index-2WXQ5Rri.js 3.7 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665
  1. function Bae(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 jw=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function pl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var BE={exports:{}},Ab={};var zU;function Hae(){if(zU)return Ab;zU=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 Ab.Fragment=e,Ab.jsx=n,Ab.jsxs=n,Ab}var BU;function $ae(){return BU||(BU=1,BE.exports=Hae()),BE.exports}var a=$ae(),HE={exports:{}},vn={};var HU;function Vae(){if(HU)return vn;HU=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"),h=Symbol.for("react.activity"),p=Symbol.iterator;function m($){return $===null||typeof $!="object"?null:($=p&&$[p]||$["@@iterator"],typeof $=="function"?$:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},y=Object.assign,v={};function b($,W,ne){this.props=$,this.context=W,this.refs=v,this.updater=ne||x}b.prototype.isReactComponent={},b.prototype.setState=function($,W){if(typeof $!="object"&&typeof $!="function"&&$!=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,$,W,"setState")},b.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function S(){}S.prototype=b.prototype;function N($,W,ne){this.props=$,this.context=W,this.refs=v,this.updater=ne||x}var T=N.prototype=new S;T.constructor=N,y(T,b.prototype),T.isPureReactComponent=!0;var k=Array.isArray;function C(){}var E={H:null,A:null,T:null,S:null},P=Object.prototype.hasOwnProperty;function A($,W,ne){var re=ne.ref;return{$$typeof:t,type:$,key:W,ref:re!==void 0?re:null,props:ne}}function D($,W){return A($.type,W,$.props)}function I($){return typeof $=="object"&&$!==null&&$.$$typeof===t}function L($){var W={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(ne){return W[ne]})}var U=/\/+/g;function j($,W){return typeof $=="object"&&$!==null&&$.key!=null?L(""+$.key):W.toString(36)}function V($){switch($.status){case"fulfilled":return $.value;case"rejected":throw $.reason;default:switch(typeof $.status=="string"?$.then(C,C):($.status="pending",$.then(function(W){$.status==="pending"&&($.status="fulfilled",$.value=W)},function(W){$.status==="pending"&&($.status="rejected",$.reason=W)})),$.status){case"fulfilled":return $.value;case"rejected":throw $.reason}}throw $}function K($,W,ne,re,ge){var me=typeof $;(me==="undefined"||me==="boolean")&&($=null);var ue=!1;if($===null)ue=!0;else switch(me){case"bigint":case"string":case"number":ue=!0;break;case"object":switch($.$$typeof){case t:case e:ue=!0;break;case d:return ue=$._init,K(ue($._payload),W,ne,re,ge)}}if(ue)return ge=ge($),ue=re===""?"."+j($,0):re,k(ge)?(ne="",ue!=null&&(ne=ue.replace(U,"$&/")+"/"),K(ge,W,ne,"",function(Ce){return Ce})):ge!=null&&(I(ge)&&(ge=D(ge,ne+(ge.key==null||$&&$.key===ge.key?"":(""+ge.key).replace(U,"$&/")+"/")+ue)),W.push(ge)),1;ue=0;var Te=re===""?".":re+":";if(k($))for(var ie=0;ie<$.length;ie++)re=$[ie],me=Te+j(re,ie),ue+=K(re,W,ne,me,ge);else if(ie=m($),typeof ie=="function")for($=ie.call($),ie=0;!(re=$.next()).done;)re=re.value,me=Te+j(re,ie++),ue+=K(re,W,ne,me,ge);else if(me==="object"){if(typeof $.then=="function")return K(V($),W,ne,re,ge);throw W=String($),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.")}return ue}function z($,W,ne){if($==null)return $;var re=[],ge=0;return K($,re,"","",function(me){return W.call(ne,me,ge++)}),re}function X($){if($._status===-1){var W=$._result;W=W(),W.then(function(ne){($._status===0||$._status===-1)&&($._status=1,$._result=ne)},function(ne){($._status===0||$._status===-1)&&($._status=2,$._result=ne)}),$._status===-1&&($._status=0,$._result=W)}if($._status===1)return $._result.default;throw $._result}var Y=typeof reportError=="function"?reportError:function($){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var W=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof $=="object"&&$!==null&&typeof $.message=="string"?String($.message):String($),error:$});if(!window.dispatchEvent(W))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",$);return}console.error($)},te={map:z,forEach:function($,W,ne){z($,function(){W.apply(this,arguments)},ne)},count:function($){var W=0;return z($,function(){W++}),W},toArray:function($){return z($,function(W){return W})||[]},only:function($){if(!I($))throw Error("React.Children.only expected to receive a single React element child.");return $}};return vn.Activity=h,vn.Children=te,vn.Component=b,vn.Fragment=n,vn.Profiler=i,vn.PureComponent=N,vn.StrictMode=r,vn.Suspense=c,vn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=E,vn.__COMPILER_RUNTIME={__proto__:null,c:function($){return E.H.useMemoCache($)}},vn.cache=function($){return function(){return $.apply(null,arguments)}},vn.cacheSignal=function(){return null},vn.cloneElement=function($,W,ne){if($==null)throw Error("The argument must be a React element, but you passed "+$+".");var re=y({},$.props),ge=$.key;if(W!=null)for(me in W.key!==void 0&&(ge=""+W.key),W)!P.call(W,me)||me==="key"||me==="__self"||me==="__source"||me==="ref"&&W.ref===void 0||(re[me]=W[me]);var me=arguments.length-2;if(me===1)re.children=ne;else if(1<me){for(var ue=Array(me),Te=0;Te<me;Te++)ue[Te]=arguments[Te+2];re.children=ue}return A($.type,ge,re)},vn.createContext=function($){return $={$$typeof:o,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null},$.Provider=$,$.Consumer={$$typeof:s,_context:$},$},vn.createElement=function($,W,ne){var re,ge={},me=null;if(W!=null)for(re in W.key!==void 0&&(me=""+W.key),W)P.call(W,re)&&re!=="key"&&re!=="__self"&&re!=="__source"&&(ge[re]=W[re]);var ue=arguments.length-2;if(ue===1)ge.children=ne;else if(1<ue){for(var Te=Array(ue),ie=0;ie<ue;ie++)Te[ie]=arguments[ie+2];ge.children=Te}if($&&$.defaultProps)for(re in ue=$.defaultProps,ue)ge[re]===void 0&&(ge[re]=ue[re]);return A($,me,ge)},vn.createRef=function(){return{current:null}},vn.forwardRef=function($){return{$$typeof:l,render:$}},vn.isValidElement=I,vn.lazy=function($){return{$$typeof:d,_payload:{_status:-1,_result:$},_init:X}},vn.memo=function($,W){return{$$typeof:u,type:$,compare:W===void 0?null:W}},vn.startTransition=function($){var W=E.T,ne={};E.T=ne;try{var re=$(),ge=E.S;ge!==null&&ge(ne,re),typeof re=="object"&&re!==null&&typeof re.then=="function"&&re.then(C,Y)}catch(me){Y(me)}finally{W!==null&&ne.types!==null&&(W.types=ne.types),E.T=W}},vn.unstable_useCacheRefresh=function(){return E.H.useCacheRefresh()},vn.use=function($){return E.H.use($)},vn.useActionState=function($,W,ne){return E.H.useActionState($,W,ne)},vn.useCallback=function($,W){return E.H.useCallback($,W)},vn.useContext=function($){return E.H.useContext($)},vn.useDebugValue=function(){},vn.useDeferredValue=function($,W){return E.H.useDeferredValue($,W)},vn.useEffect=function($,W){return E.H.useEffect($,W)},vn.useEffectEvent=function($){return E.H.useEffectEvent($)},vn.useId=function(){return E.H.useId()},vn.useImperativeHandle=function($,W,ne){return E.H.useImperativeHandle($,W,ne)},vn.useInsertionEffect=function($,W){return E.H.useInsertionEffect($,W)},vn.useLayoutEffect=function($,W){return E.H.useLayoutEffect($,W)},vn.useMemo=function($,W){return E.H.useMemo($,W)},vn.useOptimistic=function($,W){return E.H.useOptimistic($,W)},vn.useReducer=function($,W,ne){return E.H.useReducer($,W,ne)},vn.useRef=function($){return E.H.useRef($)},vn.useState=function($){return E.H.useState($)},vn.useSyncExternalStore=function($,W,ne){return E.H.useSyncExternalStore($,W,ne)},vn.useTransition=function(){return E.H.useTransition()},vn.version="19.2.0",vn}var $U;function xx(){return $U||($U=1,HE.exports=Vae()),HE.exports}var _=xx();const ei=pl(_),Gae=Bae({__proto__:null,default:ei},[_]);var $E={exports:{}},Cb={},VE={exports:{}},GE={};var VU;function qae(){return VU||(VU=1,(function(t){function e(K,z){var X=K.length;K.push(z);e:for(;0<X;){var Y=X-1>>>1,te=K[Y];if(0<i(te,z))K[Y]=z,K[X]=te,X=Y;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var z=K[0],X=K.pop();if(X!==z){K[0]=X;e:for(var Y=0,te=K.length,$=te>>>1;Y<$;){var W=2*(Y+1)-1,ne=K[W],re=W+1,ge=K[re];if(0>i(ne,X))re<te&&0>i(ge,ne)?(K[Y]=ge,K[re]=X,Y=re):(K[Y]=ne,K[W]=X,Y=W);else if(re<te&&0>i(ge,X))K[Y]=ge,K[re]=X,Y=re;else break e}}return z}function i(K,z){var X=K.sortIndex-z.sortIndex;return X!==0?X:K.id-z.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,h=null,p=3,m=!1,x=!1,y=!1,v=!1,b=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;function T(K){for(var z=n(u);z!==null;){if(z.callback===null)r(u);else if(z.startTime<=K)r(u),z.sortIndex=z.expirationTime,e(c,z);else break;z=n(u)}}function k(K){if(y=!1,T(K),!x)if(n(c)!==null)x=!0,C||(C=!0,L());else{var z=n(u);z!==null&&V(k,z.startTime-K)}}var C=!1,E=-1,P=5,A=-1;function D(){return v?!0:!(t.unstable_now()-A<P)}function I(){if(v=!1,C){var K=t.unstable_now();A=K;var z=!0;try{e:{x=!1,y&&(y=!1,S(E),E=-1),m=!0;var X=p;try{t:{for(T(K),h=n(c);h!==null&&!(h.expirationTime>K&&D());){var Y=h.callback;if(typeof Y=="function"){h.callback=null,p=h.priorityLevel;var te=Y(h.expirationTime<=K);if(K=t.unstable_now(),typeof te=="function"){h.callback=te,T(K),z=!0;break t}h===n(c)&&r(c),T(K)}else r(c);h=n(c)}if(h!==null)z=!0;else{var $=n(u);$!==null&&V(k,$.startTime-K),z=!1}}break e}finally{h=null,p=X,m=!1}z=void 0}}finally{z?L():C=!1}}}var L;if(typeof N=="function")L=function(){N(I)};else if(typeof MessageChannel<"u"){var U=new MessageChannel,j=U.port2;U.port1.onmessage=I,L=function(){j.postMessage(null)}}else L=function(){b(I,0)};function V(K,z){E=b(function(){K(t.unstable_now())},z)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(K){K.callback=null},t.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):P=0<K?Math.floor(1e3/K):5},t.unstable_getCurrentPriorityLevel=function(){return p},t.unstable_next=function(K){switch(p){case 1:case 2:case 3:var z=3;break;default:z=p}var X=p;p=z;try{return K()}finally{p=X}},t.unstable_requestPaint=function(){v=!0},t.unstable_runWithPriority=function(K,z){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var X=p;p=K;try{return z()}finally{p=X}},t.unstable_scheduleCallback=function(K,z,X){var Y=t.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?Y+X:Y):X=Y,K){case 1:var te=-1;break;case 2:te=250;break;case 5:te=1073741823;break;case 4:te=1e4;break;default:te=5e3}return te=X+te,K={id:d++,callback:z,priorityLevel:K,startTime:X,expirationTime:te,sortIndex:-1},X>Y?(K.sortIndex=X,e(u,K),n(c)===null&&K===n(u)&&(y?(S(E),E=-1):y=!0,V(k,X-Y))):(K.sortIndex=te,e(c,K),x||m||(x=!0,C||(C=!0,L()))),K},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(K){var z=p;return function(){var X=p;p=z;try{return K.apply(this,arguments)}finally{p=X}}}})(GE)),GE}var GU;function Wae(){return GU||(GU=1,VE.exports=qae()),VE.exports}var qE={exports:{}},$a={};var qU;function Kae(){if(qU)return $a;qU=1;var t=xx();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 h=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:h==null?null:""+h,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 $a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,$a.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)},$a.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()}},$a.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))},$a.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},$a.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,h=l(d,u.crossOrigin),p=typeof u.integrity=="string"?u.integrity:void 0,m=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:h,integrity:p,fetchPriority:m}):d==="script"&&r.d.X(c,{crossOrigin:h,integrity:p,fetchPriority:m,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},$a.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)},$a.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,h=l(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:h,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})}},$a.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)},$a.requestFormReset=function(c){r.d.r(c)},$a.unstable_batchedUpdates=function(c,u){return c(u)},$a.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},$a.useFormStatus=function(){return o.H.useHostTransitionStatus()},$a.version="19.2.0",$a}var WU;function Tq(){if(WU)return qE.exports;WU=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(),qE.exports=Kae(),qE.exports}var KU;function Xae(){if(KU)return Cb;KU=1;var t=Wae(),e=xx(),n=Tq();function r(f){var g="https://react.dev/errors/"+f;if(1<arguments.length){g+="?args[]="+encodeURIComponent(arguments[1]);for(var w=2;w<arguments.length;w++)g+="&args[]="+encodeURIComponent(arguments[w])}return"Minified React error #"+f+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(f){return!(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)}function s(f){var g=f,w=f;if(f.alternate)for(;g.return;)g=g.return;else{f=g;do g=f,(g.flags&4098)!==0&&(w=g.return),f=g.return;while(f)}return g.tag===3?w:null}function o(f){if(f.tag===13){var g=f.memoizedState;if(g===null&&(f=f.alternate,f!==null&&(g=f.memoizedState)),g!==null)return g.dehydrated}return null}function l(f){if(f.tag===31){var g=f.memoizedState;if(g===null&&(f=f.alternate,f!==null&&(g=f.memoizedState)),g!==null)return g.dehydrated}return null}function c(f){if(s(f)!==f)throw Error(r(188))}function u(f){var g=f.alternate;if(!g){if(g=s(f),g===null)throw Error(r(188));return g!==f?null:f}for(var w=f,M=g;;){var R=w.return;if(R===null)break;var F=R.alternate;if(F===null){if(M=R.return,M!==null){w=M;continue}break}if(R.child===F.child){for(F=R.child;F;){if(F===w)return c(R),f;if(F===M)return c(R),g;F=F.sibling}throw Error(r(188))}if(w.return!==M.return)w=R,M=F;else{for(var Z=!1,ve=R.child;ve;){if(ve===w){Z=!0,w=R,M=F;break}if(ve===M){Z=!0,M=R,w=F;break}ve=ve.sibling}if(!Z){for(ve=F.child;ve;){if(ve===w){Z=!0,w=F,M=R;break}if(ve===M){Z=!0,M=F,w=R;break}ve=ve.sibling}if(!Z)throw Error(r(189))}}if(w.alternate!==M)throw Error(r(190))}if(w.tag!==3)throw Error(r(188));return w.stateNode.current===w?f:g}function d(f){var g=f.tag;if(g===5||g===26||g===27||g===6)return f;for(f=f.child;f!==null;){if(g=d(f),g!==null)return g;f=f.sibling}return null}var h=Object.assign,p=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),N=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),k=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),I=Symbol.iterator;function L(f){return f===null||typeof f!="object"?null:(f=I&&f[I]||f["@@iterator"],typeof f=="function"?f:null)}var U=Symbol.for("react.client.reference");function j(f){if(f==null)return null;if(typeof f=="function")return f.$$typeof===U?null:f.displayName||f.name||null;if(typeof f=="string")return f;switch(f){case y:return"Fragment";case b:return"Profiler";case v:return"StrictMode";case k:return"Suspense";case C:return"SuspenseList";case A:return"Activity"}if(typeof f=="object")switch(f.$$typeof){case x:return"Portal";case N:return f.displayName||"Context";case S:return(f._context.displayName||"Context")+".Consumer";case T:var g=f.render;return f=f.displayName,f||(f=g.displayName||g.name||"",f=f!==""?"ForwardRef("+f+")":"ForwardRef"),f;case E:return g=f.displayName||null,g!==null?g:j(f.type)||"Memo";case P:g=f._payload,f=f._init;try{return j(f(g))}catch{}}return null}var V=Array.isArray,K=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X={pending:!1,data:null,method:null,action:null},Y=[],te=-1;function $(f){return{current:f}}function W(f){0>te||(f.current=Y[te],Y[te]=null,te--)}function ne(f,g){te++,Y[te]=f.current,f.current=g}var re=$(null),ge=$(null),me=$(null),ue=$(null);function Te(f,g){switch(ne(me,g),ne(ge,f),ne(re,null),g.nodeType){case 9:case 11:f=(f=g.documentElement)&&(f=f.namespaceURI)?cU(f):0;break;default:if(f=g.tagName,g=g.namespaceURI)g=cU(g),f=uU(g,f);else switch(f){case"svg":f=1;break;case"math":f=2;break;default:f=0}}W(re),ne(re,f)}function ie(){W(re),W(ge),W(me)}function Ce(f){f.memoizedState!==null&&ne(ue,f);var g=re.current,w=uU(g,f.type);g!==w&&(ne(ge,f),ne(re,w))}function Fe(f){ge.current===f&&(W(re),W(ge)),ue.current===f&&(W(ue),Mb._currentValue=X)}var xe,Ze;function G(f){if(xe===void 0)try{throw Error()}catch(w){var g=w.stack.trim().match(/\n( *(at )?)/);xe=g&&g[1]||"",Ze=-1<w.stack.indexOf(`
  2. at`)?" (<anonymous>)":-1<w.stack.indexOf("@")?"@unknown:0:0":""}return`
  3. `+xe+f+Ze}var Q=!1;function de(f,g){if(!f||Q)return"";Q=!0;var w=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var M={DetermineComponentFrameRoot:function(){try{if(g){var wt=function(){throw Error()};if(Object.defineProperty(wt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(wt,[])}catch(xt){var ft=xt}Reflect.construct(f,[],wt)}else{try{wt.call()}catch(xt){ft=xt}f.call(wt.prototype)}}else{try{throw Error()}catch(xt){ft=xt}(wt=f())&&typeof wt.catch=="function"&&wt.catch(function(){})}}catch(xt){if(xt&&ft&&typeof xt.stack=="string")return[xt.stack,ft.stack]}return[null,null]}};M.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var R=Object.getOwnPropertyDescriptor(M.DetermineComponentFrameRoot,"name");R&&R.configurable&&Object.defineProperty(M.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var F=M.DetermineComponentFrameRoot(),Z=F[0],ve=F[1];if(Z&&ve){var Ue=Z.split(`
  4. `),lt=ve.split(`
  5. `);for(R=M=0;M<Ue.length&&!Ue[M].includes("DetermineComponentFrameRoot");)M++;for(;R<lt.length&&!lt[R].includes("DetermineComponentFrameRoot");)R++;if(M===Ue.length||R===lt.length)for(M=Ue.length-1,R=lt.length-1;1<=M&&0<=R&&Ue[M]!==lt[R];)R--;for(;1<=M&&0<=R;M--,R--)if(Ue[M]!==lt[R]){if(M!==1||R!==1)do if(M--,R--,0>R||Ue[M]!==lt[R]){var bt=`
  6. `+Ue[M].replace(" at new "," at ");return f.displayName&&bt.includes("<anonymous>")&&(bt=bt.replace("<anonymous>",f.displayName)),bt}while(1<=M&&0<=R);break}}}finally{Q=!1,Error.prepareStackTrace=w}return(w=f?f.displayName||f.name:"")?G(w):""}function q(f,g){switch(f.tag){case 26:case 27:case 5:return G(f.type);case 16:return G("Lazy");case 13:return f.child!==g&&g!==null?G("Suspense Fallback"):G("Suspense");case 19:return G("SuspenseList");case 0:case 15:return de(f.type,!1);case 11:return de(f.type.render,!1);case 1:return de(f.type,!0);case 31:return G("Activity");default:return""}}function ee(f){try{var g="",w=null;do g+=q(f,w),w=f,f=f.return;while(f);return g}catch(M){return`
  7. Error generating stack: `+M.message+`
  8. `+M.stack}}var B=Object.prototype.hasOwnProperty,he=t.unstable_scheduleCallback,ke=t.unstable_cancelCallback,pe=t.unstable_shouldYield,H=t.unstable_requestPaint,O=t.unstable_now,J=t.unstable_getCurrentPriorityLevel,le=t.unstable_ImmediatePriority,Se=t.unstable_UserBlockingPriority,we=t.unstable_NormalPriority,ae=t.unstable_LowPriority,Le=t.unstable_IdlePriority,Be=t.log,Ve=t.unstable_setDisableYieldValue,He=null,be=null;function Pe(f){if(typeof Be=="function"&&Ve(f),be&&typeof be.setStrictMode=="function")try{be.setStrictMode(He,f)}catch{}}var Ie=Math.clz32?Math.clz32:Me,_e=Math.log,Ke=Math.LN2;function Me(f){return f>>>=0,f===0?32:31-(_e(f)/Ke|0)|0}var it=256,Ee=262144,Xe=4194304;function ze(f){var g=f&42;if(g!==0)return g;switch(f&-f){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 f&261888;case 262144:case 524288:case 1048576:case 2097152:return f&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return f&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return f}}function ce(f,g,w){var M=f.pendingLanes;if(M===0)return 0;var R=0,F=f.suspendedLanes,Z=f.pingedLanes;f=f.warmLanes;var ve=M&134217727;return ve!==0?(M=ve&~F,M!==0?R=ze(M):(Z&=ve,Z!==0?R=ze(Z):w||(w=ve&~f,w!==0&&(R=ze(w))))):(ve=M&~F,ve!==0?R=ze(ve):Z!==0?R=ze(Z):w||(w=M&~f,w!==0&&(R=ze(w)))),R===0?0:g!==0&&g!==R&&(g&F)===0&&(F=R&-R,w=g&-g,F>=w||F===32&&(w&4194048)!==0)?g:R}function $e(f,g){return(f.pendingLanes&~(f.suspendedLanes&~f.pingedLanes)&g)===0}function ye(f,g){switch(f){case 1:case 2:case 4:case 8:case 64:return g+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return g+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Je(){var f=Xe;return Xe<<=1,(Xe&62914560)===0&&(Xe=4194304),f}function at(f){for(var g=[],w=0;31>w;w++)g.push(f);return g}function jt(f,g){f.pendingLanes|=g,g!==268435456&&(f.suspendedLanes=0,f.pingedLanes=0,f.warmLanes=0)}function Dt(f,g,w,M,R,F){var Z=f.pendingLanes;f.pendingLanes=w,f.suspendedLanes=0,f.pingedLanes=0,f.warmLanes=0,f.expiredLanes&=w,f.entangledLanes&=w,f.errorRecoveryDisabledLanes&=w,f.shellSuspendCounter=0;var ve=f.entanglements,Ue=f.expirationTimes,lt=f.hiddenUpdates;for(w=Z&~w;0<w;){var bt=31-Ie(w),wt=1<<bt;ve[bt]=0,Ue[bt]=-1;var ft=lt[bt];if(ft!==null)for(lt[bt]=null,bt=0;bt<ft.length;bt++){var xt=ft[bt];xt!==null&&(xt.lane&=-536870913)}w&=~wt}M!==0&&yn(f,M,0),F!==0&&R===0&&f.tag!==0&&(f.suspendedLanes|=F&~(Z&~g))}function yn(f,g,w){f.pendingLanes|=g,f.suspendedLanes&=~g;var M=31-Ie(g);f.entangledLanes|=g,f.entanglements[M]=f.entanglements[M]|1073741824|w&261930}function cn(f,g){var w=f.entangledLanes|=g;for(f=f.entanglements;w;){var M=31-Ie(w),R=1<<M;R&g|f[M]&g&&(f[M]|=g),w&=~R}}function rr(f,g){var w=g&-g;return w=(w&42)!==0?1:Vn(w),(w&(f.suspendedLanes|g))!==0?0:w}function Vn(f){switch(f){case 2:f=1;break;case 8:f=4;break;case 32:f=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:f=128;break;case 268435456:f=134217728;break;default:f=0}return f}function Jn(f){return f&=-f,2<f?8<f?(f&134217727)!==0?32:268435456:8:2}function xn(){var f=z.p;return f!==0?f:(f=window.event,f===void 0?32:DU(f.type))}function sr(f,g){var w=z.p;try{return z.p=f,g()}finally{z.p=w}}var Gn=Math.random().toString(36).slice(2),Xn="__reactFiber$"+Gn,Nn="__reactProps$"+Gn,hi="__reactContainer$"+Gn,ai="__reactEvents$"+Gn,je="__reactListeners$"+Gn,tt="__reactHandles$"+Gn,dt="__reactResources$"+Gn,ht="__reactMarker$"+Gn;function ut(f){delete f[Xn],delete f[Nn],delete f[ai],delete f[je],delete f[tt]}function Et(f){var g=f[Xn];if(g)return g;for(var w=f.parentNode;w;){if(g=w[hi]||w[Xn]){if(w=g.alternate,g.child!==null||w!==null&&w.child!==null)for(f=xU(f);f!==null;){if(w=f[Xn])return w;f=xU(f)}return g}f=w,w=f.parentNode}return null}function fe(f){if(f=f[Xn]||f[hi]){var g=f.tag;if(g===5||g===6||g===13||g===31||g===26||g===27||g===3)return f}return null}function Re(f){var g=f.tag;if(g===5||g===26||g===27||g===6)return f.stateNode;throw Error(r(33))}function Ge(f){var g=f[dt];return g||(g=f[dt]={hoistableStyles:new Map,hoistableScripts:new Map}),g}function Ne(f){f[ht]=!0}var Oe=new Set,nt={};function Ye(f,g){Tt(f,g),Tt(f+"Capture",g)}function Tt(f,g){for(nt[f]=g,f=0;f<g.length;f++)Oe.add(g[f])}var At=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]*$"),It={},Rt={};function Mt(f){return B.call(Rt,f)?!0:B.call(It,f)?!1:At.test(f)?Rt[f]=!0:(It[f]=!0,!1)}function en(f,g,w){if(Mt(g))if(w===null)f.removeAttribute(g);else{switch(typeof w){case"undefined":case"function":case"symbol":f.removeAttribute(g);return;case"boolean":var M=g.toLowerCase().slice(0,5);if(M!=="data-"&&M!=="aria-"){f.removeAttribute(g);return}}f.setAttribute(g,""+w)}}function Ht(f,g,w){if(w===null)f.removeAttribute(g);else{switch(typeof w){case"undefined":case"function":case"symbol":case"boolean":f.removeAttribute(g);return}f.setAttribute(g,""+w)}}function hn(f,g,w,M){if(M===null)f.removeAttribute(w);else{switch(typeof M){case"undefined":case"function":case"symbol":case"boolean":f.removeAttribute(w);return}f.setAttributeNS(g,w,""+M)}}function un(f){switch(typeof f){case"bigint":case"boolean":case"number":case"string":case"undefined":return f;case"object":return f;default:return""}}function Mn(f){var g=f.type;return(f=f.nodeName)&&f.toLowerCase()==="input"&&(g==="checkbox"||g==="radio")}function Gt(f,g,w){var M=Object.getOwnPropertyDescriptor(f.constructor.prototype,g);if(!f.hasOwnProperty(g)&&typeof M<"u"&&typeof M.get=="function"&&typeof M.set=="function"){var R=M.get,F=M.set;return Object.defineProperty(f,g,{configurable:!0,get:function(){return R.call(this)},set:function(Z){w=""+Z,F.call(this,Z)}}),Object.defineProperty(f,g,{enumerable:M.enumerable}),{getValue:function(){return w},setValue:function(Z){w=""+Z},stopTracking:function(){f._valueTracker=null,delete f[g]}}}}function on(f){if(!f._valueTracker){var g=Mn(f)?"checked":"value";f._valueTracker=Gt(f,g,""+f[g])}}function dn(f){if(!f)return!1;var g=f._valueTracker;if(!g)return!0;var w=g.getValue(),M="";return f&&(M=Mn(f)?f.checked?"true":"false":f.value),f=M,f!==w?(g.setValue(f),!0):!1}function Yt(f){if(f=f||(typeof document<"u"?document:void 0),typeof f>"u")return null;try{return f.activeElement||f.body}catch{return f.body}}var ir=/[\n"\\]/g;function Pn(f){return f.replace(ir,function(g){return"\\"+g.charCodeAt(0).toString(16)+" "})}function si(f,g,w,M,R,F,Z,ve){f.name="",Z!=null&&typeof Z!="function"&&typeof Z!="symbol"&&typeof Z!="boolean"?f.type=Z:f.removeAttribute("type"),g!=null?Z==="number"?(g===0&&f.value===""||f.value!=g)&&(f.value=""+un(g)):f.value!==""+un(g)&&(f.value=""+un(g)):Z!=="submit"&&Z!=="reset"||f.removeAttribute("value"),g!=null?dr(f,Z,un(g)):w!=null?dr(f,Z,un(w)):M!=null&&f.removeAttribute("value"),R==null&&F!=null&&(f.defaultChecked=!!F),R!=null&&(f.checked=R&&typeof R!="function"&&typeof R!="symbol"),ve!=null&&typeof ve!="function"&&typeof ve!="symbol"&&typeof ve!="boolean"?f.name=""+un(ve):f.removeAttribute("name")}function ar(f,g,w,M,R,F,Z,ve){if(F!=null&&typeof F!="function"&&typeof F!="symbol"&&typeof F!="boolean"&&(f.type=F),g!=null||w!=null){if(!(F!=="submit"&&F!=="reset"||g!=null)){on(f);return}w=w!=null?""+un(w):"",g=g!=null?""+un(g):w,ve||g===f.value||(f.value=g),f.defaultValue=g}M=M??R,M=typeof M!="function"&&typeof M!="symbol"&&!!M,f.checked=ve?f.checked:!!M,f.defaultChecked=!!M,Z!=null&&typeof Z!="function"&&typeof Z!="symbol"&&typeof Z!="boolean"&&(f.name=Z),on(f)}function dr(f,g,w){g==="number"&&Yt(f.ownerDocument)===f||f.defaultValue===""+w||(f.defaultValue=""+w)}function rt(f,g,w,M){if(f=f.options,g){g={};for(var R=0;R<w.length;R++)g["$"+w[R]]=!0;for(w=0;w<f.length;w++)R=g.hasOwnProperty("$"+f[w].value),f[w].selected!==R&&(f[w].selected=R),R&&M&&(f[w].defaultSelected=!0)}else{for(w=""+un(w),g=null,R=0;R<f.length;R++){if(f[R].value===w){f[R].selected=!0,M&&(f[R].defaultSelected=!0);return}g!==null||f[R].disabled||(g=f[R])}g!==null&&(g.selected=!0)}}function Pt(f,g,w){if(g!=null&&(g=""+un(g),g!==f.value&&(f.value=g),w==null)){f.defaultValue!==g&&(f.defaultValue=g);return}f.defaultValue=w!=null?""+un(w):""}function qt(f,g,w,M){if(g==null){if(M!=null){if(w!=null)throw Error(r(92));if(V(M)){if(1<M.length)throw Error(r(93));M=M[0]}w=M}w==null&&(w=""),g=w}w=un(g),f.defaultValue=w,M=f.textContent,M===w&&M!==""&&M!==null&&(f.value=M),on(f)}function vt(f,g){if(g){var w=f.firstChild;if(w&&w===f.lastChild&&w.nodeType===3){w.nodeValue=g;return}}f.textContent=g}var wn=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 Fr(f,g,w){var M=g.indexOf("--")===0;w==null||typeof w=="boolean"||w===""?M?f.setProperty(g,""):g==="float"?f.cssFloat="":f[g]="":M?f.setProperty(g,w):typeof w!="number"||w===0||wn.has(g)?g==="float"?f.cssFloat=w:f[g]=(""+w).trim():f[g]=w+"px"}function Qr(f,g,w){if(g!=null&&typeof g!="object")throw Error(r(62));if(f=f.style,w!=null){for(var M in w)!w.hasOwnProperty(M)||g!=null&&g.hasOwnProperty(M)||(M.indexOf("--")===0?f.setProperty(M,""):M==="float"?f.cssFloat="":f[M]="");for(var R in g)M=g[R],g.hasOwnProperty(R)&&w[R]!==M&&Fr(f,R,M)}else for(var F in g)g.hasOwnProperty(F)&&Fr(f,F,g[F])}function Br(f){if(f.indexOf("-")===-1)return!1;switch(f){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 Ys=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"]]),nn=/^[\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 ln(f){return nn.test(""+f)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":f}function Si(){}var Es=null;function Eo(f){return f=f.target||f.srcElement||window,f.correspondingUseElement&&(f=f.correspondingUseElement),f.nodeType===3?f.parentNode:f}var To=null,Ao=null;function Ts(f){var g=fe(f);if(g&&(f=g.stateNode)){var w=f[Nn]||null;e:switch(f=g.stateNode,g.type){case"input":if(si(f,w.value,w.defaultValue,w.defaultValue,w.checked,w.defaultChecked,w.type,w.name),g=w.name,w.type==="radio"&&g!=null){for(w=f;w.parentNode;)w=w.parentNode;for(w=w.querySelectorAll('input[name="'+Pn(""+g)+'"][type="radio"]'),g=0;g<w.length;g++){var M=w[g];if(M!==f&&M.form===f.form){var R=M[Nn]||null;if(!R)throw Error(r(90));si(M,R.value,R.defaultValue,R.defaultValue,R.checked,R.defaultChecked,R.type,R.name)}}for(g=0;g<w.length;g++)M=w[g],M.form===f.form&&dn(M)}break e;case"textarea":Pt(f,w.value,w.defaultValue);break e;case"select":g=w.value,g!=null&&rt(f,!!w.multiple,g,!1)}}}var Ni=!1;function Qs(f,g,w){if(Ni)return f(g,w);Ni=!0;try{var M=f(g);return M}finally{if(Ni=!1,(To!==null||Ao!==null)&&(cw(),To&&(g=To,f=Ao,Ao=To=null,Ts(g),f)))for(g=0;g<f.length;g++)Ts(f[g])}}function da(f,g){var w=f.stateNode;if(w===null)return null;var M=w[Nn]||null;if(M===null)return null;w=M[g];e:switch(g){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(M=!M.disabled)||(f=f.type,M=!(f==="button"||f==="input"||f==="select"||f==="textarea")),f=!M;break e;default:f=!1}if(f)return null;if(w&&typeof w!="function")throw Error(r(231,g,typeof w));return w}var Hr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Bx=!1;if(Hr)try{var Gh={};Object.defineProperty(Gh,"passive",{get:function(){Bx=!0}}),window.addEventListener("test",Gh,Gh),window.removeEventListener("test",Gh,Gh)}catch{Bx=!1}var Gl=null,Hx=null,Rm=null;function Om(){if(Rm)return Rm;var f,g=Hx,w=g.length,M,R="value"in Gl?Gl.value:Gl.textContent,F=R.length;for(f=0;f<w&&g[f]===R[f];f++);var Z=w-f;for(M=1;M<=Z&&g[w-M]===R[F-M];M++);return Rm=R.slice(f,1<M?1-M:void 0)}function qh(f){var g=f.keyCode;return"charCode"in f?(f=f.charCode,f===0&&g===13&&(f=13)):f=g,f===10&&(f=13),32<=f||f===13?f:0}function Zu(){return!0}function Pc(){return!1}function ha(f){function g(w,M,R,F,Z){this._reactName=w,this._targetInst=R,this.type=M,this.nativeEvent=F,this.target=Z,this.currentTarget=null;for(var ve in f)f.hasOwnProperty(ve)&&(w=f[ve],this[ve]=w?w(F):F[ve]);return this.isDefaultPrevented=(F.defaultPrevented!=null?F.defaultPrevented:F.returnValue===!1)?Zu:Pc,this.isPropagationStopped=Pc,this}return h(g.prototype,{preventDefault:function(){this.defaultPrevented=!0;var w=this.nativeEvent;w&&(w.preventDefault?w.preventDefault():typeof w.returnValue!="unknown"&&(w.returnValue=!1),this.isDefaultPrevented=Zu)},stopPropagation:function(){var w=this.nativeEvent;w&&(w.stopPropagation?w.stopPropagation():typeof w.cancelBubble!="unknown"&&(w.cancelBubble=!0),this.isPropagationStopped=Zu)},persist:function(){},isPersistent:Zu}),g}var bl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(f){return f.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ql=ha(bl),yl=h({},bl,{view:0,detail:0}),Lm=ha(yl),Fm,Im,Ju,fn=h({},yl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Gx,button:0,buttons:0,relatedTarget:function(f){return f.relatedTarget===void 0?f.fromElement===f.srcElement?f.toElement:f.fromElement:f.relatedTarget},movementX:function(f){return"movementX"in f?f.movementX:(f!==Ju&&(Ju&&f.type==="mousemove"?(Fm=f.screenX-Ju.screenX,Im=f.screenY-Ju.screenY):Im=Fm=0,Ju=f),Fm)},movementY:function(f){return"movementY"in f?f.movementY:Im}}),Mv=ha(fn),$x=h({},fn,{dataTransfer:0}),kv=ha($x),Vx=h({},yl,{relatedTarget:0}),Um=ha(Vx),q2=h({},bl,{animationName:0,elapsedTime:0,pseudoElement:0}),Ev=ha(q2),se=h({},bl,{clipboardData:function(f){return"clipboardData"in f?f.clipboardData:window.clipboardData}}),_t=ha(se),Ln=h({},bl,{data:0}),er=ha(Ln),Co={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ed={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"},as={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ss(f){var g=this.nativeEvent;return g.getModifierState?g.getModifierState(f):(f=as[f])?!!g[f]:!1}function Gx(){return ss}var fF=h({},yl,{key:function(f){if(f.key){var g=Co[f.key]||f.key;if(g!=="Unidentified")return g}return f.type==="keypress"?(f=qh(f),f===13?"Enter":String.fromCharCode(f)):f.type==="keydown"||f.type==="keyup"?ed[f.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Gx,charCode:function(f){return f.type==="keypress"?qh(f):0},keyCode:function(f){return f.type==="keydown"||f.type==="keyup"?f.keyCode:0},which:function(f){return f.type==="keypress"?qh(f):f.type==="keydown"||f.type==="keyup"?f.keyCode:0}}),Jre=ha(fF),eie=h({},fn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),mF=ha(eie),tie=h({},yl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Gx}),nie=ha(tie),rie=h({},bl,{propertyName:0,elapsedTime:0,pseudoElement:0}),iie=ha(rie),aie=h({},fn,{deltaX:function(f){return"deltaX"in f?f.deltaX:"wheelDeltaX"in f?-f.wheelDeltaX:0},deltaY:function(f){return"deltaY"in f?f.deltaY:"wheelDeltaY"in f?-f.wheelDeltaY:"wheelDelta"in f?-f.wheelDelta:0},deltaZ:0,deltaMode:0}),sie=ha(aie),oie=h({},bl,{newState:0,oldState:0}),lie=ha(oie),cie=[9,13,27,32],W2=Hr&&"CompositionEvent"in window,qx=null;Hr&&"documentMode"in document&&(qx=document.documentMode);var uie=Hr&&"TextEvent"in window&&!qx,pF=Hr&&(!W2||qx&&8<qx&&11>=qx),gF=" ",xF=!1;function bF(f,g){switch(f){case"keyup":return cie.indexOf(g.keyCode)!==-1;case"keydown":return g.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function yF(f){return f=f.detail,typeof f=="object"&&"data"in f?f.data:null}var zm=!1;function die(f,g){switch(f){case"compositionend":return yF(g);case"keypress":return g.which!==32?null:(xF=!0,gF);case"textInput":return f=g.data,f===gF&&xF?null:f;default:return null}}function hie(f,g){if(zm)return f==="compositionend"||!W2&&bF(f,g)?(f=Om(),Rm=Hx=Gl=null,zm=!1,f):null;switch(f){case"paste":return null;case"keypress":if(!(g.ctrlKey||g.altKey||g.metaKey)||g.ctrlKey&&g.altKey){if(g.char&&1<g.char.length)return g.char;if(g.which)return String.fromCharCode(g.which)}return null;case"compositionend":return pF&&g.locale!=="ko"?null:g.data;default:return null}}var fie={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 vF(f){var g=f&&f.nodeName&&f.nodeName.toLowerCase();return g==="input"?!!fie[f.type]:g==="textarea"}function wF(f,g,w,M){To?Ao?Ao.push(M):Ao=[M]:To=M,g=gw(g,"onChange"),0<g.length&&(w=new ql("onChange","change",null,w,M),f.push({event:w,listeners:g}))}var Wx=null,Kx=null;function mie(f){rU(f,0)}function Tv(f){var g=Re(f);if(dn(g))return f}function _F(f,g){if(f==="change")return g}var SF=!1;if(Hr){var K2;if(Hr){var X2="oninput"in document;if(!X2){var NF=document.createElement("div");NF.setAttribute("oninput","return;"),X2=typeof NF.oninput=="function"}K2=X2}else K2=!1;SF=K2&&(!document.documentMode||9<document.documentMode)}function MF(){Wx&&(Wx.detachEvent("onpropertychange",kF),Kx=Wx=null)}function kF(f){if(f.propertyName==="value"&&Tv(Kx)){var g=[];wF(g,Kx,f,Eo(f)),Qs(mie,g)}}function pie(f,g,w){f==="focusin"?(MF(),Wx=g,Kx=w,Wx.attachEvent("onpropertychange",kF)):f==="focusout"&&MF()}function gie(f){if(f==="selectionchange"||f==="keyup"||f==="keydown")return Tv(Kx)}function xie(f,g){if(f==="click")return Tv(g)}function bie(f,g){if(f==="input"||f==="change")return Tv(g)}function yie(f,g){return f===g&&(f!==0||1/f===1/g)||f!==f&&g!==g}var Zs=typeof Object.is=="function"?Object.is:yie;function Xx(f,g){if(Zs(f,g))return!0;if(typeof f!="object"||f===null||typeof g!="object"||g===null)return!1;var w=Object.keys(f),M=Object.keys(g);if(w.length!==M.length)return!1;for(M=0;M<w.length;M++){var R=w[M];if(!B.call(g,R)||!Zs(f[R],g[R]))return!1}return!0}function EF(f){for(;f&&f.firstChild;)f=f.firstChild;return f}function TF(f,g){var w=EF(f);f=0;for(var M;w;){if(w.nodeType===3){if(M=f+w.textContent.length,f<=g&&M>=g)return{node:w,offset:g-f};f=M}e:{for(;w;){if(w.nextSibling){w=w.nextSibling;break e}w=w.parentNode}w=void 0}w=EF(w)}}function AF(f,g){return f&&g?f===g?!0:f&&f.nodeType===3?!1:g&&g.nodeType===3?AF(f,g.parentNode):"contains"in f?f.contains(g):f.compareDocumentPosition?!!(f.compareDocumentPosition(g)&16):!1:!1}function CF(f){f=f!=null&&f.ownerDocument!=null&&f.ownerDocument.defaultView!=null?f.ownerDocument.defaultView:window;for(var g=Yt(f.document);g instanceof f.HTMLIFrameElement;){try{var w=typeof g.contentWindow.location.href=="string"}catch{w=!1}if(w)f=g.contentWindow;else break;g=Yt(f.document)}return g}function Y2(f){var g=f&&f.nodeName&&f.nodeName.toLowerCase();return g&&(g==="input"&&(f.type==="text"||f.type==="search"||f.type==="tel"||f.type==="url"||f.type==="password")||g==="textarea"||f.contentEditable==="true")}var vie=Hr&&"documentMode"in document&&11>=document.documentMode,Bm=null,Q2=null,Yx=null,Z2=!1;function jF(f,g,w){var M=w.window===w?w.document:w.nodeType===9?w:w.ownerDocument;Z2||Bm==null||Bm!==Yt(M)||(M=Bm,"selectionStart"in M&&Y2(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}),Yx&&Xx(Yx,M)||(Yx=M,M=gw(Q2,"onSelect"),0<M.length&&(g=new ql("onSelect","select",null,g,w),f.push({event:g,listeners:M}),g.target=Bm)))}function Wh(f,g){var w={};return w[f.toLowerCase()]=g.toLowerCase(),w["Webkit"+f]="webkit"+g,w["Moz"+f]="moz"+g,w}var Hm={animationend:Wh("Animation","AnimationEnd"),animationiteration:Wh("Animation","AnimationIteration"),animationstart:Wh("Animation","AnimationStart"),transitionrun:Wh("Transition","TransitionRun"),transitionstart:Wh("Transition","TransitionStart"),transitioncancel:Wh("Transition","TransitionCancel"),transitionend:Wh("Transition","TransitionEnd")},J2={},PF={};Hr&&(PF=document.createElement("div").style,"AnimationEvent"in window||(delete Hm.animationend.animation,delete Hm.animationiteration.animation,delete Hm.animationstart.animation),"TransitionEvent"in window||delete Hm.transitionend.transition);function Kh(f){if(J2[f])return J2[f];if(!Hm[f])return f;var g=Hm[f],w;for(w in g)if(g.hasOwnProperty(w)&&w in PF)return J2[f]=g[w];return f}var DF=Kh("animationend"),RF=Kh("animationiteration"),OF=Kh("animationstart"),wie=Kh("transitionrun"),_ie=Kh("transitionstart"),Sie=Kh("transitioncancel"),LF=Kh("transitionend"),FF=new Map,ek="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(" ");ek.push("scrollEnd");function vl(f,g){FF.set(f,g),Ye(g,[f])}var Av=typeof reportError=="function"?reportError:function(f){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var g=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof f=="object"&&f!==null&&typeof f.message=="string"?String(f.message):String(f),error:f});if(!window.dispatchEvent(g))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",f);return}console.error(f)},jo=[],$m=0,tk=0;function Cv(){for(var f=$m,g=tk=$m=0;g<f;){var w=jo[g];jo[g++]=null;var M=jo[g];jo[g++]=null;var R=jo[g];jo[g++]=null;var F=jo[g];if(jo[g++]=null,M!==null&&R!==null){var Z=M.pending;Z===null?R.next=R:(R.next=Z.next,Z.next=R),M.pending=R}F!==0&&IF(w,R,F)}}function jv(f,g,w,M){jo[$m++]=f,jo[$m++]=g,jo[$m++]=w,jo[$m++]=M,tk|=M,f.lanes|=M,f=f.alternate,f!==null&&(f.lanes|=M)}function nk(f,g,w,M){return jv(f,g,w,M),Pv(f)}function Xh(f,g){return jv(f,null,null,g),Pv(f)}function IF(f,g,w){f.lanes|=w;var M=f.alternate;M!==null&&(M.lanes|=w);for(var R=!1,F=f.return;F!==null;)F.childLanes|=w,M=F.alternate,M!==null&&(M.childLanes|=w),F.tag===22&&(f=F.stateNode,f===null||f._visibility&1||(R=!0)),f=F,F=F.return;return f.tag===3?(F=f.stateNode,R&&g!==null&&(R=31-Ie(w),f=F.hiddenUpdates,M=f[R],M===null?f[R]=[g]:M.push(g),g.lane=w|536870912),F):null}function Pv(f){if(50<bb)throw bb=0,dE=null,Error(r(185));for(var g=f.return;g!==null;)f=g,g=f.return;return f.tag===3?f.stateNode:null}var Vm={};function Nie(f,g,w,M){this.tag=f,this.key=w,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=g,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=M,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Js(f,g,w,M){return new Nie(f,g,w,M)}function rk(f){return f=f.prototype,!(!f||!f.isReactComponent)}function Dc(f,g){var w=f.alternate;return w===null?(w=Js(f.tag,g,f.key,f.mode),w.elementType=f.elementType,w.type=f.type,w.stateNode=f.stateNode,w.alternate=f,f.alternate=w):(w.pendingProps=g,w.type=f.type,w.flags=0,w.subtreeFlags=0,w.deletions=null),w.flags=f.flags&65011712,w.childLanes=f.childLanes,w.lanes=f.lanes,w.child=f.child,w.memoizedProps=f.memoizedProps,w.memoizedState=f.memoizedState,w.updateQueue=f.updateQueue,g=f.dependencies,w.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext},w.sibling=f.sibling,w.index=f.index,w.ref=f.ref,w.refCleanup=f.refCleanup,w}function UF(f,g){f.flags&=65011714;var w=f.alternate;return w===null?(f.childLanes=0,f.lanes=g,f.child=null,f.subtreeFlags=0,f.memoizedProps=null,f.memoizedState=null,f.updateQueue=null,f.dependencies=null,f.stateNode=null):(f.childLanes=w.childLanes,f.lanes=w.lanes,f.child=w.child,f.subtreeFlags=0,f.deletions=null,f.memoizedProps=w.memoizedProps,f.memoizedState=w.memoizedState,f.updateQueue=w.updateQueue,f.type=w.type,g=w.dependencies,f.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext}),f}function Dv(f,g,w,M,R,F){var Z=0;if(M=f,typeof f=="function")rk(f)&&(Z=1);else if(typeof f=="string")Z=Aae(f,w,re.current)?26:f==="html"||f==="head"||f==="body"?27:5;else e:switch(f){case A:return f=Js(31,w,g,R),f.elementType=A,f.lanes=F,f;case y:return Yh(w.children,R,F,g);case v:Z=8,R|=24;break;case b:return f=Js(12,w,g,R|2),f.elementType=b,f.lanes=F,f;case k:return f=Js(13,w,g,R),f.elementType=k,f.lanes=F,f;case C:return f=Js(19,w,g,R),f.elementType=C,f.lanes=F,f;default:if(typeof f=="object"&&f!==null)switch(f.$$typeof){case N:Z=10;break e;case S:Z=9;break e;case T:Z=11;break e;case E:Z=14;break e;case P:Z=16,M=null;break e}Z=29,w=Error(r(130,f===null?"null":typeof f,"")),M=null}return g=Js(Z,w,g,R),g.elementType=f,g.type=M,g.lanes=F,g}function Yh(f,g,w,M){return f=Js(7,f,M,g),f.lanes=w,f}function ik(f,g,w){return f=Js(6,f,null,g),f.lanes=w,f}function zF(f){var g=Js(18,null,null,0);return g.stateNode=f,g}function ak(f,g,w){return g=Js(4,f.children!==null?f.children:[],f.key,g),g.lanes=w,g.stateNode={containerInfo:f.containerInfo,pendingChildren:null,implementation:f.implementation},g}var BF=new WeakMap;function Po(f,g){if(typeof f=="object"&&f!==null){var w=BF.get(f);return w!==void 0?w:(g={value:f,source:g,stack:ee(g)},BF.set(f,g),g)}return{value:f,source:g,stack:ee(g)}}var Gm=[],qm=0,Rv=null,Qx=0,Do=[],Ro=0,td=null,Wl=1,Kl="";function Rc(f,g){Gm[qm++]=Qx,Gm[qm++]=Rv,Rv=f,Qx=g}function HF(f,g,w){Do[Ro++]=Wl,Do[Ro++]=Kl,Do[Ro++]=td,td=f;var M=Wl;f=Kl;var R=32-Ie(M)-1;M&=~(1<<R),w+=1;var F=32-Ie(g)+R;if(30<F){var Z=R-R%5;F=(M&(1<<Z)-1).toString(32),M>>=Z,R-=Z,Wl=1<<32-Ie(g)+R|w<<R|M,Kl=F+f}else Wl=1<<F|w<<R|M,Kl=f}function sk(f){f.return!==null&&(Rc(f,1),HF(f,1,0))}function ok(f){for(;f===Rv;)Rv=Gm[--qm],Gm[qm]=null,Qx=Gm[--qm],Gm[qm]=null;for(;f===td;)td=Do[--Ro],Do[Ro]=null,Kl=Do[--Ro],Do[Ro]=null,Wl=Do[--Ro],Do[Ro]=null}function $F(f,g){Do[Ro++]=Wl,Do[Ro++]=Kl,Do[Ro++]=td,Wl=g.id,Kl=g.overflow,td=f}var Ea=null,$r=null,Yn=!1,nd=null,Oo=!1,lk=Error(r(519));function rd(f){var g=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Zx(Po(g,f)),lk}function VF(f){var g=f.stateNode,w=f.type,M=f.memoizedProps;switch(g[Xn]=f,g[Nn]=M,w){case"dialog":zn("cancel",g),zn("close",g);break;case"iframe":case"object":case"embed":zn("load",g);break;case"video":case"audio":for(w=0;w<vb.length;w++)zn(vb[w],g);break;case"source":zn("error",g);break;case"img":case"image":case"link":zn("error",g),zn("load",g);break;case"details":zn("toggle",g);break;case"input":zn("invalid",g),ar(g,M.value,M.defaultValue,M.checked,M.defaultChecked,M.type,M.name,!0);break;case"select":zn("invalid",g);break;case"textarea":zn("invalid",g),qt(g,M.value,M.defaultValue,M.children)}w=M.children,typeof w!="string"&&typeof w!="number"&&typeof w!="bigint"||g.textContent===""+w||M.suppressHydrationWarning===!0||oU(g.textContent,w)?(M.popover!=null&&(zn("beforetoggle",g),zn("toggle",g)),M.onScroll!=null&&zn("scroll",g),M.onScrollEnd!=null&&zn("scrollend",g),M.onClick!=null&&(g.onclick=Si),g=!0):g=!1,g||rd(f,!0)}function GF(f){for(Ea=f.return;Ea;)switch(Ea.tag){case 5:case 31:case 13:Oo=!1;return;case 27:case 3:Oo=!0;return;default:Ea=Ea.return}}function Wm(f){if(f!==Ea)return!1;if(!Yn)return GF(f),Yn=!0,!1;var g=f.tag,w;if((w=g!==3&&g!==27)&&((w=g===5)&&(w=f.type,w=!(w!=="form"&&w!=="button")||kE(f.type,f.memoizedProps)),w=!w),w&&$r&&rd(f),GF(f),g===13){if(f=f.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(r(317));$r=gU(f)}else if(g===31){if(f=f.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(r(317));$r=gU(f)}else g===27?(g=$r,xd(f.type)?(f=jE,jE=null,$r=f):$r=g):$r=Ea?Fo(f.stateNode.nextSibling):null;return!0}function Qh(){$r=Ea=null,Yn=!1}function ck(){var f=nd;return f!==null&&(Ps===null?Ps=f:Ps.push.apply(Ps,f),nd=null),f}function Zx(f){nd===null?nd=[f]:nd.push(f)}var uk=$(null),Zh=null,Oc=null;function id(f,g,w){ne(uk,g._currentValue),g._currentValue=w}function Lc(f){f._currentValue=uk.current,W(uk)}function dk(f,g,w){for(;f!==null;){var M=f.alternate;if((f.childLanes&g)!==g?(f.childLanes|=g,M!==null&&(M.childLanes|=g)):M!==null&&(M.childLanes&g)!==g&&(M.childLanes|=g),f===w)break;f=f.return}}function hk(f,g,w,M){var R=f.child;for(R!==null&&(R.return=f);R!==null;){var F=R.dependencies;if(F!==null){var Z=R.child;F=F.firstContext;e:for(;F!==null;){var ve=F;F=R;for(var Ue=0;Ue<g.length;Ue++)if(ve.context===g[Ue]){F.lanes|=w,ve=F.alternate,ve!==null&&(ve.lanes|=w),dk(F.return,w,f),M||(Z=null);break e}F=ve.next}}else if(R.tag===18){if(Z=R.return,Z===null)throw Error(r(341));Z.lanes|=w,F=Z.alternate,F!==null&&(F.lanes|=w),dk(Z,w,f),Z=null}else Z=R.child;if(Z!==null)Z.return=R;else for(Z=R;Z!==null;){if(Z===f){Z=null;break}if(R=Z.sibling,R!==null){R.return=Z.return,Z=R;break}Z=Z.return}R=Z}}function Km(f,g,w,M){f=null;for(var R=g,F=!1;R!==null;){if(!F){if((R.flags&524288)!==0)F=!0;else if((R.flags&262144)!==0)break}if(R.tag===10){var Z=R.alternate;if(Z===null)throw Error(r(387));if(Z=Z.memoizedProps,Z!==null){var ve=R.type;Zs(R.pendingProps.value,Z.value)||(f!==null?f.push(ve):f=[ve])}}else if(R===ue.current){if(Z=R.alternate,Z===null)throw Error(r(387));Z.memoizedState.memoizedState!==R.memoizedState.memoizedState&&(f!==null?f.push(Mb):f=[Mb])}R=R.return}f!==null&&hk(g,f,w,M),g.flags|=262144}function Ov(f){for(f=f.firstContext;f!==null;){if(!Zs(f.context._currentValue,f.memoizedValue))return!0;f=f.next}return!1}function Jh(f){Zh=f,Oc=null,f=f.dependencies,f!==null&&(f.firstContext=null)}function Ta(f){return qF(Zh,f)}function Lv(f,g){return Zh===null&&Jh(f),qF(f,g)}function qF(f,g){var w=g._currentValue;if(g={context:g,memoizedValue:w,next:null},Oc===null){if(f===null)throw Error(r(308));Oc=g,f.dependencies={lanes:0,firstContext:g},f.flags|=524288}else Oc=Oc.next=g;return w}var Mie=typeof AbortController<"u"?AbortController:function(){var f=[],g=this.signal={aborted:!1,addEventListener:function(w,M){f.push(M)}};this.abort=function(){g.aborted=!0,f.forEach(function(w){return w()})}},kie=t.unstable_scheduleCallback,Eie=t.unstable_NormalPriority,ji={$$typeof:N,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function fk(){return{controller:new Mie,data:new Map,refCount:0}}function Jx(f){f.refCount--,f.refCount===0&&kie(Eie,function(){f.controller.abort()})}var eb=null,mk=0,Xm=0,Ym=null;function Tie(f,g){if(eb===null){var w=eb=[];mk=0,Xm=xE(),Ym={status:"pending",value:void 0,then:function(M){w.push(M)}}}return mk++,g.then(WF,WF),g}function WF(){if(--mk===0&&eb!==null){Ym!==null&&(Ym.status="fulfilled");var f=eb;eb=null,Xm=0,Ym=null;for(var g=0;g<f.length;g++)(0,f[g])()}}function Aie(f,g){var w=[],M={status:"pending",value:null,reason:null,then:function(R){w.push(R)}};return f.then(function(){M.status="fulfilled",M.value=g;for(var R=0;R<w.length;R++)(0,w[R])(g)},function(R){for(M.status="rejected",M.reason=R,R=0;R<w.length;R++)(0,w[R])(void 0)}),M}var KF=K.S;K.S=function(f,g){j5=O(),typeof g=="object"&&g!==null&&typeof g.then=="function"&&Tie(f,g),KF!==null&&KF(f,g)};var ef=$(null);function pk(){var f=ef.current;return f!==null?f:Pr.pooledCache}function Fv(f,g){g===null?ne(ef,ef.current):ne(ef,g.pool)}function XF(){var f=pk();return f===null?null:{parent:ji._currentValue,pool:f}}var Qm=Error(r(460)),gk=Error(r(474)),Iv=Error(r(542)),Uv={then:function(){}};function YF(f){return f=f.status,f==="fulfilled"||f==="rejected"}function QF(f,g,w){switch(w=f[w],w===void 0?f.push(g):w!==g&&(g.then(Si,Si),g=w),g.status){case"fulfilled":return g.value;case"rejected":throw f=g.reason,JF(f),f;default:if(typeof g.status=="string")g.then(Si,Si);else{if(f=Pr,f!==null&&100<f.shellSuspendCounter)throw Error(r(482));f=g,f.status="pending",f.then(function(M){if(g.status==="pending"){var R=g;R.status="fulfilled",R.value=M}},function(M){if(g.status==="pending"){var R=g;R.status="rejected",R.reason=M}})}switch(g.status){case"fulfilled":return g.value;case"rejected":throw f=g.reason,JF(f),f}throw nf=g,Qm}}function tf(f){try{var g=f._init;return g(f._payload)}catch(w){throw w!==null&&typeof w=="object"&&typeof w.then=="function"?(nf=w,Qm):w}}var nf=null;function ZF(){if(nf===null)throw Error(r(459));var f=nf;return nf=null,f}function JF(f){if(f===Qm||f===Iv)throw Error(r(483))}var Zm=null,tb=0;function zv(f){var g=tb;return tb+=1,Zm===null&&(Zm=[]),QF(Zm,f,g)}function nb(f,g){g=g.props.ref,f.ref=g!==void 0?g:null}function Bv(f,g){throw g.$$typeof===p?Error(r(525)):(f=Object.prototype.toString.call(g),Error(r(31,f==="[object Object]"?"object with keys {"+Object.keys(g).join(", ")+"}":f)))}function eI(f){function g(et,qe){if(f){var ot=et.deletions;ot===null?(et.deletions=[qe],et.flags|=16):ot.push(qe)}}function w(et,qe){if(!f)return null;for(;qe!==null;)g(et,qe),qe=qe.sibling;return null}function M(et){for(var qe=new Map;et!==null;)et.key!==null?qe.set(et.key,et):qe.set(et.index,et),et=et.sibling;return qe}function R(et,qe){return et=Dc(et,qe),et.index=0,et.sibling=null,et}function F(et,qe,ot){return et.index=ot,f?(ot=et.alternate,ot!==null?(ot=ot.index,ot<qe?(et.flags|=67108866,qe):ot):(et.flags|=67108866,qe)):(et.flags|=1048576,qe)}function Z(et){return f&&et.alternate===null&&(et.flags|=67108866),et}function ve(et,qe,ot,yt){return qe===null||qe.tag!==6?(qe=ik(ot,et.mode,yt),qe.return=et,qe):(qe=R(qe,ot),qe.return=et,qe)}function Ue(et,qe,ot,yt){var Kt=ot.type;return Kt===y?bt(et,qe,ot.props.children,yt,ot.key):qe!==null&&(qe.elementType===Kt||typeof Kt=="object"&&Kt!==null&&Kt.$$typeof===P&&tf(Kt)===qe.type)?(qe=R(qe,ot.props),nb(qe,ot),qe.return=et,qe):(qe=Dv(ot.type,ot.key,ot.props,null,et.mode,yt),nb(qe,ot),qe.return=et,qe)}function lt(et,qe,ot,yt){return qe===null||qe.tag!==4||qe.stateNode.containerInfo!==ot.containerInfo||qe.stateNode.implementation!==ot.implementation?(qe=ak(ot,et.mode,yt),qe.return=et,qe):(qe=R(qe,ot.children||[]),qe.return=et,qe)}function bt(et,qe,ot,yt,Kt){return qe===null||qe.tag!==7?(qe=Yh(ot,et.mode,yt,Kt),qe.return=et,qe):(qe=R(qe,ot),qe.return=et,qe)}function wt(et,qe,ot){if(typeof qe=="string"&&qe!==""||typeof qe=="number"||typeof qe=="bigint")return qe=ik(""+qe,et.mode,ot),qe.return=et,qe;if(typeof qe=="object"&&qe!==null){switch(qe.$$typeof){case m:return ot=Dv(qe.type,qe.key,qe.props,null,et.mode,ot),nb(ot,qe),ot.return=et,ot;case x:return qe=ak(qe,et.mode,ot),qe.return=et,qe;case P:return qe=tf(qe),wt(et,qe,ot)}if(V(qe)||L(qe))return qe=Yh(qe,et.mode,ot,null),qe.return=et,qe;if(typeof qe.then=="function")return wt(et,zv(qe),ot);if(qe.$$typeof===N)return wt(et,Lv(et,qe),ot);Bv(et,qe)}return null}function ft(et,qe,ot,yt){var Kt=qe!==null?qe.key:null;if(typeof ot=="string"&&ot!==""||typeof ot=="number"||typeof ot=="bigint")return Kt!==null?null:ve(et,qe,""+ot,yt);if(typeof ot=="object"&&ot!==null){switch(ot.$$typeof){case m:return ot.key===Kt?Ue(et,qe,ot,yt):null;case x:return ot.key===Kt?lt(et,qe,ot,yt):null;case P:return ot=tf(ot),ft(et,qe,ot,yt)}if(V(ot)||L(ot))return Kt!==null?null:bt(et,qe,ot,yt,null);if(typeof ot.then=="function")return ft(et,qe,zv(ot),yt);if(ot.$$typeof===N)return ft(et,qe,Lv(et,ot),yt);Bv(et,ot)}return null}function xt(et,qe,ot,yt,Kt){if(typeof yt=="string"&&yt!==""||typeof yt=="number"||typeof yt=="bigint")return et=et.get(ot)||null,ve(qe,et,""+yt,Kt);if(typeof yt=="object"&&yt!==null){switch(yt.$$typeof){case m:return et=et.get(yt.key===null?ot:yt.key)||null,Ue(qe,et,yt,Kt);case x:return et=et.get(yt.key===null?ot:yt.key)||null,lt(qe,et,yt,Kt);case P:return yt=tf(yt),xt(et,qe,ot,yt,Kt)}if(V(yt)||L(yt))return et=et.get(ot)||null,bt(qe,et,yt,Kt,null);if(typeof yt.then=="function")return xt(et,qe,ot,zv(yt),Kt);if(yt.$$typeof===N)return xt(et,qe,ot,Lv(qe,yt),Kt);Bv(qe,yt)}return null}function Vt(et,qe,ot,yt){for(var Kt=null,or=null,Wt=qe,kn=qe=0,Wn=null;Wt!==null&&kn<ot.length;kn++){Wt.index>kn?(Wn=Wt,Wt=null):Wn=Wt.sibling;var lr=ft(et,Wt,ot[kn],yt);if(lr===null){Wt===null&&(Wt=Wn);break}f&&Wt&&lr.alternate===null&&g(et,Wt),qe=F(lr,qe,kn),or===null?Kt=lr:or.sibling=lr,or=lr,Wt=Wn}if(kn===ot.length)return w(et,Wt),Yn&&Rc(et,kn),Kt;if(Wt===null){for(;kn<ot.length;kn++)Wt=wt(et,ot[kn],yt),Wt!==null&&(qe=F(Wt,qe,kn),or===null?Kt=Wt:or.sibling=Wt,or=Wt);return Yn&&Rc(et,kn),Kt}for(Wt=M(Wt);kn<ot.length;kn++)Wn=xt(Wt,et,kn,ot[kn],yt),Wn!==null&&(f&&Wn.alternate!==null&&Wt.delete(Wn.key===null?kn:Wn.key),qe=F(Wn,qe,kn),or===null?Kt=Wn:or.sibling=Wn,or=Wn);return f&&Wt.forEach(function(_d){return g(et,_d)}),Yn&&Rc(et,kn),Kt}function rn(et,qe,ot,yt){if(ot==null)throw Error(r(151));for(var Kt=null,or=null,Wt=qe,kn=qe=0,Wn=null,lr=ot.next();Wt!==null&&!lr.done;kn++,lr=ot.next()){Wt.index>kn?(Wn=Wt,Wt=null):Wn=Wt.sibling;var _d=ft(et,Wt,lr.value,yt);if(_d===null){Wt===null&&(Wt=Wn);break}f&&Wt&&_d.alternate===null&&g(et,Wt),qe=F(_d,qe,kn),or===null?Kt=_d:or.sibling=_d,or=_d,Wt=Wn}if(lr.done)return w(et,Wt),Yn&&Rc(et,kn),Kt;if(Wt===null){for(;!lr.done;kn++,lr=ot.next())lr=wt(et,lr.value,yt),lr!==null&&(qe=F(lr,qe,kn),or===null?Kt=lr:or.sibling=lr,or=lr);return Yn&&Rc(et,kn),Kt}for(Wt=M(Wt);!lr.done;kn++,lr=ot.next())lr=xt(Wt,et,kn,lr.value,yt),lr!==null&&(f&&lr.alternate!==null&&Wt.delete(lr.key===null?kn:lr.key),qe=F(lr,qe,kn),or===null?Kt=lr:or.sibling=lr,or=lr);return f&&Wt.forEach(function(zae){return g(et,zae)}),Yn&&Rc(et,kn),Kt}function Sr(et,qe,ot,yt){if(typeof ot=="object"&&ot!==null&&ot.type===y&&ot.key===null&&(ot=ot.props.children),typeof ot=="object"&&ot!==null){switch(ot.$$typeof){case m:e:{for(var Kt=ot.key;qe!==null;){if(qe.key===Kt){if(Kt=ot.type,Kt===y){if(qe.tag===7){w(et,qe.sibling),yt=R(qe,ot.props.children),yt.return=et,et=yt;break e}}else if(qe.elementType===Kt||typeof Kt=="object"&&Kt!==null&&Kt.$$typeof===P&&tf(Kt)===qe.type){w(et,qe.sibling),yt=R(qe,ot.props),nb(yt,ot),yt.return=et,et=yt;break e}w(et,qe);break}else g(et,qe);qe=qe.sibling}ot.type===y?(yt=Yh(ot.props.children,et.mode,yt,ot.key),yt.return=et,et=yt):(yt=Dv(ot.type,ot.key,ot.props,null,et.mode,yt),nb(yt,ot),yt.return=et,et=yt)}return Z(et);case x:e:{for(Kt=ot.key;qe!==null;){if(qe.key===Kt)if(qe.tag===4&&qe.stateNode.containerInfo===ot.containerInfo&&qe.stateNode.implementation===ot.implementation){w(et,qe.sibling),yt=R(qe,ot.children||[]),yt.return=et,et=yt;break e}else{w(et,qe);break}else g(et,qe);qe=qe.sibling}yt=ak(ot,et.mode,yt),yt.return=et,et=yt}return Z(et);case P:return ot=tf(ot),Sr(et,qe,ot,yt)}if(V(ot))return Vt(et,qe,ot,yt);if(L(ot)){if(Kt=L(ot),typeof Kt!="function")throw Error(r(150));return ot=Kt.call(ot),rn(et,qe,ot,yt)}if(typeof ot.then=="function")return Sr(et,qe,zv(ot),yt);if(ot.$$typeof===N)return Sr(et,qe,Lv(et,ot),yt);Bv(et,ot)}return typeof ot=="string"&&ot!==""||typeof ot=="number"||typeof ot=="bigint"?(ot=""+ot,qe!==null&&qe.tag===6?(w(et,qe.sibling),yt=R(qe,ot),yt.return=et,et=yt):(w(et,qe),yt=ik(ot,et.mode,yt),yt.return=et,et=yt),Z(et)):w(et,qe)}return function(et,qe,ot,yt){try{tb=0;var Kt=Sr(et,qe,ot,yt);return Zm=null,Kt}catch(Wt){if(Wt===Qm||Wt===Iv)throw Wt;var or=Js(29,Wt,null,et.mode);return or.lanes=yt,or.return=et,or}finally{}}}var rf=eI(!0),tI=eI(!1),ad=!1;function xk(f){f.updateQueue={baseState:f.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function bk(f,g){f=f.updateQueue,g.updateQueue===f&&(g.updateQueue={baseState:f.baseState,firstBaseUpdate:f.firstBaseUpdate,lastBaseUpdate:f.lastBaseUpdate,shared:f.shared,callbacks:null})}function sd(f){return{lane:f,tag:0,payload:null,callback:null,next:null}}function od(f,g,w){var M=f.updateQueue;if(M===null)return null;if(M=M.shared,(hr&2)!==0){var R=M.pending;return R===null?g.next=g:(g.next=R.next,R.next=g),M.pending=g,g=Pv(f),IF(f,null,w),g}return jv(f,M,g,w),Pv(f)}function rb(f,g,w){if(g=g.updateQueue,g!==null&&(g=g.shared,(w&4194048)!==0)){var M=g.lanes;M&=f.pendingLanes,w|=M,g.lanes=w,cn(f,w)}}function yk(f,g){var w=f.updateQueue,M=f.alternate;if(M!==null&&(M=M.updateQueue,w===M)){var R=null,F=null;if(w=w.firstBaseUpdate,w!==null){do{var Z={lane:w.lane,tag:w.tag,payload:w.payload,callback:null,next:null};F===null?R=F=Z:F=F.next=Z,w=w.next}while(w!==null);F===null?R=F=g:F=F.next=g}else R=F=g;w={baseState:M.baseState,firstBaseUpdate:R,lastBaseUpdate:F,shared:M.shared,callbacks:M.callbacks},f.updateQueue=w;return}f=w.lastBaseUpdate,f===null?w.firstBaseUpdate=g:f.next=g,w.lastBaseUpdate=g}var vk=!1;function ib(){if(vk){var f=Ym;if(f!==null)throw f}}function ab(f,g,w,M){vk=!1;var R=f.updateQueue;ad=!1;var F=R.firstBaseUpdate,Z=R.lastBaseUpdate,ve=R.shared.pending;if(ve!==null){R.shared.pending=null;var Ue=ve,lt=Ue.next;Ue.next=null,Z===null?F=lt:Z.next=lt,Z=Ue;var bt=f.alternate;bt!==null&&(bt=bt.updateQueue,ve=bt.lastBaseUpdate,ve!==Z&&(ve===null?bt.firstBaseUpdate=lt:ve.next=lt,bt.lastBaseUpdate=Ue))}if(F!==null){var wt=R.baseState;Z=0,bt=lt=Ue=null,ve=F;do{var ft=ve.lane&-536870913,xt=ft!==ve.lane;if(xt?(qn&ft)===ft:(M&ft)===ft){ft!==0&&ft===Xm&&(vk=!0),bt!==null&&(bt=bt.next={lane:0,tag:ve.tag,payload:ve.payload,callback:null,next:null});e:{var Vt=f,rn=ve;ft=g;var Sr=w;switch(rn.tag){case 1:if(Vt=rn.payload,typeof Vt=="function"){wt=Vt.call(Sr,wt,ft);break e}wt=Vt;break e;case 3:Vt.flags=Vt.flags&-65537|128;case 0:if(Vt=rn.payload,ft=typeof Vt=="function"?Vt.call(Sr,wt,ft):Vt,ft==null)break e;wt=h({},wt,ft);break e;case 2:ad=!0}}ft=ve.callback,ft!==null&&(f.flags|=64,xt&&(f.flags|=8192),xt=R.callbacks,xt===null?R.callbacks=[ft]:xt.push(ft))}else xt={lane:ft,tag:ve.tag,payload:ve.payload,callback:ve.callback,next:null},bt===null?(lt=bt=xt,Ue=wt):bt=bt.next=xt,Z|=ft;if(ve=ve.next,ve===null){if(ve=R.shared.pending,ve===null)break;xt=ve,ve=xt.next,xt.next=null,R.lastBaseUpdate=xt,R.shared.pending=null}}while(!0);bt===null&&(Ue=wt),R.baseState=Ue,R.firstBaseUpdate=lt,R.lastBaseUpdate=bt,F===null&&(R.shared.lanes=0),hd|=Z,f.lanes=Z,f.memoizedState=wt}}function nI(f,g){if(typeof f!="function")throw Error(r(191,f));f.call(g)}function rI(f,g){var w=f.callbacks;if(w!==null)for(f.callbacks=null,f=0;f<w.length;f++)nI(w[f],g)}var Jm=$(null),Hv=$(0);function iI(f,g){f=Gc,ne(Hv,f),ne(Jm,g),Gc=f|g.baseLanes}function wk(){ne(Hv,Gc),ne(Jm,Jm.current)}function _k(){Gc=Hv.current,W(Jm),W(Hv)}var eo=$(null),Lo=null;function ld(f){var g=f.alternate;ne(Mi,Mi.current&1),ne(eo,f),Lo===null&&(g===null||Jm.current!==null||g.memoizedState!==null)&&(Lo=f)}function Sk(f){ne(Mi,Mi.current),ne(eo,f),Lo===null&&(Lo=f)}function aI(f){f.tag===22?(ne(Mi,Mi.current),ne(eo,f),Lo===null&&(Lo=f)):cd()}function cd(){ne(Mi,Mi.current),ne(eo,eo.current)}function to(f){W(eo),Lo===f&&(Lo=null),W(Mi)}var Mi=$(0);function $v(f){for(var g=f;g!==null;){if(g.tag===13){var w=g.memoizedState;if(w!==null&&(w=w.dehydrated,w===null||AE(w)||CE(w)))return g}else if(g.tag===19&&(g.memoizedProps.revealOrder==="forwards"||g.memoizedProps.revealOrder==="backwards"||g.memoizedProps.revealOrder==="unstable_legacy-backwards"||g.memoizedProps.revealOrder==="together")){if((g.flags&128)!==0)return g}else if(g.child!==null){g.child.return=g,g=g.child;continue}if(g===f)break;for(;g.sibling===null;){if(g.return===null||g.return===f)return null;g=g.return}g.sibling.return=g.return,g=g.sibling}return null}var Fc=0,_n=null,wr=null,Pi=null,Vv=!1,ep=!1,af=!1,Gv=0,sb=0,tp=null,Cie=0;function fi(){throw Error(r(321))}function Nk(f,g){if(g===null)return!1;for(var w=0;w<g.length&&w<f.length;w++)if(!Zs(f[w],g[w]))return!1;return!0}function Mk(f,g,w,M,R,F){return Fc=F,_n=g,g.memoizedState=null,g.updateQueue=null,g.lanes=0,K.H=f===null||f.memoizedState===null?HI:zk,af=!1,F=w(M,R),af=!1,ep&&(F=oI(g,w,M,R)),sI(f),F}function sI(f){K.H=cb;var g=wr!==null&&wr.next!==null;if(Fc=0,Pi=wr=_n=null,Vv=!1,sb=0,tp=null,g)throw Error(r(300));f===null||Di||(f=f.dependencies,f!==null&&Ov(f)&&(Di=!0))}function oI(f,g,w,M){_n=f;var R=0;do{if(ep&&(tp=null),sb=0,ep=!1,25<=R)throw Error(r(301));if(R+=1,Pi=wr=null,f.updateQueue!=null){var F=f.updateQueue;F.lastEffect=null,F.events=null,F.stores=null,F.memoCache!=null&&(F.memoCache.index=0)}K.H=$I,F=g(w,M)}while(ep);return F}function jie(){var f=K.H,g=f.useState()[0];return g=typeof g.then=="function"?ob(g):g,f=f.useState()[0],(wr!==null?wr.memoizedState:null)!==f&&(_n.flags|=1024),g}function kk(){var f=Gv!==0;return Gv=0,f}function Ek(f,g,w){g.updateQueue=f.updateQueue,g.flags&=-2053,f.lanes&=~w}function Tk(f){if(Vv){for(f=f.memoizedState;f!==null;){var g=f.queue;g!==null&&(g.pending=null),f=f.next}Vv=!1}Fc=0,Pi=wr=_n=null,ep=!1,sb=Gv=0,tp=null}function ls(){var f={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Pi===null?_n.memoizedState=Pi=f:Pi=Pi.next=f,Pi}function ki(){if(wr===null){var f=_n.alternate;f=f!==null?f.memoizedState:null}else f=wr.next;var g=Pi===null?_n.memoizedState:Pi.next;if(g!==null)Pi=g,wr=f;else{if(f===null)throw _n.alternate===null?Error(r(467)):Error(r(310));wr=f,f={memoizedState:wr.memoizedState,baseState:wr.baseState,baseQueue:wr.baseQueue,queue:wr.queue,next:null},Pi===null?_n.memoizedState=Pi=f:Pi=Pi.next=f}return Pi}function qv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ob(f){var g=sb;return sb+=1,tp===null&&(tp=[]),f=QF(tp,f,g),g=_n,(Pi===null?g.memoizedState:Pi.next)===null&&(g=g.alternate,K.H=g===null||g.memoizedState===null?HI:zk),f}function Wv(f){if(f!==null&&typeof f=="object"){if(typeof f.then=="function")return ob(f);if(f.$$typeof===N)return Ta(f)}throw Error(r(438,String(f)))}function Ak(f){var g=null,w=_n.updateQueue;if(w!==null&&(g=w.memoCache),g==null){var M=_n.alternate;M!==null&&(M=M.updateQueue,M!==null&&(M=M.memoCache,M!=null&&(g={data:M.data.map(function(R){return R.slice()}),index:0})))}if(g==null&&(g={data:[],index:0}),w===null&&(w=qv(),_n.updateQueue=w),w.memoCache=g,w=g.data[g.index],w===void 0)for(w=g.data[g.index]=Array(f),M=0;M<f;M++)w[M]=D;return g.index++,w}function Ic(f,g){return typeof g=="function"?g(f):g}function Kv(f){var g=ki();return Ck(g,wr,f)}function Ck(f,g,w){var M=f.queue;if(M===null)throw Error(r(311));M.lastRenderedReducer=w;var R=f.baseQueue,F=M.pending;if(F!==null){if(R!==null){var Z=R.next;R.next=F.next,F.next=Z}g.baseQueue=R=F,M.pending=null}if(F=f.baseState,R===null)f.memoizedState=F;else{g=R.next;var ve=Z=null,Ue=null,lt=g,bt=!1;do{var wt=lt.lane&-536870913;if(wt!==lt.lane?(qn&wt)===wt:(Fc&wt)===wt){var ft=lt.revertLane;if(ft===0)Ue!==null&&(Ue=Ue.next={lane:0,revertLane:0,gesture:null,action:lt.action,hasEagerState:lt.hasEagerState,eagerState:lt.eagerState,next:null}),wt===Xm&&(bt=!0);else if((Fc&ft)===ft){lt=lt.next,ft===Xm&&(bt=!0);continue}else wt={lane:0,revertLane:lt.revertLane,gesture:null,action:lt.action,hasEagerState:lt.hasEagerState,eagerState:lt.eagerState,next:null},Ue===null?(ve=Ue=wt,Z=F):Ue=Ue.next=wt,_n.lanes|=ft,hd|=ft;wt=lt.action,af&&w(F,wt),F=lt.hasEagerState?lt.eagerState:w(F,wt)}else ft={lane:wt,revertLane:lt.revertLane,gesture:lt.gesture,action:lt.action,hasEagerState:lt.hasEagerState,eagerState:lt.eagerState,next:null},Ue===null?(ve=Ue=ft,Z=F):Ue=Ue.next=ft,_n.lanes|=wt,hd|=wt;lt=lt.next}while(lt!==null&&lt!==g);if(Ue===null?Z=F:Ue.next=ve,!Zs(F,f.memoizedState)&&(Di=!0,bt&&(w=Ym,w!==null)))throw w;f.memoizedState=F,f.baseState=Z,f.baseQueue=Ue,M.lastRenderedState=F}return R===null&&(M.lanes=0),[f.memoizedState,M.dispatch]}function jk(f){var g=ki(),w=g.queue;if(w===null)throw Error(r(311));w.lastRenderedReducer=f;var M=w.dispatch,R=w.pending,F=g.memoizedState;if(R!==null){w.pending=null;var Z=R=R.next;do F=f(F,Z.action),Z=Z.next;while(Z!==R);Zs(F,g.memoizedState)||(Di=!0),g.memoizedState=F,g.baseQueue===null&&(g.baseState=F),w.lastRenderedState=F}return[F,M]}function lI(f,g,w){var M=_n,R=ki(),F=Yn;if(F){if(w===void 0)throw Error(r(407));w=w()}else w=g();var Z=!Zs((wr||R).memoizedState,w);if(Z&&(R.memoizedState=w,Di=!0),R=R.queue,Rk(dI.bind(null,M,R,f),[f]),R.getSnapshot!==g||Z||Pi!==null&&Pi.memoizedState.tag&1){if(M.flags|=2048,np(9,{destroy:void 0},uI.bind(null,M,R,w,g),null),Pr===null)throw Error(r(349));F||(Fc&127)!==0||cI(M,g,w)}return w}function cI(f,g,w){f.flags|=16384,f={getSnapshot:g,value:w},g=_n.updateQueue,g===null?(g=qv(),_n.updateQueue=g,g.stores=[f]):(w=g.stores,w===null?g.stores=[f]:w.push(f))}function uI(f,g,w,M){g.value=w,g.getSnapshot=M,hI(g)&&fI(f)}function dI(f,g,w){return w(function(){hI(g)&&fI(f)})}function hI(f){var g=f.getSnapshot;f=f.value;try{var w=g();return!Zs(f,w)}catch{return!0}}function fI(f){var g=Xh(f,2);g!==null&&Ds(g,f,2)}function Pk(f){var g=ls();if(typeof f=="function"){var w=f;if(f=w(),af){Pe(!0);try{w()}finally{Pe(!1)}}}return g.memoizedState=g.baseState=f,g.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ic,lastRenderedState:f},g}function mI(f,g,w,M){return f.baseState=w,Ck(f,wr,typeof M=="function"?M:Ic)}function Pie(f,g,w,M,R){if(Qv(f))throw Error(r(485));if(f=g.action,f!==null){var F={payload:R,action:f,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(Z){F.listeners.push(Z)}};K.T!==null?w(!0):F.isTransition=!1,M(F),w=g.pending,w===null?(F.next=g.pending=F,pI(g,F)):(F.next=w.next,g.pending=w.next=F)}}function pI(f,g){var w=g.action,M=g.payload,R=f.state;if(g.isTransition){var F=K.T,Z={};K.T=Z;try{var ve=w(R,M),Ue=K.S;Ue!==null&&Ue(Z,ve),gI(f,g,ve)}catch(lt){Dk(f,g,lt)}finally{F!==null&&Z.types!==null&&(F.types=Z.types),K.T=F}}else try{F=w(R,M),gI(f,g,F)}catch(lt){Dk(f,g,lt)}}function gI(f,g,w){w!==null&&typeof w=="object"&&typeof w.then=="function"?w.then(function(M){xI(f,g,M)},function(M){return Dk(f,g,M)}):xI(f,g,w)}function xI(f,g,w){g.status="fulfilled",g.value=w,bI(g),f.state=w,g=f.pending,g!==null&&(w=g.next,w===g?f.pending=null:(w=w.next,g.next=w,pI(f,w)))}function Dk(f,g,w){var M=f.pending;if(f.pending=null,M!==null){M=M.next;do g.status="rejected",g.reason=w,bI(g),g=g.next;while(g!==M)}f.action=null}function bI(f){f=f.listeners;for(var g=0;g<f.length;g++)(0,f[g])()}function yI(f,g){return g}function vI(f,g){if(Yn){var w=Pr.formState;if(w!==null){e:{var M=_n;if(Yn){if($r){t:{for(var R=$r,F=Oo;R.nodeType!==8;){if(!F){R=null;break t}if(R=Fo(R.nextSibling),R===null){R=null;break t}}F=R.data,R=F==="F!"||F==="F"?R:null}if(R){$r=Fo(R.nextSibling),M=R.data==="F!";break e}}rd(M)}M=!1}M&&(g=w[0])}}return w=ls(),w.memoizedState=w.baseState=g,M={pending:null,lanes:0,dispatch:null,lastRenderedReducer:yI,lastRenderedState:g},w.queue=M,w=UI.bind(null,_n,M),M.dispatch=w,M=Pk(!1),F=Uk.bind(null,_n,!1,M.queue),M=ls(),R={state:g,dispatch:null,action:f,pending:null},M.queue=R,w=Pie.bind(null,_n,R,F,w),R.dispatch=w,M.memoizedState=f,[g,w,!1]}function wI(f){var g=ki();return _I(g,wr,f)}function _I(f,g,w){if(g=Ck(f,g,yI)[0],f=Kv(Ic)[0],typeof g=="object"&&g!==null&&typeof g.then=="function")try{var M=ob(g)}catch(Z){throw Z===Qm?Iv:Z}else M=g;g=ki();var R=g.queue,F=R.dispatch;return w!==g.memoizedState&&(_n.flags|=2048,np(9,{destroy:void 0},Die.bind(null,R,w),null)),[M,F,f]}function Die(f,g){f.action=g}function SI(f){var g=ki(),w=wr;if(w!==null)return _I(g,w,f);ki(),g=g.memoizedState,w=ki();var M=w.queue.dispatch;return w.memoizedState=f,[g,M,!1]}function np(f,g,w,M){return f={tag:f,create:w,deps:M,inst:g,next:null},g=_n.updateQueue,g===null&&(g=qv(),_n.updateQueue=g),w=g.lastEffect,w===null?g.lastEffect=f.next=f:(M=w.next,w.next=f,f.next=M,g.lastEffect=f),f}function NI(){return ki().memoizedState}function Xv(f,g,w,M){var R=ls();_n.flags|=f,R.memoizedState=np(1|g,{destroy:void 0},w,M===void 0?null:M)}function Yv(f,g,w,M){var R=ki();M=M===void 0?null:M;var F=R.memoizedState.inst;wr!==null&&M!==null&&Nk(M,wr.memoizedState.deps)?R.memoizedState=np(g,F,w,M):(_n.flags|=f,R.memoizedState=np(1|g,F,w,M))}function MI(f,g){Xv(8390656,8,f,g)}function Rk(f,g){Yv(2048,8,f,g)}function Rie(f){_n.flags|=4;var g=_n.updateQueue;if(g===null)g=qv(),_n.updateQueue=g,g.events=[f];else{var w=g.events;w===null?g.events=[f]:w.push(f)}}function kI(f){var g=ki().memoizedState;return Rie({ref:g,nextImpl:f}),function(){if((hr&2)!==0)throw Error(r(440));return g.impl.apply(void 0,arguments)}}function EI(f,g){return Yv(4,2,f,g)}function TI(f,g){return Yv(4,4,f,g)}function AI(f,g){if(typeof g=="function"){f=f();var w=g(f);return function(){typeof w=="function"?w():g(null)}}if(g!=null)return f=f(),g.current=f,function(){g.current=null}}function CI(f,g,w){w=w!=null?w.concat([f]):null,Yv(4,4,AI.bind(null,g,f),w)}function Ok(){}function jI(f,g){var w=ki();g=g===void 0?null:g;var M=w.memoizedState;return g!==null&&Nk(g,M[1])?M[0]:(w.memoizedState=[f,g],f)}function PI(f,g){var w=ki();g=g===void 0?null:g;var M=w.memoizedState;if(g!==null&&Nk(g,M[1]))return M[0];if(M=f(),af){Pe(!0);try{f()}finally{Pe(!1)}}return w.memoizedState=[M,g],M}function Lk(f,g,w){return w===void 0||(Fc&1073741824)!==0&&(qn&261930)===0?f.memoizedState=g:(f.memoizedState=w,f=D5(),_n.lanes|=f,hd|=f,w)}function DI(f,g,w,M){return Zs(w,g)?w:Jm.current!==null?(f=Lk(f,w,M),Zs(f,g)||(Di=!0),f):(Fc&42)===0||(Fc&1073741824)!==0&&(qn&261930)===0?(Di=!0,f.memoizedState=w):(f=D5(),_n.lanes|=f,hd|=f,g)}function RI(f,g,w,M,R){var F=z.p;z.p=F!==0&&8>F?F:8;var Z=K.T,ve={};K.T=ve,Uk(f,!1,g,w);try{var Ue=R(),lt=K.S;if(lt!==null&&lt(ve,Ue),Ue!==null&&typeof Ue=="object"&&typeof Ue.then=="function"){var bt=Aie(Ue,M);lb(f,g,bt,io(f))}else lb(f,g,M,io(f))}catch(wt){lb(f,g,{then:function(){},status:"rejected",reason:wt},io())}finally{z.p=F,Z!==null&&ve.types!==null&&(Z.types=ve.types),K.T=Z}}function Oie(){}function Fk(f,g,w,M){if(f.tag!==5)throw Error(r(476));var R=OI(f).queue;RI(f,R,g,X,w===null?Oie:function(){return LI(f),w(M)})}function OI(f){var g=f.memoizedState;if(g!==null)return g;g={memoizedState:X,baseState:X,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ic,lastRenderedState:X},next:null};var w={};return g.next={memoizedState:w,baseState:w,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ic,lastRenderedState:w},next:null},f.memoizedState=g,f=f.alternate,f!==null&&(f.memoizedState=g),g}function LI(f){var g=OI(f);g.next===null&&(g=f.alternate.memoizedState),lb(f,g.next.queue,{},io())}function Ik(){return Ta(Mb)}function FI(){return ki().memoizedState}function II(){return ki().memoizedState}function Lie(f){for(var g=f.return;g!==null;){switch(g.tag){case 24:case 3:var w=io();f=sd(w);var M=od(g,f,w);M!==null&&(Ds(M,g,w),rb(M,g,w)),g={cache:fk()},f.payload=g;return}g=g.return}}function Fie(f,g,w){var M=io();w={lane:M,revertLane:0,gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null},Qv(f)?zI(g,w):(w=nk(f,g,w,M),w!==null&&(Ds(w,f,M),BI(w,g,M)))}function UI(f,g,w){var M=io();lb(f,g,w,M)}function lb(f,g,w,M){var R={lane:M,revertLane:0,gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null};if(Qv(f))zI(g,R);else{var F=f.alternate;if(f.lanes===0&&(F===null||F.lanes===0)&&(F=g.lastRenderedReducer,F!==null))try{var Z=g.lastRenderedState,ve=F(Z,w);if(R.hasEagerState=!0,R.eagerState=ve,Zs(ve,Z))return jv(f,g,R,0),Pr===null&&Cv(),!1}catch{}finally{}if(w=nk(f,g,R,M),w!==null)return Ds(w,f,M),BI(w,g,M),!0}return!1}function Uk(f,g,w,M){if(M={lane:2,revertLane:xE(),gesture:null,action:M,hasEagerState:!1,eagerState:null,next:null},Qv(f)){if(g)throw Error(r(479))}else g=nk(f,w,M,2),g!==null&&Ds(g,f,2)}function Qv(f){var g=f.alternate;return f===_n||g!==null&&g===_n}function zI(f,g){ep=Vv=!0;var w=f.pending;w===null?g.next=g:(g.next=w.next,w.next=g),f.pending=g}function BI(f,g,w){if((w&4194048)!==0){var M=g.lanes;M&=f.pendingLanes,w|=M,g.lanes=w,cn(f,w)}}var cb={readContext:Ta,use:Wv,useCallback:fi,useContext:fi,useEffect:fi,useImperativeHandle:fi,useLayoutEffect:fi,useInsertionEffect:fi,useMemo:fi,useReducer:fi,useRef:fi,useState:fi,useDebugValue:fi,useDeferredValue:fi,useTransition:fi,useSyncExternalStore:fi,useId:fi,useHostTransitionStatus:fi,useFormState:fi,useActionState:fi,useOptimistic:fi,useMemoCache:fi,useCacheRefresh:fi};cb.useEffectEvent=fi;var HI={readContext:Ta,use:Wv,useCallback:function(f,g){return ls().memoizedState=[f,g===void 0?null:g],f},useContext:Ta,useEffect:MI,useImperativeHandle:function(f,g,w){w=w!=null?w.concat([f]):null,Xv(4194308,4,AI.bind(null,g,f),w)},useLayoutEffect:function(f,g){return Xv(4194308,4,f,g)},useInsertionEffect:function(f,g){Xv(4,2,f,g)},useMemo:function(f,g){var w=ls();g=g===void 0?null:g;var M=f();if(af){Pe(!0);try{f()}finally{Pe(!1)}}return w.memoizedState=[M,g],M},useReducer:function(f,g,w){var M=ls();if(w!==void 0){var R=w(g);if(af){Pe(!0);try{w(g)}finally{Pe(!1)}}}else R=g;return M.memoizedState=M.baseState=R,f={pending:null,lanes:0,dispatch:null,lastRenderedReducer:f,lastRenderedState:R},M.queue=f,f=f.dispatch=Fie.bind(null,_n,f),[M.memoizedState,f]},useRef:function(f){var g=ls();return f={current:f},g.memoizedState=f},useState:function(f){f=Pk(f);var g=f.queue,w=UI.bind(null,_n,g);return g.dispatch=w,[f.memoizedState,w]},useDebugValue:Ok,useDeferredValue:function(f,g){var w=ls();return Lk(w,f,g)},useTransition:function(){var f=Pk(!1);return f=RI.bind(null,_n,f.queue,!0,!1),ls().memoizedState=f,[!1,f]},useSyncExternalStore:function(f,g,w){var M=_n,R=ls();if(Yn){if(w===void 0)throw Error(r(407));w=w()}else{if(w=g(),Pr===null)throw Error(r(349));(qn&127)!==0||cI(M,g,w)}R.memoizedState=w;var F={value:w,getSnapshot:g};return R.queue=F,MI(dI.bind(null,M,F,f),[f]),M.flags|=2048,np(9,{destroy:void 0},uI.bind(null,M,F,w,g),null),w},useId:function(){var f=ls(),g=Pr.identifierPrefix;if(Yn){var w=Kl,M=Wl;w=(M&~(1<<32-Ie(M)-1)).toString(32)+w,g="_"+g+"R_"+w,w=Gv++,0<w&&(g+="H"+w.toString(32)),g+="_"}else w=Cie++,g="_"+g+"r_"+w.toString(32)+"_";return f.memoizedState=g},useHostTransitionStatus:Ik,useFormState:vI,useActionState:vI,useOptimistic:function(f){var g=ls();g.memoizedState=g.baseState=f;var w={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return g.queue=w,g=Uk.bind(null,_n,!0,w),w.dispatch=g,[f,g]},useMemoCache:Ak,useCacheRefresh:function(){return ls().memoizedState=Lie.bind(null,_n)},useEffectEvent:function(f){var g=ls(),w={impl:f};return g.memoizedState=w,function(){if((hr&2)!==0)throw Error(r(440));return w.impl.apply(void 0,arguments)}}},zk={readContext:Ta,use:Wv,useCallback:jI,useContext:Ta,useEffect:Rk,useImperativeHandle:CI,useInsertionEffect:EI,useLayoutEffect:TI,useMemo:PI,useReducer:Kv,useRef:NI,useState:function(){return Kv(Ic)},useDebugValue:Ok,useDeferredValue:function(f,g){var w=ki();return DI(w,wr.memoizedState,f,g)},useTransition:function(){var f=Kv(Ic)[0],g=ki().memoizedState;return[typeof f=="boolean"?f:ob(f),g]},useSyncExternalStore:lI,useId:FI,useHostTransitionStatus:Ik,useFormState:wI,useActionState:wI,useOptimistic:function(f,g){var w=ki();return mI(w,wr,f,g)},useMemoCache:Ak,useCacheRefresh:II};zk.useEffectEvent=kI;var $I={readContext:Ta,use:Wv,useCallback:jI,useContext:Ta,useEffect:Rk,useImperativeHandle:CI,useInsertionEffect:EI,useLayoutEffect:TI,useMemo:PI,useReducer:jk,useRef:NI,useState:function(){return jk(Ic)},useDebugValue:Ok,useDeferredValue:function(f,g){var w=ki();return wr===null?Lk(w,f,g):DI(w,wr.memoizedState,f,g)},useTransition:function(){var f=jk(Ic)[0],g=ki().memoizedState;return[typeof f=="boolean"?f:ob(f),g]},useSyncExternalStore:lI,useId:FI,useHostTransitionStatus:Ik,useFormState:SI,useActionState:SI,useOptimistic:function(f,g){var w=ki();return wr!==null?mI(w,wr,f,g):(w.baseState=f,[f,w.queue.dispatch])},useMemoCache:Ak,useCacheRefresh:II};$I.useEffectEvent=kI;function Bk(f,g,w,M){g=f.memoizedState,w=w(M,g),w=w==null?g:h({},g,w),f.memoizedState=w,f.lanes===0&&(f.updateQueue.baseState=w)}var Hk={enqueueSetState:function(f,g,w){f=f._reactInternals;var M=io(),R=sd(M);R.payload=g,w!=null&&(R.callback=w),g=od(f,R,M),g!==null&&(Ds(g,f,M),rb(g,f,M))},enqueueReplaceState:function(f,g,w){f=f._reactInternals;var M=io(),R=sd(M);R.tag=1,R.payload=g,w!=null&&(R.callback=w),g=od(f,R,M),g!==null&&(Ds(g,f,M),rb(g,f,M))},enqueueForceUpdate:function(f,g){f=f._reactInternals;var w=io(),M=sd(w);M.tag=2,g!=null&&(M.callback=g),g=od(f,M,w),g!==null&&(Ds(g,f,w),rb(g,f,w))}};function VI(f,g,w,M,R,F,Z){return f=f.stateNode,typeof f.shouldComponentUpdate=="function"?f.shouldComponentUpdate(M,F,Z):g.prototype&&g.prototype.isPureReactComponent?!Xx(w,M)||!Xx(R,F):!0}function GI(f,g,w,M){f=g.state,typeof g.componentWillReceiveProps=="function"&&g.componentWillReceiveProps(w,M),typeof g.UNSAFE_componentWillReceiveProps=="function"&&g.UNSAFE_componentWillReceiveProps(w,M),g.state!==f&&Hk.enqueueReplaceState(g,g.state,null)}function sf(f,g){var w=g;if("ref"in g){w={};for(var M in g)M!=="ref"&&(w[M]=g[M])}if(f=f.defaultProps){w===g&&(w=h({},w));for(var R in f)w[R]===void 0&&(w[R]=f[R])}return w}function qI(f){Av(f)}function WI(f){console.error(f)}function KI(f){Av(f)}function Zv(f,g){try{var w=f.onUncaughtError;w(g.value,{componentStack:g.stack})}catch(M){setTimeout(function(){throw M})}}function XI(f,g,w){try{var M=f.onCaughtError;M(w.value,{componentStack:w.stack,errorBoundary:g.tag===1?g.stateNode:null})}catch(R){setTimeout(function(){throw R})}}function $k(f,g,w){return w=sd(w),w.tag=3,w.payload={element:null},w.callback=function(){Zv(f,g)},w}function YI(f){return f=sd(f),f.tag=3,f}function QI(f,g,w,M){var R=w.type.getDerivedStateFromError;if(typeof R=="function"){var F=M.value;f.payload=function(){return R(F)},f.callback=function(){XI(g,w,M)}}var Z=w.stateNode;Z!==null&&typeof Z.componentDidCatch=="function"&&(f.callback=function(){XI(g,w,M),typeof R!="function"&&(fd===null?fd=new Set([this]):fd.add(this));var ve=M.stack;this.componentDidCatch(M.value,{componentStack:ve!==null?ve:""})})}function Iie(f,g,w,M,R){if(w.flags|=32768,M!==null&&typeof M=="object"&&typeof M.then=="function"){if(g=w.alternate,g!==null&&Km(g,w,R,!0),w=eo.current,w!==null){switch(w.tag){case 31:case 13:return Lo===null?uw():w.alternate===null&&mi===0&&(mi=3),w.flags&=-257,w.flags|=65536,w.lanes=R,M===Uv?w.flags|=16384:(g=w.updateQueue,g===null?w.updateQueue=new Set([M]):g.add(M),mE(f,M,R)),!1;case 22:return w.flags|=65536,M===Uv?w.flags|=16384:(g=w.updateQueue,g===null?(g={transitions:null,markerInstances:null,retryQueue:new Set([M])},w.updateQueue=g):(w=g.retryQueue,w===null?g.retryQueue=new Set([M]):w.add(M)),mE(f,M,R)),!1}throw Error(r(435,w.tag))}return mE(f,M,R),uw(),!1}if(Yn)return g=eo.current,g!==null?((g.flags&65536)===0&&(g.flags|=256),g.flags|=65536,g.lanes=R,M!==lk&&(f=Error(r(422),{cause:M}),Zx(Po(f,w)))):(M!==lk&&(g=Error(r(423),{cause:M}),Zx(Po(g,w))),f=f.current.alternate,f.flags|=65536,R&=-R,f.lanes|=R,M=Po(M,w),R=$k(f.stateNode,M,R),yk(f,R),mi!==4&&(mi=2)),!1;var F=Error(r(520),{cause:M});if(F=Po(F,w),xb===null?xb=[F]:xb.push(F),mi!==4&&(mi=2),g===null)return!0;M=Po(M,w),w=g;do{switch(w.tag){case 3:return w.flags|=65536,f=R&-R,w.lanes|=f,f=$k(w.stateNode,M,f),yk(w,f),!1;case 1:if(g=w.type,F=w.stateNode,(w.flags&128)===0&&(typeof g.getDerivedStateFromError=="function"||F!==null&&typeof F.componentDidCatch=="function"&&(fd===null||!fd.has(F))))return w.flags|=65536,R&=-R,w.lanes|=R,R=YI(R),QI(R,f,w,M),yk(w,R),!1}w=w.return}while(w!==null);return!1}var Vk=Error(r(461)),Di=!1;function Aa(f,g,w,M){g.child=f===null?tI(g,null,w,M):rf(g,f.child,w,M)}function ZI(f,g,w,M,R){w=w.render;var F=g.ref;if("ref"in M){var Z={};for(var ve in M)ve!=="ref"&&(Z[ve]=M[ve])}else Z=M;return Jh(g),M=Mk(f,g,w,Z,F,R),ve=kk(),f!==null&&!Di?(Ek(f,g,R),Uc(f,g,R)):(Yn&&ve&&sk(g),g.flags|=1,Aa(f,g,M,R),g.child)}function JI(f,g,w,M,R){if(f===null){var F=w.type;return typeof F=="function"&&!rk(F)&&F.defaultProps===void 0&&w.compare===null?(g.tag=15,g.type=F,e5(f,g,F,M,R)):(f=Dv(w.type,null,M,g,g.mode,R),f.ref=g.ref,f.return=g,g.child=f)}if(F=f.child,!Zk(f,R)){var Z=F.memoizedProps;if(w=w.compare,w=w!==null?w:Xx,w(Z,M)&&f.ref===g.ref)return Uc(f,g,R)}return g.flags|=1,f=Dc(F,M),f.ref=g.ref,f.return=g,g.child=f}function e5(f,g,w,M,R){if(f!==null){var F=f.memoizedProps;if(Xx(F,M)&&f.ref===g.ref)if(Di=!1,g.pendingProps=M=F,Zk(f,R))(f.flags&131072)!==0&&(Di=!0);else return g.lanes=f.lanes,Uc(f,g,R)}return Gk(f,g,w,M,R)}function t5(f,g,w,M){var R=M.children,F=f!==null?f.memoizedState:null;if(f===null&&g.stateNode===null&&(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),M.mode==="hidden"){if((g.flags&128)!==0){if(F=F!==null?F.baseLanes|w:w,f!==null){for(M=g.child=f.child,R=0;M!==null;)R=R|M.lanes|M.childLanes,M=M.sibling;M=R&~F}else M=0,g.child=null;return n5(f,g,F,w,M)}if((w&536870912)!==0)g.memoizedState={baseLanes:0,cachePool:null},f!==null&&Fv(g,F!==null?F.cachePool:null),F!==null?iI(g,F):wk(),aI(g);else return M=g.lanes=536870912,n5(f,g,F!==null?F.baseLanes|w:w,w,M)}else F!==null?(Fv(g,F.cachePool),iI(g,F),cd(),g.memoizedState=null):(f!==null&&Fv(g,null),wk(),cd());return Aa(f,g,R,w),g.child}function ub(f,g){return f!==null&&f.tag===22||g.stateNode!==null||(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.sibling}function n5(f,g,w,M,R){var F=pk();return F=F===null?null:{parent:ji._currentValue,pool:F},g.memoizedState={baseLanes:w,cachePool:F},f!==null&&Fv(g,null),wk(),aI(g),f!==null&&Km(f,g,M,!0),g.childLanes=R,null}function Jv(f,g){return g=tw({mode:g.mode,children:g.children},f.mode),g.ref=f.ref,f.child=g,g.return=f,g}function r5(f,g,w){return rf(g,f.child,null,w),f=Jv(g,g.pendingProps),f.flags|=2,to(g),g.memoizedState=null,f}function Uie(f,g,w){var M=g.pendingProps,R=(g.flags&128)!==0;if(g.flags&=-129,f===null){if(Yn){if(M.mode==="hidden")return f=Jv(g,M),g.lanes=536870912,ub(null,f);if(Sk(g),(f=$r)?(f=pU(f,Oo),f=f!==null&&f.data==="&"?f:null,f!==null&&(g.memoizedState={dehydrated:f,treeContext:td!==null?{id:Wl,overflow:Kl}:null,retryLane:536870912,hydrationErrors:null},w=zF(f),w.return=g,g.child=w,Ea=g,$r=null)):f=null,f===null)throw rd(g);return g.lanes=536870912,null}return Jv(g,M)}var F=f.memoizedState;if(F!==null){var Z=F.dehydrated;if(Sk(g),R)if(g.flags&256)g.flags&=-257,g=r5(f,g,w);else if(g.memoizedState!==null)g.child=f.child,g.flags|=128,g=null;else throw Error(r(558));else if(Di||Km(f,g,w,!1),R=(w&f.childLanes)!==0,Di||R){if(M=Pr,M!==null&&(Z=rr(M,w),Z!==0&&Z!==F.retryLane))throw F.retryLane=Z,Xh(f,Z),Ds(M,f,Z),Vk;uw(),g=r5(f,g,w)}else f=F.treeContext,$r=Fo(Z.nextSibling),Ea=g,Yn=!0,nd=null,Oo=!1,f!==null&&$F(g,f),g=Jv(g,M),g.flags|=4096;return g}return f=Dc(f.child,{mode:M.mode,children:M.children}),f.ref=g.ref,g.child=f,f.return=g,f}function ew(f,g){var w=g.ref;if(w===null)f!==null&&f.ref!==null&&(g.flags|=4194816);else{if(typeof w!="function"&&typeof w!="object")throw Error(r(284));(f===null||f.ref!==w)&&(g.flags|=4194816)}}function Gk(f,g,w,M,R){return Jh(g),w=Mk(f,g,w,M,void 0,R),M=kk(),f!==null&&!Di?(Ek(f,g,R),Uc(f,g,R)):(Yn&&M&&sk(g),g.flags|=1,Aa(f,g,w,R),g.child)}function i5(f,g,w,M,R,F){return Jh(g),g.updateQueue=null,w=oI(g,M,w,R),sI(f),M=kk(),f!==null&&!Di?(Ek(f,g,F),Uc(f,g,F)):(Yn&&M&&sk(g),g.flags|=1,Aa(f,g,w,F),g.child)}function a5(f,g,w,M,R){if(Jh(g),g.stateNode===null){var F=Vm,Z=w.contextType;typeof Z=="object"&&Z!==null&&(F=Ta(Z)),F=new w(M,F),g.memoizedState=F.state!==null&&F.state!==void 0?F.state:null,F.updater=Hk,g.stateNode=F,F._reactInternals=g,F=g.stateNode,F.props=M,F.state=g.memoizedState,F.refs={},xk(g),Z=w.contextType,F.context=typeof Z=="object"&&Z!==null?Ta(Z):Vm,F.state=g.memoizedState,Z=w.getDerivedStateFromProps,typeof Z=="function"&&(Bk(g,w,Z,M),F.state=g.memoizedState),typeof w.getDerivedStateFromProps=="function"||typeof F.getSnapshotBeforeUpdate=="function"||typeof F.UNSAFE_componentWillMount!="function"&&typeof F.componentWillMount!="function"||(Z=F.state,typeof F.componentWillMount=="function"&&F.componentWillMount(),typeof F.UNSAFE_componentWillMount=="function"&&F.UNSAFE_componentWillMount(),Z!==F.state&&Hk.enqueueReplaceState(F,F.state,null),ab(g,M,F,R),ib(),F.state=g.memoizedState),typeof F.componentDidMount=="function"&&(g.flags|=4194308),M=!0}else if(f===null){F=g.stateNode;var ve=g.memoizedProps,Ue=sf(w,ve);F.props=Ue;var lt=F.context,bt=w.contextType;Z=Vm,typeof bt=="object"&&bt!==null&&(Z=Ta(bt));var wt=w.getDerivedStateFromProps;bt=typeof wt=="function"||typeof F.getSnapshotBeforeUpdate=="function",ve=g.pendingProps!==ve,bt||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(ve||lt!==Z)&&GI(g,F,M,Z),ad=!1;var ft=g.memoizedState;F.state=ft,ab(g,M,F,R),ib(),lt=g.memoizedState,ve||ft!==lt||ad?(typeof wt=="function"&&(Bk(g,w,wt,M),lt=g.memoizedState),(Ue=ad||VI(g,w,Ue,M,ft,lt,Z))?(bt||typeof F.UNSAFE_componentWillMount!="function"&&typeof F.componentWillMount!="function"||(typeof F.componentWillMount=="function"&&F.componentWillMount(),typeof F.UNSAFE_componentWillMount=="function"&&F.UNSAFE_componentWillMount()),typeof F.componentDidMount=="function"&&(g.flags|=4194308)):(typeof F.componentDidMount=="function"&&(g.flags|=4194308),g.memoizedProps=M,g.memoizedState=lt),F.props=M,F.state=lt,F.context=Z,M=Ue):(typeof F.componentDidMount=="function"&&(g.flags|=4194308),M=!1)}else{F=g.stateNode,bk(f,g),Z=g.memoizedProps,bt=sf(w,Z),F.props=bt,wt=g.pendingProps,ft=F.context,lt=w.contextType,Ue=Vm,typeof lt=="object"&&lt!==null&&(Ue=Ta(lt)),ve=w.getDerivedStateFromProps,(lt=typeof ve=="function"||typeof F.getSnapshotBeforeUpdate=="function")||typeof F.UNSAFE_componentWillReceiveProps!="function"&&typeof F.componentWillReceiveProps!="function"||(Z!==wt||ft!==Ue)&&GI(g,F,M,Ue),ad=!1,ft=g.memoizedState,F.state=ft,ab(g,M,F,R),ib();var xt=g.memoizedState;Z!==wt||ft!==xt||ad||f!==null&&f.dependencies!==null&&Ov(f.dependencies)?(typeof ve=="function"&&(Bk(g,w,ve,M),xt=g.memoizedState),(bt=ad||VI(g,w,bt,M,ft,xt,Ue)||f!==null&&f.dependencies!==null&&Ov(f.dependencies))?(lt||typeof F.UNSAFE_componentWillUpdate!="function"&&typeof F.componentWillUpdate!="function"||(typeof F.componentWillUpdate=="function"&&F.componentWillUpdate(M,xt,Ue),typeof F.UNSAFE_componentWillUpdate=="function"&&F.UNSAFE_componentWillUpdate(M,xt,Ue)),typeof F.componentDidUpdate=="function"&&(g.flags|=4),typeof F.getSnapshotBeforeUpdate=="function"&&(g.flags|=1024)):(typeof F.componentDidUpdate!="function"||Z===f.memoizedProps&&ft===f.memoizedState||(g.flags|=4),typeof F.getSnapshotBeforeUpdate!="function"||Z===f.memoizedProps&&ft===f.memoizedState||(g.flags|=1024),g.memoizedProps=M,g.memoizedState=xt),F.props=M,F.state=xt,F.context=Ue,M=bt):(typeof F.componentDidUpdate!="function"||Z===f.memoizedProps&&ft===f.memoizedState||(g.flags|=4),typeof F.getSnapshotBeforeUpdate!="function"||Z===f.memoizedProps&&ft===f.memoizedState||(g.flags|=1024),M=!1)}return F=M,ew(f,g),M=(g.flags&128)!==0,F||M?(F=g.stateNode,w=M&&typeof w.getDerivedStateFromError!="function"?null:F.render(),g.flags|=1,f!==null&&M?(g.child=rf(g,f.child,null,R),g.child=rf(g,null,w,R)):Aa(f,g,w,R),g.memoizedState=F.state,f=g.child):f=Uc(f,g,R),f}function s5(f,g,w,M){return Qh(),g.flags|=256,Aa(f,g,w,M),g.child}var qk={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Wk(f){return{baseLanes:f,cachePool:XF()}}function Kk(f,g,w){return f=f!==null?f.childLanes&~w:0,g&&(f|=ro),f}function o5(f,g,w){var M=g.pendingProps,R=!1,F=(g.flags&128)!==0,Z;if((Z=F)||(Z=f!==null&&f.memoizedState===null?!1:(Mi.current&2)!==0),Z&&(R=!0,g.flags&=-129),Z=(g.flags&32)!==0,g.flags&=-33,f===null){if(Yn){if(R?ld(g):cd(),(f=$r)?(f=pU(f,Oo),f=f!==null&&f.data!=="&"?f:null,f!==null&&(g.memoizedState={dehydrated:f,treeContext:td!==null?{id:Wl,overflow:Kl}:null,retryLane:536870912,hydrationErrors:null},w=zF(f),w.return=g,g.child=w,Ea=g,$r=null)):f=null,f===null)throw rd(g);return CE(f)?g.lanes=32:g.lanes=536870912,null}var ve=M.children;return M=M.fallback,R?(cd(),R=g.mode,ve=tw({mode:"hidden",children:ve},R),M=Yh(M,R,w,null),ve.return=g,M.return=g,ve.sibling=M,g.child=ve,M=g.child,M.memoizedState=Wk(w),M.childLanes=Kk(f,Z,w),g.memoizedState=qk,ub(null,M)):(ld(g),Xk(g,ve))}var Ue=f.memoizedState;if(Ue!==null&&(ve=Ue.dehydrated,ve!==null)){if(F)g.flags&256?(ld(g),g.flags&=-257,g=Yk(f,g,w)):g.memoizedState!==null?(cd(),g.child=f.child,g.flags|=128,g=null):(cd(),ve=M.fallback,R=g.mode,M=tw({mode:"visible",children:M.children},R),ve=Yh(ve,R,w,null),ve.flags|=2,M.return=g,ve.return=g,M.sibling=ve,g.child=M,rf(g,f.child,null,w),M=g.child,M.memoizedState=Wk(w),M.childLanes=Kk(f,Z,w),g.memoizedState=qk,g=ub(null,M));else if(ld(g),CE(ve)){if(Z=ve.nextSibling&&ve.nextSibling.dataset,Z)var lt=Z.dgst;Z=lt,M=Error(r(419)),M.stack="",M.digest=Z,Zx({value:M,source:null,stack:null}),g=Yk(f,g,w)}else if(Di||Km(f,g,w,!1),Z=(w&f.childLanes)!==0,Di||Z){if(Z=Pr,Z!==null&&(M=rr(Z,w),M!==0&&M!==Ue.retryLane))throw Ue.retryLane=M,Xh(f,M),Ds(Z,f,M),Vk;AE(ve)||uw(),g=Yk(f,g,w)}else AE(ve)?(g.flags|=192,g.child=f.child,g=null):(f=Ue.treeContext,$r=Fo(ve.nextSibling),Ea=g,Yn=!0,nd=null,Oo=!1,f!==null&&$F(g,f),g=Xk(g,M.children),g.flags|=4096);return g}return R?(cd(),ve=M.fallback,R=g.mode,Ue=f.child,lt=Ue.sibling,M=Dc(Ue,{mode:"hidden",children:M.children}),M.subtreeFlags=Ue.subtreeFlags&65011712,lt!==null?ve=Dc(lt,ve):(ve=Yh(ve,R,w,null),ve.flags|=2),ve.return=g,M.return=g,M.sibling=ve,g.child=M,ub(null,M),M=g.child,ve=f.child.memoizedState,ve===null?ve=Wk(w):(R=ve.cachePool,R!==null?(Ue=ji._currentValue,R=R.parent!==Ue?{parent:Ue,pool:Ue}:R):R=XF(),ve={baseLanes:ve.baseLanes|w,cachePool:R}),M.memoizedState=ve,M.childLanes=Kk(f,Z,w),g.memoizedState=qk,ub(f.child,M)):(ld(g),w=f.child,f=w.sibling,w=Dc(w,{mode:"visible",children:M.children}),w.return=g,w.sibling=null,f!==null&&(Z=g.deletions,Z===null?(g.deletions=[f],g.flags|=16):Z.push(f)),g.child=w,g.memoizedState=null,w)}function Xk(f,g){return g=tw({mode:"visible",children:g},f.mode),g.return=f,f.child=g}function tw(f,g){return f=Js(22,f,null,g),f.lanes=0,f}function Yk(f,g,w){return rf(g,f.child,null,w),f=Xk(g,g.pendingProps.children),f.flags|=2,g.memoizedState=null,f}function l5(f,g,w){f.lanes|=g;var M=f.alternate;M!==null&&(M.lanes|=g),dk(f.return,g,w)}function Qk(f,g,w,M,R,F){var Z=f.memoizedState;Z===null?f.memoizedState={isBackwards:g,rendering:null,renderingStartTime:0,last:M,tail:w,tailMode:R,treeForkCount:F}:(Z.isBackwards=g,Z.rendering=null,Z.renderingStartTime=0,Z.last=M,Z.tail=w,Z.tailMode=R,Z.treeForkCount=F)}function c5(f,g,w){var M=g.pendingProps,R=M.revealOrder,F=M.tail;M=M.children;var Z=Mi.current,ve=(Z&2)!==0;if(ve?(Z=Z&1|2,g.flags|=128):Z&=1,ne(Mi,Z),Aa(f,g,M,w),M=Yn?Qx:0,!ve&&f!==null&&(f.flags&128)!==0)e:for(f=g.child;f!==null;){if(f.tag===13)f.memoizedState!==null&&l5(f,w,g);else if(f.tag===19)l5(f,w,g);else if(f.child!==null){f.child.return=f,f=f.child;continue}if(f===g)break e;for(;f.sibling===null;){if(f.return===null||f.return===g)break e;f=f.return}f.sibling.return=f.return,f=f.sibling}switch(R){case"forwards":for(w=g.child,R=null;w!==null;)f=w.alternate,f!==null&&$v(f)===null&&(R=w),w=w.sibling;w=R,w===null?(R=g.child,g.child=null):(R=w.sibling,w.sibling=null),Qk(g,!1,R,w,F,M);break;case"backwards":case"unstable_legacy-backwards":for(w=null,R=g.child,g.child=null;R!==null;){if(f=R.alternate,f!==null&&$v(f)===null){g.child=R;break}f=R.sibling,R.sibling=w,w=R,R=f}Qk(g,!0,w,null,F,M);break;case"together":Qk(g,!1,null,null,void 0,M);break;default:g.memoizedState=null}return g.child}function Uc(f,g,w){if(f!==null&&(g.dependencies=f.dependencies),hd|=g.lanes,(w&g.childLanes)===0)if(f!==null){if(Km(f,g,w,!1),(w&g.childLanes)===0)return null}else return null;if(f!==null&&g.child!==f.child)throw Error(r(153));if(g.child!==null){for(f=g.child,w=Dc(f,f.pendingProps),g.child=w,w.return=g;f.sibling!==null;)f=f.sibling,w=w.sibling=Dc(f,f.pendingProps),w.return=g;w.sibling=null}return g.child}function Zk(f,g){return(f.lanes&g)!==0?!0:(f=f.dependencies,!!(f!==null&&Ov(f)))}function zie(f,g,w){switch(g.tag){case 3:Te(g,g.stateNode.containerInfo),id(g,ji,f.memoizedState.cache),Qh();break;case 27:case 5:Ce(g);break;case 4:Te(g,g.stateNode.containerInfo);break;case 10:id(g,g.type,g.memoizedProps.value);break;case 31:if(g.memoizedState!==null)return g.flags|=128,Sk(g),null;break;case 13:var M=g.memoizedState;if(M!==null)return M.dehydrated!==null?(ld(g),g.flags|=128,null):(w&g.child.childLanes)!==0?o5(f,g,w):(ld(g),f=Uc(f,g,w),f!==null?f.sibling:null);ld(g);break;case 19:var R=(f.flags&128)!==0;if(M=(w&g.childLanes)!==0,M||(Km(f,g,w,!1),M=(w&g.childLanes)!==0),R){if(M)return c5(f,g,w);g.flags|=128}if(R=g.memoizedState,R!==null&&(R.rendering=null,R.tail=null,R.lastEffect=null),ne(Mi,Mi.current),M)break;return null;case 22:return g.lanes=0,t5(f,g,w,g.pendingProps);case 24:id(g,ji,f.memoizedState.cache)}return Uc(f,g,w)}function u5(f,g,w){if(f!==null)if(f.memoizedProps!==g.pendingProps)Di=!0;else{if(!Zk(f,w)&&(g.flags&128)===0)return Di=!1,zie(f,g,w);Di=(f.flags&131072)!==0}else Di=!1,Yn&&(g.flags&1048576)!==0&&HF(g,Qx,g.index);switch(g.lanes=0,g.tag){case 16:e:{var M=g.pendingProps;if(f=tf(g.elementType),g.type=f,typeof f=="function")rk(f)?(M=sf(f,M),g.tag=1,g=a5(null,g,f,M,w)):(g.tag=0,g=Gk(null,g,f,M,w));else{if(f!=null){var R=f.$$typeof;if(R===T){g.tag=11,g=ZI(null,g,f,M,w);break e}else if(R===E){g.tag=14,g=JI(null,g,f,M,w);break e}}throw g=j(f)||f,Error(r(306,g,""))}}return g;case 0:return Gk(f,g,g.type,g.pendingProps,w);case 1:return M=g.type,R=sf(M,g.pendingProps),a5(f,g,M,R,w);case 3:e:{if(Te(g,g.stateNode.containerInfo),f===null)throw Error(r(387));M=g.pendingProps;var F=g.memoizedState;R=F.element,bk(f,g),ab(g,M,null,w);var Z=g.memoizedState;if(M=Z.cache,id(g,ji,M),M!==F.cache&&hk(g,[ji],w,!0),ib(),M=Z.element,F.isDehydrated)if(F={element:M,isDehydrated:!1,cache:Z.cache},g.updateQueue.baseState=F,g.memoizedState=F,g.flags&256){g=s5(f,g,M,w);break e}else if(M!==R){R=Po(Error(r(424)),g),Zx(R),g=s5(f,g,M,w);break e}else{switch(f=g.stateNode.containerInfo,f.nodeType){case 9:f=f.body;break;default:f=f.nodeName==="HTML"?f.ownerDocument.body:f}for($r=Fo(f.firstChild),Ea=g,Yn=!0,nd=null,Oo=!0,w=tI(g,null,M,w),g.child=w;w;)w.flags=w.flags&-3|4096,w=w.sibling}else{if(Qh(),M===R){g=Uc(f,g,w);break e}Aa(f,g,M,w)}g=g.child}return g;case 26:return ew(f,g),f===null?(w=wU(g.type,null,g.pendingProps,null))?g.memoizedState=w:Yn||(w=g.type,f=g.pendingProps,M=xw(me.current).createElement(w),M[Xn]=g,M[Nn]=f,Ca(M,w,f),Ne(M),g.stateNode=M):g.memoizedState=wU(g.type,f.memoizedProps,g.pendingProps,f.memoizedState),null;case 27:return Ce(g),f===null&&Yn&&(M=g.stateNode=bU(g.type,g.pendingProps,me.current),Ea=g,Oo=!0,R=$r,xd(g.type)?(jE=R,$r=Fo(M.firstChild)):$r=R),Aa(f,g,g.pendingProps.children,w),ew(f,g),f===null&&(g.flags|=4194304),g.child;case 5:return f===null&&Yn&&((R=M=$r)&&(M=gae(M,g.type,g.pendingProps,Oo),M!==null?(g.stateNode=M,Ea=g,$r=Fo(M.firstChild),Oo=!1,R=!0):R=!1),R||rd(g)),Ce(g),R=g.type,F=g.pendingProps,Z=f!==null?f.memoizedProps:null,M=F.children,kE(R,F)?M=null:Z!==null&&kE(R,Z)&&(g.flags|=32),g.memoizedState!==null&&(R=Mk(f,g,jie,null,null,w),Mb._currentValue=R),ew(f,g),Aa(f,g,M,w),g.child;case 6:return f===null&&Yn&&((f=w=$r)&&(w=xae(w,g.pendingProps,Oo),w!==null?(g.stateNode=w,Ea=g,$r=null,f=!0):f=!1),f||rd(g)),null;case 13:return o5(f,g,w);case 4:return Te(g,g.stateNode.containerInfo),M=g.pendingProps,f===null?g.child=rf(g,null,M,w):Aa(f,g,M,w),g.child;case 11:return ZI(f,g,g.type,g.pendingProps,w);case 7:return Aa(f,g,g.pendingProps,w),g.child;case 8:return Aa(f,g,g.pendingProps.children,w),g.child;case 12:return Aa(f,g,g.pendingProps.children,w),g.child;case 10:return M=g.pendingProps,id(g,g.type,M.value),Aa(f,g,M.children,w),g.child;case 9:return R=g.type._context,M=g.pendingProps.children,Jh(g),R=Ta(R),M=M(R),g.flags|=1,Aa(f,g,M,w),g.child;case 14:return JI(f,g,g.type,g.pendingProps,w);case 15:return e5(f,g,g.type,g.pendingProps,w);case 19:return c5(f,g,w);case 31:return Uie(f,g,w);case 22:return t5(f,g,w,g.pendingProps);case 24:return Jh(g),M=Ta(ji),f===null?(R=pk(),R===null&&(R=Pr,F=fk(),R.pooledCache=F,F.refCount++,F!==null&&(R.pooledCacheLanes|=w),R=F),g.memoizedState={parent:M,cache:R},xk(g),id(g,ji,R)):((f.lanes&w)!==0&&(bk(f,g),ab(g,null,null,w),ib()),R=f.memoizedState,F=g.memoizedState,R.parent!==M?(R={parent:M,cache:M},g.memoizedState=R,g.lanes===0&&(g.memoizedState=g.updateQueue.baseState=R),id(g,ji,M)):(M=F.cache,id(g,ji,M),M!==R.cache&&hk(g,[ji],w,!0))),Aa(f,g,g.pendingProps.children,w),g.child;case 29:throw g.pendingProps}throw Error(r(156,g.tag))}function zc(f){f.flags|=4}function Jk(f,g,w,M,R){if((g=(f.mode&32)!==0)&&(g=!1),g){if(f.flags|=16777216,(R&335544128)===R)if(f.stateNode.complete)f.flags|=8192;else if(F5())f.flags|=8192;else throw nf=Uv,gk}else f.flags&=-16777217}function d5(f,g){if(g.type!=="stylesheet"||(g.state.loading&4)!==0)f.flags&=-16777217;else if(f.flags|=16777216,!kU(g))if(F5())f.flags|=8192;else throw nf=Uv,gk}function nw(f,g){g!==null&&(f.flags|=4),f.flags&16384&&(g=f.tag!==22?Je():536870912,f.lanes|=g,sp|=g)}function db(f,g){if(!Yn)switch(f.tailMode){case"hidden":g=f.tail;for(var w=null;g!==null;)g.alternate!==null&&(w=g),g=g.sibling;w===null?f.tail=null:w.sibling=null;break;case"collapsed":w=f.tail;for(var M=null;w!==null;)w.alternate!==null&&(M=w),w=w.sibling;M===null?g||f.tail===null?f.tail=null:f.tail.sibling=null:M.sibling=null}}function Vr(f){var g=f.alternate!==null&&f.alternate.child===f.child,w=0,M=0;if(g)for(var R=f.child;R!==null;)w|=R.lanes|R.childLanes,M|=R.subtreeFlags&65011712,M|=R.flags&65011712,R.return=f,R=R.sibling;else for(R=f.child;R!==null;)w|=R.lanes|R.childLanes,M|=R.subtreeFlags,M|=R.flags,R.return=f,R=R.sibling;return f.subtreeFlags|=M,f.childLanes=w,g}function Bie(f,g,w){var M=g.pendingProps;switch(ok(g),g.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Vr(g),null;case 1:return Vr(g),null;case 3:return w=g.stateNode,M=null,f!==null&&(M=f.memoizedState.cache),g.memoizedState.cache!==M&&(g.flags|=2048),Lc(ji),ie(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(f===null||f.child===null)&&(Wm(g)?zc(g):f===null||f.memoizedState.isDehydrated&&(g.flags&256)===0||(g.flags|=1024,ck())),Vr(g),null;case 26:var R=g.type,F=g.memoizedState;return f===null?(zc(g),F!==null?(Vr(g),d5(g,F)):(Vr(g),Jk(g,R,null,M,w))):F?F!==f.memoizedState?(zc(g),Vr(g),d5(g,F)):(Vr(g),g.flags&=-16777217):(f=f.memoizedProps,f!==M&&zc(g),Vr(g),Jk(g,R,f,M,w)),null;case 27:if(Fe(g),w=me.current,R=g.type,f!==null&&g.stateNode!=null)f.memoizedProps!==M&&zc(g);else{if(!M){if(g.stateNode===null)throw Error(r(166));return Vr(g),null}f=re.current,Wm(g)?VF(g):(f=bU(R,M,w),g.stateNode=f,zc(g))}return Vr(g),null;case 5:if(Fe(g),R=g.type,f!==null&&g.stateNode!=null)f.memoizedProps!==M&&zc(g);else{if(!M){if(g.stateNode===null)throw Error(r(166));return Vr(g),null}if(F=re.current,Wm(g))VF(g);else{var Z=xw(me.current);switch(F){case 1:F=Z.createElementNS("http://www.w3.org/2000/svg",R);break;case 2:F=Z.createElementNS("http://www.w3.org/1998/Math/MathML",R);break;default:switch(R){case"svg":F=Z.createElementNS("http://www.w3.org/2000/svg",R);break;case"math":F=Z.createElementNS("http://www.w3.org/1998/Math/MathML",R);break;case"script":F=Z.createElement("div"),F.innerHTML="<script><\/script>",F=F.removeChild(F.firstChild);break;case"select":F=typeof M.is=="string"?Z.createElement("select",{is:M.is}):Z.createElement("select"),M.multiple?F.multiple=!0:M.size&&(F.size=M.size);break;default:F=typeof M.is=="string"?Z.createElement(R,{is:M.is}):Z.createElement(R)}}F[Xn]=g,F[Nn]=M;e:for(Z=g.child;Z!==null;){if(Z.tag===5||Z.tag===6)F.appendChild(Z.stateNode);else if(Z.tag!==4&&Z.tag!==27&&Z.child!==null){Z.child.return=Z,Z=Z.child;continue}if(Z===g)break e;for(;Z.sibling===null;){if(Z.return===null||Z.return===g)break e;Z=Z.return}Z.sibling.return=Z.return,Z=Z.sibling}g.stateNode=F;e:switch(Ca(F,R,M),R){case"button":case"input":case"select":case"textarea":M=!!M.autoFocus;break e;case"img":M=!0;break e;default:M=!1}M&&zc(g)}}return Vr(g),Jk(g,g.type,f===null?null:f.memoizedProps,g.pendingProps,w),null;case 6:if(f&&g.stateNode!=null)f.memoizedProps!==M&&zc(g);else{if(typeof M!="string"&&g.stateNode===null)throw Error(r(166));if(f=me.current,Wm(g)){if(f=g.stateNode,w=g.memoizedProps,M=null,R=Ea,R!==null)switch(R.tag){case 27:case 5:M=R.memoizedProps}f[Xn]=g,f=!!(f.nodeValue===w||M!==null&&M.suppressHydrationWarning===!0||oU(f.nodeValue,w)),f||rd(g,!0)}else f=xw(f).createTextNode(M),f[Xn]=g,g.stateNode=f}return Vr(g),null;case 31:if(w=g.memoizedState,f===null||f.memoizedState!==null){if(M=Wm(g),w!==null){if(f===null){if(!M)throw Error(r(318));if(f=g.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(r(557));f[Xn]=g}else Qh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Vr(g),f=!1}else w=ck(),f!==null&&f.memoizedState!==null&&(f.memoizedState.hydrationErrors=w),f=!0;if(!f)return g.flags&256?(to(g),g):(to(g),null);if((g.flags&128)!==0)throw Error(r(558))}return Vr(g),null;case 13:if(M=g.memoizedState,f===null||f.memoizedState!==null&&f.memoizedState.dehydrated!==null){if(R=Wm(g),M!==null&&M.dehydrated!==null){if(f===null){if(!R)throw Error(r(318));if(R=g.memoizedState,R=R!==null?R.dehydrated:null,!R)throw Error(r(317));R[Xn]=g}else Qh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Vr(g),R=!1}else R=ck(),f!==null&&f.memoizedState!==null&&(f.memoizedState.hydrationErrors=R),R=!0;if(!R)return g.flags&256?(to(g),g):(to(g),null)}return to(g),(g.flags&128)!==0?(g.lanes=w,g):(w=M!==null,f=f!==null&&f.memoizedState!==null,w&&(M=g.child,R=null,M.alternate!==null&&M.alternate.memoizedState!==null&&M.alternate.memoizedState.cachePool!==null&&(R=M.alternate.memoizedState.cachePool.pool),F=null,M.memoizedState!==null&&M.memoizedState.cachePool!==null&&(F=M.memoizedState.cachePool.pool),F!==R&&(M.flags|=2048)),w!==f&&w&&(g.child.flags|=8192),nw(g,g.updateQueue),Vr(g),null);case 4:return ie(),f===null&&wE(g.stateNode.containerInfo),Vr(g),null;case 10:return Lc(g.type),Vr(g),null;case 19:if(W(Mi),M=g.memoizedState,M===null)return Vr(g),null;if(R=(g.flags&128)!==0,F=M.rendering,F===null)if(R)db(M,!1);else{if(mi!==0||f!==null&&(f.flags&128)!==0)for(f=g.child;f!==null;){if(F=$v(f),F!==null){for(g.flags|=128,db(M,!1),f=F.updateQueue,g.updateQueue=f,nw(g,f),g.subtreeFlags=0,f=w,w=g.child;w!==null;)UF(w,f),w=w.sibling;return ne(Mi,Mi.current&1|2),Yn&&Rc(g,M.treeForkCount),g.child}f=f.sibling}M.tail!==null&&O()>ow&&(g.flags|=128,R=!0,db(M,!1),g.lanes=4194304)}else{if(!R)if(f=$v(F),f!==null){if(g.flags|=128,R=!0,f=f.updateQueue,g.updateQueue=f,nw(g,f),db(M,!0),M.tail===null&&M.tailMode==="hidden"&&!F.alternate&&!Yn)return Vr(g),null}else 2*O()-M.renderingStartTime>ow&&w!==536870912&&(g.flags|=128,R=!0,db(M,!1),g.lanes=4194304);M.isBackwards?(F.sibling=g.child,g.child=F):(f=M.last,f!==null?f.sibling=F:g.child=F,M.last=F)}return M.tail!==null?(f=M.tail,M.rendering=f,M.tail=f.sibling,M.renderingStartTime=O(),f.sibling=null,w=Mi.current,ne(Mi,R?w&1|2:w&1),Yn&&Rc(g,M.treeForkCount),f):(Vr(g),null);case 22:case 23:return to(g),_k(),M=g.memoizedState!==null,f!==null?f.memoizedState!==null!==M&&(g.flags|=8192):M&&(g.flags|=8192),M?(w&536870912)!==0&&(g.flags&128)===0&&(Vr(g),g.subtreeFlags&6&&(g.flags|=8192)):Vr(g),w=g.updateQueue,w!==null&&nw(g,w.retryQueue),w=null,f!==null&&f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(w=f.memoizedState.cachePool.pool),M=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(M=g.memoizedState.cachePool.pool),M!==w&&(g.flags|=2048),f!==null&&W(ef),null;case 24:return w=null,f!==null&&(w=f.memoizedState.cache),g.memoizedState.cache!==w&&(g.flags|=2048),Lc(ji),Vr(g),null;case 25:return null;case 30:return null}throw Error(r(156,g.tag))}function Hie(f,g){switch(ok(g),g.tag){case 1:return f=g.flags,f&65536?(g.flags=f&-65537|128,g):null;case 3:return Lc(ji),ie(),f=g.flags,(f&65536)!==0&&(f&128)===0?(g.flags=f&-65537|128,g):null;case 26:case 27:case 5:return Fe(g),null;case 31:if(g.memoizedState!==null){if(to(g),g.alternate===null)throw Error(r(340));Qh()}return f=g.flags,f&65536?(g.flags=f&-65537|128,g):null;case 13:if(to(g),f=g.memoizedState,f!==null&&f.dehydrated!==null){if(g.alternate===null)throw Error(r(340));Qh()}return f=g.flags,f&65536?(g.flags=f&-65537|128,g):null;case 19:return W(Mi),null;case 4:return ie(),null;case 10:return Lc(g.type),null;case 22:case 23:return to(g),_k(),f!==null&&W(ef),f=g.flags,f&65536?(g.flags=f&-65537|128,g):null;case 24:return Lc(ji),null;case 25:return null;default:return null}}function h5(f,g){switch(ok(g),g.tag){case 3:Lc(ji),ie();break;case 26:case 27:case 5:Fe(g);break;case 4:ie();break;case 31:g.memoizedState!==null&&to(g);break;case 13:to(g);break;case 19:W(Mi);break;case 10:Lc(g.type);break;case 22:case 23:to(g),_k(),f!==null&&W(ef);break;case 24:Lc(ji)}}function hb(f,g){try{var w=g.updateQueue,M=w!==null?w.lastEffect:null;if(M!==null){var R=M.next;w=R;do{if((w.tag&f)===f){M=void 0;var F=w.create,Z=w.inst;M=F(),Z.destroy=M}w=w.next}while(w!==R)}}catch(ve){gr(g,g.return,ve)}}function ud(f,g,w){try{var M=g.updateQueue,R=M!==null?M.lastEffect:null;if(R!==null){var F=R.next;M=F;do{if((M.tag&f)===f){var Z=M.inst,ve=Z.destroy;if(ve!==void 0){Z.destroy=void 0,R=g;var Ue=w,lt=ve;try{lt()}catch(bt){gr(R,Ue,bt)}}}M=M.next}while(M!==F)}}catch(bt){gr(g,g.return,bt)}}function f5(f){var g=f.updateQueue;if(g!==null){var w=f.stateNode;try{rI(g,w)}catch(M){gr(f,f.return,M)}}}function m5(f,g,w){w.props=sf(f.type,f.memoizedProps),w.state=f.memoizedState;try{w.componentWillUnmount()}catch(M){gr(f,g,M)}}function fb(f,g){try{var w=f.ref;if(w!==null){switch(f.tag){case 26:case 27:case 5:var M=f.stateNode;break;case 30:M=f.stateNode;break;default:M=f.stateNode}typeof w=="function"?f.refCleanup=w(M):w.current=M}}catch(R){gr(f,g,R)}}function Xl(f,g){var w=f.ref,M=f.refCleanup;if(w!==null)if(typeof M=="function")try{M()}catch(R){gr(f,g,R)}finally{f.refCleanup=null,f=f.alternate,f!=null&&(f.refCleanup=null)}else if(typeof w=="function")try{w(null)}catch(R){gr(f,g,R)}else w.current=null}function p5(f){var g=f.type,w=f.memoizedProps,M=f.stateNode;try{e:switch(g){case"button":case"input":case"select":case"textarea":w.autoFocus&&M.focus();break e;case"img":w.src?M.src=w.src:w.srcSet&&(M.srcset=w.srcSet)}}catch(R){gr(f,f.return,R)}}function eE(f,g,w){try{var M=f.stateNode;uae(M,f.type,w,g),M[Nn]=g}catch(R){gr(f,f.return,R)}}function g5(f){return f.tag===5||f.tag===3||f.tag===26||f.tag===27&&xd(f.type)||f.tag===4}function tE(f){e:for(;;){for(;f.sibling===null;){if(f.return===null||g5(f.return))return null;f=f.return}for(f.sibling.return=f.return,f=f.sibling;f.tag!==5&&f.tag!==6&&f.tag!==18;){if(f.tag===27&&xd(f.type)||f.flags&2||f.child===null||f.tag===4)continue e;f.child.return=f,f=f.child}if(!(f.flags&2))return f.stateNode}}function nE(f,g,w){var M=f.tag;if(M===5||M===6)f=f.stateNode,g?(w.nodeType===9?w.body:w.nodeName==="HTML"?w.ownerDocument.body:w).insertBefore(f,g):(g=w.nodeType===9?w.body:w.nodeName==="HTML"?w.ownerDocument.body:w,g.appendChild(f),w=w._reactRootContainer,w!=null||g.onclick!==null||(g.onclick=Si));else if(M!==4&&(M===27&&xd(f.type)&&(w=f.stateNode,g=null),f=f.child,f!==null))for(nE(f,g,w),f=f.sibling;f!==null;)nE(f,g,w),f=f.sibling}function rw(f,g,w){var M=f.tag;if(M===5||M===6)f=f.stateNode,g?w.insertBefore(f,g):w.appendChild(f);else if(M!==4&&(M===27&&xd(f.type)&&(w=f.stateNode),f=f.child,f!==null))for(rw(f,g,w),f=f.sibling;f!==null;)rw(f,g,w),f=f.sibling}function x5(f){var g=f.stateNode,w=f.memoizedProps;try{for(var M=f.type,R=g.attributes;R.length;)g.removeAttributeNode(R[0]);Ca(g,M,w),g[Xn]=f,g[Nn]=w}catch(F){gr(f,f.return,F)}}var Bc=!1,Ri=!1,rE=!1,b5=typeof WeakSet=="function"?WeakSet:Set,fa=null;function $ie(f,g){if(f=f.containerInfo,NE=Nw,f=CF(f),Y2(f)){if("selectionStart"in f)var w={start:f.selectionStart,end:f.selectionEnd};else e:{w=(w=f.ownerDocument)&&w.defaultView||window;var M=w.getSelection&&w.getSelection();if(M&&M.rangeCount!==0){w=M.anchorNode;var R=M.anchorOffset,F=M.focusNode;M=M.focusOffset;try{w.nodeType,F.nodeType}catch{w=null;break e}var Z=0,ve=-1,Ue=-1,lt=0,bt=0,wt=f,ft=null;t:for(;;){for(var xt;wt!==w||R!==0&&wt.nodeType!==3||(ve=Z+R),wt!==F||M!==0&&wt.nodeType!==3||(Ue=Z+M),wt.nodeType===3&&(Z+=wt.nodeValue.length),(xt=wt.firstChild)!==null;)ft=wt,wt=xt;for(;;){if(wt===f)break t;if(ft===w&&++lt===R&&(ve=Z),ft===F&&++bt===M&&(Ue=Z),(xt=wt.nextSibling)!==null)break;wt=ft,ft=wt.parentNode}wt=xt}w=ve===-1||Ue===-1?null:{start:ve,end:Ue}}else w=null}w=w||{start:0,end:0}}else w=null;for(ME={focusedElem:f,selectionRange:w},Nw=!1,fa=g;fa!==null;)if(g=fa,f=g.child,(g.subtreeFlags&1028)!==0&&f!==null)f.return=g,fa=f;else for(;fa!==null;){switch(g=fa,F=g.alternate,f=g.flags,g.tag){case 0:if((f&4)!==0&&(f=g.updateQueue,f=f!==null?f.events:null,f!==null))for(w=0;w<f.length;w++)R=f[w],R.ref.impl=R.nextImpl;break;case 11:case 15:break;case 1:if((f&1024)!==0&&F!==null){f=void 0,w=g,R=F.memoizedProps,F=F.memoizedState,M=w.stateNode;try{var Vt=sf(w.type,R);f=M.getSnapshotBeforeUpdate(Vt,F),M.__reactInternalSnapshotBeforeUpdate=f}catch(rn){gr(w,w.return,rn)}}break;case 3:if((f&1024)!==0){if(f=g.stateNode.containerInfo,w=f.nodeType,w===9)TE(f);else if(w===1)switch(f.nodeName){case"HEAD":case"HTML":case"BODY":TE(f);break;default:f.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((f&1024)!==0)throw Error(r(163))}if(f=g.sibling,f!==null){f.return=g.return,fa=f;break}fa=g.return}}function y5(f,g,w){var M=w.flags;switch(w.tag){case 0:case 11:case 15:$c(f,w),M&4&&hb(5,w);break;case 1:if($c(f,w),M&4)if(f=w.stateNode,g===null)try{f.componentDidMount()}catch(Z){gr(w,w.return,Z)}else{var R=sf(w.type,g.memoizedProps);g=g.memoizedState;try{f.componentDidUpdate(R,g,f.__reactInternalSnapshotBeforeUpdate)}catch(Z){gr(w,w.return,Z)}}M&64&&f5(w),M&512&&fb(w,w.return);break;case 3:if($c(f,w),M&64&&(f=w.updateQueue,f!==null)){if(g=null,w.child!==null)switch(w.child.tag){case 27:case 5:g=w.child.stateNode;break;case 1:g=w.child.stateNode}try{rI(f,g)}catch(Z){gr(w,w.return,Z)}}break;case 27:g===null&&M&4&&x5(w);case 26:case 5:$c(f,w),g===null&&M&4&&p5(w),M&512&&fb(w,w.return);break;case 12:$c(f,w);break;case 31:$c(f,w),M&4&&_5(f,w);break;case 13:$c(f,w),M&4&&S5(f,w),M&64&&(f=w.memoizedState,f!==null&&(f=f.dehydrated,f!==null&&(w=Zie.bind(null,w),bae(f,w))));break;case 22:if(M=w.memoizedState!==null||Bc,!M){g=g!==null&&g.memoizedState!==null||Ri,R=Bc;var F=Ri;Bc=M,(Ri=g)&&!F?Vc(f,w,(w.subtreeFlags&8772)!==0):$c(f,w),Bc=R,Ri=F}break;case 30:break;default:$c(f,w)}}function v5(f){var g=f.alternate;g!==null&&(f.alternate=null,v5(g)),f.child=null,f.deletions=null,f.sibling=null,f.tag===5&&(g=f.stateNode,g!==null&&ut(g)),f.stateNode=null,f.return=null,f.dependencies=null,f.memoizedProps=null,f.memoizedState=null,f.pendingProps=null,f.stateNode=null,f.updateQueue=null}var Zr=null,As=!1;function Hc(f,g,w){for(w=w.child;w!==null;)w5(f,g,w),w=w.sibling}function w5(f,g,w){if(be&&typeof be.onCommitFiberUnmount=="function")try{be.onCommitFiberUnmount(He,w)}catch{}switch(w.tag){case 26:Ri||Xl(w,g),Hc(f,g,w),w.memoizedState?w.memoizedState.count--:w.stateNode&&(w=w.stateNode,w.parentNode.removeChild(w));break;case 27:Ri||Xl(w,g);var M=Zr,R=As;xd(w.type)&&(Zr=w.stateNode,As=!1),Hc(f,g,w),_b(w.stateNode),Zr=M,As=R;break;case 5:Ri||Xl(w,g);case 6:if(M=Zr,R=As,Zr=null,Hc(f,g,w),Zr=M,As=R,Zr!==null)if(As)try{(Zr.nodeType===9?Zr.body:Zr.nodeName==="HTML"?Zr.ownerDocument.body:Zr).removeChild(w.stateNode)}catch(F){gr(w,g,F)}else try{Zr.removeChild(w.stateNode)}catch(F){gr(w,g,F)}break;case 18:Zr!==null&&(As?(f=Zr,fU(f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f,w.stateNode),mp(f)):fU(Zr,w.stateNode));break;case 4:M=Zr,R=As,Zr=w.stateNode.containerInfo,As=!0,Hc(f,g,w),Zr=M,As=R;break;case 0:case 11:case 14:case 15:ud(2,w,g),Ri||ud(4,w,g),Hc(f,g,w);break;case 1:Ri||(Xl(w,g),M=w.stateNode,typeof M.componentWillUnmount=="function"&&m5(w,g,M)),Hc(f,g,w);break;case 21:Hc(f,g,w);break;case 22:Ri=(M=Ri)||w.memoizedState!==null,Hc(f,g,w),Ri=M;break;default:Hc(f,g,w)}}function _5(f,g){if(g.memoizedState===null&&(f=g.alternate,f!==null&&(f=f.memoizedState,f!==null))){f=f.dehydrated;try{mp(f)}catch(w){gr(g,g.return,w)}}}function S5(f,g){if(g.memoizedState===null&&(f=g.alternate,f!==null&&(f=f.memoizedState,f!==null&&(f=f.dehydrated,f!==null))))try{mp(f)}catch(w){gr(g,g.return,w)}}function Vie(f){switch(f.tag){case 31:case 13:case 19:var g=f.stateNode;return g===null&&(g=f.stateNode=new b5),g;case 22:return f=f.stateNode,g=f._retryCache,g===null&&(g=f._retryCache=new b5),g;default:throw Error(r(435,f.tag))}}function iw(f,g){var w=Vie(f);g.forEach(function(M){if(!w.has(M)){w.add(M);var R=Jie.bind(null,f,M);M.then(R,R)}})}function Cs(f,g){var w=g.deletions;if(w!==null)for(var M=0;M<w.length;M++){var R=w[M],F=f,Z=g,ve=Z;e:for(;ve!==null;){switch(ve.tag){case 27:if(xd(ve.type)){Zr=ve.stateNode,As=!1;break e}break;case 5:Zr=ve.stateNode,As=!1;break e;case 3:case 4:Zr=ve.stateNode.containerInfo,As=!0;break e}ve=ve.return}if(Zr===null)throw Error(r(160));w5(F,Z,R),Zr=null,As=!1,F=R.alternate,F!==null&&(F.return=null),R.return=null}if(g.subtreeFlags&13886)for(g=g.child;g!==null;)N5(g,f),g=g.sibling}var wl=null;function N5(f,g){var w=f.alternate,M=f.flags;switch(f.tag){case 0:case 11:case 14:case 15:Cs(g,f),js(f),M&4&&(ud(3,f,f.return),hb(3,f),ud(5,f,f.return));break;case 1:Cs(g,f),js(f),M&512&&(Ri||w===null||Xl(w,w.return)),M&64&&Bc&&(f=f.updateQueue,f!==null&&(M=f.callbacks,M!==null&&(w=f.shared.hiddenCallbacks,f.shared.hiddenCallbacks=w===null?M:w.concat(M))));break;case 26:var R=wl;if(Cs(g,f),js(f),M&512&&(Ri||w===null||Xl(w,w.return)),M&4){var F=w!==null?w.memoizedState:null;if(M=f.memoizedState,w===null)if(M===null)if(f.stateNode===null){e:{M=f.type,w=f.memoizedProps,R=R.ownerDocument||R;t:switch(M){case"title":F=R.getElementsByTagName("title")[0],(!F||F[ht]||F[Xn]||F.namespaceURI==="http://www.w3.org/2000/svg"||F.hasAttribute("itemprop"))&&(F=R.createElement(M),R.head.insertBefore(F,R.querySelector("head > title"))),Ca(F,M,w),F[Xn]=f,Ne(F),M=F;break e;case"link":var Z=NU("link","href",R).get(M+(w.href||""));if(Z){for(var ve=0;ve<Z.length;ve++)if(F=Z[ve],F.getAttribute("href")===(w.href==null||w.href===""?null:w.href)&&F.getAttribute("rel")===(w.rel==null?null:w.rel)&&F.getAttribute("title")===(w.title==null?null:w.title)&&F.getAttribute("crossorigin")===(w.crossOrigin==null?null:w.crossOrigin)){Z.splice(ve,1);break t}}F=R.createElement(M),Ca(F,M,w),R.head.appendChild(F);break;case"meta":if(Z=NU("meta","content",R).get(M+(w.content||""))){for(ve=0;ve<Z.length;ve++)if(F=Z[ve],F.getAttribute("content")===(w.content==null?null:""+w.content)&&F.getAttribute("name")===(w.name==null?null:w.name)&&F.getAttribute("property")===(w.property==null?null:w.property)&&F.getAttribute("http-equiv")===(w.httpEquiv==null?null:w.httpEquiv)&&F.getAttribute("charset")===(w.charSet==null?null:w.charSet)){Z.splice(ve,1);break t}}F=R.createElement(M),Ca(F,M,w),R.head.appendChild(F);break;default:throw Error(r(468,M))}F[Xn]=f,Ne(F),M=F}f.stateNode=M}else MU(R,f.type,f.stateNode);else f.stateNode=SU(R,M,f.memoizedProps);else F!==M?(F===null?w.stateNode!==null&&(w=w.stateNode,w.parentNode.removeChild(w)):F.count--,M===null?MU(R,f.type,f.stateNode):SU(R,M,f.memoizedProps)):M===null&&f.stateNode!==null&&eE(f,f.memoizedProps,w.memoizedProps)}break;case 27:Cs(g,f),js(f),M&512&&(Ri||w===null||Xl(w,w.return)),w!==null&&M&4&&eE(f,f.memoizedProps,w.memoizedProps);break;case 5:if(Cs(g,f),js(f),M&512&&(Ri||w===null||Xl(w,w.return)),f.flags&32){R=f.stateNode;try{vt(R,"")}catch(Vt){gr(f,f.return,Vt)}}M&4&&f.stateNode!=null&&(R=f.memoizedProps,eE(f,R,w!==null?w.memoizedProps:R)),M&1024&&(rE=!0);break;case 6:if(Cs(g,f),js(f),M&4){if(f.stateNode===null)throw Error(r(162));M=f.memoizedProps,w=f.stateNode;try{w.nodeValue=M}catch(Vt){gr(f,f.return,Vt)}}break;case 3:if(vw=null,R=wl,wl=bw(g.containerInfo),Cs(g,f),wl=R,js(f),M&4&&w!==null&&w.memoizedState.isDehydrated)try{mp(g.containerInfo)}catch(Vt){gr(f,f.return,Vt)}rE&&(rE=!1,M5(f));break;case 4:M=wl,wl=bw(f.stateNode.containerInfo),Cs(g,f),js(f),wl=M;break;case 12:Cs(g,f),js(f);break;case 31:Cs(g,f),js(f),M&4&&(M=f.updateQueue,M!==null&&(f.updateQueue=null,iw(f,M)));break;case 13:Cs(g,f),js(f),f.child.flags&8192&&f.memoizedState!==null!=(w!==null&&w.memoizedState!==null)&&(sw=O()),M&4&&(M=f.updateQueue,M!==null&&(f.updateQueue=null,iw(f,M)));break;case 22:R=f.memoizedState!==null;var Ue=w!==null&&w.memoizedState!==null,lt=Bc,bt=Ri;if(Bc=lt||R,Ri=bt||Ue,Cs(g,f),Ri=bt,Bc=lt,js(f),M&8192)e:for(g=f.stateNode,g._visibility=R?g._visibility&-2:g._visibility|1,R&&(w===null||Ue||Bc||Ri||of(f)),w=null,g=f;;){if(g.tag===5||g.tag===26){if(w===null){Ue=w=g;try{if(F=Ue.stateNode,R)Z=F.style,typeof Z.setProperty=="function"?Z.setProperty("display","none","important"):Z.display="none";else{ve=Ue.stateNode;var wt=Ue.memoizedProps.style,ft=wt!=null&&wt.hasOwnProperty("display")?wt.display:null;ve.style.display=ft==null||typeof ft=="boolean"?"":(""+ft).trim()}}catch(Vt){gr(Ue,Ue.return,Vt)}}}else if(g.tag===6){if(w===null){Ue=g;try{Ue.stateNode.nodeValue=R?"":Ue.memoizedProps}catch(Vt){gr(Ue,Ue.return,Vt)}}}else if(g.tag===18){if(w===null){Ue=g;try{var xt=Ue.stateNode;R?mU(xt,!0):mU(Ue.stateNode,!1)}catch(Vt){gr(Ue,Ue.return,Vt)}}}else if((g.tag!==22&&g.tag!==23||g.memoizedState===null||g===f)&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===f)break e;for(;g.sibling===null;){if(g.return===null||g.return===f)break e;w===g&&(w=null),g=g.return}w===g&&(w=null),g.sibling.return=g.return,g=g.sibling}M&4&&(M=f.updateQueue,M!==null&&(w=M.retryQueue,w!==null&&(M.retryQueue=null,iw(f,w))));break;case 19:Cs(g,f),js(f),M&4&&(M=f.updateQueue,M!==null&&(f.updateQueue=null,iw(f,M)));break;case 30:break;case 21:break;default:Cs(g,f),js(f)}}function js(f){var g=f.flags;if(g&2){try{for(var w,M=f.return;M!==null;){if(g5(M)){w=M;break}M=M.return}if(w==null)throw Error(r(160));switch(w.tag){case 27:var R=w.stateNode,F=tE(f);rw(f,F,R);break;case 5:var Z=w.stateNode;w.flags&32&&(vt(Z,""),w.flags&=-33);var ve=tE(f);rw(f,ve,Z);break;case 3:case 4:var Ue=w.stateNode.containerInfo,lt=tE(f);nE(f,lt,Ue);break;default:throw Error(r(161))}}catch(bt){gr(f,f.return,bt)}f.flags&=-3}g&4096&&(f.flags&=-4097)}function M5(f){if(f.subtreeFlags&1024)for(f=f.child;f!==null;){var g=f;M5(g),g.tag===5&&g.flags&1024&&g.stateNode.reset(),f=f.sibling}}function $c(f,g){if(g.subtreeFlags&8772)for(g=g.child;g!==null;)y5(f,g.alternate,g),g=g.sibling}function of(f){for(f=f.child;f!==null;){var g=f;switch(g.tag){case 0:case 11:case 14:case 15:ud(4,g,g.return),of(g);break;case 1:Xl(g,g.return);var w=g.stateNode;typeof w.componentWillUnmount=="function"&&m5(g,g.return,w),of(g);break;case 27:_b(g.stateNode);case 26:case 5:Xl(g,g.return),of(g);break;case 22:g.memoizedState===null&&of(g);break;case 30:of(g);break;default:of(g)}f=f.sibling}}function Vc(f,g,w){for(w=w&&(g.subtreeFlags&8772)!==0,g=g.child;g!==null;){var M=g.alternate,R=f,F=g,Z=F.flags;switch(F.tag){case 0:case 11:case 15:Vc(R,F,w),hb(4,F);break;case 1:if(Vc(R,F,w),M=F,R=M.stateNode,typeof R.componentDidMount=="function")try{R.componentDidMount()}catch(lt){gr(M,M.return,lt)}if(M=F,R=M.updateQueue,R!==null){var ve=M.stateNode;try{var Ue=R.shared.hiddenCallbacks;if(Ue!==null)for(R.shared.hiddenCallbacks=null,R=0;R<Ue.length;R++)nI(Ue[R],ve)}catch(lt){gr(M,M.return,lt)}}w&&Z&64&&f5(F),fb(F,F.return);break;case 27:x5(F);case 26:case 5:Vc(R,F,w),w&&M===null&&Z&4&&p5(F),fb(F,F.return);break;case 12:Vc(R,F,w);break;case 31:Vc(R,F,w),w&&Z&4&&_5(R,F);break;case 13:Vc(R,F,w),w&&Z&4&&S5(R,F);break;case 22:F.memoizedState===null&&Vc(R,F,w),fb(F,F.return);break;case 30:break;default:Vc(R,F,w)}g=g.sibling}}function iE(f,g){var w=null;f!==null&&f.memoizedState!==null&&f.memoizedState.cachePool!==null&&(w=f.memoizedState.cachePool.pool),f=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(f=g.memoizedState.cachePool.pool),f!==w&&(f!=null&&f.refCount++,w!=null&&Jx(w))}function aE(f,g){f=null,g.alternate!==null&&(f=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==f&&(g.refCount++,f!=null&&Jx(f))}function _l(f,g,w,M){if(g.subtreeFlags&10256)for(g=g.child;g!==null;)k5(f,g,w,M),g=g.sibling}function k5(f,g,w,M){var R=g.flags;switch(g.tag){case 0:case 11:case 15:_l(f,g,w,M),R&2048&&hb(9,g);break;case 1:_l(f,g,w,M);break;case 3:_l(f,g,w,M),R&2048&&(f=null,g.alternate!==null&&(f=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==f&&(g.refCount++,f!=null&&Jx(f)));break;case 12:if(R&2048){_l(f,g,w,M),f=g.stateNode;try{var F=g.memoizedProps,Z=F.id,ve=F.onPostCommit;typeof ve=="function"&&ve(Z,g.alternate===null?"mount":"update",f.passiveEffectDuration,-0)}catch(Ue){gr(g,g.return,Ue)}}else _l(f,g,w,M);break;case 31:_l(f,g,w,M);break;case 13:_l(f,g,w,M);break;case 23:break;case 22:F=g.stateNode,Z=g.alternate,g.memoizedState!==null?F._visibility&2?_l(f,g,w,M):mb(f,g):F._visibility&2?_l(f,g,w,M):(F._visibility|=2,rp(f,g,w,M,(g.subtreeFlags&10256)!==0||!1)),R&2048&&iE(Z,g);break;case 24:_l(f,g,w,M),R&2048&&aE(g.alternate,g);break;default:_l(f,g,w,M)}}function rp(f,g,w,M,R){for(R=R&&((g.subtreeFlags&10256)!==0||!1),g=g.child;g!==null;){var F=f,Z=g,ve=w,Ue=M,lt=Z.flags;switch(Z.tag){case 0:case 11:case 15:rp(F,Z,ve,Ue,R),hb(8,Z);break;case 23:break;case 22:var bt=Z.stateNode;Z.memoizedState!==null?bt._visibility&2?rp(F,Z,ve,Ue,R):mb(F,Z):(bt._visibility|=2,rp(F,Z,ve,Ue,R)),R&&lt&2048&&iE(Z.alternate,Z);break;case 24:rp(F,Z,ve,Ue,R),R&&lt&2048&&aE(Z.alternate,Z);break;default:rp(F,Z,ve,Ue,R)}g=g.sibling}}function mb(f,g){if(g.subtreeFlags&10256)for(g=g.child;g!==null;){var w=f,M=g,R=M.flags;switch(M.tag){case 22:mb(w,M),R&2048&&iE(M.alternate,M);break;case 24:mb(w,M),R&2048&&aE(M.alternate,M);break;default:mb(w,M)}g=g.sibling}}var pb=8192;function ip(f,g,w){if(f.subtreeFlags&pb)for(f=f.child;f!==null;)E5(f,g,w),f=f.sibling}function E5(f,g,w){switch(f.tag){case 26:ip(f,g,w),f.flags&pb&&f.memoizedState!==null&&Cae(w,wl,f.memoizedState,f.memoizedProps);break;case 5:ip(f,g,w);break;case 3:case 4:var M=wl;wl=bw(f.stateNode.containerInfo),ip(f,g,w),wl=M;break;case 22:f.memoizedState===null&&(M=f.alternate,M!==null&&M.memoizedState!==null?(M=pb,pb=16777216,ip(f,g,w),pb=M):ip(f,g,w));break;default:ip(f,g,w)}}function T5(f){var g=f.alternate;if(g!==null&&(f=g.child,f!==null)){g.child=null;do g=f.sibling,f.sibling=null,f=g;while(f!==null)}}function gb(f){var g=f.deletions;if((f.flags&16)!==0){if(g!==null)for(var w=0;w<g.length;w++){var M=g[w];fa=M,C5(M,f)}T5(f)}if(f.subtreeFlags&10256)for(f=f.child;f!==null;)A5(f),f=f.sibling}function A5(f){switch(f.tag){case 0:case 11:case 15:gb(f),f.flags&2048&&ud(9,f,f.return);break;case 3:gb(f);break;case 12:gb(f);break;case 22:var g=f.stateNode;f.memoizedState!==null&&g._visibility&2&&(f.return===null||f.return.tag!==13)?(g._visibility&=-3,aw(f)):gb(f);break;default:gb(f)}}function aw(f){var g=f.deletions;if((f.flags&16)!==0){if(g!==null)for(var w=0;w<g.length;w++){var M=g[w];fa=M,C5(M,f)}T5(f)}for(f=f.child;f!==null;){switch(g=f,g.tag){case 0:case 11:case 15:ud(8,g,g.return),aw(g);break;case 22:w=g.stateNode,w._visibility&2&&(w._visibility&=-3,aw(g));break;default:aw(g)}f=f.sibling}}function C5(f,g){for(;fa!==null;){var w=fa;switch(w.tag){case 0:case 11:case 15:ud(8,w,g);break;case 23:case 22:if(w.memoizedState!==null&&w.memoizedState.cachePool!==null){var M=w.memoizedState.cachePool.pool;M!=null&&M.refCount++}break;case 24:Jx(w.memoizedState.cache)}if(M=w.child,M!==null)M.return=w,fa=M;else e:for(w=f;fa!==null;){M=fa;var R=M.sibling,F=M.return;if(v5(M),M===w){fa=null;break e}if(R!==null){R.return=F,fa=R;break e}fa=F}}}var Gie={getCacheForType:function(f){var g=Ta(ji),w=g.data.get(f);return w===void 0&&(w=f(),g.data.set(f,w)),w},cacheSignal:function(){return Ta(ji).controller.signal}},qie=typeof WeakMap=="function"?WeakMap:Map,hr=0,Pr=null,Un=null,qn=0,pr=0,no=null,dd=!1,ap=!1,sE=!1,Gc=0,mi=0,hd=0,lf=0,oE=0,ro=0,sp=0,xb=null,Ps=null,lE=!1,sw=0,j5=0,ow=1/0,lw=null,fd=null,Xi=0,md=null,op=null,qc=0,cE=0,uE=null,P5=null,bb=0,dE=null;function io(){return(hr&2)!==0&&qn!==0?qn&-qn:K.T!==null?xE():xn()}function D5(){if(ro===0)if((qn&536870912)===0||Yn){var f=Ee;Ee<<=1,(Ee&3932160)===0&&(Ee=262144),ro=f}else ro=536870912;return f=eo.current,f!==null&&(f.flags|=32),ro}function Ds(f,g,w){(f===Pr&&(pr===2||pr===9)||f.cancelPendingCommit!==null)&&(lp(f,0),pd(f,qn,ro,!1)),jt(f,w),((hr&2)===0||f!==Pr)&&(f===Pr&&((hr&2)===0&&(lf|=w),mi===4&&pd(f,qn,ro,!1)),Yl(f))}function R5(f,g,w){if((hr&6)!==0)throw Error(r(327));var M=!w&&(g&127)===0&&(g&f.expiredLanes)===0||$e(f,g),R=M?Xie(f,g):fE(f,g,!0),F=M;do{if(R===0){ap&&!M&&pd(f,g,0,!1);break}else{if(w=f.current.alternate,F&&!Wie(w)){R=fE(f,g,!1),F=!1;continue}if(R===2){if(F=g,f.errorRecoveryDisabledLanes&F)var Z=0;else Z=f.pendingLanes&-536870913,Z=Z!==0?Z:Z&536870912?536870912:0;if(Z!==0){g=Z;e:{var ve=f;R=xb;var Ue=ve.current.memoizedState.isDehydrated;if(Ue&&(lp(ve,Z).flags|=256),Z=fE(ve,Z,!1),Z!==2){if(sE&&!Ue){ve.errorRecoveryDisabledLanes|=F,lf|=F,R=4;break e}F=Ps,Ps=R,F!==null&&(Ps===null?Ps=F:Ps.push.apply(Ps,F))}R=Z}if(F=!1,R!==2)continue}}if(R===1){lp(f,0),pd(f,g,0,!0);break}e:{switch(M=f,F=R,F){case 0:case 1:throw Error(r(345));case 4:if((g&4194048)!==g)break;case 6:pd(M,g,ro,!dd);break e;case 2:Ps=null;break;case 3:case 5:break;default:throw Error(r(329))}if((g&62914560)===g&&(R=sw+300-O(),10<R)){if(pd(M,g,ro,!dd),ce(M,0,!0)!==0)break e;qc=g,M.timeoutHandle=dU(O5.bind(null,M,w,Ps,lw,lE,g,ro,lf,sp,dd,F,"Throttled",-0,0),R);break e}O5(M,w,Ps,lw,lE,g,ro,lf,sp,dd,F,null,-0,0)}}break}while(!0);Yl(f)}function O5(f,g,w,M,R,F,Z,ve,Ue,lt,bt,wt,ft,xt){if(f.timeoutHandle=-1,wt=g.subtreeFlags,wt&8192||(wt&16785408)===16785408){wt={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Si},E5(g,F,wt);var Vt=(F&62914560)===F?sw-O():(F&4194048)===F?j5-O():0;if(Vt=jae(wt,Vt),Vt!==null){qc=F,f.cancelPendingCommit=Vt($5.bind(null,f,g,F,w,M,R,Z,ve,Ue,bt,wt,null,ft,xt)),pd(f,F,Z,!lt);return}}$5(f,g,F,w,M,R,Z,ve,Ue)}function Wie(f){for(var g=f;;){var w=g.tag;if((w===0||w===11||w===15)&&g.flags&16384&&(w=g.updateQueue,w!==null&&(w=w.stores,w!==null)))for(var M=0;M<w.length;M++){var R=w[M],F=R.getSnapshot;R=R.value;try{if(!Zs(F(),R))return!1}catch{return!1}}if(w=g.child,g.subtreeFlags&16384&&w!==null)w.return=g,g=w;else{if(g===f)break;for(;g.sibling===null;){if(g.return===null||g.return===f)return!0;g=g.return}g.sibling.return=g.return,g=g.sibling}}return!0}function pd(f,g,w,M){g&=~oE,g&=~lf,f.suspendedLanes|=g,f.pingedLanes&=~g,M&&(f.warmLanes|=g),M=f.expirationTimes;for(var R=g;0<R;){var F=31-Ie(R),Z=1<<F;M[F]=-1,R&=~Z}w!==0&&yn(f,w,g)}function cw(){return(hr&6)===0?(yb(0),!1):!0}function hE(){if(Un!==null){if(pr===0)var f=Un.return;else f=Un,Oc=Zh=null,Tk(f),Zm=null,tb=0,f=Un;for(;f!==null;)h5(f.alternate,f),f=f.return;Un=null}}function lp(f,g){var w=f.timeoutHandle;w!==-1&&(f.timeoutHandle=-1,fae(w)),w=f.cancelPendingCommit,w!==null&&(f.cancelPendingCommit=null,w()),qc=0,hE(),Pr=f,Un=w=Dc(f.current,null),qn=g,pr=0,no=null,dd=!1,ap=$e(f,g),sE=!1,sp=ro=oE=lf=hd=mi=0,Ps=xb=null,lE=!1,(g&8)!==0&&(g|=g&32);var M=f.entangledLanes;if(M!==0)for(f=f.entanglements,M&=g;0<M;){var R=31-Ie(M),F=1<<R;g|=f[R],M&=~F}return Gc=g,Cv(),w}function L5(f,g){_n=null,K.H=cb,g===Qm||g===Iv?(g=ZF(),pr=3):g===gk?(g=ZF(),pr=4):pr=g===Vk?8:g!==null&&typeof g=="object"&&typeof g.then=="function"?6:1,no=g,Un===null&&(mi=1,Zv(f,Po(g,f.current)))}function F5(){var f=eo.current;return f===null?!0:(qn&4194048)===qn?Lo===null:(qn&62914560)===qn||(qn&536870912)!==0?f===Lo:!1}function I5(){var f=K.H;return K.H=cb,f===null?cb:f}function U5(){var f=K.A;return K.A=Gie,f}function uw(){mi=4,dd||(qn&4194048)!==qn&&eo.current!==null||(ap=!0),(hd&134217727)===0&&(lf&134217727)===0||Pr===null||pd(Pr,qn,ro,!1)}function fE(f,g,w){var M=hr;hr|=2;var R=I5(),F=U5();(Pr!==f||qn!==g)&&(lw=null,lp(f,g)),g=!1;var Z=mi;e:do try{if(pr!==0&&Un!==null){var ve=Un,Ue=no;switch(pr){case 8:hE(),Z=6;break e;case 3:case 2:case 9:case 6:eo.current===null&&(g=!0);var lt=pr;if(pr=0,no=null,cp(f,ve,Ue,lt),w&&ap){Z=0;break e}break;default:lt=pr,pr=0,no=null,cp(f,ve,Ue,lt)}}Kie(),Z=mi;break}catch(bt){L5(f,bt)}while(!0);return g&&f.shellSuspendCounter++,Oc=Zh=null,hr=M,K.H=R,K.A=F,Un===null&&(Pr=null,qn=0,Cv()),Z}function Kie(){for(;Un!==null;)z5(Un)}function Xie(f,g){var w=hr;hr|=2;var M=I5(),R=U5();Pr!==f||qn!==g?(lw=null,ow=O()+500,lp(f,g)):ap=$e(f,g);e:do try{if(pr!==0&&Un!==null){g=Un;var F=no;t:switch(pr){case 1:pr=0,no=null,cp(f,g,F,1);break;case 2:case 9:if(YF(F)){pr=0,no=null,B5(g);break}g=function(){pr!==2&&pr!==9||Pr!==f||(pr=7),Yl(f)},F.then(g,g);break e;case 3:pr=7;break e;case 4:pr=5;break e;case 7:YF(F)?(pr=0,no=null,B5(g)):(pr=0,no=null,cp(f,g,F,7));break;case 5:var Z=null;switch(Un.tag){case 26:Z=Un.memoizedState;case 5:case 27:var ve=Un;if(Z?kU(Z):ve.stateNode.complete){pr=0,no=null;var Ue=ve.sibling;if(Ue!==null)Un=Ue;else{var lt=ve.return;lt!==null?(Un=lt,dw(lt)):Un=null}break t}}pr=0,no=null,cp(f,g,F,5);break;case 6:pr=0,no=null,cp(f,g,F,6);break;case 8:hE(),mi=6;break e;default:throw Error(r(462))}}Yie();break}catch(bt){L5(f,bt)}while(!0);return Oc=Zh=null,K.H=M,K.A=R,hr=w,Un!==null?0:(Pr=null,qn=0,Cv(),mi)}function Yie(){for(;Un!==null&&!pe();)z5(Un)}function z5(f){var g=u5(f.alternate,f,Gc);f.memoizedProps=f.pendingProps,g===null?dw(f):Un=g}function B5(f){var g=f,w=g.alternate;switch(g.tag){case 15:case 0:g=i5(w,g,g.pendingProps,g.type,void 0,qn);break;case 11:g=i5(w,g,g.pendingProps,g.type.render,g.ref,qn);break;case 5:Tk(g);default:h5(w,g),g=Un=UF(g,Gc),g=u5(w,g,Gc)}f.memoizedProps=f.pendingProps,g===null?dw(f):Un=g}function cp(f,g,w,M){Oc=Zh=null,Tk(g),Zm=null,tb=0;var R=g.return;try{if(Iie(f,R,g,w,qn)){mi=1,Zv(f,Po(w,f.current)),Un=null;return}}catch(F){if(R!==null)throw Un=R,F;mi=1,Zv(f,Po(w,f.current)),Un=null;return}g.flags&32768?(Yn||M===1?f=!0:ap||(qn&536870912)!==0?f=!1:(dd=f=!0,(M===2||M===9||M===3||M===6)&&(M=eo.current,M!==null&&M.tag===13&&(M.flags|=16384))),H5(g,f)):dw(g)}function dw(f){var g=f;do{if((g.flags&32768)!==0){H5(g,dd);return}f=g.return;var w=Bie(g.alternate,g,Gc);if(w!==null){Un=w;return}if(g=g.sibling,g!==null){Un=g;return}Un=g=f}while(g!==null);mi===0&&(mi=5)}function H5(f,g){do{var w=Hie(f.alternate,f);if(w!==null){w.flags&=32767,Un=w;return}if(w=f.return,w!==null&&(w.flags|=32768,w.subtreeFlags=0,w.deletions=null),!g&&(f=f.sibling,f!==null)){Un=f;return}Un=f=w}while(f!==null);mi=6,Un=null}function $5(f,g,w,M,R,F,Z,ve,Ue){f.cancelPendingCommit=null;do hw();while(Xi!==0);if((hr&6)!==0)throw Error(r(327));if(g!==null){if(g===f.current)throw Error(r(177));if(F=g.lanes|g.childLanes,F|=tk,Dt(f,w,F,Z,ve,Ue),f===Pr&&(Un=Pr=null,qn=0),op=g,md=f,qc=w,cE=F,uE=R,P5=M,(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?(f.callbackNode=null,f.callbackPriority=0,eae(we,function(){return K5(),null})):(f.callbackNode=null,f.callbackPriority=0),M=(g.flags&13878)!==0,(g.subtreeFlags&13878)!==0||M){M=K.T,K.T=null,R=z.p,z.p=2,Z=hr,hr|=4;try{$ie(f,g,w)}finally{hr=Z,z.p=R,K.T=M}}Xi=1,V5(),G5(),q5()}}function V5(){if(Xi===1){Xi=0;var f=md,g=op,w=(g.flags&13878)!==0;if((g.subtreeFlags&13878)!==0||w){w=K.T,K.T=null;var M=z.p;z.p=2;var R=hr;hr|=4;try{N5(g,f);var F=ME,Z=CF(f.containerInfo),ve=F.focusedElem,Ue=F.selectionRange;if(Z!==ve&&ve&&ve.ownerDocument&&AF(ve.ownerDocument.documentElement,ve)){if(Ue!==null&&Y2(ve)){var lt=Ue.start,bt=Ue.end;if(bt===void 0&&(bt=lt),"selectionStart"in ve)ve.selectionStart=lt,ve.selectionEnd=Math.min(bt,ve.value.length);else{var wt=ve.ownerDocument||document,ft=wt&&wt.defaultView||window;if(ft.getSelection){var xt=ft.getSelection(),Vt=ve.textContent.length,rn=Math.min(Ue.start,Vt),Sr=Ue.end===void 0?rn:Math.min(Ue.end,Vt);!xt.extend&&rn>Sr&&(Z=Sr,Sr=rn,rn=Z);var et=TF(ve,rn),qe=TF(ve,Sr);if(et&&qe&&(xt.rangeCount!==1||xt.anchorNode!==et.node||xt.anchorOffset!==et.offset||xt.focusNode!==qe.node||xt.focusOffset!==qe.offset)){var ot=wt.createRange();ot.setStart(et.node,et.offset),xt.removeAllRanges(),rn>Sr?(xt.addRange(ot),xt.extend(qe.node,qe.offset)):(ot.setEnd(qe.node,qe.offset),xt.addRange(ot))}}}}for(wt=[],xt=ve;xt=xt.parentNode;)xt.nodeType===1&&wt.push({element:xt,left:xt.scrollLeft,top:xt.scrollTop});for(typeof ve.focus=="function"&&ve.focus(),ve=0;ve<wt.length;ve++){var yt=wt[ve];yt.element.scrollLeft=yt.left,yt.element.scrollTop=yt.top}}Nw=!!NE,ME=NE=null}finally{hr=R,z.p=M,K.T=w}}f.current=g,Xi=2}}function G5(){if(Xi===2){Xi=0;var f=md,g=op,w=(g.flags&8772)!==0;if((g.subtreeFlags&8772)!==0||w){w=K.T,K.T=null;var M=z.p;z.p=2;var R=hr;hr|=4;try{y5(f,g.alternate,g)}finally{hr=R,z.p=M,K.T=w}}Xi=3}}function q5(){if(Xi===4||Xi===3){Xi=0,H();var f=md,g=op,w=qc,M=P5;(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?Xi=5:(Xi=0,op=md=null,W5(f,f.pendingLanes));var R=f.pendingLanes;if(R===0&&(fd=null),Jn(w),g=g.stateNode,be&&typeof be.onCommitFiberRoot=="function")try{be.onCommitFiberRoot(He,g,void 0,(g.current.flags&128)===128)}catch{}if(M!==null){g=K.T,R=z.p,z.p=2,K.T=null;try{for(var F=f.onRecoverableError,Z=0;Z<M.length;Z++){var ve=M[Z];F(ve.value,{componentStack:ve.stack})}}finally{K.T=g,z.p=R}}(qc&3)!==0&&hw(),Yl(f),R=f.pendingLanes,(w&261930)!==0&&(R&42)!==0?f===dE?bb++:(bb=0,dE=f):bb=0,yb(0)}}function W5(f,g){(f.pooledCacheLanes&=g)===0&&(g=f.pooledCache,g!=null&&(f.pooledCache=null,Jx(g)))}function hw(){return V5(),G5(),q5(),K5()}function K5(){if(Xi!==5)return!1;var f=md,g=cE;cE=0;var w=Jn(qc),M=K.T,R=z.p;try{z.p=32>w?32:w,K.T=null,w=uE,uE=null;var F=md,Z=qc;if(Xi=0,op=md=null,qc=0,(hr&6)!==0)throw Error(r(331));var ve=hr;if(hr|=4,A5(F.current),k5(F,F.current,Z,w),hr=ve,yb(0,!1),be&&typeof be.onPostCommitFiberRoot=="function")try{be.onPostCommitFiberRoot(He,F)}catch{}return!0}finally{z.p=R,K.T=M,W5(f,g)}}function X5(f,g,w){g=Po(w,g),g=$k(f.stateNode,g,2),f=od(f,g,2),f!==null&&(jt(f,2),Yl(f))}function gr(f,g,w){if(f.tag===3)X5(f,f,w);else for(;g!==null;){if(g.tag===3){X5(g,f,w);break}else if(g.tag===1){var M=g.stateNode;if(typeof g.type.getDerivedStateFromError=="function"||typeof M.componentDidCatch=="function"&&(fd===null||!fd.has(M))){f=Po(w,f),w=YI(2),M=od(g,w,2),M!==null&&(QI(w,M,g,f),jt(M,2),Yl(M));break}}g=g.return}}function mE(f,g,w){var M=f.pingCache;if(M===null){M=f.pingCache=new qie;var R=new Set;M.set(g,R)}else R=M.get(g),R===void 0&&(R=new Set,M.set(g,R));R.has(w)||(sE=!0,R.add(w),f=Qie.bind(null,f,g,w),g.then(f,f))}function Qie(f,g,w){var M=f.pingCache;M!==null&&M.delete(g),f.pingedLanes|=f.suspendedLanes&w,f.warmLanes&=~w,Pr===f&&(qn&w)===w&&(mi===4||mi===3&&(qn&62914560)===qn&&300>O()-sw?(hr&2)===0&&lp(f,0):oE|=w,sp===qn&&(sp=0)),Yl(f)}function Y5(f,g){g===0&&(g=Je()),f=Xh(f,g),f!==null&&(jt(f,g),Yl(f))}function Zie(f){var g=f.memoizedState,w=0;g!==null&&(w=g.retryLane),Y5(f,w)}function Jie(f,g){var w=0;switch(f.tag){case 31:case 13:var M=f.stateNode,R=f.memoizedState;R!==null&&(w=R.retryLane);break;case 19:M=f.stateNode;break;case 22:M=f.stateNode._retryCache;break;default:throw Error(r(314))}M!==null&&M.delete(g),Y5(f,w)}function eae(f,g){return he(f,g)}var fw=null,up=null,pE=!1,mw=!1,gE=!1,gd=0;function Yl(f){f!==up&&f.next===null&&(up===null?fw=up=f:up=up.next=f),mw=!0,pE||(pE=!0,nae())}function yb(f,g){if(!gE&&mw){gE=!0;do for(var w=!1,M=fw;M!==null;){if(f!==0){var R=M.pendingLanes;if(R===0)var F=0;else{var Z=M.suspendedLanes,ve=M.pingedLanes;F=(1<<31-Ie(42|f)+1)-1,F&=R&~(Z&~ve),F=F&201326741?F&201326741|1:F?F|2:0}F!==0&&(w=!0,eU(M,F))}else F=qn,F=ce(M,M===Pr?F:0,M.cancelPendingCommit!==null||M.timeoutHandle!==-1),(F&3)===0||$e(M,F)||(w=!0,eU(M,F));M=M.next}while(w);gE=!1}}function tae(){Q5()}function Q5(){mw=pE=!1;var f=0;gd!==0&&hae()&&(f=gd);for(var g=O(),w=null,M=fw;M!==null;){var R=M.next,F=Z5(M,g);F===0?(M.next=null,w===null?fw=R:w.next=R,R===null&&(up=w)):(w=M,(f!==0||(F&3)!==0)&&(mw=!0)),M=R}Xi!==0&&Xi!==5||yb(f),gd!==0&&(gd=0)}function Z5(f,g){for(var w=f.suspendedLanes,M=f.pingedLanes,R=f.expirationTimes,F=f.pendingLanes&-62914561;0<F;){var Z=31-Ie(F),ve=1<<Z,Ue=R[Z];Ue===-1?((ve&w)===0||(ve&M)!==0)&&(R[Z]=ye(ve,g)):Ue<=g&&(f.expiredLanes|=ve),F&=~ve}if(g=Pr,w=qn,w=ce(f,f===g?w:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),M=f.callbackNode,w===0||f===g&&(pr===2||pr===9)||f.cancelPendingCommit!==null)return M!==null&&M!==null&&ke(M),f.callbackNode=null,f.callbackPriority=0;if((w&3)===0||$e(f,w)){if(g=w&-w,g===f.callbackPriority)return g;switch(M!==null&&ke(M),Jn(w)){case 2:case 8:w=Se;break;case 32:w=we;break;case 268435456:w=Le;break;default:w=we}return M=J5.bind(null,f),w=he(w,M),f.callbackPriority=g,f.callbackNode=w,g}return M!==null&&M!==null&&ke(M),f.callbackPriority=2,f.callbackNode=null,2}function J5(f,g){if(Xi!==0&&Xi!==5)return f.callbackNode=null,f.callbackPriority=0,null;var w=f.callbackNode;if(hw()&&f.callbackNode!==w)return null;var M=qn;return M=ce(f,f===Pr?M:0,f.cancelPendingCommit!==null||f.timeoutHandle!==-1),M===0?null:(R5(f,M,g),Z5(f,O()),f.callbackNode!=null&&f.callbackNode===w?J5.bind(null,f):null)}function eU(f,g){if(hw())return null;R5(f,g,!0)}function nae(){mae(function(){(hr&6)!==0?he(le,tae):Q5()})}function xE(){if(gd===0){var f=Xm;f===0&&(f=it,it<<=1,(it&261888)===0&&(it=256)),gd=f}return gd}function tU(f){return f==null||typeof f=="symbol"||typeof f=="boolean"?null:typeof f=="function"?f:ln(""+f)}function nU(f,g){var w=g.ownerDocument.createElement("input");return w.name=g.name,w.value=g.value,f.id&&w.setAttribute("form",f.id),g.parentNode.insertBefore(w,g),f=new FormData(f),w.parentNode.removeChild(w),f}function rae(f,g,w,M,R){if(g==="submit"&&w&&w.stateNode===R){var F=tU((R[Nn]||null).action),Z=M.submitter;Z&&(g=(g=Z[Nn]||null)?tU(g.formAction):Z.getAttribute("formAction"),g!==null&&(F=g,Z=null));var ve=new ql("action","action",null,M,R);f.push({event:ve,listeners:[{instance:null,listener:function(){if(M.defaultPrevented){if(gd!==0){var Ue=Z?nU(R,Z):new FormData(R);Fk(w,{pending:!0,data:Ue,method:R.method,action:F},null,Ue)}}else typeof F=="function"&&(ve.preventDefault(),Ue=Z?nU(R,Z):new FormData(R),Fk(w,{pending:!0,data:Ue,method:R.method,action:F},F,Ue))},currentTarget:R}]})}}for(var bE=0;bE<ek.length;bE++){var yE=ek[bE],iae=yE.toLowerCase(),aae=yE[0].toUpperCase()+yE.slice(1);vl(iae,"on"+aae)}vl(DF,"onAnimationEnd"),vl(RF,"onAnimationIteration"),vl(OF,"onAnimationStart"),vl("dblclick","onDoubleClick"),vl("focusin","onFocus"),vl("focusout","onBlur"),vl(wie,"onTransitionRun"),vl(_ie,"onTransitionStart"),vl(Sie,"onTransitionCancel"),vl(LF,"onTransitionEnd"),Tt("onMouseEnter",["mouseout","mouseover"]),Tt("onMouseLeave",["mouseout","mouseover"]),Tt("onPointerEnter",["pointerout","pointerover"]),Tt("onPointerLeave",["pointerout","pointerover"]),Ye("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Ye("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Ye("onBeforeInput",["compositionend","keypress","textInput","paste"]),Ye("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Ye("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Ye("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var vb="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(" "),sae=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(vb));function rU(f,g){g=(g&4)!==0;for(var w=0;w<f.length;w++){var M=f[w],R=M.event;M=M.listeners;e:{var F=void 0;if(g)for(var Z=M.length-1;0<=Z;Z--){var ve=M[Z],Ue=ve.instance,lt=ve.currentTarget;if(ve=ve.listener,Ue!==F&&R.isPropagationStopped())break e;F=ve,R.currentTarget=lt;try{F(R)}catch(bt){Av(bt)}R.currentTarget=null,F=Ue}else for(Z=0;Z<M.length;Z++){if(ve=M[Z],Ue=ve.instance,lt=ve.currentTarget,ve=ve.listener,Ue!==F&&R.isPropagationStopped())break e;F=ve,R.currentTarget=lt;try{F(R)}catch(bt){Av(bt)}R.currentTarget=null,F=Ue}}}}function zn(f,g){var w=g[ai];w===void 0&&(w=g[ai]=new Set);var M=f+"__bubble";w.has(M)||(iU(g,f,2,!1),w.add(M))}function vE(f,g,w){var M=0;g&&(M|=4),iU(w,f,M,g)}var pw="_reactListening"+Math.random().toString(36).slice(2);function wE(f){if(!f[pw]){f[pw]=!0,Oe.forEach(function(w){w!=="selectionchange"&&(sae.has(w)||vE(w,!1,f),vE(w,!0,f))});var g=f.nodeType===9?f:f.ownerDocument;g===null||g[pw]||(g[pw]=!0,vE("selectionchange",!1,g))}}function iU(f,g,w,M){switch(DU(g)){case 2:var R=Rae;break;case 8:R=Oae;break;default:R=LE}w=R.bind(null,g,w,f),R=void 0,!Bx||g!=="touchstart"&&g!=="touchmove"&&g!=="wheel"||(R=!0),M?R!==void 0?f.addEventListener(g,w,{capture:!0,passive:R}):f.addEventListener(g,w,!0):R!==void 0?f.addEventListener(g,w,{passive:R}):f.addEventListener(g,w,!1)}function _E(f,g,w,M,R){var F=M;if((g&1)===0&&(g&2)===0&&M!==null)e:for(;;){if(M===null)return;var Z=M.tag;if(Z===3||Z===4){var ve=M.stateNode.containerInfo;if(ve===R)break;if(Z===4)for(Z=M.return;Z!==null;){var Ue=Z.tag;if((Ue===3||Ue===4)&&Z.stateNode.containerInfo===R)return;Z=Z.return}for(;ve!==null;){if(Z=Et(ve),Z===null)return;if(Ue=Z.tag,Ue===5||Ue===6||Ue===26||Ue===27){M=F=Z;continue e}ve=ve.parentNode}}M=M.return}Qs(function(){var lt=F,bt=Eo(w),wt=[];e:{var ft=FF.get(f);if(ft!==void 0){var xt=ql,Vt=f;switch(f){case"keypress":if(qh(w)===0)break e;case"keydown":case"keyup":xt=Jre;break;case"focusin":Vt="focus",xt=Um;break;case"focusout":Vt="blur",xt=Um;break;case"beforeblur":case"afterblur":xt=Um;break;case"click":if(w.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":xt=Mv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":xt=kv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":xt=nie;break;case DF:case RF:case OF:xt=Ev;break;case LF:xt=iie;break;case"scroll":case"scrollend":xt=Lm;break;case"wheel":xt=sie;break;case"copy":case"cut":case"paste":xt=_t;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":xt=mF;break;case"toggle":case"beforetoggle":xt=lie}var rn=(g&4)!==0,Sr=!rn&&(f==="scroll"||f==="scrollend"),et=rn?ft!==null?ft+"Capture":null:ft;rn=[];for(var qe=lt,ot;qe!==null;){var yt=qe;if(ot=yt.stateNode,yt=yt.tag,yt!==5&&yt!==26&&yt!==27||ot===null||et===null||(yt=da(qe,et),yt!=null&&rn.push(wb(qe,yt,ot))),Sr)break;qe=qe.return}0<rn.length&&(ft=new xt(ft,Vt,null,w,bt),wt.push({event:ft,listeners:rn}))}}if((g&7)===0){e:{if(ft=f==="mouseover"||f==="pointerover",xt=f==="mouseout"||f==="pointerout",ft&&w!==Es&&(Vt=w.relatedTarget||w.fromElement)&&(Et(Vt)||Vt[hi]))break e;if((xt||ft)&&(ft=bt.window===bt?bt:(ft=bt.ownerDocument)?ft.defaultView||ft.parentWindow:window,xt?(Vt=w.relatedTarget||w.toElement,xt=lt,Vt=Vt?Et(Vt):null,Vt!==null&&(Sr=s(Vt),rn=Vt.tag,Vt!==Sr||rn!==5&&rn!==27&&rn!==6)&&(Vt=null)):(xt=null,Vt=lt),xt!==Vt)){if(rn=Mv,yt="onMouseLeave",et="onMouseEnter",qe="mouse",(f==="pointerout"||f==="pointerover")&&(rn=mF,yt="onPointerLeave",et="onPointerEnter",qe="pointer"),Sr=xt==null?ft:Re(xt),ot=Vt==null?ft:Re(Vt),ft=new rn(yt,qe+"leave",xt,w,bt),ft.target=Sr,ft.relatedTarget=ot,yt=null,Et(bt)===lt&&(rn=new rn(et,qe+"enter",Vt,w,bt),rn.target=ot,rn.relatedTarget=Sr,yt=rn),Sr=yt,xt&&Vt)t:{for(rn=oae,et=xt,qe=Vt,ot=0,yt=et;yt;yt=rn(yt))ot++;yt=0;for(var Kt=qe;Kt;Kt=rn(Kt))yt++;for(;0<ot-yt;)et=rn(et),ot--;for(;0<yt-ot;)qe=rn(qe),yt--;for(;ot--;){if(et===qe||qe!==null&&et===qe.alternate){rn=et;break t}et=rn(et),qe=rn(qe)}rn=null}else rn=null;xt!==null&&aU(wt,ft,xt,rn,!1),Vt!==null&&Sr!==null&&aU(wt,Sr,Vt,rn,!0)}}e:{if(ft=lt?Re(lt):window,xt=ft.nodeName&&ft.nodeName.toLowerCase(),xt==="select"||xt==="input"&&ft.type==="file")var or=_F;else if(vF(ft))if(SF)or=bie;else{or=gie;var Wt=pie}else xt=ft.nodeName,!xt||xt.toLowerCase()!=="input"||ft.type!=="checkbox"&&ft.type!=="radio"?lt&&Br(lt.elementType)&&(or=_F):or=xie;if(or&&(or=or(f,lt))){wF(wt,or,w,bt);break e}Wt&&Wt(f,ft,lt),f==="focusout"&&lt&&ft.type==="number"&&lt.memoizedProps.value!=null&&dr(ft,"number",ft.value)}switch(Wt=lt?Re(lt):window,f){case"focusin":(vF(Wt)||Wt.contentEditable==="true")&&(Bm=Wt,Q2=lt,Yx=null);break;case"focusout":Yx=Q2=Bm=null;break;case"mousedown":Z2=!0;break;case"contextmenu":case"mouseup":case"dragend":Z2=!1,jF(wt,w,bt);break;case"selectionchange":if(vie)break;case"keydown":case"keyup":jF(wt,w,bt)}var kn;if(W2)e:{switch(f){case"compositionstart":var Wn="onCompositionStart";break e;case"compositionend":Wn="onCompositionEnd";break e;case"compositionupdate":Wn="onCompositionUpdate";break e}Wn=void 0}else zm?bF(f,w)&&(Wn="onCompositionEnd"):f==="keydown"&&w.keyCode===229&&(Wn="onCompositionStart");Wn&&(pF&&w.locale!=="ko"&&(zm||Wn!=="onCompositionStart"?Wn==="onCompositionEnd"&&zm&&(kn=Om()):(Gl=bt,Hx="value"in Gl?Gl.value:Gl.textContent,zm=!0)),Wt=gw(lt,Wn),0<Wt.length&&(Wn=new er(Wn,f,null,w,bt),wt.push({event:Wn,listeners:Wt}),kn?Wn.data=kn:(kn=yF(w),kn!==null&&(Wn.data=kn)))),(kn=uie?die(f,w):hie(f,w))&&(Wn=gw(lt,"onBeforeInput"),0<Wn.length&&(Wt=new er("onBeforeInput","beforeinput",null,w,bt),wt.push({event:Wt,listeners:Wn}),Wt.data=kn)),rae(wt,f,lt,w,bt)}rU(wt,g)})}function wb(f,g,w){return{instance:f,listener:g,currentTarget:w}}function gw(f,g){for(var w=g+"Capture",M=[];f!==null;){var R=f,F=R.stateNode;if(R=R.tag,R!==5&&R!==26&&R!==27||F===null||(R=da(f,w),R!=null&&M.unshift(wb(f,R,F)),R=da(f,g),R!=null&&M.push(wb(f,R,F))),f.tag===3)return M;f=f.return}return[]}function oae(f){if(f===null)return null;do f=f.return;while(f&&f.tag!==5&&f.tag!==27);return f||null}function aU(f,g,w,M,R){for(var F=g._reactName,Z=[];w!==null&&w!==M;){var ve=w,Ue=ve.alternate,lt=ve.stateNode;if(ve=ve.tag,Ue!==null&&Ue===M)break;ve!==5&&ve!==26&&ve!==27||lt===null||(Ue=lt,R?(lt=da(w,F),lt!=null&&Z.unshift(wb(w,lt,Ue))):R||(lt=da(w,F),lt!=null&&Z.push(wb(w,lt,Ue)))),w=w.return}Z.length!==0&&f.push({event:g,listeners:Z})}var lae=/\r\n?/g,cae=/\u0000|\uFFFD/g;function sU(f){return(typeof f=="string"?f:""+f).replace(lae,`
  9. `).replace(cae,"")}function oU(f,g){return g=sU(g),sU(f)===g}function _r(f,g,w,M,R,F){switch(w){case"children":typeof M=="string"?g==="body"||g==="textarea"&&M===""||vt(f,M):(typeof M=="number"||typeof M=="bigint")&&g!=="body"&&vt(f,""+M);break;case"className":Ht(f,"class",M);break;case"tabIndex":Ht(f,"tabindex",M);break;case"dir":case"role":case"viewBox":case"width":case"height":Ht(f,w,M);break;case"style":Qr(f,M,F);break;case"data":if(g!=="object"){Ht(f,"data",M);break}case"src":case"href":if(M===""&&(g!=="a"||w!=="href")){f.removeAttribute(w);break}if(M==null||typeof M=="function"||typeof M=="symbol"||typeof M=="boolean"){f.removeAttribute(w);break}M=ln(""+M),f.setAttribute(w,M);break;case"action":case"formAction":if(typeof M=="function"){f.setAttribute(w,"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 F=="function"&&(w==="formAction"?(g!=="input"&&_r(f,g,"name",R.name,R,null),_r(f,g,"formEncType",R.formEncType,R,null),_r(f,g,"formMethod",R.formMethod,R,null),_r(f,g,"formTarget",R.formTarget,R,null)):(_r(f,g,"encType",R.encType,R,null),_r(f,g,"method",R.method,R,null),_r(f,g,"target",R.target,R,null)));if(M==null||typeof M=="symbol"||typeof M=="boolean"){f.removeAttribute(w);break}M=ln(""+M),f.setAttribute(w,M);break;case"onClick":M!=null&&(f.onclick=Si);break;case"onScroll":M!=null&&zn("scroll",f);break;case"onScrollEnd":M!=null&&zn("scrollend",f);break;case"dangerouslySetInnerHTML":if(M!=null){if(typeof M!="object"||!("__html"in M))throw Error(r(61));if(w=M.__html,w!=null){if(R.children!=null)throw Error(r(60));f.innerHTML=w}}break;case"multiple":f.multiple=M&&typeof M!="function"&&typeof M!="symbol";break;case"muted":f.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"){f.removeAttribute("xlink:href");break}w=ln(""+M),f.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",w);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"?f.setAttribute(w,""+M):f.removeAttribute(w);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"?f.setAttribute(w,""):f.removeAttribute(w);break;case"capture":case"download":M===!0?f.setAttribute(w,""):M!==!1&&M!=null&&typeof M!="function"&&typeof M!="symbol"?f.setAttribute(w,M):f.removeAttribute(w);break;case"cols":case"rows":case"size":case"span":M!=null&&typeof M!="function"&&typeof M!="symbol"&&!isNaN(M)&&1<=M?f.setAttribute(w,M):f.removeAttribute(w);break;case"rowSpan":case"start":M==null||typeof M=="function"||typeof M=="symbol"||isNaN(M)?f.removeAttribute(w):f.setAttribute(w,M);break;case"popover":zn("beforetoggle",f),zn("toggle",f),en(f,"popover",M);break;case"xlinkActuate":hn(f,"http://www.w3.org/1999/xlink","xlink:actuate",M);break;case"xlinkArcrole":hn(f,"http://www.w3.org/1999/xlink","xlink:arcrole",M);break;case"xlinkRole":hn(f,"http://www.w3.org/1999/xlink","xlink:role",M);break;case"xlinkShow":hn(f,"http://www.w3.org/1999/xlink","xlink:show",M);break;case"xlinkTitle":hn(f,"http://www.w3.org/1999/xlink","xlink:title",M);break;case"xlinkType":hn(f,"http://www.w3.org/1999/xlink","xlink:type",M);break;case"xmlBase":hn(f,"http://www.w3.org/XML/1998/namespace","xml:base",M);break;case"xmlLang":hn(f,"http://www.w3.org/XML/1998/namespace","xml:lang",M);break;case"xmlSpace":hn(f,"http://www.w3.org/XML/1998/namespace","xml:space",M);break;case"is":en(f,"is",M);break;case"innerText":case"textContent":break;default:(!(2<w.length)||w[0]!=="o"&&w[0]!=="O"||w[1]!=="n"&&w[1]!=="N")&&(w=Ys.get(w)||w,en(f,w,M))}}function SE(f,g,w,M,R,F){switch(w){case"style":Qr(f,M,F);break;case"dangerouslySetInnerHTML":if(M!=null){if(typeof M!="object"||!("__html"in M))throw Error(r(61));if(w=M.__html,w!=null){if(R.children!=null)throw Error(r(60));f.innerHTML=w}}break;case"children":typeof M=="string"?vt(f,M):(typeof M=="number"||typeof M=="bigint")&&vt(f,""+M);break;case"onScroll":M!=null&&zn("scroll",f);break;case"onScrollEnd":M!=null&&zn("scrollend",f);break;case"onClick":M!=null&&(f.onclick=Si);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!nt.hasOwnProperty(w))e:{if(w[0]==="o"&&w[1]==="n"&&(R=w.endsWith("Capture"),g=w.slice(2,R?w.length-7:void 0),F=f[Nn]||null,F=F!=null?F[w]:null,typeof F=="function"&&f.removeEventListener(g,F,R),typeof M=="function")){typeof F!="function"&&F!==null&&(w in f?f[w]=null:f.hasAttribute(w)&&f.removeAttribute(w)),f.addEventListener(g,M,R);break e}w in f?f[w]=M:M===!0?f.setAttribute(w,""):en(f,w,M)}}}function Ca(f,g,w){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":zn("error",f),zn("load",f);var M=!1,R=!1,F;for(F in w)if(w.hasOwnProperty(F)){var Z=w[F];if(Z!=null)switch(F){case"src":M=!0;break;case"srcSet":R=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:_r(f,g,F,Z,w,null)}}R&&_r(f,g,"srcSet",w.srcSet,w,null),M&&_r(f,g,"src",w.src,w,null);return;case"input":zn("invalid",f);var ve=F=Z=R=null,Ue=null,lt=null;for(M in w)if(w.hasOwnProperty(M)){var bt=w[M];if(bt!=null)switch(M){case"name":R=bt;break;case"type":Z=bt;break;case"checked":Ue=bt;break;case"defaultChecked":lt=bt;break;case"value":F=bt;break;case"defaultValue":ve=bt;break;case"children":case"dangerouslySetInnerHTML":if(bt!=null)throw Error(r(137,g));break;default:_r(f,g,M,bt,w,null)}}ar(f,F,ve,Ue,lt,Z,R,!1);return;case"select":zn("invalid",f),M=Z=F=null;for(R in w)if(w.hasOwnProperty(R)&&(ve=w[R],ve!=null))switch(R){case"value":F=ve;break;case"defaultValue":Z=ve;break;case"multiple":M=ve;default:_r(f,g,R,ve,w,null)}g=F,w=Z,f.multiple=!!M,g!=null?rt(f,!!M,g,!1):w!=null&&rt(f,!!M,w,!0);return;case"textarea":zn("invalid",f),F=R=M=null;for(Z in w)if(w.hasOwnProperty(Z)&&(ve=w[Z],ve!=null))switch(Z){case"value":M=ve;break;case"defaultValue":R=ve;break;case"children":F=ve;break;case"dangerouslySetInnerHTML":if(ve!=null)throw Error(r(91));break;default:_r(f,g,Z,ve,w,null)}qt(f,M,R,F);return;case"option":for(Ue in w)if(w.hasOwnProperty(Ue)&&(M=w[Ue],M!=null))switch(Ue){case"selected":f.selected=M&&typeof M!="function"&&typeof M!="symbol";break;default:_r(f,g,Ue,M,w,null)}return;case"dialog":zn("beforetoggle",f),zn("toggle",f),zn("cancel",f),zn("close",f);break;case"iframe":case"object":zn("load",f);break;case"video":case"audio":for(M=0;M<vb.length;M++)zn(vb[M],f);break;case"image":zn("error",f),zn("load",f);break;case"details":zn("toggle",f);break;case"embed":case"source":case"link":zn("error",f),zn("load",f);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(lt in w)if(w.hasOwnProperty(lt)&&(M=w[lt],M!=null))switch(lt){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:_r(f,g,lt,M,w,null)}return;default:if(Br(g)){for(bt in w)w.hasOwnProperty(bt)&&(M=w[bt],M!==void 0&&SE(f,g,bt,M,w,void 0));return}}for(ve in w)w.hasOwnProperty(ve)&&(M=w[ve],M!=null&&_r(f,g,ve,M,w,null))}function uae(f,g,w,M){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var R=null,F=null,Z=null,ve=null,Ue=null,lt=null,bt=null;for(xt in w){var wt=w[xt];if(w.hasOwnProperty(xt)&&wt!=null)switch(xt){case"checked":break;case"value":break;case"defaultValue":Ue=wt;default:M.hasOwnProperty(xt)||_r(f,g,xt,null,M,wt)}}for(var ft in M){var xt=M[ft];if(wt=w[ft],M.hasOwnProperty(ft)&&(xt!=null||wt!=null))switch(ft){case"type":F=xt;break;case"name":R=xt;break;case"checked":lt=xt;break;case"defaultChecked":bt=xt;break;case"value":Z=xt;break;case"defaultValue":ve=xt;break;case"children":case"dangerouslySetInnerHTML":if(xt!=null)throw Error(r(137,g));break;default:xt!==wt&&_r(f,g,ft,xt,M,wt)}}si(f,Z,ve,Ue,lt,bt,F,R);return;case"select":xt=Z=ve=ft=null;for(F in w)if(Ue=w[F],w.hasOwnProperty(F)&&Ue!=null)switch(F){case"value":break;case"multiple":xt=Ue;default:M.hasOwnProperty(F)||_r(f,g,F,null,M,Ue)}for(R in M)if(F=M[R],Ue=w[R],M.hasOwnProperty(R)&&(F!=null||Ue!=null))switch(R){case"value":ft=F;break;case"defaultValue":ve=F;break;case"multiple":Z=F;default:F!==Ue&&_r(f,g,R,F,M,Ue)}g=ve,w=Z,M=xt,ft!=null?rt(f,!!w,ft,!1):!!M!=!!w&&(g!=null?rt(f,!!w,g,!0):rt(f,!!w,w?[]:"",!1));return;case"textarea":xt=ft=null;for(ve in w)if(R=w[ve],w.hasOwnProperty(ve)&&R!=null&&!M.hasOwnProperty(ve))switch(ve){case"value":break;case"children":break;default:_r(f,g,ve,null,M,R)}for(Z in M)if(R=M[Z],F=w[Z],M.hasOwnProperty(Z)&&(R!=null||F!=null))switch(Z){case"value":ft=R;break;case"defaultValue":xt=R;break;case"children":break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(r(91));break;default:R!==F&&_r(f,g,Z,R,M,F)}Pt(f,ft,xt);return;case"option":for(var Vt in w)if(ft=w[Vt],w.hasOwnProperty(Vt)&&ft!=null&&!M.hasOwnProperty(Vt))switch(Vt){case"selected":f.selected=!1;break;default:_r(f,g,Vt,null,M,ft)}for(Ue in M)if(ft=M[Ue],xt=w[Ue],M.hasOwnProperty(Ue)&&ft!==xt&&(ft!=null||xt!=null))switch(Ue){case"selected":f.selected=ft&&typeof ft!="function"&&typeof ft!="symbol";break;default:_r(f,g,Ue,ft,M,xt)}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 w)ft=w[rn],w.hasOwnProperty(rn)&&ft!=null&&!M.hasOwnProperty(rn)&&_r(f,g,rn,null,M,ft);for(lt in M)if(ft=M[lt],xt=w[lt],M.hasOwnProperty(lt)&&ft!==xt&&(ft!=null||xt!=null))switch(lt){case"children":case"dangerouslySetInnerHTML":if(ft!=null)throw Error(r(137,g));break;default:_r(f,g,lt,ft,M,xt)}return;default:if(Br(g)){for(var Sr in w)ft=w[Sr],w.hasOwnProperty(Sr)&&ft!==void 0&&!M.hasOwnProperty(Sr)&&SE(f,g,Sr,void 0,M,ft);for(bt in M)ft=M[bt],xt=w[bt],!M.hasOwnProperty(bt)||ft===xt||ft===void 0&&xt===void 0||SE(f,g,bt,ft,M,xt);return}}for(var et in w)ft=w[et],w.hasOwnProperty(et)&&ft!=null&&!M.hasOwnProperty(et)&&_r(f,g,et,null,M,ft);for(wt in M)ft=M[wt],xt=w[wt],!M.hasOwnProperty(wt)||ft===xt||ft==null&&xt==null||_r(f,g,wt,ft,M,xt)}function lU(f){switch(f){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function dae(){if(typeof performance.getEntriesByType=="function"){for(var f=0,g=0,w=performance.getEntriesByType("resource"),M=0;M<w.length;M++){var R=w[M],F=R.transferSize,Z=R.initiatorType,ve=R.duration;if(F&&ve&&lU(Z)){for(Z=0,ve=R.responseEnd,M+=1;M<w.length;M++){var Ue=w[M],lt=Ue.startTime;if(lt>ve)break;var bt=Ue.transferSize,wt=Ue.initiatorType;bt&&lU(wt)&&(Ue=Ue.responseEnd,Z+=bt*(Ue<ve?1:(ve-lt)/(Ue-lt)))}if(--M,g+=8*(F+Z)/(R.duration/1e3),f++,10<f)break}}if(0<f)return g/f/1e6}return navigator.connection&&(f=navigator.connection.downlink,typeof f=="number")?f:5}var NE=null,ME=null;function xw(f){return f.nodeType===9?f:f.ownerDocument}function cU(f){switch(f){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function uU(f,g){if(f===0)switch(g){case"svg":return 1;case"math":return 2;default:return 0}return f===1&&g==="foreignObject"?0:f}function kE(f,g){return f==="textarea"||f==="noscript"||typeof g.children=="string"||typeof g.children=="number"||typeof g.children=="bigint"||typeof g.dangerouslySetInnerHTML=="object"&&g.dangerouslySetInnerHTML!==null&&g.dangerouslySetInnerHTML.__html!=null}var EE=null;function hae(){var f=window.event;return f&&f.type==="popstate"?f===EE?!1:(EE=f,!0):(EE=null,!1)}var dU=typeof setTimeout=="function"?setTimeout:void 0,fae=typeof clearTimeout=="function"?clearTimeout:void 0,hU=typeof Promise=="function"?Promise:void 0,mae=typeof queueMicrotask=="function"?queueMicrotask:typeof hU<"u"?function(f){return hU.resolve(null).then(f).catch(pae)}:dU;function pae(f){setTimeout(function(){throw f})}function xd(f){return f==="head"}function fU(f,g){var w=g,M=0;do{var R=w.nextSibling;if(f.removeChild(w),R&&R.nodeType===8)if(w=R.data,w==="/$"||w==="/&"){if(M===0){f.removeChild(R),mp(g);return}M--}else if(w==="$"||w==="$?"||w==="$~"||w==="$!"||w==="&")M++;else if(w==="html")_b(f.ownerDocument.documentElement);else if(w==="head"){w=f.ownerDocument.head,_b(w);for(var F=w.firstChild;F;){var Z=F.nextSibling,ve=F.nodeName;F[ht]||ve==="SCRIPT"||ve==="STYLE"||ve==="LINK"&&F.rel.toLowerCase()==="stylesheet"||w.removeChild(F),F=Z}}else w==="body"&&_b(f.ownerDocument.body);w=R}while(w);mp(g)}function mU(f,g){var w=f;f=0;do{var M=w.nextSibling;if(w.nodeType===1?g?(w._stashedDisplay=w.style.display,w.style.display="none"):(w.style.display=w._stashedDisplay||"",w.getAttribute("style")===""&&w.removeAttribute("style")):w.nodeType===3&&(g?(w._stashedText=w.nodeValue,w.nodeValue=""):w.nodeValue=w._stashedText||""),M&&M.nodeType===8)if(w=M.data,w==="/$"){if(f===0)break;f--}else w!=="$"&&w!=="$?"&&w!=="$~"&&w!=="$!"||f++;w=M}while(w)}function TE(f){var g=f.firstChild;for(g&&g.nodeType===10&&(g=g.nextSibling);g;){var w=g;switch(g=g.nextSibling,w.nodeName){case"HTML":case"HEAD":case"BODY":TE(w),ut(w);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(w.rel.toLowerCase()==="stylesheet")continue}f.removeChild(w)}}function gae(f,g,w,M){for(;f.nodeType===1;){var R=w;if(f.nodeName.toLowerCase()!==g.toLowerCase()){if(!M&&(f.nodeName!=="INPUT"||f.type!=="hidden"))break}else if(M){if(!f[ht])switch(g){case"meta":if(!f.hasAttribute("itemprop"))break;return f;case"link":if(F=f.getAttribute("rel"),F==="stylesheet"&&f.hasAttribute("data-precedence"))break;if(F!==R.rel||f.getAttribute("href")!==(R.href==null||R.href===""?null:R.href)||f.getAttribute("crossorigin")!==(R.crossOrigin==null?null:R.crossOrigin)||f.getAttribute("title")!==(R.title==null?null:R.title))break;return f;case"style":if(f.hasAttribute("data-precedence"))break;return f;case"script":if(F=f.getAttribute("src"),(F!==(R.src==null?null:R.src)||f.getAttribute("type")!==(R.type==null?null:R.type)||f.getAttribute("crossorigin")!==(R.crossOrigin==null?null:R.crossOrigin))&&F&&f.hasAttribute("async")&&!f.hasAttribute("itemprop"))break;return f;default:return f}}else if(g==="input"&&f.type==="hidden"){var F=R.name==null?null:""+R.name;if(R.type==="hidden"&&f.getAttribute("name")===F)return f}else return f;if(f=Fo(f.nextSibling),f===null)break}return null}function xae(f,g,w){if(g==="")return null;for(;f.nodeType!==3;)if((f.nodeType!==1||f.nodeName!=="INPUT"||f.type!=="hidden")&&!w||(f=Fo(f.nextSibling),f===null))return null;return f}function pU(f,g){for(;f.nodeType!==8;)if((f.nodeType!==1||f.nodeName!=="INPUT"||f.type!=="hidden")&&!g||(f=Fo(f.nextSibling),f===null))return null;return f}function AE(f){return f.data==="$?"||f.data==="$~"}function CE(f){return f.data==="$!"||f.data==="$?"&&f.ownerDocument.readyState!=="loading"}function bae(f,g){var w=f.ownerDocument;if(f.data==="$~")f._reactRetry=g;else if(f.data!=="$?"||w.readyState!=="loading")g();else{var M=function(){g(),w.removeEventListener("DOMContentLoaded",M)};w.addEventListener("DOMContentLoaded",M),f._reactRetry=M}}function Fo(f){for(;f!=null;f=f.nextSibling){var g=f.nodeType;if(g===1||g===3)break;if(g===8){if(g=f.data,g==="$"||g==="$!"||g==="$?"||g==="$~"||g==="&"||g==="F!"||g==="F")break;if(g==="/$"||g==="/&")return null}}return f}var jE=null;function gU(f){f=f.nextSibling;for(var g=0;f;){if(f.nodeType===8){var w=f.data;if(w==="/$"||w==="/&"){if(g===0)return Fo(f.nextSibling);g--}else w!=="$"&&w!=="$!"&&w!=="$?"&&w!=="$~"&&w!=="&"||g++}f=f.nextSibling}return null}function xU(f){f=f.previousSibling;for(var g=0;f;){if(f.nodeType===8){var w=f.data;if(w==="$"||w==="$!"||w==="$?"||w==="$~"||w==="&"){if(g===0)return f;g--}else w!=="/$"&&w!=="/&"||g++}f=f.previousSibling}return null}function bU(f,g,w){switch(g=xw(w),f){case"html":if(f=g.documentElement,!f)throw Error(r(452));return f;case"head":if(f=g.head,!f)throw Error(r(453));return f;case"body":if(f=g.body,!f)throw Error(r(454));return f;default:throw Error(r(451))}}function _b(f){for(var g=f.attributes;g.length;)f.removeAttributeNode(g[0]);ut(f)}var Io=new Map,yU=new Set;function bw(f){return typeof f.getRootNode=="function"?f.getRootNode():f.nodeType===9?f:f.ownerDocument}var Wc=z.d;z.d={f:yae,r:vae,D:wae,C:_ae,L:Sae,m:Nae,X:kae,S:Mae,M:Eae};function yae(){var f=Wc.f(),g=cw();return f||g}function vae(f){var g=fe(f);g!==null&&g.tag===5&&g.type==="form"?LI(g):Wc.r(f)}var dp=typeof document>"u"?null:document;function vU(f,g,w){var M=dp;if(M&&typeof g=="string"&&g){var R=Pn(g);R='link[rel="'+f+'"][href="'+R+'"]',typeof w=="string"&&(R+='[crossorigin="'+w+'"]'),yU.has(R)||(yU.add(R),f={rel:f,crossOrigin:w,href:g},M.querySelector(R)===null&&(g=M.createElement("link"),Ca(g,"link",f),Ne(g),M.head.appendChild(g)))}}function wae(f){Wc.D(f),vU("dns-prefetch",f,null)}function _ae(f,g){Wc.C(f,g),vU("preconnect",f,g)}function Sae(f,g,w){Wc.L(f,g,w);var M=dp;if(M&&f&&g){var R='link[rel="preload"][as="'+Pn(g)+'"]';g==="image"&&w&&w.imageSrcSet?(R+='[imagesrcset="'+Pn(w.imageSrcSet)+'"]',typeof w.imageSizes=="string"&&(R+='[imagesizes="'+Pn(w.imageSizes)+'"]')):R+='[href="'+Pn(f)+'"]';var F=R;switch(g){case"style":F=hp(f);break;case"script":F=fp(f)}Io.has(F)||(f=h({rel:"preload",href:g==="image"&&w&&w.imageSrcSet?void 0:f,as:g},w),Io.set(F,f),M.querySelector(R)!==null||g==="style"&&M.querySelector(Sb(F))||g==="script"&&M.querySelector(Nb(F))||(g=M.createElement("link"),Ca(g,"link",f),Ne(g),M.head.appendChild(g)))}}function Nae(f,g){Wc.m(f,g);var w=dp;if(w&&f){var M=g&&typeof g.as=="string"?g.as:"script",R='link[rel="modulepreload"][as="'+Pn(M)+'"][href="'+Pn(f)+'"]',F=R;switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":F=fp(f)}if(!Io.has(F)&&(f=h({rel:"modulepreload",href:f},g),Io.set(F,f),w.querySelector(R)===null)){switch(M){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(w.querySelector(Nb(F)))return}M=w.createElement("link"),Ca(M,"link",f),Ne(M),w.head.appendChild(M)}}}function Mae(f,g,w){Wc.S(f,g,w);var M=dp;if(M&&f){var R=Ge(M).hoistableStyles,F=hp(f);g=g||"default";var Z=R.get(F);if(!Z){var ve={loading:0,preload:null};if(Z=M.querySelector(Sb(F)))ve.loading=5;else{f=h({rel:"stylesheet",href:f,"data-precedence":g},w),(w=Io.get(F))&&PE(f,w);var Ue=Z=M.createElement("link");Ne(Ue),Ca(Ue,"link",f),Ue._p=new Promise(function(lt,bt){Ue.onload=lt,Ue.onerror=bt}),Ue.addEventListener("load",function(){ve.loading|=1}),Ue.addEventListener("error",function(){ve.loading|=2}),ve.loading|=4,yw(Z,g,M)}Z={type:"stylesheet",instance:Z,count:1,state:ve},R.set(F,Z)}}}function kae(f,g){Wc.X(f,g);var w=dp;if(w&&f){var M=Ge(w).hoistableScripts,R=fp(f),F=M.get(R);F||(F=w.querySelector(Nb(R)),F||(f=h({src:f,async:!0},g),(g=Io.get(R))&&DE(f,g),F=w.createElement("script"),Ne(F),Ca(F,"link",f),w.head.appendChild(F)),F={type:"script",instance:F,count:1,state:null},M.set(R,F))}}function Eae(f,g){Wc.M(f,g);var w=dp;if(w&&f){var M=Ge(w).hoistableScripts,R=fp(f),F=M.get(R);F||(F=w.querySelector(Nb(R)),F||(f=h({src:f,async:!0,type:"module"},g),(g=Io.get(R))&&DE(f,g),F=w.createElement("script"),Ne(F),Ca(F,"link",f),w.head.appendChild(F)),F={type:"script",instance:F,count:1,state:null},M.set(R,F))}}function wU(f,g,w,M){var R=(R=me.current)?bw(R):null;if(!R)throw Error(r(446));switch(f){case"meta":case"title":return null;case"style":return typeof w.precedence=="string"&&typeof w.href=="string"?(g=hp(w.href),w=Ge(R).hoistableStyles,M=w.get(g),M||(M={type:"style",instance:null,count:0,state:null},w.set(g,M)),M):{type:"void",instance:null,count:0,state:null};case"link":if(w.rel==="stylesheet"&&typeof w.href=="string"&&typeof w.precedence=="string"){f=hp(w.href);var F=Ge(R).hoistableStyles,Z=F.get(f);if(Z||(R=R.ownerDocument||R,Z={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},F.set(f,Z),(F=R.querySelector(Sb(f)))&&!F._p&&(Z.instance=F,Z.state.loading=5),Io.has(f)||(w={rel:"preload",as:"style",href:w.href,crossOrigin:w.crossOrigin,integrity:w.integrity,media:w.media,hrefLang:w.hrefLang,referrerPolicy:w.referrerPolicy},Io.set(f,w),F||Tae(R,f,w,Z.state))),g&&M===null)throw Error(r(528,""));return Z}if(g&&M!==null)throw Error(r(529,""));return null;case"script":return g=w.async,w=w.src,typeof w=="string"&&g&&typeof g!="function"&&typeof g!="symbol"?(g=fp(w),w=Ge(R).hoistableScripts,M=w.get(g),M||(M={type:"script",instance:null,count:0,state:null},w.set(g,M)),M):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,f))}}function hp(f){return'href="'+Pn(f)+'"'}function Sb(f){return'link[rel="stylesheet"]['+f+"]"}function _U(f){return h({},f,{"data-precedence":f.precedence,precedence:null})}function Tae(f,g,w,M){f.querySelector('link[rel="preload"][as="style"]['+g+"]")?M.loading=1:(g=f.createElement("link"),M.preload=g,g.addEventListener("load",function(){return M.loading|=1}),g.addEventListener("error",function(){return M.loading|=2}),Ca(g,"link",w),Ne(g),f.head.appendChild(g))}function fp(f){return'[src="'+Pn(f)+'"]'}function Nb(f){return"script[async]"+f}function SU(f,g,w){if(g.count++,g.instance===null)switch(g.type){case"style":var M=f.querySelector('style[data-href~="'+Pn(w.href)+'"]');if(M)return g.instance=M,Ne(M),M;var R=h({},w,{"data-href":w.href,"data-precedence":w.precedence,href:null,precedence:null});return M=(f.ownerDocument||f).createElement("style"),Ne(M),Ca(M,"style",R),yw(M,w.precedence,f),g.instance=M;case"stylesheet":R=hp(w.href);var F=f.querySelector(Sb(R));if(F)return g.state.loading|=4,g.instance=F,Ne(F),F;M=_U(w),(R=Io.get(R))&&PE(M,R),F=(f.ownerDocument||f).createElement("link"),Ne(F);var Z=F;return Z._p=new Promise(function(ve,Ue){Z.onload=ve,Z.onerror=Ue}),Ca(F,"link",M),g.state.loading|=4,yw(F,w.precedence,f),g.instance=F;case"script":return F=fp(w.src),(R=f.querySelector(Nb(F)))?(g.instance=R,Ne(R),R):(M=w,(R=Io.get(F))&&(M=h({},w),DE(M,R)),f=f.ownerDocument||f,R=f.createElement("script"),Ne(R),Ca(R,"link",M),f.head.appendChild(R),g.instance=R);case"void":return null;default:throw Error(r(443,g.type))}else g.type==="stylesheet"&&(g.state.loading&4)===0&&(M=g.instance,g.state.loading|=4,yw(M,w.precedence,f));return g.instance}function yw(f,g,w){for(var M=w.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),R=M.length?M[M.length-1]:null,F=R,Z=0;Z<M.length;Z++){var ve=M[Z];if(ve.dataset.precedence===g)F=ve;else if(F!==R)break}F?F.parentNode.insertBefore(f,F.nextSibling):(g=w.nodeType===9?w.head:w,g.insertBefore(f,g.firstChild))}function PE(f,g){f.crossOrigin==null&&(f.crossOrigin=g.crossOrigin),f.referrerPolicy==null&&(f.referrerPolicy=g.referrerPolicy),f.title==null&&(f.title=g.title)}function DE(f,g){f.crossOrigin==null&&(f.crossOrigin=g.crossOrigin),f.referrerPolicy==null&&(f.referrerPolicy=g.referrerPolicy),f.integrity==null&&(f.integrity=g.integrity)}var vw=null;function NU(f,g,w){if(vw===null){var M=new Map,R=vw=new Map;R.set(w,M)}else R=vw,M=R.get(w),M||(M=new Map,R.set(w,M));if(M.has(f))return M;for(M.set(f,null),w=w.getElementsByTagName(f),R=0;R<w.length;R++){var F=w[R];if(!(F[ht]||F[Xn]||f==="link"&&F.getAttribute("rel")==="stylesheet")&&F.namespaceURI!=="http://www.w3.org/2000/svg"){var Z=F.getAttribute(g)||"";Z=f+Z;var ve=M.get(Z);ve?ve.push(F):M.set(Z,[F])}}return M}function MU(f,g,w){f=f.ownerDocument||f,f.head.insertBefore(w,g==="title"?f.querySelector("head > title"):null)}function Aae(f,g,w){if(w===1||g.itemProp!=null)return!1;switch(f){case"meta":case"title":return!0;case"style":if(typeof g.precedence!="string"||typeof g.href!="string"||g.href==="")break;return!0;case"link":if(typeof g.rel!="string"||typeof g.href!="string"||g.href===""||g.onLoad||g.onError)break;switch(g.rel){case"stylesheet":return f=g.disabled,typeof g.precedence=="string"&&f==null;default:return!0}case"script":if(g.async&&typeof g.async!="function"&&typeof g.async!="symbol"&&!g.onLoad&&!g.onError&&g.src&&typeof g.src=="string")return!0}return!1}function kU(f){return!(f.type==="stylesheet"&&(f.state.loading&3)===0)}function Cae(f,g,w,M){if(w.type==="stylesheet"&&(typeof M.media!="string"||matchMedia(M.media).matches!==!1)&&(w.state.loading&4)===0){if(w.instance===null){var R=hp(M.href),F=g.querySelector(Sb(R));if(F){g=F._p,g!==null&&typeof g=="object"&&typeof g.then=="function"&&(f.count++,f=ww.bind(f),g.then(f,f)),w.state.loading|=4,w.instance=F,Ne(F);return}F=g.ownerDocument||g,M=_U(M),(R=Io.get(R))&&PE(M,R),F=F.createElement("link"),Ne(F);var Z=F;Z._p=new Promise(function(ve,Ue){Z.onload=ve,Z.onerror=Ue}),Ca(F,"link",M),w.instance=F}f.stylesheets===null&&(f.stylesheets=new Map),f.stylesheets.set(w,g),(g=w.state.preload)&&(w.state.loading&3)===0&&(f.count++,w=ww.bind(f),g.addEventListener("load",w),g.addEventListener("error",w))}}var RE=0;function jae(f,g){return f.stylesheets&&f.count===0&&Sw(f,f.stylesheets),0<f.count||0<f.imgCount?function(w){var M=setTimeout(function(){if(f.stylesheets&&Sw(f,f.stylesheets),f.unsuspend){var F=f.unsuspend;f.unsuspend=null,F()}},6e4+g);0<f.imgBytes&&RE===0&&(RE=62500*dae());var R=setTimeout(function(){if(f.waitingForImages=!1,f.count===0&&(f.stylesheets&&Sw(f,f.stylesheets),f.unsuspend)){var F=f.unsuspend;f.unsuspend=null,F()}},(f.imgBytes>RE?50:800)+g);return f.unsuspend=w,function(){f.unsuspend=null,clearTimeout(M),clearTimeout(R)}}:null}function ww(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Sw(this,this.stylesheets);else if(this.unsuspend){var f=this.unsuspend;this.unsuspend=null,f()}}}var _w=null;function Sw(f,g){f.stylesheets=null,f.unsuspend!==null&&(f.count++,_w=new Map,g.forEach(Pae,f),_w=null,ww.call(f))}function Pae(f,g){if(!(g.state.loading&4)){var w=_w.get(f);if(w)var M=w.get(null);else{w=new Map,_w.set(f,w);for(var R=f.querySelectorAll("link[data-precedence],style[data-precedence]"),F=0;F<R.length;F++){var Z=R[F];(Z.nodeName==="LINK"||Z.getAttribute("media")!=="not all")&&(w.set(Z.dataset.precedence,Z),M=Z)}M&&w.set(null,M)}R=g.instance,Z=R.getAttribute("data-precedence"),F=w.get(Z)||M,F===M&&w.set(null,R),w.set(Z,R),this.count++,M=ww.bind(this),R.addEventListener("load",M),R.addEventListener("error",M),F?F.parentNode.insertBefore(R,F.nextSibling):(f=f.nodeType===9?f.head:f,f.insertBefore(R,f.firstChild)),g.state.loading|=4}}var Mb={$$typeof:N,Provider:null,Consumer:null,_currentValue:X,_currentValue2:X,_threadCount:0};function Dae(f,g,w,M,R,F,Z,ve,Ue){this.tag=1,this.containerInfo=f,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=at(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=at(0),this.hiddenUpdates=at(null),this.identifierPrefix=M,this.onUncaughtError=R,this.onCaughtError=F,this.onRecoverableError=Z,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ue,this.incompleteTransitions=new Map}function EU(f,g,w,M,R,F,Z,ve,Ue,lt,bt,wt){return f=new Dae(f,g,w,Z,Ue,lt,bt,wt,ve),g=1,F===!0&&(g|=24),F=Js(3,null,null,g),f.current=F,F.stateNode=f,g=fk(),g.refCount++,f.pooledCache=g,g.refCount++,F.memoizedState={element:M,isDehydrated:w,cache:g},xk(F),f}function TU(f){return f?(f=Vm,f):Vm}function AU(f,g,w,M,R,F){R=TU(R),M.context===null?M.context=R:M.pendingContext=R,M=sd(g),M.payload={element:w},F=F===void 0?null:F,F!==null&&(M.callback=F),w=od(f,M,g),w!==null&&(Ds(w,f,g),rb(w,f,g))}function CU(f,g){if(f=f.memoizedState,f!==null&&f.dehydrated!==null){var w=f.retryLane;f.retryLane=w!==0&&w<g?w:g}}function OE(f,g){CU(f,g),(f=f.alternate)&&CU(f,g)}function jU(f){if(f.tag===13||f.tag===31){var g=Xh(f,67108864);g!==null&&Ds(g,f,67108864),OE(f,67108864)}}function PU(f){if(f.tag===13||f.tag===31){var g=io();g=Vn(g);var w=Xh(f,g);w!==null&&Ds(w,f,g),OE(f,g)}}var Nw=!0;function Rae(f,g,w,M){var R=K.T;K.T=null;var F=z.p;try{z.p=2,LE(f,g,w,M)}finally{z.p=F,K.T=R}}function Oae(f,g,w,M){var R=K.T;K.T=null;var F=z.p;try{z.p=8,LE(f,g,w,M)}finally{z.p=F,K.T=R}}function LE(f,g,w,M){if(Nw){var R=FE(M);if(R===null)_E(f,g,M,Mw,w),RU(f,M);else if(Fae(R,f,g,w,M))M.stopPropagation();else if(RU(f,M),g&4&&-1<Lae.indexOf(f)){for(;R!==null;){var F=fe(R);if(F!==null)switch(F.tag){case 3:if(F=F.stateNode,F.current.memoizedState.isDehydrated){var Z=ze(F.pendingLanes);if(Z!==0){var ve=F;for(ve.pendingLanes|=2,ve.entangledLanes|=2;Z;){var Ue=1<<31-Ie(Z);ve.entanglements[1]|=Ue,Z&=~Ue}Yl(F),(hr&6)===0&&(ow=O()+500,yb(0))}}break;case 31:case 13:ve=Xh(F,2),ve!==null&&Ds(ve,F,2),cw(),OE(F,2)}if(F=FE(M),F===null&&_E(f,g,M,Mw,w),F===R)break;R=F}R!==null&&M.stopPropagation()}else _E(f,g,M,null,w)}}function FE(f){return f=Eo(f),IE(f)}var Mw=null;function IE(f){if(Mw=null,f=Et(f),f!==null){var g=s(f);if(g===null)f=null;else{var w=g.tag;if(w===13){if(f=o(g),f!==null)return f;f=null}else if(w===31){if(f=l(g),f!==null)return f;f=null}else if(w===3){if(g.stateNode.current.memoizedState.isDehydrated)return g.tag===3?g.stateNode.containerInfo:null;f=null}else g!==f&&(f=null)}}return Mw=f,null}function DU(f){switch(f){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(J()){case le:return 2;case Se:return 8;case we:case ae:return 32;case Le:return 268435456;default:return 32}default:return 32}}var UE=!1,bd=null,yd=null,vd=null,kb=new Map,Eb=new Map,wd=[],Lae="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 RU(f,g){switch(f){case"focusin":case"focusout":bd=null;break;case"dragenter":case"dragleave":yd=null;break;case"mouseover":case"mouseout":vd=null;break;case"pointerover":case"pointerout":kb.delete(g.pointerId);break;case"gotpointercapture":case"lostpointercapture":Eb.delete(g.pointerId)}}function Tb(f,g,w,M,R,F){return f===null||f.nativeEvent!==F?(f={blockedOn:g,domEventName:w,eventSystemFlags:M,nativeEvent:F,targetContainers:[R]},g!==null&&(g=fe(g),g!==null&&jU(g)),f):(f.eventSystemFlags|=M,g=f.targetContainers,R!==null&&g.indexOf(R)===-1&&g.push(R),f)}function Fae(f,g,w,M,R){switch(g){case"focusin":return bd=Tb(bd,f,g,w,M,R),!0;case"dragenter":return yd=Tb(yd,f,g,w,M,R),!0;case"mouseover":return vd=Tb(vd,f,g,w,M,R),!0;case"pointerover":var F=R.pointerId;return kb.set(F,Tb(kb.get(F)||null,f,g,w,M,R)),!0;case"gotpointercapture":return F=R.pointerId,Eb.set(F,Tb(Eb.get(F)||null,f,g,w,M,R)),!0}return!1}function OU(f){var g=Et(f.target);if(g!==null){var w=s(g);if(w!==null){if(g=w.tag,g===13){if(g=o(w),g!==null){f.blockedOn=g,sr(f.priority,function(){PU(w)});return}}else if(g===31){if(g=l(w),g!==null){f.blockedOn=g,sr(f.priority,function(){PU(w)});return}}else if(g===3&&w.stateNode.current.memoizedState.isDehydrated){f.blockedOn=w.tag===3?w.stateNode.containerInfo:null;return}}}f.blockedOn=null}function kw(f){if(f.blockedOn!==null)return!1;for(var g=f.targetContainers;0<g.length;){var w=FE(f.nativeEvent);if(w===null){w=f.nativeEvent;var M=new w.constructor(w.type,w);Es=M,w.target.dispatchEvent(M),Es=null}else return g=fe(w),g!==null&&jU(g),f.blockedOn=w,!1;g.shift()}return!0}function LU(f,g,w){kw(f)&&w.delete(g)}function Iae(){UE=!1,bd!==null&&kw(bd)&&(bd=null),yd!==null&&kw(yd)&&(yd=null),vd!==null&&kw(vd)&&(vd=null),kb.forEach(LU),Eb.forEach(LU)}function Ew(f,g){f.blockedOn===g&&(f.blockedOn=null,UE||(UE=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Iae)))}var Tw=null;function FU(f){Tw!==f&&(Tw=f,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Tw===f&&(Tw=null);for(var g=0;g<f.length;g+=3){var w=f[g],M=f[g+1],R=f[g+2];if(typeof M!="function"){if(IE(M||w)===null)continue;break}var F=fe(w);F!==null&&(f.splice(g,3),g-=3,Fk(F,{pending:!0,data:R,method:w.method,action:M},M,R))}}))}function mp(f){function g(Ue){return Ew(Ue,f)}bd!==null&&Ew(bd,f),yd!==null&&Ew(yd,f),vd!==null&&Ew(vd,f),kb.forEach(g),Eb.forEach(g);for(var w=0;w<wd.length;w++){var M=wd[w];M.blockedOn===f&&(M.blockedOn=null)}for(;0<wd.length&&(w=wd[0],w.blockedOn===null);)OU(w),w.blockedOn===null&&wd.shift();if(w=(f.ownerDocument||f).$$reactFormReplay,w!=null)for(M=0;M<w.length;M+=3){var R=w[M],F=w[M+1],Z=R[Nn]||null;if(typeof F=="function")Z||FU(w);else if(Z){var ve=null;if(F&&F.hasAttribute("formAction")){if(R=F,Z=F[Nn]||null)ve=Z.formAction;else if(IE(R)!==null)continue}else ve=Z.action;typeof ve=="function"?w[M+1]=ve:(w.splice(M,3),M-=3),FU(w)}}}function IU(){function f(F){F.canIntercept&&F.info==="react-transition"&&F.intercept({handler:function(){return new Promise(function(Z){return R=Z})},focusReset:"manual",scroll:"manual"})}function g(){R!==null&&(R(),R=null),M||setTimeout(w,20)}function w(){if(!M&&!navigation.transition){var F=navigation.currentEntry;F&&F.url!=null&&navigation.navigate(F.url,{state:F.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var M=!1,R=null;return navigation.addEventListener("navigate",f),navigation.addEventListener("navigatesuccess",g),navigation.addEventListener("navigateerror",g),setTimeout(w,100),function(){M=!0,navigation.removeEventListener("navigate",f),navigation.removeEventListener("navigatesuccess",g),navigation.removeEventListener("navigateerror",g),R!==null&&(R(),R=null)}}}function zE(f){this._internalRoot=f}Aw.prototype.render=zE.prototype.render=function(f){var g=this._internalRoot;if(g===null)throw Error(r(409));var w=g.current,M=io();AU(w,M,f,g,null,null)},Aw.prototype.unmount=zE.prototype.unmount=function(){var f=this._internalRoot;if(f!==null){this._internalRoot=null;var g=f.containerInfo;AU(f.current,2,null,f,null,null),cw(),g[hi]=null}};function Aw(f){this._internalRoot=f}Aw.prototype.unstable_scheduleHydration=function(f){if(f){var g=xn();f={blockedOn:null,target:f,priority:g};for(var w=0;w<wd.length&&g!==0&&g<wd[w].priority;w++);wd.splice(w,0,f),w===0&&OU(f)}};var UU=e.version;if(UU!=="19.2.0")throw Error(r(527,UU,"19.2.0"));z.findDOMNode=function(f){var g=f._reactInternals;if(g===void 0)throw typeof f.render=="function"?Error(r(188)):(f=Object.keys(f).join(","),Error(r(268,f)));return f=u(g),f=f!==null?d(f):null,f=f===null?null:f.stateNode,f};var Uae={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:K,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Cw=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Cw.isDisabled&&Cw.supportsFiber)try{He=Cw.inject(Uae),be=Cw}catch{}}return Cb.createRoot=function(f,g){if(!i(f))throw Error(r(299));var w=!1,M="",R=qI,F=WI,Z=KI;return g!=null&&(g.unstable_strictMode===!0&&(w=!0),g.identifierPrefix!==void 0&&(M=g.identifierPrefix),g.onUncaughtError!==void 0&&(R=g.onUncaughtError),g.onCaughtError!==void 0&&(F=g.onCaughtError),g.onRecoverableError!==void 0&&(Z=g.onRecoverableError)),g=EU(f,1,!1,null,null,w,M,null,R,F,Z,IU),f[hi]=g.current,wE(f),new zE(g)},Cb.hydrateRoot=function(f,g,w){if(!i(f))throw Error(r(299));var M=!1,R="",F=qI,Z=WI,ve=KI,Ue=null;return w!=null&&(w.unstable_strictMode===!0&&(M=!0),w.identifierPrefix!==void 0&&(R=w.identifierPrefix),w.onUncaughtError!==void 0&&(F=w.onUncaughtError),w.onCaughtError!==void 0&&(Z=w.onCaughtError),w.onRecoverableError!==void 0&&(ve=w.onRecoverableError),w.formState!==void 0&&(Ue=w.formState)),g=EU(f,1,!0,g,w??null,M,R,Ue,F,Z,ve,IU),g.context=TU(null),w=g.current,M=io(),M=Vn(M),R=sd(M),R.callback=null,od(w,R,M),w=M,g.current.lanes=w,jt(g,w),Yl(g),f[hi]=g.current,wE(f),new Aw(g)},Cb.version="19.2.0",Cb}var XU;function Yae(){if(XU)return $E.exports;XU=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(),$E.exports=Xae(),$E.exports}var Qae=Yae();const mn=t=>typeof t=="string",jb=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},YU=t=>t==null?"":""+t,Zae=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Jae=/###/g,QU=t=>t&&t.indexOf("###")>-1?t.replace(Jae,"."):t,ZU=t=>!t||mn(t),b0=(t,e,n)=>{const r=mn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(ZU(t))return{};const s=QU(r[i]);!t[s]&&n&&(t[s]=new n),Object.prototype.hasOwnProperty.call(t,s)?t=t[s]:t={},++i}return ZU(t)?{}:{obj:t,k:QU(r[i])}},JU=(t,e,n)=>{const{obj:r,k:i}=b0(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=b0(t,o,Object);for(;l.obj===void 0&&o.length;)s=`${o[o.length-1]}.${s}`,o=o.slice(0,o.length-1),l=b0(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${s}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${s}`]=n},ese=(t,e,n,r)=>{const{obj:i,k:s}=b0(t,e,Object);i[s]=i[s]||[],i[s].push(n)},B1=(t,e)=>{const{obj:n,k:r}=b0(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},tse=(t,e,n)=>{const r=B1(t,n);return r!==void 0?r:B1(e,n)},Aq=(t,e,n)=>{for(const r in e)r!=="__proto__"&&r!=="constructor"&&(r in t?mn(t[r])||t[r]instanceof String||mn(e[r])||e[r]instanceof String?n&&(t[r]=e[r]):Aq(t[r],e[r],n):t[r]=e[r]);return t},pp=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var nse={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const rse=t=>mn(t)?t.replace(/[&<>"'\/]/g,e=>nse[e]):t;class ise{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 ase=[" ",",","?","!",";"],sse=new ise(20),ose=(t,e,n)=>{e=e||"",n=n||"";const r=ase.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=sse.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},Qj=(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},H0=t=>t?.replace("_","-"),lse={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 H1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||lse,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:(mn(e[0])&&(e[0]=`${r}${this.prefix} ${e[0]}`),this.logger[n](e))}create(e){return new H1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new H1(this.logger,e)}}var cc=new H1;let rM=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 ez extends rM{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):mn(r)&&s?l.push(...r.split(s)):l.push(r)));const c=B1(this.data,l);return!c&&!n&&!r&&e.indexOf(".")>-1&&(e=l[0],n=l[1],r=l.slice(2).join(".")),c||!o||!mn(r)?c:Qj(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),JU(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)(mn(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=B1(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?Aq(c,r,s):c={...c,...r},JU(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 jq=Symbol("i18next/PATH_KEY");function cse(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===jq?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function Zj(t,e){const{[jq]:n}=t(cse());return n.join(e?.keySeparator??".")}const tz={},WE=t=>!mn(t)&&typeof t!="boolean"&&typeof t!="number";class $1 extends rM{constructor(e,n={}){super(),Zae(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=cc.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=WE(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&&!ose(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:mn(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:mn(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=Zj(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 h=i.lng||this.language,p=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h?.toLowerCase()==="cimode")return p?s?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:h,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${l}`:s?{res:l,usedKey:l,exactUsedKey:l,usedLng:h,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:l;const m=this.resolve(e,i);let x=m?.res;const y=m?.usedKey||l,v=m?.exactUsedKey||l,b=["[object Number]","[object Function]","[object RegExp]"],S=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,N=!this.i18nFormat||this.i18nFormat.handleAsObject,T=i.count!==void 0&&!mn(i.count),k=$1.hasDefaultValue(i),C=T?this.pluralResolver.getSuffix(h,i.count,i):"",E=i.ordinal&&T?this.pluralResolver.getSuffix(h,i.count,{ordinal:!1}):"",P=T&&!i.ordinal&&i.count===0,A=P&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${C}`]||i[`defaultValue${E}`]||i.defaultValue;let D=x;N&&!x&&k&&(D=A);const I=WE(D),L=Object.prototype.toString.apply(D);if(N&&D&&I&&b.indexOf(L)<0&&!(mn(S)&&Array.isArray(D))){if(!i.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const U=this.options.returnedObjectHandler?this.options.returnedObjectHandler(y,D,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return s?(m.res=U,m.usedParams=this.getUsedParamsDetails(i),m):U}if(o){const U=Array.isArray(D),j=U?[]:{},V=U?v:y;for(const K in D)if(Object.prototype.hasOwnProperty.call(D,K)){const z=`${V}${o}${K}`;k&&!x?j[K]=this.translate(z,{...i,defaultValue:WE(A)?A[K]:void 0,joinArrays:!1,ns:c}):j[K]=this.translate(z,{...i,joinArrays:!1,ns:c}),j[K]===z&&(j[K]=D[K])}x=j}}else if(N&&mn(S)&&Array.isArray(x))x=x.join(S),x&&(x=this.extendTranslation(x,e,i,r));else{let U=!1,j=!1;!this.isValidLookup(x)&&k&&(U=!0,x=A),this.isValidLookup(x)||(j=!0,x=l);const K=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&j?void 0:x,z=k&&A!==x&&this.options.updateMissing;if(j||U||z){if(this.logger.log(z?"updateKey":"missingKey",h,u,l,z?A:x),o){const $=this.resolve(l,{...i,keySeparator:!1});$&&$.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 X=[];const Y=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Y&&Y[0])for(let $=0;$<Y.length;$++)X.push(Y[$]);else this.options.saveMissingTo==="all"?X=this.languageUtils.toResolveHierarchy(i.lng||this.language):X.push(i.lng||this.language);const te=($,W,ne)=>{const re=k&&ne!==x?ne:K;this.options.missingKeyHandler?this.options.missingKeyHandler($,u,W,re,z,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing($,u,W,re,z,i),this.emit("missingKey",$,u,W,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&T?X.forEach($=>{const W=this.pluralResolver.getSuffixes($,i);P&&i[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(ne=>{te([$],l+ne,i[`defaultValue${ne}`]||A)})}):te(X,l,A))}x=this.extendTranslation(x,e,i,m,r),j&&x===l&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${l}`),(j||U)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,U?x:void 0,i))}return s?(m.res=x,m.usedParams=this.getUsedParamsDetails(i),m):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=mn(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const h=e.match(this.interpolator.nestingRegexp);u=h&&h.length}let d=r.replace&&!mn(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 h=e.match(this.interpolator.nestingRegexp),p=h&&h.length;u<p&&(r.nest=!1)}!r.lng&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(e=this.interpolator.nest(e,(...h)=>s?.[0]===h[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):this.translate(...h,n),r)),r.interpolation&&this.interpolator.reset()}const o=r.postProcess||this.options.postProcess,l=mn(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 mn(e)&&(e=[e]),e.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;i=d;let h=u.namespaces;this.options.fallbackNS&&(h=h.concat(this.options.fallbackNS));const p=n.count!==void 0&&!mn(n.count),m=p&&!n.ordinal&&n.count===0,x=n.context!==void 0&&(mn(n.context)||typeof n.context=="number")&&n.context!=="",y=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);h.forEach(v=>{this.isValidLookup(r)||(l=v,!tz[`${y[0]}-${v}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(tz[`${y[0]}-${v}`]=!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(b=>{if(this.isValidLookup(r))return;o=b;const S=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(S,d,b,v,n);else{let T;p&&(T=this.pluralResolver.getSuffix(b,n.count,n));const k=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(n.ordinal&&T.indexOf(C)===0&&S.push(d+T.replace(C,this.options.pluralSeparator)),S.push(d+T),m&&S.push(d+k)),x){const E=`${d}${this.options.contextSeparator||"_"}${n.context}`;S.push(E),p&&(n.ordinal&&T.indexOf(C)===0&&S.push(E+T.replace(C,this.options.pluralSeparator)),S.push(E+T),m&&S.push(E+k))}}let N;for(;N=S.pop();)this.isValidLookup(r)||(s=N,r=this.getResource(b,v,N,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&&!mn(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 nz{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=cc.create("languageUtils")}getScriptPartFromCode(e){if(e=H0(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=H0(e),!e||e.indexOf("-")<0)return e;const n=e.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(e){if(mn(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)),mn(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 mn(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))):mn(e)&&s(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&s(this.formatLanguageCode(o))}),i}}const rz={zero:0,one:1,two:2,few:3,many:4,other:5},iz={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class use{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=cc.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=H0(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!"),iz;if(!e.match(/-|_/))return iz;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)=>rz[i]-rz[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 az=(t,e,n,r=".",i=!0)=>{let s=tse(t,e,n);return!s&&i&&mn(n)&&(s=Qj(t,n,r),s===void 0&&(s=Qj(e,n,r))),s},KE=t=>t.replace(/\$/g,"$$$$");class dse{constructor(e={}){this.logger=cc.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:h,nestingPrefix:p,nestingPrefixEscaped:m,nestingSuffix:x,nestingSuffixEscaped:y,nestingOptionsSeparator:v,maxReplaces:b,alwaysFormat:S}=e.interpolation;this.escape=n!==void 0?n:rse,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=s?pp(s):o||"{{",this.suffix=l?pp(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":h||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=p?pp(p):m||pp("$t("),this.nestingSuffix=x?pp(x):y||pp(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=b||1e3,this.alwaysFormat=S!==void 0?S:!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=m=>{if(m.indexOf(this.formatSeparator)<0){const b=az(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(b,void 0,r,{...i,...n,interpolationkey:m}):b}const x=m.split(this.formatSeparator),y=x.shift().trim(),v=x.join(this.formatSeparator).trim();return this.format(az(n,c,y,this.options.keySeparator,this.options.ignoreJSONStructure),v,r,{...i,...n,interpolationkey:y})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,h=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>KE(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?KE(this.escape(m)):KE(m)}].forEach(m=>{for(l=0;s=m.regex.exec(e);){const x=s[1].trim();if(o=u(x),o===void 0)if(typeof d=="function"){const v=d(e,s,i);o=mn(v)?v:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))o="";else if(h){o=s[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),o="";else!mn(o)&&!this.useRawValueToEscape&&(o=YU(o));const y=m.safeValue(o);if(e=e.replace(s[0],y),h?(m.regex.lastIndex+=o.length,m.regex.lastIndex-=s[0].length):m.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 h=c.split(new RegExp(`${d}[ ]*{`));let p=`{${h[1]}`;c=h[0],p=this.interpolate(p,o);const m=p.match(/'/g),x=p.match(/"/g);((m?.length??0)%2===0&&!x||x.length%2!==0)&&(p=p.replace(/'/g,'"'));try{o=JSON.parse(p),u&&(o={...u,...o})}catch(y){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,y),`${c}${d}${p}`}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&&!mn(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&&!mn(s))return s;mn(s)||(s=YU(s)),s||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),s=""),c.length&&(s=c.reduce((d,h)=>this.format(d,h,r.lng,{...r,interpolationkey:i[1].trim()}),s.trim())),e=e.replace(i[0],s),this.regexp.lastIndex=0}return e}}const hse=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}},sz=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(H0(r),i),e[o]=l),l(n)}},fse=t=>(e,n,r)=>t(H0(n),r)(e);class mse{constructor(e={}){this.logger=cc.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?sz:fse;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()]=sz(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}=hse(c);if(this.formats[u]){let h=l;try{const p=i?.formatParams?.[i.interpolationkey]||{},m=p.locale||p.lng||i.locale||i.lng||r;h=this.formats[u](l,m,{...d,...i,...p})}catch(p){this.logger.warn(p)}return h}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const pse=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class gse extends rM{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=cc.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(h=>{const p=`${u}|${h}`;!r.reload&&this.store.hasResourceBundle(u,h)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?o[p]===void 0&&(o[p]=!0):(this.state[p]=1,d=!1,o[p]===void 0&&(o[p]=!0),s[p]===void 0&&(s[p]=!0),c[h]===void 0&&(c[h]=!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=>{ese(c.loaded,[s],o),pse(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(h=>{l[u][h]===void 0&&(l[u][h]=!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 h=this.waitingReads.shift();this.read(h.lng,h.ns,h.fcName,h.tried,h.wait,h.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();mn(e)&&(e=this.languageUtils.toResolveHierarchy(e)),mn(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(h=>l(null,h)).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 oz=()=>({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]),mn(t[1])&&(e.defaultValue=t[1]),mn(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}),lz=t=>(mn(t.ns)&&(t.ns=[t.ns]),mn(t.fallbackLng)&&(t.fallbackLng=[t.fallbackLng]),mn(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),Pw=()=>{},xse=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class y0 extends rM{constructor(e={},n){if(super(),this.options=lz(e),this.services={},this.logger=cc,this.modules={external:[]},xse(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&&(mn(e.ns)?e.defaultNS=e.ns:e.ns.indexOf("translation")<0&&(e.defaultNS=e.ns[0]));const r=oz();this.options={...r,...this.options,...lz(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?cc.init(i(this.modules.logger),this.options):cc.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=mse;const d=new nz(this.options);this.store=new ez(this.options.resources,this.options);const h=this.services;h.logger=cc,h.resourceStore=this.store,h.languageUtils=d,h.pluralResolver=new use(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)&&(h.formatter=i(u),h.formatter.init&&h.formatter.init(h,this.options),this.options.interpolation.format=h.formatter.format.bind(h.formatter)),h.interpolator=new dse(this.options),h.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},h.backendConnector=new gse(i(this.modules.backend),h.resourceStore,h,this.options),h.backendConnector.on("*",(m,...x)=>{this.emit(m,...x)}),this.modules.languageDetector&&(h.languageDetector=i(this.modules.languageDetector),h.languageDetector.init&&h.languageDetector.init(h,this.options.detection,this.options)),this.modules.i18nFormat&&(h.i18nFormat=i(this.modules.i18nFormat),h.i18nFormat.init&&h.i18nFormat.init(this)),this.translator=new $1(this.services,this.options),this.translator.on("*",(m,...x)=>{this.emit(m,...x)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,n||(n=Pw),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=jb(),c=()=>{const u=(d,h)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(h),n(d,h)};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=Pw){let r=n;const i=mn(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=jb();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=Pw),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=jb();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=mn(l)?l:l&&l[0],u=this.store.hasLanguageSomeTranslations(c)?c:this.services.languageUtils.getBestMatchFromCodes(mn(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(h=>(typeof h=="function"&&(h=Zj(h,{...this.options,...o})),`${c.keyPrefix}${u}${h}`)):(typeof s=="function"&&(s=Zj(s,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${s}`:s),this.t(d,c)};return mn(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=jb();return this.options.ns?(mn(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=jb();mn(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 nz(oz());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 y0(e,n);return r.createInstance=y0.createInstance,r}cloneInstance(e={},n=Pw){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},s=new y0(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,h)=>(d[h]={...c[u][h]},d),c[u]),c),{});s.store=new ez(l,i),s.services.resourceStore=s.store}return s.translator=new $1(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 ks=y0.createInstance();ks.createInstance;ks.dir;ks.init;ks.loadResources;ks.reloadResources;ks.use;ks.changeLanguage;ks.getFixedT;ks.t;ks.exists;ks.setDefaultNamespace;ks.hasLoadedNamespace;ks.loadNamespaces;ks.loadLanguages;const bse=(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);nm(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},cz={},Pq=(t,e,n,r)=>{nm(n)&&cz[n]||(nm(n)&&(cz[n]=new Date),bse(t,e,n,r))},Dq=(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,Dq(t,n))},uz=(t,e,n,r)=>{if(nm(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,Dq(t,r))},yse=(t,e,n={})=>!e.languages||!e.languages.length?(Pq(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}}),nm=t=>typeof t=="string",vse=t=>typeof t=="object"&&t!==null,wse=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,_se={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},Sse=t=>_se[t],Nse=t=>t.replace(wse,Sse);let eP={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:Nse};const Mse=(t={})=>{eP={...eP,...t}},kse=()=>eP;let Rq;const Ese=t=>{Rq=t},Tse=()=>Rq,Ase={type:"3rdParty",init(t){Mse(t.options.react),Ese(t)}},Cse=_.createContext();class jse{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var XE={exports:{}},YE={};var dz;function Pse(){if(dz)return YE;dz=1;var t=xx();function e(h,p){return h===p&&(h!==0||1/h===1/p)||h!==h&&p!==p}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,s=t.useLayoutEffect,o=t.useDebugValue;function l(h,p){var m=p(),x=r({inst:{value:m,getSnapshot:p}}),y=x[0].inst,v=x[1];return s(function(){y.value=m,y.getSnapshot=p,c(y)&&v({inst:y})},[h,m,p]),i(function(){return c(y)&&v({inst:y}),h(function(){c(y)&&v({inst:y})})},[h]),o(m),m}function c(h){var p=h.getSnapshot;h=h.value;try{var m=p();return!n(h,m)}catch{return!0}}function u(h,p){return p()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return YE.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,YE}var hz;function Oq(){return hz||(hz=1,XE.exports=Pse()),XE.exports}var mR=Oq();const Dse=(t,e)=>nm(e)?e:vse(e)&&nm(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,Rse={t:Dse,ready:!1},Ose=()=>()=>{},On=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=_.useContext(Cse)||{},s=n||r||Tse();s&&!s.reportNamespaces&&(s.reportNamespaces=new jse),s||Pq(s,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=_.useMemo(()=>({...kse(),...s?.options?.react,...e}),[s,e]),{useSuspense:l,keyPrefix:c}=o,u=i||s?.options?.defaultNS,d=nm(u)?[u]:u||["translation"],h=_.useMemo(()=>d,d);s?.reportNamespaces?.addUsedNamespaces?.(h);const p=_.useRef(0),m=_.useCallback(A=>{if(!s)return Ose;const{bindI18n:D,bindI18nStore:I}=o,L=()=>{p.current+=1,A()};return D&&s.on(D,L),I&&s.store.on(I,L),()=>{D&&D.split(" ").forEach(U=>s.off(U,L)),I&&I.split(" ").forEach(U=>s.store.off(U,L))}},[s,o]),x=_.useRef(),y=_.useCallback(()=>{if(!s)return Rse;const A=!!(s.isInitialized||s.initializedStoreOnce)&&h.every(V=>yse(V,s,o)),D=e.lng||s.language,I=p.current,L=x.current;if(L&&L.ready===A&&L.lng===D&&L.keyPrefix===c&&L.revision===I)return L;const j={t:s.getFixedT(D,o.nsMode==="fallback"?h:h[0],c),ready:A,lng:D,keyPrefix:c,revision:I};return x.current=j,j},[s,h,c,o,e.lng]),[v,b]=_.useState(0),{t:S,ready:N}=mR.useSyncExternalStore(m,y,y);_.useEffect(()=>{if(s&&!N&&!l){const A=()=>b(D=>D+1);e.lng?uz(s,e.lng,h,A):Jj(s,h,A)}},[s,e.lng,h,N,l,v]);const T=s||{},k=_.useRef(null),C=_.useRef(),E=A=>{const D=Object.getOwnPropertyDescriptors(A);D.__original&&delete D.__original;const I=Object.create(Object.getPrototypeOf(A),D);if(!Object.prototype.hasOwnProperty.call(I,"__original"))try{Object.defineProperty(I,"__original",{value:A,writable:!1,enumerable:!1,configurable:!1})}catch{}return I},P=_.useMemo(()=>{const A=T,D=A?.language;let I=A;A&&(k.current&&k.current.__original===A?C.current!==D?(I=E(A),k.current=I,C.current=D):I=k.current:(I=E(A),k.current=I,C.current=D));const L=[S,I,N];return L.t=S,L.i18n=I,L.ready=N,L},[S,T,N,T.resolvedLanguage,T.language,T.languages]);if(s&&l&&!N)throw new Promise(A=>{const D=()=>A();e.lng?uz(s,e.lng,h,D):Jj(s,h,D)});return P},{slice:Lse,forEach:Fse}=[];function Ise(t){return Fse.call(Lse.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Use(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 fz=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,zse=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(!fz.test(r.domain))throw new TypeError("option domain is invalid");s+=`; Domain=${r.domain}`}if(r.path){if(!fz.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},mz={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=zse(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 Bse={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return mz.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:s}=e;n&&typeof document<"u"&&mz.create(n,t,r,i,s)}},Hse={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}},$se={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,r;if(typeof window<"u"){const{hash:i}=window.location;if(i&&i.length>2){const 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 gp=null;const pz=()=>{if(gp!==null)return gp;try{if(gp=typeof window<"u"&&window.localStorage!==null,!gp)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{gp=!1}return gp};var Vse={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&pz())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&pz()&&window.localStorage.setItem(n,t)}};let xp=null;const gz=()=>{if(xp!==null)return xp;try{if(xp=typeof window<"u"&&window.sessionStorage!==null,!xp)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{xp=!1}return xp};var Gse={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&gz())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&gz()&&window.sessionStorage.setItem(n,t)}},qse={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}},Wse={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}},Kse={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}},Xse={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 Lq=!1;try{document.cookie,Lq=!0}catch{}const Fq=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Lq||Fq.splice(1,1);const Yse=()=>({order:Fq,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class Iq{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=Ise(n,this.options||{},Yse()),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(Bse),this.addDetector(Hse),this.addDetector(Vse),this.addDetector(Gse),this.addDetector(qse),this.addDetector(Wse),this.addDetector(Kse),this.addDetector(Xse),this.addDetector($se)}addDetector(e){return this.detectors[e.name]=e,this}detect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,n=[];return e.forEach(r=>{if(this.detectors[r]){let i=this.detectors[r].lookup(this.options);i&&typeof i=="string"&&(i=[i]),i&&(n=n.concat(i))}}),n=n.filter(r=>r!=null&&!Use(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)}))}}Iq.type="languageDetector";const Qse={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}}",updateAvailableBanner:"Version {{version}} is available!",viewUpdate:"View update",viewOnGithub:"View on GitHub",keyboardShortcuts:"Keyboard shortcuts (?)",switchToLight:"Switch to light mode",switchToDark:"Switch to dark mode",smartSwitches:"Smart Switches",logout:"Logout"},common:{save:"Save",saving:"Saving...",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",days:"days",enable:"Enable",disable:"Disable",permissions:"Permissions",noPrinters:"No printers configured",noData:"No data available",linkNotFound:"Link not found",required:"Required",optional:"Optional",dismiss:"Dismiss",apply:"Apply",reset:"Reset",clear:"Clear",selectAll:"Select All",deselectAll:"Deselect All",noChange:"— No change —",unchanged:"Unchanged",unassigned:"Unassigned",unknown:"Unknown",unknownError:"Unknown error",today:"Today",asap:"ASAP",overdue:"Overdue",now:"Now",collapse:"Collapse",expand:"Expand",viewArchive:"View archive",viewInFileManager:"View in File Manager",addedBy:"Added by {{username}}",prints:"prints",more:"+{{count}} more",ascending:"Ascending",descending:"Descending",printer:"Printer",remove:"Remove",type:"Type",print:"Print",rename:"Rename",move:"Move",create:"Create",duplicate:"Duplicate",left:"Left",right:"Right"},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",sort:{name:"Name",status:"Status",model:"Model",location:"Location",ascending:"Sort ascending",descending:"Sort descending"},cardSize:{small:"Small cards",medium:"Medium cards",large:"Large cards",extraLarge:"Extra large cards"},hideOffline:"Hide offline",powerOn:"Power On",offlinePrintersWithPlugs:"Offline printers with smart plugs",noPrintersConfigured:"No printers configured yet",readyToPrint:"Ready to print",external:"External",deleteArchives:"Delete print archives",noLabel:"No label",printPreview:"Print preview",width:"Width",height:"Height",noObjectsFound:"No objects found",objectsLoadedOnPrintStart:"Objects are loaded when a print starts",willBeSkipped:"Will be skipped",name:"Name",serialCannotBeChanged:"Serial number cannot be changed",locationHelp:"Used to group printers and filter queue jobs",wifiSignal:{veryWeak:"Very weak",weak:"Weak",fair:"Fair",good:"Good",excellent:"Excellent"},maintenanceUpToDate:"All maintenance up to date - Click to view",chamberLightOn:"Turn on chamber light",chamberLightOff:"Turn off chamber light",browseFiles:"Browse printer files",autoOffAfterPrint:"Auto power-off after print",autoOffExecuted:"Auto-off was executed - turn printer on to reset",hmsErrors:"HMS Errors",viewHmsErrors:"View {{count}} HMS error(s)",resume:"Resume",pause:"Pause",stop:"Stop",camera:"Camera",skipObject:"Skip Object",reconnect:"Reconnect",mqttDebug:"MQTT Debug",activeNozzle:"Active: {{nozzle}} nozzle",firmwareUpdate:"Firmware Update",firmwareInstructions:"On the printer's touchscreen, go to",firmwareNav:"Navigate to",settings:"Settings",firmware:"Firmware",discoverPrinters:"Discover Printers",searching:"Searching...",manualEntry:"Manual Entry",addFromCloud:"Add from Cloud",toast:{printerDeleted:"Printer deleted",printerAdded:"Printer added",printerUpdated:"Printer updated",failedToDelete:"Failed to delete printer",failedToAdd:"Failed to add printer",failedToUpdate:"Failed to update printer",commandSent:"Command sent",failedToSendCommand:"Failed to send command",turnedOn:"{{name}} turned on",failedToPowerOn:"Failed to power on {{name}}",scriptTriggered:"Script triggered",printStopped:"Print stopped",printPaused:"Print paused",printResumed:"Print resumed",referenceDeleted:"Reference deleted",detectionAreaSaved:"Detection area saved",failedToRunScript:"Failed to run script",failedToStopPrint:"Failed to stop print",failedToPausePrint:"Failed to pause print",failedToResumePrint:"Failed to resume print",failedToControlChamberLight:"Failed to control chamber light",failedToUpdateSetting:"Failed to update setting",failedToSkipObjects:"Failed to skip objects",failedToRereadRfid:"Failed to re-read RFID",failedToCheckPlate:"Failed to check plate",failedToUpdateLabel:"Failed to update label",failedToDeleteReference:"Failed to delete reference",failedToSaveDetectionArea:"Failed to save detection area",plateCheckEnabled:"Plate check enabled",plateCheckDisabled:"Plate check disabled",calibrationSaved:"Calibration saved!",calibrationFailed:"Calibration failed",rfidRereadInitiated:"RFID re-read initiated"},connection:{connected:"Connected",offline:"Offline"},queue:{inQueue:"{{count}} print in queue",inQueue_plural:"{{count}} prints in queue"},controls:"Controls",rfid:{reread:"Re-read RFID"},permission:{noAdd:"You do not have permission to add printers",noEdit:"You do not have permission to edit printers",noDelete:"You do not have permission to delete printers",noControl:"You do not have permission to control printers",noFiles:"You do not have permission to access printer files",noAmsRfid:"You do not have permission to re-read AMS RFID",noSmartPlugControl:"You do not have permission to control smart plugs"},modal:{addTitle:"Add Printer",editTitle:"Edit Printer",myPrinter:"My Printer",selectModel:"Select model...",locationGroup:"Location / Group (optional)",locationPlaceholder:"e.g., Workshop, Office, Basement",autoArchiveLabel:"Auto-archive completed prints",fromPrinterSettings:"From printer settings",modelOptional:"Model (optional)",saveChanges:"Save Changes"},skipObjects:{tooltip:"Skip objects",onlyWhilePrinting:"Skip objects (only while printing)",requiresMultiple:"Skip objects (requires 2+ objects)",title:"Skip Objects",matchIdsInfo:"Match IDs with your printer display",printerShowsIds:"The printer screen shows object IDs on the build plate",skipSelected:"Skip Selected",skipping:"Skipping...",noObjectsSelected:"No objects selected",selectObjectsToSkip:"Select objects you want to skip from the current print",skipped:"skipped",objectsSkipped:"Objects skipped",activeCount:"{{count}} active",waitForLayer:"Wait for layer 2+ to skip objects (currently layer {{layer}})",skip:"Skip"},confirm:{deleteTitle:"Delete Printer",deleteMessage:'Are you sure you want to delete "{{name}}"? This will remove all connection settings.',deleteArchivesNote:"All print history for this printer will be permanently deleted.",keepArchivesNote:"Print history will be kept but no longer associated with this printer.",stopTitle:"Stop Print",stopMessage:'Are you sure you want to stop the current print on "{{name}}"? This will cancel the print job.',stopButton:"Stop Print",pauseTitle:"Pause Print",pauseMessage:'Are you sure you want to pause the current print on "{{name}}"?',pauseButton:"Pause Print",resumeTitle:"Resume Print",resumeMessage:'Are you sure you want to resume the print on "{{name}}"?',resumeButton:"Resume Print",powerOnTitle:"Power On Printer",powerOnMessage:'Are you sure you want to turn ON the power for "{{name}}"?',powerOnButton:"Power On",powerOffTitle:"Power Off Printer",powerOffMessage:'Are you sure you want to turn OFF the power for "{{name}}"?',powerOffWarning:'WARNING: "{{name}}" is currently printing! Are you sure you want to turn OFF the power? This will interrupt the print and may damage the printer.',powerOffButton:"Power Off"},discovery:{title:"Discover Printers",searching:"Searching...",scanning:"Scanning...",scanProgress:"Scanning... {{scanned}}/{{total}}",foundPrinters:"Found {{count}} printer(s)",noPrintersFound:"No printers found",noPrintersFoundSubnet:"No printers found in the specified subnet.",noPrintersFoundNetwork:"No printers found on the network.",allConfigured:"All discovered printers are already configured.",alreadyAdded:"Already added",select:"Select",manualEntry:"Manual Entry",addFromCloud:"Add from Cloud",subnetToScan:"Subnet to scan",dockerNote:"Docker detected. Enter your printer's subnet in CIDR notation. Requires network_mode: host in docker-compose.yml.",scanSubnet:"Scan Subnet for Printers",discoverNetwork:"Discover Printers on Network",scanningSubnet:"Scanning subnet for Bambu printers...",scanningNetwork:"Scanning network...",serialRequired:"Serial required",unknown:"Unknown",failedToStart:"Failed to start discovery"},filaments:"Filaments",openCameraOverlay:"Open camera overlay",openCameraWindow:"Open camera in new window",firmwareUpdateAvailable:"Firmware update available: {{current}} → {{latest}}",firmwareUpdateButton:"Update",plateDetection:{noPermission:"You do not have permission to update printers",enabledClick:"Plate check enabled - Click to disable",disabledClick:"Plate check disabled - Click to enable",manageCalibration:"Manage plate detection calibration",calibrationRequired:"Calibration Required",calibrationInstructions:"Please ensure the build plate is <strong>completely empty</strong>, then click Calibrate.",calibrationDescription:"Calibration captures a reference image of the empty plate. Future checks will compare against this reference to detect objects.",calibrationTip:"<strong>Tip:</strong> You can store up to 5 calibrations for different plates. The system automatically uses the best match when checking.",plateEmpty:"Plate appears empty",objectsDetected:"Objects detected on plate",confidence:"Confidence",difference:"Difference",analysisPreview:"Analysis preview:",analysisLegend:"Green box = detection area, Red overlay = differences from calibration",savedReferences:"Saved References ({{count}}/{{max}})",deleteReference:"Delete reference",labelPlaceholder:"Label...",clickToEdit:"{{label}} - Click to edit",clickToAddLabel:"Click to add label"},fans:{partCooling:"Part Cooling Fan",auxiliary:"Auxiliary Fan",chamber:"Chamber Fan"},clickToViewHmsErrors:"Click to view HMS errors",estimatedCompletion:"Estimated completion time",slotOptions:"Slot options",firmwareModal:{title:"Firmware Update",currentVersion:"Current:",latestVersion:"Latest:",releaseNotes:"Release Notes",checkingPrereqs:"Checking prerequisites...",sdCardReady:"SD card ready. Click below to upload firmware.",uploadedSuccess:"Firmware uploaded to SD card!",applyInstructions:"To apply the update on your printer:",step1:"On the printer's touchscreen, go to <strong>Settings</strong>",step2:"Navigate to <strong>Firmware</strong>",step3:"Select <strong>Update from SD card</strong>",step4:"The update will take 10-20 minutes",done:"Done",starting:"Starting...",uploadFirmware:"Upload Firmware",uploadedToast:"Firmware uploaded! Trigger update from printer screen."},accessCodePlaceholder:"Leave empty to keep current",roi:{title:"Detection Area (ROI)",xStart:"X Start",yStart:"Y Start",width:"Width",height:"Height",instruction:"Adjust the detection area to focus on the build plate. The green box in the preview shows the current area."}},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",sortLargest:"Largest first",sortSmallest:"Smallest first",sortSize:"Size",noArchives:"No archives found",noArchivesSearch:"No archives match your search",noArchivesYet:"No archives yet",loadingArchives:"Loading archives...",releaseToUpload:"Release to upload",showAll:"Show all",showFavoritesOnly:"Show favorites only",gridView:"Grid view",listView:"List view",calendarView:"Calendar view",manageTags:"Manage Tags",showFailedPrints:"Show failed prints",hideFailedPrints:"Hide failed prints",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"},toast:{source3mfAttached:"Source 3MF attached: {{filename}}",failedUploadSource3mf:"Failed to upload source 3MF",source3mfRemoved:"Source 3MF removed",failedRemoveSource3mf:"Failed to remove source 3MF",f3dAttached:"F3D attached: {{filename}}",failedUploadF3d:"Failed to upload F3D",f3dRemoved:"F3D removed",failedRemoveF3d:"Failed to remove F3D",timelapseAttached:"Timelapse attached: {{filename}}",timelapseAlreadyAttached:"Timelapse already attached",noMatchingTimelapse:"No matching timelapse found",failedScanTimelapse:"Failed to scan for timelapse",failedAttachTimelapse:"Failed to attach timelapse",archiveDeleted:"Archive deleted",failedDeleteArchive:"Failed to delete archive",addedToFavorites:"Added to favorites",removedFromFavorites:"Removed from favorites",projectUpdated:"Project updated",failedUpdateProject:"Failed to update project",linkCopied:"Link copied to clipboard",failedCopyLink:"Failed to copy link",photoDeleted:"Photo deleted",failedDeletePhoto:"Failed to delete photo",failedDeleteArchives:"Failed to delete archives",failedUpdateFavorites:"Failed to update favorites",exportDownloaded:"Export downloaded",exportFailed:"Export failed"},menu:{print:"Print",schedule:"Schedule",openInBambuStudio:"Open in Bambu Studio",slice:"Slice",externalLink:"External Link",viewOnMakerWorld:"View on MakerWorld",preview3d:"3D Preview",viewTimelapse:"View Timelapse",scanForTimelapse:"Scan for Timelapse",downloadSource3mf:"Download Source 3MF",uploadSource3mf:"Upload Source 3MF",replaceSource3mf:"Replace Source 3MF",removeSource3mf:"Remove Source 3MF",uploadF3d:"Upload F3D",replaceF3d:"Replace F3D",downloadF3d:"Download F3D",removeF3d:"Remove F3D",download:"Download",copyDownloadLink:"Copy Download Link",qrCode:"QR Code",viewPhotos:"View Photos",viewPhotosCount:"View Photos ({{count}})",projectPage:"Project Page",addToFavorites:"Add to Favorites",removeFromFavorites:"Remove from Favorites",edit:"Edit",goToProject:"Go to Project: {{name}}",addToProject:"Add to Project",removeFromProject:"Remove from Project",loading:"Loading...",noProjectsAvailable:"No projects available",select:"Select",deselect:"Deselect",delete:"Delete"},permission:{noReprint:"You do not have permission to reprint this archive",noAddToQueue:"You do not have permission to add to queue",noUpdateArchives:"You do not have permission to update archives",noUploadFiles:"You do not have permission to upload files",noDownload:"You do not have permission to download archives",noCopyLink:"You do not have permission to copy download links",noDelete:"You do not have permission to delete this archive",noCreate:"You do not have permission to create archives"},card:{previousPlate:"Previous plate",nextPlate:"Next plate",plateNumber:"Plate {{index}}",moreOptions:"Right-click for more options",addToFavorites:"Add to favorites",removeFromFavorites:"Remove from favorites",cancelled:"cancelled",failed:"failed",duplicate:"duplicate",duplicateTitle:"This model has been printed before",openSource3mf:"Open source 3MF in Bambu Studio (right-click for more options)",downloadF3d:"Download Fusion 360 design file",viewTimelapse:"View timelapse",viewPhoto:"View 1 photo",viewPhotos:"View {{count}} photos",openFolder:"Open folder: {{name}}",slicedFile:"Sliced file - ready to print",sourceFile:"Source file only - no AMS mapping available",gcode:"GCODE",source:"SOURCE",project:"Project: {{name}}",estimated:"Estimated: {{time}}",actual:"Actual: {{time}}",accuracy:"Accuracy: {{percent}}%",filament:"{{weight}}g",layer:"{{count}} layer",layers:"{{count}} layers",object:"{{count}} object",objects:"{{count}} objects",slicedFor:"Sliced for {{model}}",uploadedBy:"Uploaded by {{name}}",noPermissionReprint:"You do not have permission to reprint",noPermissionEdit:"You do not have permission to edit archives",noPermissionDelete:"You do not have permission to delete archives",reprint:"Reprint",schedulePrint:"Schedule Print",schedule:"Schedule",openInBambuStudio:"Open in Bambu Studio",openInBambuStudioToSlice:"Open in Bambu Studio to slice",slice:"Slice",externalLink:"External Link",makerWorld:"MakerWorld: {{designer}}",viewProject:"View project",noExternalLink:"No external link",preview3d:"3D Preview",download:"Download",edit:"Edit",delete:"Delete"},modal:{deleteArchive:"Delete Archive",deleteConfirm:'Are you sure you want to delete "{{name}}"? This action cannot be undone.',deleteButton:"Delete",removeSource3mf:"Remove Source 3MF",removeSource3mfConfirm:'Are you sure you want to remove the source 3MF file from "{{name}}"? This will delete the original slicer project file.',removeButton:"Remove",removeF3d:"Remove F3D",removeF3dConfirm:'Are you sure you want to remove the Fusion 360 design file from "{{name}}"?',timelapse:"{{name}} - Timelapse",selectTimelapse:"Select Timelapse",selectTimelapseDesc:"No auto-match found. Select the timelapse for this print:",deleteArchives:"Delete Archives",deleteArchivesConfirm:"Are you sure you want to delete {{count}} archive(s)? This action cannot be undone.",deleteCount:"Delete {{count}}"},page:{title:"Archives",printsCount:"{{filtered}} of {{total}} prints",dropFilesHere:"Drop .3mf files here",releaseToUpload:"Release to upload",only3mfSupported:"Only .3mf files are supported",close:"Close",selected:"{{count}} selected",selectAll:"Select All",tags:"Tags",project:"Project",favorite:"Favorite",delete:"Delete",toggledFavorites:"Toggled favorites for {{count}} archive(s)",failedUpdateFavorites:"Failed to update favorites",archivesDeleted:"{{count}} archive(s) deleted",failedDeleteArchives:"Failed to delete archives",photoDeleted:"Photo deleted",failedDeletePhoto:"Failed to delete photo"},list:{name:"Name",printer:"Printer",date:"Date",size:"Size",actions:"Actions",hasTimelapse:"Has timelapse"}},queue:{title:"Print Queue",subtitle:"Schedule and manage your print jobs",addToQueue:"Add to Queue",print:"Print",reprint:"Re-print",schedulePrint:"Schedule Print",editQueueItem:"Edit Queue Item",printToPrinters:"Print to {{count}} Printers",queueToPrinters:"Queue to {{count}} Printers",sending:"Sending...",sendingProgress:"Sending {{current}}/{{total}}...",adding:"Adding...",addingProgress:"Adding {{current}}/{{total}}...",savingProgress:"Saving {{current}}/{{total}}...",clearQueue:"Clear Queue",clearHistory:"Clear History",emptyQueue:"Queue is empty",position:"Position",scheduledTime:"Scheduled Time",moveUp:"Move Up",moveDown:"Move Down",startNow:"Start Now",printingInProgress:"Printing in progress...",viewArchive:"View archive",viewInFileManager:"View in File Manager",itemCount:"{{count}} item",itemCount_plural:"{{count}} items",dragToReorder:"Drag to reorder (ASAP only)",reorderHint:"Position only affects ASAP items. Scheduled items run at their set time.",addedBy:"Added by {{name}}",sections:{currentlyPrinting:"Currently Printing",queued:"Queued",history:"History"},status:{pending:"Pending",waiting:"Waiting",printing:"Printing",completed:"Completed",failed:"Failed",skipped:"Skipped",cancelled:"Cancelled"},summary:{printing:"Printing",queued:"Queued",totalTime:"Total Queue Time",history:"History"},filter:{allPrinters:"All Printers",unassigned:"Unassigned",allStatus:"All Status",allLocations:"All Locations",any:"Any"},sort:{byPosition:"Sort by Position",byName:"Sort by Name",byPrinter:"Sort by Printer",bySchedule:"Sort by Schedule",byDate:"Sort by Date",ascendingOldest:"Ascending (oldest first)",descendingNewest:"Descending (newest first)"},badges:{staged:"Staged",requiresPrevious:"Requires previous success",autoPowerOff:"Auto power off"},empty:{title:"No prints scheduled",description:'Schedule a print from the Archives page using the "Schedule" option in the context menu, or drag and drop files to get started.'},time:{asap:"ASAP",overdue:"Overdue",now:"Now",lessThanMinute:"In less than a minute",inMinutes:"In {{count}} min",inHours:"In {{count}} hours"},actions:{stopPrint:"Stop Print",startPrint:"Start Print",requeue:"Re-queue"},bulkEdit:{title:"Edit {{count}} Item",title_plural:"Edit {{count}} Items",description:"Only changed settings will be applied to selected items.",printer:"Printer",noChange:"— No change —",queueOptions:"Queue Options",staged:"Staged (manual start)",autoPowerOff:"Auto power off after print",requirePrevious:"Require previous success",printOptions:"Print Options",bedLevelling:"Bed levelling",flowCalibration:"Flow calibration",vibrationCalibration:"Vibration calibration",layerInspection:"First layer inspection",timelapse:"Timelapse",useAms:"Use AMS",applyChanges:"Apply Changes",selectAll:"Select All",deselectAll:"Deselect All",selected:"{{count}} selected",editSelected:"Edit Selected",cancelSelected:"Cancel Selected"},confirm:{cancelTitle:"Cancel Scheduled Print",cancelMessage:'Are you sure you want to cancel "{{name}}"?',stopTitle:"Stop Print",stopMessage:'Are you sure you want to stop the current print "{{name}}"? This will cancel the print job on the printer.',removeTitle:"Remove from History",removeMessage:'Are you sure you want to remove "{{name}}" from the queue history?',clearHistoryTitle:"Clear History",clearHistoryMessage:"Are you sure you want to remove all {{count}} item(s) from the history?",cancelButton:"Cancel Print",stopButton:"Stop Print",thisPrint:"this print",thisItem:"this item"},toast:{cancelled:"Queue item cancelled",cancelFailed:"Failed to cancel item",removed:"Queue item removed",removeFailed:"Failed to remove item",stopped:"Print stopped",stopFailed:"Failed to stop print",released:"Print released to queue",startFailed:"Failed to start print",reorderFailed:"Failed to reorder queue",historyCleared:"Cleared {{count}} history item(s)",clearHistoryFailed:"Failed to clear history",updateFailed:"Failed to update items",bulkCancelled:"Cancelled {{count}} item(s)",bulkCancelFailed:"Failed to cancel items"},permissions:{noStopPrint:"You do not have permission to stop prints",noStartPrint:"You do not have permission to start prints",noEdit:"You do not have permission to edit this queue item",noCancel:"You do not have permission to cancel this queue item",noRequeue:"You do not have permission to re-queue items",noRemove:"You do not have permission to remove this queue item",noClearHistory:"You do not have permission to clear all history",noEditItems:"You do not have permission to edit queue items",noCancelItems:"You do not have permission to cancel queue items"}},stats:{title:"Dashboard",subtitle:"Drag widgets to rearrange. Click the eye icon to hide.",overview:"Overview",totalPrints:"Total Prints",successRate:"Success Rate",totalPrintTime:"Total Print Time",printTime:"Print Time",totalFilament:"Total Filament Used",filamentUsed:"Filament Used",filamentCost:"Filament Cost",totalCost:"Total Cost",energyUsed:"Energy Used",energyCost:"Energy Cost",averagePrintTime:"Average Print Time",printsPerDay:"Prints per Day",byPrinter:"By Printer",printsByPrinter:"Prints by Printer",byMaterial:"By Material",byMonth:"By Month",last7Days:"Last 7 Days",last30Days:"Last 30 Days",last90Days:"Last 90 Days",allTime:"All Time",quickStats:"Quick Stats",printActivity:"Print Activity",filamentTypes:"Filament Types",filamentTrends:"Filament Trends",failureAnalysis:"Failure Analysis",timeAccuracy:"Time Accuracy",successful:"Successful:",failed:"Failed:",perfectEstimate:"100% = perfect estimate",noTimeAccuracyData:"No time accuracy data yet",noFilamentData:"No filament data available",noPrinterData:"No printer data available",noPrintData:"No print data available",noPrintDataLast30Days:"No print data in the last 30 days",failureReasons:"Failure Reasons",topFailureReasons:"Top Failure Reasons",failedPrintsCount:"{{failed}} / {{total}} prints failed",lastWeekRate:"Last week: {{rate}}%",resetLayout:"Reset Layout",recalculateCosts:"Recalculate Costs",recalculateCostsHint:"Recalculate all archive costs using current filament prices",exportStats:"Export Stats",exportAsCsv:"Export as CSV",exportAsExcel:"Export as Excel",hiddenCount:"{{count}} Hidden",exportDownloaded:"Export downloaded",exportFailed:"Export failed",layoutReset:"Layout reset",recalculatedCosts:"Recalculated costs for {{count}} archives",recalculateFailed:"Failed to recalculate costs",loadingStats:"Loading statistics...",noPermissionResetLayout:"You do not have permission to reset layout",noPermissionRecalculate:"You do not have permission to recalculate costs"},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",statusTab:"Status",settingsTab:"Settings",overdueCount:"{{count}} overdue",dueSoonCount:"{{count}} due soon",dueSoon:"Due soon",allGood:"All good",overdueBy:"Overdue by {{duration}}",dueIn:"Due in {{duration}}",timeLeft:"{{duration}} left",day:"1 day",days:"{{count}} days",week:"1 week",weeks:"{{count}} weeks",month:"1 month",months:"{{count}} months",year:"1 year",maintenanceTypes:"Maintenance Types",maintenanceTypesDescription:"System types and your custom maintenance tasks",addCustomType:"Add Custom Type",intervalType:"Interval Type",intervalValue:"Interval ({{type}})",icon:"Icon",documentationLink:"Documentation Link (optional)",assignToPrinters:"Assign to Printers",selectAtLeastOnePrinter:"Select at least one printer",addType:"Add Type",custom:"Custom",printHours:"Print Hours",calendarDays:"Calendar Days",exampleName:"e.g., Replace HEPA Filter",viewDocumentation:"View documentation",timeBasedInterval:"Time-based interval",intervalOverrides:"Interval Overrides",intervalOverridesDescription:"Customize intervals for specific printers",assignedToPrinters:"Assigned to printers:",noPrintersAssigned:"No printers assigned",addPrinterShort:"Add:",printersAssignedClick:"{{count}} printer(s) assigned - click to manage",removeFromPrinter:"Remove from this printer",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",cleanCarbonRods:"Clean Carbon Rods",checkPtfeTube:"Check PTFE Tube",replaceHepaFilter:"Replace HEPA Filter",replaceCarbonFilter:"Replace Carbon Filter",lubricateLeftNozzleRail:"Lubricate Left Nozzle Rail"},maintenanceComplete:"Maintenance marked as complete",typeUpdated:"Maintenance type updated",typeDeleted:"Maintenance type deleted",printHoursUpdated:"Print hours updated",printerAssigned:"Printer assigned",printerRemoved:"Printer removed",deleteTypeConfirm:'Delete "{{name}}"?',noPermissionUpdate:"You do not have permission to update maintenance items",noPermissionPerform:"You do not have permission to perform maintenance",noPermissionEditTypes:"You do not have permission to edit maintenance types",noPermissionDeleteTypes:"You do not have permission to delete maintenance types",noPermissionEditHours:"You do not have permission to edit print hours",noPermissionRemovePrinter:"You do not have permission to remove printer assignments",noPermissionAssignPrinter:"You do not have permission to assign printers",noPermissionEditIntervals:"You do not have permission to edit intervals",configureSettings:"Configure maintenance types and intervals"},settings:{title:"Settings",general:"General",tabs:{general:"General",smartPlugs:"Smart Plugs",notifications:"Notifications",filament:"Filament",network:"Network",apiKeys:"API Keys",virtualPrinter:"Virtual Printer",users:"Users",backup:"Backup"},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",noDefaultPrinter:"No default (ask each time)",sidebarOrder:"Sidebar order",saveThumbnails:"Save thumbnails",captureFinishPhoto:"Capture finish photo",noPrintersConfigured:"No printers configured",archiveMode:{always:"Always create archive entry",never:"Never create archive entry",ask:"Ask each time"},checkForUpdatesLabel:"Check for updates",checkPrinterFirmware:"Check printer firmware",enableRetry:"Enable retry",homeAssistantDescription:"Control smart plugs via Home Assistant",mqttConnectedTo:"Connected to",prometheusDescription:"Expose printer data in Prometheus format",noSmartPlugsTitle:"No smart plugs configured",noSmartPlugsDescription:"Add a Tasmota-based smart plug to track energy usage and automate power control.",noProvidersTitle:"No providers configured",noProvidersDescription:"Add a provider to receive alerts.",noTemplatesAvailable:"No templates available. Restart the backend to seed default templates.",apiPermissionView:"View printer status and queue",apiPermissionEdit:"Add and remove items from print queue",apiKeysEmptyTitle:"No API keys",apiKeysEmptyDescription:"Create an API key to integrate with external services.",noUsersFound:"No users found",noGroupsFound:"No groups found",noGroupsAvailable:"No groups available",passwordsDoNotMatch:"Passwords do not match",systemGroupWarning:"System group names cannot be changed",authDisabledTitle:"Authentication is Disabled",authDisabledFeature1:"Require login to access the system",authDisabledFeature2:"Create multiple users with group-based permissions",authDisabledFeature3:"Control access with 50+ granular permissions",userHasCreated:"This user has created:",userItemsQuestion:"What would you like to do with these items?",deleteUserConfirm:"Are you sure you want to delete this user?",actionCannotBeUndone:"This action cannot be undone.",addFirstSmartPlug:"Add Your First Smart Plug",providers:"Providers",log:"Log",testAll:"Test All",testResults:"Test Results",testPassedCount:"{{count}} passed",testFailedCount:"{{count}} failed",messageTemplates:"Message Templates",messageTemplatesDescription:"Customize notification messages for each event.",apiKeys:"API Keys",apiKeysDescription:"Create API keys for external integrations and webhooks.",createKey:"Create Key",apiKeyCreated:"API Key Created Successfully",apiKeyCopyWarning:"Copy this key now - it won't be shown again!",useInApiBrowser:"Use in API Browser",createNewApiKey:"Create New API Key",keyName:"Key Name",keyNamePlaceholder:"e.g., Home Assistant, OctoPrint",readStatus:"Read Status",readStatusDescription:"View printer status and queue",manageQueue:"Manage Queue",manageQueueDescription:"Add and remove items from print queue",controlPrinter:"Control Printer",controlPrinterDescription:"Pause, resume, and stop prints",unnamedKey:"Unnamed Key",lastUsed:"Last used",read:"Read",control:"Control",createFirstKey:"Create Your First Key",webhookEndpoints:"Webhook Endpoints",webhookApiKeyHint:"Use your API key in the X-API-Key header.",webhook:{getAllStatus:"Get all printer status",getSpecificStatus:"Get specific printer status",addToQueue:"Add to print queue",pausePrint:"Pause print",resumePrint:"Resume print",stopPrint:"Stop print"},apiBrowser:"API Browser",apiBrowserDescription:"Explore and test all available API endpoints.",apiKeyForTesting:"API Key for Testing",apiKeyPlaceholder:"Paste your API key here to test authenticated endpoints...",apiKeyHint:"This key will be sent as X-API-Key header with requests.",deleteApiKeyTitle:"Delete API Key",deleteApiKeyMessage:"Are you sure you want to delete this API key? Any integrations using this key will stop working.",deleteKey:"Delete Key",amsDisplayThresholds:"AMS Display Thresholds",amsThresholdsDescription:"Configure color thresholds for AMS humidity and temperature indicators.",humidity:"Humidity",goodGreen:"Good (green)",fairOrange:"Fair (orange)",aboveFairBad:"Above fair threshold shows as red (bad)",temperature:"Temperature",goodBlue:"Good (blue)",aboveFairHot:"Above fair threshold shows as red (hot)",historyRetention:"History Retention",keepSensorHistory:"Keep sensor history for",historyRetentionDescription:"Older humidity and temperature data will be automatically deleted",printModal:"Print Modal",expandCustomMapping:"Expand custom mapping by default",expandCustomMappingDescription:"When printing to multiple printers, show per-printer AMS mapping expanded",authentication:"Authentication",authEnabledDescription:"Your instance is secured with user authentication",authDisabledDescription:"Enable to require login and manage user access",authDisabledMessage:"Enable authentication to create user accounts, manage permissions, and secure your Bambuddy instance.",enableAuthentication:"Enable Authentication",currentUser:"Current User",changePassword:"Change Password",admin:"Admin",users:"Users",addUser:"Add User",groups:"Groups",addGroup:"Add Group",system:"System",noDescription:"No description",userCount:"{{count}} users",permissionCount:"{{count}} permissions",createUser:"Create User",username:"Username",enterUsername:"Enter username",password:"Password",enterPassword:"Enter password (min 6 characters)",confirmPassword:"Confirm Password",confirmPasswordPlaceholder:"Confirm password",viewReleaseOnGitHub:"View release on GitHub",turnAllPlugsOn:"Turn all plugs on",turnAllPlugsOff:"Turn all plugs off",clearNotificationLogs:"Clear Notification Logs",clearLogsMessage:"This will permanently delete all notification logs older than 30 days. This action cannot be undone.",clearLogs:"Clear Logs",resetUiPreferences:"Reset UI Preferences",resetUiPreferencesMessage:"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.",resetPreferences:"Reset Preferences",deleteGroupTitle:"Delete Group",deleteGroupMessage:"Are you sure you want to delete this group? Users in this group will lose these permissions.",deleteGroup:"Delete Group",disableAuthenticationTitle:"Disable Authentication",disableAuthenticationMessage:"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.",disableAuthentication:"Disable Authentication",configureBambuddy:"Configure Bambuddy",systemDefault:"System Default",archiveSettings:"Archive Settings",newWindow:"New Window",embeddedOverlay:"Embedded Overlay",externalCameras:"External Cameras",costTracking:"Cost Tracking",printsOnly:"Prints Only",totalConsumption:"Total Consumption",dataManagement:"Data Management",clearNotificationLogsDescription:"Delete notification logs older than 30 days",resetUiPreferencesDescription:"Reset sidebar order, theme, view modes, and layout preferences. Printers, archives, and settings are not affected.",enableHomeAssistant:"Enable Home Assistant",enableMqtt:"Enable MQTT",useTls:"Use TLS",enableMetricsEndpoint:"Enable Metrics Endpoint",availableMetrics:"Available Metrics",editUser:"Edit User",deleteUserTitle:"Delete User",groupName:"Group Name",leaveEmptyForAnonymous:"Leave empty for anonymous",leaveEmptyForNoAuth:"Leave empty for no authentication",enterNewPassword:"Enter new password",confirmNewPassword:"Confirm new password",enterGroupName:"Enter group name",enterDescriptionOptional:"Enter description (optional)",enterCurrentPassword:"Enter current password",enterNewPasswordMin6:"Enter new password (min 6 characters)",toast:{keyCopied:"Key copied to clipboard",copyFailed:"Failed to copy key",keyAddedToBrowser:"Key added to API Browser",clearLogsFailed:"Failed to clear logs",uiPreferencesReset:"UI preferences reset. Refreshing...",authDisabled:"Authentication disabled successfully",authDisableFailed:"Failed to disable authentication",apiKeyCreated:"API key created",apiKeyDeleted:"API key deleted",userCreated:"User created successfully",userUpdated:"User updated successfully",userDeleted:"User deleted successfully",groupCreated:"Group created successfully",groupUpdated:"Group updated successfully",groupDeleted:"Group deleted successfully",fillRequiredFields:"Please fill in all required fields",passwordsDoNotMatch:"Passwords do not match",passwordTooShort:"Password must be at least 6 characters",enterGroupName:"Please enter a group name",settingsSaved:"Settings saved",cameraSettingsSaved:"Camera settings saved",enterCameraUrl:"Please enter a camera URL",passwordChanged:"Password changed successfully",connectionFailed:"Connection failed",testFailed:"Test failed",cameraConnected:"Camera connected{{resolution}}"},testConnection:"Test Connection"},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"},hmsErrors:{title:"Errors - {{name}}",noErrors:"No errors",viewOnWiki:"View on Bambu Lab Wiki",clearInstructions:"Clear errors on the printer to dismiss them here."},mqttDebug:{title:"MQTT Debug Log",searchPlaceholder:"Search topic or payload...",noMessages:"No messages logged yet",startLoggingHint:'Click "Start Logging" to begin capturing MQTT messages',noMessagesMatch:"No messages match your filter",adjustFilterHint:"Try adjusting your search or filter criteria",incoming:"Incoming",outgoing:"Outgoing",loggingStopped:"Logging stopped",loggingActive:"Logging active - messages will auto-refresh",startLogging:"Start Logging",stopLogging:"Stop Logging",clearLog:"Clear Log",topic:"Topic",timestamp:"Timestamp",direction:"Direction",all:"All"},printerFiles:{title:"File Manager",storageUsed:"Used:",storageFree:"Free:",filterPlaceholder:"Filter files...",deleteButton:"Delete",deleteFiles:"Delete {{count}} Files",deleteFileConfirm:'Delete "{{name}}"? This cannot be undone.',deleteFilesConfirm:"Delete {{count}} selected files? This cannot be undone.",noFiles:"No files on printer",loadingFiles:"Loading files...",failedToLoad:"Failed to load files",toast:{filesDeleted:"Deleted {{count}} file(s)",deleteFailed:"Delete failed: {{error}}"}},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?"},login:{title:"Bambuddy Login",subtitle:"Sign in to your account",username:"Username",usernamePlaceholder:"Enter your username",password:"Password",passwordPlaceholder:"Enter your password",signIn:"Sign in",signingIn:"Logging in...",forgotPassword:"Forgot your password?",loginSuccess:"Logged in successfully",loginFailed:"Login failed",enterCredentials:"Please enter username and password",forgotPasswordTitle:"Forgot Password",forgotPasswordMessage:"If you've forgotten your password, please contact your system administrator to reset it.",howToReset:"How to reset your password:",resetStep1:"Contact your Bambuddy administrator",resetStep2:"Ask them to reset your password in User Management",resetStep3:"They can set a new temporary password for you",resetStep4:"Log in with the new password and change it in Settings",gotIt:"Got it"},setup:{title:"Bambuddy Setup",subtitle:"Configure authentication for your Bambuddy instance",enableAuth:"Enable Authentication",adminAccount:"Admin Account",adminAccountDesc:"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.",adminUsername:"Admin Username",adminPassword:"Admin Password",optionalIfAdminExists:"(optional if admin users exist)",adminUsernamePlaceholder:"Enter admin username (optional)",adminPasswordPlaceholder:"Enter admin password (optional)",confirmPassword:"Confirm Password",confirmPasswordPlaceholder:"Confirm admin password",settingUp:"Setting up...",completeSetup:"Complete Setup",toast:{authEnabledAdminCreated:"Authentication enabled and admin user created",authEnabledExistingAdmins:"Authentication enabled using existing admin users",setupCompleted:"Setup completed",enterBothCredentials:"Please enter both admin username and password, or leave both empty to use existing admin users",passwordsDoNotMatch:"Passwords do not match",passwordTooShort:"Password must be at least 6 characters"}},changePassword:{title:"Change Password",currentPassword:"Current Password",currentPasswordPlaceholder:"Enter current password",newPassword:"New Password",newPasswordPlaceholder:"Enter new password (min 6 characters)",confirmPassword:"Confirm New Password",confirmPasswordPlaceholder:"Confirm new password",passwordsDoNotMatch:"Passwords do not match",passwordTooShort:"Password must be at least 6 characters",changing:"Changing...",success:"Password changed successfully",failed:"Failed to change password"},plateAlert:{title:"Print Paused!",message:"Objects detected on build plate. The print has been automatically paused. Please clear the plate and resume the print.",understand:"I Understand"},camera:{title:"Camera View",invalidPrinterId:"Invalid printer ID",live:"Live",snapshot:"Snapshot",restartStream:"Restart stream",refreshSnapshot:"Refresh snapshot",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",connectingToCamera:"Connecting to camera...",capturingSnapshot:"Capturing snapshot...",connectionLost:"Connection lost",connectionFailed:"Camera connection failed",reconnecting:"Reconnecting in {{countdown}}s... (attempt {{attempt}}/{{max}})",reconnectNow:"Reconnect now",cameraUnavailable:"Camera unavailable",cameraUnavailableDesc:"Make sure the printer is powered on and connected.",noCamera:"No camera available",retry:"Retry",cameraStream:"Camera stream",zoomOut:"Zoom out",zoomIn:"Zoom in",resetZoom:"Reset zoom",recording:"Recording",startRecording:"Start Recording",stopRecording:"Stop Recording"},groups:{title:"Group Management",subtitle:"Manage permission groups for access control",backToSettings:"Back to Settings",createGroup:"Create Group",noPermission:"You do not have permission to access this page.",system:"System",noDescription:"No description",usersCount:"{{count}} users",permissionsCount:"{{count}} permissions",edit:"Edit",delete:"Delete",toast:{created:"Group created successfully",updated:"Group updated successfully",deleted:"Group deleted successfully",enterGroupName:"Please enter a group name"},modal:{editGroup:"Edit Group",createGroup:"Create Group",cancel:"Cancel",saving:"Saving...",creating:"Creating...",saveChanges:"Save Changes"},form:{groupName:"Group Name",groupNamePlaceholder:"Enter group name",systemGroupWarning:"System group names cannot be changed",description:"Description",descriptionPlaceholder:"Enter description (optional)",permissions:"Permissions ({{count}} selected)"},deleteModal:{title:"Delete Group",message:"Are you sure you want to delete this group? Users in this group will lose these permissions.",confirm:"Delete Group"}},users:{title:"User Management",subtitle:"Manage users and their access to your Bambuddy instance",backToSettings:"Back to Settings",createUser:"Create User",noPermission:"You do not have permission to access this page.",admin:"Admin",noGroups:"No groups",active:"Active",inactive:"Inactive",edit:"Edit",delete:"Delete",system:"System",noGroupsAvailable:"No groups available",table:{username:"Username",groups:"Groups",status:"Status",actions:"Actions"},toast:{created:"User created successfully",updated:"User updated successfully",deleted:"User deleted successfully",fillRequired:"Please fill in all required fields",passwordsDoNotMatch:"Passwords do not match",passwordTooShort:"Password must be at least 6 characters"},modal:{createUser:"Create User",editUser:"Edit User",cancel:"Cancel",creating:"Creating...",saving:"Saving...",saveChanges:"Save Changes"},form:{username:"Username",usernamePlaceholder:"Enter username",password:"Password",passwordPlaceholder:"Enter password",confirmPassword:"Confirm Password",confirmPasswordPlaceholder:"Confirm password",newPasswordPlaceholder:"Enter new password",confirmNewPasswordPlaceholder:"Confirm new password",leaveBlankToKeep:"leave blank to keep current",groups:"Groups"},deleteModal:{title:"Delete User",message:"Are you sure you want to delete this user? This action cannot be undone.",confirm:"Delete User"}},streamOverlay:{title:"Stream Overlay",invalidPrinterId:"Invalid printer ID",cameraStream:"Camera stream",progress:"Progress",eta:"ETA",tomorrow:"Tomorrow",printerIdle:"Printer is idle",printerOffline:"Printer offline",status:{printing:"Printing",paused:"Paused",finished:"Finished",failed:"Failed",idle:"Idle",unknown:"Unknown"}},profiles:{title:"Profiles",subtitle:"Manage your slicer presets and pressure advance calibrations",tabs:{cloud:"Cloud Profiles",kprofiles:"K-Profiles"},connectedAs:"Connected as",logout:"Logout",noLogoutPermission:"You do not have permission to logout",failedToLoad:"Failed to load profiles",retry:"Retry",time:{justNow:"Just now",minsAgo:"{{count}}m ago",hoursAgo:"{{count}}h ago",daysAgo:"{{count}}d ago"},toast:{loggedOut:"Logged out"},login:{title:"Connect to Bambu Cloud",subtitle:"Sync your slicer presets across devices",email:"Email",password:"Password",region:"Region",regionGlobal:"Global",regionChina:"China",verificationCode:"Verification Code",totpCode:"Authenticator Code",checkEmail:"Check your email ({{email}}) for a 6-digit code",enterTotpHint:"Enter the 6-digit code from your authenticator app",accessToken:"Access Token",accessTokenHint:"Paste your Bambu Lab access token (from Bambu Studio)",back:"Back",loginButton:"Login",verifyButton:"Verify",setTokenButton:"Set Token",useToken:"Use access token instead",useEmail:"Login with email instead",toast:{loggedIn:"Logged in successfully",codeSent:"Verification code sent to your email",enterTotp:"Enter code from your authenticator app",tokenSet:"Token set successfully"}},presets:{myPreset:"My preset (editable)",duplicate:"Duplicate",editable:"Editable",failedToLoadDetails:"Failed to load preset details",deleteConfirm:"Delete this preset?",deleteWarning:'This will permanently delete "{{name}}" from Bambu Cloud. This cannot be undone.',noDuplicatePermission:"You do not have permission to duplicate presets",noEditPermission:"You do not have permission to edit presets",noDeletePermission:"You do not have permission to delete presets",types:{filament:"Filament preset",printer:"Printer preset",process:"Process preset"},toast:{deleted:"Preset deleted",created:"Preset created",updated:"Preset updated",duplicated:"Preset duplicated",fieldAdded:'Field "{{key}}" added',exported:"Preset exported"},baseLabel:"Base: {{name}}",currentLabel:"Current: {{name}}",newPreset:"New Preset",editPreset:"Edit Preset",duplicatePreset:"Duplicate Preset",createNewPreset:"Create New Preset",customizeSettings:"Customize settings for your new preset",compareWithBase:"Compare with base preset",compare:"Compare",basePreset:"Base Preset",selectBasePreset:"Select base preset...",presetName:"Preset Name",myCustomPreset:"My custom preset",inheritsFrom:"Inherits from",dropJsonToImport:"Drop JSON to import",tabs:{common:"Common",allFields:"All Fields"},availableFields:"Available Fields",searchFieldsPlaceholder:"Search fields...",noMatchingFields:"No matching fields",allFieldsAdded:"All fields added",addCustomField:"Add custom field",yourOverrides:"Your Overrides",noOverridesYet:"No overrides yet",clickFieldsToAdd:"Click fields on the left to add them",saveAsTemplate:"Save as template",jsonTip:"Tip: Drag & drop a .json file anywhere on this modal to import settings"},cloudView:{searchPlaceholder:"Search presets...",templates:"Templates",refresh:"Refresh",newPreset:"New Preset",clearFilters:"Clear filters",compareMode:"Compare Mode",selectAnotherPreset:"Select another {{type}} preset",clickTwoPresets:"Click two presets of the same type to compare",selectFirst:"1. Select first",selectSecond:"2. Select second",compareNow:"Compare Now",lastSynced:"Last synced:",showingCount:"Showing {{showing}} of {{total}} presets",noPresetsFound:"No presets found",columns:{filament:"Filament",process:"Process",printer:"Printer"},noFilamentPresets:"No filament presets",noProcessPresets:"No process presets",noPrinterPresets:"No printer presets",filters:{type:"Type",owner:"Owner",printer:"Printer",nozzle:"Nozzle",filament:"Filament",layer:"Layer",all:"All",myPresets:"My Presets",builtIn:"Built-in",process:"Process"},noTemplatesPermission:"You do not have permission to manage templates",noRefreshPermission:"You do not have permission to refresh profiles",noCreatePermission:"You do not have permission to create presets"},templates:{title:"Quick Templates",noTemplates:"No templates yet",createFirst:"Create templates from the preset editor",typeFilter:"Type:",deleteTitle:"Delete Template",deleteWarning:"This action cannot be undone",deleteConfirm:'Are you sure you want to delete "{{name}}"?',namePlaceholder:"Template name",descriptionPlaceholder:"Description",settingsJson:"Settings (JSON)",fieldsCount:"{{count}} fields",shownInModals:"Shown in modals",hiddenInModals:"Hidden in modals",apply:"Apply",toast:{deleted:"Template deleted",updated:"Template updated",created:"Template created",applied:"Template applied"}}},support:{debugLoggingActive:"Debug logging is active",manageLogs:"Manage"},fileManager:{title:"File Manager",subtitle:"Organize and manage your print files",uploadFiles:"Upload Files",newFolder:"New Folder",folderName:"Folder Name",folderNamePlaceholder:"e.g., Functional Parts",renameFile:"Rename File",renameFolder:"Rename Folder",moveFiles:"Move {{count}} File(s)",rootNoFolder:"Root (No Folder)",current:"current",linkFolder:"Link Folder",linkFolderDescription:'Link "{{name}}" to a project or archive for quick access.',project:"Project",archive:"Archive",noProjectsFound:"No projects found",noArchivesFound:"No archives found",unlink:"Unlink",link:"Link",dragDropFiles:"Drag & drop files here",dropFilesHere:"Drop files here",orClickToBrowse:"or click to browse",allFileTypesSupported:"All file types supported. ZIP files will be extracted.",zipFilesDetected:"ZIP files detected",zipExtractOptions:"ZIP files will be extracted. Choose how to handle folder structure:",preserveZipStructure:"Preserve folder structure from ZIP",createFolderFromZip:"Create folder from ZIP filename",stlThumbnailGeneration:"STL thumbnail generation",zipMayContainStl:"ZIP files may contain STL files. Thumbnails can be generated during extraction.",thumbnailsCanBeGenerated:"Thumbnails can be generated for STL files. Large models may take longer to process.",generateThumbnailsForStl:"Generate thumbnails for STL files",willBeExtracted:"Will be extracted",filesExtracted:"{{count}} files extracted",uploadComplete:"Upload complete: {{succeeded}} succeeded",uploadFailed:"{{count}} failed",uploading:"Uploading...",changeLink:"Change Link...",linkTo:"Link to...",linkToProjectOrArchive:"Link to project or archive",addToQueue:"Add to Queue",generateThumbnail:"Generate Thumbnail",generateThumbnails:"Generate Thumbnails",generateThumbnailsForMissing:"Generate thumbnails for STL files missing them",gridView:"Grid view",listView:"List view",lowDiskSpaceWarning:"Low disk space warning",lowDiskSpaceDetails:"Only {{free}} free of {{total}} total. Threshold is set to {{threshold}} GB in settings.",files:"Files",folders:"Folders",size:"Size",free:"Free",allFiles:"All Files",wrap:"Wrap",enableTextWrapping:"Enable text wrapping",disableTextWrapping:"Disable text wrapping",dragToResizeTooltip:"Drag to resize, double-click to reset",searchFiles:"Search files...",allTypes:"All types",prints:"Prints",ascending:"Ascending",descending:"Descending",resultsCount:"{{showing}} of {{total}} files",selectAll:"Select All",deselectAll:"Deselect All",selected:"{{count}} selected",adding:"Adding...",loadingFiles:"Loading files...",folderIsEmpty:"Folder is empty",noFilesYet:"No files yet",folderEmptyDescription:"Upload files or move files into this folder to get started.",noFilesDescription:"Upload files to start organizing your print-related files.",noMatchingFiles:"No matching files",noMatchingFilesDescription:"No files match your current search or filter criteria.",clearFilters:"Clear filters",printedCount:"Printed {{count}}x",uploadedBy:"Uploaded by {{name}}",deleteFolder:"Delete Folder",deleteFile:"Delete File",deleteFilesCount:"Delete {{count}} Files",deleteFolderConfirm:"Are you sure you want to delete this folder? All files inside will also be deleted.",deleteFileConfirm:"Are you sure you want to delete this file?",deleteFilesConfirm:"Are you sure you want to delete {{count}} selected files? This action cannot be undone.",deleting:"Deleting...",noPermissionRenameFolder:"You do not have permission to rename folders",noPermissionLinkFolder:"You do not have permission to link folders",noPermissionDeleteFolder:"You do not have permission to delete folders",noPermissionPrint:"You do not have permission to print",noPermissionAddToQueue:"You do not have permission to add to queue",noPermissionDownload:"You do not have permission to download files",noPermissionRenameFile:"You do not have permission to rename this file",noPermissionGenerateThumbnail:"You do not have permission to generate thumbnails",noPermissionDeleteFile:"You do not have permission to delete this file",noPermissionCreateFolder:"You do not have permission to create folders",noPermissionUpload:"You do not have permission to upload files",noPermissionMoveFiles:"You do not have permission to move files",noPermissionDeleteFiles:"You do not have permission to delete files",toast:{folderCreated:"Folder created",folderDeleted:"Folder deleted",fileDeleted:"File deleted",filesDeleted:"Deleted {{count}} files",filesMoved:"Files moved",folderLinked:"Folder linked",folderUnlinked:"Folder unlinked",addedToQueue:"Added {{count}} file(s) to queue",addedToQueuePartial:"Added {{added}} file(s), {{failed}} failed",failedToAddToQueue:"Failed to add files: {{error}}",fileRenamed:"File renamed",folderRenamed:"Folder renamed",thumbnailsGenerated:"Generated {{count}} thumbnail(s)",thumbnailsGeneratedPartial:"Generated {{succeeded}} thumbnail(s), {{failed}} failed",noStlMissingThumbnails:"No STL files missing thumbnails",failedToGenerateThumbnails:"Failed to generate thumbnails: {{error}}",thumbnailGenerated:"Thumbnail generated",failedToGenerateThumbnail:"Failed to generate thumbnail: {{error}}"}},projects:{title:"Projects",subtitle:"Organize and track your 3D printing projects",newProject:"New Project",editProject:"Edit Project",deleteProject:"Delete Project",projectName:"Project Name",description:"Description",noProjects:"No projects yet",noProjectsFiltered:"No {{status}} projects",noProjectsFilteredHelp:"You don't have any {{status}} projects. Projects will appear here when their status changes.",createFirst:"Create your first project to start organizing related prints, tracking progress, and managing your builds.",createFirstButton:"Create Your First Project",create:"Create",files:"Files",prints:"Prints",plates:"plates",parts:"parts",lastModified:"Last Modified",deleteConfirm:"Are you sure you want to delete this project? Archives and queue items will be unlinked but not deleted.",addFiles:"Add Files",removeFile:"Remove File",viewDetails:"View Details",namePlaceholder:"e.g., Voron 2.4 Build",descriptionPlaceholder:"Optional description...",color:"Color",targetPlates:"Target Plates",targetPlatesPlaceholder:"e.g., 25",targetPlatesHelp:"Number of print jobs",targetParts:"Target Parts",targetPartsPlaceholder:"e.g., 150",targetPartsHelp:"Total objects needed",tagsLabel:"Tags (comma-separated)",tagsPlaceholder:"e.g., voron, functional, gift",dueDate:"Due Date",priority:"Priority",priorityLow:"Low",priorityNormal:"Normal",priorityHigh:"High",priorityUrgent:"Urgent",statusActive:"Active",statusCompleted:"Completed",statusArchived:"Archived",done:"Done",completed:"completed",failed:"failed",inQueue:"in queue",noPrintsYet:"No prints yet",printJobs:"Print jobs (plates)",partsPrinted:"Parts printed",failedParts:"Failed parts",import:"Import",export:"Export",importProject:"Import project",exportAll:"Export all projects",loading:"Loading projects...",noEditPermission:"You do not have permission to edit projects",noDeletePermission:"You do not have permission to delete projects",noCreatePermission:"You do not have permission to create projects",noImportPermission:"You do not have permission to import projects",noExportPermission:"You do not have permission to export projects",toast:{created:"Project created",updated:"Project updated",deleted:"Project deleted",imported:"Project imported",multipleImported:"{{count}} projects imported",importFailed:"Import failed",exported:"Projects exported (metadata only)"}},projectDetail:{notFound:"Project not found",backToProjects:"Back to Projects",export:"Export",exportProject:"Export project",noExportPermission:"You do not have permission to export projects",noEditPermission:"You do not have permission to edit projects",partOf:"Part of:",priorityLabel:"Priority:",noPrints:"No prints in this project yet",status:{active:"Active",completed:"Completed",archived:"Archived"},priority:{low:"Low",normal:"Normal",high:"High",urgent:"Urgent"},dueDate:{overdue:"Overdue",today:"Due today",daysLeft:"{{count}} days left"},progress:{platesProgress:"Plates Progress",partsProgress:"Parts Progress",printJobs:"print jobs",parts:"parts",percentComplete:"{{percent}}% complete",remaining:"{{count}} remaining"},stats:{printJobs:"Print Jobs",total:"total",failed:"{{count}} failed",partsPrinted:"{{count}} parts printed",printTime:"Print Time",filamentUsed:"Filament Used"},cost:{title:"Cost Tracking",filamentCost:"Filament Cost",energy:"Energy",budget:"Budget",remaining:"Remaining"},subProjects:{title:"Sub-projects ({{count}})"},notes:{title:"Notes",noEditPermission:"You do not have permission to edit notes",placeholder:"Add notes about this project...",empty:"No notes yet. Click Edit to add notes."},files:{title:"Files",linkFolders:"Link folders from the File Manager",forQuickAccess:"to this project for quick access.",fileCount:"{{count}} file(s)",empty:"No folders linked. Go to File Manager and link a folder to this project."},bom:{title:"Bill of Materials",acquired:"{{completed}}/{{total}} acquired",showAll:"Show all",hideDone:"Hide done",addPart:"Add Part",noAddPermission:"You do not have permission to add parts",partNamePlaceholder:"Part name (e.g., M3x8 screws)",partName:"Part name",qty:"Qty",price:"Price ({{currency}})",sourcingUrlPlaceholder:"Sourcing URL (optional)",remarksPlaceholder:"Remarks (optional)",deletePart:"Delete Part",deleteConfirm:'Are you sure you want to delete "{{name}}"?',noUpdatePermission:"You do not have permission to update parts",noEditPermission:"You do not have permission to edit parts",noDeletePermission:"You do not have permission to delete parts",totalCost:"Total cost:",empty:"No parts in the bill of materials. Add hardware, electronics, or other components to track what needs to be sourced."},timeline:{title:"Activity Timeline",empty:"No activity yet."},template:{saveAsTemplate:"Save as Template",noCreatePermission:"You do not have permission to create templates"},queue:{title:"Queue",viewAll:"View all",printing:"{{count}} printing",queued:"{{count}} queued"},prints:{title:"Prints ({{count}})"},toast:{projectUpdated:"Project updated",partAdded:"Part added",partRemoved:"Part removed",exportFailed:"Export failed",projectExported:"Project exported",templateCreated:"Template created"}},system:{title:"System Information",version:"Version",uptime:"Uptime",cpuUsage:"CPU Usage",memoryUsage:"Memory Usage",diskUsage:"Disk Usage",networkInfo:"Network Info",logs:"Logs",debugMode:"Debug Mode",enableDebug:"Enable Debug Logging",disableDebug:"Disable Debug Logging",downloadLogs:"Download Logs",clearLogs:"Clear Logs",dockerInfo:"Docker Info",containerName:"Container Name",imageName:"Image Name",platform:"Platform",architecture:"Architecture"},library:{title:"Filament Library",addFilament:"Add Filament",editFilament:"Edit Filament",deleteFilament:"Delete Filament",vendor:"Vendor",material:"Material",color:"Color",kFactor:"K Factor",temperature:"Temperature",noFilaments:"No filaments in library",deleteConfirm:"Are you sure you want to delete this filament?",importFromPrinter:"Import from Printer",exportToFile:"Export to File"},spoolman:{title:"Spoolman Integration",enabled:"Spoolman Enabled",url:"Spoolman URL",connected:"Connected",disconnected:"Not Connected",testConnection:"Test Connection",sync:"Sync",syncing:"Syncing...",lastSync:"Last Sync",linkToSpoolman:"Link to Spoolman",openInSpoolman:"Open in Spoolman",unlinkSpool:"Unlink Spool",selectSpool:"Select Spool",noUnlinkedSpools:"No unlinked spools available",linkSuccess:"Spool linked to Spoolman successfully",linkFailed:"Failed to link spool",spoolId:"Spool ID",weight:"Weight",remaining:"Remaining"},timelapse:{title:"Timelapse",create:"Create Timelapse",download:"Download",delete:"Delete",preview:"Preview",frameRate:"Frame Rate",quality:"Quality",processing:"Processing...",noTimelapses:"No timelapses available"},ams:{title:"AMS",slot:"Slot",empty:"Empty",emptySlot:"Empty slot",unknown:"Unknown",humidity:"Humidity",temperature:"Temperature",filamentType:"Filament Type",filamentColor:"Color",remaining:"Remaining",history:"AMS History",noHistory:"No history available",configureSlot:"Configure Slot",externalSpool:"External Spool",profile:"Profile",kFactor:"K Factor",fill:"Fill",configure:"Configure"},printModal:{title:"Start Print",selectPrinter:"Select Printer",selectPlate:"Select Plate",filamentMapping:"Filament Mapping",printSettings:"Print Settings",bedLeveling:"Bed Leveling",flowCalibration:"Flow Calibration",vibrationCalibration:"Vibration Calibration",layerInspection:"First Layer Inspection",timelapse:"Timelapse",startPrint:"Start Print",addToQueue:"Add to Queue",cancel:"Cancel",noPrintersAvailable:"No printers available",printerBusy:"Printer is busy",printerOffline:"Printer is offline"},backup:{title:"Backup & Restore",createBackup:"Create Backup",restoreBackup:"Restore Backup",restoreDescription:"Replace all data from a backup file",downloadBackup:"Download Backup",uploadBackup:"Upload Backup",lastBackup:"Last Backup",autoBackup:"Auto Backup",backupNow:"Backup Now",restoreWarning:"Warning: Restoring a backup will overwrite all current data.",includeArchives:"Include Archives",includeSettings:"Include Settings",includeProfiles:"Include Profiles",backupSuccess:"Backup created successfully",restoreSuccess:"Backup restored successfully",backupFailed:"Backup failed",restoreFailed:"Restore failed",restoreNote:"Virtual Printer will be stopped during restore"},tags:{title:"Tags",addTag:"Add Tag",editTag:"Edit Tag",deleteTag:"Delete Tag",tagName:"Tag Name",tagColor:"Tag Color",noTags:"No tags",deleteConfirm:"Are you sure you want to delete this tag?",manageTags:"Manage Tags"},uploadModal:{title:"Upload 3MF Files",dragDrop:"Drag & drop .3mf files here",or:"or",browseFiles:"Browse Files",extractionInfo:"The printer model will be automatically extracted from the 3MF file metadata.",uploaded:"uploaded",failed:"failed",uploading:"Uploading...",upload:"Upload",uploadFailed:"Upload failed"},editArchive:{title:"Edit Archive",name:"Name",namePlaceholder:"Print name",printer:"Printer",noPrinter:"No printer",project:"Project",noProject:"No project",itemsPrinted:"Items Printed",itemsPrintedHelp:"Number of items produced in this print job",notes:"Notes",notesPlaceholder:"Add notes about this print...",externalLink:"External Link",externalLinkPlaceholder:"https://printables.com/model/...",externalLinkHelp:"Link to Printables, Thingiverse, or other source",tags:"Tags",tagsPlaceholder:"Add tags...",addMoreTags:"Add more tags...",matchingTags:'Matching "{{query}}"',existingTags:"Existing tags",clickToAdd:"(click to add)",status:"Status",failureReason:"Failure Reason",selectReason:"Select reason...",photos:"Photos of Printed Result",photosHelp:"Click + to add photos of your printed result",printResult:"Print result",saving:"Saving...",failureReasons:{adhesionFailure:"Adhesion failure",spaghettiDetached:"Spaghetti / Detached",layerShift:"Layer shift",cloggedNozzle:"Clogged nozzle",filamentRunout:"Filament runout",warping:"Warping",stringing:"Stringing",underExtrusion:"Under-extrusion",powerFailure:"Power failure",userCancelled:"User cancelled",other:"Other"},statuses:{completed:"Completed",failed:"Failed",aborted:"Cancelled",printing:"Printing"}},kProfiles:{title:"K-Profiles",noPrintersConfigured:"No Printers Configured",addPrinterInSettings:"Add a printer in Settings to manage K-profiles",noActivePrinters:"No Active Printers",enablePrinterConnection:"Enable a printer connection to view its K-profiles",loadingProfiles:"Loading K-Profiles...",printerOffline:"Printer Offline",printerOfflineDesc:"The selected printer is not connected. Power it on to view K-profiles.",noMatchingProfiles:"No Matching Profiles",noMatchingProfilesDesc:"No profiles match your search criteria",noKProfiles:"No K-Profiles",noKProfilesDesc:"No pressure advance profiles found for {{diameter}}mm nozzle",createFirstProfile:"Create First Profile",printer:"Printer",nozzle:"Nozzle",refresh:"Refresh",addProfile:"Add Profile",export:"Export",import:"Import",select:"Select",selectAll:"Select All",delete:"Delete",searchPlaceholder:"Search by name or filament...",allExtruders:"All Extruders",leftOnly:"Left Only",rightOnly:"Right Only",allFlow:"All Flow",hfOnly:"HF Only",sOnly:"S Only",sortName:"Sort: Name",sortKValue:"Sort: K-Value",sortFilament:"Sort: Filament",leftExtruder:"Left Extruder",rightExtruder:"Right Extruder",modal:{addTitle:"Add K-Profile",editTitle:"Edit K-Profile",profileName:"Profile Name",profileNamePlaceholder:"My PLA Profile",kValue:"K-Value",kValuePlaceholder:"0.020",kValueHelp:"Typical range: 0.01 - 0.06 for PLA, 0.02 - 0.10 for PETG",filament:"Filament",selectFilament:"Select filament...",noFilamentsHelp:"No filaments found. Create a K-profile in Bambu Studio first.",flowType:"Flow Type",highFlow:"High Flow",standard:"Standard",nozzleSize:"Nozzle Size",extruder:"Extruder",extruders:"Extruders",left:"Left",right:"Right",notes:"Notes (stored locally)",notesPlaceholder:"Add notes about this profile...",notesHelp:"Notes are saved in Bambuddy, not on the printer",syncing:"Syncing with printer...",savingExtruder:"Saving to extruder {{current}}/{{total}}...",pleaseWait:"Please wait"},deleteConfirm:{title:"Delete Profile",cannotUndo:"This cannot be undone",message:'Are you sure you want to delete "{{name}}" from the printer?'},bulkDelete:{title:"Delete Profiles",cannotUndo:"This cannot be undone",message:"Are you sure you want to delete {{count}} selected profiles from the printer?"},toast:{profileSaved:"K-profile saved",profilesSaved:"K-profile saved to {{count}} extruders",selectAtLeastOneExtruder:"Please select at least one extruder",profileDeleted:"K-profile deleted",profilesDeleted:"Deleted {{count}} profiles",exportedProfiles:"Exported {{count}} profiles",importedProfiles:"Imported {{count}} of {{total}} profiles",noProfilesToExport:"No profiles to export",invalidFileFormat:"Invalid file format",failedToParseImport:"Failed to parse import file",failedToSaveBatch:"Failed to save K-profiles",noteSaved:"Note saved",failedToSaveNote:"Failed to save note"},permission:{noRead:"You do not have permission to refresh profiles",noCreate:"You do not have permission to add profiles",noUpdate:"You do not have permission to update K-profiles",noDelete:"You do not have permission to delete K-profiles",noExport:"You do not have permission to export profiles",noImport:"You do not have permission to import profiles"}},virtualPrinter:{title:"Virtual Printer",running:"Running",stopped:"Stopped",description:{default:"Enable a virtual printer that appears in Bambu Studio and OrcaSlicer. Files sent to this printer will be archived directly without printing.",proxy:"Enable a proxy that relays slicer traffic to a real printer, allowing remote printing over any network."},enable:{title:"Enable Virtual Printer",visibleInSlicer:'Visible as "Bambuddy" in slicer discovery',proxyingTo:"Proxying to {{name}}",notActive:"Not active"},model:{title:"Printer Model",description:"Select which printer model to emulate.",restartWarning:"Changing the model will restart the virtual printer"},accessCode:{title:"Access Code",isSet:"Access code is set",notSet:"No access code set - required to enable",placeholder:"Enter 8-char code",placeholderChange:"Enter new code to change",hint:"Must be exactly 8 characters. Used by slicers to authenticate.",charCount:"({{count}}/8)"},targetPrinter:{title:"Target Printer",configured:"Proxy target configured",notConfigured:"No target printer selected - required for proxy mode",placeholder:"Select a printer...",hint:"Select the printer to proxy slicer traffic to. The printer must be in LAN mode.",noPrinters:"No printers configured. Add a printer first to use proxy mode."},mode:{title:"Mode",archive:"Archive",archiveDesc:"Archive files immediately",review:"Review",reviewDesc:"Review before archiving",queue:"Queue",queueDesc:"Archive and add to queue",proxy:"Proxy",proxyDesc:"Relay to real printer"},setupRequired:{title:"Setup Required",description:"The virtual printer feature requires additional system configuration before it will work. This includes port forwarding, firewall rules, and platform-specific settings.",readGuide:"Read the setup guide before enabling"},howItWorks:{title:"How it works",titleProxy:"How it works (Proxy Mode)",step1:"Complete the setup guide for your platform",step2:"Enable the virtual printer and set an access code",step3:'In Bambu Studio or OrcaSlicer, go to "Add Printer"',step4:'The "Bambuddy" printer should appear in the discovery list',step5:"Connect using the access code you set",step6:'When you "print" to Bambuddy, the 3MF file is archived instead',proxyStep1:"Set the target printer IP (must be on your LAN)",proxyStep2:"Configure port forwarding to Bambuddy (ports 9990, 8883)",proxyStep3:"In your slicer, manually add a network printer",proxyStep4:"Enter Bambuddy's external address and printer's access code",proxyStep5:"Print as normal - traffic is relayed to the real printer"},status:{title:"Status Details",printerName:"Printer Name",model:"Model",serialNumber:"Serial Number",mode:"Mode",pendingFiles:"Pending Files",targetPrinter:"Target Printer",ftpPort:"FTP Port",mqttPort:"MQTT Port",ftpConnections:"FTP Connections",mqttConnections:"MQTT Connections"},toast:{updated:"Virtual printer settings updated",failedToUpdate:"Failed to update settings",accessCodeRequired:"Please set an access code first",targetPrinterRequired:"Please select a target printer first",accessCodeEmpty:"Access code cannot be empty",accessCodeLength:"Access code must be exactly 8 characters"}},maintenanceDescriptions:{lubricateRails:"Apply lubricant to linear rails for smooth motion",cleanNozzle:"Clean hotend and nozzle to prevent clogs",checkBelts:"Verify belt tension for accurate prints",cleanBuildPlate:"Clean build plate for better adhesion",checkExtruder:"Inspect extruder gears for wear",checkCooling:"Ensure cooling fans are working properly",generalInspection:"General printer inspection",cleanCarbonRods:"Clean carbon rods to reduce friction",checkPtfeTube:"Inspect PTFE tube for wear or damage",replaceHepaFilter:"Replace HEPA filter for air quality",replaceCarbonFilter:"Replace activated carbon filter",lubricateLeftNozzleRail:"Lubricate left nozzle rail (H2 series)"}},Zse={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}}",updateAvailableBanner:"Version {{version}} ist verfügbar!",viewUpdate:"Update anzeigen",viewOnGithub:"Auf GitHub ansehen",keyboardShortcuts:"Tastaturkürzel (?)",switchToLight:"Zum hellen Modus wechseln",switchToDark:"Zum dunklen Modus wechseln",smartSwitches:"Smart Switches",logout:"Abmelden"},common:{save:"Speichern",saving:"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",days:"Tage",enable:"Aktivieren",disable:"Deaktivieren",permissions:"Berechtigungen",noPrinters:"Keine Drucker konfiguriert",noData:"Keine Daten verfügbar",linkNotFound:"Link nicht gefunden",required:"Erforderlich",optional:"Optional",dismiss:"Schließen",apply:"Anwenden",reset:"Zurücksetzen",clear:"Leeren",selectAll:"Alle auswählen",deselectAll:"Auswahl aufheben",noChange:"— Keine Änderung —",unchanged:"Unverändert",unassigned:"Nicht zugewiesen",unknown:"Unbekannt",unknownError:"Unbekannter Fehler",today:"Heute",asap:"Sofort",overdue:"Überfällig",now:"Jetzt",collapse:"Einklappen",expand:"Ausklappen",viewArchive:"Archiv anzeigen",viewInFileManager:"Im Dateimanager anzeigen",addedBy:"Hinzugefügt von {{username}}",prints:"Drucke",more:"+{{count}} weitere",ascending:"Aufsteigend",descending:"Absteigend",printer:"Drucker",remove:"Entfernen",type:"Typ",print:"Drucken",rename:"Umbenennen",move:"Verschieben",create:"Erstellen",duplicate:"Duplizieren",left:"Links",right:"Rechts"},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",sort:{name:"Name",status:"Status",model:"Modell",location:"Standort",ascending:"Aufsteigend sortieren",descending:"Absteigend sortieren"},cardSize:{small:"Kleine Karten",medium:"Mittlere Karten",large:"Große Karten",extraLarge:"Extra große Karten"},hideOffline:"Offline ausblenden",powerOn:"Einschalten",offlinePrintersWithPlugs:"Offline-Drucker mit Smart-Plugs",noPrintersConfigured:"Noch keine Drucker konfiguriert",readyToPrint:"Druckbereit",external:"Extern",deleteArchives:"Druckarchive löschen",noLabel:"Keine Bezeichnung",printPreview:"Druckvorschau",width:"Breite",height:"Höhe",noObjectsFound:"Keine Objekte gefunden",objectsLoadedOnPrintStart:"Objekte werden beim Druckstart geladen",willBeSkipped:"Wird übersprungen",name:"Name",serialCannotBeChanged:"Seriennummer kann nicht geändert werden",locationHelp:"Dient zur Gruppierung von Druckern und zum Filtern von Warteschlangenaufträgen",wifiSignal:{veryWeak:"Sehr schwach",weak:"Schwach",fair:"Ausreichend",good:"Gut",excellent:"Ausgezeichnet"},maintenanceUpToDate:"Alle Wartungen aktuell - Klicken zum Anzeigen",chamberLightOn:"Kammerbeleuchtung einschalten",chamberLightOff:"Kammerbeleuchtung ausschalten",browseFiles:"Druckerdateien durchsuchen",autoOffAfterPrint:"Automatisches Ausschalten nach Druck",autoOffExecuted:"Auto-off wurde ausgeführt - Drucker einschalten zum Zurücksetzen",hmsErrors:"HMS-Fehler",viewHmsErrors:"{{count}} HMS-Fehler anzeigen",resume:"Fortsetzen",pause:"Pausieren",stop:"Stoppen",camera:"Kamera",skipObject:"Objekt überspringen",reconnect:"Neu verbinden",mqttDebug:"MQTT-Debug",activeNozzle:"Aktiv: {{nozzle}} Düse",firmwareUpdate:"Firmware-Update",firmwareInstructions:"Gehen Sie auf dem Touchscreen des Druckers zu",firmwareNav:"Navigieren Sie zu",settings:"Einstellungen",firmware:"Firmware",discoverPrinters:"Drucker entdecken",searching:"Suche...",manualEntry:"Manuelle Eingabe",addFromCloud:"Aus Cloud hinzufügen",toast:{printerDeleted:"Drucker gelöscht",printerAdded:"Drucker hinzugefügt",printerUpdated:"Drucker aktualisiert",failedToDelete:"Drucker konnte nicht gelöscht werden",failedToAdd:"Drucker konnte nicht hinzugefügt werden",failedToUpdate:"Drucker konnte nicht aktualisiert werden",commandSent:"Befehl gesendet",failedToSendCommand:"Befehl konnte nicht gesendet werden",turnedOn:"{{name}} eingeschaltet",failedToPowerOn:"{{name}} konnte nicht eingeschaltet werden",scriptTriggered:"Skript ausgelöst",printStopped:"Druck gestoppt",printPaused:"Druck pausiert",printResumed:"Druck fortgesetzt",referenceDeleted:"Referenz gelöscht",detectionAreaSaved:"Erkennungsbereich gespeichert",failedToRunScript:"Skript konnte nicht ausgeführt werden",failedToStopPrint:"Druck konnte nicht gestoppt werden",failedToPausePrint:"Druck konnte nicht pausiert werden",failedToResumePrint:"Druck konnte nicht fortgesetzt werden",failedToControlChamberLight:"Kammerbeleuchtung konnte nicht gesteuert werden",failedToUpdateSetting:"Einstellung konnte nicht aktualisiert werden",failedToSkipObjects:"Objekte konnten nicht übersprungen werden",failedToRereadRfid:"RFID konnte nicht erneut gelesen werden",failedToCheckPlate:"Platte konnte nicht überprüft werden",failedToUpdateLabel:"Bezeichnung konnte nicht aktualisiert werden",failedToDeleteReference:"Referenz konnte nicht gelöscht werden",failedToSaveDetectionArea:"Erkennungsbereich konnte nicht gespeichert werden",plateCheckEnabled:"Plattenprüfung aktiviert",plateCheckDisabled:"Plattenprüfung deaktiviert",calibrationSaved:"Kalibrierung gespeichert!",calibrationFailed:"Kalibrierung fehlgeschlagen",rfidRereadInitiated:"RFID-Neueinlesen gestartet"},connection:{connected:"Verbunden",offline:"Offline"},queue:{inQueue:"{{count}} Druck in Warteschlange",inQueue_plural:"{{count}} Drucke in Warteschlange"},controls:"Steuerung",rfid:{reread:"RFID neu lesen"},permission:{noAdd:"Sie haben keine Berechtigung, Drucker hinzuzufügen",noEdit:"Sie haben keine Berechtigung, Drucker zu bearbeiten",noDelete:"Sie haben keine Berechtigung, Drucker zu löschen",noControl:"Sie haben keine Berechtigung, Drucker zu steuern",noFiles:"Sie haben keine Berechtigung, auf Druckerdateien zuzugreifen",noAmsRfid:"Sie haben keine Berechtigung, AMS-RFID erneut zu lesen",noSmartPlugControl:"Sie haben keine Berechtigung, Smart Plugs zu steuern"},modal:{addTitle:"Drucker hinzufügen",editTitle:"Drucker bearbeiten",myPrinter:"Mein Drucker",selectModel:"Modell auswählen...",locationGroup:"Standort / Gruppe (optional)",locationPlaceholder:"z.B. Werkstatt, Büro, Keller",autoArchiveLabel:"Abgeschlossene Drucke automatisch archivieren",fromPrinterSettings:"Aus Druckereinstellungen",modelOptional:"Modell (optional)",saveChanges:"Änderungen speichern"},skipObjects:{tooltip:"Objekte überspringen",onlyWhilePrinting:"Objekte überspringen (nur während des Drucks)",requiresMultiple:"Objekte überspringen (erfordert 2+ Objekte)",title:"Objekte überspringen",matchIdsInfo:"IDs mit Drucker-Display abgleichen",printerShowsIds:"Der Druckerbildschirm zeigt Objekt-IDs auf der Bauplatte",skipSelected:"Ausgewählte überspringen",skipping:"Überspringe...",noObjectsSelected:"Keine Objekte ausgewählt",selectObjectsToSkip:"Wählen Sie Objekte aus, die Sie vom aktuellen Druck überspringen möchten",skipped:"übersprungen",objectsSkipped:"Objekte übersprungen",activeCount:"{{count}} aktiv",waitForLayer:"Warten Sie auf Schicht 2+ zum Überspringen von Objekten (aktuell Schicht {{layer}})",skip:"Überspringen"},confirm:{deleteTitle:"Drucker löschen",deleteMessage:'Möchten Sie "{{name}}" wirklich löschen? Alle Verbindungseinstellungen werden entfernt.',deleteArchivesNote:"Der gesamte Druckverlauf für diesen Drucker wird dauerhaft gelöscht.",keepArchivesNote:"Der Druckverlauf wird beibehalten, aber nicht mehr mit diesem Drucker verknüpft.",stopTitle:"Druck stoppen",stopMessage:'Möchten Sie den aktuellen Druck auf "{{name}}" wirklich stoppen? Der Druckauftrag wird abgebrochen.',stopButton:"Druck stoppen",pauseTitle:"Druck pausieren",pauseMessage:'Möchten Sie den aktuellen Druck auf "{{name}}" wirklich pausieren?',pauseButton:"Druck pausieren",resumeTitle:"Druck fortsetzen",resumeMessage:'Möchten Sie den Druck auf "{{name}}" fortsetzen?',resumeButton:"Druck fortsetzen",powerOnTitle:"Drucker einschalten",powerOnMessage:'Möchten Sie die Stromversorgung für "{{name}}" wirklich EINSCHALTEN?',powerOnButton:"Einschalten",powerOffTitle:"Drucker ausschalten",powerOffMessage:'Möchten Sie die Stromversorgung für "{{name}}" wirklich AUSSCHALTEN?',powerOffWarning:'WARNUNG: "{{name}}" druckt gerade! Möchten Sie die Stromversorgung wirklich AUSSCHALTEN? Dies unterbricht den Druck und kann den Drucker beschädigen.',powerOffButton:"Ausschalten"},discovery:{title:"Drucker entdecken",searching:"Suche...",scanning:"Scanne...",scanProgress:"Scanne... {{scanned}}/{{total}}",foundPrinters:"{{count}} Drucker gefunden",noPrintersFound:"Keine Drucker gefunden",noPrintersFoundSubnet:"Keine Drucker im angegebenen Subnetz gefunden.",noPrintersFoundNetwork:"Keine Drucker im Netzwerk gefunden.",allConfigured:"Alle erkannten Drucker sind bereits konfiguriert.",alreadyAdded:"Bereits hinzugefügt",select:"Auswählen",manualEntry:"Manuelle Eingabe",addFromCloud:"Aus Cloud hinzufügen",subnetToScan:"Zu scannendes Subnetz",dockerNote:"Docker erkannt. Geben Sie das Subnetz Ihres Druckers in CIDR-Notation ein. Erfordert network_mode: host in docker-compose.yml.",scanSubnet:"Subnetz nach Druckern scannen",discoverNetwork:"Drucker im Netzwerk suchen",scanningSubnet:"Subnetz wird nach Bambu-Druckern gescannt...",scanningNetwork:"Netzwerk wird gescannt...",serialRequired:"Seriennummer erforderlich",unknown:"Unbekannt",failedToStart:"Erkennung konnte nicht gestartet werden"},filaments:"Filamente",openCameraOverlay:"Kamera-Overlay öffnen",openCameraWindow:"Kamera in neuem Fenster öffnen",firmwareUpdateAvailable:"Firmware-Update verfügbar: {{current}} → {{latest}}",firmwareUpdateButton:"Update",plateDetection:{noPermission:"Sie haben keine Berechtigung, Drucker zu aktualisieren",enabledClick:"Plattenprüfung aktiviert - Klicken zum Deaktivieren",disabledClick:"Plattenprüfung deaktiviert - Klicken zum Aktivieren",manageCalibration:"Platten-Erkennungskalibrierung verwalten",calibrationRequired:"Kalibrierung erforderlich",calibrationInstructions:"Bitte stellen Sie sicher, dass die Druckplatte <strong>vollständig leer</strong> ist, und klicken Sie dann auf Kalibrieren.",calibrationDescription:"Die Kalibrierung erfasst ein Referenzbild der leeren Platte. Zukünftige Prüfungen vergleichen mit dieser Referenz, um Objekte zu erkennen.",calibrationTip:"<strong>Tipp:</strong> Sie können bis zu 5 Kalibrierungen für verschiedene Platten speichern. Das System verwendet automatisch die beste Übereinstimmung bei der Prüfung.",plateEmpty:"Platte erscheint leer",objectsDetected:"Objekte auf Platte erkannt",confidence:"Konfidenz",difference:"Differenz",analysisPreview:"Analysevorschau:",analysisLegend:"Grüner Rahmen = Erkennungsbereich, Rote Überlagerung = Unterschiede zur Kalibrierung",savedReferences:"Gespeicherte Referenzen ({{count}}/{{max}})",deleteReference:"Referenz löschen",labelPlaceholder:"Bezeichnung...",clickToEdit:"{{label}} - Zum Bearbeiten klicken",clickToAddLabel:"Zum Hinzufügen einer Bezeichnung klicken"},fans:{partCooling:"Bauteilkühlung",auxiliary:"Hilfsventilator",chamber:"Kammerventilator"},clickToViewHmsErrors:"Klicken, um HMS-Fehler anzuzeigen",estimatedCompletion:"Geschätzte Fertigstellungszeit",slotOptions:"Slot-Optionen",firmwareModal:{title:"Firmware-Update",currentVersion:"Aktuell:",latestVersion:"Neueste:",releaseNotes:"Versionshinweise",checkingPrereqs:"Prüfe Voraussetzungen...",sdCardReady:"SD-Karte bereit. Klicken Sie unten, um die Firmware hochzuladen.",uploadedSuccess:"Firmware auf SD-Karte hochgeladen!",applyInstructions:"So wenden Sie das Update auf Ihrem Drucker an:",step1:"Gehen Sie auf dem Touchscreen des Druckers zu <strong>Einstellungen</strong>",step2:"Navigieren Sie zu <strong>Firmware</strong>",step3:"Wählen Sie <strong>Update von SD-Karte</strong>",step4:"Das Update dauert 10-20 Minuten",done:"Fertig",starting:"Starte...",uploadFirmware:"Firmware hochladen",uploadedToast:"Firmware hochgeladen! Starten Sie das Update vom Druckerbildschirm."},accessCodePlaceholder:"Leer lassen, um den aktuellen zu behalten",roi:{title:"Erkennungsbereich (ROI)",xStart:"X-Start",yStart:"Y-Start",width:"Breite",height:"Höhe",instruction:"Passen Sie den Erkennungsbereich an, um sich auf die Druckplatte zu konzentrieren. Der grüne Rahmen in der Vorschau zeigt den aktuellen Bereich."}},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",sortLargest:"Größte zuerst",sortSmallest:"Kleinste zuerst",sortSize:"Größe",noArchives:"Keine Archive gefunden",noArchivesSearch:"Keine Archive entsprechen Ihrer Suche",noArchivesYet:"Noch keine Archive",loadingArchives:"Lade Archive...",releaseToUpload:"Loslassen zum Hochladen",showAll:"Alle anzeigen",showFavoritesOnly:"Nur Favoriten anzeigen",gridView:"Rasteransicht",listView:"Listenansicht",calendarView:"Kalenderansicht",manageTags:"Tags verwalten",showFailedPrints:"Fehlgeschlagene Drucke anzeigen",hideFailedPrints:"Fehlgeschlagene Drucke ausblenden",printTime:"Druckzeit",filamentUsed:"Verbrauchtes Filament",cost:"Kosten",reprint:"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"},toast:{source3mfAttached:"Quell-3MF angehängt: {{filename}}",failedUploadSource3mf:"Fehler beim Hochladen der Quell-3MF",source3mfRemoved:"Quell-3MF entfernt",failedRemoveSource3mf:"Fehler beim Entfernen der Quell-3MF",f3dAttached:"F3D angehängt: {{filename}}",failedUploadF3d:"Fehler beim Hochladen der F3D",f3dRemoved:"F3D entfernt",failedRemoveF3d:"Fehler beim Entfernen der F3D",timelapseAttached:"Zeitraffer angehängt: {{filename}}",timelapseAlreadyAttached:"Zeitraffer bereits angehängt",noMatchingTimelapse:"Kein passender Zeitraffer gefunden",failedScanTimelapse:"Fehler beim Suchen nach Zeitraffer",failedAttachTimelapse:"Fehler beim Anhängen des Zeitraffers",archiveDeleted:"Archiv gelöscht",failedDeleteArchive:"Fehler beim Löschen des Archivs",addedToFavorites:"Zu Favoriten hinzugefügt",removedFromFavorites:"Aus Favoriten entfernt",projectUpdated:"Projekt aktualisiert",failedUpdateProject:"Fehler beim Aktualisieren des Projekts",linkCopied:"Link in die Zwischenablage kopiert",failedCopyLink:"Fehler beim Kopieren des Links",photoDeleted:"Foto gelöscht",failedDeletePhoto:"Fehler beim Löschen des Fotos",failedDeleteArchives:"Fehler beim Löschen der Archive",failedUpdateFavorites:"Fehler beim Aktualisieren der Favoriten",exportDownloaded:"Export heruntergeladen",exportFailed:"Export fehlgeschlagen"},menu:{print:"Drucken",schedule:"Planen",openInBambuStudio:"In Bambu Studio öffnen",slice:"Slicen",externalLink:"Externer Link",viewOnMakerWorld:"Auf MakerWorld ansehen",preview3d:"3D-Vorschau",viewTimelapse:"Zeitraffer ansehen",scanForTimelapse:"Nach Zeitraffer suchen",downloadSource3mf:"Quell-3MF herunterladen",uploadSource3mf:"Quell-3MF hochladen",replaceSource3mf:"Quell-3MF ersetzen",removeSource3mf:"Quell-3MF entfernen",uploadF3d:"F3D hochladen",replaceF3d:"F3D ersetzen",downloadF3d:"F3D herunterladen",removeF3d:"F3D entfernen",download:"Herunterladen",copyDownloadLink:"Download-Link kopieren",qrCode:"QR-Code",viewPhotos:"Fotos ansehen",viewPhotosCount:"Fotos ansehen ({{count}})",projectPage:"Projektseite",addToFavorites:"Zu Favoriten hinzufügen",removeFromFavorites:"Aus Favoriten entfernen",edit:"Bearbeiten",goToProject:"Zum Projekt: {{name}}",addToProject:"Zu Projekt hinzufügen",removeFromProject:"Aus Projekt entfernen",loading:"Laden...",noProjectsAvailable:"Keine Projekte verfügbar",select:"Auswählen",deselect:"Abwählen",delete:"Löschen"},permission:{noReprint:"Sie haben keine Berechtigung, dieses Archiv erneut zu drucken",noAddToQueue:"Sie haben keine Berechtigung, zur Warteschlange hinzuzufügen",noUpdateArchives:"Sie haben keine Berechtigung, Archive zu aktualisieren",noUploadFiles:"Sie haben keine Berechtigung, Dateien hochzuladen",noDownload:"Sie haben keine Berechtigung, Archive herunterzuladen",noCopyLink:"Sie haben keine Berechtigung, Download-Links zu kopieren",noDelete:"Sie haben keine Berechtigung, dieses Archiv zu löschen",noCreate:"Sie haben keine Berechtigung, Archive zu erstellen"},card:{previousPlate:"Vorherige Platte",nextPlate:"Nächste Platte",plateNumber:"Platte {{index}}",moreOptions:"Rechtsklick für mehr Optionen",addToFavorites:"Zu Favoriten hinzufügen",removeFromFavorites:"Aus Favoriten entfernen",cancelled:"abgebrochen",failed:"fehlgeschlagen",duplicate:"Duplikat",duplicateTitle:"Dieses Modell wurde bereits zuvor gedruckt",openSource3mf:"Quell-3MF in Bambu Studio öffnen (Rechtsklick für mehr Optionen)",downloadF3d:"Fusion 360 Designdatei herunterladen",viewTimelapse:"Zeitraffer ansehen",viewPhoto:"1 Foto ansehen",viewPhotos:"{{count}} Fotos ansehen",openFolder:"Ordner öffnen: {{name}}",slicedFile:"Geslicte Datei - druckbereit",sourceFile:"Nur Quelldatei - keine AMS-Zuordnung verfügbar",gcode:"GCODE",source:"QUELLE",project:"Projekt: {{name}}",estimated:"Geschätzt: {{time}}",actual:"Tatsächlich: {{time}}",accuracy:"Genauigkeit: {{percent}}%",filament:"{{weight}}g",layer:"{{count}} Schicht",layers:"{{count}} Schichten",object:"{{count}} Objekt",objects:"{{count}} Objekte",slicedFor:"Geslict für {{model}}",uploadedBy:"Hochgeladen von {{name}}",noPermissionReprint:"Sie haben keine Berechtigung, erneut zu drucken",noPermissionEdit:"Sie haben keine Berechtigung, Archive zu bearbeiten",noPermissionDelete:"Sie haben keine Berechtigung, Archive zu löschen",reprint:"Drucken",schedulePrint:"Druck planen",schedule:"Planen",openInBambuStudio:"In Bambu Studio öffnen",openInBambuStudioToSlice:"In Bambu Studio öffnen zum Slicen",slice:"Slicen",externalLink:"Externer Link",makerWorld:"MakerWorld: {{designer}}",viewProject:"Projekt ansehen",noExternalLink:"Kein externer Link",preview3d:"3D-Vorschau",download:"Herunterladen",edit:"Bearbeiten",delete:"Löschen"},modal:{deleteArchive:"Archiv löschen",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.',deleteButton:"Löschen",removeSource3mf:"Quell-3MF entfernen",removeSource3mfConfirm:'Möchten Sie die Quell-3MF-Datei wirklich von "{{name}}" entfernen? Die ursprüngliche Slicer-Projektdatei wird gelöscht.',removeButton:"Entfernen",removeF3d:"F3D entfernen",removeF3dConfirm:'Möchten Sie die Fusion 360 Designdatei wirklich von "{{name}}" entfernen?',timelapse:"{{name}} - Zeitraffer",selectTimelapse:"Zeitraffer auswählen",selectTimelapseDesc:"Keine automatische Übereinstimmung gefunden. Wählen Sie den Zeitraffer für diesen Druck:",deleteArchives:"Archive löschen",deleteArchivesConfirm:"Möchten Sie wirklich {{count}} Archiv(e) löschen? Diese Aktion kann nicht rückgängig gemacht werden.",deleteCount:"{{count}} löschen"},page:{title:"Archive",printsCount:"{{filtered}} von {{total}} Drucken",dropFilesHere:".3mf-Dateien hier ablegen",releaseToUpload:"Loslassen zum Hochladen",only3mfSupported:"Nur .3mf-Dateien werden unterstützt",close:"Schließen",selected:"{{count}} ausgewählt",selectAll:"Alle auswählen",tags:"Tags",project:"Projekt",favorite:"Favorit",delete:"Löschen",toggledFavorites:"Favoriten für {{count}} Archiv(e) umgeschaltet",failedUpdateFavorites:"Fehler beim Aktualisieren der Favoriten",archivesDeleted:"{{count}} Archiv(e) gelöscht",failedDeleteArchives:"Fehler beim Löschen der Archive",photoDeleted:"Foto gelöscht",failedDeletePhoto:"Fehler beim Löschen des Fotos"},list:{name:"Name",printer:"Drucker",date:"Datum",size:"Größe",actions:"Aktionen",hasTimelapse:"Hat Zeitraffer"}},queue:{title:"Druckwarteschlange",subtitle:"Planen und verwalten Sie Ihre Druckaufträge",addToQueue:"Zur Warteschlange hinzufügen",print:"Drucken",reprint:"Erneut drucken",schedulePrint:"Druck planen",editQueueItem:"Warteschlangeneintrag bearbeiten",printToPrinters:"Auf {{count}} Druckern drucken",queueToPrinters:"Zu {{count}} Druckern hinzufügen",sending:"Wird gesendet...",sendingProgress:"Sende {{current}}/{{total}}...",adding:"Wird hinzugefügt...",addingProgress:"Füge hinzu {{current}}/{{total}}...",savingProgress:"Speichere {{current}}/{{total}}...",clearQueue:"Warteschlange leeren",clearHistory:"Verlauf löschen",emptyQueue:"Warteschlange ist leer",position:"Position",scheduledTime:"Geplante Zeit",moveUp:"Nach oben",moveDown:"Nach unten",startNow:"Jetzt starten",printingInProgress:"Druck läuft...",viewArchive:"Archiv anzeigen",viewInFileManager:"Im Dateimanager anzeigen",itemCount:"{{count}} Element",itemCount_plural:"{{count}} Elemente",dragToReorder:"Ziehen zum Neuordnen (nur Sofort)",reorderHint:"Position betrifft nur Sofort-Elemente. Geplante Elemente werden zur festgelegten Zeit ausgeführt.",addedBy:"Hinzugefügt von {{name}}",sections:{currentlyPrinting:"Aktuell druckend",queued:"In Warteschlange",history:"Verlauf"},status:{pending:"Ausstehend",waiting:"Wartend",printing:"Druckt",completed:"Abgeschlossen",failed:"Fehlgeschlagen",skipped:"Übersprungen",cancelled:"Abgebrochen"},summary:{printing:"Druckt",queued:"In Warteschlange",totalTime:"Gesamte Wartezeit",history:"Verlauf"},filter:{allPrinters:"Alle Drucker",unassigned:"Nicht zugewiesen",allStatus:"Alle Status",allLocations:"Alle Standorte",any:"Beliebig"},sort:{byPosition:"Nach Position sortieren",byName:"Nach Name sortieren",byPrinter:"Nach Drucker sortieren",bySchedule:"Nach Zeitplan sortieren",byDate:"Nach Datum sortieren",ascendingOldest:"Aufsteigend (älteste zuerst)",descendingNewest:"Absteigend (neueste zuerst)"},badges:{staged:"Bereitgestellt",requiresPrevious:"Erfordert vorherigen Erfolg",autoPowerOff:"Automatisch ausschalten"},empty:{title:"Keine Drucke geplant",description:'Planen Sie einen Druck von der Archivseite über die Option "Planen" im Kontextmenü oder ziehen Sie Dateien hierher.'},time:{asap:"Sofort",overdue:"Überfällig",now:"Jetzt",lessThanMinute:"In weniger als einer Minute",inMinutes:"In {{count}} Min",inHours:"In {{count}} Stunden"},actions:{stopPrint:"Druck stoppen",startPrint:"Druck starten",requeue:"Erneut einreihen"},bulkEdit:{title:"{{count}} Element bearbeiten",title_plural:"{{count}} Elemente bearbeiten",description:"Nur geänderte Einstellungen werden auf ausgewählte Elemente angewendet.",printer:"Drucker",noChange:"— Keine Änderung —",queueOptions:"Warteschlangenoptionen",staged:"Bereitgestellt (manueller Start)",autoPowerOff:"Nach Druck automatisch ausschalten",requirePrevious:"Vorherigen Erfolg erfordern",printOptions:"Druckoptionen",bedLevelling:"Bett-Nivellierung",flowCalibration:"Fluss-Kalibrierung",vibrationCalibration:"Vibrations-Kalibrierung",layerInspection:"Erste-Schicht-Prüfung",timelapse:"Zeitraffer",useAms:"AMS verwenden",applyChanges:"Änderungen übernehmen",selectAll:"Alle auswählen",deselectAll:"Auswahl aufheben",selected:"{{count}} ausgewählt",editSelected:"Ausgewählte bearbeiten",cancelSelected:"Ausgewählte abbrechen"},confirm:{cancelTitle:"Geplanten Druck abbrechen",cancelMessage:'Möchten Sie "{{name}}" wirklich abbrechen?',stopTitle:"Druck stoppen",stopMessage:'Möchten Sie den aktuellen Druck "{{name}}" wirklich stoppen? Der Druckauftrag wird am Drucker abgebrochen.',removeTitle:"Aus Verlauf entfernen",removeMessage:'Möchten Sie "{{name}}" wirklich aus dem Warteschlangenverlauf entfernen?',clearHistoryTitle:"Verlauf löschen",clearHistoryMessage:"Möchten Sie alle {{count}} Element(e) aus dem Verlauf entfernen?",cancelButton:"Druck abbrechen",stopButton:"Druck stoppen",thisPrint:"diesen Druck",thisItem:"dieses Element"},toast:{cancelled:"Warteschlangenelement abgebrochen",cancelFailed:"Element konnte nicht abgebrochen werden",removed:"Warteschlangenelement entfernt",removeFailed:"Element konnte nicht entfernt werden",stopped:"Druck gestoppt",stopFailed:"Druck konnte nicht gestoppt werden",released:"Druck in Warteschlange freigegeben",startFailed:"Druck konnte nicht gestartet werden",reorderFailed:"Warteschlange konnte nicht neu geordnet werden",historyCleared:"{{count}} Verlaufselement(e) gelöscht",clearHistoryFailed:"Verlauf konnte nicht gelöscht werden",updateFailed:"Elemente konnten nicht aktualisiert werden",bulkCancelled:"{{count}} Element(e) abgebrochen",bulkCancelFailed:"Elemente konnten nicht abgebrochen werden"},permissions:{noStopPrint:"Sie haben keine Berechtigung, Drucke zu stoppen",noStartPrint:"Sie haben keine Berechtigung, Drucke zu starten",noEdit:"Sie haben keine Berechtigung, dieses Warteschlangenelement zu bearbeiten",noCancel:"Sie haben keine Berechtigung, dieses Warteschlangenelement abzubrechen",noRequeue:"Sie haben keine Berechtigung, Elemente erneut einzureihen",noRemove:"Sie haben keine Berechtigung, dieses Warteschlangenelement zu entfernen",noClearHistory:"Sie haben keine Berechtigung, den gesamten Verlauf zu löschen",noEditItems:"Sie haben keine Berechtigung, Warteschlangenelemente zu bearbeiten",noCancelItems:"Sie haben keine Berechtigung, Warteschlangenelemente abzubrechen"}},stats:{title:"Dashboard",subtitle:"Widgets zum Neuanordnen ziehen. Auf das Augensymbol klicken zum Ausblenden.",overview:"Übersicht",totalPrints:"Gesamtdrucke",successRate:"Erfolgsrate",totalPrintTime:"Gesamtdruckzeit",printTime:"Druckzeit",totalFilament:"Gesamtverbrauch Filament",filamentUsed:"Filamentverbrauch",filamentCost:"Filamentkosten",totalCost:"Gesamtkosten",energyUsed:"Energieverbrauch",energyCost:"Energiekosten",averagePrintTime:"Durchschnittliche Druckzeit",printsPerDay:"Drucke pro Tag",byPrinter:"Nach Drucker",printsByPrinter:"Drucke nach Drucker",byMaterial:"Nach Material",byMonth:"Nach Monat",last7Days:"Letzte 7 Tage",last30Days:"Letzte 30 Tage",last90Days:"Letzte 90 Tage",allTime:"Gesamt",quickStats:"Schnellstatistiken",printActivity:"Druckaktivität",filamentTypes:"Filamenttypen",filamentTrends:"Filamenttrends",failureAnalysis:"Fehleranalyse",timeAccuracy:"Zeitgenauigkeit",successful:"Erfolgreich:",failed:"Fehlgeschlagen:",perfectEstimate:"100% = perfekte Schätzung",noTimeAccuracyData:"Noch keine Zeitgenauigkeitsdaten",noFilamentData:"Keine Filamentdaten verfügbar",noPrinterData:"Keine Druckerdaten verfügbar",noPrintData:"Keine Druckdaten verfügbar",noPrintDataLast30Days:"Keine Druckdaten in den letzten 30 Tagen",failureReasons:"Fehlerursachen",topFailureReasons:"Häufigste Fehlerursachen",failedPrintsCount:"{{failed}} / {{total}} Drucke fehlgeschlagen",lastWeekRate:"Letzte Woche: {{rate}}%",resetLayout:"Layout zurücksetzen",recalculateCosts:"Kosten neu berechnen",recalculateCostsHint:"Alle Archivkosten mit aktuellen Filamentpreisen neu berechnen",exportStats:"Statistiken exportieren",exportAsCsv:"Als CSV exportieren",exportAsExcel:"Als Excel exportieren",hiddenCount:"{{count}} ausgeblendet",exportDownloaded:"Export heruntergeladen",exportFailed:"Export fehlgeschlagen",layoutReset:"Layout zurückgesetzt",recalculatedCosts:"Kosten für {{count}} Archive neu berechnet",recalculateFailed:"Kosten konnten nicht neu berechnet werden",loadingStats:"Statistiken werden geladen...",noPermissionResetLayout:"Sie haben keine Berechtigung, das Layout zurückzusetzen",noPermissionRecalculate:"Sie haben keine Berechtigung, Kosten neu zu berechnen"},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",statusTab:"Status",settingsTab:"Einstellungen",overdueCount:"{{count}} überfällig",dueSoonCount:"{{count}} bald fällig",dueSoon:"Bald fällig",allGood:"Alles in Ordnung",overdueBy:"Überfällig um {{duration}}",dueIn:"Fällig in {{duration}}",timeLeft:"{{duration}} verbleibend",day:"1 Tag",days:"{{count}} Tage",week:"1 Woche",weeks:"{{count}} Wochen",month:"1 Monat",months:"{{count}} Monate",year:"1 Jahr",maintenanceTypes:"Wartungstypen",maintenanceTypesDescription:"Systemtypen und Ihre benutzerdefinierten Wartungsaufgaben",addCustomType:"Benutzerdefinierten Typ hinzufügen",intervalType:"Intervalltyp",intervalValue:"Intervall ({{type}})",icon:"Symbol",documentationLink:"Dokumentationslink (optional)",assignToPrinters:"Druckern zuweisen",selectAtLeastOnePrinter:"Wählen Sie mindestens einen Drucker",addType:"Typ hinzufügen",custom:"Benutzerdefiniert",printHours:"Druckstunden",calendarDays:"Kalendertage",exampleName:"z.B. HEPA-Filter ersetzen",viewDocumentation:"Dokumentation anzeigen",timeBasedInterval:"Zeitbasiertes Intervall",intervalOverrides:"Intervall-Überschreibungen",intervalOverridesDescription:"Intervalle für bestimmte Drucker anpassen",assignedToPrinters:"Druckern zugewiesen:",noPrintersAssigned:"Keine Drucker zugewiesen",addPrinterShort:"Hinzufügen:",printersAssignedClick:"{{count}} Drucker zugewiesen - klicken zum Verwalten",removeFromPrinter:"Von diesem Drucker entfernen",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",cleanCarbonRods:"Kohlenstoffstangen reinigen",checkPtfeTube:"PTFE-Schlauch prüfen",replaceHepaFilter:"HEPA-Filter ersetzen",replaceCarbonFilter:"Aktivkohlefilter ersetzen",lubricateLeftNozzleRail:"Linke Düsenschiene schmieren"},maintenanceComplete:"Wartung als abgeschlossen markiert",typeUpdated:"Wartungstyp aktualisiert",typeDeleted:"Wartungstyp gelöscht",printHoursUpdated:"Druckstunden aktualisiert",printerAssigned:"Drucker zugewiesen",printerRemoved:"Drucker entfernt",deleteTypeConfirm:'"{{name}}" löschen?',noPermissionUpdate:"Sie haben keine Berechtigung, Wartungselemente zu aktualisieren",noPermissionPerform:"Sie haben keine Berechtigung, Wartungen durchzuführen",noPermissionEditTypes:"Sie haben keine Berechtigung, Wartungstypen zu bearbeiten",noPermissionDeleteTypes:"Sie haben keine Berechtigung, Wartungstypen zu löschen",noPermissionEditHours:"Sie haben keine Berechtigung, Druckstunden zu bearbeiten",noPermissionRemovePrinter:"Sie haben keine Berechtigung, Druckerzuweisungen zu entfernen",noPermissionAssignPrinter:"Sie haben keine Berechtigung, Drucker zuzuweisen",noPermissionEditIntervals:"Sie haben keine Berechtigung, Intervalle zu bearbeiten",configureSettings:"Wartungstypen und Intervalle konfigurieren"},settings:{title:"Einstellungen",general:"Allgemein",tabs:{general:"Allgemein",smartPlugs:"Smart Plugs",notifications:"Benachrichtigungen",filament:"Filament",network:"Netzwerk",apiKeys:"API-Schlüssel",virtualPrinter:"Virtueller Drucker",users:"Benutzer",backup:"Sicherung"},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",noDefaultPrinter:"Kein Standard (jedes Mal fragen)",sidebarOrder:"Seitenleisten-Reihenfolge",saveThumbnails:"Vorschaubilder speichern",captureFinishPhoto:"Abschlussfoto aufnehmen",noPrintersConfigured:"Keine Drucker konfiguriert",archiveMode:{always:"Immer Archiveintrag erstellen",never:"Nie Archiveintrag erstellen",ask:"Jedes Mal fragen"},checkForUpdatesLabel:"Nach Updates suchen",checkPrinterFirmware:"Drucker-Firmware prüfen",enableRetry:"Wiederholung aktivieren",homeAssistantDescription:"Smart Plugs über Home Assistant steuern",mqttConnectedTo:"Verbunden mit",prometheusDescription:"Druckerdaten im Prometheus-Format bereitstellen",noSmartPlugsTitle:"Keine Smart Plugs konfiguriert",noSmartPlugsDescription:"Fügen Sie einen Tasmota-basierten Smart Plug hinzu, um den Energieverbrauch zu verfolgen und die Stromsteuerung zu automatisieren.",noProvidersTitle:"Keine Anbieter konfiguriert",noProvidersDescription:"Fügen Sie einen Anbieter hinzu, um Benachrichtigungen zu erhalten.",noTemplatesAvailable:"Keine Vorlagen verfügbar. Starten Sie das Backend neu, um Standardvorlagen zu laden.",apiPermissionView:"Druckerstatus und Warteschlange anzeigen",apiPermissionEdit:"Elemente zur Druckwarteschlange hinzufügen und entfernen",apiKeysEmptyTitle:"Keine API-Schlüssel",apiKeysEmptyDescription:"Erstellen Sie einen API-Schlüssel zur Integration mit externen Diensten.",noUsersFound:"Keine Benutzer gefunden",noGroupsFound:"Keine Gruppen gefunden",noGroupsAvailable:"Keine Gruppen verfügbar",passwordsDoNotMatch:"Passwörter stimmen nicht überein",systemGroupWarning:"System-Gruppennamen können nicht geändert werden",authDisabledTitle:"Authentifizierung ist deaktiviert",authDisabledFeature1:"Anmeldung zum Zugriff auf das System erforderlich",authDisabledFeature2:"Mehrere Benutzer mit gruppenbasierten Berechtigungen erstellen",authDisabledFeature3:"Zugriff mit über 50 granularen Berechtigungen steuern",userHasCreated:"Dieser Benutzer hat erstellt:",userItemsQuestion:"Was möchten Sie mit diesen Elementen tun?",deleteUserConfirm:"Möchten Sie diesen Benutzer wirklich löschen?",actionCannotBeUndone:"Diese Aktion kann nicht rückgängig gemacht werden.",addFirstSmartPlug:"Ersten Smart Plug hinzufügen",providers:"Anbieter",log:"Protokoll",testAll:"Alle testen",testResults:"Testergebnisse",testPassedCount:"{{count}} bestanden",testFailedCount:"{{count}} fehlgeschlagen",messageTemplates:"Nachrichtenvorlagen",messageTemplatesDescription:"Passen Sie Benachrichtigungen für jedes Ereignis an.",apiKeys:"API-Schlüssel",apiKeysDescription:"Erstellen Sie API-Schlüssel für externe Integrationen und Webhooks.",createKey:"Schlüssel erstellen",apiKeyCreated:"API-Schlüssel erfolgreich erstellt",apiKeyCopyWarning:"Kopieren Sie diesen Schlüssel jetzt - er wird nicht mehr angezeigt!",useInApiBrowser:"Im API-Browser verwenden",createNewApiKey:"Neuen API-Schlüssel erstellen",keyName:"Schlüsselname",keyNamePlaceholder:"z.B. Home Assistant, OctoPrint",readStatus:"Status lesen",readStatusDescription:"Druckerstatus und Warteschlange anzeigen",manageQueue:"Warteschlange verwalten",manageQueueDescription:"Elemente zur Druckwarteschlange hinzufügen und entfernen",controlPrinter:"Drucker steuern",controlPrinterDescription:"Drucke pausieren, fortsetzen und stoppen",unnamedKey:"Unbenannter Schlüssel",lastUsed:"Zuletzt verwendet",read:"Lesen",control:"Steuern",createFirstKey:"Ersten Schlüssel erstellen",webhookEndpoints:"Webhook-Endpunkte",webhookApiKeyHint:"Verwenden Sie Ihren API-Schlüssel im X-API-Key-Header.",webhook:{getAllStatus:"Alle Druckerstatus abrufen",getSpecificStatus:"Spezifischen Druckerstatus abrufen",addToQueue:"Zur Druckwarteschlange hinzufügen",pausePrint:"Druck pausieren",resumePrint:"Druck fortsetzen",stopPrint:"Druck stoppen"},apiBrowser:"API-Browser",apiBrowserDescription:"Erkunden und testen Sie alle verfügbaren API-Endpunkte.",apiKeyForTesting:"API-Schlüssel zum Testen",apiKeyPlaceholder:"Fügen Sie hier Ihren API-Schlüssel ein, um authentifizierte Endpunkte zu testen...",apiKeyHint:"Dieser Schlüssel wird als X-API-Key-Header mit Anfragen gesendet.",deleteApiKeyTitle:"API-Schlüssel löschen",deleteApiKeyMessage:"Möchten Sie diesen API-Schlüssel wirklich löschen? Alle Integrationen, die diesen Schlüssel verwenden, funktionieren nicht mehr.",deleteKey:"Schlüssel löschen",amsDisplayThresholds:"AMS-Anzeigeschwellenwerte",amsThresholdsDescription:"Konfigurieren Sie Farbschwellenwerte für AMS-Feuchtigkeits- und Temperaturanzeigen.",humidity:"Luftfeuchtigkeit",goodGreen:"Gut (grün)",fairOrange:"Mittel (orange)",aboveFairBad:"Über dem mittleren Schwellenwert wird rot angezeigt (schlecht)",temperature:"Temperatur",goodBlue:"Gut (blau)",aboveFairHot:"Über dem mittleren Schwellenwert wird rot angezeigt (heiß)",historyRetention:"Verlaufsaufbewahrung",keepSensorHistory:"Sensorverlauf behalten für",historyRetentionDescription:"Ältere Feuchtigkeits- und Temperaturdaten werden automatisch gelöscht",printModal:"Druckdialog",expandCustomMapping:"Benutzerdefinierte Zuordnung standardmäßig erweitern",expandCustomMappingDescription:"Bei Druck auf mehrere Drucker die AMS-Zuordnung pro Drucker erweitert anzeigen",authentication:"Authentifizierung",authEnabledDescription:"Ihre Instanz ist mit Benutzerauthentifizierung gesichert",authDisabledDescription:"Aktivieren Sie die Anmeldepflicht und verwalten Sie den Benutzerzugriff",authDisabledMessage:"Aktivieren Sie die Authentifizierung, um Benutzerkonten zu erstellen, Berechtigungen zu verwalten und Ihre Bambuddy-Instanz zu sichern.",enableAuthentication:"Authentifizierung aktivieren",currentUser:"Aktueller Benutzer",changePassword:"Passwort ändern",admin:"Admin",users:"Benutzer",addUser:"Benutzer hinzufügen",groups:"Gruppen",addGroup:"Gruppe hinzufügen",system:"System",noDescription:"Keine Beschreibung",userCount:"{{count}} Benutzer",permissionCount:"{{count}} Berechtigungen",createUser:"Benutzer erstellen",username:"Benutzername",enterUsername:"Benutzername eingeben",password:"Passwort",enterPassword:"Passwort eingeben (min. 6 Zeichen)",confirmPassword:"Passwort bestätigen",confirmPasswordPlaceholder:"Passwort bestätigen",viewReleaseOnGitHub:"Release auf GitHub anzeigen",turnAllPlugsOn:"Alle Stecker einschalten",turnAllPlugsOff:"Alle Stecker ausschalten",clearNotificationLogs:"Benachrichtigungsprotokolle löschen",clearLogsMessage:"Dadurch werden alle Benachrichtigungsprotokolle, die älter als 30 Tage sind, dauerhaft gelöscht. Diese Aktion kann nicht rückgängig gemacht werden.",clearLogs:"Protokolle löschen",resetUiPreferences:"UI-Einstellungen zurücksetzen",resetUiPreferencesMessage:"Dadurch werden alle UI-Einstellungen auf Standardwerte zurückgesetzt: Seitenleisten-Reihenfolge, Theme, Dashboard-Layout, Ansichtsmodi und Sortiereinstellungen. Ihre Drucker, Archive und Servereinstellungen werden NICHT beeinträchtigt. Die Seite wird nach dem Löschen neu geladen.",resetPreferences:"Einstellungen zurücksetzen",deleteGroupTitle:"Gruppe löschen",deleteGroupMessage:"Möchten Sie diese Gruppe wirklich löschen? Benutzer in dieser Gruppe verlieren diese Berechtigungen.",deleteGroup:"Gruppe löschen",disableAuthenticationTitle:"Authentifizierung deaktivieren",disableAuthenticationMessage:"Möchten Sie die Authentifizierung wirklich deaktivieren? Dadurch wird Ihre Bambuddy-Instanz ohne Anmeldung zugänglich. Alle Benutzer bleiben in der Datenbank, aber die Authentifizierung wird deaktiviert.",disableAuthentication:"Authentifizierung deaktivieren",configureBambuddy:"Bambuddy konfigurieren",systemDefault:"Systemstandard",archiveSettings:"Archiv-Einstellungen",newWindow:"Neues Fenster",embeddedOverlay:"Eingebettetes Overlay",externalCameras:"Externe Kameras",costTracking:"Kostenverfolgung",printsOnly:"Nur Drucke",totalConsumption:"Gesamtverbrauch",dataManagement:"Datenverwaltung",clearNotificationLogsDescription:"Benachrichtigungsprotokolle älter als 30 Tage löschen",resetUiPreferencesDescription:"Seitenleisten-Reihenfolge, Theme, Ansichtsmodi und Layout-Einstellungen zurücksetzen. Drucker, Archive und Einstellungen werden nicht beeinflusst.",enableHomeAssistant:"Home Assistant aktivieren",enableMqtt:"MQTT aktivieren",useTls:"TLS verwenden",enableMetricsEndpoint:"Metrik-Endpunkt aktivieren",availableMetrics:"Verfügbare Metriken",editUser:"Benutzer bearbeiten",deleteUserTitle:"Benutzer löschen",groupName:"Gruppenname",leaveEmptyForAnonymous:"Leer lassen für anonym",leaveEmptyForNoAuth:"Leer lassen für keine Authentifizierung",enterNewPassword:"Neues Passwort eingeben",confirmNewPassword:"Neues Passwort bestätigen",enterGroupName:"Gruppenname eingeben",enterDescriptionOptional:"Beschreibung eingeben (optional)",enterCurrentPassword:"Aktuelles Passwort eingeben",enterNewPasswordMin6:"Neues Passwort eingeben (min. 6 Zeichen)",toast:{keyCopied:"Schlüssel in Zwischenablage kopiert",copyFailed:"Schlüssel konnte nicht kopiert werden",keyAddedToBrowser:"Schlüssel zum API-Browser hinzugefügt",clearLogsFailed:"Protokolle konnten nicht gelöscht werden",uiPreferencesReset:"UI-Einstellungen zurückgesetzt. Wird neu geladen...",authDisabled:"Authentifizierung erfolgreich deaktiviert",authDisableFailed:"Authentifizierung konnte nicht deaktiviert werden",apiKeyCreated:"API-Schlüssel erstellt",apiKeyDeleted:"API-Schlüssel gelöscht",userCreated:"Benutzer erfolgreich erstellt",userUpdated:"Benutzer erfolgreich aktualisiert",userDeleted:"Benutzer erfolgreich gelöscht",groupCreated:"Gruppe erfolgreich erstellt",groupUpdated:"Gruppe erfolgreich aktualisiert",groupDeleted:"Gruppe erfolgreich gelöscht",fillRequiredFields:"Bitte füllen Sie alle erforderlichen Felder aus",passwordsDoNotMatch:"Passwörter stimmen nicht überein",passwordTooShort:"Passwort muss mindestens 6 Zeichen lang sein",enterGroupName:"Bitte geben Sie einen Gruppennamen ein",settingsSaved:"Einstellungen gespeichert",cameraSettingsSaved:"Kamera-Einstellungen gespeichert",enterCameraUrl:"Bitte geben Sie eine Kamera-URL ein",passwordChanged:"Passwort erfolgreich geändert",connectionFailed:"Verbindung fehlgeschlagen",testFailed:"Test fehlgeschlagen",cameraConnected:"Kamera verbunden{{resolution}}"},testConnection:"Verbindung testen"},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"},hmsErrors:{title:"Fehler - {{name}}",noErrors:"Keine Fehler",viewOnWiki:"Im Bambu Lab Wiki ansehen",clearInstructions:"Löschen Sie die Fehler am Drucker, um sie hier zu entfernen."},mqttDebug:{title:"MQTT-Debug-Protokoll",searchPlaceholder:"Topic oder Payload suchen...",noMessages:"Noch keine Nachrichten protokolliert",startLoggingHint:'Klicken Sie auf "Protokollierung starten", um MQTT-Nachrichten aufzuzeichnen',noMessagesMatch:"Keine Nachrichten entsprechen Ihrem Filter",adjustFilterHint:"Versuchen Sie, Ihre Such- oder Filterkriterien anzupassen",incoming:"Eingehend",outgoing:"Ausgehend",loggingStopped:"Protokollierung gestoppt",loggingActive:"Protokollierung aktiv - Nachrichten werden automatisch aktualisiert",startLogging:"Protokollierung starten",stopLogging:"Protokollierung stoppen",clearLog:"Protokoll löschen",topic:"Topic",timestamp:"Zeitstempel",direction:"Richtung",all:"Alle"},printerFiles:{title:"Dateimanager",storageUsed:"Belegt:",storageFree:"Frei:",filterPlaceholder:"Dateien filtern...",deleteButton:"Löschen",deleteFiles:"{{count}} Dateien löschen",deleteFileConfirm:'"{{name}}" löschen? Dies kann nicht rückgängig gemacht werden.',deleteFilesConfirm:"{{count}} ausgewählte Dateien löschen? Dies kann nicht rückgängig gemacht werden.",noFiles:"Keine Dateien auf dem Drucker",loadingFiles:"Dateien werden geladen...",failedToLoad:"Dateien konnten nicht geladen werden",toast:{filesDeleted:"{{count}} Datei(en) gelöscht",deleteFailed:"Löschen fehlgeschlagen: {{error}}"}},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?"},login:{title:"Bambuddy Anmeldung",subtitle:"Melden Sie sich bei Ihrem Konto an",username:"Benutzername",usernamePlaceholder:"Benutzername eingeben",password:"Passwort",passwordPlaceholder:"Passwort eingeben",signIn:"Anmelden",signingIn:"Anmeldung läuft...",forgotPassword:"Passwort vergessen?",loginSuccess:"Erfolgreich angemeldet",loginFailed:"Anmeldung fehlgeschlagen",enterCredentials:"Bitte Benutzername und Passwort eingeben",forgotPasswordTitle:"Passwort vergessen",forgotPasswordMessage:"Wenn Sie Ihr Passwort vergessen haben, wenden Sie sich bitte an Ihren Systemadministrator.",howToReset:"So setzen Sie Ihr Passwort zurück:",resetStep1:"Kontaktieren Sie Ihren Bambuddy-Administrator",resetStep2:"Bitten Sie ihn, Ihr Passwort in der Benutzerverwaltung zurückzusetzen",resetStep3:"Er kann ein neues temporäres Passwort für Sie festlegen",resetStep4:"Melden Sie sich mit dem neuen Passwort an und ändern Sie es in den Einstellungen",gotIt:"Verstanden"},setup:{title:"Bambuddy Einrichtung",subtitle:"Konfigurieren Sie die Authentifizierung für Ihre Bambuddy-Instanz",enableAuth:"Authentifizierung aktivieren",adminAccount:"Admin-Konto",adminAccountDesc:"Wenn bereits Admin-Benutzer existieren, wird die Authentifizierung mit den vorhandenen Admin-Konten aktiviert. Lassen Sie die Felder unten leer, um vorhandene Admins zu verwenden, oder geben Sie neue Anmeldedaten ein, um einen neuen Admin-Benutzer zu erstellen.",adminUsername:"Admin-Benutzername",adminPassword:"Admin-Passwort",optionalIfAdminExists:"(optional, wenn Admin-Benutzer existieren)",adminUsernamePlaceholder:"Admin-Benutzernamen eingeben (optional)",adminPasswordPlaceholder:"Admin-Passwort eingeben (optional)",confirmPassword:"Passwort bestätigen",confirmPasswordPlaceholder:"Admin-Passwort bestätigen",settingUp:"Einrichtung läuft...",completeSetup:"Einrichtung abschließen",toast:{authEnabledAdminCreated:"Authentifizierung aktiviert und Admin-Benutzer erstellt",authEnabledExistingAdmins:"Authentifizierung mit vorhandenen Admin-Benutzern aktiviert",setupCompleted:"Einrichtung abgeschlossen",enterBothCredentials:"Bitte geben Sie sowohl Admin-Benutzernamen als auch Passwort ein, oder lassen Sie beide leer, um vorhandene Admin-Benutzer zu verwenden",passwordsDoNotMatch:"Passwörter stimmen nicht überein",passwordTooShort:"Passwort muss mindestens 6 Zeichen lang sein"}},changePassword:{title:"Passwort ändern",currentPassword:"Aktuelles Passwort",currentPasswordPlaceholder:"Aktuelles Passwort eingeben",newPassword:"Neues Passwort",newPasswordPlaceholder:"Neues Passwort eingeben (min. 6 Zeichen)",confirmPassword:"Neues Passwort bestätigen",confirmPasswordPlaceholder:"Neues Passwort bestätigen",passwordsDoNotMatch:"Passwörter stimmen nicht überein",passwordTooShort:"Passwort muss mindestens 6 Zeichen lang sein",changing:"Wird geändert...",success:"Passwort erfolgreich geändert",failed:"Passwortänderung fehlgeschlagen"},plateAlert:{title:"Druck pausiert!",message:"Objekte auf dem Druckbett erkannt. Der Druck wurde automatisch pausiert. Bitte räumen Sie das Druckbett und setzen Sie den Druck fort.",understand:"Verstanden"},camera:{title:"Kameraansicht",invalidPrinterId:"Ungültige Drucker-ID",live:"Live",snapshot:"Schnappschuss",restartStream:"Stream neu starten",refreshSnapshot:"Schnappschuss aktualisieren",fullscreen:"Vollbild",exitFullscreen:"Vollbild beenden",connectingToCamera:"Verbinde mit Kamera...",capturingSnapshot:"Schnappschuss wird aufgenommen...",connectionLost:"Verbindung verloren",connectionFailed:"Kameraverbindung fehlgeschlagen",reconnecting:"Neuverbindung in {{countdown}}s... (Versuch {{attempt}}/{{max}})",reconnectNow:"Jetzt verbinden",cameraUnavailable:"Kamera nicht verfügbar",cameraUnavailableDesc:"Stellen Sie sicher, dass der Drucker eingeschaltet und verbunden ist.",noCamera:"Keine Kamera verfügbar",retry:"Erneut versuchen",cameraStream:"Kamera-Stream",zoomOut:"Verkleinern",zoomIn:"Vergrößern",resetZoom:"Zoom zurücksetzen",recording:"Aufnahme",startRecording:"Aufnahme starten",stopRecording:"Aufnahme stoppen"},groups:{title:"Gruppenverwaltung",subtitle:"Berechtigungsgruppen für Zugriffskontrolle verwalten",backToSettings:"Zurück zu Einstellungen",createGroup:"Gruppe erstellen",noPermission:"Sie haben keine Berechtigung, auf diese Seite zuzugreifen.",system:"System",noDescription:"Keine Beschreibung",usersCount:"{{count}} Benutzer",permissionsCount:"{{count}} Berechtigungen",edit:"Bearbeiten",delete:"Löschen",toast:{created:"Gruppe erfolgreich erstellt",updated:"Gruppe erfolgreich aktualisiert",deleted:"Gruppe erfolgreich gelöscht",enterGroupName:"Bitte geben Sie einen Gruppennamen ein"},modal:{editGroup:"Gruppe bearbeiten",createGroup:"Gruppe erstellen",cancel:"Abbrechen",saving:"Speichern...",creating:"Erstellen...",saveChanges:"Änderungen speichern"},form:{groupName:"Gruppenname",groupNamePlaceholder:"Gruppennamen eingeben",systemGroupWarning:"Systemgruppennamen können nicht geändert werden",description:"Beschreibung",descriptionPlaceholder:"Beschreibung eingeben (optional)",permissions:"Berechtigungen ({{count}} ausgewählt)"},deleteModal:{title:"Gruppe löschen",message:"Sind Sie sicher, dass Sie diese Gruppe löschen möchten? Benutzer in dieser Gruppe verlieren diese Berechtigungen.",confirm:"Gruppe löschen"}},users:{title:"Benutzerverwaltung",subtitle:"Benutzer und deren Zugriff auf Ihre Bambuddy-Instanz verwalten",backToSettings:"Zurück zu Einstellungen",createUser:"Benutzer erstellen",noPermission:"Sie haben keine Berechtigung, auf diese Seite zuzugreifen.",admin:"Admin",noGroups:"Keine Gruppen",active:"Aktiv",inactive:"Inaktiv",edit:"Bearbeiten",delete:"Löschen",system:"System",noGroupsAvailable:"Keine Gruppen verfügbar",table:{username:"Benutzername",groups:"Gruppen",status:"Status",actions:"Aktionen"},toast:{created:"Benutzer erfolgreich erstellt",updated:"Benutzer erfolgreich aktualisiert",deleted:"Benutzer erfolgreich gelöscht",fillRequired:"Bitte füllen Sie alle Pflichtfelder aus",passwordsDoNotMatch:"Passwörter stimmen nicht überein",passwordTooShort:"Passwort muss mindestens 6 Zeichen lang sein"},modal:{createUser:"Benutzer erstellen",editUser:"Benutzer bearbeiten",cancel:"Abbrechen",creating:"Erstellen...",saving:"Speichern...",saveChanges:"Änderungen speichern"},form:{username:"Benutzername",usernamePlaceholder:"Benutzernamen eingeben",password:"Passwort",passwordPlaceholder:"Passwort eingeben",confirmPassword:"Passwort bestätigen",confirmPasswordPlaceholder:"Passwort bestätigen",newPasswordPlaceholder:"Neues Passwort eingeben",confirmNewPasswordPlaceholder:"Neues Passwort bestätigen",leaveBlankToKeep:"leer lassen, um das aktuelle zu behalten",groups:"Gruppen"},deleteModal:{title:"Benutzer löschen",message:"Sind Sie sicher, dass Sie diesen Benutzer löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.",confirm:"Benutzer löschen"}},streamOverlay:{title:"Stream-Overlay",invalidPrinterId:"Ungültige Drucker-ID",cameraStream:"Kamera-Stream",progress:"Fortschritt",eta:"ETA",tomorrow:"Morgen",printerIdle:"Drucker ist inaktiv",printerOffline:"Drucker offline",status:{printing:"Druckt",paused:"Pausiert",finished:"Fertig",failed:"Fehlgeschlagen",idle:"Inaktiv",unknown:"Unbekannt"}},profiles:{title:"Profile",subtitle:"Verwalten Sie Ihre Slicer-Voreinstellungen und Druckvorschub-Kalibrierungen",tabs:{cloud:"Cloud-Profile",kprofiles:"K-Profile"},connectedAs:"Verbunden als",logout:"Abmelden",noLogoutPermission:"Sie haben keine Berechtigung zum Abmelden",failedToLoad:"Profile konnten nicht geladen werden",retry:"Erneut versuchen",time:{justNow:"Gerade eben",minsAgo:"vor {{count}}m",hoursAgo:"vor {{count}}h",daysAgo:"vor {{count}}d"},toast:{loggedOut:"Abgemeldet"},login:{title:"Mit Bambu Cloud verbinden",subtitle:"Synchronisieren Sie Ihre Slicer-Voreinstellungen geräteübergreifend",email:"E-Mail",password:"Passwort",region:"Region",regionGlobal:"Global",regionChina:"China",verificationCode:"Bestätigungscode",totpCode:"Authenticator-Code",checkEmail:"Prüfen Sie Ihre E-Mail ({{email}}) für einen 6-stelligen Code",enterTotpHint:"Geben Sie den 6-stelligen Code aus Ihrer Authenticator-App ein",accessToken:"Zugriffstoken",accessTokenHint:"Fügen Sie Ihr Bambu Lab Zugriffstoken ein (aus Bambu Studio)",back:"Zurück",loginButton:"Anmelden",verifyButton:"Bestätigen",setTokenButton:"Token setzen",useToken:"Stattdessen Zugriffstoken verwenden",useEmail:"Stattdessen mit E-Mail anmelden",toast:{loggedIn:"Erfolgreich angemeldet",codeSent:"Bestätigungscode an Ihre E-Mail gesendet",enterTotp:"Geben Sie den Code aus Ihrer Authenticator-App ein",tokenSet:"Token erfolgreich gesetzt"}},presets:{myPreset:"Mein Profil (bearbeitbar)",duplicate:"Duplizieren",editable:"Bearbeitbar",failedToLoadDetails:"Profil-Details konnten nicht geladen werden",deleteConfirm:"Dieses Profil löschen?",deleteWarning:'"{{name}}" wird dauerhaft aus Bambu Cloud gelöscht. Dies kann nicht rückgängig gemacht werden.',noDuplicatePermission:"Sie haben keine Berechtigung zum Duplizieren von Profilen",noEditPermission:"Sie haben keine Berechtigung zum Bearbeiten von Profilen",noDeletePermission:"Sie haben keine Berechtigung zum Löschen von Profilen",types:{filament:"Filament-Profil",printer:"Drucker-Profil",process:"Prozess-Profil"},toast:{deleted:"Profil gelöscht",created:"Profil erstellt",updated:"Profil aktualisiert",duplicated:"Profil dupliziert",fieldAdded:'Feld "{{key}}" hinzugefügt',exported:"Profil exportiert"},baseLabel:"Basis: {{name}}",currentLabel:"Aktuell: {{name}}",newPreset:"Neues Profil",editPreset:"Profil bearbeiten",duplicatePreset:"Profil duplizieren",createNewPreset:"Neues Profil erstellen",customizeSettings:"Passen Sie die Einstellungen für Ihr neues Profil an",compareWithBase:"Mit Basis-Profil vergleichen",compare:"Vergleichen",basePreset:"Basis-Profil",selectBasePreset:"Basis-Profil auswählen...",presetName:"Profilname",myCustomPreset:"Mein eigenes Profil",inheritsFrom:"Erbt von",dropJsonToImport:"JSON zum Importieren ablegen",tabs:{common:"Allgemein",allFields:"Alle Felder"},availableFields:"Verfügbare Felder",searchFieldsPlaceholder:"Felder suchen...",noMatchingFields:"Keine passenden Felder",allFieldsAdded:"Alle Felder hinzugefügt",addCustomField:"Eigenes Feld hinzufügen",yourOverrides:"Ihre Überschreibungen",noOverridesYet:"Noch keine Überschreibungen",clickFieldsToAdd:"Klicken Sie links auf Felder, um sie hinzuzufügen",saveAsTemplate:"Als Vorlage speichern",jsonTip:"Tipp: Ziehen Sie eine .json-Datei auf dieses Fenster, um Einstellungen zu importieren"},cloudView:{searchPlaceholder:"Profile suchen...",templates:"Vorlagen",refresh:"Aktualisieren",newPreset:"Neues Profil",clearFilters:"Filter zurücksetzen",compareMode:"Vergleichsmodus",selectAnotherPreset:"Wählen Sie ein weiteres {{type}}-Profil",clickTwoPresets:"Klicken Sie auf zwei Profile des gleichen Typs zum Vergleichen",selectFirst:"1. Erstes auswählen",selectSecond:"2. Zweites auswählen",compareNow:"Jetzt vergleichen",lastSynced:"Zuletzt synchronisiert:",showingCount:"{{showing}} von {{total}} Profilen",noPresetsFound:"Keine Profile gefunden",columns:{filament:"Filament",process:"Prozess",printer:"Drucker"},noFilamentPresets:"Keine Filament-Profile",noProcessPresets:"Keine Prozess-Profile",noPrinterPresets:"Keine Drucker-Profile",filters:{type:"Typ",owner:"Besitzer",printer:"Drucker",nozzle:"Düse",filament:"Filament",layer:"Schicht",all:"Alle",myPresets:"Meine Profile",builtIn:"Voreingestellt",process:"Prozess"},noTemplatesPermission:"Sie haben keine Berechtigung, Vorlagen zu verwalten",noRefreshPermission:"Sie haben keine Berechtigung, Profile zu aktualisieren",noCreatePermission:"Sie haben keine Berechtigung, Profile zu erstellen"},templates:{title:"Schnellvorlagen",noTemplates:"Noch keine Vorlagen",createFirst:"Erstellen Sie Vorlagen aus dem Preset-Editor",typeFilter:"Typ:",deleteTitle:"Vorlage löschen",deleteWarning:"Diese Aktion kann nicht rückgängig gemacht werden",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',namePlaceholder:"Vorlagenname",descriptionPlaceholder:"Beschreibung",settingsJson:"Einstellungen (JSON)",fieldsCount:"{{count}} Felder",shownInModals:"In Dialogen angezeigt",hiddenInModals:"In Dialogen ausgeblendet",apply:"Anwenden",toast:{deleted:"Vorlage gelöscht",updated:"Vorlage aktualisiert",created:"Vorlage erstellt",applied:"Vorlage angewendet"}}},support:{debugLoggingActive:"Debug-Protokollierung ist aktiv",manageLogs:"Verwalten"},fileManager:{title:"Dateimanager",subtitle:"Organisieren und verwalten Sie Ihre Druckdateien",uploadFiles:"Dateien hochladen",newFolder:"Neuer Ordner",folderName:"Ordnername",folderNamePlaceholder:"z.B. Funktionsteile",renameFile:"Datei umbenennen",renameFolder:"Ordner umbenennen",moveFiles:"{{count}} Datei(en) verschieben",rootNoFolder:"Stammverzeichnis (Kein Ordner)",current:"aktuell",linkFolder:"Ordner verknüpfen",linkFolderDescription:'"{{name}}" mit einem Projekt oder Archiv verknüpfen für schnellen Zugriff.',project:"Projekt",archive:"Archiv",noProjectsFound:"Keine Projekte gefunden",noArchivesFound:"Keine Archive gefunden",unlink:"Verknüpfung aufheben",link:"Verknüpfen",dragDropFiles:"Dateien hierher ziehen",dropFilesHere:"Dateien hier ablegen",orClickToBrowse:"oder klicken zum Durchsuchen",allFileTypesSupported:"Alle Dateitypen werden unterstützt. ZIP-Dateien werden extrahiert.",zipFilesDetected:"ZIP-Dateien erkannt",zipExtractOptions:"ZIP-Dateien werden extrahiert. Wählen Sie, wie die Ordnerstruktur behandelt werden soll:",preserveZipStructure:"Ordnerstruktur aus ZIP beibehalten",createFolderFromZip:"Ordner aus ZIP-Dateiname erstellen",stlThumbnailGeneration:"STL-Vorschaubildgenerierung",zipMayContainStl:"ZIP-Dateien können STL-Dateien enthalten. Vorschaubilder können während der Extraktion generiert werden.",thumbnailsCanBeGenerated:"Vorschaubilder können für STL-Dateien generiert werden. Große Modelle benötigen möglicherweise mehr Zeit.",generateThumbnailsForStl:"Vorschaubilder für STL-Dateien generieren",willBeExtracted:"Wird extrahiert",filesExtracted:"{{count}} Dateien extrahiert",uploadComplete:"Upload abgeschlossen: {{succeeded}} erfolgreich",uploadFailed:"{{count}} fehlgeschlagen",uploading:"Hochladen...",changeLink:"Verknüpfung ändern...",linkTo:"Verknüpfen mit...",linkToProjectOrArchive:"Mit Projekt oder Archiv verknüpfen",addToQueue:"Zur Warteschlange",generateThumbnail:"Vorschaubild generieren",generateThumbnails:"Vorschaubilder generieren",generateThumbnailsForMissing:"Vorschaubilder für STL-Dateien ohne Vorschau generieren",gridView:"Rasteransicht",listView:"Listenansicht",lowDiskSpaceWarning:"Warnung: Wenig Speicherplatz",lowDiskSpaceDetails:"Nur {{free}} frei von {{total}} gesamt. Schwellenwert ist auf {{threshold}} GB eingestellt.",files:"Dateien",folders:"Ordner",size:"Größe",free:"Frei",allFiles:"Alle Dateien",wrap:"Umbrechen",enableTextWrapping:"Textumbruch aktivieren",disableTextWrapping:"Textumbruch deaktivieren",dragToResizeTooltip:"Ziehen zum Ändern der Größe, Doppelklick zum Zurücksetzen",searchFiles:"Dateien suchen...",allTypes:"Alle Typen",prints:"Drucke",ascending:"Aufsteigend",descending:"Absteigend",resultsCount:"{{showing}} von {{total}} Dateien",selectAll:"Alle auswählen",deselectAll:"Auswahl aufheben",selected:"{{count}} ausgewählt",adding:"Hinzufügen...",loadingFiles:"Dateien werden geladen...",folderIsEmpty:"Ordner ist leer",noFilesYet:"Noch keine Dateien",folderEmptyDescription:"Laden Sie Dateien hoch oder verschieben Sie Dateien in diesen Ordner.",noFilesDescription:"Laden Sie Dateien hoch, um Ihre Druckdateien zu organisieren.",noMatchingFiles:"Keine passenden Dateien",noMatchingFilesDescription:"Keine Dateien entsprechen Ihren aktuellen Such- oder Filterkriterien.",clearFilters:"Filter zurücksetzen",printedCount:"{{count}}x gedruckt",uploadedBy:"Hochgeladen von {{name}}",deleteFolder:"Ordner löschen",deleteFile:"Datei löschen",deleteFilesCount:"{{count}} Dateien löschen",deleteFolderConfirm:"Möchten Sie diesen Ordner wirklich löschen? Alle Dateien darin werden ebenfalls gelöscht.",deleteFileConfirm:"Möchten Sie diese Datei wirklich löschen?",deleteFilesConfirm:"Möchten Sie {{count}} ausgewählte Dateien wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.",deleting:"Wird gelöscht...",noPermissionRenameFolder:"Sie haben keine Berechtigung, Ordner umzubenennen",noPermissionLinkFolder:"Sie haben keine Berechtigung, Ordner zu verknüpfen",noPermissionDeleteFolder:"Sie haben keine Berechtigung, Ordner zu löschen",noPermissionPrint:"Sie haben keine Berechtigung zum Drucken",noPermissionAddToQueue:"Sie haben keine Berechtigung, zur Warteschlange hinzuzufügen",noPermissionDownload:"Sie haben keine Berechtigung, Dateien herunterzuladen",noPermissionRenameFile:"Sie haben keine Berechtigung, diese Datei umzubenennen",noPermissionGenerateThumbnail:"Sie haben keine Berechtigung, Vorschaubilder zu generieren",noPermissionDeleteFile:"Sie haben keine Berechtigung, diese Datei zu löschen",noPermissionCreateFolder:"Sie haben keine Berechtigung, Ordner zu erstellen",noPermissionUpload:"Sie haben keine Berechtigung, Dateien hochzuladen",noPermissionMoveFiles:"Sie haben keine Berechtigung, Dateien zu verschieben",noPermissionDeleteFiles:"Sie haben keine Berechtigung, Dateien zu löschen",toast:{folderCreated:"Ordner erstellt",folderDeleted:"Ordner gelöscht",fileDeleted:"Datei gelöscht",filesDeleted:"{{count}} Dateien gelöscht",filesMoved:"Dateien verschoben",folderLinked:"Ordner verknüpft",folderUnlinked:"Ordnerverknüpfung aufgehoben",addedToQueue:"{{count}} Datei(en) zur Warteschlange hinzugefügt",addedToQueuePartial:"{{added}} Datei(en) hinzugefügt, {{failed}} fehlgeschlagen",failedToAddToQueue:"Fehler beim Hinzufügen: {{error}}",fileRenamed:"Datei umbenannt",folderRenamed:"Ordner umbenannt",thumbnailsGenerated:"{{count}} Vorschaubild(er) generiert",thumbnailsGeneratedPartial:"{{succeeded}} Vorschaubild(er) generiert, {{failed}} fehlgeschlagen",noStlMissingThumbnails:"Keine STL-Dateien ohne Vorschaubild",failedToGenerateThumbnails:"Fehler beim Generieren der Vorschaubilder: {{error}}",thumbnailGenerated:"Vorschaubild generiert",failedToGenerateThumbnail:"Fehler beim Generieren des Vorschaubildes: {{error}}"}},projects:{title:"Projekte",subtitle:"Organisieren und verfolgen Sie Ihre 3D-Druckprojekte",newProject:"Neues Projekt",editProject:"Projekt bearbeiten",deleteProject:"Projekt löschen",projectName:"Projektname",description:"Beschreibung",noProjects:"Noch keine Projekte",noProjectsFiltered:"Keine {{status}} Projekte",noProjectsFilteredHelp:"Sie haben keine {{status}} Projekte. Projekte werden hier angezeigt, wenn sich ihr Status ändert.",createFirst:"Erstellen Sie Ihr erstes Projekt, um verwandte Drucke zu organisieren, den Fortschritt zu verfolgen und Ihre Builds zu verwalten.",createFirstButton:"Erstes Projekt erstellen",create:"Erstellen",files:"Dateien",prints:"Drucke",plates:"Platten",parts:"Teile",lastModified:"Zuletzt geändert",deleteConfirm:"Möchten Sie dieses Projekt wirklich löschen? Archive und Warteschlangenelemente werden getrennt, aber nicht gelöscht.",addFiles:"Dateien hinzufügen",removeFile:"Datei entfernen",viewDetails:"Details anzeigen",namePlaceholder:"z.B. Voron 2.4 Build",descriptionPlaceholder:"Optionale Beschreibung...",color:"Farbe",targetPlates:"Ziel-Platten",targetPlatesPlaceholder:"z.B. 25",targetPlatesHelp:"Anzahl der Druckaufträge",targetParts:"Ziel-Teile",targetPartsPlaceholder:"z.B. 150",targetPartsHelp:"Benötigte Objekte insgesamt",tagsLabel:"Tags (kommagetrennt)",tagsPlaceholder:"z.B. voron, funktional, geschenk",dueDate:"Fälligkeitsdatum",priority:"Priorität",priorityLow:"Niedrig",priorityNormal:"Normal",priorityHigh:"Hoch",priorityUrgent:"Dringend",statusActive:"Aktiv",statusCompleted:"Abgeschlossen",statusArchived:"Archiviert",done:"Fertig",completed:"abgeschlossen",failed:"fehlgeschlagen",inQueue:"in Warteschlange",noPrintsYet:"Noch keine Drucke",printJobs:"Druckaufträge (Platten)",partsPrinted:"Gedruckte Teile",failedParts:"Fehlgeschlagene Teile",import:"Importieren",export:"Exportieren",importProject:"Projekt importieren",exportAll:"Alle Projekte exportieren",loading:"Projekte werden geladen...",noEditPermission:"Sie haben keine Berechtigung, Projekte zu bearbeiten",noDeletePermission:"Sie haben keine Berechtigung, Projekte zu löschen",noCreatePermission:"Sie haben keine Berechtigung, Projekte zu erstellen",noImportPermission:"Sie haben keine Berechtigung, Projekte zu importieren",noExportPermission:"Sie haben keine Berechtigung, Projekte zu exportieren",toast:{created:"Projekt erstellt",updated:"Projekt aktualisiert",deleted:"Projekt gelöscht",imported:"Projekt importiert",multipleImported:"{{count}} Projekte importiert",importFailed:"Import fehlgeschlagen",exported:"Projekte exportiert (nur Metadaten)"}},projectDetail:{notFound:"Projekt nicht gefunden",backToProjects:"Zurück zu Projekten",export:"Exportieren",exportProject:"Projekt exportieren",noExportPermission:"Sie haben keine Berechtigung, Projekte zu exportieren",noEditPermission:"Sie haben keine Berechtigung, Projekte zu bearbeiten",partOf:"Teil von:",priorityLabel:"Priorität:",noPrints:"Noch keine Drucke in diesem Projekt",status:{active:"Aktiv",completed:"Abgeschlossen",archived:"Archiviert"},priority:{low:"Niedrig",normal:"Normal",high:"Hoch",urgent:"Dringend"},dueDate:{overdue:"Überfällig",today:"Heute fällig",daysLeft:"{{count}} Tage übrig"},progress:{platesProgress:"Platten-Fortschritt",partsProgress:"Teile-Fortschritt",printJobs:"Druckaufträge",parts:"Teile",percentComplete:"{{percent}}% abgeschlossen",remaining:"{{count}} verbleibend"},stats:{printJobs:"Druckaufträge",total:"gesamt",failed:"{{count}} fehlgeschlagen",partsPrinted:"{{count}} Teile gedruckt",printTime:"Druckzeit",filamentUsed:"Filament verbraucht"},cost:{title:"Kostenverfolgung",filamentCost:"Filamentkosten",energy:"Energie",budget:"Budget",remaining:"Verbleibend"},subProjects:{title:"Unterprojekte ({{count}})"},notes:{title:"Notizen",noEditPermission:"Sie haben keine Berechtigung, Notizen zu bearbeiten",placeholder:"Notizen zu diesem Projekt hinzufügen...",empty:"Noch keine Notizen. Klicken Sie auf Bearbeiten, um Notizen hinzuzufügen."},files:{title:"Dateien",linkFolders:"Ordner aus dem Dateimanager verknüpfen",forQuickAccess:"für schnellen Zugriff auf dieses Projekt.",fileCount:"{{count}} Datei(en)",empty:"Keine Ordner verknüpft. Gehen Sie zum Dateimanager und verknüpfen Sie einen Ordner mit diesem Projekt."},bom:{title:"Stückliste",acquired:"{{completed}}/{{total}} beschafft",showAll:"Alle anzeigen",hideDone:"Erledigte ausblenden",addPart:"Teil hinzufügen",noAddPermission:"Sie haben keine Berechtigung, Teile hinzuzufügen",partNamePlaceholder:"Teilename (z.B. M3x8 Schrauben)",partName:"Teilename",qty:"Menge",price:"Preis ({{currency}})",sourcingUrlPlaceholder:"Bezugsquelle-URL (optional)",remarksPlaceholder:"Bemerkungen (optional)",deletePart:"Teil löschen",deleteConfirm:'Möchten Sie "{{name}}" wirklich löschen?',noUpdatePermission:"Sie haben keine Berechtigung, Teile zu aktualisieren",noEditPermission:"Sie haben keine Berechtigung, Teile zu bearbeiten",noDeletePermission:"Sie haben keine Berechtigung, Teile zu löschen",totalCost:"Gesamtkosten:",empty:"Keine Teile in der Stückliste. Fügen Sie Hardware, Elektronik oder andere Komponenten hinzu, um zu verfolgen, was beschafft werden muss."},timeline:{title:"Aktivitätsverlauf",empty:"Noch keine Aktivität."},template:{saveAsTemplate:"Als Vorlage speichern",noCreatePermission:"Sie haben keine Berechtigung, Vorlagen zu erstellen"},queue:{title:"Warteschlange",viewAll:"Alle anzeigen",printing:"{{count}} druckend",queued:"{{count}} in Warteschlange"},prints:{title:"Drucke ({{count}})"},toast:{projectUpdated:"Projekt aktualisiert",partAdded:"Teil hinzugefügt",partRemoved:"Teil entfernt",exportFailed:"Export fehlgeschlagen",projectExported:"Projekt exportiert",templateCreated:"Vorlage erstellt"}},system:{title:"Systeminformationen",version:"Version",uptime:"Laufzeit",cpuUsage:"CPU-Auslastung",memoryUsage:"Speicherauslastung",diskUsage:"Festplattenauslastung",networkInfo:"Netzwerkinformationen",logs:"Protokolle",debugMode:"Debug-Modus",enableDebug:"Debug-Protokollierung aktivieren",disableDebug:"Debug-Protokollierung deaktivieren",downloadLogs:"Protokolle herunterladen",clearLogs:"Protokolle löschen",dockerInfo:"Docker-Info",containerName:"Container-Name",imageName:"Image-Name",platform:"Plattform",architecture:"Architektur"},library:{title:"Filament-Bibliothek",addFilament:"Filament hinzufügen",editFilament:"Filament bearbeiten",deleteFilament:"Filament löschen",vendor:"Hersteller",material:"Material",color:"Farbe",kFactor:"K-Faktor",temperature:"Temperatur",noFilaments:"Keine Filamente in der Bibliothek",deleteConfirm:"Möchten Sie dieses Filament wirklich löschen?",importFromPrinter:"Vom Drucker importieren",exportToFile:"In Datei exportieren"},spoolman:{title:"Spoolman-Integration",enabled:"Spoolman aktiviert",url:"Spoolman URL",connected:"Verbunden",disconnected:"Nicht verbunden",testConnection:"Verbindung testen",sync:"Synchronisieren",syncing:"Synchronisiert...",lastSync:"Letzte Synchronisierung",linkToSpoolman:"Mit Spoolman verknüpfen",openInSpoolman:"In Spoolman öffnen",unlinkSpool:"Spule trennen",selectSpool:"Spule auswählen",noUnlinkedSpools:"Keine nicht verknüpften Spulen verfügbar",linkSuccess:"Spule erfolgreich mit Spoolman verknüpft",linkFailed:"Verknüpfung mit Spoolman fehlgeschlagen",spoolId:"Spulen-ID",weight:"Gewicht",remaining:"Verbleibend"},timelapse:{title:"Zeitraffer",create:"Zeitraffer erstellen",download:"Herunterladen",delete:"Löschen",preview:"Vorschau",frameRate:"Bildrate",quality:"Qualität",processing:"Wird verarbeitet...",noTimelapses:"Keine Zeitraffer verfügbar"},ams:{title:"AMS",slot:"Slot",empty:"Leer",emptySlot:"Leerer Slot",unknown:"Unbekannt",humidity:"Luftfeuchtigkeit",temperature:"Temperatur",filamentType:"Filamenttyp",filamentColor:"Farbe",remaining:"Verbleibend",history:"AMS-Verlauf",noHistory:"Kein Verlauf verfügbar",configureSlot:"Slot konfigurieren",externalSpool:"Externe Spule",profile:"Profil",kFactor:"K-Faktor",fill:"Füllstand",configure:"Konfigurieren"},printModal:{title:"Druck starten",selectPrinter:"Drucker auswählen",selectPlate:"Platte auswählen",filamentMapping:"Filamentzuordnung",printSettings:"Druckeinstellungen",bedLeveling:"Bett-Nivellierung",flowCalibration:"Fluss-Kalibrierung",vibrationCalibration:"Vibrations-Kalibrierung",layerInspection:"Erste-Schicht-Prüfung",timelapse:"Zeitraffer",startPrint:"Druck starten",addToQueue:"Zur Warteschlange hinzufügen",cancel:"Abbrechen",noPrintersAvailable:"Keine Drucker verfügbar",printerBusy:"Drucker ist beschäftigt",printerOffline:"Drucker ist offline"},backup:{title:"Sichern & Wiederherstellen",createBackup:"Sicherung erstellen",restoreBackup:"Sicherung wiederherstellen",restoreDescription:"Alle Daten aus einer Sicherungsdatei ersetzen",downloadBackup:"Sicherung herunterladen",uploadBackup:"Sicherung hochladen",lastBackup:"Letzte Sicherung",autoBackup:"Automatische Sicherung",backupNow:"Jetzt sichern",restoreWarning:"Warnung: Das Wiederherstellen einer Sicherung überschreibt alle aktuellen Daten.",includeArchives:"Archive einschließen",includeSettings:"Einstellungen einschließen",includeProfiles:"Profile einschließen",backupSuccess:"Sicherung erfolgreich erstellt",restoreSuccess:"Sicherung erfolgreich wiederhergestellt",backupFailed:"Sicherung fehlgeschlagen",restoreFailed:"Wiederherstellung fehlgeschlagen",restoreNote:"Virtueller Drucker wird während der Wiederherstellung gestoppt"},tags:{title:"Tags",addTag:"Tag hinzufügen",editTag:"Tag bearbeiten",deleteTag:"Tag löschen",tagName:"Tag-Name",tagColor:"Tag-Farbe",noTags:"Keine Tags",deleteConfirm:"Möchten Sie diesen Tag wirklich löschen?",manageTags:"Tags verwalten"},uploadModal:{title:"3MF-Dateien hochladen",dragDrop:"3MF-Dateien hierher ziehen",or:"oder",browseFiles:"Dateien durchsuchen",extractionInfo:"Das Druckermodell wird automatisch aus den 3MF-Datei-Metadaten extrahiert.",uploaded:"hochgeladen",failed:"fehlgeschlagen",uploading:"Wird hochgeladen...",upload:"Hochladen",uploadFailed:"Hochladen fehlgeschlagen"},editArchive:{title:"Archiv bearbeiten",name:"Name",namePlaceholder:"Druckname",printer:"Drucker",noPrinter:"Kein Drucker",project:"Projekt",noProject:"Kein Projekt",itemsPrinted:"Gedruckte Teile",itemsPrintedHelp:"Anzahl der in diesem Druckauftrag produzierten Teile",notes:"Notizen",notesPlaceholder:"Notizen zu diesem Druck hinzufügen...",externalLink:"Externer Link",externalLinkPlaceholder:"https://printables.com/model/...",externalLinkHelp:"Link zu Printables, Thingiverse oder anderer Quelle",tags:"Tags",tagsPlaceholder:"Tags hinzufügen...",addMoreTags:"Weitere Tags hinzufügen...",matchingTags:'Übereinstimmend mit "{{query}}"',existingTags:"Vorhandene Tags",clickToAdd:"(zum Hinzufügen klicken)",status:"Status",failureReason:"Fehlergrund",selectReason:"Grund auswählen...",photos:"Fotos des Druckergebnisses",photosHelp:"Klicken Sie auf + um Fotos Ihres Druckergebnisses hinzuzufügen",printResult:"Druckergebnis",saving:"Wird gespeichert...",failureReasons:{adhesionFailure:"Haftungsfehler",spaghettiDetached:"Spaghetti / Abgelöst",layerShift:"Schichtversatz",cloggedNozzle:"Verstopfte Düse",filamentRunout:"Filament aufgebraucht",warping:"Verformung",stringing:"Fadenziehen",underExtrusion:"Unterextrusion",powerFailure:"Stromausfall",userCancelled:"Vom Benutzer abgebrochen",other:"Sonstiges"},statuses:{completed:"Abgeschlossen",failed:"Fehlgeschlagen",aborted:"Abgebrochen",printing:"Druckt"}},kProfiles:{title:"K-Profile",noPrintersConfigured:"Keine Drucker konfiguriert",addPrinterInSettings:"Fügen Sie einen Drucker in den Einstellungen hinzu, um K-Profile zu verwalten",noActivePrinters:"Keine aktiven Drucker",enablePrinterConnection:"Aktivieren Sie eine Druckerverbindung, um K-Profile anzuzeigen",loadingProfiles:"Lade K-Profile...",printerOffline:"Drucker offline",printerOfflineDesc:"Der ausgewählte Drucker ist nicht verbunden. Schalten Sie ihn ein, um K-Profile anzuzeigen.",noMatchingProfiles:"Keine passenden Profile",noMatchingProfilesDesc:"Keine Profile entsprechen Ihren Suchkriterien",noKProfiles:"Keine K-Profile",noKProfilesDesc:"Keine Druckvorschub-Profile für {{diameter}}mm Düse gefunden",createFirstProfile:"Erstes Profil erstellen",printer:"Drucker",nozzle:"Düse",refresh:"Aktualisieren",addProfile:"Profil hinzufügen",export:"Exportieren",import:"Importieren",select:"Auswählen",selectAll:"Alle auswählen",delete:"Löschen",searchPlaceholder:"Nach Name oder Filament suchen...",allExtruders:"Alle Extruder",leftOnly:"Nur links",rightOnly:"Nur rechts",allFlow:"Alle Flusstypen",hfOnly:"Nur HF",sOnly:"Nur S",sortName:"Sortieren: Name",sortKValue:"Sortieren: K-Wert",sortFilament:"Sortieren: Filament",leftExtruder:"Linker Extruder",rightExtruder:"Rechter Extruder",modal:{addTitle:"K-Profil hinzufügen",editTitle:"K-Profil bearbeiten",profileName:"Profilname",profileNamePlaceholder:"Mein PLA-Profil",kValue:"K-Wert",kValuePlaceholder:"0,020",kValueHelp:"Typischer Bereich: 0,01 - 0,06 für PLA, 0,02 - 0,10 für PETG",filament:"Filament",selectFilament:"Filament auswählen...",noFilamentsHelp:"Keine Filamente gefunden. Erstellen Sie zuerst ein K-Profil in Bambu Studio.",flowType:"Flusstyp",highFlow:"High Flow",standard:"Standard",nozzleSize:"Düsengröße",extruder:"Extruder",extruders:"Extruder",left:"Links",right:"Rechts",notes:"Notizen (lokal gespeichert)",notesPlaceholder:"Notizen zu diesem Profil hinzufügen...",notesHelp:"Notizen werden in Bambuddy gespeichert, nicht auf dem Drucker",syncing:"Synchronisiert mit Drucker...",savingExtruder:"Speichern auf Extruder {{current}}/{{total}}...",pleaseWait:"Bitte warten"},deleteConfirm:{title:"Profil löschen",cannotUndo:"Dies kann nicht rückgängig gemacht werden",message:'Möchten Sie "{{name}}" wirklich vom Drucker löschen?'},bulkDelete:{title:"Profile löschen",cannotUndo:"Dies kann nicht rückgängig gemacht werden",message:"Möchten Sie wirklich {{count}} ausgewählte Profile vom Drucker löschen?"},toast:{profileSaved:"K-Profil gespeichert",profilesSaved:"K-Profil auf {{count}} Extrudern gespeichert",selectAtLeastOneExtruder:"Bitte wählen Sie mindestens einen Extruder aus",profileDeleted:"K-Profil gelöscht",profilesDeleted:"{{count}} Profile gelöscht",exportedProfiles:"{{count}} Profile exportiert",importedProfiles:"{{count}} von {{total}} Profilen importiert",noProfilesToExport:"Keine Profile zum Exportieren",invalidFileFormat:"Ungültiges Dateiformat",failedToParseImport:"Import-Datei konnte nicht gelesen werden",failedToSaveBatch:"K-Profile konnten nicht gespeichert werden",noteSaved:"Notiz gespeichert",failedToSaveNote:"Notiz konnte nicht gespeichert werden"},permission:{noRead:"Sie haben keine Berechtigung, Profile zu aktualisieren",noCreate:"Sie haben keine Berechtigung, Profile hinzuzufügen",noUpdate:"Sie haben keine Berechtigung, K-Profile zu aktualisieren",noDelete:"Sie haben keine Berechtigung, K-Profile zu löschen",noExport:"Sie haben keine Berechtigung, Profile zu exportieren",noImport:"Sie haben keine Berechtigung, Profile zu importieren"}},virtualPrinter:{title:"Virtueller Drucker",running:"Läuft",stopped:"Gestoppt",description:{default:"Aktiviere einen virtuellen Drucker, der in Bambu Studio und OrcaSlicer erscheint. Dateien, die an diesen Drucker gesendet werden, werden direkt archiviert ohne zu drucken.",proxy:"Aktiviere einen Proxy, der Slicer-Datenverkehr an einen echten Drucker weiterleitet, um Ferndruck über jedes Netzwerk zu ermöglichen."},enable:{title:"Virtuellen Drucker aktivieren",visibleInSlicer:'Sichtbar als "Bambuddy" in der Slicer-Erkennung',proxyingTo:"Proxy zu {{name}}",notActive:"Nicht aktiv"},model:{title:"Druckermodell",description:"Wähle welches Druckermodell emuliert werden soll.",restartWarning:"Das Ändern des Modells startet den virtuellen Drucker neu"},accessCode:{title:"Zugangscode",isSet:"Zugangscode ist gesetzt",notSet:"Kein Zugangscode gesetzt - erforderlich zum Aktivieren",placeholder:"8-Zeichen-Code eingeben",placeholderChange:"Neuen Code eingeben zum Ändern",hint:"Muss genau 8 Zeichen lang sein. Wird von Slicern zur Authentifizierung verwendet.",charCount:"({{count}}/8)"},targetPrinter:{title:"Zieldrucker",configured:"Proxy-Ziel konfiguriert",notConfigured:"Kein Zieldrucker ausgewählt - erforderlich für Proxy-Modus",placeholder:"Drucker auswählen...",hint:"Wähle den Drucker aus, an den der Slicer-Datenverkehr weitergeleitet werden soll. Der Drucker muss im LAN-Modus sein.",noPrinters:"Keine Drucker konfiguriert. Füge zuerst einen Drucker hinzu, um den Proxy-Modus zu verwenden."},mode:{title:"Modus",archive:"Archivieren",archiveDesc:"Dateien sofort archivieren",review:"Überprüfen",reviewDesc:"Vor dem Archivieren überprüfen",queue:"Warteschlange",queueDesc:"Archivieren und zur Warteschlange hinzufügen",proxy:"Proxy",proxyDesc:"An echten Drucker weiterleiten"},setupRequired:{title:"Einrichtung erforderlich",description:"Die virtuelle Druckerfunktion erfordert zusätzliche Systemkonfiguration, bevor sie funktioniert. Dies beinhaltet Portweiterleitung, Firewall-Regeln und plattformspezifische Einstellungen.",readGuide:"Lese die Einrichtungsanleitung vor dem Aktivieren"},howItWorks:{title:"So funktioniert es",titleProxy:"So funktioniert es (Proxy-Modus)",step1:"Schließe die Einrichtungsanleitung für deine Plattform ab",step2:"Aktiviere den virtuellen Drucker und setze einen Zugangscode",step3:'In Bambu Studio oder OrcaSlicer gehe zu "Drucker hinzufügen"',step4:'Der "Bambuddy"-Drucker sollte in der Erkennungsliste erscheinen',step5:"Verbinde mit dem von dir gesetzten Zugangscode",step6:'Wenn du zu Bambuddy "druckst", wird die 3MF-Datei stattdessen archiviert',proxyStep1:"Setze die Zieldrucker-IP (muss in deinem LAN sein)",proxyStep2:"Konfiguriere Portweiterleitung zu Bambuddy (Ports 9990, 8883)",proxyStep3:"Füge in deinem Slicer manuell einen Netzwerkdrucker hinzu",proxyStep4:"Gib Bambuddys externe Adresse und den Zugangscode des Druckers ein",proxyStep5:"Drucke wie gewohnt - der Datenverkehr wird an den echten Drucker weitergeleitet"},status:{title:"Status-Details",printerName:"Druckername",model:"Modell",serialNumber:"Seriennummer",mode:"Modus",pendingFiles:"Ausstehende Dateien",targetPrinter:"Zieldrucker",ftpPort:"FTP-Port",mqttPort:"MQTT-Port",ftpConnections:"FTP-Verbindungen",mqttConnections:"MQTT-Verbindungen"},toast:{updated:"Virtuelle Druckereinstellungen aktualisiert",failedToUpdate:"Einstellungen konnten nicht aktualisiert werden",accessCodeRequired:"Bitte zuerst einen Zugangscode setzen",targetPrinterRequired:"Bitte zuerst einen Zieldrucker auswählen",accessCodeEmpty:"Zugangscode darf nicht leer sein",accessCodeLength:"Zugangscode muss genau 8 Zeichen lang sein"}},maintenanceDescriptions:{lubricateRails:"Schmiermittel auf Linearschienen für sanfte Bewegung auftragen",cleanNozzle:"Hotend und Düse reinigen, um Verstopfungen zu verhindern",checkBelts:"Riemenspannung für präzise Drucke überprüfen",cleanBuildPlate:"Druckplatte für bessere Haftung reinigen",checkExtruder:"Extruderzahnräder auf Verschleiß prüfen",checkCooling:"Sicherstellen, dass Lüfter ordnungsgemäß funktionieren",generalInspection:"Allgemeine Druckerinspektion",cleanCarbonRods:"Karbonstäbe reinigen, um Reibung zu reduzieren",checkPtfeTube:"PTFE-Schlauch auf Verschleiß oder Beschädigung prüfen",replaceHepaFilter:"HEPA-Filter für Luftqualität ersetzen",replaceCarbonFilter:"Aktivkohlefilter ersetzen",lubricateLeftNozzleRail:"Linke Düsenschiene schmieren (H2-Serie)"}},Jse={nav:{printers:"プリンター",archives:"アーカイブ",queue:"キュー",stats:"統計",profiles:"プロファイル",maintenance:"メンテナンス",projects:"プロジェクト",files:"ファイル管理",settings:"設定",system:"システム",collapseSidebar:"サイドバーを閉じる",expandSidebar:"サイドバーを開く",update:"アップデート",updateAvailable:"アップデートあり: v{{version}}",viewOnGithub:"GitHubで表示",keyboardShortcuts:"キーボードショートカット (?)",switchToLight:"ライトモードに切替",switchToDark:"ダークモードに切替"},common:{save:"保存",cancel:"キャンセル",delete:"削除",edit:"編集",add:"追加",close:"閉じる",confirm:"確認",loading:"読み込み中...",error:"エラー",success:"成功",warning:"警告",enabled:"有効",disabled:"無効",yes:"はい",no:"いいえ",on:"オン",off:"オフ",all:"すべて",none:"なし",search:"検索",filter:"フィルター",sort:"並べ替え",refresh:"更新",download:"ダウンロード",upload:"アップロード",actions:"操作",status:"ステータス",name:"名前",description:"説明",date:"日付",time:"時間",hours:"時間",minutes:"分",seconds:"秒",noPrinters:"プリンターが登録されていません",noData:"データがありません",required:"必須",optional:"オプション",unknown:"不明",done:"完了",saving:"保存中...",saveChanges:"変更を保存",today:"今日",turnOn:"オンにする",turnOff:"オフにする",deletePhoto:"写真を削除",deletePhotoConfirm:"この写真を削除しますか?元に戻せません。",create:"作成",print:"印刷",clear:"クリア",project:"プロジェクト",archive:"アーカイブ",unknownError:"不明なエラー",show:"表示",hide:"非表示",back:"戻る",export:"エクスポート",import:"インポート",retry:"リトライ",printer:"プリンター",model:"モデル",ok:"OK"},printers:{title:"プリンター",addPrinter:"プリンターを追加",editPrinter:"プリンターを編集",deletePrinter:"プリンターを削除",printerName:"プリンター名",serialNumber:"シリアル番号",ipAddress:"IPアドレス",accessCode:"アクセスコード",model:"モデル",nozzleCount:"ノズル数",autoArchive:"自動アーカイブ",connected:"接続中",offline:"オフライン",unknownModel:"不明なモデル",statusLabel:"ステータス",status:{printing:"印刷中",paused:"一時停止",finished:"完了",failed:"失敗",idle:"待機中"},lastPrint:"最後",readyToPrint:"印刷可能",estimatedCompletion:"完了予定時刻",filaments:"フィラメント",controls:"コントロール",external:"外部",externalSpool:"外部スプール",files:"ファイル",browseFiles:"プリンターのファイルを参照",update:"アップデート",loading:"プリンターを読み込み中...",hideOffline:"オフラインを非表示",ungrouped:"未グループ",hmsErrors:"クリックしてHMSエラーを表示",slotOptions:"スロットオプション",rereadRfid:"RFIDを再読み取り",clickToView:"クリックして表示",maintenanceUpToDate:"すべてのメンテナンスが最新です",maintenanceDue:"{{count}}件のメンテナンス期限",maintenanceDueSoon:"{{count}}件のメンテナンスがまもなく期限",printsInQueue:"キューに{{count}}件の印刷",firmwareUpdateAvailable:"ファームウェアアップデートあり: {{current}} → {{latest}}",statusSummary:{printing:"印刷中",idle:"待機中",offline:"オフライン"},sort:{name:"名前",status:"ステータス",model:"モデル",location:"ロケーション",ascending:"昇順で並べ替え",descending:"降順で並べ替え"},cardSize:{small:"小",medium:"中",large:"大",extraLarge:"特大",cards:"カード"},temps:{nozzle:"ノズル",bed:"ベッド",chamber:"チャンバー",left:"左",right:"右",activeNozzle:"アクティブ: {{side}}ノズル"},fans:{partCooling:"パーツ冷却ファン",auxiliary:"補助ファン",chamber:"チャンバーファン"},printControl:{stop:"停止",pause:"一時停止",resume:"再開",stopPrint:"印刷を停止",pausePrint:"印刷を一時停止",resumePrint:"印刷を再開"},power:{on:"オン",off:"オフ",powerOn:"電源オン",autoOff:"自動オフ",autoOffDone:"自動オフ完了",autoOffTooltip:"印刷後に自動電源オフ",autoOffExecutedTooltip:"自動オフが実行されました - リセットするにはプリンターの電源を入れてください",offlineWithPlugs:"スマートプラグ付きオフラインプリンター",noPlugs:"スマートプラグ付きプリンターなし"},chamberLight:{turnOn:"チャンバーライトをオン",turnOff:"チャンバーライトをオフ"},camera:{openOverlay:"カメラオーバーレイを開く",openWindow:"カメラを新しいウィンドウで開く"},menu:{reconnect:"再接続",mqttDebug:"MQTTデバッグ"},confirm:{deleteTitle:"プリンターを削除",deleteMessage:"「{{name}}」を削除しますか?すべての接続設定が削除されます。",deleteArchives:"印刷アーカイブを削除",deleteArchivesYes:"このプリンターのすべての印刷履歴が完全に削除されます。",deleteArchivesNo:"印刷履歴は保持されますが、このプリンターとの関連付けは解除されます。",powerOnTitle:"プリンターの電源をオン",powerOnMessage:"「{{name}}」の電源をオンにしますか?",powerOn:"電源オン",powerOffTitle:"プリンターの電源をオフ",powerOffMessage:"「{{name}}」の電源をオフにしますか?",powerOffWarning:"警告: 「{{name}}」は現在印刷中です!電源をオフにしますか?印刷が中断され、プリンターが損傷する可能性があります。",powerOff:"電源オフ",stopTitle:"印刷を停止",stopMessage:"「{{name}}」の現在の印刷を停止しますか?印刷ジョブがキャンセルされます。",stopButton:"印刷を停止",pauseTitle:"印刷を一時停止",pauseMessage:"「{{name}}」の現在の印刷を一時停止しますか?",pauseButton:"印刷を一時停止",resumeTitle:"印刷を再開",resumeMessage:"「{{name}}」の印刷を再開しますか?",resumeButton:"印刷を再開"},skipObjects:{title:"オブジェクトスキップ",onlyWhilePrinting:"オブジェクトスキップ(印刷中のみ)",requires2Objects:"オブジェクトスキップ(2つ以上のオブジェクトが必要)",noObjects:"オブジェクトが見つかりません",objectsLoadedOnStart:"オブジェクトは印刷開始時に読み込まれます",matchIds:"プリンターのディスプレイとIDを照合してください",printerScreenShows:"プリンター画面にビルドプレート上のオブジェクトIDが表示されます",skippedCount:"{{skipped}}/{{total}}スキップ済み",waitForLayer:"オブジェクトをスキップするにはレイヤー2以降をお待ちください(現在レイヤー{{layer}})",activeCount:"{{count}}個アクティブ",willBeSkipped:"スキップされます",waitForLayer2:"レイヤー2以降をお待ちください",skipThisObject:"このオブジェクトをスキップ",skip:"スキップ",skipped:"スキップ済み"},form:{name:"名前",namePlaceholder:"マイプリンター",ipAddress:"IPアドレス",serialNumber:"シリアル番号",serialCannotChange:"シリアル番号は変更できません",accessCode:"アクセスコード",accessCodePlaceholder:"プリンター設定から取得",accessCodeKeepCurrent:"現在のコードを維持する場合は空のまま",modelOptional:"モデル(任意)",model:"モデル",selectModel:"モデルを選択...",locationGroup:"ロケーション / グループ",locationPlaceholder:"例: 工房、オフィス、地下室",locationHint:"プリンターのグループ化とキュージョブのフィルタリングに使用",autoArchive:"完了した印刷を自動アーカイブ"},discovery:{subnetToScan:"スキャンするサブネット",dockerSubnetHint:"Dockerが検出されました。CIDR表記でプリンターのサブネットを入力してください。docker-compose.ymlにnetwork_mode: hostが必要です。",scanning:"スキャン中...",scanningProgress:"スキャン中... {{scanned}}/{{total}}",scanSubnet:"サブネットをスキャンしてプリンターを検出",discoverNetwork:"ネットワーク上のプリンターを検出",serialRequired:"シリアル番号が必要です",scanningSubnet:"サブネットでBambuプリンターをスキャン中...",scanningNetwork:"ネットワークをスキャン中...",noPrintersSubnet:"指定されたサブネットにプリンターが見つかりません。",noPrintersNetwork:"ネットワーク上にプリンターが見つかりません。",allConfigured:"検出されたすべてのプリンターは既に設定済みです。"},firmware:{title:"ファームウェアアップデート",current:"現在",latest:"最新",releaseNotes:"リリースノート",checkingPrerequisites:"前提条件を確認中...",sdCardReady:"SDカード準備完了。下をクリックしてファームウェアをアップロードしてください。",uploadedToSd:"ファームウェアをSDカードにアップロードしました!",applyInstructions:"プリンターでアップデートを適用するには:",step1:"プリンターのタッチスクリーンで設定に移動",step2:"ファームウェアに移動",step3:"SDカードからアップデートを選択",step4:"アップデートには10〜20分かかります",starting:"開始中...",uploadFirmware:"ファームウェアをアップロード",uploadSuccess:"ファームウェアをアップロードしました!プリンター画面からアップデートを実行してください。"},empty:{noPrinters:"プリンターがまだ設定されていません",addFirst:"最初のプリンターを追加"},toast:{printStopped:"印刷を停止しました",printPaused:"印刷を一時停止しました",printResumed:"印刷を再開しました",failedToStop:"印刷の停止に失敗しました",failedToPause:"印刷の一時停止に失敗しました",failedToResume:"印刷の再開に失敗しました",chamberLightOn:"チャンバーライトをオンにしました",chamberLightOff:"チャンバーライトをオフにしました",failedChamberLight:"チャンバーライトの制御に失敗しました",objectsSkipped:"オブジェクトをスキップしました",failedToSkipObjects:"オブジェクトのスキップに失敗しました",rfidRereadInitiated:"RFID再読み取りを開始しました",failedRfidReread:"RFID再読み取りに失敗しました"},progress:"{{percent}}% 完了",timeRemaining:"残り {{time}}",maintenanceOk:"メンテナンス正常",maintenanceWarning:"{{count}}件の警告",maintenanceWarning_plural:"{{count}}件の警告",colors:{unknown:"不明",black:"黒",white:"白",darkGray:"ダークグレー",lightGray:"ライトグレー",gray:"グレー",brown:"茶色",red:"赤",orange:"オレンジ",yellow:"黄色",green:"緑",cyan:"シアン",blue:"青",purple:"紫",pink:"ピンク"},humidity:{unknown:"不明",good:"良好",fair:"注意",bad:"警告"},temperature:{good:"良好",fair:"注意",bad:"高温"},wifi:{excellent:"非常に良い",good:"良い",fair:"普通",weak:"弱い",veryWeak:"非常に弱い"},h2Series:"H2シリーズ",x1Series:"X1シリーズ",pSeries:"Pシリーズ",a1Series:"A1シリーズ",searchPresets:"プリセットを検索...",noCloudPresets:"クラウドプリセットがありません。Bambu Cloudにログインして同期してください。",noMatchingPresets:"一致するプリセットが見つかりません。",colorNamePlaceholder:"色の名前またはHex値(例:brown、FF8800)",clearCustomColor:"カスタムカラーをクリア",copySpoolUuid:"スプールUUIDをコピー",configureSlot:"フィラメントプロファイルとK値でスロットを設定"},archives:{title:"印刷アーカイブ",searchPlaceholder:"アーカイブを検索...",filterByPrinter:"プリンターで絞り込み",filterByStatus:"ステータスで絞り込み",sortBy:"並べ替え",sortNewest:"新しい順",sortOldest:"古い順",sortName:"名前順",sortDuration:"時間順",noArchives:"アーカイブが見つかりません",printTime:"印刷時間",filamentUsed:"フィラメント使用量",cost:"コスト",reprint:"再印刷",preview:"プレビュー",deleteArchive:"アーカイブを削除",deleteConfirm:"このアーカイブを削除しますか?",favorite:"お気に入り",unfavorite:"お気に入りから削除",viewDetails:"詳細を表示",status:{completed:"完了",failed:"失敗",stopped:"中止"},collections:{all:"すべてのアーカイブ",recent:"過去24時間","this-week":"今週","this-month":"今月",favorites:"お気に入り",failed:"失敗した印刷",duplicates:"重複"},bulkDeleted:"{{count}}件のアーカイブを削除しました",bulkDeleteFailed:"アーカイブの削除に失敗しました",bulkDeleteTitle:"アーカイブを削除",bulkDeleteConfirm:"{{count}}件のアーカイブを削除しますか?この操作は元に戻せません。",deleteCount:"{{count}}件を削除",only3mfSupported:".3mfファイルのみ対応しています",dropFilesHere:".3mfファイルをここにドロップ",releaseToUpload:"ドロップしてアップロード",selectedCount:"{{count}}件選択中",selectAll:"すべて選択",tags:"タグ",project:"プロジェクト",toggledFavorites:"{{count}}件のアーカイブのお気に入りを切替えました",favoriteUpdateFailed:"お気に入りの更新に失敗しました",favoriteBulk:"お気に入り",showingCount:"{{total}}件中{{shown}}件を表示",export:"エクスポート",exportDownloaded:"エクスポートをダウンロードしました",exportFailed:"エクスポートに失敗しました",exportCsv:"CSVでエクスポート",exportExcel:"Excelでエクスポート",compare:"比較 ({{count}})",select:"選択",upload3mf:"3MFアップロード",allPrinters:"すべてのプリンター",allMaterials:"すべての素材",allFiles:"すべてのファイル",slicedGcode:"スライス済み (GCODE)",sourceFileOnly:"ソースのみ",showAll:"すべて表示",showFavoritesOnly:"お気に入りのみ表示",favorites:"お気に入り",showFailedPrints:"失敗した印刷を表示",hideFailedPrints:"失敗した印刷を非表示",hideFailed:"失敗を非表示",allTags:"すべてのタグ",enterNewTag:"新しいタグを入力...",sortNewestFirst:"新しい順",sortOldestFirst:"古い順",sortNameAZ:"名前 A-Z",sortNameZA:"名前 Z-A",sortLargestFirst:"大きい順",sortSmallestFirst:"小さい順",gridView:"グリッド表示",listView:"リスト表示",calendarView:"カレンダー表示",reset:"リセット",colors:"カラー:",matchAnyColor:"いずれかの選択色に一致",matchAllColors:"すべての選択色に一致",clear:"クリア",loading:"アーカイブを読み込み中...",noMatchingArchives:"検索に一致するアーカイブはありません",noArchivesYet:"アーカイブはまだありません",autoCreated:"印刷完了時にアーカイブは自動的に作成されます",unknownPrinter:"不明",noPrinter:"プリンターなし",rightClickOptions:"右クリックでオプション表示",printedBefore:"このモデルは以前印刷されたことがあります",openSource3mf:"ソース3MFをBambu Studioで開く(右クリックでオプション表示)",viewPhotos:"{{count}}枚の写真を表示",openFolder:"フォルダーを開く: {{name}}",projectName:"プロジェクト: {{name}}",makerWorldDesigner:"MakerWorld: {{designer}}",notFromMakerWorld:"MakerWorldではありません",hasTimelapse:"タイムラプスあり",moreOptions:"その他のオプション",downloadF3d:"Fusion 360デザインファイルをダウンロード",listName:"名前",listPrinter:"プリンター",listDate:"日付",listSize:"サイズ",listActions:"アクション"},queue:{title:"印刷キュー",description:"印刷ジョブのスケジュールと管理",addToQueue:"キューに追加",clearQueue:"キューをクリア",clearHistory:"履歴をクリア",emptyQueue:"キューは空です",position:"順番",scheduledTime:"予定時刻",moveUp:"上に移動",moveDown:"下に移動",remove:"削除",requeue:"再キュー",startNow:"今すぐ開始",startPrint:"印刷を開始",stopPrint:"印刷を停止",unassigned:"未割当",printerNumber:"プリンター #{{id}}",staged:"ステージ済み",requiresPreviousSuccess:"前の印刷の成功が必要",autoPowerOff:"自動電源オフ",printingInProgress:"印刷中...",currentlyPrinting:"印刷中",viewArchive:"アーカイブを表示",viewInFileManager:"ファイルマネージャーで表示",itemCount:"{{count}}件",dragToReorder:"ドラッグして並べ替え(ASAPのみ)",overdue:"期限超過",dragReorderTooltip:"順番はASAPアイテムのみに影響します。スケジュール済みアイテムは設定された時間に実行されます。",anyModel:"任意の{{model}}{{location}}{{filaments}}",addedBy:"{{username}}が追加",bulkEdit:{title:"{{count}}件のアイテムを編集",description:"変更した設定のみが選択されたアイテムに適用されます。",printer:"プリンター",noChange:"— 変更なし —",queueOptions:"キューオプション",stagedManualStart:"ステージ済み(手動開始)",autoPowerOff:"印刷後に自動電源オフ",requirePreviousSuccess:"前の印刷の成功が必要",printOptions:"印刷オプション",bedLevelling:"ベッドレベリング",flowCalibration:"フローキャリブレーション",vibrationCalibration:"振動キャリブレーション",firstLayerInspection:"第一層検査",timelapse:"タイムラプス",useAms:"AMS使用",on:"オン",off:"オフ",saving:"保存中...",applyChanges:"変更を適用"},bulkActions:{selectAll:"すべて選択",deselectAll:"すべて選択解除",selected:"{{count}}件選択中",editSelected:"選択を編集",cancelSelected:"選択をキャンセル"},permissions:{noStopPermission:"印刷を停止する権限がありません",noStartPermission:"印刷を開始する権限がありません",noEditPermission:"キューアイテムを編集する権限がありません",noCancelPermission:"キューアイテムをキャンセルする権限がありません",noRequeuePermission:"アイテムを再キューする権限がありません",noRemovePermission:"キューアイテムを削除する権限がありません",noClearHistoryPermission:"履歴をクリアする権限がありません"},status:{pending:"待機中",printing:"印刷中",completed:"完了",failed:"失敗",skipped:"スキップ",cancelled:"キャンセル済み",waiting:"待機中"},summary:{printing:"印刷中",queued:"キュー中",totalQueueTime:"合計キュー時間",history:"履歴"},filters:{allPrinters:"すべてのプリンター",allStatus:"すべてのステータス"},sort:{byPosition:"順番で並べ替え",byName:"名前で並べ替え",byPrinter:"プリンターで並べ替え",bySchedule:"スケジュールで並べ替え",byDate:"日付で並べ替え",ascending:"昇順",descending:"降順",ascendingOldest:"昇順(古い順)",descendingNewest:"降順(新しい順)"},empty:{title:"スケジュールされた印刷はありません",description:"アーカイブページのコンテキストメニューから「スケジュール」オプションを使用するか、ファイルをドラッグ&ドロップして始めましょう。"},confirm:{cancelTitle:"スケジュール済み印刷をキャンセル",cancelMessage:"「{{name}}」をキャンセルしますか?",cancelButton:"印刷をキャンセル",stopTitle:"印刷を停止",stopMessage:"現在の印刷「{{name}}」を停止しますか?プリンター上の印刷ジョブがキャンセルされます。",stopButton:"印刷を停止",removeTitle:"履歴から削除",removeMessage:"「{{name}}」をキュー履歴から削除しますか?",clearHistoryMessage:"{{count}}件の履歴をすべて削除しますか?",thisPrint:"この印刷",thisItem:"このアイテム"},toast:{itemCancelled:"キューアイテムをキャンセルしました",itemRemoved:"キューアイテムを削除しました",printStopped:"印刷を停止しました",printReleased:"印刷をキューに戻しました",clearedHistory:"{{count}}件の履歴をクリアしました",failedToCancel:"アイテムのキャンセルに失敗しました",failedToRemove:"アイテムの削除に失敗しました",failedToStop:"印刷の停止に失敗しました",failedToStart:"印刷の開始に失敗しました",failedToReorder:"キューの並べ替えに失敗しました",failedToClear:"履歴のクリアに失敗しました",failedToUpdateItems:"アイテムの更新に失敗しました",cancelledItems:"{{count}}件のアイテムをキャンセルしました",failedToCancelItems:"アイテムの一括キャンセルに失敗しました"}},stats:{title:"統計",overview:"概要",totalPrints:"総印刷数",successRate:"成功率",totalPrintTime:"総印刷時間",totalFilament:"総フィラメント使用量",totalCost:"総コスト",averagePrintTime:"平均印刷時間",printsPerDay:"1日あたりの印刷数",byPrinter:"プリンター別",byMaterial:"素材別",byMonth:"月別",last7Days:"過去7日間",last30Days:"過去30日間",last90Days:"過去90日間",allTime:"全期間",dashboard:"統計ダッシュボード",dashboardDescription:"3Dプリントアクティビティの概要",loadingStatistics:"統計を読み込み中...",quickStats:"クイック統計",printTime:"印刷時間",filamentUsed:"フィラメント使用量",filamentCost:"フィラメントコスト",energyUsed:"エネルギー使用量",energyCost:"エネルギーコスト",successful:"成功",failed:"失敗",printsByPrinter:"プリンター別印刷数",printerFallback:"プリンター #{{id}}",timeAccuracy:"時間精度",noTimeAccuracyData:"時間精度データがありません",perfectEstimate:"100% = 完全な推定",filamentTypes:"フィラメントタイプ",noFilamentData:"フィラメントデータがありません",printsCount:"{{count}}回印刷",moreTypes:"+{{count}}種類",noPrinterData:"プリンターデータがありません",filamentUsageTrends:"フィラメント使用トレンド",noPrintData:"印刷データがありません",printActivity:"印刷アクティビティ",failureAnalysis30Days:"失敗分析(30日間)",noPrintDataLast30Days:"過去30日間の印刷データがありません",printsFailed:"{{total}}回中{{failed}}回失敗",lastWeek:"先週",failureReasons:"失敗理由",topFailureReasons:"主な失敗理由",unknown:"不明",moreReasons:"+{{count}}件の理由",hiddenCount:"{{count}}件非表示",layoutReset:"レイアウトをリセットしました",resetLayout:"レイアウトをリセット",exportStats:"統計をエクスポート",exportAsCsv:"CSVでエクスポート",exportAsExcel:"Excelでエクスポート",exportDownloaded:"エクスポートをダウンロードしました",exportFailed:"エクスポートに失敗しました",filament:"フィラメント",cost:"コスト",prints:"プリント",filamentGrams:"フィラメント (g)",weekOf:"週:",periodFilament:"期間フィラメント",periodCost:"期間コスト",avgPerPrint:"プリントあたりの平均",total:"合計",avg:"平均",usageOverTime:"使用量の推移",noDataForTimeRange:"選択した期間のデータがありません",byFilamentType:"フィラメントタイプ別",usage:"使用量",monthlyComparison:"月間比較",noPermissionRecalculate:"コストを再計算する権限がありません",noPermissionResetLayout:"レイアウトをリセットする権限がありません",recalculateCosts:"コストを再計算",recalculateFailed:"コストの再計算に失敗しました",recalculateTooltip:"現在のフィラメント価格に基づいてすべてのプリントコストを再計算します"},profiles:{title:"フィラメントプロファイル",addProfile:"プロファイルを追加",editProfile:"プロファイルを編集",deleteProfile:"プロファイルを削除",material:"素材",brand:"ブランド",color:"色",diameter:"直径",density:"密度",costPerKg:"1kgあたりの価格",spoolWeight:"スプール重量",noProfiles:"プロファイルが登録されていません",deleteConfirm:"このプロファイルを削除しますか?",templateName:"テンプレート名",descriptionOptional:"説明(任意)",searchFields:"フィールドを検索...",presetNamePlaceholder:"マイカスタムプリセット",searchPresets:"プリセットを検索...",connectToCloud:"Bambu Cloudに接続",syncDescription:"デバイス間でスライサープリセットを同期",email:"メールアドレス",password:"パスワード",region:"リージョン",regionGlobal:"グローバル",regionChina:"中国",verificationCode:"認証コード",totpCode:"認証アプリコード",checkEmail:"メール ({{email}}) に届いた6桁のコードを入力してください",enterTotpHint:"認証アプリの6桁のコードを入力してください",accessToken:"アクセストークン",accessTokenHint:"Bambu Labのアクセストークンを貼り付け(Bambu Studioから取得)",login:"ログイン",verify:"認証",setToken:"トークン設定",useTokenInstead:"アクセストークンを使用",loginWithEmail:"メールでログイン",loggedIn:"ログインしました",verificationSent:"認証コードをメールに送信しました",enterTotp:"認証アプリのコードを入力してください",tokenSet:"トークンを設定しました",loggedOut:"ログアウトしました",logout:"ログアウト",connectedAs:"接続中:",pageTitle:"プロファイル",pageDescription:"スライサープリセットと圧力キャリブレーションの管理",cloudProfiles:"クラウドプロファイル",kProfiles:"Kプロファイル",scrollToTop:"トップに戻る",justNow:"たった今",minutesAgo:"{{count}}分前",hoursAgo:"{{count}}時間前",daysAgo:"{{count}}日前",lastSynced:"最終同期:",duplicate:"複製",myPresetEditable:"マイプリセット(編集可能)",editable:"編集可能",typePreset:"{{type}}プリセット",presetDeleted:"プリセットを削除しました",presetCreated:"プリセットを作成しました",presetUpdated:"プリセットを更新しました",presetExported:"プリセットをエクスポートしました",presetName:"プリセット名",failedToLoadDetails:"プリセットの詳細を読み込めませんでした",failedToLoadProfiles:"プロファイルの読み込みに失敗しました",deletePresetConfirm:"このプリセットを削除しますか?",deletePresetWarning:'"{{name}}"をBambu Cloudから完全に削除します。この操作は元に戻せません。',noPresetsFound:"プリセットが見つかりません",showingPresets:"{{total}}件中{{count}}件を表示",myPresetLegend:"= マイプリセット(編集可能)",typeLabel:"タイプ",typeFilter:"タイプ:",owner:"所有者",myPresets:"マイプリセット",builtIn:"ビルトイン",nozzle:"ノズル",filament:"フィラメント",process:"プロセス",printer:"プリンター",layer:"レイヤー",clearFilters:"フィルターをクリア",noFilamentPresets:"フィラメントプリセットなし",noProcessPresets:"プロセスプリセットなし",noPrinterPresets:"プリンタープリセットなし",compare:"比較",compareMode:"比較モード",comparePresets:"プリセットを比較",compareNow:"比較を実行",compareWithBase:"ベースプリセットと比較",selectAnotherPreset:"同じタイプ({{type}})の別のプリセットを選択",clickTwoPresets:"同じタイプのプリセットを2つクリックして比較",selectFirst:"1. 最初を選択",selectSecond:"2. 2番目を選択",left:"左:",right:"右:",addedCount:"{{count}}件追加",removedCount:"{{count}}件削除",changedCount:"{{count}}件変更",sameCount:"{{count}}件同じ",changes:"変更点",noDifferences:"差分はありません",noFieldsMatch:"検索に一致するフィールドがありません",field:"フィールド",quickTemplates:"クイックテンプレート",templates:"テンプレート",deleteTemplate:"テンプレートを削除",actionCannotBeUndone:"この操作は元に戻せません",confirmDeleteTemplate:'"{{name}}"を削除してもよろしいですか?',templateDeleted:"テンプレートを削除しました",templateUpdated:"テンプレートを更新しました",templateApplied:"テンプレートを適用しました",templateAppliedName:"テンプレート適用: {{name}}",templateSaved:"テンプレートを保存しました",customTemplate:"カスタムテンプレート",noTemplatesYet:"テンプレートはまだありません",createTemplatesHint:"プリセットエディターからテンプレートを作成",noTemplatesSelected:"テンプレートが選択されていません。テンプレートボタンから有効にしてください。",manageTemplatesHint:"メインページのテンプレートボタンからテンプレートを管理",settingsJson:"設定 (JSON)",fieldsCount:"{{count}}フィールド",shownInModals:"モーダルに表示",hiddenInModals:"モーダルで非表示",apply:"適用",saveAsTemplate:"テンプレートとして保存",editPreset:"プリセットを編集",duplicatePreset:"プリセットを複製",createNewPreset:"新しいプリセットを作成",newPreset:"新規プリセット",customizeSettings:"新しいプリセットの設定をカスタマイズ",dropJsonToImport:"JSONファイルをドロップしてインポート",basePreset:"ベースプリセット",selectBasePreset:"ベースプリセットを選択...",inheritsFrom:"継承元:",commonTab:"共通",allFieldsTab:"全フィールド",jsonTab:"JSON",exportToJsonFile:"設定をJSONファイルにエクスポート",importFromJsonFile:"JSONファイルから設定をインポート",commonSettings:"共通設定",currentOverrides:"現在のオーバーライド",availableFields:"利用可能なフィールド",noMatchingFields:"一致するフィールドがありません",allFieldsAdded:"すべてのフィールドが追加済みです",addCustomField:"カスタムフィールドを追加",yourOverrides:"オーバーライド一覧",noOverridesYet:"オーバーライドはまだありません",clickFieldsToAdd:"左のフィールドをクリックして追加",dragDropTip:"ヒント: このモーダルに.jsonファイルをドラッグ&ドロップして設定をインポート",fieldAdded:'フィールド "{{key}}" を追加しました',noOverridesToSave:"保存するオーバーライドがありません",fileImported:"ファイルをインポートしました",fileImportedSuccess:"ファイルを正常にインポートしました",invalidJson:"無効なJSON",noPermissionCreate:"プロファイルを作成する権限がありません",noPermissionDelete:"プロファイルを削除する権限がありません",noPermissionDuplicate:"プロファイルを複製する権限がありません",noPermissionEdit:"プロファイルを編集する権限がありません",noPermissionLogout:"ログアウトする権限がありません",noPermissionManageTemplates:"テンプレートを管理する権限がありません",noPermissionRefresh:"プロファイルを更新する権限がありません"},maintenance:{title:"メンテナンス",overview:"概要",allOk:"すべてのメンテナンスは最新です",dueCount:"{{count}}件の期限到来",dueCount_plural:"{{count}}件の期限到来",warningCount:"{{count}}件の警告",warningCount_plural:"{{count}}件の警告",totalPrintTime:"総印刷時間",nextMaintenance:"次回メンテナンス",nothingDue:"予定なし",tasks:"タスク",lastPerformed:"前回実施日",interval:"間隔",hoursRemaining:"残り{{hours}}時間",hoursOverdue:"{{hours}}時間超過",markDone:"完了にする",performMaintenance:"メンテナンスを実施",history:"履歴",noHistory:"メンテナンス履歴がありません",editPrintHours:"印刷時間を編集",currentHours:"現在の時間",today:"今日",overdue:"期限超過",dueSoon:"まもなく期限",collapse:"折りたたむ",expand:"展開",left:"残り",timeBasedInterval:"時間ベースのインターバル",viewDocumentation:"ドキュメントを表示",printersAssigned:"{{count}}台のプリンターが割り当て済み - クリックして管理",deleteTypeConfirm:"「{{name}}」を削除しますか?",removeFromPrinter:"このプリンターから削除",addLabel:"追加:",maintenanceTypes:"メンテナンスタイプ",systemTypesDescription:"システムタイプとカスタムメンテナンスタスク",addCustomType:"カスタムタイプを追加",intervalType:"インターバルタイプ",printHours:"印刷時間",calendarDays:"カレンダー日数",intervalWithUnit:"インターバル ({{unit}})",days:"日",icon:"アイコン",documentationLink:"ドキュメントリンク(任意)",docLinkPlaceholder:"ドキュメントリンク(任意)",namePlaceholder:"例:HEPAフィルター交換",assignToPrinters:"プリンターに割り当て",selectAtLeastOnePrinter:"プリンターを1台以上選択してください",addType:"タイプを追加",custom:"カスタム",assignedToPrinters:"割り当て済みプリンター:",noPrintersAssigned:"プリンター未割り当て",intervalOverrides:"インターバルのオーバーライド",customizeIntervals:"プリンターごとにインターバルをカスタマイズ",addPrintersForMaintenance:"メンテナンスインターバルを設定するにはプリンターを追加してください",reset:"リセット",countOverdue:"{{count}}件が期限超過",countDueSoon:"{{count}}件がまもなく期限",allGood:"問題なし",nHours:"{{count}}時間",tasksOverdue:"{{count}}件のタスクが期限超過",configureDescription:"メンテナンスタイプとインターバルを設定",addPrintersToTrack:"メンテナンスを追跡するにはプリンターを追加してください",markedComplete:"メンテナンスを完了としてマーク",typeUpdated:"メンテナンスタイプを更新しました",typeDeleted:"メンテナンスタイプを削除しました",typeAdded:"メンテナンスタイプを追加しました",hoursUpdated:"印刷時間を更新しました",printerAssigned:"プリンターを割り当てました",printerRemoved:"プリンターを削除しました",wikiUrlPlaceholder:"https://wiki.bambulab.com/...",duration:{oneDay:"1日",days:"{{count}}日",weeks:"{{count}}週間",months:"{{count}}ヶ月",oneWeek:"1週間",nWeeks:"{{count}}週間",oneMonth:"1ヶ月",nMonths:"{{count}}ヶ月",oneYear:"1年"},noPermissionCreate:"メンテナンス記録を作成する権限がありません",noPermissionUpdate:"メンテナンス記録を更新する権限がありません",noPermissionPerform:"メンテナンスを実行する権限がありません",noPermissionRemove:"メンテナンス記録を削除する権限がありません",noPermissionAssign:"メンテナンスを割り当てる権限がありません",noPermissionEditTypes:"メンテナンスタイプを編集する権限がありません",noPermissionDeleteTypes:"メンテナンスタイプを削除する権限がありません",noPermissionEditIntervals:"メンテナンス間隔を編集する権限がありません",noPermissionEditHours:"メンテナンス時間を編集する権限がありません",types:{lubricateRails:"リニアレールの潤滑",cleanNozzle:"ノズル/ホットエンドの清掃",checkBelts:"ベルト張力の確認",cleanBuildPlate:"ビルドプレートの清掃",checkExtruder:"エクストルーダーギアの確認",checkCooling:"冷却ファンの確認",generalInspection:"総合点検",cleanCarbonRods:"カーボンロッドの清掃",checkPtfeTube:"PTFEチューブの確認",replaceHepaFilter:"HEPAフィルター交換",replaceCarbonFilter:"カーボンフィルター交換",lubricateLeftNozzleRail:"左ノズルレールの潤滑"}},settings:{title:"設定",general:"一般",appearance:"外観",notifications:"通知",smartPlugs:"スマートプラグ",tabSpoolman:"Spoolman",updates:"アップデート",language:"言語",languageDescription:"表示言語を選択してください",theme:"テーマ",themeLight:"ライト",themeDark:"ダーク",themeSystem:"システム設定に従う",defaultView:"デフォルト画面",defaultViewDescription:"アプリ起動時に表示するページ",checkForUpdates:"アップデートを確認",autoUpdate:"自動アップデート",currentVersion:"現在のバージョン",latestVersion:"最新バージョン",upToDate:"最新です",updateAvailable:"アップデートあり",telemetry:"匿名テレメトリ",telemetryDescription:"匿名の使用状況データを送信してBamBuddyの改善に協力する",telemetryLearnMore:"詳しく見る",telemetryInfoTitle:"どのようなデータが収集されますか?",telemetryInfoIntro:"BamBuddyはアプリの利用者数、使用バージョン、プリンターモデルを把握するために最小限の匿名データを収集します。これはバグ修正や新機能の優先順位付けに役立ちます。",telemetryInfoCollected:"収集するデータ:",telemetryInfoItem1:"ランダムなインストールID(個人やハードウェアとは紐付きません)",telemetryInfoItem2:"使用中のアプリバージョン",telemetryInfoItem3:"プリンターのモデル名(例: X1C, P1S)- 名前やシリアル番号は含みません",telemetryInfoItem4:"タイムスタンプ(日次/週次のアクティブユーザー数の計測用)",telemetryInfoNotCollected:"収集しないデータ:",telemetryInfoNotItem1:"IPアドレスはハッシュ化され、復元できません",telemetryInfoNotItem2:"プリンター名、シリアル番号、アクセスコード",telemetryInfoNotItem3:"印刷履歴、ファイル名、その他の個人的なコンテンツ",telemetryInfoNotItem4:"個人を特定できる情報",telemetryInfoFooter:"テレメトリはいつでも無効にできます。インストールIDはランダムに生成され、個人を追跡することはできません。",notificationLanguage:"通知の言語",notificationLanguageDescription:"プッシュ通知の言語",notificationProviders:"通知プロバイダー",addProvider:"プロバイダーを追加",editProvider:"プロバイダーを編集",providerType:"プロバイダーの種類",testNotification:"テスト通知",testSuccess:"テスト通知を送信しました",testFailed:"テスト通知の送信に失敗しました",quietHours:"おやすみ時間",quietHoursDescription:"この時間帯は通知を送信しません",quietHoursStart:"開始",quietHoursEnd:"終了",events:{title:"通知イベント",printStart:"印刷開始",printComplete:"印刷完了",printFailed:"印刷失敗",printStopped:"印刷中止",printProgress:"進捗マイルストーン",printProgressDescription:"25%, 50%, 75%で通知",printerOffline:"プリンターオフライン",printerError:"プリンターエラー",filamentLow:"フィラメント残量低下",maintenanceDue:"メンテナンス期限",maintenanceDueDescription:"メンテナンスが必要なときに通知"},smartPlug:{title:"スマートプラグ",add:"スマートプラグを追加",edit:"スマートプラグを編集",name:"名前",ipAddress:"IPアドレス",linkedPrinter:"連携プリンター",autoOn:"自動電源オン",autoOnDescription:"印刷開始時に電源を入れる",autoOff:"自動電源オフ",autoOffDescription:"印刷完了後に電源を切る",offDelay:"オフ遅延",offDelayMinutes:"印刷後の待機時間(分)",offDelayTemp:"ノズル温度が下回ったとき",currentState:"現在の状態",turnOn:"電源オン",turnOff:"電源オフ"},spoolman:{title:"Spoolman連携",description:"Spoolmanに接続してフィラメント在庫を管理します。AMSデータは自動的に同期されます。",howSyncWorks:"同期の仕組み",syncInfo1:"公式Bambu LabスプールのみRFIDで同期されます",syncInfo2:"新しいスプールは初回同期時にSpoolmanに自動作成されます",syncInfo3:"サードパーティ・詰め替えスプールはスキップされます",linkingExisting:"既存スプールの連携",linkingExistingDesc:"既存のSpoolmanスプールをAMSに連携するには、AMSスロットにカーソルを合わせて「Spoolmanに連携」をクリックしてください。",enable:"Spoolmanを有効化",enableDesc:"Spoolmanサーバーとフィラメントデータを同期",url:"Spoolman URL",urlHint:"SpoolmanサーバーのURL(例: http://localhost:7912)",syncMode:"同期モード",syncModeAuto:"自動",syncModeManual:"手動のみ",syncModeAutoDesc:"変更が検出されるとAMSデータが自動同期されます",syncModeManualDesc:"手動トリガー時のみ同期",statusLabel:"ステータス:",connected:"接続中",disconnected:"未接続",disconnect:"切断",connect:"接続",syncAmsData:"AMSデータを同期",syncAmsDataDesc:"プリンターのAMSデータをSpoolmanに手動同期",allPrinters:"すべてのプリンター",sync:"同期",syncSuccess:"{{count}}個のスプールを同期しました",syncWithErrors:"{{count}}個のスプールを同期({{errorCount}}件のエラー)",spoolsSkipped:"{{count}}個のスプールをスキップ",showAll:"すべて表示",showLess:"折りたたむ",andMore:"...他{{count}}件",errors:"エラー:",linkToSpoolman:"Spoolmanに連携",linkingAmsTray:"連携するAMSトレイ:",spoolUuid:"スプールUUID:",selectSpoolToLink:"連携するSpoolmanスプールを選択:",unknownFilament:"不明なフィラメント",noUnlinkedSpools:"Spoolmanに未連携のスプールが見つかりません。",allSpoolsLinked:"すべてのスプールはAMSトレイに連携済みです。",linking:"連携中...",linkSpool:"スプールを連携",linkTooltip:"このスプールをSpoolmanスプールに連携",noUnlinked:"未連携のスプールがありません"},subtitle:"Bambuddyの設定",saved:"設定を保存しました",saveFailed:"保存に失敗しました: {{error}}",tabGeneral:"一般",tabSmartPlugs:"スマートプラグ",tabNotifications:"通知",tabFilament:"フィラメント",tabNetwork:"ネットワーク",tabApiKeys:"APIキー",tabVirtualPrinter:"仮想プリンター",tabUsers:"ユーザー",dateFormat:"日付形式",timeFormat:"時刻形式",systemDefault:"システムデフォルト",dateFormatUS:"US (MM/DD/YYYY)",dateFormatEU:"EU (DD/MM/YYYY)",dateFormatISO:"ISO (YYYY-MM-DD)",timeFormat12h:"12時間 (3:30 PM)",timeFormat24h:"24時間 (15:30)",defaultPrinter:"デフォルトプリンター",noDefaultPrinter:"デフォルトなし(毎回選択)",defaultPrinterDescription:"アップロード、再印刷、その他の操作でこのプリンターを事前選択します。",sidebarOrder:"サイドバーの順序",sidebarOrderDescription:"サイドバーの項目をドラッグ&ドロップで並べ替えできます。ここでデフォルトの順序にリセットできます。",reset:"リセット",darkMode:"ダークモード",lightMode:"ライトモード",active:"(有効)",background:"背景",accent:"アクセント",style:"スタイル",bgNeutral:"ニュートラル",bgWarm:"ウォーム",bgCool:"クール",bgOLED:"OLED ブラック",bgSlate:"スレートブルー",bgForest:"フォレストグリーン",accentGreen:"グリーン",accentTeal:"ティール",accentBlue:"ブルー",accentOrange:"オレンジ",accentPurple:"パープル",accentRed:"レッド",styleClassic:"クラシック",styleGlow:"グロー",styleVibrant:"ビブラント",themeToggleHint:"サイドバーの太陽/月アイコンでダークモードとライトモードを切り替えます。",archiveSettings:"アーカイブ設定",autoArchive:"自動アーカイブ",autoArchiveDescription:"印刷完了時に3MFファイルを自動的に保存",saveThumbnails:"サムネイルを保存",saveThumbnailsDescription:"3MFファイルからプレビュー画像を抽出して保存",captureFinishPhoto:"完了写真を撮影",captureFinishPhotoDescription:"印刷完了時にプリンターカメラから写真を撮影",ffmpegNotInstalled:"ffmpegがインストールされていません",ffmpegInstruction:"カメラキャプチャにはffmpegが必要です。brew install ffmpeg(macOS)またはapt install ffmpeg(Linux)でインストールしてください。",camera:"カメラ",cameraViewMode:"カメラ表示モード",cameraNewWindow:"新しいウィンドウ",cameraEmbedded:"埋め込みオーバーレイ",cameraEmbeddedDescription:"メイン画面上のリサイズ可能なオーバーレイでカメラを開きます",cameraNewWindowDescription:"別のブラウザウィンドウでカメラを開きます",costTracking:"コスト追跡",defaultFilamentCost:"デフォルトフィラメントコスト(kg単位)",currency:"通貨",electricityCost:"電気代(kWh単位)",energyDisplayMode:"エネルギー表示モード",energyPrintsOnly:"印刷のみ",energyTotalConsumption:"総消費量",energyPrintsOnlyDescription:"ダッシュボードに印刷中に使用されたエネルギーの合計を表示",energyTotalDescription:"ダッシュボードにスマートプラグの累計エネルギーを表示",fileManager:"ファイルマネージャー",archiveOnPrint:"印刷時のアーカイブエントリ作成",archiveAlways:"常にアーカイブエントリを作成",archiveNever:"アーカイブエントリを作成しない",archiveAsk:"毎回確認",archiveOnPrintDescription:"ファイルマネージャーから印刷する際、オプションでアーカイブエントリを作成",lowDiskWarning:"ディスク容量不足の警告",lowDiskWarningDescription:"空きディスク容量がこのしきい値を下回ると警告を表示",checkPrinterFirmware:"プリンターファームウェアの確認",checkPrinterFirmwareDescription:"Bambu Labのプリンターファームウェア更新を確認",checkForUpdatesDescription:"起動時に自動的に新しいバージョンを確認",checkNow:"今すぐ確認",releaseNotes:"リリースノート",viewOnGitHub:"GitHubで表示",updateViaDocker:"Docker Composeでアップデート:",installUpdate:"アップデートをインストール",close:"閉じる",dataManagement:"データ管理",backupData:"データのバックアップ",backupDescription:"設定、プロバイダー、プリンターなどをエクスポート",export:"エクスポート",restoreBackup:"バックアップの復元",restoreDescription:"重複処理オプション付きでバックアップファイルから設定をインポート",restore:"復元",clearLogs:"通知ログを削除",clearLogsDescription:"30日以上前の通知ログを削除",clear:"削除",resetUI:"UIの設定をリセット",resetUIDescription:"サイドバーの順序、テーマ、表示モード、レイアウト設定をリセットします。プリンター、アーカイブ、設定には影響しません。",clearLogsTitle:"通知ログを削除",clearLogsMessage:"30日以上前のすべての通知ログを完全に削除します。この操作は元に戻せません。",clearLogsConfirm:"ログを削除",clearLogsFailed:"ログの削除に失敗しました",resetUITitle:"UIの設定をリセット",resetUIMessage:"すべてのUI設定をデフォルトにリセットします:サイドバーの順序、テーマ、ダッシュボードレイアウト、表示モード、ソート設定。プリンター、アーカイブ、サーバー設定には影響しません。クリア後にページが再読み込みされます。",resetPreferences:"設定をリセット",preferencesReset:"UI設定をリセットしました。更新中...",externalUrl:"外部URL",externalUrlDescription:"Bambuddyがアクセス可能な外部URL。通知画像や外部連携に使用されます。",bambuddyUrl:"Bambuddy URL",externalUrlHint:"プロトコルとポートを含めてください(例: http://192.168.1.100:8000)",ftpRetry:"FTPリトライ",ftpRetryDescription:"プリンターのWi-Fiが不安定な場合にFTP操作をリトライします。3MFダウンロード、印刷アップロード、タイムラプスダウンロード、ファームウェアアップデートに適用されます。",enableRetry:"リトライを有効化",enableRetryDescription:"失敗したFTP操作を自動的にリトライ",retryAttempts:"リトライ回数",times:"回",retryAttemptsDescription:"諦めるまでのリトライ回数(1-10)",retryDelay:"リトライ間隔",seconds:"秒",retryDelayDescription:"リトライ間の待ち時間(1-30)",connectionTimeout:"接続タイムアウト",connectionTimeoutDescription:"遅い接続用のソケットタイムアウト。Wi-Fiが弱いA1/A1 Miniプリンターの場合は増やしてください(10-120)",homeAssistant:"Home Assistant",connected:"接続済み",disconnected:"未接続",homeAssistantDescription:"Home Assistantに接続してHA REST APIでスマートプラグを制御します。switch、light、input_booleanエンティティに対応しています。",enableHA:"Home Assistantを有効化",enableHADescription:"Home Assistantでスマートプラグを制御",haUrl:"Home Assistant URL",haToken:"長期アクセストークン",haTokenHint:"HAでトークンを作成: プロフィール → 長期アクセストークン → トークン作成",testConnection:"接続テスト",connectionSuccessful:"接続成功",connectionFailed:"接続失敗",haConnectionSuccess:"Home Assistantへの接続に成功しました。",haConnectionFailed:"Home Assistantへの接続に失敗しました。",mqttPublishing:"MQTT配信",mqttDescription:"BamBuddyイベントを外部MQTTブローカーに配信し、Node-RED、Home Assistant、その他の自動化システムと連携します。",enableMqtt:"MQTTを有効化",enableMqttDescription:"外部MQTTブローカーにイベントを配信",brokerHostname:"ブローカーホスト名",port:"ポート",useTls:"TLSを使用",usernameOptional:"ユーザー名(オプション)",passwordOptional:"パスワード(オプション)",topicPrefix:"トピックプレフィックス",connectedTo:"接続先:",notConnected:"未接続",smartPlugsDescription:"スマートプラグ(TasmotaまたはHome Assistant)を接続して、電源制御を自動化し、プリンターのエネルギー消費を追跡します。",turnAllPlugsOn:"すべてのプラグをオン",turnAllPlugsOff:"すべてのプラグをオフ",allOn:"全オン",allOff:"全オフ",addSmartPlug:"スマートプラグを追加",energySummary:"エネルギー概要",currentPower:"現在の電力",today:"今日",yesterday:"昨日",total:"合計",enablePlugsForEnergy:"プラグを有効にしてエネルギー概要を表示",noSmartPlugs:"スマートプラグが設定されていません",noSmartPlugsDescription:"Tasmotaベースのスマートプラグを追加して、エネルギー消費を追跡し、電源制御を自動化します。",addFirstSmartPlug:"最初のスマートプラグを追加",providers:"プロバイダー",log:"ログ",testAll:"すべてテスト",add:"追加",testResults:"テスト結果",dismiss:"閉じる",noProviders:"プロバイダーが設定されていません",noProvidersDescription:"アラートを受信するにはプロバイダーを追加してください。",messageTemplates:"メッセージテンプレート",templatesDescription:"各イベントの通知メッセージをカスタマイズします。",noTemplates:"テンプレートがありません。バックエンドを再起動してデフォルトテンプレートを作成してください。",testAllSuccess:"すべて{{count}}件のプロバイダーのテストに成功しました!",testAllPartial:"{{success}}/{{tested}}件のプロバイダーが成功",testProvidersFailed:"プロバイダーのテストに失敗しました: {{error}}",bulkPlugSuccess:"すべて{{count}}個のプラグを{{action}}にしました",bulkPlugPartial:"{{success}}個のプラグを{{action}}にしました、{{failed}}個が失敗",bulkPlugFailed:"失敗: {{error}}",apiKeys:"APIキー",apiKeysDescription:"外部連携やWebhook用のAPIキーを作成します。",createKey:"キーを作成",apiKeyCreated:"APIキーを作成しました",apiKeyDeleted:"APIキーを削除しました",apiKeySuccess:"APIキーが正常に作成されました",apiKeyCopyWarning:"今すぐこのキーをコピーしてください - 再表示されません!",keyCopied:"キーをクリップボードにコピーしました",keyCopyFailed:"キーのコピーに失敗しました",keyAddedToBrowser:"キーをAPIブラウザに追加しました",useInBrowser:"APIブラウザで使用",createNewApiKey:"新しいAPIキーを作成",keyName:"キー名",permissions:"権限",readStatus:"ステータスの読み取り",readStatusDescription:"プリンターのステータスとキューを表示",manageQueue:"キューの管理",manageQueueDescription:"印刷キューへのアイテムの追加と削除",controlPrinter:"プリンターの制御",controlPrinterDescription:"印刷の一時停止、再開、停止",cancel:"キャンセル",lastUsed:"最終使用:",badgeRead:"読取",badgeQueue:"キュー",badgeControl:"制御",noApiKeys:"APIキーがありません",noApiKeysDescription:"外部サービスとの連携用にAPIキーを作成してください。",createFirstKey:"最初のキーを作成",deleteApiKeyTitle:"APIキーを削除",deleteApiKeyMessage:"このAPIキーを削除してもよろしいですか?このキーを使用しているすべての連携が動作しなくなります。",deleteKey:"キーを削除",webhookEndpoints:"Webhookエンドポイント",webhookApiKeyHint:"X-API-KeyヘッダーでAPIキーを使用してください。",webhookGetAll:"すべてのプリンターステータスを取得",webhookGetOne:"特定のプリンターステータスを取得",webhookQueue:"印刷キューに追加",webhookPause:"印刷を一時停止",webhookResume:"印刷を再開",webhookStop:"印刷を停止",apiBrowser:"APIブラウザ",apiBrowserDescription:"すべての利用可能なAPIエンドポイントを探索してテストします。",apiKeyForTesting:"テスト用APIキー",apiKeyHeaderHint:"このキーはリクエストのX-API-Keyヘッダーとして送信されます。",apiKeyCreateFailed:"APIキーの作成に失敗しました: {{error}}",apiKeyDeleteFailed:"APIキーの削除に失敗しました: {{error}}",amsThresholds:"AMS表示しきい値",amsThresholdsDescription:"AMS湿度と温度インジケーターの色しきい値を設定します。",humidity:"湿度",goodGreen:"良好(緑)≤",fairOrange:"普通(オレンジ)≤",aboveFairBad:"普通のしきい値以上は赤(悪い)で表示",temperature:"温度",goodBlue:"良好(青)≤",aboveFairHot:"普通のしきい値以上は赤(高温)で表示",historyRetention:"履歴の保持",keepHistoryFor:"センサー履歴の保持期間",days:"日",historyRetentionDescription:"古い湿度と温度データは自動的に削除されます",printModal:"印刷ダイアログ",expandMapping:"カスタムマッピングをデフォルトで展開",expandMappingDescription:"複数のプリンターに印刷する際、プリンターごとのAMSマッピングを展開して表示",currentUser:"現在のユーザー",role:"ロール:",roleAdmin:"管理者",roleUser:"ユーザー",manageUsers:"ユーザー管理",disableAuth:"認証を無効化",rolePermissions:"ロール権限",rolePermissionsDescription:"各ロールの権限の概要。",adminPerm1:"プリンター設定の管理",adminPerm2:"ユーザーの作成、編集、削除",adminPerm3:"すべてのシステム機能へのアクセス",userPerm1:"印刷ジョブの送信",userPerm2:"ファイルとアーカイブの管理",userPerm3:"フィラメントの管理",disableAuthTitle:"認証を無効化",disableAuthMessage:"認証を無効にしてもよろしいですか?これにより、Bambuddyインスタンスはログインなしでアクセス可能になります。すべてのユーザーはデータベースに残りますが、認証は無効になります。",disableAuthConfirm:"認証を無効化",authDisabledSuccess:"認証を正常に無効化しました",disableAuthFailed:"認証の無効化に失敗しました",unknownError:"不明なエラー",haUrlPlaceholder:"http://homeassistant.local:8123",haTokenPlaceholder:"長期アクセストークン",mqttHostPlaceholder:"例: 192.168.1.100",leaveEmptyAnonymous:"匿名接続の場合は空欄",mqttTopicDefault:"bambuddy",apiKeyNamePlaceholder:"例: Home Assistantインテグレーション",apiKeyTestPlaceholder:"テスト用APIキーを貼り付け",unnamedKey:"名前なしキー",plugsOnline:"{{online}}/{{total}} オンライン",passed:"{{count}}件 成功",failed:"{{count}}件 失敗",externalUrlPlaceholder:"http://192.168.1.100:8000",bulkPlugTitle:"すべてのプラグを{{action}}",bulkPlugMessage:"有効な{{count}}個のスマートプラグをすべて{{action}}しますか?",bulkPlugConfirm:"すべて{{action}}",updateCheckFailed:"確認失敗: {{error}}",releaseNotesTitle:"リリースノート - v{{version}}",mqttTopicsHint:"トピック: {{prefix}}/printers/<serial>/status など",virtualPrinterUpdated:"仮想プリンター設定を更新しました",vp:{title:"仮想プリンター",running:"稼働中",stopped:"停止中",description:"Bambu StudioやOrcaSlicerに表示される仮想プリンターを有効にします。このプリンターに送信されたファイルは印刷せずに直接アーカイブされます。",enable:"仮想プリンターを有効化",visibleInSlicer:"スライサーの検出リストに「Bambuddy」として表示",notVisible:"スライサーに表示されません",printerModel:"プリンターモデル",printerModelDescription:"エミュレートするプリンターモデルを選択します。",modelRestartWarning:"モデルを変更すると仮想プリンターが再起動されます",accessCode:"アクセスコード",accessCodeSet:"アクセスコードが設定済み",noAccessCode:"アクセスコード未設定 - 有効化に必要です",accessCodeRequired:"先にアクセスコードを設定してください",accessCodeEmpty:"アクセスコードは空にできません",accessCodeLength:"アクセスコードは8文字である必要があります",accessCodeHint:"8文字である必要があります。スライサーの認証に使用されます。",mode:"モード",modeArchive:"アーカイブ",modeArchiveDesc:"ファイルを即座にアーカイブ",modeReview:"レビュー",modeReviewDesc:"アーカイブ前にレビューとタグ付け",modeQueue:"キュー",modeQueueDesc:"アーカイブしてキューに追加",setupRequired:"セットアップが必要",setupDescription:"仮想プリンター機能を使用するには、追加のシステム設定が必要です。ポートフォワーディング、ファイアウォールルール、プラットフォーム固有の設定が含まれます。",readSetupGuide:"有効化する前にセットアップガイドをお読みください",howItWorks:"仕組み:",step1:"お使いのプラットフォームのセットアップガイドを完了する",step2:"仮想プリンターを有効にしてアクセスコードを設定する",step3:"Bambu StudioまたはOrcaSlicerで「プリンターを追加」を開く",step4:"検出リストに「Bambuddy」プリンターが表示される",step5:"設定したアクセスコードで接続する",step6:"Bambuddyに「印刷」すると、3MFファイルがアーカイブされる",statusDetails:"ステータス詳細",printerName:"プリンター名",model:"モデル",serialNumber:"シリアルナンバー",pendingFiles:"保留中のファイル"},enterNewCodeToChange:"新しいコードを入力して変更",enter8CharCode:"8文字のコードを入力",notificationTitlePlaceholder:"通知タイトル...",notificationBodyPlaceholder:"通知本文...",templateTitleRequired:"タイトルは必須です",templateBodyRequired:"本文は必須です",editTemplate:"テンプレートを編集: {{name}}",templateTitle:"タイトル",templateBody:"本文",availableVariables:"利用可能な変数",insertVariableHint:"クリックして本文のカーソル位置に挿入",livePreview:"ライブプレビュー",loadingPreview:"プレビューを読み込み中...",previewTitle:"タイトル:",previewBody:"本文:",enterTemplateToPreview:"テンプレートの内容を入力するとプレビューが表示されます",resetToDefault:"デフォルトに戻す",noExternalLinks:"外部リンクが設定されていません",clickAddLink:"「リンクを追加」をクリックして追加",deleteLink:"リンクを削除",deleteLinkConfirm:"「{{name}}」を削除しますか?この操作は取り消せません。",editLink:"リンクを編集",addExternalLink:"外部リンクを追加",addLink:"リンクを追加",sidebarLinks:"サイドバーリンク",sidebarLinksDescription:"外部リンクをサイドバーナビゲーションに追加します。ドラッグで並べ替え。",linkNamePlaceholder:"マイリンク",linkNameLabel:"名前",linkUrlLabel:"URL",linkIconLabel:"アイコン",linkCustomIcon:"カスタムアイコン",linkCustomIconHint:"PNG, JPG, GIF, SVG, WebP, ICO。最大1MB。",linkChoosePresetIcon:"またはプリセットアイコンを選択",linkNameRequired:"名前は必須です",linkUrlRequired:"URLは必須です",linkUrlInvalid:"URLは http:// または https:// で始まる必要があります",linkInvalidImageType:"有効な画像ファイルを選択してください(PNG, JPG, GIF, SVG, WebP, ICO)",linkImageTooLarge:"画像ファイルは1MB以下にしてください",removeCustomIcon:"カスタムアイコンを削除",jsonRequestBody:"JSONリクエストボディ...",searchEndpoints:"エンドポイントを検索...",groups:"グループ",addGroup:"グループを追加",noGroupsFound:"グループが見つかりません",systemGroup:"システム",noDescription:"説明なし",users:"ユーザー",addUser:"ユーザーを追加",noUsersFound:"ユーザーが見つかりません",admin:"管理者",authentication:"認証",authEnableDescription:"認証を有効にして、ユーザーアカウントの作成、権限の管理、Bambuddyインスタンスのセキュリティ保護を行います。",authSecuredDescription:"Bambuddyインスタンスは認証で保護されています。",enable:"有効にする",disable:"無効にする",changePassword:"パスワードを変更",backup:"バックアップ",backupAndRestore:"バックアップと復元",backupAndRestoreDescription:"Bambuddyデータのバックアップを作成および復元します",goToBackup:"バックアップへ移動",homeAssistantDescriptionFull:"Home Assistantに接続してスマートホームデバイスを制御します",usersCount:"{{count}}人のユーザー",permissionsCount:"{{count}}個の権限",authDisabledTitle:"認証が無効です",authDisabledDescription:"認証を有効にして、ユーザーアカウントの作成、権限の管理、Bambuddyインスタンスのセキュリティを確保しましょう。",authFeature1:"システムへのアクセスにログインを要求",authFeature2:"グループベースの権限を持つ複数のユーザーを作成",authFeature3:"50以上のきめ細かい権限でアクセスを制御",enableAuthentication:"認証を有効にする",createUser:"ユーザーを作成",username:"ユーザー名",enterUsername:"ユーザー名を入力",password:"パスワード",enterPassword:"パスワードを入力(6文字以上)",confirmPassword:"パスワードの確認",confirmPasswordPlaceholder:"パスワードを確認",passwordsDoNotMatch:"パスワードが一致しません",groupsLabel:"グループ",systemLabel:"(システム)",noGroupsAvailable:"利用可能なグループがありません",creating:"作成中...",editUser:"ユーザーを編集",leaveBlankToKeep:"(現在のパスワードを維持する場合は空白)",enterNewPassword:"新しいパスワードを入力",confirmNewPassword:"新しいパスワードを確認",deleteUser:"ユーザーを削除",deleteUserConfirm:"このユーザーを削除してもよろしいですか?この操作は元に戻せません。",createGroup:"グループを作成",editGroup:"グループを編集",groupName:"グループ名",enterGroupName:"グループ名を入力",systemGroupNameReadonly:"システムグループ名は変更できません",descriptionLabel:"説明",enterDescription:"説明を入力(任意)",permissionsSelected:"権限({{count}}件選択中)",deleteGroup:"グループを削除",deleteGroupConfirm:"このグループを削除してもよろしいですか?このグループのユーザーはこれらの権限を失います。",changePasswordTitle:"パスワードの変更",currentPassword:"現在のパスワード",enterCurrentPassword:"現在のパスワードを入力",newPassword:"新しいパスワード",enterNewPasswordMin6:"新しいパスワードを入力(6文字以上)",confirmNewPasswordPlaceholder:"新しいパスワードを確認",passwordMinLength:"パスワードは6文字以上である必要があります",passwordChanged:"パスワードが正常に変更されました",failedToChangePassword:"パスワードの変更に失敗しました",changingPassword:"変更中...",prometheusTitle:"Prometheusメトリクス",prometheusDescriptionPre:"プリンターメトリクスを",prometheusDescriptionPost:"でPrometheus/Grafanaモニタリング用に公開します。",enableMetricsEndpoint:"メトリクスエンドポイントを有効化",exposePrometheusData:"プリンターデータをPrometheus形式で公開",bearerTokenOptional:"Bearerトークン(任意)",bearerTokenPlaceholder:"認証不要の場合は空欄のまま",bearerTokenHint:"設定した場合、リクエストに次のヘッダーが必要: ",availableMetrics:"利用可能なメトリクス",metricConnectionStatus:"接続状態",metricPrinterState:"プリンター状態(アイドル/印刷中など)",metricPrintProgress:"印刷進捗 0-100%",metricBedTemp:"ベッド温度",metricNozzleTemp:"ノズル温度",metricPrintsTotal:"結果別の合計印刷数",metricAndMore:"...その他(レイヤー、ファン、キュー、フィラメント使用量)"},notification:{printStarted:{title:"印刷開始",body:"{{printer}}: {{filename}} の印刷を開始しました"},printCompleted:{title:"印刷完了",body:"{{printer}}: {{filename}} が正常に完了しました"},printFailed:{title:"印刷失敗",body:"{{printer}}: {{filename}} が失敗しました"},printStopped:{title:"印刷中止",body:"{{printer}}: {{filename}} が中止されました"},printProgress:{title:"印刷進捗",body:"{{printer}}: {{filename}} は {{percent}}% 完了"},printerOffline:{title:"プリンターオフライン",body:"{{printer}} がオフラインです"},printerError:{title:"プリンターエラー",body:"{{printer}}: {{error}}"},filamentLow:{title:"フィラメント残量低下",body:"{{printer}}: フィラメントが残りわずかです"},maintenanceDue:{title:"メンテナンス期限",body:"{{printer}}: {{items}} の対応が必要です"}},errors:{generic:"問題が発生しました",networkError:"ネットワークエラーです。接続を確認してください。",notFound:"見つかりません",unauthorized:"認証エラー",serverError:"サーバーエラー",validationError:"入力内容を確認してください",printerConnectionFailed:"プリンターへの接続に失敗しました",saveFailed:"保存に失敗しました",deleteFailed:"削除に失敗しました",loadFailed:"データの読み込みに失敗しました"},confirm:{delete:"削除しますか?",unsavedChanges:"保存されていない変更があります。このページを離れますか?",clearQueue:"キューをクリアしますか?"},calendar:{months:{january:"1月",february:"2月",march:"3月",april:"4月",may:"5月",june:"6月",july:"7月",august:"8月",september:"9月",october:"10月",november:"11月",december:"12月"},daysShort:{sun:"日",mon:"月",tue:"火",wed:"水",thu:"木",fri:"金",sat:"土"}},notificationLog:{title:"通知ログ",lastDays:"過去{{days}}日間:",notifications:"件の通知",sent:"送信済み",failed:"失敗",last24Hours:"過去24時間",showFailedOnly:"失敗のみ表示",clearOld:"古いログを削除",noFailedNotifications:"失敗した通知はありません",noNotificationsLogged:"通知ログはありません",unknownProvider:"不明なプロバイダー",titleLabel:"タイトル",messageLabel:"メッセージ",errorLabel:"エラー",provider:"プロバイダー:",time:"時間:",clearLogsFailed:"ログの削除に失敗しました: {{error}}",events:{print_start:"印刷開始",print_complete:"印刷完了",print_failed:"印刷失敗",print_stopped:"印刷中止",print_progress:"進捗",printer_offline:"プリンターオフライン",printer_error:"プリンターエラー",filament_low:"フィラメント残量低下",maintenance_due:"メンテナンス期限",ams_humidity_high:"AMS湿度高",ams_temperature_high:"AMS温度高",test:"テスト"}},providers:{callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"メール",discord:"Discord",webhook:"Webhook",descriptions:{email:"SMTPメール通知",telegram:"Telegramボット経由の通知",discord:"Webhook経由でDiscordチャンネルに送信",ntfy:"無料のセルフホスト対応プッシュ通知",pushover:"シンプルで確実なプッシュ通知",callmebot:"CallMeBot経由の無料WhatsApp通知",webhook:"任意のURLへの汎用HTTP POST"}},backup:{categories:{settings:"設定",notification_providers:"通知プロバイダー",notification_templates:"通知テンプレート",smart_plugs:"スマートプラグ",printers:"プリンター",filaments:"フィラメント",maintenance_types:"メンテナンスタイプ",archives:"アーカイブ",projects:"プロジェクト",pending_uploads:"アップロード待ち",external_links:"外部リンク",api_keys:"APIキー"},notificationProviders:"通知プロバイダー",notificationTemplates:"通知テンプレート",externalLinks:"外部リンク",printers:"プリンター",filamentInventory:"フィラメント在庫",maintenanceTypes:"メンテナンスタイプ",printArchives:"印刷アーカイブ",projects:"プロジェクト",pendingUploads:"保留中のアップロード",apiKeys:"APIキー",settingsDescription:"言語、テーマ、更新設定",notificationProvidersDescription:"ntfy、Pushover、Discordなど",notificationTemplatesDescription:"カスタムメッセージテンプレート",smartPlugsDescription:"Tasmotaプラグ設定",externalLinksDescription:"外部サービスへのサイドバーリンク",printersDescription:"プリンター情報(アクセスコードを除く)",filamentInventoryDescription:"フィラメントの種類とコスト",maintenanceDescription:"カスタムメンテナンススケジュール",printArchivesDescription:"全印刷データ+ファイル(3MF、サムネイル、写真)",projectsDescription:"プロジェクト、BOMアイテム、添付ファイル",pendingUploadsDescription:"レビュー待ちの仮想プリンターアップロード",apiKeysDescription:"Webhook APIキー(インポート時に新しいキーが生成されます)",restoreBackup:"バックアップの復元",restoreDescription:"バックアップファイルからすべてのデータを置き換える",restoreNote:"復元中、仮想プリンターは停止されます"},restore:{failedToRestore:"バックアップの復元に失敗しました。ファイル形式を確認してください。",title:"バックアップの復元",restoring:"復元中...",complete:"復元完了",failed:"復元失敗",importDescription:"バックアップファイルから設定をインポート",pleaseWait:"データを復元しています。しばらくお待ちください",duplicateHandling:"重複処理の仕組み:",clickToSelect:"クリックしてバックアップファイルを選択 (.json または .zip)",replaceExisting:"既存データを上書き",keepExisting:"既存データを保持",overwriteDescription:"既に存在する項目をバックアップデータで上書きします",skipDescription:"まだ存在しない項目のみ復元します",caution:"注意:",overwriteWarning:"上書きすると、現在の設定がバックアップのデータに置き換えられます。セキュリティのため、プリンターのアクセスコードは上書きされません。",restore:"復元",processing:"バックアップファイルを処理中...",itemsRestored:"復元済み項目",itemsSkipped:"スキップ済み項目",restoredSection:"復元済み",filesSection:"ファイル (3MF、サムネイルなど)",skippedSection:"スキップ (既に存在)",andMore:"...他 {{count}} 件",newApiKeys:"新しいAPIキーが生成されました",copyKeysWarning:"これらのキーは一度だけ表示されます。今すぐコピーしてください!",copy:"コピー",noDataFound:"バックアップファイルに復元するデータが見つかりませんでした。",dupPrinters:"プリンター",dupPrintersDesc:"シリアル番号で照合",dupSmartPlugs:"スマートプラグ",dupSmartPlugsDesc:"IPアドレスで照合",dupNotificationProviders:"通知プロバイダー",dupNotificationProvidersDesc:"名前で照合",dupFilaments:"フィラメント",dupFilamentsDesc:"名前 + 種類 + ブランドで照合",dupArchives:"アーカイブ",dupArchivesDesc:"コンテンツハッシュで照合 (常にスキップ)",dupPendingUploads:"アップロード待ち",dupPendingUploadsDesc:"ファイル名で照合",dupSettingsTemplates:"設定とテンプレート",dupSettingsTemplatesDesc:"常に上書き"},files:{root:"ルート",cache:"キャッシュ",models:"モデル",timelapse:"タイムラプス",used:"使用中:",free:"空き:",filterPlaceholder:"ファイルを検索...",noFiles:"このディレクトリにファイルがありません",deleteFile:"ファイルを削除",deleteConfirm:'"{{name}}"を削除しますか?この操作は元に戻せません。',fileManager:"ファイル管理",pageDescription:"プリントファイルを整理・管理",newFolder:"新しいフォルダ",folderName:"フォルダ名",folderNamePlaceholder:"例: 機能パーツ",renameFile:"ファイル名を変更",renameFolder:"フォルダ名を変更",rename:"名前変更",rootNoFolder:"ルート(フォルダなし)",moveFilesCount:"{{count}}個のファイルを移動",current:"(現在)",move:"移動",linkFolder:"フォルダをリンク",linkFolderDescription:"「{{name}}」をプロジェクトまたはアーカイブにリンクしてすばやくアクセス。",noProjectsFound:"プロジェクトが見つかりません",noArchivesFound:"アーカイブが見つかりません",unlink:"リンク解除",link:"リンク",uploadFiles:"ファイルをアップロード",dropFilesHere:"ここにファイルをドロップ",dragAndDropFiles:"ファイルをドラッグ&ドロップ",orClickToBrowse:"またはクリックして選択",zipAutoExtract:"ZIPファイルは自動的に展開されます",zipFilesDetected:"ZIPファイルを検出",zipChooseHandling:"ZIPファイルが展開されます。フォルダ構造の処理方法を選択してください:",preserveZipStructure:"ZIPのフォルダ構造を保持",willBeExtracted:"• 展開予定",filesExtracted:"• {{count}}個のファイルを展開済み",uploadComplete:"アップロード完了: {{count}}個成功",uploadErrorCount:"、{{count}}個失敗",uploading:"アップロード中...",filesFailed:"{{count}}個のファイルが失敗",uploadFailed:"アップロード失敗",linkToProjectOrArchive:"プロジェクトまたはアーカイブにリンク",changeLink:"リンクを変更...",linkTo:"リンク先...",printedCount:"{{count}}回印刷済み",addToQueue:"キューに追加",adding:"追加中...",folderCreated:"フォルダを作成しました",folderDeleted:"フォルダを削除しました",fileDeleted:"ファイルを削除しました",deletedFiles:"{{count}}個のファイルを削除しました",filesMoved:"ファイルを移動しました",folderUnlinked:"フォルダのリンクを解除しました",folderLinked:"フォルダをリンクしました",addedToQueue:"{{count}}個のファイルをキューに追加しました",addedToQueueWithErrors:"{{added}}個追加、{{errors}}個失敗",failedToAddFiles:"ファイルの追加に失敗: {{error}}",fileRenamed:"ファイル名を変更しました",folderRenamed:"フォルダ名を変更しました",gridView:"グリッド表示",listView:"リスト表示",lowDiskSpaceWarning:"ディスク容量不足の警告",lowDiskSpaceDescription:"空き容量は{{free}}(合計{{total}})。しきい値は設定で{{threshold}} GBに設定されています。",filesLabel:"ファイル:",foldersLabel:"フォルダ:",sizeLabel:"サイズ:",freeLabel:"空き:",folders:"フォルダ",allFiles:"すべてのファイル",allTypes:"すべての種類",date:"日付",size:"サイズ",type:"種類",prints:"印刷回数",ascending:"昇順",descending:"降順",filteredCount:"{{total}}件中{{filtered}}件",deselectAll:"すべて選択解除",selectAll:"すべて選択",selectedCount:"{{count}}件選択中",loadingFiles:"ファイルを読み込み中...",folderEmpty:"フォルダは空です",noFilesYet:"ファイルはまだありません",emptyFolderDescription:"ファイルをアップロードするか、このフォルダにファイルを移動してください。",emptyRootDescription:"プリント関連ファイルの整理を始めるにはファイルをアップロードしてください。",noMatchingFiles:"一致するファイルがありません",noMatchingFilesDescription:"現在の検索またはフィルター条件に一致するファイルがありません。",clearFilters:"フィルターをクリア",sort:{nameAsc:"名前 (A-Z)",nameDesc:"名前 (Z-A)",sizeAsc:"サイズ (小さい順)",sizeDesc:"サイズ (大きい順)",dateAsc:"日付 (古い順)",dateDesc:"日付 (新しい順)"},searchFiles:"ファイルを検索...",deleteFolder:"フォルダを削除",deleteBulkTitle:"{{count}}件のファイルを削除",deleteFolderConfirm:"このフォルダを削除しますか?中のファイルもすべて削除されます。",deleteMultipleConfirm:"選択した{{count}}件のファイルを削除しますか?この操作は元に戻せません。",deleteFileConfirm:"このファイルを削除しますか?",deleting:"削除中..."},printOptions:{title:"印刷オプション",bedLevelling:"ベッドレベリング",bedLevellingDesc:"印刷前にベッドを自動レベリング",flowCali:"フローキャリブレーション",flowCaliDesc:"押出量を校正",vibrationCali:"振動キャリブレーション",vibrationCaliDesc:"リンギングを低減",layerInspect:"初層検査",layerInspectDesc:"AIによる初層の検査",timelapse:"タイムラプス",timelapseDesc:"タイムラプス動画を記録"},printModal:{powerOffWhenDone:"完了後にプリンターの電源をオフ",immediateHelp:"プリンターがアイドル状態になり次第、印刷を開始します。",scheduledHelp:"スケジュールされた時間にプリンターがアイドル状態であれば印刷を開始します。ビジー状態の場合は、利用可能になるまで待機します。",stagedHelp:"印刷はステージングされますが、自動的には開始されません。キューに送るにはスタートボタンを使用してください。",print:"印刷",reprint:"再印刷",printToMultiple:"{{count}}台のプリンターに印刷",editQueueItem:"キューアイテムを編集",sameTypeDifferentColor:"同じタイプ、異なる色",filamentTypeNotLoaded:"フィラメントタイプが読み込まれていません",specificPrinter:"特定のプリンター",selectPrinters:"プリンターを選択",selectAll:"すべて選択",printersSelected:"{{count}}台のプリンターを選択中",noPrintersAvailable:"利用可能なプリンターがありません",noActivePrintersAvailable:"アクティブなプリンターがありません",inactive:"非アクティブ",unknownModel:"不明なモデル",customMapping:"カスタムマッピング",auto:"自動",showAll:"すべて表示",selectAtLeastOne:"プリンターを1台以上選択してください",selectTargetModel:"ターゲットモデルを選択",selectSlot:"スロットを選択...",reRead:"再読み込み",customSlotMapping:"カスタムスロットマッピング",autoMatched:"自動マッチ",manuallySelected:"手動選択",schedulerWillAssign:"スケジューラーが最初に利用可能なアイドル状態の{{model}}プリンターに割り当てます",inLocation:"{{location}}内",anyModel:"任意の{{model}}",hiddenPrinters:"他{{count}}台のプリンターが非表示(異なるモデル)",showOnlyModel:"{{model}}プリンターのみ表示",matchedCount:"({{matched}}/{{total}} 一致)",targetModelLabel:"ターゲットモデル",selectAModel:"モデルを選択...",locationFilterLabel:"ロケーションフィルター(任意)",anyLocation:"すべてのロケーション"},login:{title:"Bambuddy ログイン",subtitle:"アカウントにサインイン",username:"ユーザー名",usernamePlaceholder:"ユーザー名を入力",password:"パスワード",passwordPlaceholder:"パスワードを入力",loggingIn:"ログイン中...",signIn:"サインイン",enterCredentials:"ユーザー名とパスワードを入力してください",success:"ログインしました",failed:"ログインに失敗しました"},setup:{title:"Bambuddy セットアップ",description:"Bambuddyインスタンスの認証を設定します",enableAuthentication:"認証を有効にする",adminAccount:"管理者アカウント",adminAccountDescription:"既に管理者ユーザーが存在する場合、既存の管理者アカウントを使用して認証が有効になります。既存の管理者を使用するには以下のフィールドを空のままにするか、新しい管理者ユーザーを作成するには新しい認証情報を入力してください。",adminUsername:"管理者ユーザー名",adminPassword:"管理者パスワード",optionalIfAdminsExist:"管理者ユーザーが存在する場合は任意",placeholderAdminUsername:"管理者ユーザー名を入力(任意)",placeholderAdminPassword:"管理者パスワードを入力(任意)",confirmPassword:"パスワードの確認",placeholderConfirmPassword:"管理者パスワードを確認",settingUp:"セットアップ中...",completeSetup:"セットアップを完了",toast:{authEnabledAdminCreated:"認証が有効になり、管理者ユーザーが作成されました",authEnabledExistingAdmins:"既存の管理者ユーザーを使用して認証が有効になりました",setupCompleted:"セットアップが完了しました",enterBothOrLeaveEmpty:"管理者ユーザー名とパスワードの両方を入力するか、既存の管理者ユーザーを使用するには両方を空にしてください",passwordsDoNotMatch:"パスワードが一致しません",passwordMinLength:"パスワードは6文字以上必要です"}},users:{title:"ユーザー管理",description:"Bambuddyインスタンスのユーザーとアクセスを管理します",noPermission:"このページにアクセスする権限がありません。",backToSettings:"設定に戻る",createUser:"ユーザーを作成",deleteUser:"ユーザーを削除",deleteConfirmMessage:"このユーザーを削除してもよろしいですか?この操作は元に戻せません。",password:"パスワード",placeholderUsername:"ユーザー名を入力",placeholderPassword:"パスワードを入力",roleUser:"ユーザー",roleAdmin:"管理者",statusActive:"アクティブ",statusInactive:"非アクティブ",save:"保存",cancel:"キャンセル",edit:"編集",delete:"削除",creating:"作成中...",admin:"管理者",editUser:"ユーザーを編集",groups:"グループ",noGroups:"グループなし",noGroupsAvailable:"利用可能なグループがありません",confirmPassword:"パスワードの確認",placeholderNewPassword:"新しいパスワード",placeholderConfirmPassword:"パスワードの確認",placeholderConfirmNewPassword:"新しいパスワードの確認",leaveBlankToKeepCurrent:"現在のパスワードを維持する場合は空のままにしてください",saveChanges:"変更を保存",saving:"保存中...",system:"システム",table:{username:"ユーザー名",role:"ロール",status:"ステータス",actions:"アクション",groups:"グループ"},toast:{userCreated:"ユーザーが正常に作成されました",userUpdated:"ユーザーが正常に更新されました",userDeleted:"ユーザーが正常に削除されました",fillRequiredFields:"必須項目をすべて入力してください",passwordMinLength:"パスワードは6文字以上である必要があります",passwordsDoNotMatch:"パスワードが一致しません"}},upload:{title:"3MFファイルのアップロード",dragDrop:".3mfファイルをここにドラッグ&ドロップ",or:"または",browseFiles:"ファイルを参照",associatePrinter:"プリンターに関連付け(任意)",noPrinter:"プリンターなし",uploaded:"アップロード済み",failedCount:"失敗",filesUploaded:"{{count}}ファイルをアップロードしました",printerModelExtracted:"プリンターモデルは3MFメタデータから自動抽出されます",filesFailed:"{{count}}ファイルのアップロードに失敗しました",partialResult:"{{uploaded}}件アップロード、{{failed}}件失敗",failed:"アップロードに失敗しました",uploading:"アップロード中...",upload:"アップロード"},gcode:{loading:"G-codeを読み込み中...",notAvailable:"G-codeが利用できません",notSlicedMessage:"このファイルはまだスライスされていません。G-codeプレビューはBambu StudioまたはOrca Slicerでスライス後に利用可能です。",loadFailed:"G-codeの読み込みに失敗しました"},dashboard:{dragToReorder:"ドラッグして並べ替え",sizeClickCycle:"サイズ: {{size}} - クリックで変更",hideWidget:"ウィジェットを非表示",resetLayout:"レイアウトをリセット",hiddenCount:"{{count}}件非表示",hiddenWidgets:"非表示のウィジェット(クリックで表示):",allHidden:"すべてのウィジェットが非表示です。"},printerQueue:{nextInQueue:"次のキュー",asap:"即時",now:"今すぐ",inLessThanMin:"1分以内",inMinutes:"{{count}}分後",inHours:"{{count}}時間後"},smartPlug:{offline:"オフライン",admin:"管理",openAdminPage:"プラグの管理ページを開く",linkedTo:"接続先:",alerts:"アラート",automationSettings:"自動化設定",showInSwitchbar:"スイッチバーに表示",switchbarDesc:"サイドバーからクイックアクセス",enabledDesc:"このプラグの自動化を有効にする",autoOffDesc:"印刷完了後に自動オフ(1回のみ)",delayMode:"オフ遅延モード",temp:"温度",delayMinutes:"遅延(分)",tempThreshold:"温度しきい値(℃)",tempThresholdDesc:"ノズルがこの温度以下に冷えたらオフにします",deleteTitle:"スマートプラグを削除",deleteConfirm:'"{{name}}"を削除してもよろしいですか?この操作は元に戻せません。',turnOnTitle:"スマートプラグをオン",turnOnConfirm:'"{{name}}"をオンにしてもよろしいですか?',turnOn:"オン",turnOffTitle:"スマートプラグをオフ",turnOffConfirm:'"{{name}}"をオフにしてもよろしいですか?接続されたデバイスの電源が切断されます。',turnOff:"オフ",controlFailed:'"{{name}}"の{{action}}に失敗しました',monitorOnly:"モニタリングのみ",waiting:"データを待機中...",monitor:"モニター",power:"電力",kwhToday:"本日の消費電力",settings:"設定",smartSwitches:"スマートスイッチ",noSwitchesInSwitchbar:"スイッチバーに有効なスイッチがありません",enableInSettings:"設定 → スマートプラグで有効にしてください"},addSmartPlug:{addTitle:"スマートプラグを追加",editTitle:"スマートプラグを編集",tasmota:"Tasmota",homeAssistant:"Home Assistant",stopScanning:"スキャンを停止",discoverDevices:"Tasmotaデバイスを検出",scanningNetwork:"ネットワークをスキャン中...",foundDevices:"{{count}}台のデバイスが見つかりました - クリックして選択:",noDevicesFound:"ネットワーク上にTasmotaデバイスが見つかりません",failedToStartScan:"スキャンの開始に失敗しました",haNotConfigured:"Home Assistantが設定されていません。",haNotConfiguredPath:"設定 → ネットワーク → Home Assistant で設定してください",selectEntity:"エンティティを選択",chooseEntity:"エンティティを選択...",loadingEntities:"エンティティを読み込み中...",failedToLoadEntities:"エンティティの読み込みに失敗しました: {{error}}",searchEntities:"エンティティを検索...",noEntitiesMatching:"「{{search}}」に一致するエンティティが見つかりません",noEntitiesAvailable:"利用可能なエンティティがありません",searchingEntities:"すべてのエンティティを検索中({{count}}件見つかりました)",showingEntities:"switch、light、input_booleanを表示中({{count}}件利用可能)",energyMonitoring:"エネルギーモニタリング(任意)",energyMonitoringDescription:"電力/エネルギーデータを提供するセンサーを検索して選択します。",powerSensor:"電力センサー(W)",searchPowerSensors:"電力センサーを検索...",energyToday:"今日のエネルギー(kWh)",totalEnergy:"総エネルギー(kWh)",searchEnergySensors:"エネルギーセンサーを検索...",noMatchingSensors:"一致するセンサーがありません",ipAddress:"IPアドレス",ipAddressPlaceholder:"192.168.1.100",test:"テスト",connected:"接続されました!",device:"デバイス",state:"状態",connectionFailed:"接続に失敗しました",name:"名前",namePlaceholder:"リビングのプラグ",username:"ユーザー名",usernamePlaceholder:"admin",password:"パスワード",passwordPlaceholder:"********",authHint:"Tasmotaデバイスが認証を必要としない場合は空のままにしてください",linkToPrinter:"プリンターに連携",noPrinterOption:"プリンターなし(手動制御のみ)",linkToPrinterHint:"連携すると印刷の開始/完了時に自動オン/オフが有効になります",powerAlerts:"電力アラート",alertAbove:"超過時にアラート(W)",alertAbovePlaceholder:"例: 200",alertBelow:"下回った時にアラート(W)",alertBelowPlaceholder:"例: 10",powerAlertHint:"消費電力がこれらのしきい値を超えた/下回った場合に通知します。無効にするには空のままにしてください。",dailySchedule:"デイリースケジュール",turnOnAt:"オンにする時刻",turnOffAt:"オフにする時刻",scheduleHint:"毎日これらの時刻にプラグを自動的にオン/オフします。スキップするには空のままにしてください。",showInSwitchbar:"スイッチバーに表示",showInSwitchbarHint:"サイドバーからクイックアクセス",nameRequired:"名前は必須です",ipRequired:"Tasmotaプラグの場合、IPアドレスは必須です",entityRequired:"Home Assistantプラグの場合、エンティティは必須です",mqtt:"MQTT",mqttTopicRequired:"MQTTトピックは、電力、エネルギー、またはステートのいずれかを設定する必要があります",mqttBrokerNotConfigured:"MQTTブローカーが設定されていません。ブローカーアドレスを設定してください:",mqttBrokerNotConfiguredPath:"設定 → ネットワーク → MQTT発行",mqttBrokerNotConfiguredHint:"(パブリッシュを有効にする必要はありません。ブローカーの詳細を入力するだけです)。",mqttMonitorOnly:"モニタリングのみ",mqttMonitorOnlyDescription:"MQTTプラグはMQTTサブスクリプション経由で電力/エネルギーデータを受信します。オン/オフ制御はできません - MQTTブローカーまたはホームオートメーションシステムを使用してください。",mqttPowerMonitoring:"電力モニタリング",mqttEnergyMonitoring:"エネルギーモニタリング",mqttStateMonitoring:"ステートモニタリング",mqttTopic:"トピック",mqttJsonPath:"JSONパス",mqttMultiplier:"乗数",mqttOnValue:"ONの値",mqttPowerJsonPathHint:"JSONパスはJSONペイロードから値を抽出します(例:「power_l1」)。トピックが生の数値を発行する場合は空のままにしてください。",mqttPowerMultiplierHint:"乗数 0.001 で mW→W、1000 で kW→W に変換します。",mqttEnergyJsonPathHint:"JSONパスはJSONペイロードから値を抽出します。生の値の場合は空のままにしてください。",mqttEnergyMultiplierHint:"乗数 0.001 で Wh→kWh、1000 で MWh→kWh に変換します。",mqttStateJsonPathHint:"JSONパスはJSONペイロードから値を抽出します。生の値の場合は空のままにしてください。",mqttStateOnValueHint:"ONの値:「ON」を意味する正確な文字列。自動検出(ON、true、1)の場合は空のままにしてください。"},addNotification:{addTitle:"通知プロバイダーを追加",editTitle:"通知プロバイダーを編集",nameRequired:"名前は必須です",fieldRequired:"{{field}}は必須です",namePlaceholder:"マイ通知",providerType:"プロバイダータイプ",configuration:"設定",testConfiguration:"設定をテスト",printerFilter:"プリンターフィルター",allPrinters:"すべてのプリンター",printerFilterDesc:"このプリンターのイベントのみ通知を送信",quietHours:"サイレント時間(おやすみモード)",start:"開始",end:"終了",dailyDigest:"デイリーダイジェスト",dailyDigestDesc:"通知をまとめて1日1回のサマリーとして送信",sendDigestAt:"ダイジェスト送信時刻",digestDescription:"イベントを収集し、この時刻にまとめて送信します",notificationEvents:"通知イベント",printEvents:"印刷イベント",printerStatus:"プリンターステータス",events:{start:"開始",complete:"完了",failed:"失敗",stopped:"停止",progress:"進捗",offline:"オフライン",error:"エラー",lowFilament:"フィラメント残量少",maintenance:"メンテナンス"},config:{callmebot:{phoneNumber:"電話番号",apiKey:"APIキー",apiKeyPlaceholder:"CallMeBot APIキー"},ntfy:{serverUrl:"サーバーURL",topic:"トピック",authToken:"認証トークン",authTokenPlaceholder:"認証(任意)"},pushover:{userKey:"ユーザーキー",userKeyPlaceholder:"Pushoverユーザーキー",appToken:"アプリトークン",appTokenPlaceholder:"Pushoverアプリトークン",priority:"優先度",priorityPlaceholder:"0(通常)"},telegram:{botToken:"Botトークン",botTokenPlaceholder:"@BotFatherから取得したトークン",chatId:"チャットID",chatIdPlaceholder:"チャットまたはグループID"},email:{smtpServer:"SMTPサーバー",smtpPort:"SMTPポート",security:"セキュリティ",starttls:"STARTTLS(ポート587)",ssl:"SSL/TLS(ポート465)",securityNone:"なし(ポート25)",authentication:"認証",username:"ユーザー名",password:"パスワード",passwordPlaceholder:"アプリパスワード",fromEmail:"送信元メール",toEmail:"送信先メール"},discord:{webhookUrl:"Webhook URL"},webhook:{webhookUrl:"Webhook URL",payloadFormat:"ペイロード形式",genericJson:"汎用JSON",slackMattermost:"Slack / Mattermost",authorization:"認証",authorizationPlaceholder:"Bearerトークン(任意)",titleFieldName:"タイトルフィールド名",messageFieldName:"メッセージフィールド名"}}},pendingUploads:{title:"保留中のアップロード({{count}}件)",justNow:"たった今",minutesAgo:"{{count}}分前",hoursAgo:"{{count}}時間前",daysAgo:"{{count}}日前",fromSource:"{{ip}}から",archive:"アーカイブ",archiveAll:"すべてアーカイブ",discardAll:"すべて破棄",discard:"破棄",discardTitle:"アップロードを破棄",discardConfirm:'"{{filename}}"を破棄してもよろしいですか?この操作は元に戻せません。',tags:"タグ",tagsPlaceholder:"例: 機能部品、プロトタイプ、ギフト",notes:"メモ",notesPlaceholder:"この印刷についてメモを追加...",project:"プロジェクト",noProject:"プロジェクトなし",description:"これらのファイルはバーチャルプリンター経由でアップロードされました。確認してアーカイブし、コレクションに追加してください。",archiveAllTitle:"すべてのアップロードをアーカイブ",archiveAllConfirm:"保留中のアップロード{{count}}件をすべてアーカイブしてもよろしいですか?",discardAllTitle:"すべてのアップロードを破棄",discardAllConfirm:"保留中のアップロード{{count}}件をすべて破棄してもよろしいですか?この操作は元に戻せません。",archived:"アーカイブ済み: {{name}}",archiveFailed:"アーカイブに失敗しました",discarded:"アップロードを破棄しました",discardFailed:"破棄に失敗しました",archivedCount:"{{count}}ファイルをアーカイブしました",discardedCount:"{{count}}ファイルを破棄しました",archiveAllFailed:"すべてのアーカイブに失敗しました",discardAllFailed:"すべての破棄に失敗しました"},shortcuts:{title:"キーボードショートカット",navigation:"ナビゲーション",archives:"アーカイブ",profiles:"K-プロファイル",general:"一般",goToPrinters:"プリンターへ",goToArchives:"アーカイブへ",goToQueue:"キューへ",goToStatistics:"統計へ",goToProfiles:"クラウドプロファイルへ",goToSettings:"設定へ",openItem:"{{item}}を開く",goToItem:"{{item}}へ移動",focusSearch:"検索にフォーカス",openUpload:"アップロードダイアログを開く",clearSelection:"選択解除 / 入力をクリア",contextMenu:"カードのコンテキストメニュー",refreshProfiles:"プロファイルを更新",newProfile:"新しいプロファイル",exitSelection:"選択モードを終了",showHelp:"このヘルプを表示",pressKey:"押す",orClickToClose:"または外側をクリックで閉じる"},logViewer:{title:"アプリケーションログ",liveStreaming:"ライブストリーミング - {{count}}エントリ",description:"アプリケーションログの表示とフィルタ",live:"ライブ",stop:"停止",start:"開始",clear:"クリア",autoScroll:"自動スクロール",searchPlaceholder:"メッセージまたはロガー名で検索...",noEntries:"ログエントリが見つかりません",emptyLog:"ログファイルが空またはクリアされています",autoRefreshing:"2秒ごとに自動更新中",clickStart:"開始をクリックしてライブログストリーミングを有効にする"},editArchive:{title:"アーカイブを編集",name:"名前",printNamePlaceholder:"印刷名",printer:"プリンター",noPrinter:"プリンターなし",project:"プロジェクト",noProject:"プロジェクトなし",itemsPrinted:"印刷数",itemsPrintedDescription:"この印刷ジョブで生産されたアイテム数",notes:"メモ",notesPlaceholder:"この印刷についてメモを追加...",tags:"タグ",addTags:"タグを追加...",addMoreTags:"タグをさらに追加...",existingTagsHint:"既存のタグ(クリックで追加)",externalLink:"外部リンク",externalLinkPlaceholder:"https://...",externalLinkDescription:"MakerWorld、Printables、Thingiverseなどへのリンク",status:"ステータス",statusCompleted:"完了",statusFailed:"失敗",statusCancelled:"キャンセル",statusPrinting:"印刷中",failureReason:"失敗理由",selectReason:"理由を選択...",failureReasons:{adhesionFailure:"定着不良",spaghettiDetached:"スパゲッティ / 剥離",layerShift:"レイヤーシフト",cloggedNozzle:"ノズル詰まり",filamentRunout:"フィラメント切れ",warping:"反り",stringing:"糸引き",underExtrusion:"押出不足",powerFailure:"電源障害",userCancelled:"ユーザーによるキャンセル",other:"その他"},photos:"印刷結果の写真",printResult:"印刷結果",photosDescription:"+をクリックして印刷結果の写真を追加",saving:"保存中..."},mqttDebug:{title:"MQTTデバッグログ",empty:"<空>",startLogging:"ログ記録を開始",searchPlaceholder:"トピックまたはペイロードで検索...",incoming:"受信",outgoing:"送信",noMessages:"まだメッセージが記録されていません",clickStart:"「ログ記録を開始」をクリックしてMQTTメッセージの記録を開始",noMatch:"フィルタに一致するメッセージがありません",adjustFilter:"検索条件またはフィルタ条件を調整してみてください",loggingActive:"ログ記録中 - メッセージは自動更新されます",loggingStopped:"ログ記録停止"},archiveActions:{print:"印刷",schedule:"スケジュール",openInSlicer:"Bambu Studioで開く",slice:"スライス",viewMakerWorld:"MakerWorldで表示",preview3d:"3Dプレビュー",viewTimelapse:"タイムラプスを表示",scanTimelapse:"タイムラプスを検索",downloadSource3mf:"ソース3MFをダウンロード",uploadSource3mf:"ソース3MFをアップロード",replaceSource3mf:"ソース3MFを置換",removeSource3mf:"ソース3MFを削除",replaceF3d:"F3Dを置換",uploadF3d:"F3Dをアップロード",downloadF3d:"F3Dをダウンロード",removeF3d:"F3Dを削除",copyLink:"ダウンロードリンクをコピー",qrCode:"QRコード",viewPhotos:"写真を表示",projectPage:"プロジェクトページ",goToProject:"プロジェクトへ: {{name}}",addToProject:"プロジェクトに追加",removeFromProject:"プロジェクトから削除",noProjects:"利用可能なプロジェクトがありません",deselect:"選択解除",select:"選択",remove:"削除",source3mfAttached:"ソース3MFを添付しました: {{filename}}",source3mfUploadFailed:"ソース3MFのアップロードに失敗しました",source3mfRemoved:"ソース3MFを削除しました",source3mfRemoveFailed:"ソース3MFの削除に失敗しました",f3dAttached:"F3Dを添付しました: {{filename}}",f3dUploadFailed:"F3Dのアップロードに失敗しました",f3dRemoved:"F3Dを削除しました",f3dRemoveFailed:"F3Dの削除に失敗しました",timelapseAttached:"タイムラプスを添付しました: {{filename}}",timelapseExists:"タイムラプスは既に添付されています",noTimelapseFound:"一致するタイムラプスが見つかりません",timelapseScanFailed:"タイムラプスの検索に失敗しました",timelapseAttachFailed:"タイムラプスの添付に失敗しました",deleted:"アーカイブを削除しました",deleteFailed:"アーカイブの削除に失敗しました",addedToFavorites:"お気に入りに追加しました",removedFromFavorites:"お気に入りから削除しました",projectUpdated:"プロジェクトを更新しました",projectUpdateFailed:"プロジェクトの更新に失敗しました",linkCopied:"リンクをクリップボードにコピーしました",linkCopyFailed:"リンクのコピーに失敗しました",photoDeleted:"写真を削除しました",photoDeleteFailed:"写真の削除に失敗しました",deleteTitle:"アーカイブを削除",deleteConfirm:'"{{name}}"を削除してもよろしいですか?この操作は元に戻せません。',removeSource3mfTitle:"ソース3MFを削除",removeSource3mfConfirm:'"{{name}}"からソース3MFファイルを削除してもよろしいですか?元のスライサープロジェクトファイルが削除されます。',removeF3dTitle:"F3Dを削除",removeF3dConfirm:'"{{name}}"からFusion 360デザインファイルを削除してもよろしいですか?',selectTimelapse:"タイムラプスを選択",selectTimelapseDesc:"自動一致が見つかりませんでした。この印刷のタイムラプスを選択してください:"},camera:{camera:"カメラ",invalidPrinterId:"無効なプリンターID",printerFallback:"プリンター #{{id}}",live:"ライブ",snapshot:"スナップショット",restartStream:"ストリームを再開",refreshSnapshot:"スナップショットを更新",fullscreen:"フルスクリーン",exitFullscreen:"フルスクリーンを終了",connectingToCamera:"カメラに接続中...",capturingSnapshot:"スナップショットを撮影中...",connectionLost:"接続が切断されました",reconnectingIn:"{{seconds}}秒後に再接続します(試行{{attempt}}/{{maxAttempts}})",reconnectNow:"今すぐ再接続",cameraUnavailable:"カメラが利用できません",makeSurePrinterConnected:"プリンターが接続されていること、およびプリンター設定でカメラが有効になっていることを確認してください。",retry:"再試行",cameraStream:"カメラストリーム",zoomIn:"ズームイン",zoomOut:"ズームアウト",resetZoom:"ズームをリセット",skipBack:"5秒戻る",skipForward:"5秒進む",refreshStream:"ストリームを更新",dragToResize:"ドラッグしてリサイズ"},archiveCard:{slicedReady:"スライス済みファイル - 印刷可能",sourceOnly:"ソースファイルのみ - AMSマッピングなし",gcode:"GCODE",source:"ソース",layers:"レイヤー",objects:"{{count}}オブジェクト",objects_other:"{{count}}オブジェクト",cancelled:"キャンセル",failed:"失敗",duplicate:"重複"},providerCard:{last:"最終: ",lastSuccessAt:"最終: {{date}}",printer:"プリンター: ",allPrinters:"すべてのプリンター",tagStart:"開始",tagComplete:"完了",tagFailed:"失敗",tagStopped:"中止",tagProgress:"進捗",tagOffline:"オフライン",tagLowFilament:"フィラメント残量低下",tagMaintenance:"メンテナンス",tagAmsHumidity:"AMS湿度",tagAmsTemp:"AMS温度",tagAmsHtHumidity:"AMS-HT湿度",tagAmsHtTemp:"AMS-HT温度",quiet:"おやすみ",digest:"ダイジェスト ",digestAt:"ダイジェスト {{time}}",sendTest:"テスト通知を送信",eventSettings:"イベント設定",sendNotifications:"このプロバイダーから通知を送信",printEvents:"印刷イベント",printerStatus:"プリンターステータス",amsAlarms:"AMSアラーム",amsHumidityHigh:"AMS湿度高",amsHumidityHighDesc:"通常AMSの湿度がしきい値を超過",amsTempHigh:"AMS温度高",amsTempHighDesc:"通常AMSの温度がしきい値を超過",amsHtAlarms:"AMS-HTアラーム",amsHtHumidityHigh:"AMS-HT湿度高",amsHtHumidityHighDesc:"AMS-HTの湿度がしきい値を超過",amsHtTempHigh:"AMS-HT温度高",amsHtTempHighDesc:"AMS-HTの温度がしきい値を超過",noNotificationsDuring:"この時間帯は通知を送信しません",editQuietHours:"プロバイダーを編集しておやすみ時間を変更",dailyDigest:"デイリーダイジェスト",dailyDigestDesc:"通知を1日1回のサマリーにまとめる",sendAt:"送信時刻",editDigestTime:"プロバイダーを編集してダイジェスト時刻を変更",deleteTitle:"通知プロバイダーを削除",deleteConfirm:"「{{name}}」を削除してもよろしいですか?この操作は元に戻せません。"},projects:{title:"プロジェクト",subtitle:"印刷プロジェクトを管理",editProject:"プロジェクトを編集",newProject:"新規プロジェクト",namePlaceholder:"プロジェクト名",descriptionPlaceholder:"プロジェクトの説明(任意)",color:"色",targetPlates:"目標プレート数",targetPlatesPlaceholder:"例: 10",targetPlatesHint:"必要な印刷ジョブ/プレート数",targetParts:"目標パーツ数",targetPartsPlaceholder:"例: 50",targetPartsHint:"必要な個別パーツの総数",tags:"タグ",tagsPlaceholder:"カンマ区切りのタグ",dueDate:"期限",priorityLabel:"優先度",priority:{low:"低",normal:"通常",high:"高",urgent:"緊急"},status:{active:"進行中",completed:"完了",archived:"アーカイブ済み"},create:"作成",parts:"パーツ",plates:"プレート",failed:"失敗",completed:"完了",inQueue:"キュー内",noPrintsYet:"印刷履歴なし",more:"もっと見る",printJobsPlates:"印刷ジョブ / プレート",partsPrinted:"印刷済みパーツ",failedParts:"失敗パーツ",projectCreated:"プロジェクトを作成しました",projectUpdated:"プロジェクトを更新しました",projectDeleted:"プロジェクトを削除しました",all:"すべて",loading:"プロジェクトを読み込み中...",noProjectsYet:"プロジェクトがまだありません",noStatusProjects:"{{status}}のプロジェクトはありません",noProjectsHint:"プロジェクトを作成して印刷を整理・追跡しましょう",noStatusProjectsHint:"ステータスが「{{status}}」のプロジェクトはありません",createFirstProject:"最初のプロジェクトを作成",deleteProject:"プロジェクトを削除",deleteProjectConfirm:"このプロジェクトを削除しますか?この操作は取り消せません。",exportAllProjects:"すべてのプロジェクトをエクスポート",importProject:"プロジェクトをインポート",importFailed:"インポートに失敗しました",projectImported:"プロジェクトがインポートされました",projectsExported:"プロジェクトがエクスポートされました",noCreatePermission:"プロジェクトを作成する権限がありません",noDeletePermission:"プロジェクトを削除する権限がありません",noEditPermission:"プロジェクトを編集する権限がありません",noExportPermission:"プロジェクトをエクスポートする権限がありません",noImportPermission:"プロジェクトをインポートする権限がありません"},projectDetail:{statusActive:"進行中",statusCompleted:"完了",statusArchived:"アーカイブ済み",noPrintsYet:"印刷履歴なし",print:"印刷",unknown:"不明",priorityLow:"低",priorityNormal:"通常",priorityHigh:"高",priorityUrgent:"緊急",overdue:"期限超過",dueToday:"本日期限",daysLeft:"残り{{count}}日",projectUpdated:"プロジェクトを更新しました",partAdded:"パーツを追加しました",partRemoved:"パーツを削除しました",deletePart:"パーツを削除",deletePartConfirm:"「{{name}}」を削除しますか?",templateCreated:"プロジェクトからテンプレートを作成しました",error:"エラー",projectNotFound:"プロジェクトが見つかりません",backToProjects:"プロジェクト一覧に戻る",projects:"プロジェクト",edit:"編集",platesProgress:"プレート進捗",printJobs:"印刷ジョブ",percentComplete:"% 完了",remaining:"残り",partsProgress:"パーツ進捗",parts:"パーツ",printJobsCard:"印刷ジョブ",total:"合計",failed:"失敗",partsPrinted:"印刷済みパーツ",printTime:"印刷時間",filamentUsed:"フィラメント使用量",costTracking:"コスト追跡",filamentCost:"フィラメント",energy:"エネルギー",budget:"予算",budgetRemaining:"残り予算",subProjects:"サブプロジェクト ({{count}})",partOf:"所属先",priority:"優先度",notes:"メモ",cancel:"キャンセル",save:"保存",notesPlaceholder:"このプロジェクトについてメモを追加...",noNotesYet:"メモがありません。編集をクリックして追加してください。",files:"ファイル",linkFoldersFromFileManager:"ファイルマネージャーからフォルダーをリンク",toThisProjectForQuickAccess:"してクイックアクセス。",fileCount:"{{count}}ファイル",noFoldersLinked:"リンクされたフォルダーはありません",billOfMaterials:"部品表(BOM)",bomAcquired:"{{completed}}/{{total}} 取得済み",showAll:"すべて表示",hideDone:"完了を非表示",addPart:"パーツを追加",partNamePlaceholder:"パーツ名",qty:"数量",pricePlaceholder:"価格 ({{currency}})",sourcingUrlPlaceholder:"URL(任意)",remarksPlaceholder:"備考",delete:"削除",totalCost:"合計コスト",noBomParts:"BOMにパーツがありません",activityTimeline:"アクティビティタイムライン",noActivityYet:"アクティビティがありません",timelineEvents:{project_created:"プロジェクト作成",print_completed:"印刷完了",print_failed:"印刷失敗",print_started:"印刷開始",queued:"キューに追加"},saveAsTemplate:"テンプレートとして保存",queue:"キュー",viewAll:"すべて表示",printing:"印刷中",queued:"キュー内",prints:"{{count}}件の印刷",exportProject:"プロジェクトをエクスポート",exportFailed:"エクスポートに失敗しました",projectExported:"プロジェクトがエクスポートされました",noEditPermission:"このプロジェクトを編集する権限がありません",noAddPartsPermission:"パーツを追加する権限がありません",noDeletePartsPermission:"パーツを削除する権限がありません",noEditPartsPermission:"パーツを編集する権限がありません",noUpdatePartsPermission:"パーツを更新する権限がありません",noEditNotesPermission:"ノートを編集する権限がありません",noCreateTemplatesPermission:"テンプレートを作成する権限がありません",noExportPermission:"プロジェクトをエクスポートする権限がありません"},projectPage:{title:"プロジェクトページ",loadFailed:"プロジェクトページデータの読み込みに失敗",noData:"プロジェクトページデータがありません",noDataHint:"このプロジェクトにはMakerWorldページデータがありません",titleField:"タイトル",designer:"デザイナー",license:"ライセンス",description:"説明",descriptionPlaceholder:"プロジェクトの説明...",printProfile:"印刷プロファイル",profileTitle:"プロファイルタイトル",profileDescriptionPlaceholder:"プロファイルの説明",byUser:"{{name}} 作",images:"画像 ({{count}})",viewOnMakerWorld:"MakerWorldで表示"},batchProject:{addedToProject:"{{count}}件のアーカイブを「{{project}}」に追加しました",assignFailed:"プロジェクトへのアーカイブ割り当てに失敗しました",removedFromProject:"{{count}}件のアーカイブをプロジェクトから削除しました",removeFailed:"プロジェクトからのアーカイブ削除に失敗しました",assignTitle:"プロジェクトに割り当て",assignDescription:"{{count}}件の選択されたアーカイブのプロジェクトを選択:",removeFromProject:"プロジェクトから削除",clearAssignment:"選択されたアーカイブのプロジェクト割り当てを解除",orAssignTo:"または割り当て先:",archiveCount:"{{count}}件のアーカイブ",noProjects:"プロジェクトがありません。先にプロジェクトを作成してください。"},richTextEditor:{bold:"太字",italic:"斜体",underline:"下線",bulletList:"箇条書き",numberedList:"番号付きリスト",alignLeft:"左揃え",alignCenter:"中央揃え",alignRight:"右揃え",addLink:"リンクを追加",removeLink:"リンクを削除"},kProfiles:{editProfile:"K-プロファイルを編集",addProfile:"K-プロファイルを追加",hasNote:"メモあり",copyProfile:"プロファイルをコピー",profileNamePlaceholder:"マイPLAプロファイル",notesPlaceholder:"このプロファイルのメモを追加...",searchPlaceholder:"名前またはフィラメントで検索...",exportToJson:"JSONにエクスポート",importFromJson:"JSONからインポート",selectAllVisible:"表示中のプロファイルをすべて選択",enterSelectionMode:"一括削除の選択モードに入る",unnamed:"名前なし",notePrefix:"メモ: ",profileName:"プロファイル名",kValue:"K値",kValueRange:"一般的な範囲: PLA 0.01 - 0.06、PETG 0.02 - 0.10",filament:"フィラメント",selectFilament:"フィラメントを選択...",noFilamentsFound:"フィラメントが見つかりません。まずBambu StudioでKプロファイルを作成してください。",flowType:"フロータイプ",highFlow:"ハイフロー",standard:"スタンダード",nozzleSize:"ノズルサイズ",extruder:"エクストルーダー",extruders:"エクストルーダー",left:"左",right:"右",notesStoredLocally:"メモ(ローカル保存)",notesHint:"メモはBambuddyに保存され、プリンターには保存されません",deleteProfileTitle:"プロファイルを削除",cannotBeUndone:"この操作は元に戻せません",confirmDeleteProfile:'"{{name}}"をプリンターから削除してもよろしいですか?',profileSaved:"Kプロファイルを保存しました",profileDeleted:"Kプロファイルを削除しました",selectExtruder:"エクストルーダーを少なくとも1つ選択してください",profileSavedToExtruders:"Kプロファイルを{{count}}個のエクストルーダーに保存しました",failedToSave:"Kプロファイルの保存に失敗しました",syncingWithPrinter:"プリンターと同期中...",pleaseWait:"お待ちください",savingToExtruder:"エクストルーダー {{current}}/{{total}} に保存中...",noPrintersConfigured:"プリンターが設定されていません",addPrinterHint:"設定でプリンターを追加してKプロファイルを管理",noActivePrinters:"アクティブなプリンターがありません",enablePrinterHint:"プリンター接続を有効にしてKプロファイルを表示",loadingProfiles:"Kプロファイルを読み込み中...",nozzle:"ノズル",allExtruders:"すべてのエクストルーダー",leftOnly:"左のみ",rightOnly:"右のみ",allFlow:"すべてのフロー",hfOnly:"HFのみ",sOnly:"Sのみ",sortName:"ソート: 名前",sortKValue:"ソート: K値",sortFilament:"ソート: フィラメント",selectAll:"すべて選択",select:"選択",printerOffline:"プリンターオフライン",printerOfflineHint:"プリンターが接続されていません。電源を入れてKプロファイルを表示してください。",leftExtruder:"左エクストルーダー",rightExtruder:"右エクストルーダー",noMatchingProfiles:"一致するプロファイルなし",noProfilesMatch:"検索条件に一致するプロファイルがありません",noKProfiles:"Kプロファイルなし",noProfilesForNozzle:"{{diameter}}mmノズルの圧力キャリブレーションプロファイルが見つかりません",createFirstProfile:"最初のプロファイルを作成",deleteProfiles:"プロファイルを削除",confirmBulkDelete:"{{count}}件の選択されたプロファイルをプリンターから削除してもよろしいですか?",noProfilesToExport:"エクスポートするプロファイルがありません",exportedProfiles:"{{count}}件のプロファイルをエクスポートしました",invalidFileFormat:"無効なファイル形式",importedProfiles:"{{total}}件中{{imported}}件のプロファイルをインポートしました",failedToParseImport:"インポートファイルの解析に失敗しました",deletedProfiles:"{{count}}件のプロファイルを削除しました",failedToSaveNote:"メモの保存に失敗しました",noPermissionAdd:"K-プロファイルを追加する権限がありません",noPermissionDelete:"K-プロファイルを削除する権限がありません",noPermissionDeleteBulk:"K-プロファイルを一括削除する権限がありません",noPermissionExport:"K-プロファイルをエクスポートする権限がありません",noPermissionImport:"K-プロファイルをインポートする権限がありません",noPermissionRefresh:"K-プロファイルを更新する権限がありません"},apiBrowser:{validationError:"バリデーションエラー",missingRequiredParams:"必須パラメーターが不足: {{params}}",networkError:"ネットワークエラー",pathParameters:"パスパラメーター",queryParameters:"クエリパラメーター",selectOption:"-- 選択 --",requestBody:"リクエストボディ",execute:"実行",fillInRequired:"入力してください: {{params}}",response:"レスポンス",failedToFetchSchema:"OpenAPIスキーマの取得に失敗しました",failedToLoadSchema:"APIスキーマの読み込みに失敗しました",otherCategory:"その他",expandAll:"すべて展開",collapseAll:"すべて折りたたむ",swaggerUI:"Swagger UI",endpointCount:"{{categories}}カテゴリー内{{count}}エンドポイント"},githubBackup:{title:"GitHubバックアップ",enabled:"有効",cloudLoginRequired:"Bambu Cloudのログインが必要です。プロファイル → クラウドプロファイルからサインインしてGitHubバックアップを有効にしてください。",description:"プロファイルをプライベートGitHubリポジトリに自動同期し、バックアップとバージョン履歴を管理します。",repositoryUrl:"リポジトリURL",personalAccessToken:"パーソナルアクセストークン",saved:"保存済み",enterNewToken:"新しいトークンを入力して更新",tokenHint:"Contents読み取り/書き込み権限を持つFine-grainedトークン",branch:"ブランチ",autoBackup:"自動バックアップ",manualOnly:"手動のみ",hourly:"毎時",daily:"毎日",weekly:"毎週",includeInBackup:"バックアップに含める",kProfiles:"Kプロファイル",noPrintersConnected:"プリンター未接続",printersConnected:"{{connected}}/{{total}} 接続中",kProfilesDescription:"接続されたプリンターからの圧力前進キャリブレーション",cloudProfiles:"クラウドプロファイル",cloudProfilesDescription:"Bambu Cloudのフィラメント、プリンター、プロセスプリセット",appSettings:"アプリ設定",appSettingsDescription:"Bambuddyの設定(機密データを除く)",lastBackup:"最終バックアップ",noBackupsYet:"バックアップなし",next:"次回",startingBackup:"バックアップ開始中...",backupNow:"今すぐバックアップ",test:"テスト",enableBackup:"バックアップを有効化",testConnection:"接続テスト",history:"履歴",date:"日付",status:"ステータス",commit:"コミット",localBackup:"ローカルバックアップ",localDescription:"Bambuddyデータをローカルファイルとしてエクスポートまたはインポートし、手動バックアップや移行に利用できます。",exportData:"データエクスポート",exportDescription:"すべての設定、プリンター、プロファイルをダウンロード",importBackup:"バックアップのインポート",importDescription:"以前のエクスポートファイルから復元",tokenUpdated:"トークンを更新しました",settingsSaved:"設定を保存しました",failedToSave:"保存に失敗しました: {{error}}",backupEnabled:"GitHubバックアップを有効にしました",backupComplete:"バックアップ完了 - {{count}}ファイル更新",backupSkipped:"バックアップをスキップ - 変更なし",backupFailed:"バックアップに失敗しました: {{error}}",logsCleared:"{{count}}件のログを削除しました",failedToClearLogs:"ログの削除に失敗しました: {{error}}",enterRepoUrl:"リポジトリURLを入力してください",enterRepoUrlAndToken:"リポジトリURLとアクセストークンを入力してください",repoUrlRequired:"リポジトリURLは必須です",tokenRequired:"アクセストークンは必須です",backupDownloaded:"バックアップのダウンロードが完了しました",failedToCreateBackup:"バックアップの作成に失敗しました",backupRestored:"バックアップの復元が完了しました"}},eoe={en:{translation:Qse},de:{translation:Zse},ja:{translation:Jse}};ks.use(Iq).use(Ase).init({resources:eoe,fallbackLng:"en",supportedLngs:["en","de","ja"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const xz=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"},{code:"ja",name:"Japanese",nativeName:"日本語"}];var bz="popstate";function toe(t={}){function e(r,i){let{pathname:s,search:o,hash:l}=r.location;return tP("",{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:$0(i)}return roe(e,n,null,t)}function ri(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function _o(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function noe(){return Math.random().toString(36).substring(2,10)}function yz(t,e){return{usr:t.state,key:t.key,idx:e}}function tP(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?bx(e):e,state:n,key:e&&e.key||r||noe()}}function $0({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 bx(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 roe(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 h(){l="POP";let v=d(),b=v==null?null:v-u;u=v,c&&c({action:l,location:y.location,delta:b})}function p(v,b){l="PUSH";let S=tP(y.location,v,b);u=d()+1;let N=yz(S,u),T=y.createHref(S);try{o.pushState(N,"",T)}catch(k){if(k instanceof DOMException&&k.name==="DataCloneError")throw k;i.location.assign(T)}s&&c&&c({action:l,location:y.location,delta:1})}function m(v,b){l="REPLACE";let S=tP(y.location,v,b);u=d();let N=yz(S,u),T=y.createHref(S);o.replaceState(N,"",T),s&&c&&c({action:l,location:y.location,delta:0})}function x(v){return ioe(v)}let y={get action(){return l},get location(){return t(i,o)},listen(v){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(bz,h),c=v,()=>{i.removeEventListener(bz,h),c=null}},createHref(v){return e(i,v)},createURL:x,encodeLocation(v){let b=x(v);return{pathname:b.pathname,search:b.search,hash:b.hash}},push:p,replace:m,go(v){return o.go(v)}};return y}function ioe(t,e=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),ri(n,"No window.location.(origin|href) available to create URL");let r=typeof t=="string"?t:$0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Uq(t,e,n="/"){return aoe(t,e,n,!1)}function aoe(t,e,n,r){let i=typeof e=="string"?bx(e):e,s=Ou(i.pathname||"/",n);if(s==null)return null;let o=zq(t);soe(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=xoe(s);l=poe(o[c],u,r)}return l}function zq(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;ri(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 h=ku([r,d.relativePath]),p=n.concat(d);o.children&&o.children.length>0&&(ri(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),zq(o.children,e,p,h,c)),!(o.path==null&&!o.index)&&e.push({path:h,score:foe(h,o.index),routesMeta:p})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))s(o,l);else for(let c of Bq(o.path))s(o,l,!0,c)}),e}function Bq(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=Bq(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 soe(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:moe(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var ooe=/^:[\w-]+$/,loe=3,coe=2,uoe=1,doe=10,hoe=-2,vz=t=>t==="*";function foe(t,e){let n=t.split("/"),r=n.length;return n.some(vz)&&(r+=hoe),e&&(r+=coe),n.filter(i=>!vz(i)).reduce((i,s)=>i+(ooe.test(s)?loe:s===""?uoe:doe),r)}function moe(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 poe(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)||"/",h=V1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),p=c.route;if(!h&&u&&n&&!r[r.length-1].route.index&&(h=V1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!h)return null;Object.assign(i,h.params),o.push({params:i,pathname:ku([s,h.pathname]),pathnameBase:woe(ku([s,h.pathnameBase])),route:p}),h.pathnameBase!=="/"&&(s=ku([s,h.pathnameBase]))}return o}function V1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=goe(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:h},p)=>{if(d==="*"){let x=l[p]||"";o=s.slice(0,s.length-x.length).replace(/(.)\/+$/,"$1")}const m=l[p];return h&&!m?u[d]=void 0:u[d]=(m||"").replace(/%2F/g,"/"),u},{}),pathname:s,pathnameBase:o,pattern:t}}function goe(t,e=!1,n=!0){_o(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 xoe(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return _o(!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 Ou(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 Hq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,boe=t=>Hq.test(t);function yoe(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?bx(t):t,s;if(n)if(boe(n))s=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),_o(!1,`Pathnames cannot have embedded double slashes - normalizing ${o} -> ${n}`)}n.startsWith("/")?s=wz(n.substring(1),"/"):s=wz(n,e)}else s=e;return{pathname:s,search:_oe(r),hash:Soe(i)}}function wz(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 QE(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 voe(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function pR(t){let e=voe(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function gR(t,e,n,r=!1){let i;typeof t=="string"?i=bx(t):(i={...t},ri(!i.pathname||!i.pathname.includes("?"),QE("?","pathname","search",i)),ri(!i.pathname||!i.pathname.includes("#"),QE("#","pathname","hash",i)),ri(!i.search||!i.search.includes("#"),QE("#","search","hash",i)));let s=t===""||i.pathname==="",o=s?"/":i.pathname,l;if(o==null)l=n;else{let h=e.length-1;if(!r&&o.startsWith("..")){let p=o.split("/");for(;p[0]==="..";)p.shift(),h-=1;i.pathname=p.join("/")}l=h>=0?e[h]:"/"}let c=yoe(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(s||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var ku=t=>t.join("/").replace(/\/\/+/g,"/"),woe=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),_oe=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,Soe=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,Noe=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 Moe(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function koe(t){return t.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var $q=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Vq(t,e){let n=t;if(typeof n!="string"||!Hq.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if($q)try{let s=new URL(window.location.href),o=n.startsWith("//")?new URL(s.protocol+n):new URL(n),l=Ou(o.pathname,e);o.origin===s.origin&&l!=null?n=l+o.search+o.hash:i=!0}catch{_o(!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 Gq=["POST","PUT","PATCH","DELETE"];new Set(Gq);var Eoe=["GET",...Gq];new Set(Eoe);var yx=_.createContext(null);yx.displayName="DataRouter";var iM=_.createContext(null);iM.displayName="DataRouterState";var Toe=_.createContext(!1),qq=_.createContext({isTransitioning:!1});qq.displayName="ViewTransition";var Aoe=_.createContext(new Map);Aoe.displayName="Fetchers";var Coe=_.createContext(null);Coe.displayName="Await";var ko=_.createContext(null);ko.displayName="Navigation";var Ly=_.createContext(null);Ly.displayName="Location";var gl=_.createContext({outlet:null,matches:[],isDataRoute:!1});gl.displayName="Route";var xR=_.createContext(null);xR.displayName="RouteError";var Wq="REACT_ROUTER_ERROR",joe="REDIRECT",Poe="ROUTE_ERROR_RESPONSE";function Doe(t){if(t.startsWith(`${Wq}:${joe}:{`))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 Roe(t){if(t.startsWith(`${Wq}:${Poe}:{`))try{let e=JSON.parse(t.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new Noe(e.status,e.statusText,e.data)}catch{}}function Ooe(t,{relative:e}={}){ri(vx(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=_.useContext(ko),{hash:i,pathname:s,search:o}=Fy(t,{relative:e}),l=s;return n!=="/"&&(l=s==="/"?n:ku([n,s])),r.createHref({pathname:l,search:o,hash:i})}function vx(){return _.useContext(Ly)!=null}function Ec(){return ri(vx(),"useLocation() may be used only in the context of a <Router> component."),_.useContext(Ly).location}var Kq="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Xq(t){_.useContext(ko).static||_.useLayoutEffect(t)}function Tc(){let{isDataRoute:t}=_.useContext(gl);return t?Yoe():Loe()}function Loe(){ri(vx(),"useNavigate() may be used only in the context of a <Router> component.");let t=_.useContext(yx),{basename:e,navigator:n}=_.useContext(ko),{matches:r}=_.useContext(gl),{pathname:i}=Ec(),s=JSON.stringify(pR(r)),o=_.useRef(!1);return Xq(()=>{o.current=!0}),_.useCallback((c,u={})=>{if(_o(o.current,Kq),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=gR(c,JSON.parse(s),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:ku([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,s,i,t])}var Foe=_.createContext(null);function Ioe(t){let e=_.useContext(gl).outlet;return _.useMemo(()=>e&&_.createElement(Foe.Provider,{value:t},e),[e,t])}function aM(){let{matches:t}=_.useContext(gl),e=t[t.length-1];return e?e.params:{}}function Fy(t,{relative:e}={}){let{matches:n}=_.useContext(gl),{pathname:r}=Ec(),i=JSON.stringify(pR(n));return _.useMemo(()=>gR(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Uoe(t,e){return Yq(t,e)}function Yq(t,e,n,r,i){ri(vx(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:s}=_.useContext(ko),{matches:o}=_.useContext(gl),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",h=l&&l.route;{let S=h&&h.path||"";Zq(u,!h||S.endsWith("*")||S.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${u}" (under <Route path="${S}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
  10. Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}/*`}">.`)}let p=Ec(),m;if(e){let S=typeof e=="string"?bx(e):e;ri(d==="/"||S.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 "${S.pathname}" was given in the \`location\` prop.`),m=S}else m=p;let x=m.pathname||"/",y=x;if(d!=="/"){let S=d.replace(/^\//,"").split("/");y="/"+x.replace(/^\//,"").split("/").slice(S.length).join("/")}let v=Uq(t,{pathname:y});_o(h||v!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),_o(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${m.pathname}${m.search}${m.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let b=Voe(v&&v.map(S=>Object.assign({},S,{params:Object.assign({},c,S.params),pathname:ku([d,s.encodeLocation?s.encodeLocation(S.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?d:ku([d,s.encodeLocation?s.encodeLocation(S.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathnameBase])})),o,n,r,i);return e&&b?_.createElement(Ly.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},b):b}function zoe(){let t=Xoe(),e=Moe(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=_.createElement(_.Fragment,null,_.createElement("p",null,"💿 Hey developer 👋"),_.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",_.createElement("code",{style:s},"ErrorBoundary")," or"," ",_.createElement("code",{style:s},"errorElement")," prop on your route.")),_.createElement(_.Fragment,null,_.createElement("h2",null,"Unexpected Application Error!"),_.createElement("h3",{style:{fontStyle:"italic"}},e),n?_.createElement("pre",{style:i},n):null,o)}var Boe=_.createElement(zoe,null),Qq=class extends _.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=Roe(t.digest);n&&(t=n)}let e=t!==void 0?_.createElement(gl.Provider,{value:this.props.routeContext},_.createElement(xR.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?_.createElement(Hoe,{error:t},e):e}};Qq.contextType=Toe;var ZE=new WeakMap;function Hoe({children:t,error:e}){let{basename:n}=_.useContext(ko);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=Doe(e.digest);if(r){let i=ZE.get(e);if(i)throw i;let s=Vq(r.location,n);if($q&&!ZE.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 ZE.set(e,o),o}return _.createElement("meta",{httpEquiv:"refresh",content:`0;url=${s.absoluteURL||s.to}`})}}return t}function $oe({routeContext:t,match:e,children:n}){let r=_.useContext(yx);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),_.createElement(gl.Provider,{value:t},n)}function Voe(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(h=>h.route.id&&o?.[h.route.id]!==void 0);ri(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 h=s[d];if((h.route.HydrateFallback||h.route.hydrateFallbackElement)&&(c=d),h.route.id){let{loaderData:p,errors:m}=n,x=h.route.loader&&!p.hasOwnProperty(h.route.id)&&(!m||m[h.route.id]===void 0);if(h.route.lazy||x){l=!0,c>=0?s=s.slice(0,c+1):s=[s[0]];break}}}let u=n&&r?(d,h)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:koe(n.matches),errorInfo:h})}:void 0;return s.reduceRight((d,h,p)=>{let m,x=!1,y=null,v=null;n&&(m=o&&h.route.id?o[h.route.id]:void 0,y=h.route.errorElement||Boe,l&&(c<0&&p===0?(Zq("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,v=null):c===p&&(x=!0,v=h.route.hydrateFallbackElement||null)));let b=e.concat(s.slice(0,p+1)),S=()=>{let N;return m?N=y:x?N=v:h.route.Component?N=_.createElement(h.route.Component,null):h.route.element?N=h.route.element:N=d,_.createElement($oe,{match:h,routeContext:{outlet:d,matches:b,isDataRoute:n!=null},children:N})};return n&&(h.route.ErrorBoundary||h.route.errorElement||p===0)?_.createElement(Qq,{location:n.location,revalidation:n.revalidation,component:y,error:m,children:S(),routeContext:{outlet:null,matches:b,isDataRoute:!0},onError:u}):S()},null)}function bR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Goe(t){let e=_.useContext(yx);return ri(e,bR(t)),e}function qoe(t){let e=_.useContext(iM);return ri(e,bR(t)),e}function Woe(t){let e=_.useContext(gl);return ri(e,bR(t)),e}function yR(t){let e=Woe(t),n=e.matches[e.matches.length-1];return ri(n.route.id,`${t} can only be used on routes that contain a unique "id"`),n.route.id}function Koe(){return yR("useRouteId")}function Xoe(){let t=_.useContext(xR),e=qoe("useRouteError"),n=yR("useRouteError");return t!==void 0?t:e.errors?.[n]}function Yoe(){let{router:t}=Goe("useNavigate"),e=yR("useNavigate"),n=_.useRef(!1);return Xq(()=>{n.current=!0}),_.useCallback(async(i,s={})=>{_o(n.current,Kq),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...s}))},[t,e])}var _z={};function Zq(t,e,n){!e&&!_z[t]&&(_z[t]=!0,_o(!1,n))}_.memo(Qoe);function Qoe({routes:t,future:e,state:n,onError:r}){return Yq(t,void 0,n,r,e)}function Ug({to:t,replace:e,state:n,relative:r}){ri(vx(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=_.useContext(ko);_o(!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}=_.useContext(gl),{pathname:o}=Ec(),l=Tc(),c=gR(t,pR(s),o,r==="path"),u=JSON.stringify(c);return _.useEffect(()=>{l(JSON.parse(u),{replace:e,state:n,relative:r})},[l,u,r,e,n]),null}function Zoe(t){return Ioe(t.context)}function Fi(t){ri(!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 Joe({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:s=!1,unstable_useTransitions:o}){ri(!vx(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let l=t.replace(/^\/*/,"/"),c=_.useMemo(()=>({basename:l,navigator:i,static:s,unstable_useTransitions:o,future:{}}),[l,i,s,o]);typeof n=="string"&&(n=bx(n));let{pathname:u="/",search:d="",hash:h="",state:p=null,key:m="default"}=n,x=_.useMemo(()=>{let y=Ou(u,l);return y==null?null:{location:{pathname:y,search:d,hash:h,state:p,key:m},navigationType:r}},[l,u,d,h,p,m,r]);return _o(x!=null,`<Router basename="${l}"> is not able to match the URL "${u}${d}${h}" because it does not start with the basename, so the <Router> won't render anything.`),x==null?null:_.createElement(ko.Provider,{value:c},_.createElement(Ly.Provider,{children:e,value:x}))}function ele({children:t,location:e}){return Uoe(nP(t),e)}function nP(t,e=[]){let n=[];return _.Children.forEach(t,(r,i)=>{if(!_.isValidElement(r))return;let s=[...e,i];if(r.type===_.Fragment){n.push.apply(n,nP(r.props.children,s));return}ri(r.type===Fi,`[${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>`),ri(!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=nP(r.props.children,s)),n.push(o)}),n}var p1="get",g1="application/x-www-form-urlencoded";function sM(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function tle(t){return sM(t)&&t.tagName.toLowerCase()==="button"}function nle(t){return sM(t)&&t.tagName.toLowerCase()==="form"}function rle(t){return sM(t)&&t.tagName.toLowerCase()==="input"}function ile(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function ale(t,e){return t.button===0&&(!e||e==="_self")&&!ile(t)}function rP(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 sle(t,e){let n=rP(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(s=>{n.append(i,s)})}),n}var Dw=null;function ole(){if(Dw===null)try{new FormData(document.createElement("form"),0),Dw=!1}catch{Dw=!0}return Dw}var lle=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function JE(t){return t!=null&&!lle.has(t)?(_o(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${g1}"`),null):t}function cle(t,e){let n,r,i,s,o;if(nle(t)){let l=t.getAttribute("action");r=l?Ou(l,e):null,n=t.getAttribute("method")||p1,i=JE(t.getAttribute("enctype"))||g1,s=new FormData(t)}else if(tle(t)||rle(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?Ou(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||p1,i=JE(t.getAttribute("formenctype"))||JE(l.getAttribute("enctype"))||g1,s=new FormData(l,t),!ole()){let{name:u,type:d,value:h}=t;if(d==="image"){let p=u?`${u}.`:"";s.append(`${p}x`,"0"),s.append(`${p}y`,"0")}else u&&s.append(u,h)}}else{if(sM(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=p1,r=null,i=g1,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 vR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function ule(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&&Ou(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${r}`,i}async function dle(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 hle(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 fle(t,e,n){let r=await Promise.all(t.map(async i=>{let s=e.routes[i.route.id];if(s){let o=await dle(s,n);return o.links?o.links():[]}return[]}));return xle(r.flat(1).filter(hle).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 h=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 h=="boolean")return h}return!0}):[]}function mle(t,e,{includeHydrateFallback:n}={}){return ple(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 ple(t){return[...new Set(t)]}function gle(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function xle(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let s=JSON.stringify(gle(i));return n.has(s)||(n.add(s),r.push({key:s,link:i})),r},[])}function Jq(){let t=_.useContext(yx);return vR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function ble(){let t=_.useContext(iM);return vR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var wR=_.createContext(void 0);wR.displayName="FrameworkContext";function eW(){let t=_.useContext(wR);return vR(t,"You must render this element inside a <HydratedRouter> element"),t}function yle(t,e){let n=_.useContext(wR),[r,i]=_.useState(!1),[s,o]=_.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:h}=e,p=_.useRef(null);_.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let y=b=>{b.forEach(S=>{o(S.isIntersecting)})},v=new IntersectionObserver(y,{threshold:.5});return p.current&&v.observe(p.current),()=>{v.disconnect()}}},[t]),_.useEffect(()=>{if(r){let y=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(y)}}},[r]);let m=()=>{i(!0)},x=()=>{i(!1),o(!1)};return n?t!=="intent"?[s,p,{}]:[s,p,{onFocus:Pb(l,m),onBlur:Pb(c,x),onMouseEnter:Pb(u,m),onMouseLeave:Pb(d,x),onTouchStart:Pb(h,m)}]:[!1,p,{}]}function Pb(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function vle({page:t,...e}){let{router:n}=Jq(),r=_.useMemo(()=>Uq(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?_.createElement(_le,{page:t,matches:r,...e}):null}function wle(t){let{manifest:e,routeModules:n}=eW(),[r,i]=_.useState([]);return _.useEffect(()=>{let s=!1;return fle(t,e,n).then(o=>{s||i(o)}),()=>{s=!0}},[t,e,n]),r}function _le({page:t,matches:e,...n}){let r=Ec(),{future:i,manifest:s,routeModules:o}=eW(),{basename:l}=Jq(),{loaderData:c,matches:u}=ble(),d=_.useMemo(()=>Sz(t,e,u,s,r,"data"),[t,e,u,s,r]),h=_.useMemo(()=>Sz(t,e,u,s,r,"assets"),[t,e,u,s,r]),p=_.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let y=new Set,v=!1;if(e.forEach(S=>{let N=s.routes[S.route.id];!N||!N.hasLoader||(!d.some(T=>T.route.id===S.route.id)&&S.route.id in c&&o[S.route.id]?.shouldRevalidate||N.hasClientLoader?v=!0:y.add(S.route.id))}),y.size===0)return[];let b=ule(t,l,i.unstable_trailingSlashAwareDataRequests,"data");return v&&y.size>0&&b.searchParams.set("_routes",e.filter(S=>y.has(S.route.id)).map(S=>S.route.id).join(",")),[b.pathname+b.search]},[l,i.unstable_trailingSlashAwareDataRequests,c,r,s,d,e,t,o]),m=_.useMemo(()=>mle(h,s),[h,s]),x=wle(h);return _.createElement(_.Fragment,null,p.map(y=>_.createElement("link",{key:y,rel:"prefetch",as:"fetch",href:y,...n})),m.map(y=>_.createElement("link",{key:y,rel:"modulepreload",href:y,...n})),x.map(({key:y,link:v})=>_.createElement("link",{key:y,nonce:n.nonce,...v})))}function Sle(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var Nle=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{Nle&&(window.__reactRouterVersion="7.12.0")}catch{}function Mle({basename:t,children:e,unstable_useTransitions:n,window:r}){let i=_.useRef();i.current==null&&(i.current=toe({window:r,v5Compat:!0}));let s=i.current,[o,l]=_.useState({action:s.action,location:s.location}),c=_.useCallback(u=>{n===!1?l(u):_.startTransition(()=>l(u))},[n]);return _.useLayoutEffect(()=>s.listen(c),[s,c]),_.createElement(Joe,{basename:t,children:e,location:o.location,navigationType:o.action,navigator:s,unstable_useTransitions:n})}var tW=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Fs=_.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:h,unstable_defaultShouldRevalidate:p,...m},x){let{basename:y,unstable_useTransitions:v}=_.useContext(ko),b=typeof u=="string"&&tW.test(u),S=Vq(u,y);u=S.to;let N=Ooe(u,{relative:i}),[T,k,C]=yle(r,m),E=Tle(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:h,unstable_defaultShouldRevalidate:p,unstable_useTransitions:v});function P(D){e&&e(D),D.defaultPrevented||E(D)}let A=_.createElement("a",{...m,...C,href:S.absoluteURL||N,onClick:S.isExternal||s?e:P,ref:Sle(x,k),target:c,"data-discover":!b&&n==="render"?"true":void 0});return T&&!b?_.createElement(_.Fragment,null,A,_.createElement(vle,{page:N})):A});Fs.displayName="Link";var i0=_.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 h=Fy(o,{relative:u.relative}),p=Ec(),m=_.useContext(iM),{navigator:x,basename:y}=_.useContext(ko),v=m!=null&&Dle(h)&&l===!0,b=x.encodeLocation?x.encodeLocation(h).pathname:h.pathname,S=p.pathname,N=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(S=S.toLowerCase(),N=N?N.toLowerCase():null,b=b.toLowerCase()),N&&y&&(N=Ou(N,y)||N);const T=b!=="/"&&b.endsWith("/")?b.length-1:b.length;let k=S===b||!i&&S.startsWith(b)&&S.charAt(T)==="/",C=N!=null&&(N===b||!i&&N.startsWith(b)&&N.charAt(b.length)==="/"),E={isActive:k,isPending:C,isTransitioning:v},P=k?e:void 0,A;typeof r=="function"?A=r(E):A=[r,k?"active":null,C?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let D=typeof s=="function"?s(E):s;return _.createElement(Fs,{...u,"aria-current":P,className:A,ref:d,style:D,to:o,viewTransition:l},typeof c=="function"?c(E):c)});i0.displayName="NavLink";var kle=_.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:s,method:o=p1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:h,unstable_defaultShouldRevalidate:p,...m},x)=>{let{unstable_useTransitions:y}=_.useContext(ko),v=jle(),b=Ple(l,{relative:u}),S=o.toLowerCase()==="get"?"get":"post",N=typeof l=="string"&&tW.test(l),T=k=>{if(c&&c(k),k.defaultPrevented)return;k.preventDefault();let C=k.nativeEvent.submitter,E=C?.getAttribute("formmethod")||o,P=()=>v(C||k.currentTarget,{fetcherKey:e,method:E,navigate:n,replace:i,state:s,relative:u,preventScrollReset:d,viewTransition:h,unstable_defaultShouldRevalidate:p});y&&n!==!1?_.startTransition(()=>P()):P()};return _.createElement("form",{ref:x,method:S,action:b,onSubmit:r?c:T,...m,"data-discover":!N&&t==="render"?"true":void 0})});kle.displayName="Form";function Ele(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function nW(t){let e=_.useContext(yx);return ri(e,Ele(t)),e}function Tle(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:s,viewTransition:o,unstable_defaultShouldRevalidate:l,unstable_useTransitions:c}={}){let u=Tc(),d=Ec(),h=Fy(t,{relative:s});return _.useCallback(p=>{if(ale(p,e)){p.preventDefault();let m=n!==void 0?n:$0(d)===$0(h),x=()=>u(t,{replace:m,state:r,preventScrollReset:i,relative:s,viewTransition:o,unstable_defaultShouldRevalidate:l});c?_.startTransition(()=>x()):x()}},[d,u,h,n,r,e,t,i,s,o,l,c])}function _R(t){_o(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=_.useRef(rP(t)),n=_.useRef(!1),r=Ec(),i=_.useMemo(()=>sle(r.search,n.current?null:e.current),[r.search]),s=Tc(),o=_.useCallback((l,c)=>{const u=rP(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,s("?"+u,c)},[s,i]);return[i,o]}var Ale=0,Cle=()=>`__${String(++Ale)}__`;function jle(){let{router:t}=nW("useSubmit"),{basename:e}=_.useContext(ko),n=Koe(),r=t.fetch,i=t.navigate;return _.useCallback(async(s,o={})=>{let{action:l,method:c,encType:u,formData:d,body:h}=cle(s,e);if(o.navigate===!1){let p=o.fetcherKey||Cle();await r(p,n,o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:h,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:h,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 Ple(t,{relative:e}={}){let{basename:n}=_.useContext(ko),r=_.useContext(gl);ri(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),s={...Fy(t||".",{relative:e})},o=Ec();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(h=>h).forEach(h=>l.append("index",h));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:ku([n,s.pathname])),$0(s)}function Dle(t,{relative:e}={}){let n=_.useContext(qq);ri(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=nW("useViewTransitionState"),i=Fy(t,{relative:e});if(!n.isTransitioning)return!1;let s=Ou(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Ou(n.nextLocation.pathname,r)||n.nextLocation.pathname;return V1(i.pathname,o)!=null||V1(i.pathname,s)!=null}var bu=Tq();const Rle=pl(bu);var Em=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(){}},Ole={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Lle=class{#t=Ole;#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)}},Df=new Lle;function Fle(t){setTimeout(t,0)}var rm=typeof window>"u"||"Deno"in globalThis;function Qa(){}function Ile(t,e){return typeof t=="function"?t(e):t}function iP(t){return typeof t=="number"&&t>=0&&t!==1/0}function rW(t,e){return Math.max(t+(e||0)-Date.now(),0)}function ih(t,e){return typeof t=="function"?t(e):t}function Wo(t,e){return typeof t=="function"?t(e):t}function Nz(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==SR(o,e.options))return!1}else if(!V0(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 Mz(t,e){const{exact:n,status:r,predicate:i,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(n){if(im(e.options.mutationKey)!==im(s))return!1}else if(!V0(e.options.mutationKey,s))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function SR(t,e){return(e?.queryKeyHashFn||im)(t)}function im(t){return JSON.stringify(t,(e,n)=>aP(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function V0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>V0(t[n],e[n])):!1}var Ule=Object.prototype.hasOwnProperty;function NR(t,e){if(t===e)return t;const n=kz(t)&&kz(e);if(!n&&!(aP(t)&&aP(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],h=t[d],p=e[d];if(h===p){l[d]=h,(n?u<i:Ule.call(t,d))&&c++;continue}if(h===null||p===null||typeof h!="object"||typeof p!="object"){l[d]=p;continue}const m=NR(h,p);l[d]=m,m===h&&c++}return i===o&&c===i?t:l}function G0(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 kz(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function aP(t){if(!Ez(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!Ez(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Ez(t){return Object.prototype.toString.call(t)==="[object Object]"}function zle(t){return new Promise(e=>{Df.setTimeout(e,t)})}function sP(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?NR(t,e):e}function Ble(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function Hle(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var MR=Symbol();function iW(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===MR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function aW(t,e){return typeof t=="function"?t(...e):!!t}var $le=class extends Em{#t;#e;#n;constructor(){super(),this.#n=t=>{if(!rm&&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"}},kR=new $le;function oP(){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 Vle=Fle;function Gle(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=Vle;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 yi=Gle(),qle=class extends Em{#t=!0;#e;#n;constructor(){super(),this.#n=t=>{if(!rm&&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}},G1=new qle;function Wle(t){return Math.min(1e3*2**t,3e4)}function sW(t){return(t??"online")==="online"?G1.isOnline():!0}var lP=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function oW(t){let e=!1,n=0,r;const i=oP(),s=()=>i.status!=="pending",o=y=>{if(!s()){const v=new lP(y);p(v),t.onCancel?.(v)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>kR.isFocused()&&(t.networkMode==="always"||G1.isOnline())&&t.canRun(),d=()=>sW(t.networkMode)&&t.canRun(),h=y=>{s()||(r?.(),i.resolve(y))},p=y=>{s()||(r?.(),i.reject(y))},m=()=>new Promise(y=>{r=v=>{(s()||u())&&y(v)},t.onPause?.()}).then(()=>{r=void 0,s()||t.onContinue?.()}),x=()=>{if(s())return;let y;const v=n===0?t.initialPromise:void 0;try{y=v??t.fn()}catch(b){y=Promise.reject(b)}Promise.resolve(y).then(h).catch(b=>{if(s())return;const S=t.retry??(rm?0:3),N=t.retryDelay??Wle,T=typeof N=="function"?N(n,b):N,k=S===!0||typeof S=="number"&&n<S||typeof S=="function"&&S(n,b);if(e||!k){p(b);return}n++,t.onFail?.(n,b),zle(T).then(()=>u()?void 0:m()).then(()=>{e?p(b):x()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:l,continueRetry:c,canStart:d,start:()=>(d()?x():m().then(x),i)}}var lW=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),iP(this.gcTime)&&(this.#t=Df.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(rm?1/0:300*1e3))}clearGcTimeout(){this.#t&&(Df.clearTimeout(this.#t),this.#t=void 0)}},Kle=class extends lW{#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=Az(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=Az(this.options);e.data!==void 0&&(this.setState(Tz(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=sP(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(Qa).catch(Qa):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(t=>Wo(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===MR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>ih(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:!rW(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=iW(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=oW({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof lP&&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 lP){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,...cW(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...Tz(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),yi.batch(()=>{this.observers.forEach(n=>{n.onQueryUpdate()}),this.#n.notify({query:this,type:"updated",action:t})})}};function cW(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:sW(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Tz(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Az(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 ER=class extends Em{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=oP(),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),Cz(this.#e,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return cP(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return cP(this.#e,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#v(),this.#w(),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 Wo(this.options.enabled,this.#e)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#_(),this.#e.setOptions(this.options),e._defaulted&&!G0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&jz(this.#e,n,this.options,e)&&this.#m(),this.updateResult(),r&&(this.#e!==n||Wo(this.options.enabled,this.#e)!==Wo(e.enabled,this.#e)||ih(this.options.staleTime,this.#e)!==ih(e.staleTime,this.#e))&&this.#g();const i=this.#x();r&&(this.#e!==n||Wo(this.options.enabled,this.#e)!==Wo(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 Yle(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.#_();let e=this.#e.fetch(this.options,t);return t?.throwOnError||(e=e.catch(Qa)),e}#g(){this.#v();const t=ih(this.options.staleTime,this.#e);if(rm||this.#i.isStale||!iP(t))return;const n=rW(this.#i.dataUpdatedAt,t)+1;this.#c=Df.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.#w(),this.#l=t,!(rm||Wo(this.options.enabled,this.#e)===!1||!iP(this.#l)||this.#l===0)&&(this.#u=Df.setInterval(()=>{(this.options.refetchIntervalInBackground||kR.isFocused())&&this.#m()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(Df.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(Df.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},h=!1,p;if(e._optimisticResults){const P=this.hasListeners(),A=!P&&Cz(t,e),D=P&&jz(t,n,e,r);(A||D)&&(d={...d,...cW(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:x,status:y}=d;p=d.data;let v=!1;if(e.placeholderData!==void 0&&p===void 0&&y==="pending"){let P;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(P=i.data,v=!0):P=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,P!==void 0&&(y="success",p=sP(i?.data,P,e),h=!0)}if(e.select&&p!==void 0&&!v)if(i&&p===s?.data&&e.select===this.#f)p=this.#d;else try{this.#f=e.select,p=e.select(p),p=sP(i?.data,p,e),this.#d=p,this.#s=null}catch(P){this.#s=P}this.#s&&(m=this.#s,p=this.#d,x=Date.now(),y="error");const b=d.fetchStatus==="fetching",S=y==="pending",N=y==="error",T=S&&b,k=p!==void 0,E={status:y,fetchStatus:d.fetchStatus,isPending:S,isSuccess:y==="success",isError:N,isInitialLoading:T,isLoading:T,data:p,dataUpdatedAt:d.dataUpdatedAt,error:m,errorUpdatedAt:x,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:b,isRefetching:b&&!S,isLoadingError:N&&!k,isPaused:d.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:N&&k,isStale:TR(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Wo(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const P=I=>{E.status==="error"?I.reject(E.error):E.data!==void 0&&I.resolve(E.data)},A=()=>{const I=this.#o=E.promise=oP();P(I)},D=this.#o;switch(D.status){case"pending":t.queryHash===n.queryHash&&P(D);break;case"fulfilled":(E.status==="error"||E.data!==D.value)&&A();break;case"rejected":(E.status!=="error"||E.error!==D.reason)&&A();break}}return E}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),G0(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()})}#_(){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){yi.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#t.getQueryCache().notify({query:this.#e,type:"observerResultsUpdated"})})}};function Xle(t,e){return Wo(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Cz(t,e){return Xle(t,e)||t.state.data!==void 0&&cP(t,e,e.refetchOnMount)}function cP(t,e,n){if(Wo(e.enabled,t)!==!1&&ih(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&TR(t,e)}return!1}function jz(t,e,n,r){return(t!==e||Wo(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&TR(t,n)}function TR(t,e){return Wo(e.enabled,t)!==!1&&t.isStaleByTime(ih(e.staleTime,t))}function Yle(t,e){return!G0(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 h=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},p=iW(e.options,e.fetchOptions),m=async(x,y,v)=>{if(d)return Promise.reject();if(y==null&&x.pages.length)return Promise.resolve(x);const S=(()=>{const C={client:e.client,queryKey:e.queryKey,pageParam:y,direction:v?"backward":"forward",meta:e.options.meta};return h(C),C})(),N=await p(S),{maxPages:T}=e.options,k=v?Hle:Ble;return{pages:k(x.pages,N,T),pageParams:k(x.pageParams,y,T)}};if(i&&s.length){const x=i==="backward",y=x?Qle:Dz,v={pages:s,pageParams:o},b=y(r,v);l=await m(v,b,x)}else{const x=t??s.length;do{const y=c===0?o[0]??r.initialPageParam:Dz(r,l);if(c>0&&y==null)break;l=await m(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 Dz(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 Qle(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var Zle=class extends lW{#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||uW(),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=oW({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),yi.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function uW(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Jle=class extends Em{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 Zle({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=Rw(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=Rw(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=Rw(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=Rw(t);return typeof e=="string"?this.#e.get(e)?.find(r=>r!==t&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){yi.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=>Mz(e,n))}findAll(t={}){return this.getAll().filter(e=>Mz(t,e))}notify(t){yi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(e=>e.state.isPaused);return yi.batch(()=>Promise.all(t.map(e=>e.continue().catch(Qa))))}};function Rw(t){return t.options.scope?.id}var ece=class extends Em{#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),G0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&im(n.mutationKey)!==im(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??uW();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){yi.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 Rz(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function tce(t,e,n){const r=t.slice(0);return r[e]=n,r}var nce=class extends Em{#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,yi.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,h)=>d!==n[h]),c=o||l,u=c?!0:s.some((d,h)=>{const p=this.#e[h];return!p||!G0(d,p)});!c&&!u||(c&&(this.#r=i),this.#e=s,this.hasListeners()&&(c&&(Rz(n,i).forEach(d=>{d.destroy()}),Rz(i,n).forEach(d=>{d.subscribe(h=>{this.#u(d,h)})})),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=NR(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 ER(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#u(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=tce(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&&yi.batch(()=>{this.listeners.forEach(r=>{r(this.#e)})})}}},rce=class extends Em{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??SR(r,e);let s=this.get(i);return s||(s=new Kle({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(){yi.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=>Nz(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>Nz(t,n)):e}notify(t){yi.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){yi.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){yi.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},ice=class{#t;#e;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#t=t.queryCache||new rce,this.#e=t.mutationCache||new Jle,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=kR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=G1.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(ih(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=Ile(e,s);if(o!==void 0)return this.#t.build(this,r).setData(o,{...n,manual:!0})}setQueriesData(t,e,n){return yi.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;yi.batch(()=>{e.findAll(t).forEach(n=>{e.remove(n)})})}resetQueries(t,e){const n=this.#t;return yi.batch(()=>(n.findAll(t).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const n={revert:!0,...e},r=yi.batch(()=>this.#t.findAll(t).map(i=>i.cancel(n)));return Promise.all(r).then(Qa).catch(Qa)}invalidateQueries(t,e={}){return yi.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=yi.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(Qa)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(Qa)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#t.build(this,e);return n.isStaleByTime(ih(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Qa).catch(Qa)}fetchInfiniteQuery(t){return t.behavior=Pz(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Qa).catch(Qa)}ensureInfiniteQueryData(t){return t.behavior=Pz(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return G1.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(im(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{V0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(im(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{V0(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=SR(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===MR&&(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()}},dW=_.createContext(void 0),sn=t=>{const e=_.useContext(dW);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},ace=({client:t,children:e})=>(_.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),a.jsx(dW.Provider,{value:t,children:e})),hW=_.createContext(!1),fW=()=>_.useContext(hW);hW.Provider;function sce(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var oce=_.createContext(sce()),mW=()=>_.useContext(oce),pW=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},gW=t=>{_.useEffect(()=>{t.clearReset()},[t])},xW=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||aW(n,[t.error,r])),bW=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))}},yW=(t,e)=>t.isLoading&&t.isFetching&&!e,uP=(t,e)=>t?.suspense&&e.isPending,q1=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function vW({queries:t,...e},n){const r=sn(),i=fW(),s=mW(),o=_.useMemo(()=>t.map(y=>{const v=r.defaultQueryOptions(y);return v._optimisticResults=i?"isRestoring":"optimistic",v}),[t,r,i]);o.forEach(y=>{bW(y),pW(y,s)}),gW(s);const[l]=_.useState(()=>new nce(r,o,e)),[c,u,d]=l.getOptimisticResult(o,e.combine),h=!i&&e.subscribed!==!1;_.useSyncExternalStore(_.useCallback(y=>h?l.subscribe(yi.batchCalls(y)):Qa,[l,h]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),_.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const m=c.some((y,v)=>uP(o[v],y))?c.flatMap((y,v)=>{const b=o[v];if(b){const S=new ER(r,b);if(uP(b,y))return q1(b,S,s);yW(y,i)&&q1(b,S,s)}return[]}):[];if(m.length>0)throw Promise.all(m);const x=c.find((y,v)=>{const b=o[v];return b&&xW({result:y,errorResetBoundary:s,throwOnError:b.throwOnError,query:r.getQueryCache().get(b.queryHash),suspense:b.suspense})});if(x?.error)throw x.error;return u(d())}function lce(t,e,n){const r=fW(),i=mW(),s=sn(),o=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?"isRestoring":"optimistic",bW(o),pW(o,i),gW(i);const l=!s.getQueryCache().get(o.queryHash),[c]=_.useState(()=>new e(s,o)),u=c.getOptimisticResult(o),d=!r&&t.subscribed!==!1;if(_.useSyncExternalStore(_.useCallback(h=>{const p=d?c.subscribe(yi.batchCalls(h)):Qa;return c.updateResult(),p},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),_.useEffect(()=>{c.setOptions(o)},[o,c]),uP(o,u))throw q1(o,c,i);if(xW({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&&!rm&&yW(u,r)&&(l?q1(o,c,i):s.getQueryCache().get(o.queryHash)?.promise)?.catch(Qa).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?u:c.trackResult(u)}function ct(t,e){return lce(t,ER)}function gt(t,e){const n=sn(),[r]=_.useState(()=>new ece(n,t));_.useEffect(()=>{r.setOptions(t)},[r,t]);const i=_.useSyncExternalStore(_.useCallback(o=>r.subscribe(yi.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=_.useCallback((o,l)=>{r.mutate(o,l).catch(Qa)},[r]);if(i.error&&aW(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}const cce=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),uce=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Oz=t=>{const e=uce(t);return e.charAt(0).toUpperCase()+e.slice(1)},wW=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),dce=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var hce={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 fce=_.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...l},c)=>_.createElement("svg",{ref:c,...hce,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:wW("lucide",i),...!s&&!dce(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>_.createElement(u,d)),...Array.isArray(s)?s:[s]]));const Qe=(t,e)=>{const n=_.forwardRef(({className:r,...i},s)=>_.createElement(fce,{ref:s,iconNode:e,className:wW(`lucide-${cce(Oz(t))}`,`lucide-${t}`,r),...i}));return n.displayName=Oz(t),n};const mce=[["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"}]],pce=Qe("air-vent",mce);const gce=[["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"}]],go=Qe("archive",gce);const xce=[["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"}]],bce=Qe("arrow-down-wide-narrow",xce);const yce=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],q0=Qe("arrow-down",yce);const vce=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],wce=Qe("arrow-left",vce);const _ce=[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]],Lz=Qe("arrow-right-left",_ce);const Sce=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],dP=Qe("arrow-right",Sce);const Nce=[["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"}]],_W=Qe("arrow-up-down",Nce);const Mce=[["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"}]],kce=Qe("arrow-up-narrow-wide",Mce);const Ece=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],zg=Qe("arrow-up",Ece);const Tce=[["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"}]],Sg=Qe("bell",Tce);const Ace=[["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"}]],Cce=Qe("bold",Ace);const jce=[["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"}]],Pce=Qe("book",jce);const Dce=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],Rce=Qe("bookmark",Dce);const Oce=[["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"}]],Ui=Qe("box",Oce);const Lce=[["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"}]],SW=Qe("briefcase",Lce);const Fce=[["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"}]],oM=Qe("bug",Fce);const Ice=[["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"}]],Uce=Qe("cable",Ice);const zce=[["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"}]],Bce=Qe("calculator",zce);const Hce=[["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"}]],$ce=Qe("calendar-days",Hce);const Vce=[["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"}]],ti=Qe("calendar",Vce);const Gce=[["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"}]],Bg=Qe("camera",Gce);const qce=[["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"}]],Wce=Qe("chart-column",qce);const Kce=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Wi=Qe("check",Kce);const Xce=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Kr=Qe("chevron-down",Xce);const Yce=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],vs=Qe("chevron-right",Yce);const Qce=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],bh=Qe("chevron-left",Qce);const Zce=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],yh=Qe("chevron-up",Zce);const Jce=[["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"}]],Vi=Qe("circle-alert",Jce);const eue=[["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"}]],eT=Qe("circle-arrow-up",eue);const tue=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ar=Qe("circle-check-big",tue);const nue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],lM=Qe("circle-check",nue);const rue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],iue=Qe("circle-dot",rue);const aue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],sue=Qe("circle-question-mark",aue);const oue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],lue=Qe("circle-stop",oue);const cue=[["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"}]],Ji=Qe("circle-x",cue);const uue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],hP=Qe("circle",uue);const due=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],tr=Qe("clock",due);const hue=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],cM=Qe("cloud",hue);const fue=[["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"}]],mue=Qe("code-xml",fue);const pue=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],NW=Qe("code",pue);const gue=[["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"}]],xue=Qe("coffee",gue);const bue=[["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"}]],yue=Qe("cog",bue);const vue=[["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"}]],wue=Qe("compass",vue);const _ue=[["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"}]],Ul=Qe("copy",_ue);const Sue=[["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"}]],Ow=Qe("cpu",Sue);const Nue=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],Mue=Qe("cylinder",Nue);const kue=[["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"}]],Eu=Qe("database",kue);const Eue=[["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"}]],fP=Qe("dollar-sign",Eue);const Tue=[["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"}]],wi=Qe("download",Tue);const Aue=[["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"}]],AR=Qe("droplet",Aue);const Cue=[["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"}]],CR=Qe("droplets",Cue);const jue=[["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"}]],ah=Qe("ellipsis-vertical",jue);const Pue=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],tT=Qe("equal",Pue);const Due=[["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"}]],Xr=Qe("external-link",Due);const Rue=[["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"}]],uM=Qe("eye-off",Rue);const Oue=[["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"}]],xc=Qe("eye",Oue);const Lue=[["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"}]],MW=Qe("fan",Lue);const Fue=[["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"}]],Hf=Qe("file-box",Fue);const Iue=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"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"}]],W1=Qe("file-code",Iue);const Uue=[["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"}]],zue=Qe("file-exclamation-point",Uue);const Bue=[["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"}]],K1=Qe("file-spreadsheet",Bue);const Hue=[["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"}]],fs=Qe("file-text",Hue);const $ue=[["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"}]],dM=Qe("file",$ue);const Vue=[["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"}]],sh=Qe("film",Vue);const Gue=[["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"}]],que=Qe("flame",Gue);const Wue=[["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"}]],es=Qe("folder-kanban",Wue);const Kue=[["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"}]],zl=Qe("folder-open",Kue);const Xue=[["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"}]],Yue=Qe("folder-plus",Xue);const Que=[["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"}]],Zue=Qe("folder-tree",Que);const Jue=[["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"}]],kW=Qe("folder",Jue);const ede=[["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"}]],tde=Qe("fullscreen",ede);const nde=[["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"}]],hM=Qe("funnel",nde);const rde=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],fM=Qe("gauge",rde);const ide=[["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"}]],ade=Qe("gift",ide);const sde=[["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"}]],Ng=Qe("git-compare",sde);const ode=[["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"}]],mP=Qe("github",ode);const lde=[["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"}]],oh=Qe("globe",lde);const cde=[["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"}]],Hg=Qe("grip-vertical",cde);const ude=[["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"}]],EW=Qe("hand",ude);const dde=[["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"}]],mM=Qe("hard-drive",dde);const hde=[["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"}]],fde=Qe("hash",hde);const mde=[["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"}]],pde=Qe("headphones",mde);const gde=[["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"}]],xde=Qe("heart",gde);const bde=[["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"}]],W0=Qe("history",bde);const yde=[["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"}]],Iy=Qe("house",yde);const vde=[["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"}]],Lu=Qe("image",vde);const wde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],nl=Qe("info",wde);const _de=[["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"}]],Sde=Qe("italic",_de);const Nde=[["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"}]],Ko=Qe("key",Nde);const Mde=[["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"}]],pP=Qe("keyboard",Mde);const kde=[["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"}]],xs=Qe("layers",kde);const Ede=[["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"}]],pM=Qe("layout-grid",Ede);const Tde=[["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"}]],Ade=Qe("link-2-off",Tde);const Cde=[["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"}]],fc=Qe("link-2",Cde);const jde=[["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"}]],Uy=Qe("link",jde);const Pde=[["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"}]],TW=Qe("list-ordered",Pde);const Dde=[["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"}]],gP=Qe("list-todo",Dde);const Rde=[["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"}]],gM=Qe("list",Rde);const Ode=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],pt=Qe("loader-circle",Ode);const Lde=[["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"}]],nT=Qe("lock-open",Lde);const Fde=[["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"}]],rT=Qe("lock",Fde);const Ide=[["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"}]],Fz=Qe("log-in",Ide);const Ude=[["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"}]],xP=Qe("log-out",Ude);const zde=[["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"}]],Bde=Qe("mail",zde);const Hde=[["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"}]],$de=Qe("map",Hde);const Vde=[["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"}]],AW=Qe("maximize-2",Vde);const Gde=[["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"}]],qde=Qe("maximize",Gde);const Wde=[["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"}]],Kde=Qe("memory-stick",Wde);const Xde=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Yde=Qe("menu",Xde);const Qde=[["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"}]],CW=Qe("minimize-2",Qde);const Zde=[["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"}]],jW=Qe("minimize",Zde);const Jde=[["path",{d:"M5 12h14",key:"1ays0h"}]],bP=Qe("minus",Jde);const ehe=[["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"}]],the=Qe("monitor",ehe);const nhe=[["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"}]],X1=Qe("moon",nhe);const rhe=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],ihe=Qe("move-right",rhe);const ahe=[["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"}]],yP=Qe("music",ahe);const she=[["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"}]],bc=Qe("package",she);const ohe=[["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"}]],PW=Qe("palette",ohe);const lhe=[["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"}]],jR=Qe("pause",lhe);const che=[["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"}]],am=Qe("pen-line",che);const uhe=[["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"}]],mg=Qe("pen",uhe);const dhe=[["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"}]],ea=Qe("pencil",dhe);const hhe=[["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"}]],fhe=Qe("phone",hhe);const mhe=[["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"}]],So=Qe("play",mhe);const phe=[["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"}]],al=Qe("plug",phe);const ghe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],fr=Qe("plus",ghe);const xhe=[["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"}]],xM=Qe("power-off",xhe);const bhe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],qu=Qe("power",bhe);const yhe=[["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"}]],Ur=Qe("printer",yhe);const vhe=[["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"}]],DW=Qe("qr-code",vhe);const whe=[["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"}]],PR=Qe("radio",whe);const _he=[["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"}]],Dr=Qe("refresh-cw",_he);const She=[["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"}]],Lh=Qe("rotate-ccw",She);const Nhe=[["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"}]],Mhe=Qe("ruler",Nhe);const khe=[["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"}]],ms=Qe("save",khe);const Ehe=[["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"}]],Y1=Qe("scan-search",Ehe);const The=[["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"}]],Ahe=Qe("scissors",The);const Che=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],wa=Qe("search",Che);const jhe=[["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"}]],DR=Qe("send",jhe);const Phe=[["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"}]],wf=Qe("server",Phe);const Dhe=[["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"}]],vh=Qe("settings-2",Dhe);const Rhe=[["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"}]],bM=Qe("settings",Rhe);const Ohe=[["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"}]],iT=Qe("shield",Ohe);const Lhe=[["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"}]],RW=Qe("shopping-cart",Lhe);const Fhe=[["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"}]],Ihe=Qe("signal",Fhe);const Uhe=[["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"}]],zhe=Qe("skip-back",Uhe);const Bhe=[["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"}]],RR=Qe("skip-forward",Bhe);const Hhe=[["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"}]],Iz=Qe("sliders-vertical",Hhe);const $he=[["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"}]],K0=Qe("sparkles",$he);const Vhe=[["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"}]],Gs=Qe("square-check-big",Vhe);const Ghe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]],qhe=Qe("square-minus",Ghe);const Whe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],cl=Qe("square",Whe);const Khe=[["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"}]],sm=Qe("star",Khe);const Xhe=[["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"}]],OW=Qe("sticky-note",Xhe);const Yhe=[["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"}]],Uz=Qe("sun",Yhe);const Qhe=[["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"}]],wh=Qe("tag",Qhe);const Zhe=[["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"}]],LW=Qe("target",Zhe);const Jhe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],FW=Qe("terminal",Jhe);const efe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],tfe=Qe("text-align-center",efe);const nfe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],rfe=Qe("text-align-end",nfe);const ife=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],afe=Qe("text-align-start",ife);const sfe=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],yM=Qe("thermometer",sfe);const ofe=[["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"}]],yu=Qe("timer",ofe);const lfe=[["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"}]],an=Qe("trash-2",lfe);const cfe=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],IW=Qe("trending-down",cfe);const ufe=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],vP=Qe("trending-up",ufe);const dfe=[["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"}]],Sn=Qe("triangle-alert",dfe);const hfe=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],ffe=Qe("underline",hfe);const mfe=[["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"}]],OR=Qe("unlink",mfe);const pfe=[["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"}]],Ba=Qe("upload",pfe);const gfe=[["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"}]],om=Qe("user",gfe);const xfe=[["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"}]],pg=Qe("users",xfe);const bfe=[["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"}]],LR=Qe("video",bfe);const yfe=[["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"}]],vfe=Qe("volume-2",yfe);const wfe=[["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"}]],_fe=Qe("volume-x",wfe);const Sfe=[["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"}]],Nfe=Qe("wand-sparkles",Sfe);const Mfe=[["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"}]],lm=Qe("wifi-off",Mfe);const kfe=[["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"}]],Mg=Qe("wifi",kfe);const Efe=[["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"}]],UW=Qe("wind",Efe);const Tfe=[["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"}]],cm=Qe("wrench",Tfe);const Afe=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Lt=Qe("x",Afe);const Cfe=[["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"}]],FR=Qe("zoom-in",Cfe);const jfe=[["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"}]],_h=Qe("zap",jfe);const Pfe=[["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"}]],IR=Qe("zoom-out",Pfe),Qt="/api/v1";let tn=localStorage.getItem("auth_token");function a0(t){tn=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function zz(){return tn}async function De(t,e={}){const n={"Content-Type":"application/json",...e.headers};tn&&(n.Authorization=`Bearer ${tn}`);const r=await fetch(`${Qt}${t}`,{...e,cache:"no-store",headers:n});if(!r.ok){r.status===401&&a0(null);const o=(await r.json().catch(()=>({}))).detail,l=typeof o=="string"?o:o?JSON.stringify(o):`HTTP ${r.status}`;throw new Error(l)}const i=r.headers.get("content-length");if(!(r.status===204||i==="0"))return await r.json()}const oe={getAuthStatus:()=>De("/auth/status"),setupAuth:t=>De("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>De("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>De("/auth/logout",{method:"POST"}),getCurrentUser:()=>De("/auth/me"),disableAuth:()=>De("/auth/disable",{method:"POST"}),getUsers:()=>De("/users/"),getUser:t=>De(`/users/${t}`),createUser:t=>De("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>De(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:(t,e=!1)=>De(`/users/${t}?delete_items=${e}`,{method:"DELETE"}),getUserItemsCount:t=>De(`/users/${t}/items-count`),changePassword:(t,e)=>De("/users/me/change-password",{method:"POST",body:JSON.stringify({current_password:t,new_password:e})}),getPermissions:()=>De("/groups/permissions"),getGroups:()=>De("/groups/"),getGroup:t=>De(`/groups/${t}`),createGroup:t=>De("/groups/",{method:"POST",body:JSON.stringify(t)}),updateGroup:(t,e)=>De(`/groups/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteGroup:t=>De(`/groups/${t}`,{method:"DELETE"}),addUserToGroup:(t,e)=>De(`/groups/${t}/users/${e}`,{method:"POST"}),removeUserFromGroup:(t,e)=>De(`/groups/${t}/users/${e}`,{method:"DELETE"}),getPrinters:()=>De("/printers/"),getPrinter:t=>De(`/printers/${t}`),createPrinter:t=>De("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>De(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>De(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>De(`/printers/${t}/status`),refreshPrinterStatus:t=>De(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>De(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>De(`/printers/${t}/disconnect`,{method:"POST"}),testExternalCamera:(t,e,n)=>De(`/printers/${t}/camera/external/test?url=${encodeURIComponent(e)}&camera_type=${encodeURIComponent(n)}`,{method:"POST"}),stopPrint:t=>De(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>De(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>De(`/printers/${t}/print/resume`,{method:"POST"}),getCurrentPrintUser:t=>De(`/printers/${t}/current-print-user`),setChamberLight:(t,e)=>De(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>De(`/printers/${t}/print/objects`),skipObjects:(t,e)=>De(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>De(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>De(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>De(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>De(`/printers/${t}/logging`),clearMQTTLogs:t=>De(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>De(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${Qt}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,getPrinterFileGcodeUrl:(t,e)=>`${Qt}/printers/${t}/files/gcode?path=${encodeURIComponent(e)}`,getPrinterFilePlates:(t,e)=>De(`/printers/${t}/files/plates?path=${encodeURIComponent(e)}`),getPrinterFilePlateThumbnail:(t,e,n)=>`${Qt}/printers/${t}/files/plate-thumbnail/${e}?path=${encodeURIComponent(n)}`,downloadPrinterFile:async(t,e)=>{const n={};tn&&(n.Authorization=`Bearer ${tn}`);const r=await fetch(`${Qt}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,{headers:n});if(!r.ok){const d=await r.json().catch(()=>({}));throw new Error(d.detail||`HTTP ${r.status}`)}const o=r.headers.get("Content-Disposition")?.match(/filename="?([^";\n]+)"?/)?.[1]||e.split("/").pop()||"download",l=await r.blob(),c=window.URL.createObjectURL(l),u=document.createElement("a");u.href=c,u.download=o,document.body.appendChild(u),u.click(),document.body.removeChild(u),window.URL.revokeObjectURL(c)},downloadPrinterFilesAsZip:async(t,e)=>{const n={"Content-Type":"application/json"};tn&&(n.Authorization=`Bearer ${tn}`);const r=await fetch(`${Qt}/printers/${t}/files/download-zip`,{method:"POST",headers:n,body:JSON.stringify({paths:e})});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.blob()},deletePrinterFile:(t,e)=>De(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>De(`/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)),De(`/archives/?${i}`)},getArchive:t=>De(`/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)),De(`/archives/search?${n}`)},rebuildSearchIndex:()=>De("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>De(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>De(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>De(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>De("/archives/stats"),getTags:()=>De("/archives/tags"),renameTag:(t,e)=>De(`/archives/tags/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({new_name:e})}),deleteTag:t=>De(`/archives/tags/${encodeURIComponent(t)}`,{method:"DELETE"}),recalculateCosts:()=>De("/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)),De(`/archives/analysis/failures?${e}`)},compareArchives:t=>De(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>De(`/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={};tn&&(n.Authorization=`Bearer ${tn}`);const r=await fetch(`${Qt}/archives/export?${e}`,{headers:n});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${r.status}`)}const i=r.headers.get("Content-Disposition");let s=t?.format==="xlsx"?"archives_export.xlsx":"archives_export.csv";if(i){const l=i.match(/filename="?([^"]+)"?/);l&&(s=l[1])}return{blob:await r.blob(),filename:s}},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={};tn&&(n.Authorization=`Bearer ${tn}`);const r=await fetch(`${Qt}/archives/stats/export?${e}`,{headers:n});if(!r.ok){const l=await r.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${r.status}`)}const i=r.headers.get("Content-Disposition");let s=t?.format==="xlsx"?"stats_export.xlsx":"stats_export.csv";if(i){const l=i.match(/filename="?([^"]+)"?/);l&&(s=l[1])}return{blob:await r.blob(),filename:s}},getArchiveDuplicates:t=>De(`/archives/${t}/duplicates`),backfillContentHashes:()=>De("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${Qt}/archives/${t}/thumbnail?v=${Date.now()}`,getArchivePlateThumbnail:(t,e)=>`${Qt}/archives/${t}/plate-thumbnail/${e}`,getArchiveDownload:t=>`${Qt}/archives/${t}/download`,downloadArchive:async(t,e)=>{const n={};tn&&(n.Authorization=`Bearer ${tn}`);const r=await fetch(`${Qt}/archives/${t}/download`,{headers:n});if(!r.ok){const d=await r.json().catch(()=>({}));throw new Error(d.detail||`HTTP ${r.status}`)}const o=r.headers.get("Content-Disposition")?.match(/filename="?([^";\n]+)"?/)?.[1]||e||`archive_${t}.3mf`,l=await r.blob(),c=window.URL.createObjectURL(l),u=document.createElement("a");u.href=c,u.download=o,document.body.appendChild(u),u.click(),document.body.removeChild(u),window.URL.revokeObjectURL(c)},getArchiveGcode:t=>`${Qt}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${Qt}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${Qt}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>De(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>De(`/archives/${t}/timelapse/select?filename=${encodeURIComponent(e)}`,{method:"POST"}),uploadArchiveTimelapse:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};tn&&(r.Authorization=`Bearer ${tn}`);const i=await fetch(`${Qt}/archives/${t}/timelapse/upload`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},getTimelapseInfo:t=>De(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>De(`/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={};tn&&(i.Authorization=`Bearer ${tn}`);const s=await fetch(`${Qt}/archives/${t}/timelapse/process`,{method:"POST",headers:i,body:r});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${s.status}`)}return s.json()},getArchivePhotoUrl:(t,e)=>`${Qt}/archives/${t}/photos/${encodeURIComponent(e)}`,uploadArchivePhoto:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};tn&&(r.Authorization=`Bearer ${tn}`);const i=await fetch(`${Qt}/archives/${t}/photos`,{headers: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()},deleteArchivePhoto:(t,e)=>De(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${Qt}/archives/${t}/source`,downloadSource3mf:async t=>{const e={};tn&&(e.Authorization=`Bearer ${tn}`);const n=await fetch(`${Qt}/archives/${t}/source`,{headers:e});if(!n.ok){const u=await n.json().catch(()=>({}));throw new Error(u.detail||`HTTP ${n.status}`)}const s=n.headers.get("Content-Disposition")?.match(/filename="?([^";\n]+)"?/)?.[1]||`source_${t}.3mf`,o=await n.blob(),l=window.URL.createObjectURL(o),c=document.createElement("a");c.href=l,c.download=s,document.body.appendChild(c),c.click(),document.body.removeChild(c),window.URL.revokeObjectURL(l)},getSource3mfForSlicer:(t,e)=>`${Qt}/archives/${t}/source/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,uploadSource3mf:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};tn&&(r.Authorization=`Bearer ${tn}`);const i=await fetch(`${Qt}/archives/${t}/source`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},deleteSource3mf:t=>De(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${Qt}/archives/${t}/f3d`,downloadF3d:async t=>{const e={};tn&&(e.Authorization=`Bearer ${tn}`);const n=await fetch(`${Qt}/archives/${t}/f3d`,{headers:e});if(!n.ok){const u=await n.json().catch(()=>({}));throw new Error(u.detail||`HTTP ${n.status}`)}const s=n.headers.get("Content-Disposition")?.match(/filename="?([^";\n]+)"?/)?.[1]||`archive_${t}.f3d`,o=await n.blob(),l=window.URL.createObjectURL(o),c=document.createElement("a");c.href=l,c.download=s,document.body.appendChild(c),c.click(),document.body.removeChild(c),window.URL.revokeObjectURL(l)},uploadF3d:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};tn&&(r.Authorization=`Bearer ${tn}`);const i=await fetch(`${Qt}/archives/${t}/f3d`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},deleteF3d:t=>De(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${Qt}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>De(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>De(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>De(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${Qt}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${Qt}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchivePlates:t=>De(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>De(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>De(`/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?`${Qt}/archives/upload?printer_id=${e}`:`${Qt}/archives/upload`,i={};tn&&(i.Authorization=`Bearer ${tn}`);const s=await fetch(r,{method:"POST",headers:i,body:n});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${s.status}`)}return s.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(o=>n.append("files",o));const r=e?`${Qt}/archives/upload-bulk?printer_id=${e}`:`${Qt}/archives/upload-bulk`,i={};tn&&(i.Authorization=`Bearer ${tn}`);const s=await fetch(r,{method:"POST",headers:i,body:n});if(!s.ok){const o=await s.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${s.status}`)}return s.json()},getSettings:()=>De("/settings/"),updateSettings:t=>De("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>De("/settings/mqtt/status"),resetSettings:()=>De("/settings/reset",{method:"POST"}),exportBackup:async()=>{const t=`${Qt}/settings/backup`,e={};tn&&(e.Authorization=`Bearer ${tn}`);const n=await fetch(t,{headers:e});if(!n.ok){const o=await n.text();throw new Error(o||`Backup failed with status ${n.status}`)}const r=n.headers.get("Content-Disposition");let i="bambuddy-backup.zip";if(r){const o=r.match(/filename=([^;]+)/);o&&(i=o[1].trim())}return{blob:await n.blob(),filename:i}},importBackup:async t=>{const e=new FormData;e.append("file",t);const n=`${Qt}/settings/restore`,r={};return tn&&(r.Authorization=`Bearer ${tn}`),(await fetch(n,{method:"POST",headers:r,body:e})).json()},checkFfmpeg:()=>De("/settings/check-ffmpeg"),getCloudStatus:()=>De("/cloud/status"),cloudLogin:(t,e,n="global")=>De("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e,n)=>De("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e,tfa_key:n})}),cloudSetToken:t=>De("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>De("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>De(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>De(`/cloud/settings/${t}`),createCloudSetting:t=>De("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>De(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>De(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>De("/cloud/devices"),getCloudFields:t=>De(`/cloud/fields/${t}`),getAllCloudFields:()=>De("/cloud/fields"),getFilamentInfo:t=>De("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>De("/smart-plugs/"),getSmartPlug:t=>De(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>De(`/smart-plugs/by-printer/${t}`),getScriptPlugsByPrinter:t=>De(`/smart-plugs/by-printer/${t}/scripts`),createSmartPlug:t=>De("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>De(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>De(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>De(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>De(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>De("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${Qt}/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:()=>De("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${Qt}/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:()=>De("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>De("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:t=>{const e=t?`?search=${encodeURIComponent(t)}`:"";return De(`/smart-plugs/ha/entities${e}`)},getHASensorEntities:()=>De("/smart-plugs/ha/sensors"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),De(`/queue/?${n}`)},getQueueItem:t=>De(`/queue/${t}`),addToQueue:t=>De("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>De(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>De(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>De("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>De(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>De(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>De(`/queue/${t}/start`,{method:"POST"}),bulkUpdateQueue:t=>De("/queue/bulk",{method:"PATCH",body:JSON.stringify(t)}),getKProfiles:(t,e="0.4")=>De(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>De(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>De(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>De(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>De(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>De(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>De(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>De(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>De(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>De(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>De(`/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()),De(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>De(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>De("/filaments/"),getFilament:t=>De(`/filaments/${t}`),getFilamentsByType:t=>De(`/filaments/by-type/${t}`),getNotificationProviders:()=>De("/notifications/"),getNotificationProvider:t=>De(`/notifications/${t}`),createNotificationProvider:t=>De("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>De(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>De(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>De(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>De("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>De("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>De("/notification-templates"),getNotificationTemplate:t=>De(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>De(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>De(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>De("/notification-templates/variables"),previewTemplate:t=>De("/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)),De(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>De(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>De(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>De("/spoolman/status"),connectSpoolman:()=>De("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>De("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>De(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>De("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>De("/spoolman/spools"),getSpoolmanFilaments:()=>De("/spoolman/filaments"),getUnlinkedSpools:()=>De("/spoolman/spools/unlinked"),getLinkedSpools:()=>De("/spoolman/spools/linked"),linkSpool:(t,e)=>De(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getSpoolmanSettings:()=>De("/settings/spoolman"),updateSpoolmanSettings:t=>De("/settings/spoolman",{method:"PUT",body:JSON.stringify(t)}),getVersion:()=>De("/updates/version"),checkForUpdates:()=>De("/updates/check"),applyUpdate:()=>De("/updates/apply",{method:"POST"}),getUpdateStatus:()=>De("/updates/status"),getMaintenanceTypes:()=>De("/maintenance/types"),createMaintenanceType:t=>De("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>De(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>De(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>De("/maintenance/overview"),getPrinterMaintenance:t=>De(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>De(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>De(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>De(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>De("/maintenance/summary"),setPrinterHours:(t,e)=>De(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>De(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>De(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${Qt}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${Qt}/printers/${t}/camera/snapshot`,testCameraConnection:t=>De(`/printers/${t}/camera/test`),getCameraStatus:t=>De(`/printers/${t}/camera/status`),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)),De(`/printers/${t}/camera/check-plate?${n.toString()}`)},getPlateDetectionStatus:t=>De(`/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)),De(`/printers/${t}/camera/plate-detection/calibrate?${n.toString()}`,{method:"POST"})},deletePlateCalibration:t=>De(`/printers/${t}/camera/plate-detection/calibrate`,{method:"DELETE"}),getPlateReferences:t=>De(`/printers/${t}/camera/plate-detection/references`),getPlateReferenceThumbnailUrl:(t,e)=>`${Qt}/printers/${t}/camera/plate-detection/references/${e}/thumbnail`,updatePlateReferenceLabel:(t,e,n)=>{const r=new URLSearchParams;return r.set("label",n),De(`/printers/${t}/camera/plate-detection/references/${e}?${r.toString()}`,{method:"PUT"})},deletePlateReference:(t,e)=>De(`/printers/${t}/camera/plate-detection/references/${e}`,{method:"DELETE"}),getExternalLinks:()=>De("/external-links/"),getExternalLink:t=>De(`/external-links/${t}`),createExternalLink:t=>De("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>De(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>De(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>De("/external-links/reorder",{method:"PUT",body:JSON.stringify({ids:t})}),uploadExternalLinkIcon:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};tn&&(r.Authorization=`Bearer ${tn}`);const i=await fetch(`${Qt}/external-links/${t}/icon`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},deleteExternalLinkIcon:t=>De(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${Qt}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),De(`/projects/?${e}`)},getProject:t=>De(`/projects/${t}`),createProject:t=>De("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>De(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>De(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>De(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>De(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>De(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>De(`/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={};tn&&(r.Authorization=`Bearer ${tn}`);const i=await fetch(`${Qt}/projects/${t}/attachments`,{method:"POST",headers:r,body:n});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.detail||`HTTP ${i.status}`)}return i.json()},getProjectAttachmentUrl:(t,e)=>`${Qt}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>De(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>De(`/projects/${t}/bom`),createBOMItem:(t,e)=>De(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>De(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>De(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>De("/projects/templates/"),createTemplateFromProject:t=>De(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>De(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>De(`/projects/${t}/timeline?limit=${e}`),exportProjectJson:t=>De(`/projects/${t}/export?format=json`),importProject:t=>De("/projects/import",{method:"POST",body:JSON.stringify(t)}),importProjectFile:async t=>{const e=new FormData;e.append("file",t);const n={};tn&&(n.Authorization=`Bearer ${tn}`);const r=await fetch(`${Qt}/projects/import/file`,{method:"POST",headers:n,body:e});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${r.status}`)}return r.json()},exportProjectZip:async t=>{const e={};tn&&(e.Authorization=`Bearer ${tn}`);const n=await fetch(`${Qt}/projects/${t}/export`,{headers:e});if(!n.ok){const l=await n.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${n.status}`)}const s=n.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]||`project_${t}.zip`;return{blob:await n.blob(),filename:s}},getAPIKeys:()=>De("/api-keys/"),createAPIKey:t=>De("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>De(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>De(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>De(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>De("/system/info"),getLibraryFolders:()=>De("/library/folders"),createLibraryFolder:t=>De("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>De(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>De(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>De(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>De(`/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)),De(`/library/files?${n}`)},getLibraryFile:t=>De(`/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={};tn&&(s.Authorization=`Bearer ${tn}`);const o=await fetch(`${Qt}/library/files?${i}`,{method:"POST",headers:s,body:r});if(!o.ok){const l=await o.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${o.status}`)}return o.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={};tn&&(l.Authorization=`Bearer ${tn}`);const c=await fetch(`${Qt}/library/files/extract-zip?${o}`,{method:"POST",headers:l,body:s});if(!c.ok){const u=await c.json().catch(()=>({}));throw new Error(u.detail||`HTTP ${c.status}`)}return c.json()},updateLibraryFile:(t,e)=>De(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>De(`/library/files/${t}`,{method:"DELETE"}),getLibraryFileDownloadUrl:t=>`${Qt}/library/files/${t}/download`,downloadLibraryFile:async(t,e)=>{const n={};tn&&(n.Authorization=`Bearer ${tn}`);const r=await fetch(`${Qt}/library/files/${t}/download`,{headers:n});if(!r.ok){const d=await r.json().catch(()=>({}));throw new Error(d.detail||`HTTP ${r.status}`)}const o=r.headers.get("Content-Disposition")?.match(/filename="?([^";\n]+)"?/)?.[1]||e||`file_${t}`,l=await r.blob(),c=window.URL.createObjectURL(l),u=document.createElement("a");u.href=c,u.download=o,document.body.appendChild(u),u.click(),document.body.removeChild(u),window.URL.revokeObjectURL(c)},getLibraryFileThumbnailUrl:t=>`${Qt}/library/files/${t}/thumbnail`,getLibraryFilePlateThumbnail:(t,e)=>`${Qt}/library/files/${t}/plate-thumbnail/${e}`,getLibraryFileGcodeUrl:t=>`${Qt}/library/files/${t}/gcode`,moveLibraryFiles:(t,e)=>De("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>De("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>De("/library/stats"),batchGenerateStlThumbnails:t=>De("/library/generate-stl-thumbnails",{method:"POST",body:JSON.stringify(t)}),addLibraryFilesToQueue:t=>De("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>De(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),getLibraryFilePlates:t=>De(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>De(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),getGitHubBackupConfig:()=>De("/github-backup/config"),saveGitHubBackupConfig:t=>De("/github-backup/config",{method:"POST",body:JSON.stringify(t)}),updateGitHubBackupConfig:t=>De("/github-backup/config",{method:"PATCH",body:JSON.stringify(t)}),deleteGitHubBackupConfig:()=>De("/github-backup/config",{method:"DELETE"}),testGitHubConnection:(t,e)=>De(`/github-backup/test?repo_url=${encodeURIComponent(t)}&token=${encodeURIComponent(e)}`,{method:"POST"}),testGitHubStoredConnection:()=>De("/github-backup/test-stored",{method:"POST"}),triggerGitHubBackup:()=>De("/github-backup/run",{method:"POST"}),getGitHubBackupStatus:()=>De("/github-backup/status"),getGitHubBackupLogs:(t=50)=>De(`/github-backup/logs?limit=${t}`),clearGitHubBackupLogs:(t=10)=>De(`/github-backup/logs?keep_last=${t}`,{method:"DELETE"})},Ql={getInfo:()=>De("/discovery/info"),getStatus:()=>De("/discovery/status"),startDiscovery:(t=10)=>De(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>De("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>De("/discovery/printers"),startSubnetScan:(t,e=1)=>De("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>De("/discovery/scan/status"),stopSubnetScan:()=>De("/discovery/scan/stop",{method:"POST"})},x1={getSettings:()=>De("/settings/virtual-printer"),getModels:()=>De("/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),t.target_printer_id!==void 0&&e.set("target_printer_id",String(t.target_printer_id)),De(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},sg={list:()=>De("/pending-uploads/"),getCount:()=>De("/pending-uploads/count"),get:t=>De(`/pending-uploads/${t}`),archive:(t,e)=>De(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>De(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>De("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>De("/pending-uploads/discard-all",{method:"DELETE"})},b1={checkUpdates:()=>De("/firmware/updates"),checkPrinterUpdate:t=>De(`/firmware/updates/${t}`),prepareUpload:t=>De(`/firmware/updates/${t}/prepare`),startUpload:t=>De(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>De(`/firmware/updates/${t}/upload/status`)},kg={getDebugLoggingState:()=>De("/support/debug-logging"),setDebugLogging:t=>De("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t={};tn&&(t.Authorization=`Bearer ${tn}`);const e=await fetch(`${Qt}/support/bundle`,{headers:t});if(!e.ok){const c=await e.json().catch(()=>({}));throw new Error(c.detail||`HTTP ${e.status}`)}const r=e.headers.get("Content-Disposition")?.match(/filename=(.+)/),i=r?r[1]:"bambuddy-support.zip",s=await e.blob(),o=window.URL.createObjectURL(s),l=document.createElement("a");l.href=o,l.download=i,document.body.appendChild(l),l.click(),document.body.removeChild(l),window.URL.revokeObjectURL(o)},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 De(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>De("/support/logs",{method:"DELETE"})},zW=_.createContext(void 0);function Dfe({children:t}){const[e,n]=_.useState(()=>{const E=localStorage.getItem("theme-mode"),P=localStorage.getItem("theme");return E||P||"dark"}),[r,i]=_.useState(()=>localStorage.getItem("dark-style")||"classic"),[s,o]=_.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=_.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=_.useState(()=>localStorage.getItem("light-style")||"classic"),[h,p]=_.useState(()=>localStorage.getItem("light-background")||"neutral"),[m,x]=_.useState(()=>localStorage.getItem("light-accent")||"green");_.useEffect(()=>{oe.getSettings().then(E=>{E.dark_style&&(i(E.dark_style),localStorage.setItem("dark-style",E.dark_style)),E.dark_background&&(o(E.dark_background),localStorage.setItem("dark-background",E.dark_background)),E.dark_accent&&(c(E.dark_accent),localStorage.setItem("dark-accent",E.dark_accent)),E.light_style&&(d(E.light_style),localStorage.setItem("light-style",E.light_style)),E.light_background&&(p(E.light_background),localStorage.setItem("light-background",E.light_background)),E.light_accent&&(x(E.light_accent),localStorage.setItem("light-accent",E.light_accent))}).catch(()=>{})},[]),_.useEffect(()=>{const E=document.documentElement;E.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"?(E.classList.add("dark"),E.classList.add(`style-${r}`),E.classList.add(`bg-${s}`),E.classList.add(`accent-${l}`)):(E.classList.add(`style-${u}`),E.classList.add(`bg-${h}`),E.classList.add(`accent-${m}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,s,l,u,h,m]);const y=()=>n(E=>E==="dark"?"light":"dark"),v=E=>n(E),b=E=>{i(E),localStorage.setItem("dark-style",E),oe.updateSettings({dark_style:E}).catch(()=>{})},S=E=>{o(E),localStorage.setItem("dark-background",E),oe.updateSettings({dark_background:E}).catch(()=>{})},N=E=>{c(E),localStorage.setItem("dark-accent",E),oe.updateSettings({dark_accent:E}).catch(()=>{})},T=E=>{d(E),localStorage.setItem("light-style",E),oe.updateSettings({light_style:E}).catch(()=>{})},k=E=>{p(E),localStorage.setItem("light-background",E),oe.updateSettings({light_background:E}).catch(()=>{})},C=E=>{x(E),localStorage.setItem("light-accent",E),oe.updateSettings({light_accent:E}).catch(()=>{})};return a.jsx(zW.Provider,{value:{mode:e,darkStyle:r,darkBackground:s,darkAccent:l,lightStyle:u,lightBackground:h,lightAccent:m,toggleMode:y,setMode:v,setDarkStyle:b,setDarkBackground:S,setDarkAccent:N,setLightStyle:T,setLightBackground:k,setLightAccent:C},children:t})}function Fh(){const t=_.useContext(zW);if(!t)throw new Error("useTheme must be used within ThemeProvider");return t}function St({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 Kn({children:t,className:e=""}){return a.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Nt({children:t,className:e=""}){return a.jsx("div",{className:`p-6 ${e}`,children:t})}function Rfe(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 Bz({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 Ofe({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=On(),i=Rfe(n,e,r);return _.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(St,{className:"w-full max-w-md",onClick:s=>s.stopPropagation(),children:a.jsxs(Nt,{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(pP,{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(Lt,{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(Xr,{className:"w-3 h-3 text-bambu-gray"})]}),a.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>a.jsx(Bz,{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(Bz,{children:"Esc"})," or click outside to close"]})})]})})})}function Ae({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 Zn({title:t,message:e,confirmText:n,cancelText:r,variant:i="default",isLoading:s=!1,loadingText:o,onConfirm:l,onCancel:c}){const{t:u}=On(),d=n??u("common.confirm"),h=r??u("common.cancel"),p=o??u("common.loading");_.useEffect(()=>{const y=v=>{v.key==="Escape"&&!s&&c()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[c,s]);const x={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(St,{className:"w-full max-w-md",onClick:y=>y.stopPropagation(),children:a.jsxs(Nt,{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 ${x.icon}`,children:a.jsx(Sn,{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(Ae,{variant:"secondary",onClick:c,className:"flex-1",disabled:s,children:h}),a.jsx(Ae,{onClick:l,className:`flex-1 ${x.button}`,disabled:s,children:s?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 mr-2 animate-spin"}),p]}):d})]})]})})})}function Lfe({plug:t}){const e=sn(),[n,r]=_.useState(null),{data:i,isLoading:s}=ct({queryKey:["smart-plug-status",t.id],queryFn:()=>oe.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=gt({mutationFn:m=>oe.controlSmartPlug(t.id,m),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,h=t.plug_type==="mqtt",p=()=>{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 ${h?u?"bg-teal-500/20":"bg-red-500/20":u?l?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:h?a.jsx(PR,{className:`w-4 h-4 ${u?"text-teal-400":"text-red-400"}`}):a.jsx(al,{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(pt,{className:"w-3 h-3 text-bambu-gray animate-spin"}):h?u?a.jsxs(a.Fragment,{children:[a.jsx(_h,{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(xc,{className:"w-3 h-3 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:"Monitor"})]}):a.jsxs(a.Fragment,{children:[a.jsx(lm,{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(Mg,{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(_h,{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(lm,{className:"w-3 h-3 text-status-error"}),a.jsx("span",{className:"text-status-error",children:"Offline"})]})})]})]}),!h&&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(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(qu,{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(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(xM,{className:"w-4 h-4"})})]})]}),n&&a.jsx(Zn,{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:p,onCancel:()=>r(null)})]})}function Hz({onClose:t}){const{data:e,isLoading:n}=ct({queryKey:["smart-plugs"],queryFn:oe.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(al,{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(pt,{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(al,{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(Lfe,{plug:i},i.id))})})]})}const BW=[{name:"globe",icon:oh},{name:"link",icon:Uy},{name:"external-link",icon:Xr},{name:"book",icon:Pce},{name:"file-text",icon:fs},{name:"home",icon:Iy},{name:"star",icon:sm},{name:"heart",icon:xde},{name:"bookmark",icon:Rce},{name:"shopping-cart",icon:RW},{name:"music",icon:yP},{name:"video",icon:LR},{name:"image",icon:Lu},{name:"camera",icon:Bg},{name:"map",icon:$de},{name:"compass",icon:wue},{name:"coffee",icon:xue},{name:"gift",icon:ade},{name:"wrench",icon:cm},{name:"zap",icon:_h},{name:"cloud",icon:cM},{name:"database",icon:Eu},{name:"folder",icon:kW},{name:"mail",icon:Bde},{name:"phone",icon:fhe},{name:"user",icon:om},{name:"users",icon:pg},{name:"server",icon:wf},{name:"terminal",icon:FW},{name:"code",icon:NW}];function vM(t){return BW.find(n=>n.name===t)?.icon||Uy}function Ffe({value:t,onChange:e}){const[n,r]=_.useState(!1),i=vM(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:BW.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 $z=768;function UR(){const[t,e]=_.useState(()=>typeof window<"u"?window.innerWidth<$z:!1);return _.useEffect(()=>{const n=window.matchMedia(`(max-width: ${$z-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const HW=_.createContext(void 0);function Ife({children:t}){const[e,n]=_.useState(null),[r,i]=_.useState(!1),[s,o]=_.useState(!1),[l,c]=_.useState(!0),u=_.useRef(!1),d=_.useRef(!0),h=async()=>{try{const C=await oe.getAuthStatus();if(!d.current)return;if(i(C.auth_enabled),o(C.requires_setup),C.auth_enabled)if(zz())try{const P=await oe.getCurrentUser();if(!d.current)return;n(P)}catch{if(a0(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)}};_.useEffect(()=>(d.current=!0,h(),()=>{d.current=!1}),[]),_.useEffect(()=>{if(!l&&s&&!r){const C=window.location.pathname;C!=="/setup"&&!C.startsWith("/camera/")&&!u.current&&(u.current=!0,window.location.href="/setup")}else s||(u.current=!1)},[l,s,r]);const p=async(C,E)=>{const P=await oe.login({username:C,password:E});a0(P.access_token),n(P.user)},m=()=>{a0(null),n(null),oe.logout().catch(()=>{}),window.location.href="/login"},x=async()=>{if(r&&zz())try{const C=await oe.getCurrentUser();d.current&&n(C)}catch{a0(null),d.current&&n(null)}},y=async()=>{await h()},v=_.useMemo(()=>new Set(e?.permissions??[]),[e?.permissions]),b=_.useMemo(()=>r?e?.is_admin??!1:!0,[r,e?.is_admin]),S=_.useCallback(C=>!r||b?!0:v.has(C),[r,b,v]),N=_.useCallback((...C)=>!r||b?!0:C.some(E=>v.has(E)),[r,b,v]),T=_.useCallback((...C)=>!r||b?!0:C.every(E=>v.has(E)),[r,b,v]),k=_.useCallback((C,E,P)=>{if(!r||b)return!0;const A=`${C}:${E}_all`,D=`${C}:${E}_own`;return v.has(A)?!0:v.has(D)?P==null?!1:P===e?.id:!1},[r,b,v,e?.id]);return a.jsx(HW.Provider,{value:{user:e,authEnabled:r,requiresSetup:s,loading:l,isAdmin:b,login:p,logout:m,refreshUser:x,refreshAuth:y,hasPermission:S,hasAnyPermission:N,hasAllPermissions:T,canModify:k},children:t})}function Ci(){const t=_.useContext(HW);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const $W=_.createContext(void 0);function Hn(){const t=_.useContext($W);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Ufe={success:a.jsx(Ar,{className:"w-5 h-5 text-green-400"}),error:a.jsx(Ji,{className:"w-5 h-5 text-red-400"}),warning:a.jsx(Vi,{className:"w-5 h-5 text-yellow-400"}),info:a.jsx(nl,{className:"w-5 h-5 text-blue-400"}),loading:a.jsx(pt,{className:"w-5 h-5 text-bambu-green animate-spin"})},zfe={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 Bfe({children:t}){const[e,n]=_.useState([]),r=_.useRef(new Map);_.useEffect(()=>{const l=r.current;return()=>{l.forEach(c=>clearTimeout(c)),l.clear()}},[]);const i=_.useCallback((l,c="success")=>{const u=Math.random().toString(36).substr(2,9);n(h=>[...h,{id:u,message:l,type:c}]);const d=setTimeout(()=>{n(h=>h.filter(p=>p.id!==u)),r.current.delete(u)},3e3);r.current.set(u,d)},[]),s=_.useCallback((l,c,u="info")=>{n(d=>d.find(p=>p.id===l)?d.map(p=>p.id===l?{...p,message:c,type:u,persistent:!0}:p):[...d,{id:l,message:c,type:u,persistent:!0}])},[]),o=_.useCallback(l=>{const c=r.current.get(l);c&&(clearTimeout(c),r.current.delete(l)),n(u=>u.filter(d=>d.id!==l))},[]);return a.jsxs($W.Provider,{value:{showToast:i,showPersistentToast:s,dismissToast:o},children:[t,a.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(l=>a.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${zfe[l.type]}`,children:[Ufe[l.type],a.jsx("span",{className:"text-white text-sm",children:l.message}),a.jsx("button",{onClick:()=>o(l.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{className:"w-4 h-4"})})]},l.id))})]})}const X0=[{id:"printers",to:"/",icon:Ur,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:go,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:ti,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:Wce,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:cM,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:cm,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:es,labelKey:"nav.projects"},{id:"files",to:"/files",icon:zl,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:bM,labelKey:"nav.settings"}];function Hfe(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return X0.map(e=>e.id)}return X0.map(e=>e.id)}function $fe(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function aT(t){return t.startsWith("ext-")}function VW(){return localStorage.getItem("defaultView")||"/"}function Vfe(t){localStorage.setItem("defaultView",t)}function Gfe(){const t=Tc(),e=Ec(),{mode:n,toggleMode:r}=Fh(),{t:i}=On(),s=UR(),{user:o,authEnabled:l,logout:c,hasPermission:u}=Ci(),{showToast:d}=Hn(),[h,p]=_.useState(!1),[m,x]=_.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[y,v]=_.useState(!1),[b,S]=_.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[N,T]=_.useState(!1),[k,C]=_.useState(!1),[E,P]=_.useState(!1),[A,D]=_.useState(Hfe),[I,L]=_.useState(null),[U,j]=_.useState(null),V=_.useRef(!1),[K,z]=_.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),[X,Y]=_.useState(null),{data:te}=ct({queryKey:["version"],queryFn:oe.getVersion,staleTime:1/0}),{data:$}=ct({queryKey:["settings"],queryFn:oe.getSettings,staleTime:300*1e3}),{data:W}=ct({queryKey:["updateCheck"],queryFn:oe.checkForUpdates,enabled:$?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:ne}=ct({queryKey:["external-links"],queryFn:oe.getExternalLinks}),{data:re}=ct({queryKey:["smart-plugs"],queryFn:oe.getSmartPlugs,staleTime:30*1e3}),ge=re?.some(O=>O.show_in_switchbar)??!1,{data:me}=ct({queryKey:["debugLogging"],queryFn:kg.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:ue}=ct({queryKey:["queue","pending"],queryFn:()=>oe.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),Te=ue?.length??0,{data:ie}=ct({queryKey:["pending-uploads","count"],queryFn:sg.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),Ce=ie?.count??0,[Fe,xe]=_.useState(null);_.useEffect(()=>{if(!me?.enabled||!me.enabled_at){xe(null);return}const O=new Date(me.enabled_at).getTime(),J=()=>{xe(Math.floor((Date.now()-O)/1e3))};J();const le=setInterval(J,1e3);return()=>clearInterval(le)},[me?.enabled,me?.enabled_at]);const Ze=_.useMemo(()=>new Map(X0.map(O=>[O.id,O])),[]),G=_.useMemo(()=>new Map((ne||[]).map(O=>[`ext-${O.id}`,O])),[ne]),Q=(()=>{const O=[],J=new Set,le=l&&o?.role==="user";for(const Se of A)le&&Se==="settings"||(Ze.has(Se)||G.has(Se))&&(O.push(Se),J.add(Se));for(const Se of X0)le&&Se.id==="settings"||J.has(Se.id)||(O.push(Se.id),J.add(Se.id));for(const Se of ne||[]){const we=`ext-${Se.id}`;J.has(we)||(O.push(we),J.add(we))}return O})(),de=(O,J)=>{L(J),O.dataTransfer.effectAllowed="move",O.dataTransfer.setData("text/plain",J)},q=(O,J)=>{O.preventDefault(),O.dataTransfer.dropEffect="move",j(J)},ee=()=>{j(null)},B=(O,J)=>{if(O.preventDefault(),I===null||I===J){L(null),j(null);return}const le=[...Q],Se=le.indexOf(I),we=le.indexOf(J);if(Se===-1||we===-1){L(null),j(null);return}le.splice(Se,1),le.splice(we,0,I),D(le),$fe(le),L(null),j(null)},he=()=>{L(null),j(null)},ke=W?.update_available&&W.latest_version&&W.latest_version!==K,pe=()=>{W?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",W.latest_version),z(W.latest_version))};_.useEffect(()=>{if(!V.current&&e.pathname==="/"){const O=VW();O!=="/"&&(V.current=!0,t(O,{replace:!0}))}},[e.pathname,t]),_.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(b))},[b]),_.useEffect(()=>{s&&T(!1)},[e.pathname,s]),_.useEffect(()=>{const O=J=>{const le=J.detail;Y({printer_id:le.printer_id,printer_name:le.printer_name,message:le.message})};return window.addEventListener("plate-not-empty",O),()=>window.removeEventListener("plate-not-empty",O)},[]);const H=_.useCallback(O=>{const J=O.target;if(!(J.tagName==="INPUT"||J.tagName==="TEXTAREA"||J.isContentEditable)&&!O.metaKey&&!O.ctrlKey&&!O.altKey){const le=parseInt(O.key);if(le>=1&&le<=Q.length&&le<=9){const Se=Q[le-1];if(O.preventDefault(),aT(Se)){const we=Se.replace("ext-","");t(`/external/${we}`)}else{const we=Ze.get(Se);we&&t(we.to)}return}switch(O.key){case"?":O.preventDefault(),C(!0);break;case"Escape":C(!1);break}}},[t,Q,Ze]);return _.useEffect(()=>(document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)),[H]),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:()=>T(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:a.jsx(Yde,{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&&N&&a.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>T(!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 ${N?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${b?"w-64":"w-16"}`}`,children:[a.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${s||b?"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||b?"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:Q.map(O=>{if(aT(O)){const le=G.get(O);if(!le)return null;const Se=le.custom_icon?null:vM(le.icon);return a.jsx("li",{draggable:!0,onDragStart:we=>de(we,O),onDragOver:we=>q(we,O),onDragLeave:ee,onDrop:we=>B(we,O),onDragEnd:he,className:`relative ${I===O?"opacity-50":""} ${U===O&&I!==O?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:a.jsxs(i0,{to:`/external/${le.id}`,className:({isActive:we})=>`flex items-center ${s||b?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${we?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!b?le.name:void 0,children:[b&&!s&&a.jsx(Hg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),le.custom_icon?a.jsx("img",{src:`/api/v1/external-links/${le.id}/icon`,alt:"",className:`w-5 h-5 flex-shrink-0 ${n==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):Se&&a.jsx(Se,{className:"w-5 h-5 flex-shrink-0"}),(s||b)&&a.jsx("span",{children:le.name})]})},O)}else{const le=Ze.get(O);if(!le)return null;const{to:Se,icon:we,labelKey:ae}=le,Le=O==="queue"&&Te>0,Be=O==="archives"&&Ce>0,Ve=Le?Te:Be?Ce:0,He=Le||Be;return a.jsx("li",{draggable:!0,onDragStart:be=>de(be,O),onDragOver:be=>q(be,O),onDragLeave:ee,onDrop:be=>B(be,O),onDragEnd:he,className:`relative ${I===O?"opacity-50":""} ${U===O&&I!==O?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:a.jsxs(i0,{to:Se,className:({isActive:be})=>`flex items-center ${s||b?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${be?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!s&&!b?i(ae):void 0,children:[b&&!s&&a.jsx(Hg,{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(we,{className:"w-5 h-5 flex-shrink-0"}),He&&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 ${Be?"bg-blue-500 text-white":"bg-yellow-500 text-black"}`,children:Ve>99?"99+":Ve})]}),(s||b)&&a.jsx("span",{children:i(ae)})]})},O)}})})}),!s&&a.jsx("button",{onClick:()=>S(!b),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(b?"nav.collapseSidebar":"nav.expandSidebar"),children:b?a.jsx(bh,{className:"w-5 h-5"}):a.jsx(vs,{className:"w-5 h-5"})}),a.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:s||b?a.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[a.jsxs("div",{className:"flex items-center justify-center gap-1",children:[ge&&a.jsxs("div",{className:"relative",children:[a.jsx("button",{onMouseEnter:()=>P(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${E?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:a.jsx(al,{className:"w-5 h-5"})}),E&&a.jsx(Hz,{onClose:()=>P(!1)})]}),u("system:read")?a.jsx(i0,{to:"/system",className:({isActive:O})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${O?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:a.jsx(nl,{className:"w-5 h-5"})}):a.jsx("span",{className:"p-2 rounded-lg text-bambu-gray/50 cursor-not-allowed",title:"You do not have permission to view system information",children:a.jsx(nl,{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(mP,{className:"w-5 h-5"})}),a.jsx("button",{onClick:()=>C(!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(pP,{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(Uz,{className:"w-5 h-5"}):a.jsx(X1,{className:"w-5 h-5"})}),l&&o&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>p(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("changePassword.title"),children:a.jsx(Ko,{className:"w-5 h-5"})}),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(xP,{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",te?.version||"..."]}),W?.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:W.latest_version}),children:[a.jsx(eT,{className:"w-4 h-4"}),a.jsx("span",{children:i("nav.update")})]})]})]}):a.jsxs("div",{className:"flex flex-col items-center gap-1",children:[W?.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:W.latest_version}),children:a.jsx(eT,{className:"w-5 h-5"})}),ge&&a.jsxs("div",{className:"relative",children:[a.jsx("button",{onMouseEnter:()=>P(!0),className:`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${E?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.smartSwitches",{defaultValue:"Smart Switches"}),children:a.jsx(al,{className:"w-5 h-5"})}),E&&a.jsx(Hz,{onClose:()=>P(!1)})]}),u("system:read")?a.jsx(i0,{to:"/system",className:({isActive:O})=>`p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors ${O?"text-bambu-green":"text-bambu-gray-light hover:text-white"}`,title:i("nav.system"),children:a.jsx(nl,{className:"w-5 h-5"})}):a.jsx("span",{className:"p-2 rounded-lg text-bambu-gray/50 cursor-not-allowed",title:"You do not have permission to view system information",children:a.jsx(nl,{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(mP,{className:"w-5 h-5"})}),a.jsx("button",{onClick:()=>C(!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(pP,{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(Uz,{className:"w-5 h-5"}):a.jsx(X1,{className:"w-5 h-5"})}),l&&o&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>p(!0),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-gray-light hover:text-white",title:i("changePassword.title"),children:a.jsx(Ko,{className:"w-5 h-5"})}),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(xP,{className:"w-5 h-5"})})]})]})})]}),a.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${s?"mt-14":b?"ml-64":"ml-16"}`,children:[me?.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(oM,{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"}),Fe!==null&&a.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(Fe/60),"m ",Fe%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"})})]})}),ke&&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(eT,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{children:i("nav.updateAvailableBanner",{version:W?.latest_version,defaultValue:`Version ${W?.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:pe,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:a.jsx(Lt,{className:"w-4 h-4"})})]}),a.jsx(Zoe,{})]}),k&&a.jsx(Ofe,{onClose:()=>C(!1),sidebarItems:Q.map(O=>{if(aT(O)){const J=G.get(O);return J?{type:"external",label:J.name}:null}else{const J=Ze.get(O);return J?{type:"nav",label:J.labelKey,labelKey:J.labelKey}:null}}).filter(Boolean)}),X&&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:i("plateAlert.title")}),a.jsx("p",{className:"text-lg text-white mb-2",children:X.printer_name}),a.jsx("p",{className:"text-bambu-gray mb-6",children:i("plateAlert.message")}),a.jsx("button",{onClick:()=>Y(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("plateAlert.understand")})]})})}),h&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsxs(St,{className:"w-full max-w-md",onClick:O=>O.stopPropagation(),children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ko,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("changePassword.title")})]}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>{p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsx(Lt,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{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:i("changePassword.currentPassword")}),a.jsx("input",{type:"password",value:m.currentPassword,onChange:O=>x({...m,currentPassword:O.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:i("changePassword.currentPasswordPlaceholder"),autoComplete:"current-password"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.newPassword")}),a.jsx("input",{type:"password",value:m.newPassword,onChange:O=>x({...m,newPassword:O.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:i("changePassword.newPasswordPlaceholder"),autoComplete:"new-password",minLength:6})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.confirmPassword")}),a.jsx("input",{type:"password",value:m.confirmPassword,onChange:O=>x({...m,confirmPassword:O.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${m.confirmPassword&&m.newPassword!==m.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("changePassword.confirmPasswordPlaceholder"),autoComplete:"new-password",minLength:6}),m.confirmPassword&&m.newPassword!==m.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("changePassword.passwordsDoNotMatch")})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Ae,{variant:"secondary",onClick:()=>{p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:i("common.cancel")}),a.jsx(Ae,{onClick:async()=>{if(m.newPassword!==m.confirmPassword){d(i("changePassword.passwordsDoNotMatch"),"error");return}if(m.newPassword.length<6){d(i("changePassword.passwordTooShort"),"error");return}v(!0);try{await oe.changePassword(m.currentPassword,m.newPassword),d(i("changePassword.success"),"success"),p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})}catch(O){const J=O instanceof Error?O.message:i("changePassword.failed");d(J,"error")}finally{v(!1)}},disabled:y||!m.currentPassword||!m.newPassword||m.newPassword!==m.confirmPassword||m.newPassword.length<6,children:y?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 animate-spin"}),i("changePassword.changing")]}):a.jsxs(a.Fragment,{children:[a.jsx(Ko,{className:"w-4 h-4"}),i("changePassword.title")]})})]})]})]})})]})}function qfe(t="system"){switch(t){case"us":return"MM/DD/YYYY";case"eu":return"DD/MM/YYYY";case"iso":return"YYYY-MM-DD";case"system":default:{const n=new Date(2e3,11,31).toLocaleDateString();return n.startsWith("12")?"MM/DD/YYYY":n.startsWith("31")?"DD/MM/YYYY":"YYYY-MM-DD"}}}function Wfe(t="system"){switch(t){case"12h":return"HH:MM AM/PM";case"24h":return"HH:MM";case"system":default:{const n=new Date(2e3,0,1,14,30).toLocaleTimeString();return n.includes("PM")||n.includes("AM")?"HH:MM AM/PM":"HH:MM"}}}function Vz(t,e="system"){const n=String(t.getDate()).padStart(2,"0"),r=String(t.getMonth()+1).padStart(2,"0"),i=t.getFullYear();switch(e){case"us":return`${r}/${n}/${i}`;case"eu":return`${n}/${r}/${i}`;case"iso":return`${i}-${r}-${n}`;case"system":default:return t.toLocaleDateString()}}function Gz(t,e="system"){const n=t.getHours(),r=String(t.getMinutes()).padStart(2,"0");switch(e){case"12h":{const i=n%12||12,s=n<12?"AM":"PM";return`${i}:${r} ${s}`}case"24h":return`${String(n).padStart(2,"0")}:${r}`;case"system":default:return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}}function Kfe(t,e="system"){if(!t)return null;let n,r,i;try{switch(e){case"us":{const s=t.split("/");if(s.length!==3)return null;r=parseInt(s[0],10),n=parseInt(s[1],10),i=parseInt(s[2],10);break}case"eu":{const s=t.split("/");if(s.length!==3)return null;n=parseInt(s[0],10),r=parseInt(s[1],10),i=parseInt(s[2],10);break}case"iso":{const s=t.split("-");if(s.length!==3)return null;i=parseInt(s[0],10),r=parseInt(s[1],10),n=parseInt(s[2],10);break}case"system":default:{const s=new Date(t);if(!isNaN(s.getTime()))return s;const o=t.split("/");if(o.length===3){n=parseInt(o[0],10),r=parseInt(o[1],10),i=parseInt(o[2],10);break}return null}}return isNaN(n)||isNaN(r)||isNaN(i)||r<1||r>12||n<1||n>31||i<1900||i>2100?null:new Date(i,r-1,n)}catch{return null}}function Xfe(t){if(!t)return null;try{const e=t.trim().toUpperCase(),n=e.match(/^(\d{1,2}):(\d{2})\s*(AM|PM)?$/i);if(n){let i=parseInt(n[1],10);const s=parseInt(n[2],10),o=n[3]?.toUpperCase();return o==="PM"&&i<12&&(i+=12),o==="AM"&&i===12&&(i=0),i<0||i>23||s<0||s>59?null:{hours:i,minutes:s}}const r=e.match(/^(\d{1,2}):(\d{2})$/);if(r){const i=parseInt(r[1],10),s=parseInt(r[2],10);return i<0||i>23||s<0||s>59?null:{hours:i,minutes:s}}return null}catch{return null}}function qz(t){const e=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),i=String(t.getHours()).padStart(2,"0"),s=String(t.getMinutes()).padStart(2,"0");return`${e}-${n}-${r}T${i}:${s}`}function v0(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function zi(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function $g(t,e){const n=zi(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function Vg(t,e="system",n){const r=zi(t);if(!r)return"";const s=v0(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,s)}function Yfe(t,e="system",n){const i=v0({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}const zR="181",Eg={ROTATE:0,DOLLY:1,PAN:2},gg={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Qfe=0,Wz=1,Zfe=2,GW=1,Jfe=2,uu=3,Sh=0,Bs=1,sc=2,Tu=0,Tg=1,Kz=2,Xz=3,Yz=4,eme=5,kf=100,tme=101,nme=102,rme=103,ime=104,ame=200,sme=201,ome=202,lme=203,wP=204,_P=205,cme=206,ume=207,dme=208,hme=209,fme=210,mme=211,pme=212,gme=213,xme=214,SP=0,NP=1,MP=2,Gg=3,kP=4,EP=5,TP=6,AP=7,BR=0,bme=1,yme=2,lh=0,vme=1,wme=2,_me=3,Sme=4,Nme=5,Mme=6,kme=7,qW=300,qg=301,Wg=302,CP=303,jP=304,wM=306,PP=1e3,vu=1001,DP=1002,xo=1003,Eme=1004,Lw=1005,rl=1006,sT=1007,Rf=1008,yc=1009,WW=1010,KW=1011,Y0=1012,HR=1013,um=1014,wu=1015,wx=1016,$R=1017,VR=1018,Q0=1020,XW=35902,YW=35899,QW=1021,ZW=1022,Ol=1023,Z0=1026,J0=1027,JW=1028,GR=1029,qR=1030,WR=1031,KR=1033,y1=33776,v1=33777,w1=33778,_1=33779,RP=35840,OP=35841,LP=35842,FP=35843,IP=36196,UP=37492,zP=37496,BP=37808,HP=37809,$P=37810,VP=37811,GP=37812,qP=37813,WP=37814,KP=37815,XP=37816,YP=37817,QP=37818,ZP=37819,JP=37820,e3=37821,t3=36492,n3=36494,r3=36495,i3=36283,a3=36284,s3=36285,o3=36286,Tme=3200,Ame=3201,eK=0,Cme=1,Kd="",co="srgb",Kg="srgb-linear",Q1="linear",Mr="srgb",bp=7680,Qz=519,jme=512,Pme=513,Dme=514,tK=515,Rme=516,Ome=517,Lme=518,Fme=519,Zz=35044,Jz="300 es",uc=2e3,Z1=2001;function nK(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function J1(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Ime(){const t=J1("canvas");return t.style.display="block",t}const eB={};function tB(...t){const e="THREE."+t.shift();console.log(e,...t)}function pn(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Ti(...t){const e="THREE."+t.shift();console.error(e,...t)}function ey(...t){const e=t.join(" ");e in eB||(eB[e]=!0,pn(...t))}function Ume(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 Tm=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 Va=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],S1=Math.PI/180,l3=180/Math.PI;function zy(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Va[t&255]+Va[t>>8&255]+Va[t>>16&255]+Va[t>>24&255]+"-"+Va[e&255]+Va[e>>8&255]+"-"+Va[e>>16&15|64]+Va[e>>24&255]+"-"+Va[n&63|128]+Va[n>>8&255]+"-"+Va[n>>16&255]+Va[n>>24&255]+Va[r&255]+Va[r>>8&255]+Va[r>>16&255]+Va[r>>24&255]).toLowerCase()}function Bn(t,e,n){return Math.max(e,Math.min(n,t))}function zme(t,e){return(t%e+e)%e}function oT(t,e,n){return(1-n)*t+n*e}function Db(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 Rs(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 Bme={DEG2RAD:S1};let Cn=class rK{constructor(e=0,n=0){rK.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=Bn(this.x,e.x,n.x),this.y=Bn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=Bn(this.x,e,n),this.y=Bn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Bn(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(Bn(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}},dm=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],h=r[i+3],p=s[o+0],m=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]=h;return}if(l>=1){e[n+0]=p,e[n+1]=m,e[n+2]=x,e[n+3]=y;return}if(h!==y||c!==p||u!==m||d!==x){let v=c*p+u*m+d*x+h*y;v<0&&(p=-p,m=-m,x=-x,y=-y,v=-v);let b=1-l;if(v<.9995){const S=Math.acos(v),N=Math.sin(S);b=Math.sin(b*S)/N,l=Math.sin(l*S)/N,c=c*b+p*l,u=u*b+m*l,d=d*b+x*l,h=h*b+y*l}else{c=c*b+p*l,u=u*b+m*l,d=d*b+x*l,h=h*b+y*l;const S=1/Math.sqrt(c*c+u*u+d*d+h*h);c*=S,u*=S,d*=S,h*=S}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,s,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],h=s[o],p=s[o+1],m=s[o+2],x=s[o+3];return e[n]=l*x+d*h+c*m-u*p,e[n+1]=c*x+d*p+u*h-l*m,e[n+2]=u*x+d*m+l*p-c*h,e[n+3]=d*x-l*h-c*p-u*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n=!0){const r=e._x,i=e._y,s=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),h=l(s/2),p=c(r/2),m=c(i/2),x=c(s/2);switch(o){case"XYZ":this._x=p*d*h+u*m*x,this._y=u*m*h-p*d*x,this._z=u*d*x+p*m*h,this._w=u*d*h-p*m*x;break;case"YXZ":this._x=p*d*h+u*m*x,this._y=u*m*h-p*d*x,this._z=u*d*x-p*m*h,this._w=u*d*h+p*m*x;break;case"ZXY":this._x=p*d*h-u*m*x,this._y=u*m*h+p*d*x,this._z=u*d*x+p*m*h,this._w=u*d*h-p*m*x;break;case"ZYX":this._x=p*d*h-u*m*x,this._y=u*m*h+p*d*x,this._z=u*d*x-p*m*h,this._w=u*d*h+p*m*x;break;case"YZX":this._x=p*d*h+u*m*x,this._y=u*m*h+p*d*x,this._z=u*d*x-p*m*h,this._w=u*d*h-p*m*x;break;case"XZY":this._x=p*d*h-u*m*x,this._y=u*m*h-p*d*x,this._z=u*d*x+p*m*h,this._w=u*d*h+p*m*x;break;default:pn("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],h=n[10],p=r+l+h;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(d-c)*m,this._y=(s-u)*m,this._z=(o-i)*m}else if(r>l&&r>h){const m=2*Math.sqrt(1+r-l-h);this._w=(d-c)/m,this._x=.25*m,this._y=(i+o)/m,this._z=(s+u)/m}else if(l>h){const m=2*Math.sqrt(1+l-r-h);this._w=(s-u)/m,this._x=(i+o)/m,this._y=.25*m,this._z=(c+d)/m}else{const m=2*Math.sqrt(1+h-r-l);this._w=(o-i)/m,this._x=(s+u)/m,this._y=(c+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Bn(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}},mt=class iK{constructor(e=0,n=0,r=0){iK.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(nB.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(nB.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),h=2*(s*r-o*n);return this.x=n+c*u+o*h-l*d,this.y=r+c*d+l*u-s*h,this.z=i+c*h+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=Bn(this.x,e.x,n.x),this.y=Bn(this.y,e.y,n.y),this.z=Bn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=Bn(this.x,e,n),this.y=Bn(this.y,e,n),this.z=Bn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Bn(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 lT.copy(this).projectOnVector(e),this.sub(lT)}reflect(e){return this.sub(lT.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(Bn(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 lT=new mt,nB=new dm;let Dn=class aK{constructor(e,n,r,i,s,o,l,c,u){aK.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],h=r[7],p=r[2],m=r[5],x=r[8],y=i[0],v=i[3],b=i[6],S=i[1],N=i[4],T=i[7],k=i[2],C=i[5],E=i[8];return s[0]=o*y+l*S+c*k,s[3]=o*v+l*N+c*C,s[6]=o*b+l*T+c*E,s[1]=u*y+d*S+h*k,s[4]=u*v+d*N+h*C,s[7]=u*b+d*T+h*E,s[2]=p*y+m*S+x*k,s[5]=p*v+m*N+x*C,s[8]=p*b+m*T+x*E,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],h=d*o-l*u,p=l*c-d*s,m=u*s-o*c,x=n*h+r*p+i*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=h*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=p*y,e[4]=(d*n-i*c)*y,e[5]=(i*s-l*n)*y,e[6]=m*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(cT.makeScale(e,n)),this}rotate(e){return this.premultiply(cT.makeRotation(-e)),this}translate(e,n){return this.premultiply(cT.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 cT=new Dn,rB=new Dn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),iB=new Dn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Hme(){const t={enabled:!0,workingColorSpace:Kg,spaces:{},convert:function(i,s,o){return this.enabled===!1||s===o||!s||!o||(this.spaces[s].transfer===Mr&&(i.r=Au(i.r),i.g=Au(i.g),i.b=Au(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===Mr&&(i.r=Ag(i.r),i.g=Ag(i.g),i.b=Ag(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===Kd?Q1: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 ey("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,s)},toWorkingColorSpace:function(i,s){return ey("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({[Kg]:{primaries:e,whitePoint:r,transfer:Q1,toXYZ:rB,fromXYZ:iB,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:co},outputColorSpaceConfig:{drawingBufferColorSpace:co}},[co]:{primaries:e,whitePoint:r,transfer:Mr,toXYZ:rB,fromXYZ:iB,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:co}}}),t}const cr=Hme();function Au(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Ag(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let yp,$me=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{yp===void 0&&(yp=J1("canvas")),yp.width=e.width,yp.height=e.height;const i=yp.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=yp}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=J1("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]=Au(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(Au(n[r]/255)*255):n[r]=Au(n[r]);return{data:n,width:e.width,height:e.height}}else return pn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},Vme=0,XR=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Vme++}),this.uuid=zy(),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(uT(i[o].image)):s.push(uT(i[o]))}else s=uT(i);r.url=s}return n||(e.images[this.uuid]=r),r}};function uT(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?$me.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(pn("Texture: Unable to serialize Texture."),{})}let Gme=0;const dT=new mt;let $l=class N1 extends Tm{constructor(e=N1.DEFAULT_IMAGE,n=N1.DEFAULT_MAPPING,r=vu,i=vu,s=rl,o=Rf,l=Ol,c=yc,u=N1.DEFAULT_ANISOTROPY,d=Kd){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Gme++}),this.uuid=zy(),this.name="",this.source=new XR(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 Cn(0,0),this.repeat=new Cn(1,1),this.center=new Cn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Dn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=d,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(dT).x}get height(){return this.source.getSize(dT).y}get depth(){return this.source.getSize(dT).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){pn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){pn(`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!==qW)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 vu:e.x=e.x<0?0:1;break;case DP: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 vu:e.y=e.y<0?0:1;break;case DP: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++}};$l.DEFAULT_IMAGE=null;$l.DEFAULT_MAPPING=qW;$l.DEFAULT_ANISOTROPY=1;let Bi=class sK{constructor(e=0,n=0,r=0,i=1){sK.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],h=c[8],p=c[1],m=c[5],x=c[9],y=c[2],v=c[6],b=c[10];if(Math.abs(d-p)<.01&&Math.abs(h-y)<.01&&Math.abs(x-v)<.01){if(Math.abs(d+p)<.1&&Math.abs(h+y)<.1&&Math.abs(x+v)<.1&&Math.abs(u+m+b-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const N=(u+1)/2,T=(m+1)/2,k=(b+1)/2,C=(d+p)/4,E=(h+y)/4,P=(x+v)/4;return N>T&&N>k?N<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(N),i=C/r,s=E/r):T>k?T<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(T),r=C/i,s=P/i):k<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(k),r=E/s,i=P/s),this.set(r,i,s,n),this}let S=Math.sqrt((v-x)*(v-x)+(h-y)*(h-y)+(p-d)*(p-d));return Math.abs(S)<.001&&(S=1),this.x=(v-x)/S,this.y=(h-y)/S,this.z=(p-d)/S,this.w=Math.acos((u+m+b-1)/2),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this.w=n[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Bn(this.x,e.x,n.x),this.y=Bn(this.y,e.y,n.y),this.z=Bn(this.z,e.z,n.z),this.w=Bn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=Bn(this.x,e,n),this.y=Bn(this.y,e,n),this.z=Bn(this.z,e,n),this.w=Bn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Bn(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}},qme=class extends Tm{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:rl,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 Bi(0,0,e,n),this.scissorTest=!1,this.viewport=new Bi(0,0,e,n);const i={width:e,height:n,depth:r.depth},s=new $l(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:rl,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 XR(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"})}},hm=class extends qme{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},oK=class extends $l{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=xo,this.minFilter=xo,this.wrapR=vu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},Wme=class extends $l{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=xo,this.minFilter=xo,this.wrapR=vu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},ch=class{constructor(e=new mt(1/0,1/0,1/0),n=new mt(-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(Sl.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(Sl.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=Sl.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,Sl):Sl.fromBufferAttribute(s,o),Sl.applyMatrix4(e.matrixWorld),this.expandByPoint(Sl);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Fw.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),Fw.copy(r.boundingBox)),Fw.applyMatrix4(e.matrixWorld),this.union(Fw)}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,Sl),Sl.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(Rb),Iw.subVectors(this.max,Rb),vp.subVectors(e.a,Rb),wp.subVectors(e.b,Rb),_p.subVectors(e.c,Rb),Sd.subVectors(wp,vp),Nd.subVectors(_p,wp),cf.subVectors(vp,_p);let n=[0,-Sd.z,Sd.y,0,-Nd.z,Nd.y,0,-cf.z,cf.y,Sd.z,0,-Sd.x,Nd.z,0,-Nd.x,cf.z,0,-cf.x,-Sd.y,Sd.x,0,-Nd.y,Nd.x,0,-cf.y,cf.x,0];return!hT(n,vp,wp,_p,Iw)||(n=[1,0,0,0,1,0,0,0,1],!hT(n,vp,wp,_p,Iw))?!1:(Uw.crossVectors(Sd,Nd),n=[Uw.x,Uw.y,Uw.z],hT(n,vp,wp,_p,Iw))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Sl).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Sl).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:(Kc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Kc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Kc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Kc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Kc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Kc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Kc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Kc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Kc),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 Kc=[new mt,new mt,new mt,new mt,new mt,new mt,new mt,new mt],Sl=new mt,Fw=new ch,vp=new mt,wp=new mt,_p=new mt,Sd=new mt,Nd=new mt,cf=new mt,Rb=new mt,Iw=new mt,Uw=new mt,uf=new mt;function hT(t,e,n,r,i){for(let s=0,o=t.length-3;s<=o;s+=3){uf.fromArray(t,s);const l=i.x*Math.abs(uf.x)+i.y*Math.abs(uf.y)+i.z*Math.abs(uf.z),c=e.dot(uf),u=n.dot(uf),d=r.dot(uf);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const Kme=new ch,Ob=new mt,fT=new mt;let _M=class{constructor(e=new mt,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):Kme.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;Ob.subVectors(e,this.center);const n=Ob.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Ob,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(fT.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ob.copy(e.center).add(fT)),this.expandByPoint(Ob.copy(e.center).sub(fT))),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 Xc=new mt,mT=new mt,zw=new mt,Md=new mt,pT=new mt,Bw=new mt,gT=new mt;let YR=class{constructor(e=new mt,n=new mt(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,Xc)),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=Xc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Xc.copy(this.origin).addScaledVector(this.direction,n),Xc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){mT.copy(e).add(n).multiplyScalar(.5),zw.copy(n).sub(e).normalize(),Md.copy(this.origin).sub(mT);const s=e.distanceTo(n)*.5,o=-this.direction.dot(zw),l=Md.dot(this.direction),c=-Md.dot(zw),u=Md.lengthSq(),d=Math.abs(1-o*o);let h,p,m,x;if(d>0)if(h=o*c-l,p=o*l-c,x=s*d,h>=0)if(p>=-x)if(p<=x){const y=1/d;h*=y,p*=y,m=h*(h+o*p+2*l)+p*(o*h+p+2*c)+u}else p=s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;else p=-s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;else p<=-x?(h=Math.max(0,-(-o*s+l)),p=h>0?-s:Math.min(Math.max(-s,-c),s),m=-h*h+p*(p+2*c)+u):p<=x?(h=0,p=Math.min(Math.max(-s,-c),s),m=p*(p+2*c)+u):(h=Math.max(0,-(o*s+l)),p=h>0?s:Math.min(Math.max(-s,-c),s),m=-h*h+p*(p+2*c)+u);else p=o>0?-s:s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(mT).addScaledVector(zw,p),m}intersectSphere(e,n){Xc.subVectors(e.center,this.origin);const r=Xc.dot(this.direction),i=Xc.dot(Xc)-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,h=1/this.direction.z,p=this.origin;return u>=0?(r=(e.min.x-p.x)*u,i=(e.max.x-p.x)*u):(r=(e.max.x-p.x)*u,i=(e.min.x-p.x)*u),d>=0?(s=(e.min.y-p.y)*d,o=(e.max.y-p.y)*d):(s=(e.max.y-p.y)*d,o=(e.min.y-p.y)*d),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),h>=0?(l=(e.min.z-p.z)*h,c=(e.max.z-p.z)*h):(l=(e.max.z-p.z)*h,c=(e.min.z-p.z)*h),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,Xc)!==null}intersectTriangle(e,n,r,i,s){pT.subVectors(n,e),Bw.subVectors(r,e),gT.crossVectors(pT,Bw);let o=this.direction.dot(gT),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Md.subVectors(this.origin,e);const c=l*this.direction.dot(Bw.crossVectors(Md,Bw));if(c<0)return null;const u=l*this.direction.dot(pT.cross(Md));if(u<0||c+u>o)return null;const d=-l*Md.dot(gT);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)}},Gi=class c3{constructor(e,n,r,i,s,o,l,c,u,d,h,p,m,x,y,v){c3.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,h,p,m,x,y,v)}set(e,n,r,i,s,o,l,c,u,d,h,p,m,x,y,v){const b=this.elements;return b[0]=e,b[4]=n,b[8]=r,b[12]=i,b[1]=s,b[5]=o,b[9]=l,b[13]=c,b[2]=u,b[6]=d,b[10]=h,b[14]=p,b[3]=m,b[7]=x,b[11]=y,b[15]=v,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new c3().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/Sp.setFromMatrixColumn(e,0).length(),s=1/Sp.setFromMatrixColumn(e,1).length(),o=1/Sp.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),h=Math.sin(s);if(e.order==="XYZ"){const p=o*d,m=o*h,x=l*d,y=l*h;n[0]=c*d,n[4]=-c*h,n[8]=u,n[1]=m+x*u,n[5]=p-y*u,n[9]=-l*c,n[2]=y-p*u,n[6]=x+m*u,n[10]=o*c}else if(e.order==="YXZ"){const p=c*d,m=c*h,x=u*d,y=u*h;n[0]=p+y*l,n[4]=x*l-m,n[8]=o*u,n[1]=o*h,n[5]=o*d,n[9]=-l,n[2]=m*l-x,n[6]=y+p*l,n[10]=o*c}else if(e.order==="ZXY"){const p=c*d,m=c*h,x=u*d,y=u*h;n[0]=p-y*l,n[4]=-o*h,n[8]=x+m*l,n[1]=m+x*l,n[5]=o*d,n[9]=y-p*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const p=o*d,m=o*h,x=l*d,y=l*h;n[0]=c*d,n[4]=x*u-m,n[8]=p*u+y,n[1]=c*h,n[5]=y*u+p,n[9]=m*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const p=o*c,m=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=y-p*h,n[8]=x*h+m,n[1]=h,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=m*h+x,n[10]=p-y*h}else if(e.order==="XZY"){const p=o*c,m=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=-h,n[8]=u*d,n[1]=p*h+y,n[5]=o*d,n[9]=m*h-x,n[2]=x*h-m,n[6]=l*d,n[10]=y*h+p}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(Xme,e,Yme)}lookAt(e,n,r){const i=this.elements;return ao.subVectors(e,n),ao.lengthSq()===0&&(ao.z=1),ao.normalize(),kd.crossVectors(r,ao),kd.lengthSq()===0&&(Math.abs(r.z)===1?ao.x+=1e-4:ao.z+=1e-4,ao.normalize(),kd.crossVectors(r,ao)),kd.normalize(),Hw.crossVectors(ao,kd),i[0]=kd.x,i[4]=Hw.x,i[8]=ao.x,i[1]=kd.y,i[5]=Hw.y,i[9]=ao.y,i[2]=kd.z,i[6]=Hw.z,i[10]=ao.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],h=r[5],p=r[9],m=r[13],x=r[2],y=r[6],v=r[10],b=r[14],S=r[3],N=r[7],T=r[11],k=r[15],C=i[0],E=i[4],P=i[8],A=i[12],D=i[1],I=i[5],L=i[9],U=i[13],j=i[2],V=i[6],K=i[10],z=i[14],X=i[3],Y=i[7],te=i[11],$=i[15];return s[0]=o*C+l*D+c*j+u*X,s[4]=o*E+l*I+c*V+u*Y,s[8]=o*P+l*L+c*K+u*te,s[12]=o*A+l*U+c*z+u*$,s[1]=d*C+h*D+p*j+m*X,s[5]=d*E+h*I+p*V+m*Y,s[9]=d*P+h*L+p*K+m*te,s[13]=d*A+h*U+p*z+m*$,s[2]=x*C+y*D+v*j+b*X,s[6]=x*E+y*I+v*V+b*Y,s[10]=x*P+y*L+v*K+b*te,s[14]=x*A+y*U+v*z+b*$,s[3]=S*C+N*D+T*j+k*X,s[7]=S*E+N*I+T*V+k*Y,s[11]=S*P+N*L+T*K+k*te,s[15]=S*A+N*U+T*z+k*$,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],h=e[6],p=e[10],m=e[14],x=e[3],y=e[7],v=e[11],b=e[15];return x*(+s*c*h-i*u*h-s*l*p+r*u*p+i*l*m-r*c*m)+y*(+n*c*m-n*u*p+s*o*p-i*o*m+i*u*d-s*c*d)+v*(+n*u*h-n*l*m-s*o*h+r*o*m+s*l*d-r*u*d)+b*(-i*l*d-n*c*h+n*l*p+i*o*h-r*o*p+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],h=e[9],p=e[10],m=e[11],x=e[12],y=e[13],v=e[14],b=e[15],S=h*v*u-y*p*u+y*c*m-l*v*m-h*c*b+l*p*b,N=x*p*u-d*v*u-x*c*m+o*v*m+d*c*b-o*p*b,T=d*y*u-x*h*u+x*l*m-o*y*m-d*l*b+o*h*b,k=x*h*c-d*y*c-x*l*p+o*y*p+d*l*v-o*h*v,C=n*S+r*N+i*T+s*k;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/C;return e[0]=S*E,e[1]=(y*p*s-h*v*s-y*i*m+r*v*m+h*i*b-r*p*b)*E,e[2]=(l*v*s-y*c*s+y*i*u-r*v*u-l*i*b+r*c*b)*E,e[3]=(h*c*s-l*p*s-h*i*u+r*p*u+l*i*m-r*c*m)*E,e[4]=N*E,e[5]=(d*v*s-x*p*s+x*i*m-n*v*m-d*i*b+n*p*b)*E,e[6]=(x*c*s-o*v*s-x*i*u+n*v*u+o*i*b-n*c*b)*E,e[7]=(o*p*s-d*c*s+d*i*u-n*p*u-o*i*m+n*c*m)*E,e[8]=T*E,e[9]=(x*h*s-d*y*s-x*r*m+n*y*m+d*r*b-n*h*b)*E,e[10]=(o*y*s-x*l*s+x*r*u-n*y*u-o*r*b+n*l*b)*E,e[11]=(d*l*s-o*h*s-d*r*u+n*h*u+o*r*m-n*l*m)*E,e[12]=k*E,e[13]=(d*y*i-x*h*i+x*r*p-n*y*p-d*r*v+n*h*v)*E,e[14]=(x*l*i-o*y*i-x*r*c+n*y*c+o*r*v-n*l*v)*E,e[15]=(o*h*i-d*l*i+d*r*c-n*h*c-o*r*p+n*l*p)*E,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,h=l+l,p=s*u,m=s*d,x=s*h,y=o*d,v=o*h,b=l*h,S=c*u,N=c*d,T=c*h,k=r.x,C=r.y,E=r.z;return i[0]=(1-(y+b))*k,i[1]=(m+T)*k,i[2]=(x-N)*k,i[3]=0,i[4]=(m-T)*C,i[5]=(1-(p+b))*C,i[6]=(v+S)*C,i[7]=0,i[8]=(x+N)*E,i[9]=(v-S)*E,i[10]=(1-(p+y))*E,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=Sp.set(i[0],i[1],i[2]).length();const o=Sp.set(i[4],i[5],i[6]).length(),l=Sp.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],Nl.copy(this);const u=1/s,d=1/o,h=1/l;return Nl.elements[0]*=u,Nl.elements[1]*=u,Nl.elements[2]*=u,Nl.elements[4]*=d,Nl.elements[5]*=d,Nl.elements[6]*=d,Nl.elements[8]*=h,Nl.elements[9]*=h,Nl.elements[10]*=h,n.setFromRotationMatrix(Nl),r.x=s,r.y=o,r.z=l,this}makePerspective(e,n,r,i,s,o,l=uc,c=!1){const u=this.elements,d=2*s/(n-e),h=2*s/(r-i),p=(n+e)/(n-e),m=(r+i)/(r-i);let x,y;if(c)x=s/(o-s),y=o*s/(o-s);else if(l===uc)x=-(o+s)/(o-s),y=-2*o*s/(o-s);else if(l===Z1)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]=p,u[12]=0,u[1]=0,u[5]=h,u[9]=m,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=uc,c=!1){const u=this.elements,d=2/(n-e),h=2/(r-i),p=-(n+e)/(n-e),m=-(r+i)/(r-i);let x,y;if(c)x=1/(o-s),y=o/(o-s);else if(l===uc)x=-2/(o-s),y=-(o+s)/(o-s);else if(l===Z1)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]=p,u[1]=0,u[5]=h,u[9]=0,u[13]=m,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 Sp=new mt,Nl=new Gi,Xme=new mt(0,0,0),Yme=new mt(1,1,1),kd=new mt,Hw=new mt,ao=new mt,aB=new Gi,sB=new dm;let Nh=class lK{constructor(e=0,n=0,r=0,i=lK.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],h=i[2],p=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(Bn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(p,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Bn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Bn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-h,m),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Bn(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Bn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(l,m));break;case"XZY":this._z=Math.asin(-Bn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,u),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-d,m),this._y=0);break;default:pn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return aB.makeRotationFromQuaternion(e),this.setFromRotationMatrix(aB,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return sB.setFromEuler(this),this.setFromQuaternion(sB,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}};Nh.DEFAULT_ORDER="XYZ";let cK=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}},Qme=0;const oB=new mt,Np=new dm,Yc=new Gi,$w=new mt,Lb=new mt,Zme=new mt,Jme=new dm,lB=new mt(1,0,0),cB=new mt(0,1,0),uB=new mt(0,0,1),dB={type:"added"},epe={type:"removed"},Mp={type:"childadded",child:null},xT={type:"childremoved",child:null};let No=class M1 extends Tm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Qme++}),this.uuid=zy(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=M1.DEFAULT_UP.clone();const e=new mt,n=new Nh,r=new dm,i=new mt(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 Gi},normalMatrix:{value:new Dn}}),this.matrix=new Gi,this.matrixWorld=new Gi,this.matrixAutoUpdate=M1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=M1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new cK,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 Np.setFromAxisAngle(e,n),this.quaternion.multiply(Np),this}rotateOnWorldAxis(e,n){return Np.setFromAxisAngle(e,n),this.quaternion.premultiply(Np),this}rotateX(e){return this.rotateOnAxis(lB,e)}rotateY(e){return this.rotateOnAxis(cB,e)}rotateZ(e){return this.rotateOnAxis(uB,e)}translateOnAxis(e,n){return oB.copy(e).applyQuaternion(this.quaternion),this.position.add(oB.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(lB,e)}translateY(e){return this.translateOnAxis(cB,e)}translateZ(e){return this.translateOnAxis(uB,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Yc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?$w.copy(e):$w.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Lb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Yc.lookAt(Lb,$w,this.up):Yc.lookAt($w,Lb,this.up),this.quaternion.setFromRotationMatrix(Yc),i&&(Yc.extractRotation(i.matrixWorld),Np.setFromRotationMatrix(Yc),this.quaternion.premultiply(Np.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(Ti("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(dB),Mp.child=e,this.dispatchEvent(Mp),Mp.child=null):Ti("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(epe),xT.child=e,this.dispatchEvent(xT),xT.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),Yc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Yc.multiply(e.parent.matrixWorld)),e.applyMatrix4(Yc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(dB),Mp.child=e,this.dispatchEvent(Mp),Mp.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(Lb,e,Zme),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Lb,Jme,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 h=c[u];s(e.shapes,h)}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),h=o(e.shapes),p=o(e.skeletons),m=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),h.length>0&&(r.shapes=h),p.length>0&&(r.skeletons=p),m.length>0&&(r.animations=m),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}};No.DEFAULT_UP=new mt(0,1,0);No.DEFAULT_MATRIX_AUTO_UPDATE=!0;No.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ml=new mt,Qc=new mt,bT=new mt,Zc=new mt,kp=new mt,Ep=new mt,hB=new mt,yT=new mt,vT=new mt,wT=new mt,_T=new Bi,ST=new Bi,NT=new Bi;let Fb=class og{constructor(e=new mt,n=new mt,r=new mt){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Ml.subVectors(e,n),i.cross(Ml);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){Ml.subVectors(i,n),Qc.subVectors(r,n),bT.subVectors(e,n);const o=Ml.dot(Ml),l=Ml.dot(Qc),c=Ml.dot(bT),u=Qc.dot(Qc),d=Qc.dot(bT),h=o*u-l*l;if(h===0)return s.set(0,0,0),null;const p=1/h,m=(u*c-l*d)*p,x=(o*d-l*c)*p;return s.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Zc)===null?!1:Zc.x>=0&&Zc.y>=0&&Zc.x+Zc.y<=1}static getInterpolation(e,n,r,i,s,o,l,c){return this.getBarycoord(e,n,r,i,Zc)===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,Zc.x),c.addScaledVector(o,Zc.y),c.addScaledVector(l,Zc.z),c)}static getInterpolatedAttribute(e,n,r,i,s,o){return _T.setScalar(0),ST.setScalar(0),NT.setScalar(0),_T.fromBufferAttribute(e,n),ST.fromBufferAttribute(e,r),NT.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(_T,s.x),o.addScaledVector(ST,s.y),o.addScaledVector(NT,s.z),o}static isFrontFacing(e,n,r,i){return Ml.subVectors(r,n),Qc.subVectors(e,n),Ml.cross(Qc).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 Ml.subVectors(this.c,this.b),Qc.subVectors(this.a,this.b),Ml.cross(Qc).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return og.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return og.getBarycoord(e,this.a,this.b,this.c,n)}getInterpolation(e,n,r,i,s){return og.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return og.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return og.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;kp.subVectors(i,r),Ep.subVectors(s,r),yT.subVectors(e,r);const c=kp.dot(yT),u=Ep.dot(yT);if(c<=0&&u<=0)return n.copy(r);vT.subVectors(e,i);const d=kp.dot(vT),h=Ep.dot(vT);if(d>=0&&h<=d)return n.copy(i);const p=c*h-d*u;if(p<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(kp,o);wT.subVectors(e,s);const m=kp.dot(wT),x=Ep.dot(wT);if(x>=0&&m<=x)return n.copy(s);const y=m*u-c*x;if(y<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Ep,l);const v=d*x-m*h;if(v<=0&&h-d>=0&&m-x>=0)return hB.subVectors(s,i),l=(h-d)/(h-d+(m-x)),n.copy(i).addScaledVector(hB,l);const b=1/(v+y+p);return o=y*b,l=p*b,n.copy(r).addScaledVector(kp,o).addScaledVector(Ep,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const uK={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},Ed={h:0,s:0,l:0},Vw={h:0,s:0,l:0};function MT(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=co){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,cr.colorSpaceToWorking(this,n),this}setRGB(e,n,r,i=cr.workingColorSpace){return this.r=e,this.g=n,this.b=r,cr.colorSpaceToWorking(this,i),this}setHSL(e,n,r,i=cr.workingColorSpace){if(e=zme(e,1),n=Bn(n,0,1),r=Bn(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=MT(o,s,e+1/3),this.g=MT(o,s,e),this.b=MT(o,s,e-1/3)}return cr.colorSpaceToWorking(this,i),this}setStyle(e,n=co){function r(s){s!==void 0&&parseFloat(s)<1&&pn("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:pn("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);pn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=co){const r=uK[e.toLowerCase()];return r!==void 0?this.setHex(r,n):pn("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=Au(e.r),this.g=Au(e.g),this.b=Au(e.b),this}copyLinearToSRGB(e){return this.r=Ag(e.r),this.g=Ag(e.g),this.b=Ag(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=co){return cr.workingToColorSpace(Ga.copy(this),e),Math.round(Bn(Ga.r*255,0,255))*65536+Math.round(Bn(Ga.g*255,0,255))*256+Math.round(Bn(Ga.b*255,0,255))}getHexString(e=co){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=cr.workingColorSpace){cr.workingToColorSpace(Ga.copy(this),n);const r=Ga.r,i=Ga.g,s=Ga.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 h=o-l;switch(u=d<=.5?h/(o+l):h/(2-o-l),o){case r:c=(i-s)/h+(i<s?6:0);break;case i:c=(s-r)/h+2;break;case s:c=(r-i)/h+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=cr.workingColorSpace){return cr.workingToColorSpace(Ga.copy(this),n),e.r=Ga.r,e.g=Ga.g,e.b=Ga.b,e}getStyle(e=co){cr.workingToColorSpace(Ga.copy(this),e);const n=Ga.r,r=Ga.g,i=Ga.b;return e!==co?`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(Ed),this.setHSL(Ed.h+e,Ed.s+n,Ed.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(Ed),e.getHSL(Vw);const r=oT(Ed.h,Vw.h,n),i=oT(Ed.s,Vw.s,n),s=oT(Ed.l,Vw.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 Ga=new Rn;Rn.NAMES=uK;let tpe=0,_x=class extends Tm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:tpe++}),this.uuid=zy(),this.name="",this.type="Material",this.blending=Tg,this.side=Sh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=wP,this.blendDst=_P,this.blendEquation=kf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Rn(0,0,0),this.blendAlpha=0,this.depthFunc=Gg,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Qz,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=bp,this.stencilZFail=bp,this.stencilZPass=bp,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){pn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){pn(`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!==Tg&&(r.blending=this.blending),this.side!==Sh&&(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!==wP&&(r.blendSrc=this.blendSrc),this.blendDst!==_P&&(r.blendDst=this.blendDst),this.blendEquation!==kf&&(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!==Gg&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Qz&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==bp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==bp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==bp&&(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++}},QR=class extends _x{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 Nh,this.combine=BR,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 Oi=new mt,Gw=new Cn;let npe=0,bs=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:npe++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=Zz,this.updateRanges=[],this.gpuType=wu,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++)Gw.fromBufferAttribute(this,n),Gw.applyMatrix3(e),this.setXY(n,Gw.x,Gw.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Oi.fromBufferAttribute(this,n),Oi.applyMatrix3(e),this.setXYZ(n,Oi.x,Oi.y,Oi.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Oi.fromBufferAttribute(this,n),Oi.applyMatrix4(e),this.setXYZ(n,Oi.x,Oi.y,Oi.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Oi.fromBufferAttribute(this,n),Oi.applyNormalMatrix(e),this.setXYZ(n,Oi.x,Oi.y,Oi.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Oi.fromBufferAttribute(this,n),Oi.transformDirection(e),this.setXYZ(n,Oi.x,Oi.y,Oi.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=Db(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Rs(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Db(n,this.array)),n}setX(e,n){return this.normalized&&(n=Rs(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Db(n,this.array)),n}setY(e,n){return this.normalized&&(n=Rs(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=Db(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Rs(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=Db(n,this.array)),n}setW(e,n){return this.normalized&&(n=Rs(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Rs(n,this.array),r=Rs(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=Rs(n,this.array),r=Rs(r,this.array),i=Rs(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=Rs(n,this.array),r=Rs(r,this.array),i=Rs(i,this.array),s=Rs(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!==Zz&&(e.usage=this.usage),e}},dK=class extends bs{constructor(e,n,r){super(new Uint16Array(e),n,r)}},hK=class extends bs{constructor(e,n,r){super(new Uint32Array(e),n,r)}},bo=class extends bs{constructor(e,n,r){super(new Float32Array(e),n,r)}},rpe=0;const Uo=new Gi,kT=new No,Tp=new mt,so=new ch,Ib=new ch,ma=new mt;let ul=class fK extends Tm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:rpe++}),this.uuid=zy(),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(nK(e)?hK:dK)(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 Dn().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 Uo.makeRotationFromQuaternion(e),this.applyMatrix4(Uo),this}rotateX(e){return Uo.makeRotationX(e),this.applyMatrix4(Uo),this}rotateY(e){return Uo.makeRotationY(e),this.applyMatrix4(Uo),this}rotateZ(e){return Uo.makeRotationZ(e),this.applyMatrix4(Uo),this}translate(e,n,r){return Uo.makeTranslation(e,n,r),this.applyMatrix4(Uo),this}scale(e,n,r){return Uo.makeScale(e,n,r),this.applyMatrix4(Uo),this}lookAt(e){return kT.lookAt(e),kT.updateMatrix(),this.applyMatrix4(kT.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Tp).negate(),this.translate(Tp.x,Tp.y,Tp.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 bo(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&&pn("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 ch);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ti("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new mt(-1/0,-1/0,-1/0),new mt(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];so.setFromBufferAttribute(s),this.morphTargetsRelative?(ma.addVectors(this.boundingBox.min,so.min),this.boundingBox.expandByPoint(ma),ma.addVectors(this.boundingBox.max,so.max),this.boundingBox.expandByPoint(ma)):(this.boundingBox.expandByPoint(so.min),this.boundingBox.expandByPoint(so.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ti('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 _M);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Ti("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new mt,1/0);return}if(e){const r=this.boundingSphere.center;if(so.setFromBufferAttribute(e),n)for(let s=0,o=n.length;s<o;s++){const l=n[s];Ib.setFromBufferAttribute(l),this.morphTargetsRelative?(ma.addVectors(so.min,Ib.min),so.expandByPoint(ma),ma.addVectors(so.max,Ib.max),so.expandByPoint(ma)):(so.expandByPoint(Ib.min),so.expandByPoint(Ib.max))}so.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)ma.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(ma));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++)ma.fromBufferAttribute(l,u),c&&(Tp.fromBufferAttribute(e,u),ma.add(Tp)),i=Math.max(i,r.distanceToSquared(ma))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&Ti('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){Ti("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 bs(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let P=0;P<r.count;P++)l[P]=new mt,c[P]=new mt;const u=new mt,d=new mt,h=new mt,p=new Cn,m=new Cn,x=new Cn,y=new mt,v=new mt;function b(P,A,D){u.fromBufferAttribute(r,P),d.fromBufferAttribute(r,A),h.fromBufferAttribute(r,D),p.fromBufferAttribute(s,P),m.fromBufferAttribute(s,A),x.fromBufferAttribute(s,D),d.sub(u),h.sub(u),m.sub(p),x.sub(p);const I=1/(m.x*x.y-x.x*m.y);isFinite(I)&&(y.copy(d).multiplyScalar(x.y).addScaledVector(h,-m.y).multiplyScalar(I),v.copy(h).multiplyScalar(m.x).addScaledVector(d,-x.x).multiplyScalar(I),l[P].add(y),l[A].add(y),l[D].add(y),c[P].add(v),c[A].add(v),c[D].add(v))}let S=this.groups;S.length===0&&(S=[{start:0,count:e.count}]);for(let P=0,A=S.length;P<A;++P){const D=S[P],I=D.start,L=D.count;for(let U=I,j=I+L;U<j;U+=3)b(e.getX(U+0),e.getX(U+1),e.getX(U+2))}const N=new mt,T=new mt,k=new mt,C=new mt;function E(P){k.fromBufferAttribute(i,P),C.copy(k);const A=l[P];N.copy(A),N.sub(k.multiplyScalar(k.dot(A))).normalize(),T.crossVectors(C,A);const I=T.dot(c[P])<0?-1:1;o.setXYZW(P,N.x,N.y,N.z,I)}for(let P=0,A=S.length;P<A;++P){const D=S[P],I=D.start,L=D.count;for(let U=I,j=I+L;U<j;U+=3)E(e.getX(U+0)),E(e.getX(U+1)),E(e.getX(U+2))}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new bs(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let p=0,m=r.count;p<m;p++)r.setXYZ(p,0,0,0);const i=new mt,s=new mt,o=new mt,l=new mt,c=new mt,u=new mt,d=new mt,h=new mt;if(e)for(let p=0,m=e.count;p<m;p+=3){const x=e.getX(p+0),y=e.getX(p+1),v=e.getX(p+2);i.fromBufferAttribute(n,x),s.fromBufferAttribute(n,y),o.fromBufferAttribute(n,v),d.subVectors(o,s),h.subVectors(i,s),d.cross(h),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,v),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(v,u.x,u.y,u.z)}else for(let p=0,m=n.count;p<m;p+=3)i.fromBufferAttribute(n,p+0),s.fromBufferAttribute(n,p+1),o.fromBufferAttribute(n,p+2),d.subVectors(o,s),h.subVectors(i,s),d.cross(h),r.setXYZ(p+0,d.x,d.y,d.z),r.setXYZ(p+1,d.x,d.y,d.z),r.setXYZ(p+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++)ma.fromBufferAttribute(e,n),ma.normalize(),e.setXYZ(n,ma.x,ma.y,ma.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,h=l.normalized,p=new u.constructor(c.length*d);let m=0,x=0;for(let y=0,v=c.length;y<v;y++){l.isInterleavedBufferAttribute?m=c[y]*l.data.stride+l.offset:m=c[y]*d;for(let b=0;b<d;b++)p[x++]=u[m++]}return new bs(p,d,h)}if(this.index===null)return pn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new fK,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,h=u.length;d<h;d++){const p=u[d],m=e(p,r);c.push(m)}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 h=0,p=u.length;h<p;h++){const m=u[h];d.push(m.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=[],h=s[u];for(let p=0,m=h.length;p<m;p++)d.push(h[p].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 h=o[u];this.addGroup(h.start,h.count,h.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 fB=new Gi,df=new YR,qw=new _M,mB=new mt,Ww=new mt,Kw=new mt,Xw=new mt,ET=new mt,Yw=new mt,pB=new mt,Qw=new mt;let dl=class extends No{constructor(e=new ul,n=new QR){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){Yw.set(0,0,0);for(let c=0,u=s.length;c<u;c++){const d=l[c],h=s[c];d!==0&&(ET.fromBufferAttribute(h,e),o?Yw.addScaledVector(ET,d):Yw.addScaledVector(ET.sub(n),d))}n.add(Yw)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),qw.copy(r.boundingSphere),qw.applyMatrix4(s),df.copy(e.ray).recast(e.near),!(qw.containsPoint(df.origin)===!1&&(df.intersectSphere(qw,mB)===null||df.origin.distanceToSquared(mB)>(e.far-e.near)**2))&&(fB.copy(s).invert(),df.copy(e.ray).applyMatrix4(fB),!(r.boundingBox!==null&&df.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,df)))}_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,h=s.attributes.normal,p=s.groups,m=s.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,y=p.length;x<y;x++){const v=p[x],b=o[v.materialIndex],S=Math.max(v.start,m.start),N=Math.min(l.count,Math.min(v.start+v.count,m.start+m.count));for(let T=S,k=N;T<k;T+=3){const C=l.getX(T),E=l.getX(T+1),P=l.getX(T+2);i=Zw(this,b,e,r,u,d,h,C,E,P),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let v=x,b=y;v<b;v+=3){const S=l.getX(v),N=l.getX(v+1),T=l.getX(v+2);i=Zw(this,o,e,r,u,d,h,S,N,T),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,y=p.length;x<y;x++){const v=p[x],b=o[v.materialIndex],S=Math.max(v.start,m.start),N=Math.min(c.count,Math.min(v.start+v.count,m.start+m.count));for(let T=S,k=N;T<k;T+=3){const C=T,E=T+1,P=T+2;i=Zw(this,b,e,r,u,d,h,C,E,P),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),y=Math.min(c.count,m.start+m.count);for(let v=x,b=y;v<b;v+=3){const S=v,N=v+1,T=v+2;i=Zw(this,o,e,r,u,d,h,S,N,T),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}};function ipe(t,e,n,r,i,s,o,l){let c;if(e.side===Bs?c=r.intersectTriangle(o,s,i,!0,l):c=r.intersectTriangle(i,s,o,e.side===Sh,l),c===null)return null;Qw.copy(l),Qw.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(Qw);return u<n.near||u>n.far?null:{distance:u,point:Qw.clone(),object:t}}function Zw(t,e,n,r,i,s,o,l,c,u){t.getVertexPosition(l,Ww),t.getVertexPosition(c,Kw),t.getVertexPosition(u,Xw);const d=ipe(t,e,n,r,Ww,Kw,Xw,pB);if(d){const h=new mt;Fb.getBarycoord(pB,Ww,Kw,Xw,h),i&&(d.uv=Fb.getInterpolatedAttribute(i,l,c,u,h,new Cn)),s&&(d.uv1=Fb.getInterpolatedAttribute(s,l,c,u,h,new Cn)),o&&(d.normal=Fb.getInterpolatedAttribute(o,l,c,u,h,new mt),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const p={a:l,b:c,c:u,normal:new mt,materialIndex:0};Fb.getNormal(Ww,Kw,Xw,p.normal),d.face=p,d.barycoord=h}return d}let ZR=class mK extends ul{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=[],h=[];let p=0,m=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 bo(u,3)),this.setAttribute("normal",new bo(d,3)),this.setAttribute("uv",new bo(h,2));function x(y,v,b,S,N,T,k,C,E,P,A){const D=T/E,I=k/P,L=T/2,U=k/2,j=C/2,V=E+1,K=P+1;let z=0,X=0;const Y=new mt;for(let te=0;te<K;te++){const $=te*I-U;for(let W=0;W<V;W++){const ne=W*D-L;Y[y]=ne*S,Y[v]=$*N,Y[b]=j,u.push(Y.x,Y.y,Y.z),Y[y]=0,Y[v]=0,Y[b]=C>0?1:-1,d.push(Y.x,Y.y,Y.z),h.push(W/E),h.push(1-te/P),z+=1}}for(let te=0;te<P;te++)for(let $=0;$<E;$++){const W=p+$+V*te,ne=p+$+V*(te+1),re=p+($+1)+V*(te+1),ge=p+($+1)+V*te;c.push(W,ne,ge),c.push(ne,re,ge),X+=6}l.addGroup(m,X,A),m+=X,p+=z}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new mK(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function Xg(t){const e={};for(const n in t){e[n]={};for(const r in t[n]){const i=t[n][r];i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)?i.isRenderTargetTexture?(pn("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 us(t){const e={};for(let n=0;n<t.length;n++){const r=Xg(t[n]);for(const i in r)e[i]=r[i]}return e}function ape(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function pK(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:cr.workingColorSpace}const spe={clone:Xg,merge:us};var ope=`void main() {
  11. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  12. }`,lpe=`void main() {
  13. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  14. }`;let Fu=class extends _x{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=ope,this.fragmentShader=lpe,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=Xg(e.uniforms),this.uniformsGroups=ape(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}},gK=class extends No{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Gi,this.projectionMatrix=new Gi,this.projectionMatrixInverse=new Gi,this.coordinateSystem=uc,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 Td=new mt,gB=new Cn,xB=new Cn;let Qo=class extends gK{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=l3*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(S1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return l3*2*Math.atan(Math.tan(S1*.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){Td.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Td.x,Td.y).multiplyScalar(-e/Td.z),Td.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),r.set(Td.x,Td.y).multiplyScalar(-e/Td.z)}getViewSize(e,n){return this.getViewBounds(e,gB,xB),n.subVectors(xB,gB)}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(S1*.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 Ap=-90,Cp=1;let cpe=class extends No{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Qo(Ap,Cp,e,n);i.layers=this.layers,this.add(i);const s=new Qo(Ap,Cp,e,n);s.layers=this.layers,this.add(s);const o=new Qo(Ap,Cp,e,n);o.layers=this.layers,this.add(o);const l=new Qo(Ap,Cp,e,n);l.layers=this.layers,this.add(l);const c=new Qo(Ap,Cp,e,n);c.layers=this.layers,this.add(c);const u=new Qo(Ap,Cp,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===uc)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===Z1)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,h=e.getRenderTarget(),p=e.getActiveCubeFace(),m=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(h,p,m),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},xK=class extends $l{constructor(e=[],n=qg,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}},upe=class extends hm{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 xK(i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
  15. varying vec3 vWorldDirection;
  16. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  17. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  18. }
  19. void main() {
  20. vWorldDirection = transformDirection( position, modelMatrix );
  21. #include <begin_vertex>
  22. #include <project_vertex>
  23. }
  24. `,fragmentShader:`
  25. uniform sampler2D tEquirect;
  26. varying vec3 vWorldDirection;
  27. #include <common>
  28. void main() {
  29. vec3 direction = normalize( vWorldDirection );
  30. vec2 sampleUV = equirectUv( direction );
  31. gl_FragColor = texture2D( tEquirect, sampleUV );
  32. }
  33. `},i=new ZR(5,5,5),s=new Fu({name:"CubemapFromEquirect",uniforms:Xg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Bs,blending:Tu});s.uniforms.tEquirect.value=n;const o=new dl(i,s),l=n.minFilter;return n.minFilter===Rf&&(n.minFilter=rl),new cpe(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)}},xg=class extends No{constructor(){super(),this.isGroup=!0,this.type="Group"}};const dpe={type:"move"};let TT=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new xg,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 xg,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new mt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new mt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new xg,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new mt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new mt),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 v=n.getJointPose(y,r),b=this._getHandJoint(u,y);v!==null&&(b.matrix.fromArray(v.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,b.jointRadius=v.radius),b.visible=v!==null}const d=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],p=d.position.distanceTo(h.position),m=.02,x=.005;u.inputState.pinching&&p>m+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&p<=m-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(dpe)))}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 xg;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},hpe=class extends No{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 Nh,this.environmentIntensity=1,this.environmentRotation=new Nh,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}},fpe=class extends $l{constructor(e=null,n=1,r=1,i,s,o,l,c,u=xo,d=xo,h,p){super(null,o,l,c,u,d,i,s,h,p),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const AT=new mt,mpe=new mt,ppe=new Dn;let zd=class{constructor(e=new mt(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=AT.subVectors(r,n).cross(mpe.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(AT),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||ppe.getNormalMatrix(e),i=this.coplanarPoint(AT).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 hf=new _M,gpe=new Cn(.5,.5),Jw=new mt;let JR=class{constructor(e=new zd,n=new zd,r=new zd,i=new zd,s=new zd,o=new zd){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=uc,r=!1){const i=this.planes,s=e.elements,o=s[0],l=s[1],c=s[2],u=s[3],d=s[4],h=s[5],p=s[6],m=s[7],x=s[8],y=s[9],v=s[10],b=s[11],S=s[12],N=s[13],T=s[14],k=s[15];if(i[0].setComponents(u-o,m-d,b-x,k-S).normalize(),i[1].setComponents(u+o,m+d,b+x,k+S).normalize(),i[2].setComponents(u+l,m+h,b+y,k+N).normalize(),i[3].setComponents(u-l,m-h,b-y,k-N).normalize(),r)i[4].setComponents(c,p,v,T).normalize(),i[5].setComponents(u-c,m-p,b-v,k-T).normalize();else if(i[4].setComponents(u-c,m-p,b-v,k-T).normalize(),n===uc)i[5].setComponents(u+c,m+p,b+v,k+T).normalize();else if(n===Z1)i[5].setComponents(c,p,v,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(),hf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),hf.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(hf)}intersectsSprite(e){hf.center.set(0,0,0);const n=gpe.distanceTo(e.center);return hf.radius=.7071067811865476+n,hf.applyMatrix4(e.matrixWorld),this.intersectsSphere(hf)}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(Jw.x=i.normal.x>0?e.max.x:e.min.x,Jw.y=i.normal.y>0?e.max.y:e.min.y,Jw.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Jw)<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)}},bK=class extends _x{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 mt,tS=new mt,bB=new Gi,Ub=new YR,e_=new _M,CT=new mt,yB=new mt;let xpe=class extends No{constructor(e=new ul,n=new bK){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 bo(r,1))}else pn("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(),e_.copy(r.boundingSphere),e_.applyMatrix4(i),e_.radius+=s,e.ray.intersectsSphere(e_)===!1)return;bB.copy(i).invert(),Ub.copy(e.ray).applyMatrix4(bB);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=this.isLineSegments?2:1,d=r.index,p=r.attributes.position;if(d!==null){const m=Math.max(0,o.start),x=Math.min(d.count,o.start+o.count);for(let y=m,v=x-1;y<v;y+=u){const b=d.getX(y),S=d.getX(y+1),N=t_(this,e,Ub,c,b,S,y);N&&n.push(N)}if(this.isLineLoop){const y=d.getX(x-1),v=d.getX(m),b=t_(this,e,Ub,c,y,v,x-1);b&&n.push(b)}}else{const m=Math.max(0,o.start),x=Math.min(p.count,o.start+o.count);for(let y=m,v=x-1;y<v;y+=u){const b=t_(this,e,Ub,c,y,y+1,y);b&&n.push(b)}if(this.isLineLoop){const y=t_(this,e,Ub,c,x-1,m,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 t_(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,CT,yB)>r)return;CT.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(CT);if(!(u<e.near||u>e.far))return{distance:u,point:yB.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const vB=new mt,wB=new mt;let bpe=class extends xpe{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)vB.fromBufferAttribute(n,i),wB.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+vB.distanceTo(wB);e.setAttribute("lineDistance",new bo(r,1))}else pn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},yK=class extends $l{constructor(e,n,r=um,i,s,o,l=xo,c=xo,u,d=Z0,h=1){if(d!==Z0&&d!==J0)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:n,depth:h};super(p,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 XR(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 vK extends $l{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let eO=class wK extends ul{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,h=e/l,p=n/c,m=[],x=[],y=[],v=[];for(let b=0;b<d;b++){const S=b*p-o;for(let N=0;N<u;N++){const T=N*h-s;x.push(T,-S,0),y.push(0,0,1),v.push(N/l),v.push(1-b/c)}}for(let b=0;b<c;b++)for(let S=0;S<l;S++){const N=S+u*b,T=S+u*(b+1),k=S+1+u*(b+1),C=S+1+u*b;m.push(N,T,C),m.push(T,k,C)}this.setIndex(m),this.setAttribute("position",new bo(x,3)),this.setAttribute("normal",new bo(y,3)),this.setAttribute("uv",new bo(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new wK(e.width,e.height,e.widthSegments,e.heightSegments)}};class _K extends _x{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=eK,this.normalScale=new Cn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Nh,this.combine=BR,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 ype=class extends _x{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Tme,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}},vpe=class extends _x{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 _B={enabled:!1,files:{},add:function(t,e){this.enabled!==!1&&(this.files[t]=e)},get:function(t){if(this.enabled!==!1)return this.files[t]},remove:function(t){delete this.files[t]},clear:function(){this.files={}}};class wpe{constructor(e,n,r){const i=this;let s=!1,o=0,l=0,c;const u=[];this.onStart=void 0,this.onLoad=e,this.onProgress=n,this.onError=r,this._abortController=null,this.itemStart=function(d){l++,s===!1&&i.onStart!==void 0&&i.onStart(d,o,l),s=!0},this.itemEnd=function(d){o++,i.onProgress!==void 0&&i.onProgress(d,o,l),o===l&&(s=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(d){i.onError!==void 0&&i.onError(d)},this.resolveURL=function(d){return c?c(d):d},this.setURLModifier=function(d){return c=d,this},this.addHandler=function(d,h){return u.push(d,h),this},this.removeHandler=function(d){const h=u.indexOf(d);return h!==-1&&u.splice(h,2),this},this.getHandler=function(d){for(let h=0,p=u.length;h<p;h+=2){const m=u[h],x=u[h+1];if(m.global&&(m.lastIndex=0),m.test(d))return x}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const _pe=new wpe;class tO{constructor(e){this.manager=e!==void 0?e:_pe,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,n){const r=this;return new Promise(function(i,s){r.load(e,i,n,s)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}tO.DEFAULT_MATERIAL_NAME="__DEFAULT";const Jc={};class Spe extends Error{constructor(e,n){super(e),this.response=n}}class Npe extends tO{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,n,r,i){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const s=_B.get(`file:${e}`);if(s!==void 0)return this.manager.itemStart(e),setTimeout(()=>{n&&n(s),this.manager.itemEnd(e)},0),s;if(Jc[e]!==void 0){Jc[e].push({onLoad:n,onProgress:r,onError:i});return}Jc[e]=[],Jc[e].push({onLoad:n,onProgress:r,onError:i});const o=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),l=this.mimeType,c=this.responseType;fetch(o).then(u=>{if(u.status===200||u.status===0){if(u.status===0&&pn("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||u.body===void 0||u.body.getReader===void 0)return u;const d=Jc[e],h=u.body.getReader(),p=u.headers.get("X-File-Size")||u.headers.get("Content-Length"),m=p?parseInt(p):0,x=m!==0;let y=0;const v=new ReadableStream({start(b){S();function S(){h.read().then(({done:N,value:T})=>{if(N)b.close();else{y+=T.byteLength;const k=new ProgressEvent("progress",{lengthComputable:x,loaded:y,total:m});for(let C=0,E=d.length;C<E;C++){const P=d[C];P.onProgress&&P.onProgress(k)}b.enqueue(T),S()}},N=>{b.error(N)})}}});return new Response(v)}else throw new Spe(`fetch for "${u.url}" responded with ${u.status}: ${u.statusText}`,u)}).then(u=>{switch(c){case"arraybuffer":return u.arrayBuffer();case"blob":return u.blob();case"document":return u.text().then(d=>new DOMParser().parseFromString(d,l));case"json":return u.json();default:if(l==="")return u.text();{const h=/charset="?([^;"\s]*)"?/i.exec(l),p=h&&h[1]?h[1].toLowerCase():void 0,m=new TextDecoder(p);return u.arrayBuffer().then(x=>m.decode(x))}}}).then(u=>{_B.add(`file:${e}`,u);const d=Jc[e];delete Jc[e];for(let h=0,p=d.length;h<p;h++){const m=d[h];m.onLoad&&m.onLoad(u)}}).catch(u=>{const d=Jc[e];if(d===void 0)throw this.manager.itemError(e),u;delete Jc[e];for(let h=0,p=d.length;h<p;h++){const m=d[h];m.onError&&m.onError(u)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let SK=class extends No{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 jT=new Gi,SB=new mt,NB=new mt;let Mpe=class{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Cn(512,512),this.mapType=yc,this.map=null,this.mapPass=null,this.matrix=new Gi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new JR,this._frameExtents=new Cn(1,1),this._viewportCount=1,this._viewports=[new Bi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;SB.setFromMatrixPosition(e.matrixWorld),n.position.copy(SB),NB.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(NB),n.updateMatrixWorld(),jT.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(jT,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(jT)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.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}},NK=class extends gK{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 kpe extends Mpe{constructor(){super(new NK(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class MB extends SK{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(No.DEFAULT_UP),this.updateMatrix(),this.target=new No,this.shadow=new kpe}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let Epe=class extends SK{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},Tpe=class extends Qo{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},kB=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=Bn(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(Bn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class Ape extends bpe{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 p=0,m=0,x=-l;p<=n;p++,x+=o){c.push(-l,0,x,l,0,x),c.push(x,0,-l,x,0,l);const y=p===s?r:i;y.toArray(u,m),m+=3,y.toArray(u,m),m+=3,y.toArray(u,m),m+=3,y.toArray(u,m),m+=3}const d=new ul;d.setAttribute("position",new bo(c,3)),d.setAttribute("color",new bo(u,3));const h=new bK({vertexColors:!0,toneMapped:!1});super(d,h),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class Cpe extends Tm{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){pn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function EB(t,e,n,r){const i=jpe(r);switch(n){case QW:return t*e;case JW:return t*e/i.components*i.byteLength;case GR:return t*e/i.components*i.byteLength;case qR:return t*e*2/i.components*i.byteLength;case WR:return t*e*2/i.components*i.byteLength;case ZW:return t*e*3/i.components*i.byteLength;case Ol:return t*e*4/i.components*i.byteLength;case KR:return t*e*4/i.components*i.byteLength;case y1:case v1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case w1:case _1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case OP:case FP:return Math.max(t,16)*Math.max(e,8)/4;case RP:case LP:return Math.max(t,8)*Math.max(e,8)/2;case IP:case UP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case zP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case BP:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case HP:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case $P:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case VP:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case GP:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case qP:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case WP:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case KP:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case XP:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case YP:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case QP:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case ZP:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case JP:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case e3:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case t3:case n3:case r3:return Math.ceil(t/4)*Math.ceil(e/4)*16;case i3:case a3:return Math.ceil(t/4)*Math.ceil(e/4)*8;case s3:case o3:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function jpe(t){switch(t){case yc:case WW:return{byteLength:1,components:1};case Y0:case KW:case wx:return{byteLength:2,components:1};case $R:case VR:return{byteLength:2,components:4};case um:case HR:case wu:return{byteLength:4,components:1};case XW:case YW:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:zR}}));typeof window<"u"&&(window.__THREE__?pn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=zR);function MK(){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 Ppe(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,h=u.byteLength,p=t.createBuffer();t.bindBuffer(c,p),t.bufferData(c,u,d),l.onUploadCallback();let m;if(u instanceof Float32Array)m=t.FLOAT;else if(typeof Float16Array<"u"&&u instanceof Float16Array)m=t.HALF_FLOAT;else if(u instanceof Uint16Array)l.isFloat16BufferAttribute?m=t.HALF_FLOAT:m=t.UNSIGNED_SHORT;else if(u instanceof Int16Array)m=t.SHORT;else if(u instanceof Uint32Array)m=t.UNSIGNED_INT;else if(u instanceof Int32Array)m=t.INT;else if(u instanceof Int8Array)m=t.BYTE;else if(u instanceof Uint8Array)m=t.UNSIGNED_BYTE;else if(u instanceof Uint8ClampedArray)m=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+u);return{buffer:p,type:m,bytesPerElement:u.BYTES_PER_ELEMENT,version:l.version,size:h}}function r(l,c,u){const d=c.array,h=c.updateRanges;if(t.bindBuffer(u,l),h.length===0)t.bufferSubData(u,0,d);else{h.sort((m,x)=>m.start-x.start);let p=0;for(let m=1;m<h.length;m++){const x=h[p],y=h[m];y.start<=x.start+x.count+1?x.count=Math.max(x.count,y.start+y.count-x.start):(++p,h[p]=y)}h.length=p+1;for(let m=0,x=h.length;m<x;m++){const y=h[m];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 Dpe=`#ifdef USE_ALPHAHASH
  34. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  35. #endif`,Rpe=`#ifdef USE_ALPHAHASH
  36. const float ALPHA_HASH_SCALE = 0.05;
  37. float hash2D( vec2 value ) {
  38. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  39. }
  40. float hash3D( vec3 value ) {
  41. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  42. }
  43. float getAlphaHashThreshold( vec3 position ) {
  44. float maxDeriv = max(
  45. length( dFdx( position.xyz ) ),
  46. length( dFdy( position.xyz ) )
  47. );
  48. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  49. vec2 pixScales = vec2(
  50. exp2( floor( log2( pixScale ) ) ),
  51. exp2( ceil( log2( pixScale ) ) )
  52. );
  53. vec2 alpha = vec2(
  54. hash3D( floor( pixScales.x * position.xyz ) ),
  55. hash3D( floor( pixScales.y * position.xyz ) )
  56. );
  57. float lerpFactor = fract( log2( pixScale ) );
  58. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  59. float a = min( lerpFactor, 1.0 - lerpFactor );
  60. vec3 cases = vec3(
  61. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  62. ( x - 0.5 * a ) / ( 1.0 - a ),
  63. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  64. );
  65. float threshold = ( x < ( 1.0 - a ) )
  66. ? ( ( x < a ) ? cases.x : cases.y )
  67. : cases.z;
  68. return clamp( threshold , 1.0e-6, 1.0 );
  69. }
  70. #endif`,Ope=`#ifdef USE_ALPHAMAP
  71. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  72. #endif`,Lpe=`#ifdef USE_ALPHAMAP
  73. uniform sampler2D alphaMap;
  74. #endif`,Fpe=`#ifdef USE_ALPHATEST
  75. #ifdef ALPHA_TO_COVERAGE
  76. diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
  77. if ( diffuseColor.a == 0.0 ) discard;
  78. #else
  79. if ( diffuseColor.a < alphaTest ) discard;
  80. #endif
  81. #endif`,Ipe=`#ifdef USE_ALPHATEST
  82. uniform float alphaTest;
  83. #endif`,Upe=`#ifdef USE_AOMAP
  84. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  85. reflectedLight.indirectDiffuse *= ambientOcclusion;
  86. #if defined( USE_CLEARCOAT )
  87. clearcoatSpecularIndirect *= ambientOcclusion;
  88. #endif
  89. #if defined( USE_SHEEN )
  90. sheenSpecularIndirect *= ambientOcclusion;
  91. #endif
  92. #if defined( USE_ENVMAP ) && defined( STANDARD )
  93. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  94. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  95. #endif
  96. #endif`,zpe=`#ifdef USE_AOMAP
  97. uniform sampler2D aoMap;
  98. uniform float aoMapIntensity;
  99. #endif`,Bpe=`#ifdef USE_BATCHING
  100. #if ! defined( GL_ANGLE_multi_draw )
  101. #define gl_DrawID _gl_DrawID
  102. uniform int _gl_DrawID;
  103. #endif
  104. uniform highp sampler2D batchingTexture;
  105. uniform highp usampler2D batchingIdTexture;
  106. mat4 getBatchingMatrix( const in float i ) {
  107. int size = textureSize( batchingTexture, 0 ).x;
  108. int j = int( i ) * 4;
  109. int x = j % size;
  110. int y = j / size;
  111. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  112. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  113. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  114. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  115. return mat4( v1, v2, v3, v4 );
  116. }
  117. float getIndirectIndex( const in int i ) {
  118. int size = textureSize( batchingIdTexture, 0 ).x;
  119. int x = i % size;
  120. int y = i / size;
  121. return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
  122. }
  123. #endif
  124. #ifdef USE_BATCHING_COLOR
  125. uniform sampler2D batchingColorTexture;
  126. vec3 getBatchingColor( const in float i ) {
  127. int size = textureSize( batchingColorTexture, 0 ).x;
  128. int j = int( i );
  129. int x = j % size;
  130. int y = j / size;
  131. return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
  132. }
  133. #endif`,Hpe=`#ifdef USE_BATCHING
  134. mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
  135. #endif`,$pe=`vec3 transformed = vec3( position );
  136. #ifdef USE_ALPHAHASH
  137. vPosition = vec3( position );
  138. #endif`,Vpe=`vec3 objectNormal = vec3( normal );
  139. #ifdef USE_TANGENT
  140. vec3 objectTangent = vec3( tangent.xyz );
  141. #endif`,Gpe=`float G_BlinnPhong_Implicit( ) {
  142. return 0.25;
  143. }
  144. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  145. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  146. }
  147. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  148. vec3 halfDir = normalize( lightDir + viewDir );
  149. float dotNH = saturate( dot( normal, halfDir ) );
  150. float dotVH = saturate( dot( viewDir, halfDir ) );
  151. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  152. float G = G_BlinnPhong_Implicit( );
  153. float D = D_BlinnPhong( shininess, dotNH );
  154. return F * ( G * D );
  155. } // validated`,qpe=`#ifdef USE_IRIDESCENCE
  156. const mat3 XYZ_TO_REC709 = mat3(
  157. 3.2404542, -0.9692660, 0.0556434,
  158. -1.5371385, 1.8760108, -0.2040259,
  159. -0.4985314, 0.0415560, 1.0572252
  160. );
  161. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  162. vec3 sqrtF0 = sqrt( fresnel0 );
  163. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  164. }
  165. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  166. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  167. }
  168. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  169. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  170. }
  171. vec3 evalSensitivity( float OPD, vec3 shift ) {
  172. float phase = 2.0 * PI * OPD * 1.0e-9;
  173. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  174. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  175. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  176. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  177. xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
  178. xyz /= 1.0685e-7;
  179. vec3 rgb = XYZ_TO_REC709 * xyz;
  180. return rgb;
  181. }
  182. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  183. vec3 I;
  184. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  185. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  186. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  187. if ( cosTheta2Sq < 0.0 ) {
  188. return vec3( 1.0 );
  189. }
  190. float cosTheta2 = sqrt( cosTheta2Sq );
  191. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  192. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  193. float T121 = 1.0 - R12;
  194. float phi12 = 0.0;
  195. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  196. float phi21 = PI - phi12;
  197. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  198. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  199. vec3 phi23 = vec3( 0.0 );
  200. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  201. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  202. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  203. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  204. vec3 phi = vec3( phi21 ) + phi23;
  205. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  206. vec3 r123 = sqrt( R123 );
  207. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  208. vec3 C0 = R12 + Rs;
  209. I = C0;
  210. vec3 Cm = Rs - T121;
  211. for ( int m = 1; m <= 2; ++ m ) {
  212. Cm *= r123;
  213. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  214. I += Cm * Sm;
  215. }
  216. return max( I, vec3( 0.0 ) );
  217. }
  218. #endif`,Wpe=`#ifdef USE_BUMPMAP
  219. uniform sampler2D bumpMap;
  220. uniform float bumpScale;
  221. vec2 dHdxy_fwd() {
  222. vec2 dSTdx = dFdx( vBumpMapUv );
  223. vec2 dSTdy = dFdy( vBumpMapUv );
  224. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  225. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  226. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  227. return vec2( dBx, dBy );
  228. }
  229. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  230. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  231. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  232. vec3 vN = surf_norm;
  233. vec3 R1 = cross( vSigmaY, vN );
  234. vec3 R2 = cross( vN, vSigmaX );
  235. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  236. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  237. return normalize( abs( fDet ) * surf_norm - vGrad );
  238. }
  239. #endif`,Kpe=`#if NUM_CLIPPING_PLANES > 0
  240. vec4 plane;
  241. #ifdef ALPHA_TO_COVERAGE
  242. float distanceToPlane, distanceGradient;
  243. float clipOpacity = 1.0;
  244. #pragma unroll_loop_start
  245. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  246. plane = clippingPlanes[ i ];
  247. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  248. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  249. clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  250. if ( clipOpacity == 0.0 ) discard;
  251. }
  252. #pragma unroll_loop_end
  253. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  254. float unionClipOpacity = 1.0;
  255. #pragma unroll_loop_start
  256. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  257. plane = clippingPlanes[ i ];
  258. distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
  259. distanceGradient = fwidth( distanceToPlane ) / 2.0;
  260. unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
  261. }
  262. #pragma unroll_loop_end
  263. clipOpacity *= 1.0 - unionClipOpacity;
  264. #endif
  265. diffuseColor.a *= clipOpacity;
  266. if ( diffuseColor.a == 0.0 ) discard;
  267. #else
  268. #pragma unroll_loop_start
  269. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  270. plane = clippingPlanes[ i ];
  271. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  272. }
  273. #pragma unroll_loop_end
  274. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  275. bool clipped = true;
  276. #pragma unroll_loop_start
  277. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  278. plane = clippingPlanes[ i ];
  279. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  280. }
  281. #pragma unroll_loop_end
  282. if ( clipped ) discard;
  283. #endif
  284. #endif
  285. #endif`,Xpe=`#if NUM_CLIPPING_PLANES > 0
  286. varying vec3 vClipPosition;
  287. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  288. #endif`,Ype=`#if NUM_CLIPPING_PLANES > 0
  289. varying vec3 vClipPosition;
  290. #endif`,Qpe=`#if NUM_CLIPPING_PLANES > 0
  291. vClipPosition = - mvPosition.xyz;
  292. #endif`,Zpe=`#if defined( USE_COLOR_ALPHA )
  293. diffuseColor *= vColor;
  294. #elif defined( USE_COLOR )
  295. diffuseColor.rgb *= vColor;
  296. #endif`,Jpe=`#if defined( USE_COLOR_ALPHA )
  297. varying vec4 vColor;
  298. #elif defined( USE_COLOR )
  299. varying vec3 vColor;
  300. #endif`,ege=`#if defined( USE_COLOR_ALPHA )
  301. varying vec4 vColor;
  302. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  303. varying vec3 vColor;
  304. #endif`,tge=`#if defined( USE_COLOR_ALPHA )
  305. vColor = vec4( 1.0 );
  306. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
  307. vColor = vec3( 1.0 );
  308. #endif
  309. #ifdef USE_COLOR
  310. vColor *= color;
  311. #endif
  312. #ifdef USE_INSTANCING_COLOR
  313. vColor.xyz *= instanceColor.xyz;
  314. #endif
  315. #ifdef USE_BATCHING_COLOR
  316. vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
  317. vColor.xyz *= batchingColor.xyz;
  318. #endif`,nge=`#define PI 3.141592653589793
  319. #define PI2 6.283185307179586
  320. #define PI_HALF 1.5707963267948966
  321. #define RECIPROCAL_PI 0.3183098861837907
  322. #define RECIPROCAL_PI2 0.15915494309189535
  323. #define EPSILON 1e-6
  324. #ifndef saturate
  325. #define saturate( a ) clamp( a, 0.0, 1.0 )
  326. #endif
  327. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  328. float pow2( const in float x ) { return x*x; }
  329. vec3 pow2( const in vec3 x ) { return x*x; }
  330. float pow3( const in float x ) { return x*x*x; }
  331. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  332. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  333. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  334. highp float rand( const in vec2 uv ) {
  335. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  336. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  337. return fract( sin( sn ) * c );
  338. }
  339. #ifdef HIGH_PRECISION
  340. float precisionSafeLength( vec3 v ) { return length( v ); }
  341. #else
  342. float precisionSafeLength( vec3 v ) {
  343. float maxComponent = max3( abs( v ) );
  344. return length( v / maxComponent ) * maxComponent;
  345. }
  346. #endif
  347. struct IncidentLight {
  348. vec3 color;
  349. vec3 direction;
  350. bool visible;
  351. };
  352. struct ReflectedLight {
  353. vec3 directDiffuse;
  354. vec3 directSpecular;
  355. vec3 indirectDiffuse;
  356. vec3 indirectSpecular;
  357. };
  358. #ifdef USE_ALPHAHASH
  359. varying vec3 vPosition;
  360. #endif
  361. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  362. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  363. }
  364. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  365. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  366. }
  367. bool isPerspectiveMatrix( mat4 m ) {
  368. return m[ 2 ][ 3 ] == - 1.0;
  369. }
  370. vec2 equirectUv( in vec3 dir ) {
  371. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  372. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  373. return vec2( u, v );
  374. }
  375. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  376. return RECIPROCAL_PI * diffuseColor;
  377. }
  378. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  379. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  380. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  381. }
  382. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  383. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  384. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  385. } // validated`,rge=`#ifdef ENVMAP_TYPE_CUBE_UV
  386. #define cubeUV_minMipLevel 4.0
  387. #define cubeUV_minTileSize 16.0
  388. float getFace( vec3 direction ) {
  389. vec3 absDirection = abs( direction );
  390. float face = - 1.0;
  391. if ( absDirection.x > absDirection.z ) {
  392. if ( absDirection.x > absDirection.y )
  393. face = direction.x > 0.0 ? 0.0 : 3.0;
  394. else
  395. face = direction.y > 0.0 ? 1.0 : 4.0;
  396. } else {
  397. if ( absDirection.z > absDirection.y )
  398. face = direction.z > 0.0 ? 2.0 : 5.0;
  399. else
  400. face = direction.y > 0.0 ? 1.0 : 4.0;
  401. }
  402. return face;
  403. }
  404. vec2 getUV( vec3 direction, float face ) {
  405. vec2 uv;
  406. if ( face == 0.0 ) {
  407. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  408. } else if ( face == 1.0 ) {
  409. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  410. } else if ( face == 2.0 ) {
  411. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  412. } else if ( face == 3.0 ) {
  413. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  414. } else if ( face == 4.0 ) {
  415. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  416. } else {
  417. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  418. }
  419. return 0.5 * ( uv + 1.0 );
  420. }
  421. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  422. float face = getFace( direction );
  423. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  424. mipInt = max( mipInt, cubeUV_minMipLevel );
  425. float faceSize = exp2( mipInt );
  426. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  427. if ( face > 2.0 ) {
  428. uv.y += faceSize;
  429. face -= 3.0;
  430. }
  431. uv.x += face * faceSize;
  432. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  433. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  434. uv.x *= CUBEUV_TEXEL_WIDTH;
  435. uv.y *= CUBEUV_TEXEL_HEIGHT;
  436. #ifdef texture2DGradEXT
  437. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  438. #else
  439. return texture2D( envMap, uv ).rgb;
  440. #endif
  441. }
  442. #define cubeUV_r0 1.0
  443. #define cubeUV_m0 - 2.0
  444. #define cubeUV_r1 0.8
  445. #define cubeUV_m1 - 1.0
  446. #define cubeUV_r4 0.4
  447. #define cubeUV_m4 2.0
  448. #define cubeUV_r5 0.305
  449. #define cubeUV_m5 3.0
  450. #define cubeUV_r6 0.21
  451. #define cubeUV_m6 4.0
  452. float roughnessToMip( float roughness ) {
  453. float mip = 0.0;
  454. if ( roughness >= cubeUV_r1 ) {
  455. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  456. } else if ( roughness >= cubeUV_r4 ) {
  457. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  458. } else if ( roughness >= cubeUV_r5 ) {
  459. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  460. } else if ( roughness >= cubeUV_r6 ) {
  461. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  462. } else {
  463. mip = - 2.0 * log2( 1.16 * roughness ); }
  464. return mip;
  465. }
  466. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  467. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  468. float mipF = fract( mip );
  469. float mipInt = floor( mip );
  470. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  471. if ( mipF == 0.0 ) {
  472. return vec4( color0, 1.0 );
  473. } else {
  474. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  475. return vec4( mix( color0, color1, mipF ), 1.0 );
  476. }
  477. }
  478. #endif`,ige=`vec3 transformedNormal = objectNormal;
  479. #ifdef USE_TANGENT
  480. vec3 transformedTangent = objectTangent;
  481. #endif
  482. #ifdef USE_BATCHING
  483. mat3 bm = mat3( batchingMatrix );
  484. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  485. transformedNormal = bm * transformedNormal;
  486. #ifdef USE_TANGENT
  487. transformedTangent = bm * transformedTangent;
  488. #endif
  489. #endif
  490. #ifdef USE_INSTANCING
  491. mat3 im = mat3( instanceMatrix );
  492. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  493. transformedNormal = im * transformedNormal;
  494. #ifdef USE_TANGENT
  495. transformedTangent = im * transformedTangent;
  496. #endif
  497. #endif
  498. transformedNormal = normalMatrix * transformedNormal;
  499. #ifdef FLIP_SIDED
  500. transformedNormal = - transformedNormal;
  501. #endif
  502. #ifdef USE_TANGENT
  503. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  504. #ifdef FLIP_SIDED
  505. transformedTangent = - transformedTangent;
  506. #endif
  507. #endif`,age=`#ifdef USE_DISPLACEMENTMAP
  508. uniform sampler2D displacementMap;
  509. uniform float displacementScale;
  510. uniform float displacementBias;
  511. #endif`,sge=`#ifdef USE_DISPLACEMENTMAP
  512. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  513. #endif`,oge=`#ifdef USE_EMISSIVEMAP
  514. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  515. #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
  516. emissiveColor = sRGBTransferEOTF( emissiveColor );
  517. #endif
  518. totalEmissiveRadiance *= emissiveColor.rgb;
  519. #endif`,lge=`#ifdef USE_EMISSIVEMAP
  520. uniform sampler2D emissiveMap;
  521. #endif`,cge="gl_FragColor = linearToOutputTexel( gl_FragColor );",uge=`vec4 LinearTransferOETF( in vec4 value ) {
  522. return value;
  523. }
  524. vec4 sRGBTransferEOTF( in vec4 value ) {
  525. return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
  526. }
  527. vec4 sRGBTransferOETF( in vec4 value ) {
  528. return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
  529. }`,dge=`#ifdef USE_ENVMAP
  530. #ifdef ENV_WORLDPOS
  531. vec3 cameraToFrag;
  532. if ( isOrthographic ) {
  533. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  534. } else {
  535. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  536. }
  537. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  538. #ifdef ENVMAP_MODE_REFLECTION
  539. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  540. #else
  541. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  542. #endif
  543. #else
  544. vec3 reflectVec = vReflect;
  545. #endif
  546. #ifdef ENVMAP_TYPE_CUBE
  547. vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  548. #else
  549. vec4 envColor = vec4( 0.0 );
  550. #endif
  551. #ifdef ENVMAP_BLENDING_MULTIPLY
  552. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  553. #elif defined( ENVMAP_BLENDING_MIX )
  554. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  555. #elif defined( ENVMAP_BLENDING_ADD )
  556. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  557. #endif
  558. #endif`,hge=`#ifdef USE_ENVMAP
  559. uniform float envMapIntensity;
  560. uniform float flipEnvMap;
  561. uniform mat3 envMapRotation;
  562. #ifdef ENVMAP_TYPE_CUBE
  563. uniform samplerCube envMap;
  564. #else
  565. uniform sampler2D envMap;
  566. #endif
  567. #endif`,fge=`#ifdef USE_ENVMAP
  568. uniform float reflectivity;
  569. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  570. #define ENV_WORLDPOS
  571. #endif
  572. #ifdef ENV_WORLDPOS
  573. varying vec3 vWorldPosition;
  574. uniform float refractionRatio;
  575. #else
  576. varying vec3 vReflect;
  577. #endif
  578. #endif`,mge=`#ifdef USE_ENVMAP
  579. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  580. #define ENV_WORLDPOS
  581. #endif
  582. #ifdef ENV_WORLDPOS
  583. varying vec3 vWorldPosition;
  584. #else
  585. varying vec3 vReflect;
  586. uniform float refractionRatio;
  587. #endif
  588. #endif`,pge=`#ifdef USE_ENVMAP
  589. #ifdef ENV_WORLDPOS
  590. vWorldPosition = worldPosition.xyz;
  591. #else
  592. vec3 cameraToVertex;
  593. if ( isOrthographic ) {
  594. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  595. } else {
  596. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  597. }
  598. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  599. #ifdef ENVMAP_MODE_REFLECTION
  600. vReflect = reflect( cameraToVertex, worldNormal );
  601. #else
  602. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  603. #endif
  604. #endif
  605. #endif`,gge=`#ifdef USE_FOG
  606. vFogDepth = - mvPosition.z;
  607. #endif`,xge=`#ifdef USE_FOG
  608. varying float vFogDepth;
  609. #endif`,bge=`#ifdef USE_FOG
  610. #ifdef FOG_EXP2
  611. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  612. #else
  613. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  614. #endif
  615. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  616. #endif`,yge=`#ifdef USE_FOG
  617. uniform vec3 fogColor;
  618. varying float vFogDepth;
  619. #ifdef FOG_EXP2
  620. uniform float fogDensity;
  621. #else
  622. uniform float fogNear;
  623. uniform float fogFar;
  624. #endif
  625. #endif`,vge=`#ifdef USE_GRADIENTMAP
  626. uniform sampler2D gradientMap;
  627. #endif
  628. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  629. float dotNL = dot( normal, lightDirection );
  630. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  631. #ifdef USE_GRADIENTMAP
  632. return vec3( texture2D( gradientMap, coord ).r );
  633. #else
  634. vec2 fw = fwidth( coord ) * 0.5;
  635. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  636. #endif
  637. }`,wge=`#ifdef USE_LIGHTMAP
  638. uniform sampler2D lightMap;
  639. uniform float lightMapIntensity;
  640. #endif`,_ge=`LambertMaterial material;
  641. material.diffuseColor = diffuseColor.rgb;
  642. material.specularStrength = specularStrength;`,Sge=`varying vec3 vViewPosition;
  643. struct LambertMaterial {
  644. vec3 diffuseColor;
  645. float specularStrength;
  646. };
  647. void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  648. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  649. vec3 irradiance = dotNL * directLight.color;
  650. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  651. }
  652. void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  653. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  654. }
  655. #define RE_Direct RE_Direct_Lambert
  656. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Nge=`uniform bool receiveShadow;
  657. uniform vec3 ambientLightColor;
  658. #if defined( USE_LIGHT_PROBES )
  659. uniform vec3 lightProbe[ 9 ];
  660. #endif
  661. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  662. float x = normal.x, y = normal.y, z = normal.z;
  663. vec3 result = shCoefficients[ 0 ] * 0.886227;
  664. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  665. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  666. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  667. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  668. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  669. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  670. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  671. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  672. return result;
  673. }
  674. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  675. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  676. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  677. return irradiance;
  678. }
  679. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  680. vec3 irradiance = ambientLightColor;
  681. return irradiance;
  682. }
  683. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  684. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  685. if ( cutoffDistance > 0.0 ) {
  686. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  687. }
  688. return distanceFalloff;
  689. }
  690. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  691. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  692. }
  693. #if NUM_DIR_LIGHTS > 0
  694. struct DirectionalLight {
  695. vec3 direction;
  696. vec3 color;
  697. };
  698. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  699. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  700. light.color = directionalLight.color;
  701. light.direction = directionalLight.direction;
  702. light.visible = true;
  703. }
  704. #endif
  705. #if NUM_POINT_LIGHTS > 0
  706. struct PointLight {
  707. vec3 position;
  708. vec3 color;
  709. float distance;
  710. float decay;
  711. };
  712. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  713. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  714. vec3 lVector = pointLight.position - geometryPosition;
  715. light.direction = normalize( lVector );
  716. float lightDistance = length( lVector );
  717. light.color = pointLight.color;
  718. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  719. light.visible = ( light.color != vec3( 0.0 ) );
  720. }
  721. #endif
  722. #if NUM_SPOT_LIGHTS > 0
  723. struct SpotLight {
  724. vec3 position;
  725. vec3 direction;
  726. vec3 color;
  727. float distance;
  728. float decay;
  729. float coneCos;
  730. float penumbraCos;
  731. };
  732. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  733. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  734. vec3 lVector = spotLight.position - geometryPosition;
  735. light.direction = normalize( lVector );
  736. float angleCos = dot( light.direction, spotLight.direction );
  737. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  738. if ( spotAttenuation > 0.0 ) {
  739. float lightDistance = length( lVector );
  740. light.color = spotLight.color * spotAttenuation;
  741. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  742. light.visible = ( light.color != vec3( 0.0 ) );
  743. } else {
  744. light.color = vec3( 0.0 );
  745. light.visible = false;
  746. }
  747. }
  748. #endif
  749. #if NUM_RECT_AREA_LIGHTS > 0
  750. struct RectAreaLight {
  751. vec3 color;
  752. vec3 position;
  753. vec3 halfWidth;
  754. vec3 halfHeight;
  755. };
  756. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  757. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  758. #endif
  759. #if NUM_HEMI_LIGHTS > 0
  760. struct HemisphereLight {
  761. vec3 direction;
  762. vec3 skyColor;
  763. vec3 groundColor;
  764. };
  765. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  766. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  767. float dotNL = dot( normal, hemiLight.direction );
  768. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  769. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  770. return irradiance;
  771. }
  772. #endif`,Mge=`#ifdef USE_ENVMAP
  773. vec3 getIBLIrradiance( const in vec3 normal ) {
  774. #ifdef ENVMAP_TYPE_CUBE_UV
  775. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  776. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
  777. return PI * envMapColor.rgb * envMapIntensity;
  778. #else
  779. return vec3( 0.0 );
  780. #endif
  781. }
  782. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  783. #ifdef ENVMAP_TYPE_CUBE_UV
  784. vec3 reflectVec = reflect( - viewDir, normal );
  785. reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
  786. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  787. vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
  788. return envMapColor.rgb * envMapIntensity;
  789. #else
  790. return vec3( 0.0 );
  791. #endif
  792. }
  793. #ifdef USE_ANISOTROPY
  794. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  795. #ifdef ENVMAP_TYPE_CUBE_UV
  796. vec3 bentNormal = cross( bitangent, viewDir );
  797. bentNormal = normalize( cross( bentNormal, bitangent ) );
  798. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  799. return getIBLRadiance( viewDir, bentNormal, roughness );
  800. #else
  801. return vec3( 0.0 );
  802. #endif
  803. }
  804. #endif
  805. #endif`,kge=`ToonMaterial material;
  806. material.diffuseColor = diffuseColor.rgb;`,Ege=`varying vec3 vViewPosition;
  807. struct ToonMaterial {
  808. vec3 diffuseColor;
  809. };
  810. void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  811. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  812. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  813. }
  814. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  815. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  816. }
  817. #define RE_Direct RE_Direct_Toon
  818. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Tge=`BlinnPhongMaterial material;
  819. material.diffuseColor = diffuseColor.rgb;
  820. material.specularColor = specular;
  821. material.specularShininess = shininess;
  822. material.specularStrength = specularStrength;`,Age=`varying vec3 vViewPosition;
  823. struct BlinnPhongMaterial {
  824. vec3 diffuseColor;
  825. vec3 specularColor;
  826. float specularShininess;
  827. float specularStrength;
  828. };
  829. void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  830. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  831. vec3 irradiance = dotNL * directLight.color;
  832. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  833. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  834. }
  835. void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  836. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  837. }
  838. #define RE_Direct RE_Direct_BlinnPhong
  839. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Cge=`PhysicalMaterial material;
  840. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  841. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  842. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  843. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  844. material.roughness = min( material.roughness, 1.0 );
  845. #ifdef IOR
  846. material.ior = ior;
  847. #ifdef USE_SPECULAR
  848. float specularIntensityFactor = specularIntensity;
  849. vec3 specularColorFactor = specularColor;
  850. #ifdef USE_SPECULAR_COLORMAP
  851. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  852. #endif
  853. #ifdef USE_SPECULAR_INTENSITYMAP
  854. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  855. #endif
  856. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  857. #else
  858. float specularIntensityFactor = 1.0;
  859. vec3 specularColorFactor = vec3( 1.0 );
  860. material.specularF90 = 1.0;
  861. #endif
  862. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  863. #else
  864. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  865. material.specularF90 = 1.0;
  866. #endif
  867. #ifdef USE_CLEARCOAT
  868. material.clearcoat = clearcoat;
  869. material.clearcoatRoughness = clearcoatRoughness;
  870. material.clearcoatF0 = vec3( 0.04 );
  871. material.clearcoatF90 = 1.0;
  872. #ifdef USE_CLEARCOATMAP
  873. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  874. #endif
  875. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  876. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  877. #endif
  878. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  879. material.clearcoatRoughness += geometryRoughness;
  880. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  881. #endif
  882. #ifdef USE_DISPERSION
  883. material.dispersion = dispersion;
  884. #endif
  885. #ifdef USE_IRIDESCENCE
  886. material.iridescence = iridescence;
  887. material.iridescenceIOR = iridescenceIOR;
  888. #ifdef USE_IRIDESCENCEMAP
  889. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  890. #endif
  891. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  892. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  893. #else
  894. material.iridescenceThickness = iridescenceThicknessMaximum;
  895. #endif
  896. #endif
  897. #ifdef USE_SHEEN
  898. material.sheenColor = sheenColor;
  899. #ifdef USE_SHEEN_COLORMAP
  900. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  901. #endif
  902. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  903. #ifdef USE_SHEEN_ROUGHNESSMAP
  904. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  905. #endif
  906. #endif
  907. #ifdef USE_ANISOTROPY
  908. #ifdef USE_ANISOTROPYMAP
  909. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  910. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  911. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  912. #else
  913. vec2 anisotropyV = anisotropyVector;
  914. #endif
  915. material.anisotropy = length( anisotropyV );
  916. if( material.anisotropy == 0.0 ) {
  917. anisotropyV = vec2( 1.0, 0.0 );
  918. } else {
  919. anisotropyV /= material.anisotropy;
  920. material.anisotropy = saturate( material.anisotropy );
  921. }
  922. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  923. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  924. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  925. #endif`,jge=`uniform sampler2D dfgLUT;
  926. struct PhysicalMaterial {
  927. vec3 diffuseColor;
  928. float roughness;
  929. vec3 specularColor;
  930. float specularF90;
  931. float dispersion;
  932. #ifdef USE_CLEARCOAT
  933. float clearcoat;
  934. float clearcoatRoughness;
  935. vec3 clearcoatF0;
  936. float clearcoatF90;
  937. #endif
  938. #ifdef USE_IRIDESCENCE
  939. float iridescence;
  940. float iridescenceIOR;
  941. float iridescenceThickness;
  942. vec3 iridescenceFresnel;
  943. vec3 iridescenceF0;
  944. #endif
  945. #ifdef USE_SHEEN
  946. vec3 sheenColor;
  947. float sheenRoughness;
  948. #endif
  949. #ifdef IOR
  950. float ior;
  951. #endif
  952. #ifdef USE_TRANSMISSION
  953. float transmission;
  954. float transmissionAlpha;
  955. float thickness;
  956. float attenuationDistance;
  957. vec3 attenuationColor;
  958. #endif
  959. #ifdef USE_ANISOTROPY
  960. float anisotropy;
  961. float alphaT;
  962. vec3 anisotropyT;
  963. vec3 anisotropyB;
  964. #endif
  965. };
  966. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  967. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  968. vec3 sheenSpecularDirect = vec3( 0.0 );
  969. vec3 sheenSpecularIndirect = vec3(0.0 );
  970. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  971. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  972. float x2 = x * x;
  973. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  974. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  975. }
  976. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  977. float a2 = pow2( alpha );
  978. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  979. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  980. return 0.5 / max( gv + gl, EPSILON );
  981. }
  982. float D_GGX( const in float alpha, const in float dotNH ) {
  983. float a2 = pow2( alpha );
  984. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  985. return RECIPROCAL_PI * a2 / pow2( denom );
  986. }
  987. #ifdef USE_ANISOTROPY
  988. float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
  989. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  990. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  991. float v = 0.5 / ( gv + gl );
  992. return saturate(v);
  993. }
  994. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  995. float a2 = alphaT * alphaB;
  996. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  997. highp float v2 = dot( v, v );
  998. float w2 = a2 / v2;
  999. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  1000. }
  1001. #endif
  1002. #ifdef USE_CLEARCOAT
  1003. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  1004. vec3 f0 = material.clearcoatF0;
  1005. float f90 = material.clearcoatF90;
  1006. float roughness = material.clearcoatRoughness;
  1007. float alpha = pow2( roughness );
  1008. vec3 halfDir = normalize( lightDir + viewDir );
  1009. float dotNL = saturate( dot( normal, lightDir ) );
  1010. float dotNV = saturate( dot( normal, viewDir ) );
  1011. float dotNH = saturate( dot( normal, halfDir ) );
  1012. float dotVH = saturate( dot( viewDir, halfDir ) );
  1013. vec3 F = F_Schlick( f0, f90, dotVH );
  1014. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1015. float D = D_GGX( alpha, dotNH );
  1016. return F * ( V * D );
  1017. }
  1018. #endif
  1019. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1020. vec3 f0 = material.specularColor;
  1021. float f90 = material.specularF90;
  1022. float roughness = material.roughness;
  1023. float alpha = pow2( roughness );
  1024. vec3 halfDir = normalize( lightDir + viewDir );
  1025. float dotNL = saturate( dot( normal, lightDir ) );
  1026. float dotNV = saturate( dot( normal, viewDir ) );
  1027. float dotNH = saturate( dot( normal, halfDir ) );
  1028. float dotVH = saturate( dot( viewDir, halfDir ) );
  1029. vec3 F = F_Schlick( f0, f90, dotVH );
  1030. #ifdef USE_IRIDESCENCE
  1031. F = mix( F, material.iridescenceFresnel, material.iridescence );
  1032. #endif
  1033. #ifdef USE_ANISOTROPY
  1034. float dotTL = dot( material.anisotropyT, lightDir );
  1035. float dotTV = dot( material.anisotropyT, viewDir );
  1036. float dotTH = dot( material.anisotropyT, halfDir );
  1037. float dotBL = dot( material.anisotropyB, lightDir );
  1038. float dotBV = dot( material.anisotropyB, viewDir );
  1039. float dotBH = dot( material.anisotropyB, halfDir );
  1040. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  1041. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  1042. #else
  1043. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  1044. float D = D_GGX( alpha, dotNH );
  1045. #endif
  1046. return F * ( V * D );
  1047. }
  1048. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  1049. const float LUT_SIZE = 64.0;
  1050. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  1051. const float LUT_BIAS = 0.5 / LUT_SIZE;
  1052. float dotNV = saturate( dot( N, V ) );
  1053. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  1054. uv = uv * LUT_SCALE + LUT_BIAS;
  1055. return uv;
  1056. }
  1057. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  1058. float l = length( f );
  1059. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  1060. }
  1061. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  1062. float x = dot( v1, v2 );
  1063. float y = abs( x );
  1064. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  1065. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  1066. float v = a / b;
  1067. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  1068. return cross( v1, v2 ) * theta_sintheta;
  1069. }
  1070. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  1071. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  1072. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  1073. vec3 lightNormal = cross( v1, v2 );
  1074. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  1075. vec3 T1, T2;
  1076. T1 = normalize( V - N * dot( V, N ) );
  1077. T2 = - cross( N, T1 );
  1078. mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
  1079. vec3 coords[ 4 ];
  1080. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  1081. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  1082. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  1083. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  1084. coords[ 0 ] = normalize( coords[ 0 ] );
  1085. coords[ 1 ] = normalize( coords[ 1 ] );
  1086. coords[ 2 ] = normalize( coords[ 2 ] );
  1087. coords[ 3 ] = normalize( coords[ 3 ] );
  1088. vec3 vectorFormFactor = vec3( 0.0 );
  1089. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  1090. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  1091. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  1092. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  1093. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  1094. return vec3( result );
  1095. }
  1096. #if defined( USE_SHEEN )
  1097. float D_Charlie( float roughness, float dotNH ) {
  1098. float alpha = pow2( roughness );
  1099. float invAlpha = 1.0 / alpha;
  1100. float cos2h = dotNH * dotNH;
  1101. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  1102. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  1103. }
  1104. float V_Neubelt( float dotNV, float dotNL ) {
  1105. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  1106. }
  1107. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  1108. vec3 halfDir = normalize( lightDir + viewDir );
  1109. float dotNL = saturate( dot( normal, lightDir ) );
  1110. float dotNV = saturate( dot( normal, viewDir ) );
  1111. float dotNH = saturate( dot( normal, halfDir ) );
  1112. float D = D_Charlie( sheenRoughness, dotNH );
  1113. float V = V_Neubelt( dotNV, dotNL );
  1114. return sheenColor * ( D * V );
  1115. }
  1116. #endif
  1117. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1118. float dotNV = saturate( dot( normal, viewDir ) );
  1119. float r2 = roughness * roughness;
  1120. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  1121. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  1122. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  1123. return saturate( DG * RECIPROCAL_PI );
  1124. }
  1125. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  1126. float dotNV = saturate( dot( normal, viewDir ) );
  1127. vec2 uv = vec2( roughness, dotNV );
  1128. return texture2D( dfgLUT, uv ).rg;
  1129. }
  1130. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  1131. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1132. return specularColor * fab.x + specularF90 * fab.y;
  1133. }
  1134. #ifdef USE_IRIDESCENCE
  1135. void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  1136. #else
  1137. void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  1138. #endif
  1139. vec2 fab = DFGApprox( normal, viewDir, roughness );
  1140. #ifdef USE_IRIDESCENCE
  1141. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  1142. #else
  1143. vec3 Fr = specularColor;
  1144. #endif
  1145. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  1146. float Ess = fab.x + fab.y;
  1147. float Ems = 1.0 - Ess;
  1148. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  1149. singleScatter += FssEss;
  1150. multiScatter += Fms * Ems;
  1151. }
  1152. vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  1153. vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
  1154. float dotNL = saturate( dot( normal, lightDir ) );
  1155. float dotNV = saturate( dot( normal, viewDir ) );
  1156. vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
  1157. vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
  1158. vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
  1159. vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
  1160. float Ess_V = dfgV.x + dfgV.y;
  1161. float Ess_L = dfgL.x + dfgL.y;
  1162. float Ems_V = 1.0 - Ess_V;
  1163. float Ems_L = 1.0 - Ess_L;
  1164. vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
  1165. vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
  1166. float compensationFactor = Ems_V * Ems_L;
  1167. vec3 multiScatter = Fms * compensationFactor;
  1168. return singleScatter + multiScatter;
  1169. }
  1170. #if NUM_RECT_AREA_LIGHTS > 0
  1171. void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1172. vec3 normal = geometryNormal;
  1173. vec3 viewDir = geometryViewDir;
  1174. vec3 position = geometryPosition;
  1175. vec3 lightPos = rectAreaLight.position;
  1176. vec3 halfWidth = rectAreaLight.halfWidth;
  1177. vec3 halfHeight = rectAreaLight.halfHeight;
  1178. vec3 lightColor = rectAreaLight.color;
  1179. float roughness = material.roughness;
  1180. vec3 rectCoords[ 4 ];
  1181. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  1182. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  1183. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  1184. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  1185. vec4 t1 = texture2D( ltc_1, uv );
  1186. vec4 t2 = texture2D( ltc_2, uv );
  1187. mat3 mInv = mat3(
  1188. vec3( t1.x, 0, t1.y ),
  1189. vec3( 0, 1, 0 ),
  1190. vec3( t1.z, 0, t1.w )
  1191. );
  1192. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  1193. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  1194. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  1195. }
  1196. #endif
  1197. void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1198. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  1199. vec3 irradiance = dotNL * directLight.color;
  1200. #ifdef USE_CLEARCOAT
  1201. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  1202. vec3 ccIrradiance = dotNLcc * directLight.color;
  1203. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  1204. #endif
  1205. #ifdef USE_SHEEN
  1206. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  1207. #endif
  1208. reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
  1209. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1210. }
  1211. void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  1212. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  1213. }
  1214. void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
  1215. #ifdef USE_CLEARCOAT
  1216. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  1217. #endif
  1218. #ifdef USE_SHEEN
  1219. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  1220. #endif
  1221. vec3 singleScattering = vec3( 0.0 );
  1222. vec3 multiScattering = vec3( 0.0 );
  1223. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  1224. #ifdef USE_IRIDESCENCE
  1225. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  1226. #else
  1227. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  1228. #endif
  1229. vec3 totalScattering = singleScattering + multiScattering;
  1230. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  1231. reflectedLight.indirectSpecular += radiance * singleScattering;
  1232. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  1233. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  1234. }
  1235. #define RE_Direct RE_Direct_Physical
  1236. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  1237. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  1238. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  1239. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  1240. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  1241. }`,Pge=`
  1242. vec3 geometryPosition = - vViewPosition;
  1243. vec3 geometryNormal = normal;
  1244. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  1245. vec3 geometryClearcoatNormal = vec3( 0.0 );
  1246. #ifdef USE_CLEARCOAT
  1247. geometryClearcoatNormal = clearcoatNormal;
  1248. #endif
  1249. #ifdef USE_IRIDESCENCE
  1250. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  1251. if ( material.iridescenceThickness == 0.0 ) {
  1252. material.iridescence = 0.0;
  1253. } else {
  1254. material.iridescence = saturate( material.iridescence );
  1255. }
  1256. if ( material.iridescence > 0.0 ) {
  1257. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  1258. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  1259. }
  1260. #endif
  1261. IncidentLight directLight;
  1262. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  1263. PointLight pointLight;
  1264. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  1265. PointLightShadow pointLightShadow;
  1266. #endif
  1267. #pragma unroll_loop_start
  1268. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  1269. pointLight = pointLights[ i ];
  1270. getPointLightInfo( pointLight, geometryPosition, directLight );
  1271. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  1272. pointLightShadow = pointLightShadows[ i ];
  1273. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  1274. #endif
  1275. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1276. }
  1277. #pragma unroll_loop_end
  1278. #endif
  1279. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  1280. SpotLight spotLight;
  1281. vec4 spotColor;
  1282. vec3 spotLightCoord;
  1283. bool inSpotLightMap;
  1284. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  1285. SpotLightShadow spotLightShadow;
  1286. #endif
  1287. #pragma unroll_loop_start
  1288. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  1289. spotLight = spotLights[ i ];
  1290. getSpotLightInfo( spotLight, geometryPosition, directLight );
  1291. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1292. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  1293. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1294. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  1295. #else
  1296. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  1297. #endif
  1298. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  1299. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  1300. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  1301. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  1302. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  1303. #endif
  1304. #undef SPOT_LIGHT_MAP_INDEX
  1305. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1306. spotLightShadow = spotLightShadows[ i ];
  1307. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1308. #endif
  1309. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1310. }
  1311. #pragma unroll_loop_end
  1312. #endif
  1313. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  1314. DirectionalLight directionalLight;
  1315. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  1316. DirectionalLightShadow directionalLightShadow;
  1317. #endif
  1318. #pragma unroll_loop_start
  1319. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  1320. directionalLight = directionalLights[ i ];
  1321. getDirectionalLightInfo( directionalLight, directLight );
  1322. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  1323. directionalLightShadow = directionalLightShadows[ i ];
  1324. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1325. #endif
  1326. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1327. }
  1328. #pragma unroll_loop_end
  1329. #endif
  1330. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  1331. RectAreaLight rectAreaLight;
  1332. #pragma unroll_loop_start
  1333. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  1334. rectAreaLight = rectAreaLights[ i ];
  1335. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1336. }
  1337. #pragma unroll_loop_end
  1338. #endif
  1339. #if defined( RE_IndirectDiffuse )
  1340. vec3 iblIrradiance = vec3( 0.0 );
  1341. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  1342. #if defined( USE_LIGHT_PROBES )
  1343. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  1344. #endif
  1345. #if ( NUM_HEMI_LIGHTS > 0 )
  1346. #pragma unroll_loop_start
  1347. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  1348. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  1349. }
  1350. #pragma unroll_loop_end
  1351. #endif
  1352. #endif
  1353. #if defined( RE_IndirectSpecular )
  1354. vec3 radiance = vec3( 0.0 );
  1355. vec3 clearcoatRadiance = vec3( 0.0 );
  1356. #endif`,Dge=`#if defined( RE_IndirectDiffuse )
  1357. #ifdef USE_LIGHTMAP
  1358. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  1359. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  1360. irradiance += lightMapIrradiance;
  1361. #endif
  1362. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  1363. iblIrradiance += getIBLIrradiance( geometryNormal );
  1364. #endif
  1365. #endif
  1366. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  1367. #ifdef USE_ANISOTROPY
  1368. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  1369. #else
  1370. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  1371. #endif
  1372. #ifdef USE_CLEARCOAT
  1373. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  1374. #endif
  1375. #endif`,Rge=`#if defined( RE_IndirectDiffuse )
  1376. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1377. #endif
  1378. #if defined( RE_IndirectSpecular )
  1379. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  1380. #endif`,Oge=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1381. gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  1382. #endif`,Lge=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
  1383. uniform float logDepthBufFC;
  1384. varying float vFragDepth;
  1385. varying float vIsPerspective;
  1386. #endif`,Fge=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1387. varying float vFragDepth;
  1388. varying float vIsPerspective;
  1389. #endif`,Ige=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
  1390. vFragDepth = 1.0 + gl_Position.w;
  1391. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  1392. #endif`,Uge=`#ifdef USE_MAP
  1393. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  1394. #ifdef DECODE_VIDEO_TEXTURE
  1395. sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
  1396. #endif
  1397. diffuseColor *= sampledDiffuseColor;
  1398. #endif`,zge=`#ifdef USE_MAP
  1399. uniform sampler2D map;
  1400. #endif`,Bge=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1401. #if defined( USE_POINTS_UV )
  1402. vec2 uv = vUv;
  1403. #else
  1404. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  1405. #endif
  1406. #endif
  1407. #ifdef USE_MAP
  1408. diffuseColor *= texture2D( map, uv );
  1409. #endif
  1410. #ifdef USE_ALPHAMAP
  1411. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  1412. #endif`,Hge=`#if defined( USE_POINTS_UV )
  1413. varying vec2 vUv;
  1414. #else
  1415. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  1416. uniform mat3 uvTransform;
  1417. #endif
  1418. #endif
  1419. #ifdef USE_MAP
  1420. uniform sampler2D map;
  1421. #endif
  1422. #ifdef USE_ALPHAMAP
  1423. uniform sampler2D alphaMap;
  1424. #endif`,$ge=`float metalnessFactor = metalness;
  1425. #ifdef USE_METALNESSMAP
  1426. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  1427. metalnessFactor *= texelMetalness.b;
  1428. #endif`,Vge=`#ifdef USE_METALNESSMAP
  1429. uniform sampler2D metalnessMap;
  1430. #endif`,Gge=`#ifdef USE_INSTANCING_MORPH
  1431. float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1432. float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
  1433. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1434. morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
  1435. }
  1436. #endif`,qge=`#if defined( USE_MORPHCOLORS )
  1437. vColor *= morphTargetBaseInfluence;
  1438. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1439. #if defined( USE_COLOR_ALPHA )
  1440. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  1441. #elif defined( USE_COLOR )
  1442. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  1443. #endif
  1444. }
  1445. #endif`,Wge=`#ifdef USE_MORPHNORMALS
  1446. objectNormal *= morphTargetBaseInfluence;
  1447. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1448. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  1449. }
  1450. #endif`,Kge=`#ifdef USE_MORPHTARGETS
  1451. #ifndef USE_INSTANCING_MORPH
  1452. uniform float morphTargetBaseInfluence;
  1453. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  1454. #endif
  1455. uniform sampler2DArray morphTargetsTexture;
  1456. uniform ivec2 morphTargetsTextureSize;
  1457. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  1458. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  1459. int y = texelIndex / morphTargetsTextureSize.x;
  1460. int x = texelIndex - y * morphTargetsTextureSize.x;
  1461. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  1462. return texelFetch( morphTargetsTexture, morphUV, 0 );
  1463. }
  1464. #endif`,Xge=`#ifdef USE_MORPHTARGETS
  1465. transformed *= morphTargetBaseInfluence;
  1466. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  1467. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  1468. }
  1469. #endif`,Yge=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  1470. #ifdef FLAT_SHADED
  1471. vec3 fdx = dFdx( vViewPosition );
  1472. vec3 fdy = dFdy( vViewPosition );
  1473. vec3 normal = normalize( cross( fdx, fdy ) );
  1474. #else
  1475. vec3 normal = normalize( vNormal );
  1476. #ifdef DOUBLE_SIDED
  1477. normal *= faceDirection;
  1478. #endif
  1479. #endif
  1480. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  1481. #ifdef USE_TANGENT
  1482. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1483. #else
  1484. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  1485. #if defined( USE_NORMALMAP )
  1486. vNormalMapUv
  1487. #elif defined( USE_CLEARCOAT_NORMALMAP )
  1488. vClearcoatNormalMapUv
  1489. #else
  1490. vUv
  1491. #endif
  1492. );
  1493. #endif
  1494. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1495. tbn[0] *= faceDirection;
  1496. tbn[1] *= faceDirection;
  1497. #endif
  1498. #endif
  1499. #ifdef USE_CLEARCOAT_NORMALMAP
  1500. #ifdef USE_TANGENT
  1501. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  1502. #else
  1503. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  1504. #endif
  1505. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  1506. tbn2[0] *= faceDirection;
  1507. tbn2[1] *= faceDirection;
  1508. #endif
  1509. #endif
  1510. vec3 nonPerturbedNormal = normal;`,Qge=`#ifdef USE_NORMALMAP_OBJECTSPACE
  1511. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1512. #ifdef FLIP_SIDED
  1513. normal = - normal;
  1514. #endif
  1515. #ifdef DOUBLE_SIDED
  1516. normal = normal * faceDirection;
  1517. #endif
  1518. normal = normalize( normalMatrix * normal );
  1519. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  1520. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  1521. mapN.xy *= normalScale;
  1522. normal = normalize( tbn * mapN );
  1523. #elif defined( USE_BUMPMAP )
  1524. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  1525. #endif`,Zge=`#ifndef FLAT_SHADED
  1526. varying vec3 vNormal;
  1527. #ifdef USE_TANGENT
  1528. varying vec3 vTangent;
  1529. varying vec3 vBitangent;
  1530. #endif
  1531. #endif`,Jge=`#ifndef FLAT_SHADED
  1532. varying vec3 vNormal;
  1533. #ifdef USE_TANGENT
  1534. varying vec3 vTangent;
  1535. varying vec3 vBitangent;
  1536. #endif
  1537. #endif`,exe=`#ifndef FLAT_SHADED
  1538. vNormal = normalize( transformedNormal );
  1539. #ifdef USE_TANGENT
  1540. vTangent = normalize( transformedTangent );
  1541. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  1542. #endif
  1543. #endif`,txe=`#ifdef USE_NORMALMAP
  1544. uniform sampler2D normalMap;
  1545. uniform vec2 normalScale;
  1546. #endif
  1547. #ifdef USE_NORMALMAP_OBJECTSPACE
  1548. uniform mat3 normalMatrix;
  1549. #endif
  1550. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  1551. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  1552. vec3 q0 = dFdx( eye_pos.xyz );
  1553. vec3 q1 = dFdy( eye_pos.xyz );
  1554. vec2 st0 = dFdx( uv.st );
  1555. vec2 st1 = dFdy( uv.st );
  1556. vec3 N = surf_norm;
  1557. vec3 q1perp = cross( q1, N );
  1558. vec3 q0perp = cross( N, q0 );
  1559. vec3 T = q1perp * st0.x + q0perp * st1.x;
  1560. vec3 B = q1perp * st0.y + q0perp * st1.y;
  1561. float det = max( dot( T, T ), dot( B, B ) );
  1562. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  1563. return mat3( T * scale, B * scale, N );
  1564. }
  1565. #endif`,nxe=`#ifdef USE_CLEARCOAT
  1566. vec3 clearcoatNormal = nonPerturbedNormal;
  1567. #endif`,rxe=`#ifdef USE_CLEARCOAT_NORMALMAP
  1568. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  1569. clearcoatMapN.xy *= clearcoatNormalScale;
  1570. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  1571. #endif`,ixe=`#ifdef USE_CLEARCOATMAP
  1572. uniform sampler2D clearcoatMap;
  1573. #endif
  1574. #ifdef USE_CLEARCOAT_NORMALMAP
  1575. uniform sampler2D clearcoatNormalMap;
  1576. uniform vec2 clearcoatNormalScale;
  1577. #endif
  1578. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  1579. uniform sampler2D clearcoatRoughnessMap;
  1580. #endif`,axe=`#ifdef USE_IRIDESCENCEMAP
  1581. uniform sampler2D iridescenceMap;
  1582. #endif
  1583. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  1584. uniform sampler2D iridescenceThicknessMap;
  1585. #endif`,sxe=`#ifdef OPAQUE
  1586. diffuseColor.a = 1.0;
  1587. #endif
  1588. #ifdef USE_TRANSMISSION
  1589. diffuseColor.a *= material.transmissionAlpha;
  1590. #endif
  1591. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,oxe=`vec3 packNormalToRGB( const in vec3 normal ) {
  1592. return normalize( normal ) * 0.5 + 0.5;
  1593. }
  1594. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  1595. return 2.0 * rgb.xyz - 1.0;
  1596. }
  1597. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
  1598. const float Inv255 = 1. / 255.;
  1599. const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
  1600. const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
  1601. const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
  1602. const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
  1603. vec4 packDepthToRGBA( const in float v ) {
  1604. if( v <= 0.0 )
  1605. return vec4( 0., 0., 0., 0. );
  1606. if( v >= 1.0 )
  1607. return vec4( 1., 1., 1., 1. );
  1608. float vuf;
  1609. float af = modf( v * PackFactors.a, vuf );
  1610. float bf = modf( vuf * ShiftRight8, vuf );
  1611. float gf = modf( vuf * ShiftRight8, vuf );
  1612. return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
  1613. }
  1614. vec3 packDepthToRGB( const in float v ) {
  1615. if( v <= 0.0 )
  1616. return vec3( 0., 0., 0. );
  1617. if( v >= 1.0 )
  1618. return vec3( 1., 1., 1. );
  1619. float vuf;
  1620. float bf = modf( v * PackFactors.b, vuf );
  1621. float gf = modf( vuf * ShiftRight8, vuf );
  1622. return vec3( vuf * Inv255, gf * PackUpscale, bf );
  1623. }
  1624. vec2 packDepthToRG( const in float v ) {
  1625. if( v <= 0.0 )
  1626. return vec2( 0., 0. );
  1627. if( v >= 1.0 )
  1628. return vec2( 1., 1. );
  1629. float vuf;
  1630. float gf = modf( v * 256., vuf );
  1631. return vec2( vuf * Inv255, gf );
  1632. }
  1633. float unpackRGBAToDepth( const in vec4 v ) {
  1634. return dot( v, UnpackFactors4 );
  1635. }
  1636. float unpackRGBToDepth( const in vec3 v ) {
  1637. return dot( v, UnpackFactors3 );
  1638. }
  1639. float unpackRGToDepth( const in vec2 v ) {
  1640. return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
  1641. }
  1642. vec4 pack2HalfToRGBA( const in vec2 v ) {
  1643. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  1644. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  1645. }
  1646. vec2 unpackRGBATo2Half( const in vec4 v ) {
  1647. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  1648. }
  1649. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  1650. return ( viewZ + near ) / ( near - far );
  1651. }
  1652. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1653. return depth * ( near - far ) - near;
  1654. }
  1655. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  1656. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  1657. }
  1658. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  1659. return ( near * far ) / ( ( far - near ) * depth - far );
  1660. }`,lxe=`#ifdef PREMULTIPLIED_ALPHA
  1661. gl_FragColor.rgb *= gl_FragColor.a;
  1662. #endif`,cxe=`vec4 mvPosition = vec4( transformed, 1.0 );
  1663. #ifdef USE_BATCHING
  1664. mvPosition = batchingMatrix * mvPosition;
  1665. #endif
  1666. #ifdef USE_INSTANCING
  1667. mvPosition = instanceMatrix * mvPosition;
  1668. #endif
  1669. mvPosition = modelViewMatrix * mvPosition;
  1670. gl_Position = projectionMatrix * mvPosition;`,uxe=`#ifdef DITHERING
  1671. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  1672. #endif`,dxe=`#ifdef DITHERING
  1673. vec3 dithering( vec3 color ) {
  1674. float grid_position = rand( gl_FragCoord.xy );
  1675. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  1676. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  1677. return color + dither_shift_RGB;
  1678. }
  1679. #endif`,hxe=`float roughnessFactor = roughness;
  1680. #ifdef USE_ROUGHNESSMAP
  1681. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  1682. roughnessFactor *= texelRoughness.g;
  1683. #endif`,fxe=`#ifdef USE_ROUGHNESSMAP
  1684. uniform sampler2D roughnessMap;
  1685. #endif`,mxe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1686. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1687. #endif
  1688. #if NUM_SPOT_LIGHT_MAPS > 0
  1689. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  1690. #endif
  1691. #ifdef USE_SHADOWMAP
  1692. #if NUM_DIR_LIGHT_SHADOWS > 0
  1693. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  1694. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1695. struct DirectionalLightShadow {
  1696. float shadowIntensity;
  1697. float shadowBias;
  1698. float shadowNormalBias;
  1699. float shadowRadius;
  1700. vec2 shadowMapSize;
  1701. };
  1702. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1703. #endif
  1704. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1705. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  1706. struct SpotLightShadow {
  1707. float shadowIntensity;
  1708. float shadowBias;
  1709. float shadowNormalBias;
  1710. float shadowRadius;
  1711. vec2 shadowMapSize;
  1712. };
  1713. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1714. #endif
  1715. #if NUM_POINT_LIGHT_SHADOWS > 0
  1716. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  1717. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1718. struct PointLightShadow {
  1719. float shadowIntensity;
  1720. float shadowBias;
  1721. float shadowNormalBias;
  1722. float shadowRadius;
  1723. vec2 shadowMapSize;
  1724. float shadowCameraNear;
  1725. float shadowCameraFar;
  1726. };
  1727. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1728. #endif
  1729. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  1730. float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
  1731. #ifdef USE_REVERSED_DEPTH_BUFFER
  1732. return step( depth, compare );
  1733. #else
  1734. return step( compare, depth );
  1735. #endif
  1736. }
  1737. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  1738. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  1739. }
  1740. float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
  1741. float occlusion = 1.0;
  1742. vec2 distribution = texture2DDistribution( shadow, uv );
  1743. #ifdef USE_REVERSED_DEPTH_BUFFER
  1744. float hard_shadow = step( distribution.x, compare );
  1745. #else
  1746. float hard_shadow = step( compare, distribution.x );
  1747. #endif
  1748. if ( hard_shadow != 1.0 ) {
  1749. float distance = compare - distribution.x;
  1750. float variance = max( 0.00000, distribution.y * distribution.y );
  1751. float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
  1752. }
  1753. return occlusion;
  1754. }
  1755. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  1756. float shadow = 1.0;
  1757. shadowCoord.xyz /= shadowCoord.w;
  1758. shadowCoord.z += shadowBias;
  1759. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  1760. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  1761. if ( frustumTest ) {
  1762. #if defined( SHADOWMAP_TYPE_PCF )
  1763. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1764. float dx0 = - texelSize.x * shadowRadius;
  1765. float dy0 = - texelSize.y * shadowRadius;
  1766. float dx1 = + texelSize.x * shadowRadius;
  1767. float dy1 = + texelSize.y * shadowRadius;
  1768. float dx2 = dx0 / 2.0;
  1769. float dy2 = dy0 / 2.0;
  1770. float dx3 = dx1 / 2.0;
  1771. float dy3 = dy1 / 2.0;
  1772. shadow = (
  1773. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  1774. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  1775. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  1776. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  1777. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  1778. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  1779. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  1780. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  1781. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  1782. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  1783. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  1784. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  1785. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  1786. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  1787. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  1788. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  1789. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  1790. ) * ( 1.0 / 17.0 );
  1791. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  1792. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  1793. float dx = texelSize.x;
  1794. float dy = texelSize.y;
  1795. vec2 uv = shadowCoord.xy;
  1796. vec2 f = fract( uv * shadowMapSize + 0.5 );
  1797. uv -= f * texelSize;
  1798. shadow = (
  1799. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  1800. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  1801. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  1802. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  1803. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  1804. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  1805. f.x ) +
  1806. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  1807. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  1808. f.x ) +
  1809. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  1810. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  1811. f.y ) +
  1812. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  1813. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  1814. f.y ) +
  1815. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  1816. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  1817. f.x ),
  1818. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  1819. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  1820. f.x ),
  1821. f.y )
  1822. ) * ( 1.0 / 9.0 );
  1823. #elif defined( SHADOWMAP_TYPE_VSM )
  1824. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  1825. #else
  1826. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  1827. #endif
  1828. }
  1829. return mix( 1.0, shadow, shadowIntensity );
  1830. }
  1831. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  1832. vec3 absV = abs( v );
  1833. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  1834. absV *= scaleToCube;
  1835. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  1836. vec2 planar = v.xy;
  1837. float almostATexel = 1.5 * texelSizeY;
  1838. float almostOne = 1.0 - almostATexel;
  1839. if ( absV.z >= almostOne ) {
  1840. if ( v.z > 0.0 )
  1841. planar.x = 4.0 - v.x;
  1842. } else if ( absV.x >= almostOne ) {
  1843. float signX = sign( v.x );
  1844. planar.x = v.z * signX + 2.0 * signX;
  1845. } else if ( absV.y >= almostOne ) {
  1846. float signY = sign( v.y );
  1847. planar.x = v.x + 2.0 * signY + 2.0;
  1848. planar.y = v.z * signY - 2.0;
  1849. }
  1850. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  1851. }
  1852. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  1853. float shadow = 1.0;
  1854. vec3 lightToPosition = shadowCoord.xyz;
  1855. float lightToPositionLength = length( lightToPosition );
  1856. if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
  1857. float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  1858. vec3 bd3D = normalize( lightToPosition );
  1859. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  1860. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  1861. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  1862. shadow = (
  1863. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  1864. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  1865. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  1866. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  1867. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  1868. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  1869. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  1870. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  1871. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  1872. ) * ( 1.0 / 9.0 );
  1873. #else
  1874. shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  1875. #endif
  1876. }
  1877. return mix( 1.0, shadow, shadowIntensity );
  1878. }
  1879. #endif`,pxe=`#if NUM_SPOT_LIGHT_COORDS > 0
  1880. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  1881. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  1882. #endif
  1883. #ifdef USE_SHADOWMAP
  1884. #if NUM_DIR_LIGHT_SHADOWS > 0
  1885. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  1886. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  1887. struct DirectionalLightShadow {
  1888. float shadowIntensity;
  1889. float shadowBias;
  1890. float shadowNormalBias;
  1891. float shadowRadius;
  1892. vec2 shadowMapSize;
  1893. };
  1894. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  1895. #endif
  1896. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1897. struct SpotLightShadow {
  1898. float shadowIntensity;
  1899. float shadowBias;
  1900. float shadowNormalBias;
  1901. float shadowRadius;
  1902. vec2 shadowMapSize;
  1903. };
  1904. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  1905. #endif
  1906. #if NUM_POINT_LIGHT_SHADOWS > 0
  1907. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  1908. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  1909. struct PointLightShadow {
  1910. float shadowIntensity;
  1911. float shadowBias;
  1912. float shadowNormalBias;
  1913. float shadowRadius;
  1914. vec2 shadowMapSize;
  1915. float shadowCameraNear;
  1916. float shadowCameraFar;
  1917. };
  1918. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  1919. #endif
  1920. #endif`,gxe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  1921. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  1922. vec4 shadowWorldPosition;
  1923. #endif
  1924. #if defined( USE_SHADOWMAP )
  1925. #if NUM_DIR_LIGHT_SHADOWS > 0
  1926. #pragma unroll_loop_start
  1927. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1928. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  1929. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  1930. }
  1931. #pragma unroll_loop_end
  1932. #endif
  1933. #if NUM_POINT_LIGHT_SHADOWS > 0
  1934. #pragma unroll_loop_start
  1935. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1936. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  1937. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  1938. }
  1939. #pragma unroll_loop_end
  1940. #endif
  1941. #endif
  1942. #if NUM_SPOT_LIGHT_COORDS > 0
  1943. #pragma unroll_loop_start
  1944. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  1945. shadowWorldPosition = worldPosition;
  1946. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  1947. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  1948. #endif
  1949. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  1950. }
  1951. #pragma unroll_loop_end
  1952. #endif`,xxe=`float getShadowMask() {
  1953. float shadow = 1.0;
  1954. #ifdef USE_SHADOWMAP
  1955. #if NUM_DIR_LIGHT_SHADOWS > 0
  1956. DirectionalLightShadow directionalLight;
  1957. #pragma unroll_loop_start
  1958. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  1959. directionalLight = directionalLightShadows[ i ];
  1960. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  1961. }
  1962. #pragma unroll_loop_end
  1963. #endif
  1964. #if NUM_SPOT_LIGHT_SHADOWS > 0
  1965. SpotLightShadow spotLight;
  1966. #pragma unroll_loop_start
  1967. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  1968. spotLight = spotLightShadows[ i ];
  1969. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  1970. }
  1971. #pragma unroll_loop_end
  1972. #endif
  1973. #if NUM_POINT_LIGHT_SHADOWS > 0
  1974. PointLightShadow pointLight;
  1975. #pragma unroll_loop_start
  1976. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  1977. pointLight = pointLightShadows[ i ];
  1978. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  1979. }
  1980. #pragma unroll_loop_end
  1981. #endif
  1982. #endif
  1983. return shadow;
  1984. }`,bxe=`#ifdef USE_SKINNING
  1985. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  1986. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  1987. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  1988. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  1989. #endif`,yxe=`#ifdef USE_SKINNING
  1990. uniform mat4 bindMatrix;
  1991. uniform mat4 bindMatrixInverse;
  1992. uniform highp sampler2D boneTexture;
  1993. mat4 getBoneMatrix( const in float i ) {
  1994. int size = textureSize( boneTexture, 0 ).x;
  1995. int j = int( i ) * 4;
  1996. int x = j % size;
  1997. int y = j / size;
  1998. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  1999. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  2000. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  2001. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  2002. return mat4( v1, v2, v3, v4 );
  2003. }
  2004. #endif`,vxe=`#ifdef USE_SKINNING
  2005. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  2006. vec4 skinned = vec4( 0.0 );
  2007. skinned += boneMatX * skinVertex * skinWeight.x;
  2008. skinned += boneMatY * skinVertex * skinWeight.y;
  2009. skinned += boneMatZ * skinVertex * skinWeight.z;
  2010. skinned += boneMatW * skinVertex * skinWeight.w;
  2011. transformed = ( bindMatrixInverse * skinned ).xyz;
  2012. #endif`,wxe=`#ifdef USE_SKINNING
  2013. mat4 skinMatrix = mat4( 0.0 );
  2014. skinMatrix += skinWeight.x * boneMatX;
  2015. skinMatrix += skinWeight.y * boneMatY;
  2016. skinMatrix += skinWeight.z * boneMatZ;
  2017. skinMatrix += skinWeight.w * boneMatW;
  2018. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  2019. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  2020. #ifdef USE_TANGENT
  2021. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  2022. #endif
  2023. #endif`,_xe=`float specularStrength;
  2024. #ifdef USE_SPECULARMAP
  2025. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  2026. specularStrength = texelSpecular.r;
  2027. #else
  2028. specularStrength = 1.0;
  2029. #endif`,Sxe=`#ifdef USE_SPECULARMAP
  2030. uniform sampler2D specularMap;
  2031. #endif`,Nxe=`#if defined( TONE_MAPPING )
  2032. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  2033. #endif`,Mxe=`#ifndef saturate
  2034. #define saturate( a ) clamp( a, 0.0, 1.0 )
  2035. #endif
  2036. uniform float toneMappingExposure;
  2037. vec3 LinearToneMapping( vec3 color ) {
  2038. return saturate( toneMappingExposure * color );
  2039. }
  2040. vec3 ReinhardToneMapping( vec3 color ) {
  2041. color *= toneMappingExposure;
  2042. return saturate( color / ( vec3( 1.0 ) + color ) );
  2043. }
  2044. vec3 CineonToneMapping( vec3 color ) {
  2045. color *= toneMappingExposure;
  2046. color = max( vec3( 0.0 ), color - 0.004 );
  2047. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  2048. }
  2049. vec3 RRTAndODTFit( vec3 v ) {
  2050. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  2051. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  2052. return a / b;
  2053. }
  2054. vec3 ACESFilmicToneMapping( vec3 color ) {
  2055. const mat3 ACESInputMat = mat3(
  2056. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  2057. vec3( 0.04823, 0.01566, 0.83777 )
  2058. );
  2059. const mat3 ACESOutputMat = mat3(
  2060. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  2061. vec3( -0.07367, -0.00605, 1.07602 )
  2062. );
  2063. color *= toneMappingExposure / 0.6;
  2064. color = ACESInputMat * color;
  2065. color = RRTAndODTFit( color );
  2066. color = ACESOutputMat * color;
  2067. return saturate( color );
  2068. }
  2069. const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
  2070. vec3( 1.6605, - 0.1246, - 0.0182 ),
  2071. vec3( - 0.5876, 1.1329, - 0.1006 ),
  2072. vec3( - 0.0728, - 0.0083, 1.1187 )
  2073. );
  2074. const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
  2075. vec3( 0.6274, 0.0691, 0.0164 ),
  2076. vec3( 0.3293, 0.9195, 0.0880 ),
  2077. vec3( 0.0433, 0.0113, 0.8956 )
  2078. );
  2079. vec3 agxDefaultContrastApprox( vec3 x ) {
  2080. vec3 x2 = x * x;
  2081. vec3 x4 = x2 * x2;
  2082. return + 15.5 * x4 * x2
  2083. - 40.14 * x4 * x
  2084. + 31.96 * x4
  2085. - 6.868 * x2 * x
  2086. + 0.4298 * x2
  2087. + 0.1191 * x
  2088. - 0.00232;
  2089. }
  2090. vec3 AgXToneMapping( vec3 color ) {
  2091. const mat3 AgXInsetMatrix = mat3(
  2092. vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
  2093. vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
  2094. vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
  2095. );
  2096. const mat3 AgXOutsetMatrix = mat3(
  2097. vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
  2098. vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
  2099. vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
  2100. );
  2101. const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
  2102. color *= toneMappingExposure;
  2103. color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
  2104. color = AgXInsetMatrix * color;
  2105. color = max( color, 1e-10 ); color = log2( color );
  2106. color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
  2107. color = clamp( color, 0.0, 1.0 );
  2108. color = agxDefaultContrastApprox( color );
  2109. color = AgXOutsetMatrix * color;
  2110. color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
  2111. color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
  2112. color = clamp( color, 0.0, 1.0 );
  2113. return color;
  2114. }
  2115. vec3 NeutralToneMapping( vec3 color ) {
  2116. const float StartCompression = 0.8 - 0.04;
  2117. const float Desaturation = 0.15;
  2118. color *= toneMappingExposure;
  2119. float x = min( color.r, min( color.g, color.b ) );
  2120. float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
  2121. color -= offset;
  2122. float peak = max( color.r, max( color.g, color.b ) );
  2123. if ( peak < StartCompression ) return color;
  2124. float d = 1. - StartCompression;
  2125. float newPeak = 1. - d * d / ( peak + d - StartCompression );
  2126. color *= newPeak / peak;
  2127. float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
  2128. return mix( color, vec3( newPeak ), g );
  2129. }
  2130. vec3 CustomToneMapping( vec3 color ) { return color; }`,kxe=`#ifdef USE_TRANSMISSION
  2131. material.transmission = transmission;
  2132. material.transmissionAlpha = 1.0;
  2133. material.thickness = thickness;
  2134. material.attenuationDistance = attenuationDistance;
  2135. material.attenuationColor = attenuationColor;
  2136. #ifdef USE_TRANSMISSIONMAP
  2137. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  2138. #endif
  2139. #ifdef USE_THICKNESSMAP
  2140. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  2141. #endif
  2142. vec3 pos = vWorldPosition;
  2143. vec3 v = normalize( cameraPosition - pos );
  2144. vec3 n = inverseTransformDirection( normal, viewMatrix );
  2145. vec4 transmitted = getIBLVolumeRefraction(
  2146. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  2147. pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
  2148. material.attenuationColor, material.attenuationDistance );
  2149. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  2150. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  2151. #endif`,Exe=`#ifdef USE_TRANSMISSION
  2152. uniform float transmission;
  2153. uniform float thickness;
  2154. uniform float attenuationDistance;
  2155. uniform vec3 attenuationColor;
  2156. #ifdef USE_TRANSMISSIONMAP
  2157. uniform sampler2D transmissionMap;
  2158. #endif
  2159. #ifdef USE_THICKNESSMAP
  2160. uniform sampler2D thicknessMap;
  2161. #endif
  2162. uniform vec2 transmissionSamplerSize;
  2163. uniform sampler2D transmissionSamplerMap;
  2164. uniform mat4 modelMatrix;
  2165. uniform mat4 projectionMatrix;
  2166. varying vec3 vWorldPosition;
  2167. float w0( float a ) {
  2168. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  2169. }
  2170. float w1( float a ) {
  2171. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  2172. }
  2173. float w2( float a ){
  2174. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  2175. }
  2176. float w3( float a ) {
  2177. return ( 1.0 / 6.0 ) * ( a * a * a );
  2178. }
  2179. float g0( float a ) {
  2180. return w0( a ) + w1( a );
  2181. }
  2182. float g1( float a ) {
  2183. return w2( a ) + w3( a );
  2184. }
  2185. float h0( float a ) {
  2186. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  2187. }
  2188. float h1( float a ) {
  2189. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  2190. }
  2191. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  2192. uv = uv * texelSize.zw + 0.5;
  2193. vec2 iuv = floor( uv );
  2194. vec2 fuv = fract( uv );
  2195. float g0x = g0( fuv.x );
  2196. float g1x = g1( fuv.x );
  2197. float h0x = h0( fuv.x );
  2198. float h1x = h1( fuv.x );
  2199. float h0y = h0( fuv.y );
  2200. float h1y = h1( fuv.y );
  2201. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2202. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  2203. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2204. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  2205. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  2206. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  2207. }
  2208. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  2209. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  2210. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  2211. vec2 fLodSizeInv = 1.0 / fLodSize;
  2212. vec2 cLodSizeInv = 1.0 / cLodSize;
  2213. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  2214. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  2215. return mix( fSample, cSample, fract( lod ) );
  2216. }
  2217. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  2218. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  2219. vec3 modelScale;
  2220. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  2221. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  2222. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  2223. return normalize( refractionVector ) * thickness * modelScale;
  2224. }
  2225. float applyIorToRoughness( const in float roughness, const in float ior ) {
  2226. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  2227. }
  2228. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  2229. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  2230. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  2231. }
  2232. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  2233. if ( isinf( attenuationDistance ) ) {
  2234. return vec3( 1.0 );
  2235. } else {
  2236. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  2237. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  2238. }
  2239. }
  2240. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  2241. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  2242. const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
  2243. const in vec3 attenuationColor, const in float attenuationDistance ) {
  2244. vec4 transmittedLight;
  2245. vec3 transmittance;
  2246. #ifdef USE_DISPERSION
  2247. float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
  2248. vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
  2249. for ( int i = 0; i < 3; i ++ ) {
  2250. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
  2251. vec3 refractedRayExit = position + transmissionRay;
  2252. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2253. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2254. refractionCoords += 1.0;
  2255. refractionCoords /= 2.0;
  2256. vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
  2257. transmittedLight[ i ] = transmissionSample[ i ];
  2258. transmittedLight.a += transmissionSample.a;
  2259. transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
  2260. }
  2261. transmittedLight.a /= 3.0;
  2262. #else
  2263. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  2264. vec3 refractedRayExit = position + transmissionRay;
  2265. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  2266. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  2267. refractionCoords += 1.0;
  2268. refractionCoords /= 2.0;
  2269. transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  2270. transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  2271. #endif
  2272. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  2273. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  2274. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  2275. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  2276. }
  2277. #endif`,Txe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2278. varying vec2 vUv;
  2279. #endif
  2280. #ifdef USE_MAP
  2281. varying vec2 vMapUv;
  2282. #endif
  2283. #ifdef USE_ALPHAMAP
  2284. varying vec2 vAlphaMapUv;
  2285. #endif
  2286. #ifdef USE_LIGHTMAP
  2287. varying vec2 vLightMapUv;
  2288. #endif
  2289. #ifdef USE_AOMAP
  2290. varying vec2 vAoMapUv;
  2291. #endif
  2292. #ifdef USE_BUMPMAP
  2293. varying vec2 vBumpMapUv;
  2294. #endif
  2295. #ifdef USE_NORMALMAP
  2296. varying vec2 vNormalMapUv;
  2297. #endif
  2298. #ifdef USE_EMISSIVEMAP
  2299. varying vec2 vEmissiveMapUv;
  2300. #endif
  2301. #ifdef USE_METALNESSMAP
  2302. varying vec2 vMetalnessMapUv;
  2303. #endif
  2304. #ifdef USE_ROUGHNESSMAP
  2305. varying vec2 vRoughnessMapUv;
  2306. #endif
  2307. #ifdef USE_ANISOTROPYMAP
  2308. varying vec2 vAnisotropyMapUv;
  2309. #endif
  2310. #ifdef USE_CLEARCOATMAP
  2311. varying vec2 vClearcoatMapUv;
  2312. #endif
  2313. #ifdef USE_CLEARCOAT_NORMALMAP
  2314. varying vec2 vClearcoatNormalMapUv;
  2315. #endif
  2316. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2317. varying vec2 vClearcoatRoughnessMapUv;
  2318. #endif
  2319. #ifdef USE_IRIDESCENCEMAP
  2320. varying vec2 vIridescenceMapUv;
  2321. #endif
  2322. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2323. varying vec2 vIridescenceThicknessMapUv;
  2324. #endif
  2325. #ifdef USE_SHEEN_COLORMAP
  2326. varying vec2 vSheenColorMapUv;
  2327. #endif
  2328. #ifdef USE_SHEEN_ROUGHNESSMAP
  2329. varying vec2 vSheenRoughnessMapUv;
  2330. #endif
  2331. #ifdef USE_SPECULARMAP
  2332. varying vec2 vSpecularMapUv;
  2333. #endif
  2334. #ifdef USE_SPECULAR_COLORMAP
  2335. varying vec2 vSpecularColorMapUv;
  2336. #endif
  2337. #ifdef USE_SPECULAR_INTENSITYMAP
  2338. varying vec2 vSpecularIntensityMapUv;
  2339. #endif
  2340. #ifdef USE_TRANSMISSIONMAP
  2341. uniform mat3 transmissionMapTransform;
  2342. varying vec2 vTransmissionMapUv;
  2343. #endif
  2344. #ifdef USE_THICKNESSMAP
  2345. uniform mat3 thicknessMapTransform;
  2346. varying vec2 vThicknessMapUv;
  2347. #endif`,Axe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2348. varying vec2 vUv;
  2349. #endif
  2350. #ifdef USE_MAP
  2351. uniform mat3 mapTransform;
  2352. varying vec2 vMapUv;
  2353. #endif
  2354. #ifdef USE_ALPHAMAP
  2355. uniform mat3 alphaMapTransform;
  2356. varying vec2 vAlphaMapUv;
  2357. #endif
  2358. #ifdef USE_LIGHTMAP
  2359. uniform mat3 lightMapTransform;
  2360. varying vec2 vLightMapUv;
  2361. #endif
  2362. #ifdef USE_AOMAP
  2363. uniform mat3 aoMapTransform;
  2364. varying vec2 vAoMapUv;
  2365. #endif
  2366. #ifdef USE_BUMPMAP
  2367. uniform mat3 bumpMapTransform;
  2368. varying vec2 vBumpMapUv;
  2369. #endif
  2370. #ifdef USE_NORMALMAP
  2371. uniform mat3 normalMapTransform;
  2372. varying vec2 vNormalMapUv;
  2373. #endif
  2374. #ifdef USE_DISPLACEMENTMAP
  2375. uniform mat3 displacementMapTransform;
  2376. varying vec2 vDisplacementMapUv;
  2377. #endif
  2378. #ifdef USE_EMISSIVEMAP
  2379. uniform mat3 emissiveMapTransform;
  2380. varying vec2 vEmissiveMapUv;
  2381. #endif
  2382. #ifdef USE_METALNESSMAP
  2383. uniform mat3 metalnessMapTransform;
  2384. varying vec2 vMetalnessMapUv;
  2385. #endif
  2386. #ifdef USE_ROUGHNESSMAP
  2387. uniform mat3 roughnessMapTransform;
  2388. varying vec2 vRoughnessMapUv;
  2389. #endif
  2390. #ifdef USE_ANISOTROPYMAP
  2391. uniform mat3 anisotropyMapTransform;
  2392. varying vec2 vAnisotropyMapUv;
  2393. #endif
  2394. #ifdef USE_CLEARCOATMAP
  2395. uniform mat3 clearcoatMapTransform;
  2396. varying vec2 vClearcoatMapUv;
  2397. #endif
  2398. #ifdef USE_CLEARCOAT_NORMALMAP
  2399. uniform mat3 clearcoatNormalMapTransform;
  2400. varying vec2 vClearcoatNormalMapUv;
  2401. #endif
  2402. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2403. uniform mat3 clearcoatRoughnessMapTransform;
  2404. varying vec2 vClearcoatRoughnessMapUv;
  2405. #endif
  2406. #ifdef USE_SHEEN_COLORMAP
  2407. uniform mat3 sheenColorMapTransform;
  2408. varying vec2 vSheenColorMapUv;
  2409. #endif
  2410. #ifdef USE_SHEEN_ROUGHNESSMAP
  2411. uniform mat3 sheenRoughnessMapTransform;
  2412. varying vec2 vSheenRoughnessMapUv;
  2413. #endif
  2414. #ifdef USE_IRIDESCENCEMAP
  2415. uniform mat3 iridescenceMapTransform;
  2416. varying vec2 vIridescenceMapUv;
  2417. #endif
  2418. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2419. uniform mat3 iridescenceThicknessMapTransform;
  2420. varying vec2 vIridescenceThicknessMapUv;
  2421. #endif
  2422. #ifdef USE_SPECULARMAP
  2423. uniform mat3 specularMapTransform;
  2424. varying vec2 vSpecularMapUv;
  2425. #endif
  2426. #ifdef USE_SPECULAR_COLORMAP
  2427. uniform mat3 specularColorMapTransform;
  2428. varying vec2 vSpecularColorMapUv;
  2429. #endif
  2430. #ifdef USE_SPECULAR_INTENSITYMAP
  2431. uniform mat3 specularIntensityMapTransform;
  2432. varying vec2 vSpecularIntensityMapUv;
  2433. #endif
  2434. #ifdef USE_TRANSMISSIONMAP
  2435. uniform mat3 transmissionMapTransform;
  2436. varying vec2 vTransmissionMapUv;
  2437. #endif
  2438. #ifdef USE_THICKNESSMAP
  2439. uniform mat3 thicknessMapTransform;
  2440. varying vec2 vThicknessMapUv;
  2441. #endif`,Cxe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  2442. vUv = vec3( uv, 1 ).xy;
  2443. #endif
  2444. #ifdef USE_MAP
  2445. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  2446. #endif
  2447. #ifdef USE_ALPHAMAP
  2448. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  2449. #endif
  2450. #ifdef USE_LIGHTMAP
  2451. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  2452. #endif
  2453. #ifdef USE_AOMAP
  2454. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  2455. #endif
  2456. #ifdef USE_BUMPMAP
  2457. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  2458. #endif
  2459. #ifdef USE_NORMALMAP
  2460. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  2461. #endif
  2462. #ifdef USE_DISPLACEMENTMAP
  2463. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  2464. #endif
  2465. #ifdef USE_EMISSIVEMAP
  2466. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  2467. #endif
  2468. #ifdef USE_METALNESSMAP
  2469. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  2470. #endif
  2471. #ifdef USE_ROUGHNESSMAP
  2472. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  2473. #endif
  2474. #ifdef USE_ANISOTROPYMAP
  2475. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  2476. #endif
  2477. #ifdef USE_CLEARCOATMAP
  2478. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  2479. #endif
  2480. #ifdef USE_CLEARCOAT_NORMALMAP
  2481. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  2482. #endif
  2483. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  2484. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  2485. #endif
  2486. #ifdef USE_IRIDESCENCEMAP
  2487. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  2488. #endif
  2489. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  2490. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  2491. #endif
  2492. #ifdef USE_SHEEN_COLORMAP
  2493. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  2494. #endif
  2495. #ifdef USE_SHEEN_ROUGHNESSMAP
  2496. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  2497. #endif
  2498. #ifdef USE_SPECULARMAP
  2499. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  2500. #endif
  2501. #ifdef USE_SPECULAR_COLORMAP
  2502. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  2503. #endif
  2504. #ifdef USE_SPECULAR_INTENSITYMAP
  2505. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  2506. #endif
  2507. #ifdef USE_TRANSMISSIONMAP
  2508. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  2509. #endif
  2510. #ifdef USE_THICKNESSMAP
  2511. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  2512. #endif`,jxe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  2513. vec4 worldPosition = vec4( transformed, 1.0 );
  2514. #ifdef USE_BATCHING
  2515. worldPosition = batchingMatrix * worldPosition;
  2516. #endif
  2517. #ifdef USE_INSTANCING
  2518. worldPosition = instanceMatrix * worldPosition;
  2519. #endif
  2520. worldPosition = modelMatrix * worldPosition;
  2521. #endif`;const Pxe=`varying vec2 vUv;
  2522. uniform mat3 uvTransform;
  2523. void main() {
  2524. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  2525. gl_Position = vec4( position.xy, 1.0, 1.0 );
  2526. }`,Dxe=`uniform sampler2D t2D;
  2527. uniform float backgroundIntensity;
  2528. varying vec2 vUv;
  2529. void main() {
  2530. vec4 texColor = texture2D( t2D, vUv );
  2531. #ifdef DECODE_VIDEO_TEXTURE
  2532. texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
  2533. #endif
  2534. texColor.rgb *= backgroundIntensity;
  2535. gl_FragColor = texColor;
  2536. #include <tonemapping_fragment>
  2537. #include <colorspace_fragment>
  2538. }`,Rxe=`varying vec3 vWorldDirection;
  2539. #include <common>
  2540. void main() {
  2541. vWorldDirection = transformDirection( position, modelMatrix );
  2542. #include <begin_vertex>
  2543. #include <project_vertex>
  2544. gl_Position.z = gl_Position.w;
  2545. }`,Oxe=`#ifdef ENVMAP_TYPE_CUBE
  2546. uniform samplerCube envMap;
  2547. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2548. uniform sampler2D envMap;
  2549. #endif
  2550. uniform float flipEnvMap;
  2551. uniform float backgroundBlurriness;
  2552. uniform float backgroundIntensity;
  2553. uniform mat3 backgroundRotation;
  2554. varying vec3 vWorldDirection;
  2555. #include <cube_uv_reflection_fragment>
  2556. void main() {
  2557. #ifdef ENVMAP_TYPE_CUBE
  2558. vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  2559. #elif defined( ENVMAP_TYPE_CUBE_UV )
  2560. vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
  2561. #else
  2562. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  2563. #endif
  2564. texColor.rgb *= backgroundIntensity;
  2565. gl_FragColor = texColor;
  2566. #include <tonemapping_fragment>
  2567. #include <colorspace_fragment>
  2568. }`,Lxe=`varying vec3 vWorldDirection;
  2569. #include <common>
  2570. void main() {
  2571. vWorldDirection = transformDirection( position, modelMatrix );
  2572. #include <begin_vertex>
  2573. #include <project_vertex>
  2574. gl_Position.z = gl_Position.w;
  2575. }`,Fxe=`uniform samplerCube tCube;
  2576. uniform float tFlip;
  2577. uniform float opacity;
  2578. varying vec3 vWorldDirection;
  2579. void main() {
  2580. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  2581. gl_FragColor = texColor;
  2582. gl_FragColor.a *= opacity;
  2583. #include <tonemapping_fragment>
  2584. #include <colorspace_fragment>
  2585. }`,Ixe=`#include <common>
  2586. #include <batching_pars_vertex>
  2587. #include <uv_pars_vertex>
  2588. #include <displacementmap_pars_vertex>
  2589. #include <morphtarget_pars_vertex>
  2590. #include <skinning_pars_vertex>
  2591. #include <logdepthbuf_pars_vertex>
  2592. #include <clipping_planes_pars_vertex>
  2593. varying vec2 vHighPrecisionZW;
  2594. void main() {
  2595. #include <uv_vertex>
  2596. #include <batching_vertex>
  2597. #include <skinbase_vertex>
  2598. #include <morphinstance_vertex>
  2599. #ifdef USE_DISPLACEMENTMAP
  2600. #include <beginnormal_vertex>
  2601. #include <morphnormal_vertex>
  2602. #include <skinnormal_vertex>
  2603. #endif
  2604. #include <begin_vertex>
  2605. #include <morphtarget_vertex>
  2606. #include <skinning_vertex>
  2607. #include <displacementmap_vertex>
  2608. #include <project_vertex>
  2609. #include <logdepthbuf_vertex>
  2610. #include <clipping_planes_vertex>
  2611. vHighPrecisionZW = gl_Position.zw;
  2612. }`,Uxe=`#if DEPTH_PACKING == 3200
  2613. uniform float opacity;
  2614. #endif
  2615. #include <common>
  2616. #include <packing>
  2617. #include <uv_pars_fragment>
  2618. #include <map_pars_fragment>
  2619. #include <alphamap_pars_fragment>
  2620. #include <alphatest_pars_fragment>
  2621. #include <alphahash_pars_fragment>
  2622. #include <logdepthbuf_pars_fragment>
  2623. #include <clipping_planes_pars_fragment>
  2624. varying vec2 vHighPrecisionZW;
  2625. void main() {
  2626. vec4 diffuseColor = vec4( 1.0 );
  2627. #include <clipping_planes_fragment>
  2628. #if DEPTH_PACKING == 3200
  2629. diffuseColor.a = opacity;
  2630. #endif
  2631. #include <map_fragment>
  2632. #include <alphamap_fragment>
  2633. #include <alphatest_fragment>
  2634. #include <alphahash_fragment>
  2635. #include <logdepthbuf_fragment>
  2636. #ifdef USE_REVERSED_DEPTH_BUFFER
  2637. float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
  2638. #else
  2639. float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
  2640. #endif
  2641. #if DEPTH_PACKING == 3200
  2642. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  2643. #elif DEPTH_PACKING == 3201
  2644. gl_FragColor = packDepthToRGBA( fragCoordZ );
  2645. #elif DEPTH_PACKING == 3202
  2646. gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
  2647. #elif DEPTH_PACKING == 3203
  2648. gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
  2649. #endif
  2650. }`,zxe=`#define DISTANCE
  2651. varying vec3 vWorldPosition;
  2652. #include <common>
  2653. #include <batching_pars_vertex>
  2654. #include <uv_pars_vertex>
  2655. #include <displacementmap_pars_vertex>
  2656. #include <morphtarget_pars_vertex>
  2657. #include <skinning_pars_vertex>
  2658. #include <clipping_planes_pars_vertex>
  2659. void main() {
  2660. #include <uv_vertex>
  2661. #include <batching_vertex>
  2662. #include <skinbase_vertex>
  2663. #include <morphinstance_vertex>
  2664. #ifdef USE_DISPLACEMENTMAP
  2665. #include <beginnormal_vertex>
  2666. #include <morphnormal_vertex>
  2667. #include <skinnormal_vertex>
  2668. #endif
  2669. #include <begin_vertex>
  2670. #include <morphtarget_vertex>
  2671. #include <skinning_vertex>
  2672. #include <displacementmap_vertex>
  2673. #include <project_vertex>
  2674. #include <worldpos_vertex>
  2675. #include <clipping_planes_vertex>
  2676. vWorldPosition = worldPosition.xyz;
  2677. }`,Bxe=`#define DISTANCE
  2678. uniform vec3 referencePosition;
  2679. uniform float nearDistance;
  2680. uniform float farDistance;
  2681. varying vec3 vWorldPosition;
  2682. #include <common>
  2683. #include <packing>
  2684. #include <uv_pars_fragment>
  2685. #include <map_pars_fragment>
  2686. #include <alphamap_pars_fragment>
  2687. #include <alphatest_pars_fragment>
  2688. #include <alphahash_pars_fragment>
  2689. #include <clipping_planes_pars_fragment>
  2690. void main () {
  2691. vec4 diffuseColor = vec4( 1.0 );
  2692. #include <clipping_planes_fragment>
  2693. #include <map_fragment>
  2694. #include <alphamap_fragment>
  2695. #include <alphatest_fragment>
  2696. #include <alphahash_fragment>
  2697. float dist = length( vWorldPosition - referencePosition );
  2698. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  2699. dist = saturate( dist );
  2700. gl_FragColor = packDepthToRGBA( dist );
  2701. }`,Hxe=`varying vec3 vWorldDirection;
  2702. #include <common>
  2703. void main() {
  2704. vWorldDirection = transformDirection( position, modelMatrix );
  2705. #include <begin_vertex>
  2706. #include <project_vertex>
  2707. }`,$xe=`uniform sampler2D tEquirect;
  2708. varying vec3 vWorldDirection;
  2709. #include <common>
  2710. void main() {
  2711. vec3 direction = normalize( vWorldDirection );
  2712. vec2 sampleUV = equirectUv( direction );
  2713. gl_FragColor = texture2D( tEquirect, sampleUV );
  2714. #include <tonemapping_fragment>
  2715. #include <colorspace_fragment>
  2716. }`,Vxe=`uniform float scale;
  2717. attribute float lineDistance;
  2718. varying float vLineDistance;
  2719. #include <common>
  2720. #include <uv_pars_vertex>
  2721. #include <color_pars_vertex>
  2722. #include <fog_pars_vertex>
  2723. #include <morphtarget_pars_vertex>
  2724. #include <logdepthbuf_pars_vertex>
  2725. #include <clipping_planes_pars_vertex>
  2726. void main() {
  2727. vLineDistance = scale * lineDistance;
  2728. #include <uv_vertex>
  2729. #include <color_vertex>
  2730. #include <morphinstance_vertex>
  2731. #include <morphcolor_vertex>
  2732. #include <begin_vertex>
  2733. #include <morphtarget_vertex>
  2734. #include <project_vertex>
  2735. #include <logdepthbuf_vertex>
  2736. #include <clipping_planes_vertex>
  2737. #include <fog_vertex>
  2738. }`,Gxe=`uniform vec3 diffuse;
  2739. uniform float opacity;
  2740. uniform float dashSize;
  2741. uniform float totalSize;
  2742. varying float vLineDistance;
  2743. #include <common>
  2744. #include <color_pars_fragment>
  2745. #include <uv_pars_fragment>
  2746. #include <map_pars_fragment>
  2747. #include <fog_pars_fragment>
  2748. #include <logdepthbuf_pars_fragment>
  2749. #include <clipping_planes_pars_fragment>
  2750. void main() {
  2751. vec4 diffuseColor = vec4( diffuse, opacity );
  2752. #include <clipping_planes_fragment>
  2753. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  2754. discard;
  2755. }
  2756. vec3 outgoingLight = vec3( 0.0 );
  2757. #include <logdepthbuf_fragment>
  2758. #include <map_fragment>
  2759. #include <color_fragment>
  2760. outgoingLight = diffuseColor.rgb;
  2761. #include <opaque_fragment>
  2762. #include <tonemapping_fragment>
  2763. #include <colorspace_fragment>
  2764. #include <fog_fragment>
  2765. #include <premultiplied_alpha_fragment>
  2766. }`,qxe=`#include <common>
  2767. #include <batching_pars_vertex>
  2768. #include <uv_pars_vertex>
  2769. #include <envmap_pars_vertex>
  2770. #include <color_pars_vertex>
  2771. #include <fog_pars_vertex>
  2772. #include <morphtarget_pars_vertex>
  2773. #include <skinning_pars_vertex>
  2774. #include <logdepthbuf_pars_vertex>
  2775. #include <clipping_planes_pars_vertex>
  2776. void main() {
  2777. #include <uv_vertex>
  2778. #include <color_vertex>
  2779. #include <morphinstance_vertex>
  2780. #include <morphcolor_vertex>
  2781. #include <batching_vertex>
  2782. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  2783. #include <beginnormal_vertex>
  2784. #include <morphnormal_vertex>
  2785. #include <skinbase_vertex>
  2786. #include <skinnormal_vertex>
  2787. #include <defaultnormal_vertex>
  2788. #endif
  2789. #include <begin_vertex>
  2790. #include <morphtarget_vertex>
  2791. #include <skinning_vertex>
  2792. #include <project_vertex>
  2793. #include <logdepthbuf_vertex>
  2794. #include <clipping_planes_vertex>
  2795. #include <worldpos_vertex>
  2796. #include <envmap_vertex>
  2797. #include <fog_vertex>
  2798. }`,Wxe=`uniform vec3 diffuse;
  2799. uniform float opacity;
  2800. #ifndef FLAT_SHADED
  2801. varying vec3 vNormal;
  2802. #endif
  2803. #include <common>
  2804. #include <dithering_pars_fragment>
  2805. #include <color_pars_fragment>
  2806. #include <uv_pars_fragment>
  2807. #include <map_pars_fragment>
  2808. #include <alphamap_pars_fragment>
  2809. #include <alphatest_pars_fragment>
  2810. #include <alphahash_pars_fragment>
  2811. #include <aomap_pars_fragment>
  2812. #include <lightmap_pars_fragment>
  2813. #include <envmap_common_pars_fragment>
  2814. #include <envmap_pars_fragment>
  2815. #include <fog_pars_fragment>
  2816. #include <specularmap_pars_fragment>
  2817. #include <logdepthbuf_pars_fragment>
  2818. #include <clipping_planes_pars_fragment>
  2819. void main() {
  2820. vec4 diffuseColor = vec4( diffuse, opacity );
  2821. #include <clipping_planes_fragment>
  2822. #include <logdepthbuf_fragment>
  2823. #include <map_fragment>
  2824. #include <color_fragment>
  2825. #include <alphamap_fragment>
  2826. #include <alphatest_fragment>
  2827. #include <alphahash_fragment>
  2828. #include <specularmap_fragment>
  2829. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2830. #ifdef USE_LIGHTMAP
  2831. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  2832. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  2833. #else
  2834. reflectedLight.indirectDiffuse += vec3( 1.0 );
  2835. #endif
  2836. #include <aomap_fragment>
  2837. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  2838. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  2839. #include <envmap_fragment>
  2840. #include <opaque_fragment>
  2841. #include <tonemapping_fragment>
  2842. #include <colorspace_fragment>
  2843. #include <fog_fragment>
  2844. #include <premultiplied_alpha_fragment>
  2845. #include <dithering_fragment>
  2846. }`,Kxe=`#define LAMBERT
  2847. varying vec3 vViewPosition;
  2848. #include <common>
  2849. #include <batching_pars_vertex>
  2850. #include <uv_pars_vertex>
  2851. #include <displacementmap_pars_vertex>
  2852. #include <envmap_pars_vertex>
  2853. #include <color_pars_vertex>
  2854. #include <fog_pars_vertex>
  2855. #include <normal_pars_vertex>
  2856. #include <morphtarget_pars_vertex>
  2857. #include <skinning_pars_vertex>
  2858. #include <shadowmap_pars_vertex>
  2859. #include <logdepthbuf_pars_vertex>
  2860. #include <clipping_planes_pars_vertex>
  2861. void main() {
  2862. #include <uv_vertex>
  2863. #include <color_vertex>
  2864. #include <morphinstance_vertex>
  2865. #include <morphcolor_vertex>
  2866. #include <batching_vertex>
  2867. #include <beginnormal_vertex>
  2868. #include <morphnormal_vertex>
  2869. #include <skinbase_vertex>
  2870. #include <skinnormal_vertex>
  2871. #include <defaultnormal_vertex>
  2872. #include <normal_vertex>
  2873. #include <begin_vertex>
  2874. #include <morphtarget_vertex>
  2875. #include <skinning_vertex>
  2876. #include <displacementmap_vertex>
  2877. #include <project_vertex>
  2878. #include <logdepthbuf_vertex>
  2879. #include <clipping_planes_vertex>
  2880. vViewPosition = - mvPosition.xyz;
  2881. #include <worldpos_vertex>
  2882. #include <envmap_vertex>
  2883. #include <shadowmap_vertex>
  2884. #include <fog_vertex>
  2885. }`,Xxe=`#define LAMBERT
  2886. uniform vec3 diffuse;
  2887. uniform vec3 emissive;
  2888. uniform float opacity;
  2889. #include <common>
  2890. #include <packing>
  2891. #include <dithering_pars_fragment>
  2892. #include <color_pars_fragment>
  2893. #include <uv_pars_fragment>
  2894. #include <map_pars_fragment>
  2895. #include <alphamap_pars_fragment>
  2896. #include <alphatest_pars_fragment>
  2897. #include <alphahash_pars_fragment>
  2898. #include <aomap_pars_fragment>
  2899. #include <lightmap_pars_fragment>
  2900. #include <emissivemap_pars_fragment>
  2901. #include <envmap_common_pars_fragment>
  2902. #include <envmap_pars_fragment>
  2903. #include <fog_pars_fragment>
  2904. #include <bsdfs>
  2905. #include <lights_pars_begin>
  2906. #include <normal_pars_fragment>
  2907. #include <lights_lambert_pars_fragment>
  2908. #include <shadowmap_pars_fragment>
  2909. #include <bumpmap_pars_fragment>
  2910. #include <normalmap_pars_fragment>
  2911. #include <specularmap_pars_fragment>
  2912. #include <logdepthbuf_pars_fragment>
  2913. #include <clipping_planes_pars_fragment>
  2914. void main() {
  2915. vec4 diffuseColor = vec4( diffuse, opacity );
  2916. #include <clipping_planes_fragment>
  2917. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  2918. vec3 totalEmissiveRadiance = emissive;
  2919. #include <logdepthbuf_fragment>
  2920. #include <map_fragment>
  2921. #include <color_fragment>
  2922. #include <alphamap_fragment>
  2923. #include <alphatest_fragment>
  2924. #include <alphahash_fragment>
  2925. #include <specularmap_fragment>
  2926. #include <normal_fragment_begin>
  2927. #include <normal_fragment_maps>
  2928. #include <emissivemap_fragment>
  2929. #include <lights_lambert_fragment>
  2930. #include <lights_fragment_begin>
  2931. #include <lights_fragment_maps>
  2932. #include <lights_fragment_end>
  2933. #include <aomap_fragment>
  2934. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  2935. #include <envmap_fragment>
  2936. #include <opaque_fragment>
  2937. #include <tonemapping_fragment>
  2938. #include <colorspace_fragment>
  2939. #include <fog_fragment>
  2940. #include <premultiplied_alpha_fragment>
  2941. #include <dithering_fragment>
  2942. }`,Yxe=`#define MATCAP
  2943. varying vec3 vViewPosition;
  2944. #include <common>
  2945. #include <batching_pars_vertex>
  2946. #include <uv_pars_vertex>
  2947. #include <color_pars_vertex>
  2948. #include <displacementmap_pars_vertex>
  2949. #include <fog_pars_vertex>
  2950. #include <normal_pars_vertex>
  2951. #include <morphtarget_pars_vertex>
  2952. #include <skinning_pars_vertex>
  2953. #include <logdepthbuf_pars_vertex>
  2954. #include <clipping_planes_pars_vertex>
  2955. void main() {
  2956. #include <uv_vertex>
  2957. #include <color_vertex>
  2958. #include <morphinstance_vertex>
  2959. #include <morphcolor_vertex>
  2960. #include <batching_vertex>
  2961. #include <beginnormal_vertex>
  2962. #include <morphnormal_vertex>
  2963. #include <skinbase_vertex>
  2964. #include <skinnormal_vertex>
  2965. #include <defaultnormal_vertex>
  2966. #include <normal_vertex>
  2967. #include <begin_vertex>
  2968. #include <morphtarget_vertex>
  2969. #include <skinning_vertex>
  2970. #include <displacementmap_vertex>
  2971. #include <project_vertex>
  2972. #include <logdepthbuf_vertex>
  2973. #include <clipping_planes_vertex>
  2974. #include <fog_vertex>
  2975. vViewPosition = - mvPosition.xyz;
  2976. }`,Qxe=`#define MATCAP
  2977. uniform vec3 diffuse;
  2978. uniform float opacity;
  2979. uniform sampler2D matcap;
  2980. varying vec3 vViewPosition;
  2981. #include <common>
  2982. #include <dithering_pars_fragment>
  2983. #include <color_pars_fragment>
  2984. #include <uv_pars_fragment>
  2985. #include <map_pars_fragment>
  2986. #include <alphamap_pars_fragment>
  2987. #include <alphatest_pars_fragment>
  2988. #include <alphahash_pars_fragment>
  2989. #include <fog_pars_fragment>
  2990. #include <normal_pars_fragment>
  2991. #include <bumpmap_pars_fragment>
  2992. #include <normalmap_pars_fragment>
  2993. #include <logdepthbuf_pars_fragment>
  2994. #include <clipping_planes_pars_fragment>
  2995. void main() {
  2996. vec4 diffuseColor = vec4( diffuse, opacity );
  2997. #include <clipping_planes_fragment>
  2998. #include <logdepthbuf_fragment>
  2999. #include <map_fragment>
  3000. #include <color_fragment>
  3001. #include <alphamap_fragment>
  3002. #include <alphatest_fragment>
  3003. #include <alphahash_fragment>
  3004. #include <normal_fragment_begin>
  3005. #include <normal_fragment_maps>
  3006. vec3 viewDir = normalize( vViewPosition );
  3007. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  3008. vec3 y = cross( viewDir, x );
  3009. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  3010. #ifdef USE_MATCAP
  3011. vec4 matcapColor = texture2D( matcap, uv );
  3012. #else
  3013. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  3014. #endif
  3015. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  3016. #include <opaque_fragment>
  3017. #include <tonemapping_fragment>
  3018. #include <colorspace_fragment>
  3019. #include <fog_fragment>
  3020. #include <premultiplied_alpha_fragment>
  3021. #include <dithering_fragment>
  3022. }`,Zxe=`#define NORMAL
  3023. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3024. varying vec3 vViewPosition;
  3025. #endif
  3026. #include <common>
  3027. #include <batching_pars_vertex>
  3028. #include <uv_pars_vertex>
  3029. #include <displacementmap_pars_vertex>
  3030. #include <normal_pars_vertex>
  3031. #include <morphtarget_pars_vertex>
  3032. #include <skinning_pars_vertex>
  3033. #include <logdepthbuf_pars_vertex>
  3034. #include <clipping_planes_pars_vertex>
  3035. void main() {
  3036. #include <uv_vertex>
  3037. #include <batching_vertex>
  3038. #include <beginnormal_vertex>
  3039. #include <morphinstance_vertex>
  3040. #include <morphnormal_vertex>
  3041. #include <skinbase_vertex>
  3042. #include <skinnormal_vertex>
  3043. #include <defaultnormal_vertex>
  3044. #include <normal_vertex>
  3045. #include <begin_vertex>
  3046. #include <morphtarget_vertex>
  3047. #include <skinning_vertex>
  3048. #include <displacementmap_vertex>
  3049. #include <project_vertex>
  3050. #include <logdepthbuf_vertex>
  3051. #include <clipping_planes_vertex>
  3052. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3053. vViewPosition = - mvPosition.xyz;
  3054. #endif
  3055. }`,Jxe=`#define NORMAL
  3056. uniform float opacity;
  3057. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  3058. varying vec3 vViewPosition;
  3059. #endif
  3060. #include <packing>
  3061. #include <uv_pars_fragment>
  3062. #include <normal_pars_fragment>
  3063. #include <bumpmap_pars_fragment>
  3064. #include <normalmap_pars_fragment>
  3065. #include <logdepthbuf_pars_fragment>
  3066. #include <clipping_planes_pars_fragment>
  3067. void main() {
  3068. vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
  3069. #include <clipping_planes_fragment>
  3070. #include <logdepthbuf_fragment>
  3071. #include <normal_fragment_begin>
  3072. #include <normal_fragment_maps>
  3073. gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
  3074. #ifdef OPAQUE
  3075. gl_FragColor.a = 1.0;
  3076. #endif
  3077. }`,ebe=`#define PHONG
  3078. varying vec3 vViewPosition;
  3079. #include <common>
  3080. #include <batching_pars_vertex>
  3081. #include <uv_pars_vertex>
  3082. #include <displacementmap_pars_vertex>
  3083. #include <envmap_pars_vertex>
  3084. #include <color_pars_vertex>
  3085. #include <fog_pars_vertex>
  3086. #include <normal_pars_vertex>
  3087. #include <morphtarget_pars_vertex>
  3088. #include <skinning_pars_vertex>
  3089. #include <shadowmap_pars_vertex>
  3090. #include <logdepthbuf_pars_vertex>
  3091. #include <clipping_planes_pars_vertex>
  3092. void main() {
  3093. #include <uv_vertex>
  3094. #include <color_vertex>
  3095. #include <morphcolor_vertex>
  3096. #include <batching_vertex>
  3097. #include <beginnormal_vertex>
  3098. #include <morphinstance_vertex>
  3099. #include <morphnormal_vertex>
  3100. #include <skinbase_vertex>
  3101. #include <skinnormal_vertex>
  3102. #include <defaultnormal_vertex>
  3103. #include <normal_vertex>
  3104. #include <begin_vertex>
  3105. #include <morphtarget_vertex>
  3106. #include <skinning_vertex>
  3107. #include <displacementmap_vertex>
  3108. #include <project_vertex>
  3109. #include <logdepthbuf_vertex>
  3110. #include <clipping_planes_vertex>
  3111. vViewPosition = - mvPosition.xyz;
  3112. #include <worldpos_vertex>
  3113. #include <envmap_vertex>
  3114. #include <shadowmap_vertex>
  3115. #include <fog_vertex>
  3116. }`,tbe=`#define PHONG
  3117. uniform vec3 diffuse;
  3118. uniform vec3 emissive;
  3119. uniform vec3 specular;
  3120. uniform float shininess;
  3121. uniform float opacity;
  3122. #include <common>
  3123. #include <packing>
  3124. #include <dithering_pars_fragment>
  3125. #include <color_pars_fragment>
  3126. #include <uv_pars_fragment>
  3127. #include <map_pars_fragment>
  3128. #include <alphamap_pars_fragment>
  3129. #include <alphatest_pars_fragment>
  3130. #include <alphahash_pars_fragment>
  3131. #include <aomap_pars_fragment>
  3132. #include <lightmap_pars_fragment>
  3133. #include <emissivemap_pars_fragment>
  3134. #include <envmap_common_pars_fragment>
  3135. #include <envmap_pars_fragment>
  3136. #include <fog_pars_fragment>
  3137. #include <bsdfs>
  3138. #include <lights_pars_begin>
  3139. #include <normal_pars_fragment>
  3140. #include <lights_phong_pars_fragment>
  3141. #include <shadowmap_pars_fragment>
  3142. #include <bumpmap_pars_fragment>
  3143. #include <normalmap_pars_fragment>
  3144. #include <specularmap_pars_fragment>
  3145. #include <logdepthbuf_pars_fragment>
  3146. #include <clipping_planes_pars_fragment>
  3147. void main() {
  3148. vec4 diffuseColor = vec4( diffuse, opacity );
  3149. #include <clipping_planes_fragment>
  3150. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3151. vec3 totalEmissiveRadiance = emissive;
  3152. #include <logdepthbuf_fragment>
  3153. #include <map_fragment>
  3154. #include <color_fragment>
  3155. #include <alphamap_fragment>
  3156. #include <alphatest_fragment>
  3157. #include <alphahash_fragment>
  3158. #include <specularmap_fragment>
  3159. #include <normal_fragment_begin>
  3160. #include <normal_fragment_maps>
  3161. #include <emissivemap_fragment>
  3162. #include <lights_phong_fragment>
  3163. #include <lights_fragment_begin>
  3164. #include <lights_fragment_maps>
  3165. #include <lights_fragment_end>
  3166. #include <aomap_fragment>
  3167. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  3168. #include <envmap_fragment>
  3169. #include <opaque_fragment>
  3170. #include <tonemapping_fragment>
  3171. #include <colorspace_fragment>
  3172. #include <fog_fragment>
  3173. #include <premultiplied_alpha_fragment>
  3174. #include <dithering_fragment>
  3175. }`,nbe=`#define STANDARD
  3176. varying vec3 vViewPosition;
  3177. #ifdef USE_TRANSMISSION
  3178. varying vec3 vWorldPosition;
  3179. #endif
  3180. #include <common>
  3181. #include <batching_pars_vertex>
  3182. #include <uv_pars_vertex>
  3183. #include <displacementmap_pars_vertex>
  3184. #include <color_pars_vertex>
  3185. #include <fog_pars_vertex>
  3186. #include <normal_pars_vertex>
  3187. #include <morphtarget_pars_vertex>
  3188. #include <skinning_pars_vertex>
  3189. #include <shadowmap_pars_vertex>
  3190. #include <logdepthbuf_pars_vertex>
  3191. #include <clipping_planes_pars_vertex>
  3192. void main() {
  3193. #include <uv_vertex>
  3194. #include <color_vertex>
  3195. #include <morphinstance_vertex>
  3196. #include <morphcolor_vertex>
  3197. #include <batching_vertex>
  3198. #include <beginnormal_vertex>
  3199. #include <morphnormal_vertex>
  3200. #include <skinbase_vertex>
  3201. #include <skinnormal_vertex>
  3202. #include <defaultnormal_vertex>
  3203. #include <normal_vertex>
  3204. #include <begin_vertex>
  3205. #include <morphtarget_vertex>
  3206. #include <skinning_vertex>
  3207. #include <displacementmap_vertex>
  3208. #include <project_vertex>
  3209. #include <logdepthbuf_vertex>
  3210. #include <clipping_planes_vertex>
  3211. vViewPosition = - mvPosition.xyz;
  3212. #include <worldpos_vertex>
  3213. #include <shadowmap_vertex>
  3214. #include <fog_vertex>
  3215. #ifdef USE_TRANSMISSION
  3216. vWorldPosition = worldPosition.xyz;
  3217. #endif
  3218. }`,rbe=`#define STANDARD
  3219. #ifdef PHYSICAL
  3220. #define IOR
  3221. #define USE_SPECULAR
  3222. #endif
  3223. uniform vec3 diffuse;
  3224. uniform vec3 emissive;
  3225. uniform float roughness;
  3226. uniform float metalness;
  3227. uniform float opacity;
  3228. #ifdef IOR
  3229. uniform float ior;
  3230. #endif
  3231. #ifdef USE_SPECULAR
  3232. uniform float specularIntensity;
  3233. uniform vec3 specularColor;
  3234. #ifdef USE_SPECULAR_COLORMAP
  3235. uniform sampler2D specularColorMap;
  3236. #endif
  3237. #ifdef USE_SPECULAR_INTENSITYMAP
  3238. uniform sampler2D specularIntensityMap;
  3239. #endif
  3240. #endif
  3241. #ifdef USE_CLEARCOAT
  3242. uniform float clearcoat;
  3243. uniform float clearcoatRoughness;
  3244. #endif
  3245. #ifdef USE_DISPERSION
  3246. uniform float dispersion;
  3247. #endif
  3248. #ifdef USE_IRIDESCENCE
  3249. uniform float iridescence;
  3250. uniform float iridescenceIOR;
  3251. uniform float iridescenceThicknessMinimum;
  3252. uniform float iridescenceThicknessMaximum;
  3253. #endif
  3254. #ifdef USE_SHEEN
  3255. uniform vec3 sheenColor;
  3256. uniform float sheenRoughness;
  3257. #ifdef USE_SHEEN_COLORMAP
  3258. uniform sampler2D sheenColorMap;
  3259. #endif
  3260. #ifdef USE_SHEEN_ROUGHNESSMAP
  3261. uniform sampler2D sheenRoughnessMap;
  3262. #endif
  3263. #endif
  3264. #ifdef USE_ANISOTROPY
  3265. uniform vec2 anisotropyVector;
  3266. #ifdef USE_ANISOTROPYMAP
  3267. uniform sampler2D anisotropyMap;
  3268. #endif
  3269. #endif
  3270. varying vec3 vViewPosition;
  3271. #include <common>
  3272. #include <packing>
  3273. #include <dithering_pars_fragment>
  3274. #include <color_pars_fragment>
  3275. #include <uv_pars_fragment>
  3276. #include <map_pars_fragment>
  3277. #include <alphamap_pars_fragment>
  3278. #include <alphatest_pars_fragment>
  3279. #include <alphahash_pars_fragment>
  3280. #include <aomap_pars_fragment>
  3281. #include <lightmap_pars_fragment>
  3282. #include <emissivemap_pars_fragment>
  3283. #include <iridescence_fragment>
  3284. #include <cube_uv_reflection_fragment>
  3285. #include <envmap_common_pars_fragment>
  3286. #include <envmap_physical_pars_fragment>
  3287. #include <fog_pars_fragment>
  3288. #include <lights_pars_begin>
  3289. #include <normal_pars_fragment>
  3290. #include <lights_physical_pars_fragment>
  3291. #include <transmission_pars_fragment>
  3292. #include <shadowmap_pars_fragment>
  3293. #include <bumpmap_pars_fragment>
  3294. #include <normalmap_pars_fragment>
  3295. #include <clearcoat_pars_fragment>
  3296. #include <iridescence_pars_fragment>
  3297. #include <roughnessmap_pars_fragment>
  3298. #include <metalnessmap_pars_fragment>
  3299. #include <logdepthbuf_pars_fragment>
  3300. #include <clipping_planes_pars_fragment>
  3301. void main() {
  3302. vec4 diffuseColor = vec4( diffuse, opacity );
  3303. #include <clipping_planes_fragment>
  3304. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3305. vec3 totalEmissiveRadiance = emissive;
  3306. #include <logdepthbuf_fragment>
  3307. #include <map_fragment>
  3308. #include <color_fragment>
  3309. #include <alphamap_fragment>
  3310. #include <alphatest_fragment>
  3311. #include <alphahash_fragment>
  3312. #include <roughnessmap_fragment>
  3313. #include <metalnessmap_fragment>
  3314. #include <normal_fragment_begin>
  3315. #include <normal_fragment_maps>
  3316. #include <clearcoat_normal_fragment_begin>
  3317. #include <clearcoat_normal_fragment_maps>
  3318. #include <emissivemap_fragment>
  3319. #include <lights_physical_fragment>
  3320. #include <lights_fragment_begin>
  3321. #include <lights_fragment_maps>
  3322. #include <lights_fragment_end>
  3323. #include <aomap_fragment>
  3324. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  3325. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  3326. #include <transmission_fragment>
  3327. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  3328. #ifdef USE_SHEEN
  3329. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  3330. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  3331. #endif
  3332. #ifdef USE_CLEARCOAT
  3333. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  3334. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  3335. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  3336. #endif
  3337. #include <opaque_fragment>
  3338. #include <tonemapping_fragment>
  3339. #include <colorspace_fragment>
  3340. #include <fog_fragment>
  3341. #include <premultiplied_alpha_fragment>
  3342. #include <dithering_fragment>
  3343. }`,ibe=`#define TOON
  3344. varying vec3 vViewPosition;
  3345. #include <common>
  3346. #include <batching_pars_vertex>
  3347. #include <uv_pars_vertex>
  3348. #include <displacementmap_pars_vertex>
  3349. #include <color_pars_vertex>
  3350. #include <fog_pars_vertex>
  3351. #include <normal_pars_vertex>
  3352. #include <morphtarget_pars_vertex>
  3353. #include <skinning_pars_vertex>
  3354. #include <shadowmap_pars_vertex>
  3355. #include <logdepthbuf_pars_vertex>
  3356. #include <clipping_planes_pars_vertex>
  3357. void main() {
  3358. #include <uv_vertex>
  3359. #include <color_vertex>
  3360. #include <morphinstance_vertex>
  3361. #include <morphcolor_vertex>
  3362. #include <batching_vertex>
  3363. #include <beginnormal_vertex>
  3364. #include <morphnormal_vertex>
  3365. #include <skinbase_vertex>
  3366. #include <skinnormal_vertex>
  3367. #include <defaultnormal_vertex>
  3368. #include <normal_vertex>
  3369. #include <begin_vertex>
  3370. #include <morphtarget_vertex>
  3371. #include <skinning_vertex>
  3372. #include <displacementmap_vertex>
  3373. #include <project_vertex>
  3374. #include <logdepthbuf_vertex>
  3375. #include <clipping_planes_vertex>
  3376. vViewPosition = - mvPosition.xyz;
  3377. #include <worldpos_vertex>
  3378. #include <shadowmap_vertex>
  3379. #include <fog_vertex>
  3380. }`,abe=`#define TOON
  3381. uniform vec3 diffuse;
  3382. uniform vec3 emissive;
  3383. uniform float opacity;
  3384. #include <common>
  3385. #include <packing>
  3386. #include <dithering_pars_fragment>
  3387. #include <color_pars_fragment>
  3388. #include <uv_pars_fragment>
  3389. #include <map_pars_fragment>
  3390. #include <alphamap_pars_fragment>
  3391. #include <alphatest_pars_fragment>
  3392. #include <alphahash_pars_fragment>
  3393. #include <aomap_pars_fragment>
  3394. #include <lightmap_pars_fragment>
  3395. #include <emissivemap_pars_fragment>
  3396. #include <gradientmap_pars_fragment>
  3397. #include <fog_pars_fragment>
  3398. #include <bsdfs>
  3399. #include <lights_pars_begin>
  3400. #include <normal_pars_fragment>
  3401. #include <lights_toon_pars_fragment>
  3402. #include <shadowmap_pars_fragment>
  3403. #include <bumpmap_pars_fragment>
  3404. #include <normalmap_pars_fragment>
  3405. #include <logdepthbuf_pars_fragment>
  3406. #include <clipping_planes_pars_fragment>
  3407. void main() {
  3408. vec4 diffuseColor = vec4( diffuse, opacity );
  3409. #include <clipping_planes_fragment>
  3410. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  3411. vec3 totalEmissiveRadiance = emissive;
  3412. #include <logdepthbuf_fragment>
  3413. #include <map_fragment>
  3414. #include <color_fragment>
  3415. #include <alphamap_fragment>
  3416. #include <alphatest_fragment>
  3417. #include <alphahash_fragment>
  3418. #include <normal_fragment_begin>
  3419. #include <normal_fragment_maps>
  3420. #include <emissivemap_fragment>
  3421. #include <lights_toon_fragment>
  3422. #include <lights_fragment_begin>
  3423. #include <lights_fragment_maps>
  3424. #include <lights_fragment_end>
  3425. #include <aomap_fragment>
  3426. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  3427. #include <opaque_fragment>
  3428. #include <tonemapping_fragment>
  3429. #include <colorspace_fragment>
  3430. #include <fog_fragment>
  3431. #include <premultiplied_alpha_fragment>
  3432. #include <dithering_fragment>
  3433. }`,sbe=`uniform float size;
  3434. uniform float scale;
  3435. #include <common>
  3436. #include <color_pars_vertex>
  3437. #include <fog_pars_vertex>
  3438. #include <morphtarget_pars_vertex>
  3439. #include <logdepthbuf_pars_vertex>
  3440. #include <clipping_planes_pars_vertex>
  3441. #ifdef USE_POINTS_UV
  3442. varying vec2 vUv;
  3443. uniform mat3 uvTransform;
  3444. #endif
  3445. void main() {
  3446. #ifdef USE_POINTS_UV
  3447. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  3448. #endif
  3449. #include <color_vertex>
  3450. #include <morphinstance_vertex>
  3451. #include <morphcolor_vertex>
  3452. #include <begin_vertex>
  3453. #include <morphtarget_vertex>
  3454. #include <project_vertex>
  3455. gl_PointSize = size;
  3456. #ifdef USE_SIZEATTENUATION
  3457. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3458. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  3459. #endif
  3460. #include <logdepthbuf_vertex>
  3461. #include <clipping_planes_vertex>
  3462. #include <worldpos_vertex>
  3463. #include <fog_vertex>
  3464. }`,obe=`uniform vec3 diffuse;
  3465. uniform float opacity;
  3466. #include <common>
  3467. #include <color_pars_fragment>
  3468. #include <map_particle_pars_fragment>
  3469. #include <alphatest_pars_fragment>
  3470. #include <alphahash_pars_fragment>
  3471. #include <fog_pars_fragment>
  3472. #include <logdepthbuf_pars_fragment>
  3473. #include <clipping_planes_pars_fragment>
  3474. void main() {
  3475. vec4 diffuseColor = vec4( diffuse, opacity );
  3476. #include <clipping_planes_fragment>
  3477. vec3 outgoingLight = vec3( 0.0 );
  3478. #include <logdepthbuf_fragment>
  3479. #include <map_particle_fragment>
  3480. #include <color_fragment>
  3481. #include <alphatest_fragment>
  3482. #include <alphahash_fragment>
  3483. outgoingLight = diffuseColor.rgb;
  3484. #include <opaque_fragment>
  3485. #include <tonemapping_fragment>
  3486. #include <colorspace_fragment>
  3487. #include <fog_fragment>
  3488. #include <premultiplied_alpha_fragment>
  3489. }`,lbe=`#include <common>
  3490. #include <batching_pars_vertex>
  3491. #include <fog_pars_vertex>
  3492. #include <morphtarget_pars_vertex>
  3493. #include <skinning_pars_vertex>
  3494. #include <logdepthbuf_pars_vertex>
  3495. #include <shadowmap_pars_vertex>
  3496. void main() {
  3497. #include <batching_vertex>
  3498. #include <beginnormal_vertex>
  3499. #include <morphinstance_vertex>
  3500. #include <morphnormal_vertex>
  3501. #include <skinbase_vertex>
  3502. #include <skinnormal_vertex>
  3503. #include <defaultnormal_vertex>
  3504. #include <begin_vertex>
  3505. #include <morphtarget_vertex>
  3506. #include <skinning_vertex>
  3507. #include <project_vertex>
  3508. #include <logdepthbuf_vertex>
  3509. #include <worldpos_vertex>
  3510. #include <shadowmap_vertex>
  3511. #include <fog_vertex>
  3512. }`,cbe=`uniform vec3 color;
  3513. uniform float opacity;
  3514. #include <common>
  3515. #include <packing>
  3516. #include <fog_pars_fragment>
  3517. #include <bsdfs>
  3518. #include <lights_pars_begin>
  3519. #include <logdepthbuf_pars_fragment>
  3520. #include <shadowmap_pars_fragment>
  3521. #include <shadowmask_pars_fragment>
  3522. void main() {
  3523. #include <logdepthbuf_fragment>
  3524. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  3525. #include <tonemapping_fragment>
  3526. #include <colorspace_fragment>
  3527. #include <fog_fragment>
  3528. }`,ube=`uniform float rotation;
  3529. uniform vec2 center;
  3530. #include <common>
  3531. #include <uv_pars_vertex>
  3532. #include <fog_pars_vertex>
  3533. #include <logdepthbuf_pars_vertex>
  3534. #include <clipping_planes_pars_vertex>
  3535. void main() {
  3536. #include <uv_vertex>
  3537. vec4 mvPosition = modelViewMatrix[ 3 ];
  3538. vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
  3539. #ifndef USE_SIZEATTENUATION
  3540. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  3541. if ( isPerspective ) scale *= - mvPosition.z;
  3542. #endif
  3543. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  3544. vec2 rotatedPosition;
  3545. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  3546. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  3547. mvPosition.xy += rotatedPosition;
  3548. gl_Position = projectionMatrix * mvPosition;
  3549. #include <logdepthbuf_vertex>
  3550. #include <clipping_planes_vertex>
  3551. #include <fog_vertex>
  3552. }`,dbe=`uniform vec3 diffuse;
  3553. uniform float opacity;
  3554. #include <common>
  3555. #include <uv_pars_fragment>
  3556. #include <map_pars_fragment>
  3557. #include <alphamap_pars_fragment>
  3558. #include <alphatest_pars_fragment>
  3559. #include <alphahash_pars_fragment>
  3560. #include <fog_pars_fragment>
  3561. #include <logdepthbuf_pars_fragment>
  3562. #include <clipping_planes_pars_fragment>
  3563. void main() {
  3564. vec4 diffuseColor = vec4( diffuse, opacity );
  3565. #include <clipping_planes_fragment>
  3566. vec3 outgoingLight = vec3( 0.0 );
  3567. #include <logdepthbuf_fragment>
  3568. #include <map_fragment>
  3569. #include <alphamap_fragment>
  3570. #include <alphatest_fragment>
  3571. #include <alphahash_fragment>
  3572. outgoingLight = diffuseColor.rgb;
  3573. #include <opaque_fragment>
  3574. #include <tonemapping_fragment>
  3575. #include <colorspace_fragment>
  3576. #include <fog_fragment>
  3577. }`,Tn={alphahash_fragment:Dpe,alphahash_pars_fragment:Rpe,alphamap_fragment:Ope,alphamap_pars_fragment:Lpe,alphatest_fragment:Fpe,alphatest_pars_fragment:Ipe,aomap_fragment:Upe,aomap_pars_fragment:zpe,batching_pars_vertex:Bpe,batching_vertex:Hpe,begin_vertex:$pe,beginnormal_vertex:Vpe,bsdfs:Gpe,iridescence_fragment:qpe,bumpmap_pars_fragment:Wpe,clipping_planes_fragment:Kpe,clipping_planes_pars_fragment:Xpe,clipping_planes_pars_vertex:Ype,clipping_planes_vertex:Qpe,color_fragment:Zpe,color_pars_fragment:Jpe,color_pars_vertex:ege,color_vertex:tge,common:nge,cube_uv_reflection_fragment:rge,defaultnormal_vertex:ige,displacementmap_pars_vertex:age,displacementmap_vertex:sge,emissivemap_fragment:oge,emissivemap_pars_fragment:lge,colorspace_fragment:cge,colorspace_pars_fragment:uge,envmap_fragment:dge,envmap_common_pars_fragment:hge,envmap_pars_fragment:fge,envmap_pars_vertex:mge,envmap_physical_pars_fragment:Mge,envmap_vertex:pge,fog_vertex:gge,fog_pars_vertex:xge,fog_fragment:bge,fog_pars_fragment:yge,gradientmap_pars_fragment:vge,lightmap_pars_fragment:wge,lights_lambert_fragment:_ge,lights_lambert_pars_fragment:Sge,lights_pars_begin:Nge,lights_toon_fragment:kge,lights_toon_pars_fragment:Ege,lights_phong_fragment:Tge,lights_phong_pars_fragment:Age,lights_physical_fragment:Cge,lights_physical_pars_fragment:jge,lights_fragment_begin:Pge,lights_fragment_maps:Dge,lights_fragment_end:Rge,logdepthbuf_fragment:Oge,logdepthbuf_pars_fragment:Lge,logdepthbuf_pars_vertex:Fge,logdepthbuf_vertex:Ige,map_fragment:Uge,map_pars_fragment:zge,map_particle_fragment:Bge,map_particle_pars_fragment:Hge,metalnessmap_fragment:$ge,metalnessmap_pars_fragment:Vge,morphinstance_vertex:Gge,morphcolor_vertex:qge,morphnormal_vertex:Wge,morphtarget_pars_vertex:Kge,morphtarget_vertex:Xge,normal_fragment_begin:Yge,normal_fragment_maps:Qge,normal_pars_fragment:Zge,normal_pars_vertex:Jge,normal_vertex:exe,normalmap_pars_fragment:txe,clearcoat_normal_fragment_begin:nxe,clearcoat_normal_fragment_maps:rxe,clearcoat_pars_fragment:ixe,iridescence_pars_fragment:axe,opaque_fragment:sxe,packing:oxe,premultiplied_alpha_fragment:lxe,project_vertex:cxe,dithering_fragment:uxe,dithering_pars_fragment:dxe,roughnessmap_fragment:hxe,roughnessmap_pars_fragment:fxe,shadowmap_pars_fragment:mxe,shadowmap_pars_vertex:pxe,shadowmap_vertex:gxe,shadowmask_pars_fragment:xxe,skinbase_vertex:bxe,skinning_pars_vertex:yxe,skinning_vertex:vxe,skinnormal_vertex:wxe,specularmap_fragment:_xe,specularmap_pars_fragment:Sxe,tonemapping_fragment:Nxe,tonemapping_pars_fragment:Mxe,transmission_fragment:kxe,transmission_pars_fragment:Exe,uv_pars_fragment:Txe,uv_pars_vertex:Axe,uv_vertex:Cxe,worldpos_vertex:jxe,background_vert:Pxe,background_frag:Dxe,backgroundCube_vert:Rxe,backgroundCube_frag:Oxe,cube_vert:Lxe,cube_frag:Fxe,depth_vert:Ixe,depth_frag:Uxe,distanceRGBA_vert:zxe,distanceRGBA_frag:Bxe,equirect_vert:Hxe,equirect_frag:$xe,linedashed_vert:Vxe,linedashed_frag:Gxe,meshbasic_vert:qxe,meshbasic_frag:Wxe,meshlambert_vert:Kxe,meshlambert_frag:Xxe,meshmatcap_vert:Yxe,meshmatcap_frag:Qxe,meshnormal_vert:Zxe,meshnormal_frag:Jxe,meshphong_vert:ebe,meshphong_frag:tbe,meshphysical_vert:nbe,meshphysical_frag:rbe,meshtoon_vert:ibe,meshtoon_frag:abe,points_vert:sbe,points_frag:obe,shadow_vert:lbe,shadow_frag:cbe,sprite_vert:ube,sprite_frag:dbe},Ft={common:{diffuse:{value:new Rn(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Dn},alphaMap:{value:null},alphaMapTransform:{value:new Dn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Dn}},envmap:{envMap:{value:null},envMapRotation:{value:new Dn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Dn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Dn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Dn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Dn},normalScale:{value:new Cn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Dn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Dn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Dn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Dn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new 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 Dn},alphaTest:{value:0},uvTransform:{value:new Dn}},sprite:{diffuse:{value:new Rn(16777215)},opacity:{value:1},center:{value:new Cn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Dn},alphaMap:{value:null},alphaMapTransform:{value:new Dn},alphaTest:{value:0}}},ic={basic:{uniforms:us([Ft.common,Ft.specularmap,Ft.envmap,Ft.aomap,Ft.lightmap,Ft.fog]),vertexShader:Tn.meshbasic_vert,fragmentShader:Tn.meshbasic_frag},lambert:{uniforms:us([Ft.common,Ft.specularmap,Ft.envmap,Ft.aomap,Ft.lightmap,Ft.emissivemap,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,Ft.fog,Ft.lights,{emissive:{value:new Rn(0)}}]),vertexShader:Tn.meshlambert_vert,fragmentShader:Tn.meshlambert_frag},phong:{uniforms:us([Ft.common,Ft.specularmap,Ft.envmap,Ft.aomap,Ft.lightmap,Ft.emissivemap,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,Ft.fog,Ft.lights,{emissive:{value:new Rn(0)},specular:{value:new Rn(1118481)},shininess:{value:30}}]),vertexShader:Tn.meshphong_vert,fragmentShader:Tn.meshphong_frag},standard:{uniforms:us([Ft.common,Ft.envmap,Ft.aomap,Ft.lightmap,Ft.emissivemap,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,Ft.roughnessmap,Ft.metalnessmap,Ft.fog,Ft.lights,{emissive:{value:new Rn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Tn.meshphysical_vert,fragmentShader:Tn.meshphysical_frag},toon:{uniforms:us([Ft.common,Ft.aomap,Ft.lightmap,Ft.emissivemap,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,Ft.gradientmap,Ft.fog,Ft.lights,{emissive:{value:new Rn(0)}}]),vertexShader:Tn.meshtoon_vert,fragmentShader:Tn.meshtoon_frag},matcap:{uniforms:us([Ft.common,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,Ft.fog,{matcap:{value:null}}]),vertexShader:Tn.meshmatcap_vert,fragmentShader:Tn.meshmatcap_frag},points:{uniforms:us([Ft.points,Ft.fog]),vertexShader:Tn.points_vert,fragmentShader:Tn.points_frag},dashed:{uniforms:us([Ft.common,Ft.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Tn.linedashed_vert,fragmentShader:Tn.linedashed_frag},depth:{uniforms:us([Ft.common,Ft.displacementmap]),vertexShader:Tn.depth_vert,fragmentShader:Tn.depth_frag},normal:{uniforms:us([Ft.common,Ft.bumpmap,Ft.normalmap,Ft.displacementmap,{opacity:{value:1}}]),vertexShader:Tn.meshnormal_vert,fragmentShader:Tn.meshnormal_frag},sprite:{uniforms:us([Ft.sprite,Ft.fog]),vertexShader:Tn.sprite_vert,fragmentShader:Tn.sprite_frag},background:{uniforms:{uvTransform:{value:new Dn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Tn.background_vert,fragmentShader:Tn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Dn}},vertexShader:Tn.backgroundCube_vert,fragmentShader:Tn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Tn.cube_vert,fragmentShader:Tn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Tn.equirect_vert,fragmentShader:Tn.equirect_frag},distanceRGBA:{uniforms:us([Ft.common,Ft.displacementmap,{referencePosition:{value:new mt},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Tn.distanceRGBA_vert,fragmentShader:Tn.distanceRGBA_frag},shadow:{uniforms:us([Ft.lights,Ft.fog,{color:{value:new Rn(0)},opacity:{value:1}}]),vertexShader:Tn.shadow_vert,fragmentShader:Tn.shadow_frag}};ic.physical={uniforms:us([ic.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Dn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Dn},clearcoatNormalScale:{value:new Cn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Dn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Dn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Dn},sheen:{value:0},sheenColor:{value:new Rn(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Dn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Dn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Dn},transmissionSamplerSize:{value:new Cn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Dn},attenuationDistance:{value:0},attenuationColor:{value:new Rn(0)},specularColor:{value:new Rn(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Dn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Dn},anisotropyVector:{value:new Cn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Dn}}]),vertexShader:Tn.meshphysical_vert,fragmentShader:Tn.meshphysical_frag};const n_={r:0,b:0,g:0},ff=new Nh,hbe=new Gi;function fbe(t,e,n,r,i,s,o){const l=new Rn(0);let c=s===!0?0:1,u,d,h=null,p=0,m=null;function x(N){let T=N.isScene===!0?N.background:null;return T&&T.isTexture&&(T=(N.backgroundBlurriness>0?n:e).get(T)),T}function y(N){let T=!1;const k=x(N);k===null?b(l,c):k&&k.isColor&&(b(k,1),T=!0);const C=t.xr.getEnvironmentBlendMode();C==="additive"?r.buffers.color.setClear(0,0,0,1,o):C==="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 v(N,T){const k=x(T);k&&(k.isCubeTexture||k.mapping===wM)?(d===void 0&&(d=new dl(new ZR(1,1,1),new Fu({name:"BackgroundCubeMaterial",uniforms:Xg(ic.backgroundCube.uniforms),vertexShader:ic.backgroundCube.vertexShader,fragmentShader:ic.backgroundCube.fragmentShader,side:Bs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(C,E,P){this.matrixWorld.copyPosition(P.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),ff.copy(T.backgroundRotation),ff.x*=-1,ff.y*=-1,ff.z*=-1,k.isCubeTexture&&k.isRenderTargetTexture===!1&&(ff.y*=-1,ff.z*=-1),d.material.uniforms.envMap.value=k,d.material.uniforms.flipEnvMap.value=k.isCubeTexture&&k.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(hbe.makeRotationFromEuler(ff)),d.material.toneMapped=cr.getTransfer(k.colorSpace)!==Mr,(h!==k||p!==k.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,h=k,p=k.version,m=t.toneMapping),d.layers.enableAll(),N.unshift(d,d.geometry,d.material,0,0,null)):k&&k.isTexture&&(u===void 0&&(u=new dl(new eO(2,2),new Fu({name:"BackgroundMaterial",uniforms:Xg(ic.background.uniforms),vertexShader:ic.background.vertexShader,fragmentShader:ic.background.fragmentShader,side:Sh,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=k,u.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,u.material.toneMapped=cr.getTransfer(k.colorSpace)!==Mr,k.matrixAutoUpdate===!0&&k.updateMatrix(),u.material.uniforms.uvTransform.value.copy(k.matrix),(h!==k||p!==k.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,h=k,p=k.version,m=t.toneMapping),u.layers.enableAll(),N.unshift(u,u.geometry,u.material,0,0,null))}function b(N,T){N.getRGB(n_,pK(t)),r.buffers.color.setClear(n_.r,n_.g,n_.b,T,o)}function S(){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(N,T=1){l.set(N),c=T,b(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(N){c=N,b(l,c)},render:y,addToRenderList:v,dispose:S}}function mbe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=p(null);let s=i,o=!1;function l(D,I,L,U,j){let V=!1;const K=h(U,L,I);s!==K&&(s=K,u(s.object)),V=m(D,U,L,j),V&&x(D,U,L,j),j!==null&&e.update(j,t.ELEMENT_ARRAY_BUFFER),(V||o)&&(o=!1,T(D,I,L,U),j!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(j).buffer))}function c(){return t.createVertexArray()}function u(D){return t.bindVertexArray(D)}function d(D){return t.deleteVertexArray(D)}function h(D,I,L){const U=L.wireframe===!0;let j=r[D.id];j===void 0&&(j={},r[D.id]=j);let V=j[I.id];V===void 0&&(V={},j[I.id]=V);let K=V[U];return K===void 0&&(K=p(c()),V[U]=K),K}function p(D){const I=[],L=[],U=[];for(let j=0;j<n;j++)I[j]=0,L[j]=0,U[j]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:L,attributeDivisors:U,object:D,attributes:{},index:null}}function m(D,I,L,U){const j=s.attributes,V=I.attributes;let K=0;const z=L.getAttributes();for(const X in z)if(z[X].location>=0){const te=j[X];let $=V[X];if($===void 0&&(X==="instanceMatrix"&&D.instanceMatrix&&($=D.instanceMatrix),X==="instanceColor"&&D.instanceColor&&($=D.instanceColor)),te===void 0||te.attribute!==$||$&&te.data!==$.data)return!0;K++}return s.attributesNum!==K||s.index!==U}function x(D,I,L,U){const j={},V=I.attributes;let K=0;const z=L.getAttributes();for(const X in z)if(z[X].location>=0){let te=V[X];te===void 0&&(X==="instanceMatrix"&&D.instanceMatrix&&(te=D.instanceMatrix),X==="instanceColor"&&D.instanceColor&&(te=D.instanceColor));const $={};$.attribute=te,te&&te.data&&($.data=te.data),j[X]=$,K++}s.attributes=j,s.attributesNum=K,s.index=U}function y(){const D=s.newAttributes;for(let I=0,L=D.length;I<L;I++)D[I]=0}function v(D){b(D,0)}function b(D,I){const L=s.newAttributes,U=s.enabledAttributes,j=s.attributeDivisors;L[D]=1,U[D]===0&&(t.enableVertexAttribArray(D),U[D]=1),j[D]!==I&&(t.vertexAttribDivisor(D,I),j[D]=I)}function S(){const D=s.newAttributes,I=s.enabledAttributes;for(let L=0,U=I.length;L<U;L++)I[L]!==D[L]&&(t.disableVertexAttribArray(L),I[L]=0)}function N(D,I,L,U,j,V,K){K===!0?t.vertexAttribIPointer(D,I,L,j,V):t.vertexAttribPointer(D,I,L,U,j,V)}function T(D,I,L,U){y();const j=U.attributes,V=L.getAttributes(),K=I.defaultAttributeValues;for(const z in V){const X=V[z];if(X.location>=0){let Y=j[z];if(Y===void 0&&(z==="instanceMatrix"&&D.instanceMatrix&&(Y=D.instanceMatrix),z==="instanceColor"&&D.instanceColor&&(Y=D.instanceColor)),Y!==void 0){const te=Y.normalized,$=Y.itemSize,W=e.get(Y);if(W===void 0)continue;const ne=W.buffer,re=W.type,ge=W.bytesPerElement,me=re===t.INT||re===t.UNSIGNED_INT||Y.gpuType===HR;if(Y.isInterleavedBufferAttribute){const ue=Y.data,Te=ue.stride,ie=Y.offset;if(ue.isInstancedInterleavedBuffer){for(let Ce=0;Ce<X.locationSize;Ce++)b(X.location+Ce,ue.meshPerAttribute);D.isInstancedMesh!==!0&&U._maxInstanceCount===void 0&&(U._maxInstanceCount=ue.meshPerAttribute*ue.count)}else for(let Ce=0;Ce<X.locationSize;Ce++)v(X.location+Ce);t.bindBuffer(t.ARRAY_BUFFER,ne);for(let Ce=0;Ce<X.locationSize;Ce++)N(X.location+Ce,$/X.locationSize,re,te,Te*ge,(ie+$/X.locationSize*Ce)*ge,me)}else{if(Y.isInstancedBufferAttribute){for(let ue=0;ue<X.locationSize;ue++)b(X.location+ue,Y.meshPerAttribute);D.isInstancedMesh!==!0&&U._maxInstanceCount===void 0&&(U._maxInstanceCount=Y.meshPerAttribute*Y.count)}else for(let ue=0;ue<X.locationSize;ue++)v(X.location+ue);t.bindBuffer(t.ARRAY_BUFFER,ne);for(let ue=0;ue<X.locationSize;ue++)N(X.location+ue,$/X.locationSize,re,te,$*ge,$/X.locationSize*ue*ge,me)}}else if(K!==void 0){const te=K[z];if(te!==void 0)switch(te.length){case 2:t.vertexAttrib2fv(X.location,te);break;case 3:t.vertexAttrib3fv(X.location,te);break;case 4:t.vertexAttrib4fv(X.location,te);break;default:t.vertexAttrib1fv(X.location,te)}}}}S()}function k(){P();for(const D in r){const I=r[D];for(const L in I){const U=I[L];for(const j in U)d(U[j].object),delete U[j];delete I[L]}delete r[D]}}function C(D){if(r[D.id]===void 0)return;const I=r[D.id];for(const L in I){const U=I[L];for(const j in U)d(U[j].object),delete U[j];delete I[L]}delete r[D.id]}function E(D){for(const I in r){const L=r[I];if(L[D.id]===void 0)continue;const U=L[D.id];for(const j in U)d(U[j].object),delete U[j];delete L[D.id]}}function P(){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:P,resetDefaultState:A,dispose:k,releaseStatesOfGeometry:C,releaseStatesOfProgram:E,initAttributes:y,enableAttribute:v,disableUnusedAttributes:S}}function pbe(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,h){h!==0&&(t.drawArraysInstanced(r,u,d,h),n.update(d,r,h))}function l(u,d,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,h);let m=0;for(let x=0;x<h;x++)m+=d[x];n.update(m,r,1)}function c(u,d,h,p){if(h===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let x=0;x<u.length;x++)o(u[x],d[x],p[x]);else{m.multiDrawArraysInstancedWEBGL(r,u,0,d,0,p,0,h);let x=0;for(let y=0;y<h;y++)x+=d[y]*p[y];n.update(x,r,1)}}this.setMode=i,this.render=s,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function gbe(t,e,n,r){let i;function s(){if(i!==void 0)return i;if(e.has("EXT_texture_filter_anisotropic")===!0){const E=e.get("EXT_texture_filter_anisotropic");i=t.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function o(E){return!(E!==Ol&&r.convert(E)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(E){const P=E===wx&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(E!==yc&&r.convert(E)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&E!==wu&&!P)}function c(E){if(E==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="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&&(pn("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const h=n.logarithmicDepthBuffer===!0,p=n.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),m=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),x=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),y=t.getParameter(t.MAX_TEXTURE_SIZE),v=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),b=t.getParameter(t.MAX_VERTEX_ATTRIBS),S=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),N=t.getParameter(t.MAX_VARYING_VECTORS),T=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),k=x>0,C=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:h,reversedDepthBuffer:p,maxTextures:m,maxVertexTextures:x,maxTextureSize:y,maxCubemapSize:v,maxAttributes:b,maxVertexUniforms:S,maxVaryings:N,maxFragmentUniforms:T,vertexTextures:k,maxSamples:C}}function xbe(t){const e=this;let n=null,r=0,i=!1,s=!1;const o=new zd,l=new Dn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,p){const m=h.length!==0||p||r!==0||i;return i=p,r=h.length,m},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,p){n=d(h,p,0)},this.setState=function(h,p,m){const x=h.clippingPlanes,y=h.clipIntersection,v=h.clipShadows,b=t.get(h);if(!i||x===null||x.length===0||s&&!v)s?d(null):u();else{const S=s?0:r,N=S*4;let T=b.clippingState||null;c.value=T,T=d(x,p,N,m);for(let k=0;k!==N;++k)T[k]=n[k];b.clippingState=T,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=S}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(h,p,m,x){const y=h!==null?h.length:0;let v=null;if(y!==0){if(v=c.value,x!==!0||v===null){const b=m+y*4,S=p.matrixWorldInverse;l.getNormalMatrix(S),(v===null||v.length<b)&&(v=new Float32Array(b));for(let N=0,T=m;N!==y;++N,T+=4)o.copy(h[N]).applyMatrix4(S,l),o.normal.toArray(v,T),v[T+3]=o.constant}c.value=v,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,v}}function bbe(t){let e=new WeakMap;function n(o,l){return l===CP?o.mapping=qg:l===jP&&(o.mapping=Wg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===CP||l===jP)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 upe(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 Zd=4,TB=[.125,.215,.35,.446,.526,.582],Ef=20,ybe=256,zb=new NK,AB=new Rn;let PT=null,DT=0,RT=0,OT=!1;const vbe=new mt;let CB=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=vbe}=s;PT=this._renderer.getRenderTarget(),DT=this._renderer.getActiveCubeFace(),RT=this._renderer.getActiveMipmapLevel(),OT=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=DB(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=PB(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(PT,DT,RT),this._renderer.xr.enabled=OT,e.scissorTest=!1,jp(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===qg||e.mapping===Wg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),PT=this._renderer.getRenderTarget(),DT=this._renderer.getActiveCubeFace(),RT=this._renderer.getActiveMipmapLevel(),OT=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:rl,minFilter:rl,generateMipmaps:!1,type:wx,format:Ol,colorSpace:Kg,depthBuffer:!1},i=jB(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=jB(e,n,r);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=wbe(s)),this._blurMaterial=Sbe(s,e,n),this._ggxMaterial=_be(s,e,n)}return i}_compileMaterial(e){const n=new dl(new ul,e);this._renderer.compile(n,zb)}_sceneToCubeUV(e,n,r,i,s){const c=new Qo(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],h=this._renderer,p=h.autoClear,m=h.toneMapping;h.getClearColor(AB),h.toneMapping=lh,h.autoClear=!1,h.state.buffers.depth.getReversed()&&(h.setRenderTarget(i),h.clearDepth(),h.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new dl(new ZR,new QR({name:"PMREM.Background",side:Bs,depthWrite:!1,depthTest:!1})));const y=this._backgroundBox,v=y.material;let b=!1;const S=e.background;S?S.isColor&&(v.color.copy(S),e.background=null,b=!0):(v.color.copy(AB),b=!0);for(let N=0;N<6;N++){const T=N%3;T===0?(c.up.set(0,u[N],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+d[N],s.y,s.z)):T===1?(c.up.set(0,0,u[N]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+d[N],s.z)):(c.up.set(0,u[N],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+d[N]));const k=this._cubeSize;jp(i,T*k,N>2?k:0,k,k),h.setRenderTarget(i),b&&h.render(y,c),h.render(e,c)}h.toneMapping=m,h.autoClear=p,e.background=S}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===qg||e.mapping===Wg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=DB()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=PB());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;jp(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,zb)}_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),h=Math.sqrt(u*u-d*d),p=.05+u*.95,m=h*p,{_lodMax:x}=this,y=this._sizeLods[r],v=3*y*(r>x-Zd?r-x+Zd:0),b=4*(this._cubeSize-y);c.envMap.value=e.texture,c.roughness.value=m,c.mipInt.value=x-n,jp(s,v,b,3*y,2*y),i.setRenderTarget(s),i.render(l,zb),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=x-r,jp(e,v,b,3*y,2*y),i.setRenderTarget(e),i.render(l,zb)}_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"&&Ti("blur direction must be either latitudinal or longitudinal!");const d=3,h=this._lodMeshes[i];h.material=u;const p=u.uniforms,m=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*Ef-1),y=s/x,v=isFinite(s)?1+Math.floor(d*y):Ef;v>Ef&&pn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Ef}`);const b=[];let S=0;for(let E=0;E<Ef;++E){const P=E/y,A=Math.exp(-P*P/2);b.push(A),E===0?S+=A:E<v&&(S+=2*A)}for(let E=0;E<b.length;E++)b[E]=b[E]/S;p.envMap.value=e.texture,p.samples.value=v,p.weights.value=b,p.latitudinal.value=o==="latitudinal",l&&(p.poleAxis.value=l);const{_lodMax:N}=this;p.dTheta.value=x,p.mipInt.value=N-r;const T=this._sizeLods[i],k=3*T*(i>N-Zd?i-N+Zd:0),C=4*(this._cubeSize-T);jp(n,k,C,3*T,2*T),c.setRenderTarget(n),c.render(h,zb)}};function wbe(t){const e=[],n=[],r=[];let i=t;const s=t-Zd+1+TB.length;for(let o=0;o<s;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-Zd?c=TB[o-t+Zd-1]:o===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,h=1+u,p=[d,d,h,d,h,h,d,d,h,h,d,h],m=6,x=6,y=3,v=2,b=1,S=new Float32Array(y*x*m),N=new Float32Array(v*x*m),T=new Float32Array(b*x*m);for(let C=0;C<m;C++){const E=C%3*2/3-1,P=C>2?0:-1,A=[E,P,0,E+2/3,P,0,E+2/3,P+1,0,E,P,0,E+2/3,P+1,0,E,P+1,0];S.set(A,y*x*C),N.set(p,v*x*C);const D=[C,C,C,C,C,C];T.set(D,b*x*C)}const k=new ul;k.setAttribute("position",new bs(S,y)),k.setAttribute("uv",new bs(N,v)),k.setAttribute("faceIndex",new bs(T,b)),r.push(new dl(k,null)),i>Zd&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function jB(t,e,n){const r=new hm(t,e,n);return r.texture.mapping=wM,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function jp(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function _be(t,e,n){return new Fu({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:ybe,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:SM(),fragmentShader:`
  3578. precision highp float;
  3579. precision highp int;
  3580. varying vec3 vOutputDirection;
  3581. uniform sampler2D envMap;
  3582. uniform float roughness;
  3583. uniform float mipInt;
  3584. #define ENVMAP_TYPE_CUBE_UV
  3585. #include <cube_uv_reflection_fragment>
  3586. #define PI 3.14159265359
  3587. // Van der Corput radical inverse
  3588. float radicalInverse_VdC(uint bits) {
  3589. bits = (bits << 16u) | (bits >> 16u);
  3590. bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
  3591. bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
  3592. bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
  3593. bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
  3594. return float(bits) * 2.3283064365386963e-10; // / 0x100000000
  3595. }
  3596. // Hammersley sequence
  3597. vec2 hammersley(uint i, uint N) {
  3598. return vec2(float(i) / float(N), radicalInverse_VdC(i));
  3599. }
  3600. // GGX VNDF importance sampling (Eric Heitz 2018)
  3601. // "Sampling the GGX Distribution of Visible Normals"
  3602. // https://jcgt.org/published/0007/04/01/
  3603. vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
  3604. float alpha = roughness * roughness;
  3605. // Section 3.2: Transform view direction to hemisphere configuration
  3606. vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
  3607. // Section 4.1: Orthonormal basis
  3608. float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
  3609. vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
  3610. vec3 T2 = cross(Vh, T1);
  3611. // Section 4.2: Parameterization of projected area
  3612. float r = sqrt(Xi.x);
  3613. float phi = 2.0 * PI * Xi.y;
  3614. float t1 = r * cos(phi);
  3615. float t2 = r * sin(phi);
  3616. float s = 0.5 * (1.0 + Vh.z);
  3617. t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
  3618. // Section 4.3: Reprojection onto hemisphere
  3619. vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
  3620. // Section 3.4: Transform back to ellipsoid configuration
  3621. return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
  3622. }
  3623. void main() {
  3624. vec3 N = normalize(vOutputDirection);
  3625. vec3 V = N; // Assume view direction equals normal for pre-filtering
  3626. vec3 prefilteredColor = vec3(0.0);
  3627. float totalWeight = 0.0;
  3628. // For very low roughness, just sample the environment directly
  3629. if (roughness < 0.001) {
  3630. gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
  3631. return;
  3632. }
  3633. // Tangent space basis for VNDF sampling
  3634. vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
  3635. vec3 tangent = normalize(cross(up, N));
  3636. vec3 bitangent = cross(N, tangent);
  3637. for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
  3638. vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
  3639. // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
  3640. vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
  3641. // Transform H back to world space
  3642. vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
  3643. vec3 L = normalize(2.0 * dot(V, H) * H - V);
  3644. float NdotL = max(dot(N, L), 0.0);
  3645. if(NdotL > 0.0) {
  3646. // Sample environment at fixed mip level
  3647. // VNDF importance sampling handles the distribution filtering
  3648. vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
  3649. // Weight by NdotL for the split-sum approximation
  3650. // VNDF PDF naturally accounts for the visible microfacet distribution
  3651. prefilteredColor += sampleColor * NdotL;
  3652. totalWeight += NdotL;
  3653. }
  3654. }
  3655. if (totalWeight > 0.0) {
  3656. prefilteredColor = prefilteredColor / totalWeight;
  3657. }
  3658. gl_FragColor = vec4(prefilteredColor, 1.0);
  3659. }
  3660. `,blending:Tu,depthTest:!1,depthWrite:!1})}function Sbe(t,e,n){const r=new Float32Array(Ef),i=new mt(0,1,0);return new Fu({name:"SphericalGaussianBlur",defines:{n:Ef,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:SM(),fragmentShader:`
  3661. precision mediump float;
  3662. precision mediump int;
  3663. varying vec3 vOutputDirection;
  3664. uniform sampler2D envMap;
  3665. uniform int samples;
  3666. uniform float weights[ n ];
  3667. uniform bool latitudinal;
  3668. uniform float dTheta;
  3669. uniform float mipInt;
  3670. uniform vec3 poleAxis;
  3671. #define ENVMAP_TYPE_CUBE_UV
  3672. #include <cube_uv_reflection_fragment>
  3673. vec3 getSample( float theta, vec3 axis ) {
  3674. float cosTheta = cos( theta );
  3675. // Rodrigues' axis-angle rotation
  3676. vec3 sampleDirection = vOutputDirection * cosTheta
  3677. + cross( axis, vOutputDirection ) * sin( theta )
  3678. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  3679. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  3680. }
  3681. void main() {
  3682. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  3683. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  3684. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  3685. }
  3686. axis = normalize( axis );
  3687. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  3688. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  3689. for ( int i = 1; i < n; i++ ) {
  3690. if ( i >= samples ) {
  3691. break;
  3692. }
  3693. float theta = dTheta * float( i );
  3694. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  3695. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  3696. }
  3697. }
  3698. `,blending:Tu,depthTest:!1,depthWrite:!1})}function PB(){return new Fu({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:SM(),fragmentShader:`
  3699. precision mediump float;
  3700. precision mediump int;
  3701. varying vec3 vOutputDirection;
  3702. uniform sampler2D envMap;
  3703. #include <common>
  3704. void main() {
  3705. vec3 outputDirection = normalize( vOutputDirection );
  3706. vec2 uv = equirectUv( outputDirection );
  3707. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  3708. }
  3709. `,blending:Tu,depthTest:!1,depthWrite:!1})}function DB(){return new Fu({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:SM(),fragmentShader:`
  3710. precision mediump float;
  3711. precision mediump int;
  3712. uniform float flipEnvMap;
  3713. varying vec3 vOutputDirection;
  3714. uniform samplerCube envMap;
  3715. void main() {
  3716. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  3717. }
  3718. `,blending:Tu,depthTest:!1,depthWrite:!1})}function SM(){return`
  3719. precision mediump float;
  3720. precision mediump int;
  3721. attribute float faceIndex;
  3722. varying vec3 vOutputDirection;
  3723. // RH coordinate system; PMREM face-indexing convention
  3724. vec3 getDirection( vec2 uv, float face ) {
  3725. uv = 2.0 * uv - 1.0;
  3726. vec3 direction = vec3( uv, 1.0 );
  3727. if ( face == 0.0 ) {
  3728. direction = direction.zyx; // ( 1, v, u ) pos x
  3729. } else if ( face == 1.0 ) {
  3730. direction = direction.xzy;
  3731. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  3732. } else if ( face == 2.0 ) {
  3733. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  3734. } else if ( face == 3.0 ) {
  3735. direction = direction.zyx;
  3736. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  3737. } else if ( face == 4.0 ) {
  3738. direction = direction.xzy;
  3739. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  3740. } else if ( face == 5.0 ) {
  3741. direction.z *= -1.0; // ( u, v, -1 ) neg z
  3742. }
  3743. return direction;
  3744. }
  3745. void main() {
  3746. vOutputDirection = getDirection( uv, faceIndex );
  3747. gl_Position = vec4( position, 1.0 );
  3748. }
  3749. `}function Nbe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===CP||c===jP,d=c===qg||c===Wg;if(u||d){let h=e.get(l);const p=h!==void 0?h.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==p)return n===null&&(n=new CB(t)),h=u?n.fromEquirectangular(l,h):n.fromCubemap(l,h),h.texture.pmremVersion=l.pmremVersion,e.set(l,h),h.texture;if(h!==void 0)return h.texture;{const m=l.image;return u&&m&&m.height>0||d&&m&&i(m)?(n===null&&(n=new CB(t)),h=u?n.fromEquirectangular(l):n.fromCubemap(l),h.texture.pmremVersion=l.pmremVersion,e.set(l,h),l.addEventListener("dispose",s),h.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 Mbe(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&&ey("WebGLRenderer: "+r+" extension not supported."),i}}}function kbe(t,e,n,r){const i={},s=new WeakMap;function o(h){const p=h.target;p.index!==null&&e.remove(p.index);for(const x in p.attributes)e.remove(p.attributes[x]);p.removeEventListener("dispose",o),delete i[p.id];const m=s.get(p);m&&(e.remove(m),s.delete(p)),r.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function l(h,p){return i[p.id]===!0||(p.addEventListener("dispose",o),i[p.id]=!0,n.memory.geometries++),p}function c(h){const p=h.attributes;for(const m in p)e.update(p[m],t.ARRAY_BUFFER)}function u(h){const p=[],m=h.index,x=h.attributes.position;let y=0;if(m!==null){const S=m.array;y=m.version;for(let N=0,T=S.length;N<T;N+=3){const k=S[N+0],C=S[N+1],E=S[N+2];p.push(k,C,C,E,E,k)}}else if(x!==void 0){const S=x.array;y=x.version;for(let N=0,T=S.length/3-1;N<T;N+=3){const k=N+0,C=N+1,E=N+2;p.push(k,C,C,E,E,k)}}else return;const v=new(nK(p)?hK:dK)(p,1);v.version=y;const b=s.get(h);b&&e.remove(b),s.set(h,v)}function d(h){const p=s.get(h);if(p){const m=h.index;m!==null&&p.version<m.version&&u(h)}else u(h);return s.get(h)}return{get:l,update:c,getWireframeAttribute:d}}function Ebe(t,e,n){let r;function i(p){r=p}let s,o;function l(p){s=p.type,o=p.bytesPerElement}function c(p,m){t.drawElements(r,m,s,p*o),n.update(m,r,1)}function u(p,m,x){x!==0&&(t.drawElementsInstanced(r,m,s,p*o,x),n.update(m,r,x))}function d(p,m,x){if(x===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,m,0,s,p,0,x);let v=0;for(let b=0;b<x;b++)v+=m[b];n.update(v,r,1)}function h(p,m,x,y){if(x===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let b=0;b<p.length;b++)u(p[b]/o,m[b],y[b]);else{v.multiDrawElementsInstancedWEBGL(r,m,0,s,p,0,y,0,x);let b=0;for(let S=0;S<x;S++)b+=m[S]*y[S];n.update(b,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=h}function Tbe(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:Ti("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 Abe(t,e,n){const r=new WeakMap,i=new Bi;function s(o,l,c){const u=o.morphTargetInfluences,d=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,h=d!==void 0?d.length:0;let p=r.get(l);if(p===void 0||p.count!==h){let D=function(){P.dispose(),r.delete(l),l.removeEventListener("dispose",D)};var m=D;p!==void 0&&p.texture.dispose();const x=l.morphAttributes.position!==void 0,y=l.morphAttributes.normal!==void 0,v=l.morphAttributes.color!==void 0,b=l.morphAttributes.position||[],S=l.morphAttributes.normal||[],N=l.morphAttributes.color||[];let T=0;x===!0&&(T=1),y===!0&&(T=2),v===!0&&(T=3);let k=l.attributes.position.count*T,C=1;k>e.maxTextureSize&&(C=Math.ceil(k/e.maxTextureSize),k=e.maxTextureSize);const E=new Float32Array(k*C*4*h),P=new oK(E,k,C,h);P.type=wu,P.needsUpdate=!0;const A=T*4;for(let I=0;I<h;I++){const L=b[I],U=S[I],j=N[I],V=k*C*4*I;for(let K=0;K<L.count;K++){const z=K*A;x===!0&&(i.fromBufferAttribute(L,K),E[V+z+0]=i.x,E[V+z+1]=i.y,E[V+z+2]=i.z,E[V+z+3]=0),y===!0&&(i.fromBufferAttribute(U,K),E[V+z+4]=i.x,E[V+z+5]=i.y,E[V+z+6]=i.z,E[V+z+7]=0),v===!0&&(i.fromBufferAttribute(j,K),E[V+z+8]=i.x,E[V+z+9]=i.y,E[V+z+10]=i.z,E[V+z+11]=j.itemSize===4?i.w:1)}}p={count:h,texture:P,size:new Cn(k,C)},r.set(l,p),l.addEventListener("dispose",D)}if(o.isInstancedMesh===!0&&o.morphTexture!==null)c.getUniforms().setValue(t,"morphTexture",o.morphTexture,n);else{let x=0;for(let v=0;v<u.length;v++)x+=u[v];const y=l.morphTargetsRelative?1:1-x;c.getUniforms().setValue(t,"morphTargetBaseInfluence",y),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",p.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",p.size)}return{update:s}}function Cbe(t,e,n,r){let i=new WeakMap;function s(c){const u=r.render.frame,d=c.geometry,h=e.get(c,d);if(i.get(h)!==u&&(e.update(h),i.set(h,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 p=c.skeleton;i.get(p)!==u&&(p.update(),i.set(p,u))}return h}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 kK=new $l,RB=new yK(1,1),EK=new oK,TK=new Wme,AK=new xK,OB=[],LB=[],FB=new Float32Array(16),IB=new Float32Array(9),UB=new Float32Array(4);function Sx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=OB[i];if(s===void 0&&(s=new Float32Array(i),OB[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 ta(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 na(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function NM(t,e){let n=LB[e];n===void 0&&(n=new Int32Array(e),LB[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function jbe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function Pbe(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(ta(n,e))return;t.uniform2fv(this.addr,e),na(n,e)}}function Dbe(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(ta(n,e))return;t.uniform3fv(this.addr,e),na(n,e)}}function Rbe(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(ta(n,e))return;t.uniform4fv(this.addr,e),na(n,e)}}function Obe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ta(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),na(n,e)}else{if(ta(n,r))return;UB.set(r),t.uniformMatrix2fv(this.addr,!1,UB),na(n,r)}}function Lbe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ta(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),na(n,e)}else{if(ta(n,r))return;IB.set(r),t.uniformMatrix3fv(this.addr,!1,IB),na(n,r)}}function Fbe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ta(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),na(n,e)}else{if(ta(n,r))return;FB.set(r),t.uniformMatrix4fv(this.addr,!1,FB),na(n,r)}}function Ibe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function Ube(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(ta(n,e))return;t.uniform2iv(this.addr,e),na(n,e)}}function zbe(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(ta(n,e))return;t.uniform3iv(this.addr,e),na(n,e)}}function Bbe(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(ta(n,e))return;t.uniform4iv(this.addr,e),na(n,e)}}function Hbe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function $be(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(ta(n,e))return;t.uniform2uiv(this.addr,e),na(n,e)}}function Vbe(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(ta(n,e))return;t.uniform3uiv(this.addr,e),na(n,e)}}function Gbe(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(ta(n,e))return;t.uniform4uiv(this.addr,e),na(n,e)}}function qbe(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?(RB.compareFunction=tK,s=RB):s=kK,n.setTexture2D(e||s,i)}function Wbe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||TK,i)}function Kbe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||AK,i)}function Xbe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||EK,i)}function Ybe(t){switch(t){case 5126:return jbe;case 35664:return Pbe;case 35665:return Dbe;case 35666:return Rbe;case 35674:return Obe;case 35675:return Lbe;case 35676:return Fbe;case 5124:case 35670:return Ibe;case 35667:case 35671:return Ube;case 35668:case 35672:return zbe;case 35669:case 35673:return Bbe;case 5125:return Hbe;case 36294:return $be;case 36295:return Vbe;case 36296:return Gbe;case 35678:case 36198:case 36298:case 36306:case 35682:return qbe;case 35679:case 36299:case 36307:return Wbe;case 35680:case 36300:case 36308:case 36293:return Kbe;case 36289:case 36303:case 36311:case 36292:return Xbe}}function Qbe(t,e){t.uniform1fv(this.addr,e)}function Zbe(t,e){const n=Sx(e,this.size,2);t.uniform2fv(this.addr,n)}function Jbe(t,e){const n=Sx(e,this.size,3);t.uniform3fv(this.addr,n)}function e0e(t,e){const n=Sx(e,this.size,4);t.uniform4fv(this.addr,n)}function t0e(t,e){const n=Sx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function n0e(t,e){const n=Sx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function r0e(t,e){const n=Sx(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function i0e(t,e){t.uniform1iv(this.addr,e)}function a0e(t,e){t.uniform2iv(this.addr,e)}function s0e(t,e){t.uniform3iv(this.addr,e)}function o0e(t,e){t.uniform4iv(this.addr,e)}function l0e(t,e){t.uniform1uiv(this.addr,e)}function c0e(t,e){t.uniform2uiv(this.addr,e)}function u0e(t,e){t.uniform3uiv(this.addr,e)}function d0e(t,e){t.uniform4uiv(this.addr,e)}function h0e(t,e,n){const r=this.cache,i=e.length,s=NM(n,i);ta(r,s)||(t.uniform1iv(this.addr,s),na(r,s));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||kK,s[o])}function f0e(t,e,n){const r=this.cache,i=e.length,s=NM(n,i);ta(r,s)||(t.uniform1iv(this.addr,s),na(r,s));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||TK,s[o])}function m0e(t,e,n){const r=this.cache,i=e.length,s=NM(n,i);ta(r,s)||(t.uniform1iv(this.addr,s),na(r,s));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||AK,s[o])}function p0e(t,e,n){const r=this.cache,i=e.length,s=NM(n,i);ta(r,s)||(t.uniform1iv(this.addr,s),na(r,s));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||EK,s[o])}function g0e(t){switch(t){case 5126:return Qbe;case 35664:return Zbe;case 35665:return Jbe;case 35666:return e0e;case 35674:return t0e;case 35675:return n0e;case 35676:return r0e;case 5124:case 35670:return i0e;case 35667:case 35671:return a0e;case 35668:case 35672:return s0e;case 35669:case 35673:return o0e;case 5125:return l0e;case 36294:return c0e;case 36295:return u0e;case 36296:return d0e;case 35678:case 36198:case 36298:case 36306:case 35682:return h0e;case 35679:case 36299:case 36307:return f0e;case 35680:case 36300:case 36308:case 36293:return m0e;case 36289:case 36303:case 36311:case 36292:return p0e}}let x0e=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=Ybe(n.type)}},b0e=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=g0e(n.type)}},y0e=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 LT=/(\w+)(\])?(\[|\.)?/g;function zB(t,e){t.seq.push(e),t.map[e.id]=e}function v0e(t,e,n){const r=t.name,i=r.length;for(LT.lastIndex=0;;){const s=LT.exec(r),o=LT.lastIndex;let l=s[1];const c=s[2]==="]",u=s[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){zB(n,u===void 0?new x0e(l,t,e):new b0e(l,t,e));break}else{let h=n.map[l];h===void 0&&(h=new y0e(l),zB(n,h)),n=h}}}let k1=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);v0e(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 BB(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const w0e=37297;let _0e=0;function S0e(t,e){const n=t.split(`
  3750. `),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(`
  3751. `)}const HB=new Dn;function N0e(t){cr._getMatrix(HB,cr.workingColorSpace,t);const e=`mat3( ${HB.elements.map(n=>n.toFixed(4))} )`;switch(cr.getTransfer(t)){case Q1:return[e,"LinearTransferOETF"];case Mr:return[e,"sRGBTransferOETF"];default:return pn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function $B(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()+`
  3752. `+s+`
  3753. `+S0e(t.getShaderSource(e),l)}else return s}function M0e(t,e){const n=N0e(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
  3754. `)}function k0e(t,e){let n;switch(e){case vme:n="Linear";break;case wme:n="Reinhard";break;case _me:n="Cineon";break;case Sme:n="ACESFilmic";break;case Mme:n="AgX";break;case kme:n="Neutral";break;case Nme:n="Custom";break;default:pn("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const r_=new mt;function E0e(){cr.getLuminanceCoefficients(r_);const t=r_.x.toFixed(4),e=r_.y.toFixed(4),n=r_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
  3755. `)}function T0e(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(s0).join(`
  3756. `)}function A0e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  3757. `)}function C0e(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 s0(t){return t!==""}function VB(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 GB(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const j0e=/^[ \t]*#include +<([\w\d./]+)>/gm;function u3(t){return t.replace(j0e,D0e)}const P0e=new Map;function D0e(t,e){let n=Tn[e];if(n===void 0){const r=P0e.get(e);if(r!==void 0)n=Tn[r],pn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return u3(n)}const R0e=/#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 qB(t){return t.replace(R0e,O0e)}function O0e(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 WB(t){let e=`precision ${t.precision} float;
  3758. precision ${t.precision} int;
  3759. precision ${t.precision} sampler2D;
  3760. precision ${t.precision} samplerCube;
  3761. precision ${t.precision} sampler3D;
  3762. precision ${t.precision} sampler2DArray;
  3763. precision ${t.precision} sampler2DShadow;
  3764. precision ${t.precision} samplerCubeShadow;
  3765. precision ${t.precision} sampler2DArrayShadow;
  3766. precision ${t.precision} isampler2D;
  3767. precision ${t.precision} isampler3D;
  3768. precision ${t.precision} isamplerCube;
  3769. precision ${t.precision} isampler2DArray;
  3770. precision ${t.precision} usampler2D;
  3771. precision ${t.precision} usampler3D;
  3772. precision ${t.precision} usamplerCube;
  3773. precision ${t.precision} usampler2DArray;
  3774. `;return t.precision==="highp"?e+=`
  3775. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  3776. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  3777. #define LOW_PRECISION`),e}function L0e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===GW?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===Jfe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===uu&&(e="SHADOWMAP_TYPE_VSM"),e}function F0e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case qg:case Wg:e="ENVMAP_TYPE_CUBE";break;case wM:e="ENVMAP_TYPE_CUBE_UV";break}return e}function I0e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Wg:e="ENVMAP_MODE_REFRACTION";break}return e}function U0e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case BR:e="ENVMAP_BLENDING_MULTIPLY";break;case bme:e="ENVMAP_BLENDING_MIX";break;case yme:e="ENVMAP_BLENDING_ADD";break}return e}function z0e(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 B0e(t,e,n,r){const i=t.getContext(),s=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=L0e(n),u=F0e(n),d=I0e(n),h=U0e(n),p=z0e(n),m=T0e(n),x=A0e(s),y=i.createProgram();let v,b,S=n.glslVersion?"#version "+n.glslVersion+`
  3778. `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(s0).join(`
  3779. `),v.length>0&&(v+=`
  3780. `),b=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(s0).join(`
  3781. `),b.length>0&&(b+=`
  3782. `)):(v=[WB(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",`
  3783. `].filter(s0).join(`
  3784. `),b=[WB(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 "+h:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.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!==lh?"#define TONE_MAPPING":"",n.toneMapping!==lh?Tn.tonemapping_pars_fragment:"",n.toneMapping!==lh?k0e("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Tn.colorspace_pars_fragment,M0e("linearToOutputTexel",n.outputColorSpace),E0e(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  3785. `].filter(s0).join(`
  3786. `)),o=u3(o),o=VB(o,n),o=GB(o,n),l=u3(l),l=VB(l,n),l=GB(l,n),o=qB(o),l=qB(l),n.isRawShaderMaterial!==!0&&(S=`#version 300 es
  3787. `,v=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
  3788. `)+`
  3789. `+v,b=["#define varying in",n.glslVersion===Jz?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Jz?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
  3790. `)+`
  3791. `+b);const N=S+v+o,T=S+b+l,k=BB(i,i.VERTEX_SHADER,N),C=BB(i,i.FRAGMENT_SHADER,T);i.attachShader(y,k),i.attachShader(y,C),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function E(I){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(y)||"",U=i.getShaderInfoLog(k)||"",j=i.getShaderInfoLog(C)||"",V=L.trim(),K=U.trim(),z=j.trim();let X=!0,Y=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(X=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,k,C);else{const te=$B(i,k,"vertex"),$=$B(i,C,"fragment");Ti("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
  3792. Material Name: `+I.name+`
  3793. Material Type: `+I.type+`
  3794. Program Info Log: `+V+`
  3795. `+te+`
  3796. `+$)}else V!==""?pn("WebGLProgram: Program Info Log:",V):(K===""||z==="")&&(Y=!1);Y&&(I.diagnostics={runnable:X,programLog:V,vertexShader:{log:K,prefix:v},fragmentShader:{log:z,prefix:b}})}i.deleteShader(k),i.deleteShader(C),P=new k1(i,y),A=C0e(i,y)}let P;this.getUniforms=function(){return P===void 0&&E(this),P};let A;this.getAttributes=function(){return A===void 0&&E(this),A};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(y,w0e)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=_0e++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=k,this.fragmentShader=C,this}let H0e=0,$0e=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 V0e(e),n.set(e,r)),r}},V0e=class{constructor(e){this.id=H0e++,this.code=e,this.usedTimes=0}};function G0e(t,e,n,r,i,s,o){const l=new cK,c=new $0e,u=new Set,d=[],h=i.logarithmicDepthBuffer,p=i.vertexTextures;let m=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 v(A,D,I,L,U){const j=L.fog,V=U.geometry,K=A.isMeshStandardMaterial?L.environment:null,z=(A.isMeshStandardMaterial?n:e).get(A.envMap||K),X=z&&z.mapping===wM?z.image.height:null,Y=x[A.type];A.precision!==null&&(m=i.getMaxPrecision(A.precision),m!==A.precision&&pn("WebGLProgram.getParameters:",A.precision,"not supported, using",m,"instead."));const te=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,$=te!==void 0?te.length:0;let W=0;V.morphAttributes.position!==void 0&&(W=1),V.morphAttributes.normal!==void 0&&(W=2),V.morphAttributes.color!==void 0&&(W=3);let ne,re,ge,me;if(Y){const at=ic[Y];ne=at.vertexShader,re=at.fragmentShader}else ne=A.vertexShader,re=A.fragmentShader,c.update(A),ge=c.getVertexShaderID(A),me=c.getFragmentShaderID(A);const ue=t.getRenderTarget(),Te=t.state.buffers.depth.getReversed(),ie=U.isInstancedMesh===!0,Ce=U.isBatchedMesh===!0,Fe=!!A.map,xe=!!A.matcap,Ze=!!z,G=!!A.aoMap,Q=!!A.lightMap,de=!!A.bumpMap,q=!!A.normalMap,ee=!!A.displacementMap,B=!!A.emissiveMap,he=!!A.metalnessMap,ke=!!A.roughnessMap,pe=A.anisotropy>0,H=A.clearcoat>0,O=A.dispersion>0,J=A.iridescence>0,le=A.sheen>0,Se=A.transmission>0,we=pe&&!!A.anisotropyMap,ae=H&&!!A.clearcoatMap,Le=H&&!!A.clearcoatNormalMap,Be=H&&!!A.clearcoatRoughnessMap,Ve=J&&!!A.iridescenceMap,He=J&&!!A.iridescenceThicknessMap,be=le&&!!A.sheenColorMap,Pe=le&&!!A.sheenRoughnessMap,Ie=!!A.specularMap,_e=!!A.specularColorMap,Ke=!!A.specularIntensityMap,Me=Se&&!!A.transmissionMap,it=Se&&!!A.thicknessMap,Ee=!!A.gradientMap,Xe=!!A.alphaMap,ze=A.alphaTest>0,ce=!!A.alphaHash,$e=!!A.extensions;let ye=lh;A.toneMapped&&(ue===null||ue.isXRRenderTarget===!0)&&(ye=t.toneMapping);const Je={shaderID:Y,shaderType:A.type,shaderName:A.name,vertexShader:ne,fragmentShader:re,defines:A.defines,customVertexShaderID:ge,customFragmentShaderID:me,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:m,batching:Ce,batchingColor:Ce&&U._colorsTexture!==null,instancing:ie,instancingColor:ie&&U.instanceColor!==null,instancingMorph:ie&&U.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:ue===null?t.outputColorSpace:ue.isXRRenderTarget===!0?ue.texture.colorSpace:Kg,alphaToCoverage:!!A.alphaToCoverage,map:Fe,matcap:xe,envMap:Ze,envMapMode:Ze&&z.mapping,envMapCubeUVHeight:X,aoMap:G,lightMap:Q,bumpMap:de,normalMap:q,displacementMap:p&&ee,emissiveMap:B,normalMapObjectSpace:q&&A.normalMapType===Cme,normalMapTangentSpace:q&&A.normalMapType===eK,metalnessMap:he,roughnessMap:ke,anisotropy:pe,anisotropyMap:we,clearcoat:H,clearcoatMap:ae,clearcoatNormalMap:Le,clearcoatRoughnessMap:Be,dispersion:O,iridescence:J,iridescenceMap:Ve,iridescenceThicknessMap:He,sheen:le,sheenColorMap:be,sheenRoughnessMap:Pe,specularMap:Ie,specularColorMap:_e,specularIntensityMap:Ke,transmission:Se,transmissionMap:Me,thicknessMap:it,gradientMap:Ee,opaque:A.transparent===!1&&A.blending===Tg&&A.alphaToCoverage===!1,alphaMap:Xe,alphaTest:ze,alphaHash:ce,combine:A.combine,mapUv:Fe&&y(A.map.channel),aoMapUv:G&&y(A.aoMap.channel),lightMapUv:Q&&y(A.lightMap.channel),bumpMapUv:de&&y(A.bumpMap.channel),normalMapUv:q&&y(A.normalMap.channel),displacementMapUv:ee&&y(A.displacementMap.channel),emissiveMapUv:B&&y(A.emissiveMap.channel),metalnessMapUv:he&&y(A.metalnessMap.channel),roughnessMapUv:ke&&y(A.roughnessMap.channel),anisotropyMapUv:we&&y(A.anisotropyMap.channel),clearcoatMapUv:ae&&y(A.clearcoatMap.channel),clearcoatNormalMapUv:Le&&y(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Be&&y(A.clearcoatRoughnessMap.channel),iridescenceMapUv:Ve&&y(A.iridescenceMap.channel),iridescenceThicknessMapUv:He&&y(A.iridescenceThicknessMap.channel),sheenColorMapUv:be&&y(A.sheenColorMap.channel),sheenRoughnessMapUv:Pe&&y(A.sheenRoughnessMap.channel),specularMapUv:Ie&&y(A.specularMap.channel),specularColorMapUv:_e&&y(A.specularColorMap.channel),specularIntensityMapUv:Ke&&y(A.specularIntensityMap.channel),transmissionMapUv:Me&&y(A.transmissionMap.channel),thicknessMapUv:it&&y(A.thicknessMap.channel),alphaMapUv:Xe&&y(A.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&(q||pe),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,pointsUvs:U.isPoints===!0&&!!V.attributes.uv&&(Fe||Xe),fog:!!j,useFog:A.fog===!0,fogExp2:!!j&&j.isFogExp2,flatShading:A.flatShading===!0&&A.wireframe===!1,sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:h,reversedDepthBuffer:Te,skinning:U.isSkinnedMesh===!0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.morphAttributes.color!==void 0,morphTargetsCount:$,morphTextureStride:W,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:A.dithering,shadowMapEnabled:t.shadowMap.enabled&&I.length>0,shadowMapType:t.shadowMap.type,toneMapping:ye,decodeVideoTexture:Fe&&A.map.isVideoTexture===!0&&cr.getTransfer(A.map.colorSpace)===Mr,decodeVideoTextureEmissive:B&&A.emissiveMap.isVideoTexture===!0&&cr.getTransfer(A.emissiveMap.colorSpace)===Mr,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===sc,flipSided:A.side===Bs,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionClipCullDistance:$e&&A.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:($e&&A.extensions.multiDraw===!0||Ce)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:A.customProgramCacheKey()};return Je.vertexUv1s=u.has(1),Je.vertexUv2s=u.has(2),Je.vertexUv3s=u.has(3),u.clear(),Je}function b(A){const D=[];if(A.shaderID?D.push(A.shaderID):(D.push(A.customVertexShaderID),D.push(A.customFragmentShaderID)),A.defines!==void 0)for(const I in A.defines)D.push(I),D.push(A.defines[I]);return A.isRawShaderMaterial===!1&&(S(D,A),N(D,A),D.push(t.outputColorSpace)),D.push(A.customProgramCacheKey),D.join()}function S(A,D){A.push(D.precision),A.push(D.outputColorSpace),A.push(D.envMapMode),A.push(D.envMapCubeUVHeight),A.push(D.mapUv),A.push(D.alphaMapUv),A.push(D.lightMapUv),A.push(D.aoMapUv),A.push(D.bumpMapUv),A.push(D.normalMapUv),A.push(D.displacementMapUv),A.push(D.emissiveMapUv),A.push(D.metalnessMapUv),A.push(D.roughnessMapUv),A.push(D.anisotropyMapUv),A.push(D.clearcoatMapUv),A.push(D.clearcoatNormalMapUv),A.push(D.clearcoatRoughnessMapUv),A.push(D.iridescenceMapUv),A.push(D.iridescenceThicknessMapUv),A.push(D.sheenColorMapUv),A.push(D.sheenRoughnessMapUv),A.push(D.specularMapUv),A.push(D.specularColorMapUv),A.push(D.specularIntensityMapUv),A.push(D.transmissionMapUv),A.push(D.thicknessMapUv),A.push(D.combine),A.push(D.fogExp2),A.push(D.sizeAttenuation),A.push(D.morphTargetsCount),A.push(D.morphAttributeCount),A.push(D.numDirLights),A.push(D.numPointLights),A.push(D.numSpotLights),A.push(D.numSpotLightMaps),A.push(D.numHemiLights),A.push(D.numRectAreaLights),A.push(D.numDirLightShadows),A.push(D.numPointLightShadows),A.push(D.numSpotLightShadows),A.push(D.numSpotLightShadowsWithMaps),A.push(D.numLightProbes),A.push(D.shadowMapType),A.push(D.toneMapping),A.push(D.numClippingPlanes),A.push(D.numClipIntersection),A.push(D.depthPacking)}function N(A,D){l.disableAll(),D.supportsVertexTextures&&l.enable(0),D.instancing&&l.enable(1),D.instancingColor&&l.enable(2),D.instancingMorph&&l.enable(3),D.matcap&&l.enable(4),D.envMap&&l.enable(5),D.normalMapObjectSpace&&l.enable(6),D.normalMapTangentSpace&&l.enable(7),D.clearcoat&&l.enable(8),D.iridescence&&l.enable(9),D.alphaTest&&l.enable(10),D.vertexColors&&l.enable(11),D.vertexAlphas&&l.enable(12),D.vertexUv1s&&l.enable(13),D.vertexUv2s&&l.enable(14),D.vertexUv3s&&l.enable(15),D.vertexTangents&&l.enable(16),D.anisotropy&&l.enable(17),D.alphaHash&&l.enable(18),D.batching&&l.enable(19),D.dispersion&&l.enable(20),D.batchingColor&&l.enable(21),D.gradientMap&&l.enable(22),A.push(l.mask),l.disableAll(),D.fog&&l.enable(0),D.useFog&&l.enable(1),D.flatShading&&l.enable(2),D.logarithmicDepthBuffer&&l.enable(3),D.reversedDepthBuffer&&l.enable(4),D.skinning&&l.enable(5),D.morphTargets&&l.enable(6),D.morphNormals&&l.enable(7),D.morphColors&&l.enable(8),D.premultipliedAlpha&&l.enable(9),D.shadowMapEnabled&&l.enable(10),D.doubleSided&&l.enable(11),D.flipSided&&l.enable(12),D.useDepthPacking&&l.enable(13),D.dithering&&l.enable(14),D.transmission&&l.enable(15),D.sheen&&l.enable(16),D.opaque&&l.enable(17),D.pointsUvs&&l.enable(18),D.decodeVideoTexture&&l.enable(19),D.decodeVideoTextureEmissive&&l.enable(20),D.alphaToCoverage&&l.enable(21),A.push(l.mask)}function T(A){const D=x[A.type];let I;if(D){const L=ic[D];I=spe.clone(L.uniforms)}else I=A.uniforms;return I}function k(A,D){let I;for(let L=0,U=d.length;L<U;L++){const j=d[L];if(j.cacheKey===D){I=j,++I.usedTimes;break}}return I===void 0&&(I=new B0e(t,D,A,s),d.push(I)),I}function C(A){if(--A.usedTimes===0){const D=d.indexOf(A);d[D]=d[d.length-1],d.pop(),A.destroy()}}function E(A){c.remove(A)}function P(){c.dispose()}return{getParameters:v,getProgramCacheKey:b,getUniforms:T,acquireProgram:k,releaseProgram:C,releaseShaderCache:E,programs:d,dispose:P}}function q0e(){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 W0e(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 KB(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 XB(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function o(h,p,m,x,y,v){let b=t[e];return b===void 0?(b={id:h.id,object:h,geometry:p,material:m,groupOrder:x,renderOrder:h.renderOrder,z:y,group:v},t[e]=b):(b.id=h.id,b.object=h,b.geometry=p,b.material=m,b.groupOrder=x,b.renderOrder=h.renderOrder,b.z=y,b.group=v),e++,b}function l(h,p,m,x,y,v){const b=o(h,p,m,x,y,v);m.transmission>0?r.push(b):m.transparent===!0?i.push(b):n.push(b)}function c(h,p,m,x,y,v){const b=o(h,p,m,x,y,v);m.transmission>0?r.unshift(b):m.transparent===!0?i.unshift(b):n.unshift(b)}function u(h,p){n.length>1&&n.sort(h||W0e),r.length>1&&r.sort(p||KB),i.length>1&&i.sort(p||KB)}function d(){for(let h=e,p=t.length;h<p;h++){const m=t[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:l,unshift:c,finish:d,sort:u}}function K0e(){let t=new WeakMap;function e(r,i){const s=t.get(r);let o;return s===void 0?(o=new XB,t.set(r,[o])):i>=s.length?(o=new XB,s.push(o)):o=s[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function X0e(){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 mt,color:new Rn};break;case"SpotLight":n={position:new mt,direction:new mt,color:new Rn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new mt,color:new Rn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new mt,skyColor:new Rn,groundColor:new Rn};break;case"RectAreaLight":n={color:new Rn,position:new mt,halfWidth:new mt,halfHeight:new mt};break}return t[e.id]=n,n}}}function Y0e(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Cn};break;case"SpotLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Cn};break;case"PointLight":n={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Cn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let Q0e=0;function Z0e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function J0e(t){const e=new X0e,n=Y0e(),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 mt);const i=new mt,s=new Gi,o=new Gi;function l(u){let d=0,h=0,p=0;for(let A=0;A<9;A++)r.probe[A].set(0,0,0);let m=0,x=0,y=0,v=0,b=0,S=0,N=0,T=0,k=0,C=0,E=0;u.sort(Z0e);for(let A=0,D=u.length;A<D;A++){const I=u[A],L=I.color,U=I.intensity,j=I.distance,V=I.shadow&&I.shadow.map?I.shadow.map.texture:null;if(I.isAmbientLight)d+=L.r*U,h+=L.g*U,p+=L.b*U;else if(I.isLightProbe){for(let K=0;K<9;K++)r.probe[K].addScaledVector(I.sh.coefficients[K],U);E++}else if(I.isDirectionalLight){const K=e.get(I);if(K.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){const z=I.shadow,X=n.get(I);X.shadowIntensity=z.intensity,X.shadowBias=z.bias,X.shadowNormalBias=z.normalBias,X.shadowRadius=z.radius,X.shadowMapSize=z.mapSize,r.directionalShadow[m]=X,r.directionalShadowMap[m]=V,r.directionalShadowMatrix[m]=I.shadow.matrix,S++}r.directional[m]=K,m++}else if(I.isSpotLight){const K=e.get(I);K.position.setFromMatrixPosition(I.matrixWorld),K.color.copy(L).multiplyScalar(U),K.distance=j,K.coneCos=Math.cos(I.angle),K.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),K.decay=I.decay,r.spot[y]=K;const z=I.shadow;if(I.map&&(r.spotLightMap[k]=I.map,k++,z.updateMatrices(I),I.castShadow&&C++),r.spotLightMatrix[y]=z.matrix,I.castShadow){const X=n.get(I);X.shadowIntensity=z.intensity,X.shadowBias=z.bias,X.shadowNormalBias=z.normalBias,X.shadowRadius=z.radius,X.shadowMapSize=z.mapSize,r.spotShadow[y]=X,r.spotShadowMap[y]=V,T++}y++}else if(I.isRectAreaLight){const K=e.get(I);K.color.copy(L).multiplyScalar(U),K.halfWidth.set(I.width*.5,0,0),K.halfHeight.set(0,I.height*.5,0),r.rectArea[v]=K,v++}else if(I.isPointLight){const K=e.get(I);if(K.color.copy(I.color).multiplyScalar(I.intensity),K.distance=I.distance,K.decay=I.decay,I.castShadow){const z=I.shadow,X=n.get(I);X.shadowIntensity=z.intensity,X.shadowBias=z.bias,X.shadowNormalBias=z.normalBias,X.shadowRadius=z.radius,X.shadowMapSize=z.mapSize,X.shadowCameraNear=z.camera.near,X.shadowCameraFar=z.camera.far,r.pointShadow[x]=X,r.pointShadowMap[x]=V,r.pointShadowMatrix[x]=I.shadow.matrix,N++}r.point[x]=K,x++}else if(I.isHemisphereLight){const K=e.get(I);K.skyColor.copy(I.color).multiplyScalar(U),K.groundColor.copy(I.groundColor).multiplyScalar(U),r.hemi[b]=K,b++}}v>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Ft.LTC_FLOAT_1,r.rectAreaLTC2=Ft.LTC_FLOAT_2):(r.rectAreaLTC1=Ft.LTC_HALF_1,r.rectAreaLTC2=Ft.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=h,r.ambient[2]=p;const P=r.hash;(P.directionalLength!==m||P.pointLength!==x||P.spotLength!==y||P.rectAreaLength!==v||P.hemiLength!==b||P.numDirectionalShadows!==S||P.numPointShadows!==N||P.numSpotShadows!==T||P.numSpotMaps!==k||P.numLightProbes!==E)&&(r.directional.length=m,r.spot.length=y,r.rectArea.length=v,r.point.length=x,r.hemi.length=b,r.directionalShadow.length=S,r.directionalShadowMap.length=S,r.pointShadow.length=N,r.pointShadowMap.length=N,r.spotShadow.length=T,r.spotShadowMap.length=T,r.directionalShadowMatrix.length=S,r.pointShadowMatrix.length=N,r.spotLightMatrix.length=T+k-C,r.spotLightMap.length=k,r.numSpotLightShadowsWithMaps=C,r.numLightProbes=E,P.directionalLength=m,P.pointLength=x,P.spotLength=y,P.rectAreaLength=v,P.hemiLength=b,P.numDirectionalShadows=S,P.numPointShadows=N,P.numSpotShadows=T,P.numSpotMaps=k,P.numLightProbes=E,r.version=Q0e++)}function c(u,d){let h=0,p=0,m=0,x=0,y=0;const v=d.matrixWorldInverse;for(let b=0,S=u.length;b<S;b++){const N=u[b];if(N.isDirectionalLight){const T=r.directional[h];T.direction.setFromMatrixPosition(N.matrixWorld),i.setFromMatrixPosition(N.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(v),h++}else if(N.isSpotLight){const T=r.spot[m];T.position.setFromMatrixPosition(N.matrixWorld),T.position.applyMatrix4(v),T.direction.setFromMatrixPosition(N.matrixWorld),i.setFromMatrixPosition(N.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(v),m++}else if(N.isRectAreaLight){const T=r.rectArea[x];T.position.setFromMatrixPosition(N.matrixWorld),T.position.applyMatrix4(v),o.identity(),s.copy(N.matrixWorld),s.premultiply(v),o.extractRotation(s),T.halfWidth.set(N.width*.5,0,0),T.halfHeight.set(0,N.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),x++}else if(N.isPointLight){const T=r.point[p];T.position.setFromMatrixPosition(N.matrixWorld),T.position.applyMatrix4(v),p++}else if(N.isHemisphereLight){const T=r.hemi[y];T.direction.setFromMatrixPosition(N.matrixWorld),T.direction.transformDirection(v),y++}}}return{setup:l,setupView:c,state:r}}function YB(t){const e=new J0e(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 eye(t){let e=new WeakMap;function n(i,s=0){const o=e.get(i);let l;return o===void 0?(l=new YB(t),e.set(i,[l])):s>=o.length?(l=new YB(t),o.push(l)):l=o[s],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const tye=`void main() {
  3797. gl_Position = vec4( position, 1.0 );
  3798. }`,nye=`uniform sampler2D shadow_pass;
  3799. uniform vec2 resolution;
  3800. uniform float radius;
  3801. #include <packing>
  3802. void main() {
  3803. const float samples = float( VSM_SAMPLES );
  3804. float mean = 0.0;
  3805. float squared_mean = 0.0;
  3806. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  3807. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  3808. for ( float i = 0.0; i < samples; i ++ ) {
  3809. float uvOffset = uvStart + i * uvStride;
  3810. #ifdef HORIZONTAL_PASS
  3811. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  3812. mean += distribution.x;
  3813. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  3814. #else
  3815. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  3816. mean += depth;
  3817. squared_mean += depth * depth;
  3818. #endif
  3819. }
  3820. mean = mean / samples;
  3821. squared_mean = squared_mean / samples;
  3822. float std_dev = sqrt( squared_mean - mean * mean );
  3823. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  3824. }`;function rye(t,e,n){let r=new JR;const i=new Cn,s=new Cn,o=new Bi,l=new ype({depthPacking:Ame}),c=new vpe,u={},d=n.maxTextureSize,h={[Sh]:Bs,[Bs]:Sh,[sc]:sc},p=new Fu({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Cn},radius:{value:4}},vertexShader:tye,fragmentShader:nye}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const x=new ul;x.setAttribute("position",new bs(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new dl(x,p),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=GW;let b=this.type;this.render=function(C,E,P){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||C.length===0)return;const A=t.getRenderTarget(),D=t.getActiveCubeFace(),I=t.getActiveMipmapLevel(),L=t.state;L.setBlending(Tu),L.buffers.depth.getReversed()===!0?L.buffers.color.setClear(0,0,0,0):L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);const U=b!==uu&&this.type===uu,j=b===uu&&this.type!==uu;for(let V=0,K=C.length;V<K;V++){const z=C[V],X=z.shadow;if(X===void 0){pn("WebGLShadowMap:",z,"has no shadow.");continue}if(X.autoUpdate===!1&&X.needsUpdate===!1)continue;i.copy(X.mapSize);const Y=X.getFrameExtents();if(i.multiply(Y),s.copy(X.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/Y.x),i.x=s.x*Y.x,X.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/Y.y),i.y=s.y*Y.y,X.mapSize.y=s.y)),X.map===null||U===!0||j===!0){const $=this.type!==uu?{minFilter:xo,magFilter:xo}:{};X.map!==null&&X.map.dispose(),X.map=new hm(i.x,i.y,$),X.map.texture.name=z.name+".shadowMap",X.camera.updateProjectionMatrix()}t.setRenderTarget(X.map),t.clear();const te=X.getViewportCount();for(let $=0;$<te;$++){const W=X.getViewport($);o.set(s.x*W.x,s.y*W.y,s.x*W.z,s.y*W.w),L.viewport(o),X.updateMatrices(z,$),r=X.getFrustum(),T(E,P,X.camera,z,this.type)}X.isPointLightShadow!==!0&&this.type===uu&&S(X,P),X.needsUpdate=!1}b=this.type,v.needsUpdate=!1,t.setRenderTarget(A,D,I)};function S(C,E){const P=e.update(y);p.defines.VSM_SAMPLES!==C.blurSamples&&(p.defines.VSM_SAMPLES=C.blurSamples,m.defines.VSM_SAMPLES=C.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),C.mapPass===null&&(C.mapPass=new hm(i.x,i.y)),p.uniforms.shadow_pass.value=C.map.texture,p.uniforms.resolution.value=C.mapSize,p.uniforms.radius.value=C.radius,t.setRenderTarget(C.mapPass),t.clear(),t.renderBufferDirect(E,null,P,p,y,null),m.uniforms.shadow_pass.value=C.mapPass.texture,m.uniforms.resolution.value=C.mapSize,m.uniforms.radius.value=C.radius,t.setRenderTarget(C.map),t.clear(),t.renderBufferDirect(E,null,P,m,y,null)}function N(C,E,P,A){let D=null;const I=P.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(I!==void 0)D=I;else if(D=P.isPointLight===!0?c:l,t.localClippingEnabled&&E.clipShadows===!0&&Array.isArray(E.clippingPlanes)&&E.clippingPlanes.length!==0||E.displacementMap&&E.displacementScale!==0||E.alphaMap&&E.alphaTest>0||E.map&&E.alphaTest>0||E.alphaToCoverage===!0){const L=D.uuid,U=E.uuid;let j=u[L];j===void 0&&(j={},u[L]=j);let V=j[U];V===void 0&&(V=D.clone(),j[U]=V,E.addEventListener("dispose",k)),D=V}if(D.visible=E.visible,D.wireframe=E.wireframe,A===uu?D.side=E.shadowSide!==null?E.shadowSide:E.side:D.side=E.shadowSide!==null?E.shadowSide:h[E.side],D.alphaMap=E.alphaMap,D.alphaTest=E.alphaToCoverage===!0?.5:E.alphaTest,D.map=E.map,D.clipShadows=E.clipShadows,D.clippingPlanes=E.clippingPlanes,D.clipIntersection=E.clipIntersection,D.displacementMap=E.displacementMap,D.displacementScale=E.displacementScale,D.displacementBias=E.displacementBias,D.wireframeLinewidth=E.wireframeLinewidth,D.linewidth=E.linewidth,P.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const L=t.properties.get(D);L.light=P}return D}function T(C,E,P,A,D){if(C.visible===!1)return;if(C.layers.test(E.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&D===uu)&&(!C.frustumCulled||r.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(P.matrixWorldInverse,C.matrixWorld);const U=e.update(C),j=C.material;if(Array.isArray(j)){const V=U.groups;for(let K=0,z=V.length;K<z;K++){const X=V[K],Y=j[X.materialIndex];if(Y&&Y.visible){const te=N(C,Y,A,D);C.onBeforeShadow(t,C,E,P,U,te,X),t.renderBufferDirect(P,null,U,te,C,X),C.onAfterShadow(t,C,E,P,U,te,X)}}}else if(j.visible){const V=N(C,j,A,D);C.onBeforeShadow(t,C,E,P,U,V,null),t.renderBufferDirect(P,null,U,V,C,null),C.onAfterShadow(t,C,E,P,U,V,null)}}const L=C.children;for(let U=0,j=L.length;U<j;U++)T(L[U],E,P,A,D)}function k(C){C.target.removeEventListener("dispose",k);for(const P in u){const A=u[P],D=C.target.uuid;D in A&&(A[D].dispose(),delete A[D])}}}const iye={[SP]:NP,[MP]:TP,[kP]:AP,[Gg]:EP,[NP]:SP,[TP]:MP,[AP]:kP,[EP]:Gg};function aye(t,e){function n(){let Me=!1;const it=new Bi;let Ee=null;const Xe=new Bi(0,0,0,0);return{setMask:function(ze){Ee!==ze&&!Me&&(t.colorMask(ze,ze,ze,ze),Ee=ze)},setLocked:function(ze){Me=ze},setClear:function(ze,ce,$e,ye,Je){Je===!0&&(ze*=ye,ce*=ye,$e*=ye),it.set(ze,ce,$e,ye),Xe.equals(it)===!1&&(t.clearColor(ze,ce,$e,ye),Xe.copy(it))},reset:function(){Me=!1,Ee=null,Xe.set(-1,0,0,0)}}}function r(){let Me=!1,it=!1,Ee=null,Xe=null,ze=null;return{setReversed:function(ce){if(it!==ce){const $e=e.get("EXT_clip_control");ce?$e.clipControlEXT($e.LOWER_LEFT_EXT,$e.ZERO_TO_ONE_EXT):$e.clipControlEXT($e.LOWER_LEFT_EXT,$e.NEGATIVE_ONE_TO_ONE_EXT),it=ce;const ye=ze;ze=null,this.setClear(ye)}},getReversed:function(){return it},setTest:function(ce){ce?ue(t.DEPTH_TEST):Te(t.DEPTH_TEST)},setMask:function(ce){Ee!==ce&&!Me&&(t.depthMask(ce),Ee=ce)},setFunc:function(ce){if(it&&(ce=iye[ce]),Xe!==ce){switch(ce){case SP:t.depthFunc(t.NEVER);break;case NP:t.depthFunc(t.ALWAYS);break;case MP:t.depthFunc(t.LESS);break;case Gg:t.depthFunc(t.LEQUAL);break;case kP:t.depthFunc(t.EQUAL);break;case EP:t.depthFunc(t.GEQUAL);break;case TP:t.depthFunc(t.GREATER);break;case AP:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Xe=ce}},setLocked:function(ce){Me=ce},setClear:function(ce){ze!==ce&&(it&&(ce=1-ce),t.clearDepth(ce),ze=ce)},reset:function(){Me=!1,Ee=null,Xe=null,ze=null,it=!1}}}function i(){let Me=!1,it=null,Ee=null,Xe=null,ze=null,ce=null,$e=null,ye=null,Je=null;return{setTest:function(at){Me||(at?ue(t.STENCIL_TEST):Te(t.STENCIL_TEST))},setMask:function(at){it!==at&&!Me&&(t.stencilMask(at),it=at)},setFunc:function(at,jt,Dt){(Ee!==at||Xe!==jt||ze!==Dt)&&(t.stencilFunc(at,jt,Dt),Ee=at,Xe=jt,ze=Dt)},setOp:function(at,jt,Dt){(ce!==at||$e!==jt||ye!==Dt)&&(t.stencilOp(at,jt,Dt),ce=at,$e=jt,ye=Dt)},setLocked:function(at){Me=at},setClear:function(at){Je!==at&&(t.clearStencil(at),Je=at)},reset:function(){Me=!1,it=null,Ee=null,Xe=null,ze=null,ce=null,$e=null,ye=null,Je=null}}}const s=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},h={},p=new WeakMap,m=[],x=null,y=!1,v=null,b=null,S=null,N=null,T=null,k=null,C=null,E=new Rn(0,0,0),P=0,A=!1,D=null,I=null,L=null,U=null,j=null;const V=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let K=!1,z=0;const X=t.getParameter(t.VERSION);X.indexOf("WebGL")!==-1?(z=parseFloat(/^WebGL (\d)/.exec(X)[1]),K=z>=1):X.indexOf("OpenGL ES")!==-1&&(z=parseFloat(/^OpenGL ES (\d)/.exec(X)[1]),K=z>=2);let Y=null,te={};const $=t.getParameter(t.SCISSOR_BOX),W=t.getParameter(t.VIEWPORT),ne=new Bi().fromArray($),re=new Bi().fromArray(W);function ge(Me,it,Ee,Xe){const ze=new Uint8Array(4),ce=t.createTexture();t.bindTexture(Me,ce),t.texParameteri(Me,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(Me,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let $e=0;$e<Ee;$e++)Me===t.TEXTURE_3D||Me===t.TEXTURE_2D_ARRAY?t.texImage3D(it,0,t.RGBA,1,1,Xe,0,t.RGBA,t.UNSIGNED_BYTE,ze):t.texImage2D(it+$e,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,ze);return ce}const me={};me[t.TEXTURE_2D]=ge(t.TEXTURE_2D,t.TEXTURE_2D,1),me[t.TEXTURE_CUBE_MAP]=ge(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),me[t.TEXTURE_2D_ARRAY]=ge(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),me[t.TEXTURE_3D]=ge(t.TEXTURE_3D,t.TEXTURE_3D,1,1),s.setClear(0,0,0,1),o.setClear(1),l.setClear(0),ue(t.DEPTH_TEST),o.setFunc(Gg),de(!1),q(Wz),ue(t.CULL_FACE),G(Tu);function ue(Me){d[Me]!==!0&&(t.enable(Me),d[Me]=!0)}function Te(Me){d[Me]!==!1&&(t.disable(Me),d[Me]=!1)}function ie(Me,it){return h[Me]!==it?(t.bindFramebuffer(Me,it),h[Me]=it,Me===t.DRAW_FRAMEBUFFER&&(h[t.FRAMEBUFFER]=it),Me===t.FRAMEBUFFER&&(h[t.DRAW_FRAMEBUFFER]=it),!0):!1}function Ce(Me,it){let Ee=m,Xe=!1;if(Me){Ee=p.get(it),Ee===void 0&&(Ee=[],p.set(it,Ee));const ze=Me.textures;if(Ee.length!==ze.length||Ee[0]!==t.COLOR_ATTACHMENT0){for(let ce=0,$e=ze.length;ce<$e;ce++)Ee[ce]=t.COLOR_ATTACHMENT0+ce;Ee.length=ze.length,Xe=!0}}else Ee[0]!==t.BACK&&(Ee[0]=t.BACK,Xe=!0);Xe&&t.drawBuffers(Ee)}function Fe(Me){return x!==Me?(t.useProgram(Me),x=Me,!0):!1}const xe={[kf]:t.FUNC_ADD,[tme]:t.FUNC_SUBTRACT,[nme]:t.FUNC_REVERSE_SUBTRACT};xe[rme]=t.MIN,xe[ime]=t.MAX;const Ze={[ame]:t.ZERO,[sme]:t.ONE,[ome]:t.SRC_COLOR,[wP]:t.SRC_ALPHA,[fme]:t.SRC_ALPHA_SATURATE,[dme]:t.DST_COLOR,[cme]:t.DST_ALPHA,[lme]:t.ONE_MINUS_SRC_COLOR,[_P]:t.ONE_MINUS_SRC_ALPHA,[hme]:t.ONE_MINUS_DST_COLOR,[ume]:t.ONE_MINUS_DST_ALPHA,[mme]:t.CONSTANT_COLOR,[pme]:t.ONE_MINUS_CONSTANT_COLOR,[gme]:t.CONSTANT_ALPHA,[xme]:t.ONE_MINUS_CONSTANT_ALPHA};function G(Me,it,Ee,Xe,ze,ce,$e,ye,Je,at){if(Me===Tu){y===!0&&(Te(t.BLEND),y=!1);return}if(y===!1&&(ue(t.BLEND),y=!0),Me!==eme){if(Me!==v||at!==A){if((b!==kf||T!==kf)&&(t.blendEquation(t.FUNC_ADD),b=kf,T=kf),at)switch(Me){case Tg:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case Kz:t.blendFunc(t.ONE,t.ONE);break;case Xz:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case Yz:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Ti("WebGLState: Invalid blending: ",Me);break}else switch(Me){case Tg:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case Kz:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case Xz:Ti("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Yz:Ti("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ti("WebGLState: Invalid blending: ",Me);break}S=null,N=null,k=null,C=null,E.set(0,0,0),P=0,v=Me,A=at}return}ze=ze||it,ce=ce||Ee,$e=$e||Xe,(it!==b||ze!==T)&&(t.blendEquationSeparate(xe[it],xe[ze]),b=it,T=ze),(Ee!==S||Xe!==N||ce!==k||$e!==C)&&(t.blendFuncSeparate(Ze[Ee],Ze[Xe],Ze[ce],Ze[$e]),S=Ee,N=Xe,k=ce,C=$e),(ye.equals(E)===!1||Je!==P)&&(t.blendColor(ye.r,ye.g,ye.b,Je),E.copy(ye),P=Je),v=Me,A=!1}function Q(Me,it){Me.side===sc?Te(t.CULL_FACE):ue(t.CULL_FACE);let Ee=Me.side===Bs;it&&(Ee=!Ee),de(Ee),Me.blending===Tg&&Me.transparent===!1?G(Tu):G(Me.blending,Me.blendEquation,Me.blendSrc,Me.blendDst,Me.blendEquationAlpha,Me.blendSrcAlpha,Me.blendDstAlpha,Me.blendColor,Me.blendAlpha,Me.premultipliedAlpha),o.setFunc(Me.depthFunc),o.setTest(Me.depthTest),o.setMask(Me.depthWrite),s.setMask(Me.colorWrite);const Xe=Me.stencilWrite;l.setTest(Xe),Xe&&(l.setMask(Me.stencilWriteMask),l.setFunc(Me.stencilFunc,Me.stencilRef,Me.stencilFuncMask),l.setOp(Me.stencilFail,Me.stencilZFail,Me.stencilZPass)),B(Me.polygonOffset,Me.polygonOffsetFactor,Me.polygonOffsetUnits),Me.alphaToCoverage===!0?ue(t.SAMPLE_ALPHA_TO_COVERAGE):Te(t.SAMPLE_ALPHA_TO_COVERAGE)}function de(Me){D!==Me&&(Me?t.frontFace(t.CW):t.frontFace(t.CCW),D=Me)}function q(Me){Me!==Qfe?(ue(t.CULL_FACE),Me!==I&&(Me===Wz?t.cullFace(t.BACK):Me===Zfe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Te(t.CULL_FACE),I=Me}function ee(Me){Me!==L&&(K&&t.lineWidth(Me),L=Me)}function B(Me,it,Ee){Me?(ue(t.POLYGON_OFFSET_FILL),(U!==it||j!==Ee)&&(t.polygonOffset(it,Ee),U=it,j=Ee)):Te(t.POLYGON_OFFSET_FILL)}function he(Me){Me?ue(t.SCISSOR_TEST):Te(t.SCISSOR_TEST)}function ke(Me){Me===void 0&&(Me=t.TEXTURE0+V-1),Y!==Me&&(t.activeTexture(Me),Y=Me)}function pe(Me,it,Ee){Ee===void 0&&(Y===null?Ee=t.TEXTURE0+V-1:Ee=Y);let Xe=te[Ee];Xe===void 0&&(Xe={type:void 0,texture:void 0},te[Ee]=Xe),(Xe.type!==Me||Xe.texture!==it)&&(Y!==Ee&&(t.activeTexture(Ee),Y=Ee),t.bindTexture(Me,it||me[Me]),Xe.type=Me,Xe.texture=it)}function H(){const Me=te[Y];Me!==void 0&&Me.type!==void 0&&(t.bindTexture(Me.type,null),Me.type=void 0,Me.texture=void 0)}function O(){try{t.compressedTexImage2D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function J(){try{t.compressedTexImage3D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function le(){try{t.texSubImage2D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function Se(){try{t.texSubImage3D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function we(){try{t.compressedTexSubImage2D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function ae(){try{t.compressedTexSubImage3D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function Le(){try{t.texStorage2D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function Be(){try{t.texStorage3D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function Ve(){try{t.texImage2D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function He(){try{t.texImage3D(...arguments)}catch(Me){Me("WebGLState:",Me)}}function be(Me){ne.equals(Me)===!1&&(t.scissor(Me.x,Me.y,Me.z,Me.w),ne.copy(Me))}function Pe(Me){re.equals(Me)===!1&&(t.viewport(Me.x,Me.y,Me.z,Me.w),re.copy(Me))}function Ie(Me,it){let Ee=u.get(it);Ee===void 0&&(Ee=new WeakMap,u.set(it,Ee));let Xe=Ee.get(Me);Xe===void 0&&(Xe=t.getUniformBlockIndex(it,Me.name),Ee.set(Me,Xe))}function _e(Me,it){const Xe=u.get(it).get(Me);c.get(it)!==Xe&&(t.uniformBlockBinding(it,Xe,Me.__bindingPointIndex),c.set(it,Xe))}function Ke(){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={},Y=null,te={},h={},p=new WeakMap,m=[],x=null,y=!1,v=null,b=null,S=null,N=null,T=null,k=null,C=null,E=new Rn(0,0,0),P=0,A=!1,D=null,I=null,L=null,U=null,j=null,ne.set(0,0,t.canvas.width,t.canvas.height),re.set(0,0,t.canvas.width,t.canvas.height),s.reset(),o.reset(),l.reset()}return{buffers:{color:s,depth:o,stencil:l},enable:ue,disable:Te,bindFramebuffer:ie,drawBuffers:Ce,useProgram:Fe,setBlending:G,setMaterial:Q,setFlipSided:de,setCullFace:q,setLineWidth:ee,setPolygonOffset:B,setScissorTest:he,activeTexture:ke,bindTexture:pe,unbindTexture:H,compressedTexImage2D:O,compressedTexImage3D:J,texImage2D:Ve,texImage3D:He,updateUBOMapping:Ie,uniformBlockBinding:_e,texStorage2D:Le,texStorage3D:Be,texSubImage2D:le,texSubImage3D:Se,compressedTexSubImage2D:we,compressedTexSubImage3D:ae,scissor:be,viewport:Pe,reset:Ke}}function sye(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 Cn,d=new WeakMap;let h;const p=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(H,O){return m?new OffscreenCanvas(H,O):J1("canvas")}function y(H,O,J){let le=1;const Se=pe(H);if((Se.width>J||Se.height>J)&&(le=J/Math.max(Se.width,Se.height)),le<1)if(typeof HTMLImageElement<"u"&&H instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&H instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&H instanceof ImageBitmap||typeof VideoFrame<"u"&&H instanceof VideoFrame){const we=Math.floor(le*Se.width),ae=Math.floor(le*Se.height);h===void 0&&(h=x(we,ae));const Le=O?x(we,ae):h;return Le.width=we,Le.height=ae,Le.getContext("2d").drawImage(H,0,0,we,ae),pn("WebGLRenderer: Texture has been resized from ("+Se.width+"x"+Se.height+") to ("+we+"x"+ae+")."),Le}else return"data"in H&&pn("WebGLRenderer: Image in DataTexture is too big ("+Se.width+"x"+Se.height+")."),H;return H}function v(H){return H.generateMipmaps}function b(H){t.generateMipmap(H)}function S(H){return H.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:H.isWebGL3DRenderTarget?t.TEXTURE_3D:H.isWebGLArrayRenderTarget||H.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function N(H,O,J,le,Se=!1){if(H!==null){if(t[H]!==void 0)return t[H];pn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+H+"'")}let we=O;if(O===t.RED&&(J===t.FLOAT&&(we=t.R32F),J===t.HALF_FLOAT&&(we=t.R16F),J===t.UNSIGNED_BYTE&&(we=t.R8)),O===t.RED_INTEGER&&(J===t.UNSIGNED_BYTE&&(we=t.R8UI),J===t.UNSIGNED_SHORT&&(we=t.R16UI),J===t.UNSIGNED_INT&&(we=t.R32UI),J===t.BYTE&&(we=t.R8I),J===t.SHORT&&(we=t.R16I),J===t.INT&&(we=t.R32I)),O===t.RG&&(J===t.FLOAT&&(we=t.RG32F),J===t.HALF_FLOAT&&(we=t.RG16F),J===t.UNSIGNED_BYTE&&(we=t.RG8)),O===t.RG_INTEGER&&(J===t.UNSIGNED_BYTE&&(we=t.RG8UI),J===t.UNSIGNED_SHORT&&(we=t.RG16UI),J===t.UNSIGNED_INT&&(we=t.RG32UI),J===t.BYTE&&(we=t.RG8I),J===t.SHORT&&(we=t.RG16I),J===t.INT&&(we=t.RG32I)),O===t.RGB_INTEGER&&(J===t.UNSIGNED_BYTE&&(we=t.RGB8UI),J===t.UNSIGNED_SHORT&&(we=t.RGB16UI),J===t.UNSIGNED_INT&&(we=t.RGB32UI),J===t.BYTE&&(we=t.RGB8I),J===t.SHORT&&(we=t.RGB16I),J===t.INT&&(we=t.RGB32I)),O===t.RGBA_INTEGER&&(J===t.UNSIGNED_BYTE&&(we=t.RGBA8UI),J===t.UNSIGNED_SHORT&&(we=t.RGBA16UI),J===t.UNSIGNED_INT&&(we=t.RGBA32UI),J===t.BYTE&&(we=t.RGBA8I),J===t.SHORT&&(we=t.RGBA16I),J===t.INT&&(we=t.RGBA32I)),O===t.RGB&&(J===t.UNSIGNED_INT_5_9_9_9_REV&&(we=t.RGB9_E5),J===t.UNSIGNED_INT_10F_11F_11F_REV&&(we=t.R11F_G11F_B10F)),O===t.RGBA){const ae=Se?Q1:cr.getTransfer(le);J===t.FLOAT&&(we=t.RGBA32F),J===t.HALF_FLOAT&&(we=t.RGBA16F),J===t.UNSIGNED_BYTE&&(we=ae===Mr?t.SRGB8_ALPHA8:t.RGBA8),J===t.UNSIGNED_SHORT_4_4_4_4&&(we=t.RGBA4),J===t.UNSIGNED_SHORT_5_5_5_1&&(we=t.RGB5_A1)}return(we===t.R16F||we===t.R32F||we===t.RG16F||we===t.RG32F||we===t.RGBA16F||we===t.RGBA32F)&&e.get("EXT_color_buffer_float"),we}function T(H,O){let J;return H?O===null||O===um||O===Q0?J=t.DEPTH24_STENCIL8:O===wu?J=t.DEPTH32F_STENCIL8:O===Y0&&(J=t.DEPTH24_STENCIL8,pn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):O===null||O===um||O===Q0?J=t.DEPTH_COMPONENT24:O===wu?J=t.DEPTH_COMPONENT32F:O===Y0&&(J=t.DEPTH_COMPONENT16),J}function k(H,O){return v(H)===!0||H.isFramebufferTexture&&H.minFilter!==xo&&H.minFilter!==rl?Math.log2(Math.max(O.width,O.height))+1:H.mipmaps!==void 0&&H.mipmaps.length>0?H.mipmaps.length:H.isCompressedTexture&&Array.isArray(H.image)?O.mipmaps.length:1}function C(H){const O=H.target;O.removeEventListener("dispose",C),P(O),O.isVideoTexture&&d.delete(O)}function E(H){const O=H.target;O.removeEventListener("dispose",E),D(O)}function P(H){const O=r.get(H);if(O.__webglInit===void 0)return;const J=H.source,le=p.get(J);if(le){const Se=le[O.__cacheKey];Se.usedTimes--,Se.usedTimes===0&&A(H),Object.keys(le).length===0&&p.delete(J)}r.remove(H)}function A(H){const O=r.get(H);t.deleteTexture(O.__webglTexture);const J=H.source,le=p.get(J);delete le[O.__cacheKey],o.memory.textures--}function D(H){const O=r.get(H);if(H.depthTexture&&(H.depthTexture.dispose(),r.remove(H.depthTexture)),H.isWebGLCubeRenderTarget)for(let le=0;le<6;le++){if(Array.isArray(O.__webglFramebuffer[le]))for(let Se=0;Se<O.__webglFramebuffer[le].length;Se++)t.deleteFramebuffer(O.__webglFramebuffer[le][Se]);else t.deleteFramebuffer(O.__webglFramebuffer[le]);O.__webglDepthbuffer&&t.deleteRenderbuffer(O.__webglDepthbuffer[le])}else{if(Array.isArray(O.__webglFramebuffer))for(let le=0;le<O.__webglFramebuffer.length;le++)t.deleteFramebuffer(O.__webglFramebuffer[le]);else t.deleteFramebuffer(O.__webglFramebuffer);if(O.__webglDepthbuffer&&t.deleteRenderbuffer(O.__webglDepthbuffer),O.__webglMultisampledFramebuffer&&t.deleteFramebuffer(O.__webglMultisampledFramebuffer),O.__webglColorRenderbuffer)for(let le=0;le<O.__webglColorRenderbuffer.length;le++)O.__webglColorRenderbuffer[le]&&t.deleteRenderbuffer(O.__webglColorRenderbuffer[le]);O.__webglDepthRenderbuffer&&t.deleteRenderbuffer(O.__webglDepthRenderbuffer)}const J=H.textures;for(let le=0,Se=J.length;le<Se;le++){const we=r.get(J[le]);we.__webglTexture&&(t.deleteTexture(we.__webglTexture),o.memory.textures--),r.remove(J[le])}r.remove(H)}let I=0;function L(){I=0}function U(){const H=I;return H>=i.maxTextures&&pn("WebGLTextures: Trying to use "+H+" texture units while this GPU supports only "+i.maxTextures),I+=1,H}function j(H){const O=[];return O.push(H.wrapS),O.push(H.wrapT),O.push(H.wrapR||0),O.push(H.magFilter),O.push(H.minFilter),O.push(H.anisotropy),O.push(H.internalFormat),O.push(H.format),O.push(H.type),O.push(H.generateMipmaps),O.push(H.premultiplyAlpha),O.push(H.flipY),O.push(H.unpackAlignment),O.push(H.colorSpace),O.join()}function V(H,O){const J=r.get(H);if(H.isVideoTexture&&he(H),H.isRenderTargetTexture===!1&&H.isExternalTexture!==!0&&H.version>0&&J.__version!==H.version){const le=H.image;if(le===null)pn("WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)pn("WebGLRenderer: Texture marked for update but image is incomplete");else{me(J,H,O);return}}else H.isExternalTexture&&(J.__webglTexture=H.sourceTexture?H.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,J.__webglTexture,t.TEXTURE0+O)}function K(H,O){const J=r.get(H);if(H.isRenderTargetTexture===!1&&H.version>0&&J.__version!==H.version){me(J,H,O);return}else H.isExternalTexture&&(J.__webglTexture=H.sourceTexture?H.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,J.__webglTexture,t.TEXTURE0+O)}function z(H,O){const J=r.get(H);if(H.isRenderTargetTexture===!1&&H.version>0&&J.__version!==H.version){me(J,H,O);return}n.bindTexture(t.TEXTURE_3D,J.__webglTexture,t.TEXTURE0+O)}function X(H,O){const J=r.get(H);if(H.version>0&&J.__version!==H.version){ue(J,H,O);return}n.bindTexture(t.TEXTURE_CUBE_MAP,J.__webglTexture,t.TEXTURE0+O)}const Y={[PP]:t.REPEAT,[vu]:t.CLAMP_TO_EDGE,[DP]:t.MIRRORED_REPEAT},te={[xo]:t.NEAREST,[Eme]:t.NEAREST_MIPMAP_NEAREST,[Lw]:t.NEAREST_MIPMAP_LINEAR,[rl]:t.LINEAR,[sT]:t.LINEAR_MIPMAP_NEAREST,[Rf]:t.LINEAR_MIPMAP_LINEAR},$={[jme]:t.NEVER,[Fme]:t.ALWAYS,[Pme]:t.LESS,[tK]:t.LEQUAL,[Dme]:t.EQUAL,[Lme]:t.GEQUAL,[Rme]:t.GREATER,[Ome]:t.NOTEQUAL};function W(H,O){if(O.type===wu&&e.has("OES_texture_float_linear")===!1&&(O.magFilter===rl||O.magFilter===sT||O.magFilter===Lw||O.magFilter===Rf||O.minFilter===rl||O.minFilter===sT||O.minFilter===Lw||O.minFilter===Rf)&&pn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(H,t.TEXTURE_WRAP_S,Y[O.wrapS]),t.texParameteri(H,t.TEXTURE_WRAP_T,Y[O.wrapT]),(H===t.TEXTURE_3D||H===t.TEXTURE_2D_ARRAY)&&t.texParameteri(H,t.TEXTURE_WRAP_R,Y[O.wrapR]),t.texParameteri(H,t.TEXTURE_MAG_FILTER,te[O.magFilter]),t.texParameteri(H,t.TEXTURE_MIN_FILTER,te[O.minFilter]),O.compareFunction&&(t.texParameteri(H,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(H,t.TEXTURE_COMPARE_FUNC,$[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(O.magFilter===xo||O.minFilter!==Lw&&O.minFilter!==Rf||O.type===wu&&e.has("OES_texture_float_linear")===!1)return;if(O.anisotropy>1||r.get(O).__currentAnisotropy){const J=e.get("EXT_texture_filter_anisotropic");t.texParameterf(H,J.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy}}}function ne(H,O){let J=!1;H.__webglInit===void 0&&(H.__webglInit=!0,O.addEventListener("dispose",C));const le=O.source;let Se=p.get(le);Se===void 0&&(Se={},p.set(le,Se));const we=j(O);if(we!==H.__cacheKey){Se[we]===void 0&&(Se[we]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,J=!0),Se[we].usedTimes++;const ae=Se[H.__cacheKey];ae!==void 0&&(Se[H.__cacheKey].usedTimes--,ae.usedTimes===0&&A(O)),H.__cacheKey=we,H.__webglTexture=Se[we].texture}return J}function re(H,O,J){return Math.floor(Math.floor(H/J)/O)}function ge(H,O,J,le){const we=H.updateRanges;if(we.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,O.width,O.height,J,le,O.data);else{we.sort((He,be)=>He.start-be.start);let ae=0;for(let He=1;He<we.length;He++){const be=we[ae],Pe=we[He],Ie=be.start+be.count,_e=re(Pe.start,O.width,4),Ke=re(be.start,O.width,4);Pe.start<=Ie+1&&_e===Ke&&re(Pe.start+Pe.count-1,O.width,4)===_e?be.count=Math.max(be.count,Pe.start+Pe.count-be.start):(++ae,we[ae]=Pe)}we.length=ae+1;const Le=t.getParameter(t.UNPACK_ROW_LENGTH),Be=t.getParameter(t.UNPACK_SKIP_PIXELS),Ve=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,O.width);for(let He=0,be=we.length;He<be;He++){const Pe=we[He],Ie=Math.floor(Pe.start/4),_e=Math.ceil(Pe.count/4),Ke=Ie%O.width,Me=Math.floor(Ie/O.width),it=_e,Ee=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,Ke),t.pixelStorei(t.UNPACK_SKIP_ROWS,Me),n.texSubImage2D(t.TEXTURE_2D,0,Ke,Me,it,Ee,J,le,O.data)}H.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Le),t.pixelStorei(t.UNPACK_SKIP_PIXELS,Be),t.pixelStorei(t.UNPACK_SKIP_ROWS,Ve)}}function me(H,O,J){let le=t.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(le=t.TEXTURE_2D_ARRAY),O.isData3DTexture&&(le=t.TEXTURE_3D);const Se=ne(H,O),we=O.source;n.bindTexture(le,H.__webglTexture,t.TEXTURE0+J);const ae=r.get(we);if(we.version!==ae.__version||Se===!0){n.activeTexture(t.TEXTURE0+J);const Le=cr.getPrimaries(cr.workingColorSpace),Be=O.colorSpace===Kd?null:cr.getPrimaries(O.colorSpace),Ve=O.colorSpace===Kd||Le===Be?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ve);let He=y(O.image,!1,i.maxTextureSize);He=ke(O,He);const be=s.convert(O.format,O.colorSpace),Pe=s.convert(O.type);let Ie=N(O.internalFormat,be,Pe,O.colorSpace,O.isVideoTexture);W(le,O);let _e;const Ke=O.mipmaps,Me=O.isVideoTexture!==!0,it=ae.__version===void 0||Se===!0,Ee=we.dataReady,Xe=k(O,He);if(O.isDepthTexture)Ie=T(O.format===J0,O.type),it&&(Me?n.texStorage2D(t.TEXTURE_2D,1,Ie,He.width,He.height):n.texImage2D(t.TEXTURE_2D,0,Ie,He.width,He.height,0,be,Pe,null));else if(O.isDataTexture)if(Ke.length>0){Me&&it&&n.texStorage2D(t.TEXTURE_2D,Xe,Ie,Ke[0].width,Ke[0].height);for(let ze=0,ce=Ke.length;ze<ce;ze++)_e=Ke[ze],Me?Ee&&n.texSubImage2D(t.TEXTURE_2D,ze,0,0,_e.width,_e.height,be,Pe,_e.data):n.texImage2D(t.TEXTURE_2D,ze,Ie,_e.width,_e.height,0,be,Pe,_e.data);O.generateMipmaps=!1}else Me?(it&&n.texStorage2D(t.TEXTURE_2D,Xe,Ie,He.width,He.height),Ee&&ge(O,He,be,Pe)):n.texImage2D(t.TEXTURE_2D,0,Ie,He.width,He.height,0,be,Pe,He.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Me&&it&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Xe,Ie,Ke[0].width,Ke[0].height,He.depth);for(let ze=0,ce=Ke.length;ze<ce;ze++)if(_e=Ke[ze],O.format!==Ol)if(be!==null)if(Me){if(Ee)if(O.layerUpdates.size>0){const $e=EB(_e.width,_e.height,O.format,O.type);for(const ye of O.layerUpdates){const Je=_e.data.subarray(ye*$e/_e.data.BYTES_PER_ELEMENT,(ye+1)*$e/_e.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,ze,0,0,ye,_e.width,_e.height,1,be,Je)}O.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,ze,0,0,0,_e.width,_e.height,He.depth,be,_e.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,ze,Ie,_e.width,_e.height,He.depth,0,_e.data,0,0);else pn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Me?Ee&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,ze,0,0,0,_e.width,_e.height,He.depth,be,Pe,_e.data):n.texImage3D(t.TEXTURE_2D_ARRAY,ze,Ie,_e.width,_e.height,He.depth,0,be,Pe,_e.data)}else{Me&&it&&n.texStorage2D(t.TEXTURE_2D,Xe,Ie,Ke[0].width,Ke[0].height);for(let ze=0,ce=Ke.length;ze<ce;ze++)_e=Ke[ze],O.format!==Ol?be!==null?Me?Ee&&n.compressedTexSubImage2D(t.TEXTURE_2D,ze,0,0,_e.width,_e.height,be,_e.data):n.compressedTexImage2D(t.TEXTURE_2D,ze,Ie,_e.width,_e.height,0,_e.data):pn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Me?Ee&&n.texSubImage2D(t.TEXTURE_2D,ze,0,0,_e.width,_e.height,be,Pe,_e.data):n.texImage2D(t.TEXTURE_2D,ze,Ie,_e.width,_e.height,0,be,Pe,_e.data)}else if(O.isDataArrayTexture)if(Me){if(it&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Xe,Ie,He.width,He.height,He.depth),Ee)if(O.layerUpdates.size>0){const ze=EB(He.width,He.height,O.format,O.type);for(const ce of O.layerUpdates){const $e=He.data.subarray(ce*ze/He.data.BYTES_PER_ELEMENT,(ce+1)*ze/He.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,ce,He.width,He.height,1,be,Pe,$e)}O.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,He.width,He.height,He.depth,be,Pe,He.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,Ie,He.width,He.height,He.depth,0,be,Pe,He.data);else if(O.isData3DTexture)Me?(it&&n.texStorage3D(t.TEXTURE_3D,Xe,Ie,He.width,He.height,He.depth),Ee&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,He.width,He.height,He.depth,be,Pe,He.data)):n.texImage3D(t.TEXTURE_3D,0,Ie,He.width,He.height,He.depth,0,be,Pe,He.data);else if(O.isFramebufferTexture){if(it)if(Me)n.texStorage2D(t.TEXTURE_2D,Xe,Ie,He.width,He.height);else{let ze=He.width,ce=He.height;for(let $e=0;$e<Xe;$e++)n.texImage2D(t.TEXTURE_2D,$e,Ie,ze,ce,0,be,Pe,null),ze>>=1,ce>>=1}}else if(Ke.length>0){if(Me&&it){const ze=pe(Ke[0]);n.texStorage2D(t.TEXTURE_2D,Xe,Ie,ze.width,ze.height)}for(let ze=0,ce=Ke.length;ze<ce;ze++)_e=Ke[ze],Me?Ee&&n.texSubImage2D(t.TEXTURE_2D,ze,0,0,be,Pe,_e):n.texImage2D(t.TEXTURE_2D,ze,Ie,be,Pe,_e);O.generateMipmaps=!1}else if(Me){if(it){const ze=pe(He);n.texStorage2D(t.TEXTURE_2D,Xe,Ie,ze.width,ze.height)}Ee&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,be,Pe,He)}else n.texImage2D(t.TEXTURE_2D,0,Ie,be,Pe,He);v(O)&&b(le),ae.__version=we.version,O.onUpdate&&O.onUpdate(O)}H.__version=O.version}function ue(H,O,J){if(O.image.length!==6)return;const le=ne(H,O),Se=O.source;n.bindTexture(t.TEXTURE_CUBE_MAP,H.__webglTexture,t.TEXTURE0+J);const we=r.get(Se);if(Se.version!==we.__version||le===!0){n.activeTexture(t.TEXTURE0+J);const ae=cr.getPrimaries(cr.workingColorSpace),Le=O.colorSpace===Kd?null:cr.getPrimaries(O.colorSpace),Be=O.colorSpace===Kd||ae===Le?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Be);const Ve=O.isCompressedTexture||O.image[0].isCompressedTexture,He=O.image[0]&&O.image[0].isDataTexture,be=[];for(let ce=0;ce<6;ce++)!Ve&&!He?be[ce]=y(O.image[ce],!0,i.maxCubemapSize):be[ce]=He?O.image[ce].image:O.image[ce],be[ce]=ke(O,be[ce]);const Pe=be[0],Ie=s.convert(O.format,O.colorSpace),_e=s.convert(O.type),Ke=N(O.internalFormat,Ie,_e,O.colorSpace),Me=O.isVideoTexture!==!0,it=we.__version===void 0||le===!0,Ee=Se.dataReady;let Xe=k(O,Pe);W(t.TEXTURE_CUBE_MAP,O);let ze;if(Ve){Me&&it&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Xe,Ke,Pe.width,Pe.height);for(let ce=0;ce<6;ce++){ze=be[ce].mipmaps;for(let $e=0;$e<ze.length;$e++){const ye=ze[$e];O.format!==Ol?Ie!==null?Me?Ee&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e,0,0,ye.width,ye.height,Ie,ye.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e,Ke,ye.width,ye.height,0,ye.data):pn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Me?Ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e,0,0,ye.width,ye.height,Ie,_e,ye.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e,Ke,ye.width,ye.height,0,Ie,_e,ye.data)}}}else{if(ze=O.mipmaps,Me&&it){ze.length>0&&Xe++;const ce=pe(be[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Xe,Ke,ce.width,ce.height)}for(let ce=0;ce<6;ce++)if(He){Me?Ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,be[ce].width,be[ce].height,Ie,_e,be[ce].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,Ke,be[ce].width,be[ce].height,0,Ie,_e,be[ce].data);for(let $e=0;$e<ze.length;$e++){const Je=ze[$e].image[ce].image;Me?Ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e+1,0,0,Je.width,Je.height,Ie,_e,Je.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e+1,Ke,Je.width,Je.height,0,Ie,_e,Je.data)}}else{Me?Ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,Ie,_e,be[ce]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,Ke,Ie,_e,be[ce]);for(let $e=0;$e<ze.length;$e++){const ye=ze[$e];Me?Ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e+1,0,0,Ie,_e,ye.image[ce]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e+1,Ke,Ie,_e,ye.image[ce])}}}v(O)&&b(t.TEXTURE_CUBE_MAP),we.__version=Se.version,O.onUpdate&&O.onUpdate(O)}H.__version=O.version}function Te(H,O,J,le,Se,we){const ae=s.convert(J.format,J.colorSpace),Le=s.convert(J.type),Be=N(J.internalFormat,ae,Le,J.colorSpace),Ve=r.get(O),He=r.get(J);if(He.__renderTarget=O,!Ve.__hasExternalTextures){const be=Math.max(1,O.width>>we),Pe=Math.max(1,O.height>>we);Se===t.TEXTURE_3D||Se===t.TEXTURE_2D_ARRAY?n.texImage3D(Se,we,Be,be,Pe,O.depth,0,ae,Le,null):n.texImage2D(Se,we,Be,be,Pe,0,ae,Le,null)}n.bindFramebuffer(t.FRAMEBUFFER,H),B(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,le,Se,He.__webglTexture,0,ee(O)):(Se===t.TEXTURE_2D||Se>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Se<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,le,Se,He.__webglTexture,we),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ie(H,O,J){if(t.bindRenderbuffer(t.RENDERBUFFER,H),O.depthBuffer){const le=O.depthTexture,Se=le&&le.isDepthTexture?le.type:null,we=T(O.stencilBuffer,Se),ae=O.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Le=ee(O);B(O)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Le,we,O.width,O.height):J?t.renderbufferStorageMultisample(t.RENDERBUFFER,Le,we,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,we,O.width,O.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,ae,t.RENDERBUFFER,H)}else{const le=O.textures;for(let Se=0;Se<le.length;Se++){const we=le[Se],ae=s.convert(we.format,we.colorSpace),Le=s.convert(we.type),Be=N(we.internalFormat,ae,Le,we.colorSpace),Ve=ee(O);J&&B(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ve,Be,O.width,O.height):B(O)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ve,Be,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,Be,O.width,O.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ce(H,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,H),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const le=r.get(O.depthTexture);le.__renderTarget=O,(!le.__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),V(O.depthTexture,0);const Se=le.__webglTexture,we=ee(O);if(O.depthTexture.format===Z0)B(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Se,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,Se,0);else if(O.depthTexture.format===J0)B(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Se,0,we):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,Se,0);else throw new Error("Unknown depthTexture format")}function Fe(H){const O=r.get(H),J=H.isWebGLCubeRenderTarget===!0;if(O.__boundDepthTexture!==H.depthTexture){const le=H.depthTexture;if(O.__depthDisposeCallback&&O.__depthDisposeCallback(),le){const Se=()=>{delete O.__boundDepthTexture,delete O.__depthDisposeCallback,le.removeEventListener("dispose",Se)};le.addEventListener("dispose",Se),O.__depthDisposeCallback=Se}O.__boundDepthTexture=le}if(H.depthTexture&&!O.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");const le=H.texture.mipmaps;le&&le.length>0?Ce(O.__webglFramebuffer[0],H):Ce(O.__webglFramebuffer,H)}else if(J){O.__webglDepthbuffer=[];for(let le=0;le<6;le++)if(n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[le]),O.__webglDepthbuffer[le]===void 0)O.__webglDepthbuffer[le]=t.createRenderbuffer(),ie(O.__webglDepthbuffer[le],H,!1);else{const Se=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,we=O.__webglDepthbuffer[le];t.bindRenderbuffer(t.RENDERBUFFER,we),t.framebufferRenderbuffer(t.FRAMEBUFFER,Se,t.RENDERBUFFER,we)}}else{const le=H.texture.mipmaps;if(le&&le.length>0?n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[0]):n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer===void 0)O.__webglDepthbuffer=t.createRenderbuffer(),ie(O.__webglDepthbuffer,H,!1);else{const Se=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,we=O.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,we),t.framebufferRenderbuffer(t.FRAMEBUFFER,Se,t.RENDERBUFFER,we)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function xe(H,O,J){const le=r.get(H);O!==void 0&&Te(le.__webglFramebuffer,H,H.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),J!==void 0&&Fe(H)}function Ze(H){const O=H.texture,J=r.get(H),le=r.get(O);H.addEventListener("dispose",E);const Se=H.textures,we=H.isWebGLCubeRenderTarget===!0,ae=Se.length>1;if(ae||(le.__webglTexture===void 0&&(le.__webglTexture=t.createTexture()),le.__version=O.version,o.memory.textures++),we){J.__webglFramebuffer=[];for(let Le=0;Le<6;Le++)if(O.mipmaps&&O.mipmaps.length>0){J.__webglFramebuffer[Le]=[];for(let Be=0;Be<O.mipmaps.length;Be++)J.__webglFramebuffer[Le][Be]=t.createFramebuffer()}else J.__webglFramebuffer[Le]=t.createFramebuffer()}else{if(O.mipmaps&&O.mipmaps.length>0){J.__webglFramebuffer=[];for(let Le=0;Le<O.mipmaps.length;Le++)J.__webglFramebuffer[Le]=t.createFramebuffer()}else J.__webglFramebuffer=t.createFramebuffer();if(ae)for(let Le=0,Be=Se.length;Le<Be;Le++){const Ve=r.get(Se[Le]);Ve.__webglTexture===void 0&&(Ve.__webglTexture=t.createTexture(),o.memory.textures++)}if(H.samples>0&&B(H)===!1){J.__webglMultisampledFramebuffer=t.createFramebuffer(),J.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,J.__webglMultisampledFramebuffer);for(let Le=0;Le<Se.length;Le++){const Be=Se[Le];J.__webglColorRenderbuffer[Le]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,J.__webglColorRenderbuffer[Le]);const Ve=s.convert(Be.format,Be.colorSpace),He=s.convert(Be.type),be=N(Be.internalFormat,Ve,He,Be.colorSpace,H.isXRRenderTarget===!0),Pe=ee(H);t.renderbufferStorageMultisample(t.RENDERBUFFER,Pe,be,H.width,H.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Le,t.RENDERBUFFER,J.__webglColorRenderbuffer[Le])}t.bindRenderbuffer(t.RENDERBUFFER,null),H.depthBuffer&&(J.__webglDepthRenderbuffer=t.createRenderbuffer(),ie(J.__webglDepthRenderbuffer,H,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(we){n.bindTexture(t.TEXTURE_CUBE_MAP,le.__webglTexture),W(t.TEXTURE_CUBE_MAP,O);for(let Le=0;Le<6;Le++)if(O.mipmaps&&O.mipmaps.length>0)for(let Be=0;Be<O.mipmaps.length;Be++)Te(J.__webglFramebuffer[Le][Be],H,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,Be);else Te(J.__webglFramebuffer[Le],H,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,0);v(O)&&b(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ae){for(let Le=0,Be=Se.length;Le<Be;Le++){const Ve=Se[Le],He=r.get(Ve);let be=t.TEXTURE_2D;(H.isWebGL3DRenderTarget||H.isWebGLArrayRenderTarget)&&(be=H.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(be,He.__webglTexture),W(be,Ve),Te(J.__webglFramebuffer,H,Ve,t.COLOR_ATTACHMENT0+Le,be,0),v(Ve)&&b(be)}n.unbindTexture()}else{let Le=t.TEXTURE_2D;if((H.isWebGL3DRenderTarget||H.isWebGLArrayRenderTarget)&&(Le=H.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Le,le.__webglTexture),W(Le,O),O.mipmaps&&O.mipmaps.length>0)for(let Be=0;Be<O.mipmaps.length;Be++)Te(J.__webglFramebuffer[Be],H,O,t.COLOR_ATTACHMENT0,Le,Be);else Te(J.__webglFramebuffer,H,O,t.COLOR_ATTACHMENT0,Le,0);v(O)&&b(Le),n.unbindTexture()}H.depthBuffer&&Fe(H)}function G(H){const O=H.textures;for(let J=0,le=O.length;J<le;J++){const Se=O[J];if(v(Se)){const we=S(H),ae=r.get(Se).__webglTexture;n.bindTexture(we,ae),b(we),n.unbindTexture()}}}const Q=[],de=[];function q(H){if(H.samples>0){if(B(H)===!1){const O=H.textures,J=H.width,le=H.height;let Se=t.COLOR_BUFFER_BIT;const we=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ae=r.get(H),Le=O.length>1;if(Le)for(let Ve=0;Ve<O.length;Ve++)n.bindFramebuffer(t.FRAMEBUFFER,ae.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,ae.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,ae.__webglMultisampledFramebuffer);const Be=H.texture.mipmaps;Be&&Be.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ae.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ae.__webglFramebuffer);for(let Ve=0;Ve<O.length;Ve++){if(H.resolveDepthBuffer&&(H.depthBuffer&&(Se|=t.DEPTH_BUFFER_BIT),H.stencilBuffer&&H.resolveStencilBuffer&&(Se|=t.STENCIL_BUFFER_BIT)),Le){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,ae.__webglColorRenderbuffer[Ve]);const He=r.get(O[Ve]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,He,0)}t.blitFramebuffer(0,0,J,le,0,0,J,le,Se,t.NEAREST),c===!0&&(Q.length=0,de.length=0,Q.push(t.COLOR_ATTACHMENT0+Ve),H.depthBuffer&&H.resolveDepthBuffer===!1&&(Q.push(we),de.push(we),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,de)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,Q))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Le)for(let Ve=0;Ve<O.length;Ve++){n.bindFramebuffer(t.FRAMEBUFFER,ae.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,ae.__webglColorRenderbuffer[Ve]);const He=r.get(O[Ve]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,ae.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,He,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ae.__webglMultisampledFramebuffer)}else if(H.depthBuffer&&H.resolveDepthBuffer===!1&&c){const O=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[O])}}}function ee(H){return Math.min(i.maxSamples,H.samples)}function B(H){const O=r.get(H);return H.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function he(H){const O=o.render.frame;d.get(H)!==O&&(d.set(H,O),H.update())}function ke(H,O){const J=H.colorSpace,le=H.format,Se=H.type;return H.isCompressedTexture===!0||H.isVideoTexture===!0||J!==Kg&&J!==Kd&&(cr.getTransfer(J)===Mr?(le!==Ol||Se!==yc)&&pn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ti("WebGLTextures: Unsupported texture color space:",J)),O}function pe(H){return typeof HTMLImageElement<"u"&&H instanceof HTMLImageElement?(u.width=H.naturalWidth||H.width,u.height=H.naturalHeight||H.height):typeof VideoFrame<"u"&&H instanceof VideoFrame?(u.width=H.displayWidth,u.height=H.displayHeight):(u.width=H.width,u.height=H.height),u}this.allocateTextureUnit=U,this.resetTextureUnits=L,this.setTexture2D=V,this.setTexture2DArray=K,this.setTexture3D=z,this.setTextureCube=X,this.rebindTextures=xe,this.setupRenderTarget=Ze,this.updateRenderTargetMipmap=G,this.updateMultisampleRenderTarget=q,this.setupDepthRenderbuffer=Fe,this.setupFrameBufferTexture=Te,this.useMultisampledRTT=B}function oye(t,e){function n(r,i=Kd){let s;const o=cr.getTransfer(i);if(r===yc)return t.UNSIGNED_BYTE;if(r===$R)return t.UNSIGNED_SHORT_4_4_4_4;if(r===VR)return t.UNSIGNED_SHORT_5_5_5_1;if(r===XW)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===YW)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===WW)return t.BYTE;if(r===KW)return t.SHORT;if(r===Y0)return t.UNSIGNED_SHORT;if(r===HR)return t.INT;if(r===um)return t.UNSIGNED_INT;if(r===wu)return t.FLOAT;if(r===wx)return t.HALF_FLOAT;if(r===QW)return t.ALPHA;if(r===ZW)return t.RGB;if(r===Ol)return t.RGBA;if(r===Z0)return t.DEPTH_COMPONENT;if(r===J0)return t.DEPTH_STENCIL;if(r===JW)return t.RED;if(r===GR)return t.RED_INTEGER;if(r===qR)return t.RG;if(r===WR)return t.RG_INTEGER;if(r===KR)return t.RGBA_INTEGER;if(r===y1||r===v1||r===w1||r===_1)if(o===Mr)if(s=e.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(r===y1)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===v1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===w1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===_1)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=e.get("WEBGL_compressed_texture_s3tc"),s!==null){if(r===y1)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===v1)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===w1)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===_1)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===RP||r===OP||r===LP||r===FP)if(s=e.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(r===RP)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===OP)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===LP)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===FP)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===IP||r===UP||r===zP)if(s=e.get("WEBGL_compressed_texture_etc"),s!==null){if(r===IP||r===UP)return o===Mr?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(r===zP)return o===Mr?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===BP||r===HP||r===$P||r===VP||r===GP||r===qP||r===WP||r===KP||r===XP||r===YP||r===QP||r===ZP||r===JP||r===e3)if(s=e.get("WEBGL_compressed_texture_astc"),s!==null){if(r===BP)return o===Mr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===HP)return o===Mr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===$P)return o===Mr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===VP)return o===Mr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===GP)return o===Mr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===qP)return o===Mr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===WP)return o===Mr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===KP)return o===Mr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===XP)return o===Mr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===YP)return o===Mr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===QP)return o===Mr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===ZP)return o===Mr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===JP)return o===Mr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===e3)return o===Mr?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===t3||r===n3||r===r3)if(s=e.get("EXT_texture_compression_bptc"),s!==null){if(r===t3)return o===Mr?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===n3)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===r3)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===i3||r===a3||r===s3||r===o3)if(s=e.get("EXT_texture_compression_rgtc"),s!==null){if(r===i3)return s.COMPRESSED_RED_RGTC1_EXT;if(r===a3)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===s3)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===o3)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===Q0?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const lye=`
  3825. void main() {
  3826. gl_Position = vec4( position, 1.0 );
  3827. }`,cye=`
  3828. uniform sampler2DArray depthColor;
  3829. uniform float depthWidth;
  3830. uniform float depthHeight;
  3831. void main() {
  3832. vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
  3833. if ( coord.x >= 1.0 ) {
  3834. gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
  3835. } else {
  3836. gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
  3837. }
  3838. }`;class uye{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new vK(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 Fu({vertexShader:lye,fragmentShader:cye,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new dl(new eO(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let dye=class extends Tm{constructor(e,n){super();const r=this;let i=null,s=1,o=null,l="local-floor",c=1,u=null,d=null,h=null,p=null,m=null,x=null;const y=typeof XRWebGLBinding<"u",v=new uye,b={},S=n.getContextAttributes();let N=null,T=null;const k=[],C=[],E=new Cn;let P=null;const A=new Qo;A.viewport=new Bi;const D=new Qo;D.viewport=new Bi;const I=[A,D],L=new Tpe;let U=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(me){let ue=k[me];return ue===void 0&&(ue=new TT,k[me]=ue),ue.getTargetRaySpace()},this.getControllerGrip=function(me){let ue=k[me];return ue===void 0&&(ue=new TT,k[me]=ue),ue.getGripSpace()},this.getHand=function(me){let ue=k[me];return ue===void 0&&(ue=new TT,k[me]=ue),ue.getHandSpace()};function V(me){const ue=C.indexOf(me.inputSource);if(ue===-1)return;const Te=k[ue];Te!==void 0&&(Te.update(me.inputSource,me.frame,u||o),Te.dispatchEvent({type:me.type,data:me.inputSource}))}function K(){i.removeEventListener("select",V),i.removeEventListener("selectstart",V),i.removeEventListener("selectend",V),i.removeEventListener("squeeze",V),i.removeEventListener("squeezestart",V),i.removeEventListener("squeezeend",V),i.removeEventListener("end",K),i.removeEventListener("inputsourceschange",z);for(let me=0;me<k.length;me++){const ue=C[me];ue!==null&&(C[me]=null,k[me].disconnect(ue))}U=null,j=null,v.reset();for(const me in b)delete b[me];e.setRenderTarget(N),m=null,p=null,h=null,i=null,T=null,ge.stop(),r.isPresenting=!1,e.setPixelRatio(P),e.setSize(E.width,E.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(me){s=me,r.isPresenting===!0&&pn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(me){l=me,r.isPresenting===!0&&pn("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(me){u=me},this.getBaseLayer=function(){return p!==null?p:m},this.getBinding=function(){return h===null&&y&&(h=new XRWebGLBinding(i,n)),h},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(me){if(i=me,i!==null){if(N=e.getRenderTarget(),i.addEventListener("select",V),i.addEventListener("selectstart",V),i.addEventListener("selectend",V),i.addEventListener("squeeze",V),i.addEventListener("squeezestart",V),i.addEventListener("squeezeend",V),i.addEventListener("end",K),i.addEventListener("inputsourceschange",z),S.xrCompatible!==!0&&await n.makeXRCompatible(),P=e.getPixelRatio(),e.getSize(E),y&&"createProjectionLayer"in XRWebGLBinding.prototype){let Te=null,ie=null,Ce=null;S.depth&&(Ce=S.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Te=S.stencil?J0:Z0,ie=S.stencil?Q0:um);const Fe={colorFormat:n.RGBA8,depthFormat:Ce,scaleFactor:s};h=this.getBinding(),p=h.createProjectionLayer(Fe),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),T=new hm(p.textureWidth,p.textureHeight,{format:Ol,type:yc,depthTexture:new yK(p.textureWidth,p.textureHeight,ie,void 0,void 0,void 0,void 0,void 0,void 0,Te),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}else{const Te={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,Te),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),T=new hm(m.framebufferWidth,m.framebufferHeight,{format:Ol,type:yc,colorSpace:e.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:m.ignoreDepthValues===!1,resolveStencilBuffer:m.ignoreDepthValues===!1})}T.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),ge.setContext(i),ge.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function z(me){for(let ue=0;ue<me.removed.length;ue++){const Te=me.removed[ue],ie=C.indexOf(Te);ie>=0&&(C[ie]=null,k[ie].disconnect(Te))}for(let ue=0;ue<me.added.length;ue++){const Te=me.added[ue];let ie=C.indexOf(Te);if(ie===-1){for(let Fe=0;Fe<k.length;Fe++)if(Fe>=C.length){C.push(Te),ie=Fe;break}else if(C[Fe]===null){C[Fe]=Te,ie=Fe;break}if(ie===-1)break}const Ce=k[ie];Ce&&Ce.connect(Te)}}const X=new mt,Y=new mt;function te(me,ue,Te){X.setFromMatrixPosition(ue.matrixWorld),Y.setFromMatrixPosition(Te.matrixWorld);const ie=X.distanceTo(Y),Ce=ue.projectionMatrix.elements,Fe=Te.projectionMatrix.elements,xe=Ce[14]/(Ce[10]-1),Ze=Ce[14]/(Ce[10]+1),G=(Ce[9]+1)/Ce[5],Q=(Ce[9]-1)/Ce[5],de=(Ce[8]-1)/Ce[0],q=(Fe[8]+1)/Fe[0],ee=xe*de,B=xe*q,he=ie/(-de+q),ke=he*-de;if(ue.matrixWorld.decompose(me.position,me.quaternion,me.scale),me.translateX(ke),me.translateZ(he),me.matrixWorld.compose(me.position,me.quaternion,me.scale),me.matrixWorldInverse.copy(me.matrixWorld).invert(),Ce[10]===-1)me.projectionMatrix.copy(ue.projectionMatrix),me.projectionMatrixInverse.copy(ue.projectionMatrixInverse);else{const pe=xe+he,H=Ze+he,O=ee-ke,J=B+(ie-ke),le=G*Ze/H*pe,Se=Q*Ze/H*pe;me.projectionMatrix.makePerspective(O,J,le,Se,pe,H),me.projectionMatrixInverse.copy(me.projectionMatrix).invert()}}function $(me,ue){ue===null?me.matrixWorld.copy(me.matrix):me.matrixWorld.multiplyMatrices(ue.matrixWorld,me.matrix),me.matrixWorldInverse.copy(me.matrixWorld).invert()}this.updateCamera=function(me){if(i===null)return;let ue=me.near,Te=me.far;v.texture!==null&&(v.depthNear>0&&(ue=v.depthNear),v.depthFar>0&&(Te=v.depthFar)),L.near=D.near=A.near=ue,L.far=D.far=A.far=Te,(U!==L.near||j!==L.far)&&(i.updateRenderState({depthNear:L.near,depthFar:L.far}),U=L.near,j=L.far),L.layers.mask=me.layers.mask|6,A.layers.mask=L.layers.mask&3,D.layers.mask=L.layers.mask&5;const ie=me.parent,Ce=L.cameras;$(L,ie);for(let Fe=0;Fe<Ce.length;Fe++)$(Ce[Fe],ie);Ce.length===2?te(L,A,D):L.projectionMatrix.copy(A.projectionMatrix),W(me,L,ie)};function W(me,ue,Te){Te===null?me.matrix.copy(ue.matrixWorld):(me.matrix.copy(Te.matrixWorld),me.matrix.invert(),me.matrix.multiply(ue.matrixWorld)),me.matrix.decompose(me.position,me.quaternion,me.scale),me.updateMatrixWorld(!0),me.projectionMatrix.copy(ue.projectionMatrix),me.projectionMatrixInverse.copy(ue.projectionMatrixInverse),me.isPerspectiveCamera&&(me.fov=l3*2*Math.atan(1/me.projectionMatrix.elements[5]),me.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(p===null&&m===null))return c},this.setFoveation=function(me){c=me,p!==null&&(p.fixedFoveation=me),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=me)},this.hasDepthSensing=function(){return v.texture!==null},this.getDepthSensingMesh=function(){return v.getMesh(L)},this.getCameraTexture=function(me){return b[me]};let ne=null;function re(me,ue){if(d=ue.getViewerPose(u||o),x=ue,d!==null){const Te=d.views;m!==null&&(e.setRenderTargetFramebuffer(T,m.framebuffer),e.setRenderTarget(T));let ie=!1;Te.length!==L.cameras.length&&(L.cameras.length=0,ie=!0);for(let Ze=0;Ze<Te.length;Ze++){const G=Te[Ze];let Q=null;if(m!==null)Q=m.getViewport(G);else{const q=h.getViewSubImage(p,G);Q=q.viewport,Ze===0&&(e.setRenderTargetTextures(T,q.colorTexture,q.depthStencilTexture),e.setRenderTarget(T))}let de=I[Ze];de===void 0&&(de=new Qo,de.layers.enable(Ze),de.viewport=new Bi,I[Ze]=de),de.matrix.fromArray(G.transform.matrix),de.matrix.decompose(de.position,de.quaternion,de.scale),de.projectionMatrix.fromArray(G.projectionMatrix),de.projectionMatrixInverse.copy(de.projectionMatrix).invert(),de.viewport.set(Q.x,Q.y,Q.width,Q.height),Ze===0&&(L.matrix.copy(de.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),ie===!0&&L.cameras.push(de)}const Ce=i.enabledFeatures;if(Ce&&Ce.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&y){h=r.getBinding();const Ze=h.getDepthInformation(Te[0]);Ze&&Ze.isValid&&Ze.texture&&v.init(Ze,i.renderState)}if(Ce&&Ce.includes("camera-access")&&y){e.state.unbindTexture(),h=r.getBinding();for(let Ze=0;Ze<Te.length;Ze++){const G=Te[Ze].camera;if(G){let Q=b[G];Q||(Q=new vK,b[G]=Q);const de=h.getCameraImage(G);Q.sourceTexture=de}}}}for(let Te=0;Te<k.length;Te++){const ie=C[Te],Ce=k[Te];ie!==null&&Ce!==void 0&&Ce.update(ie,ue,u||o)}ne&&ne(me,ue),ue.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ue}),x=null}const ge=new MK;ge.setAnimationLoop(re),this.setAnimationLoop=function(me){ne=me},this.dispose=function(){}}};const mf=new Nh,hye=new Gi;function fye(t,e){function n(v,b){v.matrixAutoUpdate===!0&&v.updateMatrix(),b.value.copy(v.matrix)}function r(v,b){b.color.getRGB(v.fogColor.value,pK(t)),b.isFog?(v.fogNear.value=b.near,v.fogFar.value=b.far):b.isFogExp2&&(v.fogDensity.value=b.density)}function i(v,b,S,N,T){b.isMeshBasicMaterial||b.isMeshLambertMaterial?s(v,b):b.isMeshToonMaterial?(s(v,b),h(v,b)):b.isMeshPhongMaterial?(s(v,b),d(v,b)):b.isMeshStandardMaterial?(s(v,b),p(v,b),b.isMeshPhysicalMaterial&&m(v,b,T)):b.isMeshMatcapMaterial?(s(v,b),x(v,b)):b.isMeshDepthMaterial?s(v,b):b.isMeshDistanceMaterial?(s(v,b),y(v,b)):b.isMeshNormalMaterial?s(v,b):b.isLineBasicMaterial?(o(v,b),b.isLineDashedMaterial&&l(v,b)):b.isPointsMaterial?c(v,b,S,N):b.isSpriteMaterial?u(v,b):b.isShadowMaterial?(v.color.value.copy(b.color),v.opacity.value=b.opacity):b.isShaderMaterial&&(b.uniformsNeedUpdate=!1)}function s(v,b){v.opacity.value=b.opacity,b.color&&v.diffuse.value.copy(b.color),b.emissive&&v.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity),b.map&&(v.map.value=b.map,n(b.map,v.mapTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.bumpMap&&(v.bumpMap.value=b.bumpMap,n(b.bumpMap,v.bumpMapTransform),v.bumpScale.value=b.bumpScale,b.side===Bs&&(v.bumpScale.value*=-1)),b.normalMap&&(v.normalMap.value=b.normalMap,n(b.normalMap,v.normalMapTransform),v.normalScale.value.copy(b.normalScale),b.side===Bs&&v.normalScale.value.negate()),b.displacementMap&&(v.displacementMap.value=b.displacementMap,n(b.displacementMap,v.displacementMapTransform),v.displacementScale.value=b.displacementScale,v.displacementBias.value=b.displacementBias),b.emissiveMap&&(v.emissiveMap.value=b.emissiveMap,n(b.emissiveMap,v.emissiveMapTransform)),b.specularMap&&(v.specularMap.value=b.specularMap,n(b.specularMap,v.specularMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest);const S=e.get(b),N=S.envMap,T=S.envMapRotation;N&&(v.envMap.value=N,mf.copy(T),mf.x*=-1,mf.y*=-1,mf.z*=-1,N.isCubeTexture&&N.isRenderTargetTexture===!1&&(mf.y*=-1,mf.z*=-1),v.envMapRotation.value.setFromMatrix4(hye.makeRotationFromEuler(mf)),v.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=b.reflectivity,v.ior.value=b.ior,v.refractionRatio.value=b.refractionRatio),b.lightMap&&(v.lightMap.value=b.lightMap,v.lightMapIntensity.value=b.lightMapIntensity,n(b.lightMap,v.lightMapTransform)),b.aoMap&&(v.aoMap.value=b.aoMap,v.aoMapIntensity.value=b.aoMapIntensity,n(b.aoMap,v.aoMapTransform))}function o(v,b){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,b.map&&(v.map.value=b.map,n(b.map,v.mapTransform))}function l(v,b){v.dashSize.value=b.dashSize,v.totalSize.value=b.dashSize+b.gapSize,v.scale.value=b.scale}function c(v,b,S,N){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,v.size.value=b.size*S,v.scale.value=N*.5,b.map&&(v.map.value=b.map,n(b.map,v.uvTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest)}function u(v,b){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,v.rotation.value=b.rotation,b.map&&(v.map.value=b.map,n(b.map,v.mapTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest)}function d(v,b){v.specular.value.copy(b.specular),v.shininess.value=Math.max(b.shininess,1e-4)}function h(v,b){b.gradientMap&&(v.gradientMap.value=b.gradientMap)}function p(v,b){v.metalness.value=b.metalness,b.metalnessMap&&(v.metalnessMap.value=b.metalnessMap,n(b.metalnessMap,v.metalnessMapTransform)),v.roughness.value=b.roughness,b.roughnessMap&&(v.roughnessMap.value=b.roughnessMap,n(b.roughnessMap,v.roughnessMapTransform)),b.envMap&&(v.envMapIntensity.value=b.envMapIntensity)}function m(v,b,S){v.ior.value=b.ior,b.sheen>0&&(v.sheenColor.value.copy(b.sheenColor).multiplyScalar(b.sheen),v.sheenRoughness.value=b.sheenRoughness,b.sheenColorMap&&(v.sheenColorMap.value=b.sheenColorMap,n(b.sheenColorMap,v.sheenColorMapTransform)),b.sheenRoughnessMap&&(v.sheenRoughnessMap.value=b.sheenRoughnessMap,n(b.sheenRoughnessMap,v.sheenRoughnessMapTransform))),b.clearcoat>0&&(v.clearcoat.value=b.clearcoat,v.clearcoatRoughness.value=b.clearcoatRoughness,b.clearcoatMap&&(v.clearcoatMap.value=b.clearcoatMap,n(b.clearcoatMap,v.clearcoatMapTransform)),b.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=b.clearcoatRoughnessMap,n(b.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),b.clearcoatNormalMap&&(v.clearcoatNormalMap.value=b.clearcoatNormalMap,n(b.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(b.clearcoatNormalScale),b.side===Bs&&v.clearcoatNormalScale.value.negate())),b.dispersion>0&&(v.dispersion.value=b.dispersion),b.iridescence>0&&(v.iridescence.value=b.iridescence,v.iridescenceIOR.value=b.iridescenceIOR,v.iridescenceThicknessMinimum.value=b.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=b.iridescenceThicknessRange[1],b.iridescenceMap&&(v.iridescenceMap.value=b.iridescenceMap,n(b.iridescenceMap,v.iridescenceMapTransform)),b.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=b.iridescenceThicknessMap,n(b.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),b.transmission>0&&(v.transmission.value=b.transmission,v.transmissionSamplerMap.value=S.texture,v.transmissionSamplerSize.value.set(S.width,S.height),b.transmissionMap&&(v.transmissionMap.value=b.transmissionMap,n(b.transmissionMap,v.transmissionMapTransform)),v.thickness.value=b.thickness,b.thicknessMap&&(v.thicknessMap.value=b.thicknessMap,n(b.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=b.attenuationDistance,v.attenuationColor.value.copy(b.attenuationColor)),b.anisotropy>0&&(v.anisotropyVector.value.set(b.anisotropy*Math.cos(b.anisotropyRotation),b.anisotropy*Math.sin(b.anisotropyRotation)),b.anisotropyMap&&(v.anisotropyMap.value=b.anisotropyMap,n(b.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=b.specularIntensity,v.specularColor.value.copy(b.specularColor),b.specularColorMap&&(v.specularColorMap.value=b.specularColorMap,n(b.specularColorMap,v.specularColorMapTransform)),b.specularIntensityMap&&(v.specularIntensityMap.value=b.specularIntensityMap,n(b.specularIntensityMap,v.specularIntensityMapTransform))}function x(v,b){b.matcap&&(v.matcap.value=b.matcap)}function y(v,b){const S=e.get(b).light;v.referencePosition.value.setFromMatrixPosition(S.matrixWorld),v.nearDistance.value=S.shadow.camera.near,v.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function mye(t,e,n,r){let i={},s={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,N){const T=N.program;r.uniformBlockBinding(S,T)}function u(S,N){let T=i[S.id];T===void 0&&(x(S),T=d(S),i[S.id]=T,S.addEventListener("dispose",v));const k=N.program;r.updateUBOMapping(S,k);const C=e.render.frame;s[S.id]!==C&&(p(S),s[S.id]=C)}function d(S){const N=h();S.__bindingPointIndex=N;const T=t.createBuffer(),k=S.__size,C=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,k,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,N,T),T}function h(){for(let S=0;S<l;S++)if(o.indexOf(S)===-1)return o.push(S),S;return Ti("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(S){const N=i[S.id],T=S.uniforms,k=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,N);for(let C=0,E=T.length;C<E;C++){const P=Array.isArray(T[C])?T[C]:[T[C]];for(let A=0,D=P.length;A<D;A++){const I=P[A];if(m(I,C,A,k)===!0){const L=I.__offset,U=Array.isArray(I.value)?I.value:[I.value];let j=0;for(let V=0;V<U.length;V++){const K=U[V],z=y(K);typeof K=="number"||typeof K=="boolean"?(I.__data[0]=K,t.bufferSubData(t.UNIFORM_BUFFER,L+j,I.__data)):K.isMatrix3?(I.__data[0]=K.elements[0],I.__data[1]=K.elements[1],I.__data[2]=K.elements[2],I.__data[3]=0,I.__data[4]=K.elements[3],I.__data[5]=K.elements[4],I.__data[6]=K.elements[5],I.__data[7]=0,I.__data[8]=K.elements[6],I.__data[9]=K.elements[7],I.__data[10]=K.elements[8],I.__data[11]=0):(K.toArray(I.__data,j),j+=z.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,L,I.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(S,N,T,k){const C=S.value,E=N+"_"+T;if(k[E]===void 0)return typeof C=="number"||typeof C=="boolean"?k[E]=C:k[E]=C.clone(),!0;{const P=k[E];if(typeof C=="number"||typeof C=="boolean"){if(P!==C)return k[E]=C,!0}else if(P.equals(C)===!1)return P.copy(C),!0}return!1}function x(S){const N=S.uniforms;let T=0;const k=16;for(let E=0,P=N.length;E<P;E++){const A=Array.isArray(N[E])?N[E]:[N[E]];for(let D=0,I=A.length;D<I;D++){const L=A[D],U=Array.isArray(L.value)?L.value:[L.value];for(let j=0,V=U.length;j<V;j++){const K=U[j],z=y(K),X=T%k,Y=X%z.boundary,te=X+Y;T+=Y,te!==0&&k-te<z.storage&&(T+=k-te),L.__data=new Float32Array(z.storage/Float32Array.BYTES_PER_ELEMENT),L.__offset=T,T+=z.storage}}}const C=T%k;return C>0&&(T+=k-C),S.__size=T,S.__cache={},this}function y(S){const N={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(N.boundary=4,N.storage=4):S.isVector2?(N.boundary=8,N.storage=8):S.isVector3||S.isColor?(N.boundary=16,N.storage=12):S.isVector4?(N.boundary=16,N.storage=16):S.isMatrix3?(N.boundary=48,N.storage=48):S.isMatrix4?(N.boundary=64,N.storage=64):S.isTexture?pn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):pn("WebGLRenderer: Unsupported uniform value type.",S),N}function v(S){const N=S.target;N.removeEventListener("dispose",v);const T=o.indexOf(N.__bindingPointIndex);o.splice(T,1),t.deleteBuffer(i[N.id]),delete i[N.id],delete s[N.id]}function b(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},s={}}return{bind:c,update:u,dispose:b}}const pye=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 eu=null;function gye(){return eu===null&&(eu=new fpe(pye,32,32,qR,wx),eu.minFilter=rl,eu.magFilter=rl,eu.wrapS=vu,eu.wrapT=vu,eu.generateMipmaps=!1,eu.needsUpdate=!0),eu}let xye=class{constructor(e={}){const{canvas:n=Ime(),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:h=!1,reversedDepthBuffer:p=!1}=e;this.isWebGLRenderer=!0;let m;if(r!==null){if(typeof WebGLRenderingContext<"u"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");m=r.getContextAttributes().alpha}else m=o;const x=new Set([KR,WR,GR]),y=new Set([yc,um,Y0,Q0,$R,VR]),v=new Uint32Array(4),b=new Int32Array(4);let S=null,N=null;const T=[],k=[];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=lh,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let E=!1;this._outputColorSpace=co;let P=0,A=0,D=null,I=-1,L=null;const U=new Bi,j=new Bi;let V=null;const K=new Rn(0);let z=0,X=n.width,Y=n.height,te=1,$=null,W=null;const ne=new Bi(0,0,X,Y),re=new Bi(0,0,X,Y);let ge=!1;const me=new JR;let ue=!1,Te=!1;const ie=new Gi,Ce=new mt,Fe=new Bi,xe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ze=!1;function G(){return D===null?te:1}let Q=r;function de(fe,Re){return n.getContext(fe,Re)}try{const fe={alpha:!0,depth:i,stencil:s,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:h};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${zR}`),n.addEventListener("webglcontextlost",ze,!1),n.addEventListener("webglcontextrestored",ce,!1),n.addEventListener("webglcontextcreationerror",$e,!1),Q===null){const Re="webgl2";if(Q=de(Re,fe),Q===null)throw de(Re)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(fe){throw fe("WebGLRenderer: "+fe.message),fe}let q,ee,B,he,ke,pe,H,O,J,le,Se,we,ae,Le,Be,Ve,He,be,Pe,Ie,_e,Ke,Me,it;function Ee(){q=new Mbe(Q),q.init(),Ke=new oye(Q,q),ee=new gbe(Q,q,e,Ke),B=new aye(Q,q),ee.reversedDepthBuffer&&p&&B.buffers.depth.setReversed(!0),he=new Tbe(Q),ke=new q0e,pe=new sye(Q,q,B,ke,ee,Ke,he),H=new bbe(C),O=new Nbe(C),J=new Ppe(Q),Me=new mbe(Q,J),le=new kbe(Q,J,he,Me),Se=new Cbe(Q,le,J,he),Pe=new Abe(Q,ee,pe),Ve=new xbe(ke),we=new G0e(C,H,O,q,ee,Me,Ve),ae=new fye(C,ke),Le=new K0e,Be=new eye(q),be=new fbe(C,H,O,B,Se,m,c),He=new rye(C,Se,ee),it=new mye(Q,he,ee,B),Ie=new pbe(Q,q,he),_e=new Ebe(Q,q,he),he.programs=we.programs,C.capabilities=ee,C.extensions=q,C.properties=ke,C.renderLists=Le,C.shadowMap=He,C.state=B,C.info=he}Ee();const Xe=new dye(C,Q);this.xr=Xe,this.getContext=function(){return Q},this.getContextAttributes=function(){return Q.getContextAttributes()},this.forceContextLoss=function(){const fe=q.get("WEBGL_lose_context");fe&&fe.loseContext()},this.forceContextRestore=function(){const fe=q.get("WEBGL_lose_context");fe&&fe.restoreContext()},this.getPixelRatio=function(){return te},this.setPixelRatio=function(fe){fe!==void 0&&(te=fe,this.setSize(X,Y,!1))},this.getSize=function(fe){return fe.set(X,Y)},this.setSize=function(fe,Re,Ge=!0){if(Xe.isPresenting){pn("WebGLRenderer: Can't change size while VR device is presenting.");return}X=fe,Y=Re,n.width=Math.floor(fe*te),n.height=Math.floor(Re*te),Ge===!0&&(n.style.width=fe+"px",n.style.height=Re+"px"),this.setViewport(0,0,fe,Re)},this.getDrawingBufferSize=function(fe){return fe.set(X*te,Y*te).floor()},this.setDrawingBufferSize=function(fe,Re,Ge){X=fe,Y=Re,te=Ge,n.width=Math.floor(fe*Ge),n.height=Math.floor(Re*Ge),this.setViewport(0,0,fe,Re)},this.getCurrentViewport=function(fe){return fe.copy(U)},this.getViewport=function(fe){return fe.copy(ne)},this.setViewport=function(fe,Re,Ge,Ne){fe.isVector4?ne.set(fe.x,fe.y,fe.z,fe.w):ne.set(fe,Re,Ge,Ne),B.viewport(U.copy(ne).multiplyScalar(te).round())},this.getScissor=function(fe){return fe.copy(re)},this.setScissor=function(fe,Re,Ge,Ne){fe.isVector4?re.set(fe.x,fe.y,fe.z,fe.w):re.set(fe,Re,Ge,Ne),B.scissor(j.copy(re).multiplyScalar(te).round())},this.getScissorTest=function(){return ge},this.setScissorTest=function(fe){B.setScissorTest(ge=fe)},this.setOpaqueSort=function(fe){$=fe},this.setTransparentSort=function(fe){W=fe},this.getClearColor=function(fe){return fe.copy(be.getClearColor())},this.setClearColor=function(){be.setClearColor(...arguments)},this.getClearAlpha=function(){return be.getClearAlpha()},this.setClearAlpha=function(){be.setClearAlpha(...arguments)},this.clear=function(fe=!0,Re=!0,Ge=!0){let Ne=0;if(fe){let Oe=!1;if(D!==null){const nt=D.texture.format;Oe=x.has(nt)}if(Oe){const nt=D.texture.type,Ye=y.has(nt),Tt=be.getClearColor(),At=be.getClearAlpha(),It=Tt.r,Rt=Tt.g,Mt=Tt.b;Ye?(v[0]=It,v[1]=Rt,v[2]=Mt,v[3]=At,Q.clearBufferuiv(Q.COLOR,0,v)):(b[0]=It,b[1]=Rt,b[2]=Mt,b[3]=At,Q.clearBufferiv(Q.COLOR,0,b))}else Ne|=Q.COLOR_BUFFER_BIT}Re&&(Ne|=Q.DEPTH_BUFFER_BIT),Ge&&(Ne|=Q.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Q.clear(Ne)},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",ze,!1),n.removeEventListener("webglcontextrestored",ce,!1),n.removeEventListener("webglcontextcreationerror",$e,!1),be.dispose(),Le.dispose(),Be.dispose(),ke.dispose(),H.dispose(),O.dispose(),Se.dispose(),Me.dispose(),it.dispose(),we.dispose(),Xe.dispose(),Xe.removeEventListener("sessionstart",cn),Xe.removeEventListener("sessionend",rr),Vn.stop()};function ze(fe){fe.preventDefault(),tB("WebGLRenderer: Context Lost."),E=!0}function ce(){tB("WebGLRenderer: Context Restored."),E=!1;const fe=he.autoReset,Re=He.enabled,Ge=He.autoUpdate,Ne=He.needsUpdate,Oe=He.type;Ee(),he.autoReset=fe,He.enabled=Re,He.autoUpdate=Ge,He.needsUpdate=Ne,He.type=Oe}function $e(fe){Ti("WebGLRenderer: A WebGL context could not be created. Reason: ",fe.statusMessage)}function ye(fe){const Re=fe.target;Re.removeEventListener("dispose",ye),Je(Re)}function Je(fe){at(fe),ke.remove(fe)}function at(fe){const Re=ke.get(fe).programs;Re!==void 0&&(Re.forEach(function(Ge){we.releaseProgram(Ge)}),fe.isShaderMaterial&&we.releaseShaderCache(fe))}this.renderBufferDirect=function(fe,Re,Ge,Ne,Oe,nt){Re===null&&(Re=xe);const Ye=Oe.isMesh&&Oe.matrixWorld.determinant()<0,Tt=je(fe,Re,Ge,Ne,Oe);B.setMaterial(Ne,Ye);let At=Ge.index,It=1;if(Ne.wireframe===!0){if(At=le.getWireframeAttribute(Ge),At===void 0)return;It=2}const Rt=Ge.drawRange,Mt=Ge.attributes.position;let en=Rt.start*It,Ht=(Rt.start+Rt.count)*It;nt!==null&&(en=Math.max(en,nt.start*It),Ht=Math.min(Ht,(nt.start+nt.count)*It)),At!==null?(en=Math.max(en,0),Ht=Math.min(Ht,At.count)):Mt!=null&&(en=Math.max(en,0),Ht=Math.min(Ht,Mt.count));const hn=Ht-en;if(hn<0||hn===1/0)return;Me.setup(Oe,Ne,Tt,Ge,At);let un,Mn=Ie;if(At!==null&&(un=J.get(At),Mn=_e,Mn.setIndex(un)),Oe.isMesh)Ne.wireframe===!0?(B.setLineWidth(Ne.wireframeLinewidth*G()),Mn.setMode(Q.LINES)):Mn.setMode(Q.TRIANGLES);else if(Oe.isLine){let Gt=Ne.linewidth;Gt===void 0&&(Gt=1),B.setLineWidth(Gt*G()),Oe.isLineSegments?Mn.setMode(Q.LINES):Oe.isLineLoop?Mn.setMode(Q.LINE_LOOP):Mn.setMode(Q.LINE_STRIP)}else Oe.isPoints?Mn.setMode(Q.POINTS):Oe.isSprite&&Mn.setMode(Q.TRIANGLES);if(Oe.isBatchedMesh)if(Oe._multiDrawInstances!==null)ey("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Mn.renderMultiDrawInstances(Oe._multiDrawStarts,Oe._multiDrawCounts,Oe._multiDrawCount,Oe._multiDrawInstances);else if(q.get("WEBGL_multi_draw"))Mn.renderMultiDraw(Oe._multiDrawStarts,Oe._multiDrawCounts,Oe._multiDrawCount);else{const Gt=Oe._multiDrawStarts,on=Oe._multiDrawCounts,dn=Oe._multiDrawCount,Yt=At?J.get(At).bytesPerElement:1,ir=ke.get(Ne).currentProgram.getUniforms();for(let Pn=0;Pn<dn;Pn++)ir.setValue(Q,"_gl_DrawID",Pn),Mn.render(Gt[Pn]/Yt,on[Pn])}else if(Oe.isInstancedMesh)Mn.renderInstances(en,hn,Oe.count);else if(Ge.isInstancedBufferGeometry){const Gt=Ge._maxInstanceCount!==void 0?Ge._maxInstanceCount:1/0,on=Math.min(Ge.instanceCount,Gt);Mn.renderInstances(en,hn,on)}else Mn.render(en,hn)};function jt(fe,Re,Ge){fe.transparent===!0&&fe.side===sc&&fe.forceSinglePass===!1?(fe.side=Bs,fe.needsUpdate=!0,Nn(fe,Re,Ge),fe.side=Sh,fe.needsUpdate=!0,Nn(fe,Re,Ge),fe.side=sc):Nn(fe,Re,Ge)}this.compile=function(fe,Re,Ge=null){Ge===null&&(Ge=fe),N=Be.get(Ge),N.init(Re),k.push(N),Ge.traverseVisible(function(Oe){Oe.isLight&&Oe.layers.test(Re.layers)&&(N.pushLight(Oe),Oe.castShadow&&N.pushShadow(Oe))}),fe!==Ge&&fe.traverseVisible(function(Oe){Oe.isLight&&Oe.layers.test(Re.layers)&&(N.pushLight(Oe),Oe.castShadow&&N.pushShadow(Oe))}),N.setupLights();const Ne=new Set;return fe.traverse(function(Oe){if(!(Oe.isMesh||Oe.isPoints||Oe.isLine||Oe.isSprite))return;const nt=Oe.material;if(nt)if(Array.isArray(nt))for(let Ye=0;Ye<nt.length;Ye++){const Tt=nt[Ye];jt(Tt,Ge,Oe),Ne.add(Tt)}else jt(nt,Ge,Oe),Ne.add(nt)}),N=k.pop(),Ne},this.compileAsync=function(fe,Re,Ge=null){const Ne=this.compile(fe,Re,Ge);return new Promise(Oe=>{function nt(){if(Ne.forEach(function(Ye){ke.get(Ye).currentProgram.isReady()&&Ne.delete(Ye)}),Ne.size===0){Oe(fe);return}setTimeout(nt,10)}q.get("KHR_parallel_shader_compile")!==null?nt():setTimeout(nt,10)})};let Dt=null;function yn(fe){Dt&&Dt(fe)}function cn(){Vn.stop()}function rr(){Vn.start()}const Vn=new MK;Vn.setAnimationLoop(yn),typeof self<"u"&&Vn.setContext(self),this.setAnimationLoop=function(fe){Dt=fe,Xe.setAnimationLoop(fe),fe===null?Vn.stop():Vn.start()},Xe.addEventListener("sessionstart",cn),Xe.addEventListener("sessionend",rr),this.render=function(fe,Re){if(Re!==void 0&&Re.isCamera!==!0){Ti("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(E===!0)return;if(fe.matrixWorldAutoUpdate===!0&&fe.updateMatrixWorld(),Re.parent===null&&Re.matrixWorldAutoUpdate===!0&&Re.updateMatrixWorld(),Xe.enabled===!0&&Xe.isPresenting===!0&&(Xe.cameraAutoUpdate===!0&&Xe.updateCamera(Re),Re=Xe.getCamera()),fe.isScene===!0&&fe.onBeforeRender(C,fe,Re,D),N=Be.get(fe,k.length),N.init(Re),k.push(N),ie.multiplyMatrices(Re.projectionMatrix,Re.matrixWorldInverse),me.setFromProjectionMatrix(ie,uc,Re.reversedDepth),Te=this.localClippingEnabled,ue=Ve.init(this.clippingPlanes,Te),S=Le.get(fe,T.length),S.init(),T.push(S),Xe.enabled===!0&&Xe.isPresenting===!0){const nt=C.xr.getDepthSensingMesh();nt!==null&&Jn(nt,Re,-1/0,C.sortObjects)}Jn(fe,Re,0,C.sortObjects),S.finish(),C.sortObjects===!0&&S.sort($,W),Ze=Xe.enabled===!1||Xe.isPresenting===!1||Xe.hasDepthSensing()===!1,Ze&&be.addToRenderList(S,fe),this.info.render.frame++,ue===!0&&Ve.beginShadows();const Ge=N.state.shadowsArray;He.render(Ge,fe,Re),ue===!0&&Ve.endShadows(),this.info.autoReset===!0&&this.info.reset();const Ne=S.opaque,Oe=S.transmissive;if(N.setupLights(),Re.isArrayCamera){const nt=Re.cameras;if(Oe.length>0)for(let Ye=0,Tt=nt.length;Ye<Tt;Ye++){const At=nt[Ye];sr(Ne,Oe,fe,At)}Ze&&be.render(fe);for(let Ye=0,Tt=nt.length;Ye<Tt;Ye++){const At=nt[Ye];xn(S,fe,At,At.viewport)}}else Oe.length>0&&sr(Ne,Oe,fe,Re),Ze&&be.render(fe),xn(S,fe,Re);D!==null&&A===0&&(pe.updateMultisampleRenderTarget(D),pe.updateRenderTargetMipmap(D)),fe.isScene===!0&&fe.onAfterRender(C,fe,Re),Me.resetDefaultState(),I=-1,L=null,k.pop(),k.length>0?(N=k[k.length-1],ue===!0&&Ve.setGlobalState(C.clippingPlanes,N.state.camera)):N=null,T.pop(),T.length>0?S=T[T.length-1]:S=null};function Jn(fe,Re,Ge,Ne){if(fe.visible===!1)return;if(fe.layers.test(Re.layers)){if(fe.isGroup)Ge=fe.renderOrder;else if(fe.isLOD)fe.autoUpdate===!0&&fe.update(Re);else if(fe.isLight)N.pushLight(fe),fe.castShadow&&N.pushShadow(fe);else if(fe.isSprite){if(!fe.frustumCulled||me.intersectsSprite(fe)){Ne&&Fe.setFromMatrixPosition(fe.matrixWorld).applyMatrix4(ie);const Ye=Se.update(fe),Tt=fe.material;Tt.visible&&S.push(fe,Ye,Tt,Ge,Fe.z,null)}}else if((fe.isMesh||fe.isLine||fe.isPoints)&&(!fe.frustumCulled||me.intersectsObject(fe))){const Ye=Se.update(fe),Tt=fe.material;if(Ne&&(fe.boundingSphere!==void 0?(fe.boundingSphere===null&&fe.computeBoundingSphere(),Fe.copy(fe.boundingSphere.center)):(Ye.boundingSphere===null&&Ye.computeBoundingSphere(),Fe.copy(Ye.boundingSphere.center)),Fe.applyMatrix4(fe.matrixWorld).applyMatrix4(ie)),Array.isArray(Tt)){const At=Ye.groups;for(let It=0,Rt=At.length;It<Rt;It++){const Mt=At[It],en=Tt[Mt.materialIndex];en&&en.visible&&S.push(fe,Ye,en,Ge,Fe.z,Mt)}}else Tt.visible&&S.push(fe,Ye,Tt,Ge,Fe.z,null)}}const nt=fe.children;for(let Ye=0,Tt=nt.length;Ye<Tt;Ye++)Jn(nt[Ye],Re,Ge,Ne)}function xn(fe,Re,Ge,Ne){const{opaque:Oe,transmissive:nt,transparent:Ye}=fe;N.setupLightsView(Ge),ue===!0&&Ve.setGlobalState(C.clippingPlanes,Ge),Ne&&B.viewport(U.copy(Ne)),Oe.length>0&&Gn(Oe,Re,Ge),nt.length>0&&Gn(nt,Re,Ge),Ye.length>0&&Gn(Ye,Re,Ge),B.buffers.depth.setTest(!0),B.buffers.depth.setMask(!0),B.buffers.color.setMask(!0),B.setPolygonOffset(!1)}function sr(fe,Re,Ge,Ne){if((Ge.isScene===!0?Ge.overrideMaterial:null)!==null)return;N.state.transmissionRenderTarget[Ne.id]===void 0&&(N.state.transmissionRenderTarget[Ne.id]=new hm(1,1,{generateMipmaps:!0,type:q.has("EXT_color_buffer_half_float")||q.has("EXT_color_buffer_float")?wx:yc,minFilter:Rf,samples:4,stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:cr.workingColorSpace}));const nt=N.state.transmissionRenderTarget[Ne.id],Ye=Ne.viewport||U;nt.setSize(Ye.z*C.transmissionResolutionScale,Ye.w*C.transmissionResolutionScale);const Tt=C.getRenderTarget(),At=C.getActiveCubeFace(),It=C.getActiveMipmapLevel();C.setRenderTarget(nt),C.getClearColor(K),z=C.getClearAlpha(),z<1&&C.setClearColor(16777215,.5),C.clear(),Ze&&be.render(Ge);const Rt=C.toneMapping;C.toneMapping=lh;const Mt=Ne.viewport;if(Ne.viewport!==void 0&&(Ne.viewport=void 0),N.setupLightsView(Ne),ue===!0&&Ve.setGlobalState(C.clippingPlanes,Ne),Gn(fe,Ge,Ne),pe.updateMultisampleRenderTarget(nt),pe.updateRenderTargetMipmap(nt),q.has("WEBGL_multisampled_render_to_texture")===!1){let en=!1;for(let Ht=0,hn=Re.length;Ht<hn;Ht++){const un=Re[Ht],{object:Mn,geometry:Gt,material:on,group:dn}=un;if(on.side===sc&&Mn.layers.test(Ne.layers)){const Yt=on.side;on.side=Bs,on.needsUpdate=!0,Xn(Mn,Ge,Ne,Gt,on,dn),on.side=Yt,on.needsUpdate=!0,en=!0}}en===!0&&(pe.updateMultisampleRenderTarget(nt),pe.updateRenderTargetMipmap(nt))}C.setRenderTarget(Tt,At,It),C.setClearColor(K,z),Mt!==void 0&&(Ne.viewport=Mt),C.toneMapping=Rt}function Gn(fe,Re,Ge){const Ne=Re.isScene===!0?Re.overrideMaterial:null;for(let Oe=0,nt=fe.length;Oe<nt;Oe++){const Ye=fe[Oe],{object:Tt,geometry:At,group:It}=Ye;let Rt=Ye.material;Rt.allowOverride===!0&&Ne!==null&&(Rt=Ne),Tt.layers.test(Ge.layers)&&Xn(Tt,Re,Ge,At,Rt,It)}}function Xn(fe,Re,Ge,Ne,Oe,nt){fe.onBeforeRender(C,Re,Ge,Ne,Oe,nt),fe.modelViewMatrix.multiplyMatrices(Ge.matrixWorldInverse,fe.matrixWorld),fe.normalMatrix.getNormalMatrix(fe.modelViewMatrix),Oe.onBeforeRender(C,Re,Ge,Ne,fe,nt),Oe.transparent===!0&&Oe.side===sc&&Oe.forceSinglePass===!1?(Oe.side=Bs,Oe.needsUpdate=!0,C.renderBufferDirect(Ge,Re,Ne,Oe,fe,nt),Oe.side=Sh,Oe.needsUpdate=!0,C.renderBufferDirect(Ge,Re,Ne,Oe,fe,nt),Oe.side=sc):C.renderBufferDirect(Ge,Re,Ne,Oe,fe,nt),fe.onAfterRender(C,Re,Ge,Ne,Oe,nt)}function Nn(fe,Re,Ge){Re.isScene!==!0&&(Re=xe);const Ne=ke.get(fe),Oe=N.state.lights,nt=N.state.shadowsArray,Ye=Oe.state.version,Tt=we.getParameters(fe,Oe.state,nt,Re,Ge),At=we.getProgramCacheKey(Tt);let It=Ne.programs;Ne.environment=fe.isMeshStandardMaterial?Re.environment:null,Ne.fog=Re.fog,Ne.envMap=(fe.isMeshStandardMaterial?O:H).get(fe.envMap||Ne.environment),Ne.envMapRotation=Ne.environment!==null&&fe.envMap===null?Re.environmentRotation:fe.envMapRotation,It===void 0&&(fe.addEventListener("dispose",ye),It=new Map,Ne.programs=It);let Rt=It.get(At);if(Rt!==void 0){if(Ne.currentProgram===Rt&&Ne.lightsStateVersion===Ye)return ai(fe,Tt),Rt}else Tt.uniforms=we.getUniforms(fe),fe.onBeforeCompile(Tt,C),Rt=we.acquireProgram(Tt,At),It.set(At,Rt),Ne.uniforms=Tt.uniforms;const Mt=Ne.uniforms;return(!fe.isShaderMaterial&&!fe.isRawShaderMaterial||fe.clipping===!0)&&(Mt.clippingPlanes=Ve.uniform),ai(fe,Tt),Ne.needsLights=dt(fe),Ne.lightsStateVersion=Ye,Ne.needsLights&&(Mt.ambientLightColor.value=Oe.state.ambient,Mt.lightProbe.value=Oe.state.probe,Mt.directionalLights.value=Oe.state.directional,Mt.directionalLightShadows.value=Oe.state.directionalShadow,Mt.spotLights.value=Oe.state.spot,Mt.spotLightShadows.value=Oe.state.spotShadow,Mt.rectAreaLights.value=Oe.state.rectArea,Mt.ltc_1.value=Oe.state.rectAreaLTC1,Mt.ltc_2.value=Oe.state.rectAreaLTC2,Mt.pointLights.value=Oe.state.point,Mt.pointLightShadows.value=Oe.state.pointShadow,Mt.hemisphereLights.value=Oe.state.hemi,Mt.directionalShadowMap.value=Oe.state.directionalShadowMap,Mt.directionalShadowMatrix.value=Oe.state.directionalShadowMatrix,Mt.spotShadowMap.value=Oe.state.spotShadowMap,Mt.spotLightMatrix.value=Oe.state.spotLightMatrix,Mt.spotLightMap.value=Oe.state.spotLightMap,Mt.pointShadowMap.value=Oe.state.pointShadowMap,Mt.pointShadowMatrix.value=Oe.state.pointShadowMatrix),Ne.currentProgram=Rt,Ne.uniformsList=null,Rt}function hi(fe){if(fe.uniformsList===null){const Re=fe.currentProgram.getUniforms();fe.uniformsList=k1.seqWithValue(Re.seq,fe.uniforms)}return fe.uniformsList}function ai(fe,Re){const Ge=ke.get(fe);Ge.outputColorSpace=Re.outputColorSpace,Ge.batching=Re.batching,Ge.batchingColor=Re.batchingColor,Ge.instancing=Re.instancing,Ge.instancingColor=Re.instancingColor,Ge.instancingMorph=Re.instancingMorph,Ge.skinning=Re.skinning,Ge.morphTargets=Re.morphTargets,Ge.morphNormals=Re.morphNormals,Ge.morphColors=Re.morphColors,Ge.morphTargetsCount=Re.morphTargetsCount,Ge.numClippingPlanes=Re.numClippingPlanes,Ge.numIntersection=Re.numClipIntersection,Ge.vertexAlphas=Re.vertexAlphas,Ge.vertexTangents=Re.vertexTangents,Ge.toneMapping=Re.toneMapping}function je(fe,Re,Ge,Ne,Oe){Re.isScene!==!0&&(Re=xe),pe.resetTextureUnits();const nt=Re.fog,Ye=Ne.isMeshStandardMaterial?Re.environment:null,Tt=D===null?C.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:Kg,At=(Ne.isMeshStandardMaterial?O:H).get(Ne.envMap||Ye),It=Ne.vertexColors===!0&&!!Ge.attributes.color&&Ge.attributes.color.itemSize===4,Rt=!!Ge.attributes.tangent&&(!!Ne.normalMap||Ne.anisotropy>0),Mt=!!Ge.morphAttributes.position,en=!!Ge.morphAttributes.normal,Ht=!!Ge.morphAttributes.color;let hn=lh;Ne.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(hn=C.toneMapping);const un=Ge.morphAttributes.position||Ge.morphAttributes.normal||Ge.morphAttributes.color,Mn=un!==void 0?un.length:0,Gt=ke.get(Ne),on=N.state.lights;if(ue===!0&&(Te===!0||fe!==L)){const Pt=fe===L&&Ne.id===I;Ve.setState(Ne,fe,Pt)}let dn=!1;Ne.version===Gt.__version?(Gt.needsLights&&Gt.lightsStateVersion!==on.state.version||Gt.outputColorSpace!==Tt||Oe.isBatchedMesh&&Gt.batching===!1||!Oe.isBatchedMesh&&Gt.batching===!0||Oe.isBatchedMesh&&Gt.batchingColor===!0&&Oe.colorTexture===null||Oe.isBatchedMesh&&Gt.batchingColor===!1&&Oe.colorTexture!==null||Oe.isInstancedMesh&&Gt.instancing===!1||!Oe.isInstancedMesh&&Gt.instancing===!0||Oe.isSkinnedMesh&&Gt.skinning===!1||!Oe.isSkinnedMesh&&Gt.skinning===!0||Oe.isInstancedMesh&&Gt.instancingColor===!0&&Oe.instanceColor===null||Oe.isInstancedMesh&&Gt.instancingColor===!1&&Oe.instanceColor!==null||Oe.isInstancedMesh&&Gt.instancingMorph===!0&&Oe.morphTexture===null||Oe.isInstancedMesh&&Gt.instancingMorph===!1&&Oe.morphTexture!==null||Gt.envMap!==At||Ne.fog===!0&&Gt.fog!==nt||Gt.numClippingPlanes!==void 0&&(Gt.numClippingPlanes!==Ve.numPlanes||Gt.numIntersection!==Ve.numIntersection)||Gt.vertexAlphas!==It||Gt.vertexTangents!==Rt||Gt.morphTargets!==Mt||Gt.morphNormals!==en||Gt.morphColors!==Ht||Gt.toneMapping!==hn||Gt.morphTargetsCount!==Mn)&&(dn=!0):(dn=!0,Gt.__version=Ne.version);let Yt=Gt.currentProgram;dn===!0&&(Yt=Nn(Ne,Re,Oe));let ir=!1,Pn=!1,si=!1;const ar=Yt.getUniforms(),dr=Gt.uniforms;if(B.useProgram(Yt.program)&&(ir=!0,Pn=!0,si=!0),Ne.id!==I&&(I=Ne.id,Pn=!0),ir||L!==fe){B.buffers.depth.getReversed()&&fe.reversedDepth!==!0&&(fe._reversedDepth=!0,fe.updateProjectionMatrix()),ar.setValue(Q,"projectionMatrix",fe.projectionMatrix),ar.setValue(Q,"viewMatrix",fe.matrixWorldInverse);const qt=ar.map.cameraPosition;qt!==void 0&&qt.setValue(Q,Ce.setFromMatrixPosition(fe.matrixWorld)),ee.logarithmicDepthBuffer&&ar.setValue(Q,"logDepthBufFC",2/(Math.log(fe.far+1)/Math.LN2)),(Ne.isMeshPhongMaterial||Ne.isMeshToonMaterial||Ne.isMeshLambertMaterial||Ne.isMeshBasicMaterial||Ne.isMeshStandardMaterial||Ne.isShaderMaterial)&&ar.setValue(Q,"isOrthographic",fe.isOrthographicCamera===!0),L!==fe&&(L=fe,Pn=!0,si=!0)}if(Oe.isSkinnedMesh){ar.setOptional(Q,Oe,"bindMatrix"),ar.setOptional(Q,Oe,"bindMatrixInverse");const Pt=Oe.skeleton;Pt&&(Pt.boneTexture===null&&Pt.computeBoneTexture(),ar.setValue(Q,"boneTexture",Pt.boneTexture,pe))}Oe.isBatchedMesh&&(ar.setOptional(Q,Oe,"batchingTexture"),ar.setValue(Q,"batchingTexture",Oe._matricesTexture,pe),ar.setOptional(Q,Oe,"batchingIdTexture"),ar.setValue(Q,"batchingIdTexture",Oe._indirectTexture,pe),ar.setOptional(Q,Oe,"batchingColorTexture"),Oe._colorsTexture!==null&&ar.setValue(Q,"batchingColorTexture",Oe._colorsTexture,pe));const rt=Ge.morphAttributes;if((rt.position!==void 0||rt.normal!==void 0||rt.color!==void 0)&&Pe.update(Oe,Ge,Yt),(Pn||Gt.receiveShadow!==Oe.receiveShadow)&&(Gt.receiveShadow=Oe.receiveShadow,ar.setValue(Q,"receiveShadow",Oe.receiveShadow)),Ne.isMeshGouraudMaterial&&Ne.envMap!==null&&(dr.envMap.value=At,dr.flipEnvMap.value=At.isCubeTexture&&At.isRenderTargetTexture===!1?-1:1),Ne.isMeshStandardMaterial&&Ne.envMap===null&&Re.environment!==null&&(dr.envMapIntensity.value=Re.environmentIntensity),dr.dfgLUT!==void 0&&(dr.dfgLUT.value=gye()),Pn&&(ar.setValue(Q,"toneMappingExposure",C.toneMappingExposure),Gt.needsLights&&tt(dr,si),nt&&Ne.fog===!0&&ae.refreshFogUniforms(dr,nt),ae.refreshMaterialUniforms(dr,Ne,te,Y,N.state.transmissionRenderTarget[fe.id]),k1.upload(Q,hi(Gt),dr,pe)),Ne.isShaderMaterial&&Ne.uniformsNeedUpdate===!0&&(k1.upload(Q,hi(Gt),dr,pe),Ne.uniformsNeedUpdate=!1),Ne.isSpriteMaterial&&ar.setValue(Q,"center",Oe.center),ar.setValue(Q,"modelViewMatrix",Oe.modelViewMatrix),ar.setValue(Q,"normalMatrix",Oe.normalMatrix),ar.setValue(Q,"modelMatrix",Oe.matrixWorld),Ne.isShaderMaterial||Ne.isRawShaderMaterial){const Pt=Ne.uniformsGroups;for(let qt=0,vt=Pt.length;qt<vt;qt++){const wn=Pt[qt];it.update(wn,Yt),it.bind(wn,Yt)}}return Yt}function tt(fe,Re){fe.ambientLightColor.needsUpdate=Re,fe.lightProbe.needsUpdate=Re,fe.directionalLights.needsUpdate=Re,fe.directionalLightShadows.needsUpdate=Re,fe.pointLights.needsUpdate=Re,fe.pointLightShadows.needsUpdate=Re,fe.spotLights.needsUpdate=Re,fe.spotLightShadows.needsUpdate=Re,fe.rectAreaLights.needsUpdate=Re,fe.hemisphereLights.needsUpdate=Re}function dt(fe){return fe.isMeshLambertMaterial||fe.isMeshToonMaterial||fe.isMeshPhongMaterial||fe.isMeshStandardMaterial||fe.isShadowMaterial||fe.isShaderMaterial&&fe.lights===!0}this.getActiveCubeFace=function(){return P},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(fe,Re,Ge){const Ne=ke.get(fe);Ne.__autoAllocateDepthBuffer=fe.resolveDepthBuffer===!1,Ne.__autoAllocateDepthBuffer===!1&&(Ne.__useRenderToTexture=!1),ke.get(fe.texture).__webglTexture=Re,ke.get(fe.depthTexture).__webglTexture=Ne.__autoAllocateDepthBuffer?void 0:Ge,Ne.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(fe,Re){const Ge=ke.get(fe);Ge.__webglFramebuffer=Re,Ge.__useDefaultFramebuffer=Re===void 0};const ht=Q.createFramebuffer();this.setRenderTarget=function(fe,Re=0,Ge=0){D=fe,P=Re,A=Ge;let Ne=!0,Oe=null,nt=!1,Ye=!1;if(fe){const At=ke.get(fe);if(At.__useDefaultFramebuffer!==void 0)B.bindFramebuffer(Q.FRAMEBUFFER,null),Ne=!1;else if(At.__webglFramebuffer===void 0)pe.setupRenderTarget(fe);else if(At.__hasExternalTextures)pe.rebindTextures(fe,ke.get(fe.texture).__webglTexture,ke.get(fe.depthTexture).__webglTexture);else if(fe.depthBuffer){const Mt=fe.depthTexture;if(At.__boundDepthTexture!==Mt){if(Mt!==null&&ke.has(Mt)&&(fe.width!==Mt.image.width||fe.height!==Mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");pe.setupDepthRenderbuffer(fe)}}const It=fe.texture;(It.isData3DTexture||It.isDataArrayTexture||It.isCompressedArrayTexture)&&(Ye=!0);const Rt=ke.get(fe).__webglFramebuffer;fe.isWebGLCubeRenderTarget?(Array.isArray(Rt[Re])?Oe=Rt[Re][Ge]:Oe=Rt[Re],nt=!0):fe.samples>0&&pe.useMultisampledRTT(fe)===!1?Oe=ke.get(fe).__webglMultisampledFramebuffer:Array.isArray(Rt)?Oe=Rt[Ge]:Oe=Rt,U.copy(fe.viewport),j.copy(fe.scissor),V=fe.scissorTest}else U.copy(ne).multiplyScalar(te).floor(),j.copy(re).multiplyScalar(te).floor(),V=ge;if(Ge!==0&&(Oe=ht),B.bindFramebuffer(Q.FRAMEBUFFER,Oe)&&Ne&&B.drawBuffers(fe,Oe),B.viewport(U),B.scissor(j),B.setScissorTest(V),nt){const At=ke.get(fe.texture);Q.framebufferTexture2D(Q.FRAMEBUFFER,Q.COLOR_ATTACHMENT0,Q.TEXTURE_CUBE_MAP_POSITIVE_X+Re,At.__webglTexture,Ge)}else if(Ye){const At=Re;for(let It=0;It<fe.textures.length;It++){const Rt=ke.get(fe.textures[It]);Q.framebufferTextureLayer(Q.FRAMEBUFFER,Q.COLOR_ATTACHMENT0+It,Rt.__webglTexture,Ge,At)}}else if(fe!==null&&Ge!==0){const At=ke.get(fe.texture);Q.framebufferTexture2D(Q.FRAMEBUFFER,Q.COLOR_ATTACHMENT0,Q.TEXTURE_2D,At.__webglTexture,Ge)}I=-1},this.readRenderTargetPixels=function(fe,Re,Ge,Ne,Oe,nt,Ye,Tt=0){if(!(fe&&fe.isWebGLRenderTarget)){Ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let At=ke.get(fe).__webglFramebuffer;if(fe.isWebGLCubeRenderTarget&&Ye!==void 0&&(At=At[Ye]),At){B.bindFramebuffer(Q.FRAMEBUFFER,At);try{const It=fe.textures[Tt],Rt=It.format,Mt=It.type;if(!ee.textureFormatReadable(Rt)){Ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!ee.textureTypeReadable(Mt)){Ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Re>=0&&Re<=fe.width-Ne&&Ge>=0&&Ge<=fe.height-Oe&&(fe.textures.length>1&&Q.readBuffer(Q.COLOR_ATTACHMENT0+Tt),Q.readPixels(Re,Ge,Ne,Oe,Ke.convert(Rt),Ke.convert(Mt),nt))}finally{const It=D!==null?ke.get(D).__webglFramebuffer:null;B.bindFramebuffer(Q.FRAMEBUFFER,It)}}},this.readRenderTargetPixelsAsync=async function(fe,Re,Ge,Ne,Oe,nt,Ye,Tt=0){if(!(fe&&fe.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let At=ke.get(fe).__webglFramebuffer;if(fe.isWebGLCubeRenderTarget&&Ye!==void 0&&(At=At[Ye]),At)if(Re>=0&&Re<=fe.width-Ne&&Ge>=0&&Ge<=fe.height-Oe){B.bindFramebuffer(Q.FRAMEBUFFER,At);const It=fe.textures[Tt],Rt=It.format,Mt=It.type;if(!ee.textureFormatReadable(Rt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!ee.textureTypeReadable(Mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const en=Q.createBuffer();Q.bindBuffer(Q.PIXEL_PACK_BUFFER,en),Q.bufferData(Q.PIXEL_PACK_BUFFER,nt.byteLength,Q.STREAM_READ),fe.textures.length>1&&Q.readBuffer(Q.COLOR_ATTACHMENT0+Tt),Q.readPixels(Re,Ge,Ne,Oe,Ke.convert(Rt),Ke.convert(Mt),0);const Ht=D!==null?ke.get(D).__webglFramebuffer:null;B.bindFramebuffer(Q.FRAMEBUFFER,Ht);const hn=Q.fenceSync(Q.SYNC_GPU_COMMANDS_COMPLETE,0);return Q.flush(),await Ume(Q,hn,4),Q.bindBuffer(Q.PIXEL_PACK_BUFFER,en),Q.getBufferSubData(Q.PIXEL_PACK_BUFFER,0,nt),Q.deleteBuffer(en),Q.deleteSync(hn),nt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(fe,Re=null,Ge=0){const Ne=Math.pow(2,-Ge),Oe=Math.floor(fe.image.width*Ne),nt=Math.floor(fe.image.height*Ne),Ye=Re!==null?Re.x:0,Tt=Re!==null?Re.y:0;pe.setTexture2D(fe,0),Q.copyTexSubImage2D(Q.TEXTURE_2D,Ge,0,0,Ye,Tt,Oe,nt),B.unbindTexture()};const ut=Q.createFramebuffer(),Et=Q.createFramebuffer();this.copyTextureToTexture=function(fe,Re,Ge=null,Ne=null,Oe=0,nt=null){nt===null&&(Oe!==0?(ey("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),nt=Oe,Oe=0):nt=0);let Ye,Tt,At,It,Rt,Mt,en,Ht,hn;const un=fe.isCompressedTexture?fe.mipmaps[nt]:fe.image;if(Ge!==null)Ye=Ge.max.x-Ge.min.x,Tt=Ge.max.y-Ge.min.y,At=Ge.isBox3?Ge.max.z-Ge.min.z:1,It=Ge.min.x,Rt=Ge.min.y,Mt=Ge.isBox3?Ge.min.z:0;else{const rt=Math.pow(2,-Oe);Ye=Math.floor(un.width*rt),Tt=Math.floor(un.height*rt),fe.isDataArrayTexture?At=un.depth:fe.isData3DTexture?At=Math.floor(un.depth*rt):At=1,It=0,Rt=0,Mt=0}Ne!==null?(en=Ne.x,Ht=Ne.y,hn=Ne.z):(en=0,Ht=0,hn=0);const Mn=Ke.convert(Re.format),Gt=Ke.convert(Re.type);let on;Re.isData3DTexture?(pe.setTexture3D(Re,0),on=Q.TEXTURE_3D):Re.isDataArrayTexture||Re.isCompressedArrayTexture?(pe.setTexture2DArray(Re,0),on=Q.TEXTURE_2D_ARRAY):(pe.setTexture2D(Re,0),on=Q.TEXTURE_2D),Q.pixelStorei(Q.UNPACK_FLIP_Y_WEBGL,Re.flipY),Q.pixelStorei(Q.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Re.premultiplyAlpha),Q.pixelStorei(Q.UNPACK_ALIGNMENT,Re.unpackAlignment);const dn=Q.getParameter(Q.UNPACK_ROW_LENGTH),Yt=Q.getParameter(Q.UNPACK_IMAGE_HEIGHT),ir=Q.getParameter(Q.UNPACK_SKIP_PIXELS),Pn=Q.getParameter(Q.UNPACK_SKIP_ROWS),si=Q.getParameter(Q.UNPACK_SKIP_IMAGES);Q.pixelStorei(Q.UNPACK_ROW_LENGTH,un.width),Q.pixelStorei(Q.UNPACK_IMAGE_HEIGHT,un.height),Q.pixelStorei(Q.UNPACK_SKIP_PIXELS,It),Q.pixelStorei(Q.UNPACK_SKIP_ROWS,Rt),Q.pixelStorei(Q.UNPACK_SKIP_IMAGES,Mt);const ar=fe.isDataArrayTexture||fe.isData3DTexture,dr=Re.isDataArrayTexture||Re.isData3DTexture;if(fe.isDepthTexture){const rt=ke.get(fe),Pt=ke.get(Re),qt=ke.get(rt.__renderTarget),vt=ke.get(Pt.__renderTarget);B.bindFramebuffer(Q.READ_FRAMEBUFFER,qt.__webglFramebuffer),B.bindFramebuffer(Q.DRAW_FRAMEBUFFER,vt.__webglFramebuffer);for(let wn=0;wn<At;wn++)ar&&(Q.framebufferTextureLayer(Q.READ_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,ke.get(fe).__webglTexture,Oe,Mt+wn),Q.framebufferTextureLayer(Q.DRAW_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,ke.get(Re).__webglTexture,nt,hn+wn)),Q.blitFramebuffer(It,Rt,Ye,Tt,en,Ht,Ye,Tt,Q.DEPTH_BUFFER_BIT,Q.NEAREST);B.bindFramebuffer(Q.READ_FRAMEBUFFER,null),B.bindFramebuffer(Q.DRAW_FRAMEBUFFER,null)}else if(Oe!==0||fe.isRenderTargetTexture||ke.has(fe)){const rt=ke.get(fe),Pt=ke.get(Re);B.bindFramebuffer(Q.READ_FRAMEBUFFER,ut),B.bindFramebuffer(Q.DRAW_FRAMEBUFFER,Et);for(let qt=0;qt<At;qt++)ar?Q.framebufferTextureLayer(Q.READ_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,rt.__webglTexture,Oe,Mt+qt):Q.framebufferTexture2D(Q.READ_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,Q.TEXTURE_2D,rt.__webglTexture,Oe),dr?Q.framebufferTextureLayer(Q.DRAW_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,Pt.__webglTexture,nt,hn+qt):Q.framebufferTexture2D(Q.DRAW_FRAMEBUFFER,Q.COLOR_ATTACHMENT0,Q.TEXTURE_2D,Pt.__webglTexture,nt),Oe!==0?Q.blitFramebuffer(It,Rt,Ye,Tt,en,Ht,Ye,Tt,Q.COLOR_BUFFER_BIT,Q.NEAREST):dr?Q.copyTexSubImage3D(on,nt,en,Ht,hn+qt,It,Rt,Ye,Tt):Q.copyTexSubImage2D(on,nt,en,Ht,It,Rt,Ye,Tt);B.bindFramebuffer(Q.READ_FRAMEBUFFER,null),B.bindFramebuffer(Q.DRAW_FRAMEBUFFER,null)}else dr?fe.isDataTexture||fe.isData3DTexture?Q.texSubImage3D(on,nt,en,Ht,hn,Ye,Tt,At,Mn,Gt,un.data):Re.isCompressedArrayTexture?Q.compressedTexSubImage3D(on,nt,en,Ht,hn,Ye,Tt,At,Mn,un.data):Q.texSubImage3D(on,nt,en,Ht,hn,Ye,Tt,At,Mn,Gt,un):fe.isDataTexture?Q.texSubImage2D(Q.TEXTURE_2D,nt,en,Ht,Ye,Tt,Mn,Gt,un.data):fe.isCompressedTexture?Q.compressedTexSubImage2D(Q.TEXTURE_2D,nt,en,Ht,un.width,un.height,Mn,un.data):Q.texSubImage2D(Q.TEXTURE_2D,nt,en,Ht,Ye,Tt,Mn,Gt,un);Q.pixelStorei(Q.UNPACK_ROW_LENGTH,dn),Q.pixelStorei(Q.UNPACK_IMAGE_HEIGHT,Yt),Q.pixelStorei(Q.UNPACK_SKIP_PIXELS,ir),Q.pixelStorei(Q.UNPACK_SKIP_ROWS,Pn),Q.pixelStorei(Q.UNPACK_SKIP_IMAGES,si),nt===0&&Re.generateMipmaps&&Q.generateMipmap(on),B.unbindTexture()},this.initRenderTarget=function(fe){ke.get(fe).__webglFramebuffer===void 0&&pe.setupRenderTarget(fe)},this.initTexture=function(fe){fe.isCubeTexture?pe.setTextureCube(fe,0):fe.isData3DTexture?pe.setTexture3D(fe,0):fe.isDataArrayTexture||fe.isCompressedArrayTexture?pe.setTexture2DArray(fe,0):pe.setTexture2D(fe,0),B.unbindTexture()},this.resetState=function(){P=0,A=0,D=null,B.reset(),Me.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return uc}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=cr._getDrawingBufferColorSpace(e),n.unpackColorSpace=cr._getUnpackColorSpace()}};const QB={type:"change"},nO={type:"start"},CK={type:"end"},i_=new YR,ZB=new zd,bye=Math.cos(70*Bme.DEG2RAD),Yi=new mt,Os=2*Math.PI,Tr={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},FT=1e-6;class yye extends Cpe{constructor(e,n=null){super(e,n),this.state=Tr.NONE,this.target=new mt,this.cursor=new mt,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:Eg.ROTATE,MIDDLE:Eg.DOLLY,RIGHT:Eg.PAN},this.touches={ONE:gg.ROTATE,TWO:gg.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new mt,this._lastQuaternion=new dm,this._lastTargetPosition=new mt,this._quat=new dm().setFromUnitVectors(e.up,new mt(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new kB,this._sphericalDelta=new kB,this._scale=1,this._panOffset=new mt,this._rotateStart=new Cn,this._rotateEnd=new Cn,this._rotateDelta=new Cn,this._panStart=new Cn,this._panEnd=new Cn,this._panDelta=new Cn,this._dollyStart=new Cn,this._dollyEnd=new Cn,this._dollyDelta=new Cn,this._dollyDirection=new mt,this._mouse=new Cn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=wye.bind(this),this._onPointerDown=vye.bind(this),this._onPointerUp=_ye.bind(this),this._onContextMenu=Aye.bind(this),this._onMouseWheel=Mye.bind(this),this._onKeyDown=kye.bind(this),this._onTouchStart=Eye.bind(this),this._onTouchMove=Tye.bind(this),this._onMouseDown=Sye.bind(this),this._onMouseMove=Nye.bind(this),this._interceptControlDown=Cye.bind(this),this._interceptControlUp=jye.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(QB),this.update(),this.state=Tr.NONE}update(e=null){const n=this.object.position;Yi.copy(n).sub(this.target),Yi.applyQuaternion(this._quat),this._spherical.setFromVector3(Yi),this.autoRotate&&this.state===Tr.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=Os:r>Math.PI&&(r-=Os),i<-Math.PI?i+=Os:i>Math.PI&&(i-=Os),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(Yi.setFromSpherical(this._spherical),Yi.applyQuaternion(this._quatInverse),n.copy(this.target).add(Yi),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=Yi.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 mt(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 mt(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=Yi.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):(i_.origin.copy(this.object.position),i_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(i_.direction))<bye?this.object.lookAt(this.target):(ZB.setFromNormalAndCoplanarPoint(this.object.up,this.target),i_.intersectPlane(ZB,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)>FT||8*(1-this._lastQuaternion.dot(this.object.quaternion))>FT||this._lastTargetPosition.distanceToSquared(this.target)>FT?(this.dispatchEvent(QB),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Os/60*this.autoRotateSpeed*e:Os/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){Yi.setFromMatrixColumn(n,0),Yi.multiplyScalar(-e),this._panOffset.add(Yi)}_panUp(e,n){this.screenSpacePanning===!0?Yi.setFromMatrixColumn(n,1):(Yi.setFromMatrixColumn(n,0),Yi.crossVectors(this.object.up,Yi)),Yi.multiplyScalar(e),this._panOffset.add(Yi)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Yi.copy(i).sub(this.target);let s=Yi.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(Os*this._rotateDelta.x/n.clientHeight),this._rotateUp(Os*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(Os*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(-Os*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(Os*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(-Os*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(Os*this._rotateDelta.x/n.clientHeight),this._rotateUp(Os*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 Cn,this._pointerPositions[e.pointerId]=n),n.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const n=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[n]}_customWheelEvent(e){const n=e.deltaMode,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(n){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function vye(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 wye(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function _ye(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(CK),this.state=Tr.NONE;break;case 1:const e=this._pointers[0],n=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:n.x,pageY:n.y});break}}function Sye(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 Eg.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Tr.DOLLY;break;case Eg.ROTATE:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Tr.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Tr.ROTATE}break;case Eg.PAN:if(t.ctrlKey||t.metaKey||t.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(t),this.state=Tr.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(t),this.state=Tr.PAN}break;default:this.state=Tr.NONE}this.state!==Tr.NONE&&this.dispatchEvent(nO)}function Nye(t){switch(this.state){case Tr.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(t);break;case Tr.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(t);break;case Tr.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(t);break}}function Mye(t){this.enabled===!1||this.enableZoom===!1||this.state!==Tr.NONE||(t.preventDefault(),this.dispatchEvent(nO),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(CK))}function kye(t){this.enabled!==!1&&this._handleKeyDown(t)}function Eye(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case gg.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Tr.TOUCH_ROTATE;break;case gg.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(t),this.state=Tr.TOUCH_PAN;break;default:this.state=Tr.NONE}break;case 2:switch(this.touches.TWO){case gg.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Tr.TOUCH_DOLLY_PAN;break;case gg.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(t),this.state=Tr.TOUCH_DOLLY_ROTATE;break;default:this.state=Tr.NONE}break;default:this.state=Tr.NONE}this.state!==Tr.NONE&&this.dispatchEvent(nO)}function Tye(t){switch(this._trackPointer(t),this.state){case Tr.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(t),this.update();break;case Tr.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(t),this.update();break;case Tr.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(t),this.update();break;case Tr.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(t),this.update();break;default:this.state=Tr.NONE}}function Aye(t){this.enabled!==!1&&t.preventDefault()}function Cye(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function jye(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Pye(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 ul;let u=0;for(let d=0;d<t.length;++d){const h=t[d];let p=0;if(n!==(h.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const m in h.attributes){if(!r.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;s[m]===void 0&&(s[m]=[]),s[m].push(h.attributes[m]),p++}if(p!==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!==h.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const m in h.morphAttributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;o[m]===void 0&&(o[m]=[]),o[m].push(h.morphAttributes[m])}if(e){let m;if(n)m=h.index.count;else if(h.attributes.position!==void 0)m=h.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;c.addGroup(u,m,d),u+=m}}if(n){let d=0;const h=[];for(let p=0;p<t.length;++p){const m=t[p].index;for(let x=0;x<m.count;++x)h.push(m.getX(x)+d);d+=t[p].attributes.position.count}c.setIndex(h)}for(const d in s){const h=JB(s[d]);if(!h)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,h)}for(const d in o){const h=o[d][0].length;if(h===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let p=0;p<h;++p){const m=[];for(let y=0;y<o[d].length;++y)m.push(o[d][y][p]);const x=JB(m);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 JB(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 bs(o,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const h=c/n;for(let p=0,m=d.count;p<m;p++)for(let x=0;x<n;x++){const y=d.getComponent(p,x);l.setComponent(p+h,x,y)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}class Dye extends tO{constructor(e){super(e)}load(e,n,r,i){const s=this,o=new Npe(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(l){try{n(s.parse(l))}catch(c){i?i(c):console.error(c),s.manager.itemError(e)}},r,i)}parse(e){function n(u){const d=new DataView(u),h=32/8*3+32/8*3*3+16/8,p=d.getUint32(80,!0);if(80+32/8+p*h===d.byteLength)return!0;const x=[115,111,108,105,100];for(let y=0;y<5;y++)if(r(x,d,y))return!1;return!0}function r(u,d,h){for(let p=0,m=u.length;p<m;p++)if(u[p]!==d.getUint8(h+p))return!1;return!0}function i(u){const d=new DataView(u),h=d.getUint32(80,!0);let p,m,x,y=!1,v,b,S,N,T;for(let I=0;I<70;I++)d.getUint32(I,!1)==1129270351&&d.getUint8(I+4)==82&&d.getUint8(I+5)==61&&(y=!0,v=new Float32Array(h*3*3),b=d.getUint8(I+6)/255,S=d.getUint8(I+7)/255,N=d.getUint8(I+8)/255,T=d.getUint8(I+9)/255);const k=84,C=50,E=new ul,P=new Float32Array(h*3*3),A=new Float32Array(h*3*3),D=new Rn;for(let I=0;I<h;I++){const L=k+I*C,U=d.getFloat32(L,!0),j=d.getFloat32(L+4,!0),V=d.getFloat32(L+8,!0);if(y){const K=d.getUint16(L+48,!0);(K&32768)===0?(p=(K&31)/31,m=(K>>5&31)/31,x=(K>>10&31)/31):(p=b,m=S,x=N)}for(let K=1;K<=3;K++){const z=L+K*12,X=I*3*3+(K-1)*3;P[X]=d.getFloat32(z,!0),P[X+1]=d.getFloat32(z+4,!0),P[X+2]=d.getFloat32(z+8,!0),A[X]=U,A[X+1]=j,A[X+2]=V,y&&(D.setRGB(p,m,x,co),v[X]=D.r,v[X+1]=D.g,v[X+2]=D.b)}}return E.setAttribute("position",new bs(P,3)),E.setAttribute("normal",new bs(A,3)),y&&(E.setAttribute("color",new bs(v,3)),E.hasColors=!0,E.alpha=T),E}function s(u){const d=new ul,h=/solid([\s\S]*?)endsolid/g,p=/facet([\s\S]*?)endfacet/g,m=/solid\s(.+)/;let x=0;const y=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,v=new RegExp("vertex"+y+y+y,"g"),b=new RegExp("normal"+y+y+y,"g"),S=[],N=[],T=[],k=new mt;let C,E=0,P=0,A=0;for(;(C=h.exec(u))!==null;){P=A;const D=C[0],I=(C=m.exec(D))!==null?C[1]:"";for(T.push(I);(C=p.exec(D))!==null;){let j=0,V=0;const K=C[0];for(;(C=b.exec(K))!==null;)k.x=parseFloat(C[1]),k.y=parseFloat(C[2]),k.z=parseFloat(C[3]),V++;for(;(C=v.exec(K))!==null;)S.push(parseFloat(C[1]),parseFloat(C[2]),parseFloat(C[3])),N.push(k.x,k.y,k.z),j++,A++;V!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+x),j!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+x),x++}const L=P,U=A-P;d.userData.groupNames=T,d.addGroup(L,U,E),E++}return d.setAttribute("position",new bo(S,3)),d.setAttribute("normal",new bo(N,3)),d}function o(u){return typeof u!="string"?new TextDecoder().decode(u):u}function l(u){if(typeof u=="string"){const d=new Uint8Array(u.length);for(let h=0;h<u.length;h++)d[h]=u.charCodeAt(h)&255;return d.buffer||d}else return u}const c=l(e);return n(c)?i(c):s(o(e))}}function a_(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 IT={exports:{}};var e8;function Rye(){return e8||(e8=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 h=typeof a_=="function"&&a_;if(!d&&h)return h(u,!0);if(l)return l(u,!0);var p=new Error("Cannot find module '"+u+"'");throw p.code="MODULE_NOT_FOUND",p}var m=i[u]={exports:{}};r[u][0].call(m.exports,function(x){var y=r[u][1][x];return o(y||x)},m,m.exports,n,r,i,s)}return i[u].exports}for(var l=typeof a_=="function"&&a_,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,h,p,m,x,y,v=[],b=0,S=c.length,N=S,T=s.getTypeOf(c)!=="string";b<c.length;)N=S-b,h=T?(u=c[b++],d=b<S?c[b++]:0,b<S?c[b++]:0):(u=c.charCodeAt(b++),d=b<S?c.charCodeAt(b++):0,b<S?c.charCodeAt(b++):0),p=u>>2,m=(3&u)<<4|d>>4,x=1<N?(15&d)<<2|h>>6:64,y=2<N?63&h:64,v.push(l.charAt(p)+l.charAt(m)+l.charAt(x)+l.charAt(y));return v.join("")},i.decode=function(c){var u,d,h,p,m,x,y=0,v=0,b="data:";if(c.substr(0,b.length)===b)throw new Error("Invalid base64 input, it looks like a data url.");var S,N=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&N--,c.charAt(c.length-2)===l.charAt(64)&&N--,N%1!=0)throw new Error("Invalid base64 input, bad content length.");for(S=o.uint8array?new Uint8Array(0|N):new Array(0|N);y<c.length;)u=l.indexOf(c.charAt(y++))<<2|(p=l.indexOf(c.charAt(y++)))>>4,d=(15&p)<<4|(m=l.indexOf(c.charAt(y++)))>>2,h=(3&m)<<6|(x=l.indexOf(c.charAt(y++))),S[v++]=u,m!==64&&(S[v++]=d),x!==64&&(S[v++]=h);return S}},{"./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,h,p,m,x){this.compressedSize=d,this.uncompressedSize=h,this.crc32=p,this.compression=m,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")),h=this;return d.on("end",function(){if(this.streamInfo.data_length!==h.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,h,p){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(h.compressWorker(p)).pipe(new c("compressedSize")).withStreamInfo("compression",h)},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,h,p){var m=o,x=p+h;u^=-1;for(var y=p;y<x;y++)u=u>>>8^m[255&(u^d[y])];return-1^u})(0|c,l,l.length,0):(function(u,d,h,p){var m=o,x=p+h;u^=-1;for(var y=p;y<x;y++)u=u>>>8^m[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(h,p){c.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=p,this.meta={}}i.magic="\b\0",l.inherits(d,c),d.prototype.processChunk=function(h){this.meta=h.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,h.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 h=this;this._pako.onData=function(p){h.push({data:p,meta:h.meta})}},i.compressWorker=function(h){return new d("Deflate",h)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function s(m,x){var y,v="";for(y=0;y<x;y++)v+=String.fromCharCode(255&m),m>>>=8;return v}function o(m,x,y,v,b,S){var N,T,k=m.file,C=m.compression,E=S!==u.utf8encode,P=l.transformTo("string",S(k.name)),A=l.transformTo("string",u.utf8encode(k.name)),D=k.comment,I=l.transformTo("string",S(D)),L=l.transformTo("string",u.utf8encode(D)),U=A.length!==k.name.length,j=L.length!==D.length,V="",K="",z="",X=k.dir,Y=k.date,te={crc32:0,compressedSize:0,uncompressedSize:0};x&&!y||(te.crc32=m.crc32,te.compressedSize=m.compressedSize,te.uncompressedSize=m.uncompressedSize);var $=0;x&&($|=8),E||!U&&!j||($|=2048);var W=0,ne=0;X&&(W|=16),b==="UNIX"?(ne=798,W|=(function(ge,me){var ue=ge;return ge||(ue=me?16893:33204),(65535&ue)<<16})(k.unixPermissions,X)):(ne=20,W|=(function(ge){return 63&(ge||0)})(k.dosPermissions)),N=Y.getUTCHours(),N<<=6,N|=Y.getUTCMinutes(),N<<=5,N|=Y.getUTCSeconds()/2,T=Y.getUTCFullYear()-1980,T<<=4,T|=Y.getUTCMonth()+1,T<<=5,T|=Y.getUTCDate(),U&&(K=s(1,1)+s(d(P),4)+A,V+="up"+s(K.length,2)+K),j&&(z=s(1,1)+s(d(I),4)+L,V+="uc"+s(z.length,2)+z);var re="";return re+=`
  3839. \0`,re+=s($,2),re+=C.magic,re+=s(N,2),re+=s(T,2),re+=s(te.crc32,4),re+=s(te.compressedSize,4),re+=s(te.uncompressedSize,4),re+=s(P.length,2),re+=s(V.length,2),{fileRecord:h.LOCAL_FILE_HEADER+re+P+V,dirRecord:h.CENTRAL_FILE_HEADER+s(ne,2)+re+s(I.length,2)+"\0\0\0\0"+s(W,4)+s(v,4)+P+V+I}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),h=n("../signature");function p(m,x,y,v){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=y,this.encodeFileName=v,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}l.inherits(p,c),p.prototype.push=function(m){var x=m.meta.percent||0,y=this.entriesCount,v=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,c.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:y?(x+100*(y-v-1))/y:100}}))},p.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var x=this.streamFiles&&!m.file.dir;if(x){var y=o(m,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:y.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(m){this.accumulate=!1;var x=this.streamFiles&&!m.file.dir,y=o(m,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(y.dirRecord),x)this.push({data:(function(v){return h.DATA_DESCRIPTOR+s(v.crc32,4)+s(v.compressedSize,4)+s(v.uncompressedSize,4)})(m),meta:{percent:100}});else for(this.push({data:y.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},p.prototype.flush=function(){for(var m=this.bytesWritten,x=0;x<this.dirRecords.length;x++)this.push({data:this.dirRecords[x],meta:{percent:100}});var y=this.bytesWritten-m,v=(function(b,S,N,T,k){var C=l.transformTo("string",k(T));return h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(b,2)+s(b,2)+s(S,4)+s(N,4)+s(C.length,2)+C})(this.dirRecords.length,y,m,this.zipComment,this.encodeFileName);this.push({data:v,meta:{percent:100}})},p.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},p.prototype.registerPrevious=function(m){this._sources.push(m);var x=this;return m.on("data",function(y){x.processChunk(y)}),m.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),m.on("error",function(y){x.error(y)}),this},p.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))},p.prototype.error=function(m){var x=this._sources;if(!c.prototype.error.call(this,m))return!1;for(var y=0;y<x.length;y++)try{x[y].error(m)}catch{}return!0},p.prototype.lock=function(){c.prototype.lock.call(this);for(var m=this._sources,x=0;x<m.length;x++)m[x].lock()},r.exports=p},{"../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),h=0;try{l.forEach(function(p,m){h++;var x=(function(S,N){var T=S||N,k=s[T];if(!k)throw new Error(T+" is not a valid compression method !");return k})(m.options.compression,c.compression),y=m.options.compressionOptions||c.compressionOptions||{},v=m.dir,b=m.date;m._compressWorker(x,y).withStreamInfo("file",{name:p,dir:v,date:b,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(d)}),d.entriesCount=h}catch(p){d.error(p)}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 h(p){return new o.Promise(function(m,x){var y=p.decompressed.getContentWorker().pipe(new u);y.on("error",function(v){x(v)}).on("end",function(){y.streamInfo.crc32!==p.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(p,m){var x=this;return m=s.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:l.utf8decode}),d.isNode&&d.isStream(p)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",p,!0,m.optimizedBinaryString,m.base64).then(function(y){var v=new c(m);return v.load(y),v}).then(function(y){var v=[o.Promise.resolve(y)],b=y.files;if(m.checkCRC32)for(var S=0;S<b.length;S++)v.push(h(b[S]));return o.Promise.all(v)}).then(function(y){for(var v=y.shift(),b=v.files,S=0;S<b.length;S++){var N=b[S],T=N.fileNameStr,k=s.resolve(N.fileNameStr);x.file(k,N.decompressed,{binary:!0,optimizedBinaryString:!0,date:N.date,dir:N.dir,comment:N.fileCommentStr.length?N.fileCommentStr:null,unixPermissions:N.unixPermissions,dosPermissions:N.dosPermissions,createFolders:m.createFolders}),N.dir||(x.file(k).unsafeOriginalName=T)}return v.zipComment.length&&(x.comment=v.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(h,p){d.push(h)||d._helper.pause(),u&&u(p)}).on("error",function(h){d.emit("error",h)}).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(k,C,E){var P,A=l.getTypeOf(C),D=l.extend(E||{},d);D.date=D.date||new Date,D.compression!==null&&(D.compression=D.compression.toUpperCase()),typeof D.unixPermissions=="string"&&(D.unixPermissions=parseInt(D.unixPermissions,8)),D.unixPermissions&&16384&D.unixPermissions&&(D.dir=!0),D.dosPermissions&&16&D.dosPermissions&&(D.dir=!0),D.dir&&(k=b(k)),D.createFolders&&(P=v(k))&&S.call(this,P,!0);var I=A==="string"&&D.binary===!1&&D.base64===!1;E&&E.binary!==void 0||(D.binary=!I),(C instanceof h&&C.uncompressedSize===0||D.dir||!C||C.length===0)&&(D.base64=!1,D.binary=!0,C="",D.compression="STORE",A="string");var L=null;L=C instanceof h||C instanceof c?C:x.isNode&&x.isStream(C)?new y(k,C):l.prepareContent(k,C,D.binary,D.optimizedBinaryString,D.base64);var U=new p(k,L,D);this.files[k]=U}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),h=n("./compressedObject"),p=n("./zipObject"),m=n("./generate"),x=n("./nodejsUtils"),y=n("./nodejs/NodejsStreamInputAdapter"),v=function(k){k.slice(-1)==="/"&&(k=k.substring(0,k.length-1));var C=k.lastIndexOf("/");return 0<C?k.substring(0,C):""},b=function(k){return k.slice(-1)!=="/"&&(k+="/"),k},S=function(k,C){return C=C!==void 0?C:d.createFolders,k=b(k),this.files[k]||s.call(this,k,null,{dir:!0,createFolders:C}),this.files[k]};function N(k){return Object.prototype.toString.call(k)==="[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(k){var C,E,P;for(C in this.files)P=this.files[C],(E=C.slice(this.root.length,C.length))&&C.slice(0,this.root.length)===this.root&&k(E,P)},filter:function(k){var C=[];return this.forEach(function(E,P){k(E,P)&&C.push(P)}),C},file:function(k,C,E){if(arguments.length!==1)return k=this.root+k,s.call(this,k,C,E),this;if(N(k)){var P=k;return this.filter(function(D,I){return!I.dir&&P.test(D)})}var A=this.files[this.root+k];return A&&!A.dir?A:null},folder:function(k){if(!k)return this;if(N(k))return this.filter(function(A,D){return D.dir&&k.test(A)});var C=this.root+k,E=S.call(this,C),P=this.clone();return P.root=E.name,P},remove:function(k){k=this.root+k;var C=this.files[k];if(C||(k.slice(-1)!=="/"&&(k+="/"),C=this.files[k]),C&&!C.dir)delete this.files[k];else for(var E=this.filter(function(A,D){return D.name.slice(0,k.length)===k}),P=0;P<E.length;P++)delete this.files[E[P].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(k){var C,E={};try{if((E=l.extend(k||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=E.type.toLowerCase(),E.compression=E.compression.toUpperCase(),E.type==="binarystring"&&(E.type="string"),!E.type)throw new Error("No output type specified.");l.checkSupport(E.type),E.platform!=="darwin"&&E.platform!=="freebsd"&&E.platform!=="linux"&&E.platform!=="sunos"||(E.platform="UNIX"),E.platform==="win32"&&(E.platform="DOS");var P=E.comment||this.comment||"";C=m.generateWorker(this,E,P)}catch(A){(C=new c("error")).error(A)}return new u(C,E.type||"string",E.mimeType)},generateAsync:function(k,C){return this.generateInternalStream(k).accumulate(C)},generateNodeStream:function(k,C){return(k=k||{}).type||(k.type="nodebuffer"),this.generateInternalStream(k).toNodejsStream(C)}};r.exports=T},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var 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),h=l.charCodeAt(3),p=this.length-4;0<=p;--p)if(this.data[p]===c&&this.data[p+1]===u&&this.data[p+2]===d&&this.data[p+3]===h)return p-this.zero;return-1},o.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),h=l.charCodeAt(3),p=this.readData(4);return c===p[0]&&u===p[1]&&d===p[2]&&h===p[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(h){var p=s.getTypeOf(h);return s.checkSupport(p),p!=="string"||o.uint8array?p==="nodebuffer"?new u(h):o.uint8array?new d(s.transformTo("uint8array",h)):new l(s.transformTo("array",h)):new c(h)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var 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"),h=null;if(u.nodestream)try{h=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(x,y){return new d.Promise(function(v,b){var S=[],N=x._internalType,T=x._outputType,k=x._mimeType;x.on("data",function(C,E){S.push(C),y&&y(E)}).on("error",function(C){S=[],b(C)}).on("end",function(){try{var C=(function(E,P,A){switch(E){case"blob":return s.newBlob(s.transformTo("arraybuffer",P),A);case"base64":return c.encode(P);default:return s.transformTo(E,P)}})(T,(function(E,P){var A,D=0,I=null,L=0;for(A=0;A<P.length;A++)L+=P[A].length;switch(E){case"string":return P.join("");case"array":return Array.prototype.concat.apply([],P);case"uint8array":for(I=new Uint8Array(L),A=0;A<P.length;A++)I.set(P[A],D),D+=P[A].length;return I;case"nodebuffer":return Buffer.concat(P);default:throw new Error("concat : unsupported type '"+E+"'")}})(N,S),k);v(C)}catch(E){b(E)}S=[]}).resume()})}function m(x,y,v){var b=y;switch(y){case"blob":case"arraybuffer":b="uint8array";break;case"base64":b="string"}try{this._internalType=b,this._outputType=y,this._mimeType=v,s.checkSupport(b),this._worker=x.pipe(new o(b)),x.lock()}catch(S){this._worker=new l("error"),this._worker.error(S)}}m.prototype={accumulate:function(x){return p(this,x)},on:function(x,y){var v=this;return x==="data"?this._worker.on(x,function(b){y.call(v,b.data,b.meta)}):this._worker.on(x,function(){s.delay(y,arguments,v)}),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 h(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=m},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var 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 h(){c.call(this,"utf-8 decode"),this.leftOver=null}function p(){c.call(this,"utf-8 encode")}i.utf8encode=function(m){return o.nodebuffer?l.newBufferFrom(m,"utf-8"):(function(x){var y,v,b,S,N,T=x.length,k=0;for(S=0;S<T;S++)(64512&(v=x.charCodeAt(S)))==55296&&S+1<T&&(64512&(b=x.charCodeAt(S+1)))==56320&&(v=65536+(v-55296<<10)+(b-56320),S++),k+=v<128?1:v<2048?2:v<65536?3:4;for(y=o.uint8array?new Uint8Array(k):new Array(k),S=N=0;N<k;S++)(64512&(v=x.charCodeAt(S)))==55296&&S+1<T&&(64512&(b=x.charCodeAt(S+1)))==56320&&(v=65536+(v-55296<<10)+(b-56320),S++),v<128?y[N++]=v:(v<2048?y[N++]=192|v>>>6:(v<65536?y[N++]=224|v>>>12:(y[N++]=240|v>>>18,y[N++]=128|v>>>12&63),y[N++]=128|v>>>6&63),y[N++]=128|63&v);return y})(m)},i.utf8decode=function(m){return o.nodebuffer?s.transformTo("nodebuffer",m).toString("utf-8"):(function(x){var y,v,b,S,N=x.length,T=new Array(2*N);for(y=v=0;y<N;)if((b=x[y++])<128)T[v++]=b;else if(4<(S=u[b]))T[v++]=65533,y+=S-1;else{for(b&=S===2?31:S===3?15:7;1<S&&y<N;)b=b<<6|63&x[y++],S--;1<S?T[v++]=65533:b<65536?T[v++]=b:(b-=65536,T[v++]=55296|b>>10&1023,T[v++]=56320|1023&b)}return T.length!==v&&(T.subarray?T=T.subarray(0,v):T.length=v),s.applyFromCharCode(T)})(m=s.transformTo(o.uint8array?"uint8array":"array",m))},s.inherits(h,c),h.prototype.processChunk=function(m){var x=s.transformTo(o.uint8array?"uint8array":"array",m.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 v=(function(S,N){var T;for((N=N||S.length)>S.length&&(N=S.length),T=N-1;0<=T&&(192&S[T])==128;)T--;return T<0||T===0?N:T+u[S[T]]>N?T:N})(x),b=x;v!==x.length&&(o.uint8array?(b=x.subarray(0,v),this.leftOver=x.subarray(v,x.length)):(b=x.slice(0,v),this.leftOver=x.slice(v,x.length))),this.push({data:i.utf8decode(b),meta:m.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=h,s.inherits(p,c),p.prototype.processChunk=function(m){this.push({data:i.utf8encode(m.data),meta:m.meta})},i.Utf8EncodeWorker=p},{"./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,v){for(var b=0;b<y.length;++b)v[b]=255&y.charCodeAt(b);return v}n("setimmediate"),i.newBlob=function(y,v){i.checkSupport("blob");try{return new Blob([y],{type:v})}catch{try{var b=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return b.append(y),b.getBlob(v)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(y,v,b){var S=[],N=0,T=y.length;if(T<=b)return String.fromCharCode.apply(null,y);for(;N<T;)v==="array"||v==="nodebuffer"?S.push(String.fromCharCode.apply(null,y.slice(N,Math.min(N+b,T)))):S.push(String.fromCharCode.apply(null,y.subarray(N,Math.min(N+b,T)))),N+=b;return S.join("")},stringifyByChar:function(y){for(var v="",b=0;b<y.length;b++)v+=String.fromCharCode(y[b]);return v},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 p(y){var v=65536,b=i.getTypeOf(y),S=!0;if(b==="uint8array"?S=h.applyCanBeUsed.uint8array:b==="nodebuffer"&&(S=h.applyCanBeUsed.nodebuffer),S)for(;1<v;)try{return h.stringifyByChunk(y,b,v)}catch{v=Math.floor(v/2)}return h.stringifyByChar(y)}function m(y,v){for(var b=0;b<y.length;b++)v[b]=y[b];return v}i.applyFromCharCode=p;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:p,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 p(new Uint8Array(y))},array:function(y){return m(new Uint8Array(y),new Array(y.byteLength))},arraybuffer:u,uint8array:function(y){return new Uint8Array(y)},nodebuffer:function(y){return l.newBufferFrom(new Uint8Array(y))}},x.uint8array={string:p,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return y.buffer},uint8array:u,nodebuffer:function(y){return l.newBufferFrom(y)}},x.nodebuffer={string:p,array:function(y){return m(y,new Array(y.length))},arraybuffer:function(y){return x.nodebuffer.uint8array(y).buffer},uint8array:function(y){return m(y,new Uint8Array(y.length))},nodebuffer:u},i.transformTo=function(y,v){if(v=v||"",!y)return v;i.checkSupport(y);var b=i.getTypeOf(v);return x[b][y](v)},i.resolve=function(y){for(var v=y.split("/"),b=[],S=0;S<v.length;S++){var N=v[S];N==="."||N===""&&S!==0&&S!==v.length-1||(N===".."?b.pop():b.push(N))}return b.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 v,b,S="";for(b=0;b<(y||"").length;b++)S+="\\x"+((v=y.charCodeAt(b))<16?"0":"")+v.toString(16).toUpperCase();return S},i.delay=function(y,v,b){setImmediate(function(){y.apply(b||null,v||[])})},i.inherits=function(y,v){function b(){}b.prototype=v.prototype,y.prototype=new b},i.extend=function(){var y,v,b={};for(y=0;y<arguments.length;y++)for(v in arguments[y])Object.prototype.hasOwnProperty.call(arguments[y],v)&&b[v]===void 0&&(b[v]=arguments[y][v]);return b},i.prepareContent=function(y,v,b,S,N){return c.Promise.resolve(v).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(k,C){var E=new FileReader;E.onload=function(P){k(P.target.result)},E.onerror=function(P){C(P.target.error)},E.readAsArrayBuffer(T)}):T}).then(function(T){var k=i.getTypeOf(T);return k?(k==="arraybuffer"?T=i.transformTo("uint8array",T):k==="string"&&(N?T=o.decode(T):b&&S!==!0&&(T=(function(C){return d(C,s.uint8array?new Uint8Array(C.length):new Array(C.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(h){this.files=[],this.loadOptions=h}d.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(p)+", expected "+o.pretty(h)+")")}},isSignature:function(h,p){var m=this.reader.index;this.reader.setIndex(h);var x=this.reader.readString(4)===p;return this.reader.setIndex(m),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 h=this.reader.readData(this.zipCommentLength),p=u.uint8array?"uint8array":"array",m=o.transformTo(p,h);this.zipComment=this.loadOptions.decodeFileName(m)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var h,p,m,x=this.zip64EndOfCentralSize-44;0<x;)h=this.reader.readInt(2),p=this.reader.readInt(4),m=this.reader.readData(p),this.zip64ExtensibleData[h]={id:h,length:p,value:m}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var h,p;for(h=0;h<this.files.length;h++)p=this.files[h],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(h=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(h);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var h=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(h<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(h);var p=h;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,(h=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(h),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 m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var x=p-m;if(0<x)this.isSignature(p,l.CENTRAL_FILE_HEADER)||(this.reader.zero=x);else if(x<0)throw new Error("Corrupted zip: missing "+Math.abs(x)+" bytes.")},prepareReader:function(h){this.reader=s(h)},load:function(h){this.prepareReader(h),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"),h=n("./support");function p(m,x){this.options=m,this.loadOptions=x}p.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var x,y;if(m.skip(22),this.fileNameLength=m.readInt(2),y=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.skip(y),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((x=(function(v){for(var b in d)if(Object.prototype.hasOwnProperty.call(d,b)&&d[b].magic===v)return d[b];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,m.readData(this.compressedSize))},readCentralPart:function(m){this.versionMadeBy=m.readInt(2),m.skip(2),this.bitFlag=m.readInt(2),this.compressionMethod=m.readString(2),this.date=m.readDate(),this.crc32=m.readInt(4),this.compressedSize=m.readInt(4),this.uncompressedSize=m.readInt(4);var x=m.readInt(2);if(this.extraFieldsLength=m.readInt(2),this.fileCommentLength=m.readInt(2),this.diskNumberStart=m.readInt(2),this.internalFileAttributes=m.readInt(2),this.externalFileAttributes=m.readInt(4),this.localHeaderOffset=m.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");m.skip(x),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=s(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var x,y,v,b=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<b;)x=m.readInt(2),y=m.readInt(2),v=m.readData(y),this.extraFields[x]={id:x,length:y,value:v};m.setIndex(b)},handleUTF8:function(){var m=h.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(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(y)}var v=this.findExtraFieldUnicodeComment();if(v!==null)this.fileCommentStr=v;else{var b=o.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(b)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var x=s(m.value);return x.readInt(1)!==1||c(this.fileName)!==x.readInt(4)?null:u.utf8decode(x.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var x=s(m.value);return x.readInt(1)!==1||c(this.fileComment)!==x.readInt(4)?null:u.utf8decode(x.readData(m.length-5))}return null}},r.exports=p},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(n,r,i){function s(x,y,v){this.name=x,this.dir=v.dir,this.date=v.date,this.comment=v.comment,this.unixPermissions=v.unixPermissions,this.dosPermissions=v.dosPermissions,this._data=y,this._dataBinary=v.binary,this.options={compression:v.compression,compressionOptions:v.compressionOptions}}var 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,v="string";try{if(!x)throw new Error("No output type specified.");var b=(v=x.toLowerCase())==="string"||v==="text";v!=="binarystring"&&v!=="text"||(v="string"),y=this._decompressWorker();var S=!this._dataBinary;S&&!b&&(y=y.pipe(new c.Utf8EncodeWorker)),!S&&b&&(y=y.pipe(new c.Utf8DecodeWorker))}catch(N){(y=new d("error")).error(N)}return new o(y,v,"")},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 v=this._decompressWorker();return this._dataBinary||(v=v.pipe(new c.Utf8EncodeWorker)),u.createWorkerFrom(v,x,y)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(this._data)}};for(var h=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<h.length;m++)s.prototype[h[m]]=p;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),h=s.document.createTextNode("");d.observe(h,{characterData:!0}),o=function(){h.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 p=new s.MessageChannel;p.port1.onmessage=x,o=function(){p.port2.postMessage(0)}}var m=[];function x(){var y,v;l=!0;for(var b=m.length;b;){for(v=m,m=[],y=-1;++y<b;)v[y]();b=m.length}l=!1}r.exports=function(y){m.push(y)!==1||l||o()}}).call(this,typeof jw<"u"?jw: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 h(b){if(typeof b!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,b!==o&&y(this,b)}function p(b,S,N){this.promise=b,typeof S=="function"&&(this.onFulfilled=S,this.callFulfilled=this.otherCallFulfilled),typeof N=="function"&&(this.onRejected=N,this.callRejected=this.otherCallRejected)}function m(b,S,N){s(function(){var T;try{T=S(N)}catch(k){return l.reject(b,k)}T===b?l.reject(b,new TypeError("Cannot resolve promise with itself")):l.resolve(b,T)})}function x(b){var S=b&&b.then;if(b&&(typeof b=="object"||typeof b=="function")&&typeof S=="function")return function(){S.apply(b,arguments)}}function y(b,S){var N=!1;function T(E){N||(N=!0,l.reject(b,E))}function k(E){N||(N=!0,l.resolve(b,E))}var C=v(function(){S(k,T)});C.status==="error"&&T(C.value)}function v(b,S){var N={};try{N.value=b(S),N.status="success"}catch(T){N.status="error",N.value=T}return N}(r.exports=h).prototype.finally=function(b){if(typeof b!="function")return this;var S=this.constructor;return this.then(function(N){return S.resolve(b()).then(function(){return N})},function(N){return S.resolve(b()).then(function(){throw N})})},h.prototype.catch=function(b){return this.then(null,b)},h.prototype.then=function(b,S){if(typeof b!="function"&&this.state===u||typeof S!="function"&&this.state===c)return this;var N=new this.constructor(o);return this.state!==d?m(N,this.state===u?b:S,this.outcome):this.queue.push(new p(N,b,S)),N},p.prototype.callFulfilled=function(b){l.resolve(this.promise,b)},p.prototype.otherCallFulfilled=function(b){m(this.promise,this.onFulfilled,b)},p.prototype.callRejected=function(b){l.reject(this.promise,b)},p.prototype.otherCallRejected=function(b){m(this.promise,this.onRejected,b)},l.resolve=function(b,S){var N=v(x,S);if(N.status==="error")return l.reject(b,N.value);var T=N.value;if(T)y(b,T);else{b.state=u,b.outcome=S;for(var k=-1,C=b.queue.length;++k<C;)b.queue[k].callFulfilled(S)}return b},l.reject=function(b,S){b.state=c,b.outcome=S;for(var N=-1,T=b.queue.length;++N<T;)b.queue[N].callRejected(S);return b},h.resolve=function(b){return b instanceof this?b:l.resolve(new this(o),b)},h.reject=function(b){var S=new this(o);return l.reject(S,b)},h.all=function(b){var S=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var N=b.length,T=!1;if(!N)return this.resolve([]);for(var k=new Array(N),C=0,E=-1,P=new this(o);++E<N;)A(b[E],E);return P;function A(D,I){S.resolve(D).then(function(L){k[I]=L,++C!==N||T||(T=!0,l.resolve(P,k))},function(L){T||(T=!0,l.reject(P,L))})}},h.race=function(b){var S=this;if(Object.prototype.toString.call(b)!=="[object Array]")return this.reject(new TypeError("must be an array"));var N=b.length,T=!1;if(!N)return this.resolve([]);for(var k=-1,C=new this(o);++k<N;)E=b[k],S.resolve(E).then(function(P){T||(T=!0,l.resolve(C,P))},function(P){T||(T=!0,l.reject(C,P))});var E;return C}},{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,h=0,p=-1,m=0,x=8;function y(b){if(!(this instanceof y))return new y(b);this.options=o.assign({level:p,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},b||{});var S=this.options;S.raw&&0<S.windowBits?S.windowBits=-S.windowBits:S.gzip&&0<S.windowBits&&S.windowBits<16&&(S.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var N=s.deflateInit2(this.strm,S.level,S.method,S.windowBits,S.memLevel,S.strategy);if(N!==h)throw new Error(c[N]);if(S.header&&s.deflateSetHeader(this.strm,S.header),S.dictionary){var T;if(T=typeof S.dictionary=="string"?l.string2buf(S.dictionary):d.call(S.dictionary)==="[object ArrayBuffer]"?new Uint8Array(S.dictionary):S.dictionary,(N=s.deflateSetDictionary(this.strm,T))!==h)throw new Error(c[N]);this._dict_set=!0}}function v(b,S){var N=new y(S);if(N.push(b,!0),N.err)throw N.msg||c[N.err];return N.result}y.prototype.push=function(b,S){var N,T,k=this.strm,C=this.options.chunkSize;if(this.ended)return!1;T=S===~~S?S:S===!0?4:0,typeof b=="string"?k.input=l.string2buf(b):d.call(b)==="[object ArrayBuffer]"?k.input=new Uint8Array(b):k.input=b,k.next_in=0,k.avail_in=k.input.length;do{if(k.avail_out===0&&(k.output=new o.Buf8(C),k.next_out=0,k.avail_out=C),(N=s.deflate(k,T))!==1&&N!==h)return this.onEnd(N),!(this.ended=!0);k.avail_out!==0&&(k.avail_in!==0||T!==4&&T!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(o.shrinkBuf(k.output,k.next_out))):this.onData(o.shrinkBuf(k.output,k.next_out)))}while((0<k.avail_in||k.avail_out===0)&&N!==1);return T===4?(N=s.deflateEnd(this.strm),this.onEnd(N),this.ended=!0,N===h):T!==2||(this.onEnd(h),!(k.avail_out=0))},y.prototype.onData=function(b){this.chunks.push(b)},y.prototype.onEnd=function(b){b===h&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=b,this.msg=this.strm.msg},i.Deflate=y,i.deflate=v,i.deflateRaw=function(b,S){return(S=S||{}).raw=!0,v(b,S)},i.gzip=function(b,S){return(S=S||{}).gzip=!0,v(b,S)}},{"./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"),h=n("./zlib/gzheader"),p=Object.prototype.toString;function m(y){if(!(this instanceof m))return new m(y);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},y||{});var v=this.options;v.raw&&0<=v.windowBits&&v.windowBits<16&&(v.windowBits=-v.windowBits,v.windowBits===0&&(v.windowBits=-15)),!(0<=v.windowBits&&v.windowBits<16)||y&&y.windowBits||(v.windowBits+=32),15<v.windowBits&&v.windowBits<48&&(15&v.windowBits)==0&&(v.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new d,this.strm.avail_out=0;var b=s.inflateInit2(this.strm,v.windowBits);if(b!==c.Z_OK)throw new Error(u[b]);this.header=new h,s.inflateGetHeader(this.strm,this.header)}function x(y,v){var b=new m(v);if(b.push(y,!0),b.err)throw b.msg||u[b.err];return b.result}m.prototype.push=function(y,v){var b,S,N,T,k,C,E=this.strm,P=this.options.chunkSize,A=this.options.dictionary,D=!1;if(this.ended)return!1;S=v===~~v?v:v===!0?c.Z_FINISH:c.Z_NO_FLUSH,typeof y=="string"?E.input=l.binstring2buf(y):p.call(y)==="[object ArrayBuffer]"?E.input=new Uint8Array(y):E.input=y,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new o.Buf8(P),E.next_out=0,E.avail_out=P),(b=s.inflate(E,c.Z_NO_FLUSH))===c.Z_NEED_DICT&&A&&(C=typeof A=="string"?l.string2buf(A):p.call(A)==="[object ArrayBuffer]"?new Uint8Array(A):A,b=s.inflateSetDictionary(this.strm,C)),b===c.Z_BUF_ERROR&&D===!0&&(b=c.Z_OK,D=!1),b!==c.Z_STREAM_END&&b!==c.Z_OK)return this.onEnd(b),!(this.ended=!0);E.next_out&&(E.avail_out!==0&&b!==c.Z_STREAM_END&&(E.avail_in!==0||S!==c.Z_FINISH&&S!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(N=l.utf8border(E.output,E.next_out),T=E.next_out-N,k=l.buf2string(E.output,N),E.next_out=T,E.avail_out=P-T,T&&o.arraySet(E.output,E.output,N,T,0),this.onData(k)):this.onData(o.shrinkBuf(E.output,E.next_out)))),E.avail_in===0&&E.avail_out===0&&(D=!0)}while((0<E.avail_in||E.avail_out===0)&&b!==c.Z_STREAM_END);return b===c.Z_STREAM_END&&(S=c.Z_FINISH),S===c.Z_FINISH?(b=s.inflateEnd(this.strm),this.onEnd(b),this.ended=!0,b===c.Z_OK):S!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(E.avail_out=0))},m.prototype.onData=function(y){this.chunks.push(y)},m.prototype.onEnd=function(y){y===c.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Inflate=m,i.inflate=x,i.inflateRaw=function(y,v){return(v=v||{}).raw=!0,x(y,v)},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 h in d)d.hasOwnProperty(h)&&(c[h]=d[h])}}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,h,p){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+h),p);else for(var m=0;m<h;m++)c[p+m]=u[d+m]},flattenChunks:function(c){var u,d,h,p,m,x;for(u=h=0,d=c.length;u<d;u++)h+=c[u].length;for(x=new Uint8Array(h),u=p=0,d=c.length;u<d;u++)m=c[u],x.set(m,p),p+=m.length;return x}},l={arraySet:function(c,u,d,h,p){for(var m=0;m<h;m++)c[p+m]=u[d+m]},flattenChunks:function(c){return[].concat.apply([],c)}};i.setTyped=function(c){c?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,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(h,p){if(p<65537&&(h.subarray&&l||!h.subarray&&o))return String.fromCharCode.apply(null,s.shrinkBuf(h,p));for(var m="",x=0;x<p;x++)m+=String.fromCharCode(h[x]);return m}c[254]=c[254]=1,i.string2buf=function(h){var p,m,x,y,v,b=h.length,S=0;for(y=0;y<b;y++)(64512&(m=h.charCodeAt(y)))==55296&&y+1<b&&(64512&(x=h.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),y++),S+=m<128?1:m<2048?2:m<65536?3:4;for(p=new s.Buf8(S),y=v=0;v<S;y++)(64512&(m=h.charCodeAt(y)))==55296&&y+1<b&&(64512&(x=h.charCodeAt(y+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),y++),m<128?p[v++]=m:(m<2048?p[v++]=192|m>>>6:(m<65536?p[v++]=224|m>>>12:(p[v++]=240|m>>>18,p[v++]=128|m>>>12&63),p[v++]=128|m>>>6&63),p[v++]=128|63&m);return p},i.buf2binstring=function(h){return d(h,h.length)},i.binstring2buf=function(h){for(var p=new s.Buf8(h.length),m=0,x=p.length;m<x;m++)p[m]=h.charCodeAt(m);return p},i.buf2string=function(h,p){var m,x,y,v,b=p||h.length,S=new Array(2*b);for(m=x=0;m<b;)if((y=h[m++])<128)S[x++]=y;else if(4<(v=c[y]))S[x++]=65533,m+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&m<b;)y=y<<6|63&h[m++],v--;1<v?S[x++]=65533:y<65536?S[x++]=y:(y-=65536,S[x++]=55296|y>>10&1023,S[x++]=56320|1023&y)}return d(S,x)},i.utf8border=function(h,p){var m;for((p=p||h.length)>h.length&&(p=h.length),m=p-1;0<=m&&(192&h[m])==128;)m--;return m<0||m===0?p:m+c[h[m]]>p?m:p}},{"./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,h=0;l!==0;){for(l-=h=2e3<l?2e3:l;d=d+(u=u+o[c++]|0)|0,--h;);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,h=u+c;o^=-1;for(var p=u;p<h;p++)o=o>>>8^d[255&(o^l[p])];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"),h=0,p=4,m=0,x=-2,y=-1,v=4,b=2,S=8,N=9,T=286,k=30,C=19,E=2*T+1,P=15,A=3,D=258,I=D+A+1,L=42,U=113,j=1,V=2,K=3,z=4;function X(G,Q){return G.msg=d[Q],Q}function Y(G){return(G<<1)-(4<G?9:0)}function te(G){for(var Q=G.length;0<=--Q;)G[Q]=0}function $(G){var Q=G.state,de=Q.pending;de>G.avail_out&&(de=G.avail_out),de!==0&&(o.arraySet(G.output,Q.pending_buf,Q.pending_out,de,G.next_out),G.next_out+=de,Q.pending_out+=de,G.total_out+=de,G.avail_out-=de,Q.pending-=de,Q.pending===0&&(Q.pending_out=0))}function W(G,Q){l._tr_flush_block(G,0<=G.block_start?G.block_start:-1,G.strstart-G.block_start,Q),G.block_start=G.strstart,$(G.strm)}function ne(G,Q){G.pending_buf[G.pending++]=Q}function re(G,Q){G.pending_buf[G.pending++]=Q>>>8&255,G.pending_buf[G.pending++]=255&Q}function ge(G,Q){var de,q,ee=G.max_chain_length,B=G.strstart,he=G.prev_length,ke=G.nice_match,pe=G.strstart>G.w_size-I?G.strstart-(G.w_size-I):0,H=G.window,O=G.w_mask,J=G.prev,le=G.strstart+D,Se=H[B+he-1],we=H[B+he];G.prev_length>=G.good_match&&(ee>>=2),ke>G.lookahead&&(ke=G.lookahead);do if(H[(de=Q)+he]===we&&H[de+he-1]===Se&&H[de]===H[B]&&H[++de]===H[B+1]){B+=2,de++;do;while(H[++B]===H[++de]&&H[++B]===H[++de]&&H[++B]===H[++de]&&H[++B]===H[++de]&&H[++B]===H[++de]&&H[++B]===H[++de]&&H[++B]===H[++de]&&H[++B]===H[++de]&&B<le);if(q=D-(le-B),B=le-D,he<q){if(G.match_start=Q,ke<=(he=q))break;Se=H[B+he-1],we=H[B+he]}}while((Q=J[Q&O])>pe&&--ee!=0);return he<=G.lookahead?he:G.lookahead}function me(G){var Q,de,q,ee,B,he,ke,pe,H,O,J=G.w_size;do{if(ee=G.window_size-G.lookahead-G.strstart,G.strstart>=J+(J-I)){for(o.arraySet(G.window,G.window,J,J,0),G.match_start-=J,G.strstart-=J,G.block_start-=J,Q=de=G.hash_size;q=G.head[--Q],G.head[Q]=J<=q?q-J:0,--de;);for(Q=de=J;q=G.prev[--Q],G.prev[Q]=J<=q?q-J:0,--de;);ee+=J}if(G.strm.avail_in===0)break;if(he=G.strm,ke=G.window,pe=G.strstart+G.lookahead,H=ee,O=void 0,O=he.avail_in,H<O&&(O=H),de=O===0?0:(he.avail_in-=O,o.arraySet(ke,he.input,he.next_in,O,pe),he.state.wrap===1?he.adler=c(he.adler,ke,O,pe):he.state.wrap===2&&(he.adler=u(he.adler,ke,O,pe)),he.next_in+=O,he.total_in+=O,O),G.lookahead+=de,G.lookahead+G.insert>=A)for(B=G.strstart-G.insert,G.ins_h=G.window[B],G.ins_h=(G.ins_h<<G.hash_shift^G.window[B+1])&G.hash_mask;G.insert&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[B+A-1])&G.hash_mask,G.prev[B&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=B,B++,G.insert--,!(G.lookahead+G.insert<A)););}while(G.lookahead<I&&G.strm.avail_in!==0)}function ue(G,Q){for(var de,q;;){if(G.lookahead<I){if(me(G),G.lookahead<I&&Q===h)return j;if(G.lookahead===0)break}if(de=0,G.lookahead>=A&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+A-1])&G.hash_mask,de=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),de!==0&&G.strstart-de<=G.w_size-I&&(G.match_length=ge(G,de)),G.match_length>=A)if(q=l._tr_tally(G,G.strstart-G.match_start,G.match_length-A),G.lookahead-=G.match_length,G.match_length<=G.max_lazy_match&&G.lookahead>=A){for(G.match_length--;G.strstart++,G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+A-1])&G.hash_mask,de=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart,--G.match_length!=0;);G.strstart++}else G.strstart+=G.match_length,G.match_length=0,G.ins_h=G.window[G.strstart],G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+1])&G.hash_mask;else q=l._tr_tally(G,0,G.window[G.strstart]),G.lookahead--,G.strstart++;if(q&&(W(G,!1),G.strm.avail_out===0))return j}return G.insert=G.strstart<A-1?G.strstart:A-1,Q===p?(W(G,!0),G.strm.avail_out===0?K:z):G.last_lit&&(W(G,!1),G.strm.avail_out===0)?j:V}function Te(G,Q){for(var de,q,ee;;){if(G.lookahead<I){if(me(G),G.lookahead<I&&Q===h)return j;if(G.lookahead===0)break}if(de=0,G.lookahead>=A&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+A-1])&G.hash_mask,de=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),G.prev_length=G.match_length,G.prev_match=G.match_start,G.match_length=A-1,de!==0&&G.prev_length<G.max_lazy_match&&G.strstart-de<=G.w_size-I&&(G.match_length=ge(G,de),G.match_length<=5&&(G.strategy===1||G.match_length===A&&4096<G.strstart-G.match_start)&&(G.match_length=A-1)),G.prev_length>=A&&G.match_length<=G.prev_length){for(ee=G.strstart+G.lookahead-A,q=l._tr_tally(G,G.strstart-1-G.prev_match,G.prev_length-A),G.lookahead-=G.prev_length-1,G.prev_length-=2;++G.strstart<=ee&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+A-1])&G.hash_mask,de=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),--G.prev_length!=0;);if(G.match_available=0,G.match_length=A-1,G.strstart++,q&&(W(G,!1),G.strm.avail_out===0))return j}else if(G.match_available){if((q=l._tr_tally(G,0,G.window[G.strstart-1]))&&W(G,!1),G.strstart++,G.lookahead--,G.strm.avail_out===0)return j}else G.match_available=1,G.strstart++,G.lookahead--}return G.match_available&&(q=l._tr_tally(G,0,G.window[G.strstart-1]),G.match_available=0),G.insert=G.strstart<A-1?G.strstart:A-1,Q===p?(W(G,!0),G.strm.avail_out===0?K:z):G.last_lit&&(W(G,!1),G.strm.avail_out===0)?j:V}function ie(G,Q,de,q,ee){this.good_length=G,this.max_lazy=Q,this.nice_length=de,this.max_chain=q,this.func=ee}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=S,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*E),this.dyn_dtree=new o.Buf16(2*(2*k+1)),this.bl_tree=new o.Buf16(2*(2*C+1)),te(this.dyn_ltree),te(this.dyn_dtree),te(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(P+1),this.heap=new o.Buf16(2*T+1),te(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*T+1),te(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 Fe(G){var Q;return G&&G.state?(G.total_in=G.total_out=0,G.data_type=b,(Q=G.state).pending=0,Q.pending_out=0,Q.wrap<0&&(Q.wrap=-Q.wrap),Q.status=Q.wrap?L:U,G.adler=Q.wrap===2?0:1,Q.last_flush=h,l._tr_init(Q),m):X(G,x)}function xe(G){var Q=Fe(G);return Q===m&&(function(de){de.window_size=2*de.w_size,te(de.head),de.max_lazy_match=s[de.level].max_lazy,de.good_match=s[de.level].good_length,de.nice_match=s[de.level].nice_length,de.max_chain_length=s[de.level].max_chain,de.strstart=0,de.block_start=0,de.lookahead=0,de.insert=0,de.match_length=de.prev_length=A-1,de.match_available=0,de.ins_h=0})(G.state),Q}function Ze(G,Q,de,q,ee,B){if(!G)return x;var he=1;if(Q===y&&(Q=6),q<0?(he=0,q=-q):15<q&&(he=2,q-=16),ee<1||N<ee||de!==S||q<8||15<q||Q<0||9<Q||B<0||v<B)return X(G,x);q===8&&(q=9);var ke=new Ce;return(G.state=ke).strm=G,ke.wrap=he,ke.gzhead=null,ke.w_bits=q,ke.w_size=1<<ke.w_bits,ke.w_mask=ke.w_size-1,ke.hash_bits=ee+7,ke.hash_size=1<<ke.hash_bits,ke.hash_mask=ke.hash_size-1,ke.hash_shift=~~((ke.hash_bits+A-1)/A),ke.window=new o.Buf8(2*ke.w_size),ke.head=new o.Buf16(ke.hash_size),ke.prev=new o.Buf16(ke.w_size),ke.lit_bufsize=1<<ee+6,ke.pending_buf_size=4*ke.lit_bufsize,ke.pending_buf=new o.Buf8(ke.pending_buf_size),ke.d_buf=1*ke.lit_bufsize,ke.l_buf=3*ke.lit_bufsize,ke.level=Q,ke.strategy=B,ke.method=de,xe(G)}s=[new ie(0,0,0,0,function(G,Q){var de=65535;for(de>G.pending_buf_size-5&&(de=G.pending_buf_size-5);;){if(G.lookahead<=1){if(me(G),G.lookahead===0&&Q===h)return j;if(G.lookahead===0)break}G.strstart+=G.lookahead,G.lookahead=0;var q=G.block_start+de;if((G.strstart===0||G.strstart>=q)&&(G.lookahead=G.strstart-q,G.strstart=q,W(G,!1),G.strm.avail_out===0)||G.strstart-G.block_start>=G.w_size-I&&(W(G,!1),G.strm.avail_out===0))return j}return G.insert=0,Q===p?(W(G,!0),G.strm.avail_out===0?K:z):(G.strstart>G.block_start&&(W(G,!1),G.strm.avail_out),j)}),new ie(4,4,8,4,ue),new ie(4,5,16,8,ue),new ie(4,6,32,32,ue),new ie(4,4,16,16,Te),new ie(8,16,32,32,Te),new ie(8,16,128,128,Te),new ie(8,32,128,256,Te),new ie(32,128,258,1024,Te),new ie(32,258,258,4096,Te)],i.deflateInit=function(G,Q){return Ze(G,Q,S,15,8,0)},i.deflateInit2=Ze,i.deflateReset=xe,i.deflateResetKeep=Fe,i.deflateSetHeader=function(G,Q){return G&&G.state?G.state.wrap!==2?x:(G.state.gzhead=Q,m):x},i.deflate=function(G,Q){var de,q,ee,B;if(!G||!G.state||5<Q||Q<0)return G?X(G,x):x;if(q=G.state,!G.output||!G.input&&G.avail_in!==0||q.status===666&&Q!==p)return X(G,G.avail_out===0?-5:x);if(q.strm=G,de=q.last_flush,q.last_flush=Q,q.status===L)if(q.wrap===2)G.adler=0,ne(q,31),ne(q,139),ne(q,8),q.gzhead?(ne(q,(q.gzhead.text?1:0)+(q.gzhead.hcrc?2:0)+(q.gzhead.extra?4:0)+(q.gzhead.name?8:0)+(q.gzhead.comment?16:0)),ne(q,255&q.gzhead.time),ne(q,q.gzhead.time>>8&255),ne(q,q.gzhead.time>>16&255),ne(q,q.gzhead.time>>24&255),ne(q,q.level===9?2:2<=q.strategy||q.level<2?4:0),ne(q,255&q.gzhead.os),q.gzhead.extra&&q.gzhead.extra.length&&(ne(q,255&q.gzhead.extra.length),ne(q,q.gzhead.extra.length>>8&255)),q.gzhead.hcrc&&(G.adler=u(G.adler,q.pending_buf,q.pending,0)),q.gzindex=0,q.status=69):(ne(q,0),ne(q,0),ne(q,0),ne(q,0),ne(q,0),ne(q,q.level===9?2:2<=q.strategy||q.level<2?4:0),ne(q,3),q.status=U);else{var he=S+(q.w_bits-8<<4)<<8;he|=(2<=q.strategy||q.level<2?0:q.level<6?1:q.level===6?2:3)<<6,q.strstart!==0&&(he|=32),he+=31-he%31,q.status=U,re(q,he),q.strstart!==0&&(re(q,G.adler>>>16),re(q,65535&G.adler)),G.adler=1}if(q.status===69)if(q.gzhead.extra){for(ee=q.pending;q.gzindex<(65535&q.gzhead.extra.length)&&(q.pending!==q.pending_buf_size||(q.gzhead.hcrc&&q.pending>ee&&(G.adler=u(G.adler,q.pending_buf,q.pending-ee,ee)),$(G),ee=q.pending,q.pending!==q.pending_buf_size));)ne(q,255&q.gzhead.extra[q.gzindex]),q.gzindex++;q.gzhead.hcrc&&q.pending>ee&&(G.adler=u(G.adler,q.pending_buf,q.pending-ee,ee)),q.gzindex===q.gzhead.extra.length&&(q.gzindex=0,q.status=73)}else q.status=73;if(q.status===73)if(q.gzhead.name){ee=q.pending;do{if(q.pending===q.pending_buf_size&&(q.gzhead.hcrc&&q.pending>ee&&(G.adler=u(G.adler,q.pending_buf,q.pending-ee,ee)),$(G),ee=q.pending,q.pending===q.pending_buf_size)){B=1;break}B=q.gzindex<q.gzhead.name.length?255&q.gzhead.name.charCodeAt(q.gzindex++):0,ne(q,B)}while(B!==0);q.gzhead.hcrc&&q.pending>ee&&(G.adler=u(G.adler,q.pending_buf,q.pending-ee,ee)),B===0&&(q.gzindex=0,q.status=91)}else q.status=91;if(q.status===91)if(q.gzhead.comment){ee=q.pending;do{if(q.pending===q.pending_buf_size&&(q.gzhead.hcrc&&q.pending>ee&&(G.adler=u(G.adler,q.pending_buf,q.pending-ee,ee)),$(G),ee=q.pending,q.pending===q.pending_buf_size)){B=1;break}B=q.gzindex<q.gzhead.comment.length?255&q.gzhead.comment.charCodeAt(q.gzindex++):0,ne(q,B)}while(B!==0);q.gzhead.hcrc&&q.pending>ee&&(G.adler=u(G.adler,q.pending_buf,q.pending-ee,ee)),B===0&&(q.status=103)}else q.status=103;if(q.status===103&&(q.gzhead.hcrc?(q.pending+2>q.pending_buf_size&&$(G),q.pending+2<=q.pending_buf_size&&(ne(q,255&G.adler),ne(q,G.adler>>8&255),G.adler=0,q.status=U)):q.status=U),q.pending!==0){if($(G),G.avail_out===0)return q.last_flush=-1,m}else if(G.avail_in===0&&Y(Q)<=Y(de)&&Q!==p)return X(G,-5);if(q.status===666&&G.avail_in!==0)return X(G,-5);if(G.avail_in!==0||q.lookahead!==0||Q!==h&&q.status!==666){var ke=q.strategy===2?(function(pe,H){for(var O;;){if(pe.lookahead===0&&(me(pe),pe.lookahead===0)){if(H===h)return j;break}if(pe.match_length=0,O=l._tr_tally(pe,0,pe.window[pe.strstart]),pe.lookahead--,pe.strstart++,O&&(W(pe,!1),pe.strm.avail_out===0))return j}return pe.insert=0,H===p?(W(pe,!0),pe.strm.avail_out===0?K:z):pe.last_lit&&(W(pe,!1),pe.strm.avail_out===0)?j:V})(q,Q):q.strategy===3?(function(pe,H){for(var O,J,le,Se,we=pe.window;;){if(pe.lookahead<=D){if(me(pe),pe.lookahead<=D&&H===h)return j;if(pe.lookahead===0)break}if(pe.match_length=0,pe.lookahead>=A&&0<pe.strstart&&(J=we[le=pe.strstart-1])===we[++le]&&J===we[++le]&&J===we[++le]){Se=pe.strstart+D;do;while(J===we[++le]&&J===we[++le]&&J===we[++le]&&J===we[++le]&&J===we[++le]&&J===we[++le]&&J===we[++le]&&J===we[++le]&&le<Se);pe.match_length=D-(Se-le),pe.match_length>pe.lookahead&&(pe.match_length=pe.lookahead)}if(pe.match_length>=A?(O=l._tr_tally(pe,1,pe.match_length-A),pe.lookahead-=pe.match_length,pe.strstart+=pe.match_length,pe.match_length=0):(O=l._tr_tally(pe,0,pe.window[pe.strstart]),pe.lookahead--,pe.strstart++),O&&(W(pe,!1),pe.strm.avail_out===0))return j}return pe.insert=0,H===p?(W(pe,!0),pe.strm.avail_out===0?K:z):pe.last_lit&&(W(pe,!1),pe.strm.avail_out===0)?j:V})(q,Q):s[q.level].func(q,Q);if(ke!==K&&ke!==z||(q.status=666),ke===j||ke===K)return G.avail_out===0&&(q.last_flush=-1),m;if(ke===V&&(Q===1?l._tr_align(q):Q!==5&&(l._tr_stored_block(q,0,0,!1),Q===3&&(te(q.head),q.lookahead===0&&(q.strstart=0,q.block_start=0,q.insert=0))),$(G),G.avail_out===0))return q.last_flush=-1,m}return Q!==p?m:q.wrap<=0?1:(q.wrap===2?(ne(q,255&G.adler),ne(q,G.adler>>8&255),ne(q,G.adler>>16&255),ne(q,G.adler>>24&255),ne(q,255&G.total_in),ne(q,G.total_in>>8&255),ne(q,G.total_in>>16&255),ne(q,G.total_in>>24&255)):(re(q,G.adler>>>16),re(q,65535&G.adler)),$(G),0<q.wrap&&(q.wrap=-q.wrap),q.pending!==0?m:1)},i.deflateEnd=function(G){var Q;return G&&G.state?(Q=G.state.status)!==L&&Q!==69&&Q!==73&&Q!==91&&Q!==103&&Q!==U&&Q!==666?X(G,x):(G.state=null,Q===U?X(G,-3):m):x},i.deflateSetDictionary=function(G,Q){var de,q,ee,B,he,ke,pe,H,O=Q.length;if(!G||!G.state||(B=(de=G.state).wrap)===2||B===1&&de.status!==L||de.lookahead)return x;for(B===1&&(G.adler=c(G.adler,Q,O,0)),de.wrap=0,O>=de.w_size&&(B===0&&(te(de.head),de.strstart=0,de.block_start=0,de.insert=0),H=new o.Buf8(de.w_size),o.arraySet(H,Q,O-de.w_size,de.w_size,0),Q=H,O=de.w_size),he=G.avail_in,ke=G.next_in,pe=G.input,G.avail_in=O,G.next_in=0,G.input=Q,me(de);de.lookahead>=A;){for(q=de.strstart,ee=de.lookahead-(A-1);de.ins_h=(de.ins_h<<de.hash_shift^de.window[q+A-1])&de.hash_mask,de.prev[q&de.w_mask]=de.head[de.ins_h],de.head[de.ins_h]=q,q++,--ee;);de.strstart=q,de.lookahead=A-1,me(de)}return de.strstart+=de.lookahead,de.block_start=de.strstart,de.insert=de.lookahead,de.lookahead=0,de.match_length=de.prev_length=A-1,de.match_available=0,G.next_in=ke,G.input=pe,G.avail_in=he,de.wrap=B,m},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(s,o){var l,c,u,d,h,p,m,x,y,v,b,S,N,T,k,C,E,P,A,D,I,L,U,j,V;l=s.state,c=s.next_in,j=s.input,u=c+(s.avail_in-5),d=s.next_out,V=s.output,h=d-(o-s.avail_out),p=d+(s.avail_out-257),m=l.dmax,x=l.wsize,y=l.whave,v=l.wnext,b=l.window,S=l.hold,N=l.bits,T=l.lencode,k=l.distcode,C=(1<<l.lenbits)-1,E=(1<<l.distbits)-1;e:do{N<15&&(S+=j[c++]<<N,N+=8,S+=j[c++]<<N,N+=8),P=T[S&C];t:for(;;){if(S>>>=A=P>>>24,N-=A,(A=P>>>16&255)===0)V[d++]=65535&P;else{if(!(16&A)){if((64&A)==0){P=T[(65535&P)+(S&(1<<A)-1)];continue t}if(32&A){l.mode=12;break e}s.msg="invalid literal/length code",l.mode=30;break e}D=65535&P,(A&=15)&&(N<A&&(S+=j[c++]<<N,N+=8),D+=S&(1<<A)-1,S>>>=A,N-=A),N<15&&(S+=j[c++]<<N,N+=8,S+=j[c++]<<N,N+=8),P=k[S&E];n:for(;;){if(S>>>=A=P>>>24,N-=A,!(16&(A=P>>>16&255))){if((64&A)==0){P=k[(65535&P)+(S&(1<<A)-1)];continue n}s.msg="invalid distance code",l.mode=30;break e}if(I=65535&P,N<(A&=15)&&(S+=j[c++]<<N,(N+=8)<A&&(S+=j[c++]<<N,N+=8)),m<(I+=S&(1<<A)-1)){s.msg="invalid distance too far back",l.mode=30;break e}if(S>>>=A,N-=A,(A=d-h)<I){if(y<(A=I-A)&&l.sane){s.msg="invalid distance too far back",l.mode=30;break e}if(U=b,(L=0)===v){if(L+=x-A,A<D){for(D-=A;V[d++]=b[L++],--A;);L=d-I,U=V}}else if(v<A){if(L+=x+v-A,(A-=v)<D){for(D-=A;V[d++]=b[L++],--A;);if(L=0,v<D){for(D-=A=v;V[d++]=b[L++],--A;);L=d-I,U=V}}}else if(L+=v-A,A<D){for(D-=A;V[d++]=b[L++],--A;);L=d-I,U=V}for(;2<D;)V[d++]=U[L++],V[d++]=U[L++],V[d++]=U[L++],D-=3;D&&(V[d++]=U[L++],1<D&&(V[d++]=U[L++]))}else{for(L=d-I;V[d++]=V[L++],V[d++]=V[L++],V[d++]=V[L++],2<(D-=3););D&&(V[d++]=V[L++],1<D&&(V[d++]=V[L++]))}break}}break}}while(c<u&&d<p);c-=D=N>>3,S&=(1<<(N-=D<<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<p?p-d+257:257-(d-p),l.hold=S,l.bits=N}},{}],49:[function(n,r,i){var s=n("../utils/common"),o=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,h=2,p=0,m=-2,x=1,y=852,v=592;function b(L){return(L>>>24&255)+(L>>>8&65280)+((65280&L)<<8)+((255&L)<<24)}function S(){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 N(L){var U;return L&&L.state?(U=L.state,L.total_in=L.total_out=U.total=0,L.msg="",U.wrap&&(L.adler=1&U.wrap),U.mode=x,U.last=0,U.havedict=0,U.dmax=32768,U.head=null,U.hold=0,U.bits=0,U.lencode=U.lendyn=new s.Buf32(y),U.distcode=U.distdyn=new s.Buf32(v),U.sane=1,U.back=-1,p):m}function T(L){var U;return L&&L.state?((U=L.state).wsize=0,U.whave=0,U.wnext=0,N(L)):m}function k(L,U){var j,V;return L&&L.state?(V=L.state,U<0?(j=0,U=-U):(j=1+(U>>4),U<48&&(U&=15)),U&&(U<8||15<U)?m:(V.window!==null&&V.wbits!==U&&(V.window=null),V.wrap=j,V.wbits=U,T(L))):m}function C(L,U){var j,V;return L?(V=new S,(L.state=V).window=null,(j=k(L,U))!==p&&(L.state=null),j):m}var E,P,A=!0;function D(L){if(A){var U;for(E=new s.Buf32(512),P=new s.Buf32(32),U=0;U<144;)L.lens[U++]=8;for(;U<256;)L.lens[U++]=9;for(;U<280;)L.lens[U++]=7;for(;U<288;)L.lens[U++]=8;for(u(d,L.lens,0,288,E,0,L.work,{bits:9}),U=0;U<32;)L.lens[U++]=5;u(h,L.lens,0,32,P,0,L.work,{bits:5}),A=!1}L.lencode=E,L.lenbits=9,L.distcode=P,L.distbits=5}function I(L,U,j,V){var K,z=L.state;return z.window===null&&(z.wsize=1<<z.wbits,z.wnext=0,z.whave=0,z.window=new s.Buf8(z.wsize)),V>=z.wsize?(s.arraySet(z.window,U,j-z.wsize,z.wsize,0),z.wnext=0,z.whave=z.wsize):(V<(K=z.wsize-z.wnext)&&(K=V),s.arraySet(z.window,U,j-V,K,z.wnext),(V-=K)?(s.arraySet(z.window,U,j-V,V,0),z.wnext=V,z.whave=z.wsize):(z.wnext+=K,z.wnext===z.wsize&&(z.wnext=0),z.whave<z.wsize&&(z.whave+=K))),0}i.inflateReset=T,i.inflateReset2=k,i.inflateResetKeep=N,i.inflateInit=function(L){return C(L,15)},i.inflateInit2=C,i.inflate=function(L,U){var j,V,K,z,X,Y,te,$,W,ne,re,ge,me,ue,Te,ie,Ce,Fe,xe,Ze,G,Q,de,q,ee=0,B=new s.Buf8(4),he=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!L||!L.state||!L.output||!L.input&&L.avail_in!==0)return m;(j=L.state).mode===12&&(j.mode=13),X=L.next_out,K=L.output,te=L.avail_out,z=L.next_in,V=L.input,Y=L.avail_in,$=j.hold,W=j.bits,ne=Y,re=te,Q=p;e:for(;;)switch(j.mode){case x:if(j.wrap===0){j.mode=13;break}for(;W<16;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}if(2&j.wrap&&$===35615){B[j.check=0]=255&$,B[1]=$>>>8&255,j.check=l(j.check,B,2,0),W=$=0,j.mode=2;break}if(j.flags=0,j.head&&(j.head.done=!1),!(1&j.wrap)||(((255&$)<<8)+($>>8))%31){L.msg="incorrect header check",j.mode=30;break}if((15&$)!=8){L.msg="unknown compression method",j.mode=30;break}if(W-=4,G=8+(15&($>>>=4)),j.wbits===0)j.wbits=G;else if(G>j.wbits){L.msg="invalid window size",j.mode=30;break}j.dmax=1<<G,L.adler=j.check=1,j.mode=512&$?10:12,W=$=0;break;case 2:for(;W<16;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}if(j.flags=$,(255&j.flags)!=8){L.msg="unknown compression method",j.mode=30;break}if(57344&j.flags){L.msg="unknown header flags set",j.mode=30;break}j.head&&(j.head.text=$>>8&1),512&j.flags&&(B[0]=255&$,B[1]=$>>>8&255,j.check=l(j.check,B,2,0)),W=$=0,j.mode=3;case 3:for(;W<32;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}j.head&&(j.head.time=$),512&j.flags&&(B[0]=255&$,B[1]=$>>>8&255,B[2]=$>>>16&255,B[3]=$>>>24&255,j.check=l(j.check,B,4,0)),W=$=0,j.mode=4;case 4:for(;W<16;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}j.head&&(j.head.xflags=255&$,j.head.os=$>>8),512&j.flags&&(B[0]=255&$,B[1]=$>>>8&255,j.check=l(j.check,B,2,0)),W=$=0,j.mode=5;case 5:if(1024&j.flags){for(;W<16;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}j.length=$,j.head&&(j.head.extra_len=$),512&j.flags&&(B[0]=255&$,B[1]=$>>>8&255,j.check=l(j.check,B,2,0)),W=$=0}else j.head&&(j.head.extra=null);j.mode=6;case 6:if(1024&j.flags&&(Y<(ge=j.length)&&(ge=Y),ge&&(j.head&&(G=j.head.extra_len-j.length,j.head.extra||(j.head.extra=new Array(j.head.extra_len)),s.arraySet(j.head.extra,V,z,ge,G)),512&j.flags&&(j.check=l(j.check,V,ge,z)),Y-=ge,z+=ge,j.length-=ge),j.length))break e;j.length=0,j.mode=7;case 7:if(2048&j.flags){if(Y===0)break e;for(ge=0;G=V[z+ge++],j.head&&G&&j.length<65536&&(j.head.name+=String.fromCharCode(G)),G&&ge<Y;);if(512&j.flags&&(j.check=l(j.check,V,ge,z)),Y-=ge,z+=ge,G)break e}else j.head&&(j.head.name=null);j.length=0,j.mode=8;case 8:if(4096&j.flags){if(Y===0)break e;for(ge=0;G=V[z+ge++],j.head&&G&&j.length<65536&&(j.head.comment+=String.fromCharCode(G)),G&&ge<Y;);if(512&j.flags&&(j.check=l(j.check,V,ge,z)),Y-=ge,z+=ge,G)break e}else j.head&&(j.head.comment=null);j.mode=9;case 9:if(512&j.flags){for(;W<16;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}if($!==(65535&j.check)){L.msg="header crc mismatch",j.mode=30;break}W=$=0}j.head&&(j.head.hcrc=j.flags>>9&1,j.head.done=!0),L.adler=j.check=0,j.mode=12;break;case 10:for(;W<32;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}L.adler=j.check=b($),W=$=0,j.mode=11;case 11:if(j.havedict===0)return L.next_out=X,L.avail_out=te,L.next_in=z,L.avail_in=Y,j.hold=$,j.bits=W,2;L.adler=j.check=1,j.mode=12;case 12:if(U===5||U===6)break e;case 13:if(j.last){$>>>=7&W,W-=7&W,j.mode=27;break}for(;W<3;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}switch(j.last=1&$,W-=1,3&($>>>=1)){case 0:j.mode=14;break;case 1:if(D(j),j.mode=20,U!==6)break;$>>>=2,W-=2;break e;case 2:j.mode=17;break;case 3:L.msg="invalid block type",j.mode=30}$>>>=2,W-=2;break;case 14:for($>>>=7&W,W-=7&W;W<32;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}if((65535&$)!=($>>>16^65535)){L.msg="invalid stored block lengths",j.mode=30;break}if(j.length=65535&$,W=$=0,j.mode=15,U===6)break e;case 15:j.mode=16;case 16:if(ge=j.length){if(Y<ge&&(ge=Y),te<ge&&(ge=te),ge===0)break e;s.arraySet(K,V,z,ge,X),Y-=ge,z+=ge,te-=ge,X+=ge,j.length-=ge;break}j.mode=12;break;case 17:for(;W<14;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}if(j.nlen=257+(31&$),$>>>=5,W-=5,j.ndist=1+(31&$),$>>>=5,W-=5,j.ncode=4+(15&$),$>>>=4,W-=4,286<j.nlen||30<j.ndist){L.msg="too many length or distance symbols",j.mode=30;break}j.have=0,j.mode=18;case 18:for(;j.have<j.ncode;){for(;W<3;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}j.lens[he[j.have++]]=7&$,$>>>=3,W-=3}for(;j.have<19;)j.lens[he[j.have++]]=0;if(j.lencode=j.lendyn,j.lenbits=7,de={bits:j.lenbits},Q=u(0,j.lens,0,19,j.lencode,0,j.work,de),j.lenbits=de.bits,Q){L.msg="invalid code lengths set",j.mode=30;break}j.have=0,j.mode=19;case 19:for(;j.have<j.nlen+j.ndist;){for(;ie=(ee=j.lencode[$&(1<<j.lenbits)-1])>>>16&255,Ce=65535&ee,!((Te=ee>>>24)<=W);){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}if(Ce<16)$>>>=Te,W-=Te,j.lens[j.have++]=Ce;else{if(Ce===16){for(q=Te+2;W<q;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}if($>>>=Te,W-=Te,j.have===0){L.msg="invalid bit length repeat",j.mode=30;break}G=j.lens[j.have-1],ge=3+(3&$),$>>>=2,W-=2}else if(Ce===17){for(q=Te+3;W<q;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}W-=Te,G=0,ge=3+(7&($>>>=Te)),$>>>=3,W-=3}else{for(q=Te+7;W<q;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}W-=Te,G=0,ge=11+(127&($>>>=Te)),$>>>=7,W-=7}if(j.have+ge>j.nlen+j.ndist){L.msg="invalid bit length repeat",j.mode=30;break}for(;ge--;)j.lens[j.have++]=G}}if(j.mode===30)break;if(j.lens[256]===0){L.msg="invalid code -- missing end-of-block",j.mode=30;break}if(j.lenbits=9,de={bits:j.lenbits},Q=u(d,j.lens,0,j.nlen,j.lencode,0,j.work,de),j.lenbits=de.bits,Q){L.msg="invalid literal/lengths set",j.mode=30;break}if(j.distbits=6,j.distcode=j.distdyn,de={bits:j.distbits},Q=u(h,j.lens,j.nlen,j.ndist,j.distcode,0,j.work,de),j.distbits=de.bits,Q){L.msg="invalid distances set",j.mode=30;break}if(j.mode=20,U===6)break e;case 20:j.mode=21;case 21:if(6<=Y&&258<=te){L.next_out=X,L.avail_out=te,L.next_in=z,L.avail_in=Y,j.hold=$,j.bits=W,c(L,re),X=L.next_out,K=L.output,te=L.avail_out,z=L.next_in,V=L.input,Y=L.avail_in,$=j.hold,W=j.bits,j.mode===12&&(j.back=-1);break}for(j.back=0;ie=(ee=j.lencode[$&(1<<j.lenbits)-1])>>>16&255,Ce=65535&ee,!((Te=ee>>>24)<=W);){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}if(ie&&(240&ie)==0){for(Fe=Te,xe=ie,Ze=Ce;ie=(ee=j.lencode[Ze+(($&(1<<Fe+xe)-1)>>Fe)])>>>16&255,Ce=65535&ee,!(Fe+(Te=ee>>>24)<=W);){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}$>>>=Fe,W-=Fe,j.back+=Fe}if($>>>=Te,W-=Te,j.back+=Te,j.length=Ce,ie===0){j.mode=26;break}if(32&ie){j.back=-1,j.mode=12;break}if(64&ie){L.msg="invalid literal/length code",j.mode=30;break}j.extra=15&ie,j.mode=22;case 22:if(j.extra){for(q=j.extra;W<q;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}j.length+=$&(1<<j.extra)-1,$>>>=j.extra,W-=j.extra,j.back+=j.extra}j.was=j.length,j.mode=23;case 23:for(;ie=(ee=j.distcode[$&(1<<j.distbits)-1])>>>16&255,Ce=65535&ee,!((Te=ee>>>24)<=W);){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}if((240&ie)==0){for(Fe=Te,xe=ie,Ze=Ce;ie=(ee=j.distcode[Ze+(($&(1<<Fe+xe)-1)>>Fe)])>>>16&255,Ce=65535&ee,!(Fe+(Te=ee>>>24)<=W);){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}$>>>=Fe,W-=Fe,j.back+=Fe}if($>>>=Te,W-=Te,j.back+=Te,64&ie){L.msg="invalid distance code",j.mode=30;break}j.offset=Ce,j.extra=15&ie,j.mode=24;case 24:if(j.extra){for(q=j.extra;W<q;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}j.offset+=$&(1<<j.extra)-1,$>>>=j.extra,W-=j.extra,j.back+=j.extra}if(j.offset>j.dmax){L.msg="invalid distance too far back",j.mode=30;break}j.mode=25;case 25:if(te===0)break e;if(ge=re-te,j.offset>ge){if((ge=j.offset-ge)>j.whave&&j.sane){L.msg="invalid distance too far back",j.mode=30;break}me=ge>j.wnext?(ge-=j.wnext,j.wsize-ge):j.wnext-ge,ge>j.length&&(ge=j.length),ue=j.window}else ue=K,me=X-j.offset,ge=j.length;for(te<ge&&(ge=te),te-=ge,j.length-=ge;K[X++]=ue[me++],--ge;);j.length===0&&(j.mode=21);break;case 26:if(te===0)break e;K[X++]=j.length,te--,j.mode=21;break;case 27:if(j.wrap){for(;W<32;){if(Y===0)break e;Y--,$|=V[z++]<<W,W+=8}if(re-=te,L.total_out+=re,j.total+=re,re&&(L.adler=j.check=j.flags?l(j.check,K,re,X-re):o(j.check,K,re,X-re)),re=te,(j.flags?$:b($))!==j.check){L.msg="incorrect data check",j.mode=30;break}W=$=0}j.mode=28;case 28:if(j.wrap&&j.flags){for(;W<32;){if(Y===0)break e;Y--,$+=V[z++]<<W,W+=8}if($!==(4294967295&j.total)){L.msg="incorrect length check",j.mode=30;break}W=$=0}j.mode=29;case 29:Q=1;break e;case 30:Q=-3;break e;case 31:return-4;case 32:default:return m}return L.next_out=X,L.avail_out=te,L.next_in=z,L.avail_in=Y,j.hold=$,j.bits=W,(j.wsize||re!==L.avail_out&&j.mode<30&&(j.mode<27||U!==4))&&I(L,L.output,L.next_out,re-L.avail_out)?(j.mode=31,-4):(ne-=L.avail_in,re-=L.avail_out,L.total_in+=ne,L.total_out+=re,j.total+=re,j.wrap&&re&&(L.adler=j.check=j.flags?l(j.check,K,re,L.next_out-re):o(j.check,K,re,L.next_out-re)),L.data_type=j.bits+(j.last?64:0)+(j.mode===12?128:0)+(j.mode===20||j.mode===15?256:0),(ne==0&&re===0||U===4)&&Q===p&&(Q=-5),Q)},i.inflateEnd=function(L){if(!L||!L.state)return m;var U=L.state;return U.window&&(U.window=null),L.state=null,p},i.inflateGetHeader=function(L,U){var j;return L&&L.state?(2&(j=L.state).wrap)==0?m:((j.head=U).done=!1,p):m},i.inflateSetDictionary=function(L,U){var j,V=U.length;return L&&L.state?(j=L.state).wrap!==0&&j.mode!==11?m:j.mode===11&&o(1,U,V,0)!==j.check?-3:I(L,U,V,V)?(j.mode=31,-4):(j.havedict=1,p):m},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(n,r,i){var 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,h,p,m,x,y,v,b){var S,N,T,k,C,E,P,A,D,I=b.bits,L=0,U=0,j=0,V=0,K=0,z=0,X=0,Y=0,te=0,$=0,W=null,ne=0,re=new s.Buf16(16),ge=new s.Buf16(16),me=null,ue=0;for(L=0;L<=15;L++)re[L]=0;for(U=0;U<m;U++)re[h[p+U]]++;for(K=I,V=15;1<=V&&re[V]===0;V--);if(V<K&&(K=V),V===0)return x[y++]=20971520,x[y++]=20971520,b.bits=1,0;for(j=1;j<V&&re[j]===0;j++);for(K<j&&(K=j),L=Y=1;L<=15;L++)if(Y<<=1,(Y-=re[L])<0)return-1;if(0<Y&&(d===0||V!==1))return-1;for(ge[1]=0,L=1;L<15;L++)ge[L+1]=ge[L]+re[L];for(U=0;U<m;U++)h[p+U]!==0&&(v[ge[h[p+U]]++]=U);if(E=d===0?(W=me=v,19):d===1?(W=o,ne-=257,me=l,ue-=257,256):(W=c,me=u,-1),L=j,C=y,X=U=$=0,T=-1,k=(te=1<<(z=K))-1,d===1&&852<te||d===2&&592<te)return 1;for(;;){for(P=L-X,D=v[U]<E?(A=0,v[U]):v[U]>E?(A=me[ue+v[U]],W[ne+v[U]]):(A=96,0),S=1<<L-X,j=N=1<<z;x[C+($>>X)+(N-=S)]=P<<24|A<<16|D|0,N!==0;);for(S=1<<L-1;$&S;)S>>=1;if(S!==0?($&=S-1,$+=S):$=0,U++,--re[L]==0){if(L===V)break;L=h[p+v[U]]}if(K<L&&($&k)!==T){for(X===0&&(X=K),C+=j,Y=1<<(z=L-X);z+X<V&&!((Y-=re[z+X])<=0);)z++,Y<<=1;if(te+=1<<z,d===1&&852<te||d===2&&592<te)return 1;x[T=$&k]=K<<24|z<<16|C-y|0}}return $!==0&&(x[C+$]=L-X<<24|64<<16|0),b.bits=K,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var s=n("../utils/common"),o=0,l=1;function c(ee){for(var B=ee.length;0<=--B;)ee[B]=0}var u=0,d=29,h=256,p=h+1+d,m=30,x=19,y=2*p+1,v=15,b=16,S=7,N=256,T=16,k=17,C=18,E=[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],P=[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],D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],I=new Array(2*(p+2));c(I);var L=new Array(2*m);c(L);var U=new Array(512);c(U);var j=new Array(256);c(j);var V=new Array(d);c(V);var K,z,X,Y=new Array(m);function te(ee,B,he,ke,pe){this.static_tree=ee,this.extra_bits=B,this.extra_base=he,this.elems=ke,this.max_length=pe,this.has_stree=ee&&ee.length}function $(ee,B){this.dyn_tree=ee,this.max_code=0,this.stat_desc=B}function W(ee){return ee<256?U[ee]:U[256+(ee>>>7)]}function ne(ee,B){ee.pending_buf[ee.pending++]=255&B,ee.pending_buf[ee.pending++]=B>>>8&255}function re(ee,B,he){ee.bi_valid>b-he?(ee.bi_buf|=B<<ee.bi_valid&65535,ne(ee,ee.bi_buf),ee.bi_buf=B>>b-ee.bi_valid,ee.bi_valid+=he-b):(ee.bi_buf|=B<<ee.bi_valid&65535,ee.bi_valid+=he)}function ge(ee,B,he){re(ee,he[2*B],he[2*B+1])}function me(ee,B){for(var he=0;he|=1&ee,ee>>>=1,he<<=1,0<--B;);return he>>>1}function ue(ee,B,he){var ke,pe,H=new Array(v+1),O=0;for(ke=1;ke<=v;ke++)H[ke]=O=O+he[ke-1]<<1;for(pe=0;pe<=B;pe++){var J=ee[2*pe+1];J!==0&&(ee[2*pe]=me(H[J]++,J))}}function Te(ee){var B;for(B=0;B<p;B++)ee.dyn_ltree[2*B]=0;for(B=0;B<m;B++)ee.dyn_dtree[2*B]=0;for(B=0;B<x;B++)ee.bl_tree[2*B]=0;ee.dyn_ltree[2*N]=1,ee.opt_len=ee.static_len=0,ee.last_lit=ee.matches=0}function ie(ee){8<ee.bi_valid?ne(ee,ee.bi_buf):0<ee.bi_valid&&(ee.pending_buf[ee.pending++]=ee.bi_buf),ee.bi_buf=0,ee.bi_valid=0}function Ce(ee,B,he,ke){var pe=2*B,H=2*he;return ee[pe]<ee[H]||ee[pe]===ee[H]&&ke[B]<=ke[he]}function Fe(ee,B,he){for(var ke=ee.heap[he],pe=he<<1;pe<=ee.heap_len&&(pe<ee.heap_len&&Ce(B,ee.heap[pe+1],ee.heap[pe],ee.depth)&&pe++,!Ce(B,ke,ee.heap[pe],ee.depth));)ee.heap[he]=ee.heap[pe],he=pe,pe<<=1;ee.heap[he]=ke}function xe(ee,B,he){var ke,pe,H,O,J=0;if(ee.last_lit!==0)for(;ke=ee.pending_buf[ee.d_buf+2*J]<<8|ee.pending_buf[ee.d_buf+2*J+1],pe=ee.pending_buf[ee.l_buf+J],J++,ke===0?ge(ee,pe,B):(ge(ee,(H=j[pe])+h+1,B),(O=E[H])!==0&&re(ee,pe-=V[H],O),ge(ee,H=W(--ke),he),(O=P[H])!==0&&re(ee,ke-=Y[H],O)),J<ee.last_lit;);ge(ee,N,B)}function Ze(ee,B){var he,ke,pe,H=B.dyn_tree,O=B.stat_desc.static_tree,J=B.stat_desc.has_stree,le=B.stat_desc.elems,Se=-1;for(ee.heap_len=0,ee.heap_max=y,he=0;he<le;he++)H[2*he]!==0?(ee.heap[++ee.heap_len]=Se=he,ee.depth[he]=0):H[2*he+1]=0;for(;ee.heap_len<2;)H[2*(pe=ee.heap[++ee.heap_len]=Se<2?++Se:0)]=1,ee.depth[pe]=0,ee.opt_len--,J&&(ee.static_len-=O[2*pe+1]);for(B.max_code=Se,he=ee.heap_len>>1;1<=he;he--)Fe(ee,H,he);for(pe=le;he=ee.heap[1],ee.heap[1]=ee.heap[ee.heap_len--],Fe(ee,H,1),ke=ee.heap[1],ee.heap[--ee.heap_max]=he,ee.heap[--ee.heap_max]=ke,H[2*pe]=H[2*he]+H[2*ke],ee.depth[pe]=(ee.depth[he]>=ee.depth[ke]?ee.depth[he]:ee.depth[ke])+1,H[2*he+1]=H[2*ke+1]=pe,ee.heap[1]=pe++,Fe(ee,H,1),2<=ee.heap_len;);ee.heap[--ee.heap_max]=ee.heap[1],(function(we,ae){var Le,Be,Ve,He,be,Pe,Ie=ae.dyn_tree,_e=ae.max_code,Ke=ae.stat_desc.static_tree,Me=ae.stat_desc.has_stree,it=ae.stat_desc.extra_bits,Ee=ae.stat_desc.extra_base,Xe=ae.stat_desc.max_length,ze=0;for(He=0;He<=v;He++)we.bl_count[He]=0;for(Ie[2*we.heap[we.heap_max]+1]=0,Le=we.heap_max+1;Le<y;Le++)Xe<(He=Ie[2*Ie[2*(Be=we.heap[Le])+1]+1]+1)&&(He=Xe,ze++),Ie[2*Be+1]=He,_e<Be||(we.bl_count[He]++,be=0,Ee<=Be&&(be=it[Be-Ee]),Pe=Ie[2*Be],we.opt_len+=Pe*(He+be),Me&&(we.static_len+=Pe*(Ke[2*Be+1]+be)));if(ze!==0){do{for(He=Xe-1;we.bl_count[He]===0;)He--;we.bl_count[He]--,we.bl_count[He+1]+=2,we.bl_count[Xe]--,ze-=2}while(0<ze);for(He=Xe;He!==0;He--)for(Be=we.bl_count[He];Be!==0;)_e<(Ve=we.heap[--Le])||(Ie[2*Ve+1]!==He&&(we.opt_len+=(He-Ie[2*Ve+1])*Ie[2*Ve],Ie[2*Ve+1]=He),Be--)}})(ee,B),ue(H,Se,ee.bl_count)}function G(ee,B,he){var ke,pe,H=-1,O=B[1],J=0,le=7,Se=4;for(O===0&&(le=138,Se=3),B[2*(he+1)+1]=65535,ke=0;ke<=he;ke++)pe=O,O=B[2*(ke+1)+1],++J<le&&pe===O||(J<Se?ee.bl_tree[2*pe]+=J:pe!==0?(pe!==H&&ee.bl_tree[2*pe]++,ee.bl_tree[2*T]++):J<=10?ee.bl_tree[2*k]++:ee.bl_tree[2*C]++,H=pe,Se=(J=0)===O?(le=138,3):pe===O?(le=6,3):(le=7,4))}function Q(ee,B,he){var ke,pe,H=-1,O=B[1],J=0,le=7,Se=4;for(O===0&&(le=138,Se=3),ke=0;ke<=he;ke++)if(pe=O,O=B[2*(ke+1)+1],!(++J<le&&pe===O)){if(J<Se)for(;ge(ee,pe,ee.bl_tree),--J!=0;);else pe!==0?(pe!==H&&(ge(ee,pe,ee.bl_tree),J--),ge(ee,T,ee.bl_tree),re(ee,J-3,2)):J<=10?(ge(ee,k,ee.bl_tree),re(ee,J-3,3)):(ge(ee,C,ee.bl_tree),re(ee,J-11,7));H=pe,Se=(J=0)===O?(le=138,3):pe===O?(le=6,3):(le=7,4)}}c(Y);var de=!1;function q(ee,B,he,ke){re(ee,(u<<1)+(ke?1:0),3),(function(pe,H,O,J){ie(pe),ne(pe,O),ne(pe,~O),s.arraySet(pe.pending_buf,pe.window,H,O,pe.pending),pe.pending+=O})(ee,B,he)}i._tr_init=function(ee){de||((function(){var B,he,ke,pe,H,O=new Array(v+1);for(pe=ke=0;pe<d-1;pe++)for(V[pe]=ke,B=0;B<1<<E[pe];B++)j[ke++]=pe;for(j[ke-1]=pe,pe=H=0;pe<16;pe++)for(Y[pe]=H,B=0;B<1<<P[pe];B++)U[H++]=pe;for(H>>=7;pe<m;pe++)for(Y[pe]=H<<7,B=0;B<1<<P[pe]-7;B++)U[256+H++]=pe;for(he=0;he<=v;he++)O[he]=0;for(B=0;B<=143;)I[2*B+1]=8,B++,O[8]++;for(;B<=255;)I[2*B+1]=9,B++,O[9]++;for(;B<=279;)I[2*B+1]=7,B++,O[7]++;for(;B<=287;)I[2*B+1]=8,B++,O[8]++;for(ue(I,p+1,O),B=0;B<m;B++)L[2*B+1]=5,L[2*B]=me(B,5);K=new te(I,E,h+1,p,v),z=new te(L,P,0,m,v),X=new te(new Array(0),A,0,x,S)})(),de=!0),ee.l_desc=new $(ee.dyn_ltree,K),ee.d_desc=new $(ee.dyn_dtree,z),ee.bl_desc=new $(ee.bl_tree,X),ee.bi_buf=0,ee.bi_valid=0,Te(ee)},i._tr_stored_block=q,i._tr_flush_block=function(ee,B,he,ke){var pe,H,O=0;0<ee.level?(ee.strm.data_type===2&&(ee.strm.data_type=(function(J){var le,Se=4093624447;for(le=0;le<=31;le++,Se>>>=1)if(1&Se&&J.dyn_ltree[2*le]!==0)return o;if(J.dyn_ltree[18]!==0||J.dyn_ltree[20]!==0||J.dyn_ltree[26]!==0)return l;for(le=32;le<h;le++)if(J.dyn_ltree[2*le]!==0)return l;return o})(ee)),Ze(ee,ee.l_desc),Ze(ee,ee.d_desc),O=(function(J){var le;for(G(J,J.dyn_ltree,J.l_desc.max_code),G(J,J.dyn_dtree,J.d_desc.max_code),Ze(J,J.bl_desc),le=x-1;3<=le&&J.bl_tree[2*D[le]+1]===0;le--);return J.opt_len+=3*(le+1)+5+5+4,le})(ee),pe=ee.opt_len+3+7>>>3,(H=ee.static_len+3+7>>>3)<=pe&&(pe=H)):pe=H=he+5,he+4<=pe&&B!==-1?q(ee,B,he,ke):ee.strategy===4||H===pe?(re(ee,2+(ke?1:0),3),xe(ee,I,L)):(re(ee,4+(ke?1:0),3),(function(J,le,Se,we){var ae;for(re(J,le-257,5),re(J,Se-1,5),re(J,we-4,4),ae=0;ae<we;ae++)re(J,J.bl_tree[2*D[ae]+1],3);Q(J,J.dyn_ltree,le-1),Q(J,J.dyn_dtree,Se-1)})(ee,ee.l_desc.max_code+1,ee.d_desc.max_code+1,O+1),xe(ee,ee.dyn_ltree,ee.dyn_dtree)),Te(ee),ke&&ie(ee)},i._tr_tally=function(ee,B,he){return ee.pending_buf[ee.d_buf+2*ee.last_lit]=B>>>8&255,ee.pending_buf[ee.d_buf+2*ee.last_lit+1]=255&B,ee.pending_buf[ee.l_buf+ee.last_lit]=255&he,ee.last_lit++,B===0?ee.dyn_ltree[2*he]++:(ee.matches++,B--,ee.dyn_ltree[2*(j[he]+h+1)]++,ee.dyn_dtree[2*W(B)]++),ee.last_lit===ee.lit_bufsize-1},i._tr_align=function(ee){re(ee,2,3),ge(ee,N,I),(function(B){B.bi_valid===16?(ne(B,B.bi_buf),B.bi_buf=0,B.bi_valid=0):8<=B.bi_valid&&(B.pending_buf[B.pending++]=255&B.bi_buf,B.bi_buf>>=8,B.bi_valid-=8)})(ee)}},{"../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,h,p=1,m={},x=!1,y=o.document,v=Object.getPrototypeOf&&Object.getPrototypeOf(o);v=v&&v.setTimeout?v:o,c={}.toString.call(o.process)==="[object process]"?function(T){process.nextTick(function(){S(T)})}:(function(){if(o.postMessage&&!o.importScripts){var T=!0,k=o.onmessage;return o.onmessage=function(){T=!1},o.postMessage("","*"),o.onmessage=k,T}})()?(h="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",N,!1):o.attachEvent("onmessage",N),function(T){o.postMessage(h+T,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(T){S(T.data)},function(T){d.port2.postMessage(T)}):y&&"onreadystatechange"in y.createElement("script")?(u=y.documentElement,function(T){var k=y.createElement("script");k.onreadystatechange=function(){S(T),k.onreadystatechange=null,u.removeChild(k),k=null},u.appendChild(k)}):function(T){setTimeout(S,0,T)},v.setImmediate=function(T){typeof T!="function"&&(T=new Function(""+T));for(var k=new Array(arguments.length-1),C=0;C<k.length;C++)k[C]=arguments[C+1];var E={callback:T,args:k};return m[p]=E,c(p),p++},v.clearImmediate=b}function b(T){delete m[T]}function S(T){if(x)setTimeout(S,0,T);else{var k=m[T];if(k){x=!0;try{(function(C){var E=C.callback,P=C.args;switch(P.length){case 0:E();break;case 1:E(P[0]);break;case 2:E(P[0],P[1]);break;case 3:E(P[0],P[1],P[2]);break;default:E.apply(l,P)}})(k)}finally{b(T),x=!1}}}}function N(T){T.source===o&&typeof T.data=="string"&&T.data.indexOf(h)===0&&S(+T.data.slice(h.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof jw<"u"?jw:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(IT)),IT.exports}var Oye=Rye();const Lye=pl(Oye);function Fye(t){const e=new Gi;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 t8=Fye;async function n8(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 h=c[d];o.push(parseFloat(h.getAttribute("x")||"0"),parseFloat(h.getAttribute("y")||"0"),parseFloat(h.getAttribute("z")||"0"))}const u=s.getElementsByTagName("triangle");for(let d=0;d<u.length;d++){const h=u[d];l.push(parseInt(h.getAttribute("v1")||"0"),parseInt(h.getAttribute("v2")||"0"),parseInt(h.getAttribute("v3")||"0"))}o.length>0&&l.length>0&&n.push({vertices:o,triangles:l,extruder:e})}return n}function r8(t){const e=Array.from(t.attributes).find(r=>{const i=r.name.toLowerCase();return i==="plate_id"||i==="plater_id"||i==="plateid"||i==="platerid"||i.endsWith(":plate_id")||i.endsWith(":plater_id")});if(!e?.value)return null;const n=Number.parseInt(e.value,10);return Number.isFinite(n)?n:null}async function Iye(t){let e;try{e=await Lye.loadAsync(t)}catch{throw new Error("Unsupported file format")}const n=new Map,r=[],i=new Map,s=new DOMParser;async function o(S){const N=S.startsWith("/")?S.slice(1):S,T=e.files[N];if(!T)return null;const k=await T.async("string");return s.parseFromString(k,"application/xml")}const l=new Map,c=new Map,u=new Map,d=new Map,h=e.files["Metadata/model_settings.config"];if(h)try{const S=await h.async("string"),N=s.parseFromString(S,"application/xml"),T=N.getElementsByTagName("object");for(let C=0;C<T.length;C++){const E=T[C],P=E.getAttribute("id");if(!P)continue;const A=Array.from(E.children).filter(U=>U.tagName==="metadata"&&U.getAttribute("key")==="extruder");if(A.length>0){const U=A[0].getAttribute("value");U&&l.set(P,Math.max(0,parseInt(U,10)-1))}const I=Array.from(E.children).find(U=>U.tagName==="metadata"&&U.getAttribute("key")==="name")?.getAttribute("value");I&&u.set(P,I);const L=E.getElementsByTagName("part");for(let U=0;U<L.length;U++){const j=L[U],V=j.getAttribute("id");if(!V)continue;const K=Array.from(j.children).filter(z=>z.tagName==="metadata"&&z.getAttribute("key")==="extruder");if(K.length>0){const z=K[0].getAttribute("value");z&&c.set(`${P}:${V}`,Math.max(0,parseInt(z,10)-1))}}}const k=N.getElementsByTagName("plate");for(let C=0;C<k.length;C++){const E=k[C];let P=null;const A=E.getElementsByTagName("metadata");for(let I=0;I<A.length;I++){const L=A[I],U=L.getAttribute("key");if(U==="plater_id"||U==="plate_id"){const j=L.getAttribute("value");if(j){const V=Number.parseInt(j,10);Number.isFinite(V)&&(P=V)}}}if(P==null)continue;const D=E.getElementsByTagName("model_instance");for(let I=0;I<D.length;I++){const U=D[I].getElementsByTagName("metadata");for(let j=0;j<U.length;j++){const V=U[j];if(V.getAttribute("key")==="object_id"){const K=V.getAttribute("value");K&&d.set(K,P)}}}}}catch{}const p=new Map,m=Object.keys(e.files).filter(S=>S.startsWith("Metadata/plate_")&&S.endsWith(".json"));for(const S of m){const N=S.match(/^Metadata\/plate_(\d+)\.json$/);if(!N)continue;const T=Number.parseInt(N[1],10);if(Number.isFinite(T))try{const k=await e.files[S].async("string"),C=JSON.parse(k),E=C.bbox_objects??[];for(const P of E)P?.name&&p.set(P.name,T);if(Array.isArray(C.bbox_all)&&C.bbox_all.length>=4){const[P,A,D,I]=C.bbox_all;[P,A,D,I].every(L=>Number.isFinite(L))&&i.set(T,{minX:P,minY:A,maxX:D,maxY:I})}}catch{}}const x=Object.keys(e.files).find(S=>S==="3D/3dmodel.model"||S.endsWith("/3dmodel.model"));if(!x){const S=Object.keys(e.files).find(N=>N.endsWith(".model"));if(S){const N=await o(S);if(N){const T=await n8(N,0);T.length>0&&n.set("1",{id:"1",meshes:T,defaultExtruder:0})}}return{objects:n,buildItems:r,plateBounds:i}}const y=await o(x);if(!y)return{objects:n,buildItems:r,plateBounds:i};const v=y.getElementsByTagName("object");for(let S=0;S<v.length;S++){const N=v[S],T=N.getAttribute("id");if(!T)continue;const k=r8(N)??d.get(T)??null;let C=l.get(T)??-1;if(C<0){const D=N.getAttribute("p:extruder")||N.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";C=Math.max(0,parseInt(D,10)-1)}const E=[],P=N.getElementsByTagName("mesh");for(let D=0;D<P.length;D++){const I=P[D],L=[],U=[],j=I.getElementsByTagName("vertex");for(let K=0;K<j.length;K++){const z=j[K];L.push(parseFloat(z.getAttribute("x")||"0"),parseFloat(z.getAttribute("y")||"0"),parseFloat(z.getAttribute("z")||"0"))}const V=I.getElementsByTagName("triangle");for(let K=0;K<V.length;K++){const z=V[K];U.push(parseInt(z.getAttribute("v1")||"0"),parseInt(z.getAttribute("v2")||"0"),parseInt(z.getAttribute("v3")||"0"))}L.length>0&&U.length>0&&E.push({vertices:L,triangles:U,extruder:C})}const A=N.getElementsByTagName("component");for(let D=0;D<A.length;D++){const I=A[D],L=I.getAttribute("p:path")||I.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),U=I.getAttribute("objectid");if(L){const j=await o(L);if(j){const V=U?`${T}:${U}`:null,K=V?c.get(V)??C:C,z=await n8(j,K),X=I.getAttribute("transform"),Y=t8(X);for(const te of z)if(X){const $=[];for(let W=0;W<te.vertices.length;W+=3){const ne=new mt(te.vertices[W],te.vertices[W+1],te.vertices[W+2]);ne.applyMatrix4(Y),$.push(ne.x,ne.y,ne.z)}E.push({vertices:$,triangles:te.triangles,extruder:te.extruder})}else E.push(te)}}}E.length>0&&n.set(T,{id:T,meshes:E,defaultExtruder:C,plateId:k})}const b=y.getElementsByTagName("build");if(b.length>0){const S=b[0].getElementsByTagName("item");for(let N=0;N<S.length;N++){const T=S[N],k=T.getAttribute("objectid");if(!k)continue;const C=t8(T.getAttribute("transform")),E=r8(T),P=n.get(k)?.plateId??null,A=u.get(k),D=A?p.get(A)??null:null;r.push({objectId:k,transform:C,plateId:E??P??D??null})}}return{objects:n,buildItems:r,plateBounds:i}}function i8(t){const e=new ul,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 bs(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function Uye(t){t.traverse(e=>{if(e instanceof dl)if(e.geometry.dispose(),Array.isArray(e.material))for(const n of e.material)n.dispose();else e.material.dispose()})}function zye(t,e,n){const{objects:r,buildItems:i}=t,s=new xg,o=h=>{const m=n?.[h]||"#00ae42",x=new Rn(m);return new _K({color:x,shininess:30,flatShading:!1})},l=new Map,c=i.some(h=>h.plateId!=null),u=e==null||!c?i:i.filter(h=>h.plateId===e),d=u.length>0?u:i;if(d.length>0)for(const h of d){const p=r.get(h.objectId);if(p)for(const m of p.meshes){const x=h.extruder??m.extruder,y=[];for(let b=0;b<m.vertices.length;b+=3){const S=new mt(m.vertices[b],m.vertices[b+1],m.vertices[b+2]);S.applyMatrix4(h.transform),y.push(S.x,S.y,S.z)}const v=i8({vertices:y,triangles:m.triangles});l.has(x)||l.set(x,[]),l.get(x).push(v)}}else for(const h of r.values())for(const p of h.meshes){const m=p.extruder,x=i8(p);l.has(m)||l.set(m,[]),l.get(m).push(x)}for(const[h,p]of l){if(p.length===0)continue;const m=p.length===1?p[0]:Pye(p,!1);if(m){const x=o(h),y=new dl(m,x);s.add(y)}if(p.length>1)for(const x of p)x.dispose()}return s}function jK({url:t,fileType:e,buildVolume:n={x:256,y:256,z:256},filamentColors:r,selectedPlateId:i=null,className:s=""}){const o=_.useRef(null),l=_.useRef(null),c=_.useRef(null),u=_.useRef(null),d=_.useRef(null),h=_.useRef(null),p=_.useRef(null),m=_.useRef(null),[x,y]=_.useState(!0),[v,b]=_.useState(null),[S,N]=_.useState(null),[T,k]=_.useState(null);_.useEffect(()=>{if(!o.current)return;const P=o.current,A=P.clientWidth,D=P.clientHeight,I=new hpe;I.background=new Rn(1710618),c.current=I;const L=new Qo(45,A/D,.1,1e4);L.position.set(150,150,150),u.current=L;const U=new xye({antialias:!0});U.setSize(A,D),U.setPixelRatio(window.devicePixelRatio),P.appendChild(U.domElement),l.current=U;const j=new yye(L,U.domElement);j.enableDamping=!0,j.dampingFactor=.05,d.current=j;const V=new Epe(16777215,.6);I.add(V);const K=new MB(16777215,.8);K.position.set(100,100,100),I.add(K);const z=new MB(16777215,.4);z.position.set(-100,50,-100),I.add(z);const X=Math.max(n.x,n.y),Y=Math.ceil(X/16),te=new Ape(X,Y,4473924,3355443);I.add(te),m.current=te;const $=new eO(n.x,n.y),W=new QR({color:44610,transparent:!0,opacity:.15,side:sc}),ne=new dl($,W);ne.rotation.x=-Math.PI/2,ne.position.y=-.5,I.add(ne),p.current=ne;let re;const ge=()=>{re=requestAnimationFrame(ge),j.update(),U.render(I,L)};ge(),y(!0),b(null),N(null),k(null);const me=(e||t.split("?")[0].split(".").pop()||"").toLowerCase();me==="stl"?fetch(t).then(Te=>{if(!Te.ok)throw new Error("Failed to load file");return Te.arrayBuffer()}).then(Te=>{const Ce=new Dye().parse(Te);Ce.computeVertexNormals(),Ce.rotateX(-Math.PI/2),k(Ce)}).catch(Te=>{b(Te.message),y(!1)}):me==="3mf"?fetch(t).then(Te=>{if(!Te.ok)throw new Error("Failed to load file");return Te.arrayBuffer()}).then(Iye).then(Te=>{if(Te.objects.size===0)throw new Error("No meshes found in 3MF file");N(Te)}).catch(Te=>{b(Te.message),y(!1)}):(b("Unsupported file format"),y(!1));const ue=()=>{if(!P)return;const Te=P.clientWidth,ie=P.clientHeight;L.aspect=Te/ie,L.updateProjectionMatrix(),U.setSize(Te,ie)};return window.addEventListener("resize",ue),()=>{window.removeEventListener("resize",ue),cancelAnimationFrame(re),j.dispose(),U.dispose(),P.removeChild(U.domElement),h.current=null,p.current=null,m.current=null}},[t,n,e]),_.useEffect(()=>{if(!c.current||!u.current||!d.current||!S&&!T)return;h.current&&(c.current.remove(h.current),Uye(h.current));const P=!!T,A=P?(()=>{const re=r?.[0]||"#00ae42",ge=new _K({color:new Rn(re),shininess:30}),me=new dl(T,ge),ue=new xg;return ue.add(me),ue})():zye(S,i??null,r);h.current=A,c.current.add(A);const D=new ch().setFromObject(A),I=D.getCenter(new mt);A.position.y=-D.min.y;const L=P||S.buildItems.length===0,U=L?-I.x:0,j=L?-I.z:0;let V=0,K=0;if(!P&&i!=null&&S.buildItems.length>0){const re=new ch().setFromObject(A),ge=S.plateBounds.get(i);ge?(V=re.min.x-ge.minX,K=re.min.z-ge.minY):(V=Math.floor((re.min.x+1e-6)/n.x)*n.x,K=Math.floor((re.min.z+1e-6)/n.y)*n.y)}const z=n.x/2,X=n.y/2;!P&&i!=null&&S.buildItems.length>0?(A.position.x=U-V,A.position.z=j-K):P?(A.position.x=U+z,A.position.z=j+X):(A.position.x=U,A.position.z=j),p.current&&(p.current.position.x=z,p.current.position.z=X),m.current&&(m.current.position.x=z,m.current.position.z=X);const Y=new ch().setFromObject(A),te=Y.getCenter(new mt),$=Y.getSize(new mt),ne=Math.max($.x,$.y,$.z)*1.8;u.current.position.set(te.x+ne*.7,te.y+ne*.5,te.z+ne*.7),d.current.target.copy(te),d.current.update(),y(!1)},[S,T,i,r,n]);const C=()=>{u.current&&d.current&&(u.current.position.set(150,150,150),d.current.target.set(0,50,0),d.current.update())},E=P=>{u.current&&u.current.position.multiplyScalar(P)};return a.jsxs("div",{className:`relative ${s}`,children:[a.jsx("div",{ref:o,className:"w-full h-full min-h-[400px]"}),x&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:a.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}),v&&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:v})}),!x&&!v&&a.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[a.jsx(Ae,{variant:"secondary",size:"sm",onClick:()=>E(.8),children:a.jsx(FR,{className:"w-4 h-4"})}),a.jsx(Ae,{variant:"secondary",size:"sm",onClick:()=>E(1.25),children:a.jsx(IR,{className:"w-4 h-4"})}),a.jsx(Ae,{variant:"secondary",size:"sm",onClick:C,children:a.jsx(Lh,{className:"w-4 h-4"})})]})]})}const MM="159",Pp={ROTATE:0,DOLLY:1,PAN:2},Dp={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},Bye=0,a8=1,Hye=2,PK=1,$ye=2,du=3,Mh=0,Hs=1,pu=2,uh=0,Cg=1,s8=2,o8=3,l8=4,Vye=5,Tf=100,Gye=101,qye=102,c8=103,u8=104,Wye=200,Kye=201,Xye=202,Yye=203,d3=204,h3=205,Qye=206,Zye=207,Jye=208,eve=209,tve=210,nve=211,rve=212,ive=213,ave=214,sve=0,ove=1,lve=2,nS=3,cve=4,uve=5,dve=6,hve=7,rO=0,fve=1,mve=2,dh=0,pve=1,gve=2,xve=3,bve=4,yve=5,DK=300,Yg=301,Qg=302,f3=303,m3=304,kM=306,p3=1e3,Cl=1001,g3=1002,La=1003,d8=1004,UT=1005,Zo=1006,vve=1007,ty=1008,hh=1009,wve=1010,_ve=1011,iO=1012,RK=1013,Jd=1014,_u=1015,ny=1016,OK=1017,LK=1018,$f=1020,Sve=1021,Jo=1023,Nve=1024,Mve=1025,Vf=1026,Zg=1027,kve=1028,FK=1029,Eve=1030,IK=1031,UK=1033,zT=33776,BT=33777,HT=33778,$T=33779,h8=35840,f8=35841,m8=35842,p8=35843,zK=36196,g8=37492,x8=37496,b8=37808,y8=37809,v8=37810,w8=37811,_8=37812,S8=37813,N8=37814,M8=37815,k8=37816,E8=37817,T8=37818,A8=37819,C8=37820,j8=37821,VT=36492,P8=36494,D8=36495,Tve=36283,R8=36284,O8=36285,L8=36286,BK=3e3,Gf=3001,Ave=3200,Cve=3201,HK=0,jve=1,el="",Fa="srgb",Iu="srgb-linear",aO="display-p3",EM="display-p3-linear",rS="linear",Gr="srgb",iS="rec709",aS="p3",Rp=7680,F8=519,Pve=512,Dve=513,Rve=514,$K=515,Ove=516,Lve=517,Fve=518,Ive=519,x3=35044,I8="300 es",b3=1035,dc=2e3,ry=2001;class Am{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 qa=["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 U8=1234567;const w0=Math.PI/180,iy=180/Math.PI;function Cu(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(qa[t&255]+qa[t>>8&255]+qa[t>>16&255]+qa[t>>24&255]+"-"+qa[e&255]+qa[e>>8&255]+"-"+qa[e>>16&15|64]+qa[e>>24&255]+"-"+qa[n&63|128]+qa[n>>8&255]+"-"+qa[n>>16&255]+qa[n>>24&255]+qa[r&255]+qa[r>>8&255]+qa[r>>16&255]+qa[r>>24&255]).toLowerCase()}function Ia(t,e,n){return Math.max(e,Math.min(n,t))}function sO(t,e){return(t%e+e)%e}function Uve(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function zve(t,e,n){return t!==e?(n-t)/(e-t):0}function _0(t,e,n){return(1-n)*t+n*e}function Bve(t,e,n,r){return _0(t,e,1-Math.exp(-n*r))}function Hve(t,e=1){return e-Math.abs(sO(t,e*2)-e)}function $ve(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function Vve(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function Gve(t,e){return t+Math.floor(Math.random()*(e-t+1))}function qve(t,e){return t+Math.random()*(e-t)}function Wve(t){return t*(.5-Math.random())}function Kve(t){t!==void 0&&(U8=t);let e=U8+=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 Xve(t){return t*w0}function Yve(t){return t*iy}function y3(t){return(t&t-1)===0&&t!==0}function Qve(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function sS(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Zve(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),h=s((e-r)/2),p=o((e-r)/2),m=s((r-e)/2),x=o((r-e)/2);switch(i){case"XYX":t.set(l*d,c*h,c*p,l*u);break;case"YZY":t.set(c*p,l*d,c*h,l*u);break;case"ZXZ":t.set(c*h,c*p,l*d,l*u);break;case"XZX":t.set(l*d,c*x,c*m,l*u);break;case"YXY":t.set(c*m,l*d,c*x,l*u);break;case"ZYZ":t.set(c*x,c*m,l*d,l*u);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function oc(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 kr(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 VK={DEG2RAD:w0,RAD2DEG:iy,generateUUID:Cu,clamp:Ia,euclideanModulo:sO,mapLinear:Uve,inverseLerp:zve,lerp:_0,damp:Bve,pingpong:Hve,smoothstep:$ve,smootherstep:Vve,randInt:Gve,randFloat:qve,randFloatSpread:Wve,seededRandom:Kve,degToRad:Xve,radToDeg:Yve,isPowerOfTwo:y3,ceilPowerOfTwo:Qve,floorPowerOfTwo:sS,setQuaternionFromProperEuler:Zve,normalize:kr,denormalize:oc};class bn{constructor(e=0,n=0){bn.prototype.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,r=this.y,i=e.elements;return this.x=i[0]*n+i[3]*r+i[6],this.y=i[1]*n+i[4]*r+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Ia(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),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 In{constructor(e,n,r,i,s,o,l,c,u){In.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],h=r[7],p=r[2],m=r[5],x=r[8],y=i[0],v=i[3],b=i[6],S=i[1],N=i[4],T=i[7],k=i[2],C=i[5],E=i[8];return s[0]=o*y+l*S+c*k,s[3]=o*v+l*N+c*C,s[6]=o*b+l*T+c*E,s[1]=u*y+d*S+h*k,s[4]=u*v+d*N+h*C,s[7]=u*b+d*T+h*E,s[2]=p*y+m*S+x*k,s[5]=p*v+m*N+x*C,s[8]=p*b+m*T+x*E,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],h=d*o-l*u,p=l*c-d*s,m=u*s-o*c,x=n*h+r*p+i*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/x;return e[0]=h*y,e[1]=(i*u-d*r)*y,e[2]=(l*r-i*o)*y,e[3]=p*y,e[4]=(d*n-i*c)*y,e[5]=(i*s-l*n)*y,e[6]=m*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(GT.makeScale(e,n)),this}rotate(e){return this.premultiply(GT.makeRotation(-e)),this}translate(e,n){return this.premultiply(GT.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 GT=new In;function GK(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function oS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function Jve(){const t=oS("canvas");return t.style.display="block",t}const z8={};function S0(t){t in z8||(z8[t]=!0,console.warn(t))}const B8=new In().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),H8=new In().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),s_={[Iu]:{transfer:rS,primaries:iS,toReference:t=>t,fromReference:t=>t},[Fa]:{transfer:Gr,primaries:iS,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[EM]:{transfer:rS,primaries:aS,toReference:t=>t.applyMatrix3(H8),fromReference:t=>t.applyMatrix3(B8)},[aO]:{transfer:Gr,primaries:aS,toReference:t=>t.convertSRGBToLinear().applyMatrix3(H8),fromReference:t=>t.applyMatrix3(B8).convertLinearToSRGB()}},ewe=new Set([Iu,EM]),Er={enabled:!0,_workingColorSpace:Iu,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(!ewe.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=s_[e].toReference,i=s_[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 s_[t].primaries},getTransfer:function(t){return t===el?rS:s_[t].transfer}};function jg(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function qT(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Op;class qK{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Op===void 0&&(Op=oS("canvas")),Op.width=e.width,Op.height=e.height;const r=Op.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Op}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=oS("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]=jg(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(jg(n[r]/255)*255):n[r]=jg(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 twe=0;class WK{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:twe++}),this.uuid=Cu(),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(WT(i[o].image)):s.push(WT(i[o]))}else s=WT(i);r.url=s}return n||(e.images[this.uuid]=r),r}}function WT(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?qK.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 nwe=0;class $s extends Am{constructor(e=$s.DEFAULT_IMAGE,n=$s.DEFAULT_MAPPING,r=Cl,i=Cl,s=Zo,o=ty,l=Jo,c=hh,u=$s.DEFAULT_ANISOTROPY,d=el){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:nwe++}),this.uuid=Cu(),this.name="",this.source=new WK(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 bn(0,0),this.repeat=new bn(1,1),this.center=new bn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new In,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,typeof d=="string"?this.colorSpace=d:(S0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=d===Gf?Fa:el),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!==DK)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case p3:e.x=e.x-Math.floor(e.x);break;case Cl:e.x=e.x<0?0:1;break;case g3: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 p3:e.y=e.y-Math.floor(e.y);break;case Cl:e.y=e.y<0?0:1;break;case g3: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 S0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace===Fa?Gf:BK}set encoding(e){S0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Gf?Fa:el}}$s.DEFAULT_IMAGE=null;$s.DEFAULT_MAPPING=DK;$s.DEFAULT_ANISOTROPY=1;class Cr{constructor(e=0,n=0,r=0,i=1){Cr.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],h=c[8],p=c[1],m=c[5],x=c[9],y=c[2],v=c[6],b=c[10];if(Math.abs(d-p)<.01&&Math.abs(h-y)<.01&&Math.abs(x-v)<.01){if(Math.abs(d+p)<.1&&Math.abs(h+y)<.1&&Math.abs(x+v)<.1&&Math.abs(u+m+b-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const N=(u+1)/2,T=(m+1)/2,k=(b+1)/2,C=(d+p)/4,E=(h+y)/4,P=(x+v)/4;return N>T&&N>k?N<.01?(r=0,i=.707106781,s=.707106781):(r=Math.sqrt(N),i=C/r,s=E/r):T>k?T<.01?(r=.707106781,i=0,s=.707106781):(i=Math.sqrt(T),r=C/i,s=P/i):k<.01?(r=.707106781,i=.707106781,s=0):(s=Math.sqrt(k),r=E/s,i=P/s),this.set(r,i,s,n),this}let S=Math.sqrt((v-x)*(v-x)+(h-y)*(h-y)+(p-d)*(p-d));return Math.abs(S)<.001&&(S=1),this.x=(v-x)/S,this.y=(h-y)/S,this.z=(p-d)/S,this.w=Math.acos((u+m+b-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this.w=e.w+(n.w-e.w)*r,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class rwe extends Am{constructor(e=1,n=1,r={}){super(),this.isRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Cr(0,0,e,n),this.scissorTest=!1,this.viewport=new Cr(0,0,e,n);const i={width:e,height:n,depth:1};r.encoding!==void 0&&(S0("THREE.WebGLRenderTarget: option.encoding has been replaced by option.colorSpace."),r.colorSpace=r.encoding===Gf?Fa:el),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Zo,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new $s(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 WK(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 fm extends rwe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class KK extends $s{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=La,this.minFilter=La,this.wrapR=Cl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class iwe extends $s{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=La,this.minFilter=La,this.wrapR=Cl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class mm{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],h=r[i+3];const p=s[o+0],m=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]=h;return}if(l===1){e[n+0]=p,e[n+1]=m,e[n+2]=x,e[n+3]=y;return}if(h!==y||c!==p||u!==m||d!==x){let v=1-l;const b=c*p+u*m+d*x+h*y,S=b>=0?1:-1,N=1-b*b;if(N>Number.EPSILON){const k=Math.sqrt(N),C=Math.atan2(k,b*S);v=Math.sin(v*C)/k,l=Math.sin(l*C)/k}const T=l*S;if(c=c*v+p*T,u=u*v+m*T,d=d*v+x*T,h=h*v+y*T,v===1-l){const k=1/Math.sqrt(c*c+u*u+d*d+h*h);c*=k,u*=k,d*=k,h*=k}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=h}static multiplyQuaternionsFlat(e,n,r,i,s,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],h=s[o],p=s[o+1],m=s[o+2],x=s[o+3];return e[n]=l*x+d*h+c*m-u*p,e[n+1]=c*x+d*p+u*h-l*m,e[n+2]=u*x+d*m+l*p-c*h,e[n+3]=d*x-l*h-c*p-u*m,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,r,i){return this._x=e,this._y=n,this._z=r,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){const r=e._x,i=e._y,s=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),h=l(s/2),p=c(r/2),m=c(i/2),x=c(s/2);switch(o){case"XYZ":this._x=p*d*h+u*m*x,this._y=u*m*h-p*d*x,this._z=u*d*x+p*m*h,this._w=u*d*h-p*m*x;break;case"YXZ":this._x=p*d*h+u*m*x,this._y=u*m*h-p*d*x,this._z=u*d*x-p*m*h,this._w=u*d*h+p*m*x;break;case"ZXY":this._x=p*d*h-u*m*x,this._y=u*m*h+p*d*x,this._z=u*d*x+p*m*h,this._w=u*d*h-p*m*x;break;case"ZYX":this._x=p*d*h-u*m*x,this._y=u*m*h+p*d*x,this._z=u*d*x-p*m*h,this._w=u*d*h+p*m*x;break;case"YZX":this._x=p*d*h+u*m*x,this._y=u*m*h+p*d*x,this._z=u*d*x-p*m*h,this._w=u*d*h-p*m*x;break;case"XZY":this._x=p*d*h-u*m*x,this._y=u*m*h-p*d*x,this._z=u*d*x+p*m*h,this._w=u*d*h+p*m*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],h=n[10],p=r+l+h;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(d-c)*m,this._y=(s-u)*m,this._z=(o-i)*m}else if(r>l&&r>h){const m=2*Math.sqrt(1+r-l-h);this._w=(d-c)/m,this._x=.25*m,this._y=(i+o)/m,this._z=(s+u)/m}else if(l>h){const m=2*Math.sqrt(1+l-r-h);this._w=(s-u)/m,this._x=(i+o)/m,this._y=.25*m,this._z=(c+d)/m}else{const m=2*Math.sqrt(1+h-r-l);this._w=(o-i)/m,this._x=(s+u)/m,this._y=(c+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ia(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,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 m=1-n;return this._w=m*o+n*this._w,this._x=m*r+n*this._x,this._y=m*i+n*this._y,this._z=m*s+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,l),h=Math.sin((1-n)*d)/u,p=Math.sin(n*d)/u;return this._w=o*h+this._w*p,this._x=r*h+this._x*p,this._y=i*h+this._y*p,this._z=s*h+this._z*p,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 We{constructor(e=0,n=0,r=0){We.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($8.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion($8.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),h=2*(s*r-o*n);return this.x=n+c*u+o*h-l*d,this.y=r+c*d+l*u-s*h,this.z=i+c*h+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 KT.copy(this).projectOnVector(e),this.sub(KT)}reflect(e){return this.sub(KT.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const r=this.dot(e)/n;return Math.acos(Ia(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y,i=this.z-e.z;return n*n+r*r+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,r){const i=Math.sin(n)*e;return this.x=i*Math.sin(r),this.y=Math.cos(n)*e,this.z=i*Math.cos(r),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,r){return this.x=e*Math.sin(n),this.y=r,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=r,this.z=i,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,n=Math.random()*Math.PI*2,r=Math.sqrt(1-e**2);return this.x=r*Math.cos(n),this.y=r*Math.sin(n),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const KT=new We,$8=new mm;class sl{constructor(e=new We(1/0,1/0,1/0),n=new We(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(kl.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(kl.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=kl.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,kl):kl.fromBufferAttribute(s,o),kl.applyMatrix4(e.matrixWorld),this.expandByPoint(kl);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),o_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),o_.copy(r.boundingBox)),o_.applyMatrix4(e.matrixWorld),this.union(o_)}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,kl),kl.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(Bb),l_.subVectors(this.max,Bb),Lp.subVectors(e.a,Bb),Fp.subVectors(e.b,Bb),Ip.subVectors(e.c,Bb),Ad.subVectors(Fp,Lp),Cd.subVectors(Ip,Fp),pf.subVectors(Lp,Ip);let n=[0,-Ad.z,Ad.y,0,-Cd.z,Cd.y,0,-pf.z,pf.y,Ad.z,0,-Ad.x,Cd.z,0,-Cd.x,pf.z,0,-pf.x,-Ad.y,Ad.x,0,-Cd.y,Cd.x,0,-pf.y,pf.x,0];return!XT(n,Lp,Fp,Ip,l_)||(n=[1,0,0,0,1,0,0,0,1],!XT(n,Lp,Fp,Ip,l_))?!1:(c_.crossVectors(Ad,Cd),n=[c_.x,c_.y,c_.z],XT(n,Lp,Fp,Ip,l_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,kl).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(kl).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:(tu[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),tu[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),tu[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),tu[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),tu[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),tu[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),tu[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),tu[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(tu),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 tu=[new We,new We,new We,new We,new We,new We,new We,new We],kl=new We,o_=new sl,Lp=new We,Fp=new We,Ip=new We,Ad=new We,Cd=new We,pf=new We,Bb=new We,l_=new We,c_=new We,gf=new We;function XT(t,e,n,r,i){for(let s=0,o=t.length-3;s<=o;s+=3){gf.fromArray(t,s);const l=i.x*Math.abs(gf.x)+i.y*Math.abs(gf.y)+i.z*Math.abs(gf.z),c=e.dot(gf),u=n.dot(gf),d=r.dot(gf);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const awe=new sl,Hb=new We,YT=new We;class mc{constructor(e=new We,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):awe.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;Hb.subVectors(e,this.center);const n=Hb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Hb,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):(YT.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Hb.copy(e.center).add(YT)),this.expandByPoint(Hb.copy(e.center).sub(YT))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const nu=new We,QT=new We,u_=new We,jd=new We,ZT=new We,d_=new We,JT=new We;class oO{constructor(e=new We,n=new We(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,nu)),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=nu.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(nu.copy(this.origin).addScaledVector(this.direction,n),nu.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){QT.copy(e).add(n).multiplyScalar(.5),u_.copy(n).sub(e).normalize(),jd.copy(this.origin).sub(QT);const s=e.distanceTo(n)*.5,o=-this.direction.dot(u_),l=jd.dot(this.direction),c=-jd.dot(u_),u=jd.lengthSq(),d=Math.abs(1-o*o);let h,p,m,x;if(d>0)if(h=o*c-l,p=o*l-c,x=s*d,h>=0)if(p>=-x)if(p<=x){const y=1/d;h*=y,p*=y,m=h*(h+o*p+2*l)+p*(o*h+p+2*c)+u}else p=s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;else p=-s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;else p<=-x?(h=Math.max(0,-(-o*s+l)),p=h>0?-s:Math.min(Math.max(-s,-c),s),m=-h*h+p*(p+2*c)+u):p<=x?(h=0,p=Math.min(Math.max(-s,-c),s),m=p*(p+2*c)+u):(h=Math.max(0,-(o*s+l)),p=h>0?s:Math.min(Math.max(-s,-c),s),m=-h*h+p*(p+2*c)+u);else p=o>0?-s:s,h=Math.max(0,-(o*p+l)),m=-h*h+p*(p+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,h),i&&i.copy(QT).addScaledVector(u_,p),m}intersectSphere(e,n){nu.subVectors(e.center,this.origin);const r=nu.dot(this.direction),i=nu.dot(nu)-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,h=1/this.direction.z,p=this.origin;return u>=0?(r=(e.min.x-p.x)*u,i=(e.max.x-p.x)*u):(r=(e.max.x-p.x)*u,i=(e.min.x-p.x)*u),d>=0?(s=(e.min.y-p.y)*d,o=(e.max.y-p.y)*d):(s=(e.max.y-p.y)*d,o=(e.min.y-p.y)*d),r>o||s>i||((s>r||isNaN(r))&&(r=s),(o<i||isNaN(i))&&(i=o),h>=0?(l=(e.min.z-p.z)*h,c=(e.max.z-p.z)*h):(l=(e.max.z-p.z)*h,c=(e.min.z-p.z)*h),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,nu)!==null}intersectTriangle(e,n,r,i,s){ZT.subVectors(n,e),d_.subVectors(r,e),JT.crossVectors(ZT,d_);let o=this.direction.dot(JT),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;jd.subVectors(this.origin,e);const c=l*this.direction.dot(d_.crossVectors(jd,d_));if(c<0)return null;const u=l*this.direction.dot(ZT.cross(jd));if(u<0||c+u>o)return null;const d=-l*jd.dot(JT);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 zr{constructor(e,n,r,i,s,o,l,c,u,d,h,p,m,x,y,v){zr.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,h,p,m,x,y,v)}set(e,n,r,i,s,o,l,c,u,d,h,p,m,x,y,v){const b=this.elements;return b[0]=e,b[4]=n,b[8]=r,b[12]=i,b[1]=s,b[5]=o,b[9]=l,b[13]=c,b[2]=u,b[6]=d,b[10]=h,b[14]=p,b[3]=m,b[7]=x,b[11]=y,b[15]=v,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new zr().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/Up.setFromMatrixColumn(e,0).length(),s=1/Up.setFromMatrixColumn(e,1).length(),o=1/Up.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),h=Math.sin(s);if(e.order==="XYZ"){const p=o*d,m=o*h,x=l*d,y=l*h;n[0]=c*d,n[4]=-c*h,n[8]=u,n[1]=m+x*u,n[5]=p-y*u,n[9]=-l*c,n[2]=y-p*u,n[6]=x+m*u,n[10]=o*c}else if(e.order==="YXZ"){const p=c*d,m=c*h,x=u*d,y=u*h;n[0]=p+y*l,n[4]=x*l-m,n[8]=o*u,n[1]=o*h,n[5]=o*d,n[9]=-l,n[2]=m*l-x,n[6]=y+p*l,n[10]=o*c}else if(e.order==="ZXY"){const p=c*d,m=c*h,x=u*d,y=u*h;n[0]=p-y*l,n[4]=-o*h,n[8]=x+m*l,n[1]=m+x*l,n[5]=o*d,n[9]=y-p*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const p=o*d,m=o*h,x=l*d,y=l*h;n[0]=c*d,n[4]=x*u-m,n[8]=p*u+y,n[1]=c*h,n[5]=y*u+p,n[9]=m*u-x,n[2]=-u,n[6]=l*c,n[10]=o*c}else if(e.order==="YZX"){const p=o*c,m=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=y-p*h,n[8]=x*h+m,n[1]=h,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=m*h+x,n[10]=p-y*h}else if(e.order==="XZY"){const p=o*c,m=o*u,x=l*c,y=l*u;n[0]=c*d,n[4]=-h,n[8]=u*d,n[1]=p*h+y,n[5]=o*d,n[9]=m*h-x,n[2]=x*h-m,n[6]=l*d,n[10]=y*h+p}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(swe,e,owe)}lookAt(e,n,r){const i=this.elements;return oo.subVectors(e,n),oo.lengthSq()===0&&(oo.z=1),oo.normalize(),Pd.crossVectors(r,oo),Pd.lengthSq()===0&&(Math.abs(r.z)===1?oo.x+=1e-4:oo.z+=1e-4,oo.normalize(),Pd.crossVectors(r,oo)),Pd.normalize(),h_.crossVectors(oo,Pd),i[0]=Pd.x,i[4]=h_.x,i[8]=oo.x,i[1]=Pd.y,i[5]=h_.y,i[9]=oo.y,i[2]=Pd.z,i[6]=h_.z,i[10]=oo.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],h=r[5],p=r[9],m=r[13],x=r[2],y=r[6],v=r[10],b=r[14],S=r[3],N=r[7],T=r[11],k=r[15],C=i[0],E=i[4],P=i[8],A=i[12],D=i[1],I=i[5],L=i[9],U=i[13],j=i[2],V=i[6],K=i[10],z=i[14],X=i[3],Y=i[7],te=i[11],$=i[15];return s[0]=o*C+l*D+c*j+u*X,s[4]=o*E+l*I+c*V+u*Y,s[8]=o*P+l*L+c*K+u*te,s[12]=o*A+l*U+c*z+u*$,s[1]=d*C+h*D+p*j+m*X,s[5]=d*E+h*I+p*V+m*Y,s[9]=d*P+h*L+p*K+m*te,s[13]=d*A+h*U+p*z+m*$,s[2]=x*C+y*D+v*j+b*X,s[6]=x*E+y*I+v*V+b*Y,s[10]=x*P+y*L+v*K+b*te,s[14]=x*A+y*U+v*z+b*$,s[3]=S*C+N*D+T*j+k*X,s[7]=S*E+N*I+T*V+k*Y,s[11]=S*P+N*L+T*K+k*te,s[15]=S*A+N*U+T*z+k*$,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],h=e[6],p=e[10],m=e[14],x=e[3],y=e[7],v=e[11],b=e[15];return x*(+s*c*h-i*u*h-s*l*p+r*u*p+i*l*m-r*c*m)+y*(+n*c*m-n*u*p+s*o*p-i*o*m+i*u*d-s*c*d)+v*(+n*u*h-n*l*m-s*o*h+r*o*m+s*l*d-r*u*d)+b*(-i*l*d-n*c*h+n*l*p+i*o*h-r*o*p+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],h=e[9],p=e[10],m=e[11],x=e[12],y=e[13],v=e[14],b=e[15],S=h*v*u-y*p*u+y*c*m-l*v*m-h*c*b+l*p*b,N=x*p*u-d*v*u-x*c*m+o*v*m+d*c*b-o*p*b,T=d*y*u-x*h*u+x*l*m-o*y*m-d*l*b+o*h*b,k=x*h*c-d*y*c-x*l*p+o*y*p+d*l*v-o*h*v,C=n*S+r*N+i*T+s*k;if(C===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const E=1/C;return e[0]=S*E,e[1]=(y*p*s-h*v*s-y*i*m+r*v*m+h*i*b-r*p*b)*E,e[2]=(l*v*s-y*c*s+y*i*u-r*v*u-l*i*b+r*c*b)*E,e[3]=(h*c*s-l*p*s-h*i*u+r*p*u+l*i*m-r*c*m)*E,e[4]=N*E,e[5]=(d*v*s-x*p*s+x*i*m-n*v*m-d*i*b+n*p*b)*E,e[6]=(x*c*s-o*v*s-x*i*u+n*v*u+o*i*b-n*c*b)*E,e[7]=(o*p*s-d*c*s+d*i*u-n*p*u-o*i*m+n*c*m)*E,e[8]=T*E,e[9]=(x*h*s-d*y*s-x*r*m+n*y*m+d*r*b-n*h*b)*E,e[10]=(o*y*s-x*l*s+x*r*u-n*y*u-o*r*b+n*l*b)*E,e[11]=(d*l*s-o*h*s-d*r*u+n*h*u+o*r*m-n*l*m)*E,e[12]=k*E,e[13]=(d*y*i-x*h*i+x*r*p-n*y*p-d*r*v+n*h*v)*E,e[14]=(x*l*i-o*y*i-x*r*c+n*y*c+o*r*v-n*l*v)*E,e[15]=(o*h*i-d*l*i+d*r*c-n*h*c-o*r*p+n*l*p)*E,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,h=l+l,p=s*u,m=s*d,x=s*h,y=o*d,v=o*h,b=l*h,S=c*u,N=c*d,T=c*h,k=r.x,C=r.y,E=r.z;return i[0]=(1-(y+b))*k,i[1]=(m+T)*k,i[2]=(x-N)*k,i[3]=0,i[4]=(m-T)*C,i[5]=(1-(p+b))*C,i[6]=(v+S)*C,i[7]=0,i[8]=(x+N)*E,i[9]=(v-S)*E,i[10]=(1-(p+y))*E,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=Up.set(i[0],i[1],i[2]).length();const o=Up.set(i[4],i[5],i[6]).length(),l=Up.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],El.copy(this);const u=1/s,d=1/o,h=1/l;return El.elements[0]*=u,El.elements[1]*=u,El.elements[2]*=u,El.elements[4]*=d,El.elements[5]*=d,El.elements[6]*=d,El.elements[8]*=h,El.elements[9]*=h,El.elements[10]*=h,n.setFromRotationMatrix(El),r.x=s,r.y=o,r.z=l,this}makePerspective(e,n,r,i,s,o,l=dc){const c=this.elements,u=2*s/(n-e),d=2*s/(r-i),h=(n+e)/(n-e),p=(r+i)/(r-i);let m,x;if(l===dc)m=-(o+s)/(o-s),x=-2*o*s/(o-s);else if(l===ry)m=-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]=h,c[12]=0,c[1]=0,c[5]=d,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=m,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,n,r,i,s,o,l=dc){const c=this.elements,u=1/(n-e),d=1/(r-i),h=1/(o-s),p=(n+e)*u,m=(r+i)*d;let x,y;if(l===dc)x=(o+s)*h,y=-2*h;else if(l===ry)x=s*h,y=-1*h;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-p,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-m,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 Up=new We,El=new zr,swe=new We(0,0,0),owe=new We(1,1,1),Pd=new We,h_=new We,oo=new We,V8=new zr,G8=new mm;class By{constructor(e=0,n=0,r=0,i=By.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],h=i[2],p=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(Ia(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(p,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Ia(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-h,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ia(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-h,m),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Ia(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Ia(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-h,s)):(this._x=0,this._y=Math.atan2(l,m));break;case"XZY":this._z=Math.asin(-Ia(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,u),this._y=Math.atan2(l,s)):(this._x=Math.atan2(-d,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return V8.makeRotationFromQuaternion(e),this.setFromRotationMatrix(V8,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return G8.setFromEuler(this),this.setFromQuaternion(G8,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}}By.DEFAULT_ORDER="XYZ";class XK{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 lwe=0;const q8=new We,zp=new mm,ru=new zr,f_=new We,$b=new We,cwe=new We,uwe=new mm,W8=new We(1,0,0),K8=new We(0,1,0),X8=new We(0,0,1),dwe={type:"added"},hwe={type:"removed"};class ys extends Am{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:lwe++}),this.uuid=Cu(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ys.DEFAULT_UP.clone();const e=new We,n=new By,r=new mm,i=new We(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 zr},normalMatrix:{value:new In}}),this.matrix=new zr,this.matrixWorld=new zr,this.matrixAutoUpdate=ys.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ys.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new XK,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 zp.setFromAxisAngle(e,n),this.quaternion.multiply(zp),this}rotateOnWorldAxis(e,n){return zp.setFromAxisAngle(e,n),this.quaternion.premultiply(zp),this}rotateX(e){return this.rotateOnAxis(W8,e)}rotateY(e){return this.rotateOnAxis(K8,e)}rotateZ(e){return this.rotateOnAxis(X8,e)}translateOnAxis(e,n){return q8.copy(e).applyQuaternion(this.quaternion),this.position.add(q8.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(W8,e)}translateY(e){return this.translateOnAxis(K8,e)}translateZ(e){return this.translateOnAxis(X8,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(ru.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?f_.copy(e):f_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),$b.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ru.lookAt($b,f_,this.up):ru.lookAt(f_,$b,this.up),this.quaternion.setFromRotationMatrix(ru),i&&(ru.extractRotation(i.matrixWorld),zp.setFromRotationMatrix(ru),this.quaternion.premultiply(zp.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(dwe)):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(hwe)),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),ru.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),ru.multiply(e.parent.matrixWorld)),e.applyMatrix4(ru),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($b,e,cwe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose($b,uwe,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 h=c[u];s(e.shapes,h)}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),h=o(e.shapes),p=o(e.skeletons),m=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),h.length>0&&(r.shapes=h),p.length>0&&(r.skeletons=p),m.length>0&&(r.animations=m),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}}ys.DEFAULT_UP=new We(0,1,0);ys.DEFAULT_MATRIX_AUTO_UPDATE=!0;ys.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Tl=new We,iu=new We,eA=new We,au=new We,Bp=new We,Hp=new We,Y8=new We,tA=new We,nA=new We,rA=new We;let m_=!1;class Al{constructor(e=new We,n=new We,r=new We){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Tl.subVectors(e,n),i.cross(Tl);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){Tl.subVectors(i,n),iu.subVectors(r,n),eA.subVectors(e,n);const o=Tl.dot(Tl),l=Tl.dot(iu),c=Tl.dot(eA),u=iu.dot(iu),d=iu.dot(eA),h=o*u-l*l;if(h===0)return s.set(-2,-1,-1);const p=1/h,m=(u*c-l*d)*p,x=(o*d-l*c)*p;return s.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,au),au.x>=0&&au.y>=0&&au.x+au.y<=1}static getUV(e,n,r,i,s,o,l,c){return m_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),m_=!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,au),c.setScalar(0),c.addScaledVector(s,au.x),c.addScaledVector(o,au.y),c.addScaledVector(l,au.z),c}static isFrontFacing(e,n,r,i){return Tl.subVectors(r,n),iu.subVectors(e,n),Tl.cross(iu).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 Tl.subVectors(this.c,this.b),iu.subVectors(this.a,this.b),Tl.cross(iu).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Al.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return Al.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,s){return m_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),m_=!0),Al.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}getInterpolation(e,n,r,i,s){return Al.getInterpolation(e,this.a,this.b,this.c,n,r,i,s)}containsPoint(e){return Al.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Al.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;Bp.subVectors(i,r),Hp.subVectors(s,r),tA.subVectors(e,r);const c=Bp.dot(tA),u=Hp.dot(tA);if(c<=0&&u<=0)return n.copy(r);nA.subVectors(e,i);const d=Bp.dot(nA),h=Hp.dot(nA);if(d>=0&&h<=d)return n.copy(i);const p=c*h-d*u;if(p<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Bp,o);rA.subVectors(e,s);const m=Bp.dot(rA),x=Hp.dot(rA);if(x>=0&&m<=x)return n.copy(s);const y=m*u-c*x;if(y<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Hp,l);const v=d*x-m*h;if(v<=0&&h-d>=0&&m-x>=0)return Y8.subVectors(s,i),l=(h-d)/(h-d+(m-x)),n.copy(i).addScaledVector(Y8,l);const b=1/(v+y+p);return o=y*b,l=p*b,n.copy(r).addScaledVector(Bp,o).addScaledVector(Hp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const YK={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},Dd={h:0,s:0,l:0},p_={h:0,s:0,l:0};function iA(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=Fa){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Er.toWorkingColorSpace(this,n),this}setRGB(e,n,r,i=Er.workingColorSpace){return this.r=e,this.g=n,this.b=r,Er.toWorkingColorSpace(this,i),this}setHSL(e,n,r,i=Er.workingColorSpace){if(e=sO(e,1),n=Ia(n,0,1),r=Ia(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=iA(o,s,e+1/3),this.g=iA(o,s,e),this.b=iA(o,s,e-1/3)}return Er.toWorkingColorSpace(this,i),this}setStyle(e,n=Fa){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=Fa){const r=YK[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=jg(e.r),this.g=jg(e.g),this.b=jg(e.b),this}copyLinearToSRGB(e){return this.r=qT(e.r),this.g=qT(e.g),this.b=qT(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Fa){return Er.fromWorkingColorSpace(Wa.copy(this),e),Math.round(Ia(Wa.r*255,0,255))*65536+Math.round(Ia(Wa.g*255,0,255))*256+Math.round(Ia(Wa.b*255,0,255))}getHexString(e=Fa){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Er.workingColorSpace){Er.fromWorkingColorSpace(Wa.copy(this),n);const r=Wa.r,i=Wa.g,s=Wa.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 h=o-l;switch(u=d<=.5?h/(o+l):h/(2-o-l),o){case r:c=(i-s)/h+(i<s?6:0);break;case i:c=(s-r)/h+2;break;case s:c=(r-i)/h+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=Er.workingColorSpace){return Er.fromWorkingColorSpace(Wa.copy(this),n),e.r=Wa.r,e.g=Wa.g,e.b=Wa.b,e}getStyle(e=Fa){Er.fromWorkingColorSpace(Wa.copy(this),e);const n=Wa.r,r=Wa.g,i=Wa.b;return e!==Fa?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(Dd),this.setHSL(Dd.h+e,Dd.s+n,Dd.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(Dd),e.getHSL(p_);const r=_0(Dd.h,p_.h,n),i=_0(Dd.s,p_.s,n),s=_0(Dd.l,p_.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 Wa=new Jt;Jt.NAMES=YK;let fwe=0;class Nx extends Am{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:fwe++}),this.uuid=Cu(),this.name="",this.type="Material",this.blending=Cg,this.side=Mh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=d3,this.blendDst=h3,this.blendEquation=Tf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Jt(0,0,0),this.blendAlpha=0,this.depthFunc=nS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=F8,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Rp,this.stencilZFail=Rp,this.stencilZPass=Rp,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!==Cg&&(r.blending=this.blending),this.side!==Mh&&(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!==d3&&(r.blendSrc=this.blendSrc),this.blendDst!==h3&&(r.blendDst=this.blendDst),this.blendEquation!==Tf&&(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!==nS&&(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!==F8&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Rp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Rp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Rp&&(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 QK extends Nx{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=rO,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 Li=new We,g_=new bn;class yo{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=x3,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=_u,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++)g_.fromBufferAttribute(this,n),g_.applyMatrix3(e),this.setXY(n,g_.x,g_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)Li.fromBufferAttribute(this,n),Li.applyMatrix3(e),this.setXYZ(n,Li.x,Li.y,Li.z);return this}applyMatrix4(e){for(let n=0,r=this.count;n<r;n++)Li.fromBufferAttribute(this,n),Li.applyMatrix4(e),this.setXYZ(n,Li.x,Li.y,Li.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)Li.fromBufferAttribute(this,n),Li.applyNormalMatrix(e),this.setXYZ(n,Li.x,Li.y,Li.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)Li.fromBufferAttribute(this,n),Li.transformDirection(e),this.setXYZ(n,Li.x,Li.y,Li.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=oc(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=kr(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=oc(n,this.array)),n}setX(e,n){return this.normalized&&(n=kr(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=oc(n,this.array)),n}setY(e,n){return this.normalized&&(n=kr(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=oc(n,this.array)),n}setZ(e,n){return this.normalized&&(n=kr(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=oc(n,this.array)),n}setW(e,n){return this.normalized&&(n=kr(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=kr(n,this.array),r=kr(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=kr(n,this.array),r=kr(r,this.array),i=kr(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=kr(n,this.array),r=kr(r,this.array),i=kr(i,this.array),s=kr(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!==x3&&(e.usage=this.usage),e}}class ZK extends yo{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class JK extends yo{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Ai extends yo{constructor(e,n,r){super(new Float32Array(e),n,r)}}let mwe=0;const zo=new zr,aA=new ys,$p=new We,lo=new sl,Vb=new sl,pa=new We;class ns extends Am{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:mwe++}),this.uuid=Cu(),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(GK(e)?JK:ZK)(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 In().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 zo.makeRotationFromQuaternion(e),this.applyMatrix4(zo),this}rotateX(e){return zo.makeRotationX(e),this.applyMatrix4(zo),this}rotateY(e){return zo.makeRotationY(e),this.applyMatrix4(zo),this}rotateZ(e){return zo.makeRotationZ(e),this.applyMatrix4(zo),this}translate(e,n,r){return zo.makeTranslation(e,n,r),this.applyMatrix4(zo),this}scale(e,n,r){return zo.makeScale(e,n,r),this.applyMatrix4(zo),this}lookAt(e){return aA.lookAt(e),aA.updateMatrix(),this.applyMatrix4(aA.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter($p).negate(),this.translate($p.x,$p.y,$p.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 Ai(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new sl);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 We(-1/0,-1/0,-1/0),new We(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const s=n[r];lo.setFromBufferAttribute(s),this.morphTargetsRelative?(pa.addVectors(this.boundingBox.min,lo.min),this.boundingBox.expandByPoint(pa),pa.addVectors(this.boundingBox.max,lo.max),this.boundingBox.expandByPoint(pa)):(this.boundingBox.expandByPoint(lo.min),this.boundingBox.expandByPoint(lo.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 mc);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 We,1/0);return}if(e){const r=this.boundingSphere.center;if(lo.setFromBufferAttribute(e),n)for(let s=0,o=n.length;s<o;s++){const l=n[s];Vb.setFromBufferAttribute(l),this.morphTargetsRelative?(pa.addVectors(lo.min,Vb.min),lo.expandByPoint(pa),pa.addVectors(lo.max,Vb.max),lo.expandByPoint(pa)):(lo.expandByPoint(Vb.min),lo.expandByPoint(Vb.max))}lo.getCenter(r);let i=0;for(let s=0,o=e.count;s<o;s++)pa.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(pa));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++)pa.fromBufferAttribute(l,u),c&&($p.fromBufferAttribute(e,u),pa.add($p)),i=Math.max(i,r.distanceToSquared(pa))}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 yo(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let D=0;D<l;D++)u[D]=new We,d[D]=new We;const h=new We,p=new We,m=new We,x=new bn,y=new bn,v=new bn,b=new We,S=new We;function N(D,I,L){h.fromArray(i,D*3),p.fromArray(i,I*3),m.fromArray(i,L*3),x.fromArray(o,D*2),y.fromArray(o,I*2),v.fromArray(o,L*2),p.sub(h),m.sub(h),y.sub(x),v.sub(x);const U=1/(y.x*v.y-v.x*y.y);isFinite(U)&&(b.copy(p).multiplyScalar(v.y).addScaledVector(m,-y.y).multiplyScalar(U),S.copy(m).multiplyScalar(y.x).addScaledVector(p,-v.x).multiplyScalar(U),u[D].add(b),u[I].add(b),u[L].add(b),d[D].add(S),d[I].add(S),d[L].add(S))}let T=this.groups;T.length===0&&(T=[{start:0,count:r.length}]);for(let D=0,I=T.length;D<I;++D){const L=T[D],U=L.start,j=L.count;for(let V=U,K=U+j;V<K;V+=3)N(r[V+0],r[V+1],r[V+2])}const k=new We,C=new We,E=new We,P=new We;function A(D){E.fromArray(s,D*3),P.copy(E);const I=u[D];k.copy(I),k.sub(E.multiplyScalar(E.dot(I))).normalize(),C.crossVectors(P,I);const U=C.dot(d[D])<0?-1:1;c[D*4]=k.x,c[D*4+1]=k.y,c[D*4+2]=k.z,c[D*4+3]=U}for(let D=0,I=T.length;D<I;++D){const L=T[D],U=L.start,j=L.count;for(let V=U,K=U+j;V<K;V+=3)A(r[V+0]),A(r[V+1]),A(r[V+2])}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let r=this.getAttribute("normal");if(r===void 0)r=new yo(new Float32Array(n.count*3),3),this.setAttribute("normal",r);else for(let p=0,m=r.count;p<m;p++)r.setXYZ(p,0,0,0);const i=new We,s=new We,o=new We,l=new We,c=new We,u=new We,d=new We,h=new We;if(e)for(let p=0,m=e.count;p<m;p+=3){const x=e.getX(p+0),y=e.getX(p+1),v=e.getX(p+2);i.fromBufferAttribute(n,x),s.fromBufferAttribute(n,y),o.fromBufferAttribute(n,v),d.subVectors(o,s),h.subVectors(i,s),d.cross(h),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,y),u.fromBufferAttribute(r,v),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(v,u.x,u.y,u.z)}else for(let p=0,m=n.count;p<m;p+=3)i.fromBufferAttribute(n,p+0),s.fromBufferAttribute(n,p+1),o.fromBufferAttribute(n,p+2),d.subVectors(o,s),h.subVectors(i,s),d.cross(h),r.setXYZ(p+0,d.x,d.y,d.z),r.setXYZ(p+1,d.x,d.y,d.z),r.setXYZ(p+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++)pa.fromBufferAttribute(e,n),pa.normalize(),e.setXYZ(n,pa.x,pa.y,pa.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,h=l.normalized,p=new u.constructor(c.length*d);let m=0,x=0;for(let y=0,v=c.length;y<v;y++){l.isInterleavedBufferAttribute?m=c[y]*l.data.stride+l.offset:m=c[y]*d;for(let b=0;b<d;b++)p[x++]=u[m++]}return new yo(p,d,h)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new ns,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,h=u.length;d<h;d++){const p=u[d],m=e(p,r);c.push(m)}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 h=0,p=u.length;h<p;h++){const m=u[h];d.push(m.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=[],h=s[u];for(let p=0,m=h.length;p<m;p++)d.push(h[p].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 h=o[u];this.addGroup(h.start,h.count,h.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 Q8=new zr,xf=new oO,x_=new mc,Z8=new We,Vp=new We,Gp=new We,qp=new We,sA=new We,b_=new We,y_=new bn,v_=new bn,w_=new bn,J8=new We,e6=new We,t6=new We,__=new We,S_=new We;class Ll extends ys{constructor(e=new ns,n=new QK){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){b_.set(0,0,0);for(let c=0,u=s.length;c<u;c++){const d=l[c],h=s[c];d!==0&&(sA.fromBufferAttribute(h,e),o?b_.addScaledVector(sA,d):b_.addScaledVector(sA.sub(n),d))}n.add(b_)}return n}raycast(e,n){const r=this.geometry,i=this.material,s=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),x_.copy(r.boundingSphere),x_.applyMatrix4(s),xf.copy(e.ray).recast(e.near),!(x_.containsPoint(xf.origin)===!1&&(xf.intersectSphere(x_,Z8)===null||xf.origin.distanceToSquared(Z8)>(e.far-e.near)**2))&&(Q8.copy(s).invert(),xf.copy(e.ray).applyMatrix4(Q8),!(r.boundingBox!==null&&xf.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,xf)))}_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,h=s.attributes.normal,p=s.groups,m=s.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,y=p.length;x<y;x++){const v=p[x],b=o[v.materialIndex],S=Math.max(v.start,m.start),N=Math.min(l.count,Math.min(v.start+v.count,m.start+m.count));for(let T=S,k=N;T<k;T+=3){const C=l.getX(T),E=l.getX(T+1),P=l.getX(T+2);i=N_(this,b,e,r,u,d,h,C,E,P),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),y=Math.min(l.count,m.start+m.count);for(let v=x,b=y;v<b;v+=3){const S=l.getX(v),N=l.getX(v+1),T=l.getX(v+2);i=N_(this,o,e,r,u,d,h,S,N,T),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,y=p.length;x<y;x++){const v=p[x],b=o[v.materialIndex],S=Math.max(v.start,m.start),N=Math.min(c.count,Math.min(v.start+v.count,m.start+m.count));for(let T=S,k=N;T<k;T+=3){const C=T,E=T+1,P=T+2;i=N_(this,b,e,r,u,d,h,C,E,P),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),y=Math.min(c.count,m.start+m.count);for(let v=x,b=y;v<b;v+=3){const S=v,N=v+1,T=v+2;i=N_(this,o,e,r,u,d,h,S,N,T),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}}function pwe(t,e,n,r,i,s,o,l){let c;if(e.side===Hs?c=r.intersectTriangle(o,s,i,!0,l):c=r.intersectTriangle(i,s,o,e.side===Mh,l),c===null)return null;S_.copy(l),S_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(S_);return u<n.near||u>n.far?null:{distance:u,point:S_.clone(),object:t}}function N_(t,e,n,r,i,s,o,l,c,u){t.getVertexPosition(l,Vp),t.getVertexPosition(c,Gp),t.getVertexPosition(u,qp);const d=pwe(t,e,n,r,Vp,Gp,qp,__);if(d){i&&(y_.fromBufferAttribute(i,l),v_.fromBufferAttribute(i,c),w_.fromBufferAttribute(i,u),d.uv=Al.getInterpolation(__,Vp,Gp,qp,y_,v_,w_,new bn)),s&&(y_.fromBufferAttribute(s,l),v_.fromBufferAttribute(s,c),w_.fromBufferAttribute(s,u),d.uv1=Al.getInterpolation(__,Vp,Gp,qp,y_,v_,w_,new bn),d.uv2=d.uv1),o&&(J8.fromBufferAttribute(o,l),e6.fromBufferAttribute(o,c),t6.fromBufferAttribute(o,u),d.normal=Al.getInterpolation(__,Vp,Gp,qp,J8,e6,t6,new We),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const h={a:l,b:c,c:u,normal:new We,materialIndex:0};Al.getNormal(Vp,Gp,qp,h.normal),d.face=h}return d}class Hy extends ns{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=[],h=[];let p=0,m=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 Ai(u,3)),this.setAttribute("normal",new Ai(d,3)),this.setAttribute("uv",new Ai(h,2));function x(y,v,b,S,N,T,k,C,E,P,A){const D=T/E,I=k/P,L=T/2,U=k/2,j=C/2,V=E+1,K=P+1;let z=0,X=0;const Y=new We;for(let te=0;te<K;te++){const $=te*I-U;for(let W=0;W<V;W++){const ne=W*D-L;Y[y]=ne*S,Y[v]=$*N,Y[b]=j,u.push(Y.x,Y.y,Y.z),Y[y]=0,Y[v]=0,Y[b]=C>0?1:-1,d.push(Y.x,Y.y,Y.z),h.push(W/E),h.push(1-te/P),z+=1}}for(let te=0;te<P;te++)for(let $=0;$<E;$++){const W=p+$+V*te,ne=p+$+V*(te+1),re=p+($+1)+V*(te+1),ge=p+($+1)+V*te;c.push(W,ne,ge),c.push(ne,re,ge),X+=6}l.addGroup(m,X,A),m+=X,p+=z}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Hy(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Jg(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 ds(t){const e={};for(let n=0;n<t.length;n++){const r=Jg(t[n]);for(const i in r)e[i]=r[i]}return e}function gwe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function eX(t){return t.getRenderTarget()===null?t.outputColorSpace:Er.workingColorSpace}const lO={clone:Jg,merge:ds};var xwe=`void main() {
  3840. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  3841. }`,bwe=`void main() {
  3842. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  3843. }`;class kh extends Nx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=xwe,this.fragmentShader=bwe,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=Jg(e.uniforms),this.uniformsGroups=gwe(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 tX extends ys{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new zr,this.projectionMatrix=new zr,this.projectionMatrixInverse=new zr,this.coordinateSystem=dc}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 ho extends tX{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=iy*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(w0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return iy*2*Math.atan(Math.tan(w0*.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(w0*.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,Kp=1;class ywe extends ys{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new ho(Wp,Kp,e,n);i.layers=this.layers,this.add(i);const s=new ho(Wp,Kp,e,n);s.layers=this.layers,this.add(s);const o=new ho(Wp,Kp,e,n);o.layers=this.layers,this.add(o);const l=new ho(Wp,Kp,e,n);l.layers=this.layers,this.add(l);const c=new ho(Wp,Kp,e,n);c.layers=this.layers,this.add(c);const u=new ho(Wp,Kp,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===dc)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===ry)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,h=e.getRenderTarget(),p=e.getActiveCubeFace(),m=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(h,p,m),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class nX extends $s{constructor(e,n,r,i,s,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:Yg,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 vwe extends fm{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&&(S0("THREE.WebGLCubeRenderTarget: option.encoding has been replaced by option.colorSpace."),n.colorSpace=n.encoding===Gf?Fa:el),this.texture=new nX(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:Zo}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
  3844. varying vec3 vWorldDirection;
  3845. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  3846. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  3847. }
  3848. void main() {
  3849. vWorldDirection = transformDirection( position, modelMatrix );
  3850. #include <begin_vertex>
  3851. #include <project_vertex>
  3852. }
  3853. `,fragmentShader:`
  3854. uniform sampler2D tEquirect;
  3855. varying vec3 vWorldDirection;
  3856. #include <common>
  3857. void main() {
  3858. vec3 direction = normalize( vWorldDirection );
  3859. vec2 sampleUV = equirectUv( direction );
  3860. gl_FragColor = texture2D( tEquirect, sampleUV );
  3861. }
  3862. `},i=new Hy(5,5,5),s=new kh({name:"CubemapFromEquirect",uniforms:Jg(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Hs,blending:uh});s.uniforms.tEquirect.value=n;const o=new Ll(i,s),l=n.minFilter;return n.minFilter===ty&&(n.minFilter=Zo),new ywe(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 oA=new We,wwe=new We,_we=new In;class Bd{constructor(e=new We(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=oA.subVectors(r,n).cross(wwe.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(oA),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||_we.getNormalMatrix(e),i=this.coplanarPoint(oA).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 bf=new mc,M_=new We;class TM{constructor(e=new Bd,n=new Bd,r=new Bd,i=new Bd,s=new Bd,o=new Bd){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=dc){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],h=i[6],p=i[7],m=i[8],x=i[9],y=i[10],v=i[11],b=i[12],S=i[13],N=i[14],T=i[15];if(r[0].setComponents(c-s,p-u,v-m,T-b).normalize(),r[1].setComponents(c+s,p+u,v+m,T+b).normalize(),r[2].setComponents(c+o,p+d,v+x,T+S).normalize(),r[3].setComponents(c-o,p-d,v-x,T-S).normalize(),r[4].setComponents(c-l,p-h,v-y,T-N).normalize(),n===dc)r[5].setComponents(c+l,p+h,v+y,T+N).normalize();else if(n===ry)r[5].setComponents(l,h,y,N).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(),bf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),bf.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(bf)}intersectsSprite(e){return bf.center.set(0,0,0),bf.radius=.7071067811865476,bf.applyMatrix4(e.matrixWorld),this.intersectsSphere(bf)}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(M_.x=i.normal.x>0?e.max.x:e.min.x,M_.y=i.normal.y>0?e.max.y:e.min.y,M_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(M_)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let r=0;r<6;r++)if(n[r].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function rX(){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 Swe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const h=u.array,p=u.usage,m=h.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,h,p),u.onUploadCallback();let y;if(h instanceof Float32Array)y=t.FLOAT;else if(h 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(h instanceof Int16Array)y=t.SHORT;else if(h instanceof Uint32Array)y=t.UNSIGNED_INT;else if(h instanceof Int32Array)y=t.INT;else if(h instanceof Int8Array)y=t.BYTE;else if(h instanceof Uint8Array)y=t.UNSIGNED_BYTE;else if(h instanceof Uint8ClampedArray)y=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+h);return{buffer:x,type:y,bytesPerElement:h.BYTES_PER_ELEMENT,version:u.version,size:m}}function s(u,d,h){const p=d.array,m=d._updateRange,x=d.updateRanges;if(t.bindBuffer(h,u),m.count===-1&&x.length===0&&t.bufferSubData(h,0,p),x.length!==0){for(let y=0,v=x.length;y<v;y++){const b=x[y];n?t.bufferSubData(h,b.start*p.BYTES_PER_ELEMENT,p,b.start,b.count):t.bufferSubData(h,b.start*p.BYTES_PER_ELEMENT,p.subarray(b.start,b.start+b.count))}d.clearUpdateRanges()}m.count!==-1&&(n?t.bufferSubData(h,m.offset*p.BYTES_PER_ELEMENT,p,m.offset,m.count):t.bufferSubData(h,m.offset*p.BYTES_PER_ELEMENT,p.subarray(m.offset,m.offset+m.count)),m.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 p=r.get(u);(!p||p.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 h=r.get(u);if(h===void 0)r.set(u,i(u,d));else if(h.version<u.version){if(h.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(h.buffer,u,d),h.version=u.version}}return{get:o,remove:l,update:c}}class cO extends ns{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,h=e/l,p=n/c,m=[],x=[],y=[],v=[];for(let b=0;b<d;b++){const S=b*p-o;for(let N=0;N<u;N++){const T=N*h-s;x.push(T,-S,0),y.push(0,0,1),v.push(N/l),v.push(1-b/c)}}for(let b=0;b<c;b++)for(let S=0;S<l;S++){const N=S+u*b,T=S+u*(b+1),k=S+1+u*(b+1),C=S+1+u*b;m.push(N,T,C),m.push(T,k,C)}this.setIndex(m),this.setAttribute("position",new Ai(x,3)),this.setAttribute("normal",new Ai(y,3)),this.setAttribute("uv",new Ai(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new cO(e.width,e.height,e.widthSegments,e.heightSegments)}}var Nwe=`#ifdef USE_ALPHAHASH
  3863. if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
  3864. #endif`,Mwe=`#ifdef USE_ALPHAHASH
  3865. const float ALPHA_HASH_SCALE = 0.05;
  3866. float hash2D( vec2 value ) {
  3867. return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
  3868. }
  3869. float hash3D( vec3 value ) {
  3870. return hash2D( vec2( hash2D( value.xy ), value.z ) );
  3871. }
  3872. float getAlphaHashThreshold( vec3 position ) {
  3873. float maxDeriv = max(
  3874. length( dFdx( position.xyz ) ),
  3875. length( dFdy( position.xyz ) )
  3876. );
  3877. float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
  3878. vec2 pixScales = vec2(
  3879. exp2( floor( log2( pixScale ) ) ),
  3880. exp2( ceil( log2( pixScale ) ) )
  3881. );
  3882. vec2 alpha = vec2(
  3883. hash3D( floor( pixScales.x * position.xyz ) ),
  3884. hash3D( floor( pixScales.y * position.xyz ) )
  3885. );
  3886. float lerpFactor = fract( log2( pixScale ) );
  3887. float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
  3888. float a = min( lerpFactor, 1.0 - lerpFactor );
  3889. vec3 cases = vec3(
  3890. x * x / ( 2.0 * a * ( 1.0 - a ) ),
  3891. ( x - 0.5 * a ) / ( 1.0 - a ),
  3892. 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
  3893. );
  3894. float threshold = ( x < ( 1.0 - a ) )
  3895. ? ( ( x < a ) ? cases.x : cases.y )
  3896. : cases.z;
  3897. return clamp( threshold , 1.0e-6, 1.0 );
  3898. }
  3899. #endif`,kwe=`#ifdef USE_ALPHAMAP
  3900. diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
  3901. #endif`,Ewe=`#ifdef USE_ALPHAMAP
  3902. uniform sampler2D alphaMap;
  3903. #endif`,Twe=`#ifdef USE_ALPHATEST
  3904. if ( diffuseColor.a < alphaTest ) discard;
  3905. #endif`,Awe=`#ifdef USE_ALPHATEST
  3906. uniform float alphaTest;
  3907. #endif`,Cwe=`#ifdef USE_AOMAP
  3908. float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
  3909. reflectedLight.indirectDiffuse *= ambientOcclusion;
  3910. #if defined( USE_CLEARCOAT )
  3911. clearcoatSpecularIndirect *= ambientOcclusion;
  3912. #endif
  3913. #if defined( USE_SHEEN )
  3914. sheenSpecularIndirect *= ambientOcclusion;
  3915. #endif
  3916. #if defined( USE_ENVMAP ) && defined( STANDARD )
  3917. float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
  3918. reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
  3919. #endif
  3920. #endif`,jwe=`#ifdef USE_AOMAP
  3921. uniform sampler2D aoMap;
  3922. uniform float aoMapIntensity;
  3923. #endif`,Pwe=`#ifdef USE_BATCHING
  3924. attribute float batchId;
  3925. uniform highp sampler2D batchingTexture;
  3926. mat4 getBatchingMatrix( const in float i ) {
  3927. int size = textureSize( batchingTexture, 0 ).x;
  3928. int j = int( i ) * 4;
  3929. int x = j % size;
  3930. int y = j / size;
  3931. vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
  3932. vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
  3933. vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
  3934. vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
  3935. return mat4( v1, v2, v3, v4 );
  3936. }
  3937. #endif`,Dwe=`#ifdef USE_BATCHING
  3938. mat4 batchingMatrix = getBatchingMatrix( batchId );
  3939. #endif`,Rwe=`vec3 transformed = vec3( position );
  3940. #ifdef USE_ALPHAHASH
  3941. vPosition = vec3( position );
  3942. #endif`,Owe=`vec3 objectNormal = vec3( normal );
  3943. #ifdef USE_TANGENT
  3944. vec3 objectTangent = vec3( tangent.xyz );
  3945. #endif`,Lwe=`float G_BlinnPhong_Implicit( ) {
  3946. return 0.25;
  3947. }
  3948. float D_BlinnPhong( const in float shininess, const in float dotNH ) {
  3949. return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
  3950. }
  3951. vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
  3952. vec3 halfDir = normalize( lightDir + viewDir );
  3953. float dotNH = saturate( dot( normal, halfDir ) );
  3954. float dotVH = saturate( dot( viewDir, halfDir ) );
  3955. vec3 F = F_Schlick( specularColor, 1.0, dotVH );
  3956. float G = G_BlinnPhong_Implicit( );
  3957. float D = D_BlinnPhong( shininess, dotNH );
  3958. return F * ( G * D );
  3959. } // validated`,Fwe=`#ifdef USE_IRIDESCENCE
  3960. const mat3 XYZ_TO_REC709 = mat3(
  3961. 3.2404542, -0.9692660, 0.0556434,
  3962. -1.5371385, 1.8760108, -0.2040259,
  3963. -0.4985314, 0.0415560, 1.0572252
  3964. );
  3965. vec3 Fresnel0ToIor( vec3 fresnel0 ) {
  3966. vec3 sqrtF0 = sqrt( fresnel0 );
  3967. return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
  3968. }
  3969. vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
  3970. return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
  3971. }
  3972. float IorToFresnel0( float transmittedIor, float incidentIor ) {
  3973. return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
  3974. }
  3975. vec3 evalSensitivity( float OPD, vec3 shift ) {
  3976. float phase = 2.0 * PI * OPD * 1.0e-9;
  3977. vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
  3978. vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
  3979. vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
  3980. vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
  3981. xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
  3982. xyz /= 1.0685e-7;
  3983. vec3 rgb = XYZ_TO_REC709 * xyz;
  3984. return rgb;
  3985. }
  3986. vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
  3987. vec3 I;
  3988. float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
  3989. float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
  3990. float cosTheta2Sq = 1.0 - sinTheta2Sq;
  3991. if ( cosTheta2Sq < 0.0 ) {
  3992. return vec3( 1.0 );
  3993. }
  3994. float cosTheta2 = sqrt( cosTheta2Sq );
  3995. float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
  3996. float R12 = F_Schlick( R0, 1.0, cosTheta1 );
  3997. float T121 = 1.0 - R12;
  3998. float phi12 = 0.0;
  3999. if ( iridescenceIOR < outsideIOR ) phi12 = PI;
  4000. float phi21 = PI - phi12;
  4001. vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
  4002. vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
  4003. vec3 phi23 = vec3( 0.0 );
  4004. if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
  4005. if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
  4006. if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
  4007. float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
  4008. vec3 phi = vec3( phi21 ) + phi23;
  4009. vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
  4010. vec3 r123 = sqrt( R123 );
  4011. vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
  4012. vec3 C0 = R12 + Rs;
  4013. I = C0;
  4014. vec3 Cm = Rs - T121;
  4015. for ( int m = 1; m <= 2; ++ m ) {
  4016. Cm *= r123;
  4017. vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
  4018. I += Cm * Sm;
  4019. }
  4020. return max( I, vec3( 0.0 ) );
  4021. }
  4022. #endif`,Iwe=`#ifdef USE_BUMPMAP
  4023. uniform sampler2D bumpMap;
  4024. uniform float bumpScale;
  4025. vec2 dHdxy_fwd() {
  4026. vec2 dSTdx = dFdx( vBumpMapUv );
  4027. vec2 dSTdy = dFdy( vBumpMapUv );
  4028. float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
  4029. float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
  4030. float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
  4031. return vec2( dBx, dBy );
  4032. }
  4033. vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
  4034. vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
  4035. vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
  4036. vec3 vN = surf_norm;
  4037. vec3 R1 = cross( vSigmaY, vN );
  4038. vec3 R2 = cross( vN, vSigmaX );
  4039. float fDet = dot( vSigmaX, R1 ) * faceDirection;
  4040. vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
  4041. return normalize( abs( fDet ) * surf_norm - vGrad );
  4042. }
  4043. #endif`,Uwe=`#if NUM_CLIPPING_PLANES > 0
  4044. vec4 plane;
  4045. #pragma unroll_loop_start
  4046. for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
  4047. plane = clippingPlanes[ i ];
  4048. if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
  4049. }
  4050. #pragma unroll_loop_end
  4051. #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
  4052. bool clipped = true;
  4053. #pragma unroll_loop_start
  4054. for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
  4055. plane = clippingPlanes[ i ];
  4056. clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
  4057. }
  4058. #pragma unroll_loop_end
  4059. if ( clipped ) discard;
  4060. #endif
  4061. #endif`,zwe=`#if NUM_CLIPPING_PLANES > 0
  4062. varying vec3 vClipPosition;
  4063. uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
  4064. #endif`,Bwe=`#if NUM_CLIPPING_PLANES > 0
  4065. varying vec3 vClipPosition;
  4066. #endif`,Hwe=`#if NUM_CLIPPING_PLANES > 0
  4067. vClipPosition = - mvPosition.xyz;
  4068. #endif`,$we=`#if defined( USE_COLOR_ALPHA )
  4069. diffuseColor *= vColor;
  4070. #elif defined( USE_COLOR )
  4071. diffuseColor.rgb *= vColor;
  4072. #endif`,Vwe=`#if defined( USE_COLOR_ALPHA )
  4073. varying vec4 vColor;
  4074. #elif defined( USE_COLOR )
  4075. varying vec3 vColor;
  4076. #endif`,Gwe=`#if defined( USE_COLOR_ALPHA )
  4077. varying vec4 vColor;
  4078. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4079. varying vec3 vColor;
  4080. #endif`,qwe=`#if defined( USE_COLOR_ALPHA )
  4081. vColor = vec4( 1.0 );
  4082. #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
  4083. vColor = vec3( 1.0 );
  4084. #endif
  4085. #ifdef USE_COLOR
  4086. vColor *= color;
  4087. #endif
  4088. #ifdef USE_INSTANCING_COLOR
  4089. vColor.xyz *= instanceColor.xyz;
  4090. #endif`,Wwe=`#define PI 3.141592653589793
  4091. #define PI2 6.283185307179586
  4092. #define PI_HALF 1.5707963267948966
  4093. #define RECIPROCAL_PI 0.3183098861837907
  4094. #define RECIPROCAL_PI2 0.15915494309189535
  4095. #define EPSILON 1e-6
  4096. #ifndef saturate
  4097. #define saturate( a ) clamp( a, 0.0, 1.0 )
  4098. #endif
  4099. #define whiteComplement( a ) ( 1.0 - saturate( a ) )
  4100. float pow2( const in float x ) { return x*x; }
  4101. vec3 pow2( const in vec3 x ) { return x*x; }
  4102. float pow3( const in float x ) { return x*x*x; }
  4103. float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
  4104. float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
  4105. float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
  4106. highp float rand( const in vec2 uv ) {
  4107. const highp float a = 12.9898, b = 78.233, c = 43758.5453;
  4108. highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
  4109. return fract( sin( sn ) * c );
  4110. }
  4111. #ifdef HIGH_PRECISION
  4112. float precisionSafeLength( vec3 v ) { return length( v ); }
  4113. #else
  4114. float precisionSafeLength( vec3 v ) {
  4115. float maxComponent = max3( abs( v ) );
  4116. return length( v / maxComponent ) * maxComponent;
  4117. }
  4118. #endif
  4119. struct IncidentLight {
  4120. vec3 color;
  4121. vec3 direction;
  4122. bool visible;
  4123. };
  4124. struct ReflectedLight {
  4125. vec3 directDiffuse;
  4126. vec3 directSpecular;
  4127. vec3 indirectDiffuse;
  4128. vec3 indirectSpecular;
  4129. };
  4130. #ifdef USE_ALPHAHASH
  4131. varying vec3 vPosition;
  4132. #endif
  4133. vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
  4134. return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
  4135. }
  4136. vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
  4137. return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
  4138. }
  4139. mat3 transposeMat3( const in mat3 m ) {
  4140. mat3 tmp;
  4141. tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
  4142. tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
  4143. tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
  4144. return tmp;
  4145. }
  4146. float luminance( const in vec3 rgb ) {
  4147. const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
  4148. return dot( weights, rgb );
  4149. }
  4150. bool isPerspectiveMatrix( mat4 m ) {
  4151. return m[ 2 ][ 3 ] == - 1.0;
  4152. }
  4153. vec2 equirectUv( in vec3 dir ) {
  4154. float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
  4155. float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
  4156. return vec2( u, v );
  4157. }
  4158. vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
  4159. return RECIPROCAL_PI * diffuseColor;
  4160. }
  4161. vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
  4162. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4163. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4164. }
  4165. float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
  4166. float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
  4167. return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
  4168. } // validated`,Kwe=`#ifdef ENVMAP_TYPE_CUBE_UV
  4169. #define cubeUV_minMipLevel 4.0
  4170. #define cubeUV_minTileSize 16.0
  4171. float getFace( vec3 direction ) {
  4172. vec3 absDirection = abs( direction );
  4173. float face = - 1.0;
  4174. if ( absDirection.x > absDirection.z ) {
  4175. if ( absDirection.x > absDirection.y )
  4176. face = direction.x > 0.0 ? 0.0 : 3.0;
  4177. else
  4178. face = direction.y > 0.0 ? 1.0 : 4.0;
  4179. } else {
  4180. if ( absDirection.z > absDirection.y )
  4181. face = direction.z > 0.0 ? 2.0 : 5.0;
  4182. else
  4183. face = direction.y > 0.0 ? 1.0 : 4.0;
  4184. }
  4185. return face;
  4186. }
  4187. vec2 getUV( vec3 direction, float face ) {
  4188. vec2 uv;
  4189. if ( face == 0.0 ) {
  4190. uv = vec2( direction.z, direction.y ) / abs( direction.x );
  4191. } else if ( face == 1.0 ) {
  4192. uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
  4193. } else if ( face == 2.0 ) {
  4194. uv = vec2( - direction.x, direction.y ) / abs( direction.z );
  4195. } else if ( face == 3.0 ) {
  4196. uv = vec2( - direction.z, direction.y ) / abs( direction.x );
  4197. } else if ( face == 4.0 ) {
  4198. uv = vec2( - direction.x, direction.z ) / abs( direction.y );
  4199. } else {
  4200. uv = vec2( direction.x, direction.y ) / abs( direction.z );
  4201. }
  4202. return 0.5 * ( uv + 1.0 );
  4203. }
  4204. vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
  4205. float face = getFace( direction );
  4206. float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
  4207. mipInt = max( mipInt, cubeUV_minMipLevel );
  4208. float faceSize = exp2( mipInt );
  4209. highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
  4210. if ( face > 2.0 ) {
  4211. uv.y += faceSize;
  4212. face -= 3.0;
  4213. }
  4214. uv.x += face * faceSize;
  4215. uv.x += filterInt * 3.0 * cubeUV_minTileSize;
  4216. uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
  4217. uv.x *= CUBEUV_TEXEL_WIDTH;
  4218. uv.y *= CUBEUV_TEXEL_HEIGHT;
  4219. #ifdef texture2DGradEXT
  4220. return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
  4221. #else
  4222. return texture2D( envMap, uv ).rgb;
  4223. #endif
  4224. }
  4225. #define cubeUV_r0 1.0
  4226. #define cubeUV_v0 0.339
  4227. #define cubeUV_m0 - 2.0
  4228. #define cubeUV_r1 0.8
  4229. #define cubeUV_v1 0.276
  4230. #define cubeUV_m1 - 1.0
  4231. #define cubeUV_r4 0.4
  4232. #define cubeUV_v4 0.046
  4233. #define cubeUV_m4 2.0
  4234. #define cubeUV_r5 0.305
  4235. #define cubeUV_v5 0.016
  4236. #define cubeUV_m5 3.0
  4237. #define cubeUV_r6 0.21
  4238. #define cubeUV_v6 0.0038
  4239. #define cubeUV_m6 4.0
  4240. float roughnessToMip( float roughness ) {
  4241. float mip = 0.0;
  4242. if ( roughness >= cubeUV_r1 ) {
  4243. mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
  4244. } else if ( roughness >= cubeUV_r4 ) {
  4245. mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
  4246. } else if ( roughness >= cubeUV_r5 ) {
  4247. mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
  4248. } else if ( roughness >= cubeUV_r6 ) {
  4249. mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
  4250. } else {
  4251. mip = - 2.0 * log2( 1.16 * roughness ); }
  4252. return mip;
  4253. }
  4254. vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
  4255. float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
  4256. float mipF = fract( mip );
  4257. float mipInt = floor( mip );
  4258. vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
  4259. if ( mipF == 0.0 ) {
  4260. return vec4( color0, 1.0 );
  4261. } else {
  4262. vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
  4263. return vec4( mix( color0, color1, mipF ), 1.0 );
  4264. }
  4265. }
  4266. #endif`,Xwe=`vec3 transformedNormal = objectNormal;
  4267. #ifdef USE_TANGENT
  4268. vec3 transformedTangent = objectTangent;
  4269. #endif
  4270. #ifdef USE_BATCHING
  4271. mat3 bm = mat3( batchingMatrix );
  4272. transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
  4273. transformedNormal = bm * transformedNormal;
  4274. #ifdef USE_TANGENT
  4275. transformedTangent = bm * transformedTangent;
  4276. #endif
  4277. #endif
  4278. #ifdef USE_INSTANCING
  4279. mat3 im = mat3( instanceMatrix );
  4280. transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
  4281. transformedNormal = im * transformedNormal;
  4282. #ifdef USE_TANGENT
  4283. transformedTangent = im * transformedTangent;
  4284. #endif
  4285. #endif
  4286. transformedNormal = normalMatrix * transformedNormal;
  4287. #ifdef FLIP_SIDED
  4288. transformedNormal = - transformedNormal;
  4289. #endif
  4290. #ifdef USE_TANGENT
  4291. transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
  4292. #ifdef FLIP_SIDED
  4293. transformedTangent = - transformedTangent;
  4294. #endif
  4295. #endif`,Ywe=`#ifdef USE_DISPLACEMENTMAP
  4296. uniform sampler2D displacementMap;
  4297. uniform float displacementScale;
  4298. uniform float displacementBias;
  4299. #endif`,Qwe=`#ifdef USE_DISPLACEMENTMAP
  4300. transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
  4301. #endif`,Zwe=`#ifdef USE_EMISSIVEMAP
  4302. vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
  4303. totalEmissiveRadiance *= emissiveColor.rgb;
  4304. #endif`,Jwe=`#ifdef USE_EMISSIVEMAP
  4305. uniform sampler2D emissiveMap;
  4306. #endif`,e_e="gl_FragColor = linearToOutputTexel( gl_FragColor );",t_e=`
  4307. const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
  4308. vec3( 0.8224621, 0.177538, 0.0 ),
  4309. vec3( 0.0331941, 0.9668058, 0.0 ),
  4310. vec3( 0.0170827, 0.0723974, 0.9105199 )
  4311. );
  4312. const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
  4313. vec3( 1.2249401, - 0.2249404, 0.0 ),
  4314. vec3( - 0.0420569, 1.0420571, 0.0 ),
  4315. vec3( - 0.0196376, - 0.0786361, 1.0982735 )
  4316. );
  4317. vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
  4318. return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
  4319. }
  4320. vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
  4321. return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
  4322. }
  4323. vec4 LinearTransferOETF( in vec4 value ) {
  4324. return value;
  4325. }
  4326. vec4 sRGBTransferOETF( in vec4 value ) {
  4327. return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
  4328. }
  4329. vec4 LinearToLinear( in vec4 value ) {
  4330. return value;
  4331. }
  4332. vec4 LinearTosRGB( in vec4 value ) {
  4333. return sRGBTransferOETF( value );
  4334. }`,n_e=`#ifdef USE_ENVMAP
  4335. #ifdef ENV_WORLDPOS
  4336. vec3 cameraToFrag;
  4337. if ( isOrthographic ) {
  4338. cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4339. } else {
  4340. cameraToFrag = normalize( vWorldPosition - cameraPosition );
  4341. }
  4342. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4343. #ifdef ENVMAP_MODE_REFLECTION
  4344. vec3 reflectVec = reflect( cameraToFrag, worldNormal );
  4345. #else
  4346. vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
  4347. #endif
  4348. #else
  4349. vec3 reflectVec = vReflect;
  4350. #endif
  4351. #ifdef ENVMAP_TYPE_CUBE
  4352. vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
  4353. #else
  4354. vec4 envColor = vec4( 0.0 );
  4355. #endif
  4356. #ifdef ENVMAP_BLENDING_MULTIPLY
  4357. outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
  4358. #elif defined( ENVMAP_BLENDING_MIX )
  4359. outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
  4360. #elif defined( ENVMAP_BLENDING_ADD )
  4361. outgoingLight += envColor.xyz * specularStrength * reflectivity;
  4362. #endif
  4363. #endif`,r_e=`#ifdef USE_ENVMAP
  4364. uniform float envMapIntensity;
  4365. uniform float flipEnvMap;
  4366. #ifdef ENVMAP_TYPE_CUBE
  4367. uniform samplerCube envMap;
  4368. #else
  4369. uniform sampler2D envMap;
  4370. #endif
  4371. #endif`,i_e=`#ifdef USE_ENVMAP
  4372. uniform float reflectivity;
  4373. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4374. #define ENV_WORLDPOS
  4375. #endif
  4376. #ifdef ENV_WORLDPOS
  4377. varying vec3 vWorldPosition;
  4378. uniform float refractionRatio;
  4379. #else
  4380. varying vec3 vReflect;
  4381. #endif
  4382. #endif`,a_e=`#ifdef USE_ENVMAP
  4383. #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
  4384. #define ENV_WORLDPOS
  4385. #endif
  4386. #ifdef ENV_WORLDPOS
  4387. varying vec3 vWorldPosition;
  4388. #else
  4389. varying vec3 vReflect;
  4390. uniform float refractionRatio;
  4391. #endif
  4392. #endif`,s_e=`#ifdef USE_ENVMAP
  4393. #ifdef ENV_WORLDPOS
  4394. vWorldPosition = worldPosition.xyz;
  4395. #else
  4396. vec3 cameraToVertex;
  4397. if ( isOrthographic ) {
  4398. cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
  4399. } else {
  4400. cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
  4401. }
  4402. vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  4403. #ifdef ENVMAP_MODE_REFLECTION
  4404. vReflect = reflect( cameraToVertex, worldNormal );
  4405. #else
  4406. vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
  4407. #endif
  4408. #endif
  4409. #endif`,o_e=`#ifdef USE_FOG
  4410. vFogDepth = - mvPosition.z;
  4411. #endif`,l_e=`#ifdef USE_FOG
  4412. varying float vFogDepth;
  4413. #endif`,c_e=`#ifdef USE_FOG
  4414. #ifdef FOG_EXP2
  4415. float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
  4416. #else
  4417. float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
  4418. #endif
  4419. gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
  4420. #endif`,u_e=`#ifdef USE_FOG
  4421. uniform vec3 fogColor;
  4422. varying float vFogDepth;
  4423. #ifdef FOG_EXP2
  4424. uniform float fogDensity;
  4425. #else
  4426. uniform float fogNear;
  4427. uniform float fogFar;
  4428. #endif
  4429. #endif`,d_e=`#ifdef USE_GRADIENTMAP
  4430. uniform sampler2D gradientMap;
  4431. #endif
  4432. vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
  4433. float dotNL = dot( normal, lightDirection );
  4434. vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
  4435. #ifdef USE_GRADIENTMAP
  4436. return vec3( texture2D( gradientMap, coord ).r );
  4437. #else
  4438. vec2 fw = fwidth( coord ) * 0.5;
  4439. return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
  4440. #endif
  4441. }`,h_e=`#ifdef USE_LIGHTMAP
  4442. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  4443. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  4444. reflectedLight.indirectDiffuse += lightMapIrradiance;
  4445. #endif`,f_e=`#ifdef USE_LIGHTMAP
  4446. uniform sampler2D lightMap;
  4447. uniform float lightMapIntensity;
  4448. #endif`,m_e=`LambertMaterial material;
  4449. material.diffuseColor = diffuseColor.rgb;
  4450. material.specularStrength = specularStrength;`,p_e=`varying vec3 vViewPosition;
  4451. struct LambertMaterial {
  4452. vec3 diffuseColor;
  4453. float specularStrength;
  4454. };
  4455. void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  4456. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4457. vec3 irradiance = dotNL * directLight.color;
  4458. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4459. }
  4460. void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
  4461. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4462. }
  4463. #define RE_Direct RE_Direct_Lambert
  4464. #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,g_e=`uniform bool receiveShadow;
  4465. uniform vec3 ambientLightColor;
  4466. #if defined( USE_LIGHT_PROBES )
  4467. uniform vec3 lightProbe[ 9 ];
  4468. #endif
  4469. vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
  4470. float x = normal.x, y = normal.y, z = normal.z;
  4471. vec3 result = shCoefficients[ 0 ] * 0.886227;
  4472. result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
  4473. result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
  4474. result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
  4475. result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
  4476. result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
  4477. result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
  4478. result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
  4479. result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
  4480. return result;
  4481. }
  4482. vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
  4483. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4484. vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
  4485. return irradiance;
  4486. }
  4487. vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
  4488. vec3 irradiance = ambientLightColor;
  4489. return irradiance;
  4490. }
  4491. float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
  4492. #if defined ( LEGACY_LIGHTS )
  4493. if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
  4494. return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
  4495. }
  4496. return 1.0;
  4497. #else
  4498. float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
  4499. if ( cutoffDistance > 0.0 ) {
  4500. distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
  4501. }
  4502. return distanceFalloff;
  4503. #endif
  4504. }
  4505. float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
  4506. return smoothstep( coneCosine, penumbraCosine, angleCosine );
  4507. }
  4508. #if NUM_DIR_LIGHTS > 0
  4509. struct DirectionalLight {
  4510. vec3 direction;
  4511. vec3 color;
  4512. };
  4513. uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
  4514. void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
  4515. light.color = directionalLight.color;
  4516. light.direction = directionalLight.direction;
  4517. light.visible = true;
  4518. }
  4519. #endif
  4520. #if NUM_POINT_LIGHTS > 0
  4521. struct PointLight {
  4522. vec3 position;
  4523. vec3 color;
  4524. float distance;
  4525. float decay;
  4526. };
  4527. uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
  4528. void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4529. vec3 lVector = pointLight.position - geometryPosition;
  4530. light.direction = normalize( lVector );
  4531. float lightDistance = length( lVector );
  4532. light.color = pointLight.color;
  4533. light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
  4534. light.visible = ( light.color != vec3( 0.0 ) );
  4535. }
  4536. #endif
  4537. #if NUM_SPOT_LIGHTS > 0
  4538. struct SpotLight {
  4539. vec3 position;
  4540. vec3 direction;
  4541. vec3 color;
  4542. float distance;
  4543. float decay;
  4544. float coneCos;
  4545. float penumbraCos;
  4546. };
  4547. uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
  4548. void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
  4549. vec3 lVector = spotLight.position - geometryPosition;
  4550. light.direction = normalize( lVector );
  4551. float angleCos = dot( light.direction, spotLight.direction );
  4552. float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
  4553. if ( spotAttenuation > 0.0 ) {
  4554. float lightDistance = length( lVector );
  4555. light.color = spotLight.color * spotAttenuation;
  4556. light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
  4557. light.visible = ( light.color != vec3( 0.0 ) );
  4558. } else {
  4559. light.color = vec3( 0.0 );
  4560. light.visible = false;
  4561. }
  4562. }
  4563. #endif
  4564. #if NUM_RECT_AREA_LIGHTS > 0
  4565. struct RectAreaLight {
  4566. vec3 color;
  4567. vec3 position;
  4568. vec3 halfWidth;
  4569. vec3 halfHeight;
  4570. };
  4571. uniform sampler2D ltc_1; uniform sampler2D ltc_2;
  4572. uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
  4573. #endif
  4574. #if NUM_HEMI_LIGHTS > 0
  4575. struct HemisphereLight {
  4576. vec3 direction;
  4577. vec3 skyColor;
  4578. vec3 groundColor;
  4579. };
  4580. uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
  4581. vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
  4582. float dotNL = dot( normal, hemiLight.direction );
  4583. float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
  4584. vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
  4585. return irradiance;
  4586. }
  4587. #endif`,x_e=`#ifdef USE_ENVMAP
  4588. vec3 getIBLIrradiance( const in vec3 normal ) {
  4589. #ifdef ENVMAP_TYPE_CUBE_UV
  4590. vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
  4591. vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
  4592. return PI * envMapColor.rgb * envMapIntensity;
  4593. #else
  4594. return vec3( 0.0 );
  4595. #endif
  4596. }
  4597. vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
  4598. #ifdef ENVMAP_TYPE_CUBE_UV
  4599. vec3 reflectVec = reflect( - viewDir, normal );
  4600. reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
  4601. reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
  4602. vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
  4603. return envMapColor.rgb * envMapIntensity;
  4604. #else
  4605. return vec3( 0.0 );
  4606. #endif
  4607. }
  4608. #ifdef USE_ANISOTROPY
  4609. vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
  4610. #ifdef ENVMAP_TYPE_CUBE_UV
  4611. vec3 bentNormal = cross( bitangent, viewDir );
  4612. bentNormal = normalize( cross( bentNormal, bitangent ) );
  4613. bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
  4614. return getIBLRadiance( viewDir, bentNormal, roughness );
  4615. #else
  4616. return vec3( 0.0 );
  4617. #endif
  4618. }
  4619. #endif
  4620. #endif`,b_e=`ToonMaterial material;
  4621. material.diffuseColor = diffuseColor.rgb;`,y_e=`varying vec3 vViewPosition;
  4622. struct ToonMaterial {
  4623. vec3 diffuseColor;
  4624. };
  4625. void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  4626. vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
  4627. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4628. }
  4629. void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
  4630. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4631. }
  4632. #define RE_Direct RE_Direct_Toon
  4633. #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,v_e=`BlinnPhongMaterial material;
  4634. material.diffuseColor = diffuseColor.rgb;
  4635. material.specularColor = specular;
  4636. material.specularShininess = shininess;
  4637. material.specularStrength = specularStrength;`,w_e=`varying vec3 vViewPosition;
  4638. struct BlinnPhongMaterial {
  4639. vec3 diffuseColor;
  4640. vec3 specularColor;
  4641. float specularShininess;
  4642. float specularStrength;
  4643. };
  4644. void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  4645. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4646. vec3 irradiance = dotNL * directLight.color;
  4647. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4648. reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
  4649. }
  4650. void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
  4651. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  4652. }
  4653. #define RE_Direct RE_Direct_BlinnPhong
  4654. #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,__e=`PhysicalMaterial material;
  4655. material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
  4656. vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
  4657. float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
  4658. material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
  4659. material.roughness = min( material.roughness, 1.0 );
  4660. #ifdef IOR
  4661. material.ior = ior;
  4662. #ifdef USE_SPECULAR
  4663. float specularIntensityFactor = specularIntensity;
  4664. vec3 specularColorFactor = specularColor;
  4665. #ifdef USE_SPECULAR_COLORMAP
  4666. specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
  4667. #endif
  4668. #ifdef USE_SPECULAR_INTENSITYMAP
  4669. specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
  4670. #endif
  4671. material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
  4672. #else
  4673. float specularIntensityFactor = 1.0;
  4674. vec3 specularColorFactor = vec3( 1.0 );
  4675. material.specularF90 = 1.0;
  4676. #endif
  4677. material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
  4678. #else
  4679. material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
  4680. material.specularF90 = 1.0;
  4681. #endif
  4682. #ifdef USE_CLEARCOAT
  4683. material.clearcoat = clearcoat;
  4684. material.clearcoatRoughness = clearcoatRoughness;
  4685. material.clearcoatF0 = vec3( 0.04 );
  4686. material.clearcoatF90 = 1.0;
  4687. #ifdef USE_CLEARCOATMAP
  4688. material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
  4689. #endif
  4690. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  4691. material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
  4692. #endif
  4693. material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
  4694. material.clearcoatRoughness += geometryRoughness;
  4695. material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
  4696. #endif
  4697. #ifdef USE_IRIDESCENCE
  4698. material.iridescence = iridescence;
  4699. material.iridescenceIOR = iridescenceIOR;
  4700. #ifdef USE_IRIDESCENCEMAP
  4701. material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
  4702. #endif
  4703. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  4704. material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
  4705. #else
  4706. material.iridescenceThickness = iridescenceThicknessMaximum;
  4707. #endif
  4708. #endif
  4709. #ifdef USE_SHEEN
  4710. material.sheenColor = sheenColor;
  4711. #ifdef USE_SHEEN_COLORMAP
  4712. material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
  4713. #endif
  4714. material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
  4715. #ifdef USE_SHEEN_ROUGHNESSMAP
  4716. material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
  4717. #endif
  4718. #endif
  4719. #ifdef USE_ANISOTROPY
  4720. #ifdef USE_ANISOTROPYMAP
  4721. mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
  4722. vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
  4723. vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
  4724. #else
  4725. vec2 anisotropyV = anisotropyVector;
  4726. #endif
  4727. material.anisotropy = length( anisotropyV );
  4728. if( material.anisotropy == 0.0 ) {
  4729. anisotropyV = vec2( 1.0, 0.0 );
  4730. } else {
  4731. anisotropyV /= material.anisotropy;
  4732. material.anisotropy = saturate( material.anisotropy );
  4733. }
  4734. material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
  4735. material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
  4736. material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
  4737. #endif`,S_e=`struct PhysicalMaterial {
  4738. vec3 diffuseColor;
  4739. float roughness;
  4740. vec3 specularColor;
  4741. float specularF90;
  4742. #ifdef USE_CLEARCOAT
  4743. float clearcoat;
  4744. float clearcoatRoughness;
  4745. vec3 clearcoatF0;
  4746. float clearcoatF90;
  4747. #endif
  4748. #ifdef USE_IRIDESCENCE
  4749. float iridescence;
  4750. float iridescenceIOR;
  4751. float iridescenceThickness;
  4752. vec3 iridescenceFresnel;
  4753. vec3 iridescenceF0;
  4754. #endif
  4755. #ifdef USE_SHEEN
  4756. vec3 sheenColor;
  4757. float sheenRoughness;
  4758. #endif
  4759. #ifdef IOR
  4760. float ior;
  4761. #endif
  4762. #ifdef USE_TRANSMISSION
  4763. float transmission;
  4764. float transmissionAlpha;
  4765. float thickness;
  4766. float attenuationDistance;
  4767. vec3 attenuationColor;
  4768. #endif
  4769. #ifdef USE_ANISOTROPY
  4770. float anisotropy;
  4771. float alphaT;
  4772. vec3 anisotropyT;
  4773. vec3 anisotropyB;
  4774. #endif
  4775. };
  4776. vec3 clearcoatSpecularDirect = vec3( 0.0 );
  4777. vec3 clearcoatSpecularIndirect = vec3( 0.0 );
  4778. vec3 sheenSpecularDirect = vec3( 0.0 );
  4779. vec3 sheenSpecularIndirect = vec3(0.0 );
  4780. vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
  4781. float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
  4782. float x2 = x * x;
  4783. float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
  4784. return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
  4785. }
  4786. float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
  4787. float a2 = pow2( alpha );
  4788. float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
  4789. float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
  4790. return 0.5 / max( gv + gl, EPSILON );
  4791. }
  4792. float D_GGX( const in float alpha, const in float dotNH ) {
  4793. float a2 = pow2( alpha );
  4794. float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
  4795. return RECIPROCAL_PI * a2 / pow2( denom );
  4796. }
  4797. #ifdef USE_ANISOTROPY
  4798. float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
  4799. float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
  4800. float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
  4801. float v = 0.5 / ( gv + gl );
  4802. return saturate(v);
  4803. }
  4804. float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
  4805. float a2 = alphaT * alphaB;
  4806. highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
  4807. highp float v2 = dot( v, v );
  4808. float w2 = a2 / v2;
  4809. return RECIPROCAL_PI * a2 * pow2 ( w2 );
  4810. }
  4811. #endif
  4812. #ifdef USE_CLEARCOAT
  4813. vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
  4814. vec3 f0 = material.clearcoatF0;
  4815. float f90 = material.clearcoatF90;
  4816. float roughness = material.clearcoatRoughness;
  4817. float alpha = pow2( roughness );
  4818. vec3 halfDir = normalize( lightDir + viewDir );
  4819. float dotNL = saturate( dot( normal, lightDir ) );
  4820. float dotNV = saturate( dot( normal, viewDir ) );
  4821. float dotNH = saturate( dot( normal, halfDir ) );
  4822. float dotVH = saturate( dot( viewDir, halfDir ) );
  4823. vec3 F = F_Schlick( f0, f90, dotVH );
  4824. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4825. float D = D_GGX( alpha, dotNH );
  4826. return F * ( V * D );
  4827. }
  4828. #endif
  4829. vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
  4830. vec3 f0 = material.specularColor;
  4831. float f90 = material.specularF90;
  4832. float roughness = material.roughness;
  4833. float alpha = pow2( roughness );
  4834. vec3 halfDir = normalize( lightDir + viewDir );
  4835. float dotNL = saturate( dot( normal, lightDir ) );
  4836. float dotNV = saturate( dot( normal, viewDir ) );
  4837. float dotNH = saturate( dot( normal, halfDir ) );
  4838. float dotVH = saturate( dot( viewDir, halfDir ) );
  4839. vec3 F = F_Schlick( f0, f90, dotVH );
  4840. #ifdef USE_IRIDESCENCE
  4841. F = mix( F, material.iridescenceFresnel, material.iridescence );
  4842. #endif
  4843. #ifdef USE_ANISOTROPY
  4844. float dotTL = dot( material.anisotropyT, lightDir );
  4845. float dotTV = dot( material.anisotropyT, viewDir );
  4846. float dotTH = dot( material.anisotropyT, halfDir );
  4847. float dotBL = dot( material.anisotropyB, lightDir );
  4848. float dotBV = dot( material.anisotropyB, viewDir );
  4849. float dotBH = dot( material.anisotropyB, halfDir );
  4850. float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
  4851. float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
  4852. #else
  4853. float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
  4854. float D = D_GGX( alpha, dotNH );
  4855. #endif
  4856. return F * ( V * D );
  4857. }
  4858. vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
  4859. const float LUT_SIZE = 64.0;
  4860. const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
  4861. const float LUT_BIAS = 0.5 / LUT_SIZE;
  4862. float dotNV = saturate( dot( N, V ) );
  4863. vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
  4864. uv = uv * LUT_SCALE + LUT_BIAS;
  4865. return uv;
  4866. }
  4867. float LTC_ClippedSphereFormFactor( const in vec3 f ) {
  4868. float l = length( f );
  4869. return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
  4870. }
  4871. vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
  4872. float x = dot( v1, v2 );
  4873. float y = abs( x );
  4874. float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
  4875. float b = 3.4175940 + ( 4.1616724 + y ) * y;
  4876. float v = a / b;
  4877. float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
  4878. return cross( v1, v2 ) * theta_sintheta;
  4879. }
  4880. vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
  4881. vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
  4882. vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
  4883. vec3 lightNormal = cross( v1, v2 );
  4884. if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
  4885. vec3 T1, T2;
  4886. T1 = normalize( V - N * dot( V, N ) );
  4887. T2 = - cross( N, T1 );
  4888. mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
  4889. vec3 coords[ 4 ];
  4890. coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
  4891. coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
  4892. coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
  4893. coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
  4894. coords[ 0 ] = normalize( coords[ 0 ] );
  4895. coords[ 1 ] = normalize( coords[ 1 ] );
  4896. coords[ 2 ] = normalize( coords[ 2 ] );
  4897. coords[ 3 ] = normalize( coords[ 3 ] );
  4898. vec3 vectorFormFactor = vec3( 0.0 );
  4899. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
  4900. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
  4901. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
  4902. vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
  4903. float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
  4904. return vec3( result );
  4905. }
  4906. #if defined( USE_SHEEN )
  4907. float D_Charlie( float roughness, float dotNH ) {
  4908. float alpha = pow2( roughness );
  4909. float invAlpha = 1.0 / alpha;
  4910. float cos2h = dotNH * dotNH;
  4911. float sin2h = max( 1.0 - cos2h, 0.0078125 );
  4912. return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
  4913. }
  4914. float V_Neubelt( float dotNV, float dotNL ) {
  4915. return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
  4916. }
  4917. vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
  4918. vec3 halfDir = normalize( lightDir + viewDir );
  4919. float dotNL = saturate( dot( normal, lightDir ) );
  4920. float dotNV = saturate( dot( normal, viewDir ) );
  4921. float dotNH = saturate( dot( normal, halfDir ) );
  4922. float D = D_Charlie( sheenRoughness, dotNH );
  4923. float V = V_Neubelt( dotNV, dotNL );
  4924. return sheenColor * ( D * V );
  4925. }
  4926. #endif
  4927. float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  4928. float dotNV = saturate( dot( normal, viewDir ) );
  4929. float r2 = roughness * roughness;
  4930. float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
  4931. float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
  4932. float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
  4933. return saturate( DG * RECIPROCAL_PI );
  4934. }
  4935. vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
  4936. float dotNV = saturate( dot( normal, viewDir ) );
  4937. const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
  4938. const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
  4939. vec4 r = roughness * c0 + c1;
  4940. float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
  4941. vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
  4942. return fab;
  4943. }
  4944. vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
  4945. vec2 fab = DFGApprox( normal, viewDir, roughness );
  4946. return specularColor * fab.x + specularF90 * fab.y;
  4947. }
  4948. #ifdef USE_IRIDESCENCE
  4949. void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  4950. #else
  4951. void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
  4952. #endif
  4953. vec2 fab = DFGApprox( normal, viewDir, roughness );
  4954. #ifdef USE_IRIDESCENCE
  4955. vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
  4956. #else
  4957. vec3 Fr = specularColor;
  4958. #endif
  4959. vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
  4960. float Ess = fab.x + fab.y;
  4961. float Ems = 1.0 - Ess;
  4962. vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
  4963. singleScatter += FssEss;
  4964. multiScatter += Fms * Ems;
  4965. }
  4966. #if NUM_RECT_AREA_LIGHTS > 0
  4967. void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  4968. vec3 normal = geometryNormal;
  4969. vec3 viewDir = geometryViewDir;
  4970. vec3 position = geometryPosition;
  4971. vec3 lightPos = rectAreaLight.position;
  4972. vec3 halfWidth = rectAreaLight.halfWidth;
  4973. vec3 halfHeight = rectAreaLight.halfHeight;
  4974. vec3 lightColor = rectAreaLight.color;
  4975. float roughness = material.roughness;
  4976. vec3 rectCoords[ 4 ];
  4977. rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
  4978. rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
  4979. rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
  4980. vec2 uv = LTC_Uv( normal, viewDir, roughness );
  4981. vec4 t1 = texture2D( ltc_1, uv );
  4982. vec4 t2 = texture2D( ltc_2, uv );
  4983. mat3 mInv = mat3(
  4984. vec3( t1.x, 0, t1.y ),
  4985. vec3( 0, 1, 0 ),
  4986. vec3( t1.z, 0, t1.w )
  4987. );
  4988. vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
  4989. reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
  4990. reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
  4991. }
  4992. #endif
  4993. void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  4994. float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
  4995. vec3 irradiance = dotNL * directLight.color;
  4996. #ifdef USE_CLEARCOAT
  4997. float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
  4998. vec3 ccIrradiance = dotNLcc * directLight.color;
  4999. clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
  5000. #endif
  5001. #ifdef USE_SHEEN
  5002. sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
  5003. #endif
  5004. reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
  5005. reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5006. }
  5007. void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
  5008. reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
  5009. }
  5010. void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
  5011. #ifdef USE_CLEARCOAT
  5012. clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
  5013. #endif
  5014. #ifdef USE_SHEEN
  5015. sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
  5016. #endif
  5017. vec3 singleScattering = vec3( 0.0 );
  5018. vec3 multiScattering = vec3( 0.0 );
  5019. vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
  5020. #ifdef USE_IRIDESCENCE
  5021. computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
  5022. #else
  5023. computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
  5024. #endif
  5025. vec3 totalScattering = singleScattering + multiScattering;
  5026. vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
  5027. reflectedLight.indirectSpecular += radiance * singleScattering;
  5028. reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
  5029. reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
  5030. }
  5031. #define RE_Direct RE_Direct_Physical
  5032. #define RE_Direct_RectArea RE_Direct_RectArea_Physical
  5033. #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
  5034. #define RE_IndirectSpecular RE_IndirectSpecular_Physical
  5035. float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
  5036. return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
  5037. }`,N_e=`
  5038. vec3 geometryPosition = - vViewPosition;
  5039. vec3 geometryNormal = normal;
  5040. vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
  5041. vec3 geometryClearcoatNormal = vec3( 0.0 );
  5042. #ifdef USE_CLEARCOAT
  5043. geometryClearcoatNormal = clearcoatNormal;
  5044. #endif
  5045. #ifdef USE_IRIDESCENCE
  5046. float dotNVi = saturate( dot( normal, geometryViewDir ) );
  5047. if ( material.iridescenceThickness == 0.0 ) {
  5048. material.iridescence = 0.0;
  5049. } else {
  5050. material.iridescence = saturate( material.iridescence );
  5051. }
  5052. if ( material.iridescence > 0.0 ) {
  5053. material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
  5054. material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
  5055. }
  5056. #endif
  5057. IncidentLight directLight;
  5058. #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
  5059. PointLight pointLight;
  5060. #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
  5061. PointLightShadow pointLightShadow;
  5062. #endif
  5063. #pragma unroll_loop_start
  5064. for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
  5065. pointLight = pointLights[ i ];
  5066. getPointLightInfo( pointLight, geometryPosition, directLight );
  5067. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
  5068. pointLightShadow = pointLightShadows[ i ];
  5069. directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
  5070. #endif
  5071. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5072. }
  5073. #pragma unroll_loop_end
  5074. #endif
  5075. #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
  5076. SpotLight spotLight;
  5077. vec4 spotColor;
  5078. vec3 spotLightCoord;
  5079. bool inSpotLightMap;
  5080. #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
  5081. SpotLightShadow spotLightShadow;
  5082. #endif
  5083. #pragma unroll_loop_start
  5084. for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
  5085. spotLight = spotLights[ i ];
  5086. getSpotLightInfo( spotLight, geometryPosition, directLight );
  5087. #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5088. #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
  5089. #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5090. #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
  5091. #else
  5092. #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
  5093. #endif
  5094. #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
  5095. spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
  5096. inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
  5097. spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
  5098. directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
  5099. #endif
  5100. #undef SPOT_LIGHT_MAP_INDEX
  5101. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5102. spotLightShadow = spotLightShadows[ i ];
  5103. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5104. #endif
  5105. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5106. }
  5107. #pragma unroll_loop_end
  5108. #endif
  5109. #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
  5110. DirectionalLight directionalLight;
  5111. #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
  5112. DirectionalLightShadow directionalLightShadow;
  5113. #endif
  5114. #pragma unroll_loop_start
  5115. for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
  5116. directionalLight = directionalLights[ i ];
  5117. getDirectionalLightInfo( directionalLight, directLight );
  5118. #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
  5119. directionalLightShadow = directionalLightShadows[ i ];
  5120. directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5121. #endif
  5122. RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5123. }
  5124. #pragma unroll_loop_end
  5125. #endif
  5126. #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
  5127. RectAreaLight rectAreaLight;
  5128. #pragma unroll_loop_start
  5129. for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
  5130. rectAreaLight = rectAreaLights[ i ];
  5131. RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5132. }
  5133. #pragma unroll_loop_end
  5134. #endif
  5135. #if defined( RE_IndirectDiffuse )
  5136. vec3 iblIrradiance = vec3( 0.0 );
  5137. vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
  5138. #if defined( USE_LIGHT_PROBES )
  5139. irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
  5140. #endif
  5141. #if ( NUM_HEMI_LIGHTS > 0 )
  5142. #pragma unroll_loop_start
  5143. for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
  5144. irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
  5145. }
  5146. #pragma unroll_loop_end
  5147. #endif
  5148. #endif
  5149. #if defined( RE_IndirectSpecular )
  5150. vec3 radiance = vec3( 0.0 );
  5151. vec3 clearcoatRadiance = vec3( 0.0 );
  5152. #endif`,M_e=`#if defined( RE_IndirectDiffuse )
  5153. #ifdef USE_LIGHTMAP
  5154. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  5155. vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
  5156. irradiance += lightMapIrradiance;
  5157. #endif
  5158. #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
  5159. iblIrradiance += getIBLIrradiance( geometryNormal );
  5160. #endif
  5161. #endif
  5162. #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
  5163. #ifdef USE_ANISOTROPY
  5164. radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
  5165. #else
  5166. radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
  5167. #endif
  5168. #ifdef USE_CLEARCOAT
  5169. clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
  5170. #endif
  5171. #endif`,k_e=`#if defined( RE_IndirectDiffuse )
  5172. RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5173. #endif
  5174. #if defined( RE_IndirectSpecular )
  5175. RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
  5176. #endif`,E_e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5177. gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
  5178. #endif`,T_e=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
  5179. uniform float logDepthBufFC;
  5180. varying float vFragDepth;
  5181. varying float vIsPerspective;
  5182. #endif`,A_e=`#ifdef USE_LOGDEPTHBUF
  5183. #ifdef USE_LOGDEPTHBUF_EXT
  5184. varying float vFragDepth;
  5185. varying float vIsPerspective;
  5186. #else
  5187. uniform float logDepthBufFC;
  5188. #endif
  5189. #endif`,C_e=`#ifdef USE_LOGDEPTHBUF
  5190. #ifdef USE_LOGDEPTHBUF_EXT
  5191. vFragDepth = 1.0 + gl_Position.w;
  5192. vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
  5193. #else
  5194. if ( isPerspectiveMatrix( projectionMatrix ) ) {
  5195. gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
  5196. gl_Position.z *= gl_Position.w;
  5197. }
  5198. #endif
  5199. #endif`,j_e=`#ifdef USE_MAP
  5200. vec4 sampledDiffuseColor = texture2D( map, vMapUv );
  5201. #ifdef DECODE_VIDEO_TEXTURE
  5202. sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
  5203. #endif
  5204. diffuseColor *= sampledDiffuseColor;
  5205. #endif`,P_e=`#ifdef USE_MAP
  5206. uniform sampler2D map;
  5207. #endif`,D_e=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5208. #if defined( USE_POINTS_UV )
  5209. vec2 uv = vUv;
  5210. #else
  5211. vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
  5212. #endif
  5213. #endif
  5214. #ifdef USE_MAP
  5215. diffuseColor *= texture2D( map, uv );
  5216. #endif
  5217. #ifdef USE_ALPHAMAP
  5218. diffuseColor.a *= texture2D( alphaMap, uv ).g;
  5219. #endif`,R_e=`#if defined( USE_POINTS_UV )
  5220. varying vec2 vUv;
  5221. #else
  5222. #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
  5223. uniform mat3 uvTransform;
  5224. #endif
  5225. #endif
  5226. #ifdef USE_MAP
  5227. uniform sampler2D map;
  5228. #endif
  5229. #ifdef USE_ALPHAMAP
  5230. uniform sampler2D alphaMap;
  5231. #endif`,O_e=`float metalnessFactor = metalness;
  5232. #ifdef USE_METALNESSMAP
  5233. vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
  5234. metalnessFactor *= texelMetalness.b;
  5235. #endif`,L_e=`#ifdef USE_METALNESSMAP
  5236. uniform sampler2D metalnessMap;
  5237. #endif`,F_e=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
  5238. vColor *= morphTargetBaseInfluence;
  5239. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5240. #if defined( USE_COLOR_ALPHA )
  5241. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
  5242. #elif defined( USE_COLOR )
  5243. if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
  5244. #endif
  5245. }
  5246. #endif`,I_e=`#ifdef USE_MORPHNORMALS
  5247. objectNormal *= morphTargetBaseInfluence;
  5248. #ifdef MORPHTARGETS_TEXTURE
  5249. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5250. if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
  5251. }
  5252. #else
  5253. objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
  5254. objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
  5255. objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
  5256. objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
  5257. #endif
  5258. #endif`,U_e=`#ifdef USE_MORPHTARGETS
  5259. uniform float morphTargetBaseInfluence;
  5260. #ifdef MORPHTARGETS_TEXTURE
  5261. uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
  5262. uniform sampler2DArray morphTargetsTexture;
  5263. uniform ivec2 morphTargetsTextureSize;
  5264. vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
  5265. int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
  5266. int y = texelIndex / morphTargetsTextureSize.x;
  5267. int x = texelIndex - y * morphTargetsTextureSize.x;
  5268. ivec3 morphUV = ivec3( x, y, morphTargetIndex );
  5269. return texelFetch( morphTargetsTexture, morphUV, 0 );
  5270. }
  5271. #else
  5272. #ifndef USE_MORPHNORMALS
  5273. uniform float morphTargetInfluences[ 8 ];
  5274. #else
  5275. uniform float morphTargetInfluences[ 4 ];
  5276. #endif
  5277. #endif
  5278. #endif`,z_e=`#ifdef USE_MORPHTARGETS
  5279. transformed *= morphTargetBaseInfluence;
  5280. #ifdef MORPHTARGETS_TEXTURE
  5281. for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
  5282. if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
  5283. }
  5284. #else
  5285. transformed += morphTarget0 * morphTargetInfluences[ 0 ];
  5286. transformed += morphTarget1 * morphTargetInfluences[ 1 ];
  5287. transformed += morphTarget2 * morphTargetInfluences[ 2 ];
  5288. transformed += morphTarget3 * morphTargetInfluences[ 3 ];
  5289. #ifndef USE_MORPHNORMALS
  5290. transformed += morphTarget4 * morphTargetInfluences[ 4 ];
  5291. transformed += morphTarget5 * morphTargetInfluences[ 5 ];
  5292. transformed += morphTarget6 * morphTargetInfluences[ 6 ];
  5293. transformed += morphTarget7 * morphTargetInfluences[ 7 ];
  5294. #endif
  5295. #endif
  5296. #endif`,B_e=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
  5297. #ifdef FLAT_SHADED
  5298. vec3 fdx = dFdx( vViewPosition );
  5299. vec3 fdy = dFdy( vViewPosition );
  5300. vec3 normal = normalize( cross( fdx, fdy ) );
  5301. #else
  5302. vec3 normal = normalize( vNormal );
  5303. #ifdef DOUBLE_SIDED
  5304. normal *= faceDirection;
  5305. #endif
  5306. #endif
  5307. #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
  5308. #ifdef USE_TANGENT
  5309. mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5310. #else
  5311. mat3 tbn = getTangentFrame( - vViewPosition, normal,
  5312. #if defined( USE_NORMALMAP )
  5313. vNormalMapUv
  5314. #elif defined( USE_CLEARCOAT_NORMALMAP )
  5315. vClearcoatNormalMapUv
  5316. #else
  5317. vUv
  5318. #endif
  5319. );
  5320. #endif
  5321. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5322. tbn[0] *= faceDirection;
  5323. tbn[1] *= faceDirection;
  5324. #endif
  5325. #endif
  5326. #ifdef USE_CLEARCOAT_NORMALMAP
  5327. #ifdef USE_TANGENT
  5328. mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
  5329. #else
  5330. mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
  5331. #endif
  5332. #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
  5333. tbn2[0] *= faceDirection;
  5334. tbn2[1] *= faceDirection;
  5335. #endif
  5336. #endif
  5337. vec3 nonPerturbedNormal = normal;`,H_e=`#ifdef USE_NORMALMAP_OBJECTSPACE
  5338. normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5339. #ifdef FLIP_SIDED
  5340. normal = - normal;
  5341. #endif
  5342. #ifdef DOUBLE_SIDED
  5343. normal = normal * faceDirection;
  5344. #endif
  5345. normal = normalize( normalMatrix * normal );
  5346. #elif defined( USE_NORMALMAP_TANGENTSPACE )
  5347. vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
  5348. mapN.xy *= normalScale;
  5349. normal = normalize( tbn * mapN );
  5350. #elif defined( USE_BUMPMAP )
  5351. normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
  5352. #endif`,$_e=`#ifndef FLAT_SHADED
  5353. varying vec3 vNormal;
  5354. #ifdef USE_TANGENT
  5355. varying vec3 vTangent;
  5356. varying vec3 vBitangent;
  5357. #endif
  5358. #endif`,V_e=`#ifndef FLAT_SHADED
  5359. varying vec3 vNormal;
  5360. #ifdef USE_TANGENT
  5361. varying vec3 vTangent;
  5362. varying vec3 vBitangent;
  5363. #endif
  5364. #endif`,G_e=`#ifndef FLAT_SHADED
  5365. vNormal = normalize( transformedNormal );
  5366. #ifdef USE_TANGENT
  5367. vTangent = normalize( transformedTangent );
  5368. vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
  5369. #endif
  5370. #endif`,q_e=`#ifdef USE_NORMALMAP
  5371. uniform sampler2D normalMap;
  5372. uniform vec2 normalScale;
  5373. #endif
  5374. #ifdef USE_NORMALMAP_OBJECTSPACE
  5375. uniform mat3 normalMatrix;
  5376. #endif
  5377. #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
  5378. mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
  5379. vec3 q0 = dFdx( eye_pos.xyz );
  5380. vec3 q1 = dFdy( eye_pos.xyz );
  5381. vec2 st0 = dFdx( uv.st );
  5382. vec2 st1 = dFdy( uv.st );
  5383. vec3 N = surf_norm;
  5384. vec3 q1perp = cross( q1, N );
  5385. vec3 q0perp = cross( N, q0 );
  5386. vec3 T = q1perp * st0.x + q0perp * st1.x;
  5387. vec3 B = q1perp * st0.y + q0perp * st1.y;
  5388. float det = max( dot( T, T ), dot( B, B ) );
  5389. float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
  5390. return mat3( T * scale, B * scale, N );
  5391. }
  5392. #endif`,W_e=`#ifdef USE_CLEARCOAT
  5393. vec3 clearcoatNormal = nonPerturbedNormal;
  5394. #endif`,K_e=`#ifdef USE_CLEARCOAT_NORMALMAP
  5395. vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
  5396. clearcoatMapN.xy *= clearcoatNormalScale;
  5397. clearcoatNormal = normalize( tbn2 * clearcoatMapN );
  5398. #endif`,X_e=`#ifdef USE_CLEARCOATMAP
  5399. uniform sampler2D clearcoatMap;
  5400. #endif
  5401. #ifdef USE_CLEARCOAT_NORMALMAP
  5402. uniform sampler2D clearcoatNormalMap;
  5403. uniform vec2 clearcoatNormalScale;
  5404. #endif
  5405. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  5406. uniform sampler2D clearcoatRoughnessMap;
  5407. #endif`,Y_e=`#ifdef USE_IRIDESCENCEMAP
  5408. uniform sampler2D iridescenceMap;
  5409. #endif
  5410. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  5411. uniform sampler2D iridescenceThicknessMap;
  5412. #endif`,Q_e=`#ifdef OPAQUE
  5413. diffuseColor.a = 1.0;
  5414. #endif
  5415. #ifdef USE_TRANSMISSION
  5416. diffuseColor.a *= material.transmissionAlpha;
  5417. #endif
  5418. gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Z_e=`vec3 packNormalToRGB( const in vec3 normal ) {
  5419. return normalize( normal ) * 0.5 + 0.5;
  5420. }
  5421. vec3 unpackRGBToNormal( const in vec3 rgb ) {
  5422. return 2.0 * rgb.xyz - 1.0;
  5423. }
  5424. const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
  5425. const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
  5426. const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
  5427. const float ShiftRight8 = 1. / 256.;
  5428. vec4 packDepthToRGBA( const in float v ) {
  5429. vec4 r = vec4( fract( v * PackFactors ), v );
  5430. r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
  5431. }
  5432. float unpackRGBAToDepth( const in vec4 v ) {
  5433. return dot( v, UnpackFactors );
  5434. }
  5435. vec2 packDepthToRG( in highp float v ) {
  5436. return packDepthToRGBA( v ).yx;
  5437. }
  5438. float unpackRGToDepth( const in highp vec2 v ) {
  5439. return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
  5440. }
  5441. vec4 pack2HalfToRGBA( vec2 v ) {
  5442. vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
  5443. return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
  5444. }
  5445. vec2 unpackRGBATo2Half( vec4 v ) {
  5446. return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
  5447. }
  5448. float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
  5449. return ( viewZ + near ) / ( near - far );
  5450. }
  5451. float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5452. return depth * ( near - far ) - near;
  5453. }
  5454. float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
  5455. return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
  5456. }
  5457. float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
  5458. return ( near * far ) / ( ( far - near ) * depth - far );
  5459. }`,J_e=`#ifdef PREMULTIPLIED_ALPHA
  5460. gl_FragColor.rgb *= gl_FragColor.a;
  5461. #endif`,e1e=`vec4 mvPosition = vec4( transformed, 1.0 );
  5462. #ifdef USE_BATCHING
  5463. mvPosition = batchingMatrix * mvPosition;
  5464. #endif
  5465. #ifdef USE_INSTANCING
  5466. mvPosition = instanceMatrix * mvPosition;
  5467. #endif
  5468. mvPosition = modelViewMatrix * mvPosition;
  5469. gl_Position = projectionMatrix * mvPosition;`,t1e=`#ifdef DITHERING
  5470. gl_FragColor.rgb = dithering( gl_FragColor.rgb );
  5471. #endif`,n1e=`#ifdef DITHERING
  5472. vec3 dithering( vec3 color ) {
  5473. float grid_position = rand( gl_FragCoord.xy );
  5474. vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
  5475. dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
  5476. return color + dither_shift_RGB;
  5477. }
  5478. #endif`,r1e=`float roughnessFactor = roughness;
  5479. #ifdef USE_ROUGHNESSMAP
  5480. vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
  5481. roughnessFactor *= texelRoughness.g;
  5482. #endif`,i1e=`#ifdef USE_ROUGHNESSMAP
  5483. uniform sampler2D roughnessMap;
  5484. #endif`,a1e=`#if NUM_SPOT_LIGHT_COORDS > 0
  5485. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5486. #endif
  5487. #if NUM_SPOT_LIGHT_MAPS > 0
  5488. uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
  5489. #endif
  5490. #ifdef USE_SHADOWMAP
  5491. #if NUM_DIR_LIGHT_SHADOWS > 0
  5492. uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
  5493. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5494. struct DirectionalLightShadow {
  5495. float shadowBias;
  5496. float shadowNormalBias;
  5497. float shadowRadius;
  5498. vec2 shadowMapSize;
  5499. };
  5500. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5501. #endif
  5502. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5503. uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
  5504. struct SpotLightShadow {
  5505. float shadowBias;
  5506. float shadowNormalBias;
  5507. float shadowRadius;
  5508. vec2 shadowMapSize;
  5509. };
  5510. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5511. #endif
  5512. #if NUM_POINT_LIGHT_SHADOWS > 0
  5513. uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
  5514. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5515. struct PointLightShadow {
  5516. float shadowBias;
  5517. float shadowNormalBias;
  5518. float shadowRadius;
  5519. vec2 shadowMapSize;
  5520. float shadowCameraNear;
  5521. float shadowCameraFar;
  5522. };
  5523. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5524. #endif
  5525. float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
  5526. return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
  5527. }
  5528. vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
  5529. return unpackRGBATo2Half( texture2D( shadow, uv ) );
  5530. }
  5531. float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
  5532. float occlusion = 1.0;
  5533. vec2 distribution = texture2DDistribution( shadow, uv );
  5534. float hard_shadow = step( compare , distribution.x );
  5535. if (hard_shadow != 1.0 ) {
  5536. float distance = compare - distribution.x ;
  5537. float variance = max( 0.00000, distribution.y * distribution.y );
  5538. float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
  5539. }
  5540. return occlusion;
  5541. }
  5542. float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
  5543. float shadow = 1.0;
  5544. shadowCoord.xyz /= shadowCoord.w;
  5545. shadowCoord.z += shadowBias;
  5546. bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
  5547. bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
  5548. if ( frustumTest ) {
  5549. #if defined( SHADOWMAP_TYPE_PCF )
  5550. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5551. float dx0 = - texelSize.x * shadowRadius;
  5552. float dy0 = - texelSize.y * shadowRadius;
  5553. float dx1 = + texelSize.x * shadowRadius;
  5554. float dy1 = + texelSize.y * shadowRadius;
  5555. float dx2 = dx0 / 2.0;
  5556. float dy2 = dy0 / 2.0;
  5557. float dx3 = dx1 / 2.0;
  5558. float dy3 = dy1 / 2.0;
  5559. shadow = (
  5560. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
  5561. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
  5562. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
  5563. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
  5564. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
  5565. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
  5566. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
  5567. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
  5568. texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
  5569. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
  5570. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
  5571. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
  5572. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
  5573. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
  5574. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
  5575. texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
  5576. texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
  5577. ) * ( 1.0 / 17.0 );
  5578. #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
  5579. vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
  5580. float dx = texelSize.x;
  5581. float dy = texelSize.y;
  5582. vec2 uv = shadowCoord.xy;
  5583. vec2 f = fract( uv * shadowMapSize + 0.5 );
  5584. uv -= f * texelSize;
  5585. shadow = (
  5586. texture2DCompare( shadowMap, uv, shadowCoord.z ) +
  5587. texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
  5588. texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
  5589. texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
  5590. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
  5591. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
  5592. f.x ) +
  5593. mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
  5594. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
  5595. f.x ) +
  5596. mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
  5597. texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
  5598. f.y ) +
  5599. mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
  5600. texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
  5601. f.y ) +
  5602. mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
  5603. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
  5604. f.x ),
  5605. mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
  5606. texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
  5607. f.x ),
  5608. f.y )
  5609. ) * ( 1.0 / 9.0 );
  5610. #elif defined( SHADOWMAP_TYPE_VSM )
  5611. shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
  5612. #else
  5613. shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
  5614. #endif
  5615. }
  5616. return shadow;
  5617. }
  5618. vec2 cubeToUV( vec3 v, float texelSizeY ) {
  5619. vec3 absV = abs( v );
  5620. float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
  5621. absV *= scaleToCube;
  5622. v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
  5623. vec2 planar = v.xy;
  5624. float almostATexel = 1.5 * texelSizeY;
  5625. float almostOne = 1.0 - almostATexel;
  5626. if ( absV.z >= almostOne ) {
  5627. if ( v.z > 0.0 )
  5628. planar.x = 4.0 - v.x;
  5629. } else if ( absV.x >= almostOne ) {
  5630. float signX = sign( v.x );
  5631. planar.x = v.z * signX + 2.0 * signX;
  5632. } else if ( absV.y >= almostOne ) {
  5633. float signY = sign( v.y );
  5634. planar.x = v.x + 2.0 * signY + 2.0;
  5635. planar.y = v.z * signY - 2.0;
  5636. }
  5637. return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
  5638. }
  5639. float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
  5640. vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
  5641. vec3 lightToPosition = shadowCoord.xyz;
  5642. float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
  5643. vec3 bd3D = normalize( lightToPosition );
  5644. #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
  5645. vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
  5646. return (
  5647. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
  5648. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
  5649. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
  5650. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
  5651. texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
  5652. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
  5653. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
  5654. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
  5655. texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
  5656. ) * ( 1.0 / 9.0 );
  5657. #else
  5658. return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
  5659. #endif
  5660. }
  5661. #endif`,s1e=`#if NUM_SPOT_LIGHT_COORDS > 0
  5662. uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
  5663. varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
  5664. #endif
  5665. #ifdef USE_SHADOWMAP
  5666. #if NUM_DIR_LIGHT_SHADOWS > 0
  5667. uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
  5668. varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
  5669. struct DirectionalLightShadow {
  5670. float shadowBias;
  5671. float shadowNormalBias;
  5672. float shadowRadius;
  5673. vec2 shadowMapSize;
  5674. };
  5675. uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
  5676. #endif
  5677. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5678. struct SpotLightShadow {
  5679. float shadowBias;
  5680. float shadowNormalBias;
  5681. float shadowRadius;
  5682. vec2 shadowMapSize;
  5683. };
  5684. uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
  5685. #endif
  5686. #if NUM_POINT_LIGHT_SHADOWS > 0
  5687. uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
  5688. varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
  5689. struct PointLightShadow {
  5690. float shadowBias;
  5691. float shadowNormalBias;
  5692. float shadowRadius;
  5693. vec2 shadowMapSize;
  5694. float shadowCameraNear;
  5695. float shadowCameraFar;
  5696. };
  5697. uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
  5698. #endif
  5699. #endif`,o1e=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
  5700. vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
  5701. vec4 shadowWorldPosition;
  5702. #endif
  5703. #if defined( USE_SHADOWMAP )
  5704. #if NUM_DIR_LIGHT_SHADOWS > 0
  5705. #pragma unroll_loop_start
  5706. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5707. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
  5708. vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
  5709. }
  5710. #pragma unroll_loop_end
  5711. #endif
  5712. #if NUM_POINT_LIGHT_SHADOWS > 0
  5713. #pragma unroll_loop_start
  5714. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5715. shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
  5716. vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
  5717. }
  5718. #pragma unroll_loop_end
  5719. #endif
  5720. #endif
  5721. #if NUM_SPOT_LIGHT_COORDS > 0
  5722. #pragma unroll_loop_start
  5723. for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
  5724. shadowWorldPosition = worldPosition;
  5725. #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
  5726. shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
  5727. #endif
  5728. vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
  5729. }
  5730. #pragma unroll_loop_end
  5731. #endif`,l1e=`float getShadowMask() {
  5732. float shadow = 1.0;
  5733. #ifdef USE_SHADOWMAP
  5734. #if NUM_DIR_LIGHT_SHADOWS > 0
  5735. DirectionalLightShadow directionalLight;
  5736. #pragma unroll_loop_start
  5737. for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
  5738. directionalLight = directionalLightShadows[ i ];
  5739. shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
  5740. }
  5741. #pragma unroll_loop_end
  5742. #endif
  5743. #if NUM_SPOT_LIGHT_SHADOWS > 0
  5744. SpotLightShadow spotLight;
  5745. #pragma unroll_loop_start
  5746. for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
  5747. spotLight = spotLightShadows[ i ];
  5748. shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
  5749. }
  5750. #pragma unroll_loop_end
  5751. #endif
  5752. #if NUM_POINT_LIGHT_SHADOWS > 0
  5753. PointLightShadow pointLight;
  5754. #pragma unroll_loop_start
  5755. for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
  5756. pointLight = pointLightShadows[ i ];
  5757. shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
  5758. }
  5759. #pragma unroll_loop_end
  5760. #endif
  5761. #endif
  5762. return shadow;
  5763. }`,c1e=`#ifdef USE_SKINNING
  5764. mat4 boneMatX = getBoneMatrix( skinIndex.x );
  5765. mat4 boneMatY = getBoneMatrix( skinIndex.y );
  5766. mat4 boneMatZ = getBoneMatrix( skinIndex.z );
  5767. mat4 boneMatW = getBoneMatrix( skinIndex.w );
  5768. #endif`,u1e=`#ifdef USE_SKINNING
  5769. uniform mat4 bindMatrix;
  5770. uniform mat4 bindMatrixInverse;
  5771. uniform highp sampler2D boneTexture;
  5772. mat4 getBoneMatrix( const in float i ) {
  5773. int size = textureSize( boneTexture, 0 ).x;
  5774. int j = int( i ) * 4;
  5775. int x = j % size;
  5776. int y = j / size;
  5777. vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
  5778. vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
  5779. vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
  5780. vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
  5781. return mat4( v1, v2, v3, v4 );
  5782. }
  5783. #endif`,d1e=`#ifdef USE_SKINNING
  5784. vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
  5785. vec4 skinned = vec4( 0.0 );
  5786. skinned += boneMatX * skinVertex * skinWeight.x;
  5787. skinned += boneMatY * skinVertex * skinWeight.y;
  5788. skinned += boneMatZ * skinVertex * skinWeight.z;
  5789. skinned += boneMatW * skinVertex * skinWeight.w;
  5790. transformed = ( bindMatrixInverse * skinned ).xyz;
  5791. #endif`,h1e=`#ifdef USE_SKINNING
  5792. mat4 skinMatrix = mat4( 0.0 );
  5793. skinMatrix += skinWeight.x * boneMatX;
  5794. skinMatrix += skinWeight.y * boneMatY;
  5795. skinMatrix += skinWeight.z * boneMatZ;
  5796. skinMatrix += skinWeight.w * boneMatW;
  5797. skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
  5798. objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
  5799. #ifdef USE_TANGENT
  5800. objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
  5801. #endif
  5802. #endif`,f1e=`float specularStrength;
  5803. #ifdef USE_SPECULARMAP
  5804. vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
  5805. specularStrength = texelSpecular.r;
  5806. #else
  5807. specularStrength = 1.0;
  5808. #endif`,m1e=`#ifdef USE_SPECULARMAP
  5809. uniform sampler2D specularMap;
  5810. #endif`,p1e=`#if defined( TONE_MAPPING )
  5811. gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
  5812. #endif`,g1e=`#ifndef saturate
  5813. #define saturate( a ) clamp( a, 0.0, 1.0 )
  5814. #endif
  5815. uniform float toneMappingExposure;
  5816. vec3 LinearToneMapping( vec3 color ) {
  5817. return saturate( toneMappingExposure * color );
  5818. }
  5819. vec3 ReinhardToneMapping( vec3 color ) {
  5820. color *= toneMappingExposure;
  5821. return saturate( color / ( vec3( 1.0 ) + color ) );
  5822. }
  5823. vec3 OptimizedCineonToneMapping( vec3 color ) {
  5824. color *= toneMappingExposure;
  5825. color = max( vec3( 0.0 ), color - 0.004 );
  5826. return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
  5827. }
  5828. vec3 RRTAndODTFit( vec3 v ) {
  5829. vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
  5830. vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
  5831. return a / b;
  5832. }
  5833. vec3 ACESFilmicToneMapping( vec3 color ) {
  5834. const mat3 ACESInputMat = mat3(
  5835. vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
  5836. vec3( 0.04823, 0.01566, 0.83777 )
  5837. );
  5838. const mat3 ACESOutputMat = mat3(
  5839. vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
  5840. vec3( -0.07367, -0.00605, 1.07602 )
  5841. );
  5842. color *= toneMappingExposure / 0.6;
  5843. color = ACESInputMat * color;
  5844. color = RRTAndODTFit( color );
  5845. color = ACESOutputMat * color;
  5846. return saturate( color );
  5847. }
  5848. vec3 CustomToneMapping( vec3 color ) { return color; }`,x1e=`#ifdef USE_TRANSMISSION
  5849. material.transmission = transmission;
  5850. material.transmissionAlpha = 1.0;
  5851. material.thickness = thickness;
  5852. material.attenuationDistance = attenuationDistance;
  5853. material.attenuationColor = attenuationColor;
  5854. #ifdef USE_TRANSMISSIONMAP
  5855. material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
  5856. #endif
  5857. #ifdef USE_THICKNESSMAP
  5858. material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
  5859. #endif
  5860. vec3 pos = vWorldPosition;
  5861. vec3 v = normalize( cameraPosition - pos );
  5862. vec3 n = inverseTransformDirection( normal, viewMatrix );
  5863. vec4 transmitted = getIBLVolumeRefraction(
  5864. n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
  5865. pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
  5866. material.attenuationColor, material.attenuationDistance );
  5867. material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
  5868. totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
  5869. #endif`,b1e=`#ifdef USE_TRANSMISSION
  5870. uniform float transmission;
  5871. uniform float thickness;
  5872. uniform float attenuationDistance;
  5873. uniform vec3 attenuationColor;
  5874. #ifdef USE_TRANSMISSIONMAP
  5875. uniform sampler2D transmissionMap;
  5876. #endif
  5877. #ifdef USE_THICKNESSMAP
  5878. uniform sampler2D thicknessMap;
  5879. #endif
  5880. uniform vec2 transmissionSamplerSize;
  5881. uniform sampler2D transmissionSamplerMap;
  5882. uniform mat4 modelMatrix;
  5883. uniform mat4 projectionMatrix;
  5884. varying vec3 vWorldPosition;
  5885. float w0( float a ) {
  5886. return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
  5887. }
  5888. float w1( float a ) {
  5889. return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
  5890. }
  5891. float w2( float a ){
  5892. return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
  5893. }
  5894. float w3( float a ) {
  5895. return ( 1.0 / 6.0 ) * ( a * a * a );
  5896. }
  5897. float g0( float a ) {
  5898. return w0( a ) + w1( a );
  5899. }
  5900. float g1( float a ) {
  5901. return w2( a ) + w3( a );
  5902. }
  5903. float h0( float a ) {
  5904. return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
  5905. }
  5906. float h1( float a ) {
  5907. return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
  5908. }
  5909. vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
  5910. uv = uv * texelSize.zw + 0.5;
  5911. vec2 iuv = floor( uv );
  5912. vec2 fuv = fract( uv );
  5913. float g0x = g0( fuv.x );
  5914. float g1x = g1( fuv.x );
  5915. float h0x = h0( fuv.x );
  5916. float h1x = h1( fuv.x );
  5917. float h0y = h0( fuv.y );
  5918. float h1y = h1( fuv.y );
  5919. vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  5920. vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
  5921. vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  5922. vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
  5923. return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
  5924. g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
  5925. }
  5926. vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
  5927. vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
  5928. vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
  5929. vec2 fLodSizeInv = 1.0 / fLodSize;
  5930. vec2 cLodSizeInv = 1.0 / cLodSize;
  5931. vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
  5932. vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
  5933. return mix( fSample, cSample, fract( lod ) );
  5934. }
  5935. vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
  5936. vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
  5937. vec3 modelScale;
  5938. modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
  5939. modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
  5940. modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
  5941. return normalize( refractionVector ) * thickness * modelScale;
  5942. }
  5943. float applyIorToRoughness( const in float roughness, const in float ior ) {
  5944. return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
  5945. }
  5946. vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
  5947. float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
  5948. return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
  5949. }
  5950. vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
  5951. if ( isinf( attenuationDistance ) ) {
  5952. return vec3( 1.0 );
  5953. } else {
  5954. vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
  5955. vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
  5956. }
  5957. }
  5958. vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
  5959. const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
  5960. const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
  5961. const in vec3 attenuationColor, const in float attenuationDistance ) {
  5962. vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
  5963. vec3 refractedRayExit = position + transmissionRay;
  5964. vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
  5965. vec2 refractionCoords = ndcPos.xy / ndcPos.w;
  5966. refractionCoords += 1.0;
  5967. refractionCoords /= 2.0;
  5968. vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
  5969. vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
  5970. vec3 attenuatedColor = transmittance * transmittedLight.rgb;
  5971. vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
  5972. float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
  5973. return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
  5974. }
  5975. #endif`,y1e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  5976. varying vec2 vUv;
  5977. #endif
  5978. #ifdef USE_MAP
  5979. varying vec2 vMapUv;
  5980. #endif
  5981. #ifdef USE_ALPHAMAP
  5982. varying vec2 vAlphaMapUv;
  5983. #endif
  5984. #ifdef USE_LIGHTMAP
  5985. varying vec2 vLightMapUv;
  5986. #endif
  5987. #ifdef USE_AOMAP
  5988. varying vec2 vAoMapUv;
  5989. #endif
  5990. #ifdef USE_BUMPMAP
  5991. varying vec2 vBumpMapUv;
  5992. #endif
  5993. #ifdef USE_NORMALMAP
  5994. varying vec2 vNormalMapUv;
  5995. #endif
  5996. #ifdef USE_EMISSIVEMAP
  5997. varying vec2 vEmissiveMapUv;
  5998. #endif
  5999. #ifdef USE_METALNESSMAP
  6000. varying vec2 vMetalnessMapUv;
  6001. #endif
  6002. #ifdef USE_ROUGHNESSMAP
  6003. varying vec2 vRoughnessMapUv;
  6004. #endif
  6005. #ifdef USE_ANISOTROPYMAP
  6006. varying vec2 vAnisotropyMapUv;
  6007. #endif
  6008. #ifdef USE_CLEARCOATMAP
  6009. varying vec2 vClearcoatMapUv;
  6010. #endif
  6011. #ifdef USE_CLEARCOAT_NORMALMAP
  6012. varying vec2 vClearcoatNormalMapUv;
  6013. #endif
  6014. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6015. varying vec2 vClearcoatRoughnessMapUv;
  6016. #endif
  6017. #ifdef USE_IRIDESCENCEMAP
  6018. varying vec2 vIridescenceMapUv;
  6019. #endif
  6020. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6021. varying vec2 vIridescenceThicknessMapUv;
  6022. #endif
  6023. #ifdef USE_SHEEN_COLORMAP
  6024. varying vec2 vSheenColorMapUv;
  6025. #endif
  6026. #ifdef USE_SHEEN_ROUGHNESSMAP
  6027. varying vec2 vSheenRoughnessMapUv;
  6028. #endif
  6029. #ifdef USE_SPECULARMAP
  6030. varying vec2 vSpecularMapUv;
  6031. #endif
  6032. #ifdef USE_SPECULAR_COLORMAP
  6033. varying vec2 vSpecularColorMapUv;
  6034. #endif
  6035. #ifdef USE_SPECULAR_INTENSITYMAP
  6036. varying vec2 vSpecularIntensityMapUv;
  6037. #endif
  6038. #ifdef USE_TRANSMISSIONMAP
  6039. uniform mat3 transmissionMapTransform;
  6040. varying vec2 vTransmissionMapUv;
  6041. #endif
  6042. #ifdef USE_THICKNESSMAP
  6043. uniform mat3 thicknessMapTransform;
  6044. varying vec2 vThicknessMapUv;
  6045. #endif`,v1e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6046. varying vec2 vUv;
  6047. #endif
  6048. #ifdef USE_MAP
  6049. uniform mat3 mapTransform;
  6050. varying vec2 vMapUv;
  6051. #endif
  6052. #ifdef USE_ALPHAMAP
  6053. uniform mat3 alphaMapTransform;
  6054. varying vec2 vAlphaMapUv;
  6055. #endif
  6056. #ifdef USE_LIGHTMAP
  6057. uniform mat3 lightMapTransform;
  6058. varying vec2 vLightMapUv;
  6059. #endif
  6060. #ifdef USE_AOMAP
  6061. uniform mat3 aoMapTransform;
  6062. varying vec2 vAoMapUv;
  6063. #endif
  6064. #ifdef USE_BUMPMAP
  6065. uniform mat3 bumpMapTransform;
  6066. varying vec2 vBumpMapUv;
  6067. #endif
  6068. #ifdef USE_NORMALMAP
  6069. uniform mat3 normalMapTransform;
  6070. varying vec2 vNormalMapUv;
  6071. #endif
  6072. #ifdef USE_DISPLACEMENTMAP
  6073. uniform mat3 displacementMapTransform;
  6074. varying vec2 vDisplacementMapUv;
  6075. #endif
  6076. #ifdef USE_EMISSIVEMAP
  6077. uniform mat3 emissiveMapTransform;
  6078. varying vec2 vEmissiveMapUv;
  6079. #endif
  6080. #ifdef USE_METALNESSMAP
  6081. uniform mat3 metalnessMapTransform;
  6082. varying vec2 vMetalnessMapUv;
  6083. #endif
  6084. #ifdef USE_ROUGHNESSMAP
  6085. uniform mat3 roughnessMapTransform;
  6086. varying vec2 vRoughnessMapUv;
  6087. #endif
  6088. #ifdef USE_ANISOTROPYMAP
  6089. uniform mat3 anisotropyMapTransform;
  6090. varying vec2 vAnisotropyMapUv;
  6091. #endif
  6092. #ifdef USE_CLEARCOATMAP
  6093. uniform mat3 clearcoatMapTransform;
  6094. varying vec2 vClearcoatMapUv;
  6095. #endif
  6096. #ifdef USE_CLEARCOAT_NORMALMAP
  6097. uniform mat3 clearcoatNormalMapTransform;
  6098. varying vec2 vClearcoatNormalMapUv;
  6099. #endif
  6100. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6101. uniform mat3 clearcoatRoughnessMapTransform;
  6102. varying vec2 vClearcoatRoughnessMapUv;
  6103. #endif
  6104. #ifdef USE_SHEEN_COLORMAP
  6105. uniform mat3 sheenColorMapTransform;
  6106. varying vec2 vSheenColorMapUv;
  6107. #endif
  6108. #ifdef USE_SHEEN_ROUGHNESSMAP
  6109. uniform mat3 sheenRoughnessMapTransform;
  6110. varying vec2 vSheenRoughnessMapUv;
  6111. #endif
  6112. #ifdef USE_IRIDESCENCEMAP
  6113. uniform mat3 iridescenceMapTransform;
  6114. varying vec2 vIridescenceMapUv;
  6115. #endif
  6116. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6117. uniform mat3 iridescenceThicknessMapTransform;
  6118. varying vec2 vIridescenceThicknessMapUv;
  6119. #endif
  6120. #ifdef USE_SPECULARMAP
  6121. uniform mat3 specularMapTransform;
  6122. varying vec2 vSpecularMapUv;
  6123. #endif
  6124. #ifdef USE_SPECULAR_COLORMAP
  6125. uniform mat3 specularColorMapTransform;
  6126. varying vec2 vSpecularColorMapUv;
  6127. #endif
  6128. #ifdef USE_SPECULAR_INTENSITYMAP
  6129. uniform mat3 specularIntensityMapTransform;
  6130. varying vec2 vSpecularIntensityMapUv;
  6131. #endif
  6132. #ifdef USE_TRANSMISSIONMAP
  6133. uniform mat3 transmissionMapTransform;
  6134. varying vec2 vTransmissionMapUv;
  6135. #endif
  6136. #ifdef USE_THICKNESSMAP
  6137. uniform mat3 thicknessMapTransform;
  6138. varying vec2 vThicknessMapUv;
  6139. #endif`,w1e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
  6140. vUv = vec3( uv, 1 ).xy;
  6141. #endif
  6142. #ifdef USE_MAP
  6143. vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
  6144. #endif
  6145. #ifdef USE_ALPHAMAP
  6146. vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
  6147. #endif
  6148. #ifdef USE_LIGHTMAP
  6149. vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
  6150. #endif
  6151. #ifdef USE_AOMAP
  6152. vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
  6153. #endif
  6154. #ifdef USE_BUMPMAP
  6155. vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
  6156. #endif
  6157. #ifdef USE_NORMALMAP
  6158. vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
  6159. #endif
  6160. #ifdef USE_DISPLACEMENTMAP
  6161. vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
  6162. #endif
  6163. #ifdef USE_EMISSIVEMAP
  6164. vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
  6165. #endif
  6166. #ifdef USE_METALNESSMAP
  6167. vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
  6168. #endif
  6169. #ifdef USE_ROUGHNESSMAP
  6170. vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
  6171. #endif
  6172. #ifdef USE_ANISOTROPYMAP
  6173. vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
  6174. #endif
  6175. #ifdef USE_CLEARCOATMAP
  6176. vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
  6177. #endif
  6178. #ifdef USE_CLEARCOAT_NORMALMAP
  6179. vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
  6180. #endif
  6181. #ifdef USE_CLEARCOAT_ROUGHNESSMAP
  6182. vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
  6183. #endif
  6184. #ifdef USE_IRIDESCENCEMAP
  6185. vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
  6186. #endif
  6187. #ifdef USE_IRIDESCENCE_THICKNESSMAP
  6188. vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
  6189. #endif
  6190. #ifdef USE_SHEEN_COLORMAP
  6191. vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
  6192. #endif
  6193. #ifdef USE_SHEEN_ROUGHNESSMAP
  6194. vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
  6195. #endif
  6196. #ifdef USE_SPECULARMAP
  6197. vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
  6198. #endif
  6199. #ifdef USE_SPECULAR_COLORMAP
  6200. vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
  6201. #endif
  6202. #ifdef USE_SPECULAR_INTENSITYMAP
  6203. vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
  6204. #endif
  6205. #ifdef USE_TRANSMISSIONMAP
  6206. vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
  6207. #endif
  6208. #ifdef USE_THICKNESSMAP
  6209. vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
  6210. #endif`,_1e=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
  6211. vec4 worldPosition = vec4( transformed, 1.0 );
  6212. #ifdef USE_BATCHING
  6213. worldPosition = batchingMatrix * worldPosition;
  6214. #endif
  6215. #ifdef USE_INSTANCING
  6216. worldPosition = instanceMatrix * worldPosition;
  6217. #endif
  6218. worldPosition = modelMatrix * worldPosition;
  6219. #endif`;const S1e=`varying vec2 vUv;
  6220. uniform mat3 uvTransform;
  6221. void main() {
  6222. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  6223. gl_Position = vec4( position.xy, 1.0, 1.0 );
  6224. }`,N1e=`uniform sampler2D t2D;
  6225. uniform float backgroundIntensity;
  6226. varying vec2 vUv;
  6227. void main() {
  6228. vec4 texColor = texture2D( t2D, vUv );
  6229. #ifdef DECODE_VIDEO_TEXTURE
  6230. texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
  6231. #endif
  6232. texColor.rgb *= backgroundIntensity;
  6233. gl_FragColor = texColor;
  6234. #include <tonemapping_fragment>
  6235. #include <colorspace_fragment>
  6236. }`,M1e=`varying vec3 vWorldDirection;
  6237. #include <common>
  6238. void main() {
  6239. vWorldDirection = transformDirection( position, modelMatrix );
  6240. #include <begin_vertex>
  6241. #include <project_vertex>
  6242. gl_Position.z = gl_Position.w;
  6243. }`,k1e=`#ifdef ENVMAP_TYPE_CUBE
  6244. uniform samplerCube envMap;
  6245. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6246. uniform sampler2D envMap;
  6247. #endif
  6248. uniform float flipEnvMap;
  6249. uniform float backgroundBlurriness;
  6250. uniform float backgroundIntensity;
  6251. varying vec3 vWorldDirection;
  6252. #include <cube_uv_reflection_fragment>
  6253. void main() {
  6254. #ifdef ENVMAP_TYPE_CUBE
  6255. vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
  6256. #elif defined( ENVMAP_TYPE_CUBE_UV )
  6257. vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
  6258. #else
  6259. vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  6260. #endif
  6261. texColor.rgb *= backgroundIntensity;
  6262. gl_FragColor = texColor;
  6263. #include <tonemapping_fragment>
  6264. #include <colorspace_fragment>
  6265. }`,E1e=`varying vec3 vWorldDirection;
  6266. #include <common>
  6267. void main() {
  6268. vWorldDirection = transformDirection( position, modelMatrix );
  6269. #include <begin_vertex>
  6270. #include <project_vertex>
  6271. gl_Position.z = gl_Position.w;
  6272. }`,T1e=`uniform samplerCube tCube;
  6273. uniform float tFlip;
  6274. uniform float opacity;
  6275. varying vec3 vWorldDirection;
  6276. void main() {
  6277. vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
  6278. gl_FragColor = texColor;
  6279. gl_FragColor.a *= opacity;
  6280. #include <tonemapping_fragment>
  6281. #include <colorspace_fragment>
  6282. }`,A1e=`#include <common>
  6283. #include <batching_pars_vertex>
  6284. #include <uv_pars_vertex>
  6285. #include <displacementmap_pars_vertex>
  6286. #include <morphtarget_pars_vertex>
  6287. #include <skinning_pars_vertex>
  6288. #include <logdepthbuf_pars_vertex>
  6289. #include <clipping_planes_pars_vertex>
  6290. varying vec2 vHighPrecisionZW;
  6291. void main() {
  6292. #include <uv_vertex>
  6293. #include <batching_vertex>
  6294. #include <skinbase_vertex>
  6295. #ifdef USE_DISPLACEMENTMAP
  6296. #include <beginnormal_vertex>
  6297. #include <morphnormal_vertex>
  6298. #include <skinnormal_vertex>
  6299. #endif
  6300. #include <begin_vertex>
  6301. #include <morphtarget_vertex>
  6302. #include <skinning_vertex>
  6303. #include <displacementmap_vertex>
  6304. #include <project_vertex>
  6305. #include <logdepthbuf_vertex>
  6306. #include <clipping_planes_vertex>
  6307. vHighPrecisionZW = gl_Position.zw;
  6308. }`,C1e=`#if DEPTH_PACKING == 3200
  6309. uniform float opacity;
  6310. #endif
  6311. #include <common>
  6312. #include <packing>
  6313. #include <uv_pars_fragment>
  6314. #include <map_pars_fragment>
  6315. #include <alphamap_pars_fragment>
  6316. #include <alphatest_pars_fragment>
  6317. #include <alphahash_pars_fragment>
  6318. #include <logdepthbuf_pars_fragment>
  6319. #include <clipping_planes_pars_fragment>
  6320. varying vec2 vHighPrecisionZW;
  6321. void main() {
  6322. #include <clipping_planes_fragment>
  6323. vec4 diffuseColor = vec4( 1.0 );
  6324. #if DEPTH_PACKING == 3200
  6325. diffuseColor.a = opacity;
  6326. #endif
  6327. #include <map_fragment>
  6328. #include <alphamap_fragment>
  6329. #include <alphatest_fragment>
  6330. #include <alphahash_fragment>
  6331. #include <logdepthbuf_fragment>
  6332. float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
  6333. #if DEPTH_PACKING == 3200
  6334. gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
  6335. #elif DEPTH_PACKING == 3201
  6336. gl_FragColor = packDepthToRGBA( fragCoordZ );
  6337. #endif
  6338. }`,j1e=`#define DISTANCE
  6339. varying vec3 vWorldPosition;
  6340. #include <common>
  6341. #include <batching_pars_vertex>
  6342. #include <uv_pars_vertex>
  6343. #include <displacementmap_pars_vertex>
  6344. #include <morphtarget_pars_vertex>
  6345. #include <skinning_pars_vertex>
  6346. #include <clipping_planes_pars_vertex>
  6347. void main() {
  6348. #include <uv_vertex>
  6349. #include <batching_vertex>
  6350. #include <skinbase_vertex>
  6351. #ifdef USE_DISPLACEMENTMAP
  6352. #include <beginnormal_vertex>
  6353. #include <morphnormal_vertex>
  6354. #include <skinnormal_vertex>
  6355. #endif
  6356. #include <begin_vertex>
  6357. #include <morphtarget_vertex>
  6358. #include <skinning_vertex>
  6359. #include <displacementmap_vertex>
  6360. #include <project_vertex>
  6361. #include <worldpos_vertex>
  6362. #include <clipping_planes_vertex>
  6363. vWorldPosition = worldPosition.xyz;
  6364. }`,P1e=`#define DISTANCE
  6365. uniform vec3 referencePosition;
  6366. uniform float nearDistance;
  6367. uniform float farDistance;
  6368. varying vec3 vWorldPosition;
  6369. #include <common>
  6370. #include <packing>
  6371. #include <uv_pars_fragment>
  6372. #include <map_pars_fragment>
  6373. #include <alphamap_pars_fragment>
  6374. #include <alphatest_pars_fragment>
  6375. #include <alphahash_pars_fragment>
  6376. #include <clipping_planes_pars_fragment>
  6377. void main () {
  6378. #include <clipping_planes_fragment>
  6379. vec4 diffuseColor = vec4( 1.0 );
  6380. #include <map_fragment>
  6381. #include <alphamap_fragment>
  6382. #include <alphatest_fragment>
  6383. #include <alphahash_fragment>
  6384. float dist = length( vWorldPosition - referencePosition );
  6385. dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
  6386. dist = saturate( dist );
  6387. gl_FragColor = packDepthToRGBA( dist );
  6388. }`,D1e=`varying vec3 vWorldDirection;
  6389. #include <common>
  6390. void main() {
  6391. vWorldDirection = transformDirection( position, modelMatrix );
  6392. #include <begin_vertex>
  6393. #include <project_vertex>
  6394. }`,R1e=`uniform sampler2D tEquirect;
  6395. varying vec3 vWorldDirection;
  6396. #include <common>
  6397. void main() {
  6398. vec3 direction = normalize( vWorldDirection );
  6399. vec2 sampleUV = equirectUv( direction );
  6400. gl_FragColor = texture2D( tEquirect, sampleUV );
  6401. #include <tonemapping_fragment>
  6402. #include <colorspace_fragment>
  6403. }`,O1e=`uniform float scale;
  6404. attribute float lineDistance;
  6405. varying float vLineDistance;
  6406. #include <common>
  6407. #include <uv_pars_vertex>
  6408. #include <color_pars_vertex>
  6409. #include <fog_pars_vertex>
  6410. #include <morphtarget_pars_vertex>
  6411. #include <logdepthbuf_pars_vertex>
  6412. #include <clipping_planes_pars_vertex>
  6413. void main() {
  6414. vLineDistance = scale * lineDistance;
  6415. #include <uv_vertex>
  6416. #include <color_vertex>
  6417. #include <morphcolor_vertex>
  6418. #include <begin_vertex>
  6419. #include <morphtarget_vertex>
  6420. #include <project_vertex>
  6421. #include <logdepthbuf_vertex>
  6422. #include <clipping_planes_vertex>
  6423. #include <fog_vertex>
  6424. }`,L1e=`uniform vec3 diffuse;
  6425. uniform float opacity;
  6426. uniform float dashSize;
  6427. uniform float totalSize;
  6428. varying float vLineDistance;
  6429. #include <common>
  6430. #include <color_pars_fragment>
  6431. #include <uv_pars_fragment>
  6432. #include <map_pars_fragment>
  6433. #include <fog_pars_fragment>
  6434. #include <logdepthbuf_pars_fragment>
  6435. #include <clipping_planes_pars_fragment>
  6436. void main() {
  6437. #include <clipping_planes_fragment>
  6438. if ( mod( vLineDistance, totalSize ) > dashSize ) {
  6439. discard;
  6440. }
  6441. vec3 outgoingLight = vec3( 0.0 );
  6442. vec4 diffuseColor = vec4( diffuse, opacity );
  6443. #include <logdepthbuf_fragment>
  6444. #include <map_fragment>
  6445. #include <color_fragment>
  6446. outgoingLight = diffuseColor.rgb;
  6447. #include <opaque_fragment>
  6448. #include <tonemapping_fragment>
  6449. #include <colorspace_fragment>
  6450. #include <fog_fragment>
  6451. #include <premultiplied_alpha_fragment>
  6452. }`,F1e=`#include <common>
  6453. #include <batching_pars_vertex>
  6454. #include <uv_pars_vertex>
  6455. #include <envmap_pars_vertex>
  6456. #include <color_pars_vertex>
  6457. #include <fog_pars_vertex>
  6458. #include <morphtarget_pars_vertex>
  6459. #include <skinning_pars_vertex>
  6460. #include <logdepthbuf_pars_vertex>
  6461. #include <clipping_planes_pars_vertex>
  6462. void main() {
  6463. #include <uv_vertex>
  6464. #include <color_vertex>
  6465. #include <morphcolor_vertex>
  6466. #include <batching_vertex>
  6467. #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
  6468. #include <beginnormal_vertex>
  6469. #include <morphnormal_vertex>
  6470. #include <skinbase_vertex>
  6471. #include <skinnormal_vertex>
  6472. #include <defaultnormal_vertex>
  6473. #endif
  6474. #include <begin_vertex>
  6475. #include <morphtarget_vertex>
  6476. #include <skinning_vertex>
  6477. #include <project_vertex>
  6478. #include <logdepthbuf_vertex>
  6479. #include <clipping_planes_vertex>
  6480. #include <worldpos_vertex>
  6481. #include <envmap_vertex>
  6482. #include <fog_vertex>
  6483. }`,I1e=`uniform vec3 diffuse;
  6484. uniform float opacity;
  6485. #ifndef FLAT_SHADED
  6486. varying vec3 vNormal;
  6487. #endif
  6488. #include <common>
  6489. #include <dithering_pars_fragment>
  6490. #include <color_pars_fragment>
  6491. #include <uv_pars_fragment>
  6492. #include <map_pars_fragment>
  6493. #include <alphamap_pars_fragment>
  6494. #include <alphatest_pars_fragment>
  6495. #include <alphahash_pars_fragment>
  6496. #include <aomap_pars_fragment>
  6497. #include <lightmap_pars_fragment>
  6498. #include <envmap_common_pars_fragment>
  6499. #include <envmap_pars_fragment>
  6500. #include <fog_pars_fragment>
  6501. #include <specularmap_pars_fragment>
  6502. #include <logdepthbuf_pars_fragment>
  6503. #include <clipping_planes_pars_fragment>
  6504. void main() {
  6505. #include <clipping_planes_fragment>
  6506. vec4 diffuseColor = vec4( diffuse, opacity );
  6507. #include <logdepthbuf_fragment>
  6508. #include <map_fragment>
  6509. #include <color_fragment>
  6510. #include <alphamap_fragment>
  6511. #include <alphatest_fragment>
  6512. #include <alphahash_fragment>
  6513. #include <specularmap_fragment>
  6514. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6515. #ifdef USE_LIGHTMAP
  6516. vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
  6517. reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
  6518. #else
  6519. reflectedLight.indirectDiffuse += vec3( 1.0 );
  6520. #endif
  6521. #include <aomap_fragment>
  6522. reflectedLight.indirectDiffuse *= diffuseColor.rgb;
  6523. vec3 outgoingLight = reflectedLight.indirectDiffuse;
  6524. #include <envmap_fragment>
  6525. #include <opaque_fragment>
  6526. #include <tonemapping_fragment>
  6527. #include <colorspace_fragment>
  6528. #include <fog_fragment>
  6529. #include <premultiplied_alpha_fragment>
  6530. #include <dithering_fragment>
  6531. }`,U1e=`#define LAMBERT
  6532. varying vec3 vViewPosition;
  6533. #include <common>
  6534. #include <batching_pars_vertex>
  6535. #include <uv_pars_vertex>
  6536. #include <displacementmap_pars_vertex>
  6537. #include <envmap_pars_vertex>
  6538. #include <color_pars_vertex>
  6539. #include <fog_pars_vertex>
  6540. #include <normal_pars_vertex>
  6541. #include <morphtarget_pars_vertex>
  6542. #include <skinning_pars_vertex>
  6543. #include <shadowmap_pars_vertex>
  6544. #include <logdepthbuf_pars_vertex>
  6545. #include <clipping_planes_pars_vertex>
  6546. void main() {
  6547. #include <uv_vertex>
  6548. #include <color_vertex>
  6549. #include <morphcolor_vertex>
  6550. #include <batching_vertex>
  6551. #include <beginnormal_vertex>
  6552. #include <morphnormal_vertex>
  6553. #include <skinbase_vertex>
  6554. #include <skinnormal_vertex>
  6555. #include <defaultnormal_vertex>
  6556. #include <normal_vertex>
  6557. #include <begin_vertex>
  6558. #include <morphtarget_vertex>
  6559. #include <skinning_vertex>
  6560. #include <displacementmap_vertex>
  6561. #include <project_vertex>
  6562. #include <logdepthbuf_vertex>
  6563. #include <clipping_planes_vertex>
  6564. vViewPosition = - mvPosition.xyz;
  6565. #include <worldpos_vertex>
  6566. #include <envmap_vertex>
  6567. #include <shadowmap_vertex>
  6568. #include <fog_vertex>
  6569. }`,z1e=`#define LAMBERT
  6570. uniform vec3 diffuse;
  6571. uniform vec3 emissive;
  6572. uniform float opacity;
  6573. #include <common>
  6574. #include <packing>
  6575. #include <dithering_pars_fragment>
  6576. #include <color_pars_fragment>
  6577. #include <uv_pars_fragment>
  6578. #include <map_pars_fragment>
  6579. #include <alphamap_pars_fragment>
  6580. #include <alphatest_pars_fragment>
  6581. #include <alphahash_pars_fragment>
  6582. #include <aomap_pars_fragment>
  6583. #include <lightmap_pars_fragment>
  6584. #include <emissivemap_pars_fragment>
  6585. #include <envmap_common_pars_fragment>
  6586. #include <envmap_pars_fragment>
  6587. #include <fog_pars_fragment>
  6588. #include <bsdfs>
  6589. #include <lights_pars_begin>
  6590. #include <normal_pars_fragment>
  6591. #include <lights_lambert_pars_fragment>
  6592. #include <shadowmap_pars_fragment>
  6593. #include <bumpmap_pars_fragment>
  6594. #include <normalmap_pars_fragment>
  6595. #include <specularmap_pars_fragment>
  6596. #include <logdepthbuf_pars_fragment>
  6597. #include <clipping_planes_pars_fragment>
  6598. void main() {
  6599. #include <clipping_planes_fragment>
  6600. vec4 diffuseColor = vec4( diffuse, opacity );
  6601. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6602. vec3 totalEmissiveRadiance = emissive;
  6603. #include <logdepthbuf_fragment>
  6604. #include <map_fragment>
  6605. #include <color_fragment>
  6606. #include <alphamap_fragment>
  6607. #include <alphatest_fragment>
  6608. #include <alphahash_fragment>
  6609. #include <specularmap_fragment>
  6610. #include <normal_fragment_begin>
  6611. #include <normal_fragment_maps>
  6612. #include <emissivemap_fragment>
  6613. #include <lights_lambert_fragment>
  6614. #include <lights_fragment_begin>
  6615. #include <lights_fragment_maps>
  6616. #include <lights_fragment_end>
  6617. #include <aomap_fragment>
  6618. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  6619. #include <envmap_fragment>
  6620. #include <opaque_fragment>
  6621. #include <tonemapping_fragment>
  6622. #include <colorspace_fragment>
  6623. #include <fog_fragment>
  6624. #include <premultiplied_alpha_fragment>
  6625. #include <dithering_fragment>
  6626. }`,B1e=`#define MATCAP
  6627. varying vec3 vViewPosition;
  6628. #include <common>
  6629. #include <batching_pars_vertex>
  6630. #include <uv_pars_vertex>
  6631. #include <color_pars_vertex>
  6632. #include <displacementmap_pars_vertex>
  6633. #include <fog_pars_vertex>
  6634. #include <normal_pars_vertex>
  6635. #include <morphtarget_pars_vertex>
  6636. #include <skinning_pars_vertex>
  6637. #include <logdepthbuf_pars_vertex>
  6638. #include <clipping_planes_pars_vertex>
  6639. void main() {
  6640. #include <uv_vertex>
  6641. #include <color_vertex>
  6642. #include <morphcolor_vertex>
  6643. #include <batching_vertex>
  6644. #include <beginnormal_vertex>
  6645. #include <morphnormal_vertex>
  6646. #include <skinbase_vertex>
  6647. #include <skinnormal_vertex>
  6648. #include <defaultnormal_vertex>
  6649. #include <normal_vertex>
  6650. #include <begin_vertex>
  6651. #include <morphtarget_vertex>
  6652. #include <skinning_vertex>
  6653. #include <displacementmap_vertex>
  6654. #include <project_vertex>
  6655. #include <logdepthbuf_vertex>
  6656. #include <clipping_planes_vertex>
  6657. #include <fog_vertex>
  6658. vViewPosition = - mvPosition.xyz;
  6659. }`,H1e=`#define MATCAP
  6660. uniform vec3 diffuse;
  6661. uniform float opacity;
  6662. uniform sampler2D matcap;
  6663. varying vec3 vViewPosition;
  6664. #include <common>
  6665. #include <dithering_pars_fragment>
  6666. #include <color_pars_fragment>
  6667. #include <uv_pars_fragment>
  6668. #include <map_pars_fragment>
  6669. #include <alphamap_pars_fragment>
  6670. #include <alphatest_pars_fragment>
  6671. #include <alphahash_pars_fragment>
  6672. #include <fog_pars_fragment>
  6673. #include <normal_pars_fragment>
  6674. #include <bumpmap_pars_fragment>
  6675. #include <normalmap_pars_fragment>
  6676. #include <logdepthbuf_pars_fragment>
  6677. #include <clipping_planes_pars_fragment>
  6678. void main() {
  6679. #include <clipping_planes_fragment>
  6680. vec4 diffuseColor = vec4( diffuse, opacity );
  6681. #include <logdepthbuf_fragment>
  6682. #include <map_fragment>
  6683. #include <color_fragment>
  6684. #include <alphamap_fragment>
  6685. #include <alphatest_fragment>
  6686. #include <alphahash_fragment>
  6687. #include <normal_fragment_begin>
  6688. #include <normal_fragment_maps>
  6689. vec3 viewDir = normalize( vViewPosition );
  6690. vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
  6691. vec3 y = cross( viewDir, x );
  6692. vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
  6693. #ifdef USE_MATCAP
  6694. vec4 matcapColor = texture2D( matcap, uv );
  6695. #else
  6696. vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
  6697. #endif
  6698. vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
  6699. #include <opaque_fragment>
  6700. #include <tonemapping_fragment>
  6701. #include <colorspace_fragment>
  6702. #include <fog_fragment>
  6703. #include <premultiplied_alpha_fragment>
  6704. #include <dithering_fragment>
  6705. }`,$1e=`#define NORMAL
  6706. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6707. varying vec3 vViewPosition;
  6708. #endif
  6709. #include <common>
  6710. #include <batching_pars_vertex>
  6711. #include <uv_pars_vertex>
  6712. #include <displacementmap_pars_vertex>
  6713. #include <normal_pars_vertex>
  6714. #include <morphtarget_pars_vertex>
  6715. #include <skinning_pars_vertex>
  6716. #include <logdepthbuf_pars_vertex>
  6717. #include <clipping_planes_pars_vertex>
  6718. void main() {
  6719. #include <uv_vertex>
  6720. #include <batching_vertex>
  6721. #include <beginnormal_vertex>
  6722. #include <morphnormal_vertex>
  6723. #include <skinbase_vertex>
  6724. #include <skinnormal_vertex>
  6725. #include <defaultnormal_vertex>
  6726. #include <normal_vertex>
  6727. #include <begin_vertex>
  6728. #include <morphtarget_vertex>
  6729. #include <skinning_vertex>
  6730. #include <displacementmap_vertex>
  6731. #include <project_vertex>
  6732. #include <logdepthbuf_vertex>
  6733. #include <clipping_planes_vertex>
  6734. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6735. vViewPosition = - mvPosition.xyz;
  6736. #endif
  6737. }`,V1e=`#define NORMAL
  6738. uniform float opacity;
  6739. #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
  6740. varying vec3 vViewPosition;
  6741. #endif
  6742. #include <packing>
  6743. #include <uv_pars_fragment>
  6744. #include <normal_pars_fragment>
  6745. #include <bumpmap_pars_fragment>
  6746. #include <normalmap_pars_fragment>
  6747. #include <logdepthbuf_pars_fragment>
  6748. #include <clipping_planes_pars_fragment>
  6749. void main() {
  6750. #include <clipping_planes_fragment>
  6751. #include <logdepthbuf_fragment>
  6752. #include <normal_fragment_begin>
  6753. #include <normal_fragment_maps>
  6754. gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
  6755. #ifdef OPAQUE
  6756. gl_FragColor.a = 1.0;
  6757. #endif
  6758. }`,G1e=`#define PHONG
  6759. varying vec3 vViewPosition;
  6760. #include <common>
  6761. #include <batching_pars_vertex>
  6762. #include <uv_pars_vertex>
  6763. #include <displacementmap_pars_vertex>
  6764. #include <envmap_pars_vertex>
  6765. #include <color_pars_vertex>
  6766. #include <fog_pars_vertex>
  6767. #include <normal_pars_vertex>
  6768. #include <morphtarget_pars_vertex>
  6769. #include <skinning_pars_vertex>
  6770. #include <shadowmap_pars_vertex>
  6771. #include <logdepthbuf_pars_vertex>
  6772. #include <clipping_planes_pars_vertex>
  6773. void main() {
  6774. #include <uv_vertex>
  6775. #include <color_vertex>
  6776. #include <morphcolor_vertex>
  6777. #include <batching_vertex>
  6778. #include <beginnormal_vertex>
  6779. #include <morphnormal_vertex>
  6780. #include <skinbase_vertex>
  6781. #include <skinnormal_vertex>
  6782. #include <defaultnormal_vertex>
  6783. #include <normal_vertex>
  6784. #include <begin_vertex>
  6785. #include <morphtarget_vertex>
  6786. #include <skinning_vertex>
  6787. #include <displacementmap_vertex>
  6788. #include <project_vertex>
  6789. #include <logdepthbuf_vertex>
  6790. #include <clipping_planes_vertex>
  6791. vViewPosition = - mvPosition.xyz;
  6792. #include <worldpos_vertex>
  6793. #include <envmap_vertex>
  6794. #include <shadowmap_vertex>
  6795. #include <fog_vertex>
  6796. }`,q1e=`#define PHONG
  6797. uniform vec3 diffuse;
  6798. uniform vec3 emissive;
  6799. uniform vec3 specular;
  6800. uniform float shininess;
  6801. uniform float opacity;
  6802. #include <common>
  6803. #include <packing>
  6804. #include <dithering_pars_fragment>
  6805. #include <color_pars_fragment>
  6806. #include <uv_pars_fragment>
  6807. #include <map_pars_fragment>
  6808. #include <alphamap_pars_fragment>
  6809. #include <alphatest_pars_fragment>
  6810. #include <alphahash_pars_fragment>
  6811. #include <aomap_pars_fragment>
  6812. #include <lightmap_pars_fragment>
  6813. #include <emissivemap_pars_fragment>
  6814. #include <envmap_common_pars_fragment>
  6815. #include <envmap_pars_fragment>
  6816. #include <fog_pars_fragment>
  6817. #include <bsdfs>
  6818. #include <lights_pars_begin>
  6819. #include <normal_pars_fragment>
  6820. #include <lights_phong_pars_fragment>
  6821. #include <shadowmap_pars_fragment>
  6822. #include <bumpmap_pars_fragment>
  6823. #include <normalmap_pars_fragment>
  6824. #include <specularmap_pars_fragment>
  6825. #include <logdepthbuf_pars_fragment>
  6826. #include <clipping_planes_pars_fragment>
  6827. void main() {
  6828. #include <clipping_planes_fragment>
  6829. vec4 diffuseColor = vec4( diffuse, opacity );
  6830. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6831. vec3 totalEmissiveRadiance = emissive;
  6832. #include <logdepthbuf_fragment>
  6833. #include <map_fragment>
  6834. #include <color_fragment>
  6835. #include <alphamap_fragment>
  6836. #include <alphatest_fragment>
  6837. #include <alphahash_fragment>
  6838. #include <specularmap_fragment>
  6839. #include <normal_fragment_begin>
  6840. #include <normal_fragment_maps>
  6841. #include <emissivemap_fragment>
  6842. #include <lights_phong_fragment>
  6843. #include <lights_fragment_begin>
  6844. #include <lights_fragment_maps>
  6845. #include <lights_fragment_end>
  6846. #include <aomap_fragment>
  6847. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
  6848. #include <envmap_fragment>
  6849. #include <opaque_fragment>
  6850. #include <tonemapping_fragment>
  6851. #include <colorspace_fragment>
  6852. #include <fog_fragment>
  6853. #include <premultiplied_alpha_fragment>
  6854. #include <dithering_fragment>
  6855. }`,W1e=`#define STANDARD
  6856. varying vec3 vViewPosition;
  6857. #ifdef USE_TRANSMISSION
  6858. varying vec3 vWorldPosition;
  6859. #endif
  6860. #include <common>
  6861. #include <batching_pars_vertex>
  6862. #include <uv_pars_vertex>
  6863. #include <displacementmap_pars_vertex>
  6864. #include <color_pars_vertex>
  6865. #include <fog_pars_vertex>
  6866. #include <normal_pars_vertex>
  6867. #include <morphtarget_pars_vertex>
  6868. #include <skinning_pars_vertex>
  6869. #include <shadowmap_pars_vertex>
  6870. #include <logdepthbuf_pars_vertex>
  6871. #include <clipping_planes_pars_vertex>
  6872. void main() {
  6873. #include <uv_vertex>
  6874. #include <color_vertex>
  6875. #include <morphcolor_vertex>
  6876. #include <batching_vertex>
  6877. #include <beginnormal_vertex>
  6878. #include <morphnormal_vertex>
  6879. #include <skinbase_vertex>
  6880. #include <skinnormal_vertex>
  6881. #include <defaultnormal_vertex>
  6882. #include <normal_vertex>
  6883. #include <begin_vertex>
  6884. #include <morphtarget_vertex>
  6885. #include <skinning_vertex>
  6886. #include <displacementmap_vertex>
  6887. #include <project_vertex>
  6888. #include <logdepthbuf_vertex>
  6889. #include <clipping_planes_vertex>
  6890. vViewPosition = - mvPosition.xyz;
  6891. #include <worldpos_vertex>
  6892. #include <shadowmap_vertex>
  6893. #include <fog_vertex>
  6894. #ifdef USE_TRANSMISSION
  6895. vWorldPosition = worldPosition.xyz;
  6896. #endif
  6897. }`,K1e=`#define STANDARD
  6898. #ifdef PHYSICAL
  6899. #define IOR
  6900. #define USE_SPECULAR
  6901. #endif
  6902. uniform vec3 diffuse;
  6903. uniform vec3 emissive;
  6904. uniform float roughness;
  6905. uniform float metalness;
  6906. uniform float opacity;
  6907. #ifdef IOR
  6908. uniform float ior;
  6909. #endif
  6910. #ifdef USE_SPECULAR
  6911. uniform float specularIntensity;
  6912. uniform vec3 specularColor;
  6913. #ifdef USE_SPECULAR_COLORMAP
  6914. uniform sampler2D specularColorMap;
  6915. #endif
  6916. #ifdef USE_SPECULAR_INTENSITYMAP
  6917. uniform sampler2D specularIntensityMap;
  6918. #endif
  6919. #endif
  6920. #ifdef USE_CLEARCOAT
  6921. uniform float clearcoat;
  6922. uniform float clearcoatRoughness;
  6923. #endif
  6924. #ifdef USE_IRIDESCENCE
  6925. uniform float iridescence;
  6926. uniform float iridescenceIOR;
  6927. uniform float iridescenceThicknessMinimum;
  6928. uniform float iridescenceThicknessMaximum;
  6929. #endif
  6930. #ifdef USE_SHEEN
  6931. uniform vec3 sheenColor;
  6932. uniform float sheenRoughness;
  6933. #ifdef USE_SHEEN_COLORMAP
  6934. uniform sampler2D sheenColorMap;
  6935. #endif
  6936. #ifdef USE_SHEEN_ROUGHNESSMAP
  6937. uniform sampler2D sheenRoughnessMap;
  6938. #endif
  6939. #endif
  6940. #ifdef USE_ANISOTROPY
  6941. uniform vec2 anisotropyVector;
  6942. #ifdef USE_ANISOTROPYMAP
  6943. uniform sampler2D anisotropyMap;
  6944. #endif
  6945. #endif
  6946. varying vec3 vViewPosition;
  6947. #include <common>
  6948. #include <packing>
  6949. #include <dithering_pars_fragment>
  6950. #include <color_pars_fragment>
  6951. #include <uv_pars_fragment>
  6952. #include <map_pars_fragment>
  6953. #include <alphamap_pars_fragment>
  6954. #include <alphatest_pars_fragment>
  6955. #include <alphahash_pars_fragment>
  6956. #include <aomap_pars_fragment>
  6957. #include <lightmap_pars_fragment>
  6958. #include <emissivemap_pars_fragment>
  6959. #include <iridescence_fragment>
  6960. #include <cube_uv_reflection_fragment>
  6961. #include <envmap_common_pars_fragment>
  6962. #include <envmap_physical_pars_fragment>
  6963. #include <fog_pars_fragment>
  6964. #include <lights_pars_begin>
  6965. #include <normal_pars_fragment>
  6966. #include <lights_physical_pars_fragment>
  6967. #include <transmission_pars_fragment>
  6968. #include <shadowmap_pars_fragment>
  6969. #include <bumpmap_pars_fragment>
  6970. #include <normalmap_pars_fragment>
  6971. #include <clearcoat_pars_fragment>
  6972. #include <iridescence_pars_fragment>
  6973. #include <roughnessmap_pars_fragment>
  6974. #include <metalnessmap_pars_fragment>
  6975. #include <logdepthbuf_pars_fragment>
  6976. #include <clipping_planes_pars_fragment>
  6977. void main() {
  6978. #include <clipping_planes_fragment>
  6979. vec4 diffuseColor = vec4( diffuse, opacity );
  6980. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  6981. vec3 totalEmissiveRadiance = emissive;
  6982. #include <logdepthbuf_fragment>
  6983. #include <map_fragment>
  6984. #include <color_fragment>
  6985. #include <alphamap_fragment>
  6986. #include <alphatest_fragment>
  6987. #include <alphahash_fragment>
  6988. #include <roughnessmap_fragment>
  6989. #include <metalnessmap_fragment>
  6990. #include <normal_fragment_begin>
  6991. #include <normal_fragment_maps>
  6992. #include <clearcoat_normal_fragment_begin>
  6993. #include <clearcoat_normal_fragment_maps>
  6994. #include <emissivemap_fragment>
  6995. #include <lights_physical_fragment>
  6996. #include <lights_fragment_begin>
  6997. #include <lights_fragment_maps>
  6998. #include <lights_fragment_end>
  6999. #include <aomap_fragment>
  7000. vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
  7001. vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
  7002. #include <transmission_fragment>
  7003. vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
  7004. #ifdef USE_SHEEN
  7005. float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
  7006. outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
  7007. #endif
  7008. #ifdef USE_CLEARCOAT
  7009. float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
  7010. vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
  7011. outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
  7012. #endif
  7013. #include <opaque_fragment>
  7014. #include <tonemapping_fragment>
  7015. #include <colorspace_fragment>
  7016. #include <fog_fragment>
  7017. #include <premultiplied_alpha_fragment>
  7018. #include <dithering_fragment>
  7019. }`,X1e=`#define TOON
  7020. varying vec3 vViewPosition;
  7021. #include <common>
  7022. #include <batching_pars_vertex>
  7023. #include <uv_pars_vertex>
  7024. #include <displacementmap_pars_vertex>
  7025. #include <color_pars_vertex>
  7026. #include <fog_pars_vertex>
  7027. #include <normal_pars_vertex>
  7028. #include <morphtarget_pars_vertex>
  7029. #include <skinning_pars_vertex>
  7030. #include <shadowmap_pars_vertex>
  7031. #include <logdepthbuf_pars_vertex>
  7032. #include <clipping_planes_pars_vertex>
  7033. void main() {
  7034. #include <uv_vertex>
  7035. #include <color_vertex>
  7036. #include <morphcolor_vertex>
  7037. #include <batching_vertex>
  7038. #include <beginnormal_vertex>
  7039. #include <morphnormal_vertex>
  7040. #include <skinbase_vertex>
  7041. #include <skinnormal_vertex>
  7042. #include <defaultnormal_vertex>
  7043. #include <normal_vertex>
  7044. #include <begin_vertex>
  7045. #include <morphtarget_vertex>
  7046. #include <skinning_vertex>
  7047. #include <displacementmap_vertex>
  7048. #include <project_vertex>
  7049. #include <logdepthbuf_vertex>
  7050. #include <clipping_planes_vertex>
  7051. vViewPosition = - mvPosition.xyz;
  7052. #include <worldpos_vertex>
  7053. #include <shadowmap_vertex>
  7054. #include <fog_vertex>
  7055. }`,Y1e=`#define TOON
  7056. uniform vec3 diffuse;
  7057. uniform vec3 emissive;
  7058. uniform float opacity;
  7059. #include <common>
  7060. #include <packing>
  7061. #include <dithering_pars_fragment>
  7062. #include <color_pars_fragment>
  7063. #include <uv_pars_fragment>
  7064. #include <map_pars_fragment>
  7065. #include <alphamap_pars_fragment>
  7066. #include <alphatest_pars_fragment>
  7067. #include <alphahash_pars_fragment>
  7068. #include <aomap_pars_fragment>
  7069. #include <lightmap_pars_fragment>
  7070. #include <emissivemap_pars_fragment>
  7071. #include <gradientmap_pars_fragment>
  7072. #include <fog_pars_fragment>
  7073. #include <bsdfs>
  7074. #include <lights_pars_begin>
  7075. #include <normal_pars_fragment>
  7076. #include <lights_toon_pars_fragment>
  7077. #include <shadowmap_pars_fragment>
  7078. #include <bumpmap_pars_fragment>
  7079. #include <normalmap_pars_fragment>
  7080. #include <logdepthbuf_pars_fragment>
  7081. #include <clipping_planes_pars_fragment>
  7082. void main() {
  7083. #include <clipping_planes_fragment>
  7084. vec4 diffuseColor = vec4( diffuse, opacity );
  7085. ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
  7086. vec3 totalEmissiveRadiance = emissive;
  7087. #include <logdepthbuf_fragment>
  7088. #include <map_fragment>
  7089. #include <color_fragment>
  7090. #include <alphamap_fragment>
  7091. #include <alphatest_fragment>
  7092. #include <alphahash_fragment>
  7093. #include <normal_fragment_begin>
  7094. #include <normal_fragment_maps>
  7095. #include <emissivemap_fragment>
  7096. #include <lights_toon_fragment>
  7097. #include <lights_fragment_begin>
  7098. #include <lights_fragment_maps>
  7099. #include <lights_fragment_end>
  7100. #include <aomap_fragment>
  7101. vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
  7102. #include <opaque_fragment>
  7103. #include <tonemapping_fragment>
  7104. #include <colorspace_fragment>
  7105. #include <fog_fragment>
  7106. #include <premultiplied_alpha_fragment>
  7107. #include <dithering_fragment>
  7108. }`,Q1e=`uniform float size;
  7109. uniform float scale;
  7110. #include <common>
  7111. #include <color_pars_vertex>
  7112. #include <fog_pars_vertex>
  7113. #include <morphtarget_pars_vertex>
  7114. #include <logdepthbuf_pars_vertex>
  7115. #include <clipping_planes_pars_vertex>
  7116. #ifdef USE_POINTS_UV
  7117. varying vec2 vUv;
  7118. uniform mat3 uvTransform;
  7119. #endif
  7120. void main() {
  7121. #ifdef USE_POINTS_UV
  7122. vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
  7123. #endif
  7124. #include <color_vertex>
  7125. #include <morphcolor_vertex>
  7126. #include <begin_vertex>
  7127. #include <morphtarget_vertex>
  7128. #include <project_vertex>
  7129. gl_PointSize = size;
  7130. #ifdef USE_SIZEATTENUATION
  7131. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7132. if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
  7133. #endif
  7134. #include <logdepthbuf_vertex>
  7135. #include <clipping_planes_vertex>
  7136. #include <worldpos_vertex>
  7137. #include <fog_vertex>
  7138. }`,Z1e=`uniform vec3 diffuse;
  7139. uniform float opacity;
  7140. #include <common>
  7141. #include <color_pars_fragment>
  7142. #include <map_particle_pars_fragment>
  7143. #include <alphatest_pars_fragment>
  7144. #include <alphahash_pars_fragment>
  7145. #include <fog_pars_fragment>
  7146. #include <logdepthbuf_pars_fragment>
  7147. #include <clipping_planes_pars_fragment>
  7148. void main() {
  7149. #include <clipping_planes_fragment>
  7150. vec3 outgoingLight = vec3( 0.0 );
  7151. vec4 diffuseColor = vec4( diffuse, opacity );
  7152. #include <logdepthbuf_fragment>
  7153. #include <map_particle_fragment>
  7154. #include <color_fragment>
  7155. #include <alphatest_fragment>
  7156. #include <alphahash_fragment>
  7157. outgoingLight = diffuseColor.rgb;
  7158. #include <opaque_fragment>
  7159. #include <tonemapping_fragment>
  7160. #include <colorspace_fragment>
  7161. #include <fog_fragment>
  7162. #include <premultiplied_alpha_fragment>
  7163. }`,J1e=`#include <common>
  7164. #include <batching_pars_vertex>
  7165. #include <fog_pars_vertex>
  7166. #include <morphtarget_pars_vertex>
  7167. #include <skinning_pars_vertex>
  7168. #include <logdepthbuf_pars_vertex>
  7169. #include <shadowmap_pars_vertex>
  7170. void main() {
  7171. #include <batching_vertex>
  7172. #include <beginnormal_vertex>
  7173. #include <morphnormal_vertex>
  7174. #include <skinbase_vertex>
  7175. #include <skinnormal_vertex>
  7176. #include <defaultnormal_vertex>
  7177. #include <begin_vertex>
  7178. #include <morphtarget_vertex>
  7179. #include <skinning_vertex>
  7180. #include <project_vertex>
  7181. #include <logdepthbuf_vertex>
  7182. #include <worldpos_vertex>
  7183. #include <shadowmap_vertex>
  7184. #include <fog_vertex>
  7185. }`,eSe=`uniform vec3 color;
  7186. uniform float opacity;
  7187. #include <common>
  7188. #include <packing>
  7189. #include <fog_pars_fragment>
  7190. #include <bsdfs>
  7191. #include <lights_pars_begin>
  7192. #include <logdepthbuf_pars_fragment>
  7193. #include <shadowmap_pars_fragment>
  7194. #include <shadowmask_pars_fragment>
  7195. void main() {
  7196. #include <logdepthbuf_fragment>
  7197. gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
  7198. #include <tonemapping_fragment>
  7199. #include <colorspace_fragment>
  7200. #include <fog_fragment>
  7201. }`,tSe=`uniform float rotation;
  7202. uniform vec2 center;
  7203. #include <common>
  7204. #include <uv_pars_vertex>
  7205. #include <fog_pars_vertex>
  7206. #include <logdepthbuf_pars_vertex>
  7207. #include <clipping_planes_pars_vertex>
  7208. void main() {
  7209. #include <uv_vertex>
  7210. vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
  7211. vec2 scale;
  7212. scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
  7213. scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
  7214. #ifndef USE_SIZEATTENUATION
  7215. bool isPerspective = isPerspectiveMatrix( projectionMatrix );
  7216. if ( isPerspective ) scale *= - mvPosition.z;
  7217. #endif
  7218. vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
  7219. vec2 rotatedPosition;
  7220. rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
  7221. rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
  7222. mvPosition.xy += rotatedPosition;
  7223. gl_Position = projectionMatrix * mvPosition;
  7224. #include <logdepthbuf_vertex>
  7225. #include <clipping_planes_vertex>
  7226. #include <fog_vertex>
  7227. }`,nSe=`uniform vec3 diffuse;
  7228. uniform float opacity;
  7229. #include <common>
  7230. #include <uv_pars_fragment>
  7231. #include <map_pars_fragment>
  7232. #include <alphamap_pars_fragment>
  7233. #include <alphatest_pars_fragment>
  7234. #include <alphahash_pars_fragment>
  7235. #include <fog_pars_fragment>
  7236. #include <logdepthbuf_pars_fragment>
  7237. #include <clipping_planes_pars_fragment>
  7238. void main() {
  7239. #include <clipping_planes_fragment>
  7240. vec3 outgoingLight = vec3( 0.0 );
  7241. vec4 diffuseColor = vec4( diffuse, opacity );
  7242. #include <logdepthbuf_fragment>
  7243. #include <map_fragment>
  7244. #include <alphamap_fragment>
  7245. #include <alphatest_fragment>
  7246. #include <alphahash_fragment>
  7247. outgoingLight = diffuseColor.rgb;
  7248. #include <opaque_fragment>
  7249. #include <tonemapping_fragment>
  7250. #include <colorspace_fragment>
  7251. #include <fog_fragment>
  7252. }`,An={alphahash_fragment:Nwe,alphahash_pars_fragment:Mwe,alphamap_fragment:kwe,alphamap_pars_fragment:Ewe,alphatest_fragment:Twe,alphatest_pars_fragment:Awe,aomap_fragment:Cwe,aomap_pars_fragment:jwe,batching_pars_vertex:Pwe,batching_vertex:Dwe,begin_vertex:Rwe,beginnormal_vertex:Owe,bsdfs:Lwe,iridescence_fragment:Fwe,bumpmap_pars_fragment:Iwe,clipping_planes_fragment:Uwe,clipping_planes_pars_fragment:zwe,clipping_planes_pars_vertex:Bwe,clipping_planes_vertex:Hwe,color_fragment:$we,color_pars_fragment:Vwe,color_pars_vertex:Gwe,color_vertex:qwe,common:Wwe,cube_uv_reflection_fragment:Kwe,defaultnormal_vertex:Xwe,displacementmap_pars_vertex:Ywe,displacementmap_vertex:Qwe,emissivemap_fragment:Zwe,emissivemap_pars_fragment:Jwe,colorspace_fragment:e_e,colorspace_pars_fragment:t_e,envmap_fragment:n_e,envmap_common_pars_fragment:r_e,envmap_pars_fragment:i_e,envmap_pars_vertex:a_e,envmap_physical_pars_fragment:x_e,envmap_vertex:s_e,fog_vertex:o_e,fog_pars_vertex:l_e,fog_fragment:c_e,fog_pars_fragment:u_e,gradientmap_pars_fragment:d_e,lightmap_fragment:h_e,lightmap_pars_fragment:f_e,lights_lambert_fragment:m_e,lights_lambert_pars_fragment:p_e,lights_pars_begin:g_e,lights_toon_fragment:b_e,lights_toon_pars_fragment:y_e,lights_phong_fragment:v_e,lights_phong_pars_fragment:w_e,lights_physical_fragment:__e,lights_physical_pars_fragment:S_e,lights_fragment_begin:N_e,lights_fragment_maps:M_e,lights_fragment_end:k_e,logdepthbuf_fragment:E_e,logdepthbuf_pars_fragment:T_e,logdepthbuf_pars_vertex:A_e,logdepthbuf_vertex:C_e,map_fragment:j_e,map_pars_fragment:P_e,map_particle_fragment:D_e,map_particle_pars_fragment:R_e,metalnessmap_fragment:O_e,metalnessmap_pars_fragment:L_e,morphcolor_vertex:F_e,morphnormal_vertex:I_e,morphtarget_pars_vertex:U_e,morphtarget_vertex:z_e,normal_fragment_begin:B_e,normal_fragment_maps:H_e,normal_pars_fragment:$_e,normal_pars_vertex:V_e,normal_vertex:G_e,normalmap_pars_fragment:q_e,clearcoat_normal_fragment_begin:W_e,clearcoat_normal_fragment_maps:K_e,clearcoat_pars_fragment:X_e,iridescence_pars_fragment:Y_e,opaque_fragment:Q_e,packing:Z_e,premultiplied_alpha_fragment:J_e,project_vertex:e1e,dithering_fragment:t1e,dithering_pars_fragment:n1e,roughnessmap_fragment:r1e,roughnessmap_pars_fragment:i1e,shadowmap_pars_fragment:a1e,shadowmap_pars_vertex:s1e,shadowmap_vertex:o1e,shadowmask_pars_fragment:l1e,skinbase_vertex:c1e,skinning_pars_vertex:u1e,skinning_vertex:d1e,skinnormal_vertex:h1e,specularmap_fragment:f1e,specularmap_pars_fragment:m1e,tonemapping_fragment:p1e,tonemapping_pars_fragment:g1e,transmission_fragment:x1e,transmission_pars_fragment:b1e,uv_pars_fragment:y1e,uv_pars_vertex:v1e,uv_vertex:w1e,worldpos_vertex:_1e,background_vert:S1e,background_frag:N1e,backgroundCube_vert:M1e,backgroundCube_frag:k1e,cube_vert:E1e,cube_frag:T1e,depth_vert:A1e,depth_frag:C1e,distanceRGBA_vert:j1e,distanceRGBA_frag:P1e,equirect_vert:D1e,equirect_frag:R1e,linedashed_vert:O1e,linedashed_frag:L1e,meshbasic_vert:F1e,meshbasic_frag:I1e,meshlambert_vert:U1e,meshlambert_frag:z1e,meshmatcap_vert:B1e,meshmatcap_frag:H1e,meshnormal_vert:$1e,meshnormal_frag:V1e,meshphong_vert:G1e,meshphong_frag:q1e,meshphysical_vert:W1e,meshphysical_frag:K1e,meshtoon_vert:X1e,meshtoon_frag:Y1e,points_vert:Q1e,points_frag:Z1e,shadow_vert:J1e,shadow_frag:eSe,sprite_vert:tSe,sprite_frag:nSe},Ot={common:{diffuse:{value:new Jt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new In},alphaMap:{value:null},alphaMapTransform:{value:new In},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new In}},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 In}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new In}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new In},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new In},normalScale:{value:new bn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new In},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new In}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new In}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new In}},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 In},alphaTest:{value:0},uvTransform:{value:new In}},sprite:{diffuse:{value:new Jt(16777215)},opacity:{value:1},center:{value:new bn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new In},alphaMap:{value:null},alphaMapTransform:{value:new In},alphaTest:{value:0}}},Is={basic:{uniforms:ds([Ot.common,Ot.specularmap,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.fog]),vertexShader:An.meshbasic_vert,fragmentShader:An.meshbasic_frag},lambert:{uniforms:ds([Ot.common,Ot.specularmap,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.fog,Ot.lights,{emissive:{value:new Jt(0)}}]),vertexShader:An.meshlambert_vert,fragmentShader:An.meshlambert_frag},phong:{uniforms:ds([Ot.common,Ot.specularmap,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.fog,Ot.lights,{emissive:{value:new Jt(0)},specular:{value:new Jt(1118481)},shininess:{value:30}}]),vertexShader:An.meshphong_vert,fragmentShader:An.meshphong_frag},standard:{uniforms:ds([Ot.common,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.roughnessmap,Ot.metalnessmap,Ot.fog,Ot.lights,{emissive:{value:new Jt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:An.meshphysical_vert,fragmentShader:An.meshphysical_frag},toon:{uniforms:ds([Ot.common,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.gradientmap,Ot.fog,Ot.lights,{emissive:{value:new Jt(0)}}]),vertexShader:An.meshtoon_vert,fragmentShader:An.meshtoon_frag},matcap:{uniforms:ds([Ot.common,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.fog,{matcap:{value:null}}]),vertexShader:An.meshmatcap_vert,fragmentShader:An.meshmatcap_frag},points:{uniforms:ds([Ot.points,Ot.fog]),vertexShader:An.points_vert,fragmentShader:An.points_frag},dashed:{uniforms:ds([Ot.common,Ot.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:An.linedashed_vert,fragmentShader:An.linedashed_frag},depth:{uniforms:ds([Ot.common,Ot.displacementmap]),vertexShader:An.depth_vert,fragmentShader:An.depth_frag},normal:{uniforms:ds([Ot.common,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,{opacity:{value:1}}]),vertexShader:An.meshnormal_vert,fragmentShader:An.meshnormal_frag},sprite:{uniforms:ds([Ot.sprite,Ot.fog]),vertexShader:An.sprite_vert,fragmentShader:An.sprite_frag},background:{uniforms:{uvTransform:{value:new In},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:An.background_vert,fragmentShader:An.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:An.backgroundCube_vert,fragmentShader:An.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:An.cube_vert,fragmentShader:An.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:An.equirect_vert,fragmentShader:An.equirect_frag},distanceRGBA:{uniforms:ds([Ot.common,Ot.displacementmap,{referencePosition:{value:new We},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:An.distanceRGBA_vert,fragmentShader:An.distanceRGBA_frag},shadow:{uniforms:ds([Ot.lights,Ot.fog,{color:{value:new Jt(0)},opacity:{value:1}}]),vertexShader:An.shadow_vert,fragmentShader:An.shadow_frag}};Is.physical={uniforms:ds([Is.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new In},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new In},clearcoatNormalScale:{value:new bn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new In},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new In},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new In},sheen:{value:0},sheenColor:{value:new Jt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new In},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new In},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new In},transmissionSamplerSize:{value:new bn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new In},attenuationDistance:{value:0},attenuationColor:{value:new Jt(0)},specularColor:{value:new Jt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new In},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new In},anisotropyVector:{value:new bn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new In}}]),vertexShader:An.meshphysical_vert,fragmentShader:An.meshphysical_frag};const k_={r:0,b:0,g:0};function rSe(t,e,n,r,i,s,o){const l=new Jt(0);let c=s===!0?0:1,u,d,h=null,p=0,m=null;function x(v,b){let S=!1,N=b.isScene===!0?b.background:null;N&&N.isTexture&&(N=(b.backgroundBlurriness>0?n:e).get(N)),N===null?y(l,c):N&&N.isColor&&(y(N,1),S=!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||S)&&t.clear(t.autoClearColor,t.autoClearDepth,t.autoClearStencil),N&&(N.isCubeTexture||N.mapping===kM)?(d===void 0&&(d=new Ll(new Hy(1,1,1),new kh({name:"BackgroundCubeMaterial",uniforms:Jg(Is.backgroundCube.uniforms),vertexShader:Is.backgroundCube.vertexShader,fragmentShader:Is.backgroundCube.fragmentShader,side:Hs,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(k,C,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),d.material.uniforms.envMap.value=N,d.material.uniforms.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,d.material.toneMapped=Er.getTransfer(N.colorSpace)!==Gr,(h!==N||p!==N.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,h=N,p=N.version,m=t.toneMapping),d.layers.enableAll(),v.unshift(d,d.geometry,d.material,0,0,null)):N&&N.isTexture&&(u===void 0&&(u=new Ll(new cO(2,2),new kh({name:"BackgroundMaterial",uniforms:Jg(Is.background.uniforms),vertexShader:Is.background.vertexShader,fragmentShader:Is.background.fragmentShader,side:Mh,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=N,u.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,u.material.toneMapped=Er.getTransfer(N.colorSpace)!==Gr,N.matrixAutoUpdate===!0&&N.updateMatrix(),u.material.uniforms.uvTransform.value.copy(N.matrix),(h!==N||p!==N.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,h=N,p=N.version,m=t.toneMapping),u.layers.enableAll(),v.unshift(u,u.geometry,u.material,0,0,null))}function y(v,b){v.getRGB(k_,eX(t)),r.buffers.color.setClear(k_.r,k_.g,k_.b,b,o)}return{getClearColor:function(){return l},setClearColor:function(v,b=1){l.set(v),c=b,y(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(v){c=v,y(l,c)},render:x}}function iSe(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=v(null);let u=c,d=!1;function h(j,V,K,z,X){let Y=!1;if(o){const te=y(z,K,V);u!==te&&(u=te,m(u.object)),Y=b(j,z,K,X),Y&&S(j,z,K,X)}else{const te=V.wireframe===!0;(u.geometry!==z.id||u.program!==K.id||u.wireframe!==te)&&(u.geometry=z.id,u.program=K.id,u.wireframe=te,Y=!0)}X!==null&&n.update(X,t.ELEMENT_ARRAY_BUFFER),(Y||d)&&(d=!1,P(j,V,K,z),X!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(X).buffer))}function p(){return r.isWebGL2?t.createVertexArray():s.createVertexArrayOES()}function m(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,V,K){const z=K.wireframe===!0;let X=l[j.id];X===void 0&&(X={},l[j.id]=X);let Y=X[V.id];Y===void 0&&(Y={},X[V.id]=Y);let te=Y[z];return te===void 0&&(te=v(p()),Y[z]=te),te}function v(j){const V=[],K=[],z=[];for(let X=0;X<i;X++)V[X]=0,K[X]=0,z[X]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:V,enabledAttributes:K,attributeDivisors:z,object:j,attributes:{},index:null}}function b(j,V,K,z){const X=u.attributes,Y=V.attributes;let te=0;const $=K.getAttributes();for(const W in $)if($[W].location>=0){const re=X[W];let ge=Y[W];if(ge===void 0&&(W==="instanceMatrix"&&j.instanceMatrix&&(ge=j.instanceMatrix),W==="instanceColor"&&j.instanceColor&&(ge=j.instanceColor)),re===void 0||re.attribute!==ge||ge&&re.data!==ge.data)return!0;te++}return u.attributesNum!==te||u.index!==z}function S(j,V,K,z){const X={},Y=V.attributes;let te=0;const $=K.getAttributes();for(const W in $)if($[W].location>=0){let re=Y[W];re===void 0&&(W==="instanceMatrix"&&j.instanceMatrix&&(re=j.instanceMatrix),W==="instanceColor"&&j.instanceColor&&(re=j.instanceColor));const ge={};ge.attribute=re,re&&re.data&&(ge.data=re.data),X[W]=ge,te++}u.attributes=X,u.attributesNum=te,u.index=z}function N(){const j=u.newAttributes;for(let V=0,K=j.length;V<K;V++)j[V]=0}function T(j){k(j,0)}function k(j,V){const K=u.newAttributes,z=u.enabledAttributes,X=u.attributeDivisors;K[j]=1,z[j]===0&&(t.enableVertexAttribArray(j),z[j]=1),X[j]!==V&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](j,V),X[j]=V)}function C(){const j=u.newAttributes,V=u.enabledAttributes;for(let K=0,z=V.length;K<z;K++)V[K]!==j[K]&&(t.disableVertexAttribArray(K),V[K]=0)}function E(j,V,K,z,X,Y,te){te===!0?t.vertexAttribIPointer(j,V,K,X,Y):t.vertexAttribPointer(j,V,K,z,X,Y)}function P(j,V,K,z){if(r.isWebGL2===!1&&(j.isInstancedMesh||z.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;N();const X=z.attributes,Y=K.getAttributes(),te=V.defaultAttributeValues;for(const $ in Y){const W=Y[$];if(W.location>=0){let ne=X[$];if(ne===void 0&&($==="instanceMatrix"&&j.instanceMatrix&&(ne=j.instanceMatrix),$==="instanceColor"&&j.instanceColor&&(ne=j.instanceColor)),ne!==void 0){const re=ne.normalized,ge=ne.itemSize,me=n.get(ne);if(me===void 0)continue;const ue=me.buffer,Te=me.type,ie=me.bytesPerElement,Ce=r.isWebGL2===!0&&(Te===t.INT||Te===t.UNSIGNED_INT||ne.gpuType===RK);if(ne.isInterleavedBufferAttribute){const Fe=ne.data,xe=Fe.stride,Ze=ne.offset;if(Fe.isInstancedInterleavedBuffer){for(let G=0;G<W.locationSize;G++)k(W.location+G,Fe.meshPerAttribute);j.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=Fe.meshPerAttribute*Fe.count)}else for(let G=0;G<W.locationSize;G++)T(W.location+G);t.bindBuffer(t.ARRAY_BUFFER,ue);for(let G=0;G<W.locationSize;G++)E(W.location+G,ge/W.locationSize,Te,re,xe*ie,(Ze+ge/W.locationSize*G)*ie,Ce)}else{if(ne.isInstancedBufferAttribute){for(let Fe=0;Fe<W.locationSize;Fe++)k(W.location+Fe,ne.meshPerAttribute);j.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Fe=0;Fe<W.locationSize;Fe++)T(W.location+Fe);t.bindBuffer(t.ARRAY_BUFFER,ue);for(let Fe=0;Fe<W.locationSize;Fe++)E(W.location+Fe,ge/W.locationSize,Te,re,ge*ie,ge/W.locationSize*Fe*ie,Ce)}}else if(te!==void 0){const re=te[$];if(re!==void 0)switch(re.length){case 2:t.vertexAttrib2fv(W.location,re);break;case 3:t.vertexAttrib3fv(W.location,re);break;case 4:t.vertexAttrib4fv(W.location,re);break;default:t.vertexAttrib1fv(W.location,re)}}}}C()}function A(){L();for(const j in l){const V=l[j];for(const K in V){const z=V[K];for(const X in z)x(z[X].object),delete z[X];delete V[K]}delete l[j]}}function D(j){if(l[j.id]===void 0)return;const V=l[j.id];for(const K in V){const z=V[K];for(const X in z)x(z[X].object),delete z[X];delete V[K]}delete l[j.id]}function I(j){for(const V in l){const K=l[V];if(K[j.id]===void 0)continue;const z=K[j.id];for(const X in z)x(z[X].object),delete z[X];delete K[j.id]}}function L(){U(),d=!0,u!==c&&(u=c,m(u.object))}function U(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:h,reset:L,resetDefaultState:U,dispose:A,releaseStatesOfGeometry:D,releaseStatesOfProgram:I,initAttributes:N,enableAttribute:T,disableUnusedAttributes:C}}function aSe(t,e,n,r){const i=r.isWebGL2;let s;function o(d){s=d}function l(d,h){t.drawArrays(s,d,h),n.update(h,s,1)}function c(d,h,p){if(p===0)return;let m,x;if(i)m=t,x="drawArraysInstanced";else if(m=e.get("ANGLE_instanced_arrays"),x="drawArraysInstancedANGLE",m===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}m[x](s,d,h,p),n.update(h,s,p)}function u(d,h,p){if(p===0)return;const m=e.get("WEBGL_multi_draw");if(m===null)for(let x=0;x<p;x++)this.render(d[x],h[x]);else{m.multiDrawArraysWEBGL(s,d,0,h,0,p);let x=0;for(let y=0;y<p;y++)x+=h[y];n.update(x,s,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function sSe(t,e,n){let r;function i(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const E=e.get("EXT_texture_filter_anisotropic");r=t.getParameter(E.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function s(E){if(E==="highp"){if(t.getShaderPrecisionFormat(t.VERTEX_SHADER,t.HIGH_FLOAT).precision>0&&t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="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,h=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),p=t.getParameter(t.MAX_VERTEX_TEXTURE_IMAGE_UNITS),m=t.getParameter(t.MAX_TEXTURE_SIZE),x=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),v=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),b=t.getParameter(t.MAX_VARYING_VECTORS),S=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),N=p>0,T=o||e.has("OES_texture_float"),k=N&&T,C=o?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:s,precision:l,logarithmicDepthBuffer:d,maxTextures:h,maxVertexTextures:p,maxTextureSize:m,maxCubemapSize:x,maxAttributes:y,maxVertexUniforms:v,maxVaryings:b,maxFragmentUniforms:S,vertexTextures:N,floatFragmentTextures:T,floatVertexTextures:k,maxSamples:C}}function oSe(t){const e=this;let n=null,r=0,i=!1,s=!1;const o=new Bd,l=new In,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(h,p){const m=h.length!==0||p||r!==0||i;return i=p,r=h.length,m},this.beginShadows=function(){s=!0,d(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(h,p){n=d(h,p,0)},this.setState=function(h,p,m){const x=h.clippingPlanes,y=h.clipIntersection,v=h.clipShadows,b=t.get(h);if(!i||x===null||x.length===0||s&&!v)s?d(null):u();else{const S=s?0:r,N=S*4;let T=b.clippingState||null;c.value=T,T=d(x,p,N,m);for(let k=0;k!==N;++k)T[k]=n[k];b.clippingState=T,this.numIntersection=y?this.numPlanes:0,this.numPlanes+=S}};function u(){c.value!==n&&(c.value=n,c.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function d(h,p,m,x){const y=h!==null?h.length:0;let v=null;if(y!==0){if(v=c.value,x!==!0||v===null){const b=m+y*4,S=p.matrixWorldInverse;l.getNormalMatrix(S),(v===null||v.length<b)&&(v=new Float32Array(b));for(let N=0,T=m;N!==y;++N,T+=4)o.copy(h[N]).applyMatrix4(S,l),o.normal.toArray(v,T),v[T+3]=o.constant}c.value=v,c.needsUpdate=!0}return e.numPlanes=y,e.numIntersection=0,v}}function lSe(t){let e=new WeakMap;function n(o,l){return l===f3?o.mapping=Yg:l===m3&&(o.mapping=Qg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===f3||l===m3)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 vwe(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 cSe extends tX{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 bg=4,n6=[.125,.215,.35,.446,.526,.582],Af=20,lA=new cSe,r6=new Jt;let cA=null,uA=0,dA=0;const _f=(1+Math.sqrt(5))/2,Xp=1/_f,i6=[new We(1,1,1),new We(-1,1,1),new We(1,1,-1),new We(-1,1,-1),new We(0,_f,Xp),new We(0,_f,-Xp),new We(Xp,0,_f),new We(-Xp,0,_f),new We(_f,Xp,0),new We(-_f,Xp,0)];class a6{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){cA=this._renderer.getRenderTarget(),uA=this._renderer.getActiveCubeFace(),dA=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=l6(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=o6(),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(cA,uA,dA),e.scissorTest=!1,E_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Yg||e.mapping===Qg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),cA=this._renderer.getRenderTarget(),uA=this._renderer.getActiveCubeFace(),dA=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:Zo,minFilter:Zo,generateMipmaps:!1,type:ny,format:Jo,colorSpace:Iu,depthBuffer:!1},i=s6(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=s6(e,n,r);const{_lodMax:s}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=uSe(s)),this._blurMaterial=dSe(s,e,n)}return i}_compileMaterial(e){const n=new Ll(this._lodPlanes[0],e);this._renderer.compile(n,lA)}_sceneToCubeUV(e,n,r,i){const l=new ho(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,h=d.autoClear,p=d.toneMapping;d.getClearColor(r6),d.toneMapping=dh,d.autoClear=!1;const m=new QK({name:"PMREM.Background",side:Hs,depthWrite:!1,depthTest:!1}),x=new Ll(new Hy,m);let y=!1;const v=e.background;v?v.isColor&&(m.color.copy(v),e.background=null,y=!0):(m.color.copy(r6),y=!0);for(let b=0;b<6;b++){const S=b%3;S===0?(l.up.set(0,c[b],0),l.lookAt(u[b],0,0)):S===1?(l.up.set(0,0,c[b]),l.lookAt(0,u[b],0)):(l.up.set(0,c[b],0),l.lookAt(0,0,u[b]));const N=this._cubeSize;E_(i,S*N,b>2?N:0,N,N),d.setRenderTarget(i),y&&d.render(x,l),d.render(e,l)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=p,d.autoClear=h,e.background=v}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Yg||e.mapping===Qg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=l6()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=o6());const s=i?this._cubemapMaterial:this._equirectMaterial,o=new Ll(this._lodPlanes[0],s),l=s.uniforms;l.envMap.value=e;const c=this._cubeSize;E_(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,lA)}_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=i6[(i-1)%i6.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,h=new Ll(this._lodPlanes[i],u),p=u.uniforms,m=this._sizeLods[r]-1,x=isFinite(s)?Math.PI/(2*m):2*Math.PI/(2*Af-1),y=s/x,v=isFinite(s)?1+Math.floor(d*y):Af;v>Af&&console.warn(`sigmaRadians, ${s}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Af}`);const b=[];let S=0;for(let E=0;E<Af;++E){const P=E/y,A=Math.exp(-P*P/2);b.push(A),E===0?S+=A:E<v&&(S+=2*A)}for(let E=0;E<b.length;E++)b[E]=b[E]/S;p.envMap.value=e.texture,p.samples.value=v,p.weights.value=b,p.latitudinal.value=o==="latitudinal",l&&(p.poleAxis.value=l);const{_lodMax:N}=this;p.dTheta.value=x,p.mipInt.value=N-r;const T=this._sizeLods[i],k=3*T*(i>N-bg?i-N+bg:0),C=4*(this._cubeSize-T);E_(n,k,C,3*T,2*T),c.setRenderTarget(n),c.render(h,lA)}}function uSe(t){const e=[],n=[],r=[];let i=t;const s=t-bg+1+n6.length;for(let o=0;o<s;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-bg?c=n6[o-t+bg-1]:o===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,h=1+u,p=[d,d,h,d,h,h,d,d,h,h,d,h],m=6,x=6,y=3,v=2,b=1,S=new Float32Array(y*x*m),N=new Float32Array(v*x*m),T=new Float32Array(b*x*m);for(let C=0;C<m;C++){const E=C%3*2/3-1,P=C>2?0:-1,A=[E,P,0,E+2/3,P,0,E+2/3,P+1,0,E,P,0,E+2/3,P+1,0,E,P+1,0];S.set(A,y*x*C),N.set(p,v*x*C);const D=[C,C,C,C,C,C];T.set(D,b*x*C)}const k=new ns;k.setAttribute("position",new yo(S,y)),k.setAttribute("uv",new yo(N,v)),k.setAttribute("faceIndex",new yo(T,b)),e.push(k),i>bg&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function s6(t,e,n){const r=new fm(t,e,n);return r.texture.mapping=kM,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function E_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function dSe(t,e,n){const r=new Float32Array(Af),i=new We(0,1,0);return new kh({name:"SphericalGaussianBlur",defines:{n:Af,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:uO(),fragmentShader:`
  7253. precision mediump float;
  7254. precision mediump int;
  7255. varying vec3 vOutputDirection;
  7256. uniform sampler2D envMap;
  7257. uniform int samples;
  7258. uniform float weights[ n ];
  7259. uniform bool latitudinal;
  7260. uniform float dTheta;
  7261. uniform float mipInt;
  7262. uniform vec3 poleAxis;
  7263. #define ENVMAP_TYPE_CUBE_UV
  7264. #include <cube_uv_reflection_fragment>
  7265. vec3 getSample( float theta, vec3 axis ) {
  7266. float cosTheta = cos( theta );
  7267. // Rodrigues' axis-angle rotation
  7268. vec3 sampleDirection = vOutputDirection * cosTheta
  7269. + cross( axis, vOutputDirection ) * sin( theta )
  7270. + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
  7271. return bilinearCubeUV( envMap, sampleDirection, mipInt );
  7272. }
  7273. void main() {
  7274. vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
  7275. if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
  7276. axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
  7277. }
  7278. axis = normalize( axis );
  7279. gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
  7280. gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
  7281. for ( int i = 1; i < n; i++ ) {
  7282. if ( i >= samples ) {
  7283. break;
  7284. }
  7285. float theta = dTheta * float( i );
  7286. gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
  7287. gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
  7288. }
  7289. }
  7290. `,blending:uh,depthTest:!1,depthWrite:!1})}function o6(){return new kh({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:uO(),fragmentShader:`
  7291. precision mediump float;
  7292. precision mediump int;
  7293. varying vec3 vOutputDirection;
  7294. uniform sampler2D envMap;
  7295. #include <common>
  7296. void main() {
  7297. vec3 outputDirection = normalize( vOutputDirection );
  7298. vec2 uv = equirectUv( outputDirection );
  7299. gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
  7300. }
  7301. `,blending:uh,depthTest:!1,depthWrite:!1})}function l6(){return new kh({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:uO(),fragmentShader:`
  7302. precision mediump float;
  7303. precision mediump int;
  7304. uniform float flipEnvMap;
  7305. varying vec3 vOutputDirection;
  7306. uniform samplerCube envMap;
  7307. void main() {
  7308. gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
  7309. }
  7310. `,blending:uh,depthTest:!1,depthWrite:!1})}function uO(){return`
  7311. precision mediump float;
  7312. precision mediump int;
  7313. attribute float faceIndex;
  7314. varying vec3 vOutputDirection;
  7315. // RH coordinate system; PMREM face-indexing convention
  7316. vec3 getDirection( vec2 uv, float face ) {
  7317. uv = 2.0 * uv - 1.0;
  7318. vec3 direction = vec3( uv, 1.0 );
  7319. if ( face == 0.0 ) {
  7320. direction = direction.zyx; // ( 1, v, u ) pos x
  7321. } else if ( face == 1.0 ) {
  7322. direction = direction.xzy;
  7323. direction.xz *= -1.0; // ( -u, 1, -v ) pos y
  7324. } else if ( face == 2.0 ) {
  7325. direction.x *= -1.0; // ( -u, v, 1 ) pos z
  7326. } else if ( face == 3.0 ) {
  7327. direction = direction.zyx;
  7328. direction.xz *= -1.0; // ( -1, v, -u ) neg x
  7329. } else if ( face == 4.0 ) {
  7330. direction = direction.xzy;
  7331. direction.xy *= -1.0; // ( -u, -1, v ) neg y
  7332. } else if ( face == 5.0 ) {
  7333. direction.z *= -1.0; // ( u, v, -1 ) neg z
  7334. }
  7335. return direction;
  7336. }
  7337. void main() {
  7338. vOutputDirection = getDirection( uv, faceIndex );
  7339. gl_Position = vec4( position, 1.0 );
  7340. }
  7341. `}function hSe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===f3||c===m3,d=c===Yg||c===Qg;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let h=e.get(l);return n===null&&(n=new a6(t)),h=u?n.fromEquirectangular(l,h):n.fromCubemap(l,h),e.set(l,h),h.texture}else{if(e.has(l))return e.get(l).texture;{const h=l.image;if(u&&h&&h.height>0||d&&h&&i(h)){n===null&&(n=new a6(t));const p=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,p),l.addEventListener("dispose",s),p.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 fSe(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 mSe(t,e,n,r){const i={},s=new WeakMap;function o(h){const p=h.target;p.index!==null&&e.remove(p.index);for(const x in p.attributes)e.remove(p.attributes[x]);for(const x in p.morphAttributes){const y=p.morphAttributes[x];for(let v=0,b=y.length;v<b;v++)e.remove(y[v])}p.removeEventListener("dispose",o),delete i[p.id];const m=s.get(p);m&&(e.remove(m),s.delete(p)),r.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function l(h,p){return i[p.id]===!0||(p.addEventListener("dispose",o),i[p.id]=!0,n.memory.geometries++),p}function c(h){const p=h.attributes;for(const x in p)e.update(p[x],t.ARRAY_BUFFER);const m=h.morphAttributes;for(const x in m){const y=m[x];for(let v=0,b=y.length;v<b;v++)e.update(y[v],t.ARRAY_BUFFER)}}function u(h){const p=[],m=h.index,x=h.attributes.position;let y=0;if(m!==null){const S=m.array;y=m.version;for(let N=0,T=S.length;N<T;N+=3){const k=S[N+0],C=S[N+1],E=S[N+2];p.push(k,C,C,E,E,k)}}else if(x!==void 0){const S=x.array;y=x.version;for(let N=0,T=S.length/3-1;N<T;N+=3){const k=N+0,C=N+1,E=N+2;p.push(k,C,C,E,E,k)}}else return;const v=new(GK(p)?JK:ZK)(p,1);v.version=y;const b=s.get(h);b&&e.remove(b),s.set(h,v)}function d(h){const p=s.get(h);if(p){const m=h.index;m!==null&&p.version<m.version&&u(h)}else u(h);return s.get(h)}return{get:l,update:c,getWireframeAttribute:d}}function pSe(t,e,n,r){const i=r.isWebGL2;let s;function o(m){s=m}let l,c;function u(m){l=m.type,c=m.bytesPerElement}function d(m,x){t.drawElements(s,x,l,m*c),n.update(x,s,1)}function h(m,x,y){if(y===0)return;let v,b;if(i)v=t,b="drawElementsInstanced";else if(v=e.get("ANGLE_instanced_arrays"),b="drawElementsInstancedANGLE",v===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}v[b](s,x,l,m*c,y),n.update(x,s,y)}function p(m,x,y){if(y===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let b=0;b<y;b++)this.render(m[b]/c,x[b]);else{v.multiDrawElementsWEBGL(s,x,0,l,m,0,y);let b=0;for(let S=0;S<y;S++)b+=x[S];n.update(b,s,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=h,this.renderMultiDraw=p}function gSe(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 xSe(t,e){return t[0]-e[0]}function bSe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function ySe(t,e,n){const r={},i=new Float32Array(8),s=new WeakMap,o=new Cr,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,h){const p=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 v=s.get(d);if(v===void 0||v.count!==y){let V=function(){U.dispose(),s.delete(d),d.removeEventListener("dispose",V)};var m=V;v!==void 0&&v.texture.dispose();const N=d.morphAttributes.position!==void 0,T=d.morphAttributes.normal!==void 0,k=d.morphAttributes.color!==void 0,C=d.morphAttributes.position||[],E=d.morphAttributes.normal||[],P=d.morphAttributes.color||[];let A=0;N===!0&&(A=1),T===!0&&(A=2),k===!0&&(A=3);let D=d.attributes.position.count*A,I=1;D>e.maxTextureSize&&(I=Math.ceil(D/e.maxTextureSize),D=e.maxTextureSize);const L=new Float32Array(D*I*4*y),U=new KK(L,D,I,y);U.type=_u,U.needsUpdate=!0;const j=A*4;for(let K=0;K<y;K++){const z=C[K],X=E[K],Y=P[K],te=D*I*4*K;for(let $=0;$<z.count;$++){const W=$*j;N===!0&&(o.fromBufferAttribute(z,$),L[te+W+0]=o.x,L[te+W+1]=o.y,L[te+W+2]=o.z,L[te+W+3]=0),T===!0&&(o.fromBufferAttribute(X,$),L[te+W+4]=o.x,L[te+W+5]=o.y,L[te+W+6]=o.z,L[te+W+7]=0),k===!0&&(o.fromBufferAttribute(Y,$),L[te+W+8]=o.x,L[te+W+9]=o.y,L[te+W+10]=o.z,L[te+W+11]=Y.itemSize===4?o.w:1)}}v={count:y,texture:U,size:new bn(D,I)},s.set(d,v),d.addEventListener("dispose",V)}let b=0;for(let N=0;N<p.length;N++)b+=p[N];const S=d.morphTargetsRelative?1:1-b;h.getUniforms().setValue(t,"morphTargetBaseInfluence",S),h.getUniforms().setValue(t,"morphTargetInfluences",p),h.getUniforms().setValue(t,"morphTargetsTexture",v.texture,n),h.getUniforms().setValue(t,"morphTargetsTextureSize",v.size)}else{const x=p===void 0?0:p.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 k=y[T];k[0]=T,k[1]=p[T]}y.sort(bSe);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(xSe);const v=d.morphAttributes.position,b=d.morphAttributes.normal;let S=0;for(let T=0;T<8;T++){const k=l[T],C=k[0],E=k[1];C!==Number.MAX_SAFE_INTEGER&&E?(v&&d.getAttribute("morphTarget"+T)!==v[C]&&d.setAttribute("morphTarget"+T,v[C]),b&&d.getAttribute("morphNormal"+T)!==b[C]&&d.setAttribute("morphNormal"+T,b[C]),i[T]=E,S+=E):(v&&d.hasAttribute("morphTarget"+T)===!0&&d.deleteAttribute("morphTarget"+T),b&&d.hasAttribute("morphNormal"+T)===!0&&d.deleteAttribute("morphNormal"+T),i[T]=0)}const N=d.morphTargetsRelative?1:1-S;h.getUniforms().setValue(t,"morphTargetBaseInfluence",N),h.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function vSe(t,e,n,r){let i=new WeakMap;function s(c){const u=r.render.frame,d=c.geometry,h=e.get(c,d);if(i.get(h)!==u&&(e.update(h),i.set(h,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 p=c.skeleton;i.get(p)!==u&&(p.update(),i.set(p,u))}return h}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 iX extends $s{constructor(e,n,r,i,s,o,l,c,u,d){if(d=d!==void 0?d:Vf,d!==Vf&&d!==Zg)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===Vf&&(r=Jd),r===void 0&&d===Zg&&(r=$f),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:La,this.minFilter=c!==void 0?c:La,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 aX=new $s,sX=new iX(1,1);sX.compareFunction=$K;const oX=new KK,lX=new iwe,cX=new nX,c6=[],u6=[],d6=new Float32Array(16),h6=new Float32Array(9),f6=new Float32Array(4);function Mx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let s=c6[i];if(s===void 0&&(s=new Float32Array(i),c6[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 ra(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 ia(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function AM(t,e){let n=u6[e];n===void 0&&(n=new Int32Array(e),u6[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function wSe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function _Se(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(ra(n,e))return;t.uniform2fv(this.addr,e),ia(n,e)}}function SSe(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(ra(n,e))return;t.uniform3fv(this.addr,e),ia(n,e)}}function NSe(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(ra(n,e))return;t.uniform4fv(this.addr,e),ia(n,e)}}function MSe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ra(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ia(n,e)}else{if(ra(n,r))return;f6.set(r),t.uniformMatrix2fv(this.addr,!1,f6),ia(n,r)}}function kSe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ra(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ia(n,e)}else{if(ra(n,r))return;h6.set(r),t.uniformMatrix3fv(this.addr,!1,h6),ia(n,r)}}function ESe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(ra(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ia(n,e)}else{if(ra(n,r))return;d6.set(r),t.uniformMatrix4fv(this.addr,!1,d6),ia(n,r)}}function TSe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function ASe(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(ra(n,e))return;t.uniform2iv(this.addr,e),ia(n,e)}}function CSe(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(ra(n,e))return;t.uniform3iv(this.addr,e),ia(n,e)}}function jSe(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(ra(n,e))return;t.uniform4iv(this.addr,e),ia(n,e)}}function PSe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function DSe(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(ra(n,e))return;t.uniform2uiv(this.addr,e),ia(n,e)}}function RSe(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(ra(n,e))return;t.uniform3uiv(this.addr,e),ia(n,e)}}function OSe(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(ra(n,e))return;t.uniform4uiv(this.addr,e),ia(n,e)}}function LSe(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?sX:aX;n.setTexture2D(e||s,i)}function FSe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||lX,i)}function ISe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||cX,i)}function USe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||oX,i)}function zSe(t){switch(t){case 5126:return wSe;case 35664:return _Se;case 35665:return SSe;case 35666:return NSe;case 35674:return MSe;case 35675:return kSe;case 35676:return ESe;case 5124:case 35670:return TSe;case 35667:case 35671:return ASe;case 35668:case 35672:return CSe;case 35669:case 35673:return jSe;case 5125:return PSe;case 36294:return DSe;case 36295:return RSe;case 36296:return OSe;case 35678:case 36198:case 36298:case 36306:case 35682:return LSe;case 35679:case 36299:case 36307:return FSe;case 35680:case 36300:case 36308:case 36293:return ISe;case 36289:case 36303:case 36311:case 36292:return USe}}function BSe(t,e){t.uniform1fv(this.addr,e)}function HSe(t,e){const n=Mx(e,this.size,2);t.uniform2fv(this.addr,n)}function $Se(t,e){const n=Mx(e,this.size,3);t.uniform3fv(this.addr,n)}function VSe(t,e){const n=Mx(e,this.size,4);t.uniform4fv(this.addr,n)}function GSe(t,e){const n=Mx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function qSe(t,e){const n=Mx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function WSe(t,e){const n=Mx(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function KSe(t,e){t.uniform1iv(this.addr,e)}function XSe(t,e){t.uniform2iv(this.addr,e)}function YSe(t,e){t.uniform3iv(this.addr,e)}function QSe(t,e){t.uniform4iv(this.addr,e)}function ZSe(t,e){t.uniform1uiv(this.addr,e)}function JSe(t,e){t.uniform2uiv(this.addr,e)}function eNe(t,e){t.uniform3uiv(this.addr,e)}function tNe(t,e){t.uniform4uiv(this.addr,e)}function nNe(t,e,n){const r=this.cache,i=e.length,s=AM(n,i);ra(r,s)||(t.uniform1iv(this.addr,s),ia(r,s));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||aX,s[o])}function rNe(t,e,n){const r=this.cache,i=e.length,s=AM(n,i);ra(r,s)||(t.uniform1iv(this.addr,s),ia(r,s));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||lX,s[o])}function iNe(t,e,n){const r=this.cache,i=e.length,s=AM(n,i);ra(r,s)||(t.uniform1iv(this.addr,s),ia(r,s));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||cX,s[o])}function aNe(t,e,n){const r=this.cache,i=e.length,s=AM(n,i);ra(r,s)||(t.uniform1iv(this.addr,s),ia(r,s));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||oX,s[o])}function sNe(t){switch(t){case 5126:return BSe;case 35664:return HSe;case 35665:return $Se;case 35666:return VSe;case 35674:return GSe;case 35675:return qSe;case 35676:return WSe;case 5124:case 35670:return KSe;case 35667:case 35671:return XSe;case 35668:case 35672:return YSe;case 35669:case 35673:return QSe;case 5125:return ZSe;case 36294:return JSe;case 36295:return eNe;case 36296:return tNe;case 35678:case 36198:case 36298:case 36306:case 35682:return nNe;case 35679:case 36299:case 36307:return rNe;case 35680:case 36300:case 36308:case 36293:return iNe;case 36289:case 36303:case 36311:case 36292:return aNe}}class oNe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=zSe(n.type)}}class lNe{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=sNe(n.type)}}class cNe{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 hA=/(\w+)(\])?(\[|\.)?/g;function m6(t,e){t.seq.push(e),t.map[e.id]=e}function uNe(t,e,n){const r=t.name,i=r.length;for(hA.lastIndex=0;;){const s=hA.exec(r),o=hA.lastIndex;let l=s[1];const c=s[2]==="]",u=s[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){m6(n,u===void 0?new oNe(l,t,e):new lNe(l,t,e));break}else{let h=n.map[l];h===void 0&&(h=new cNe(l),m6(n,h)),n=h}}}class E1{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const s=e.getActiveUniform(n,i),o=e.getUniformLocation(n,s.name);uNe(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 p6(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const dNe=37297;let hNe=0;function fNe(t,e){const n=t.split(`
  7342. `),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(`
  7343. `)}function mNe(t){const e=Er.getPrimaries(Er.workingColorSpace),n=Er.getPrimaries(t);let r;switch(e===n?r="":e===aS&&n===iS?r="LinearDisplayP3ToLinearSRGB":e===iS&&n===aS&&(r="LinearSRGBToLinearDisplayP3"),t){case Iu:case EM:return[r,"LinearTransferOETF"];case Fa:case aO:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function g6(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()+`
  7344. `+i+`
  7345. `+fNe(t.getShaderSource(e),o)}else return i}function pNe(t,e){const n=mNe(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function gNe(t,e){let n;switch(e){case pve:n="Linear";break;case gve:n="Reinhard";break;case xve:n="OptimizedCineon";break;case bve:n="ACESFilmic";break;case yve:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function xNe(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(o0).join(`
  7346. `)}function bNe(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
  7347. `)}function yNe(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 o0(t){return t!==""}function x6(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 b6(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const vNe=/^[ \t]*#include +<([\w\d./]+)>/gm;function v3(t){return t.replace(vNe,_Ne)}const wNe=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function _Ne(t,e){let n=An[e];if(n===void 0){const r=wNe.get(e);if(r!==void 0)n=An[r],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return v3(n)}const SNe=/#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 y6(t){return t.replace(SNe,NNe)}function NNe(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 v6(t){let e="precision "+t.precision+` float;
  7348. precision `+t.precision+" int;";return t.precision==="highp"?e+=`
  7349. #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
  7350. #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
  7351. #define LOW_PRECISION`),e}function MNe(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===PK?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===$ye?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===du&&(e="SHADOWMAP_TYPE_VSM"),e}function kNe(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Yg:case Qg:e="ENVMAP_TYPE_CUBE";break;case kM:e="ENVMAP_TYPE_CUBE_UV";break}return e}function ENe(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Qg:e="ENVMAP_MODE_REFRACTION";break}return e}function TNe(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case rO:e="ENVMAP_BLENDING_MULTIPLY";break;case fve:e="ENVMAP_BLENDING_MIX";break;case mve:e="ENVMAP_BLENDING_ADD";break}return e}function ANe(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 CNe(t,e,n,r){const i=t.getContext(),s=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=MNe(n),u=kNe(n),d=ENe(n),h=TNe(n),p=ANe(n),m=n.isWebGL2?"":xNe(n),x=bNe(s),y=i.createProgram();let v,b,S=n.glslVersion?"#version "+n.glslVersion+`
  7352. `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(o0).join(`
  7353. `),v.length>0&&(v+=`
  7354. `),b=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(o0).join(`
  7355. `),b.length>0&&(b+=`
  7356. `)):(v=[v6(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",`
  7357. `].filter(o0).join(`
  7358. `),b=[m,v6(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 "+h:"",p?"#define CUBEUV_TEXEL_WIDTH "+p.texelWidth:"",p?"#define CUBEUV_TEXEL_HEIGHT "+p.texelHeight:"",p?"#define CUBEUV_MAX_MIP "+p.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!==dh?"#define TONE_MAPPING":"",n.toneMapping!==dh?An.tonemapping_pars_fragment:"",n.toneMapping!==dh?gNe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",An.colorspace_pars_fragment,pNe("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
  7359. `].filter(o0).join(`
  7360. `)),o=v3(o),o=x6(o,n),o=b6(o,n),l=v3(l),l=x6(l,n),l=b6(l,n),o=y6(o),l=y6(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(S=`#version 300 es
  7361. `,v=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
  7362. `)+`
  7363. `+v,b=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===I8?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===I8?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
  7364. `)+`
  7365. `+b);const N=S+v+o,T=S+b+l,k=p6(i,i.VERTEX_SHADER,N),C=p6(i,i.FRAGMENT_SHADER,T);i.attachShader(y,k),i.attachShader(y,C),n.index0AttributeName!==void 0?i.bindAttribLocation(y,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(y,0,"position"),i.linkProgram(y);function E(I){if(t.debug.checkShaderErrors){const L=i.getProgramInfoLog(y).trim(),U=i.getShaderInfoLog(k).trim(),j=i.getShaderInfoLog(C).trim();let V=!0,K=!0;if(i.getProgramParameter(y,i.LINK_STATUS)===!1)if(V=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,y,k,C);else{const z=g6(i,k,"vertex"),X=g6(i,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(y,i.VALIDATE_STATUS)+`
  7366. Program Info Log: `+L+`
  7367. `+z+`
  7368. `+X)}else L!==""?console.warn("THREE.WebGLProgram: Program Info Log:",L):(U===""||j==="")&&(K=!1);K&&(I.diagnostics={runnable:V,programLog:L,vertexShader:{log:U,prefix:v},fragmentShader:{log:j,prefix:b}})}i.deleteShader(k),i.deleteShader(C),P=new E1(i,y),A=yNe(i,y)}let P;this.getUniforms=function(){return P===void 0&&E(this),P};let A;this.getAttributes=function(){return A===void 0&&E(this),A};let D=n.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=i.getProgramParameter(y,dNe)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(y),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=hNe++,this.cacheKey=e,this.usedTimes=1,this.program=y,this.vertexShader=k,this.fragmentShader=C,this}let jNe=0;class PNe{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 DNe(e),n.set(e,r)),r}}class DNe{constructor(e){this.id=jNe++,this.code=e,this.usedTimes=0}}function RNe(t,e,n,r,i,s,o){const l=new XK,c=new PNe,u=[],d=i.isWebGL2,h=i.logarithmicDepthBuffer,p=i.vertexTextures;let m=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 v(A,D,I,L,U){const j=L.fog,V=U.geometry,K=A.isMeshStandardMaterial?L.environment:null,z=(A.isMeshStandardMaterial?n:e).get(A.envMap||K),X=z&&z.mapping===kM?z.image.height:null,Y=x[A.type];A.precision!==null&&(m=i.getMaxPrecision(A.precision),m!==A.precision&&console.warn("THREE.WebGLProgram.getParameters:",A.precision,"not supported, using",m,"instead."));const te=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,$=te!==void 0?te.length:0;let W=0;V.morphAttributes.position!==void 0&&(W=1),V.morphAttributes.normal!==void 0&&(W=2),V.morphAttributes.color!==void 0&&(W=3);let ne,re,ge,me;if(Y){const jt=Is[Y];ne=jt.vertexShader,re=jt.fragmentShader}else ne=A.vertexShader,re=A.fragmentShader,c.update(A),ge=c.getVertexShaderID(A),me=c.getFragmentShaderID(A);const ue=t.getRenderTarget(),Te=U.isInstancedMesh===!0,ie=U.isBatchedMesh===!0,Ce=!!A.map,Fe=!!A.matcap,xe=!!z,Ze=!!A.aoMap,G=!!A.lightMap,Q=!!A.bumpMap,de=!!A.normalMap,q=!!A.displacementMap,ee=!!A.emissiveMap,B=!!A.metalnessMap,he=!!A.roughnessMap,ke=A.anisotropy>0,pe=A.clearcoat>0,H=A.iridescence>0,O=A.sheen>0,J=A.transmission>0,le=ke&&!!A.anisotropyMap,Se=pe&&!!A.clearcoatMap,we=pe&&!!A.clearcoatNormalMap,ae=pe&&!!A.clearcoatRoughnessMap,Le=H&&!!A.iridescenceMap,Be=H&&!!A.iridescenceThicknessMap,Ve=O&&!!A.sheenColorMap,He=O&&!!A.sheenRoughnessMap,be=!!A.specularMap,Pe=!!A.specularColorMap,Ie=!!A.specularIntensityMap,_e=J&&!!A.transmissionMap,Ke=J&&!!A.thicknessMap,Me=!!A.gradientMap,it=!!A.alphaMap,Ee=A.alphaTest>0,Xe=!!A.alphaHash,ze=!!A.extensions,ce=!!V.attributes.uv1,$e=!!V.attributes.uv2,ye=!!V.attributes.uv3;let Je=dh;return A.toneMapped&&(ue===null||ue.isXRRenderTarget===!0)&&(Je=t.toneMapping),{isWebGL2:d,shaderID:Y,shaderType:A.type,shaderName:A.name,vertexShader:ne,fragmentShader:re,defines:A.defines,customVertexShaderID:ge,customFragmentShaderID:me,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:m,batching:ie,instancing:Te,instancingColor:Te&&U.instanceColor!==null,supportsVertexTextures:p,outputColorSpace:ue===null?t.outputColorSpace:ue.isXRRenderTarget===!0?ue.texture.colorSpace:Iu,map:Ce,matcap:Fe,envMap:xe,envMapMode:xe&&z.mapping,envMapCubeUVHeight:X,aoMap:Ze,lightMap:G,bumpMap:Q,normalMap:de,displacementMap:p&&q,emissiveMap:ee,normalMapObjectSpace:de&&A.normalMapType===jve,normalMapTangentSpace:de&&A.normalMapType===HK,metalnessMap:B,roughnessMap:he,anisotropy:ke,anisotropyMap:le,clearcoat:pe,clearcoatMap:Se,clearcoatNormalMap:we,clearcoatRoughnessMap:ae,iridescence:H,iridescenceMap:Le,iridescenceThicknessMap:Be,sheen:O,sheenColorMap:Ve,sheenRoughnessMap:He,specularMap:be,specularColorMap:Pe,specularIntensityMap:Ie,transmission:J,transmissionMap:_e,thicknessMap:Ke,gradientMap:Me,opaque:A.transparent===!1&&A.blending===Cg,alphaMap:it,alphaTest:Ee,alphaHash:Xe,combine:A.combine,mapUv:Ce&&y(A.map.channel),aoMapUv:Ze&&y(A.aoMap.channel),lightMapUv:G&&y(A.lightMap.channel),bumpMapUv:Q&&y(A.bumpMap.channel),normalMapUv:de&&y(A.normalMap.channel),displacementMapUv:q&&y(A.displacementMap.channel),emissiveMapUv:ee&&y(A.emissiveMap.channel),metalnessMapUv:B&&y(A.metalnessMap.channel),roughnessMapUv:he&&y(A.roughnessMap.channel),anisotropyMapUv:le&&y(A.anisotropyMap.channel),clearcoatMapUv:Se&&y(A.clearcoatMap.channel),clearcoatNormalMapUv:we&&y(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ae&&y(A.clearcoatRoughnessMap.channel),iridescenceMapUv:Le&&y(A.iridescenceMap.channel),iridescenceThicknessMapUv:Be&&y(A.iridescenceThicknessMap.channel),sheenColorMapUv:Ve&&y(A.sheenColorMap.channel),sheenRoughnessMapUv:He&&y(A.sheenRoughnessMap.channel),specularMapUv:be&&y(A.specularMap.channel),specularColorMapUv:Pe&&y(A.specularColorMap.channel),specularIntensityMapUv:Ie&&y(A.specularIntensityMap.channel),transmissionMapUv:_e&&y(A.transmissionMap.channel),thicknessMapUv:Ke&&y(A.thicknessMap.channel),alphaMapUv:it&&y(A.alphaMap.channel),vertexTangents:!!V.attributes.tangent&&(de||ke),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,vertexUv1s:ce,vertexUv2s:$e,vertexUv3s:ye,pointsUvs:U.isPoints===!0&&!!V.attributes.uv&&(Ce||it),fog:!!j,useFog:A.fog===!0,fogExp2:j&&j.isFogExp2,flatShading:A.flatShading===!0,sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:h,skinning:U.isSkinnedMesh===!0,morphTargets:V.morphAttributes.position!==void 0,morphNormals:V.morphAttributes.normal!==void 0,morphColors:V.morphAttributes.color!==void 0,morphTargetsCount:$,morphTextureStride:W,numDirLights:D.directional.length,numPointLights:D.point.length,numSpotLights:D.spot.length,numSpotLightMaps:D.spotLightMap.length,numRectAreaLights:D.rectArea.length,numHemiLights:D.hemi.length,numDirLightShadows:D.directionalShadowMap.length,numPointLightShadows:D.pointShadowMap.length,numSpotLightShadows:D.spotShadowMap.length,numSpotLightShadowsWithMaps:D.numSpotLightShadowsWithMaps,numLightProbes:D.numLightProbes,numClippingPlanes:o.numPlanes,numClipIntersection:o.numIntersection,dithering:A.dithering,shadowMapEnabled:t.shadowMap.enabled&&I.length>0,shadowMapType:t.shadowMap.type,toneMapping:Je,useLegacyLights:t._useLegacyLights,decodeVideoTexture:Ce&&A.map.isVideoTexture===!0&&Er.getTransfer(A.map.colorSpace)===Gr,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===pu,flipSided:A.side===Hs,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionDerivatives:ze&&A.extensions.derivatives===!0,extensionFragDepth:ze&&A.extensions.fragDepth===!0,extensionDrawBuffers:ze&&A.extensions.drawBuffers===!0,extensionShaderTextureLOD:ze&&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 b(A){const D=[];if(A.shaderID?D.push(A.shaderID):(D.push(A.customVertexShaderID),D.push(A.customFragmentShaderID)),A.defines!==void 0)for(const I in A.defines)D.push(I),D.push(A.defines[I]);return A.isRawShaderMaterial===!1&&(S(D,A),N(D,A),D.push(t.outputColorSpace)),D.push(A.customProgramCacheKey),D.join()}function S(A,D){A.push(D.precision),A.push(D.outputColorSpace),A.push(D.envMapMode),A.push(D.envMapCubeUVHeight),A.push(D.mapUv),A.push(D.alphaMapUv),A.push(D.lightMapUv),A.push(D.aoMapUv),A.push(D.bumpMapUv),A.push(D.normalMapUv),A.push(D.displacementMapUv),A.push(D.emissiveMapUv),A.push(D.metalnessMapUv),A.push(D.roughnessMapUv),A.push(D.anisotropyMapUv),A.push(D.clearcoatMapUv),A.push(D.clearcoatNormalMapUv),A.push(D.clearcoatRoughnessMapUv),A.push(D.iridescenceMapUv),A.push(D.iridescenceThicknessMapUv),A.push(D.sheenColorMapUv),A.push(D.sheenRoughnessMapUv),A.push(D.specularMapUv),A.push(D.specularColorMapUv),A.push(D.specularIntensityMapUv),A.push(D.transmissionMapUv),A.push(D.thicknessMapUv),A.push(D.combine),A.push(D.fogExp2),A.push(D.sizeAttenuation),A.push(D.morphTargetsCount),A.push(D.morphAttributeCount),A.push(D.numDirLights),A.push(D.numPointLights),A.push(D.numSpotLights),A.push(D.numSpotLightMaps),A.push(D.numHemiLights),A.push(D.numRectAreaLights),A.push(D.numDirLightShadows),A.push(D.numPointLightShadows),A.push(D.numSpotLightShadows),A.push(D.numSpotLightShadowsWithMaps),A.push(D.numLightProbes),A.push(D.shadowMapType),A.push(D.toneMapping),A.push(D.numClippingPlanes),A.push(D.numClipIntersection),A.push(D.depthPacking)}function N(A,D){l.disableAll(),D.isWebGL2&&l.enable(0),D.supportsVertexTextures&&l.enable(1),D.instancing&&l.enable(2),D.instancingColor&&l.enable(3),D.matcap&&l.enable(4),D.envMap&&l.enable(5),D.normalMapObjectSpace&&l.enable(6),D.normalMapTangentSpace&&l.enable(7),D.clearcoat&&l.enable(8),D.iridescence&&l.enable(9),D.alphaTest&&l.enable(10),D.vertexColors&&l.enable(11),D.vertexAlphas&&l.enable(12),D.vertexUv1s&&l.enable(13),D.vertexUv2s&&l.enable(14),D.vertexUv3s&&l.enable(15),D.vertexTangents&&l.enable(16),D.anisotropy&&l.enable(17),D.alphaHash&&l.enable(18),D.batching&&l.enable(19),A.push(l.mask),l.disableAll(),D.fog&&l.enable(0),D.useFog&&l.enable(1),D.flatShading&&l.enable(2),D.logarithmicDepthBuffer&&l.enable(3),D.skinning&&l.enable(4),D.morphTargets&&l.enable(5),D.morphNormals&&l.enable(6),D.morphColors&&l.enable(7),D.premultipliedAlpha&&l.enable(8),D.shadowMapEnabled&&l.enable(9),D.useLegacyLights&&l.enable(10),D.doubleSided&&l.enable(11),D.flipSided&&l.enable(12),D.useDepthPacking&&l.enable(13),D.dithering&&l.enable(14),D.transmission&&l.enable(15),D.sheen&&l.enable(16),D.opaque&&l.enable(17),D.pointsUvs&&l.enable(18),D.decodeVideoTexture&&l.enable(19),A.push(l.mask)}function T(A){const D=x[A.type];let I;if(D){const L=Is[D];I=lO.clone(L.uniforms)}else I=A.uniforms;return I}function k(A,D){let I;for(let L=0,U=u.length;L<U;L++){const j=u[L];if(j.cacheKey===D){I=j,++I.usedTimes;break}}return I===void 0&&(I=new CNe(t,D,A,s),u.push(I)),I}function C(A){if(--A.usedTimes===0){const D=u.indexOf(A);u[D]=u[u.length-1],u.pop(),A.destroy()}}function E(A){c.remove(A)}function P(){c.dispose()}return{getParameters:v,getProgramCacheKey:b,getUniforms:T,acquireProgram:k,releaseProgram:C,releaseShaderCache:E,programs:u,dispose:P}}function ONe(){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 LNe(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 w6(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 _6(){const t=[];let e=0;const n=[],r=[],i=[];function s(){e=0,n.length=0,r.length=0,i.length=0}function o(h,p,m,x,y,v){let b=t[e];return b===void 0?(b={id:h.id,object:h,geometry:p,material:m,groupOrder:x,renderOrder:h.renderOrder,z:y,group:v},t[e]=b):(b.id=h.id,b.object=h,b.geometry=p,b.material=m,b.groupOrder=x,b.renderOrder=h.renderOrder,b.z=y,b.group=v),e++,b}function l(h,p,m,x,y,v){const b=o(h,p,m,x,y,v);m.transmission>0?r.push(b):m.transparent===!0?i.push(b):n.push(b)}function c(h,p,m,x,y,v){const b=o(h,p,m,x,y,v);m.transmission>0?r.unshift(b):m.transparent===!0?i.unshift(b):n.unshift(b)}function u(h,p){n.length>1&&n.sort(h||LNe),r.length>1&&r.sort(p||w6),i.length>1&&i.sort(p||w6)}function d(){for(let h=e,p=t.length;h<p;h++){const m=t[h];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:s,push:l,unshift:c,finish:d,sort:u}}function FNe(){let t=new WeakMap;function e(r,i){const s=t.get(r);let o;return s===void 0?(o=new _6,t.set(r,[o])):i>=s.length?(o=new _6,s.push(o)):o=s[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function INe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new We,color:new Jt};break;case"SpotLight":n={position:new We,direction:new We,color:new Jt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new We,color:new Jt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new We,skyColor:new Jt,groundColor:new Jt};break;case"RectAreaLight":n={color:new Jt,position:new We,halfWidth:new We,halfHeight:new We};break}return t[e.id]=n,n}}}function UNe(){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 bn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new bn,shadowCameraNear:1,shadowCameraFar:1e3};break}return t[e.id]=n,n}}}let zNe=0;function BNe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function HNe(t,e){const n=new INe,r=UNe(),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 We);const s=new We,o=new zr,l=new zr;function c(d,h){let p=0,m=0,x=0;for(let L=0;L<9;L++)i.probe[L].set(0,0,0);let y=0,v=0,b=0,S=0,N=0,T=0,k=0,C=0,E=0,P=0,A=0;d.sort(BNe);const D=h===!0?Math.PI:1;for(let L=0,U=d.length;L<U;L++){const j=d[L],V=j.color,K=j.intensity,z=j.distance,X=j.shadow&&j.shadow.map?j.shadow.map.texture:null;if(j.isAmbientLight)p+=V.r*K*D,m+=V.g*K*D,x+=V.b*K*D;else if(j.isLightProbe){for(let Y=0;Y<9;Y++)i.probe[Y].addScaledVector(j.sh.coefficients[Y],K);A++}else if(j.isDirectionalLight){const Y=n.get(j);if(Y.color.copy(j.color).multiplyScalar(j.intensity*D),j.castShadow){const te=j.shadow,$=r.get(j);$.shadowBias=te.bias,$.shadowNormalBias=te.normalBias,$.shadowRadius=te.radius,$.shadowMapSize=te.mapSize,i.directionalShadow[y]=$,i.directionalShadowMap[y]=X,i.directionalShadowMatrix[y]=j.shadow.matrix,T++}i.directional[y]=Y,y++}else if(j.isSpotLight){const Y=n.get(j);Y.position.setFromMatrixPosition(j.matrixWorld),Y.color.copy(V).multiplyScalar(K*D),Y.distance=z,Y.coneCos=Math.cos(j.angle),Y.penumbraCos=Math.cos(j.angle*(1-j.penumbra)),Y.decay=j.decay,i.spot[b]=Y;const te=j.shadow;if(j.map&&(i.spotLightMap[E]=j.map,E++,te.updateMatrices(j),j.castShadow&&P++),i.spotLightMatrix[b]=te.matrix,j.castShadow){const $=r.get(j);$.shadowBias=te.bias,$.shadowNormalBias=te.normalBias,$.shadowRadius=te.radius,$.shadowMapSize=te.mapSize,i.spotShadow[b]=$,i.spotShadowMap[b]=X,C++}b++}else if(j.isRectAreaLight){const Y=n.get(j);Y.color.copy(V).multiplyScalar(K),Y.halfWidth.set(j.width*.5,0,0),Y.halfHeight.set(0,j.height*.5,0),i.rectArea[S]=Y,S++}else if(j.isPointLight){const Y=n.get(j);if(Y.color.copy(j.color).multiplyScalar(j.intensity*D),Y.distance=j.distance,Y.decay=j.decay,j.castShadow){const te=j.shadow,$=r.get(j);$.shadowBias=te.bias,$.shadowNormalBias=te.normalBias,$.shadowRadius=te.radius,$.shadowMapSize=te.mapSize,$.shadowCameraNear=te.camera.near,$.shadowCameraFar=te.camera.far,i.pointShadow[v]=$,i.pointShadowMap[v]=X,i.pointShadowMatrix[v]=j.shadow.matrix,k++}i.point[v]=Y,v++}else if(j.isHemisphereLight){const Y=n.get(j);Y.skyColor.copy(j.color).multiplyScalar(K*D),Y.groundColor.copy(j.groundColor).multiplyScalar(K*D),i.hemi[N]=Y,N++}}S>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ot.LTC_FLOAT_1,i.rectAreaLTC2=Ot.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Ot.LTC_HALF_1,i.rectAreaLTC2=Ot.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),i.ambient[0]=p,i.ambient[1]=m,i.ambient[2]=x;const I=i.hash;(I.directionalLength!==y||I.pointLength!==v||I.spotLength!==b||I.rectAreaLength!==S||I.hemiLength!==N||I.numDirectionalShadows!==T||I.numPointShadows!==k||I.numSpotShadows!==C||I.numSpotMaps!==E||I.numLightProbes!==A)&&(i.directional.length=y,i.spot.length=b,i.rectArea.length=S,i.point.length=v,i.hemi.length=N,i.directionalShadow.length=T,i.directionalShadowMap.length=T,i.pointShadow.length=k,i.pointShadowMap.length=k,i.spotShadow.length=C,i.spotShadowMap.length=C,i.directionalShadowMatrix.length=T,i.pointShadowMatrix.length=k,i.spotLightMatrix.length=C+E-P,i.spotLightMap.length=E,i.numSpotLightShadowsWithMaps=P,i.numLightProbes=A,I.directionalLength=y,I.pointLength=v,I.spotLength=b,I.rectAreaLength=S,I.hemiLength=N,I.numDirectionalShadows=T,I.numPointShadows=k,I.numSpotShadows=C,I.numSpotMaps=E,I.numLightProbes=A,i.version=zNe++)}function u(d,h){let p=0,m=0,x=0,y=0,v=0;const b=h.matrixWorldInverse;for(let S=0,N=d.length;S<N;S++){const T=d[S];if(T.isDirectionalLight){const k=i.directional[p];k.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),k.direction.sub(s),k.direction.transformDirection(b),p++}else if(T.isSpotLight){const k=i.spot[x];k.position.setFromMatrixPosition(T.matrixWorld),k.position.applyMatrix4(b),k.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),k.direction.sub(s),k.direction.transformDirection(b),x++}else if(T.isRectAreaLight){const k=i.rectArea[y];k.position.setFromMatrixPosition(T.matrixWorld),k.position.applyMatrix4(b),l.identity(),o.copy(T.matrixWorld),o.premultiply(b),l.extractRotation(o),k.halfWidth.set(T.width*.5,0,0),k.halfHeight.set(0,T.height*.5,0),k.halfWidth.applyMatrix4(l),k.halfHeight.applyMatrix4(l),y++}else if(T.isPointLight){const k=i.point[m];k.position.setFromMatrixPosition(T.matrixWorld),k.position.applyMatrix4(b),m++}else if(T.isHemisphereLight){const k=i.hemi[v];k.direction.setFromMatrixPosition(T.matrixWorld),k.direction.transformDirection(b),v++}}}return{setup:c,setupView:u,state:i}}function S6(t,e){const n=new HNe(t,e),r=[],i=[];function s(){r.length=0,i.length=0}function o(h){r.push(h)}function l(h){i.push(h)}function c(h){n.setup(r,h)}function u(h){n.setupView(r,h)}return{init:s,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:u,pushLight:o,pushShadow:l}}function $Ne(t,e){let n=new WeakMap;function r(s,o=0){const l=n.get(s);let c;return l===void 0?(c=new S6(t,e),n.set(s,[c])):o>=l.length?(c=new S6(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class VNe extends Nx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Ave,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 GNe extends Nx{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 qNe=`void main() {
  7369. gl_Position = vec4( position, 1.0 );
  7370. }`,WNe=`uniform sampler2D shadow_pass;
  7371. uniform vec2 resolution;
  7372. uniform float radius;
  7373. #include <packing>
  7374. void main() {
  7375. const float samples = float( VSM_SAMPLES );
  7376. float mean = 0.0;
  7377. float squared_mean = 0.0;
  7378. float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
  7379. float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
  7380. for ( float i = 0.0; i < samples; i ++ ) {
  7381. float uvOffset = uvStart + i * uvStride;
  7382. #ifdef HORIZONTAL_PASS
  7383. vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
  7384. mean += distribution.x;
  7385. squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
  7386. #else
  7387. float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
  7388. mean += depth;
  7389. squared_mean += depth * depth;
  7390. #endif
  7391. }
  7392. mean = mean / samples;
  7393. squared_mean = squared_mean / samples;
  7394. float std_dev = sqrt( squared_mean - mean * mean );
  7395. gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
  7396. }`;function KNe(t,e,n){let r=new TM;const i=new bn,s=new bn,o=new Cr,l=new VNe({depthPacking:Cve}),c=new GNe,u={},d=n.maxTextureSize,h={[Mh]:Hs,[Hs]:Mh,[pu]:pu},p=new kh({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new bn},radius:{value:4}},vertexShader:qNe,fragmentShader:WNe}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const x=new ns;x.setAttribute("position",new yo(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const y=new Ll(x,p),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=PK;let b=this.type;this.render=function(k,C,E){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||k.length===0)return;const P=t.getRenderTarget(),A=t.getActiveCubeFace(),D=t.getActiveMipmapLevel(),I=t.state;I.setBlending(uh),I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const L=b!==du&&this.type===du,U=b===du&&this.type!==du;for(let j=0,V=k.length;j<V;j++){const K=k[j],z=K.shadow;if(z===void 0){console.warn("THREE.WebGLShadowMap:",K,"has no shadow.");continue}if(z.autoUpdate===!1&&z.needsUpdate===!1)continue;i.copy(z.mapSize);const X=z.getFrameExtents();if(i.multiply(X),s.copy(z.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(s.x=Math.floor(d/X.x),i.x=s.x*X.x,z.mapSize.x=s.x),i.y>d&&(s.y=Math.floor(d/X.y),i.y=s.y*X.y,z.mapSize.y=s.y)),z.map===null||L===!0||U===!0){const te=this.type!==du?{minFilter:La,magFilter:La}:{};z.map!==null&&z.map.dispose(),z.map=new fm(i.x,i.y,te),z.map.texture.name=K.name+".shadowMap",z.camera.updateProjectionMatrix()}t.setRenderTarget(z.map),t.clear();const Y=z.getViewportCount();for(let te=0;te<Y;te++){const $=z.getViewport(te);o.set(s.x*$.x,s.y*$.y,s.x*$.z,s.y*$.w),I.viewport(o),z.updateMatrices(K,te),r=z.getFrustum(),T(C,E,z.camera,K,this.type)}z.isPointLightShadow!==!0&&this.type===du&&S(z,E),z.needsUpdate=!1}b=this.type,v.needsUpdate=!1,t.setRenderTarget(P,A,D)};function S(k,C){const E=e.update(y);p.defines.VSM_SAMPLES!==k.blurSamples&&(p.defines.VSM_SAMPLES=k.blurSamples,m.defines.VSM_SAMPLES=k.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),k.mapPass===null&&(k.mapPass=new fm(i.x,i.y)),p.uniforms.shadow_pass.value=k.map.texture,p.uniforms.resolution.value=k.mapSize,p.uniforms.radius.value=k.radius,t.setRenderTarget(k.mapPass),t.clear(),t.renderBufferDirect(C,null,E,p,y,null),m.uniforms.shadow_pass.value=k.mapPass.texture,m.uniforms.resolution.value=k.mapSize,m.uniforms.radius.value=k.radius,t.setRenderTarget(k.map),t.clear(),t.renderBufferDirect(C,null,E,m,y,null)}function N(k,C,E,P){let A=null;const D=E.isPointLight===!0?k.customDistanceMaterial:k.customDepthMaterial;if(D!==void 0)A=D;else if(A=E.isPointLight===!0?c:l,t.localClippingEnabled&&C.clipShadows===!0&&Array.isArray(C.clippingPlanes)&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0||C.map&&C.alphaTest>0){const I=A.uuid,L=C.uuid;let U=u[I];U===void 0&&(U={},u[I]=U);let j=U[L];j===void 0&&(j=A.clone(),U[L]=j),A=j}if(A.visible=C.visible,A.wireframe=C.wireframe,P===du?A.side=C.shadowSide!==null?C.shadowSide:C.side:A.side=C.shadowSide!==null?C.shadowSide:h[C.side],A.alphaMap=C.alphaMap,A.alphaTest=C.alphaTest,A.map=C.map,A.clipShadows=C.clipShadows,A.clippingPlanes=C.clippingPlanes,A.clipIntersection=C.clipIntersection,A.displacementMap=C.displacementMap,A.displacementScale=C.displacementScale,A.displacementBias=C.displacementBias,A.wireframeLinewidth=C.wireframeLinewidth,A.linewidth=C.linewidth,E.isPointLight===!0&&A.isMeshDistanceMaterial===!0){const I=t.properties.get(A);I.light=E}return A}function T(k,C,E,P,A){if(k.visible===!1)return;if(k.layers.test(C.layers)&&(k.isMesh||k.isLine||k.isPoints)&&(k.castShadow||k.receiveShadow&&A===du)&&(!k.frustumCulled||r.intersectsObject(k))){k.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,k.matrixWorld);const L=e.update(k),U=k.material;if(Array.isArray(U)){const j=L.groups;for(let V=0,K=j.length;V<K;V++){const z=j[V],X=U[z.materialIndex];if(X&&X.visible){const Y=N(k,X,P,A);k.onBeforeShadow(t,k,C,E,L,Y,z),t.renderBufferDirect(E,null,L,Y,k,z),k.onAfterShadow(t,k,C,E,L,Y,z)}}}else if(U.visible){const j=N(k,U,P,A);k.onBeforeShadow(t,k,C,E,L,j,null),t.renderBufferDirect(E,null,L,j,k,null),k.onAfterShadow(t,k,C,E,L,j,null)}}const I=k.children;for(let L=0,U=I.length;L<U;L++)T(I[L],C,E,P,A)}}function XNe(t,e,n){const r=n.isWebGL2;function i(){let Ee=!1;const Xe=new Cr;let ze=null;const ce=new Cr(0,0,0,0);return{setMask:function($e){ze!==$e&&!Ee&&(t.colorMask($e,$e,$e,$e),ze=$e)},setLocked:function($e){Ee=$e},setClear:function($e,ye,Je,at,jt){jt===!0&&($e*=at,ye*=at,Je*=at),Xe.set($e,ye,Je,at),ce.equals(Xe)===!1&&(t.clearColor($e,ye,Je,at),ce.copy(Xe))},reset:function(){Ee=!1,ze=null,ce.set(-1,0,0,0)}}}function s(){let Ee=!1,Xe=null,ze=null,ce=null;return{setTest:function($e){$e?ie(t.DEPTH_TEST):Ce(t.DEPTH_TEST)},setMask:function($e){Xe!==$e&&!Ee&&(t.depthMask($e),Xe=$e)},setFunc:function($e){if(ze!==$e){switch($e){case sve:t.depthFunc(t.NEVER);break;case ove:t.depthFunc(t.ALWAYS);break;case lve:t.depthFunc(t.LESS);break;case nS:t.depthFunc(t.LEQUAL);break;case cve:t.depthFunc(t.EQUAL);break;case uve:t.depthFunc(t.GEQUAL);break;case dve:t.depthFunc(t.GREATER);break;case hve:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}ze=$e}},setLocked:function($e){Ee=$e},setClear:function($e){ce!==$e&&(t.clearDepth($e),ce=$e)},reset:function(){Ee=!1,Xe=null,ze=null,ce=null}}}function o(){let Ee=!1,Xe=null,ze=null,ce=null,$e=null,ye=null,Je=null,at=null,jt=null;return{setTest:function(Dt){Ee||(Dt?ie(t.STENCIL_TEST):Ce(t.STENCIL_TEST))},setMask:function(Dt){Xe!==Dt&&!Ee&&(t.stencilMask(Dt),Xe=Dt)},setFunc:function(Dt,yn,cn){(ze!==Dt||ce!==yn||$e!==cn)&&(t.stencilFunc(Dt,yn,cn),ze=Dt,ce=yn,$e=cn)},setOp:function(Dt,yn,cn){(ye!==Dt||Je!==yn||at!==cn)&&(t.stencilOp(Dt,yn,cn),ye=Dt,Je=yn,at=cn)},setLocked:function(Dt){Ee=Dt},setClear:function(Dt){jt!==Dt&&(t.clearStencil(Dt),jt=Dt)},reset:function(){Ee=!1,Xe=null,ze=null,ce=null,$e=null,ye=null,Je=null,at=null,jt=null}}}const l=new i,c=new s,u=new o,d=new WeakMap,h=new WeakMap;let p={},m={},x=new WeakMap,y=[],v=null,b=!1,S=null,N=null,T=null,k=null,C=null,E=null,P=null,A=new Jt(0,0,0),D=0,I=!1,L=null,U=null,j=null,V=null,K=null;const z=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let X=!1,Y=0;const te=t.getParameter(t.VERSION);te.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(te)[1]),X=Y>=1):te.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(te)[1]),X=Y>=2);let $=null,W={};const ne=t.getParameter(t.SCISSOR_BOX),re=t.getParameter(t.VIEWPORT),ge=new Cr().fromArray(ne),me=new Cr().fromArray(re);function ue(Ee,Xe,ze,ce){const $e=new Uint8Array(4),ye=t.createTexture();t.bindTexture(Ee,ye),t.texParameteri(Ee,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(Ee,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let Je=0;Je<ze;Je++)r&&(Ee===t.TEXTURE_3D||Ee===t.TEXTURE_2D_ARRAY)?t.texImage3D(Xe,0,t.RGBA,1,1,ce,0,t.RGBA,t.UNSIGNED_BYTE,$e):t.texImage2D(Xe+Je,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,$e);return ye}const Te={};Te[t.TEXTURE_2D]=ue(t.TEXTURE_2D,t.TEXTURE_2D,1),Te[t.TEXTURE_CUBE_MAP]=ue(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Te[t.TEXTURE_2D_ARRAY]=ue(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Te[t.TEXTURE_3D]=ue(t.TEXTURE_3D,t.TEXTURE_3D,1,1)),l.setClear(0,0,0,1),c.setClear(1),u.setClear(0),ie(t.DEPTH_TEST),c.setFunc(nS),ee(!1),B(a8),ie(t.CULL_FACE),de(uh);function ie(Ee){p[Ee]!==!0&&(t.enable(Ee),p[Ee]=!0)}function Ce(Ee){p[Ee]!==!1&&(t.disable(Ee),p[Ee]=!1)}function Fe(Ee,Xe){return m[Ee]!==Xe?(t.bindFramebuffer(Ee,Xe),m[Ee]=Xe,r&&(Ee===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=Xe),Ee===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=Xe)),!0):!1}function xe(Ee,Xe){let ze=y,ce=!1;if(Ee)if(ze=x.get(Xe),ze===void 0&&(ze=[],x.set(Xe,ze)),Ee.isWebGLMultipleRenderTargets){const $e=Ee.texture;if(ze.length!==$e.length||ze[0]!==t.COLOR_ATTACHMENT0){for(let ye=0,Je=$e.length;ye<Je;ye++)ze[ye]=t.COLOR_ATTACHMENT0+ye;ze.length=$e.length,ce=!0}}else ze[0]!==t.COLOR_ATTACHMENT0&&(ze[0]=t.COLOR_ATTACHMENT0,ce=!0);else ze[0]!==t.BACK&&(ze[0]=t.BACK,ce=!0);ce&&(n.isWebGL2?t.drawBuffers(ze):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(ze))}function Ze(Ee){return v!==Ee?(t.useProgram(Ee),v=Ee,!0):!1}const G={[Tf]:t.FUNC_ADD,[Gye]:t.FUNC_SUBTRACT,[qye]:t.FUNC_REVERSE_SUBTRACT};if(r)G[c8]=t.MIN,G[u8]=t.MAX;else{const Ee=e.get("EXT_blend_minmax");Ee!==null&&(G[c8]=Ee.MIN_EXT,G[u8]=Ee.MAX_EXT)}const Q={[Wye]:t.ZERO,[Kye]:t.ONE,[Xye]:t.SRC_COLOR,[d3]:t.SRC_ALPHA,[tve]:t.SRC_ALPHA_SATURATE,[Jye]:t.DST_COLOR,[Qye]:t.DST_ALPHA,[Yye]:t.ONE_MINUS_SRC_COLOR,[h3]:t.ONE_MINUS_SRC_ALPHA,[eve]:t.ONE_MINUS_DST_COLOR,[Zye]:t.ONE_MINUS_DST_ALPHA,[nve]:t.CONSTANT_COLOR,[rve]:t.ONE_MINUS_CONSTANT_COLOR,[ive]:t.CONSTANT_ALPHA,[ave]:t.ONE_MINUS_CONSTANT_ALPHA};function de(Ee,Xe,ze,ce,$e,ye,Je,at,jt,Dt){if(Ee===uh){b===!0&&(Ce(t.BLEND),b=!1);return}if(b===!1&&(ie(t.BLEND),b=!0),Ee!==Vye){if(Ee!==S||Dt!==I){if((N!==Tf||C!==Tf)&&(t.blendEquation(t.FUNC_ADD),N=Tf,C=Tf),Dt)switch(Ee){case Cg:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case s8:t.blendFunc(t.ONE,t.ONE);break;case o8:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case l8: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 Cg:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case s8:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case o8:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case l8:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",Ee);break}T=null,k=null,E=null,P=null,A.set(0,0,0),D=0,S=Ee,I=Dt}return}$e=$e||Xe,ye=ye||ze,Je=Je||ce,(Xe!==N||$e!==C)&&(t.blendEquationSeparate(G[Xe],G[$e]),N=Xe,C=$e),(ze!==T||ce!==k||ye!==E||Je!==P)&&(t.blendFuncSeparate(Q[ze],Q[ce],Q[ye],Q[Je]),T=ze,k=ce,E=ye,P=Je),(at.equals(A)===!1||jt!==D)&&(t.blendColor(at.r,at.g,at.b,jt),A.copy(at),D=jt),S=Ee,I=!1}function q(Ee,Xe){Ee.side===pu?Ce(t.CULL_FACE):ie(t.CULL_FACE);let ze=Ee.side===Hs;Xe&&(ze=!ze),ee(ze),Ee.blending===Cg&&Ee.transparent===!1?de(uh):de(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 ce=Ee.stencilWrite;u.setTest(ce),ce&&(u.setMask(Ee.stencilWriteMask),u.setFunc(Ee.stencilFunc,Ee.stencilRef,Ee.stencilFuncMask),u.setOp(Ee.stencilFail,Ee.stencilZFail,Ee.stencilZPass)),ke(Ee.polygonOffset,Ee.polygonOffsetFactor,Ee.polygonOffsetUnits),Ee.alphaToCoverage===!0?ie(t.SAMPLE_ALPHA_TO_COVERAGE):Ce(t.SAMPLE_ALPHA_TO_COVERAGE)}function ee(Ee){L!==Ee&&(Ee?t.frontFace(t.CW):t.frontFace(t.CCW),L=Ee)}function B(Ee){Ee!==Bye?(ie(t.CULL_FACE),Ee!==U&&(Ee===a8?t.cullFace(t.BACK):Ee===Hye?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ce(t.CULL_FACE),U=Ee}function he(Ee){Ee!==j&&(X&&t.lineWidth(Ee),j=Ee)}function ke(Ee,Xe,ze){Ee?(ie(t.POLYGON_OFFSET_FILL),(V!==Xe||K!==ze)&&(t.polygonOffset(Xe,ze),V=Xe,K=ze)):Ce(t.POLYGON_OFFSET_FILL)}function pe(Ee){Ee?ie(t.SCISSOR_TEST):Ce(t.SCISSOR_TEST)}function H(Ee){Ee===void 0&&(Ee=t.TEXTURE0+z-1),$!==Ee&&(t.activeTexture(Ee),$=Ee)}function O(Ee,Xe,ze){ze===void 0&&($===null?ze=t.TEXTURE0+z-1:ze=$);let ce=W[ze];ce===void 0&&(ce={type:void 0,texture:void 0},W[ze]=ce),(ce.type!==Ee||ce.texture!==Xe)&&($!==ze&&(t.activeTexture(ze),$=ze),t.bindTexture(Ee,Xe||Te[Ee]),ce.type=Ee,ce.texture=Xe)}function J(){const Ee=W[$];Ee!==void 0&&Ee.type!==void 0&&(t.bindTexture(Ee.type,null),Ee.type=void 0,Ee.texture=void 0)}function le(){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 we(){try{t.texSubImage2D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function ae(){try{t.texSubImage3D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function Le(){try{t.compressedTexSubImage2D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function Be(){try{t.compressedTexSubImage3D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function Ve(){try{t.texStorage2D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function He(){try{t.texStorage3D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function be(){try{t.texImage2D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function Pe(){try{t.texImage3D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function Ie(Ee){ge.equals(Ee)===!1&&(t.scissor(Ee.x,Ee.y,Ee.z,Ee.w),ge.copy(Ee))}function _e(Ee){me.equals(Ee)===!1&&(t.viewport(Ee.x,Ee.y,Ee.z,Ee.w),me.copy(Ee))}function Ke(Ee,Xe){let ze=h.get(Xe);ze===void 0&&(ze=new WeakMap,h.set(Xe,ze));let ce=ze.get(Ee);ce===void 0&&(ce=t.getUniformBlockIndex(Xe,Ee.name),ze.set(Ee,ce))}function Me(Ee,Xe){const ce=h.get(Xe).get(Ee);d.get(Xe)!==ce&&(t.uniformBlockBinding(Xe,ce,Ee.__bindingPointIndex),d.set(Xe,ce))}function it(){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),p={},$=null,W={},m={},x=new WeakMap,y=[],v=null,b=!1,S=null,N=null,T=null,k=null,C=null,E=null,P=null,A=new Jt(0,0,0),D=0,I=!1,L=null,U=null,j=null,V=null,K=null,ge.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:ie,disable:Ce,bindFramebuffer:Fe,drawBuffers:xe,useProgram:Ze,setBlending:de,setMaterial:q,setFlipSided:ee,setCullFace:B,setLineWidth:he,setPolygonOffset:ke,setScissorTest:pe,activeTexture:H,bindTexture:O,unbindTexture:J,compressedTexImage2D:le,compressedTexImage3D:Se,texImage2D:be,texImage3D:Pe,updateUBOMapping:Ke,uniformBlockBinding:Me,texStorage2D:Ve,texStorage3D:He,texSubImage2D:we,texSubImage3D:ae,compressedTexSubImage2D:Le,compressedTexSubImage3D:Be,scissor:Ie,viewport:_e,reset:it}}function YNe(t,e,n,r,i,s,o){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,h=i.maxSamples,p=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,m=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),x=new WeakMap;let y;const v=new WeakMap;let b=!1;try{b=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function S(H,O){return b?new OffscreenCanvas(H,O):oS("canvas")}function N(H,O,J,le){let Se=1;if((H.width>le||H.height>le)&&(Se=le/Math.max(H.width,H.height)),Se<1||O===!0)if(typeof HTMLImageElement<"u"&&H instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&H instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&H instanceof ImageBitmap){const we=O?sS:Math.floor,ae=we(Se*H.width),Le=we(Se*H.height);y===void 0&&(y=S(ae,Le));const Be=J?S(ae,Le):y;return Be.width=ae,Be.height=Le,Be.getContext("2d").drawImage(H,0,0,ae,Le),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+H.width+"x"+H.height+") to ("+ae+"x"+Le+")."),Be}else return"data"in H&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+H.width+"x"+H.height+")."),H;return H}function T(H){return y3(H.width)&&y3(H.height)}function k(H){return l?!1:H.wrapS!==Cl||H.wrapT!==Cl||H.minFilter!==La&&H.minFilter!==Zo}function C(H,O){return H.generateMipmaps&&O&&H.minFilter!==La&&H.minFilter!==Zo}function E(H){t.generateMipmap(H)}function P(H,O,J,le,Se=!1){if(l===!1)return O;if(H!==null){if(t[H]!==void 0)return t[H];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+H+"'")}let we=O;if(O===t.RED&&(J===t.FLOAT&&(we=t.R32F),J===t.HALF_FLOAT&&(we=t.R16F),J===t.UNSIGNED_BYTE&&(we=t.R8)),O===t.RED_INTEGER&&(J===t.UNSIGNED_BYTE&&(we=t.R8UI),J===t.UNSIGNED_SHORT&&(we=t.R16UI),J===t.UNSIGNED_INT&&(we=t.R32UI),J===t.BYTE&&(we=t.R8I),J===t.SHORT&&(we=t.R16I),J===t.INT&&(we=t.R32I)),O===t.RG&&(J===t.FLOAT&&(we=t.RG32F),J===t.HALF_FLOAT&&(we=t.RG16F),J===t.UNSIGNED_BYTE&&(we=t.RG8)),O===t.RGBA){const ae=Se?rS:Er.getTransfer(le);J===t.FLOAT&&(we=t.RGBA32F),J===t.HALF_FLOAT&&(we=t.RGBA16F),J===t.UNSIGNED_BYTE&&(we=ae===Gr?t.SRGB8_ALPHA8:t.RGBA8),J===t.UNSIGNED_SHORT_4_4_4_4&&(we=t.RGBA4),J===t.UNSIGNED_SHORT_5_5_5_1&&(we=t.RGB5_A1)}return(we===t.R16F||we===t.R32F||we===t.RG16F||we===t.RG32F||we===t.RGBA16F||we===t.RGBA32F)&&e.get("EXT_color_buffer_float"),we}function A(H,O,J){return C(H,J)===!0||H.isFramebufferTexture&&H.minFilter!==La&&H.minFilter!==Zo?Math.log2(Math.max(O.width,O.height))+1:H.mipmaps!==void 0&&H.mipmaps.length>0?H.mipmaps.length:H.isCompressedTexture&&Array.isArray(H.image)?O.mipmaps.length:1}function D(H){return H===La||H===d8||H===UT?t.NEAREST:t.LINEAR}function I(H){const O=H.target;O.removeEventListener("dispose",I),U(O),O.isVideoTexture&&x.delete(O)}function L(H){const O=H.target;O.removeEventListener("dispose",L),V(O)}function U(H){const O=r.get(H);if(O.__webglInit===void 0)return;const J=H.source,le=v.get(J);if(le){const Se=le[O.__cacheKey];Se.usedTimes--,Se.usedTimes===0&&j(H),Object.keys(le).length===0&&v.delete(J)}r.remove(H)}function j(H){const O=r.get(H);t.deleteTexture(O.__webglTexture);const J=H.source,le=v.get(J);delete le[O.__cacheKey],o.memory.textures--}function V(H){const O=H.texture,J=r.get(H),le=r.get(O);if(le.__webglTexture!==void 0&&(t.deleteTexture(le.__webglTexture),o.memory.textures--),H.depthTexture&&H.depthTexture.dispose(),H.isWebGLCubeRenderTarget)for(let Se=0;Se<6;Se++){if(Array.isArray(J.__webglFramebuffer[Se]))for(let we=0;we<J.__webglFramebuffer[Se].length;we++)t.deleteFramebuffer(J.__webglFramebuffer[Se][we]);else t.deleteFramebuffer(J.__webglFramebuffer[Se]);J.__webglDepthbuffer&&t.deleteRenderbuffer(J.__webglDepthbuffer[Se])}else{if(Array.isArray(J.__webglFramebuffer))for(let Se=0;Se<J.__webglFramebuffer.length;Se++)t.deleteFramebuffer(J.__webglFramebuffer[Se]);else t.deleteFramebuffer(J.__webglFramebuffer);if(J.__webglDepthbuffer&&t.deleteRenderbuffer(J.__webglDepthbuffer),J.__webglMultisampledFramebuffer&&t.deleteFramebuffer(J.__webglMultisampledFramebuffer),J.__webglColorRenderbuffer)for(let Se=0;Se<J.__webglColorRenderbuffer.length;Se++)J.__webglColorRenderbuffer[Se]&&t.deleteRenderbuffer(J.__webglColorRenderbuffer[Se]);J.__webglDepthRenderbuffer&&t.deleteRenderbuffer(J.__webglDepthRenderbuffer)}if(H.isWebGLMultipleRenderTargets)for(let Se=0,we=O.length;Se<we;Se++){const ae=r.get(O[Se]);ae.__webglTexture&&(t.deleteTexture(ae.__webglTexture),o.memory.textures--),r.remove(O[Se])}r.remove(O),r.remove(H)}let K=0;function z(){K=0}function X(){const H=K;return H>=c&&console.warn("THREE.WebGLTextures: Trying to use "+H+" texture units while this GPU supports only "+c),K+=1,H}function Y(H){const O=[];return O.push(H.wrapS),O.push(H.wrapT),O.push(H.wrapR||0),O.push(H.magFilter),O.push(H.minFilter),O.push(H.anisotropy),O.push(H.internalFormat),O.push(H.format),O.push(H.type),O.push(H.generateMipmaps),O.push(H.premultiplyAlpha),O.push(H.flipY),O.push(H.unpackAlignment),O.push(H.colorSpace),O.join()}function te(H,O){const J=r.get(H);if(H.isVideoTexture&&ke(H),H.isRenderTargetTexture===!1&&H.version>0&&J.__version!==H.version){const le=H.image;if(le===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{ie(J,H,O);return}}n.bindTexture(t.TEXTURE_2D,J.__webglTexture,t.TEXTURE0+O)}function $(H,O){const J=r.get(H);if(H.version>0&&J.__version!==H.version){ie(J,H,O);return}n.bindTexture(t.TEXTURE_2D_ARRAY,J.__webglTexture,t.TEXTURE0+O)}function W(H,O){const J=r.get(H);if(H.version>0&&J.__version!==H.version){ie(J,H,O);return}n.bindTexture(t.TEXTURE_3D,J.__webglTexture,t.TEXTURE0+O)}function ne(H,O){const J=r.get(H);if(H.version>0&&J.__version!==H.version){Ce(J,H,O);return}n.bindTexture(t.TEXTURE_CUBE_MAP,J.__webglTexture,t.TEXTURE0+O)}const re={[p3]:t.REPEAT,[Cl]:t.CLAMP_TO_EDGE,[g3]:t.MIRRORED_REPEAT},ge={[La]:t.NEAREST,[d8]:t.NEAREST_MIPMAP_NEAREST,[UT]:t.NEAREST_MIPMAP_LINEAR,[Zo]:t.LINEAR,[vve]:t.LINEAR_MIPMAP_NEAREST,[ty]:t.LINEAR_MIPMAP_LINEAR},me={[Pve]:t.NEVER,[Ive]:t.ALWAYS,[Dve]:t.LESS,[$K]:t.LEQUAL,[Rve]:t.EQUAL,[Fve]:t.GEQUAL,[Ove]:t.GREATER,[Lve]:t.NOTEQUAL};function ue(H,O,J){if(J?(t.texParameteri(H,t.TEXTURE_WRAP_S,re[O.wrapS]),t.texParameteri(H,t.TEXTURE_WRAP_T,re[O.wrapT]),(H===t.TEXTURE_3D||H===t.TEXTURE_2D_ARRAY)&&t.texParameteri(H,t.TEXTURE_WRAP_R,re[O.wrapR]),t.texParameteri(H,t.TEXTURE_MAG_FILTER,ge[O.magFilter]),t.texParameteri(H,t.TEXTURE_MIN_FILTER,ge[O.minFilter])):(t.texParameteri(H,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(H,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(H===t.TEXTURE_3D||H===t.TEXTURE_2D_ARRAY)&&t.texParameteri(H,t.TEXTURE_WRAP_R,t.CLAMP_TO_EDGE),(O.wrapS!==Cl||O.wrapT!==Cl)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),t.texParameteri(H,t.TEXTURE_MAG_FILTER,D(O.magFilter)),t.texParameteri(H,t.TEXTURE_MIN_FILTER,D(O.minFilter)),O.minFilter!==La&&O.minFilter!==Zo&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),O.compareFunction&&(t.texParameteri(H,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(H,t.TEXTURE_COMPARE_FUNC,me[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){const le=e.get("EXT_texture_filter_anisotropic");if(O.magFilter===La||O.minFilter!==UT&&O.minFilter!==ty||O.type===_u&&e.has("OES_texture_float_linear")===!1||l===!1&&O.type===ny&&e.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(t.texParameterf(H,le.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function Te(H,O){let J=!1;H.__webglInit===void 0&&(H.__webglInit=!0,O.addEventListener("dispose",I));const le=O.source;let Se=v.get(le);Se===void 0&&(Se={},v.set(le,Se));const we=Y(O);if(we!==H.__cacheKey){Se[we]===void 0&&(Se[we]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,J=!0),Se[we].usedTimes++;const ae=Se[H.__cacheKey];ae!==void 0&&(Se[H.__cacheKey].usedTimes--,ae.usedTimes===0&&j(O)),H.__cacheKey=we,H.__webglTexture=Se[we].texture}return J}function ie(H,O,J){let le=t.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(le=t.TEXTURE_2D_ARRAY),O.isData3DTexture&&(le=t.TEXTURE_3D);const Se=Te(H,O),we=O.source;n.bindTexture(le,H.__webglTexture,t.TEXTURE0+J);const ae=r.get(we);if(we.version!==ae.__version||Se===!0){n.activeTexture(t.TEXTURE0+J);const Le=Er.getPrimaries(Er.workingColorSpace),Be=O.colorSpace===el?null:Er.getPrimaries(O.colorSpace),Ve=O.colorSpace===el||Le===Be?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Ve);const He=k(O)&&T(O.image)===!1;let be=N(O.image,He,!1,d);be=pe(O,be);const Pe=T(be)||l,Ie=s.convert(O.format,O.colorSpace);let _e=s.convert(O.type),Ke=P(O.internalFormat,Ie,_e,O.colorSpace,O.isVideoTexture);ue(le,O,Pe);let Me;const it=O.mipmaps,Ee=l&&O.isVideoTexture!==!0&&Ke!==zK,Xe=ae.__version===void 0||Se===!0,ze=A(O,be,Pe);if(O.isDepthTexture)Ke=t.DEPTH_COMPONENT,l?O.type===_u?Ke=t.DEPTH_COMPONENT32F:O.type===Jd?Ke=t.DEPTH_COMPONENT24:O.type===$f?Ke=t.DEPTH24_STENCIL8:Ke=t.DEPTH_COMPONENT16:O.type===_u&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===Vf&&Ke===t.DEPTH_COMPONENT&&O.type!==iO&&O.type!==Jd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=Jd,_e=s.convert(O.type)),O.format===Zg&&Ke===t.DEPTH_COMPONENT&&(Ke=t.DEPTH_STENCIL,O.type!==$f&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=$f,_e=s.convert(O.type))),Xe&&(Ee?n.texStorage2D(t.TEXTURE_2D,1,Ke,be.width,be.height):n.texImage2D(t.TEXTURE_2D,0,Ke,be.width,be.height,0,Ie,_e,null));else if(O.isDataTexture)if(it.length>0&&Pe){Ee&&Xe&&n.texStorage2D(t.TEXTURE_2D,ze,Ke,it[0].width,it[0].height);for(let ce=0,$e=it.length;ce<$e;ce++)Me=it[ce],Ee?n.texSubImage2D(t.TEXTURE_2D,ce,0,0,Me.width,Me.height,Ie,_e,Me.data):n.texImage2D(t.TEXTURE_2D,ce,Ke,Me.width,Me.height,0,Ie,_e,Me.data);O.generateMipmaps=!1}else Ee?(Xe&&n.texStorage2D(t.TEXTURE_2D,ze,Ke,be.width,be.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,be.width,be.height,Ie,_e,be.data)):n.texImage2D(t.TEXTURE_2D,0,Ke,be.width,be.height,0,Ie,_e,be.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Ee&&Xe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ze,Ke,it[0].width,it[0].height,be.depth);for(let ce=0,$e=it.length;ce<$e;ce++)Me=it[ce],O.format!==Jo?Ie!==null?Ee?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,ce,0,0,0,Me.width,Me.height,be.depth,Ie,Me.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,ce,Ke,Me.width,Me.height,be.depth,0,Me.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ee?n.texSubImage3D(t.TEXTURE_2D_ARRAY,ce,0,0,0,Me.width,Me.height,be.depth,Ie,_e,Me.data):n.texImage3D(t.TEXTURE_2D_ARRAY,ce,Ke,Me.width,Me.height,be.depth,0,Ie,_e,Me.data)}else{Ee&&Xe&&n.texStorage2D(t.TEXTURE_2D,ze,Ke,it[0].width,it[0].height);for(let ce=0,$e=it.length;ce<$e;ce++)Me=it[ce],O.format!==Jo?Ie!==null?Ee?n.compressedTexSubImage2D(t.TEXTURE_2D,ce,0,0,Me.width,Me.height,Ie,Me.data):n.compressedTexImage2D(t.TEXTURE_2D,ce,Ke,Me.width,Me.height,0,Me.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ee?n.texSubImage2D(t.TEXTURE_2D,ce,0,0,Me.width,Me.height,Ie,_e,Me.data):n.texImage2D(t.TEXTURE_2D,ce,Ke,Me.width,Me.height,0,Ie,_e,Me.data)}else if(O.isDataArrayTexture)Ee?(Xe&&n.texStorage3D(t.TEXTURE_2D_ARRAY,ze,Ke,be.width,be.height,be.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,be.width,be.height,be.depth,Ie,_e,be.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,Ke,be.width,be.height,be.depth,0,Ie,_e,be.data);else if(O.isData3DTexture)Ee?(Xe&&n.texStorage3D(t.TEXTURE_3D,ze,Ke,be.width,be.height,be.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,be.width,be.height,be.depth,Ie,_e,be.data)):n.texImage3D(t.TEXTURE_3D,0,Ke,be.width,be.height,be.depth,0,Ie,_e,be.data);else if(O.isFramebufferTexture){if(Xe)if(Ee)n.texStorage2D(t.TEXTURE_2D,ze,Ke,be.width,be.height);else{let ce=be.width,$e=be.height;for(let ye=0;ye<ze;ye++)n.texImage2D(t.TEXTURE_2D,ye,Ke,ce,$e,0,Ie,_e,null),ce>>=1,$e>>=1}}else if(it.length>0&&Pe){Ee&&Xe&&n.texStorage2D(t.TEXTURE_2D,ze,Ke,it[0].width,it[0].height);for(let ce=0,$e=it.length;ce<$e;ce++)Me=it[ce],Ee?n.texSubImage2D(t.TEXTURE_2D,ce,0,0,Ie,_e,Me):n.texImage2D(t.TEXTURE_2D,ce,Ke,Ie,_e,Me);O.generateMipmaps=!1}else Ee?(Xe&&n.texStorage2D(t.TEXTURE_2D,ze,Ke,be.width,be.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,Ie,_e,be)):n.texImage2D(t.TEXTURE_2D,0,Ke,Ie,_e,be);C(O,Pe)&&E(le),ae.__version=we.version,O.onUpdate&&O.onUpdate(O)}H.__version=O.version}function Ce(H,O,J){if(O.image.length!==6)return;const le=Te(H,O),Se=O.source;n.bindTexture(t.TEXTURE_CUBE_MAP,H.__webglTexture,t.TEXTURE0+J);const we=r.get(Se);if(Se.version!==we.__version||le===!0){n.activeTexture(t.TEXTURE0+J);const ae=Er.getPrimaries(Er.workingColorSpace),Le=O.colorSpace===el?null:Er.getPrimaries(O.colorSpace),Be=O.colorSpace===el||ae===Le?t.NONE:t.BROWSER_DEFAULT_WEBGL;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,O.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,O.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,O.unpackAlignment),t.pixelStorei(t.UNPACK_COLORSPACE_CONVERSION_WEBGL,Be);const Ve=O.isCompressedTexture||O.image[0].isCompressedTexture,He=O.image[0]&&O.image[0].isDataTexture,be=[];for(let ce=0;ce<6;ce++)!Ve&&!He?be[ce]=N(O.image[ce],!1,!0,u):be[ce]=He?O.image[ce].image:O.image[ce],be[ce]=pe(O,be[ce]);const Pe=be[0],Ie=T(Pe)||l,_e=s.convert(O.format,O.colorSpace),Ke=s.convert(O.type),Me=P(O.internalFormat,_e,Ke,O.colorSpace),it=l&&O.isVideoTexture!==!0,Ee=we.__version===void 0||le===!0;let Xe=A(O,Pe,Ie);ue(t.TEXTURE_CUBE_MAP,O,Ie);let ze;if(Ve){it&&Ee&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Xe,Me,Pe.width,Pe.height);for(let ce=0;ce<6;ce++){ze=be[ce].mipmaps;for(let $e=0;$e<ze.length;$e++){const ye=ze[$e];O.format!==Jo?_e!==null?it?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e,0,0,ye.width,ye.height,_e,ye.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e,Me,ye.width,ye.height,0,ye.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):it?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e,0,0,ye.width,ye.height,_e,Ke,ye.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e,Me,ye.width,ye.height,0,_e,Ke,ye.data)}}}else{ze=O.mipmaps,it&&Ee&&(ze.length>0&&Xe++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Xe,Me,be[0].width,be[0].height));for(let ce=0;ce<6;ce++)if(He){it?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,be[ce].width,be[ce].height,_e,Ke,be[ce].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,Me,be[ce].width,be[ce].height,0,_e,Ke,be[ce].data);for(let $e=0;$e<ze.length;$e++){const Je=ze[$e].image[ce].image;it?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e+1,0,0,Je.width,Je.height,_e,Ke,Je.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e+1,Me,Je.width,Je.height,0,_e,Ke,Je.data)}}else{it?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,0,0,_e,Ke,be[ce]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,Me,_e,Ke,be[ce]);for(let $e=0;$e<ze.length;$e++){const ye=ze[$e];it?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e+1,0,0,_e,Ke,ye.image[ce]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+ce,$e+1,Me,_e,Ke,ye.image[ce])}}}C(O,Ie)&&E(t.TEXTURE_CUBE_MAP),we.__version=Se.version,O.onUpdate&&O.onUpdate(O)}H.__version=O.version}function Fe(H,O,J,le,Se,we){const ae=s.convert(J.format,J.colorSpace),Le=s.convert(J.type),Be=P(J.internalFormat,ae,Le,J.colorSpace);if(!r.get(O).__hasExternalTextures){const He=Math.max(1,O.width>>we),be=Math.max(1,O.height>>we);Se===t.TEXTURE_3D||Se===t.TEXTURE_2D_ARRAY?n.texImage3D(Se,we,Be,He,be,O.depth,0,ae,Le,null):n.texImage2D(Se,we,Be,He,be,0,ae,Le,null)}n.bindFramebuffer(t.FRAMEBUFFER,H),he(O)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,le,Se,r.get(J).__webglTexture,0,B(O)):(Se===t.TEXTURE_2D||Se>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&Se<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,le,Se,r.get(J).__webglTexture,we),n.bindFramebuffer(t.FRAMEBUFFER,null)}function xe(H,O,J){if(t.bindRenderbuffer(t.RENDERBUFFER,H),O.depthBuffer&&!O.stencilBuffer){let le=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(J||he(O)){const Se=O.depthTexture;Se&&Se.isDepthTexture&&(Se.type===_u?le=t.DEPTH_COMPONENT32F:Se.type===Jd&&(le=t.DEPTH_COMPONENT24));const we=B(O);he(O)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,we,le,O.width,O.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,we,le,O.width,O.height)}else t.renderbufferStorage(t.RENDERBUFFER,le,O.width,O.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,H)}else if(O.depthBuffer&&O.stencilBuffer){const le=B(O);J&&he(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,le,t.DEPTH24_STENCIL8,O.width,O.height):he(O)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,le,t.DEPTH24_STENCIL8,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,t.DEPTH_STENCIL,O.width,O.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,H)}else{const le=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let Se=0;Se<le.length;Se++){const we=le[Se],ae=s.convert(we.format,we.colorSpace),Le=s.convert(we.type),Be=P(we.internalFormat,ae,Le,we.colorSpace),Ve=B(O);J&&he(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,Ve,Be,O.width,O.height):he(O)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Ve,Be,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,Be,O.width,O.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function Ze(H,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,H),!(O.depthTexture&&O.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!r.get(O.depthTexture).__webglTexture||O.depthTexture.image.width!==O.width||O.depthTexture.image.height!==O.height)&&(O.depthTexture.image.width=O.width,O.depthTexture.image.height=O.height,O.depthTexture.needsUpdate=!0),te(O.depthTexture,0);const le=r.get(O.depthTexture).__webglTexture,Se=B(O);if(O.depthTexture.format===Vf)he(O)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,le,0,Se):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,le,0);else if(O.depthTexture.format===Zg)he(O)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,le,0,Se):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,le,0);else throw new Error("Unknown depthTexture format")}function G(H){const O=r.get(H),J=H.isWebGLCubeRenderTarget===!0;if(H.depthTexture&&!O.__autoAllocateDepthBuffer){if(J)throw new Error("target.depthTexture not supported in Cube render targets");Ze(O.__webglFramebuffer,H)}else if(J){O.__webglDepthbuffer=[];for(let le=0;le<6;le++)n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[le]),O.__webglDepthbuffer[le]=t.createRenderbuffer(),xe(O.__webglDepthbuffer[le],H,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer=t.createRenderbuffer(),xe(O.__webglDepthbuffer,H,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function Q(H,O,J){const le=r.get(H);O!==void 0&&Fe(le.__webglFramebuffer,H,H.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),J!==void 0&&G(H)}function de(H){const O=H.texture,J=r.get(H),le=r.get(O);H.addEventListener("dispose",L),H.isWebGLMultipleRenderTargets!==!0&&(le.__webglTexture===void 0&&(le.__webglTexture=t.createTexture()),le.__version=O.version,o.memory.textures++);const Se=H.isWebGLCubeRenderTarget===!0,we=H.isWebGLMultipleRenderTargets===!0,ae=T(H)||l;if(Se){J.__webglFramebuffer=[];for(let Le=0;Le<6;Le++)if(l&&O.mipmaps&&O.mipmaps.length>0){J.__webglFramebuffer[Le]=[];for(let Be=0;Be<O.mipmaps.length;Be++)J.__webglFramebuffer[Le][Be]=t.createFramebuffer()}else J.__webglFramebuffer[Le]=t.createFramebuffer()}else{if(l&&O.mipmaps&&O.mipmaps.length>0){J.__webglFramebuffer=[];for(let Le=0;Le<O.mipmaps.length;Le++)J.__webglFramebuffer[Le]=t.createFramebuffer()}else J.__webglFramebuffer=t.createFramebuffer();if(we)if(i.drawBuffers){const Le=H.texture;for(let Be=0,Ve=Le.length;Be<Ve;Be++){const He=r.get(Le[Be]);He.__webglTexture===void 0&&(He.__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&&H.samples>0&&he(H)===!1){const Le=we?O:[O];J.__webglMultisampledFramebuffer=t.createFramebuffer(),J.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,J.__webglMultisampledFramebuffer);for(let Be=0;Be<Le.length;Be++){const Ve=Le[Be];J.__webglColorRenderbuffer[Be]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,J.__webglColorRenderbuffer[Be]);const He=s.convert(Ve.format,Ve.colorSpace),be=s.convert(Ve.type),Pe=P(Ve.internalFormat,He,be,Ve.colorSpace,H.isXRRenderTarget===!0),Ie=B(H);t.renderbufferStorageMultisample(t.RENDERBUFFER,Ie,Pe,H.width,H.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Be,t.RENDERBUFFER,J.__webglColorRenderbuffer[Be])}t.bindRenderbuffer(t.RENDERBUFFER,null),H.depthBuffer&&(J.__webglDepthRenderbuffer=t.createRenderbuffer(),xe(J.__webglDepthRenderbuffer,H,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(Se){n.bindTexture(t.TEXTURE_CUBE_MAP,le.__webglTexture),ue(t.TEXTURE_CUBE_MAP,O,ae);for(let Le=0;Le<6;Le++)if(l&&O.mipmaps&&O.mipmaps.length>0)for(let Be=0;Be<O.mipmaps.length;Be++)Fe(J.__webglFramebuffer[Le][Be],H,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,Be);else Fe(J.__webglFramebuffer[Le],H,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Le,0);C(O,ae)&&E(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(we){const Le=H.texture;for(let Be=0,Ve=Le.length;Be<Ve;Be++){const He=Le[Be],be=r.get(He);n.bindTexture(t.TEXTURE_2D,be.__webglTexture),ue(t.TEXTURE_2D,He,ae),Fe(J.__webglFramebuffer,H,He,t.COLOR_ATTACHMENT0+Be,t.TEXTURE_2D,0),C(He,ae)&&E(t.TEXTURE_2D)}n.unbindTexture()}else{let Le=t.TEXTURE_2D;if((H.isWebGL3DRenderTarget||H.isWebGLArrayRenderTarget)&&(l?Le=H.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Le,le.__webglTexture),ue(Le,O,ae),l&&O.mipmaps&&O.mipmaps.length>0)for(let Be=0;Be<O.mipmaps.length;Be++)Fe(J.__webglFramebuffer[Be],H,O,t.COLOR_ATTACHMENT0,Le,Be);else Fe(J.__webglFramebuffer,H,O,t.COLOR_ATTACHMENT0,Le,0);C(O,ae)&&E(Le),n.unbindTexture()}H.depthBuffer&&G(H)}function q(H){const O=T(H)||l,J=H.isWebGLMultipleRenderTargets===!0?H.texture:[H.texture];for(let le=0,Se=J.length;le<Se;le++){const we=J[le];if(C(we,O)){const ae=H.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Le=r.get(we).__webglTexture;n.bindTexture(ae,Le),E(ae),n.unbindTexture()}}}function ee(H){if(l&&H.samples>0&&he(H)===!1){const O=H.isWebGLMultipleRenderTargets?H.texture:[H.texture],J=H.width,le=H.height;let Se=t.COLOR_BUFFER_BIT;const we=[],ae=H.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Le=r.get(H),Be=H.isWebGLMultipleRenderTargets===!0;if(Be)for(let Ve=0;Ve<O.length;Ve++)n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Le.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Le.__webglFramebuffer);for(let Ve=0;Ve<O.length;Ve++){we.push(t.COLOR_ATTACHMENT0+Ve),H.depthBuffer&&we.push(ae);const He=Le.__ignoreDepthValues!==void 0?Le.__ignoreDepthValues:!1;if(He===!1&&(H.depthBuffer&&(Se|=t.DEPTH_BUFFER_BIT),H.stencilBuffer&&(Se|=t.STENCIL_BUFFER_BIT)),Be&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Le.__webglColorRenderbuffer[Ve]),He===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[ae]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[ae])),Be){const be=r.get(O[Ve]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,be,0)}t.blitFramebuffer(0,0,J,le,0,0,J,le,Se,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,we)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Be)for(let Ve=0;Ve<O.length;Ve++){n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.RENDERBUFFER,Le.__webglColorRenderbuffer[Ve]);const He=r.get(O[Ve]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Le.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+Ve,t.TEXTURE_2D,He,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Le.__webglMultisampledFramebuffer)}}function B(H){return Math.min(h,H.samples)}function he(H){const O=r.get(H);return l&&H.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function ke(H){const O=o.render.frame;x.get(H)!==O&&(x.set(H,O),H.update())}function pe(H,O){const J=H.colorSpace,le=H.format,Se=H.type;return H.isCompressedTexture===!0||H.isVideoTexture===!0||H.format===b3||J!==Iu&&J!==el&&(Er.getTransfer(J)===Gr?l===!1?e.has("EXT_sRGB")===!0&&le===Jo?(H.format=b3,H.minFilter=Zo,H.generateMipmaps=!1):O=qK.sRGBToLinear(O):(le!==Jo||Se!==hh)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",J)),O}this.allocateTextureUnit=X,this.resetTextureUnits=z,this.setTexture2D=te,this.setTexture2DArray=$,this.setTexture3D=W,this.setTextureCube=ne,this.rebindTextures=Q,this.setupRenderTarget=de,this.updateRenderTargetMipmap=q,this.updateMultisampleRenderTarget=ee,this.setupDepthRenderbuffer=G,this.setupFrameBufferTexture=Fe,this.useMultisampledRTT=he}function QNe(t,e,n){const r=n.isWebGL2;function i(s,o=el){let l;const c=Er.getTransfer(o);if(s===hh)return t.UNSIGNED_BYTE;if(s===OK)return t.UNSIGNED_SHORT_4_4_4_4;if(s===LK)return t.UNSIGNED_SHORT_5_5_5_1;if(s===wve)return t.BYTE;if(s===_ve)return t.SHORT;if(s===iO)return t.UNSIGNED_SHORT;if(s===RK)return t.INT;if(s===Jd)return t.UNSIGNED_INT;if(s===_u)return t.FLOAT;if(s===ny)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(s===Sve)return t.ALPHA;if(s===Jo)return t.RGBA;if(s===Nve)return t.LUMINANCE;if(s===Mve)return t.LUMINANCE_ALPHA;if(s===Vf)return t.DEPTH_COMPONENT;if(s===Zg)return t.DEPTH_STENCIL;if(s===b3)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(s===kve)return t.RED;if(s===FK)return t.RED_INTEGER;if(s===Eve)return t.RG;if(s===IK)return t.RG_INTEGER;if(s===UK)return t.RGBA_INTEGER;if(s===zT||s===BT||s===HT||s===$T)if(c===Gr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(s===zT)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(s===BT)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(s===HT)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(s===$T)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(s===zT)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(s===BT)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(s===HT)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(s===$T)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(s===h8||s===f8||s===m8||s===p8)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(s===h8)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(s===f8)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(s===m8)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(s===p8)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(s===zK)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(s===g8||s===x8)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(s===g8)return c===Gr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(s===x8)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(s===b8||s===y8||s===v8||s===w8||s===_8||s===S8||s===N8||s===M8||s===k8||s===E8||s===T8||s===A8||s===C8||s===j8)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(s===b8)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(s===y8)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(s===v8)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(s===w8)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(s===_8)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(s===S8)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(s===N8)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(s===M8)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(s===k8)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(s===E8)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(s===T8)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(s===A8)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(s===C8)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(s===j8)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(s===VT||s===P8||s===D8)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(s===VT)return c===Gr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(s===P8)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(s===D8)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(s===Tve||s===R8||s===O8||s===L8)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(s===VT)return l.COMPRESSED_RED_RGTC1_EXT;if(s===R8)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(s===O8)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(s===L8)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return s===$f?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 ZNe extends ho{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class l0 extends ys{constructor(){super(),this.isGroup=!0,this.type="Group"}}const JNe={type:"move"};class fA{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new l0,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 l0,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new We,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new We),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new l0,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new We,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new We),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,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 v=n.getJointPose(y,r),b=this._getHandJoint(u,y);v!==null&&(b.matrix.fromArray(v.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,b.jointRadius=v.radius),b.visible=v!==null}const d=u.joints["index-finger-tip"],h=u.joints["thumb-tip"],p=d.position.distanceTo(h.position),m=.02,x=.005;u.inputState.pinching&&p>m+x?(u.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!u.inputState.pinching&&p<=m-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(JNe)))}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 l0;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class eMe extends Am{constructor(e,n){super();const r=this;let i=null,s=1,o=null,l="local-floor",c=1,u=null,d=null,h=null,p=null,m=null,x=null;const y=n.getContextAttributes();let v=null,b=null;const S=[],N=[],T=new bn;let k=null;const C=new ho;C.layers.enable(1),C.viewport=new Cr;const E=new ho;E.layers.enable(2),E.viewport=new Cr;const P=[C,E],A=new ZNe;A.layers.enable(1),A.layers.enable(2);let D=null,I=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ne){let re=S[ne];return re===void 0&&(re=new fA,S[ne]=re),re.getTargetRaySpace()},this.getControllerGrip=function(ne){let re=S[ne];return re===void 0&&(re=new fA,S[ne]=re),re.getGripSpace()},this.getHand=function(ne){let re=S[ne];return re===void 0&&(re=new fA,S[ne]=re),re.getHandSpace()};function L(ne){const re=N.indexOf(ne.inputSource);if(re===-1)return;const ge=S[re];ge!==void 0&&(ge.update(ne.inputSource,ne.frame,u||o),ge.dispatchEvent({type:ne.type,data:ne.inputSource}))}function U(){i.removeEventListener("select",L),i.removeEventListener("selectstart",L),i.removeEventListener("selectend",L),i.removeEventListener("squeeze",L),i.removeEventListener("squeezestart",L),i.removeEventListener("squeezeend",L),i.removeEventListener("end",U),i.removeEventListener("inputsourceschange",j);for(let ne=0;ne<S.length;ne++){const re=N[ne];re!==null&&(N[ne]=null,S[ne].disconnect(re))}D=null,I=null,e.setRenderTarget(v),m=null,p=null,h=null,i=null,b=null,W.stop(),r.isPresenting=!1,e.setPixelRatio(k),e.setSize(T.width,T.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ne){s=ne,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ne){l=ne,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(ne){u=ne},this.getBaseLayer=function(){return p!==null?p:m},this.getBinding=function(){return h},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(ne){if(i=ne,i!==null){if(v=e.getRenderTarget(),i.addEventListener("select",L),i.addEventListener("selectstart",L),i.addEventListener("selectend",L),i.addEventListener("squeeze",L),i.addEventListener("squeezestart",L),i.addEventListener("squeezeend",L),i.addEventListener("end",U),i.addEventListener("inputsourceschange",j),y.xrCompatible!==!0&&await n.makeXRCompatible(),k=e.getPixelRatio(),e.getSize(T),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const re={antialias:i.renderState.layers===void 0?y.antialias:!0,alpha:!0,depth:y.depth,stencil:y.stencil,framebufferScaleFactor:s};m=new XRWebGLLayer(i,n,re),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),b=new fm(m.framebufferWidth,m.framebufferHeight,{format:Jo,type:hh,colorSpace:e.outputColorSpace,stencilBuffer:y.stencil})}else{let re=null,ge=null,me=null;y.depth&&(me=y.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,re=y.stencil?Zg:Vf,ge=y.stencil?$f:Jd);const ue={colorFormat:n.RGBA8,depthFormat:me,scaleFactor:s};h=new XRWebGLBinding(i,n),p=h.createProjectionLayer(ue),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),b=new fm(p.textureWidth,p.textureHeight,{format:Jo,type:hh,depthTexture:new iX(p.textureWidth,p.textureHeight,ge,void 0,void 0,void 0,void 0,void 0,void 0,re),stencilBuffer:y.stencil,colorSpace:e.outputColorSpace,samples:y.antialias?4:0});const Te=e.properties.get(b);Te.__ignoreDepthValues=p.ignoreDepthValues}b.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(ne){for(let re=0;re<ne.removed.length;re++){const ge=ne.removed[re],me=N.indexOf(ge);me>=0&&(N[me]=null,S[me].disconnect(ge))}for(let re=0;re<ne.added.length;re++){const ge=ne.added[re];let me=N.indexOf(ge);if(me===-1){for(let Te=0;Te<S.length;Te++)if(Te>=N.length){N.push(ge),me=Te;break}else if(N[Te]===null){N[Te]=ge,me=Te;break}if(me===-1)break}const ue=S[me];ue&&ue.connect(ge)}}const V=new We,K=new We;function z(ne,re,ge){V.setFromMatrixPosition(re.matrixWorld),K.setFromMatrixPosition(ge.matrixWorld);const me=V.distanceTo(K),ue=re.projectionMatrix.elements,Te=ge.projectionMatrix.elements,ie=ue[14]/(ue[10]-1),Ce=ue[14]/(ue[10]+1),Fe=(ue[9]+1)/ue[5],xe=(ue[9]-1)/ue[5],Ze=(ue[8]-1)/ue[0],G=(Te[8]+1)/Te[0],Q=ie*Ze,de=ie*G,q=me/(-Ze+G),ee=q*-Ze;re.matrixWorld.decompose(ne.position,ne.quaternion,ne.scale),ne.translateX(ee),ne.translateZ(q),ne.matrixWorld.compose(ne.position,ne.quaternion,ne.scale),ne.matrixWorldInverse.copy(ne.matrixWorld).invert();const B=ie+q,he=Ce+q,ke=Q-ee,pe=de+(me-ee),H=Fe*Ce/he*B,O=xe*Ce/he*B;ne.projectionMatrix.makePerspective(ke,pe,H,O,B,he),ne.projectionMatrixInverse.copy(ne.projectionMatrix).invert()}function X(ne,re){re===null?ne.matrixWorld.copy(ne.matrix):ne.matrixWorld.multiplyMatrices(re.matrixWorld,ne.matrix),ne.matrixWorldInverse.copy(ne.matrixWorld).invert()}this.updateCamera=function(ne){if(i===null)return;A.near=E.near=C.near=ne.near,A.far=E.far=C.far=ne.far,(D!==A.near||I!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),D=A.near,I=A.far);const re=ne.parent,ge=A.cameras;X(A,re);for(let me=0;me<ge.length;me++)X(ge[me],re);ge.length===2?z(A,C,E):A.projectionMatrix.copy(C.projectionMatrix),Y(ne,A,re)};function Y(ne,re,ge){ge===null?ne.matrix.copy(re.matrixWorld):(ne.matrix.copy(ge.matrixWorld),ne.matrix.invert(),ne.matrix.multiply(re.matrixWorld)),ne.matrix.decompose(ne.position,ne.quaternion,ne.scale),ne.updateMatrixWorld(!0),ne.projectionMatrix.copy(re.projectionMatrix),ne.projectionMatrixInverse.copy(re.projectionMatrixInverse),ne.isPerspectiveCamera&&(ne.fov=iy*2*Math.atan(1/ne.projectionMatrix.elements[5]),ne.zoom=1)}this.getCamera=function(){return A},this.getFoveation=function(){if(!(p===null&&m===null))return c},this.setFoveation=function(ne){c=ne,p!==null&&(p.fixedFoveation=ne),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=ne)};let te=null;function $(ne,re){if(d=re.getViewerPose(u||o),x=re,d!==null){const ge=d.views;m!==null&&(e.setRenderTargetFramebuffer(b,m.framebuffer),e.setRenderTarget(b));let me=!1;ge.length!==A.cameras.length&&(A.cameras.length=0,me=!0);for(let ue=0;ue<ge.length;ue++){const Te=ge[ue];let ie=null;if(m!==null)ie=m.getViewport(Te);else{const Fe=h.getViewSubImage(p,Te);ie=Fe.viewport,ue===0&&(e.setRenderTargetTextures(b,Fe.colorTexture,p.ignoreDepthValues?void 0:Fe.depthStencilTexture),e.setRenderTarget(b))}let Ce=P[ue];Ce===void 0&&(Ce=new ho,Ce.layers.enable(ue),Ce.viewport=new Cr,P[ue]=Ce),Ce.matrix.fromArray(Te.transform.matrix),Ce.matrix.decompose(Ce.position,Ce.quaternion,Ce.scale),Ce.projectionMatrix.fromArray(Te.projectionMatrix),Ce.projectionMatrixInverse.copy(Ce.projectionMatrix).invert(),Ce.viewport.set(ie.x,ie.y,ie.width,ie.height),ue===0&&(A.matrix.copy(Ce.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),me===!0&&A.cameras.push(Ce)}}for(let ge=0;ge<S.length;ge++){const me=N[ge],ue=S[ge];me!==null&&ue!==void 0&&ue.update(me,re,u||o)}te&&te(ne,re),re.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:re}),x=null}const W=new rX;W.setAnimationLoop($),this.setAnimationLoop=function(ne){te=ne},this.dispose=function(){}}}function tMe(t,e){function n(v,b){v.matrixAutoUpdate===!0&&v.updateMatrix(),b.value.copy(v.matrix)}function r(v,b){b.color.getRGB(v.fogColor.value,eX(t)),b.isFog?(v.fogNear.value=b.near,v.fogFar.value=b.far):b.isFogExp2&&(v.fogDensity.value=b.density)}function i(v,b,S,N,T){b.isMeshBasicMaterial||b.isMeshLambertMaterial?s(v,b):b.isMeshToonMaterial?(s(v,b),h(v,b)):b.isMeshPhongMaterial?(s(v,b),d(v,b)):b.isMeshStandardMaterial?(s(v,b),p(v,b),b.isMeshPhysicalMaterial&&m(v,b,T)):b.isMeshMatcapMaterial?(s(v,b),x(v,b)):b.isMeshDepthMaterial?s(v,b):b.isMeshDistanceMaterial?(s(v,b),y(v,b)):b.isMeshNormalMaterial?s(v,b):b.isLineBasicMaterial?(o(v,b),b.isLineDashedMaterial&&l(v,b)):b.isPointsMaterial?c(v,b,S,N):b.isSpriteMaterial?u(v,b):b.isShadowMaterial?(v.color.value.copy(b.color),v.opacity.value=b.opacity):b.isShaderMaterial&&(b.uniformsNeedUpdate=!1)}function s(v,b){v.opacity.value=b.opacity,b.color&&v.diffuse.value.copy(b.color),b.emissive&&v.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity),b.map&&(v.map.value=b.map,n(b.map,v.mapTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.bumpMap&&(v.bumpMap.value=b.bumpMap,n(b.bumpMap,v.bumpMapTransform),v.bumpScale.value=b.bumpScale,b.side===Hs&&(v.bumpScale.value*=-1)),b.normalMap&&(v.normalMap.value=b.normalMap,n(b.normalMap,v.normalMapTransform),v.normalScale.value.copy(b.normalScale),b.side===Hs&&v.normalScale.value.negate()),b.displacementMap&&(v.displacementMap.value=b.displacementMap,n(b.displacementMap,v.displacementMapTransform),v.displacementScale.value=b.displacementScale,v.displacementBias.value=b.displacementBias),b.emissiveMap&&(v.emissiveMap.value=b.emissiveMap,n(b.emissiveMap,v.emissiveMapTransform)),b.specularMap&&(v.specularMap.value=b.specularMap,n(b.specularMap,v.specularMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest);const S=e.get(b).envMap;if(S&&(v.envMap.value=S,v.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=b.reflectivity,v.ior.value=b.ior,v.refractionRatio.value=b.refractionRatio),b.lightMap){v.lightMap.value=b.lightMap;const N=t._useLegacyLights===!0?Math.PI:1;v.lightMapIntensity.value=b.lightMapIntensity*N,n(b.lightMap,v.lightMapTransform)}b.aoMap&&(v.aoMap.value=b.aoMap,v.aoMapIntensity.value=b.aoMapIntensity,n(b.aoMap,v.aoMapTransform))}function o(v,b){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,b.map&&(v.map.value=b.map,n(b.map,v.mapTransform))}function l(v,b){v.dashSize.value=b.dashSize,v.totalSize.value=b.dashSize+b.gapSize,v.scale.value=b.scale}function c(v,b,S,N){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,v.size.value=b.size*S,v.scale.value=N*.5,b.map&&(v.map.value=b.map,n(b.map,v.uvTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest)}function u(v,b){v.diffuse.value.copy(b.color),v.opacity.value=b.opacity,v.rotation.value=b.rotation,b.map&&(v.map.value=b.map,n(b.map,v.mapTransform)),b.alphaMap&&(v.alphaMap.value=b.alphaMap,n(b.alphaMap,v.alphaMapTransform)),b.alphaTest>0&&(v.alphaTest.value=b.alphaTest)}function d(v,b){v.specular.value.copy(b.specular),v.shininess.value=Math.max(b.shininess,1e-4)}function h(v,b){b.gradientMap&&(v.gradientMap.value=b.gradientMap)}function p(v,b){v.metalness.value=b.metalness,b.metalnessMap&&(v.metalnessMap.value=b.metalnessMap,n(b.metalnessMap,v.metalnessMapTransform)),v.roughness.value=b.roughness,b.roughnessMap&&(v.roughnessMap.value=b.roughnessMap,n(b.roughnessMap,v.roughnessMapTransform)),e.get(b).envMap&&(v.envMapIntensity.value=b.envMapIntensity)}function m(v,b,S){v.ior.value=b.ior,b.sheen>0&&(v.sheenColor.value.copy(b.sheenColor).multiplyScalar(b.sheen),v.sheenRoughness.value=b.sheenRoughness,b.sheenColorMap&&(v.sheenColorMap.value=b.sheenColorMap,n(b.sheenColorMap,v.sheenColorMapTransform)),b.sheenRoughnessMap&&(v.sheenRoughnessMap.value=b.sheenRoughnessMap,n(b.sheenRoughnessMap,v.sheenRoughnessMapTransform))),b.clearcoat>0&&(v.clearcoat.value=b.clearcoat,v.clearcoatRoughness.value=b.clearcoatRoughness,b.clearcoatMap&&(v.clearcoatMap.value=b.clearcoatMap,n(b.clearcoatMap,v.clearcoatMapTransform)),b.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=b.clearcoatRoughnessMap,n(b.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),b.clearcoatNormalMap&&(v.clearcoatNormalMap.value=b.clearcoatNormalMap,n(b.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(b.clearcoatNormalScale),b.side===Hs&&v.clearcoatNormalScale.value.negate())),b.iridescence>0&&(v.iridescence.value=b.iridescence,v.iridescenceIOR.value=b.iridescenceIOR,v.iridescenceThicknessMinimum.value=b.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=b.iridescenceThicknessRange[1],b.iridescenceMap&&(v.iridescenceMap.value=b.iridescenceMap,n(b.iridescenceMap,v.iridescenceMapTransform)),b.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=b.iridescenceThicknessMap,n(b.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),b.transmission>0&&(v.transmission.value=b.transmission,v.transmissionSamplerMap.value=S.texture,v.transmissionSamplerSize.value.set(S.width,S.height),b.transmissionMap&&(v.transmissionMap.value=b.transmissionMap,n(b.transmissionMap,v.transmissionMapTransform)),v.thickness.value=b.thickness,b.thicknessMap&&(v.thicknessMap.value=b.thicknessMap,n(b.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=b.attenuationDistance,v.attenuationColor.value.copy(b.attenuationColor)),b.anisotropy>0&&(v.anisotropyVector.value.set(b.anisotropy*Math.cos(b.anisotropyRotation),b.anisotropy*Math.sin(b.anisotropyRotation)),b.anisotropyMap&&(v.anisotropyMap.value=b.anisotropyMap,n(b.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=b.specularIntensity,v.specularColor.value.copy(b.specularColor),b.specularColorMap&&(v.specularColorMap.value=b.specularColorMap,n(b.specularColorMap,v.specularColorMapTransform)),b.specularIntensityMap&&(v.specularIntensityMap.value=b.specularIntensityMap,n(b.specularIntensityMap,v.specularIntensityMapTransform))}function x(v,b){b.matcap&&(v.matcap.value=b.matcap)}function y(v,b){const S=e.get(b).light;v.referencePosition.value.setFromMatrixPosition(S.matrixWorld),v.nearDistance.value=S.shadow.camera.near,v.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function nMe(t,e,n,r){let i={},s={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(S,N){const T=N.program;r.uniformBlockBinding(S,T)}function u(S,N){let T=i[S.id];T===void 0&&(x(S),T=d(S),i[S.id]=T,S.addEventListener("dispose",v));const k=N.program;r.updateUBOMapping(S,k);const C=e.render.frame;s[S.id]!==C&&(p(S),s[S.id]=C)}function d(S){const N=h();S.__bindingPointIndex=N;const T=t.createBuffer(),k=S.__size,C=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,k,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,N,T),T}function h(){for(let S=0;S<l;S++)if(o.indexOf(S)===-1)return o.push(S),S;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function p(S){const N=i[S.id],T=S.uniforms,k=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,N);for(let C=0,E=T.length;C<E;C++){const P=T[C];if(m(P,C,k)===!0){const A=P.__offset,D=Array.isArray(P.value)?P.value:[P.value];let I=0;for(let L=0;L<D.length;L++){const U=D[L],j=y(U);typeof U=="number"?(P.__data[0]=U,t.bufferSubData(t.UNIFORM_BUFFER,A+I,P.__data)):U.isMatrix3?(P.__data[0]=U.elements[0],P.__data[1]=U.elements[1],P.__data[2]=U.elements[2],P.__data[3]=U.elements[0],P.__data[4]=U.elements[3],P.__data[5]=U.elements[4],P.__data[6]=U.elements[5],P.__data[7]=U.elements[0],P.__data[8]=U.elements[6],P.__data[9]=U.elements[7],P.__data[10]=U.elements[8],P.__data[11]=U.elements[0]):(U.toArray(P.__data,I),I+=j.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,A,P.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(S,N,T){const k=S.value;if(T[N]===void 0){if(typeof k=="number")T[N]=k;else{const C=Array.isArray(k)?k:[k],E=[];for(let P=0;P<C.length;P++)E.push(C[P].clone());T[N]=E}return!0}else if(typeof k=="number"){if(T[N]!==k)return T[N]=k,!0}else{const C=Array.isArray(T[N])?T[N]:[T[N]],E=Array.isArray(k)?k:[k];for(let P=0;P<C.length;P++){const A=C[P];if(A.equals(E[P])===!1)return A.copy(E[P]),!0}}return!1}function x(S){const N=S.uniforms;let T=0;const k=16;let C=0;for(let E=0,P=N.length;E<P;E++){const A=N[E],D={boundary:0,storage:0},I=Array.isArray(A.value)?A.value:[A.value];for(let L=0,U=I.length;L<U;L++){const j=I[L],V=y(j);D.boundary+=V.boundary,D.storage+=V.storage}if(A.__data=new Float32Array(D.storage/Float32Array.BYTES_PER_ELEMENT),A.__offset=T,E>0){C=T%k;const L=k-C;C!==0&&L-D.boundary<0&&(T+=k-C,A.__offset=T)}T+=D.storage}return C=T%k,C>0&&(T+=k-C),S.__size=T,S.__cache={},this}function y(S){const N={boundary:0,storage:0};return typeof S=="number"?(N.boundary=4,N.storage=4):S.isVector2?(N.boundary=8,N.storage=8):S.isVector3||S.isColor?(N.boundary=16,N.storage=12):S.isVector4?(N.boundary=16,N.storage=16):S.isMatrix3?(N.boundary=48,N.storage=48):S.isMatrix4?(N.boundary=64,N.storage=64):S.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",S),N}function v(S){const N=S.target;N.removeEventListener("dispose",v);const T=o.indexOf(N.__bindingPointIndex);o.splice(T,1),t.deleteBuffer(i[N.id]),delete i[N.id],delete s[N.id]}function b(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},s={}}return{bind:c,update:u,dispose:b}}class w3{constructor(e={}){const{canvas:n=Jve(),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:h=!1}=e;this.isWebGLRenderer=!0;let p;r!==null?p=r.getContextAttributes().alpha:p=o;const m=new Uint32Array(4),x=new Int32Array(4);let y=null,v=null;const b=[],S=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Fa,this._useLegacyLights=!1,this.toneMapping=dh,this.toneMappingExposure=1;const N=this;let T=!1,k=0,C=0,E=null,P=-1,A=null;const D=new Cr,I=new Cr;let L=null;const U=new Jt(0);let j=0,V=n.width,K=n.height,z=1,X=null,Y=null;const te=new Cr(0,0,V,K),$=new Cr(0,0,V,K);let W=!1;const ne=new TM;let re=!1,ge=!1,me=null;const ue=new zr,Te=new bn,ie=new We,Ce={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Fe(){return E===null?z:1}let xe=r;function Ze(je,tt){for(let dt=0;dt<je.length;dt++){const ht=je[dt],ut=n.getContext(ht,tt);if(ut!==null)return ut}return null}try{const je={alpha:!0,depth:i,stencil:s,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:h};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${MM}`),n.addEventListener("webglcontextlost",it,!1),n.addEventListener("webglcontextrestored",Ee,!1),n.addEventListener("webglcontextcreationerror",Xe,!1),xe===null){const tt=["webgl2","webgl","experimental-webgl"];if(N.isWebGL1Renderer===!0&&tt.shift(),xe=Ze(tt,je),xe===null)throw Ze(tt)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&xe instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),xe.getShaderPrecisionFormat===void 0&&(xe.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(je){throw console.error("THREE.WebGLRenderer: "+je.message),je}let G,Q,de,q,ee,B,he,ke,pe,H,O,J,le,Se,we,ae,Le,Be,Ve,He,be,Pe,Ie,_e;function Ke(){G=new fSe(xe),Q=new sSe(xe,G,e),G.init(Q),Pe=new QNe(xe,G,Q),de=new XNe(xe,G,Q),q=new gSe(xe),ee=new ONe,B=new YNe(xe,G,de,ee,Q,Pe,q),he=new lSe(N),ke=new hSe(N),pe=new Swe(xe,Q),Ie=new iSe(xe,G,pe,Q),H=new mSe(xe,pe,q,Ie),O=new vSe(xe,H,pe,q),Ve=new ySe(xe,Q,B),ae=new oSe(ee),J=new RNe(N,he,ke,G,Q,Ie,ae),le=new tMe(N,ee),Se=new FNe,we=new $Ne(G,Q),Be=new rSe(N,he,ke,de,O,p,c),Le=new KNe(N,O,Q),_e=new nMe(xe,q,Q,de),He=new aSe(xe,G,q,Q),be=new pSe(xe,G,q,Q),q.programs=J.programs,N.capabilities=Q,N.extensions=G,N.properties=ee,N.renderLists=Se,N.shadowMap=Le,N.state=de,N.info=q}Ke();const Me=new eMe(N,xe);this.xr=Me,this.getContext=function(){return xe},this.getContextAttributes=function(){return xe.getContextAttributes()},this.forceContextLoss=function(){const je=G.get("WEBGL_lose_context");je&&je.loseContext()},this.forceContextRestore=function(){const je=G.get("WEBGL_lose_context");je&&je.restoreContext()},this.getPixelRatio=function(){return z},this.setPixelRatio=function(je){je!==void 0&&(z=je,this.setSize(V,K,!1))},this.getSize=function(je){return je.set(V,K)},this.setSize=function(je,tt,dt=!0){if(Me.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}V=je,K=tt,n.width=Math.floor(je*z),n.height=Math.floor(tt*z),dt===!0&&(n.style.width=je+"px",n.style.height=tt+"px"),this.setViewport(0,0,je,tt)},this.getDrawingBufferSize=function(je){return je.set(V*z,K*z).floor()},this.setDrawingBufferSize=function(je,tt,dt){V=je,K=tt,z=dt,n.width=Math.floor(je*dt),n.height=Math.floor(tt*dt),this.setViewport(0,0,je,tt)},this.getCurrentViewport=function(je){return je.copy(D)},this.getViewport=function(je){return je.copy(te)},this.setViewport=function(je,tt,dt,ht){je.isVector4?te.set(je.x,je.y,je.z,je.w):te.set(je,tt,dt,ht),de.viewport(D.copy(te).multiplyScalar(z).floor())},this.getScissor=function(je){return je.copy($)},this.setScissor=function(je,tt,dt,ht){je.isVector4?$.set(je.x,je.y,je.z,je.w):$.set(je,tt,dt,ht),de.scissor(I.copy($).multiplyScalar(z).floor())},this.getScissorTest=function(){return W},this.setScissorTest=function(je){de.setScissorTest(W=je)},this.setOpaqueSort=function(je){X=je},this.setTransparentSort=function(je){Y=je},this.getClearColor=function(je){return je.copy(Be.getClearColor())},this.setClearColor=function(){Be.setClearColor.apply(Be,arguments)},this.getClearAlpha=function(){return Be.getClearAlpha()},this.setClearAlpha=function(){Be.setClearAlpha.apply(Be,arguments)},this.clear=function(je=!0,tt=!0,dt=!0){let ht=0;if(je){let ut=!1;if(E!==null){const Et=E.texture.format;ut=Et===UK||Et===IK||Et===FK}if(ut){const Et=E.texture.type,fe=Et===hh||Et===Jd||Et===iO||Et===$f||Et===OK||Et===LK,Re=Be.getClearColor(),Ge=Be.getClearAlpha(),Ne=Re.r,Oe=Re.g,nt=Re.b;fe?(m[0]=Ne,m[1]=Oe,m[2]=nt,m[3]=Ge,xe.clearBufferuiv(xe.COLOR,0,m)):(x[0]=Ne,x[1]=Oe,x[2]=nt,x[3]=Ge,xe.clearBufferiv(xe.COLOR,0,x))}else ht|=xe.COLOR_BUFFER_BIT}tt&&(ht|=xe.DEPTH_BUFFER_BIT),dt&&(ht|=xe.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),xe.clear(ht)},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",it,!1),n.removeEventListener("webglcontextrestored",Ee,!1),n.removeEventListener("webglcontextcreationerror",Xe,!1),Se.dispose(),we.dispose(),ee.dispose(),he.dispose(),ke.dispose(),O.dispose(),Ie.dispose(),_e.dispose(),J.dispose(),Me.dispose(),Me.removeEventListener("sessionstart",jt),Me.removeEventListener("sessionend",Dt),me&&(me.dispose(),me=null),yn.stop()};function it(je){je.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),T=!0}function Ee(){console.log("THREE.WebGLRenderer: Context Restored."),T=!1;const je=q.autoReset,tt=Le.enabled,dt=Le.autoUpdate,ht=Le.needsUpdate,ut=Le.type;Ke(),q.autoReset=je,Le.enabled=tt,Le.autoUpdate=dt,Le.needsUpdate=ht,Le.type=ut}function Xe(je){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",je.statusMessage)}function ze(je){const tt=je.target;tt.removeEventListener("dispose",ze),ce(tt)}function ce(je){$e(je),ee.remove(je)}function $e(je){const tt=ee.get(je).programs;tt!==void 0&&(tt.forEach(function(dt){J.releaseProgram(dt)}),je.isShaderMaterial&&J.releaseShaderCache(je))}this.renderBufferDirect=function(je,tt,dt,ht,ut,Et){tt===null&&(tt=Ce);const fe=ut.isMesh&&ut.matrixWorld.determinant()<0,Re=Nn(je,tt,dt,ht,ut);de.setMaterial(ht,fe);let Ge=dt.index,Ne=1;if(ht.wireframe===!0){if(Ge=H.getWireframeAttribute(dt),Ge===void 0)return;Ne=2}const Oe=dt.drawRange,nt=dt.attributes.position;let Ye=Oe.start*Ne,Tt=(Oe.start+Oe.count)*Ne;Et!==null&&(Ye=Math.max(Ye,Et.start*Ne),Tt=Math.min(Tt,(Et.start+Et.count)*Ne)),Ge!==null?(Ye=Math.max(Ye,0),Tt=Math.min(Tt,Ge.count)):nt!=null&&(Ye=Math.max(Ye,0),Tt=Math.min(Tt,nt.count));const At=Tt-Ye;if(At<0||At===1/0)return;Ie.setup(ut,ht,Re,dt,Ge);let It,Rt=He;if(Ge!==null&&(It=pe.get(Ge),Rt=be,Rt.setIndex(It)),ut.isMesh)ht.wireframe===!0?(de.setLineWidth(ht.wireframeLinewidth*Fe()),Rt.setMode(xe.LINES)):Rt.setMode(xe.TRIANGLES);else if(ut.isLine){let Mt=ht.linewidth;Mt===void 0&&(Mt=1),de.setLineWidth(Mt*Fe()),ut.isLineSegments?Rt.setMode(xe.LINES):ut.isLineLoop?Rt.setMode(xe.LINE_LOOP):Rt.setMode(xe.LINE_STRIP)}else ut.isPoints?Rt.setMode(xe.POINTS):ut.isSprite&&Rt.setMode(xe.TRIANGLES);if(ut.isBatchedMesh)Rt.renderMultiDraw(ut._multiDrawStarts,ut._multiDrawCounts,ut._multiDrawCount);else if(ut.isInstancedMesh)Rt.renderInstances(Ye,At,ut.count);else if(dt.isInstancedBufferGeometry){const Mt=dt._maxInstanceCount!==void 0?dt._maxInstanceCount:1/0,en=Math.min(dt.instanceCount,Mt);Rt.renderInstances(Ye,At,en)}else Rt.render(Ye,At)};function ye(je,tt,dt){je.transparent===!0&&je.side===pu&&je.forceSinglePass===!1?(je.side=Hs,je.needsUpdate=!0,sr(je,tt,dt),je.side=Mh,je.needsUpdate=!0,sr(je,tt,dt),je.side=pu):sr(je,tt,dt)}this.compile=function(je,tt,dt=null){dt===null&&(dt=je),v=we.get(dt),v.init(),S.push(v),dt.traverseVisible(function(ut){ut.isLight&&ut.layers.test(tt.layers)&&(v.pushLight(ut),ut.castShadow&&v.pushShadow(ut))}),je!==dt&&je.traverseVisible(function(ut){ut.isLight&&ut.layers.test(tt.layers)&&(v.pushLight(ut),ut.castShadow&&v.pushShadow(ut))}),v.setupLights(N._useLegacyLights);const ht=new Set;return je.traverse(function(ut){const Et=ut.material;if(Et)if(Array.isArray(Et))for(let fe=0;fe<Et.length;fe++){const Re=Et[fe];ye(Re,dt,ut),ht.add(Re)}else ye(Et,dt,ut),ht.add(Et)}),S.pop(),v=null,ht},this.compileAsync=function(je,tt,dt=null){const ht=this.compile(je,tt,dt);return new Promise(ut=>{function Et(){if(ht.forEach(function(fe){ee.get(fe).currentProgram.isReady()&&ht.delete(fe)}),ht.size===0){ut(je);return}setTimeout(Et,10)}G.get("KHR_parallel_shader_compile")!==null?Et():setTimeout(Et,10)})};let Je=null;function at(je){Je&&Je(je)}function jt(){yn.stop()}function Dt(){yn.start()}const yn=new rX;yn.setAnimationLoop(at),typeof self<"u"&&yn.setContext(self),this.setAnimationLoop=function(je){Je=je,Me.setAnimationLoop(je),je===null?yn.stop():yn.start()},Me.addEventListener("sessionstart",jt),Me.addEventListener("sessionend",Dt),this.render=function(je,tt){if(tt!==void 0&&tt.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;je.matrixWorldAutoUpdate===!0&&je.updateMatrixWorld(),tt.parent===null&&tt.matrixWorldAutoUpdate===!0&&tt.updateMatrixWorld(),Me.enabled===!0&&Me.isPresenting===!0&&(Me.cameraAutoUpdate===!0&&Me.updateCamera(tt),tt=Me.getCamera()),je.isScene===!0&&je.onBeforeRender(N,je,tt,E),v=we.get(je,S.length),v.init(),S.push(v),ue.multiplyMatrices(tt.projectionMatrix,tt.matrixWorldInverse),ne.setFromProjectionMatrix(ue),ge=this.localClippingEnabled,re=ae.init(this.clippingPlanes,ge),y=Se.get(je,b.length),y.init(),b.push(y),cn(je,tt,0,N.sortObjects),y.finish(),N.sortObjects===!0&&y.sort(X,Y),this.info.render.frame++,re===!0&&ae.beginShadows();const dt=v.state.shadowsArray;if(Le.render(dt,je,tt),re===!0&&ae.endShadows(),this.info.autoReset===!0&&this.info.reset(),Be.render(y,je),v.setupLights(N._useLegacyLights),tt.isArrayCamera){const ht=tt.cameras;for(let ut=0,Et=ht.length;ut<Et;ut++){const fe=ht[ut];rr(y,je,fe,fe.viewport)}}else rr(y,je,tt);E!==null&&(B.updateMultisampleRenderTarget(E),B.updateRenderTargetMipmap(E)),je.isScene===!0&&je.onAfterRender(N,je,tt),Ie.resetDefaultState(),P=-1,A=null,S.pop(),S.length>0?v=S[S.length-1]:v=null,b.pop(),b.length>0?y=b[b.length-1]:y=null};function cn(je,tt,dt,ht){if(je.visible===!1)return;if(je.layers.test(tt.layers)){if(je.isGroup)dt=je.renderOrder;else if(je.isLOD)je.autoUpdate===!0&&je.update(tt);else if(je.isLight)v.pushLight(je),je.castShadow&&v.pushShadow(je);else if(je.isSprite){if(!je.frustumCulled||ne.intersectsSprite(je)){ht&&ie.setFromMatrixPosition(je.matrixWorld).applyMatrix4(ue);const fe=O.update(je),Re=je.material;Re.visible&&y.push(je,fe,Re,dt,ie.z,null)}}else if((je.isMesh||je.isLine||je.isPoints)&&(!je.frustumCulled||ne.intersectsObject(je))){const fe=O.update(je),Re=je.material;if(ht&&(je.boundingSphere!==void 0?(je.boundingSphere===null&&je.computeBoundingSphere(),ie.copy(je.boundingSphere.center)):(fe.boundingSphere===null&&fe.computeBoundingSphere(),ie.copy(fe.boundingSphere.center)),ie.applyMatrix4(je.matrixWorld).applyMatrix4(ue)),Array.isArray(Re)){const Ge=fe.groups;for(let Ne=0,Oe=Ge.length;Ne<Oe;Ne++){const nt=Ge[Ne],Ye=Re[nt.materialIndex];Ye&&Ye.visible&&y.push(je,fe,Ye,dt,ie.z,nt)}}else Re.visible&&y.push(je,fe,Re,dt,ie.z,null)}}const Et=je.children;for(let fe=0,Re=Et.length;fe<Re;fe++)cn(Et[fe],tt,dt,ht)}function rr(je,tt,dt,ht){const ut=je.opaque,Et=je.transmissive,fe=je.transparent;v.setupLightsView(dt),re===!0&&ae.setGlobalState(N.clippingPlanes,dt),Et.length>0&&Vn(ut,Et,tt,dt),ht&&de.viewport(D.copy(ht)),ut.length>0&&Jn(ut,tt,dt),Et.length>0&&Jn(Et,tt,dt),fe.length>0&&Jn(fe,tt,dt),de.buffers.depth.setTest(!0),de.buffers.depth.setMask(!0),de.buffers.color.setMask(!0),de.setPolygonOffset(!1)}function Vn(je,tt,dt,ht){if((dt.isScene===!0?dt.overrideMaterial:null)!==null)return;const Et=Q.isWebGL2;me===null&&(me=new fm(1,1,{generateMipmaps:!0,type:G.has("EXT_color_buffer_half_float")?ny:hh,minFilter:ty,samples:Et?4:0})),N.getDrawingBufferSize(Te),Et?me.setSize(Te.x,Te.y):me.setSize(sS(Te.x),sS(Te.y));const fe=N.getRenderTarget();N.setRenderTarget(me),N.getClearColor(U),j=N.getClearAlpha(),j<1&&N.setClearColor(16777215,.5),N.clear();const Re=N.toneMapping;N.toneMapping=dh,Jn(je,dt,ht),B.updateMultisampleRenderTarget(me),B.updateRenderTargetMipmap(me);let Ge=!1;for(let Ne=0,Oe=tt.length;Ne<Oe;Ne++){const nt=tt[Ne],Ye=nt.object,Tt=nt.geometry,At=nt.material,It=nt.group;if(At.side===pu&&Ye.layers.test(ht.layers)){const Rt=At.side;At.side=Hs,At.needsUpdate=!0,xn(Ye,dt,ht,Tt,At,It),At.side=Rt,At.needsUpdate=!0,Ge=!0}}Ge===!0&&(B.updateMultisampleRenderTarget(me),B.updateRenderTargetMipmap(me)),N.setRenderTarget(fe),N.setClearColor(U,j),N.toneMapping=Re}function Jn(je,tt,dt){const ht=tt.isScene===!0?tt.overrideMaterial:null;for(let ut=0,Et=je.length;ut<Et;ut++){const fe=je[ut],Re=fe.object,Ge=fe.geometry,Ne=ht===null?fe.material:ht,Oe=fe.group;Re.layers.test(dt.layers)&&xn(Re,tt,dt,Ge,Ne,Oe)}}function xn(je,tt,dt,ht,ut,Et){je.onBeforeRender(N,tt,dt,ht,ut,Et),je.modelViewMatrix.multiplyMatrices(dt.matrixWorldInverse,je.matrixWorld),je.normalMatrix.getNormalMatrix(je.modelViewMatrix),ut.onBeforeRender(N,tt,dt,ht,je,Et),ut.transparent===!0&&ut.side===pu&&ut.forceSinglePass===!1?(ut.side=Hs,ut.needsUpdate=!0,N.renderBufferDirect(dt,tt,ht,ut,je,Et),ut.side=Mh,ut.needsUpdate=!0,N.renderBufferDirect(dt,tt,ht,ut,je,Et),ut.side=pu):N.renderBufferDirect(dt,tt,ht,ut,je,Et),je.onAfterRender(N,tt,dt,ht,ut,Et)}function sr(je,tt,dt){tt.isScene!==!0&&(tt=Ce);const ht=ee.get(je),ut=v.state.lights,Et=v.state.shadowsArray,fe=ut.state.version,Re=J.getParameters(je,ut.state,Et,tt,dt),Ge=J.getProgramCacheKey(Re);let Ne=ht.programs;ht.environment=je.isMeshStandardMaterial?tt.environment:null,ht.fog=tt.fog,ht.envMap=(je.isMeshStandardMaterial?ke:he).get(je.envMap||ht.environment),Ne===void 0&&(je.addEventListener("dispose",ze),Ne=new Map,ht.programs=Ne);let Oe=Ne.get(Ge);if(Oe!==void 0){if(ht.currentProgram===Oe&&ht.lightsStateVersion===fe)return Xn(je,Re),Oe}else Re.uniforms=J.getUniforms(je),je.onBuild(dt,Re,N),je.onBeforeCompile(Re,N),Oe=J.acquireProgram(Re,Ge),Ne.set(Ge,Oe),ht.uniforms=Re.uniforms;const nt=ht.uniforms;return(!je.isShaderMaterial&&!je.isRawShaderMaterial||je.clipping===!0)&&(nt.clippingPlanes=ae.uniform),Xn(je,Re),ht.needsLights=ai(je),ht.lightsStateVersion=fe,ht.needsLights&&(nt.ambientLightColor.value=ut.state.ambient,nt.lightProbe.value=ut.state.probe,nt.directionalLights.value=ut.state.directional,nt.directionalLightShadows.value=ut.state.directionalShadow,nt.spotLights.value=ut.state.spot,nt.spotLightShadows.value=ut.state.spotShadow,nt.rectAreaLights.value=ut.state.rectArea,nt.ltc_1.value=ut.state.rectAreaLTC1,nt.ltc_2.value=ut.state.rectAreaLTC2,nt.pointLights.value=ut.state.point,nt.pointLightShadows.value=ut.state.pointShadow,nt.hemisphereLights.value=ut.state.hemi,nt.directionalShadowMap.value=ut.state.directionalShadowMap,nt.directionalShadowMatrix.value=ut.state.directionalShadowMatrix,nt.spotShadowMap.value=ut.state.spotShadowMap,nt.spotLightMatrix.value=ut.state.spotLightMatrix,nt.spotLightMap.value=ut.state.spotLightMap,nt.pointShadowMap.value=ut.state.pointShadowMap,nt.pointShadowMatrix.value=ut.state.pointShadowMatrix),ht.currentProgram=Oe,ht.uniformsList=null,Oe}function Gn(je){if(je.uniformsList===null){const tt=je.currentProgram.getUniforms();je.uniformsList=E1.seqWithValue(tt.seq,je.uniforms)}return je.uniformsList}function Xn(je,tt){const dt=ee.get(je);dt.outputColorSpace=tt.outputColorSpace,dt.batching=tt.batching,dt.instancing=tt.instancing,dt.instancingColor=tt.instancingColor,dt.skinning=tt.skinning,dt.morphTargets=tt.morphTargets,dt.morphNormals=tt.morphNormals,dt.morphColors=tt.morphColors,dt.morphTargetsCount=tt.morphTargetsCount,dt.numClippingPlanes=tt.numClippingPlanes,dt.numIntersection=tt.numClipIntersection,dt.vertexAlphas=tt.vertexAlphas,dt.vertexTangents=tt.vertexTangents,dt.toneMapping=tt.toneMapping}function Nn(je,tt,dt,ht,ut){tt.isScene!==!0&&(tt=Ce),B.resetTextureUnits();const Et=tt.fog,fe=ht.isMeshStandardMaterial?tt.environment:null,Re=E===null?N.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:Iu,Ge=(ht.isMeshStandardMaterial?ke:he).get(ht.envMap||fe),Ne=ht.vertexColors===!0&&!!dt.attributes.color&&dt.attributes.color.itemSize===4,Oe=!!dt.attributes.tangent&&(!!ht.normalMap||ht.anisotropy>0),nt=!!dt.morphAttributes.position,Ye=!!dt.morphAttributes.normal,Tt=!!dt.morphAttributes.color;let At=dh;ht.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(At=N.toneMapping);const It=dt.morphAttributes.position||dt.morphAttributes.normal||dt.morphAttributes.color,Rt=It!==void 0?It.length:0,Mt=ee.get(ht),en=v.state.lights;if(re===!0&&(ge===!0||je!==A)){const ir=je===A&&ht.id===P;ae.setState(ht,je,ir)}let Ht=!1;ht.version===Mt.__version?(Mt.needsLights&&Mt.lightsStateVersion!==en.state.version||Mt.outputColorSpace!==Re||ut.isBatchedMesh&&Mt.batching===!1||!ut.isBatchedMesh&&Mt.batching===!0||ut.isInstancedMesh&&Mt.instancing===!1||!ut.isInstancedMesh&&Mt.instancing===!0||ut.isSkinnedMesh&&Mt.skinning===!1||!ut.isSkinnedMesh&&Mt.skinning===!0||ut.isInstancedMesh&&Mt.instancingColor===!0&&ut.instanceColor===null||ut.isInstancedMesh&&Mt.instancingColor===!1&&ut.instanceColor!==null||Mt.envMap!==Ge||ht.fog===!0&&Mt.fog!==Et||Mt.numClippingPlanes!==void 0&&(Mt.numClippingPlanes!==ae.numPlanes||Mt.numIntersection!==ae.numIntersection)||Mt.vertexAlphas!==Ne||Mt.vertexTangents!==Oe||Mt.morphTargets!==nt||Mt.morphNormals!==Ye||Mt.morphColors!==Tt||Mt.toneMapping!==At||Q.isWebGL2===!0&&Mt.morphTargetsCount!==Rt)&&(Ht=!0):(Ht=!0,Mt.__version=ht.version);let hn=Mt.currentProgram;Ht===!0&&(hn=sr(ht,tt,ut));let un=!1,Mn=!1,Gt=!1;const on=hn.getUniforms(),dn=Mt.uniforms;if(de.useProgram(hn.program)&&(un=!0,Mn=!0,Gt=!0),ht.id!==P&&(P=ht.id,Mn=!0),un||A!==je){on.setValue(xe,"projectionMatrix",je.projectionMatrix),on.setValue(xe,"viewMatrix",je.matrixWorldInverse);const ir=on.map.cameraPosition;ir!==void 0&&ir.setValue(xe,ie.setFromMatrixPosition(je.matrixWorld)),Q.logarithmicDepthBuffer&&on.setValue(xe,"logDepthBufFC",2/(Math.log(je.far+1)/Math.LN2)),(ht.isMeshPhongMaterial||ht.isMeshToonMaterial||ht.isMeshLambertMaterial||ht.isMeshBasicMaterial||ht.isMeshStandardMaterial||ht.isShaderMaterial)&&on.setValue(xe,"isOrthographic",je.isOrthographicCamera===!0),A!==je&&(A=je,Mn=!0,Gt=!0)}if(ut.isSkinnedMesh){on.setOptional(xe,ut,"bindMatrix"),on.setOptional(xe,ut,"bindMatrixInverse");const ir=ut.skeleton;ir&&(Q.floatVertexTextures?(ir.boneTexture===null&&ir.computeBoneTexture(),on.setValue(xe,"boneTexture",ir.boneTexture,B)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}ut.isBatchedMesh&&(on.setOptional(xe,ut,"batchingTexture"),on.setValue(xe,"batchingTexture",ut._matricesTexture,B));const Yt=dt.morphAttributes;if((Yt.position!==void 0||Yt.normal!==void 0||Yt.color!==void 0&&Q.isWebGL2===!0)&&Ve.update(ut,dt,hn),(Mn||Mt.receiveShadow!==ut.receiveShadow)&&(Mt.receiveShadow=ut.receiveShadow,on.setValue(xe,"receiveShadow",ut.receiveShadow)),ht.isMeshGouraudMaterial&&ht.envMap!==null&&(dn.envMap.value=Ge,dn.flipEnvMap.value=Ge.isCubeTexture&&Ge.isRenderTargetTexture===!1?-1:1),Mn&&(on.setValue(xe,"toneMappingExposure",N.toneMappingExposure),Mt.needsLights&&hi(dn,Gt),Et&&ht.fog===!0&&le.refreshFogUniforms(dn,Et),le.refreshMaterialUniforms(dn,ht,z,K,me),E1.upload(xe,Gn(Mt),dn,B)),ht.isShaderMaterial&&ht.uniformsNeedUpdate===!0&&(E1.upload(xe,Gn(Mt),dn,B),ht.uniformsNeedUpdate=!1),ht.isSpriteMaterial&&on.setValue(xe,"center",ut.center),on.setValue(xe,"modelViewMatrix",ut.modelViewMatrix),on.setValue(xe,"normalMatrix",ut.normalMatrix),on.setValue(xe,"modelMatrix",ut.matrixWorld),ht.isShaderMaterial||ht.isRawShaderMaterial){const ir=ht.uniformsGroups;for(let Pn=0,si=ir.length;Pn<si;Pn++)if(Q.isWebGL2){const ar=ir[Pn];_e.update(ar,hn),_e.bind(ar,hn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return hn}function hi(je,tt){je.ambientLightColor.needsUpdate=tt,je.lightProbe.needsUpdate=tt,je.directionalLights.needsUpdate=tt,je.directionalLightShadows.needsUpdate=tt,je.pointLights.needsUpdate=tt,je.pointLightShadows.needsUpdate=tt,je.spotLights.needsUpdate=tt,je.spotLightShadows.needsUpdate=tt,je.rectAreaLights.needsUpdate=tt,je.hemisphereLights.needsUpdate=tt}function ai(je){return je.isMeshLambertMaterial||je.isMeshToonMaterial||je.isMeshPhongMaterial||je.isMeshStandardMaterial||je.isShadowMaterial||je.isShaderMaterial&&je.lights===!0}this.getActiveCubeFace=function(){return k},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(je,tt,dt){ee.get(je.texture).__webglTexture=tt,ee.get(je.depthTexture).__webglTexture=dt;const ht=ee.get(je);ht.__hasExternalTextures=!0,ht.__hasExternalTextures&&(ht.__autoAllocateDepthBuffer=dt===void 0,ht.__autoAllocateDepthBuffer||G.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),ht.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(je,tt){const dt=ee.get(je);dt.__webglFramebuffer=tt,dt.__useDefaultFramebuffer=tt===void 0},this.setRenderTarget=function(je,tt=0,dt=0){E=je,k=tt,C=dt;let ht=!0,ut=null,Et=!1,fe=!1;if(je){const Ge=ee.get(je);Ge.__useDefaultFramebuffer!==void 0?(de.bindFramebuffer(xe.FRAMEBUFFER,null),ht=!1):Ge.__webglFramebuffer===void 0?B.setupRenderTarget(je):Ge.__hasExternalTextures&&B.rebindTextures(je,ee.get(je.texture).__webglTexture,ee.get(je.depthTexture).__webglTexture);const Ne=je.texture;(Ne.isData3DTexture||Ne.isDataArrayTexture||Ne.isCompressedArrayTexture)&&(fe=!0);const Oe=ee.get(je).__webglFramebuffer;je.isWebGLCubeRenderTarget?(Array.isArray(Oe[tt])?ut=Oe[tt][dt]:ut=Oe[tt],Et=!0):Q.isWebGL2&&je.samples>0&&B.useMultisampledRTT(je)===!1?ut=ee.get(je).__webglMultisampledFramebuffer:Array.isArray(Oe)?ut=Oe[dt]:ut=Oe,D.copy(je.viewport),I.copy(je.scissor),L=je.scissorTest}else D.copy(te).multiplyScalar(z).floor(),I.copy($).multiplyScalar(z).floor(),L=W;if(de.bindFramebuffer(xe.FRAMEBUFFER,ut)&&Q.drawBuffers&&ht&&de.drawBuffers(je,ut),de.viewport(D),de.scissor(I),de.setScissorTest(L),Et){const Ge=ee.get(je.texture);xe.framebufferTexture2D(xe.FRAMEBUFFER,xe.COLOR_ATTACHMENT0,xe.TEXTURE_CUBE_MAP_POSITIVE_X+tt,Ge.__webglTexture,dt)}else if(fe){const Ge=ee.get(je.texture),Ne=tt||0;xe.framebufferTextureLayer(xe.FRAMEBUFFER,xe.COLOR_ATTACHMENT0,Ge.__webglTexture,dt||0,Ne)}P=-1},this.readRenderTargetPixels=function(je,tt,dt,ht,ut,Et,fe){if(!(je&&je.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Re=ee.get(je).__webglFramebuffer;if(je.isWebGLCubeRenderTarget&&fe!==void 0&&(Re=Re[fe]),Re){de.bindFramebuffer(xe.FRAMEBUFFER,Re);try{const Ge=je.texture,Ne=Ge.format,Oe=Ge.type;if(Ne!==Jo&&Pe.convert(Ne)!==xe.getParameter(xe.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const nt=Oe===ny&&(G.has("EXT_color_buffer_half_float")||Q.isWebGL2&&G.has("EXT_color_buffer_float"));if(Oe!==hh&&Pe.convert(Oe)!==xe.getParameter(xe.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Oe===_u&&(Q.isWebGL2||G.has("OES_texture_float")||G.has("WEBGL_color_buffer_float")))&&!nt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}tt>=0&&tt<=je.width-ht&&dt>=0&&dt<=je.height-ut&&xe.readPixels(tt,dt,ht,ut,Pe.convert(Ne),Pe.convert(Oe),Et)}finally{const Ge=E!==null?ee.get(E).__webglFramebuffer:null;de.bindFramebuffer(xe.FRAMEBUFFER,Ge)}}},this.copyFramebufferToTexture=function(je,tt,dt=0){const ht=Math.pow(2,-dt),ut=Math.floor(tt.image.width*ht),Et=Math.floor(tt.image.height*ht);B.setTexture2D(tt,0),xe.copyTexSubImage2D(xe.TEXTURE_2D,dt,0,0,je.x,je.y,ut,Et),de.unbindTexture()},this.copyTextureToTexture=function(je,tt,dt,ht=0){const ut=tt.image.width,Et=tt.image.height,fe=Pe.convert(dt.format),Re=Pe.convert(dt.type);B.setTexture2D(dt,0),xe.pixelStorei(xe.UNPACK_FLIP_Y_WEBGL,dt.flipY),xe.pixelStorei(xe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,dt.premultiplyAlpha),xe.pixelStorei(xe.UNPACK_ALIGNMENT,dt.unpackAlignment),tt.isDataTexture?xe.texSubImage2D(xe.TEXTURE_2D,ht,je.x,je.y,ut,Et,fe,Re,tt.image.data):tt.isCompressedTexture?xe.compressedTexSubImage2D(xe.TEXTURE_2D,ht,je.x,je.y,tt.mipmaps[0].width,tt.mipmaps[0].height,fe,tt.mipmaps[0].data):xe.texSubImage2D(xe.TEXTURE_2D,ht,je.x,je.y,fe,Re,tt.image),ht===0&&dt.generateMipmaps&&xe.generateMipmap(xe.TEXTURE_2D),de.unbindTexture()},this.copyTextureToTexture3D=function(je,tt,dt,ht,ut=0){if(N.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Et=je.max.x-je.min.x+1,fe=je.max.y-je.min.y+1,Re=je.max.z-je.min.z+1,Ge=Pe.convert(ht.format),Ne=Pe.convert(ht.type);let Oe;if(ht.isData3DTexture)B.setTexture3D(ht,0),Oe=xe.TEXTURE_3D;else if(ht.isDataArrayTexture)B.setTexture2DArray(ht,0),Oe=xe.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}xe.pixelStorei(xe.UNPACK_FLIP_Y_WEBGL,ht.flipY),xe.pixelStorei(xe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ht.premultiplyAlpha),xe.pixelStorei(xe.UNPACK_ALIGNMENT,ht.unpackAlignment);const nt=xe.getParameter(xe.UNPACK_ROW_LENGTH),Ye=xe.getParameter(xe.UNPACK_IMAGE_HEIGHT),Tt=xe.getParameter(xe.UNPACK_SKIP_PIXELS),At=xe.getParameter(xe.UNPACK_SKIP_ROWS),It=xe.getParameter(xe.UNPACK_SKIP_IMAGES),Rt=dt.isCompressedTexture?dt.mipmaps[0]:dt.image;xe.pixelStorei(xe.UNPACK_ROW_LENGTH,Rt.width),xe.pixelStorei(xe.UNPACK_IMAGE_HEIGHT,Rt.height),xe.pixelStorei(xe.UNPACK_SKIP_PIXELS,je.min.x),xe.pixelStorei(xe.UNPACK_SKIP_ROWS,je.min.y),xe.pixelStorei(xe.UNPACK_SKIP_IMAGES,je.min.z),dt.isDataTexture||dt.isData3DTexture?xe.texSubImage3D(Oe,ut,tt.x,tt.y,tt.z,Et,fe,Re,Ge,Ne,Rt.data):dt.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),xe.compressedTexSubImage3D(Oe,ut,tt.x,tt.y,tt.z,Et,fe,Re,Ge,Rt.data)):xe.texSubImage3D(Oe,ut,tt.x,tt.y,tt.z,Et,fe,Re,Ge,Ne,Rt),xe.pixelStorei(xe.UNPACK_ROW_LENGTH,nt),xe.pixelStorei(xe.UNPACK_IMAGE_HEIGHT,Ye),xe.pixelStorei(xe.UNPACK_SKIP_PIXELS,Tt),xe.pixelStorei(xe.UNPACK_SKIP_ROWS,At),xe.pixelStorei(xe.UNPACK_SKIP_IMAGES,It),ut===0&&ht.generateMipmaps&&xe.generateMipmap(Oe),de.unbindTexture()},this.initTexture=function(je){je.isCubeTexture?B.setTextureCube(je,0):je.isData3DTexture?B.setTexture3D(je,0):je.isDataArrayTexture||je.isCompressedArrayTexture?B.setTexture2DArray(je,0):B.setTexture2D(je,0),de.unbindTexture()},this.resetState=function(){k=0,C=0,E=null,de.reset(),Ie.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return dc}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===aO?"display-p3":"srgb",n.unpackColorSpace=Er.workingColorSpace===EM?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(e){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!e}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Fa?Gf:BK}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Gf?Fa:Iu}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 rMe extends w3{}rMe.prototype.isWebGL1Renderer=!0;class dO{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 dO(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class iMe extends ys{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 aMe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=x3,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Cu()}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=Cu()),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=Cu()),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 cs=new We;class eh{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++)cs.fromBufferAttribute(this,n),cs.applyMatrix4(e),this.setXYZ(n,cs.x,cs.y,cs.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)cs.fromBufferAttribute(this,n),cs.applyNormalMatrix(e),this.setXYZ(n,cs.x,cs.y,cs.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)cs.fromBufferAttribute(this,n),cs.transformDirection(e),this.setXYZ(n,cs.x,cs.y,cs.z);return this}setX(e,n){return this.normalized&&(n=kr(n,this.array)),this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.normalized&&(n=kr(n,this.array)),this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.normalized&&(n=kr(n,this.array)),this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.normalized&&(n=kr(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=oc(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=oc(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=oc(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=oc(n,this.array)),n}setXY(e,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(n=kr(n,this.array),r=kr(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=kr(n,this.array),r=kr(r,this.array),i=kr(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=kr(n,this.array),r=kr(r,this.array),i=kr(i,this.array),s=kr(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 yo(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 eh(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 sMe extends $s{constructor(e=null,n=1,r=1,i,s,o,l,c,u=La,d=La,h,p){super(null,o,l,c,u,d,i,s,h,p),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function oMe(t,e){return t.z-e.z}function lMe(t,e){return e.z-t.z}class cMe{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 Yp="batchId",Rd=new zr,N6=new zr,uMe=new zr,M6=new zr,mA=new TM,T_=new sl,yf=new mc,Gb=new We,pA=new cMe,Ka=new Ll,A_=[];function dMe(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 hMe extends Ll{get maxGeometryCount(){return this._maxGeometryCount}constructor(e,n,r=n*2,i){super(new ns,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 sMe(n,e,e,Jo,_u);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:h}=c,p=new u.constructor(r*d),m=new c.constructor(p,d,h);m.setUsage(c.usage),n.setAttribute(l,m)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(s):new Uint16Array(s);n.setIndex(new yo(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Yp,new yo(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Yp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Yp}"`);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===Yp)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 sl);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,Rd),this.getBoundingBoxAt(i,T_).applyMatrix4(Rd),n.union(T_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new mc);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,Rd),this.getBoundingSphereAt(i,yf).applyMatrix4(Rd),n.union(yf))}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 h=this._visibility,p=this._active,m=this._matricesTexture,x=this._matricesTexture.image.data;h.push(!0),p.push(!0);const y=this._geometryCount;this._geometryCount++,uMe.toArray(x,y*16),m.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new sl,sphereInitialized:!1,sphere:new mc});const v=this.geometry.getAttribute(Yp);for(let b=0;b<i.vertexCount;b++)v.setX(i.vertexStart+b,y);return v.needsUpdate=!0,this.setGeometryAt(y,e),y}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,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 m in r.attributes){if(m===Yp)continue;const x=n.getAttribute(m),y=r.getAttribute(m);dMe(x,y,c);const v=x.itemSize;for(let b=x.count,S=u;b<S;b++){const N=c+b;for(let T=0;T<v;T++)y.setComponent(N,T,0)}y.needsUpdate=!0}if(i){const m=l.indexStart;for(let x=0;x<o.count;x++)s.setX(m+x,c+o.getX(x));for(let x=o.count,y=l.indexCount;x<y;x++)s.setX(m+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 h=this._drawRanges[e],p=n.getAttribute("position");return h.count=i?o.count:p.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,h=u.start+u.count;d<h;d++){let p=d;l&&(p=l.getX(p)),s.expandByPoint(Gb.fromBufferAttribute(c,p))}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,T_),T_.getCenter(s.center);const l=o.index,c=o.attributes.position,u=this._drawRanges[e];let d=0;for(let h=u.start,p=u.start+u.count;h<p;h++){let m=h;l&&(m=l.getX(m)),Gb.fromBufferAttribute(c,m),d=Math.max(d,s.center.distanceToSquared(Gb))}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;Ka.material=this.material,Ka.geometry.index=c.index,Ka.geometry.attributes=c.attributes,Ka.geometry.boundingBox===null&&(Ka.geometry.boundingBox=new sl),Ka.geometry.boundingSphere===null&&(Ka.geometry.boundingSphere=new mc);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=s[u];Ka.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,Ka.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,Ka.geometry.boundingBox),this.getBoundingSphereAt(u,Ka.geometry.boundingSphere),Ka.raycast(e,A_);for(let h=0,p=A_.length;h<p;h++){const m=A_[h];m.object=this,m.batchId=u,n.push(m)}A_.length=0}Ka.material=null,Ka.geometry.index=null,Ka.geometry.attributes={},Ka.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,h=this._drawRanges,p=this.perObjectFrustumCulled;p&&(M6.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),mA.setFromProjectionMatrix(M6,e.isWebGPURenderer?ry:dc));let m=0;if(this.sortObjects){N6.copy(this.matrixWorld).invert(),Gb.setFromMatrixPosition(r.matrixWorld).applyMatrix4(N6);for(let v=0,b=c.length;v<b;v++)if(c[v]){this.getMatrixAt(v,Rd),this.getBoundingSphereAt(v,yf).applyMatrix4(Rd);let S=!1;if(p&&(S=!mA.intersectsSphere(yf)),!S){const N=Gb.distanceTo(yf.center);pA.push(h[v],N)}}const x=pA.list,y=this.customSort;y===null?x.sort(s.transparent?lMe:oMe):y.call(this,x,r);for(let v=0,b=x.length;v<b;v++){const S=x[v];u[m]=S.start*l,d[m]=S.count,m++}pA.reset()}else for(let x=0,y=c.length;x<y;x++)if(c[x]){let v=!1;if(p&&(this.getMatrixAt(x,Rd),this.getBoundingSphereAt(x,yf).applyMatrix4(Rd),v=!mA.intersectsSphere(yf)),!v){const b=h[x];u[m]=b.start*l,d[m]=b.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,s,o){this.onBeforeRender(e,null,i,s,o)}}class $y extends Nx{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 k6=new We,E6=new We,T6=new zr,gA=new oO,C_=new mc;let fMe=class extends ys{constructor(e=new ns,n=new $y){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++)k6.fromBufferAttribute(n,i-1),E6.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=k6.distanceTo(E6);e.setAttribute("lineDistance",new Ai(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(),C_.copy(r.boundingSphere),C_.applyMatrix4(i),C_.radius+=s,e.ray.intersectsSphere(C_)===!1)return;T6.copy(i).invert(),gA.copy(e.ray).applyMatrix4(T6);const l=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new We,d=new We,h=new We,p=new We,m=this.isLineSegments?2:1,x=r.index,v=r.attributes.position;if(x!==null){const b=Math.max(0,o.start),S=Math.min(x.count,o.start+o.count);for(let N=b,T=S-1;N<T;N+=m){const k=x.getX(N),C=x.getX(N+1);if(u.fromBufferAttribute(v,k),d.fromBufferAttribute(v,C),gA.distanceSqToSegment(u,d,p,h)>c)continue;p.applyMatrix4(this.matrixWorld);const P=e.ray.origin.distanceTo(p);P<e.near||P>e.far||n.push({distance:P,point:h.clone().applyMatrix4(this.matrixWorld),index:N,face:null,faceIndex:null,object:this})}}else{const b=Math.max(0,o.start),S=Math.min(v.count,o.start+o.count);for(let N=b,T=S-1;N<T;N+=m){if(u.fromBufferAttribute(v,N),d.fromBufferAttribute(v,N+1),gA.distanceSqToSegment(u,d,p,h)>c)continue;p.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(p);C<e.near||C>e.far||n.push({distance:C,point:h.clone().applyMatrix4(this.matrixWorld),index:N,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 A6=new We,C6=new We;class CM extends fMe{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)A6.fromBufferAttribute(n,i),C6.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+A6.distanceTo(C6);e.setAttribute("lineDistance",new Ai(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class mMe extends ns{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new We,s=new We;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 h=c[u],p=h.start,m=h.count;for(let x=p,y=p+m;x<y;x+=3)for(let v=0;v<3;v++){const b=l.getX(x+v),S=l.getX(x+(v+1)%3);i.fromBufferAttribute(o,b),s.fromBufferAttribute(o,S),j6(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,h=3*l+(u+1)%3;i.fromBufferAttribute(o,d),s.fromBufferAttribute(o,h),j6(i,s,r)===!0&&(n.push(i.x,i.y,i.z),n.push(s.x,s.y,s.z))}}this.setAttribute("position",new Ai(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function j6(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 pMe extends Nx{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=HK,this.normalScale=new bn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=rO,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 gMe extends $y{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 uX extends ys{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 xA=new zr,P6=new We,D6=new We;class xMe{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new bn(512,512),this.map=null,this.mapPass=null,this.matrix=new zr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new TM,this._frameExtents=new bn(1,1),this._viewportCount=1,this._viewports=[new Cr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;P6.setFromMatrixPosition(e.matrixWorld),n.position.copy(P6),D6.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(D6),n.updateMatrixWorld(),xA.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(xA),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.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 R6=new zr,qb=new We,bA=new We;class bMe extends xMe{constructor(){super(new ho(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new bn(4,2),this._viewportCount=6,this._viewports=[new Cr(2,1,1,1),new Cr(0,1,1,1),new Cr(3,1,1,1),new Cr(1,1,1,1),new Cr(3,0,1,1),new Cr(1,0,1,1)],this._cubeDirections=[new We(1,0,0),new We(-1,0,0),new We(0,0,1),new We(0,0,-1),new We(0,1,0),new We(0,-1,0)],this._cubeUps=[new We(0,1,0),new We(0,1,0),new We(0,1,0),new We(0,1,0),new We(0,0,1),new We(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()),qb.setFromMatrixPosition(e.matrixWorld),r.position.copy(qb),bA.copy(r.position),bA.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(bA),r.updateMatrixWorld(),i.makeTranslation(-qb.x,-qb.y,-qb.z),R6.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(R6)}}class yMe extends uX{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 bMe}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 vMe extends uX{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class wMe extends ns{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 _3 extends aMe{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 O6{constructor(e=1,n=0,r=0){return this.radius=e,this.phi=n,this.theta=r,this}set(e,n,r){return this.radius=e,this.phi=n,this.theta=r,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,r){return this.radius=Math.sqrt(e*e+n*n+r*r),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,r),this.phi=Math.acos(Ia(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const L6=new We,j_=new We;class _Me{constructor(e=new We,n=new We){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){L6.subVectors(e,this.start),j_.subVectors(this.end,this.start);const r=j_.dot(j_);let s=j_.dot(L6)/r;return n&&(s=Ia(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 SMe extends CM{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 ns;i.setAttribute("position",new Ai(n,3)),i.setAttribute("color",new Ai(r,3));const s=new $y({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:MM}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=MM);class pc{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"),pc.nextNameID=pc.nextNameID||0,this.$name.id=`lil-gui-name-${++pc.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 NMe extends pc{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 S3(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 MMe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:S3,toHexString:S3},ay={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},kMe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=ay.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 ay.toHexString(i)}},EMe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=ay.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 ay.toHexString(i)}},TMe=[MMe,ay,kMe,EMe];function AMe(t){return TMe.find(e=>e.match(t))}class CMe extends pc{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=AMe(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=S3(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 yA extends pc{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 jMe extends pc{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 S=parseFloat(this.$input.value);isNaN(S)||(this._stepExplicit&&(S=this._snap(S)),this.setValue(this._clamp(S)))},r=S=>{const N=parseFloat(this.$input.value);isNaN(N)||(this._snapClampSetValue(N+S),this.$input.value=this.getValue())},i=S=>{S.key==="Enter"&&this.$input.blur(),S.code==="ArrowUp"&&(S.preventDefault(),r(this._step*this._arrowKeyMultiplier(S))),S.code==="ArrowDown"&&(S.preventDefault(),r(this._step*this._arrowKeyMultiplier(S)*-1))},s=S=>{this._inputFocused&&(S.preventDefault(),r(this._step*this._normalizeMouseWheel(S)))};let o=!1,l,c,u,d,h;const p=5,m=S=>{l=S.clientX,c=u=S.clientY,o=!0,d=this.getValue(),h=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",y)},x=S=>{if(o){const N=S.clientX-l,T=S.clientY-c;Math.abs(T)>p?(S.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(N)>p&&y()}if(!o){const N=S.clientY-u;h-=N*this._step*this._arrowKeyMultiplier(S),d+h>this._max?h=this._max-d:d+h<this._min&&(h=this._min-d),this._snapClampSetValue(d+h)}u=S.clientY},y=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",y)},v=()=>{this._inputFocused=!0},b=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",s,{passive:!1}),this.$input.addEventListener("mousedown",m),this.$input.addEventListener("focus",v),this.$input.addEventListener("blur",b)}_initSlider(){this._hasSlider=!0,this.$slider=document.createElement("div"),this.$slider.classList.add("slider"),this.$fill=document.createElement("div"),this.$fill.classList.add("fill"),this.$slider.appendChild(this.$fill),this.$widget.insertBefore(this.$slider,this.$input),this.domElement.classList.add("hasSlider");const e=(b,S,N,T,k)=>(b-S)/(N-S)*(k-T)+T,n=b=>{const S=this.$slider.getBoundingClientRect();let N=e(b,S.left,S.right,this._min,this._max);this._snapClampSetValue(N)},r=b=>{this._setDraggingStyle(!0),n(b.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",s)},i=b=>{n(b.clientX)},s=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",s)};let o=!1,l,c;const u=b=>{b.preventDefault(),this._setDraggingStyle(!0),n(b.touches[0].clientX),o=!1},d=b=>{b.touches.length>1||(this._hasScrollBar?(l=b.touches[0].clientX,c=b.touches[0].clientY,o=!0):u(b),window.addEventListener("touchmove",h,{passive:!1}),window.addEventListener("touchend",p))},h=b=>{if(o){const S=b.touches[0].clientX-l,N=b.touches[0].clientY-c;Math.abs(S)>Math.abs(N)?u(b):(window.removeEventListener("touchmove",h),window.removeEventListener("touchend",p))}else b.preventDefault(),n(b.touches[0].clientX)},p=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",h),window.removeEventListener("touchend",p)},m=this._callOnFinishChange.bind(this),x=400;let y;const v=b=>{if(Math.abs(b.deltaX)<Math.abs(b.deltaY)&&this._hasScrollBar)return;b.preventDefault();const N=this._normalizeMouseWheel(b)*this._step;this._snapClampSetValue(this.getValue()+N),this.$input.value=this.getValue(),clearTimeout(y),y=setTimeout(m,x)};this.$slider.addEventListener("mousedown",r),this.$slider.addEventListener("touchstart",d,{passive:!1}),this.$slider.addEventListener("wheel",v,{passive:!1})}_setDraggingStyle(e,n="horizontal"){this.$slider&&this.$slider.classList.toggle("active",e),document.body.classList.toggle("lil-gui-dragging",e),document.body.classList.toggle(`lil-gui-${n}`,e)}_getImplicitStep(){return this._hasMin&&this._hasMax?(this._max-this._min)/1e3:.1}_onUpdateMinMax(){!this._hasSlider&&this._hasMin&&this._hasMax&&(this._stepExplicit||this.step(this._getImplicitStep(),!1),this._initSlider(),this.updateDisplay())}_normalizeMouseWheel(e){let{deltaX:n,deltaY:r}=e;return Math.floor(e.deltaY)!==e.deltaY&&e.wheelDelta&&(n=0,r=-e.wheelDelta/120,r*=this._stepExplicit?1:10),n+-r}_arrowKeyMultiplier(e){let n=this._stepExplicit?1:10;return e.shiftKey?n*=10:e.altKey&&(n/=10),n}_snap(e){const n=Math.round(e/this._step)*this._step;return parseFloat(n.toPrecision(15))}_clamp(e){return e<this._min&&(e=this._min),e>this._max&&(e=this._max),e}_snapClampSetValue(e){this.setValue(this._clamp(this._snap(e)))}get _hasScrollBar(){const e=this.parent.root.$children;return e.scrollHeight>e.clientHeight}get _hasMin(){return this._min!==void 0}get _hasMax(){return this._max!==void 0}}class PMe extends pc{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 DMe extends pc{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 RMe=`.lil-gui {
  7397. font-family: var(--font-family);
  7398. font-size: var(--font-size);
  7399. line-height: 1;
  7400. font-weight: normal;
  7401. font-style: normal;
  7402. text-align: left;
  7403. color: var(--text-color);
  7404. user-select: none;
  7405. -webkit-user-select: none;
  7406. touch-action: manipulation;
  7407. --background-color: #1f1f1f;
  7408. --text-color: #ebebeb;
  7409. --title-background-color: #111111;
  7410. --title-text-color: #ebebeb;
  7411. --widget-color: #424242;
  7412. --hover-color: #4f4f4f;
  7413. --focus-color: #595959;
  7414. --number-color: #2cc9ff;
  7415. --string-color: #a2db3c;
  7416. --font-size: 11px;
  7417. --input-font-size: 11px;
  7418. --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  7419. --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
  7420. --padding: 4px;
  7421. --spacing: 4px;
  7422. --widget-height: 20px;
  7423. --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
  7424. --name-width: 45%;
  7425. --slider-knob-width: 2px;
  7426. --slider-input-width: 27%;
  7427. --color-input-width: 27%;
  7428. --slider-input-min-width: 45px;
  7429. --color-input-min-width: 45px;
  7430. --folder-indent: 7px;
  7431. --widget-padding: 0 0 0 3px;
  7432. --widget-border-radius: 2px;
  7433. --checkbox-size: calc(0.75 * var(--widget-height));
  7434. --scrollbar-width: 5px;
  7435. }
  7436. .lil-gui, .lil-gui * {
  7437. box-sizing: border-box;
  7438. margin: 0;
  7439. padding: 0;
  7440. }
  7441. .lil-gui.root {
  7442. width: var(--width, 245px);
  7443. display: flex;
  7444. flex-direction: column;
  7445. background: var(--background-color);
  7446. }
  7447. .lil-gui.root > .title {
  7448. background: var(--title-background-color);
  7449. color: var(--title-text-color);
  7450. }
  7451. .lil-gui.root > .children {
  7452. overflow-x: hidden;
  7453. overflow-y: auto;
  7454. }
  7455. .lil-gui.root > .children::-webkit-scrollbar {
  7456. width: var(--scrollbar-width);
  7457. height: var(--scrollbar-width);
  7458. background: var(--background-color);
  7459. }
  7460. .lil-gui.root > .children::-webkit-scrollbar-thumb {
  7461. border-radius: var(--scrollbar-width);
  7462. background: var(--focus-color);
  7463. }
  7464. @media (pointer: coarse) {
  7465. .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
  7466. --widget-height: 28px;
  7467. --padding: 6px;
  7468. --spacing: 6px;
  7469. --font-size: 13px;
  7470. --input-font-size: 16px;
  7471. --folder-indent: 10px;
  7472. --scrollbar-width: 7px;
  7473. --slider-input-min-width: 50px;
  7474. --color-input-min-width: 65px;
  7475. }
  7476. }
  7477. .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
  7478. --widget-height: 28px;
  7479. --padding: 6px;
  7480. --spacing: 6px;
  7481. --font-size: 13px;
  7482. --input-font-size: 16px;
  7483. --folder-indent: 10px;
  7484. --scrollbar-width: 7px;
  7485. --slider-input-min-width: 50px;
  7486. --color-input-min-width: 65px;
  7487. }
  7488. .lil-gui.autoPlace {
  7489. max-height: 100%;
  7490. position: fixed;
  7491. top: 0;
  7492. right: 15px;
  7493. z-index: 1001;
  7494. }
  7495. .lil-gui .controller {
  7496. display: flex;
  7497. align-items: center;
  7498. padding: 0 var(--padding);
  7499. margin: var(--spacing) 0;
  7500. }
  7501. .lil-gui .controller.disabled {
  7502. opacity: 0.5;
  7503. }
  7504. .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
  7505. pointer-events: none !important;
  7506. }
  7507. .lil-gui .controller > .name {
  7508. min-width: var(--name-width);
  7509. flex-shrink: 0;
  7510. white-space: pre;
  7511. padding-right: var(--spacing);
  7512. line-height: var(--widget-height);
  7513. }
  7514. .lil-gui .controller .widget {
  7515. position: relative;
  7516. display: flex;
  7517. align-items: center;
  7518. width: 100%;
  7519. min-height: var(--widget-height);
  7520. }
  7521. .lil-gui .controller.string input {
  7522. color: var(--string-color);
  7523. }
  7524. .lil-gui .controller.boolean {
  7525. cursor: pointer;
  7526. }
  7527. .lil-gui .controller.color .display {
  7528. width: 100%;
  7529. height: var(--widget-height);
  7530. border-radius: var(--widget-border-radius);
  7531. position: relative;
  7532. }
  7533. @media (hover: hover) {
  7534. .lil-gui .controller.color .display:hover:before {
  7535. content: " ";
  7536. display: block;
  7537. position: absolute;
  7538. border-radius: var(--widget-border-radius);
  7539. border: 1px solid #fff9;
  7540. top: 0;
  7541. right: 0;
  7542. bottom: 0;
  7543. left: 0;
  7544. }
  7545. }
  7546. .lil-gui .controller.color input[type=color] {
  7547. opacity: 0;
  7548. width: 100%;
  7549. height: 100%;
  7550. cursor: pointer;
  7551. }
  7552. .lil-gui .controller.color input[type=text] {
  7553. margin-left: var(--spacing);
  7554. font-family: var(--font-family-mono);
  7555. min-width: var(--color-input-min-width);
  7556. width: var(--color-input-width);
  7557. flex-shrink: 0;
  7558. }
  7559. .lil-gui .controller.option select {
  7560. opacity: 0;
  7561. position: absolute;
  7562. width: 100%;
  7563. max-width: 100%;
  7564. }
  7565. .lil-gui .controller.option .display {
  7566. position: relative;
  7567. pointer-events: none;
  7568. border-radius: var(--widget-border-radius);
  7569. height: var(--widget-height);
  7570. line-height: var(--widget-height);
  7571. max-width: 100%;
  7572. overflow: hidden;
  7573. word-break: break-all;
  7574. padding-left: 0.55em;
  7575. padding-right: 1.75em;
  7576. background: var(--widget-color);
  7577. }
  7578. @media (hover: hover) {
  7579. .lil-gui .controller.option .display.focus {
  7580. background: var(--focus-color);
  7581. }
  7582. }
  7583. .lil-gui .controller.option .display.active {
  7584. background: var(--focus-color);
  7585. }
  7586. .lil-gui .controller.option .display:after {
  7587. font-family: "lil-gui";
  7588. content: "↕";
  7589. position: absolute;
  7590. top: 0;
  7591. right: 0;
  7592. bottom: 0;
  7593. padding-right: 0.375em;
  7594. }
  7595. .lil-gui .controller.option .widget,
  7596. .lil-gui .controller.option select {
  7597. cursor: pointer;
  7598. }
  7599. @media (hover: hover) {
  7600. .lil-gui .controller.option .widget:hover .display {
  7601. background: var(--hover-color);
  7602. }
  7603. }
  7604. .lil-gui .controller.number input {
  7605. color: var(--number-color);
  7606. }
  7607. .lil-gui .controller.number.hasSlider input {
  7608. margin-left: var(--spacing);
  7609. width: var(--slider-input-width);
  7610. min-width: var(--slider-input-min-width);
  7611. flex-shrink: 0;
  7612. }
  7613. .lil-gui .controller.number .slider {
  7614. width: 100%;
  7615. height: var(--widget-height);
  7616. background: var(--widget-color);
  7617. border-radius: var(--widget-border-radius);
  7618. padding-right: var(--slider-knob-width);
  7619. overflow: hidden;
  7620. cursor: ew-resize;
  7621. touch-action: pan-y;
  7622. }
  7623. @media (hover: hover) {
  7624. .lil-gui .controller.number .slider:hover {
  7625. background: var(--hover-color);
  7626. }
  7627. }
  7628. .lil-gui .controller.number .slider.active {
  7629. background: var(--focus-color);
  7630. }
  7631. .lil-gui .controller.number .slider.active .fill {
  7632. opacity: 0.95;
  7633. }
  7634. .lil-gui .controller.number .fill {
  7635. height: 100%;
  7636. border-right: var(--slider-knob-width) solid var(--number-color);
  7637. box-sizing: content-box;
  7638. }
  7639. .lil-gui-dragging .lil-gui {
  7640. --hover-color: var(--widget-color);
  7641. }
  7642. .lil-gui-dragging * {
  7643. cursor: ew-resize !important;
  7644. }
  7645. .lil-gui-dragging.lil-gui-vertical * {
  7646. cursor: ns-resize !important;
  7647. }
  7648. .lil-gui .title {
  7649. height: var(--title-height);
  7650. line-height: calc(var(--title-height) - 4px);
  7651. font-weight: 600;
  7652. padding: 0 var(--padding);
  7653. -webkit-tap-highlight-color: transparent;
  7654. cursor: pointer;
  7655. outline: none;
  7656. text-decoration-skip: objects;
  7657. }
  7658. .lil-gui .title:before {
  7659. font-family: "lil-gui";
  7660. content: "▾";
  7661. padding-right: 2px;
  7662. display: inline-block;
  7663. }
  7664. .lil-gui .title:active {
  7665. background: var(--title-background-color);
  7666. opacity: 0.75;
  7667. }
  7668. @media (hover: hover) {
  7669. body:not(.lil-gui-dragging) .lil-gui .title:hover {
  7670. background: var(--title-background-color);
  7671. opacity: 0.85;
  7672. }
  7673. .lil-gui .title:focus {
  7674. text-decoration: underline var(--focus-color);
  7675. }
  7676. }
  7677. .lil-gui.root > .title:focus {
  7678. text-decoration: none !important;
  7679. }
  7680. .lil-gui.closed > .title:before {
  7681. content: "▸";
  7682. }
  7683. .lil-gui.closed > .children {
  7684. transform: translateY(-7px);
  7685. opacity: 0;
  7686. }
  7687. .lil-gui.closed:not(.transition) > .children {
  7688. display: none;
  7689. }
  7690. .lil-gui.transition > .children {
  7691. transition-duration: 300ms;
  7692. transition-property: height, opacity, transform;
  7693. transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
  7694. overflow: hidden;
  7695. pointer-events: none;
  7696. }
  7697. .lil-gui .children:empty:before {
  7698. content: "Empty";
  7699. padding: 0 var(--padding);
  7700. margin: var(--spacing) 0;
  7701. display: block;
  7702. height: var(--widget-height);
  7703. font-style: italic;
  7704. line-height: var(--widget-height);
  7705. opacity: 0.5;
  7706. }
  7707. .lil-gui.root > .children > .lil-gui > .title {
  7708. border: 0 solid var(--widget-color);
  7709. border-width: 1px 0;
  7710. transition: border-color 300ms;
  7711. }
  7712. .lil-gui.root > .children > .lil-gui.closed > .title {
  7713. border-bottom-color: transparent;
  7714. }
  7715. .lil-gui + .controller {
  7716. border-top: 1px solid var(--widget-color);
  7717. margin-top: 0;
  7718. padding-top: var(--spacing);
  7719. }
  7720. .lil-gui .lil-gui .lil-gui > .title {
  7721. border: none;
  7722. }
  7723. .lil-gui .lil-gui .lil-gui > .children {
  7724. border: none;
  7725. margin-left: var(--folder-indent);
  7726. border-left: 2px solid var(--widget-color);
  7727. }
  7728. .lil-gui .lil-gui .controller {
  7729. border: none;
  7730. }
  7731. .lil-gui label, .lil-gui input, .lil-gui button {
  7732. -webkit-tap-highlight-color: transparent;
  7733. }
  7734. .lil-gui input {
  7735. border: 0;
  7736. outline: none;
  7737. font-family: var(--font-family);
  7738. font-size: var(--input-font-size);
  7739. border-radius: var(--widget-border-radius);
  7740. height: var(--widget-height);
  7741. background: var(--widget-color);
  7742. color: var(--text-color);
  7743. width: 100%;
  7744. }
  7745. @media (hover: hover) {
  7746. .lil-gui input:hover {
  7747. background: var(--hover-color);
  7748. }
  7749. .lil-gui input:active {
  7750. background: var(--focus-color);
  7751. }
  7752. }
  7753. .lil-gui input:disabled {
  7754. opacity: 1;
  7755. }
  7756. .lil-gui input[type=text],
  7757. .lil-gui input[type=number] {
  7758. padding: var(--widget-padding);
  7759. -moz-appearance: textfield;
  7760. }
  7761. .lil-gui input[type=text]:focus,
  7762. .lil-gui input[type=number]:focus {
  7763. background: var(--focus-color);
  7764. }
  7765. .lil-gui input[type=checkbox] {
  7766. appearance: none;
  7767. width: var(--checkbox-size);
  7768. height: var(--checkbox-size);
  7769. border-radius: var(--widget-border-radius);
  7770. text-align: center;
  7771. cursor: pointer;
  7772. }
  7773. .lil-gui input[type=checkbox]:checked:before {
  7774. font-family: "lil-gui";
  7775. content: "✓";
  7776. font-size: var(--checkbox-size);
  7777. line-height: var(--checkbox-size);
  7778. }
  7779. @media (hover: hover) {
  7780. .lil-gui input[type=checkbox]:focus {
  7781. box-shadow: inset 0 0 0 1px var(--focus-color);
  7782. }
  7783. }
  7784. .lil-gui button {
  7785. outline: none;
  7786. cursor: pointer;
  7787. font-family: var(--font-family);
  7788. font-size: var(--font-size);
  7789. color: var(--text-color);
  7790. width: 100%;
  7791. height: var(--widget-height);
  7792. text-transform: none;
  7793. background: var(--widget-color);
  7794. border-radius: var(--widget-border-radius);
  7795. border: none;
  7796. }
  7797. @media (hover: hover) {
  7798. .lil-gui button:hover {
  7799. background: var(--hover-color);
  7800. }
  7801. .lil-gui button:focus {
  7802. box-shadow: inset 0 0 0 1px var(--focus-color);
  7803. }
  7804. }
  7805. .lil-gui button:active {
  7806. background: var(--focus-color);
  7807. }
  7808. @font-face {
  7809. font-family: "lil-gui";
  7810. src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff");
  7811. }`;function OMe(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 F6=!1;class lS{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"),!F6&&l&&(OMe(RMe),F6=!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 PMe(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new jMe(this,e,n,r,i,s);case"boolean":return new NMe(this,e,n);case"string":return new DMe(this,e,n);case"function":return new yA(this,e,n)}console.error(`gui.add failed
  7812. property:`,n,`
  7813. object:`,e,`
  7814. value:`,o)}addColor(e,n,r=1){return new CMe(this,e,n,r)}addFolder(e){const n=new lS({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof yA||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 yA)){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 vA(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(h){h(d)}))).then(o,l)}c((r=r.apply(t,[])).next())}))}class hO{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 hO(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 fO{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class I6 extends fO{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Od extends fO{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class U6{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class cS{constructor(e){this.lines=[],this.preamble=new U6(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
  7815. `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((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 I6(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 fO(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 I6){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 U6(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=hO.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}}}cS.prototype.parseGcode=cS.prototype.parseGCode;const z6={type:"change"},wA={type:"start"},B6={type:"end"},P_=new oO,H6=new Bd,LMe=Math.cos(70*VK.DEG2RAD);class FMe extends Am{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new We,this.cursor=new We,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Pp.ROTATE,MIDDLE:Pp.DOLLY,RIGHT:Pp.PAN},this.touches={ONE:Dp.ROTATE,TWO:Dp.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(Q){Q.addEventListener("keydown",Fe),this._domElementKeyEvents=Q},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Fe),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(z6),r.update(),s=i.NONE},this.update=(function(){const Q=new We,de=new mm().setFromUnitVectors(e.up,new We(0,1,0)),q=de.clone().invert(),ee=new We,B=new mm,he=new We,ke=2*Math.PI;return function(pe=null){const H=r.object.position;Q.copy(H).sub(r.target),Q.applyQuaternion(de),l.setFromVector3(Q),r.autoRotate&&s===i.NONE&&D((function(Se){return Se!==null?2*Math.PI/60*r.autoRotateSpeed*Se:2*Math.PI/60/60*r.autoRotateSpeed})(pe)),r.enableDamping?(l.theta+=c.theta*r.dampingFactor,l.phi+=c.phi*r.dampingFactor):(l.theta+=c.theta,l.phi+=c.phi);let O=r.minAzimuthAngle,J=r.maxAzimuthAngle;isFinite(O)&&isFinite(J)&&(O<-Math.PI?O+=ke:O>Math.PI&&(O-=ke),J<-Math.PI?J+=ke:J>Math.PI&&(J-=ke),l.theta=O<=J?Math.max(O,Math.min(J,l.theta)):l.theta>(O+J)/2?Math.max(O,l.theta):Math.min(J,l.theta)),l.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,l.phi)),l.makeSafe(),r.enableDamping===!0?r.target.addScaledVector(d,r.dampingFactor):r.target.add(d),r.target.sub(r.cursor),r.target.clampLength(r.minTargetRadius,r.maxTargetRadius),r.target.add(r.cursor),r.zoomToCursor&&C||r.object.isOrthographicCamera?l.radius=X(l.radius):l.radius=X(l.radius*u),Q.setFromSpherical(l),Q.applyQuaternion(q),H.copy(r.target).add(Q),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 le=!1;if(r.zoomToCursor&&C){let Se=null;if(r.object.isPerspectiveCamera){const we=Q.length();Se=X(we*u);const ae=we-Se;r.object.position.addScaledVector(T,ae),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const we=new We(k.x,k.y,0);we.unproject(r.object),r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),le=!0;const ae=new We(k.x,k.y,0);ae.unproject(r.object),r.object.position.sub(ae).add(we),r.object.updateMatrixWorld(),Se=Q.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):(P_.origin.copy(r.object.position),P_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(P_.direction))<LMe?e.lookAt(r.target):(H6.setFromNormalAndCoplanarPoint(r.object.up,r.target),P_.intersectPlane(H6,r.target))))}else r.object.isOrthographicCamera&&(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/u)),r.object.updateProjectionMatrix(),le=!0);return u=1,C=!1,!!(le||ee.distanceToSquared(r.object.position)>o||8*(1-B.dot(r.object.quaternion))>o||he.distanceToSquared(r.target)>0)&&(r.dispatchEvent(z6),ee.copy(r.object.position),B.copy(r.object.quaternion),he.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",xe),r.domElement.removeEventListener("pointerdown",ue),r.domElement.removeEventListener("pointercancel",ie),r.domElement.removeEventListener("wheel",Ce),r.domElement.removeEventListener("pointermove",Te),r.domElement.removeEventListener("pointerup",ie),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Fe),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 O6,c=new O6;let u=1;const d=new We,h=new bn,p=new bn,m=new bn,x=new bn,y=new bn,v=new bn,b=new bn,S=new bn,N=new bn,T=new We,k=new bn;let C=!1;const E=[],P={};function A(){return Math.pow(.95,r.zoomSpeed)}function D(Q){c.theta-=Q}function I(Q){c.phi-=Q}const L=(function(){const Q=new We;return function(de,q){Q.setFromMatrixColumn(q,0),Q.multiplyScalar(-de),d.add(Q)}})(),U=(function(){const Q=new We;return function(de,q){r.screenSpacePanning===!0?Q.setFromMatrixColumn(q,1):(Q.setFromMatrixColumn(q,0),Q.crossVectors(r.object.up,Q)),Q.multiplyScalar(de),d.add(Q)}})(),j=(function(){const Q=new We;return function(de,q){const ee=r.domElement;if(r.object.isPerspectiveCamera){const B=r.object.position;Q.copy(B).sub(r.target);let he=Q.length();he*=Math.tan(r.object.fov/2*Math.PI/180),L(2*de*he/ee.clientHeight,r.object.matrix),U(2*q*he/ee.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(L(de*(r.object.right-r.object.left)/r.object.zoom/ee.clientWidth,r.object.matrix),U(q*(r.object.top-r.object.bottom)/r.object.zoom/ee.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function V(Q){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=Q:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function K(Q){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=Q:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function z(Q){if(!r.zoomToCursor)return;C=!0;const de=r.domElement.getBoundingClientRect(),q=Q.clientX-de.left,ee=Q.clientY-de.top,B=de.width,he=de.height;k.x=q/B*2-1,k.y=-ee/he*2+1,T.set(k.x,k.y,1).unproject(r.object).sub(r.object.position).normalize()}function X(Q){return Math.max(r.minDistance,Math.min(r.maxDistance,Q))}function Y(Q){h.set(Q.clientX,Q.clientY)}function te(Q){x.set(Q.clientX,Q.clientY)}function $(){if(E.length===1)h.set(E[0].pageX,E[0].pageY);else{const Q=.5*(E[0].pageX+E[1].pageX),de=.5*(E[0].pageY+E[1].pageY);h.set(Q,de)}}function W(){if(E.length===1)x.set(E[0].pageX,E[0].pageY);else{const Q=.5*(E[0].pageX+E[1].pageX),de=.5*(E[0].pageY+E[1].pageY);x.set(Q,de)}}function ne(){const Q=E[0].pageX-E[1].pageX,de=E[0].pageY-E[1].pageY,q=Math.sqrt(Q*Q+de*de);b.set(0,q)}function re(Q){if(E.length==1)p.set(Q.pageX,Q.pageY);else{const q=G(Q),ee=.5*(Q.pageX+q.x),B=.5*(Q.pageY+q.y);p.set(ee,B)}m.subVectors(p,h).multiplyScalar(r.rotateSpeed);const de=r.domElement;D(2*Math.PI*m.x/de.clientHeight),I(2*Math.PI*m.y/de.clientHeight),h.copy(p)}function ge(Q){if(E.length===1)y.set(Q.pageX,Q.pageY);else{const de=G(Q),q=.5*(Q.pageX+de.x),ee=.5*(Q.pageY+de.y);y.set(q,ee)}v.subVectors(y,x).multiplyScalar(r.panSpeed),j(v.x,v.y),x.copy(y)}function me(Q){const de=G(Q),q=Q.pageX-de.x,ee=Q.pageY-de.y,B=Math.sqrt(q*q+ee*ee);S.set(0,B),N.set(0,Math.pow(S.y/b.y,r.zoomSpeed)),V(N.y),b.copy(S)}function ue(Q){r.enabled!==!1&&(E.length===0&&(r.domElement.setPointerCapture(Q.pointerId),r.domElement.addEventListener("pointermove",Te),r.domElement.addEventListener("pointerup",ie)),(function(de){E.push(de)})(Q),Q.pointerType==="touch"?(function(de){switch(Ze(de),E.length){case 1:switch(r.touches.ONE){case Dp.ROTATE:if(r.enableRotate===!1)return;$(),s=i.TOUCH_ROTATE;break;case Dp.PAN:if(r.enablePan===!1)return;W(),s=i.TOUCH_PAN;break;default:s=i.NONE}break;case 2:switch(r.touches.TWO){case Dp.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&ne(),r.enablePan&&W(),s=i.TOUCH_DOLLY_PAN;break;case Dp.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&ne(),r.enableRotate&&$(),s=i.TOUCH_DOLLY_ROTATE;break;default:s=i.NONE}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(wA)})(Q):(function(de){let q;switch(de.button){case 0:q=r.mouseButtons.LEFT;break;case 1:q=r.mouseButtons.MIDDLE;break;case 2:q=r.mouseButtons.RIGHT;break;default:q=-1}switch(q){case Pp.DOLLY:if(r.enableZoom===!1)return;(function(ee){z(ee),b.set(ee.clientX,ee.clientY)})(de),s=i.DOLLY;break;case Pp.ROTATE:if(de.ctrlKey||de.metaKey||de.shiftKey){if(r.enablePan===!1)return;te(de),s=i.PAN}else{if(r.enableRotate===!1)return;Y(de),s=i.ROTATE}break;case Pp.PAN:if(de.ctrlKey||de.metaKey||de.shiftKey){if(r.enableRotate===!1)return;Y(de),s=i.ROTATE}else{if(r.enablePan===!1)return;te(de),s=i.PAN}break;default:s=i.NONE}s!==i.NONE&&r.dispatchEvent(wA)})(Q))}function Te(Q){r.enabled!==!1&&(Q.pointerType==="touch"?(function(de){switch(Ze(de),s){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;re(de),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;ge(de),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(q){r.enableZoom&&me(q),r.enablePan&&ge(q)})(de),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(q){r.enableZoom&&me(q),r.enableRotate&&re(q)})(de),r.update();break;default:s=i.NONE}})(Q):(function(de){switch(s){case i.ROTATE:if(r.enableRotate===!1)return;(function(q){p.set(q.clientX,q.clientY),m.subVectors(p,h).multiplyScalar(r.rotateSpeed);const ee=r.domElement;D(2*Math.PI*m.x/ee.clientHeight),I(2*Math.PI*m.y/ee.clientHeight),h.copy(p),r.update()})(de);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(q){S.set(q.clientX,q.clientY),N.subVectors(S,b),N.y>0?V(A()):N.y<0&&K(A()),b.copy(S),r.update()})(de);break;case i.PAN:if(r.enablePan===!1)return;(function(q){y.set(q.clientX,q.clientY),v.subVectors(y,x).multiplyScalar(r.panSpeed),j(v.x,v.y),x.copy(y),r.update()})(de)}})(Q))}function ie(Q){(function(de){delete P[de.pointerId];for(let q=0;q<E.length;q++)if(E[q].pointerId==de.pointerId)return void E.splice(q,1)})(Q),E.length===0&&(r.domElement.releasePointerCapture(Q.pointerId),r.domElement.removeEventListener("pointermove",Te),r.domElement.removeEventListener("pointerup",ie)),r.dispatchEvent(B6),s=i.NONE}function Ce(Q){r.enabled!==!1&&r.enableZoom!==!1&&s===i.NONE&&(Q.preventDefault(),r.dispatchEvent(wA),(function(de){z(de),de.deltaY<0?K(A()):de.deltaY>0&&V(A()),r.update()})(Q),r.dispatchEvent(B6))}function Fe(Q){r.enabled!==!1&&r.enablePan!==!1&&(function(de){let q=!1;switch(de.code){case r.keys.UP:de.ctrlKey||de.metaKey||de.shiftKey?I(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,r.keyPanSpeed),q=!0;break;case r.keys.BOTTOM:de.ctrlKey||de.metaKey||de.shiftKey?I(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(0,-r.keyPanSpeed),q=!0;break;case r.keys.LEFT:de.ctrlKey||de.metaKey||de.shiftKey?D(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(r.keyPanSpeed,0),q=!0;break;case r.keys.RIGHT:de.ctrlKey||de.metaKey||de.shiftKey?D(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):j(-r.keyPanSpeed,0),q=!0}q&&(de.preventDefault(),r.update())})(Q)}function xe(Q){r.enabled!==!1&&Q.preventDefault()}function Ze(Q){let de=P[Q.pointerId];de===void 0&&(de=new bn,P[Q.pointerId]=de),de.set(Q.pageX,Q.pageY)}function G(Q){const de=Q.pointerId===E[0].pointerId?E[1]:E[0];return P[de.pointerId]}r.domElement.addEventListener("contextmenu",xe),r.domElement.addEventListener("pointerdown",ue),r.domElement.addEventListener("pointercancel",ie),r.domElement.addEventListener("wheel",Ce,{passive:!1}),this.update()}}Ot.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new bn(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},Is.line={uniforms:lO.merge([Ot.common,Ot.fog,Ot.line]),vertexShader:`
  7816. #include <common>
  7817. #include <color_pars_vertex>
  7818. #include <fog_pars_vertex>
  7819. #include <logdepthbuf_pars_vertex>
  7820. #include <clipping_planes_pars_vertex>
  7821. uniform float linewidth;
  7822. uniform vec2 resolution;
  7823. attribute vec3 instanceStart;
  7824. attribute vec3 instanceEnd;
  7825. attribute vec3 instanceColorStart;
  7826. attribute vec3 instanceColorEnd;
  7827. #ifdef WORLD_UNITS
  7828. varying vec4 worldPos;
  7829. varying vec3 worldStart;
  7830. varying vec3 worldEnd;
  7831. #ifdef USE_DASH
  7832. varying vec2 vUv;
  7833. #endif
  7834. #else
  7835. varying vec2 vUv;
  7836. #endif
  7837. #ifdef USE_DASH
  7838. uniform float dashScale;
  7839. attribute float instanceDistanceStart;
  7840. attribute float instanceDistanceEnd;
  7841. varying float vLineDistance;
  7842. #endif
  7843. void trimSegment( const in vec4 start, inout vec4 end ) {
  7844. // trim end segment so it terminates between the camera plane and the near plane
  7845. // conservative estimate of the near plane
  7846. float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
  7847. float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
  7848. float nearEstimate = - 0.5 * b / a;
  7849. float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
  7850. end.xyz = mix( start.xyz, end.xyz, alpha );
  7851. }
  7852. void main() {
  7853. #ifdef USE_COLOR
  7854. vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
  7855. #endif
  7856. #ifdef USE_DASH
  7857. vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
  7858. vUv = uv;
  7859. #endif
  7860. float aspect = resolution.x / resolution.y;
  7861. // camera space
  7862. vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
  7863. vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
  7864. #ifdef WORLD_UNITS
  7865. worldStart = start.xyz;
  7866. worldEnd = end.xyz;
  7867. #else
  7868. vUv = uv;
  7869. #endif
  7870. // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
  7871. // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
  7872. // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
  7873. // perhaps there is a more elegant solution -- WestLangley
  7874. bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
  7875. if ( perspective ) {
  7876. if ( start.z < 0.0 && end.z >= 0.0 ) {
  7877. trimSegment( start, end );
  7878. } else if ( end.z < 0.0 && start.z >= 0.0 ) {
  7879. trimSegment( end, start );
  7880. }
  7881. }
  7882. // clip space
  7883. vec4 clipStart = projectionMatrix * start;
  7884. vec4 clipEnd = projectionMatrix * end;
  7885. // ndc space
  7886. vec3 ndcStart = clipStart.xyz / clipStart.w;
  7887. vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
  7888. // direction
  7889. vec2 dir = ndcEnd.xy - ndcStart.xy;
  7890. // account for clip-space aspect ratio
  7891. dir.x *= aspect;
  7892. dir = normalize( dir );
  7893. #ifdef WORLD_UNITS
  7894. // get the offset direction as perpendicular to the view vector
  7895. vec3 worldDir = normalize( end.xyz - start.xyz );
  7896. vec3 offset;
  7897. if ( position.y < 0.5 ) {
  7898. offset = normalize( cross( start.xyz, worldDir ) );
  7899. } else {
  7900. offset = normalize( cross( end.xyz, worldDir ) );
  7901. }
  7902. // sign flip
  7903. if ( position.x < 0.0 ) offset *= - 1.0;
  7904. float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
  7905. // don't extend the line if we're rendering dashes because we
  7906. // won't be rendering the endcaps
  7907. #ifndef USE_DASH
  7908. // extend the line bounds to encompass endcaps
  7909. start.xyz += - worldDir * linewidth * 0.5;
  7910. end.xyz += worldDir * linewidth * 0.5;
  7911. // shift the position of the quad so it hugs the forward edge of the line
  7912. offset.xy -= dir * forwardOffset;
  7913. offset.z += 0.5;
  7914. #endif
  7915. // endcaps
  7916. if ( position.y > 1.0 || position.y < 0.0 ) {
  7917. offset.xy += dir * 2.0 * forwardOffset;
  7918. }
  7919. // adjust for linewidth
  7920. offset *= linewidth * 0.5;
  7921. // set the world position
  7922. worldPos = ( position.y < 0.5 ) ? start : end;
  7923. worldPos.xyz += offset;
  7924. // project the worldpos
  7925. vec4 clip = projectionMatrix * worldPos;
  7926. // shift the depth of the projected points so the line
  7927. // segments overlap neatly
  7928. vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
  7929. clip.z = clipPose.z * clip.w;
  7930. #else
  7931. vec2 offset = vec2( dir.y, - dir.x );
  7932. // undo aspect ratio adjustment
  7933. dir.x /= aspect;
  7934. offset.x /= aspect;
  7935. // sign flip
  7936. if ( position.x < 0.0 ) offset *= - 1.0;
  7937. // endcaps
  7938. if ( position.y < 0.0 ) {
  7939. offset += - dir;
  7940. } else if ( position.y > 1.0 ) {
  7941. offset += dir;
  7942. }
  7943. // adjust for linewidth
  7944. offset *= linewidth;
  7945. // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
  7946. offset /= resolution.y;
  7947. // select end
  7948. vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
  7949. // back to clip space
  7950. offset *= clip.w;
  7951. clip.xy += offset;
  7952. #endif
  7953. gl_Position = clip;
  7954. vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
  7955. #include <logdepthbuf_vertex>
  7956. #include <clipping_planes_vertex>
  7957. #include <fog_vertex>
  7958. }
  7959. `,fragmentShader:`
  7960. uniform vec3 diffuse;
  7961. uniform float opacity;
  7962. uniform float linewidth;
  7963. #ifdef USE_DASH
  7964. uniform float dashOffset;
  7965. uniform float dashSize;
  7966. uniform float gapSize;
  7967. #endif
  7968. varying float vLineDistance;
  7969. #ifdef WORLD_UNITS
  7970. varying vec4 worldPos;
  7971. varying vec3 worldStart;
  7972. varying vec3 worldEnd;
  7973. #ifdef USE_DASH
  7974. varying vec2 vUv;
  7975. #endif
  7976. #else
  7977. varying vec2 vUv;
  7978. #endif
  7979. #include <common>
  7980. #include <color_pars_fragment>
  7981. #include <fog_pars_fragment>
  7982. #include <logdepthbuf_pars_fragment>
  7983. #include <clipping_planes_pars_fragment>
  7984. vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
  7985. float mua;
  7986. float mub;
  7987. vec3 p13 = p1 - p3;
  7988. vec3 p43 = p4 - p3;
  7989. vec3 p21 = p2 - p1;
  7990. float d1343 = dot( p13, p43 );
  7991. float d4321 = dot( p43, p21 );
  7992. float d1321 = dot( p13, p21 );
  7993. float d4343 = dot( p43, p43 );
  7994. float d2121 = dot( p21, p21 );
  7995. float denom = d2121 * d4343 - d4321 * d4321;
  7996. float numer = d1343 * d4321 - d1321 * d4343;
  7997. mua = numer / denom;
  7998. mua = clamp( mua, 0.0, 1.0 );
  7999. mub = ( d1343 + d4321 * ( mua ) ) / d4343;
  8000. mub = clamp( mub, 0.0, 1.0 );
  8001. return vec2( mua, mub );
  8002. }
  8003. void main() {
  8004. #include <clipping_planes_fragment>
  8005. #ifdef USE_DASH
  8006. if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
  8007. if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
  8008. #endif
  8009. float alpha = opacity;
  8010. #ifdef WORLD_UNITS
  8011. // Find the closest points on the view ray and the line segment
  8012. vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
  8013. vec3 lineDir = worldEnd - worldStart;
  8014. vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
  8015. vec3 p1 = worldStart + lineDir * params.x;
  8016. vec3 p2 = rayEnd * params.y;
  8017. vec3 delta = p1 - p2;
  8018. float len = length( delta );
  8019. float norm = len / linewidth;
  8020. #ifndef USE_DASH
  8021. #ifdef USE_ALPHA_TO_COVERAGE
  8022. float dnorm = fwidth( norm );
  8023. alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
  8024. #else
  8025. if ( norm > 0.5 ) {
  8026. discard;
  8027. }
  8028. #endif
  8029. #endif
  8030. #else
  8031. #ifdef USE_ALPHA_TO_COVERAGE
  8032. // artifacts appear on some hardware if a derivative is taken within a conditional
  8033. float a = vUv.x;
  8034. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8035. float len2 = a * a + b * b;
  8036. float dlen = fwidth( len2 );
  8037. if ( abs( vUv.y ) > 1.0 ) {
  8038. alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
  8039. }
  8040. #else
  8041. if ( abs( vUv.y ) > 1.0 ) {
  8042. float a = vUv.x;
  8043. float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
  8044. float len2 = a * a + b * b;
  8045. if ( len2 > 1.0 ) discard;
  8046. }
  8047. #endif
  8048. #endif
  8049. vec4 diffuseColor = vec4( diffuse, alpha );
  8050. #include <logdepthbuf_fragment>
  8051. #include <color_fragment>
  8052. gl_FragColor = vec4( diffuseColor.rgb, alpha );
  8053. #include <tonemapping_fragment>
  8054. #include <colorspace_fragment>
  8055. #include <fog_fragment>
  8056. #include <premultiplied_alpha_fragment>
  8057. }
  8058. `};class dX extends kh{constructor(e){super({type:"LineMaterial",uniforms:lO.clone(Is.line.uniforms),vertexShader:Is.line.vertexShader,fragmentShader:Is.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 $6=new sl,D_=new We;class hX extends wMe{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 Ai([-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 Ai([-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 _3(n,6,1);return this.setAttribute("instanceStart",new eh(r,3,0)),this.setAttribute("instanceEnd",new eh(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 _3(n,6,1);return this.setAttribute("instanceColorStart",new eh(r,3,0)),this.setAttribute("instanceColorEnd",new eh(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 mMe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new sl);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),$6.setFromBufferAttribute(n),this.boundingBox.union($6))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new mc),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++)D_.fromBufferAttribute(e,s),i=Math.max(i,r.distanceToSquared(D_)),D_.fromBufferAttribute(n,s),i=Math.max(i,r.distanceToSquared(D_));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 V6=new We,G6=new We,ja=new Cr,Pa=new Cr,Zl=new Cr,_A=new We,SA=new zr,Da=new _Me,q6=new We,R_=new sl,O_=new mc,Jl=new Cr;let ec,Cf;function W6(t,e,n){return Jl.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),Jl.multiplyScalar(1/Jl.w),Jl.x=Cf/n.width,Jl.y=Cf/n.height,Jl.applyMatrix4(t.projectionMatrixInverse),Jl.multiplyScalar(1/Jl.w),Math.abs(Math.max(Jl.x,Jl.y))}class IMe extends Ll{constructor(e=new hX,n=new dX({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)V6.fromBufferAttribute(n,o),G6.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+V6.distanceTo(G6);const s=new _3(i,2,1);return e.setAttribute("instanceDistanceStart",new eh(s,1,0)),e.setAttribute("instanceDistanceEnd",new eh(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;ec=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;Cf=c.linewidth+s,l.boundingSphere===null&&l.computeBoundingSphere(),O_.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*Cf:u=W6(i,Math.max(i.near,O_.distanceToPoint(ec.origin)),c.resolution),O_.radius+=u,ec.intersectsSphere(O_)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),R_.copy(l.boundingBox).applyMatrix4(o),r?d=.5*Cf:d=W6(i,Math.max(i.near,R_.distanceToPoint(ec.origin)),c.resolution),R_.expandByScalar(d),ec.intersectsBox(R_)!==!1&&(r?(function(h,p){const m=h.matrixWorld,x=h.geometry,y=x.attributes.instanceStart,v=x.attributes.instanceEnd;for(let b=0,S=Math.min(x.instanceCount,y.count);b<S;b++){Da.start.fromBufferAttribute(y,b),Da.end.fromBufferAttribute(v,b),Da.applyMatrix4(m);const N=new We,T=new We;ec.distanceSqToSegment(Da.start,Da.end,T,N),T.distanceTo(N)<.5*Cf&&p.push({point:T,pointOnLine:N,distance:ec.origin.distanceTo(T),object:h,face:null,faceIndex:b,uv:null,uv1:null})}})(this,n):(function(h,p,m){const x=p.projectionMatrix,y=h.material.resolution,v=h.matrixWorld,b=h.geometry,S=b.attributes.instanceStart,N=b.attributes.instanceEnd,T=Math.min(b.instanceCount,S.count),k=-p.near;ec.at(1,Zl),Zl.w=1,Zl.applyMatrix4(p.matrixWorldInverse),Zl.applyMatrix4(x),Zl.multiplyScalar(1/Zl.w),Zl.x*=y.x/2,Zl.y*=y.y/2,Zl.z=0,_A.copy(Zl),SA.multiplyMatrices(p.matrixWorldInverse,v);for(let C=0,E=T;C<E;C++){if(ja.fromBufferAttribute(S,C),Pa.fromBufferAttribute(N,C),ja.w=1,Pa.w=1,ja.applyMatrix4(SA),Pa.applyMatrix4(SA),ja.z>k&&Pa.z>k)continue;if(ja.z>k){const L=ja.z-Pa.z,U=(ja.z-k)/L;ja.lerp(Pa,U)}else if(Pa.z>k){const L=Pa.z-ja.z,U=(Pa.z-k)/L;Pa.lerp(ja,U)}ja.applyMatrix4(x),Pa.applyMatrix4(x),ja.multiplyScalar(1/ja.w),Pa.multiplyScalar(1/Pa.w),ja.x*=y.x/2,ja.y*=y.y/2,Pa.x*=y.x/2,Pa.y*=y.y/2,Da.start.copy(ja),Da.start.z=0,Da.end.copy(Pa),Da.end.z=0;const P=Da.closestPointToPointParameter(_A,!0);Da.at(P,q6);const A=VK.lerp(ja.z,Pa.z,P),D=A>=-1&&A<=1,I=_A.distanceTo(q6)<.5*Cf;if(D&&I){Da.start.fromBufferAttribute(S,C),Da.end.fromBufferAttribute(N,C),Da.start.applyMatrix4(v),Da.end.applyMatrix4(v);const L=new We,U=new We;ec.distanceSqToSegment(Da.start,Da.end,U,L),m.push({point:U,pointOnLine:L,distance:ec.origin.distanceTo(U),object:h,face:null,faceIndex:C,uv:null,uv1:null})}}})(this,i,n)))}}class UMe extends CM{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 p=-1*(e=l*n/2);p<=e;p+=n){c.push(p,0,-1*r,p,0,r);const m=p===0?s:o;m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3}for(let p=-1*r;p<=r;p+=i){c.push(-1*e,0,p,e,0,p);const m=p===0?s:o;m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3,m.toArray(u,d),d+=3}const h=new ns;h.setAttribute("position",new Ai(c,3)),h.setAttribute("color",new Ai(u,3)),super(h,new $y({vertexColors:!0,toneMapped:!1}))}}function zMe(t,e,n,r){const i=(function(o,l,c){o*=.5,l*=.5,c*=.5;const u=new ns,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 Ai(d,3)),u})(t,e,n),s=new CM(i,new gMe({color:new Jt(r),dashSize:3,gapSize:1}));return s.computeLineDistances(),s}var N0=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function r(d){for(var h=0;h<e.children.length;h++)e.children[h].style.display=h===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 N0.Panel("FPS","#0ff","#002")),c=n(new N0.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=n(new N0.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 h=performance.memory;u.update(h.usedJSHeapSize/1048576,h.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:r}};N0.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,h=3*o,p=15*o,m=74*o,x=30*o,y=document.createElement("canvas");y.width=l,y.height=c,y.style.cssText="width:80px;height:48px";var v=y.getContext("2d");return v.font="bold "+9*o+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=n,v.fillRect(0,0,l,c),v.fillStyle=e,v.fillText(t,u,d),v.fillRect(h,p,m,x),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(h,p,m,x),{dom:y,update:function(b,S){r=Math.min(r,b),i=Math.max(i,b),v.fillStyle=n,v.globalAlpha=1,v.fillRect(0,0,l,p),v.fillStyle=e,v.fillText(s(b)+" "+t+" ("+s(r)+"-"+s(i)+")",u,d),v.drawImage(y,h+o,p,m-o,x,h,p,m-o,x),v.fillRect(h+m-o,p,o,x),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(h+m-o,p,o,s((1-b/S)*x))}}};var BMe=N0;class K6{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new lS,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 lS,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 HMe extends ns{constructor(e=[new We],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 We,o=new We,l=new bn,c=[],u=[],d=[],h=[];function p(m){const[x,y,v]=(function(b){const S=e[b],N=new We,T=new We,k=new We,C=new We;N.copy(S).sub(e[b-1]||S).normalize().add((e[b+1]||S).clone().sub(S).normalize()).normalize();let E=Number.MAX_VALUE;const P=Math.abs(N.x),A=Math.abs(N.y),D=Math.abs(N.z);return P<=E&&(E=P,T.set(1,0,0)),A<=E&&(E=A,T.set(0,1,0)),D<=E&&T.set(0,0,1),C.crossVectors(N,T).normalize(),T.crossVectors(N,C),k.crossVectors(N,T),[S,T,k]})(m);for(let b=0;b<=i;b++){const S=b/i*Math.PI*2,N=Math.sin(S),T=-Math.cos(S);o.x=T*y.x+N*v.x,o.y=T*y.y+N*v.y,o.z=T*y.z+N*v.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 m=0;m<e.length;m++)p(m);p(closed===!1?e.length-1:0),(function(){for(let m=0;m<e.length;m++)for(let x=0;x<=i;x++)l.x=m/e.length,l.y=x/i,d.push(l.x,l.y)})(),(function(){for(let m=1;m<e.length;m++)for(let x=1;x<=i;x++){const y=(i+1)*(m-1)+(x-1),v=(i+1)*m+(x-1),b=(i+1)*m+x,S=(i+1)*(m-1)+x;h.push(y,v,S),h.push(v,b,S)}})()})(),this.setIndex(h),this.setAttribute("position",new Ai(c,3)),this.setAttribute("normal",new Ai(u,3)),this.setAttribute("uv",new Ai(d,2))}}class M0{static get initial(){const e=new M0;return Object.assign(e,{x:0,y:0,z:0,r:0,e:0,i:0,j:0,t:0}),e}}const NA={h:0,s:0,l:0};class Pg{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=M0.initial,this.beyondFirstMove=!1,this.disposables=[],this._extrusionColor=Pg.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 cS(this.minLayerThreshold),this.scene=new iMe,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 BMe: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[m,x]of Object.entries(e.toolColors))this._toolColors[parseInt(m)]=new Jt(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+MM),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 w3({canvas:this.canvas,preserveDrawingBuffer:!0});else{if(!this.targetId)throw Error("Set either opts.canvas or opts.targetId");const m=document.getElementById(this.targetId);if(!m)throw new Error("Unable to find element "+this.targetId);this.renderer=new w3({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,m.appendChild(this.canvas)}this.camera=new ho(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const h=this.camera.far,p=.8*h;this.scene.fog=new dO(this._backgroundColor,p,h),this.resize(),this.controls=new FMe(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?Pg.defaultExtrusionColor:this._extrusionColor instanceof Jt?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Pg.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 SMe(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 vMe(13421772,.3*Math.PI),n=new yMe(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 l0;return n.name=e,n.quaternion.setFromEuler(new By(-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=M0.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 vA(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],h={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const p of d.commands)if(p.gcode!="g20"){if(p.gcode.startsWith("t")){this.doRenderExtrusion(h,e),h.extrusion=[];const m=p;this.state.t=m.toolIndex}else if(["g0","g00","g1","g01","g2","g02","g3","g03"].indexOf(p.gcode)>-1){const m=p,x={x:(n=m.params.x)!==null&&n!==void 0?n:this.state.x,y:(r=m.params.y)!==null&&r!==void 0?r:this.state.y,z:(i=m.params.z)!==null&&i!==void 0?i:this.state.z,r:(s=m.params.r)!==null&&s!==void 0?s:this.state.r,e:(o=m.params.e)!==null&&o!==void 0?o:this.state.e,i:(l=m.params.i)!==null&&l!==void 0?l:this.state.i,j:(c=m.params.j)!==null&&c!==void 0?c:this.state.j,t:this.state.t};if(e>=this.minLayerIndex){const y=((u=m.params.e)!==null&&u!==void 0?u:0)>0||this.nonTravelmoves.indexOf(p.gcode)>-1;(x.x!=this.state.x||x.y!=this.state.y||x.z!=this.state.z)&&(y&&this.renderExtrusion||!y&&this.renderTravel)&&(p.gcode=="g2"||p.gcode=="g3"||p.gcode=="g02"||p.gcode=="g03"?this.addArcSegment(h,this.state,x,y,p.gcode=="g2"||p.gcode=="g02"):this.addLineSegment(h,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(h,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(NA),s=new Jt().setHSL(NA.h,NA.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 UMe(this.buildVolume.x,10,this.buildVolume.y,10));const e=zMe(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 cS(this.minLayerThreshold)}resetState(){var e;this.startLayer=1,this.endLayer=1/0,this.singleLayerMode=!1,this.beyondFirstMove=!1,this.state=M0.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,h=r.y,p=r.z;let m=r.r,x=r.i,y=r.j;if(m){const V=d-l,K=h-c,z=Math.sqrt(Math.pow(V/2,2)+Math.pow(K/2,2));m=Math.max(m,z);const X=Math.pow(V,2)+Math.pow(K,2),Y=Math.pow(m,2)-X/4;let te=Math.sqrt(Y/X);(s&&m<0||!s&&m>0)&&(te=-te),x=V/2+K*te,y=K/2-V*te}const v=l==d&&c==h,b=l+x,S=c+y,N=Math.sqrt(x*x+y*y),T=Math.atan2(-y,-x),k=Math.atan2(h-S,d-b);let C;v?C=2*Math.PI:(C=s?T-k:k-T,C<0&&(C+=2*Math.PI));let E=N*C/1.8;this.inches&&(E*=25),E<1&&(E=1);let P=C/E;P*=s?-1:1;const A=[];A.push({x:l,y:c,z:u});const D=(u-p)/E;let I=l,L=c,U=u,j=T;for(let V=0;V<E-1;V++)j+=P,I=b+N*Math.cos(j),L=S+N*Math.sin(j),U+=D,A.push({x:I,y:L,z:U});A.push({x:r.x,y:r.y,z:r.z});for(let V=0;V<A.length-1;V++)o.push(A[V].x,A[V].y,A[V].z,A[V+1].x,A[V+1].y,A[V+1].z)}addLine(e,n){var r;if(typeof this.lineWidth=="number"&&this.lineWidth>0)return void this.addThickLine(e,n);const i=new ns;i.setAttribute("position",new Ai(e,3)),this.disposables.push(i);const s=new $y({color:n});this.disposables.push(s);const o=new CM(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 We(l[0],l[1],l[2]),u=new We(l[3],l[4],l[5]),d=new We(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 HMe(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 hX;this.disposables.push(i);const s=new dX({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(s),i.setPositions(e);const o=new IMe(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=>vA(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 pMe({color:e,wireframe:this._wireframe});this.disposables.push(i);const s=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new hMe(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 vA(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(`
  8059. `),h=u.slice(0,d);this.parser.parseGCode(o+h),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 K6(this):typeof this.devMode=="object"&&(this.devGui=new K6(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())}}Pg.defaultExtrusionColor=new Jt("hotpink");function fX({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=_.useRef(null),s=_.useRef(null),o=_.useRef(null),l=_.useRef(!1),[c,u]=_.useState(!0),[d,h]=_.useState(null),[p,m]=_.useState(!1),[x,y]=_.useState(0),[v,b]=_.useState(0),S=_.useMemo(()=>JSON.stringify(n),[n]);_.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const k=i.current,C=k.parentElement?.getBoundingClientRect();C&&(k.width=C.width,k.height=C.height);const E=n&&n.length>1,P=n?.[0]||"#00ae42",A=new Pg({canvas:k,buildVolume:e,backgroundColor:1710618,extrusionColor:E?n:P,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});s.current=A,fetch(t).then(async I=>{if(!I.ok)throw I.status===404&&(await I.json().catch(()=>({}))).detail?.includes("sliced")?(m(!0),new Error("not_sliced")):new Error("Failed to load G-code");return I.text()}).then(I=>{const L=new Set,U=/^(\s*)T(\d+)(\s*;.*)?$/gim;let j;for(;(j=U.exec(I))!==null;){const te=parseInt(j[2],10);te<=15&&L.add(te)}const V=new Map,K=Array.from(L).sort((te,$)=>te-$);K.forEach((te,$)=>{V.set(te,$%8)});const z=[];K.forEach((te,$)=>{const W=n?.[te]||"#00ae42";z[$%8]=W});const X=I.split(`
  8060. `).map(te=>{const $=te.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if($){const W=parseInt($[2],10);if(W>15)return`; FILTERED: ${te.trim()}`;const ne=V.get(W)??0;return`${$[1]}T${ne}${$[3]||""}`}return te}).join(`
  8061. `);z.length>0&&(A.extrusionColor=z),A.processGCode(X);const Y=A.layers?.length||0;b(Y),y(Y),A.render(),u(!1)}).catch(I=>{I.message!=="not_sliced"&&h(I.message),u(!1)});const D=()=>{if(k.parentElement&&s.current){const I=k.parentElement.getBoundingClientRect();k.width=I.width,k.height=I.height,s.current.resize()}};return window.addEventListener("resize",D),()=>{window.removeEventListener("resize",D),o.current&&cancelAnimationFrame(o.current),s.current&&(s.current.dispose(),s.current=null),l.current=!1}},[t,S]);const N=_.useCallback(k=>{if(!s.current)return;const C=Math.max(1,Math.min(k,v));y(C),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{s.current&&(s.current.endLayer=C,s.current.render())})},[v]),T=k=>{N(parseInt(k.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(pt,{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..."})]})}),p&&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(zue,{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&&!p&&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&&!p&&v>0&&a.jsx("div",{className:"mt-4 px-2",children:a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(xs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("button",{onClick:()=>N(x-1),disabled:x<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:a.jsx(bh,{className:"w-4 h-4"})}),a.jsx("input",{type:"range",min:1,max:v,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:()=>N(x+1),disabled:x>=v,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:a.jsx(vs,{className:"w-4 h-4"})}),a.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[x," / ",v]})]})})]})}function $Me({printerId:t,filePath:e,filename:n,onClose:r}){const[i,s]=_.useState(null),[o,l]=_.useState([]),[c,u]=_.useState(!1),[d,h]=_.useState(null),p=n.toLowerCase().split(".").pop()||"",m=p==="3mf"||p==="stl",x=p==="gcode"||p==="3mf";_.useEffect(()=>{s(m?"3d":x?"gcode":null)},[m,x]),_.useEffect(()=>{l([]),h(null),m&&(u(!0),oe.getPrinterFilePlates(t,e).then(b=>l(b.plates||[])).catch(()=>l([])).finally(()=>u(!1)))},[e,m,t]);const y=o.length>1,v=d==null?null:o.find(b=>b.index===d)??null;return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-6",onClick:r,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:b=>b.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:n}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:r,children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>m&&s("3d"),disabled:!m,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${i==="3d"?"text-bambu-green border-b-2 border-bambu-green":m?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(Ui,{className:"w-4 h-4"}),"3D Model",!m&&a.jsx("span",{className:"text-xs",children:"(not available)"})]}),a.jsxs("button",{onClick:()=>x&&s("gcode"),disabled:!x,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${i==="gcode"?"text-bambu-green border-b-2 border-bambu-green":x?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(fs,{className:"w-4 h-4"}),"G-code Preview",!x&&a.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),a.jsx("div",{className:"flex-1 overflow-hidden p-4",children:i==="3d"&&m?a.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[y&&a.jsxs("div",{className:"rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray mb-2",children:[a.jsx(Ui,{className:"w-4 h-4"}),"Plates",c&&a.jsx(pt,{className:"w-3 h-3 animate-spin"})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>h(null),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${d==null?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx(Ui,{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:"All Plates"}),a.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[o.length," plate",o.length!==1?"s":""]})]}),d==null&&a.jsx(Gs,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]}),o.map(b=>a.jsxs("button",{type:"button",onClick:()=>h(b.index),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${d===b.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[b.has_thumbnail?a.jsx("img",{src:oe.getPrinterFilePlateThumbnail(t,b.index,e),alt:`Plate ${b.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(Ui,{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:b.name||`Plate ${b.index}`}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:b.objects.length>0?b.objects.slice(0,2).join(", ")+(b.objects.length>2?"…":""):`${b.filaments.length} filament${b.filaments.length!==1?"s":""}`})]}),d===b.index&&a.jsx(Gs,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},b.index))]}),v&&a.jsxs("div",{className:"mt-3 text-xs text-bambu-gray flex flex-wrap gap-x-4 gap-y-1",children:[a.jsxs("span",{children:["Plate ",v.index]}),v.print_time_seconds!=null&&a.jsxs("span",{children:["ETA ",Math.round(v.print_time_seconds/60)," min"]}),v.filament_used_grams!=null&&a.jsxs("span",{children:[v.filament_used_grams.toFixed(1)," g"]}),v.filaments.length>0&&a.jsxs("span",{children:[v.filaments.length," filament",v.filaments.length!==1?"s":""]})]})]}),a.jsx("div",{className:"flex-1",children:a.jsx(jK,{url:oe.getPrinterFileDownloadUrl(t,e),fileType:p,selectedPlateId:d,className:"w-full h-full"})})]}):i==="gcode"&&x?a.jsx(fX,{gcodeUrl:oe.getPrinterFileGcodeUrl(t,e),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"})})]})})}function VMe(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 X6(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 GMe(t,e){if(e)return kW;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return Hf;case"gcode":return fs;case"mp4":case"avi":return sh;case"png":case"jpg":case"jpeg":return Lu;default:return dM}}const qMe=[{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 WMe({printerId:t,printerName:e,onClose:n}){const{t:r}=On(),{showToast:i}=Hn(),s=sn(),[o,l]=_.useState("/"),[c,u]=_.useState(new Set),[d,h]=_.useState(""),[p,m]=_.useState([]),[x,y]=_.useState("name-asc"),[v,b]=_.useState(null),[S,N]=_.useState(null);_.useEffect(()=>{const z=X=>{X.key==="Escape"&&n()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[n]);const{data:T,isLoading:k,refetch:C}=ct({queryKey:["printerFiles",t,o],queryFn:()=>oe.getPrinterFiles(t,o)}),{data:E}=ct({queryKey:["printerStorage",t],queryFn:()=>oe.getPrinterStorage(t),staleTime:3e4}),P=gt({mutationFn:async z=>{for(const X of z)await oe.deletePrinterFile(t,X)},onSuccess:()=>{i(r("printerFiles.toast.filesDeleted",{count:p.length})),s.invalidateQueries({queryKey:["printerFiles",t]}),u(new Set),m([])},onError:z=>{i(r("printerFiles.toast.deleteFailed",{error:z.message}),"error")}}),A=z=>{l(z),u(new Set)},D=()=>{if(o==="/")return;const z=o.split("/").filter(Boolean);z.pop(),l(z.length?"/"+z.join("/"):"/"),u(new Set)},I=(z,X)=>{X.stopPropagation(),u(Y=>{const te=new Set(Y);return te.has(z)?te.delete(z):te.add(z),te})},L=()=>{if(!T?.files)return;const z=T.files.filter(X=>!X.is_directory&&(!d||X.name.toLowerCase().includes(d.toLowerCase()))).map(X=>X.path);u(new Set(z))},U=()=>{u(new Set)},j=async()=>{if(c.size===0)return;const z=Array.from(c);if(z.length===1){oe.downloadPrinterFile(t,z[0]).catch(X=>{console.error("Printer file download failed:",X)}),u(new Set);return}b({current:0,total:z.length});try{const X=await oe.downloadPrinterFilesAsZip(t,z),Y=URL.createObjectURL(X),te=document.createElement("a");te.href=Y,te.download=`${e.replace(/[^a-zA-Z0-9]/g,"_")}-files.zip`,document.body.appendChild(te),te.click(),document.body.removeChild(te),URL.revokeObjectURL(Y),i(`Downloaded ${z.length} files as ZIP`),u(new Set)}catch(X){i(`Download failed: ${X instanceof Error?X.message:"Unknown error"}`,"error")}finally{b(null)}},V=()=>{c.size!==0&&m(Array.from(c))},K=[{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:z=>z.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(mM,{className:"w-5 h-5 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("printerFiles.title")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),a.jsxs("div",{className:"flex items-center gap-4",children:[E&&(E.used_bytes!=null||E.free_bytes!=null)&&a.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[E.used_bytes!=null&&a.jsxs("span",{children:[r("printerFiles.storageUsed")," ",X6(E.used_bytes)]}),E.used_bytes!=null&&E.free_bytes!=null&&a.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),E.free_bytes!=null&&a.jsxs("span",{children:[r("printerFiles.storageFree")," ",X6(E.free_bytes)]})]}),a.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",title:"Close file manager","aria-label":"Close file manager",children:a.jsx(Lt,{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:[K.map(z=>a.jsx("button",{onClick:()=>{A(z.path),h("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${o===z.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:z.label},z.path)),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"relative",children:[a.jsx(wa,{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:r("printerFiles.filterPlaceholder"),value:d,onChange:z=>h(z.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(_W,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("select",{value:x,onChange:z=>y(z.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",title:"Sort files","aria-label":"Sort files",children:qMe.map(z=>a.jsx("option",{value:z.value,children:z.label},z.value))})]}),a.jsx(Ae,{variant:"secondary",size:"sm",onClick:()=>C(),disabled:k,children:a.jsx(Dr,{className:`w-4 h-4 ${k?"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:D,disabled:o==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",title:"Go to parent folder","aria-label":"Go to parent folder",children:a.jsx(bh,{className:"w-4 h-4"})}),a.jsx("span",{className:"text-bambu-gray font-mono",children:o})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:k?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):T?.files?.length?a.jsx("div",{className:"space-y-1",children:[...T.files].filter(z=>!d||z.name.toLowerCase().includes(d.toLowerCase())).sort((z,X)=>{if(z.is_directory&&!X.is_directory)return-1;if(!z.is_directory&&X.is_directory)return 1;switch(x){case"name-asc":return z.name.localeCompare(X.name);case"name-desc":return X.name.localeCompare(z.name);case"size-asc":return z.size-X.size;case"size-desc":return X.size-z.size;case"date-asc":{const Y=z.mtime?new Date(z.mtime).getTime():0,te=X.mtime?new Date(X.mtime).getTime():0;return Y-te}case"date-desc":{const Y=z.mtime?new Date(z.mtime).getTime():0;return(X.mtime?new Date(X.mtime).getTime():0)-Y}default:return z.name.localeCompare(X.name)}}).map(z=>{const X=GMe(z.name,z.is_directory),Y=c.has(z.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:()=>{z.is_directory&&A(z.path)},children:[z.is_directory?null:a.jsx("button",{onClick:te=>I(z.path,te),className:"flex-shrink-0 text-bambu-gray hover:text-white",children:Y?a.jsx(Gs,{className:"w-5 h-5 text-bambu-green"}):a.jsx(cl,{className:"w-5 h-5"})}),a.jsx(X,{className:`w-5 h-5 flex-shrink-0 ${z.is_directory?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("span",{className:"flex-1 text-white truncate",children:z.name}),!z.is_directory&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:VMe(z.size)}),(z.name.toLowerCase().endsWith(".3mf")||z.name.toLowerCase().endsWith(".gcode")||z.name.toLowerCase().endsWith(".stl"))&&a.jsx("button",{onClick:te=>{te.stopPropagation(),N({path:z.path,name:z.name})},className:"p-1 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green",title:"3D View",children:a.jsx(Ui,{className:"w-4 h-4"})})]}),z.is_directory&&a.jsx(bh,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},z.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:c.size>0?`${c.size} selected`:d?`${T?.files?.filter(z=>z.name.toLowerCase().includes(d.toLowerCase())).length||0} of ${T?.files?.length||0} items`:`${T?.files?.length||0} items`}),T?.files?.some(z=>!z.is_directory)&&a.jsx("div",{className:"flex items-center gap-2",children:c.size>0?a.jsxs("button",{onClick:U,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(qhe,{className:"w-4 h-4"}),"Deselect All"]}):a.jsxs("button",{onClick:L,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[a.jsx(Gs,{className:"w-4 h-4"}),"Select All"]})})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ae,{variant:"secondary",disabled:c.size===0||v!==null,onClick:j,children:v?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 animate-spin"}),v.current,"/",v.total]}):a.jsxs(a.Fragment,{children:[a.jsx(wi,{className:"w-4 h-4"}),"Download",c.size>1?` (${c.size})`:""]})}),a.jsxs(Ae,{variant:"secondary",disabled:c.size===0||P.isPending,onClick:V,className:"text-red-400 hover:text-red-300",children:[P.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(an,{className:"w-4 h-4"}),r("printerFiles.deleteButton"),c.size>1?` (${c.size})`:""]})]})]})]}),p.length>0&&a.jsx(Zn,{title:p.length>1?r("printerFiles.deleteFiles",{count:p.length}):r("fileManager.deleteFile"),message:p.length>1?r("printerFiles.deleteFilesConfirm",{count:p.length}):r("printerFiles.deleteFileConfirm",{name:p[0].split("/").pop()}),confirmText:r("common.delete"),variant:"danger",onConfirm:()=>{P.mutate(p)},onCancel:()=>m([])}),S&&a.jsx($Me,{printerId:t,filePath:S.path,filename:S.name,onClose:()=>N(null)})]})}const KMe="embeddedCameraState_",Y6=5,XMe=2e3,YMe=3e4,QMe=5e3,MA={x:window.innerWidth-420,y:20,width:400,height:300};function ZMe({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const i=`${KMe}${t}`,s=()=>{try{const Pe=localStorage.getItem(i);if(Pe){const Ie=JSON.parse(Pe);return{x:Math.min(Math.max(0,Ie.x),window.innerWidth-100),y:Math.min(Math.max(0,Ie.y),window.innerHeight-100),width:Math.max(200,Math.min(Ie.width,window.innerWidth-20)),height:Math.max(150,Math.min(Ie.height,window.innerHeight-20))}}}catch{}const be=n*30;return{...MA,x:Math.max(0,MA.x-be),y:Math.max(0,MA.y+be)}},[o,l]=_.useState(s),[c,u]=_.useState(!1),[d,h]=_.useState(!1),[p,m]=_.useState({x:0,y:0}),[x,y]=_.useState(!1),[v,b]=_.useState(!1),[S,N]=_.useState(1),[T,k]=_.useState({x:0,y:0}),[C,E]=_.useState(!1),[P,A]=_.useState({x:0,y:0}),[D,I]=_.useState(null),[L,U]=_.useState(null),[j,V]=_.useState(!1),[K,z]=_.useState(!0),[X,Y]=_.useState(Date.now()),[te,$]=_.useState(0),[W,ne]=_.useState(!1),[re,ge]=_.useState(0),me=_.useRef(null),ue=_.useRef(null),Te=_.useRef(null),ie=_.useRef(null),Ce=_.useRef(null),{data:Fe}=ct({queryKey:["printer",t],queryFn:()=>oe.getPrinter(t),enabled:t>0});_.useEffect(()=>{const be=setTimeout(()=>{localStorage.setItem(i,JSON.stringify(o))},500);return()=>clearTimeout(be)},[o,i]);const xe=_.useRef(!1);_.useEffect(()=>{xe.current=!1;const be=`/api/v1/printers/${t}/camera/stop`,Pe=()=>{t>0&&!xe.current&&(xe.current=!0,navigator.sendBeacon(be))},Ie=ue.current;return()=>{Ie&&(Ie.src=""),Pe(),Te.current&&clearTimeout(Te.current),ie.current&&clearInterval(ie.current),Ce.current&&clearInterval(Ce.current)}},[t]),_.useEffect(()=>{if(K){const be=setTimeout(()=>z(!1),3e3);return()=>clearTimeout(be)}},[K,X]);const Ze=_.useCallback(()=>{if(te>=Y6){ne(!1),V(!0);return}const be=Math.min(XMe*Math.pow(2,te),YMe);ne(!0),ge(Math.ceil(be/1e3)),ie.current=setInterval(()=>{ge(Pe=>Pe<=1?(ie.current&&clearInterval(ie.current),0):Pe-1)},1e3),Te.current=setTimeout(()=>{$(Pe=>Pe+1),ne(!1),z(!0),V(!1),ue.current&&(ue.current.src=""),Y(Date.now())},be)},[te]);_.useEffect(()=>{if(K||W||x){Ce.current&&(clearInterval(Ce.current),Ce.current=null);return}return Ce.current=setInterval(async()=>{try{const be=await oe.getCameraStatus(t);(be.stalled||!be.active&&!j)&&(Ce.current&&(clearInterval(Ce.current),Ce.current=null),z(!1),Ze())}catch{}},QMe),()=>{Ce.current&&(clearInterval(Ce.current),Ce.current=null)}},[K,j,W,x,t,Ze]),_.useEffect(()=>{const be=()=>{const Pe=!!document.fullscreenElement;b(Pe),Pe||(N(1),k({x:0,y:0}))};return document.addEventListener("fullscreenchange",be),()=>document.removeEventListener("fullscreenchange",be)},[]);const G=()=>{me.current&&(document.fullscreenElement?document.exitFullscreen():me.current.requestFullscreen())},Q=()=>{N(be=>Math.min(be+.5,4))},de=()=>{N(be=>{const Pe=Math.max(be-.5,1);return Pe===1&&k({x:0,y:0}),Pe})},q=be=>{be.preventDefault(),be.deltaY<0?Q():de()},ee=be=>{S>1&&(be.preventDefault(),E(!0),A({x:be.clientX-T.x,y:be.clientY-T.y}))},B=_.useCallback(()=>{if(!me.current||!ue.current)return{x:200,y:150};const be=me.current.getBoundingClientRect(),Pe=be.width*(S-1)/2,Ie=be.height*(S-1)/2;return{x:Math.max(50,Pe),y:Math.max(50,Ie)}},[S]),he=be=>{if(C&&S>1){const Pe=be.clientX-P.x,Ie=be.clientY-P.y,_e=B();k({x:Math.max(-_e.x,Math.min(_e.x,Pe)),y:Math.max(-_e.y,Math.min(_e.y,Ie))})}},ke=()=>{E(!1)},pe=be=>{if(be.length<2)return 0;const Pe=be[0].clientX-be[1].clientX,Ie=be[0].clientY-be[1].clientY;return Math.sqrt(Pe*Pe+Ie*Ie)},H=be=>be.length<2?{x:be[0].clientX,y:be[0].clientY}:{x:(be[0].clientX+be[1].clientX)/2,y:(be[0].clientY+be[1].clientY)/2},O=be=>{be.touches.length===2?(be.preventDefault(),I(pe(be.touches)),U(H(be.touches))):be.touches.length===1&&S>1&&(be.preventDefault(),E(!0),A({x:be.touches[0].clientX-T.x,y:be.touches[0].clientY-T.y}))},J=be=>{if(be.touches.length===2&&D!==null){be.preventDefault();const Pe=pe(be.touches),Ie=Pe/D;N(Ke=>{const Me=Math.max(1,Math.min(4,Ke*Ie));return Me===1&&k({x:0,y:0}),Me}),I(Pe);const _e=H(be.touches);if(L){const Ke=B();k(Me=>({x:Math.max(-Ke.x,Math.min(Ke.x,Me.x+(_e.x-L.x))),y:Math.max(-Ke.y,Math.min(Ke.y,Me.y+(_e.y-L.y)))}))}U(_e)}else if(be.touches.length===1&&C&&S>1){be.preventDefault();const Pe=be.touches[0].clientX-P.x,Ie=be.touches[0].clientY-P.y,_e=B();k({x:Math.max(-_e.x,Math.min(_e.x,Pe)),y:Math.max(-_e.y,Math.min(_e.y,Ie))})}},le=be=>{be.touches.length<2&&(I(null),U(null)),be.touches.length===0&&E(!1)},Se=()=>{N(1),k({x:0,y:0})},we=()=>{z(!1),te<Y6?Ze():V(!0)},ae=()=>{z(!1),V(!1),$(0),ne(!1),Te.current&&clearTimeout(Te.current),ie.current&&clearInterval(ie.current)},Le=()=>{z(!0),V(!1),$(0),ne(!1),Te.current&&clearTimeout(Te.current),ie.current&&clearInterval(ie.current),fetch(`/api/v1/printers/${t}/camera/stop`).catch(()=>{}),ue.current&&(ue.current.src=""),setTimeout(()=>Y(Date.now()),100)},Be=be=>{be.target.closest(".no-drag")||(u(!0),m({x:be.clientX-o.x,y:be.clientY-o.y}))},Ve=be=>{be.stopPropagation(),h(!0)};_.useEffect(()=>{const be=Ie=>{if(c)l(_e=>({..._e,x:Math.max(0,Math.min(Ie.clientX-p.x,window.innerWidth-_e.width)),y:Math.max(0,Math.min(Ie.clientY-p.y,window.innerHeight-_e.height))}));else if(d&&me.current){const _e=me.current.getBoundingClientRect();l(Ke=>({...Ke,width:Math.max(200,Math.min(Ie.clientX-_e.left,window.innerWidth-Ke.x-10)),height:Math.max(150,Math.min(Ie.clientY-_e.top,window.innerHeight-Ke.y-10))}))}},Pe=()=>{u(!1),h(!1)};if(c||d)return document.addEventListener("mousemove",be),document.addEventListener("mouseup",Pe),()=>{document.removeEventListener("mousemove",be),document.removeEventListener("mouseup",Pe)}},[c,d,p]);const He=`/api/v1/printers/${t}/camera/stream?fps=15&t=${X}`;return a.jsxs("div",{ref:me,className:`${v?"fixed inset-0 z-[100]":"fixed z-50 rounded-lg shadow-2xl border border-bambu-dark-tertiary"} bg-bambu-dark-secondary overflow-hidden`,style:v?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:Be,children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[a.jsx(Hg,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"truncate",children:Fe?.name||e})]}),a.jsxs("div",{className:"flex items-center gap-1 no-drag",children:[a.jsx("button",{onClick:Le,disabled:K||W,className:"p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:"Refresh stream",children:a.jsx(Dr,{className:`w-3.5 h-3.5 text-bambu-gray ${K?"animate-spin":""}`})}),a.jsx("button",{onClick:G,className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:v?"Exit fullscreen":"Fullscreen",children:v?a.jsx(jW,{className:"w-3.5 h-3.5 text-bambu-gray"}):a.jsx(tde,{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(AW,{className:"w-3.5 h-3.5 text-bambu-gray"}):a.jsx(CW,{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(Lt,{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:q,onMouseMove:he,onMouseUp:ke,onMouseLeave:ke,onTouchStart:O,onTouchMove:J,onTouchEnd:le,style:{touchAction:"none"},children:[K&&!W&&a.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:a.jsx(Dr,{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(lm,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Reconnecting in ",re,"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(Sn,{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:Le,className:"px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80",children:"Retry"})]})}),a.jsx("img",{ref:ue,src:He,alt:"Camera stream",className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${S}) translate(${T.x/S}px, ${T.y/S}px)`,cursor:S>1?C?"grabbing":"grab":"default"},onError:we,onLoad:ae,onMouseDown:ee,draggable:!1},X),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:de,disabled:S<=1,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:a.jsx(IR,{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(S*100),"%"]}),a.jsx("button",{onClick:Q,disabled:S>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:a.jsx(FR,{className:"w-3.5 h-3.5 text-white"})})]}),!v&&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:Ve,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 JMe({printerId:t,printerName:e,onClose:n}){const{t:r}=On(),i=sn(),[s,o]=_.useState(!0),[l,c]=_.useState(new Set),[u,d]=_.useState(""),[h,p]=_.useState("all"),m=_.useRef(null),{data:x,isLoading:y,refetch:v}=ct({queryKey:["mqtt-logs",t],queryFn:()=>oe.getMQTTLogs(t),refetchInterval:1e3}),b=gt({mutationFn:()=>oe.enableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),S=gt({mutationFn:()=>oe.disableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),N=gt({mutationFn:()=>oe.clearMQTTLogs(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}});_.useEffect(()=>{const D=I=>{I.key==="Escape"&&n()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[n]),_.useEffect(()=>{s&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[x?.logs,s]);const T=D=>{c(I=>{const L=new Set(I);return L.has(D)?L.delete(D):L.add(D),L})},k=D=>new Date(D).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),C=(D,I)=>{if(D==null)return"<empty>";const L=typeof D=="string"?JSON.parse(D):D,U=JSON.stringify(L,null,I?2:0);return!I&&U.length>100?U.substring(0,100)+"...":U},E=x?.logging_enabled??!1,P=_.useMemo(()=>x?.logs??[],[x?.logs]),A=_.useMemo(()=>P.filter(D=>{if(h!=="all"&&D.direction!==h)return!1;if(u.trim()){const I=u.toLowerCase(),L=D.topic.toLowerCase().includes(I),j=JSON.stringify(D.payload).toLowerCase().includes(I);return L||j}return!0}),[P,u,h]);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:r("mqttDebug.title")}),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(Lt,{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:[E?a.jsxs(Ae,{size:"sm",variant:"secondary",onClick:()=>S.mutate(),disabled:S.isPending,children:[a.jsx(cl,{className:"w-4 h-4"}),r("mqttDebug.stopLogging")]}):a.jsxs(Ae,{size:"sm",onClick:()=>b.mutate(),disabled:b.isPending,children:[a.jsx(So,{className:"w-4 h-4"}),r("mqttDebug.startLogging")]}),a.jsxs(Ae,{size:"sm",variant:"secondary",onClick:()=>N.mutate(),disabled:N.isPending||P.length===0,children:[a.jsx(an,{className:"w-4 h-4"}),r("mqttDebug.clearLog")]}),a.jsx(Ae,{size:"sm",variant:"secondary",onClick:()=>v(),disabled:y,children:a.jsx(Dr,{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:s,onChange:D=>o(D.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),a.jsxs("span",{className:"text-sm text-bambu-gray",children:[A.length,"/",P.length]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx(wa,{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:r("mqttDebug.searchPlaceholder"),value:u,onChange:D=>d(D.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"}),u&&a.jsx("button",{onClick:()=>d(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:a.jsx(Lt,{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:()=>p("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${h==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:r("mqttDebug.all")}),a.jsxs("button",{onClick:()=>p("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${h==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[a.jsx(q0,{className:"w-3 h-3"}),r("mqttDebug.incoming")]}),a.jsxs("button",{onClick:()=>p("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${h==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[a.jsx(zg,{className:"w-3 h-3"}),r("mqttDebug.outgoing")]})]})]})]}),a.jsx("div",{ref:m,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:P.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:r("mqttDebug.noMessages")}),!E&&a.jsx("p",{className:"text-sm",children:r("mqttDebug.startLoggingHint")})]}):A.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:r("mqttDebug.noMessagesMatch")}),a.jsx("p",{className:"text-sm",children:r("mqttDebug.adjustFilterHint")})]}):a.jsx("div",{className:"space-y-1",children:A.map((D,I)=>{const L=l.has(I),U=D.direction==="in";return a.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${L?"bg-bambu-dark-secondary":""}`,onClick:()=>T(I),children:[a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-bambu-gray shrink-0",children:k(D.timestamp)}),a.jsx("span",{className:`shrink-0 ${U?"text-blue-400":"text-green-400"}`,title:r(U?"mqttDebug.incoming":"mqttDebug.outgoing"),children:U?a.jsx(q0,{className:"w-3 h-3"}):a.jsx(zg,{className:"w-3 h-3"})}),a.jsx("span",{className:"text-purple-400 shrink-0",children:D.topic})]}),L?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:C(D.payload,!0)}):a.jsx("pre",{className:"mt-1 text-white/80 truncate",children:C(D.payload,!1)})]},I)})})}),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:E?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"}),r("mqttDebug.loggingActive")]}):a.jsx("span",{children:r("mqttDebug.loggingStopped")})}),a.jsx(Ae,{variant:"secondary",onClick:n,children:r("common.close")})]})]})})}const N3={"0300_4000":"Z axis homing failed; the task has been stopped.","0300_4001":"The printer timed out waiting for the nozzle to cool down before homing.","0300_4002":"Auto Bed Leveling failed; the task has been stopped.","0300_4005":"The hotend cooling fan speed is abnormal.","0300_4006":"The nozzle is clogged.","0300_4008":"The AMS failed to change filament.","0300_4009":"Homing XY axis failed.","0300_400A":"Mechanical resonance frequency identification failed.","0300_400B":"Internal communication exception","0300_400C":"The task was canceled.","0300_400D":"Resume failed after power loss.","0300_400E":"The motor self-check failed.","0300_400F":"The power supply voltage does not match the printer.","0300_4010":"Nozzle offset calibration failed.","0300_4011":"Flow Dynamics Calibration failed; please reinitiate printing or calibration.","0300_4013":"Printing cannot be initiated while AMS is drying.","0300_4014":"Homing Z axis failed: temperature control abnormality.","0300_4015":"Nozzle clumping detection calibration failed. Please go to 'Assistant' for troubleshooting.","0300_4016":"Nozzle cleaning failed. Please click the Assistant for troubleshooting.","0300_401F":"The hotend is not installed, and the toolhead cannot perform homing. Please install the hotend and then continue.","0300_4020":"The nozzle presence detection failed. Please check the Assistant for details.","0300_4021":"Nozzle offset calibration sensor signal abnormality detected. Please check the sensor and retry.","0300_4042":"The Laser Safety Window is not properly installed. The task has been stopped.","0300_4044":"The Flame Sensor is abnormal. The sensor may be short-circuited. Please troubleshoot the issue before starting a print job.","0300_404B":"Task aborted because the front door or top cover is open.","0300_404D":"The current temperature of the hotend, heatbed, or chamber is too high. Please wait for it to cool down to room temperature before restarting the task.","0300_4050":"Liveview Camera calibration timeout; please restart the printer.","0300_4052":"Blade Z-axis homing failed","0300_4057":"Z-axis step loss detected. The task has stopped. Please check if there are any obstructions beneath the heatbed.","0300_4066":"Calibration of motion precision failed.","0300_4067":"Calibration result is over the threshold.","0300_4068":"Step loss occurred during the motion accuracy enhancement process. Please try again.","0300_8000":"Printing was paused for unknown reason. You can select 'Resume' to resume the print job.","0300_8001":"Printing was paused by the user. You can select 'Resume' to continue printing.","0300_8002":"First layer defects were detected by the Micro Lidar. Please check the quality of the printed model before continuing your print.","0300_8003":"Spaghetti defects were detected by the AI Print Monitoring. Please check the quality of the printed model before continuing your print.","0300_8004":"Filament ran out. Please load new filament.","0300_8005":"Toolhead front cover fell off. Please remount the front cover and check to make sure your print is going okay.","0300_8006":"The build plate marker was not detected. Please confirm the build plate is correctly positioned on the heatbed with all four corners aligned, and the marker is visible.","0300_8007":"There was an unfinished print job when the printer lost power. If the model is still adhered to the build plate, you can try resuming the print job.","0300_8008":"Nozzle temperature malfunction","0300_8009":"Heatbed temperature malfunction","0300_800A":"A Filament pile-up was detected by AI Print Monitoring. Please clean filament from the waste chute.","0300_800B":"The cutter is stuck. Please make sure the cutter handle is out and check the filament sensor cable connection.","0300_800C":"Skipped step detected: auto-recover complete; please resume print and check if there are any layer shift problems.","0300_800D":"Detected that the extruder is not extruding normally. If the defects are acceptable, select 'Resume' to resume the print job.","0300_800E":"The print file is not available. Please check to see if the storage media has been removed.","0300_800F":"The door seems to be open, so printing was paused.","0300_8010":"The hotend cooling fan speed is abnormal.","0300_8011":"Detected build plate is not the same as the Gcode file. Please adjust slicer settings or use the correct plate.","0300_8013":"Printing paused due to the pause command added to the printing file.","0300_8014":"The nozzle is covered with filament, or the build plate is installed incorrectly. Please cancel this print and clean the nozzle or adjust the build plate according to the actual status. You can als...","0300_8015":"The filament on external spool has run out; please load new filament. If the filament is loaded, please select 'Resume'.","0300_8016":"The nozzle is clogged with filament. Please cancel this print and clean the nozzle or select 'Resume' to resume the print job.","0300_8017":"Foreign objects detected on heatbed. Please check and clean the heatbed. Then, select 'Resume' to resume the print job.","0300_8018":"Chamber temperature malfunction.","0300_8019":"No build plate is placed.","0300_801A":"Filament extrusion error; please check the assistant for troubleshooting. After resolving the issue, decide whether to cancel or resume the print job based on the actual print status.","0300_801B":"Nozzle temperature problem detected. Refer to Assistant to re-connect the hotend connector. POWER OFF the printer before this operation to avoid short circuits.","0300_801C":"The extrusion resistance is abnormal. The extruder may be clogged; please refer to the assistant. After trouble shooting, you can select 'Resume' to resume the print job.","0300_801D":"The extruder servo motor position sensor is malfunctioning. Please power off the printer first and check if the connection cable is loose.","0300_801E":"The extrusion motor is overloaded, please check the Assistant for details.","0300_8021":"The nozzle may not be installed or not properly installed. Please ensure the nozzle is correctly installed before proceeding.","0300_8022":"The heatbed may be obstructed while moving downward. Please clear any objects beneath the heatbed and check for any resistance or jamming during its movement.","0300_8028":"Nozzle offset calibration sensor error. If using a single hotend or the calibration function is disabled, you may ignore this and continue printing; otherwise, it is recommended to check the sensor...","0300_8041":"Platform detection timeout: please restart the printer.","0300_8042":"Task paused because the door is open.","0300_8043":"The laser module is abnormal.","0300_8044":"Fire was detected inside the chamber.","0300_8045":"Material detection timeout: please restart the printer.","0300_8046":"Foreign object detect timeout: please restart the printer.","0300_8047":"Quick-release lever detection time out: please restart the printer.","0300_8048":"Laser Module unlock has timed out, and the task cannot proceed. Please restart the printer and try again.","0300_8049":"The current plate is invalid.","0300_804A":"Emergency stop button improperly installed. Please reinstall according to the Wiki before proceeding.","0300_804B":"Task paused. The Laser Safety Window is open.","0300_804E":"This is a printing task. Please detach the Laser/Cutting Module from the Toolhead.","0300_804F":"The loading/unloading process is currently ongoing. Please stop the process or remove the laser/cutting module.","0300_8050":"This device does not support the 40W Laser Module. Please remove it or replace it with a 10W Laser Module.","0300_8051":"The cutting module has dropped or the cutting module cable is disconnected; please check the module.","0300_8053":"Laser module detected. Please install the right nozzle correctly to ensure proper Laser Module Mounting Calibration.","0300_8054":"Please place the paper required for Print Then Cut.","0300_8055":"The module mounted on the toolhead does not match the task. Please install the correct module.","0300_8057":"The rotary attachment is disconnected. Please ensure it is properly installed and the cable is securely plugged in.","0300_8058":"The rotary attachment is detected. Please remove it before continuing.","0300_8061":"The mode of Airflow System failed to activate; check the air door condition.","0300_8062":"The chamber temperature is too high. It may be due to high environmental temperature.","0300_8063":"The chamber temperature is too high. Please open the top cover and front door to cool down.","0300_8064":"The chamber temperature is too high. Please open the top cover and front door to cool down. (Open door detection for this print job will be set to 'Notification' level)","0300_8065":"The temperature of the MC module is too high. Please check the Wiki for possible explanations.","0300_8071":"The Toolhead Enhanced Cooling Fan module is malfunctioning.","0300_807D":"Fire Extinguisher not detected, the automatic extinguishing function will be unavailable.","0300_807E":"Fire Extinguisher not detected, the automatic extinguishing function will be unavailable.","0300_807F":"Fire Extinguisher is malfunctioning.","0300_8080":"Fire extinguisher motor reset failed.","0300_8081":"Fire extinguisher cylinder not installed. Please confirm on the extinguisher page.","0300_8082":"The Fire Extinguisher Gas Cylinder is empty.","0300_C012":"Please heat the nozzle to above 170°C.","0300_C056":"A minor fire was detected inside the chamber, and the Auto Fire Extinguishing process has been aborted.","0300_C070":"The fire extinguisher has been detected and is ready for use after the laser module is connected.","0500_4001":"Failed to connect to Bambu Cloud. Please check your network connection.","0500_4002":"Unsupported print file path or name. Please resend the print job.","0500_4003":"Printing stopped because the printer was unable to parse the file. Please resend your print job.","0500_4004":"Device is busy and cannot start new task. Please wait for current task to complete before sending new task.","0500_4005":"Print jobs are not allowed to be sent while updating firmware.","0500_4006":"There is not enough free storage space for the print job. Restoring to factory settings can free up available space.","0500_4007":"The device requires a repair upgrade, and printing is currently unavailable.","0500_4008":"Starting printing failed; please power cycle the printer and resend the print job.","0500_4009":"Print jobs are not allowed to be sent while updating logs.","0500_400A":"The file name is not supported. Please rename and restart the print job.","0500_400B":"There was a problem downloading a file. Please check your network connection and resend the print job.","0500_400C":"Please insert a MicroSD card and restart the print job.","0500_400D":"Please run a self-test and restart the print job.","0500_400E":"Printing was cancelled.","0500_400F":"AMS is initializing and cannot be upgraded at the moment. Please try again later.","0500_4010":"AMS is drying and cannot be upgraded at the moment. Please try again later.","0500_4011":"The printer is loading or unloading filament and cannot be upgraded at the moment. Please try again later.","0500_4012":"The device is printing and cannot be upgraded at the moment. Please try again later.","0500_4013":"AMS is in operation and cannot be upgraded at the moment. Please try again when it is idle.","0500_4014":"Slicing for the print job failed. Please check your settings and restart the print job.","0500_4015":"There is not enough free storage space for the print job. Please format or clear files from the MicroSD card to free up space.","0500_4016":"The MicroSD Card is write-protected. Please replace the MicroSD Card.","0500_4017":"Binding failed. Please retry or restart the printer and retry.","0500_4018":"Binding configuration information parsing failed; please try again.","0500_4019":"The printer has already been bound. Please unbind it and try again.","0500_401A":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0500_401B":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_401C":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_401D":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_401E":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_401F":"Authorization timed out. Please make sure that your phone or PC has access to the internet, and ensure that the Bambu Studio/Bambu Handy APP is running in the foreground during the binding operation.","0500_4020":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4021":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_4022":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4023":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4024":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0500_4025":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4026":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_4027":"Cloud access failed; this may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0500_4028":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0500_4029":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0500_402A":"Failed to connect to the router, which may be caused by wireless interference or being too far away from the router. Please try again or move the printer closer to the router and try again.","0500_402B":"Router connection failed due to incorrect password. Please check the password and try again.","0500_402C":"Failed to obtain IP address, which may be caused by wireless interference resulting in data transmission failure or the DHCP address pool of the router being full. Please move the printer closer to...","0500_402D":"System exception","0500_402E":"System does not support the file system currently used by the USB flash drive. Please replace or format the USB flash drive to FAT32.","0500_402F":"The MicroSD card sector data is damaged. Please use the SD card repair tool to repair or format it. If it still cannot be identified, please replace the MicroSD card.","0500_4030":"The device is currently upgrading. Please try again when it is idle.","0500_4031":"The accessory firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4033":"The AMS firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4034":"The Laser Module firmware does not match the printer. Please update it on the 'Firmware' page.","0500_4035":"The BirdsEye Camera is malfunctioning. Please try restarting the device. If the issue persists after multiple restarts, check the camera connection status or contact customer support.","0500_4037":"Your sliced file is not compatible with current printer model. This file can't be printed on this printer.","0500_4038":"The nozzle diameter in sliced file is not consistent with the current nozzle setting. This file can't be printed.","0500_4039":"The current task does not allow the installation of the laser/cutting module, and the task has been halted.","0500_403A":"The current temperature is too low. In order to protect you and your printer, printing tasks, moving an axis and other operations are disabled. Please move the printer to an environment above 10 de...","0500_403B":"Laser/cutting tasks cannot be initiated on the machine at the moment. Please use the computer software to start the task.","0500_403C":"The current nozzle setting does not match the slicing file. Continuing to print may affect print quality. It is recommended to re-slice before starting the print.","0500_403D":"The toolhead module is not set up. Please set it up before initiating the task.","0500_403E":"The current tool head does not support initialization.","0500_403F":"Failed to download print job; please check your network connection.","0500_4040":"The printer has reached its power limit. Please connect a dedicated power adapter to this AMS to enable drying.","0500_4041":"The AMS drying cannot be started during printing.","0500_4042":"Due to power limitations, starting AMS drying will pause current operations such as nozzle heating and fan running. Do you want to proceed with drying?","0500_4043":"Due to power limitations, only one AMS is allowed to use the device's power for drying.","0500_4044":"BirdsEye Camera malfunction: please contact customer support.","0500_4045":"Hotend check in progress. This operation is temporarily unavailable. Please wait.","0500_4050":"Error detected on the print board.","0500_4052":"Error detected on the hot end.","0500_4054":"Error detected on the mat.","0500_405D":"Laser module Serial Number error: unable to calibrate or make project.","0500_4065":"The task requires a Laser Platform, but the current one is a Cutting Platform. Please replace it, measure the material thickness in the software, and then restart the task.","0500_4070":"The laser or cutter module is connected, so the device cannot initiate a 3D printing task.","0500_4075":"No Laser Platform was detected, which may affect thickness measurement accuracy. Please place the laser platform correctly and ensure the rear markers are not blocked, then restart the thickness me...","0500_4076":"Please place the Laser Platform correctly and ensure the rear markers are not blocked, then restart the thickness measurement in the software before initiating the task.","0500_4097":"The device cannot detect the Laser Module. Please reconnect the module cable or restart the printer.","0500_4098":"The device cannot detect AMS A. Please reconnect the AMS cable or restart the printer.","0500_4099":"The firmware of Cutting Module does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409A":"The firmware of the Air Pump does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409B":"The firmware of the Laser Module does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0500_409D":"The firmware of AMS A does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0500_409E":"The device cannot detect the Cutting Module. Please reconnect the module cable or restart the printer.","0500_409F":"The device cannot detect the Air Pump. Please reconnect the module cable or restart the printer.","0500_40A0":"The Rotary Attachment module is not detected. Please reconnect the cable or restart the printer.","0500_40A1":"The Auto Fire Extinguishing System is not detected. Please reconnect the module cable or restart the printer.","0500_40A3":"AMS(or AMS lite) A communication is abnormal. Please reconnect the module cable or restart the printer.","0500_40A4":"The current firmware only supports 1 AMS Lite. Please remove all AMS units before reconnecting the supported AMS Lite device.","0500_40A5":"The current firmware only supports AMS/AMS 2 Pro/AMS HT, with a maximum of 4 units. Please remove all AMS units before reconnecting the supported one.","0500_8013":"The print file is not available. Please check to see if the storage media has been removed.","0500_8036":"Your sliced file is not consistent with the current printer model. Continue?","0500_803C":"The current nozzle setting does not match the slicing file. Continuing to print may affect print quality. It is recommended to re-slice before starting the print.","0500_8040":"Toolhead front cover is detached. Moving the toolhead may damage the printer. Do you want to continue?","0500_8041":"The filament in hotend is too cold. Extrusion may damage the extruder. Still feeding in/out the filament?","0500_8048":"The module on the toolhead is not calibrated. Please cancel the task to perform calibration or switch to a calibrated module.","0500_8051":"Detected build plate is not the same as the Gcode file. Please adjust slicer settings or use the correct plate.","0500_8053":"Nozzle mismatch was detected during printing. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","0500_8055":"Laser module is installed, but a Cutting Platform is detected. Please place a Laser Platform and perform laser calibration.","0500_8056":"Cutting module is installed, but the laser platform is detected. Please place the cutting platform for calibration.","0500_8058":"Please place the light grip cutting mat correctly and ensure the marker is exposed.","0500_8059":"Cutting platform base is not correctly aligned. Please ensure that the four corners of the platform are aligned with the heatbed.","0500_805A":"Please place the cutting mat on cutting protection base.","0500_805B":"The cutting mat type is unknown; please replace it with the correct cutting mat.","0500_805C":"The grip cutting mat type does not match; please place a LightGrip cutting mat.","0500_805E":"Cutting module Serial Number error: unable to calibrate or make project.","0500_8060":"The current module on toolhead does not meet requirements. Please replace the module as per the on-screen instructions.","0500_8061":"No print plate detected. Please make sure it is placed correctly.","0500_8062":"The print plate marker was not detected. Please confirm the print plate is correctly positioned on the heatbed with all four corners aligned, and the marker is visible. If strong light is shining o...","0500_8063":"The platform is not detected during calibration; please make sure the Laser Platform is properly placed.","0500_8064":"Please place the Laser Platform correctly and ensure the rear markers are not blocked for laser calibration.","0500_8066":"The task requires a Cutting Platform, but the current one is a Laser Platform. Please replace it with a Cutting Platform (Cutting Protection Base + LightGrip cutting mat).","0500_8067":"Please place a LightGrip cutting mat on the cutting protection base.","0500_8068":"Please place the strong grip cutting mat correctly and ensure the marker is exposed.","0500_8069":"Unable to recognize the left and right hotends. They might be third party hotends, or the hotend marks may be dirty. Please manually set the hotend types.","0500_806A":"Unable to recognize the left and right hotends. They might be third party hotends, or the hotend marks may be dirty. Please set hotend types on printer screen before next print.","0500_806B":"Quick-release Lever is not locked. Please press down the external toolhead module to ensure it is properly seated, then push down the level to lock it in place.","0500_806C":"Please place the cutting platform correctly and ensure the marker is exposed.","0500_806D":"Material not detected. Please confirm placement and continue.","0500_806E":"Foreign objects detected on heatbed; please check and clean up the heatbed.","0500_806F":"The grip cutting mat type does not match; please place a StrongGrip cutting mat.","0500_8071":"No cutting platform was detected. Please confirm that it has been correctly placed.","0500_8072":"Live View camera is blocked","0500_8073":"Heatbed limit block is obstructed or contaminated. Please clean and ensure the limit block is visible, otherwise platform position offset detection may be inaccurate.","0500_8074":"The Laser Platform is offset. Please ensure that the four corners of the platform are aligned with the heatbed, and the marker is not obstructed.","0500_8077":"The visual marker was not detected. Please ensure the paper is properly placed.","0500_8078":"Current material does not match the sliced file settings. Please load the correct material and ensure the QR code on the material is not damaged or dirty.","0500_8079":"Please place the Laser Test Material (350g paperboard) and position support strips underneath to prevent material warping.","0500_807A":"The foreign object detection function is not working. You can continue the task or check the assistant for troubleshooting.","0500_807B":"Please place the cutting platform (cutting protection base + LightGrip cutting mat).","0500_807C":"Please place the cutting platform (cutting protection base + StrongGrip cutting mat).","0500_807D":"This task requires a Cutting Platform, but the current one is a Laser Platform. Please replace it with a Cutting Platform (Cutting Protection Base + StrongGrip Cutting Mat).","0500_807E":"Please place a StrongGrip cutting mat on the cutting protection base.","0500_8080":"The left and right hotends are not installed.","0500_8081":"The left and right hotends are not installed.","0500_8082":"Please remove the protective film on the Opaque Glossy Acrylic before processing","0500_8083":"Material is not allowed in Mounting Calibration. Please remove the material from the platform.","0500_8084":"The Live View Camera is dirty; please clean it and continue.","0500_8085":"Toolhead camera is obstructed","0500_8086":"Toolhead Camera is dirty, which affects the AI function; please clean the lens surface.","0500_8087":"BirdsEye camera is obstructed","0500_8088":"The Birdseye Camera is dirty","0500_8089":"Task paused due to Presence Check failed. Please check the printer to continue.","0500_808A":"The BirdsEye Camera is installed offset. Please refer to the assistant to reinstall it.","0500_808B":"The BirdsEye Camera setup failed. Please remove all objects and the mat on the heatbed to ensure the heatbed markers are visible. Meanwhile, please ensure the BirdsEye Camera is installed correctly...","0500_808C":"Detected build plate offset. Please align the build plate with the heatbed, and then continue.","0500_808D":"The Cutting Module offset calibration failed, which may result in inaccurate cuts. Please ensure the cutting material is properly positioned and check whether the cutting blade tip is worn.","0500_808E":"BirdsEye Camera initialization failed. The toolhead camera did not detect the Heatbed features. Please clean the Heatbed, remove all objects and pads, and ensure the bed markings are visible. Check...","0500_808F":"Nozzle camera lens is dirty, affecting AI monitoring. Clean the lens with a non-woven cloth and a small amount of alcohol. Beware of hotend heat; wait for it to cool before handling.","0500_8090":"Please attach the 80g White Printing Paper to the center area of the platform.","0500_8091":"The Cutting Module offset calibration failed, which may result in inaccurate cuts. Please ensure the 80g white printer paper(letter paper thickness) is properly positioned and check whether the cut...","0500_8092":"Toolhead Camera initialization failed. This print can still continue, but some AI functions will be disabled. If you encounter this issue again after restarting, please contact customer support.","0500_8093":"The nozzle silicone sleeve is not installed; there is a risk of temperature control failure. Please install it correctly and try again.","0500_80A0":"The visual encoder board was not detected. Please check if the board is properly placed and aligned at all four corners, and ensure the positioning markings are clear and free from wear.","0500_C010":"MicroSD Card read/write exception: please reinsert or replace the MicroSD Card.","0500_C032":"Laser/Cutting module connected to the toolhead. The drying process has been automatically stopped.","0500_C036":"This is a printing task. Please detach the Laser/Cutting Module from the Toolhead.","0500_C07F":"Device is busy and cannot perform this operation. To proceed, please pause or stop the current task.","0501_4017":"Binding failed. Please retry or restart the printer and retry.","0501_4018":"Binding configuration information parsing failed; please try again.","0501_4019":"The printer has already been bound. Please unbind it and try again.","0501_401A":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0501_401B":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_401C":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_401D":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_401E":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_401F":"Authorization timed out. Please make sure that your phone or PC has access to the internet, and ensure that the Bambu Studio/Bambu Handy APP is running in the foreground during the binding operation.","0501_4020":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4021":"Cloud access failed, which may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_4022":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4023":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4024":"Cloud access failed. Possible reasons include network instability caused by interference, inability to access the internet, or router firewall configuration restrictions. You can try moving the pri...","0501_4025":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4026":"Cloud access rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4027":"Cloud access failed; this may be caused by network instability due to interference. You can try moving the printer closer to the router before you try again.","0501_4028":"Cloud response is invalid. If you have tried multiple times and are still failing, please contact customer support.","0501_4029":"Cloud access is rejected. If you have tried multiple times and are still failing, please contact customer support.","0501_4031":"Device discovery binding is in progress, and the QR code cannot be displayed on the screen. You can wait for the binding to finish or abort the device discovery binding process in the APP/Studio an...","0501_4032":"QR code binding is in progress, so device discovery binding cannot be performed. You can scan the QR code on the screen for binding or exit the QR code display page on screen and try device discove...","0501_4033":"Your APP region does not match with your printer; please download the APP in the corresponding region and register your account again.","0501_4034":"The slicing progress has not been updated for a long time, and the printing task has exited. Please confirm the parameters and reinitiate printing.","0501_4035":"The device is in the process of binding and cannot respond to new binding requests.","0501_4038":"The regional settings do not match the printer; please check the printer's regional settings.","0501_4039":"Device login has expired; please try to bind again.","0501_4098":"The device cannot detect AMS B. Please reconnect the AMS cable or restart the printer.","0501_409D":"The firmware of AMS B does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0501_40A3":"AMS(or AMS lite) B communication is abnormal. Please reconnect the module cable or restart the printer.","0502_4001":"Current filament will be used in this print job. Settings cannot be changed.","0502_4002":"Please go to “Settings > Calibration” to run the Motion Accuracy Enhancement Calibration before turning on Motion Accuracy Enhancement mode.","0502_4003":"The printer is currently printing and the motion accuracy enhancement feature cannot be turned on or off.","0502_4004":"Some features are not supported by the current device. Please check the Studio feature settings or update the firmware to the latest version.","0502_4005":"The AMS has not been calibrated yet, so printing cannot be initiated.","0502_4006":"Unknown module detected; please try updating the firmware to the latest version.","0502_400D":"Failed to start a new task: filament loading/unloading not completed.","0502_400E":"Failed to start a new task: The nozzle cold pull was not completed.","0502_4013":"This device is not compatible with the 40W laser module. Please replace it with a 10W laser module or remove it.","0502_4098":"The device cannot detect AMS C. Please reconnect the AMS cable or restart the printer.","0502_409D":"The firmware of AMS C does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0502_40A3":"AMS(or AMS lite) C communication is abnormal. Please reconnect the module cable or restart the printer.","0502_C00F":"The device is busy and cannot perform nozzle identification.","0502_C010":"Due to printer power limitations, printing, calibration, controls and other actions cannot be performed during AMS drying. Please stop the drying process before proceeding with any other operation.","0502_C011":"Currently in 2D production mode. Please continue the operation on the printer","0502_C012":"The task cannot be paused.","0502_C014":"The AMS Remaining Filament Estimation is enabled by default and cannot be disabled.","0502_C024":"The flow dynamic calibration records have exceeded the storage limit. Please delete some historical records in the slicer software before adding new calibration data.","0503_4098":"The device cannot detect AMS D. Please reconnect the AMS cable or restart the printer.","0503_409D":"The firmware of AMS D does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0503_40A3":"AMS(or AMS lite) D communication is abnormal. Please reconnect the module cable or restart the printer.","0580_4096":"The device cannot detect AMS-HT A. Please reconnect the AMS-HT cable or restart the printer.","0580_409C":"The firmware of AMS-HT A does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0580_40A2":"AMS-HT A communication is abnormal. Please reconnect the module cable or restart the printer.","0581_4096":"The device cannot detect AMS-HT B. Please reconnect the AMS-HT cable or restart the printer.","0581_409C":"The firmware of AMS-HT B does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0581_40A2":"AMS-HT B communication is abnormal. Please reconnect the module cable or restart the printer.","0582_4096":"The device cannot detect AMS-HT C. Please reconnect the AMS-HT cable or restart the printer.","0582_409C":"The firmware of AMS-HT C does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0582_40A2":"AMS-HT C communication is abnormal. Please reconnect the module cable or restart the printer.","0583_4096":"The device cannot detect AMS-HT D. Please reconnect the AMS-HT cable or restart the printer.","0583_409C":"The firmware of AMS-HT D does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0583_40A2":"AMS-HT D communication is abnormal. Please reconnect the module cable or restart the printer.","0584_4096":"The device cannot detect AMS-HT F. Please reconnect the AMS-HT cable or restart the printer.","0584_409C":"The firmware of AMS-HT E does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0584_40A2":"AMS-HT E communication is abnormal. Please reconnect the module cable or restart the printer.","0585_4096":"The device cannot detect AMS-HT E. Please reconnect the AMS-HT cable or restart the printer.","0585_409C":"The firmware of AMS-HT F does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0585_40A2":"AMS-HT F communication is abnormal. Please reconnect the module cable or restart the printer.","0586_4096":"The device cannot detect AMS-HT G. Please reconnect the AMS-HT cable or restart the printer.","0586_409C":"The firmware of AMS-HT G does not match the printer; the device cannot continue working. Please update it on the 'Firmware' page.","0586_40A2":"AMS-HT G communication is abnormal. Please reconnect the module cable or restart the printer.","0587_4096":"The device cannot detect AMS-HT H. Please reconnect the AMS-HT cable or restart the printer.","0587_409C":"The firmware of AMS-HT H does not match the printer; the device cannot continue working. Please upgrade it on the 'Firmware' page.","0587_40A2":"AMS-HT H communication is abnormal. Please reconnect the module cable or restart the printer.","05FE_8053":"The left nozzle is not matched with slicing file. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","05FE_8069":"Unable to recognize the left hotend. It might be a third party hotend, or the hotend mark may be dirty. Please manually set the hotend type.","05FE_806A":"Unable to recognize the left hotend. It might be a third party hotend, or the hotend mark may be dirty. Please set hotend type on printer screen before next print.","05FE_8080":"The left hotend is not installed.","05FE_8081":"The left hotend is not installed.","05FF_8053":"The right nozzle is not matched with slicing file. Please initiate the print after re-slicing, or continue printing after replacing with the correct nozzle. Caution: the hotend temperature is high.","05FF_8069":"Unable to recognize the right hotend. It might be a third party hotend, or the hotend mark may be dirty. Please manually set the hotend type.","05FF_806A":"Unable to recognize the right hotend. It might be a third party hotend, or the hotend mark may be dirty. Please set hotend type on printer screen before next print.","05FF_8080":"The right hotend is not installed.","05FF_8081":"The right hotend is not installed.","0700_4001":"The AMS has been disabled for a print, but it still has filament loaded. Please unload the AMS filament and switch to the spool holder filament for printing.","0700_4025":"Failed to read the filament information.","0700_8001":"Failed to cut the filament. Please check the cutter.","0700_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0700_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0700_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0700_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0700_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0700_8007":"Extruding filament failed. The extruder might be clogged.","0700_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS A to the extruder is properly connected.","0700_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0700_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0700_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0700_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0700_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0700_8017":"AMS A is drying. Please stop drying process before loading/unloading material.","0700_8021":"AMS setup failed; please refer to the assistant.","0700_8023":"AMS A cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0700_C069":"An error occurred during AMS A drying. Please go to Assistant for more details.","0700_C06A":"AMS A is reading RFID. Unable to start drying. Please try again later.","0700_C06B":"AMS A is changing filament. Unable to start drying. Please try again later.","0700_C06C":"AMS A is in Feed Assist Mode. Unable to start drying. Please try again later.","0700_C06D":"AMS A is assisting in filament insertion. Unable to start drying. Please try again later.","0700_C06E":"AMS A motor is performing self-test. Unable to start drying. Please try again later.","0701_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0701_4025":"Failed to read the filament information.","0701_8001":"Failed to cut the filament. Please check the cutter.","0701_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0701_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0701_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0701_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0701_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0701_8007":"Extruding filament failed. The extruder might be clogged.","0701_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS B to the extruder is properly connected.","0701_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0701_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0701_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0701_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0701_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0701_8017":"AMS B is drying. Please stop drying process before loading/unloading material.","0701_8021":"AMS setup failed; please refer to the assistant.","0701_8023":"AMS B cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0701_C069":"An error occurred during AMS B drying. Please go to Assistant for more details.","0701_C06A":"AMS B is reading RFID. Unable to start drying. Please try again later.","0701_C06B":"AMS B is changing filament. Unable to start drying. Please try again later.","0701_C06C":"AMS B is in Feed Assist Mode. Unable to start drying. Please try again later.","0701_C06D":"AMS B is assisting in filament insertion. Unable to start drying. Please try again later.","0701_C06E":"AMS B motor is performing self-test. Unable to start drying. Please try again later.","0702_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0702_4025":"Failed to read the filament information.","0702_8001":"Failed to cut the filament. Please check the cutter.","0702_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0702_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0702_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0702_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0702_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0702_8007":"Extruding filament failed. The extruder might be clogged.","0702_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS C to the extruder is properly connected.","0702_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0702_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0702_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0702_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0702_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0702_8017":"AMS C is drying. Please stop drying process before loading/unloading material.","0702_8021":"AMS setup failed; please refer to the assistant.","0702_8023":"AMS C cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0702_C069":"An error occurred during AMS C drying. Please go to Assistant for more details.","0702_C06A":"AMS C is reading RFID. Unable to start drying. Please try again later.","0702_C06B":"AMS C is changing filament. Unable to start drying. Please try again later.","0702_C06C":"AMS C is in Feed Assist Mode. Unable to start drying. Please try again later.","0702_C06D":"AMS C is assisting in filament insertion. Unable to start drying. Please try again later.","0702_C06E":"AMS C motor is performing self-test. Unable to start drying. Please try again later.","0703_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","0703_4025":"Failed to read the filament information.","0703_8001":"Failed to cut the filament. Please check the cutter.","0703_8002":"The cutter is stuck. Please make sure the cutter handle is out.","0703_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0703_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0703_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0703_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0703_8007":"Extruding filament failed. The extruder might be clogged.","0703_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS D to the extruder is properly connected.","0703_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0703_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0703_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0703_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0703_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0703_8017":"AMS D is drying. Please stop drying process before loading/unloading material.","0703_8021":"AMS setup failed; please refer to the assistant.","0703_8023":"AMS D cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0703_C069":"An error occurred during AMS D drying. Please go to Assistant for more details.","0703_C06A":"AMS D is reading RFID. Unable to start drying. Please try again later.","0703_C06B":"AMS D is changing filament. Unable to start drying. Please try again later.","0703_C06C":"AMS D is in Feed Assist Mode. Unable to start drying. Please try again later.","0703_C06D":"AMS D is assisting in filament insertion. Unable to start drying. Please try again later.","0703_C06E":"AMS D motor is performing self-test. Unable to start drying. Please try again later.","0704_4025":"Failed to read the filament information.","0704_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0704_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0704_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0704_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0704_8007":"Extruding filament failed. The extruder might be clogged.","0704_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS E to the extruder is properly connected.","0704_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0704_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0704_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0704_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0704_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0704_8021":"AMS setup failed; please refer to the assistant.","0704_8023":"AMS E cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0705_4025":"Failed to read the filament information.","0705_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0705_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0705_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0705_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0705_8007":"Extruding filament failed. The extruder might be clogged.","0705_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS F to the extruder is properly connected.","0705_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0705_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0705_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0705_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0705_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0705_8021":"AMS setup failed; please refer to the assistant.","0705_8023":"AMS F cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0706_4025":"Failed to read the filament information.","0706_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0706_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0706_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0706_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0706_8007":"Extruding filament failed. The extruder might be clogged.","0706_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS G to the extruder is properly connected.","0706_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0706_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0706_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0706_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0706_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0706_8021":"AMS setup failed; please refer to the assistant.","0706_8023":"AMS G cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","0707_4025":"Failed to read the filament information.","0707_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","0707_8004":"AMS failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","0707_8005":"The AMS failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","0707_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","0707_8007":"Extruding filament failed. The extruder might be clogged.","0707_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS H to the extruder is properly connected.","0707_8010":"The AMS assist motor is overloaded. This could be due to entangled filament or a stuck spool.","0707_8011":"AMS filament ran out. Please insert a new filament into the same AMS slot.","0707_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","0707_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","0707_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","0707_8021":"AMS setup failed; please refer to the assistant.","0707_8023":"AMS H cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","07FE_8001":"Failed to cut the filament of the left extruder. Please check the cutter.","07FE_8002":"The cutter of the left extruder is stuck. Please pull out the cutter handle.","07FE_8003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are ab...","07FE_8004":"Failed to pull back the filament from the left extruder. Please check whether the filament is stuck inside the extruder.","07FE_8005":"Failed to feed the filament outside the AMS. Please clip the end of the filament flat and check to see if the spool is stuck.","07FE_8006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_8007":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","07FE_8010":"Check if the left external filament spool or filament is stuck.","07FE_8011":"The external filament connected to the left extruder has run out; please load a new filament.","07FE_8012":"Failed to get mapping table; please select 'Resume' to retry.","07FE_8013":"Timeout purging old filament of the left extruder: Please check if the filament is stuck or the extruder is clogged.","07FE_8020":"Extruder change failed; please refer to the assistant.","07FE_8021":"AMS setup failed; please refer to the assistant.","07FE_8024":"Extruder position calibration failed; please refer to the assistant.","07FE_8025":"Cold pull timed out. Please promptly operate or check whether the filament is broken inside the extruder, and click the Assistant for details.","07FE_8030":"The filament specified in the slicer has been used up. Printing is paused. Please go to the machine to replace the material and resume printing.","07FE_C003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","07FE_C006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_C008":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","07FE_C009":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","07FE_C00A":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","07FE_C010":"Insert the filament (over 30cm long) until it stops. You might see slight smoke during flushing. After insertion, close the front door and top cover.","07FE_C011":"Please manually and slowly pull out the filament from the extruder. Then click “Continue”.","07FE_C012":"Press the black PTFE tube coupler and unplug the PTFE tube. After completing the operation, click 'Continue.'","07FF_4001":"Filament is still loaded from the AMS after it has been disabled. Please unload the filament, load from the spool holder, and restart printing.","07FF_8001":"Failed to cut the filament of the right extruder. Please check the cutter.","07FF_8002":"The cutter is stuck. Please make sure the cutter handle is out.","07FF_8003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are a...","07FF_8004":"Failed to pull back the filament from the right extruder. Please check whether the filament is stuck inside the extruder.","07FF_8005":"Failed to feed the filament outside the AMS. Please clip the end of the filament flat and check to see if the spool is stuck.","07FF_8006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_8007":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","07FF_8010":"Check if the external filament spool or filament is stuck.","07FF_8011":"External filament has run out; please load a new filament.","07FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","07FF_8013":"Timeout purging old filament of the right extruder: Please check if the filament is stuck or the extruder is clogged.","07FF_8020":"Extruder change failed; please refer to the assistant.","07FF_8021":"AMS setup failed; please refer to the assistant.","07FF_8024":"Extruder position calibration failed; please refer to the assistant.","07FF_8025":"Cold pull timed out. Please promptly operate or check whether the filament is broken inside the extruder, and click the Assistant for details.","07FF_8030":"The filament specified in the slicer has been used up. Printing is paused. Please go to the machine to replace the material and resume printing.","07FF_C003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","07FF_C006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_C008":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","07FF_C009":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","07FF_C00A":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","07FF_C010":"Insert the filament (over 30cm long) until it stops. You might see slight smoke during flushing. After insertion, close the front door and top cover.","07FF_C011":"Hold the driven wheel bracket, slowly pull the filament from the extruder, then press 'Continue'.","07FF_C012":"Press the black PTFE tube coupler and unplug the PTFE tube. After completing the operation, click 'Continue.'","0C00_4020":"The setup of BirdsEye Camera failed. Please clear all objects and remove the mat. Make sure the marker is not obstructed. Meanwhile, clean both the BirdsEye Camera and Toolhead Camera, and remove a...","0C00_4021":"The setup of BirdsEye Camera failed; please reboot the printer.","0C00_4022":"The setup of BirdsEye Camera failed. Please check if the laser module is working properly.","0C00_4024":"The Birdseye Camera is installed offset. Please refer to the assistant to reinstall it.","0C00_4025":"The Birdseye Camera is dirty. Please clean it and restart the process.","0C00_4026":"The Live View Camera initialization failed; please reboot the printer.","0C00_4027":"The Live View Camera calibration failed. Please refer to the assistant for details and recalibrate the camera after processing.","0C00_4029":"Material not detected. Please confirm placement and continue.","0C00_402A":"The visual marker was not detected. Please re-paste the paper in the correct position.","0C00_402C":"Device data link error. Please reboot the printer","0C00_402D":"The toolhead camera is not working properly; please reboot the device.","0C00_403D":"The vision encoder plate was not detected. Please confirm it is correctly positioned on the heatbed.","0C00_403E":"The high-precision nozzle offset calibration has failed, possibly due to a damaged pattern or the similarity of the colors of the two selected filaments. Please clear the printed pattern and replac...","0C00_4041":"Toolhead camera calibration failed. Please ensure the Calibration Marker on the heatbed or Height Calibration Marker on the homing area is clean and undamaged, then re-run the calibration process.","0C00_8001":"First layer defects were detected. If the defects are acceptable, select 'Resume' to resume the print job.","0C00_8005":"Purged filament has piled up in the waste chute, which may cause a tool head collision.","0C00_8009":"Build plate localization marker was not found.","0C00_800B":"The heatbed marker was not detected. Please clear all objects and remove the mat. Make sure the marker is not obstructed.","0C00_8015":"Objects detected on the platform; please clean them up in a timely manner.","0C00_8016":"The foreign object detection function is not working. You can continue the task or check assistant for solutions.","0C00_8017":"Foreign objects detected on the platform; please clean them up on time.","0C00_8018":"The foreign object detection function is not working. You can continue the task or view the assistant for troubleshooting.","0C00_8033":"Quick-release Lever is not locked. Please push it down to secure.","0C00_8034":"Liveview Camera initialization failed. This print can still continue, but some AI functions will be disabled. If you encounter this issue again after restarting, please contact customer support.","0C00_803F":"AI detected nozzle clumping. Please check the nozzle condition. Refer to assistant for solutions.","0C00_8040":"AI detected air-printing defect. Please check the hotend extrusion status. Refer to assistant for solutions.","0C00_8042":"The AI print monitor has detected a spaghetti defect. Please check the print and take the necessary action.","0C00_8043":"AI detected nozzle clumping. Please check the nozzle condition. Refer to assistant for solutions.","0C00_C003":"Possible defects were detected in the first layer.","0C00_C004":"Possible spaghetti failure was detected.","0C00_C006":"Purged filament may have piled up in the waste chute.","1000_C001":"High bed temperature may lead to filament clogging in the nozzle. You may open the chamber door.","1000_C002":"Printing CF material with stainless steel may cause nozzle damage.","1000_C003":"Enabling Timelapse in traditional mode may cause defects; please activate this feature as needed.","1001_4001":"Timelapse is not supported as Spiral Vase mode is enabled in slicing presets.","1001_4002":"Timelapse is not supported as the Print sequence is set to 'By object'.","1001_8003":"The time-lapse mode is set to Traditional in the slicing file. This may cause surface defects. Would you like to enable it?","1001_8004":"Prime Tower is not enabled and time-lapse mode is set to Smooth in slicing file. This may cause surface defects. Would you like to enable it?","1200_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1200_8001":"Cutting the filament failed. Please check to see if the cutter is stuck. Refer to the Assistant for solutions.","1200_8002":"The cutter is stuck. Please pull out the cutter handle.","1200_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1200_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1200_8005":"The filament is not inserted. Please insert the filament.","1200_8006":"Unable to feed filament into the extruder. This could be due to tangled filament or a stuck spool. If not, please check if the AMS PTFE tube is connected.","1200_8007":"Failed to extrude the filament. This might be caused by clogged extruder or stuck filament. Refer to the Assistant for solutions.","1200_8010":"Filament or spool may be stuck.","1200_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1200_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1200_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1200_8014":"The filament location in the toolhead was not found. Refer to the Assistant for solutions.","1200_8015":"Failed to pull out the filament from the toolhead. Please check if the filament is stuck, or if it is broken inside the extruder or PTFE tube.","1200_8016":"The extruder is not extruding normally. Refer to the Assistant for troubleshooting. There may be defects in this layer, but you may resume if the defects are acceptable.","1201_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1201_8001":"Failed to cut the filament. Please check the cutter.","1201_8002":"The cutter is stuck. Please pull out the cutter handle.","1201_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1201_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1201_8005":"Failed to feed the filament. Please load the filament and then select 'Retry'.","1201_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1201_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1201_8010":"Please check if the spool or filament is stuck.","1201_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1201_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1201_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1201_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1201_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or the filament is broken inside the extruder.","1201_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","1202_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1202_8001":"Failed to cut the filament. Please check the cutter.","1202_8002":"The cutter is stuck. Please pull out the cutter handle.","1202_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1202_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1202_8005":"The filament is not inserted. Please insert the filament.","1202_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1202_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1202_8010":"Please check if the spool or filament is stuck.","1202_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1202_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1202_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1202_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1202_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or is broken inside the extruder.","1202_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","1203_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","1203_8001":"Failed to cut the filament. Please check the cutter.","1203_8002":"The cutter is stuck. Please pull out the cutter handle.","1203_8003":"Failed to pull out the filament from the extruder. Please check whether the extruder is clogged or whether the filament is broken inside the extruder.","1203_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","1203_8005":"The filament is not inserted. Please insert the filament.","1203_8006":"Failed to feed the filament into the toolhead. Please check whether the filament is stuck.","1203_8007":"Failed to extrude the filament. The extruder may be clogged or the filament may be stuck; please refer to HMS.","1203_8010":"Please check if the spool or filament is stuck.","1203_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","1203_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1203_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","1203_8014":"Failed to check the filament location in the tool head; please refer to the HMS.","1203_8015":"Failed to pull back the filament from the toolhead. Please check if the filament is stuck or is broken inside the extruder.","1203_8016":"The extruder is not extruding normally; please refer to the HMS. After trouble shooting, if the defects are acceptable, please resume printing.","12FF_4001":"Filament is still loaded from the AMS when it has been disabled. Please unload AMS filament, load from spool holder, and restart print job.","12FF_8001":"Failed to cut the filament. Please check the cutter.","12FF_8002":"The cutter is stuck. Please pull out the cutter handle.","12FF_8003":"Please pull out the filament on the spool holder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube if you are about to us...","12FF_8004":"Failed to pull back the filament from the toolhead. Please check whether the filament is stuck.","12FF_8005":"The filament is not inserted. Please insert the filament.","12FF_8006":"Please feed filament into the PTFE tube until it can not be pushed any farther.","12FF_8007":"Check nozzle. Select 'Done' if filament was extruded, otherwise push filament forward slightly and select 'Retry.'","12FF_8010":"Please check if the filament or the spool is stuck.","12FF_8011":"AMS filament has run out. Please insert a new filament into the same AMS slot.","12FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","12FF_8013":"Timeout while purging old filament. Please check if the filament is stuck or the extruder clogged.","12FF_C003":"Please pull out the filament on the spool holder. If this message persists, please check to see if there is filament broken in the extruder or PTFE Tube. (Connect a PTFE tube if you are about to us...","12FF_C006":"Please feed filament into the PTFE tube until it can not be pushed any farther.","1800_4025":"Failed to read the filament information.","1800_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1800_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1800_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1800_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1800_8007":"Extruding filament failed. The extruder might be clogged.","1800_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT A to the extruder is properly connected.","1800_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1800_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1800_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1800_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1800_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1800_8017":"AMS-HT A is drying. Please stop drying process before loading/unloading material.","1800_8021":"AMS setup failed; please refer to the assistant.","1800_8023":"AMS-HT A cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1800_C069":"An error occurred during AMS-HT A drying. Please go to Assistant for more details.","1800_C06A":"AMS-HT A is reading RFID. Unable to start drying. Please try again later.","1800_C06B":"AMS-HT A is changing filament. Unable to start drying. Please try again later.","1800_C06C":"AMS-HT A is in Feed Assist Mode. Unable to start drying. Please try again later.","1800_C06D":"AMS-HT A is assisting in filament insertion. Unable to start drying. Please try again later.","1800_C06E":"AMS-HT A motor is performing self-test. Unable to start drying. Please try again later.","1801_4025":"Failed to read the filament information.","1801_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1801_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1801_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1801_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1801_8007":"Extruding filament failed. The extruder might be clogged.","1801_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT B to the extruder is properly connected.","1801_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1801_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1801_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1801_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1801_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1801_8017":"AMS-HT B is drying. Please stop drying process before loading/unloading material.","1801_8021":"AMS setup failed; please refer to the assistant.","1801_8023":"AMS-HT B cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1801_C069":"An error occurred during AMS-HT B drying. Please go to Assistant for more details.","1801_C06A":"AMS-HT B is reading RFID. Unable to start drying. Please try again later.","1801_C06B":"AMS-HT B is changing filament. Unable to start drying. Please try again later.","1801_C06C":"AMS-HT B is in Feed Assist Mode. Unable to start drying. Please try again later.","1801_C06D":"AMS-HT B is assisting in filament insertion. Unable to start drying. Please try again later.","1801_C06E":"AMS-HT B motor is performing self-test. Unable to start drying. Please try again later.","1802_4025":"Failed to read the filament information.","1802_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1802_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1802_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1802_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1802_8007":"Extruding filament failed. The extruder might be clogged.","1802_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT C to the extruder is properly connected.","1802_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1802_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1802_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1802_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1802_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1802_8017":"AMS-HT C is drying. Please stop drying process before loading/unloading material.","1802_8021":"AMS setup failed; please refer to the assistant.","1802_8023":"AMS-HT C cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1802_C069":"An error occurred during AMS-HT C drying. Please go to Assistant for more details.","1802_C06A":"AMS-HT C is reading RFID. Unable to start drying. Please try again later.","1802_C06B":"AMS-HT C is changing filament. Unable to start drying. Please try again later.","1802_C06C":"AMS-HT C is in Feed Assist Mode. Unable to start drying. Please try again later.","1802_C06D":"AMS-HT C is assisting in filament insertion. Unable to start drying. Please try again later.","1802_C06E":"AMS-HT C motor is performing self-test. Unable to start drying. Please try again later.","1803_4025":"Failed to read the filament information.","1803_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1803_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1803_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1803_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1803_8007":"Extruding filament failed. The extruder might be clogged.","1803_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT D to the extruder is properly connected.","1803_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1803_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1803_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1803_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1803_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1803_8017":"AMS-HT D is drying. Please stop drying process before loading/unloading material.","1803_8021":"AMS setup failed; please refer to the assistant.","1803_8023":"AMS-HT D cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1803_C069":"An error occurred during AMS-HT D drying. Please go to Assistant for more details.","1803_C06A":"AMS-HT D is reading RFID. Unable to start drying. Please try again later.","1803_C06B":"AMS-HT D is changing filament. Unable to start drying. Please try again later.","1803_C06C":"AMS-HT D is in Feed Assist Mode. Unable to start drying. Please try again later.","1803_C06D":"AMS-HT D is assisting in filament insertion. Unable to start drying. Please try again later.","1803_C06E":"AMS-HT D motor is performing self-test. Unable to start drying. Please try again later.","1804_4025":"Failed to read the filament information.","1804_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1804_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1804_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1804_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1804_8007":"Extruding filament failed. The extruder might be clogged.","1804_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT E to the extruder is properly connected.","1804_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1804_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1804_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1804_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1804_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1804_8021":"AMS setup failed; please refer to the assistant.","1804_8023":"AMS-HT E cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1804_C069":"An error occurred during AMS-HT E drying. Please go to Assistant for more details.","1804_C06A":"AMS-HT E is reading RFID. Unable to start drying. Please try again later.","1804_C06B":"AMS-HT E is changing filament. Unable to start drying. Please try again later.","1804_C06C":"AMS-HT E is in Feed Assist Mode. Unable to start drying. Please try again later.","1804_C06D":"AMS-HT E is assisting in filament insertion. Unable to start drying. Please try again later.","1804_C06E":"AMS-HT E motor is performing self-test. Unable to start drying. Please try again later.","1805_4025":"Failed to read the filament information.","1805_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1805_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1805_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1805_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1805_8007":"Extruding filament failed. The extruder might be clogged.","1805_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT F to the extruder is properly connected.","1805_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1805_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1805_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1805_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1805_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1805_8021":"AMS setup failed; please refer to the assistant.","1805_8023":"AMS-HT F cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1805_C069":"An error occurred during AMS-HT F drying. Please go to Assistant for more details.","1805_C06A":"AMS-HT F is reading RFID. Unable to start drying. Please try again later.","1805_C06B":"AMS-HT F is changing filament. Unable to start drying. Please try again later.","1805_C06C":"AMS-HT F is in Feed Assist Mode. Unable to start drying. Please try again later.","1805_C06D":"AMS-HT F is assisting in filament insertion. Unable to start drying. Please try again later.","1805_C06E":"AMS-HT F motor is performing self-test. Unable to start drying. Please try again later.","1806_4025":"Failed to read the filament information.","1806_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1806_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1806_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1806_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1806_8007":"Extruding filament failed. The extruder might be clogged.","1806_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT G to the extruder is properly connected.","1806_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1806_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1806_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1806_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1806_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1806_8021":"AMS setup failed; please refer to the assistant.","1806_8023":"AMS-HT G cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1806_C069":"An error occurred during AMS-HT G drying. Please go to Assistant for more details.","1806_C06A":"AMS-HT G is reading RFID. Unable to start drying. Please try again later.","1806_C06B":"AMS-HT G is changing filament. Unable to start drying. Please try again later.","1806_C06C":"AMS-HT G is in Feed Assist Mode. Unable to start drying. Please try again later.","1806_C06D":"AMS-HT G is assisting in filament insertion. Unable to start drying. Please try again later.","1806_C06E":"AMS-HT G motor is performing self-test. Unable to start drying. Please try again later.","1807_4025":"Failed to read the filament information.","1807_8003":"Failed to pull out the filament from the extruder. This might be caused by clogged extruder or filament broken inside the extruder.","1807_8004":"AMS-HT failed to pull back filament. This could be due to a stuck spool or the end of the filament being stuck in the path.","1807_8005":"The AMS-HT failed to send out filament. You can clip the end of your filament flat, and reinsert. If this message persists, please check the PTFE tubes in AMS for any signs of wear and tear.","1807_8006":"Unable to feed filament into the extruder. The AMS may be mismatched with the extruder. You can rerun the AMS Setup. This could also be due to an entangled filament or a stuck spool. If not, please...","1807_8007":"Extruding filament failed. The extruder might be clogged.","1807_800A":"PTFE tube disconnection detected. Please check if the PTFE tube from AMS-HT H to the extruder is properly connected.","1807_8010":"The AMS-HT assist motor is overloaded. This could be due to entangled filament or a stuck spool.","1807_8011":"AMS-HT filament ran out. Please insert a new filament into the same AMS-HT slot.","1807_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","1807_8013":"Timeout purging old filament: Please check if the filament is stuck or the extruder is clogged.","1807_8016":"The extruder is not extruding normally; please refer to the Assistant. After trouble shooting. If the defects are acceptable, please resume.","1807_8021":"AMS setup failed; please refer to the assistant.","1807_8023":"AMS-HT H cooling failed. The ambient temperature may be too high. Please operate the device in a suitable environment.","1807_C069":"An error occurred during AMS-HT H drying. Please go to Assistant for more details.","1807_C06A":"AMS-HT H is reading RFID. Unable to start drying. Please try again later.","1807_C06B":"AMS-HT H is changing filament. Unable to start drying. Please try again later.","1807_C06C":"AMS-HT H is in Feed Assist Mode. Unable to start drying. Please try again later.","1807_C06D":"AMS-HT H is assisting in filament insertion. Unable to start drying. Please try again later.","1807_C06E":"AMS-HT H motor is performing self-test. Unable to start drying. Please try again later.","18FE_8001":"Failed to cut the filament of the left extruder. Please check the cutter.","18FE_8002":"The cutter of the left extruder is stuck. Please pull out the cutter handle.","18FE_8003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are ab...","18FE_8004":"Failed to pull back the filament from the left extruder. Please check whether the filament is stuck inside the extruder.","18FE_8005":"Failed to feed the filament outside the AMS-HT. Please clip the end of the filament flat and check to see if the spool is stuck.","18FE_8006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_8007":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","18FE_8011":"The external filament connected to the left extruder has run out; please load a new filament.","18FE_8012":"Failed to get mapping table; please select 'Resume' to retry.","18FE_8013":"Timeout purging old filament of the left extruder: Please check if the filament is stuck or the extruder is clogged.","18FE_8020":"Extruder change failed; please refer to the assistant.","18FE_8021":"AMS setup failed; please refer to the assistant.","18FE_8024":"Extruder position calibration failed; please refer to the assistant.","18FE_C003":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","18FE_C006":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_C008":"Please pull out the filament on the spool holder of the left extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube i...","18FE_C009":"Please feed filament into the PTFE tube of the left extruder until it can not be pushed any farther.","18FE_C00A":"Please observe the nozzle of the left extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'.","18FF_8001":"Failed to cut the filament of the right extruder. Please check the cutter.","18FF_8002":"The cutter of the right extruder is stuck. Please pull out the cutter handle.","18FF_8003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder. (Connect a PTFE tube if you are a...","18FF_8004":"Failed to pull back the filament from the right extruder. Please check whether the filament is stuck inside the extruder.","18FF_8005":"Failed to feed the filament outside the AMS-HT. Please clip the end of the filament flat and check to see if the spool is stuck.","18FF_8006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_8007":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if it has not, please push the filament forward slightly, and then select 'Retry'.","18FF_8011":"The external filament connected to the right extruder has run out; please load a new filament.","18FF_8012":"Failed to get AMS mapping table; please select 'Resume' to retry.","18FF_8013":"Timeout purging old filament of the right extruder: Please check if the filament is stuck or the extruder is clogged.","18FF_8020":"Extruder change failed; please refer to the assistant.","18FF_8021":"AMS setup failed; please refer to the assistant.","18FF_8024":"Extruder position calibration failed; please refer to the assistant.","18FF_C003":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","18FF_C006":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_C008":"Please pull out the filament on the spool holder of the right extruder. If this message persists, please check to see if there is filament broken in the extruder or PTFE tube. (Connect a PTFE tube ...","18FF_C009":"Please feed filament into the PTFE tube of the right extruder until it can not be pushed any farther.","18FF_C00A":"Please observe the nozzle of the right extruder. If the filament has been extruded, select 'Continue'; if not, please push the filament forward slightly and then select 'Retry'."};function e2e(t){switch(t){case 1:return{label:"Fatal",color:"text-red-500",bgColor:"bg-red-500/20",Icon:Sn};case 2:return{label:"Serious",color:"text-red-400",bgColor:"bg-red-500/15",Icon:Sn};case 3:return{label:"Warning",color:"text-orange-400",bgColor:"bg-orange-500/20",Icon:Vi};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:nl}}}function M3(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 t2e(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=M3(e.attr,n);return N3[r]!==void 0})}function n2e(){return"https://wiki.bambulab.com/en/hms/home"}function r2e({printerName:t,errors:e,onClose:n}){const{t:r}=On();console.log("HMSErrorModal errors:",JSON.stringify(e,null,2));const i=e.filter(s=>{const o=parseInt(s.code.replace("0x",""),16)||0,l=M3(s.attr,o);return N3[l]!==void 0});return _.useEffect(()=>{const s=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[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(Sn,{className:"w-5 h-5 text-orange-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:r("hmsErrors.title",{name:t})})]}),a.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(Lt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:i.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(Vi,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{children:r("hmsErrors.noErrors")})]}):a.jsx("div",{className:"space-y-3",children:i.map((s,o)=>{const{label:l,color:c,bgColor:u,Icon:d}=e2e(s.severity),h=parseInt(s.code.replace("0x",""),16)||0,p=M3(s.attr,h),m=N3[p],x=n2e(),y=p.replace("_","-");return a.jsx("div",{className:`p-4 rounded-lg ${u} border border-white/10`,children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(d,{className:`w-5 h-5 ${c} 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 ${c}`,children:["[",y,"]"]}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${u} ${c}`,children:l})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:m}),a.jsxs("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[a.jsx(Xr,{className:"w-3 h-3"}),r("hmsErrors.viewOnWiki")]})]})]})},`${s.code}-${o}`)})})}),a.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:a.jsx("p",{className:"text-xs text-bambu-gray",children:r("hmsErrors.clearInstructions")})})]})})}function i2e(t){if(!t)return"ASAP";const e=zi(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 a2e({printerId:t}){const{data:e}=ct({queryKey:["queue",t,"pending"],queryFn:()=>oe.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:a.jsx(Fs,{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(ti,{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(tr,{className:"w-3 h-3"}),i2e(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(vs,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function mX(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=mX(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function nr(){for(var t,e,n=0,r="",i=arguments.length;n<i;n++)(t=arguments[n])&&(e=mX(t))&&(r&&(r+=" "),r+=e);return r}var s2e=["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 mO(t){if(typeof t!="string")return!1;var e=s2e;return e.includes(t)}var o2e=["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"],l2e=new Set(o2e);function pX(t){return typeof t!="string"?!1:l2e.has(t)}function gX(t){return typeof t=="string"&&t.startsWith("data-")}function ws(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(pX(n)||gX(n))&&(e[n]=t[n]);return e}function pm(t){if(t==null)return null;if(_.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return ws(e)}return typeof t=="object"&&!Array.isArray(t)?ws(t):null}function Ha(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(pX(n)||gX(n)||mO(n))&&(e[n]=t[n]);return e}function c2e(t){return t==null?null:_.isValidElement(t)?Ha(t.props):typeof t=="object"&&!Array.isArray(t)?Ha(t):null}var u2e=["children","width","height","viewBox","className","style","title","desc"];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 d2e(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 pO=_.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:s,className:o,style:l,title:c,desc:u}=t,d=d2e(t,u2e),h=s||{width:r,height:i,x:0,y:0},p=nr("recharts-surface",o);return _.createElement("svg",k3({},Ha(d),{className:p,width:r,height:i,style:l,viewBox:"".concat(h.x," ").concat(h.y," ").concat(h.width," ").concat(h.height),ref:e}),_.createElement("title",null,c),_.createElement("desc",null,u),n)}),f2e=["children","className"];function E3(){return E3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},E3.apply(null,arguments)}function m2e(t,e){if(t==null)return{};var n,r,i=p2e(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 p2e(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 li=_.forwardRef((t,e)=>{var{children:n,className:r}=t,i=m2e(t,f2e),s=nr("recharts-layer",r);return _.createElement("g",E3({className:s},Ha(i),{ref:e}),n)}),xX=_.createContext(null),g2e=()=>_.useContext(xX);function Ir(t){return function(){return t}}const bX=Math.cos,uS=Math.sin,Vl=Math.sqrt,dS=Math.PI,jM=2*dS,T3=Math.PI,A3=2*T3,Sf=1e-6,x2e=A3-Sf;function yX(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function b2e(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return yX;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 y2e{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?yX:b2e(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,h=l-n,p=d*d+h*h;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(p>Sf)if(!(Math.abs(h*c-u*d)>Sf)||!s)this._append`L${this._x1=e},${this._y1=n}`;else{let m=r-o,x=i-l,y=c*c+u*u,v=m*m+x*x,b=Math.sqrt(y),S=Math.sqrt(p),N=s*Math.tan((T3-Math.acos((y+p-v)/(2*b*S)))/2),T=N/S,k=N/b;Math.abs(T-1)>Sf&&this._append`L${e+T*d},${n+T*h}`,this._append`A${s},${s},0,0,${+(h*m>d*x)},${this._x1=e+k*c},${this._y1=n+k*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,h=1^o,p=o?i-s:s-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>Sf||Math.abs(this._y1-d)>Sf)&&this._append`L${u},${d}`,r&&(p<0&&(p=p%A3+A3),p>x2e?this._append`A${r},${r},0,1,${h},${e-l},${n-c}A${r},${r},0,1,${h},${this._x1=u},${this._y1=d}`:p>Sf&&this._append`A${r},${r},0,${+(p>=T3)},${h},${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 gO(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 y2e(e)}function xO(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function vX(t){this._context=t}vX.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 PM(t){return new vX(t)}function wX(t){return t[0]}function _X(t){return t[1]}function SX(t,e){var n=Ir(!0),r=null,i=PM,s=null,o=gO(l);t=typeof t=="function"?t:t===void 0?wX:Ir(t),e=typeof e=="function"?e:e===void 0?_X:Ir(e);function l(c){var u,d=(c=xO(c)).length,h,p=!1,m;for(r==null&&(s=i(m=o())),u=0;u<=d;++u)!(u<d&&n(h=c[u],u,c))===p&&((p=!p)?s.lineStart():s.lineEnd()),p&&s.point(+t(h,u,c),+e(h,u,c));if(m)return s=null,m+""||null}return l.x=function(c){return arguments.length?(t=typeof c=="function"?c:Ir(+c),l):t},l.y=function(c){return arguments.length?(e=typeof c=="function"?c:Ir(+c),l):e},l.defined=function(c){return arguments.length?(n=typeof c=="function"?c:Ir(!!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 L_(t,e,n){var r=null,i=Ir(!0),s=null,o=PM,l=null,c=gO(u);t=typeof t=="function"?t:t===void 0?wX:Ir(+t),e=typeof e=="function"?e:Ir(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?_X:Ir(+n);function u(h){var p,m,x,y=(h=xO(h)).length,v,b=!1,S,N=new Array(y),T=new Array(y);for(s==null&&(l=o(S=c())),p=0;p<=y;++p){if(!(p<y&&i(v=h[p],p,h))===b)if(b=!b)m=p,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=p-1;x>=m;--x)l.point(N[x],T[x]);l.lineEnd(),l.areaEnd()}b&&(N[p]=+t(v,p,h),T[p]=+e(v,p,h),l.point(r?+r(v,p,h):N[p],n?+n(v,p,h):T[p]))}if(S)return l=null,S+""||null}function d(){return SX().defined(i).curve(o).context(s)}return u.x=function(h){return arguments.length?(t=typeof h=="function"?h:Ir(+h),r=null,u):t},u.x0=function(h){return arguments.length?(t=typeof h=="function"?h:Ir(+h),u):t},u.x1=function(h){return arguments.length?(r=h==null?null:typeof h=="function"?h:Ir(+h),u):r},u.y=function(h){return arguments.length?(e=typeof h=="function"?h:Ir(+h),n=null,u):e},u.y0=function(h){return arguments.length?(e=typeof h=="function"?h:Ir(+h),u):e},u.y1=function(h){return arguments.length?(n=h==null?null:typeof h=="function"?h:Ir(+h),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(h){return arguments.length?(i=typeof h=="function"?h:Ir(!!h),u):i},u.curve=function(h){return arguments.length?(o=h,s!=null&&(l=o(s)),u):o},u.context=function(h){return arguments.length?(h==null?s=l=null:l=o(s=h),u):s},u}class NX{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 v2e(t){return new NX(t,!0)}function w2e(t){return new NX(t,!1)}const bO={draw(t,e){const n=Vl(e/dS);t.moveTo(n,0),t.arc(0,0,n,0,jM)}},_2e={draw(t,e){const n=Vl(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()}},MX=Vl(1/3),S2e=MX*2,N2e={draw(t,e){const n=Vl(e/S2e),r=n*MX;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},M2e={draw(t,e){const n=Vl(e),r=-n/2;t.rect(r,r,n,n)}},k2e=.8908130915292852,kX=uS(dS/10)/uS(7*dS/10),E2e=uS(jM/10)*kX,T2e=-bX(jM/10)*kX,A2e={draw(t,e){const n=Vl(e*k2e),r=E2e*n,i=T2e*n;t.moveTo(0,-n),t.lineTo(r,i);for(let s=1;s<5;++s){const o=jM*s/5,l=bX(o),c=uS(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},kA=Vl(3),C2e={draw(t,e){const n=-Vl(e/(kA*3));t.moveTo(0,n*2),t.lineTo(-kA*n,-n),t.lineTo(kA*n,-n),t.closePath()}},Bo=-.5,Ho=Vl(3)/2,C3=1/Vl(12),j2e=(C3/2+1)*3,P2e={draw(t,e){const n=Vl(e/j2e),r=n/2,i=n*C3,s=r,o=n*C3+n,l=-s,c=o;t.moveTo(r,i),t.lineTo(s,o),t.lineTo(l,c),t.lineTo(Bo*r-Ho*i,Ho*r+Bo*i),t.lineTo(Bo*s-Ho*o,Ho*s+Bo*o),t.lineTo(Bo*l-Ho*c,Ho*l+Bo*c),t.lineTo(Bo*r+Ho*i,Bo*i-Ho*r),t.lineTo(Bo*s+Ho*o,Bo*o-Ho*s),t.lineTo(Bo*l+Ho*c,Bo*c-Ho*l),t.closePath()}};function D2e(t,e){let n=null,r=gO(i);t=typeof t=="function"?t:Ir(t||bO),e=typeof e=="function"?e:Ir(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:Ir(s),i):t},i.size=function(s){return arguments.length?(e=typeof s=="function"?s:Ir(+s),i):e},i.context=function(s){return arguments.length?(n=s??null,i):n},i}function hS(){}function fS(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 EX(t){this._context=t}EX.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:fS(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:fS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function R2e(t){return new EX(t)}function TX(t){this._context=t}TX.prototype={areaStart:hS,areaEnd:hS,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:fS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function O2e(t){return new TX(t)}function AX(t){this._context=t}AX.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:fS(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function L2e(t){return new AX(t)}function CX(t){this._context=t}CX.prototype={areaStart:hS,areaEnd:hS,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 F2e(t){return new CX(t)}function Q6(t){return t<0?-1:1}function Z6(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(Q6(s)+Q6(o))*Math.min(Math.abs(s),Math.abs(o),.5*Math.abs(l))||0}function J6(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function EA(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 mS(t){this._context=t}mS.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:EA(this,this._t0,J6(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,EA(this,J6(this,n=Z6(this,t,e)),n);break;default:EA(this,this._t0,n=Z6(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function jX(t){this._context=new PX(t)}(jX.prototype=Object.create(mS.prototype)).point=function(t,e){mS.prototype.point.call(this,e,t)};function PX(t){this._context=t}PX.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 I2e(t){return new mS(t)}function U2e(t){return new jX(t)}function DX(t){this._context=t}DX.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=eH(t),i=eH(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 eH(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 z2e(t){return new DX(t)}function DM(t,e){this._context=t,this._t=e}DM.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 B2e(t){return new DM(t,.5)}function H2e(t){return new DM(t,0)}function $2e(t){return new DM(t,1)}function ex(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 j3(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function V2e(t,e){return t[e]}function G2e(t){const e=[];return e.key=t,e}function q2e(){var t=Ir([]),e=j3,n=ex,r=V2e;function i(s){var o=Array.from(t.apply(this,arguments),G2e),l,c=o.length,u=-1,d;for(const h of s)for(l=0,++u;l<c;++l)(o[l][u]=[0,+r(h,o[l].key,u,s)]).data=h;for(l=0,d=xO(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:Ir(Array.from(s)),i):t},i.value=function(s){return arguments.length?(r=typeof s=="function"?s:Ir(+s),i):r},i.order=function(s){return arguments.length?(e=s==null?j3:typeof s=="function"?s:Ir(Array.from(s)),i):e},i.offset=function(s){return arguments.length?(n=s??ex,i):n},i}function W2e(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}ex(t,e)}}function K2e(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}ex(t,e)}}function X2e(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]],h=d[r][1]||0,p=d[r-1][1]||0,m=(h-p)/2,x=0;x<l;++x){var y=t[e[x]],v=y[r][1]||0,b=y[r-1][1]||0;m+=v-b}c+=h,u+=m*h}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,ex(t,e)}}var TA={},AA={},tH;function Y2e(){return tH||(tH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(AA)),AA}var CA={},nH;function RX(){return nH||(nH=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})(CA)),CA}var jA={},rH;function yO(){return rH||(rH=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})(jA)),jA}var PA={},DA={},iH;function Q2e(){return iH||(iH=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})(DA)),DA}var aH;function vO(){return aH||(aH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Q2e(),n=yO();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 h=i[l];u?h==="\\"&&l+1<o?(l++,c+=i[l]):h===u?u="":c+=h:d?h==='"'||h==="'"?u=h:h==="]"?(d=!1,s.push(c),c=""):c+=h:h==="["?(d=!0,c&&(s.push(c),c="")):h==="."?c&&(s.push(c),c=""):c+=h,l++}return c&&s.push(c),s}t.toPath=r})(PA)),PA}var sH;function wO(){return sH||(sH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Y2e(),n=RX(),r=yO(),i=vO();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 h=0;h<c.length;h++){if(d==null||e.isUnsafeProperty(c[h]))return u;d=d[c[h]]}return d===void 0?u:d}t.get=s})(TA)),TA}var RA,oH;function Z2e(){return oH||(oH=1,RA=wO().get),RA}var J2e=Z2e();const gm=pl(J2e);var _a=t=>t===0?0:t>0?1:-1,qs=t=>typeof t=="number"&&t!=+t,Uu=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,Bt=t=>(typeof t=="number"||t instanceof Number)&&!qs(t),hl=t=>Bt(t)||typeof t=="string",eke=0,sy=t=>{var e=++eke;return"".concat(t||"").concat(e)},ts=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(!Bt(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 qs(s)&&(s=r),i&&n!=null&&s>n&&(s=n),s},OX=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 mr(t,e,n){return Bt(t)&&Bt(e)?t+n*(e-t):e}function LX(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):gm(r,e))===n)}var Yr=t=>t===null||typeof t>"u",Vy=t=>Yr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function tke(t){return t!=null}function Gy(){}var nke=["type","size","sizeType"];function P3(){return P3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},P3.apply(null,arguments)}function lH(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 cH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?lH(Object(n),!0).forEach(function(r){rke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):lH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function rke(t,e,n){return(e=ike(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ike(t){var e=ake(t,"string");return typeof e=="symbol"?e:e+""}function ake(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ske(t,e){if(t==null)return{};var n,r,i=oke(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 oke(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 FX={symbolCircle:bO,symbolCross:_2e,symbolDiamond:N2e,symbolSquare:M2e,symbolStar:A2e,symbolTriangle:C2e,symbolWye:P2e},lke=Math.PI/180,cke=t=>{var e="symbol".concat(Vy(t));return FX[e]||bO},uke=(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*lke;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}},dke=(t,e)=>{FX["symbol".concat(Vy(t))]=e},_O=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=ske(t,nke),s=cH(cH({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var p=cke(o),m=D2e().type(p).size(uke(n,r,o)),x=m();if(x!==null)return x},{className:c,cx:u,cy:d}=s,h=Ha(s);return Bt(u)&&Bt(d)&&Bt(n)?_.createElement("path",P3({},h,{className:nr("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};_O.registerSymbol=dke;var IX=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,SO=(t,e)=>{if(!t||typeof t=="function"||typeof t=="boolean")return null;var n=t;if(_.isValidElement(t)&&(n=t.props),typeof n!="object"&&typeof n!="function")return null;var r={};return Object.keys(n).forEach(i=>{mO(i)&&(r[i]=(s=>n[i](n,s)))}),r},hke=(t,e,n)=>r=>(t(e,n,r),null),qy=(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];mO(i)&&typeof s=="function"&&(r||(r={}),r[i]=hke(s,e,n))}),r};function uH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function fke(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?uH(Object(n),!0).forEach(function(r){mke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):uH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function mke(t,e,n){return(e=pke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pke(t){var e=gke(t,"string");return typeof e=="symbol"?e:e+""}function gke(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 ci(t,e){var n=fke({},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 pS(){return pS=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},pS.apply(null,arguments)}function dH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function xke(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?dH(Object(n),!0).forEach(function(r){bke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):dH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bke(t,e,n){return(e=yke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yke(t){var e=vke(t,"string");return typeof e=="symbol"?e:e+""}function vke(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Go=32,wke={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function _ke(t){var{data:e,iconType:n,inactiveColor:r}=t,i=Go/2,s=Go/6,o=Go/3,l=e.inactive?r:e.color,c=n??e.type;if(c==="none")return null;if(c==="plainline"){var u;return _.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:Go,y2:i,className:"recharts-legend-icon"})}if(c==="line")return _.createElement("path",{strokeWidth:4,fill:"none",stroke:l,d:"M0,".concat(i,"h").concat(o,`
  8062. A`).concat(s,",").concat(s,",0,1,1,").concat(2*o,",").concat(i,`
  8063. H`).concat(Go,"M").concat(2*o,",").concat(i,`
  8064. A`).concat(s,",").concat(s,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return _.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(Go/8,"h").concat(Go,"v").concat(Go*3/4,"h").concat(-Go,"z"),className:"recharts-legend-icon"});if(_.isValidElement(e.legendIcon)){var d=xke({},e);return delete d.legendIcon,_.cloneElement(e.legendIcon,d)}return _.createElement(_O,{fill:l,cx:i,cy:i,size:Go,sizeType:"diameter",type:c})}function Ske(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:s,iconType:o}=t,l={x:0,y:0,width:Go,height:Go},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,h)=>{var p=d.formatter||i,m=nr({"recharts-legend-item":!0,["legend-item-".concat(h)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?s:d.color,y=p?p(d.value,d,h):d.value;return _.createElement("li",pS({className:m,style:c,key:"legend-item-".concat(h)},qy(t,d,h)),_.createElement(pO,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(y," legend icon")},_.createElement(_ke,{data:d,iconType:o,inactiveColor:s})),_.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},y))})}var Nke=t=>{var e=ci(t,wke),{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 _.createElement("ul",{className:"recharts-default-legend",style:s},_.createElement(Ske,pS({},e,{payload:n})))},OA={},LA={},hH;function Mke(){return hH||(hH=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})(LA)),LA}var FA={},fH;function UX(){return fH||(fH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(FA)),FA}var IA={},UA={},zA={},mH;function kke(){return mH||(mH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(zA)),zA}var pH;function NO(){return pH||(pH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=kke();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(UA)),UA}var BA={},gH;function Eke(){return gH||(gH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(BA)),BA}var xH;function Tke(){return xH||(xH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=NO(),n=Eke();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(IA)),IA}var HA={},$A={},bH;function Ake(){return bH||(bH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=wO();function n(r){return function(i){return e.get(i,r)}}t.property=n})($A)),$A}var VA={},GA={},qA={},WA={},yH;function zX(){return yH||(yH=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})(WA)),WA}var KA={},vH;function BX(){return vH||(vH=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})(KA)),KA}var XA={},wH;function HX(){return wH||(wH=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})(XA)),XA}var _H;function Cke(){return _H||(_H=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=zX(),n=BX(),r=HX();function i(d,h,p){return typeof p!="function"?i(d,h,()=>{}):s(d,h,function m(x,y,v,b,S,N){const T=p(x,y,v,b,S,N);return T!==void 0?!!T:s(x,y,m,N)},new Map)}function s(d,h,p,m){if(h===d)return!0;switch(typeof h){case"object":return o(d,h,p,m);case"function":return Object.keys(h).length>0?s(d,{...h},p,m):r.eq(d,h);default:return e.isObject(d)?typeof h=="string"?h==="":!0:r.eq(d,h)}}function o(d,h,p,m){if(h==null)return!0;if(Array.isArray(h))return c(d,h,p,m);if(h instanceof Map)return l(d,h,p,m);if(h instanceof Set)return u(d,h,p,m);const x=Object.keys(h);if(d==null)return x.length===0;if(x.length===0)return!0;if(m?.has(h))return m.get(h)===d;m?.set(h,d);try{for(let y=0;y<x.length;y++){const v=x[y];if(!n.isPrimitive(d)&&!(v in d)||h[v]===void 0&&d[v]!==void 0||h[v]===null&&d[v]!==null||!p(d[v],h[v],v,d,h,m))return!1}return!0}finally{m?.delete(h)}}function l(d,h,p,m){if(h.size===0)return!0;if(!(d instanceof Map))return!1;for(const[x,y]of h.entries()){const v=d.get(x);if(p(v,y,x,d,h,m)===!1)return!1}return!0}function c(d,h,p,m){if(h.length===0)return!0;if(!Array.isArray(d))return!1;const x=new Set;for(let y=0;y<h.length;y++){const v=h[y];let b=!1;for(let S=0;S<d.length;S++){if(x.has(S))continue;const N=d[S];let T=!1;if(p(N,v,y,d,h,m)&&(T=!0),T){x.add(S),b=!0;break}}if(!b)return!1}return!0}function u(d,h,p,m){return h.size===0?!0:d instanceof Set?c([...d],[...h],p,m):!1}t.isMatchWith=i,t.isSetMatch=u})(qA)),qA}var SH;function $X(){return SH||(SH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Cke();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(GA)),GA}var YA={},QA={},ZA={},NH;function jke(){return NH||(NH=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})(ZA)),ZA}var JA={},MH;function VX(){return MH||(MH=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})(JA)),JA}var eC={},kH;function GX(){return kH||(kH=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]",h="[object Function]",p="[object ArrayBuffer]",m="[object Object]",x="[object Error]",y="[object DataView]",v="[object Uint8Array]",b="[object Uint8ClampedArray]",S="[object Uint16Array]",N="[object Uint32Array]",T="[object BigUint64Array]",k="[object Int8Array]",C="[object Int16Array]",E="[object Int32Array]",P="[object BigInt64Array]",A="[object Float32Array]",D="[object Float64Array]";t.argumentsTag=s,t.arrayBufferTag=p,t.arrayTag=d,t.bigInt64ArrayTag=P,t.bigUint64ArrayTag=T,t.booleanTag=i,t.dataViewTag=y,t.dateTag=l,t.errorTag=x,t.float32ArrayTag=A,t.float64ArrayTag=D,t.functionTag=h,t.int16ArrayTag=C,t.int32ArrayTag=E,t.int8ArrayTag=k,t.mapTag=c,t.numberTag=r,t.objectTag=m,t.regexpTag=e,t.setTag=u,t.stringTag=n,t.symbolTag=o,t.uint16ArrayTag=S,t.uint32ArrayTag=N,t.uint8ArrayTag=v,t.uint8ClampedArrayTag=b})(eC)),eC}var tC={},EH;function Pke(){return EH||(EH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(tC)),tC}var TH;function qX(){return TH||(TH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=jke(),n=VX(),r=GX(),i=BX(),s=Pke();function o(d,h){return l(d,void 0,d,new Map,h)}function l(d,h,p,m=new Map,x=void 0){const y=x?.(d,h,p,m);if(y!==void 0)return y;if(i.isPrimitive(d))return d;if(m.has(d))return m.get(d);if(Array.isArray(d)){const v=new Array(d.length);m.set(d,v);for(let b=0;b<d.length;b++)v[b]=l(d[b],b,p,m,x);return Object.hasOwn(d,"index")&&(v.index=d.index),Object.hasOwn(d,"input")&&(v.input=d.input),v}if(d instanceof Date)return new Date(d.getTime());if(d instanceof RegExp){const v=new RegExp(d.source,d.flags);return v.lastIndex=d.lastIndex,v}if(d instanceof Map){const v=new Map;m.set(d,v);for(const[b,S]of d)v.set(b,l(S,b,p,m,x));return v}if(d instanceof Set){const v=new Set;m.set(d,v);for(const b of d)v.add(l(b,void 0,p,m,x));return v}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(s.isTypedArray(d)){const v=new(Object.getPrototypeOf(d)).constructor(d.length);m.set(d,v);for(let b=0;b<d.length;b++)v[b]=l(d[b],b,p,m,x);return v}if(d instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&d instanceof SharedArrayBuffer)return d.slice(0);if(d instanceof DataView){const v=new DataView(d.buffer.slice(0),d.byteOffset,d.byteLength);return m.set(d,v),c(v,d,p,m,x),v}if(typeof File<"u"&&d instanceof File){const v=new File([d],d.name,{type:d.type});return m.set(d,v),c(v,d,p,m,x),v}if(typeof Blob<"u"&&d instanceof Blob){const v=new Blob([d],{type:d.type});return m.set(d,v),c(v,d,p,m,x),v}if(d instanceof Error){const v=new d.constructor;return m.set(d,v),v.message=d.message,v.name=d.name,v.stack=d.stack,v.cause=d.cause,c(v,d,p,m,x),v}if(d instanceof Boolean){const v=new Boolean(d.valueOf());return m.set(d,v),c(v,d,p,m,x),v}if(d instanceof Number){const v=new Number(d.valueOf());return m.set(d,v),c(v,d,p,m,x),v}if(d instanceof String){const v=new String(d.valueOf());return m.set(d,v),c(v,d,p,m,x),v}if(typeof d=="object"&&u(d)){const v=Object.create(Object.getPrototypeOf(d));return m.set(d,v),c(v,d,p,m,x),v}return d}function c(d,h,p=d,m,x){const y=[...Object.keys(h),...e.getSymbols(h)];for(let v=0;v<y.length;v++){const b=y[v],S=Object.getOwnPropertyDescriptor(d,b);(S==null||S.writable)&&(d[b]=l(h[b],b,p,m,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})(QA)),QA}var AH;function Dke(){return AH||(AH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qX();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(YA)),YA}var CH;function Rke(){return CH||(CH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$X(),n=Dke();function r(i){return i=n.cloneDeep(i),s=>e.isMatch(s,i)}t.matches=r})(VA)),VA}var nC={},rC={},iC={},jH;function Oke(){return jH||(jH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qX(),n=GX();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 h=new i.constructor(i?.valueOf());return e.copyProperties(h,i),h}case n.argumentsTag:{const h={};return e.copyProperties(h,i),h.length=i.length,h[Symbol.iterator]=i[Symbol.iterator],h}default:return}})}t.cloneDeepWith=r})(iC)),iC}var PH;function Lke(){return PH||(PH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Oke();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(rC)),rC}var aC={},sC={},DH;function WX(){return DH||(DH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=/^(?:0|[1-9]\d*)$/;function n(r,i=Number.MAX_SAFE_INTEGER){switch(typeof r){case"number":return Number.isInteger(r)&&r>=0&&r<i;case"symbol":return!1;case"string":return e.test(r)}}t.isIndex=n})(sC)),sC}var oC={},RH;function Fke(){return RH||(RH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=VX();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(oC)),oC}var OH;function Ike(){return OH||(OH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=RX(),n=WX(),r=Fke(),i=vO();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 h=c[d];if((u==null||!Object.hasOwn(u,h))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(h)&&h<u.length))return!1;u=u[h]}return!0}t.has=s})(aC)),aC}var LH;function Uke(){return LH||(LH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$X(),n=yO(),r=Lke(),i=wO(),s=Ike();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})(nC)),nC}var FH;function zke(){return FH||(FH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=UX(),n=Ake(),r=Rke(),i=Uke();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})(HA)),HA}var IH;function Bke(){return IH||(IH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Mke(),n=UX(),r=Tke(),i=zke();function s(o,l=n.identity){return r.isArrayLikeObject(o)?e.uniqBy(Array.from(o),i.iteratee(l)):[]}t.uniqBy=s})(OA)),OA}var lC,UH;function Hke(){return UH||(UH=1,lC=Bke().uniqBy),lC}var $ke=Hke();const zH=pl($ke);function KX(t,e,n){return e===!0?zH(t,n):typeof e=="function"?zH(t,e):t}var cC={exports:{}},uC={};var BH;function Vke(){if(BH)return uC;BH=1;var t=xx(),e=Oq();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 uC.useSyncExternalStoreWithSelector=function(u,d,h,p,m){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 b(C){if(!S){if(S=!0,N=C,C=p(C),m!==void 0&&y.hasValue){var E=y.value;if(m(E,C))return T=E}return T=C}if(E=T,r(N,C))return E;var P=p(C);return m!==void 0&&m(E,P)?(N=C,E):(N=C,T=P)}var S=!1,N,T,k=h===void 0?null:h;return[function(){return b(d())},k===null?void 0:function(){return b(k())}]},[d,h,p,m]);var v=i(u,x[0],x[1]);return o(function(){y.hasValue=!0,y.value=v},[v]),c(v),v},uC}var HH;function Gke(){return HH||(HH=1,cC.exports=Vke()),cC.exports}var XX=Gke(),MO=_.createContext(null),qke=t=>t,Lr=()=>{var t=_.useContext(MO);return t?t.store.dispatch:qke},T1=()=>{},Wke=()=>T1,Kke=(t,e)=>t===e;function Ut(t){var e=_.useContext(MO);return XX.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:Wke,e?e.store.getState:T1,e?e.store.getState:T1,e?t:T1,Kke)}function Xke(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function Yke(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function Qke(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 $H=t=>Array.isArray(t)?t:[t];function Zke(t){const e=Array.isArray(t[0])?t[0]:t;return Qke(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function Jke(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var eEe=class{constructor(t){this.value=t}deref(){return this.value}},tEe=typeof WeakRef<"u"?WeakRef:eEe,nEe=0,VH=1;function F_(){return{s:nEe,v:void 0,o:null,p:null}}function YX(t,e={}){let n=F_();const{resultEqualityCheck:r}=e;let i,s=0;function o(){let l=n;const{length:c}=arguments;for(let h=0,p=c;h<p;h++){const m=arguments[h];if(typeof m=="function"||typeof m=="object"&&m!==null){let x=l.o;x===null&&(l.o=x=new WeakMap);const y=x.get(m);y===void 0?(l=F_(),x.set(m,l)):l=y}else{let x=l.p;x===null&&(l.p=x=new Map);const y=x.get(m);y===void 0?(l=F_(),x.set(m,l)):l=y}}const u=l;let d;if(l.s===VH)d=l.v;else if(d=t.apply(null,arguments),s++,r){const h=i?.deref?.()??i;h!=null&&r(h,d)&&(d=h,s!==0&&s--),i=typeof d=="object"&&d!==null||typeof d=="function"?new tEe(d):d}return u.s=VH,u.v=d,d}return o.clearCache=()=>{n=F_(),o.resetResultsCount()},o.resultsCount=()=>s,o.resetResultsCount=()=>{s=0},o}function rEe(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()),Xke(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:h,memoizeOptions:p=[],argsMemoize:m=YX,argsMemoizeOptions:x=[]}=d,y=$H(p),v=$H(x),b=Zke(i),S=h(function(){return s++,u.apply(null,arguments)},...y),N=m(function(){o++;const k=Jke(b,arguments);return l=S.apply(null,k),l},...v);return Object.assign(N,{resultFunc:u,memoizedResultFunc:S,dependencies:b,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>s,resetRecomputations:()=>{s=0},memoize:h,argsMemoize:m})};return Object.assign(r,{withTypes:()=>r}),r}var st=rEe(YX),iEe=Object.assign((t,e=st)=>{Yke(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:()=>iEe}),dC={},hC={},fC={},GH;function aEe(){return GH||(GH=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})(fC)),fC}var mC={},pC={},qH;function QX(){return qH||(qH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(pC)),pC}var WH;function sEe(){return WH||(WH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=QX(),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})(mC)),mC}var KH;function oEe(){return KH||(KH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=aEe(),n=sEe(),r=vO();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(m=>String(m));const u=(m,x)=>{let y=m;for(let v=0;v<x.length&&y!=null;++v)y=y[x[v]];return y},d=(m,x)=>x==null||m==null?x:typeof m=="object"&&"key"in m?Object.hasOwn(x,m.key)?x[m.key]:u(x,m.path):typeof m=="function"?m(x):Array.isArray(m)?u(x,m):typeof x=="object"?x[m]:x,h=o.map(m=>(Array.isArray(m)&&m.length===1&&(m=m[0]),m==null||typeof m=="function"||Array.isArray(m)||n.isKey(m)?m:{key:m,path:r.toPath(m)}));return s.map(m=>({original:m,criteria:h.map(x=>d(x,m))})).slice().sort((m,x)=>{for(let y=0;y<h.length;y++){const v=e.compareValues(m.criteria[y],x.criteria[y],l[y]);if(v!==0)return v}return 0}).map(m=>m.original)}t.orderBy=i})(hC)),hC}var gC={},XH;function lEe(){return XH||(XH=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})(gC)),gC}var xC={},YH;function ZX(){return YH||(YH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=WX(),n=NO(),r=zX(),i=HX();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})(xC)),xC}var QH;function cEe(){return QH||(QH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=oEe(),n=lEe(),r=ZX();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})(dC)),dC}var bC,ZH;function uEe(){return ZH||(ZH=1,bC=cEe().sortBy),bC}var dEe=uEe();const RM=pl(dEe);var JX=t=>t.legend.settings,hEe=t=>t.legend.size,fEe=t=>t.legend.payload,mEe=st([fEe,JX],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?RM(r,n):r});function pEe(){return Ut(mEe)}var I_=1;function eY(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],[e,n]=_.useState({height:0,left:0,top:0,width:0}),r=_.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)>I_||Math.abs(o.left-e.left)>I_||Math.abs(o.top-e.top)>I_||Math.abs(o.width-e.width)>I_)&&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 Ra(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 gEe=typeof Symbol=="function"&&Symbol.observable||"@@observable",JH=gEe,yC=()=>Math.random().toString(36).substring(7).split("").join("."),xEe={INIT:`@@redux/INIT${yC()}`,REPLACE:`@@redux/REPLACE${yC()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${yC()}`},gS=xEe;function kO(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 tY(t,e,n){if(typeof t!="function")throw new Error(Ra(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Ra(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Ra(1));return n(tY)(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((v,b)=>{o.set(b,v)}))}function d(){if(c)throw new Error(Ra(3));return i}function h(v){if(typeof v!="function")throw new Error(Ra(4));if(c)throw new Error(Ra(5));let b=!0;u();const S=l++;return o.set(S,v),function(){if(b){if(c)throw new Error(Ra(6));b=!1,u(),o.delete(S),s=null}}}function p(v){if(!kO(v))throw new Error(Ra(7));if(typeof v.type>"u")throw new Error(Ra(8));if(typeof v.type!="string")throw new Error(Ra(17));if(c)throw new Error(Ra(9));try{c=!0,i=r(i,v)}finally{c=!1}return(s=o).forEach(S=>{S()}),v}function m(v){if(typeof v!="function")throw new Error(Ra(10));r=v,p({type:gS.REPLACE})}function x(){const v=h;return{subscribe(b){if(typeof b!="object"||b===null)throw new Error(Ra(11));function S(){const T=b;T.next&&T.next(d())}return S(),{unsubscribe:v(S)}},[JH](){return this}}}return p({type:gS.INIT}),{dispatch:p,subscribe:h,getState:d,replaceReducer:m,[JH]:x}}function bEe(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:gS.INIT})>"u")throw new Error(Ra(12));if(typeof n(void 0,{type:gS.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Ra(13))})}function nY(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{bEe(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 h=r[d],p=n[h],m=o[h],x=p(m,l);if(typeof x>"u")throw l&&l.type,new Error(Ra(14));u[h]=x,c=c||x!==m}return c=c||r.length!==Object.keys(o).length,c?u:o}}function xS(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function yEe(...t){return e=>(n,r)=>{const i=e(n,r);let s=()=>{throw new Error(Ra(15))};const o={getState:i.getState,dispatch:(c,...u)=>s(c,...u)},l=t.map(c=>c(o));return s=xS(...l)(i.dispatch),{...i,dispatch:s}}}function rY(t){return kO(t)&&"type"in t&&typeof t.type=="string"}var iY=Symbol.for("immer-nothing"),e$=Symbol.for("immer-draftable"),_s=Symbol.for("immer-state");function jl(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var po=Object,tx=po.getPrototypeOf,bS="constructor",OM="prototype",D3="configurable",yS="enumerable",A1="writable",oy="value",zu=t=>!!t&&!!t[_s];function Bl(t){return t?aY(t)||LM(t)||!!t[e$]||!!t[bS]?.[e$]||FM(t)||IM(t):!1}var vEe=po[OM][bS].toString(),t$=new WeakMap;function aY(t){if(!t||!EO(t))return!1;const e=tx(t);if(e===null||e===po[OM])return!0;const n=po.hasOwnProperty.call(e,bS)&&e[bS];if(n===Object)return!0;if(!lg(n))return!1;let r=t$.get(n);return r===void 0&&(r=Function.toString.call(n),t$.set(n,r)),r===vEe}function Wy(t,e,n=!0){Ky(t)===0?(n?Reflect.ownKeys(t):po.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function Ky(t){const e=t[_s];return e?e.type_:LM(t)?1:FM(t)?2:IM(t)?3:0}var n$=(t,e,n=Ky(t))=>n===2?t.has(e):po[OM].hasOwnProperty.call(t,e),R3=(t,e,n=Ky(t))=>n===2?t.get(e):t[e],vS=(t,e,n,r=Ky(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function wEe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var LM=Array.isArray,FM=t=>t instanceof Map,IM=t=>t instanceof Set,EO=t=>typeof t=="object",lg=t=>typeof t=="function",vC=t=>typeof t=="boolean",mu=t=>t.copy_||t.base_,TO=t=>t.modified_?t.copy_:t.base_;function O3(t,e){if(FM(t))return new Map(t);if(IM(t))return new Set(t);if(LM(t))return Array[OM].slice.call(t);const n=aY(t);if(e===!0||e==="class_only"&&!n){const r=po.getOwnPropertyDescriptors(t);delete r[_s];let i=Reflect.ownKeys(r);for(let s=0;s<i.length;s++){const o=i[s],l=r[o];l[A1]===!1&&(l[A1]=!0,l[D3]=!0),(l.get||l.set)&&(r[o]={[D3]:!0,[A1]:!0,[yS]:l[yS],[oy]:t[o]})}return po.create(tx(t),r)}else{const r=tx(t);if(r!==null&&n)return{...t};const i=po.create(r);return po.assign(i,t)}}function AO(t,e=!1){return UM(t)||zu(t)||!Bl(t)||(Ky(t)>1&&po.defineProperties(t,{set:U_,add:U_,clear:U_,delete:U_}),po.freeze(t),e&&Wy(t,(n,r)=>{AO(r,!0)},!1)),t}function _Ee(){jl(2)}var U_={[oy]:_Ee};function UM(t){return t===null||!EO(t)?!0:po.isFrozen(t)}var wS="MapSet",L3="Patches",sY={};function nx(t){const e=sY[t];return e||jl(0,t),e}var SEe=t=>!!sY[t],ly,oY=()=>ly,NEe=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:SEe(wS)?nx(wS):void 0});function r$(t,e){e&&(t.patchPlugin_=nx(L3),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function F3(t){I3(t),t.drafts_.forEach(MEe),t.drafts_=null}function I3(t){t===ly&&(ly=t.parent_)}var i$=t=>ly=NEe(ly,t);function MEe(t){const e=t[_s];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function a$(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[_s].modified_&&(F3(e),jl(4)),Bl(t)&&(t=s$(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[_s].base_,t,e)}else t=s$(e,n);return kEe(e,t,!0),F3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==iY?t:void 0}function s$(t,e){if(UM(e))return e;const n=e[_s];if(!n)return CO(e,t.handledSet_,t);if(!zM(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);uY(n,t)}return n.copy_}function kEe(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&AO(e,n)}function lY(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var zM=(t,e)=>t.scope_===e,EEe=[];function cY(t,e,n,r){const i=mu(t),s=t.type_;if(r!==void 0&&R3(i,r,s)===e){vS(i,r,n,s);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;Wy(i,(c,u)=>{if(zu(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??EEe;for(const l of o)vS(i,l,n,s)}function TEe(t,e,n){t.callbacks_.push(function(i){const s=e;if(!s||!zM(s,i))return;i.mapSetPlugin_?.fixSetContents(s);const o=TO(s);cY(t,s.draft_??s,o,n),uY(s,i)})}function uY(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)}lY(t)}}function AEe(t,e,n){const{scope_:r}=t;if(zu(n)){const i=n[_s];zM(i,r)&&i.callbacks_.push(function(){C1(t);const o=TO(i);cY(t,n,o,e)})}else Bl(n)&&t.callbacks_.push(function(){const s=mu(t);R3(s,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&CO(R3(t.copy_,e,t.type_),r.handledSet_,r)})}function CO(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||zu(t)||e.has(t)||!Bl(t)||UM(t)||(e.add(t),Wy(t,(r,i)=>{if(zu(i)){const s=i[_s];if(zM(s,n)){const o=TO(s);vS(t,r,o,t.type_),lY(s)}}else Bl(i)&&CO(i,e,n)})),t}function CEe(t,e){const n=LM(t),r={type_:n?1:0,scope_:e?e.scope_:oY(),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=jO;n&&(i=[r],s=cy);const{revoke:o,proxy:l}=Proxy.revocable(i,s);return r.draft_=l,r.revoke_=o,[l,r]}var jO={get(t,e){if(e===_s)return t;const n=mu(t);if(!n$(n,e,t.type_))return jEe(t,n,e);const r=n[e];if(t.finalized_||!Bl(r))return r;if(r===wC(t.base_,e)){C1(t);const i=t.type_===1?+e:e,s=z3(t.scope_,r,t,i);return t.copy_[i]=s}return r},has(t,e){return e in mu(t)},ownKeys(t){return Reflect.ownKeys(mu(t))},set(t,e,n){const r=dY(mu(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=wC(mu(t),e),s=i?.[_s];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(wEe(n,i)&&(n!==void 0||n$(t.base_,e,t.type_)))return!0;C1(t),U3(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),AEe(t,e,n)),!0},deleteProperty(t,e){return C1(t),wC(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),U3(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=mu(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[A1]:!0,[D3]:t.type_!==1||e!=="length",[yS]:r[yS],[oy]:n[e]}},defineProperty(){jl(11)},getPrototypeOf(t){return tx(t.base_)},setPrototypeOf(){jl(12)}},cy={};Wy(jO,(t,e)=>{cy[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});cy.deleteProperty=function(t,e){return cy.set.call(this,t,e,void 0)};cy.set=function(t,e,n){return jO.set.call(this,t[0],e,n,t[0])};function wC(t,e){const n=t[_s];return(n?mu(n):t)[e]}function jEe(t,e,n){const r=dY(e,n);return r?oy in r?r[oy]:r.get?.call(t.draft_):void 0}function dY(t,e){if(!(e in t))return;let n=tx(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=tx(n)}}function U3(t){t.modified_||(t.modified_=!0,t.parent_&&U3(t.parent_))}function C1(t){t.copy_||(t.assigned_=new Map,t.copy_=O3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var PEe=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(lg(n)&&!lg(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,h=>r.call(this,h,...d))}}lg(r)||jl(6),i!==void 0&&!lg(i)&&jl(7);let s;if(Bl(n)){const o=i$(this),l=z3(o,n,void 0);let c=!0;try{s=r(l),c=!1}finally{c?F3(o):I3(o)}return r$(o,i),a$(s,o)}else if(!n||!EO(n)){if(s=r(n),s===void 0&&(s=n),s===iY&&(s=void 0),this.autoFreeze_&&AO(s,!0),i){const o=[],l=[];nx(L3).generateReplacementPatches_(n,s,{patches_:o,inversePatches_:l}),i(o,l)}return s}else jl(1,n)},this.produceWithPatches=(n,r)=>{if(lg(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]},vC(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),vC(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),vC(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Bl(e)||jl(8),zu(e)&&(e=Il(e));const n=i$(this),r=z3(n,e,void 0);return r[_s].isManual_=!0,I3(n),r}finishDraft(e,n){const r=e&&e[_s];(!r||!r.isManual_)&&jl(9);const{scope_:i}=r;return r$(i,n),a$(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=nx(L3).applyPatches_;return zu(e)?i(e,n):this.produce(e,s=>i(s,n))}};function z3(t,e,n,r){const[i,s]=FM(e)?nx(wS).proxyMap_(e,n):IM(e)?nx(wS).proxySet_(e,n):CEe(e,n);return(n?.scope_??oY()).drafts_.push(i),s.callbacks_=n?.callbacks_??[],s.key_=r,n&&r!==void 0?TEe(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 Il(t){return zu(t)||jl(10,t),hY(t)}function hY(t){if(!Bl(t)||UM(t))return t;const e=t[_s];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=O3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=O3(t,!0);return Wy(n,(i,s)=>{vS(n,i,hY(s))},r),e&&(e.finalized_=!1),n}var DEe=new PEe,fY=DEe.produce;function mY(t){return({dispatch:n,getState:r})=>i=>s=>typeof s=="function"?s(n,r,t):i(s)}var REe=mY(),OEe=mY,LEe=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?xS:xS.apply(null,arguments)};function fl(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(vo(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=>rY(r)&&r.type===t,n}var pY=class c0 extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,c0.prototype)}static get[Symbol.species](){return c0}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new c0(...e[0].concat(this)):new c0(...e.concat(this))}};function o$(t){return Bl(t)?fY(t,()=>{}):t}function z_(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function FEe(t){return typeof t=="boolean"}var IEe=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:s=!0}=e??{};let o=new pY;return n&&(FEe(n)?o.push(REe):o.push(OEe(n.extraArgument))),o},gY="RTK_autoBatch",Jr=()=>t=>({payload:t,meta:{[gY]:!0}}),l$=t=>e=>{setTimeout(e,t)},xY=(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:l$(10):t.type==="callback"?t.queueNotification:l$(t.timeout),u=()=>{o=!1,s&&(s=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const h=()=>i&&d(),p=r.subscribe(h);return l.add(d),()=>{p(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[gY],s=!i,s&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},UEe=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new pY(t);return r&&i.push(xY(typeof r=="object"?r:void 0)),i};function zEe(t){const e=IEe(),{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(kO(n))l=nY(n);else throw new Error(vo(1));let c;typeof r=="function"?c=r(e):c=e();let u=xS;i&&(u=LEe({trace:!1,...typeof i=="object"&&i}));const d=yEe(...c),h=UEe(d);let p=typeof o=="function"?o(h):h();const m=u(...p);return tY(l,s,m)}function bY(t){const e={},n=[];let r;const i={addCase(s,o){const l=typeof s=="string"?s:s.type;if(!l)throw new Error(vo(28));if(l in e)throw new Error(vo(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 BEe(t){return typeof t=="function"}function HEe(t,e){let[n,r,i]=bY(e),s;if(BEe(t))s=()=>o$(t());else{const l=o$(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,h)=>{if(h)if(zu(d)){const m=h(d,c);return m===void 0?d:m}else{if(Bl(d))return fY(d,p=>h(p,c));{const p=h(d,c);if(p===void 0){if(d===null)return d;throw Error("A case reducer on a non-draftable value must not return undefined")}return p}}return d},l)}return o.getInitialState=s,o}var $Ee="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",VEe=(t=21)=>{let e="",n=t;for(;n--;)e+=$Ee[Math.random()*64|0];return e},GEe=Symbol.for("rtk-slice-createasyncthunk");function qEe(t,e){return`${t}/${e}`}function WEe({creators:t}={}){const e=t?.asyncThunk?.[GEe];return function(r){const{name:i,reducerPath:s=i}=r;if(!i)throw new Error(vo(11));const o=(typeof r.reducers=="function"?r.reducers(XEe()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(N,T){const k=typeof N=="string"?N:N.type;if(!k)throw new Error(vo(12));if(k in c.sliceCaseReducersByType)throw new Error(vo(13));return c.sliceCaseReducersByType[k]=T,u},addMatcher(N,T){return c.sliceMatchers.push({matcher:N,reducer:T}),u},exposeAction(N,T){return c.actionCreators[N]=T,u},exposeCaseReducer(N,T){return c.sliceCaseReducersByName[N]=T,u}};l.forEach(N=>{const T=o[N],k={reducerName:N,type:qEe(i,N),createNotation:typeof r.reducers=="function"};QEe(T)?JEe(k,T,u,e):YEe(k,T,u)});function d(){const[N={},T=[],k=void 0]=typeof r.extraReducers=="function"?bY(r.extraReducers):[r.extraReducers],C={...N,...c.sliceCaseReducersByType};return HEe(r.initialState,E=>{for(let P in C)E.addCase(P,C[P]);for(let P of c.sliceMatchers)E.addMatcher(P.matcher,P.reducer);for(let P of T)E.addMatcher(P.matcher,P.reducer);k&&E.addDefaultCase(k)})}const h=N=>N,p=new Map,m=new WeakMap;let x;function y(N,T){return x||(x=d()),x(N,T)}function v(){return x||(x=d()),x.getInitialState()}function b(N,T=!1){function k(E){let P=E[N];return typeof P>"u"&&T&&(P=z_(m,k,v)),P}function C(E=h){const P=z_(p,T,()=>new WeakMap);return z_(P,E,()=>{const A={};for(const[D,I]of Object.entries(r.selectors??{}))A[D]=KEe(I,E,()=>z_(m,E,v),T);return A})}return{reducerPath:N,getSelectors:C,get selectors(){return C(k)},selectSlice:k}}const S={name:i,reducer:y,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:v,...b(s),injectInto(N,{reducerPath:T,...k}={}){const C=T??s;return N.inject({reducerPath:C,reducer:y},k),{...S,...b(C,!0)}}};return S}}function KEe(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 Ws=WEe();function XEe(){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 YEe({type:t,reducerName:e,createNotation:n},r,i){let s,o;if("reducer"in r){if(n&&!ZEe(r))throw new Error(vo(17));s=r.reducer,o=r.prepare}else s=r;i.addCase(t,s).exposeCaseReducer(e,s).exposeAction(e,o?fl(t,o):fl(t))}function QEe(t){return t._reducerDefinitionType==="asyncThunk"}function ZEe(t){return t._reducerDefinitionType==="reducerWithPrepare"}function JEe({type:t,reducerName:e},n,r,i){if(!i)throw new Error(vo(18));const{payloadCreator:s,fulfilled:o,pending:l,rejected:c,settled:u,options:d}=n,h=i(t,s,d);r.exposeAction(e,h),o&&r.addCase(h.fulfilled,o),l&&r.addCase(h.pending,l),c&&r.addCase(h.rejected,c),u&&r.addMatcher(h.settled,u),r.exposeCaseReducer(e,{fulfilled:o||B_,pending:l||B_,rejected:c||B_,settled:u||B_})}function B_(){}var eTe="task",yY="listener",vY="completed",PO="cancelled",tTe=`task-${PO}`,nTe=`task-${vY}`,B3=`${yY}-${PO}`,rTe=`${yY}-${vY}`,BM=class{constructor(t){this.code=t,this.message=`${eTe} ${PO} (reason: ${t})`}name="TaskAbortError";message},DO=(t,e)=>{if(typeof t!="function")throw new TypeError(vo(32))},_S=()=>{},wY=(t,e=_S)=>(t.catch(e),t),_Y=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),qf=(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))},Wf=t=>{if(t.aborted){const{reason:e}=t;throw new BM(e)}};function SY(t,e){let n=_S;return new Promise((r,i)=>{const s=()=>i(new BM(t.reason));if(t.aborted){s();return}n=_Y(t,s),e.finally(()=>n()).then(r,i)}).finally(()=>{n=_S})}var iTe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof BM?"cancelled":"rejected",error:n}}finally{e?.()}},SS=t=>e=>wY(SY(t,e).then(n=>(Wf(t),n))),NY=t=>{const e=SS(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:Dg}=Object,c$={},HM="listenerMiddleware",aTe=(t,e)=>{const n=r=>_Y(t,()=>qf(r,t.reason));return(r,i)=>{DO(r);const s=new AbortController;n(s);const o=iTe(async()=>{Wf(t),Wf(s.signal);const l=await r({pause:SS(s.signal),delay:NY(s.signal),signal:s.signal});return Wf(s.signal),l},()=>qf(s,nTe));return i?.autoJoin&&e.push(o.catch(_S)),{result:SS(t)(o),cancel(){qf(s,tTe)}}}},sTe=(t,e)=>{const n=async(r,i)=>{Wf(e);let s=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(h,p)=>{p.unsubscribe(),c([h,p.getState(),p.getOriginalState()])}});s=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await SY(e,Promise.race(l));return Wf(e),c}finally{s()}};return(r,i)=>wY(n(r,i))},MY=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:s}=t;if(e)i=fl(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(vo(21));return DO(s),{predicate:i,type:e,effect:s}},kY=Dg(t=>{const{type:e,predicate:n,effect:r}=MY(t);return{id:VEe(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(vo(22))}}},{withTypes:()=>kY}),u$=(t,e)=>{const{type:n,effect:r,predicate:i}=MY(e);return Array.from(t.values()).find(s=>(typeof n=="string"?s.type===n:s.predicate===i)&&s.effect===r)},H3=t=>{t.pending.forEach(e=>{qf(e,B3)})},oTe=(t,e)=>()=>{for(const n of e.keys())H3(n);t.clear()},d$=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},EY=Dg(fl(`${HM}/add`),{withTypes:()=>EY}),lTe=fl(`${HM}/removeAll`),TY=Dg(fl(`${HM}/remove`),{withTypes:()=>TY}),cTe=(...t)=>{console.error(`${HM}/error`,...t)},Xy=(t={})=>{const e=new Map,n=new Map,r=m=>{const x=n.get(m)??0;n.set(m,x+1)},i=m=>{const x=n.get(m)??1;x===1?n.delete(m):n.set(m,x-1)},{extra:s,onError:o=cTe}=t;DO(o);const l=m=>(m.unsubscribe=()=>e.delete(m.id),e.set(m.id,m),x=>{m.unsubscribe(),x?.cancelActive&&H3(m)}),c=m=>{const x=u$(e,m)??kY(m);return l(x)};Dg(c,{withTypes:()=>c});const u=m=>{const x=u$(e,m);return x&&(x.unsubscribe(),m.cancelActive&&H3(x)),!!x};Dg(u,{withTypes:()=>u});const d=async(m,x,y,v)=>{const b=new AbortController,S=sTe(c,b.signal),N=[];try{m.pending.add(b),r(m),await Promise.resolve(m.effect(x,Dg({},y,{getOriginalState:v,condition:(T,k)=>S(T,k).then(Boolean),take:S,delay:NY(b.signal),pause:SS(b.signal),extra:s,signal:b.signal,fork:aTe(b.signal,N),unsubscribe:m.unsubscribe,subscribe:()=>{e.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((T,k,C)=>{T!==b&&(qf(T,B3),C.delete(T))})},cancel:()=>{qf(b,B3),m.pending.delete(b)},throwIfCancelled:()=>{Wf(b.signal)}})))}catch(T){T instanceof BM||d$(o,T,{raisedBy:"effect"})}finally{await Promise.all(N),qf(b,rTe),i(m),m.pending.delete(b)}},h=oTe(e,n);return{middleware:m=>x=>y=>{if(!rY(y))return x(y);if(EY.match(y))return c(y.payload);if(lTe.match(y)){h();return}if(TY.match(y))return u(y.payload);let v=m.getState();const b=()=>{if(v===c$)throw new Error(vo(23));return v};let S;try{if(S=x(y),e.size>0){const N=m.getState(),T=Array.from(e.values());for(const k of T){let C=!1;try{C=k.predicate(y,N,v)}catch(E){C=!1,d$(o,E,{raisedBy:"predicate"})}C&&d(k,y,m,b)}}}finally{v=c$}return S},startListening:c,stopListening:u,clearListeners:h}};function vo(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 uTe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},AY=Ws({name:"chartLayout",initialState:uTe,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:dTe,setLayout:hTe,setChartSize:fTe,setScale:mTe}=AY.actions,pTe=AY.reducer;function CY(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function h$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function yg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?h$(Object(n),!0).forEach(function(r){gTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):h$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gTe(t,e,n){return(e=xTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function xTe(t){var e=bTe(t,"string");return typeof e=="symbol"?e:e+""}function bTe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function yr(t,e,n){return Yr(t)||Yr(e)?n:hl(e)?gm(t,e,n):typeof e=="function"?e(t):n}var yTe=(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"&&Bt(t[s]))return yg(yg({},t),{},{[s]:t[s]+(r||0)});if((l==="horizontal"||l==="vertical"&&s==="center")&&o!=="middle"&&Bt(t[o]))return yg(yg({},t),{},{[o]:t[o]+(i||0)})}return t},Ac=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",jY=(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},PY=(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:h,niceTicks:p,axisType:m}=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=m==="angleAxis"&&s&&s.length>=2?_a(s[0]-s[1])*2*y:y,h||p){var v=(h||p||[]).map((b,S)=>{var N=r?r.indexOf(b):b;return{coordinate:o(N)+y,value:b,offset:y,index:S}});return v.filter(b=>!qs(b.coordinate))}return c&&u?u.map((b,S)=>({coordinate:o(b)+y,value:b,index:S,offset:y})):o.ticks&&d!=null?o.ticks(d).map((b,S)=>({coordinate:o(b)+y,value:b,offset:y,index:S})):o.domain().map((b,S)=>({coordinate:o(b)+y,value:r?r[b]:b,index:S,offset:y}))},f$=1e-4,vTe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-f$,s=Math.max(r[0],r[1])+f$,o=t(e[0]),l=t(e[n-1]);(o<i||o>s||l<i||l>s)&&t.domain([e[0],e[n-1]])}},wTe=(t,e)=>{if(!e||e.length!==2||!Bt(e[0])||!Bt(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(!Bt(t[0])||t[0]<n)&&(i[0]=n),(!Bt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},_Te=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=qs(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])}},STe=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=qs(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)}},NTe={sign:_Te,expand:W2e,none:ex,silhouette:K2e,wiggle:X2e,positive:STe},MTe=(t,e,n)=>{var r=NTe[n],i=q2e().keys(e).value((s,o)=>Number(yr(s,o,0))).order(j3).offset(r);return i(t)};function DY(t){return t==null?void 0:String(t)}function NS(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:s,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Yr(i[e.dataKey])){var l=LX(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n[s]?n[s].coordinate+r/2:null}var c=yr(i,Yr(o)?e.dataKey:o);return Yr(c)?null:e.scale(c)}var m$=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=yr(s,e.dataKey,e.scale.domain()[o]);return Yr(l)?null:e.scale(l)-i/2+r},kTe=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]},ETe=t=>{var e=t.flat(2).filter(Bt);return[Math.min(...e),Math.max(...e)]},TTe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],ATe=(t,e,n)=>{if(t!=null)return TTe(Object.keys(t).reduce((r,i)=>{var s=t[i],{stackedData:o}=s,l=o.reduce((c,u)=>{var d=CY(u,e,n),h=ETe(d);return[Math.min(c[0],h[0]),Math.max(c[1],h[1])]},[1/0,-1/0]);return[Math.min(l[0],r[0]),Math.max(l[1],r[1])]},[1/0,-1/0]))},p$=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,g$=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,Eh=(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=RM(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 x$(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:s}=t;return yg(yg({},e),{},{dataKey:n,payload:r,value:i,name:s})}function Ih(t,e){if(t)return String(t);if(typeof e=="string")return e}var CTe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},jTe=(t,e)=>e==="centric"?t.angle:t.radius,Wu=t=>t.layout.width,Ku=t=>t.layout.height,PTe=t=>t.layout.scale,RY=t=>t.layout.margin,$M=st(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),VM=st(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),OY="data-recharts-item-index",LY="data-recharts-item-data-key",Yy=60;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 H_(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){DTe(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 DTe(t,e,n){return(e=RTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function RTe(t){var e=OTe(t,"string");return typeof e=="symbol"?e:e+""}function OTe(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 LTe=t=>t.brush.height;function FTe(t){var e=VM(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Yy;return n+i}return n},0)}function ITe(t){var e=VM(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Yy;return n+i}return n},0)}function UTe(t){var e=$M(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function zTe(t){var e=$M(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var aa=st([Wu,Ku,RY,LTe,FTe,ITe,UTe,zTe,JX,hEe],(t,e,n,r,i,s,o,l,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+s},h={top:(n.top||0)+o,bottom:(n.bottom||0)+l},p=H_(H_({},h),d),m=p.bottom;p.bottom+=r,p=yTe(p,c,u);var x=t-p.left-p.right,y=e-p.top-p.bottom;return H_(H_({brushBottom:m},p),{},{width:Math.max(x,0),height:Math.max(y,0)})}),BTe=st(aa,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),RO=st(Wu,Ku,(t,e)=>({x:0,y:0,width:t,height:e})),HTe=_.createContext(null),sa=()=>_.useContext(HTe)!=null,GM=t=>t.brush,qM=st([GM,aa,RY],(t,e,n)=>({height:t.height,x:Bt(t.x)?t.x:e.left,y:Bt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:Bt(t.width)?t.width:e.width})),_C={},SC={},NC={},y$;function $Te(){return y$||(y$=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)},h=()=>{u&&d(),y()};let p=null;const m=()=>{p!=null&&clearTimeout(p),p=setTimeout(()=>{p=null,h()},r)},x=()=>{p!==null&&(clearTimeout(p),p=null)},y=()=>{x(),o=void 0,l=null},v=()=>{d()},b=function(...S){if(i?.aborted)return;o=this,l=S;const N=p==null;m(),c&&N&&d()};return b.schedule=m,b.cancel=y,b.flush=v,i?.addEventListener("abort",y,{once:!0}),b}t.debounce=e})(NC)),NC}var v$;function VTe(){return v$||(v$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$Te();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,h=null;const p=e.debounce(function(...y){d=r.apply(this,y),h=null},i,{edges:u}),m=function(...y){return c!=null&&(h===null&&(h=Date.now()),Date.now()-h>=c)?(d=r.apply(this,y),h=Date.now(),p.cancel(),p.schedule(),d):(p.apply(this,y),d)},x=()=>(p.flush(),d);return m.cancel=p.cancel,m.flush=x,m}t.debounce=n})(SC)),SC}var w$;function GTe(){return w$||(w$=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=VTe();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})(_C)),_C}var MC,_$;function qTe(){return _$||(_$=1,MC=GTe().throttle),MC}var WTe=qTe();const KTe=pl(WTe);var MS=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++]))}},FY=(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}},XTe={width:0,height:0,overflow:"visible"},YTe={width:0,overflowX:"visible"},QTe={height:0,overflowY:"visible"},ZTe={},JTe=t=>{var{width:e,height:n}=t,r=Uu(e),i=Uu(n);return r&&i?XTe:r?YTe:i?QTe:ZTe};function eAe(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 vr(t){return Number.isFinite(t)}function vc(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function $3(){return $3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},$3.apply(null,arguments)}function 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 N$(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){tAe(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 tAe(t,e,n){return(e=nAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nAe(t){var e=rAe(t,"string");return typeof e=="symbol"?e:e+""}function rAe(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 IY=_.createContext({width:-1,height:-1});function iAe(t){return vc(t.width)&&vc(t.height)}function UY(t){var{children:e,width:n,height:r}=t,i=_.useMemo(()=>({width:n,height:r}),[n,r]);return iAe(i)?_.createElement(IY.Provider,{value:i},e):null}var OO=()=>_.useContext(IY),aAe=_.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:h,className:p,onResize:m,style:x={}}=t,y=_.useRef(null),v=_.useRef();v.current=m,_.useImperativeHandle(e,()=>y.current);var[b,S]=_.useState({containerWidth:r.width,containerHeight:r.height}),N=_.useCallback((P,A)=>{S(D=>{var I=Math.round(P),L=Math.round(A);return D.containerWidth===I&&D.containerHeight===L?D:{containerWidth:I,containerHeight:L}})},[]);_.useEffect(()=>{if(y.current==null||typeof ResizeObserver>"u")return Gy;var P=L=>{var U,{width:j,height:V}=L[0].contentRect;N(j,V),(U=v.current)===null||U===void 0||U.call(v,j,V)};d>0&&(P=KTe(P,d,{trailing:!0,leading:!1}));var A=new ResizeObserver(P),{width:D,height:I}=y.current.getBoundingClientRect();return N(D,I),A.observe(y.current),()=>{A.disconnect()}},[N,d]);var{containerWidth:T,containerHeight:k}=b;MS(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:C,calculatedHeight:E}=FY(T,k,{width:i,height:s,aspect:n,maxHeight:c});return MS(C!=null&&C>0||E!=null&&E>0,`The width(%s) and height(%s) of chart should be greater than 0,
  8065. please check the style of container, or the props width(%s) and height(%s),
  8066. or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
  8067. height and width.`,C,E,i,s,o,l,n),_.createElement("div",{id:h?"".concat(h):void 0,className:nr("recharts-responsive-container",p),style:N$(N$({},x),{},{width:i,height:s,minWidth:o,minHeight:l,maxHeight:c}),ref:y},_.createElement("div",{style:JTe({width:i,height:s})},_.createElement(UY,{width:C,height:E},u)))}),j1=_.forwardRef((t,e)=>{var n=OO();if(vc(n.width)&&vc(n.height))return t.children;var{width:r,height:i}=eAe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:s,calculatedHeight:o}=FY(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return Bt(s)&&Bt(o)?_.createElement(UY,{width:s,height:o},t.children):_.createElement(aAe,$3({},t,{width:r,height:i,ref:e}))});function zY(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 Qy=()=>{var t,e=sa(),n=Ut(BTe),r=Ut(qM),i=(t=Ut(GM))===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}},sAe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},BY=()=>{var t;return(t=Ut(aa))!==null&&t!==void 0?t:sAe},LO=()=>Ut(Wu),FO=()=>Ut(Ku),oAe=()=>Ut(t=>t.layout.margin),$n=t=>t.layout.layoutType,Cm=()=>Ut($n),lAe=()=>{var t=Cm();if(t==="horizontal"||t==="vertical")return t},cAe=()=>{var t=Cm();return t!==void 0},WM=t=>{var e=Lr(),n=sa(),{width:r,height:i}=t,s=OO(),o=r,l=i;return s&&(o=s.width>0?s.width:r,l=s.height>0?s.height:i),_.useEffect(()=>{!n&&vc(o)&&vc(l)&&e(fTe({width:o,height:l}))},[e,n,o,l]),null},HY=Symbol.for("immer-nothing"),M$=Symbol.for("immer-draftable"),Mo=Symbol.for("immer-state");function Pl(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var uy=Object.getPrototypeOf;function rx(t){return!!t&&!!t[Mo]}function xm(t){return t?$Y(t)||Array.isArray(t)||!!t[M$]||!!t.constructor?.[M$]||Zy(t)||XM(t):!1}var uAe=Object.prototype.constructor.toString(),k$=new WeakMap;function $Y(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=k$.get(n);return r===void 0&&(r=Function.toString.call(n),k$.set(n,r)),r===uAe}function kS(t,e,n=!0){KM(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 KM(t){const e=t[Mo];return e?e.type_:Array.isArray(t)?1:Zy(t)?2:XM(t)?3:0}function V3(t,e){return KM(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function VY(t,e,n){const r=KM(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function dAe(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Zy(t){return t instanceof Map}function XM(t){return t instanceof Set}function Nf(t){return t.copy_||t.base_}function G3(t,e){if(Zy(t))return new Map(t);if(XM(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=$Y(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[Mo];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(uy(t),r)}else{const r=uy(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function IO(t,e=!1){return YM(t)||rx(t)||!xm(t)||(KM(t)>1&&Object.defineProperties(t,{set:$_,add:$_,clear:$_,delete:$_}),Object.freeze(t),e&&Object.values(t).forEach(n=>IO(n,!0))),t}function hAe(){Pl(2)}var $_={value:hAe};function YM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var fAe={};function bm(t){const e=fAe[t];return e||Pl(0,t),e}var dy;function GY(){return dy}function mAe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function E$(t,e){e&&(bm("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function q3(t){W3(t),t.drafts_.forEach(pAe),t.drafts_=null}function W3(t){t===dy&&(dy=t.parent_)}function T$(t){return dy=mAe(dy,t)}function pAe(t){const e=t[Mo];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function A$(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[Mo].modified_&&(q3(e),Pl(4)),xm(t)&&(t=ES(e,t),e.parent_||TS(e,t)),e.patches_&&bm("Patches").generateReplacementPatches_(n[Mo].base_,t,e.patches_,e.inversePatches_)):t=ES(e,n,[]),q3(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==HY?t:void 0}function ES(t,e,n){if(YM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[Mo];if(!i)return kS(e,(s,o)=>C$(t,i,e,s,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return TS(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),kS(o,(c,u)=>C$(t,i,s,c,u,n,l),r),TS(t,s,!1),n&&t.patches_&&bm("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function C$(t,e,n,r,i,s,o){if(i==null||typeof i!="object"&&!o)return;const l=YM(i);if(!(l&&!o)){if(rx(i)){const c=s&&e&&e.type_!==3&&!V3(e.assigned_,r)?s.concat(r):void 0,u=ES(t,i,c);if(VY(n,r,u),rx(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(xm(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;ES(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Zy(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&TS(t,i)}}}function TS(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&IO(e,n)}function gAe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:GY(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,s=UO;n&&(i=[r],s=hy);const{revoke:o,proxy:l}=Proxy.revocable(i,s);return r.draft_=l,r.revoke_=o,l}var UO={get(t,e){if(e===Mo)return t;const n=Nf(t);if(!V3(n,e))return xAe(t,n,e);const r=n[e];return t.finalized_||!xm(r)?r:r===kC(t.base_,e)?(EC(t),t.copy_[e]=X3(r,t)):r},has(t,e){return e in Nf(t)},ownKeys(t){return Reflect.ownKeys(Nf(t))},set(t,e,n){const r=qY(Nf(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=kC(Nf(t),e),s=i?.[Mo];if(s&&s.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(dAe(n,i)&&(n!==void 0||V3(t.base_,e)))return!0;EC(t),K3(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 kC(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,EC(t),K3(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Nf(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Pl(11)},getPrototypeOf(t){return uy(t.base_)},setPrototypeOf(){Pl(12)}},hy={};kS(UO,(t,e)=>{hy[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});hy.deleteProperty=function(t,e){return hy.set.call(this,t,e,void 0)};hy.set=function(t,e,n){return UO.set.call(this,t[0],e,n,t[0])};function kC(t,e){const n=t[Mo];return(n?Nf(n):t)[e]}function xAe(t,e,n){const r=qY(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function qY(t,e){if(!(e in t))return;let n=uy(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=uy(n)}}function K3(t){t.modified_||(t.modified_=!0,t.parent_&&K3(t.parent_))}function EC(t){t.copy_||(t.copy_=G3(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var bAe=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"&&Pl(6),r!==void 0&&typeof r!="function"&&Pl(7);let i;if(xm(e)){const s=T$(this),o=X3(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?q3(s):W3(s)}return E$(s,r),A$(i,s)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===HY&&(i=void 0),this.autoFreeze_&&IO(i,!0),r){const s=[],o=[];bm("Patches").generateReplacementPatches_(e,i,s,o),r(s,o)}return i}else Pl(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){xm(t)||Pl(8),rx(t)&&(t=yAe(t));const e=T$(this),n=X3(t,void 0);return n[Mo].isManual_=!0,W3(e),n}finishDraft(t,e){const n=t&&t[Mo];(!n||!n.isManual_)&&Pl(9);const{scope_:r}=n;return E$(r,e),A$(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=bm("Patches").applyPatches_;return rx(t)?r(t,e):this.produce(t,i=>r(i,e))}};function X3(t,e){const n=Zy(t)?bm("MapSet").proxyMap_(t,e):XM(t)?bm("MapSet").proxySet_(t,e):gAe(t,e);return(e?e.scope_:GY()).drafts_.push(n),n}function yAe(t){return rx(t)||Pl(10,t),WY(t)}function WY(t){if(!xm(t)||YM(t))return t;const e=t[Mo];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=G3(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=G3(t,!0);return kS(n,(i,s)=>{VY(n,i,WY(s))},r),e&&(e.finalized_=!1),n}var vAe=new bAe;vAe.produce;var wAe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},KY=Ws({name:"legend",initialState:wAe,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:Jr()},replaceLegendPayload:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Il(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Jr()},removeLegendPayload:{reducer(t,e){var n=Il(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Jr()}}}),{setLegendSize:j$,setLegendSettings:_Ae,addLegendPayload:XY,replaceLegendPayload:YY,removeLegendPayload:QY}=KY.actions,SAe=KY.reducer,NAe=["contextPayload"];function Y3(){return Y3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Y3.apply(null,arguments)}function P$(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 ix(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P$(Object(n),!0).forEach(function(r){MAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function MAe(t,e,n){return(e=kAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kAe(t){var e=EAe(t,"string");return typeof e=="symbol"?e:e+""}function EAe(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 TAe(t,e){if(t==null)return{};var n,r,i=AAe(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 AAe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function CAe(t){return t.value}function jAe(t){var{contextPayload:e}=t,n=TAe(t,NAe),r=KX(e,t.payloadUniqBy,CAe),i=ix(ix({},n),{},{payload:r});return _.isValidElement(t.content)?_.cloneElement(t.content,i):typeof t.content=="function"?_.createElement(t.content,i):_.createElement(Nke,i)}function PAe(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}),ix(ix({},u),d)}function DAe(t){var e=Lr();return _.useEffect(()=>{e(_Ae(t))},[e,t]),null}function RAe(t){var e=Lr();return _.useEffect(()=>(e(j$(t)),()=>{e(j$({width:0,height:0}))}),[e,t]),null}function OAe(t,e,n,r){return t==="vertical"&&Bt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var LAe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function zO(t){var e=ci(t,LAe),n=pEe(),r=g2e(),i=oAe(),{width:s,height:o,wrapperStyle:l,portal:c}=e,[u,d]=eY([n]),h=LO(),p=FO();if(h==null||p==null)return null;var m=h-(i?.left||0)-(i?.right||0),x=OAe(e.layout,o,s,m),y=c?l:ix(ix({position:"absolute",width:x?.width||s||"auto",height:x?.height||o||"auto"},PAe(l,e,i,h,p,u)),l),v=c??r;if(v==null||n==null)return null;var b=_.createElement("div",{className:"recharts-legend-wrapper",style:y,ref:d},_.createElement(DAe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&_.createElement(RAe,{width:u.width,height:u.height}),_.createElement(jAe,Y3({},e,x,{margin:i,chartWidth:h,chartHeight:p,contextPayload:n})));return bu.createPortal(b,v)}zO.displayName="Legend";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 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 TC(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){FAe(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 FAe(t,e,n){return(e=IAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function IAe(t){var e=UAe(t,"string");return typeof e=="symbol"?e:e+""}function UAe(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 zAe(t){return Array.isArray(t)&&hl(t[0])&&hl(t[1])?t.join(" ~ "):t}var BAe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:s,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:h,accessibilityLayer:p=!1}=t,m=()=>{if(s&&s.length){var k={padding:0,margin:0},C=(l?RM(s,l):s).map((E,P)=>{if(E.type==="none")return null;var A=E.formatter||o||zAe,{value:D,name:I}=E,L=D,U=I;if(A){var j=A(D,I,E,P,s);if(Array.isArray(j))[L,U]=j;else if(j!=null)L=j;else return null}var V=TC({display:"block",paddingTop:4,paddingBottom:4,color:E.color||"#000"},r);return _.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(P),style:V},hl(U)?_.createElement("span",{className:"recharts-tooltip-item-name"},U):null,hl(U)?_.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,_.createElement("span",{className:"recharts-tooltip-item-value"},L),_.createElement("span",{className:"recharts-tooltip-item-unit"},E.unit||""))});return _.createElement("ul",{className:"recharts-tooltip-item-list",style:k},C)}return null},x=TC({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),y=TC({margin:0},i),v=!Yr(d),b=v?d:"",S=nr("recharts-default-tooltip",c),N=nr("recharts-tooltip-label",u);v&&h&&s!==void 0&&s!==null&&(b=h(d,s));var T=p?{role:"status","aria-live":"assertive"}:{};return _.createElement("div",Q3({className:S,style:x},T),_.createElement("p",{className:N,style:y},_.isValidElement(b)?b:"".concat(b)),m())},Wb="recharts-tooltip-wrapper",HAe={visibility:"hidden"};function $Ae(t){var{coordinate:e,translateX:n,translateY:r}=t;return nr(Wb,{["".concat(Wb,"-right")]:Bt(n)&&e&&Bt(e.x)&&n>=e.x,["".concat(Wb,"-left")]:Bt(n)&&e&&Bt(e.x)&&n<e.x,["".concat(Wb,"-bottom")]:Bt(r)&&e&&Bt(e.y)&&r>=e.y,["".concat(Wb,"-top")]:Bt(r)&&e&&Bt(e.y)&&r<e.y})}function R$(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:s,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(s&&Bt(s[r]))return s[r];var d=n[r]-l-(i>0?i:0),h=n[r]+i;if(e[r])return o[r]?d:h;var p=c[r];if(p==null)return 0;if(o[r]){var m=d,x=p;return m<x?Math.max(h,p):Math.max(d,p)}if(u==null)return 0;var y=h+l,v=p+u;return y>v?Math.max(d,p):Math.max(h,p)}function VAe(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 GAe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:s,tooltipBox:o,useTranslate3d:l,viewBox:c}=t,u,d,h;return o.height>0&&o.width>0&&n?(d=R$({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),h=R$({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:s,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=VAe({translateX:d,translateY:h,useTranslate3d:l})):u=HAe,{cssProperties:u,cssClasses:$Ae({translateX:d,translateY:h,coordinate:n})}}function O$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function V_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?O$(Object(n),!0).forEach(function(r){Z3(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):O$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Z3(t,e,n){return(e=qAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function qAe(t){var e=WAe(t,"string");return typeof e=="symbol"?e:e+""}function WAe(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 KAe extends _.PureComponent{constructor(){super(...arguments),Z3(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),Z3(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:h,useTranslate3d:p,viewBox:m,wrapperStyle:x,lastBoundingBox:y,innerRef:v,hasPortalFromProps:b}=this.props,{cssClasses:S,cssProperties:N}=GAe({allowEscapeViewBox:n,coordinate:o,offsetTopLeft:u,position:d,reverseDirection:h,tooltipBox:{height:y.height,width:y.width},useTranslate3d:p,viewBox:m}),T=b?{}:V_(V_({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},N),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),k=V_(V_({},T),{},{visibility:!this.state.dismissed&&e&&l?"visible":"hidden"},x);return _.createElement("div",{xmlns:"http://www.w3.org/1999/xhtml",tabIndex:-1,className:S,style:k,ref:v},s)}}var ZY=()=>{var t;return(t=Ut(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};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 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 F$(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){XAe(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 XAe(t,e,n){return(e=YAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YAe(t){var e=QAe(t,"string");return typeof e=="symbol"?e:e+""}function QAe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var I$={curveBasisClosed:O2e,curveBasisOpen:L2e,curveBasis:R2e,curveBumpX:v2e,curveBumpY:w2e,curveLinearClosed:F2e,curveLinear:PM,curveMonotoneX:I2e,curveMonotoneY:U2e,curveNatural:z2e,curveStep:B2e,curveStepAfter:$2e,curveStepBefore:H2e},AS=t=>vr(t.x)&&vr(t.y),U$=t=>t.base!=null&&AS(t.base)&&AS(t),Kb=t=>t.x,Xb=t=>t.y,ZAe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Vy(t));return(n==="curveMonotone"||n==="curveBump")&&e?I$["".concat(n).concat(e==="vertical"?"Y":"X")]:I$[n]||PM},JAe=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:s=!1}=t,o=ZAe(e,i),l=s?n.filter(AS):n,c;if(Array.isArray(r)){var u=n.map((m,x)=>F$(F$({},m),{},{base:r[x]}));i==="vertical"?c=L_().y(Xb).x1(Kb).x0(m=>m.base.x):c=L_().x(Kb).y1(Xb).y0(m=>m.base.y);var d=c.defined(U$).curve(o),h=s?u.filter(U$):u;return d(h)}i==="vertical"&&Bt(r)?c=L_().y(Xb).x1(Kb).x0(r):Bt(r)?c=L_().x(Kb).y1(Xb).y0(r):c=SX().x(Kb).y(Xb);var p=c.defined(AS).curve(o);return p(l)},Rg=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var s=n&&n.length?JAe(t):r;return _.createElement("path",J3({},ws(t),SO(t),{className:nr("recharts-curve",e),d:s===null?void 0:s,ref:i}))},eCe=["x","y","top","left","width","height","className"];function eD(){return eD=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},eD.apply(null,arguments)}function z$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function tCe(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){nCe(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 nCe(t,e,n){return(e=rCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rCe(t){var e=iCe(t,"string");return typeof e=="symbol"?e:e+""}function iCe(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 aCe(t,e){if(t==null)return{};var n,r,i=sCe(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 sCe(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 oCe=(t,e,n,r,i,s)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(s,",").concat(e,"h").concat(n),lCe=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:s=0,height:o=0,className:l}=t,c=aCe(t,eCe),u=tCe({x:e,y:n,top:r,left:i,width:s,height:o},c);return!Bt(e)||!Bt(n)||!Bt(s)||!Bt(o)||!Bt(r)||!Bt(i)?null:_.createElement("path",eD({},Ha(u),{className:nr("recharts-cross",l),d:oCe(e,n,s,o,r,i)}))};function cCe(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 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 H$(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){uCe(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 uCe(t,e,n){return(e=dCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function dCe(t){var e=hCe(t,"string");return typeof e=="symbol"?e:e+""}function hCe(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 fCe=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),JY=(t,e,n)=>t.map(r=>"".concat(fCe(r)," ").concat(e,"ms ").concat(n)).join(","),mCe=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),fy=(t,e)=>Object.keys(e).reduce((n,r)=>H$(H$({},n),{},{[r]:t(r,e[r])}),{});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 Qi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$$(Object(n),!0).forEach(function(r){pCe(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 pCe(t,e,n){return(e=gCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gCe(t){var e=xCe(t,"string");return typeof e=="symbol"?e:e+""}function xCe(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 CS=(t,e,n)=>t+(e-t)*n,tD=t=>{var{from:e,to:n}=t;return e!==n},eQ=(t,e,n)=>{var r=fy((i,s)=>{if(tD(s)){var[o,l]=t(s.from,s.to,s.velocity);return Qi(Qi({},s),{},{from:o,velocity:l})}return s},e);return n<1?fy((i,s)=>tD(s)?Qi(Qi({},s),{},{velocity:CS(s.velocity,r[i].velocity,n),from:CS(s.from,r[i].from,n)}):s,e):eQ(t,r,n-1)};function bCe(t,e,n,r,i,s){var o,l=r.reduce((p,m)=>Qi(Qi({},p),{},{[m]:{from:t[m],velocity:0,to:e[m]}}),{}),c=()=>fy((p,m)=>m.from,l),u=()=>!Object.values(l).filter(tD).length,d=null,h=p=>{o||(o=p);var m=p-o,x=m/n.dt;l=eQ(n,l,x),i(Qi(Qi(Qi({},t),e),c())),o=p,u()||(d=s.setTimeout(h))};return()=>(d=s.setTimeout(h),()=>{var p;(p=d)===null||p===void 0||p()})}function yCe(t,e,n,r,i,s,o){var l=null,c=i.reduce((h,p)=>Qi(Qi({},h),{},{[p]:[t[p],e[p]]}),{}),u,d=h=>{u||(u=h);var p=(h-u)/r,m=fy((y,v)=>CS(...v,n(p)),c);if(s(Qi(Qi(Qi({},t),e),m)),p<1)l=o.setTimeout(d);else{var x=fy((y,v)=>CS(...v,n(1)),c);s(Qi(Qi(Qi({},t),e),x))}};return()=>(l=o.setTimeout(d),()=>{var h;(h=l)===null||h===void 0||h()})}const vCe=(t,e,n,r,i,s)=>{var o=mCe(t,e);return n==null?()=>(i(Qi(Qi({},t),e)),()=>{}):n.isStepper===!0?bCe(t,e,n,o,i,s):yCe(t,e,n,r,o,i,s)};var jS=1e-4,tQ=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],nQ=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),V$=(t,e)=>n=>{var r=tQ(t,e);return nQ(r,n)},wCe=(t,e)=>n=>{var r=tQ(t,e),i=[...r.map((s,o)=>s*o).slice(1),0];return nQ(i,n)},_Ce=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]},SCe=(t,e,n,r)=>{var i=V$(t,n),s=V$(e,r),o=wCe(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,h=d,p=0;p<8;++p){var m=i(h)-d,x=o(h);if(Math.abs(m-d)<jS||x<jS)return s(h);h=l(h-m/x)}return s(h)};return c.isStepper=!1,c},G$=function(){return SCe(..._Ce(...arguments))},NCe=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,h=c+(u-d)*i/1e3,p=c*i/1e3+o;return Math.abs(p-l)<jS&&Math.abs(h)<jS?[l,0]:[p,h]};return s.isStepper=!0,s.dt=i,s},MCe=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return G$(t);case"spring":return NCe();default:if(t.split("(")[0]==="cubic-bezier")return G$(t)}return typeof t=="function"?t:null};function kCe(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 ECe{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 TCe(){return kCe(new ECe)}var ACe=_.createContext(TCe);function CCe(t,e){var n=_.useContext(ACe);return _.useMemo(()=>e??n(t),[t,e,n])}var jCe=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),kx={devToolsEnabled:!1,isSsr:jCe()},PCe={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},q$={t:0},AC={t:1};function Ex(t){var e=ci(t,PCe),{isActive:n,canBegin:r,duration:i,easing:s,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!kx.isSsr:n,h=CCe(e.animationId,e.animationManager),[p,m]=_.useState(d?q$:AC),x=_.useRef(null);return _.useEffect(()=>{d||m(AC)},[d]),_.useEffect(()=>{if(!d||!r)return Gy;var y=vCe(q$,AC,MCe(s),i,m,h.getTimeoutController()),v=()=>{x.current=y()};return h.start([c,o,v,i,l]),()=>{h.stop(),x.current&&x.current(),l()}},[d,r,i,s,o,c,l,h]),u(p.t)}function Tx(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=_.useRef(sy(e)),r=_.useRef(t);return r.current!==t&&(n.current=sy(e),r.current=t),n.current}var DCe=["radius"],RCe=["radius"];function W$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function K$(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?W$(Object(n),!0).forEach(function(r){OCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):W$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function OCe(t,e,n){return(e=LCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LCe(t){var e=FCe(t,"string");return typeof e=="symbol"?e:e+""}function FCe(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 PS(){return PS=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},PS.apply(null,arguments)}function X$(t,e){if(t==null)return{};var n,r,i=ICe(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 ICe(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 Y$=(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],h=0,p=4;h<p;h++)d[h]=i[h]>s?s:i[h];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,`,
  8068. `).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,`,
  8069. `).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,`,
  8070. `).concat(t,",").concat(e+r-o*d[3])),u+="Z"}else if(s>0&&i===+i&&i>0){var m=Math.min(s,i);u="M ".concat(t,",").concat(e+o*m,`
  8071. A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+l*m,",").concat(e,`
  8072. L `).concat(t+n-l*m,",").concat(e,`
  8073. A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+n,",").concat(e+o*m,`
  8074. L `).concat(t+n,",").concat(e+r-o*m,`
  8075. A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+n-l*m,",").concat(e+r,`
  8076. L `).concat(t+l*m,",").concat(e+r,`
  8077. A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t,",").concat(e+r-o*m," Z")}else u="M ".concat(t,",").concat(e," h ").concat(n," v ").concat(r," h ").concat(-n," Z");return u},Q$={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},rQ=t=>{var e=ci(t,Q$),n=_.useRef(null),[r,i]=_.useState(-1);_.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var z=n.current.getTotalLength();z&&i(z)}catch{}},[]);var{x:s,y:o,width:l,height:c,radius:u,className:d}=e,{animationEasing:h,animationDuration:p,animationBegin:m,isAnimationActive:x,isUpdateAnimationActive:y}=e,v=_.useRef(l),b=_.useRef(c),S=_.useRef(s),N=_.useRef(o),T=_.useMemo(()=>({x:s,y:o,width:l,height:c,radius:u}),[s,o,l,c,u]),k=Tx(T,"rectangle-");if(s!==+s||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var C=nr("recharts-rectangle",d);if(!y){var E=Ha(e),{radius:P}=E,A=X$(E,DCe);return _.createElement("path",PS({},A,{radius:typeof u=="number"?u:void 0,className:C,d:Y$(s,o,l,c,u)}))}var D=v.current,I=b.current,L=S.current,U=N.current,j="0px ".concat(r===-1?1:r,"px"),V="".concat(r,"px 0px"),K=JY(["strokeDasharray"],p,typeof h=="string"?h:Q$.animationEasing);return _.createElement(Ex,{animationId:k,key:k,canBegin:r>0,duration:p,easing:h,isActive:y,begin:m},z=>{var X=mr(D,l,z),Y=mr(I,c,z),te=mr(L,s,z),$=mr(U,o,z);n.current&&(v.current=X,b.current=Y,S.current=te,N.current=$);var W;x?z>0?W={transition:K,strokeDasharray:V}:W={strokeDasharray:j}:W={strokeDasharray:V};var ne=Ha(e),{radius:re}=ne,ge=X$(ne,RCe);return _.createElement("path",PS({},ge,{radius:typeof u=="number"?u:void 0,className:C,d:Y$(te,$,X,Y,u),ref:n,style:K$(K$({},W),e.style)}))})};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){UCe(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 UCe(t,e,n){return(e=zCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zCe(t){var e=BCe(t,"string");return typeof e=="symbol"?e:e+""}function BCe(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 DS=Math.PI/180,HCe=t=>t*180/Math.PI,Hi=(t,e,n,r)=>({x:t+Math.cos(-DS*r)*n,y:e+Math.sin(-DS*r)*n}),iQ=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},$Ce=(t,e)=>{var{x:n,y:r}=t,{x:i,y:s}=e;return Math.sqrt((n-i)**2+(r-s)**2)},VCe=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:s}=e,o=$Ce({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:HCe(c),angleInRadian:c}},GCe=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}},qCe=(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},WCe=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:s}=VCe({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=GCe(e),d=s,h;if(c<=u){for(;d>u;)d-=360;for(;d<c;)d+=360;h=d>=c&&d<=u}else{for(;d>c;)d-=360;for(;d<u;)d+=360;h=d>=u&&d<=c}return h?J$(J$({},e),{},{radius:i,angle:qCe(d,e)}):null};function aQ(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:s}=t,o=Hi(e,n,r,i),l=Hi(e,n,r,s);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:s}}function nD(){return nD=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},nD.apply(null,arguments)}var KCe=(t,e)=>{var n=_a(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)/DS,h=c?i:i+s*d,p=Hi(e,n,u,h),m=Hi(e,n,r,h),x=c?i-s*d:i,y=Hi(e,n,u*Math.cos(d*DS),x);return{center:p,circleTangency:m,lineTangency:y,theta:d}},sQ=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:s,endAngle:o}=t,l=KCe(s,o),c=s+l,u=Hi(e,n,i,s),d=Hi(e,n,i,c),h="M ".concat(u.x,",").concat(u.y,`
  8078. A `).concat(i,",").concat(i,`,0,
  8079. `).concat(+(Math.abs(l)>180),",").concat(+(s>c),`,
  8080. `).concat(d.x,",").concat(d.y,`
  8081. `);if(r>0){var p=Hi(e,n,r,s),m=Hi(e,n,r,c);h+="L ".concat(m.x,",").concat(m.y,`
  8082. A `).concat(r,",").concat(r,`,0,
  8083. `).concat(+(Math.abs(l)>180),",").concat(+(s<=c),`,
  8084. `).concat(p.x,",").concat(p.y," Z")}else h+="L ".concat(e,",").concat(n," Z");return h},XCe=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:s,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=_a(u-c),{circleTangency:h,lineTangency:p,theta:m}=G_({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:s,cornerIsExternal:l}),{circleTangency:x,lineTangency:y,theta:v}=G_({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:s,cornerIsExternal:l}),b=l?Math.abs(c-u):Math.abs(c-u)-m-v;if(b<0)return o?"M ".concat(p.x,",").concat(p.y,`
  8085. a`).concat(s,",").concat(s,",0,0,1,").concat(s*2,`,0
  8086. a`).concat(s,",").concat(s,",0,0,1,").concat(-s*2,`,0
  8087. `):sQ({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var S="M ".concat(p.x,",").concat(p.y,`
  8088. A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(h.x,",").concat(h.y,`
  8089. A`).concat(i,",").concat(i,",0,").concat(+(b>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
  8090. A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(y.x,",").concat(y.y,`
  8091. `);if(r>0){var{circleTangency:N,lineTangency:T,theta:k}=G_({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:s,cornerIsExternal:l}),{circleTangency:C,lineTangency:E,theta:P}=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)-k-P;if(A<0&&s===0)return"".concat(S,"L").concat(e,",").concat(n,"Z");S+="L".concat(E.x,",").concat(E.y,`
  8092. A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(C.x,",").concat(C.y,`
  8093. A`).concat(r,",").concat(r,",0,").concat(+(A>180),",").concat(+(d>0),",").concat(N.x,",").concat(N.y,`
  8094. A`).concat(s,",").concat(s,",0,0,").concat(+(d<0),",").concat(T.x,",").concat(T.y,"Z")}else S+="L".concat(e,",").concat(n,"Z");return S},YCe={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},oQ=t=>{var e=ci(t,YCe),{cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:o,forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d,className:h}=e;if(s<i||u===d)return null;var p=nr("recharts-sector",h),m=s-i,x=ts(o,m,0,!0),y;return x>0&&Math.abs(u-d)<360?y=XCe({cx:n,cy:r,innerRadius:i,outerRadius:s,cornerRadius:Math.min(x,m/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):y=sQ({cx:n,cy:r,innerRadius:i,outerRadius:s,startAngle:u,endAngle:d}),_.createElement("path",nD({},Ha(e),{className:p,d:y}))};function QCe(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(IX(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:s,outerRadius:o,angle:l}=e,c=Hi(r,i,s,l),u=Hi(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return aQ(e)}}var CC={},jC={},PC={},eV;function ZCe(){return eV||(eV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=QX();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(PC)),PC}var tV;function JCe(){return tV||(tV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ZCe();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})(jC)),jC}var nV;function eje(){return nV||(nV=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ZX(),n=JCe();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})(CC)),CC}var DC,rV;function tje(){return rV||(rV=1,DC=eje().range),DC}var nje=tje();const lQ=pl(nje);function fh(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function rje(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function BO(t){let e,n,r;t.length!==2?(e=fh,n=(l,c)=>fh(t(l),c),r=(l,c)=>t(l)-c):(e=t===fh||t===rje?t:ije,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 h=u+d>>>1;n(l[h],c)<0?u=h+1:d=h}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 h=u+d>>>1;n(l[h],c)<=0?u=h+1:d=h}while(u<d)}return u}function o(l,c,u=0,d=l.length){const h=i(l,c,u,d-1);return h>u&&r(l[h-1],c)>-r(l[h],c)?h-1:h}return{left:i,center:o,right:s}}function ije(){return 0}function cQ(t){return t===null?NaN:+t}function*aje(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const sje=BO(fh),Jy=sje.right;BO(cQ).center;class iV extends Map{constructor(e,n=cje){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(aV(this,e))}has(e){return super.has(aV(this,e))}set(e,n){return super.set(oje(this,e),n)}delete(e){return super.delete(lje(this,e))}}function aV({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function oje({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function lje({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function cje(t){return t!==null&&typeof t=="object"?t.valueOf():t}function uje(t=fh){if(t===fh)return uQ;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 uQ(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const dje=Math.sqrt(50),hje=Math.sqrt(10),fje=Math.sqrt(2);function RS(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>=dje?10:s>=hje?5:s>=fje?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?RS(t,e,n*2):[l,c,u]}function rD(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?RS(e,t,n):RS(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 iD(t,e,n){return e=+e,t=+t,n=+n,RS(t,e,n)[2]}function aD(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?iD(e,t,n):iD(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function sV(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function oV(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function dQ(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?uQ:uje(i);r>n;){if(r-n>600){const c=r-n+1,u=e-n+1,d=Math.log(c),h=.5*Math.exp(2*d/3),p=.5*Math.sqrt(d*h*(c-h)/c)*(u-c/2<0?-1:1),m=Math.max(n,Math.floor(e-u*h/c+p)),x=Math.min(r,Math.floor(e+(c-u)*h/c+p));dQ(t,e,m,x,i)}const s=t[e];let o=n,l=r;for(Yb(t,n,e),i(t[r],s)>0&&Yb(t,n,r);o<l;){for(Yb(t,o,l),++o,--l;i(t[o],s)<0;)++o;for(;i(t[l],s)>0;)--l}i(t[n],s)===0?Yb(t,n,l):(++l,Yb(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function Yb(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function mje(t,e,n){if(t=Float64Array.from(aje(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return oV(t);if(e>=1)return sV(t);var r,i=(r-1)*e,s=Math.floor(i),o=sV(dQ(t,s).subarray(0,s+1)),l=oV(t.subarray(s+1));return o+(l-o)*(i-s)}}function pje(t,e,n=cQ){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 gje(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 xl(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Xu(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 sD=Symbol("implicit");function HO(){var t=new iV,e=[],n=[],r=sD;function i(s){let o=t.get(s);if(o===void 0){if(r!==sD)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 iV;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 HO(e,n).unknown(r)},xl.apply(i,arguments),i}function $O(){var t=HO().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 h(){var p=e().length,m=i<r,x=m?i:r,y=m?r:i;s=(y-x)/Math.max(1,p-c+u*2),l&&(s=Math.floor(s)),x+=(y-x-s*(p-c))*d,o=s*(1-c),l&&(x=Math.round(x),o=Math.round(o));var v=gje(p).map(function(b){return x+s*b});return n(m?v.reverse():v)}return t.domain=function(p){return arguments.length?(e(p),h()):e()},t.range=function(p){return arguments.length?([r,i]=p,r=+r,i=+i,h()):[r,i]},t.rangeRound=function(p){return[r,i]=p,r=+r,i=+i,l=!0,h()},t.bandwidth=function(){return o},t.step=function(){return s},t.round=function(p){return arguments.length?(l=!!p,h()):l},t.padding=function(p){return arguments.length?(c=Math.min(1,u=+p),h()):c},t.paddingInner=function(p){return arguments.length?(c=Math.min(1,p),h()):c},t.paddingOuter=function(p){return arguments.length?(u=+p,h()):u},t.align=function(p){return arguments.length?(d=Math.max(0,Math.min(1,p)),h()):d},t.copy=function(){return $O(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},xl.apply(h(),arguments)}function hQ(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return hQ(e())},t}function xje(){return hQ($O.apply(null,arguments).paddingInner(1))}function VO(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function fQ(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function ev(){}var my=.7,OS=1/my,Og="\\s*([+-]?\\d+)\\s*",py="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",gc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",bje=/^#([0-9a-f]{3,8})$/,yje=new RegExp(`^rgb\\(${Og},${Og},${Og}\\)$`),vje=new RegExp(`^rgb\\(${gc},${gc},${gc}\\)$`),wje=new RegExp(`^rgba\\(${Og},${Og},${Og},${py}\\)$`),_je=new RegExp(`^rgba\\(${gc},${gc},${gc},${py}\\)$`),Sje=new RegExp(`^hsl\\(${py},${gc},${gc}\\)$`),Nje=new RegExp(`^hsla\\(${py},${gc},${gc},${py}\\)$`),lV={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};VO(ev,gy,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:cV,formatHex:cV,formatHex8:Mje,formatHsl:kje,formatRgb:uV,toString:uV});function cV(){return this.rgb().formatHex()}function Mje(){return this.rgb().formatHex8()}function kje(){return mQ(this).formatHsl()}function uV(){return this.rgb().formatRgb()}function gy(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=bje.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?dV(e):n===3?new zs(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?q_(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?q_(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=yje.exec(t))?new zs(e[1],e[2],e[3],1):(e=vje.exec(t))?new zs(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=wje.exec(t))?q_(e[1],e[2],e[3],e[4]):(e=_je.exec(t))?q_(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Sje.exec(t))?mV(e[1],e[2]/100,e[3]/100,1):(e=Nje.exec(t))?mV(e[1],e[2]/100,e[3]/100,e[4]):lV.hasOwnProperty(t)?dV(lV[t]):t==="transparent"?new zs(NaN,NaN,NaN,0):null}function dV(t){return new zs(t>>16&255,t>>8&255,t&255,1)}function q_(t,e,n,r){return r<=0&&(t=e=n=NaN),new zs(t,e,n,r)}function Eje(t){return t instanceof ev||(t=gy(t)),t?(t=t.rgb(),new zs(t.r,t.g,t.b,t.opacity)):new zs}function oD(t,e,n,r){return arguments.length===1?Eje(t):new zs(t,e,n,r??1)}function zs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}VO(zs,oD,fQ(ev,{brighter(t){return t=t==null?OS:Math.pow(OS,t),new zs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?my:Math.pow(my,t),new zs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new zs(Kf(this.r),Kf(this.g),Kf(this.b),LS(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:hV,formatHex:hV,formatHex8:Tje,formatRgb:fV,toString:fV}));function hV(){return`#${Of(this.r)}${Of(this.g)}${Of(this.b)}`}function Tje(){return`#${Of(this.r)}${Of(this.g)}${Of(this.b)}${Of((isNaN(this.opacity)?1:this.opacity)*255)}`}function fV(){const t=LS(this.opacity);return`${t===1?"rgb(":"rgba("}${Kf(this.r)}, ${Kf(this.g)}, ${Kf(this.b)}${t===1?")":`, ${t})`}`}function LS(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Kf(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Of(t){return t=Kf(t),(t<16?"0":"")+t.toString(16)}function mV(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Dl(t,e,n,r)}function mQ(t){if(t instanceof Dl)return new Dl(t.h,t.s,t.l,t.opacity);if(t instanceof ev||(t=gy(t)),!t)return new Dl;if(t instanceof Dl)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 Dl(o,l,c,t.opacity)}function Aje(t,e,n,r){return arguments.length===1?mQ(t):new Dl(t,e,n,r??1)}function Dl(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}VO(Dl,Aje,fQ(ev,{brighter(t){return t=t==null?OS:Math.pow(OS,t),new Dl(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?my:Math.pow(my,t),new Dl(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 zs(RC(t>=240?t-240:t+120,i,r),RC(t,i,r),RC(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Dl(pV(this.h),W_(this.s),W_(this.l),LS(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=LS(this.opacity);return`${t===1?"hsl(":"hsla("}${pV(this.h)}, ${W_(this.s)*100}%, ${W_(this.l)*100}%${t===1?")":`, ${t})`}`}}));function pV(t){return t=(t||0)%360,t<0?t+360:t}function W_(t){return Math.max(0,Math.min(1,t||0))}function RC(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 GO=t=>()=>t;function Cje(t,e){return function(n){return t+n*e}}function jje(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 Pje(t){return(t=+t)==1?pQ:function(e,n){return n-e?jje(e,n,t):GO(isNaN(e)?n:e)}}function pQ(t,e){var n=e-t;return n?Cje(t,n):GO(isNaN(t)?e:t)}const gV=(function t(e){var n=Pje(e);function r(i,s){var o=n((i=oD(i)).r,(s=oD(s)).r),l=n(i.g,s.g),c=n(i.b,s.b),u=pQ(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 Dje(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 Rje(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Oje(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]=Ax(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 Lje(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function FS(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Fje(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]=Ax(t[i],e[i]):r[i]=e[i];return function(s){for(i in n)r[i]=n[i](s);return r}}var lD=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,OC=new RegExp(lD.source,"g");function Ije(t){return function(){return t}}function Uje(t){return function(e){return t(e)+""}}function zje(t,e){var n=lD.lastIndex=OC.lastIndex=0,r,i,s,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=lD.exec(t))&&(i=OC.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:FS(r,i)})),n=OC.lastIndex;return n<e.length&&(s=e.slice(n),l[o]?l[o]+=s:l[++o]=s),l.length<2?c[0]?Uje(c[0].x):Ije(e):(e=c.length,function(u){for(var d=0,h;d<e;++d)l[(h=c[d]).i]=h.x(u);return l.join("")})}function Ax(t,e){var n=typeof e,r;return e==null||n==="boolean"?GO(e):(n==="number"?FS:n==="string"?(r=gy(e))?(e=r,gV):zje:e instanceof gy?gV:e instanceof Date?Lje:Rje(e)?Dje:Array.isArray(e)?Oje:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Fje:FS)(t,e)}function qO(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function Bje(t,e){e===void 0&&(e=t,t=Ax);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 Hje(t){return function(){return t}}function IS(t){return+t}var xV=[0,1];function ps(t){return t}function cD(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Hje(isNaN(e)?NaN:.5)}function $je(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function Vje(t,e,n){var r=t[0],i=t[1],s=e[0],o=e[1];return i<r?(r=cD(i,r),s=n(o,s)):(r=cD(r,i),s=n(s,o)),function(l){return s(r(l))}}function Gje(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]=cD(t[o],t[o+1]),s[o]=n(e[o],e[o+1]);return function(l){var c=Jy(t,l,1,r)-1;return s[c](i[c](l))}}function tv(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function QM(){var t=xV,e=xV,n=Ax,r,i,s,o=ps,l,c,u;function d(){var p=Math.min(t.length,e.length);return o!==ps&&(o=$je(t[0],t[p-1])),l=p>2?Gje:Vje,c=u=null,h}function h(p){return p==null||isNaN(p=+p)?s:(c||(c=l(t.map(r),e,n)))(r(o(p)))}return h.invert=function(p){return o(i((u||(u=l(e,t.map(r),FS)))(p)))},h.domain=function(p){return arguments.length?(t=Array.from(p,IS),d()):t.slice()},h.range=function(p){return arguments.length?(e=Array.from(p),d()):e.slice()},h.rangeRound=function(p){return e=Array.from(p),n=qO,d()},h.clamp=function(p){return arguments.length?(o=p?!0:ps,d()):o!==ps},h.interpolate=function(p){return arguments.length?(n=p,d()):n},h.unknown=function(p){return arguments.length?(s=p,h):s},function(p,m){return r=p,i=m,d()}}function WO(){return QM()(ps,ps)}function qje(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function US(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 ax(t){return t=US(Math.abs(t)),t?t[1]:NaN}function Wje(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 Kje(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var Xje=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function xy(t){if(!(e=Xje.exec(t)))throw new Error("invalid format: "+t);var e;return new KO({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]})}xy.prototype=KO.prototype;function KO(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+""}KO.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 Yje(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 gQ;function Qje(t,e){var n=US(t,e);if(!n)return t+"";var r=n[0],i=n[1],s=i-(gQ=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")+US(t,Math.max(0,e+s-1))[0]}function bV(t,e){var n=US(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 yV={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:qje,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)=>bV(t*100,e),r:bV,s:Qje,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function vV(t){return t}var wV=Array.prototype.map,_V=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Zje(t){var e=t.grouping===void 0||t.thousands===void 0?vV:Wje(wV.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?vV:Kje(wV.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(h){h=xy(h);var p=h.fill,m=h.align,x=h.sign,y=h.symbol,v=h.zero,b=h.width,S=h.comma,N=h.precision,T=h.trim,k=h.type;k==="n"?(S=!0,k="g"):yV[k]||(N===void 0&&(N=12),T=!0,k="g"),(v||p==="0"&&m==="=")&&(v=!0,p="0",m="=");var C=y==="$"?n:y==="#"&&/[boxX]/.test(k)?"0"+k.toLowerCase():"",E=y==="$"?r:/[%p]/.test(k)?o:"",P=yV[k],A=/[defgprs%]/.test(k);N=N===void 0?6:/[gprs]/.test(k)?Math.max(1,Math.min(21,N)):Math.max(0,Math.min(20,N));function D(I){var L=C,U=E,j,V,K;if(k==="c")U=P(I)+U,I="";else{I=+I;var z=I<0||1/I<0;if(I=isNaN(I)?c:P(Math.abs(I),N),T&&(I=Yje(I)),z&&+I==0&&x!=="+"&&(z=!1),L=(z?x==="("?x:l:x==="-"||x==="("?"":x)+L,U=(k==="s"?_V[8+gQ/3]:"")+U+(z&&x==="("?")":""),A){for(j=-1,V=I.length;++j<V;)if(K=I.charCodeAt(j),48>K||K>57){U=(K===46?i+I.slice(j+1):I.slice(j))+U,I=I.slice(0,j);break}}}S&&!v&&(I=e(I,1/0));var X=L.length+I.length+U.length,Y=X<b?new Array(b-X+1).join(p):"";switch(S&&v&&(I=e(Y+I,Y.length?b-U.length:1/0),Y=""),m){case"<":I=L+I+U+Y;break;case"=":I=L+Y+I+U;break;case"^":I=Y.slice(0,X=Y.length>>1)+L+I+U+Y.slice(X);break;default:I=Y+L+I+U;break}return s(I)}return D.toString=function(){return h+""},D}function d(h,p){var m=u((h=xy(h),h.type="f",h)),x=Math.max(-8,Math.min(8,Math.floor(ax(p)/3)))*3,y=Math.pow(10,-x),v=_V[8+x/3];return function(b){return m(y*b)+v}}return{format:u,formatPrefix:d}}var K_,XO,xQ;Jje({thousands:",",grouping:[3],currency:["$",""]});function Jje(t){return K_=Zje(t),XO=K_.format,xQ=K_.formatPrefix,K_}function ePe(t){return Math.max(0,-ax(Math.abs(t)))}function tPe(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(ax(e)/3)))*3-ax(Math.abs(t)))}function nPe(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,ax(e)-ax(t))+1}function bQ(t,e,n,r){var i=aD(t,e,n),s;switch(r=xy(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(s=tPe(i,o))&&(r.precision=s),xQ(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(s=nPe(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=s-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(s=ePe(i))&&(r.precision=s-(r.type==="%")*2);break}}return XO(r)}function Uh(t){var e=t.domain;return t.ticks=function(n){var r=e();return rD(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return bQ(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=iD(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 yQ(){var t=WO();return t.copy=function(){return tv(t,yQ())},xl.apply(t,arguments),Uh(t)}function vQ(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,IS),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return vQ(t).unknown(e)},t=arguments.length?Array.from(t,IS):[0,1],Uh(n)}function wQ(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 SV(t){return Math.log(t)}function NV(t){return Math.exp(t)}function rPe(t){return-Math.log(-t)}function iPe(t){return-Math.exp(-t)}function aPe(t){return isFinite(t)?+("1e"+t):t<0?0:t}function sPe(t){return t===10?aPe:t===Math.E?Math.exp:e=>Math.pow(t,e)}function oPe(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 MV(t){return(e,n)=>-t(-e,n)}function YO(t){const e=t(SV,NV),n=e.domain;let r=10,i,s;function o(){return i=oPe(r),s=sPe(r),n()[0]<0?(i=MV(i),s=MV(s),t(rPe,iPe)):t(SV,NV),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 h=d<u;h&&([u,d]=[d,u]);let p=i(u),m=i(d),x,y;const v=l==null?10:+l;let b=[];if(!(r%1)&&m-p<v){if(p=Math.floor(p),m=Math.ceil(m),u>0){for(;p<=m;++p)for(x=1;x<r;++x)if(y=p<0?x/s(-p):x*s(p),!(y<u)){if(y>d)break;b.push(y)}}else for(;p<=m;++p)for(x=r-1;x>=1;--x)if(y=p>0?x/s(-p):x*s(p),!(y<u)){if(y>d)break;b.push(y)}b.length*2<v&&(b=rD(u,d,v))}else b=rD(p,m,Math.min(m-p,v)).map(s);return h?b.reverse():b},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=xy(c)).precision==null&&(c.trim=!0),c=XO(c)),l===1/0)return c;const u=Math.max(1,r*l/e.ticks().length);return d=>{let h=d/s(Math.round(i(d)));return h*r<r-.5&&(h*=r),h<=u?c(d):""}},e.nice=()=>n(wQ(n(),{floor:l=>s(Math.floor(i(l))),ceil:l=>s(Math.ceil(i(l)))})),e}function _Q(){const t=YO(QM()).domain([1,10]);return t.copy=()=>tv(t,_Q()).base(t.base()),xl.apply(t,arguments),t}function kV(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function EV(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function QO(t){var e=1,n=t(kV(e),EV(e));return n.constant=function(r){return arguments.length?t(kV(e=+r),EV(e)):e},Uh(n)}function SQ(){var t=QO(QM());return t.copy=function(){return tv(t,SQ()).constant(t.constant())},xl.apply(t,arguments)}function TV(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function lPe(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function cPe(t){return t<0?-t*t:t*t}function ZO(t){var e=t(ps,ps),n=1;function r(){return n===1?t(ps,ps):n===.5?t(lPe,cPe):t(TV(n),TV(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Uh(e)}function JO(){var t=ZO(QM());return t.copy=function(){return tv(t,JO()).exponent(t.exponent())},xl.apply(t,arguments),t}function uPe(){return JO.apply(null,arguments).exponent(.5)}function AV(t){return Math.sign(t)*t*t}function dPe(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function NQ(){var t=WO(),e=[0,1],n=!1,r;function i(s){var o=dPe(t(s));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(s){return t.invert(AV(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,IS)).map(AV)),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 NQ(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},xl.apply(i,arguments),Uh(i)}function MQ(){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]=pje(t,o/l);return s}function s(o){return o==null||isNaN(o=+o)?r:e[Jy(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(fh),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 MQ().domain(t).range(e).unknown(r)},xl.apply(s,arguments)}function kQ(){var t=0,e=1,n=1,r=[.5],i=[0,1],s;function o(c){return c!=null&&c<=c?i[Jy(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 kQ().domain([t,e]).range(i).unknown(s)},xl.apply(Uh(o),arguments)}function EQ(){var t=[.5],e=[0,1],n,r=1;function i(s){return s!=null&&s<=s?e[Jy(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 EQ().domain(t).range(e).unknown(n)},xl.apply(i,arguments)}const LC=new Date,FC=new Date;function oa(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=>oa(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)=>(LC.setTime(+s),FC.setTime(+o),t(LC),t(FC),Math.floor(n(LC,FC))),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 zS=oa(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);zS.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?oa(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):zS);zS.range;const Su=1e3,il=Su*60,Nu=il*60,Bu=Nu*24,e4=Bu*7,CV=Bu*30,IC=Bu*365,Lf=oa(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*Su)},(t,e)=>(e-t)/Su,t=>t.getUTCSeconds());Lf.range;const t4=oa(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Su)},(t,e)=>{t.setTime(+t+e*il)},(t,e)=>(e-t)/il,t=>t.getMinutes());t4.range;const n4=oa(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*il)},(t,e)=>(e-t)/il,t=>t.getUTCMinutes());n4.range;const r4=oa(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Su-t.getMinutes()*il)},(t,e)=>{t.setTime(+t+e*Nu)},(t,e)=>(e-t)/Nu,t=>t.getHours());r4.range;const i4=oa(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*Nu)},(t,e)=>(e-t)/Nu,t=>t.getUTCHours());i4.range;const nv=oa(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*il)/Bu,t=>t.getDate()-1);nv.range;const ZM=oa(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Bu,t=>t.getUTCDate()-1);ZM.range;const TQ=oa(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Bu,t=>Math.floor(t/Bu));TQ.range;function jm(t){return oa(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())*il)/e4)}const JM=jm(0),BS=jm(1),hPe=jm(2),fPe=jm(3),sx=jm(4),mPe=jm(5),pPe=jm(6);JM.range;BS.range;hPe.range;fPe.range;sx.range;mPe.range;pPe.range;function Pm(t){return oa(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)/e4)}const e2=Pm(0),HS=Pm(1),gPe=Pm(2),xPe=Pm(3),ox=Pm(4),bPe=Pm(5),yPe=Pm(6);e2.range;HS.range;gPe.range;xPe.range;ox.range;bPe.range;yPe.range;const a4=oa(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());a4.range;const s4=oa(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());s4.range;const Hu=oa(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());Hu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:oa(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)});Hu.range;const $u=oa(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());$u.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:oa(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)});$u.range;function AQ(t,e,n,r,i,s){const o=[[Lf,1,Su],[Lf,5,5*Su],[Lf,15,15*Su],[Lf,30,30*Su],[s,1,il],[s,5,5*il],[s,15,15*il],[s,30,30*il],[i,1,Nu],[i,3,3*Nu],[i,6,6*Nu],[i,12,12*Nu],[r,1,Bu],[r,2,2*Bu],[n,1,e4],[e,1,CV],[e,3,3*CV],[t,1,IC]];function l(u,d,h){const p=d<u;p&&([u,d]=[d,u]);const m=h&&typeof h.range=="function"?h:c(u,d,h),x=m?m.range(u,+d+1):[];return p?x.reverse():x}function c(u,d,h){const p=Math.abs(d-u)/h,m=BO(([,,v])=>v).right(o,p);if(m===o.length)return t.every(aD(u/IC,d/IC,h));if(m===0)return zS.every(Math.max(aD(u,d,h),1));const[x,y]=o[p/o[m-1][2]<o[m][2]/p?m-1:m];return x.every(y)}return[l,c]}const[vPe,wPe]=AQ($u,s4,e2,TQ,i4,n4),[_Pe,SPe]=AQ(Hu,a4,JM,nv,r4,t4);function UC(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 zC(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 Qb(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function NPe(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=Zb(i),d=Jb(i),h=Zb(s),p=Jb(s),m=Zb(o),x=Jb(o),y=Zb(l),v=Jb(l),b=Zb(c),S=Jb(c),N={a:z,A:X,b:Y,B:te,c:null,d:LV,e:LV,f:WPe,g:r3e,G:a3e,H:VPe,I:GPe,j:qPe,L:CQ,m:KPe,M:XPe,p:$,q:W,Q:UV,s:zV,S:YPe,u:QPe,U:ZPe,V:JPe,w:e3e,W:t3e,x:null,X:null,y:n3e,Y:i3e,Z:s3e,"%":IV},T={a:ne,A:re,b:ge,B:me,c:null,d:FV,e:FV,f:u3e,g:v3e,G:_3e,H:o3e,I:l3e,j:c3e,L:PQ,m:d3e,M:h3e,p:ue,q:Te,Q:UV,s:zV,S:f3e,u:m3e,U:p3e,V:g3e,w:x3e,W:b3e,x:null,X:null,y:y3e,Y:w3e,Z:S3e,"%":IV},k={a:D,A:I,b:L,B:U,c:j,d:RV,e:RV,f:zPe,g:DV,G:PV,H:OV,I:OV,j:LPe,L:UPe,m:OPe,M:FPe,p:A,q:RPe,Q:HPe,s:$Pe,S:IPe,u:APe,U:CPe,V:jPe,w:TPe,W:PPe,x:V,X:K,y:DV,Y:PV,Z:DPe,"%":BPe};N.x=C(n,N),N.X=C(r,N),N.c=C(e,N),T.x=C(n,T),T.X=C(r,T),T.c=C(e,T);function C(ie,Ce){return function(Fe){var xe=[],Ze=-1,G=0,Q=ie.length,de,q,ee;for(Fe instanceof Date||(Fe=new Date(+Fe));++Ze<Q;)ie.charCodeAt(Ze)===37&&(xe.push(ie.slice(G,Ze)),(q=jV[de=ie.charAt(++Ze)])!=null?de=ie.charAt(++Ze):q=de==="e"?" ":"0",(ee=Ce[de])&&(de=ee(Fe,q)),xe.push(de),G=Ze+1);return xe.push(ie.slice(G,Ze)),xe.join("")}}function E(ie,Ce){return function(Fe){var xe=Qb(1900,void 0,1),Ze=P(xe,ie,Fe+="",0),G,Q;if(Ze!=Fe.length)return null;if("Q"in xe)return new Date(xe.Q);if("s"in xe)return new Date(xe.s*1e3+("L"in xe?xe.L:0));if(Ce&&!("Z"in xe)&&(xe.Z=0),"p"in xe&&(xe.H=xe.H%12+xe.p*12),xe.m===void 0&&(xe.m="q"in xe?xe.q:0),"V"in xe){if(xe.V<1||xe.V>53)return null;"w"in xe||(xe.w=1),"Z"in xe?(G=zC(Qb(xe.y,0,1)),Q=G.getUTCDay(),G=Q>4||Q===0?HS.ceil(G):HS(G),G=ZM.offset(G,(xe.V-1)*7),xe.y=G.getUTCFullYear(),xe.m=G.getUTCMonth(),xe.d=G.getUTCDate()+(xe.w+6)%7):(G=UC(Qb(xe.y,0,1)),Q=G.getDay(),G=Q>4||Q===0?BS.ceil(G):BS(G),G=nv.offset(G,(xe.V-1)*7),xe.y=G.getFullYear(),xe.m=G.getMonth(),xe.d=G.getDate()+(xe.w+6)%7)}else("W"in xe||"U"in xe)&&("w"in xe||(xe.w="u"in xe?xe.u%7:"W"in xe?1:0),Q="Z"in xe?zC(Qb(xe.y,0,1)).getUTCDay():UC(Qb(xe.y,0,1)).getDay(),xe.m=0,xe.d="W"in xe?(xe.w+6)%7+xe.W*7-(Q+5)%7:xe.w+xe.U*7-(Q+6)%7);return"Z"in xe?(xe.H+=xe.Z/100|0,xe.M+=xe.Z%100,zC(xe)):UC(xe)}}function P(ie,Ce,Fe,xe){for(var Ze=0,G=Ce.length,Q=Fe.length,de,q;Ze<G;){if(xe>=Q)return-1;if(de=Ce.charCodeAt(Ze++),de===37){if(de=Ce.charAt(Ze++),q=k[de in jV?Ce.charAt(Ze++):de],!q||(xe=q(ie,Fe,xe))<0)return-1}else if(de!=Fe.charCodeAt(xe++))return-1}return xe}function A(ie,Ce,Fe){var xe=u.exec(Ce.slice(Fe));return xe?(ie.p=d.get(xe[0].toLowerCase()),Fe+xe[0].length):-1}function D(ie,Ce,Fe){var xe=m.exec(Ce.slice(Fe));return xe?(ie.w=x.get(xe[0].toLowerCase()),Fe+xe[0].length):-1}function I(ie,Ce,Fe){var xe=h.exec(Ce.slice(Fe));return xe?(ie.w=p.get(xe[0].toLowerCase()),Fe+xe[0].length):-1}function L(ie,Ce,Fe){var xe=b.exec(Ce.slice(Fe));return xe?(ie.m=S.get(xe[0].toLowerCase()),Fe+xe[0].length):-1}function U(ie,Ce,Fe){var xe=y.exec(Ce.slice(Fe));return xe?(ie.m=v.get(xe[0].toLowerCase()),Fe+xe[0].length):-1}function j(ie,Ce,Fe){return P(ie,e,Ce,Fe)}function V(ie,Ce,Fe){return P(ie,n,Ce,Fe)}function K(ie,Ce,Fe){return P(ie,r,Ce,Fe)}function z(ie){return o[ie.getDay()]}function X(ie){return s[ie.getDay()]}function Y(ie){return c[ie.getMonth()]}function te(ie){return l[ie.getMonth()]}function $(ie){return i[+(ie.getHours()>=12)]}function W(ie){return 1+~~(ie.getMonth()/3)}function ne(ie){return o[ie.getUTCDay()]}function re(ie){return s[ie.getUTCDay()]}function ge(ie){return c[ie.getUTCMonth()]}function me(ie){return l[ie.getUTCMonth()]}function ue(ie){return i[+(ie.getUTCHours()>=12)]}function Te(ie){return 1+~~(ie.getUTCMonth()/3)}return{format:function(ie){var Ce=C(ie+="",N);return Ce.toString=function(){return ie},Ce},parse:function(ie){var Ce=E(ie+="",!1);return Ce.toString=function(){return ie},Ce},utcFormat:function(ie){var Ce=C(ie+="",T);return Ce.toString=function(){return ie},Ce},utcParse:function(ie){var Ce=E(ie+="",!0);return Ce.toString=function(){return ie},Ce}}}var jV={"-":"",_:" ",0:"0"},ka=/^\s*\d+/,MPe=/^%/,kPe=/[\\^$*+?|[\]().{}]/g;function ur(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 EPe(t){return t.replace(kPe,"\\$&")}function Zb(t){return new RegExp("^(?:"+t.map(EPe).join("|")+")","i")}function Jb(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function TPe(t,e,n){var r=ka.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function APe(t,e,n){var r=ka.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function CPe(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function jPe(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function PPe(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function PV(t,e,n){var r=ka.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function DV(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function DPe(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 RPe(t,e,n){var r=ka.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function OPe(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function RV(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function LPe(t,e,n){var r=ka.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function OV(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function FPe(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function IPe(t,e,n){var r=ka.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function UPe(t,e,n){var r=ka.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function zPe(t,e,n){var r=ka.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function BPe(t,e,n){var r=MPe.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function HPe(t,e,n){var r=ka.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function $Pe(t,e,n){var r=ka.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function LV(t,e){return ur(t.getDate(),e,2)}function VPe(t,e){return ur(t.getHours(),e,2)}function GPe(t,e){return ur(t.getHours()%12||12,e,2)}function qPe(t,e){return ur(1+nv.count(Hu(t),t),e,3)}function CQ(t,e){return ur(t.getMilliseconds(),e,3)}function WPe(t,e){return CQ(t,e)+"000"}function KPe(t,e){return ur(t.getMonth()+1,e,2)}function XPe(t,e){return ur(t.getMinutes(),e,2)}function YPe(t,e){return ur(t.getSeconds(),e,2)}function QPe(t){var e=t.getDay();return e===0?7:e}function ZPe(t,e){return ur(JM.count(Hu(t)-1,t),e,2)}function jQ(t){var e=t.getDay();return e>=4||e===0?sx(t):sx.ceil(t)}function JPe(t,e){return t=jQ(t),ur(sx.count(Hu(t),t)+(Hu(t).getDay()===4),e,2)}function e3e(t){return t.getDay()}function t3e(t,e){return ur(BS.count(Hu(t)-1,t),e,2)}function n3e(t,e){return ur(t.getFullYear()%100,e,2)}function r3e(t,e){return t=jQ(t),ur(t.getFullYear()%100,e,2)}function i3e(t,e){return ur(t.getFullYear()%1e4,e,4)}function a3e(t,e){var n=t.getDay();return t=n>=4||n===0?sx(t):sx.ceil(t),ur(t.getFullYear()%1e4,e,4)}function s3e(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+ur(e/60|0,"0",2)+ur(e%60,"0",2)}function FV(t,e){return ur(t.getUTCDate(),e,2)}function o3e(t,e){return ur(t.getUTCHours(),e,2)}function l3e(t,e){return ur(t.getUTCHours()%12||12,e,2)}function c3e(t,e){return ur(1+ZM.count($u(t),t),e,3)}function PQ(t,e){return ur(t.getUTCMilliseconds(),e,3)}function u3e(t,e){return PQ(t,e)+"000"}function d3e(t,e){return ur(t.getUTCMonth()+1,e,2)}function h3e(t,e){return ur(t.getUTCMinutes(),e,2)}function f3e(t,e){return ur(t.getUTCSeconds(),e,2)}function m3e(t){var e=t.getUTCDay();return e===0?7:e}function p3e(t,e){return ur(e2.count($u(t)-1,t),e,2)}function DQ(t){var e=t.getUTCDay();return e>=4||e===0?ox(t):ox.ceil(t)}function g3e(t,e){return t=DQ(t),ur(ox.count($u(t),t)+($u(t).getUTCDay()===4),e,2)}function x3e(t){return t.getUTCDay()}function b3e(t,e){return ur(HS.count($u(t)-1,t),e,2)}function y3e(t,e){return ur(t.getUTCFullYear()%100,e,2)}function v3e(t,e){return t=DQ(t),ur(t.getUTCFullYear()%100,e,2)}function w3e(t,e){return ur(t.getUTCFullYear()%1e4,e,4)}function _3e(t,e){var n=t.getUTCDay();return t=n>=4||n===0?ox(t):ox.ceil(t),ur(t.getUTCFullYear()%1e4,e,4)}function S3e(){return"+0000"}function IV(){return"%"}function UV(t){return+t}function zV(t){return Math.floor(+t/1e3)}var Qp,RQ,OQ;N3e({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 N3e(t){return Qp=NPe(t),RQ=Qp.format,Qp.parse,OQ=Qp.utcFormat,Qp.utcParse,Qp}function M3e(t){return new Date(t)}function k3e(t){return t instanceof Date?+t:+new Date(+t)}function o4(t,e,n,r,i,s,o,l,c,u){var d=WO(),h=d.invert,p=d.domain,m=u(".%L"),x=u(":%S"),y=u("%I:%M"),v=u("%I %p"),b=u("%a %d"),S=u("%b %d"),N=u("%B"),T=u("%Y");function k(C){return(c(C)<C?m:l(C)<C?x:o(C)<C?y:s(C)<C?v:r(C)<C?i(C)<C?b:S:n(C)<C?N:T)(C)}return d.invert=function(C){return new Date(h(C))},d.domain=function(C){return arguments.length?p(Array.from(C,k3e)):p().map(M3e)},d.ticks=function(C){var E=p();return t(E[0],E[E.length-1],C??10)},d.tickFormat=function(C,E){return E==null?k:u(E)},d.nice=function(C){var E=p();return(!C||typeof C.range!="function")&&(C=e(E[0],E[E.length-1],C??10)),C?p(wQ(E,C)):d},d.copy=function(){return tv(d,o4(t,e,n,r,i,s,o,l,c,u))},d}function E3e(){return xl.apply(o4(_Pe,SPe,Hu,a4,JM,nv,r4,t4,Lf,RQ).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function T3e(){return xl.apply(o4(vPe,wPe,$u,s4,e2,ZM,i4,n4,Lf,OQ).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function t2(){var t=0,e=1,n,r,i,s,o=ps,l=!1,c;function u(h){return h==null||isNaN(h=+h)?c:o(i===0?.5:(h=(s(h)-n)*i,l?Math.max(0,Math.min(1,h)):h))}u.domain=function(h){return arguments.length?([t,e]=h,n=s(t=+t),r=s(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(h){return arguments.length?(l=!!h,u):l},u.interpolator=function(h){return arguments.length?(o=h,u):o};function d(h){return function(p){var m,x;return arguments.length?([m,x]=p,o=h(m,x),u):[o(0),o(1)]}}return u.range=d(Ax),u.rangeRound=d(qO),u.unknown=function(h){return arguments.length?(c=h,u):c},function(h){return s=h,n=h(t),r=h(e),i=n===r?0:1/(r-n),u}}function zh(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function LQ(){var t=Uh(t2()(ps));return t.copy=function(){return zh(t,LQ())},Xu.apply(t,arguments)}function FQ(){var t=YO(t2()).domain([1,10]);return t.copy=function(){return zh(t,FQ()).base(t.base())},Xu.apply(t,arguments)}function IQ(){var t=QO(t2());return t.copy=function(){return zh(t,IQ()).constant(t.constant())},Xu.apply(t,arguments)}function l4(){var t=ZO(t2());return t.copy=function(){return zh(t,l4()).exponent(t.exponent())},Xu.apply(t,arguments)}function A3e(){return l4.apply(null,arguments).exponent(.5)}function UQ(){var t=[],e=ps;function n(r){if(r!=null&&!isNaN(r=+r))return e((Jy(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(fh),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)=>mje(t,s/r))},n.copy=function(){return UQ(e).domain(t)},Xu.apply(n,arguments)}function n2(){var t=0,e=.5,n=1,r=1,i,s,o,l,c,u=ps,d,h=!1,p;function m(y){return isNaN(y=+y)?p:(y=.5+((y=+d(y))-s)*(r*y<r*s?l:c),u(h?Math.max(0,Math.min(1,y)):y))}m.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,m):[t,e,n]},m.clamp=function(y){return arguments.length?(h=!!y,m):h},m.interpolator=function(y){return arguments.length?(u=y,m):u};function x(y){return function(v){var b,S,N;return arguments.length?([b,S,N]=v,u=Bje(y,[b,S,N]),m):[u(0),u(.5),u(1)]}}return m.range=x(Ax),m.rangeRound=x(qO),m.unknown=function(y){return arguments.length?(p=y,m):p},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,m}}function zQ(){var t=Uh(n2()(ps));return t.copy=function(){return zh(t,zQ())},Xu.apply(t,arguments)}function BQ(){var t=YO(n2()).domain([.1,1,10]);return t.copy=function(){return zh(t,BQ()).base(t.base())},Xu.apply(t,arguments)}function HQ(){var t=QO(n2());return t.copy=function(){return zh(t,HQ()).constant(t.constant())},Xu.apply(t,arguments)}function c4(){var t=ZO(n2());return t.copy=function(){return zh(t,c4()).exponent(t.exponent())},Xu.apply(t,arguments)}function C3e(){return c4.apply(null,arguments).exponent(.5)}const u0=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:$O,scaleDiverging:zQ,scaleDivergingLog:BQ,scaleDivergingPow:c4,scaleDivergingSqrt:C3e,scaleDivergingSymlog:HQ,scaleIdentity:vQ,scaleImplicit:sD,scaleLinear:yQ,scaleLog:_Q,scaleOrdinal:HO,scalePoint:xje,scalePow:JO,scaleQuantile:MQ,scaleQuantize:kQ,scaleRadial:NQ,scaleSequential:LQ,scaleSequentialLog:FQ,scaleSequentialPow:l4,scaleSequentialQuantile:UQ,scaleSequentialSqrt:A3e,scaleSequentialSymlog:IQ,scaleSqrt:uPe,scaleSymlog:SQ,scaleThreshold:EQ,scaleTime:E3e,scaleUtc:T3e,tickFormat:bQ},Symbol.toStringTag,{value:"Module"}));var Bh=t=>t.chartData,u4=st([Bh],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),rv=(t,e,n,r)=>r?u4(t):Bh(t);function Th(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(vr(e)&&vr(n))return!0}return!1}function BV(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function $Q(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,s;if(vr(n))i=n;else if(typeof n=="function")return;if(vr(r))s=r;else if(typeof r=="function")return;var o=[i,s];if(Th(o))return o}}function j3e(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(Th(r))return BV(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(Bt(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&p$.test(i)){var c=p$.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(Bt(s))l=s;else if(typeof s=="function")try{e!=null&&(l=s(e?.[1]))}catch{}else if(typeof s=="string"&&g$.test(s)){var d=g$.exec(s);if(d==null||e==null)l=void 0;else{var h=+d[1];l=e[1]+h}}else l=e?.[1];var p=[o,l];if(Th(p))return e==null?p:BV(p,e,n)}}}var Cx=1e9,P3e={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},h4,ni=!0,ml="[DecimalError] ",Xf=ml+"Invalid argument: ",d4=ml+"Exponent out of range: ",jx=Math.floor,Mf=Math.pow,D3e=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,fo,ba=1e7,Wr=7,VQ=9007199254740991,$S=jx(VQ/Wr),$t={};$t.absoluteValue=$t.abs=function(){var t=new this.constructor(this);return t.s&&(t.s=1),t};$t.comparedTo=$t.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};$t.decimalPlaces=$t.dp=function(){var t=this,e=t.d.length-1,n=(e-t.e)*Wr;if(e=t.d[e],e)for(;e%10==0;e/=10)n--;return n<0?0:n};$t.dividedBy=$t.div=function(t){return ju(this,new this.constructor(t))};$t.dividedToIntegerBy=$t.idiv=function(t){var e=this,n=e.constructor;return Or(ju(e,new n(t),0,1),n.precision)};$t.equals=$t.eq=function(t){return!this.cmp(t)};$t.exponent=function(){return qi(this)};$t.greaterThan=$t.gt=function(t){return this.cmp(t)>0};$t.greaterThanOrEqualTo=$t.gte=function(t){return this.cmp(t)>=0};$t.isInteger=$t.isint=function(){return this.e>this.d.length-2};$t.isNegative=$t.isneg=function(){return this.s<0};$t.isPositive=$t.ispos=function(){return this.s>0};$t.isZero=function(){return this.s===0};$t.lessThan=$t.lt=function(t){return this.cmp(t)<0};$t.lessThanOrEqualTo=$t.lte=function(t){return this.cmp(t)<1};$t.logarithm=$t.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(fo))throw Error(ml+"NaN");if(n.s<1)throw Error(ml+(n.s?"NaN":"-Infinity"));return n.eq(fo)?new r(0):(ni=!1,e=ju(by(n,s),by(t,s),s),ni=!0,Or(e,i))};$t.minus=$t.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?WQ(e,t):GQ(e,(t.s=-t.s,t))};$t.modulo=$t.mod=function(t){var e,n=this,r=n.constructor,i=r.precision;if(t=new r(t),!t.s)throw Error(ml+"NaN");return n.s?(ni=!1,e=ju(n,t,0,1).times(t),ni=!0,n.minus(e)):Or(new r(n),i)};$t.naturalExponential=$t.exp=function(){return qQ(this)};$t.naturalLogarithm=$t.ln=function(){return by(this)};$t.negated=$t.neg=function(){var t=new this.constructor(this);return t.s=-t.s||0,t};$t.plus=$t.add=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?GQ(e,t):WQ(e,(t.s=-t.s,t))};$t.precision=$t.sd=function(t){var e,n,r,i=this;if(t!==void 0&&t!==!!t&&t!==1&&t!==0)throw Error(Xf+t);if(e=qi(i)+1,r=i.d.length-1,n=r*Wr+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};$t.squareRoot=$t.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(ml+"NaN")}for(t=qi(l),ni=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=hc(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=jx((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(ju(l,s,o+2)).times(.5),hc(s.d).slice(0,o)===(e=hc(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(Or(s,n+1,0),s.times(s).eq(l)){r=s;break}}else if(e!="9999")break;o+=4}return ni=!0,Or(r,n)};$t.times=$t.mul=function(t){var e,n,r,i,s,o,l,c,u,d=this,h=d.constructor,p=d.d,m=(t=new h(t)).d;if(!d.s||!t.s)return new h(0);for(t.s*=d.s,n=d.e+t.e,c=p.length,u=m.length,c<u&&(s=p,p=m,m=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]+m[r]*p[i-r-1]+e,s[i--]=l%ba|0,e=l/ba|0;s[i]=(s[i]+e)%ba|0}for(;!s[--o];)s.pop();return e?++n:s.shift(),t.d=s,t.e=n,ni?Or(t,h.precision):t};$t.toDecimalPlaces=$t.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(wc(t,0,Cx),e===void 0?e=r.rounding:wc(e,0,8),Or(n,t+qi(n)+1,e))};$t.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=ym(r,!0):(wc(t,0,Cx),e===void 0?e=i.rounding:wc(e,0,8),r=Or(new i(r),t+1,e),n=ym(r,!0,t+1)),n};$t.toFixed=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?ym(i):(wc(t,0,Cx),e===void 0?e=s.rounding:wc(e,0,8),r=Or(new s(i),t+qi(i)+1,e),n=ym(r.abs(),!1,t+qi(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};$t.toInteger=$t.toint=function(){var t=this,e=t.constructor;return Or(new e(t),qi(t)+1,e.rounding)};$t.toNumber=function(){return+this};$t.toPower=$t.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(fo);if(l=new c(l),!l.s){if(t.s<1)throw Error(ml+"Infinity");return l}if(l.eq(fo))return l;if(r=c.precision,t.eq(fo))return Or(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,s=l.s,o){if((n=d<0?-d:d)<=VQ){for(i=new c(fo),e=Math.ceil(r/Wr+4),ni=!1;n%2&&(i=i.times(l),$V(i.d,e)),n=jx(n/2),n!==0;)l=l.times(l),$V(l.d,e);return ni=!0,t.s<0?new c(fo).div(i):Or(i,r)}}else if(s<0)throw Error(ml+"NaN");return s=s<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,ni=!1,i=t.times(by(l,r+u)),ni=!0,i=qQ(i),i.s=s,i};$t.toPrecision=function(t,e){var n,r,i=this,s=i.constructor;return t===void 0?(n=qi(i),r=ym(i,n<=s.toExpNeg||n>=s.toExpPos)):(wc(t,1,Cx),e===void 0?e=s.rounding:wc(e,0,8),i=Or(new s(i),t,e),n=qi(i),r=ym(i,t<=n||n<=s.toExpNeg,t)),r};$t.toSignificantDigits=$t.tosd=function(t,e){var n=this,r=n.constructor;return t===void 0?(t=r.precision,e=r.rounding):(wc(t,1,Cx),e===void 0?e=r.rounding:wc(e,0,8)),Or(new r(n),t,e)};$t.toString=$t.valueOf=$t.val=$t.toJSON=$t[Symbol.for("nodejs.util.inspect.custom")]=function(){var t=this,e=qi(t),n=t.constructor;return ym(t,e<=n.toExpNeg||e>=n.toExpPos)};function GQ(t,e){var n,r,i,s,o,l,c,u,d=t.constructor,h=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),ni?Or(e,h):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(h/Wr),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)/ba|0,c[s]%=ba;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,ni?Or(e,h):e}function wc(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Xf+t)}function hc(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=Wr-r.length,n&&(s+=Hd(n)),s+=r;o=t[e],r=o+"",n=Wr-r.length,n&&(s+=Hd(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}var ju=(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%ba|0,o=s/ba|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*ba+r[s]-i[s];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,s,o){var l,c,u,d,h,p,m,x,y,v,b,S,N,T,k,C,E,P,A=r.constructor,D=r.s==i.s?1:-1,I=r.d,L=i.d;if(!r.s)return new A(r);if(!i.s)throw Error(ml+"Division by zero");for(c=r.e-i.e,E=L.length,k=I.length,m=new A(D),x=m.d=[],u=0;L[u]==(I[u]||0);)++u;if(L[u]>(I[u]||0)&&--c,s==null?S=s=A.precision:o?S=s+(qi(r)-qi(i))+1:S=s,S<0)return new A(0);if(S=S/Wr+2|0,u=0,E==1)for(d=0,L=L[0],S++;(u<k||d)&&S--;u++)N=d*ba+(I[u]||0),x[u]=N/L|0,d=N%L|0;else{for(d=ba/(L[0]+1)|0,d>1&&(L=t(L,d),I=t(I,d),E=L.length,k=I.length),T=E,y=I.slice(0,E),v=y.length;v<E;)y[v++]=0;P=L.slice(),P.unshift(0),C=L[0],L[1]>=ba/2&&++C;do d=0,l=e(L,y,E,v),l<0?(b=y[0],E!=v&&(b=b*ba+(y[1]||0)),d=b/C|0,d>1?(d>=ba&&(d=ba-1),h=t(L,d),p=h.length,v=y.length,l=e(h,y,p,v),l==1&&(d--,n(h,E<p?P:L,p))):(d==0&&(l=d=1),h=L.slice()),p=h.length,p<v&&h.unshift(0),n(y,h,v),l==-1&&(v=y.length,l=e(L,y,E,v),l<1&&(d++,n(y,E<v?P:L,v))),v=y.length):l===0&&(d++,y=[0]),x[u++]=d,l&&y[0]?y[v++]=I[T]||0:(y=[I[T]],v=1);while((T++<k||y[0]!==void 0)&&S--)}return x[0]||x.shift(),m.e=c,Or(m,o?s+qi(m)+1:s)}})();function qQ(t,e){var n,r,i,s,o,l,c=0,u=0,d=t.constructor,h=d.precision;if(qi(t)>16)throw Error(d4+qi(t));if(!t.s)return new d(fo);for(ni=!1,l=h,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(Mf(2,u))/Math.LN10*2+5|0,l+=r,n=i=s=new d(fo),d.precision=l;;){if(i=Or(i.times(t),l),n=n.times(++c),o=s.plus(ju(i,n,l)),hc(o.d).slice(0,l)===hc(s.d).slice(0,l)){for(;u--;)s=Or(s.times(s),l);return d.precision=h,e==null?(ni=!0,Or(s,h)):s}s=o}}function qi(t){for(var e=t.e*Wr,n=t.d[0];n>=10;n/=10)e++;return e}function BC(t,e,n){if(e>t.LN10.sd())throw ni=!0,n&&(t.precision=n),Error(ml+"LN10 precision limit exceeded");return Or(new t(t.LN10),e)}function Hd(t){for(var e="";t--;)e+="0";return e}function by(t,e){var n,r,i,s,o,l,c,u,d,h=1,p=10,m=t,x=m.d,y=m.constructor,v=y.precision;if(m.s<1)throw Error(ml+(m.s?"NaN":"-Infinity"));if(m.eq(fo))return new y(0);if(e==null?(ni=!1,u=v):u=e,m.eq(10))return e==null&&(ni=!0),BC(y,u);if(u+=p,y.precision=u,n=hc(x),r=n.charAt(0),s=qi(m),Math.abs(s)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)m=m.times(t),n=hc(m.d),r=n.charAt(0),h++;s=qi(m),r>1?(m=new y("0."+n),s++):m=new y(r+"."+n.slice(1))}else return c=BC(y,u+2,v).times(s+""),m=by(new y(r+"."+n.slice(1)),u-p).plus(c),y.precision=v,e==null?(ni=!0,Or(m,v)):m;for(l=o=m=ju(m.minus(fo),m.plus(fo),u),d=Or(m.times(m),u),i=3;;){if(o=Or(o.times(d),u),c=l.plus(ju(o,new y(i),u)),hc(c.d).slice(0,u)===hc(l.d).slice(0,u))return l=l.times(2),s!==0&&(l=l.plus(BC(y,u+2,v).times(s+""))),l=ju(l,new y(h),u),y.precision=v,e==null?(ni=!0,Or(l,v)):l;l=c,i+=2}}function HV(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=jx(n/Wr),t.d=[],r=(n+1)%Wr,n<0&&(r+=Wr),r<i){for(r&&t.d.push(+e.slice(0,r)),i-=Wr;r<i;)t.d.push(+e.slice(r,r+=Wr));e=e.slice(r),r=Wr-e.length}else r-=i;for(;r--;)e+="0";if(t.d.push(+e),ni&&(t.e>$S||t.e<-$S))throw Error(d4+n)}else t.s=0,t.e=0,t.d=[0];return t}function Or(t,e,n){var r,i,s,o,l,c,u,d,h=t.d;for(o=1,s=h[0];s>=10;s/=10)o++;if(r=e-o,r<0)r+=Wr,i=e,u=h[d=0];else{if(d=Math.ceil((r+1)/Wr),s=h.length,d>=s)return t;for(u=s=h[d],o=1;s>=10;s/=10)o++;r%=Wr,i=r-Wr+o}if(n!==void 0&&(s=Mf(10,o-i-1),l=u/s%10|0,c=e<0||h[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/Mf(10,o-i):0:h[d-1])%10&1||n==(t.s<0?8:7))),e<1||!h[0])return c?(s=qi(t),h.length=1,e=e-s-1,h[0]=Mf(10,(Wr-e%Wr)%Wr),t.e=jx(-e/Wr)||0):(h.length=1,h[0]=t.e=t.s=0),t;if(r==0?(h.length=d,s=1,d--):(h.length=d+1,s=Mf(10,Wr-r),h[d]=i>0?(u/Mf(10,o-i)%Mf(10,i)|0)*s:0),c)for(;;)if(d==0){(h[0]+=s)==ba&&(h[0]=1,++t.e);break}else{if(h[d]+=s,h[d]!=ba)break;h[d--]=0,s=1}for(r=h.length;h[--r]===0;)h.pop();if(ni&&(t.e>$S||t.e<-$S))throw Error(d4+qi(t));return t}function WQ(t,e){var n,r,i,s,o,l,c,u,d,h,p=t.constructor,m=p.precision;if(!t.s||!e.s)return e.s?e.s=-e.s:e=new p(t),ni?Or(e,m):e;if(c=t.d,h=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=h.length):(n=h,r=u,l=c.length),i=Math.max(Math.ceil(m/Wr),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=h.length,d=i<l,d&&(l=i),i=0;i<l;i++)if(c[i]!=h[i]){d=c[i]<h[i];break}o=0}for(d&&(n=c,c=h,h=n,e.s=-e.s),l=c.length,i=h.length-l;i>0;--i)c[l++]=0;for(i=h.length;i>o;){if(c[--i]<h[i]){for(s=i;s&&c[--s]===0;)c[s]=ba-1;--c[s],c[i]+=ba}c[i]-=h[i]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,ni?Or(e,m):e):new p(0)}function ym(t,e,n){var r,i=qi(t),s=hc(t.d),o=s.length;return e?(n&&(r=n-o)>0?s=s.charAt(0)+"."+s.slice(1)+Hd(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(i<0?"e":"e+")+i):i<0?(s="0."+Hd(-i-1)+s,n&&(r=n-o)>0&&(s+=Hd(r))):i>=o?(s+=Hd(i+1-o),n&&(r=n-i-1)>0&&(s=s+"."+Hd(r))):((r=i+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(s+="."),s+=Hd(r))),t.s<0?"-"+s:s}function $V(t,e){if(t.length>e)return t.length=e,!0}function KQ(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(Xf+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 HV(o,s.toString())}else if(typeof s!="string")throw Error(Xf+s);if(s.charCodeAt(0)===45?(s=s.slice(1),o.s=-1):o.s=1,D3e.test(s))HV(o,s);else throw Error(Xf+s)}if(i.prototype=$t,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=KQ,i.config=i.set=R3e,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 R3e(t){if(!t||typeof t!="object")throw Error(ml+"Object expected");var e,n,r,i=["precision",1,Cx,"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(jx(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Xf+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Xf+n+": "+r);return this}var h4=KQ(P3e);fo=new h4(1);const br=h4;var O3e=t=>t,XQ={},YQ=t=>t===XQ,VV=t=>function e(){return arguments.length===0||arguments.length===1&&YQ(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},QQ=(t,e)=>t===1?e:VV(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!==XQ).length;return s>=t?e(...r):QQ(t-s,VV(function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];var u=r.map(d=>YQ(d)?l.shift():d);return e(...u,...l)}))}),L3e=t=>QQ(t.length,t),uD=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},F3e=L3e((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),I3e=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return O3e;var i=n.reverse(),s=i[0],o=i.slice(1);return function(){return o.reduce((l,c)=>c(l),s(...arguments))}},dD=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function ZQ(t){var e;return t===0?e=1:e=Math.floor(new br(t).abs().log(10).toNumber())+1,e}function JQ(t,e,n){for(var r=new br(t),i=0,s=[];r.lt(e)&&i<1e5;)s.push(r.toNumber()),r=r.add(n),i++;return s}var eZ=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},tZ=(t,e,n)=>{if(t.lte(0))return new br(0);var r=ZQ(t.toNumber()),i=new br(10).pow(r),s=t.div(i),o=r!==1?.05:.1,l=new br(Math.ceil(s.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new br(c.toNumber()):new br(Math.ceil(c.toNumber()))},U3e=(t,e,n)=>{var r=new br(1),i=new br(t);if(!i.isint()&&n){var s=Math.abs(t);s<1?(r=new br(10).pow(ZQ(t)-1),i=new br(Math.floor(i.div(r).toNumber())).mul(r)):s>1&&(i=new br(Math.floor(t)))}else t===0?i=new br(Math.floor((e-1)/2)):n||(i=new br(Math.floor(t)));var o=Math.floor((e-1)/2),l=I3e(F3e(c=>i.add(new br(c-o).mul(r)).toNumber()),uD);return l(0,e)},nZ=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 br(0),tickMin:new br(0),tickMax:new br(0)};var o=tZ(new br(n).sub(e).div(r-1),i,s),l;e<=0&&n>=0?l=new br(0):(l=new br(e).add(n).div(2),l=l.sub(new br(l).mod(o)));var c=Math.ceil(l.sub(e).div(o).toNumber()),u=Math.ceil(new br(n).sub(l).div(o).toNumber()),d=c+u+1;return d>r?nZ(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 br(c).mul(o)),tickMax:l.add(new br(u).mul(o))})},z3e=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]=eZ([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...uD(0,i-1).map(()=>1/0)]:[...uD(0,i-1).map(()=>-1/0),c];return n>r?dD(u):u}if(l===c)return U3e(l,i,s);var{step:d,tickMin:h,tickMax:p}=nZ(l,c,o,s,0),m=JQ(h,p.add(new br(.1).mul(d)),d);return n>r?dD(m):m},B3e=function(e,n){var[r,i]=e,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=eZ([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=tZ(new br(l).sub(o).div(c-1),s,0),d=[...JQ(new br(o),new br(l),u),l];return s===!1&&(d=d.map(h=>Math.round(h))),r>i?dD(d):d},rZ=t=>t.rootProps.maxBarSize,H3e=t=>t.rootProps.barGap,iZ=t=>t.rootProps.barCategoryGap,$3e=t=>t.rootProps.barSize,iv=t=>t.rootProps.stackOffset,aZ=t=>t.rootProps.reverseStackOrder,f4=t=>t.options.chartName,m4=t=>t.rootProps.syncId,sZ=t=>t.rootProps.syncMethod,p4=t=>t.options.eventEmitter,V3e=t=>t.rootProps.baseValue,vi={grid:-100,barBackground:-50,area:100,cursorRectangle:200,bar:300,line:400,axis:500,scatter:600,activeBar:1e3,cursorLine:1100,activeDot:1200,label:2e3},gu={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},uo={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},r2=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},G3e={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:gu.angleAxisId,includeHidden:!1,name:void 0,reversed:gu.reversed,scale:gu.scale,tick:gu.tick,tickCount:void 0,ticks:void 0,type:gu.type,unit:void 0},q3e={allowDataOverflow:uo.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:uo.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:uo.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:uo.scale,tick:uo.tick,tickCount:uo.tickCount,ticks:void 0,type:uo.type,unit:void 0},W3e={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:gu.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:gu.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:gu.scale,tick:gu.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},K3e={allowDataOverflow:uo.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:uo.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:uo.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:uo.scale,tick:uo.tick,tickCount:uo.tickCount,ticks:void 0,type:"category",unit:void 0},g4=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?W3e:G3e,x4=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?K3e:q3e,i2=t=>t.polarOptions,b4=st([Wu,Ku,aa],iQ),oZ=st([i2,b4],(t,e)=>{if(t!=null)return ts(t.innerRadius,e,0)}),lZ=st([i2,b4],(t,e)=>{if(t!=null)return ts(t.outerRadius,e,e*.8)}),X3e=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},cZ=st([i2],X3e);st([g4,cZ],r2);var uZ=st([b4,oZ,lZ],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});st([x4,uZ],r2);var dZ=st([$n,i2,oZ,lZ,Wu,Ku],(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:ts(o,i,i/2),cy:ts(l,s,s/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),ii=(t,e)=>e,av=(t,e,n)=>n;function a2(t){return t?.id}function hZ(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=a2(l);u.forEach((h,p)=>{var m=s==null||i?p:String(yr(h,s,null)),x=yr(h,l.dataKey,0),y;o.has(m)?y=o.get(m):y={},Object.assign(y,{[d]:x}),o.set(m,y)})}}),Array.from(o.values())}function s2(t){return t.stackId!=null&&t.dataKey!=null}var o2=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function l2(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function Y3e(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 la=t=>{var e=$n(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},Px=t=>t.tooltip.settings.axisId;function GV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function VS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?GV(Object(n),!0).forEach(function(r){Q3e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):GV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Q3e(t,e,n){return(e=Z3e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Z3e(t){var e=J3e(t,"string");return typeof e=="symbol"?e:e+""}function J3e(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 hD=[0,"auto"],ga={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},fZ=(t,e)=>t.cartesianAxis.xAxis[e],Cc=(t,e)=>{var n=fZ(t,e);return n??ga},xa={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:hD,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:Yy},mZ=(t,e)=>t.cartesianAxis.yAxis[e],jc=(t,e)=>{var n=mZ(t,e);return n??xa},eDe={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:""},y4=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??eDe},ui=(t,e,n)=>{switch(e){case"xAxis":return Cc(t,n);case"yAxis":return jc(t,n);case"zAxis":return y4(t,n);case"angleAxis":return g4(t,n);case"radiusAxis":return x4(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},tDe=(t,e,n)=>{switch(e){case"xAxis":return Cc(t,n);case"yAxis":return jc(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},sv=(t,e,n)=>{switch(e){case"xAxis":return Cc(t,n);case"yAxis":return jc(t,n);case"angleAxis":return g4(t,n);case"radiusAxis":return x4(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},pZ=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function v4(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 ov=t=>t.graphicalItems.cartesianItems,nDe=st([ii,av],v4),w4=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),lv=st([ov,ui,nDe],w4,{memoizeOptions:{resultEqualityCheck:l2}}),gZ=st([lv],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(s2)),xZ=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),rDe=st([lv],xZ),_4=t=>t.map(e=>e.data).filter(Boolean).flat(1),iDe=st([lv],_4,{memoizeOptions:{resultEqualityCheck:l2}}),S4=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},N4=st([iDe,rv],S4),M4=(t,e,n)=>e?.dataKey!=null?t.map(r=>({value:yr(r,e.dataKey)})):n.length>0?n.map(r=>r.dataKey).flatMap(r=>t.map(i=>({value:yr(i,r)}))):t.map(r=>({value:r})),c2=st([N4,ui,lv],M4);function bZ(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function P1(t){if(hl(t)||t instanceof Date){var e=Number(t);if(vr(e))return e}}function qV(t){if(Array.isArray(t)){var e=[P1(t[0]),P1(t[1])];return Th(e)?e:void 0}var n=P1(t);if(n!=null)return[n,n]}function Vu(t){return t.map(P1).filter(tke)}function aDe(t,e,n){return!n||typeof e!="number"||qs(e)?[]:n.length?Vu(n.flatMap(r=>{var i=yr(t,r.dataKey),s,o;if(Array.isArray(i)?[s,o]=i:s=o=i,!(!vr(s)||!vr(o)))return[e-s,e+o]})):[]}var ca=t=>{var e=la(t),n=Px(t);return sv(t,e,n)},cv=st([ca],t=>t?.dataKey),sDe=st([gZ,rv,ca],hZ),yZ=(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(a2);return[l,{stackedData:MTe(t,d,n),graphicalItems:u}]}))},yy=st([sDe,gZ,iv,aZ],yZ),vZ=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:s}=e;if(r==null&&n!=="zAxis"){var o=ATe(t,i,s);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},oDe=st([ui],t=>t.allowDataOverflow),k4=t=>{var e;if(t==null||!("domain"in t))return hD;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Vu(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:hD},E4=st([ui],k4),T4=st([E4,oDe],$Q),lDe=st([yy,Bh,ii,T4],vZ,{memoizeOptions:{resultEqualityCheck:o2}}),u2=t=>t.errorBars,cDe=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>bZ(n,r)),GS=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]}},A4=(t,e,n,r,i)=>{var s,o;if(n.length>0&&t.forEach(l=>{n.forEach(c=>{var u,d,h=(u=r[c.id])===null||u===void 0?void 0:u.filter(b=>bZ(i,b)),p=yr(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),m=aDe(l,p,h);if(m.length>=2){var x=Math.min(...m),y=Math.max(...m);(s==null||x<s)&&(s=x),(o==null||y>o)&&(o=y)}var v=qV(p);v!=null&&(s=s==null?v[0]:Math.min(s,v[0]),o=o==null?v[1]:Math.max(o,v[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=qV(yr(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]))}),vr(s)&&vr(o))return[s,o]},uDe=st([N4,ui,rDe,u2,ii],A4,{memoizeOptions:{resultEqualityCheck:o2}});function dDe(t){var{value:e}=t;if(hl(e)||e instanceof Date)return e}var hDe=(t,e,n)=>{var r=t.map(dDe).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&OX(r))?lQ(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},wZ=t=>t.referenceElements.dots,Dx=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),fDe=st([wZ,ii,av],Dx),_Z=t=>t.referenceElements.areas,mDe=st([_Z,ii,av],Dx),SZ=t=>t.referenceElements.lines,pDe=st([SZ,ii,av],Dx),NZ=(t,e)=>{var n=Vu(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},gDe=st(fDe,ii,NZ),MZ=(t,e)=>{var n=Vu(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)]},xDe=st([mDe,ii],MZ);function bDe(t){var e;if(t.x!=null)return Vu([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Vu(n)}function yDe(t){var e;if(t.y!=null)return Vu([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Vu(n)}var kZ=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?bDe(r):yDe(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},vDe=st([pDe,ii],kZ),wDe=st(gDe,vDe,xDe,(t,e,n)=>GS(t,n,e)),C4=(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?GS(r,s,i):GS(s,i);return j3e(e,u,t.allowDataOverflow)},_De=st([ui,E4,T4,lDe,uDe,wDe,$n,ii],C4,{memoizeOptions:{resultEqualityCheck:o2}}),SDe=[0,1],j4=(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=Ac(e,s);if(u&&l==null){var d;return lQ(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?hDe(r,t,u):i==="expand"?SDe:o}},P4=st([ui,$n,N4,c2,iv,ii,_De],j4),EZ=(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(Vy(s));return l in u0?l:"point"}}},Rx=st([ui,$n,pZ,f4,ii],EZ);function NDe(t){if(t!=null){if(t in u0)return u0[t]();var e="scale".concat(Vy(t));if(e in u0)return u0[e]()}}function D4(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=NDe(e);if(i!=null){var s=i.domain(n).range(r);return vTe(s),s}}}var R4=(t,e,n)=>{var r=k4(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&Th(t))return z3e(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&Th(t))return B3e(t,e.tickCount,e.allowDecimals)}},O4=st([P4,sv,Rx],R4),L4=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&Th(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},MDe=st([ui,P4,O4,ii],L4),kDe=st(c2,ui,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Vu(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}}),TZ=st(kDe,$n,iZ,aa,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!vr(t))return 0;var s=e==="vertical"?r.height:r.width;if(i==="gap")return t*s/2;if(i==="no-gap"){var o=ts(n,t*s),l=t*s/2;return l-o-(l-o)/s*o}return 0}),EDe=(t,e)=>{var n=Cc(t,e);return n==null||typeof n.padding!="string"?0:TZ(t,"xAxis",e,n.padding)},TDe=(t,e)=>{var n=jc(t,e);return n==null||typeof n.padding!="string"?0:TZ(t,"yAxis",e,n.padding)},ADe=st(Cc,EDe,(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}}),CDe=st(jc,TDe,(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}}),jDe=st([aa,ADe,qM,GM,(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]}),PDe=st([aa,$n,CDe,qM,GM,(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]}),uv=(t,e,n,r)=>{var i;switch(e){case"xAxis":return jDe(t,n,r);case"yAxis":return PDe(t,n,r);case"zAxis":return(i=y4(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return cZ(t);case"radiusAxis":return uZ(t,n);default:return}},AZ=st([ui,uv],r2),Ah=st([ui,Rx,MDe,AZ],D4);st([lv,u2,ii],cDe);function CZ(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var d2=(t,e)=>e,h2=(t,e,n)=>n,DDe=st($M,d2,h2,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(CZ)),RDe=st(VM,d2,h2,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(CZ)),jZ=(t,e)=>({width:t.width,height:e.height}),ODe=(t,e)=>{var n=typeof e.width=="number"?e.width:Yy;return{width:n,height:t.height}},PZ=st(aa,Cc,jZ),LDe=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},FDe=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},IDe=st(Ku,aa,DDe,d2,h2,(t,e,n,r,i)=>{var s={},o;return n.forEach(l=>{var c=jZ(e,l);o==null&&(o=LDe(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}),UDe=st(Wu,aa,RDe,d2,h2,(t,e,n,r,i)=>{var s={},o;return n.forEach(l=>{var c=ODe(e,l);o==null&&(o=FDe(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}),zDe=(t,e)=>{var n=Cc(t,e);if(n!=null)return IDe(t,n.orientation,n.mirror)},BDe=st([aa,Cc,zDe,(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}}}),HDe=(t,e)=>{var n=jc(t,e);if(n!=null)return UDe(t,n.orientation,n.mirror)},$De=st([aa,jc,HDe,(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}}}),DZ=st(aa,jc,(t,e)=>{var n=typeof e.width=="number"?e.width:Yy;return{width:n,height:t.height}}),WV=(t,e,n)=>{switch(e){case"xAxis":return PZ(t,n).width;case"yAxis":return DZ(t,n).height;default:return}},RZ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:s,dataKey:o}=n,l=Ac(t,r),c=e.map(u=>u.value);if(o&&l&&s==="category"&&i&&OX(c))return c}},F4=st([$n,c2,ui,ii],RZ),OZ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:s}=n,o=Ac(t,r);if(o&&(i==="number"||s!=="auto"))return e.map(l=>l.value)}},I4=st([$n,c2,sv,ii],OZ),KV=st([$n,tDe,Rx,Ah,F4,I4,uv,O4,ii],(t,e,n,r,i,s,o,l,c)=>{if(e!=null){var u=Ac(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}}}),VDe=(t,e,n,r,i,s,o,l,c)=>{if(!(e==null||r==null)){var u=Ac(t,c),{type:d,ticks:h,tickCount:p}=e,m=n==="scaleBand"&&typeof r.bandwidth=="function"?r.bandwidth()/2:2,x=d==="category"&&r.bandwidth?r.bandwidth()/m:0;x=c==="angleAxis"&&s!=null&&s.length>=2?_a(s[0]-s[1])*2*x:x;var y=h||i;if(y){var v=y.map((b,S)=>{var N=o?o.indexOf(b):b;return{index:S,coordinate:r(N)+x,value:b,offset:x}});return v.filter(b=>vr(b.coordinate))}return u&&l?l.map((b,S)=>({coordinate:r(b)+x,value:b,index:S,offset:x})).filter(b=>vr(b.coordinate)):r.ticks?r.ticks(p).map(b=>({coordinate:r(b)+x,value:b,offset:x})):r.domain().map((b,S)=>({coordinate:r(b)+x,value:o?o[b]:b,index:S,offset:x}))}},LZ=st([$n,sv,Rx,Ah,O4,uv,F4,I4,ii],VDe),GDe=(t,e,n,r,i,s,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=Ac(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?_a(r[0]-r[1])*2*u:u,l&&s?s.map((d,h)=>({coordinate:n(d)+u,value:d,index:h,offset:u})):n.ticks?n.ticks(c).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,h)=>({coordinate:n(d)+u,value:i?i[d]:d,index:h,offset:u}))}},_c=st([$n,sv,Ah,uv,F4,I4,ii],GDe),Sc=st(ui,Ah,(t,e)=>{if(!(t==null||e==null))return VS(VS({},t),{},{scale:e})}),qDe=st([ui,Rx,P4,AZ],D4);st((t,e,n)=>y4(t,n),qDe,(t,e)=>{if(!(t==null||e==null))return VS(VS({},t),{},{scale:e})});var WDe=st([$n,$M,VM],(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}}),FZ=t=>t.options.defaultTooltipEventType,IZ=t=>t.options.validateTooltipEventTypes;function UZ(t,e,n){if(t==null)return e;var r=t?"axis":"item";return n==null?e:n.includes(r)?r:e}function U4(t,e){var n=FZ(t),r=IZ(t);return UZ(e,n,r)}function KDe(t){return Ut(e=>U4(e,t))}var zZ=(t,e)=>{var n,r=Number(e);if(!(qs(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},XDe=t=>t.tooltip.settings,Xd={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},YDe={itemInteraction:{click:Xd,hover:Xd},axisInteraction:{click:Xd,hover:Xd},keyboardInteraction:Xd,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}},BZ=Ws({name:"tooltip",initialState:YDe,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:Jr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Il(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Jr()},removeTooltipEntrySettings:{reducer(t,e){var n=Il(t).tooltipItemPayloads.indexOf(e.payload);n>-1&&t.tooltipItemPayloads.splice(n,1)},prepare:Jr()},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:QDe,replaceTooltipEntrySettings:ZDe,removeTooltipEntrySettings:JDe,setTooltipSettingsState:eRe,setActiveMouseOverItemIndex:HZ,mouseLeaveItem:tRe,mouseLeaveChart:$Z,setActiveClickItemIndex:nRe,setMouseOverAxisIndex:VZ,setMouseClickAxisIndex:rRe,setSyncInteraction:fD,setKeyboardInteraction:mD}=BZ.actions,iRe=BZ.reducer;function XV(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 X_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?XV(Object(n),!0).forEach(function(r){aRe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):XV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function aRe(t,e,n){return(e=sRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sRe(t){var e=oRe(t,"string");return typeof e=="symbol"?e:e+""}function oRe(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 lRe(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function cRe(t){return t.index!=null}var GZ=(t,e,n,r)=>{if(e==null)return Xd;var i=lRe(t,e,n);if(i==null)return Xd;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(cRe(i)){if(s)return X_(X_({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return X_(X_({},Xd),{},{coordinate:i.coordinate})};function uRe(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 dRe(t,e){var n=uRe(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 hRe(t,e,n){if(n==null||e==null)return!0;var r=yr(t,e);return r==null||!Th(n)?!0:dRe(r,n)}var z4=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var s=Number(i);if(!vr(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||hRe(u,n,r)?String(c):null},qZ=(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}}}},WZ=(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})},dv=t=>t.options.tooltipPayloadSearcher,Ox=t=>t.tooltip;function YV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function QV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?YV(Object(n),!0).forEach(function(r){fRe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):YV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fRe(t,e,n){return(e=mRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mRe(t){var e=pRe(t,"string");return typeof e=="symbol"?e:e+""}function pRe(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 gRe(t,e){return t??e}var KZ=(t,e,n,r,i,s,o)=>{if(!(e==null||s==null)){var{chartData:l,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,h=[];return t.reduce((p,m)=>{var x,{dataDefinedOnItem:y,settings:v}=m,b=gRe(y,l),S=Array.isArray(b)?CY(b,u,d):b,N=(x=v?.dataKey)!==null&&x!==void 0?x:r,T=v?.nameKey,k;if(r&&Array.isArray(S)&&!Array.isArray(S[0])&&o==="axis"?k=LX(S,r,i):k=s(S,e,c,T),Array.isArray(k))k.forEach(E=>{var P=QV(QV({},v),{},{name:E.name,unit:E.unit,color:void 0,fill:void 0});p.push(x$({tooltipEntrySettings:P,dataKey:E.dataKey,payload:E.payload,value:yr(E.payload,E.dataKey),name:E.name}))});else{var C;p.push(x$({tooltipEntrySettings:v,dataKey:N,payload:k,value:yr(k,N),name:(C=yr(k,T))!==null&&C!==void 0?C:v?.name}))}return p},h)}},B4=st([ca,$n,pZ,f4,la],EZ),xRe=st([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),bRe=st([la,Px],v4),hv=st([xRe,ca,bRe],w4,{memoizeOptions:{resultEqualityCheck:l2}}),yRe=st([hv],t=>t.filter(s2)),vRe=st([hv],_4,{memoizeOptions:{resultEqualityCheck:l2}}),Lx=st([vRe,Bh],S4),wRe=st([yRe,Bh,ca],hZ),H4=st([Lx,ca,hv],M4),XZ=st([ca],k4),_Re=st([ca],t=>t.allowDataOverflow),YZ=st([XZ,_Re],$Q),SRe=st([hv],t=>t.filter(s2)),NRe=st([wRe,SRe,iv,aZ],yZ),MRe=st([NRe,Bh,la,YZ],vZ),kRe=st([hv],xZ),ERe=st([Lx,ca,kRe,u2,la],A4,{memoizeOptions:{resultEqualityCheck:o2}}),TRe=st([wZ,la,Px],Dx),ARe=st([TRe,la],NZ),CRe=st([_Z,la,Px],Dx),jRe=st([CRe,la],MZ),PRe=st([SZ,la,Px],Dx),DRe=st([PRe,la],kZ),RRe=st([ARe,DRe,jRe],GS),ORe=st([ca,XZ,YZ,MRe,ERe,RRe,$n,la],C4),fv=st([ca,$n,Lx,H4,iv,la,ORe],j4),LRe=st([fv,ca,B4],R4),FRe=st([ca,fv,LRe,la],L4),QZ=t=>{var e=la(t),n=Px(t),r=!1;return uv(t,e,n,r)},ZZ=st([ca,QZ],r2),JZ=st([ca,B4,FRe,ZZ],D4),IRe=st([$n,H4,ca,la],RZ),URe=st([$n,H4,ca,la],OZ),zRe=(t,e,n,r,i,s,o,l)=>{if(e){var{type:c}=e,u=Ac(t,l);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,h=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return h=l==="angleAxis"&&i!=null&&i?.length>=2?_a(i[0]-i[1])*2*h:h,u&&o?o.map((p,m)=>({coordinate:r(p)+h,value:p,index:m,offset:h})):r.domain().map((p,m)=>({coordinate:r(p)+h,value:s?s[p]:p,index:m,offset:h}))}}},Yu=st([$n,ca,B4,JZ,QZ,IRe,URe,la],zRe),$4=st([FZ,IZ,XDe],(t,e,n)=>UZ(n.shared,t,e)),eJ=t=>t.tooltip.settings.trigger,V4=t=>t.tooltip.settings.defaultIndex,mv=st([Ox,$4,eJ,V4],GZ),Ch=st([mv,Lx,cv,fv],z4),tJ=st([Yu,Ch],zZ),G4=st([mv],t=>{if(t)return t.dataKey}),BRe=st([mv],t=>{if(t)return t.graphicalItemId}),nJ=st([Ox,$4,eJ,V4],WZ),HRe=st([Wu,Ku,$n,aa,Yu,V4,nJ,dv],qZ),$Re=st([mv,HRe],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),VRe=st([mv],t=>t.active),GRe=st([nJ,Ch,Bh,cv,tJ,dv,$4],KZ),qRe=st([GRe],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function ZV(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function JV(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ZV(Object(n),!0).forEach(function(r){WRe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ZV(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function WRe(t,e,n){return(e=KRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function KRe(t){var e=XRe(t,"string");return typeof e=="symbol"?e:e+""}function XRe(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 YRe=()=>Ut(ca),QRe=()=>{var t=YRe(),e=Ut(Yu),n=Ut(JZ);return Eh(!t||!n?void 0:JV(JV({},t),{},{scale:n}),e)};function eG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Zp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?eG(Object(n),!0).forEach(function(r){ZRe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):eG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZRe(t,e,n){return(e=JRe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function JRe(t){var e=eOe(t,"string");return typeof e=="symbol"?e:e+""}function eOe(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 tOe=(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}},nOe=(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 Zp(Zp(Zp({},r),Hi(r.cx,r.cy,o,s)),{},{angle:s,radius:o})}var l=i.coordinate,{angle:c}=r;return Zp(Zp(Zp({},r),Hi(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 rOe(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 rJ=(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,h=c>=l-1?n[0].coordinate:n[c+1].coordinate,p=void 0;if(_a(d-u)!==_a(h-d)){var m=[];if(_a(h-d)===_a(i[1]-i[0])){p=h;var x=d+i[1]-i[0];m[0]=Math.min(x,(x+u)/2),m[1]=Math.max(x,(x+u)/2)}else{p=u;var y=h+i[1]-i[0];m[0]=Math.min(d,(y+d)/2),m[1]=Math.max(d,(y+d)/2)}var v=[Math.min(d,(p+d)/2),Math.max(d,(p+d)/2)];if(t>v[0]&&t<=v[1]||t>=m[0]&&t<=m[1]){({index:o}=n[c]);break}}else{var b=Math.min(u,h),S=Math.max(u,h);if(t>(b+d)/2&&t<=(S+d)/2){({index:o}=n[c]);break}}}else if(e){for(var N=0;N<l;N++)if(N===0&&t<=(e[N].coordinate+e[N+1].coordinate)/2||N>0&&N<l-1&&t>(e[N].coordinate+e[N-1].coordinate)/2&&t<=(e[N].coordinate+e[N+1].coordinate)/2||N===l-1&&t>(e[N].coordinate+e[N-1].coordinate)/2){({index:o}=e[N]);break}}return o},iJ=()=>Ut(f4),q4=(t,e)=>e,aJ=(t,e,n)=>n,W4=(t,e,n,r)=>r,iOe=st(Yu,t=>RM(t,e=>e.coordinate)),K4=st([Ox,q4,aJ,W4],GZ),X4=st([K4,Lx,cv,fv],z4),aOe=(t,e,n)=>{if(e!=null){var r=Ox(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},sJ=st([Ox,q4,aJ,W4],WZ),qS=st([Wu,Ku,$n,aa,Yu,W4,sJ,dv],qZ),sOe=st([K4,qS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),oJ=st([Yu,X4],zZ),oOe=st([sJ,X4,Bh,cv,oJ,dv,q4],KZ),lOe=st([K4,X4],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),cOe=(t,e,n,r,i,s,o)=>{if(!(!t||!n||!r||!i)&&rOe(t,o)){var l=CTe(t,e),c=rJ(l,s,i,n,r),u=tOe(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},uOe=(t,e,n,r,i,s,o)=>{if(!(!t||!r||!i||!s||!n)){var l=WCe(t,n);if(l){var c=jTe(l,e),u=rJ(c,o,s,r,i),d=nOe(e,s,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},dOe=(t,e,n,r,i,s,o,l)=>{if(!(!t||!e||!r||!i||!s))return e==="horizontal"||e==="vertical"?cOe(t,e,r,i,s,o,l):uOe(t,e,n,r,i,s,o)},hOe=st(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}}),fOe=st(t=>t.zIndex.zIndexMap,t=>{var e=Object.keys(t).map(r=>parseInt(r,10)).concat(Object.values(vi)),n=Array.from(new Set(e));return n.sort((r,i)=>r-i)},{memoizeOptions:{resultEqualityCheck:Y3e}});function tG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function nG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?tG(Object(n),!0).forEach(function(r){mOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):tG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function mOe(t,e,n){return(e=pOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pOe(t){var e=gOe(t,"string");return typeof e=="symbol"?e:e+""}function gOe(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 xOe={},bOe={zIndexMap:Object.values(vi).reduce((t,e)=>nG(nG({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),xOe)},yOe=new Set(Object.values(vi));function vOe(t){return yOe.has(t)}var lJ=Ws({name:"zIndex",initialState:bOe,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:Jr()},unregisterZIndexPortal:{reducer:(t,e)=>{var{zIndex:n}=e.payload;t.zIndexMap[n]&&(t.zIndexMap[n].consumers-=1,t.zIndexMap[n].consumers<=0&&!vOe(n)&&delete t.zIndexMap[n])},prepare:Jr()},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:Jr()},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:Jr()}}}),{registerZIndexPortal:wOe,unregisterZIndexPortal:_Oe,registerZIndexPortalId:SOe,unregisterZIndexPortalId:NOe}=lJ.actions,MOe=lJ.reducer;function rs(t){var{zIndex:e,children:n}=t,r=cAe(),i=r&&e!==void 0&&e!==0,s=sa(),o=Lr();_.useLayoutEffect(()=>i?(o(wOe({zIndex:e})),()=>{o(_Oe({zIndex:e}))}):Gy,[o,e,i]);var l=Ut(u=>hOe(u,e,s));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?bu.createPortal(n,c):null}function pD(){return pD=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},pD.apply(null,arguments)}function rG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Y_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?rG(Object(n),!0).forEach(function(r){kOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):rG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function kOe(t,e,n){return(e=EOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function EOe(t){var e=TOe(t,"string");return typeof e=="symbol"?e:e+""}function TOe(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 AOe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return _.isValidElement(e)?_.cloneElement(e,r):_.createElement(n,r)}function COe(t){var e,{coordinate:n,payload:r,index:i,offset:s,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,h=n,p=r,m=i;if(!c||!h||d!=="ScatterChart"&&u!=="axis")return null;var x,y,v;if(d==="ScatterChart")x=h,y=lCe,v=vi.cursorLine;else if(d==="BarChart")x=cCe(l,h,s,o),y=rQ,v=vi.cursorRectangle;else if(l==="radial"&&IX(h)){var{cx:b,cy:S,radius:N,startAngle:T,endAngle:k}=aQ(h);x={cx:b,cy:S,startAngle:T,endAngle:k,innerRadius:N,outerRadius:N},y=oQ,v=vi.cursorLine}else x={points:QCe(l,h,s)},y=Rg,v=vi.cursorLine;var C=typeof c=="object"&&"className"in c?c.className:void 0,E=Y_(Y_(Y_(Y_({stroke:"#ccc",pointerEvents:"none"},s),x),pm(c)),{},{payload:p,payloadIndex:m,className:nr("recharts-tooltip-cursor",C)});return _.createElement(rs,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:v},_.createElement(AOe,{cursor:c,cursorComp:y,cursorProps:E}))}function jOe(t){var e=QRe(),n=BY(),r=Cm(),i=iJ();return e==null||n==null||r==null||i==null?null:_.createElement(COe,pD({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var cJ=_.createContext(null),POe=()=>_.useContext(cJ),HC={exports:{}},iG;function DOe(){return iG||(iG=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,h,p){if(typeof d!="function")throw new TypeError("The listener must be a function");var m=new i(d,h||c,p),x=n?n+u:u;return c._events[x]?c._events[x].fn?c._events[x]=[c._events[x],m]:c._events[x].push(m):(c._events[x]=m,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,h;if(this._eventsCount===0)return u;for(h in d=this._events)e.call(d,h)&&u.push(n?h.slice(1):h);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},l.prototype.listeners=function(u){var d=n?n+u:u,h=this._events[d];if(!h)return[];if(h.fn)return[h.fn];for(var p=0,m=h.length,x=new Array(m);p<m;p++)x[p]=h[p].fn;return x},l.prototype.listenerCount=function(u){var d=n?n+u:u,h=this._events[d];return h?h.fn?1:h.length:0},l.prototype.emit=function(u,d,h,p,m,x){var y=n?n+u:u;if(!this._events[y])return!1;var v=this._events[y],b=arguments.length,S,N;if(v.fn){switch(v.once&&this.removeListener(u,v.fn,void 0,!0),b){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,d),!0;case 3:return v.fn.call(v.context,d,h),!0;case 4:return v.fn.call(v.context,d,h,p),!0;case 5:return v.fn.call(v.context,d,h,p,m),!0;case 6:return v.fn.call(v.context,d,h,p,m,x),!0}for(N=1,S=new Array(b-1);N<b;N++)S[N-1]=arguments[N];v.fn.apply(v.context,S)}else{var T=v.length,k;for(N=0;N<T;N++)switch(v[N].once&&this.removeListener(u,v[N].fn,void 0,!0),b){case 1:v[N].fn.call(v[N].context);break;case 2:v[N].fn.call(v[N].context,d);break;case 3:v[N].fn.call(v[N].context,d,h);break;case 4:v[N].fn.call(v[N].context,d,h,p);break;default:if(!S)for(k=1,S=new Array(b-1);k<b;k++)S[k-1]=arguments[k];v[N].fn.apply(v[N].context,S)}}return!0},l.prototype.on=function(u,d,h){return s(this,u,d,h,!1)},l.prototype.once=function(u,d,h){return s(this,u,d,h,!0)},l.prototype.removeListener=function(u,d,h,p){var m=n?n+u:u;if(!this._events[m])return this;if(!d)return o(this,m),this;var x=this._events[m];if(x.fn)x.fn===d&&(!p||x.once)&&(!h||x.context===h)&&o(this,m);else{for(var y=0,v=[],b=x.length;y<b;y++)(x[y].fn!==d||p&&!x[y].once||h&&x[y].context!==h)&&v.push(x[y]);v.length?this._events[m]=v.length===1?v[0]:v:o(this,m)}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})(HC)),HC.exports}var ROe=DOe();const OOe=pl(ROe);var vy=new OOe,gD="recharts.syncEvent.tooltip",aG="recharts.syncEvent.brush";function f2(t,e){if(e){var n=Number.parseInt(e,10);if(!qs(n))return t?.[n]}}var LOe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},uJ=Ws({name:"options",initialState:LOe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),FOe=uJ.reducer,{createEventEmitter:IOe}=uJ.actions;function UOe(t){return t.tooltip.syncInteraction}var zOe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},dJ=Ws({name:"chartData",initialState:zOe,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:sG,setDataStartEndIndexes:BOe,setComputedData:JYe}=dJ.actions,HOe=dJ.reducer,$Oe=["x","y"];function oG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Jp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?oG(Object(n),!0).forEach(function(r){VOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):oG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function VOe(t,e,n){return(e=GOe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function GOe(t){var e=qOe(t,"string");return typeof e=="symbol"?e:e+""}function qOe(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 WOe(t,e){if(t==null)return{};var n,r,i=KOe(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 KOe(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 XOe(){var t=Ut(m4),e=Ut(p4),n=Lr(),r=Ut(sZ),i=Ut(Yu),s=Cm(),o=Qy(),l=Ut(c=>c.rootProps.className);_.useEffect(()=>{if(t==null)return Gy;var c=(u,d,h)=>{if(e!==h&&t===u){if(r==="index"){var p;if(o&&d!==null&&d!==void 0&&(p=d.payload)!==null&&p!==void 0&&p.coordinate&&d.payload.sourceViewBox){var m=d.payload.coordinate,{x,y}=m,v=WOe(m,$Oe),{x:b,y:S,width:N,height:T}=d.payload.sourceViewBox,k=Jp(Jp({},v),{},{x:o.x+(N?(x-b)/N:0)*o.width,y:o.y+(T?(y-S)/T:0)*o.height});n(Jp(Jp({},d),{},{payload:Jp(Jp({},d.payload),{},{coordinate:k})}))}else n(d);return}if(i!=null){var C;if(typeof r=="function"){var E={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},P=r(i,E);C=i[P]}else r==="value"&&(C=i.find(K=>String(K.value)===d.payload.label));var{coordinate:A}=d.payload;if(C==null||d.payload.active===!1||A==null||o==null){n(fD({active:!1,coordinate:void 0,dataKey:void 0,index:null,label:void 0,sourceViewBox:void 0,graphicalItemId:void 0}));return}var{x:D,y:I}=A,L=Math.min(D,o.x+o.width),U=Math.min(I,o.y+o.height),j={x:s==="horizontal"?C.coordinate:L,y:s==="horizontal"?U:C.coordinate},V=fD({active:d.payload.active,coordinate:j,dataKey:d.payload.dataKey,index:String(C.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n(V)}}};return vy.on(gD,c),()=>{vy.off(gD,c)}},[l,n,e,t,r,i,s,o])}function YOe(){var t=Ut(m4),e=Ut(p4),n=Lr();_.useEffect(()=>{if(t==null)return Gy;var r=(i,s,o)=>{e!==o&&t===i&&n(BOe(s))};return vy.on(aG,r),()=>{vy.off(aG,r)}},[n,e,t])}function QOe(){var t=Lr();_.useEffect(()=>{t(IOe())},[t]),XOe(),YOe()}function ZOe(t,e,n,r,i,s){var o=Ut(m=>aOe(m,t,e)),l=Ut(p4),c=Ut(m4),u=Ut(sZ),d=Ut(UOe),h=d?.active,p=Qy();_.useEffect(()=>{if(!h&&c!=null&&l!=null){var m=fD({active:s,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:p,graphicalItemId:void 0});vy.emit(gD,c,m,l)}},[h,n,o,i,r,l,c,u,s,p])}function lG(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 cG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?lG(Object(n),!0).forEach(function(r){JOe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):lG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function JOe(t,e,n){return(e=e4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function e4e(t){var e=t4e(t,"string");return typeof e=="symbol"?e:e+""}function t4e(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 n4e(t){return t.dataKey}function r4e(t,e){return _.isValidElement(t)?_.cloneElement(t,e):typeof t=="function"?_.createElement(t,e):_.createElement(BAe,e)}var uG=[],i4e={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 D1(t){var e,n,r=ci(t,i4e),{active:i,allowEscapeViewBox:s,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:h,payloadUniqBy:p,position:m,reverseDirection:x,useTranslate3d:y,wrapperStyle:v,cursor:b,shared:S,trigger:N,defaultIndex:T,portal:k,axisId:C}=r,E=Lr(),P=typeof T=="number"?String(T):T;_.useEffect(()=>{E(eRe({shared:S,trigger:N,axisId:C,active:i,defaultIndex:P}))},[E,S,N,C,i,P]);var A=Qy(),D=ZY(),I=KDe(S),{activeIndex:L,isActive:U}=(e=Ut(ue=>lOe(ue,I,N,P)))!==null&&e!==void 0?e:{},j=Ut(ue=>oOe(ue,I,N,P)),V=Ut(ue=>oJ(ue,I,N,P)),K=Ut(ue=>sOe(ue,I,N,P)),z=j,X=POe(),Y=(n=i??U)!==null&&n!==void 0?n:!1,[te,$]=eY([z,Y]),W=I==="axis"?V:void 0;ZOe(I,N,K,W,L,Y);var ne=k??X;if(ne==null||A==null||I==null)return null;var re=z??uG;Y||(re=uG),u&&re.length&&(re=KX(re.filter(ue=>ue.value!=null&&(ue.hide!==!0||r.includeHidden)),p,n4e));var ge=re.length>0,me=_.createElement(KAe,{allowEscapeViewBox:s,animationDuration:o,animationEasing:l,isAnimationActive:d,active:Y,coordinate:K,hasPayload:ge,offset:h,position:m,reverseDirection:x,useTranslate3d:y,viewBox:A,wrapperStyle:v,lastBoundingBox:te,innerRef:$,hasPortalFromProps:!!k},r4e(c,cG(cG({},r),{},{payload:re,label:W,active:Y,activeIndex:L,coordinate:K,accessibilityLayer:D})));return _.createElement(_.Fragment,null,bu.createPortal(me,ne),Y&&_.createElement(jOe,{cursor:b,tooltipEventType:I,coordinate:K,payload:re,index:L}))}var pv=t=>null;pv.displayName="Cell";function a4e(t,e,n){return(e=s4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s4e(t){var e=o4e(t,"string");return typeof e=="symbol"?e:e+""}function o4e(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 l4e{constructor(e){a4e(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 dG(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 c4e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?dG(Object(n),!0).forEach(function(r){u4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):dG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function u4e(t,e,n){return(e=d4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function d4e(t){var e=h4e(t,"string");return typeof e=="symbol"?e:e+""}function h4e(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 f4e={cacheSize:2e3,enableCache:!0},hJ=c4e({},f4e),hG=new l4e(hJ.cacheSize),m4e={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},fG="recharts_measurement_span";function p4e(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 mG=(t,e)=>{try{var n=document.getElementById(fG);n||(n=document.createElement("span"),n.setAttribute("id",fG),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,m4e,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},k0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||kx.isSsr)return{width:0,height:0};if(!hJ.enableCache)return mG(e,n);var r=p4e(e,n),i=hG.get(r);if(i)return i;var s=mG(e,n);return hG.set(r,s),s},pG=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,gG=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,g4e=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,x4e=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,fJ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},b4e=Object.keys(fJ),vg="NaN";function y4e(t,e){return t*fJ[e]}class Ls{static parse(e){var n,[,r,i]=(n=x4e.exec(e))!==null&&n!==void 0?n:[];return new Ls(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,qs(e)&&(this.unit=""),n!==""&&!g4e.test(n)&&(this.num=NaN,this.unit=""),b4e.includes(n)&&(this.num=y4e(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new Ls(NaN,""):new Ls(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new Ls(NaN,""):new Ls(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Ls(NaN,""):new Ls(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new Ls(NaN,""):new Ls(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return qs(this.num)}}function mJ(t){if(t.includes(vg))return vg;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,s]=(n=pG.exec(e))!==null&&n!==void 0?n:[],o=Ls.parse(r??""),l=Ls.parse(s??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return vg;e=e.replace(pG,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,h,p]=(u=gG.exec(e))!==null&&u!==void 0?u:[],m=Ls.parse(d??""),x=Ls.parse(p??""),y=h==="+"?m.add(x):m.subtract(x);if(y.isNaN())return vg;e=e.replace(gG,y.toString())}return e}var xG=/\(([^()]*)\)/;function v4e(t){for(var e=t,n;(n=xG.exec(e))!=null;){var[,r]=n;e=e.replace(xG,mJ(r))}return e}function w4e(t){var e=t.replace(/\s+/g,"");return e=v4e(e),e=mJ(e),e}function _4e(t){try{return w4e(t)}catch{return vg}}function $C(t){var e=_4e(t.slice(5,-1));return e===vg?"":e}var S4e=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],N4e=["dx","dy","angle","className","breakAll"];function xD(){return xD=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},xD.apply(null,arguments)}function bG(t,e){if(t==null)return{};var n,r,i=M4e(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 M4e(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 pJ=/[ \f\n\r\t\v\u2028\u2029]+/,gJ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Yr(e)||(n?i=e.toString().split(""):i=e.toString().split(pJ));var s=i.map(l=>({word:l,width:k0(l,r).width})),o=n?0:k0(" ",r).width;return{wordsWithComputedWidth:s,spaceWidth:o}}catch{return null}};function k4e(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var xJ=(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},[]),bJ=t=>t.reduce((e,n)=>e.width>n.width?e:n),E4e="…",yG=(t,e,n,r,i,s,o,l)=>{var c=t.slice(0,e),u=gJ({breakAll:n,style:r,children:c+E4e});if(!u)return[!1,[]];var d=xJ(u.wordsWithComputedWidth,s,o,l),h=d.length>i||bJ(d).width>Number(s);return[h,d]},T4e=(t,e,n,r,i)=>{var{maxLines:s,children:o,style:l,breakAll:c}=t,u=Bt(s),d=String(o),h=xJ(e,r,n,i);if(!u||i)return h;var p=h.length>s||bJ(h).width>Number(r);if(!p)return h;for(var m=0,x=d.length-1,y=0,v;m<=x&&y<=d.length-1;){var b=Math.floor((m+x)/2),S=b-1,[N,T]=yG(d,S,c,l,s,r,n,i),[k]=yG(d,b,c,l,s,r,n,i);if(!N&&!k&&(m=b+1),N&&k&&(x=b-1),!N&&k){v=T;break}y++}return v||h},vG=t=>{var e=Yr(t)?[]:t.toString().split(pJ);return[{words:e,width:void 0}]},A4e=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:s,maxLines:o}=t;if((e||n)&&!kx.isSsr){var l,c,u=gJ({breakAll:s,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:h}=u;l=d,c=h}else return vG(r);return T4e({breakAll:s,children:r,maxLines:o,style:i},l,c,e,!!n)}return vG(r)},yJ="#808080",C4e={angle:0,breakAll:!1,capHeight:"0.71em",fill:yJ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},m2=_.forwardRef((t,e)=>{var n=ci(t,C4e),{x:r,y:i,lineHeight:s,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,h=bG(n,S4e),p=_.useMemo(()=>A4e({breakAll:h.breakAll,children:h.children,maxLines:h.maxLines,scaleToFit:c,style:h.style,width:h.width}),[h.breakAll,h.children,h.maxLines,c,h.style,h.width]),{dx:m,dy:x,angle:y,className:v,breakAll:b}=h,S=bG(h,N4e);if(!hl(r)||!hl(i)||p.length===0)return null;var N=Number(r)+(Bt(m)?m:0),T=Number(i)+(Bt(x)?x:0);if(!vr(N)||!vr(T))return null;var k;switch(d){case"start":k=$C("calc(".concat(o,")"));break;case"middle":k=$C("calc(".concat((p.length-1)/2," * -").concat(s," + (").concat(o," / 2))"));break;default:k=$C("calc(".concat(p.length-1," * -").concat(s,")"));break}var C=[];if(c){var E=p[0].width,{width:P}=h;C.push("scale(".concat(Bt(P)&&Bt(E)?P/E:1,")"))}return y&&C.push("rotate(".concat(y,", ").concat(N,", ").concat(T,")")),C.length&&(S.transform=C.join(" ")),_.createElement("text",xD({},Ha(S),{ref:e,x:N,y:T,className:nr("recharts-text",v),textAnchor:u,fill:l.includes("url")?yJ:l}),p.map((A,D)=>{var I=A.words.join(b?"":" ");return _.createElement("tspan",{x:N,dy:D===0?k:s,key:"".concat(I,"-").concat(D)},I)}))});m2.displayName="Text";var j4e=["labelRef"];function P4e(t,e){if(t==null)return{};var n,r,i=D4e(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 D4e(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 wG(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 Ei(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?wG(Object(n),!0).forEach(function(r){R4e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function R4e(t,e,n){return(e=O4e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function O4e(t){var e=L4e(t,"string");return typeof e=="symbol"?e:e+""}function L4e(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 xu(){return xu=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},xu.apply(null,arguments)}var vJ=_.createContext(null),wJ=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:o,children:l}=t,c=_.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:s,height:o}),[e,n,r,i,s,o]);return _.createElement(vJ.Provider,{value:c},l)},_J=()=>{var t=_.useContext(vJ),e=Qy();return t||zY(e)},F4e=_.createContext(null),I4e=()=>{var t=_.useContext(F4e),e=Ut(dZ);return t||e},U4e=t=>{var{value:e,formatter:n}=t,r=Yr(t.children)?e:t.children;return typeof n=="function"?n(r):r},Y4=t=>t!=null&&typeof t=="function",z4e=(t,e)=>{var n=_a(e-t),r=Math.min(Math.abs(e-t),360);return n*r},B4e=(t,e,n,r,i)=>{var{offset:s,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:h,endAngle:p,clockWise:m}=i,x=(u+d)/2,y=z4e(h,p),v=y>=0?1:-1,b,S;switch(e){case"insideStart":b=h+v*s,S=m;break;case"insideEnd":b=p-v*s,S=!m;break;case"end":b=p+v*s,S=m;break;default:throw new Error("Unsupported position ".concat(e))}S=y<=0?S:!S;var N=Hi(l,c,x,b),T=Hi(l,c,x,b+(S?1:-1)*359),k="M".concat(N.x,",").concat(N.y,`
  8095. A`).concat(x,",").concat(x,",0,1,").concat(S?0:1,`,
  8096. `).concat(T.x,",").concat(T.y),C=Yr(t.id)?sy("recharts-radial-line-"):t.id;return _.createElement("text",xu({},r,{dominantBaseline:"central",className:nr("recharts-radial-bar-label",o)}),_.createElement("defs",null,_.createElement("path",{id:C,d:k})),_.createElement("textPath",{xlinkHref:"#".concat(C)},n))},H4e=(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:h}=Hi(r,i,o+e,u);return{x:d,y:h,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 p=(s+o)/2,{x:m,y:x}=Hi(r,i,p,u);return{x:m,y:x,textAnchor:"middle",verticalAnchor:"middle"}},bD=t=>"cx"in t&&Bt(t.cx),$4e=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,s;n!=null&&!bD(n)&&(s=n);var{x:o,y:l,upperWidth:c,lowerWidth:u,height:d}=e,h=o,p=o+(c-u)/2,m=(h+p)/2,x=(c+u)/2,y=h+c/2,v=d>=0?1:-1,b=v*r,S=v>0?"end":"start",N=v>0?"start":"end",T=c>=0?1:-1,k=T*r,C=T>0?"end":"start",E=T>0?"start":"end";if(i==="top"){var P={x:h+c/2,y:l-b,textAnchor:"middle",verticalAnchor:S};return Ei(Ei({},P),s?{height:Math.max(l-s.y,0),width:c}:{})}if(i==="bottom"){var A={x:p+u/2,y:l+d+b,textAnchor:"middle",verticalAnchor:N};return Ei(Ei({},A),s?{height:Math.max(s.y+s.height-(l+d),0),width:u}:{})}if(i==="left"){var D={x:m-k,y:l+d/2,textAnchor:C,verticalAnchor:"middle"};return Ei(Ei({},D),s?{width:Math.max(D.x-s.x,0),height:d}:{})}if(i==="right"){var I={x:m+x+k,y:l+d/2,textAnchor:E,verticalAnchor:"middle"};return Ei(Ei({},I),s?{width:Math.max(s.x+s.width-I.x,0),height:d}:{})}var L=s?{width:x,height:d}:{};return i==="insideLeft"?Ei({x:m+k,y:l+d/2,textAnchor:E,verticalAnchor:"middle"},L):i==="insideRight"?Ei({x:m+x-k,y:l+d/2,textAnchor:C,verticalAnchor:"middle"},L):i==="insideTop"?Ei({x:h+c/2,y:l+b,textAnchor:"middle",verticalAnchor:N},L):i==="insideBottom"?Ei({x:p+u/2,y:l+d-b,textAnchor:"middle",verticalAnchor:S},L):i==="insideTopLeft"?Ei({x:h+k,y:l+b,textAnchor:E,verticalAnchor:N},L):i==="insideTopRight"?Ei({x:h+c-k,y:l+b,textAnchor:C,verticalAnchor:N},L):i==="insideBottomLeft"?Ei({x:p+k,y:l+d-b,textAnchor:E,verticalAnchor:S},L):i==="insideBottomRight"?Ei({x:p+u-k,y:l+d-b,textAnchor:C,verticalAnchor:S},L):i&&typeof i=="object"&&(Bt(i.x)||Uu(i.x))&&(Bt(i.y)||Uu(i.y))?Ei({x:o+ts(i.x,x),y:l+ts(i.y,d),textAnchor:"end",verticalAnchor:"end"},L):Ei({x:y,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},L)},V4e={angle:0,offset:5,zIndex:vi.label,position:"middle",textBreakAll:!1};function $d(t){var e=ci(t,V4e),{viewBox:n,position:r,value:i,children:s,content:o,className:l="",textBreakAll:c,labelRef:u}=e,d=I4e(),h=_J(),p=r==="center"?h:d??h,m,x,y;if(n==null?m=p:bD(n)?m=n:m=zY(n),!m||Yr(i)&&Yr(s)&&!_.isValidElement(o)&&typeof o!="function")return null;var v=Ei(Ei({},e),{},{viewBox:m});if(_.isValidElement(o)){var{labelRef:b}=v,S=P4e(v,j4e);return _.cloneElement(o,S)}if(typeof o=="function"){if(x=_.createElement(o,v),_.isValidElement(x))return x}else x=U4e(e);var N=Ha(e);if(bD(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return B4e(e,r,x,N,m);y=H4e(m,e.offset,e.position)}else y=$4e(e,m);return _.createElement(rs,{zIndex:e.zIndex},_.createElement(m2,xu({ref:u,className:nr("recharts-label",l)},N,y,{textAnchor:k4e(N.textAnchor)?N.textAnchor:y.textAnchor,breakAll:c}),x))}$d.displayName="Label";var G4e=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?_.createElement($d,xu({key:"label-implicit"},r)):hl(t)?_.createElement($d,xu({key:"label-implicit",value:t},r)):_.isValidElement(t)?t.type===$d?_.cloneElement(t,Ei({key:"label-implicit"},r)):_.createElement($d,xu({key:"label-implicit",content:t},r)):Y4(t)?_.createElement($d,xu({key:"label-implicit",content:t},r)):t&&typeof t=="object"?_.createElement($d,xu({},t,{key:"label-implicit"},r)):null};function SJ(t){var{label:e,labelRef:n}=t,r=_J();return G4e(e,r,n)||null}var VC={},GC={},_G;function q4e(){return _G||(_G=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(GC)),GC}var qC={},SG;function W4e(){return SG||(SG=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(qC)),qC}var NG;function K4e(){return NG||(NG=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=q4e(),n=W4e(),r=NO();function i(s){if(r.isArrayLike(s))return e.last(n.toArray(s))}t.last=i})(VC)),VC}var WC,MG;function X4e(){return MG||(MG=1,WC=K4e().last),WC}var Y4e=X4e();const Q4e=pl(Y4e);var Z4e=["valueAccessor"],J4e=["dataKey","clockWise","id","textBreakAll","zIndex"];function WS(){return WS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},WS.apply(null,arguments)}function kG(t,e){if(t==null)return{};var n,r,i=eLe(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 eLe(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 tLe=t=>Array.isArray(t.value)?Q4e(t.value):t.value,NJ=_.createContext(void 0),Q4=NJ.Provider,MJ=_.createContext(void 0),nLe=MJ.Provider;function rLe(){return _.useContext(NJ)}function iLe(){return _.useContext(MJ)}function R1(t){var{valueAccessor:e=tLe}=t,n=kG(t,Z4e),{dataKey:r,clockWise:i,id:s,textBreakAll:o,zIndex:l}=n,c=kG(n,J4e),u=rLe(),d=iLe(),h=u||d;return!h||!h.length?null:_.createElement(rs,{zIndex:l??vi.label},_.createElement(li,{className:"recharts-label-list"},h.map((p,m)=>{var x,y=Yr(r)?e(p,m):yr(p&&p.payload,r),v=Yr(s)?{}:{id:"".concat(s,"-").concat(m)};return _.createElement($d,WS({key:"label-".concat(m)},Ha(p),c,v,{fill:(x=n.fill)!==null&&x!==void 0?x:p.fill,parentViewBox:p.parentViewBox,value:y,textBreakAll:o,viewBox:p.viewBox,index:m,zIndex:0}))})))}R1.displayName="LabelList";function p2(t){var{label:e}=t;return e?e===!0?_.createElement(R1,{key:"labelList-implicit"}):_.isValidElement(e)||Y4(e)?_.createElement(R1,{key:"labelList-implicit",content:e}):typeof e=="object"?_.createElement(R1,WS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function yD(){return yD=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},yD.apply(null,arguments)}var kJ=t=>{var{cx:e,cy:n,r,className:i}=t,s=nr("recharts-dot",i);return Bt(e)&&Bt(n)&&Bt(r)?_.createElement("circle",yD({},ws(t),SO(t),{className:s,cx:e,cy:n,r})):null},EJ=t=>t.graphicalItems.polarItems,aLe=st([ii,av],v4),g2=st([EJ,ui,aLe],w4),sLe=st([g2],_4),x2=st([sLe,u4],S4),oLe=st([x2,ui,g2],M4);st([x2,ui,g2],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var s,o=yr(r,(s=e.dataKey)!==null&&s!==void 0?s:i.dataKey);return{value:o,errorDomain:[]}})).filter(Boolean):e?.dataKey!=null?t.map(r=>({value:yr(r,e.dataKey),errorDomain:[]})):t.map(r=>({value:r,errorDomain:[]})));var EG=()=>{},lLe=st([x2,ui,g2,u2,ii],A4),cLe=st([ui,E4,T4,EG,lLe,EG,$n,ii],C4),TJ=st([ui,$n,x2,oLe,iv,ii,cLe],j4),uLe=st([TJ,ui,Rx],R4);st([ui,TJ,uLe,ii],L4);var dLe={radiusAxis:{},angleAxis:{}},AJ=Ws({name:"polarAxis",initialState:dLe,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:eQe,removeRadiusAxis:tQe,addAngleAxis:nQe,removeAngleAxis:rQe}=AJ.actions,hLe=AJ.reducer;function TG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function AG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?TG(Object(n),!0).forEach(function(r){fLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):TG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fLe(t,e,n){return(e=mLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mLe(t){var e=pLe(t,"string");return typeof e=="symbol"?e:e+""}function pLe(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 gLe=(t,e)=>e,Z4=st([EJ,gLe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),xLe=[],J4=(t,e,n)=>n?.length===0?xLe:n,CJ=st([u4,Z4,J4],(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=>AG(AG({},e.presentationProps),s.props))),i!=null)return i}}),bLe=st([CJ,Z4,J4],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var s,o=yr(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:Ih(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),yLe=st([CJ,Z4,J4,aa],(t,e,n,r)=>{if(!(e==null||t==null))return vFe({offset:r,pieSettings:e,displayedData:t,cells:n})}),KC={exports:{}},Nr={};var CG;function vLe(){if(CG)return Nr;CG=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"),h=Symbol.for("react.lazy"),p=Symbol.for("react.view_transition"),m=Symbol.for("react.client.reference");function x(y){if(typeof y=="object"&&y!==null){var v=y.$$typeof;switch(v){case t:switch(y=y.type,y){case n:case i:case r:case c:case u:case p:return y;default:switch(y=y&&y.$$typeof,y){case o:case l:case h:case d:return y;case s:return y;default:return v}}case e:return v}}}return Nr.ContextConsumer=s,Nr.ContextProvider=o,Nr.Element=t,Nr.ForwardRef=l,Nr.Fragment=n,Nr.Lazy=h,Nr.Memo=d,Nr.Portal=e,Nr.Profiler=i,Nr.StrictMode=r,Nr.Suspense=c,Nr.SuspenseList=u,Nr.isContextConsumer=function(y){return x(y)===s},Nr.isContextProvider=function(y){return x(y)===o},Nr.isElement=function(y){return typeof y=="object"&&y!==null&&y.$$typeof===t},Nr.isForwardRef=function(y){return x(y)===l},Nr.isFragment=function(y){return x(y)===n},Nr.isLazy=function(y){return x(y)===h},Nr.isMemo=function(y){return x(y)===d},Nr.isPortal=function(y){return x(y)===e},Nr.isProfiler=function(y){return x(y)===i},Nr.isStrictMode=function(y){return x(y)===r},Nr.isSuspense=function(y){return x(y)===c},Nr.isSuspenseList=function(y){return x(y)===u},Nr.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===h||y.$$typeof===d||y.$$typeof===o||y.$$typeof===s||y.$$typeof===l||y.$$typeof===m||y.getModuleId!==void 0)},Nr.typeOf=x,Nr}var jG;function wLe(){return jG||(jG=1,KC.exports=vLe()),KC.exports}var _Le=wLe(),PG=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",DG=null,XC=null,jJ=t=>{if(t===DG&&Array.isArray(XC))return XC;var e=[];return _.Children.forEach(t,n=>{Yr(n)||(_Le.isFragment(n)?e=e.concat(jJ(n.props.children)):e.push(n))}),XC=e,DG=t,e};function eL(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>PG(i)):r=[PG(e)],jJ(t).forEach(i=>{var s=gm(i,"type.displayName")||gm(i,"type.name");s&&r.indexOf(s)!==-1&&n.push(i)}),n}var tL=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,YC={},RG;function SLe(){return RG||(RG=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})(YC)),YC}var QC,OG;function NLe(){return OG||(OG=1,QC=SLe().isPlainObject),QC}var MLe=NLe();const kLe=pl(MLe);function LG(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 FG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?LG(Object(n),!0).forEach(function(r){ELe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):LG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ELe(t,e,n){return(e=TLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function TLe(t){var e=ALe(t,"string");return typeof e=="symbol"?e:e+""}function ALe(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 KS(){return KS=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},KS.apply(null,arguments)}var IG=(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},CLe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},jLe=t=>{var e=ci(t,CLe),{x:n,y:r,upperWidth:i,lowerWidth:s,height:o,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:h}=e,p=_.useRef(null),[m,x]=_.useState(-1),y=_.useRef(i),v=_.useRef(s),b=_.useRef(o),S=_.useRef(n),N=_.useRef(r),T=Tx(t,"trapezoid-");if(_.useEffect(()=>{if(p.current&&p.current.getTotalLength)try{var j=p.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 k=nr("recharts-trapezoid",l);if(!h)return _.createElement("g",null,_.createElement("path",KS({},Ha(e),{className:k,d:IG(n,r,i,s,o)})));var C=y.current,E=v.current,P=b.current,A=S.current,D=N.current,I="0px ".concat(m===-1?1:m,"px"),L="".concat(m,"px 0px"),U=JY(["strokeDasharray"],u,c);return _.createElement(Ex,{animationId:T,key:T,canBegin:m>0,duration:u,easing:c,isActive:h,begin:d},j=>{var V=mr(C,i,j),K=mr(E,s,j),z=mr(P,o,j),X=mr(A,n,j),Y=mr(D,r,j);p.current&&(y.current=V,v.current=K,b.current=z,S.current=X,N.current=Y);var te=j>0?{transition:U,strokeDasharray:L}:{strokeDasharray:I};return _.createElement("path",KS({},Ha(e),{className:k,d:IG(X,Y,V,K,z),ref:p,style:FG(FG({},te),e.style)}))})},PLe=["option","shapeType","propTransformer","activeClassName"];function DLe(t,e){if(t==null)return{};var n,r,i=RLe(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 RLe(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 UG(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 XS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?UG(Object(n),!0).forEach(function(r){OLe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):UG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function OLe(t,e,n){return(e=LLe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function LLe(t){var e=FLe(t,"string");return typeof e=="symbol"?e:e+""}function FLe(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 ILe(t,e){return XS(XS({},e),t)}function ULe(t,e){return t==="symbols"}function zG(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return _.createElement(rQ,n);case"trapezoid":return _.createElement(jLe,n);case"sector":return _.createElement(oQ,n);case"symbols":if(ULe(e))return _.createElement(_O,n);break;case"curve":return _.createElement(Rg,n);default:return null}}function zLe(t){return _.isValidElement(t)?t.props:t}function nL(t){var{option:e,shapeType:n,propTransformer:r=ILe,activeClassName:i="recharts-active-shape"}=t,s=DLe(t,PLe),o;if(_.isValidElement(e))o=_.cloneElement(e,XS(XS({},s),zLe(e)));else if(typeof e=="function")o=e(s,s.index);else if(kLe(e)&&typeof e!="boolean"){var l=r(e,s);o=_.createElement(zG,{shapeType:n,elementProps:l})}else{var c=s;o=_.createElement(zG,{shapeType:n,elementProps:c})}return s.isActive?_.createElement(li,{className:i},o):o}var rL=(t,e,n)=>{var r=Lr();return(i,s)=>o=>{t?.(i,s,o),r(HZ({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},iL=t=>{var e=Lr();return(n,r)=>i=>{t?.(n,r,i),e(tRe())}},aL=(t,e,n)=>{var r=Lr();return(i,s)=>o=>{t?.(i,s,o),r(nRe({activeIndex:String(s),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function b2(t){var{tooltipEntrySettings:e}=t,n=Lr(),r=sa(),i=_.useRef(null);return _.useLayoutEffect(()=>{r||(i.current===null?n(QDe(e)):i.current!==e&&n(ZDe({prev:i.current,next:e})),i.current=e)},[e,n,r]),_.useLayoutEffect(()=>()=>{i.current&&(n(JDe(i.current)),i.current=null)},[n]),null}function sL(t){var{legendPayload:e}=t,n=Lr(),r=sa(),i=_.useRef(null);return _.useLayoutEffect(()=>{r||(i.current===null?n(XY(e)):i.current!==e&&n(YY({prev:i.current,next:e})),i.current=e)},[n,r,e]),_.useLayoutEffect(()=>()=>{i.current&&(n(QY(i.current)),i.current=null)},[n]),null}function BLe(t){var{legendPayload:e}=t,n=Lr(),r=Ut($n),i=_.useRef(null);return _.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(XY(e)):i.current!==e&&n(YY({prev:i.current,next:e})),i.current=e)},[n,r,e]),_.useLayoutEffect(()=>()=>{i.current&&(n(QY(i.current)),i.current=null)},[n]),null}var ZC,HLe=()=>{var[t]=_.useState(()=>sy("uid-"));return t},$Le=(ZC=Gae.useId)!==null&&ZC!==void 0?ZC:HLe;function PJ(t,e){var n=$Le();return e||(t?"".concat(t,"-").concat(n):n)}var VLe=_.createContext(void 0),y2=t=>{var{id:e,type:n,children:r}=t,i=PJ("recharts-".concat(n),e);return _.createElement(VLe.Provider,{value:i},r(i))},GLe={cartesianItems:[],polarItems:[]},DJ=Ws({name:"graphicalItems",initialState:GLe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:Jr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Il(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Jr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Il(t).cartesianItems.indexOf(e.payload);n>-1&&t.cartesianItems.splice(n,1)},prepare:Jr()},addPolarGraphicalItem:{reducer(t,e){t.polarItems.push(e.payload)},prepare:Jr()},removePolarGraphicalItem:{reducer(t,e){var n=Il(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Jr()}}}),{addCartesianGraphicalItem:qLe,replaceCartesianGraphicalItem:WLe,removeCartesianGraphicalItem:KLe,addPolarGraphicalItem:XLe,removePolarGraphicalItem:YLe}=DJ.actions,QLe=DJ.reducer,ZLe=t=>{var e=Lr(),n=_.useRef(null);return _.useLayoutEffect(()=>{n.current===null?e(qLe(t)):n.current!==t&&e(WLe({prev:n.current,next:t})),n.current=t},[e,t]),_.useLayoutEffect(()=>()=>{n.current&&(e(KLe(n.current)),n.current=null)},[e]),null},oL=_.memo(ZLe);function JLe(t){var e=Lr();return _.useLayoutEffect(()=>(e(XLe(t)),()=>{e(YLe(t))}),[e,t]),null}var eFe=["key"],tFe=["onMouseEnter","onClick","onMouseLeave"],nFe=["id"],rFe=["id"];function BG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function xi(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?BG(Object(n),!0).forEach(function(r){iFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):BG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function iFe(t,e,n){return(e=aFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aFe(t){var e=sFe(t,"string");return typeof e=="symbol"?e:e+""}function sFe(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 jh(){return jh=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},jh.apply(null,arguments)}function v2(t,e){if(t==null)return{};var n,r,i=oFe(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 oFe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function lFe(t){var e=_.useMemo(()=>eL(t.children,pv),[t.children]),n=Ut(r=>bLe(r,t.id,e));return n==null?null:_.createElement(BLe,{legendPayload:n})}var cFe=_.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(h=>h.tooltipPayload),positions:r.map(h=>h.tooltipPosition),settings:{stroke:i,strokeWidth:s,fill:o,dataKey:e,nameKey:n,name:Ih(l,e),hide:c,type:u,color:o,unit:""}};return _.createElement(b2,{tooltipEntrySettings:d})}),uFe=(t,e)=>t>e?"start":t<e?"end":"middle",dFe=(t,e,n)=>ts(typeof e=="function"?e(t):e,n,n*.8),hFe=(t,e,n)=>{var{top:r,left:i,width:s,height:o}=e,l=iQ(s,o),c=i+ts(t.cx,s,s/2),u=r+ts(t.cy,o,o/2),d=ts(t.innerRadius,l,0),h=dFe(n,t.outerRadius,l),p=t.maxRadius||Math.sqrt(s*s+o*o)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:h,maxRadius:p}},fFe=(t,e)=>{var n=_a(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function mFe(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var pFe=(t,e)=>{if(_.isValidElement(t))return _.cloneElement(t,e);if(typeof t=="function")return t(e);var n=nr("recharts-pie-label-line",typeof t!="boolean"?t.className:""),{key:r}=e,i=v2(e,eFe);return _.createElement(Rg,jh({},i,{type:"linear",className:n}))},gFe=(t,e,n)=>{if(_.isValidElement(t))return _.cloneElement(t,e);var r=n;if(typeof t=="function"&&(r=t(e),_.isValidElement(r)))return r;var i=nr("recharts-pie-label-text",mFe(t));return _.createElement(m2,jh({},e,{alignmentBaseline:"middle",className:i}),r)};function xFe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:s,dataKey:o}=n;if(!r||!i||!e)return null;var l=ws(n),c=pm(i),u=pm(s),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,h=e.map((p,m)=>{var x=(p.startAngle+p.endAngle)/2,y=Hi(p.cx,p.cy,p.outerRadius+d,x),v=xi(xi(xi(xi({},l),p),{},{stroke:"none"},c),{},{index:m,textAnchor:uFe(y.x,p.cx)},y),b=xi(xi(xi(xi({},l),p),{},{fill:"none",stroke:p.fill},u),{},{index:m,points:[Hi(p.cx,p.cy,p.outerRadius,x),y],key:"line"});return _.createElement(rs,{zIndex:vi.label,key:"label-".concat(p.startAngle,"-").concat(p.endAngle,"-").concat(p.midAngle,"-").concat(m)},_.createElement(li,null,s&&pFe(s,b),gFe(i,v,yr(p,o))))});return _.createElement(li,{className:"recharts-pie-labels"},h)}function bFe(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?_.createElement(p2,{label:i}):_.createElement(xFe,{sectors:e,props:n,showLabels:r})}function yFe(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:s,id:o}=t,l=Ut(Ch),c=Ut(G4),u=Ut(BRe),{onMouseEnter:d,onClick:h,onMouseLeave:p}=i,m=v2(i,tFe),x=rL(d,i.dataKey,o),y=iL(p),v=aL(h,i.dataKey,o);return e==null||e.length===0?null:_.createElement(_.Fragment,null,e.map((b,S)=>{if(b?.startAngle===0&&b?.endAngle===0&&e.length!==1)return null;var N=u==null||u===o,T=String(S)===l&&(c==null||i.dataKey===c)&&N,k=l?r:null,C=n&&T?n:k,E=xi(xi({},b),{},{stroke:b.stroke,tabIndex:-1,[OY]:S,[LY]:i.dataKey});return _.createElement(li,jh({key:"sector-".concat(b?.startAngle,"-").concat(b?.endAngle,"-").concat(b.midAngle,"-").concat(S),tabIndex:-1,className:"recharts-pie-sector"},qy(m,b,S),{onMouseEnter:x(b,S),onMouseLeave:y(b,S),onClick:v(b,S)}),_.createElement(nL,jh({option:s??C,index:S,shapeType:"sector",isActive:T},E)))}))}function vFe(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:s}=t,{cornerRadius:o,startAngle:l,endAngle:c,dataKey:u,nameKey:d,tooltipType:h}=n,p=Math.abs(n.minAngle),m=fFe(l,c),x=Math.abs(m),y=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,v=r.filter(C=>yr(C,u,0)!==0).length,b=(x>=360?v:v-1)*y,S=x-v*p-b,N=r.reduce((C,E)=>{var P=yr(E,u,0);return C+(Bt(P)?P:0)},0),T;if(N>0){var k;T=r.map((C,E)=>{var P=yr(C,u,0),A=yr(C,d,E),D=hFe(n,s,C),I=(Bt(P)?P:0)/N,L,U=xi(xi({},C),i&&i[E]&&i[E].props);E?L=k.endAngle+_a(m)*y*(P!==0?1:0):L=l;var j=L+_a(m)*((P!==0?p:0)+I*S),V=(L+j)/2,K=(D.innerRadius+D.outerRadius)/2,z=[{name:A,value:P,payload:U,dataKey:u,type:h}],X=Hi(D.cx,D.cy,K,V);return k=xi(xi(xi(xi({},n.presentationProps),{},{percent:I,cornerRadius:typeof o=="string"?parseFloat(o):o,name:A,tooltipPayload:z,midAngle:V,middleRadius:K,tooltipPosition:X},U),D),{},{value:P,dataKey:u,startAngle:L,endAngle:j,payload:U,paddingAngle:_a(m)*y}),k})}return T}function wFe(t){var{showLabels:e,sectors:n,children:r}=t,i=_.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 _.createElement(nLe,{value:e?i:void 0},r)}function _Fe(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:s,animationBegin:o,animationDuration:l,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:h,onAnimationEnd:p}=e,m=Tx(e,"recharts-pie-"),x=n.current,[y,v]=_.useState(!1),b=_.useCallback(()=>{typeof p=="function"&&p(),v(!1)},[p]),S=_.useCallback(()=>{typeof h=="function"&&h(),v(!0)},[h]);return _.createElement(wFe,{showLabels:!y,sectors:i},_.createElement(Ex,{animationId:m,begin:o,duration:l,isActive:s,easing:c,onAnimationStart:S,onAnimationEnd:b,key:m},N=>{var T=[],k=i&&i[0],C=k?.startAngle;return i?.forEach((E,P)=>{var A=x&&x[P],D=P>0?gm(E,"paddingAngle",0):0;if(A){var I=mr(A.endAngle-A.startAngle,E.endAngle-E.startAngle,N),L=xi(xi({},E),{},{startAngle:C+D,endAngle:C+I+D});T.push(L),C=L.endAngle}else{var{endAngle:U,startAngle:j}=E,V=mr(0,U-j,N),K=xi(xi({},E),{},{startAngle:C+D,endAngle:C+V+D});T.push(K),C=K.endAngle}}),n.current=T,_.createElement(li,null,_.createElement(yFe,{sectors:T,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),_.createElement(bFe,{showLabels:!y,sectors:i,props:e}),e.children)}var SFe={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:vi.area};function NFe(t){var{id:e}=t,n=v2(t,nFe),{hide:r,className:i,rootTabIndex:s}=t,o=_.useMemo(()=>eL(t.children,pv),[t.children]),l=Ut(d=>yLe(d,e,o)),c=_.useRef(null),u=nr("recharts-pie",i);return r||l==null?(c.current=null,_.createElement(li,{tabIndex:s,className:u})):_.createElement(rs,{zIndex:t.zIndex},_.createElement(cFe,{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}),_.createElement(li,{tabIndex:s,className:u},_.createElement(_Fe,{props:xi(xi({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function RJ(t){var e=ci(t,SFe),{id:n}=e,r=v2(e,rFe),i=ws(r);return _.createElement(y2,{id:n,type:"pie"},s=>_.createElement(_.Fragment,null,_.createElement(JLe,{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}),_.createElement(lFe,jh({},r,{id:s})),_.createElement(NFe,jh({},r,{id:s}))))}RJ.displayName="Pie";var MFe=["points"];function HG(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function JC(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?HG(Object(n),!0).forEach(function(r){kFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):HG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function kFe(t,e,n){return(e=EFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function EFe(t){var e=TFe(t,"string");return typeof e=="symbol"?e:e+""}function TFe(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 YS(){return YS=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},YS.apply(null,arguments)}function AFe(t,e){if(t==null)return{};var n,r,i=CFe(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 CFe(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 jFe(t){var{option:e,dotProps:n,className:r}=t;if(_.isValidElement(e))return _.cloneElement(e,n);if(typeof e=="function")return e(n);var i=nr(r,typeof e!="boolean"?e.className:""),s=n??{},{points:o}=s,l=AFe(s,MFe);return _.createElement(kJ,YS({},l,{className:i}))}function PFe(t,e){return t==null?!1:e?!0:t.length===1}function OJ(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:s,baseProps:o,needClip:l,clipPathId:c,zIndex:u=vi.scatter}=t;if(!PFe(e,n))return null;var d=tL(n),h=c2e(n),p=e.map((x,y)=>{var v,b,S=JC(JC(JC({r:3},o),h),{},{index:y,cx:(v=x.x)!==null&&v!==void 0?v:void 0,cy:(b=x.y)!==null&&b!==void 0?b:void 0,dataKey:s,value:x.value,payload:x.payload,points:e});return _.createElement(jFe,{key:"dot-".concat(y),option:n,dotProps:S,className:i})}),m={};return l&&c!=null&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),_.createElement(rs,{zIndex:u},_.createElement(li,YS({className:r},m),p))}function $G(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 VG(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?$G(Object(n),!0).forEach(function(r){DFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):$G(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function DFe(t,e,n){return(e=RFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function RFe(t){var e=OFe(t,"string");return typeof e=="symbol"?e:e+""}function OFe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var LFe={xAxis:{},yAxis:{},zAxis:{}},LJ=Ws({name:"cartesianAxis",initialState:LFe,reducers:{addXAxis:{reducer(t,e){t.xAxis[e.payload.id]=e.payload},prepare:Jr()},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:Jr()},removeXAxis:{reducer(t,e){delete t.xAxis[e.payload.id]},prepare:Jr()},addYAxis:{reducer(t,e){t.yAxis[e.payload.id]=e.payload},prepare:Jr()},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:Jr()},removeYAxis:{reducer(t,e){delete t.yAxis[e.payload.id]},prepare:Jr()},addZAxis:{reducer(t,e){t.zAxis[e.payload.id]=e.payload},prepare:Jr()},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:Jr()},removeZAxis:{reducer(t,e){delete t.zAxis[e.payload.id]},prepare:Jr()},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]=VG(VG({},t.yAxis[n]),{},{width:r,widthHistory:o})}}}}),{addXAxis:FFe,replaceXAxis:IFe,removeXAxis:UFe,addYAxis:zFe,replaceYAxis:BFe,removeYAxis:HFe,addZAxis:iQe,replaceZAxis:aQe,removeZAxis:sQe,updateYAxisWidth:$Fe}=LJ.actions,VFe=LJ.reducer,GFe=st([aa],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),qFe=st([GFe,Wu,Ku],(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)}}),w2=()=>Ut(qFe),WFe=()=>Ut(qRe);function GG(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 ej(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?GG(Object(n),!0).forEach(function(r){KFe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):GG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function KFe(t,e,n){return(e=XFe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function XFe(t){var e=YFe(t,"string");return typeof e=="symbol"?e:e+""}function YFe(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 QFe=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=ej(ej(ej({},l),pm(i)),SO(i)),u;return _.isValidElement(i)?u=_.cloneElement(i,c):typeof i=="function"?u=i(c):u=_.createElement(kJ,c),_.createElement(li,{className:"recharts-active-dot",clipPath:o},u)};function vD(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:s,zIndex:o=vi.activeDot}=t,l=Ut(Ch),c=WFe();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Yr(u)?null:_.createElement(rs,{zIndex:o},_.createElement(QFe,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:s}))}var ZFe="Invariant failed";function JFe(t,e){throw new Error(ZFe)}var eIe=["x","y"];function wD(){return wD=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},wD.apply(null,arguments)}function qG(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 e0(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qG(Object(n),!0).forEach(function(r){tIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function tIe(t,e,n){return(e=nIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function nIe(t){var e=rIe(t,"string");return typeof e=="symbol"?e:e+""}function rIe(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 iIe(t,e){if(t==null)return{};var n,r,i=aIe(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 aIe(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 sIe(t,e){var{x:n,y:r}=t,i=iIe(t,eIe),s="".concat(n),o=parseInt(s,10),l="".concat(r),c=parseInt(l,10),u="".concat(e.height||i.height),d=parseInt(u,10),h="".concat(e.width||i.width),p=parseInt(h,10);return e0(e0(e0(e0(e0({},e),i),o?{x:o}:{}),c?{y:c}:{}),{},{height:d,width:p,name:e.name,radius:e.radius})}function QS(t){return _.createElement(nL,wD({shapeType:"rectangle",propTransformer:sIe,activeClassName:"recharts-active-bar"},t))}var oIe=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(Bt(e))return e;var s=Bt(r)||Yr(r);return s?e(r,i):(s||JFe(),n)}},lIe={},FJ=Ws({name:"errorBars",initialState:lIe,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:oQe,replaceErrorBar:lQe,removeErrorBar:cQe}=FJ.actions,cIe=FJ.reducer,uIe=["children"];function dIe(t,e){if(t==null)return{};var n,r,i=hIe(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 hIe(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 fIe={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},mIe=_.createContext(fIe);function IJ(t){var{children:e}=t,n=dIe(t,uIe);return _.createElement(mIe.Provider,{value:n},e)}function _2(t,e){var n,r,i=Ut(u=>Cc(u,t)),s=Ut(u=>jc(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:ga.allowDataOverflow,l=(r=s?.allowDataOverflow)!==null&&r!==void 0?r:xa.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function lL(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=w2(),{needClipX:s,needClipY:o,needClip:l}=_2(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:h}=i;return _.createElement("clipPath",{id:"clipPath-".concat(r)},_.createElement("rect",{x:s?c:c-d/2,y:o?u:u-h/2,width:s?d:d*2,height:o?h:h*2}))}function pIe(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&vr(t.zIndex)?t.zIndex:e}var tj={exports:{}},nj={};var WG;function gIe(){if(WG)return nj;WG=1;var t=xx();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 nj.useSyncExternalStoreWithSelector=function(c,u,d,h,p){var m=i(null);if(m.current===null){var x={hasValue:!1,value:null};m.current=x}else x=m.current;m=o(function(){function v(k){if(!b){if(b=!0,S=k,k=h(k),p!==void 0&&x.hasValue){var C=x.value;if(p(C,k))return N=C}return N=k}if(C=N,n(S,k))return C;var E=h(k);return p!==void 0&&p(C,E)?(S=k,C):(S=k,N=E)}var b=!1,S,N,T=d===void 0?null:d;return[function(){return v(u())},T===null?void 0:function(){return v(T())}]},[u,d,h,p]);var y=r(c,m[0],m[1]);return s(function(){x.hasValue=!0,x.value=y},[y]),l(y),y},nj}var KG;function xIe(){return KG||(KG=1,tj.exports=gIe()),tj.exports}xIe();function bIe(t){t()}function yIe(){let t=null,e=null;return{clear(){t=null,e=null},notify(){bIe(()=>{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 XG={notify(){},get:()=>[]};function vIe(t,e){let n,r=XG,i=0,s=!1;function o(y){d();const v=r.subscribe(y);let b=!1;return()=>{b||(b=!0,v(),h())}}function l(){r.notify()}function c(){x.onStateChange&&x.onStateChange()}function u(){return s}function d(){i++,n||(n=t.subscribe(c),r=yIe())}function h(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=XG)}function p(){s||(s=!0,d())}function m(){s&&(s=!1,h())}const x={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:p,tryUnsubscribe:m,getListeners:()=>r};return x}var wIe=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",_Ie=wIe(),SIe=()=>typeof navigator<"u"&&navigator.product==="ReactNative",NIe=SIe(),MIe=()=>_Ie||NIe?_.useLayoutEffect:_.useEffect,kIe=MIe();function YG(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function EIe(t,e){if(YG(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])||!YG(t[n[i]],e[n[i]]))return!1;return!0}var TIe=Symbol.for("react-redux-context"),AIe=typeof globalThis<"u"?globalThis:{};function CIe(){if(!_.createContext)return{};const t=AIe[TIe]??=new Map;let e=t.get(_.createContext);return e||(e=_.createContext(null),t.set(_.createContext,e)),e}var jIe=CIe();function PIe(t){const{children:e,context:n,serverState:r,store:i}=t,s=_.useMemo(()=>{const c=vIe(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=_.useMemo(()=>i.getState(),[i]);kIe(()=>{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||jIe;return _.createElement(l.Provider,{value:s},e)}var DIe=PIe,RIe=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function OIe(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function gv(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(RIe.has(r)){if(t[r]==null&&e[r]==null)continue;if(!EIe(t[r],e[r]))return!1}else if(!OIe(t[r],e[r]))return!1;return!0}var LIe=["onMouseEnter","onMouseLeave","onClick"],FIe=["value","background","tooltipPosition"],IIe=["id"],UIe=["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 QG(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 hs(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?QG(Object(n),!0).forEach(function(r){zIe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):QG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function zIe(t,e,n){return(e=BIe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function BIe(t){var e=HIe(t,"string");return typeof e=="symbol"?e:e+""}function HIe(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 ZS(t,e){if(t==null)return{};var n,r,i=$Ie(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 $Ie(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 VIe=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:Ih(n,e),payload:t}]},GIe=_.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:Ih(s,e),hide:o,type:c,color:i,unit:l}};return _.createElement(b2,{tooltipEntrySettings:u})});function qIe(t){var e=Ut(Ch),{data:n,dataKey:r,background:i,allOtherBarProps:s}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=s,u=ZS(s,LIe),d=rL(o,r),h=iL(l),p=aL(c,r);if(!i||n==null)return null;var m=pm(i);return _.createElement(rs,{zIndex:pIe(i,vi.barBackground)},n.map((x,y)=>{var{value:v,background:b,tooltipPosition:S}=x,N=ZS(x,FIe);if(!b)return null;var T=d(x,y),k=h(x,y),C=p(x,y),E=hs(hs(hs(hs(hs({option:i,isActive:String(y)===e},N),{},{fill:"#eee"},b),m),qy(u,x,y)),{},{onMouseEnter:T,onMouseLeave:k,onClick:C,dataKey:r,index:y,className:"recharts-bar-background-rectangle"});return _.createElement(QS,Gu({key:"background-bar-".concat(y)},E))}))}function WIe(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 hs(hs({},o),{},{value:s.value,payload:s.payload,parentViewBox:s.parentViewBox,viewBox:o,fill:s.fill})});return _.createElement(Q4,{value:e?i:void 0},n)}function KIe(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:s,dataKey:o}=t,l=Ut(Ch),c=Ut(G4),u=n&&String(s)===l&&(c==null||o===c),d=u?n:e;return u?_.createElement(rs,{zIndex:vi.activeBar},_.createElement(QS,Gu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:o}))):_.createElement(QS,Gu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:s,dataKey:o}))}function XIe(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:s}=t;return _.createElement(QS,Gu({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:s}))}function YIe(t){var e,{data:n,props:r}=t,i=(e=ws(r))!==null&&e!==void 0?e:{},{id:s}=i,o=ZS(i,IIe),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:h,onMouseLeave:p}=r,m=ZS(r,UIe),x=rL(d,c),y=iL(p),v=aL(h,c);return n?_.createElement(_.Fragment,null,n.map((b,S)=>_.createElement(li,Gu({key:"rectangle-".concat(b?.x,"-").concat(b?.y,"-").concat(b?.value,"-").concat(S),className:"recharts-bar-rectangle"},qy(m,b,S),{onMouseEnter:x(b,S),onMouseLeave:y(b,S),onClick:v(b,S)}),u?_.createElement(KIe,{shape:l,activeBar:u,baseProps:o,entry:b,index:S,dataKey:c}):_.createElement(XIe,{shape:l,baseProps:o,entry:b,index:S,dataKey:c})))):null}function QIe(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:s,animationBegin:o,animationDuration:l,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,h=n.current,p=Tx(e,"recharts-bar-"),[m,x]=_.useState(!1),y=!m,v=_.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),b=_.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return _.createElement(WIe,{showLabels:y,rects:r},_.createElement(Ex,{animationId:p,begin:o,duration:l,isActive:s,easing:c,onAnimationEnd:v,onAnimationStart:b,key:p},S=>{var N=S===1?r:r?.map((T,k)=>{var C=h&&h[k];if(C)return hs(hs({},T),{},{x:mr(C.x,T.x,S),y:mr(C.y,T.y,S),width:mr(C.width,T.width,S),height:mr(C.height,T.height,S)});if(i==="horizontal"){var E=mr(0,T.height,S),P=mr(T.stackedBarStart,T.y,S);return hs(hs({},T),{},{y:P,height:E})}var A=mr(0,T.width,S),D=mr(T.stackedBarStart,T.x,S);return hs(hs({},T),{},{width:A,x:D})});return S>0&&(n.current=N??null),N==null?null:_.createElement(li,null,_.createElement(YIe,{props:e,data:N}))}),_.createElement(p2,{label:e.label}),e.children)}function ZIe(t){var e=_.useRef(null);return _.createElement(QIe,{previousRectanglesRef:e,props:t})}var UJ=0,JIe=(t,e)=>{var n=Array.isArray(t.value)?t.value[1]:t.value;return{x:t.x,y:t.y,value:n,errorVal:yr(t,e)}};class e5e extends _.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=nr("recharts-bar",i),h=u;return _.createElement(li,{className:d,id:u},l&&_.createElement("defs",null,_.createElement(lL,{clipPathId:h,xAxisId:s,yAxisId:o})),_.createElement(li,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(h,")"):void 0},_.createElement(qIe,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),_.createElement(ZIe,this.props)))}}var t5e={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:UJ,xAxisId:0,yAxisId:0,zIndex:vi.bar};function n5e(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:h}=_2(e,n),p=Cm(),m=sa(),x=eL(t.children,pv),y=Ut(S=>C5e(S,e,n,m,t.id,x));if(p!=="vertical"&&p!=="horizontal")return null;var v,b=y?.[0];return b==null||b.height==null||b.width==null?v=0:v=p==="vertical"?b.height/2:b.width/2,_.createElement(IJ,{xAxisId:e,yAxisId:n,data:y,dataPointFormatter:JIe,errorBarOffset:v},_.createElement(e5e,Gu({},t,{layout:p,needClip:h,data:y,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:s,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function r5e(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:s,xAxis:o,yAxis:l,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:h,offset:p,cells:m,parentViewBox:x,dataStartIndex:y}=t,v=e==="horizontal"?l:o,b=d?v.scale.domain():null,S=kTe({numericAxis:v}),N=v.scale(S);return h.map((T,k)=>{var C,E,P,A,D,I;d?C=wTe(d[k+y],b):(C=yr(T,n),Array.isArray(C)||(C=[S,C]));var L=oIe(r,UJ)(C[1],k);if(e==="horizontal"){var U,[j,V]=[l.scale(C[0]),l.scale(C[1])];E=m$({axis:o,ticks:c,bandSize:s,offset:i.offset,entry:T,index:k}),P=(U=V??j)!==null&&U!==void 0?U:void 0,A=i.size;var K=j-V;if(D=qs(K)?0:K,I={x:E,y:p.top,width:A,height:p.height},Math.abs(L)>0&&Math.abs(D)<Math.abs(L)){var z=_a(D||L)*(Math.abs(L)-Math.abs(D));P-=z,D+=z}}else{var[X,Y]=[o.scale(C[0]),o.scale(C[1])];if(E=X,P=m$({axis:l,ticks:u,bandSize:s,offset:i.offset,entry:T,index:k}),A=Y-X,D=i.size,I={x:p.left,y:P,width:p.width,height:D},Math.abs(L)>0&&Math.abs(A)<Math.abs(L)){var te=_a(A||L)*(Math.abs(L)-Math.abs(A));A+=te}}if(E==null||P==null||A==null||D==null)return null;var $=hs(hs({},T),{},{stackedBarStart:N,x:E,y:P,width:A,height:D,value:d?C:C[1],payload:T,background:I,tooltipPosition:{x:E+A/2,y:P+D/2},parentViewBox:x},m&&m[k]&&m[k].props);return $}).filter(Boolean)}function i5e(t){var e=ci(t,t5e),n=sa();return _.createElement(y2,{id:e.id,type:"bar"},r=>_.createElement(_.Fragment,null,_.createElement(sL,{legendPayload:VIe(e)}),_.createElement(GIe,{dataKey:e.dataKey,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,unit:e.unit,tooltipType:e.tooltipType}),_.createElement(oL,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:DY(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),_.createElement(rs,{zIndex:e.zIndex},_.createElement(n5e,Gu({},e,{id:r})))))}var zJ=_.memo(i5e,gv);zJ.displayName="Bar";function ZG(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 Q_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ZG(Object(n),!0).forEach(function(r){a5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ZG(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function a5e(t,e,n){return(e=s5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function s5e(t){var e=o5e(t,"string");return typeof e=="symbol"?e:e+""}function o5e(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 l5e=(t,e)=>e,c5e=(t,e,n)=>n,u5e=(t,e,n,r)=>r,d5e=(t,e,n,r,i)=>i,xv=st([ov,d5e],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),h5e=st([xv],t=>t?.maxBarSize),f5e=(t,e,n,r,i,s)=>s,JG=(t,e,n)=>{var r=n??t;if(!Yr(r))return ts(r,e,0)},m5e=st([$n,ov,l5e,c5e,u5e],(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")),p5e=(t,e,n,r)=>{var i=$n(t);return i==="horizontal"?yy(t,"yAxis",n,r):yy(t,"xAxis",e,r)},g5e=(t,e,n)=>{var r=$n(t);return r==="horizontal"?WV(t,"xAxis",e):WV(t,"yAxis",n)},x5e=(t,e,n)=>{var r={},i=t.filter(s2),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,h]=u,p=h.map(x=>x.dataKey),m=JG(e,n,h[0].barSize);return{stackId:d,dataKeys:p,barSize:m}}),c=s.map(u=>{var d=[u.dataKey].filter(p=>p!=null),h=JG(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:h}});return[...l,...c]},b5e=st([m5e,$3e,g5e],x5e),y5e=(t,e,n,r,i)=>{var s,o,l=xv(t,e,n,r,i);if(l!=null){var c=$n(t),u=rZ(t),{maxBarSize:d}=l,h=Yr(d)?u:d,p,m;return c==="horizontal"?(p=Sc(t,"xAxis",e,r),m=_c(t,"xAxis",e,r)):(p=Sc(t,"yAxis",n,r),m=_c(t,"yAxis",n,r)),(s=(o=Eh(p,m,!0))!==null&&o!==void 0?o:h)!==null&&s!==void 0?s:0}},BJ=(t,e,n,r)=>{var i=$n(t),s,o;return i==="horizontal"?(s=Sc(t,"xAxis",e,r),o=_c(t,"xAxis",e,r)):(s=Sc(t,"yAxis",n,r),o=_c(t,"yAxis",n,r)),Eh(s,o)};function v5e(t,e,n,r,i){var s=r.length;if(!(s<1)){var o=ts(t,n,0,!0),l,c=[];if(vr(r[0].barSize)){var u=!1,d=n/s,h=r.reduce((b,S)=>b+(S.barSize||0),0);h+=(s-1)*o,h>=n&&(h-=(s-1)*o,o=0),h>=n&&d>0&&(u=!0,d*=.9,h=s*d);var p=(n-h)/2>>0,m={offset:p-o,size:0};l=r.reduce((b,S)=>{var N,T={stackId:S.stackId,dataKeys:S.dataKeys,position:{offset:m.offset+m.size+o,size:u?d:(N=S.barSize)!==null&&N!==void 0?N:0}},k=[...b,T];return m=k[k.length-1].position,k},c)}else{var x=ts(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 v=vr(i)?Math.min(y,i):y;l=r.reduce((b,S,N)=>[...b,{stackId:S.stackId,dataKeys:S.dataKeys,position:{offset:x+(y+o)*N+(y-v)/2,size:v}}],c)}return l}}var w5e=(t,e,n,r,i,s,o)=>{var l=Yr(o)?e:o,c=v5e(n,r,i!==s?i:s,t,l);return i!==s&&c!=null&&(c=c.map(u=>Q_(Q_({},u),{},{position:Q_(Q_({},u.position),{},{offset:u.position.offset-i/2})}))),c},_5e=st([b5e,rZ,H3e,iZ,y5e,BJ,h5e],w5e),S5e=(t,e,n,r)=>Sc(t,"xAxis",e,r),N5e=(t,e,n,r)=>Sc(t,"yAxis",n,r),M5e=(t,e,n,r)=>_c(t,"xAxis",e,r),k5e=(t,e,n,r)=>_c(t,"yAxis",n,r),E5e=st([_5e,xv],(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}}),T5e=(t,e)=>{var n=a2(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)}}}},A5e=st([p5e,xv],T5e),C5e=st([aa,RO,S5e,N5e,M5e,k5e,E5e,$n,rv,BJ,A5e,xv,f5e],(t,e,n,r,i,s,o,l,c,u,d,h,p)=>{var{chartData:m,dataStartIndex:x,dataEndIndex:y}=c;if(!(h==null||o==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||s==null||u==null)){var{data:v}=h,b;if(v!=null&&v.length>0?b=v:b=m?.slice(x,y+1),b!=null)return r5e({layout:l,barSettings:h,pos:o,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:s,stackedData:d,displayedData:b,offset:t,cells:p,dataStartIndex:x})}}),HJ=t=>{var{chartData:e}=t,n=Lr(),r=sa();return _.useEffect(()=>r?()=>{}:(n(sG(e)),()=>{n(sG(void 0))}),[e,n,r]),null},e7={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},$J=Ws({name:"brush",initialState:e7,reducers:{setBrushSettings(t,e){return e.payload==null?e7:e.payload}}}),{setBrushSettings:uQe}=$J.actions,j5e=$J.reducer;function t7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Z_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?t7(Object(n),!0).forEach(function(r){VJ(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):t7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function VJ(t,e,n){return(e=P5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function P5e(t){var e=D5e(t,"string");return typeof e=="symbol"?e:e+""}function D5e(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 R5e=(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)}},O5e=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return R5e({x:e,y:n},{x:r,y:i})};class S2{static create(e){return new S2(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}}VJ(S2,"EPS",1e-4);var L5e=t=>{var e=Object.keys(t).reduce((n,r)=>Z_(Z_({},n),{},{[r]:S2.create(t[r])}),{});return Z_(Z_({},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 F5e(t){return(t%180+180)%180}var I5e=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=F5e(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)},U5e={dots:[],areas:[],lines:[]},GJ=Ws({name:"referenceElements",initialState:U5e,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Il(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=Il(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=Il(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:dQe,removeDot:hQe,addArea:fQe,removeArea:mQe,addLine:z5e,removeLine:B5e}=GJ.actions,H5e=GJ.reducer,qJ=_.createContext(void 0),$5e=t=>{var{children:e}=t,[n]=_.useState("".concat(sy("recharts"),"-clip")),r=w2();if(r==null)return null;var{x:i,y:s,width:o,height:l}=r;return _.createElement(qJ.Provider,{value:n},_.createElement("defs",null,_.createElement("clipPath",{id:n},_.createElement("rect",{x:i,y:s,height:l,width:o}))),e)},V5e=()=>_.useContext(qJ);function n7(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 r7(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?n7(Object(n),!0).forEach(function(r){G5e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):n7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function G5e(t,e,n){return(e=q5e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function q5e(t){var e=W5e(t,"string");return typeof e=="symbol"?e:e+""}function W5e(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 JS(){return JS=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},JS.apply(null,arguments)}var K5e=(t,e)=>{var n;if(_.isValidElement(t))n=_.cloneElement(t,e);else if(typeof t=="function")n=t(e);else{if(!vr(e.x1)||!vr(e.y1)||!vr(e.x2)||!vr(e.y2))return null;n=_.createElement("line",JS({},e,{className:"recharts-reference-line-line"}))}return n},X5e=(t,e,n,r,i,s)=>{var{x:o,width:l}=s,c=i.y.apply(t,{position:n});if(qs(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},Y5e=(t,e,n,r,i,s)=>{var{y:o,height:l}=s,c=i.x.apply(t,{position:n});if(qs(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},Q5e=(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},Z5e=(t,e,n,r,i,s)=>{var{x:o,y:l,segment:c,ifOverflow:u}=s,d=hl(o),h=hl(l);return h?X5e(l,u,n,i,t,e):d?Y5e(o,u,n,r,t,e):c!=null&&c.length===2?Q5e(c,u,n,t):null};function J5e(t){var e=Lr();return _.useEffect(()=>(e(z5e(t)),()=>{e(B5e(t))})),null}function eUe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:s}=t,o=sa(),l=V5e(),c=Ut(C=>Cc(C,e)),u=Ut(C=>jc(C,n)),d=Ut(C=>Ah(C,"xAxis",e,o)),h=Ut(C=>Ah(C,"yAxis",n,o)),p=Qy();if(!l||!p||c==null||u==null||d==null||h==null)return null;var m=L5e({x:d,y:h}),x=Z5e(m,p,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:y,y:v},{x:b,y:S}]=x,N=s==="hidden"?"url(#".concat(l,")"):void 0,T=r7(r7({clipPath:N},Ha(t)),{},{x1:y,y1:v,x2:b,y2:S}),k=O5e({x1:y,y1:v,x2:b,y2:S});return _.createElement(rs,{zIndex:t.zIndex},_.createElement(li,{className:nr("recharts-reference-line",i)},K5e(r,T),_.createElement(wJ,JS({},k,{lowerWidth:k.width,upperWidth:k.width}),_.createElement(SJ,{label:t.label}),t.children)))}var tUe={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:vi.line};function d0(t){var e=ci(t,tUe);return _.createElement(_.Fragment,null,_.createElement(J5e,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),_.createElement(eUe,e))}d0.displayName="ReferenceLine";function WJ(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 nUe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return I5e(r,n)}function rUe(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 eN(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 iUe(t,e){return WJ(t,e+1)}function aUe(t,e,n,r,i){for(var s=(r||[]).slice(),{start:o,end:l}=e,c=0,u=1,d=o,h=function(){var x=r?.[c];if(x===void 0)return{v:WJ(r,u)};var y=c,v,b=()=>(v===void 0&&(v=n(x,y)),v),S=x.coordinate,N=c===0||eN(t,S,b,d,l);N||(c=0,d=o,u+=1),N&&(d=S+t*(b()/2+i),c+=u)},p;u<=s.length;)if(p=h(),p)return p.v;return[]}function i7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Xa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?i7(Object(n),!0).forEach(function(r){sUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function sUe(t,e,n){return(e=oUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function oUe(t){var e=lUe(t,"string");return typeof e=="symbol"?e:e+""}function lUe(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 cUe(t,e,n,r,i){for(var s=(r||[]).slice(),o=s.length,{start:l}=e,{end:c}=e,u=function(p){var m=s[p],x,y=()=>(x===void 0&&(x=n(m,p)),x);if(p===o-1){var v=t*(m.coordinate+t*y()/2-c);s[p]=m=Xa(Xa({},m),{},{tickCoord:v>0?m.coordinate-v*t:m.coordinate})}else s[p]=m=Xa(Xa({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var b=eN(t,m.tickCoord,y,l,c);b&&(c=m.tickCoord-t*(y()/2+i),s[p]=Xa(Xa({},m),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return s}function uUe(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],h=n(d,l-1),p=t*(d.coordinate+t*h/2-u);if(o[l-1]=d=Xa(Xa({},d),{},{tickCoord:p>0?d.coordinate-p*t:d.coordinate}),d.tickCoord!=null){var m=eN(t,d.tickCoord,()=>h,c,u);m&&(u=d.tickCoord-t*(h/2+i),o[l-1]=Xa(Xa({},d),{},{isShow:!0}))}}for(var x=s?l-1:l,y=function(S){var N=o[S],T,k=()=>(T===void 0&&(T=n(N,S)),T);if(S===0){var C=t*(N.coordinate-t*k()/2-c);o[S]=N=Xa(Xa({},N),{},{tickCoord:C<0?N.coordinate-C*t:N.coordinate})}else o[S]=N=Xa(Xa({},N),{},{tickCoord:N.coordinate});if(N.tickCoord!=null){var E=eN(t,N.tickCoord,k,c,u);E&&(c=N.tickCoord+t*(k()/2+i),o[S]=Xa(Xa({},N),{},{isShow:!0}))}},v=0;v<x;v++)y(v);return o}function cL(t,e,n){var{tick:r,ticks:i,viewBox:s,minTickGap:o,orientation:l,interval:c,tickFormatter:u,unit:d,angle:h}=t;if(!i||!i.length||!r)return[];if(Bt(c)||kx.isSsr){var p;return(p=iUe(i,Bt(c)?c:0))!==null&&p!==void 0?p:[]}var m=[],x=l==="top"||l==="bottom"?"width":"height",y=d&&x==="width"?k0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},v=(N,T)=>{var k=typeof u=="function"?u(N.value,T):N.value;return x==="width"?nUe(k0(k,{fontSize:e,letterSpacing:n}),y,h):k0(k,{fontSize:e,letterSpacing:n})[x]},b=i.length>=2?_a(i[1].coordinate-i[0].coordinate):1,S=rUe(s,b,x);return c==="equidistantPreserveStart"?aUe(b,S,v,i,o):(c==="preserveStart"||c==="preserveStartEnd"?m=uUe(b,S,v,i,o,c==="preserveStartEnd"):m=cUe(b,S,v,i,o),m.filter(N=>N.isShow))}var dUe=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 h=d.getBoundingClientRect();h.width>o&&(o=h.width)}});var l=n?n.getBoundingClientRect().width:0,c=i+s,u=o+c+l+(n?r:0);return Math.round(u)}return 0},hUe=["axisLine","width","height","className","hide","ticks","axisType"];function fUe(t,e){if(t==null)return{};var n,r,i=mUe(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 mUe(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 vm(){return vm=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},vm.apply(null,arguments)}function a7(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ii(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?a7(Object(n),!0).forEach(function(r){pUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pUe(t,e,n){return(e=gUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gUe(t){var e=xUe(t,"string");return typeof e=="symbol"?e:e+""}function xUe(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 Pu={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:vi.axis};function bUe(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=Ii(Ii(Ii({},c),ws(l)),{},{fill:"none"});if(s==="top"||s==="bottom"){var d=+(s==="top"&&!o||s==="bottom"&&o);u=Ii(Ii({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var h=+(s==="left"&&!o||s==="right"&&o);u=Ii(Ii({},u),{},{x1:e+h*r,y1:n,x2:e+h*r,y2:n+i})}return _.createElement("line",vm({},u,{className:nr("recharts-cartesian-axis-line",gm(l,"className"))}))}function yUe(t,e,n,r,i,s,o,l,c){var u,d,h,p,m,x,y=l?-1:1,v=t.tickSize||o,b=Bt(t.tickCoord)?t.tickCoord:t.coordinate;switch(s){case"top":u=d=t.coordinate,p=n+ +!l*i,h=p-y*v,x=h-y*c,m=b;break;case"left":h=p=t.coordinate,d=e+ +!l*r,u=d-y*v,m=u-y*c,x=b;break;case"right":h=p=t.coordinate,d=e+ +l*r,u=d+y*v,m=u+y*c,x=b;break;default:u=d=t.coordinate,p=n+ +l*i,h=p+y*v,x=h+y*c,m=b;break}return{line:{x1:u,y1:h,x2:d,y2:p},tick:{x:m,y:x}}}function vUe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function wUe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function _Ue(t){var{option:e,tickProps:n,value:r}=t,i,s=nr(n.className,"recharts-cartesian-axis-tick-value");if(_.isValidElement(e))i=_.cloneElement(e,Ii(Ii({},n),{},{className:s}));else if(typeof e=="function")i=e(Ii(Ii({},n),{},{className:s}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=nr(o,e?.className)),i=_.createElement(m2,vm({},n,{className:o}),r)}return i}var SUe=_.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:s,tickFormatter:o,unit:l,padding:c,tickTextProps:u,orientation:d,mirror:h,x:p,y:m,width:x,height:y,tickSize:v,tickMargin:b,fontSize:S,letterSpacing:N,getTicksConfig:T,events:k,axisType:C}=t,E=cL(Ii(Ii({},T),{},{ticks:n}),S,N),P=vUe(d,h),A=wUe(d,h),D=ws(T),I=pm(r),L={};typeof i=="object"&&(L=i);var U=Ii(Ii({},D),{},{fill:"none"},L),j=E.map(z=>Ii({entry:z},yUe(z,p,m,x,y,d,v,h,b))),V=j.map(z=>{var{entry:X,line:Y}=z;return _.createElement(li,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(X.value,"-").concat(X.coordinate,"-").concat(X.tickCoord)},i&&_.createElement("line",vm({},U,Y,{className:nr("recharts-cartesian-axis-tick-line",gm(i,"className"))})))}),K=j.map((z,X)=>{var{entry:Y,tick:te}=z,$=Ii(Ii(Ii(Ii({textAnchor:P,verticalAnchor:A},D),{},{stroke:"none",fill:s},I),te),{},{index:X,payload:Y,visibleTicksCount:E.length,tickFormatter:o,padding:c},u);return _.createElement(li,vm({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Y.value,"-").concat(Y.coordinate,"-").concat(Y.tickCoord)},qy(k,Y,X)),r&&_.createElement(_Ue,{option:r,tickProps:$,value:"".concat(typeof o=="function"?o(Y.value,X):Y.value).concat(l||"")}))});return _.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(C,"-ticks")},K.length>0&&_.createElement(rs,{zIndex:vi.label},_.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(C,"-tick-labels"),ref:e},K)),V.length>0&&_.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(C,"-tick-lines")},V))}),NUe=_.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:s,hide:o,ticks:l,axisType:c}=t,u=fUe(t,hUe),[d,h]=_.useState(""),[p,m]=_.useState(""),x=_.useRef(null);_.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var v;return dUe({ticks:x.current,label:(v=t.labelRef)===null||v===void 0?void 0:v.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var y=_.useCallback(v=>{if(v){var b=v.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=b;var S=b[0];if(S){var N=window.getComputedStyle(S),T=N.fontSize,k=N.letterSpacing;(T!==d||k!==p)&&(h(T),m(k))}}},[d,p]);return o||r!=null&&r<=0||i!=null&&i<=0?null:_.createElement(rs,{zIndex:t.zIndex},_.createElement(li,{className:nr("recharts-cartesian-axis",s)},_.createElement(bUe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:ws(t)}),_.createElement(SUe,{ref:y,axisType:c,events:u,fontSize:d,getTicksConfig:t,height:t.height,letterSpacing:p,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}),_.createElement(wJ,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},_.createElement(SJ,{label:t.label,labelRef:t.labelRef}),t.children)))}),uL=_.forwardRef((t,e)=>{var n=ci(t,Pu);return _.createElement(NUe,vm({},n,{ref:e}))});uL.displayName="CartesianAxis";var MUe=["x1","y1","x2","y2","key"],kUe=["offset"],EUe=["xAxisId","yAxisId"],TUe=["xAxisId","yAxisId"];function s7(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 Za(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?s7(Object(n),!0).forEach(function(r){AUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):s7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function AUe(t,e,n){return(e=CUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function CUe(t){var e=jUe(t,"string");return typeof e=="symbol"?e:e+""}function jUe(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 Ff(){return Ff=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},Ff.apply(null,arguments)}function tN(t,e){if(t==null)return{};var n,r,i=PUe(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 PUe(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 DUe=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 _.createElement("rect",{x:r,y:i,ry:l,width:s,height:o,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function KJ(t){var{option:e,lineItemProps:n}=t,r;if(_.isValidElement(e))r=_.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=tN(n,MUe),h=(i=ws(d))!==null&&i!==void 0?i:{},{offset:p}=h,m=tN(h,kUe);r=_.createElement("line",Ff({},m,{x1:s,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function RUe(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=tN(t,EUe),c=i.map((u,d)=>{var h=Za(Za({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return _.createElement(KJ,{key:"line-".concat(d),option:r,lineItemProps:h})});return _.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function OUe(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=tN(t,TUe),c=i.map((u,d)=>{var h=Za(Za({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return _.createElement(KJ,{option:r,lineItemProps:h,key:"line-".concat(d)})});return _.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function LUe(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(h=>Math.round(h+i-i)).sort((h,p)=>h-p);i!==u[0]&&u.unshift(0);var d=u.map((h,p)=>{var m=!u[p+1],x=m?i+o-h:u[p+1]-h;if(x<=0)return null;var y=p%e.length;return _.createElement("rect",{key:"react-".concat(p),y:h,x:r,height:x,width:s,stroke:"none",fill:e[y],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return _.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function FUe(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(h=>Math.round(h+i-i)).sort((h,p)=>h-p);i!==u[0]&&u.unshift(0);var d=u.map((h,p)=>{var m=!u[p+1],x=m?i+o-h:u[p+1]-h;if(x<=0)return null;var y=p%n.length;return _.createElement("rect",{key:"react-".concat(p),x:h,y:s,width:x,height:l,stroke:"none",fill:n[y],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return _.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var IUe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:s}=t;return jY(cL(Za(Za(Za({},Pu),n),{},{ticks:PY(n),viewBox:{x:0,y:0,width:r,height:i}})),s.left,s.left+s.width,e)},UUe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:s}=t;return jY(cL(Za(Za(Za({},Pu),n),{},{ticks:PY(n),viewBox:{x:0,y:0,width:r,height:i}})),s.top,s.top+s.height,e)},zUe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:vi.grid};function nN(t){var e=LO(),n=FO(),r=BY(),i=Za(Za({},ci(t,zUe)),{},{x:Bt(t.x)?t.x:r.left,y:Bt(t.y)?t.y:r.top,width:Bt(t.width)?t.width:r.width,height:Bt(t.height)?t.height:r.height}),{xAxisId:s,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:h,horizontalValues:p,verticalValues:m}=i,x=sa(),y=Ut(A=>KV(A,"xAxis",s,x)),v=Ut(A=>KV(A,"yAxis",o,x));if(!vc(u)||!vc(d)||!Bt(l)||!Bt(c))return null;var b=i.verticalCoordinatesGenerator||IUe,S=i.horizontalCoordinatesGenerator||UUe,{horizontalPoints:N,verticalPoints:T}=i;if((!N||!N.length)&&typeof S=="function"){var k=p&&p.length,C=S({yAxis:v?Za(Za({},v),{},{ticks:k?p:v.ticks}):void 0,width:e??u,height:n??d,offset:r},k?!0:h);MS(Array.isArray(C),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof C,"]")),Array.isArray(C)&&(N=C)}if((!T||!T.length)&&typeof b=="function"){var E=m&&m.length,P=b({xAxis:y?Za(Za({},y),{},{ticks:E?m:y.ticks}):void 0,width:e??u,height:n??d,offset:r},E?!0:h);MS(Array.isArray(P),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof P,"]")),Array.isArray(P)&&(T=P)}return _.createElement(rs,{zIndex:i.zIndex},_.createElement("g",{className:"recharts-cartesian-grid"},_.createElement(DUe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),_.createElement(LUe,Ff({},i,{horizontalPoints:N})),_.createElement(FUe,Ff({},i,{verticalPoints:T})),_.createElement(RUe,Ff({},i,{offset:r,horizontalPoints:N,xAxis:y,yAxis:v})),_.createElement(OUe,Ff({},i,{offset:r,verticalPoints:T,xAxis:y,yAxis:v}))))}nN.displayName="CartesianGrid";var XJ=(t,e,n,r)=>Sc(t,"xAxis",e,r),YJ=(t,e,n,r)=>_c(t,"xAxis",e,r),QJ=(t,e,n,r)=>Sc(t,"yAxis",n,r),ZJ=(t,e,n,r)=>_c(t,"yAxis",n,r),BUe=st([$n,XJ,QJ,YJ,ZJ],(t,e,n,r,i)=>Ac(t,"xAxis")?Eh(e,r,!1):Eh(n,i,!1)),HUe=(t,e,n,r,i)=>i;function $Ue(t){return t.type==="line"}var VUe=st([ov,HUe],(t,e)=>t.filter($Ue).find(n=>n.id===e)),GUe=st([$n,XJ,QJ,YJ,ZJ,VUe,BUe,rv],(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:h,data:p}=s,m;if(p!=null&&p.length>0?m=p:m=c?.slice(u,d+1),m!=null)return dze({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:h,bandSize:o,displayedData:m})}});function JJ(t){var e=pm(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 qUe=["id"],WUe=["type","layout","connectNulls","needClip","shape"],KUe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function wy(){return wy=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},wy.apply(null,arguments)}function o7(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 ac(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?o7(Object(n),!0).forEach(function(r){XUe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function XUe(t,e,n){return(e=YUe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function YUe(t){var e=QUe(t,"string");return typeof e=="symbol"?e:e+""}function QUe(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 dL(t,e){if(t==null)return{};var n,r,i=ZUe(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 ZUe(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 JUe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:s}=t;return[{inactive:s,dataKey:e,type:i,color:r,value:Ih(n,e),payload:t}]},eze=_.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:Ih(o,e),hide:l,type:u,color:r,unit:c}};return _.createElement(b2,{tooltipEntrySettings:d})}),eee=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function tze(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var nze=(t,e,n)=>{var r=n.reduce((h,p)=>h+p);if(!r)return eee(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[...tze(n,i),...l,...d].map(h=>"".concat(h,"px")).join(", ")};function rze(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:s,needClip:o}=r,{id:l}=r,c=dL(r,qUe),u=ws(c);return _.createElement(OJ,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:s,baseProps:u,needClip:o,clipPathId:e})}function ize(t){var{showLabels:e,children:n,points:r}=t,i=_.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 ac(ac({},c),{},{value:s.value,payload:s.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return _.createElement(Q4,{value:e?i:void 0},n)}function l7(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:s}=t,{type:o,layout:l,connectNulls:c,needClip:u,shape:d}=s,h=dL(s,WUe),p=ac(ac({},Ha(h)),{},{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 _.createElement(_.Fragment,null,r?.length>1&&_.createElement(nL,wy({shapeType:"curve",option:d},p,{pathRef:n})),_.createElement(rze,{points:r,clipPathId:e,props:s}))}function aze(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function sze(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:s}=t,{points:o,strokeDasharray:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:h,animateNewValues:p,width:m,height:x,onAnimationEnd:y,onAnimationStart:v}=n,b=i.current,S=Tx(o,"recharts-line-"),N=_.useRef(S),[T,k]=_.useState(!1),C=!T,E=_.useCallback(()=>{typeof y=="function"&&y(),k(!1)},[y]),P=_.useCallback(()=>{typeof v=="function"&&v(),k(!0)},[v]),A=aze(r.current),D=_.useRef(0);N.current!==S&&(D.current=s.current,N.current=S);var I=D.current;return _.createElement(ize,{points:o,showLabels:C},n.children,_.createElement(Ex,{animationId:S,begin:u,duration:d,isActive:c,easing:h,onAnimationEnd:E,onAnimationStart:P,key:S},L=>{var U=mr(I,A+I,L),j=Math.min(U,A),V;if(c)if(l){var K="".concat(l).split(/[,\s]+/gim).map(Y=>parseFloat(Y));V=nze(j,A,K)}else V=eee(A,j);else V=l==null?void 0:String(l);if(L>0&&A>0&&(i.current=o,s.current=Math.max(s.current,j)),b){var z=b.length/o.length,X=L===1?o:o.map((Y,te)=>{var $=Math.floor(te*z);if(b[$]){var W=b[$];return ac(ac({},Y),{},{x:mr(W.x,Y.x,L),y:mr(W.y,Y.y,L)})}return p?ac(ac({},Y),{},{x:mr(m*2,Y.x,L),y:mr(x/2,Y.y,L)}):ac(ac({},Y),{},{x:Y.x,y:Y.y})});return i.current=X,_.createElement(l7,{props:n,points:X,clipPathId:e,pathRef:r,strokeDasharray:V})}return _.createElement(l7,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:V})}),_.createElement(p2,{label:n.label}))}function oze(t){var{clipPathId:e,props:n}=t,r=_.useRef(null),i=_.useRef(0),s=_.useRef(null);return _.createElement(sze,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:s})}var lze=(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:yr(t.payload,e)}};class cze extends _.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:s,yAxisId:o,top:l,left:c,width:u,height:d,id:h,needClip:p,zIndex:m}=this.props;if(e)return null;var x=nr("recharts-line",i),y=h,{r:v,strokeWidth:b}=JJ(n),S=tL(n),N=v*2+b,T=p?"url(#clipPath-".concat(S?"":"dots-").concat(y,")"):void 0;return _.createElement(rs,{zIndex:m},_.createElement(li,{className:x},p&&_.createElement("defs",null,_.createElement(lL,{clipPathId:y,xAxisId:s,yAxisId:o}),!S&&_.createElement("clipPath",{id:"clipPath-dots-".concat(y)},_.createElement("rect",{x:c-N/2,y:l-N/2,width:u+N,height:d+N}))),_.createElement(IJ,{xAxisId:s,yAxisId:o,data:r,dataPointFormatter:lze,errorBarOffset:0},_.createElement(oze,{props:this.props,clipPathId:y}))),_.createElement(vD,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:T}))}}var tee={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:vi.line,type:"linear"};function uze(t){var e=ci(t,tee),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:h,legendType:p,xAxisId:m,yAxisId:x,id:y}=e,v=dL(e,KUe),{needClip:b}=_2(m,x),S=w2(),N=Cm(),T=sa(),k=Ut(D=>GUe(D,m,x,T,y));if(N!=="horizontal"&&N!=="vertical"||k==null||S==null)return null;var{height:C,width:E,x:P,y:A}=S;return _.createElement(cze,wy({},v,{id:y,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:s,animationEasing:o,isAnimationActive:d,hide:u,label:h,legendType:p,xAxisId:m,yAxisId:x,points:k,layout:N,height:C,width:E,left:P,top:A,needClip:b}))}function dze(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 h=yr(u,o);if(e==="horizontal"){var p=NS({axis:n,ticks:i,bandSize:l,entry:u,index:d}),m=Yr(h)?null:r.scale(h);return{x:p,y:m,value:h,payload:u}}var x=Yr(h)?null:n.scale(h),y=NS({axis:r,ticks:s,bandSize:l,entry:u,index:d});return x==null||y==null?null:{x,y,value:h,payload:u}}).filter(Boolean)}function hze(t){var e=ci(t,tee),n=sa();return _.createElement(y2,{id:e.id,type:"line"},r=>_.createElement(_.Fragment,null,_.createElement(sL,{legendPayload:JUe(e)}),_.createElement(eze,{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}),_.createElement(oL,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),_.createElement(uze,wy({},e,{id:r}))))}var nee=_.memo(hze,gv);nee.displayName="Line";var ree=(t,e,n,r)=>Sc(t,"xAxis",e,r),iee=(t,e,n,r)=>_c(t,"xAxis",e,r),aee=(t,e,n,r)=>Sc(t,"yAxis",n,r),see=(t,e,n,r)=>_c(t,"yAxis",n,r),fze=st([$n,ree,aee,iee,see],(t,e,n,r,i)=>Ac(t,"xAxis")?Eh(e,r,!1):Eh(n,i,!1)),mze=(t,e,n,r,i)=>i,oee=st([ov,mze],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),pze=(t,e,n,r,i)=>{var s,o=oee(t,e,n,r,i);if(o!=null){var l=$n(t),c=Ac(l,"xAxis"),u;if(c?u=yy(t,"yAxis",n,r):u=yy(t,"xAxis",e,r),u!=null){var{stackId:d}=o,h=a2(o);if(!(d==null||h==null)){var p=(s=u[d])===null||s===void 0?void 0:s.stackedData;return p?.find(m=>m.key===h)}}}},gze=st([$n,ree,aee,iee,see,pze,rv,fze,oee,V3e],(t,e,n,r,i,s,o,l,c,u)=>{var{chartData:d,dataStartIndex:h,dataEndIndex:p}=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:m}=c,x;if(m&&m.length>0?x=m:x=d?.slice(h,p+1),x!=null)return Oze({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:h,areaSettings:c,stackedData:s,displayedData:x,chartBaseValue:u,bandSize:l})}}),xze=["id"],bze=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Yf(){return Yf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Yf.apply(null,arguments)}function lee(t,e){if(t==null)return{};var n,r,i=yze(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 yze(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function c7(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 wg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?c7(Object(n),!0).forEach(function(r){vze(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):c7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function vze(t,e,n){return(e=wze(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function wze(t){var e=_ze(t,"string");return typeof e=="symbol"?e:e+""}function _ze(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 rN(t,e){return t&&t!=="none"?t:e}var Sze=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:s,hide:o}=t;return[{inactive:o,dataKey:e,type:s,color:rN(r,i),value:Ih(n,e),payload:t}]},Nze=_.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:Ih(o,e),hide:l,type:u,color:rN(r,s),unit:c}};return _.createElement(b2,{tooltipEntrySettings:d})});function Mze(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:s,dataKey:o}=r,l=ws(r);return _.createElement(OJ,{points:n,dot:s,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function kze(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 wg(wg({},c),{},{value:s.value,payload:s.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return _.createElement(Q4,{value:e?i:void 0},n)}function u7(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:h}=s,p=lee(s,xze),m=ws(p),x=Ha(p);return _.createElement(_.Fragment,null,e?.length>1&&_.createElement(li,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},_.createElement(Rg,Yf({},x,{id:h,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&_.createElement(Rg,Yf({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&_.createElement(Rg,Yf({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),_.createElement(Mze,{points:e,props:p,clipPathId:i}))}function Eze(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].y,o=r[r.length-1].y;if(!vr(s)||!vr(o))return null;var l=e*Math.abs(s-o),c=Math.max(...r.map(u=>u.x||0));return Bt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),Bt(c)?_.createElement("rect",{x:0,y:s<o?s:s-l,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(l)}):null}function Tze(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,s=r[0].x,o=r[r.length-1].x;if(!vr(s)||!vr(o))return null;var l=e*Math.abs(s-o),c=Math.max(...r.map(u=>u.y||0));return Bt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),Bt(c)?_.createElement("rect",{x:s<o?s:s-l,y:0,width:l,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function Aze(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:s}=t;return n==="vertical"?_.createElement(Eze,{alpha:e,points:r,baseLine:i,strokeWidth:s}):_.createElement(Tze,{alpha:e,points:r,baseLine:i,strokeWidth:s})}function Cze(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s}=t,{points:o,baseLine:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:h,onAnimationStart:p,onAnimationEnd:m}=r,x=_.useMemo(()=>({points:o,baseLine:l}),[o,l]),y=Tx(x,"recharts-area-"),v=lAe(),[b,S]=_.useState(!1),N=!b,T=_.useCallback(()=>{typeof m=="function"&&m(),S(!1)},[m]),k=_.useCallback(()=>{typeof p=="function"&&p(),S(!0)},[p]);if(v==null)return null;var C=i.current,E=s.current;return _.createElement(kze,{showLabels:N,points:o},r.children,_.createElement(Ex,{animationId:y,begin:u,duration:d,isActive:c,easing:h,onAnimationEnd:T,onAnimationStart:k,key:y},P=>{if(C){var A=C.length/o.length,D=P===1?o:o.map((L,U)=>{var j=Math.floor(U*A);if(C[j]){var V=C[j];return wg(wg({},L),{},{x:mr(V.x,L.x,P),y:mr(V.y,L.y,P)})}return L}),I;return Bt(l)?I=mr(E,l,P):Yr(l)||qs(l)?I=mr(E,0,P):I=l.map((L,U)=>{var j=Math.floor(U*A);if(Array.isArray(E)&&E[j]){var V=E[j];return wg(wg({},L),{},{x:mr(V.x,L.x,P),y:mr(V.y,L.y,P)})}return L}),P>0&&(i.current=D,s.current=I),_.createElement(u7,{points:D,baseLine:I,needClip:e,clipPathId:n,props:r})}return P>0&&(i.current=o,s.current=l),_.createElement(li,null,c&&_.createElement("defs",null,_.createElement("clipPath",{id:"animationClipPath-".concat(n)},_.createElement(Aze,{alpha:P,points:o,baseLine:l,layout:v,strokeWidth:r.strokeWidth}))),_.createElement(li,{clipPath:"url(#animationClipPath-".concat(n,")")},_.createElement(u7,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),_.createElement(p2,{label:r.label}))}function jze(t){var{needClip:e,clipPathId:n,props:r}=t,i=_.useRef(null),s=_.useRef();return _.createElement(Cze,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:s})}class Pze extends _.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:s,left:o,needClip:l,xAxisId:c,yAxisId:u,width:d,height:h,id:p,baseLine:m,zIndex:x}=this.props;if(e)return null;var y=nr("recharts-area",i),v=p,{r:b,strokeWidth:S}=JJ(n),N=tL(n),T=b*2+S,k=l?"url(#clipPath-".concat(N?"":"dots-").concat(v,")"):void 0;return _.createElement(rs,{zIndex:x},_.createElement(li,{className:y},l&&_.createElement("defs",null,_.createElement(lL,{clipPathId:v,xAxisId:c,yAxisId:u}),!N&&_.createElement("clipPath",{id:"clipPath-dots-".concat(v)},_.createElement("rect",{x:o-T/2,y:s-T/2,width:d+T,height:h+T}))),_.createElement(jze,{needClip:l,clipPathId:v,props:this.props})),_.createElement(vD,{points:r,mainColor:rN(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:k}),this.props.isRange&&Array.isArray(m)&&_.createElement(vD,{points:m,mainColor:rN(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:k}))}}var cee={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:vi.area};function Dze(t){var e,n=ci(t,cee),{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:h,isAnimationActive:p,legendType:m,stroke:x,xAxisId:y,yAxisId:v}=n,b=lee(n,bze),S=Cm(),N=iJ(),{needClip:T}=_2(y,v),k=sa(),{points:C,isRange:E,baseLine:P}=(e=Ut(j=>gze(j,y,v,k,t.id)))!==null&&e!==void 0?e:{},A=w2();if(S!=="horizontal"&&S!=="vertical"||A==null||N!=="AreaChart"&&N!=="ComposedChart")return null;var{height:D,width:I,x:L,y:U}=A;return!C||!C.length?null:_.createElement(Pze,Yf({},b,{activeDot:r,animationBegin:i,animationDuration:s,animationEasing:o,baseLine:P,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:D,hide:h,layout:S,isAnimationActive:p==="auto"?!kx.isSsr:p,isRange:E,legendType:m,needClip:T,points:C,stroke:x,width:I,left:L,top:U,xAxisId:y,yAxisId:v}))}var Rze=(t,e,n,r,i)=>{var s=n??e;if(Bt(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 Oze(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:s,chartBaseValue:o,xAxis:l,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:h,yAxisTicks:p,bandSize:m}=t,x=i&&i.length,y=Rze(s,o,n,l,c),v=s==="horizontal",b=!1,S=u.map((T,k)=>{var C;x?C=i[d+k]:(C=yr(T,r),Array.isArray(C)?b=!0:C=[y,C]);var E=C[1]==null||x&&!e&&yr(T,r)==null;return v?{x:NS({axis:l,ticks:h,bandSize:m,entry:T,index:k}),y:E?null:c.scale(C[1]),value:C,payload:T}:{x:E?null:l.scale(C[1]),y:NS({axis:c,ticks:p,bandSize:m,entry:T,index:k}),value:C,payload:T}}),N;return x||b?N=S.map(T=>{var k=Array.isArray(T.value)?T.value[0]:null;return v?{x:T.x,y:k!=null&&T.y!=null?c.scale(k):null,payload:T.payload}:{x:k!=null?l.scale(k):null,y:T.y,payload:T.payload}}):N=v?c.scale(y):l.scale(y),{points:S,baseLine:N,isRange:b}}function Lze(t){var e=ci(t,cee),n=sa();return _.createElement(y2,{id:e.id,type:"area"},r=>_.createElement(_.Fragment,null,_.createElement(sL,{legendPayload:Sze(e)}),_.createElement(Nze,{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}),_.createElement(oL,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:DY(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),_.createElement(Dze,Yf({},e,{id:r}))))}var uee=_.memo(Lze,gv);uee.displayName="Area";var Fze=["domain","range"],Ize=["domain","range"];function d7(t,e){if(t==null)return{};var n,r,i=Uze(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 Uze(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 h7(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 dee(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=d7(t,Fze),{domain:s,range:o}=e,l=d7(e,Ize);return!h7(n,s)||!h7(r,o)?!1:gv(i,l)}var zze=["dangerouslySetInnerHTML","ticks"],Bze=["id"];function _D(){return _D=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},_D.apply(null,arguments)}function f7(t,e){if(t==null)return{};var n,r,i=Hze(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 Hze(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 $ze(t){var e=Lr(),n=_.useRef(null);return _.useLayoutEffect(()=>{n.current===null?e(FFe(t)):n.current!==t&&e(IFe({prev:n.current,next:t})),n.current=t},[t,e]),_.useLayoutEffect(()=>()=>{n.current&&(e(UFe(n.current)),n.current=null)},[e]),null}var Vze=t=>{var{xAxisId:e,className:n}=t,r=Ut(RO),i=sa(),s="xAxis",o=Ut(v=>Ah(v,s,e,i)),l=Ut(v=>LZ(v,s,e,i)),c=Ut(v=>PZ(v,e)),u=Ut(v=>BDe(v,e)),d=Ut(v=>fZ(v,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:h,ticks:p}=t,m=f7(t,zze),{id:x}=d,y=f7(d,Bze);return _.createElement(uL,_D({},m,y,{scale:o,x:u.x,y:u.y,width:c.width,height:c.height,className:nr("recharts-".concat(s," ").concat(s),n),viewBox:r,ticks:l,axisType:s}))},Gze={allowDataOverflow:ga.allowDataOverflow,allowDecimals:ga.allowDecimals,allowDuplicatedCategory:ga.allowDuplicatedCategory,angle:ga.angle,axisLine:Pu.axisLine,height:ga.height,hide:!1,includeHidden:ga.includeHidden,interval:ga.interval,minTickGap:ga.minTickGap,mirror:ga.mirror,orientation:ga.orientation,padding:ga.padding,reversed:ga.reversed,scale:ga.scale,tick:ga.tick,tickCount:ga.tickCount,tickLine:Pu.tickLine,tickSize:Pu.tickSize,type:ga.type,xAxisId:0},qze=t=>{var e=ci(t,Gze);return _.createElement(_.Fragment,null,_.createElement($ze,{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}),_.createElement(Vze,e))},iN=_.memo(qze,dee);iN.displayName="XAxis";var Wze=["dangerouslySetInnerHTML","ticks"],Kze=["id"];function SD(){return SD=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},SD.apply(null,arguments)}function m7(t,e){if(t==null)return{};var n,r,i=Xze(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 Xze(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 Yze(t){var e=Lr(),n=_.useRef(null);return _.useLayoutEffect(()=>{n.current===null?e(zFe(t)):n.current!==t&&e(BFe({prev:n.current,next:t})),n.current=t},[t,e]),_.useLayoutEffect(()=>()=>{n.current&&(e(HFe(n.current)),n.current=null)},[e]),null}var Qze=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,s=_.useRef(null),o=_.useRef(null),l=Ut(RO),c=sa(),u=Lr(),d="yAxis",h=Ut(k=>Ah(k,d,e,c)),p=Ut(k=>DZ(k,e)),m=Ut(k=>$De(k,e)),x=Ut(k=>LZ(k,d,e,c)),y=Ut(k=>mZ(k,e));if(_.useLayoutEffect(()=>{if(!(r!=="auto"||!p||Y4(i)||_.isValidElement(i)||y==null)){var k=s.current;if(k){var C=k.getCalculatedWidth();Math.round(p.width)!==Math.round(C)&&u($Fe({id:e,width:C}))}}},[x,p,u,i,e,r,y]),p==null||m==null||y==null)return null;var{dangerouslySetInnerHTML:v,ticks:b}=t,S=m7(t,Wze),{id:N}=y,T=m7(y,Kze);return _.createElement(uL,SD({},S,T,{ref:s,labelRef:o,scale:h,x:m.x,y:m.y,tickTextProps:r==="auto"?{width:void 0}:{width:r},width:p.width,height:p.height,className:nr("recharts-".concat(d," ").concat(d),n),viewBox:l,ticks:x,axisType:d}))},Zze={allowDataOverflow:xa.allowDataOverflow,allowDecimals:xa.allowDecimals,allowDuplicatedCategory:xa.allowDuplicatedCategory,angle:xa.angle,axisLine:Pu.axisLine,hide:!1,includeHidden:xa.includeHidden,interval:xa.interval,minTickGap:xa.minTickGap,mirror:xa.mirror,orientation:xa.orientation,padding:xa.padding,reversed:xa.reversed,scale:xa.scale,tick:xa.tick,tickCount:xa.tickCount,tickLine:Pu.tickLine,tickSize:Pu.tickSize,type:xa.type,width:xa.width,yAxisId:0},Jze=t=>{var e=ci(t,Zze);return _.createElement(_.Fragment,null,_.createElement(Yze,{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}),_.createElement(Qze,e))},aN=_.memo(Jze,dee);aN.displayName="YAxis";var eBe=(t,e)=>e,hL=st([eBe,$n,dZ,la,ZZ,Yu,iOe,aa],dOe),fL=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)}},hee=fl("mouseClick"),fee=Xy();fee.startListening({actionCreator:hee,effect:(t,e)=>{var n=t.payload,r=hL(e.getState(),fL(n));r?.activeIndex!=null&&e.dispatch(rRe({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var ND=fl("mouseMove"),mee=Xy(),J_=null;mee.startListening({actionCreator:ND,effect:(t,e)=>{var n=t.payload;J_!==null&&cancelAnimationFrame(J_);var r=fL(n);J_=requestAnimationFrame(()=>{var i=e.getState(),s=U4(i,i.tooltip.settings.shared);if(s==="axis"){var o=hL(i,r);o?.activeIndex!=null?e.dispatch(VZ({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch($Z())}J_=null})}});var p7={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},pee=Ws({name:"rootProps",initialState:p7,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:p7.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}}}),tBe=pee.reducer,{updateOptions:nBe}=pee.actions,gee=Ws({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:rBe}=gee.actions,iBe=gee.reducer,xee=fl("keyDown"),bee=fl("focus"),mL=Xy();mL.startListening({actionCreator:xee,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=z4(i,Lx(n),cv(n),fv(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=Yu(n);if(s==="Enter"){var u=qS(n,"axis","hover",String(i.index));e.dispatch(mD({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=WDe(n),h=d==="left-to-right"?1:-1,p=s==="ArrowRight"?1:-1,m=l+p*h;if(!(c==null||m>=c.length||m<0)){var x=qS(n,"axis","hover",String(m));e.dispatch(mD({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});mL.startListening({actionCreator:bee,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=qS(n,"axis","hover",String(s));e.dispatch(mD({activeDataKey:void 0,active:!0,activeIndex:s,activeCoordinate:o}))}}}});var Vo=fl("externalEvent"),yee=Xy(),rj=new Map;yee.startListening({actionCreator:Vo,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,s=rj.get(i);s!==void 0&&cancelAnimationFrame(s);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:$Re(l),activeDataKey:G4(l),activeIndex:Ch(l),activeLabel:tJ(l),activeTooltipIndex:Ch(l),isTooltipActive:VRe(l)};n(c,r)}finally{rj.delete(i)}});rj.set(i,o)}}});var aBe=st([Ox],t=>t.tooltipItemPayloads),sBe=st([aBe,dv,(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}}}),vee=fl("touchMove"),wee=Xy();wee.startListening({actionCreator:vee,effect:(t,e)=>{var n=t.payload;if(!(n.touches==null||n.touches.length===0)){var r=e.getState(),i=U4(r,r.tooltip.settings.shared);if(i==="axis"){var s=hL(r,fL({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));s?.activeIndex!=null&&e.dispatch(VZ({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(OY),d=(o=c.getAttribute(LY))!==null&&o!==void 0?o:void 0,h=sBe(e.getState(),u,d);e.dispatch(HZ({activeDataKey:d,activeIndex:u,activeCoordinate:h}))}}}});var oBe=nY({brush:j5e,cartesianAxis:VFe,chartData:HOe,errorBars:cIe,graphicalItems:QLe,layout:pTe,legend:SAe,options:FOe,polarAxis:hLe,polarOptions:iBe,referenceElements:H5e,rootProps:tBe,tooltip:iRe,zIndex:MOe}),lBe=function(e){return zEe({reducer:oBe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([fee.middleware,mee.middleware,mL.middleware,yee.middleware,wee.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat(xY({type:"raf"}))},devTools:kx.devToolsEnabled})};function _ee(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=sa(),s=_.useRef(null);if(i)return n;s.current==null&&(s.current=lBe(e));var o=MO;return _.createElement(DIe,{context:o,store:s.current},n)}function cBe(t){var{layout:e,margin:n}=t,r=Lr(),i=sa();return _.useEffect(()=>{i||(r(hTe(e)),r(dTe(n)))},[r,i,e,n]),null}var See=_.memo(cBe,gv);function Nee(t){var e=Lr();return _.useEffect(()=>{e(nBe(t))},[e,t]),null}function g7(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=PJ("".concat(r).concat(e)),s=Lr();return _.useLayoutEffect(()=>(s(SOe({zIndex:e,elementId:i,isPanorama:n})),()=>{s(NOe({zIndex:e,isPanorama:n}))}),[s,e,i,n]),_.createElement("g",{tabIndex:-1,id:i})}function x7(t){var{children:e,isPanorama:n}=t,r=Ut(fOe);if(!r||r.length===0)return e;var i=r.filter(o=>o<0),s=r.filter(o=>o>0);return _.createElement(_.Fragment,null,i.map(o=>_.createElement(g7,{key:o,zIndex:o,isPanorama:n})),e,s.map(o=>_.createElement(g7,{key:o,zIndex:o,isPanorama:n})))}var uBe=["children"];function dBe(t,e){if(t==null)return{};var n,r,i=hBe(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 hBe(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 sN(){return sN=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},sN.apply(null,arguments)}var fBe={width:"100%",height:"100%",display:"block"},mBe=_.forwardRef((t,e)=>{var n=LO(),r=FO(),i=ZY();if(!vc(n)||!vc(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),_.createElement(pO,sN({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:fBe,ref:e}),s)}),pBe=t=>{var{children:e}=t,n=Ut(qM);if(!n)return null;var{width:r,height:i,y:s,x:o}=n;return _.createElement(pO,{width:r,height:i,x:o,y:s},e)},b7=_.forwardRef((t,e)=>{var{children:n}=t,r=dBe(t,uBe),i=sa();return i?_.createElement(pBe,null,_.createElement(x7,{isPanorama:!0},n)):_.createElement(mBe,sN({ref:e},r),_.createElement(x7,{isPanorama:!1},n))});function gBe(){var t=Lr(),[e,n]=_.useState(null),r=Ut(PTe);return _.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),s=i.width/e.offsetWidth;vr(s)&&s!==r&&t(mTe(s))}},[e,t,r]),n}function y7(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 xBe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?y7(Object(n),!0).forEach(function(r){bBe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):y7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function bBe(t,e,n){return(e=yBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function yBe(t){var e=vBe(t,"string");return typeof e=="symbol"?e:e+""}function vBe(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 wm(){return wm=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},wm.apply(null,arguments)}var wBe=()=>(QOe(),null);function oN(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var _Be=_.forwardRef((t,e)=>{var n,r,i=_.useRef(null),[s,o]=_.useState({containerWidth:oN((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:oN((r=t.style)===null||r===void 0?void 0:r.height)}),l=_.useCallback((u,d)=>{o(h=>{var p=Math.round(u),m=Math.round(d);return h.containerWidth===p&&h.containerHeight===m?h:{containerWidth:p,containerHeight:m}})},[]),c=_.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:h}=u.getBoundingClientRect();l(d,h);var p=x=>{var{width:y,height:v}=x[0].contentRect;l(y,v)},m=new ResizeObserver(p);m.observe(u),i.current=m}},[e,l]);return _.useEffect(()=>()=>{var u=i.current;u?.disconnect()},[l]),_.createElement(_.Fragment,null,_.createElement(WM,{width:s.containerWidth,height:s.containerHeight}),_.createElement("div",wm({ref:c},t)))}),SBe=_.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,s]=_.useState({containerWidth:oN(n),containerHeight:oN(r)}),o=_.useCallback((c,u)=>{s(d=>{var h=Math.round(c),p=Math.round(u);return d.containerWidth===h&&d.containerHeight===p?d:{containerWidth:h,containerHeight:p}})},[]),l=_.useCallback(c=>{if(typeof e=="function"&&e(c),c!=null){var{width:u,height:d}=c.getBoundingClientRect();o(u,d)}},[e,o]);return _.createElement(_.Fragment,null,_.createElement(WM,{width:i.containerWidth,height:i.containerHeight}),_.createElement("div",wm({ref:l},t)))}),NBe=_.forwardRef((t,e)=>{var{width:n,height:r}=t;return _.createElement(_.Fragment,null,_.createElement(WM,{width:n,height:r}),_.createElement("div",wm({ref:e},t)))}),MBe=_.forwardRef((t,e)=>{var{width:n,height:r}=t;return Uu(n)||Uu(r)?_.createElement(SBe,wm({},t,{ref:e})):_.createElement(NBe,wm({},t,{ref:e}))});function kBe(t){return t===!0?_Be:MBe}var EBe=_.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:s,onContextMenu:o,onDoubleClick:l,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:h,onMouseUp:p,onTouchEnd:m,onTouchMove:x,onTouchStart:y,style:v,width:b,responsive:S,dispatchTouchEvents:N=!0}=t,T=_.useRef(null),k=Lr(),[C,E]=_.useState(null),[P,A]=_.useState(null),D=gBe(),I=OO(),L=I?.width>0?I.width:b,U=I?.height>0?I.height:i,j=_.useCallback(ie=>{D(ie),typeof e=="function"&&e(ie),E(ie),A(ie),ie!=null&&(T.current=ie)},[D,e,E,A]),V=_.useCallback(ie=>{k(hee(ie)),k(Vo({handler:s,reactEvent:ie}))},[k,s]),K=_.useCallback(ie=>{k(ND(ie)),k(Vo({handler:u,reactEvent:ie}))},[k,u]),z=_.useCallback(ie=>{k($Z()),k(Vo({handler:d,reactEvent:ie}))},[k,d]),X=_.useCallback(ie=>{k(ND(ie)),k(Vo({handler:h,reactEvent:ie}))},[k,h]),Y=_.useCallback(()=>{k(bee())},[k]),te=_.useCallback(ie=>{k(xee(ie.key))},[k]),$=_.useCallback(ie=>{k(Vo({handler:o,reactEvent:ie}))},[k,o]),W=_.useCallback(ie=>{k(Vo({handler:l,reactEvent:ie}))},[k,l]),ne=_.useCallback(ie=>{k(Vo({handler:c,reactEvent:ie}))},[k,c]),re=_.useCallback(ie=>{k(Vo({handler:p,reactEvent:ie}))},[k,p]),ge=_.useCallback(ie=>{k(Vo({handler:y,reactEvent:ie}))},[k,y]),me=_.useCallback(ie=>{N&&k(vee(ie)),k(Vo({handler:x,reactEvent:ie}))},[k,N,x]),ue=_.useCallback(ie=>{k(Vo({handler:m,reactEvent:ie}))},[k,m]),Te=kBe(S);return _.createElement(cJ.Provider,{value:C},_.createElement(xX.Provider,{value:P},_.createElement(Te,{width:L??v?.width,height:U??v?.height,className:nr("recharts-wrapper",r),style:xBe({position:"relative",cursor:"default",width:L,height:U},v),onClick:V,onContextMenu:$,onDoubleClick:W,onFocus:Y,onKeyDown:te,onMouseDown:ne,onMouseEnter:K,onMouseLeave:z,onMouseMove:X,onMouseUp:re,onTouchEnd:ue,onTouchMove:me,onTouchStart:ge,ref:j},_.createElement(wBe,null),n)))}),TBe=["width","height","responsive","children","className","style","compact","title","desc"];function ABe(t,e){if(t==null)return{};var n,r,i=CBe(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 CBe(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 Mee=_.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:s,className:o,style:l,compact:c,title:u,desc:d}=t,h=ABe(t,TBe),p=ws(h);return c?_.createElement(_.Fragment,null,_.createElement(WM,{width:n,height:r}),_.createElement(b7,{otherAttributes:p,title:u,desc:d},s)):_.createElement(EBe,{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},_.createElement(b7,{otherAttributes:p,title:u,desc:d,ref:e},_.createElement($5e,null,s)))});function MD(){return MD=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},MD.apply(null,arguments)}var jBe={top:5,right:5,bottom:5,left:5},PBe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:jBe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},pL=_.forwardRef(function(e,n){var r,i=ci(e.categoricalChartProps,PBe),{chartName:s,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:s,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return _.createElement(_ee,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:s},_.createElement(HJ,{chartData:u.data}),_.createElement(See,{layout:i.layout,margin:i.margin}),_.createElement(Nee,{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}),_.createElement(Mee,MD({},i,{ref:n})))}),DBe=["axis"],RBe=_.forwardRef((t,e)=>_.createElement(pL,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:DBe,tooltipPayloadSearcher:f2,categoricalChartProps:t,ref:e})),OBe=["axis","item"],LBe=_.forwardRef((t,e)=>_.createElement(pL,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:OBe,tooltipPayloadSearcher:f2,categoricalChartProps:t,ref:e}));function FBe(t){var e=Lr();return _.useEffect(()=>{e(rBe(t))},[e,t]),null}var IBe=["layout"];function kD(){return kD=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},kD.apply(null,arguments)}function UBe(t,e){if(t==null)return{};var n,r,i=zBe(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 zBe(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 BBe={top:5,right:5,bottom:5,left:5},kee={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:BBe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},HBe=_.forwardRef(function(e,n){var r,i=ci(e.categoricalChartProps,kee),{layout:s}=i,o=UBe(i,IBe),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,h={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return _.createElement(_ee,{preloadedState:{options:h},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},_.createElement(HJ,{chartData:i.data}),_.createElement(See,{layout:s,margin:i.margin}),_.createElement(Nee,{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}),_.createElement(FBe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),_.createElement(Mee,kD({},o,{ref:n})))});function v7(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 w7(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?v7(Object(n),!0).forEach(function(r){$Be(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):v7(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $Be(t,e,n){return(e=VBe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VBe(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)}var qBe=["item"],WBe=w7(w7({},kee),{},{layout:"centric",startAngle:0,endAngle:360}),KBe=_.forwardRef((t,e)=>{var n=ci(t,WBe);return _.createElement(HBe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:qBe,tooltipPayloadSearcher:f2,categoricalChartProps:n,ref:e})}),XBe=["axis"],YBe=_.forwardRef((t,e)=>_.createElement(pL,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:XBe,tooltipPayloadSearcher:f2,categoricalChartProps:t,ref:e}));const _7=[{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 QBe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:s,initialMode:o="humidity",thresholds:l}){const{t:c}=On(),{mode:u}=Fh(),[d,h]=_.useState("24h"),[p,m]=_.useState(o),x=u==="dark",{data:y}=ct({queryKey:["settings"],queryFn:oe.getSettings}),v=y?.time_format||"system";_.useEffect(()=>{if(!t)return;const re=ge=>{ge.key==="Escape"&&e()};return window.addEventListener("keydown",re),()=>window.removeEventListener("keydown",re)},[t,e]);const b=_7.find(re=>re.value===d)?.hours||24,{data:S,isLoading:N,error:T}=ct({queryKey:["ams-history",n,i,b],queryFn:()=>oe.getAMSHistory(n,i,b),enabled:t,refetchInterval:6e4});if(!t)return null;const k=S?.data.map(re=>{const ge=zi(re.recorded_at)||new Date,me={hour:"2-digit",minute:"2-digit",...b>24?{day:"numeric",month:"short"}:{}};return{time:ge.getTime(),humidity:re.humidity,temperature:re.temperature,timeLabel:ge.toLocaleTimeString([],v0(me,v))}})||[],C=l?.humidityGood||40,E=l?.humidityFair||60,P=l?.tempGood||30,A=l?.tempFair||35,D=k[k.length-1],I=D?.humidity,L=D?.temperature,U=re=>{const ge=re.filter(Fe=>Fe!=null);if(ge.length<4)return"stable";const me=ge.slice(0,Math.floor(ge.length/4)),ue=ge.slice(-Math.floor(ge.length/4)),Te=me.reduce((Fe,xe)=>Fe+xe,0)/me.length,Ce=ue.reduce((Fe,xe)=>Fe+xe,0)/ue.length-Te;return Math.abs(Ce)<2?"stable":Ce>0?"up":"down"},j=U(k.map(re=>re.humidity)),V=U(k.map(re=>re.temperature)),K=({trend:re})=>re==="up"?a.jsx(vP,{className:"w-4 h-4 text-red-400"}):re==="down"?a.jsx(IW,{className:"w-4 h-4 text-green-400"}):a.jsx(bP,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),z=re=>re==null?"#9ca3af":re<=C?"#22a352":re<=E?"#d4a017":"#c62828",X=re=>re==null?"#9ca3af":re<=P?"#22a352":re<=A?"#d4a017":"#c62828",Y=x?"#2d2d2d":"#ffffff",te=x?"#1d1d1d":"#f3f4f6",$=x?"#3d3d3d":"#e5e7eb",W=x?"#ffffff":"#111827",ne=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:Y},onClick:re=>re.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:$},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:ne},children:r})]}),a.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:ne},children:a.jsx(Lt,{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:te},children:[a.jsxs("button",{onClick:()=>m("humidity"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${p==="humidity"?"bg-blue-600 text-white":""}`,style:p!=="humidity"?{color:ne}:void 0,children:[a.jsx(CR,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),a.jsxs("button",{onClick:()=>m("temperature"),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${p==="temperature"?"bg-orange-600 text-white":""}`,style:p!=="temperature"?{color:ne}:void 0,children:[a.jsx(yM,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),a.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:te},children:_7.map(re=>a.jsx("button",{onClick:()=>h(re.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===re.value?"bg-bambu-green text-white":""}`,style:d!==re.value?{color:ne}:void 0,children:re.label},re.value))})]}),a.jsx("div",{className:"grid grid-cols-4 gap-4",children:p==="humidity"?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[a.jsx("p",{className:"text-xs",style:{color:ne},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(I)},children:I!=null?`${I}%`:"—"}),a.jsx(K,{trend:j})]})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[a.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.average","Average")}),a.jsx("p",{className:"text-2xl font-bold",style:{color:W},children:S?.avg_humidity!=null?`${S.avg_humidity}%`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[a.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.min","Min")}),a.jsx("p",{className:"text-2xl font-bold text-green-500",children:S?.min_humidity!=null?`${S.min_humidity}%`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[a.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.max","Max")}),a.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_humidity!=null?`${S.max_humidity}%`:"—"})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[a.jsx("p",{className:"text-xs",style:{color:ne},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:X(L)},children:L!=null?`${L}°C`:"—"}),a.jsx(K,{trend:V})]})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[a.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.average","Average")}),a.jsx("p",{className:"text-2xl font-bold",style:{color:W},children:S?.avg_temperature!=null?`${S.avg_temperature}°C`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[a.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.min","Min")}),a.jsx("p",{className:"text-2xl font-bold text-blue-500",children:S?.min_temperature!=null?`${S.min_temperature}°C`:"—"})]}),a.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:[a.jsx("p",{className:"text-xs",style:{color:ne},children:c("common.max","Max")}),a.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_temperature!=null?`${S.max_temperature}°C`:"—"})]})]})}),a.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:te},children:N?a.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ne},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")}):k.length===0?a.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:ne},children:c("common.noData","No data available for this time range")}):a.jsx(j1,{width:"100%",height:300,children:a.jsxs(RBe,{data:k,children:[a.jsx(nN,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),a.jsx(iN,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:re=>{const ge=new Date(re);return b>24?ge.toLocaleDateString([],{day:"numeric",month:"short"}):ge.toLocaleTimeString([],v0({hour:"2-digit",minute:"2-digit"},v))},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),a.jsx(aN,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:p==="humidity"?[0,100]:["auto","auto"],tickFormatter:re=>p==="humidity"?`${re}%`:`${re}°C`}),a.jsx(D1,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:re=>new Date(re).toLocaleString(void 0,v0({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},v)),formatter:re=>[p==="humidity"?`${re??0}%`:`${re??0}°C`,p==="humidity"?"Humidity":"Temperature"]}),a.jsx(zO,{}),p==="humidity"?a.jsxs(a.Fragment,{children:[a.jsx(d0,{y:C,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),a.jsx(d0,{y:E,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):a.jsxs(a.Fragment,{children:[a.jsx(d0,{y:P,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),a.jsx(d0,{y:A,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),a.jsx(nee,{type:"monotone",dataKey:p,name:p==="humidity"?"Humidity":"Temperature",stroke:p==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),a.jsx("div",{className:"text-xs text-center",style:{color:ne},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function ij({data:t,children:e,disabled:n,className:r="",spoolman:i,configureSlot:s}){const{t:o}=On(),[l,c]=_.useState(!1),[u,d]=_.useState("top"),[h,p]=_.useState(!1),m=_.useRef(null),x=_.useRef(null),y=_.useRef(null),v=()=>{const E=t.trayUuid;E&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(E).then(()=>{p(!0),setTimeout(()=>p(!1),2e3)}).catch(()=>{b(E)}):b(E))},b=E=>{const P=document.createElement("textarea");P.value=E,P.style.position="fixed",P.style.opacity="0",document.body.appendChild(P),P.select();try{document.execCommand("copy"),p(!0),setTimeout(()=>p(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(P)};_.useEffect(()=>{if(l&&m.current&&x.current){const E=m.current.getBoundingClientRect(),P=x.current.offsetHeight,A=E.top,D=window.innerHeight-E.bottom;A<P+12&&D>A?d("bottom"):d("top")}},[l]);const S=()=>{n||(y.current&&clearTimeout(y.current),y.current=setTimeout(()=>c(!0),80))},N=()=>{y.current&&clearTimeout(y.current),y.current=setTimeout(()=>c(!1),100)};_.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]);const T=E=>E<=15?"#ef4444":E<=30?"#f97316":E<=50?"#eab308":"#22c55e",k=E=>{if(!E)return!1;const P=E.replace("#",""),A=parseInt(P.slice(0,2),16),D=parseInt(P.slice(2,4),16),I=parseInt(P.slice(4,6),16);return(.299*A+.587*D+.114*I)/255>.6},C=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return a.jsxs("div",{ref:m,className:`relative ${r}`,onMouseEnter:S,onMouseLeave:N,children:[e,l&&a.jsxs("div",{ref:x,className:`
  8097. absolute left-1/2 -translate-x-1/2 z-50
  8098. ${u==="top"?"bottom-full mb-2":"top-full mt-2"}
  8099. animate-in fade-in-0 zoom-in-95 duration-150
  8100. `,style:{maxWidth:"calc(100vw - 24px)"},children:[a.jsxs("div",{className:`
  8101. w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
  8102. rounded-lg shadow-xl overflow-hidden
  8103. backdrop-blur-sm
  8104. `,children:[a.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:C||"#3d3d3d"},children:[a.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),a.jsx("div",{className:`
  8105. absolute inset-0 flex items-center justify-center
  8106. font-semibold text-sm tracking-wide
  8107. ${k(C)?"text-black/80":"text-white/90"}
  8108. `,children:t.colorName}),a.jsx("div",{className:`
  8109. absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
  8110. ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
  8111. `,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:o("ams.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:o("ams.kFactor")}),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(CR,{className:"w-3 h-3"}),o("ams.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:T(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:o("spoolman.spoolId")}),a.jsxs("button",{onClick:E=>{E.stopPropagation(),v()},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),"..."]}),h?a.jsx(Wi,{className:"w-3 h-3 text-bambu-green"}):a.jsx(Ul,{className:"w-3 h-3"})]})]}),i.linkedSpoolId&&i.spoolmanUrl&&a.jsxs("a",{href:`${i.spoolmanUrl.replace(/\/$/,"")}/spool/show/${i.linkedSpoolId}`,target:"_blank",rel:"noopener noreferrer",onClick:E=>E.stopPropagation(),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-green/20 hover:bg-bambu-green/30 text-bambu-green",title:o("spoolman.openInSpoolman"),children:[a.jsx(Xr,{className:"w-3.5 h-3.5"}),o("spoolman.openInSpoolman")]}),!i.linkedSpoolId&&i.onLinkSpool&&a.jsxs("button",{onClick:E=>{E.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?o("spoolman.noUnlinkedSpools"):o("spoolman.linkToSpoolman"),children:[a.jsx(fc,{className:"w-3.5 h-3.5"}),o("spoolman.linkToSpoolman")]})]}),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:E=>{E.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:o("ams.configureSlot"),children:[a.jsx(vh,{className:"w-3.5 h-3.5"}),o("ams.configure")]})})]})]}),a.jsx("div",{className:`
  8112. absolute left-1/2 -translate-x-1/2 w-0 h-0
  8113. border-l-[6px] border-l-transparent
  8114. border-r-[6px] border-r-transparent
  8115. ${u==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
  8116. `})]})]})}function S7({children:t,className:e="",configureSlot:n}){const{t:r}=On(),[i,s]=_.useState(!1),o=_.useRef(null),l=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>s(!0),80)},c=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>s(!1),100)};return _.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),a.jsxs("div",{className:`relative ${e}`,onMouseEnter:l,onMouseLeave:c,children:[t,i&&a.jsxs("div",{className:`
  8117. absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
  8118. animate-in fade-in-0 zoom-in-95 duration-150
  8119. `,children:[a.jsxs("div",{className:`
  8120. bg-bambu-dark-secondary border border-bambu-dark-tertiary
  8121. rounded-md shadow-lg overflow-hidden
  8122. `,children:[a.jsx("div",{className:"px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap",children:r("ams.emptySlot")}),n?.enabled&&a.jsx("div",{className:"px-2 pb-2",children:a.jsxs("button",{onClick:u=>{u.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:r("ams.configureSlot"),children:[a.jsx(vh,{className:"w-3.5 h-3.5"}),r("ams.configure")]})})]}),a.jsx("div",{className:`
  8123. absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
  8124. border-l-[5px] border-l-transparent
  8125. border-r-[5px] border-r-transparent
  8126. border-t-[5px] border-t-bambu-dark-tertiary
  8127. `})]})]})}function ZBe({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const{t:i}=On(),s=sn(),{showToast:o}=Hn(),[l,c]=_.useState(null),{data:u,isLoading:d}=ct({queryKey:["unlinked-spools"],queryFn:oe.getUnlinkedSpools,enabled:t}),h=gt({mutationFn:m=>oe.linkSpool(m,n),onSuccess:()=>{s.invalidateQueries({queryKey:["unlinked-spools"]}),s.invalidateQueries({queryKey:["linked-spools"]}),s.invalidateQueries({queryKey:["spoolman-status"]}),o(i("spoolman.linkSuccess"),"success"),e()},onError:m=>{o(`${i("spoolman.linkFailed")}: ${m.message}`,"error")}});if(!t)return null;const p=()=>{l&&h.mutate(l)};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(fc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("spoolman.linkToSpoolman")})]}),a.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Lt,{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.jsxs("p",{className:"text-xs text-bambu-gray mb-1",children:[i("spoolman.spoolId"),":"]}),a.jsx("code",{className:"text-xs text-bambu-green font-mono break-all",children:n})]}),a.jsxs("div",{children:[a.jsxs("p",{className:"text-sm text-bambu-gray mb-2",children:[i("spoolman.selectSpool"),":"]}),d?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2",children:u.map(m=>a.jsx("button",{onClick:()=>c(m.id),className:`w-full p-3 rounded-lg border text-left transition-colors ${l===m.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:[m.filament_color_hex&&a.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:`#${m.filament_color_hex}`}}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-white font-medium truncate",children:m.filament_name||"Unknown filament"}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[m.filament_material||"Unknown",m.remaining_weight!==null&&` - ${Math.round(m.remaining_weight)}g`,m.location&&` - ${m.location}`]})]}),l===m.id&&a.jsx(Wi,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},m.id))}):a.jsx("div",{className:"text-center py-8 text-bambu-gray",children:a.jsx("p",{children:i("spoolman.noUnlinkedSpools")})})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Ae,{variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Ae,{onClick:p,disabled:!l||h.isPending,children:h.isPending?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 animate-spin"}),i("spoolman.syncing")]}):a.jsxs(a.Fragment,{children:[a.jsx(fc,{className:"w-4 h-4"}),i("spoolman.linkToSpoolman")]})})]}),h.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:h.error.message})]})]})}function JBe(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 N7(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 e8e=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function M7(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of e8e){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 aj(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const t8e={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"},n8e=[{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"}],r8e=[{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 i8e(t){const e=t.toLowerCase().trim();return t8e[e]||null}function a8e({isOpen:t,onClose:e,printerId:n,slotInfo:r,nozzleDiameter:i="0.4",onSuccess:s}){const[o,l]=_.useState(""),[c,u]=_.useState(null),[d,h]=_.useState(""),[p,m]=_.useState(""),[x,y]=_.useState(""),[v,b]=_.useState(!1),[S,N]=_.useState(!1),{data:T,isLoading:k}=ct({queryKey:["cloudSettings"],queryFn:()=>oe.getCloudSettings(),enabled:t}),{data:C,isLoading:E}=ct({queryKey:["kprofiles",n,i],queryFn:()=>oe.getKProfiles(n,i),enabled:t&&!!n}),P=gt({mutationFn:async()=>{if(!o)throw new Error("No filament preset selected");const X=T?.filament.find(ie=>ie.setting_id===o);if(!X)throw new Error("Selected preset not found");const Y=M7(X.name),te=c?.slot_id??-1,$=d||r.trayColor?.slice(0,6)||"FFFFFF",W=X.name.replace(/@.+$/,"").trim();let ne=N7(o);if(!o.startsWith("GFS"))try{const ie=await oe.getCloudSettingDetail(o);ie.filament_id?ne=ie.filament_id:ie.base_id&&(ne=N7(ie.base_id),console.log(`Derived tray_info_idx from base_id: ${ie.base_id} -> ${ne}`))}catch(ie){console.warn("Failed to fetch preset detail for filament_id:",ie)}let re=190,ge=230;const me=Y.material.toUpperCase();me.includes("PLA")?(re=190,ge=230):me.includes("PETG")?(re=220,ge=260):me.includes("ABS")||me.includes("ASA")?(re=240,ge=280):me.includes("TPU")?(re=200,ge=240):me.includes("PC")?(re=260,ge=300):(me.includes("PA")||me.includes("NYLON"))&&(re=250,ge=290);const ue=c?.k_value?parseFloat(c.k_value):0,Te=await oe.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:ne,tray_type:Y.material||"PLA",tray_sub_brands:W,tray_color:$+"FF",nozzle_temp_min:re,nozzle_temp_max:ge,cali_idx:te,nozzle_diameter:i,setting_id:o,kprofile_filament_id:c?.filament_id,kprofile_setting_id:c?.setting_id||void 0,k_value:ue});try{await oe.saveSlotPreset(n,r.amsId,r.trayId,o,W)}catch(ie){console.warn("Failed to save slot preset mapping:",ie)}return Te},onSuccess:()=>{b(!0),s?.(),setTimeout(()=>{b(!1),e()},1500)}}),A=gt({mutationFn:async()=>oe.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{b(!0),s?.(),setTimeout(()=>{b(!1),e()},1500)}}),D=_.useMemo(()=>{if(!T?.filament)return[];const X=x.toLowerCase();return T.filament.filter(Y=>X?Y.name.toLowerCase().includes(X):!0).sort((Y,te)=>{const $=aj(Y.setting_id),W=aj(te.setting_id);return $&&!W?-1:!$&&W?1:Y.name.localeCompare(te.name)})},[T?.filament,x]),I=_.useMemo(()=>{if(!o||!T?.filament)return null;const X=T.filament.find($=>$.setting_id===o);if(!X)return null;let Y=X.name.replace(/@.+$/,"").trim();Y.startsWith("# ")&&(Y=Y.slice(2).trim());const te=M7(Y);return{fullName:Y,material:te.material,brand:te.brand}},[o,T?.filament]),L=I?.fullName||"",U=_.useMemo(()=>{if(!C?.profiles||!I)return[];const{fullName:X,material:Y,brand:te}=I,$=X.toUpperCase(),W=Y.toUpperCase(),ne=te.toUpperCase();if(!W||W.length<2)return[];const re=C.profiles.filter(me=>{const ue=me.name.toUpperCase();if(ne)return!(!ue.includes(ne)||!ue.includes(W));if(ue.includes($)||ue.includes(W))return!0;const ie={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[W]||[];for(const Ce of ie)if(ue.includes(Ce))return!0;return!1}),ge=new Map;for(const me of re){const ue=`${me.name}|${me.k_value}`,Te=ge.get(ue);Te?me.extruder_id===1&&Te.extruder_id===0&&ge.set(ue,me):ge.set(ue,me)}return Array.from(ge.values())},[C?.profiles,I]);_.useEffect(()=>{if(t&&T?.filament){if(r.trayInfoIdx){const X=T.filament.find(Y=>Y.setting_id===r.trayInfoIdx);X&&l(X.setting_id)}}else t||(l(""),u(null),h(""),m(""),y(""),b(!1))},[t,T?.filament,r.trayInfoIdx]),_.useEffect(()=>{U.length>0?u(U[0]):u(null)},[o,U]);const j=_.useCallback(X=>{X.key==="Escape"&&e()},[e]);if(_.useEffect(()=>{if(t)return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[t,j]),!t)return null;const V=k||E,K=o&&!P.isPending,z=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(vh,{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(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4 max-h-[60vh] overflow-y-auto",children:[v&&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(lM,{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:[JBe(r.amsId,r.trayCount)," Slot ",r.trayId+1]}),r.traySubBrands&&a.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),V?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(pt,{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:X=>y(X.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:D.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."}):D.map(X=>a.jsx("button",{onClick:()=>l(X.setting_id),className:`w-full p-2 rounded-lg border text-left transition-colors ${o===X.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:X.name}),aj(X.setting_id)&&a.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:"Custom"})]})},X.setting_id))})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["K Profile (Pressure Advance)",L&&a.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",L]})]}),U.length>0?a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:c?.name||"",onChange:X=>{const Y=U.find(te=>te.name===X.target.value);u(Y||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)"}),U.map(X=>a.jsxs("option",{value:X.name,children:[X.name," (K=",X.k_value,")"]},`${X.name}-${X.extruder_id}`))]}),a.jsx(Kr,{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:[n8e.map(X=>a.jsx("button",{onClick:()=>{h(X.hex),m(X.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===X.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${X.hex}`},title:X.name},X.hex)),a.jsx("button",{onClick:()=>N(!S),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:S?"Show less colors":"Show more colors",children:S?"−":"+"})]}),S&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:r8e.map(X=>a.jsx("button",{onClick:()=>{h(X.hex),m(X.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===X.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${X.hex}`},title:X.name},X.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:`#${z}`}}),a.jsx("input",{type:"text",placeholder:"Color name or hex (e.g., brown, FF8800)",value:p,onChange:X=>{const Y=X.target.value;m(Y);const te=i8e(Y);if(te)h(te);else{const $=Y.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();$.length===6?h($):$.length===3&&h($.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:()=>{h(""),m("")},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(Ae,{variant:"secondary",onClick:()=>A.mutate(),disabled:A.isPending||P.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:A.isPending?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Lh,{className:"w-4 h-4"}),"Reset Slot"]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ae,{variant:"secondary",onClick:e,children:"Cancel"}),a.jsx(Ae,{onClick:()=>P.mutate(),disabled:!K,children:P.isPending?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):a.jsxs(a.Fragment,{children:[a.jsx(vh,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(P.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:P.error?.message||A.error?.message})]})]})}function s8e({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 k7=({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"})]}),E7={"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"},o8e={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 sj(t){if(!t)return null;if(E7[t])return E7[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return o8e[n]||null}function oj(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,h=n/255,p=r/255;i===d?l=((h-p)/u+(h<p?6:0))/6:i===h?l=((p-d)/u+2)/6:l=((d-h)/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 lj(t){return(t??.02).toFixed(3)}function T7({side:t}){const{mode:e}=Fh(),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 A7({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 l8e({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 c8e({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 u8e({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 d8e({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 h8e({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 cj({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 C7({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=A7:s<=l?d=l8e:d=c8e,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 j7({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=u8e):t<=o?(l="#d4a017",c="Fair",u=d8e):(l="#c62828",c="Bad",u=h8e),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 Ld(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 P7(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function f8e(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function m8e(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 p8e(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 g8e(t){return t==null?{labelKey:"",color:"text-bambu-gray",bars:0}:t>=-50?{labelKey:"printers.wifiSignal.excellent",color:"text-bambu-green",bars:4}:t>=-60?{labelKey:"printers.wifiSignal.good",color:"text-bambu-green",bars:3}:t>=-70?{labelKey:"printers.wifiSignal.fair",color:"text-yellow-400",bars:2}:t>=-80?{labelKey:"printers.wifiSignal.weak",color:"text-orange-400",bars:1}:{labelKey:"printers.wifiSignal.veryWeak",color:"text-red-400",bars:1}}function uj(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 x8e({url:t,printName:e}){const{t:n}=On(),[r,i]=_.useState(!1),[s,o]=_.useState(!1),[l,c]=_.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&&r?"cursor-pointer":""}`,onClick:()=>t&&r&&c(!0),children:t&&!s?a.jsxs(a.Fragment,{children:[a.jsx("img",{src:t,alt:n("printers.printPreview"),className:`w-full h-full object-cover ${r?"block":"hidden"}`,onLoad:()=>i(!0),onError:()=>o(!0)}),!r&&a.jsx(Ui,{className:"w-8 h-8 text-bambu-gray"})]}):a.jsx(Ui,{className:"w-8 h-8 text-bambu-gray"})}),l&&t&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>c(!1),children:a.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[a.jsx("img",{src:t,alt:n("printers.printPreview"),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 b8e({printers:t}){const{t:e}=On(),n=sn(),r=_.useMemo(()=>{let s=0,o=0,l=0,c=0;return t?.forEach(u=>{const d=n.getQueryData(["printerStatus",u.id]);d===void 0?c++:d.connected?d.state==="RUNNING"?s++:o++:l++}),{printing:s,idle:o,offline:l,loading:c,total:t?.length||0}},[t,n]),[,i]=_.useState(0);return _.useEffect(()=>{let s=!1;const o=n.getQueryCache().subscribe(()=>{s||(s=!0,requestAnimationFrame(()=>{i(l=>l+1),s=!1}))});return()=>o()},[n]),t?.length?a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[r.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:r.printing})," ",e("printers.status.printing").toLowerCase()]})]}),r.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:r.idle})," ",e("printers.status.idle").toLowerCase()]})]}),r.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:r.offline})," ",e("printers.status.offline").toLowerCase()]})]})]}):null}function D7(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 R7({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:s,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,linkedSpools:c,spoolmanUrl:u,timeFormat:d="system",cameraViewMode:h="window",onOpenEmbeddedCamera:p,checkPrinterFirmware:m=!0}){const{t:x}=On(),y=sn(),v=Tc(),{showToast:b}=Hn(),{hasPermission:S}=Ci(),[N,T]=_.useState(!1),[k,C]=_.useState(!1),[E,P]=_.useState(!0),[A,D]=_.useState(!1),[I,L]=_.useState(!1),[U,j]=_.useState(!1),[V,K]=_.useState(!1),[z,X]=_.useState(!1),[Y,te]=_.useState(!1),[$,W]=_.useState(!1),[ne,re]=_.useState(!1),[ge,me]=_.useState(!1),[ue,Te]=_.useState(!1),[ie,Ce]=_.useState(null),[Fe,xe]=_.useState(null),[Ze,G]=_.useState(null),[Q,de]=_.useState(!1),[q,ee]=_.useState(null),[B,he]=_.useState(!1),[ke,pe]=_.useState(!1),[H,O]=_.useState(null),[J,le]=_.useState(!1),[Se,we]=_.useState(!1),{data:ae}=ct({queryKey:["printerStatus",t.id],queryFn:()=>oe.getPrinterStatus(t.id),refetchInterval:3e4}),{data:Le}=ct({queryKey:["firmwareUpdate",t.id],queryFn:()=>b1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3,enabled:m}),Be=_.useMemo(()=>{const rt=new Set;if(ae?.ams)for(const Pt of ae.ams)for(const qt of Pt.tray||[])qt.tray_info_idx&&rt.add(qt.tray_info_idx);return ae?.vt_tray?.tray_info_idx&&rt.add(ae.vt_tray.tray_info_idx),Array.from(rt)},[ae?.ams,ae?.vt_tray]),{data:Ve}=ct({queryKey:["filamentInfo",Be],queryFn:()=>oe.getFilamentInfo(Be),enabled:Be.length>0,staleTime:300*1e3}),{data:He}=ct({queryKey:["slotPresets",t.id],queryFn:()=>oe.getSlotPresets(t.id),staleTime:120*1e3}),[be,Pe]=_.useState(null);_.useEffect(()=>{ae?.wifi_signal!=null&&Pe(ae.wifi_signal)},[ae?.wifi_signal]);const Ie=ae?.wifi_signal??be,_e=_.useRef(void 0);_.useEffect(()=>{ae?.connected!==void 0&&(_e.current=ae.connected)},[ae?.connected]);const Ke=ae?.connected??_e.current,Me=_.useRef({});_.useEffect(()=>{ae?.ams_extruder_map&&Object.keys(ae.ams_extruder_map).length>0&&(Me.current=ae.ams_extruder_map)},[ae?.ams_extruder_map]);const it=ae?.ams_extruder_map&&Object.keys(ae.ams_extruder_map).length>0?ae.ams_extruder_map:Me.current,Ee=_.useRef([]);_.useEffect(()=>{ae?.ams&&ae.ams.length>0&&(Ee.current=ae.ams)},[ae?.ams]);const Xe=ae?.ams&&ae.ams.length>0?ae.ams:Ee.current,ze=_.useRef(255),ce=ae?.tray_now;ce!==void 0&&ce!==255&&(ze.current=ce);const $e=ce===void 0||ce===255?ze.current:ce,{data:ye}=ct({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>oe.getSmartPlugByPrinter(t.id)}),{data:Je}=ct({queryKey:["scriptPlugsByPrinter",t.id],queryFn:()=>oe.getScriptPlugsByPrinter(t.id)}),{data:at}=ct({queryKey:["smartPlugStatus",ye?.id],queryFn:()=>ye?oe.getSmartPlugStatus(ye.id):null,enabled:!!ye,refetchInterval:1e4}),{data:jt}=ct({queryKey:["queue",t.id,"pending"],queryFn:()=>oe.getQueue(t.id,"pending")}),Dt=jt?.length||0,{data:yn}=ct({queryKey:["queue",t.id,"printing"],queryFn:()=>oe.getQueue(t.id,"printing"),enabled:ae?.state==="RUNNING"}),{data:cn}=ct({queryKey:["currentPrintUser",t.id],queryFn:()=>oe.getCurrentPrintUser(t.id),enabled:ae?.state==="RUNNING"}),rr=yn?.[0]?.created_by_username||cn?.username,{data:Vn}=ct({queryKey:["archives",t.id,"last"],queryFn:()=>oe.getArchives(t.id,1,0),enabled:ae?.connected&&ae?.state!=="RUNNING"}),Jn=Vn?.[0],xn=e&&Ke===!1,sr=gt({mutationFn:rt=>oe.deletePrinter(t.id,rt.deleteArchives),onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),y.invalidateQueries({queryKey:["archives"]}),y.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:rt=>b(rt.message||x("printers.toast.failedToDelete"),"error")}),Gn=gt({mutationFn:()=>oe.connectPrinter(t.id),onSuccess:()=>{y.invalidateQueries({queryKey:["printerStatus",t.id]})}}),Xn=gt({mutationFn:rt=>ye?oe.controlSmartPlug(ye.id,rt):Promise.reject("No plug"),onSuccess:()=>{y.invalidateQueries({queryKey:["smartPlugStatus",ye?.id]})}}),Nn=gt({mutationFn:rt=>ye?oe.updateSmartPlug(ye.id,{auto_off:rt}):Promise.reject("No plug"),onSuccess:()=>{y.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),y.invalidateQueries({queryKey:["smart-plugs"]})}}),hi=gt({mutationFn:rt=>oe.controlSmartPlug(rt,"on"),onSuccess:()=>{b(x("printers.toast.scriptTriggered"))},onError:rt=>b(rt.message||x("printers.toast.failedToRunScript"),"error")}),ai=gt({mutationFn:()=>oe.stopPrint(t.id),onSuccess:()=>{b(x("printers.toast.printStopped")),y.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:rt=>b(rt.message||x("printers.toast.failedToStopPrint"),"error")}),je=gt({mutationFn:()=>oe.pausePrint(t.id),onSuccess:()=>{b(x("printers.toast.printPaused")),y.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:rt=>b(rt.message||x("printers.toast.failedToPausePrint"),"error")}),tt=gt({mutationFn:()=>oe.resumePrint(t.id),onSuccess:()=>{b(x("printers.toast.printResumed")),y.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:rt=>b(rt.message||x("printers.toast.failedToResumePrint"),"error")}),dt=gt({mutationFn:rt=>oe.setChamberLight(t.id,rt),onMutate:async rt=>{await y.cancelQueries({queryKey:["printerStatus",t.id]});const Pt=y.getQueryData(["printerStatus",t.id]);return y.setQueryData(["printerStatus",t.id],qt=>({...qt,chamber_light:rt})),{previousStatus:Pt}},onSuccess:(rt,Pt)=>{b(`Chamber light ${Pt?"on":"off"}`)},onError:(rt,Pt,qt)=>{qt?.previousStatus&&y.setQueryData(["printerStatus",t.id],qt.previousStatus),b(rt.message||x("printers.toast.failedToControlChamberLight"),"error")}}),ht=gt({mutationFn:rt=>oe.updatePrinter(t.id,{plate_detection_enabled:rt}),onSuccess:()=>{y.invalidateQueries({queryKey:["printers"]}),b(ht.variables?x("printers.toast.plateCheckEnabled"):x("printers.toast.plateCheckDisabled"))},onError:rt=>b(rt.message||x("printers.toast.failedToUpdateSetting"),"error")}),ut=(ae?.state==="RUNNING"||ae?.state==="PAUSE"||ae?.state==="PAUSED")&&(ae?.printable_objects_count??0)>=2,{data:Et,refetch:fe}=ct({queryKey:["printableObjects",t.id],queryFn:()=>oe.getPrintableObjects(t.id),enabled:ue||ut,refetchInterval:ue?5e3:ut?3e4:!1}),Re=gt({mutationFn:rt=>oe.skipObjects(t.id,rt),onSuccess:rt=>{b(rt.message||x("printers.skipObjects.objectsSkipped")),fe()},onError:rt=>b(rt.message||x("printers.toast.failedToSkipObjects"),"error")}),[Ge,Ne]=_.useState(null),Oe=_.useRef(!1),nt=_.useRef(null),Ye=_.useRef(!1),Tt=gt({mutationFn:({amsId:rt,slotId:Pt})=>oe.refreshAmsSlot(t.id,rt,Pt),onMutate:({amsId:rt,slotId:Pt})=>{nt.current&&clearTimeout(nt.current),Oe.current=!1,Ye.current=!1,Ne({amsId:rt,slotId:Pt}),setTimeout(()=>{Ye.current=!0},2e3),nt.current=setTimeout(()=>{Ne(null)},3e4)},onSuccess:rt=>{b(rt.message||x("printers.toast.rfidRereadInitiated"))},onError:rt=>{b(rt.message||x("printers.toast.failedToRereadRfid"),"error"),nt.current&&clearTimeout(nt.current),Ne(null)}}),[At,It]=_.useState(null),[Rt,Mt]=_.useState(null),en=async()=>{try{const rt=await oe.getPlateReferences(t.id);It(rt)}catch{}},Ht=()=>{ht.mutate(!t.plate_detection_enabled)},hn=async()=>{he(!0),ee(null);const rt=ae?.chamber_light===!1;we(rt),rt&&(await oe.setChamberLight(t.id,!0),await new Promise(Pt=>setTimeout(Pt,2500)));try{const Pt=await oe.checkPlateEmpty(t.id,{includeDebugImage:!0});ee(Pt),en()}catch(Pt){b(Pt instanceof Error?Pt.message:x("printers.toast.failedToCheckPlate"),"error"),rt&&(await oe.setChamberLight(t.id,!1),we(!1))}finally{he(!1)}},un=_.useCallback(async()=>{ee(null),Se&&(await oe.setChamberLight(t.id,!1),we(!1))},[Se,t.id]),Mn=async rt=>{pe(!0);try{const Pt=await oe.calibratePlateDetection(t.id,{label:rt});if(Pt.success){b(Pt.message||x("printers.toast.calibrationSaved"),"success"),en();const qt=await oe.checkPlateEmpty(t.id,{includeDebugImage:!0});ee(qt)}else b(Pt.message||x("printers.toast.calibrationFailed"),"error")}catch(Pt){b(Pt instanceof Error?Pt.message:x("printers.toast.calibrationFailed"),"error")}finally{pe(!1)}},Gt=async(rt,Pt)=>{try{await oe.updatePlateReferenceLabel(t.id,rt,Pt),Mt(null),en()}catch(qt){b(qt instanceof Error?qt.message:x("printers.toast.failedToUpdateLabel"),"error")}},on=async rt=>{try{await oe.deletePlateReference(t.id,rt),b(x("printers.toast.referenceDeleted"),"success"),en();const Pt=await oe.checkPlateEmpty(t.id,{includeDebugImage:!0});ee(Pt)}catch(Pt){b(Pt instanceof Error?Pt.message:x("printers.toast.failedToDeleteReference"),"error")}},dn=async()=>{if(H){le(!0);try{await oe.updatePrinter(t.id,{plate_detection_roi:H}),b(x("printers.toast.detectionAreaSaved"),"success"),O(null);const rt=await oe.checkPlateEmpty(t.id,{includeDebugImage:!0});ee(rt)}catch(rt){b(rt instanceof Error?rt.message:x("printers.toast.failedToSaveDetectionArea"),"error")}finally{le(!1)}}};_.useEffect(()=>{const rt=Pt=>{Pt.key==="Escape"&&q&&un()};return window.addEventListener("keydown",rt),()=>window.removeEventListener("keydown",rt)},[q,un]);const Yt=_.useRef(null);_.useEffect(()=>{if(!Ge)return;const rt=ae?.ams_status_main??0;return rt!==0&&(Oe.current=!0,Yt.current&&(clearTimeout(Yt.current),Yt.current=null)),Oe.current&&rt===0&&(Ye.current?(nt.current&&clearTimeout(nt.current),Ne(null)):Yt.current||(Yt.current=setTimeout(()=>{nt.current&&clearTimeout(nt.current),Ne(null)},2e3))),()=>{Yt.current&&clearTimeout(Yt.current)}},[ae?.ams_status_main,Ge]);const[ir,Pn]=_.useState(null);if(xn)return null;const si=()=>{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"}},ar=()=>{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"}},dr=()=>{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(St,{className:"relative",children:[a.jsxs(Nt,{className:i>=3?"p-5":"",children:[a.jsxs("div",{className:dr(),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:p8e(t.model),alt:t.model||x("common.printer"),className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${si()}`}),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 ${ar()}`,children:t.name}),r==="compact"&&a.jsx("div",{className:`w-2 h-2 rounded-full flex-shrink-0 ${ae?.connected?"bg-status-ok":"bg-status-error"}`,title:ae?.connected?x("printers.connection.connected"):x("printers.connection.offline")})]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&ae?.nozzles&&ae.nozzles[0]?.nozzle_diameter&&a.jsxs("span",{className:"ml-1.5 text-bambu-gray",title:ae.nozzles[0].nozzle_type||"Nozzle",children:["• ",ae.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(tr,{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(Ae,{variant:"ghost",size:"sm",onClick:()=>T(!N),children:a.jsx(ah,{className:"w-4 h-4"})}),N&&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 flex items-center gap-2 ${S("printers:update")?"hover:bg-bambu-dark-tertiary":"opacity-50 cursor-not-allowed"}`,onClick:()=>{S("printers:update")&&(D(!0),T(!1))},title:S("printers:update")?void 0:x("printers.permission.noEdit"),children:[a.jsx(ea,{className:"w-4 h-4"}),x("common.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:()=>{Gn.mutate(),T(!1)},children:[a.jsx(Dr,{className:"w-4 h-4"}),x("printers.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:()=>{j(!0),T(!1)},children:[a.jsx(FW,{className:"w-4 h-4"}),x("printers.mqttDebug")]}),a.jsxs("button",{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${S("printers:delete")?"text-red-400 hover:bg-bambu-dark-tertiary":"text-red-400/50 cursor-not-allowed"}`,onClick:()=>{S("printers:delete")&&(C(!0),T(!1))},title:S("printers:delete")?void 0:x("printers.permission.noDelete"),children:[a.jsx(an,{className:"w-4 h-4"}),x("common.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 ${ae?.connected?"bg-status-ok/20 text-status-ok":"bg-status-error/20 text-status-error"}`,children:[ae?.connected?a.jsx(Uy,{className:"w-3 h-3"}):a.jsx(OR,{className:"w-3 h-3"}),ae?.connected?x("printers.connection.connected"):x("printers.connection.offline")]}),ae?.connected&&Ie!=null&&a.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${Ie>=-50||Ie>=-60?"bg-status-ok/20 text-status-ok":Ie>=-70?"bg-status-warning/20 text-status-warning":Ie>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${Ie} dBm - ${x(g8e(Ie).labelKey)}`,children:[a.jsx(Ihe,{className:"w-3 h-3"}),Ie,"dBm"]}),ae?.connected&&(()=>{const rt=ae.hms_errors?t2e(ae.hms_errors):[];return a.jsxs("button",{onClick:()=>te(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${rt.length>0?rt.some(Pt=>Pt.severity<=2)?"bg-status-error/20 text-status-error":"bg-status-warning/20 text-status-warning":"bg-status-ok/20 text-status-ok"}`,title:x("printers.clickToViewHmsErrors"),children:[a.jsx(Sn,{className:"w-3 h-3"}),rt.length>0?rt.length:"OK"]})})(),n&&a.jsxs("button",{onClick:()=>v("/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`:x("printers.maintenanceUpToDate"),children:[a.jsx(cm,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Dt>0&&a.jsxs("button",{onClick:()=>v("/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:x("printers.queue.inQueue",{count:Dt}),children:[a.jsx(xs,{className:"w-3 h-3"}),Dt]}),Le?.update_available&&a.jsxs("button",{onClick:()=>de(!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:x("printers.firmwareUpdateAvailable",{current:Le.current_version,latest:Le.latest_version}),children:[a.jsx(wi,{className:"w-3 h-3"}),x("printers.firmwareUpdateButton")]})]})]}),k&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsx(St,{className:"w-full max-w-md mx-4",children:a.jsxs(Nt,{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(Sn,{className:"w-5 h-5 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:x("printers.confirm.deleteTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:x("printers.confirm.deleteMessage",{name:t.name})})]})]}),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:E,onChange:rt=>P(rt.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:x("printers.deleteArchives")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:x(E?"printers.confirm.deleteArchivesNote":"printers.confirm.keepArchivesNote")})]})]})}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Ae,{variant:"secondary",onClick:()=>{C(!1),P(!0)},children:x("common.cancel")}),a.jsx(Ae,{variant:"danger",onClick:()=>{sr.mutate({deleteArchives:E}),C(!1),P(!0)},children:"Delete"})]})]})})}),ae?.connected&&a.jsxs(a.Fragment,{children:[r==="compact"?a.jsx("div",{className:"mt-2",children:ae.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:`${ae.progress||0}%`}})}),a.jsxs("span",{className:"text-xs text-white",children:[Math.round(ae.progress||0),"%"]})]}):a.jsx("p",{className:"text-xs text-bambu-gray",children:D7(ae.state,ae.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:()=>Te(!0),disabled:!(ae.state==="RUNNING"||ae.state==="PAUSE"||ae.state==="PAUSED")||(ae.printable_objects_count??0)<2||!S("printers:control"),className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${(ae.state==="RUNNING"||ae.state==="PAUSE"||ae.state==="PAUSED")&&(ae.printable_objects_count??0)>=2&&S("printers:control")?"text-bambu-gray hover:text-white hover:bg-white/10":"text-bambu-gray/30 cursor-not-allowed"}`,title:S("printers:control")?ae.state==="RUNNING"||ae.state==="PAUSE"||ae.state==="PAUSED"?(ae.printable_objects_count??0)>=2?x("printers.skipObjects.tooltip"):x("printers.skipObjects.requiresMultiple"):x("printers.skipObjects.onlyWhilePrinting"):x("printers.permission.noControl"),children:[a.jsx(k7,{className:"w-4 h-4"}),Et&&Et.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:Et.skipped_count})]}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(x8e,{url:ae.state==="RUNNING"?ae.cover_url:null,printName:ae.state==="RUNNING"&&(ae.subtask_name||ae.current_print)||void 0}),a.jsx("div",{className:"flex-1 min-w-0",children:ae.current_print&&ae.state==="RUNNING"?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:ae.stg_cur_name||"Printing"}),a.jsx("p",{className:"text-white text-sm mb-2 truncate",children:ae.subtask_name||ae.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:`${ae.progress||0}%`}})}),a.jsxs("span",{className:"text-white",children:[Math.round(ae.progress||0),"%"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[ae.remaining_time!=null&&ae.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(tr,{className:"w-3 h-3"}),f8e(ae.remaining_time*60)]}),a.jsxs("span",{className:"text-bambu-green font-medium",title:x("printers.estimatedCompletion"),children:["ETA ",m8e(ae.remaining_time,d)]})]}),ae.layer_num!=null&&ae.total_layers!=null&&ae.total_layers>0&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(xs,{className:"w-3 h-3"}),ae.layer_num,"/",ae.total_layers]}),rr&&a.jsxs("span",{className:"flex items-center gap-1",title:`Started by ${rr}`,children:[a.jsx(om,{className:"w-3 h-3"}),rr]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:x("printers.sort.status")}),a.jsx("p",{className:"text-white text-sm mb-2",children:D7(ae.state,ae.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:"—"})]}),Jn?a.jsxs("p",{className:"text-xs text-bambu-gray mt-2 truncate",title:Jn.print_name||Jn.filename,children:["Last: ",Jn.print_name||Jn.filename,Jn.completed_at&&a.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",$g(Jn.completed_at,{month:"short",day:"numeric"})]})]}):a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:x("printers.readyToPrint")})]})})]})]}),ae.state!=="RUNNING"&&a.jsx(a2e,{printerId:t.id})]}),ae.temperatures&&r==="expanded"&&(()=>{const rt=ae.temperatures.nozzle_heating||ae.temperatures.nozzle_2_heating||!1,Pt=ae.temperatures.bed_heating||!1,qt=ae.temperatures.chamber_heating||!1,vt=t.nozzle_count===2||ae.temperatures.nozzle_2!==void 0,wn=ae.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(cj,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:rt}),ae.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(ae.temperatures.nozzle||0),"° / ",Math.round(ae.temperatures.nozzle_2||0),"°"]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.nozzle")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.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(cj,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-blue-400",isHeating:Pt}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.bed")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.bed||0),"°C"]})]}),ae.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(cj,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-green-400",isHeating:qt}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.chamber")}),a.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.chamber||0),"°C"]})]}),vt&&a.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg",title:x("printers.activeNozzle",{nozzle:x(wn==="L"?"common.left":"common.right")}),children:[a.jsx("p",{className:`text-[11px] font-bold ${wn==="L"?"text-amber-400":"text-gray-500"}`,children:"L"}),a.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.nozzle")}),a.jsx("p",{className:`text-[11px] font-bold ${wn==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const rt=ae.state==="RUNNING",Pt=ae.state==="PAUSED"||ae.state==="PAUSE",qt=rt||Pt,vt=ai.isPending||je.isPending||tt.isPending,wn=ae.cooling_fan_speed,Fr=ae.big_fan1_speed,Qr=ae.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:x("printers.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 ${wn&&wn>0?"bg-cyan-500/10":"bg-bambu-dark"}`,title:x("printers.fans.partCooling"),children:[a.jsx(MW,{className:`w-3.5 h-3.5 ${wn&&wn>0?"text-cyan-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${wn&&wn>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[wn??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Fr&&Fr>0?"bg-blue-500/10":"bg-bambu-dark"}`,title:x("printers.fans.auxiliary"),children:[a.jsx(UW,{className:`w-3.5 h-3.5 ${Fr&&Fr>0?"text-blue-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${Fr&&Fr>0?"text-blue-400":"text-bambu-gray/50"}`,children:[Fr??0,"%"]})]}),a.jsxs("div",{className:`flex items-center gap-1 px-1.5 py-1 rounded ${Qr&&Qr>0?"bg-green-500/10":"bg-bambu-dark"}`,title:x("printers.fans.chamber"),children:[a.jsx(pce,{className:`w-3.5 h-3.5 ${Qr&&Qr>0?"text-green-400":"text-bambu-gray/50"}`}),a.jsxs("span",{className:`text-[10px] ${Qr&&Qr>0?"text-green-400":"text-bambu-gray/50"}`,children:[Qr??0,"%"]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:()=>W(!0),disabled:!qt||vt||!S("printers:control"),className:`
  8128. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  8129. transition-colors
  8130. ${qt&&S("printers:control")?"bg-red-500/20 text-red-400 hover:bg-red-500/30":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}
  8131. `,title:S("printers:control")?x("printers.stop"):x("printers.permission.noControl"),children:[a.jsx(cl,{className:"w-3 h-3"}),x("printers.stop")]}),a.jsxs("button",{onClick:()=>Pt?me(!0):re(!0),disabled:!qt||vt||!S("printers:control"),className:`
  8132. flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
  8133. transition-colors
  8134. ${qt&&S("printers:control")?Pt?"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"}
  8135. `,title:S("printers:control")?x(Pt?"printers.resume":"printers.pause"):x("printers.permission.noControl"),children:[Pt?a.jsx(So,{className:"w-3 h-3"}):a.jsx(jR,{className:"w-3 h-3"}),x(Pt?"printers.resume":"printers.pause")]})]})]})]})})(),Xe&&Xe.length>0&&r==="expanded"&&(()=>{const rt=Xe.filter(vt=>vt.tray.length>1),Pt=Xe.filter(vt=>vt.tray.length===1),qt=t.nozzle_count===2||ae?.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:x("printers.filaments")}),a.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),a.jsxs("div",{className:"space-y-3",children:[rt.length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-3",children:rt.map(vt=>{const wn=it[String(vt.id)],Fr=vt.id>=128?vt.id-128:vt.id,Qr=wn!==void 0?wn:Fr,Br=Qr===1,Ys=Qr===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:Ld(vt.id,vt.tray.length)}),qt&&(Br||Ys)&&a.jsx(T7,{side:Br?"L":"R"})]}),(vt.humidity!=null||vt.temp!=null)&&a.jsxs("div",{className:"flex items-center gap-1.5",children:[vt.humidity!=null&&a.jsx(C7,{humidity:vt.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair,onClick:()=>Ce({amsId:vt.id,amsLabel:Ld(vt.id,vt.tray.length),mode:"humidity"}),compact:!0}),vt.temp!=null&&a.jsx(j7,{temp:vt.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair,onClick:()=>Ce({amsId:vt.id,amsLabel:Ld(vt.id,vt.tray.length),mode:"temperature"}),compact:!0})]})]}),a.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:[0,1,2,3].map(nn=>{const ln=vt.tray[nn]||vt.tray.find(Hr=>Hr.id===nn),Si=ln?.tray_type&&ln.remain>=0,Es=!ln?.tray_type,Eo=vt.id*4+nn,To=$e===Eo,Ao=ln?.tray_info_idx?Ve?.[ln.tray_info_idx]:null,Ts=He?.[Eo],Ni=ln?.tray_type?{vendor:uj(ln)?"Bambu Lab":"Generic",profile:Ao?.name||Ts?.preset_name||ln.tray_sub_brands||ln.tray_type,colorName:sj(ln.tray_id_name)||oj(ln.tray_color),colorHex:ln.tray_color||null,kFactor:lj(ln.k),fillLevel:Si?ln.remain:null,trayUuid:ln.tray_uuid||null}:null,Qs=Ge?.amsId===vt.id&&Ge?.slotId===nn,da=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Es?"opacity-50":""} ${To?"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:ln?.tray_color?`#${ln.tray_color}`:ln?.tray_type?"#333":"transparent",borderColor:Es?"#666":"rgba(255,255,255,0.1)",borderStyle:Es?"dashed":"solid"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:ln?.tray_type||"—"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Si&&ln?a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${ln.remain}%`,backgroundColor:P7(ln.remain)}}):ln?.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:[Qs&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:a.jsx(Dr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),ae?.state!=="RUNNING"&&a.jsx("button",{onClick:Hr=>{Hr.stopPropagation(),Pn(ir?.amsId===vt.id&&ir?.slotId===nn?null:{amsId:vt.id,slotId:nn})},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:x("printers.slotOptions"),children:a.jsx(ah,{className:"w-2.5 h-2.5 text-bambu-gray"})}),ae?.state!=="RUNNING"&&ir?.amsId===vt.id&&ir?.slotId===nn&&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 flex items-center gap-2 ${S("printers:ams_rfid")?"text-white hover:bg-bambu-dark-tertiary":"text-bambu-gray/50 cursor-not-allowed"}`,onClick:Hr=>{Hr.stopPropagation(),S("printers:ams_rfid")&&(Tt.mutate({amsId:vt.id,slotId:nn}),Pn(null))},disabled:Qs||!S("printers:ams_rfid"),title:S("printers:ams_rfid")?void 0:x("printers.permission.noAmsRfid"),children:[a.jsx(Dr,{className:`w-3 h-3 ${Qs?"animate-spin":""}`}),x("printers.rfid.reread")]})}),Ni?a.jsx(ij,{data:Ni,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Ni.trayUuid?c?.[Ni.trayUuid.toUpperCase()]:void 0,spoolmanUrl:u,onLinkSpool:o&&Ni.trayUuid?Hr=>{xe({trayUuid:Hr,trayInfo:{type:Ni.profile,color:Ni.colorHex||"",location:`${Ld(vt.id,vt.tray.length)} Slot ${nn+1}`}})}:void 0},configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:vt.id,trayId:nn,trayCount:vt.tray.length,trayType:ln?.tray_type||void 0,trayColor:ln?.tray_color||void 0,traySubBrands:ln?.tray_sub_brands||void 0,trayInfoIdx:ln?.tray_info_idx||void 0})},children:da}):a.jsx(S7,{configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:vt.id,trayId:nn,trayCount:vt.tray.length})},children:da})]},nn)})})]},vt.id)})}),(Pt.length>0||ae.vt_tray&&ae.vt_tray.tray_type)&&a.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[Pt.map(vt=>{const wn=it[String(vt.id)],Fr=vt.id>=128?vt.id-128:vt.id,Qr=wn!==void 0?wn:Fr,Br=Qr===1,Ys=Qr===0,nn=vt.tray[0],ln=nn?.tray_type&&nn.remain>=0,Si=!nn?.tray_type,Es=vt.id*4+(nn?.id??0),Eo=$e===Es,To=nn?.tray_info_idx?Ve?.[nn.tray_info_idx]:null,Ao=He?.[Es],Ts=nn?.tray_type?{vendor:uj(nn)?"Bambu Lab":"Generic",profile:To?.name||Ao?.preset_name||nn.tray_sub_brands||nn.tray_type,colorName:sj(nn.tray_id_name)||oj(nn.tray_color),colorHex:nn.tray_color||null,kFactor:lj(nn.k),fillLevel:ln?nn.remain:null,trayUuid:nn.tray_uuid||null}:null,Ni=nn?.id??0,Qs=Ge?.amsId===vt.id&&Ge?.slotId===Ni,da=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Si?"opacity-50":""} ${Eo?"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:nn?.tray_color?`#${nn.tray_color}`:nn?.tray_type?"#333":"transparent",borderColor:Si?"#666":"rgba(255,255,255,0.1)",borderStyle:Si?"dashed":"solid"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:nn?.tray_type||"—"}),a.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:ln?a.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${nn.remain}%`,backgroundColor:P7(nn.remain)}}):nn?.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:Ld(vt.id,vt.tray.length)}),qt&&(Br||Ys)&&a.jsx(T7,{side:Br?"L":"R"})]}),a.jsxs("div",{className:"flex gap-1.5",children:[a.jsxs("div",{className:"relative group flex-1",children:[Qs&&a.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:a.jsx(Dr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),ae?.state!=="RUNNING"&&a.jsx("button",{onClick:Hr=>{Hr.stopPropagation(),Pn(ir?.amsId===vt.id&&ir?.slotId===Ni?null:{amsId:vt.id,slotId:Ni})},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:x("printers.slotOptions"),children:a.jsx(ah,{className:"w-2.5 h-2.5 text-bambu-gray"})}),ae?.state!=="RUNNING"&&ir?.amsId===vt.id&&ir?.slotId===Ni&&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 flex items-center gap-2 ${S("printers:ams_rfid")?"text-white hover:bg-bambu-dark-tertiary":"text-bambu-gray/50 cursor-not-allowed"}`,onClick:Hr=>{Hr.stopPropagation(),S("printers:ams_rfid")&&(Tt.mutate({amsId:vt.id,slotId:Ni}),Pn(null))},disabled:Qs||!S("printers:ams_rfid"),title:S("printers:ams_rfid")?void 0:x("printers.permission.noAmsRfid"),children:[a.jsx(Dr,{className:`w-3 h-3 ${Qs?"animate-spin":""}`}),x("printers.rfid.reread")]})}),Ts?a.jsx(ij,{data:Ts,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Ts.trayUuid?c?.[Ts.trayUuid.toUpperCase()]:void 0,spoolmanUrl:u,onLinkSpool:o&&Ts.trayUuid?Hr=>{xe({trayUuid:Hr,trayInfo:{type:Ts.profile,color:Ts.colorHex||"",location:Ld(vt.id,vt.tray.length)}})}:void 0},configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:vt.id,trayId:Ni,trayCount:vt.tray.length,trayType:nn?.tray_type||void 0,trayColor:nn?.tray_color||void 0,traySubBrands:nn?.tray_sub_brands||void 0,trayInfoIdx:nn?.tray_info_idx||void 0})},children:da}):a.jsx(S7,{configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:vt.id,trayId:Ni,trayCount:vt.tray.length})},children:da})]}),(vt.humidity!=null||vt.temp!=null)&&a.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[vt.temp!=null&&a.jsx(j7,{temp:vt.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair,onClick:()=>Ce({amsId:vt.id,amsLabel:Ld(vt.id,vt.tray.length),mode:"temperature"}),compact:!0}),vt.humidity!=null&&a.jsx(C7,{humidity:vt.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair,onClick:()=>Ce({amsId:vt.id,amsLabel:Ld(vt.id,vt.tray.length),mode:"humidity"}),compact:!0})]})]})]},vt.id)}),ae.vt_tray&&ae.vt_tray.tray_type&&(()=>{const vt=ae.vt_tray,wn=$e===254,Fr=vt.tray_info_idx?Ve?.[vt.tray_info_idx]:null,Qr=He?.[1020],Br={vendor:uj(vt)?"Bambu Lab":"Generic",profile:Fr?.name||Qr?.preset_name||vt.tray_sub_brands||vt.tray_type||"Unknown",colorName:sj(vt.tray_id_name)||oj(vt.tray_color),colorHex:vt.tray_color||null,kFactor:lj(vt.k),fillLevel:null,trayUuid:vt.tray_uuid||null},Ys=a.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center cursor-default ${wn?"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:vt.tray_color?`#${vt.tray_color}`:"#333",borderColor:wn?"var(--accent)":"rgba(255,255,255,0.1)"}}),a.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:vt.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:x("printers.external")})}),a.jsx(ij,{data:Br,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Br.trayUuid?c?.[Br.trayUuid.toUpperCase()]:void 0,spoolmanUrl:u,onLinkSpool:o&&Br.trayUuid?nn=>{xe({trayUuid:nn,trayInfo:{type:Br.profile,color:Br.colorHex||"",location:"External Spool"}})}:void 0},configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:255,trayId:0,trayCount:1,trayType:vt.tray_type||void 0,trayColor:vt.tray_color||void 0,traySubBrands:vt.tray_sub_brands||void 0,trayInfoIdx:vt.tray_info_idx||void 0})},children:Ys})]})})()]})]})]})})()]}),ye&&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(_h,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"text-sm text-white truncate",children:ye.name}),at&&a.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${at.state==="ON"?"bg-bambu-green/20 text-bambu-green":at.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[at.state||"?",at.state==="ON"&&at.energy?.power!=null&&a.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",at.energy.power,"W"]})]})]}),a.jsx("div",{className:"flex-1"}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsxs("button",{onClick:()=>K(!0),disabled:Xn.isPending||at?.state==="ON"||!S("smart_plugs:control"),className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${S("smart_plugs:control")?at?.state==="ON"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}`,title:S("smart_plugs:control")?void 0:x("printers.permission.noSmartPlugControl"),children:[a.jsx(qu,{className:"w-3 h-3"}),"On"]}),a.jsxs("button",{onClick:()=>X(!0),disabled:Xn.isPending||at?.state==="OFF"||!S("smart_plugs:control"),className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${S("smart_plugs:control")?at?.state==="OFF"?"bg-red-500/30 text-red-400":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary":"bg-bambu-dark text-bambu-gray/50 cursor-not-allowed"}`,title:S("smart_plugs:control")?void 0:x("printers.permission.noSmartPlugControl"),children:[a.jsx(xM,{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 ${ye.auto_off_executed?"text-bambu-green":"text-bambu-gray"}`,children:ye.auto_off_executed?"Auto-off done":"Auto-off"}),a.jsx("button",{onClick:()=>Nn.mutate(!ye.auto_off),disabled:Nn.isPending||ye.auto_off_executed||!S("smart_plugs:control"),title:S("smart_plugs:control")?ye.auto_off_executed?x("printers.autoOffExecuted"):x("printers.autoOffAfterPrint"):x("printers.permission.noSmartPlugControl"),className:`relative w-9 h-5 rounded-full transition-colors flex-shrink-0 ${S("smart_plugs:control")?ye.auto_off_executed?"bg-bambu-green/50 cursor-not-allowed":ye.auto_off?"bg-bambu-green":"bg-bambu-dark-tertiary":"bg-bambu-dark-tertiary/50 cursor-not-allowed"}`,children:a.jsx("span",{className:`absolute top-[2px] left-[2px] w-4 h-4 bg-white rounded-full transition-transform ${ye.auto_off||ye.auto_off_executed?"translate-x-4":"translate-x-0"}`})})]})]}),Je&&Je.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(Iy,{className:"w-3.5 h-3.5 text-blue-400 flex-shrink-0"}),a.jsx("span",{className:"text-xs text-bambu-gray",children:"HA:"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:Je.map(rt=>a.jsxs("button",{onClick:()=>hi.mutate(rt.id),disabled:hi.isPending,title:`Run ${rt.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(So,{className:"w-2.5 h-2.5"}),rt.name]},rt.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(Ae,{variant:"secondary",size:"sm",onClick:()=>dt.mutate(!ae?.chamber_light),disabled:!ae?.connected||dt.isPending||!S("printers:control"),title:S("printers:control")?ae?.chamber_light?x("printers.chamberLightOff"):x("printers.chamberLightOn"):x("printers.permission.noControl"),className:ae?.chamber_light?"bg-yellow-500/20 hover:bg-yellow-500/30 border-yellow-500/30":"",children:a.jsx(s8e,{on:ae?.chamber_light??!1,className:"w-4 h-4"})}),a.jsx(Ae,{variant:"secondary",size:"sm",onClick:()=>{if(h==="embedded"&&p)p(t.id,t.name);else{const rt=localStorage.getItem("cameraWindowState"),Pt=rt?JSON.parse(rt):{width:640,height:400},qt=[`width=${Pt.width}`,`height=${Pt.height}`,Pt.left!==void 0?`left=${Pt.left}`:"",Pt.top!==void 0?`top=${Pt.top}`:"","menubar=no,toolbar=no,location=no,status=no,noopener"].filter(Boolean).join(",");window.open(`/camera/${t.id}`,`camera-${t.id}`,qt)}},disabled:!ae?.connected,title:x(h==="embedded"?"printers.openCameraOverlay":"printers.openCameraWindow"),children:a.jsx(LR,{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(Ae,{variant:"secondary",size:"sm",onClick:Ht,disabled:!ae?.connected||ht.isPending||!S("printers:update"),title:S("printers:update")?t.plate_detection_enabled?x("printers.plateDetection.enabledClick"):x("printers.plateDetection.disabledClick"):x("printers.plateDetection.noPermission"),className:`!rounded-r-none !border-r-0 ${t.plate_detection_enabled?"!border-green-500 !text-green-400 hover:!bg-green-500/20":""}`,children:ht.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(Y1,{className:"w-4 h-4"})}),a.jsx(Ae,{variant:"secondary",size:"sm",onClick:hn,disabled:!ae?.connected||B||!S("printers:update"),title:S("printers:update")?x("printers.plateDetection.manageCalibration"):x("printers.plateDetection.noPermission"),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(pt,{className:"w-3 h-3 animate-spin"}):a.jsx(Kr,{className:"w-3 h-3"})})]}),a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:()=>L(!0),disabled:!S("printers:files"),title:S("printers:files")?x("printers.browseFiles"):x("printers.permission.noFiles"),children:[a.jsx(mM,{className:"w-4 h-4"}),"Files"]})]})]})]}),I&&a.jsx(WMe,{printerId:t.id,printerName:t.name,onClose:()=>L(!1)}),U&&a.jsx(JMe,{printerId:t.id,printerName:t.name,onClose:()=>j(!1)}),q&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>un(),children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full",onClick:rt=>rt.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:[q.needs_calibration?a.jsx(Y1,{className:"w-5 h-5 text-blue-500"}):q.is_empty?a.jsx(Ar,{className:"w-5 h-5 text-green-500"}):a.jsx(Ji,{className:"w-5 h-5 text-yellow-500"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Build Plate Check"}),q.reference_count!==void 0&&q.max_references&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:[q.reference_count,"/",q.max_references," refs"]})]}),a.jsx("button",{onClick:()=>un(),className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[q.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:x("printers.plateDetection.calibrationRequired")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",dangerouslySetInnerHTML:{__html:x("printers.plateDetection.calibrationInstructions")}})]}),a.jsxs("div",{className:"text-sm text-bambu-gray space-y-2",children:[a.jsx("p",{children:x("printers.plateDetection.calibrationDescription")}),a.jsx("p",{dangerouslySetInnerHTML:{__html:x("printers.plateDetection.calibrationTip")}})]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`p-3 rounded-lg ${q.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 ${q.is_empty?"text-green-400":"text-yellow-400"}`,children:q.is_empty?x("printers.plateDetection.plateEmpty"):x("printers.plateDetection.objectsDetected")}),a.jsxs("p",{className:"text-sm text-bambu-gray mt-1",children:[x("printers.plateDetection.confidence"),": ",Math.round(q.confidence*100),"% | ",x("printers.plateDetection.difference"),": ",q.difference_percent.toFixed(1),"%"]})]}),q.debug_image_url&&a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:x("printers.plateDetection.analysisPreview")}),a.jsx("img",{src:q.debug_image_url,alt:x("printers.plateDetection.analysisPreview"),className:"w-full rounded-lg border border-bambu-dark-tertiary"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:x("printers.plateDetection.analysisLegend")})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:q.message})]}),At&&At.references.length>0&&a.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[a.jsx("p",{className:"text-sm font-medium text-white mb-2",children:x("printers.plateDetection.savedReferences",{count:At.references.length,max:At.max_references})}),a.jsx("div",{className:"grid grid-cols-5 gap-2",children:At.references.map(rt=>a.jsxs("div",{className:"relative group",children:[a.jsx("img",{src:oe.getPlateReferenceThumbnailUrl(t.id,rt.index),alt:rt.label||`Reference ${rt.index+1}`,className:"w-full aspect-video object-cover rounded border border-bambu-dark-tertiary"}),a.jsx("button",{onClick:()=>on(rt.index),className:"absolute top-1 right-1 p-0.5 bg-red-500/80 rounded opacity-0 group-hover:opacity-100 transition-opacity",title:x("printers.plateDetection.deleteReference"),children:a.jsx(Lt,{className:"w-3 h-3 text-white"})}),Rt?.index===rt.index?a.jsx("input",{type:"text",value:Rt.label,onChange:Pt=>Mt({...Rt,label:Pt.target.value}),onBlur:()=>Gt(rt.index,Rt.label),onKeyDown:Pt=>{Pt.key==="Enter"&&Gt(rt.index,Rt.label),Pt.key==="Escape"&&Mt(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:x("printers.plateDetection.labelPlaceholder")}):a.jsx("p",{className:"text-xs text-bambu-gray mt-1 truncate cursor-pointer hover:text-white",onClick:()=>Mt({index:rt.index,label:rt.label}),title:rt.label?x("printers.plateDetection.clickToEdit",{label:rt.label}):x("printers.plateDetection.clickToAddLabel"),children:rt.label||a.jsx("span",{className:"italic opacity-50",children:x("printers.noLabel")})}),a.jsx("p",{className:"text-[10px] text-bambu-gray/60",children:rt.timestamp?new Date(rt.timestamp).toLocaleDateString():""})]},rt.index))})]}),!q.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:x("printers.roi.title")}),H?a.jsxs("div",{className:"flex gap-1",children:[a.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>O(null),disabled:J,children:x("common.cancel")}),a.jsx(Ae,{size:"sm",onClick:dn,disabled:J,children:J?a.jsx(pt,{className:"w-3 h-3 animate-spin"}):x("common.save")})]}):a.jsxs(Ae,{variant:"ghost",size:"sm",onClick:()=>O(q.roi||{x:.15,y:.35,w:.7,h:.55}),children:[a.jsx(ea,{className:"w-3 h-3 mr-1"}),x("common.edit")]})]}),H?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("printers.roi.xStart")}),a.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:H.x,onChange:rt=>O({...H,x:parseFloat(rt.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(H.x*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:x("printers.roi.yStart")}),a.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:H.y,onChange:rt=>O({...H,y:parseFloat(rt.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(H.y*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:x("printers.width")}),a.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:H.w,onChange:rt=>O({...H,w:parseFloat(rt.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(H.w*100),"%"]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-xs text-bambu-gray",children:x("printers.height")}),a.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:H.h,onChange:rt=>O({...H,h:parseFloat(rt.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(H.h*100),"%"]})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:x("printers.roi.instruction")})]}):a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Current: X=",Math.round((q.roi?.x||.15)*100),"%, Y=",Math.round((q.roi?.y||.35)*100),"%, W=",Math.round((q.roi?.w||.7)*100),"%, H=",Math.round((q.roi?.h||.55)*100),"%"]})]})]}),a.jsx("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:q.needs_calibration?a.jsxs(a.Fragment,{children:[a.jsx(Ae,{variant:"ghost",onClick:()=>un(),children:x("common.cancel")}),a.jsx(Ae,{onClick:()=>Mn(),disabled:ke,children:ke?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 mr-2 animate-spin"}),"Calibrating..."]}):"Calibrate Empty Plate"})]}):a.jsxs(a.Fragment,{children:[a.jsx(Ae,{variant:"ghost",onClick:()=>Mn(),disabled:ke,children:ke?"Adding...":`Add Reference (${At?.references.length||0}/${At?.max_references||5})`}),a.jsx(Ae,{onClick:()=>un(),children:"Close"})]})})]})}),V&&ye&&a.jsx(Zn,{title:x("printers.confirm.powerOnTitle"),message:x("printers.confirm.powerOnMessage",{name:t.name}),confirmText:x("printers.confirm.powerOnButton"),variant:"default",onConfirm:()=>{Xn.mutate("on"),K(!1)},onCancel:()=>K(!1)}),z&&ye&&a.jsx(Zn,{title:x("printers.confirm.powerOffTitle"),message:ae?.state==="RUNNING"?x("printers.confirm.powerOffWarning",{name:t.name}):x("printers.confirm.powerOffMessage",{name:t.name}),confirmText:x("printers.confirm.powerOffButton"),variant:"danger",onConfirm:()=>{Xn.mutate("off"),X(!1)},onCancel:()=>X(!1)}),$&&a.jsx(Zn,{title:x("printers.confirm.stopTitle"),message:x("printers.confirm.stopMessage",{name:t.name}),confirmText:x("printers.confirm.stopButton"),variant:"danger",onConfirm:()=>{ai.mutate(),W(!1)},onCancel:()=>W(!1)}),ne&&a.jsx(Zn,{title:x("printers.confirm.pauseTitle"),message:x("printers.confirm.pauseMessage",{name:t.name}),confirmText:x("printers.confirm.pauseButton"),variant:"default",onConfirm:()=>{je.mutate(),re(!1)},onCancel:()=>re(!1)}),ge&&a.jsx(Zn,{title:x("printers.confirm.resumeTitle"),message:x("printers.confirm.resumeMessage",{name:t.name}),confirmText:x("printers.confirm.resumeButton"),variant:"default",onConfirm:()=>{tt.mutate(),me(!1)},onCancel:()=>me(!1)}),ue&&a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>Te(!1),onKeyDown:rt=>rt.key==="Escape"&&Te(!1),tabIndex:-1,ref:rt=>rt?.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:rt=>rt.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(k7,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:x("printers.skipObjects.title")})]}),a.jsx("button",{onClick:()=>Te(!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(Lt,{className:"w-4 h-4"})})]}),Et?Et.objects.length===0?a.jsxs("div",{className:"text-center py-8 px-4 text-bambu-gray",children:[a.jsx("p",{className:"text-sm",children:x("printers.noObjectsFound")}),a.jsx("p",{className:"text-xs mt-1 opacity-70",children:x("printers.objectsLoadedOnPrintStart")})]}):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(the,{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:x("printers.skipObjects.matchIdsInfo")}),a.jsx("p",{className:"text-[10px] text-blue-500/70 dark:text-blue-300/60",children:x("printers.skipObjects.printerShowsIds")})]}),a.jsxs("div",{className:"flex-shrink-0 text-xs text-gray-500 dark:text-bambu-gray",children:[Et.skipped_count,"/",Et.total," ",x("printers.skipObjects.skipped")]})]}),(ae?.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(Vi,{className:"w-4 h-4 text-amber-500 dark:text-amber-400 flex-shrink-0"}),a.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:x("printers.skipObjects.waitForLayer",{layer:ae?.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:[ae?.cover_url?a.jsx("img",{src:`${ae.cover_url}?view=top`,alt:x("printers.printPreview"),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(Ui,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),Et.objects.length>0&&a.jsx("div",{className:"absolute inset-0 pointer-events-none",children:Et.objects.map((rt,Pt)=>{let qt,vt;if(rt.x!=null&&rt.y!=null&&Et.bbox_all){const[wn,Fr,Qr,Br]=Et.bbox_all,Ys=Qr-wn,nn=Br-Fr,ln=8,Si=100-ln*2;qt=ln+(rt.x-wn)/Ys*Si,vt=ln+(Br-rt.y)/nn*Si,qt=Math.max(5,Math.min(95,qt)),vt=Math.max(5,Math.min(95,vt))}else if(rt.x!=null&&rt.y!=null)qt=rt.x/256*100,vt=100-rt.y/256*100,qt=Math.max(5,Math.min(95,qt)),vt=Math.max(5,Math.min(95,vt));else{const wn=Math.ceil(Math.sqrt(Et.objects.length)),Fr=Math.floor(Pt/wn),Qr=Pt%wn,Br=Math.ceil(Et.objects.length/wn);qt=15+Qr*(70/wn)+35/wn,vt=15+Fr*(70/Br)+35/Br}return a.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${rt.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${qt}%`,top:`${vt}%`,transform:"translate(-50%, -50%)"},title:rt.name,children:rt.id},rt.id)})}),a.jsx("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:x("printers.skipObjects.activeCount",{count:Et.objects.filter(rt=>!rt.skipped).length})})]})}),a.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:Et.objects.map(rt=>a.jsxs("div",{className:`
  8136. flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
  8137. ${rt.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
  8138. `,children:[a.jsxs("div",{className:`
  8139. w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
  8140. ${rt.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"}
  8141. `,children:[a.jsx("span",{className:`text-lg font-mono font-bold ${rt.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:rt.id}),a.jsx("span",{className:`text-[8px] uppercase tracking-wider ${rt.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 ${rt.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:rt.name}),rt.skipped&&a.jsx("span",{className:"text-[10px] text-red-400/60",children:x("printers.willBeSkipped")})]}),rt.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:x("printers.skipObjects.skipped")}):a.jsx("button",{onClick:()=>Re.mutate([rt.id]),disabled:Re.isPending||(ae?.layer_num??0)<=1||!S("printers:control"),className:`px-4 py-2 text-xs font-medium rounded-lg transition-colors ${(ae?.layer_num??0)<=1||!S("printers:control")?"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:S("printers:control")?(ae?.layer_num??0)<=1?x("printers.skipObjects.waitForLayer",{layer:ae?.layer_num??0}):x("printers.skipObjects.skip"):x("printers.permission.noControl"),children:x("printers.skipObjects.skip")})]},rt.id))})]})]}):a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(pt,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),Y&&a.jsx(r2e,{printerName:t.name,errors:ae?.hms_errors||[],onClose:()=>te(!1)}),ie&&a.jsx(QBe,{isOpen:!!ie,onClose:()=>Ce(null),printerId:t.id,printerName:t.name,amsId:ie.amsId,amsLabel:ie.amsLabel,initialMode:ie.mode,thresholds:s}),Fe&&a.jsx(ZBe,{isOpen:!!Fe,onClose:()=>xe(null),trayUuid:Fe.trayUuid,trayInfo:Fe.trayInfo}),Ze&&a.jsx(a8e,{isOpen:!!Ze,onClose:()=>G(null),printerId:t.id,slotInfo:Ze,onSuccess:()=>{y.invalidateQueries({queryKey:["slotPresets",t.id]}),y.invalidateQueries({queryKey:["printerStatus",t.id]})}}),A&&a.jsx(w8e,{printer:t,onClose:()=>D(!1)}),Q&&Le&&a.jsx(v8e,{printer:t,firmwareInfo:Le,onClose:()=>de(!1)}),ir&&a.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Pn(null)})]})}function y8e({onClose:t,onAdd:e,existingSerials:n}){const{t:r}=On(),[i,s]=_.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",location:"",auto_archive:!0}),[o,l]=_.useState(!1),[c,u]=_.useState([]),[d,h]=_.useState(""),[p,m]=_.useState(!1),[x,y]=_.useState(!1),[v,b]=_.useState("192.168.1.0/24"),[S,N]=_.useState({scanned:0,total:0});_.useEffect(()=>{Ql.getInfo().then(P=>{y(P.is_docker)}).catch(()=>{})},[]);const T=c.filter(P=>!n.includes(P.serial)),k=async()=>{h(""),u([]),l(!0),m(!1),N({scanned:0,total:0});try{if(x){await Ql.startSubnetScan(v);const P=setInterval(async()=>{try{const A=await Ql.getScanStatus();N({scanned:A.scanned,total:A.total});const D=await Ql.getDiscoveredPrinters();u(D),A.running||(clearInterval(P),l(!1),m(!0))}catch(A){console.error("Failed to get scan status:",A)}},500)}else{await Ql.startDiscovery(10);const P=setInterval(async()=>{try{const A=await Ql.getDiscoveredPrinters();u(A)}catch(A){console.error("Failed to get discovered printers:",A)}},1e3);setTimeout(async()=>{clearInterval(P);try{await Ql.stopDiscovery()}catch{}l(!1),m(!0);try{const A=await Ql.getDiscoveredPrinters();u(A)}catch(A){console.error("Failed to get final discovered printers:",A)}},1e4)}}catch(P){console.error("Failed to start discovery:",P),h(P instanceof Error?P.message:r("printers.discovery.failedToStart")),l(!1),m(!0)}},C=P=>P?{O1D:"H2D",O1E:"H2D Pro",O2D:"H2D Pro",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","H2D Pro":"H2D Pro",H2C:"H2C",H2S:"H2S"}[P]||P:"",E=P=>{const A=P.serial.startsWith("unknown-")?"":P.serial;s({...i,name:P.name||"",serial_number:A,ip_address:P.ip_address,model:C(P.model)}),u([])};return _.useEffect(()=>()=>{Ql.stopDiscovery().catch(()=>{}),Ql.stopSubnetScan().catch(()=>{})},[]),_.useEffect(()=>{const P=A=>{A.key==="Escape"&&t()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:a.jsx(St,{className:"w-full max-w-md",onClick:P=>P.stopPropagation(),children:a.jsxs(Nt,{children:[a.jsx("h2",{className:"text-xl font-semibold mb-4",children:r("printers.addPrinter")}),a.jsxs("div",{className:"mb-4 pb-4 border-b border-bambu-dark-tertiary",children:[x&&a.jsxs("div",{className:"mb-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.discovery.subnetToScan")}),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:v,onChange:P=>b(P.target.value),placeholder:"192.168.1.0/24",disabled:o}),a.jsx("p",{className:"mt-1 text-xs text-bambu-gray",children:r("printers.discovery.dockerNote")})]}),a.jsx(Ae,{type:"button",variant:"secondary",onClick:k,disabled:o,className:"w-full",children:o?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 animate-spin"}),x&&S.total>0?r("printers.discovery.scanProgress",{scanned:S.scanned,total:S.total}):r("printers.discovery.scanning")]}):a.jsxs(a.Fragment,{children:[a.jsx(wa,{className:"w-4 h-4"}),r(x?"printers.discovery.scanSubnet":"printers.discovery.discoverNetwork")]})}),d&&a.jsx("div",{className:"mt-2 text-sm text-red-400",children:d}),T.length>0&&a.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:T.map(P=>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:()=>E(P),children:[a.jsxs("div",{className:"min-w-0 flex-1",children:[a.jsx("p",{className:"font-medium text-white text-sm truncate",children:P.name||P.serial}),a.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[C(P.model)||r("printers.discovery.unknown")," • ",P.ip_address,P.serial.startsWith("unknown-")&&a.jsxs("span",{className:"text-yellow-500",children:[" • ",r("printers.discovery.serialRequired")]})]})]}),a.jsx(Kr,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},P.serial))}),o&&a.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r(x?"printers.discovery.scanningSubnet":"printers.discovery.scanningNetwork")}),p&&!o&&c.length===0&&a.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r(x?"printers.discovery.noPrintersFoundSubnet":"printers.discovery.noPrintersFoundNetwork")}),p&&!o&&c.length>0&&T.length===0&&a.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r("printers.discovery.allConfigured")})]}),a.jsxs("form",{onSubmit:P=>{P.preventDefault(),e(i)},className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.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:i.name,onChange:P=>s({...i,name:P.target.value}),placeholder:r("printers.modal.myPrinter")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.ipAddress")}),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:i.ip_address,onChange:P=>s({...i,ip_address:P.target.value}),placeholder:"192.168.1.100"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.serialNumber")}),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:i.serial_number,onChange:P=>s({...i,serial_number:P.target.value}),placeholder:"01P00A000000000"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.accessCode")}),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:i.access_code,onChange:P=>s({...i,access_code:P.target.value}),placeholder:r("printers.modal.fromPrinterSettings")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.modal.modelOptional")}),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:i.model||"",onChange:P=>s({...i,model:P.target.value}),children:[a.jsx("option",{value:"",children:r("printers.modal.selectModel")}),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:"H2D Pro",children:"H2D Pro"}),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:r("printers.modal.locationGroup")}),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:i.location||"",onChange:P=>s({...i,location:P.target.value}),placeholder:r("printers.modal.locationPlaceholder")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r("printers.locationHelp")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"auto_archive",checked:i.auto_archive,onChange:P=>s({...i,auto_archive:P.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:r("printers.modal.autoArchiveLabel")})]}),a.jsxs("div",{className:"flex gap-3 pt-4",children:[a.jsx(Ae,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),a.jsx(Ae,{type:"submit",className:"flex-1",children:r("printers.addPrinter")})]})]})]})})})}function v8e({printer:t,firmwareInfo:e,onClose:n}){const{t:r}=On(),i=sn(),{showToast:s}=Hn(),[o,l]=_.useState(null),[c,u]=_.useState(!1),[d,h]=_.useState(null),{data:p,isLoading:m}=ct({queryKey:["firmwarePrepare",t.id],queryFn:()=>b1.prepareUpload(t.id),staleTime:3e4}),x=gt({mutationFn:()=>b1.startUpload(t.id),onSuccess:()=>{u(!0);const v=setInterval(async()=>{try{const b=await b1.getUploadStatus(t.id);l(b),(b.status==="complete"||b.status==="error")&&(clearInterval(v),h(null),u(!1),b.status==="complete"&&(s(r("printers.firmwareModal.uploadedToast"),"success"),i.invalidateQueries({queryKey:["firmwareUpdate",t.id]})))}catch{}},2e3);h(v)},onError:v=>{s(`Failed to start upload: ${v.message}`,"error"),u(!1)}});_.useEffect(()=>()=>{d&&clearInterval(d)},[d]);const y=()=>{l(null),x.mutate()};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:a.jsx(St,{className:"w-full max-w-md mx-4",children:a.jsxs(Nt,{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(wi,{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:r("printers.firmwareModal.title")}),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:r("printers.firmwareModal.currentVersion")}),a.jsx("span",{className:"text-white font-mono",children:e.current_version||r("common.unknown")})]}),a.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[a.jsx("span",{className:"text-bambu-gray",children:r("printers.firmwareModal.latestVersion")}),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:r("printers.firmwareModal.releaseNotes")}),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(pt,{className:"w-4 h-4 animate-spin"}),r("printers.firmwareModal.checkingPrereqs")]}):p&&!c&&!o?a.jsx("div",{className:"mb-4",children:p.can_proceed?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-green text-sm",children:[a.jsx(Ui,{className:"w-4 h-4"}),r("printers.firmwareModal.sdCardReady")]}):a.jsx("div",{className:"space-y-1",children:p.errors.map((v,b)=>a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(Vi,{className:"w-4 h-4 flex-shrink-0"}),v]},b))})}):null,(c||o)&&o&&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:o.status}),a.jsxs("span",{className:"text-white",children:[o.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 ${o.status==="error"?"bg-status-error":o.status==="complete"?"bg-status-ok":"bg-orange-500"} ${o.status==="uploading"?"animate-pulse":""}`,style:{width:`${o.progress}%`}})}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:o.message}),o.error&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:o.error})]}),o?.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:r("printers.firmwareModal.uploadedSuccess")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:r("printers.firmwareModal.applyInstructions")}),a.jsxs("ol",{className:"text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1",children:[a.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step1")}}),a.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step2")}}),a.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step3")}}),a.jsx("li",{children:r("printers.firmwareModal.step4")})]})]}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Ae,{variant:"secondary",onClick:n,children:o?.status==="complete"?r("printers.firmwareModal.done"):r("common.cancel")}),p?.can_proceed&&!c&&o?.status!=="complete"&&a.jsx(Ae,{onClick:y,disabled:x.isPending,children:x.isPending?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}),r("printers.firmwareModal.starting")]}):a.jsxs(a.Fragment,{children:[a.jsx(wi,{className:"w-4 h-4 mr-2"}),r("printers.firmwareModal.uploadFirmware")]})})]})]})})})}function w8e({printer:t,onClose:e}){const{t:n}=On(),r=sn(),{showToast:i}=Hn(),[s,o]=_.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),l=gt({mutationFn:u=>oe.updatePrinter(t.id,u),onSuccess:()=>{r.invalidateQueries({queryKey:["printers"]}),r.invalidateQueries({queryKey:["printerStatus",t.id]}),e()},onError:u=>i(u.message||n("printers.toast.failedToUpdate"),"error")});_.useEffect(()=>{const u=d=>{d.key==="Escape"&&e()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[e]);const c=u=>{u.preventDefault();const d={name:s.name,ip_address:s.ip_address,model:s.model||void 0,location:s.location||void 0,auto_archive:s.auto_archive};s.access_code&&(d.access_code=s.access_code),l.mutate(d)};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:a.jsx(St,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:a.jsxs(Nt,{children:[a.jsx("h2",{className:"text-xl font-semibold mb-4",children:n("printers.editPrinter")}),a.jsxs("form",{onSubmit:c,className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.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:s.name,onChange:u=>o({...s,name:u.target.value}),placeholder:n("printers.modal.myPrinter")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.ipAddress")}),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:s.ip_address,onChange:u=>o({...s,ip_address:u.target.value}),placeholder:"192.168.1.100"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.serialNumber")}),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:n("printers.serialCannotBeChanged")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.accessCode")}),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:s.access_code,onChange:u=>o({...s,access_code:u.target.value}),placeholder:n("printers.accessCodePlaceholder")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.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:s.model,onChange:u=>o({...s,model:u.target.value}),children:[a.jsx("option",{value:"",children:n("printers.modal.selectModel")}),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:"H2D Pro",children:"H2D Pro"}),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:s.location,onChange:u=>o({...s,location:u.target.value}),placeholder:n("printers.modal.locationPlaceholder")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("printers.locationHelp")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:s.auto_archive,onChange:u=>o({...s,auto_archive:u.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:n("printers.modal.autoArchiveLabel")})]}),a.jsxs("div",{className:"flex gap-3 pt-4",children:[a.jsx(Ae,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:n("common.cancel")}),a.jsx(Ae,{type:"submit",className:"flex-1",disabled:l.isPending,children:l.isPending?n("common.saving"):n("printers.modal.saveChanges")})]})]})]})})})}function _8e(t){const{data:e}=ct({queryKey:["printerStatus",t],queryFn:()=>oe.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function S8e({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=_8e(t.id),{data:s}=ct({queryKey:["smartPlugStatus",e.id],queryFn:()=>oe.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(qu,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function N8e(){const{t}=On(),[e,n]=_.useState(!1),[r,i]=_.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[s,o]=_.useState(!1),[l,c]=_.useState(null),[u,d]=_.useState(()=>localStorage.getItem("printerSortBy")||"name"),[h,p]=_.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[m,x]=_.useState(()=>{const ue=localStorage.getItem("printerCardSize");return ue?parseInt(ue,10):2}),y=m===1?"compact":"expanded",v=sn(),{showToast:b}=Hn(),{hasPermission:S}=Ci(),[N,T]=_.useState(()=>{const ue=localStorage.getItem("openEmbeddedCameras");if(ue)try{const Te=JSON.parse(ue);return new Map(Te.map(ie=>[ie.id,ie]))}catch{return new Map}return new Map});_.useEffect(()=>{const ue=Array.from(N.values());ue.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(ue)):localStorage.removeItem("openEmbeddedCameras")},[N]);const{data:k,isLoading:C}=ct({queryKey:["printers"],queryFn:oe.getPrinters}),{data:E}=ct({queryKey:["settings"],queryFn:oe.getSettings});_.useEffect(()=>{E?.camera_view_mode==="window"&&N.size>0&&T(new Map)},[E?.camera_view_mode,N.size]);const{data:P}=ct({queryKey:["smart-plugs"],queryFn:oe.getSmartPlugs}),{data:A}=ct({queryKey:["maintenanceOverview"],queryFn:oe.getMaintenanceOverview,staleTime:60*1e3}),{data:D}=ct({queryKey:["spoolman-status"],queryFn:oe.getSpoolmanStatus,staleTime:60*1e3}),I=D?.enabled&&D?.connected,{data:L}=ct({queryKey:["unlinked-spools"],queryFn:oe.getUnlinkedSpools,enabled:!!I,staleTime:30*1e3}),U=L&&L.length>0,{data:j}=ct({queryKey:["linked-spools"],queryFn:oe.getLinkedSpools,enabled:!!I,staleTime:30*1e3}),V=j?.linked,K=A?.reduce((ue,Te)=>(ue[Te.printer_id]={due_count:Te.due_count,warning_count:Te.warning_count,total_print_hours:Te.total_print_hours},ue),{})||{},z=P?.reduce((ue,Te)=>(Te.printer_id&&(ue[Te.printer_id]=Te),ue),{})||{},X=gt({mutationFn:oe.createPrinter,onSuccess:()=>{v.invalidateQueries({queryKey:["printers"]}),v.invalidateQueries({queryKey:["maintenanceOverview"]}),n(!1)},onError:ue=>b(ue.message||t("printers.toast.failedToAdd"),"error")}),Y=gt({mutationFn:ue=>oe.controlSmartPlug(ue,"on"),onSuccess:()=>{v.invalidateQueries({queryKey:["smart-plugs"]}),c(null)},onError:()=>{c(null)}}),te=()=>{const ue=!r;i(ue),localStorage.setItem("hideDisconnectedPrinters",String(ue))},$=ue=>{d(ue),localStorage.setItem("printerSortBy",ue)},W=()=>{const ue=!h;p(ue),localStorage.setItem("printerSortAsc",String(ue))},ne=()=>{switch(m){case 1:return"grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5";case 2:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3";case 3:return"grid-cols-1 lg:grid-cols-2";case 4:return"grid-cols-1";default:return"grid-cols-1 md:grid-cols-2 xl:grid-cols-3"}},re=["S","M","L","XL"],ge=_.useMemo(()=>{if(!k)return[];const ue=[...k];switch(u){case"name":ue.sort((Te,ie)=>Te.name.localeCompare(ie.name));break;case"model":ue.sort((Te,ie)=>(Te.model||"").localeCompare(ie.model||""));break;case"location":ue.sort((Te,ie)=>{const Ce=Te.location||"",Fe=ie.location||"";return!Ce&&Fe?1:Ce&&!Fe?-1:Ce.localeCompare(Fe)||Te.name.localeCompare(ie.name)});break;case"status":ue.sort((Te,ie)=>{const Ce=v.getQueryData(["printerStatus",Te.id]),Fe=v.getQueryData(["printerStatus",ie.id]),xe=Ze=>Ze?.connected?Ze.state==="RUNNING"?0:1:2;return xe(Ce)-xe(Fe)});break}return h||ue.reverse(),ue},[k,u,h,v]),me=_.useMemo(()=>{if(u!=="location")return null;const ue={};return ge.forEach(Te=>{const ie=Te.location||"Ungrouped";ue[ie]||(ue[ie]=[]),ue[ie].push(Te)}),ue},[u,ge]);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:t("printers.title")}),a.jsx(b8e,{printers:k})]}),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:u,onChange:ue=>$(ue.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:t("printers.sort.name")}),a.jsx("option",{value:"status",children:t("printers.sort.status")}),a.jsx("option",{value:"model",children:t("printers.sort.model")}),a.jsx("option",{value:"location",children:t("printers.sort.location")})]}),a.jsx("button",{onClick:W,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:t(h?"printers.sort.descending":"printers.sort.ascending"),children:h?a.jsx(zg,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(q0,{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:re.map((ue,Te)=>{const ie=Te+1,Ce=m===ie;return a.jsx("button",{onClick:()=>{x(ie),localStorage.setItem("printerCardSize",String(ie))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${Te===0?"rounded-l-lg":""} ${Te===re.length-1?"rounded-r-lg":""} ${Ce?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:t(ue==="S"?"printers.cardSize.small":ue==="M"?"printers.cardSize.medium":ue==="L"?"printers.cardSize.large":"printers.cardSize.extraLarge"),children:ue},ue)})}),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:r,onChange:te,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),t("printers.hideOffline")]}),r&&Object.keys(z).length>0&&a.jsxs("div",{className:"relative",children:[a.jsxs("button",{onClick:()=>o(!s),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(qu,{className:"w-4 h-4"}),t("printers.powerOn"),a.jsx(Kr,{className:`w-3 h-3 transition-transform ${s?"rotate-180":""}`})]}),s&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>o(!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:t("printers.offlinePrintersWithPlugs")}),k?.filter(ue=>z[ue.id]).map(ue=>a.jsx(S8e,{printer:ue,plug:z[ue.id],onPowerOn:Te=>{c(Te),Y.mutate(Te)},isPowering:l===z[ue.id]?.id},ue.id)),k?.filter(ue=>z[ue.id]).length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),a.jsxs(Ae,{onClick:()=>n(!0),disabled:!S("printers:create"),title:S("printers:create")?void 0:t("printers.permission.noAdd"),children:[a.jsx(fr,{className:"w-4 h-4"}),t("printers.addPrinter")]})]})]}),C?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):k?.length===0?a.jsx(St,{children:a.jsxs(Nt,{className:"text-center py-12",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:t("printers.noPrintersConfigured")}),a.jsxs(Ae,{onClick:()=>n(!0),disabled:!S("printers:create"),title:S("printers:create")?void 0:t("printers.permission.noAdd"),children:[a.jsx(fr,{className:"w-4 h-4"}),t("printers.addPrinter")]})]})}):me?a.jsx("div",{className:"space-y-6",children:Object.entries(me).map(([ue,Te])=>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"}),ue,a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Te.length,")"]})]}),a.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${ne()}`,children:Te.map(ie=>a.jsx(R7,{printer:ie,hideIfDisconnected:r,maintenanceInfo:K[ie.id],viewMode:y,cardSize:m,amsThresholds:E?{humidityGood:Number(E.ams_humidity_good)||40,humidityFair:Number(E.ams_humidity_fair)||60,tempGood:Number(E.ams_temp_good)||28,tempFair:Number(E.ams_temp_fair)||35}:void 0,spoolmanEnabled:I,hasUnlinkedSpools:U,linkedSpools:V,spoolmanUrl:D?.url,timeFormat:E?.time_format||"system",cameraViewMode:E?.camera_view_mode||"window",onOpenEmbeddedCamera:(Ce,Fe)=>T(xe=>new Map(xe).set(Ce,{id:Ce,name:Fe})),checkPrinterFirmware:E?.check_printer_firmware!==!1},ie.id))})]},ue))}):a.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${ne()}`,children:ge.map(ue=>a.jsx(R7,{printer:ue,hideIfDisconnected:r,maintenanceInfo:K[ue.id],viewMode:y,cardSize:m,spoolmanEnabled:I,hasUnlinkedSpools:U,linkedSpools:V,spoolmanUrl:D?.url,amsThresholds:E?{humidityGood:Number(E.ams_humidity_good)||40,humidityFair:Number(E.ams_humidity_fair)||60,tempGood:Number(E.ams_temp_good)||28,tempFair:Number(E.ams_temp_fair)||35}:void 0,timeFormat:E?.time_format||"system",cameraViewMode:E?.camera_view_mode||"window",onOpenEmbeddedCamera:(Te,ie)=>T(Ce=>new Map(Ce).set(Te,{id:Te,name:ie})),checkPrinterFirmware:E?.check_printer_firmware!==!1},ue.id))}),e&&a.jsx(y8e,{onClose:()=>n(!1),onAdd:ue=>X.mutate(ue),existingSerials:k?.map(ue=>ue.serial_number)||[]}),Array.from(N.values()).map((ue,Te)=>a.jsx(ZMe,{printerId:ue.id,printerName:ue.name,viewerIndex:Te,onClose:()=>T(ie=>{const Ce=new Map(ie);return Ce.delete(ue.id),Ce})},ue.id))]})}function M8e(){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 k8e(){switch(M8e()){case"windows":return"bambustudio://";case"macos":case"linux":default:return"bambustudioopen://"}}function lc(t){const e=k8e();window.location.href=`${e}${encodeURIComponent(t)}`}function gL({archiveId:t,libraryFileId:e,title:n,fileType:r,onClose:i}){const s=e!=null,[o,l]=_.useState(null),[c,u]=_.useState(null),[d,h]=_.useState(!0),[p,m]=_.useState(null),[x,y]=_.useState(!1),[v,b]=_.useState(null);_.useEffect(()=>{const E=P=>{P.key==="Escape"&&i()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[i]),_.useEffect(()=>{if(h(!0),s){const E=(r||"").toLowerCase(),P=E==="3mf"||E==="stl",A=E==="gcode"||E==="3mf";u({has_model:P,has_gcode:A,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),l(P?"3d":A?"gcode":null),h(!1);return}if(!t){u(null),l(null),h(!1);return}oe.getArchiveCapabilities(t).then(E=>{u(E),E.has_model?l("3d"):E.has_gcode&&l("gcode"),h(!1)}).catch(()=>{u({has_model:!0,has_gcode:!1,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),l("3d"),h(!1)})},[t,r,s]),_.useEffect(()=>{if(y(!0),b(null),s){const E=(r||"").toLowerCase();if(!e||E!=="3mf"){m(null),y(!1);return}oe.getLibraryFilePlates(e).then(P=>m(P)).catch(()=>m(null)).finally(()=>y(!1));return}if(!t){m(null),y(!1);return}oe.getArchivePlates(t).then(E=>m(E)).catch(()=>m(null)).finally(()=>y(!1))},[t,r,s,e]);const S=p?.plates??[],N=(p?.is_multi_plate??!1)&&S.length>1,T=v==null?null:S.find(E=>E.index===v)??null,k=s?(r||"").toLowerCase()==="3mf":!0,C=()=>{if(!k)return;const E=n||"model";if(s){const A=`${window.location.origin}${oe.getLibraryFileDownloadUrl(e)}`;lc(A);return}const P=`${window.location.origin}${oe.getArchiveForSlicer(t,E)}`;lc(P)};return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:i,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:E=>E.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:n}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:C,disabled:!k,children:[a.jsx(Xr,{className:"w-4 h-4"}),"Open in Slicer"]}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:i,children:a.jsx(Lt,{className:"w-5 h-5"})})]})]}),c&&a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[a.jsxs("button",{onClick:()=>c.has_model&&l("3d"),disabled:!c.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${o==="3d"?"text-bambu-green border-b-2 border-bambu-green":c.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(Ui,{className:"w-4 h-4"}),"3D Model",!c.has_model&&a.jsx("span",{className:"text-xs",children:"(not available)"})]}),a.jsxs("button",{onClick:()=>c.has_gcode&&l("gcode"),disabled:!c.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${o==="gcode"?"text-bambu-green border-b-2 border-bambu-green":c.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[a.jsx(mue,{className:"w-4 h-4"}),"G-code Preview",!c.has_gcode&&a.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),a.jsx("div",{className:"flex-1 overflow-hidden p-4",children:d?a.jsx("div",{className:"w-full h-full flex items-center justify-center",children:a.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"})}):o==="3d"&&c?a.jsxs("div",{className:"w-full h-full flex flex-col gap-3",children:[N&&a.jsxs("div",{className:"rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray mb-2",children:[a.jsx(xs,{className:"w-4 h-4"}),"Plates",x&&a.jsx(pt,{className:"w-3 h-3 animate-spin"})]}),a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:[a.jsxs("button",{type:"button",onClick:()=>b(null),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${v==null?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[a.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:a.jsx(xs,{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:"All Plates"}),a.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[S.length," plate",S.length!==1?"s":""]})]}),v==null&&a.jsx(Wi,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]}),S.map(E=>a.jsxs("button",{type:"button",onClick:()=>b(E.index),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${v===E.index?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray"}`,children:[E.has_thumbnail&&E.thumbnail_url?a.jsx("img",{src:E.thumbnail_url,alt:`Plate ${E.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(xs,{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:E.name||`Plate ${E.index}`}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:E.objects.length>0?E.objects.slice(0,2).join(", ")+(E.objects.length>2?"…":""):`${E.filaments.length} filament${E.filaments.length!==1?"s":""}`})]}),v===E.index&&a.jsx(Wi,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},E.index))]}),T&&a.jsxs("div",{className:"mt-3 text-xs text-bambu-gray flex flex-wrap gap-x-4 gap-y-1",children:[a.jsxs("span",{children:["Plate ",T.index]}),T.print_time_seconds!=null&&a.jsxs("span",{children:["ETA ",Math.round(T.print_time_seconds/60)," min"]}),T.filament_used_grams!=null&&a.jsxs("span",{children:[T.filament_used_grams.toFixed(1)," g"]}),T.filaments.length>0&&a.jsxs("span",{children:[T.filaments.length," filament",T.filaments.length!==1?"s":""]})]})]}),a.jsx("div",{className:"flex-1",children:a.jsx(jK,{url:s?oe.getLibraryFileDownloadUrl(e):c.has_source?oe.getSource3mfDownloadUrl(t):oe.getArchiveDownload(t),fileType:r,buildVolume:c.build_volume,filamentColors:c.filament_colors,selectedPlateId:v,className:"w-full h-full"})})]}):o==="gcode"&&c?a.jsx(fX,{gcodeUrl:s?oe.getLibraryFileGcodeUrl(e):oe.getArchiveGcode(t),filamentColors:c.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 O7={"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 E8e(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 h=n/255,p=r/255,m=i/255;s===h?c=((p-m)/d+(p<m?6:0))/6:s===p?c=((m-h)/d+2)/6:c=((h-p)/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 lx(t){const e=t.replace("#","").toLowerCase().substring(0,6);return O7[e]?O7[e]:E8e(t)}function lN(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function Sa(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function Ph(t,e,n=40){const r=Sa(t),i=Sa(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 Eee(t,e,n,r){const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function Tee(t,e,n){return t*4+e}function T8e(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 L7(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return new Date(t).getTime()>e}function xL(t){const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const s=lN(i.tray_color);e.push({type:i.tray_type,color:s,colorName:lx(s),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:Eee(n.id,i.id,r),globalTrayId:Tee(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=lN(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:lx(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e}function F7(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=xL(e);if(n.length===0)return;const r=new Set,i=t.filaments.map(l=>{const c=n.find(p=>!r.has(p.globalTrayId)&&p.type?.toUpperCase()===l.type?.toUpperCase()&&Sa(p.color)===Sa(l.color)),u=!c&&n.find(p=>!r.has(p.globalTrayId)&&p.type?.toUpperCase()===l.type?.toUpperCase()&&Ph(p.color,l.color)),d=!c&&!u&&n.find(p=>!r.has(p.globalTrayId)&&p.type?.toUpperCase()===l.type?.toUpperCase()),h=c||u||d||void 0;return h&&r.add(h.globalTrayId),{slot_id:l.slot_id,globalTrayId:h?.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 A8e(t){return _.useMemo(()=>{const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const s=lN(i.tray_color);e.push({type:i.tray_type,color:s,colorName:lx(s),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:Eee(n.id,i.id,r),globalTrayId:Tee(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=lN(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:lx(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e},[t])}function Aee(t,e,n){const r=A8e(e),i=_.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 N=n[d],T=r.find(k=>k.globalTrayId===N);if(T){const k=T.type?.toUpperCase()===u.type?.toUpperCase(),C=Sa(T.color)===Sa(u.color)||Ph(T.color,u.color);let E;return k&&C?E="match":k?E="type_only":E="mismatch",{...u,loaded:T,hasFilament:!0,typeMatch:k,colorMatch:C,status:E,isManual:!0}}}const h=r.find(N=>!c.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()&&Sa(N.color)===Sa(u.color)),p=!h&&r.find(N=>!c.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()&&Ph(N.color,u.color)),m=!h&&!p&&r.find(N=>!c.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()),x=h||p||m||void 0;x&&c.add(x.globalTrayId);const y=!!x,v=y,b=!!h||!!p;let S;return h||p?S="match":m?S="type_only":S="mismatch",{...u,loaded:x,hasFilament:y,typeMatch:v,colorMatch:b,status:S,isManual:!1}})},[t,r,n]),s=_.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 C8e(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],v=e.find(b=>b.globalTrayId===y);if(v){const b=v.type?.toUpperCase()===u.type?.toUpperCase(),S=Sa(v.color)===Sa(u.color)||Ph(v.color,u.color);b&&S?r++:b?i++:s++;continue}}const h=e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()&&Sa(y.color)===Sa(u.color)),p=h?void 0:e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()&&Ph(y.color,u.color)),m=h||p?void 0:e.find(y=>!o.has(y.globalTrayId)&&y.type?.toUpperCase()===u.type?.toUpperCase()),x=h??p??m;x&&o.add(x.globalTrayId),h||p?r++:m?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 j8e(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=xL(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()&&Sa(x.color)===Sa(c.color)),h=d?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()&&Ph(x.color,c.color)),p=d||h?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()),m=d??h??p;m&&i.add(m.globalTrayId),s.push({slot_id:u,globalTrayId:m?.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 I7={useDefault:!0,manualMappings:{},autoConfigured:!1};function P8e(t,e,n,r,i,s){const o=vW({queries:t.map(x=>({queryKey:["printer-status",x],queryFn:()=>oe.getPrinterStatus(x),enabled:t.length>0,staleTime:5e3}))}),l=_.useMemo(()=>t.map((x,y)=>{const v=o[y],b=v?.data,N=e?.find(D=>D.id===x)?.name||`Printer ${x}`,T=xL(b),k=i[x]||I7,C=F7(n,b),E=k.useDefault?r:k.manualMappings,P=j8e(n,b,E),A=C8e(n?.filaments,T,E);return{printerId:x,printerName:N,status:b,isLoading:v?.isLoading??!1,loadedFilaments:T,autoMapping:C,finalMapping:P,matchStatus:A.status,exactMatches:A.exactMatches,typeOnlyMatches:A.typeOnlyMatches,missingTypes:A.missingTypes,totalSlots:A.totalSlots,config:k}}),[t,o,e,n,i,r]),c=o.some(x=>x.isLoading),u=(x,y)=>{s(v=>({...v,[x]:{...v[x]||I7,...y}}))},d=x=>{const y=l.find(S=>S.printerId===x);if(!y||!y.status||!n?.filaments)return;const v=F7(n,y.status);if(!v)return;const b={};v.forEach((S,N)=>{S!==-1&&(b[N+1]=S)}),u(x,{useDefault:!1,manualMappings:b,autoConfigured:!0})},h=()=>{for(const x of t)d(x)},p=x=>l.find(v=>v.printerId===x)?.finalMapping,m=l.every(x=>x.matchStatus!=="missing");return{printerResults:l,isLoading:c,perPrinterConfigs:i,updatePrinterConfig:u,autoConfigureAll:h,autoConfigurePrinter:d,getFinalMapping:p,allPrintersReady:m}}function D8e({printerResult:t,filamentReqs:e,onUpdateConfig:n}){const r=sn(),[i,s]=_.useState(!1),o=(u,d)=>{if(u<=0)return;const h={...t.config.manualMappings};d===""?delete h[u]:h[u]=parseInt(d,10),n({useDefault:!1,manualMappings:h,autoConfigured:!1})},l=async()=>{s(!0);try{await oe.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,h=t.config.manualMappings[d];let p,m=!1;if(h!==void 0)p=t.loadedFilaments.find(y=>y.globalTrayId===h),m=!0;else{const y=new Set(Object.values(t.config.manualMappings)),v=t.loadedFilaments.find(N=>!y.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()&&Sa(N.color)===Sa(u.color)),b=v?void 0:t.loadedFilaments.find(N=>!y.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase()&&Ph(N.color,u.color)),S=v||b?void 0:t.loadedFilaments.find(N=>!y.has(N.globalTrayId)&&N.type?.toUpperCase()===u.type?.toUpperCase());p=v??b??S}let x="mismatch";if(p){const y=p.type?.toUpperCase()===u.type?.toUpperCase(),v=Sa(p.color)===Sa(u.color)||Ph(p.color,u.color);y&&v?x="match":y&&(x="type_only")}return{req:u,loaded:p,status:x,isManual:m}});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(Dr,{className:`w-3 h-3 ${i?"animate-spin":""}`}),a.jsx("span",{children:"Re-read"})]})]}),c.map(({req:u,loaded:d,status:h,isManual:p},m)=>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} - ${lx(u.color)}`,children:a.jsx(hP,{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 ${h==="match"?"border-bambu-green/50 text-bambu-green":h==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${p?"ring-1 ring-blue-400/50":""}`,title:p?"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))]}),h==="match"?a.jsx(Wi,{className:"w-3 h-3 text-bambu-green"}):h==="type_only"?a.jsx("span",{title:"Same type, different color",children:a.jsx(Sn,{className:"w-3 h-3 text-yellow-400"})}):a.jsx("span",{title:"Filament type not loaded",children:a.jsx(Sn,{className:"w-3 h-3 text-orange-400"})})]},m))]})}function R8e({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:h,targetModel:p,onTargetModelChange:m,targetLocation:x,onTargetLocationChange:y,slicedForModel:v}){const[b,S]=_.useState(!1),N=s?t:t.filter(z=>z.is_active),T=_.useMemo(()=>{if(d!=="printer"||!v||b)return N;const z=N.filter(X=>X.model===v);return z.length>0?z:N},[N,d,v,b]),k=N.length-T.length,C=_.useMemo(()=>{const z=N.map(X=>X.model).filter(X=>!!X);return[...new Set(z)].sort()},[N]),E=_.useMemo(()=>{if(!p)return[];const z=N.filter(X=>X.model===p&&X.location).map(X=>X.location).filter(X=>!!X);return[...new Set(z)].sort()},[N,p]),P=h&&m&&C.length>0,A=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(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(T.length===0)return a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm mb-4",children:[a.jsx(Vi,{className:"w-4 h-4"}),"No ",s?"":"active ","printers available"]});const D=z=>{i?e.includes(z)?n(e.filter(X=>X!==z)):n([...e,z]):n([z])},I=()=>{n(T.map(z=>z.id))},L=()=>{n([])},U=(z,X,Y)=>{Y.stopPropagation(),!(!c||!u)&&(X?c(z):u(z,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},j=z=>e.includes(z),V=e.length,K=z=>o?.find(X=>X.printerId===z);return a.jsxs("div",{className:"space-y-2 mb-6",children:[P&&a.jsxs("div",{className:"flex gap-2 mb-4",children:[a.jsxs("button",{type:"button",onClick:()=>{h("printer"),m(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(Ur,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:"Specific Printer"})]}),a.jsxs("button",{type:"button",onClick:()=>{h("model"),n([]);const z=v&&C.includes(v)?v:C[0];m(z)},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(pg,{className:"w-4 h-4"}),a.jsxs("span",{className:"text-sm",children:["Any ",v||"Model"]})]})]}),d==="model"&&P&&a.jsxs("div",{className:"space-y-3 mb-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Target Model"}),a.jsxs("select",{value:p||"",onChange:z=>{m(z.target.value||null),y&&y(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 text-sm",children:[a.jsx("option",{value:"",children:"Select a model..."}),C.map(z=>a.jsx("option",{value:z,children:z},z))]})]}),p&&E.length>0&&y&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Location Filter (optional)"}),a.jsxs("select",{value:x||"",onChange:z=>y(z.target.value||null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm",children:[a.jsx("option",{value:"",children:"Any location"}),E.map(z=>a.jsx("option",{value:z,children:z},z))]})]}),p&&a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Scheduler will assign to first available idle ",p," printer",x?` in ${x}`:""]})]}),d==="printer"&&i&&T.length>1&&a.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray mb-2",children:[a.jsx("span",{children:V===0?"Select printers":`${V} printer${V!==1?"s":""} selected`}),a.jsxs("div",{className:"flex gap-2",children:[V<T.length&&a.jsx("button",{type:"button",onClick:I,className:"text-bambu-green hover:text-bambu-green/80 transition-colors",children:"Select all"}),V>0&&a.jsx("button",{type:"button",onClick:L,className:"text-bambu-gray hover:text-white transition-colors",children:"Clear"})]})]}),d==="printer"&&T.map(z=>{const X=j(z.id),Y=K(z.id),te=Y&&!Y.config.useDefault;return a.jsxs("div",{children:[a.jsxs("button",{type:"button",onClick:()=>D(z.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${X?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"} ${z.is_active?"":"opacity-60"}`,children:[a.jsx("div",{className:`p-2 rounded-lg ${X?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:a.jsx(Ur,{className:`w-5 h-5 ${X?"text-bambu-green":"text-bambu-gray"}`})}),a.jsxs("div",{className:"text-left flex-1",children:[a.jsxs("p",{className:"text-white font-medium",children:[z.name,!z.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:[z.model||"Unknown model"," • ",z.ip_address]})]}),i&&a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${X?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:X&&a.jsx(Wi,{className:"w-3 h-3 text-white"})})]}),X&&A&&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:$=>$.stopPropagation(),children:[a.jsx("input",{type:"checkbox",checked:te,onChange:$=>U(z.id,$.target.checked,$),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(Dr,{className:"w-3 h-3 text-bambu-gray animate-spin"}),te&&a.jsxs("button",{type:"button",onClick:$=>{$.stopPropagation(),c(z.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(Nfe,{className:"w-3 h-3"}),"Auto"]})]}),te&&a.jsx(D8e,{printerResult:Y,filamentReqs:l.filaments,onUpdateConfig:$=>u(z.id,$)})]})]},z.id)}),d==="printer"&&k>0&&!b&&a.jsxs("button",{type:"button",onClick:()=>S(!0),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2 flex items-center gap-1",children:[a.jsx(Sn,{className:"w-3 h-3 text-yellow-400"}),k," other printer",k>1?"s":""," hidden (different model) —",a.jsx("span",{className:"underline",children:"show all"})]}),d==="printer"&&b&&v&&a.jsx("button",{type:"button",onClick:()=>S(!1),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2",children:a.jsxs("span",{className:"underline",children:["Show only ",v," printers"]})}),d==="printer"&&V===0&&a.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[a.jsx(Vi,{className:"w-3 h-3"}),"Select at least one printer"]}),d==="model"&&!p&&a.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[a.jsx(Vi,{className:"w-3 h-3"}),"Select a target printer model"]})]})}function O8e({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(xs,{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(Sn,{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(xs,{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?` • ${T8e(i.print_time_seconds)}`:""]})]}),n===i.index&&a.jsx(Wi,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function L8e({printerId:t,filamentReqs:e,manualMappings:n,onManualMappingChange:r,defaultExpanded:i=!1}){const s=sn(),[o,l]=_.useState(!1),[c,u]=_.useState(i),{data:d}=ct({queryKey:["printer-status",t],queryFn:()=>oe.getPrinterStatus(t),enabled:!!t}),{loadedFilaments:h,filamentComparison:p,hasTypeMismatch:m,hasColorMismatch:x}=Aee(e,d,n);if(!(e?.filaments&&e.filaments.length>0)||!d)return null;const v=m?"#f97316":x?"#facc15":"#00ae42",b=(N,T)=>{if(N>0)if(T===""){const k={...n};delete k[N],r(k)}else r({...n,[N]:parseInt(T,10)})},S=async()=>{l(!0);try{await oe.refreshPrinterStatus(t),await new Promise(N=>setTimeout(N,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(hP,{className:"w-4 h-4",fill:v,stroke:"none"}),a.jsx("span",{children:"Filament Mapping"}),m?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(yh,{className:"w-4 h-4 ml-auto"}):a.jsx(Kr,{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:S,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(Dr,{className:`w-3 h-3 ${o?"animate-spin":""}`}),a.jsx("span",{children:"Re-read"})]})]}),p.map((N,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: ${N.type} - ${lx(N.color)}`,children:a.jsx(hP,{className:"w-3 h-3",fill:N.color,stroke:N.color})}),a.jsxs("span",{className:"text-white truncate",children:[N.type," ",a.jsxs("span",{className:"text-bambu-gray",children:["(",N.used_grams,"g)"]})]}),a.jsx("span",{className:"text-bambu-gray",children:"→"}),a.jsxs("select",{value:N.loaded?.globalTrayId??"",onChange:k=>b(N.slot_id||0,k.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 ${N.status==="match"?"border-bambu-green/50 text-bambu-green":N.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${N.isManual?"ring-1 ring-blue-400/50":""}`,title:N.isManual?"Manually selected":"Auto-matched",children:[a.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),h.map(k=>a.jsxs("option",{value:k.globalTrayId,className:"bg-bambu-dark text-white",children:[k.label,": ",k.type," (",k.colorName,")"]},k.globalTrayId))]}),N.status==="match"?a.jsx(Wi,{className:"w-3 h-3 text-bambu-green"}):N.status==="type_only"?a.jsx("span",{title:"Same type, different color",children:a.jsx(Sn,{className:"w-3 h-3 text-yellow-400"})}):a.jsx("span",{title:"Filament type not loaded",children:a.jsx(Sn,{className:"w-3 h-3 text-orange-400"})})]},T)),m&&a.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]})]})}const F8e=[{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 I8e({options:t,onChange:e,defaultExpanded:n=!1}){const[r,i]=_.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(bM,{className:"w-4 h-4"}),a.jsx("span",{children:"Print Options"}),r?a.jsx(yh,{className:"w-4 h-4 ml-auto"}):a.jsx(Kr,{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:F8e.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 U8e({options:t,onChange:e,dateFormat:n="system",timeFormat:r="system"}){const[i,s]=_.useState(""),[o,l]=_.useState(""),[c,u]=_.useState(!0),[d,h]=_.useState(!0),p=_.useRef(null),m=_.useRef(!1);_.useEffect(()=>{if(t.scheduleType!=="scheduled"){m.current=!1;return}if(!m.current){m.current=!0;let T;t.scheduledTime?(T=new Date(t.scheduledTime),isNaN(T.getTime())&&(T=new Date,T.setHours(T.getHours()+1,0,0,0))):(T=new Date,T.setHours(T.getHours()+1,0,0,0),e({...t,scheduledTime:qz(T)})),s(Vz(T,n)),l(Gz(T,r)),u(!0),h(!0)}},[t.scheduleType,t.scheduledTime,n,r,e,t]);const x=T=>{e({...t,scheduleType:T})},y=(T,k)=>{const C=Kfe(T,n),E=Xfe(k);u(!!C),h(!!E),C&&E&&(C.setHours(E.hours,E.minutes,0,0),C>new Date&&e({...t,scheduledTime:qz(C)}))},v=T=>{s(T),y(T,o)},b=T=>{l(T),y(i,T)},S=T=>{const k=T.target.value;if(k){const C=new Date(k);isNaN(C.getTime())||(s(Vz(C,n)),l(Gz(C,r)),u(!0),h(!0),e({...t,scheduledTime:k}))}},N=()=>{p.current?.showPicker()};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:()=>x("asap"),children:[a.jsx(tr,{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:()=>x("scheduled"),children:[a.jsx(ti,{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:()=>x("manual"),children:[a.jsx(EW,{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.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"flex-1 relative",children:[a.jsx("input",{type:"text",className:`w-full px-3 py-2 pr-10 bg-bambu-dark border rounded-lg text-white focus:outline-none ${c?"border-bambu-dark-tertiary focus:border-bambu-green":"border-red-500"}`,value:i,onChange:T=>v(T.target.value),placeholder:qfe(n)}),a.jsx("button",{type:"button",onClick:N,className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",title:"Open calendar",children:a.jsx(ti,{className:"w-4 h-4"})})]}),a.jsx("div",{className:"w-32",children:a.jsx("input",{type:"text",className:`w-full px-3 py-2 bg-bambu-dark border rounded-lg text-white focus:outline-none ${d?"border-bambu-dark-tertiary focus:border-bambu-green":"border-red-500"}`,value:o,onChange:T=>b(T.target.value),placeholder:Wfe(r)})})]}),a.jsx("input",{ref:p,type:"datetime-local",className:"sr-only",value:t.scheduledTime,onChange:S,tabIndex:-1}),(!c||!d)&&a.jsx("p",{className:"mt-1 text-xs text-red-400",children:"Please enter a valid date and time"})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"requirePrevious",checked:t.requirePreviousSuccess,onChange:T=>e({...t,requirePreviousSuccess:T.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:T=>e({...t,autoOffAfter:T.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(qu,{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 eg={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},z8e={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function Dh({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:s,onSuccess:o}){const{t:l}=On(),c=sn(),{showToast:u}=Hn(),d=!!n&&!e,[h,p]=_.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[m,x]=_.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[y,v]=_.useState(()=>t==="edit-queue-item"&&i?{bed_levelling:i.bed_levelling??eg.bed_levelling,flow_cali:i.flow_cali??eg.flow_cali,vibration_cali:i.vibration_cali??eg.vibration_cali,layer_inspect:i.layer_inspect??eg.layer_inspect,timelapse:i.timelapse??eg.timelapse}:eg),[b,S]=_.useState(()=>{if(t==="edit-queue-item"&&i){let Ve="asap";i.manual_start?Ve="manual":i.scheduled_time&&!L7(i.scheduled_time)&&(Ve="scheduled");let He="";return i.scheduled_time&&!L7(i.scheduled_time)&&(He=new Date(i.scheduled_time).toISOString().slice(0,16)),{scheduleType:Ve,scheduledTime:He,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return z8e}),[N,T]=_.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const Ve={};return i.ams_mapping.forEach((He,be)=>{He!==-1&&(Ve[be+1]=He)}),Ve}return{}}),[k,C]=_.useState({}),[E,P]=_.useState(()=>t==="edit-queue-item"&&i?.target_model?"model":"printer"),[A,D]=_.useState(()=>t==="edit-queue-item"&&i?.target_model?i.target_model:null),[I,L]=_.useState(()=>t==="edit-queue-item"&&i?.target_location?i.target_location:null),[U]=_.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[j]=_.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[V,K]=_.useState(!1),[z,X]=_.useState({current:0,total:0}),[Y,te]=_.useState(new Set),$=h.length,W=h.length>0?h[0]:null,{data:ne}=ct({queryKey:["settings"],queryFn:oe.getSettings}),{data:re,isLoading:ge}=ct({queryKey:["printers"],queryFn:oe.getPrinters}),{data:me}=ct({queryKey:["archive",e],queryFn:()=>oe.getArchive(e),enabled:!!e&&!d}),ue=me?.sliced_for_model||null,{data:Te,isError:ie}=ct({queryKey:["archive-plates",e],queryFn:()=>oe.getArchivePlates(e),enabled:!!e&&!d,retry:!1}),{data:Ce}=ct({queryKey:["library-file-plates",n],queryFn:()=>oe.getLibraryFilePlates(n),enabled:d&&!!n}),Fe=d?Ce:Te,{data:xe,isError:Ze}=ct({queryKey:["archive-filaments",e,m],queryFn:()=>oe.getArchiveFilamentRequirements(e,m??void 0),enabled:!!e&&!d&&(m!==null||!Fe?.is_multi_plate),retry:!1}),{data:G}=ct({queryKey:["library-file-filaments",n,m],queryFn:()=>oe.getLibraryFileFilamentRequirements(n,m??void 0),enabled:d&&!!n&&(m!==null||!Fe?.is_multi_plate)}),Q=!d&&(ie||Ze),de=d?G:xe,{data:q}=ct({queryKey:["printer-status",W],queryFn:()=>oe.getPrinterStatus(W),enabled:!!W}),{amsMapping:ee}=Aee(de,q,N),B=P8e(h,re,de,N,k,C);_.useEffect(()=>{Fe?.plates?.length===1&&!m&&x(Fe.plates[0].index)},[Fe,m]),_.useEffect(()=>{if(t==="edit-queue-item")return;const Ve=re?.filter(He=>He.is_active)||[];Ve.length===1&&h.length===0&&p([Ve[0].id])},[t,re,h.length]),_.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(h.sort())!==JSON.stringify(U.sort())||m!==j)&&(T({}),C({}),te(new Set)):(T({}),C({}),te(new Set))},[t,h,m,U,j]),_.useEffect(()=>{if(!ne?.per_printer_mapping_expanded||h.length<=1)return;const Ve=h.filter(He=>{if(Y.has(He))return!1;const be=B.printerResults.find(Pe=>Pe.printerId===He);return be&&be.status&&!be.isLoading});Ve.length>0&&(te(He=>{const be=new Set(He);return Ve.forEach(Pe=>be.add(Pe)),be}),Ve.forEach(He=>{B.autoConfigurePrinter(He)}))},[ne?.per_printer_mapping_expanded,h,Y,B]),_.useEffect(()=>{const Ve=He=>{He.key==="Escape"&&!V&&s()};return window.addEventListener("keydown",Ve),()=>window.removeEventListener("keydown",Ve)},[s,V]);const he=Fe?.is_multi_plate??!1,ke=Fe?.plates??[],pe=gt({mutationFn:Ve=>oe.addToQueue(Ve)}),H=gt({mutationFn:Ve=>oe.updateQueueItem(i.id,Ve),onSuccess:()=>{c.invalidateQueries({queryKey:["queue"]}),u("Queue item updated"),o?.(),s()},onError:Ve=>{u(Ve.message||"Failed to update queue item","error")}}),O=async Ve=>{if(Ve?.preventDefault(),E==="printer"&&h.length===0){u("Please select at least one printer","error");return}if(E==="model"&&!A){u("Please select a target printer model","error");return}K(!0);const He=E==="model"?1:h.length;X({current:0,total:He});const be={success:0,failed:0,errors:[]},Pe=_e=>{if(h.length>1){const Ke=k[_e];if(Ke&&!Ke.useDefault)return B.getFinalMapping(_e)}return ee},Ie=_e=>({printer_id:E==="printer"?_e:null,target_model:E==="model"?A:null,target_location:E==="model"?I:null,archive_id:d?void 0:e,library_file_id:d?n:void 0,require_previous_success:b.requirePreviousSuccess,auto_off_after:b.autoOffAfter,manual_start:b.scheduleType==="manual",ams_mapping:_e?Pe(_e):void 0,plate_id:m,scheduled_time:b.scheduleType==="scheduled"&&b.scheduledTime?new Date(b.scheduledTime).toISOString():void 0,...y});if(E==="model"){X({current:1,total:1});try{if(t==="reprint"){u("Model-based assignment only works with queue mode","error"),K(!1);return}else if(t==="edit-queue-item"){const _e={printer_id:null,target_model:A,target_location:I,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,...y};await H.mutateAsync(_e)}else await pe.mutateAsync(Ie(null));be.success++}catch(_e){be.failed++,be.errors.push(_e.message)}}else for(let _e=0;_e<h.length;_e++){const Ke=h[_e];X({current:_e+1,total:h.length});try{if(t==="reprint"){const Me=Pe(Ke);d?await oe.printLibraryFile(n,Ke,{ams_mapping:Me,...y}):await oe.reprintArchive(e,Ke,{plate_id:m??void 0,ams_mapping:Me,...y})}else if(t==="edit-queue-item"&&_e===0){const Me=Pe(Ke),it={printer_id:Ke,target_model:null,target_location:null,require_previous_success:b.requirePreviousSuccess,auto_off_after:b.autoOffAfter,manual_start:b.scheduleType==="manual",ams_mapping:Me,plate_id:m,scheduled_time:b.scheduleType==="scheduled"&&b.scheduledTime?new Date(b.scheduledTime).toISOString():null,...y};await H.mutateAsync(it)}else await pe.mutateAsync(Ie(Ke));be.success++}catch(Me){be.failed++;const it=re?.find(Ee=>Ee.id===Ke)?.name||`Printer ${Ke}`;be.errors.push(`${it}: ${Me.message}`)}}if(K(!1),be.failed===0){if(E==="model")u(t==="edit-queue-item"?"Queue item updated":`Queued for any ${A}`);else{const _e=t==="reprint"?"sent to":t==="edit-queue-item"?"updated/queued for":"queued for";be.success===1?u(t==="edit-queue-item"?"Queue item updated":`Print ${_e} printer`):u(`Print ${_e} ${be.success} printers`)}c.invalidateQueries({queryKey:["queue"]}),o?.(),s()}else be.success===0?u(`Failed: ${be.errors[0]}`,"error"):(u(`${be.success} succeeded, ${be.failed} failed`,"error"),c.invalidateQueries({queryKey:["queue"]}))},J=V||H.isPending,le=_.useMemo(()=>!(J||E==="printer"&&h.length===0||E==="model"&&!A||E==="model"&&t==="reprint"||!d&&he&&!m),[h.length,E,A,t,he,m,J,d]),we=(()=>{const Ve=h.length;return t==="reprint"?{title:l(d?"queue.print":"queue.reprint"),icon:Ur,submitText:Ve>1?l("queue.printToPrinters",{count:Ve}):l("queue.print"),submitIcon:Ur,loadingText:z.total>1?l("queue.sendingProgress",{current:z.current,total:z.total}):l("queue.sending")}:t==="add-to-queue"?{title:l("queue.schedulePrint"),icon:ti,submitText:Ve>1?l("queue.queueToPrinters",{count:Ve}):l("queue.addToQueue"),submitIcon:ti,loadingText:z.total>1?l("queue.addingProgress",{current:z.current,total:z.total}):l("queue.adding")}:{title:l("queue.editQueueItem"),icon:ea,submitText:l("common.save"),submitIcon:ea,loadingText:z.total>1?l("queue.savingProgress",{current:z.current,total:z.total}):l("common.saving")}})(),ae=we.icon,Le=we.submitIcon,Be=W&&(d||(he?m!==null:!0));return a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:V?void 0:s,children:a.jsx(St,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:Ve=>Ve.stopPropagation(),children:a.jsxs(Nt,{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(ae,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:we.title})]}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:s,disabled:V,children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:O,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(O8e,{plates:ke,isMultiPlate:he,selectedPlate:m,onSelect:x}),a.jsx(R8e,{printers:re||[],selectedPrinterIds:h,onMultiSelect:p,isLoading:ge,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:B.printerResults,filamentReqs:de,onAutoConfigurePrinter:B.autoConfigurePrinter,onUpdatePrinterConfig:B.updatePrinterConfig,assignmentMode:t==="reprint"?"printer":E,onAssignmentModeChange:t!=="reprint"?P:void 0,targetModel:A,onTargetModelChange:t!=="reprint"?D:void 0,targetLocation:I,onTargetLocationChange:t!=="reprint"?L:void 0,slicedForModel:ue}),ue&&E==="printer"&&h.length===1&&(()=>{const Ve=re?.find(He=>He.id===h[0]);return Ve&&Ve.model&&ue!==Ve.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(Sn,{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 ",ue,", but printing on ",Ve.model]})]}):null})(),Q&&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(Vi,{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."})]}),Be&&!Q&&h.length===1&&a.jsx(L8e,{printerId:W,filamentReqs:de,manualMappings:N,onManualMappingChange:T,defaultExpanded:ne?.per_printer_mapping_expanded??!1}),(t==="reprint"||$>0||E==="model"&&A)&&a.jsx(I8e,{options:y,onChange:v}),t!=="reprint"&&a.jsx(U8e,{options:b,onChange:S,dateFormat:ne?.date_format||"system",timeFormat:ne?.time_format||"system"}),H.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:H.error?.message||"Failed to complete operation"}),a.jsxs("div",{className:`flex gap-3 ${t==="reprint"?"":"pt-2"}`,children:[a.jsx(Ae,{type:"button",variant:"secondary",onClick:s,className:"flex-1",disabled:V,children:"Cancel"}),a.jsx(Ae,{type:"submit",disabled:!le,className:"flex-1",children:J?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 animate-spin"}),we.loadingText]}):a.jsxs(a.Fragment,{children:[a.jsx(Le,{className:"w-4 h-4"}),we.submitText]})})]})]})]})})})}function B8e({onClose:t,initialFiles:e}){const{t:n}=On(),r=sn(),{showToast:i}=Hn(),s=_.useRef(null),[o,l]=_.useState(()=>e?.filter(k=>k.name.endsWith(".3mf")).map(k=>({file:k,status:"pending"}))||[]),[c,u]=_.useState(!1),[d,h]=_.useState(null);_.useEffect(()=>{const k=C=>{C.key==="Escape"&&t()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[t]);const p=gt({mutationFn:k=>oe.uploadArchivesBulk(k),onSuccess:k=>{h(k),r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["archiveStats"]}),l(C=>C.map(E=>{const P=k.results.find(D=>D.filename===E.file.name),A=k.errors.find(D=>D.filename===E.file.name);return P?{...E,status:"success",archiveId:P.id}:A?{...E,status:"error",error:A.error}:E})),k.failed===0?i(`${k.uploaded} file${k.uploaded!==1?"s":""} uploaded`):k.uploaded===0?i(`Failed to upload ${k.failed} file${k.failed!==1?"s":""}`,"error"):i(`${k.uploaded} uploaded, ${k.failed} failed`,"warning")},onError:()=>{l(k=>k.map(C=>({...C,status:"error",error:"Upload failed"}))),i("Upload failed","error")}}),m=_.useCallback(k=>{k.preventDefault(),u(!0)},[]),x=_.useCallback(k=>{k.preventDefault(),u(!1)},[]),y=_.useCallback(k=>{k.preventDefault(),u(!1);const C=Array.from(k.dataTransfer.files).filter(E=>E.name.endsWith(".3mf"));C.length>0&&l(E=>[...E,...C.map(P=>({file:P,status:"pending"}))])},[]),v=_.useCallback(k=>{const C=Array.from(k.target.files||[]).filter(E=>E.name.endsWith(".3mf"));C.length>0&&l(E=>[...E,...C.map(P=>({file:P,status:"pending"}))]),s.current&&(s.current.value="")},[]),b=_.useCallback(k=>{l(C=>C.filter((E,P)=>P!==k))},[]),S=()=>{if(o.length===0)return;const k=o.filter(C=>C.status==="pending");k.length!==0&&(l(C=>C.map(E=>E.status==="pending"?{...E,status:"uploading"}:E)),p.mutate(k.map(C=>C.file)))},N=o.filter(k=>k.status==="pending").length,T=p.isPending;return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(St,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:a.jsxs(Nt,{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:n("uploadModal.title")}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{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 ${c?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,onDragOver:m,onDragLeave:x,onDrop:y,children:[a.jsx(Ba,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),a.jsx("p",{className:"text-white mb-2",children:n("uploadModal.dragDrop")}),a.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:n("uploadModal.or")}),a.jsx(Ae,{variant:"secondary",onClick:()=>s.current?.click(),disabled:T,children:n("uploadModal.browseFiles")}),a.jsx("input",{ref:s,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:v})]})}),a.jsx("div",{className:"px-4 pb-4",children:a.jsx("p",{className:"text-xs text-bambu-gray",children:n("uploadModal.extractionInfo")})}),o.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:o.map((k,C)=>a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx(dM,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"flex-1 text-white text-sm truncate",children:k.file.name}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[(k.file.size/(1024*1024)).toFixed(1)," MB"]}),k.status==="pending"&&a.jsx("button",{onClick:()=>b(C),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:T,children:a.jsx(Lt,{className:"w-4 h-4"})}),k.status==="uploading"&&a.jsx(pt,{className:"w-4 h-4 text-bambu-green animate-spin"}),k.status==="success"&&a.jsx(Ar,{className:"w-4 h-4 text-bambu-green"}),k.status==="error"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-red-400",children:k.error}),a.jsx(Vi,{className:"w-4 h-4 text-red-400"})]})]},`${k.file.name}-${C}`))})}),d&&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:d.uploaded})," ",n("uploadModal.uploaded"),d.failed>0&&a.jsxs(a.Fragment,{children:[", ",a.jsx("span",{className:"text-red-400",children:d.failed})," ",n("uploadModal.failed")]})]})})}),a.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Ae,{variant:"secondary",onClick:t,className:"flex-1",children:n(d?"common.close":"common.cancel")}),!d&&a.jsx(Ae,{onClick:S,disabled:N===0||T,className:"flex-1",children:T?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 animate-spin"}),n("uploadModal.uploading")]}):a.jsxs(a.Fragment,{children:[a.jsx(Ba,{className:"w-4 h-4"}),n("uploadModal.upload")," ",N>0&&`(${N})`]})})]})]})})})}const H8e=["adhesionFailure","spaghettiDetached","layerShift","cloggedNozzle","filamentRunout","warping","stringing","underExtrusion","powerFailure","userCancelled","other"],$8e=["completed","failed","aborted","printing"];function Cee({archive:t,onClose:e,existingTags:n=[]}){const{t:r}=On();_.useEffect(()=>{const ie=Ce=>{Ce.key==="Escape"&&e()};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[e]);const i=sn(),[s,o]=_.useState(t.print_name||""),[l,c]=_.useState(t.printer_id),[u,d]=_.useState(t.project_id??null),[h,p]=_.useState(t.notes||""),[m,x]=_.useState(t.tags||""),[y,v]=_.useState(t.failure_reason||""),[b,S]=_.useState(t.status),[N,T]=_.useState(t.quantity??1),[k,C]=_.useState(t.photos||[]),[E,P]=_.useState(t.external_url||""),[A,D]=_.useState(!1),[I,L]=_.useState(!1),U=_.useRef(null),j=_.useRef(null),V=_.useRef(null),{data:K}=ct({queryKey:["printers"],queryFn:oe.getPrinters}),{data:z}=ct({queryKey:["projects"],queryFn:()=>oe.getProjects()}),{data:X}=ct({queryKey:["tags"],queryFn:oe.getTags,enabled:n.length===0}),Y=n.length>0?n:X?.map(ie=>ie.name)||[],te=m.split(",").map(ie=>ie.trim()).filter(Boolean),$=m.includes(",")?m.substring(m.lastIndexOf(",")+1).trim().toLowerCase():m.trim().toLowerCase(),W=Y.filter(ie=>!te.includes(ie)&&($===""||ie.toLowerCase().includes($))),ne=ie=>{let Ce;if($&&!Y.includes($)?Ce=m.includes(",")?m.substring(0,m.lastIndexOf(",")).split(",").map(Fe=>Fe.trim()).filter(Boolean):[]:Ce=te,!Ce.includes(ie)){const Fe=[...Ce,ie].join(", ");x(Fe)}V.current!==null&&clearTimeout(V.current),U.current?.focus()},re=ie=>{const Ce=te.filter(Fe=>Fe!==ie).join(", ");x(Ce)},ge=gt({mutationFn:ie=>oe.updateArchive(t.id,ie),onSuccess:()=>{i.invalidateQueries({queryKey:["archives"]}),i.invalidateQueries({queryKey:["projects"]}),e()}}),me=async ie=>{const Ce=ie.target.files?.[0];if(Ce){D(!0);try{const Fe=await oe.uploadArchivePhoto(t.id,Ce);C(Fe.photos),i.invalidateQueries({queryKey:["archives"]})}catch(Fe){console.error("Failed to upload photo:",Fe)}finally{D(!1),j.current&&(j.current.value="")}}},ue=async ie=>{try{const Ce=await oe.deleteArchivePhoto(t.id,ie);C(Ce.photos||[]),i.invalidateQueries({queryKey:["archives"]})}catch(Ce){console.error("Failed to delete photo:",Ce)}},Te=ie=>{ie.preventDefault();const Ce={print_name:s||void 0,printer_id:l,project_id:u,notes:h||void 0,tags:m||void 0,quantity:N,external_url:E||null};b!==t.status&&(Ce.status=b),b==="failed"||b==="aborted"?Ce.failure_reason=y||void 0:(t.status==="failed"||t.status==="aborted")&&(Ce.failure_reason=null),ge.mutate(Ce)};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:ie=>ie.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("editArchive.title")}),a.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:Te,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:r("editArchive.name")}),a.jsx("input",{type:"text",value:s,onChange:ie=>o(ie.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:r("editArchive.namePlaceholder")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.printer")}),a.jsxs("select",{value:l??"",onChange:ie=>c(ie.target.value?Number(ie.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:r("editArchive.noPrinter")}),K?.map(ie=>a.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(es,{className:"w-4 h-4 inline mr-1"}),r("editArchive.project")]}),a.jsxs("select",{value:u??"",onChange:ie=>d(ie.target.value?Number(ie.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:r("editArchive.noProject")}),z?.map(ie=>a.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(fde,{className:"w-4 h-4 inline mr-1"}),r("editArchive.itemsPrinted")]}),a.jsx("input",{type:"number",min:1,value:N,onChange:ie=>T(Math.max(1,parseInt(ie.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:r("editArchive.itemsPrintedHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.notes")}),a.jsx("textarea",{value:h,onChange:ie=>p(ie.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:r("editArchive.notesPlaceholder")})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Uy,{className:"w-4 h-4 inline mr-1"}),r("editArchive.externalLink")]}),a.jsx("input",{type:"url",value:E,onChange:ie=>P(ie.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:r("editArchive.externalLinkHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.tags")}),te.length>0&&a.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:te.map(ie=>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(wh,{className:"w-3 h-3"}),ie,a.jsx("button",{type:"button",onClick:()=>re(ie),className:"ml-0.5 text-bambu-gray hover:text-white",children:a.jsx(Lt,{className:"w-3 h-3"})})]},ie))}),a.jsxs("div",{className:"relative",children:[a.jsx("input",{ref:U,type:"text",value:m,onChange:ie=>x(ie.target.value),onFocus:()=>{V.current!==null&&clearTimeout(V.current),L(!0)},onBlur:()=>{V.current=window.setTimeout(()=>L(!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?r("editArchive.addMoreTags"):r("editArchive.tagsPlaceholder")}),I&&W.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:[$?r("editArchive.matchingTags",{query:$}):r("editArchive.existingTags")," ",r("editArchive.clickToAdd")]}),a.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:W.map(ie=>a.jsx("button",{type:"button",onClick:()=>ne(ie),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:ie},ie))})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.status")}),a.jsx("select",{value:b,onChange:ie=>{S(ie.target.value),ie.target.value==="completed"&&v("")},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:$8e.map(ie=>a.jsx("option",{value:ie,children:r(`editArchive.statuses.${ie}`)},ie))})]}),(b==="failed"||b==="aborted")&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.failureReason")}),a.jsxs("select",{value:y,onChange:ie=>v(ie.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:r("editArchive.selectReason")}),H8e.map(ie=>a.jsx("option",{value:r(`editArchive.failureReasons.${ie}`),children:r(`editArchive.failureReasons.${ie}`)},ie))]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(Bg,{className:"w-4 h-4 inline mr-1"}),r("editArchive.photos")]}),a.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[k.map(ie=>a.jsxs("div",{className:"relative group",children:[a.jsx("img",{src:oe.getArchivePhotoUrl(t.id,ie),alt:r("editArchive.printResult"),className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),a.jsx("button",{type:"button",onClick:()=>ue(ie),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx(an,{className:"w-3 h-3 text-white"})})]},ie)),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:j,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:me,className:"hidden",disabled:A}),A?a.jsx(pt,{className:"w-6 h-6 text-bambu-gray animate-spin"}):a.jsx(fr,{className:"w-6 h-6 text-bambu-gray"})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:r("editArchive.photosHelp")})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Ae,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:r("common.cancel")}),a.jsxs(Ae,{type:"submit",disabled:ge.isPending,className:"flex-1",children:[a.jsx(ms,{className:"w-4 h-4"}),ge.isPending?r("common.saving"):r("common.save")]})]})]})]})})}function jee({x:t,y:e,items:n,onClose:r}){const i=_.useRef(null),[s,o]=_.useState(null),l=_.useRef(null),[c,u]=_.useState({x:t,y:e,visible:!1}),[d,h]=_.useState(!1),[p,m]=_.useState({});_.useEffect(()=>{const v=N=>{i.current&&!i.current.contains(N.target)&&r()},b=N=>{N.key==="Escape"&&r()},S=()=>{r()};return document.addEventListener("mousedown",v),document.addEventListener("keydown",b),document.addEventListener("scroll",S,!0),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",b),document.removeEventListener("scroll",S,!0),l.current&&clearTimeout(l.current)}},[r]),_.useLayoutEffect(()=>{if(i.current){i.current.style.visibility="hidden",i.current.style.display="block";const v=i.current.getBoundingClientRect(),b=window.innerWidth,S=window.innerHeight,N=8;let T=t,k=e;t+v.width>b-N&&(T=Math.max(N,b-v.width-N)),T<N&&(T=N),e+v.height>S-N&&(k=Math.max(N,S-v.height-N)),k<N&&(k=N);const C=180,E=b-T-v.width,P=T;h(E<C&&P>C),u({x:T,y:k,visible:!0})}},[t,e]);const x=(v,b)=>{l.current&&(clearTimeout(l.current),l.current=null);const S=b.getBoundingClientRect(),N=window.innerHeight,T=300,E=N-S.top-8<T&&S.top>T;m(P=>({...P,[v]:E?"bottom":"top"})),o(v)},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((v,b)=>{if(v.divider)return a.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},b);const S=v.submenu&&v.submenu.length>0;return a.jsxs("div",{className:"relative",onMouseEnter:N=>S&&x(b,N.currentTarget),onMouseLeave:()=>S&&y(),children:[a.jsxs("button",{onMouseEnter:N=>S&&x(b,N.currentTarget.parentElement),onClick:()=>{S?o(s===b?null:b):v.disabled||(v.onClick(),r())},disabled:v.disabled,title:v.title,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${v.disabled?"text-bambu-gray cursor-not-allowed":v.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"} ${S&&s===b?"bg-bambu-dark-tertiary":""}`,children:[v.icon&&a.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:v.icon}),a.jsx("span",{className:"flex-1",children:v.label}),S&&a.jsx(vs,{className:"w-4 h-4 text-bambu-gray"})]}),S&&s===b&&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"} ${p[b]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>y(),children:v.submenu.map((N,T)=>a.jsxs("button",{onClick:()=>{N.disabled||(N.onClick(),r())},disabled:N.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${N.disabled?"text-bambu-gray cursor-not-allowed":N.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[N.icon&&a.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:N.icon}),N.label]},T))})]},b)})})}function V8e({selectedIds:t,existingTags:e,onClose:n}){const r=sn(),{showToast:i}=Hn(),[s,o]=_.useState(""),[l,c]=_.useState(new Set),[u,d]=_.useState("add");_.useEffect(()=>{const y=v=>{v.key==="Escape"&&n()};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[n]);const h=gt({mutationFn:async()=>{const y=Array.from(l);let v=0;for(const b of t)try{const S=await oe.getArchive(b),N=S.tags?S.tags.split(",").map(k=>k.trim()).filter(Boolean):[];let T;u==="add"?T=[...new Set([...N,...y])]:T=N.filter(k=>!l.has(k)),await oe.updateArchive(b,{tags:T.join(", ")}),v++}catch(S){throw console.error(`Failed to update archive ${b}:`,S),new Error(`Failed on archive ${b}: ${S instanceof Error?S.message:"Unknown error"}`)}return{count:v,mode:u,tags:y}},onSuccess:({count:y,mode:v,tags:b})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${v==="add"?"Added":"Removed"} ${b.length} tag${b.length!==1?"s":""} ${v==="add"?"to":"from"} ${y} archive${y!==1?"s":""}`),n()},onError:y=>{i(y.message||"Failed to update tags","error")}}),p=y=>{c(v=>{const b=new Set(v);return b.has(y)?b.delete(y):b.add(y),b})},m=()=>{s.trim()&&!l.has(s.trim())&&(c(y=>new Set([...y,s.trim()])),o(""))},x=y=>{y.key==="Enter"&&(y.preventDefault(),m())};return a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(St,{className:"w-full max-w-md",children:a.jsxs(Nt,{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(wh,{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(Lt,{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(Ae,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),a.jsx(Ae,{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(Ae,{size:"sm",variant:"secondary",onClick:m,disabled:!s.trim(),children:a.jsx(fr,{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:()=>p(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:()=>p(y),className:"hover:opacity-70",children:a.jsx(Lt,{className:"w-3 h-3"})})]},y))})]})]}),a.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Ae,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),a.jsx(Ae,{onClick:()=>h.mutate(),disabled:l.size===0||h.isPending,className:"flex-1",children:h.isPending?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(wh,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function G8e({selectedIds:t,onClose:e}){const n=sn(),{showToast:r}=Hn(),{data:i,isLoading:s}=ct({queryKey:["projects"],queryFn:()=>oe.getProjects()});_.useEffect(()=>{const d=h=>{h.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=gt({mutationFn:async d=>(await oe.addArchivesToProject(d,t),d),onSuccess:d=>{const h=i?.find(p=>p.id===d);o(),r(`Added ${t.length} archive${t.length!==1?"s":""} to "${h?.name}"`),e()},onError:()=>{r("Failed to assign project","error")}}),c=gt({mutationFn:async()=>{for(const d of t)await oe.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(St,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:a.jsxs(Nt,{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(es,{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(Lt,{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(pt,{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(Ji,{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(pt,{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(es,{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(pt,{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(Ae,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function q8e(t,e){return new Date(t,e+1,0).getDate()}function W8e(t,e){return new Date(t,e,1).getDay()}const K8e=["January","February","March","April","May","June","July","August","September","October","November","December"],X8e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Y8e({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,s]=_.useState(r.getMonth()),[o,l]=_.useState(r.getFullYear()),[c,u]=_.useState(null),[d,h]=_.useState(null),p=_.useMemo(()=>{const k=new Map;return t.forEach(C=>{const E=zi(C.completed_at||C.created_at)||new Date,P=`${E.getFullYear()}-${String(E.getMonth()+1).padStart(2,"0")}-${String(E.getDate()).padStart(2,"0")}`,A=k.get(P)||[];A.push(C),k.set(P,A)}),k},[t]),m=q8e(o,i),x=W8e(o,i),y=()=>{i===0?(s(11),l(o-1)):s(i-1)},v=()=>{i===11?(s(0),l(o+1)):s(i+1)},b=()=>{s(r.getMonth()),l(r.getFullYear())},S=[];for(let k=0;k<x;k++)S.push(null);for(let k=1;k<=m;k++)S.push(k);const N=c?p.get(c)||[]:[],T=k=>{k!==c&&h(null),u(k)};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(bh,{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:[K8e[i]," ",o]}),a.jsx("button",{onClick:b,className:"px-2 py-1 text-xs bg-bambu-dark-tertiary hover:bg-bambu-green/20 text-bambu-gray hover:text-white rounded transition-colors",children:"Today"})]}),a.jsx("button",{onClick:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:a.jsx(vs,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:X8e.map(k=>a.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:k},k))}),a.jsx("div",{className:"grid grid-cols-7 gap-1",children:S.map((k,C)=>{if(k===null)return a.jsx("div",{className:"aspect-square"},`empty-${C}`);const E=`${o}-${String(i+1).padStart(2,"0")}-${String(k).padStart(2,"0")}`,P=p.get(E)||[],A=P.length>0,D=k===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),I=E===c,L=P.filter(j=>j.status==="completed").length,U=P.filter(j=>j.status==="failed").length;return a.jsxs("button",{onClick:()=>T(I?null:E),className:`aspect-square rounded-lg p-1 flex flex-col items-center justify-center transition-colors relative ${I?"bg-bambu-green text-white":D?"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 ${D&&!I?"text-bambu-green":""}`,children:k}),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 ${U>0&&L===0?"bg-red-400":U>0?"bg-yellow-400":"bg-green-400"}`}),a.jsx("span",{className:"text-xs font-medium",children:P.length})]})]},k)})}),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(k=>{const C=new Date(k.completed_at||k.created_at);return C.getMonth()===i&&C.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(k=>{const C=new Date(k.completed_at||k.created_at);return C.getMonth()===i&&C.getFullYear()===o&&k.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(k=>{const C=new Date(k.completed_at||k.created_at);return C.getMonth()===i&&C.getFullYear()===o&&k.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"})}),N.length>0?a.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:N.map(k=>{const C=k.id===d||k.id===n;return a.jsxs("button",{onClick:()=>{h(k.id),e?.(k)},className:`w-full flex items-center gap-3 p-2 rounded-lg transition-colors text-left ${C?"":"hover:bg-bambu-dark-tertiary"}`,style:C?{outline:"4px solid #facc15",outlineOffset:"2px"}:void 0,children:[k.thumbnail_path?a.jsx("img",{src:oe.getArchiveThumbnail(k.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:k.print_name||k.filename}),a.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[a.jsx("span",{className:k.status==="failed"?"text-red-400":"text-green-400",children:k.status==="failed"?"Failed":"Completed"}),k.filament_color&&a.jsx("div",{className:"flex gap-0.5",children:k.filament_color.split(",").map((E,P)=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:E}},P))})]})]})]},k.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 Pee({archiveId:t,archiveName:e,onClose:n}){const r=oe.getArchiveQRCodeUrl(t,300);_.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(Lt,{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(Ae,{onClick:i,className:"w-full",children:[a.jsx(wi,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function Dee({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[s,o]=_.useState(0),[l,c]=_.useState(!1);if(_.useEffect(()=>{const m=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",m),()=>window.removeEventListener("keydown",m)},[r,n.length]),_.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=oe.getArchivePhotoUrl(t,u),h=()=>{const m=document.createElement("a");m.href=d,m.download=`${e}_photo_${s+1}.jpg`,m.click()},p=()=>{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:m=>m.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(Ae,{variant:"secondary",size:"sm",onClick:h,children:[a.jsx(wi,{className:"w-4 h-4"}),"Download"]}),i&&a.jsx(Ae,{variant:"secondary",size:"sm",onClick:p,className:"text-red-400 hover:text-red-300",children:a.jsx(an,{className:"w-4 h-4"})}),a.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{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(m=>m-1),className:"absolute left-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:a.jsx(bh,{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(m=>m+1),className:"absolute right-4 z-10 p-3 bg-black/50 hover:bg-black/70 rounded-full transition-colors",children:a.jsx(vs,{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((m,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:oe.getArchivePhotoUrl(t,m),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},m))})]}),l&&a.jsx(Zn,{title:"Delete Photo",message:"Delete this photo? This cannot be undone.",confirmText:"Delete",variant:"danger",onConfirm:()=>{i?.(u),c(!1)},onCancel:()=>c(!1)})]})}function Oa(t){this.content=t}Oa.prototype={constructor:Oa,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 Oa(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 Oa(n)},addToStart:function(t,e){return new Oa([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Oa(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 Oa(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=Oa.from(t),t.size?new Oa(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Oa.from(t),t.size?new Oa(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Oa.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}};Oa.from=function(t){if(t instanceof Oa)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Oa(e)};function Ree(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=Ree(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Oee(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=Oee(o.content,l.content,n-1,r-1);if(u)return u}n-=c,r-=c}}class kt{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 kt(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 kt(r,i)}cutByIndex(e,n){return e==n?kt.empty:e==0&&n==this.content.length?this:new kt(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 kt(i,s)}addToStart(e){return new kt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new kt(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 Ree(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Oee(this,e,n,r)}findIndex(e){if(e==0)return e1(0,e);if(e==this.size)return e1(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?e1(n+1,s):e1(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 kt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new kt(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return kt.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 kt(n||e,r)}static from(e){if(!e)return kt.empty;if(e instanceof kt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new kt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}kt.empty=new kt([],0);const dj={index:0,offset:0};function e1(t,e){return dj.index=t,dj.offset=e,dj}function cN(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(!cN(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!cN(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Rr=class ED{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&&cN(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 ED.none;if(e instanceof ED)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Rr.none=[];class uN extends Error{}class zt{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=Fee(this.content,e+this.openStart,n);return r&&new zt(r,this.openStart,this.openEnd)}removeBetween(e,n){return new zt(Lee(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 zt.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 zt(kt.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 zt(e,r,i)}}zt.empty=new zt(kt.empty,0,0);function Lee(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(Lee(s.content,e-i-1,n-i-1)))}function Fee(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=Fee(o.content,e-s-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function Q8e(t,e,n){if(n.openStart>t.depth)throw new uN("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new uN("Inconsistent open depths");return Iee(t,e,n,0)}function Iee(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=Iee(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 Zf(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Z8e(n,t);return Zf(s,zee(t,o,l,e,r))}else return Zf(s,dN(t,e,r))}function Uee(t,e){if(!e.type.compatibleContent(t.type))throw new uN("Cannot join "+e.type.name+" onto "+t.type.name)}function TD(t,e,n){let r=t.node(n);return Uee(r,e.node(n)),r}function Qf(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 E0(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&&(Qf(t.nodeAfter,r),s++));for(let l=s;l<o;l++)Qf(i.child(l),r);e&&e.depth==n&&e.textOffset&&Qf(e.nodeBefore,r)}function Zf(t,e){return t.type.checkContent(e),t.copy(e)}function zee(t,e,n,r,i){let s=t.depth>i&&TD(t,e,i+1),o=r.depth>i&&TD(n,r,i+1),l=[];return E0(null,t,i,l),s&&o&&e.index(i)==n.index(i)?(Uee(s,o),Qf(Zf(s,zee(t,e,n,r,i+1)),l)):(s&&Qf(Zf(s,dN(t,e,i+1)),l),E0(e,n,i,l),o&&Qf(Zf(o,dN(n,r,i+1)),l)),E0(r,null,i,l),new kt(l)}function dN(t,e,n){let r=[];if(E0(null,t,n,r),t.depth>n){let i=TD(t,e,n+1);Qf(Zf(i,dN(t,e,n+1)),r)}return E0(e,null,n,r),new kt(r)}function Z8e(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(kt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class _y{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 Rr.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 hN(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 _y(n,r,s)}static resolveCached(e,n){let r=U7.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 U7.set(e,r=new J8e);let i=r.elts[r.i]=_y.resolve(e,n);return r.i=(r.i+1)%e6e,i}}class J8e{constructor(){this.elts=[],this.i=0}}const e6e=12,U7=new WeakMap;class hN{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 t6e=Object.create(null);let mh=class AD{constructor(e,n,r,i=Rr.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||kt.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&&cN(this.attrs,n||e.defaultAttrs||t6e)&&Rr.sameSet(this.marks,r||Rr.none)}copy(e=null){return e==this.content?this:new AD(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new AD(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 zt.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 zt(u,i.depth-o,s.depth-o)}replace(e,n,r){return Q8e(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 _y.resolveCached(this,e)}resolveNoCache(e){return _y.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()+")"),Bee(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=kt.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=Rr.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(!Rr.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=kt.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};mh.prototype.text=void 0;class fN extends mh{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):Bee(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 fN(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new fN(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 Bee(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class _m{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new n6e(e,n);if(r.next==null)return _m.empty;let i=Hee(r);r.next&&r.err("Unexpected trailing text");let s=c6e(l6e(i));return u6e(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 kt.from(l.map(u=>u.createAndFill()));for(let u=0;u<o.next.length;u++){let{type:d,next:h}=o.next[u];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(h)==-1){i.push(h);let p=s(h,l.concat(d));if(p)return p}}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(`
  8142. `)}}_m.empty=new _m(!0);class n6e{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 Hee(t){let e=[];do e.push(r6e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function r6e(t){let e=[];do e.push(i6e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function i6e(t){let e=o6e(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=a6e(t,e);else break;return e}function z7(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function a6e(t,e){let n=z7(t),r=n;return t.eat(",")&&(t.next!="}"?r=z7(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function s6e(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 o6e(t){if(t.eat("(")){let e=Hee(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=s6e(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 l6e(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 B7(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 c6e(t){let e=Object.create(null);return n(B7(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]);B7(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let s=e[r.join(",")]=new _m(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 u6e(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 Vee(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 Gee(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 qee(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 Wee(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new h6e(t,r,e[r]);return n}let H7=class Kee{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=Wee(e,r.attrs),this.defaultAttrs=Vee(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==_m.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:Gee(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new mh(this,this.computeAttrs(e),kt.from(n),Rr.setFrom(r))}createChecked(e=null,n,r){return n=kt.from(n),this.checkContent(n),new mh(this,this.computeAttrs(e),n,Rr.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=kt.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(kt.empty,!0);return s?new mh(this,e,n.append(s),Rr.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){qee(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:Rr.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,o)=>r[s]=new Kee(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 d6e(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 h6e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?d6e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class N2{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Wee(e,i.attrs),this.excluded=null;let s=Vee(this.attrs);this.instance=s?new Rr(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Rr(this,Gee(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new N2(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){qee(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Xee{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=Oa.from(e.nodes),n.marks=Oa.from(e.marks||{}),this.nodes=H7.compile(this.spec.nodes,this),this.marks=N2.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]=_m.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?$7(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==""?[]:$7(this,o.split(" "))}this.nodeFromJSON=i=>mh.fromJSON(this,i),this.markFromJSON=i=>Rr.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 H7){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 fN(r,r.defaultAttrs,e,Rr.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 $7(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 f6e(t){return t.tag!=null}function m6e(t){return t.style!=null}let T0=class CD{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(f6e(i))this.tags.push(i);else if(m6e(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 G7(this,n,!1);return r.addAll(e,Rr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new G7(this,n,!0);return r.addAll(e,Rr.none,n.from,n.to),zt.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(x6e(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=q7(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=q7(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new CD(e,CD.schemaRules(e)))}};const Yee={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},p6e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Qee={ol:!0,ul:!0},Sy=1,jD=2,A0=4;function V7(t,e,n){return e!=null?(e?Sy:0)|(e==="full"?jD:0):t&&t.whitespace=="pre"?Sy|jD:n&~A0}class t1{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=Rr.none,this.match=s||(o&A0?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(kt.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&Sy)){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=kt.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(kt.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&&!Yee.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class G7{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=V7(null,n.preserveWhitespace,0)|(r?A0:0);i?s=new t1(i.type,i.attrs,Rr.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new t1(null,null,Rr.none,!0,null,o):s=new t1(e.schema.topNodeType,null,Rr.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&jD?"full":this.localPreserveWS||(i.options&Sy)>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,`
  8143. `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let c=0;c<l.length;c++)c&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[c]&&this.insertNode(o.text(l[c]),n,!/\S/.test(l[c]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],c=e.previousSibling;(!l||c&&c.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Qee.hasOwnProperty(o)&&this.parser.normalizeLists&&g6e(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:p6e.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(Yee.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 h=c&&c.skip?n:this.readStyles(e,n);h&&this.addAll(e,h),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(`
  8144. `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let 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=Rr.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):W7(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=V7(e,s,o.options);o.options&A0&&o.content.length==0&&(l|=A0);let c=Rr.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):W7(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new t1(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|=Sy)}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 g6e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Qee.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function x6e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function q7(t){let e={};for(let n in t)e[n]=t[n];return e}function W7(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 Dm{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=hj(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}=O1(hj(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&&O1(hj(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return O1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Dm(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=K7(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return K7(e.marks)}}function K7(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function hj(t){return t.document||window.document}const X7=new WeakMap;function b6e(t){let e=X7.get(t);return e===void 0&&X7.set(t,e=y6e(t)),e}function y6e(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 O1(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=b6e(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 h in u)if(u[h]!=null){let p=h.indexOf(" ");p>0?c.setAttributeNS(h.slice(0,p),h.slice(p+1),u[h]):h=="style"&&c.style?c.style.cssText=u[h]:c.setAttribute(h,u[h])}}for(let h=d;h<e.length;h++){let p=e[h];if(p===0){if(h<e.length-1||h>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:m,contentDOM:x}=O1(t,p,n,r);if(c.appendChild(m),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:c,contentDOM:l}}const Zee=65535,Jee=Math.pow(2,16);function v6e(t,e){return t+e*Jee}function Y7(t){return t&Zee}function w6e(t){return(t-(t&Zee))/Jee}const ete=1,tte=2,L1=4,nte=8;class PD{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&nte)>0}get deletedBefore(){return(this.delInfo&(ete|L1))>0}get deletedAfter(){return(this.delInfo&(tte|L1))>0}get deletedAcross(){return(this.delInfo&L1)>0}}class mo{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&mo.empty)return mo.empty}recover(e){let n=0,r=Y7(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+w6e(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],h=c+u;if(e<=h){let p=u?e==c?-1:e==h?1:n:n,m=c+i+(p<0?0:d);if(r)return m;let x=e==(n<0?c:h)?null:v6e(l/3,e-c),y=e==c?tte:e==h?ete:L1;return(n<0?e!=c:e!=h)&&(y|=nte),new PD(m,y,x)}i+=d-u}return r?e+i:new PD(e+i,0,null)}touches(e,n){let r=0,i=Y7(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 mo(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?mo.empty:new mo(e<0?[0,-e,0]:[0,0,e])}}mo.empty=new mo([]);class Ny{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 Ny(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 Ny;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 PD(e,i,null)}}const fj=Object.create(null);class is{getMap(){return mo.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=fj[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 fj)throw new RangeError("Duplicate use of step JSON ID "+e);return fj[e]=n,n.prototype.jsonID=e,n}}class $i{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new $i(e,null)}static fail(e){return new $i(null,e)}static fromReplace(e,n,r,i){try{return $i.ok(e.replace(n,r,i))}catch(s){if(s instanceof uN)return $i.fail(s.message);throw s}}}function bL(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(bL(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return kt.fromArray(r)}class th extends is{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 zt(bL(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 $i.fromReplace(e,this.from,this.to,s)}invert(){return new Fl(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 th(n.pos,r.pos,this.mark)}merge(e){return e instanceof th&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new th(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 th(n.from,n.to,e.markFromJSON(n.mark))}}is.jsonID("addMark",th);class Fl extends is{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 zt(bL(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return $i.fromReplace(e,this.from,this.to,r)}invert(){return new th(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 Fl(n.pos,r.pos,this.mark)}merge(e){return e instanceof Fl&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Fl(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 Fl(n.from,n.to,e.markFromJSON(n.mark))}}is.jsonID("removeMark",Fl);class nh extends is{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return $i.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return $i.fromReplace(e,this.pos,this.pos+1,new zt(kt.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 nh(this.pos,n.marks[i]);return new nh(this.pos,this.mark)}}return new Sm(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new nh(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 nh(n.pos,e.markFromJSON(n.mark))}}is.jsonID("addNodeMark",nh);class Sm extends is{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return $i.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return $i.fromReplace(e,this.pos,this.pos+1,new zt(kt.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new nh(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Sm(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 Sm(n.pos,e.markFromJSON(n.mark))}}is.jsonID("removeNodeMark",Sm);class va extends is{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&DD(e,this.from,this.to)?$i.fail("Structure replace would overwrite content"):$i.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new mo([this.from,this.to-this.from,this.slice.size])}invert(e){return new va(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 va(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof va)||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?zt.empty:new zt(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new va(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?zt.empty:new zt(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new va(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 va(n.from,n.to,zt.fromJSON(e,n.slice),!!n.structure)}}is.jsonID("replace",va);class Na extends is{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&&(DD(e,this.from,this.gapFrom)||DD(e,this.gapTo,this.to)))return $i.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return $i.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?$i.fromReplace(e,this.from,this.to,r):$i.fail("Content does not fit in gap")}getMap(){return new mo([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 Na(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 Na(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 Na(n.from,n.to,n.gapFrom,n.gapTo,zt.fromJSON(e,n.slice),n.insert,!!n.structure)}}is.jsonID("replaceAround",Na);function DD(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 _6e(t,e,n,r){let i=[],s=[],o,l;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let h=c.marks;if(!r.isInSet(h)&&d.type.allowsMarkType(r.type)){let p=Math.max(u,e),m=Math.min(u+c.nodeSize,n),x=r.addToSet(h);for(let y=0;y<h.length;y++)h[y].isInSet(x)||(o&&o.to==p&&o.mark.eq(h[y])?o.to=m:i.push(o=new Fl(p,m,h[y])));l&&l.to==p?l.to=m:s.push(l=new th(p,m,r))}}),i.forEach(c=>t.step(c)),s.forEach(c=>t.step(c))}function S6e(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 N2){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 h=c[d],p;for(let m=0;m<i.length;m++){let x=i[m];x.step==s-1&&h.eq(i[m].style)&&(p=x)}p?(p.to=u,p.step=s):i.push({style:h,from:Math.max(l,e),to:u,step:s})}}}),i.forEach(o=>t.step(new Fl(o.from,o.to,o.style)))}function yL(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,h=r.matchType(u.type);if(!h)o.push(new va(l,d,zt.empty));else{r=h;for(let p=0;p<u.marks.length;p++)n.allowsMarkType(u.marks[p].type)||t.step(new Fl(l,d,u.marks[p]));if(i&&u.isText&&n.whitespace!="pre"){let p,m=/\r?\n|\r/g,x;for(;p=m.exec(u.text);)x||(x=new zt(kt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new va(l+p.index,l+p.index+p[0].length,x))}}l=d}if(!r.validEnd){let c=r.fillBefore(kt.empty,!0);t.replace(l,l,new zt(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 Fx(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 M6e(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=kt.empty,h=0;for(let x=s,y=!1;x>n;x--)y||r.index(x)>0?(y=!0,d=kt.from(r.node(x).copy(d)),h++):c--;let p=kt.empty,m=0;for(let x=s,y=!1;x>n;x--)y||i.after(x+1)<i.end(x)?(y=!0,p=kt.from(i.node(x).copy(p)),m++):u++;t.step(new Na(c,u,o,l,new zt(d.append(p),h,m),d.size-h,!0))}function vL(t,e,n=null,r=t){let i=k6e(t,e),s=i&&E6e(r,e);return s?i.map(Q7).concat({type:e,attrs:n}).concat(s.map(Q7)):null}function Q7(t){return{type:t,attrs:null}}function k6e(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 E6e(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 T6e(t,e,n){let r=kt.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=kt.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new Na(i,s,i,s,new zt(r,0,0),n.length,!0))}function A6e(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)&&C6e(t.doc,t.mapping.slice(s).map(l),r)){let u=null;if(r.schema.linebreakReplacement){let m=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);m&&!x?u=!1:!m&&x&&(u=!0)}u===!1&&ite(t,o,l,s),yL(t,t.mapping.slice(s).map(l,1),r,void 0,u===null);let d=t.mapping.slice(s),h=d.map(l,1),p=d.map(l+o.nodeSize,1);return t.step(new Na(h,p,h+1,p-1,new zt(kt.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&rte(t,o,l,s),!1}})}function rte(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 ite(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(`
  8145. `))}})}function C6e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function j6e(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 Na(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new zt(kt.from(o),0,0),1,!0))}function Du(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 h=i.node(u),p=i.index(u);if(h.type.spec.isolating)return!1;let m=h.content.cutByIndex(p,h.childCount),x=r&&r[d+1];x&&(m=m.replaceChild(0,x.type.create(x.attrs)));let y=r&&r[d]||h;if(!h.canReplace(p+1,h.childCount)||!y.type.validContent(m))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 P6e(t,e,n=1,r){let i=t.doc.resolve(e),s=kt.empty,o=kt.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){s=kt.from(i.node(l).copy(s));let d=r&&r[u];o=kt.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new va(e,e,new zt(s.append(o),n,n),!0))}function Hh(t,e){let n=t.resolve(e),r=n.index();return ate(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 ate(t,e){return!!(t&&e&&!t.isLeaf&&D6e(t,e))}function M2(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&&ate(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 R6e(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",h=!!o.contentMatch.matchType(i);d&&!h?r=!1:!d&&h&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);ite(t,d.node(),d.before(),l)}o.inlineContent&&yL(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 va(u,c.map(e+n,-1),zt.empty,!0)),r===!0){let d=t.doc.resolve(u);rte(t,d.node(),d.before(),t.steps.length)}return t}function O6e(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 ste(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 h=u.contentMatchAt(c).findWrapping(i.firstChild.type);d=h&&u.canReplaceWith(c,c,h[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function k2(t,e,n=e,r=zt.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return ote(i,s,r)?new va(e,n,r):new L6e(i,s,r).fit()}function ote(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class L6e{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=kt.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=kt.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 zt(s,o,l);return e>-1?new Na(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new va(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=mj(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,h=null;if(n==1&&(o?u.matchType(o.type)||(h=u.fillBefore(kt.from(o),!1)):s&&c.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:h};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=mj(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new zt(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=mj(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new zt(h0(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new zt(h0(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:h,type:p}=this.frontier[n];if(i){for(let y=0;y<i.childCount;y++)d.push(i.child(y));h=h.matchFragment(i)}let m=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let y=l.child(u),v=h.matchType(y.type);if(!v)break;u++,(u>1||c==0||y.content.size)&&(h=v,d.push(lte(y.mark(p.allowedMarks(y.marks)),u==1?c:0,u==l.childCount?m:-1)))}let x=u==l.childCount;x||(m=-1),this.placed=f0(this.placed,n,kt.from(d)),this.frontier[n].match=h,x&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let y=0,v=l;y<m;y++){let b=v.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),v=b.content}this.unplaced=x?e==0?zt.empty:new zt(h0(o.content,e-1,1),e-1,m<0?o.openEnd:e-1):new zt(h0(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||!pj(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=pj(e,n,i,r,s);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=pj(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=f0(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=f0(this.placed,this.depth,kt.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(kt.empty,!0);n.childCount&&(this.placed=f0(this.placed,this.frontier.length,n))}}function h0(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(h0(t.firstChild.content,e-1,n)))}function f0(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(f0(t.lastChild.content,e-1,n)))}function mj(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function lte(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,lte(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(kt.empty,!0)))),t.copy(r)}function pj(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&&!F6e(n,s.content,o)?l:null}function F6e(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function I6e(t){return t.spec.defining||t.spec.definingForContent}function U6e(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(ote(i,s,r))return t.step(new va(e,n,r));let o=ute(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let p=i.depth,m=i.pos-1;p>0;p--,m--){let x=i.node(p).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;o.indexOf(p)>-1?l=p:i.before(p)==m&&o.splice(1,0,-p)}let c=o.indexOf(l),u=[],d=r.openStart;for(let p=r.content,m=0;;m++){let x=p.firstChild;if(u.push(x),m==r.openStart)break;p=x.content}for(let p=d-1;p>=0;p--){let m=u[p],x=I6e(m.type);if(x&&!m.sameMarkup(i.node(Math.abs(l)-1)))d=p;else if(x||!m.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let m=(p+d+1)%(r.openStart+1),x=u[m];if(x)for(let y=0;y<o.length;y++){let v=o[(y+c)%o.length],b=!0;v<0&&(b=!1,v=-v);let S=i.node(v-1),N=i.index(v-1);if(S.canReplaceWith(N,N,x.type,x.marks))return t.replace(i.before(v),b?s.after(v):n,new zt(cte(r.content,0,r.openStart,m),m,r.openEnd))}}let h=t.steps.length;for(let p=o.length-1;p>=0&&(t.replace(e,n,r),!(t.steps.length>h));p--){let m=o[p];m<0||(e=i.before(m),n=s.after(m))}}function cte(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(cte(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(kt.empty,!0))}return t}function z6e(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=O6e(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new zt(kt.from(r),0,0))}function B6e(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=ute(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 ute(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 Lg extends is{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 $i.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 $i.fromReplace(e,this.pos,this.pos+1,new zt(kt.from(i),0,n.isLeaf?0:1))}getMap(){return mo.empty}invert(e){return new Lg(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 Lg(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 Lg(n.pos,n.attr,n.value)}}is.jsonID("attr",Lg);class My extends is{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 $i.ok(r)}getMap(){return mo.empty}invert(e){return new My(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 My(n.attr,n.value)}}is.jsonID("docAttr",My);let cx=class extends Error{};cx=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};cx.prototype=Object.create(Error.prototype);cx.prototype.constructor=cx;cx.prototype.name="TransformError";class dte{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ny}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new cx(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=zt.empty){let i=k2(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new zt(kt.from(r),0,0))}delete(e,n){return this.replace(e,n,zt.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return U6e(this,e,n,r),this}replaceRangeWith(e,n,r){return z6e(this,e,n,r),this}deleteRange(e,n){return B6e(this,e,n),this}lift(e,n){return M6e(this,e,n),this}join(e,n=1){return R6e(this,e,n),this}wrap(e,n){return T6e(this,e,n),this}setBlockType(e,n=e,r,i=null){return A6e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return j6e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Lg(e,n,r)),this}setDocAttribute(e,n){return this.step(new My(e,n)),this}addNodeMark(e,n){return this.step(new nh(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 Rr)n.isInSet(r.marks)&&this.step(new Sm(e,n));else{let i=r.marks,s,o=[];for(;s=n.isInSet(i);)o.push(new Sm(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 P6e(this,e,n,r),this}addMark(e,n,r){return _6e(this,e,n,r),this}removeMark(e,n,r){return S6e(this,e,n,r),this}clearIncompatible(e,n,r){return yL(this,e,n,r),this}}const gj=Object.create(null);class jn{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new H6e(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=zt.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?zt.empty:n),l==0&&e9(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),e9(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new gn(e):cg(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?cg(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):cg(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 wo(e.node(0))}static atStart(e){return cg(e,e,0,0,1)||new wo(e)}static atEnd(e){return cg(e,e,e.content.size,e.childCount,-1)||new wo(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=gj[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 gj)throw new RangeError("Duplicate use of selection JSON ID "+e);return gj[e]=n,n.prototype.jsonID=e,n}getBookmark(){return gn.between(this.$anchor,this.$head).getBookmark()}}jn.prototype.visible=!0;class H6e{constructor(e,n){this.$from=e,this.$to=n}}let Z7=!1;function J7(t){!Z7&&!t.parent.inlineContent&&(Z7=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class gn extends jn{constructor(e,n=e){J7(e),J7(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 jn.near(r);let i=e.resolve(n.map(this.anchor));return new gn(i.parent.inlineContent?i:r,r)}replace(e,n=zt.empty){if(super.replace(e,n),n==zt.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof gn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new E2(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 gn(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=jn.findFrom(n,r,!0)||jn.findFrom(n,-r,!0);if(s)n=s.$head;else return jn.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(jn.findFrom(e,-r,!0)||jn.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new gn(e,n)}}jn.jsonID("text",gn);class E2{constructor(e,n){this.anchor=e,this.head=n}map(e){return new E2(e.map(this.anchor),e.map(this.head))}resolve(e){return gn.between(e.resolve(this.anchor),e.resolve(this.head))}}class Zt extends jn{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?jn.near(s):new Zt(s)}content(){return new zt(kt.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 wL(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;jn.jsonID("node",Zt);class wL{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new E2(r,r):new wL(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Zt.isSelectable(r)?new Zt(n):jn.near(n)}}class wo extends jn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=zt.empty){if(n==zt.empty){e.delete(0,e.doc.content.size);let r=jn.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new wo(e)}map(e){return new wo(e)}eq(e){return e instanceof wo}getBookmark(){return $6e}}jn.jsonID("all",wo);const $6e={map(){return this},resolve(t){return new wo(t)}};function cg(t,e,n,r,i,s=!1){if(e.inlineContent)return gn.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=cg(t,l,n+i,i<0?l.childCount:0,i,s);if(c)return c}n+=l.nodeSize*i}return null}function e9(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof va||i instanceof Na))return;let s=t.mapping.maps[r],o;s.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(jn.near(t.doc.resolve(o),n))}const t9=1,n1=2,n9=4;class V6e extends dte{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|t9)&~n1,this.storedMarks=null,this}get selectionSet(){return(this.updated&t9)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=n1,this}ensureMarks(e){return Rr.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&n1)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~n1,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)||Rr.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(jn.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|=n9,this}get scrolledIntoView(){return(this.updated&n9)>0}}function r9(t,e){return!e||!t?t:t.bind(e)}class m0{constructor(e,n,r){this.name=e,this.init=r9(n.init,r),this.apply=r9(n.apply,r)}}const G6e=[new m0("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new m0("selection",{init(t,e){return t.selection||jn.atStart(e.doc)},apply(t){return t.selection}}),new m0("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new m0("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class xj{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=G6e.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 m0(r.key,r.spec.state,r))})}}class _g{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 h=0;h<this.config.plugins.length;h++)i.push(h<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 _g(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 V6e(this)}static create(e){let n=new xj(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new _g(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 xj(this.schema,e.plugins),r=n.fields,i=new _g(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 xj(e.schema,e.plugins),s=new _g(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=mh.fromJSON(e.schema,n.doc);else if(o.name=="selection")s.selection=jn.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 hte(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=hte(i,e,{})),n[r]=i}return n}class di{constructor(e){this.spec=e,this.props={},e.props&&hte(e.props,this,this.props),this.key=e.key?e.key.key:fte("plugin")}getState(e){return e[this.key]}}const bj=Object.create(null);function fte(t){return t in bj?t+"$"+ ++bj[t]:(bj[t]=0,t+"$")}class ua{constructor(e="key"){this.key=fte(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const _L=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function mte(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const pte=(t,e,n)=>{let r=mte(t,n);if(!r)return!1;let i=SL(r);if(!i){let o=r.blockRange(),l=o&&Fx(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&&(ux(s,"end")||Zt.isSelectable(s)))for(let o=r.depth;;o--){let l=k2(t.doc,r.before(o),r.after(o),zt.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(ux(s,"end")?jn.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},q6e=(t,e,n)=>{let r=mte(t,n);if(!r)return!1;let i=SL(r);return i?gte(t,i,e):!1},W6e=(t,e,n)=>{let r=bte(t,n);if(!r)return!1;let i=NL(r);return i?gte(t,i,e):!1};function gte(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=k2(t.doc,s,c,zt.empty);if(!u||u.from!=s||u instanceof va&&u.slice.size>=c-s)return!1;if(n){let d=t.tr.step(u);d.setSelection(gn.create(d.doc,s)),n(d.scrollIntoView())}return!0}function ux(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 xte=(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=SL(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 SL(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 bte(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const yte=(t,e,n)=>{let r=bte(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&&(ux(s,"start")||Zt.isSelectable(s))){let o=k2(t.doc,r.before(),r.after(),zt.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(ux(s,"start")?jn.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},vte=(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 K6e=(t,e)=>{let n=t.selection,r=n instanceof Zt,i;if(r){if(n.node.isTextblock||!Hh(t.doc,n.from))return!1;i=n.from}else if(i=M2(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},X6e=(t,e)=>{let n=t.selection,r;if(n instanceof Zt){if(n.node.isTextblock||!Hh(t.doc,n.to))return!1;r=n.to}else if(r=M2(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Y6e=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&Fx(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},wte=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
  8146. `).scrollIntoView()),!0)};function ML(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 Q6e=(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=ML(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(jn.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},_te=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof wo||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=ML(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(gn.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Ste=(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(Du(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Fx(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function Z6e(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Zt&&e.selection.node.isBlock)return!r.parentOffset||!Du(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 m=r.depth;;m--)if(r.node(m).isBlock){c=r.end(m)==r.pos+(r.depth-m),u=r.start(m)==r.pos-(r.depth-m),l=ML(r.node(m-1).contentMatchAt(r.indexAfter(m-1))),s.unshift(c&&l?{type:l}:null),o=m;break}else{if(m==1)return!1;s.unshift(null)}let d=e.tr;(e.selection instanceof gn||e.selection instanceof wo)&&d.deleteSelection();let h=d.mapping.map(r.pos),p=Du(d.doc,h,s.length,s);if(p||(s[0]=l?{type:l}:null,p=Du(d.doc,h,s.length,s)),!p)return!1;if(d.split(h,s.length,s),!c&&u&&r.node(o).type!=l){let m=d.mapping.map(r.before(o)),x=d.doc.resolve(m);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=Z6e(),eHe=(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 tHe(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||Hh(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&&tHe(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 m=e.pos+s.nodeSize,x=kt.empty;for(let b=o.length-1;b>=0;b--)x=kt.from(o[b].create(null,x));x=kt.from(i.copy(x));let y=t.tr.step(new Na(e.pos-1,m,e.pos,m,new zt(x,1,0),o.length,!0)),v=y.doc.resolve(m+2*o.length);v.nodeAfter&&v.nodeAfter.type==i.type&&Hh(y.doc,v.pos)&&y.join(v.pos),n(y.scrollIntoView())}return!0}let d=s.type.spec.isolating||r>0&&c?null:jn.findFrom(e,1),h=d&&d.$from.blockRange(d.$to),p=h&&Fx(h);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(h,p).scrollIntoView()),!0;if(u&&ux(s,"start",!0)&&ux(i,"end")){let m=i,x=[];for(;x.push(m),!m.isTextblock;)m=m.lastChild;let y=s,v=1;for(;!y.isTextblock;y=y.firstChild)v++;if(m.canReplace(m.childCount,m.childCount,y.content)){if(n){let b=kt.empty;for(let N=x.length-1;N>=0;N--)b=kt.from(x[N].copy(b));let S=t.tr.step(new Na(e.pos-x.length,e.pos+s.nodeSize,e.pos+v,e.pos+s.nodeSize-v,new zt(b,x.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function Mte(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(gn.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const nHe=Mte(-1),rHe=Mte(1);function iHe(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),l=o&&vL(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function i9(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),h=d.index();i=d.parent.canReplaceWith(h,h+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 kL(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}kL(_L,pte,xte);kL(_L,yte,vte);kL(wte,_te,Ste,J6e);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function aHe(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 sHe(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function sHe(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 hN(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new hN(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=vL(s,n,r,e);return l?(t&&oHe(t,e,l,i,n),!0):!1}function oHe(t,e,n,r,i){let s=kt.empty;for(let d=n.length-1;d>=0;d--)s=kt.from(n[d].type.create(n[d].attrs,s));t.step(new Na(e.start-(r?2:0),e.end,e.start,e.end,new zt(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,h=e.endIndex,p=!0;d<h;d++,p=!1)!p&&Du(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function lHe(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?cHe(e,n,t,s):uHe(e,n,s):!0:!1}}function cHe(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new Na(s-1,o,s,o,new zt(kt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new hN(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=Fx(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(s,-1)-1);return Hh(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function uHe(t,e,n){let r=t.tr,i=n.parent;for(let m=n.end,x=n.endIndex-1,y=n.startIndex;x>y;x--)m-=i.child(x).nodeSize,r.delete(m-1,m+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?kt.empty:kt.from(i))))return!1;let h=s.pos,p=h+o.nodeSize;return r.step(new Na(h-(l?1:0),p+(c?1:0),h+1,p-1,new zt((l?kt.empty:kt.from(i.copy(kt.empty))).append(c?kt.empty:kt.from(i.copy(kt.empty))),l?0:1,c?0:1),l?0:1)),e(r.scrollIntoView()),!0}function dHe(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=kt.from(u?t.create():null),h=new zt(kt.from(t.create(null,kt.from(l.type.create(null,d)))),u?3:1,0),p=s.start,m=s.end;n(e.tr.step(new Na(p-(u?3:1),m,p,m,h,1,!0)).scrollIntoView())}return!0}}const Ua=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},dx=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let RD=null;const fu=function(t,e,n){let r=RD||(RD=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},hHe=function(){RD=null},Nm=function(t,e,n,r){return n&&(a9(t,e,n,r,-1)||a9(t,e,n,r,1))},fHe=/^(img|br|input|textarea|hr)$/i;function a9(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:tl(t))){let o=t.parentNode;if(!o||o.nodeType!=1||bv(t)||fHe.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ua(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?tl(t):0}else return!1}}function tl(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function mHe(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=tl(t)}else if(t.parentNode&&!bv(t))e=Ua(t),t=t.parentNode;else return null}}function pHe(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&&!bv(t))e=Ua(t)+1,t=t.parentNode;else return null}}function gHe(t,e,n){for(let r=e==0,i=e==tl(t);r||i;){if(t==n)return!0;let s=Ua(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==tl(t)}}function bv(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 T2=function(t){return t.focusNode&&Nm(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function jf(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function xHe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function bHe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(tl(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(tl(r.startContainer),r.startOffset)}}}const Nc=typeof navigator<"u"?navigator:null,s9=typeof document<"u"?document:null,$h=Nc&&Nc.userAgent||"",OD=/Edge\/(\d+)/.exec($h),kte=/MSIE \d/.exec($h),LD=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec($h),Vs=!!(kte||LD||OD),ph=kte?document.documentMode:LD?+LD[1]:OD?+OD[1]:0,ol=!Vs&&/gecko\/(\d+)/i.test($h);ol&&+(/Firefox\/(\d+)/.exec($h)||[0,0])[1];const FD=!Vs&&/Chrome\/(\d+)/.exec($h),Ja=!!FD,Ete=FD?+FD[1]:0,Ss=!Vs&&!!Nc&&/Apple Computer/.test(Nc.vendor),hx=Ss&&(/Mobile\/\w+/.test($h)||!!Nc&&Nc.maxTouchPoints>2),Xo=hx||(Nc?/Mac/.test(Nc.platform):!1),yHe=Nc?/Win/.test(Nc.platform):!1,Mu=/Android \d/.test($h),yv=!!s9&&"webkitFontSmoothing"in s9.documentElement.style,vHe=yv?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function wHe(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 su(t,e){return typeof t=="number"?t:t[e]}function _He(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 o9(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=dx(o);continue}let l=o,c=l==s.body,u=c?wHe(s):_He(l),d=0,h=0;if(e.top<u.top+su(r,"top")?h=-(u.top-e.top+su(i,"top")):e.bottom>u.bottom-su(r,"bottom")&&(h=e.bottom-e.top>u.bottom-u.top?e.top+su(i,"top")-u.top:e.bottom-u.bottom+su(i,"bottom")),e.left<u.left+su(r,"left")?d=-(u.left-e.left+su(i,"left")):e.right>u.right-su(r,"right")&&(d=e.right-u.right+su(i,"right")),d||h)if(c)s.defaultView.scrollBy(d,h);else{let m=l.scrollLeft,x=l.scrollTop;h&&(l.scrollTop+=h),d&&(l.scrollLeft+=d);let y=l.scrollLeft-m,v=l.scrollTop-x;e={left:e.left-y,top:e.top-v,right:e.right-y,bottom:e.bottom-v}}let p=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(p))break;o=p=="absolute"?o.offsetParent:dx(o)}}function SHe(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:Tte(t.dom)}}function Tte(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=dx(r));return e}function NHe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Ate(n,r==0?0:r-e)}function Ate(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 tg=null;function MHe(t){if(t.setActive)return t.setActive();if(tg)return t.focus(tg);let e=Tte(t);t.focus(tg==null?{get preventScroll(){return tg={preventScroll:!0},!0}}:void 0),tg||(tg=!1,Ate(e,0))}function Cte(t,e){let n,r=2e8,i,s=0,o=e.top,l=e.top,c,u;for(let d=t.firstChild,h=0;d;d=d.nextSibling,h++){let p;if(d.nodeType==1)p=d.getClientRects();else if(d.nodeType==3)p=fu(d).getClientRects();else continue;for(let m=0;m<p.length;m++){let x=p[m];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=h+(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=h+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?kHe(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:Cte(n,i)}function kHe(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&&EL(e,s))return{node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:t,offset:0}}function EL(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function EHe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function THe(t,e,n){let{node:r,offset:i}=Cte(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 AHe(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 jte(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(EL(e,u))return jte(o,e,u)}}if((s=(s+1)%r)==i)break}return t}function CHe(t,e){let n=t.dom.ownerDocument,r,i=0,s=bHe(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(!EL(e,u)||(o=jte(t.dom,e,u),!o))return null}if(Ss)for(let u=o;r&&u;u=dx(u))u.draggable&&(r=void 0);if(o=EHe(o,e),r){if(ol&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],h;d.nodeName=="IMG"&&(h=d.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&i++}let u;yv&&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=AHe(t,r,i,e))}l==null&&(l=THe(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function l9(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(l9(r))return r}return Array.prototype.find.call(n,l9)||t.getBoundingClientRect()}const jHe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Pte(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=yv||ol;if(r.nodeType==3)if(o&&(jHe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=Ud(fu(r,i,i),n);if(ol&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Ud(fu(r,i-1,i-1),-1);if(u.top==c.top){let d=Ud(fu(r,i,i+1),-1);if(d.top!=c.top)return t0(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++,t0(Ud(fu(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==tl(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return yj(c.getBoundingClientRect(),!1)}if(s==null&&i<tl(r)){let c=r.childNodes[i];if(c.nodeType==1)return yj(c.getBoundingClientRect(),!0)}return yj(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==tl(r))){let c=r.childNodes[i-1],u=c.nodeType==3?fu(c,tl(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return t0(Ud(u,1),!1)}if(s==null&&i<tl(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?fu(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return t0(Ud(u,-1),!0)}return t0(Ud(r.nodeType==3?fu(r):r,-n),n>=0)}function t0(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 yj(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 PHe(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=Pte(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=fu(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 DHe=/[\u0590-\u08ac]/;function RHe(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?!DHe.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:o:Dte(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:h}=t.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",n,"character");let m=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:y}=t.domSelectionRange(),v=x&&!m.contains(x.nodeType==1?x:x.parentNode)||c==x&&u==y;try{l.collapse(d,h),c&&(c!=d||u!=h)&&l.extend&&l.extend(c,u)}catch{}return p!=null&&(l.caretBidiLevel=p),v}):r.pos==r.start()||r.pos==r.end()}let c9=null,u9=null,d9=!1;function OHe(t,e,n){return c9==e&&u9==n?d9:(c9=e,u9=n,d9=n=="up"||n=="down"?PHe(t,e,n):RHe(t,e,n))}const ll=0,h9=1,If=2,Mc=3;class vv{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=ll,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>Ua(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 Ote){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 Rte&&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?Ua(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?Ua(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 h=l;h>0;h--){let p=this.children[h-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){i=Ua(p.dom)+1;break}e-=p.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 h=this.children[d];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){s=Ua(h.dom);break}n+=h.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 m=0,x=0;m<this.children.length;m++){let y=this.children[m],v=x+y.size;if(s>x&&o<v)return y.setSelection(e-x-y.border,n-x-y.border,r,i);x=v}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(),h=!1;if((ol||Ss)&&e==n){let{node:m,offset:x}=l;if(m.nodeType==3){if(h=!!(x&&m.nodeValue[x-1]==`
  8147. `),h&&x==m.nodeValue.length)for(let y=m,v;y;y=y.parentNode){if(v=y.nextSibling){v.nodeName=="BR"&&(l=c={node:v.parentNode,offset:Ua(v)+1});break}let b=y.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let y=m.childNodes[x-1];h=y&&(y.nodeName=="BR"||y.contentEditable=="false")}}if(ol&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let m=d.focusNode.childNodes[d.focusOffset];m&&m.contentEditable=="false"&&(i=!0)}if(!(i||h&&Ss)&&Nm(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Nm(c.node,c.offset,d.focusNode,d.focusOffset))return;let p=!1;if((u.extend||e==n)&&!(h&&ol)){u.collapse(l.node,l.offset);try{e!=n&&u.extend(c.node,c.offset),p=!0}catch{}}if(!p){if(e>n){let x=l;l=c,c=x}let m=document.createRange();m.setEnd(c.node,c.offset),m.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(m)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i<this.children.length;i++){let 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?If:h9,e==l&&n==c&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Mc:s.markDirty(e-l,n-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?If:Mc}r=o}this.dirty=If}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?If:h9;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Rte extends vv{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==ll&&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 LHe extends vv{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 Mm extends vv{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=Dm.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Mm(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Mc||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Mc&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=ll){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=ll}}slice(e,n,r){let i=Mm.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;n<o&&(s=UD(s,n,o,r)),e>0&&(s=UD(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 gh extends vv{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,h=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:h}=Dm.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!h&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let p=d;return d=Ite(d,r,n),u?c=new FHe(e,n,r,i,d,h||null,p,u,s,o+1):n.isText?new A2(e,n,r,i,d,p,s):new gh(e,n,r,i,d,h||null,p,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=()=>kt.empty)}return e}matchesNode(e,n,r){return this.dirty==ll&&e.eq(this.node)&&mN(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 UHe(this,o&&o.node,e);HHe(this.node,this.innerDeco,(u,d,h)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!h&&c.syncToMarks(d==this.node.childCount?Rr.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,h,p)=>{c.syncToMarks(u.marks,r,e);let m;c.findNodeMatch(u,d,h,p)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(m=c.findIndexWithChild(s.node))>-1&&c.updateNodeAt(u,d,h,m,e)||c.updateNextNode(u,d,h,e,p,i)||c.addNode(u,d,h,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==If)&&(o&&this.protectLocalComposition(e,o),Lte(this.contentDOM,this.children,e),hx&&$He(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof gn)||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=VHe(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 LHe(this,s,n,i);e.input.compositionNodes.push(o),this.children=UD(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==Mc||!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=ll}updateOuterDeco(e){if(mN(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Fte(this.dom,this.nodeDOM,ID(this.outerDeco,this.node,n),ID(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 f9(t,e,n,r,i){Ite(r,e,t);let s=new gh(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class A2 extends gh{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==Mc||this.dirty!=ll&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=ll||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=ll,!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 A2(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=Mc)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Ote extends vv{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ll&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class FHe extends gh{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==Mc)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 Lte(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=m9(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof Mm){let c=r?r.previousSibling:t.lastChild;Lte(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=m9(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const C0=function(t){t&&(this.nodeName=t)};C0.prototype=Object.create(null);const Uf=[new C0];function ID(t,e,n){if(t.length==0)return Uf;let r=n?Uf[0]:new C0,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new C0(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new C0(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 Fte(t,e,n,r){if(n==Uf&&r==Uf)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=Uf[0]),i=c}IHe(i,l||Uf[0],o)}return i}function IHe(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 Ite(t,e,n){return Fte(t,t,Uf,ID(e,n,t.nodeType!=1))}function mN(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 m9(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class UHe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=zHe(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=ll,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=Mm.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==Mc&&o.dom==o.contentDOM&&(o.dirty=If),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 gh){let u=this.preMatch.matched.get(c);if(u!=null&&u!=s)return!1;let d=c.dom,h,p=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=Mc&&mN(n,c.outerDeco));if(!p&&c.update(e,n,r,i))return this.destroyBetween(this.index,l),c.dom!=d&&(this.changed=!0),this.index++,!0;if(!p&&(h=this.recreateWrapper(c,e,n,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=If,h.updateChildren(i,o+1),h.dirty=ll),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)||!mN(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=gh.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=gh.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 Rte(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 Mm;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof A2)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Ss||Ja)&&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 Ote(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 zHe(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 Mm)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 BHe(t,e){return t.type.side-e.type.side}function HHe(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,h;for(;o<i.length&&i[o].to==s;){let v=i[o++];v.widget&&(d?(h||(h=[d])).push(v):d=v)}if(d)if(h){h.sort(BHe);for(let v=0;v<h.length;v++)n(h[v],u,!!c)}else n(d,u,!!c);let p,m;if(c)m=-1,p=c,c=null;else if(u<t.childCount)m=u,p=t.child(u++);else break;for(let v=0;v<l.length;v++)l[v].to<=s&&l.splice(v--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let x=s+p.nodeSize;if(p.isText){let v=x;o<i.length&&i[o].from<v&&(v=i[o].from);for(let b=0;b<l.length;b++)l[b].to<v&&(v=l[b].to);v<x&&(c=p.cut(v-s),p=p.cut(0,v-s),x=v,m=-1)}else for(;o<i.length&&i[o].to<x;)o++;let y=p.isInline&&!p.isLeaf?l.filter(v=>!v.inline):l.slice();r(p,y,e.forChild(s,p),m),s=x}}function $He(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 VHe(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 UD(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 TL(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(T2(n)){for(c=o;i&&!i.node;)i=i.parent;let h=i.node;if(i&&h.isAtom&&Zt.isSelectable(h)&&i.parent&&!(h.isInline&&gHe(n.focusNode,n.focusOffset,i.dom))){let p=i.posBefore;u=new Zt(o==p?l:r.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let h=o,p=o;for(let m=0;m<n.rangeCount;m++){let x=n.getRangeAt(m);h=Math.min(h,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(h<0)return null;[c,o]=p==t.state.selection.anchor?[p,h]:[h,p],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 h=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;u=AL(t,d,l,h)}return u}function Ute(t){return t.editable?t.hasFocus():Bte(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Ru(t,e=!1){let n=t.state.selection;if(zte(t,n),!!Ute(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ja){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Nm(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)qHe(t);else{let{anchor:r,head:i}=n,s,o;p9&&!(n instanceof gn)&&(n.$from.parent.inlineContent||(s=g9(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=g9(t,n.to))),t.docView.setSelection(r,i,t,e),p9&&(s&&x9(s),o&&x9(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&GHe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const p9=Ss||Ja&&Ete<63;function g9(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(Ss&&i&&i.contentEditable=="false")return vj(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return vj(i);if(s)return vj(s)}}function vj(t){return t.contentEditable="true",Ss&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function x9(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function GHe(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(()=>{(!Ute(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function qHe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ua(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Vs&&ph<=11&&(n.disabled=!0,n.disabled=!1)}function zte(t,e){if(e instanceof Zt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(b9(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else b9(t)}function b9(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function AL(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||gn.between(e,n,r)}function y9(t){return t.editable&&!t.hasFocus()?!1:Bte(t)}function Bte(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 WHe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Nm(e.node,e.offset,n.anchorNode,n.anchorOffset)}function zD(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&&jn.findFrom(s,e)}function Vd(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function v9(t,e,n){let r=t.state.selection;if(r instanceof gn)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 Vd(t,new gn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=zD(t.state,e);return i&&i instanceof Zt?Vd(t,i):!1}else if(!(Xo&&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)?Vd(t,new Zt(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):yv?Vd(t,new gn(t.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Zt&&r.node.isInline)return Vd(t,new gn(e>0?r.$to:r.$from));{let i=zD(t.state,e);return i?Vd(t,i):!1}}}function pN(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function j0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function ng(t,e){return e<0?KHe(t):XHe(t)}function KHe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(ol&&n.nodeType==1&&r<pN(n)&&j0(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(j0(l,-1))i=n,s=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Hte(n))break;{let l=n.previousSibling;for(;l&&j0(l,-1);)i=n.parentNode,s=Ua(l),l=l.previousSibling;if(l)n=l,r=pN(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?BD(t,n,r):i&&BD(t,i,s)}function XHe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=pN(n),s,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(j0(l,1))s=n,o=++r;else break}else{if(Hte(n))break;{let l=n.nextSibling;for(;l&&j0(l,1);)s=l.parentNode,o=Ua(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=pN(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&BD(t,s,o)}function Hte(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function YHe(t,e){for(;t&&e==t.childNodes.length&&!bv(t);)e=Ua(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 QHe(t,e){for(;t&&!e&&!bv(t);)e=Ua(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 BD(t,e,n){if(e.nodeType!=3){let s,o;(o=YHe(e,n))?(e=o,n=0):(s=QHe(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(T2(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&&Ru(t)},50)}function w9(t,e){let n=t.state.doc.resolve(e);if(!(Ja||yHe)&&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 _9(t,e,n){let r=t.state.selection;if(r instanceof gn&&!r.empty||n.indexOf("s")>-1||Xo&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=zD(t.state,e);if(o&&o instanceof Zt)return Vd(t,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof wo?jn.near(o,e):jn.findFrom(o,e);return l?Vd(t,l):!1}return!1}function S9(t,e){if(!(t.state.selection instanceof gn))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 N9(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function ZHe(t){if(!Ss||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;N9(t,r,"true"),setTimeout(()=>N9(t,r,"false"),20)}return!1}function JHe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function e$e(t,e){let n=e.keyCode,r=JHe(e);if(n==8||Xo&&n==72&&r=="c")return S9(t,-1)||ng(t,-1);if(n==46&&!e.shiftKey||Xo&&n==68&&r=="c")return S9(t,1)||ng(t,1);if(n==13||n==27)return!0;if(n==37||Xo&&n==66&&r=="c"){let i=n==37?w9(t,t.state.selection.from)=="ltr"?-1:1:-1;return v9(t,i,r)||ng(t,i)}else if(n==39||Xo&&n==70&&r=="c"){let i=n==39?w9(t,t.state.selection.from)=="ltr"?1:-1:1;return v9(t,i,r)||ng(t,i)}else{if(n==38||Xo&&n==80&&r=="c")return _9(t,-1,r)||ng(t,-1);if(n==40||Xo&&n==78&&r=="c")return ZHe(t)||_9(t,1,r)||ng(t,1);if(r==(Xo?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function CL(t,e){t.someProp("transformCopied",m=>{e=m(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 m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let o=t.someProp("clipboardSerializer")||Dm.fromSchema(t.state.schema),l=Kte(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,h=0;for(;u&&u.nodeType==1&&(d=Wte[u.nodeName.toLowerCase()]);){for(let m=d.length-1;m>=0;m--){let x=l.createElement(d[m]);for(;c.firstChild;)x.appendChild(c.firstChild);c.appendChild(x),h++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${s}${h?` -${h}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
  8148. `);return{dom:c,text:p,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",p=>{e=p(e,s||r,t)}),s)return l=new zt(kt.from(t.state.schema.text(e.replace(/\r\n?/g,`
  8149. `))),0,0),t.someProp("transformPasted",p=>{l=p(l,t,!0)}),l;let h=t.someProp("clipboardTextParser",p=>p(e,i,r,t));if(h)l=h;else{let p=i.marks(),{schema:m}=t.state,x=Dm.fromSchema(m);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let v=o.appendChild(document.createElement("p"));y&&v.appendChild(x.serializeNode(m.text(y,p)))})}}else t.someProp("transformPastedHTML",h=>{n=h(n,t)}),o=i$e(n),yv&&a$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 h=+d[3];h>0;h--){let p=o.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;o=p}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||T0.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!t$e.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=s$e(M9(l,+d[1],+d[2]),d[4]);else if(l=zt.maxOpen(n$e(l.content,i),!0),l.openStart||l.openEnd){let h=0,p=0;for(let m=l.content.firstChild;h<l.openStart&&!m.type.spec.isolating;h++,m=m.firstChild);for(let m=l.content.lastChild;p<l.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);l=M9(l,h,p)}return t.someProp("transformPasted",h=>{l=h(l,t,c)}),l}const t$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 n$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&&Gte(c,s,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=qte(o[o.length-1],s.length));let d=Vte(l,c);o.push(d),i=i.matchType(d.type),s=c}}),o)return kt.from(o)}return t}function Vte(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,kt.from(t));return t}function Gte(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=Gte(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(kt.from(Vte(n,t,i+1))))}}function qte(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,qte(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(kt.empty,!0);return t.copy(n.append(r))}function HD(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=HD(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(kt.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function M9(t,e,n){return e<t.openStart&&(t=new zt(HD(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new zt(HD(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Wte={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let k9=null;function Kte(){return k9||(k9=document.implementation.createHTMLDocument("title"))}let wj=null;function r$e(t){let e=window.trustedTypes;return e?(wj||(wj=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),wj.createHTML(t)):t}function i$e(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Kte().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&Wte[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=r$e(t),i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function a$e(t){let e=t.querySelectorAll(Ja?"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 s$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=kt.from(c.create(r[l+1],i)),s++,o++}return new zt(i,s,o)}const Ns={},Ms={},o$e={touchstart:!0,touchmove:!0};class l$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 c$e(t){for(let e in Ns){let n=Ns[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{d$e(t,r)&&!jL(t,r)&&(t.editable||!(r.type in Ms))&&n(t,r)},o$e[e]?{passive:!0}:void 0)}Ss&&t.dom.addEventListener("input",()=>null),$D(t)}function rh(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function u$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 $D(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>jL(t,r))})}function jL(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function d$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 h$e(t,e){!jL(t,e)&&Ns[e.type]&&(t.editable||!(e.type in Ms))&&Ns[e.type](t,e)}Ms.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Yte(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Mu&&Ja&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),hx&&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,jf(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||e$e(t,n)?n.preventDefault():rh(t,"key")};Ms.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ms.keypress=(t,e)=>{let n=e;if(Yte(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Xo&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof gn)||!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 C2(t){return{left:t.clientX,top:t.clientY}}function f$e(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function PL(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 Fg(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 m$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)?(Fg(t,new Zt(n)),!0):!1}function p$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?(Fg(t,Zt.create(t.state.doc,i)),!0):!1}function g$e(t,e,n,r,i){return PL(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?p$e(t,n):m$e(t,n))}function x$e(t,e,n,r){return PL(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function b$e(t,e,n,r){return PL(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||y$e(t,n,r)}function y$e(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Fg(t,gn.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)Fg(t,gn.create(r,l+1,l+1+o.content.size));else if(Zt.isSelectable(o))Fg(t,Zt.create(r,l));else continue;return!0}}function DL(t){return gN(t)}const Xte=Xo?"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&&f$e(n,t.input.lastClick)&&!n[Xte]&&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(C2(n));o&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new v$e(t,o,n,!!r)):(s=="doubleClick"?x$e:b$e)(t,o.pos,o.inside,n)?n.preventDefault():rh(t,"pointer"))};class v$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[Xte],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&&ol&&!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)),rh(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(()=>Ru(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(C2(e))),this.updateAllowDefault(e),this.allowDefault||!n?rh(this.view,"pointer"):g$e(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ss&&this.mightDrag&&!this.mightDrag.node.isAtom||Ja&&!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)?(Fg(this.view,jn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):rh(this.view,"pointer")}move(e){this.updateAllowDefault(e),rh(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),rh(t,"pointer")};Ns.touchmove=t=>{t.input.lastTouch=Date.now(),rh(t,"pointer")};Ns.contextmenu=t=>DL(t);function Yte(t,e){return t.composing?!0:Ss&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const w$e=Mu?5e3:-1;Ms.compositionstart=Ms.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof gn&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),gN(t,!0),t.markCursor=null;else if(gN(t,!e.selection.empty),ol&&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}Qte(t,w$e)};Ms.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++,Qte(t,20))};function Qte(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>gN(t),e))}function Zte(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=S$e());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function _$e(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=mHe(e.focusNode,e.focusOffset),r=pHe(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 S$e(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function gN(t,e=!1){if(!(Mu&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Zte(t),e||t.docView&&t.docView.dirty){let n=TL(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 N$e(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const ky=Vs&&ph<15||hx&&vHe<604;Ns.copy=Ms.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=ky?null:n.clipboardData,o=r.content(),{dom:l,text:c}=CL(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",c)):N$e(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function M$e(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function k$e(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Ey(t,r.value,null,i,e):Ey(t,r.textContent,r.innerHTML,i,e)},50)}function Ey(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||zt.empty)))return!0;if(!s)return!1;let o=M$e(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," "):""}Ms.paste=(t,e)=>{let n=e;if(t.composing&&!Mu)return;let r=ky?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Ey(t,Jte(r),r.getData("text/html"),i,n)?n.preventDefault():k$e(t,n)};class ene{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const E$e=Xo?"altKey":"ctrlKey";function tne(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[E$e]}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(C2(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 h=t.docView.nearestDesc(n.target,!0);h&&h.node.type.spec.draggable&&h!=t.docView&&(o=Zt.create(t.state.doc,h.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=CL(t,l);(!n.dataTransfer.files.length||!Ja||Ete>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(ky?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",ky||n.dataTransfer.setData("text/plain",u),t.dragging=new ene(d,tne(t,n),o)};Ns.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ms.dragover=Ms.dragenter=(t,e)=>e.preventDefault();Ms.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(C2(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),ky?null:n.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&tne(t,n));if(t.someProp("handleDrop",x=>x(t,n,o||zt.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let c=o?ste(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),h=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,p=u.doc;if(h?u.replaceRangeWith(d,d,o.content.firstChild):u.replaceRange(d,d,o),u.doc.eq(p))return;let m=u.doc.resolve(d);if(h&&Zt.isSelectable(o.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new Zt(m));else{let x=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((y,v,b,S)=>x=S),u.setSelection(AL(t,m,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())&&Ru(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(Ja&&Mu&&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,jf(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 Ms)Ns[t]=Ms[t];function Ty(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 xN{constructor(e,n){this.toDOM=e,this.spec=n||Jf,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 gs(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof xN&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ty(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class xh{constructor(e,n){this.attrs=e,this.spec=n||Jf}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 gs(s,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof xh&&Ty(this.attrs,e.attrs)&&Ty(this.spec,e.spec)}static is(e){return e.type instanceof xh}destroy(){}}class RL{constructor(e,n){this.attrs=e,this.spec=n||Jf}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 gs(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 RL&&Ty(this.attrs,e.attrs)&&Ty(this.spec,e.spec)}destroy(){}}class gs{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new gs(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 gs(e,e,new xN(n,r))}static inline(e,n,r,i){return new gs(e,n,new xh(r,i))}static node(e,n,r,i){return new gs(e,n,new RL(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof xh}get widget(){return this.type instanceof xN}}const ug=[],Jf={};class oi{constructor(e,n){this.local=e.length?e:ug,this.children=n.length?n:ug}static create(e,n){return n.length?bN(n,e,0,Jf):Ya}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==Ya||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Jf)}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?T$e(this.children,o||[],e,n,r,i,s):o?new oi(o.sort(em),ug):Ya}add(e,n){return n.length?this==Ya?oi.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=rne(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,bN(d,l,u+1,Jf)),s+=3}});let o=nne(s?ine(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new oi(o.length?this.local.concat(o).sort(em):this.local,i||this.children)}remove(e){return e.length==0||this==Ya?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,h;d<e.length;d++)(h=e[d])&&h.from>l&&h.to<c&&(e[d]=null,(o||(o=[])).push(h));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[s+2].removeInner(o,l+1);u!=Ya?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 oi(i,r):Ya}forChild(e,n){if(this==Ya)return this;if(n.isLeaf)return oi.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 xh){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 oi(i.sort(em),ug);return r?new Yd([l,r]):l}return r||Ya}eq(e){if(this==e)return!0;if(!(e instanceof oi)||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 OL(this.localsInner(e))}localsInner(e){if(this==Ya)return ug;if(e.inlineContent||!this.local.some(xh.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof xh||n.push(this.local[r]);return n}forEachSet(e){e(this)}}oi.empty=new oi([],[]);oi.removeOverlap=OL;const Ya=oi.empty;class Yd{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Jf));return Yd.from(r)}forChild(e,n){if(n.isLeaf)return oi.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=Ya&&(s instanceof Yd?r=r.concat(s.members):r.push(s))}return Yd.from(r)}eq(e){if(!(e instanceof Yd)||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?OL(r?n:n.sort(em)):ug}static from(e){switch(e.length){case 0:return Ya;case 1:return e[0];default:return new Yd(e.every(n=>n instanceof oi)?e:e.reduce((n,r)=>n.concat(r instanceof oi?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function T$e(t,e,n,r,i,s,o){let l=t.slice();for(let u=0,d=s;u<n.maps.length;u++){let h=0;n.maps[u].forEach((p,m,x,y)=>{let v=y-x-(m-p);for(let b=0;b<l.length;b+=3){let S=l[b+1];if(S<0||p>S+d-h)continue;let N=l[b]+d-h;m>=N?l[b+1]=p<=N?-2:-1:p>=d&&v&&(l[b]+=v,l[b+1]+=v)}h+=v}),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),h=d-i;if(h<0||h>=r.content.size){c=!0;continue}let p=n.map(t[u+1]+s,-1),m=p-i,{index:x,offset:y}=r.content.findIndex(h),v=r.maybeChild(x);if(v&&y==h&&y+v.nodeSize==m){let b=l[u+2].mapInner(n,v,d+1,t[u]+s+1,o);b!=Ya?(l[u]=h,l[u+1]=m,l[u+2]=b):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=A$e(l,t,e,n,i,s,o),d=bN(u,r,0,o);e=d.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,p=0;h<d.children.length;h+=3){let m=d.children[h];for(;p<l.length&&l[p]<m;)p+=3;l.splice(p,0,d.children[h],d.children[h+1],d.children[h+2])}}return new oi(e.sort(em),l)}function nne(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 gs(i.from+e,i.to+e,i.type))}return n}function A$e(t,e,n,r,i,s,o){function l(c,u){for(let d=0;d<c.local.length;d++){let h=c.local[d].map(r,i,u);h?n.push(h):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 rne(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 ine(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function bN(t,e,n,r){let i=[],s=!1;e.forEach((l,c)=>{let u=rne(t,l,c+n);if(u){s=!0;let d=bN(u,l,n+c+1,r);d!=Ya&&i.push(c,c+l.nodeSize,d)}});let o=nne(s?ine(t):t,-n).sort(em);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 oi(o,i):Ya}function em(t,e){return t.from-e.from||t.to-e.to}function OL(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),E9(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),E9(e,i,r.copy(s.from,r.to)));break}}}return e}function E9(t,e,n){for(;e<t.length&&em(n,t[e])>0;)e++;t.splice(e,0,n)}function _j(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Ya&&e.push(r)}),t.cursorWrapper&&e.push(oi.create(t.state.doc,[t.cursorWrapper.deco])),Yd.from(e)}const C$e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},j$e=Vs&&ph<=11;class P$e{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class D$e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new P$e,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);Vs&&ph<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),j$e&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,C$e)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(y9(this.view)){if(this.suppressingSelectionUpdates)return Ru(this.view);if(Vs&&ph<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Nm(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=dx(s))n.add(s);for(let s=e.anchorNode;s;s=dx(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)&&y9(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,c=[];if(e.editable)for(let d=0;d<n.length;d++){let h=this.registerMutation(n[d],c);h&&(s=s<0?h.from:Math.min(h.from,s),o=o<0?h.to:Math.max(h.to,o),h.typeOver&&(l=!0))}if(ol&&c.length){let d=c.filter(h=>h.nodeName=="BR");if(d.length==2){let[h,p]=d;h.parentNode&&h.parentNode.parentNode==p.parentNode?p.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let p of d){let m=p.parentNode;m&&m.nodeName=="LI"&&(!h||L$e(e,h)!=m)&&p.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&&T2(r)&&(u=TL(e))&&u.eq(jn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ru(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),R$e(e)),this.handleDOMChange(s,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ru(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 h=e.addedNodes[d];n.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(Vs&&ph<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:h,nextSibling:p}=e.addedNodes[d];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(s=p)}let o=i&&i.parentNode==e.target?Ua(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=s&&s.parentNode==e.target?Ua(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 T9=new WeakMap,A9=!1;function R$e(t){if(!T9.has(t)&&(T9.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=ol,A9)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."),A9=!0}}function C9(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Nm(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function O$e(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return C9(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?C9(t,n):null}function L$e(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function F$e(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}],T2(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Ja&&t.input.lastKeyCode===8)for(let v=s;v>i;v--){let b=r.childNodes[v-1],S=b.pmViewDesc;if(b.nodeName=="BR"&&!S){s=v;break}if(!S||S.size)break}let h=t.state.doc,p=t.someProp("domParser")||T0.fromSchema(t.state.schema),m=h.resolve(o),x=null,y=p.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:s,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:I$e,context:m});if(u&&u[0].pos!=null){let v=u[0].pos,b=u[1]&&u[1].pos;b==null&&(b=v),x={anchor:v+o,head:b+o}}return{doc:y,sel:x,from:o,to:l}}function I$e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ss&&/^(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||Ss&&/^(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 U$e=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function z$e(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let E=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,P=TL(t,E);if(P&&!t.state.selection.eq(P)){if(Ja&&Mu&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",D=>D(t,jf(13,"Enter"))))return;let A=t.state.tr.setSelection(P);E=="pointer"?A.setMeta("pointer",!0):E=="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=F$e(t,e,n),d=t.state.doc,h=d.slice(u.from,u.to),p,m;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(p=t.state.selection.to,m="end"):(p=t.state.selection.from,m="start"),t.input.lastKeyCode=null;let x=$$e(h.content,u.doc.content,u.from,p,m);if(x&&t.input.domChangeCount++,(hx&&t.input.lastIOSEnter>Date.now()-225||Mu)&&i.some(E=>E.nodeType==1&&!U$e.test(E.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",E=>E(t,jf(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof gn&&!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 E=j9(t,t.state.doc,u.sel);if(E&&!E.eq(t.state.selection)){let P=t.state.tr.setSelection(E);s&&P.setMeta("composition",s),t.dispatch(P)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof gn&&(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)),Vs&&ph<=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),v=u.doc.resolveNoCache(x.endB-u.from),b=d.resolve(x.start),S=y.sameParent(v)&&y.parent.inlineContent&&b.end()>=x.endA;if((hx&&t.input.lastIOSEnter>Date.now()-225&&(!S||i.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!S&&y.pos<u.doc.content.size&&(!y.sameParent(v)||!y.parent.inlineContent)&&y.pos<v.pos&&!/\S/.test(u.doc.textBetween(y.pos,v.pos,"","")))&&t.someProp("handleKeyDown",E=>E(t,jf(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&H$e(d,x.start,x.endA,y,v)&&t.someProp("handleKeyDown",E=>E(t,jf(8,"Backspace")))){Mu&&Ja&&t.domObserver.suppressSelectionUpdates();return}Ja&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),Mu&&!S&&y.start()!=v.start()&&v.parentOffset==0&&y.depth==v.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==x.endA&&(x.endB-=2,v=u.doc.resolveNoCache(x.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(E){return E(t,jf(13,"Enter"))})},20));let N=x.start,T=x.endA,k=E=>{let P=E||t.state.tr.replace(N,T,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let A=j9(t,P.doc,u.sel);A&&!(Ja&&t.composing&&A.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(A.head==N||A.head==P.mapping.map(T)-1)||Vs&&A.empty&&A.head==N)&&P.setSelection(A)}return s&&P.setMeta("composition",s),P.scrollIntoView()},C;if(S)if(y.pos==v.pos){Vs&&ph<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ru(t),20));let E=k(t.state.tr.delete(N,T)),P=d.resolve(x.start).marksAcross(d.resolve(x.endA));P&&E.ensureMarks(P),t.dispatch(E)}else if(x.endA==x.endB&&(C=B$e(y.parent.content.cut(y.parentOffset,v.parentOffset),b.parent.content.cut(b.parentOffset,x.endA-b.start())))){let E=k(t.state.tr);C.type=="add"?E.addMark(N,T,C.mark):E.removeMark(N,T,C.mark),t.dispatch(E)}else if(y.parent.child(y.index()).isText&&y.index()==v.index()-(v.textOffset?0:1)){let E=y.parent.textBetween(y.parentOffset,v.parentOffset),P=()=>k(t.state.tr.insertText(E,N,T));t.someProp("handleTextInput",A=>A(t,N,T,E,P))||t.dispatch(P())}else t.dispatch(k());else t.dispatch(k())}function j9(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:AL(t,e.resolve(n.anchor),e.resolve(n.head))}function B$e(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(kt.from(u).eq(t))return{mark:l,type:o}}function H$e(t,e,n,r,i){if(n-e<=i.pos-r.pos||Sj(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(Sj(s,!0,!0));return!o.parent.isTextblock||o.pos>n||Sj(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Sj(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 $$e(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&&P9(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&&P9(t.textBetween(s-1,s+1))&&(s+=c?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function P9(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 ane{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 l$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(F9),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=O9(this),R9(this),this.nodeViews=L9(this),this.docView=f9(this.state.doc,D9(this),_j(this),this.dom,this),this.domObserver=new D$e(this,(r,i,s,o)=>z$e(this,r,i,s,o)),this.domObserver.start(),c$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&&$D(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(F9),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&&(Zte(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 m=L9(this);G$e(m,this.nodeViews)&&(this.nodeViews=m,s=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&$D(this),this.editable=O9(this),R9(this);let c=_j(this),u=D9(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",h=s||!this.docView.matchesNode(e.doc,u,c);(h||!e.selection.eq(i.selection))&&(o=!0);let p=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&SHe(this);if(o){this.domObserver.stop();let m=h&&(Vs||Ja)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&V$e(i.selection,e.selection);if(h){let x=Ja?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=_$e(this)),(s||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=f9(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&WHe(this))?Ru(this,m):(zte(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():p&&NHe(p)}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&&o9(this,n.getBoundingClientRect(),e)}else o9(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 ene(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(Vs){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&&MHe(this.dom),Ru(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 CHe(this,e)}coordsAtPos(e,n=1){return Pte(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 OHe(this,n||this.state,e)}pasteHTML(e,n){return Ey(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Ey(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return CL(this,e)}destroy(){this.docView&&(u$e(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],_j(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,hHe())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return h$e(this,e)}domSelectionRange(){let e=this.domSelection();return e?Ss&&this.root.nodeType===11&&xHe(this.dom.ownerDocument)==this.dom&&O$e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}ane.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function D9(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"),[gs.node(0,t.state.doc.content.size,e)]}function R9(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:gs.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function O9(t){return!t.someProp("editable",e=>e(t.state)===!1)}function V$e(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function L9(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 G$e(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 F9(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 Rh={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:"'"},yN={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},q$e=typeof navigator<"u"&&/Mac/.test(navigator.platform),W$e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var za=0;za<10;za++)Rh[48+za]=Rh[96+za]=String(za);for(var za=1;za<=24;za++)Rh[za+111]="F"+za;for(var za=65;za<=90;za++)Rh[za]=String.fromCharCode(za+32),yN[za]=String.fromCharCode(za);for(var Nj in Rh)yN.hasOwnProperty(Nj)||(yN[Nj]=Rh[Nj]);function K$e(t){var e=q$e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||W$e&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?yN:Rh)[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 X$e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Y$e=typeof navigator<"u"&&/Win/.test(navigator.platform);function Q$e(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))X$e?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 Z$e(t){let e=Object.create(null);for(let n in t)e[Q$e(n)]=t[n];return e}function Mj(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 J$e(t){return new di({props:{handleKeyDown:sne(t)}})}function sne(t){let e=Z$e(t);return function(n,r){let i=K$e(r),s,o=e[Mj(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Mj(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Y$e&&r.ctrlKey&&r.altKey)&&(s=Rh[r.keyCode])&&s!=i){let l=e[Mj(s,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var eVe=Object.defineProperty,LL=(t,e)=>{for(var n in e)eVe(t,n,{get:e[n],enumerable:!0})};function j2(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 P2=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(h=>h===!0)),d={...Object.fromEntries(Object.entries(n).map(([h,p])=>[h,(...x)=>{const y=this.buildProps(c,e),v=p(...x)(y);return o.push(v),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:j2({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}},one={};LL(one,{blur:()=>tVe,clearContent:()=>nVe,clearNodes:()=>rVe,command:()=>iVe,createParagraphNear:()=>aVe,cut:()=>sVe,deleteCurrentNode:()=>oVe,deleteNode:()=>lVe,deleteRange:()=>cVe,deleteSelection:()=>uVe,enter:()=>dVe,exitCode:()=>hVe,extendMarkRange:()=>fVe,first:()=>mVe,focus:()=>gVe,forEach:()=>xVe,insertContent:()=>bVe,insertContentAt:()=>wVe,joinBackward:()=>NVe,joinDown:()=>SVe,joinForward:()=>MVe,joinItemBackward:()=>kVe,joinItemForward:()=>EVe,joinTextblockBackward:()=>TVe,joinTextblockForward:()=>AVe,joinUp:()=>_Ve,keyboardShortcut:()=>jVe,lift:()=>PVe,liftEmptyBlock:()=>DVe,liftListItem:()=>RVe,newlineInCode:()=>OVe,resetAttributes:()=>LVe,scrollIntoView:()=>FVe,selectAll:()=>IVe,selectNodeBackward:()=>UVe,selectNodeForward:()=>zVe,selectParentNode:()=>BVe,selectTextblockEnd:()=>HVe,selectTextblockStart:()=>$Ve,setContent:()=>VVe,setMark:()=>lGe,setMeta:()=>cGe,setNode:()=>uGe,setNodeSelection:()=>dGe,setTextDirection:()=>hGe,setTextSelection:()=>fGe,sinkListItem:()=>mGe,splitBlock:()=>pGe,splitListItem:()=>gGe,toggleList:()=>xGe,toggleMark:()=>bGe,toggleNode:()=>yGe,toggleWrap:()=>vGe,undoInputRule:()=>wGe,unsetAllMarks:()=>_Ge,unsetMark:()=>SGe,unsetTextDirection:()=>NGe,updateAttributes:()=>MGe,wrapIn:()=>kGe,wrapInList:()=>EGe});var tVe=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),nVe=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),rVe=()=>({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,h=u.resolve(d.map(c)),p=u.resolve(d.map(c+l.nodeSize)),m=h.blockRange(p);if(!m)return;const x=Fx(m);if(l.type.isTextblock){const{defaultType:y}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(m.start,y)}(x||x===0)&&e.lift(m,x)})}),!0},iVe=t=>e=>t(e),aVe=()=>({state:t,dispatch:e})=>_te(t,e),sVe=(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 gn(r.doc.resolve(Math.max(o-1,0)))),!0},oVe=()=>({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 Ki(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 lVe=t=>({tr:e,state:n,dispatch:r})=>{const i=Ki(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},cVe=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},uVe=()=>({state:t,dispatch:e})=>_L(t,e),dVe=()=>({commands:t})=>t.keyboardShortcut("Enter"),hVe=()=>({state:t,dispatch:e})=>Q6e(t,e);function FL(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function vN(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:FL(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function lne(t,e,n={}){return t.find(r=>r.type===e&&vN(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function I9(t,e,n={}){return!!lne(t,e,n)}function IL(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),!lne([...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&&I9([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&I9([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function Qu(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 fVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=Qu(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const h=IL(c,s,e);if(h&&h.from<=u&&h.to>=d){const p=gn.create(o,h.from,h.to);n.setSelection(p)}}return!0},mVe=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 cne(t){return t instanceof gn}function zf(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function une(t,e=null){if(!e)return null;const n=jn.atStart(t),r=jn.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?gn.create(t,zf(0,i,s),zf(t.content.size,i,s)):gn.create(t,zf(e,i,s),zf(e,i,s))}function pVe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function UL(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var gVe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(UL()||pVe())&&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&&!cne(n.state.selection))return o(),!0;const l=une(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},xVe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),bVe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),dne=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&&dne(r)}return t};function r1(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 dne(n)}function Ay(t,e,n){if(t instanceof mh||t instanceof kt)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 kt.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),Ay("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new Xee({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?T0.fromSchema(c).parseSlice(r1(t),n.parseOptions):T0.fromSchema(c).parse(r1(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=T0.fromSchema(e);return n.slice?s.parseSlice(r1(t),n.parseOptions).content:s.parse(r1(t),n.parseOptions)}return Ay("",e,n)}function yVe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof va||i instanceof Na))return;const s=t.mapping.maps[r];let o=0;s.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(jn.near(t.doc.resolve(o),n))}var vVe=t=>!("type"in t),wVe=(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=v=>{s.emit("contentError",{editor:s,error:v,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{Ay(e,s.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(v){c(v)}try{l=Ay(e,s.schema,{parseOptions:u,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(v){return c(v),!1}let{from:d,to:h}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},p=!0,m=!0;if((vVe(l)?l:[l]).forEach(v=>{v.check(),p=p?v.isText&&v.marks.length===0:!1,m=m?v.isBlock:!1}),d===h&&m){const{parent:v}=r.doc.resolve(d);v.isTextblock&&!v.type.spec.code&&!v.childCount&&(d-=1,h+=1)}let y;if(p){if(Array.isArray(e))y=e.map(v=>v.text||"").join("");else if(e instanceof kt){let v="";e.forEach(b=>{b.text&&(v+=b.text)}),y=v}else typeof e=="object"&&e&&e.text?y=e.text:y=e;r.insertText(y,d,h)}else{y=l;const v=r.doc.resolve(d),b=v.node(),S=v.parentOffset===0,N=b.isText||b.isTextblock,T=b.content.size>0;S&&N&&T&&(d=Math.max(0,d-1)),r.replaceWith(d,h,y)}n.updateSelection&&yVe(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},_Ve=()=>({state:t,dispatch:e})=>K6e(t,e),SVe=()=>({state:t,dispatch:e})=>X6e(t,e),NVe=()=>({state:t,dispatch:e})=>pte(t,e),MVe=()=>({state:t,dispatch:e})=>yte(t,e),kVe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=M2(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},EVe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=M2(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},TVe=()=>({state:t,dispatch:e})=>q6e(t,e),AVe=()=>({state:t,dispatch:e})=>W6e(t,e);function hne(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function CVe(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))UL()||hne()?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 jVe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=CVe(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?Ki(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(h,p)=>{if(h.isText)return;const m=Math.max(r,p),x=Math.min(i,p+h.nodeSize);l.push({node:h,from:m,to:x})});const c=i-r,u=l.filter(h=>o?o.name===h.node.type.name:!0).filter(h=>vN(h.node.attrs,n,{strict:!1}));return s?!!u.length:u.reduce((h,p)=>h+p.to-p.from,0)>=c}var PVe=(t,e={})=>({state:n,dispatch:r})=>{const i=Ki(t,n.schema);return Oh(n,i,e)?Y6e(n,r):!1},DVe=()=>({state:t,dispatch:e})=>Ste(t,e),RVe=t=>({state:e,dispatch:n})=>{const r=Ki(t,e.schema);return lHe(r)(e,n)},OVe=()=>({state:t,dispatch:e})=>wte(t,e);function D2(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function U9(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 LVe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=D2(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=Ki(t,r.schema)),l==="mark"&&(o=Qu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,h)=>{s&&s===d.type&&(c=!0,i&&n.setNodeMarkup(h,void 0,U9(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(p=>{o===p.type&&(c=!0,i&&n.addMark(h,h+d.nodeSize,o.create(U9(p.attrs,e))))})})}),c},FVe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),IVe=()=>({tr:t,dispatch:e})=>{if(e){const n=new wo(t.doc);t.setSelection(n)}return!0},UVe=()=>({state:t,dispatch:e})=>xte(t,e),zVe=()=>({state:t,dispatch:e})=>vte(t,e),BVe=()=>({state:t,dispatch:e})=>eHe(t,e),HVe=()=>({state:t,dispatch:e})=>rHe(t,e),$Ve=()=>({state:t,dispatch:e})=>nHe(t,e);function VD(t,e,n={},r={}){return Ay(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var VVe=(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=VD(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 fne(t,e){const n=Qu(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 mne(t,e){const n=new dte(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function GVe(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 qVe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function WVe(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 R2(t){return e=>WVe(e.$from,t)}function Xt(t,e,n){return t.config[e]===void 0&&t.parent?Xt(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Xt(t.parent,e,n):null}):t.config[e]}function zL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Xt(e,"addExtensions",n);return r?[e,...zL(r())]:e}).flat(10)}function BL(t,e){const n=Dm.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function pne(t){return typeof t=="function"}function xr(t,e=void 0,...n){return pne(t)?e?t.bind(e)(...n):t(...n):t}function KVe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function fx(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 gne(t){const e=[],{nodeExtensions:n,markExtensions:r}=fx(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=Xt(o,"addGlobalAttributes",l);if(!c)return;c().forEach(d=>{d.types.forEach(h=>{Object.entries(d.attributes).forEach(([p,m])=>{e.push({type:h,name:p,attribute:{...s,...m}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},c=Xt(o,"addAttributes",l);if(!c)return;const u=c();Object.entries(u).forEach(([d,h])=>{const p={...s,...h};typeof p?.default=="function"&&(p.default=p.default()),p?.isRequired&&p?.default===void 0&&delete p.default,e.push({type:o.name,name:d,attribute:p})})}),e}function _i(...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[h,p]=d.split(":").map(m=>m.trim());u.set(h,p)}),l.forEach(d=>{const[h,p]=d.split(":").map(m=>m.trim());u.set(h,p)}),r[i]=Array.from(u.entries()).map(([d,h])=>`${d}: ${h}`).join("; ")}else r[i]=s}),r},{})}function wN(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)=>_i(n,r),{})}function XVe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function z9(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):XVe(n.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function B9(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&KVe(n)?!1:n!=null))}function H9(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 YVe(t,e){var n;const r=gne(t),{nodeExtensions:i,markExtensions:s}=fx(t),o=(n=i.find(u=>Xt(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(b=>b.type===u.name),h={name:u.name,options:u.options,storage:u.storage,editor:e},p=t.reduce((b,S)=>{const N=Xt(S,"extendNodeSchema",h);return{...b,...N?N(u):{}}},{}),m=B9({...p,content:xr(Xt(u,"content",h)),marks:xr(Xt(u,"marks",h)),group:xr(Xt(u,"group",h)),inline:xr(Xt(u,"inline",h)),atom:xr(Xt(u,"atom",h)),selectable:xr(Xt(u,"selectable",h)),draggable:xr(Xt(u,"draggable",h)),code:xr(Xt(u,"code",h)),whitespace:xr(Xt(u,"whitespace",h)),linebreakReplacement:xr(Xt(u,"linebreakReplacement",h)),defining:xr(Xt(u,"defining",h)),isolating:xr(Xt(u,"isolating",h)),attrs:Object.fromEntries(d.map(H9))}),x=xr(Xt(u,"parseHTML",h));x&&(m.parseDOM=x.map(b=>z9(b,d)));const y=Xt(u,"renderHTML",h);y&&(m.toDOM=b=>y({node:b,HTMLAttributes:wN(b,d)}));const v=Xt(u,"renderText",h);return v&&(m.toText=v),[u.name,m]})),c=Object.fromEntries(s.map(u=>{const d=r.filter(v=>v.type===u.name),h={name:u.name,options:u.options,storage:u.storage,editor:e},p=t.reduce((v,b)=>{const S=Xt(b,"extendMarkSchema",h);return{...v,...S?S(u):{}}},{}),m=B9({...p,inclusive:xr(Xt(u,"inclusive",h)),excludes:xr(Xt(u,"excludes",h)),group:xr(Xt(u,"group",h)),spanning:xr(Xt(u,"spanning",h)),code:xr(Xt(u,"code",h)),attrs:Object.fromEntries(d.map(H9))}),x=xr(Xt(u,"parseHTML",h));x&&(m.parseDOM=x.map(v=>z9(v,d)));const y=Xt(u,"renderHTML",h);return y&&(m.toDOM=v=>y({mark:v,HTMLAttributes:wN(v,d)})),[u.name,m]}));return new Xee({topNode:o,nodes:l,marks:c})}function QVe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function HL(t){return t.sort((n,r)=>{const i=Xt(n,"priority")||100,s=Xt(r,"priority")||100;return i>s?-1:i<s?1:0})}function xne(t){const e=HL(zL(t)),n=QVe(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 bne(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`
  8150. `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,h)=>{var p;c.isBlock&&u>r&&(l+=s);const m=o?.[c.type.name];if(m)return d&&(l+=m({node:c,pos:u,parent:d,index:h,range:e})),!1;c.isText&&(l+=(p=c?.text)==null?void 0:p.slice(Math.max(r,u)-u,i-u))}),l}function ZVe(t,e){const n={from:0,to:t.content.size};return bne(t,n,e)}function yne(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=Ki(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 vne(t,e){const n=D2(typeof e=="string"?e:e.name,t.schema);return n==="node"?JVe(t,e):n==="mark"?fne(t,e):{}}function eGe(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 tGe(t){const e=eGe(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 wne(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),h=e.invert().map(u,-1),p=e.invert().map(d);r.push({oldRange:{from:h,to:p},newRange:{from:u,to:d}})})}),tGe(r)}function $L(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t),o=IL(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 nGe=(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 kj(t,e){return e.nodes[t]||e.marks[t]||null}function F1(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 rGe=(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 GD(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?Qu(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>s?s.name===h.type.name:!0).find(h=>vN(h.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:h,$to:p})=>{const m=h.pos,x=p.pos;t.doc.nodesBetween(m,x,(y,v)=>{if(!y.isText&&!y.marks.length)return;const b=Math.max(m,v),S=Math.min(x,v+y.nodeSize),N=S-b;o+=N,l.push(...y.marks.map(T=>({mark:T,from:b,to:S})))})}),o===0)return!1;const c=l.filter(h=>s?s.name===h.mark.type.name:!0).filter(h=>vN(h.mark.attrs,n,{strict:!1})).reduce((h,p)=>h+p.to-p.from,0),u=l.filter(h=>s?h.mark.type!==s&&h.mark.type.excludes(s):!0).reduce((h,p)=>h+p.to-p.from,0);return(c>0?c+u:c)>=o}function iGe(t,e,n={}){if(!e)return Oh(t,null,n)||GD(t,null,n);const r=D2(e,t.schema);return r==="node"?Oh(t,e,n):r==="mark"?GD(t,e,n):!1}var aGe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=R2(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)},sGe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function $9(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function V9(t,e){const{nodeExtensions:n}=fx(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=xr(Xt(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function O2(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&&(O2(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function _ne(t){return t instanceof Zt}function oGe(t,e,n){var r;const{selection:i}=e;let s=null;if(cne(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,h,p)=>{if(u)return!1;if(d.isInline){const m=!p||p.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(y=>y.type.excludes(n));u=m&&x}return!u}),u})}var lGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:l}=s,c=Qu(t,r.schema);if(i)if(o){const u=fne(r,c);n.addStoredMark(c.create({...u,...e}))}else l.forEach(u=>{const d=u.$from.pos,h=u.$to.pos;r.doc.nodesBetween(d,h,(p,m)=>{const x=Math.max(m,d),y=Math.min(m+p.nodeSize,h);p.marks.find(b=>b.type===c)?p.marks.forEach(b=>{c===b.type&&n.addMark(x,y,c.create({...b.attrs,...e}))}):n.addMark(x,y,c.create(e))})});return oGe(r,n,c)},cGe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),uGe=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=Ki(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})=>i9(s,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>i9(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},dGe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=zf(t,0,r.content.size),s=Zt.create(r,i);e.setSelection(s)}return!0},hGe=(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},fGe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,o=gn.atStart(r).from,l=gn.atEnd(r).to,c=zf(i,o,l),u=zf(s,o,l),d=gn.create(r,c,u);e.setSelection(d)}return!0},mGe=t=>({state:e,dispatch:n})=>{const r=Ki(t,e.schema);return dHe(r)(e,n)};function G9(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 pGe=({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=F1(u,l.node().type.name,l.node().attrs);if(s instanceof Zt&&s.node.isBlock)return!l.parentOffset||!Du(o,l.pos)?!1:(r&&(t&&G9(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const h=c.parentOffset===c.parent.content.size,p=l.depth===0?void 0:GVe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let m=h&&p?[{type:p,attrs:d}]:void 0,x=Du(e.doc,e.mapping.map(l.pos),1,m);if(!m&&!x&&Du(e.doc,e.mapping.map(l.pos),1,p?[{type:p}]:void 0)&&(x=!0,m=p?[{type:p,attrs:d}]:void 0),r){if(x&&(s instanceof gn&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,m),p&&!h&&!l.parentOffset&&l.parent.type!==p)){const y=e.mapping.map(l.before()),v=e.doc.resolve(y);l.node(-1).canReplaceWith(v.index(),v.index()+1,p)&&e.setNodeMarkup(e.mapping.map(l.before()),p)}t&&G9(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},gGe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var o;const l=Ki(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 h=c.node(-1);if(h.type!==l)return!1;const p=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 b=kt.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let P=c.depth-S;P>=c.depth-3;P-=1)b=kt.from(c.node(P).copy(b));const N=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,T={...F1(p,c.node().type.name,c.node().attrs),...e},k=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(T))||void 0;b=b.append(kt.from(l.createAndFill(null,k)||void 0));const C=c.before(c.depth-(S-1));n.replace(C,c.after(-N),new zt(b,4-S,0));let E=-1;n.doc.nodesBetween(C,n.doc.content.size,(P,A)=>{if(E>-1)return!1;P.isTextblock&&P.content.size===0&&(E=A+1)}),E>-1&&n.setSelection(gn.near(n.doc.resolve(E))),n.scrollIntoView()}return!0}const m=u.pos===c.end()?h.contentMatchAt(0).defaultType:null,x={...F1(p,h.type.name,h.attrs),...e},y={...F1(p,c.node().type.name,c.node().attrs),...e};n.delete(c.pos,u.pos);const v=m?[{type:l,attrs:x},{type:m,attrs:y}]:[{type:l,attrs:x}];if(!Du(n.doc,c.pos,2))return!1;if(i){const{selection:b,storedMarks:S}=r,{splittableMarks:N}=s.extensionManager,T=S||b.$to.parentOffset&&b.$from.marks();if(n.split(c.pos,2,v).scrollIntoView(),!T||!i)return!0;const k=T.filter(C=>N.includes(C.type.name));n.ensureMarks(k)}return!0},Ej=(t,e)=>{const n=R2(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&&Hh(t.doc,n.pos)&&t.join(n.pos),!0},Tj=(t,e)=>{const n=R2(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&&Hh(t.doc,r)&&t.join(r),!0},xGe=(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:h,splittableMarks:p}=i.extensionManager,m=Ki(t,o.schema),x=Ki(e,o.schema),{selection:y,storedMarks:v}=o,{$from:b,$to:S}=y,N=b.blockRange(S),T=v||y.$to.parentOffset&&y.$from.marks();if(!N)return!1;const k=R2(C=>V9(C.type.name,h))(y);if(N.depth>=1&&k&&N.depth-k.depth<=1){if(k.node.type===m)return u.liftListItem(x);if(V9(k.node.type.name,h)&&m.validContent(k.node.content)&&l)return c().command(()=>(s.setNodeMarkup(k.pos,m),!0)).command(()=>Ej(s,m)).command(()=>Tj(s,m)).run()}return!n||!T||!l?c().command(()=>d().wrapInList(m,r)?!0:u.clearNodes()).wrapInList(m,r).command(()=>Ej(s,m)).command(()=>Tj(s,m)).run():c().command(()=>{const C=d().wrapInList(m,r),E=T.filter(P=>p.includes(P.type.name));return s.ensureMarks(E),C?!0:u.clearNodes()}).wrapInList(m,r).command(()=>Ej(s,m)).command(()=>Tj(s,m)).run()},bGe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=Qu(t,r.schema);return GD(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},yGe=(t,e,n={})=>({state:r,commands:i})=>{const s=Ki(t,r.schema),o=Ki(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})},vGe=(t,e={})=>({state:n,commands:r})=>{const i=Ki(t,n.schema);return Oh(n,i,e)?r.lift(i):r.wrapIn(i,e)},wGe=()=>({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},_Ge=()=>({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},SGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=Qu(t,r.schema),{$from:u,empty:d,ranges:h}=l;if(!i)return!0;if(d&&o){let{from:p,to:m}=l;const x=(s=u.marks().find(v=>v.type===c))==null?void 0:s.attrs,y=IL(u,c,x);y&&(p=y.from,m=y.to),n.removeMark(p,m,c)}else h.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,c)});return n.removeStoredMark(c),!0},NGe=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},MGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=D2(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=Ki(t,r.schema)),l==="mark"&&(o=Qu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,h=u.$to.pos;let p,m,x,y;n.selection.empty?r.doc.nodesBetween(d,h,(v,b)=>{s&&s===v.type&&(c=!0,x=Math.max(b,d),y=Math.min(b+v.nodeSize,h),p=b,m=v)}):r.doc.nodesBetween(d,h,(v,b)=>{b<d&&s&&s===v.type&&(c=!0,x=Math.max(b,d),y=Math.min(b+v.nodeSize,h),p=b,m=v),b>=d&&b<=h&&(s&&s===v.type&&(c=!0,i&&n.setNodeMarkup(b,void 0,{...v.attrs,...e})),o&&v.marks.length&&v.marks.forEach(S=>{if(o===S.type&&(c=!0,i)){const N=Math.max(b,d),T=Math.min(b+v.nodeSize,h);n.addMark(N,T,o.create({...S.attrs,...e}))}}))}),m&&(p!==void 0&&i&&n.setNodeMarkup(p,void 0,{...m.attrs,...e}),o&&m.marks.length&&m.marks.forEach(v=>{o===v.type&&i&&n.addMark(x,y,o.create({...v.attrs,...e}))}))}),c},kGe=(t,e={})=>({state:n,dispatch:r})=>{const i=Ki(t,n.schema);return iHe(i,e)(n,r)},EGe=(t,e={})=>({state:n,dispatch:r})=>{const i=Ki(t,n.schema);return aHe(i,e)(n,r)},TGe=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={}}},L2=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},AGe=(t,e)=>{if(FL(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function i1(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(p=>p.type.spec.code))return!1;let d=!1;const h=rGe(u)+s;return o.forEach(p=>{if(d)return;const m=AGe(h,p.find);if(!m)return;const x=c.state.tr,y=j2({state:c.state,transaction:x}),v={from:r-(m[0].length-s.length),to:i},{commands:b,chain:S,can:N}=new P2({editor:n,state:y});p.handler({state:y,range:v,match:m,commands:b,chain:S,can:N})===null||!x.steps.length||(p.undoable&&x.setMeta(l,{transform:x,from:r,to:i,text:s}),c.dispatch(x),d=!0)}),d}function CGe(t){const{editor:e,rules:n}=t,r=new di({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=BL(kt.from(d),o.schema);const{from:h}=c,p=h+d.length;i1({editor:e,from:h,to:p,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return i1({editor:e,from:s,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&i1({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?i1({editor:e,from:o.pos,to:o.pos,text:`
  8151. `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function jGe(t){return Object.prototype.toString.call(t).slice(8,-1)}function a1(t){return jGe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Sne(t,e){const n={...t};return a1(t)&&a1(e)&&Object.keys(e).forEach(r=>{a1(e[r])&&a1(t[r])?n[r]=Sne(t[r],e[r]):n[r]=e[r]}),n}var VL=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...xr(Xt(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...xr(Xt(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Sne(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}},Vh=class Nne extends VL{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 PGe(t){return typeof t=="number"}var DGe=class{constructor(t){this.find=t.find,this.handler=t.handler}},RGe=(t,e,n)=>{if(FL(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 OGe(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new P2({editor:e,state:n}),h=[];return n.doc.nodesBetween(r,i,(m,x)=>{var y,v,b,S,N;if((v=(y=m.type)==null?void 0:y.spec)!=null&&v.code||!(m.isText||m.isTextblock||m.isInline))return;const T=(N=(S=(b=m.content)==null?void 0:b.size)!=null?S:m.nodeSize)!=null?N:0,k=Math.max(r,x),C=Math.min(i,x+T);if(k>=C)return;const E=m.isText?m.text||"":m.textBetween(k-x,C-x,void 0,"");RGe(E,s.find,o).forEach(A=>{if(A.index===void 0)return;const D=k+A.index+1,I=D+A[0].length,L={from:n.tr.mapping.map(D),to:n.tr.mapping.map(I)},U=s.handler({state:n,range:L,match:A,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});h.push(U)})}),h.every(m=>m!==null)}var s1=null,LGe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function FGe(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:h,to:p,rule:m,pasteEvt:x})=>{const y=d.tr,v=j2({state:d,transaction:y});if(!(!OGe({editor:e,state:v,from:Math.max(h-1,0),to:p.b-1,rule:m,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 di({view(h){const p=x=>{var y;r=(y=h.dom.parentElement)!=null&&y.contains(x.target)?h.dom.parentElement:null,r&&(s1=e)},m=()=>{s1&&(s1=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(h,p)=>{if(s=r===h.dom.parentElement,l=p,!s){const m=s1;m?.isEditable&&setTimeout(()=>{const x=m.state.selection;x&&m.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(h,p)=>{var m;const x=(m=p.clipboardData)==null?void 0:m.getData("text/html");return o=p,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(h,p,m)=>{const x=h[0],y=x.getMeta("uiEvent")==="paste"&&!i,v=x.getMeta("uiEvent")==="drop"&&!s,b=x.getMeta("applyPasteRules"),S=!!b;if(!y&&!v&&!S)return;if(S){let{text:k}=b;typeof k=="string"?k=k:k=BL(kt.from(k),m.schema);const{from:C}=b,E=C+k.length,P=LGe(k);return c({rule:d,state:m,from:C,to:{b:E},pasteEvt:P})}const N=p.doc.content.findDiffStart(m.doc.content),T=p.doc.content.findDiffEnd(m.doc.content);if(!(!PGe(N)||!T||N===T.b))return c({rule:d,state:m,from:N,to:T,pasteEvt:o})}}))}var F2=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=xne(t),this.schema=YVe(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:kj(e.name,this.schema)},r=Xt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return HL([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:kj(r.name,this.schema)},s=[],o=Xt(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&Xt(r,"exitable",i)&&(l.ArrowRight=()=>Vh.handleExit({editor:t,mark:r})),o){const p=Object.fromEntries(Object.entries(o()).map(([m,x])=>[m,()=>x({editor:t})]));l={...l,...p}}const c=J$e(l);s.push(c);const u=Xt(r,"addInputRules",i);if($9(r,t.options.enableInputRules)&&u){const p=u();if(p&&p.length){const m=CGe({editor:t,rules:p}),x=Array.isArray(m)?m:[m];s.push(...x)}}const d=Xt(r,"addPasteRules",i);if($9(r,t.options.enablePasteRules)&&d){const p=d();if(p&&p.length){const m=FGe({editor:t,rules:p});s.push(...m)}}const h=Xt(r,"addProseMirrorPlugins",i);if(h){const p=h();s.push(...p)}return s})}get attributes(){return gne(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=fx(this.extensions);return Object.fromEntries(e.filter(n=>!!Xt(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:Ki(n.name,this.schema)},s=Xt(n,"addNodeView",i);if(!s)return[];const o=s();if(!o)return[];const l=(c,u,d,h,p)=>{const m=wN(c,r);return o({node:c,view:u,getPos:d,decorations:h,innerDecorations:p,editor:t,extension:n,HTMLAttributes:m})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=fx(this.extensions);return Object.fromEntries(e.filter(n=>!!Xt(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:Qu(n.name,this.schema)},s=Xt(n,"addMarkView",i);if(!s)return[];const o=(l,c,u)=>{const d=wN(l,r);return s()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:h=>{ZGe(l,t,h)}})};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:kj(e.name,this.schema)};e.type==="mark"&&((n=xr(Xt(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const i=Xt(e,"onBeforeCreate",r),s=Xt(e,"onCreate",r),o=Xt(e,"onUpdate",r),l=Xt(e,"onSelectionUpdate",r),c=Xt(e,"onTransaction",r),u=Xt(e,"onFocus",r),d=Xt(e,"onBlur",r),h=Xt(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),h&&this.editor.on("destroy",h)})}};F2.resolve=xne;F2.sort=HL;F2.flatten=zL;var IGe={};LL(IGe,{ClipboardTextSerializer:()=>kne,Commands:()=>Ene,Delete:()=>Tne,Drop:()=>Ane,Editable:()=>Cne,FocusEvents:()=>Pne,Keymap:()=>Dne,Paste:()=>Rne,Tabindex:()=>One,TextDirection:()=>Lne,focusEventsPluginKey:()=>jne});var jr=class Mne extends VL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Mne(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},kne=jr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new di({key:new ua("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=yne(n);return bne(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),Ene=jr.create({name:"commands",addCommands(){return{...one}}}),Tne=jr.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=mne(t.before,[t,...e]);wne(d).forEach(m=>{d.mapping.mapResult(m.oldRange.from).deletedAfter&&d.mapping.mapResult(m.oldRange.to).deletedBefore&&d.before.nodesBetween(m.oldRange.from,m.oldRange.to,(x,y)=>{const v=y+x.nodeSize-2,b=m.oldRange.from<=y&&v<=m.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:y,to:v,newFrom:d.mapping.map(y),newTo:d.mapping.map(v),deletedRange:m.oldRange,newRange:m.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:d})})});const p=d.mapping;d.steps.forEach((m,x)=>{var y,v;if(m instanceof Fl){const b=p.slice(x).map(m.from,-1),S=p.slice(x).map(m.to),N=p.invert().map(b,-1),T=p.invert().map(S),k=(y=d.doc.nodeAt(b-1))==null?void 0:y.marks.some(E=>E.eq(m.mark)),C=(v=d.doc.nodeAt(S))==null?void 0:v.marks.some(E=>E.eq(m.mark));this.editor.emit("delete",{type:"mark",mark:m.mark,from:m.from,to:m.to,deletedRange:{from:N,to:T},newRange:{from:b,to:S},partial:!!(C||k),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()}}),Ane=jr.create({name:"drop",addProseMirrorPlugins(){return[new di({key:new ua("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Cne=jr.create({name:"editable",addProseMirrorPlugins(){return[new di({key:new ua("editable"),props:{editable:()=>this.editor.options.editable}})]}}),jne=new ua("focusEvents"),Pne=jr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new di({key:jne,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=jr.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:h}=c,{pos:p,parent:m}=h,x=h.parent.isTextblock&&p>0?l.doc.resolve(p-1):h,y=x.parent.type.spec.isolating,v=h.pos-h.parentOffset,b=y&&x.parent.childCount===1?v===h.pos:jn.atStart(u).from===p;return!d||!m.type.isTextblock||m.textContent.length||!b||b&&h.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 UL()||hne()?s:i},addProseMirrorPlugins(){return[new di({key:new ua("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=jn.atStart(e.doc).from,u=jn.atEnd(e.doc).to;if(s||!(o===c&&l===u)||!O2(n.doc))return;const p=n.tr,m=j2({state:n,transaction:p}),{commands:x}=new P2({editor:this.editor,state:m});if(x.clearNodes(),!!p.steps.length)return p}})]}}),Rne=jr.create({name:"paste",addProseMirrorPlugins(){return[new di({key:new ua("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),One=jr.create({name:"tabindex",addProseMirrorPlugins(){return[new di({key:new ua("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Lne=jr.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=fx(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 di({key:new ua("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),UGe=class dg{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 dg(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 dg(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 dg(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 dg(l,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new dg(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)}},zGe=`.ProseMirror {
  8152. position: relative;
  8153. }
  8154. .ProseMirror {
  8155. word-wrap: break-word;
  8156. white-space: pre-wrap;
  8157. white-space: break-spaces;
  8158. -webkit-font-variant-ligatures: none;
  8159. font-variant-ligatures: none;
  8160. font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
  8161. }
  8162. .ProseMirror [contenteditable="false"] {
  8163. white-space: normal;
  8164. }
  8165. .ProseMirror [contenteditable="false"] [contenteditable="true"] {
  8166. white-space: pre-wrap;
  8167. }
  8168. .ProseMirror pre {
  8169. white-space: pre-wrap;
  8170. }
  8171. img.ProseMirror-separator {
  8172. display: inline !important;
  8173. border: none !important;
  8174. margin: 0 !important;
  8175. width: 0 !important;
  8176. height: 0 !important;
  8177. }
  8178. .ProseMirror-gapcursor {
  8179. display: none;
  8180. pointer-events: none;
  8181. position: absolute;
  8182. margin: 0;
  8183. }
  8184. .ProseMirror-gapcursor:after {
  8185. content: "";
  8186. display: block;
  8187. position: absolute;
  8188. top: -2px;
  8189. width: 20px;
  8190. border-top: 1px solid black;
  8191. animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
  8192. }
  8193. @keyframes ProseMirror-cursor-blink {
  8194. to {
  8195. visibility: hidden;
  8196. }
  8197. }
  8198. .ProseMirror-hideselection *::selection {
  8199. background: transparent;
  8200. }
  8201. .ProseMirror-hideselection *::-moz-selection {
  8202. background: transparent;
  8203. }
  8204. .ProseMirror-hideselection * {
  8205. caret-color: transparent;
  8206. }
  8207. .ProseMirror-focused .ProseMirror-gapcursor {
  8208. display: block;
  8209. }`;function BGe(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 HGe=class extends TGe{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=une(e,this.options.autofocus);this.editorState=_g.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=BGe(zGe,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=pne(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?[Cne,kne.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Ene,Pne,Dne,One,Ane,Rne,Tne,Lne.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 F2(r,this)}createCommandManager(){this.commandManager=new P2({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=VD(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=VD(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new ane(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 vne(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return iGe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return BL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
  8210. `,textSerializers:n={}}=t||{};return ZVe(this.state.doc,{blockSeparator:e,textSerializers:{...yne(this.schema),...n}})}get isEmpty(){return O2(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 UGe(e,this)}get $doc(){return this.$pos(0)}};function mx(t){return new L2({find:t.find,handler:({state:e,range:n,match:r})=>{const i=xr(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(m=>m.mark.type.excluded.find(y=>y===t.type&&y!==m.mark.type)).filter(m=>m.to>u).length)return null;d<n.to&&s.delete(d,n.to),u>n.from&&s.delete(n.from+c,u);const p=n.from+c+o.length;s.addMark(n.from+c,p,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function Fne(t){return new L2({find:t.find,handler:({state:e,range:n,match:r})=>{const i=xr(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 h=r[0][r[0].length-1];s.insertText(h,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 qD(t){return new L2({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=xr(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 px(t){return new L2({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=xr(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&vL(c,t.type,s);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:h,storedMarks:p}=e,{splittableMarks:m}=t.editor.extensionManager,x=p||h.$to.parentOffset&&h.$from.marks();if(x){const y=x.filter(v=>m.includes(v.type.name));o.ensureMarks(y)}}if(t.keepAttributes){const h=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(h,s).run()}const d=o.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&Hh(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var $Ge=t=>"touches"in t,VGe=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,$Ge(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 GGe(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 qGe={};LL(qGe,{createAtomBlockMarkdownSpec:()=>WGe,createBlockMarkdownSpec:()=>KGe,createInlineMarkdownSpec:()=>QGe,parseAttributes:()=>GL,parseIndentedBlocks:()=>WD,renderNestedMarkdownContent:()=>WL,serializeAttributes:()=>qL});function GL(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 h;const p=parseInt(((h=d.match(/__QUOTED_(\d+)__/))==null?void 0:h[1])||"0",10),m=n[p];m&&(e[u]=m.slice(1,-1))});const c=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return c&&c.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function qL(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 WGe(t){const{nodeName:e,name:n,parseAttributes:r=GL,serializeAttributes:i=qL,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const h={};return l.forEach(p=>{p in d&&(h[p]=d[p])}),h};return{parseMarkdown:(d,h)=>{const p={...s,...d.attributes};return h.createNode(e,p,[])},markdownTokenizer:{name:e,level:"block",start(d){var h;const p=new RegExp(`^:::${c}(?:\\s|$)`,"m"),m=(h=d.match(p))==null?void 0:h.index;return m!==void 0?m:-1},tokenize(d,h,p){const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(m);if(!x)return;const y=x[1]||"",v=r(y);if(!o.find(S=>!(S in v)))return{type:e,raw:x[0],attributes:v}}},renderMarkdown:d=>{const h=u(d.attrs||{}),p=i(h),m=p?` {${p}}`:"";return`:::${c}${m} :::`}}}function KGe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=GL,serializeAttributes:s=qL,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=h=>{if(!c)return h;const p={};return c.forEach(m=>{m in h&&(p[m]=h[m])}),p};return{parseMarkdown:(h,p)=>{let m;if(r){const y=r(h);m=typeof y=="string"?[{type:"text",text:y}]:y}else l==="block"?m=p.parseChildren(h.tokens||[]):m=p.parseInline(h.tokens||[]);const x={...o,...h.attributes};return p.createNode(e,x,m)},markdownTokenizer:{name:e,level:"block",start(h){var p;const m=new RegExp(`^:::${u}`,"m"),x=(p=h.match(m))==null?void 0:p.index;return x!==void 0?x:-1},tokenize(h,p,m){var x;const y=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),v=h.match(y);if(!v)return;const[b,S=""]=v,N=i(S);let T=1;const k=b.length;let C="";const E=/^:::([\w-]*)(\s.*)?/gm,P=h.slice(k);for(E.lastIndex=0;;){const A=E.exec(P);if(A===null)break;const D=A.index,I=A[1];if(!((x=A[2])!=null&&x.endsWith(":::"))){if(I)T+=1;else if(T-=1,T===0){const L=P.slice(0,D);C=L.trim();const U=h.slice(0,k+D+A[0].length);let j=[];if(C)if(l==="block")for(j=m.blockTokens(L),j.forEach(V=>{V.text&&(!V.tokens||V.tokens.length===0)&&(V.tokens=m.inlineTokens(V.text))});j.length>0;){const V=j[j.length-1];if(V.type==="paragraph"&&(!V.text||V.text.trim()===""))j.pop();else break}else j=m.inlineTokens(C);return{type:e,raw:U,attributes:N,content:C,tokens:j}}}}}},renderMarkdown:(h,p)=>{const m=d(h.attrs||{}),x=s(m),y=x?` {${x}}`:"",v=p.renderChildren(h.content||[],`
  8211. `);return`:::${u}${y}
  8212. ${v}
  8213. :::`}}}function XGe(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 YGe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function QGe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=XGe,serializeAttributes:s=YGe,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:c}=t,u=n||e,d=p=>{if(!c)return p;const m={};return c.forEach(x=>{x in p&&(m[x]=p[x])}),m},h=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(p,m)=>{const x={...o,...p.attributes};if(l)return m.createNode(e,x);const y=r?r(p):p.content||"";return y?m.createNode(e,x,[m.createTextNode(y)]):m.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(p){const m=l?new RegExp(`\\[${h}\\s*[^\\]]*\\]`):new RegExp(`\\[${h}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${h}\\]`),x=p.match(m),y=x?.index;return y!==void 0?y:-1},tokenize(p,m,x){const y=l?new RegExp(`^\\[${h}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${h}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${h}\\]`),v=p.match(y);if(!v)return;let b="",S="";if(l){const[,T]=v;S=T}else{const[,T,k]=v;S=T,b=k||""}const N=i(S.trim());return{type:e,raw:v[0],content:b.trim(),attributes:N}}},renderMarkdown:p=>{let m="";r?m=r(p):p.content&&p.content.length>0&&(m=p.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const x=d(p.attrs||{}),y=s(x),v=y?` ${y}`:"";return l?`[${u}${v}]`:`[${u}${v}]${m}[/${u}]`}}}function WD(t,e,n){var r,i,s,o;const l=t.split(`
  8214. `),c=[];let u="",d=0;const h=e.baseIndentSize||2;for(;d<l.length;){const p=l[d],m=p.match(e.itemPattern);if(!m){if(c.length>0)break;if(p.trim()===""){d+=1,u=`${u}${p}
  8215. `;continue}else return}const x=e.extractItemData(m),{indentLevel:y,mainContent:v}=x;u=`${u}${p}
  8216. `;const b=[v];for(d+=1;d<l.length;){const k=l[d];if(k.trim()===""){const E=l.slice(d+1).findIndex(D=>D.trim()!=="");if(E===-1)break;if((((i=(r=l[d+1+E].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>y){b.push(k),u=`${u}${k}
  8217. `,d+=1;continue}else break}if((((o=(s=k.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>y)b.push(k),u=`${u}${k}
  8218. `,d+=1;else break}let S;const N=b.slice(1);if(N.length>0){const k=N.map(C=>C.slice(y+h)).join(`
  8219. `);k.trim()&&(e.customNestedParser?S=e.customNestedParser(k):S=n.blockTokens(k))}const T=e.createToken(x,S);c.push(T)}if(c.length!==0)return{items:c,raw:u}}function WL(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 h=d.split(`
  8220. `).map(p=>p?e.indent(p):"").join(`
  8221. `);c.push(h)}}),c.join(`
  8222. `)}function ZGe(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 h=null;if(l.marks.forEach(m=>{if(m!==o)return!1;h=m}),!h)return;let p=!1;if(Object.keys(n).forEach(m=>{n[m]!==h.attrs[m]&&(p=!0)}),p){const m=t.type.create({...t.attrs,...n});s.removeMark(u,d,t.type),s.addMark(u,d,m)}}),s.docChanged&&e.view.dispatch(s)}var Ks=class Ine extends VL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Ine(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function km(t){return new DGe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=xr(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/),h=n.from+c.indexOf(l),p=h+l.length;if($L(n.from,n.to,e.doc).filter(x=>x.mark.type.excluded.find(v=>v===t.type&&v!==x.mark.type)).filter(x=>x.to>h).length)return null;p<n.to&&o.delete(p,n.to),h>n.from&&o.delete(n.from+d,h),u=n.from+d+l.length,o.addMark(n.from+d,u,t.type.create(s||{})),o.removeStoredMark(t.type)}}})}var Aj,q9;function JGe(){return q9||(q9=1,Aj=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}),Aj}var e7e=JGe();const t7e=pl(e7e);var n7e=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},r7e=({contentComponent:t})=>{const e=mR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return a.jsx(a.Fragment,{children:Object.values(e)})};function i7e(){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]:Rle.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 a7e=class extends ei.Component{constructor(t){var e;super(t),this.editorContentRef=ei.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=i7e(),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:n7e(e,this.editorContentRef),...n}),t?.contentComponent&&a.jsx(r7e,{contentComponent:t.contentComponent})]})}},s7e=_.forwardRef((t,e)=>{const n=ei.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ei.createElement(a7e,{key:n,innerRef:e,...t})}),o7e=ei.memo(s7e),l7e=typeof window<"u"?_.useLayoutEffect:_.useEffect,c7e=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 u7e(t){var e;const[n]=_.useState(()=>new c7e(t.editor)),r=XX.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:t7e);return l7e(()=>n.watch(t.editor),[t.editor,n]),_.useDebugValue(r),r}var d7e=!1,KD=typeof window>"u",h7e=KD||!!(typeof window<"u"&&window.next),f7e=class Une{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?KD||h7e?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 HGe(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?Une.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 m7e(t={},e=[]){const n=_.useRef(t);n.current=t;const[r]=_.useState(()=>new f7e(n)),i=mR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return _.useDebugValue(i),_.useEffect(r.onRender(e)),u7e({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var p7e=_.createContext({editor:null});p7e.Consumer;var g7e=_.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),x7e=()=>_.useContext(g7e);ei.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}})});ei.createContext({markViewContentRef:()=>{}});var _N=(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]},b7e=/^\s*>\s$/,y7e=Ks.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return _N("blockquote",{..._i(this.options.HTMLAttributes,t),children:_N("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const l=e.renderChildren([i]).split(`
  8223. `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
  8224. `))}),r.join(`
  8225. ${n}
  8226. `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[px({find:b7e,type:this.type})]}}),v7e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,w7e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,_7e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,S7e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,N7e=Vh.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 _N("strong",{..._i(this.options.HTMLAttributes,t),children:_N("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[mx({find:v7e,type:this.type}),mx({find:_7e,type:this.type})]},addPasteRules(){return[km({find:w7e,type:this.type}),km({find:S7e,type:this.type})]}}),M7e=/(^|[^`])`([^`]+)`(?!`)$/,k7e=/(^|[^`])`([^`]+)`(?!`)/g,E7e=Vh.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",_i(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[mx({find:M7e,type:this.type})]},addPasteRules(){return[km({find:k7e,type:this.type})]}}),Cj=4,T7e=/^```([a-z]+)?[\s\n]$/,A7e=/^~~~([a-z]+)?[\s\n]$/,C7e=Ks.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Cj,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",_i(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
  8227. `):r=`\`\`\`${i}
  8228. \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Cj,{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,m=r.doc.textBetween(u,d,`
  8229. `,`
  8230. `).split(`
  8231. `).map(x=>l+x).join(`
  8232. `);return c.replaceWith(u,d,r.schema.text(m)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Cj,{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(),h=s.end(),m=r.doc.textBetween(d,h,`
  8233. `,`
  8234. `).split(`
  8235. `);let x=0,y=0;const v=u-d;for(let C=0;C<m.length;C+=1){if(y+m[C].length>=v){x=C;break}y+=m[C].length+1}const S=((c=m[x].match(/^ */))==null?void 0:c[0])||"",N=Math.min(S.length,n);if(N===0)return!0;let T=d;for(let C=0;C<x;C+=1)T+=m[C].length+1;return l.delete(T,T+N),u-T<=N&&l.setSelection(gn.create(l.doc,T)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,p=r.doc.textBetween(c,u,`
  8236. `,`
  8237. `).split(`
  8238. `).map(m=>{var x;const y=((x=m.match(/^ */))==null?void 0:x[0])||"",v=Math.min(y.length,n);return m.slice(v)}).join(`
  8239. `);return l.replaceWith(c,u,r.schema.text(p)),!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(`
  8240. `);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(jn.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[qD({find:T7e,type:this.type,getAttributes:t=>({language:t[1]})}),qD({find:A7e,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new di({key:new ua("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,`
  8241. `));return o.replaceSelectionWith(this.type.create({language:s},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(gn.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),j7e=Ks.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8242. `):""}),P7e=Ks.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",_i(this.options.HTMLAttributes,t)]},renderText(){return`
  8243. `},renderMarkdown:()=>`
  8244. `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks: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 h=c.filter(p=>l.includes(p.type.name));u.ensureMarks(h)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),D7e=Ks.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]}`,_i(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=>qD({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),R7e=Ks.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",_i(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!GGe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return _ne(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(gn.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(Zt.create(o.doc,c.pos)):o.setSelection(gn.create(o.doc,c.pos));else{const d=s.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,h=d?.create();h&&(o.insert(u,h),o.setSelection(gn.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Fne({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),O7e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,L7e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,F7e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,I7e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,U7e=Vh.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",_i(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[mx({find:O7e,type:this.type}),mx({find:F7e,type:this.type})]},addPasteRules(){return[km({find:L7e,type:this.type}),km({find:I7e,type:this.type})]}});const z7e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",B7e="ελ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",XD="numeric",YD="ascii",QD="alpha",P0="asciinumeric",p0="alphanumeric",ZD="domain",zne="emoji",H7e="scheme",$7e="slashscheme",jj="whitespace";function V7e(t,e){return t in e||(e[t]=[]),e[t]}function Bf(t,e,n){e[XD]&&(e[P0]=!0,e[p0]=!0),e[YD]&&(e[P0]=!0,e[QD]=!0),e[P0]&&(e[p0]=!0),e[QD]&&(e[p0]=!0),e[p0]&&(e[ZD]=!0),e[zne]&&(e[ZD]=!0);for(const r in e){const i=V7e(r,n);i.indexOf(t)<0&&i.push(t)}}function G7e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Us(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Us.groups={};Us.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||Us.groups;let i;return e&&e.j?i=e:(i=new Us(e),n&&r&&Bf(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||Us.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 Us,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Us,s){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(G7e(o.t,r),n);Bf(s,c,r)}else n&&Bf(s,n,r);o.t=s}return i.j[t]=o,o}};const En=(t,e,n,r,i)=>t.ta(e,n,r,i),pi=(t,e,n,r,i)=>t.tr(e,n,r,i),W9=(t,e,n,r,i)=>t.ts(e,n,r,i),Ct=(t,e,n,r,i)=>t.tt(e,n,r,i),hu="WORD",JD="UWORD",Bne="ASCIINUMERICAL",Hne="ALPHANUMERICAL",Cy="LOCALHOST",eR="TLD",tR="UTLD",I1="SCHEME",hg="SLASH_SCHEME",KL="NUM",nR="WS",XL="NL",D0="OPENBRACE",R0="CLOSEBRACE",SN="OPENBRACKET",NN="CLOSEBRACKET",MN="OPENPAREN",kN="CLOSEPAREN",EN="OPENANGLEBRACKET",TN="CLOSEANGLEBRACKET",AN="FULLWIDTHLEFTPAREN",CN="FULLWIDTHRIGHTPAREN",jN="LEFTCORNERBRACKET",PN="RIGHTCORNERBRACKET",DN="LEFTWHITECORNERBRACKET",RN="RIGHTWHITECORNERBRACKET",ON="FULLWIDTHLESSTHAN",LN="FULLWIDTHGREATERTHAN",FN="AMPERSAND",IN="APOSTROPHE",UN="ASTERISK",Gd="AT",zN="BACKSLASH",BN="BACKTICK",HN="CARET",Qd="COLON",YL="COMMA",$N="DOLLAR",tc="DOT",VN="EQUALS",QL="EXCLAMATION",qo="HYPHEN",O0="PERCENT",GN="PIPE",qN="PLUS",WN="POUND",L0="QUERY",ZL="QUOTE",$ne="FULLWIDTHMIDDLEDOT",JL="SEMI",nc="SLASH",F0="TILDE",KN="UNDERSCORE",Vne="EMOJI",XN="SYM";var Gne=Object.freeze({__proto__:null,ALPHANUMERICAL:Hne,AMPERSAND:FN,APOSTROPHE:IN,ASCIINUMERICAL:Bne,ASTERISK:UN,AT:Gd,BACKSLASH:zN,BACKTICK:BN,CARET:HN,CLOSEANGLEBRACKET:TN,CLOSEBRACE:R0,CLOSEBRACKET:NN,CLOSEPAREN:kN,COLON:Qd,COMMA:YL,DOLLAR:$N,DOT:tc,EMOJI:Vne,EQUALS:VN,EXCLAMATION:QL,FULLWIDTHGREATERTHAN:LN,FULLWIDTHLEFTPAREN:AN,FULLWIDTHLESSTHAN:ON,FULLWIDTHMIDDLEDOT:$ne,FULLWIDTHRIGHTPAREN:CN,HYPHEN:qo,LEFTCORNERBRACKET:jN,LEFTWHITECORNERBRACKET:DN,LOCALHOST:Cy,NL:XL,NUM:KL,OPENANGLEBRACKET:EN,OPENBRACE:D0,OPENBRACKET:SN,OPENPAREN:MN,PERCENT:O0,PIPE:GN,PLUS:qN,POUND:WN,QUERY:L0,QUOTE:ZL,RIGHTCORNERBRACKET:PN,RIGHTWHITECORNERBRACKET:RN,SCHEME:I1,SEMI:JL,SLASH:nc,SLASH_SCHEME:hg,SYM:XN,TILDE:F0,TLD:eR,UNDERSCORE:KN,UTLD:tR,UWORD:JD,WORD:hu,WS:nR});const ou=/[a-z]/,n0=new RegExp("\\p{L}","u"),Pj=new RegExp("\\p{Emoji}","u"),lu=/\d/,Dj=/\s/,K9="\r",Rj=`
  8245. `,q7e="️",W7e="‍",Oj="";let o1=null,l1=null;function K7e(t=[]){const e={};Us.groups=e;const n=new Us;o1==null&&(o1=X9(z7e)),l1==null&&(l1=X9(B7e)),Ct(n,"'",IN),Ct(n,"{",D0),Ct(n,"}",R0),Ct(n,"[",SN),Ct(n,"]",NN),Ct(n,"(",MN),Ct(n,")",kN),Ct(n,"<",EN),Ct(n,">",TN),Ct(n,"(",AN),Ct(n,")",CN),Ct(n,"「",jN),Ct(n,"」",PN),Ct(n,"『",DN),Ct(n,"』",RN),Ct(n,"<",ON),Ct(n,">",LN),Ct(n,"&",FN),Ct(n,"*",UN),Ct(n,"@",Gd),Ct(n,"`",BN),Ct(n,"^",HN),Ct(n,":",Qd),Ct(n,",",YL),Ct(n,"$",$N),Ct(n,".",tc),Ct(n,"=",VN),Ct(n,"!",QL),Ct(n,"-",qo),Ct(n,"%",O0),Ct(n,"|",GN),Ct(n,"+",qN),Ct(n,"#",WN),Ct(n,"?",L0),Ct(n,'"',ZL),Ct(n,"/",nc),Ct(n,";",JL),Ct(n,"~",F0),Ct(n,"_",KN),Ct(n,"\\",zN),Ct(n,"・",$ne);const r=pi(n,lu,KL,{[XD]:!0});pi(r,lu,r);const i=pi(r,ou,Bne,{[P0]:!0}),s=pi(r,n0,Hne,{[p0]:!0}),o=pi(n,ou,hu,{[YD]:!0});pi(o,lu,i),pi(o,ou,o),pi(i,lu,i),pi(i,ou,i);const l=pi(n,n0,JD,{[QD]:!0});pi(l,ou),pi(l,lu,s),pi(l,n0,l),pi(s,lu,s),pi(s,ou),pi(s,n0,s);const c=Ct(n,Rj,XL,{[jj]:!0}),u=Ct(n,K9,nR,{[jj]:!0}),d=pi(n,Dj,nR,{[jj]:!0});Ct(n,Oj,d),Ct(u,Rj,c),Ct(u,Oj,d),pi(u,Dj,d),Ct(d,K9),Ct(d,Rj),pi(d,Dj,d),Ct(d,Oj,d);const h=pi(n,Pj,Vne,{[zne]:!0});Ct(h,"#"),pi(h,Pj,h),Ct(h,q7e,h);const p=Ct(h,W7e);Ct(p,"#"),pi(p,Pj,h);const m=[[ou,o],[lu,i]],x=[[ou,null],[n0,l],[lu,s]];for(let y=0;y<o1.length;y++)Fd(n,o1[y],eR,hu,m);for(let y=0;y<l1.length;y++)Fd(n,l1[y],tR,JD,x);Bf(eR,{tld:!0,ascii:!0},e),Bf(tR,{utld:!0,alpha:!0},e),Fd(n,"file",I1,hu,m),Fd(n,"mailto",I1,hu,m),Fd(n,"http",hg,hu,m),Fd(n,"https",hg,hu,m),Fd(n,"ftp",hg,hu,m),Fd(n,"ftps",hg,hu,m),Bf(I1,{scheme:!0,ascii:!0},e),Bf(hg,{slashscheme:!0,ascii:!0},e),t=t.sort((y,v)=>y[0]>v[0]?1:-1);for(let y=0;y<t.length;y++){const v=t[y][0],S=t[y][1]?{[H7e]:!0}:{[$7e]:!0};v.indexOf("-")>=0?S[ZD]=!0:ou.test(v)?lu.test(v)?S[P0]=!0:S[YD]=!0:S[XD]=!0,W9(n,v,v,S)}return W9(n,"localhost",Cy,{ascii:!0}),n.jd=new Us(XN),{start:n,tokens:Object.assign({groups:e},Gne)}}function qne(t,e){const n=X7e(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,h=-1,p=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(h=0,p=0,d=l):h>=0&&(h+=n[o].length,p++),u+=n[o].length,s+=n[o].length,o++;s-=h,o-=p,u-=h,i.push({t:d.t,v:e.slice(s-u,s),s:s-u,e:s})}return i}function X7e(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 Fd(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 Us(r),s.jr=i.slice(),t.j[c]=s),t=s}return s=new Us(n),s.jr=i.slice(),t.j[e[o-1]]=s,s}function X9(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 jy={defaultProtocol:"http",events:null,format:Y9,formatHref:Y9,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function eF(t,e=null){let n=Object.assign({},jy);t&&(n=Object.assign(n,t instanceof eF?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}eF.prototype={o:jy,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]:jy[t],typeof i=="function"&&r&&(i=i(e,n))):typeof i=="function"&&r&&(i=i(e,n.t,n)),i)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Y9(t){return t}function Wne(t,e){this.t="token",this.v=t,this.tk=e}Wne.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=jy.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),h=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:h}}};function I2(t,e){class n extends Wne{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 Q9=I2("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Z9=I2("text"),Y7e=I2("nl"),c1=I2("url",{isLink:!0,toHref(t=jy.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Cy&&t[1].t===Qd}}),$o=t=>new Us(t);function Q7e({groups:t}){const e=t.domain.concat([FN,UN,Gd,zN,BN,HN,$N,VN,qo,KL,O0,GN,qN,WN,nc,XN,F0,KN]),n=[IN,Qd,YL,tc,QL,O0,L0,ZL,JL,EN,TN,D0,R0,NN,SN,MN,kN,AN,CN,jN,PN,DN,RN,ON,LN],r=[FN,IN,UN,zN,BN,HN,$N,VN,qo,D0,R0,O0,GN,qN,WN,L0,nc,XN,F0,KN],i=$o(),s=Ct(i,F0);En(s,r,s),En(s,t.domain,s);const o=$o(),l=$o(),c=$o();En(i,t.domain,o),En(i,t.scheme,l),En(i,t.slashscheme,c),En(o,r,s),En(o,t.domain,o);const u=Ct(o,Gd);Ct(s,Gd,u),Ct(l,Gd,u),Ct(c,Gd,u);const d=Ct(s,tc);En(d,r,s),En(d,t.domain,s);const h=$o();En(u,t.domain,h),En(h,t.domain,h);const p=Ct(h,tc);En(p,t.domain,h);const m=$o(Q9);En(p,t.tld,m),En(p,t.utld,m),Ct(u,Cy,m);const x=Ct(h,qo);Ct(x,qo,x),En(x,t.domain,h),En(m,t.domain,h),Ct(m,tc,p),Ct(m,qo,x);const y=Ct(m,Qd);En(y,t.numeric,Q9);const v=Ct(o,qo),b=Ct(o,tc);Ct(v,qo,v),En(v,t.domain,o),En(b,r,s),En(b,t.domain,o);const S=$o(c1);En(b,t.tld,S),En(b,t.utld,S),En(S,t.domain,o),En(S,r,s),Ct(S,tc,b),Ct(S,qo,v),Ct(S,Gd,u);const N=Ct(S,Qd),T=$o(c1);En(N,t.numeric,T);const k=$o(c1),C=$o();En(k,e,k),En(k,n,C),En(C,e,k),En(C,n,C),Ct(S,nc,k),Ct(T,nc,k);const E=Ct(l,Qd),P=Ct(c,Qd),A=Ct(P,nc),D=Ct(A,nc);En(l,t.domain,o),Ct(l,tc,b),Ct(l,qo,v),En(c,t.domain,o),Ct(c,tc,b),Ct(c,qo,v),En(E,t.domain,k),Ct(E,nc,k),Ct(E,L0,k),En(D,t.domain,k),En(D,e,k),Ct(D,nc,k);const I=[[D0,R0],[SN,NN],[MN,kN],[EN,TN],[AN,CN],[jN,PN],[DN,RN],[ON,LN]];for(let L=0;L<I.length;L++){const[U,j]=I[L],V=Ct(k,U);Ct(C,U,V),Ct(V,j,k);const K=$o(c1);En(V,e,K);const z=$o();En(V,n),En(K,e,K),En(K,n,z),En(z,e,K),En(z,n,z),Ct(K,j,k),Ct(z,j,k)}return Ct(i,Cy,S),Ct(i,XL,Y7e),{start:i,tokens:Gne}}function Z7e(t,e,n){let r=n.length,i=0,s=[],o=[];for(;i<r;){let l=t,c=null,u=null,d=0,h=null,p=-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()?(p=0,h=l):p>=0&&p++,i++,d++;if(p<0)i-=d,i<r&&(o.push(n[i]),i++);else{o.length>0&&(s.push(Lj(Z9,e,o)),o=[]),i-=p,d-=p;const m=h.t,x=n.slice(i-d,i);s.push(Lj(m,e,x))}}return o.length>0&&s.push(Lj(Z9,e,o)),s}function Lj(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 J7e=typeof console<"u"&&console&&console.warn||(()=>{}),e9e="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",qr={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function t9e(){return Us.groups={},qr.scanner=null,qr.parser=null,qr.tokenQueue=[],qr.pluginQueue=[],qr.customSchemes=[],qr.initialized=!1,qr}function J9(t,e=!1){if(qr.initialized&&J7e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${e9e}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
  8246. 1. Must only contain digits, lowercase ASCII letters or "-"
  8247. 2. Cannot start or end with "-"
  8248. 3. "-" cannot repeat`);qr.customSchemes.push([t,e])}function n9e(){qr.scanner=K7e(qr.customSchemes);for(let t=0;t<qr.tokenQueue.length;t++)qr.tokenQueue[t][1]({scanner:qr.scanner});qr.parser=Q7e(qr.scanner.tokens);for(let t=0;t<qr.pluginQueue.length;t++)qr.pluginQueue[t][1]({scanner:qr.scanner,parser:qr.parser});return qr.initialized=!0,qr}function tF(t){return qr.initialized||n9e(),Z7e(qr.parser.start,t,qne(qr.scanner.start,t))}tF.scan=qne;function Kne(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 eF(n),i=tF(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 nF="[\0-   ᠎ -\u2029  ]",r9e=new RegExp(nF),i9e=new RegExp(`${nF}$`),a9e=new RegExp(nF,"g");function s9e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function o9e(t){return new di({key:new ua("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=mne(n.doc,[...e]);if(wne(l).forEach(({newRange:u})=>{const d=qVe(r.doc,u,m=>m.isTextblock);let h,p;if(d.length>1)h=d[0],p=r.doc.textBetween(h.pos,h.pos+h.node.nodeSize,void 0," ");else if(d.length){const m=r.doc.textBetween(u.from,u.to," "," ");if(!i9e.test(m))return;h=d[0],p=r.doc.textBetween(h.pos,u.to,void 0," ")}if(h&&p){const m=p.split(r9e).filter(Boolean);if(m.length<=0)return!1;const x=m[m.length-1],y=h.pos+p.lastIndexOf(x);if(!x)return!1;const v=tF(x).map(b=>b.toObject(t.defaultProtocol));if(!s9e(v))return!1;v.filter(b=>b.isLink).map(b=>({...b,from:y+b.start+1,to:y+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{$L(b.from,b.to,r.doc).some(S=>S.mark.type===t.type)||o.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!o.steps.length)return o}})}function l9e(t){return new di({key:new ua("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 h=[];for(;d.nodeName!=="DIV";)h.push(d),d=d.parentNode;o=h.find(p=>p.nodeName==="A")}if(!o)return!1;const l=vne(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 c9e(t){return new di({key:new ua("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=Kne(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 vf(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(a9e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Xne=Vh.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"){J9(t);return}J9(t.scheme,t.optionalSlashes)})},onDestroy(){t9e()},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)=>!!vf(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=>!!vf(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=>!!vf(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",_i(this.options.HTMLAttributes,t),0]:["a",_i(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=>!!vf(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=>!!vf(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[km({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Kne(t).filter(s=>s.isLink&&this.options.isAllowedUri(s.value,{defaultValidate:o=>!!vf(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(o9e({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!vf(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(l9e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(c9e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),u9e=Xne,d9e=Object.defineProperty,h9e=(t,e)=>{for(var n in e)d9e(t,n,{get:e[n],enumerable:!0})},f9e="listItem",eq="textStyle",tq=/^\s*([-+*])\s$/,Yne=Ks.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",_i(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8249. `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(f9e,this.editor.getAttributes(eq)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=px({find:tq,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=px({find:tq,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(eq),editor:this.editor})),[t]}}),Qne=Ks.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",_i(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)=>WL(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)}}}),m9e={};h9e(m9e,{findListItemPos:()=>wv,getNextListDepth:()=>rF,handleBackspace:()=>rR,handleDelete:()=>iR,hasListBefore:()=>Zne,hasListItemAfter:()=>p9e,hasListItemBefore:()=>Jne,listItemHasSubList:()=>ere,nextListIsDeeper:()=>tre,nextListIsHigher:()=>nre});var wv=(t,e)=>{const{$from:n}=e.selection,r=Ki(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}},rF=(t,e)=>{const n=wv(t,e);if(!n)return!1;const[,r]=nGe(e,t,n.$pos.pos+4);return r},Zne=(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)},ere=(t,e,n)=>{if(!n)return!1;const r=Ki(t,e.schema);let i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},rR=(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)&&Zne(t.state,e,n)){const{$anchor:l}=t.state.selection,c=t.state.doc.resolve(l.before()-1),u=[];c.node().descendants((p,m)=>{p.type.name===e&&u.push({node:p,pos:m})});const d=u.at(-1);if(!d)return!1;const h=t.state.doc.resolve(c.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},h.end()).joinForward().run()}if(!Oh(t.state,e)||!sGe(t.state))return!1;const r=wv(e,t.state);if(!r)return!1;const s=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=ere(e,t.state,s);return Jne(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},tre=(t,e)=>{const n=rF(t,e),r=wv(t,e);return!r||!n?!1:n>r.depth},nre=(t,e)=>{const n=rF(t,e),r=wv(t,e);return!r||!n?!1:n<r.depth},iR=(t,e)=>{if(!Oh(t.state,e)||!aGe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:tre(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():nre(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},p9e=(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)},rre=jr.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&&iR(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&&iR(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&&rR(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&&rR(t,n,r)&&(e=!0)}),e}}}}),nq=/^(\s*)(\d+)\.\s+(.*)$/,g9e=/^\s/;function x9e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(nq);if(!s)break;const[,o,l,c]=s,u=o.length;let d=c,h=n+1;const p=[i];for(;h<t.length;){const m=t[h];if(m.match(nq))break;if(m.trim()==="")p.push(m),d+=`
  8250. `,h+=1;else if(m.match(g9e))p.push(m),d+=`
  8251. ${m.slice(u+2)}`,h+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:p.join(`
  8252. `)}),r=h,n=h}return[e,r]}function ire(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(`
  8253. `),c=((r=l[0])==null?void 0:r.trim())||"",u=[];c&&u.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});const d=l.slice(1).join(`
  8254. `).trim();if(d){const m=n.blockTokens(d);u.push(...m)}let h=s+1;const p=[];for(;h<t.length&&t[h].indent>e;)p.push(t[h]),h+=1;if(p.length>0){const m=Math.min(...p.map(y=>y.indent)),x=ire(p,m,n);u.push({type:"list",ordered:!0,start:p[0].number,items:x,raw:p.map(y=>y.raw).join(`
  8255. `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),s=h}else s+=1}return i}function b9e(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 y9e="listItem",rq="textStyle",iq=/^(\d+)\.\s$/,are=Ks.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",_i(this.options.HTMLAttributes,n),0]:["ol",_i(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?b9e(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8256. `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(`
  8257. `),[s,o]=x9e(i);if(s.length===0)return;const l=ire(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(`
  8258. `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(y9e,this.editor.getAttributes(rq)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=px({find:iq,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=px({find:iq,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(rq)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),v9e=/^\s*(\[([( |x])?\])\s$/,w9e=Ks.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",_i(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 WL(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 h,p;l.ariaLabel=((p=(h=this.options.a11y)==null?void 0:h.checkboxLabel)==null?void 0:p.call(h,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:h}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:p})=>{const m=n();if(typeof m!="number")return!1;const x=p.doc.nodeAt(m);return p.setNodeMarkup(m,void 0,{...x?.attrs,checked:h}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,h)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,h])=>{i.setAttribute(d,h)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,s.append(l,o),i.append(s,c),Object.entries(e).forEach(([d,h])=>{i.setAttribute(d,h)}),{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[px({find:v9e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),_9e=Ks.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",_i(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
  8259. `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=s=>{const o=WD(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=WD(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()}}});jr.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Yne.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Qne.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(rre.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(are.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(w9e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(_9e.configure(this.options.taskList)),t}});var S9e=Ks.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",_i(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()}}}),N9e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,M9e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,k9e=Vh.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",_i(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[mx({find:N9e,type:this.type})]},addPasteRules(){return[km({find:M9e,type:this.type})]}}),E9e=Ks.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),sre=Vh.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",_i(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()}}}),T9e=sre;function A9e(t={}){return new di({view(e){return new C9e(e,t)}})}class C9e{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 h=e.nodeBefore,p=e.nodeAfter;if(h||p){let m=this.editorView.nodeDOM(this.cursorPos-(h?h.nodeSize:0));if(m){let x=m.getBoundingClientRect(),y=h?x.bottom:x.top;h&&p&&(y=(y+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let v=this.width/2*l;r={left:x.left,right:x.right,top:y-v,bottom:y+v}}}}if(!r){let h=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*o;r={left:h.left-p,right:h.left+p,top:h.top,bottom:h.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 h=c.getBoundingClientRect(),p=h.width/c.offsetWidth,m=h.height/c.offsetHeight;u=h.left-c.scrollLeft*p,d=h.top-c.scrollTop*m}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=ste(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 bi extends jn{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return bi.valid(r)?new bi(r):jn.near(r)}content(){return zt.empty}eq(e){return e instanceof bi&&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 bi(e.resolve(n.pos))}getBookmark(){return new iF(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!j9e(e)||!P9e(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&&bi.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(bi.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(bi.valid(l))return l}return null}}}bi.prototype.visible=!1;bi.findFrom=bi.findGapCursorFrom;jn.jsonID("gapcursor",bi);class iF{constructor(e){this.pos=e}map(e){return new iF(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return bi.valid(n)?new bi(n):jn.near(n)}}function ore(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function j9e(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||ore(i.type))return!0;if(i.inlineContent)return!1}}return!0}function P9e(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||ore(i.type))return!0;if(i.inlineContent)return!1}}return!0}function D9e(){return new di({props:{decorations:F9e,createSelectionBetween(t,e,n){return e.pos==n.pos&&bi.valid(n)?new bi(n):null},handleClick:O9e,handleKeyDown:R9e,handleDOMEvents:{beforeinput:L9e}}})}const R9e=sne({ArrowLeft:u1("horiz",-1),ArrowRight:u1("horiz",1),ArrowUp:u1("vert",-1),ArrowDown:u1("vert",1)});function u1(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 gn){if(!s.endOfTextblock(n)||l.depth==0)return!1;c=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=bi.findGapCursorFrom(l,e,c);return u?(i&&i(r.tr.setSelection(new bi(u))),!0):!1}}function O9e(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!bi.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 bi(r))),!0)}function L9e(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof bi))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=kt.empty;for(let o=r.length-1;o>=0;o--)i=kt.from(r[o].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new zt(i,0,0));return s.setSelection(gn.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function F9e(t){if(!(t.selection instanceof bi))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",oi.create(t.doc,[gs.widget(t.selection.head,e,{key:"gapcursor"})])}var YN=200,Ma=function(){};Ma.prototype.append=function(e){return e.length?(e=Ma.from(e),!this.length&&e||e.length<YN&&this.leafAppend(e)||this.length<YN&&e.leafPrepend(this)||this.appendInner(e)):this};Ma.prototype.prepend=function(e){return e.length?Ma.from(e).append(this):this};Ma.prototype.appendInner=function(e){return new I9e(this,e)};Ma.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ma.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Ma.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Ma.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)};Ma.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};Ma.from=function(e){return e instanceof Ma?e:e&&e.length?new lre(e):Ma.empty};var lre=(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<=YN)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=YN)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})(Ma);Ma.empty=new lre([]);var I9e=(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})(Ma);const U9e=500;class Rl{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((h,p)=>{if(!h.step){i||(i=this.remapping(r,p+1),s=i.maps.length),s--,d.push(h);return}if(i){d.push(new rc(h.map));let m=h.step.map(i.slice(s)),x;m&&o.maybeStep(m).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],u.push(new rc(x,void 0,void 0,u.length+d.length))),s--,x&&i.appendMap(x,s)}else o.maybeStep(h.step);if(h.selection)return l=i?h.selection.map(i.slice(s)):h.selection,c=new Rl(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 h=e.steps[d].invert(e.docs[d]),p=new rc(e.mapping.maps[d],h,n),m;(m=c&&c.merge(p))&&(p=m,d?s.pop():l=l.slice(0,l.length-1)),s.push(p),n&&(o++,n=void 0),i||(c=p)}let u=o-r.depth;return u>B9e&&(l=z9e(l,u),o-=u),new Rl(l.append(s),o)}remapping(e,n){let r=new Ny;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 Rl(this.items.append(e.map(n=>new rc(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(p=>{p.selection&&l--},i);let c=n;this.items.forEach(p=>{let m=s.getMirror(--c);if(m==null)return;o=Math.min(o,m);let x=s.maps[m];if(p.step){let y=e.steps[m].invert(e.docs[m]),v=p.selection&&p.selection.map(s.slice(c+1,m));v&&l++,r.push(new rc(x,y,v))}else r.push(new rc(x))},i);let u=[];for(let p=n;p<o;p++)u.push(new rc(s.maps[p]));let d=this.items.slice(0,i).append(u).append(r),h=new Rl(d,l);return h.emptyItemCount()>U9e&&(h=h.compress(this.items.length-r.length)),h}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],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 h=new rc(u.invert(),c,d),p,m=i.length-1;(p=i.length&&i[m].merge(h))?i[m]=p:i.push(h)}}else o.map&&r--},this.items.length,0),new Rl(Ma.from(i.reverse()),s)}}Rl.empty=new Rl(Ma.empty,0);function z9e(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class rc{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 rc(n.getMap().invert(),n,this.selection)}}}class qd{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const B9e=20;function H9e(t,e,n,r){let i=n.getMeta(tm),s;if(i)return i.historyState;n.getMeta(G9e)&&(t=new qd(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(tm))return o.getMeta(tm).redo?new qd(t.done.addTransform(n,void 0,r,U1(e)),t.undone,aq(n.mapping.maps),t.prevTime,t.prevComposition):new qd(t.done,t.undone.addTransform(n,void 0,r,U1(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||!$9e(n,t.prevRanges)),u=o?Fj(t.prevRanges,n.mapping):aq(n.mapping.maps);return new qd(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,U1(e)),Rl.empty,u,n.time,l??t.prevComposition)}else return(s=n.getMeta("rebased"))?new qd(t.done.rebased(n,s),t.undone.rebased(n,s),Fj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new qd(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Fj(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function $9e(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 aq(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 Fj(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 V9e(t,e,n){let r=U1(e),i=tm.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 qd(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(tm,{redo:n,historyState:c})}let Ij=!1,sq=null;function U1(t){let e=t.plugins;if(sq!=e){Ij=!1,sq=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Ij=!0;break}}return Ij}const tm=new ua("history"),G9e=new ua("closeHistory");function q9e(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new di({key:tm,state:{init(){return new qd(Rl.empty,Rl.empty,null,0,-1)},apply(e,n,r){return H9e(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?ure:r=="historyRedo"?dre:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function cre(t,e){return(n,r)=>{let i=tm.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=V9e(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const ure=cre(!1,!0),dre=cre(!0,!0);jr.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 di({key:new ua("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 W9e=jr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[A9e(this.options)]}});jr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new di({key:new ua("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return oi.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(gs.node(u,u+c.nodeSize,{class:this.options.className}))}),oi.create(t,s)}}})]}});var K9e=jr.create({name:"gapCursor",addProseMirrorPlugins(){return[D9e()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=xr(Xt(t,"allowGapCursor",n)))!=null?e:null}}});jr.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new di({key:new ua("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&&O2(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];s&&d.push(this.options.emptyEditorClass);const h=gs.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(h)}return this.options.includeChildren}),oi.create(t,i)}}})]}});jr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new di({key:new ua("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||_ne(n.selection)||t.view.dragging?null:oi.create(n.doc,[gs.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function oq({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var X9e=jr.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ua(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 di({key:e,appendTransaction:(i,s,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),h=l.content.size,p=u.nodes[n];if(d)return c.insert(h,p.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!oq({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!oq({node:o,types:r})}}})]}}),Y9e=jr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>ure(t,e),redo:()=>({state:t,dispatch:e})=>dre(t,e)}},addProseMirrorPlugins(){return[q9e(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()}}}),Q9e=jr.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(N7e.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(y7e.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(Yne.configure(this.options.bulletList)),this.options.code!==!1&&i.push(E7e.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(C7e.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(j7e.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(W9e.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(K9e.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(P7e.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(D7e.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(Y9e.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(R7e.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(U7e.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Qne.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(rre.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Xne.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(are.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(S9e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(k9e.configure(this.options.strike)),this.options.text!==!1&&i.push(E9e.configure(this.options.text)),this.options.underline!==!1&&i.push(sre.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(X9e.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),Z9e=Q9e,J9e=jr.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")}}}),eqe=J9e,tqe=20,hre=(t,e=0)=>{const n=[];return!t.children.length||e>tqe||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...hre(r,e+1))}),n},nqe=t=>{if(!t.children.length)return;const e=hre(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}`)})},fre=Vh.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&nqe(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",_i(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}}}}),rqe=jr.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()}}}),mre=jr.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()}}}),iqe=jr.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()}}}),aqe=jr.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()}}}),sqe=jr.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()}}});jr.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(rqe.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(mre.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(iqe.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(aqe.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(sqe.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(fre.configure(this.options.textStyle)),t}});var oqe=mre,lqe=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,cqe=Ks.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",_i(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?`![${c}](${l} "${u}")`:`![${c}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:s,HTMLAttributes:o})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,h])=>{if(h!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,h);break}}),l.src=o.src;const c=new VGe({element:l,node:i,getPos:s,onResize:(d,h)=>{l.style.width=`${d}px`,l.style.height=`${h}px`},onCommit:(d,h)=>{const p=s();p!==void 0&&this.editor.chain().setNodeSelection(p).updateAttributes(this.name,{width:d,height:h}).run()},onUpdate:(d,h,p)=>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[Fne({find:lqe,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),uqe=cqe;function aR({content:t,onChange:e,placeholder:n}){const r=m7e({extensions:[Z9e.configure({heading:!1,codeBlock:!1,code:!1}),T9e,u9e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),eqe.configure({types:["paragraph"]}),fre,oqe,uqe.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(Cce,{className:"w-4 h-4"})}),a.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:a.jsx(Sde,{className:"w-4 h-4"})}),a.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:a.jsx(ffe,{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(gM,{className:"w-4 h-4"})}),a.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:a.jsx(TW,{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(afe,{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(tfe,{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(rfe,{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(Uy,{className:"w-4 h-4"})}),r.isActive("link")&&a.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:a.jsx(OR,{className:"w-4 h-4"})})]}),a.jsx(o7e,{editor:r})]})}function pre({archiveId:t,archiveName:e,onClose:n}){const r=sn(),[i,s]=_.useState(!1),[o,l]=_.useState(null),[c,u]=_.useState({}),{data:d,isLoading:h,error:p}=ct({queryKey:["archive-project-page",t],queryFn:()=>oe.getArchiveProjectPage(t)}),m=gt({mutationFn:k=>oe.updateArchiveProjectPage(t,k),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),s(!1),u({})}});_.useEffect(()=>{const k=C=>{C.key==="Escape"&&(o!==null?l(null):i?b():n())};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[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)},v=()=>{m.mutate(c)},b=()=>{s(!1),u({})},S=k=>{const C=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],E=new DOMParser().parseFromString(k,"text/html"),P=A=>{if(A.nodeType===Node.TEXT_NODE)return A.textContent||"";if(A.nodeType===Node.ELEMENT_NODE){const D=A,I=D.tagName.toLowerCase();if(!C.includes(I))return Array.from(D.childNodes).map(P).join("");let L="";if(I==="a"&&D.getAttribute("href")){const j=D.getAttribute("href");j?.toLowerCase().startsWith("http")&&(L=` href="${j}" target="_blank" rel="noopener noreferrer"`)}if(I==="img"){const j=D.getAttribute("src");if(!j?.toLowerCase().startsWith("http"))return"";L=` src="${j}" style="max-width: 100%; height: auto;"`}const U=Array.from(D.childNodes).map(P).join("");return["br","img"].includes(I)?`<${I}${L} />`:`<${I}${L}>${U}</${I}>`}return""};return Array.from(E.body.childNodes).map(P).join("")},N=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),T=k=>{k.target===k.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(fs,{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&&N&&a.jsxs(Ae,{variant:"ghost",size:"sm",onClick:y,children:[a.jsx(am,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&a.jsxs(a.Fragment,{children:[a.jsx(Ae,{variant:"ghost",size:"sm",onClick:b,children:"Cancel"}),a.jsxs(Ae,{variant:"primary",size:"sm",onClick:v,disabled:m.isPending,children:[a.jsx(ms,{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(Lt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[h&&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"})}),p&&a.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!N&&a.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[a.jsx(fs,{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&&N&&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:k=>u({...c,title:k.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(om,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c.designer||"",onChange:k=>u({...c,designer:k.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(om,{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(Xr,{className:"w-3 h-3"})})]}),d.creation_date&&a.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[a.jsx(ti,{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(fs,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c.license||"",onChange:k=>u({...c,license:k.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(fs,{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(aR,{content:c.description||"",onChange:k=>u({...c,description:k}),placeholder:"Enter description..."}):a.jsx("div",{className:"prose prose-invert prose-sm max-w-none text-bambu-gray-light",dangerouslySetInnerHTML:{__html:S(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:k=>u({...c,profile_title:k.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(aR,{content:c.profile_description||"",onChange:k=>u({...c,profile_description:k}),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:S(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(Lu,{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((k,C)=>a.jsx("button",{onClick:()=>l(C),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:a.jsx("img",{src:k.url,alt:k.name,className:"w-full h-full object-cover"})},k.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(Xr,{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:k=>{k.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(bh,{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:k=>k.stopPropagation()}),a.jsx("button",{onClick:k=>{k.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(vs,{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(Lt,{className:"w-6 h-6 text-white"})}),a.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",x.length]})]})]})}const dqe=[.25,.5,.75,1,1.5,2,3,4];function rg(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function hqe({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=Hn(),s=_.useRef(null),o=_.useRef(null),[l,c]=_.useState(!1),[u,d]=_.useState(0),[h,p]=_.useState(0),[m,x]=_.useState(0),[y,v]=_.useState(0),[b,S]=_.useState(1),[N,T]=_.useState(null),[k,C]=_.useState(null),[E,P]=_.useState(.8),[A,D]=_.useState(!1),{data:I,isLoading:L}=ct({queryKey:["timelapse-info",t],queryFn:()=>oe.getTimelapseInfo(t)}),{data:U}=ct({queryKey:["timelapse-thumbnails",t],queryFn:()=>oe.getTimelapseThumbnails(t,15)}),j=gt({mutationFn:()=>oe.processTimelapse(t,{trimStart:m,trimEnd:y,speed:b,saveMode:"replace"},N||void 0),onSuccess:$=>{i($.message,"success"),r?.(),n()},onError:$=>{i($.message||"Processing failed","error")}});_.useEffect(()=>{I?.duration&&y===0&&v(I.duration)},[I?.duration,y]),_.useEffect(()=>{const $=W=>{W.key==="Escape"&&n()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[n]),_.useEffect(()=>{const $=s.current;if(!$)return;const W=()=>{const me=$.currentTime;d(me),me>=y&&($.currentTime=m)},ne=()=>{p($.duration),y===0&&v($.duration)},re=()=>c(!0),ge=()=>c(!1);return $.addEventListener("timeupdate",W),$.addEventListener("durationchange",ne),$.addEventListener("play",re),$.addEventListener("pause",ge),()=>{$.removeEventListener("timeupdate",W),$.removeEventListener("durationchange",ne),$.removeEventListener("play",re),$.removeEventListener("pause",ge)}},[m,y]),_.useEffect(()=>{const $=o.current,W=s.current;!$||!W||!k||($.currentTime=W.currentTime,$.playbackRate=W.playbackRate,l&&!A?$.play().catch(()=>{}):$.pause())},[l,k,A]),_.useEffect(()=>{o.current&&(o.current.volume=A?0:E)},[E,A]),_.useEffect(()=>{s.current&&(s.current.playbackRate=b),o.current&&(o.current.playbackRate=b)},[b]);const V=_.useCallback(()=>{const $=s.current;$&&(l?$.pause():($.currentTime<m&&($.currentTime=m),$.play()))},[l,m]),K=$=>{const W=s.current;W&&(W.currentTime=Math.max(m,Math.min(y,$)))},z=$=>{const W=$.target.files?.[0];W&&(k&&URL.revokeObjectURL(k),T(W),C(URL.createObjectURL(W)))},X=()=>{k&&URL.revokeObjectURL(k),T(null),C(null)};_.useEffect(()=>()=>{k&&URL.revokeObjectURL(k)},[k]);const Y=y-m,te=Y/b;return L?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(pt,{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(sh,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ae,{variant:"primary",size:"sm",onClick:()=>j.mutate(),disabled:j.isPending,children:j.isPending?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(ms,{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(Lt,{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:V,muted:!!k}),!l&&a.jsx("button",{onClick:V,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(So,{className:"w-8 h-8 text-white"})})}),k&&a.jsx("audio",{ref:o,src:k,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(Ahe,{className:"w-4 h-4"}),a.jsx("span",{children:"Trim"}),a.jsxs("span",{className:"ml-auto",children:[rg(m)," - ",rg(y)," (",rg(Y),")"]})]}),a.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[a.jsx("div",{className:"absolute inset-0 flex",children:U?.thumbnails.map(($,W)=>a.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${$})`}},W))}),a.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${m/h*100}%`}}),a.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(h-y)/h*100}%`}}),a.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${m/h*100}%`,right:`${(h-y)/h*100}%`}}),a.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-white shadow-lg",style:{left:`${u/h*100}%`}}),a.jsx("input",{type:"range",min:0,max:h,step:.1,value:m,onChange:$=>{const W=parseFloat($.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:h,step:.1,value:y,onChange:$=>{const W=parseFloat($.target.value);W>m+1&&v(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:h,step:.1,value:u,onChange:$=>K(parseFloat($.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8260. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8261. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8262. [&::-webkit-slider-thumb]:cursor-pointer`}),a.jsx("div",{className:"flex items-center justify-center gap-2",children:a.jsx("button",{onClick:V,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?a.jsx(jR,{className:"w-5 h-5 text-white"}):a.jsx(So,{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(fM,{className:"w-4 h-4"}),a.jsx("span",{children:"Speed"}),a.jsxs("span",{className:"ml-auto",children:[b,"x (output: ",rg(te),")"]})]}),a.jsx("div",{className:"flex gap-1",children:dqe.map($=>a.jsxs("button",{onClick:()=>S($),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${b===$?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[$,"x"]},$))})]}),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(yP,{className:"w-4 h-4"}),a.jsx("span",{children:"Music Overlay"})]}),N?a.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[a.jsx(yP,{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:N.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[(N.size/1024/1024).toFixed(1)," MB"]})]}),a.jsx("button",{onClick:()=>D(!A),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:A?a.jsx(_fe,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(vfe,{className:"w-4 h-4 text-bambu-green"})}),a.jsx("input",{type:"range",min:0,max:1,step:.1,value:E,onChange:$=>P(parseFloat($.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8263. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8264. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),a.jsx("button",{onClick:X,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:a.jsx(an,{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(Ba,{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:z,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:"})," ",rg(h)," @ ",I?.width,"x",I?.height]}),a.jsxs("p",{className:"text-bambu-gray",children:[a.jsx("span",{className:"text-white",children:"Output:"})," ",rg(te)," @ ",b,"x speed",N&&" + 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(pt,{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 fqe=[.25,.5,.75,1,1.5,2,3,4];function gre({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:s}){const o=_.useRef(null),[l,c]=_.useState(!0),[u,d]=_.useState(1),[h,p]=_.useState(0),[m,x]=_.useState(0),[y,v]=_.useState(!1);_.useEffect(()=>{const E=o.current;E&&(E.playbackRate=u)},[u]),_.useEffect(()=>{const E=P=>{P.key==="Escape"&&i()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[i]),_.useEffect(()=>{const E=o.current;if(!E)return;const P=()=>p(E.currentTime),A=()=>x(E.duration),D=()=>c(!0),I=()=>c(!1);return E.addEventListener("timeupdate",P),E.addEventListener("durationchange",A),E.addEventListener("play",D),E.addEventListener("pause",I),()=>{E.removeEventListener("timeupdate",P),E.removeEventListener("durationchange",A),E.removeEventListener("play",D),E.removeEventListener("pause",I)}},[]);const b=()=>{const E=o.current;E&&(l?E.pause():E.play())},S=E=>{const P=o.current;P&&(P.currentTime=parseFloat(E.target.value))},N=()=>{const E=o.current;E&&(E.currentTime=Math.max(0,E.currentTime-5))},T=()=>{const E=o.current;E&&(E.currentTime=Math.min(m,E.currentTime+5))},k=E=>{const P=Math.floor(E/60),A=Math.floor(E%60);return`${P}:${A.toString().padStart(2,"0")}`},C=()=>{const E=document.createElement("a");E.href=t,E.download=n,E.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(sh,{className:"w-5 h-5 text-bambu-green"}),e]}),a.jsxs("div",{className:"flex items-center gap-2",children:[r&&a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:()=>v(!0),children:[a.jsx(ea,{className:"w-4 h-4"}),"Edit"]}),a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:C,children:[a.jsx(wi,{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(Lt,{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:b}),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:k(h)}),a.jsx("input",{type:"range",min:0,max:m||100,value:h,onChange:S,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
  8265. [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
  8266. [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
  8267. [&::-webkit-slider-thumb]:cursor-pointer`}),a.jsx("span",{className:"text-xs text-bambu-gray w-12",children:k(m)})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{onClick:N,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:a.jsx(zhe,{className:"w-5 h-5 text-bambu-gray"})}),a.jsx("button",{onClick:b,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?a.jsx(jR,{className:"w-5 h-5 text-white"}):a.jsx(So,{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(RR,{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:fqe.map(E=>a.jsxs("button",{onClick:()=>d(E),className:`px-2 py-1 text-xs rounded transition-colors ${u===E?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:bg-bambu-dark-tertiary/80"}`,children:[E,"x"]},E))})]})]})]})]})]}),y&&r&&a.jsx(hqe,{archiveId:r,timelapseSrc:t,onClose:()=>v(!1),onSave:s})]})}function mqe({archiveIds:t,onClose:e}){_.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:()=>oe.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(Lt,{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(pt,{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(Sn,{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(pqe,{comparison:n}):null}),a.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:a.jsx(Ae,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function pqe({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(Sn,{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(Sn,{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(Wi,{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 gqe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function xqe(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 bqe({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:s}){const[o,l]=_.useState(!1),[c,u]=_.useState(t.tags||""),[d,h]=_.useState(t.notes||""),[p,m]=_.useState(t.project_id),[x,y]=_.useState(!1);return a.jsx(St,{children:a.jsxs(Nt,{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(Hf,{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:gqe(t.file_size)}),a.jsx("span",{children:"·"}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(tr,{className:"w-3 h-3"}),xqe(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(yh,{className:"w-5 h-5"}):a.jsx(Kr,{className:"w-5 h-5"})}),a.jsx(Ae,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:p||void 0}),disabled:i,children:i?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(go,{className:"w-4 h-4"}),"Archive"]})}),a.jsx(Ae,{variant:"secondary",size:"sm",onClick:()=>y(!0),disabled:s,children:s?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(an,{className:"w-4 h-4 text-red-400"})})]})]}),x&&a.jsx(Zn,{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:v=>u(v.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:v=>h(v.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:p||"",onChange:v=>m(v.target.value?Number(v.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(v=>a.jsx("option",{value:v.id,children:v.name},v.id))]})]})]})]})})}function yqe(){const t=sn(),{showToast:e}=Hn(),[n,r]=_.useState(!1),[i,s]=_.useState(!1),[o,l]=_.useState(new Set),[c,u]=_.useState(new Set),{data:d,isLoading:h}=ct({queryKey:["pending-uploads"],queryFn:sg.list,refetchInterval:1e4}),{data:p}=ct({queryKey:["projects"],queryFn:()=>oe.getProjects()}),m=gt({mutationFn:({id:b,data:S})=>sg.archive(b,S),onMutate:({id:b})=>{l(S=>new Set(S).add(b))},onSettled:(b,S,{id:N})=>{l(T=>{const k=new Set(T);return k.delete(N),k})},onSuccess:b=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${b.print_name}`)},onError:b=>{e(b.message||"Failed to archive","error")}}),x=gt({mutationFn:b=>sg.discard(b),onMutate:b=>{u(S=>new Set(S).add(b))},onSettled:(b,S,N)=>{u(T=>{const k=new Set(T);return k.delete(N),k})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:b=>{e(b.message||"Failed to discard","error")}}),y=gt({mutationFn:sg.archiveAll,onSuccess:b=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived ${b.archived} files${b.failed>0?`, ${b.failed} failed`:""}`)},onError:b=>{e(b.message||"Failed to archive all","error")}}),v=gt({mutationFn:sg.discardAll,onSuccess:b=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${b.discarded} files`)},onError:b=>{e(b.message||"Failed to discard all","error")}});return h?a.jsx(St,{children:a.jsx(Nt,{className:"py-8 flex justify-center",children:a.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:a.jsxs("div",{className:"mb-6",children:[a.jsxs(St,{className:"border-l-4 border-l-yellow-500",children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ba,{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(Ae,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:y.isPending,children:y.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(go,{className:"w-4 h-4"}),"Archive All"]})}),a.jsx(Ae,{variant:"secondary",size:"sm",onClick:()=>s(!0),disabled:v.isPending,children:v.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsxs(a.Fragment,{children:[a.jsx(an,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),a.jsxs(Nt,{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(b=>a.jsx(bqe,{upload:b,projects:p||[],onArchive:(S,N)=>m.mutate({id:S,data:N}),onDiscard:S=>x.mutate(S),isArchiving:o.has(b.id),isDiscarding:c.has(b.id)},b.id))})]})]}),n&&a.jsx(Zn,{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(Zn,{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:()=>{v.mutate(),s(!1)},onCancel:()=>s(!1)})]})}function vqe({onClose:t}){const e=sn(),{showToast:n}=Hn(),[r,i]=_.useState(""),[s,o]=_.useState(null),[l,c]=_.useState(""),[u,d]=_.useState(null),[h,p]=_.useState("count");_.useEffect(()=>{const A=D=>{D.key==="Escape"&&(s?o(null):u?d(null):t())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t,s,u]);const{data:m,isLoading:x}=ct({queryKey:["tags"],queryFn:oe.getTags}),y=gt({mutationFn:({oldName:A,newName:D})=>oe.renameTag(A,D),onSuccess:(A,{oldName:D,newName:I})=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Renamed "${D}" to "${I}" in ${A.affected} archive${A.affected!==1?"s":""}`),o(null)},onError:A=>{n(A.message||"Failed to rename tag","error")}}),v=gt({mutationFn:A=>oe.deleteTag(A),onSuccess:(A,D)=>{e.invalidateQueries({queryKey:["tags"]}),e.invalidateQueries({queryKey:["archives"]}),n(`Deleted "${D}" from ${A.affected} archive${A.affected!==1?"s":""}`),d(null)},onError:A=>{n(A.message||"Failed to delete tag","error")}}),b=A=>{o(A.name),c(A.name),d(null)},S=()=>{o(null),c("")},N=()=>{if(!s||!l.trim())return;const A=l.trim();if(A===s){S();return}y.mutate({oldName:s,newName:A})},T=A=>{A.key==="Enter"?(A.preventDefault(),N()):A.key==="Escape"&&(A.preventDefault(),S())},k=A=>{d(A),o(null)},C=()=>{u&&v.mutate(u)},E=m?.filter(A=>A.name.toLowerCase().includes(r.toLowerCase())).sort((A,D)=>h==="count"&&D.count-A.count||A.name.localeCompare(D.name)),P=m?.reduce((A,D)=>A+D.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(St,{className:"w-full max-w-lg max-h-[80vh] flex flex-col",children:a.jsxs(Nt,{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(wh,{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(Lt,{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(wa,{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:h,onChange:A=>p(A.target.value),children:[a.jsx("option",{value:"count",children:"Sort by Count"}),a.jsx("option",{value:"name",children:"Sort by Name"})]})]}),m&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[m.length," tag",m.length!==1?"s":""," across ",P," usage",P!==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(pt,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):E?.length?a.jsx("div",{className:"space-y-2",children:E.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:D=>c(D.target.value),onKeyDown:T,autoFocus:!0}),a.jsx(Ae,{size:"sm",variant:"primary",onClick:N,disabled:!l.trim()||y.isPending,className:"p-1.5",children:y.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(Wi,{className:"w-4 h-4"})}),a.jsx(Ae,{size:"sm",variant:"ghost",onClick:S,className:"p-1.5",children:a.jsx(Lt,{className:"w-4 h-4"})})]}):u===A.name?a.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[a.jsx(Sn,{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(Ae,{size:"sm",variant:"danger",onClick:C,disabled:v.isPending,className:"p-1.5",children:v.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(an,{className:"w-4 h-4"})}),a.jsx(Ae,{size:"sm",variant:"ghost",onClick:()=>d(null),className:"p-1.5",children:a.jsx(Lt,{className:"w-4 h-4"})})]}):a.jsxs(a.Fragment,{children:[a.jsx(wh,{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:()=>b(A),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Rename tag",children:a.jsx(ea,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>k(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(an,{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(Ae,{variant:"secondary",onClick:t,className:"flex-1",children:"Close"})})]})})})}function QN(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function r0(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Pf(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function xre(t){if(!t)return;const e=t.toLowerCase();return e.endsWith(".3mf")?"3mf":e.endsWith(".stl")?"stl":e.endsWith(".gcode")||e.includes(".gcode.")?"gcode":e.split(".").pop()}function wqe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s,isHighlighted:o,timeFormat:l="system",t:c}){o&&console.log("ArchiveCard isHighlighted=true for archive:",t.id);const u=sn(),{showToast:d}=Hn(),{hasPermission:h,canModify:p}=Ci(),m=UR(),[x,y]=_.useState(!1),[v,b]=_.useState(!1),[S,N]=_.useState(!1),[T,k]=_.useState(!1),[C,E]=_.useState(!1),[P,A]=_.useState(!1),[D,I]=_.useState([]),[L,U]=_.useState(!1),[j,V]=_.useState(!1),[K,z]=_.useState(!1),[X,Y]=_.useState(!1),[te,$]=_.useState(!1),[W,ne]=_.useState(!1),[re,ge]=_.useState(null),[me,ue]=_.useState(null),[Te,ie]=_.useState(!1),Ce=_.useRef(null),Fe=_.useRef(null),{data:xe}=ct({queryKey:["archive-plates",t.id],queryFn:()=>oe.getArchivePlates(t.id),enabled:Te,staleTime:300*1e3}),Ze=xe?.plates??[],G=xe?.is_multi_plate??!1,Q=me??0,de=gt({mutationFn:ae=>oe.uploadSource3mf(t.id,ae),onSuccess:ae=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.source3mfAttached",{filename:ae.filename}))},onError:ae=>{d(ae.message||c("archives.toast.failedUploadSource3mf"),"error")}}),q=gt({mutationFn:()=>oe.deleteSource3mf(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.source3mfRemoved"))},onError:ae=>{d(ae.message||c("archives.toast.failedRemoveSource3mf"),"error")}}),ee=gt({mutationFn:ae=>oe.uploadF3d(t.id,ae),onSuccess:ae=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.f3dAttached",{filename:ae.filename}))},onError:ae=>{d(ae.message||c("archives.toast.failedUploadF3d"),"error")}}),B=gt({mutationFn:()=>oe.deleteF3d(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.f3dRemoved"))},onError:ae=>{d(ae.message||c("archives.toast.failedRemoveF3d"),"error")}}),he=gt({mutationFn:()=>oe.scanArchiveTimelapse(t.id),onSuccess:ae=>{ae.status==="attached"?(u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.timelapseAttached",{filename:ae.filename}))):ae.status==="exists"?d(c("archives.toast.timelapseAlreadyAttached")):ae.status==="not_found"&&ae.available_files&&ae.available_files.length>0?(I(ae.available_files),A(!0)):d(ae.message||c("archives.toast.noMatchingTimelapse"),"warning")},onError:ae=>{d(ae.message||c("archives.toast.failedScanTimelapse"),"error")}}),ke=gt({mutationFn:ae=>oe.selectArchiveTimelapse(t.id,ae),onSuccess:ae=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.timelapseAttached",{filename:ae.filename})),A(!1),I([])},onError:ae=>{d(ae.message||c("archives.toast.failedAttachTimelapse"),"error")}}),pe=gt({mutationFn:()=>oe.deleteArchive(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.archiveDeleted"))},onError:()=>{d(c("archives.toast.failedDeleteArchive"),"error")}}),H=gt({mutationFn:()=>oe.toggleFavorite(t.id),onSuccess:ae=>{u.invalidateQueries({queryKey:["archives"]}),d(ae.is_favorite?c("archives.toast.addedToFavorites"):c("archives.toast.removedFromFavorites"))}}),{data:O}=ct({queryKey:["archive-folders",t.id],queryFn:()=>oe.getLibraryFoldersByArchive(t.id)}),J=gt({mutationFn:ae=>oe.updateArchive(t.id,{project_id:ae}),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),u.invalidateQueries({queryKey:["projects"]}),d(c("archives.toast.projectUpdated"))},onError:()=>{d(c("archives.toast.failedUpdateProject"),"error")}}),le=ae=>{ae.preventDefault(),ge({x:ae.clientX,y:ae.clientY})},we=[...Pf(t.filename)?[{label:c("archives.menu.print"),icon:a.jsx(Ur,{className:"w-4 h-4"}),onClick:()=>b(!0),disabled:!p("archives","reprint",t.created_by_id),title:p("archives","reprint",t.created_by_id)?void 0:c("archives.permission.noReprint")},{label:c("archives.menu.schedule"),icon:a.jsx(ti,{className:"w-4 h-4"}),onClick:()=>Y(!0),disabled:!h("queue:create"),title:h("queue:create")?void 0:c("archives.permission.noAddToQueue")},{label:c("archives.menu.openInBambuStudio"),icon:a.jsx(Xr,{className:"w-4 h-4"}),onClick:()=>{const ae=t.print_name||t.filename||"model",Le=`${window.location.origin}${oe.getArchiveForSlicer(t.id,ae)}`;lc(Le)}}]:[{label:c("archives.menu.slice"),icon:a.jsx(Xr,{className:"w-4 h-4"}),onClick:()=>{const ae=t.print_name||t.filename||"model",Le=`${window.location.origin}${oe.getArchiveForSlicer(t.id,ae)}`;lc(Le)}}],{label:t.external_url?c("archives.menu.externalLink"):c("archives.menu.viewOnMakerWorld"),icon:a.jsx(oh,{className:"w-4 h-4"}),onClick:()=>{const ae=t.external_url||t.makerworld_url;ae&&window.open(ae,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.preview3d"),icon:a.jsx(Ui,{className:"w-4 h-4"}),onClick:()=>y(!0)},{label:c("archives.menu.viewTimelapse"),icon:a.jsx(sh,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!t.timelapse_path},{label:c("archives.menu.scanForTimelapse"),icon:a.jsx(Y1,{className:"w-4 h-4"}),onClick:()=>he.mutate(),disabled:!t.printer_id||!!t.timelapse_path||he.isPending||!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?c("archives.menu.downloadSource3mf"):c("archives.menu.uploadSource3mf"),icon:a.jsx(W1,{className:"w-4 h-4"}),onClick:()=>{t.source_3mf_path?oe.downloadSource3mf(t.id).catch(ae=>{console.error("Source 3MF download failed:",ae)}):Ce.current?.click()},disabled:!t.source_3mf_path&&!p("archives","update",t.created_by_id),title:!t.source_3mf_path&&!p("archives","update",t.created_by_id)?c("archives.permission.noUploadFiles"):void 0},...t.source_3mf_path?[{label:c("archives.menu.replaceSource3mf"),icon:a.jsx(Ba,{className:"w-4 h-4"}),onClick:()=>Ce.current?.click(),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},{label:c("archives.menu.removeSource3mf"),icon:a.jsx(an,{className:"w-4 h-4"}),onClick:()=>$(!0),danger:!0,disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")}]:[],{label:t.f3d_path?c("archives.menu.replaceF3d"):c("archives.menu.uploadF3d"),icon:a.jsx(Ui,{className:"w-4 h-4"}),onClick:()=>Fe.current?.click(),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},...t.f3d_path?[{label:c("archives.menu.downloadF3d"),icon:a.jsx(wi,{className:"w-4 h-4"}),onClick:()=>{oe.downloadF3d(t.id).catch(ae=>{console.error("F3D download failed:",ae)})}},{label:c("archives.menu.removeF3d"),icon:a.jsx(an,{className:"w-4 h-4"}),onClick:()=>ne(!0),danger:!0,disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")}]:[],{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.download"),icon:a.jsx(wi,{className:"w-4 h-4"}),onClick:()=>{oe.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(ae=>{console.error("Archive download failed:",ae)})},disabled:!h("archives:read"),title:h("archives:read")?void 0:c("archives.permission.noDownload")},{label:c("archives.menu.copyDownloadLink"),icon:a.jsx(Ul,{className:"w-4 h-4"}),onClick:()=>{const ae=`${window.location.origin}${oe.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(ae).then(()=>{d(c("archives.toast.linkCopied"))}).catch(()=>{d(c("archives.toast.failedCopyLink"),"error")})},disabled:!h("archives:read"),title:h("archives:read")?void 0:c("archives.permission.noCopyLink")},{label:c("archives.menu.qrCode"),icon:a.jsx(DW,{className:"w-4 h-4"}),onClick:()=>U(!0)},{label:t.photos?.length?c("archives.menu.viewPhotosCount",{count:t.photos.length}):c("archives.menu.viewPhotos"),icon:a.jsx(Bg,{className:"w-4 h-4"}),onClick:()=>V(!0),disabled:!t.photos?.length},{label:c("archives.menu.projectPage"),icon:a.jsx(fs,{className:"w-4 h-4"}),onClick:()=>z(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?c("archives.menu.removeFromFavorites"):c("archives.menu.addToFavorites"),icon:a.jsx(sm,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>H.mutate(),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},{label:c("archives.menu.edit"),icon:a.jsx(ea,{className:"w-4 h-4"}),onClick:()=>k(!0),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives")},...t.project_id&&t.project_name?[{label:c("archives.menu.goToProject",{name:t.project_name}),icon:a.jsx(es,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:c("archives.menu.addToProject"),icon:a.jsx(es,{className:"w-4 h-4"}),onClick:()=>{},disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?void 0:c("archives.permission.noUpdateArchives"),submenu:(()=>{const ae=[];if(t.project_id&&ae.push({label:c("archives.menu.removeFromProject"),icon:a.jsx(Lt,{className:"w-4 h-4"}),onClick:()=>J.mutate(null),disabled:!p("archives","update",t.created_by_id)}),!s)ae.push({label:c("archives.menu.loading"),icon:a.jsx(pt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const Le=s.filter(Be=>Be.status==="active");Le.length===0?ae.push({label:c("archives.menu.noProjectsAvailable"),icon:a.jsx(es,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):Le.forEach(Be=>{ae.push({label:Be.name,icon:a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Be.color||"#888"}}),onClick:()=>J.mutate(Be.id),disabled:t.project_id===Be.id||!p("archives","update",t.created_by_id)})})}return ae})()},{label:c(n?"archives.menu.deselect":"archives.menu.select"),icon:n?a.jsx(Gs,{className:"w-4 h-4"}):a.jsx(cl,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.delete"),icon:a.jsx(an,{className:"w-4 h-4"}),onClick:()=>N(!0),danger:!0,disabled:!p("archives","delete",t.created_by_id),title:p("archives","delete",t.created_by_id)?void 0:c("archives.permission.noDelete")}];return a.jsxs(St,{"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:le,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:ae=>{ae.stopPropagation(),r(t.id)},children:n?a.jsx(Gs,{className:"w-5 h-5 text-bambu-green"}):a.jsx(cl,{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:()=>ie(!0),onMouseLeave:()=>ie(!1),children:[t.thumbnail_path?a.jsx("img",{src:me!==null&&Ze.length>0?oe.getArchivePlateThumbnail(t.id,Ze[Q]?.index??0):oe.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(Lu,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),G&&Ze.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 ${m?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:ae=>{ae.stopPropagation(),ue(Le=>{const Be=Le??0;return Be>0?Be-1:Ze.length-1})},title:c("archives.card.previousPlate"),children:a.jsx(bh,{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 ${m?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:ae=>{ae.stopPropagation(),ue(Le=>{const Be=Le??0;return Be<Ze.length-1?Be+1:0})},title:c("archives.card.nextPlate"),children:a.jsx(vs,{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 ${m?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:Ze.map((ae,Le)=>a.jsx("button",{className:`w-2 h-2 rounded-full transition-colors ${Le===Q?"bg-bambu-green":"bg-white/50 hover:bg-white/80"}`,onClick:Be=>{Be.stopPropagation(),ue(Le)},title:ae.name||c("archives.card.plateNumber",{index:ae.index})},ae.index))})]}),a.jsx("button",{className:`absolute top-2 left-2 p-1.5 rounded bg-black/50 hover:bg-black/70 transition-all ${m?"opacity-100":"opacity-0 group-hover:opacity-100"} ${i?"left-10":""}`,onClick:ae=>{ae.stopPropagation();const Le=ae.currentTarget.getBoundingClientRect();ge({x:Le.left,y:Le.bottom+4})},title:c("archives.card.moreOptions"),children:a.jsx(ah,{className:"w-5 h-5 text-white"})}),a.jsx("button",{className:`absolute top-2 right-2 p-1 rounded transition-colors ${p("archives","update",t.created_by_id)?"bg-black/50 hover:bg-black/70":"bg-black/30 cursor-not-allowed"}`,onClick:ae=>{ae.stopPropagation(),p("archives","update",t.created_by_id)&&H.mutate()},disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?t.is_favorite?c("archives.card.removeFromFavorites"):c("archives.card.addToFavorites"):c("archives.permission.noUpdateArchives"),children:a.jsx(sm,{className:`w-5 h-5 ${t.is_favorite?"text-yellow-400 fill-yellow-400":"text-white"} ${p("archives","update",t.created_by_id)?"":"opacity-50"}`})}),(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"?c("archives.card.cancelled"):c("archives.card.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:c("archives.card.duplicateTitle"),children:[a.jsx(Ul,{className:"w-3 h-3"}),c("archives.card.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:ae=>{ae.stopPropagation();const Le=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Be=`${window.location.origin}${oe.getSource3mfForSlicer(t.id,Le)}`;lc(Be)},title:c("archives.card.openSource3mf"),children:a.jsx(W1,{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:ae=>{ae.stopPropagation(),oe.downloadF3d(t.id).catch(Le=>{console.error("F3D download failed:",Le)})},title:c("archives.card.downloadF3d"),children:a.jsx(Ui,{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:ae=>{ae.stopPropagation(),E(!0)},title:c("archives.card.viewTimelapse"),children:a.jsx(sh,{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:ae=>{ae.stopPropagation(),V(!0)},title:t.photos.length===1?c("archives.card.viewPhoto"):c("archives.card.viewPhotos",{count:t.photos.length}),children:[a.jsx(Bg,{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})]}),O&&O.length>0&&a.jsx(Fs,{to:`/files?folder=${O[0].id}`,className:"absolute bottom-2 p-1.5 rounded bg-black/60 hover:bg-black/80 transition-colors",onClick:ae=>ae.stopPropagation(),title:c("archives.card.openFolder",{name:O[0].name}),style:{left:t.source_3mf_path?t.f3d_path?"5.5rem":"3rem":t.f3d_path?"3rem":"0.5rem"},children:a.jsx(zl,{className:"w-4 h-4 text-yellow-400"})})]}),a.jsxs(Nt,{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 ${Pf(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:Pf(t.filename)?c("archives.card.slicedFile"):c("archives.card.sourceFile"),children:Pf(t.filename)?c("archives.card.gcode"):c("archives.card.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(ae=>ae.id===t.project_id)?.color||"#6b7280"}20`,color:s?.find(ae=>ae.id===t.project_id)?.color||"#6b7280"},title:c("archives.card.project",{name: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: ${r0(t.print_time_seconds||0)}
  8268. Actual: ${r0(t.actual_time_seconds||0)}
  8269. Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${r0(t.actual_time_seconds)}`:`Estimated: ${r0(t.print_time_seconds||0)}`,children:[a.jsx(tr,{className:"w-3 h-3"}),r0(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(bc,{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(xs,{className:"w-3 h-3"}),t.total_layers&&a.jsx("span",{children:t.total_layers===1?c("archives.card.layer",{count:t.total_layers}):c("archives.card.layers",{count:t.total_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===1?c("archives.card.object",{count:t.object_count}):c("archives.card.objects",{count:t.object_count}),children:[a.jsx(Ui,{className:"w-3 h-3"}),t.object_count===1?c("archives.card.object",{count:t.object_count}):c("archives.card.objects",{count:t.object_count})]}),t.sliced_for_model&&a.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:c("archives.card.slicedFor",{model:t.sliced_for_model}),children:[a.jsx(Ur,{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((ae,Le)=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:ae},title:ae},Le))})]})]}),(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(OW,{className:"w-3 h-3"})}),t.tags?.split(",").map((ae,Le)=>a.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:ae.trim()},Le))]}),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:Vg(t.created_at,l)}),a.jsxs("div",{className:"flex items-center gap-2",children:[t.created_by_username&&a.jsxs("span",{className:"flex items-center gap-1",title:c("archives.card.uploadedBy",{name:t.created_by_username}),children:[a.jsx(om,{className:"w-3 h-3"}),t.created_by_username]}),a.jsx("span",{children:QN(t.file_size)})]})]}),a.jsxs("div",{className:"flex gap-1 mt-3",children:[Pf(t.filename)?a.jsxs(a.Fragment,{children:[a.jsxs(Ae,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>b(!0),disabled:!p("archives","reprint",t.created_by_id),title:p("archives","reprint",t.created_by_id)?void 0:c("archives.card.noPermissionReprint"),children:[a.jsx(Ur,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:c("archives.card.reprint")})]}),a.jsxs(Ae,{variant:"secondary",size:"sm",className:"flex-1 min-w-0",onClick:()=>Y(!0),disabled:!h("queue:create"),title:h("queue:create")?c("archives.card.schedulePrint"):c("archives.permission.noAddToQueue"),children:[a.jsx(ti,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:c("archives.card.schedule")})]}),a.jsx(Ae,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ae=t.print_name||t.filename||"model",Le=`${window.location.origin}${oe.getArchiveForSlicer(t.id,ae)}`;lc(Le)},title:c("archives.card.openInBambuStudio"),children:a.jsx(Xr,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):a.jsxs(Ae,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const ae=t.print_name||t.filename||"model",Le=`${window.location.origin}${oe.getArchiveForSlicer(t.id,ae)}`;lc(Le)},title:c("archives.card.openInBambuStudioToSlice"),children:[a.jsx(Xr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"hidden sm:inline",children:c("archives.card.slice")})]}),a.jsx(Ae,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ae=t.external_url||t.makerworld_url;ae&&window.open(ae,"_blank")},disabled:!t.external_url&&!t.makerworld_url,title:t.external_url?c("archives.card.externalLink"):t.makerworld_url?c("archives.card.makerWorld",{designer:t.designer||c("archives.card.viewProject")}):c("archives.card.noExternalLink"),children:a.jsx(oh,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!t.external_url&&!t.makerworld_url?"opacity-20":""}`})}),a.jsx(Ae,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>y(!0),title:c("archives.card.preview3d"),children:a.jsx(Ui,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Ae,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{oe.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(ae=>{console.error("Archive download failed:",ae)})},title:c("archives.card.download"),children:a.jsx(wi,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Ae,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>k(!0),disabled:!p("archives","update",t.created_by_id),title:p("archives","update",t.created_by_id)?c("archives.card.edit"):c("archives.card.noPermissionEdit"),children:a.jsx(ea,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),a.jsx(Ae,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>N(!0),disabled:!p("archives","delete",t.created_by_id),title:p("archives","delete",t.created_by_id)?c("archives.card.delete"):c("archives.card.noPermissionDelete"),children:a.jsx(an,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),T&&a.jsx(Cee,{archive:t,onClose:()=>k(!1)}),x&&a.jsx(gL,{archiveId:t.id,title:t.print_name||t.filename,fileType:xre(t.filename),onClose:()=>y(!1)}),v&&a.jsx(Dh,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),S&&a.jsx(Zn,{title:c("archives.modal.deleteArchive"),message:c("archives.modal.deleteConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.deleteButton"),variant:"danger",onConfirm:()=>{pe.mutate(),N(!1)},onCancel:()=>N(!1)}),te&&a.jsx(Zn,{title:c("archives.modal.removeSource3mf"),message:c("archives.modal.removeSource3mfConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{q.mutate(),$(!1)},onCancel:()=>$(!1)}),W&&a.jsx(Zn,{title:c("archives.modal.removeF3d"),message:c("archives.modal.removeF3dConfirm",{name:t.print_name||t.filename}),confirmText:c("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{B.mutate(),ne(!1)},onCancel:()=>ne(!1)}),re&&a.jsx(jee,{x:re.x,y:re.y,items:we,onClose:()=>ge(null)}),C&&t.timelapse_path&&a.jsx(gre,{src:oe.getArchiveTimelapse(t.id),title:c("archives.modal.timelapse",{name:t.print_name||t.filename}),downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>E(!1),onEdit:()=>{u.invalidateQueries({queryKey:["archives"]}),E(!1)}}),P&&D.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:()=>{A(!1),I([])},className:"text-gray-400 hover:text-white p-1",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:D.map(ae=>a.jsxs("button",{onClick:()=>ke.mutate(ae.name),disabled:ke.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(sh,{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:ae.name}),a.jsxs("p",{className:"text-sm text-gray-400",children:[QN(ae.size),ae.mtime&&` • ${Vg(ae.mtime,l)}`]})]})]},ae.name))}),a.jsx("div",{className:"p-4 border-t border-gray-700",children:a.jsx(Ae,{variant:"secondary",onClick:()=>{A(!1),I([])},className:"w-full",children:"Cancel"})})]})}),L&&a.jsx(Pee,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>U(!1)}),j&&t.photos&&t.photos.length>0&&a.jsx(Dee,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>V(!1),onDelete:async ae=>{try{await oe.deleteArchivePhoto(t.id,ae),u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.photoDeleted"))}catch{d(c("archives.toast.failedDeletePhoto"),"error")}}}),K&&a.jsx(pre,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>z(!1)}),X&&a.jsx(Dh,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>Y(!1)}),a.jsx("input",{ref:Ce,type:"file",accept:".3mf",className:"hidden",onChange:ae=>{const Le=ae.target.files?.[0];Le&&de.mutate(Le),ae.target.value=""}}),a.jsx("input",{ref:Fe,type:"file",accept:".f3d",className:"hidden",onChange:ae=>{const Le=ae.target.files?.[0];Le&&ee.mutate(Le),ae.target.value=""}})]})}function _qe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:s,isHighlighted:o,t:l}){const c=sn(),{showToast:u}=Hn(),{hasPermission:d,canModify:h}=Ci(),[p,m]=_.useState(!1),[x,y]=_.useState(!1),[v,b]=_.useState(!1),[S,N]=_.useState(!1),[T,k]=_.useState(!1),[C,E]=_.useState(!1),[P,A]=_.useState(!1),[D,I]=_.useState([]),[L,U]=_.useState(!1),[j,V]=_.useState(!1),[K,z]=_.useState(!1),[X,Y]=_.useState(!1),[te,$]=_.useState(!1),[W,ne]=_.useState(null),re=_.useRef(null),ge=_.useRef(null),me=gt({mutationFn:B=>oe.uploadSource3mf(t.id,B),onSuccess:B=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.source3mfAttached",{filename:B.filename}))},onError:B=>{u(B.message||l("archives.toast.failedUploadSource3mf"),"error")}}),ue=gt({mutationFn:()=>oe.deleteSource3mf(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.source3mfRemoved"))},onError:B=>{u(B.message||l("archives.toast.failedRemoveSource3mf"),"error")}}),Te=gt({mutationFn:B=>oe.uploadF3d(t.id,B),onSuccess:B=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.f3dAttached",{filename:B.filename}))},onError:B=>{u(B.message||l("archives.toast.failedUploadF3d"),"error")}}),ie=gt({mutationFn:()=>oe.deleteF3d(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.f3dRemoved"))},onError:B=>{u(B.message||l("archives.toast.failedRemoveF3d"),"error")}}),Ce=gt({mutationFn:()=>oe.scanArchiveTimelapse(t.id),onSuccess:B=>{B.status==="attached"?(c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.timelapseAttached",{filename:B.filename}))):B.status==="exists"?u(l("archives.toast.timelapseAlreadyAttached")):B.status==="not_found"&&B.available_files&&B.available_files.length>0?(I(B.available_files),A(!0)):u(B.message||l("archives.toast.noMatchingTimelapse"),"warning")},onError:B=>{u(B.message||l("archives.toast.failedScanTimelapse"),"error")}}),Fe=gt({mutationFn:B=>oe.selectArchiveTimelapse(t.id,B),onSuccess:B=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.timelapseAttached",{filename:B.filename})),A(!1),I([])},onError:B=>{u(B.message||l("archives.toast.failedAttachTimelapse"),"error")}}),xe=gt({mutationFn:()=>oe.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.archiveDeleted"))},onError:()=>{u(l("archives.toast.failedDeleteArchive"),"error")}}),Ze=gt({mutationFn:()=>oe.toggleFavorite(t.id),onSuccess:B=>{c.invalidateQueries({queryKey:["archives"]}),u(B.is_favorite?l("archives.toast.addedToFavorites"):l("archives.toast.removedFromFavorites"))}}),{data:G}=ct({queryKey:["archive-folders",t.id],queryFn:()=>oe.getLibraryFoldersByArchive(t.id)}),Q=gt({mutationFn:B=>oe.updateArchive(t.id,{project_id:B}),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),c.invalidateQueries({queryKey:["projects"]}),u(l("archives.toast.projectUpdated"))},onError:()=>{u(l("archives.toast.failedUpdateProject"),"error")}}),de=B=>{B.preventDefault(),ne({x:B.clientX,y:B.clientY})},ee=[...Pf(t.filename)?[{label:l("archives.menu.print"),icon:a.jsx(Ur,{className:"w-4 h-4"}),onClick:()=>b(!0),disabled:!h("archives","reprint",t.created_by_id),title:h("archives","reprint",t.created_by_id)?void 0:l("archives.permission.noReprint")},{label:l("archives.menu.schedule"),icon:a.jsx(ti,{className:"w-4 h-4"}),onClick:()=>N(!0),disabled:!d("queue:create"),title:d("queue:create")?void 0:l("archives.permission.noAddToQueue")},{label:l("archives.menu.openInBambuStudio"),icon:a.jsx(Xr,{className:"w-4 h-4"}),onClick:()=>{const B=t.print_name||t.filename||"model",he=`${window.location.origin}${oe.getArchiveForSlicer(t.id,B)}`;lc(he)}}]:[{label:l("archives.menu.slice"),icon:a.jsx(Xr,{className:"w-4 h-4"}),onClick:()=>{const B=t.print_name||t.filename||"model",he=`${window.location.origin}${oe.getArchiveForSlicer(t.id,B)}`;lc(he)}}],{label:t.external_url?l("archives.menu.externalLink"):l("archives.menu.viewOnMakerWorld"),icon:a.jsx(oh,{className:"w-4 h-4"}),onClick:()=>{const B=t.external_url||t.makerworld_url;B&&window.open(B,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:l("archives.menu.preview3d"),icon:a.jsx(Ui,{className:"w-4 h-4"}),onClick:()=>k(!0)},{label:l("archives.menu.viewTimelapse"),icon:a.jsx(sh,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!t.timelapse_path},{label:l("archives.menu.scanForTimelapse"),icon:a.jsx(Y1,{className:"w-4 h-4"}),onClick:()=>Ce.mutate(),disabled:!t.printer_id||!!t.timelapse_path||Ce.isPending||!h("archives","update",t.created_by_id),title:h("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},{label:"",divider:!0,onClick:()=>{}},{label:t.source_3mf_path?l("archives.menu.downloadSource3mf"):l("archives.menu.uploadSource3mf"),icon:a.jsx(W1,{className:"w-4 h-4"}),onClick:()=>{t.source_3mf_path?oe.downloadSource3mf(t.id).catch(B=>{console.error("Source 3MF download failed:",B)}):re.current?.click()},disabled:!t.source_3mf_path&&!h("archives","update",t.created_by_id),title:!t.source_3mf_path&&!h("archives","update",t.created_by_id)?l("archives.permission.noUploadFiles"):void 0},...t.source_3mf_path?[{label:l("archives.menu.replaceSource3mf"),icon:a.jsx(Ba,{className:"w-4 h-4"}),onClick:()=>re.current?.click(),disabled:!h("archives","update",t.created_by_id),title:h("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},{label:l("archives.menu.removeSource3mf"),icon:a.jsx(an,{className:"w-4 h-4"}),onClick:()=>Y(!0),danger:!0,disabled:!h("archives","update",t.created_by_id),title:h("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")}]:[],{label:t.f3d_path?l("archives.menu.replaceF3d"):l("archives.menu.uploadF3d"),icon:a.jsx(Ui,{className:"w-4 h-4"}),onClick:()=>ge.current?.click(),disabled:!h("archives","update",t.created_by_id),title:h("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},...t.f3d_path?[{label:l("archives.menu.downloadF3d"),icon:a.jsx(wi,{className:"w-4 h-4"}),onClick:()=>{oe.downloadF3d(t.id).catch(B=>{console.error("F3D download failed:",B)})}},{label:l("archives.menu.removeF3d"),icon:a.jsx(an,{className:"w-4 h-4"}),onClick:()=>$(!0),danger:!0,disabled:!h("archives","update",t.created_by_id),title:h("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")}]:[],{label:"",divider:!0,onClick:()=>{}},{label:l("archives.menu.download"),icon:a.jsx(wi,{className:"w-4 h-4"}),onClick:()=>{oe.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(B=>{console.error("Archive download failed:",B)})},disabled:!d("archives:read"),title:d("archives:read")?void 0:l("archives.permission.noDownload")},{label:l("archives.menu.copyDownloadLink"),icon:a.jsx(Ul,{className:"w-4 h-4"}),onClick:()=>{const B=`${window.location.origin}${oe.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(B).then(()=>{u(l("archives.toast.linkCopied"))}).catch(()=>{u(l("archives.toast.failedCopyLink"),"error")})},disabled:!d("archives:read"),title:d("archives:read")?void 0:l("archives.permission.noCopyLink")},{label:l("archives.menu.qrCode"),icon:a.jsx(DW,{className:"w-4 h-4"}),onClick:()=>U(!0)},{label:t.photos?.length?l("archives.menu.viewPhotosCount",{count:t.photos.length}):l("archives.menu.viewPhotos"),icon:a.jsx(Bg,{className:"w-4 h-4"}),onClick:()=>V(!0),disabled:!t.photos?.length},{label:l("archives.menu.projectPage"),icon:a.jsx(fs,{className:"w-4 h-4"}),onClick:()=>z(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?l("archives.menu.removeFromFavorites"):l("archives.menu.addToFavorites"),icon:a.jsx(sm,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>Ze.mutate(),disabled:!h("archives","update",t.created_by_id),title:h("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},{label:l("archives.menu.edit"),icon:a.jsx(ea,{className:"w-4 h-4"}),onClick:()=>m(!0),disabled:!h("archives","update",t.created_by_id),title:h("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},...t.project_id&&t.project_name?[{label:l("archives.menu.goToProject",{name:t.project_name}),icon:a.jsx(es,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:l("archives.menu.addToProject"),icon:a.jsx(es,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const B=[];if(t.project_id&&B.push({label:l("archives.menu.removeFromProject"),icon:a.jsx(Lt,{className:"w-4 h-4"}),onClick:()=>Q.mutate(null)}),!s)B.push({label:l("archives.menu.loading"),icon:a.jsx(pt,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const he=s.filter(ke=>ke.status==="active");he.length===0?B.push({label:l("archives.menu.noProjectsAvailable"),icon:a.jsx(es,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):he.forEach(ke=>{B.push({label:ke.name,icon:a.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:ke.color||"#888"}}),onClick:()=>Q.mutate(ke.id),disabled:t.project_id===ke.id})})}return B})()},{label:l(n?"archives.menu.deselect":"archives.menu.select"),icon:n?a.jsx(Gs,{className:"w-4 h-4"}):a.jsx(cl,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:l("archives.menu.delete"),icon:a.jsx(an,{className:"w-4 h-4"}),onClick:()=>y(!0),danger:!0,disabled:!h("archives","delete",t.created_by_id),title:h("archives","delete",t.created_by_id)?void 0:l("archives.permission.noDelete")}];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:de,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(Gs,{className:"w-4 h-4 text-bambu-green"}):a.jsx(cl,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?a.jsx("img",{src:oe.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(Lu,{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:l("archives.list.hasTimelapse"),children:a.jsx(sh,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),G&&G.length>0&&a.jsx(Fs,{to:`/files?folder=${G[0].id}`,className:"flex-shrink-0",title:l("archives.card.openFolder",{name:G[0].name}),onClick:B=>B.stopPropagation(),children:a.jsx(zl,{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:l("archives.card.slicedFor",{model:t.sliced_for_model}),children:[a.jsx(Ur,{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((B,he)=>a.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:B},title:B},he))})]})]}),a.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:e}),a.jsxs("div",{className:"col-span-2 text-sm text-bambu-gray",children:[a.jsx("div",{children:$g(t.created_at)}),t.created_by_username&&a.jsxs("div",{className:"flex items-center gap-1 text-xs opacity-75",title:l("archives.card.uploadedBy",{name:t.created_by_username}),children:[a.jsx(om,{className:"w-3 h-3"}),t.created_by_username]})]}),a.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:QN(t.file_size)}),a.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[a.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>{const B=t.print_name||t.filename||"model",he=`${window.location.origin}${oe.getArchiveForSlicer(t.id,B)}`;lc(he)},title:l("archives.card.openInBambuStudio"),children:a.jsx(Xr,{className:"w-4 h-4"})}),(t.external_url||t.makerworld_url)&&a.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>window.open(t.external_url||t.makerworld_url,"_blank"),title:t.external_url?l("archives.card.externalLink"):"MakerWorld",children:a.jsx(oh,{className:"w-4 h-4"})}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>{oe.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(B=>{console.error("Archive download failed:",B)})},title:l("archives.card.download"),children:a.jsx(wi,{className:"w-4 h-4"})}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>m(!0),disabled:!h("archives","update",t.created_by_id),title:h("archives","update",t.created_by_id)?l("archives.card.edit"):l("archives.card.noPermissionEdit"),children:a.jsx(ea,{className:"w-4 h-4"})}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>y(!0),disabled:!h("archives","delete",t.created_by_id),title:h("archives","delete",t.created_by_id)?l("archives.card.delete"):l("archives.card.noPermissionDelete"),children:a.jsx(an,{className:"w-4 h-4 text-red-400"})}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:B=>{const he=B.currentTarget.getBoundingClientRect();ne({x:he.left,y:he.bottom+4})},title:l("archives.card.moreOptions"),children:a.jsx(ah,{className:"w-4 h-4"})})]})]}),p&&a.jsx(Cee,{archive:t,onClose:()=>m(!1)}),T&&a.jsx(gL,{archiveId:t.id,title:t.print_name||t.filename,fileType:xre(t.filename),onClose:()=>k(!1)}),v&&a.jsx(Dh,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>b(!1)}),x&&a.jsx(Zn,{title:l("archives.modal.deleteArchive"),message:l("archives.modal.deleteConfirm",{name:t.print_name||t.filename}),confirmText:l("archives.modal.deleteButton"),variant:"danger",onConfirm:()=>{xe.mutate(),y(!1)},onCancel:()=>y(!1)}),X&&a.jsx(Zn,{title:l("archives.modal.removeSource3mf"),message:l("archives.modal.removeSource3mfConfirm",{name:t.print_name||t.filename}),confirmText:l("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{ue.mutate(),Y(!1)},onCancel:()=>Y(!1)}),te&&a.jsx(Zn,{title:l("archives.modal.removeF3d"),message:l("archives.modal.removeF3dConfirm",{name:t.print_name||t.filename}),confirmText:l("archives.modal.removeButton"),variant:"danger",onConfirm:()=>{ie.mutate(),$(!1)},onCancel:()=>$(!1)}),W&&a.jsx(jee,{x:W.x,y:W.y,items:ee,onClose:()=>ne(null)}),C&&t.timelapse_path&&a.jsx(gre,{src:oe.getArchiveTimelapse(t.id),title:l("archives.modal.timelapse",{name:t.print_name||t.filename}),downloadFilename:`${t.print_name||t.filename}_timelapse.mp4`,archiveId:t.id,onClose:()=>E(!1),onEdit:()=>{c.invalidateQueries({queryKey:["archives"]}),E(!1)}}),P&&D.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:()=>{A(!1),I([])},className:"text-gray-400 hover:text-white p-1",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:D.map(B=>a.jsxs("button",{onClick:()=>Fe.mutate(B.name),disabled:Fe.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:B.name}),a.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[a.jsx("span",{children:QN(B.size)}),B.mtime&&a.jsx("span",{children:$g(B.mtime)})]})]},B.name))})]})}),L&&a.jsx(Pee,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>U(!1)}),j&&t.photos&&a.jsx(Dee,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>V(!1),onDelete:async B=>{try{await oe.deleteArchivePhoto(t.id,B),c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.photoDeleted"))}catch{u(l("archives.toast.failedDeletePhoto"),"error")}}}),K&&a.jsx(pre,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>z(!1)}),S&&a.jsx(Dh,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>N(!1)}),a.jsx("input",{ref:re,type:"file",accept:".3mf",className:"hidden",onChange:B=>{const he=B.target.files?.[0];he&&me.mutate(he),B.target.value=""}}),a.jsx("input",{ref:ge,type:"file",accept:".f3d",className:"hidden",onChange:B=>{const he=B.target.files?.[0];he&&Te.mutate(he),B.target.value=""}})]})}const Sqe=[{id:"all",label:"All Archives",icon:a.jsx(zl,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:a.jsx(tr,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:a.jsx(ti,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:a.jsx(ti,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:a.jsx(sm,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:a.jsx(Vi,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:a.jsx(Ul,{className:"w-4 h-4"})}];function Nqe(){const{t}=On(),e=sn(),{showToast:n}=Hn(),{hasPermission:r,hasAnyPermission:i}=Ci(),s=_.useRef(null),[o,l]=_.useState(""),[c,u]=_.useState(()=>{const ce=localStorage.getItem("archiveFilterPrinter");return ce?Number(ce):null}),[d,h]=_.useState(()=>localStorage.getItem("archiveFilterMaterial")),[p,m]=_.useState(()=>{const ce=localStorage.getItem("archiveFilterColors");return ce?new Set(JSON.parse(ce)):new Set}),[x,y]=_.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[v,b]=_.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[S,N]=_.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[T,k]=_.useState(()=>localStorage.getItem("archiveFilterTag")),[C,E]=_.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[P,A]=_.useState(!1),[D,I]=_.useState([]),[L,U]=_.useState(!1),[j,V]=_.useState(new Set),[K,z]=_.useState(!1),[X,Y]=_.useState(!1),[te,$]=_.useState(!1),[W,ne]=_.useState(!1),[re,ge]=_.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[me,ue]=_.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[Te,ie]=_.useState(()=>localStorage.getItem("archiveCollection")||"all"),[Ce,Fe]=_.useState(!1),[xe,Ze]=_.useState(!1),[G,Q]=_.useState(!1),[de,q]=_.useState(!1),[ee,B]=_.useState(null);_.useEffect(()=>{if(ee){const ce=setTimeout(()=>{const ye=document.querySelector(`[data-archive-id="${ee}"]`);ye&&ye.scrollIntoView({behavior:"smooth",block:"center"})},100),$e=setTimeout(()=>B(null),5e3);return()=>{clearTimeout(ce),clearTimeout($e)}}},[ee]);const{data:he,isLoading:ke}=ct({queryKey:["archives",c],queryFn:()=>oe.getArchives(c||void 0)}),{data:pe}=ct({queryKey:["printers"],queryFn:oe.getPrinters}),{data:H}=ct({queryKey:["projects"],queryFn:()=>oe.getProjects()}),{data:O}=ct({queryKey:["settings"],queryFn:oe.getSettings}),J=O?.time_format||"system",le=gt({mutationFn:async ce=>(await Promise.all(ce.map($e=>oe.deleteArchive($e))),ce.length),onSuccess:ce=>{e.invalidateQueries({queryKey:["archives"]}),V(new Set),n(`${ce} archive${ce!==1?"s":""} deleted`)},onError:()=>{n(t("archives.toast.failedDeleteArchives"),"error")}});_.useEffect(()=>{c!==null?localStorage.setItem("archiveFilterPrinter",c.toString()):localStorage.removeItem("archiveFilterPrinter")},[c]),_.useEffect(()=>{d?localStorage.setItem("archiveFilterMaterial",d):localStorage.removeItem("archiveFilterMaterial")},[d]),_.useEffect(()=>{localStorage.setItem("archiveFilterColors",JSON.stringify([...p]))},[p]),_.useEffect(()=>{localStorage.setItem("archiveColorFilterMode",x)},[x]),_.useEffect(()=>{localStorage.setItem("archiveFilterFavorites",v.toString())},[v]),_.useEffect(()=>{localStorage.setItem("archiveHideFailed",S.toString())},[S]),_.useEffect(()=>{T?localStorage.setItem("archiveFilterTag",T):localStorage.removeItem("archiveFilterTag")},[T]),_.useEffect(()=>{localStorage.setItem("archiveFilterFileType",C)},[C]),_.useEffect(()=>{localStorage.setItem("archiveViewMode",re)},[re]),_.useEffect(()=>{localStorage.setItem("archiveSortBy",me)},[me]),_.useEffect(()=>{localStorage.setItem("archiveCollection",Te)},[Te]);const Se=new Map(pe?.map(ce=>[ce.id,ce.name])||[]),we=[...new Set(he?.flatMap(ce=>ce.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),ae=[...new Set(he?.flatMap(ce=>ce.filament_color?.split(",")||[]).filter(Boolean)||[])],Le=[...new Set(he?.flatMap(ce=>ce.tags?.split(",").map($e=>$e.trim())||[]).filter(Boolean)||[])].sort(),Be=he?.filter(ce=>{const $e=new Date,ye=zi(ce.created_at)||new Date(0);let Je=!0;switch(Te){case"recent":Je=$e.getTime()-ye.getTime()<1440*60*1e3;break;case"this-week":Je=$e.getTime()-ye.getTime()<10080*60*1e3;break;case"this-month":Je=ye.getMonth()===$e.getMonth()&&ye.getFullYear()===$e.getFullYear();break;case"favorites":Je=ce.is_favorite===!0;break;case"failed":Je=ce.status==="failed"||ce.status==="aborted";break;case"duplicates":Je=ce.duplicate_count>0;break}const at=(ce.print_name||ce.filename).toLowerCase().includes(o.toLowerCase()),jt=!d||ce.filament_type?.split(", ").includes(d),Dt=ce.filament_color?.split(",")||[],yn=p.size===0||(x==="or"?Dt.some(Gn=>p.has(Gn)):[...p].every(Gn=>Dt.includes(Gn))),cn=Te==="favorites"||!v||ce.is_favorite,rr=Te==="failed"||!S||ce.status!=="failed"&&ce.status!=="aborted",Vn=ce.tags?.split(",").map(Gn=>Gn.trim())||[],Jn=!T||Vn.includes(T),xn=Pf(ce.filename);return Je&&at&&jt&&yn&&cn&&rr&&Jn&&(C==="all"||C==="gcode"&&xn||C==="source"&&!xn)}).sort((ce,$e)=>{switch(me){case"date-desc":return(zi($e.created_at)?.getTime()||0)-(zi(ce.created_at)?.getTime()||0);case"date-asc":return(zi(ce.created_at)?.getTime()||0)-(zi($e.created_at)?.getTime()||0);case"name-asc":return(ce.print_name||ce.filename).localeCompare($e.print_name||$e.filename);case"name-desc":return($e.print_name||$e.filename).localeCompare(ce.print_name||ce.filename);case"size-desc":return $e.file_size-ce.file_size;case"size-asc":return ce.file_size-$e.file_size;default:return 0}}),Ve=K||j.size>0,He=ce=>{V($e=>{const ye=new Set($e);return ye.has(ce)?ye.delete(ce):ye.add(ce),ye})},be=()=>{Be&&V(new Set(Be.map(ce=>ce.id)))},Pe=()=>{V(new Set),z(!1)},Ie=ce=>{m($e=>{const ye=new Set($e);return ye.has(ce)?ye.delete(ce):ye.add(ce),ye})},_e=()=>{m(new Set)},Ke=()=>{l(""),u(null),h(null),b(!1),N(!1),k(null),E("all")},Me=o||c||d||v||S||T||C!=="all",it=_.useCallback(ce=>{ce.preventDefault(),ce.dataTransfer.types.includes("Files")&&U(!0)},[]),Ee=_.useCallback(ce=>{ce.preventDefault(),ce.currentTarget===ce.target&&U(!1)},[]),Xe=_.useCallback(ce=>{ce.preventDefault(),U(!1);const $e=Array.from(ce.dataTransfer.files).filter(ye=>ye.name.endsWith(".3mf"));$e.length>0?(I($e),A(!0)):ce.dataTransfer.files.length>0&&n(t("archives.page.only3mfSupported"),"warning")},[n,t]),ze=_.useCallback(ce=>{const $e=ce.target;if($e.tagName==="INPUT"||$e.tagName==="TEXTAREA"||$e.isContentEditable){ce.key==="Escape"&&$e.blur();return}switch(ce.key){case"/":ce.preventDefault(),s.current?.focus();break;case"u":case"U":!ce.metaKey&&!ce.ctrlKey&&(ce.preventDefault(),A(!0));break;case"Escape":Ve&&Pe();break}},[Ve]);return _.useEffect(()=>(document.addEventListener("keydown",ze),()=>document.removeEventListener("keydown",ze)),[ze]),a.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:it,onDragLeave:Ee,onDrop:Xe,children:[L&&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(Ba,{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:t("archives.releaseToUpload")})]})}),Ve&&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(Ae,{variant:"secondary",size:"sm",onClick:Pe,children:[a.jsx(Lt,{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:[j.size," selected"]}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsx(Ae,{variant:"secondary",size:"sm",onClick:be,children:"Select All"}),a.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:()=>$(!0),disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),children:[a.jsx(wh,{className:"w-4 h-4"}),"Tags"]}),a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:()=>ne(!0),disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),children:[a.jsx(es,{className:"w-4 h-4"}),"Project"]}),a.jsxs(Ae,{variant:"secondary",size:"sm",disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),onClick:()=>{const ce=Array.from(j);Promise.all(ce.map($e=>oe.toggleFavorite($e))).then(()=>{e.invalidateQueries({queryKey:["archives"]}),n(`Toggled favorites for ${ce.length} archive${ce.length!==1?"s":""}`)}).catch(()=>{n(t("archives.toast.failedUpdateFavorites"),"error")})},children:[a.jsx(sm,{className:"w-4 h-4"}),"Favorite"]}),a.jsxs(Ae,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>Y(!0),disabled:!i("archives:delete_own","archives:delete_all"),title:i("archives:delete_own","archives:delete_all")?void 0:t("archives.permission.noDelete"),children:[a.jsx(an,{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:Te,onChange:ce=>ie(ce.target.value),children:Sqe.map(ce=>a.jsx("option",{value:ce.id,children:ce.label},ce.id))})]}),a.jsxs("p",{className:"text-bambu-gray",children:[Be?.length||0," of ",he?.length||0," prints"]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"relative",children:[a.jsxs(Ae,{variant:"secondary",onClick:()=>Fe(!Ce),disabled:xe,children:[xe?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(K1,{className:"w-4 h-4"}),"Export"]}),Ce&&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()=>{Fe(!1),Ze(!0);try{const{blob:ce,filename:$e}=await oe.exportArchives({format:"csv",printerId:c||void 0,status:Te==="failed"?"failed":void 0,search:o||void 0}),ye=URL.createObjectURL(ce),Je=document.createElement("a");Je.href=ye,Je.download=$e,Je.click(),URL.revokeObjectURL(ye),n(t("archives.toast.exportDownloaded"))}catch{n(t("archives.toast.exportFailed"),"error")}finally{Ze(!1)}},children:[a.jsx(fs,{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()=>{Fe(!1),Ze(!0);try{const{blob:ce,filename:$e}=await oe.exportArchives({format:"xlsx",printerId:c||void 0,status:Te==="failed"?"failed":void 0,search:o||void 0}),ye=URL.createObjectURL(ce),Je=document.createElement("a");Je.href=ye,Je.download=$e,Je.click(),URL.revokeObjectURL(ye),n(t("archives.toast.exportDownloaded"))}catch{n(t("archives.toast.exportFailed"),"error")}finally{Ze(!1)}},children:[a.jsx(K1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),j.size>=2&&j.size<=5&&a.jsxs(Ae,{variant:"secondary",onClick:()=>Q(!0),children:[a.jsx(Ng,{className:"w-4 h-4"}),"Compare (",j.size,")"]}),!Ve&&a.jsxs(Ae,{variant:"secondary",onClick:()=>z(!0),children:[a.jsx(Gs,{className:"w-4 h-4"}),"Select"]}),a.jsxs(Ae,{onClick:()=>A(!0),disabled:!r("archives:create"),title:r("archives:create")?void 0:t("archives.permission.noCreate"),children:[a.jsx(Ba,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),a.jsx(St,{className:"mb-6",children:a.jsxs(Nt,{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(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{ref:s,type:"text",placeholder:t("archives.searchPlaceholder"),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:o,onChange:ce=>l(ce.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(hM,{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:c||"",onChange:ce=>u(ce.target.value?Number(ce.target.value):null),children:[a.jsx("option",{value:"",children:"All Printers"}),pe?.map(ce=>a.jsx("option",{value:ce.id,children:ce.name},ce.id))]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(bc,{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:d||"",onChange:ce=>h(ce.target.value||null),children:[a.jsx("option",{value:"",children:"All Materials"}),we.map(ce=>a.jsx("option",{value:ce,children:ce},ce))]})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(W1,{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:C,onChange:ce=>E(ce.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:()=>b(!v),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${v?"bg-yellow-500/20 border-yellow-500 text-yellow-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:t(v?"archives.showAll":"archives.showFavoritesOnly"),children:[a.jsx(sm,{className:`w-4 h-4 ${v?"fill-yellow-400":""}`}),a.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),a.jsxs("button",{onClick:()=>N(!S),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${S?"bg-red-500/20 border-red-500 text-red-400":"bg-bambu-dark border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:t(S?"archives.showFailedPrints":"archives.hideFailedPrints"),children:[a.jsx(Vi,{className:"w-4 h-4 "}),a.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),Le.length>0&&a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(wh,{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:T||"",onChange:ce=>k(ce.target.value||null),children:[a.jsx("option",{value:"",children:"All Tags"}),Le.map(ce=>a.jsx("option",{value:ce,children:ce},ce))]}),a.jsx("button",{onClick:()=>q(!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:t("archives.manageTags"),children:a.jsx(bM,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[a.jsx(_W,{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:me,onChange:ce=>ue(ce.target.value),children:[a.jsx("option",{value:"date-desc",children:t("archives.sortNewest")}),a.jsx("option",{value:"date-asc",children:t("archives.sortOldest")}),a.jsxs("option",{value:"name-asc",children:[t("archives.sortName")," A-Z"]}),a.jsxs("option",{value:"name-desc",children:[t("archives.sortName")," Z-A"]}),a.jsx("option",{value:"size-desc",children:t("archives.sortLargest")}),a.jsx("option",{value:"size-asc",children:t("archives.sortSmallest")})]})]}),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 ${re==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>ge("grid"),title:t("archives.gridView"),children:a.jsx(pM,{className:"w-4 h-4"})}),a.jsx("button",{className:`p-2 ${re==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>ge("list"),title:t("archives.listView"),children:a.jsx(gM,{className:"w-4 h-4"})}),a.jsx("button",{className:`p-2 ${re==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>ge("calendar"),title:t("archives.calendarView"),children:a.jsx($ce,{className:"w-4 h-4"})})]})]}),Me&&a.jsxs(Ae,{variant:"ghost",size:"sm",onClick:Ke,className:"text-bambu-gray hover:text-white",children:[a.jsx(Lt,{className:"w-4 h-4"}),"Reset"]})]}),ae.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:"}),p.size>1&&a.jsx("button",{onClick:()=>y(ce=>ce==="or"?"and":"or"),className:`px-2 py-0.5 text-xs rounded transition-colors ${x==="and"?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:x==="or"?"Match ANY selected color":"Match ALL selected colors",children:x.toUpperCase()}),a.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:ae.map(ce=>a.jsx("button",{onClick:()=>Ie(ce),className:`w-6 h-6 rounded-full border-2 transition-all ${p.has(ce)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:ce},title:ce},ce))}),p.size>0&&a.jsxs("button",{onClick:_e,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[a.jsx(Lt,{className:"w-3 h-3"}),"Clear"]})]})]})}),a.jsx(yqe,{}),ke?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("archives.loadingArchives")}):Be?.length===0?a.jsx(St,{children:a.jsxs(Nt,{className:"text-center py-12",children:[a.jsx("p",{className:"text-bambu-gray",children:t(o?"archives.noArchivesSearch":"archives.noArchivesYet")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):re==="calendar"?a.jsx(St,{className:"p-6",children:a.jsx(Y8e,{archives:Be||[],onArchiveClick:ce=>{l(""),ge("grid"),B(ce.id)},highlightedArchiveId:ee})}):re==="grid"?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:Be?.map(ce=>a.jsx(wqe,{archive:ce,printerName:ce.printer_id?Se.get(ce.printer_id)||"Unknown":ce.sliced_for_model?`Sliced for ${ce.sliced_for_model}`:"No Printer",isSelected:j.has(ce.id),onSelect:He,selectionMode:Ve,projects:H,isHighlighted:ce.id===ee,timeFormat:J,t},ce.id))}):re==="list"?a.jsx(St,{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"})]}),Be?.map(ce=>a.jsx(_qe,{archive:ce,printerName:ce.printer_id?Se.get(ce.printer_id)||"Unknown":ce.sliced_for_model?`Sliced for ${ce.sliced_for_model}`:"No Printer",isSelected:j.has(ce.id),onSelect:He,selectionMode:Ve,projects:H,isHighlighted:ce.id===ee,t},ce.id))]})}):null,P&&a.jsx(B8e,{onClose:()=>{A(!1),I([])},initialFiles:D}),X&&a.jsx(Zn,{title:t("archives.modal.deleteArchives"),message:t("archives.modal.deleteArchivesConfirm",{count:j.size}),confirmText:t("archives.modal.deleteCount",{count:j.size}),variant:"danger",onConfirm:()=>{le.mutate(Array.from(j)),Y(!1)},onCancel:()=>Y(!1)}),te&&a.jsx(V8e,{selectedIds:Array.from(j),existingTags:Le,onClose:()=>$(!1)}),W&&a.jsx(G8e,{selectedIds:Array.from(j),onClose:()=>ne(!1)}),G&&j.size>=2&&j.size<=5&&a.jsx(mqe,{archiveIds:Array.from(j),onClose:()=>{Q(!1),V(new Set),z(!1)}}),de&&a.jsx(vqe,{onClose:()=>q(!1)})]})}function Mqe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return _.useMemo(()=>r=>{e.forEach(i=>i(r))},e)}const U2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ix(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function aF(t){return"nodeType"in t}function Xs(t){var e,n;return t?Ix(t)?t:aF(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function sF(t){const{Document:e}=Xs(t);return t instanceof e}function _v(t){return Ix(t)?!1:t instanceof Xs(t).HTMLElement}function bre(t){return t instanceof Xs(t).SVGElement}function Ux(t){return t?Ix(t)?t.document:aF(t)?sF(t)?t:_v(t)||bre(t)?t.ownerDocument:document:document:document}const kc=U2?_.useLayoutEffect:_.useEffect;function oF(t){const e=_.useRef(t);return kc(()=>{e.current=t}),_.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 kqe(){const t=_.useRef(null),e=_.useCallback((r,i)=>{t.current=setInterval(r,i)},[]),n=_.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function Py(t,e){e===void 0&&(e=[t]);const n=_.useRef(t);return kc(()=>{n.current!==t&&(n.current=t)},e),n}function Sv(t,e){const n=_.useRef();return _.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function ZN(t){const e=oF(t),n=_.useRef(null),r=_.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function sR(t){const e=_.useRef();return _.useEffect(()=>{e.current=t},[t]),e.current}let Uj={};function Nv(t,e){return _.useMemo(()=>{if(e)return e;const n=Uj[t]==null?0:Uj[t]+1;return Uj[t]=n,t+"-"+n},[t,e])}function yre(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 Ig=yre(1),Dy=yre(-1);function Eqe(t){return"clientX"in t&&"clientY"in t}function lF(t){if(!t)return!1;const{KeyboardEvent:e}=Xs(t.target);return e&&t instanceof e}function Tqe(t){if(!t)return!1;const{TouchEvent:e}=Xs(t.target);return e&&t instanceof e}function oR(t){if(Tqe(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 Eqe(t)?{x:t.clientX,y:t.clientY}:null}const gx=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[gx.Translate.toString(t),gx.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),lq="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Aqe(t){return t.matches(lq)?t:t.querySelector(lq)}const Cqe={display:"none"};function jqe(t){let{id:e,value:n}=t;return ei.createElement("div",{id:e,style:Cqe},n)}function Pqe(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 ei.createElement("div",{id:e,style:i,role:"status","aria-live":r,"aria-atomic":!0},n)}function Dqe(){const[t,e]=_.useState("");return{announce:_.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const vre=_.createContext(null);function Rqe(t){const e=_.useContext(vre);_.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function Oqe(){const[t]=_.useState(()=>new Set),e=_.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[_.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 Lqe={draggable:`
  8270. To pick up a draggable item, press the space bar.
  8271. While dragging, use the arrow keys to move the item.
  8272. Press space again to drop the item in its new position, or press escape to cancel.
  8273. `},Fqe={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 Iqe(t){let{announcements:e=Fqe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Lqe}=t;const{announce:s,announcement:o}=Dqe(),l=Nv("DndLiveRegion"),[c,u]=_.useState(!1);if(_.useEffect(()=>{u(!0)},[]),Rqe(_.useMemo(()=>({onDragStart(h){let{active:p}=h;s(e.onDragStart({active:p}))},onDragMove(h){let{active:p,over:m}=h;e.onDragMove&&s(e.onDragMove({active:p,over:m}))},onDragOver(h){let{active:p,over:m}=h;s(e.onDragOver({active:p,over:m}))},onDragEnd(h){let{active:p,over:m}=h;s(e.onDragEnd({active:p,over:m}))},onDragCancel(h){let{active:p,over:m}=h;s(e.onDragCancel({active:p,over:m}))}}),[s,e])),!c)return null;const d=ei.createElement(ei.Fragment,null,ei.createElement(jqe,{id:r,value:i.draggable}),ei.createElement(Pqe,{id:l,announcement:o}));return n?bu.createPortal(d,n):d}var Zi;(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"})(Zi||(Zi={}));function JN(){}function eM(t,e){return _.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function wre(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return _.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const Hl=Object.freeze({x:0,y:0});function _re(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Sre(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function Uqe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function cq(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 Nre(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function uq(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 Mre=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=uq(e,e.left,e.top),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=_re(uq(c),i);s.push({id:l,data:{droppableContainer:o,value:u}})}}return s.sort(Sre)},zqe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=cq(e),s=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=cq(c),d=i.reduce((p,m,x)=>p+_re(u[x],m),0),h=Number((d/4).toFixed(4));s.push({id:l,data:{droppableContainer:o,value:h}})}}return s.sort(Sre)};function Bqe(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,h=d/(c+u-d);return Number(h.toFixed(4))}return 0}const Hqe=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=Bqe(l,e);c>0&&i.push({id:o,data:{droppableContainer:s,value:c}})}}return i.sort(Uqe)};function $qe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function kre(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:Hl}function Vqe(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 Gqe=Vqe(1);function qqe(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 Wqe(t,e,n){const r=qqe(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,h=s?t.height/s:t.height;return{width:d,height:h,top:u,right:c+d,bottom:u+h,left:c}}const Kqe={ignoreTransform:!1};function zx(t,e){e===void 0&&(e=Kqe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=Xs(t).getComputedStyle(t);u&&(n=Wqe(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 dq(t){return zx(t,{ignoreTransform:!0})}function Xqe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function Yqe(t,e){return e===void 0&&(e=Xs(t).getComputedStyle(t)),e.position==="fixed"}function Qqe(t,e){e===void 0&&(e=Xs(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 z2(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(sF(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!_v(i)||bre(i)||n.includes(i))return n;const s=Xs(t).getComputedStyle(i);return i!==t&&Qqe(i,s)&&n.push(i),Yqe(i,s)?n:r(i.parentNode)}return t?r(t):n}function Ere(t){const[e]=z2(t,1);return e??null}function zj(t){return!U2||!t?null:Ix(t)?t:aF(t)?sF(t)||t===Ux(t).scrollingElement?window:_v(t)?t:null:null}function Tre(t){return Ix(t)?t.scrollX:t.scrollLeft}function Are(t){return Ix(t)?t.scrollY:t.scrollTop}function lR(t){return{x:Tre(t),y:Are(t)}}var ya;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(ya||(ya={}));function Cre(t){return!U2||!t?!1:t===document.scrollingElement}function jre(t){const e={x:0,y:0},n=Cre(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 Zqe={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=Zqe);const{isTop:u,isBottom:d,isLeft:h,isRight:p}=jre(t),m={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?(m.y=ya.Backward,x.y=r*Math.abs((e.top+y.height-s)/y.height)):!d&&c>=e.bottom-y.height&&(m.y=ya.Forward,x.y=r*Math.abs((e.bottom-y.height-c)/y.height)),!p&&l>=e.right-y.width?(m.x=ya.Forward,x.x=r*Math.abs((e.right-y.width-l)/y.width)):!h&&o<=e.left+y.width&&(m.x=ya.Backward,x.x=r*Math.abs((e.left+y.width-o)/y.width)),{direction:m,speed:x}}function eWe(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 Pre(t){return t.reduce((e,n)=>Ig(e,lR(n)),Hl)}function tWe(t){return t.reduce((e,n)=>e+Tre(n),0)}function nWe(t){return t.reduce((e,n)=>e+Are(n),0)}function rWe(t,e){if(e===void 0&&(e=zx),!t)return;const{top:n,left:r,bottom:i,right:s}=e(t);Ere(t)&&(i<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const iWe=[["x",["left","right"],tWe],["y",["top","bottom"],nWe]];class cF{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=z2(n),i=Pre(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,o,l]of iWe)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 I0{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 aWe(t){const{EventTarget:e}=Xs(t);return t instanceof e?t:Ux(t)}function Bj(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 Yo;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(Yo||(Yo={}));function hq(t){t.preventDefault()}function sWe(t){t.stopPropagation()}var Qn;(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"})(Qn||(Qn={}));const Dre={start:[Qn.Space,Qn.Enter],cancel:[Qn.Esc],end:[Qn.Space,Qn.Enter,Qn.Tab]},oWe=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Qn.Right:return{...n,x:n.x+25};case Qn.Left:return{...n,x:n.x-25};case Qn.Down:return{...n,y:n.y+25};case Qn.Up:return{...n,y:n.y-25}}};class B2{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 I0(Ux(n)),this.windowListeners=new I0(Xs(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Yo.Resize,this.handleCancel),this.windowListeners.add(Yo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Yo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&rWe(r),n(Hl)}handleKeyDown(e){if(lF(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:s=Dre,coordinateGetter:o=oWe,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 h=o(e,{active:n,context:r.current,currentCoordinates:d});if(h){const p=Dy(h,d),m={x:0,y:0},{scrollableAncestors:x}=r.current;for(const y of x){const v=e.code,{isTop:b,isRight:S,isLeft:N,isBottom:T,maxScroll:k,minScroll:C}=jre(y),E=eWe(y),P={x:Math.min(v===Qn.Right?E.right-E.width/2:E.right,Math.max(v===Qn.Right?E.left:E.left+E.width/2,h.x)),y:Math.min(v===Qn.Down?E.bottom-E.height/2:E.bottom,Math.max(v===Qn.Down?E.top:E.top+E.height/2,h.y))},A=v===Qn.Right&&!S||v===Qn.Left&&!N,D=v===Qn.Down&&!T||v===Qn.Up&&!b;if(A&&P.x!==h.x){const I=y.scrollLeft+p.x,L=v===Qn.Right&&I<=k.x||v===Qn.Left&&I>=C.x;if(L&&!p.y){y.scrollTo({left:I,behavior:l});return}L?m.x=y.scrollLeft-I:m.x=v===Qn.Right?y.scrollLeft-k.x:y.scrollLeft-C.x,m.x&&y.scrollBy({left:-m.x,behavior:l});break}else if(D&&P.y!==h.y){const I=y.scrollTop+p.y,L=v===Qn.Down&&I<=k.y||v===Qn.Up&&I>=C.y;if(L&&!p.x){y.scrollTo({top:I,behavior:l});return}L?m.y=y.scrollTop-I:m.y=v===Qn.Down?y.scrollTop-k.y:y.scrollTop-C.y,m.y&&y.scrollBy({top:-m.y,behavior:l});break}}this.handleMove(e,Ig(Dy(h,this.referenceCoordinates),m))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}B2.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Dre,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 fq(t){return!!(t&&"distance"in t)}function mq(t){return!!(t&&"delay"in t)}class uF{constructor(e,n,r){var i;r===void 0&&(r=aWe(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=Ux(o),this.documentListeners=new I0(this.document),this.listeners=new I0(r),this.windowListeners=new I0(Xs(o)),this.initialCoordinates=(i=oR(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(Yo.Resize,this.handleCancel),this.windowListeners.add(Yo.DragStart,hq),this.windowListeners.add(Yo.VisibilityChange,this.handleCancel),this.windowListeners.add(Yo.ContextMenu,hq),this.documentListeners.add(Yo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(mq(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(fq(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(Yo.Click,sWe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Yo.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=oR(e))!=null?n:Hl,u=Dy(i,c);if(!r&&l){if(fq(l)){if(l.tolerance!=null&&Bj(u,l.tolerance))return this.handleCancel();if(Bj(u,l.distance))return this.handleStart()}if(mq(l)&&Bj(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===Qn.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const lWe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class H2 extends uF{constructor(e){const{event:n}=e,r=Ux(n.target);super(e,lWe,r)}}H2.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 cWe={move:{name:"mousemove"},end:{name:"mouseup"}};var cR;(function(t){t[t.RightClick=2]="RightClick"})(cR||(cR={}));class uWe extends uF{constructor(e){super(e,cWe,Ux(e.event.target))}}uWe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===cR.RightClick?!1:(r?.({event:n}),!0)}}];const Hj={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class dWe extends uF{constructor(e){super(e,Hj)}static setup(){return window.addEventListener(Hj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Hj.move.name,e)};function e(){}}}dWe.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 U0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(U0||(U0={}));var tM;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(tM||(tM={}));function hWe(t){let{acceleration:e,activator:n=U0.Pointer,canScroll:r,draggingRect:i,enabled:s,interval:o=5,order:l=tM.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:h,threshold:p}=t;const m=mWe({delta:h,disabled:!s}),[x,y]=kqe(),v=_.useRef({x:0,y:0}),b=_.useRef({x:0,y:0}),S=_.useMemo(()=>{switch(n){case U0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case U0.DraggableRect:return i}},[n,i,c]),N=_.useRef(null),T=_.useCallback(()=>{const C=N.current;if(!C)return;const E=v.current.x*b.current.x,P=v.current.y*b.current.y;C.scrollBy(E,P)},[]),k=_.useMemo(()=>l===tM.TreeOrder?[...u].reverse():u,[l,u]);_.useEffect(()=>{if(!s||!u.length||!S){y();return}for(const C of k){if(r?.(C)===!1)continue;const E=u.indexOf(C),P=d[E];if(!P)continue;const{direction:A,speed:D}=Jqe(C,P,S,e,p);for(const I of["x","y"])m[I][A[I]]||(D[I]=0,A[I]=0);if(D.x>0||D.y>0){y(),N.current=C,x(T,o),v.current=D,b.current=A;return}}v.current={x:0,y:0},b.current={x:0,y:0},y()},[e,T,r,y,s,o,JSON.stringify(S),JSON.stringify(m),x,u,k,d,JSON.stringify(p)])}const fWe={x:{[ya.Backward]:!1,[ya.Forward]:!1},y:{[ya.Backward]:!1,[ya.Forward]:!1}};function mWe(t){let{delta:e,disabled:n}=t;const r=sR(e);return Sv(i=>{if(n||!r||!i)return fWe;const s={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[ya.Backward]:i.x[ya.Backward]||s.x===-1,[ya.Forward]:i.x[ya.Forward]||s.x===1},y:{[ya.Backward]:i.y[ya.Backward]||s.y===-1,[ya.Forward]:i.y[ya.Forward]||s.y===1}}},[n,e,r])}function pWe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return Sv(i=>{var s;return e==null?null:(s=r??i)!=null?s:null},[r,e])}function gWe(t,e){return _.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 Ry;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Ry||(Ry={}));var uR;(function(t){t.Optimized="optimized"})(uR||(uR={}));const pq=new Map;function xWe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[s,o]=_.useState(null),{frequency:l,measure:c,strategy:u}=i,d=_.useRef(t),h=v(),p=Py(h),m=_.useCallback(function(b){b===void 0&&(b=[]),!p.current&&o(S=>S===null?b:S.concat(b.filter(N=>!S.includes(N))))},[p]),x=_.useRef(null),y=Sv(b=>{if(h&&!n)return pq;if(!b||b===pq||d.current!==t||s!=null){const S=new Map;for(let N of t){if(!N)continue;if(s&&s.length>0&&!s.includes(N.id)&&N.rect.current){S.set(N.id,N.rect.current);continue}const T=N.node.current,k=T?new cF(c(T),T):null;N.rect.current=k,k&&S.set(N.id,k)}return S}return b},[t,s,n,h,c]);return _.useEffect(()=>{d.current=t},[t]),_.useEffect(()=>{h||m()},[n,h]),_.useEffect(()=>{s&&s.length>0&&o(null)},[JSON.stringify(s)]),_.useEffect(()=>{h||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{m(),x.current=null},l))},[l,h,m,...r]),{droppableRects:y,measureDroppableContainers:m,measuringScheduled:s!=null};function v(){switch(u){case Ry.Always:return!1;case Ry.BeforeDragging:return n;default:return!n}}}function Rre(t,e){return Sv(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function bWe(t,e){return Rre(t,e)}function yWe(t){let{callback:e,disabled:n}=t;const r=oF(e),i=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:s}=window;return new s(r)},[r,n]);return _.useEffect(()=>()=>i?.disconnect(),[i]),i}function $2(t){let{callback:e,disabled:n}=t;const r=oF(e),i=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:s}=window;return new s(r)},[n]);return _.useEffect(()=>()=>i?.disconnect(),[i]),i}function vWe(t){return new cF(zx(t),t)}function gq(t,e,n){e===void 0&&(e=vWe);const[r,i]=_.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=yWe({callback(c){if(t)for(const u of c){const{type:d,target:h}=u;if(d==="childList"&&h instanceof HTMLElement&&h.contains(t)){s();break}}}}),l=$2({callback:s});return kc(()=>{s(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function wWe(t){const e=Rre(t);return kre(t,e)}const xq=[];function _We(t){const e=_.useRef(t),n=Sv(r=>t?r&&r!==xq&&t&&e.current&&t.parentNode===e.current.parentNode?r:z2(t):xq,[t]);return _.useEffect(()=>{e.current=t},[t]),n}function SWe(t){const[e,n]=_.useState(null),r=_.useRef(t),i=_.useCallback(s=>{const o=zj(s.target);o&&n(l=>l?(l.set(o,lR(o)),new Map(l)):null)},[]);return _.useEffect(()=>{const s=r.current;if(t!==s){o(s);const l=t.map(c=>{const u=zj(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,lR(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=zj(c);u?.removeEventListener("scroll",i)})}},[i,t]),_.useMemo(()=>t.length?e?Array.from(e.values()).reduce((s,o)=>Ig(s,o),Hl):Pre(t):Hl,[t,e])}function bq(t,e){e===void 0&&(e=[]);const n=_.useRef(null);return _.useEffect(()=>{n.current=null},e),_.useEffect(()=>{const r=t!==Hl;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?Dy(t,n.current):Hl}function NWe(t){_.useEffect(()=>{if(!U2)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 MWe(t,e){return _.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:s}=r;return n[i]=o=>{s(o,e)},n},{}),[t,e])}function Ore(t){return _.useMemo(()=>t?Xqe(t):null,[t])}const yq=[];function kWe(t,e){e===void 0&&(e=zx);const[n]=t,r=Ore(n?Xs(n):null),[i,s]=_.useState(yq);function o(){s(()=>t.length?t.map(c=>Cre(c)?r:new cF(e(c),c)):yq)}const l=$2({callback:o});return kc(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function EWe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return _v(e)?e:t}function TWe(t){let{measure:e}=t;const[n,r]=_.useState(null),i=_.useCallback(u=>{for(const{target:d}of u)if(_v(d)){r(h=>{const p=e(d);return h?{...h,width:p.width,height:p.height}:p});break}},[e]),s=$2({callback:i}),o=_.useCallback(u=>{const d=EWe(u);s?.disconnect(),d&&s?.observe(d),r(d?e(d):null)},[e,s]),[l,c]=ZN(o);return _.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const AWe=[{sensor:H2,options:{}},{sensor:B2,options:{}}],CWe={current:{}},z1={draggable:{measure:dq},droppable:{measure:dq,strategy:Ry.WhileDragging,frequency:uR.Optimized},dragOverlay:{measure:zx}};class z0 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 jWe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new z0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:JN},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:z1,measureDroppableContainers:JN,windowRect:null,measuringScheduled:!1},PWe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:JN,draggableNodes:new Map,over:null,measureDroppableContainers:JN},V2=_.createContext(PWe),Lre=_.createContext(jWe);function DWe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new z0}}}function RWe(t,e){switch(e.type){case Zi.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Zi.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 Zi.DragEnd:case Zi.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Zi.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new z0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case Zi.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 z0(t.droppable.containers);return o.set(n,{...s,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case Zi.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new z0(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function OWe(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=_.useContext(V2),s=sR(r),o=sR(n?.id);return _.useEffect(()=>{if(!e&&!r&&s&&o!=null){if(!lF(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 h=Aqe(d);if(h){h.focus();break}}})}},[r,e,i,o,s]),null}function LWe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,s)=>s({transform:i,...r}),n):n}function FWe(t){return _.useMemo(()=>({draggable:{...z1.draggable,...t?.draggable},droppable:{...z1.droppable,...t?.droppable},dragOverlay:{...z1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function IWe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const s=_.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;kc(()=>{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),h=kre(d,r);if(o||(h.x=0),l||(h.y=0),s.current=!0,Math.abs(h.x)>0||Math.abs(h.y)>0){const p=Ere(u);p&&p.scrollBy({top:h.y,left:h.x})}},[e,o,l,r,n])}const Fre=_.createContext({...Hl,scaleX:1,scaleY:1});var Wd;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Wd||(Wd={}));const Ire=_.memo(function(e){var n,r,i,s;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=AWe,collisionDetection:h=Hqe,measuring:p,modifiers:m,...x}=e;const y=_.useReducer(RWe,void 0,DWe),[v,b]=y,[S,N]=Oqe(),[T,k]=_.useState(Wd.Uninitialized),C=T===Wd.Initialized,{draggable:{active:E,nodes:P,translate:A},droppable:{containers:D}}=v,I=E!=null?P.get(E):null,L=_.useRef({initial:null,translated:null}),U=_.useMemo(()=>{var Xe;return E!=null?{id:E,data:(Xe=I?.data)!=null?Xe:CWe,rect:L}:null},[E,I]),j=_.useRef(null),[V,K]=_.useState(null),[z,X]=_.useState(null),Y=Py(x,Object.values(x)),te=Nv("DndDescribedBy",o),$=_.useMemo(()=>D.getEnabled(),[D]),W=FWe(p),{droppableRects:ne,measureDroppableContainers:re,measuringScheduled:ge}=xWe($,{dragging:C,dependencies:[A.x,A.y],config:W.droppable}),me=pWe(P,E),ue=_.useMemo(()=>z?oR(z):null,[z]),Te=Ee(),ie=bWe(me,W.draggable.measure);IWe({activeNode:E!=null?P.get(E):null,config:Te.layoutShiftCompensation,initialRect:ie,measure:W.draggable.measure});const Ce=gq(me,W.draggable.measure,ie),Fe=gq(me?me.parentElement:null),xe=_.useRef({activatorEvent:null,active:null,activeNode:me,collisionRect:null,collisions:null,droppableRects:ne,draggableNodes:P,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Ze=D.getNodeFor((n=xe.current.over)==null?void 0:n.id),G=TWe({measure:W.dragOverlay.measure}),Q=(r=G.nodeRef.current)!=null?r:me,de=C?(i=G.rect)!=null?i:Ce:null,q=!!(G.nodeRef.current&&G.rect),ee=wWe(q?null:Ce),B=Ore(Q?Xs(Q):null),he=_We(C?Ze??me:null),ke=kWe(he),pe=LWe(m,{transform:{x:A.x-ee.x,y:A.y-ee.y,scaleX:1,scaleY:1},activatorEvent:z,active:U,activeNodeRect:Ce,containerNodeRect:Fe,draggingNodeRect:de,over:xe.current.over,overlayNodeRect:G.rect,scrollableAncestors:he,scrollableAncestorRects:ke,windowRect:B}),H=ue?Ig(ue,A):null,O=SWe(he),J=bq(O),le=bq(O,[Ce]),Se=Ig(pe,J),we=de?Gqe(de,pe):null,ae=U&&we?h({active:U,collisionRect:we,droppableRects:ne,droppableContainers:$,pointerCoordinates:H}):null,Le=Nre(ae,"id"),[Be,Ve]=_.useState(null),He=q?pe:Ig(pe,le),be=$qe(He,(s=Be?.rect)!=null?s:null,Ce),Pe=_.useRef(null),Ie=_.useCallback((Xe,ze)=>{let{sensor:ce,options:$e}=ze;if(j.current==null)return;const ye=P.get(j.current);if(!ye)return;const Je=Xe.nativeEvent,at=new ce({active:j.current,activeNode:ye,event:Je,options:$e,context:xe,onAbort(Dt){if(!P.get(Dt))return;const{onDragAbort:cn}=Y.current,rr={id:Dt};cn?.(rr),S({type:"onDragAbort",event:rr})},onPending(Dt,yn,cn,rr){if(!P.get(Dt))return;const{onDragPending:Jn}=Y.current,xn={id:Dt,constraint:yn,initialCoordinates:cn,offset:rr};Jn?.(xn),S({type:"onDragPending",event:xn})},onStart(Dt){const yn=j.current;if(yn==null)return;const cn=P.get(yn);if(!cn)return;const{onDragStart:rr}=Y.current,Vn={activatorEvent:Je,active:{id:yn,data:cn.data,rect:L}};bu.unstable_batchedUpdates(()=>{rr?.(Vn),k(Wd.Initializing),b({type:Zi.DragStart,initialCoordinates:Dt,active:yn}),S({type:"onDragStart",event:Vn}),K(Pe.current),X(Je)})},onMove(Dt){b({type:Zi.DragMove,coordinates:Dt})},onEnd:jt(Zi.DragEnd),onCancel:jt(Zi.DragCancel)});Pe.current=at;function jt(Dt){return async function(){const{active:cn,collisions:rr,over:Vn,scrollAdjustedTranslate:Jn}=xe.current;let xn=null;if(cn&&Jn){const{cancelDrop:sr}=Y.current;xn={activatorEvent:Je,active:cn,collisions:rr,delta:Jn,over:Vn},Dt===Zi.DragEnd&&typeof sr=="function"&&await Promise.resolve(sr(xn))&&(Dt=Zi.DragCancel)}j.current=null,bu.unstable_batchedUpdates(()=>{b({type:Dt}),k(Wd.Uninitialized),Ve(null),K(null),X(null),Pe.current=null;const sr=Dt===Zi.DragEnd?"onDragEnd":"onDragCancel";if(xn){const Gn=Y.current[sr];Gn?.(xn),S({type:sr,event:xn})}})}}},[P]),_e=_.useCallback((Xe,ze)=>(ce,$e)=>{const ye=ce.nativeEvent,Je=P.get($e);if(j.current!==null||!Je||ye.dndKit||ye.defaultPrevented)return;const at={active:Je};Xe(ce,ze.options,at)===!0&&(ye.dndKit={capturedBy:ze.sensor},j.current=$e,Ie(ce,ze))},[P,Ie]),Ke=gWe(d,_e);NWe(d),kc(()=>{Ce&&T===Wd.Initializing&&k(Wd.Initialized)},[Ce,T]),_.useEffect(()=>{const{onDragMove:Xe}=Y.current,{active:ze,activatorEvent:ce,collisions:$e,over:ye}=xe.current;if(!ze||!ce)return;const Je={active:ze,activatorEvent:ce,collisions:$e,delta:{x:Se.x,y:Se.y},over:ye};bu.unstable_batchedUpdates(()=>{Xe?.(Je),S({type:"onDragMove",event:Je})})},[Se.x,Se.y]),_.useEffect(()=>{const{active:Xe,activatorEvent:ze,collisions:ce,droppableContainers:$e,scrollAdjustedTranslate:ye}=xe.current;if(!Xe||j.current==null||!ze||!ye)return;const{onDragOver:Je}=Y.current,at=$e.get(Le),jt=at&&at.rect.current?{id:at.id,rect:at.rect.current,data:at.data,disabled:at.disabled}:null,Dt={active:Xe,activatorEvent:ze,collisions:ce,delta:{x:ye.x,y:ye.y},over:jt};bu.unstable_batchedUpdates(()=>{Ve(jt),Je?.(Dt),S({type:"onDragOver",event:Dt})})},[Le]),kc(()=>{xe.current={activatorEvent:z,active:U,activeNode:me,collisionRect:we,collisions:ae,droppableRects:ne,draggableNodes:P,draggingNode:Q,draggingNodeRect:de,droppableContainers:D,over:Be,scrollableAncestors:he,scrollAdjustedTranslate:Se},L.current={initial:de,translated:we}},[U,me,ae,we,P,Q,de,ne,D,Be,he,Se]),hWe({...Te,delta:A,draggingRect:we,pointerCoordinates:H,scrollableAncestors:he,scrollableAncestorRects:ke});const Me=_.useMemo(()=>({active:U,activeNode:me,activeNodeRect:Ce,activatorEvent:z,collisions:ae,containerNodeRect:Fe,dragOverlay:G,draggableNodes:P,droppableContainers:D,droppableRects:ne,over:Be,measureDroppableContainers:re,scrollableAncestors:he,scrollableAncestorRects:ke,measuringConfiguration:W,measuringScheduled:ge,windowRect:B}),[U,me,Ce,z,ae,Fe,G,P,D,ne,Be,re,he,ke,W,ge,B]),it=_.useMemo(()=>({activatorEvent:z,activators:Ke,active:U,activeNodeRect:Ce,ariaDescribedById:{draggable:te},dispatch:b,draggableNodes:P,over:Be,measureDroppableContainers:re}),[z,Ke,U,Ce,b,te,P,Be,re]);return ei.createElement(vre.Provider,{value:N},ei.createElement(V2.Provider,{value:it},ei.createElement(Lre.Provider,{value:Me},ei.createElement(Fre.Provider,{value:be},u)),ei.createElement(OWe,{disabled:l?.restoreFocus===!1})),ei.createElement(Iqe,{...l,hiddenTextDescribedById:te}));function Ee(){const Xe=V?.autoScrollEnabled===!1,ze=typeof c=="object"?c.enabled===!1:c===!1,ce=C&&!Xe&&!ze;return typeof c=="object"?{...c,enabled:ce}:{enabled:ce}}}),UWe=_.createContext(null),vq="button",zWe="Draggable";function BWe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const s=Nv(zWe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:h,over:p}=_.useContext(V2),{role:m=vq,roleDescription:x="draggable",tabIndex:y=0}=i??{},v=c?.id===e,b=_.useContext(v?Fre:UWe),[S,N]=ZN(),[T,k]=ZN(),C=MWe(o,e),E=Py(n);kc(()=>(h.set(e,{id:e,key:s,node:S,activatorNode:T,data:E}),()=>{const A=h.get(e);A&&A.key===s&&h.delete(e)}),[h,e]);const P=_.useMemo(()=>({role:m,tabIndex:y,"aria-disabled":r,"aria-pressed":v&&m===vq?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,m,y,v,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:P,isDragging:v,listeners:r?void 0:C,node:S,over:p,setNodeRef:N,setActivatorNodeRef:k,transform:b}}function HWe(){return _.useContext(Lre)}const $We="Droppable",VWe={timeout:25};function GWe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const s=Nv($We),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=_.useContext(V2),d=_.useRef({disabled:n}),h=_.useRef(!1),p=_.useRef(null),m=_.useRef(null),{disabled:x,updateMeasurementsFor:y,timeout:v}={...VWe,...i},b=Py(y??r),S=_.useCallback(()=>{if(!h.current){h.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(b.current)?b.current:[b.current]),m.current=null},v)},[v]),N=$2({callback:S,disabled:x||!o}),T=_.useCallback((P,A)=>{N&&(A&&(N.unobserve(A),h.current=!1),P&&N.observe(P))},[N]),[k,C]=ZN(T),E=Py(e);return _.useEffect(()=>{!N||!k.current||(N.disconnect(),h.current=!1,N.observe(k.current))},[k,N]),_.useEffect(()=>(l({type:Zi.RegisterDroppable,element:{id:r,key:s,disabled:n,node:k,rect:p,data:E}}),()=>l({type:Zi.UnregisterDroppable,key:s,id:r})),[r]),_.useEffect(()=>{n!==d.current.disabled&&(l({type:Zi.SetDroppableDisabled,id:r,key:s,disabled:n}),d.current.disabled=n)},[r,s,n,l]),{active:o,rect:p,isOver:c?.id===r,node:k,over:c,setNodeRef:C}}function G2(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function qWe(t,e){return t.reduce((n,r,i)=>{const s=e.get(r);return s&&(n[i]=s),n},Array(t.length))}function d1(t){return t!==null&&t>=0}function WWe(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 KWe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const dF=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const s=G2(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}},h1={scaleX:1,scaleY:1},XWe=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,...h1}:null}const c=YWe(s,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...h1}:i<n&&i>=o?{x:0,y:l.height+c,...h1}:{x:0,y:0,...h1}};function YWe(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 Ure="Sortable",zre=ei.createContext({activeIndex:-1,containerId:Ure,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:dF,disabled:{draggable:!1,droppable:!1}});function Bre(t){let{children:e,id:n,items:r,strategy:i=dF,disabled:s=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=HWe(),h=Nv(Ure,n),p=l.rect!==null,m=_.useMemo(()=>r.map(C=>typeof C=="object"&&"id"in C?C.id:C),[r]),x=o!=null,y=o?m.indexOf(o.id):-1,v=u?m.indexOf(u.id):-1,b=_.useRef(m),S=!WWe(m,b.current),N=v!==-1&&y===-1||S,T=KWe(s);kc(()=>{S&&x&&d(m)},[S,m,x,d]),_.useEffect(()=>{b.current=m},[m]);const k=_.useMemo(()=>({activeIndex:y,containerId:h,disabled:T,disableTransforms:N,items:m,overIndex:v,useDragOverlay:p,sortedRects:qWe(m,c),strategy:i}),[y,h,T.draggable,T.droppable,N,m,v,c,p,i]);return ei.createElement(zre.Provider,{value:k},e)}const QWe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return G2(n,r,i).indexOf(e)},ZWe=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"},Hre="transform",eKe=gx.Transition.toString({property:Hre,duration:0,easing:"linear"}),tKe={roleDescription:"sortable"};function nKe(t){let{disabled:e,index:n,node:r,rect:i}=t;const[s,o]=_.useState(null),l=_.useRef(n);return kc(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=zx(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]),_.useEffect(()=>{s&&o(null)},[s]),s}function $re(t){let{animateLayoutChanges:e=ZWe,attributes:n,disabled:r,data:i,getNewIndex:s=QWe,id:o,strategy:l,resizeObserverConfig:c,transition:u=JWe}=t;const{items:d,containerId:h,activeIndex:p,disabled:m,disableTransforms:x,sortedRects:y,overIndex:v,useDragOverlay:b,strategy:S}=_.useContext(zre),N=rKe(r,m),T=d.indexOf(o),k=_.useMemo(()=>({sortable:{containerId:h,index:T,items:d},...i}),[h,i,T,d]),C=_.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:E,node:P,isOver:A,setNodeRef:D}=GWe({id:o,data:k,disabled:N.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:I,activatorEvent:L,activeNodeRect:U,attributes:j,setNodeRef:V,listeners:K,isDragging:z,over:X,setActivatorNodeRef:Y,transform:te}=BWe({id:o,data:k,attributes:{...tKe,...n},disabled:N.draggable}),$=Mqe(D,V),W=!!I,ne=W&&!x&&d1(p)&&d1(v),re=!b&&z,ge=re&&ne?te:null,ue=ne?ge??(l??S)({rects:y,activeNodeRect:U,activeIndex:p,overIndex:v,index:T}):null,Te=d1(p)&&d1(v)?s({id:o,items:d,activeIndex:p,overIndex:v}):T,ie=I?.id,Ce=_.useRef({activeId:ie,items:d,newIndex:Te,containerId:h}),Fe=d!==Ce.current.items,xe=e({active:I,containerId:h,isDragging:z,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}),Ze=nKe({disabled:!xe,index:T,node:P,rect:E});return _.useEffect(()=>{W&&Ce.current.newIndex!==Te&&(Ce.current.newIndex=Te),h!==Ce.current.containerId&&(Ce.current.containerId=h),d!==Ce.current.items&&(Ce.current.items=d)},[W,Te,h,d]),_.useEffect(()=>{if(ie===Ce.current.activeId)return;if(ie!=null&&Ce.current.activeId==null){Ce.current.activeId=ie;return}const Q=setTimeout(()=>{Ce.current.activeId=ie},50);return()=>clearTimeout(Q)},[ie]),{active:I,activeIndex:p,attributes:j,data:k,rect:E,index:T,newIndex:Te,items:d,isOver:A,isSorting:W,isDragging:z,listeners:K,node:P,overIndex:v,over:X,setNodeRef:$,setActivatorNodeRef:Y,setDroppableNodeRef:D,setDraggableNodeRef:V,transform:Ze??ue,transition:G()};function G(){if(Ze||Fe&&Ce.current.newIndex===T)return eKe;if(!(re&&!lF(L)||!u)&&(W||xe))return gx.Transition.toString({...u,property:Hre})}}function rKe(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 nM(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 iKe=[Qn.Down,Qn.Right,Qn.Up,Qn.Left],Vre=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:s,over:o,scrollableAncestors:l}}=e;if(iKe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];s.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const p=i.get(h.id);if(p)switch(t.code){case Qn.Down:r.top<p.top&&c.push(h);break;case Qn.Up:r.top>p.top&&c.push(h);break;case Qn.Left:r.left>p.left&&c.push(h);break;case Qn.Right:r.left<p.left&&c.push(h);break}});const u=zqe({collisionRect:r,droppableRects:i,droppableContainers:c});let d=Nre(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const h=s.get(n.id),p=s.get(d),m=p?i.get(p.id):null,x=p?.node.current;if(x&&m&&h&&p){const v=z2(x).some((C,E)=>l[E]!==C),b=Gre(h,p),S=aKe(h,p),N=v||!b?{x:0,y:0}:{x:S?r.width-m.width:0,y:S?r.height-m.height:0},T={x:m.left,y:m.top};return N.x&&N.y?T:Dy(T,N)}}}};function Gre(t,e){return!nM(t)||!nM(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function aKe(t,e){return!nM(t)||!nM(e)||!Gre(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function qre(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 sKe(t,e="system",n){if(!t)return n?.("queue.time.asap")??"ASAP";const r=zi(t);if(!r)return n?.("queue.time.asap")??"ASAP";const i=new Date,s=r.getTime()-i.getTime();return s<-6e4?n?.("queue.time.overdue")??"Overdue":s<0?n?.("queue.time.now")??"Now":s<6e4?n?.("queue.time.lessThanMinute")??"In less than a minute":s<36e5?n?.("queue.time.inMinutes",{count:Math.round(s/6e4)})??`In ${Math.round(s/6e4)} min`:s<864e5?n?.("queue.time.inHours",{count:Math.round(s/36e5)})??`In ${Math.round(s/36e5)} hours`:Vg(t,e)}function oKe({status:t,waitingReason:e,t:n}){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(tr,{className:"w-3.5 h-3.5"}),n("queue.status.waiting")]});const r={pending:{icon:tr,color:"text-status-warning bg-status-warning/10 border-status-warning/20",label:n("queue.status.pending")},printing:{icon:So,color:"text-blue-400 bg-blue-400/10 border-blue-400/20",label:n("queue.status.printing")},completed:{icon:Ar,color:"text-status-ok bg-status-ok/10 border-status-ok/20",label:n("queue.status.completed")},failed:{icon:Ji,color:"text-status-error bg-status-error/10 border-status-error/20",label:n("queue.status.failed")},skipped:{icon:RR,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:n("queue.status.skipped")},cancelled:{icon:Lt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:n("queue.status.cancelled")}},{icon:i,color:s,label:o}=r[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 ${s}`,children:[a.jsx(i,{className:"w-3.5 h-3.5"}),o]})}function lKe({selectedCount:t,printers:e,onSave:n,onClose:r,isSaving:i,t:s}){const[o,l]=_.useState("unchanged"),[c,u]=_.useState("unchanged"),[d,h]=_.useState("unchanged"),[p,m]=_.useState("unchanged"),[x,y]=_.useState("unchanged"),[v,b]=_.useState("unchanged"),[S,N]=_.useState("unchanged"),[T,k]=_.useState("unchanged"),[C,E]=_.useState("unchanged"),[P,A]=_.useState("unchanged"),D=()=>{const L={};o!=="unchanged"&&(L.printer_id=o),c!=="unchanged"&&(L.manual_start=c),d!=="unchanged"&&(L.auto_off_after=d),p!=="unchanged"&&(L.require_previous_success=p),x!=="unchanged"&&(L.bed_levelling=x),v!=="unchanged"&&(L.flow_cali=v),S!=="unchanged"&&(L.vibration_cali=S),T!=="unchanged"&&(L.layer_inspect=T),C!=="unchanged"&&(L.timelapse=C),P!=="unchanged"&&(L.use_ams=P),n(L)},I=o!=="unchanged"||c!=="unchanged"||d!=="unchanged"||p!=="unchanged"||x!=="unchanged"||v!=="unchanged"||S!=="unchanged"||T!=="unchanged"||C!=="unchanged"||P!=="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.jsx("h2",{className:"text-lg font-semibold text-white",children:s("queue.bulkEdit.title",{count:t})}),a.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Lt,{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:s("queue.bulkEdit.description")}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:s("queue.bulkEdit.printer")}),a.jsxs("select",{value:o===null?"null":o==="unchanged"?"unchanged":String(o),onChange:L=>{const U=L.target.value;l(U==="unchanged"?"unchanged":U==="null"?null:Number(U))},className:"w-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:s("queue.bulkEdit.noChange")}),a.jsx("option",{value:"null",children:s("queue.filter.unassigned")}),e.map(L=>a.jsx("option",{value:L.id,children:L.name},L.id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:s("queue.bulkEdit.queueOptions")}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(cu,{label:s("queue.bulkEdit.staged"),value:c,onChange:u,t:s}),a.jsx(cu,{label:s("queue.bulkEdit.autoPowerOff"),value:d,onChange:h,t:s}),a.jsx(cu,{label:s("queue.bulkEdit.requirePrevious"),value:p,onChange:m,t:s})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:s("queue.bulkEdit.printOptions")}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(cu,{label:s("queue.bulkEdit.bedLevelling"),value:x,onChange:y,t:s}),a.jsx(cu,{label:s("queue.bulkEdit.flowCalibration"),value:v,onChange:b,t:s}),a.jsx(cu,{label:s("queue.bulkEdit.vibrationCalibration"),value:S,onChange:N,t:s}),a.jsx(cu,{label:s("queue.bulkEdit.layerInspection"),value:T,onChange:k,t:s}),a.jsx(cu,{label:s("queue.bulkEdit.timelapse"),value:C,onChange:E,t:s}),a.jsx(cu,{label:s("queue.bulkEdit.useAms"),value:P,onChange:A,t:s})]})]})]}),a.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[a.jsx(Ae,{variant:"secondary",onClick:r,children:s("common.cancel")}),a.jsx(Ae,{onClick:D,disabled:!I||i,children:s(i?"common.saving":"queue.bulkEdit.applyChanges")})]})]})})}function cu({label:t,value:e,onChange:n,t:r}){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:r("common.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:r("common.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,hasPermission:h,canModify:p,t:m}){const x=h("queue:reorder"),{attributes:y,listeners:v,setNodeRef:b,transform:S,transition:N,isDragging:T}=$re({id:t.id,disabled:t.status!=="pending"||!x}),k={transform:gx.Transform.toString(S),transition:N},C=t.status==="printing",E=t.status==="pending",P=["completed","failed","skipped","cancelled"].includes(t.status);return a.jsx("div",{ref:b,style:k,className:`
  8274. group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
  8275. transition-all duration-200 hover:border-bambu-dark-tertiary/80
  8276. ${T?"opacity-50 scale-[1.02] shadow-xl z-50":""}
  8277. ${C?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
  8278. `,children:a.jsxs("div",{className:"flex items-center gap-4 p-4",children:[E&&d&&a.jsx("button",{onClick:A=>{A.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(Wi,{className:"w-4 h-4"})}),E?a.jsx("div",{...y,...v,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(Hg,{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?oe.getArchivePlateThumbnail(t.archive_id,t.plate_id):oe.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?a.jsx("img",{src:t.plate_id!=null?oe.getLibraryFilePlateThumbnail(t.library_file_id,t.plate_id):oe.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(xs,{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(Fs,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:m("queue.viewArchive"),children:a.jsx(Xr,{className:"w-3.5 h-3.5"})}):t.library_file_id?a.jsx(Fs,{to:`/library?highlight=${t.library_file_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:m("queue.viewInFileManager"),children:a.jsx(Xr,{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(Ur,{className:"w-3.5 h-3.5"}),t.target_model?`${m("queue.filter.any")} ${t.target_model}${t.target_location?` @ ${t.target_location}`:""}${t.required_filament_types?.length?` (${t.required_filament_types.join(", ")})`:""}`:t.printer_id===null?m("queue.filter.unassigned"):t.printer_name||`${m("common.printer")} #${t.printer_id}`]}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(yu,{className:"w-3.5 h-3.5"}),qre(t.print_time_seconds)]}),t.created_by_username&&a.jsxs("span",{className:"flex items-center gap-1.5",title:m("queue.addedBy",{name:t.created_by_username}),children:[a.jsx(om,{className:"w-3.5 h-3.5"}),t.created_by_username]}),E&&!t.manual_start&&a.jsxs("span",{className:"flex items-center gap-1.5",children:[a.jsx(tr,{className:"w-3.5 h-3.5"}),sKe(t.scheduled_time,c,m)]})]}),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(EW,{className:"w-3 h-3"}),m("queue.badges.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:m("queue.badges.requiresPrevious")}),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(qu,{className:"w-3 h-3"}),m("queue.badges.autoPowerOff")]})]}),C&&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:m("queue.printingInProgress")})]}),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(Vi,{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(Vi,{className:"w-3 h-3"}),t.error_message]})]}),a.jsx(oKe,{status:t.status,waitingReason:t.waiting_reason,t:m}),a.jsxs("div",{className:"flex items-center gap-1",children:[C&&a.jsx(Ae,{variant:"ghost",size:"sm",onClick:s,disabled:!h("printers:control"),title:h("printers:control")?m("queue.actions.stopPrint"):m("queue.permissions.noStopPrint"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:a.jsx(lue,{className:"w-4 h-4"})}),E&&a.jsxs(a.Fragment,{children:[t.manual_start&&a.jsx(Ae,{variant:"ghost",size:"sm",onClick:l,disabled:!h("printers:control"),title:h("printers:control")?m("queue.actions.startPrint"):m("queue.permissions.noStartPrint"),className:"text-bambu-green hover:text-bambu-green-light hover:bg-bambu-green/10",children:a.jsx(So,{className:"w-4 h-4"})}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:n,disabled:!p("queue","update",t.created_by_id),title:p("queue","update",t.created_by_id)?m("common.edit"):m("queue.permissions.noEdit"),children:a.jsx(ea,{className:"w-4 h-4"})}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:r,disabled:!p("queue","delete",t.created_by_id),title:p("queue","delete",t.created_by_id)?m("common.cancel"):m("queue.permissions.noCancel"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:a.jsx(Lt,{className:"w-4 h-4"})})]}),P&&a.jsxs(a.Fragment,{children:[a.jsx(Ae,{variant:"ghost",size:"sm",onClick:o,disabled:!h("queue:create"),title:h("queue:create")?m("queue.actions.requeue"):m("queue.permissions.noRequeue"),className:"text-bambu-green hover:text-bambu-green/80 hover:bg-bambu-green/10",children:a.jsx(Dr,{className:"w-4 h-4"})}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:i,disabled:!p("queue","delete",t.created_by_id),title:p("queue","delete",t.created_by_id)?m("common.remove"):m("queue.permissions.noRemove"),children:a.jsx(an,{className:"w-4 h-4"})})]})]})]})})}function cKe(){const{t}=On(),e=sn(),{showToast:n}=Hn(),{hasPermission:r,hasAnyPermission:i,canModify:s}=Ci(),[o,l]=_.useState(null),[c,u]=_.useState(""),[d,h]=_.useState(""),[p,m]=_.useState(!1),[x,y]=_.useState(null),[v,b]=_.useState(null),[S,N]=_.useState(null),[T,k]=_.useState([]),[C,E]=_.useState(!1),[P,A]=_.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[D,I]=_.useState(()=>{const B=localStorage.getItem("queue.historySortAsc");return B!==null?B==="true":!1}),[L,U]=_.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[j,V]=_.useState(()=>{const B=localStorage.getItem("queue.pendingSortAsc");return B!==null?B==="true":!0});_.useEffect(()=>{localStorage.setItem("queue.historySortBy",P)},[P]),_.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(D))},[D]),_.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",L)},[L]),_.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(j))},[j]);const K=wre(eM(H2,{activationConstraint:{distance:8}}),eM(B2,{coordinateGetter:Vre})),{data:z}=ct({queryKey:["settings"],queryFn:oe.getSettings}),X=z?.time_format||"system",{data:Y,isLoading:te}=ct({queryKey:["queue",o,c],queryFn:()=>oe.getQueue(o||void 0,c||void 0),refetchInterval:5e3}),{data:$}=ct({queryKey:["printers"],queryFn:()=>oe.getPrinters()}),W=gt({mutationFn:B=>oe.cancelQueueItem(B),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.cancelled"))},onError:()=>n(t("queue.toast.cancelFailed"),"error")}),ne=gt({mutationFn:B=>oe.removeFromQueue(B),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.removed"))},onError:()=>n(t("queue.toast.removeFailed"),"error")}),re=gt({mutationFn:B=>oe.stopQueueItem(B),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.stopped"))},onError:()=>n(t("queue.toast.stopFailed"),"error")}),ge=gt({mutationFn:B=>oe.startQueueItem(B),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.released"))},onError:()=>n(t("queue.toast.startFailed"),"error")}),me=gt({mutationFn:B=>oe.reorderQueue(B),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]})},onError:()=>n(t("queue.toast.reorderFailed"),"error")}),ue=gt({mutationFn:async()=>{const B=Y?.filter(he=>["completed","failed","skipped","cancelled"].includes(he.status))||[];for(const he of B)await oe.removeFromQueue(he.id);return B.length},onSuccess:B=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.historyCleared",{count:B}))},onError:()=>n(t("queue.toast.clearHistoryFailed"),"error")}),Te=gt({mutationFn:B=>oe.bulkUpdateQueue(B),onSuccess:B=>{e.invalidateQueries({queryKey:["queue"]}),k([]),E(!1),n(B.message)},onError:()=>n(t("queue.toast.updateFailed"),"error")}),ie=gt({mutationFn:async B=>{for(const he of B)await oe.cancelQueueItem(he);return B.length},onSuccess:B=>{e.invalidateQueries({queryKey:["queue"]}),k([]),n(t("queue.toast.bulkCancelled",{count:B}))},onError:()=>n(t("queue.toast.bulkCancelFailed"),"error")}),Ce=B=>{k(he=>he.includes(B)?he.filter(ke=>ke!==B):[...he,B])},Fe=_.useMemo(()=>{const B=new Set;return $?.forEach(he=>{he.location&&B.add(he.location)}),Y?.forEach(he=>{he.target_location&&B.add(he.target_location)}),Array.from(B).sort()},[$,Y]),xe=_.useCallback(B=>d?B.target_location?B.target_location===d:B.printer_id?$?.find(ke=>ke.id===B.printer_id)?.location===d:!1:!0,[d,$]),Ze=_.useMemo(()=>{let B=Y?.filter(ke=>ke.status==="pending")||[];d&&(B=B.filter(xe));const he=ke=>{if(!ke.scheduled_time)return 0;const pe=new Date(ke.scheduled_time).getTime(),H=Date.now()+4320*60*60*1e3;return pe>H?0:pe};return[...B].sort((ke,pe)=>{let H;if(L==="name"){const O=ke.archive_name||ke.library_file_name||"",J=pe.archive_name||pe.library_file_name||"";H=O.localeCompare(J)}else L==="printer"?H=(ke.printer_name||"").localeCompare(pe.printer_name||""):L==="time"?H=he(ke)-he(pe):H=ke.position-pe.position;return j?H:-H})},[Y,L,j,xe,d]),G=()=>{const B=Ze.map(he=>he.id);T.length===B.length?k([]):k(B)},Q=_.useMemo(()=>{let B=Y?.filter(he=>he.status==="printing")||[];return d&&(B=B.filter(xe)),B},[Y,d,xe]),de=_.useMemo(()=>{let B=Y?.filter(he=>["completed","failed","skipped","cancelled"].includes(he.status))||[];return d&&(B=B.filter(xe)),[...B].sort((he,ke)=>{let pe;if(P==="name"){const H=he.archive_name||he.library_file_name||"",O=ke.archive_name||ke.library_file_name||"";pe=H.localeCompare(O)}else P==="printer"?pe=(he.printer_name||"").localeCompare(ke.printer_name||""):pe=new Date(ke.completed_at||ke.created_at).getTime()-new Date(he.completed_at||he.created_at).getTime();return D?-pe:pe})},[Y,P,D,xe,d]),q=_.useMemo(()=>Ze.reduce((B,he)=>B+(he.print_time_seconds||0),0),[Ze]),ee=B=>{const{active:he,over:ke}=B;if(!ke||he.id===ke.id)return;const pe=Ze.findIndex(O=>O.id===he.id),H=Ze.findIndex(O=>O.id===ke.id);if(pe!==-1&&H!==-1){const J=G2(Ze,pe,H).map((le,Se)=>({id:le.id,position:Se+1}));me.mutate(J)}};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(TW,{className:"w-7 h-7 text-bambu-green"}),t("queue.title")]}),a.jsx("p",{className:"text-bambu-gray mt-1",children:t("queue.subtitle")})]})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[a.jsx(St,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:a.jsx(Nt,{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(So,{className:"w-5 h-5 text-blue-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:Q.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.printing")})]})]})})}),a.jsx(St,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:a.jsx(Nt,{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(tr,{className:"w-5 h-5 text-yellow-400"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:Ze.length}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.queued")})]})]})})}),a.jsx(St,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:a.jsx(Nt,{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(yu,{className:"w-5 h-5 text-bambu-green"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-2xl font-bold text-white",children:qre(q)}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.totalTime")})]})]})})}),a.jsx(St,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:a.jsx(Nt,{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(Ar,{className:"w-5 h-5 text-gray-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:t("queue.summary.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:o===-1?"unassigned":o||"",onChange:B=>{const he=B.target.value;l(he==="unassigned"?-1:he===""?null:Number(he))},children:[a.jsx("option",{value:"",children:t("queue.filter.allPrinters")}),a.jsx("option",{value:"unassigned",children:t("queue.filter.unassigned")}),$?.map(B=>a.jsx("option",{value:B.id,children:B.name},B.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:c,onChange:B=>u(B.target.value),children:[a.jsx("option",{value:"",children:t("queue.filter.allStatus")}),a.jsx("option",{value:"pending",children:t("queue.status.pending")}),a.jsx("option",{value:"printing",children:t("queue.status.printing")}),a.jsx("option",{value:"completed",children:t("queue.status.completed")}),a.jsx("option",{value:"failed",children:t("queue.status.failed")}),a.jsx("option",{value:"skipped",children:t("queue.status.skipped")}),a.jsx("option",{value:"cancelled",children:t("queue.status.cancelled")})]}),Fe.length>0&&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:d,onChange:B=>h(B.target.value),children:[a.jsx("option",{value:"",children:t("queue.filter.allLocations")}),Fe.map(B=>a.jsx("option",{value:B,children:B},B))]}),a.jsx("div",{className:"flex-1"}),de.length>0&&a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:()=>m(!0),disabled:!r("queue:delete_all"),title:r("queue:delete_all")?void 0:t("queue.permissions.noClearHistory"),children:[a.jsx(an,{className:"w-4 h-4"}),t("queue.clearHistory")]})]}),te?a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):Y?.length===0?a.jsxs(St,{className:"p-12 text-center border-dashed",children:[a.jsx(ti,{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:t("queue.empty.title")}),a.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:t("queue.empty.description")})]}):a.jsxs("div",{className:"space-y-8",children:[Q.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"}),t("queue.sections.currentlyPrinting")]}),a.jsx("div",{className:"space-y-3",children:Q.map(B=>a.jsx($j,{item:B,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>N({type:"stop",item:B}),onRequeue:()=>{},onStart:()=>{},timeFormat:X,hasPermission:r,canModify:s,t},B.id))})]}),Ze.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(tr,{className:"w-5 h-5 text-yellow-400"}),t("queue.sections.queued"),a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:Ze.length}),")"]}),a.jsx("span",{className:"text-xs text-bambu-gray ml-2",title:t("queue.reorderHint"),children:t("queue.dragToReorder")})]}),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:L,onChange:B=>U(B.target.value),children:[a.jsx("option",{value:"position",children:t("queue.sort.byPosition")}),a.jsx("option",{value:"name",children:t("queue.sort.byName")}),a.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")}),a.jsx("option",{value:"time",children:t("queue.sort.bySchedule")})]}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>V(!j),title:t(j?"common.ascending":"common.descending"),className:"px-2",children:j?a.jsx(zg,{className:"w-4 h-4"}):a.jsx(q0,{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(Ae,{variant:"ghost",size:"sm",onClick:G,className:"flex items-center gap-2",children:[T.length===Ze.length&&Ze.length>0?a.jsx(Gs,{className:"w-4 h-4 text-bambu-green"}):a.jsx(cl,{className:"w-4 h-4"}),T.length===Ze.length&&Ze.length>0?t("queue.bulkEdit.deselectAll"):t("queue.bulkEdit.selectAll")]}),T.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-bambu-gray",children:t("queue.bulkEdit.selected",{count:T.length})}),a.jsx("div",{className:"h-4 w-px bg-bambu-dark-tertiary"}),a.jsxs(Ae,{variant:"ghost",size:"sm",onClick:()=>E(!0),className:"flex items-center gap-2 text-bambu-green hover:text-bambu-green-light",disabled:!i("queue:update_own","queue:update_all"),title:i("queue:update_own","queue:update_all")?void 0:t("queue.permissions.noEditItems"),children:[a.jsx(ea,{className:"w-4 h-4"}),t("queue.bulkEdit.editSelected")]}),a.jsxs(Ae,{variant:"ghost",size:"sm",onClick:()=>ie.mutate(T),className:"flex items-center gap-2 text-red-400 hover:text-red-300",disabled:ie.isPending||!i("queue:delete_own","queue:delete_all"),title:i("queue:delete_own","queue:delete_all")?void 0:t("queue.permissions.noCancelItems"),children:[a.jsx(Lt,{className:"w-4 h-4"}),t("queue.bulkEdit.cancelSelected")]})]})]}),a.jsx(Ire,{sensors:K,collisionDetection:Mre,onDragEnd:ee,children:a.jsx(Bre,{items:Ze.map(B=>B.id),strategy:XWe,children:a.jsx("div",{className:"space-y-3",children:Ze.map((B,he)=>a.jsx($j,{item:B,position:he+1,onEdit:()=>y(B),onCancel:()=>N({type:"cancel",item:B}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>ge.mutate(B.id),timeFormat:X,isSelected:T.includes(B.id),onToggleSelect:()=>Ce(B.id),hasPermission:r,canModify:s,t},B.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(Ar,{className:"w-5 h-5 text-bambu-gray"}),t("queue.sections.history"),a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:de.length}),")"]})]}),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:P,onChange:B=>A(B.target.value),children:[a.jsx("option",{value:"date",children:t("queue.sort.byDate")}),a.jsx("option",{value:"name",children:t("queue.sort.byName")}),a.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")})]}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>I(!D),title:t(D?"queue.sort.ascendingOldest":"queue.sort.descendingNewest"),className:"px-2",children:D?a.jsx(zg,{className:"w-4 h-4"}):a.jsx(q0,{className:"w-4 h-4"})})]})]}),a.jsx("div",{className:"space-y-3",children:de.slice(0,20).map((B,he)=>a.jsx($j,{item:B,position:he+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>N({type:"remove",item:B}),onStop:()=>{},onRequeue:()=>b(B),onStart:()=>{},timeFormat:X,hasPermission:r,canModify:s,t},B.id))})]})]}),x&&a.jsx(Dh,{mode:"edit-queue-item",archiveId:x.archive_id??void 0,libraryFileId:x.library_file_id??void 0,archiveName:x.archive_name||x.library_file_name||`File #${x.archive_id||x.library_file_id}`,queueItem:x,onClose:()=>y(null)}),v&&a.jsx(Dh,{mode:"add-to-queue",archiveId:v.archive_id??void 0,libraryFileId:v.library_file_id??void 0,archiveName:v.archive_name||v.library_file_name||`File #${v.archive_id||v.library_file_id}`,onClose:()=>b(null)}),S&&a.jsx(Zn,{title:S.type==="cancel"?t("queue.confirm.cancelTitle"):S.type==="stop"?t("queue.confirm.stopTitle"):t("queue.confirm.removeTitle"),message:S.type==="cancel"?t("queue.confirm.cancelMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisPrint")}):S.type==="stop"?t("queue.confirm.stopMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisPrint")}):t("queue.confirm.removeMessage",{name:S.item.archive_name||S.item.library_file_name||t("queue.confirm.thisItem")}),confirmText:S.type==="cancel"?t("queue.confirm.cancelButton"):S.type==="stop"?t("queue.confirm.stopButton"):t("common.remove"),variant:"danger",onConfirm:()=>{S.type==="cancel"?W.mutate(S.item.id):S.type==="stop"?re.mutate(S.item.id):ne.mutate(S.item.id),N(null)},onCancel:()=>N(null)}),p&&a.jsx(Zn,{title:t("queue.confirm.clearHistoryTitle"),message:t("queue.confirm.clearHistoryMessage",{count:de.length}),confirmText:t("queue.clearHistory"),variant:"danger",onConfirm:()=>{ue.mutate(),m(!1)},onCancel:()=>m(!1)}),C&&a.jsx(lKe,{selectedCount:T.length,printers:$?.map(B=>({id:B.id,name:B.name}))||[],onSave:B=>{Object.keys(B).length>0&&Te.mutate({item_ids:T,...B})},onClose:()=>E(!1),isSaving:Te.isPending,t})]})}function uKe({printDates:t,months:e=3}){const n=_.useRef(null),[r,i]=_.useState(0);_.useEffect(()=>{const S=n.current;if(!S)return;const N=new ResizeObserver(T=>{const k=T[0]?.contentRect.width||0;i(k)});return N.observe(S),()=>N.disconnect()},[]);const{weeks:s,monthLabels:o,printCounts:l}=_.useMemo(()=>{const S={};t.forEach(I=>{const L=I.split("T")[0];S[L]=(S[L]||0)+1});const N=new Date,T=new Date(N);T.setMonth(T.getMonth()-e),T.setDate(T.getDate()-T.getDay());const k=[],C=[];let E=[],P=-1;const A=new Date(T);let D=0;for(;A<=N;)A.getDay()===0&&E.length>0&&(k.push(E),E=[],D++),A.getMonth()!==P&&(C.push({month:A.toLocaleDateString("en-US",{month:"short"}),weekIndex:D}),P=A.getMonth()),E.push(new Date(A)),A.setDate(A.getDate()+1);return E.length>0&&k.push(E),{weeks:k,monthLabels:C,printCounts:S}},[t,e]),c=Math.max(1,...Object.values(l)),u=S=>{if(S===0)return"bg-bambu-dark";const N=S/c;return N<=.25?"bg-bambu-green/30":N<=.5?"bg-bambu-green/50":N<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],h=s.length,p=32,m=2,x=r-p-16,y=h>0?Math.floor((x-(h-1)*m)/h):12,v=Math.max(8,Math.min(20,y)),b=v<=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:p+4},children:o.map(({month:S,weekIndex:N},T)=>a.jsx("div",{className:"text-bambu-gray",style:{fontSize:b,marginLeft:T===0?0:`${(N-(o[T-1]?.weekIndex||0))*(v+m)-24}px`},children:S},T))}),a.jsxs("div",{className:"flex",style:{gap:m},children:[a.jsx("div",{className:"flex flex-col",style:{gap:m,marginRight:4,width:p},children:d.map((S,N)=>a.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:p,height:v,fontSize:b,visibility:N%2===1?"visible":"hidden"},children:S},S))}),s.map((S,N)=>a.jsx("div",{className:"flex flex-col",style:{gap:m},children:[0,1,2,3,4,5,6].map(T=>{const k=S.find(A=>A.getDay()===T);if(!k)return a.jsx("div",{style:{width:v,height:v}},T);const C=k.toISOString().split("T")[0],E=l[C]||0,P=C===new Date().toISOString().split("T")[0];return a.jsx("div",{className:`rounded-sm ${u(E)} ${P?"ring-1 ring-white":""}`,style:{width:v,height:v},title:`${k.toLocaleDateString()}: ${E} print${E!==1?"s":""}`},T)})},N))]}),a.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:b},children:[a.jsx("span",{children:"Less"}),a.jsxs("div",{className:"flex",style:{gap:m},children:[a.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:v,height:v}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:v,height:v}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:v,height:v}}),a.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:v,height:v}}),a.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:v,height:v}})]}),a.jsx("span",{children:"More"})]})]})})}const f1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function dKe(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 hKe({archives:t,currency:e="$"}){const[n,r]=_.useState("30d"),i=_.useMemo(()=>{const m=dKe(n);return t.filter(x=>(zi(x.completed_at||x.created_at)||new Date(0))>=m)},[t,n]),s=_.useMemo(()=>{const m=new Map;return i.forEach(x=>{const y=zi(x.completed_at||x.created_at)||new Date,v=`${y.getFullYear()}-${String(y.getMonth()+1).padStart(2,"0")}-${String(y.getDate()).padStart(2,"0")}`,b=m.get(v)||{date:v,filament:0,cost:0,prints:0},S=x.quantity||1;b.filament+=(x.filament_used_grams||0)*S,b.cost+=x.cost||0,b.prints+=S,m.set(v,b)}),Array.from(m.values()).sort((x,y)=>x.date.localeCompare(y.date)).map(x=>({...x,dateLabel:new Date(x.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}))},[i]),o=_.useMemo(()=>{if(n==="7d"||n==="30d")return s;const m=new Map;return i.forEach(x=>{const y=zi(x.completed_at||x.created_at)||new Date,v=new Date(y);v.setDate(y.getDate()-y.getDay());const b=`${v.getFullYear()}-${String(v.getMonth()+1).padStart(2,"0")}-${String(v.getDate()).padStart(2,"0")}`,S=m.get(b)||{week:b,filament:0,cost:0,prints:0},N=x.quantity||1;S.filament+=(x.filament_used_grams||0)*N,S.cost+=x.cost||0,S.prints+=N,m.set(b,S)}),Array.from(m.values()).sort((x,y)=>x.week.localeCompare(y.week)).map(x=>({date:x.week,dateLabel:`Week of ${new Date(x.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...x}))},[i,s,n]),l=_.useMemo(()=>{const m=new Map;return i.forEach(x=>{const y=x.filament_type||"Unknown",v=x.quantity||1,b=y.split(", ");b.forEach(S=>{const N=(x.filament_used_grams||0)*v/b.length;m.set(S,(m.get(S)||0)+N)})}),Array.from(m.entries()).map(([x,y])=>({name:x,value:Math.round(y)})).sort((x,y)=>y.value-x.value)},[i]),c=_.useMemo(()=>{const m=new Date,x=[];for(let y=5;y>=0;y--){const v=new Date(m.getFullYear(),m.getMonth()-y,1),b=new Date(m.getFullYear(),m.getMonth()-y+1,0),S=v.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),N=t.filter(T=>{const k=zi(T.completed_at||T.created_at)||new Date(0);return k>=v&&k<=b});x.push({month:S,filament:Math.round(N.reduce((T,k)=>T+(k.filament_used_grams||0),0)),cost:N.reduce((T,k)=>T+(k.cost||0),0),prints:N.reduce((T,k)=>T+(k.quantity||1),0)})}return x},[t]),u=n==="7d"||n==="30d"?s:o,d=i.reduce((m,x)=>m+(x.filament_used_grams||0),0),h=i.reduce((m,x)=>m+(x.cost||0),0),p=i.reduce((m,x)=>m+(x.quantity||1),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,h.toFixed(2)]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[p," 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:[p>0?(d/p).toFixed(0):0,"g"]}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,p>0?(h/p).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(j1,{width:"100%",height:250,children:a.jsxs(YBe,{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(nN,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(iN,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),a.jsx(aN,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),a.jsx(D1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:m=>[`${Number(m??0).toFixed(0)}g`,"Filament"]}),a.jsx(uee,{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(j1,{width:160,height:160,children:a.jsxs(KBe,{children:[a.jsx(RJ,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((m,x)=>a.jsx(pv,{fill:f1[x%f1.length]},`cell-${x}`))}),a.jsx(D1,{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,x)=>{const y=l.reduce((b,S)=>b+S.value,0),v=y>0?(m.value/y*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[x%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:[v,"%"]})]},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(j1,{width:"100%",height:200,children:a.jsxs(LBe,{data:c,children:[a.jsx(nN,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),a.jsx(iN,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),a.jsx(aN,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),a.jsx(D1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:(m,x)=>[x==="filament"?`${m??0}g`:x==="cost"?`${e}${Number(m??0).toFixed(2)}`:m??0,x==="filament"?"Filament":x==="cost"?"Cost":"Prints"]}),a.jsx(zO,{}),a.jsx(zJ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function fKe({id:t,title:e,component:n,isHidden:r,size:i,onToggleVisibility:s,onToggleSize:o}){const{attributes:l,listeners:c,setNodeRef:u,transform:d,transition:h,isDragging:p}=$re({id:t}),m={transform:gx.Transform.toString(d),transition:h,opacity:p?.5:1};return r?null:a.jsxs("div",{ref:u,style:{...m,gridColumn:`span ${i}`},className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden ${p?"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(Hg,{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(CW,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):a.jsx(AW,{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(uM,{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 mKe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:s}){const o=()=>{const T={};return t.forEach(k=>{T[k.id]=k.defaultSize||4}),T},[l,c]=_.useState(()=>{const T=localStorage.getItem(e);if(T)try{const k=JSON.parse(T);return k.sizes||(k.sizes=o()),k}catch{}return{order:t.map(k=>k.id),hidden:t.filter(k=>k.defaultVisible===!1).map(k=>k.id),sizes:o()}}),[u,d]=_.useState(!1);_.useEffect(()=>{const T=()=>d(k=>!k);return window.addEventListener("toggle-hidden-panel",T),()=>window.removeEventListener("toggle-hidden-panel",T)},[]),_.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),_.useEffect(()=>{const k=t.map(C=>C.id).filter(C=>!l.order.includes(C));k.length>0&&c(C=>({...C,order:[...C.order,...k]}))},[t,l.order]);const h=wre(eM(H2,{activationConstraint:{distance:8}}),eM(B2,{coordinateGetter:Vre})),p=T=>{const{active:k,over:C}=T;C&&k.id!==C.id&&c(E=>{const P=E.order.indexOf(k.id),A=E.order.indexOf(C.id);return{...E,order:G2(E.order,P,A)}})},m=T=>{c(k=>({...k,hidden:k.hidden.includes(T)?k.hidden.filter(C=>C!==T):[...k.hidden,T]}))},x=T=>{c(k=>{const C=k.sizes[T]||4,E=C===1?2:C===2?4:1;return{...k,sizes:{...k.sizes,[T]:E}}})},y=()=>{const T={order:t.map(k=>k.id),hidden:t.filter(k=>k.defaultVisible===!1).map(k=>k.id),sizes:o()};c(T),i?.()},v=l.order.map(T=>t.find(k=>k.id===T)).filter(Boolean),b=v.filter(T=>!l.hidden.includes(T.id)),S=v.filter(T=>l.hidden.includes(T.id)),N=s?.({hiddenCount:S.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:y});return a.jsxs("div",{className:"space-y-4",children:[N,!r&&!s&&a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:y,children:[a.jsx(Lh,{className:"w-4 h-4"}),"Reset Layout"]}),S.length>0&&a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[a.jsx(xc,{className:"w-4 h-4"}),S.length," Hidden"]})]}),u&&S.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:S.map(T=>a.jsxs("button",{onClick:()=>m(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(xc,{className:"w-3 h-3"}),T.title]},T.id))})]}),a.jsx(Ire,{sensors:h,collisionDetection:Mre,onDragEnd:p,children:a.jsx(Bre,{items:b.map(T=>T.id),strategy:dF,children:a.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:b.map(T=>a.jsx(fKe,{id:T.id,title:T.title,component:T.component,isHidden:l.hidden.includes(T.id),size:l.sizes[T.id]||2,onToggleVisibility:()=>m(T.id),onToggleSize:()=>x(T.id)},T.id))})})}),b.length===0&&a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx("p",{children:"All widgets are hidden."}),a.jsx(Ae,{className:"mt-4",onClick:y,children:"Reset Layout"})]})]})}function pKe({stats:t,currency:e,t:n}){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(bc,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.totalPrints")}),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(tr,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.printTime")}),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(bc,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentUsed")}),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(fP,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentCost")}),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(_h,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyUsed")}),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(fP,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyCost")}),a.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function gKe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0,s=n===1?112:n===2?128:144,o=s/2-8,l=o*2*Math.PI;return a.jsxs("div",{className:"flex items-center gap-6",children:[a.jsxs("div",{className:"relative flex-shrink-0",style:{width:s,height:s},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:s/2,cy:s/2,r:o,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:s/2,cy:s/2,r:o,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i/100*l} ${l}`})]}),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:[i,"%"]})})]}),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(Ar,{className:"w-4 h-4 text-status-ok flex-shrink-0"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.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(Ji,{className:"w-4 h-4 text-status-error flex-shrink-0"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.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:r("stats.printsByPrinter")}),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(([c,u])=>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(c)||`${r("common.printer")} ${c}`}),a.jsx("span",{className:"text-white font-medium",children:u})]},c))})]})]})]})}function xKe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.average_time_accuracy;if(i==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:r("stats.noTimeAccuracyData")})});const o=(Math.min(150,Math.max(50,i))-50)/100*100,c=(y=>y>=95&&y<=105?"#00ae42":y>105?"#3b82f6":"#f97316")(i),u=i-100,d=n===1?112:n===2?128:144,h=d/2-8,p=h*2*Math.PI,m=n===1?3:n===2?6:999,x=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:d,height:d},children:[a.jsxs("svg",{className:"w-full h-full -rotate-90",children:[a.jsx("circle",{cx:d/2,cy:d/2,r:h,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),a.jsx("circle",{cx:d/2,cy:d/2,r:h,fill:"none",stroke:c,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${o/100*p} ${p}`})]}),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:[i.toFixed(0),"%"]}),a.jsxs("span",{className:`text-xs ${u>=0?"text-blue-400":"text-orange-400"}`,children:[u>=0?"+":"",u.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(LW,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{children:r("stats.perfectEstimate")})]}),x.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:x.map(([y,v])=>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(y)||`${r("common.printer")} ${y}`}),a.jsxs("span",{className:`font-medium ${v>=95&&v<=105?"text-status-ok":v>105?"text-blue-400":"text-status-warning"}`,children:[v.toFixed(0),"%"]})]},y))})]})]})}function bKe({stats:t,size:e=1,t:n}){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:n("stats.noFilamentData")});const r=Object.entries(t.prints_by_filament_type).sort(([,l],[,c])=>c-l),i=e===1?5:e===2?8:999,s=r.slice(0,i),o=r.length>i;return e===4&&s.length>4?a.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:s.map(([l,c])=>{const u=Math.round(c/(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:l}),a.jsx("span",{className:"text-bambu-gray",children:c})]}),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:`${u}%`}})})]},l)})}):a.jsxs("div",{className:"space-y-3",children:[s.map(([l,c])=>{const u=Math.round(c/(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:l}),a.jsxs("span",{className:"text-bambu-gray",children:[c," ",n("common.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:`${u}%`}})})]},l)}),o&&a.jsx("p",{className:"text-xs text-bambu-gray text-center pt-1",children:n("common.more",{count:r.length-i})})]})}function yKe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return a.jsx(uKe,{printDates:t,months:n})}function vKe({stats:t,printerMap:e,t:n}){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:n("stats.noPrinterData")}):a.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([r,i])=>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(Ur,{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(r)||`${n("common.printer")} ${r}`}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[i," ",n("common.prints")]})]})]},r))})}function wKe({archives:t,currency:e,t:n}){return!t||t.length===0?a.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrintData")}):a.jsx(hKe,{archives:t,currency:e})}function _Ke({size:t=1,t:e}){const{data:n,isLoading:r}=ct({queryKey:["failureAnalysis"],queryFn:()=>oe.getFailureAnalysis({days:30})});if(r)return a.jsx("div",{className:"flex justify-center py-4",children:a.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!n||n.total_prints===0)return a.jsx("p",{className:"text-bambu-gray text-center py-4",children:e("stats.noPrintDataLast30Days")});const i=t===1?5:t===2?8:999,s=Object.entries(n.failures_by_reason).sort(([,c],[,u])=>u-c),o=s.slice(0,i),l=s.length>i;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(Sn,{className:`w-5 h-5 ${n.failure_rate>20?"text-status-error":n.failure_rate>10?"text-status-warning":"text-status-ok"}`}),a.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[n.failure_rate.toFixed(1),"%"]})]})}),a.jsx("div",{className:"text-sm text-bambu-gray mt-1",children:e("stats.failedPrintsCount",{failed:n.failed_prints,total:n.total_prints})}),n.trend&&n.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(IW,{className:`w-4 h-4 ${n.trend[n.trend.length-1].failure_rate<n.trend[n.trend.length-2].failure_rate?"text-status-ok":"text-status-error"}`}),a.jsx("span",{className:"text-bambu-gray",children:e("stats.lastWeekRate",{rate:n.trend[n.trend.length-1].failure_rate.toFixed(1)})})]})})]}),o.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?e("stats.failureReasons"):e("stats.topFailureReasons")}),a.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:o.map(([c,u])=>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:c||e("common.unknown")}),a.jsx("span",{className:"text-bambu-gray ml-2",children:u})]},c))}),l&&a.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:e("common.more",{count:s.length-i})})]})]})}function SKe(){const{t}=On(),{showToast:e}=Hn(),{hasPermission:n}=Ci(),[r,i]=_.useState(!1),[s,o]=_.useState(!1),[l,c]=_.useState(0),[u,d]=_.useState(0),[h,p]=_.useState(!1);_.useEffect(()=>{const A=()=>{try{const I=localStorage.getItem("bambusy-dashboard-layout");if(I){const L=JSON.parse(I);d(L.hidden?.length||0)}}catch{d(0)}};A(),window.addEventListener("storage",A);const D=setInterval(A,500);return()=>{window.removeEventListener("storage",A),clearInterval(D)}},[l]);const{data:m,isLoading:x,refetch:y}=ct({queryKey:["archiveStats"],queryFn:oe.getArchiveStats}),{data:v}=ct({queryKey:["printers"],queryFn:oe.getPrinters}),{data:b}=ct({queryKey:["archives"],queryFn:()=>oe.getArchives(void 0,void 0,1e3,0)}),{data:S}=ct({queryKey:["settings"],queryFn:oe.getSettings}),N=async A=>{o(!1),i(!0);try{const{blob:D,filename:I}=await oe.exportStats({format:A,days:90}),L=URL.createObjectURL(D),U=document.createElement("a");U.href=L,U.download=I,U.click(),URL.revokeObjectURL(L),e(t("stats.exportDownloaded"))}catch{e(t("stats.exportFailed"),"error")}finally{i(!1)}},T=async()=>{p(!0);try{const A=await oe.recalculateCosts();await y(),e(t("stats.recalculatedCosts",{count:A.updated}))}catch{e(t("stats.recalculateFailed"),"error")}finally{p(!1)}},k=S?.currency||"$",C=new Map(v?.map(A=>[String(A.id),A.name])||[]),E=b?.map(A=>A.created_at)||[];if(x)return a.jsx("div",{className:"p-4 md:p-8",children:a.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("stats.loadingStats")})});const P=[{id:"quick-stats",title:t("stats.quickStats"),component:a.jsx(pKe,{stats:m,currency:k,t}),defaultSize:2},{id:"success-rate",title:t("stats.successRate"),component:A=>a.jsx(gKe,{stats:m,printerMap:C,size:A,t}),defaultSize:1},{id:"time-accuracy",title:t("stats.timeAccuracy"),component:A=>a.jsx(xKe,{stats:m,printerMap:C,size:A,t}),defaultSize:1},{id:"filament-types",title:t("stats.filamentTypes"),component:A=>a.jsx(bKe,{stats:m,size:A,t}),defaultSize:1},{id:"failure-analysis",title:t("stats.failureAnalysis"),component:A=>a.jsx(_Ke,{size:A,t}),defaultSize:1},{id:"print-activity",title:t("stats.printActivity"),component:A=>a.jsx(yKe,{printDates:E,size:A}),defaultSize:2},{id:"prints-by-printer",title:t("stats.printsByPrinter"),component:a.jsx(vKe,{stats:m,printerMap:C,t}),defaultSize:2},{id:"filament-trends",title:t("stats.filamentTrends"),component:a.jsx(wKe,{archives:b||[],currency:k,t}),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:t("stats.title")}),a.jsx("p",{className:"text-bambu-gray",children:t("stats.subtitle")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[u>0&&a.jsxs(Ae,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[a.jsx(xc,{className:"w-4 h-4"}),t("stats.hiddenCount",{count:u})]}),a.jsxs(Ae,{variant:"secondary",onClick:()=>{localStorage.removeItem("bambusy-dashboard-layout"),c(A=>A+1),e(t("stats.layoutReset"))},disabled:!n("settings:update"),title:n("settings:update")?void 0:t("stats.noPermissionResetLayout"),children:[a.jsx(Lh,{className:"w-4 h-4"}),t("stats.resetLayout")]}),a.jsxs(Ae,{variant:"secondary",onClick:T,disabled:h||!n("archives:update_all"),title:n("archives:update_all")?t("stats.recalculateCostsHint"):t("stats.noPermissionRecalculate"),children:[h?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(Bce,{className:"w-4 h-4"}),t("stats.recalculateCosts")]}),a.jsxs("div",{className:"relative",children:[a.jsxs(Ae,{variant:"secondary",onClick:()=>o(!s),disabled:r,children:[r?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(K1,{className:"w-4 h-4"}),t("stats.exportStats")]}),s&&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:()=>N("csv"),children:[a.jsx(fs,{className:"w-4 h-4"}),t("stats.exportAsCsv")]}),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:()=>N("xlsx"),children:[a.jsx(K1,{className:"w-4 h-4"}),t("stats.exportAsExcel")]})]})]})]})]}),a.jsx(mKe,{widgets:P,storageKey:"bambusy-dashboard-layout",hideControls:!0},l)]})}function NKe({plug:t,onEdit:e}){const n=sn(),{showToast:r}=Hn(),[i,s]=_.useState(!1),[o,l]=_.useState(!1),[c,u]=_.useState(!1),[d,h]=_.useState(!1),{data:p,isLoading:m}=ct({queryKey:["smart-plug-status",t.id],queryFn:()=>oe.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=ct({queryKey:["printers"],queryFn:oe.getPrinters}),y=x?.find(A=>A.id===t.printer_id),v=gt({mutationFn:A=>oe.controlSmartPlug(t.id,A),onMutate:async A=>{await n.cancelQueries({queryKey:["smart-plug-status",t.id]});const D=n.getQueryData(["smart-plug-status",t.id]),I=A==="on"?"ON":A==="off"||p?.state==="ON"?"OFF":"ON";return n.setQueryData(["smart-plug-status",t.id],L=>({...L,state:I})),{previousStatus:D}},onError:(A,D,I)=>{I?.previousStatus&&n.setQueryData(["smart-plug-status",t.id],I.previousStatus),r(`Failed to turn ${D} "${t.name}"`,"error")},onSettled:()=>{setTimeout(()=>{n.invalidateQueries({queryKey:["smart-plug-status",t.id]}),n.invalidateQueries({queryKey:["smart-plugs"]})},1e3)}}),b=gt({mutationFn:A=>oe.updateSmartPlug(t.id,A),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&(n.invalidateQueries({queryKey:["smartPlugByPrinter",t.printer_id]}),n.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]}))}}),S=gt({mutationFn:()=>oe.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]})}}),N=p?.state==="ON",T=t.plug_type==="mqtt"&&p?.energy?.power!==null&&p?.energy?.power!==void 0,k=(p?.reachable??!1)||T,C=v.isPending,P=(()=>{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(St,{className:"relative",children:a.jsxs(Nt,{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"?k?"bg-teal-500/20":"bg-red-500/20":k?N?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="mqtt"?a.jsx(PR,{className:`w-5 h-5 ${k?"text-teal-400":"text-red-400"}`}):t.plug_type==="homeassistant"?a.jsx(Iy,{className:`w-5 h-5 ${k?N?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):a.jsx(al,{className:`w-5 h-5 ${k?N?"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:[m?a.jsx(pt,{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"}),k&&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:k?N?"text-status-ok":"text-bambu-gray":"text-status-error",children:k?p?.state||"?":"Offline"})]}):k?a.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[a.jsx(Mg,{className:"w-4 h-4 text-status-ok"}),a.jsx("span",{className:N?"text-status-ok":"text-bambu-gray",children:p?.state||"Unknown"})]}):a.jsxs("div",{className:"flex items-center gap-1 text-sm text-status-error",children:[a.jsx(lm,{className:"w-4 h-4"}),a.jsx("span",{children:"Offline"})]}),P&&a.jsxs("a",{href:P,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(Xr,{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(xc,{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(Sg,{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(ti,{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(Ae,{size:"sm",variant:N?"primary":"secondary",disabled:!k||C,onClick:()=>l(!0),className:"flex-1",children:[C?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(qu,{className:"w-4 h-4"}),"On"]}),a.jsxs(Ae,{size:"sm",variant:N?"secondary":"primary",disabled:!k||C,onClick:()=>u(!0),className:"flex-1",children:[C?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(xM,{className:"w-4 h-4"}),"Off"]})]}),t.plug_type==="mqtt"&&p?.energy&&a.jsxs("div",{className:"flex gap-2 mb-3 px-3 py-2 bg-bambu-dark rounded-lg",children:[p.energy.power!==null&&p.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(p.energy.power),"W"]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Power"})]}),p.energy.today!==null&&p.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:p.energy.today.toFixed(2)}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"kWh Today"})]})]}),a.jsxs("button",{onClick:()=>h(!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(vh,{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(pM,{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=>b.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=>b.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=>b.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=>b.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:()=>b.mutate({off_delay_mode:"time"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="time"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[a.jsx(tr,{className:"w-4 h-4"}),"Time"]}),a.jsxs("button",{onClick:()=>b.mutate({off_delay_mode:"temperature"}),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg text-sm transition-colors ${t.off_delay_mode==="temperature"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:[a.jsx(yM,{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=>b.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=>b.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(Ae,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(mg,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Ae,{size:"sm",variant:"secondary",onClick:()=>s(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(an,{className:"w-4 h-4"})})]})]})]})}),i&&a.jsx(Zn,{title:"Delete Smart Plug",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{S.mutate(),s(!1)},onCancel:()=>s(!1)}),o&&a.jsx(Zn,{title:"Turn On Smart Plug",message:`Are you sure you want to turn on "${t.name}"?`,confirmText:"Turn On",variant:"default",onConfirm:()=>{v.mutate("on"),l(!1)},onCancel:()=>l(!1)}),c&&a.jsx(Zn,{title:"Turn Off Smart Plug",message:`Are you sure you want to turn off "${t.name}"? This will cut power to the connected device.`,confirmText:"Turn Off",variant:"danger",onConfirm:()=>{v.mutate("off"),u(!1)},onCancel:()=>u(!1)})]})}function MKe({plug:t,onClose:e}){const n=sn(),r=!!t,[i,s]=_.useState(t?.plug_type||"tasmota"),[o,l]=_.useState(t?.name||""),[c,u]=_.useState(t?.ip_address||""),[d,h]=_.useState(t?.username||""),[p,m]=_.useState(t?.password||""),[x,y]=_.useState(t?.ha_entity_id||""),[v,b]=_.useState(t?.mqtt_power_topic||t?.mqtt_topic||""),[S,N]=_.useState(t?.mqtt_power_path||""),[T,k]=_.useState((t?.mqtt_power_multiplier??t?.mqtt_multiplier??1).toString()),[C,E]=_.useState(t?.mqtt_energy_topic||""),[P,A]=_.useState(t?.mqtt_energy_path||""),[D,I]=_.useState((t?.mqtt_energy_multiplier??1).toString()),[L,U]=_.useState(t?.mqtt_state_topic||""),[j,V]=_.useState(t?.mqtt_state_path||""),[K,z]=_.useState(t?.mqtt_state_on_value||""),[X,Y]=_.useState(t?.ha_power_entity||""),[te,$]=_.useState(t?.ha_energy_today_entity||""),[W,ne]=_.useState(t?.ha_energy_total_entity||""),[re,ge]=_.useState(""),[me,ue]=_.useState(""),[Te,ie]=_.useState(!1),Ce=_.useRef(null),[Fe,xe]=_.useState(""),[Ze,G]=_.useState(!1),Q=_.useRef(null),[de,q]=_.useState(""),[ee,B]=_.useState(!1),he=_.useRef(null),[ke,pe]=_.useState(""),[H,O]=_.useState(!1),J=_.useRef(null),[le,Se]=_.useState(t?.printer_id||null),[we,ae]=_.useState(null),[Le,Be]=_.useState(null),[Ve,He]=_.useState(t?.power_alert_enabled||!1),[be,Pe]=_.useState(t?.power_alert_high?.toString()||""),[Ie,_e]=_.useState(t?.power_alert_low?.toString()||""),[Ke,Me]=_.useState(t?.schedule_enabled||!1),[it,Ee]=_.useState(t?.schedule_on_time||""),[Xe,ze]=_.useState(t?.schedule_off_time||""),[ce,$e]=_.useState(t?.show_in_switchbar||!1),[ye,Je]=_.useState(t?.show_on_printer_card??!0),[at,jt]=_.useState(!1),[Dt,yn]=_.useState({scanned:0,total:0}),[cn,rr]=_.useState([]),Vn=_.useRef(null),{data:Jn}=ct({queryKey:["printers"],queryFn:oe.getPrinters}),{data:xn}=ct({queryKey:["smart-plugs"],queryFn:oe.getSmartPlugs}),{data:sr}=ct({queryKey:["settings"],queryFn:oe.getSettings}),Gn=!!(sr?.ha_enabled&&sr?.ha_url&&sr?.ha_token);_.useEffect(()=>{const Ne=setTimeout(()=>{ue(re)},300);return()=>clearTimeout(Ne)},[re]),_.useEffect(()=>{const Ne=Oe=>{Ce.current&&!Ce.current.contains(Oe.target)&&ie(!1),Q.current&&!Q.current.contains(Oe.target)&&G(!1),he.current&&!he.current.contains(Oe.target)&&B(!1),J.current&&!J.current.contains(Oe.target)&&O(!1)};return document.addEventListener("mousedown",Ne),()=>document.removeEventListener("mousedown",Ne)},[]);const{data:Xn,isLoading:Nn,error:hi}=ct({queryKey:["ha-entities",me],queryFn:()=>oe.getHAEntities(me||void 0),enabled:i==="homeassistant"&&Gn,retry:!1,staleTime:0}),{data:ai}=ct({queryKey:["ha-sensor-entities"],queryFn:oe.getHASensorEntities,enabled:i==="homeassistant"&&Gn,retry:!1,staleTime:0});_.useEffect(()=>{const Ne=Oe=>{Oe.key==="Escape"&&e()};return window.addEventListener("keydown",Ne),()=>{window.removeEventListener("keydown",Ne),Vn.current&&clearInterval(Vn.current)}},[e]);const je=async()=>{jt(!0),rr([]),yn({scanned:0,total:0}),Be(null);try{await oe.startTasmotaScan();const Ne=async()=>{try{const Oe=await oe.getTasmotaScanStatus();yn({scanned:Oe.scanned,total:Oe.total});const nt=await oe.getDiscoveredTasmotaDevices();rr(nt),Oe.running||(jt(!1),Vn.current&&(clearInterval(Vn.current),Vn.current=null))}catch(Oe){console.error("Polling error:",Oe)}};await Ne(),Vn.current=setInterval(Ne,500)}catch(Ne){jt(!1);const Oe=Ne instanceof Error?Ne.message:typeof Ne=="string"?Ne:JSON.stringify(Ne);Be(Oe||"Failed to start scan")}},tt=async()=>{try{await oe.stopTasmotaScan()}catch{}jt(!1),Vn.current&&(clearInterval(Vn.current),Vn.current=null)},dt=Ne=>{u(Ne.ip_address),l(Ne.name),ae(null)},ht=gt({mutationFn:()=>oe.testSmartPlugConnection(c,d||null,p||null),onSuccess:Ne=>{ae(Ne),Be(null),!o&&Ne.device_name&&l(Ne.device_name)},onError:Ne=>{ae(null),Be(Ne.message)}}),ut=gt({mutationFn:Ne=>oe.createSmartPlug(Ne),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),n.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:Ne=>{Be(Ne.message)}}),Et=gt({mutationFn:Ne=>oe.updateSmartPlug(t.id,Ne),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),n.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:Ne=>{Be(Ne.message)}}),fe=Jn?.filter(Ne=>i==="tasmota"?!xn?.some(nt=>nt.printer_id===Ne.id&&nt.id!==t?.id&&nt.plug_type==="tasmota"):!0),Re=Ne=>{if(Ne.preventDefault(),Be(null),!o.trim()){Be("Name is required");return}if(i==="tasmota"&&!c.trim()){Be("IP address is required for Tasmota plugs");return}if(i==="homeassistant"&&!x){Be("Entity is required for Home Assistant plugs");return}if(i==="mqtt"){const nt=v.trim(),Ye=C.trim(),Tt=L.trim();if(!nt&&!Ye&&!Tt){Be("At least one MQTT topic must be configured for power, energy, or state monitoring");return}}const Oe={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"&&X||null,ha_energy_today_entity:i==="homeassistant"&&te||null,ha_energy_total_entity:i==="homeassistant"&&W||null,mqtt_power_topic:i==="mqtt"&&v.trim()||null,mqtt_power_path:i==="mqtt"&&S.trim()||null,mqtt_power_multiplier:i==="mqtt"&&parseFloat(T)||1,mqtt_energy_topic:i==="mqtt"&&C.trim()||null,mqtt_energy_path:i==="mqtt"&&P.trim()||null,mqtt_energy_multiplier:i==="mqtt"&&parseFloat(D)||1,mqtt_state_topic:i==="mqtt"&&L.trim()||null,mqtt_state_path:i==="mqtt"&&j.trim()||null,mqtt_state_on_value:i==="mqtt"&&K.trim()||null,username:i==="tasmota"&&d.trim()||null,password:i==="tasmota"&&p.trim()||null,printer_id:le,power_alert_enabled:Ve,power_alert_high:be?parseFloat(be):null,power_alert_low:Ie?parseFloat(Ie):null,schedule_enabled:Ke,schedule_on_time:it||null,schedule_off_time:Xe||null,show_in_switchbar:ce,show_on_printer_card:ye};r?Et.mutate(Oe):ut.mutate(Oe)},Ge=ut.isPending||Et.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:Ne=>Ne.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(Lt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:Re,className:"p-6 space-y-4 overflow-y-auto",children:[Le&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:Le}),!r&&a.jsxs("div",{className:"flex gap-2 mb-2",children:[a.jsxs("button",{type:"button",onClick:()=>{s("tasmota"),ae(null),Be(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(al,{className:"w-4 h-4"}),"Tasmota"]}),a.jsxs("button",{type:"button",onClick:()=>{s("homeassistant"),ae(null),Be(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(Iy,{className:"w-4 h-4"}),"HA"]}),a.jsxs("button",{type:"button",onClick:()=>{s("mqtt"),ae(null),Be(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(PR,{className:"w-4 h-4"}),"MQTT"]})]}),!r&&i==="tasmota"&&a.jsxs("div",{className:"space-y-3",children:[at?a.jsxs(Ae,{type:"button",variant:"secondary",onClick:tt,className:"w-full",children:[a.jsx(Lt,{className:"w-4 h-4"}),"Stop Scanning"]}):a.jsxs(Ae,{type:"button",variant:"primary",onClick:je,className:"w-full",children:[a.jsx(wa,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),at&&Dt.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:[Dt.scanned," / ",Dt.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:`${Dt.scanned/Dt.total*100}%`}})})]}),cn.length>0&&a.jsxs("div",{className:"space-y-2",children:[a.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",cn.length," device(s) - click to select:"]}),a.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:cn.map(Ne=>a.jsxs("button",{type:"button",onClick:()=>dt(Ne),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(al,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-white",children:Ne.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:Ne.ip_address})]})]}),Ne.state&&a.jsxs("span",{className:`flex items-center gap-1 text-xs ${Ne.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[a.jsx(qu,{className:"w-3 h-3"}),Ne.state]})]},Ne.ip_address))})]}),!at&&cn.length===0&&Dt.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:[!Gn&&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..."})})]})]}),Gn&&a.jsxs(a.Fragment,{children:[Nn&&a.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[a.jsx(pt,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),hi&&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: ",hi.message]}),(()=>{const Ne=xn?.filter(Ye=>Ye.ha_entity_id&&Ye.id!==t?.id).map(Ye=>Ye.ha_entity_id)||[],Oe=(Xn||[]).filter(Ye=>!Ne.includes(Ye.entity_id)),nt=Xn?.find(Ye=>Ye.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(wa,{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:Te?re:nt?`${nt.friendly_name} (${nt.entity_id})`:"",onChange:Ye=>{ge(Ye.target.value),Te||ie(!0)},onFocus:()=>{ie(!0),ge("")},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&&!Te&&a.jsx("button",{type:"button",onClick:()=>{y(""),ge("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Lt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),Nn&&a.jsx(pt,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),Te&&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:[Nn&&a.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[a.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Loading..."]}),!Nn&&Oe.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"}),!Nn&&Oe.map(Ye=>a.jsxs("button",{type:"button",onClick:()=>{y(Ye.entity_id),ie(!1),ge(""),o||l(Ye.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${Ye.entity_id===x?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:Ye.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[a.jsx("span",{children:Ye.entity_id}),a.jsx("span",{className:Ye.state==="on"?"text-bambu-green":"",children:Ye.state})]})]},Ye.entity_id))]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:me?`Searching all entities (${Oe.length} found)`:`Showing switch, light, input_boolean (${Oe.length} available)`})]})})(),x&&ai&&ai.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 Ne=ai.filter(Ye=>Ye.unit_of_measurement==="W"||Ye.unit_of_measurement==="kW"||Ye.unit_of_measurement==="mW"),Oe=Fe?Ne.filter(Ye=>Ye.entity_id.toLowerCase().includes(Fe.toLowerCase())||Ye.friendly_name.toLowerCase().includes(Fe.toLowerCase())):Ne,nt=ai.find(Ye=>Ye.entity_id===X);return a.jsxs("div",{ref:Q,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(wa,{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:Ze?Fe:nt?`${nt.friendly_name} (${nt.state} ${nt.unit_of_measurement})`:"",onChange:Ye=>{xe(Ye.target.value),Ze||G(!0)},onFocus:()=>{G(!0),xe("")},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"}),X&&!Ze&&a.jsx("button",{type:"button",onClick:()=>{Y(""),xe("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Lt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),Ze&&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:()=>{Y(""),G(!1),xe("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Oe.map(Ye=>a.jsxs("button",{type:"button",onClick:()=>{Y(Ye.entity_id),G(!1),xe("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Ye.entity_id===X?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:Ye.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[Ye.entity_id," • ",Ye.state," ",Ye.unit_of_measurement]})]},Ye.entity_id)),Oe.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const Ne=ai.filter(Ye=>Ye.unit_of_measurement==="kWh"||Ye.unit_of_measurement==="Wh"||Ye.unit_of_measurement==="MWh"),Oe=de?Ne.filter(Ye=>Ye.entity_id.toLowerCase().includes(de.toLowerCase())||Ye.friendly_name.toLowerCase().includes(de.toLowerCase())):Ne,nt=ai.find(Ye=>Ye.entity_id===te);return a.jsxs("div",{ref:he,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(wa,{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:ee?de:nt?`${nt.friendly_name} (${nt.state} ${nt.unit_of_measurement})`:"",onChange:Ye=>{q(Ye.target.value),ee||B(!0)},onFocus:()=>{B(!0),q("")},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"}),te&&!ee&&a.jsx("button",{type:"button",onClick:()=>{$(""),q("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Lt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),ee&&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:()=>{$(""),B(!1),q("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Oe.map(Ye=>a.jsxs("button",{type:"button",onClick:()=>{$(Ye.entity_id),B(!1),q("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Ye.entity_id===te?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:Ye.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[Ye.entity_id," • ",Ye.state," ",Ye.unit_of_measurement]})]},Ye.entity_id)),Oe.length===0&&a.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const Ne=ai.filter(Ye=>Ye.unit_of_measurement==="kWh"||Ye.unit_of_measurement==="Wh"||Ye.unit_of_measurement==="MWh"),Oe=ke?Ne.filter(Ye=>Ye.entity_id.toLowerCase().includes(ke.toLowerCase())||Ye.friendly_name.toLowerCase().includes(ke.toLowerCase())):Ne,nt=ai.find(Ye=>Ye.entity_id===W);return a.jsxs("div",{ref:J,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(wa,{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:H?ke:nt?`${nt.friendly_name} (${nt.state} ${nt.unit_of_measurement})`:"",onChange:Ye=>{pe(Ye.target.value),H||O(!0)},onFocus:()=>{O(!0),pe("")},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&&!H&&a.jsx("button",{type:"button",onClick:()=>{ne(""),pe("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Lt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),H&&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:()=>{ne(""),O(!1),pe("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Oe.map(Ye=>a.jsxs("button",{type:"button",onClick:()=>{ne(Ye.entity_id),O(!1),pe("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Ye.entity_id===W?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[a.jsx("div",{className:"font-medium",children:Ye.friendly_name}),a.jsxs("div",{className:"text-xs text-bambu-gray",children:[Ye.entity_id," • ",Ye.state," ",Ye.unit_of_measurement]})]},Ye.entity_id)),Oe.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:[!sr?.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)."]}),sr?.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:v,onChange:Ne=>b(Ne.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:S,onChange:Ne=>N(Ne.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:Ne=>k(Ne.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:C,onChange:Ne=>E(Ne.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:P,onChange:Ne=>A(Ne.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:D,onChange:Ne=>I(Ne.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:L,onChange:Ne=>U(Ne.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:Ne=>V(Ne.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:K,onChange:Ne=>z(Ne.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:Ne=>{u(Ne.target.value),ae(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(Ae,{type:"button",variant:"secondary",onClick:()=>ht.mutate(),disabled:!c.trim()||ht.isPending,children:[ht.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(Mg,{className:"w-4 h-4"}),"Test"]})]})]}),i==="tasmota"&&we&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${we.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:we.success?a.jsxs(a.Fragment,{children:[a.jsx(Ar,{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:[we.device_name&&`Device: ${we.device_name} - `,"State: ",we.state]})]})]}):a.jsxs(a.Fragment,{children:[a.jsx(lm,{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:Ne=>l(Ne.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:Ne=>h(Ne.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:p,onChange:Ne=>m(Ne.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:le??"",onChange:Ne=>Se(Ne.target.value?Number(Ne.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)"}),fe?.map(Ne=>a.jsx("option",{value:Ne.id,children:Ne.name},Ne.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(Sg,{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:Ve,onChange:Ne=>He(Ne.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"})]})]}),Ve&&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:be,onChange:Ne=>Pe(Ne.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:Ie,onChange:Ne=>_e(Ne.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(tr,{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:Ke,onChange:Ne=>Me(Ne.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"})]})]}),Ke&&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:it,onChange:Ne=>Ee(Ne.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:Xe,onChange:Ne=>ze(Ne.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(pM,{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:ce,onChange:Ne=>$e(Ne.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"})]})]})}),i==="homeassistant"&&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(xc,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("div",{children:[a.jsx("span",{className:"text-white font-medium",children:"Show on Printer Card"}),a.jsx("p",{className:"text-xs text-bambu-gray",children:"Display button on printer card"})]})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:ye,onChange:Ne=>Je(Ne.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(Ae,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Ae,{type:"submit",disabled:Ge,className:"flex-1",children:[Ge?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(ms,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Fn({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 kKe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function EKe({provider:t,onEdit:e}){const n=sn(),[r,i]=_.useState(!1),[s,o]=_.useState(!1),[l,c]=_.useState(null),{data:u}=ct({queryKey:["printers"],queryFn:oe.getPrinters}),d=u?.find(y=>y.id===t.printer_id),h=gt({mutationFn:y=>oe.updateNotificationProvider(t.id,y),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=gt({mutationFn:()=>oe.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=gt({mutationFn:()=>oe.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(St,{className:"relative",children:a.jsxs(Nt,{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(Sg,{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:kKe[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: ",$g(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(zi(t.last_error_at)?.getTime()||0)>(zi(t.last_success)?.getTime()||0))&&a.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),a.jsx(Fn,{checked:t.enabled,onChange:y=>h.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(X1,{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(ti,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),a.jsx("div",{className:"mb-3",children:a.jsxs(Ae,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{c(null),m.mutate()},className:"w-full",children:[m.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(DR,{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(Ar,{className:"w-4 h-4"}):a.jsx(Ji,{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(vh,{className:"w-4 h-4"}),"Event Settings"]}),s?a.jsx(yh,{className:"w-4 h-4"}):a.jsx(Kr,{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(Fn,{checked:t.enabled,onChange:y=>h.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(Fn,{checked:t.on_print_start,onChange:y=>h.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(Fn,{checked:t.on_plate_not_empty??!0,onChange:y=>h.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(Fn,{checked:t.on_print_complete,onChange:y=>h.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(Fn,{checked:t.on_print_failed,onChange:y=>h.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(Fn,{checked:t.on_print_stopped,onChange:y=>h.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(Fn,{checked:t.on_print_progress,onChange:y=>h.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(Fn,{checked:t.on_printer_offline,onChange:y=>h.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(Fn,{checked:t.on_printer_error,onChange:y=>h.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(Fn,{checked:t.on_filament_low,onChange:y=>h.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(Fn,{checked:t.on_maintenance_due??!1,onChange:y=>h.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(Fn,{checked:t.on_ams_humidity_high??!1,onChange:y=>h.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(Fn,{checked:t.on_ams_temperature_high??!1,onChange:y=>h.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(Fn,{checked:t.on_ams_ht_humidity_high??!1,onChange:y=>h.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(Fn,{checked:t.on_ams_ht_temperature_high??!1,onChange:y=>h.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(Fn,{checked:t.on_queue_job_added??!1,onChange:y=>h.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(Fn,{checked:t.on_queue_job_assigned??!1,onChange:y=>h.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(Fn,{checked:t.on_queue_job_started??!1,onChange:y=>h.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(Fn,{checked:t.on_queue_job_waiting??!0,onChange:y=>h.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(Fn,{checked:t.on_queue_job_skipped??!0,onChange:y=>h.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(Fn,{checked:t.on_queue_job_failed??!0,onChange:y=>h.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(Fn,{checked:t.on_queue_completed??!1,onChange:y=>h.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(X1,{className:"w-4 h-4 text-purple-400"}),a.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),a.jsx(Fn,{checked:t.quiet_hours_enabled,onChange:y=>h.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(tr,{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(ti,{className:"w-4 h-4 text-emerald-400"}),a.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),a.jsx(Fn,{checked:t.daily_digest_enabled,onChange:y=>h.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(tr,{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(Ae,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[a.jsx(mg,{className:"w-4 h-4"}),"Edit"]}),a.jsx(Ae,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:a.jsx(an,{className:"w-4 h-4"})})]})]})]})}),r&&a.jsx(Zn,{title:"Delete Notification Provider",message:`Are you sure you want to delete "${t.name}"? This cannot be undone.`,confirmText:"Delete",variant:"danger",onConfirm:()=>{p.mutate(),i(!1)},onCancel:()=>i(!1)})]})}const wq=[{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 TKe({provider:t,onClose:e}){const n=sn(),r=!!t,[i,s]=_.useState(t?.name||""),[o,l]=_.useState(t?.provider_type||"email"),[c,u]=_.useState(t?.printer_id||null),[d,h]=_.useState(t?.quiet_hours_enabled||!1),[p,m]=_.useState(t?.quiet_hours_start||"22:00"),[x,y]=_.useState(t?.quiet_hours_end||"07:00"),[v,b]=_.useState(t?.daily_digest_enabled||!1),[S,N]=_.useState(t?.daily_digest_time||"08:00"),[T,k]=_.useState(t?.on_print_start??!1),[C,E]=_.useState(t?.on_print_complete??!0),[P,A]=_.useState(t?.on_print_failed??!0),[D,I]=_.useState(t?.on_print_stopped??!0),[L,U]=_.useState(t?.on_print_progress??!1),[j,V]=_.useState(t?.on_printer_offline??!1),[K,z]=_.useState(t?.on_printer_error??!1),[X,Y]=_.useState(t?.on_filament_low??!1),[te,$]=_.useState(t?.on_maintenance_due??!1),[W,ne]=_.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([q,ee])=>[q,String(ee)])):{}),[re,ge]=_.useState(null),[me,ue]=_.useState(null),{data:Te}=ct({queryKey:["printers"],queryFn:oe.getPrinters});_.useEffect(()=>{const q=ee=>{ee.key==="Escape"&&e()};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[e]);const ie=gt({mutationFn:()=>oe.testNotificationConfig({provider_type:o,config:W}),onSuccess:q=>{ge(q),ue(null)},onError:q=>{ge({success:!1,message:q.message})}}),Ce=gt({mutationFn:q=>oe.createNotificationProvider(q),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:q=>{ue(q.message)}}),Fe=gt({mutationFn:q=>oe.updateNotificationProvider(t.id,q),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:q=>{ue(q.message)}}),xe=q=>{if(q.preventDefault(),ue(null),!i.trim()){ue("Name is required");return}const ee=Q(o);for(const he of ee)if(!W[he.key]?.trim()){ue(`${he.label} is required`);return}const B={name:i.trim(),provider_type:o,config:W,printer_id:c,quiet_hours_enabled:d,quiet_hours_start:d?p:null,quiet_hours_end:d?x:null,daily_digest_enabled:v,daily_digest_time:v?S:null,on_print_start:T,on_print_complete:C,on_print_failed:P,on_print_stopped:D,on_print_progress:L,on_printer_offline:j,on_printer_error:K,on_filament_low:X,on_maintenance_due:te};r?Fe.mutate(B):Ce.mutate(B)},Ze=Ce.isPending||Fe.isPending,G=q=>{switch(q){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:ee=>ee.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:ee=>ee.payload_format!=="slack"}];default:return[]}},Q=q=>G(q).filter(ee=>ee.required),de=G(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:q=>q.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(Lt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:xe,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:q=>s(q.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:q=>{l(q.target.value),ne({}),ge(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:wq.map(q=>a.jsx("option",{value:q.value,children:q.label},q.value))}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:wq.find(q=>q.value===o)?.description})]}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),de.filter(q=>!("showIf"in q)||q.showIf?.(W)!==!1).map(q=>a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[q.label," ",q.required&&"*"]}),q.type==="select"&&"options"in q&&q.options?a.jsx("select",{value:W[q.key]||q.options[0]?.value||"",onChange:ee=>{ne({...W,[q.key]:ee.target.value}),ge(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:q.options.map(ee=>a.jsx("option",{value:ee.value,children:ee.label},ee.value))}):a.jsx("input",{type:q.type,value:W[q.key]||"",onChange:ee=>{ne({...W,[q.key]:ee.target.value}),ge(null)},placeholder:q.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"})]},q.key))]}),a.jsx("div",{className:"flex gap-2",children:a.jsxs(Ae,{type:"button",variant:"secondary",onClick:()=>{ge(null),ie.mutate()},disabled:ie.isPending||!W[Q(o)[0]?.key],className:"flex-1",children:[ie.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(DR,{className:"w-4 h-4"}),"Test Configuration"]})}),re&&a.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${re.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:re.success?a.jsxs(a.Fragment,{children:[a.jsx(Ar,{className:"w-5 h-5"}),a.jsx("span",{children:re.message})]}):a.jsxs(a.Fragment,{children:[a.jsx(Ji,{className:"w-5 h-5"}),a.jsx("span",{children:re.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:q=>u(q.target.value?Number(q.target.value):null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"",children:"All printers"}),Te?.map(q=>a.jsx("option",{value:q.id,children:q.name},q.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(Fn,{checked:d,onChange:h})]}),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:p,onChange:q=>m(q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),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:q=>y(q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]})]})]}),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(Fn,{checked:v,onChange:b})]}),v&&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:S,onChange:q=>N(q.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),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(Fn,{checked:T,onChange:k})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Complete"}),a.jsx(Fn,{checked:C,onChange:E})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Failed"}),a.jsx(Fn,{checked:P,onChange:A})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Stopped"}),a.jsx(Fn,{checked:D,onChange:I})]}),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(Fn,{checked:L,onChange:U})]})]})]}),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(Fn,{checked:j,onChange:V})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Error"}),a.jsx(Fn,{checked:K,onChange:z})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),a.jsx(Fn,{checked:X,onChange:Y})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),a.jsx(Fn,{checked:te,onChange:$})]})]})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Ae,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Ae,{type:"submit",disabled:Ze,className:"flex-1",children:[Ze?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(ms,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function AKe({template:t,onClose:e}){const n=sn(),r=_.useRef(null),[i,s]=_.useState(t.title_template),[o,l]=_.useState(t.body_template),[c,u]=_.useState(null),[d,h]=_.useState(!0),{data:p}=ct({queryKey:["template-variables"],queryFn:oe.getTemplateVariables}),m=p?.find(k=>k.event_type===t.event_type),{data:x,isLoading:y}=ct({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>oe.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});_.useEffect(()=>{const k=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[e]);const v=gt({mutationFn:k=>oe.updateNotificationTemplate(t.id,k),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:k=>{u(k.message)}}),b=gt({mutationFn:()=>oe.resetNotificationTemplate(t.id),onSuccess:k=>{s(k.title_template),l(k.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:k=>{u(k.message)}}),S=k=>{if(k.preventDefault(),u(null),!i.trim()){u("Title is required");return}if(!o.trim()){u("Body is required");return}v.mutate({title_template:i,body_template:o})},N=k=>{const C=r.current;if(!C)return;const E=C.selectionStart,P=C.selectionEnd,A=o,D=A.substring(0,E),I=A.substring(P),L=D+`{${k}}`+I;l(L),setTimeout(()=>{C.focus();const U=E+k.length+2;C.setSelectionRange(U,U)},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(Lt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("form",{onSubmit:S,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:k=>s(k.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:k=>l(k.target.value),rows:4,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green font-mono text-sm resize-none",placeholder:"Notification body..."})]}),m&&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:m.variables.map(k=>a.jsxs("button",{type:"button",onClick:()=>N(k),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(fr,{className:"w-3 h-3"}),k]},k))}),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(xc,{className:"w-4 h-4"}),"Live Preview"]}),a.jsx("button",{type:"button",onClick:()=>h(!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(pt,{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(Ae,{type:"button",variant:"ghost",onClick:()=>b.mutate(),disabled:b.isPending,className:"text-orange-400 hover:text-orange-300",children:[b.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(Lh,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ae,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),a.jsxs(Ae,{onClick:S,disabled:v.isPending||!T,children:[v.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(ms,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const CKe={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"},jKe={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 PKe({onClose:t}){const e=sn(),{showToast:n}=Hn(),[r,i]=_.useState(7),[s,o]=_.useState(null),[l,c]=_.useState(!1),{data:u}=ct({queryKey:["settings"],queryFn:oe.getSettings}),d=u?.time_format||"system",{data:h,isLoading:p,refetch:m,isRefetching:x}=ct({queryKey:["notification-logs",r,l],queryFn:()=>oe.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:y}=ct({queryKey:["notification-log-stats",r],queryFn:()=>oe.getNotificationLogStats(r)}),v=gt({mutationFn:()=>oe.clearNotificationLogs(30),onSuccess:S=>{n(S.message,"success"),e.invalidateQueries({queryKey:["notification-logs"]}),e.invalidateQueries({queryKey:["notification-log-stats"]})},onError:S=>{n(`Failed to clear logs: ${S.message}`,"error")}}),b=S=>{const N=zi(S);if(!N)return"";const k=new Date().getTime()-N.getTime();return k<6e4?"Just now":k<36e5?`${Math.floor(k/6e4)}m ago`:k<864e5?`${Math.floor(k/36e5)}h ago`:N.toLocaleDateString()+" "+Yfe(N,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(W0,{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(Ar,{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(Ji,{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:S=>i(Number(S.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:S=>c(S.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(Ae,{size:"sm",variant:"secondary",onClick:()=>m(),disabled:x,children:[x?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(Dr,{className:"w-4 h-4"}),"Refresh"]}),a.jsxs(Ae,{size:"sm",variant:"secondary",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-red-400 hover:text-red-300",children:[v.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(an,{className:"w-4 h-4"}),"Clear Old"]})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:p?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):h&&h.length>0?a.jsx("div",{className:"space-y-2",children:h.map(S=>a.jsx(DKe,{log:S,isExpanded:s===S.id,onToggle:()=>o(s===S.id?null:S.id),formatDate:b,formatFullDate:N=>Vg(N,d)},S.id))}):a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(W0,{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(Ar,{className:"w-4 h-4 text-bambu-green shrink-0"}):a.jsx(Ji,{className:"w-4 h-4 text-red-400 shrink-0"}),a.jsx("span",{className:`text-xs font-medium ${jKe[t.event_type]||"text-bambu-gray"}`,children:CKe[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(yh,{className:"w-4 h-4 text-bambu-gray shrink-0"}):a.jsx(Kr,{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)]})]})]})]})}function RKe(){const t=sn(),[e,n]=_.useState(!1),[r,i]=_.useState(""),[s,o]=_.useState("auto"),[l,c]=_.useState(!1),[u,d]=_.useState("all"),[h,p]=_.useState(!1),[m,x]=_.useState(!1),{data:y,isLoading:v}=ct({queryKey:["spoolman-settings"],queryFn:oe.getSpoolmanSettings}),{data:b,isLoading:S,refetch:N}=ct({queryKey:["spoolman-status"],queryFn:oe.getSpoolmanStatus,refetchInterval:3e4}),{data:T}=ct({queryKey:["printers"],queryFn:oe.getPrinters});_.useEffect(()=>{y&&(n(y.spoolman_enabled==="true"),i(y.spoolman_url||""),o(y.spoolman_sync_mode||"auto"),p(!0))},[y]),_.useEffect(()=>{if(!h||!y)return;if(y.spoolman_enabled==="true"!==e||(y.spoolman_url||"")!==r||(y.spoolman_sync_mode||"auto")!==s){const V=setTimeout(()=>{k.mutate()},500);return()=>clearTimeout(V)}},[e,r,s,h]);const k=gt({mutationFn:()=>oe.updateSpoolmanSettings({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)}}),C=gt({mutationFn:oe.connectSpoolman,onSuccess:()=>{N()}}),E=gt({mutationFn:oe.disconnectSpoolman,onSuccess:()=>{N()}}),P=gt({mutationFn:oe.syncAllPrintersAms,onSuccess:j=>{j.success}}),A=gt({mutationFn:j=>oe.syncPrinterAms(j),onSuccess:j=>{j.success}}),D=()=>{u==="all"?P.mutate():A.mutate(u)},I=P.isPending||A.isPending,L=u==="all"?P.data:A.data,U=u==="all"?P.isSuccess:A.isSuccess;return v?a.jsxs(St,{children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Eu,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),a.jsx(Nt,{children:a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):a.jsxs(St,{children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Eu,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),k.isPending&&a.jsx(pt,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&a.jsx(Wi,{className:"w-4 h-4 text-bambu-green"})]})}),a.jsxs(Nt,{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(nl,{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:"}),S?a.jsx(pt,{className:"w-4 h-4 text-bambu-gray animate-spin"}):b?.connected?a.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[a.jsx(Wi,{className:"w-4 h-4"}),"Connected"]}):a.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[a.jsx(Lt,{className:"w-4 h-4"}),"Disconnected"]})]}),a.jsx("div",{className:"flex gap-2",children:b?.connected?a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:()=>E.mutate(),disabled:E.isPending,children:[E.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(Ade,{className:"w-4 h-4"}),"Disconnect"]}):a.jsxs(Ae,{size:"sm",onClick:()=>C.mutate(),disabled:C.isPending||!r,children:[C.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(fc,{className:"w-4 h-4"}),"Connect"]})})]}),C.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:C.error.message}),b?.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(Kr,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:D,disabled:I,children:[I?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(Dr,{className:"w-4 h-4"}),"Sync"]})]})]}),U&&L&&a.jsxs("div",{className:"mt-3 space-y-2",children:[a.jsx("div",{className:`p-2 rounded text-sm ${L.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:L.success?`Synced ${L.synced_count} spool${L.synced_count!==1?"s":""} successfully`:`Synced ${L.synced_count} spool${L.synced_count!==1?"s":""} with ${L.errors.length} error${L.errors.length!==1?"s":""}`}),L.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(Sn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{className:"font-medium",children:[L.skipped_count," spool",L.skipped_count!==1?"s":""," skipped"]})]}),L.skipped_count>5&&a.jsx("button",{onClick:()=>x(!m),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:m?"Show less":"Show all"})]}),a.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(m?L.skipped:L.skipped.slice(0,5)).map((j,V)=>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]})]},V)),!m&&L.skipped_count>5&&a.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",L.skipped_count-5," more"]})]})]}),L.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:L.errors.map((j,V)=>a.jsx("li",{children:j},V))})]})]})]})]})]})}function OKe({link:t,onClose:e}){const n=sn(),{mode:r}=Fh(),i=!!t,s=_.useRef(null),[o,l]=_.useState(t?.name||""),[c,u]=_.useState(t?.url||""),[d,h]=_.useState(t?.icon||"link"),[p,m]=_.useState(!!t?.custom_icon),[x,y]=_.useState(t?.custom_icon?oe.getExternalLinkIconUrl(t.id):null),[v,b]=_.useState(null),[S,N]=_.useState(null);_.useEffect(()=>{const I=L=>{L.key==="Escape"&&e()};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[e]);const T=gt({mutationFn:async I=>{const L=await oe.createExternalLink(I);return v?await oe.uploadExternalLinkIcon(L.id,v):L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:I=>{N(I.message)}}),k=gt({mutationFn:async I=>{let L=await oe.updateExternalLink(t.id,I);return v?L=await oe.uploadExternalLinkIcon(t.id,v):!p&&t?.custom_icon&&(L=await oe.deleteExternalLinkIcon(t.id)),L},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:I=>{N(I.message)}}),C=I=>{const L=I.target.files?.[0];if(L){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(L.type)){N("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(L.size>1024*1024){N("Image file must be less than 1MB");return}b(L),m(!0);const j=new FileReader;j.onload=V=>{y(V.target?.result)},j.readAsDataURL(L)}},E=()=>{b(null),y(null),m(!1),s.current&&(s.current.value="")},P=I=>{if(I.preventDefault(),N(null),!o.trim()){N("Name is required");return}if(!c.trim()){N("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){N("URL must start with http:// or https://");return}const L={name:o.trim(),url:c.trim(),icon:d};i?k.mutate(L):T.mutate(L)},A=T.isPending||k.isPending,D=vM(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:I=>I.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:p&&x?a.jsx("img",{src:x,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):a.jsx(D,{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(Lt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:P,className:"p-6 space-y-4",children:[S&&a.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:S}),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:I=>l(I.target.value),placeholder:"My Link",maxLength:50,className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),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:I=>u(I.target.value),placeholder:"https://example.com",className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),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:C}),p&&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:E,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:a.jsx(an,{className:"w-4 h-4"})})]}):a.jsxs(Ae,{type:"button",variant:"secondary",size:"sm",onClick:()=>s.current?.click(),children:[a.jsx(Ba,{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."})]}),!p&&a.jsxs("div",{children:[a.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),a.jsx(Ffe,{value:d,onChange:h})]})]}),a.jsxs("div",{className:"flex gap-3 pt-2",children:[a.jsx(Ae,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),a.jsxs(Ae,{type:"submit",disabled:A,className:"flex-1",children:[A?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(ms,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function LKe(){const t=sn(),[e,n]=_.useState(!1),[r,i]=_.useState(null),[s,o]=_.useState(null),[l,c]=_.useState(null),{data:u,isLoading:d}=ct({queryKey:["external-links"],queryFn:oe.getExternalLinks}),h=gt({mutationFn:S=>oe.deleteExternalLink(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),p=gt({mutationFn:S=>oe.reorderExternalLinks(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=(S,N)=>{c(N),S.dataTransfer.effectAllowed="move"},x=S=>{S.preventDefault(),S.dataTransfer.dropEffect="move"},y=(S,N)=>{if(S.preventDefault(),l===null||l===N||!u)return;const T=u.map(P=>P.id),k=T.indexOf(l),C=T.indexOf(N);if(k===-1||C===-1)return;const E=[...T];E.splice(k,1),E.splice(C,0,l),p.mutate(E),c(null)},v=S=>{o(S)},b=()=>{s&&(h.mutate(s.id),o(null))};return a.jsxs(a.Fragment,{children:[a.jsxs(St,{children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(fc,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),a.jsxs(Ae,{size:"sm",onClick:()=>n(!0),children:[a.jsx(fr,{className:"w-4 h-4"}),"Add Link"]})]})}),a.jsxs(Nt,{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(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?a.jsx("div",{className:"space-y-2",children:u.map(S=>{const N=vM(S.icon);return a.jsxs("div",{draggable:!0,onDragStart:T=>m(T,S.id),onDragOver:x,onDrop:T=>y(T,S.id),className:`flex items-center gap-3 p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary transition-colors ${l===S.id?"opacity-50":""}`,children:[a.jsx(Hg,{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(N,{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:S.name}),a.jsx(Xr,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),a.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:S.url})]}),a.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[a.jsx("button",{onClick:()=>i(S),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:"Edit",children:a.jsx(ea,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>v(S),disabled:h.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(an,{className:"w-4 h-4"})})]})]},S.id)})}):a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(fc,{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(OKe,{link:r,onClose:()=>{n(!1),i(null)}}),s&&a.jsx(Zn,{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:b,onCancel:()=>o(null)})]})}function FKe(){const{t}=On(),e=sn(),{showToast:n}=Hn(),[r,i]=_.useState(!1),[s,o]=_.useState(""),[l,c]=_.useState("immediate"),[u,d]=_.useState("3DPrinter-X1-Carbon"),[h,p]=_.useState(null),[m,x]=_.useState(!1),[y,v]=_.useState(null),{data:b,isLoading:S}=ct({queryKey:["virtual-printer-settings"],queryFn:x1.getSettings,refetchInterval:1e4}),{data:N}=ct({queryKey:["virtual-printer-models"],queryFn:x1.getModels}),{data:T}=ct({queryKey:["printers"],queryFn:oe.getPrinters});_.useEffect(()=>{if(b){i(b.enabled);let U=b.mode==="queue"?"review":b.mode;U!=="immediate"&&U!=="review"&&U!=="print_queue"&&U!=="proxy"&&(U="immediate"),c(U),d(b.model),p(b.target_printer_id)}},[b]);const k=gt({mutationFn:U=>x1.updateSettings(U),onSuccess:()=>{e.invalidateQueries({queryKey:["virtual-printer-settings"]}),n(t("virtualPrinter.toast.updated")),v(null)},onError:U=>{if(n(U.message||t("virtualPrinter.toast.failedToUpdate"),"error"),b){i(b.enabled);const j=b.mode==="queue"?"review":b.mode;c(["immediate","review","print_queue","proxy"].includes(j)?j:"immediate"),d(b.model),p(b.target_printer_id)}v(null)}}),C=()=>{const U=!r;if(U){if(l==="proxy"){if(!h){n(t("virtualPrinter.toast.targetPrinterRequired"),"error");return}}else if(!s&&!b?.access_code_set){n(t("virtualPrinter.toast.accessCodeRequired"),"error");return}}i(U),v("toggle"),k.mutate({enabled:U,access_code:l!=="proxy"&&s||void 0,mode:l,target_printer_id:l==="proxy"?h??void 0:void 0})},E=()=>{if(!s){n(t("virtualPrinter.toast.accessCodeEmpty"),"error");return}if(s.length!==8){n(t("virtualPrinter.toast.accessCodeLength"),"error");return}v("accessCode"),k.mutate({access_code:s}),o("")},P=U=>{c(U),v("mode"),k.mutate({mode:U})},A=U=>{p(U),v("targetPrinter"),k.mutate({target_printer_id:U})},D=U=>{d(U),v("model"),k.mutate({model:U})};if(S)return a.jsx(St,{children:a.jsx(Nt,{className:"py-8 flex justify-center",children:a.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const I=b?.status,L=I?.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(St,{children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ur,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:t("virtualPrinter.title")})]}),I&&a.jsxs("div",{className:`flex items-center gap-2 text-sm ${L?"text-green-400":"text-bambu-gray"}`,children:[a.jsx("span",{className:`w-2 h-2 rounded-full ${L?"bg-green-400 animate-pulse":"bg-gray-500"}`}),t(L?"virtualPrinter.running":"virtualPrinter.stopped")]})]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:t(l==="proxy"?"virtualPrinter.description.proxy":"virtualPrinter.description.default")}),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:t("virtualPrinter.enable.title")}),a.jsx("div",{className:"text-sm text-bambu-gray",children:L?l==="proxy"?t("virtualPrinter.enable.proxyingTo",{name:T?.find(U=>U.id===h)?.name||"printer"}):t("virtualPrinter.enable.visibleInSlicer"):t("virtualPrinter.enable.notActive")})]}),a.jsx("button",{onClick:C,disabled:y==="toggle",className:`relative w-12 h-6 rounded-full transition-colors ${r?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${y==="toggle"?"opacity-50":""}`,children:a.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${r?"translate-x-6":""}`})})]}),l!=="proxy"&&a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.model.title")}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:t("virtualPrinter.model.description")}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:u,onChange:U=>D(U.target.value),disabled:y==="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:N?.models&&Object.entries(N.models).sort(([,U],[,j])=>U.localeCompare(j)).map(([U,j])=>a.jsx("option",{value:U,children:j},U))}),a.jsx(Kr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),r&&L&&a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[a.jsx(nl,{className:"w-3 h-3 inline mr-1"}),t("virtualPrinter.model.restartWarning")]})]}),l!=="proxy"&&a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.accessCode.title")}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:b?.access_code_set?a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(Wi,{className:"w-4 h-4"}),t("virtualPrinter.accessCode.isSet")]}):a.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[a.jsx(Sn,{className:"w-4 h-4"}),t("virtualPrinter.accessCode.notSet")]})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("div",{className:"relative flex-1",children:[a.jsx("input",{type:m?"text":"password",value:s,onChange:U=>o(U.target.value),placeholder:b?.access_code_set?t("virtualPrinter.accessCode.placeholderChange"):t("virtualPrinter.accessCode.placeholder"),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:()=>x(!m),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:m?a.jsx(uM,{className:"w-4 h-4"}):a.jsx(xc,{className:"w-4 h-4"})})]}),a.jsx(Ae,{onClick:E,disabled:!s||y==="accessCode",variant:"primary",children:y==="accessCode"?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):t("common.save")})]}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[t("virtualPrinter.accessCode.hint"),s&&a.jsxs("span",{className:s.length===8?"text-green-400":"text-yellow-400",children:[" ",t("virtualPrinter.accessCode.charCount",{count:s.length})]})]})]}),l==="proxy"&&a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.targetPrinter.title")}),a.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:h?a.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[a.jsx(Wi,{className:"w-4 h-4"}),t("virtualPrinter.targetPrinter.configured")]}):a.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[a.jsx(Sn,{className:"w-4 h-4"}),t("virtualPrinter.targetPrinter.notConfigured")]})}),a.jsxs("div",{className:"relative",children:[a.jsxs("select",{value:h??"",onChange:U=>{const j=parseInt(U.target.value,10);isNaN(j)||A(j)},disabled:y==="targetPrinter",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:[a.jsx("option",{value:"",children:t("virtualPrinter.targetPrinter.placeholder")}),T?.map(U=>a.jsxs("option",{value:U.id,children:[U.name," (",U.ip_address,")"]},U.id))]}),a.jsx(Kr,{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-2",children:t("virtualPrinter.targetPrinter.hint")}),!T?.length&&a.jsxs("p",{className:"text-xs text-yellow-400 mt-2",children:[a.jsx(Sn,{className:"w-3 h-3 inline mr-1"}),t("virtualPrinter.targetPrinter.noPrinters")]})]}),a.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[a.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.mode.title")}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("button",{onClick:()=>P("immediate"),disabled:y==="mode",className:`p-3 rounded-lg border text-left transition-colors ${l==="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:t("virtualPrinter.mode.archive")}),a.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.archiveDesc")})]}),a.jsxs("button",{onClick:()=>P("review"),disabled:y==="mode",className:`p-3 rounded-lg border text-left transition-colors ${l==="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:t("virtualPrinter.mode.review")}),a.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.reviewDesc")})]}),a.jsxs("button",{onClick:()=>P("print_queue"),disabled:y==="mode",className:`p-3 rounded-lg border text-left transition-colors ${l==="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:t("virtualPrinter.mode.queue")}),a.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.queueDesc")})]}),a.jsxs("button",{onClick:()=>P("proxy"),disabled:y==="mode",className:`p-3 rounded-lg border text-left transition-colors ${l==="proxy"?"border-blue-500 bg-blue-500/10":"border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:[a.jsxs("div",{className:"flex items-center gap-1.5 text-white font-medium",children:[a.jsx(Lz,{className:"w-4 h-4"}),t("virtualPrinter.mode.proxy")]}),a.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.proxyDesc")})]})]})]})]})]})}),a.jsxs("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:[a.jsx(St,{className:"border-l-4 border-l-yellow-500",children:a.jsx(Nt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Sn,{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:t("virtualPrinter.setupRequired.title")}),a.jsx("p",{className:"text-bambu-gray mb-3",children:t("virtualPrinter.setupRequired.description")}),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(Xr,{className:"w-4 h-4"}),t("virtualPrinter.setupRequired.readGuide")]})]})]})})}),a.jsx(St,{children:a.jsx(Nt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(nl,{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.jsxs("strong",{className:"text-white",children:[t(l==="proxy"?"virtualPrinter.howItWorks.titleProxy":"virtualPrinter.howItWorks.title"),":"]})}),l==="proxy"?a.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep1")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep2")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep3")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep4")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep5")})]}):a.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[a.jsx("li",{children:t("virtualPrinter.howItWorks.step1")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step2")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step3")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step4")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step5")}),a.jsx("li",{children:t("virtualPrinter.howItWorks.step6")})]})]})]})})}),I&&L&&a.jsxs(St,{children:[a.jsx(Kn,{children:a.jsx("h3",{className:"text-md font-semibold text-white",children:t("virtualPrinter.status.title")})}),a.jsx(Nt,{children:I.mode==="proxy"&&I.proxy?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:t("virtualPrinter.status.targetPrinter")}),a.jsx("div",{className:"text-white",children:T?.find(U=>U.id===h)?.name||I.proxy.target_host}),a.jsx("div",{className:"text-xs text-bambu-gray font-mono",children:I.proxy.target_host})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mode")}),a.jsxs("div",{className:"text-white flex items-center gap-1.5",children:[a.jsx(Lz,{className:"w-4 h-4"}),t("virtualPrinter.mode.proxy")]})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.ftpPort")}),a.jsx("div",{className:"text-white font-mono",children:I.proxy.ftp_port})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mqttPort")}),a.jsx("div",{className:"text-white font-mono",children:I.proxy.mqtt_port})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.ftpConnections")}),a.jsx("div",{className:"text-white",children:I.proxy.ftp_connections})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mqttConnections")}),a.jsx("div",{className:"text-white",children:I.proxy.mqtt_connections})]})]}):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:t("virtualPrinter.status.printerName")}),a.jsx("div",{className:"text-white",children:I.name})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.model")}),a.jsx("div",{className:"text-white",children:I.model_name||I.model})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.serialNumber")}),a.jsx("div",{className:"text-white font-mono",children:I.serial})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mode")}),a.jsx("div",{className:"text-white capitalize",children:I.mode})]}),a.jsxs("div",{children:[a.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.pendingFiles")}),a.jsx("div",{className:"text-white",children:I.pending_files})]})]})})]})]})]})}function _q({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(Ar,{className:"w-3 h-3"}),failed:a.jsx(Ji,{className:"w-3 h-3"}),skipped:a.jsx(RR,{className:"w-3 h-3"}),running:a.jsx(pt,{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 IKe(t){return t?new Date(t).toLocaleString():"-"}function Sq(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 UKe(){const t=sn(),{showToast:e}=Hn(),{t:n}=On(),[r,i]=_.useState(""),[s,o]=_.useState(""),[l,c]=_.useState("main"),[u,d]=_.useState(!1),[h,p]=_.useState("daily"),[m,x]=_.useState(!0),[y,v]=_.useState(!0),[b,S]=_.useState(!1),[N,T]=_.useState(!0),[k,C]=_.useState(!1),[E,P]=_.useState(!1),[A,D]=_.useState(""),[I,L]=_.useState(!1),[U,j]=_.useState(null),[V,K]=_.useState(null),z=_.useRef(null);_.useEffect(()=>{if(k||E){const H=O=>(O.preventDefault(),O.returnValue="A backup operation is in progress. Are you sure you want to leave?",O.returnValue);return window.addEventListener("beforeunload",H),()=>window.removeEventListener("beforeunload",H)}},[k,E]);const[X,Y]=_.useState(!1),[te,$]=_.useState(null),W=_.useRef(null),ne=_.useRef(!1),{data:re,isLoading:ge}=ct({queryKey:["github-backup-config"],queryFn:oe.getGitHubBackupConfig}),{data:me}=ct({queryKey:["github-backup-status"],queryFn:oe.getGitHubBackupStatus,refetchInterval:pe=>pe.state.data?.is_running?500:1e4}),{data:ue}=ct({queryKey:["github-backup-logs"],queryFn:()=>oe.getGitHubBackupLogs(20)}),{data:Te}=ct({queryKey:["cloud-status"],queryFn:oe.getCloudStatus}),{data:ie}=ct({queryKey:["printers"],queryFn:oe.getPrinters}),Ce=vW({queries:(ie??[]).map(pe=>({queryKey:["printerStatus",pe.id],queryFn:()=>oe.getPrinterStatus(pe.id),staleTime:1e4,refetchInterval:3e4}))}),Fe=(ie??[]).map((pe,H)=>({printer:pe,connected:Ce[H]?.data?.connected??!1})),xe=Fe.length,Ze=Fe.filter(pe=>pe.connected).length,G=xe>0&&Ze===0,Q=Ze>0&&Ze<xe;_.useEffect(()=>{re&&(i(re.repository_url),c(re.branch),d(re.schedule_enabled),p(re.schedule_type),x(re.backup_kprofiles),v(re.backup_cloud_profiles),S(re.backup_settings),T(re.enabled),o(""),setTimeout(()=>{ne.current=!0},100))},[re]);const de=_.useCallback(async(pe=!1)=>{if(re?.has_token)try{pe&&s?(await oe.saveGitHubBackupConfig({repository_url:r,access_token:s,branch:l,schedule_enabled:u,schedule_type:h,backup_kprofiles:m,backup_cloud_profiles:y,backup_settings:b,enabled:N}),o(""),e("Token updated")):(await oe.updateGitHubBackupConfig({repository_url:r,branch:l,schedule_enabled:u,schedule_type:h,backup_kprofiles:m,backup_cloud_profiles:y,backup_settings:b,enabled:N}),e("Settings saved")),t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]})}catch(H){e(`Failed to save: ${H.message}`,"error")}},[re?.has_token,r,s,l,u,h,m,y,b,N,t,e]);_.useEffect(()=>{if(!(!ne.current||!re?.has_token))return W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{de(!1)},500),()=>{W.current&&clearTimeout(W.current)}},[r,l,u,h,m,y,b,N,de,re?.has_token]),_.useEffect(()=>{if(!(!ne.current||!re?.has_token||!s))return W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{de(!0)},1e3),()=>{W.current&&clearTimeout(W.current)}},[s,de,re?.has_token]);const q=gt({mutationFn:pe=>oe.saveGitHubBackupConfig(pe),onSuccess:()=>{t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]}),e("GitHub backup enabled"),o(""),ne.current=!0},onError:pe=>{e(`Failed to save: ${pe.message}`,"error")}}),ee=gt({mutationFn:oe.triggerGitHubBackup,onSuccess:pe=>{t.invalidateQueries({queryKey:["github-backup-status"]}),t.invalidateQueries({queryKey:["github-backup-logs"]}),pe.success?pe.files_changed>0?e(`Backup complete - ${pe.files_changed} files updated`):e("Backup skipped - no changes"):e(`Backup failed: ${pe.message}`,"error")},onError:pe=>{e(`Backup failed: ${pe.message}`,"error")}}),B=gt({mutationFn:()=>oe.clearGitHubBackupLogs(0),onSuccess:pe=>{t.invalidateQueries({queryKey:["github-backup-logs"]}),e(`Cleared ${pe.deleted} logs`)},onError:pe=>{e(`Failed to clear logs: ${pe.message}`,"error")}}),he=async()=>{Y(!0),$(null);try{let pe;if(s){if(!r){e("Enter repository URL","error"),Y(!1);return}pe=await oe.testGitHubConnection(r,s)}else if(re?.has_token)pe=await oe.testGitHubStoredConnection();else{e("Enter repository URL and access token","error"),Y(!1);return}$({success:pe.success,message:pe.message})}catch(pe){$({success:!1,message:pe.message})}finally{Y(!1)}},ke=()=>{if(!r){e("Repository URL is required","error");return}if(!s){e("Access token is required","error");return}q.mutate({repository_url:r,access_token:s,branch:l,schedule_enabled:u,schedule_type:h,backup_kprofiles:m,backup_cloud_profiles:y,backup_settings:b,enabled:N})};return ge?a.jsx("div",{className:"flex items-center justify-center py-12",children:a.jsx(pt,{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(St,{children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(mP,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"GitHub Backup"})]}),re&&Te?.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(Fn,{checked:N,onChange:T})]})]})}),a.jsx(Nt,{className:"space-y-4",children:Te?.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:r,onChange:pe=>{i(pe.target.value),$(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 ",re?.has_token&&a.jsx("span",{className:"text-green-400",children:"(saved)"})]}),a.jsx("input",{type:"password",value:s,onChange:pe=>{o(pe.target.value),$(null)},placeholder:re?.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:l,onChange:pe=>c(pe.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:u?h:"disabled",onChange:pe=>{pe.target.value==="disabled"?d(!1):(d(!0),p(pe.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 ${G?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[a.jsx("input",{type:"checkbox",checked:m,onChange:pe=>x(pe.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:G}),a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`text-sm ${G?"text-bambu-gray":"text-white"}`,children:"K-Profiles"}),G&&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(Sn,{className:"w-3 h-3"}),"No printers connected"]}),Q&&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(Sn,{className:"w-3 h-3"}),Ze,"/",xe," 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:y,onChange:pe=>v(pe.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:!Te?.is_authenticated}),a.jsxs("div",{children:[a.jsx("span",{className:`text-sm ${Te?.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:pe=>S(pe.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:[me?.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:me.last_backup_at?a.jsxs(a.Fragment,{children:[a.jsxs("span",{children:["Last backup: ",Sq(me.last_backup_at)]}),a.jsx(_q,{status:me.last_backup_status})]}):a.jsx("span",{children:"No backups yet"})}),me.next_scheduled_run&&a.jsxs("span",{className:"text-bambu-gray",children:[a.jsx(tr,{className:"w-3 h-3 inline mr-1"}),"Next: ",Sq(me.next_scheduled_run)]})]}),te&&a.jsxs("div",{className:`text-sm flex items-center gap-1 ${te.success?"text-green-400":"text-red-400"}`,children:[te.success?a.jsx(Ar,{className:"w-4 h-4"}):a.jsx(Ji,{className:"w-4 h-4"}),te.message]}),a.jsx("div",{className:"flex flex-wrap items-center gap-2",children:me?.configured?a.jsx(a.Fragment,{children:ee.isPending||me.is_running?a.jsxs("div",{className:"flex items-center gap-2 text-bambu-green",children:[a.jsx(pt,{className:"w-4 h-4 animate-spin"}),a.jsx("span",{className:"text-sm",children:me.progress||"Starting backup..."})]}):a.jsxs(a.Fragment,{children:[a.jsxs(Ae,{variant:"primary",size:"sm",onClick:()=>ee.mutate(),disabled:!re?.enabled,children:[a.jsx(So,{className:"w-4 h-4"}),"Backup Now"]}),a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:he,disabled:X,children:[X?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(Dr,{className:"w-4 h-4"}),"Test"]})]})}):a.jsxs(a.Fragment,{children:[a.jsxs(Ae,{variant:"primary",size:"sm",onClick:ke,disabled:q.isPending||!r||!s,children:[q.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(Ar,{className:"w-4 h-4"}),"Enable Backup"]}),a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:he,disabled:X||!r||!s,children:[X?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(Dr,{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(Sn,{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."})]})})]}),ue&&ue.length>0&&a.jsxs(St,{children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(W0,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"History"})]}),a.jsxs(Ae,{variant:"ghost",size:"sm",onClick:()=>B.mutate(),disabled:B.isPending,children:[a.jsx(an,{className:"w-4 h-4"}),"Clear"]})]})}),a.jsx(Nt,{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:ue.slice(0,10).map(pe=>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:IKe(pe.started_at)}),a.jsx("td",{className:"py-2 px-2",children:a.jsx(_q,{status:pe.status})}),a.jsx("td",{className:"py-2 px-2",children:pe.commit_sha?a.jsxs("a",{href:`${re?.repository_url}/commit/${pe.commit_sha}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline inline-flex items-center gap-1",children:[pe.commit_sha.substring(0,7),a.jsx(Xr,{className:"w-3 h-3"})]}):a.jsx("span",{className:"text-bambu-gray",children:"-"})})]},pe.id))})]})})})]})]}),a.jsx("div",{className:"space-y-6",children:a.jsxs(St,{children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Eu,{className:"w-5 h-5 text-gray-400"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Local Backup"})]})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:"Create a complete backup of your Bambuddy data including the database, archives, uploads, and all files."}),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:"Download Backup"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Complete backup: database + all files (ZIP)"})]}),a.jsxs(Ae,{variant:"secondary",size:"sm",disabled:k||E,onClick:async()=>{C(!0),D("Preparing backup...");try{D("Creating backup archive... This may take a while for large archives.");const{blob:pe,filename:H}=await oe.exportBackup();D("Downloading backup file...");const O=URL.createObjectURL(pe),J=document.createElement("a");J.href=O,J.download=H,J.click(),URL.revokeObjectURL(O),e("Backup downloaded successfully")}catch(pe){e(`Failed to create backup: ${pe instanceof Error?pe.message:"Unknown error"}`,"error")}finally{C(!1),D("")}},children:[a.jsx(wi,{className:"w-4 h-4"}),"Download"]})]}),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:n("backup.restoreBackup")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.restoreDescription")}),a.jsx("p",{className:"text-xs text-bambu-gray-light mt-1",children:n("backup.restoreNote")})]}),a.jsx("input",{ref:z,type:"file",accept:".zip",className:"hidden",onChange:pe=>{const H=pe.target.files?.[0];H&&(j(H),L(!0)),pe.target.value=""}}),a.jsxs(Ae,{variant:"secondary",size:"sm",disabled:E||k,onClick:()=>z.current?.click(),children:[a.jsx(Ba,{className:"w-4 h-4"}),"Restore"]})]}),V&&a.jsx("div",{className:`p-3 rounded-lg ${V.success?"bg-green-500/10 border border-green-500/30":"bg-red-500/10 border border-red-500/30"}`,children:a.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[V.success?a.jsx(Ar,{className:"w-4 h-4 text-green-400 mt-0.5 flex-shrink-0"}):a.jsx(Ji,{className:"w-4 h-4 text-red-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:V.success?"text-green-200":"text-red-200",children:[V.message,V.success&&a.jsx("div",{className:"mt-2",children:a.jsxs(Ae,{size:"sm",onClick:()=>window.location.reload(),children:[a.jsx(Lh,{className:"w-3 h-3"}),"Reload Now"]})})]})]})}),a.jsx("div",{className:"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(Sn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsxs("div",{className:"text-yellow-200",children:[a.jsx("span",{className:"font-medium",children:"Restore replaces all data."})," ",a.jsx("span",{className:"text-yellow-200/70",children:"Your current database and files will be completely replaced. A restart is required after restore."})]})]})})]})]})}),I&&U&&a.jsx(Zn,{title:"Restore Backup",message:`Are you sure you want to restore from "${U.name}"? This will completely replace your current database and all files. The application will need to be restarted after restore.`,confirmText:"Restore Backup",variant:"danger",onConfirm:async()=>{L(!1),P(!0),K(null);try{D("Uploading backup file...");const pe=await oe.importBackup(U);K(pe),pe.success?e("Backup restored. Please restart Bambuddy.","success"):e(pe.message,"error")}catch(pe){const H=pe instanceof Error?pe.message:"Failed to restore backup";K({success:!1,message:H}),e(H,"error")}finally{P(!1),D(""),j(null)}},onCancel:()=>{L(!1),j(null)}}),(k||E)&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[100]",children:a.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl p-8 max-w-md w-full mx-4 text-center",children:[a.jsx("div",{className:"flex justify-center mb-4",children:a.jsxs("div",{className:"relative",children:[a.jsx("div",{className:"w-16 h-16 border-4 border-bambu-dark-tertiary rounded-full"}),a.jsx("div",{className:"w-16 h-16 border-4 border-bambu-green border-t-transparent rounded-full absolute inset-0 animate-spin"})]})}),a.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:k?"Creating Backup":"Restoring Backup"}),a.jsx("p",{className:"text-bambu-gray mb-4",children:A||(k?"Preparing...":"Processing...")}),a.jsx("div",{className:"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(Sn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-yellow-200 text-left",children:"Please do not close this page or navigate away. This operation may take several minutes for large backups."})]})})]})})]})}const zKe={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 BKe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function g0(t,e,n=0){if(n>5)return"...";if(e.$ref)return g0(t,BKe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const s=g0(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?[g0(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,s]of Object.entries(e.properties))r[i]=g0(t,s,n+1);return r}return{};default:return null}}function HKe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[s,o]=_.useState(!1),[l,c]=_.useState({}),[u,d]=_.useState(""),[h,p]=_.useState(null),[m,x]=_.useState(!1),[y,v]=_.useState(!1);_.useEffect(()=>{if(s&&n.parameters){const P={};for(const A of n.parameters)A.schema?.default!==void 0&&(P[A.name]=String(A.schema.default));c(A=>({...P,...A}))}},[s,n.parameters]),_.useEffect(()=>{if(s&&n.requestBody?.content?.["application/json"]?.schema&&!u){const P=n.requestBody.content["application/json"].schema,A=g0(r,P);d(JSON.stringify(A,null,2))}},[s,n.requestBody,r,u]);const S=(()=>{const P=[];for(const A of n.parameters||[])if(A.in==="path"||A.required){const D=l[A.name];(D===void 0||D==="")&&P.push(A.name)}return P})(),N=async()=>{if(S.length>0){p({status:0,statusText:"Validation Error",headers:{},body:`Missing required parameters: ${S.join(", ")}`,duration:0});return}x(!0),p(null);try{let P=t;const A=new URLSearchParams;for(const te of n.parameters||[]){const $=l[te.name];$!==void 0&&$!==""&&(te.in==="path"?P=P.replace(`{${te.name}}`,encodeURIComponent($)):te.in==="query"&&A.append(te.name,$))}const D=A.toString(),I=`${P}${D?`?${D}`:""}`,L={"Content-Type":"application/json"};i&&(L["X-API-Key"]=i);const U={method:e.toUpperCase(),headers:L};["post","put","patch"].includes(e)&&u&&(U.body=u);const j=performance.now(),V=await fetch(I,U),K=Math.round(performance.now()-j),z={};V.headers.forEach((te,$)=>{z[$]=te});let X;V.headers.get("content-type")?.includes("application/json")?X=await V.json():X=await V.text(),p({status:V.status,statusText:V.statusText,headers:z,body:X,duration:K})}catch(P){p({status:0,statusText:"Network Error",headers:{},body:P instanceof Error?P.message:"Unknown error",duration:0})}finally{x(!1)}},T=async()=>{if(h){const P=typeof h.body=="string"?h.body:JSON.stringify(h.body,null,2);try{await navigator.clipboard.writeText(P),v(!0),setTimeout(()=>v(!1),2e3)}catch{const A=document.createElement("textarea");A.value=P,A.style.position="fixed",A.style.left="-999999px",document.body.appendChild(A),A.select(),document.execCommand("copy"),document.body.removeChild(A),v(!0),setTimeout(()=>v(!1),2e3)}}},k=(n.parameters||[]).filter(P=>P.in==="path"),C=(n.parameters||[]).filter(P=>P.in==="query"),E=["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(Kr,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):a.jsx(vs,{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 ${zKe[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}),k.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:k.map(P=>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:[P.name,P.required&&a.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),a.jsx("input",{type:"text",value:l[P.name]||"",onChange:A=>c(D=>({...D,[P.name]:A.target.value})),placeholder:P.description||P.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"})]},P.name))})]}),C.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:C.map(P=>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:[P.name,P.required&&a.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),P.schema?.enum?a.jsxs("select",{value:l[P.name]||"",onChange:A=>c(D=>({...D,[P.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 --"}),P.schema.enum.map(A=>a.jsx("option",{value:A,children:A},A))]}):a.jsx("input",{type:"text",value:l[P.name]||"",onChange:A=>c(D=>({...D,[P.name]:A.target.value})),placeholder:P.description||P.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"})]},P.name))})]}),E&&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:P=>d(P.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(Ae,{onClick:N,disabled:m,children:[m?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(So,{className:"w-4 h-4"}),"Execute"]}),S.length>0&&a.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[a.jsx(Vi,{className:"w-3 h-3"}),"Fill in: ",S.join(", ")]})]}),h&&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 ${h.status>=200&&h.status<300?"bg-green-500/20 text-green-400":h.status>=400?"bg-red-500/20 text-red-400":"bg-yellow-500/20 text-yellow-400"}`,children:[h.status," ",h.statusText]}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:[h.duration,"ms"]})]}),a.jsx(Ae,{variant:"secondary",size:"sm",onClick:T,children:y?a.jsx(Ar,{className:"w-3 h-3 text-green-400"}):a.jsx(Ul,{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 h.body=="string"?h.body:JSON.stringify(h.body,null,2)})]})]})]})}function $Ke({apiKey:t=""}){const[e,n]=_.useState(null),[r,i]=_.useState(!0),[s,o]=_.useState(null),[l,c]=_.useState(new Set),[u,d]=_.useState("");if(_.useEffect(()=>{async function v(){try{const b=await fetch("/openapi.json");if(!b.ok)throw new Error("Failed to fetch OpenAPI schema");const S=await b.json();n(S)}catch(b){o(b instanceof Error?b.message:"Unknown error")}finally{i(!1)}}v()},[]),r)return a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(s||!e)return a.jsx(St,{children:a.jsx(Nt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-red-400",children:[a.jsx(Vi,{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 h={};for(const[v,b]of Object.entries(e.paths))for(const[S,N]of Object.entries(b)){if(S==="parameters")continue;const T=N.tags||["Other"];for(const k of T)h[k]||(h[k]=[]),h[k].push({path:v,method:S,spec:N})}const p=Object.entries(h).map(([v,b])=>{if(!u)return{tag:v,endpoints:b};const S=b.filter(({path:N,method:T,spec:k})=>{const C=u.toLowerCase();return N.toLowerCase().includes(C)||T.toLowerCase().includes(C)||(k.summary?.toLowerCase()||"").includes(C)||(k.description?.toLowerCase()||"").includes(C)});return{tag:v,endpoints:S}}).filter(({endpoints:v})=>v.length>0).sort((v,b)=>v.tag.localeCompare(b.tag)),m=v=>{c(b=>{const S=new Set(b);return S.has(v)?S.delete(v):S.add(v),S})},x=()=>{c(new Set(p.map(v=>v.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:v=>d(v.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(Ae,{variant:"secondary",size:"sm",onClick:x,children:"Expand All"}),a.jsx(Ae,{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(Xr,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:[p.reduce((v,b)=>v+b.endpoints.length,0)," endpoints in ",p.length," categories"]}),a.jsx("div",{className:"space-y-3",children:p.map(({tag:v,endpoints:b})=>a.jsxs(St,{children:[a.jsx("button",{onClick:()=>m(v),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(v)?a.jsx(Kr,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(vs,{className:"w-5 h-5 text-bambu-gray"}),a.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:v.replace(/-/g," ")}),a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:b.length})]})}),l.has(v)&&a.jsx(Nt,{className:"pt-0 space-y-2",children:b.map(({path:S,method:N,spec:T})=>a.jsx(HKe,{path:S,method:N,spec:T,schema:e,apiKey:t},`${N}-${S}`))})]},v))})]})}const VKe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users","backup"];function GKe(){const t=sn(),e=Tc(),[n,r]=_R(),{t:i,i18n:s}=On(),{showToast:o}=Hn(),{authEnabled:l,user:c,refreshAuth:u}=Ci(),{mode:d,darkStyle:h,darkBackground:p,darkAccent:m,lightStyle:x,lightBackground:y,lightAccent:v,setDarkStyle:b,setDarkBackground:S,setDarkAccent:N,setLightStyle:T,setLightBackground:k,setLightAccent:C}=Fh(),[E,P]=_.useState(null),[A,D]=_.useState(!1),[I,L]=_.useState(null),[U,j]=_.useState(!1),[V,K]=_.useState(null),[z,X]=_.useState(null),[Y,te]=_.useState(!1),[$,W]=_.useState(VW()),ne=n.get("tab"),re=ne&&VKe.includes(ne)?ne:"general",[ge,me]=_.useState(re),ue=se=>{me(se),se==="general"?n.delete("tab"):n.set("tab",se),r(n,{replace:!0})},[Te,ie]=_.useState(!1),[Ce,Fe]=_.useState(""),[xe,Ze]=_.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[G,Q]=_.useState(null),[de,q]=_.useState(null),[ee,B]=_.useState(""),[he,ke]=_.useState(!1),[pe,H]=_.useState(!1),[O,J]=_.useState(null),[le,Se]=_.useState(!1),[we,ae]=_.useState(!1),[Le,Be]=_.useState(!1),[Ve,He]=_.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[be,Pe]=_.useState(!1),[Ie,_e]=_.useState(!1),[Ke,Me]=_.useState(!1),[it,Ee]=_.useState(null),[Xe,ze]=_.useState(null),[ce,$e]=_.useState(null),[ye,Je]=_.useState(!1),[at,jt]=_.useState({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]}),[Dt,yn]=_.useState(!1),[cn,rr]=_.useState(null),[Vn,Jn]=_.useState(null),[xn,sr]=_.useState({name:"",description:"",permissions:[]}),[Gn,Xn]=_.useState(new Set),[Nn,hi]=_.useState(null),[ai,je]=_.useState(!1),[tt,dt]=_.useState({}),[ht,ut]=_.useState({}),Et=se=>{W(se),Vfe(se),o(i("settings.toast.settingsSaved"),"success")},fe=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:Re,isLoading:Ge}=ct({queryKey:["settings"],queryFn:oe.getSettings}),{data:Ne,isLoading:Oe}=ct({queryKey:["smart-plugs"],queryFn:oe.getSmartPlugs}),{data:nt,isLoading:Ye}=ct({queryKey:["smart-plugs-energy",Ne?.map(se=>se.id)],queryFn:async()=>{if(!Ne||Ne.length===0)return null;const se=await Promise.all(Ne.filter(as=>as.enabled).map(async as=>{try{const ss=await oe.getSmartPlugStatus(as.id);return{plug:as,status:ss}}catch{return{plug:as,status:null}}}));let _t=0,Ln=0,er=0,Co=0,ed=0;for(const{plug:as,status:ss}of se){const Gx=as.plug_type==="mqtt"&&ss?.energy?.power!=null;(ss?.reachable||Gx)&&ss?.energy&&(ed++,ss.energy?.power!=null&&(_t+=ss.energy.power),ss.energy?.today!=null&&(Ln+=ss.energy.today),ss.energy?.yesterday!=null&&(er+=ss.energy.yesterday),ss.energy?.total!=null&&(Co+=ss.energy.total))}return{totalPower:_t,totalToday:Ln,totalYesterday:er,totalLifetime:Co,reachableCount:ed,totalPlugs:Ne.filter(as=>as.enabled).length}},enabled:ge==="plugs"&&!!Ne&&Ne.length>0,refetchInterval:ge==="plugs"?1e4:!1}),{data:Tt,isLoading:At}=ct({queryKey:["notification-providers"],queryFn:oe.getNotificationProviders}),{data:It,isLoading:Rt}=ct({queryKey:["api-keys"],queryFn:oe.getAPIKeys}),Mt=gt({mutationFn:se=>oe.createAPIKey(se),onSuccess:se=>{Q(se.key||null),ie(!1),Fe(""),t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyCreated"))},onError:se=>{o(`Failed to create API key: ${se.message}`,"error")}}),en=gt({mutationFn:se=>oe.deleteAPIKey(se),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyDeleted"))},onError:se=>{o(`Failed to delete API key: ${se.message}`,"error")}}),{data:Ht}=ct({queryKey:["printers"],queryFn:oe.getPrinters}),{data:hn,isLoading:un}=ct({queryKey:["notification-templates"],queryFn:oe.getNotificationTemplates}),{data:Mn}=ct({queryKey:["virtual-printer-settings"],queryFn:x1.getSettings,refetchInterval:1e4}),Gt=Mn?.status?.running??!1,{data:on}=ct({queryKey:["ffmpeg-status"],queryFn:oe.checkFfmpeg}),{data:dn}=ct({queryKey:["version"],queryFn:oe.getVersion}),{data:Yt,refetch:ir,isRefetching:Pn}=ct({queryKey:["updateCheck"],queryFn:oe.checkForUpdates,staleTime:300*1e3}),{data:si,refetch:ar}=ct({queryKey:["updateStatus"],queryFn:oe.getUpdateStatus,refetchInterval:se=>{const _t=se.state.data;return _t?.status==="downloading"||_t?.status==="installing"?1e3:!1}}),{data:dr}=ct({queryKey:["mqtt-status"],queryFn:oe.getMQTTStatus,refetchInterval:ge==="network"?5e3:!1}),{data:rt}=ct({queryKey:["github-backup-status"],queryFn:oe.getGitHubBackupStatus}),{data:Pt}=ct({queryKey:["cloud-status"],queryFn:oe.getCloudStatus}),{hasPermission:qt}=Ci(),{data:vt=[],isLoading:wn}=ct({queryKey:["users"],queryFn:()=>oe.getUsers(),enabled:l&&qt("users:read")}),{data:Fr=[],isLoading:Qr}=ct({queryKey:["groups"],queryFn:()=>oe.getGroups(),enabled:l&&qt("groups:read")}),{data:Br}=ct({queryKey:["permissions"],queryFn:()=>oe.getPermissions(),enabled:l&&qt("groups:read")}),Ys=gt({mutationFn:se=>oe.createUser(se),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),_e(!1),jt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userCreated"))},onError:se=>{o(se.message,"error")}}),nn=gt({mutationFn:({id:se,data:_t})=>oe.updateUser(se,_t),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),Me(!1),Ee(null),jt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userUpdated"))},onError:se=>{o(se.message,"error")}}),ln=gt({mutationFn:({id:se,deleteItems:_t})=>oe.deleteUser(se,_t),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),o(i("settings.toast.userDeleted")),ze(null),$e(null)},onError:se=>{o(se.message,"error")}}),Si=async se=>{ze(se),Je(!0);try{const _t=await oe.getUserItemsCount(se);$e(_t)}catch{$e({archives:0,queue_items:0,library_files:0})}finally{Je(!1)}},Es=gt({mutationFn:se=>oe.createGroup(se),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),yn(!1),da(),o(i("settings.toast.groupCreated"))},onError:se=>{o(se.message,"error")}}),Eo=gt({mutationFn:({id:se,data:_t})=>oe.updateGroup(se,_t),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),rr(null),da(),o(i("settings.toast.groupUpdated"))},onError:se=>{o(se.message,"error")}}),To=gt({mutationFn:se=>oe.deleteGroup(se),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),o(i("settings.toast.groupDeleted"))},onError:se=>{o(se.message,"error")}}),Ao=()=>{if(!at.username||!at.password){o(i("settings.toast.fillRequiredFields"),"error");return}if(at.password!==at.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(at.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}Ys.mutate({username:at.username,password:at.password,role:at.role,group_ids:at.group_ids.length>0?at.group_ids:void 0})},Ts=se=>{if(at.password){if(at.password!==at.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(at.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}}const _t={username:at.username||void 0,password:at.password||void 0,role:at.role,group_ids:at.group_ids};_t.password||delete _t.password,nn.mutate({id:se,data:_t})},Ni=se=>{Ee(se.id),jt({username:se.username,password:"",confirmPassword:"",role:se.role,group_ids:se.groups?.map(_t=>_t.id)||[]}),Me(!0)},Qs=se=>{jt(_t=>({..._t,group_ids:_t.group_ids.includes(se)?_t.group_ids.filter(Ln=>Ln!==se):[..._t.group_ids,se]}))},da=()=>{sr({name:"",description:"",permissions:[]}),Xn(new Set)},Hr=()=>{if(!xn.name.trim()){o(i("settings.toast.enterGroupName"),"error");return}Es.mutate({name:xn.name,description:xn.description||void 0,permissions:xn.permissions})},Bx=()=>{if(cn){if(!xn.name.trim()){o(i("settings.toast.enterGroupName"),"error");return}Eo.mutate({id:cn.id,data:{name:xn.name!==cn.name?xn.name:void 0,description:xn.description,permissions:xn.permissions}})}},Gh=se=>{rr(se),sr({name:se.name,description:se.description||"",permissions:se.permissions});const _t=new Set;Br?.categories.forEach(Ln=>{Ln.permissions.some(er=>se.permissions.includes(er.value))&&_t.add(Ln.name)}),Xn(_t)},Gl=se=>{Xn(_t=>{const Ln=new Set(_t);return Ln.has(se)?Ln.delete(se):Ln.add(se),Ln})},Hx=se=>{sr(_t=>{const Ln=_t.permissions.includes(se)?_t.permissions.filter(er=>er!==se):[..._t.permissions,se];return{..._t,permissions:Ln}})},Rm=(se,_t)=>{sr(Ln=>{const er=se.permissions.map(as=>as.value),Co=Ln.permissions.filter(as=>!er.includes(as)),ed=_t?[...Co,...er]:Co;return{...Ln,permissions:ed}})},Om=se=>se.permissions.every(_t=>xn.permissions.includes(_t.value)),qh=se=>{const _t=se.permissions.filter(Ln=>xn.permissions.includes(Ln.value));return _t.length>0&&_t.length<se.permissions.length},Zu=gt({mutationFn:oe.applyUpdate,onSuccess:se=>{se.is_docker?o(se.message,"error"):ar()}}),[Pc,ha]=_.useState(null),bl=gt({mutationFn:oe.testAllNotificationProviders,onSuccess:se=>{ha(se),t.invalidateQueries({queryKey:["notification-providers"]}),se.failed===0?o(`All ${se.tested} providers tested successfully!`,"success"):o(`${se.success}/${se.tested} providers succeeded`,se.failed>0?"error":"success")},onError:se=>{o(`Failed to test providers: ${se.message}`,"error")}}),ql=gt({mutationFn:async se=>{if(!Ne)return{success:0,failed:0};const _t=Ne.filter(er=>er.enabled),Ln=await Promise.all(_t.map(async er=>{try{return await oe.controlSmartPlug(er.id,se),{success:!0}}catch{return{success:!1}}}));return{success:Ln.filter(er=>er.success).length,failed:Ln.filter(er=>!er.success).length}},onSuccess:(se,_t)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),se.failed===0?o(`All ${se.success} plugs turned ${_t}`,"success"):o(`${se.success} plugs turned ${_t}, ${se.failed} failed`,"error")},onError:se=>{o(`Failed: ${se.message}`,"error")}}),yl=_.useRef(null),Lm=_.useRef(!1),Fm=_.useRef(!0);_.useEffect(()=>{if(Re&&!E){const se={...Re,external_url:Re.external_url||window.location.origin};P(se),setTimeout(()=>{Fm.current=!1},100)}},[Re,E]);const Im=gt({mutationFn:oe.updateSettings,onSuccess:se=>{t.setQueryData(["settings"],se),P(se),t.invalidateQueries({queryKey:["archiveStats"]}),o(i("settings.toast.settingsSaved"),"success")},onError:se=>{o(`Failed to save: ${se.message}`,"error")},onSettled:()=>{Lm.current=!1}}),Ju=gt({mutationFn:({id:se,data:_t})=>oe.updatePrinter(se,_t),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o(i("settings.toast.cameraSettingsSaved"),"success")},onError:se=>{o(`Failed to update printer: ${se.message}`,"error")}});_.useEffect(()=>{if(!(Fm.current||!E||!Re||!(Re.auto_archive!==E.auto_archive||Re.save_thumbnails!==E.save_thumbnails||Re.capture_finish_photo!==E.capture_finish_photo||Re.default_filament_cost!==E.default_filament_cost||Re.currency!==E.currency||Re.energy_cost_per_kwh!==E.energy_cost_per_kwh||Re.energy_tracking_mode!==E.energy_tracking_mode||Re.check_updates!==E.check_updates||(Re.check_printer_firmware??!0)!==(E.check_printer_firmware??!0)||Re.notification_language!==E.notification_language||Re.ams_humidity_good!==E.ams_humidity_good||Re.ams_humidity_fair!==E.ams_humidity_fair||Re.ams_temp_good!==E.ams_temp_good||Re.ams_temp_fair!==E.ams_temp_fair||Re.ams_history_retention_days!==E.ams_history_retention_days||Re.per_printer_mapping_expanded!==E.per_printer_mapping_expanded||Re.date_format!==E.date_format||Re.time_format!==E.time_format||Re.default_printer_id!==E.default_printer_id||Re.ftp_retry_enabled!==E.ftp_retry_enabled||Re.ftp_retry_count!==E.ftp_retry_count||Re.ftp_retry_delay!==E.ftp_retry_delay||Re.ftp_timeout!==E.ftp_timeout||Re.mqtt_enabled!==E.mqtt_enabled||Re.mqtt_broker!==E.mqtt_broker||Re.mqtt_port!==E.mqtt_port||Re.mqtt_username!==E.mqtt_username||Re.mqtt_password!==E.mqtt_password||Re.mqtt_topic_prefix!==E.mqtt_topic_prefix||Re.mqtt_use_tls!==E.mqtt_use_tls||Re.external_url!==E.external_url||Re.ha_enabled!==E.ha_enabled||Re.ha_url!==E.ha_url||Re.ha_token!==E.ha_token||(Re.library_archive_mode??"ask")!==(E.library_archive_mode??"ask")||Number(Re.library_disk_warning_gb??5)!==Number(E.library_disk_warning_gb??5)||(Re.camera_view_mode??"window")!==(E.camera_view_mode??"window")||Re.prometheus_enabled!==E.prometheus_enabled||Re.prometheus_token!==E.prometheus_token))&&!Lm.current)return yl.current&&clearTimeout(yl.current),yl.current=setTimeout(()=>{if(Lm.current)return;Lm.current=!0;const _t={auto_archive:E.auto_archive,save_thumbnails:E.save_thumbnails,capture_finish_photo:E.capture_finish_photo,default_filament_cost:E.default_filament_cost,currency:E.currency,energy_cost_per_kwh:E.energy_cost_per_kwh,energy_tracking_mode:E.energy_tracking_mode,check_updates:E.check_updates,check_printer_firmware:E.check_printer_firmware,notification_language:E.notification_language,ams_humidity_good:E.ams_humidity_good,ams_humidity_fair:E.ams_humidity_fair,ams_temp_good:E.ams_temp_good,ams_temp_fair:E.ams_temp_fair,ams_history_retention_days:E.ams_history_retention_days,per_printer_mapping_expanded:E.per_printer_mapping_expanded,date_format:E.date_format,time_format:E.time_format,default_printer_id:E.default_printer_id,ftp_retry_enabled:E.ftp_retry_enabled,ftp_retry_count:E.ftp_retry_count,ftp_retry_delay:E.ftp_retry_delay,ftp_timeout:E.ftp_timeout,mqtt_enabled:E.mqtt_enabled,mqtt_broker:E.mqtt_broker,mqtt_port:E.mqtt_port,mqtt_username:E.mqtt_username,mqtt_password:E.mqtt_password,mqtt_topic_prefix:E.mqtt_topic_prefix,mqtt_use_tls:E.mqtt_use_tls,external_url:E.external_url,ha_enabled:E.ha_enabled,ha_url:E.ha_url,ha_token:E.ha_token,library_archive_mode:E.library_archive_mode,library_disk_warning_gb:E.library_disk_warning_gb,camera_view_mode:E.camera_view_mode,prometheus_enabled:E.prometheus_enabled,prometheus_token:E.prometheus_token};Im.mutate(_t)},500),()=>{yl.current&&clearTimeout(yl.current)}},[E,Re,Im]);const fn=_.useCallback((se,_t)=>{P(Ln=>Ln?{...Ln,[se]:_t}:null)},[]),Mv=async(se,_t,Ln)=>{if(!_t){o(i("settings.toast.enterCameraUrl"),"error");return}ut(er=>({...er,[se]:!0})),dt(er=>({...er,[se]:null}));try{const er=await oe.testExternalCamera(se,_t,Ln);dt(Co=>({...Co,[se]:er})),er.success?o(i("settings.toast.cameraConnected",{resolution:er.resolution||""}),"success"):o(er.error||i("settings.toast.connectionFailed"),"error")}catch(er){const Co=er instanceof Error?er.message:i("settings.toast.testFailed");dt(ed=>({...ed,[se]:{success:!1,error:Co}})),o(Co,"error")}finally{ut(er=>({...er,[se]:!1}))}},[$x,kv]=_.useState({}),Vx=_.useRef({}),Um=_.useRef(new Set);_.useEffect(()=>{if(Ht){const se={};Ht.forEach(_t=>{_t.external_camera_url&&!Um.current.has(_t.id)&&(se[_t.id]=_t.external_camera_url,Um.current.add(_t.id))}),Object.keys(se).length>0&&kv(_t=>({..._t,...se}))}},[Ht]);const q2=(se,_t)=>{kv(Ln=>({...Ln,[se]:_t})),Vx.current[se]&&clearTimeout(Vx.current[se]),Vx.current[se]=setTimeout(()=>{Ju.mutate({id:se,data:{external_camera_url:_t||null}})},800)},Ev=(se,_t)=>{const Ln={};_t.type!==void 0&&(Ln.external_camera_type=_t.type||null),_t.enabled!==void 0&&(Ln.external_camera_enabled=_t.enabled),Ju.mutate({id:se,data:Ln})};return Ge||!E?a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(pt,{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:i("settings.title")}),a.jsx("p",{className:"text-bambu-gray",children:i("settings.configureBambuddy")})]}),a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary overflow-x-auto",children:[a.jsx("button",{onClick:()=>ue("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${ge==="general"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:i("settings.tabs.general")}),a.jsxs("button",{onClick:()=>ue("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ge==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(al,{className:"w-4 h-4"}),i("settings.tabs.smartPlugs"),Ne&&Ne.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ne.length})]}),a.jsxs("button",{onClick:()=>ue("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ge==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Sg,{className:"w-4 h-4"}),i("settings.tabs.notifications"),Tt&&Tt.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Tt.length})]}),a.jsxs("button",{onClick:()=>ue("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ge==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Mue,{className:"w-4 h-4"}),i("settings.tabs.filament")]}),a.jsxs("button",{onClick:()=>ue("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ge==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Mg,{className:"w-4 h-4"}),i("settings.tabs.network"),a.jsx("span",{className:`w-2 h-2 rounded-full ${dr?.enabled?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>ue("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ge==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Ko,{className:"w-4 h-4"}),i("settings.tabs.apiKeys"),It&&It.length>0&&a.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:It.length})]}),a.jsxs("button",{onClick:()=>ue("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ge==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Ur,{className:"w-4 h-4"}),i("settings.tabs.virtualPrinter"),a.jsx("span",{className:`w-2 h-2 rounded-full ${Gt?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>ue("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ge==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(pg,{className:"w-4 h-4"}),i("settings.tabs.users"),l&&a.jsx("span",{className:`w-2 h-2 rounded-full ${l?"bg-green-400":"bg-gray-500"}`})]}),a.jsxs("button",{onClick:()=>ue("backup"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${ge==="backup"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[a.jsx(Eu,{className:"w-4 h-4"}),i("settings.tabs.backup"),a.jsx("span",{className:`w-2 h-2 rounded-full ${Pt?.is_authenticated&&rt?.configured&&rt?.enabled?"bg-green-400":"bg-gray-500"}`})]})]}),ge==="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(St,{children:[a.jsx(Kn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[a.jsx(oh,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),a.jsxs("div",{className:"relative",children:[a.jsx("select",{value:s.language,onChange:se=>{s.changeLanguage(se.target.value),o(i("settings.toast.settingsSaved"),"success")},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:xz.map(se=>a.jsxs("option",{value:se.code,children:[se.nativeName," (",se.name,")"]},se.code))}),a.jsx(Kr,{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:$,onChange:se=>Et(se.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:X0.map(se=>a.jsx("option",{value:se.to,children:i(se.labelKey)},se.id))}),a.jsx(Kr,{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:E.date_format||"system",onChange:se=>fn("date_format",se.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:i("settings.systemDefault")}),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(Kr,{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:E.time_format||"system",onChange:se=>fn("time_format",se.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:i("settings.systemDefault")}),a.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),a.jsx("option",{value:"24h",children:"24-hour (15:30)"})]}),a.jsx(Kr,{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:E.default_printer_id??"",onChange:se=>fn("default_printer_id",se.target.value?Number(se.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:i("settings.noDefaultPrinter")}),Ht?.map(se=>a.jsx("option",{value:se.id,children:se.name},se.id))]}),a.jsx(Kr,{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:i("settings.sidebarOrder")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:fe,children:[a.jsx(Lh,{className:"w-4 h-4"}),"Reset"]})]})]})]}),a.jsxs(St,{children:[a.jsx(Kn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(PW,{className:"w-5 h-5"}),"Appearance"]})}),a.jsxs(Nt,{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:p,onChange:se=>{S(se.target.value),o(i("settings.toast.settingsSaved"),"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:m,onChange:se=>{N(se.target.value),o(i("settings.toast.settingsSaved"),"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:h,onChange:se=>{b(se.target.value),o(i("settings.toast.settingsSaved"),"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:se=>{k(se.target.value),o(i("settings.toast.settingsSaved"),"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:v,onChange:se=>{C(se.target.value),o(i("settings.toast.settingsSaved"),"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:se=>{T(se.target.value),o(i("settings.toast.settingsSaved"),"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(St,{children:[a.jsx(Kn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.archiveSettings")})}),a.jsxs(Nt,{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:E.auto_archive,onChange:se=>fn("auto_archive",se.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:i("settings.saveThumbnails")}),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:E.save_thumbnails,onChange:se=>fn("save_thumbnails",se.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:i("settings.captureFinishPhoto")}),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:E.capture_finish_photo,onChange:se=>fn("capture_finish_photo",se.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"})]})]}),E.capture_finish_photo&&on&&!on.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(Sn,{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(St,{children:[a.jsx(Kn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(LR,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),a.jsxs(Nt,{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:E.camera_view_mode??"window",onChange:se=>fn("camera_view_mode",se.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"window",children:i("settings.newWindow")}),a.jsx("option",{value:"embedded",children:i("settings.embeddedOverlay")})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:E.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:i("settings.externalCameras")}),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."}),Ht&&Ht.length>0?a.jsx("div",{className:"space-y-3",children:Ht.map(se=>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:se.name}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:se.external_camera_enabled,onChange:_t=>Ev(se.id,{enabled:_t.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"})]})]}),se.external_camera_enabled&&a.jsxs("div",{className:"space-y-2 mt-2",children:[a.jsx("input",{type:"text",placeholder:se.external_camera_type==="usb"?"Device path (/dev/video0)":"Camera URL (rtsp://... or http://...)",value:$x[se.id]??se.external_camera_url??"",onChange:_t=>q2(se.id,_t.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:se.external_camera_type||"mjpeg",onChange:_t=>Ev(se.id,{type:_t.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(Ae,{size:"sm",variant:"secondary",onClick:()=>Mv(se.id,$x[se.id]??se.external_camera_url??"",se.external_camera_type||"mjpeg"),disabled:ht[se.id]||!($x[se.id]??se.external_camera_url),children:ht[se.id]?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):"Test"})]}),tt[se.id]&&a.jsx("div",{className:`text-xs flex items-center gap-1 ${tt[se.id]?.success?"text-green-500":"text-red-500"}`,children:tt[se.id]?.success?a.jsxs(a.Fragment,{children:[a.jsx(Ar,{className:"w-3 h-3"}),"Connected",tt[se.id]?.resolution&&` (${tt[se.id]?.resolution})`]}):a.jsxs(a.Fragment,{children:[a.jsx(Ji,{className:"w-3 h-3"}),tt[se.id]?.error||i("settings.toast.connectionFailed")]})})]})]},se.id))}):a.jsx("p",{className:"text-xs text-bambu-gray italic",children:i("settings.noPrintersConfigured")})]})]})]}),a.jsxs(St,{children:[a.jsx(Kn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.costTracking")})}),a.jsxs(Nt,{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:E.default_filament_cost,onChange:se=>fn("default_filament_cost",parseFloat(se.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:E.currency,onChange:se=>fn("currency",se.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[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:E.energy_cost_per_kwh,onChange:se=>fn("energy_cost_per_kwh",parseFloat(se.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:E.energy_tracking_mode||"total",onChange:se=>fn("energy_tracking_mode",se.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"print",children:i("settings.printsOnly")}),a.jsx("option",{value:"total",children:i("settings.totalConsumption")})]}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:E.energy_tracking_mode==="print"?"Dashboard shows sum of energy used during prints":"Dashboard shows lifetime energy from smart plugs"})]})]})]}),a.jsxs(St,{children:[a.jsx(Kn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(fs,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),a.jsxs(Nt,{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:E.library_archive_mode??"ask",onChange:se=>fn("library_archive_mode",se.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"always",children:i("settings.archiveMode.always")}),a.jsx("option",{value:"never",children:i("settings.archiveMode.never")}),a.jsx("option",{value:"ask",children:i("settings.archiveMode.ask")})]}),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:E.library_disk_warning_gb??5,onChange:se=>fn("library_disk_warning_gb",parseFloat(se.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(LKe,{}),a.jsxs(St,{children:[a.jsx(Kn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),a.jsxs(Nt,{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:i("settings.checkForUpdatesLabel")}),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:E.check_updates,onChange:se=>fn("check_updates",se.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:i("settings.checkPrinterFirmware")}),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:E.check_printer_firmware??!0,onChange:se=>fn("check_printer_firmware",se.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:i("settings.currentVersion")}),a.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",dn?.version||"..."]})]}),a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:()=>ir(),disabled:Pn,children:[Pn?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(Dr,{className:"w-4 h-4"}),"Check now"]})]}),Yt?.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",Yt.latest_version]}),Yt.release_name&&Yt.release_name!==Yt.latest_version&&a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:Yt.release_name})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[Yt.release_notes&&a.jsx("button",{onClick:()=>Se(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),Yt.release_url&&a.jsx("a",{href:Yt.release_url,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-white transition-colors",title:i("settings.viewReleaseOnGitHub"),children:a.jsx(Xr,{className:"w-4 h-4"})})]})]}),si?.status==="downloading"||si?.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(pt,{className:"w-4 h-4 animate-spin"}),a.jsx("span",{children:si.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:`${si.progress}%`}})})]}):si?.status==="complete"?a.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:si.message}):si?.status==="error"?a.jsx("div",{className:"mt-3 p-2 bg-red-500/20 rounded text-sm text-red-400",children:si.error||si.message}):Yt?.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(Ae,{className:"mt-3",onClick:()=>Zu.mutate(),disabled:Zu.isPending,children:[Zu.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(wi,{className:"w-4 h-4"}),"Install Update"]})]}):Yt?.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: ",Yt.error]}):Yt&&!Yt.update_available?a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),a.jsxs(St,{children:[a.jsx(Kn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.dataManagement")})}),a.jsxs(Nt,{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:i("settings.clearNotificationLogs")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.clearNotificationLogsDescription")})]}),a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:()=>ke(!0),children:[a.jsx(an,{className:"w-4 h-4"}),i("common.clear")]})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-white",children:i("settings.resetUiPreferences")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.resetUiPreferencesDescription")})]}),a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:()=>H(!0),children:[a.jsx(an,{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(Ae,{variant:"secondary",size:"sm",onClick:()=>ue("backup"),children:[a.jsx(Eu,{className:"w-4 h-4"}),"Go to Backup"]})]})]})]})]})]}),ge==="network"&&E&&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(St,{children:[a.jsx(Kn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(oh,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),a.jsxs(Nt,{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:E.external_url??"",onChange:se=>fn("external_url",se.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(St,{children:[a.jsx(Kn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(Dr,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),a.jsxs(Nt,{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:i("settings.enableRetry")}),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:E.ftp_retry_enabled??!0,onChange:se=>fn("ftp_retry_enabled",se.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"})]})]}),E.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:E.ftp_retry_count??3,onChange:se=>fn("ftp_retry_count",Math.min(10,Math.max(1,parseInt(se.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:E.ftp_retry_delay??2,onChange:se=>fn("ftp_retry_delay",Math.min(30,Math.max(1,parseInt(se.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:E.ftp_timeout??30,onChange:se=>fn("ftp_timeout",Math.min(120,Math.max(10,parseInt(se.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(St,{children:[a.jsx(Kn,{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(Iy,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),E.ha_enabled&&Nn&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Nn.success?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:`text-sm ${Nn.success?"text-green-400":"text-red-400"}`,children:Nn.success?"Connected":"Disconnected"})]})]})}),a.jsxs(Nt,{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:i("settings.enableHomeAssistant")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.homeAssistantDescription")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.ha_enabled??!1,onChange:se=>fn("ha_enabled",se.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"})]})]}),E.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:E.ha_url??"",onChange:se=>fn("ha_url",se.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:E.ha_token??"",onChange:se=>fn("ha_token",se.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"})]}),E.ha_url&&E.ha_token&&a.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:a.jsxs(Ae,{variant:"secondary",size:"sm",disabled:ai,onClick:async()=>{je(!0),hi(null);try{const se=await oe.testHAConnection(E.ha_url,E.ha_token);hi(se)}catch(se){hi({success:!1,message:null,error:se instanceof Error?se.message:i("common.unknownError")})}finally{je(!1)}},children:[ai?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(Mg,{className:"w-4 h-4"}),i("settings.testConnection")]})})]})]})]}),a.jsxs(St,{children:[a.jsx(Kn,{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(Mg,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),dr?.enabled&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${dr.connected?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:`text-sm ${dr.connected?"text-green-400":"text-red-400"}`,children:dr.connected?"Connected":"Disconnected"})]})]})}),a.jsxs(Nt,{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:i("settings.enableMqtt")}),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:E.mqtt_enabled??!1,onChange:se=>fn("mqtt_enabled",se.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"})]})]}),E.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:E.mqtt_broker??"",onChange:se=>fn("mqtt_broker",se.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:E.mqtt_port??1883,onChange:se=>fn("mqtt_port",Math.min(65535,Math.max(1,parseInt(se.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:E.mqtt_use_tls??!1,onChange:se=>{const _t=se.target.checked;fn("mqtt_use_tls",_t);const Ln=E.mqtt_port??1883;_t&&Ln===1883?fn("mqtt_port",8883):!_t&&Ln===8883&&fn("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:i("settings.useTls")})]})]}),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:E.mqtt_username??"",onChange:se=>fn("mqtt_username",se.target.value),placeholder:i("settings.leaveEmptyForAnonymous"),className:"w-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:E.mqtt_password??"",onChange:se=>fn("mqtt_password",se.target.value),placeholder:i("settings.leaveEmptyForAnonymous"),className:"w-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:E.mqtt_topic_prefix??"bambuddy",onChange:se=>fn("mqtt_topic_prefix",se.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: ",E.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),dr&&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 ${dr.connected?"bg-green-400":"bg-red-400"}`}),a.jsx("span",{className:"text-bambu-gray",children:dr.connected?a.jsxs(a.Fragment,{children:[i("settings.mqttConnectedTo")," ",a.jsxs("span",{className:"text-white",children:[dr.broker,":",dr.port]})]}):i("settings.spoolmanDisconnected")})]})})]})]})]})]}),a.jsx("div",{className:"flex-1 lg:max-w-md space-y-4",children:a.jsxs(St,{children:[a.jsx(Kn,{children:a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(vP,{className:"w-5 h-5 text-orange-400"}),"Prometheus Metrics"]})}),a.jsxs(Nt,{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:i("settings.enableMetricsEndpoint")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.prometheusDescription")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.prometheus_enabled??!1,onChange:se=>fn("prometheus_enabled",se.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"})]})]}),E.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:E.prometheus_token??"",onChange:se=>fn("prometheus_token",se.target.value),placeholder:i("settings.leaveEmptyForNoAuth"),className:"w-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:i("settings.availableMetrics")}),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)"})]})]})]})]})]})})]}),Nn&&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:[Nn.success?a.jsx(Ar,{className:"w-8 h-8 text-green-400"}):a.jsx(Ji,{className:"w-8 h-8 text-red-400"}),a.jsx("h3",{className:"text-lg font-medium text-white",children:Nn.success?"Connection Successful":"Connection Failed"})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:Nn.success?Nn.message||"Successfully connected to Home Assistant.":Nn.error||"Failed to connect to Home Assistant."}),a.jsx("div",{className:"flex justify-end",children:a.jsx(Ae,{variant:"primary",onClick:()=>hi(null),children:"OK"})})]})}),ge==="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(al,{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:[Ne&&Ne.filter(se=>se.enabled).length>1&&a.jsxs(a.Fragment,{children:[a.jsxs(Ae,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>J("on"),disabled:ql.isPending,title:i("settings.turnAllPlugsOn"),children:[ql.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(qu,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),a.jsxs(Ae,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>J("off"),disabled:ql.isPending,title:i("settings.turnAllPlugsOff"),children:[ql.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(xM,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),a.jsxs(Ae,{className:"whitespace-nowrap",onClick:()=>{L(null),D(!0)},children:[a.jsx(fr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),Ne&&Ne.length>0&&a.jsxs(St,{className:"mb-6",children:[a.jsx(Kn,{children:a.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[a.jsx(_h,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",Ye&&a.jsx(pt,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),a.jsx(Nt,{children:nt?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(_h,{className:"w-3 h-3"}),"Current Power"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[nt.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:[nt.reachableCount,"/",nt.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(ti,{className:"w-3 h-3"}),"Today"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[nt.totalToday.toFixed(2),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),E&&E.energy_cost_per_kwh>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(nt.totalToday*E.energy_cost_per_kwh).toFixed(2)," ",E.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(vP,{className:"w-3 h-3"}),"Yesterday"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[nt.totalYesterday.toFixed(2),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),E&&E.energy_cost_per_kwh>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(nt.totalYesterday*E.energy_cost_per_kwh).toFixed(2)," ",E.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(fP,{className:"w-3 h-3"}),"Total"]}),a.jsxs("div",{className:"text-xl font-bold text-white",children:[nt.totalLifetime.toFixed(1),a.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),E&&E.energy_cost_per_kwh>0&&a.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(nt.totalLifetime*E.energy_cost_per_kwh).toFixed(2)," ",E.currency]})]})]}):Ye?null:a.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),Oe?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Ne&&Ne.length>0?a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Ne.map(se=>a.jsx(NKe,{plug:se,onEdit:_t=>{L(_t),D(!0)}},se.id))}):a.jsx(St,{children:a.jsx(Nt,{className:"py-12",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(al,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:i("settings.noSmartPlugsTitle")}),a.jsx("p",{className:"text-sm mb-4",children:i("settings.noSmartPlugsDescription")}),a.jsxs(Ae,{onClick:()=>{L(null),D(!0)},children:[a.jsx(fr,{className:"w-4 h-4"}),i("settings.addFirstSmartPlug")]})]})})})]}),ge==="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(Sg,{className:"w-5 h-5 text-bambu-green"}),i("settings.providers")]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs(Ae,{size:"sm",variant:"secondary",onClick:()=>te(!0),children:[a.jsx(W0,{className:"w-4 h-4"}),i("settings.log")]}),Tt&&Tt.length>0&&a.jsxs(Ae,{size:"sm",variant:"secondary",onClick:()=>{ha(null),bl.mutate()},disabled:bl.isPending,children:[bl.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(DR,{className:"w-4 h-4"}),i("settings.testAll")]}),a.jsxs(Ae,{size:"sm",onClick:()=>{K(null),j(!0)},children:[a.jsx(fr,{className:"w-4 h-4"}),"Add"]})]})]}),a.jsx(St,{className:"mb-4",children:a.jsx(Nt,{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:E.notification_language||"en",onChange:se=>fn("notification_language",se.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:xz.map(se=>a.jsx("option",{value:se.code,children:se.nativeName},se.code))})]})})}),Pc&&a.jsx(St,{className:"mb-4",children:a.jsxs(Nt,{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:i("settings.testResults")}),a.jsx("button",{onClick:()=>ha(null),className:"text-bambu-gray hover:text-white text-xs",children:i("common.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(Ar,{className:"w-4 h-4"}),i("settings.testPassedCount",{count:Pc.success})]}),Pc.failed>0&&a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(Ji,{className:"w-4 h-4"}),i("settings.testFailedCount",{count:Pc.failed})]})]}),Pc.results.filter(se=>!se.success).length>0&&a.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Pc.results.filter(se=>!se.success).map(se=>a.jsxs("div",{className:"text-xs text-red-400",children:[a.jsxs("span",{className:"font-medium",children:[se.provider_name,":"]})," ",se.message]},se.provider_id))})]})}),At?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Tt&&Tt.length>0?a.jsx("div",{className:"space-y-3",children:Tt.map(se=>a.jsx(EKe,{provider:se,onEdit:_t=>{K(_t),j(!0)}},se.id))}):a.jsx(St,{children:a.jsx(Nt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(Sg,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm font-medium text-white mb-2",children:i("settings.noProvidersTitle")}),a.jsx("p",{className:"text-xs mb-3",children:i("settings.noProvidersDescription")}),a.jsxs(Ae,{size:"sm",onClick:()=>{K(null),j(!0)},children:[a.jsx(fr,{className:"w-4 h-4"}),i("settings.addProvider")]})]})})})]}),a.jsxs("div",{children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[a.jsx(fs,{className:"w-5 h-5 text-bambu-green"}),i("settings.messageTemplates")]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:i("settings.messageTemplatesDescription")}),un?a.jsx("div",{className:"flex justify-center py-8",children:a.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):hn&&hn.length>0?a.jsx("div",{className:"space-y-2",children:hn.map(se=>a.jsx(St,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>X(se),children:a.jsx(Nt,{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:se.name}),a.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:se.title_template})]}),a.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:_t=>{_t.stopPropagation(),X(se)},children:a.jsx(mg,{className:"w-4 h-4 text-bambu-gray"})})]})})},se.id))}):a.jsx(St,{children:a.jsx(Nt,{className:"py-8",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(fs,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),a.jsx("p",{className:"text-sm",children:i("settings.noTemplatesAvailable")})]})})})]})]}),ge==="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(Ko,{className:"w-5 h-5 text-bambu-green"}),i("settings.apiKeys")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.apiKeysDescription")})]}),a.jsxs(Ae,{size:"sm",onClick:()=>ie(!0),className:"flex-shrink-0",children:[a.jsx(fr,{className:"w-4 h-4"}),i("settings.createKey")]})]}),G&&a.jsx(St,{className:"mb-6 border-bambu-green",children:a.jsx(Nt,{className:"py-4",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx(Ar,{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:i("settings.apiKeyCreated")}),a.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:i("settings.apiKeyCopyWarning")}),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:G}),a.jsx(Ae,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(G);else{const se=document.createElement("textarea");se.value=G,se.style.position="fixed",se.style.left="-999999px",document.body.appendChild(se),se.select(),document.execCommand("copy"),document.body.removeChild(se)}o(i("settings.toast.keyCopied"))}catch{o(i("settings.toast.copyFailed"),"error")}},children:a.jsx(Ul,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex gap-2 mt-3",children:[a.jsx(Ae,{variant:"secondary",size:"sm",onClick:()=>{B(G),o(i("settings.toast.keyAddedToBrowser"))},children:i("settings.useInApiBrowser")}),a.jsx(Ae,{variant:"secondary",size:"sm",onClick:()=>Q(null),children:i("common.dismiss")})]})]})]})})}),Te&&a.jsxs(St,{className:"mb-6",children:[a.jsx(Kn,{children:a.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.createNewApiKey")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.keyName")}),a.jsx("input",{type:"text",value:Ce,onChange:se=>Fe(se.target.value),placeholder:i("settings.keyNamePlaceholder"),className:"w-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:i("common.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:xe.can_read_status,onChange:se=>Ze(_t=>({..._t,can_read_status:se.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:i("settings.readStatus")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.readStatusDescription")})]})]}),a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:xe.can_queue,onChange:se=>Ze(_t=>({..._t,can_queue:se.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:i("settings.manageQueue")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.manageQueueDescription")})]})]}),a.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:xe.can_control_printer,onChange:se=>Ze(_t=>({..._t,can_control_printer:se.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:i("settings.controlPrinter")}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.controlPrinterDescription")})]})]})]})]}),a.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[a.jsxs(Ae,{onClick:()=>Mt.mutate({name:Ce||i("settings.unnamedKey"),...xe}),disabled:Mt.isPending,children:[Mt.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(fr,{className:"w-4 h-4"}),i("settings.createKey")]}),a.jsx(Ae,{variant:"secondary",onClick:()=>ie(!1),children:i("common.cancel")})]})]})]}),Rt?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):It&&It.length>0?a.jsx("div",{className:"space-y-3",children:It.map(se=>a.jsx(St,{children:a.jsx(Nt,{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(Ko,{className:`w-5 h-5 ${se.enabled?"text-bambu-green":"text-bambu-gray"}`}),a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium",children:se.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[se.key_prefix,"••••••••",se.last_used&&` · ${i("settings.lastUsed")}: ${$g(se.last_used)}`]})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("div",{className:"flex gap-1 text-xs",children:[se.can_read_status&&a.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:i("settings.read")}),se.can_queue&&a.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:i("queue.title")}),se.can_control_printer&&a.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:i("settings.control")})]}),a.jsx(Ae,{variant:"secondary",size:"sm",onClick:()=>q(se.id),children:a.jsx(an,{className:"w-4 h-4 text-red-400"})})]})]})})},se.id))}):a.jsx(St,{children:a.jsx(Nt,{className:"py-12",children:a.jsxs("div",{className:"text-center text-bambu-gray",children:[a.jsx(Ko,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),a.jsx("p",{className:"text-lg font-medium text-white mb-2",children:i("settings.apiKeysEmptyTitle")}),a.jsx("p",{className:"text-sm mb-4",children:i("settings.apiKeysEmptyDescription")}),a.jsxs(Ae,{onClick:()=>ie(!0),children:[a.jsx(fr,{className:"w-4 h-4"}),i("settings.createFirstKey")]})]})})}),a.jsxs(St,{className:"mt-6",children:[a.jsx(Kn,{children:a.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.webhookEndpoints")})}),a.jsxs(Nt,{className:"space-y-3 text-sm",children:[a.jsx("p",{className:"text-bambu-gray",children:i("settings.webhookApiKeyHint")}),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.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.getAllStatus")]})]}),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.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.getSpecificStatus")]})]}),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.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.addToQueue")]})]}),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.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.pausePrint")]})]}),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.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.resumePrint")]})]}),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.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.stopPrint")]})]})]})]})]})]}),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(oh,{className:"w-5 h-5 text-bambu-green"}),i("settings.apiBrowser")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.apiBrowserDescription")})]}),a.jsx(St,{className:"mb-4",children:a.jsxs(Nt,{className:"py-3",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:i("settings.apiKeyForTesting")}),a.jsx("input",{type:"text",value:ee,onChange:se=>B(se.target.value),placeholder:i("settings.apiKeyPlaceholder"),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.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:i("settings.apiKeyHint")})]})}),a.jsx($Ke,{apiKey:ee})]})]}),ge==="virtual-printer"&&a.jsx(FKe,{}),ge==="filament"&&E&&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(St,{children:[a.jsx(Kn,{children:a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.amsDisplayThresholds")})}),a.jsxs(Nt,{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.amsThresholdsDescription")}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-white",children:[a.jsx(CR,{className:"w-4 h-4 text-blue-400"}),a.jsx("span",{className:"font-medium",children:i("settings.humidity")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.goodGreen")," ≤"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0",max:"100",value:E.ams_humidity_good??40,onChange:se=>fn("ams_humidity_good",parseInt(se.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.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.fairOrange")," ≤"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"0",max:"100",value:E.ams_humidity_fair??60,onChange:se=>fn("ams_humidity_fair",parseInt(se.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:i("settings.aboveFairBad")})]}),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(yM,{className:"w-4 h-4 text-orange-400"}),a.jsx("span",{className:"font-medium",children:i("settings.temperature")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.goodBlue")," ≤"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:E.ams_temp_good??28,onChange:se=>fn("ams_temp_good",parseFloat(se.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.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.fairOrange")," ≤"]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:E.ams_temp_fair??35,onChange:se=>fn("ams_temp_fair",parseFloat(se.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:i("settings.aboveFairHot")})]}),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(Eu,{className:"w-4 h-4 text-purple-400"}),a.jsx("span",{className:"font-medium",children:i("settings.historyRetention")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.keepSensorHistory")}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",min:"1",max:"365",value:E.ams_history_retention_days??30,onChange:se=>fn("ams_history_retention_days",parseInt(se.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:i("common.days")})]})]}),a.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.historyRetentionDescription")})]}),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(Ur,{className:"w-4 h-4 text-bambu-green"}),a.jsx("span",{className:"font-medium",children:i("settings.printModal")})]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-white",children:i("settings.expandCustomMapping")}),a.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:i("settings.expandCustomMappingDescription")})]}),a.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.per_printer_mapping_expanded??!1,onChange:se=>fn("per_printer_mapping_expanded",se.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(RKe,{})})]}),de!==null&&a.jsx(Zn,{title:i("settings.deleteApiKeyTitle"),message:i("settings.deleteApiKeyMessage"),confirmText:i("settings.deleteKey"),variant:"danger",onConfirm:()=>{en.mutate(de),q(null)},onCancel:()=>q(null)}),A&&a.jsx(MKe,{plug:I,onClose:()=>{D(!1),L(null)}}),U&&a.jsx(TKe,{provider:V,onClose:()=>{j(!1),K(null)}}),z&&a.jsx(AKe,{template:z,onClose:()=>X(null)}),Y&&a.jsx(PKe,{onClose:()=>te(!1)}),he&&a.jsx(Zn,{title:i("settings.clearNotificationLogs"),message:i("settings.clearLogsMessage"),confirmText:i("settings.clearLogs"),variant:"warning",onConfirm:async()=>{ke(!1);try{const se=await oe.clearNotificationLogs(30);o(se.message,"success")}catch{o(i("settings.toast.clearLogsFailed"),"error")}},onCancel:()=>ke(!1)}),pe&&a.jsx(Zn,{title:i("settings.resetUiPreferences"),message:i("settings.resetUiPreferencesMessage"),confirmText:i("settings.resetPreferences"),variant:"default",onConfirm:()=>{H(!1),localStorage.clear(),o(i("settings.toast.uiPreferencesReset"),"success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>H(!1)}),O&&a.jsx(Zn,{title:`Turn All Plugs ${O==="on"?"On":"Off"}`,message:`This will turn ${O==="on"?"ON":"OFF"} all ${Ne?.filter(se=>se.enabled).length||0} enabled smart plugs. ${O==="off"?"Any running printers may be affected!":""}`,confirmText:`Turn All ${O==="on"?"On":"Off"}`,variant:O==="off"?"danger":"warning",onConfirm:()=>{const se=O;J(null),ql.mutate(se)},onCancel:()=>J(null)}),le&&Yt?.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(St,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:se=>se.stopPropagation(),children:[a.jsxs(Kn,{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",Yt.latest_version]}),Yt.release_name&&Yt.release_name!==Yt.latest_version&&a.jsx("p",{className:"text-sm text-bambu-gray",children:Yt.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(Lt,{className:"w-5 h-5"})})]}),a.jsx(Nt,{className:"overflow-y-auto flex-1",children:a.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:Yt.release_notes})}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[Yt.release_url&&a.jsx("a",{href:Yt.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:a.jsxs(Ae,{variant:"secondary",className:"w-full",children:[a.jsx(Xr,{className:"w-4 h-4"}),"View on GitHub"]})}),a.jsx(Ae,{onClick:()=>Se(!1),className:"flex-1",children:"Close"})]})]})}),ge==="users"&&a.jsxs("div",{className:"space-y-6",children:[a.jsx(St,{children:a.jsx(Nt,{className:"py-4",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${l?"bg-green-500/20":"bg-gray-500/20"}`,children:l?a.jsx(rT,{className:"w-5 h-5 text-green-400"}):a.jsx(nT,{className:"w-5 h-5 text-gray-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-white font-medium",children:i("settings.authentication")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:i(l?"settings.authEnabledDescription":"settings.authDisabledDescription")})]})]}),l?c?.is_admin&&a.jsxs(Ae,{variant:"secondary",onClick:()=>ae(!0),children:[a.jsx(nT,{className:"w-4 h-4"}),i("common.disable")]}):a.jsxs(Ae,{onClick:()=>e("/setup"),children:[a.jsx(rT,{className:"w-4 h-4"}),i("common.enable")]})]})})}),l&&a.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-6",children:[a.jsxs("div",{className:"space-y-6",children:[c&&a.jsxs(St,{children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(pg,{className:"w-5 h-5 text-bambu-green"}),i("settings.currentUser")]}),a.jsxs(Ae,{size:"sm",variant:"ghost",onClick:()=>Be(!0),children:[a.jsx(Ko,{className:"w-4 h-4"}),i("settings.changePassword")]})]})}),a.jsx(Nt,{children:a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("p",{className:"text-white font-medium text-lg",children:c.username}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[c.is_admin&&a.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300",children:i("settings.admin")}),c.groups?.map(se=>a.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${se.name==="Administrators"?"bg-purple-500/20 text-purple-300":se.name==="Operators"?"bg-blue-500/20 text-blue-300":se.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:se.name},se.id))]})]})})})]}),a.jsxs(St,{children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(pg,{className:"w-5 h-5 text-bambu-green"}),i("settings.users")]}),qt("users:create")&&a.jsxs(Ae,{size:"sm",onClick:()=>{_e(!0),jt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:[a.jsx(fr,{className:"w-4 h-4"}),i("settings.addUser")]})]})}),a.jsx(Nt,{children:wn?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):vt.length===0?a.jsx("p",{className:"text-center text-bambu-gray py-8",children:i("settings.noUsersFound")}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:vt.map(se=>a.jsxs("div",{className:"py-3 flex items-center justify-between",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-white font-medium truncate",children:se.username}),a.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[se.is_admin&&a.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-purple-500/20 text-purple-300",children:i("settings.admin")}),se.groups?.map(_t=>a.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${_t.name==="Administrators"?"bg-purple-500/20 text-purple-300":_t.name==="Operators"?"bg-blue-500/20 text-blue-300":_t.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:_t.name},_t.id))]})]}),a.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[qt("users:update")&&a.jsx(Ae,{size:"sm",variant:"ghost",onClick:()=>Ni(se),children:a.jsx(mg,{className:"w-4 h-4"})}),qt("users:delete")&&se.id!==c?.id&&a.jsx(Ae,{size:"sm",variant:"ghost",onClick:()=>Si(se.id),children:a.jsx(an,{className:"w-4 h-4"})})]})]},se.id))})})]})]}),a.jsx("div",{children:a.jsxs(St,{children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[a.jsx(iT,{className:"w-5 h-5 text-bambu-green"}),i("settings.groups")]}),qt("groups:create")&&a.jsxs(Ae,{size:"sm",onClick:()=>{yn(!0),da()},children:[a.jsx(fr,{className:"w-4 h-4"}),i("settings.addGroup")]})]})}),a.jsx(Nt,{children:Qr?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(pt,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Fr.length===0?a.jsx("p",{className:"text-center text-bambu-gray py-8",children:i("settings.noGroupsFound")}):a.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:Fr.map(se=>a.jsxs("div",{className:"py-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(iT,{className:`w-4 h-4 ${se.name==="Administrators"?"text-purple-400":se.name==="Operators"?"text-blue-400":se.name==="Viewers"?"text-green-400":"text-bambu-gray"}`}),a.jsx("span",{className:"text-white font-medium",children:se.name}),se.is_system&&a.jsx("span",{className:"px-2 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:i("settings.system")})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[qt("groups:update")&&a.jsx(Ae,{size:"sm",variant:"ghost",onClick:()=>Gh(se),children:a.jsx(mg,{className:"w-4 h-4"})}),qt("groups:delete")&&!se.is_system&&a.jsx(Ae,{size:"sm",variant:"ghost",onClick:()=>Jn(se.id),children:a.jsx(an,{className:"w-4 h-4"})})]})]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-6",children:se.description||i("settings.noDescription")}),a.jsxs("div",{className:"flex items-center gap-4 mt-2 ml-6 text-xs text-bambu-gray",children:[a.jsx("span",{children:i("settings.userCount",{count:se.user_count})}),a.jsx("span",{children:i("settings.permissionCount",{count:se.permissions.length})})]})]},se.id))})})]})})]}),!l&&a.jsx(St,{children:a.jsx(Nt,{className:"py-6",children:a.jsxs("div",{className:"text-center",children:[a.jsx(nT,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:i("settings.authDisabledTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4 max-w-md mx-auto",children:i("settings.authDisabledMessage")}),a.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray mb-6 text-left max-w-xs mx-auto",children:[a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:i("settings.authDisabledFeature1")})]}),a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:i("settings.authDisabledFeature2")})]}),a.jsxs("li",{className:"flex items-start gap-2",children:[a.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),a.jsx("span",{children:i("settings.authDisabledFeature3")})]})]}),a.jsxs(Ae,{onClick:()=>e("/setup"),children:[a.jsx(rT,{className:"w-4 h-4"}),i("settings.enableAuthentication")]})]})})})]}),Ie&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{_e(!1),jt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsxs(St,{className:"w-full max-w-md",onClick:se=>se.stopPropagation(),children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(pg,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.createUser")})]}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>{_e(!1),jt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsx(Lt,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{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:i("settings.username")}),a.jsx("input",{type:"text",value:at.username,onChange:se=>jt({...at,username:se.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:i("settings.enterUsername"),autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.password")}),a.jsx("input",{type:"password",value:at.password,onChange:se=>jt({...at,password:se.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:i("settings.enterPassword"),autoComplete:"new-password",minLength:6})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.confirmPassword")}),a.jsx("input",{type:"password",value:at.confirmPassword,onChange:se=>jt({...at,confirmPassword:se.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${at.confirmPassword&&at.password!==at.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmPasswordPlaceholder"),autoComplete:"new-password",minLength:6}),at.confirmPassword&&at.password!==at.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Groups"}),a.jsxs("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:[Fr.map(se=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:at.group_ids.includes(se.id),onChange:()=>Qs(se.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),a.jsx("span",{className:"text-sm text-white",children:se.name}),se.is_system&&a.jsx("span",{className:"text-xs text-yellow-400",children:"(System)"})]},se.id)),Fr.length===0&&a.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.noGroupsAvailable")})]})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Ae,{variant:"secondary",onClick:()=>{_e(!1),jt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:"Cancel"}),a.jsx(Ae,{onClick:Ao,disabled:Ys.isPending||!at.username||!at.password||at.password!==at.confirmPassword||at.password.length<6,children:Ys.isPending?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):a.jsxs(a.Fragment,{children:[a.jsx(fr,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),Ke&&it!==null&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{Me(!1),Ee(null),jt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsxs(St,{className:"w-full max-w-md",onClick:se=>se.stopPropagation(),children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(mg,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.editUser")})]}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>{Me(!1),Ee(null),jt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:a.jsx(Lt,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{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:i("settings.username")}),a.jsx("input",{type:"text",value:at.username,onChange:se=>jt({...at,username:se.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:i("settings.enterUsername"),autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:["Password ",a.jsx("span",{className:"text-bambu-gray font-normal",children:"(leave blank to keep current)"})]}),a.jsx("input",{type:"password",value:at.password,onChange:se=>jt({...at,password:se.target.value,confirmPassword:""}),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:i("settings.enterNewPassword"),autoComplete:"new-password",minLength:6})]}),at.password&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.confirmPassword")}),a.jsx("input",{type:"password",value:at.confirmPassword,onChange:se=>jt({...at,confirmPassword:se.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${at.confirmPassword&&at.password!==at.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),at.confirmPassword&&at.password!==at.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Groups"}),a.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto p-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg",children:Fr.map(se=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:at.group_ids.includes(se.id),onChange:()=>Qs(se.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),a.jsx("span",{className:"text-sm text-white",children:se.name}),se.is_system&&a.jsx("span",{className:"text-xs text-yellow-400",children:"(System)"})]},se.id))})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Ae,{variant:"secondary",onClick:()=>{Me(!1),Ee(null),jt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:"Cancel"}),a.jsx(Ae,{onClick:()=>Ts(it),disabled:nn.isPending||!at.username||!!(at.password&&(at.password!==at.confirmPassword||at.password.length<6)),children:nn.isPending?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):a.jsxs(a.Fragment,{children:[a.jsx(ms,{className:"w-4 h-4"}),"Save Changes"]})})]})]})]})}),Xe!==null&&a.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:()=>{ze(null),$e(null)},children:a.jsxs(St,{className:"w-full max-w-md",onClick:se=>se.stopPropagation(),children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center gap-2 text-red-400",children:[a.jsx(an,{className:"w-5 h-5"}),a.jsx("h3",{className:"text-lg font-semibold",children:i("settings.deleteUserTitle")})]})}),a.jsx(Nt,{className:"space-y-4",children:ye?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-bambu-green border-t-transparent"})}):ce&&ce.archives+ce.queue_items+ce.library_files>0?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-white",children:i("settings.userHasCreated")}),a.jsxs("ul",{className:"list-disc list-inside text-bambu-gray space-y-1",children:[ce.archives>0&&a.jsxs("li",{children:[ce.archives," archive",ce.archives!==1?"s":""]}),ce.queue_items>0&&a.jsxs("li",{children:[ce.queue_items," queue item",ce.queue_items!==1?"s":""]}),ce.library_files>0&&a.jsxs("li",{children:[ce.library_files," library file",ce.library_files!==1?"s":""]})]}),a.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.userItemsQuestion")}),a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(Ae,{variant:"danger",onClick:()=>ln.mutate({id:Xe,deleteItems:!0}),disabled:ln.isPending,className:"justify-center",children:"Delete user AND their items"}),a.jsx(Ae,{variant:"secondary",onClick:()=>ln.mutate({id:Xe,deleteItems:!1}),disabled:ln.isPending,className:"justify-center",children:"Delete user, keep items (become ownerless)"}),a.jsx(Ae,{variant:"ghost",onClick:()=>{ze(null),$e(null)},disabled:ln.isPending,className:"justify-center",children:"Cancel"})]})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"text-white",children:i("settings.deleteUserConfirm")}),a.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.actionCannotBeUndone")}),a.jsxs("div",{className:"flex gap-2 justify-end",children:[a.jsx(Ae,{variant:"ghost",onClick:()=>{ze(null),$e(null)},disabled:ln.isPending,children:"Cancel"}),a.jsx(Ae,{variant:"danger",onClick:()=>ln.mutate({id:Xe,deleteItems:!1}),disabled:ln.isPending,children:"Delete User"})]})]})})]})}),(Dt||cn)&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{yn(!1),rr(null),da()},children:a.jsxs(St,{className:"w-full max-w-2xl max-h-[90vh] overflow-y-auto",onClick:se=>se.stopPropagation(),children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(iT,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:cn?"Edit Group":"Create Group"})]}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>{yn(!1),rr(null),da()},children:a.jsx(Lt,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{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:i("settings.groupName")}),a.jsx("input",{type:"text",value:xn.name,onChange:se=>sr({...xn,name:se.target.value}),disabled:cn?.is_system,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 disabled:opacity-50",placeholder:i("settings.enterGroupName")}),cn?.is_system&&a.jsx("p",{className:"text-xs text-yellow-400 mt-1",children:i("settings.systemGroupWarning")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Description"}),a.jsx("textarea",{value:xn.description,onChange:se=>sr({...xn,description:se.target.value}),rows:2,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 resize-none",placeholder:i("settings.enterDescriptionOptional")})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:["Permissions (",xn.permissions.length," selected)"]}),a.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:Br?.categories.map(se=>a.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary cursor-pointer hover:bg-bambu-dark-tertiary transition-colors",onClick:()=>Gl(se.name),children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("button",{type:"button",onClick:_t=>{_t.stopPropagation(),Rm(se,!Om(se))},className:`w-5 h-5 rounded border flex items-center justify-center transition-colors ${Om(se)?"bg-bambu-green border-bambu-green":qh(se)?"bg-bambu-green/50 border-bambu-green":"border-bambu-gray hover:border-white"}`,children:(Om(se)||qh(se))&&a.jsx(Wi,{className:"w-3 h-3 text-white"})}),a.jsx("span",{className:"text-white font-medium",children:se.name}),a.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",se.permissions.filter(_t=>xn.permissions.includes(_t.value)).length,"/",se.permissions.length,")"]})]}),Gn.has(se.name)?a.jsx(Kr,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(vs,{className:"w-4 h-4 text-bambu-gray"})]}),Gn.has(se.name)&&a.jsx("div",{className:"p-3 bg-bambu-dark space-y-2",children:se.permissions.map(_t=>a.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-secondary cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:xn.permissions.includes(_t.value),onChange:()=>Hx(_t.value),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark-secondary"}),a.jsx("span",{className:"text-sm text-bambu-gray",children:_t.label})]},_t.value))})]},se.name))})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Ae,{variant:"secondary",onClick:()=>{yn(!1),rr(null),da()},children:"Cancel"}),a.jsx(Ae,{onClick:cn?Bx:Hr,disabled:Es.isPending||Eo.isPending||!xn.name.trim(),children:Es.isPending||Eo.isPending?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 animate-spin"}),cn?"Saving...":"Creating..."]}):a.jsxs(a.Fragment,{children:[a.jsx(ms,{className:"w-4 h-4"}),cn?"Save Changes":"Create Group"]})})]})]})]})}),Vn!==null&&a.jsx(Zn,{title:i("settings.deleteGroupTitle"),message:i("settings.deleteGroupMessage"),confirmText:i("settings.deleteGroup"),variant:"danger",onConfirm:()=>{To.mutate(Vn),Jn(null)},onCancel:()=>Jn(null)}),ge==="backup"&&a.jsx(UKe,{}),we&&a.jsx(Zn,{title:i("settings.disableAuthenticationTitle"),message:i("settings.disableAuthenticationMessage"),confirmText:i("settings.disableAuthentication"),variant:"danger",onConfirm:async()=>{try{await oe.disableAuth(),o(i("settings.toast.authDisabled"),"success"),await u(),ae(!1),window.location.href="/"}catch(se){const _t=se instanceof Error?se.message:i("settings.toast.authDisableFailed");o(_t,"error")}},onCancel:()=>ae(!1)}),Le&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>{Be(!1),He({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsxs(St,{className:"w-full max-w-md",onClick:se=>se.stopPropagation(),children:[a.jsx(Kn,{children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Ko,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.changePassword")})]}),a.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>{Be(!1),He({currentPassword:"",newPassword:"",confirmPassword:""})},children:a.jsx(Lt,{className:"w-5 h-5"})})]})}),a.jsxs(Nt,{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:"Current Password"}),a.jsx("input",{type:"password",value:Ve.currentPassword,onChange:se=>He({...Ve,currentPassword:se.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:i("settings.enterCurrentPassword"),autoComplete:"current-password"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"New Password"}),a.jsx("input",{type:"password",value:Ve.newPassword,onChange:se=>He({...Ve,newPassword:se.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:i("settings.enterNewPasswordMin6"),autoComplete:"new-password",minLength:6})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Confirm New Password"}),a.jsx("input",{type:"password",value:Ve.confirmPassword,onChange:se=>He({...Ve,confirmPassword:se.target.value}),className:`w-full px-4 py-3 bg-bambu-dark-secondary border rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors ${Ve.confirmPassword&&Ve.newPassword!==Ve.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),Ve.confirmPassword&&Ve.newPassword!==Ve.confirmPassword&&a.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]})]}),a.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[a.jsx(Ae,{variant:"secondary",onClick:()=>{Be(!1),He({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),a.jsx(Ae,{onClick:async()=>{if(Ve.newPassword!==Ve.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(Ve.newPassword.length<6){o(i("settings.toast.passwordTooShort"),"error");return}Pe(!0);try{await oe.changePassword(Ve.currentPassword,Ve.newPassword),o(i("settings.toast.passwordChanged"),"success"),Be(!1),He({currentPassword:"",newPassword:"",confirmPassword:""})}catch(se){const _t=se instanceof Error?se.message:"Failed to change password";o(_t,"error")}finally{Pe(!1)}},disabled:be||!Ve.currentPassword||!Ve.newPassword||Ve.newPassword!==Ve.confirmPassword||Ve.newPassword.length<6,children:be?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 animate-spin"}),"Changing..."]}):a.jsxs(a.Fragment,{children:[a.jsx(Ko,{className:"w-4 h-4"}),"Change Password"]})})]})]})]})})]})}const Wre=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},qKe=t=>t.startsWith("HH")?"HF":"S",WKe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},dR=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 Vj({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:s,note:o}){const l=qKe(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(Gs,{className:"w-4 h-4 text-bambu-green"}):a.jsx(cl,{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:Wre(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(OW,{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(Ul,{className:"w-4 h-4"})})]})}function Gj({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:s="",initialNoteKey:o=null,onClose:l,onSave:c,onSaveNote:u,hasPermission:d}){const{t:h}=On(),{showToast:p}=Hn(),[m,x]=_.useState(t?.name||""),[y,v]=_.useState(t?.k_value?Wre(t.k_value):"0.020"),[b,S]=_.useState(t?.filament_id||""),[N,T]=_.useState(t?.nozzle_id?WKe(t.nozzle_id):"HH00"),[k,C]=_.useState(t?.nozzle_diameter||n),[E,P]=_.useState(t?[t.extruder_id]:i?[0,1]:[0]),[A,D]=_.useState(!1),[I,L]=_.useState({current:0,total:0}),[U,j]=_.useState(s),V=ei.useMemo(()=>{const W=new Map;for(const ne of r)if(ne.filament_id&&!W.has(ne.filament_id)){const re=dR(ne.name||"");W.set(ne.filament_id,{id:ne.filament_id,name:re||ne.filament_id})}return Array.from(W.values()).sort((ne,re)=>ne.name.localeCompare(re.name))},[r]),K=gt({mutationFn:W=>(console.log("[KProfile] Calling API..."),oe.setKProfile(e,W)),onSuccess:W=>{if(console.log("[KProfile] Save success:",W),p(h("kProfiles.toast.profileSaved")),u&&U!==s){let ne;U===""&&o?ne=o:t&&t.slot_id>0?ne=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:ne=`name_${m}_${b}`,u(ne,U)}D(!0),setTimeout(()=>{D(!1),c()},2500)},onError:W=>{console.error("[KProfile] Save error:",W),p(W.message,"error"),D(!1)}}),z=gt({mutationFn:W=>(console.log("[KProfile] Deleting profile..."),oe.deleteKProfile(e,W)),onSuccess:W=>{console.log("[KProfile] Delete success:",W),p(h("kProfiles.toast.profileDeleted")),D(!0),setTimeout(()=>{D(!1),l()},4e3)},onError:W=>{console.error("[KProfile] Delete error:",W),p(W.message,"error"),D(!1)}}),[X,Y]=_.useState(!1),te=()=>{t&&z.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})},$=async W=>{if(W.preventDefault(),i&&!t&&E.length===0){p(h("kProfiles.toast.selectAtLeastOneExtruder"),"error");return}const ne=parseFloat(y).toFixed(6),re=`${N}-${k}`;if(t||E.length===1){const me={name:m,k_value:ne,filament_id:b,nozzle_id:re,nozzle_diameter:k,extruder_id:t?t.extruder_id:E[0],setting_id:t?.setting_id,slot_id:t?.slot_id??0};console.log("[KProfile] Saving profile:",me),K.mutate(me);return}D(!0),L({current:1,total:E.length});const ge=E.map(me=>({name:m,k_value:ne,filament_id:b,nozzle_id:re,nozzle_diameter:k,extruder_id:me,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${ge.length} profiles in batch:`,ge);try{if(await oe.setKProfilesBatch(e,ge),p(h("kProfiles.toast.profilesSaved",{count:E.length})),u&&U){const me=`name_${m}_${b}`;u(me,U)}}catch(me){console.error("[KProfile] Failed to save batch:",me),p(h("kProfiles.toast.failedToSaveBatch"),"error"),D(!1),L({current:0,total:0});return}L({current:E.length,total:E.length}),setTimeout(()=>{D(!1),L({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(St,{className:"w-full max-w-md relative",children:[A&&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(pt,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),a.jsx("p",{className:"text-white font-medium",children:I.total>1?h("kProfiles.modal.savingExtruder",{current:I.current,total:I.total}):h("kProfiles.modal.syncing")}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:h("kProfiles.modal.pleaseWait")})]}),a.jsxs(Nt,{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:h(t?"kProfiles.modal.editTitle":"kProfiles.modal.addTitle")}),a.jsx("button",{onClick:l,className:"text-bambu-gray hover:text-white transition-colors",disabled:A,children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("form",{onSubmit:$,className:"p-4 space-y-4",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.profileName")}),a.jsx("input",{type:"text",value:m,onChange:W=>x(W.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:h("kProfiles.modal.profileNamePlaceholder"),required:!t})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.kValue")}),a.jsx("input",{type:"text",inputMode:"decimal",value:y,onChange:W=>{const ne=W.target.value;(ne===""||/^\d*\.?\d*$/.test(ne))&&v(ne)},onBlur:W=>{const ne=parseFloat(W.target.value);isNaN(ne)||v((Math.trunc(ne*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:h("kProfiles.modal.kValuePlaceholder"),required:!0}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:h("kProfiles.modal.kValueHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.filament")}),a.jsxs("select",{value:b,onChange:W=>{const ne=W.target.value;if(S(ne),!t&&ne&&!m){const re=V.find(ge=>ge.id===ne);re&&x(`${N==="HH00"?"HF":"S"} ${re.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:h("kProfiles.modal.selectFilament")}),t?.filament_id&&a.jsx("option",{value:t.filament_id,children:V.find(W=>W.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&V.map(W=>a.jsx("option",{value:W.id,children:W.name},W.id))]}),!t&&V.length===0&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:h("kProfiles.modal.noFilamentsHelp")})]}),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:h("kProfiles.modal.flowType")}),a.jsxs("select",{value:N,onChange:W=>{const ne=W.target.value;if(T(ne),!t&&b&&!m){const re=V.find(ge=>ge.id===b);re&&x(`${ne==="HS00"?"HF":"S"} ${re.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:h("kProfiles.modal.highFlow")}),a.jsx("option",{value:"HS00",children:h("kProfiles.modal.standard")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.nozzleSize")}),a.jsxs("select",{value:k,onChange:W=>C(W.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:h(t?"kProfiles.modal.extruder":"kProfiles.modal.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?h("kProfiles.modal.left"):h("kProfiles.modal.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:W=>{W.target.checked?P([...E,1]):P(E.filter(ne=>ne!==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:h("kProfiles.modal.left")})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:E.includes(0),onChange:W=>{W.target.checked?P([...E,0]):P(E.filter(ne=>ne!==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:h("kProfiles.modal.right")})]})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:h("kProfiles.modal.notes")}),a.jsx("textarea",{value:U,onChange:W=>j(W.target.value),placeholder:h("kProfiles.modal.notesPlaceholder"),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:h("kProfiles.modal.notesHelp")})]}),a.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&a.jsx(Ae,{type:"button",variant:"secondary",onClick:()=>Y(!0),disabled:z.isPending||A||!d("kprofiles:delete"),title:d("kprofiles:delete")?void 0:h("kProfiles.permission.noDelete"),className:"text-red-500 hover:bg-red-500/10",children:z.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(an,{className:"w-4 h-4"})}),a.jsx(Ae,{type:"button",variant:"secondary",onClick:l,disabled:A,className:"flex-1",children:h("common.cancel")}),a.jsxs(Ae,{type:"submit",disabled:K.isPending||A||!d(t?"kprofiles:update":"kprofiles:create"),title:d(t?"kprofiles:update":"kprofiles:create")?void 0:h(t?"kProfiles.permission.noUpdate":"kProfiles.permission.noCreate"),className:"flex-1",children:[K.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(fM,{className:"w-4 h-4"}),h("common.save")]})]})]})]})]}),X&&a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:a.jsx(St,{className:"w-full max-w-sm",children:a.jsxs(Nt,{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(an,{className:"w-5 h-5 text-red-500"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:h("kProfiles.deleteConfirm.title")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:h("kProfiles.deleteConfirm.cannotUndo")})]})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:h("kProfiles.deleteConfirm.message",{name:t?.name})}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(Ae,{variant:"secondary",onClick:()=>Y(!1),className:"flex-1",children:h("common.cancel")}),a.jsxs(Ae,{onClick:()=>{Y(!1),te()},disabled:z.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[z.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(an,{className:"w-4 h-4"}),h("common.delete")]})]})]})})})]})}const m1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function KKe(){const{t}=On(),{showToast:e}=Hn(),{hasPermission:n}=Ci(),[r,i]=_.useState(null),[s,o]=_.useState(()=>localStorage.getItem(m1.NOZZLE_DIAMETER)||"0.4"),[l,c]=_.useState(null),[u,d]=_.useState(!1),[h,p]=_.useState(null),[m,x]=_.useState(""),[y,v]=_.useState("all"),[b,S]=_.useState("all"),[N,T]=_.useState(()=>localStorage.getItem(m1.SORT_OPTION)||"name"),[k,C]=_.useState(!1),[E,P]=_.useState(new Set),[A,D]=_.useState(!1),[I,L]=_.useState(!1),U=_.useCallback(B=>`${B.slot_id}_${B.extruder_id}`,[]);_.useEffect(()=>{localStorage.setItem(m1.NOZZLE_DIAMETER,s)},[s]),_.useEffect(()=>{localStorage.setItem(m1.SORT_OPTION,N)},[N]);const{data:j,isLoading:V}=ct({queryKey:["printers"],queryFn:oe.getPrinters}),{data:K,isLoading:z,isFetching:X,error:Y,refetch:te}=ct({queryKey:["kprofiles",r,s],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",r,"nozzle",s);const B=await oe.getKProfiles(r,s);return console.log("[KProfiles] Received profiles:",B?.profiles?.length||0,"profiles"),B},enabled:!!r,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:$}=ct({queryKey:["kprofiles",r,"0.4"],queryFn:()=>oe.getKProfiles(r,"0.4"),enabled:!!r,staleTime:6e4}),{data:W,refetch:ne}=ct({queryKey:["kprofile-notes",r],queryFn:()=>oe.getKProfileNotes(r),enabled:!!r,staleTime:3e4}),re=Y?.message?.includes("not connected");_.useEffect(()=>{if(!r&&j&&j.length>0){const B=j.find(he=>he.is_active);B&&i(B.id)}},[r,j]),_.useEffect(()=>{if(r){const B=setTimeout(()=>{te()},150);return()=>clearTimeout(B)}},[r,s]);const ge=j?.filter(B=>B.is_active)||[],me=ei.useMemo(()=>K?.profiles?K.profiles.filter(he=>{const ke=m.toLowerCase(),pe=!ke||he.name.toLowerCase().includes(ke)||he.filament_id.toLowerCase().includes(ke),H=y==="all"||y==="left"&&he.extruder_id===1||y==="right"&&he.extruder_id===0,O=b==="all"||b==="hf"&&he.nozzle_id.startsWith("HH")||b==="s"&&he.nozzle_id.startsWith("HS");return pe&&H&&O}).sort((he,ke)=>{switch(N){case"k_value":return parseFloat(he.k_value)-parseFloat(ke.k_value);case"filament":return dR(he.name).localeCompare(dR(ke.name));case"name":default:return he.name.localeCompare(ke.name)}}):[],[K?.profiles,m,y,b,N]),ue=j?.find(B=>B.id===r),Te=ue?.nozzle_count===2;_.useEffect(()=>{const B=he=>{he.target instanceof HTMLInputElement||he.target instanceof HTMLTextAreaElement||he.target instanceof HTMLSelectElement||l||u||h||(he.key==="r"||he.key==="R"?(he.preventDefault(),te()):he.key==="n"||he.key==="N"?(he.preventDefault(),d(!0)):he.key==="Escape"&&k&&(he.preventDefault(),C(!1),P(new Set)))};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[l,u,h,k,te]);const ie=_.useCallback(()=>{if(!K?.profiles||K.profiles.length===0){e(t("kProfiles.toast.noProfilesToExport"),"error");return}const B={version:1,exported_at:new Date().toISOString(),printer:ue?.name||"Unknown",nozzle_diameter:s,profiles:K.profiles.map(H=>({name:H.name,k_value:H.k_value,filament_id:H.filament_id,nozzle_id:H.nozzle_id,nozzle_diameter:H.nozzle_diameter,extruder_id:H.extruder_id}))},he=new Blob([JSON.stringify(B,null,2)],{type:"application/json"}),ke=URL.createObjectURL(he),pe=document.createElement("a");pe.href=ke,pe.download=`kprofiles_${ue?.name||"printer"}_${s}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(pe),pe.click(),document.body.removeChild(pe),URL.revokeObjectURL(ke),e(t("kProfiles.toast.exportedProfiles",{count:K.profiles.length}))},[K?.profiles,ue,s,e,t]),Ce=_.useCallback(()=>{const B=document.createElement("input");B.type="file",B.accept=".json",B.onchange=async he=>{const ke=he.target.files?.[0];if(ke)try{const pe=await ke.text(),H=JSON.parse(pe);if(!H.profiles||!Array.isArray(H.profiles)){e(t("kProfiles.toast.invalidFileFormat"),"error");return}let O=0;for(const J of H.profiles)if(!(!J.name||!J.k_value||!J.filament_id))try{await oe.setKProfile(r,{name:J.name,k_value:parseFloat(J.k_value).toFixed(6),filament_id:J.filament_id,nozzle_id:J.nozzle_id||`HH00-${s}`,nozzle_diameter:J.nozzle_diameter||s,extruder_id:J.extruder_id??0,slot_id:0}),O++,await new Promise(le=>setTimeout(le,500))}catch(le){console.error("Failed to import profile:",J.name,le)}e(t("kProfiles.toast.importedProfiles",{count:O,total:H.profiles.length})),te()}catch(pe){console.error("Import error:",pe),e(t("kProfiles.toast.failedToParseImport"),"error")}},B.click()},[r,s,e,te,t]),Fe=_.useCallback(B=>{P(he=>{const ke=new Set(he);return ke.has(B)?ke.delete(B):ke.add(B),ke})},[]),xe=_.useCallback(()=>{P(new Set(me.map(B=>U(B))))},[me,U]),Ze=_.useCallback(()=>{E.size!==0&&D(!0)},[E.size]),G=_.useCallback(async()=>{const B=me.filter(ke=>E.has(U(ke)));L(!0);let he=0;for(const ke of B)try{await oe.deleteKProfile(r,{slot_id:ke.slot_id,extruder_id:ke.extruder_id,nozzle_id:ke.nozzle_id,nozzle_diameter:ke.nozzle_diameter,filament_id:ke.filament_id,setting_id:ke.setting_id}),he++,await new Promise(pe=>setTimeout(pe,300))}catch(pe){console.error("Failed to delete profile:",ke.name,pe)}e(t("kProfiles.toast.profilesDeleted",{count:he})),L(!1),D(!1),C(!1),P(new Set),te()},[r,E,me,e,te,U,t]),Q=_.useCallback(B=>{const he=[];return B.setting_id&&he.push(B.setting_id),he.push(`slot_${B.slot_id}_${B.filament_id}_${B.extruder_id}`),he.push(`name_${B.name}_${B.filament_id}`),he},[]),de=_.useCallback(async(B,he)=>{if(r)try{await oe.setKProfileNote(r,B,he),ne()}catch(ke){console.error("Failed to save note:",ke),e(t("kProfiles.toast.failedToSaveNote"),"error")}},[r,ne,e,t]),q=_.useCallback(B=>{if(!W?.notes)return{note:"",key:null};const he=Q(B);for(const ke of he)if(W.notes[ke])return{note:W.notes[ke],key:ke};return{note:"",key:null}},[W,Q]),ee=_.useCallback(B=>q(B).note,[q]);return V?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!j||j.length===0?a.jsx(St,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(Vi,{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:t("kProfiles.noPrintersConfigured")}),a.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.addPrinterInSettings")})]})}):ge.length===0?a.jsx(St,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(Ur,{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:t("kProfiles.noActivePrinters")}),a.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.enablePrinterConnection")})]})}):a.jsxs(a.Fragment,{children:[X&&!z&&a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[a.jsx(pt,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),a.jsx("p",{className:"text-white font-medium",children:t("kProfiles.loadingProfiles")})]}),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:t("kProfiles.printer")}),a.jsx("select",{value:r||"",onChange:B=>i(parseInt(B.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:ge.map(B=>a.jsx("option",{value:B.id,children:B.name},B.id))})]}),a.jsxs("div",{className:"w-32",children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("kProfiles.nozzle")}),a.jsxs("select",{value:s,onChange:B=>o(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",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(Ae,{variant:"secondary",onClick:()=>te(),disabled:X||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noRead"),children:[a.jsx(Dr,{className:`w-4 h-4 ${X?"animate-spin":""}`}),t("kProfiles.refresh")]}),a.jsxs(Ae,{onClick:()=>d(!0),disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noCreate"),children:[a.jsx(fr,{className:"w-4 h-4"}),t("kProfiles.addProfile")]})]})]}),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(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:m,onChange:B=>x(B.target.value),placeholder:t("kProfiles.searchPlaceholder"),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"})]}),Te&&a.jsx("div",{className:"w-36",children:a.jsxs("select",{value:y,onChange:B=>v(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"all",children:t("kProfiles.allExtruders")}),a.jsx("option",{value:"left",children:t("kProfiles.leftOnly")}),a.jsx("option",{value:"right",children:t("kProfiles.rightOnly")})]})}),a.jsx("div",{className:"w-32",children:a.jsxs("select",{value:b,onChange:B=>S(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"all",children:t("kProfiles.allFlow")}),a.jsx("option",{value:"hf",children:t("kProfiles.hfOnly")}),a.jsx("option",{value:"s",children:t("kProfiles.sOnly")})]})}),a.jsx("div",{className:"w-32",children:a.jsxs("select",{value:N,onChange:B=>T(B.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"name",children:t("kProfiles.sortName")}),a.jsx("option",{value:"k_value",children:t("kProfiles.sortKValue")}),a.jsx("option",{value:"filament",children:t("kProfiles.sortFilament")})]})})]}),a.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[a.jsxs(Ae,{variant:"secondary",onClick:ie,disabled:!K?.profiles?.length||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noExport"),children:[a.jsx(wi,{className:"w-4 h-4"}),t("kProfiles.export")]}),a.jsxs(Ae,{variant:"secondary",onClick:Ce,disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noImport"),children:[a.jsx(Ba,{className:"w-4 h-4"}),t("kProfiles.import")]}),a.jsx("div",{className:"flex-1"}),k?a.jsxs(a.Fragment,{children:[a.jsxs(Ae,{variant:"secondary",onClick:xe,children:[a.jsx(Gs,{className:"w-4 h-4"}),t("kProfiles.selectAll")]}),a.jsxs(Ae,{variant:"secondary",onClick:Ze,disabled:E.size===0||!n("kprofiles:delete"),className:"text-red-500 hover:bg-red-500/10",title:n("kprofiles:delete")?void 0:t("kProfiles.permission.noDelete"),children:[a.jsx(an,{className:"w-4 h-4"}),t("kProfiles.delete")," (",E.size,")"]}),a.jsxs(Ae,{variant:"secondary",onClick:()=>{C(!1),P(new Set)},children:[a.jsx(Lt,{className:"w-4 h-4"}),t("common.cancel")]})]}):a.jsxs(Ae,{variant:"secondary",onClick:()=>C(!0),disabled:!me.length||!n("kprofiles:delete"),title:n("kprofiles:delete")?void 0:t("kProfiles.permission.noDelete"),children:[a.jsx(Gs,{className:"w-4 h-4"}),t("kProfiles.select")]})]}),z?a.jsx("div",{className:"flex justify-center py-12",children:a.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):re?a.jsx(St,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(lm,{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:t("kProfiles.printerOffline")}),a.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.printerOfflineDesc")}),a.jsxs(Ae,{variant:"secondary",onClick:()=>te(),children:[a.jsx(Dr,{className:"w-4 h-4"}),t("common.refresh")]})]})}):me.length>0?Te?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:t("kProfiles.leftExtruder")}),a.jsx("div",{className:"space-y-1",children:me.filter(B=>B.extruder_id===1).map(B=>a.jsx(Vj,{profile:B,onEdit:()=>c(B),onCopy:()=>p(B),selectionMode:k,isSelected:E.has(U(B)),onToggleSelect:()=>Fe(U(B)),note:ee(B)},U(B)))})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:t("kProfiles.rightExtruder")}),a.jsx("div",{className:"space-y-1",children:me.filter(B=>B.extruder_id===0).map(B=>a.jsx(Vj,{profile:B,onEdit:()=>c(B),onCopy:()=>p(B),selectionMode:k,isSelected:E.has(U(B)),onToggleSelect:()=>Fe(U(B)),note:ee(B)},U(B)))})]})]}):a.jsx("div",{className:"space-y-1",children:me.map(B=>a.jsx(Vj,{profile:B,onEdit:()=>c(B),onCopy:()=>p(B),selectionMode:k,isSelected:E.has(U(B)),onToggleSelect:()=>Fe(U(B)),note:ee(B)},U(B)))}):m||y!=="all"||b!=="all"?a.jsx(St,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(wa,{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:t("kProfiles.noMatchingProfiles")}),a.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.noMatchingProfilesDesc")})]})}):a.jsx(St,{children:a.jsxs(Nt,{className:"py-12 text-center",children:[a.jsx(fM,{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:t("kProfiles.noKProfiles")}),a.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.noKProfilesDesc",{diameter:s})}),a.jsxs(Ae,{onClick:()=>d(!0),children:[a.jsx(fr,{className:"w-4 h-4"}),t("kProfiles.createFirstProfile")]})]})}),l&&r&&(()=>{const{note:B,key:he}=q(l);return a.jsx(Gj,{profile:l,printerId:r,nozzleDiameter:s,existingProfiles:$?.profiles||K?.profiles,isDualNozzle:Te,initialNote:B,initialNoteKey:he,onSaveNote:de,hasPermission:n,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),c(null),te()},onSave:()=>{c(null),te()}})})(),u&&r&&a.jsx(Gj,{printerId:r,nozzleDiameter:s,existingProfiles:$?.profiles||K?.profiles,isDualNozzle:Te,onSaveNote:de,hasPermission:n,onClose:()=>{d(!1),te()},onSave:()=>{d(!1),te()}}),h&&r&&a.jsx(Gj,{printerId:r,nozzleDiameter:s,existingProfiles:$?.profiles||K?.profiles,isDualNozzle:Te,onSaveNote:de,hasPermission:n,profile:{...h,slot_id:0,name:`${h.name} (Copy)`},onClose:()=>{p(null),te()},onSave:()=>{p(null),te()}}),A&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsx(St,{className:"w-full max-w-sm",children:a.jsxs(Nt,{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(an,{className:"w-5 h-5 text-red-500"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:t("kProfiles.bulkDelete.title")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("kProfiles.bulkDelete.cannotUndo")})]})]}),a.jsx("p",{className:"text-bambu-gray mb-6",children:t("kProfiles.bulkDelete.message",{count:E.size})}),a.jsxs("div",{className:"flex gap-3",children:[a.jsx(Ae,{variant:"secondary",onClick:()=>D(!1),disabled:I,className:"flex-1",children:t("common.cancel")}),a.jsxs(Ae,{onClick:G,disabled:I,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[I?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(an,{className:"w-4 h-4"}),t("common.delete")]})]})]})})})]})}function hF(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 Oy(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function XKe(t,e){const n=zi(t);if(!n)return"";const i=new Date().getTime()-n.getTime(),s=Math.floor(i/6e4),o=Math.floor(i/36e5),l=Math.floor(i/864e5);return s<1?e("profiles.time.justNow"):s<60?e("profiles.time.minsAgo",{count:s}):o<24?e("profiles.time.hoursAgo",{count:o}):l<7?e("profiles.time.daysAgo",{count:l}):n.toLocaleDateString()}function YKe({onSuccess:t,t:e}){const{showToast:n}=Hn(),[r,i]=_.useState("email"),[s,o]=_.useState(""),[l,c]=_.useState(""),[u,d]=_.useState(""),[h,p]=_.useState(""),[m,x]=_.useState("global"),[y,v]=_.useState(null),[b,S]=_.useState(null),N=gt({mutationFn:()=>oe.cloudLogin(s,l,m),onSuccess:P=>{P.success?(n(e("profiles.login.toast.loggedIn")),t()):P.needs_verification?(v(P.verification_type||"email"),S(P.tfa_key||null),P.verification_type==="totp"?n(e("profiles.login.toast.enterTotp")):n(e("profiles.login.toast.codeSent")),i("code")):n(P.message,"error")},onError:P=>n(P.message,"error")}),T=gt({mutationFn:()=>oe.cloudVerify(s,u,b||void 0),onSuccess:P=>{P.success?(n(e("profiles.login.toast.loggedIn")),t()):n(P.message,"error")},onError:P=>n(P.message,"error")}),k=gt({mutationFn:()=>oe.cloudSetToken(h),onSuccess:()=>{n(e("profiles.login.toast.tokenSet")),t()},onError:P=>n(P.message,"error")}),C=P=>{P.preventDefault(),r==="email"?N.mutate():r==="code"?T.mutate():r==="token"&&k.mutate()},E=N.isPending||T.isPending||k.isPending;return a.jsx(St,{className:"max-w-md mx-auto",children:a.jsxs(Nt,{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(cM,{className:"w-6 h-6 text-bambu-green"})}),a.jsx("h2",{className:"text-xl font-semibold text-white",children:e("profiles.login.title")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:e("profiles.login.subtitle")})]}),a.jsxs("form",{onSubmit:C,className:"space-y-4",children:[r==="email"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.email")}),a.jsx("input",{type:"email",value:s,onChange:P=>o(P.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:e("profiles.login.password")}),a.jsx("input",{type:"password",value:l,onChange:P=>c(P.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:e("profiles.login.region")}),a.jsxs("select",{value:m,onChange:P=>x(P.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[a.jsx("option",{value:"global",children:e("profiles.login.regionGlobal")}),a.jsx("option",{value:"china",children:e("profiles.login.regionChina")})]})]})]}),r==="code"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e(y==="totp"?"profiles.login.totpCode":"profiles.login.verificationCode")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:y==="totp"?e("profiles.login.enterTotpHint"):e("profiles.login.checkEmail",{email:s})}),a.jsx("input",{type:"text",value:u,onChange:P=>d(P.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})]}),r==="token"&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.accessToken")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:e("profiles.login.accessTokenHint")}),a.jsx("textarea",{value:h,onChange:P=>p(P.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:[r==="code"&&a.jsx(Ae,{type:"button",variant:"secondary",onClick:()=>i("email"),className:"flex-1",children:e("profiles.login.back")}),a.jsxs(Ae,{type:"submit",disabled:E,className:"flex-1",children:[E?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(Fz,{className:"w-4 h-4"}),e(r==="email"?"profiles.login.loginButton":r==="code"?"profiles.login.verifyButton":"profiles.login.setTokenButton")]})]}),r==="email"&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("button",{type:"button",onClick:()=>i("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[a.jsx(Ko,{className:"w-4 h-4"}),e("profiles.login.useToken")]})}),r==="token"&&a.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:a.jsxs("button",{type:"button",onClick:()=>i("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[a.jsx(Fz,{className:"w-4 h-4"}),e("profiles.login.useEmail")]})})]})]})})}function ig({label:t,value:e,options:n,onChange:r}){const[i,s]=_.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(Kr,{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 QKe(){const[t,e]=_.useState(!1);_.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(zg,{className:"w-5 h-5"})}):null}function qj({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:s,compareDisabled:o,t:l}){const c=hF(t.name),u=Oy(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&&u&&a.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:l("profiles.presets.myPreset")}),a.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),c.filamentType&&t.type==="filament"&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.filamentType}),c.layerHeight&&t.type==="process"&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.layerHeight}),c.printer&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.printer})]})}),a.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"opacity-0 group-hover:opacity-100 text-bambu-gray hover:text-white transition-all p-1",title:l("profiles.presets.duplicate"),children:a.jsx(Ul,{className:"w-4 h-4"})})]})}function hR(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(`
  8279. `)){const i=t.replace(/\\n/g,`
  8280. `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
  8281. `);if(i.length>1)return`"""
  8282. `+i.map(s=>n+" "+s).join(`
  8283. `)+`
  8284. `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
  8285. `+t.map(i=>n+" "+hR(i,e+1)).join(`,
  8286. `)+`
  8287. `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
  8288. `+r.map(([s,o])=>n+" "+JSON.stringify(s)+": "+hR(o,e+1)).join(`,
  8289. `)+`
  8290. `+n+"}"}return String(t)}function ZKe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i,hasPermission:s,t:o}){const{showToast:l}=Hn(),c=sn(),[u,d]=_.useState(!1),{data:h,isLoading:p}=ct({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>oe.getCloudSettingDetail(t.setting_id)}),m=gt({mutationFn:()=>oe.deleteCloudSetting(t.setting_id),onSuccess:()=>{l(o("profiles.presets.toast.deleted")),c.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:v=>l(v.message,"error")}),x=Oy(t.setting_id),y=hF(t.name,h?.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(St,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:a.jsxs(Nt,{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}),x&&a.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-bambu-green/20 text-bambu-green rounded-full",children:o("profiles.presets.editable")})]}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[a.jsx("span",{className:"capitalize",children:o(`profiles.presets.types.${t.type}`)}),y.printer&&a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"•"}),a.jsx("span",{children:y.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(Lt,{className:"w-5 h-5"})})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:p?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h?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:hR(h)}):a.jsx("div",{className:"text-center py-16 text-bambu-gray",children:o("profiles.presets.failedToLoadDetails")})}),u?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(Sn,{className:"w-5 h-5"}),a.jsx("span",{className:"font-medium",children:o("profiles.presets.deleteConfirm")})]}),a.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:o("profiles.presets.deleteWarning",{name:t.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ae,{variant:"secondary",onClick:()=>d(!1),disabled:m.isPending,className:"flex-1",children:o("common.cancel")}),a.jsxs(Ae,{variant:"danger",onClick:()=>m.mutate(),disabled:m.isPending,className:"flex-1",children:[m.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):a.jsx(an,{className:"w-4 h-4"}),o("common.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(Ae,{variant:"secondary",onClick:e,className:"flex-1",children:o("common.close")}),a.jsxs(Ae,{variant:"secondary",onClick:r,disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDuplicatePermission"),children:[a.jsx(Ul,{className:"w-4 h-4"}),o("profiles.presets.duplicate")]}),x&&a.jsxs(a.Fragment,{children:[a.jsxs(Ae,{variant:"secondary",onClick:i,disabled:p||!h||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noEditPermission"),children:[a.jsx(ea,{className:"w-4 h-4"}),o("common.edit")]}),a.jsx(Ae,{variant:"danger",onClick:()=>d(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.presets.noDeletePermission"),children:a.jsx(an,{className:"w-4 h-4"})})]})]})})]})})})}function Kre(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Xre(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function JKe({onClose:t,onApply:e,t:n}){const{showToast:r}=Hn(),[i,s]=_.useState(Kre),[o,l]=_.useState("all"),[c,u]=_.useState(null),[d,h]=_.useState(""),[p,m]=_.useState(""),[x,y]=_.useState("{}"),[v,b]=_.useState(null),[S,N]=_.useState(null),T=o==="all"?i:i.filter(U=>U.type===o),k=U=>{s(U),Xre(U)},C=U=>{const j=i.filter(V=>V.id!==U);k(j),N(null),r(n("profiles.templates.toast.deleted"))},E=U=>{u(U.id),h(U.name),m(U.description),y(JSON.stringify(U.settings,null,2)),b(null)},P=()=>{if(!(!c||!d.trim()))try{const U=JSON.parse(x),j=i.map(V=>V.id===c?{...V,name:d.trim(),description:p.trim(),settings:U}:V);k(j),u(null),r(n("profiles.templates.toast.updated"))}catch(U){b(U.message)}},A=()=>{u(null),h(""),m(""),y("{}"),b(null)},D=U=>{const j=i.map(V=>V.id===U?{...V,showInModal:!V.showInModal}:V);k(j)},I={filament:{label:n("profiles.presets.types.filament"),icon:AR,color:"text-amber-400"},print:{label:n("profiles.presets.types.process"),icon:vh,color:"text-blue-400"},printer:{label:n("profiles.presets.types.printer"),icon:Ur,color:"text-purple-400"}},L=S?i.find(U=>U.id===S):null;return _.useEffect(()=>{const U=j=>{j.key==="Escape"&&(S?N(null):c?A():t())};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[S,c,t]),a.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[L&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:a.jsx(St,{className:"w-full max-w-md",children:a.jsxs(Nt,{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(Sn,{className:"w-6 h-6 text-red-400"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-semibold text-white",children:n("profiles.templates.deleteTitle")}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("profiles.templates.deleteWarning")})]})]}),a.jsx("p",{className:"text-white mb-6",children:n("profiles.templates.deleteConfirm",{name:L.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ae,{variant:"secondary",onClick:()=>N(null),className:"flex-1",children:n("common.cancel")}),a.jsxs(Ae,{onClick:()=>C(S),className:"flex-1 bg-red-500 hover:bg-red-600",children:[a.jsx(an,{className:"w-4 h-4"}),n("common.delete")]})]})]})})}),a.jsx(St,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:a.jsxs(Nt,{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(K0,{className:"w-5 h-5 text-amber-400"}),n("profiles.templates.title")]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Lt,{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:n("profiles.templates.typeFilter")}),["all","filament","print","printer"].map(U=>a.jsx("button",{onClick:()=>l(U),className:`px-3 py-1 text-sm rounded-lg transition-colors ${o===U?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:U==="all"?n("common.all"):I[U].label},U))]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:T.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(K0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:n("profiles.templates.noTemplates")}),a.jsx("p",{className:"text-sm mt-1",children:n("profiles.templates.createFirst")})]}):a.jsx("div",{className:"space-y-2",children:T.map(U=>{const j=I[U.type],V=j.icon;return c===U.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:d,onChange:K=>h(K.target.value),placeholder:n("profiles.templates.namePlaceholder"),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:p,onChange:K=>m(K.target.value),placeholder:n("profiles.templates.descriptionPlaceholder"),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:n("profiles.templates.settingsJson")}),a.jsx("textarea",{value:x,onChange:K=>{y(K.target.value),b(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${v?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),v&&a.jsx("p",{className:"text-xs text-red-400 mt-1",children:v})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ae,{size:"sm",onClick:P,disabled:!d.trim(),children:[a.jsx(ms,{className:"w-4 h-4"}),"Save"]}),a.jsx(Ae,{size:"sm",variant:"secondary",onClick:A,children:"Cancel"})]})]},U.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(V,{className:`w-5 h-5 ${j.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:U.name}),a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:U.description})]}),a.jsx("span",{className:"text-xs text-bambu-gray-dark px-2 py-1 bg-bambu-dark-secondary rounded",children:n("profiles.templates.fieldsCount",{count:Object.keys(U.settings).length})}),a.jsx("button",{onClick:()=>D(U.id),className:`p-1 transition-colors ${U.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:U.showInModal?n("profiles.templates.shownInModals"):n("profiles.templates.hiddenInModals"),children:U.showInModal?a.jsx(xc,{className:"w-4 h-4"}):a.jsx(uM,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>e(U),className:"px-3 py-1 text-xs bg-bambu-green/20 text-bambu-green rounded hover:bg-bambu-green/30 transition-colors",children:n("profiles.templates.apply")}),a.jsx("button",{onClick:()=>E(U),className:"p-1 text-bambu-gray hover:text-white",title:n("common.edit"),children:a.jsx(ea,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>N(U.id),className:"p-1 text-bambu-gray hover:text-red-400",title:n("common.delete"),children:a.jsx(an,{className:"w-4 h-4"})})]},U.id)})})})]})})]})}function Yre({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i,t:s}){const[o,l]=_.useState("changes"),[c,u]=_.useState(""),d=_.useMemo(()=>{const x=new Set([...Object.keys(e),...Object.keys(n)]),y=[];for(const v of x){if(v==="inherits"||v==="version")continue;const b=e[v],S=n[v],N=v in e,T=v in n;let k;!N&&T?k="added":N&&!T?k="removed":JSON.stringify(b)!==JSON.stringify(S)?k="changed":k="same",y.push({key:v,left:b,right:S,status:k})}return y.sort((v,b)=>{const S={changed:0,added:1,removed:2,same:3};return S[v.status]!==S[b.status]?S[v.status]-S[b.status]:v.key.localeCompare(b.key)})},[e,n]),h=_.useMemo(()=>{let x=[...d];if(o==="changes"&&(x=x.filter(y=>y.status!=="same")),c){const y=c.toLowerCase();x=x.filter(v=>v.key.toLowerCase().includes(y)||String(v.left).toLowerCase().includes(y)||String(v.right).toLowerCase().includes(y))}return x},[d,o,c]),p=_.useMemo(()=>({added:d.filter(x=>x.status==="added").length,removed:d.filter(x=>x.status==="removed").length,changed:d.filter(x=>x.status==="changed").length,same:d.filter(x=>x.status==="same").length}),[d]),m=x=>{if(x===void 0)return"—";if(x===null)return"null";if(Array.isArray(x))return x.length===0?"[]":x.length===1?String(x[0]):x.join(", ");if(typeof x=="object")return JSON.stringify(x);const y=String(x);if(y.includes("\\n")||y.length>100){const v=y.split("\\n").length;if(v>1)return`[${v} lines of G-code/script]`;if(y.length>100)return y.substring(0,100)+"…"}return y};return _.useEffect(()=>{const x=y=>{y.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]),a.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:a.jsx(St,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:a.jsxs(Nt,{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(Ng,{className:"w-5 h-5 text-blue-400"}),s("profiles.diff.title")]}),a.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:a.jsx(Lt,{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:s("profiles.diff.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:s("profiles.diff.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(fr,{className:"w-3.5 h-3.5"}),p.added," ",s("profiles.diff.added")]}),a.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[a.jsx(bP,{className:"w-3.5 h-3.5"}),p.removed," ",s("profiles.diff.removed")]}),a.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[a.jsx(dP,{className:"w-3.5 h-3.5"}),p.changed," ",s("profiles.diff.changed")]}),a.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[a.jsx(tT,{className:"w-3.5 h-3.5"}),p.same," ",s("profiles.diff.same")]})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"relative",children:[a.jsx(wa,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:c,onChange:x=>u(x.target.value),placeholder:s("profiles.diff.searchFields"),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"})]}),p.same>0&&a.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>l("changes"),className:`px-3 py-1.5 text-sm transition-colors ${o==="changes"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s("profiles.diff.changes")}),a.jsx("button",{onClick:()=>l("all"),className:`px-3 py-1.5 text-sm transition-colors ${o==="all"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s("common.all")})]})]})]}),a.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:h.length===0?a.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[a.jsx(tT,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),a.jsx("p",{children:s(o==="changes"?"profiles.diff.noDifferences":"profiles.diff.noFieldsMatch")})]}):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:s("profiles.diff.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:h.map(x=>{const y={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[x.status],v={added:a.jsx(fr,{className:"w-3.5 h-3.5 text-green-400"}),removed:a.jsx(bP,{className:"w-3.5 h-3.5 text-red-400"}),changed:a.jsx(dP,{className:"w-3.5 h-3.5 text-amber-400"}),same:a.jsx(tT,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[x.status];return a.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${y}`,children:[a.jsx("td",{className:"p-3",children:a.jsxs("div",{className:"flex items-center gap-2",children:[v,a.jsx("span",{className:"text-sm text-white font-mono",children:x.key})]})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${x.status==="removed"?"text-red-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(x.left)})}),a.jsx("td",{className:"p-3",children:a.jsx("span",{className:`text-sm font-mono break-all ${x.status==="added"?"text-green-300":x.status==="changed"?"text-white":"text-bambu-gray"}`,children:m(x.right)})})]},x.key)})})]})})]})})})}function eXe({onClose:t,initialData:e,allPresets:n,t:r}){const{showToast:i}=Hn(),s=sn(),o=!!e?.setting_id,[l,c]=_.useState("common"),[u,d]=_.useState(e?.type||"filament"),[h,p]=_.useState(e?.name?o?e.name:`${e.name} (Copy)`:""),[m,x]=_.useState(e?.base_id||""),[y,v]=_.useState(""),[b,S]=_.useState(e?.setting||{inherits:""}),[N,T]=_.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[k,C]=_.useState(null),[E,P]=_.useState(""),[A,D]=_.useState(!1),[I,L]=_.useState(""),[U,j]=_.useState(!1),[V,K]=_.useState(Kre),[z,X]=_.useState(!1),[Y,te]=_.useState(""),[$,W]=_.useState(""),[ne,re]=_.useState(!0),[ge,me]=_.useState(null),[ue,Te]=_.useState(!1),ie=_.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[u]||[],[n,u]),Ce=_.useMemo(()=>ie.filter(Pe=>Oy(Pe.setting_id)),[ie]),{data:Fe}=ct({queryKey:["cloudFields",u],queryFn:()=>oe.getCloudFields(u==="print"?"process":u),staleTime:1e3*60*60}),{data:xe}=ct({queryKey:["allPresetDetails",u,Ce.map(Pe=>Pe.setting_id).join(",")],queryFn:async()=>{const Pe={};for(let _e=0;_e<Ce.length;_e+=5){const Ke=Ce.slice(_e,_e+5);(await Promise.all(Ke.map(async it=>{try{const Ee=await oe.getCloudSettingDetail(it.setting_id);return{id:it.setting_id,detail:Ee}}catch{return null}}))).forEach(it=>{it&&(Pe[it.id]=it.detail)})}return Pe},enabled:Ce.length>0,staleTime:1e3*60*10}),{data:Ze,isLoading:G}=ct({queryKey:["cloudSettingDetail",m],queryFn:()=>oe.getCloudSettingDetail(m),enabled:!!m});_.useEffect(()=>{l!=="json"&&T(JSON.stringify(b,null,2))},[b,l]);const Q=_.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[u]||[]).filter(Ie=>!Oy(Ie.setting_id)).sort((Ie,_e)=>Ie.name.localeCompare(_e.name)),[n,u]);_.useEffect(()=>{if(!m)return;const Pe=Q.find(Ie=>Ie.setting_id===m);Pe&&(v(Pe.name),o||(S({inherits:Pe.name}),T(JSON.stringify({inherits:Pe.name},null,2))))},[m,Q,o]);const de=_.useMemo(()=>{const Pe=Fe?.fields||[],Ie=new Set(Pe.map(it=>it.key)),_e=new Set,Ke=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);xe&&Object.values(xe).forEach(it=>{it?.setting&&Object.keys(it.setting).forEach(Ee=>{!Ie.has(Ee)&&!Ke.has(Ee)&&_e.add(Ee)})}),Object.keys(b).forEach(it=>{!Ie.has(it)&&!Ke.has(it)&&_e.add(it)});const Me=Array.from(_e).sort().map(it=>({key:it,label:it.replace(/_/g," ").replace(/\b\w/g,Ee=>Ee.toUpperCase()),type:"text",category:"discovered",description:r("profiles.presets.discoveredFromPresets")}));return[...Pe,...Me]},[Fe,xe,b,r]),q=de.filter(Pe=>Pe.label.toLowerCase().includes(E.toLowerCase())||Pe.key.toLowerCase().includes(E.toLowerCase())),ee=()=>{if(I.trim()){const Pe=I.trim().toLowerCase().replace(/\s+/g,"_");B(Pe,""),L(""),j(!1),i(r("profiles.presets.toast.fieldAdded",{key:Pe}))}},B=(Pe,Ie)=>{S(_e=>{const Ke={..._e};return Ie===""||Ie===void 0?delete Ke[Pe]:Ke[Pe]=Ie,Ke})},he=Pe=>{S(Ie=>({...Ie,...Pe.settings})),me(Pe.name),i(r("profiles.templates.toast.applied"))},ke=()=>{if(!Y.trim())return;const Pe={...b};if(delete Pe.inherits,Object.keys(Pe).length===0){i(r("profiles.presets.noOverridesToSave"),"error");return}const Ie={id:Date.now().toString(),name:Y.trim(),description:$.trim()||r("profiles.presets.customTemplate"),type:u,settings:Pe,showInModal:ne},_e=[...V,Ie];K(_e),Xre(_e),X(!1),te(""),W(""),re(!0),i(r("profiles.templates.toast.created"))},pe=_.useMemo(()=>V.filter(Pe=>Pe.type===u&&Pe.showInModal),[u,V]),H=Pe=>{T(Pe);try{const Ie=JSON.parse(Pe);S(Ie),C(null)}catch(Ie){C(Ie.message)}},O=Pe=>{Pe.preventDefault(),D(!1);const Ie=Pe.dataTransfer.files[0];if(Ie&&Ie.name.endsWith(".json")){const _e=new FileReader;_e.onload=Ke=>{try{const Me=Ke.target?.result,it=JSON.parse(Me),Ee=it.setting||it;S(Xe=>({...Xe,...Ee})),T(JSON.stringify({...b,...Ee},null,2)),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJsonFile"),"error")}},_e.readAsText(Ie)}},J=gt({mutationFn:()=>{const Pe={...b},Ie=u==="filament"?"filament_settings_id":u==="print"?"print_settings_id":"printer_settings_id";Pe[Ie]=`"${h}"`;const _e={type:u,name:h,base_id:m,setting:Pe};return oe.createCloudSetting(_e)},onSuccess:async()=>{i(r("profiles.presets.toast.created")),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:Pe=>i(Pe.message,"error")}),le=gt({mutationFn:()=>{if(!e?.setting_id)throw new Error(r("profiles.presets.noSettingId"));return oe.updateCloudSetting(e.setting_id,{name:h,setting:b})},onSuccess:async()=>{i(r("profiles.presets.toast.updated")),s.removeQueries({queryKey:["cloudSettingDetail"]}),await s.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:Pe=>i(Pe.message,"error")}),Se=o?le:J,we=Ze?.setting?.inherits,ae=we?Q.find(Pe=>Pe.name===we):void 0,{data:Le}=ct({queryKey:["cloudSettingDetail",ae?.setting_id],queryFn:()=>oe.getCloudSettingDetail(ae.setting_id),enabled:!!ae?.setting_id}),Be=_.useMemo(()=>{const Pe=Le?.setting||{},Ie=Ze?.setting||{},_e=m&&xe?.[m]?.setting?xe[m].setting:{};return{...Pe,...Ie,..._e}},[m,Ze,Le,xe]),Ve=Pe=>{if(Pe==null)return"";if(Array.isArray(Pe)){const Ie=[...new Set(Pe.map(_e=>String(_e)))];return Ie.length===1?Ie[0]:Pe.join(", ")}return String(Pe)},He=Pe=>{const Ie=b[Pe.key],_e=Be[Pe.key],Ke=Ve(_e),Me=G?r("common.loading"):Ke||"",it="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(Pe.type==="boolean"){const Ee=Ie==="1"||Ie===void 0&&_e==="1";return a.jsx("button",{type:"button",onClick:()=>B(Pe.key,Ie==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Ee?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:a.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow transition-transform ${Ee?"translate-x-3.5":"translate-x-0.5"}`})})}return Pe.type==="select"?a.jsxs("select",{value:Ie||"",onChange:Ee=>B(Pe.key,Ee.target.value),className:it,children:[a.jsx("option",{value:"",children:Me}),Pe.options?.map(Ee=>a.jsx("option",{value:Ee.value,children:Ee.label},Ee.value))]}):a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:Pe.type==="number"?"number":"text",value:Ie!==void 0?String(Ie):"",onChange:Ee=>B(Pe.key,Ee.target.value),step:Pe.step,min:Pe.min,max:Pe.max,placeholder:Me,className:it}),Pe.unit&&a.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:Pe.unit})]})},be=_.useMemo(()=>Ze?.setting?Ze.setting:{},[Ze]);return a.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onDragOver:Pe=>{Pe.preventDefault(),D(!0)},onDragLeave:()=>D(!1),onDrop:O,children:[ue&&m&&a.jsx(Yre,{onClose:()=>Te(!1),leftPreset:be,rightPreset:b,leftLabel:r("profiles.presets.baseLabel",{name:y||m}),rightLabel:r("profiles.presets.currentLabel",{name:h||r("profiles.presets.newPreset")}),t:r}),a.jsx(St,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:a.jsxs(Nt,{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:r(o?"profiles.presets.editPreset":e?"profiles.presets.duplicatePreset":"profiles.presets.createNewPreset")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("profiles.presets.customizeSettings")})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[m&&a.jsxs("button",{onClick:()=>Te(!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:r("profiles.presets.compareWithBase"),children:[a.jsx(Ng,{className:"w-4 h-4"}),r("profiles.presets.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(Lt,{className:"w-5 h-5"})})]})]}),A&&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(Ba,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),a.jsx("p",{className:"text-bambu-green font-medium",children:r("profiles.presets.dropJsonToImport")})]})}),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:r("common.type")}),a.jsxs("select",{value:u,onChange:Pe=>{d(Pe.target.value),x("")},className:"w-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:r("profiles.presets.types.filament")}),a.jsx("option",{value:"print",children:r("profiles.presets.types.process")}),a.jsx("option",{value:"printer",children:r("profiles.presets.types.printer")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.basePreset")}),a.jsxs("select",{value:m,onChange:Pe=>x(Pe.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:r("profiles.presets.selectBasePreset")}),Q.map(Pe=>a.jsx("option",{value:Pe.setting_id,children:Pe.name},Pe.setting_id))]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.presetName")}),a.jsx("input",{type:"text",value:h,onChange:Pe=>p(Pe.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:r("profiles.presets.myCustomPreset")})]})]}),y&&a.jsx("div",{className:"text-xs text-bambu-gray",children:a.jsxs("p",{className:"flex items-center gap-1",children:[a.jsx(Wi,{className:"w-3 h-3 text-bambu-green"}),r("profiles.presets.inheritsFrom")," ",a.jsx("span",{className:"text-white",children:y}),G&&a.jsx(pt,{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:()=>c("common"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="common"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(Iz,{className:"w-4 h-4"}),r("profiles.presets.tabs.common")]}),a.jsxs("button",{onClick:()=>c("fields"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="fields"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(gM,{className:"w-4 h-4"}),r("profiles.presets.tabs.allFields")]}),a.jsxs("button",{onClick:()=>c("json"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${l==="json"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(NW,{className:"w-4 h-4"}),"JSON",k&&a.jsx(Vi,{className:"w-3 h-3 text-red-400"})]}),a.jsx("div",{className:"flex-1"}),a.jsxs("button",{onClick:()=>{const Pe={name:h,type:u,base_id:m,setting:b},Ie=new Blob([JSON.stringify(Pe,null,2)],{type:"application/json"}),_e=URL.createObjectURL(Ie),Ke=document.createElement("a");Ke.href=_e,Ke.download=`${h||"preset"}.json`,document.body.appendChild(Ke),Ke.click(),document.body.removeChild(Ke),URL.revokeObjectURL(_e),i(r("profiles.presets.toast.exported"))},className:"flex items-center gap-2 px-4 py-3 text-sm text-bambu-gray hover:text-white transition-colors",title:r("profiles.presets.exportToJson"),children:[a.jsx(wi,{className:"w-4 h-4"}),r("common.download")]}),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:r("profiles.presets.importFromJson"),children:[a.jsx(Ba,{className:"w-4 h-4"}),r("common.upload")]}),a.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:Pe=>{const Ie=Pe.target.files?.[0];if(Ie){const _e=new FileReader;_e.onload=Ke=>{try{const Me=JSON.parse(Ke.target?.result),it=Me.setting||Me;S(Ee=>({...Ee,...it})),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJson"),"error")}},_e.readAsText(Ie)}}})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[l==="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(K0,{className:"w-4 h-4 text-amber-400"}),r("profiles.templates.title")]}),Object.keys(b).filter(Pe=>Pe!=="inherits").length>0&&a.jsxs("button",{onClick:()=>X(!z),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[a.jsx(ms,{className:"w-3 h-3"}),r("profiles.presets.saveAsTemplate")]})]}),z&&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:Y,onChange:Pe=>te(Pe.target.value),placeholder:r("profiles.templates.namePlaceholder"),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:$,onChange:Pe=>W(Pe.target.value),placeholder:r("profiles.templates.descriptionPlaceholder"),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(Ae,{size:"sm",onClick:ke,disabled:!Y.trim(),children:[a.jsx(ms,{className:"w-3 h-3"}),r("common.save")]}),a.jsx(Ae,{size:"sm",variant:"secondary",onClick:()=>X(!1),children:r("common.cancel")})]}),a.jsxs("button",{onClick:()=>re(!ne),className:`flex items-center gap-1.5 text-xs transition-colors ${ne?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[ne?a.jsx(xc,{className:"w-3.5 h-3.5"}):a.jsx(uM,{className:"w-3.5 h-3.5"}),r(ne?"profiles.templates.shownInModals":"profiles.templates.hiddenInModals")]})]})]}),ge&&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(Wi,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("span",{className:"text-sm text-bambu-green",children:[r("profiles.presets.templateApplied")," ",a.jsx("span",{className:"font-medium",children:ge})]}),a.jsx("button",{onClick:()=>me(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:a.jsx(Lt,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[pe.map(Pe=>a.jsxs("button",{onClick:()=>he(Pe),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:Pe.name}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:Pe.description})]},Pe.id)),pe.length===0&&a.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:r("profiles.presets.noTemplatesSelected")})]}),a.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:r("profiles.presets.manageTemplatesHint")})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.commonSettings")}),a.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:de.slice(0,10).map(Pe=>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:Pe.label}),a.jsx("div",{className:"w-48",children:He(Pe)})]},Pe.key))})]}),Object.keys(b).length>1&&a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.currentOverrides")}),a.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(b).filter(([Pe])=>Pe!=="inherits").map(([Pe,Ie])=>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:[Pe,": ",String(Ie).slice(0,20),a.jsx("button",{onClick:()=>B(Pe,void 0),className:"hover:text-white",children:a.jsx(Lt,{className:"w-3 h-3"})})]},Pe))})]})]}),l==="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:r("profiles.presets.availableFields")}),a.jsx("span",{className:"text-xs text-bambu-gray",children:xe?r("profiles.templates.fieldsCount",{count:de.length}):r("common.loading")})]}),a.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[a.jsx(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:E,onChange:Pe=>P(Pe.target.value),placeholder:r("profiles.presets.searchFieldsPlaceholder"),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:[q.filter(Pe=>!(Pe.key in b)).map(Pe=>{const Ie=Be[Pe.key],_e=Ve(Ie);return a.jsxs("div",{onClick:()=>{S(Ke=>({...Ke,[Pe.key]:_e||""}))},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:Pe.label}),a.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:Pe.key})]}),a.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[_e&&a.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:_e,children:[_e.slice(0,20),_e.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(fr,{className:"w-4 h-4 text-bambu-gray group-hover:text-bambu-green transition-colors"})})]})]},Pe.key)}),q.filter(Pe=>!(Pe.key in b)).length===0&&a.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:r(E?"profiles.presets.noMatchingFields":"profiles.presets.allFieldsAdded")})]}),a.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:U?a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:I,onChange:Pe=>L(Pe.target.value),onKeyDown:Pe=>Pe.key==="Enter"&&ee(),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(Ae,{size:"sm",onClick:ee,disabled:!I.trim(),children:a.jsx(fr,{className:"w-4 h-4"})}),a.jsx(Ae,{size:"sm",variant:"secondary",onClick:()=>{j(!1),L("")},children:a.jsx(Lt,{className:"w-4 h-4"})})]}):a.jsxs("button",{onClick:()=>j(!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(fr,{className:"w-4 h-4"}),r("profiles.presets.addCustomField")]})})]}),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:r("profiles.presets.yourOverrides")}),a.jsx("span",{className:"text-xs text-bambu-gray",children:r("profiles.templates.fieldsCount",{count:Object.keys(b).filter(Pe=>Pe!=="inherits").length})})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(b).filter(([Pe])=>Pe!=="inherits").map(([Pe,Ie])=>{const _e=de.find(Ke=>Ke.key===Pe);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:_e?.label||Pe}),a.jsx("p",{className:"text-xs text-bambu-gray-dark",children:Pe})]}),a.jsx("button",{onClick:()=>B(Pe,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:a.jsx(Lt,{className:"w-4 h-4"})})]}),_e?He(_e):a.jsx("input",{type:"text",value:String(Ie),onChange:Ke=>B(Pe,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"})]},Pe)}),Object.keys(b).filter(Pe=>Pe!=="inherits").length===0&&a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(Iz,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),a.jsx("p",{className:"text-sm",children:r("profiles.presets.noOverridesYet")}),a.jsx("p",{className:"text-xs mt-1",children:r("profiles.presets.clickFieldsToAdd")})]})]}),Object.keys(b).filter(Pe=>Pe!=="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:()=>{X(!0),c("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(ms,{className:"w-4 h-4"}),r("profiles.presets.saveAsTemplate")]})})]})]}),l==="json"&&a.jsxs("div",{className:"space-y-2",children:[k&&a.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[a.jsx(Vi,{className:"w-4 h-4"}),k]}),a.jsx("textarea",{value:N,onChange:Pe=>H(Pe.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 ${k?"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:r("profiles.presets.jsonTip")})]})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[a.jsx(Ae,{variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),a.jsxs(Ae,{onClick:()=>Se.mutate(),disabled:Se.isPending||!h.trim()||!o&&!m||!!k,className:"flex-1",children:[Se.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):o?a.jsx(ms,{className:"w-4 h-4"}):a.jsx(fr,{className:"w-4 h-4"}),r(o?"common.save":e?"common.duplicate":"common.create")]})]})]})})]})}function tXe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i,hasPermission:s,t:o}){const[l,c]=_.useState(""),[u,d]=_.useState("all"),[h,p]=_.useState("all"),[m,x]=_.useState("all"),[y,v]=_.useState("all"),[b,S]=_.useState("all"),[N,T]=_.useState("all"),[k,C]=_.useState(null),[E,P]=_.useState(!1),[A,D]=_.useState(!1),[I,L]=_.useState(null),[U,j]=_.useState(null),[V,K]=_.useState(null),[z,X]=_.useState(!1),[Y,te]=_.useState([null,null]),[$,W]=_.useState(!1),[ne,re]=_.useState(null),ge=sn(),me=_.useMemo(()=>[...t.filament.map(ee=>({...ee,type:"filament"})),...t.printer.map(ee=>({...ee,type:"printer"})),...t.process.map(ee=>({...ee,type:"process"}))].map(ee=>({...ee,meta:hF(ee.name)})),[t]),ue=_.useMemo(()=>{const q=new Set,ee=new Set,B=new Set;return me.forEach(he=>{he.meta.nozzle&&q.add(he.meta.nozzle),he.meta.filamentType&&ee.add(he.meta.filamentType),he.meta.layerHeight&&B.add(he.meta.layerHeight)}),{printers:i.map(he=>({id:he.id.toString(),name:he.name})),nozzles:Array.from(q).sort((he,ke)=>parseFloat(he)-parseFloat(ke)),filaments:Array.from(ee).sort(),layerHeights:Array.from(B).sort((he,ke)=>parseFloat(he)-parseFloat(ke))}},[me,i]),Te=_.useMemo(()=>m==="all"?null:i.find(ee=>ee.id.toString()===m)?.model||null,[m,i]),ie=_.useMemo(()=>me.filter(q=>u==="all"||q.type===u).filter(q=>{if(h==="all")return!0;const ee=Oy(q.setting_id);return h==="custom"?ee:!ee}).filter(q=>{if(m==="all"||!Te)return!0;const ee=q.meta.printer?.toLowerCase()||"",B=Te.toLowerCase();return ee.includes(B)||B.includes(ee)}).filter(q=>y==="all"||q.meta.nozzle===y).filter(q=>b==="all"||q.meta.filamentType===b).filter(q=>N==="all"||q.meta.layerHeight===N).filter(q=>l===""||q.name.toLowerCase().includes(l.toLowerCase())).sort((q,ee)=>q.name.localeCompare(ee.name)),[me,u,h,m,Te,y,b,N,l]),Ce=q=>{if(z){const ee=Y[0]?.setting_id===q.setting_id,B=Y[1]?.setting_id===q.setting_id;if(ee)te([Y[1],null]);else if(B)te([Y[0],null]);else if(!Y[0])te([q,null]);else if(Y[1]){if(Y[0].type!==q.type)return;te([Y[0],q])}else{if(Y[0].type!==q.type)return;te([Y[0],q])}}else C(q)},Fe=q=>{if(Y[0]?.setting_id===q.setting_id)return 0;if(Y[1]?.setting_id===q.setting_id)return 1},xe=async q=>{try{const ee=await oe.getCloudSettingDetail(q.setting_id),B=q.type==="process"?"print":q.type;L({type:B,name:q.name,base_id:ee.base_id||"GFSA00",setting:ee.setting||{}}),C(null)}catch(ee){console.error("Failed to fetch preset details for duplication:",ee)}},Ze=async q=>{try{ge.removeQueries({queryKey:["cloudSettingDetail",q.setting_id]});const ee=await oe.getCloudSettingDetail(q.setting_id),B=q.type==="process"?"print":q.type;j({type:B,name:q.name,base_id:ee.base_id||"GFSA00",setting:ee.setting||{},setting_id:q.setting_id}),C(null)}catch(ee){console.error("Failed to fetch preset details for editing:",ee)}},G=()=>{d("all"),p("all"),x("all"),v("all"),S("all"),T("all"),c("")},Q=u!=="all"||h!=="all"||m!=="all"||y!=="all"||b!=="all"||N!=="all"||l!=="",de=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(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",value:l,onChange:q=>c(q.target.value),placeholder:o("profiles.cloudView.searchPlaceholder"),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(Ae,{variant:z?"primary":"secondary",onClick:()=>{z?(X(!1),te([null,null])):X(!0)},children:[a.jsx(Ng,{className:"w-4 h-4"}),o(z?"common.cancel":"profiles.presets.compare")]}),a.jsxs(Ae,{variant:"secondary",onClick:()=>D(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noTemplatesPermission"),children:[a.jsx(K0,{className:"w-4 h-4"}),o("profiles.cloudView.templates")]}),a.jsxs(Ae,{variant:"secondary",onClick:n,disabled:r||!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noRefreshPermission"),children:[a.jsx(Dr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),o("profiles.cloudView.refresh")]}),a.jsxs(Ae,{onClick:()=>P(!0),disabled:!s("cloud:auth"),title:s("cloud:auth")?void 0:o("profiles.cloudView.noCreatePermission"),children:[a.jsx(fr,{className:"w-4 h-4"}),o("profiles.cloudView.newPreset")]})]})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(hM,{className:"w-4 h-4 text-bambu-gray"}),a.jsx(ig,{label:o("profiles.cloudView.filters.type"),value:u,options:[{value:"all",label:o("profiles.cloudView.filters.all"),count:de},{value:"filament",label:o("profiles.cloudView.filters.filament"),count:t.filament.length},{value:"printer",label:o("profiles.cloudView.filters.printer"),count:t.printer.length},{value:"process",label:o("profiles.cloudView.filters.process"),count:t.process.length}],onChange:q=>d(q)}),a.jsx(ig,{label:o("profiles.cloudView.filters.owner"),value:h,options:[{value:"all",label:o("profiles.cloudView.filters.all")},{value:"custom",label:o("profiles.cloudView.filters.myPresets")},{value:"builtin",label:o("profiles.cloudView.filters.builtIn")}],onChange:q=>p(q)}),ue.printers.length>0&&a.jsx(ig,{label:o("profiles.cloudView.filters.printer"),value:m,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...ue.printers.map(q=>({value:q.id,label:q.name}))],onChange:x}),ue.nozzles.length>0&&a.jsx(ig,{label:o("profiles.cloudView.filters.nozzle"),value:y,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...ue.nozzles.map(q=>({value:q,label:q}))],onChange:v}),ue.filaments.length>0&&(u==="all"||u==="filament")&&a.jsx(ig,{label:o("profiles.cloudView.filters.filament"),value:b,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...ue.filaments.map(q=>({value:q,label:q}))],onChange:S}),ue.layerHeights.length>0&&(u==="all"||u==="process")&&a.jsx(ig,{label:o("profiles.cloudView.filters.layer"),value:N,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...ue.layerHeights.map(q=>({value:q,label:q}))],onChange:T}),Q&&a.jsx("button",{onClick:G,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:o("profiles.cloudView.clearFilters")})]})]}),z&&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(Ng,{className:"w-5 h-5 text-blue-400"}),a.jsx("span",{className:"text-white font-medium",children:o("profiles.cloudView.compareMode")}),a.jsx("span",{className:"text-bambu-gray",children:Y[0]?o("profiles.cloudView.selectAnotherPreset",{type:Y[0].type}):o("profiles.cloudView.clickTwoPresets")})]}),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] ${Y[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Y[0]?Y[0].name:o("profiles.cloudView.selectFirst")}),a.jsx(dP,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Y[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Y[1]?Y[1].name:o("profiles.cloudView.selectSecond")})]}),Y[0]&&Y[1]&&a.jsxs(Ae,{size:"sm",onClick:async()=>{try{const[q,ee]=await Promise.all([oe.getCloudSettingDetail(Y[0].setting_id),oe.getCloudSettingDetail(Y[1].setting_id)]);re([q.setting||{},ee.setting||{}]),W(!0)}catch{}},children:[a.jsx(Ng,{className:"w-4 h-4"}),o("profiles.cloudView.compareNow")]})]})]})}),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(tr,{className:"w-3 h-3"}),o("profiles.cloudView.lastSynced")," ",XKe(e.toISOString(),o)]}),a.jsx("span",{children:o("profiles.cloudView.showingCount",{showing:ie.length,total:de})}),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.jsxs("span",{children:["= ",o("profiles.presets.myPreset")]})]})]}),ie.length===0?a.jsxs("div",{className:"text-center py-16",children:[a.jsx(xs,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),a.jsx("p",{className:"text-bambu-gray",children:o("profiles.cloudView.noPresetsFound")}),Q&&a.jsx("button",{onClick:G,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:o("profiles.cloudView.clearFilters")})]}):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(AR,{className:"w-4 h-4 text-amber-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.filament")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ie.filter(q=>q.type==="filament").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ie.filter(q=>q.type==="filament").map(q=>a.jsx(qj,{setting:q,onClick:()=>Ce(q),onDuplicate:()=>xe(q),compareMode:z,isCompareSelected:Fe(q)!==void 0,compareIndex:Fe(q),compareDisabled:z&&!!Y[0]&&Y[0].type!==q.type,t:o},q.setting_id)),ie.filter(q=>q.type==="filament").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noFilamentPresets")})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(vh,{className:"w-4 h-4 text-blue-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.process")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ie.filter(q=>q.type==="process").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ie.filter(q=>q.type==="process").map(q=>a.jsx(qj,{setting:q,onClick:()=>Ce(q),onDuplicate:()=>xe(q),compareMode:z,isCompareSelected:Fe(q)!==void 0,compareIndex:Fe(q),compareDisabled:z&&!!Y[0]&&Y[0].type!==q.type,t:o},q.setting_id)),ie.filter(q=>q.type==="process").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noProcessPresets")})]})]}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[a.jsx(Ur,{className:"w-4 h-4 text-purple-400"}),a.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.printer")}),a.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ie.filter(q=>q.type==="printer").length,")"]})]}),a.jsxs("div",{className:"space-y-1 max-h-[calc(100vh-320px)] overflow-y-auto pr-1",children:[ie.filter(q=>q.type==="printer").map(q=>a.jsx(qj,{setting:q,onClick:()=>Ce(q),onDuplicate:()=>xe(q),compareMode:z,isCompareSelected:Fe(q)!==void 0,compareIndex:Fe(q),compareDisabled:z&&!!Y[0]&&Y[0].type!==q.type,t:o},q.setting_id)),ie.filter(q=>q.type==="printer").length===0&&a.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noPrinterPresets")})]})]})]}),k&&a.jsx(ZKe,{setting:k,onClose:()=>C(null),onDeleted:()=>C(null),onDuplicate:()=>xe(k),onEdit:()=>Ze(k),hasPermission:s,t:o}),(E||I||U||V)&&a.jsx(eXe,{onClose:()=>{P(!1),L(null),j(null),K(null)},initialData:U||I||(V?{type:V.type,name:"",base_id:"",setting:V.setting}:void 0),allPresets:t,t:o}),A&&a.jsx(JKe,{onClose:()=>D(!1),onApply:q=>{K({type:q.type,setting:q.settings}),D(!1)},t:o}),$&&ne&&Y[0]&&Y[1]&&a.jsx(Yre,{onClose:()=>{W(!1),re(null)},leftPreset:ne[0],rightPreset:ne[1],leftLabel:Y[0].name,rightLabel:Y[1].name,t:o})]})}function nXe(){const{t}=On(),e=sn(),{showToast:n}=Hn(),{hasPermission:r}=Ci(),[i,s]=_.useState("cloud"),[o,l]=_.useState(),{data:c,isLoading:u}=ct({queryKey:["cloudStatus"],queryFn:oe.getCloudStatus}),{data:d=[]}=ct({queryKey:["printers"],queryFn:oe.getPrinters}),{data:h,isLoading:p,refetch:m,dataUpdatedAt:x}=ct({queryKey:["cloudSettings"],queryFn:()=>oe.getCloudSettings(),enabled:!!c?.is_authenticated,retry:!1,staleTime:1e3*60*5});_.useEffect(()=>{x&&l(new Date(x))},[x]);const y=gt({mutationFn:oe.cloudLogout,onSuccess:()=>{e.invalidateQueries({queryKey:["cloudStatus"]}),e.removeQueries({queryKey:["cloudSettings"]}),n(t("profiles.toast.loggedOut"))}}),v=()=>{e.invalidateQueries({queryKey:["cloudStatus"]})};return u?a.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:a.jsx(pt,{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:t("profiles.title")}),a.jsx("p",{className:"text-bambu-gray",children:t("profiles.subtitle")})]}),a.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[a.jsxs("button",{onClick:()=>s("cloud"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="cloud"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(cM,{className:"w-4 h-4"}),t("profiles.tabs.cloud")]}),a.jsxs("button",{onClick:()=>s("kprofiles"),className:`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors border-b-2 -mb-px ${i==="kprofiles"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-white border-transparent"}`,children:[a.jsx(fM,{className:"w-4 h-4"}),t("profiles.tabs.kprofiles")]})]}),i==="cloud"&&a.jsxs(a.Fragment,{children:[c?.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:[t("profiles.connectedAs")," ",a.jsx("span",{className:"text-white",children:c.email})]})]}),a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:()=>y.mutate(),disabled:y.isPending||!r("cloud:auth"),title:r("cloud:auth")?void 0:t("profiles.noLogoutPermission"),children:[a.jsx(xP,{className:"w-4 h-4"}),t("profiles.logout")]})]}),c?.is_authenticated?p?a.jsx("div",{className:"flex items-center justify-center py-16",children:a.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):h?a.jsx(tXe,{settings:h,lastSyncTime:o,onRefresh:()=>m(),isRefreshing:p,printers:d,hasPermission:r,t}):a.jsxs("div",{className:"text-center py-16",children:[a.jsx("p",{className:"text-bambu-gray mb-4",children:t("profiles.failedToLoad")}),a.jsx(Ae,{onClick:()=>m(),children:t("profiles.retry")})]}):a.jsx(YKe,{onSuccess:v,t})]}),i==="kprofiles"&&a.jsx(KKe,{}),a.jsx(QKe,{})]})}const x0={Droplet:AR,Flame:que,Ruler:Mhe,Sparkles:K0,Square:cl,Cable:Uce,Wrench:cm,Calendar:ti,Timer:yu,Cog:yue,Fan:MW,Zap:_h,Wind:UW,Thermometer:yM,Layers:xs,Box:Ui,Target:LW,RefreshCw:Dr,Settings:bM,Filter:hM,CircleDot:iue};function B0(t){return t&&x0[t]||cm}function ag(t,e,n){if(e==="days"){if(t<1)return n?n("common.today"):"Today";if(t===1)return n?n("maintenance.day"):"1 day";if(t<7){const i=Math.round(t);return n?n("maintenance.days",{count:i}):`${i} days`}if(t<180){const i=Math.round(t/7);return i===1?n?n("maintenance.week"):"1 week":n?n("maintenance.weeks",{count:i}):`${i} weeks`}const r=Math.round(t/30);return r===1?n?n("maintenance.month"):"1 month":n?n("maintenance.months",{count:r}):`${r} months`}else{if(t<1)return`${Math.round(t*60)}m`;if(t<24)return`${t<10?t.toFixed(1):Math.round(t)}h`;const r=t/24;if(r<7)return`${r<2?r.toFixed(1):Math.round(r)}d`;const i=r/7;return i<12?`${i<2?i.toFixed(1):Math.round(i)}w`:`${Math.round(i/4)}mo`}}function Wj(t,e,n){return e==="days"?t===1?n?n("maintenance.day"):"1 day":t===7?n?n("maintenance.week"):"1 week":t===14?n?n("maintenance.weeks",{count:2}):"2 weeks":t===30?n?n("maintenance.month"):"1 month":t===60?n?n("maintenance.months",{count:2}):"2 months":t===90?n?n("maintenance.months",{count:3}):"3 months":t===180?n?n("maintenance.months",{count:6}):"6 months":t===365?n?n("maintenance.year"):"1 year":n?n("maintenance.days",{count:t}):`${t} days`:`${t}h`}function rXe(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,h=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":h?"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":h?"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":h?"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||h?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 iXe({item:t,onPerform:e,onToggle:n,hasPermission:r,t:i}){const s=B0(t.maintenance_type_icon),o=t.interval_type||"hours",c=(()=>{if(o==="days"){const m=t.days_since_maintenance??0;return Math.max(0,Math.min(100,m/t.interval_hours*100))}return Math.max(0,Math.min(100,(t.interval_hours-t.hours_until_due)/t.interval_hours*100))})(),u=()=>t.enabled?t.is_due?"text-red-400":t.is_warning?"text-amber-400":"text-bambu-green":"text-bambu-gray",d=()=>t.enabled?t.is_due?"bg-red-500":t.is_warning?"bg-amber-500":"bg-bambu-green":"bg-bambu-gray/30",h=()=>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",p=()=>{if(!t.enabled)return i("common.disabled");if(o==="days"){const m=t.days_until_due??0;return t.is_due?i("maintenance.overdueBy",{duration:ag(Math.abs(m),"days",i)}):t.is_warning?i("maintenance.dueIn",{duration:ag(m,"days",i)}):i("maintenance.timeLeft",{duration:ag(m,"days",i)})}else return t.is_due?i("maintenance.overdueBy",{duration:ag(Math.abs(t.hours_until_due),"hours",i)}):t.is_warning?i("maintenance.dueIn",{duration:ag(t.hours_until_due,"hours",i)}):i("maintenance.timeLeft",{duration:ag(t.hours_until_due,"hours",i)})};return a.jsx("div",{className:`rounded-xl border p-4 transition-all ${h()}`,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(s,{className:`w-5 h-5 ${u()}`}),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}),o==="days"&&a.jsx("span",{title:i("maintenance.timeBasedInterval"),children:a.jsx(ti,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const m=t.maintenance_type_wiki_url||rXe(t.maintenance_type_name,t.printer_model);return m?a.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-gray hover:text-bambu-green transition-colors shrink-0",title:i("maintenance.viewDocumentation"),onClick:x=>x.stopPropagation(),children:a.jsx(Xr,{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 ${d()}`,style:{width:`${c}%`}})})}),a.jsxs("div",{className:`text-xs flex items-center gap-1 ${u()}`,children:[t.is_due&&a.jsx(Sn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&a.jsx(tr,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&a.jsx(Wi,{className:"w-3 h-3"}),p()]})]}),a.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[a.jsx("span",{title:r("maintenance:update")?void 0:i("maintenance.noPermissionUpdate"),children:a.jsx(Fn,{checked:t.enabled,onChange:m=>n(t.id,m),disabled:!r("maintenance:update")})}),a.jsxs(Ae,{size:"sm",variant:t.is_due?"primary":"secondary",onClick:()=>e(t.id),disabled:!t.enabled||!r("maintenance:update"),title:r("maintenance:update")?void 0:i("maintenance.noPermissionPerform"),className:"!px-3",children:[a.jsx(Lh,{className:"w-3.5 h-3.5"}),i("common.reset")]})]})]})})}function aXe({overview:t,onPerform:e,onToggle:n,onSetHours:r,hasPermission:i,t:s}){const[o,l]=_.useState(!0),[c,u]=_.useState(!1),[d,h]=_.useState(t.total_print_hours.toFixed(1)),p=[...t.maintenance_items].sort((y,v)=>y.is_due&&!v.is_due?-1:!y.is_due&&v.is_due?1:y.is_warning&&!v.is_warning?-1:!y.is_warning&&v.is_warning?1:y.maintenance_type_id-v.maintenance_type_id),m=p.find(y=>y.enabled&&(y.is_due||y.is_warning)),x=()=>{const y=parseFloat(d);!isNaN(y)&&y>=0&&(r(t.printer_id,y),u(!1))};return a.jsxs(St,{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(Sn,{className:"w-3 h-3"}),s("maintenance.overdueCount",{count:t.due_count})]}),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(tr,{className:"w-3 h-3"}),s("maintenance.dueSoonCount",{count:t.warning_count})]}),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(Wi,{className:"w-3 h-3"}),s("maintenance.allGood")]})]})]}),a.jsxs("button",{onClick:()=>l(!o),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:[o?a.jsx(yh,{className:"w-4 h-4"}):a.jsx(Kr,{className:"w-4 h-4"}),s(o?"common.collapse":"common.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(yu,{className:"w-4 h-4 text-bambu-gray"})}),c?a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"number",value:d,onChange:y=>h(y.target.value),onKeyDown:y=>{y.key==="Enter"&&x(),y.key==="Escape"&&u(!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:s("common.hours")}),a.jsx(Ae,{size:"sm",onClick:x,children:s("common.save")}),a.jsx(Ae,{size:"sm",variant:"secondary",onClick:()=>u(!1),children:s("common.cancel")})]}):a.jsxs("button",{onClick:()=>{i("maintenance:update")&&(h(Math.round(t.total_print_hours).toString()),u(!0))},className:`group ${i("maintenance:update")?"":"cursor-not-allowed opacity-60"}`,title:i("maintenance:update")?void 0:s("maintenance.noPermissionEditHours"),children:[a.jsxs("div",{className:`text-sm font-medium text-white ${i("maintenance:update")?"group-hover:text-bambu-green":""} transition-colors flex items-center gap-1`,children:[Math.round(t.total_print_hours)," ",s("common.hours"),a.jsx(am,{className:`w-3 h-3 text-bambu-gray ${i("maintenance:update")?"group-hover:text-bambu-green":""}`})]}),a.jsx("div",{className:"text-xs text-bambu-gray",children:s("maintenance.totalPrintTime")})]})]}),a.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),m&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:`p-2 rounded-lg ${m.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const y=B0(m.maintenance_type_icon);return a.jsx(y,{className:`w-4 h-4 ${m.is_due?"text-red-400":"text-amber-400"}`})})()}),a.jsxs("div",{children:[a.jsx("div",{className:`text-sm font-medium ${m.is_due?"text-red-400":"text-amber-400"}`,children:m.maintenance_type_name}),a.jsx("div",{className:`text-xs ${m.is_due?"text-red-400/70":"text-amber-400/70"}`,children:m.is_due?s("common.overdue"):s("maintenance.dueSoon")})]})]})]})]}),o&&a.jsx(Nt,{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:p.map(y=>a.jsx(iXe,{item:y,onPerform:e,onToggle:n,hasPermission:i,t:s},y.id))})})]})}function sXe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:s,onAssignType:o,onRemoveItem:l,hasPermission:c,t:u}){const[d,h]=_.useState(null),[p,m]=_.useState(""),[x,y]=_.useState("hours"),[v,b]=_.useState(!1),[S,N]=_.useState(""),[T,k]=_.useState("100"),[C,E]=_.useState("hours"),[P,A]=_.useState("Wrench"),[D,I]=_.useState(""),[L,U]=_.useState(new Set),[j,V]=_.useState(null),K=_.useMemo(()=>t?t.map(B=>({id:B.printer_id,name:B.printer_name})):[],[t]),z=B=>t?t.filter(he=>he.maintenance_items.some(ke=>ke.maintenance_type_id===B)).map(he=>({printerId:he.printer_id,printerName:he.printer_name,itemId:he.maintenance_items.find(ke=>ke.maintenance_type_id===B)?.id})):[],X=B=>{if(!t)return[];const he=new Set(z(B).map(ke=>ke.printerId));return K.filter(ke=>!he.has(ke.id))},[Y,te]=_.useState(null),[$,W]=_.useState(""),[ne,re]=_.useState(""),[ge,me]=_.useState("hours"),[ue,Te]=_.useState("Wrench"),[ie,Ce]=_.useState(""),Fe=B=>{te(B),W(B.name),re(B.default_interval_hours.toString()),me(B.interval_type||"hours"),Te(B.icon||"Wrench"),Ce(B.wiki_url||"")},xe=()=>{Y&&$.trim()&&parseFloat(ne)>0&&(i(Y.id,{name:$.trim(),default_interval_hours:parseFloat(ne),interval_type:ge,icon:ue,wiki_url:ie.trim()||null}),te(null))},Ze=(B,he,ke)=>{const pe=parseFloat(p);if(!isNaN(pe)&&pe>0){const H=Math.abs(pe-he)<.01?null:pe;n(B,{custom_interval_hours:H,custom_interval_type:x!==ke?x:null})}h(null)},G=B=>{B.preventDefault(),S.trim()&&parseFloat(T)>0&&L.size>0&&(r({name:S.trim(),default_interval_hours:parseFloat(T),interval_type:C,icon:P,wiki_url:D.trim()||null},Array.from(L)),N(""),k("100"),E("hours"),I(""),U(new Set),b(!1))},Q=B=>{U(he=>{const ke=new Set(he);return ke.has(B)?ke.delete(B):ke.add(B),ke})},de=t?.map(B=>({printerId:B.printer_id,printerName:B.printer_name,items:B.maintenance_items.sort((he,ke)=>he.maintenance_type_id-ke.maintenance_type_id)})).sort((B,he)=>B.printerName.localeCompare(he.printerName))||[],q=e.filter(B=>B.is_system),ee=e.filter(B=>!B.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:u("maintenance.maintenanceTypes")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:u("maintenance.maintenanceTypesDescription")})]}),a.jsxs(Ae,{onClick:()=>b(!v),disabled:!c("maintenance:create"),title:c("maintenance:create")?void 0:u("maintenance.noPermissionEditTypes"),children:[a.jsx(fr,{className:"w-4 h-4"}),u("maintenance.addCustomType")]})]}),v&&a.jsx(St,{className:"mb-6",children:a.jsx(Nt,{className:"py-4",children:a.jsxs("form",{onSubmit:G,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:u("common.name")}),a.jsx("input",{type:"text",value:S,onChange:B=>N(B.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:u("maintenance.exampleName"),autoFocus:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.intervalType")}),a.jsxs("select",{value:C,onChange:B=>{E(B.target.value),B.target.value==="days"?k("30"):k("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:u("maintenance.printHours")}),a.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.intervalValue",{type:C==="days"?u("maintenance.calendarDays").toLowerCase():u("common.hours")})}),a.jsx("input",{type:"number",value:T,onChange:B=>k(B.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:u("maintenance.icon")}),a.jsx("div",{className:"flex gap-1",children:Object.keys(x0).map(B=>{const he=x0[B];return a.jsx("button",{type:"button",onClick:()=>A(B),className:`p-2 rounded-lg transition-colors ${P===B?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:a.jsx(he,{className:"w-4 h-4"})},B)})})]})}),a.jsxs("div",{className:"mt-4",children:[a.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.documentationLink")}),a.jsx("input",{type:"url",value:D,onChange:B=>I(B.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:u("maintenance.assignToPrinters")}),a.jsx("div",{className:"flex flex-wrap gap-2",children:K.map(B=>a.jsx("button",{type:"button",onClick:()=>Q(B.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${L.has(B.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:B.name},B.id))}),L.size===0&&a.jsx("p",{className:"text-xs text-orange-400 mt-1",children:u("maintenance.selectAtLeastOnePrinter")})]}),a.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[a.jsx(Ae,{type:"button",variant:"secondary",onClick:()=>{b(!1),U(new Set)},children:u("common.cancel")}),a.jsx(Ae,{type:"submit",disabled:!S.trim()||L.size===0,children:u("maintenance.addType")})]})]})})}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[q.map(B=>{const he=B0(B.icon),ke=B.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(he,{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:B.name}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[ke==="days"?a.jsx(ti,{className:"w-3 h-3"}):a.jsx(yu,{className:"w-3 h-3"}),Wj(B.default_interval_hours,ke,u)]})]})]})},B.id)}),ee.map(B=>{const he=B0(B.icon),ke=B.interval_type||"hours";if(Y?.id===B.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:$,onChange:le=>W(le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:u("common.name"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("select",{value:ge,onChange:le=>me(le.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:u("maintenance.printHours")}),a.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]}),a.jsx("input",{type:"number",value:ne,onChange:le=>re(le.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(x0).map(le=>{const Se=x0[le];return a.jsx("button",{type:"button",onClick:()=>Te(le),className:`p-1.5 rounded transition-colors ${ue===le?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:a.jsx(Se,{className:"w-3.5 h-3.5"})},le)})}),a.jsx("input",{type:"url",value:ie,onChange:le=>Ce(le.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:u("maintenance.documentationLink")}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Ae,{size:"sm",onClick:xe,disabled:!$.trim(),children:u("common.save")}),a.jsx(Ae,{size:"sm",variant:"secondary",onClick:()=>te(null),children:u("common.cancel")})]})]})},B.id);const H=z(B.id),O=X(B.id),J=j===B.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(he,{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:B.name}),a.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-green/20 text-bambu-green text-[10px] font-medium rounded",children:u("maintenance.custom")})]}),a.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[ke==="days"?a.jsx(ti,{className:"w-3 h-3"}):a.jsx(yu,{className:"w-3 h-3"}),Wj(B.default_interval_hours,ke,u)]})]}),a.jsxs("button",{onClick:()=>V(J?null:B.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${H.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:u("maintenance.printersAssignedClick",{count:H.length}),children:[a.jsx(Ur,{className:"w-3 h-3"}),a.jsx("span",{className:"text-xs font-medium",children:H.length}),a.jsx(Kr,{className:`w-3 h-3 transition-transform ${J?"rotate-180":""}`})]}),a.jsx("button",{onClick:()=>Fe(B),disabled:!c("maintenance:update"),title:c("maintenance:update")?void 0:u("maintenance.noPermissionEditTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors ${c("maintenance:update")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(am,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>{confirm(u("maintenance.deleteTypeConfirm",{name:B.name}))&&s(B.id)},disabled:!c("maintenance:delete"),title:c("maintenance:delete")?void 0:u("maintenance.noPermissionDeleteTypes"),className:`p-2 rounded-lg hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors ${c("maintenance:delete")?"":"opacity-50 cursor-not-allowed"}`,children:a.jsx(an,{className:"w-4 h-4"})})]}),J&&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:u("maintenance.assignedToPrinters")}),H.length===0?a.jsx("p",{className:"text-xs text-orange-400",children:u("maintenance.noPrintersAssigned")}):a.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:H.map(le=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[le.printerName,a.jsx("button",{onClick:()=>le.itemId&&l(le.itemId),disabled:!c("maintenance:delete"),title:c("maintenance:delete")?u("maintenance.removeFromPrinter"):u("maintenance.noPermissionRemovePrinter"),className:`ml-1 ${c("maintenance:delete")?"hover:text-red-400":"opacity-50 cursor-not-allowed"}`,children:"×"})]},le.printerId))}),O.length>0&&a.jsxs("div",{className:"flex flex-wrap gap-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:u("maintenance.addPrinterShort")}),O.map(le=>a.jsxs("button",{onClick:()=>o(le.id,B.id),disabled:!c("maintenance:create"),title:c("maintenance:create")?void 0:u("maintenance.noPermissionAssignPrinter"),className:`px-2 py-1 bg-bambu-dark rounded text-xs transition-colors ${c("maintenance:create")?"hover:bg-bambu-green/20 text-bambu-gray hover:text-bambu-green":"opacity-50 cursor-not-allowed text-bambu-gray"}`,children:["+ ",le.name]},le.id))]})]})]},B.id)})]})]}),de.length>0&&a.jsxs("div",{children:[a.jsxs("div",{className:"mb-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white",children:u("maintenance.intervalOverrides")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:u("maintenance.intervalOverridesDescription")})]}),a.jsx("div",{className:"space-y-4",children:de.map(B=>a.jsx(St,{children:a.jsxs(Nt,{className:"py-4",children:[a.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:B.printerName}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:B.items.map(he=>{const ke=B0(he.maintenance_type_icon),pe=e.find(Se=>Se.id===he.maintenance_type_id),H=pe?.default_interval_hours||he.interval_hours,O=pe?.interval_type||"hours",J=he.interval_type||"hours",le=d===he.id;return a.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[a.jsx(ke,{className:"w-4 h-4 text-bambu-gray shrink-0"}),a.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:he.maintenance_type_name}),le?a.jsxs("div",{className:"flex items-center gap-1",children:[x==="days"?a.jsx(ti,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):a.jsx(yu,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),a.jsxs("select",{value:x,onChange:Se=>y(Se.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:u("maintenance.printHours")}),a.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]}),a.jsx("input",{type:"number",value:p,onChange:Se=>m(Se.target.value),onKeyDown:Se=>{Se.key==="Enter"&&Ze(he.id,H,O),Se.key==="Escape"&&h(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(Ae,{size:"sm",onClick:()=>Ze(he.id,H,O),children:"OK"})]}):a.jsxs("button",{onClick:()=>{c("maintenance:update")&&(h(he.id),m(he.interval_hours.toString()),y(J))},disabled:!c("maintenance:update"),title:c("maintenance:update")?void 0:u("maintenance.noPermissionEditIntervals"),className:`px-2 py-1 bg-bambu-dark-tertiary border border-bambu-dark-tertiary rounded text-xs font-medium text-white transition-colors flex items-center gap-1 ${c("maintenance:update")?"hover:bg-bambu-dark-secondary hover:border-bambu-green":"opacity-50 cursor-not-allowed"}`,children:[J==="days"?a.jsx(ti,{className:"w-3 h-3"}):a.jsx(yu,{className:"w-3 h-3"}),Wj(he.interval_hours,J,u),a.jsx(am,{className:"w-3 h-3 text-bambu-gray"})]})]},he.id)})})]})},B.printerId))})]}),de.length===0&&a.jsx(St,{children:a.jsxs(Nt,{className:"text-center py-12",children:[a.jsx(tr,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),a.jsx("p",{className:"text-bambu-gray",children:u("common.noPrinters")}),a.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:u("maintenance.intervalOverridesDescription")})]})})]})}function oXe(){const{t}=On(),e=sn(),{showToast:n}=Hn(),{hasPermission:r}=Ci(),[i,s]=_.useState("status"),{data:o,isLoading:l}=ct({queryKey:["maintenanceOverview"],queryFn:oe.getMaintenanceOverview}),{data:c}=ct({queryKey:["maintenanceTypes"],queryFn:oe.getMaintenanceTypes}),u=gt({mutationFn:({id:k,notes:C})=>oe.performMaintenance(k,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.maintenanceComplete"))},onError:k=>{n(k.message,"error")}}),d=gt({mutationFn:({id:k,data:C})=>oe.updateMaintenanceItem(k,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:k=>{n(k.message,"error")}}),h=gt({mutationFn:({id:k,data:C})=>oe.updateMaintenanceType(k,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onError:k=>{n(k.message,"error")}}),p=gt({mutationFn:oe.deleteMaintenanceType,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeDeleted"))},onError:k=>{n(k.message,"error")}}),m=gt({mutationFn:({printerId:k,hours:C})=>oe.setPrinterHours(k,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.printHoursUpdated"))},onError:k=>{n(k.message,"error")}}),x=gt({mutationFn:({printerId:k,typeId:C})=>oe.assignMaintenanceType(k,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerAssigned"))},onError:k=>{n(k.message,"error")}}),y=gt({mutationFn:oe.removeMaintenanceItem,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerRemoved"))},onError:k=>{n(k.message,"error")}}),v=k=>{u.mutate({id:k})},b=(k,C)=>{d.mutate({id:k,data:{enabled:C}})},S=(k,C)=>{m.mutate({printerId:k,hours:C})};if(l)return a.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:a.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})});const N=o?.reduce((k,C)=>k+C.due_count,0)||0,T=o?.reduce((k,C)=>k+C.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:t("maintenance.title")}),a.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:i==="status"?a.jsxs(a.Fragment,{children:[N>0&&a.jsx("span",{className:"text-red-400",children:t("maintenance.dueCount",{count:N})}),N>0&&T>0&&" · ",T>0&&a.jsx("span",{className:"text-amber-400",children:t("maintenance.warningCount",{count:T})}),N===0&&T===0&&a.jsx("span",{className:"text-bambu-green",children:t("maintenance.allOk")})]}):t("maintenance.configureSettings")})]}),a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[a.jsx("button",{onClick:()=>s("status"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i==="status"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.statusTab")}),a.jsx("button",{onClick:()=>s("settings"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${i==="settings"?"text-bambu-green border-bambu-green":"text-bambu-gray border-transparent hover:text-white"}`,children:t("maintenance.settingsTab")})]}),i==="status"?a.jsx("div",{className:"space-y-6",children:o&&o.length>0?[...o].sort((k,C)=>{const E=k.due_count*10+k.warning_count,P=C.due_count*10+C.warning_count;return E!==P?P-E:k.printer_name.localeCompare(C.printer_name)}).map(k=>a.jsx(aXe,{overview:k,onPerform:v,onToggle:b,onSetHours:S,hasPermission:r,t},k.printer_id)):a.jsx(St,{children:a.jsxs(Nt,{className:"text-center py-16",children:[a.jsx(cm,{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:t("common.noPrinters")}),a.jsx("p",{className:"text-bambu-gray",children:t("maintenance.configureSettings")})]})})}):a.jsx(sXe,{overview:o,types:c||[],onUpdateInterval:(k,C)=>d.mutate({id:k,data:C}),onAddType:async(k,C)=>{const E=await oe.createMaintenanceType(k);for(const P of C)await oe.assignMaintenanceType(P,E.id);e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onUpdateType:(k,C)=>h.mutate({id:k,data:C}),onDeleteType:k=>p.mutate(k),onAssignType:(k,C)=>x.mutate({printerId:k,typeId:C}),onRemoveItem:k=>y.mutate(k),hasPermission:r,t})]})}const Nq=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function Qre({project:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=_.useState(t?.name||""),[l,c]=_.useState(t?.description||""),[u,d]=_.useState(t?.color||Nq[0]),[h,p]=_.useState(t?.target_count?.toString()||""),[m,x]=_.useState(t?.target_parts_count?.toString()||""),[y,v]=_.useState(t?.status||"active"),[b,S]=_.useState(t?.tags||""),[N,T]=_.useState(t?.due_date?.split("T")[0]||""),[k,C]=_.useState(t?.priority||"normal"),E=P=>{P.preventDefault(),n({name:s.trim(),description:l.trim()||void 0,color:u,target_count:h?parseInt(h,10):void 0,target_parts_count:m?parseInt(m,10):void 0,tags:b.trim()||void 0,due_date:N||void 0,priority:k,...t&&{status:y}})};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:i(t?"projects.editProject":"projects.newProject")})}),a.jsxs("form",{onSubmit:E,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:i("common.name")}),a.jsx("input",{type:"text",value:s,onChange:P=>o(P.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:i("projects.namePlaceholder"),required:!0})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.description")}),a.jsx("textarea",{value:l,onChange:P=>c(P.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:i("projects.descriptionPlaceholder"),rows:2})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.color")}),a.jsx("div",{className:"flex gap-2 flex-wrap",children:Nq.map(P=>a.jsx("button",{type:"button",onClick:()=>d(P),className:`w-8 h-8 rounded-full transition-transform ${u===P?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:P}},P))})]}),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:i("projects.targetPlates")}),a.jsx("input",{type:"number",value:h,onChange:P=>p(P.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:i("projects.targetPlatesPlaceholder"),min:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPlatesHelp")})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetParts")}),a.jsx("input",{type:"number",value:m,onChange:P=>x(P.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:i("projects.targetPartsPlaceholder"),min:"1"}),a.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPartsHelp")})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.tagsLabel")}),a.jsx("input",{type:"text",value:b,onChange:P=>S(P.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:i("projects.tagsPlaceholder")})]}),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:i("projects.dueDate")}),a.jsx("input",{type:"date",value:N,onChange:P=>T(P.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:i("projects.priority")}),a.jsxs("select",{value:k,onChange:P=>C(P.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:i("projects.priorityLow")}),a.jsx("option",{value:"normal",children:i("projects.priorityNormal")}),a.jsx("option",{value:"high",children:i("projects.priorityHigh")}),a.jsx("option",{value:"urgent",children:i("projects.priorityUrgent")})]})]})]}),t&&a.jsxs("div",{children:[a.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.status")}),a.jsxs("select",{value:y,onChange:P=>v(P.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:i("projects.statusActive")}),a.jsx("option",{value:"completed",children:i("projects.statusCompleted")}),a.jsx("option",{value:"archived",children:i("projects.statusArchived")})]})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Ae,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Ae,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):i(t?"common.save":"projects.create")})]})]})]})})}function lXe({project:t,onClick:e,onEdit:n,onDelete:r,hasPermission:i,t:s}){const o=t.target_count?Math.round(t.archive_count/t.target_count*100):0,l=t.target_parts_count?Math.round(t.completed_count/t.target_parts_count*100):0,c=t.status==="completed",u=t.status==="archived",[d,h]=_.useState(!1),m=c?{icon:lM,color:"text-bambu-green",bg:"bg-bambu-green/10"}:u?{icon:go,color:"text-bambu-gray",bg:"bg-bambu-gray/10"}:t.queue_count>0?{icon:tr,color:"text-blue-400",bg:"bg-blue-400/10"}:{icon:es,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 ${m.bg} flex-shrink-0`,children:a.jsx(m.icon,{className:`w-5 h-5 ${m.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 ${l>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.completed_count,"/",t.target_parts_count," ",s("projects.parts")]}):t.target_count?a.jsxs("span",{className:`text-xs px-2 py-0.5 rounded-full whitespace-nowrap font-medium ${o>=100?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray"}`,children:[t.archive_count,"/",t.target_count," ",s("projects.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," ",s("projects.parts")]}):null,c&&a.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.done")}),u&&a.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:s("projects.statusArchived")})]}),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 x=t.archives.map(S=>S.filament_type).filter(Boolean).flatMap(S=>S.split(",").map(N=>N.trim())).filter(Boolean),y=[...new Set(x)],v=t.archives.map(S=>S.filament_color).filter(Boolean).flatMap(S=>S.split(",").map(N=>N.trim())).filter(S=>S.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(S)),b=[...new Set(v)];return y.length===0&&b.length===0?null:a.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[y.slice(0,3).map(S=>a.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:S},S)),b.length>0&&a.jsxs("div",{className:"flex items-center gap-0.5",children:[b.slice(0,5).map(S=>a.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:S.startsWith("#")?S:`#${S}`},title:S},S)),b.length>5&&a.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",b.length-5]})]})]})})()]})]}),a.jsxs("div",{className:"relative",onClick:x=>x.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:()=>h(!d),children:a.jsx(ah,{className:"w-4 h-4"})}),d&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>h(!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 flex items-center gap-2 ${i("projects:update")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:update")&&(n(),h(!1))},disabled:!i("projects:update"),title:i("projects:update")?void 0:s("projects.noEditPermission"),children:[a.jsx(am,{className:"w-4 h-4"}),s("common.edit")]}),a.jsxs("button",{className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 ${i("projects:delete")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{i("projects:delete")&&(r(),h(!1))},disabled:!i("projects:delete"),title:i("projects:delete")?void 0:s("projects.noDeletePermission"),children:[a.jsx(an,{className:"w-4 h-4"}),s("common.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:s("projects.plates")}),a.jsxs("span",{className:o>=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(o,100)}%`,background:o>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${o>=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:s("projects.parts")}),a.jsxs("span",{className:l>=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(l,100)}%`,background:l>=100?"linear-gradient(90deg, #22c55e, #4ade80)":`linear-gradient(90deg, ${t.color||"#6b7280"}, ${t.color||"#6b7280"}cc)`,boxShadow:`0 0 8px ${l>=100?"#22c55e":t.color||"#6b7280"}60`}})})]}),t.failed_count>0&&a.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," ",s("projects.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(go,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.completed_count," ",s("projects.completed")]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[a.jsx(Sn,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.failed_count," ",s("projects.failed")]})]}),t.queue_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[a.jsx(tr,{className:"w-3.5 h-3.5"}),a.jsxs("span",{children:[t.queue_count," ",s("projects.inQueue")]})]})]}):a.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:s("projects.noPrintsYet")})}),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(x=>a.jsxs("div",{className:"relative aspect-square rounded-lg bg-bambu-dark overflow-hidden border border-bambu-dark-tertiary",title:x.print_name||"Unknown",children:[x.thumbnail_path?a.jsx("img",{src:oe.getArchiveThumbnail(x.id),alt:x.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(bc,{className:"w-6 h-6"})}),x.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:a.jsx(Sn,{className:"w-4 h-4 text-white"})})]},x.id))}),t.archive_count>4&&a.jsx("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:s("common.more",{count:t.archive_count-4})})]}),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:s("projects.printJobs"),children:[a.jsx(xs,{className:"w-3.5 h-3.5 text-blue-400"}),a.jsxs("span",{children:[t.archive_count," ",s("projects.plates")]})]}),a.jsxs("div",{className:"flex items-center gap-1.5",title:s("projects.partsPrinted"),children:[a.jsx(bc,{className:"w-3.5 h-3.5 text-bambu-green"}),a.jsxs("span",{children:[t.completed_count," ",s("projects.parts")]})]}),t.failed_count>0&&a.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:s("projects.failedParts"),children:[a.jsx(Sn,{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:s("projects.inQueue"),children:[a.jsx(gP,{className:"w-3.5 h-3.5"}),a.jsx("span",{children:t.queue_count})]})]}),a.jsx(vs,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function cXe(){const{t}=On(),e=Tc(),n=sn(),{showToast:r}=Hn(),{hasPermission:i}=Ci(),[s,o]=_.useState(!1),[l,c]=_.useState(),[u,d]=_.useState("active"),[h,p]=_.useState(null),{data:m,isLoading:x}=ct({queryKey:["projects",u==="all"?void 0:u],queryFn:()=>oe.getProjects(u==="all"?void 0:u)}),y=gt({mutationFn:U=>oe.createProject(U),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),r(t("projects.toast.created"),"success")},onError:U=>{r(U.message,"error")}}),v=gt({mutationFn:({id:U,data:j})=>oe.updateProject(U,j),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),c(void 0),r(t("projects.toast.updated"),"success")},onError:U=>{r(U.message,"error")}}),b=gt({mutationFn:U=>oe.deleteProject(U),onSuccess:()=>{p(null),r(t("projects.toast.deleted"),"success"),setTimeout(()=>window.location.reload(),100)},onError:U=>{p(null),r(U.message,"error")}}),S=gt({mutationFn:U=>oe.importProject(U),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success")},onError:U=>{r(U.message,"error")}}),N=_.useRef(null),T=async()=>{try{const U=await oe.getProjects(),j=await Promise.all(U.map(async X=>await oe.exportProjectJson(X.id))),V=new Blob([JSON.stringify(j,null,2)],{type:"application/json"}),K=URL.createObjectURL(V),z=document.createElement("a");z.href=K,z.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,z.click(),URL.revokeObjectURL(K),r(t("projects.toast.exported"),"success")}catch(U){r(U.message,"error")}},k=()=>{N.current?.click()},C=async U=>{const j=U.target.files?.[0];if(j){try{if(j.name.toLowerCase().endsWith(".zip"))await oe.importProjectFile(j),n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success");else{const K=await j.text(),z=JSON.parse(K),X=Array.isArray(z)?z:[z];for(const Y of X)await S.mutateAsync(Y);X.length>1&&r(t("projects.toast.multipleImported",{count:X.length}),"success")}}catch(V){r(`${t("projects.toast.importFailed")}: ${V.message}`,"error")}U.target.value=""}},E=U=>{l?v.mutate({id:l.id,data:U}):y.mutate(U)},P=U=>{c(U),o(!0)},A=U=>{e(`/projects/${U.id}`)},D=U=>{p(U)},I=()=>{h!==null&&b.mutate(h)},L=m?.reduce((U,j)=>(U[j.status]=(U[j.status]||0)+1,U.all=(U.all||0)+1,U),{})||{};return a.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[a.jsx("input",{ref:N,type:"file",accept:".json,.zip",onChange:C,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(es,{className:"w-6 h-6 text-bambu-green"})}),t("projects.title")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("projects.subtitle")})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ae,{variant:"secondary",onClick:k,disabled:!i("projects:create"),title:i("projects:create")?t("projects.importProject"):t("projects.noImportPermission"),children:[a.jsx(Ba,{className:"w-4 h-4 mr-2"}),t("projects.import")]}),a.jsxs(Ae,{variant:"secondary",onClick:T,disabled:!i("projects:read"),title:i("projects:read")?t("projects.exportAll"):t("projects.noExportPermission"),children:[a.jsx(wi,{className:"w-4 h-4 mr-2"}),t("projects.export")]}),a.jsxs(Ae,{onClick:()=>o(!0),className:"sm:w-auto w-full",disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(fr,{className:"w-4 h-4 mr-2"}),t("projects.newProject")]})]})]}),a.jsx("div",{className:"flex gap-1 p-1 bg-bambu-dark rounded-xl w-fit",children:[{key:"active",label:t("projects.statusActive"),icon:tr},{key:"completed",label:t("projects.statusCompleted"),icon:lM},{key:"archived",label:t("projects.statusArchived"),icon:go},{key:"all",label:t("common.all"),icon:es}].map(({key:U,label:j,icon:V})=>a.jsxs("button",{onClick:()=>d(U),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${u===U?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[a.jsx(V,{className:"w-4 h-4"}),a.jsx("span",{children:j}),L[U]>0&&a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${u===U?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:L[U]})]},U))}),x?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(pt,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("projects.loading")})]})}):m?.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(es,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:u==="all"?t("projects.noProjects"):t("projects.noProjectsFiltered",{status:u})}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:u==="all"?t("projects.createFirst"):t("projects.noProjectsFilteredHelp",{status:u})}),u==="all"&&a.jsxs(Ae,{onClick:()=>o(!0),disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[a.jsx(fr,{className:"w-4 h-4 mr-2"}),t("projects.createFirstButton")]})]}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:m?.map(U=>a.jsx(lXe,{project:U,onClick:()=>A(U),onEdit:()=>P(U),onDelete:()=>D(U.id),hasPermission:i,t},U.id))}),h!==null&&a.jsx(Zn,{title:t("projects.deleteProject"),message:t("projects.deleteConfirm"),confirmText:t("projects.deleteProject"),variant:"danger",onConfirm:I,onCancel:()=>p(null)}),s&&a.jsx(Qre,{project:l,onClose:()=>{o(!1),c(void 0)},onSave:E,isLoading:y.isPending||v.isPending,t})]})}function uXe(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 dXe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function hXe({status:t,t:e}){const n={active:"bg-bambu-green/20 text-bambu-green",completed:"bg-blue-500/20 text-blue-400",archived:"bg-bambu-gray/20 text-bambu-gray"},r=n[t]||n.active,i={active:e("projectDetail.status.active"),completed:e("projectDetail.status.completed"),archived:e("projectDetail.status.archived")};return a.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${r}`,children:i[t]||t.charAt(0).toUpperCase()+t.slice(1)})}function Mq({icon:t,label:e,value:n,subValue:r,hint:i,color:s="text-bambu-gray"}){return a.jsx(St,{children:a.jsx(Nt,{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 fXe({archives:t,t:e}){return t.length===0?a.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[a.jsx(bc,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),a.jsx("p",{children:e("projectDetail.noPrints")})]}):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(n=>a.jsxs(Fs,{to:`/archives?search=${encodeURIComponent(n.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:[n.thumbnail_path?a.jsx("img",{src:oe.getArchiveThumbnail(n.id),alt:n.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(bc,{className:"w-8 h-8"})}),n.status==="failed"&&a.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:a.jsx(Ji,{className:"w-8 h-8 text-white"})}),n.status==="completed"&&a.jsx("div",{className:"absolute top-1 right-1",children:a.jsx(Ar,{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:n.print_name||"Unknown"})})]},n.id))})}function mXe({priority:t,t:e}){const n={low:{color:"bg-gray-500/20 text-gray-400",label:e("projectDetail.priority.low")},normal:{color:"bg-blue-500/20 text-blue-400",label:e("projectDetail.priority.normal")},high:{color:"bg-orange-500/20 text-orange-400",label:e("projectDetail.priority.high")},urgent:{color:"bg-red-500/20 text-red-400",label:e("projectDetail.priority.urgent")}},{color:r,label:i}=n[t]||n.normal;return a.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${r}`,children:[t==="urgent"&&a.jsx(Sn,{className:"w-3 h-3"}),i]})}function pXe(t){return t?$g(t,{year:"numeric",month:"short",day:"numeric"}):""}function Kj(t,e){if(!t)return null;const n=zi(t);if(!n)return null;const r=new Date,i=Math.ceil((n.getTime()-r.getTime())/(1e3*60*60*24));return i<0?{color:"text-red-400",label:e("projectDetail.dueDate.overdue")}:i===0?{color:"text-orange-400",label:e("projectDetail.dueDate.today")}:i<=3?{color:"text-yellow-400",label:e("projectDetail.dueDate.daysLeft",{count:i})}:{color:"text-bambu-gray",label:e("projectDetail.dueDate.daysLeft",{count:i})}}function gXe(){const{id:t}=aM(),e=Tc(),{t:n}=On(),r=sn(),{showToast:i}=Hn(),{hasPermission:s}=Ci(),[o,l]=_.useState(!1),[c,u]=_.useState(!1),[d,h]=_.useState(""),p=parseInt(t||"0",10),{data:m,isLoading:x,error:y}=ct({queryKey:["project",p],queryFn:()=>oe.getProject(p),enabled:p>0}),{data:v,isLoading:b}=ct({queryKey:["project-archives",p],queryFn:()=>oe.getProjectArchives(p),enabled:p>0}),{data:S,isLoading:N}=ct({queryKey:["project-bom",p],queryFn:()=>oe.getProjectBOM(p),enabled:p>0}),{data:T,isLoading:k}=ct({queryKey:["project-timeline",p],queryFn:()=>oe.getProjectTimeline(p,20),enabled:p>0}),{data:C}=ct({queryKey:["settings"],queryFn:oe.getSettings}),{data:E}=ct({queryKey:["project-folders",p],queryFn:()=>oe.getLibraryFoldersByProject(p),enabled:p>0}),P=C?.currency||"$",A=C?.time_format||"system",D=gt({mutationFn:_e=>oe.updateProject(p,_e),onSuccess:()=>{r.invalidateQueries({queryKey:["project",p]}),r.invalidateQueries({queryKey:["projects"]}),l(!1),u(!1),i(n("projectDetail.toast.projectUpdated"),"success")},onError:_e=>{i(_e.message,"error")}}),I=()=>{h(m?.notes||""),u(!0)},L=()=>{D.mutate({notes:d})},U=()=>{u(!1),h("")},[j,V]=_.useState(""),[K,z]=_.useState(1),[X,Y]=_.useState(""),[te,$]=_.useState(""),[W,ne]=_.useState(""),[re,ge]=_.useState(!1),[me,ue]=_.useState(!1),[Te,ie]=_.useState(null),[Ce,Fe]=_.useState(""),[xe,Ze]=_.useState(1),[G,Q]=_.useState(""),[de,q]=_.useState(""),[ee,B]=_.useState(""),[he,ke]=_.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),pe=gt({mutationFn:_e=>oe.createBOMItem(p,_e),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),V(""),z(1),Y(""),$(""),ne(""),ge(!1),i(n("projectDetail.toast.partAdded"),"success")},onError:_e=>i(_e.message,"error")}),H=gt({mutationFn:({itemId:_e,data:Ke})=>oe.updateBOMItem(p,_e,Ke),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),ie(null)},onError:_e=>i(_e.message,"error")}),O=gt({mutationFn:_e=>oe.deleteBOMItem(p,_e),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),i(n("projectDetail.toast.partRemoved"),"success")},onError:_e=>i(_e.message,"error")}),J=_e=>{_e.preventDefault(),j.trim()&&pe.mutate({name:j.trim(),quantity_needed:K,unit_price:X?parseFloat(X):void 0,sourcing_url:te.trim()||void 0,remarks:W.trim()||void 0})},le=_e=>{const Ke=_e.is_complete?0:_e.quantity_needed;H.mutate({itemId:_e.id,data:{quantity_acquired:Ke}})},Se=(_e,Ke)=>{ke({isOpen:!0,title:n("projectDetail.bom.deletePart"),message:n("projectDetail.bom.deleteConfirm",{name:Ke}),onConfirm:()=>{ke(Me=>({...Me,isOpen:!1})),O.mutate(_e)}})},we=_e=>{ie(_e),Fe(_e.name),Ze(_e.quantity_needed),Q(_e.unit_price?.toString()||""),q(_e.sourcing_url||""),B(_e.remarks||"")},ae=_e=>{_e.preventDefault(),!(!Te||!Ce.trim())&&H.mutate({itemId:Te.id,data:{name:Ce.trim(),quantity_needed:xe,unit_price:G?parseFloat(G):void 0,sourcing_url:de.trim()||void 0,remarks:ee.trim()||void 0}})},Le=()=>{ie(null)},Be=async()=>{try{const{blob:_e,filename:Ke}=await oe.exportProjectZip(Number(p)),Me=URL.createObjectURL(_e),it=document.createElement("a");it.href=Me,it.download=Ke||`${m?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,it.click(),URL.revokeObjectURL(Me),i(n("projectDetail.toast.projectExported"),"success")}catch(_e){i(_e.message,"error")}},Ve=gt({mutationFn:()=>oe.createTemplateFromProject(p),onSuccess:()=>{r.invalidateQueries({queryKey:["projects"]}),i(n("projectDetail.toast.templateCreated"),"success")},onError:_e=>i(_e.message,"error")}),He=_e=>Vg(_e,A,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(x)return a.jsx("div",{className:"flex items-center justify-center py-24",children:a.jsx(pt,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(y||!m)return a.jsxs("div",{className:"text-center py-24",children:[a.jsx("p",{className:"text-bambu-gray",children:y?`${n("common.error")}: ${y.message}`:n("projectDetail.notFound")}),a.jsx(Ae,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:n("projectDetail.backToProjects")})]});const be=m.stats,Pe=be?.progress_percent??0,Ie=be?.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(Fs,{to:"/projects",className:"hover:text-white transition-colors",children:n("navigation.projects")}),a.jsx(vs,{className:"w-4 h-4"}),a.jsx("span",{className:"text-white",children:m.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(wce,{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:m.color||"#6b7280"}}),a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl font-bold text-white",children:m.name}),m.description&&a.jsx("p",{className:"text-bambu-gray mt-1",children:m.description})]})]}),a.jsx(hXe,{status:m.status,t:n})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ae,{variant:"secondary",onClick:Be,disabled:!s("projects:read"),title:s("projects:read")?n("projectDetail.exportProject"):n("projectDetail.noExportPermission"),children:[a.jsx(wi,{className:"w-4 h-4 mr-2"}),n("projectDetail.export")]}),a.jsxs(Ae,{onClick:()=>l(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.noEditPermission"),children:[a.jsx(am,{className:"w-4 h-4 mr-2"}),n("common.edit")]})]})]}),(m.target_count||m.target_parts_count)&&a.jsx(St,{children:a.jsxs(Nt,{className:"p-4 space-y-4",children:[m.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:n("projectDetail.progress.platesProgress")}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[be?.total_archives||0," / ",m.target_count," ",n("projectDetail.progress.printJobs")]})]}),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(Pe,100)}%`,backgroundColor:Pe>=100?"#22c55e":m.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:Pe.toFixed(0)})}),be?.remaining_prints!=null&&be.remaining_prints>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:be.remaining_prints})})]})]}),m.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:n("projectDetail.progress.partsProgress")}),a.jsxs("span",{className:"text-sm font-medium text-white",children:[be?.completed_prints||0," / ",m.target_parts_count," ",n("projectDetail.progress.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(Ie,100)}%`,backgroundColor:Ie>=100?"#22c55e":m.color||"#6b7280"}})}),a.jsxs("div",{className:"flex justify-between mt-1",children:[a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:Ie.toFixed(0)})}),be?.remaining_parts!=null&&be.remaining_parts>0&&a.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:be.remaining_parts})})]})]})]})}),be&&a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(St,{children:a.jsx(Nt,{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(bc,{className:"w-5 h-5"})}),a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.printJobs")}),a.jsxs("p",{className:"text-xl font-semibold text-white",children:[be.total_archives," ",a.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:n("projectDetail.stats.total")})]}),be.failed_prints>0&&a.jsx("p",{className:"text-sm text-status-error",children:n("projectDetail.stats.failed",{count:be.failed_prints})}),a.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.partsPrinted",{count:be.completed_prints})})]})]})})}),a.jsx(Mq,{icon:tr,label:n("projectDetail.stats.printTime"),value:uXe(be.total_print_time_hours),color:"text-yellow-400"}),a.jsx(Mq,{icon:Ur,label:n("projectDetail.stats.filamentUsed"),value:dXe(be.total_filament_grams),color:"text-purple-400"})]}),be&&(be.estimated_cost>0||m.budget)&&a.jsx(St,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:n("projectDetail.cost.title")}),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:n("projectDetail.cost.filamentCost")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[P,be.estimated_cost.toFixed(2)]})]}),be.total_energy_kwh>0&&a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.energy")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[be.total_energy_kwh.toFixed(2)," kWh",be.total_energy_cost>0&&a.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",P,be.total_energy_cost.toFixed(2),")"]})]})]}),m.budget&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.budget")}),a.jsxs("p",{className:"text-lg font-semibold text-white",children:[P,m.budget.toFixed(2)]})]}),a.jsxs("div",{children:[a.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.remaining")}),a.jsxs("p",{className:`text-lg font-semibold ${m.budget-be.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[P,(m.budget-be.estimated_cost).toFixed(2)]})]})]})]})]})}),m.children&&m.children.length>0&&a.jsx(St,{children:a.jsxs(Nt,{className:"p-4",children:[a.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[a.jsx(Zue,{className:"w-5 h-5"}),n("projectDetail.subProjects.title",{count:m.children.length})]}),a.jsx("div",{className:"space-y-2",children:m.children.map(_e=>a.jsxs(Fs,{to:`/projects/${_e.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:_e.color||"#6b7280"}}),a.jsx("span",{className:"text-white",children:_e.name}),a.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${_e.status==="completed"?"bg-status-ok/20 text-status-ok":_e.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:_e.status})]}),_e.progress_percent!==null&&a.jsxs("span",{className:"text-sm text-bambu-gray",children:[_e.progress_percent.toFixed(0),"%"]})]},_e.id))})]})}),m.parent_id&&m.parent_name&&a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(xs,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.partOf")}),a.jsx(Fs,{to:`/projects/${m.parent_id}`,className:"text-bambu-green hover:underline",children:m.parent_name})]}),(m.tags||m.due_date||m.priority!=="normal")&&a.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[m.priority&&m.priority!=="normal"&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.priorityLabel")}),a.jsx(mXe,{priority:m.priority,t:n})]}),m.due_date&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(ti,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("span",{className:"text-sm text-white",children:pXe(m.due_date)}),Kj(m.due_date,n)&&a.jsxs("span",{className:`text-xs ${Kj(m.due_date,n).color}`,children:["(",Kj(m.due_date,n).label,")"]})]}),m.tags&&a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(wh,{className:"w-4 h-4 text-bambu-gray"}),a.jsx("div",{className:"flex flex-wrap gap-1",children:m.tags.split(",").map((_e,Ke)=>a.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:_e.trim()},Ke))})]})]}),a.jsx(St,{children:a.jsxs(Nt,{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(fs,{className:"w-5 h-5"}),n("projectDetail.notes.title")]}),c?a.jsxs("div",{className:"flex gap-2",children:[a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:U,disabled:D.isPending,children:[a.jsx(Lt,{className:"w-4 h-4 mr-1"}),n("common.cancel")]}),a.jsxs(Ae,{size:"sm",onClick:L,disabled:D.isPending,children:[D.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin mr-1"}):a.jsx(ms,{className:"w-4 h-4 mr-1"}),n("common.save")]})]}):a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:I,disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.notes.noEditPermission"),children:[a.jsx(am,{className:"w-4 h-4 mr-1"}),n("common.edit")]})]}),c?a.jsx(aR,{content:d,onChange:h,placeholder:n("projectDetail.notes.placeholder")}):m.notes?a.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:m.notes}}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.notes.empty")})]})}),a.jsx(St,{children:a.jsxs(Nt,{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(zl,{className:"w-5 h-5"}),n("projectDetail.files.title")]})}),a.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[a.jsx(Fs,{to:"/files",className:"text-bambu-green hover:underline",children:n("projectDetail.files.linkFolders")})," ",n("projectDetail.files.forQuickAccess")]}),E&&E.length>0?a.jsx("div",{className:"space-y-2",children:E.map(_e=>a.jsxs(Fs,{to:`/files?folder=${_e.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(zl,{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:_e.name}),a.jsx("p",{className:"text-xs text-bambu-gray",children:n("projectDetail.files.fileCount",{count:_e.file_count})})]})]}),a.jsx(vs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},_e.id))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.files.empty")})]})}),a.jsx(St,{children:a.jsxs(Nt,{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(RW,{className:"w-5 h-5"}),n("projectDetail.bom.title"),be&&be.bom_total_items>0&&a.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",n("projectDetail.bom.acquired",{completed:be.bom_completed_items,total:be.bom_total_items}),")"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[S&&S.some(_e=>_e.is_complete)&&a.jsx("button",{onClick:()=>ue(!me),className:`text-xs px-2 py-1 rounded transition-colors ${me?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:n(me?"projectDetail.bom.showAll":"projectDetail.bom.hideDone")}),!re&&a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:()=>ge(!0),disabled:!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noAddPermission"),children:[a.jsx(fr,{className:"w-4 h-4 mr-1"}),n("projectDetail.bom.addPart")]})]})]}),re&&a.jsxs("form",{onSubmit:J,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:j,onChange:_e=>V(_e.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:n("projectDetail.bom.partNamePlaceholder"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:K,onChange:_e=>z(parseInt(_e.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:n("projectDetail.bom.qty")}),a.jsx("input",{type:"number",step:"0.01",value:X,onChange:_e=>Y(_e.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:n("projectDetail.bom.price",{currency:P})})]})]}),a.jsx("input",{type:"url",value:te,onChange:_e=>$(_e.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:n("projectDetail.bom.sourcingUrlPlaceholder")}),a.jsx("input",{type:"text",value:W,onChange:_e=>ne(_e.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:n("projectDetail.bom.remarksPlaceholder")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Ae,{type:"button",variant:"secondary",size:"sm",onClick:()=>ge(!1),children:n("common.cancel")}),a.jsx(Ae,{type:"submit",size:"sm",disabled:!j.trim()||pe.isPending,children:pe.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):n("projectDetail.bom.addPart")})]})]}),N?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):S&&S.length>0?a.jsxs("div",{className:"space-y-2",children:[S.filter(_e=>!me||!_e.is_complete).map(_e=>a.jsx("div",{className:`p-3 rounded-lg transition-colors ${_e.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:Te?.id===_e.id?a.jsxs("form",{onSubmit:ae,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:Ce,onChange:Ke=>Fe(Ke.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:n("projectDetail.bom.partName"),autoFocus:!0}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"number",value:xe,onChange:Ke=>Ze(parseInt(Ke.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:n("projectDetail.bom.qty")}),a.jsx("input",{type:"number",step:"0.01",value:G,onChange:Ke=>Q(Ke.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:n("projectDetail.bom.price",{currency:P})})]})]}),a.jsx("input",{type:"url",value:de,onChange:Ke=>q(Ke.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:n("projectDetail.bom.sourcingUrlPlaceholder")}),a.jsx("input",{type:"text",value:ee,onChange:Ke=>B(Ke.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:n("projectDetail.bom.remarksPlaceholder")}),a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Ae,{type:"button",variant:"secondary",size:"sm",onClick:Le,children:n("common.cancel")}),a.jsx(Ae,{type:"submit",size:"sm",disabled:!Ce.trim()||H.isPending,children:H.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):n("common.save")})]})]}):a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("button",{onClick:()=>s("projects:update")&&le(_e),disabled:H.isPending||!s("projects:update"),title:s("projects:update")?void 0:n("projectDetail.bom.noUpdatePermission"),className:`w-5 h-5 mt-0.5 rounded border-2 flex items-center justify-center transition-colors flex-shrink-0 ${_e.is_complete?"bg-status-ok border-status-ok text-white":s("projects:update")?"border-bambu-gray hover:border-bambu-green":"border-bambu-gray/50 cursor-not-allowed"}`,children:_e.is_complete&&a.jsx(Ar,{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 ${_e.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[_e.name,a.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",_e.quantity_needed]})]}),_e.unit_price!==null&&a.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[P,(_e.unit_price*_e.quantity_needed).toFixed(2)]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx("button",{onClick:()=>s("projects:update")&&we(_e),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.edit"):n("projectDetail.bom.noEditPermission"),children:a.jsx(ea,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("projects:update")&&Se(_e.id,_e.name),disabled:!s("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${s("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("projects:update")?n("common.delete"):n("projectDetail.bom.noDeletePermission"),children:a.jsx(an,{className:"w-4 h-4"})})]})]}),_e.sourcing_url&&a.jsxs("a",{href:_e.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:Ke=>Ke.stopPropagation(),children:[a.jsx(Xr,{className:"w-3 h-3 flex-shrink-0"}),a.jsx("span",{className:"truncate",children:(()=>{try{return new URL(_e.sourcing_url).hostname.replace("www.","")}catch{return _e.sourcing_url}})()})]}),_e.remarks&&a.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:_e.remarks})]})]})},_e.id)),S.some(_e=>_e.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:n("projectDetail.bom.totalCost")}),a.jsxs("span",{className:"text-white font-medium",children:[P,S.reduce((_e,Ke)=>_e+(Ke.unit_price||0)*Ke.quantity_needed,0).toFixed(2)]})]})]}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.bom.empty")})]})}),a.jsx(St,{children:a.jsxs(Nt,{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(W0,{className:"w-5 h-5"}),n("projectDetail.timeline.title")]})}),k?a.jsx("div",{className:"flex items-center justify-center py-4",children:a.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):T&&T.length>0?a.jsx("div",{className:"space-y-3",children:T.slice(0,10).map((_e,Ke)=>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 ${_e.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":_e.event_type==="print_failed"?"bg-status-error/20 text-status-error":_e.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[_e.event_type==="print_completed"&&a.jsx(Ar,{className:"w-4 h-4"}),_e.event_type==="print_failed"&&a.jsx(Ji,{className:"w-4 h-4"}),_e.event_type==="print_started"&&a.jsx(Ur,{className:"w-4 h-4"}),_e.event_type==="queued"&&a.jsx(gP,{className:"w-4 h-4"}),_e.event_type==="project_created"&&a.jsx(fr,{className:"w-4 h-4"})]}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("p",{className:"text-sm text-white",children:_e.title}),_e.description&&a.jsx("p",{className:"text-xs text-bambu-gray truncate",children:_e.description}),a.jsx("p",{className:"text-xs text-bambu-gray/70",children:He(_e.timestamp)})]})]},Ke))}):a.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.timeline.empty")})]})}),!m.is_template&&a.jsx("div",{className:"flex justify-end",children:a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:()=>Ve.mutate(),disabled:Ve.isPending||!s("projects:create"),title:s("projects:create")?void 0:n("projectDetail.template.noCreatePermission"),children:[Ve.isPending?a.jsx(pt,{className:"w-4 h-4 animate-spin mr-2"}):a.jsx(Ul,{className:"w-4 h-4 mr-2"}),n("projectDetail.template.saveAsTemplate")]})}),be&&(be.queued_prints>0||be.in_progress_prints>0)&&a.jsx(St,{children:a.jsxs(Nt,{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(gP,{className:"w-5 h-5"}),n("projectDetail.queue.title")]}),a.jsx(Fs,{to:`/queue?project=${p}`,className:"text-sm text-bambu-green hover:underline",children:n("projectDetail.queue.viewAll")})]}),a.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[be.in_progress_prints>0&&a.jsx("span",{className:"text-yellow-400",children:n("projectDetail.queue.printing",{count:be.in_progress_prints})}),be.queued_prints>0&&a.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.queue.queued",{count:be.queued_prints})})]})]})}),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(bc,{className:"w-5 h-5"}),n("projectDetail.prints.title",{count:v?.length||0})]})}),b?a.jsx("div",{className:"flex items-center justify-center py-8",children:a.jsx(pt,{className:"w-6 h-6 animate-spin text-bambu-green"})}):a.jsx(fXe,{archives:v||[],t:n})]}),o&&a.jsx(Qre,{t:n,project:{...m,archive_count:be?.total_archives||0,total_items:be?.total_items||0,completed_count:be?.completed_prints||0,failed_count:be?.failed_prints||0,queue_count:be?.queued_prints||0,progress_percent:be?.progress_percent||null,archives:[]},onClose:()=>l(!1),onSave:_e=>D.mutate(_e),isLoading:D.isPending}),he.isOpen&&a.jsx(Zn,{title:he.title,message:he.message,confirmText:n("common.delete"),variant:"danger",onConfirm:he.onConfirm,onCancel:()=>ke(_e=>({..._e,isOpen:!1}))})]})}function fg(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 xXe(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 bXe({parentId:t,onClose:e,onSave:n,isLoading:r,t:i}){const[s,o]=_.useState(""),l=c=>{c.preventDefault(),n({name:s.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:i("fileManager.newFolder")})}),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:i("fileManager.folderName")}),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",placeholder:i("fileManager.folderNamePlaceholder"),autoFocus:!0,required:!0})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Ae,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Ae,{type:"submit",disabled:!s.trim()||r,children:r?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):i("common.create")})]})]})]})})}function yXe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i,t:s}){const[o,l]=_.useState(e),c=u=>{u.preventDefault(),o.trim()&&o.trim()!==e&&r(o.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.jsx("h2",{className:"text-lg font-semibold text-white",children:s(t==="file"?"fileManager.renameFile":"fileManager.renameFolder")})}),a.jsxs("form",{onSubmit:c,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:s("common.name")}),a.jsx("input",{type:"text",value:o,onChange:u=>l(u.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(Ae,{type:"button",variant:"secondary",onClick:n,children:s("common.cancel")}),a.jsx(Ae,{type:"submit",disabled:!o.trim()||o.trim()===e||i,children:i?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):s("common.rename")})]})]})]})})}function vXe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:s,t:o}){const[l,c]=_.useState(null),u=(h,p=0)=>{const m=[];for(const x of h)m.push({id:x.id,name:x.name,depth:p}),x.children.length>0&&m.push(...u(x.children,p+1));return m},d=[{id:null,name:o("fileManager.rootNoFolder"),depth:0},...u(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:o("fileManager.moveFiles",{count:e.length})})}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:d.map(h=>a.jsxs("button",{onClick:()=>c(h.id),disabled:h.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===h.id?"bg-bambu-green/20 text-bambu-green":h.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+h.depth*16}px`},children:[a.jsx(zl,{className:"w-4 h-4"}),h.name,h.id===n&&a.jsxs("span",{className:"text-xs text-bambu-gray ml-auto",children:["(",o("fileManager.current"),")"]})]},h.id??"root"))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[a.jsx(Ae,{type:"button",variant:"secondary",onClick:r,children:o("common.cancel")}),a.jsx(Ae,{onClick:()=>i(l),disabled:s,children:s?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):o("common.move")})]})]})]})})}function wXe({folder:t,onClose:e,onLink:n,isLoading:r,t:i}){const[s,o]=_.useState("project"),[l,c]=_.useState(t.project_id||t.archive_id||null);_.useState(()=>{t.archive_id&&o("archive")});const{data:u}=ct({queryKey:["projects"],queryFn:()=>oe.getProjects()}),{data:d}=ct({queryKey:["archives-for-link"],queryFn:()=>oe.getArchives(void 0,void 0,100)}),h=()=>{n(s==="project"?{project_id:l,archive_id:0}:{project_id:0,archive_id:l})},p=()=>{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(fc,{className:"w-5 h-5 text-bambu-green"}),i("fileManager.linkFolder")]}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Lt,{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:i("fileManager.linkFolderDescription",{name:t.name})}),a.jsxs("div",{className:"flex gap-2",children:[a.jsxs("button",{onClick:()=>{o("project"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${s==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(SW,{className:"w-4 h-4"}),i("fileManager.project")]}),a.jsxs("button",{onClick:()=>{o("archive"),c(null)},className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 rounded-lg border transition-colors ${s==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[a.jsx(go,{className:"w-4 h-4"}),i("fileManager.archive")]})]}),a.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:s==="project"?u&&u.length>0?u.map(x=>a.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.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:x.color||"#00ae42"}}),a.jsx("span",{className:"truncate",children:x.name})]},x.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noProjectsFound")}):d&&d.length>0?d.map(x=>a.jsxs("button",{onClick:()=>c(x.id),className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===x.id?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark-tertiary text-white"}`,children:[a.jsx(Hf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),a.jsx("span",{className:"truncate",children:x.print_name||x.filename})]},x.id)):a.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noArchivesFound")})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[m&&a.jsxs(Ae,{variant:"danger",onClick:p,disabled:r,children:[a.jsx(OR,{className:"w-4 h-4 mr-2"}),i("fileManager.unlink")]}),a.jsxs("div",{className:`flex gap-2 ${m?"":"ml-auto"}`,children:[a.jsx(Ae,{variant:"secondary",onClick:e,children:i("common.cancel")}),a.jsx(Ae,{onClick:h,disabled:!l||r,children:r?a.jsx(pt,{className:"w-4 h-4 animate-spin"}):i("fileManager.link")})]})]})]})})}function _Xe({folderId:t,onClose:e,onUploadComplete:n,t:r}){const[i,s]=_.useState([]),[o,l]=_.useState(!1),[c,u]=_.useState(!1),[d,h]=_.useState(!0),[p,m]=_.useState(!1),[x,y]=_.useState(!0),v=_.useRef(null),b=j=>{j.preventDefault(),l(!0)},S=j=>{j.preventDefault(),l(!1)},N=j=>{j.preventDefault(),l(!1);const V=Array.from(j.dataTransfer.files);k(V)},T=j=>{j.target.files&&k(Array.from(j.target.files))},k=j=>{const V=j.map(K=>({file:K,status:"pending",isZip:K.name.toLowerCase().endsWith(".zip")}));s(K=>[...K,...V])},C=j=>{s(V=>V.filter((K,z)=>z!==j))},E=i.some(j=>j.isZip&&j.status==="pending"),P=i.some(j=>j.file.name.toLowerCase().endsWith(".stl")&&j.status==="pending"),A=async()=>{if(i.length!==0){u(!0);for(let j=0;j<i.length;j++)if(i[j].status==="pending"){s(V=>V.map((K,z)=>z===j?{...K,status:"uploading"}:K));try{if(i[j].isZip){const V=await oe.extractZipFile(i[j].file,t,d,p,x);s(K=>K.map((z,X)=>X===j?{...z,status:V.errors.length>0&&V.extracted===0?"error":"success",extractedCount:V.extracted,error:V.errors.length>0?`${V.errors.length} files failed`:void 0}:z))}else await oe.uploadLibraryFile(i[j].file,t,x),s(V=>V.map((K,z)=>z===j?{...K,status:"success"}:K))}catch(V){s(K=>K.map((z,X)=>X===j?{...z,status:"error",error:V instanceof Error?V.message:"Upload failed"}:z))}}u(!1),n(),e()}},D=i.filter(j=>j.status==="pending").length,I=i.filter(j=>j.status==="success").length,L=i.filter(j=>j.status==="error").length,U=i.length>0&&D===0&&!c;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:r("fileManager.uploadFiles")}),a.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:a.jsx(Lt,{className:"w-5 h-5 text-bambu-gray"})})]}),a.jsxs("div",{className:"p-4 space-y-4",children:[a.jsxs("div",{onDragOver:b,onDragLeave:S,onDrop:N,onClick:()=>v.current?.click(),className:`border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${o?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary hover:border-bambu-green/50"}`,children:[a.jsx(Ba,{className:`w-10 h-10 mx-auto mb-3 ${o?"text-bambu-green":"text-bambu-gray"}`}),a.jsx("p",{className:"text-white font-medium",children:r(o?"fileManager.dropFilesHere":"fileManager.dragDropFiles")}),a.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("fileManager.orClickToBrowse")}),a.jsx("p",{className:"text-xs text-bambu-gray/70 mt-2",children:r("fileManager.allFileTypesSupported")})]}),a.jsx("input",{ref:v,type:"file",multiple:!0,className:"hidden",onChange:T}),E&&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(go,{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:r("fileManager.zipFilesDetected")}),a.jsx("p",{className:"text-xs text-blue-300/70 mt-1",children:r("fileManager.zipExtractOptions")}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:d,onChange:j=>h(j.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:r("fileManager.preserveZipStructure")})]}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:p,onChange:j=>m(j.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:r("fileManager.createFolderFromZip")})]})]})]})}),(P||E)&&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(Lu,{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:r("fileManager.stlThumbnailGeneration")}),a.jsx("p",{className:"text-xs text-bambu-green/70 mt-1",children:r(E&&!P?"fileManager.zipMayContainStl":"fileManager.thumbnailsCanBeGenerated")}),a.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:x,onChange:j=>y(j.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:r("fileManager.generateThumbnailsForStl")})]})]})]})}),i.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:i.map((j,V)=>a.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[j.isZip?a.jsx(go,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):a.jsx(dM,{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:j.file.name}),a.jsxs("p",{className:"text-xs text-bambu-gray",children:[(j.file.size/1024/1024).toFixed(2)," MB",j.isZip&&j.status==="pending"&&a.jsxs("span",{className:"text-blue-400 ml-2",children:["• ",r("fileManager.willBeExtracted")]}),j.extractedCount!==void 0&&a.jsxs("span",{className:"text-green-400 ml-2",children:["• ",r("fileManager.filesExtracted",{count:j.extractedCount})]})]})]}),j.status==="pending"&&a.jsx("button",{onClick:()=>C(V),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(Lt,{className:"w-4 h-4 text-bambu-gray"})}),j.status==="uploading"&&a.jsx(pt,{className:"w-4 h-4 text-bambu-green animate-spin"}),j.status==="success"&&a.jsx(Ar,{className:"w-4 h-4 text-green-500"}),j.status==="error"&&a.jsx("span",{title:j.error,children:a.jsx(Ji,{className:"w-4 h-4 text-red-500"})})]},V))}),U&&a.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:a.jsxs("p",{className:"text-sm text-white",children:[r("fileManager.uploadComplete",{succeeded:I}),L>0&&a.jsxs("span",{className:"text-red-400",children:[", ",r("fileManager.uploadFailed",{count:L})]})]})})]}),a.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[a.jsx(Ae,{variant:"secondary",onClick:e,children:r(U?"common.close":"common.cancel")}),!U&&a.jsx(Ae,{onClick:A,disabled:D===0||c,children:c?a.jsxs(a.Fragment,{children:[a.jsx(pt,{className:"w-4 h-4 mr-2 animate-spin"}),r("fileManager.uploading")]}):a.jsxs(a.Fragment,{children:[a.jsx(Ba,{className:"w-4 h-4 mr-2"}),r("common.upload")," ",D>0?`(${D})`:""]})})]})]})})}function Zre({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o=0,wrapNames:l=!1,hasPermission:c,t:u}){const[d,h]=_.useState(!0),[p,m]=_.useState(!1),x=t.children.length>0,y=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:[x?a.jsx("button",{onClick:v=>{v.stopPropagation(),h(!d)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:a.jsx(vs,{className:`w-3.5 h-3.5 transition-transform ${d?"rotate-90":""}`})}):a.jsx("div",{className:"w-4.5"}),a.jsx(zl,{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}),y&&a.jsxs("button",{onClick:v=>{v.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(fc,{className:"w-3 h-3"}),t.project_name?a.jsx(SW,{className:"w-3 h-3"}):a.jsx(go,{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}),!y&&a.jsx("button",{onClick:v=>{v.stopPropagation(),i(t)},className:"flex-shrink-0 p-1 rounded hover:bg-bambu-dark-tertiary",title:u("fileManager.linkToProjectOrArchive"),children:a.jsx(fc,{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:v=>v.stopPropagation(),children:a.jsxs("div",{className:"relative",children:[a.jsx("button",{onClick:()=>m(!p),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:a.jsx(ah,{className:"w-3.5 h-3.5 text-bambu-gray"})}),p&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>m(!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 flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(s(t),m(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionRenameFolder"),children:[a.jsx(ea,{className:"w-3.5 h-3.5"}),u("common.rename")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:update_all")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:update_all")&&(i(t),m(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionLinkFolder"),children:[a.jsx(fc,{className:"w-3.5 h-3.5"}),u(y?"fileManager.changeLink":"fileManager.linkTo")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${c("library:delete_all")?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{c("library:delete_all")&&(r(t.id),m(!1))},disabled:!c("library:delete_all"),title:c("library:delete_all")?void 0:u("fileManager.noPermissionDeleteFolder"),children:[a.jsx(an,{className:"w-3.5 h-3.5"}),u("common.delete")]})]})]})]})})]}),x&&d&&a.jsx("div",{children:t.children.map(v=>a.jsx(Zre,{folder:v,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:s,depth:o+1,wrapNames:l,hasPermission:c,t:u},v.id))})]})}function fR(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function SXe({file:t,isSelected:e,isMobile:n,onSelect:r,onDelete:i,onDownload:s,onAddToQueue:o,onPrint:l,onPreview3d:c,onRename:u,onGenerateThumbnail:d,thumbnailVersion:h,hasPermission:p,canModify:m,t:x}){const[y,v]=_.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:`${oe.getLibraryFileThumbnailUrl(t.id)}${h?`?v=${h}`:""}`,alt:t.filename,className:"w-full h-full object-cover"}):a.jsx(Hf,{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:fg(t.file_size)}),t.print_time_seconds&&a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(tr,{className:"w-3 h-3"}),xXe(t.print_time_seconds)]})]}),t.print_count>0&&a.jsx("div",{className:"mt-1 text-xs text-bambu-green",children:x("fileManager.printedCount",{count:t.print_count})}),t.created_by_username&&a.jsx("div",{className:"mt-1 text-xs text-bambu-gray",children:x("fileManager.uploadedBy",{name:t.created_by_username})})]}),a.jsxs("div",{className:`absolute bottom-2 right-2 transition-opacity ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:b=>b.stopPropagation(),children:[a.jsx("button",{onClick:()=>v(!y),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:a.jsx(ah,{className:"w-4 h-4 text-bambu-gray"})}),y&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>v(!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&&fR(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("printers:control")?"text-bambu-green hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("printers:control")&&(l(t),v(!1))},disabled:!p("printers:control"),title:p("printers:control")?void 0:x("fileManager.noPermissionPrint"),children:[a.jsx(Ur,{className:"w-3.5 h-3.5"}),x("common.print")]}),o&&fR(t.filename)&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("queue:create")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("queue:create")&&(o(t.id),v(!1))},disabled:!p("queue:create"),title:p("queue:create")?void 0:x("fileManager.noPermissionAddToQueue"),children:[a.jsx(tr,{className:"w-3.5 h-3.5"}),x("fileManager.addToQueue")]}),c&&(t.file_type==="3mf"||t.file_type==="gcode"||t.file_type==="stl")&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library:read")&&(c(t),v(!1))},disabled:!p("library:read"),title:p("library:read")?void 0:"You do not have permission to preview files",children:[a.jsx(Ui,{className:"w-3.5 h-3.5"}),"3D Preview"]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library:read")&&(s(t.id),v(!1))},disabled:!p("library:read"),title:p("library:read")?void 0:x("fileManager.noPermissionDownload"),children:[a.jsx(wi,{className:"w-3.5 h-3.5"}),x("common.download")]}),u&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${m("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{m("library","update",t.created_by_id)&&(u(t),v(!1))},disabled:!m("library","update",t.created_by_id),title:m("library","update",t.created_by_id)?void 0:x("fileManager.noPermissionRenameFile"),children:[a.jsx(ea,{className:"w-3.5 h-3.5"}),x("common.rename")]}),d&&t.file_type==="stl"&&a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${m("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{m("library","update",t.created_by_id)&&(d(t),v(!1))},disabled:!m("library","update",t.created_by_id),title:m("library","update",t.created_by_id)?void 0:x("fileManager.noPermissionGenerateThumbnail"),children:[a.jsx(Lu,{className:"w-3.5 h-3.5"}),x("fileManager.generateThumbnail")]}),a.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${m("library","delete",t.created_by_id)?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{m("library","delete",t.created_by_id)&&(i(t.id),v(!1))},disabled:!m("library","delete",t.created_by_id),title:m("library","delete",t.created_by_id)?void 0:x("fileManager.noPermissionDeleteFile"),children:[a.jsx(an,{className:"w-3.5 h-3.5"}),x("common.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 NXe(){const{t}=On(),e=sn(),{showToast:n}=Hn(),{hasPermission:r,hasAnyPermission:i,canModify:s}=Ci(),[o]=_R(),l=o.get("folder"),c=l?parseInt(l,10):null,[u,d]=_.useState(c),[h,p]=_.useState([]),[m,x]=_.useState(!1),[y,v]=_.useState(!1),[b,S]=_.useState(!1),[N,T]=_.useState(null),[k,C]=_.useState(null),[E,P]=_.useState(null),[A,D]=_.useState(null),[I,L]=_.useState(null),[U,j]=_.useState({}),[V,K]=_.useState(null),[z,X]=_.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[Y,te]=_.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[$,W]=_.useState(()=>{const ye=localStorage.getItem("library-sidebar-width");return ye?parseInt(ye,10):256}),[ne,re]=_.useState(!1),ge=_.useRef(null);_.useEffect(()=>{if(!ne)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const ye=at=>{if(!ge.current)return;const jt=ge.current.parentElement?.getBoundingClientRect();if(!jt)return;const Dt=at.clientX-jt.left,yn=Math.min(500,Math.max(200,Dt));W(yn)},Je=()=>{re(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String($))};return document.addEventListener("mousemove",ye),document.addEventListener("mouseup",Je),()=>{document.removeEventListener("mousemove",ye),document.removeEventListener("mouseup",Je),document.body.style.userSelect="",document.body.style.cursor=""}},[ne,$]);const[me,ue]=_.useState(""),[Te,ie]=_.useState("all"),[Ce,Fe]=_.useState(()=>localStorage.getItem("library-sort-field")||"name"),[xe,Ze]=_.useState(()=>localStorage.getItem("library-sort-direction")||"asc"),G=UR();_.useEffect(()=>{const ye=o.get("folder");if(ye){const Je=parseInt(ye,10);d(Je)}},[o]);const{data:Q}=ct({queryKey:["settings"],queryFn:()=>oe.getSettings()}),{data:de,isLoading:q}=ct({queryKey:["library-folders"],queryFn:()=>oe.getLibraryFolders()}),{data:ee,isLoading:B}=ct({queryKey:["library-files",u],queryFn:()=>oe.getLibraryFiles(u,u===null)}),{data:he}=ct({queryKey:["library-stats"],queryFn:()=>oe.getLibraryStats()}),ke=_.useMemo(()=>{if(!ee)return[];const ye=new Set(ee.map(Je=>Je.file_type));return Array.from(ye).sort()},[ee]),pe=_.useMemo(()=>{if(!ee)return[];let ye=[...ee];if(me.trim()){const Je=me.toLowerCase();ye=ye.filter(at=>at.filename.toLowerCase().includes(Je)||at.print_name&&at.print_name.toLowerCase().includes(Je))}return Te!=="all"&&(ye=ye.filter(Je=>Je.file_type===Te)),ye.sort((Je,at)=>{let jt=0;switch(Ce){case"name":jt=(Je.print_name||Je.filename).localeCompare(at.print_name||at.filename);break;case"date":jt=new Date(Je.created_at).getTime()-new Date(at.created_at).getTime();break;case"size":jt=Je.file_size-at.file_size;break;case"type":jt=Je.file_type.localeCompare(at.file_type);break;case"prints":jt=Je.print_count-at.print_count;break}return xe==="asc"?jt:-jt}),ye},[ee,me,Te,Ce,xe]),H=_.useMemo(()=>{if(!he||!Q)return!1;const ye=(Q.library_disk_warning_gb||5)*1024*1024*1024;return he.disk_free_bytes<ye},[he,Q]),O=gt({mutationFn:ye=>oe.createLibraryFolder(ye),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),x(!1),n(t("fileManager.toast.folderCreated"),"success")},onError:ye=>n(ye.message,"error")}),J=gt({mutationFn:ye=>oe.deleteLibraryFolder(ye),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-stats"]}),u===k?.id&&d(null),C(null),n(t("fileManager.toast.folderDeleted"),"success")},onError:ye=>{C(null),n(ye.message,"error")}}),le=gt({mutationFn:ye=>oe.deleteLibraryFile(ye),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),p(ye=>ye.filter(Je=>Je!==k?.id)),C(null),n(t("fileManager.toast.fileDeleted"),"success")},onError:ye=>{C(null),n(ye.message,"error")}}),Se=gt({mutationFn:ye=>oe.bulkDeleteLibrary(ye,[]),onSuccess:(ye,Je)=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),n(t("fileManager.toast.filesDeleted",{count:Je.length}),"success"),p([]),C(null)},onError:ye=>{C(null),n(ye.message,"error")}}),we=gt({mutationFn:({fileIds:ye,folderId:Je})=>oe.moveLibraryFiles(ye,Je),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),p([]),v(!1),n(t("fileManager.toast.filesMoved"),"success")},onError:ye=>n(ye.message,"error")}),ae=gt({mutationFn:({id:ye,data:Je})=>oe.updateLibraryFolder(ye,Je),onSuccess:(ye,Je)=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["project-folders"]}),e.invalidateQueries({queryKey:["archive-folders"]}),T(null);const at=Je.data.project_id===0&&Je.data.archive_id===0;n(t(at?"fileManager.toast.folderUnlinked":"fileManager.toast.folderLinked"),"success")},onError:ye=>n(ye.message,"error")}),Le=gt({mutationFn:ye=>oe.addLibraryFilesToQueue(ye),onSuccess:ye=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["queue"]}),e.invalidateQueries({queryKey:["archives"]}),p([]),ye.added.length>0&&ye.errors.length===0?n(t("fileManager.toast.addedToQueue",{count:ye.added.length}),"success"):ye.added.length>0&&ye.errors.length>0?n(t("fileManager.toast.addedToQueuePartial",{added:ye.added.length,failed:ye.errors.length}),"success"):n(t("fileManager.toast.failedToAddToQueue",{error:ye.errors[0]?.error||"Unknown error"}),"error")},onError:ye=>n(ye.message,"error")}),Be=gt({mutationFn:({id:ye,filename:Je})=>oe.updateLibraryFile(ye,{filename:Je}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),L(null),n(t("fileManager.toast.fileRenamed"),"success")},onError:ye=>{L(null),n(ye.message,"error")}}),Ve=gt({mutationFn:({id:ye,name:Je})=>oe.updateLibraryFolder(ye,{name:Je}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),L(null),n(t("fileManager.toast.folderRenamed"),"success")},onError:ye=>{L(null),n(ye.message,"error")}}),He=gt({mutationFn:()=>oe.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:ye=>{if(e.invalidateQueries({queryKey:["library-files"]}),ye.succeeded>0){const Je=Date.now(),at={};ye.results.forEach(jt=>{jt.success&&(at[jt.file_id]=Je)}),j(jt=>({...jt,...at}))}ye.succeeded>0&&ye.failed===0?n(t("fileManager.toast.thumbnailsGenerated",{count:ye.succeeded}),"success"):ye.succeeded>0&&ye.failed>0?n(t("fileManager.toast.thumbnailsGeneratedPartial",{succeeded:ye.succeeded,failed:ye.failed}),"success"):ye.processed===0?n(t("fileManager.toast.noStlMissingThumbnails"),"info"):n(t("fileManager.toast.failedToGenerateThumbnails",{error:ye.results[0]?.error||"Unknown error"}),"error")},onError:ye=>n(ye.message,"error")}),be=gt({mutationFn:ye=>oe.batchGenerateStlThumbnails({file_ids:[ye]}),onSuccess:ye=>{if(e.invalidateQueries({queryKey:["library-files"]}),ye.succeeded>0){const Je=ye.results[0]?.file_id;Je&&j(at=>({...at,[Je]:Date.now()})),n(t("fileManager.toast.thumbnailGenerated"),"success")}else n(t("fileManager.toast.failedToGenerateThumbnail",{error:ye.results[0]?.error||"Unknown error"}),"error")},onError:ye=>n(ye.message,"error")}),Pe=_.useCallback(ye=>{const Je=ye.toLowerCase();return Je.endsWith(".gcode")||Je.includes(".gcode.")},[]),Ie=_.useMemo(()=>ee?ee.filter(ye=>h.includes(ye.id)&&Pe(ye.filename)):[],[ee,h,Pe]),_e=_.useCallback(ye=>{p(Je=>Je.includes(ye)?Je.filter(at=>at!==ye):[...Je,ye])},[]),Ke=_.useCallback(()=>{pe.length>0&&p(pe.map(ye=>ye.id))},[pe]),Me=_.useCallback(()=>{p([])},[]),it=()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]})},Ee=ye=>{oe.downloadLibraryFile(ye).catch(Je=>{console.error("Library file download failed:",Je)})},Xe=()=>{k&&(k.type==="file"?le.mutate(k.id):k.type==="folder"?J.mutate(k.id):k.type==="bulk"&&Se.mutate(h))},ze=J.isPending||le.isPending||Se.isPending,ce=ye=>{X(ye),localStorage.setItem("library-view-mode",ye)},$e=q||B;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(zl,{className:"w-6 h-6 text-bambu-green"})}),t("fileManager.title")]}),a.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("fileManager.subtitle")})]}),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:()=>ce("grid"),className:`p-1.5 rounded transition-colors ${z==="grid"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.gridView"),children:a.jsx(pM,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>ce("list"),className:`p-1.5 rounded transition-colors ${z==="list"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.listView"),children:a.jsx(gM,{className:"w-4 h-4"})})]}),a.jsxs(Ae,{variant:"secondary",onClick:()=>He.mutate(),disabled:He.isPending||!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?t("fileManager.generateThumbnailsForMissing"):t("fileManager.noPermissionGenerateThumbnail"),children:[He.isPending?a.jsx(pt,{className:"w-4 h-4 mr-2 animate-spin"}):a.jsx(Lu,{className:"w-4 h-4 mr-2"}),t("fileManager.generateThumbnails")]}),a.jsxs(Ae,{variant:"secondary",onClick:()=>x(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionCreateFolder"),children:[a.jsx(Yue,{className:"w-4 h-4 mr-2"}),t("fileManager.newFolder")]}),a.jsxs(Ae,{onClick:()=>S(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(Ba,{className:"w-4 h-4 mr-2"}),t("common.upload")]})]})]}),H&&he&&Q&&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(Sn,{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:t("fileManager.lowDiskSpaceWarning")}),a.jsx("p",{className:"text-xs text-amber-500/80",children:t("fileManager.lowDiskSpaceDetails",{free:fg(he.disk_free_bytes),total:fg(he.disk_total_bytes),threshold:Q.library_disk_warning_gb})})]})]}),he&&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(dM,{className:"w-4 h-4 text-bambu-green"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.files"),":"]}),a.jsx("span",{className:"text-white font-medium",children:he.total_files})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(zl,{className:"w-4 h-4 text-blue-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.folders"),":"]}),a.jsx("span",{className:"text-white font-medium",children:he.total_folders})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx(mM,{className:"w-4 h-4 text-amber-400"}),a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.size"),":"]}),a.jsx("span",{className:"text-white font-medium",children:fg(he.total_size_bytes)})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm sm:ml-auto",children:[a.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.free"),":"]}),a.jsx("span",{className:`font-medium ${H?"text-amber-500":"text-white"}`,children:fg(he.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:u??"",onChange:ye=>d(ye.target.value?parseInt(ye.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.jsxs("option",{value:"",children:["📁 ",t("fileManager.allFiles")]}),de&&(()=>{const ye=(Je,at=0)=>{const jt=[];for(const Dt of Je)jt.push({id:Dt.id,name:Dt.name,fileCount:Dt.file_count,depth:at}),Dt.children.length>0&&jt.push(...ye(Dt.children,at+1));return jt};return ye(de).map(Je=>a.jsxs("option",{value:Je.id,children:["│ ".repeat(Je.depth),"📂 ",Je.name," ",Je.fileCount>0?`(${Je.fileCount})`:""]},Je.id))})()]})}),a.jsxs("div",{ref:ge,className:"hidden lg:flex flex-shrink-0 bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden flex-col relative",style:{width:`${$}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 ${ne?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:ye=>{ye.preventDefault(),re(!0)},onDoubleClick:()=>{W(256),localStorage.setItem("library-sidebar-width","256")},title:t("fileManager.dragToResizeTooltip"),children:a.jsxs("div",{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${ne?"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:t("fileManager.folders")}),a.jsx("button",{onClick:()=>{const ye=!Y;te(ye),localStorage.setItem("library-wrap-folders",String(ye))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${Y?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:t(Y?"fileManager.disableTextWrapping":"fileManager.enableTextWrapping"),children:t("fileManager.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 ${u===null?"bg-bambu-green/20 text-bambu-green":"hover:bg-bambu-dark text-white"}`,onClick:()=>d(null),children:[a.jsx(Hf,{className:"w-4 h-4"}),a.jsx("span",{className:"text-sm",children:t("fileManager.allFiles")})]}),de?.map(ye=>a.jsx(Zre,{folder:ye,selectedFolderId:u,onSelect:d,onDelete:Je=>C({type:"folder",id:Je}),onLink:T,onRename:Je=>L({type:"folder",id:Je.id,name:Je.name}),wrapNames:Y,hasPermission:r,t},ye.id))]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[ee&&ee.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(wa,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),a.jsx("input",{type:"text",placeholder:t("fileManager.searchFiles"),value:me,onChange:ye=>ue(ye.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(hM,{className:"w-4 h-4 text-bambu-gray hidden sm:block"}),a.jsxs("select",{value:Te,onChange:ye=>ie(ye.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:t("fileManager.allTypes")}),ke.map(ye=>a.jsx("option",{value:ye,children:ye.toUpperCase()},ye))]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("select",{value:Ce,onChange:ye=>{const Je=ye.target.value;Fe(Je),localStorage.setItem("library-sort-field",Je)},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:t("common.name")}),a.jsx("option",{value:"date",children:t("common.date")}),a.jsx("option",{value:"size",children:t("fileManager.size")}),a.jsx("option",{value:"type",children:t("common.type")}),a.jsx("option",{value:"prints",children:t("fileManager.prints")})]}),a.jsx("button",{onClick:()=>Ze(ye=>{const Je=ye==="asc"?"desc":"asc";return localStorage.setItem("library-sort-direction",Je),Je}),className:"p-1.5 rounded bg-bambu-dark border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",title:t(xe==="asc"?"fileManager.ascending":"fileManager.descending"),children:xe==="asc"?a.jsx(kce,{className:"w-4 h-4 text-white"}):a.jsx(bce,{className:"w-4 h-4 text-white"})})]}),(me||Te!=="all")&&a.jsx("span",{className:"text-sm text-bambu-gray hidden sm:inline",children:t("fileManager.resultsCount",{showing:pe.length,total:ee.length})})]}),pe.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:[h.length===pe.length&&h.length>0?a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:Me,children:[a.jsx(cl,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.deselectAll")})]}):a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:Ke,children:[a.jsx(Gs,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("fileManager.selectAll")})]}),h.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-sm text-bambu-gray ml-2",children:t("fileManager.selected",{count:h.length})}),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:[Ie.length===1&&a.jsxs(Ae,{variant:"primary",size:"sm",onClick:()=>D(Ie[0]),disabled:!r("printers:control"),title:r("printers:control")?void 0:t("fileManager.noPermissionPrint"),children:[a.jsx(So,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.print")})]}),Ie.length>0&&a.jsxs(Ae,{variant:Ie.length===1?"secondary":"primary",size:"sm",onClick:()=>Le.mutate(Ie.map(ye=>ye.id)),disabled:Le.isPending||!r("queue:create"),title:r("queue:create")?void 0:t("fileManager.noPermissionAddToQueue"),children:[a.jsx(tr,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:Le.isPending?t("fileManager.adding"):`${t("fileManager.addToQueue")}${Ie.length<h.length?` (${Ie.length})`:""}`})]}),a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:()=>v(!0),disabled:!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?void 0:t("fileManager.noPermissionMoveFiles"),children:[a.jsx(ihe,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.move")})]}),a.jsxs(Ae,{variant:"danger",size:"sm",onClick:()=>{h.length===1?C({type:"file",id:h[0]}):C({type:"bulk",id:0,count:h.length})},disabled:!i("library:delete_own","library:delete_all"),title:i("library:delete_own","library:delete_all")?void 0:t("fileManager.noPermissionDeleteFiles"),children:[a.jsx(an,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.delete")})]}),a.jsxs(Ae,{variant:"secondary",size:"sm",onClick:Me,children:[a.jsx(Lt,{className:"w-4 h-4 sm:mr-1"}),a.jsx("span",{className:"hidden sm:inline",children:t("common.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(pt,{className:"w-8 h-8 animate-spin text-bambu-green"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t("fileManager.loadingFiles")})]})}):ee?.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(Hf,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t(u!==null?"fileManager.folderIsEmpty":"fileManager.noFilesYet")}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t(u!==null?"fileManager.folderEmptyDescription":"fileManager.noFilesDescription")}),a.jsxs(Ae,{onClick:()=>S(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[a.jsx(fr,{className:"w-4 h-4 mr-2"}),t("fileManager.uploadFiles")]})]}):pe.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(wa,{className:"w-12 h-12 text-bambu-gray/50"})}),a.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t("fileManager.noMatchingFiles")}),a.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t("fileManager.noMatchingFilesDescription")}),a.jsx(Ae,{variant:"secondary",onClick:()=>{ue(""),ie("all")},children:t("fileManager.clearFilters")})]}):z==="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:pe.map(ye=>a.jsx(SXe,{file:ye,isSelected:h.includes(ye.id),isMobile:G,t,onSelect:_e,onDelete:Je=>C({type:"file",id:Je}),onDownload:Ee,onAddToQueue:Je=>Le.mutate([Je]),onPrint:P,onPreview3d:K,onRename:Je=>L({type:"file",id:Je.id,name:Je.filename}),onGenerateThumbnail:Je=>be.mutate(Je.id),thumbnailVersion:U[ye.id],hasPermission:r,canModify:s},ye.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:t("common.name")}),a.jsx("div",{children:t("common.type")}),a.jsx("div",{children:t("fileManager.size")}),a.jsx("div",{children:t("fileManager.prints")}),a.jsx("div",{})]}),pe.map(ye=>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 ${h.includes(ye.id)?"bg-bambu-green/10":""}`,onClick:()=>_e(ye.id),children:[a.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${h.includes(ye.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:h.includes(ye.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:ye.thumbnail_path?a.jsx("img",{src:`${oe.getLibraryFileThumbnailUrl(ye.id)}${U[ye.id]?`?v=${U[ye.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(Hf,{className:"w-5 h-5 text-bambu-gray/50"})})}),ye.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:`${oe.getLibraryFileThumbnailUrl(ye.id)}${U[ye.id]?`?v=${U[ye.id]}`:""}`,alt:ye.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:ye.print_name||ye.filename})})]}),a.jsx("div",{children:a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${ye.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":ye.file_type==="gcode"?"bg-blue-500/20 text-blue-400":ye.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:ye.file_type.toUpperCase()})}),a.jsx("div",{className:"text-sm text-bambu-gray",children:fg(ye.file_size)}),a.jsx("div",{className:"text-sm text-bambu-gray",children:ye.print_count>0?`${ye.print_count}x`:"-"}),a.jsxs("div",{className:"flex items-center gap-1",onClick:Je=>Je.stopPropagation(),children:[fR(ye.filename)&&a.jsxs(a.Fragment,{children:[a.jsx("button",{onClick:()=>r("printers:control")&&P(ye),className:`p-1.5 rounded transition-colors ${r("printers:control")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("printers:control")?t("common.print"):t("fileManager.noPermissionPrint"),disabled:!r("printers:control"),children:a.jsx(Ur,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>r("queue:create")&&Le.mutate([ye.id]),className:`p-1.5 rounded transition-colors ${r("queue:create")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("queue:create")?t("fileManager.addToQueue"):t("fileManager.noPermissionAddToQueue"),disabled:Le.isPending||!r("queue:create"),children:a.jsx(tr,{className:"w-4 h-4"})})]}),(ye.file_type==="3mf"||ye.file_type==="gcode"||ye.file_type==="stl")&&a.jsx("button",{onClick:()=>r("library:read")&&K(ye),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?"3D Preview":"You do not have permission to preview files",disabled:!r("library:read"),children:a.jsx(Ui,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>r("library:read")&&Ee(ye.id),className:`p-1.5 rounded transition-colors ${r("library:read")?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:r("library:read")?t("common.download"):t("fileManager.noPermissionDownload"),disabled:!r("library:read"),children:a.jsx(wi,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","update",ye.created_by_id)&&L({type:"file",id:ye.id,name:ye.filename}),className:`p-1.5 rounded transition-colors ${s("library","update",ye.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",ye.created_by_id)?t("common.rename"):t("fileManager.noPermissionRenameFile"),disabled:!s("library","update",ye.created_by_id),children:a.jsx(ea,{className:"w-4 h-4"})}),ye.file_type==="stl"&&a.jsx("button",{onClick:()=>s("library","update",ye.created_by_id)&&be.mutate(ye.id),className:`p-1.5 rounded transition-colors ${s("library","update",ye.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","update",ye.created_by_id)?t("fileManager.generateThumbnail"):t("fileManager.noPermissionGenerateThumbnail"),disabled:be.isPending||!s("library","update",ye.created_by_id),children:a.jsx(Lu,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>s("library","delete",ye.created_by_id)&&C({type:"file",id:ye.id}),className:`p-1.5 rounded transition-colors ${s("library","delete",ye.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:s("library","delete",ye.created_by_id)?t("common.delete"):t("fileManager.noPermissionDeleteFile"),disabled:!s("library","delete",ye.created_by_id),children:a.jsx(an,{className:"w-4 h-4"})})]})]},ye.id))]})})]})]}),m&&a.jsx(bXe,{parentId:u,onClose:()=>x(!1),onSave:ye=>O.mutate(ye),isLoading:O.isPending,t}),y&&de&&a.jsx(vXe,{folders:de,selectedFiles:h,currentFolderId:u,onClose:()=>v(!1),onMove:ye=>we.mutate({fileIds:h,folderId:ye}),isLoading:we.isPending,t}),b&&a.jsx(_Xe,{folderId:u,onClose:()=>S(!1),onUploadComplete:it,t}),N&&a.jsx(wXe,{folder:N,onClose:()=>T(null),onLink:ye=>ae.mutate({id:N.id,data:ye}),isLoading:ae.isPending,t}),k&&a.jsx(Zn,{title:k.type==="folder"?t("fileManager.deleteFolder"):k.type==="bulk"?t("fileManager.deleteFilesCount",{count:k.count}):t("fileManager.deleteFile"),message:k.type==="folder"?t("fileManager.deleteFolderConfirm"):k.type==="bulk"?t("fileManager.deleteFilesConfirm",{count:k.count}):t("fileManager.deleteFileConfirm"),confirmText:t("common.delete"),variant:"danger",isLoading:ze,loadingText:t("fileManager.deleting"),onConfirm:Xe,onCancel:()=>C(null)}),E&&a.jsx(Dh,{mode:"reprint",libraryFileId:E.id,archiveName:E.print_name||E.filename,onClose:()=>P(null),onSuccess:()=>{P(null),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),A&&a.jsx(Dh,{mode:"reprint",libraryFileId:A.id,archiveName:A.print_name||A.filename,onClose:()=>D(null),onSuccess:()=>{D(null),p([]),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),V&&a.jsx(gL,{libraryFileId:V.id,title:V.print_name||V.filename,fileType:V.file_type,onClose:()=>K(null)}),I&&a.jsx(yXe,{type:I.type,currentName:I.name,onClose:()=>L(null),onSave:ye=>{I.type==="file"?Be.mutate({id:I.id,filename:ye}):Ve.mutate({id:I.id,name:ye})},isLoading:Be.isPending||Ve.isPending,t})]})}const Xj=5,MXe=2e3,kXe=3e4,EXe=5e3;function TXe(){const{t}=On(),{printerId:e}=aM(),n=parseInt(e||"0",10),[r,i]=_.useState("stream"),[s,o]=_.useState(!1),[l,c]=_.useState(!0),[u,d]=_.useState(Date.now()),[h,p]=_.useState(!1),[m,x]=_.useState(!1),[y,v]=_.useState(0),[b,S]=_.useState(!1),[N,T]=_.useState(0),[k,C]=_.useState(1),[E,P]=_.useState({x:0,y:0}),[A,D]=_.useState(!1),[I,L]=_.useState({x:0,y:0}),[U,j]=_.useState(null),[V,K]=_.useState(null),z=_.useRef(null),X=_.useRef(null),Y=_.useRef(null),te=_.useRef(null),$=_.useRef(null),{data:W}=ct({queryKey:["printer",n],queryFn:()=>oe.getPrinter(n),enabled:n>0});_.useEffect(()=>(W&&(document.title=`${W.name} - Camera`),()=>{document.title="Bambuddy"}),[W]);const ne=_.useRef(!1);_.useEffect(()=>{const le=`/api/v1/printers/${n}/camera/stop`;ne.current=!1;const Se=()=>{n>0&&!ne.current&&(ne.current=!0,navigator.sendBeacon(le))},we=()=>{Se()};window.addEventListener("beforeunload",we);const ae=z.current;return()=>{window.removeEventListener("beforeunload",we),ae&&(ae.src=""),Se()}},[n]),_.useEffect(()=>{if(l&&!h){const Se=setTimeout(()=>{c(!1)},r==="stream"?3e3:2e4);return()=>clearTimeout(Se)}},[r,l,u,h]),_.useEffect(()=>{const le=()=>{const Se=!!document.fullscreenElement;x(Se),C(1),P({x:0,y:0}),r==="stream"&&!h&&(z.current&&(z.current.src=""),setTimeout(()=>{c(!0),d(Date.now())},200))};return document.addEventListener("fullscreenchange",le),()=>document.removeEventListener("fullscreenchange",le)},[r,h]),_.useEffect(()=>{let le;const Se=()=>{clearTimeout(le),le=setTimeout(()=>{localStorage.setItem("cameraWindowState",JSON.stringify({width:window.outerWidth,height:window.outerHeight,left:window.screenX,top:window.screenY}))},500)};return window.addEventListener("resize",Se),()=>{clearTimeout(le),window.removeEventListener("resize",Se)}},[]),_.useEffect(()=>()=>{Y.current&&clearTimeout(Y.current),te.current&&clearInterval(te.current),$.current&&clearInterval($.current)},[]);const re=_.useCallback(()=>{if(y>=Xj){S(!1),o(!0);return}const le=Math.min(MXe*Math.pow(2,y),kXe);S(!0),T(Math.ceil(le/1e3)),te.current=setInterval(()=>{T(Se=>Se<=1?(te.current&&clearInterval(te.current),0):Se-1)},1e3),Y.current=setTimeout(()=>{v(Se=>Se+1),S(!1),c(!0),o(!1),z.current&&(z.current.src=""),d(Date.now())},le)},[y]);_.useEffect(()=>{if(r!=="stream"||l||b||h){$.current&&(clearInterval($.current),$.current=null);return}return $.current=setInterval(async()=>{try{const le=await oe.getCameraStatus(n);(le.stalled||!le.active&&!s)&&(console.log(`Stream issue detected: stalled=${le.stalled}, active=${le.active}, reconnecting...`),$.current&&(clearInterval($.current),$.current=null),c(!1),re())}catch{}},EXe),()=>{$.current&&(clearInterval($.current),$.current=null)}},[r,l,s,b,h,n,re]);const ge=()=>{c(!1),r==="stream"&&y<Xj?re():o(!0)},me=()=>{if(c(!1),o(!1),v(0),S(!1),Y.current&&clearTimeout(Y.current),te.current&&clearInterval(te.current),z.current&&!localStorage.getItem("cameraWindowState")){const le=z.current,Se=le.naturalWidth,we=le.naturalHeight;if(Se>0&&we>0){const Be=window.outerWidth-window.innerWidth,Ve=window.outerHeight-window.innerHeight,He=Se+16+Be,be=we+45+16+Ve;try{window.resizeTo(He,be)}catch{}}}},ue=()=>{n>0&&fetch(`/api/v1/printers/${n}/camera/stop`).catch(()=>{})},Te=le=>{r===le||h||(p(!0),c(!0),o(!1),v(0),S(!1),C(1),P({x:0,y:0}),Y.current&&clearTimeout(Y.current),te.current&&clearInterval(te.current),z.current&&(z.current.src=""),r==="stream"&&ue(),setTimeout(()=>{i(le),d(Date.now()),p(!1)},100))},ie=()=>{h||(p(!0),c(!0),o(!1),v(0),S(!1),Y.current&&clearTimeout(Y.current),te.current&&clearInterval(te.current),z.current&&(z.current.src=""),r==="stream"&&ue(),setTimeout(()=>{d(Date.now()),p(!1)},100))},Ce=()=>{X.current&&(document.fullscreenElement?document.exitFullscreen():X.current.requestFullscreen())},Fe=()=>{C(le=>Math.min(le+.5,4))},xe=()=>{C(le=>{const Se=Math.max(le-.5,1);return Se===1&&P({x:0,y:0}),Se})},Ze=le=>{le.preventDefault(),le.deltaY<0?Fe():xe()},G=le=>{k>1&&(le.preventDefault(),D(!0),L({x:le.clientX-E.x,y:le.clientY-E.y}))},Q=_.useCallback(()=>{if(!X.current)return{x:300,y:200};const le=X.current.getBoundingClientRect(),Se=le.width*(k-1)/2,we=le.height*(k-1)/2;return{x:Math.max(50,Se),y:Math.max(50,we)}},[k]),de=le=>{if(A&&k>1){const Se=le.clientX-I.x,we=le.clientY-I.y,ae=Q();P({x:Math.max(-ae.x,Math.min(ae.x,Se)),y:Math.max(-ae.y,Math.min(ae.y,we))})}},q=()=>{D(!1)},ee=le=>{if(le.length<2)return 0;const Se=le[0].clientX-le[1].clientX,we=le[0].clientY-le[1].clientY;return Math.sqrt(Se*Se+we*we)},B=le=>le.length<2?{x:le[0].clientX,y:le[0].clientY}:{x:(le[0].clientX+le[1].clientX)/2,y:(le[0].clientY+le[1].clientY)/2},he=le=>{le.touches.length===2?(le.preventDefault(),j(ee(le.touches)),K(B(le.touches))):le.touches.length===1&&k>1&&(le.preventDefault(),D(!0),L({x:le.touches[0].clientX-E.x,y:le.touches[0].clientY-E.y}))},ke=le=>{if(le.touches.length===2&&U!==null){le.preventDefault();const Se=ee(le.touches),we=Se/U;C(Le=>{const Be=Math.max(1,Math.min(4,Le*we));return Be===1&&P({x:0,y:0}),Be}),j(Se);const ae=B(le.touches);if(V){const Le=Q();P(Be=>({x:Math.max(-Le.x,Math.min(Le.x,Be.x+(ae.x-V.x))),y:Math.max(-Le.y,Math.min(Le.y,Be.y+(ae.y-V.y)))}))}K(ae)}else if(le.touches.length===1&&A&&k>1){le.preventDefault();const Se=le.touches[0].clientX-I.x,we=le.touches[0].clientY-I.y,ae=Q();P({x:Math.max(-ae.x,Math.min(ae.x,Se)),y:Math.max(-ae.y,Math.min(ae.y,we))})}},pe=le=>{le.touches.length<2&&(j(null),K(null)),le.touches.length===0&&D(!1)},H=()=>{C(1),P({x:0,y:0})},O=h?"":r==="stream"?`/api/v1/printers/${n}/camera/stream?fps=15&t=${u}`:`/api/v1/printers/${n}/camera/snapshot?t=${u}`,J=l||h||b;return n?a.jsxs("div",{ref:X,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(Bg,{className:"w-4 h-4"}),W?.name||`Printer ${n}`]}),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:()=>Te("stream"),disabled:J,className:`px-3 py-1 text-xs rounded transition-colors ${r==="stream"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.live")}),a.jsx("button",{onClick:()=>Te("snapshot"),disabled:J,className:`px-3 py-1 text-xs rounded transition-colors ${r==="snapshot"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white disabled:opacity-50"}`,children:t("camera.snapshot")})]}),a.jsx("button",{onClick:ie,disabled:J,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:t(r==="stream"?"camera.restartStream":"camera.refreshSnapshot"),children:a.jsx(Dr,{className:`w-4 h-4 text-bambu-gray ${J?"animate-spin":""}`})}),a.jsx("button",{onClick:Ce,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:t(m?"camera.exitFullscreen":"camera.fullscreen"),children:m?a.jsx(jW,{className:"w-4 h-4 text-bambu-gray"}):a.jsx(qde,{className:"w-4 h-4 text-bambu-gray"})})]})]}),a.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:Ze,onMouseMove:de,onMouseUp:q,onMouseLeave:q,onTouchStart:he,onTouchMove:ke,onTouchEnd:pe,style:{touchAction:"none"},children:a.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(l||h)&&!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(Dr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),a.jsx("p",{className:"text-sm text-bambu-gray",children:t(r==="stream"?"camera.connectingToCamera":"camera.capturingSnapshot")})]})}),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(lm,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:t("camera.connectionLost")}),a.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:t("camera.reconnecting",{countdown:N,attempt:y+1,max:Xj})}),a.jsx("button",{onClick:ie,className:"px-4 py-2 bg-bambu-green text-white text-sm rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.reconnectNow")})]})}),s&&!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(Sn,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),a.jsx("p",{className:"text-white mb-2",children:t("camera.cameraUnavailable")}),a.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:t("camera.cameraUnavailableDesc")}),a.jsx("button",{onClick:ie,className:"px-4 py-2 bg-bambu-green text-white rounded hover:bg-bambu-green/80 transition-colors",children:t("camera.retry")})]})}),a.jsx("img",{ref:z,src:O,alt:t("camera.cameraStream"),className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${k}) translate(${E.x/k}px, ${E.y/k}px)`,cursor:k>1?A?"grabbing":"grab":"default"},onError:O?ge:void 0,onLoad:O?me:void 0,onMouseDown:G,draggable:!1},u),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:xe,disabled:k<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomOut"),children:a.jsx(IR,{className:"w-4 h-4 text-white"})}),a.jsxs("button",{onClick:H,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:t("camera.resetZoom"),children:[Math.round(k*100),"%"]}),a.jsx("button",{onClick:Fe,disabled:k>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomIn"),children:a.jsx(FR,{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:t("camera.invalidPrinterId")})})}function AXe(t){const e=t.get("show")?.split(",")||["progress","layers","eta","filename","status"],n=parseInt(t.get("fps")||"15",10),r=Math.min(Math.max(isNaN(n)?15:n,1),30),i=t.get("camera"),s=i!=="false"&&i!=="0";return{size:t.get("size")||"medium",fps:r,showCamera:s,showProgress:e.includes("progress"),showLayers:e.includes("layers"),showEta:e.includes("eta"),showFilename:e.includes("filename"),showStatus:e.includes("status"),showPrinter:e.includes("printer")}}function CXe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function jXe(t,e){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=r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return s.getTime()===i.getTime()?o:s.getTime()===i.getTime()+864e5?`${e("streamOverlay.tomorrow")} ${o}`:r.toLocaleDateString([],{weekday:"short"})+" "+o}function PXe(t,e){if(t.stg_cur_name)return t.stg_cur_name;switch(t.state){case"RUNNING":return e("streamOverlay.status.printing");case"PAUSE":return e("streamOverlay.status.paused");case"FINISH":return e("streamOverlay.status.finished");case"FAILED":return e("streamOverlay.status.failed");case"IDLE":return e("streamOverlay.status.idle");default:return t.state||e("streamOverlay.status.unknown")}}function DXe(t){switch(t){case"small":return{container:"p-3",text:"text-sm",textLarge:"text-lg",progressHeight:"h-2",icon:"w-3 h-3",gap:"gap-2",logoHeight:"h-12"};case"large":return{container:"p-6",text:"text-xl",textLarge:"text-3xl",progressHeight:"h-4",icon:"w-6 h-6",gap:"gap-4",logoHeight:"h-24"};case"medium":default:return{container:"p-4",text:"text-base",textLarge:"text-xl",progressHeight:"h-3",icon:"w-4 h-4",gap:"gap-3",logoHeight:"h-16"}}}function RXe(){const{printerId:t}=aM(),[e]=_R(),{t:n}=On(),r=sn(),i=parseInt(t||"0",10),[s,o]=_.useState(Date.now()),l=_.useMemo(()=>AXe(e),[e]),c=DXe(l.size),{data:u}=ct({queryKey:["printer",i],queryFn:()=>oe.getPrinter(i),enabled:i>0}),{data:d}=ct({queryKey:["printerStatus",i],queryFn:()=>oe.getPrinterStatus(i),enabled:i>0,refetchInterval:2e3});_.useEffect(()=>{if(!i)return;const v=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,b=new WebSocket(v);return b.onmessage=S=>{try{const N=JSON.parse(S.data);N.type==="printer_status"&&N.printer_id===i&&r.setQueryData(["printerStatus",i],N.status)}catch{}},b.onerror=()=>{},()=>{b.close()}},[i,r]),_.useEffect(()=>(document.title=u?`${u.name} - ${n("streamOverlay.title")}`:n("streamOverlay.title"),()=>{document.title="Bambuddy"}),[u,n]);const h=()=>{setTimeout(()=>{o(Date.now())},3e3)};if(!i)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-white",children:n("streamOverlay.invalidPrinterId")})});if(!d)return a.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:a.jsx("p",{className:"text-gray-400",children:n("common.loading")})});const p=d.state==="RUNNING"||d.state==="PAUSE",m=d.progress||0,x=`/api/v1/printers/${i}/camera/stream?fps=${l.fps}&t=${s}`;return a.jsxs("div",{className:"min-h-screen bg-black relative overflow-hidden",children:[l.showCamera&&a.jsx("img",{src:x,alt:n("streamOverlay.cameraStream"),className:"absolute inset-0 w-full h-full object-contain",onError:h},s),a.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"absolute top-4 right-4 z-10",children:a.jsx("img",{src:"/img/bambuddy_logo_dark_transparent.png",alt:"Bambuddy",className:`${c.logoHeight} object-contain drop-shadow-lg hover:scale-105 transition-transform`})}),a.jsx("div",{className:"absolute bottom-0 left-0 right-0 z-10 bg-gradient-to-t from-black/80 via-black/60 to-transparent",children:a.jsxs("div",{className:`${c.container}`,children:[l.showPrinter&&u&&a.jsxs("div",{className:`flex items-center ${c.gap} mb-2`,children:[a.jsx(Ur,{className:`${c.icon} text-white/70`}),a.jsx("span",{className:`${c.text} text-white font-medium`,children:u.name})]}),l.showFilename&&d.current_print&&a.jsx("div",{className:`${c.textLarge} text-white font-semibold mb-2 truncate drop-shadow-md`,children:d.current_print.replace(/\.gcode\.3mf$|\.3mf$|\.gcode$/i,"")}),l.showStatus&&a.jsx("div",{className:`${c.text} text-white/70 mb-2`,children:PXe(d,n)}),l.showProgress&&p&&a.jsxs("div",{className:"mb-3",children:[a.jsxs("div",{className:`flex items-center justify-between mb-1 ${c.text}`,children:[a.jsx("span",{className:"text-white/70",children:n("streamOverlay.progress")}),a.jsxs("span",{className:"text-white font-bold",children:[Math.round(m),"%"]})]}),a.jsx("div",{className:`w-full bg-white/20 rounded-full ${c.progressHeight}`,children:a.jsx("div",{className:`bg-bambu-green ${c.progressHeight} rounded-full transition-all duration-500`,style:{width:`${m}%`}})})]}),p&&(l.showLayers||l.showEta)&&a.jsxs("div",{className:`flex items-center ${c.gap} flex-wrap`,children:[l.showLayers&&d.layer_num!=null&&d.total_layers!=null&&d.total_layers>0&&a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(xs,{className:c.icon}),a.jsxs("span",{className:c.text,children:[a.jsx("span",{className:"text-white",children:d.layer_num}),a.jsx("span",{className:"mx-1",children:"/"}),a.jsx("span",{children:d.total_layers})]})]}),l.showEta&&d.remaining_time!=null&&d.remaining_time>0&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(yu,{className:c.icon}),a.jsx("span",{className:`${c.text} text-white`,children:CXe(d.remaining_time*60)})]}),a.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[a.jsx(tr,{className:c.icon}),a.jsxs("span",{className:`${c.text} text-white`,children:[n("streamOverlay.eta")," ",jXe(d.remaining_time,n)]})]})]})]}),!p&&a.jsx("div",{className:`${c.text} text-white/70 py-2`,children:d.connected?n("streamOverlay.printerIdle"):n("streamOverlay.printerOffline")})]})})]})}function OXe(){const{t}=On(),{id:e}=aM(),{mode:n}=Fh(),{data:r,isLoading:i,error:s}=ct({queryKey:["external-link",e],queryFn:()=>oe.getExternalLink(Number(e)),enabled:!!e});return i?a.jsx("div",{className:"flex items-center justify-center h-full",children:a.jsx(pt,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s||!r?a.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[a.jsx(Sn,{className:"w-12 h-12"}),a.jsx("p",{children:t("common.linkNotFound")})]}):a.jsx("iframe",{src:r.url,className:"h-full w-full border-0",style:{colorScheme:n},title:r.name,sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"})}const kq=["DEBUG","INFO","WARNING","ERROR"],Yj={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},LXe={DEBUG:oM,INFO:nl,WARNING:Sn,ERROR:Vi};function FXe(){const t=sn(),[e,n]=_.useState(!0),[r,i]=_.useState(new Set),[s,o]=_.useState(""),[l,c]=_.useState("ALL"),[u,d]=_.useState(!1),[h,p]=_.useState(!1),m=_.useRef(null),{data:x,isLoading:y,refetch:v}=ct({queryKey:["application-logs",l,s],queryFn:()=>kg.getLogs({limit:200,level:l==="ALL"?void 0:l,search:s||void 0}),refetchInterval:h?2e3:!1,enabled:u});_.useEffect(()=>{u||p(!1)},[u]);const b=gt({mutationFn:()=>kg.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});_.useEffect(()=>{e&&m.current&&x?.entries&&(m.current.scrollTop=m.current.scrollHeight)},[x?.entries,e]);const S=E=>{i(P=>{const A=new Set(P);return A.has(E)?A.delete(E):A.add(E),A})},N=E=>{const P=E.split(" ");return P.length>=2?P[1]:E},T=_.useMemo(()=>x?.entries??[],[x?.entries]),k=_.useMemo(()=>[...T].reverse(),[T]),C=({level:E})=>{const P=LXe[E]||nl;return a.jsx(P,{className:`w-3.5 h-3.5 ${Yj[E]||"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 ${h?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(oM,{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:h?`Live streaming - ${x?.filtered_count??0} entries`:"View and filter application logs"})]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[h&&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(yh,{className:"w-5 h-5 text-bambu-gray"}):a.jsx(Kr,{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:[h?a.jsxs("button",{onClick:E=>{E.stopPropagation(),p(!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(cl,{className:"w-4 h-4"}),"Stop"]}):a.jsxs("button",{onClick:E=>{E.stopPropagation(),p(!0),v()},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(So,{className:"w-4 h-4"}),"Start"]}),a.jsxs("button",{onClick:()=>b.mutate(),disabled:b.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(an,{className:"w-4 h-4"}),"Clear"]}),a.jsx("button",{onClick:()=>v(),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(Dr,{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:E=>n(E.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(wa,{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:E=>o(E.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(Lt,{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"}),kq.map((E,P)=>a.jsx("button",{onClick:()=>c(E),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${P===kq.length-1?"rounded-r":""} ${l===E?`${Yj[E]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:E},E))]})]})]}),a.jsx("div",{ref:m,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:k.map((E,P)=>{const A=r.has(P),D=E.message.includes(`
  8291. `);return a.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${A?"bg-bambu-dark-secondary/30":""}`,onClick:()=>D&&S(P),children:a.jsxs("div",{className:"flex items-start gap-2",children:[a.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:N(E.timestamp)}),a.jsx("span",{className:"shrink-0",children:a.jsx(C,{level:E.level})}),a.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:E.logger_name,children:["[",E.logger_name,"]"]}),a.jsx("span",{className:`flex-1 ${Yj[E.level]||"text-white/80"} ${!A&&D?"truncate":""}`,children:A?a.jsx("pre",{className:"whitespace-pre-wrap break-all",children:E.message}):E.message.split(`
  8292. `)[0]}),D&&a.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:A?a.jsx(yh,{className:"w-3.5 h-3.5"}):a.jsx(Kr,{className:"w-3.5 h-3.5"})})]})},P)})})}),a.jsx("div",{className:"flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray",children:h?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 IXe(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 gi({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 Eq({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 Id({title:t,icon:e,children:n}){return a.jsxs(St,{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 UXe(){const{t}=On(),e=sn(),[n,r]=_.useState(null),[i,s]=_.useState(!1),[o,l]=_.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:h}=ct({queryKey:["systemInfo"],queryFn:oe.getSystemInfo,refetchInterval:3e4}),{data:p}=ct({queryKey:["debugLogging"],queryFn:kg.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:m}=ct({queryKey:["settings"],queryFn:oe.getSettings}),{data:x}=ct({queryKey:["library-stats"],queryFn:oe.getLibraryStats}),y=m?.time_format||"system",v=async()=>{l(!0);try{const T=await kg.setDebugLogging(!p?.enabled);e.setQueryData(["debugLogging"],T)}catch(T){console.error("Failed to toggle debug logging:",T)}finally{l(!1)}},b=async()=>{r(null),s(!0);try{await kg.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(pt,{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 S=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",N=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:h,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(Dr,{className:`w-4 h-4 ${h?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),a.jsx(Id,{title:t("system.application","Application"),icon:wf,children:a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[a.jsx(gi,{icon:wf,label:t("system.version","Version"),value:`v${c.app.version}`}),a.jsx(gi,{icon:tr,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),a.jsx(gi,{icon:wf,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),a.jsx(Id,{title:t("support.title","Support & Troubleshooting"),icon:pde,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 ${p?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:a.jsx(oM,{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:[p?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),p?.enabled&&p.duration_seconds!==null&&a.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(p.duration_seconds/60),"m ",p.duration_seconds%60,"s)"]})]})]})]}),a.jsxs("button",{onClick:v,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${p?.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(pt,{className:"w-4 h-4 animate-spin"}),p?.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(wi,{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:b,disabled:i||!p?.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:p?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[i&&a.jsx(pt,{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}),!p?.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(Id,{title:t("system.database","Database"),icon:Eu,children:[a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[a.jsx(gi,{icon:go,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),a.jsx(gi,{icon:lM,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),a.jsx(gi,{icon:Ji,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),a.jsx(gi,{icon:pt,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(gi,{icon:Ur,label:t("system.printers","Printers"),value:c.database.printers}),a.jsx(gi,{icon:PW,label:t("system.filaments","Filaments"),value:c.database.filaments}),a.jsx(gi,{icon:es,label:t("system.projects","Projects"),value:c.database.projects}),a.jsx(gi,{icon:al,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(gi,{icon:tr,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),a.jsx(gi,{icon:go,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),a.jsxs(Id,{title:t("system.connectedPrinters","Connected Printers"),icon:Ur,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(Id,{title:t("system.storage","Storage"),icon:mM,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(Eq,{percent:c.storage.disk_percent_used,color:S}),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(gi,{icon:go,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),a.jsx(gi,{icon:Eu,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),x&&a.jsx(gi,{icon:zl,label:t("system.fileManagerStorage","File Manager"),value:IXe(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(Id,{title:t("system.memory","Memory"),icon:Kde,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(Eq,{percent:c.memory.percent_used,color:N}),a.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),a.jsx(Id,{title:t("system.cpu","CPU"),icon:Ow,children:a.jsx("div",{className:"space-y-4",children:a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(gi,{icon:Ow,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),a.jsx(gi,{icon:Ow,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),a.jsx(Id,{title:t("system.systemDetails","System Details"),icon:wf,children:a.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[a.jsx(gi,{icon:wf,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),a.jsx(gi,{icon:Ow,label:t("system.architecture","Architecture"),value:c.system.architecture}),a.jsx(gi,{icon:wf,label:t("system.python","Python"),value:c.system.python_version}),a.jsx(gi,{icon:tr,label:t("system.bootTime","Boot Time"),value:Vg(c.system.boot_time,y)})]})})]})}function zXe(){const t=Tc(),{t:e}=On(),{login:n}=Ci(),{showToast:r}=Hn(),{mode:i}=Fh(),[s,o]=_.useState(""),[l,c]=_.useState(""),[u,d]=_.useState(!1),h=gt({mutationFn:()=>n(s,l),onSuccess:()=>{r(e("login.loginSuccess")),t("/")},onError:m=>{r(m.message||e("login.loginFailed"),"error")}}),p=m=>{if(m.preventDefault(),!s||!l){r(e("login.enterCredentials"),"error");return}h.mutate()};return a.jsxs("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:i==="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:e("login.title")}),a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("login.subtitle")})]}),a.jsxs("form",{className:"mt-8 space-y-6",onSubmit:p,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:e("login.username")}),a.jsx("input",{id:"username",type:"text",required:!0,value:s,onChange:m=>o(m.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:e("login.usernamePlaceholder"),autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-white mb-2",children:e("login.password")}),a.jsx("input",{id:"password",type:"password",required:!0,value:l,onChange:m=>c(m.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:e("login.passwordPlaceholder"),autoComplete:"current-password"})]})]}),a.jsx("div",{children:a.jsx("button",{type:"submit",disabled:h.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:h.isPending?e("login.signingIn"):e("login.signIn")})}),a.jsx("div",{className:"text-center",children:a.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-sm text-bambu-gray hover:text-bambu-green transition-colors",children:e("login.forgotPassword")})})]})]}),u&&a.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>d(!1),children:a.jsxs("div",{className:"w-full max-w-md bg-bambu-card rounded-xl border border-bambu-dark-tertiary shadow-lg p-6",onClick:m=>m.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(sue,{className:"w-5 h-5 text-bambu-green"}),a.jsx("h2",{className:"text-lg font-semibold text-white",children:e("login.forgotPasswordTitle")})]}),a.jsx("button",{onClick:()=>d(!1),className:"p-1 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",children:a.jsx(Lt,{className:"w-5 h-5"})})]}),a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-bambu-gray",children:e("login.forgotPasswordMessage")}),a.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4 space-y-2",children:[a.jsx("p",{className:"text-sm text-white font-medium",children:e("login.howToReset")}),a.jsxs("ol",{className:"text-sm text-bambu-gray space-y-1 list-decimal list-inside",children:[a.jsx("li",{children:e("login.resetStep1")}),a.jsx("li",{children:e("login.resetStep2")}),a.jsx("li",{children:e("login.resetStep3")}),a.jsx("li",{children:e("login.resetStep4")})]})]}),a.jsx("button",{onClick:()=>d(!1),className:"w-full py-2 px-4 bg-bambu-dark-tertiary hover:bg-bambu-dark text-white rounded-lg transition-colors",children:e("login.gotIt")})]})]})})]})}function BXe(){const t=Tc(),{t:e}=On(),{showToast:n}=Hn(),{mode:r}=Fh(),{refreshAuth:i}=Ci(),[s,o]=_.useState(!1),[l,c]=_.useState(""),[u,d]=_.useState(""),[h,p]=_.useState(""),m=gt({mutationFn:()=>oe.setupAuth({auth_enabled:s,admin_username:s?l:void 0,admin_password:s?u:void 0}),onSuccess:async y=>{await i(),y.auth_enabled?y.admin_created?(n(e("setup.toast.authEnabledAdminCreated")),t("/login")):(n(e("setup.toast.authEnabledExistingAdmins")),t("/login")):(n(e("setup.toast.setupCompleted")),t("/"))},onError:y=>{n(y.message,"error")}}),x=y=>{if(y.preventDefault(),s&&(l||u)){if(!l||!u){n(e("setup.toast.enterBothCredentials"),"error");return}if(u!==h){n(e("setup.toast.passwordsDoNotMatch"),"error");return}if(u.length<6){n(e("setup.toast.passwordTooShort"),"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: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:e("setup.title")}),a.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("setup.subtitle")})]}),a.jsxs("form",{className:"mt-8 space-y-6",onSubmit:x,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:s,onChange:y=>o(y.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:e("setup.enableAuth")})]}),s&&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(nl,{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:e("setup.adminAccount")}),a.jsx("p",{children:e("setup.adminAccountDesc")})]})]})}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminUsername")," ",a.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),a.jsx("input",{id:"admin-username",type:"text",value:l,onChange:y=>c(y.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:e("setup.adminUsernamePlaceholder"),autoComplete:"username"})]}),a.jsxs("div",{children:[a.jsxs("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminPassword")," ",a.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),a.jsx("input",{id:"admin-password",type:"password",value:u,onChange:y=>d(y.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:e("setup.adminPasswordPlaceholder"),minLength:6,autoComplete:"new-password"})]}),u&&a.jsxs("div",{children:[a.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:e("setup.confirmPassword")}),a.jsx("input",{id:"confirm-password",type:"password",value:h,onChange:y=>p(y.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:e("setup.confirmPasswordPlaceholder"),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?e("setup.settingUp"):e("setup.completeSetup")})})]})]})})}function HXe(){const t=_.useRef(null),e=_.useRef(null),n=sn(),[r,i]=_.useState(!1),s=_.useRef(new Set),o=_.useRef(null),l=_.useRef(new Map),c=_.useRef(null),u=_.useRef([]),d=_.useRef(!1),h=_.useRef(()=>{}),p=_.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const S=()=>{const N=u.current.shift();N?requestAnimationFrame(()=>{h.current(N),u.current.length>0?setTimeout(S,16):d.current=!1}):d.current=!1};S()},[]),m=_.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const N=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,T=new WebSocket(N);let k=null;T.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),k=window.setInterval(()=>{T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:"ping"}))},3e4)},T.onmessage=C=>{try{const E=JSON.parse(C.data);E.type==="printer_status"&&E.printer_id!==void 0&&E.data?h.current(E):(u.current.push(E),p())}catch{}},T.onclose=C=>{console.log("[WebSocket] Closed",C.code,C.reason),k&&(clearInterval(k),k=null),i(!1),t.current=null,e.current=window.setTimeout(()=>{m()},3e3)},T.onerror=C=>{console.error("[WebSocket] Error",C),T.close()},t.current=T},[p]),x=_.useCallback((S,N)=>{const T=l.current.get(S)||{};l.current.set(S,{...T,...N}),c.current||(c.current=window.setTimeout(()=>{const k=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{k.forEach((C,E)=>{n.setQueryData(["printerStatus",E],P=>{const A={...P,...C};return A.wifi_signal==null&&P?.wifi_signal!=null&&(A.wifi_signal=P.wifi_signal),A})})})},100))},[n]),y=_.useCallback(S=>{s.current.add(S),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const N=Array.from(s.current);s.current.clear(),o.current=null;let T=0;N.forEach(k=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[k]})})},T),T+=500})},3e3)},[n]),v=_.useCallback(S=>{switch(S.type){case"printer_status":S.printer_id!==void 0&&S.data&&x(S.printer_id,S.data);break;case"print_start":S.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",S.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:S.printer_id,printer_name:S.printer_name,message:S.message}}));break}},[n,y,x]);_.useEffect(()=>{h.current=v},[v]),_.useEffect(()=>(m(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[m]);const b=_.useCallback(S=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(S))},[]);return{isConnected:r,sendMessage:b}}const $Xe=new ice({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function VXe({children:t}){return HXe(),a.jsx(a.Fragment,{children:t})}function GXe({children:t}){const{authEnabled:e,loading:n,user:r}=Ci();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?a.jsx(Ug,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function qXe({children:t}){const{authEnabled:e,loading:n,user:r,isAdmin:i}=Ci();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?i?a.jsx(a.Fragment,{children:t}):a.jsx(Ug,{to:"/",replace:!0}):a.jsx(Ug,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function WXe({children:t}){const{authEnabled:e,loading:n}=Ci();return n?a.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?a.jsx(Ug,{to:"/login",replace:!0}):a.jsx(a.Fragment,{children:t})}function KXe(){return a.jsx(Dfe,{children:a.jsx(Bfe,{children:a.jsx(ace,{client:$Xe,children:a.jsx(Ife,{children:a.jsx(Mle,{children:a.jsxs(ele,{children:[a.jsx(Fi,{path:"/setup",element:a.jsx(WXe,{children:a.jsx(BXe,{})})}),a.jsx(Fi,{path:"/login",element:a.jsx(zXe,{})}),a.jsx(Fi,{path:"/camera/:printerId",element:a.jsx(TXe,{})}),a.jsx(Fi,{path:"/overlay/:printerId",element:a.jsx(RXe,{})}),a.jsxs(Fi,{element:a.jsx(GXe,{children:a.jsx(VXe,{children:a.jsx(Gfe,{})})}),children:[a.jsx(Fi,{index:!0,element:a.jsx(N8e,{})}),a.jsx(Fi,{path:"archives",element:a.jsx(Nqe,{})}),a.jsx(Fi,{path:"queue",element:a.jsx(cKe,{})}),a.jsx(Fi,{path:"stats",element:a.jsx(SKe,{})}),a.jsx(Fi,{path:"profiles",element:a.jsx(nXe,{})}),a.jsx(Fi,{path:"maintenance",element:a.jsx(oXe,{})}),a.jsx(Fi,{path:"projects",element:a.jsx(cXe,{})}),a.jsx(Fi,{path:"projects/:id",element:a.jsx(gXe,{})}),a.jsx(Fi,{path:"files",element:a.jsx(NXe,{})}),a.jsx(Fi,{path:"settings",element:a.jsx(qXe,{children:a.jsx(GKe,{})})}),a.jsx(Fi,{path:"users",element:a.jsx(Ug,{to:"/settings?tab=users",replace:!0})}),a.jsx(Fi,{path:"groups",element:a.jsx(Ug,{to:"/settings?tab=users",replace:!0})}),a.jsx(Fi,{path:"system",element:a.jsx(UXe,{})}),a.jsx(Fi,{path:"external/:id",element:a.jsx(OXe,{})})]})]})})})})})})}Qae.createRoot(document.getElementById("root")).render(a.jsx(_.StrictMode,{children:a.jsx(KXe,{})}));