| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665 |
- function Dae(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(t,i,a.get?a:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const o of a.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();var Cw=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function hl(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var zE={exports:{}},Eb={};var FU;function Rae(){if(FU)return Eb;FU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,a){var o=null;if(a!==void 0&&(o=""+a),i.key!==void 0&&(o=""+i.key),"key"in i){a={};for(var l in i)l!=="key"&&(a[l]=i[l])}else a=i;return i=a.ref,{$$typeof:t,type:r,key:o,ref:i!==void 0?i:null,props:a}}return Eb.Fragment=e,Eb.jsx=n,Eb.jsxs=n,Eb}var IU;function Oae(){return IU||(IU=1,zE.exports=Rae()),zE.exports}var s=Oae(),BE={exports:{}},yn={};var UU;function Lae(){if(UU)return yn;UU=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),p=Symbol.iterator;function m(H){return H===null||typeof H!="object"?null:(H=p&&H[p]||H["@@iterator"],typeof H=="function"?H:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},b=Object.assign,v={};function y(H,K,re){this.props=H,this.context=K,this.refs=v,this.updater=re||x}y.prototype.isReactComponent={},y.prototype.setState=function(H,K){if(typeof H!="object"&&typeof H!="function"&&H!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,H,K,"setState")},y.prototype.forceUpdate=function(H){this.updater.enqueueForceUpdate(this,H,"forceUpdate")};function S(){}S.prototype=y.prototype;function k(H,K,re){this.props=H,this.context=K,this.refs=v,this.updater=re||x}var T=k.prototype=new S;T.constructor=k,b(T,y.prototype),T.isPureReactComponent=!0;var M=Array.isArray;function C(){}var E={H:null,A:null,T:null,S:null},R=Object.prototype.hasOwnProperty;function A(H,K,re){var ne=re.ref;return{$$typeof:t,type:H,key:K,ref:ne!==void 0?ne:null,props:re}}function D(H,K){return A(H.type,K,H.props)}function I(H){return typeof H=="object"&&H!==null&&H.$$typeof===t}function F(H){var K={"=":"=0",":":"=2"};return"$"+H.replace(/[=:]/g,function(re){return K[re]})}var z=/\/+/g;function P(H,K){return typeof H=="object"&&H!==null&&H.key!=null?F(""+H.key):K.toString(36)}function $(H){switch(H.status){case"fulfilled":return H.value;case"rejected":throw H.reason;default:switch(typeof H.status=="string"?H.then(C,C):(H.status="pending",H.then(function(K){H.status==="pending"&&(H.status="fulfilled",H.value=K)},function(K){H.status==="pending"&&(H.status="rejected",H.reason=K)})),H.status){case"fulfilled":return H.value;case"rejected":throw H.reason}}throw H}function X(H,K,re,ne,be){var me=typeof H;(me==="undefined"||me==="boolean")&&(H=null);var de=!1;if(H===null)de=!0;else switch(me){case"bigint":case"string":case"number":de=!0;break;case"object":switch(H.$$typeof){case t:case e:de=!0;break;case d:return de=H._init,X(de(H._payload),K,re,ne,be)}}if(de)return be=be(H),de=ne===""?"."+P(H,0):ne,M(be)?(re="",de!=null&&(re=de.replace(z,"$&/")+"/"),X(be,K,re,"",function(ke){return ke})):be!=null&&(I(be)&&(be=D(be,re+(be.key==null||H&&H.key===be.key?"":(""+be.key).replace(z,"$&/")+"/")+de)),K.push(be)),1;de=0;var Ce=ne===""?".":ne+":";if(M(H))for(var ie=0;ie<H.length;ie++)ne=H[ie],me=Ce+P(ne,ie),de+=X(ne,K,re,me,be);else if(ie=m(H),typeof ie=="function")for(H=ie.call(H),ie=0;!(ne=H.next()).done;)ne=ne.value,me=Ce+P(ne,ie++),de+=X(ne,K,re,me,be);else if(me==="object"){if(typeof H.then=="function")return X($(H),K,re,ne,be);throw K=String(H),Error("Objects are not valid as a React child (found: "+(K==="[object Object]"?"object with keys {"+Object.keys(H).join(", ")+"}":K)+"). If you meant to render a collection of children, use an array instead.")}return de}function V(H,K,re){if(H==null)return H;var ne=[],be=0;return X(H,ne,"","",function(me){return K.call(re,me,be++)}),ne}function Q(H){if(H._status===-1){var K=H._result;K=K(),K.then(function(re){(H._status===0||H._status===-1)&&(H._status=1,H._result=re)},function(re){(H._status===0||H._status===-1)&&(H._status=2,H._result=re)}),H._status===-1&&(H._status=0,H._result=K)}if(H._status===1)return H._result.default;throw H._result}var Z=typeof reportError=="function"?reportError:function(H){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var K=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof H=="object"&&H!==null&&typeof H.message=="string"?String(H.message):String(H),error:H});if(!window.dispatchEvent(K))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",H);return}console.error(H)},se={map:V,forEach:function(H,K,re){V(H,function(){K.apply(this,arguments)},re)},count:function(H){var K=0;return V(H,function(){K++}),K},toArray:function(H){return V(H,function(K){return K})||[]},only:function(H){if(!I(H))throw Error("React.Children.only expected to receive a single React element child.");return H}};return yn.Activity=f,yn.Children=se,yn.Component=y,yn.Fragment=n,yn.Profiler=i,yn.PureComponent=k,yn.StrictMode=r,yn.Suspense=c,yn.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=E,yn.__COMPILER_RUNTIME={__proto__:null,c:function(H){return E.H.useMemoCache(H)}},yn.cache=function(H){return function(){return H.apply(null,arguments)}},yn.cacheSignal=function(){return null},yn.cloneElement=function(H,K,re){if(H==null)throw Error("The argument must be a React element, but you passed "+H+".");var ne=b({},H.props),be=H.key;if(K!=null)for(me in K.key!==void 0&&(be=""+K.key),K)!R.call(K,me)||me==="key"||me==="__self"||me==="__source"||me==="ref"&&K.ref===void 0||(ne[me]=K[me]);var me=arguments.length-2;if(me===1)ne.children=re;else if(1<me){for(var de=Array(me),Ce=0;Ce<me;Ce++)de[Ce]=arguments[Ce+2];ne.children=de}return A(H.type,be,ne)},yn.createContext=function(H){return H={$$typeof:o,_currentValue:H,_currentValue2:H,_threadCount:0,Provider:null,Consumer:null},H.Provider=H,H.Consumer={$$typeof:a,_context:H},H},yn.createElement=function(H,K,re){var ne,be={},me=null;if(K!=null)for(ne in K.key!==void 0&&(me=""+K.key),K)R.call(K,ne)&&ne!=="key"&&ne!=="__self"&&ne!=="__source"&&(be[ne]=K[ne]);var de=arguments.length-2;if(de===1)be.children=re;else if(1<de){for(var Ce=Array(de),ie=0;ie<de;ie++)Ce[ie]=arguments[ie+2];be.children=Ce}if(H&&H.defaultProps)for(ne in de=H.defaultProps,de)be[ne]===void 0&&(be[ne]=de[ne]);return A(H,me,be)},yn.createRef=function(){return{current:null}},yn.forwardRef=function(H){return{$$typeof:l,render:H}},yn.isValidElement=I,yn.lazy=function(H){return{$$typeof:d,_payload:{_status:-1,_result:H},_init:Q}},yn.memo=function(H,K){return{$$typeof:u,type:H,compare:K===void 0?null:K}},yn.startTransition=function(H){var K=E.T,re={};E.T=re;try{var ne=H(),be=E.S;be!==null&&be(re,ne),typeof ne=="object"&&ne!==null&&typeof ne.then=="function"&&ne.then(C,Z)}catch(me){Z(me)}finally{K!==null&&re.types!==null&&(K.types=re.types),E.T=K}},yn.unstable_useCacheRefresh=function(){return E.H.useCacheRefresh()},yn.use=function(H){return E.H.use(H)},yn.useActionState=function(H,K,re){return E.H.useActionState(H,K,re)},yn.useCallback=function(H,K){return E.H.useCallback(H,K)},yn.useContext=function(H){return E.H.useContext(H)},yn.useDebugValue=function(){},yn.useDeferredValue=function(H,K){return E.H.useDeferredValue(H,K)},yn.useEffect=function(H,K){return E.H.useEffect(H,K)},yn.useEffectEvent=function(H){return E.H.useEffectEvent(H)},yn.useId=function(){return E.H.useId()},yn.useImperativeHandle=function(H,K,re){return E.H.useImperativeHandle(H,K,re)},yn.useInsertionEffect=function(H,K){return E.H.useInsertionEffect(H,K)},yn.useLayoutEffect=function(H,K){return E.H.useLayoutEffect(H,K)},yn.useMemo=function(H,K){return E.H.useMemo(H,K)},yn.useOptimistic=function(H,K){return E.H.useOptimistic(H,K)},yn.useReducer=function(H,K,re){return E.H.useReducer(H,K,re)},yn.useRef=function(H){return E.H.useRef(H)},yn.useState=function(H){return E.H.useState(H)},yn.useSyncExternalStore=function(H,K,re){return E.H.useSyncExternalStore(H,K,re)},yn.useTransition=function(){return E.H.useTransition()},yn.version="19.2.0",yn}var zU;function px(){return zU||(zU=1,BE.exports=Lae()),BE.exports}var _=px();const ei=hl(_),Fae=Dae({__proto__:null,default:ei},[_]);var HE={exports:{}},Tb={},$E={exports:{}},VE={};var BU;function Iae(){return BU||(BU=1,(function(t){function e(X,V){var Q=X.length;X.push(V);e:for(;0<Q;){var Z=Q-1>>>1,se=X[Z];if(0<i(se,V))X[Z]=V,X[Q]=se,Q=Z;else break e}}function n(X){return X.length===0?null:X[0]}function r(X){if(X.length===0)return null;var V=X[0],Q=X.pop();if(Q!==V){X[0]=Q;e:for(var Z=0,se=X.length,H=se>>>1;Z<H;){var K=2*(Z+1)-1,re=X[K],ne=K+1,be=X[ne];if(0>i(re,Q))ne<se&&0>i(be,re)?(X[Z]=be,X[ne]=Q,Z=ne):(X[Z]=re,X[K]=Q,Z=K);else if(ne<se&&0>i(be,Q))X[Z]=be,X[ne]=Q,Z=ne;else break e}}return V}function i(X,V){var Q=X.sortIndex-V.sortIndex;return Q!==0?Q:X.id-V.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var c=[],u=[],d=1,f=null,p=3,m=!1,x=!1,b=!1,v=!1,y=typeof setTimeout=="function"?setTimeout:null,S=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;function T(X){for(var V=n(u);V!==null;){if(V.callback===null)r(u);else if(V.startTime<=X)r(u),V.sortIndex=V.expirationTime,e(c,V);else break;V=n(u)}}function M(X){if(b=!1,T(X),!x)if(n(c)!==null)x=!0,C||(C=!0,F());else{var V=n(u);V!==null&&$(M,V.startTime-X)}}var C=!1,E=-1,R=5,A=-1;function D(){return v?!0:!(t.unstable_now()-A<R)}function I(){if(v=!1,C){var X=t.unstable_now();A=X;var V=!0;try{e:{x=!1,b&&(b=!1,S(E),E=-1),m=!0;var Q=p;try{t:{for(T(X),f=n(c);f!==null&&!(f.expirationTime>X&&D());){var Z=f.callback;if(typeof Z=="function"){f.callback=null,p=f.priorityLevel;var se=Z(f.expirationTime<=X);if(X=t.unstable_now(),typeof se=="function"){f.callback=se,T(X),V=!0;break t}f===n(c)&&r(c),T(X)}else r(c);f=n(c)}if(f!==null)V=!0;else{var H=n(u);H!==null&&$(M,H.startTime-X),V=!1}}break e}finally{f=null,p=Q,m=!1}V=void 0}}finally{V?F():C=!1}}}var F;if(typeof k=="function")F=function(){k(I)};else if(typeof MessageChannel<"u"){var z=new MessageChannel,P=z.port2;z.port1.onmessage=I,F=function(){P.postMessage(null)}}else F=function(){y(I,0)};function $(X,V){E=y(function(){X(t.unstable_now())},V)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(X){X.callback=null},t.unstable_forceFrameRate=function(X){0>X||125<X?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):R=0<X?Math.floor(1e3/X):5},t.unstable_getCurrentPriorityLevel=function(){return p},t.unstable_next=function(X){switch(p){case 1:case 2:case 3:var V=3;break;default:V=p}var Q=p;p=V;try{return X()}finally{p=Q}},t.unstable_requestPaint=function(){v=!0},t.unstable_runWithPriority=function(X,V){switch(X){case 1:case 2:case 3:case 4:case 5:break;default:X=3}var Q=p;p=X;try{return V()}finally{p=Q}},t.unstable_scheduleCallback=function(X,V,Q){var Z=t.unstable_now();switch(typeof Q=="object"&&Q!==null?(Q=Q.delay,Q=typeof Q=="number"&&0<Q?Z+Q:Z):Q=Z,X){case 1:var se=-1;break;case 2:se=250;break;case 5:se=1073741823;break;case 4:se=1e4;break;default:se=5e3}return se=Q+se,X={id:d++,callback:V,priorityLevel:X,startTime:Q,expirationTime:se,sortIndex:-1},Q>Z?(X.sortIndex=Q,e(u,X),n(c)===null&&X===n(u)&&(b?(S(E),E=-1):b=!0,$(M,Q-Z))):(X.sortIndex=se,e(c,X),x||m||(x=!0,C||(C=!0,F()))),X},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(X){var V=p;return function(){var Q=p;p=V;try{return X.apply(this,arguments)}finally{p=Q}}}})(VE)),VE}var HU;function Uae(){return HU||(HU=1,$E.exports=Iae()),$E.exports}var GE={exports:{}},Ha={};var $U;function zae(){if($U)return Ha;$U=1;var t=px();function e(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function a(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var 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 Ha.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Ha.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(e(299));return a(c,u,null,d)},Ha.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()}},Ha.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))},Ha.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},Ha.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=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:f,integrity:p,fetchPriority:m}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:p,fetchPriority:m,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},Ha.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)},Ha.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},Ha.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)},Ha.requestFormReset=function(c){r.d.r(c)},Ha.unstable_batchedUpdates=function(c,u){return c(u)},Ha.useFormState=function(c,u,d){return o.H.useFormState(c,u,d)},Ha.useFormStatus=function(){return o.H.useHostTransitionStatus()},Ha.version="19.2.0",Ha}var VU;function Sq(){if(VU)return GE.exports;VU=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(),GE.exports=zae(),GE.exports}var GU;function Bae(){if(GU)return Tb;GU=1;var t=Uae(),e=px(),n=Sq();function r(h){var g="https://react.dev/errors/"+h;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 #"+h+"; visit "+g+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(h){return!(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)}function a(h){var g=h,w=h;if(h.alternate)for(;g.return;)g=g.return;else{h=g;do g=h,(g.flags&4098)!==0&&(w=g.return),h=g.return;while(h)}return g.tag===3?w:null}function o(h){if(h.tag===13){var g=h.memoizedState;if(g===null&&(h=h.alternate,h!==null&&(g=h.memoizedState)),g!==null)return g.dehydrated}return null}function l(h){if(h.tag===31){var g=h.memoizedState;if(g===null&&(h=h.alternate,h!==null&&(g=h.memoizedState)),g!==null)return g.dehydrated}return null}function c(h){if(a(h)!==h)throw Error(r(188))}function u(h){var g=h.alternate;if(!g){if(g=a(h),g===null)throw Error(r(188));return g!==h?null:h}for(var w=h,N=g;;){var j=w.return;if(j===null)break;var L=j.alternate;if(L===null){if(N=j.return,N!==null){w=N;continue}break}if(j.child===L.child){for(L=j.child;L;){if(L===w)return c(j),h;if(L===N)return c(j),g;L=L.sibling}throw Error(r(188))}if(w.return!==N.return)w=j,N=L;else{for(var J=!1,ye=j.child;ye;){if(ye===w){J=!0,w=j,N=L;break}if(ye===N){J=!0,N=j,w=L;break}ye=ye.sibling}if(!J){for(ye=L.child;ye;){if(ye===w){J=!0,w=L,N=j;break}if(ye===N){J=!0,N=L,w=j;break}ye=ye.sibling}if(!J)throw Error(r(189))}}if(w.alternate!==N)throw Error(r(190))}if(w.tag!==3)throw Error(r(188));return w.stateNode.current===w?h:g}function d(h){var g=h.tag;if(g===5||g===26||g===27||g===6)return h;for(h=h.child;h!==null;){if(g=d(h),g!==null)return g;h=h.sibling}return null}var f=Object.assign,p=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),b=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),k=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),D=Symbol.for("react.memo_cache_sentinel"),I=Symbol.iterator;function F(h){return h===null||typeof h!="object"?null:(h=I&&h[I]||h["@@iterator"],typeof h=="function"?h:null)}var z=Symbol.for("react.client.reference");function P(h){if(h==null)return null;if(typeof h=="function")return h.$$typeof===z?null:h.displayName||h.name||null;if(typeof h=="string")return h;switch(h){case b:return"Fragment";case y:return"Profiler";case v:return"StrictMode";case M:return"Suspense";case C:return"SuspenseList";case A:return"Activity"}if(typeof h=="object")switch(h.$$typeof){case x:return"Portal";case k:return h.displayName||"Context";case S:return(h._context.displayName||"Context")+".Consumer";case T:var g=h.render;return h=h.displayName,h||(h=g.displayName||g.name||"",h=h!==""?"ForwardRef("+h+")":"ForwardRef"),h;case E:return g=h.displayName||null,g!==null?g:P(h.type)||"Memo";case R:g=h._payload,h=h._init;try{return P(h(g))}catch{}}return null}var $=Array.isArray,X=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q={pending:!1,data:null,method:null,action:null},Z=[],se=-1;function H(h){return{current:h}}function K(h){0>se||(h.current=Z[se],Z[se]=null,se--)}function re(h,g){se++,Z[se]=h.current,h.current=g}var ne=H(null),be=H(null),me=H(null),de=H(null);function Ce(h,g){switch(re(me,g),re(be,h),re(ne,null),g.nodeType){case 9:case 11:h=(h=g.documentElement)&&(h=h.namespaceURI)?sU(h):0;break;default:if(h=g.tagName,g=g.namespaceURI)g=sU(g),h=oU(g,h);else switch(h){case"svg":h=1;break;case"math":h=2;break;default:h=0}}K(ne),re(ne,h)}function ie(){K(ne),K(be),K(me)}function ke(h){h.memoizedState!==null&&re(de,h);var g=ne.current,w=oU(g,h.type);g!==w&&(re(be,h),re(ne,w))}function Oe(h){be.current===h&&(K(ne),K(be)),de.current===h&&(K(de),Sb._currentValue=Q)}var pe,We;function G(h){if(pe===void 0)try{throw Error()}catch(w){var g=w.stack.trim().match(/\n( *(at )?)/);pe=g&&g[1]||"",We=-1<w.stack.indexOf(`
- at`)?" (<anonymous>)":-1<w.stack.indexOf("@")?"@unknown:0:0":""}return`
- `+pe+h+We}var Y=!1;function ue(h,g){if(!h||Y)return"";Y=!0;var w=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var N={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(gt){var dt=gt}Reflect.construct(h,[],wt)}else{try{wt.call()}catch(gt){dt=gt}h.call(wt.prototype)}}else{try{throw Error()}catch(gt){dt=gt}(wt=h())&&typeof wt.catch=="function"&&wt.catch(function(){})}}catch(gt){if(gt&&dt&&typeof gt.stack=="string")return[gt.stack,dt.stack]}return[null,null]}};N.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var j=Object.getOwnPropertyDescriptor(N.DetermineComponentFrameRoot,"name");j&&j.configurable&&Object.defineProperty(N.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var L=N.DetermineComponentFrameRoot(),J=L[0],ye=L[1];if(J&&ye){var Ie=J.split(`
- `),st=ye.split(`
- `);for(j=N=0;N<Ie.length&&!Ie[N].includes("DetermineComponentFrameRoot");)N++;for(;j<st.length&&!st[j].includes("DetermineComponentFrameRoot");)j++;if(N===Ie.length||j===st.length)for(N=Ie.length-1,j=st.length-1;1<=N&&0<=j&&Ie[N]!==st[j];)j--;for(;1<=N&&0<=j;N--,j--)if(Ie[N]!==st[j]){if(N!==1||j!==1)do if(N--,j--,0>j||Ie[N]!==st[j]){var xt=`
- `+Ie[N].replace(" at new "," at ");return h.displayName&&xt.includes("<anonymous>")&&(xt=xt.replace("<anonymous>",h.displayName)),xt}while(1<=N&&0<=j);break}}}finally{Y=!1,Error.prepareStackTrace=w}return(w=h?h.displayName||h.name:"")?G(w):""}function q(h,g){switch(h.tag){case 26:case 27:case 5:return G(h.type);case 16:return G("Lazy");case 13:return h.child!==g&&g!==null?G("Suspense Fallback"):G("Suspense");case 19:return G("SuspenseList");case 0:case 15:return ue(h.type,!1);case 11:return ue(h.type.render,!1);case 1:return ue(h.type,!0);case 31:return G("Activity");default:return""}}function te(h){try{var g="",w=null;do g+=q(h,w),w=h,h=h.return;while(h);return g}catch(N){return`
- Error generating stack: `+N.message+`
- `+N.stack}}var U=Object.prototype.hasOwnProperty,he=t.unstable_scheduleCallback,Me=t.unstable_cancelCallback,ge=t.unstable_shouldYield,B=t.unstable_requestPaint,O=t.unstable_now,ee=t.unstable_getCurrentPriorityLevel,le=t.unstable_ImmediatePriority,_e=t.unstable_UserBlockingPriority,ve=t.unstable_NormalPriority,ae=t.unstable_LowPriority,Fe=t.unstable_IdlePriority,Be=t.log,$e=t.unstable_setDisableYieldValue,He=null,xe=null;function Pe(h){if(typeof Be=="function"&&$e(h),xe&&typeof xe.setStrictMode=="function")try{xe.setStrictMode(He,h)}catch{}}var ze=Math.clz32?Math.clz32:Ne,we=Math.log,Xe=Math.LN2;function Ne(h){return h>>>=0,h===0?32:31-(we(h)/Xe|0)|0}var rt=256,Ee=262144,Ke=4194304;function Ue(h){var g=h&42;if(g!==0)return g;switch(h&-h){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return h&261888;case 262144:case 524288:case 1048576:case 2097152:return h&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return h&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return h}}function W(h,g,w){var N=h.pendingLanes;if(N===0)return 0;var j=0,L=h.suspendedLanes,J=h.pingedLanes;h=h.warmLanes;var ye=N&134217727;return ye!==0?(N=ye&~L,N!==0?j=Ue(N):(J&=ye,J!==0?j=Ue(J):w||(w=ye&~h,w!==0&&(j=Ue(w))))):(ye=N&~L,ye!==0?j=Ue(ye):J!==0?j=Ue(J):w||(w=N&~h,w!==0&&(j=Ue(w)))),j===0?0:g!==0&&g!==j&&(g&L)===0&&(L=j&-j,w=g&-g,L>=w||L===32&&(w&4194048)!==0)?g:j}function je(h,g){return(h.pendingLanes&~(h.suspendedLanes&~h.pingedLanes)&g)===0}function Ye(h,g){switch(h){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 bt(){var h=Ke;return Ke<<=1,(Ke&62914560)===0&&(Ke=4194304),h}function pt(h){for(var g=[],w=0;31>w;w++)g.push(h);return g}function Bt(h,g){h.pendingLanes|=g,g!==268435456&&(h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0)}function Lt(h,g,w,N,j,L){var J=h.pendingLanes;h.pendingLanes=w,h.suspendedLanes=0,h.pingedLanes=0,h.warmLanes=0,h.expiredLanes&=w,h.entangledLanes&=w,h.errorRecoveryDisabledLanes&=w,h.shellSuspendCounter=0;var ye=h.entanglements,Ie=h.expirationTimes,st=h.hiddenUpdates;for(w=J&~w;0<w;){var xt=31-ze(w),wt=1<<xt;ye[xt]=0,Ie[xt]=-1;var dt=st[xt];if(dt!==null)for(st[xt]=null,xt=0;xt<dt.length;xt++){var gt=dt[xt];gt!==null&&(gt.lane&=-536870913)}w&=~wt}N!==0&&vn(h,N,0),L!==0&&j===0&&h.tag!==0&&(h.suspendedLanes|=L&~(J&~g))}function vn(h,g,w){h.pendingLanes|=g,h.suspendedLanes&=~g;var N=31-ze(g);h.entangledLanes|=g,h.entanglements[N]=h.entanglements[N]|1073741824|w&261930}function cn(h,g){var w=h.entangledLanes|=g;for(h=h.entanglements;w;){var N=31-ze(w),j=1<<N;j&g|h[N]&g&&(h[N]|=g),w&=~j}}function rr(h,g){var w=g&-g;return w=(w&42)!==0?1:Vn(w),(w&(h.suspendedLanes|g))!==0?0:w}function Vn(h){switch(h){case 2:h=1;break;case 8:h=4;break;case 32:h=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:h=128;break;case 268435456:h=134217728;break;default:h=0}return h}function Jn(h){return h&=-h,2<h?8<h?(h&134217727)!==0?32:268435456:8:2}function gn(){var h=V.p;return h!==0?h:(h=window.event,h===void 0?32:CU(h.type))}function sr(h,g){var w=V.p;try{return V.p=h,g()}finally{V.p=w}}var Gn=Math.random().toString(36).slice(2),Xn="__reactFiber$"+Gn,Nn="__reactProps$"+Gn,hi="__reactContainer$"+Gn,ai="__reactEvents$"+Gn,Ae="__reactListeners$"+Gn,et="__reactHandles$"+Gn,ct="__reactResources$"+Gn,ut="__reactMarker$"+Gn;function lt(h){delete h[Xn],delete h[Nn],delete h[ai],delete h[Ae],delete h[et]}function Et(h){var g=h[Xn];if(g)return g;for(var w=h.parentNode;w;){if(g=w[hi]||w[Xn]){if(w=g.alternate,g.child!==null||w!==null&&w.child!==null)for(h=mU(h);h!==null;){if(w=h[Xn])return w;h=mU(h)}return g}h=w,w=h.parentNode}return null}function fe(h){if(h=h[Xn]||h[hi]){var g=h.tag;if(g===5||g===6||g===13||g===31||g===26||g===27||g===3)return h}return null}function De(h){var g=h.tag;if(g===5||g===26||g===27||g===6)return h.stateNode;throw Error(r(33))}function Ve(h){var g=h[ct];return g||(g=h[ct]={hoistableStyles:new Map,hoistableScripts:new Map}),g}function Se(h){h[ut]=!0}var Le=new Set,tt={};function Qe(h,g){Tt(h,g),Tt(h+"Capture",g)}function Tt(h,g){for(tt[h]=g,h=0;h<g.length;h++)Le.add(g[h])}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]*$"),Ft={},jt={};function Mt(h){return U.call(jt,h)?!0:U.call(Ft,h)?!1:At.test(h)?jt[h]=!0:(Ft[h]=!0,!1)}function Jt(h,g,w){if(Mt(g))if(w===null)h.removeAttribute(g);else{switch(typeof w){case"undefined":case"function":case"symbol":h.removeAttribute(g);return;case"boolean":var N=g.toLowerCase().slice(0,5);if(N!=="data-"&&N!=="aria-"){h.removeAttribute(g);return}}h.setAttribute(g,""+w)}}function Ht(h,g,w){if(w===null)h.removeAttribute(g);else{switch(typeof w){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(g);return}h.setAttribute(g,""+w)}}function hn(h,g,w,N){if(N===null)h.removeAttribute(w);else{switch(typeof N){case"undefined":case"function":case"symbol":case"boolean":h.removeAttribute(w);return}h.setAttributeNS(g,w,""+N)}}function un(h){switch(typeof h){case"bigint":case"boolean":case"number":case"string":case"undefined":return h;case"object":return h;default:return""}}function Mn(h){var g=h.type;return(h=h.nodeName)&&h.toLowerCase()==="input"&&(g==="checkbox"||g==="radio")}function Gt(h,g,w){var N=Object.getOwnPropertyDescriptor(h.constructor.prototype,g);if(!h.hasOwnProperty(g)&&typeof N<"u"&&typeof N.get=="function"&&typeof N.set=="function"){var j=N.get,L=N.set;return Object.defineProperty(h,g,{configurable:!0,get:function(){return j.call(this)},set:function(J){w=""+J,L.call(this,J)}}),Object.defineProperty(h,g,{enumerable:N.enumerable}),{getValue:function(){return w},setValue:function(J){w=""+J},stopTracking:function(){h._valueTracker=null,delete h[g]}}}}function on(h){if(!h._valueTracker){var g=Mn(h)?"checked":"value";h._valueTracker=Gt(h,g,""+h[g])}}function dn(h){if(!h)return!1;var g=h._valueTracker;if(!g)return!0;var w=g.getValue(),N="";return h&&(N=Mn(h)?h.checked?"true":"false":h.value),h=N,h!==w?(g.setValue(h),!0):!1}function Yt(h){if(h=h||(typeof document<"u"?document:void 0),typeof h>"u")return null;try{return h.activeElement||h.body}catch{return h.body}}var ir=/[\n"\\]/g;function jn(h){return h.replace(ir,function(g){return"\\"+g.charCodeAt(0).toString(16)+" "})}function si(h,g,w,N,j,L,J,ye){h.name="",J!=null&&typeof J!="function"&&typeof J!="symbol"&&typeof J!="boolean"?h.type=J:h.removeAttribute("type"),g!=null?J==="number"?(g===0&&h.value===""||h.value!=g)&&(h.value=""+un(g)):h.value!==""+un(g)&&(h.value=""+un(g)):J!=="submit"&&J!=="reset"||h.removeAttribute("value"),g!=null?dr(h,J,un(g)):w!=null?dr(h,J,un(w)):N!=null&&h.removeAttribute("value"),j==null&&L!=null&&(h.defaultChecked=!!L),j!=null&&(h.checked=j&&typeof j!="function"&&typeof j!="symbol"),ye!=null&&typeof ye!="function"&&typeof ye!="symbol"&&typeof ye!="boolean"?h.name=""+un(ye):h.removeAttribute("name")}function ar(h,g,w,N,j,L,J,ye){if(L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"&&(h.type=L),g!=null||w!=null){if(!(L!=="submit"&&L!=="reset"||g!=null)){on(h);return}w=w!=null?""+un(w):"",g=g!=null?""+un(g):w,ye||g===h.value||(h.value=g),h.defaultValue=g}N=N??j,N=typeof N!="function"&&typeof N!="symbol"&&!!N,h.checked=ye?h.checked:!!N,h.defaultChecked=!!N,J!=null&&typeof J!="function"&&typeof J!="symbol"&&typeof J!="boolean"&&(h.name=J),on(h)}function dr(h,g,w){g==="number"&&Yt(h.ownerDocument)===h||h.defaultValue===""+w||(h.defaultValue=""+w)}function nt(h,g,w,N){if(h=h.options,g){g={};for(var j=0;j<w.length;j++)g["$"+w[j]]=!0;for(w=0;w<h.length;w++)j=g.hasOwnProperty("$"+h[w].value),h[w].selected!==j&&(h[w].selected=j),j&&N&&(h[w].defaultSelected=!0)}else{for(w=""+un(w),g=null,j=0;j<h.length;j++){if(h[j].value===w){h[j].selected=!0,N&&(h[j].defaultSelected=!0);return}g!==null||h[j].disabled||(g=h[j])}g!==null&&(g.selected=!0)}}function Pt(h,g,w){if(g!=null&&(g=""+un(g),g!==h.value&&(h.value=g),w==null)){h.defaultValue!==g&&(h.defaultValue=g);return}h.defaultValue=w!=null?""+un(w):""}function qt(h,g,w,N){if(g==null){if(N!=null){if(w!=null)throw Error(r(92));if($(N)){if(1<N.length)throw Error(r(93));N=N[0]}w=N}w==null&&(w=""),g=w}w=un(g),h.defaultValue=w,N=h.textContent,N===w&&N!==""&&N!==null&&(h.value=N),on(h)}function vt(h,g){if(g){var w=h.firstChild;if(w&&w===h.lastChild&&w.nodeType===3){w.nodeValue=g;return}}h.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(h,g,w){var N=g.indexOf("--")===0;w==null||typeof w=="boolean"||w===""?N?h.setProperty(g,""):g==="float"?h.cssFloat="":h[g]="":N?h.setProperty(g,w):typeof w!="number"||w===0||wn.has(g)?g==="float"?h.cssFloat=w:h[g]=(""+w).trim():h[g]=w+"px"}function Qr(h,g,w){if(g!=null&&typeof g!="object")throw Error(r(62));if(h=h.style,w!=null){for(var N in w)!w.hasOwnProperty(N)||g!=null&&g.hasOwnProperty(N)||(N.indexOf("--")===0?h.setProperty(N,""):N==="float"?h.cssFloat="":h[N]="");for(var j in g)N=g[j],g.hasOwnProperty(j)&&w[j]!==N&&Fr(h,j,N)}else for(var L in g)g.hasOwnProperty(L)&&Fr(h,L,g[L])}function Br(h){if(h.indexOf("-")===-1)return!1;switch(h){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var qs=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(h){return nn.test(""+h)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":h}function Si(){}var Ss=null;function _o(h){return h=h.target||h.srcElement||window,h.correspondingUseElement&&(h=h.correspondingUseElement),h.nodeType===3?h.parentNode:h}var So=null,No=null;function Ns(h){var g=fe(h);if(g&&(h=g.stateNode)){var w=h[Nn]||null;e:switch(h=g.stateNode,g.type){case"input":if(si(h,w.value,w.defaultValue,w.defaultValue,w.checked,w.defaultChecked,w.type,w.name),g=w.name,w.type==="radio"&&g!=null){for(w=h;w.parentNode;)w=w.parentNode;for(w=w.querySelectorAll('input[name="'+jn(""+g)+'"][type="radio"]'),g=0;g<w.length;g++){var N=w[g];if(N!==h&&N.form===h.form){var j=N[Nn]||null;if(!j)throw Error(r(90));si(N,j.value,j.defaultValue,j.defaultValue,j.checked,j.defaultChecked,j.type,j.name)}}for(g=0;g<w.length;g++)N=w[g],N.form===h.form&&dn(N)}break e;case"textarea":Pt(h,w.value,w.defaultValue);break e;case"select":g=w.value,g!=null&&nt(h,!!w.multiple,g,!1)}}}var Ni=!1;function Ws(h,g,w){if(Ni)return h(g,w);Ni=!0;try{var N=h(g);return N}finally{if(Ni=!1,(So!==null||No!==null)&&(lw(),So&&(g=So,h=No,No=So=null,Ns(g),h)))for(g=0;g<h.length;g++)Ns(h[g])}}function ca(h,g){var w=h.stateNode;if(w===null)return null;var N=w[Nn]||null;if(N===null)return null;w=N[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":(N=!N.disabled)||(h=h.type,N=!(h==="button"||h==="input"||h==="select"||h==="textarea")),h=!N;break e;default:h=!1}if(h)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"),Ux=!1;if(Hr)try{var $h={};Object.defineProperty($h,"passive",{get:function(){Ux=!0}}),window.addEventListener("test",$h,$h),window.removeEventListener("test",$h,$h)}catch{Ux=!1}var $l=null,zx=null,Dm=null;function Rm(){if(Dm)return Dm;var h,g=zx,w=g.length,N,j="value"in $l?$l.value:$l.textContent,L=j.length;for(h=0;h<w&&g[h]===j[h];h++);var J=w-h;for(N=1;N<=J&&g[w-N]===j[L-N];N++);return Dm=j.slice(h,1<N?1-N:void 0)}function Vh(h){var g=h.keyCode;return"charCode"in h?(h=h.charCode,h===0&&g===13&&(h=13)):h=g,h===10&&(h=13),32<=h||h===13?h:0}function Qu(){return!0}function Pc(){return!1}function ua(h){function g(w,N,j,L,J){this._reactName=w,this._targetInst=j,this.type=N,this.nativeEvent=L,this.target=J,this.currentTarget=null;for(var ye in h)h.hasOwnProperty(ye)&&(w=h[ye],this[ye]=w?w(L):L[ye]);return this.isDefaultPrevented=(L.defaultPrevented!=null?L.defaultPrevented:L.returnValue===!1)?Qu:Pc,this.isPropagationStopped=Pc,this}return f(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=Qu)},stopPropagation:function(){var w=this.nativeEvent;w&&(w.stopPropagation?w.stopPropagation():typeof w.cancelBubble!="unknown"&&(w.cancelBubble=!0),this.isPropagationStopped=Qu)},persist:function(){},isPersistent:Qu}),g}var pl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(h){return h.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Vl=ua(pl),gl=f({},pl,{view:0,detail:0}),Om=ua(gl),Lm,Fm,Zu,fn=f({},gl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:$x,button:0,buttons:0,relatedTarget:function(h){return h.relatedTarget===void 0?h.fromElement===h.srcElement?h.toElement:h.fromElement:h.relatedTarget},movementX:function(h){return"movementX"in h?h.movementX:(h!==Zu&&(Zu&&h.type==="mousemove"?(Lm=h.screenX-Zu.screenX,Fm=h.screenY-Zu.screenY):Fm=Lm=0,Zu=h),Lm)},movementY:function(h){return"movementY"in h?h.movementY:Fm}}),Nv=ua(fn),Bx=f({},fn,{dataTransfer:0}),Mv=ua(Bx),Hx=f({},gl,{relatedTarget:0}),Im=ua(Hx),G2=f({},pl,{animationName:0,elapsedTime:0,pseudoElement:0}),kv=ua(G2),oe=f({},pl,{clipboardData:function(h){return"clipboardData"in h?h.clipboardData:window.clipboardData}}),_t=ua(oe),On=f({},pl,{data:0}),er=ua(On),Mo={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Ju={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"},is={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function as(h){var g=this.nativeEvent;return g.getModifierState?g.getModifierState(h):(h=is[h])?!!g[h]:!1}function $x(){return as}var uF=f({},gl,{key:function(h){if(h.key){var g=Mo[h.key]||h.key;if(g!=="Unidentified")return g}return h.type==="keypress"?(h=Vh(h),h===13?"Enter":String.fromCharCode(h)):h.type==="keydown"||h.type==="keyup"?Ju[h.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:$x,charCode:function(h){return h.type==="keypress"?Vh(h):0},keyCode:function(h){return h.type==="keydown"||h.type==="keyup"?h.keyCode:0},which:function(h){return h.type==="keypress"?Vh(h):h.type==="keydown"||h.type==="keyup"?h.keyCode:0}}),Gre=ua(uF),qre=f({},fn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),dF=ua(qre),Wre=f({},gl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:$x}),Kre=ua(Wre),Xre=f({},pl,{propertyName:0,elapsedTime:0,pseudoElement:0}),Yre=ua(Xre),Qre=f({},fn,{deltaX:function(h){return"deltaX"in h?h.deltaX:"wheelDeltaX"in h?-h.wheelDeltaX:0},deltaY:function(h){return"deltaY"in h?h.deltaY:"wheelDeltaY"in h?-h.wheelDeltaY:"wheelDelta"in h?-h.wheelDelta:0},deltaZ:0,deltaMode:0}),Zre=ua(Qre),Jre=f({},pl,{newState:0,oldState:0}),eie=ua(Jre),tie=[9,13,27,32],q2=Hr&&"CompositionEvent"in window,Vx=null;Hr&&"documentMode"in document&&(Vx=document.documentMode);var nie=Hr&&"TextEvent"in window&&!Vx,hF=Hr&&(!q2||Vx&&8<Vx&&11>=Vx),fF=" ",mF=!1;function pF(h,g){switch(h){case"keyup":return tie.indexOf(g.keyCode)!==-1;case"keydown":return g.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function gF(h){return h=h.detail,typeof h=="object"&&"data"in h?h.data:null}var Um=!1;function rie(h,g){switch(h){case"compositionend":return gF(g);case"keypress":return g.which!==32?null:(mF=!0,fF);case"textInput":return h=g.data,h===fF&&mF?null:h;default:return null}}function iie(h,g){if(Um)return h==="compositionend"||!q2&&pF(h,g)?(h=Rm(),Dm=zx=$l=null,Um=!1,h):null;switch(h){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 hF&&g.locale!=="ko"?null:g.data;default:return null}}var aie={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 xF(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g==="input"?!!aie[h.type]:g==="textarea"}function bF(h,g,w,N){So?No?No.push(N):No=[N]:So=N,g=pw(g,"onChange"),0<g.length&&(w=new Vl("onChange","change",null,w,N),h.push({event:w,listeners:g}))}var Gx=null,qx=null;function sie(h){eU(h,0)}function Ev(h){var g=De(h);if(dn(g))return h}function yF(h,g){if(h==="change")return g}var vF=!1;if(Hr){var W2;if(Hr){var K2="oninput"in document;if(!K2){var wF=document.createElement("div");wF.setAttribute("oninput","return;"),K2=typeof wF.oninput=="function"}W2=K2}else W2=!1;vF=W2&&(!document.documentMode||9<document.documentMode)}function _F(){Gx&&(Gx.detachEvent("onpropertychange",SF),qx=Gx=null)}function SF(h){if(h.propertyName==="value"&&Ev(qx)){var g=[];bF(g,qx,h,_o(h)),Ws(sie,g)}}function oie(h,g,w){h==="focusin"?(_F(),Gx=g,qx=w,Gx.attachEvent("onpropertychange",SF)):h==="focusout"&&_F()}function lie(h){if(h==="selectionchange"||h==="keyup"||h==="keydown")return Ev(qx)}function cie(h,g){if(h==="click")return Ev(g)}function uie(h,g){if(h==="input"||h==="change")return Ev(g)}function die(h,g){return h===g&&(h!==0||1/h===1/g)||h!==h&&g!==g}var Ks=typeof Object.is=="function"?Object.is:die;function Wx(h,g){if(Ks(h,g))return!0;if(typeof h!="object"||h===null||typeof g!="object"||g===null)return!1;var w=Object.keys(h),N=Object.keys(g);if(w.length!==N.length)return!1;for(N=0;N<w.length;N++){var j=w[N];if(!U.call(g,j)||!Ks(h[j],g[j]))return!1}return!0}function NF(h){for(;h&&h.firstChild;)h=h.firstChild;return h}function MF(h,g){var w=NF(h);h=0;for(var N;w;){if(w.nodeType===3){if(N=h+w.textContent.length,h<=g&&N>=g)return{node:w,offset:g-h};h=N}e:{for(;w;){if(w.nextSibling){w=w.nextSibling;break e}w=w.parentNode}w=void 0}w=NF(w)}}function kF(h,g){return h&&g?h===g?!0:h&&h.nodeType===3?!1:g&&g.nodeType===3?kF(h,g.parentNode):"contains"in h?h.contains(g):h.compareDocumentPosition?!!(h.compareDocumentPosition(g)&16):!1:!1}function EF(h){h=h!=null&&h.ownerDocument!=null&&h.ownerDocument.defaultView!=null?h.ownerDocument.defaultView:window;for(var g=Yt(h.document);g instanceof h.HTMLIFrameElement;){try{var w=typeof g.contentWindow.location.href=="string"}catch{w=!1}if(w)h=g.contentWindow;else break;g=Yt(h.document)}return g}function X2(h){var g=h&&h.nodeName&&h.nodeName.toLowerCase();return g&&(g==="input"&&(h.type==="text"||h.type==="search"||h.type==="tel"||h.type==="url"||h.type==="password")||g==="textarea"||h.contentEditable==="true")}var hie=Hr&&"documentMode"in document&&11>=document.documentMode,zm=null,Y2=null,Kx=null,Q2=!1;function TF(h,g,w){var N=w.window===w?w.document:w.nodeType===9?w:w.ownerDocument;Q2||zm==null||zm!==Yt(N)||(N=zm,"selectionStart"in N&&X2(N)?N={start:N.selectionStart,end:N.selectionEnd}:(N=(N.ownerDocument&&N.ownerDocument.defaultView||window).getSelection(),N={anchorNode:N.anchorNode,anchorOffset:N.anchorOffset,focusNode:N.focusNode,focusOffset:N.focusOffset}),Kx&&Wx(Kx,N)||(Kx=N,N=pw(Y2,"onSelect"),0<N.length&&(g=new Vl("onSelect","select",null,g,w),h.push({event:g,listeners:N}),g.target=zm)))}function Gh(h,g){var w={};return w[h.toLowerCase()]=g.toLowerCase(),w["Webkit"+h]="webkit"+g,w["Moz"+h]="moz"+g,w}var Bm={animationend:Gh("Animation","AnimationEnd"),animationiteration:Gh("Animation","AnimationIteration"),animationstart:Gh("Animation","AnimationStart"),transitionrun:Gh("Transition","TransitionRun"),transitionstart:Gh("Transition","TransitionStart"),transitioncancel:Gh("Transition","TransitionCancel"),transitionend:Gh("Transition","TransitionEnd")},Z2={},AF={};Hr&&(AF=document.createElement("div").style,"AnimationEvent"in window||(delete Bm.animationend.animation,delete Bm.animationiteration.animation,delete Bm.animationstart.animation),"TransitionEvent"in window||delete Bm.transitionend.transition);function qh(h){if(Z2[h])return Z2[h];if(!Bm[h])return h;var g=Bm[h],w;for(w in g)if(g.hasOwnProperty(w)&&w in AF)return Z2[h]=g[w];return h}var CF=qh("animationend"),PF=qh("animationiteration"),jF=qh("animationstart"),fie=qh("transitionrun"),mie=qh("transitionstart"),pie=qh("transitioncancel"),DF=qh("transitionend"),RF=new Map,J2="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(" ");J2.push("scrollEnd");function xl(h,g){RF.set(h,g),Qe(g,[h])}var Tv=typeof reportError=="function"?reportError:function(h){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var g=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof h=="object"&&h!==null&&typeof h.message=="string"?String(h.message):String(h),error:h});if(!window.dispatchEvent(g))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",h);return}console.error(h)},ko=[],Hm=0,ek=0;function Av(){for(var h=Hm,g=ek=Hm=0;g<h;){var w=ko[g];ko[g++]=null;var N=ko[g];ko[g++]=null;var j=ko[g];ko[g++]=null;var L=ko[g];if(ko[g++]=null,N!==null&&j!==null){var J=N.pending;J===null?j.next=j:(j.next=J.next,J.next=j),N.pending=j}L!==0&&OF(w,j,L)}}function Cv(h,g,w,N){ko[Hm++]=h,ko[Hm++]=g,ko[Hm++]=w,ko[Hm++]=N,ek|=N,h.lanes|=N,h=h.alternate,h!==null&&(h.lanes|=N)}function tk(h,g,w,N){return Cv(h,g,w,N),Pv(h)}function Wh(h,g){return Cv(h,null,null,g),Pv(h)}function OF(h,g,w){h.lanes|=w;var N=h.alternate;N!==null&&(N.lanes|=w);for(var j=!1,L=h.return;L!==null;)L.childLanes|=w,N=L.alternate,N!==null&&(N.childLanes|=w),L.tag===22&&(h=L.stateNode,h===null||h._visibility&1||(j=!0)),h=L,L=L.return;return h.tag===3?(L=h.stateNode,j&&g!==null&&(j=31-ze(w),h=L.hiddenUpdates,N=h[j],N===null?h[j]=[g]:N.push(g),g.lane=w|536870912),L):null}function Pv(h){if(50<gb)throw gb=0,uE=null,Error(r(185));for(var g=h.return;g!==null;)h=g,g=h.return;return h.tag===3?h.stateNode:null}var $m={};function gie(h,g,w,N){this.tag=h,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=N,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Xs(h,g,w,N){return new gie(h,g,w,N)}function nk(h){return h=h.prototype,!(!h||!h.isReactComponent)}function jc(h,g){var w=h.alternate;return w===null?(w=Xs(h.tag,g,h.key,h.mode),w.elementType=h.elementType,w.type=h.type,w.stateNode=h.stateNode,w.alternate=h,h.alternate=w):(w.pendingProps=g,w.type=h.type,w.flags=0,w.subtreeFlags=0,w.deletions=null),w.flags=h.flags&65011712,w.childLanes=h.childLanes,w.lanes=h.lanes,w.child=h.child,w.memoizedProps=h.memoizedProps,w.memoizedState=h.memoizedState,w.updateQueue=h.updateQueue,g=h.dependencies,w.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext},w.sibling=h.sibling,w.index=h.index,w.ref=h.ref,w.refCleanup=h.refCleanup,w}function LF(h,g){h.flags&=65011714;var w=h.alternate;return w===null?(h.childLanes=0,h.lanes=g,h.child=null,h.subtreeFlags=0,h.memoizedProps=null,h.memoizedState=null,h.updateQueue=null,h.dependencies=null,h.stateNode=null):(h.childLanes=w.childLanes,h.lanes=w.lanes,h.child=w.child,h.subtreeFlags=0,h.deletions=null,h.memoizedProps=w.memoizedProps,h.memoizedState=w.memoizedState,h.updateQueue=w.updateQueue,h.type=w.type,g=w.dependencies,h.dependencies=g===null?null:{lanes:g.lanes,firstContext:g.firstContext}),h}function jv(h,g,w,N,j,L){var J=0;if(N=h,typeof h=="function")nk(h)&&(J=1);else if(typeof h=="string")J=wae(h,w,ne.current)?26:h==="html"||h==="head"||h==="body"?27:5;else e:switch(h){case A:return h=Xs(31,w,g,j),h.elementType=A,h.lanes=L,h;case b:return Kh(w.children,j,L,g);case v:J=8,j|=24;break;case y:return h=Xs(12,w,g,j|2),h.elementType=y,h.lanes=L,h;case M:return h=Xs(13,w,g,j),h.elementType=M,h.lanes=L,h;case C:return h=Xs(19,w,g,j),h.elementType=C,h.lanes=L,h;default:if(typeof h=="object"&&h!==null)switch(h.$$typeof){case k:J=10;break e;case S:J=9;break e;case T:J=11;break e;case E:J=14;break e;case R:J=16,N=null;break e}J=29,w=Error(r(130,h===null?"null":typeof h,"")),N=null}return g=Xs(J,w,g,j),g.elementType=h,g.type=N,g.lanes=L,g}function Kh(h,g,w,N){return h=Xs(7,h,N,g),h.lanes=w,h}function rk(h,g,w){return h=Xs(6,h,null,g),h.lanes=w,h}function FF(h){var g=Xs(18,null,null,0);return g.stateNode=h,g}function ik(h,g,w){return g=Xs(4,h.children!==null?h.children:[],h.key,g),g.lanes=w,g.stateNode={containerInfo:h.containerInfo,pendingChildren:null,implementation:h.implementation},g}var IF=new WeakMap;function Eo(h,g){if(typeof h=="object"&&h!==null){var w=IF.get(h);return w!==void 0?w:(g={value:h,source:g,stack:te(g)},IF.set(h,g),g)}return{value:h,source:g,stack:te(g)}}var Vm=[],Gm=0,Dv=null,Xx=0,To=[],Ao=0,ed=null,Gl=1,ql="";function Dc(h,g){Vm[Gm++]=Xx,Vm[Gm++]=Dv,Dv=h,Xx=g}function UF(h,g,w){To[Ao++]=Gl,To[Ao++]=ql,To[Ao++]=ed,ed=h;var N=Gl;h=ql;var j=32-ze(N)-1;N&=~(1<<j),w+=1;var L=32-ze(g)+j;if(30<L){var J=j-j%5;L=(N&(1<<J)-1).toString(32),N>>=J,j-=J,Gl=1<<32-ze(g)+j|w<<j|N,ql=L+h}else Gl=1<<L|w<<j|N,ql=h}function ak(h){h.return!==null&&(Dc(h,1),UF(h,1,0))}function sk(h){for(;h===Dv;)Dv=Vm[--Gm],Vm[Gm]=null,Xx=Vm[--Gm],Vm[Gm]=null;for(;h===ed;)ed=To[--Ao],To[Ao]=null,ql=To[--Ao],To[Ao]=null,Gl=To[--Ao],To[Ao]=null}function zF(h,g){To[Ao++]=Gl,To[Ao++]=ql,To[Ao++]=ed,Gl=g.id,ql=g.overflow,ed=h}var ka=null,$r=null,Yn=!1,td=null,Co=!1,ok=Error(r(519));function nd(h){var g=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Yx(Eo(g,h)),ok}function BF(h){var g=h.stateNode,w=h.type,N=h.memoizedProps;switch(g[Xn]=h,g[Nn]=N,w){case"dialog":Un("cancel",g),Un("close",g);break;case"iframe":case"object":case"embed":Un("load",g);break;case"video":case"audio":for(w=0;w<bb.length;w++)Un(bb[w],g);break;case"source":Un("error",g);break;case"img":case"image":case"link":Un("error",g),Un("load",g);break;case"details":Un("toggle",g);break;case"input":Un("invalid",g),ar(g,N.value,N.defaultValue,N.checked,N.defaultChecked,N.type,N.name,!0);break;case"select":Un("invalid",g);break;case"textarea":Un("invalid",g),qt(g,N.value,N.defaultValue,N.children)}w=N.children,typeof w!="string"&&typeof w!="number"&&typeof w!="bigint"||g.textContent===""+w||N.suppressHydrationWarning===!0||iU(g.textContent,w)?(N.popover!=null&&(Un("beforetoggle",g),Un("toggle",g)),N.onScroll!=null&&Un("scroll",g),N.onScrollEnd!=null&&Un("scrollend",g),N.onClick!=null&&(g.onclick=Si),g=!0):g=!1,g||nd(h,!0)}function HF(h){for(ka=h.return;ka;)switch(ka.tag){case 5:case 31:case 13:Co=!1;return;case 27:case 3:Co=!0;return;default:ka=ka.return}}function qm(h){if(h!==ka)return!1;if(!Yn)return HF(h),Yn=!0,!1;var g=h.tag,w;if((w=g!==3&&g!==27)&&((w=g===5)&&(w=h.type,w=!(w!=="form"&&w!=="button")||ME(h.type,h.memoizedProps)),w=!w),w&&$r&&nd(h),HF(h),g===13){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));$r=fU(h)}else if(g===31){if(h=h.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(317));$r=fU(h)}else g===27?(g=$r,gd(h.type)?(h=CE,CE=null,$r=h):$r=g):$r=ka?jo(h.stateNode.nextSibling):null;return!0}function Xh(){$r=ka=null,Yn=!1}function lk(){var h=td;return h!==null&&(Ts===null?Ts=h:Ts.push.apply(Ts,h),td=null),h}function Yx(h){td===null?td=[h]:td.push(h)}var ck=H(null),Yh=null,Rc=null;function rd(h,g,w){re(ck,g._currentValue),g._currentValue=w}function Oc(h){h._currentValue=ck.current,K(ck)}function uk(h,g,w){for(;h!==null;){var N=h.alternate;if((h.childLanes&g)!==g?(h.childLanes|=g,N!==null&&(N.childLanes|=g)):N!==null&&(N.childLanes&g)!==g&&(N.childLanes|=g),h===w)break;h=h.return}}function dk(h,g,w,N){var j=h.child;for(j!==null&&(j.return=h);j!==null;){var L=j.dependencies;if(L!==null){var J=j.child;L=L.firstContext;e:for(;L!==null;){var ye=L;L=j;for(var Ie=0;Ie<g.length;Ie++)if(ye.context===g[Ie]){L.lanes|=w,ye=L.alternate,ye!==null&&(ye.lanes|=w),uk(L.return,w,h),N||(J=null);break e}L=ye.next}}else if(j.tag===18){if(J=j.return,J===null)throw Error(r(341));J.lanes|=w,L=J.alternate,L!==null&&(L.lanes|=w),uk(J,w,h),J=null}else J=j.child;if(J!==null)J.return=j;else for(J=j;J!==null;){if(J===h){J=null;break}if(j=J.sibling,j!==null){j.return=J.return,J=j;break}J=J.return}j=J}}function Wm(h,g,w,N){h=null;for(var j=g,L=!1;j!==null;){if(!L){if((j.flags&524288)!==0)L=!0;else if((j.flags&262144)!==0)break}if(j.tag===10){var J=j.alternate;if(J===null)throw Error(r(387));if(J=J.memoizedProps,J!==null){var ye=j.type;Ks(j.pendingProps.value,J.value)||(h!==null?h.push(ye):h=[ye])}}else if(j===de.current){if(J=j.alternate,J===null)throw Error(r(387));J.memoizedState.memoizedState!==j.memoizedState.memoizedState&&(h!==null?h.push(Sb):h=[Sb])}j=j.return}h!==null&&dk(g,h,w,N),g.flags|=262144}function Rv(h){for(h=h.firstContext;h!==null;){if(!Ks(h.context._currentValue,h.memoizedValue))return!0;h=h.next}return!1}function Qh(h){Yh=h,Rc=null,h=h.dependencies,h!==null&&(h.firstContext=null)}function Ea(h){return $F(Yh,h)}function Ov(h,g){return Yh===null&&Qh(h),$F(h,g)}function $F(h,g){var w=g._currentValue;if(g={context:g,memoizedValue:w,next:null},Rc===null){if(h===null)throw Error(r(308));Rc=g,h.dependencies={lanes:0,firstContext:g},h.flags|=524288}else Rc=Rc.next=g;return w}var xie=typeof AbortController<"u"?AbortController:function(){var h=[],g=this.signal={aborted:!1,addEventListener:function(w,N){h.push(N)}};this.abort=function(){g.aborted=!0,h.forEach(function(w){return w()})}},bie=t.unstable_scheduleCallback,yie=t.unstable_NormalPriority,Pi={$$typeof:k,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function hk(){return{controller:new xie,data:new Map,refCount:0}}function Qx(h){h.refCount--,h.refCount===0&&bie(yie,function(){h.controller.abort()})}var Zx=null,fk=0,Km=0,Xm=null;function vie(h,g){if(Zx===null){var w=Zx=[];fk=0,Km=gE(),Xm={status:"pending",value:void 0,then:function(N){w.push(N)}}}return fk++,g.then(VF,VF),g}function VF(){if(--fk===0&&Zx!==null){Xm!==null&&(Xm.status="fulfilled");var h=Zx;Zx=null,Km=0,Xm=null;for(var g=0;g<h.length;g++)(0,h[g])()}}function wie(h,g){var w=[],N={status:"pending",value:null,reason:null,then:function(j){w.push(j)}};return h.then(function(){N.status="fulfilled",N.value=g;for(var j=0;j<w.length;j++)(0,w[j])(g)},function(j){for(N.status="rejected",N.reason=j,j=0;j<w.length;j++)(0,w[j])(void 0)}),N}var GF=X.S;X.S=function(h,g){T5=O(),typeof g=="object"&&g!==null&&typeof g.then=="function"&&vie(h,g),GF!==null&&GF(h,g)};var Zh=H(null);function mk(){var h=Zh.current;return h!==null?h:jr.pooledCache}function Lv(h,g){g===null?re(Zh,Zh.current):re(Zh,g.pool)}function qF(){var h=mk();return h===null?null:{parent:Pi._currentValue,pool:h}}var Ym=Error(r(460)),pk=Error(r(474)),Fv=Error(r(542)),Iv={then:function(){}};function WF(h){return h=h.status,h==="fulfilled"||h==="rejected"}function KF(h,g,w){switch(w=h[w],w===void 0?h.push(g):w!==g&&(g.then(Si,Si),g=w),g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,YF(h),h;default:if(typeof g.status=="string")g.then(Si,Si);else{if(h=jr,h!==null&&100<h.shellSuspendCounter)throw Error(r(482));h=g,h.status="pending",h.then(function(N){if(g.status==="pending"){var j=g;j.status="fulfilled",j.value=N}},function(N){if(g.status==="pending"){var j=g;j.status="rejected",j.reason=N}})}switch(g.status){case"fulfilled":return g.value;case"rejected":throw h=g.reason,YF(h),h}throw ef=g,Ym}}function Jh(h){try{var g=h._init;return g(h._payload)}catch(w){throw w!==null&&typeof w=="object"&&typeof w.then=="function"?(ef=w,Ym):w}}var ef=null;function XF(){if(ef===null)throw Error(r(459));var h=ef;return ef=null,h}function YF(h){if(h===Ym||h===Fv)throw Error(r(483))}var Qm=null,Jx=0;function Uv(h){var g=Jx;return Jx+=1,Qm===null&&(Qm=[]),KF(Qm,h,g)}function eb(h,g){g=g.props.ref,h.ref=g!==void 0?g:null}function zv(h,g){throw g.$$typeof===p?Error(r(525)):(h=Object.prototype.toString.call(g),Error(r(31,h==="[object Object]"?"object with keys {"+Object.keys(g).join(", ")+"}":h)))}function QF(h){function g(Je,Ge){if(h){var at=Je.deletions;at===null?(Je.deletions=[Ge],Je.flags|=16):at.push(Ge)}}function w(Je,Ge){if(!h)return null;for(;Ge!==null;)g(Je,Ge),Ge=Ge.sibling;return null}function N(Je){for(var Ge=new Map;Je!==null;)Je.key!==null?Ge.set(Je.key,Je):Ge.set(Je.index,Je),Je=Je.sibling;return Ge}function j(Je,Ge){return Je=jc(Je,Ge),Je.index=0,Je.sibling=null,Je}function L(Je,Ge,at){return Je.index=at,h?(at=Je.alternate,at!==null?(at=at.index,at<Ge?(Je.flags|=67108866,Ge):at):(Je.flags|=67108866,Ge)):(Je.flags|=1048576,Ge)}function J(Je){return h&&Je.alternate===null&&(Je.flags|=67108866),Je}function ye(Je,Ge,at,yt){return Ge===null||Ge.tag!==6?(Ge=rk(at,Je.mode,yt),Ge.return=Je,Ge):(Ge=j(Ge,at),Ge.return=Je,Ge)}function Ie(Je,Ge,at,yt){var Kt=at.type;return Kt===b?xt(Je,Ge,at.props.children,yt,at.key):Ge!==null&&(Ge.elementType===Kt||typeof Kt=="object"&&Kt!==null&&Kt.$$typeof===R&&Jh(Kt)===Ge.type)?(Ge=j(Ge,at.props),eb(Ge,at),Ge.return=Je,Ge):(Ge=jv(at.type,at.key,at.props,null,Je.mode,yt),eb(Ge,at),Ge.return=Je,Ge)}function st(Je,Ge,at,yt){return Ge===null||Ge.tag!==4||Ge.stateNode.containerInfo!==at.containerInfo||Ge.stateNode.implementation!==at.implementation?(Ge=ik(at,Je.mode,yt),Ge.return=Je,Ge):(Ge=j(Ge,at.children||[]),Ge.return=Je,Ge)}function xt(Je,Ge,at,yt,Kt){return Ge===null||Ge.tag!==7?(Ge=Kh(at,Je.mode,yt,Kt),Ge.return=Je,Ge):(Ge=j(Ge,at),Ge.return=Je,Ge)}function wt(Je,Ge,at){if(typeof Ge=="string"&&Ge!==""||typeof Ge=="number"||typeof Ge=="bigint")return Ge=rk(""+Ge,Je.mode,at),Ge.return=Je,Ge;if(typeof Ge=="object"&&Ge!==null){switch(Ge.$$typeof){case m:return at=jv(Ge.type,Ge.key,Ge.props,null,Je.mode,at),eb(at,Ge),at.return=Je,at;case x:return Ge=ik(Ge,Je.mode,at),Ge.return=Je,Ge;case R:return Ge=Jh(Ge),wt(Je,Ge,at)}if($(Ge)||F(Ge))return Ge=Kh(Ge,Je.mode,at,null),Ge.return=Je,Ge;if(typeof Ge.then=="function")return wt(Je,Uv(Ge),at);if(Ge.$$typeof===k)return wt(Je,Ov(Je,Ge),at);zv(Je,Ge)}return null}function dt(Je,Ge,at,yt){var Kt=Ge!==null?Ge.key:null;if(typeof at=="string"&&at!==""||typeof at=="number"||typeof at=="bigint")return Kt!==null?null:ye(Je,Ge,""+at,yt);if(typeof at=="object"&&at!==null){switch(at.$$typeof){case m:return at.key===Kt?Ie(Je,Ge,at,yt):null;case x:return at.key===Kt?st(Je,Ge,at,yt):null;case R:return at=Jh(at),dt(Je,Ge,at,yt)}if($(at)||F(at))return Kt!==null?null:xt(Je,Ge,at,yt,null);if(typeof at.then=="function")return dt(Je,Ge,Uv(at),yt);if(at.$$typeof===k)return dt(Je,Ge,Ov(Je,at),yt);zv(Je,at)}return null}function gt(Je,Ge,at,yt,Kt){if(typeof yt=="string"&&yt!==""||typeof yt=="number"||typeof yt=="bigint")return Je=Je.get(at)||null,ye(Ge,Je,""+yt,Kt);if(typeof yt=="object"&&yt!==null){switch(yt.$$typeof){case m:return Je=Je.get(yt.key===null?at:yt.key)||null,Ie(Ge,Je,yt,Kt);case x:return Je=Je.get(yt.key===null?at:yt.key)||null,st(Ge,Je,yt,Kt);case R:return yt=Jh(yt),gt(Je,Ge,at,yt,Kt)}if($(yt)||F(yt))return Je=Je.get(at)||null,xt(Ge,Je,yt,Kt,null);if(typeof yt.then=="function")return gt(Je,Ge,at,Uv(yt),Kt);if(yt.$$typeof===k)return gt(Je,Ge,at,Ov(Ge,yt),Kt);zv(Ge,yt)}return null}function Vt(Je,Ge,at,yt){for(var Kt=null,or=null,Wt=Ge,kn=Ge=0,Wn=null;Wt!==null&&kn<at.length;kn++){Wt.index>kn?(Wn=Wt,Wt=null):Wn=Wt.sibling;var lr=dt(Je,Wt,at[kn],yt);if(lr===null){Wt===null&&(Wt=Wn);break}h&&Wt&&lr.alternate===null&&g(Je,Wt),Ge=L(lr,Ge,kn),or===null?Kt=lr:or.sibling=lr,or=lr,Wt=Wn}if(kn===at.length)return w(Je,Wt),Yn&&Dc(Je,kn),Kt;if(Wt===null){for(;kn<at.length;kn++)Wt=wt(Je,at[kn],yt),Wt!==null&&(Ge=L(Wt,Ge,kn),or===null?Kt=Wt:or.sibling=Wt,or=Wt);return Yn&&Dc(Je,kn),Kt}for(Wt=N(Wt);kn<at.length;kn++)Wn=gt(Wt,Je,kn,at[kn],yt),Wn!==null&&(h&&Wn.alternate!==null&&Wt.delete(Wn.key===null?kn:Wn.key),Ge=L(Wn,Ge,kn),or===null?Kt=Wn:or.sibling=Wn,or=Wn);return h&&Wt.forEach(function(wd){return g(Je,wd)}),Yn&&Dc(Je,kn),Kt}function rn(Je,Ge,at,yt){if(at==null)throw Error(r(151));for(var Kt=null,or=null,Wt=Ge,kn=Ge=0,Wn=null,lr=at.next();Wt!==null&&!lr.done;kn++,lr=at.next()){Wt.index>kn?(Wn=Wt,Wt=null):Wn=Wt.sibling;var wd=dt(Je,Wt,lr.value,yt);if(wd===null){Wt===null&&(Wt=Wn);break}h&&Wt&&wd.alternate===null&&g(Je,Wt),Ge=L(wd,Ge,kn),or===null?Kt=wd:or.sibling=wd,or=wd,Wt=Wn}if(lr.done)return w(Je,Wt),Yn&&Dc(Je,kn),Kt;if(Wt===null){for(;!lr.done;kn++,lr=at.next())lr=wt(Je,lr.value,yt),lr!==null&&(Ge=L(lr,Ge,kn),or===null?Kt=lr:or.sibling=lr,or=lr);return Yn&&Dc(Je,kn),Kt}for(Wt=N(Wt);!lr.done;kn++,lr=at.next())lr=gt(Wt,Je,kn,lr.value,yt),lr!==null&&(h&&lr.alternate!==null&&Wt.delete(lr.key===null?kn:lr.key),Ge=L(lr,Ge,kn),or===null?Kt=lr:or.sibling=lr,or=lr);return h&&Wt.forEach(function(jae){return g(Je,jae)}),Yn&&Dc(Je,kn),Kt}function Sr(Je,Ge,at,yt){if(typeof at=="object"&&at!==null&&at.type===b&&at.key===null&&(at=at.props.children),typeof at=="object"&&at!==null){switch(at.$$typeof){case m:e:{for(var Kt=at.key;Ge!==null;){if(Ge.key===Kt){if(Kt=at.type,Kt===b){if(Ge.tag===7){w(Je,Ge.sibling),yt=j(Ge,at.props.children),yt.return=Je,Je=yt;break e}}else if(Ge.elementType===Kt||typeof Kt=="object"&&Kt!==null&&Kt.$$typeof===R&&Jh(Kt)===Ge.type){w(Je,Ge.sibling),yt=j(Ge,at.props),eb(yt,at),yt.return=Je,Je=yt;break e}w(Je,Ge);break}else g(Je,Ge);Ge=Ge.sibling}at.type===b?(yt=Kh(at.props.children,Je.mode,yt,at.key),yt.return=Je,Je=yt):(yt=jv(at.type,at.key,at.props,null,Je.mode,yt),eb(yt,at),yt.return=Je,Je=yt)}return J(Je);case x:e:{for(Kt=at.key;Ge!==null;){if(Ge.key===Kt)if(Ge.tag===4&&Ge.stateNode.containerInfo===at.containerInfo&&Ge.stateNode.implementation===at.implementation){w(Je,Ge.sibling),yt=j(Ge,at.children||[]),yt.return=Je,Je=yt;break e}else{w(Je,Ge);break}else g(Je,Ge);Ge=Ge.sibling}yt=ik(at,Je.mode,yt),yt.return=Je,Je=yt}return J(Je);case R:return at=Jh(at),Sr(Je,Ge,at,yt)}if($(at))return Vt(Je,Ge,at,yt);if(F(at)){if(Kt=F(at),typeof Kt!="function")throw Error(r(150));return at=Kt.call(at),rn(Je,Ge,at,yt)}if(typeof at.then=="function")return Sr(Je,Ge,Uv(at),yt);if(at.$$typeof===k)return Sr(Je,Ge,Ov(Je,at),yt);zv(Je,at)}return typeof at=="string"&&at!==""||typeof at=="number"||typeof at=="bigint"?(at=""+at,Ge!==null&&Ge.tag===6?(w(Je,Ge.sibling),yt=j(Ge,at),yt.return=Je,Je=yt):(w(Je,Ge),yt=rk(at,Je.mode,yt),yt.return=Je,Je=yt),J(Je)):w(Je,Ge)}return function(Je,Ge,at,yt){try{Jx=0;var Kt=Sr(Je,Ge,at,yt);return Qm=null,Kt}catch(Wt){if(Wt===Ym||Wt===Fv)throw Wt;var or=Xs(29,Wt,null,Je.mode);return or.lanes=yt,or.return=Je,or}finally{}}}var tf=QF(!0),ZF=QF(!1),id=!1;function gk(h){h.updateQueue={baseState:h.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function xk(h,g){h=h.updateQueue,g.updateQueue===h&&(g.updateQueue={baseState:h.baseState,firstBaseUpdate:h.firstBaseUpdate,lastBaseUpdate:h.lastBaseUpdate,shared:h.shared,callbacks:null})}function ad(h){return{lane:h,tag:0,payload:null,callback:null,next:null}}function sd(h,g,w){var N=h.updateQueue;if(N===null)return null;if(N=N.shared,(hr&2)!==0){var j=N.pending;return j===null?g.next=g:(g.next=j.next,j.next=g),N.pending=g,g=Pv(h),OF(h,null,w),g}return Cv(h,N,g,w),Pv(h)}function tb(h,g,w){if(g=g.updateQueue,g!==null&&(g=g.shared,(w&4194048)!==0)){var N=g.lanes;N&=h.pendingLanes,w|=N,g.lanes=w,cn(h,w)}}function bk(h,g){var w=h.updateQueue,N=h.alternate;if(N!==null&&(N=N.updateQueue,w===N)){var j=null,L=null;if(w=w.firstBaseUpdate,w!==null){do{var J={lane:w.lane,tag:w.tag,payload:w.payload,callback:null,next:null};L===null?j=L=J:L=L.next=J,w=w.next}while(w!==null);L===null?j=L=g:L=L.next=g}else j=L=g;w={baseState:N.baseState,firstBaseUpdate:j,lastBaseUpdate:L,shared:N.shared,callbacks:N.callbacks},h.updateQueue=w;return}h=w.lastBaseUpdate,h===null?w.firstBaseUpdate=g:h.next=g,w.lastBaseUpdate=g}var yk=!1;function nb(){if(yk){var h=Xm;if(h!==null)throw h}}function rb(h,g,w,N){yk=!1;var j=h.updateQueue;id=!1;var L=j.firstBaseUpdate,J=j.lastBaseUpdate,ye=j.shared.pending;if(ye!==null){j.shared.pending=null;var Ie=ye,st=Ie.next;Ie.next=null,J===null?L=st:J.next=st,J=Ie;var xt=h.alternate;xt!==null&&(xt=xt.updateQueue,ye=xt.lastBaseUpdate,ye!==J&&(ye===null?xt.firstBaseUpdate=st:ye.next=st,xt.lastBaseUpdate=Ie))}if(L!==null){var wt=j.baseState;J=0,xt=st=Ie=null,ye=L;do{var dt=ye.lane&-536870913,gt=dt!==ye.lane;if(gt?(qn&dt)===dt:(N&dt)===dt){dt!==0&&dt===Km&&(yk=!0),xt!==null&&(xt=xt.next={lane:0,tag:ye.tag,payload:ye.payload,callback:null,next:null});e:{var Vt=h,rn=ye;dt=g;var Sr=w;switch(rn.tag){case 1:if(Vt=rn.payload,typeof Vt=="function"){wt=Vt.call(Sr,wt,dt);break e}wt=Vt;break e;case 3:Vt.flags=Vt.flags&-65537|128;case 0:if(Vt=rn.payload,dt=typeof Vt=="function"?Vt.call(Sr,wt,dt):Vt,dt==null)break e;wt=f({},wt,dt);break e;case 2:id=!0}}dt=ye.callback,dt!==null&&(h.flags|=64,gt&&(h.flags|=8192),gt=j.callbacks,gt===null?j.callbacks=[dt]:gt.push(dt))}else gt={lane:dt,tag:ye.tag,payload:ye.payload,callback:ye.callback,next:null},xt===null?(st=xt=gt,Ie=wt):xt=xt.next=gt,J|=dt;if(ye=ye.next,ye===null){if(ye=j.shared.pending,ye===null)break;gt=ye,ye=gt.next,gt.next=null,j.lastBaseUpdate=gt,j.shared.pending=null}}while(!0);xt===null&&(Ie=wt),j.baseState=Ie,j.firstBaseUpdate=st,j.lastBaseUpdate=xt,L===null&&(j.shared.lanes=0),dd|=J,h.lanes=J,h.memoizedState=wt}}function JF(h,g){if(typeof h!="function")throw Error(r(191,h));h.call(g)}function eI(h,g){var w=h.callbacks;if(w!==null)for(h.callbacks=null,h=0;h<w.length;h++)JF(w[h],g)}var Zm=H(null),Bv=H(0);function tI(h,g){h=Vc,re(Bv,h),re(Zm,g),Vc=h|g.baseLanes}function vk(){re(Bv,Vc),re(Zm,Zm.current)}function wk(){Vc=Bv.current,K(Zm),K(Bv)}var Ys=H(null),Po=null;function od(h){var g=h.alternate;re(Mi,Mi.current&1),re(Ys,h),Po===null&&(g===null||Zm.current!==null||g.memoizedState!==null)&&(Po=h)}function _k(h){re(Mi,Mi.current),re(Ys,h),Po===null&&(Po=h)}function nI(h){h.tag===22?(re(Mi,Mi.current),re(Ys,h),Po===null&&(Po=h)):ld()}function ld(){re(Mi,Mi.current),re(Ys,Ys.current)}function Qs(h){K(Ys),Po===h&&(Po=null),K(Mi)}var Mi=H(0);function Hv(h){for(var g=h;g!==null;){if(g.tag===13){var w=g.memoizedState;if(w!==null&&(w=w.dehydrated,w===null||TE(w)||AE(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===h)break;for(;g.sibling===null;){if(g.return===null||g.return===h)return null;g=g.return}g.sibling.return=g.return,g=g.sibling}return null}var Lc=0,_n=null,wr=null,ji=null,$v=!1,Jm=!1,nf=!1,Vv=0,ib=0,ep=null,_ie=0;function fi(){throw Error(r(321))}function Sk(h,g){if(g===null)return!1;for(var w=0;w<g.length&&w<h.length;w++)if(!Ks(h[w],g[w]))return!1;return!0}function Nk(h,g,w,N,j,L){return Lc=L,_n=g,g.memoizedState=null,g.updateQueue=null,g.lanes=0,X.H=h===null||h.memoizedState===null?UI:Uk,nf=!1,L=w(N,j),nf=!1,Jm&&(L=iI(g,w,N,j)),rI(h),L}function rI(h){X.H=ob;var g=wr!==null&&wr.next!==null;if(Lc=0,ji=wr=_n=null,$v=!1,ib=0,ep=null,g)throw Error(r(300));h===null||Di||(h=h.dependencies,h!==null&&Rv(h)&&(Di=!0))}function iI(h,g,w,N){_n=h;var j=0;do{if(Jm&&(ep=null),ib=0,Jm=!1,25<=j)throw Error(r(301));if(j+=1,ji=wr=null,h.updateQueue!=null){var L=h.updateQueue;L.lastEffect=null,L.events=null,L.stores=null,L.memoCache!=null&&(L.memoCache.index=0)}X.H=zI,L=g(w,N)}while(Jm);return L}function Sie(){var h=X.H,g=h.useState()[0];return g=typeof g.then=="function"?ab(g):g,h=h.useState()[0],(wr!==null?wr.memoizedState:null)!==h&&(_n.flags|=1024),g}function Mk(){var h=Vv!==0;return Vv=0,h}function kk(h,g,w){g.updateQueue=h.updateQueue,g.flags&=-2053,h.lanes&=~w}function Ek(h){if($v){for(h=h.memoizedState;h!==null;){var g=h.queue;g!==null&&(g.pending=null),h=h.next}$v=!1}Lc=0,ji=wr=_n=null,Jm=!1,ib=Vv=0,ep=null}function ss(){var h={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return ji===null?_n.memoizedState=ji=h:ji=ji.next=h,ji}function ki(){if(wr===null){var h=_n.alternate;h=h!==null?h.memoizedState:null}else h=wr.next;var g=ji===null?_n.memoizedState:ji.next;if(g!==null)ji=g,wr=h;else{if(h===null)throw _n.alternate===null?Error(r(467)):Error(r(310));wr=h,h={memoizedState:wr.memoizedState,baseState:wr.baseState,baseQueue:wr.baseQueue,queue:wr.queue,next:null},ji===null?_n.memoizedState=ji=h:ji=ji.next=h}return ji}function Gv(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ab(h){var g=ib;return ib+=1,ep===null&&(ep=[]),h=KF(ep,h,g),g=_n,(ji===null?g.memoizedState:ji.next)===null&&(g=g.alternate,X.H=g===null||g.memoizedState===null?UI:Uk),h}function qv(h){if(h!==null&&typeof h=="object"){if(typeof h.then=="function")return ab(h);if(h.$$typeof===k)return Ea(h)}throw Error(r(438,String(h)))}function Tk(h){var g=null,w=_n.updateQueue;if(w!==null&&(g=w.memoCache),g==null){var N=_n.alternate;N!==null&&(N=N.updateQueue,N!==null&&(N=N.memoCache,N!=null&&(g={data:N.data.map(function(j){return j.slice()}),index:0})))}if(g==null&&(g={data:[],index:0}),w===null&&(w=Gv(),_n.updateQueue=w),w.memoCache=g,w=g.data[g.index],w===void 0)for(w=g.data[g.index]=Array(h),N=0;N<h;N++)w[N]=D;return g.index++,w}function Fc(h,g){return typeof g=="function"?g(h):g}function Wv(h){var g=ki();return Ak(g,wr,h)}function Ak(h,g,w){var N=h.queue;if(N===null)throw Error(r(311));N.lastRenderedReducer=w;var j=h.baseQueue,L=N.pending;if(L!==null){if(j!==null){var J=j.next;j.next=L.next,L.next=J}g.baseQueue=j=L,N.pending=null}if(L=h.baseState,j===null)h.memoizedState=L;else{g=j.next;var ye=J=null,Ie=null,st=g,xt=!1;do{var wt=st.lane&-536870913;if(wt!==st.lane?(qn&wt)===wt:(Lc&wt)===wt){var dt=st.revertLane;if(dt===0)Ie!==null&&(Ie=Ie.next={lane:0,revertLane:0,gesture:null,action:st.action,hasEagerState:st.hasEagerState,eagerState:st.eagerState,next:null}),wt===Km&&(xt=!0);else if((Lc&dt)===dt){st=st.next,dt===Km&&(xt=!0);continue}else wt={lane:0,revertLane:st.revertLane,gesture:null,action:st.action,hasEagerState:st.hasEagerState,eagerState:st.eagerState,next:null},Ie===null?(ye=Ie=wt,J=L):Ie=Ie.next=wt,_n.lanes|=dt,dd|=dt;wt=st.action,nf&&w(L,wt),L=st.hasEagerState?st.eagerState:w(L,wt)}else dt={lane:wt,revertLane:st.revertLane,gesture:st.gesture,action:st.action,hasEagerState:st.hasEagerState,eagerState:st.eagerState,next:null},Ie===null?(ye=Ie=dt,J=L):Ie=Ie.next=dt,_n.lanes|=wt,dd|=wt;st=st.next}while(st!==null&&st!==g);if(Ie===null?J=L:Ie.next=ye,!Ks(L,h.memoizedState)&&(Di=!0,xt&&(w=Xm,w!==null)))throw w;h.memoizedState=L,h.baseState=J,h.baseQueue=Ie,N.lastRenderedState=L}return j===null&&(N.lanes=0),[h.memoizedState,N.dispatch]}function Ck(h){var g=ki(),w=g.queue;if(w===null)throw Error(r(311));w.lastRenderedReducer=h;var N=w.dispatch,j=w.pending,L=g.memoizedState;if(j!==null){w.pending=null;var J=j=j.next;do L=h(L,J.action),J=J.next;while(J!==j);Ks(L,g.memoizedState)||(Di=!0),g.memoizedState=L,g.baseQueue===null&&(g.baseState=L),w.lastRenderedState=L}return[L,N]}function aI(h,g,w){var N=_n,j=ki(),L=Yn;if(L){if(w===void 0)throw Error(r(407));w=w()}else w=g();var J=!Ks((wr||j).memoizedState,w);if(J&&(j.memoizedState=w,Di=!0),j=j.queue,Dk(lI.bind(null,N,j,h),[h]),j.getSnapshot!==g||J||ji!==null&&ji.memoizedState.tag&1){if(N.flags|=2048,tp(9,{destroy:void 0},oI.bind(null,N,j,w,g),null),jr===null)throw Error(r(349));L||(Lc&127)!==0||sI(N,g,w)}return w}function sI(h,g,w){h.flags|=16384,h={getSnapshot:g,value:w},g=_n.updateQueue,g===null?(g=Gv(),_n.updateQueue=g,g.stores=[h]):(w=g.stores,w===null?g.stores=[h]:w.push(h))}function oI(h,g,w,N){g.value=w,g.getSnapshot=N,cI(g)&&uI(h)}function lI(h,g,w){return w(function(){cI(g)&&uI(h)})}function cI(h){var g=h.getSnapshot;h=h.value;try{var w=g();return!Ks(h,w)}catch{return!0}}function uI(h){var g=Wh(h,2);g!==null&&As(g,h,2)}function Pk(h){var g=ss();if(typeof h=="function"){var w=h;if(h=w(),nf){Pe(!0);try{w()}finally{Pe(!1)}}}return g.memoizedState=g.baseState=h,g.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fc,lastRenderedState:h},g}function dI(h,g,w,N){return h.baseState=w,Ak(h,wr,typeof N=="function"?N:Fc)}function Nie(h,g,w,N,j){if(Yv(h))throw Error(r(485));if(h=g.action,h!==null){var L={payload:j,action:h,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(J){L.listeners.push(J)}};X.T!==null?w(!0):L.isTransition=!1,N(L),w=g.pending,w===null?(L.next=g.pending=L,hI(g,L)):(L.next=w.next,g.pending=w.next=L)}}function hI(h,g){var w=g.action,N=g.payload,j=h.state;if(g.isTransition){var L=X.T,J={};X.T=J;try{var ye=w(j,N),Ie=X.S;Ie!==null&&Ie(J,ye),fI(h,g,ye)}catch(st){jk(h,g,st)}finally{L!==null&&J.types!==null&&(L.types=J.types),X.T=L}}else try{L=w(j,N),fI(h,g,L)}catch(st){jk(h,g,st)}}function fI(h,g,w){w!==null&&typeof w=="object"&&typeof w.then=="function"?w.then(function(N){mI(h,g,N)},function(N){return jk(h,g,N)}):mI(h,g,w)}function mI(h,g,w){g.status="fulfilled",g.value=w,pI(g),h.state=w,g=h.pending,g!==null&&(w=g.next,w===g?h.pending=null:(w=w.next,g.next=w,hI(h,w)))}function jk(h,g,w){var N=h.pending;if(h.pending=null,N!==null){N=N.next;do g.status="rejected",g.reason=w,pI(g),g=g.next;while(g!==N)}h.action=null}function pI(h){h=h.listeners;for(var g=0;g<h.length;g++)(0,h[g])()}function gI(h,g){return g}function xI(h,g){if(Yn){var w=jr.formState;if(w!==null){e:{var N=_n;if(Yn){if($r){t:{for(var j=$r,L=Co;j.nodeType!==8;){if(!L){j=null;break t}if(j=jo(j.nextSibling),j===null){j=null;break t}}L=j.data,j=L==="F!"||L==="F"?j:null}if(j){$r=jo(j.nextSibling),N=j.data==="F!";break e}}nd(N)}N=!1}N&&(g=w[0])}}return w=ss(),w.memoizedState=w.baseState=g,N={pending:null,lanes:0,dispatch:null,lastRenderedReducer:gI,lastRenderedState:g},w.queue=N,w=LI.bind(null,_n,N),N.dispatch=w,N=Pk(!1),L=Ik.bind(null,_n,!1,N.queue),N=ss(),j={state:g,dispatch:null,action:h,pending:null},N.queue=j,w=Nie.bind(null,_n,j,L,w),j.dispatch=w,N.memoizedState=h,[g,w,!1]}function bI(h){var g=ki();return yI(g,wr,h)}function yI(h,g,w){if(g=Ak(h,g,gI)[0],h=Wv(Fc)[0],typeof g=="object"&&g!==null&&typeof g.then=="function")try{var N=ab(g)}catch(J){throw J===Ym?Fv:J}else N=g;g=ki();var j=g.queue,L=j.dispatch;return w!==g.memoizedState&&(_n.flags|=2048,tp(9,{destroy:void 0},Mie.bind(null,j,w),null)),[N,L,h]}function Mie(h,g){h.action=g}function vI(h){var g=ki(),w=wr;if(w!==null)return yI(g,w,h);ki(),g=g.memoizedState,w=ki();var N=w.queue.dispatch;return w.memoizedState=h,[g,N,!1]}function tp(h,g,w,N){return h={tag:h,create:w,deps:N,inst:g,next:null},g=_n.updateQueue,g===null&&(g=Gv(),_n.updateQueue=g),w=g.lastEffect,w===null?g.lastEffect=h.next=h:(N=w.next,w.next=h,h.next=N,g.lastEffect=h),h}function wI(){return ki().memoizedState}function Kv(h,g,w,N){var j=ss();_n.flags|=h,j.memoizedState=tp(1|g,{destroy:void 0},w,N===void 0?null:N)}function Xv(h,g,w,N){var j=ki();N=N===void 0?null:N;var L=j.memoizedState.inst;wr!==null&&N!==null&&Sk(N,wr.memoizedState.deps)?j.memoizedState=tp(g,L,w,N):(_n.flags|=h,j.memoizedState=tp(1|g,L,w,N))}function _I(h,g){Kv(8390656,8,h,g)}function Dk(h,g){Xv(2048,8,h,g)}function kie(h){_n.flags|=4;var g=_n.updateQueue;if(g===null)g=Gv(),_n.updateQueue=g,g.events=[h];else{var w=g.events;w===null?g.events=[h]:w.push(h)}}function SI(h){var g=ki().memoizedState;return kie({ref:g,nextImpl:h}),function(){if((hr&2)!==0)throw Error(r(440));return g.impl.apply(void 0,arguments)}}function NI(h,g){return Xv(4,2,h,g)}function MI(h,g){return Xv(4,4,h,g)}function kI(h,g){if(typeof g=="function"){h=h();var w=g(h);return function(){typeof w=="function"?w():g(null)}}if(g!=null)return h=h(),g.current=h,function(){g.current=null}}function EI(h,g,w){w=w!=null?w.concat([h]):null,Xv(4,4,kI.bind(null,g,h),w)}function Rk(){}function TI(h,g){var w=ki();g=g===void 0?null:g;var N=w.memoizedState;return g!==null&&Sk(g,N[1])?N[0]:(w.memoizedState=[h,g],h)}function AI(h,g){var w=ki();g=g===void 0?null:g;var N=w.memoizedState;if(g!==null&&Sk(g,N[1]))return N[0];if(N=h(),nf){Pe(!0);try{h()}finally{Pe(!1)}}return w.memoizedState=[N,g],N}function Ok(h,g,w){return w===void 0||(Lc&1073741824)!==0&&(qn&261930)===0?h.memoizedState=g:(h.memoizedState=w,h=C5(),_n.lanes|=h,dd|=h,w)}function CI(h,g,w,N){return Ks(w,g)?w:Zm.current!==null?(h=Ok(h,w,N),Ks(h,g)||(Di=!0),h):(Lc&42)===0||(Lc&1073741824)!==0&&(qn&261930)===0?(Di=!0,h.memoizedState=w):(h=C5(),_n.lanes|=h,dd|=h,g)}function PI(h,g,w,N,j){var L=V.p;V.p=L!==0&&8>L?L:8;var J=X.T,ye={};X.T=ye,Ik(h,!1,g,w);try{var Ie=j(),st=X.S;if(st!==null&&st(ye,Ie),Ie!==null&&typeof Ie=="object"&&typeof Ie.then=="function"){var xt=wie(Ie,N);sb(h,g,xt,eo(h))}else sb(h,g,N,eo(h))}catch(wt){sb(h,g,{then:function(){},status:"rejected",reason:wt},eo())}finally{V.p=L,J!==null&&ye.types!==null&&(J.types=ye.types),X.T=J}}function Eie(){}function Lk(h,g,w,N){if(h.tag!==5)throw Error(r(476));var j=jI(h).queue;PI(h,j,g,Q,w===null?Eie:function(){return DI(h),w(N)})}function jI(h){var g=h.memoizedState;if(g!==null)return g;g={memoizedState:Q,baseState:Q,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fc,lastRenderedState:Q},next:null};var w={};return g.next={memoizedState:w,baseState:w,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fc,lastRenderedState:w},next:null},h.memoizedState=g,h=h.alternate,h!==null&&(h.memoizedState=g),g}function DI(h){var g=jI(h);g.next===null&&(g=h.alternate.memoizedState),sb(h,g.next.queue,{},eo())}function Fk(){return Ea(Sb)}function RI(){return ki().memoizedState}function OI(){return ki().memoizedState}function Tie(h){for(var g=h.return;g!==null;){switch(g.tag){case 24:case 3:var w=eo();h=ad(w);var N=sd(g,h,w);N!==null&&(As(N,g,w),tb(N,g,w)),g={cache:hk()},h.payload=g;return}g=g.return}}function Aie(h,g,w){var N=eo();w={lane:N,revertLane:0,gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null},Yv(h)?FI(g,w):(w=tk(h,g,w,N),w!==null&&(As(w,h,N),II(w,g,N)))}function LI(h,g,w){var N=eo();sb(h,g,w,N)}function sb(h,g,w,N){var j={lane:N,revertLane:0,gesture:null,action:w,hasEagerState:!1,eagerState:null,next:null};if(Yv(h))FI(g,j);else{var L=h.alternate;if(h.lanes===0&&(L===null||L.lanes===0)&&(L=g.lastRenderedReducer,L!==null))try{var J=g.lastRenderedState,ye=L(J,w);if(j.hasEagerState=!0,j.eagerState=ye,Ks(ye,J))return Cv(h,g,j,0),jr===null&&Av(),!1}catch{}finally{}if(w=tk(h,g,j,N),w!==null)return As(w,h,N),II(w,g,N),!0}return!1}function Ik(h,g,w,N){if(N={lane:2,revertLane:gE(),gesture:null,action:N,hasEagerState:!1,eagerState:null,next:null},Yv(h)){if(g)throw Error(r(479))}else g=tk(h,w,N,2),g!==null&&As(g,h,2)}function Yv(h){var g=h.alternate;return h===_n||g!==null&&g===_n}function FI(h,g){Jm=$v=!0;var w=h.pending;w===null?g.next=g:(g.next=w.next,w.next=g),h.pending=g}function II(h,g,w){if((w&4194048)!==0){var N=g.lanes;N&=h.pendingLanes,w|=N,g.lanes=w,cn(h,w)}}var ob={readContext:Ea,use:qv,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};ob.useEffectEvent=fi;var UI={readContext:Ea,use:qv,useCallback:function(h,g){return ss().memoizedState=[h,g===void 0?null:g],h},useContext:Ea,useEffect:_I,useImperativeHandle:function(h,g,w){w=w!=null?w.concat([h]):null,Kv(4194308,4,kI.bind(null,g,h),w)},useLayoutEffect:function(h,g){return Kv(4194308,4,h,g)},useInsertionEffect:function(h,g){Kv(4,2,h,g)},useMemo:function(h,g){var w=ss();g=g===void 0?null:g;var N=h();if(nf){Pe(!0);try{h()}finally{Pe(!1)}}return w.memoizedState=[N,g],N},useReducer:function(h,g,w){var N=ss();if(w!==void 0){var j=w(g);if(nf){Pe(!0);try{w(g)}finally{Pe(!1)}}}else j=g;return N.memoizedState=N.baseState=j,h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:h,lastRenderedState:j},N.queue=h,h=h.dispatch=Aie.bind(null,_n,h),[N.memoizedState,h]},useRef:function(h){var g=ss();return h={current:h},g.memoizedState=h},useState:function(h){h=Pk(h);var g=h.queue,w=LI.bind(null,_n,g);return g.dispatch=w,[h.memoizedState,w]},useDebugValue:Rk,useDeferredValue:function(h,g){var w=ss();return Ok(w,h,g)},useTransition:function(){var h=Pk(!1);return h=PI.bind(null,_n,h.queue,!0,!1),ss().memoizedState=h,[!1,h]},useSyncExternalStore:function(h,g,w){var N=_n,j=ss();if(Yn){if(w===void 0)throw Error(r(407));w=w()}else{if(w=g(),jr===null)throw Error(r(349));(qn&127)!==0||sI(N,g,w)}j.memoizedState=w;var L={value:w,getSnapshot:g};return j.queue=L,_I(lI.bind(null,N,L,h),[h]),N.flags|=2048,tp(9,{destroy:void 0},oI.bind(null,N,L,w,g),null),w},useId:function(){var h=ss(),g=jr.identifierPrefix;if(Yn){var w=ql,N=Gl;w=(N&~(1<<32-ze(N)-1)).toString(32)+w,g="_"+g+"R_"+w,w=Vv++,0<w&&(g+="H"+w.toString(32)),g+="_"}else w=_ie++,g="_"+g+"r_"+w.toString(32)+"_";return h.memoizedState=g},useHostTransitionStatus:Fk,useFormState:xI,useActionState:xI,useOptimistic:function(h){var g=ss();g.memoizedState=g.baseState=h;var w={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return g.queue=w,g=Ik.bind(null,_n,!0,w),w.dispatch=g,[h,g]},useMemoCache:Tk,useCacheRefresh:function(){return ss().memoizedState=Tie.bind(null,_n)},useEffectEvent:function(h){var g=ss(),w={impl:h};return g.memoizedState=w,function(){if((hr&2)!==0)throw Error(r(440));return w.impl.apply(void 0,arguments)}}},Uk={readContext:Ea,use:qv,useCallback:TI,useContext:Ea,useEffect:Dk,useImperativeHandle:EI,useInsertionEffect:NI,useLayoutEffect:MI,useMemo:AI,useReducer:Wv,useRef:wI,useState:function(){return Wv(Fc)},useDebugValue:Rk,useDeferredValue:function(h,g){var w=ki();return CI(w,wr.memoizedState,h,g)},useTransition:function(){var h=Wv(Fc)[0],g=ki().memoizedState;return[typeof h=="boolean"?h:ab(h),g]},useSyncExternalStore:aI,useId:RI,useHostTransitionStatus:Fk,useFormState:bI,useActionState:bI,useOptimistic:function(h,g){var w=ki();return dI(w,wr,h,g)},useMemoCache:Tk,useCacheRefresh:OI};Uk.useEffectEvent=SI;var zI={readContext:Ea,use:qv,useCallback:TI,useContext:Ea,useEffect:Dk,useImperativeHandle:EI,useInsertionEffect:NI,useLayoutEffect:MI,useMemo:AI,useReducer:Ck,useRef:wI,useState:function(){return Ck(Fc)},useDebugValue:Rk,useDeferredValue:function(h,g){var w=ki();return wr===null?Ok(w,h,g):CI(w,wr.memoizedState,h,g)},useTransition:function(){var h=Ck(Fc)[0],g=ki().memoizedState;return[typeof h=="boolean"?h:ab(h),g]},useSyncExternalStore:aI,useId:RI,useHostTransitionStatus:Fk,useFormState:vI,useActionState:vI,useOptimistic:function(h,g){var w=ki();return wr!==null?dI(w,wr,h,g):(w.baseState=h,[h,w.queue.dispatch])},useMemoCache:Tk,useCacheRefresh:OI};zI.useEffectEvent=SI;function zk(h,g,w,N){g=h.memoizedState,w=w(N,g),w=w==null?g:f({},g,w),h.memoizedState=w,h.lanes===0&&(h.updateQueue.baseState=w)}var Bk={enqueueSetState:function(h,g,w){h=h._reactInternals;var N=eo(),j=ad(N);j.payload=g,w!=null&&(j.callback=w),g=sd(h,j,N),g!==null&&(As(g,h,N),tb(g,h,N))},enqueueReplaceState:function(h,g,w){h=h._reactInternals;var N=eo(),j=ad(N);j.tag=1,j.payload=g,w!=null&&(j.callback=w),g=sd(h,j,N),g!==null&&(As(g,h,N),tb(g,h,N))},enqueueForceUpdate:function(h,g){h=h._reactInternals;var w=eo(),N=ad(w);N.tag=2,g!=null&&(N.callback=g),g=sd(h,N,w),g!==null&&(As(g,h,w),tb(g,h,w))}};function BI(h,g,w,N,j,L,J){return h=h.stateNode,typeof h.shouldComponentUpdate=="function"?h.shouldComponentUpdate(N,L,J):g.prototype&&g.prototype.isPureReactComponent?!Wx(w,N)||!Wx(j,L):!0}function HI(h,g,w,N){h=g.state,typeof g.componentWillReceiveProps=="function"&&g.componentWillReceiveProps(w,N),typeof g.UNSAFE_componentWillReceiveProps=="function"&&g.UNSAFE_componentWillReceiveProps(w,N),g.state!==h&&Bk.enqueueReplaceState(g,g.state,null)}function rf(h,g){var w=g;if("ref"in g){w={};for(var N in g)N!=="ref"&&(w[N]=g[N])}if(h=h.defaultProps){w===g&&(w=f({},w));for(var j in h)w[j]===void 0&&(w[j]=h[j])}return w}function $I(h){Tv(h)}function VI(h){console.error(h)}function GI(h){Tv(h)}function Qv(h,g){try{var w=h.onUncaughtError;w(g.value,{componentStack:g.stack})}catch(N){setTimeout(function(){throw N})}}function qI(h,g,w){try{var N=h.onCaughtError;N(w.value,{componentStack:w.stack,errorBoundary:g.tag===1?g.stateNode:null})}catch(j){setTimeout(function(){throw j})}}function Hk(h,g,w){return w=ad(w),w.tag=3,w.payload={element:null},w.callback=function(){Qv(h,g)},w}function WI(h){return h=ad(h),h.tag=3,h}function KI(h,g,w,N){var j=w.type.getDerivedStateFromError;if(typeof j=="function"){var L=N.value;h.payload=function(){return j(L)},h.callback=function(){qI(g,w,N)}}var J=w.stateNode;J!==null&&typeof J.componentDidCatch=="function"&&(h.callback=function(){qI(g,w,N),typeof j!="function"&&(hd===null?hd=new Set([this]):hd.add(this));var ye=N.stack;this.componentDidCatch(N.value,{componentStack:ye!==null?ye:""})})}function Cie(h,g,w,N,j){if(w.flags|=32768,N!==null&&typeof N=="object"&&typeof N.then=="function"){if(g=w.alternate,g!==null&&Wm(g,w,j,!0),w=Ys.current,w!==null){switch(w.tag){case 31:case 13:return Po===null?cw():w.alternate===null&&mi===0&&(mi=3),w.flags&=-257,w.flags|=65536,w.lanes=j,N===Iv?w.flags|=16384:(g=w.updateQueue,g===null?w.updateQueue=new Set([N]):g.add(N),fE(h,N,j)),!1;case 22:return w.flags|=65536,N===Iv?w.flags|=16384:(g=w.updateQueue,g===null?(g={transitions:null,markerInstances:null,retryQueue:new Set([N])},w.updateQueue=g):(w=g.retryQueue,w===null?g.retryQueue=new Set([N]):w.add(N)),fE(h,N,j)),!1}throw Error(r(435,w.tag))}return fE(h,N,j),cw(),!1}if(Yn)return g=Ys.current,g!==null?((g.flags&65536)===0&&(g.flags|=256),g.flags|=65536,g.lanes=j,N!==ok&&(h=Error(r(422),{cause:N}),Yx(Eo(h,w)))):(N!==ok&&(g=Error(r(423),{cause:N}),Yx(Eo(g,w))),h=h.current.alternate,h.flags|=65536,j&=-j,h.lanes|=j,N=Eo(N,w),j=Hk(h.stateNode,N,j),bk(h,j),mi!==4&&(mi=2)),!1;var L=Error(r(520),{cause:N});if(L=Eo(L,w),pb===null?pb=[L]:pb.push(L),mi!==4&&(mi=2),g===null)return!0;N=Eo(N,w),w=g;do{switch(w.tag){case 3:return w.flags|=65536,h=j&-j,w.lanes|=h,h=Hk(w.stateNode,N,h),bk(w,h),!1;case 1:if(g=w.type,L=w.stateNode,(w.flags&128)===0&&(typeof g.getDerivedStateFromError=="function"||L!==null&&typeof L.componentDidCatch=="function"&&(hd===null||!hd.has(L))))return w.flags|=65536,j&=-j,w.lanes|=j,j=WI(j),KI(j,h,w,N),bk(w,j),!1}w=w.return}while(w!==null);return!1}var $k=Error(r(461)),Di=!1;function Ta(h,g,w,N){g.child=h===null?ZF(g,null,w,N):tf(g,h.child,w,N)}function XI(h,g,w,N,j){w=w.render;var L=g.ref;if("ref"in N){var J={};for(var ye in N)ye!=="ref"&&(J[ye]=N[ye])}else J=N;return Qh(g),N=Nk(h,g,w,J,L,j),ye=Mk(),h!==null&&!Di?(kk(h,g,j),Ic(h,g,j)):(Yn&&ye&&ak(g),g.flags|=1,Ta(h,g,N,j),g.child)}function YI(h,g,w,N,j){if(h===null){var L=w.type;return typeof L=="function"&&!nk(L)&&L.defaultProps===void 0&&w.compare===null?(g.tag=15,g.type=L,QI(h,g,L,N,j)):(h=jv(w.type,null,N,g,g.mode,j),h.ref=g.ref,h.return=g,g.child=h)}if(L=h.child,!Qk(h,j)){var J=L.memoizedProps;if(w=w.compare,w=w!==null?w:Wx,w(J,N)&&h.ref===g.ref)return Ic(h,g,j)}return g.flags|=1,h=jc(L,N),h.ref=g.ref,h.return=g,g.child=h}function QI(h,g,w,N,j){if(h!==null){var L=h.memoizedProps;if(Wx(L,N)&&h.ref===g.ref)if(Di=!1,g.pendingProps=N=L,Qk(h,j))(h.flags&131072)!==0&&(Di=!0);else return g.lanes=h.lanes,Ic(h,g,j)}return Vk(h,g,w,N,j)}function ZI(h,g,w,N){var j=N.children,L=h!==null?h.memoizedState:null;if(h===null&&g.stateNode===null&&(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),N.mode==="hidden"){if((g.flags&128)!==0){if(L=L!==null?L.baseLanes|w:w,h!==null){for(N=g.child=h.child,j=0;N!==null;)j=j|N.lanes|N.childLanes,N=N.sibling;N=j&~L}else N=0,g.child=null;return JI(h,g,L,w,N)}if((w&536870912)!==0)g.memoizedState={baseLanes:0,cachePool:null},h!==null&&Lv(g,L!==null?L.cachePool:null),L!==null?tI(g,L):vk(),nI(g);else return N=g.lanes=536870912,JI(h,g,L!==null?L.baseLanes|w:w,w,N)}else L!==null?(Lv(g,L.cachePool),tI(g,L),ld(),g.memoizedState=null):(h!==null&&Lv(g,null),vk(),ld());return Ta(h,g,j,w),g.child}function lb(h,g){return h!==null&&h.tag===22||g.stateNode!==null||(g.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),g.sibling}function JI(h,g,w,N,j){var L=mk();return L=L===null?null:{parent:Pi._currentValue,pool:L},g.memoizedState={baseLanes:w,cachePool:L},h!==null&&Lv(g,null),vk(),nI(g),h!==null&&Wm(h,g,N,!0),g.childLanes=j,null}function Zv(h,g){return g=ew({mode:g.mode,children:g.children},h.mode),g.ref=h.ref,h.child=g,g.return=h,g}function e5(h,g,w){return tf(g,h.child,null,w),h=Zv(g,g.pendingProps),h.flags|=2,Qs(g),g.memoizedState=null,h}function Pie(h,g,w){var N=g.pendingProps,j=(g.flags&128)!==0;if(g.flags&=-129,h===null){if(Yn){if(N.mode==="hidden")return h=Zv(g,N),g.lanes=536870912,lb(null,h);if(_k(g),(h=$r)?(h=hU(h,Co),h=h!==null&&h.data==="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:ed!==null?{id:Gl,overflow:ql}:null,retryLane:536870912,hydrationErrors:null},w=FF(h),w.return=g,g.child=w,ka=g,$r=null)):h=null,h===null)throw nd(g);return g.lanes=536870912,null}return Zv(g,N)}var L=h.memoizedState;if(L!==null){var J=L.dehydrated;if(_k(g),j)if(g.flags&256)g.flags&=-257,g=e5(h,g,w);else if(g.memoizedState!==null)g.child=h.child,g.flags|=128,g=null;else throw Error(r(558));else if(Di||Wm(h,g,w,!1),j=(w&h.childLanes)!==0,Di||j){if(N=jr,N!==null&&(J=rr(N,w),J!==0&&J!==L.retryLane))throw L.retryLane=J,Wh(h,J),As(N,h,J),$k;cw(),g=e5(h,g,w)}else h=L.treeContext,$r=jo(J.nextSibling),ka=g,Yn=!0,td=null,Co=!1,h!==null&&zF(g,h),g=Zv(g,N),g.flags|=4096;return g}return h=jc(h.child,{mode:N.mode,children:N.children}),h.ref=g.ref,g.child=h,h.return=g,h}function Jv(h,g){var w=g.ref;if(w===null)h!==null&&h.ref!==null&&(g.flags|=4194816);else{if(typeof w!="function"&&typeof w!="object")throw Error(r(284));(h===null||h.ref!==w)&&(g.flags|=4194816)}}function Vk(h,g,w,N,j){return Qh(g),w=Nk(h,g,w,N,void 0,j),N=Mk(),h!==null&&!Di?(kk(h,g,j),Ic(h,g,j)):(Yn&&N&&ak(g),g.flags|=1,Ta(h,g,w,j),g.child)}function t5(h,g,w,N,j,L){return Qh(g),g.updateQueue=null,w=iI(g,N,w,j),rI(h),N=Mk(),h!==null&&!Di?(kk(h,g,L),Ic(h,g,L)):(Yn&&N&&ak(g),g.flags|=1,Ta(h,g,w,L),g.child)}function n5(h,g,w,N,j){if(Qh(g),g.stateNode===null){var L=$m,J=w.contextType;typeof J=="object"&&J!==null&&(L=Ea(J)),L=new w(N,L),g.memoizedState=L.state!==null&&L.state!==void 0?L.state:null,L.updater=Bk,g.stateNode=L,L._reactInternals=g,L=g.stateNode,L.props=N,L.state=g.memoizedState,L.refs={},gk(g),J=w.contextType,L.context=typeof J=="object"&&J!==null?Ea(J):$m,L.state=g.memoizedState,J=w.getDerivedStateFromProps,typeof J=="function"&&(zk(g,w,J,N),L.state=g.memoizedState),typeof w.getDerivedStateFromProps=="function"||typeof L.getSnapshotBeforeUpdate=="function"||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(J=L.state,typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount(),J!==L.state&&Bk.enqueueReplaceState(L,L.state,null),rb(g,N,L,j),nb(),L.state=g.memoizedState),typeof L.componentDidMount=="function"&&(g.flags|=4194308),N=!0}else if(h===null){L=g.stateNode;var ye=g.memoizedProps,Ie=rf(w,ye);L.props=Ie;var st=L.context,xt=w.contextType;J=$m,typeof xt=="object"&&xt!==null&&(J=Ea(xt));var wt=w.getDerivedStateFromProps;xt=typeof wt=="function"||typeof L.getSnapshotBeforeUpdate=="function",ye=g.pendingProps!==ye,xt||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(ye||st!==J)&&HI(g,L,N,J),id=!1;var dt=g.memoizedState;L.state=dt,rb(g,N,L,j),nb(),st=g.memoizedState,ye||dt!==st||id?(typeof wt=="function"&&(zk(g,w,wt,N),st=g.memoizedState),(Ie=id||BI(g,w,Ie,N,dt,st,J))?(xt||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount()),typeof L.componentDidMount=="function"&&(g.flags|=4194308)):(typeof L.componentDidMount=="function"&&(g.flags|=4194308),g.memoizedProps=N,g.memoizedState=st),L.props=N,L.state=st,L.context=J,N=Ie):(typeof L.componentDidMount=="function"&&(g.flags|=4194308),N=!1)}else{L=g.stateNode,xk(h,g),J=g.memoizedProps,xt=rf(w,J),L.props=xt,wt=g.pendingProps,dt=L.context,st=w.contextType,Ie=$m,typeof st=="object"&&st!==null&&(Ie=Ea(st)),ye=w.getDerivedStateFromProps,(st=typeof ye=="function"||typeof L.getSnapshotBeforeUpdate=="function")||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(J!==wt||dt!==Ie)&&HI(g,L,N,Ie),id=!1,dt=g.memoizedState,L.state=dt,rb(g,N,L,j),nb();var gt=g.memoizedState;J!==wt||dt!==gt||id||h!==null&&h.dependencies!==null&&Rv(h.dependencies)?(typeof ye=="function"&&(zk(g,w,ye,N),gt=g.memoizedState),(xt=id||BI(g,w,xt,N,dt,gt,Ie)||h!==null&&h.dependencies!==null&&Rv(h.dependencies))?(st||typeof L.UNSAFE_componentWillUpdate!="function"&&typeof L.componentWillUpdate!="function"||(typeof L.componentWillUpdate=="function"&&L.componentWillUpdate(N,gt,Ie),typeof L.UNSAFE_componentWillUpdate=="function"&&L.UNSAFE_componentWillUpdate(N,gt,Ie)),typeof L.componentDidUpdate=="function"&&(g.flags|=4),typeof L.getSnapshotBeforeUpdate=="function"&&(g.flags|=1024)):(typeof L.componentDidUpdate!="function"||J===h.memoizedProps&&dt===h.memoizedState||(g.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||J===h.memoizedProps&&dt===h.memoizedState||(g.flags|=1024),g.memoizedProps=N,g.memoizedState=gt),L.props=N,L.state=gt,L.context=Ie,N=xt):(typeof L.componentDidUpdate!="function"||J===h.memoizedProps&&dt===h.memoizedState||(g.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||J===h.memoizedProps&&dt===h.memoizedState||(g.flags|=1024),N=!1)}return L=N,Jv(h,g),N=(g.flags&128)!==0,L||N?(L=g.stateNode,w=N&&typeof w.getDerivedStateFromError!="function"?null:L.render(),g.flags|=1,h!==null&&N?(g.child=tf(g,h.child,null,j),g.child=tf(g,null,w,j)):Ta(h,g,w,j),g.memoizedState=L.state,h=g.child):h=Ic(h,g,j),h}function r5(h,g,w,N){return Xh(),g.flags|=256,Ta(h,g,w,N),g.child}var Gk={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function qk(h){return{baseLanes:h,cachePool:qF()}}function Wk(h,g,w){return h=h!==null?h.childLanes&~w:0,g&&(h|=Js),h}function i5(h,g,w){var N=g.pendingProps,j=!1,L=(g.flags&128)!==0,J;if((J=L)||(J=h!==null&&h.memoizedState===null?!1:(Mi.current&2)!==0),J&&(j=!0,g.flags&=-129),J=(g.flags&32)!==0,g.flags&=-33,h===null){if(Yn){if(j?od(g):ld(),(h=$r)?(h=hU(h,Co),h=h!==null&&h.data!=="&"?h:null,h!==null&&(g.memoizedState={dehydrated:h,treeContext:ed!==null?{id:Gl,overflow:ql}:null,retryLane:536870912,hydrationErrors:null},w=FF(h),w.return=g,g.child=w,ka=g,$r=null)):h=null,h===null)throw nd(g);return AE(h)?g.lanes=32:g.lanes=536870912,null}var ye=N.children;return N=N.fallback,j?(ld(),j=g.mode,ye=ew({mode:"hidden",children:ye},j),N=Kh(N,j,w,null),ye.return=g,N.return=g,ye.sibling=N,g.child=ye,N=g.child,N.memoizedState=qk(w),N.childLanes=Wk(h,J,w),g.memoizedState=Gk,lb(null,N)):(od(g),Kk(g,ye))}var Ie=h.memoizedState;if(Ie!==null&&(ye=Ie.dehydrated,ye!==null)){if(L)g.flags&256?(od(g),g.flags&=-257,g=Xk(h,g,w)):g.memoizedState!==null?(ld(),g.child=h.child,g.flags|=128,g=null):(ld(),ye=N.fallback,j=g.mode,N=ew({mode:"visible",children:N.children},j),ye=Kh(ye,j,w,null),ye.flags|=2,N.return=g,ye.return=g,N.sibling=ye,g.child=N,tf(g,h.child,null,w),N=g.child,N.memoizedState=qk(w),N.childLanes=Wk(h,J,w),g.memoizedState=Gk,g=lb(null,N));else if(od(g),AE(ye)){if(J=ye.nextSibling&&ye.nextSibling.dataset,J)var st=J.dgst;J=st,N=Error(r(419)),N.stack="",N.digest=J,Yx({value:N,source:null,stack:null}),g=Xk(h,g,w)}else if(Di||Wm(h,g,w,!1),J=(w&h.childLanes)!==0,Di||J){if(J=jr,J!==null&&(N=rr(J,w),N!==0&&N!==Ie.retryLane))throw Ie.retryLane=N,Wh(h,N),As(J,h,N),$k;TE(ye)||cw(),g=Xk(h,g,w)}else TE(ye)?(g.flags|=192,g.child=h.child,g=null):(h=Ie.treeContext,$r=jo(ye.nextSibling),ka=g,Yn=!0,td=null,Co=!1,h!==null&&zF(g,h),g=Kk(g,N.children),g.flags|=4096);return g}return j?(ld(),ye=N.fallback,j=g.mode,Ie=h.child,st=Ie.sibling,N=jc(Ie,{mode:"hidden",children:N.children}),N.subtreeFlags=Ie.subtreeFlags&65011712,st!==null?ye=jc(st,ye):(ye=Kh(ye,j,w,null),ye.flags|=2),ye.return=g,N.return=g,N.sibling=ye,g.child=N,lb(null,N),N=g.child,ye=h.child.memoizedState,ye===null?ye=qk(w):(j=ye.cachePool,j!==null?(Ie=Pi._currentValue,j=j.parent!==Ie?{parent:Ie,pool:Ie}:j):j=qF(),ye={baseLanes:ye.baseLanes|w,cachePool:j}),N.memoizedState=ye,N.childLanes=Wk(h,J,w),g.memoizedState=Gk,lb(h.child,N)):(od(g),w=h.child,h=w.sibling,w=jc(w,{mode:"visible",children:N.children}),w.return=g,w.sibling=null,h!==null&&(J=g.deletions,J===null?(g.deletions=[h],g.flags|=16):J.push(h)),g.child=w,g.memoizedState=null,w)}function Kk(h,g){return g=ew({mode:"visible",children:g},h.mode),g.return=h,h.child=g}function ew(h,g){return h=Xs(22,h,null,g),h.lanes=0,h}function Xk(h,g,w){return tf(g,h.child,null,w),h=Kk(g,g.pendingProps.children),h.flags|=2,g.memoizedState=null,h}function a5(h,g,w){h.lanes|=g;var N=h.alternate;N!==null&&(N.lanes|=g),uk(h.return,g,w)}function Yk(h,g,w,N,j,L){var J=h.memoizedState;J===null?h.memoizedState={isBackwards:g,rendering:null,renderingStartTime:0,last:N,tail:w,tailMode:j,treeForkCount:L}:(J.isBackwards=g,J.rendering=null,J.renderingStartTime=0,J.last=N,J.tail=w,J.tailMode=j,J.treeForkCount=L)}function s5(h,g,w){var N=g.pendingProps,j=N.revealOrder,L=N.tail;N=N.children;var J=Mi.current,ye=(J&2)!==0;if(ye?(J=J&1|2,g.flags|=128):J&=1,re(Mi,J),Ta(h,g,N,w),N=Yn?Xx:0,!ye&&h!==null&&(h.flags&128)!==0)e:for(h=g.child;h!==null;){if(h.tag===13)h.memoizedState!==null&&a5(h,w,g);else if(h.tag===19)a5(h,w,g);else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===g)break e;for(;h.sibling===null;){if(h.return===null||h.return===g)break e;h=h.return}h.sibling.return=h.return,h=h.sibling}switch(j){case"forwards":for(w=g.child,j=null;w!==null;)h=w.alternate,h!==null&&Hv(h)===null&&(j=w),w=w.sibling;w=j,w===null?(j=g.child,g.child=null):(j=w.sibling,w.sibling=null),Yk(g,!1,j,w,L,N);break;case"backwards":case"unstable_legacy-backwards":for(w=null,j=g.child,g.child=null;j!==null;){if(h=j.alternate,h!==null&&Hv(h)===null){g.child=j;break}h=j.sibling,j.sibling=w,w=j,j=h}Yk(g,!0,w,null,L,N);break;case"together":Yk(g,!1,null,null,void 0,N);break;default:g.memoizedState=null}return g.child}function Ic(h,g,w){if(h!==null&&(g.dependencies=h.dependencies),dd|=g.lanes,(w&g.childLanes)===0)if(h!==null){if(Wm(h,g,w,!1),(w&g.childLanes)===0)return null}else return null;if(h!==null&&g.child!==h.child)throw Error(r(153));if(g.child!==null){for(h=g.child,w=jc(h,h.pendingProps),g.child=w,w.return=g;h.sibling!==null;)h=h.sibling,w=w.sibling=jc(h,h.pendingProps),w.return=g;w.sibling=null}return g.child}function Qk(h,g){return(h.lanes&g)!==0?!0:(h=h.dependencies,!!(h!==null&&Rv(h)))}function jie(h,g,w){switch(g.tag){case 3:Ce(g,g.stateNode.containerInfo),rd(g,Pi,h.memoizedState.cache),Xh();break;case 27:case 5:ke(g);break;case 4:Ce(g,g.stateNode.containerInfo);break;case 10:rd(g,g.type,g.memoizedProps.value);break;case 31:if(g.memoizedState!==null)return g.flags|=128,_k(g),null;break;case 13:var N=g.memoizedState;if(N!==null)return N.dehydrated!==null?(od(g),g.flags|=128,null):(w&g.child.childLanes)!==0?i5(h,g,w):(od(g),h=Ic(h,g,w),h!==null?h.sibling:null);od(g);break;case 19:var j=(h.flags&128)!==0;if(N=(w&g.childLanes)!==0,N||(Wm(h,g,w,!1),N=(w&g.childLanes)!==0),j){if(N)return s5(h,g,w);g.flags|=128}if(j=g.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),re(Mi,Mi.current),N)break;return null;case 22:return g.lanes=0,ZI(h,g,w,g.pendingProps);case 24:rd(g,Pi,h.memoizedState.cache)}return Ic(h,g,w)}function o5(h,g,w){if(h!==null)if(h.memoizedProps!==g.pendingProps)Di=!0;else{if(!Qk(h,w)&&(g.flags&128)===0)return Di=!1,jie(h,g,w);Di=(h.flags&131072)!==0}else Di=!1,Yn&&(g.flags&1048576)!==0&&UF(g,Xx,g.index);switch(g.lanes=0,g.tag){case 16:e:{var N=g.pendingProps;if(h=Jh(g.elementType),g.type=h,typeof h=="function")nk(h)?(N=rf(h,N),g.tag=1,g=n5(null,g,h,N,w)):(g.tag=0,g=Vk(null,g,h,N,w));else{if(h!=null){var j=h.$$typeof;if(j===T){g.tag=11,g=XI(null,g,h,N,w);break e}else if(j===E){g.tag=14,g=YI(null,g,h,N,w);break e}}throw g=P(h)||h,Error(r(306,g,""))}}return g;case 0:return Vk(h,g,g.type,g.pendingProps,w);case 1:return N=g.type,j=rf(N,g.pendingProps),n5(h,g,N,j,w);case 3:e:{if(Ce(g,g.stateNode.containerInfo),h===null)throw Error(r(387));N=g.pendingProps;var L=g.memoizedState;j=L.element,xk(h,g),rb(g,N,null,w);var J=g.memoizedState;if(N=J.cache,rd(g,Pi,N),N!==L.cache&&dk(g,[Pi],w,!0),nb(),N=J.element,L.isDehydrated)if(L={element:N,isDehydrated:!1,cache:J.cache},g.updateQueue.baseState=L,g.memoizedState=L,g.flags&256){g=r5(h,g,N,w);break e}else if(N!==j){j=Eo(Error(r(424)),g),Yx(j),g=r5(h,g,N,w);break e}else{switch(h=g.stateNode.containerInfo,h.nodeType){case 9:h=h.body;break;default:h=h.nodeName==="HTML"?h.ownerDocument.body:h}for($r=jo(h.firstChild),ka=g,Yn=!0,td=null,Co=!0,w=ZF(g,null,N,w),g.child=w;w;)w.flags=w.flags&-3|4096,w=w.sibling}else{if(Xh(),N===j){g=Ic(h,g,w);break e}Ta(h,g,N,w)}g=g.child}return g;case 26:return Jv(h,g),h===null?(w=bU(g.type,null,g.pendingProps,null))?g.memoizedState=w:Yn||(w=g.type,h=g.pendingProps,N=gw(me.current).createElement(w),N[Xn]=g,N[Nn]=h,Aa(N,w,h),Se(N),g.stateNode=N):g.memoizedState=bU(g.type,h.memoizedProps,g.pendingProps,h.memoizedState),null;case 27:return ke(g),h===null&&Yn&&(N=g.stateNode=pU(g.type,g.pendingProps,me.current),ka=g,Co=!0,j=$r,gd(g.type)?(CE=j,$r=jo(N.firstChild)):$r=j),Ta(h,g,g.pendingProps.children,w),Jv(h,g),h===null&&(g.flags|=4194304),g.child;case 5:return h===null&&Yn&&((j=N=$r)&&(N=lae(N,g.type,g.pendingProps,Co),N!==null?(g.stateNode=N,ka=g,$r=jo(N.firstChild),Co=!1,j=!0):j=!1),j||nd(g)),ke(g),j=g.type,L=g.pendingProps,J=h!==null?h.memoizedProps:null,N=L.children,ME(j,L)?N=null:J!==null&&ME(j,J)&&(g.flags|=32),g.memoizedState!==null&&(j=Nk(h,g,Sie,null,null,w),Sb._currentValue=j),Jv(h,g),Ta(h,g,N,w),g.child;case 6:return h===null&&Yn&&((h=w=$r)&&(w=cae(w,g.pendingProps,Co),w!==null?(g.stateNode=w,ka=g,$r=null,h=!0):h=!1),h||nd(g)),null;case 13:return i5(h,g,w);case 4:return Ce(g,g.stateNode.containerInfo),N=g.pendingProps,h===null?g.child=tf(g,null,N,w):Ta(h,g,N,w),g.child;case 11:return XI(h,g,g.type,g.pendingProps,w);case 7:return Ta(h,g,g.pendingProps,w),g.child;case 8:return Ta(h,g,g.pendingProps.children,w),g.child;case 12:return Ta(h,g,g.pendingProps.children,w),g.child;case 10:return N=g.pendingProps,rd(g,g.type,N.value),Ta(h,g,N.children,w),g.child;case 9:return j=g.type._context,N=g.pendingProps.children,Qh(g),j=Ea(j),N=N(j),g.flags|=1,Ta(h,g,N,w),g.child;case 14:return YI(h,g,g.type,g.pendingProps,w);case 15:return QI(h,g,g.type,g.pendingProps,w);case 19:return s5(h,g,w);case 31:return Pie(h,g,w);case 22:return ZI(h,g,w,g.pendingProps);case 24:return Qh(g),N=Ea(Pi),h===null?(j=mk(),j===null&&(j=jr,L=hk(),j.pooledCache=L,L.refCount++,L!==null&&(j.pooledCacheLanes|=w),j=L),g.memoizedState={parent:N,cache:j},gk(g),rd(g,Pi,j)):((h.lanes&w)!==0&&(xk(h,g),rb(g,null,null,w),nb()),j=h.memoizedState,L=g.memoizedState,j.parent!==N?(j={parent:N,cache:N},g.memoizedState=j,g.lanes===0&&(g.memoizedState=g.updateQueue.baseState=j),rd(g,Pi,N)):(N=L.cache,rd(g,Pi,N),N!==j.cache&&dk(g,[Pi],w,!0))),Ta(h,g,g.pendingProps.children,w),g.child;case 29:throw g.pendingProps}throw Error(r(156,g.tag))}function Uc(h){h.flags|=4}function Zk(h,g,w,N,j){if((g=(h.mode&32)!==0)&&(g=!1),g){if(h.flags|=16777216,(j&335544128)===j)if(h.stateNode.complete)h.flags|=8192;else if(R5())h.flags|=8192;else throw ef=Iv,pk}else h.flags&=-16777217}function l5(h,g){if(g.type!=="stylesheet"||(g.state.loading&4)!==0)h.flags&=-16777217;else if(h.flags|=16777216,!SU(g))if(R5())h.flags|=8192;else throw ef=Iv,pk}function tw(h,g){g!==null&&(h.flags|=4),h.flags&16384&&(g=h.tag!==22?bt():536870912,h.lanes|=g,ap|=g)}function cb(h,g){if(!Yn)switch(h.tailMode){case"hidden":g=h.tail;for(var w=null;g!==null;)g.alternate!==null&&(w=g),g=g.sibling;w===null?h.tail=null:w.sibling=null;break;case"collapsed":w=h.tail;for(var N=null;w!==null;)w.alternate!==null&&(N=w),w=w.sibling;N===null?g||h.tail===null?h.tail=null:h.tail.sibling=null:N.sibling=null}}function Vr(h){var g=h.alternate!==null&&h.alternate.child===h.child,w=0,N=0;if(g)for(var j=h.child;j!==null;)w|=j.lanes|j.childLanes,N|=j.subtreeFlags&65011712,N|=j.flags&65011712,j.return=h,j=j.sibling;else for(j=h.child;j!==null;)w|=j.lanes|j.childLanes,N|=j.subtreeFlags,N|=j.flags,j.return=h,j=j.sibling;return h.subtreeFlags|=N,h.childLanes=w,g}function Die(h,g,w){var N=g.pendingProps;switch(sk(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,N=null,h!==null&&(N=h.memoizedState.cache),g.memoizedState.cache!==N&&(g.flags|=2048),Oc(Pi),ie(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(h===null||h.child===null)&&(qm(g)?Uc(g):h===null||h.memoizedState.isDehydrated&&(g.flags&256)===0||(g.flags|=1024,lk())),Vr(g),null;case 26:var j=g.type,L=g.memoizedState;return h===null?(Uc(g),L!==null?(Vr(g),l5(g,L)):(Vr(g),Zk(g,j,null,N,w))):L?L!==h.memoizedState?(Uc(g),Vr(g),l5(g,L)):(Vr(g),g.flags&=-16777217):(h=h.memoizedProps,h!==N&&Uc(g),Vr(g),Zk(g,j,h,N,w)),null;case 27:if(Oe(g),w=me.current,j=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==N&&Uc(g);else{if(!N){if(g.stateNode===null)throw Error(r(166));return Vr(g),null}h=ne.current,qm(g)?BF(g):(h=pU(j,N,w),g.stateNode=h,Uc(g))}return Vr(g),null;case 5:if(Oe(g),j=g.type,h!==null&&g.stateNode!=null)h.memoizedProps!==N&&Uc(g);else{if(!N){if(g.stateNode===null)throw Error(r(166));return Vr(g),null}if(L=ne.current,qm(g))BF(g);else{var J=gw(me.current);switch(L){case 1:L=J.createElementNS("http://www.w3.org/2000/svg",j);break;case 2:L=J.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;default:switch(j){case"svg":L=J.createElementNS("http://www.w3.org/2000/svg",j);break;case"math":L=J.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;case"script":L=J.createElement("div"),L.innerHTML="<script><\/script>",L=L.removeChild(L.firstChild);break;case"select":L=typeof N.is=="string"?J.createElement("select",{is:N.is}):J.createElement("select"),N.multiple?L.multiple=!0:N.size&&(L.size=N.size);break;default:L=typeof N.is=="string"?J.createElement(j,{is:N.is}):J.createElement(j)}}L[Xn]=g,L[Nn]=N;e:for(J=g.child;J!==null;){if(J.tag===5||J.tag===6)L.appendChild(J.stateNode);else if(J.tag!==4&&J.tag!==27&&J.child!==null){J.child.return=J,J=J.child;continue}if(J===g)break e;for(;J.sibling===null;){if(J.return===null||J.return===g)break e;J=J.return}J.sibling.return=J.return,J=J.sibling}g.stateNode=L;e:switch(Aa(L,j,N),j){case"button":case"input":case"select":case"textarea":N=!!N.autoFocus;break e;case"img":N=!0;break e;default:N=!1}N&&Uc(g)}}return Vr(g),Zk(g,g.type,h===null?null:h.memoizedProps,g.pendingProps,w),null;case 6:if(h&&g.stateNode!=null)h.memoizedProps!==N&&Uc(g);else{if(typeof N!="string"&&g.stateNode===null)throw Error(r(166));if(h=me.current,qm(g)){if(h=g.stateNode,w=g.memoizedProps,N=null,j=ka,j!==null)switch(j.tag){case 27:case 5:N=j.memoizedProps}h[Xn]=g,h=!!(h.nodeValue===w||N!==null&&N.suppressHydrationWarning===!0||iU(h.nodeValue,w)),h||nd(g,!0)}else h=gw(h).createTextNode(N),h[Xn]=g,g.stateNode=h}return Vr(g),null;case 31:if(w=g.memoizedState,h===null||h.memoizedState!==null){if(N=qm(g),w!==null){if(h===null){if(!N)throw Error(r(318));if(h=g.memoizedState,h=h!==null?h.dehydrated:null,!h)throw Error(r(557));h[Xn]=g}else Xh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Vr(g),h=!1}else w=lk(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=w),h=!0;if(!h)return g.flags&256?(Qs(g),g):(Qs(g),null);if((g.flags&128)!==0)throw Error(r(558))}return Vr(g),null;case 13:if(N=g.memoizedState,h===null||h.memoizedState!==null&&h.memoizedState.dehydrated!==null){if(j=qm(g),N!==null&&N.dehydrated!==null){if(h===null){if(!j)throw Error(r(318));if(j=g.memoizedState,j=j!==null?j.dehydrated:null,!j)throw Error(r(317));j[Xn]=g}else Xh(),(g.flags&128)===0&&(g.memoizedState=null),g.flags|=4;Vr(g),j=!1}else j=lk(),h!==null&&h.memoizedState!==null&&(h.memoizedState.hydrationErrors=j),j=!0;if(!j)return g.flags&256?(Qs(g),g):(Qs(g),null)}return Qs(g),(g.flags&128)!==0?(g.lanes=w,g):(w=N!==null,h=h!==null&&h.memoizedState!==null,w&&(N=g.child,j=null,N.alternate!==null&&N.alternate.memoizedState!==null&&N.alternate.memoizedState.cachePool!==null&&(j=N.alternate.memoizedState.cachePool.pool),L=null,N.memoizedState!==null&&N.memoizedState.cachePool!==null&&(L=N.memoizedState.cachePool.pool),L!==j&&(N.flags|=2048)),w!==h&&w&&(g.child.flags|=8192),tw(g,g.updateQueue),Vr(g),null);case 4:return ie(),h===null&&vE(g.stateNode.containerInfo),Vr(g),null;case 10:return Oc(g.type),Vr(g),null;case 19:if(K(Mi),N=g.memoizedState,N===null)return Vr(g),null;if(j=(g.flags&128)!==0,L=N.rendering,L===null)if(j)cb(N,!1);else{if(mi!==0||h!==null&&(h.flags&128)!==0)for(h=g.child;h!==null;){if(L=Hv(h),L!==null){for(g.flags|=128,cb(N,!1),h=L.updateQueue,g.updateQueue=h,tw(g,h),g.subtreeFlags=0,h=w,w=g.child;w!==null;)LF(w,h),w=w.sibling;return re(Mi,Mi.current&1|2),Yn&&Dc(g,N.treeForkCount),g.child}h=h.sibling}N.tail!==null&&O()>sw&&(g.flags|=128,j=!0,cb(N,!1),g.lanes=4194304)}else{if(!j)if(h=Hv(L),h!==null){if(g.flags|=128,j=!0,h=h.updateQueue,g.updateQueue=h,tw(g,h),cb(N,!0),N.tail===null&&N.tailMode==="hidden"&&!L.alternate&&!Yn)return Vr(g),null}else 2*O()-N.renderingStartTime>sw&&w!==536870912&&(g.flags|=128,j=!0,cb(N,!1),g.lanes=4194304);N.isBackwards?(L.sibling=g.child,g.child=L):(h=N.last,h!==null?h.sibling=L:g.child=L,N.last=L)}return N.tail!==null?(h=N.tail,N.rendering=h,N.tail=h.sibling,N.renderingStartTime=O(),h.sibling=null,w=Mi.current,re(Mi,j?w&1|2:w&1),Yn&&Dc(g,N.treeForkCount),h):(Vr(g),null);case 22:case 23:return Qs(g),wk(),N=g.memoizedState!==null,h!==null?h.memoizedState!==null!==N&&(g.flags|=8192):N&&(g.flags|=8192),N?(w&536870912)!==0&&(g.flags&128)===0&&(Vr(g),g.subtreeFlags&6&&(g.flags|=8192)):Vr(g),w=g.updateQueue,w!==null&&tw(g,w.retryQueue),w=null,h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(w=h.memoizedState.cachePool.pool),N=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(N=g.memoizedState.cachePool.pool),N!==w&&(g.flags|=2048),h!==null&&K(Zh),null;case 24:return w=null,h!==null&&(w=h.memoizedState.cache),g.memoizedState.cache!==w&&(g.flags|=2048),Oc(Pi),Vr(g),null;case 25:return null;case 30:return null}throw Error(r(156,g.tag))}function Rie(h,g){switch(sk(g),g.tag){case 1:return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 3:return Oc(Pi),ie(),h=g.flags,(h&65536)!==0&&(h&128)===0?(g.flags=h&-65537|128,g):null;case 26:case 27:case 5:return Oe(g),null;case 31:if(g.memoizedState!==null){if(Qs(g),g.alternate===null)throw Error(r(340));Xh()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 13:if(Qs(g),h=g.memoizedState,h!==null&&h.dehydrated!==null){if(g.alternate===null)throw Error(r(340));Xh()}return h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 19:return K(Mi),null;case 4:return ie(),null;case 10:return Oc(g.type),null;case 22:case 23:return Qs(g),wk(),h!==null&&K(Zh),h=g.flags,h&65536?(g.flags=h&-65537|128,g):null;case 24:return Oc(Pi),null;case 25:return null;default:return null}}function c5(h,g){switch(sk(g),g.tag){case 3:Oc(Pi),ie();break;case 26:case 27:case 5:Oe(g);break;case 4:ie();break;case 31:g.memoizedState!==null&&Qs(g);break;case 13:Qs(g);break;case 19:K(Mi);break;case 10:Oc(g.type);break;case 22:case 23:Qs(g),wk(),h!==null&&K(Zh);break;case 24:Oc(Pi)}}function ub(h,g){try{var w=g.updateQueue,N=w!==null?w.lastEffect:null;if(N!==null){var j=N.next;w=j;do{if((w.tag&h)===h){N=void 0;var L=w.create,J=w.inst;N=L(),J.destroy=N}w=w.next}while(w!==j)}}catch(ye){gr(g,g.return,ye)}}function cd(h,g,w){try{var N=g.updateQueue,j=N!==null?N.lastEffect:null;if(j!==null){var L=j.next;N=L;do{if((N.tag&h)===h){var J=N.inst,ye=J.destroy;if(ye!==void 0){J.destroy=void 0,j=g;var Ie=w,st=ye;try{st()}catch(xt){gr(j,Ie,xt)}}}N=N.next}while(N!==L)}}catch(xt){gr(g,g.return,xt)}}function u5(h){var g=h.updateQueue;if(g!==null){var w=h.stateNode;try{eI(g,w)}catch(N){gr(h,h.return,N)}}}function d5(h,g,w){w.props=rf(h.type,h.memoizedProps),w.state=h.memoizedState;try{w.componentWillUnmount()}catch(N){gr(h,g,N)}}function db(h,g){try{var w=h.ref;if(w!==null){switch(h.tag){case 26:case 27:case 5:var N=h.stateNode;break;case 30:N=h.stateNode;break;default:N=h.stateNode}typeof w=="function"?h.refCleanup=w(N):w.current=N}}catch(j){gr(h,g,j)}}function Wl(h,g){var w=h.ref,N=h.refCleanup;if(w!==null)if(typeof N=="function")try{N()}catch(j){gr(h,g,j)}finally{h.refCleanup=null,h=h.alternate,h!=null&&(h.refCleanup=null)}else if(typeof w=="function")try{w(null)}catch(j){gr(h,g,j)}else w.current=null}function h5(h){var g=h.type,w=h.memoizedProps,N=h.stateNode;try{e:switch(g){case"button":case"input":case"select":case"textarea":w.autoFocus&&N.focus();break e;case"img":w.src?N.src=w.src:w.srcSet&&(N.srcset=w.srcSet)}}catch(j){gr(h,h.return,j)}}function Jk(h,g,w){try{var N=h.stateNode;nae(N,h.type,w,g),N[Nn]=g}catch(j){gr(h,h.return,j)}}function f5(h){return h.tag===5||h.tag===3||h.tag===26||h.tag===27&&gd(h.type)||h.tag===4}function eE(h){e:for(;;){for(;h.sibling===null;){if(h.return===null||f5(h.return))return null;h=h.return}for(h.sibling.return=h.return,h=h.sibling;h.tag!==5&&h.tag!==6&&h.tag!==18;){if(h.tag===27&&gd(h.type)||h.flags&2||h.child===null||h.tag===4)continue e;h.child.return=h,h=h.child}if(!(h.flags&2))return h.stateNode}}function tE(h,g,w){var N=h.tag;if(N===5||N===6)h=h.stateNode,g?(w.nodeType===9?w.body:w.nodeName==="HTML"?w.ownerDocument.body:w).insertBefore(h,g):(g=w.nodeType===9?w.body:w.nodeName==="HTML"?w.ownerDocument.body:w,g.appendChild(h),w=w._reactRootContainer,w!=null||g.onclick!==null||(g.onclick=Si));else if(N!==4&&(N===27&&gd(h.type)&&(w=h.stateNode,g=null),h=h.child,h!==null))for(tE(h,g,w),h=h.sibling;h!==null;)tE(h,g,w),h=h.sibling}function nw(h,g,w){var N=h.tag;if(N===5||N===6)h=h.stateNode,g?w.insertBefore(h,g):w.appendChild(h);else if(N!==4&&(N===27&&gd(h.type)&&(w=h.stateNode),h=h.child,h!==null))for(nw(h,g,w),h=h.sibling;h!==null;)nw(h,g,w),h=h.sibling}function m5(h){var g=h.stateNode,w=h.memoizedProps;try{for(var N=h.type,j=g.attributes;j.length;)g.removeAttributeNode(j[0]);Aa(g,N,w),g[Xn]=h,g[Nn]=w}catch(L){gr(h,h.return,L)}}var zc=!1,Ri=!1,nE=!1,p5=typeof WeakSet=="function"?WeakSet:Set,da=null;function Oie(h,g){if(h=h.containerInfo,SE=Sw,h=EF(h),X2(h)){if("selectionStart"in h)var w={start:h.selectionStart,end:h.selectionEnd};else e:{w=(w=h.ownerDocument)&&w.defaultView||window;var N=w.getSelection&&w.getSelection();if(N&&N.rangeCount!==0){w=N.anchorNode;var j=N.anchorOffset,L=N.focusNode;N=N.focusOffset;try{w.nodeType,L.nodeType}catch{w=null;break e}var J=0,ye=-1,Ie=-1,st=0,xt=0,wt=h,dt=null;t:for(;;){for(var gt;wt!==w||j!==0&&wt.nodeType!==3||(ye=J+j),wt!==L||N!==0&&wt.nodeType!==3||(Ie=J+N),wt.nodeType===3&&(J+=wt.nodeValue.length),(gt=wt.firstChild)!==null;)dt=wt,wt=gt;for(;;){if(wt===h)break t;if(dt===w&&++st===j&&(ye=J),dt===L&&++xt===N&&(Ie=J),(gt=wt.nextSibling)!==null)break;wt=dt,dt=wt.parentNode}wt=gt}w=ye===-1||Ie===-1?null:{start:ye,end:Ie}}else w=null}w=w||{start:0,end:0}}else w=null;for(NE={focusedElem:h,selectionRange:w},Sw=!1,da=g;da!==null;)if(g=da,h=g.child,(g.subtreeFlags&1028)!==0&&h!==null)h.return=g,da=h;else for(;da!==null;){switch(g=da,L=g.alternate,h=g.flags,g.tag){case 0:if((h&4)!==0&&(h=g.updateQueue,h=h!==null?h.events:null,h!==null))for(w=0;w<h.length;w++)j=h[w],j.ref.impl=j.nextImpl;break;case 11:case 15:break;case 1:if((h&1024)!==0&&L!==null){h=void 0,w=g,j=L.memoizedProps,L=L.memoizedState,N=w.stateNode;try{var Vt=rf(w.type,j);h=N.getSnapshotBeforeUpdate(Vt,L),N.__reactInternalSnapshotBeforeUpdate=h}catch(rn){gr(w,w.return,rn)}}break;case 3:if((h&1024)!==0){if(h=g.stateNode.containerInfo,w=h.nodeType,w===9)EE(h);else if(w===1)switch(h.nodeName){case"HEAD":case"HTML":case"BODY":EE(h);break;default:h.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((h&1024)!==0)throw Error(r(163))}if(h=g.sibling,h!==null){h.return=g.return,da=h;break}da=g.return}}function g5(h,g,w){var N=w.flags;switch(w.tag){case 0:case 11:case 15:Hc(h,w),N&4&&ub(5,w);break;case 1:if(Hc(h,w),N&4)if(h=w.stateNode,g===null)try{h.componentDidMount()}catch(J){gr(w,w.return,J)}else{var j=rf(w.type,g.memoizedProps);g=g.memoizedState;try{h.componentDidUpdate(j,g,h.__reactInternalSnapshotBeforeUpdate)}catch(J){gr(w,w.return,J)}}N&64&&u5(w),N&512&&db(w,w.return);break;case 3:if(Hc(h,w),N&64&&(h=w.updateQueue,h!==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{eI(h,g)}catch(J){gr(w,w.return,J)}}break;case 27:g===null&&N&4&&m5(w);case 26:case 5:Hc(h,w),g===null&&N&4&&h5(w),N&512&&db(w,w.return);break;case 12:Hc(h,w);break;case 31:Hc(h,w),N&4&&y5(h,w);break;case 13:Hc(h,w),N&4&&v5(h,w),N&64&&(h=w.memoizedState,h!==null&&(h=h.dehydrated,h!==null&&(w=Vie.bind(null,w),uae(h,w))));break;case 22:if(N=w.memoizedState!==null||zc,!N){g=g!==null&&g.memoizedState!==null||Ri,j=zc;var L=Ri;zc=N,(Ri=g)&&!L?$c(h,w,(w.subtreeFlags&8772)!==0):Hc(h,w),zc=j,Ri=L}break;case 30:break;default:Hc(h,w)}}function x5(h){var g=h.alternate;g!==null&&(h.alternate=null,x5(g)),h.child=null,h.deletions=null,h.sibling=null,h.tag===5&&(g=h.stateNode,g!==null&<(g)),h.stateNode=null,h.return=null,h.dependencies=null,h.memoizedProps=null,h.memoizedState=null,h.pendingProps=null,h.stateNode=null,h.updateQueue=null}var Zr=null,Ms=!1;function Bc(h,g,w){for(w=w.child;w!==null;)b5(h,g,w),w=w.sibling}function b5(h,g,w){if(xe&&typeof xe.onCommitFiberUnmount=="function")try{xe.onCommitFiberUnmount(He,w)}catch{}switch(w.tag){case 26:Ri||Wl(w,g),Bc(h,g,w),w.memoizedState?w.memoizedState.count--:w.stateNode&&(w=w.stateNode,w.parentNode.removeChild(w));break;case 27:Ri||Wl(w,g);var N=Zr,j=Ms;gd(w.type)&&(Zr=w.stateNode,Ms=!1),Bc(h,g,w),vb(w.stateNode),Zr=N,Ms=j;break;case 5:Ri||Wl(w,g);case 6:if(N=Zr,j=Ms,Zr=null,Bc(h,g,w),Zr=N,Ms=j,Zr!==null)if(Ms)try{(Zr.nodeType===9?Zr.body:Zr.nodeName==="HTML"?Zr.ownerDocument.body:Zr).removeChild(w.stateNode)}catch(L){gr(w,g,L)}else try{Zr.removeChild(w.stateNode)}catch(L){gr(w,g,L)}break;case 18:Zr!==null&&(Ms?(h=Zr,uU(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,w.stateNode),fp(h)):uU(Zr,w.stateNode));break;case 4:N=Zr,j=Ms,Zr=w.stateNode.containerInfo,Ms=!0,Bc(h,g,w),Zr=N,Ms=j;break;case 0:case 11:case 14:case 15:cd(2,w,g),Ri||cd(4,w,g),Bc(h,g,w);break;case 1:Ri||(Wl(w,g),N=w.stateNode,typeof N.componentWillUnmount=="function"&&d5(w,g,N)),Bc(h,g,w);break;case 21:Bc(h,g,w);break;case 22:Ri=(N=Ri)||w.memoizedState!==null,Bc(h,g,w),Ri=N;break;default:Bc(h,g,w)}}function y5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null))){h=h.dehydrated;try{fp(h)}catch(w){gr(g,g.return,w)}}}function v5(h,g){if(g.memoizedState===null&&(h=g.alternate,h!==null&&(h=h.memoizedState,h!==null&&(h=h.dehydrated,h!==null))))try{fp(h)}catch(w){gr(g,g.return,w)}}function Lie(h){switch(h.tag){case 31:case 13:case 19:var g=h.stateNode;return g===null&&(g=h.stateNode=new p5),g;case 22:return h=h.stateNode,g=h._retryCache,g===null&&(g=h._retryCache=new p5),g;default:throw Error(r(435,h.tag))}}function rw(h,g){var w=Lie(h);g.forEach(function(N){if(!w.has(N)){w.add(N);var j=Gie.bind(null,h,N);N.then(j,j)}})}function ks(h,g){var w=g.deletions;if(w!==null)for(var N=0;N<w.length;N++){var j=w[N],L=h,J=g,ye=J;e:for(;ye!==null;){switch(ye.tag){case 27:if(gd(ye.type)){Zr=ye.stateNode,Ms=!1;break e}break;case 5:Zr=ye.stateNode,Ms=!1;break e;case 3:case 4:Zr=ye.stateNode.containerInfo,Ms=!0;break e}ye=ye.return}if(Zr===null)throw Error(r(160));b5(L,J,j),Zr=null,Ms=!1,L=j.alternate,L!==null&&(L.return=null),j.return=null}if(g.subtreeFlags&13886)for(g=g.child;g!==null;)w5(g,h),g=g.sibling}var bl=null;function w5(h,g){var w=h.alternate,N=h.flags;switch(h.tag){case 0:case 11:case 14:case 15:ks(g,h),Es(h),N&4&&(cd(3,h,h.return),ub(3,h),cd(5,h,h.return));break;case 1:ks(g,h),Es(h),N&512&&(Ri||w===null||Wl(w,w.return)),N&64&&zc&&(h=h.updateQueue,h!==null&&(N=h.callbacks,N!==null&&(w=h.shared.hiddenCallbacks,h.shared.hiddenCallbacks=w===null?N:w.concat(N))));break;case 26:var j=bl;if(ks(g,h),Es(h),N&512&&(Ri||w===null||Wl(w,w.return)),N&4){var L=w!==null?w.memoizedState:null;if(N=h.memoizedState,w===null)if(N===null)if(h.stateNode===null){e:{N=h.type,w=h.memoizedProps,j=j.ownerDocument||j;t:switch(N){case"title":L=j.getElementsByTagName("title")[0],(!L||L[ut]||L[Xn]||L.namespaceURI==="http://www.w3.org/2000/svg"||L.hasAttribute("itemprop"))&&(L=j.createElement(N),j.head.insertBefore(L,j.querySelector("head > title"))),Aa(L,N,w),L[Xn]=h,Se(L),N=L;break e;case"link":var J=wU("link","href",j).get(N+(w.href||""));if(J){for(var ye=0;ye<J.length;ye++)if(L=J[ye],L.getAttribute("href")===(w.href==null||w.href===""?null:w.href)&&L.getAttribute("rel")===(w.rel==null?null:w.rel)&&L.getAttribute("title")===(w.title==null?null:w.title)&&L.getAttribute("crossorigin")===(w.crossOrigin==null?null:w.crossOrigin)){J.splice(ye,1);break t}}L=j.createElement(N),Aa(L,N,w),j.head.appendChild(L);break;case"meta":if(J=wU("meta","content",j).get(N+(w.content||""))){for(ye=0;ye<J.length;ye++)if(L=J[ye],L.getAttribute("content")===(w.content==null?null:""+w.content)&&L.getAttribute("name")===(w.name==null?null:w.name)&&L.getAttribute("property")===(w.property==null?null:w.property)&&L.getAttribute("http-equiv")===(w.httpEquiv==null?null:w.httpEquiv)&&L.getAttribute("charset")===(w.charSet==null?null:w.charSet)){J.splice(ye,1);break t}}L=j.createElement(N),Aa(L,N,w),j.head.appendChild(L);break;default:throw Error(r(468,N))}L[Xn]=h,Se(L),N=L}h.stateNode=N}else _U(j,h.type,h.stateNode);else h.stateNode=vU(j,N,h.memoizedProps);else L!==N?(L===null?w.stateNode!==null&&(w=w.stateNode,w.parentNode.removeChild(w)):L.count--,N===null?_U(j,h.type,h.stateNode):vU(j,N,h.memoizedProps)):N===null&&h.stateNode!==null&&Jk(h,h.memoizedProps,w.memoizedProps)}break;case 27:ks(g,h),Es(h),N&512&&(Ri||w===null||Wl(w,w.return)),w!==null&&N&4&&Jk(h,h.memoizedProps,w.memoizedProps);break;case 5:if(ks(g,h),Es(h),N&512&&(Ri||w===null||Wl(w,w.return)),h.flags&32){j=h.stateNode;try{vt(j,"")}catch(Vt){gr(h,h.return,Vt)}}N&4&&h.stateNode!=null&&(j=h.memoizedProps,Jk(h,j,w!==null?w.memoizedProps:j)),N&1024&&(nE=!0);break;case 6:if(ks(g,h),Es(h),N&4){if(h.stateNode===null)throw Error(r(162));N=h.memoizedProps,w=h.stateNode;try{w.nodeValue=N}catch(Vt){gr(h,h.return,Vt)}}break;case 3:if(yw=null,j=bl,bl=xw(g.containerInfo),ks(g,h),bl=j,Es(h),N&4&&w!==null&&w.memoizedState.isDehydrated)try{fp(g.containerInfo)}catch(Vt){gr(h,h.return,Vt)}nE&&(nE=!1,_5(h));break;case 4:N=bl,bl=xw(h.stateNode.containerInfo),ks(g,h),Es(h),bl=N;break;case 12:ks(g,h),Es(h);break;case 31:ks(g,h),Es(h),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,rw(h,N)));break;case 13:ks(g,h),Es(h),h.child.flags&8192&&h.memoizedState!==null!=(w!==null&&w.memoizedState!==null)&&(aw=O()),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,rw(h,N)));break;case 22:j=h.memoizedState!==null;var Ie=w!==null&&w.memoizedState!==null,st=zc,xt=Ri;if(zc=st||j,Ri=xt||Ie,ks(g,h),Ri=xt,zc=st,Es(h),N&8192)e:for(g=h.stateNode,g._visibility=j?g._visibility&-2:g._visibility|1,j&&(w===null||Ie||zc||Ri||af(h)),w=null,g=h;;){if(g.tag===5||g.tag===26){if(w===null){Ie=w=g;try{if(L=Ie.stateNode,j)J=L.style,typeof J.setProperty=="function"?J.setProperty("display","none","important"):J.display="none";else{ye=Ie.stateNode;var wt=Ie.memoizedProps.style,dt=wt!=null&&wt.hasOwnProperty("display")?wt.display:null;ye.style.display=dt==null||typeof dt=="boolean"?"":(""+dt).trim()}}catch(Vt){gr(Ie,Ie.return,Vt)}}}else if(g.tag===6){if(w===null){Ie=g;try{Ie.stateNode.nodeValue=j?"":Ie.memoizedProps}catch(Vt){gr(Ie,Ie.return,Vt)}}}else if(g.tag===18){if(w===null){Ie=g;try{var gt=Ie.stateNode;j?dU(gt,!0):dU(Ie.stateNode,!1)}catch(Vt){gr(Ie,Ie.return,Vt)}}}else if((g.tag!==22&&g.tag!==23||g.memoizedState===null||g===h)&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===h)break e;for(;g.sibling===null;){if(g.return===null||g.return===h)break e;w===g&&(w=null),g=g.return}w===g&&(w=null),g.sibling.return=g.return,g=g.sibling}N&4&&(N=h.updateQueue,N!==null&&(w=N.retryQueue,w!==null&&(N.retryQueue=null,rw(h,w))));break;case 19:ks(g,h),Es(h),N&4&&(N=h.updateQueue,N!==null&&(h.updateQueue=null,rw(h,N)));break;case 30:break;case 21:break;default:ks(g,h),Es(h)}}function Es(h){var g=h.flags;if(g&2){try{for(var w,N=h.return;N!==null;){if(f5(N)){w=N;break}N=N.return}if(w==null)throw Error(r(160));switch(w.tag){case 27:var j=w.stateNode,L=eE(h);nw(h,L,j);break;case 5:var J=w.stateNode;w.flags&32&&(vt(J,""),w.flags&=-33);var ye=eE(h);nw(h,ye,J);break;case 3:case 4:var Ie=w.stateNode.containerInfo,st=eE(h);tE(h,st,Ie);break;default:throw Error(r(161))}}catch(xt){gr(h,h.return,xt)}h.flags&=-3}g&4096&&(h.flags&=-4097)}function _5(h){if(h.subtreeFlags&1024)for(h=h.child;h!==null;){var g=h;_5(g),g.tag===5&&g.flags&1024&&g.stateNode.reset(),h=h.sibling}}function Hc(h,g){if(g.subtreeFlags&8772)for(g=g.child;g!==null;)g5(h,g.alternate,g),g=g.sibling}function af(h){for(h=h.child;h!==null;){var g=h;switch(g.tag){case 0:case 11:case 14:case 15:cd(4,g,g.return),af(g);break;case 1:Wl(g,g.return);var w=g.stateNode;typeof w.componentWillUnmount=="function"&&d5(g,g.return,w),af(g);break;case 27:vb(g.stateNode);case 26:case 5:Wl(g,g.return),af(g);break;case 22:g.memoizedState===null&&af(g);break;case 30:af(g);break;default:af(g)}h=h.sibling}}function $c(h,g,w){for(w=w&&(g.subtreeFlags&8772)!==0,g=g.child;g!==null;){var N=g.alternate,j=h,L=g,J=L.flags;switch(L.tag){case 0:case 11:case 15:$c(j,L,w),ub(4,L);break;case 1:if($c(j,L,w),N=L,j=N.stateNode,typeof j.componentDidMount=="function")try{j.componentDidMount()}catch(st){gr(N,N.return,st)}if(N=L,j=N.updateQueue,j!==null){var ye=N.stateNode;try{var Ie=j.shared.hiddenCallbacks;if(Ie!==null)for(j.shared.hiddenCallbacks=null,j=0;j<Ie.length;j++)JF(Ie[j],ye)}catch(st){gr(N,N.return,st)}}w&&J&64&&u5(L),db(L,L.return);break;case 27:m5(L);case 26:case 5:$c(j,L,w),w&&N===null&&J&4&&h5(L),db(L,L.return);break;case 12:$c(j,L,w);break;case 31:$c(j,L,w),w&&J&4&&y5(j,L);break;case 13:$c(j,L,w),w&&J&4&&v5(j,L);break;case 22:L.memoizedState===null&&$c(j,L,w),db(L,L.return);break;case 30:break;default:$c(j,L,w)}g=g.sibling}}function rE(h,g){var w=null;h!==null&&h.memoizedState!==null&&h.memoizedState.cachePool!==null&&(w=h.memoizedState.cachePool.pool),h=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(h=g.memoizedState.cachePool.pool),h!==w&&(h!=null&&h.refCount++,w!=null&&Qx(w))}function iE(h,g){h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&Qx(h))}function yl(h,g,w,N){if(g.subtreeFlags&10256)for(g=g.child;g!==null;)S5(h,g,w,N),g=g.sibling}function S5(h,g,w,N){var j=g.flags;switch(g.tag){case 0:case 11:case 15:yl(h,g,w,N),j&2048&&ub(9,g);break;case 1:yl(h,g,w,N);break;case 3:yl(h,g,w,N),j&2048&&(h=null,g.alternate!==null&&(h=g.alternate.memoizedState.cache),g=g.memoizedState.cache,g!==h&&(g.refCount++,h!=null&&Qx(h)));break;case 12:if(j&2048){yl(h,g,w,N),h=g.stateNode;try{var L=g.memoizedProps,J=L.id,ye=L.onPostCommit;typeof ye=="function"&&ye(J,g.alternate===null?"mount":"update",h.passiveEffectDuration,-0)}catch(Ie){gr(g,g.return,Ie)}}else yl(h,g,w,N);break;case 31:yl(h,g,w,N);break;case 13:yl(h,g,w,N);break;case 23:break;case 22:L=g.stateNode,J=g.alternate,g.memoizedState!==null?L._visibility&2?yl(h,g,w,N):hb(h,g):L._visibility&2?yl(h,g,w,N):(L._visibility|=2,np(h,g,w,N,(g.subtreeFlags&10256)!==0||!1)),j&2048&&rE(J,g);break;case 24:yl(h,g,w,N),j&2048&&iE(g.alternate,g);break;default:yl(h,g,w,N)}}function np(h,g,w,N,j){for(j=j&&((g.subtreeFlags&10256)!==0||!1),g=g.child;g!==null;){var L=h,J=g,ye=w,Ie=N,st=J.flags;switch(J.tag){case 0:case 11:case 15:np(L,J,ye,Ie,j),ub(8,J);break;case 23:break;case 22:var xt=J.stateNode;J.memoizedState!==null?xt._visibility&2?np(L,J,ye,Ie,j):hb(L,J):(xt._visibility|=2,np(L,J,ye,Ie,j)),j&&st&2048&&rE(J.alternate,J);break;case 24:np(L,J,ye,Ie,j),j&&st&2048&&iE(J.alternate,J);break;default:np(L,J,ye,Ie,j)}g=g.sibling}}function hb(h,g){if(g.subtreeFlags&10256)for(g=g.child;g!==null;){var w=h,N=g,j=N.flags;switch(N.tag){case 22:hb(w,N),j&2048&&rE(N.alternate,N);break;case 24:hb(w,N),j&2048&&iE(N.alternate,N);break;default:hb(w,N)}g=g.sibling}}var fb=8192;function rp(h,g,w){if(h.subtreeFlags&fb)for(h=h.child;h!==null;)N5(h,g,w),h=h.sibling}function N5(h,g,w){switch(h.tag){case 26:rp(h,g,w),h.flags&fb&&h.memoizedState!==null&&_ae(w,bl,h.memoizedState,h.memoizedProps);break;case 5:rp(h,g,w);break;case 3:case 4:var N=bl;bl=xw(h.stateNode.containerInfo),rp(h,g,w),bl=N;break;case 22:h.memoizedState===null&&(N=h.alternate,N!==null&&N.memoizedState!==null?(N=fb,fb=16777216,rp(h,g,w),fb=N):rp(h,g,w));break;default:rp(h,g,w)}}function M5(h){var g=h.alternate;if(g!==null&&(h=g.child,h!==null)){g.child=null;do g=h.sibling,h.sibling=null,h=g;while(h!==null)}}function mb(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var w=0;w<g.length;w++){var N=g[w];da=N,E5(N,h)}M5(h)}if(h.subtreeFlags&10256)for(h=h.child;h!==null;)k5(h),h=h.sibling}function k5(h){switch(h.tag){case 0:case 11:case 15:mb(h),h.flags&2048&&cd(9,h,h.return);break;case 3:mb(h);break;case 12:mb(h);break;case 22:var g=h.stateNode;h.memoizedState!==null&&g._visibility&2&&(h.return===null||h.return.tag!==13)?(g._visibility&=-3,iw(h)):mb(h);break;default:mb(h)}}function iw(h){var g=h.deletions;if((h.flags&16)!==0){if(g!==null)for(var w=0;w<g.length;w++){var N=g[w];da=N,E5(N,h)}M5(h)}for(h=h.child;h!==null;){switch(g=h,g.tag){case 0:case 11:case 15:cd(8,g,g.return),iw(g);break;case 22:w=g.stateNode,w._visibility&2&&(w._visibility&=-3,iw(g));break;default:iw(g)}h=h.sibling}}function E5(h,g){for(;da!==null;){var w=da;switch(w.tag){case 0:case 11:case 15:cd(8,w,g);break;case 23:case 22:if(w.memoizedState!==null&&w.memoizedState.cachePool!==null){var N=w.memoizedState.cachePool.pool;N!=null&&N.refCount++}break;case 24:Qx(w.memoizedState.cache)}if(N=w.child,N!==null)N.return=w,da=N;else e:for(w=h;da!==null;){N=da;var j=N.sibling,L=N.return;if(x5(N),N===w){da=null;break e}if(j!==null){j.return=L,da=j;break e}da=L}}}var Fie={getCacheForType:function(h){var g=Ea(Pi),w=g.data.get(h);return w===void 0&&(w=h(),g.data.set(h,w)),w},cacheSignal:function(){return Ea(Pi).controller.signal}},Iie=typeof WeakMap=="function"?WeakMap:Map,hr=0,jr=null,In=null,qn=0,pr=0,Zs=null,ud=!1,ip=!1,aE=!1,Vc=0,mi=0,dd=0,sf=0,sE=0,Js=0,ap=0,pb=null,Ts=null,oE=!1,aw=0,T5=0,sw=1/0,ow=null,hd=null,Wi=0,fd=null,sp=null,Gc=0,lE=0,cE=null,A5=null,gb=0,uE=null;function eo(){return(hr&2)!==0&&qn!==0?qn&-qn:X.T!==null?gE():gn()}function C5(){if(Js===0)if((qn&536870912)===0||Yn){var h=Ee;Ee<<=1,(Ee&3932160)===0&&(Ee=262144),Js=h}else Js=536870912;return h=Ys.current,h!==null&&(h.flags|=32),Js}function As(h,g,w){(h===jr&&(pr===2||pr===9)||h.cancelPendingCommit!==null)&&(op(h,0),md(h,qn,Js,!1)),Bt(h,w),((hr&2)===0||h!==jr)&&(h===jr&&((hr&2)===0&&(sf|=w),mi===4&&md(h,qn,Js,!1)),Kl(h))}function P5(h,g,w){if((hr&6)!==0)throw Error(r(327));var N=!w&&(g&127)===0&&(g&h.expiredLanes)===0||je(h,g),j=N?Bie(h,g):hE(h,g,!0),L=N;do{if(j===0){ip&&!N&&md(h,g,0,!1);break}else{if(w=h.current.alternate,L&&!Uie(w)){j=hE(h,g,!1),L=!1;continue}if(j===2){if(L=g,h.errorRecoveryDisabledLanes&L)var J=0;else J=h.pendingLanes&-536870913,J=J!==0?J:J&536870912?536870912:0;if(J!==0){g=J;e:{var ye=h;j=pb;var Ie=ye.current.memoizedState.isDehydrated;if(Ie&&(op(ye,J).flags|=256),J=hE(ye,J,!1),J!==2){if(aE&&!Ie){ye.errorRecoveryDisabledLanes|=L,sf|=L,j=4;break e}L=Ts,Ts=j,L!==null&&(Ts===null?Ts=L:Ts.push.apply(Ts,L))}j=J}if(L=!1,j!==2)continue}}if(j===1){op(h,0),md(h,g,0,!0);break}e:{switch(N=h,L=j,L){case 0:case 1:throw Error(r(345));case 4:if((g&4194048)!==g)break;case 6:md(N,g,Js,!ud);break e;case 2:Ts=null;break;case 3:case 5:break;default:throw Error(r(329))}if((g&62914560)===g&&(j=aw+300-O(),10<j)){if(md(N,g,Js,!ud),W(N,0,!0)!==0)break e;Gc=g,N.timeoutHandle=lU(j5.bind(null,N,w,Ts,ow,oE,g,Js,sf,ap,ud,L,"Throttled",-0,0),j);break e}j5(N,w,Ts,ow,oE,g,Js,sf,ap,ud,L,null,-0,0)}}break}while(!0);Kl(h)}function j5(h,g,w,N,j,L,J,ye,Ie,st,xt,wt,dt,gt){if(h.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},N5(g,L,wt);var Vt=(L&62914560)===L?aw-O():(L&4194048)===L?T5-O():0;if(Vt=Sae(wt,Vt),Vt!==null){Gc=L,h.cancelPendingCommit=Vt(z5.bind(null,h,g,L,w,N,j,J,ye,Ie,xt,wt,null,dt,gt)),md(h,L,J,!st);return}}z5(h,g,L,w,N,j,J,ye,Ie)}function Uie(h){for(var g=h;;){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 N=0;N<w.length;N++){var j=w[N],L=j.getSnapshot;j=j.value;try{if(!Ks(L(),j))return!1}catch{return!1}}if(w=g.child,g.subtreeFlags&16384&&w!==null)w.return=g,g=w;else{if(g===h)break;for(;g.sibling===null;){if(g.return===null||g.return===h)return!0;g=g.return}g.sibling.return=g.return,g=g.sibling}}return!0}function md(h,g,w,N){g&=~sE,g&=~sf,h.suspendedLanes|=g,h.pingedLanes&=~g,N&&(h.warmLanes|=g),N=h.expirationTimes;for(var j=g;0<j;){var L=31-ze(j),J=1<<L;N[L]=-1,j&=~J}w!==0&&vn(h,w,g)}function lw(){return(hr&6)===0?(xb(0),!1):!0}function dE(){if(In!==null){if(pr===0)var h=In.return;else h=In,Rc=Yh=null,Ek(h),Qm=null,Jx=0,h=In;for(;h!==null;)c5(h.alternate,h),h=h.return;In=null}}function op(h,g){var w=h.timeoutHandle;w!==-1&&(h.timeoutHandle=-1,aae(w)),w=h.cancelPendingCommit,w!==null&&(h.cancelPendingCommit=null,w()),Gc=0,dE(),jr=h,In=w=jc(h.current,null),qn=g,pr=0,Zs=null,ud=!1,ip=je(h,g),aE=!1,ap=Js=sE=sf=dd=mi=0,Ts=pb=null,oE=!1,(g&8)!==0&&(g|=g&32);var N=h.entangledLanes;if(N!==0)for(h=h.entanglements,N&=g;0<N;){var j=31-ze(N),L=1<<j;g|=h[j],N&=~L}return Vc=g,Av(),w}function D5(h,g){_n=null,X.H=ob,g===Ym||g===Fv?(g=XF(),pr=3):g===pk?(g=XF(),pr=4):pr=g===$k?8:g!==null&&typeof g=="object"&&typeof g.then=="function"?6:1,Zs=g,In===null&&(mi=1,Qv(h,Eo(g,h.current)))}function R5(){var h=Ys.current;return h===null?!0:(qn&4194048)===qn?Po===null:(qn&62914560)===qn||(qn&536870912)!==0?h===Po:!1}function O5(){var h=X.H;return X.H=ob,h===null?ob:h}function L5(){var h=X.A;return X.A=Fie,h}function cw(){mi=4,ud||(qn&4194048)!==qn&&Ys.current!==null||(ip=!0),(dd&134217727)===0&&(sf&134217727)===0||jr===null||md(jr,qn,Js,!1)}function hE(h,g,w){var N=hr;hr|=2;var j=O5(),L=L5();(jr!==h||qn!==g)&&(ow=null,op(h,g)),g=!1;var J=mi;e:do try{if(pr!==0&&In!==null){var ye=In,Ie=Zs;switch(pr){case 8:dE(),J=6;break e;case 3:case 2:case 9:case 6:Ys.current===null&&(g=!0);var st=pr;if(pr=0,Zs=null,lp(h,ye,Ie,st),w&&ip){J=0;break e}break;default:st=pr,pr=0,Zs=null,lp(h,ye,Ie,st)}}zie(),J=mi;break}catch(xt){D5(h,xt)}while(!0);return g&&h.shellSuspendCounter++,Rc=Yh=null,hr=N,X.H=j,X.A=L,In===null&&(jr=null,qn=0,Av()),J}function zie(){for(;In!==null;)F5(In)}function Bie(h,g){var w=hr;hr|=2;var N=O5(),j=L5();jr!==h||qn!==g?(ow=null,sw=O()+500,op(h,g)):ip=je(h,g);e:do try{if(pr!==0&&In!==null){g=In;var L=Zs;t:switch(pr){case 1:pr=0,Zs=null,lp(h,g,L,1);break;case 2:case 9:if(WF(L)){pr=0,Zs=null,I5(g);break}g=function(){pr!==2&&pr!==9||jr!==h||(pr=7),Kl(h)},L.then(g,g);break e;case 3:pr=7;break e;case 4:pr=5;break e;case 7:WF(L)?(pr=0,Zs=null,I5(g)):(pr=0,Zs=null,lp(h,g,L,7));break;case 5:var J=null;switch(In.tag){case 26:J=In.memoizedState;case 5:case 27:var ye=In;if(J?SU(J):ye.stateNode.complete){pr=0,Zs=null;var Ie=ye.sibling;if(Ie!==null)In=Ie;else{var st=ye.return;st!==null?(In=st,uw(st)):In=null}break t}}pr=0,Zs=null,lp(h,g,L,5);break;case 6:pr=0,Zs=null,lp(h,g,L,6);break;case 8:dE(),mi=6;break e;default:throw Error(r(462))}}Hie();break}catch(xt){D5(h,xt)}while(!0);return Rc=Yh=null,X.H=N,X.A=j,hr=w,In!==null?0:(jr=null,qn=0,Av(),mi)}function Hie(){for(;In!==null&&!ge();)F5(In)}function F5(h){var g=o5(h.alternate,h,Vc);h.memoizedProps=h.pendingProps,g===null?uw(h):In=g}function I5(h){var g=h,w=g.alternate;switch(g.tag){case 15:case 0:g=t5(w,g,g.pendingProps,g.type,void 0,qn);break;case 11:g=t5(w,g,g.pendingProps,g.type.render,g.ref,qn);break;case 5:Ek(g);default:c5(w,g),g=In=LF(g,Vc),g=o5(w,g,Vc)}h.memoizedProps=h.pendingProps,g===null?uw(h):In=g}function lp(h,g,w,N){Rc=Yh=null,Ek(g),Qm=null,Jx=0;var j=g.return;try{if(Cie(h,j,g,w,qn)){mi=1,Qv(h,Eo(w,h.current)),In=null;return}}catch(L){if(j!==null)throw In=j,L;mi=1,Qv(h,Eo(w,h.current)),In=null;return}g.flags&32768?(Yn||N===1?h=!0:ip||(qn&536870912)!==0?h=!1:(ud=h=!0,(N===2||N===9||N===3||N===6)&&(N=Ys.current,N!==null&&N.tag===13&&(N.flags|=16384))),U5(g,h)):uw(g)}function uw(h){var g=h;do{if((g.flags&32768)!==0){U5(g,ud);return}h=g.return;var w=Die(g.alternate,g,Vc);if(w!==null){In=w;return}if(g=g.sibling,g!==null){In=g;return}In=g=h}while(g!==null);mi===0&&(mi=5)}function U5(h,g){do{var w=Rie(h.alternate,h);if(w!==null){w.flags&=32767,In=w;return}if(w=h.return,w!==null&&(w.flags|=32768,w.subtreeFlags=0,w.deletions=null),!g&&(h=h.sibling,h!==null)){In=h;return}In=h=w}while(h!==null);mi=6,In=null}function z5(h,g,w,N,j,L,J,ye,Ie){h.cancelPendingCommit=null;do dw();while(Wi!==0);if((hr&6)!==0)throw Error(r(327));if(g!==null){if(g===h.current)throw Error(r(177));if(L=g.lanes|g.childLanes,L|=ek,Lt(h,w,L,J,ye,Ie),h===jr&&(In=jr=null,qn=0),sp=g,fd=h,Gc=w,lE=L,cE=j,A5=N,(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?(h.callbackNode=null,h.callbackPriority=0,qie(ve,function(){return G5(),null})):(h.callbackNode=null,h.callbackPriority=0),N=(g.flags&13878)!==0,(g.subtreeFlags&13878)!==0||N){N=X.T,X.T=null,j=V.p,V.p=2,J=hr,hr|=4;try{Oie(h,g,w)}finally{hr=J,V.p=j,X.T=N}}Wi=1,B5(),H5(),$5()}}function B5(){if(Wi===1){Wi=0;var h=fd,g=sp,w=(g.flags&13878)!==0;if((g.subtreeFlags&13878)!==0||w){w=X.T,X.T=null;var N=V.p;V.p=2;var j=hr;hr|=4;try{w5(g,h);var L=NE,J=EF(h.containerInfo),ye=L.focusedElem,Ie=L.selectionRange;if(J!==ye&&ye&&ye.ownerDocument&&kF(ye.ownerDocument.documentElement,ye)){if(Ie!==null&&X2(ye)){var st=Ie.start,xt=Ie.end;if(xt===void 0&&(xt=st),"selectionStart"in ye)ye.selectionStart=st,ye.selectionEnd=Math.min(xt,ye.value.length);else{var wt=ye.ownerDocument||document,dt=wt&&wt.defaultView||window;if(dt.getSelection){var gt=dt.getSelection(),Vt=ye.textContent.length,rn=Math.min(Ie.start,Vt),Sr=Ie.end===void 0?rn:Math.min(Ie.end,Vt);!gt.extend&&rn>Sr&&(J=Sr,Sr=rn,rn=J);var Je=MF(ye,rn),Ge=MF(ye,Sr);if(Je&&Ge&&(gt.rangeCount!==1||gt.anchorNode!==Je.node||gt.anchorOffset!==Je.offset||gt.focusNode!==Ge.node||gt.focusOffset!==Ge.offset)){var at=wt.createRange();at.setStart(Je.node,Je.offset),gt.removeAllRanges(),rn>Sr?(gt.addRange(at),gt.extend(Ge.node,Ge.offset)):(at.setEnd(Ge.node,Ge.offset),gt.addRange(at))}}}}for(wt=[],gt=ye;gt=gt.parentNode;)gt.nodeType===1&&wt.push({element:gt,left:gt.scrollLeft,top:gt.scrollTop});for(typeof ye.focus=="function"&&ye.focus(),ye=0;ye<wt.length;ye++){var yt=wt[ye];yt.element.scrollLeft=yt.left,yt.element.scrollTop=yt.top}}Sw=!!SE,NE=SE=null}finally{hr=j,V.p=N,X.T=w}}h.current=g,Wi=2}}function H5(){if(Wi===2){Wi=0;var h=fd,g=sp,w=(g.flags&8772)!==0;if((g.subtreeFlags&8772)!==0||w){w=X.T,X.T=null;var N=V.p;V.p=2;var j=hr;hr|=4;try{g5(h,g.alternate,g)}finally{hr=j,V.p=N,X.T=w}}Wi=3}}function $5(){if(Wi===4||Wi===3){Wi=0,B();var h=fd,g=sp,w=Gc,N=A5;(g.subtreeFlags&10256)!==0||(g.flags&10256)!==0?Wi=5:(Wi=0,sp=fd=null,V5(h,h.pendingLanes));var j=h.pendingLanes;if(j===0&&(hd=null),Jn(w),g=g.stateNode,xe&&typeof xe.onCommitFiberRoot=="function")try{xe.onCommitFiberRoot(He,g,void 0,(g.current.flags&128)===128)}catch{}if(N!==null){g=X.T,j=V.p,V.p=2,X.T=null;try{for(var L=h.onRecoverableError,J=0;J<N.length;J++){var ye=N[J];L(ye.value,{componentStack:ye.stack})}}finally{X.T=g,V.p=j}}(Gc&3)!==0&&dw(),Kl(h),j=h.pendingLanes,(w&261930)!==0&&(j&42)!==0?h===uE?gb++:(gb=0,uE=h):gb=0,xb(0)}}function V5(h,g){(h.pooledCacheLanes&=g)===0&&(g=h.pooledCache,g!=null&&(h.pooledCache=null,Qx(g)))}function dw(){return B5(),H5(),$5(),G5()}function G5(){if(Wi!==5)return!1;var h=fd,g=lE;lE=0;var w=Jn(Gc),N=X.T,j=V.p;try{V.p=32>w?32:w,X.T=null,w=cE,cE=null;var L=fd,J=Gc;if(Wi=0,sp=fd=null,Gc=0,(hr&6)!==0)throw Error(r(331));var ye=hr;if(hr|=4,k5(L.current),S5(L,L.current,J,w),hr=ye,xb(0,!1),xe&&typeof xe.onPostCommitFiberRoot=="function")try{xe.onPostCommitFiberRoot(He,L)}catch{}return!0}finally{V.p=j,X.T=N,V5(h,g)}}function q5(h,g,w){g=Eo(w,g),g=Hk(h.stateNode,g,2),h=sd(h,g,2),h!==null&&(Bt(h,2),Kl(h))}function gr(h,g,w){if(h.tag===3)q5(h,h,w);else for(;g!==null;){if(g.tag===3){q5(g,h,w);break}else if(g.tag===1){var N=g.stateNode;if(typeof g.type.getDerivedStateFromError=="function"||typeof N.componentDidCatch=="function"&&(hd===null||!hd.has(N))){h=Eo(w,h),w=WI(2),N=sd(g,w,2),N!==null&&(KI(w,N,g,h),Bt(N,2),Kl(N));break}}g=g.return}}function fE(h,g,w){var N=h.pingCache;if(N===null){N=h.pingCache=new Iie;var j=new Set;N.set(g,j)}else j=N.get(g),j===void 0&&(j=new Set,N.set(g,j));j.has(w)||(aE=!0,j.add(w),h=$ie.bind(null,h,g,w),g.then(h,h))}function $ie(h,g,w){var N=h.pingCache;N!==null&&N.delete(g),h.pingedLanes|=h.suspendedLanes&w,h.warmLanes&=~w,jr===h&&(qn&w)===w&&(mi===4||mi===3&&(qn&62914560)===qn&&300>O()-aw?(hr&2)===0&&op(h,0):sE|=w,ap===qn&&(ap=0)),Kl(h)}function W5(h,g){g===0&&(g=bt()),h=Wh(h,g),h!==null&&(Bt(h,g),Kl(h))}function Vie(h){var g=h.memoizedState,w=0;g!==null&&(w=g.retryLane),W5(h,w)}function Gie(h,g){var w=0;switch(h.tag){case 31:case 13:var N=h.stateNode,j=h.memoizedState;j!==null&&(w=j.retryLane);break;case 19:N=h.stateNode;break;case 22:N=h.stateNode._retryCache;break;default:throw Error(r(314))}N!==null&&N.delete(g),W5(h,w)}function qie(h,g){return he(h,g)}var hw=null,cp=null,mE=!1,fw=!1,pE=!1,pd=0;function Kl(h){h!==cp&&h.next===null&&(cp===null?hw=cp=h:cp=cp.next=h),fw=!0,mE||(mE=!0,Kie())}function xb(h,g){if(!pE&&fw){pE=!0;do for(var w=!1,N=hw;N!==null;){if(h!==0){var j=N.pendingLanes;if(j===0)var L=0;else{var J=N.suspendedLanes,ye=N.pingedLanes;L=(1<<31-ze(42|h)+1)-1,L&=j&~(J&~ye),L=L&201326741?L&201326741|1:L?L|2:0}L!==0&&(w=!0,Q5(N,L))}else L=qn,L=W(N,N===jr?L:0,N.cancelPendingCommit!==null||N.timeoutHandle!==-1),(L&3)===0||je(N,L)||(w=!0,Q5(N,L));N=N.next}while(w);pE=!1}}function Wie(){K5()}function K5(){fw=mE=!1;var h=0;pd!==0&&iae()&&(h=pd);for(var g=O(),w=null,N=hw;N!==null;){var j=N.next,L=X5(N,g);L===0?(N.next=null,w===null?hw=j:w.next=j,j===null&&(cp=w)):(w=N,(h!==0||(L&3)!==0)&&(fw=!0)),N=j}Wi!==0&&Wi!==5||xb(h),pd!==0&&(pd=0)}function X5(h,g){for(var w=h.suspendedLanes,N=h.pingedLanes,j=h.expirationTimes,L=h.pendingLanes&-62914561;0<L;){var J=31-ze(L),ye=1<<J,Ie=j[J];Ie===-1?((ye&w)===0||(ye&N)!==0)&&(j[J]=Ye(ye,g)):Ie<=g&&(h.expiredLanes|=ye),L&=~ye}if(g=jr,w=qn,w=W(h,h===g?w:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),N=h.callbackNode,w===0||h===g&&(pr===2||pr===9)||h.cancelPendingCommit!==null)return N!==null&&N!==null&&Me(N),h.callbackNode=null,h.callbackPriority=0;if((w&3)===0||je(h,w)){if(g=w&-w,g===h.callbackPriority)return g;switch(N!==null&&Me(N),Jn(w)){case 2:case 8:w=_e;break;case 32:w=ve;break;case 268435456:w=Fe;break;default:w=ve}return N=Y5.bind(null,h),w=he(w,N),h.callbackPriority=g,h.callbackNode=w,g}return N!==null&&N!==null&&Me(N),h.callbackPriority=2,h.callbackNode=null,2}function Y5(h,g){if(Wi!==0&&Wi!==5)return h.callbackNode=null,h.callbackPriority=0,null;var w=h.callbackNode;if(dw()&&h.callbackNode!==w)return null;var N=qn;return N=W(h,h===jr?N:0,h.cancelPendingCommit!==null||h.timeoutHandle!==-1),N===0?null:(P5(h,N,g),X5(h,O()),h.callbackNode!=null&&h.callbackNode===w?Y5.bind(null,h):null)}function Q5(h,g){if(dw())return null;P5(h,g,!0)}function Kie(){sae(function(){(hr&6)!==0?he(le,Wie):K5()})}function gE(){if(pd===0){var h=Km;h===0&&(h=rt,rt<<=1,(rt&261888)===0&&(rt=256)),pd=h}return pd}function Z5(h){return h==null||typeof h=="symbol"||typeof h=="boolean"?null:typeof h=="function"?h:ln(""+h)}function J5(h,g){var w=g.ownerDocument.createElement("input");return w.name=g.name,w.value=g.value,h.id&&w.setAttribute("form",h.id),g.parentNode.insertBefore(w,g),h=new FormData(h),w.parentNode.removeChild(w),h}function Xie(h,g,w,N,j){if(g==="submit"&&w&&w.stateNode===j){var L=Z5((j[Nn]||null).action),J=N.submitter;J&&(g=(g=J[Nn]||null)?Z5(g.formAction):J.getAttribute("formAction"),g!==null&&(L=g,J=null));var ye=new Vl("action","action",null,N,j);h.push({event:ye,listeners:[{instance:null,listener:function(){if(N.defaultPrevented){if(pd!==0){var Ie=J?J5(j,J):new FormData(j);Lk(w,{pending:!0,data:Ie,method:j.method,action:L},null,Ie)}}else typeof L=="function"&&(ye.preventDefault(),Ie=J?J5(j,J):new FormData(j),Lk(w,{pending:!0,data:Ie,method:j.method,action:L},L,Ie))},currentTarget:j}]})}}for(var xE=0;xE<J2.length;xE++){var bE=J2[xE],Yie=bE.toLowerCase(),Qie=bE[0].toUpperCase()+bE.slice(1);xl(Yie,"on"+Qie)}xl(CF,"onAnimationEnd"),xl(PF,"onAnimationIteration"),xl(jF,"onAnimationStart"),xl("dblclick","onDoubleClick"),xl("focusin","onFocus"),xl("focusout","onBlur"),xl(fie,"onTransitionRun"),xl(mie,"onTransitionStart"),xl(pie,"onTransitionCancel"),xl(DF,"onTransitionEnd"),Tt("onMouseEnter",["mouseout","mouseover"]),Tt("onMouseLeave",["mouseout","mouseover"]),Tt("onPointerEnter",["pointerout","pointerover"]),Tt("onPointerLeave",["pointerout","pointerover"]),Qe("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Qe("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Qe("onBeforeInput",["compositionend","keypress","textInput","paste"]),Qe("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Qe("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Qe("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var bb="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(" "),Zie=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(bb));function eU(h,g){g=(g&4)!==0;for(var w=0;w<h.length;w++){var N=h[w],j=N.event;N=N.listeners;e:{var L=void 0;if(g)for(var J=N.length-1;0<=J;J--){var ye=N[J],Ie=ye.instance,st=ye.currentTarget;if(ye=ye.listener,Ie!==L&&j.isPropagationStopped())break e;L=ye,j.currentTarget=st;try{L(j)}catch(xt){Tv(xt)}j.currentTarget=null,L=Ie}else for(J=0;J<N.length;J++){if(ye=N[J],Ie=ye.instance,st=ye.currentTarget,ye=ye.listener,Ie!==L&&j.isPropagationStopped())break e;L=ye,j.currentTarget=st;try{L(j)}catch(xt){Tv(xt)}j.currentTarget=null,L=Ie}}}}function Un(h,g){var w=g[ai];w===void 0&&(w=g[ai]=new Set);var N=h+"__bubble";w.has(N)||(tU(g,h,2,!1),w.add(N))}function yE(h,g,w){var N=0;g&&(N|=4),tU(w,h,N,g)}var mw="_reactListening"+Math.random().toString(36).slice(2);function vE(h){if(!h[mw]){h[mw]=!0,Le.forEach(function(w){w!=="selectionchange"&&(Zie.has(w)||yE(w,!1,h),yE(w,!0,h))});var g=h.nodeType===9?h:h.ownerDocument;g===null||g[mw]||(g[mw]=!0,yE("selectionchange",!1,g))}}function tU(h,g,w,N){switch(CU(g)){case 2:var j=kae;break;case 8:j=Eae;break;default:j=OE}w=j.bind(null,g,w,h),j=void 0,!Ux||g!=="touchstart"&&g!=="touchmove"&&g!=="wheel"||(j=!0),N?j!==void 0?h.addEventListener(g,w,{capture:!0,passive:j}):h.addEventListener(g,w,!0):j!==void 0?h.addEventListener(g,w,{passive:j}):h.addEventListener(g,w,!1)}function wE(h,g,w,N,j){var L=N;if((g&1)===0&&(g&2)===0&&N!==null)e:for(;;){if(N===null)return;var J=N.tag;if(J===3||J===4){var ye=N.stateNode.containerInfo;if(ye===j)break;if(J===4)for(J=N.return;J!==null;){var Ie=J.tag;if((Ie===3||Ie===4)&&J.stateNode.containerInfo===j)return;J=J.return}for(;ye!==null;){if(J=Et(ye),J===null)return;if(Ie=J.tag,Ie===5||Ie===6||Ie===26||Ie===27){N=L=J;continue e}ye=ye.parentNode}}N=N.return}Ws(function(){var st=L,xt=_o(w),wt=[];e:{var dt=RF.get(h);if(dt!==void 0){var gt=Vl,Vt=h;switch(h){case"keypress":if(Vh(w)===0)break e;case"keydown":case"keyup":gt=Gre;break;case"focusin":Vt="focus",gt=Im;break;case"focusout":Vt="blur",gt=Im;break;case"beforeblur":case"afterblur":gt=Im;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":gt=Nv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":gt=Mv;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":gt=Kre;break;case CF:case PF:case jF:gt=kv;break;case DF:gt=Yre;break;case"scroll":case"scrollend":gt=Om;break;case"wheel":gt=Zre;break;case"copy":case"cut":case"paste":gt=_t;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":gt=dF;break;case"toggle":case"beforetoggle":gt=eie}var rn=(g&4)!==0,Sr=!rn&&(h==="scroll"||h==="scrollend"),Je=rn?dt!==null?dt+"Capture":null:dt;rn=[];for(var Ge=st,at;Ge!==null;){var yt=Ge;if(at=yt.stateNode,yt=yt.tag,yt!==5&&yt!==26&&yt!==27||at===null||Je===null||(yt=ca(Ge,Je),yt!=null&&rn.push(yb(Ge,yt,at))),Sr)break;Ge=Ge.return}0<rn.length&&(dt=new gt(dt,Vt,null,w,xt),wt.push({event:dt,listeners:rn}))}}if((g&7)===0){e:{if(dt=h==="mouseover"||h==="pointerover",gt=h==="mouseout"||h==="pointerout",dt&&w!==Ss&&(Vt=w.relatedTarget||w.fromElement)&&(Et(Vt)||Vt[hi]))break e;if((gt||dt)&&(dt=xt.window===xt?xt:(dt=xt.ownerDocument)?dt.defaultView||dt.parentWindow:window,gt?(Vt=w.relatedTarget||w.toElement,gt=st,Vt=Vt?Et(Vt):null,Vt!==null&&(Sr=a(Vt),rn=Vt.tag,Vt!==Sr||rn!==5&&rn!==27&&rn!==6)&&(Vt=null)):(gt=null,Vt=st),gt!==Vt)){if(rn=Nv,yt="onMouseLeave",Je="onMouseEnter",Ge="mouse",(h==="pointerout"||h==="pointerover")&&(rn=dF,yt="onPointerLeave",Je="onPointerEnter",Ge="pointer"),Sr=gt==null?dt:De(gt),at=Vt==null?dt:De(Vt),dt=new rn(yt,Ge+"leave",gt,w,xt),dt.target=Sr,dt.relatedTarget=at,yt=null,Et(xt)===st&&(rn=new rn(Je,Ge+"enter",Vt,w,xt),rn.target=at,rn.relatedTarget=Sr,yt=rn),Sr=yt,gt&&Vt)t:{for(rn=Jie,Je=gt,Ge=Vt,at=0,yt=Je;yt;yt=rn(yt))at++;yt=0;for(var Kt=Ge;Kt;Kt=rn(Kt))yt++;for(;0<at-yt;)Je=rn(Je),at--;for(;0<yt-at;)Ge=rn(Ge),yt--;for(;at--;){if(Je===Ge||Ge!==null&&Je===Ge.alternate){rn=Je;break t}Je=rn(Je),Ge=rn(Ge)}rn=null}else rn=null;gt!==null&&nU(wt,dt,gt,rn,!1),Vt!==null&&Sr!==null&&nU(wt,Sr,Vt,rn,!0)}}e:{if(dt=st?De(st):window,gt=dt.nodeName&&dt.nodeName.toLowerCase(),gt==="select"||gt==="input"&&dt.type==="file")var or=yF;else if(xF(dt))if(vF)or=uie;else{or=lie;var Wt=oie}else gt=dt.nodeName,!gt||gt.toLowerCase()!=="input"||dt.type!=="checkbox"&&dt.type!=="radio"?st&&Br(st.elementType)&&(or=yF):or=cie;if(or&&(or=or(h,st))){bF(wt,or,w,xt);break e}Wt&&Wt(h,dt,st),h==="focusout"&&st&&dt.type==="number"&&st.memoizedProps.value!=null&&dr(dt,"number",dt.value)}switch(Wt=st?De(st):window,h){case"focusin":(xF(Wt)||Wt.contentEditable==="true")&&(zm=Wt,Y2=st,Kx=null);break;case"focusout":Kx=Y2=zm=null;break;case"mousedown":Q2=!0;break;case"contextmenu":case"mouseup":case"dragend":Q2=!1,TF(wt,w,xt);break;case"selectionchange":if(hie)break;case"keydown":case"keyup":TF(wt,w,xt)}var kn;if(q2)e:{switch(h){case"compositionstart":var Wn="onCompositionStart";break e;case"compositionend":Wn="onCompositionEnd";break e;case"compositionupdate":Wn="onCompositionUpdate";break e}Wn=void 0}else Um?pF(h,w)&&(Wn="onCompositionEnd"):h==="keydown"&&w.keyCode===229&&(Wn="onCompositionStart");Wn&&(hF&&w.locale!=="ko"&&(Um||Wn!=="onCompositionStart"?Wn==="onCompositionEnd"&&Um&&(kn=Rm()):($l=xt,zx="value"in $l?$l.value:$l.textContent,Um=!0)),Wt=pw(st,Wn),0<Wt.length&&(Wn=new er(Wn,h,null,w,xt),wt.push({event:Wn,listeners:Wt}),kn?Wn.data=kn:(kn=gF(w),kn!==null&&(Wn.data=kn)))),(kn=nie?rie(h,w):iie(h,w))&&(Wn=pw(st,"onBeforeInput"),0<Wn.length&&(Wt=new er("onBeforeInput","beforeinput",null,w,xt),wt.push({event:Wt,listeners:Wn}),Wt.data=kn)),Xie(wt,h,st,w,xt)}eU(wt,g)})}function yb(h,g,w){return{instance:h,listener:g,currentTarget:w}}function pw(h,g){for(var w=g+"Capture",N=[];h!==null;){var j=h,L=j.stateNode;if(j=j.tag,j!==5&&j!==26&&j!==27||L===null||(j=ca(h,w),j!=null&&N.unshift(yb(h,j,L)),j=ca(h,g),j!=null&&N.push(yb(h,j,L))),h.tag===3)return N;h=h.return}return[]}function Jie(h){if(h===null)return null;do h=h.return;while(h&&h.tag!==5&&h.tag!==27);return h||null}function nU(h,g,w,N,j){for(var L=g._reactName,J=[];w!==null&&w!==N;){var ye=w,Ie=ye.alternate,st=ye.stateNode;if(ye=ye.tag,Ie!==null&&Ie===N)break;ye!==5&&ye!==26&&ye!==27||st===null||(Ie=st,j?(st=ca(w,L),st!=null&&J.unshift(yb(w,st,Ie))):j||(st=ca(w,L),st!=null&&J.push(yb(w,st,Ie)))),w=w.return}J.length!==0&&h.push({event:g,listeners:J})}var eae=/\r\n?/g,tae=/\u0000|\uFFFD/g;function rU(h){return(typeof h=="string"?h:""+h).replace(eae,`
- `).replace(tae,"")}function iU(h,g){return g=rU(g),rU(h)===g}function _r(h,g,w,N,j,L){switch(w){case"children":typeof N=="string"?g==="body"||g==="textarea"&&N===""||vt(h,N):(typeof N=="number"||typeof N=="bigint")&&g!=="body"&&vt(h,""+N);break;case"className":Ht(h,"class",N);break;case"tabIndex":Ht(h,"tabindex",N);break;case"dir":case"role":case"viewBox":case"width":case"height":Ht(h,w,N);break;case"style":Qr(h,N,L);break;case"data":if(g!=="object"){Ht(h,"data",N);break}case"src":case"href":if(N===""&&(g!=="a"||w!=="href")){h.removeAttribute(w);break}if(N==null||typeof N=="function"||typeof N=="symbol"||typeof N=="boolean"){h.removeAttribute(w);break}N=ln(""+N),h.setAttribute(w,N);break;case"action":case"formAction":if(typeof N=="function"){h.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 L=="function"&&(w==="formAction"?(g!=="input"&&_r(h,g,"name",j.name,j,null),_r(h,g,"formEncType",j.formEncType,j,null),_r(h,g,"formMethod",j.formMethod,j,null),_r(h,g,"formTarget",j.formTarget,j,null)):(_r(h,g,"encType",j.encType,j,null),_r(h,g,"method",j.method,j,null),_r(h,g,"target",j.target,j,null)));if(N==null||typeof N=="symbol"||typeof N=="boolean"){h.removeAttribute(w);break}N=ln(""+N),h.setAttribute(w,N);break;case"onClick":N!=null&&(h.onclick=Si);break;case"onScroll":N!=null&&Un("scroll",h);break;case"onScrollEnd":N!=null&&Un("scrollend",h);break;case"dangerouslySetInnerHTML":if(N!=null){if(typeof N!="object"||!("__html"in N))throw Error(r(61));if(w=N.__html,w!=null){if(j.children!=null)throw Error(r(60));h.innerHTML=w}}break;case"multiple":h.multiple=N&&typeof N!="function"&&typeof N!="symbol";break;case"muted":h.muted=N&&typeof N!="function"&&typeof N!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(N==null||typeof N=="function"||typeof N=="boolean"||typeof N=="symbol"){h.removeAttribute("xlink:href");break}w=ln(""+N),h.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":N!=null&&typeof N!="function"&&typeof N!="symbol"?h.setAttribute(w,""+N):h.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":N&&typeof N!="function"&&typeof N!="symbol"?h.setAttribute(w,""):h.removeAttribute(w);break;case"capture":case"download":N===!0?h.setAttribute(w,""):N!==!1&&N!=null&&typeof N!="function"&&typeof N!="symbol"?h.setAttribute(w,N):h.removeAttribute(w);break;case"cols":case"rows":case"size":case"span":N!=null&&typeof N!="function"&&typeof N!="symbol"&&!isNaN(N)&&1<=N?h.setAttribute(w,N):h.removeAttribute(w);break;case"rowSpan":case"start":N==null||typeof N=="function"||typeof N=="symbol"||isNaN(N)?h.removeAttribute(w):h.setAttribute(w,N);break;case"popover":Un("beforetoggle",h),Un("toggle",h),Jt(h,"popover",N);break;case"xlinkActuate":hn(h,"http://www.w3.org/1999/xlink","xlink:actuate",N);break;case"xlinkArcrole":hn(h,"http://www.w3.org/1999/xlink","xlink:arcrole",N);break;case"xlinkRole":hn(h,"http://www.w3.org/1999/xlink","xlink:role",N);break;case"xlinkShow":hn(h,"http://www.w3.org/1999/xlink","xlink:show",N);break;case"xlinkTitle":hn(h,"http://www.w3.org/1999/xlink","xlink:title",N);break;case"xlinkType":hn(h,"http://www.w3.org/1999/xlink","xlink:type",N);break;case"xmlBase":hn(h,"http://www.w3.org/XML/1998/namespace","xml:base",N);break;case"xmlLang":hn(h,"http://www.w3.org/XML/1998/namespace","xml:lang",N);break;case"xmlSpace":hn(h,"http://www.w3.org/XML/1998/namespace","xml:space",N);break;case"is":Jt(h,"is",N);break;case"innerText":case"textContent":break;default:(!(2<w.length)||w[0]!=="o"&&w[0]!=="O"||w[1]!=="n"&&w[1]!=="N")&&(w=qs.get(w)||w,Jt(h,w,N))}}function _E(h,g,w,N,j,L){switch(w){case"style":Qr(h,N,L);break;case"dangerouslySetInnerHTML":if(N!=null){if(typeof N!="object"||!("__html"in N))throw Error(r(61));if(w=N.__html,w!=null){if(j.children!=null)throw Error(r(60));h.innerHTML=w}}break;case"children":typeof N=="string"?vt(h,N):(typeof N=="number"||typeof N=="bigint")&&vt(h,""+N);break;case"onScroll":N!=null&&Un("scroll",h);break;case"onScrollEnd":N!=null&&Un("scrollend",h);break;case"onClick":N!=null&&(h.onclick=Si);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!tt.hasOwnProperty(w))e:{if(w[0]==="o"&&w[1]==="n"&&(j=w.endsWith("Capture"),g=w.slice(2,j?w.length-7:void 0),L=h[Nn]||null,L=L!=null?L[w]:null,typeof L=="function"&&h.removeEventListener(g,L,j),typeof N=="function")){typeof L!="function"&&L!==null&&(w in h?h[w]=null:h.hasAttribute(w)&&h.removeAttribute(w)),h.addEventListener(g,N,j);break e}w in h?h[w]=N:N===!0?h.setAttribute(w,""):Jt(h,w,N)}}}function Aa(h,g,w){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Un("error",h),Un("load",h);var N=!1,j=!1,L;for(L in w)if(w.hasOwnProperty(L)){var J=w[L];if(J!=null)switch(L){case"src":N=!0;break;case"srcSet":j=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:_r(h,g,L,J,w,null)}}j&&_r(h,g,"srcSet",w.srcSet,w,null),N&&_r(h,g,"src",w.src,w,null);return;case"input":Un("invalid",h);var ye=L=J=j=null,Ie=null,st=null;for(N in w)if(w.hasOwnProperty(N)){var xt=w[N];if(xt!=null)switch(N){case"name":j=xt;break;case"type":J=xt;break;case"checked":Ie=xt;break;case"defaultChecked":st=xt;break;case"value":L=xt;break;case"defaultValue":ye=xt;break;case"children":case"dangerouslySetInnerHTML":if(xt!=null)throw Error(r(137,g));break;default:_r(h,g,N,xt,w,null)}}ar(h,L,ye,Ie,st,J,j,!1);return;case"select":Un("invalid",h),N=J=L=null;for(j in w)if(w.hasOwnProperty(j)&&(ye=w[j],ye!=null))switch(j){case"value":L=ye;break;case"defaultValue":J=ye;break;case"multiple":N=ye;default:_r(h,g,j,ye,w,null)}g=L,w=J,h.multiple=!!N,g!=null?nt(h,!!N,g,!1):w!=null&&nt(h,!!N,w,!0);return;case"textarea":Un("invalid",h),L=j=N=null;for(J in w)if(w.hasOwnProperty(J)&&(ye=w[J],ye!=null))switch(J){case"value":N=ye;break;case"defaultValue":j=ye;break;case"children":L=ye;break;case"dangerouslySetInnerHTML":if(ye!=null)throw Error(r(91));break;default:_r(h,g,J,ye,w,null)}qt(h,N,j,L);return;case"option":for(Ie in w)if(w.hasOwnProperty(Ie)&&(N=w[Ie],N!=null))switch(Ie){case"selected":h.selected=N&&typeof N!="function"&&typeof N!="symbol";break;default:_r(h,g,Ie,N,w,null)}return;case"dialog":Un("beforetoggle",h),Un("toggle",h),Un("cancel",h),Un("close",h);break;case"iframe":case"object":Un("load",h);break;case"video":case"audio":for(N=0;N<bb.length;N++)Un(bb[N],h);break;case"image":Un("error",h),Un("load",h);break;case"details":Un("toggle",h);break;case"embed":case"source":case"link":Un("error",h),Un("load",h);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(st in w)if(w.hasOwnProperty(st)&&(N=w[st],N!=null))switch(st){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,g));default:_r(h,g,st,N,w,null)}return;default:if(Br(g)){for(xt in w)w.hasOwnProperty(xt)&&(N=w[xt],N!==void 0&&_E(h,g,xt,N,w,void 0));return}}for(ye in w)w.hasOwnProperty(ye)&&(N=w[ye],N!=null&&_r(h,g,ye,N,w,null))}function nae(h,g,w,N){switch(g){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var j=null,L=null,J=null,ye=null,Ie=null,st=null,xt=null;for(gt in w){var wt=w[gt];if(w.hasOwnProperty(gt)&&wt!=null)switch(gt){case"checked":break;case"value":break;case"defaultValue":Ie=wt;default:N.hasOwnProperty(gt)||_r(h,g,gt,null,N,wt)}}for(var dt in N){var gt=N[dt];if(wt=w[dt],N.hasOwnProperty(dt)&&(gt!=null||wt!=null))switch(dt){case"type":L=gt;break;case"name":j=gt;break;case"checked":st=gt;break;case"defaultChecked":xt=gt;break;case"value":J=gt;break;case"defaultValue":ye=gt;break;case"children":case"dangerouslySetInnerHTML":if(gt!=null)throw Error(r(137,g));break;default:gt!==wt&&_r(h,g,dt,gt,N,wt)}}si(h,J,ye,Ie,st,xt,L,j);return;case"select":gt=J=ye=dt=null;for(L in w)if(Ie=w[L],w.hasOwnProperty(L)&&Ie!=null)switch(L){case"value":break;case"multiple":gt=Ie;default:N.hasOwnProperty(L)||_r(h,g,L,null,N,Ie)}for(j in N)if(L=N[j],Ie=w[j],N.hasOwnProperty(j)&&(L!=null||Ie!=null))switch(j){case"value":dt=L;break;case"defaultValue":ye=L;break;case"multiple":J=L;default:L!==Ie&&_r(h,g,j,L,N,Ie)}g=ye,w=J,N=gt,dt!=null?nt(h,!!w,dt,!1):!!N!=!!w&&(g!=null?nt(h,!!w,g,!0):nt(h,!!w,w?[]:"",!1));return;case"textarea":gt=dt=null;for(ye in w)if(j=w[ye],w.hasOwnProperty(ye)&&j!=null&&!N.hasOwnProperty(ye))switch(ye){case"value":break;case"children":break;default:_r(h,g,ye,null,N,j)}for(J in N)if(j=N[J],L=w[J],N.hasOwnProperty(J)&&(j!=null||L!=null))switch(J){case"value":dt=j;break;case"defaultValue":gt=j;break;case"children":break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(r(91));break;default:j!==L&&_r(h,g,J,j,N,L)}Pt(h,dt,gt);return;case"option":for(var Vt in w)if(dt=w[Vt],w.hasOwnProperty(Vt)&&dt!=null&&!N.hasOwnProperty(Vt))switch(Vt){case"selected":h.selected=!1;break;default:_r(h,g,Vt,null,N,dt)}for(Ie in N)if(dt=N[Ie],gt=w[Ie],N.hasOwnProperty(Ie)&&dt!==gt&&(dt!=null||gt!=null))switch(Ie){case"selected":h.selected=dt&&typeof dt!="function"&&typeof dt!="symbol";break;default:_r(h,g,Ie,dt,N,gt)}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)dt=w[rn],w.hasOwnProperty(rn)&&dt!=null&&!N.hasOwnProperty(rn)&&_r(h,g,rn,null,N,dt);for(st in N)if(dt=N[st],gt=w[st],N.hasOwnProperty(st)&&dt!==gt&&(dt!=null||gt!=null))switch(st){case"children":case"dangerouslySetInnerHTML":if(dt!=null)throw Error(r(137,g));break;default:_r(h,g,st,dt,N,gt)}return;default:if(Br(g)){for(var Sr in w)dt=w[Sr],w.hasOwnProperty(Sr)&&dt!==void 0&&!N.hasOwnProperty(Sr)&&_E(h,g,Sr,void 0,N,dt);for(xt in N)dt=N[xt],gt=w[xt],!N.hasOwnProperty(xt)||dt===gt||dt===void 0&>===void 0||_E(h,g,xt,dt,N,gt);return}}for(var Je in w)dt=w[Je],w.hasOwnProperty(Je)&&dt!=null&&!N.hasOwnProperty(Je)&&_r(h,g,Je,null,N,dt);for(wt in N)dt=N[wt],gt=w[wt],!N.hasOwnProperty(wt)||dt===gt||dt==null&>==null||_r(h,g,wt,dt,N,gt)}function aU(h){switch(h){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function rae(){if(typeof performance.getEntriesByType=="function"){for(var h=0,g=0,w=performance.getEntriesByType("resource"),N=0;N<w.length;N++){var j=w[N],L=j.transferSize,J=j.initiatorType,ye=j.duration;if(L&&ye&&aU(J)){for(J=0,ye=j.responseEnd,N+=1;N<w.length;N++){var Ie=w[N],st=Ie.startTime;if(st>ye)break;var xt=Ie.transferSize,wt=Ie.initiatorType;xt&&aU(wt)&&(Ie=Ie.responseEnd,J+=xt*(Ie<ye?1:(ye-st)/(Ie-st)))}if(--N,g+=8*(L+J)/(j.duration/1e3),h++,10<h)break}}if(0<h)return g/h/1e6}return navigator.connection&&(h=navigator.connection.downlink,typeof h=="number")?h:5}var SE=null,NE=null;function gw(h){return h.nodeType===9?h:h.ownerDocument}function sU(h){switch(h){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function oU(h,g){if(h===0)switch(g){case"svg":return 1;case"math":return 2;default:return 0}return h===1&&g==="foreignObject"?0:h}function ME(h,g){return h==="textarea"||h==="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 kE=null;function iae(){var h=window.event;return h&&h.type==="popstate"?h===kE?!1:(kE=h,!0):(kE=null,!1)}var lU=typeof setTimeout=="function"?setTimeout:void 0,aae=typeof clearTimeout=="function"?clearTimeout:void 0,cU=typeof Promise=="function"?Promise:void 0,sae=typeof queueMicrotask=="function"?queueMicrotask:typeof cU<"u"?function(h){return cU.resolve(null).then(h).catch(oae)}:lU;function oae(h){setTimeout(function(){throw h})}function gd(h){return h==="head"}function uU(h,g){var w=g,N=0;do{var j=w.nextSibling;if(h.removeChild(w),j&&j.nodeType===8)if(w=j.data,w==="/$"||w==="/&"){if(N===0){h.removeChild(j),fp(g);return}N--}else if(w==="$"||w==="$?"||w==="$~"||w==="$!"||w==="&")N++;else if(w==="html")vb(h.ownerDocument.documentElement);else if(w==="head"){w=h.ownerDocument.head,vb(w);for(var L=w.firstChild;L;){var J=L.nextSibling,ye=L.nodeName;L[ut]||ye==="SCRIPT"||ye==="STYLE"||ye==="LINK"&&L.rel.toLowerCase()==="stylesheet"||w.removeChild(L),L=J}}else w==="body"&&vb(h.ownerDocument.body);w=j}while(w);fp(g)}function dU(h,g){var w=h;h=0;do{var N=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||""),N&&N.nodeType===8)if(w=N.data,w==="/$"){if(h===0)break;h--}else w!=="$"&&w!=="$?"&&w!=="$~"&&w!=="$!"||h++;w=N}while(w)}function EE(h){var g=h.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":EE(w),lt(w);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(w.rel.toLowerCase()==="stylesheet")continue}h.removeChild(w)}}function lae(h,g,w,N){for(;h.nodeType===1;){var j=w;if(h.nodeName.toLowerCase()!==g.toLowerCase()){if(!N&&(h.nodeName!=="INPUT"||h.type!=="hidden"))break}else if(N){if(!h[ut])switch(g){case"meta":if(!h.hasAttribute("itemprop"))break;return h;case"link":if(L=h.getAttribute("rel"),L==="stylesheet"&&h.hasAttribute("data-precedence"))break;if(L!==j.rel||h.getAttribute("href")!==(j.href==null||j.href===""?null:j.href)||h.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin)||h.getAttribute("title")!==(j.title==null?null:j.title))break;return h;case"style":if(h.hasAttribute("data-precedence"))break;return h;case"script":if(L=h.getAttribute("src"),(L!==(j.src==null?null:j.src)||h.getAttribute("type")!==(j.type==null?null:j.type)||h.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin))&&L&&h.hasAttribute("async")&&!h.hasAttribute("itemprop"))break;return h;default:return h}}else if(g==="input"&&h.type==="hidden"){var L=j.name==null?null:""+j.name;if(j.type==="hidden"&&h.getAttribute("name")===L)return h}else return h;if(h=jo(h.nextSibling),h===null)break}return null}function cae(h,g,w){if(g==="")return null;for(;h.nodeType!==3;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!w||(h=jo(h.nextSibling),h===null))return null;return h}function hU(h,g){for(;h.nodeType!==8;)if((h.nodeType!==1||h.nodeName!=="INPUT"||h.type!=="hidden")&&!g||(h=jo(h.nextSibling),h===null))return null;return h}function TE(h){return h.data==="$?"||h.data==="$~"}function AE(h){return h.data==="$!"||h.data==="$?"&&h.ownerDocument.readyState!=="loading"}function uae(h,g){var w=h.ownerDocument;if(h.data==="$~")h._reactRetry=g;else if(h.data!=="$?"||w.readyState!=="loading")g();else{var N=function(){g(),w.removeEventListener("DOMContentLoaded",N)};w.addEventListener("DOMContentLoaded",N),h._reactRetry=N}}function jo(h){for(;h!=null;h=h.nextSibling){var g=h.nodeType;if(g===1||g===3)break;if(g===8){if(g=h.data,g==="$"||g==="$!"||g==="$?"||g==="$~"||g==="&"||g==="F!"||g==="F")break;if(g==="/$"||g==="/&")return null}}return h}var CE=null;function fU(h){h=h.nextSibling;for(var g=0;h;){if(h.nodeType===8){var w=h.data;if(w==="/$"||w==="/&"){if(g===0)return jo(h.nextSibling);g--}else w!=="$"&&w!=="$!"&&w!=="$?"&&w!=="$~"&&w!=="&"||g++}h=h.nextSibling}return null}function mU(h){h=h.previousSibling;for(var g=0;h;){if(h.nodeType===8){var w=h.data;if(w==="$"||w==="$!"||w==="$?"||w==="$~"||w==="&"){if(g===0)return h;g--}else w!=="/$"&&w!=="/&"||g++}h=h.previousSibling}return null}function pU(h,g,w){switch(g=gw(w),h){case"html":if(h=g.documentElement,!h)throw Error(r(452));return h;case"head":if(h=g.head,!h)throw Error(r(453));return h;case"body":if(h=g.body,!h)throw Error(r(454));return h;default:throw Error(r(451))}}function vb(h){for(var g=h.attributes;g.length;)h.removeAttributeNode(g[0]);lt(h)}var Do=new Map,gU=new Set;function xw(h){return typeof h.getRootNode=="function"?h.getRootNode():h.nodeType===9?h:h.ownerDocument}var qc=V.d;V.d={f:dae,r:hae,D:fae,C:mae,L:pae,m:gae,X:bae,S:xae,M:yae};function dae(){var h=qc.f(),g=lw();return h||g}function hae(h){var g=fe(h);g!==null&&g.tag===5&&g.type==="form"?DI(g):qc.r(h)}var up=typeof document>"u"?null:document;function xU(h,g,w){var N=up;if(N&&typeof g=="string"&&g){var j=jn(g);j='link[rel="'+h+'"][href="'+j+'"]',typeof w=="string"&&(j+='[crossorigin="'+w+'"]'),gU.has(j)||(gU.add(j),h={rel:h,crossOrigin:w,href:g},N.querySelector(j)===null&&(g=N.createElement("link"),Aa(g,"link",h),Se(g),N.head.appendChild(g)))}}function fae(h){qc.D(h),xU("dns-prefetch",h,null)}function mae(h,g){qc.C(h,g),xU("preconnect",h,g)}function pae(h,g,w){qc.L(h,g,w);var N=up;if(N&&h&&g){var j='link[rel="preload"][as="'+jn(g)+'"]';g==="image"&&w&&w.imageSrcSet?(j+='[imagesrcset="'+jn(w.imageSrcSet)+'"]',typeof w.imageSizes=="string"&&(j+='[imagesizes="'+jn(w.imageSizes)+'"]')):j+='[href="'+jn(h)+'"]';var L=j;switch(g){case"style":L=dp(h);break;case"script":L=hp(h)}Do.has(L)||(h=f({rel:"preload",href:g==="image"&&w&&w.imageSrcSet?void 0:h,as:g},w),Do.set(L,h),N.querySelector(j)!==null||g==="style"&&N.querySelector(wb(L))||g==="script"&&N.querySelector(_b(L))||(g=N.createElement("link"),Aa(g,"link",h),Se(g),N.head.appendChild(g)))}}function gae(h,g){qc.m(h,g);var w=up;if(w&&h){var N=g&&typeof g.as=="string"?g.as:"script",j='link[rel="modulepreload"][as="'+jn(N)+'"][href="'+jn(h)+'"]',L=j;switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":L=hp(h)}if(!Do.has(L)&&(h=f({rel:"modulepreload",href:h},g),Do.set(L,h),w.querySelector(j)===null)){switch(N){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(w.querySelector(_b(L)))return}N=w.createElement("link"),Aa(N,"link",h),Se(N),w.head.appendChild(N)}}}function xae(h,g,w){qc.S(h,g,w);var N=up;if(N&&h){var j=Ve(N).hoistableStyles,L=dp(h);g=g||"default";var J=j.get(L);if(!J){var ye={loading:0,preload:null};if(J=N.querySelector(wb(L)))ye.loading=5;else{h=f({rel:"stylesheet",href:h,"data-precedence":g},w),(w=Do.get(L))&&PE(h,w);var Ie=J=N.createElement("link");Se(Ie),Aa(Ie,"link",h),Ie._p=new Promise(function(st,xt){Ie.onload=st,Ie.onerror=xt}),Ie.addEventListener("load",function(){ye.loading|=1}),Ie.addEventListener("error",function(){ye.loading|=2}),ye.loading|=4,bw(J,g,N)}J={type:"stylesheet",instance:J,count:1,state:ye},j.set(L,J)}}}function bae(h,g){qc.X(h,g);var w=up;if(w&&h){var N=Ve(w).hoistableScripts,j=hp(h),L=N.get(j);L||(L=w.querySelector(_b(j)),L||(h=f({src:h,async:!0},g),(g=Do.get(j))&&jE(h,g),L=w.createElement("script"),Se(L),Aa(L,"link",h),w.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},N.set(j,L))}}function yae(h,g){qc.M(h,g);var w=up;if(w&&h){var N=Ve(w).hoistableScripts,j=hp(h),L=N.get(j);L||(L=w.querySelector(_b(j)),L||(h=f({src:h,async:!0,type:"module"},g),(g=Do.get(j))&&jE(h,g),L=w.createElement("script"),Se(L),Aa(L,"link",h),w.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},N.set(j,L))}}function bU(h,g,w,N){var j=(j=me.current)?xw(j):null;if(!j)throw Error(r(446));switch(h){case"meta":case"title":return null;case"style":return typeof w.precedence=="string"&&typeof w.href=="string"?(g=dp(w.href),w=Ve(j).hoistableStyles,N=w.get(g),N||(N={type:"style",instance:null,count:0,state:null},w.set(g,N)),N):{type:"void",instance:null,count:0,state:null};case"link":if(w.rel==="stylesheet"&&typeof w.href=="string"&&typeof w.precedence=="string"){h=dp(w.href);var L=Ve(j).hoistableStyles,J=L.get(h);if(J||(j=j.ownerDocument||j,J={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},L.set(h,J),(L=j.querySelector(wb(h)))&&!L._p&&(J.instance=L,J.state.loading=5),Do.has(h)||(w={rel:"preload",as:"style",href:w.href,crossOrigin:w.crossOrigin,integrity:w.integrity,media:w.media,hrefLang:w.hrefLang,referrerPolicy:w.referrerPolicy},Do.set(h,w),L||vae(j,h,w,J.state))),g&&N===null)throw Error(r(528,""));return J}if(g&&N!==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=hp(w),w=Ve(j).hoistableScripts,N=w.get(g),N||(N={type:"script",instance:null,count:0,state:null},w.set(g,N)),N):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,h))}}function dp(h){return'href="'+jn(h)+'"'}function wb(h){return'link[rel="stylesheet"]['+h+"]"}function yU(h){return f({},h,{"data-precedence":h.precedence,precedence:null})}function vae(h,g,w,N){h.querySelector('link[rel="preload"][as="style"]['+g+"]")?N.loading=1:(g=h.createElement("link"),N.preload=g,g.addEventListener("load",function(){return N.loading|=1}),g.addEventListener("error",function(){return N.loading|=2}),Aa(g,"link",w),Se(g),h.head.appendChild(g))}function hp(h){return'[src="'+jn(h)+'"]'}function _b(h){return"script[async]"+h}function vU(h,g,w){if(g.count++,g.instance===null)switch(g.type){case"style":var N=h.querySelector('style[data-href~="'+jn(w.href)+'"]');if(N)return g.instance=N,Se(N),N;var j=f({},w,{"data-href":w.href,"data-precedence":w.precedence,href:null,precedence:null});return N=(h.ownerDocument||h).createElement("style"),Se(N),Aa(N,"style",j),bw(N,w.precedence,h),g.instance=N;case"stylesheet":j=dp(w.href);var L=h.querySelector(wb(j));if(L)return g.state.loading|=4,g.instance=L,Se(L),L;N=yU(w),(j=Do.get(j))&&PE(N,j),L=(h.ownerDocument||h).createElement("link"),Se(L);var J=L;return J._p=new Promise(function(ye,Ie){J.onload=ye,J.onerror=Ie}),Aa(L,"link",N),g.state.loading|=4,bw(L,w.precedence,h),g.instance=L;case"script":return L=hp(w.src),(j=h.querySelector(_b(L)))?(g.instance=j,Se(j),j):(N=w,(j=Do.get(L))&&(N=f({},w),jE(N,j)),h=h.ownerDocument||h,j=h.createElement("script"),Se(j),Aa(j,"link",N),h.head.appendChild(j),g.instance=j);case"void":return null;default:throw Error(r(443,g.type))}else g.type==="stylesheet"&&(g.state.loading&4)===0&&(N=g.instance,g.state.loading|=4,bw(N,w.precedence,h));return g.instance}function bw(h,g,w){for(var N=w.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),j=N.length?N[N.length-1]:null,L=j,J=0;J<N.length;J++){var ye=N[J];if(ye.dataset.precedence===g)L=ye;else if(L!==j)break}L?L.parentNode.insertBefore(h,L.nextSibling):(g=w.nodeType===9?w.head:w,g.insertBefore(h,g.firstChild))}function PE(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.title==null&&(h.title=g.title)}function jE(h,g){h.crossOrigin==null&&(h.crossOrigin=g.crossOrigin),h.referrerPolicy==null&&(h.referrerPolicy=g.referrerPolicy),h.integrity==null&&(h.integrity=g.integrity)}var yw=null;function wU(h,g,w){if(yw===null){var N=new Map,j=yw=new Map;j.set(w,N)}else j=yw,N=j.get(w),N||(N=new Map,j.set(w,N));if(N.has(h))return N;for(N.set(h,null),w=w.getElementsByTagName(h),j=0;j<w.length;j++){var L=w[j];if(!(L[ut]||L[Xn]||h==="link"&&L.getAttribute("rel")==="stylesheet")&&L.namespaceURI!=="http://www.w3.org/2000/svg"){var J=L.getAttribute(g)||"";J=h+J;var ye=N.get(J);ye?ye.push(L):N.set(J,[L])}}return N}function _U(h,g,w){h=h.ownerDocument||h,h.head.insertBefore(w,g==="title"?h.querySelector("head > title"):null)}function wae(h,g,w){if(w===1||g.itemProp!=null)return!1;switch(h){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 h=g.disabled,typeof g.precedence=="string"&&h==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 SU(h){return!(h.type==="stylesheet"&&(h.state.loading&3)===0)}function _ae(h,g,w,N){if(w.type==="stylesheet"&&(typeof N.media!="string"||matchMedia(N.media).matches!==!1)&&(w.state.loading&4)===0){if(w.instance===null){var j=dp(N.href),L=g.querySelector(wb(j));if(L){g=L._p,g!==null&&typeof g=="object"&&typeof g.then=="function"&&(h.count++,h=vw.bind(h),g.then(h,h)),w.state.loading|=4,w.instance=L,Se(L);return}L=g.ownerDocument||g,N=yU(N),(j=Do.get(j))&&PE(N,j),L=L.createElement("link"),Se(L);var J=L;J._p=new Promise(function(ye,Ie){J.onload=ye,J.onerror=Ie}),Aa(L,"link",N),w.instance=L}h.stylesheets===null&&(h.stylesheets=new Map),h.stylesheets.set(w,g),(g=w.state.preload)&&(w.state.loading&3)===0&&(h.count++,w=vw.bind(h),g.addEventListener("load",w),g.addEventListener("error",w))}}var DE=0;function Sae(h,g){return h.stylesheets&&h.count===0&&_w(h,h.stylesheets),0<h.count||0<h.imgCount?function(w){var N=setTimeout(function(){if(h.stylesheets&&_w(h,h.stylesheets),h.unsuspend){var L=h.unsuspend;h.unsuspend=null,L()}},6e4+g);0<h.imgBytes&&DE===0&&(DE=62500*rae());var j=setTimeout(function(){if(h.waitingForImages=!1,h.count===0&&(h.stylesheets&&_w(h,h.stylesheets),h.unsuspend)){var L=h.unsuspend;h.unsuspend=null,L()}},(h.imgBytes>DE?50:800)+g);return h.unsuspend=w,function(){h.unsuspend=null,clearTimeout(N),clearTimeout(j)}}:null}function vw(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)_w(this,this.stylesheets);else if(this.unsuspend){var h=this.unsuspend;this.unsuspend=null,h()}}}var ww=null;function _w(h,g){h.stylesheets=null,h.unsuspend!==null&&(h.count++,ww=new Map,g.forEach(Nae,h),ww=null,vw.call(h))}function Nae(h,g){if(!(g.state.loading&4)){var w=ww.get(h);if(w)var N=w.get(null);else{w=new Map,ww.set(h,w);for(var j=h.querySelectorAll("link[data-precedence],style[data-precedence]"),L=0;L<j.length;L++){var J=j[L];(J.nodeName==="LINK"||J.getAttribute("media")!=="not all")&&(w.set(J.dataset.precedence,J),N=J)}N&&w.set(null,N)}j=g.instance,J=j.getAttribute("data-precedence"),L=w.get(J)||N,L===N&&w.set(null,j),w.set(J,j),this.count++,N=vw.bind(this),j.addEventListener("load",N),j.addEventListener("error",N),L?L.parentNode.insertBefore(j,L.nextSibling):(h=h.nodeType===9?h.head:h,h.insertBefore(j,h.firstChild)),g.state.loading|=4}}var Sb={$$typeof:k,Provider:null,Consumer:null,_currentValue:Q,_currentValue2:Q,_threadCount:0};function Mae(h,g,w,N,j,L,J,ye,Ie){this.tag=1,this.containerInfo=h,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=pt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pt(0),this.hiddenUpdates=pt(null),this.identifierPrefix=N,this.onUncaughtError=j,this.onCaughtError=L,this.onRecoverableError=J,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=Ie,this.incompleteTransitions=new Map}function NU(h,g,w,N,j,L,J,ye,Ie,st,xt,wt){return h=new Mae(h,g,w,J,Ie,st,xt,wt,ye),g=1,L===!0&&(g|=24),L=Xs(3,null,null,g),h.current=L,L.stateNode=h,g=hk(),g.refCount++,h.pooledCache=g,g.refCount++,L.memoizedState={element:N,isDehydrated:w,cache:g},gk(L),h}function MU(h){return h?(h=$m,h):$m}function kU(h,g,w,N,j,L){j=MU(j),N.context===null?N.context=j:N.pendingContext=j,N=ad(g),N.payload={element:w},L=L===void 0?null:L,L!==null&&(N.callback=L),w=sd(h,N,g),w!==null&&(As(w,h,g),tb(w,h,g))}function EU(h,g){if(h=h.memoizedState,h!==null&&h.dehydrated!==null){var w=h.retryLane;h.retryLane=w!==0&&w<g?w:g}}function RE(h,g){EU(h,g),(h=h.alternate)&&EU(h,g)}function TU(h){if(h.tag===13||h.tag===31){var g=Wh(h,67108864);g!==null&&As(g,h,67108864),RE(h,67108864)}}function AU(h){if(h.tag===13||h.tag===31){var g=eo();g=Vn(g);var w=Wh(h,g);w!==null&&As(w,h,g),RE(h,g)}}var Sw=!0;function kae(h,g,w,N){var j=X.T;X.T=null;var L=V.p;try{V.p=2,OE(h,g,w,N)}finally{V.p=L,X.T=j}}function Eae(h,g,w,N){var j=X.T;X.T=null;var L=V.p;try{V.p=8,OE(h,g,w,N)}finally{V.p=L,X.T=j}}function OE(h,g,w,N){if(Sw){var j=LE(N);if(j===null)wE(h,g,N,Nw,w),PU(h,N);else if(Aae(j,h,g,w,N))N.stopPropagation();else if(PU(h,N),g&4&&-1<Tae.indexOf(h)){for(;j!==null;){var L=fe(j);if(L!==null)switch(L.tag){case 3:if(L=L.stateNode,L.current.memoizedState.isDehydrated){var J=Ue(L.pendingLanes);if(J!==0){var ye=L;for(ye.pendingLanes|=2,ye.entangledLanes|=2;J;){var Ie=1<<31-ze(J);ye.entanglements[1]|=Ie,J&=~Ie}Kl(L),(hr&6)===0&&(sw=O()+500,xb(0))}}break;case 31:case 13:ye=Wh(L,2),ye!==null&&As(ye,L,2),lw(),RE(L,2)}if(L=LE(N),L===null&&wE(h,g,N,Nw,w),L===j)break;j=L}j!==null&&N.stopPropagation()}else wE(h,g,N,null,w)}}function LE(h){return h=_o(h),FE(h)}var Nw=null;function FE(h){if(Nw=null,h=Et(h),h!==null){var g=a(h);if(g===null)h=null;else{var w=g.tag;if(w===13){if(h=o(g),h!==null)return h;h=null}else if(w===31){if(h=l(g),h!==null)return h;h=null}else if(w===3){if(g.stateNode.current.memoizedState.isDehydrated)return g.tag===3?g.stateNode.containerInfo:null;h=null}else g!==h&&(h=null)}}return Nw=h,null}function CU(h){switch(h){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(ee()){case le:return 2;case _e:return 8;case ve:case ae:return 32;case Fe:return 268435456;default:return 32}default:return 32}}var IE=!1,xd=null,bd=null,yd=null,Nb=new Map,Mb=new Map,vd=[],Tae="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function PU(h,g){switch(h){case"focusin":case"focusout":xd=null;break;case"dragenter":case"dragleave":bd=null;break;case"mouseover":case"mouseout":yd=null;break;case"pointerover":case"pointerout":Nb.delete(g.pointerId);break;case"gotpointercapture":case"lostpointercapture":Mb.delete(g.pointerId)}}function kb(h,g,w,N,j,L){return h===null||h.nativeEvent!==L?(h={blockedOn:g,domEventName:w,eventSystemFlags:N,nativeEvent:L,targetContainers:[j]},g!==null&&(g=fe(g),g!==null&&TU(g)),h):(h.eventSystemFlags|=N,g=h.targetContainers,j!==null&&g.indexOf(j)===-1&&g.push(j),h)}function Aae(h,g,w,N,j){switch(g){case"focusin":return xd=kb(xd,h,g,w,N,j),!0;case"dragenter":return bd=kb(bd,h,g,w,N,j),!0;case"mouseover":return yd=kb(yd,h,g,w,N,j),!0;case"pointerover":var L=j.pointerId;return Nb.set(L,kb(Nb.get(L)||null,h,g,w,N,j)),!0;case"gotpointercapture":return L=j.pointerId,Mb.set(L,kb(Mb.get(L)||null,h,g,w,N,j)),!0}return!1}function jU(h){var g=Et(h.target);if(g!==null){var w=a(g);if(w!==null){if(g=w.tag,g===13){if(g=o(w),g!==null){h.blockedOn=g,sr(h.priority,function(){AU(w)});return}}else if(g===31){if(g=l(w),g!==null){h.blockedOn=g,sr(h.priority,function(){AU(w)});return}}else if(g===3&&w.stateNode.current.memoizedState.isDehydrated){h.blockedOn=w.tag===3?w.stateNode.containerInfo:null;return}}}h.blockedOn=null}function Mw(h){if(h.blockedOn!==null)return!1;for(var g=h.targetContainers;0<g.length;){var w=LE(h.nativeEvent);if(w===null){w=h.nativeEvent;var N=new w.constructor(w.type,w);Ss=N,w.target.dispatchEvent(N),Ss=null}else return g=fe(w),g!==null&&TU(g),h.blockedOn=w,!1;g.shift()}return!0}function DU(h,g,w){Mw(h)&&w.delete(g)}function Cae(){IE=!1,xd!==null&&Mw(xd)&&(xd=null),bd!==null&&Mw(bd)&&(bd=null),yd!==null&&Mw(yd)&&(yd=null),Nb.forEach(DU),Mb.forEach(DU)}function kw(h,g){h.blockedOn===g&&(h.blockedOn=null,IE||(IE=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Cae)))}var Ew=null;function RU(h){Ew!==h&&(Ew=h,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Ew===h&&(Ew=null);for(var g=0;g<h.length;g+=3){var w=h[g],N=h[g+1],j=h[g+2];if(typeof N!="function"){if(FE(N||w)===null)continue;break}var L=fe(w);L!==null&&(h.splice(g,3),g-=3,Lk(L,{pending:!0,data:j,method:w.method,action:N},N,j))}}))}function fp(h){function g(Ie){return kw(Ie,h)}xd!==null&&kw(xd,h),bd!==null&&kw(bd,h),yd!==null&&kw(yd,h),Nb.forEach(g),Mb.forEach(g);for(var w=0;w<vd.length;w++){var N=vd[w];N.blockedOn===h&&(N.blockedOn=null)}for(;0<vd.length&&(w=vd[0],w.blockedOn===null);)jU(w),w.blockedOn===null&&vd.shift();if(w=(h.ownerDocument||h).$$reactFormReplay,w!=null)for(N=0;N<w.length;N+=3){var j=w[N],L=w[N+1],J=j[Nn]||null;if(typeof L=="function")J||RU(w);else if(J){var ye=null;if(L&&L.hasAttribute("formAction")){if(j=L,J=L[Nn]||null)ye=J.formAction;else if(FE(j)!==null)continue}else ye=J.action;typeof ye=="function"?w[N+1]=ye:(w.splice(N,3),N-=3),RU(w)}}}function OU(){function h(L){L.canIntercept&&L.info==="react-transition"&&L.intercept({handler:function(){return new Promise(function(J){return j=J})},focusReset:"manual",scroll:"manual"})}function g(){j!==null&&(j(),j=null),N||setTimeout(w,20)}function w(){if(!N&&!navigation.transition){var L=navigation.currentEntry;L&&L.url!=null&&navigation.navigate(L.url,{state:L.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var N=!1,j=null;return navigation.addEventListener("navigate",h),navigation.addEventListener("navigatesuccess",g),navigation.addEventListener("navigateerror",g),setTimeout(w,100),function(){N=!0,navigation.removeEventListener("navigate",h),navigation.removeEventListener("navigatesuccess",g),navigation.removeEventListener("navigateerror",g),j!==null&&(j(),j=null)}}}function UE(h){this._internalRoot=h}Tw.prototype.render=UE.prototype.render=function(h){var g=this._internalRoot;if(g===null)throw Error(r(409));var w=g.current,N=eo();kU(w,N,h,g,null,null)},Tw.prototype.unmount=UE.prototype.unmount=function(){var h=this._internalRoot;if(h!==null){this._internalRoot=null;var g=h.containerInfo;kU(h.current,2,null,h,null,null),lw(),g[hi]=null}};function Tw(h){this._internalRoot=h}Tw.prototype.unstable_scheduleHydration=function(h){if(h){var g=gn();h={blockedOn:null,target:h,priority:g};for(var w=0;w<vd.length&&g!==0&&g<vd[w].priority;w++);vd.splice(w,0,h),w===0&&jU(h)}};var LU=e.version;if(LU!=="19.2.0")throw Error(r(527,LU,"19.2.0"));V.findDOMNode=function(h){var g=h._reactInternals;if(g===void 0)throw typeof h.render=="function"?Error(r(188)):(h=Object.keys(h).join(","),Error(r(268,h)));return h=u(g),h=h!==null?d(h):null,h=h===null?null:h.stateNode,h};var Pae={bundleType:0,version:"19.2.0",rendererPackageName:"react-dom",currentDispatcherRef:X,reconcilerVersion:"19.2.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Aw=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Aw.isDisabled&&Aw.supportsFiber)try{He=Aw.inject(Pae),xe=Aw}catch{}}return Tb.createRoot=function(h,g){if(!i(h))throw Error(r(299));var w=!1,N="",j=$I,L=VI,J=GI;return g!=null&&(g.unstable_strictMode===!0&&(w=!0),g.identifierPrefix!==void 0&&(N=g.identifierPrefix),g.onUncaughtError!==void 0&&(j=g.onUncaughtError),g.onCaughtError!==void 0&&(L=g.onCaughtError),g.onRecoverableError!==void 0&&(J=g.onRecoverableError)),g=NU(h,1,!1,null,null,w,N,null,j,L,J,OU),h[hi]=g.current,vE(h),new UE(g)},Tb.hydrateRoot=function(h,g,w){if(!i(h))throw Error(r(299));var N=!1,j="",L=$I,J=VI,ye=GI,Ie=null;return w!=null&&(w.unstable_strictMode===!0&&(N=!0),w.identifierPrefix!==void 0&&(j=w.identifierPrefix),w.onUncaughtError!==void 0&&(L=w.onUncaughtError),w.onCaughtError!==void 0&&(J=w.onCaughtError),w.onRecoverableError!==void 0&&(ye=w.onRecoverableError),w.formState!==void 0&&(Ie=w.formState)),g=NU(h,1,!0,g,w??null,N,j,Ie,L,J,ye,OU),g.context=MU(null),w=g.current,N=eo(),N=Vn(N),j=ad(N),j.callback=null,sd(w,j,N),w=N,g.current.lanes=w,Bt(g,w),Kl(g),h[hi]=g.current,vE(h),new Tw(g)},Tb.version="19.2.0",Tb}var qU;function Hae(){if(qU)return HE.exports;qU=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(),HE.exports=Bae(),HE.exports}var $ae=Hae();const mn=t=>typeof t=="string",Ab=()=>{let t,e;const n=new Promise((r,i)=>{t=r,e=i});return n.resolve=t,n.reject=e,n},WU=t=>t==null?"":""+t,Vae=(t,e,n)=>{t.forEach(r=>{e[r]&&(n[r]=e[r])})},Gae=/###/g,KU=t=>t&&t.indexOf("###")>-1?t.replace(Gae,"."):t,XU=t=>!t||mn(t),x0=(t,e,n)=>{const r=mn(e)?e.split("."):e;let i=0;for(;i<r.length-1;){if(XU(t))return{};const a=KU(r[i]);!t[a]&&n&&(t[a]=new n),Object.prototype.hasOwnProperty.call(t,a)?t=t[a]:t={},++i}return XU(t)?{}:{obj:t,k:KU(r[i])}},YU=(t,e,n)=>{const{obj:r,k:i}=x0(t,e,Object);if(r!==void 0||e.length===1){r[i]=n;return}let a=e[e.length-1],o=e.slice(0,e.length-1),l=x0(t,o,Object);for(;l.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),l=x0(t,o,Object),l?.obj&&typeof l.obj[`${l.k}.${a}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${a}`]=n},qae=(t,e,n,r)=>{const{obj:i,k:a}=x0(t,e,Object);i[a]=i[a]||[],i[a].push(n)},z1=(t,e)=>{const{obj:n,k:r}=x0(t,e);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},Wae=(t,e,n)=>{const r=z1(t,n);return r!==void 0?r:z1(e,n)},Nq=(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]):Nq(t[r],e[r],n):t[r]=e[r]);return t},mp=t=>t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var Kae={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const Xae=t=>mn(t)?t.replace(/[&<>"'\/]/g,e=>Kae[e]):t;class Yae{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 Qae=[" ",",","?","!",";"],Zae=new Yae(20),Jae=(t,e,n)=>{e=e||"",n=n||"";const r=Qae.filter(o=>e.indexOf(o)<0&&n.indexOf(o)<0);if(r.length===0)return!0;const i=Zae.getRegExp(`(${r.map(o=>o==="?"?"\\?":o).join("|")})`);let a=!i.test(t);if(!a){const o=t.indexOf(n);o>0&&!i.test(t.substring(0,o))&&(a=!0)}return a},YP=(t,e,n=".")=>{if(!t)return;if(t[e])return Object.prototype.hasOwnProperty.call(t,e)?t[e]:void 0;const r=e.split(n);let i=t;for(let a=0;a<r.length;){if(!i||typeof i!="object")return;let o,l="";for(let c=a;c<r.length;++c)if(c!==a&&(l+=n),l+=r[c],o=i[l],o!==void 0){if(["string","number","boolean"].indexOf(typeof o)>-1&&c<r.length-1)continue;a+=c-a+1;break}i=o}return i},B0=t=>t?.replace("_","-"),ese={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 B1{constructor(e,n={}){this.init(e,n)}init(e,n={}){this.prefix=n.prefix||"i18next:",this.logger=e||ese,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 B1(this.logger,{prefix:`${this.prefix}:${e}:`,...this.options})}clone(e){return e=e||this.options,e.prefix=e.prefix||this.prefix,new B1(this.logger,e)}}var sc=new B1;let nM=class{constructor(){this.observers={}}on(e,n){return e.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+1)}),this}off(e,n){if(this.observers[e]){if(!n){delete this.observers[e];return}this.observers[e].delete(n)}}emit(e,...n){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([i,a])=>{for(let o=0;o<a;o++)i(...n)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(([i,a])=>{for(let o=0;o<a;o++)i.apply(i,[e,...n])})}};class QU extends nM{constructor(e,n={ns:["translation"],defaultNS:"translation"}){super(),this.data=e||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){const n=this.options.ns.indexOf(e);n>-1&&this.options.ns.splice(n,1)}getResource(e,n,r,i={}){const a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,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)&&a?l.push(...r.split(a)):l.push(r)));const c=z1(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:YP(this.data?.[e]?.[n],r,a)}addResource(e,n,r,i,a={silent:!1}){const o=a.keySeparator!==void 0?a.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),YU(this.data,l,i),a.silent||this.emit("added",e,n,r,i)}addResources(e,n,r,i={silent:!1}){for(const a in r)(mn(r[a])||Array.isArray(r[a]))&&this.addResource(e,n,a,r[a],{silent:!0});i.silent||this.emit("added",e,n,r)}addResourceBundle(e,n,r,i,a,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=z1(this.data,l)||{};o.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?Nq(c,r,a):c={...c,...r},YU(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 Mq={processors:{},addPostProcessor(t){this.processors[t.name]=t},handle(t,e,n,r,i){return t.forEach(a=>{e=this.processors[a]?.process(e,n,r,i)??e}),e}};const kq=Symbol("i18next/PATH_KEY");function tse(){const t=[],e=Object.create(null);let n;return e.get=(r,i)=>(n?.revoke?.(),i===kq?t:(t.push(i),n=Proxy.revocable(r,e),n.proxy)),Proxy.revocable(Object.create(null),e).proxy}function QP(t,e){const{[kq]:n}=t(tse());return n.join(e?.keySeparator??".")}const ZU={},qE=t=>!mn(t)&&typeof t!="boolean"&&typeof t!="number";class H1 extends nM{constructor(e,n={}){super(),Vae(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],e,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=sc.create("translator")}changeLanguage(e){e&&(this.language=e)}exists(e,n={interpolation:{}}){const r={...n};if(e==null)return!1;const i=this.resolve(e,r);if(i?.res===void 0)return!1;const a=qE(i.res);return!(r.returnObjects===!1&&a)}extractFromKey(e,n){let r=n.nsSeparator!==void 0?n.nsSeparator:this.options.nsSeparator;r===void 0&&(r=":");const i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let a=n.ns||this.options.defaultNS||[];const o=r&&e.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!Jae(e,r,i);if(o&&!l){const c=e.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:e,namespaces:mn(a)?[a]:a};const u=e.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(a=u.shift()),e=u.join(i)}return{key:e,namespaces:mn(a)?[a]:a}}translate(e,n,r){let i=typeof n=="object"?{...n}:n;if(typeof i!="object"&&this.options.overloadTranslationOptionHandler&&(i=this.options.overloadTranslationOptionHandler(arguments)),typeof i=="object"&&(i={...i}),i||(i={}),e==null)return"";typeof e=="function"&&(e=QP(e,{...this.options,...i})),Array.isArray(e)||(e=[String(e)]);const a=i.returnDetails!==void 0?i.returnDetails:this.options.returnDetails,o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,{key:l,namespaces:c}=this.extractFromKey(e[e.length-1],i),u=c[c.length-1];let d=i.nsSeparator!==void 0?i.nsSeparator:this.options.nsSeparator;d===void 0&&(d=":");const f=i.lng||this.language,p=i.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()==="cimode")return p?a?{res:`${u}${d}${l}`,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:`${u}${d}${l}`:a?{res:l,usedKey:l,exactUsedKey:l,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(i)}:l;const m=this.resolve(e,i);let x=m?.res;const b=m?.usedKey||l,v=m?.exactUsedKey||l,y=["[object Number]","[object Function]","[object RegExp]"],S=i.joinArrays!==void 0?i.joinArrays:this.options.joinArrays,k=!this.i18nFormat||this.i18nFormat.handleAsObject,T=i.count!==void 0&&!mn(i.count),M=H1.hasDefaultValue(i),C=T?this.pluralResolver.getSuffix(f,i.count,i):"",E=i.ordinal&&T?this.pluralResolver.getSuffix(f,i.count,{ordinal:!1}):"",R=T&&!i.ordinal&&i.count===0,A=R&&i[`defaultValue${this.options.pluralSeparator}zero`]||i[`defaultValue${C}`]||i[`defaultValue${E}`]||i.defaultValue;let D=x;k&&!x&&M&&(D=A);const I=qE(D),F=Object.prototype.toString.apply(D);if(k&&D&&I&&y.indexOf(F)<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 z=this.options.returnedObjectHandler?this.options.returnedObjectHandler(b,D,{...i,ns:c}):`key '${l} (${this.language})' returned an object instead of string.`;return a?(m.res=z,m.usedParams=this.getUsedParamsDetails(i),m):z}if(o){const z=Array.isArray(D),P=z?[]:{},$=z?v:b;for(const X in D)if(Object.prototype.hasOwnProperty.call(D,X)){const V=`${$}${o}${X}`;M&&!x?P[X]=this.translate(V,{...i,defaultValue:qE(A)?A[X]:void 0,joinArrays:!1,ns:c}):P[X]=this.translate(V,{...i,joinArrays:!1,ns:c}),P[X]===V&&(P[X]=D[X])}x=P}}else if(k&&mn(S)&&Array.isArray(x))x=x.join(S),x&&(x=this.extendTranslation(x,e,i,r));else{let z=!1,P=!1;!this.isValidLookup(x)&&M&&(z=!0,x=A),this.isValidLookup(x)||(P=!0,x=l);const X=(i.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&P?void 0:x,V=M&&A!==x&&this.options.updateMissing;if(P||z||V){if(this.logger.log(V?"updateKey":"missingKey",f,u,l,V?A:x),o){const H=this.resolve(l,{...i,keySeparator:!1});H&&H.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let Q=[];const Z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,i.lng||this.language);if(this.options.saveMissingTo==="fallback"&&Z&&Z[0])for(let H=0;H<Z.length;H++)Q.push(Z[H]);else this.options.saveMissingTo==="all"?Q=this.languageUtils.toResolveHierarchy(i.lng||this.language):Q.push(i.lng||this.language);const se=(H,K,re)=>{const ne=M&&re!==x?re:X;this.options.missingKeyHandler?this.options.missingKeyHandler(H,u,K,ne,V,i):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(H,u,K,ne,V,i),this.emit("missingKey",H,u,K,x)};this.options.saveMissing&&(this.options.saveMissingPlurals&&T?Q.forEach(H=>{const K=this.pluralResolver.getSuffixes(H,i);R&&i[`defaultValue${this.options.pluralSeparator}zero`]&&K.indexOf(`${this.options.pluralSeparator}zero`)<0&&K.push(`${this.options.pluralSeparator}zero`),K.forEach(re=>{se([H],l+re,i[`defaultValue${re}`]||A)})}):se(Q,l,A))}x=this.extendTranslation(x,e,i,m,r),P&&x===l&&this.options.appendNamespaceToMissingKey&&(x=`${u}${d}${l}`),(P||z)&&this.options.parseMissingKeyHandler&&(x=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${l}`:l,z?x:void 0,i))}return a?(m.res=x,m.usedParams=this.getUsedParamsDetails(i),m):x}extendTranslation(e,n,r,i,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const c=mn(e)&&(r?.interpolation?.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let u;if(c){const f=e.match(this.interpolator.nestingRegexp);u=f&&f.length}let d=r.replace&&!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 f=e.match(this.interpolator.nestingRegexp),p=f&&f.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,(...f)=>a?.[0]===f[0]&&!r.context?(this.logger.warn(`It seems you are nesting recursively key: ${f[0]} in key: ${n[0]}`),null):this.translate(...f,n),r)),r.interpolation&&this.interpolator.reset()}const o=r.postProcess||this.options.postProcess,l=mn(o)?[o]:o;return e!=null&&l?.length&&r.applyPostProcessor!==!1&&(e=Mq.handle(l,e,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),e}resolve(e,n={}){let r,i,a,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 f=u.namespaces;this.options.fallbackNS&&(f=f.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!=="",b=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(v=>{this.isValidLookup(r)||(l=v,!ZU[`${b[0]}-${v}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(l)&&(ZU[`${b[0]}-${v}`]=!0,this.logger.warn(`key "${i}" for languages "${b.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!!!")),b.forEach(y=>{if(this.isValidLookup(r))return;o=y;const S=[d];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(S,d,y,v,n);else{let T;p&&(T=this.pluralResolver.getSuffix(y,n.count,n));const M=`${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+M)),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+M))}}let k;for(;k=S.pop();)this.isValidLookup(r)||(a=k,r=this.getResource(y,v,k,n))}))})}),{res:r,usedKey:i,exactUsedKey:a,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 a of n)delete i[a]}return i}static hasDefaultValue(e){const n="defaultValue";for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)&&n===r.substring(0,n.length)&&e[r]!==void 0)return!0;return!1}}class JU{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=sc.create("languageUtils")}getScriptPartFromCode(e){if(e=B0(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=B0(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 a=this.getLanguagePartFromCode(r);if(this.isSupportedCode(a))return n=a;n=this.options.supportedLngs.find(o=>{if(o===a)return o;if(!(o.indexOf("-")<0&&a.indexOf("-")<0)&&(o.indexOf("-")>0&&a.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===a||o.indexOf(a)===0&&a.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=[],a=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"&&a(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(e))):mn(e)&&a(this.formatLanguageCode(e)),r.forEach(o=>{i.indexOf(o)<0&&a(this.formatLanguageCode(o))}),i}}const ez={zero:0,one:1,two:2,few:3,many:4,other:5},tz={select:t=>t===1?"one":"other",resolvedOptions:()=>({pluralCategories:["one","other"]})};class nse{constructor(e,n={}){this.languageUtils=e,this.options=n,this.logger=sc.create("pluralResolver"),this.pluralRulesCache={}}addRule(e,n){this.rules[e]=n}clearCache(){this.pluralRulesCache={}}getRule(e,n={}){const r=B0(e==="dev"?"en":e),i=n.ordinal?"ordinal":"cardinal",a=JSON.stringify({cleanedCode:r,type:i});if(a in this.pluralRulesCache)return this.pluralRulesCache[a];let o;try{o=new Intl.PluralRules(r,{type:i})}catch{if(!Intl)return this.logger.error("No Intl support, please use an Intl polyfill!"),tz;if(!e.match(/-|_/))return tz;const c=this.languageUtils.getLanguagePartFromCode(e);o=this.getRule(c,n)}return this.pluralRulesCache[a]=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,a)=>ez[i]-ez[a]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):[]}getSuffix(e,n,r={}){const i=this.getRule(e,r);return i?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix("dev",n,r))}}const nz=(t,e,n,r=".",i=!0)=>{let a=Wae(t,e,n);return!a&&i&&mn(n)&&(a=YP(t,n,r),a===void 0&&(a=YP(e,n,r))),a},WE=t=>t.replace(/\$/g,"$$$$");class rse{constructor(e={}){this.logger=sc.create("interpolator"),this.options=e,this.format=e?.interpolation?.format||(n=>n),this.init(e)}init(e={}){e.interpolation||(e.interpolation={escapeValue:!0});const{escape:n,escapeValue:r,useRawValueToEscape:i,prefix:a,prefixEscaped:o,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:d,unescapePrefix:f,nestingPrefix:p,nestingPrefixEscaped:m,nestingSuffix:x,nestingSuffixEscaped:b,nestingOptionsSeparator:v,maxReplaces:y,alwaysFormat:S}=e.interpolation;this.escape=n!==void 0?n:Xae,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=a?mp(a):o||"{{",this.suffix=l?mp(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=p?mp(p):m||mp("$t("),this.nestingSuffix=x?mp(x):b||mp(")"),this.nestingOptionsSeparator=v||",",this.maxReplaces=y||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 a,o,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=m=>{if(m.indexOf(this.formatSeparator)<0){const y=nz(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,r,{...i,...n,interpolationkey:m}):y}const x=m.split(this.formatSeparator),b=x.shift().trim(),v=x.join(this.formatSeparator).trim();return this.format(nz(n,c,b,this.options.keySeparator,this.options.ignoreJSONStructure),v,r,{...i,...n,interpolationkey:b})};this.resetRegExp();const d=i?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=i?.interpolation?.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>WE(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?WE(this.escape(m)):WE(m)}].forEach(m=>{for(l=0;a=m.regex.exec(e);){const x=a[1].trim();if(o=u(x),o===void 0)if(typeof d=="function"){const v=d(e,a,i);o=mn(v)?v:""}else if(i&&Object.prototype.hasOwnProperty.call(i,x))o="";else if(f){o=a[0];continue}else this.logger.warn(`missed to pass in variable ${x} for interpolating ${e}`),o="";else!mn(o)&&!this.useRawValueToEscape&&(o=WU(o));const b=m.safeValue(o);if(e=e.replace(a[0],b),f?(m.regex.lastIndex+=o.length,m.regex.lastIndex-=a[0].length):m.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),e}nest(e,n,r={}){let i,a,o;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let p=`{${f[1]}`;c=f[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(b){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,b),`${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)),a=n(l.call(this,i[1].trim(),o),o),a&&i[0]===e&&!mn(a))return a;mn(a)||(a=WU(a)),a||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${e}`),a=""),c.length&&(a=c.reduce((d,f)=>this.format(d,f,r.lng,{...r,interpolationkey:i[1].trim()}),a.trim())),e=e.replace(i[0],a),this.regexp.lastIndex=0}return e}}const ise=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}},rz=t=>{const e={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});const o=r+JSON.stringify(a);let l=e[o];return l||(l=t(B0(r),i),e[o]=l),l(n)}},ase=t=>(e,n,r)=>t(B0(n),r)(e);class sse{constructor(e={}){this.logger=sc.create("formatter"),this.options=e,this.init(e)}init(e,n={interpolation:{}}){this.formatSeparator=n.interpolation.formatSeparator||",";const r=n.cacheInBuiltFormats?rz:ase;this.formats={number:r((i,a)=>{const o=new Intl.NumberFormat(i,{...a});return l=>o.format(l)}),currency:r((i,a)=>{const o=new Intl.NumberFormat(i,{...a,style:"currency"});return l=>o.format(l)}),datetime:r((i,a)=>{const o=new Intl.DateTimeFormat(i,{...a});return l=>o.format(l)}),relativetime:r((i,a)=>{const o=new Intl.RelativeTimeFormat(i,{...a});return l=>o.format(l,a.range||"day")}),list:r((i,a)=>{const o=new Intl.ListFormat(i,{...a});return l=>o.format(l)})}}add(e,n){this.formats[e.toLowerCase().trim()]=n}addCached(e,n){this.formats[e.toLowerCase().trim()]=rz(n)}format(e,n,r,i={}){const a=n.split(this.formatSeparator);if(a.length>1&&a[0].indexOf("(")>1&&a[0].indexOf(")")<0&&a.find(l=>l.indexOf(")")>-1)){const l=a.findIndex(c=>c.indexOf(")")>-1);a[0]=[a[0],...a.splice(1,l)].join(this.formatSeparator)}return a.reduce((l,c)=>{const{formatName:u,formatOptions:d}=ise(c);if(this.formats[u]){let f=l;try{const p=i?.formatParams?.[i.interpolationkey]||{},m=p.locale||p.lng||i.locale||i.lng||r;f=this.formats[u](l,m,{...d,...i,...p})}catch(p){this.logger.warn(p)}return f}else this.logger.warn(`there was no format function for ${u}`);return l},e)}}const ose=(t,e)=>{t.pending[e]!==void 0&&(delete t.pending[e],t.pendingCount--)};class lse extends nM{constructor(e,n,r,i={}){super(),this.backend=e,this.store=n,this.services=r,this.languageUtils=r.languageUtils,this.options=i,this.logger=sc.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(r,i.backend,i)}queueLoad(e,n,r,i){const a={},o={},l={},c={};return e.forEach(u=>{let d=!0;n.forEach(f=>{const p=`${u}|${f}`;!r.reload&&this.store.hasResourceBundle(u,f)?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),a[p]===void 0&&(a[p]=!0),c[f]===void 0&&(c[f]=!0)))}),d||(l[u]=!0)}),(Object.keys(a).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(a),pending:Object.keys(o),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(e,n,r){const i=e.split("|"),a=i[0],o=i[1];n&&this.emit("failedLoading",a,o,n),!n&&r&&this.store.addResourceBundle(a,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=>{qae(c.loaded,[a],o),ose(c,e),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const d=c.loaded[u];d.length&&d.forEach(f=>{l[u][f]===void 0&&(l[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(e,n,r,i=0,a=this.retryTimeout,o){if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:n,fcName:r,tried:i,wait:a,callback:o});return}this.readingCalls++;const l=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&d&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,e,n,r,i+1,a*2,o)},a);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 a=this.queueLoad(e,n,r,i);if(!a.toLoad.length)return a.pending.length||i(),null;a.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],a=r[1];this.read(i,a,"read",void 0,void 0,(o,l)=>{o&&this.logger.warn(`${n}loading namespace ${a} for language ${i} failed`,o),!o&&l&&this.logger.log(`${n}loaded namespace ${a} for language ${i}`,l),this.loaded(e,o,l)})}saveMissing(e,n,r,i,a,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:a},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(e,n,r,i,c):d=u(e,n,r,i),d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}else u(e,n,r,i,l,c)}!e||!e[0]||this.store.addResource(e[0],n,r,i)}}}const iz=()=>({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}),az=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=()=>{},cse=t=>{Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(n=>{typeof t[n]=="function"&&(t[n]=t[n].bind(t))})};class b0 extends nM{constructor(e={},n){if(super(),this.options=az(e),this.services={},this.logger=sc,this.modules={external:[]},cse(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=iz();this.options={...r,...this.options,...az(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?sc.init(i(this.modules.logger),this.options):sc.init(null,this.options);let u;this.modules.formatter?u=this.modules.formatter:u=sse;const d=new JU(this.options);this.store=new QU(this.options.resources,this.options);const f=this.services;f.logger=sc,f.resourceStore=this.store,f.languageUtils=d,f.pluralResolver=new nse(d,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),this.options.interpolation.format&&this.options.interpolation.format!==r.interpolation.format&&this.logger.deprecate("init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting"),u&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(f.formatter=i(u),f.formatter.init&&f.formatter.init(f,this.options),this.options.interpolation.format=f.formatter.format.bind(f.formatter)),f.interpolator=new rse(this.options),f.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},f.backendConnector=new lse(i(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",(m,...x)=>{this.emit(m,...x)}),this.modules.languageDetector&&(f.languageDetector=i(this.modules.languageDetector),f.languageDetector.init&&f.languageDetector.init(f,this.options.detection,this.options)),this.modules.i18nFormat&&(f.i18nFormat=i(this.modules.i18nFormat),f.i18nFormat.init&&f.i18nFormat.init(this)),this.translator=new H1(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=Ab(),c=()=>{const u=(d,f)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),l.resolve(f),n(d,f)};if(this.languages&&!this.isInitialized)return u(null,this.t.bind(this));this.changeLanguage(this.options.lng,u)};return this.options.resources||!this.options.initAsync?c():setTimeout(c,0),l}loadResources(e,n=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 a=[],o=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&a.indexOf(u)<0&&a.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(a,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(e,n,r){const i=Ab();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,a=>{i.resolve(),r(a)}),i}use(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return e.type==="backend"&&(this.modules.backend=e),(e.type==="logger"||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type==="languageDetector"&&(this.modules.languageDetector=e),e.type==="i18nFormat"&&(this.modules.i18nFormat=e),e.type==="postProcessor"&&Mq.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=Ab();this.emit("languageChanging",e);const i=l=>{this.language=l,this.languages=this.services.languageUtils.toResolveHierarchy(l),this.resolvedLanguage=void 0,this.setResolvedLanguage(l)},a=(l,c)=>{c?this.isLanguageChangingTo===e&&(i(c),this.translator.changeLanguage(c),this.isLanguageChangingTo=void 0,this.emit("languageChanged",c),this.logger.log("languageChanged",c)):this.isLanguageChangingTo=void 0,r.resolve((...u)=>this.t(...u)),n&&n(l,(...u)=>this.t(...u))},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=>{a(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=(a,o,...l)=>{let c;typeof o!="object"?c=this.options.overloadTranslationOptionHandler([a,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(a)?d=a.map(f=>(typeof f=="function"&&(f=QP(f,{...this.options,...o})),`${c.keyPrefix}${u}${f}`)):(typeof a=="function"&&(a=QP(a,{...this.options,...o})),d=c.keyPrefix?`${c.keyPrefix}${u}${a}`:a),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,a=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(a,e)))}loadNamespaces(e,n){const r=Ab();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=Ab();mn(e)&&(e=[e]);const i=this.options.preload||[],a=e.filter(o=>i.indexOf(o)<0&&this.services.languageUtils.isSupportedCode(o));return a.length?(this.options.preload=i.concat(a),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 a=i.getTextInfo();if(a&&a.direction)return a.direction}}catch{}const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services?.languageUtils||new JU(iz());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 b0(e,n);return r.createInstance=b0.createInstance,r}cloneInstance(e={},n=Pw){const r=e.forkResourceStore;r&&delete e.forkResourceStore;const i={...this.options,...e,isClone:!0},a=new b0(i);if((e.debug!==void 0||e.prefix!==void 0)&&(a.logger=a.logger.clone(e)),["store","services","language"].forEach(l=>{a[l]=this[l]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r){const l=Object.keys(this.store.data).reduce((c,u)=>(c[u]={...this.store.data[u]},c[u]=Object.keys(c[u]).reduce((d,f)=>(d[f]={...c[u][f]},d),c[u]),c),{});a.store=new QU(l,i),a.services.resourceStore=a.store}return a.translator=new H1(a.services,i),a.translator.on("*",(l,...c)=>{a.emit(l,...c)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const _s=b0.createInstance();_s.createInstance;_s.dir;_s.init;_s.loadResources;_s.reloadResources;_s.use;_s.changeLanguage;_s.getFixedT;_s.t;_s.exists;_s.setDefaultNamespace;_s.hasLoadedNamespace;_s.loadNamespaces;_s.loadLanguages;const use=(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);em(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),t?.services?.logger?.warn?t.services.logger.warn(...i):console?.warn&&console.warn(...i)},sz={},Eq=(t,e,n,r)=>{em(n)&&sz[n]||(em(n)&&(sz[n]=new Date),use(t,e,n,r))},Tq=(t,e)=>()=>{if(t.isInitialized)e();else{const n=()=>{setTimeout(()=>{t.off("initialized",n)},0),e()};t.on("initialized",n)}},ZP=(t,e,n)=>{t.loadNamespaces(e,Tq(t,n))},oz=(t,e,n,r)=>{if(em(n)&&(n=[n]),t.options.preload&&t.options.preload.indexOf(e)>-1)return ZP(t,n,r);n.forEach(i=>{t.options.ns.indexOf(i)<0&&t.options.ns.push(i)}),t.loadLanguages(e,Tq(t,r))},dse=(t,e,n={})=>!e.languages||!e.languages.length?(Eq(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}}),em=t=>typeof t=="string",hse=t=>typeof t=="object"&&t!==null,fse=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,mse={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},pse=t=>mse[t],gse=t=>t.replace(fse,pse);let JP={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:gse};const xse=(t={})=>{JP={...JP,...t}},bse=()=>JP;let Aq;const yse=t=>{Aq=t},vse=()=>Aq,wse={type:"3rdParty",init(t){xse(t.options.react),yse(t)}},_se=_.createContext();class Sse{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}var KE={exports:{}},XE={};var lz;function Nse(){if(lz)return XE;lz=1;var t=px();function e(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,a=t.useLayoutEffect,o=t.useDebugValue;function l(f,p){var m=p(),x=r({inst:{value:m,getSnapshot:p}}),b=x[0].inst,v=x[1];return a(function(){b.value=m,b.getSnapshot=p,c(b)&&v({inst:b})},[f,m,p]),i(function(){return c(b)&&v({inst:b}),f(function(){c(b)&&v({inst:b})})},[f]),o(m),m}function c(f){var p=f.getSnapshot;f=f.value;try{var m=p();return!n(f,m)}catch{return!0}}function u(f,p){return p()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:l;return XE.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,XE}var cz;function Cq(){return cz||(cz=1,KE.exports=Nse()),KE.exports}var fR=Cq();const Mse=(t,e)=>em(e)?e:hse(e)&&em(e.defaultValue)?e.defaultValue:Array.isArray(t)?t[t.length-1]:t,kse={t:Mse,ready:!1},Ese=()=>()=>{},Rn=(t,e={})=>{const{i18n:n}=e,{i18n:r,defaultNS:i}=_.useContext(_se)||{},a=n||r||vse();a&&!a.reportNamespaces&&(a.reportNamespaces=new Sse),a||Eq(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const o=_.useMemo(()=>({...bse(),...a?.options?.react,...e}),[a,e]),{useSuspense:l,keyPrefix:c}=o,u=i||a?.options?.defaultNS,d=em(u)?[u]:u||["translation"],f=_.useMemo(()=>d,d);a?.reportNamespaces?.addUsedNamespaces?.(f);const p=_.useRef(0),m=_.useCallback(A=>{if(!a)return Ese;const{bindI18n:D,bindI18nStore:I}=o,F=()=>{p.current+=1,A()};return D&&a.on(D,F),I&&a.store.on(I,F),()=>{D&&D.split(" ").forEach(z=>a.off(z,F)),I&&I.split(" ").forEach(z=>a.store.off(z,F))}},[a,o]),x=_.useRef(),b=_.useCallback(()=>{if(!a)return kse;const A=!!(a.isInitialized||a.initializedStoreOnce)&&f.every($=>dse($,a,o)),D=e.lng||a.language,I=p.current,F=x.current;if(F&&F.ready===A&&F.lng===D&&F.keyPrefix===c&&F.revision===I)return F;const P={t:a.getFixedT(D,o.nsMode==="fallback"?f:f[0],c),ready:A,lng:D,keyPrefix:c,revision:I};return x.current=P,P},[a,f,c,o,e.lng]),[v,y]=_.useState(0),{t:S,ready:k}=fR.useSyncExternalStore(m,b,b);_.useEffect(()=>{if(a&&!k&&!l){const A=()=>y(D=>D+1);e.lng?oz(a,e.lng,f,A):ZP(a,f,A)}},[a,e.lng,f,k,l,v]);const T=a||{},M=_.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},R=_.useMemo(()=>{const A=T,D=A?.language;let I=A;A&&(M.current&&M.current.__original===A?C.current!==D?(I=E(A),M.current=I,C.current=D):I=M.current:(I=E(A),M.current=I,C.current=D));const F=[S,I,k];return F.t=S,F.i18n=I,F.ready=k,F},[S,T,k,T.resolvedLanguage,T.language,T.languages]);if(a&&l&&!k)throw new Promise(A=>{const D=()=>A();e.lng?oz(a,e.lng,f,D):ZP(a,f,D)});return R},{slice:Tse,forEach:Ase}=[];function Cse(t){return Ase.call(Tse.call(arguments,1),e=>{if(e)for(const n in e)t[n]===void 0&&(t[n]=e[n])}),t}function Pse(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 uz=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,jse=function(t,e){const r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:"/"},i=encodeURIComponent(e);let a=`${t}=${i}`;if(r.maxAge>0){const o=r.maxAge-0;if(Number.isNaN(o))throw new Error("maxAge should be a Number");a+=`; Max-Age=${Math.floor(o)}`}if(r.domain){if(!uz.test(r.domain))throw new TypeError("option domain is invalid");a+=`; Domain=${r.domain}`}if(r.path){if(!uz.test(r.path))throw new TypeError("option path is invalid");a+=`; Path=${r.path}`}if(r.expires){if(typeof r.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+=`; Expires=${r.expires.toUTCString()}`}if(r.httpOnly&&(a+="; HttpOnly"),r.secure&&(a+="; Secure"),r.sameSite)switch(typeof r.sameSite=="string"?r.sameSite.toLowerCase():r.sameSite){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return r.partitioned&&(a+="; Partitioned"),a},dz={create(t,e,n,r){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};n&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+n*60*1e3)),r&&(i.domain=r),document.cookie=jse(t,e,i)},read(t){const e=`${t}=`,n=document.cookie.split(";");for(let r=0;r<n.length;r++){let i=n[r];for(;i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return i.substring(e.length,i.length)}return null},remove(t,e){this.create(t,"",-1,e)}};var Dse={name:"cookie",lookup(t){let{lookupCookie:e}=t;if(e&&typeof document<"u")return dz.read(e)||void 0},cacheUserLanguage(t,e){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=e;n&&typeof document<"u"&&dz.create(n,t,r,i,a)}},Rse={name:"querystring",lookup(t){let{lookupQuerystring:e}=t,n;if(typeof window<"u"){let{search:r}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));const a=r.substring(1).split("&");for(let o=0;o<a.length;o++){const l=a[o].indexOf("=");l>0&&a[o].substring(0,l)===e&&(n=a[o].substring(l+1))}}return n}},Ose={name:"hash",lookup(t){let{lookupHash:e,lookupFromHashIndex:n}=t,r;if(typeof window<"u"){const{hash:i}=window.location;if(i&&i.length>2){const a=i.substring(1);if(e){const o=a.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 pp=null;const hz=()=>{if(pp!==null)return pp;try{if(pp=typeof window<"u"&&window.localStorage!==null,!pp)return!1;const t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{pp=!1}return pp};var Lse={name:"localStorage",lookup(t){let{lookupLocalStorage:e}=t;if(e&&hz())return window.localStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupLocalStorage:n}=e;n&&hz()&&window.localStorage.setItem(n,t)}};let gp=null;const fz=()=>{if(gp!==null)return gp;try{if(gp=typeof window<"u"&&window.sessionStorage!==null,!gp)return!1;const t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{gp=!1}return gp};var Fse={name:"sessionStorage",lookup(t){let{lookupSessionStorage:e}=t;if(e&&fz())return window.sessionStorage.getItem(e)||void 0},cacheUserLanguage(t,e){let{lookupSessionStorage:n}=e;n&&fz()&&window.sessionStorage.setItem(n,t)}},Ise={name:"navigator",lookup(t){const e=[];if(typeof navigator<"u"){const{languages:n,userLanguage:r,language:i}=navigator;if(n)for(let a=0;a<n.length;a++)e.push(n[a]);r&&e.push(r),i&&e.push(i)}return e.length>0?e:void 0}},Use={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}},zse={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}},Bse={name:"subdomain",lookup(t){let{lookupFromSubdomainIndex:e}=t;const n=typeof e=="number"?e+1:1,r=typeof window<"u"&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[n]}};let Pq=!1;try{document.cookie,Pq=!0}catch{}const jq=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];Pq||jq.splice(1,1);const Hse=()=>({order:jq,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:t=>t});class Dq{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=Cse(n,this.options||{},Hse()),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(Dse),this.addDetector(Rse),this.addDetector(Lse),this.addDetector(Fse),this.addDetector(Ise),this.addDetector(Use),this.addDetector(zse),this.addDetector(Bse),this.addDetector(Ose)}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&&!Pse(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)}))}}Dq.type="languageDetector";const $se={nav:{printers:"Printers",archives:"Archives",queue:"Queue",stats:"Statistics",profiles:"Profiles",maintenance:"Maintenance",projects:"Projects",files:"File Manager",settings:"Settings",system:"System",collapseSidebar:"Collapse sidebar",expandSidebar:"Expand sidebar",update:"Update",updateAvailable:"Update available: v{{version}}",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)"}},Vse={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)"}},Gse={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:"バックアップの復元が完了しました"}},qse={en:{translation:$se},de:{translation:Vse},ja:{translation:Gse}};_s.use(Dq).use(wse).init({resources:qse,fallbackLng:"en",supportedLngs:["en","de","ja"],detection:{order:["localStorage","navigator","htmlTag"],lookupLocalStorage:"bambutrack_language",caches:["localStorage"]},interpolation:{escapeValue:!1},react:{useSuspense:!1}});const mz=[{code:"en",name:"English",nativeName:"English"},{code:"de",name:"German",nativeName:"Deutsch"},{code:"ja",name:"Japanese",nativeName:"日本語"}];var pz="popstate";function Wse(t={}){function e(r,i){let{pathname:a,search:o,hash:l}=r.location;return ej("",{pathname:a,search:o,hash:l},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:H0(i)}return Xse(e,n,null,t)}function ri(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function xo(t,e){if(!t){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function Kse(){return Math.random().toString(36).substring(2,10)}function gz(t,e){return{usr:t.state,key:t.key,idx:e}}function ej(t,e,n=null,r){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof e=="string"?gx(e):e,state:n,key:e&&e.key||r||Kse()}}function H0({pathname:t="/",search:e="",hash:n=""}){return e&&e!=="?"&&(t+=e.charAt(0)==="?"?e:"?"+e),n&&n!=="#"&&(t+=n.charAt(0)==="#"?n:"#"+n),t}function gx(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 Xse(t,e,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,l="POP",c=null,u=d();u==null&&(u=0,o.replaceState({...o.state,idx:u},""));function d(){return(o.state||{idx:null}).idx}function f(){l="POP";let v=d(),y=v==null?null:v-u;u=v,c&&c({action:l,location:b.location,delta:y})}function p(v,y){l="PUSH";let S=ej(b.location,v,y);u=d()+1;let k=gz(S,u),T=b.createHref(S);try{o.pushState(k,"",T)}catch(M){if(M instanceof DOMException&&M.name==="DataCloneError")throw M;i.location.assign(T)}a&&c&&c({action:l,location:b.location,delta:1})}function m(v,y){l="REPLACE";let S=ej(b.location,v,y);u=d();let k=gz(S,u),T=b.createHref(S);o.replaceState(k,"",T),a&&c&&c({action:l,location:b.location,delta:0})}function x(v){return Yse(v)}let b={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(pz,f),c=v,()=>{i.removeEventListener(pz,f),c=null}},createHref(v){return e(i,v)},createURL:x,encodeLocation(v){let y=x(v);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:p,replace:m,go(v){return o.go(v)}};return b}function Yse(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:H0(t);return r=r.replace(/ $/,"%20"),!e&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Rq(t,e,n="/"){return Qse(t,e,n,!1)}function Qse(t,e,n,r){let i=typeof e=="string"?gx(e):e,a=Ru(i.pathname||"/",n);if(a==null)return null;let o=Oq(t);Zse(o);let l=null;for(let c=0;l==null&&c<o.length;++c){let u=coe(a);l=ooe(o[c],u,r)}return l}function Oq(t,e=[],n=[],r="",i=!1){let a=(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 f=Mu([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 "${f}".`),Oq(o.children,e,p,f,c)),!(o.path==null&&!o.index)&&e.push({path:f,score:aoe(f,o.index),routesMeta:p})};return t.forEach((o,l)=>{if(o.path===""||!o.path?.includes("?"))a(o,l);else for(let c of Lq(o.path))a(o,l,!0,c)}),e}function Lq(t){let e=t.split("/");if(e.length===0)return[];let[n,...r]=e,i=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return i?[a,""]:[a];let o=Lq(r.join("/")),l=[];return l.push(...o.map(c=>c===""?a:[a,c].join("/"))),i&&l.push(...o),l.map(c=>t.startsWith("/")&&c===""?"/":c)}function Zse(t){t.sort((e,n)=>e.score!==n.score?n.score-e.score:soe(e.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var Jse=/^:[\w-]+$/,eoe=3,toe=2,noe=1,roe=10,ioe=-2,xz=t=>t==="*";function aoe(t,e){let n=t.split("/"),r=n.length;return n.some(xz)&&(r+=ioe),e&&(r+=toe),n.filter(i=>!xz(i)).reduce((i,a)=>i+(Jse.test(a)?eoe:a===""?noe:roe),r)}function soe(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 ooe(t,e,n=!1){let{routesMeta:r}=t,i={},a="/",o=[];for(let l=0;l<r.length;++l){let c=r[l],u=l===r.length-1,d=a==="/"?e:e.slice(a.length)||"/",f=$1({path:c.relativePath,caseSensitive:c.caseSensitive,end:u},d),p=c.route;if(!f&&u&&n&&!r[r.length-1].route.index&&(f=$1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},d)),!f)return null;Object.assign(i,f.params),o.push({params:i,pathname:Mu([a,f.pathname]),pathnameBase:foe(Mu([a,f.pathnameBase])),route:p}),f.pathnameBase!=="/"&&(a=Mu([a,f.pathnameBase]))}return o}function $1(t,e){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[n,r]=loe(t.path,t.caseSensitive,t.end),i=e.match(n);if(!i)return null;let a=i[0],o=a.replace(/(.)\/+$/,"$1"),l=i.slice(1);return{params:r.reduce((u,{paramName:d,isOptional:f},p)=>{if(d==="*"){let x=l[p]||"";o=a.slice(0,a.length-x.length).replace(/(.)\/+$/,"$1")}const m=l[p];return f&&!m?u[d]=void 0:u[d]=(m||"").replace(/%2F/g,"/"),u},{}),pathname:a,pathnameBase:o,pattern:t}}function loe(t,e=!1,n=!0){xo(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 coe(t){try{return t.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return xo(!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 Ru(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 Fq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,uoe=t=>Fq.test(t);function doe(t,e="/"){let{pathname:n,search:r="",hash:i=""}=typeof t=="string"?gx(t):t,a;if(n)if(uoe(n))a=n;else{if(n.includes("//")){let o=n;n=n.replace(/\/\/+/g,"/"),xo(!1,`Pathnames cannot have embedded double slashes - normalizing ${o} -> ${n}`)}n.startsWith("/")?a=bz(n.substring(1),"/"):a=bz(n,e)}else a=e;return{pathname:a,search:moe(r),hash:poe(i)}}function bz(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 YE(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 hoe(t){return t.filter((e,n)=>n===0||e.route.path&&e.route.path.length>0)}function mR(t){let e=hoe(t);return e.map((n,r)=>r===e.length-1?n.pathname:n.pathnameBase)}function pR(t,e,n,r=!1){let i;typeof t=="string"?i=gx(t):(i={...t},ri(!i.pathname||!i.pathname.includes("?"),YE("?","pathname","search",i)),ri(!i.pathname||!i.pathname.includes("#"),YE("#","pathname","hash",i)),ri(!i.search||!i.search.includes("#"),YE("#","search","hash",i)));let a=t===""||i.pathname==="",o=a?"/":i.pathname,l;if(o==null)l=n;else{let f=e.length-1;if(!r&&o.startsWith("..")){let p=o.split("/");for(;p[0]==="..";)p.shift(),f-=1;i.pathname=p.join("/")}l=f>=0?e[f]:"/"}let c=doe(i,l),u=o&&o!=="/"&&o.endsWith("/"),d=(a||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}var Mu=t=>t.join("/").replace(/\/\/+/g,"/"),foe=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),moe=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,poe=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,goe=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 xoe(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function boe(t){return t.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var Iq=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Uq(t,e){let n=t;if(typeof n!="string"||!Fq.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Iq)try{let a=new URL(window.location.href),o=n.startsWith("//")?new URL(a.protocol+n):new URL(n),l=Ru(o.pathname,e);o.origin===a.origin&&l!=null?n=l+o.search+o.hash:i=!0}catch{xo(!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 zq=["POST","PUT","PATCH","DELETE"];new Set(zq);var yoe=["GET",...zq];new Set(yoe);var xx=_.createContext(null);xx.displayName="DataRouter";var rM=_.createContext(null);rM.displayName="DataRouterState";var voe=_.createContext(!1),Bq=_.createContext({isTransitioning:!1});Bq.displayName="ViewTransition";var woe=_.createContext(new Map);woe.displayName="Fetchers";var _oe=_.createContext(null);_oe.displayName="Await";var wo=_.createContext(null);wo.displayName="Navigation";var Oy=_.createContext(null);Oy.displayName="Location";var fl=_.createContext({outlet:null,matches:[],isDataRoute:!1});fl.displayName="Route";var gR=_.createContext(null);gR.displayName="RouteError";var Hq="REACT_ROUTER_ERROR",Soe="REDIRECT",Noe="ROUTE_ERROR_RESPONSE";function Moe(t){if(t.startsWith(`${Hq}:${Soe}:{`))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 koe(t){if(t.startsWith(`${Hq}:${Noe}:{`))try{let e=JSON.parse(t.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new goe(e.status,e.statusText,e.data)}catch{}}function Eoe(t,{relative:e}={}){ri(bx(),"useHref() may be used only in the context of a <Router> component.");let{basename:n,navigator:r}=_.useContext(wo),{hash:i,pathname:a,search:o}=Ly(t,{relative:e}),l=a;return n!=="/"&&(l=a==="/"?n:Mu([n,a])),r.createHref({pathname:l,search:o,hash:i})}function bx(){return _.useContext(Oy)!=null}function Mc(){return ri(bx(),"useLocation() may be used only in the context of a <Router> component."),_.useContext(Oy).location}var $q="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Vq(t){_.useContext(wo).static||_.useLayoutEffect(t)}function kc(){let{isDataRoute:t}=_.useContext(fl);return t?Hoe():Toe()}function Toe(){ri(bx(),"useNavigate() may be used only in the context of a <Router> component.");let t=_.useContext(xx),{basename:e,navigator:n}=_.useContext(wo),{matches:r}=_.useContext(fl),{pathname:i}=Mc(),a=JSON.stringify(mR(r)),o=_.useRef(!1);return Vq(()=>{o.current=!0}),_.useCallback((c,u={})=>{if(xo(o.current,$q),!o.current)return;if(typeof c=="number"){n.go(c);return}let d=pR(c,JSON.parse(a),i,u.relative==="path");t==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:Mu([e,d.pathname])),(u.replace?n.replace:n.push)(d,u.state,u)},[e,n,a,i,t])}var Aoe=_.createContext(null);function Coe(t){let e=_.useContext(fl).outlet;return _.useMemo(()=>e&&_.createElement(Aoe.Provider,{value:t},e),[e,t])}function iM(){let{matches:t}=_.useContext(fl),e=t[t.length-1];return e?e.params:{}}function Ly(t,{relative:e}={}){let{matches:n}=_.useContext(fl),{pathname:r}=Mc(),i=JSON.stringify(mR(n));return _.useMemo(()=>pR(t,JSON.parse(i),r,e==="path"),[t,i,r,e])}function Poe(t,e){return Gq(t,e)}function Gq(t,e,n,r,i){ri(bx(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:a}=_.useContext(wo),{matches:o}=_.useContext(fl),l=o[o.length-1],c=l?l.params:{},u=l?l.pathname:"/",d=l?l.pathnameBase:"/",f=l&&l.route;{let S=f&&f.path||"";Wq(u,!f||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.
- Please change the parent <Route path="${S}"> to <Route path="${S==="/"?"*":`${S}/*`}">.`)}let p=Mc(),m;if(e){let S=typeof e=="string"?gx(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||"/",b=x;if(d!=="/"){let S=d.replace(/^\//,"").split("/");b="/"+x.replace(/^\//,"").split("/").slice(S.length).join("/")}let v=Rq(t,{pathname:b});xo(f||v!=null,`No routes matched location "${m.pathname}${m.search}${m.hash}" `),xo(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 y=Loe(v&&v.map(S=>Object.assign({},S,{params:Object.assign({},c,S.params),pathname:Mu([d,a.encodeLocation?a.encodeLocation(S.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?d:Mu([d,a.encodeLocation?a.encodeLocation(S.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:S.pathnameBase])})),o,n,r,i);return e&&y?_.createElement(Oy.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...m},navigationType:"POP"}},y):y}function joe(){let t=Boe(),e=xoe(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),n=t instanceof Error?t.stack:null,r="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:r},a={padding:"2px 4px",backgroundColor:r},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:a},"ErrorBoundary")," or"," ",_.createElement("code",{style:a},"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 Doe=_.createElement(joe,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=koe(t.digest);n&&(t=n)}let e=t!==void 0?_.createElement(fl.Provider,{value:this.props.routeContext},_.createElement(gR.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?_.createElement(Roe,{error:t},e):e}};qq.contextType=voe;var QE=new WeakMap;function Roe({children:t,error:e}){let{basename:n}=_.useContext(wo);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let r=Moe(e.digest);if(r){let i=QE.get(e);if(i)throw i;let a=Uq(r.location,n);if(Iq&&!QE.get(e))if(a.isExternal||r.reloadDocument)window.location.href=a.absoluteURL||a.to;else{const o=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:r.replace}));throw QE.set(e,o),o}return _.createElement("meta",{httpEquiv:"refresh",content:`0;url=${a.absoluteURL||a.to}`})}}return t}function Ooe({routeContext:t,match:e,children:n}){let r=_.useContext(xx);return r&&r.static&&r.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=e.route.id),_.createElement(fl.Provider,{value:t},n)}function Loe(t,e=[],n=null,r=null,i=null){if(t==null){if(!n)return null;if(n.errors)t=n.matches;else if(e.length===0&&!n.initialized&&n.matches.length>0)t=n.matches;else return null}let a=t,o=n?.errors;if(o!=null){let d=a.findIndex(f=>f.route.id&&o?.[f.route.id]!==void 0);ri(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),a=a.slice(0,Math.min(a.length,d+1))}let l=!1,c=-1;if(n)for(let d=0;d<a.length;d++){let f=a[d];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(c=d),f.route.id){let{loaderData:p,errors:m}=n,x=f.route.loader&&!p.hasOwnProperty(f.route.id)&&(!m||m[f.route.id]===void 0);if(f.route.lazy||x){l=!0,c>=0?a=a.slice(0,c+1):a=[a[0]];break}}}let u=n&&r?(d,f)=>{r(d,{location:n.location,params:n.matches?.[0]?.params??{},unstable_pattern:boe(n.matches),errorInfo:f})}:void 0;return a.reduceRight((d,f,p)=>{let m,x=!1,b=null,v=null;n&&(m=o&&f.route.id?o[f.route.id]:void 0,b=f.route.errorElement||Doe,l&&(c<0&&p===0?(Wq("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),x=!0,v=null):c===p&&(x=!0,v=f.route.hydrateFallbackElement||null)));let y=e.concat(a.slice(0,p+1)),S=()=>{let k;return m?k=b:x?k=v:f.route.Component?k=_.createElement(f.route.Component,null):f.route.element?k=f.route.element:k=d,_.createElement(Ooe,{match:f,routeContext:{outlet:d,matches:y,isDataRoute:n!=null},children:k})};return n&&(f.route.ErrorBoundary||f.route.errorElement||p===0)?_.createElement(qq,{location:n.location,revalidation:n.revalidation,component:b,error:m,children:S(),routeContext:{outlet:null,matches:y,isDataRoute:!0},onError:u}):S()},null)}function xR(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Foe(t){let e=_.useContext(xx);return ri(e,xR(t)),e}function Ioe(t){let e=_.useContext(rM);return ri(e,xR(t)),e}function Uoe(t){let e=_.useContext(fl);return ri(e,xR(t)),e}function bR(t){let e=Uoe(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 zoe(){return bR("useRouteId")}function Boe(){let t=_.useContext(gR),e=Ioe("useRouteError"),n=bR("useRouteError");return t!==void 0?t:e.errors?.[n]}function Hoe(){let{router:t}=Foe("useNavigate"),e=bR("useNavigate"),n=_.useRef(!1);return Vq(()=>{n.current=!0}),_.useCallback(async(i,a={})=>{xo(n.current,$q),n.current&&(typeof i=="number"?await t.navigate(i):await t.navigate(i,{fromRouteId:e,...a}))},[t,e])}var yz={};function Wq(t,e,n){!e&&!yz[t]&&(yz[t]=!0,xo(!1,n))}_.memo($oe);function $oe({routes:t,future:e,state:n,onError:r}){return Gq(t,void 0,n,r,e)}function Fg({to:t,replace:e,state:n,relative:r}){ri(bx(),"<Navigate> may be used only in the context of a <Router> component.");let{static:i}=_.useContext(wo);xo(!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:a}=_.useContext(fl),{pathname:o}=Mc(),l=kc(),c=pR(t,mR(a),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 Voe(t){return Coe(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 Goe({basename:t="/",children:e=null,location:n,navigationType:r="POP",navigator:i,static:a=!1,unstable_useTransitions:o}){ri(!bx(),"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:a,unstable_useTransitions:o,future:{}}),[l,i,a,o]);typeof n=="string"&&(n=gx(n));let{pathname:u="/",search:d="",hash:f="",state:p=null,key:m="default"}=n,x=_.useMemo(()=>{let b=Ru(u,l);return b==null?null:{location:{pathname:b,search:d,hash:f,state:p,key:m},navigationType:r}},[l,u,d,f,p,m,r]);return xo(x!=null,`<Router basename="${l}"> is not able to match the URL "${u}${d}${f}" because it does not start with the basename, so the <Router> won't render anything.`),x==null?null:_.createElement(wo.Provider,{value:c},_.createElement(Oy.Provider,{children:e,value:x}))}function qoe({children:t,location:e}){return Poe(tj(t),e)}function tj(t,e=[]){let n=[];return _.Children.forEach(t,(r,i)=>{if(!_.isValidElement(r))return;let a=[...e,i];if(r.type===_.Fragment){n.push.apply(n,tj(r.props.children,a));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||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(o.children=tj(r.props.children,a)),n.push(o)}),n}var m1="get",p1="application/x-www-form-urlencoded";function aM(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Woe(t){return aM(t)&&t.tagName.toLowerCase()==="button"}function Koe(t){return aM(t)&&t.tagName.toLowerCase()==="form"}function Xoe(t){return aM(t)&&t.tagName.toLowerCase()==="input"}function Yoe(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Qoe(t,e){return t.button===0&&(!e||e==="_self")&&!Yoe(t)}function nj(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 Zoe(t,e){let n=nj(t);return e&&e.forEach((r,i)=>{n.has(i)||e.getAll(i).forEach(a=>{n.append(i,a)})}),n}var jw=null;function Joe(){if(jw===null)try{new FormData(document.createElement("form"),0),jw=!1}catch{jw=!0}return jw}var ele=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function ZE(t){return t!=null&&!ele.has(t)?(xo(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${p1}"`),null):t}function tle(t,e){let n,r,i,a,o;if(Koe(t)){let l=t.getAttribute("action");r=l?Ru(l,e):null,n=t.getAttribute("method")||m1,i=ZE(t.getAttribute("enctype"))||p1,a=new FormData(t)}else if(Woe(t)||Xoe(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?Ru(c,e):null,n=t.getAttribute("formmethod")||l.getAttribute("method")||m1,i=ZE(t.getAttribute("formenctype"))||ZE(l.getAttribute("enctype"))||p1,a=new FormData(l,t),!Joe()){let{name:u,type:d,value:f}=t;if(d==="image"){let p=u?`${u}.`:"";a.append(`${p}x`,"0"),a.append(`${p}y`,"0")}else u&&a.append(u,f)}}else{if(aM(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');n=m1,r=null,i=p1,o=t}return a&&i==="text/plain"&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function yR(t,e){if(t===!1||t===null||typeof t>"u")throw new Error(e)}function nle(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&&Ru(i.pathname,e)==="/"?i.pathname=`${e.replace(/\/$/,"")}/_root.${r}`:i.pathname=`${i.pathname.replace(/\/$/,"")}.${r}`,i}async function rle(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 ile(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 ale(t,e,n){let r=await Promise.all(t.map(async i=>{let a=e.routes[i.route.id];if(a){let o=await rle(a,n);return o.links?o.links():[]}return[]}));return cle(r.flat(1).filter(ile).filter(i=>i.rel==="stylesheet"||i.rel==="preload").map(i=>i.rel==="stylesheet"?{...i,rel:"prefetch",as:"style"}:{...i,rel:"prefetch"}))}function vz(t,e,n,r,i,a){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 a==="assets"?e.filter((c,u)=>o(c,u)||l(c,u)):a==="data"?e.filter((c,u)=>{let d=r.routes[c.route.id];if(!d||!d.hasLoader)return!1;if(o(c,u)||l(c,u))return!0;if(c.route.shouldRevalidate){let f=c.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(t,window.origin),nextParams:c.params,defaultShouldRevalidate:!0});if(typeof f=="boolean")return f}return!0}):[]}function sle(t,e,{includeHydrateFallback:n}={}){return ole(t.map(r=>{let i=e.routes[r.route.id];if(!i)return[];let a=[i.module];return i.clientActionModule&&(a=a.concat(i.clientActionModule)),i.clientLoaderModule&&(a=a.concat(i.clientLoaderModule)),n&&i.hydrateFallbackModule&&(a=a.concat(i.hydrateFallbackModule)),i.imports&&(a=a.concat(i.imports)),a}).flat(1))}function ole(t){return[...new Set(t)]}function lle(t){let e={},n=Object.keys(t).sort();for(let r of n)e[r]=t[r];return e}function cle(t,e){let n=new Set;return new Set(e),t.reduce((r,i)=>{let a=JSON.stringify(lle(i));return n.has(a)||(n.add(a),r.push({key:a,link:i})),r},[])}function Kq(){let t=_.useContext(xx);return yR(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function ule(){let t=_.useContext(rM);return yR(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var vR=_.createContext(void 0);vR.displayName="FrameworkContext";function Xq(){let t=_.useContext(vR);return yR(t,"You must render this element inside a <HydratedRouter> element"),t}function dle(t,e){let n=_.useContext(vR),[r,i]=_.useState(!1),[a,o]=_.useState(!1),{onFocus:l,onBlur:c,onMouseEnter:u,onMouseLeave:d,onTouchStart:f}=e,p=_.useRef(null);_.useEffect(()=>{if(t==="render"&&o(!0),t==="viewport"){let b=y=>{y.forEach(S=>{o(S.isIntersecting)})},v=new IntersectionObserver(b,{threshold:.5});return p.current&&v.observe(p.current),()=>{v.disconnect()}}},[t]),_.useEffect(()=>{if(r){let b=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(b)}}},[r]);let m=()=>{i(!0)},x=()=>{i(!1),o(!1)};return n?t!=="intent"?[a,p,{}]:[a,p,{onFocus:Cb(l,m),onBlur:Cb(c,x),onMouseEnter:Cb(u,m),onMouseLeave:Cb(d,x),onTouchStart:Cb(f,m)}]:[!1,p,{}]}function Cb(t,e){return n=>{t&&t(n),n.defaultPrevented||e(n)}}function hle({page:t,...e}){let{router:n}=Kq(),r=_.useMemo(()=>Rq(n.routes,t,n.basename),[n.routes,t,n.basename]);return r?_.createElement(mle,{page:t,matches:r,...e}):null}function fle(t){let{manifest:e,routeModules:n}=Xq(),[r,i]=_.useState([]);return _.useEffect(()=>{let a=!1;return ale(t,e,n).then(o=>{a||i(o)}),()=>{a=!0}},[t,e,n]),r}function mle({page:t,matches:e,...n}){let r=Mc(),{future:i,manifest:a,routeModules:o}=Xq(),{basename:l}=Kq(),{loaderData:c,matches:u}=ule(),d=_.useMemo(()=>vz(t,e,u,a,r,"data"),[t,e,u,a,r]),f=_.useMemo(()=>vz(t,e,u,a,r,"assets"),[t,e,u,a,r]),p=_.useMemo(()=>{if(t===r.pathname+r.search+r.hash)return[];let b=new Set,v=!1;if(e.forEach(S=>{let k=a.routes[S.route.id];!k||!k.hasLoader||(!d.some(T=>T.route.id===S.route.id)&&S.route.id in c&&o[S.route.id]?.shouldRevalidate||k.hasClientLoader?v=!0:b.add(S.route.id))}),b.size===0)return[];let y=nle(t,l,i.unstable_trailingSlashAwareDataRequests,"data");return v&&b.size>0&&y.searchParams.set("_routes",e.filter(S=>b.has(S.route.id)).map(S=>S.route.id).join(",")),[y.pathname+y.search]},[l,i.unstable_trailingSlashAwareDataRequests,c,r,a,d,e,t,o]),m=_.useMemo(()=>sle(f,a),[f,a]),x=fle(f);return _.createElement(_.Fragment,null,p.map(b=>_.createElement("link",{key:b,rel:"prefetch",as:"fetch",href:b,...n})),m.map(b=>_.createElement("link",{key:b,rel:"modulepreload",href:b,...n})),x.map(({key:b,link:v})=>_.createElement("link",{key:b,nonce:n.nonce,...v})))}function ple(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}var gle=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{gle&&(window.__reactRouterVersion="7.12.0")}catch{}function xle({basename:t,children:e,unstable_useTransitions:n,window:r}){let i=_.useRef();i.current==null&&(i.current=Wse({window:r,v5Compat:!0}));let a=i.current,[o,l]=_.useState({action:a.action,location:a.location}),c=_.useCallback(u=>{n===!1?l(u):_.startTransition(()=>l(u))},[n]);return _.useLayoutEffect(()=>a.listen(c),[a,c]),_.createElement(Goe,{basename:t,children:e,location:o.location,navigationType:o.action,navigator:a,unstable_useTransitions:n})}var Yq=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ds=_.forwardRef(function({onClick:e,discover:n="render",prefetch:r="none",relative:i,reloadDocument:a,replace:o,state:l,target:c,to:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:p,...m},x){let{basename:b,unstable_useTransitions:v}=_.useContext(wo),y=typeof u=="string"&&Yq.test(u),S=Uq(u,b);u=S.to;let k=Eoe(u,{relative:i}),[T,M,C]=dle(r,m),E=vle(u,{replace:o,state:l,target:c,preventScrollReset:d,relative:i,viewTransition:f,unstable_defaultShouldRevalidate:p,unstable_useTransitions:v});function R(D){e&&e(D),D.defaultPrevented||E(D)}let A=_.createElement("a",{...m,...C,href:S.absoluteURL||k,onClick:S.isExternal||a?e:R,ref:ple(x,M),target:c,"data-discover":!y&&n==="render"?"true":void 0});return T&&!y?_.createElement(_.Fragment,null,A,_.createElement(hle,{page:k})):A});Ds.displayName="Link";var n0=_.forwardRef(function({"aria-current":e="page",caseSensitive:n=!1,className:r="",end:i=!1,style:a,to:o,viewTransition:l,children:c,...u},d){let f=Ly(o,{relative:u.relative}),p=Mc(),m=_.useContext(rM),{navigator:x,basename:b}=_.useContext(wo),v=m!=null&&Mle(f)&&l===!0,y=x.encodeLocation?x.encodeLocation(f).pathname:f.pathname,S=p.pathname,k=m&&m.navigation&&m.navigation.location?m.navigation.location.pathname:null;n||(S=S.toLowerCase(),k=k?k.toLowerCase():null,y=y.toLowerCase()),k&&b&&(k=Ru(k,b)||k);const T=y!=="/"&&y.endsWith("/")?y.length-1:y.length;let M=S===y||!i&&S.startsWith(y)&&S.charAt(T)==="/",C=k!=null&&(k===y||!i&&k.startsWith(y)&&k.charAt(y.length)==="/"),E={isActive:M,isPending:C,isTransitioning:v},R=M?e:void 0,A;typeof r=="function"?A=r(E):A=[r,M?"active":null,C?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let D=typeof a=="function"?a(E):a;return _.createElement(Ds,{...u,"aria-current":R,className:A,ref:d,style:D,to:o,viewTransition:l},typeof c=="function"?c(E):c)});n0.displayName="NavLink";var ble=_.forwardRef(({discover:t="render",fetcherKey:e,navigate:n,reloadDocument:r,replace:i,state:a,method:o=m1,action:l,onSubmit:c,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:p,...m},x)=>{let{unstable_useTransitions:b}=_.useContext(wo),v=Sle(),y=Nle(l,{relative:u}),S=o.toLowerCase()==="get"?"get":"post",k=typeof l=="string"&&Yq.test(l),T=M=>{if(c&&c(M),M.defaultPrevented)return;M.preventDefault();let C=M.nativeEvent.submitter,E=C?.getAttribute("formmethod")||o,R=()=>v(C||M.currentTarget,{fetcherKey:e,method:E,navigate:n,replace:i,state:a,relative:u,preventScrollReset:d,viewTransition:f,unstable_defaultShouldRevalidate:p});b&&n!==!1?_.startTransition(()=>R()):R()};return _.createElement("form",{ref:x,method:S,action:y,onSubmit:r?c:T,...m,"data-discover":!k&&t==="render"?"true":void 0})});ble.displayName="Form";function yle(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Qq(t){let e=_.useContext(xx);return ri(e,yle(t)),e}function vle(t,{target:e,replace:n,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:l,unstable_useTransitions:c}={}){let u=kc(),d=Mc(),f=Ly(t,{relative:a});return _.useCallback(p=>{if(Qoe(p,e)){p.preventDefault();let m=n!==void 0?n:H0(d)===H0(f),x=()=>u(t,{replace:m,state:r,preventScrollReset:i,relative:a,viewTransition:o,unstable_defaultShouldRevalidate:l});c?_.startTransition(()=>x()):x()}},[d,u,f,n,r,e,t,i,a,o,l,c])}function wR(t){xo(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(nj(t)),n=_.useRef(!1),r=Mc(),i=_.useMemo(()=>Zoe(r.search,n.current?null:e.current),[r.search]),a=kc(),o=_.useCallback((l,c)=>{const u=nj(typeof l=="function"?l(new URLSearchParams(i)):l);n.current=!0,a("?"+u,c)},[a,i]);return[i,o]}var wle=0,_le=()=>`__${String(++wle)}__`;function Sle(){let{router:t}=Qq("useSubmit"),{basename:e}=_.useContext(wo),n=zoe(),r=t.fetch,i=t.navigate;return _.useCallback(async(a,o={})=>{let{action:l,method:c,encType:u,formData:d,body:f}=tle(a,e);if(o.navigate===!1){let p=o.fetcherKey||_le();await r(p,n,o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:f,formMethod:o.method||c,formEncType:o.encType||u,flushSync:o.flushSync})}else await i(o.action||l,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:f,formMethod:o.method||c,formEncType:o.encType||u,replace:o.replace,state:o.state,fromRouteId:n,flushSync:o.flushSync,viewTransition:o.viewTransition})},[r,i,e,n])}function Nle(t,{relative:e}={}){let{basename:n}=_.useContext(wo),r=_.useContext(fl);ri(r,"useFormAction must be used inside a RouteContext");let[i]=r.matches.slice(-1),a={...Ly(t||".",{relative:e})},o=Mc();if(t==null){a.search=o.search;let l=new URLSearchParams(a.search),c=l.getAll("index");if(c.some(d=>d==="")){l.delete("index"),c.filter(f=>f).forEach(f=>l.append("index",f));let d=l.toString();a.search=d?`?${d}`:""}}return(!t||t===".")&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,"?index&"):"?index"),n!=="/"&&(a.pathname=a.pathname==="/"?n:Mu([n,a.pathname])),H0(a)}function Mle(t,{relative:e}={}){let n=_.useContext(Bq);ri(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Qq("useViewTransitionState"),i=Ly(t,{relative:e});if(!n.isTransitioning)return!1;let a=Ru(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Ru(n.nextLocation.pathname,r)||n.nextLocation.pathname;return $1(i.pathname,o)!=null||$1(i.pathname,a)!=null}var xu=Sq();const kle=hl(xu);var km=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(){}},Ele={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Tle=class{#t=Ele;#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)}},Pf=new Tle;function Ale(t){setTimeout(t,0)}var tm=typeof window>"u"||"Deno"in globalThis;function Ya(){}function Cle(t,e){return typeof t=="function"?t(e):t}function rj(t){return typeof t=="number"&&t>=0&&t!==1/0}function Zq(t,e){return Math.max(t+(e||0)-Date.now(),0)}function rh(t,e){return typeof t=="function"?t(e):t}function Ho(t,e){return typeof t=="function"?t(e):t}function wz(t,e){const{type:n="all",exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:l}=t;if(o){if(r){if(e.queryHash!==_R(o,e.options))return!1}else if(!$0(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||a&&!a(e))}function _z(t,e){const{exact:n,status:r,predicate:i,mutationKey:a}=t;if(a){if(!e.options.mutationKey)return!1;if(n){if(nm(e.options.mutationKey)!==nm(a))return!1}else if(!$0(e.options.mutationKey,a))return!1}return!(r&&e.state.status!==r||i&&!i(e))}function _R(t,e){return(e?.queryKeyHashFn||nm)(t)}function nm(t){return JSON.stringify(t,(e,n)=>ij(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function $0(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(n=>$0(t[n],e[n])):!1}var Ple=Object.prototype.hasOwnProperty;function SR(t,e){if(t===e)return t;const n=Sz(t)&&Sz(e);if(!n&&!(ij(t)&&ij(e)))return e;const i=(n?t:Object.keys(t)).length,a=n?e:Object.keys(e),o=a.length,l=n?new Array(o):{};let c=0;for(let u=0;u<o;u++){const d=n?u:a[u],f=t[d],p=e[d];if(f===p){l[d]=f,(n?u<i:Ple.call(t,d))&&c++;continue}if(f===null||p===null||typeof f!="object"||typeof p!="object"){l[d]=p;continue}const m=SR(f,p);l[d]=m,m===f&&c++}return i===o&&c===i?t:l}function V0(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 Sz(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function ij(t){if(!Nz(t))return!1;const e=t.constructor;if(e===void 0)return!0;const n=e.prototype;return!(!Nz(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Nz(t){return Object.prototype.toString.call(t)==="[object Object]"}function jle(t){return new Promise(e=>{Pf.setTimeout(e,t)})}function aj(t,e,n){return typeof n.structuralSharing=="function"?n.structuralSharing(t,e):n.structuralSharing!==!1?SR(t,e):e}function Dle(t,e,n=0){const r=[...t,e];return n&&r.length>n?r.slice(1):r}function Rle(t,e,n=0){const r=[e,...t];return n&&r.length>n?r.slice(0,-1):r}var NR=Symbol();function Jq(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===NR?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function eW(t,e){return typeof t=="function"?t(...e):!!t}var Ole=class extends km{#t;#e;#n;constructor(){super(),this.#n=t=>{if(!tm&&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"}},MR=new Ole;function sj(){let t,e;const n=new Promise((i,a)=>{t=i,e=a});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),t(i)},n.reject=i=>{r({status:"rejected",reason:i}),e(i)},n}var Lle=Ale;function Fle(){let t=[],e=0,n=l=>{l()},r=l=>{l()},i=Lle;const a=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)=>{a(()=>{l(...c)})},schedule:a,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var yi=Fle(),Ile=class extends km{#t=!0;#e;#n;constructor(){super(),this.#n=t=>{if(!tm&&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}},V1=new Ile;function Ule(t){return Math.min(1e3*2**t,3e4)}function tW(t){return(t??"online")==="online"?V1.isOnline():!0}var oj=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function nW(t){let e=!1,n=0,r;const i=sj(),a=()=>i.status!=="pending",o=b=>{if(!a()){const v=new oj(b);p(v),t.onCancel?.(v)}},l=()=>{e=!0},c=()=>{e=!1},u=()=>MR.isFocused()&&(t.networkMode==="always"||V1.isOnline())&&t.canRun(),d=()=>tW(t.networkMode)&&t.canRun(),f=b=>{a()||(r?.(),i.resolve(b))},p=b=>{a()||(r?.(),i.reject(b))},m=()=>new Promise(b=>{r=v=>{(a()||u())&&b(v)},t.onPause?.()}).then(()=>{r=void 0,a()||t.onContinue?.()}),x=()=>{if(a())return;let b;const v=n===0?t.initialPromise:void 0;try{b=v??t.fn()}catch(y){b=Promise.reject(y)}Promise.resolve(b).then(f).catch(y=>{if(a())return;const S=t.retry??(tm?0:3),k=t.retryDelay??Ule,T=typeof k=="function"?k(n,y):k,M=S===!0||typeof S=="number"&&n<S||typeof S=="function"&&S(n,y);if(e||!M){p(y);return}n++,t.onFail?.(n,y),jle(T).then(()=>u()?void 0:m()).then(()=>{e?p(y):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 rW=class{#t;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),rj(this.gcTime)&&(this.#t=Pf.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(tm?1/0:300*1e3))}clearGcTimeout(){this.#t&&(Pf.clearTimeout(this.#t),this.#t=void 0)}},zle=class extends rW{#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=kz(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=kz(this.options);e.data!==void 0&&(this.setState(Mz(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#n.remove(this)}setData(t,e){const n=aj(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(Ya).catch(Ya):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#t)}isActive(){return this.observers.some(t=>Ho(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===NR||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>rh(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:!Zq(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=Jq(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=nW({initialPromise:e?.initialPromise,fn:o.fetchFn,onCancel:l=>{l instanceof oj&&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 oj){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,...iW(n.data,this.options),fetchMeta:t.meta??null};case"success":const r={...n,...Mz(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 iW(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:tW(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Mz(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function kz(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 kR=class extends km{constructor(t,e){super(),this.options=e,this.#t=t,this.#s=null,this.#o=sj(),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),Ez(this.#e,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return lj(this.#e,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return lj(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 Ho(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&&!V0(this.options,e)&&this.#t.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#e,observer:this});const r=this.hasListeners();r&&Tz(this.#e,n,this.options,e)&&this.#m(),this.updateResult(),r&&(this.#e!==n||Ho(this.options.enabled,this.#e)!==Ho(e.enabled,this.#e)||rh(this.options.staleTime,this.#e)!==rh(e.staleTime,this.#e))&&this.#g();const i=this.#x();r&&(this.#e!==n||Ho(this.options.enabled,this.#e)!==Ho(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 Hle(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(Ya)),e}#g(){this.#v();const t=rh(this.options.staleTime,this.#e);if(tm||this.#i.isStale||!rj(t))return;const n=Zq(this.#i.dataUpdatedAt,t)+1;this.#c=Pf.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,!(tm||Ho(this.options.enabled,this.#e)===!1||!rj(this.#l)||this.#l===0)&&(this.#u=Pf.setInterval(()=>{(this.options.refetchIntervalInBackground||MR.isFocused())&&this.#m()},this.#l))}#y(){this.#g(),this.#b(this.#x())}#v(){this.#c&&(Pf.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#u&&(Pf.clearInterval(this.#u),this.#u=void 0)}createResult(t,e){const n=this.#e,r=this.options,i=this.#i,a=this.#r,o=this.#a,c=t!==n?t.state:this.#n,{state:u}=t;let d={...u},f=!1,p;if(e._optimisticResults){const R=this.hasListeners(),A=!R&&Ez(t,e),D=R&&Tz(t,n,e,r);(A||D)&&(d={...d,...iW(u.data,t.options)}),e._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:m,errorUpdatedAt:x,status:b}=d;p=d.data;let v=!1;if(e.placeholderData!==void 0&&p===void 0&&b==="pending"){let R;i?.isPlaceholderData&&e.placeholderData===o?.placeholderData?(R=i.data,v=!0):R=typeof e.placeholderData=="function"?e.placeholderData(this.#h?.state.data,this.#h):e.placeholderData,R!==void 0&&(b="success",p=aj(i?.data,R,e),f=!0)}if(e.select&&p!==void 0&&!v)if(i&&p===a?.data&&e.select===this.#f)p=this.#d;else try{this.#f=e.select,p=e.select(p),p=aj(i?.data,p,e),this.#d=p,this.#s=null}catch(R){this.#s=R}this.#s&&(m=this.#s,p=this.#d,x=Date.now(),b="error");const y=d.fetchStatus==="fetching",S=b==="pending",k=b==="error",T=S&&y,M=p!==void 0,E={status:b,fetchStatus:d.fetchStatus,isPending:S,isSuccess:b==="success",isError:k,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:y,isRefetching:y&&!S,isLoadingError:k&&!M,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:k&&M,isStale:ER(t,e),refetch:this.refetch,promise:this.#o,isEnabled:Ho(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const R=I=>{E.status==="error"?I.reject(E.error):E.data!==void 0&&I.resolve(E.data)},A=()=>{const I=this.#o=E.promise=sj();R(I)},D=this.#o;switch(D.status){case"pending":t.queryHash===n.queryHash&&R(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),V0(e,t))return;this.#i=e;const n=()=>{if(!t)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#p.size)return!0;const a=new Set(i??this.#p);return this.options.throwOnError&&a.add("error"),Object.keys(this.#i).some(o=>{const l=o;return this.#i[l]!==t[l]&&a.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 Ble(t,e){return Ho(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function Ez(t,e){return Ble(t,e)||t.state.data!==void 0&&lj(t,e,e.refetchOnMount)}function lj(t,e,n){if(Ho(e.enabled,t)!==!1&&rh(e.staleTime,t)!=="static"){const r=typeof n=="function"?n(t):n;return r==="always"||r!==!1&&ER(t,e)}return!1}function Tz(t,e,n,r){return(t!==e||Ho(r.enabled,t)===!1)&&(!n.suspense||t.state.status!=="error")&&ER(t,n)}function ER(t,e){return Ho(e.enabled,t)!==!1&&t.isStaleByTime(rh(e.staleTime,t))}function Hle(t,e){return!V0(t.getCurrentResult(),e)}function Az(t){return{onFetch:(e,n)=>{const r=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,a=e.state.data?.pages||[],o=e.state.data?.pageParams||[];let l={pages:[],pageParams:[]},c=0;const u=async()=>{let d=!1;const f=x=>{Object.defineProperty(x,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},p=Jq(e.options,e.fetchOptions),m=async(x,b,v)=>{if(d)return Promise.reject();if(b==null&&x.pages.length)return Promise.resolve(x);const S=(()=>{const C={client:e.client,queryKey:e.queryKey,pageParam:b,direction:v?"backward":"forward",meta:e.options.meta};return f(C),C})(),k=await p(S),{maxPages:T}=e.options,M=v?Rle:Dle;return{pages:M(x.pages,k,T),pageParams:M(x.pageParams,b,T)}};if(i&&a.length){const x=i==="backward",b=x?$le:Cz,v={pages:a,pageParams:o},y=b(r,v);l=await m(v,y,x)}else{const x=t??a.length;do{const b=c===0?o[0]??r.initialPageParam:Cz(r,l);if(c>0&&b==null)break;l=await m(l,b),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 Cz(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 $le(t,{pages:e,pageParams:n}){return e.length>0?t.getPreviousPageParam?.(e[0],e,n[0],n):void 0}var Vle=class extends rW{#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||aW(),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=nW({fn:()=>this.options.mutationFn?this.options.mutationFn(t,n):Promise.reject(new Error("No mutationFn found")),onFail:(a,o)=>{this.#r({type:"failed",failureCount:a,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 a=await this.#i.start();return await this.#n.config.onSuccess?.(a,t,this.state.context,this,n),await this.options.onSuccess?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,t,this.state.context,n),this.#r({type:"success",data:a}),a}catch(a){try{throw await this.#n.config.onError?.(a,t,this.state.context,this,n),await this.options.onError?.(a,t,this.state.context,n),await this.#n.config.onSettled?.(void 0,a,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(void 0,a,t,this.state.context,n),a}finally{this.#r({type:"error",error:a})}}finally{this.#n.runNext(this)}}#r(t){const e=n=>{switch(t.type){case"failed":return{...n,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...n,isPaused:!0};case"continue":return{...n,isPaused:!1};case"pending":return{...n,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...n,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...n,data:void 0,error:t.error,failureCount:n.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=e(this.state),yi.batch(()=>{this.#e.forEach(n=>{n.onMutationUpdate(t)}),this.#n.notify({mutation:this,type:"updated",action:t})})}};function aW(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Gle=class extends km{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 Vle({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=Dw(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=Dw(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=Dw(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=Dw(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=>_z(e,n))}findAll(t={}){return this.getAll().filter(e=>_z(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(Ya))))}};function Dw(t){return t.options.scope?.id}var qle=class extends km{#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),V0(this.options,n)||this.#t.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#n,observer:this}),n?.mutationKey&&this.options.mutationKey&&nm(n.mutationKey)!==nm(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??aW();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 Pz(t,e){const n=new Set(e);return t.filter(r=>!n.has(r))}function Wle(t,e,n){const r=t.slice(0);return r[e]=n,r}var Kle=class extends km{#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),a=i.map(d=>d.getCurrentResult()),o=n.length!==i.length,l=i.some((d,f)=>d!==n[f]),c=o||l,u=c?!0:a.some((d,f)=>{const p=this.#e[f];return!p||!V0(d,p)});!c&&!u||(c&&(this.#r=i),this.#e=a,this.hasListeners()&&(c&&(Pz(n,i).forEach(d=>{d.destroy()}),Pz(i,n).forEach(d=>{d.subscribe(f=>{this.#u(d,f)})})),this.#l()))})}getCurrentResult(){return this.#e}getQueries(){return this.#r.map(t=>t.getCurrentQuery())}getObservers(){return this.#r}getOptimisticResult(t,e){const n=this.#c(t),r=n.map(i=>i.observer.getOptimisticResult(i.defaultedQueryOptions));return[r,i=>this.#h(i??r,e),()=>this.#d(r,n)]}#d(t,e){return e.map((n,r)=>{const i=t[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,a=>{e.forEach(o=>{o.observer.trackProp(a)})})})}#h(t,e){return e?((!this.#a||this.#e!==this.#s||e!==this.#o)&&(this.#o=e,this.#s=this.#e,this.#a=SR(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 a=e.get(i);a?a.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 kR(this.#t,i);n.push({defaultedQueryOptions:i,observer:o})}),n}#u(t,e){const n=this.#r.indexOf(t);n!==-1&&(this.#e=Wle(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)})})}}},Xle=class extends km{constructor(t={}){super(),this.config=t,this.#t=new Map}#t;build(t,e,n){const r=e.queryKey,i=e.queryHash??_R(r,e);let a=this.get(i);return a||(a=new zle({client:t,queryKey:r,queryHash:i,options:t.defaultQueryOptions(e),state:n,defaultOptions:t.getQueryDefaults(r)}),this.add(a)),a}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=>wz(e,n))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(n=>wz(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()})})}},Yle=class{#t;#e;#n;#i;#r;#a;#o;#s;constructor(t={}){this.#t=t.queryCache||new Xle,this.#e=t.mutationCache||new Gle,this.#n=t.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=MR.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#t.onFocus())}),this.#s=V1.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(rh(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}),a=this.#t.get(r.queryHash)?.state.data,o=Cle(e,a);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(Ya).catch(Ya)}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 a=i.fetch(void 0,n);return n.throwOnError||(a=a.catch(Ya)),i.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ya)}fetchQuery(t){const e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);const n=this.#t.build(this,e);return n.isStaleByTime(rh(e.staleTime,n))?n.fetch(e):Promise.resolve(n.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(Ya).catch(Ya)}fetchInfiniteQuery(t){return t.behavior=Az(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(Ya).catch(Ya)}ensureInfiniteQueryData(t){return t.behavior=Az(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return V1.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(nm(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#i.values()],n={};return e.forEach(r=>{$0(t,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(t,e){this.#r.set(nm(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#r.values()],n={};return e.forEach(r=>{$0(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=_R(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===NR&&(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()}},sW=_.createContext(void 0),sn=t=>{const e=_.useContext(sW);if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},Qle=({client:t,children:e})=>(_.useEffect(()=>(t.mount(),()=>{t.unmount()}),[t]),s.jsx(sW.Provider,{value:t,children:e})),oW=_.createContext(!1),lW=()=>_.useContext(oW);oW.Provider;function Zle(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Jle=_.createContext(Zle()),cW=()=>_.useContext(Jle),uW=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},dW=t=>{_.useEffect(()=>{t.clearReset()},[t])},hW=({result:t,errorResetBoundary:e,throwOnError:n,query:r,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&r&&(i&&t.data===void 0||eW(n,[t.error,r])),fW=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))}},mW=(t,e)=>t.isLoading&&t.isFetching&&!e,cj=(t,e)=>t?.suspense&&e.isPending,G1=(t,e,n)=>e.fetchOptimistic(t).catch(()=>{n.clearReset()});function pW({queries:t,...e},n){const r=sn(),i=lW(),a=cW(),o=_.useMemo(()=>t.map(b=>{const v=r.defaultQueryOptions(b);return v._optimisticResults=i?"isRestoring":"optimistic",v}),[t,r,i]);o.forEach(b=>{fW(b),uW(b,a)}),dW(a);const[l]=_.useState(()=>new Kle(r,o,e)),[c,u,d]=l.getOptimisticResult(o,e.combine),f=!i&&e.subscribed!==!1;_.useSyncExternalStore(_.useCallback(b=>f?l.subscribe(yi.batchCalls(b)):Ya,[l,f]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),_.useEffect(()=>{l.setQueries(o,e)},[o,e,l]);const m=c.some((b,v)=>cj(o[v],b))?c.flatMap((b,v)=>{const y=o[v];if(y){const S=new kR(r,y);if(cj(y,b))return G1(y,S,a);mW(b,i)&&G1(y,S,a)}return[]}):[];if(m.length>0)throw Promise.all(m);const x=c.find((b,v)=>{const y=o[v];return y&&hW({result:b,errorResetBoundary:a,throwOnError:y.throwOnError,query:r.getQueryCache().get(y.queryHash),suspense:y.suspense})});if(x?.error)throw x.error;return u(d())}function ece(t,e,n){const r=lW(),i=cW(),a=sn(),o=a.defaultQueryOptions(t);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?"isRestoring":"optimistic",fW(o),uW(o,i),dW(i);const l=!a.getQueryCache().get(o.queryHash),[c]=_.useState(()=>new e(a,o)),u=c.getOptimisticResult(o),d=!r&&t.subscribed!==!1;if(_.useSyncExternalStore(_.useCallback(f=>{const p=d?c.subscribe(yi.batchCalls(f)):Ya;return c.updateResult(),p},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),_.useEffect(()=>{c.setOptions(o)},[o,c]),cj(o,u))throw G1(o,c,i);if(hW({result:u,errorResetBoundary:i,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,u),o.experimental_prefetchInRender&&!tm&&mW(u,r)&&(l?G1(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Ya).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?u:c.trackResult(u)}function ot(t,e){return ece(t,kR)}function mt(t,e){const n=sn(),[r]=_.useState(()=>new qle(n,t));_.useEffect(()=>{r.setOptions(t)},[r,t]);const i=_.useSyncExternalStore(_.useCallback(o=>r.subscribe(yi.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=_.useCallback((o,l)=>{r.mutate(o,l).catch(Ya)},[r]);if(i.error&&eW(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}const tce=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),nce=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),jz=t=>{const e=nce(t);return e.charAt(0).toUpperCase()+e.slice(1)},gW=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),rce=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var ice={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 ace=_.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:a,iconNode:o,...l},c)=>_.createElement("svg",{ref:c,...ice,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:gW("lucide",i),...!a&&!rce(l)&&{"aria-hidden":"true"},...l},[...o.map(([u,d])=>_.createElement(u,d)),...Array.isArray(a)?a:[a]]));const Ze=(t,e)=>{const n=_.forwardRef(({className:r,...i},a)=>_.createElement(ace,{ref:a,iconNode:e,className:gW(`lucide-${tce(jz(t))}`,`lucide-${t}`,r),...i}));return n.displayName=jz(t),n};const sce=[["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"}]],oce=Ze("air-vent",sce);const lce=[["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"}]],ho=Ze("archive",lce);const cce=[["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"}]],uce=Ze("arrow-down-wide-narrow",cce);const dce=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],G0=Ze("arrow-down",dce);const hce=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],fce=Ze("arrow-left",hce);const mce=[["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"}]],Dz=Ze("arrow-right-left",mce);const pce=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],uj=Ze("arrow-right",pce);const gce=[["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"}]],xW=Ze("arrow-up-down",gce);const xce=[["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"}]],bce=Ze("arrow-up-narrow-wide",xce);const yce=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Ig=Ze("arrow-up",yce);const vce=[["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"}]],wg=Ze("bell",vce);const wce=[["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"}]],_ce=Ze("bold",wce);const Sce=[["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"}]],Nce=Ze("book",Sce);const Mce=[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]],kce=Ze("bookmark",Mce);const Ece=[["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"}]],oo=Ze("box",Ece);const Tce=[["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"}]],bW=Ze("briefcase",Tce);const Ace=[["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"}]],sM=Ze("bug",Ace);const Cce=[["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"}]],Pce=Ze("cable",Cce);const jce=[["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"}]],Dce=Ze("calculator",jce);const Rce=[["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"}]],Oce=Ze("calendar-days",Rce);const Lce=[["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=Ze("calendar",Lce);const Fce=[["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"}]],Ug=Ze("camera",Fce);const Ice=[["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"}]],Uce=Ze("chart-column",Ice);const zce=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Na=Ze("check",zce);const Bce=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Kr=Ze("chevron-down",Bce);const Hce=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],gs=Ze("chevron-right",Hce);const $ce=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],gh=Ze("chevron-left",$ce);const Vce=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],xh=Ze("chevron-up",Vce);const Gce=[["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"}]],$i=Ze("circle-alert",Gce);const qce=[["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"}]],JE=Ze("circle-arrow-up",qce);const Wce=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ar=Ze("circle-check-big",Wce);const Kce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],oM=Ze("circle-check",Kce);const Xce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Yce=Ze("circle-dot",Xce);const Qce=[["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"}]],Zce=Ze("circle-question-mark",Qce);const Jce=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],eue=Ze("circle-stop",Jce);const tue=[["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"}]],Qi=Ze("circle-x",tue);const nue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],dj=Ze("circle",nue);const rue=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],tr=Ze("clock",rue);const iue=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],lM=Ze("cloud",iue);const aue=[["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"}]],sue=Ze("code-xml",aue);const oue=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],yW=Ze("code",oue);const lue=[["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"}]],cue=Ze("coffee",lue);const uue=[["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"}]],due=Ze("cog",uue);const hue=[["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"}]],fue=Ze("compass",hue);const mue=[["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"}]],Fl=Ze("copy",mue);const pue=[["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"}]],Rw=Ze("cpu",pue);const gue=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5v14a9 3 0 0 0 18 0V5",key:"aqi0yr"}]],xue=Ze("cylinder",gue);const bue=[["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"}]],ku=Ze("database",bue);const yue=[["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"}]],hj=Ze("dollar-sign",yue);const vue=[["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=Ze("download",vue);const wue=[["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"}]],TR=Ze("droplet",wue);const _ue=[["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"}]],AR=Ze("droplets",_ue);const Sue=[["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"}]],ih=Ze("ellipsis-vertical",Sue);const Nue=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],eT=Ze("equal",Nue);const Mue=[["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=Ze("external-link",Mue);const kue=[["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"}]],cM=Ze("eye-off",kue);const Eue=[["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"}]],mc=Ze("eye",Eue);const Tue=[["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"}]],vW=Ze("fan",Tue);const Aue=[["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"}]],zf=Ze("file-box",Aue);const Cue=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],q1=Ze("file-code",Cue);const Pue=[["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"}]],jue=Ze("file-exclamation-point",Pue);const Due=[["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"}]],W1=Ze("file-spreadsheet",Due);const Rue=[["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"}]],Ls=Ze("file-text",Rue);const Oue=[["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"}]],uM=Ze("file",Oue);const Lue=[["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"}]],ah=Ze("film",Lue);const Fue=[["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"}]],Iue=Ze("flame",Fue);const Uue=[["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"}]],Ja=Ze("folder-kanban",Uue);const zue=[["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"}]],Il=Ze("folder-open",zue);const Bue=[["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"}]],Hue=Ze("folder-plus",Bue);const $ue=[["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"}]],Vue=Ze("folder-tree",$ue);const Gue=[["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"}]],wW=Ze("folder",Gue);const que=[["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"}]],Wue=Ze("fullscreen",que);const Kue=[["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"}]],dM=Ze("funnel",Kue);const Xue=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],hM=Ze("gauge",Xue);const Yue=[["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"}]],Que=Ze("gift",Yue);const Zue=[["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"}]],_g=Ze("git-compare",Zue);const Jue=[["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"}]],fj=Ze("github",Jue);const ede=[["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"}]],sh=Ze("globe",ede);const tde=[["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"}]],zg=Ze("grip-vertical",tde);const nde=[["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"}]],_W=Ze("hand",nde);const rde=[["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"}]],fM=Ze("hard-drive",rde);const ide=[["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"}]],ade=Ze("hash",ide);const sde=[["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"}]],ode=Ze("headphones",sde);const lde=[["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"}]],cde=Ze("heart",lde);const ude=[["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"}]],q0=Ze("history",ude);const dde=[["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"}]],Fy=Ze("house",dde);const hde=[["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"}]],Ou=Ze("image",hde);const fde=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Zo=Ze("info",fde);const mde=[["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"}]],pde=Ze("italic",mde);const gde=[["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"}]],$o=Ze("key",gde);const xde=[["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"}]],mj=Ze("keyboard",xde);const bde=[["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"}]],sl=Ze("layers",bde);const yde=[["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"}]],mM=Ze("layout-grid",yde);const vde=[["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"}]],wde=Ze("link-2-off",vde);const _de=[["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"}]],uc=Ze("link-2",_de);const Sde=[["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"}]],Iy=Ze("link",Sde);const Nde=[["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"}]],SW=Ze("list-ordered",Nde);const Mde=[["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"}]],pj=Ze("list-todo",Mde);const kde=[["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"}]],pM=Ze("list",kde);const Ede=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ft=Ze("loader-circle",Ede);const Tde=[["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"}]],tT=Ze("lock-open",Tde);const Ade=[["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"}]],nT=Ze("lock",Ade);const Cde=[["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"}]],Rz=Ze("log-in",Cde);const Pde=[["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"}]],gj=Ze("log-out",Pde);const jde=[["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"}]],Dde=Ze("mail",jde);const Rde=[["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"}]],Ode=Ze("map",Rde);const Lde=[["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"}]],NW=Ze("maximize-2",Lde);const Fde=[["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"}]],Ide=Ze("maximize",Fde);const Ude=[["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"}]],zde=Ze("memory-stick",Ude);const Bde=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],Hde=Ze("menu",Bde);const $de=[["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"}]],MW=Ze("minimize-2",$de);const Vde=[["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"}]],kW=Ze("minimize",Vde);const Gde=[["path",{d:"M5 12h14",key:"1ays0h"}]],xj=Ze("minus",Gde);const qde=[["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"}]],Wde=Ze("monitor",qde);const Kde=[["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"}]],K1=Ze("moon",Kde);const Xde=[["path",{d:"M18 8L22 12L18 16",key:"1r0oui"}],["path",{d:"M2 12H22",key:"1m8cig"}]],Yde=Ze("move-right",Xde);const Qde=[["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"}]],bj=Ze("music",Qde);const Zde=[["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"}]],pc=Ze("package",Zde);const Jde=[["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"}]],EW=Ze("palette",Jde);const ehe=[["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"}]],CR=Ze("pause",ehe);const the=[["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"}]],rm=Ze("pen-line",the);const nhe=[["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"}]],fg=Ze("pen",nhe);const rhe=[["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"}]],Zi=Ze("pencil",rhe);const ihe=[["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"}]],ahe=Ze("phone",ihe);const she=[["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"}]],bo=Ze("play",she);const ohe=[["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"}]],tl=Ze("plug",ohe);const lhe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],fr=Ze("plus",lhe);const che=[["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"}]],gM=Ze("power-off",che);const uhe=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Gu=Ze("power",uhe);const dhe=[["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=Ze("printer",dhe);const hhe=[["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"}]],TW=Ze("qr-code",hhe);const fhe=[["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=Ze("radio",fhe);const mhe=[["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=Ze("refresh-cw",mhe);const phe=[["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"}]],Rh=Ze("rotate-ccw",phe);const ghe=[["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"}]],xhe=Ze("ruler",ghe);const bhe=[["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"}]],hs=Ze("save",bhe);const yhe=[["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"}]],X1=Ze("scan-search",yhe);const vhe=[["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"}]],whe=Ze("scissors",vhe);const _he=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],ya=Ze("search",_he);const She=[["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"}]],jR=Ze("send",She);const Nhe=[["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"}]],yf=Ze("server",Nhe);const Mhe=[["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"}]],bh=Ze("settings-2",Mhe);const khe=[["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"}]],xM=Ze("settings",khe);const Ehe=[["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"}]],rT=Ze("shield",Ehe);const The=[["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"}]],AW=Ze("shopping-cart",The);const Ahe=[["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"}]],Che=Ze("signal",Ahe);const Phe=[["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"}]],jhe=Ze("skip-back",Phe);const Dhe=[["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"}]],DR=Ze("skip-forward",Dhe);const Rhe=[["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"}]],Oz=Ze("sliders-vertical",Rhe);const Ohe=[["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"}]],W0=Ze("sparkles",Ohe);const Lhe=[["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"}]],ol=Ze("square-check-big",Lhe);const Fhe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}]],Ihe=Ze("square-minus",Fhe);const Uhe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ll=Ze("square",Uhe);const zhe=[["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"}]],im=Ze("star",zhe);const Bhe=[["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"}]],CW=Ze("sticky-note",Bhe);const Hhe=[["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"}]],Lz=Ze("sun",Hhe);const $he=[["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"}]],yh=Ze("tag",$he);const Vhe=[["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"}]],PW=Ze("target",Vhe);const Ghe=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],jW=Ze("terminal",Ghe);const qhe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Whe=Ze("text-align-center",qhe);const Khe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Xhe=Ze("text-align-end",Khe);const Yhe=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Qhe=Ze("text-align-start",Yhe);const Zhe=[["path",{d:"M14 4v10.54a4 4 0 1 1-4 0V4a2 2 0 0 1 4 0Z",key:"17jzev"}]],bM=Ze("thermometer",Zhe);const Jhe=[["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"}]],bu=Ze("timer",Jhe);const efe=[["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=Ze("trash-2",efe);const tfe=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],DW=Ze("trending-down",tfe);const nfe=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],yj=Ze("trending-up",nfe);const rfe=[["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=Ze("triangle-alert",rfe);const ife=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],afe=Ze("underline",ife);const sfe=[["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"}]],RR=Ze("unlink",sfe);const ofe=[["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"}]],za=Ze("upload",ofe);const lfe=[["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"}]],am=Ze("user",lfe);const cfe=[["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"}]],mg=Ze("users",cfe);const ufe=[["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"}]],OR=Ze("video",ufe);const dfe=[["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"}]],hfe=Ze("volume-2",dfe);const ffe=[["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"}]],mfe=Ze("volume-x",ffe);const pfe=[["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"}]],gfe=Ze("wand-sparkles",pfe);const xfe=[["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"}]],sm=Ze("wifi-off",xfe);const bfe=[["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"}]],Sg=Ze("wifi",bfe);const yfe=[["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"}]],RW=Ze("wind",yfe);const vfe=[["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"}]],om=Ze("wrench",vfe);const wfe=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Rt=Ze("x",wfe);const _fe=[["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"}]],LR=Ze("zoom-in",_fe);const Sfe=[["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"}]],vh=Ze("zap",Sfe);const Nfe=[["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"}]],FR=Ze("zoom-out",Nfe),en="/api/v1";let tn=localStorage.getItem("auth_token");function r0(t){tn=t,t?localStorage.setItem("auth_token",t):localStorage.removeItem("auth_token")}function Fz(){return tn}async function Re(t,e={}){const n={"Content-Type":"application/json",...e.headers};tn&&(n.Authorization=`Bearer ${tn}`);const r=await fetch(`${en}${t}`,{...e,cache:"no-store",headers:n});if(!r.ok){r.status===401&&r0(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 ce={getAuthStatus:()=>Re("/auth/status"),setupAuth:t=>Re("/auth/setup",{method:"POST",body:JSON.stringify(t)}),login:t=>Re("/auth/login",{method:"POST",body:JSON.stringify(t)}),logout:()=>Re("/auth/logout",{method:"POST"}),getCurrentUser:()=>Re("/auth/me"),disableAuth:()=>Re("/auth/disable",{method:"POST"}),getUsers:()=>Re("/users/"),getUser:t=>Re(`/users/${t}`),createUser:t=>Re("/users/",{method:"POST",body:JSON.stringify(t)}),updateUser:(t,e)=>Re(`/users/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteUser:(t,e=!1)=>Re(`/users/${t}?delete_items=${e}`,{method:"DELETE"}),getUserItemsCount:t=>Re(`/users/${t}/items-count`),changePassword:(t,e)=>Re("/users/me/change-password",{method:"POST",body:JSON.stringify({current_password:t,new_password:e})}),getPermissions:()=>Re("/groups/permissions"),getGroups:()=>Re("/groups/"),getGroup:t=>Re(`/groups/${t}`),createGroup:t=>Re("/groups/",{method:"POST",body:JSON.stringify(t)}),updateGroup:(t,e)=>Re(`/groups/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteGroup:t=>Re(`/groups/${t}`,{method:"DELETE"}),addUserToGroup:(t,e)=>Re(`/groups/${t}/users/${e}`,{method:"POST"}),removeUserFromGroup:(t,e)=>Re(`/groups/${t}/users/${e}`,{method:"DELETE"}),getPrinters:()=>Re("/printers/"),getPrinter:t=>Re(`/printers/${t}`),createPrinter:t=>Re("/printers/",{method:"POST",body:JSON.stringify(t)}),updatePrinter:(t,e)=>Re(`/printers/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deletePrinter:(t,e=!0)=>Re(`/printers/${t}?delete_archives=${e}`,{method:"DELETE"}),getPrinterStatus:t=>Re(`/printers/${t}/status`),refreshPrinterStatus:t=>Re(`/printers/${t}/refresh-status`,{method:"POST"}),connectPrinter:t=>Re(`/printers/${t}/connect`,{method:"POST"}),disconnectPrinter:t=>Re(`/printers/${t}/disconnect`,{method:"POST"}),testExternalCamera:(t,e,n)=>Re(`/printers/${t}/camera/external/test?url=${encodeURIComponent(e)}&camera_type=${encodeURIComponent(n)}`,{method:"POST"}),stopPrint:t=>Re(`/printers/${t}/print/stop`,{method:"POST"}),pausePrint:t=>Re(`/printers/${t}/print/pause`,{method:"POST"}),resumePrint:t=>Re(`/printers/${t}/print/resume`,{method:"POST"}),getCurrentPrintUser:t=>Re(`/printers/${t}/current-print-user`),setChamberLight:(t,e)=>Re(`/printers/${t}/chamber-light?on=${e}`,{method:"POST"}),getPrintableObjects:t=>Re(`/printers/${t}/print/objects`),skipObjects:(t,e)=>Re(`/printers/${t}/print/skip-objects`,{method:"POST",body:JSON.stringify(e)}),refreshAmsSlot:(t,e,n)=>Re(`/printers/${t}/ams/${e}/slot/${n}/refresh`,{method:"POST"}),enableMQTTLogging:t=>Re(`/printers/${t}/logging/enable`,{method:"POST"}),disableMQTTLogging:t=>Re(`/printers/${t}/logging/disable`,{method:"POST"}),getMQTTLogs:t=>Re(`/printers/${t}/logging`),clearMQTTLogs:t=>Re(`/printers/${t}/logging`,{method:"DELETE"}),getPrinterFiles:(t,e="/")=>Re(`/printers/${t}/files?path=${encodeURIComponent(e)}`),getPrinterFileDownloadUrl:(t,e)=>`${en}/printers/${t}/files/download?path=${encodeURIComponent(e)}`,downloadPrinterFile:async(t,e)=>{const n={};tn&&(n.Authorization=`Bearer ${tn}`);const r=await fetch(`${en}/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(`${en}/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)=>Re(`/printers/${t}/files?path=${encodeURIComponent(e)}`,{method:"DELETE"}),getPrinterStorage:t=>Re(`/printers/${t}/storage`),getArchives:(t,e,n=50,r=0)=>{const i=new URLSearchParams;return t&&i.set("printer_id",String(t)),e&&i.set("project_id",String(e)),i.set("limit",String(n)),i.set("offset",String(r)),Re(`/archives/?${i}`)},getArchive:t=>Re(`/archives/${t}`),searchArchives:(t,e)=>{const n=new URLSearchParams;return n.set("q",t),e?.printerId&&n.set("printer_id",String(e.printerId)),e?.projectId&&n.set("project_id",String(e.projectId)),e?.status&&n.set("status",e.status),e?.limit&&n.set("limit",String(e.limit)),e?.offset&&n.set("offset",String(e.offset)),Re(`/archives/search?${n}`)},rebuildSearchIndex:()=>Re("/archives/search/rebuild-index",{method:"POST"}),updateArchive:(t,e)=>Re(`/archives/${t}`,{method:"PATCH",body:JSON.stringify(e)}),toggleFavorite:t=>Re(`/archives/${t}/favorite`,{method:"POST"}),deleteArchive:t=>Re(`/archives/${t}`,{method:"DELETE"}),getArchiveStats:()=>Re("/archives/stats"),getTags:()=>Re("/archives/tags"),renameTag:(t,e)=>Re(`/archives/tags/${encodeURIComponent(t)}`,{method:"PUT",body:JSON.stringify({new_name:e})}),deleteTag:t=>Re(`/archives/tags/${encodeURIComponent(t)}`,{method:"DELETE"}),recalculateCosts:()=>Re("/archives/recalculate-costs",{method:"POST"}),getFailureAnalysis:t=>{const e=new URLSearchParams;return t?.days&&e.set("days",String(t.days)),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),Re(`/archives/analysis/failures?${e}`)},compareArchives:t=>Re(`/archives/compare?archive_ids=${t.join(",")}`),findSimilarArchives:(t,e=10)=>Re(`/archives/${t}/similar?limit=${e}`),exportArchives:async t=>{const e=new URLSearchParams;t?.format&&e.set("format",t.format),t?.fields&&e.set("fields",t.fields.join(",")),t?.printerId&&e.set("printer_id",String(t.printerId)),t?.projectId&&e.set("project_id",String(t.projectId)),t?.status&&e.set("status",t.status),t?.dateFrom&&e.set("date_from",t.dateFrom),t?.dateTo&&e.set("date_to",t.dateTo),t?.search&&e.set("search",t.search);const n={};tn&&(n.Authorization=`Bearer ${tn}`);const r=await fetch(`${en}/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 a=t?.format==="xlsx"?"archives_export.xlsx":"archives_export.csv";if(i){const l=i.match(/filename="?([^"]+)"?/);l&&(a=l[1])}return{blob:await r.blob(),filename:a}},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(`${en}/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 a=t?.format==="xlsx"?"stats_export.xlsx":"stats_export.csv";if(i){const l=i.match(/filename="?([^"]+)"?/);l&&(a=l[1])}return{blob:await r.blob(),filename:a}},getArchiveDuplicates:t=>Re(`/archives/${t}/duplicates`),backfillContentHashes:()=>Re("/archives/backfill-hashes",{method:"POST"}),getArchiveThumbnail:t=>`${en}/archives/${t}/thumbnail?v=${Date.now()}`,getArchivePlateThumbnail:(t,e)=>`${en}/archives/${t}/plate-thumbnail/${e}`,getArchiveDownload:t=>`${en}/archives/${t}/download`,downloadArchive:async(t,e)=>{const n={};tn&&(n.Authorization=`Bearer ${tn}`);const r=await fetch(`${en}/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=>`${en}/archives/${t}/gcode`,getArchivePlatePreview:t=>`${en}/archives/${t}/plate-preview`,getArchiveTimelapse:t=>`${en}/archives/${t}/timelapse?v=${Date.now()}`,scanArchiveTimelapse:t=>Re(`/archives/${t}/timelapse/scan`,{method:"POST"}),selectArchiveTimelapse:(t,e)=>Re(`/archives/${t}/timelapse/select?filename=${encodeURIComponent(e)}`,{method:"POST"}),uploadArchiveTimelapse:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};tn&&(r.Authorization=`Bearer ${tn}`);const i=await fetch(`${en}/archives/${t}/timelapse/upload`,{method:"POST",headers:r,body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getTimelapseInfo:t=>Re(`/archives/${t}/timelapse/info`),getTimelapseThumbnails:(t,e=10)=>Re(`/archives/${t}/timelapse/thumbnails?count=${e}`),processTimelapse:async(t,e,n)=>{const r=new FormData;r.append("trim_start",String(e.trimStart??0)),e.trimEnd!==void 0&&r.append("trim_end",String(e.trimEnd)),r.append("speed",String(e.speed??1)),r.append("save_mode",e.saveMode),e.outputFilename&&r.append("output_filename",e.outputFilename),n&&r.append("audio",n);const i={};tn&&(i.Authorization=`Bearer ${tn}`);const a=await fetch(`${en}/archives/${t}/timelapse/process`,{method:"POST",headers:i,body:r});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${a.status}`)}return a.json()},getArchivePhotoUrl:(t,e)=>`${en}/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(`${en}/archives/${t}/photos`,{headers:r,method:"POST",body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},deleteArchivePhoto:(t,e)=>Re(`/archives/${t}/photos/${encodeURIComponent(e)}`,{method:"DELETE"}),getSource3mfDownloadUrl:t=>`${en}/archives/${t}/source`,downloadSource3mf:async t=>{const e={};tn&&(e.Authorization=`Bearer ${tn}`);const n=await fetch(`${en}/archives/${t}/source`,{headers:e});if(!n.ok){const u=await n.json().catch(()=>({}));throw new Error(u.detail||`HTTP ${n.status}`)}const a=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=a,document.body.appendChild(c),c.click(),document.body.removeChild(c),window.URL.revokeObjectURL(l)},getSource3mfForSlicer:(t,e)=>`${en}/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(`${en}/archives/${t}/source`,{method:"POST",headers:r,body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},deleteSource3mf:t=>Re(`/archives/${t}/source`,{method:"DELETE"}),getF3dDownloadUrl:t=>`${en}/archives/${t}/f3d`,downloadF3d:async t=>{const e={};tn&&(e.Authorization=`Bearer ${tn}`);const n=await fetch(`${en}/archives/${t}/f3d`,{headers:e});if(!n.ok){const u=await n.json().catch(()=>({}));throw new Error(u.detail||`HTTP ${n.status}`)}const a=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=a,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(`${en}/archives/${t}/f3d`,{method:"POST",headers:r,body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},deleteF3d:t=>Re(`/archives/${t}/f3d`,{method:"DELETE"}),getArchiveQRCodeUrl:(t,e=200)=>`${en}/archives/${t}/qrcode?size=${e}`,getArchiveCapabilities:t=>Re(`/archives/${t}/capabilities`),getArchiveProjectPage:t=>Re(`/archives/${t}/project-page`),updateArchiveProjectPage:(t,e)=>Re(`/archives/${t}/project-page`,{method:"PATCH",body:JSON.stringify(e)}),getArchiveProjectImageUrl:(t,e)=>`${en}/archives/${t}/project-image/${encodeURIComponent(e)}`,getArchiveForSlicer:(t,e)=>`${en}/archives/${t}/file/${encodeURIComponent(e.endsWith(".3mf")?e:e+".3mf")}`,getArchivePlates:t=>Re(`/archives/${t}/plates`),getArchiveFilamentRequirements:(t,e)=>Re(`/archives/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),reprintArchive:(t,e,n)=>Re(`/archives/${t}/reprint?printer_id=${e}`,{method:"POST",headers:n?{"Content-Type":"application/json"}:void 0,body:n?JSON.stringify(n):void 0}),uploadArchive:async(t,e)=>{const n=new FormData;n.append("file",t);const r=e?`${en}/archives/upload?printer_id=${e}`:`${en}/archives/upload`,i={};tn&&(i.Authorization=`Bearer ${tn}`);const a=await fetch(r,{method:"POST",headers:i,body:n});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${a.status}`)}return a.json()},uploadArchivesBulk:async(t,e)=>{const n=new FormData;t.forEach(o=>n.append("files",o));const r=e?`${en}/archives/upload-bulk?printer_id=${e}`:`${en}/archives/upload-bulk`,i={};tn&&(i.Authorization=`Bearer ${tn}`);const a=await fetch(r,{method:"POST",headers:i,body:n});if(!a.ok){const o=await a.json().catch(()=>({}));throw new Error(o.detail||`HTTP ${a.status}`)}return a.json()},getSettings:()=>Re("/settings/"),updateSettings:t=>Re("/settings/",{method:"PUT",body:JSON.stringify(t)}),getMQTTStatus:()=>Re("/settings/mqtt/status"),resetSettings:()=>Re("/settings/reset",{method:"POST"}),exportBackup:async()=>{const t=`${en}/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=`${en}/settings/restore`,r={};return tn&&(r.Authorization=`Bearer ${tn}`),(await fetch(n,{method:"POST",headers:r,body:e})).json()},checkFfmpeg:()=>Re("/settings/check-ffmpeg"),getCloudStatus:()=>Re("/cloud/status"),cloudLogin:(t,e,n="global")=>Re("/cloud/login",{method:"POST",body:JSON.stringify({email:t,password:e,region:n})}),cloudVerify:(t,e,n)=>Re("/cloud/verify",{method:"POST",body:JSON.stringify({email:t,code:e,tfa_key:n})}),cloudSetToken:t=>Re("/cloud/token",{method:"POST",body:JSON.stringify({access_token:t})}),cloudLogout:()=>Re("/cloud/logout",{method:"POST"}),getCloudSettings:(t="02.04.00.70")=>Re(`/cloud/settings?version=${t}`),getCloudSettingDetail:t=>Re(`/cloud/settings/${t}`),createCloudSetting:t=>Re("/cloud/settings",{method:"POST",body:JSON.stringify(t)}),updateCloudSetting:(t,e)=>Re(`/cloud/settings/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteCloudSetting:t=>Re(`/cloud/settings/${t}`,{method:"DELETE"}),getCloudDevices:()=>Re("/cloud/devices"),getCloudFields:t=>Re(`/cloud/fields/${t}`),getAllCloudFields:()=>Re("/cloud/fields"),getFilamentInfo:t=>Re("/cloud/filament-info",{method:"POST",body:JSON.stringify(t)}),getSmartPlugs:()=>Re("/smart-plugs/"),getSmartPlug:t=>Re(`/smart-plugs/${t}`),getSmartPlugByPrinter:t=>Re(`/smart-plugs/by-printer/${t}`),getScriptPlugsByPrinter:t=>Re(`/smart-plugs/by-printer/${t}/scripts`),createSmartPlug:t=>Re("/smart-plugs/",{method:"POST",body:JSON.stringify(t)}),updateSmartPlug:(t,e)=>Re(`/smart-plugs/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteSmartPlug:t=>Re(`/smart-plugs/${t}`,{method:"DELETE"}),controlSmartPlug:(t,e)=>Re(`/smart-plugs/${t}/control`,{method:"POST",body:JSON.stringify({action:e})}),getSmartPlugStatus:t=>Re(`/smart-plugs/${t}/status`),testSmartPlugConnection:(t,e,n)=>Re("/smart-plugs/test-connection",{method:"POST",body:JSON.stringify({ip_address:t,username:e,password:n})}),startTasmotaScan:()=>fetch(`${en}/smart-plugs/discover/scan`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getTasmotaScanStatus:()=>Re("/smart-plugs/discover/status"),stopTasmotaScan:()=>fetch(`${en}/smart-plugs/discover/stop`,{method:"POST"}).then(t=>t.ok?t.json():t.json().then(e=>{throw new Error(e.detail||`HTTP ${t.status}`)})),getDiscoveredTasmotaDevices:()=>Re("/smart-plugs/discover/devices"),testHAConnection:(t,e)=>Re("/smart-plugs/ha/test-connection",{method:"POST",body:JSON.stringify({url:t,token:e})}),getHAEntities:t=>{const e=t?`?search=${encodeURIComponent(t)}`:"";return Re(`/smart-plugs/ha/entities${e}`)},getHASensorEntities:()=>Re("/smart-plugs/ha/sensors"),getQueue:(t,e)=>{const n=new URLSearchParams;return t&&n.set("printer_id",String(t)),e&&n.set("status",e),Re(`/queue/?${n}`)},getQueueItem:t=>Re(`/queue/${t}`),addToQueue:t=>Re("/queue/",{method:"POST",body:JSON.stringify(t)}),updateQueueItem:(t,e)=>Re(`/queue/${t}`,{method:"PATCH",body:JSON.stringify(e)}),removeFromQueue:t=>Re(`/queue/${t}`,{method:"DELETE"}),reorderQueue:t=>Re("/queue/reorder",{method:"POST",body:JSON.stringify({items:t})}),cancelQueueItem:t=>Re(`/queue/${t}/cancel`,{method:"POST"}),stopQueueItem:t=>Re(`/queue/${t}/stop`,{method:"POST"}),startQueueItem:t=>Re(`/queue/${t}/start`,{method:"POST"}),bulkUpdateQueue:t=>Re("/queue/bulk",{method:"PATCH",body:JSON.stringify(t)}),getKProfiles:(t,e="0.4")=>Re(`/printers/${t}/kprofiles/?nozzle_diameter=${e}`),setKProfile:(t,e)=>Re(`/printers/${t}/kprofiles/`,{method:"POST",body:JSON.stringify(e)}),deleteKProfile:(t,e)=>Re(`/printers/${t}/kprofiles/`,{method:"DELETE",body:JSON.stringify(e)}),setKProfilesBatch:(t,e)=>Re(`/printers/${t}/kprofiles/batch`,{method:"POST",body:JSON.stringify(e)}),getKProfileNotes:t=>Re(`/printers/${t}/kprofiles/notes`),setKProfileNote:(t,e,n)=>Re(`/printers/${t}/kprofiles/notes`,{method:"PUT",body:JSON.stringify({setting_id:e,note:n})}),deleteKProfileNote:(t,e)=>Re(`/printers/${t}/kprofiles/notes/${encodeURIComponent(e)}`,{method:"DELETE"}),getSlotPresets:t=>Re(`/printers/${t}/slot-presets`),getSlotPreset:(t,e,n)=>Re(`/printers/${t}/slot-presets/${e}/${n}`),saveSlotPreset:(t,e,n,r,i)=>Re(`/printers/${t}/slot-presets/${e}/${n}?preset_id=${encodeURIComponent(r)}&preset_name=${encodeURIComponent(i)}`,{method:"PUT"}),deleteSlotPreset:(t,e,n)=>Re(`/printers/${t}/slot-presets/${e}/${n}`,{method:"DELETE"}),configureAmsSlot:(t,e,n,r)=>{const i=new URLSearchParams({tray_info_idx:r.tray_info_idx,tray_type:r.tray_type,tray_sub_brands:r.tray_sub_brands,tray_color:r.tray_color,nozzle_temp_min:r.nozzle_temp_min.toString(),nozzle_temp_max:r.nozzle_temp_max.toString(),cali_idx:r.cali_idx.toString(),nozzle_diameter:r.nozzle_diameter});return r.setting_id&&i.set("setting_id",r.setting_id),r.kprofile_filament_id&&i.set("kprofile_filament_id",r.kprofile_filament_id),r.kprofile_setting_id&&i.set("kprofile_setting_id",r.kprofile_setting_id),r.k_value!==void 0&&r.k_value>0&&i.set("k_value",r.k_value.toString()),Re(`/printers/${t}/slots/${e}/${n}/configure?${i}`,{method:"POST"})},resetAmsSlot:(t,e,n)=>Re(`/printers/${t}/ams/${e}/tray/${n}/reset`,{method:"POST"}),listFilaments:()=>Re("/filaments/"),getFilament:t=>Re(`/filaments/${t}`),getFilamentsByType:t=>Re(`/filaments/by-type/${t}`),getNotificationProviders:()=>Re("/notifications/"),getNotificationProvider:t=>Re(`/notifications/${t}`),createNotificationProvider:t=>Re("/notifications/",{method:"POST",body:JSON.stringify(t)}),updateNotificationProvider:(t,e)=>Re(`/notifications/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteNotificationProvider:t=>Re(`/notifications/${t}`,{method:"DELETE"}),testNotificationProvider:t=>Re(`/notifications/${t}/test`,{method:"POST"}),testNotificationConfig:t=>Re("/notifications/test-config",{method:"POST",body:JSON.stringify(t)}),testAllNotificationProviders:()=>Re("/notifications/test-all",{method:"POST"}),getNotificationTemplates:()=>Re("/notification-templates"),getNotificationTemplate:t=>Re(`/notification-templates/${t}`),updateNotificationTemplate:(t,e)=>Re(`/notification-templates/${t}`,{method:"PUT",body:JSON.stringify(e)}),resetNotificationTemplate:t=>Re(`/notification-templates/${t}/reset`,{method:"POST"}),getTemplateVariables:()=>Re("/notification-templates/variables"),previewTemplate:t=>Re("/notification-templates/preview",{method:"POST",body:JSON.stringify(t)}),getNotificationLogs:t=>{const e=new URLSearchParams;return t?.limit&&e.set("limit",String(t.limit)),t?.offset&&e.set("offset",String(t.offset)),t?.provider_id&&e.set("provider_id",String(t.provider_id)),t?.event_type&&e.set("event_type",t.event_type),t?.success!==void 0&&e.set("success",String(t.success)),t?.days&&e.set("days",String(t.days)),Re(`/notifications/logs?${e}`)},getNotificationLogStats:(t=7)=>Re(`/notifications/logs/stats?days=${t}`),clearNotificationLogs:(t=30)=>Re(`/notifications/logs?older_than_days=${t}`,{method:"DELETE"}),getSpoolmanStatus:()=>Re("/spoolman/status"),connectSpoolman:()=>Re("/spoolman/connect",{method:"POST"}),disconnectSpoolman:()=>Re("/spoolman/disconnect",{method:"POST"}),syncPrinterAms:t=>Re(`/spoolman/sync/${t}`,{method:"POST"}),syncAllPrintersAms:()=>Re("/spoolman/sync-all",{method:"POST"}),getSpoolmanSpools:()=>Re("/spoolman/spools"),getSpoolmanFilaments:()=>Re("/spoolman/filaments"),getUnlinkedSpools:()=>Re("/spoolman/spools/unlinked"),getLinkedSpools:()=>Re("/spoolman/spools/linked"),linkSpool:(t,e)=>Re(`/spoolman/spools/${t}/link`,{method:"POST",body:JSON.stringify({tray_uuid:e})}),getSpoolmanSettings:()=>Re("/settings/spoolman"),updateSpoolmanSettings:t=>Re("/settings/spoolman",{method:"PUT",body:JSON.stringify(t)}),getVersion:()=>Re("/updates/version"),checkForUpdates:()=>Re("/updates/check"),applyUpdate:()=>Re("/updates/apply",{method:"POST"}),getUpdateStatus:()=>Re("/updates/status"),getMaintenanceTypes:()=>Re("/maintenance/types"),createMaintenanceType:t=>Re("/maintenance/types",{method:"POST",body:JSON.stringify(t)}),updateMaintenanceType:(t,e)=>Re(`/maintenance/types/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteMaintenanceType:t=>Re(`/maintenance/types/${t}`,{method:"DELETE"}),getMaintenanceOverview:()=>Re("/maintenance/overview"),getPrinterMaintenance:t=>Re(`/maintenance/printers/${t}`),updateMaintenanceItem:(t,e)=>Re(`/maintenance/items/${t}`,{method:"PATCH",body:JSON.stringify(e)}),performMaintenance:(t,e)=>Re(`/maintenance/items/${t}/perform`,{method:"POST",body:JSON.stringify({notes:e})}),getMaintenanceHistory:t=>Re(`/maintenance/items/${t}/history`),getMaintenanceSummary:()=>Re("/maintenance/summary"),setPrinterHours:(t,e)=>Re(`/maintenance/printers/${t}/hours?total_hours=${e}`,{method:"PATCH"}),assignMaintenanceType:(t,e)=>Re(`/maintenance/printers/${t}/assign/${e}`,{method:"POST"}),removeMaintenanceItem:t=>Re(`/maintenance/items/${t}`,{method:"DELETE"}),getCameraStreamUrl:(t,e=10)=>`${en}/printers/${t}/camera/stream?fps=${e}`,getCameraSnapshotUrl:t=>`${en}/printers/${t}/camera/snapshot`,testCameraConnection:t=>Re(`/printers/${t}/camera/test`),getCameraStatus:t=>Re(`/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)),Re(`/printers/${t}/camera/check-plate?${n.toString()}`)},getPlateDetectionStatus:t=>Re(`/printers/${t}/camera/plate-detection/status`),calibratePlateDetection:(t,e)=>{const n=new URLSearchParams;return e?.label&&n.set("label",e.label),n.set("use_external",String(e?.useExternal??!1)),Re(`/printers/${t}/camera/plate-detection/calibrate?${n.toString()}`,{method:"POST"})},deletePlateCalibration:t=>Re(`/printers/${t}/camera/plate-detection/calibrate`,{method:"DELETE"}),getPlateReferences:t=>Re(`/printers/${t}/camera/plate-detection/references`),getPlateReferenceThumbnailUrl:(t,e)=>`${en}/printers/${t}/camera/plate-detection/references/${e}/thumbnail`,updatePlateReferenceLabel:(t,e,n)=>{const r=new URLSearchParams;return r.set("label",n),Re(`/printers/${t}/camera/plate-detection/references/${e}?${r.toString()}`,{method:"PUT"})},deletePlateReference:(t,e)=>Re(`/printers/${t}/camera/plate-detection/references/${e}`,{method:"DELETE"}),getExternalLinks:()=>Re("/external-links/"),getExternalLink:t=>Re(`/external-links/${t}`),createExternalLink:t=>Re("/external-links/",{method:"POST",body:JSON.stringify(t)}),updateExternalLink:(t,e)=>Re(`/external-links/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteExternalLink:t=>Re(`/external-links/${t}`,{method:"DELETE"}),reorderExternalLinks:t=>Re("/external-links/reorder",{method:"PUT",body:JSON.stringify({ids:t})}),uploadExternalLinkIcon:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};tn&&(r.Authorization=`Bearer ${tn}`);const i=await fetch(`${en}/external-links/${t}/icon`,{method:"POST",headers:r,body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},deleteExternalLinkIcon:t=>Re(`/external-links/${t}/icon`,{method:"DELETE"}),getExternalLinkIconUrl:t=>`${en}/external-links/${t}/icon`,getProjects:t=>{const e=new URLSearchParams;return t&&e.set("status",t),Re(`/projects/?${e}`)},getProject:t=>Re(`/projects/${t}`),createProject:t=>Re("/projects/",{method:"POST",body:JSON.stringify(t)}),updateProject:(t,e)=>Re(`/projects/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteProject:t=>Re(`/projects/${t}`,{method:"DELETE"}),getProjectArchives:(t,e=100,n=0)=>Re(`/projects/${t}/archives?limit=${e}&offset=${n}`),addArchivesToProject:(t,e)=>Re(`/projects/${t}/add-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),removeArchivesFromProject:(t,e)=>Re(`/projects/${t}/remove-archives`,{method:"POST",body:JSON.stringify({archive_ids:e})}),addQueueItemsToProject:(t,e)=>Re(`/projects/${t}/add-queue`,{method:"POST",body:JSON.stringify({queue_item_ids:e})}),uploadProjectAttachment:async(t,e)=>{const n=new FormData;n.append("file",e);const r={};tn&&(r.Authorization=`Bearer ${tn}`);const i=await fetch(`${en}/projects/${t}/attachments`,{method:"POST",headers:r,body:n});if(!i.ok){const a=await i.json().catch(()=>({}));throw new Error(a.detail||`HTTP ${i.status}`)}return i.json()},getProjectAttachmentUrl:(t,e)=>`${en}/projects/${t}/attachments/${encodeURIComponent(e)}`,deleteProjectAttachment:(t,e)=>Re(`/projects/${t}/attachments/${encodeURIComponent(e)}`,{method:"DELETE"}),getProjectBOM:t=>Re(`/projects/${t}/bom`),createBOMItem:(t,e)=>Re(`/projects/${t}/bom`,{method:"POST",body:JSON.stringify(e)}),updateBOMItem:(t,e,n)=>Re(`/projects/${t}/bom/${e}`,{method:"PATCH",body:JSON.stringify(n)}),deleteBOMItem:(t,e)=>Re(`/projects/${t}/bom/${e}`,{method:"DELETE"}),getTemplates:()=>Re("/projects/templates/"),createTemplateFromProject:t=>Re(`/projects/${t}/create-template`,{method:"POST"}),createProjectFromTemplate:(t,e)=>Re(`/projects/from-template/${t}${e?`?name=${encodeURIComponent(e)}`:""}`,{method:"POST"}),getProjectTimeline:(t,e=50)=>Re(`/projects/${t}/timeline?limit=${e}`),exportProjectJson:t=>Re(`/projects/${t}/export?format=json`),importProject:t=>Re("/projects/import",{method:"POST",body:JSON.stringify(t)}),importProjectFile:async t=>{const e=new FormData;e.append("file",t);const n={};tn&&(n.Authorization=`Bearer ${tn}`);const r=await fetch(`${en}/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(`${en}/projects/${t}/export`,{headers:e});if(!n.ok){const l=await n.json().catch(()=>({}));throw new Error(l.detail||`HTTP ${n.status}`)}const a=n.headers.get("Content-Disposition")?.match(/filename="(.+)"/)?.[1]||`project_${t}.zip`;return{blob:await n.blob(),filename:a}},getAPIKeys:()=>Re("/api-keys/"),createAPIKey:t=>Re("/api-keys/",{method:"POST",body:JSON.stringify(t)}),updateAPIKey:(t,e)=>Re(`/api-keys/${t}`,{method:"PATCH",body:JSON.stringify(e)}),deleteAPIKey:t=>Re(`/api-keys/${t}`,{method:"DELETE"}),getAMSHistory:(t,e,n=24)=>Re(`/ams-history/${t}/${e}?hours=${n}`),getSystemInfo:()=>Re("/system/info"),getLibraryFolders:()=>Re("/library/folders"),createLibraryFolder:t=>Re("/library/folders",{method:"POST",body:JSON.stringify(t)}),updateLibraryFolder:(t,e)=>Re(`/library/folders/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFolder:t=>Re(`/library/folders/${t}`,{method:"DELETE"}),getLibraryFoldersByProject:t=>Re(`/library/folders/by-project/${t}`),getLibraryFoldersByArchive:t=>Re(`/library/folders/by-archive/${t}`),getLibraryFiles:(t,e=!0)=>{const n=new URLSearchParams;return t!=null&&n.set("folder_id",String(t)),n.set("include_root",String(e)),Re(`/library/files?${n}`)},getLibraryFile:t=>Re(`/library/files/${t}`),uploadLibraryFile:async(t,e,n=!0)=>{const r=new FormData;r.append("file",t);const i=new URLSearchParams;e&&i.set("folder_id",String(e)),i.set("generate_stl_thumbnails",String(n));const a={};tn&&(a.Authorization=`Bearer ${tn}`);const o=await fetch(`${en}/library/files?${i}`,{method:"POST",headers:a,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 a=new FormData;a.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(`${en}/library/files/extract-zip?${o}`,{method:"POST",headers:l,body:a});if(!c.ok){const u=await c.json().catch(()=>({}));throw new Error(u.detail||`HTTP ${c.status}`)}return c.json()},updateLibraryFile:(t,e)=>Re(`/library/files/${t}`,{method:"PUT",body:JSON.stringify(e)}),deleteLibraryFile:t=>Re(`/library/files/${t}`,{method:"DELETE"}),getLibraryFileDownloadUrl:t=>`${en}/library/files/${t}/download`,downloadLibraryFile:async(t,e)=>{const n={};tn&&(n.Authorization=`Bearer ${tn}`);const r=await fetch(`${en}/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=>`${en}/library/files/${t}/thumbnail`,getLibraryFilePlateThumbnail:(t,e)=>`${en}/library/files/${t}/plate-thumbnail/${e}`,getLibraryFileGcodeUrl:t=>`${en}/library/files/${t}/gcode`,moveLibraryFiles:(t,e)=>Re("/library/files/move",{method:"POST",body:JSON.stringify({file_ids:t,folder_id:e})}),bulkDeleteLibrary:(t,e)=>Re("/library/bulk-delete",{method:"POST",body:JSON.stringify({file_ids:t,folder_ids:e})}),getLibraryStats:()=>Re("/library/stats"),batchGenerateStlThumbnails:t=>Re("/library/generate-stl-thumbnails",{method:"POST",body:JSON.stringify(t)}),addLibraryFilesToQueue:t=>Re("/library/files/add-to-queue",{method:"POST",body:JSON.stringify({file_ids:t})}),printLibraryFile:(t,e,n)=>Re(`/library/files/${t}/print?printer_id=${e}`,{method:"POST",body:n?JSON.stringify(n):void 0}),getLibraryFilePlates:t=>Re(`/library/files/${t}/plates`),getLibraryFileFilamentRequirements:(t,e)=>Re(`/library/files/${t}/filament-requirements${e!==void 0?`?plate_id=${e}`:""}`),getGitHubBackupConfig:()=>Re("/github-backup/config"),saveGitHubBackupConfig:t=>Re("/github-backup/config",{method:"POST",body:JSON.stringify(t)}),updateGitHubBackupConfig:t=>Re("/github-backup/config",{method:"PATCH",body:JSON.stringify(t)}),deleteGitHubBackupConfig:()=>Re("/github-backup/config",{method:"DELETE"}),testGitHubConnection:(t,e)=>Re(`/github-backup/test?repo_url=${encodeURIComponent(t)}&token=${encodeURIComponent(e)}`,{method:"POST"}),testGitHubStoredConnection:()=>Re("/github-backup/test-stored",{method:"POST"}),triggerGitHubBackup:()=>Re("/github-backup/run",{method:"POST"}),getGitHubBackupStatus:()=>Re("/github-backup/status"),getGitHubBackupLogs:(t=50)=>Re(`/github-backup/logs?limit=${t}`),clearGitHubBackupLogs:(t=10)=>Re(`/github-backup/logs?keep_last=${t}`,{method:"DELETE"})},Xl={getInfo:()=>Re("/discovery/info"),getStatus:()=>Re("/discovery/status"),startDiscovery:(t=10)=>Re(`/discovery/start?duration=${t}`,{method:"POST"}),stopDiscovery:()=>Re("/discovery/stop",{method:"POST"}),getDiscoveredPrinters:()=>Re("/discovery/printers"),startSubnetScan:(t,e=1)=>Re("/discovery/scan",{method:"POST",body:JSON.stringify({subnet:t,timeout:e})}),getScanStatus:()=>Re("/discovery/scan/status"),stopSubnetScan:()=>Re("/discovery/scan/stop",{method:"POST"})},g1={getSettings:()=>Re("/settings/virtual-printer"),getModels:()=>Re("/settings/virtual-printer/models"),updateSettings:t=>{const e=new URLSearchParams;return t.enabled!==void 0&&e.set("enabled",String(t.enabled)),t.access_code!==void 0&&e.set("access_code",t.access_code),t.mode!==void 0&&e.set("mode",t.mode),t.model!==void 0&&e.set("model",t.model),t.target_printer_id!==void 0&&e.set("target_printer_id",String(t.target_printer_id)),Re(`/settings/virtual-printer?${e.toString()}`,{method:"PUT"})}},ag={list:()=>Re("/pending-uploads/"),getCount:()=>Re("/pending-uploads/count"),get:t=>Re(`/pending-uploads/${t}`),archive:(t,e)=>Re(`/pending-uploads/${t}/archive`,{method:"POST",body:JSON.stringify(e||{})}),discard:t=>Re(`/pending-uploads/${t}`,{method:"DELETE"}),archiveAll:()=>Re("/pending-uploads/archive-all",{method:"POST"}),discardAll:()=>Re("/pending-uploads/discard-all",{method:"DELETE"})},x1={checkUpdates:()=>Re("/firmware/updates"),checkPrinterUpdate:t=>Re(`/firmware/updates/${t}`),prepareUpload:t=>Re(`/firmware/updates/${t}/prepare`),startUpload:t=>Re(`/firmware/updates/${t}/upload`,{method:"POST"}),getUploadStatus:t=>Re(`/firmware/updates/${t}/upload/status`)},Ng={getDebugLoggingState:()=>Re("/support/debug-logging"),setDebugLogging:t=>Re("/support/debug-logging",{method:"POST",body:JSON.stringify({enabled:t})}),downloadSupportBundle:async()=>{const t={};tn&&(t.Authorization=`Bearer ${tn}`);const e=await fetch(`${en}/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",a=await e.blob(),o=window.URL.createObjectURL(a),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 Re(`/support/logs${n?`?${n}`:""}`)},clearLogs:()=>Re("/support/logs",{method:"DELETE"})},OW=_.createContext(void 0);function Mfe({children:t}){const[e,n]=_.useState(()=>{const E=localStorage.getItem("theme-mode"),R=localStorage.getItem("theme");return E||R||"dark"}),[r,i]=_.useState(()=>localStorage.getItem("dark-style")||"classic"),[a,o]=_.useState(()=>localStorage.getItem("dark-background")||"neutral"),[l,c]=_.useState(()=>localStorage.getItem("dark-accent")||"green"),[u,d]=_.useState(()=>localStorage.getItem("light-style")||"classic"),[f,p]=_.useState(()=>localStorage.getItem("light-background")||"neutral"),[m,x]=_.useState(()=>localStorage.getItem("light-accent")||"green");_.useEffect(()=>{ce.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-${a}`),E.classList.add(`accent-${l}`)):(E.classList.add(`style-${u}`),E.classList.add(`bg-${f}`),E.classList.add(`accent-${m}`)),localStorage.setItem("theme-mode",e),localStorage.removeItem("theme")},[e,r,a,l,u,f,m]);const b=()=>n(E=>E==="dark"?"light":"dark"),v=E=>n(E),y=E=>{i(E),localStorage.setItem("dark-style",E),ce.updateSettings({dark_style:E}).catch(()=>{})},S=E=>{o(E),localStorage.setItem("dark-background",E),ce.updateSettings({dark_background:E}).catch(()=>{})},k=E=>{c(E),localStorage.setItem("dark-accent",E),ce.updateSettings({dark_accent:E}).catch(()=>{})},T=E=>{d(E),localStorage.setItem("light-style",E),ce.updateSettings({light_style:E}).catch(()=>{})},M=E=>{p(E),localStorage.setItem("light-background",E),ce.updateSettings({light_background:E}).catch(()=>{})},C=E=>{x(E),localStorage.setItem("light-accent",E),ce.updateSettings({light_accent:E}).catch(()=>{})};return s.jsx(OW.Provider,{value:{mode:e,darkStyle:r,darkBackground:a,darkAccent:l,lightStyle:u,lightBackground:f,lightAccent:m,toggleMode:b,setMode:v,setDarkStyle:y,setDarkBackground:S,setDarkAccent:k,setLightStyle:T,setLightBackground:M,setLightAccent:C},children:t})}function Oh(){const t=_.useContext(OW);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 s.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 s.jsx("div",{className:`px-6 py-4 border-b border-bambu-dark-tertiary ${e}`,children:t})}function Nt({children:t,className:e=""}){return s.jsx("div",{className:`p-6 ${e}`,children:t})}function kfe(t,e,n){return[{category:"Navigation",items:t?t.slice(0,9).map((i,a)=>({keys:[String(a+1)],description:i.type==="external"?`Open ${i.label}`:`Go to ${i.labelKey?n(i.labelKey):i.label}`,isExternal:i.type==="external"})):e?e.map((i,a)=>({keys:[String(a+1)],description:`Go to ${n(i.labelKey)}`,isExternal:!1})):[{keys:["1"],description:"Go to Printers",isExternal:!1},{keys:["2"],description:"Go to Archives",isExternal:!1},{keys:["3"],description:"Go to Queue",isExternal:!1},{keys:["4"],description:"Go to Statistics",isExternal:!1},{keys:["5"],description:"Go to Cloud Profiles",isExternal:!1},{keys:["6"],description:"Go to Settings",isExternal:!1}]},{category:"Archives",items:[{keys:["/"],description:"Focus search",isExternal:!1},{keys:["U"],description:"Open upload modal",isExternal:!1},{keys:["Esc"],description:"Clear selection / blur input",isExternal:!1},{keys:["Right-click"],description:"Context menu on cards",isExternal:!1}]},{category:"K-Profiles",items:[{keys:["R"],description:"Refresh profiles",isExternal:!1},{keys:["N"],description:"New profile",isExternal:!1},{keys:["Esc"],description:"Exit selection mode",isExternal:!1}]},{category:"General",items:[{keys:["?"],description:"Show this help",isExternal:!1}]}]}function Iz({children:t}){return s.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 Efe({onClose:t,navItems:e,sidebarItems:n}){const{t:r}=Rn(),i=kfe(n,e,r);return _.useEffect(()=>{const a=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:t,children:s.jsx(St,{className:"w-full max-w-md",onClick:a=>a.stopPropagation(),children:s.jsxs(Nt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mj,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Keyboard Shortcuts"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4 space-y-6 max-h-[60vh] overflow-y-auto",children:i.map(a=>s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-3",children:a.category}),s.jsx("div",{className:"space-y-2",children:a.items.map(o=>s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-white text-sm flex items-center gap-1.5",children:[o.description,o.isExternal&&s.jsx(Xr,{className:"w-3 h-3 text-bambu-gray"})]}),s.jsx("div",{className:"flex gap-1",children:o.keys.map(l=>s.jsx(Iz,{children:l},l))})]},o.description))})]},a.category))}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsxs("p",{className:"text-xs text-bambu-gray text-center",children:["Press ",s.jsx(Iz,{children:"Esc"})," or click outside to close"]})})]})})})}function Te({variant:t="primary",size:e="md",className:n="",children:r,...i}){const a="inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-bambu-dark disabled:opacity-50 disabled:cursor-not-allowed",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 s.jsx("button",{className:`${a} ${o[t]} ${l[e]} ${n}`,...i,children:r})}function Zn({title:t,message:e,confirmText:n,cancelText:r,variant:i="default",isLoading:a=!1,loadingText:o,onConfirm:l,onCancel:c}){const{t:u}=Rn(),d=n??u("common.confirm"),f=r??u("common.cancel"),p=o??u("common.loading");_.useEffect(()=>{const b=v=>{v.key==="Escape"&&!a&&c()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[c,a]);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 s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:a?void 0:c,children:s.jsx(St,{className:"w-full max-w-md",onClick:b=>b.stopPropagation(),children:s.jsxs(Nt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsx("div",{className:`p-2 rounded-full bg-bambu-dark ${x.icon}`,children:s.jsx(Sn,{className:"w-6 h-6"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t}),s.jsx("p",{className:"text-bambu-gray text-sm",children:e})]})]}),s.jsxs("div",{className:"flex gap-3 mt-6",children:[s.jsx(Te,{variant:"secondary",onClick:c,className:"flex-1",disabled:a,children:f}),s.jsx(Te,{onClick:l,className:`flex-1 ${x.button}`,disabled:a,children:a?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}),p]}):d})]})]})})})}function Tfe({plug:t}){const e=sn(),[n,r]=_.useState(null),{data:i,isLoading:a}=ot({queryKey:["smart-plug-status",t.id],queryFn:()=>ce.getSmartPlugStatus(t.id),refetchInterval:1e4}),o=mt({mutationFn:m=>ce.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,f=t.plug_type==="mqtt",p=()=>{n&&(o.mutate(n),r(null))};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between py-2 px-3 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:`p-1.5 rounded ${f?u?"bg-teal-500/20":"bg-red-500/20":u?l?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:f?s.jsx(PR,{className:`w-4 h-4 ${u?"text-teal-400":"text-red-400"}`}):s.jsx(tl,{className:`w-4 h-4 ${u?l?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white font-medium",children:t.name}),s.jsx("div",{className:"flex items-center gap-1 text-xs",children:a?s.jsx(ft,{className:"w-3 h-3 text-bambu-gray animate-spin"}):f?u?s.jsxs(s.Fragment,{children:[s.jsx(vh,{className:"w-3 h-3 text-teal-400"}),s.jsxs("span",{className:"text-teal-400",children:[Math.round(i?.energy?.power??0),"W"]}),s.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),s.jsx(mc,{className:"w-3 h-3 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:"Monitor"})]}):s.jsxs(s.Fragment,{children:[s.jsx(sm,{className:"w-3 h-3 text-status-error"}),s.jsx("span",{className:"text-status-error",children:"Waiting"})]}):u?s.jsxs(s.Fragment,{children:[s.jsx(Sg,{className:"w-3 h-3 text-status-ok"}),s.jsx("span",{className:l?"text-status-ok":"text-bambu-gray",children:i?.state||"Unknown"}),i?.energy?.power!==null&&i?.energy?.power!==void 0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-bambu-gray mx-1",children:"|"}),s.jsx(vh,{className:"w-3 h-3 text-yellow-400"}),s.jsxs("span",{className:"text-yellow-400",children:[Math.round(i.energy.power),"W"]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(sm,{className:"w-3 h-3 text-status-error"}),s.jsx("span",{className:"text-status-error",children:"Offline"})]})})]})]}),!f&&s.jsxs("div",{className:"flex gap-1",children:[s.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?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Gu,{className:"w-4 h-4"})}),s.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?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(gM,{className:"w-4 h-4"})})]})]}),n&&s.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 Uz({onClose:t}){const{data:e,isLoading:n}=ot({queryKey:["smart-plugs"],queryFn:ce.getSmartPlugs}),r=e?.filter(i=>i.show_in_switchbar)||[];return s.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:[s.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary",children:s.jsxs("h3",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[s.jsx(tl,{className:"w-4 h-4 text-bambu-green"}),"Smart Switches"]})}),s.jsx("div",{className:"p-2 max-h-80 overflow-y-auto",children:n?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-gray animate-spin"})}):r.length===0?s.jsxs("div",{className:"text-center py-6 px-4",children:[s.jsx(tl,{className:"w-8 h-8 text-bambu-gray mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"No switches in switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:'Enable "Show in Switchbar" in Settings > Smart Plugs'})]}):s.jsx("div",{className:"space-y-1",children:r.map(i=>s.jsx(Tfe,{plug:i},i.id))})})]})}const LW=[{name:"globe",icon:sh},{name:"link",icon:Iy},{name:"external-link",icon:Xr},{name:"book",icon:Nce},{name:"file-text",icon:Ls},{name:"home",icon:Fy},{name:"star",icon:im},{name:"heart",icon:cde},{name:"bookmark",icon:kce},{name:"shopping-cart",icon:AW},{name:"music",icon:bj},{name:"video",icon:OR},{name:"image",icon:Ou},{name:"camera",icon:Ug},{name:"map",icon:Ode},{name:"compass",icon:fue},{name:"coffee",icon:cue},{name:"gift",icon:Que},{name:"wrench",icon:om},{name:"zap",icon:vh},{name:"cloud",icon:lM},{name:"database",icon:ku},{name:"folder",icon:wW},{name:"mail",icon:Dde},{name:"phone",icon:ahe},{name:"user",icon:am},{name:"users",icon:mg},{name:"server",icon:yf},{name:"terminal",icon:jW},{name:"code",icon:yW}];function yM(t){return LW.find(n=>n.name===t)?.icon||Iy}function Afe({value:t,onChange:e}){const[n,r]=_.useState(!1),i=yM(t);return s.jsxs("div",{className:"relative",children:[s.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:[s.jsx(i,{className:"w-5 h-5"}),s.jsx("span",{className:"text-sm text-bambu-gray flex-1 text-left",children:t})]}),n&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>r(!1)}),s.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:s.jsx("div",{className:"grid grid-cols-5 gap-1 p-2",children:LW.map(({name:a,icon:o})=>s.jsx("button",{type:"button",onClick:()=>{e(a),r(!1)},className:`p-2 rounded-lg transition-colors flex items-center justify-center ${t===a?"bg-bambu-green text-white":"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,title:a,children:s.jsx(o,{className:"w-5 h-5"})},a))})})]})]})}const zz=768;function IR(){const[t,e]=_.useState(()=>typeof window<"u"?window.innerWidth<zz:!1);return _.useEffect(()=>{const n=window.matchMedia(`(max-width: ${zz-1}px)`),r=i=>{e(i.matches)};return e(n.matches),n.addEventListener("change",r),()=>n.removeEventListener("change",r)},[]),t}const FW=_.createContext(void 0);function Cfe({children:t}){const[e,n]=_.useState(null),[r,i]=_.useState(!1),[a,o]=_.useState(!1),[l,c]=_.useState(!0),u=_.useRef(!1),d=_.useRef(!0),f=async()=>{try{const C=await ce.getAuthStatus();if(!d.current)return;if(i(C.auth_enabled),o(C.requires_setup),C.auth_enabled)if(Fz())try{const R=await ce.getCurrentUser();if(!d.current)return;n(R)}catch{if(r0(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,f(),()=>{d.current=!1}),[]),_.useEffect(()=>{if(!l&&a&&!r){const C=window.location.pathname;C!=="/setup"&&!C.startsWith("/camera/")&&!u.current&&(u.current=!0,window.location.href="/setup")}else a||(u.current=!1)},[l,a,r]);const p=async(C,E)=>{const R=await ce.login({username:C,password:E});r0(R.access_token),n(R.user)},m=()=>{r0(null),n(null),ce.logout().catch(()=>{}),window.location.href="/login"},x=async()=>{if(r&&Fz())try{const C=await ce.getCurrentUser();d.current&&n(C)}catch{r0(null),d.current&&n(null)}},b=async()=>{await f()},v=_.useMemo(()=>new Set(e?.permissions??[]),[e?.permissions]),y=_.useMemo(()=>r?e?.is_admin??!1:!0,[r,e?.is_admin]),S=_.useCallback(C=>!r||y?!0:v.has(C),[r,y,v]),k=_.useCallback((...C)=>!r||y?!0:C.some(E=>v.has(E)),[r,y,v]),T=_.useCallback((...C)=>!r||y?!0:C.every(E=>v.has(E)),[r,y,v]),M=_.useCallback((C,E,R)=>{if(!r||y)return!0;const A=`${C}:${E}_all`,D=`${C}:${E}_own`;return v.has(A)?!0:v.has(D)?R==null?!1:R===e?.id:!1},[r,y,v,e?.id]);return s.jsx(FW.Provider,{value:{user:e,authEnabled:r,requiresSetup:a,loading:l,isAdmin:y,login:p,logout:m,refreshUser:x,refreshAuth:b,hasPermission:S,hasAnyPermission:k,hasAllPermissions:T,canModify:M},children:t})}function Ci(){const t=_.useContext(FW);if(t===void 0)throw new Error("useAuth must be used within an AuthProvider");return t}const IW=_.createContext(void 0);function Hn(){const t=_.useContext(IW);if(!t)throw new Error("useToast must be used within a ToastProvider");return t}const Pfe={success:s.jsx(Ar,{className:"w-5 h-5 text-green-400"}),error:s.jsx(Qi,{className:"w-5 h-5 text-red-400"}),warning:s.jsx($i,{className:"w-5 h-5 text-yellow-400"}),info:s.jsx(Zo,{className:"w-5 h-5 text-blue-400"}),loading:s.jsx(ft,{className:"w-5 h-5 text-bambu-green animate-spin"})},jfe={success:"bg-green-500/10 border-green-500/30",error:"bg-red-500/10 border-red-500/30",warning:"bg-yellow-500/10 border-yellow-500/30",info:"bg-blue-500/10 border-blue-500/30",loading:"bg-bambu-green/10 border-bambu-green/30"};function Dfe({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(f=>[...f,{id:u,message:l,type:c}]);const d=setTimeout(()=>{n(f=>f.filter(p=>p.id!==u)),r.current.delete(u)},3e3);r.current.set(u,d)},[]),a=_.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 s.jsxs(IW.Provider,{value:{showToast:i,showPersistentToast:a,dismissToast:o},children:[t,s.jsx("div",{className:"fixed bottom-4 right-4 z-50 flex flex-col gap-2",children:e.map(l=>s.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border shadow-lg backdrop-blur-sm animate-slide-in ${jfe[l.type]}`,children:[Pfe[l.type],s.jsx("span",{className:"text-white text-sm",children:l.message}),s.jsx("button",{onClick:()=>o(l.id),className:"ml-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-4 h-4"})})]},l.id))})]})}const K0=[{id:"printers",to:"/",icon:Ur,labelKey:"nav.printers"},{id:"archives",to:"/archives",icon:ho,labelKey:"nav.archives"},{id:"queue",to:"/queue",icon:ti,labelKey:"nav.queue"},{id:"stats",to:"/stats",icon:Uce,labelKey:"nav.stats"},{id:"profiles",to:"/profiles",icon:lM,labelKey:"nav.profiles"},{id:"maintenance",to:"/maintenance",icon:om,labelKey:"nav.maintenance"},{id:"projects",to:"/projects",icon:Ja,labelKey:"nav.projects"},{id:"files",to:"/files",icon:Il,labelKey:"nav.files"},{id:"settings",to:"/settings",icon:xM,labelKey:"nav.settings"}];function Rfe(){const t=localStorage.getItem("sidebarOrder");if(t)try{return JSON.parse(t)}catch{return K0.map(e=>e.id)}return K0.map(e=>e.id)}function Ofe(t){localStorage.setItem("sidebarOrder",JSON.stringify(t))}function iT(t){return t.startsWith("ext-")}function UW(){return localStorage.getItem("defaultView")||"/"}function Lfe(t){localStorage.setItem("defaultView",t)}function Ffe(){const t=kc(),e=Mc(),{mode:n,toggleMode:r}=Oh(),{t:i}=Rn(),a=IR(),{user:o,authEnabled:l,logout:c,hasPermission:u}=Ci(),{showToast:d}=Hn(),[f,p]=_.useState(!1),[m,x]=_.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[b,v]=_.useState(!1),[y,S]=_.useState(()=>localStorage.getItem("sidebarExpanded")!=="false"),[k,T]=_.useState(!1),[M,C]=_.useState(!1),[E,R]=_.useState(!1),[A,D]=_.useState(Rfe),[I,F]=_.useState(null),[z,P]=_.useState(null),$=_.useRef(!1),[X,V]=_.useState(()=>sessionStorage.getItem("dismissedUpdateVersion")),[Q,Z]=_.useState(null),{data:se}=ot({queryKey:["version"],queryFn:ce.getVersion,staleTime:1/0}),{data:H}=ot({queryKey:["settings"],queryFn:ce.getSettings,staleTime:300*1e3}),{data:K}=ot({queryKey:["updateCheck"],queryFn:ce.checkForUpdates,enabled:H?.check_updates!==!1,staleTime:3600*1e3,refetchInterval:3600*1e3}),{data:re}=ot({queryKey:["external-links"],queryFn:ce.getExternalLinks}),{data:ne}=ot({queryKey:["smart-plugs"],queryFn:ce.getSmartPlugs,staleTime:30*1e3}),be=ne?.some(O=>O.show_in_switchbar)??!1,{data:me}=ot({queryKey:["debugLogging"],queryFn:Ng.getDebugLoggingState,staleTime:60*1e3,refetchInterval:60*1e3}),{data:de}=ot({queryKey:["queue","pending"],queryFn:()=>ce.getQueue(void 0,"pending"),staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),Ce=de?.length??0,{data:ie}=ot({queryKey:["pending-uploads","count"],queryFn:ag.getCount,staleTime:5*1e3,refetchInterval:5*1e3,refetchOnWindowFocus:!0}),ke=ie?.count??0,[Oe,pe]=_.useState(null);_.useEffect(()=>{if(!me?.enabled||!me.enabled_at){pe(null);return}const O=new Date(me.enabled_at).getTime(),ee=()=>{pe(Math.floor((Date.now()-O)/1e3))};ee();const le=setInterval(ee,1e3);return()=>clearInterval(le)},[me?.enabled,me?.enabled_at]);const We=_.useMemo(()=>new Map(K0.map(O=>[O.id,O])),[]),G=_.useMemo(()=>new Map((re||[]).map(O=>[`ext-${O.id}`,O])),[re]),Y=(()=>{const O=[],ee=new Set,le=l&&o?.role==="user";for(const _e of A)le&&_e==="settings"||(We.has(_e)||G.has(_e))&&(O.push(_e),ee.add(_e));for(const _e of K0)le&&_e.id==="settings"||ee.has(_e.id)||(O.push(_e.id),ee.add(_e.id));for(const _e of re||[]){const ve=`ext-${_e.id}`;ee.has(ve)||(O.push(ve),ee.add(ve))}return O})(),ue=(O,ee)=>{F(ee),O.dataTransfer.effectAllowed="move",O.dataTransfer.setData("text/plain",ee)},q=(O,ee)=>{O.preventDefault(),O.dataTransfer.dropEffect="move",P(ee)},te=()=>{P(null)},U=(O,ee)=>{if(O.preventDefault(),I===null||I===ee){F(null),P(null);return}const le=[...Y],_e=le.indexOf(I),ve=le.indexOf(ee);if(_e===-1||ve===-1){F(null),P(null);return}le.splice(_e,1),le.splice(ve,0,I),D(le),Ofe(le),F(null),P(null)},he=()=>{F(null),P(null)},Me=K?.update_available&&K.latest_version&&K.latest_version!==X,ge=()=>{K?.latest_version&&(sessionStorage.setItem("dismissedUpdateVersion",K.latest_version),V(K.latest_version))};_.useEffect(()=>{if(!$.current&&e.pathname==="/"){const O=UW();O!=="/"&&($.current=!0,t(O,{replace:!0}))}},[e.pathname,t]),_.useEffect(()=>{localStorage.setItem("sidebarExpanded",String(y))},[y]),_.useEffect(()=>{a&&T(!1)},[e.pathname,a]),_.useEffect(()=>{const O=ee=>{const le=ee.detail;Z({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 B=_.useCallback(O=>{const ee=O.target;if(!(ee.tagName==="INPUT"||ee.tagName==="TEXTAREA"||ee.isContentEditable)&&!O.metaKey&&!O.ctrlKey&&!O.altKey){const le=parseInt(O.key);if(le>=1&&le<=Y.length&&le<=9){const _e=Y[le-1];if(O.preventDefault(),iT(_e)){const ve=_e.replace("ext-","");t(`/external/${ve}`)}else{const ve=We.get(_e);ve&&t(ve.to)}return}switch(O.key){case"?":O.preventDefault(),C(!0);break;case"Escape":C(!1);break}}},[t,Y,We]);return _.useEffect(()=>(document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)),[B]),s.jsxs("div",{className:"flex min-h-screen",children:[a&&s.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:[s.jsx("button",{onClick:()=>T(!0),className:"p-2 -ml-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors","aria-label":"Open menu",children:s.jsx(Hde,{className:"w-6 h-6 text-white"})}),s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-8 ml-3"})]}),a&&k&&s.jsx("div",{className:"fixed inset-0 bg-black/60 z-40 transition-opacity",onClick:()=>T(!1)}),s.jsxs("aside",{className:`bg-bambu-dark-secondary border-r border-bambu-dark-tertiary flex flex-col transition-all duration-300 ${a?`fixed inset-y-0 left-0 z-50 w-72 transform ${k?"translate-x-0":"-translate-x-full"}`:`fixed inset-y-0 left-0 z-30 ${y?"w-64":"w-16"}`}`,children:[s.jsx("div",{className:`border-b border-bambu-dark-tertiary flex items-center justify-center ${a||y?"p-4":"p-2"}`,children:s.jsx("img",{src:n==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:a||y?"h-16 w-auto":"h-8 w-8 object-cover object-left"})}),s.jsx("nav",{className:"flex-1 p-2",children:s.jsx("ul",{className:"space-y-2",children:Y.map(O=>{if(iT(O)){const le=G.get(O);if(!le)return null;const _e=le.custom_icon?null:yM(le.icon);return s.jsx("li",{draggable:!0,onDragStart:ve=>ue(ve,O),onDragOver:ve=>q(ve,O),onDragLeave:te,onDrop:ve=>U(ve,O),onDragEnd:he,className:`relative ${I===O?"opacity-50":""} ${z===O&&I!==O?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(n0,{to:`/external/${le.id}`,className:({isActive:ve})=>`flex items-center ${a||y?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${ve?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!y?le.name:void 0,children:[y&&!a&&s.jsx(zg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),le.custom_icon?s.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"}`}):_e&&s.jsx(_e,{className:"w-5 h-5 flex-shrink-0"}),(a||y)&&s.jsx("span",{children:le.name})]})},O)}else{const le=We.get(O);if(!le)return null;const{to:_e,icon:ve,labelKey:ae}=le,Fe=O==="queue"&&Ce>0,Be=O==="archives"&&ke>0,$e=Fe?Ce:Be?ke:0,He=Fe||Be;return s.jsx("li",{draggable:!0,onDragStart:xe=>ue(xe,O),onDragOver:xe=>q(xe,O),onDragLeave:te,onDrop:xe=>U(xe,O),onDragEnd:he,className:`relative ${I===O?"opacity-50":""} ${z===O&&I!==O?"before:absolute before:left-0 before:right-0 before:top-0 before:h-0.5 before:bg-bambu-green":""}`,children:s.jsxs(n0,{to:_e,className:({isActive:xe})=>`flex items-center ${a||y?"gap-3 px-4":"justify-center px-2"} py-3 rounded-lg transition-colors group ${xe?"bg-bambu-green text-white":"text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white"}`,title:!a&&!y?i(ae):void 0,children:[y&&!a&&s.jsx(zg,{className:"w-4 h-4 flex-shrink-0 opacity-0 group-hover:opacity-50 cursor-grab active:cursor-grabbing -ml-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(ve,{className:"w-5 h-5 flex-shrink-0"}),He&&s.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:$e>99?"99+":$e})]}),(a||y)&&s.jsx("span",{children:i(ae)})]})},O)}})})}),!a&&s.jsx("button",{onClick:()=>S(!y),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(y?"nav.collapseSidebar":"nav.expandSidebar"),children:y?s.jsx(gh,{className:"w-5 h-5"}):s.jsx(gs,{className:"w-5 h-5"})}),s.jsx("div",{className:"p-2 border-t border-bambu-dark-tertiary",children:a||y?s.jsxs("div",{className:"flex flex-col gap-2 px-2",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[be&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>R(!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:s.jsx(tl,{className:"w-5 h-5"})}),E&&s.jsx(Uz,{onClose:()=>R(!1)})]}),u("system:read")?s.jsx(n0,{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:s.jsx(Zo,{className:"w-5 h-5"})}):s.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:s.jsx(Zo,{className:"w-5 h-5"})}),s.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:s.jsx(fj,{className:"w-5 h-5"})}),s.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:s.jsx(mj,{className:"w-5 h-5"})}),s.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"?s.jsx(Lz,{className:"w-5 h-5"}):s.jsx(K1,{className:"w-5 h-5"})}),l&&o&&s.jsxs(s.Fragment,{children:[s.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:s.jsx($o,{className:"w-5 h-5"})}),s.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:s.jsx(gj,{className:"w-5 h-5"})})]})]}),s.jsxs("div",{className:"flex items-center justify-center gap-2",children:[s.jsxs("span",{className:"text-sm text-bambu-gray",children:["v",se?.version||"..."]}),K?.update_available&&s.jsxs("button",{onClick:()=>t("/settings"),className:"flex items-center gap-1 text-xs text-bambu-green hover:text-bambu-green/80 transition-colors",title:i("nav.updateAvailable",{version:K.latest_version}),children:[s.jsx(JE,{className:"w-4 h-4"}),s.jsx("span",{children:i("nav.update")})]})]})]}):s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[K?.update_available&&s.jsx("button",{onClick:()=>t("/settings"),className:"p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors text-bambu-green hover:text-bambu-green/80",title:i("nav.updateAvailable",{version:K.latest_version}),children:s.jsx(JE,{className:"w-5 h-5"})}),be&&s.jsxs("div",{className:"relative",children:[s.jsx("button",{onMouseEnter:()=>R(!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:s.jsx(tl,{className:"w-5 h-5"})}),E&&s.jsx(Uz,{onClose:()=>R(!1)})]}),u("system:read")?s.jsx(n0,{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:s.jsx(Zo,{className:"w-5 h-5"})}):s.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:s.jsx(Zo,{className:"w-5 h-5"})}),s.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:s.jsx(fj,{className:"w-5 h-5"})}),s.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:s.jsx(mj,{className:"w-5 h-5"})}),s.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"?s.jsx(Lz,{className:"w-5 h-5"}):s.jsx(K1,{className:"w-5 h-5"})}),l&&o&&s.jsxs(s.Fragment,{children:[s.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:s.jsx($o,{className:"w-5 h-5"})}),s.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:s.jsx(gj,{className:"w-5 h-5"})})]})]})})]}),s.jsxs("main",{className:`flex-1 bg-bambu-dark overflow-auto transition-all duration-300 ${a?"mt-14":y?"ml-64":"ml-16"}`,children:[me?.enabled&&s.jsx("div",{className:"bg-amber-500/20 border-b border-amber-500/30 px-4 py-2 flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(sM,{className:"w-4 h-4 text-amber-500 animate-pulse"}),s.jsxs("span",{className:"text-amber-200",children:[i("support.debugLoggingActive",{defaultValue:"Debug logging is active"}),Oe!==null&&s.jsxs("span",{className:"text-amber-300/70 ml-2",children:["(",Math.floor(Oe/60),"m ",Oe%60,"s)"]})]}),s.jsx("button",{onClick:()=>t("/system"),className:"text-amber-400 hover:text-amber-300 font-medium underline ml-2",children:i("support.manageLogs",{defaultValue:"Manage"})})]})}),Me&&s.jsxs("div",{className:"bg-bambu-green/20 border-b border-bambu-green/30 px-4 py-2 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(JE,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{children:i("nav.updateAvailableBanner",{version:K?.latest_version,defaultValue:`Version ${K?.latest_version} is available!`})}),s.jsx("button",{onClick:()=>t("/settings"),className:"text-bambu-green hover:text-bambu-green/80 font-medium underline",children:i("nav.viewUpdate",{defaultValue:"View update"})})]}),s.jsx("button",{onClick:ge,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:i("common.dismiss",{defaultValue:"Dismiss"}),children:s.jsx(Rt,{className:"w-4 h-4"})})]}),s.jsx(Voe,{})]}),M&&s.jsx(Efe,{onClose:()=>C(!1),sidebarItems:Y.map(O=>{if(iT(O)){const ee=G.get(O);return ee?{type:"external",label:ee.name}:null}else{const ee=We.get(O);return ee?{type:"nav",label:ee.labelKey,labelKey:ee.labelKey}:null}}).filter(Boolean)}),Q&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[100] p-4",children:s.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:s.jsxs("div",{className:"p-6 text-center",children:[s.jsx("div",{className:"w-16 h-16 mx-auto mb-4 rounded-full bg-yellow-500/20 flex items-center justify-center",children:s.jsx("svg",{className:"w-10 h-10 text-yellow-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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"})})}),s.jsx("h2",{className:"text-xl font-bold text-yellow-400 mb-2",children:i("plateAlert.title")}),s.jsx("p",{className:"text-lg text-white mb-2",children:Q.printer_name}),s.jsx("p",{className:"text-bambu-gray mb-6",children:i("plateAlert.message")}),s.jsx("button",{onClick:()=>Z(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")})]})})}),f&&s.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:s.jsxs(St,{className:"w-full max-w-md",onClick:O=>O.stopPropagation(),children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($o,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("changePassword.title")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:s.jsx(Rt,{className:"w-5 h-5"})})]})}),s.jsxs(Nt,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.currentPassword")}),s.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.newPassword")}),s.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("changePassword.confirmPassword")}),s.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&&s.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("changePassword.passwordsDoNotMatch")})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})},children:i("common.cancel")}),s.jsx(Te,{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 ce.changePassword(m.currentPassword,m.newPassword),d(i("changePassword.success"),"success"),p(!1),x({currentPassword:"",newPassword:"",confirmPassword:""})}catch(O){const ee=O instanceof Error?O.message:i("changePassword.failed");d(ee,"error")}finally{v(!1)}},disabled:b||!m.currentPassword||!m.newPassword||m.newPassword!==m.confirmPassword||m.newPassword.length<6,children:b?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),i("changePassword.changing")]}):s.jsxs(s.Fragment,{children:[s.jsx($o,{className:"w-4 h-4"}),i("changePassword.title")]})})]})]})]})})]})}function Ife(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 Ufe(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 Bz(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 Hz(t,e="system"){const n=t.getHours(),r=String(t.getMinutes()).padStart(2,"0");switch(e){case"12h":{const i=n%12||12,a=n<12?"AM":"PM";return`${i}:${r} ${a}`}case"24h":return`${String(n).padStart(2,"0")}:${r}`;case"system":default:return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}}function zfe(t,e="system"){if(!t)return null;let n,r,i;try{switch(e){case"us":{const a=t.split("/");if(a.length!==3)return null;r=parseInt(a[0],10),n=parseInt(a[1],10),i=parseInt(a[2],10);break}case"eu":{const a=t.split("/");if(a.length!==3)return null;n=parseInt(a[0],10),r=parseInt(a[1],10),i=parseInt(a[2],10);break}case"iso":{const a=t.split("-");if(a.length!==3)return null;i=parseInt(a[0],10),r=parseInt(a[1],10),n=parseInt(a[2],10);break}case"system":default:{const a=new Date(t);if(!isNaN(a.getTime()))return a;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 Bfe(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 a=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||a<0||a>59?null:{hours:i,minutes:a}}const r=e.match(/^(\d{1,2}):(\d{2})$/);if(r){const i=parseInt(r[1],10),a=parseInt(r[2],10);return i<0||i>23||a<0||a>59?null:{hours:i,minutes:a}}return null}catch{return null}}function $z(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"),a=String(t.getMinutes()).padStart(2,"0");return`${e}-${n}-${r}T${i}:${a}`}function y0(t,e="system"){return e==="12h"?t.hour12=!0:e==="24h"&&(t.hour12=!1),t}function Ui(t){return t?t.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(t)?new Date(t):new Date(t+"Z"):null}function Bg(t,e){const n=Ui(t);if(!n)return"";const r={year:"numeric",month:"short",day:"numeric"};return n.toLocaleDateString(void 0,e??r)}function Hg(t,e="system",n){const r=Ui(t);if(!r)return"";const a=y0(n??{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},e);return r.toLocaleString(void 0,a)}function Hfe(t,e="system",n){const i=y0({...{hour:"2-digit",minute:"2-digit"},...n},e);return t.toLocaleTimeString([],i)}function $fe(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 Vz(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 Vfe(t,e){if(e)return wW;switch(t.toLowerCase().split(".").pop()||""){case"3mf":return zf;case"gcode":return Ls;case"mp4":case"avi":return ah;case"png":case"jpg":case"jpeg":return Ou;default:return uM}}const Gfe=[{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 qfe({printerId:t,printerName:e,onClose:n}){const{t:r}=Rn(),{showToast:i}=Hn(),a=sn(),[o,l]=_.useState("/"),[c,u]=_.useState(new Set),[d,f]=_.useState(""),[p,m]=_.useState([]),[x,b]=_.useState("name-asc"),[v,y]=_.useState(null);_.useEffect(()=>{const $=X=>{X.key==="Escape"&&n()};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[n]);const{data:S,isLoading:k,refetch:T}=ot({queryKey:["printerFiles",t,o],queryFn:()=>ce.getPrinterFiles(t,o)}),{data:M}=ot({queryKey:["printerStorage",t],queryFn:()=>ce.getPrinterStorage(t),staleTime:3e4}),C=mt({mutationFn:async $=>{for(const X of $)await ce.deletePrinterFile(t,X)},onSuccess:()=>{i(r("printerFiles.toast.filesDeleted",{count:p.length})),a.invalidateQueries({queryKey:["printerFiles",t]}),u(new Set),m([])},onError:$=>{i(r("printerFiles.toast.deleteFailed",{error:$.message}),"error")}}),E=$=>{l($),u(new Set)},R=()=>{if(o==="/")return;const $=o.split("/").filter(Boolean);$.pop(),l($.length?"/"+$.join("/"):"/"),u(new Set)},A=($,X)=>{X.stopPropagation(),u(V=>{const Q=new Set(V);return Q.has($)?Q.delete($):Q.add($),Q})},D=()=>{if(!S?.files)return;const $=S.files.filter(X=>!X.is_directory&&(!d||X.name.toLowerCase().includes(d.toLowerCase()))).map(X=>X.path);u(new Set($))},I=()=>{u(new Set)},F=async()=>{if(c.size===0)return;const $=Array.from(c);if($.length===1){ce.downloadPrinterFile(t,$[0]).catch(X=>{console.error("Printer file download failed:",X)}),u(new Set);return}y({current:0,total:$.length});try{const X=await ce.downloadPrinterFilesAsZip(t,$),V=URL.createObjectURL(X),Q=document.createElement("a");Q.href=V,Q.download=`${e.replace(/[^a-zA-Z0-9]/g,"_")}-files.zip`,document.body.appendChild(Q),Q.click(),document.body.removeChild(Q),URL.revokeObjectURL(V),i(`Downloaded ${$.length} files as ZIP`),u(new Set)}catch(X){i(`Download failed: ${X instanceof Error?X.message:"Unknown error"}`,"error")}finally{y(null)}},z=()=>{c.size!==0&&m(Array.from(c))},P=[{path:"/",label:"Root"},{path:"/cache",label:"Cache"},{path:"/model",label:"Models"},{path:"/timelapse",label:"Timelapse"}];return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:n,children:[s.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:$=>$.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(fM,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r("printerFiles.title")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[M&&(M.used_bytes!=null||M.free_bytes!=null)&&s.jsxs("div",{className:"text-sm text-bambu-gray flex items-center gap-2",children:[M.used_bytes!=null&&s.jsxs("span",{children:[r("printerFiles.storageUsed")," ",Vz(M.used_bytes)]}),M.used_bytes!=null&&M.free_bytes!=null&&s.jsx("span",{className:"text-bambu-dark-tertiary",children:"|"}),M.free_bytes!=null&&s.jsxs("span",{children:[r("printerFiles.storageFree")," ",Vz(M.free_bytes)]})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]})]}),s.jsxs("div",{className:"flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[P.map($=>s.jsx("button",{onClick:()=>{E($.path),f("")},className:`px-3 py-1 text-sm rounded-full transition-colors ${o===$.path?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:$.label},$.path)),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"relative",children:[s.jsx(ya,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:r("printerFiles.filterPlaceholder"),value:d,onChange:$=>f($.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"})]}),s.jsxs("div",{className:"relative flex items-center gap-1",children:[s.jsx(xW,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("select",{value:x,onChange:$=>b($.target.value),className:"appearance-none bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm py-1.5 pl-2 pr-6 focus:border-bambu-green focus:outline-none cursor-pointer",children:Gfe.map($=>s.jsx("option",{value:$.value,children:$.label},$.value))})]}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>T(),disabled:k,children:s.jsx(Dr,{className:`w-4 h-4 ${k?"animate-spin":""}`})})]}),s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0",children:[s.jsx("button",{onClick:R,disabled:o==="/",className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed",children:s.jsx(gh,{className:"w-4 h-4"})}),s.jsx("span",{className:"text-bambu-gray font-mono",children:o})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-2 min-h-0",children:k?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):S?.files?.length?s.jsx("div",{className:"space-y-1",children:[...S.files].filter($=>!d||$.name.toLowerCase().includes(d.toLowerCase())).sort(($,X)=>{if($.is_directory&&!X.is_directory)return-1;if(!$.is_directory&&X.is_directory)return 1;switch(x){case"name-asc":return $.name.localeCompare(X.name);case"name-desc":return X.name.localeCompare($.name);case"size-asc":return $.size-X.size;case"size-desc":return X.size-$.size;case"date-asc":{const V=$.mtime?new Date($.mtime).getTime():0,Q=X.mtime?new Date(X.mtime).getTime():0;return V-Q}case"date-desc":{const V=$.mtime?new Date($.mtime).getTime():0;return(X.mtime?new Date(X.mtime).getTime():0)-V}default:return $.name.localeCompare(X.name)}}).map($=>{const X=Vfe($.name,$.is_directory),V=c.has($.path);return s.jsxs("div",{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${V?"bg-bambu-green/20 border border-bambu-green/50":"hover:bg-bambu-dark-tertiary"}`,onClick:()=>{$.is_directory&&E($.path)},children:[$.is_directory?null:s.jsx("button",{onClick:Q=>A($.path,Q),className:"flex-shrink-0 text-bambu-gray hover:text-white",children:V?s.jsx(ol,{className:"w-5 h-5 text-bambu-green"}):s.jsx(ll,{className:"w-5 h-5"})}),s.jsx(X,{className:`w-5 h-5 flex-shrink-0 ${$.is_directory?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("span",{className:"flex-1 text-white truncate",children:$.name}),!$.is_directory&&s.jsx("span",{className:"text-sm text-bambu-gray",children:$fe($.size)}),$.is_directory&&s.jsx(gh,{className:"w-4 h-4 text-bambu-gray rotate-180"})]},$.path)})}):s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:"No files in this directory"})}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:c.size>0?`${c.size} selected`:d?`${S?.files?.filter($=>$.name.toLowerCase().includes(d.toLowerCase())).length||0} of ${S?.files?.length||0} items`:`${S?.files?.length||0} items`}),S?.files?.some($=>!$.is_directory)&&s.jsx("div",{className:"flex items-center gap-2",children:c.size>0?s.jsxs("button",{onClick:I,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(Ihe,{className:"w-4 h-4"}),"Deselect All"]}):s.jsxs("button",{onClick:D,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors",children:[s.jsx(ol,{className:"w-4 h-4"}),"Select All"]})})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{variant:"secondary",disabled:c.size===0||v!==null,onClick:F,children:v?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),v.current,"/",v.total]}):s.jsxs(s.Fragment,{children:[s.jsx(wi,{className:"w-4 h-4"}),"Download",c.size>1?` (${c.size})`:""]})}),s.jsxs(Te,{variant:"secondary",disabled:c.size===0||C.isPending,onClick:z,className:"text-red-400 hover:text-red-300",children:[C.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(an,{className:"w-4 h-4"}),r("printerFiles.deleteButton"),c.size>1?` (${c.size})`:""]})]})]})]}),p.length>0&&s.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:()=>{C.mutate(p)},onCancel:()=>m([])})]})}const Wfe="embeddedCameraState_",Gz=5,Kfe=2e3,Xfe=3e4,Yfe=5e3,aT={x:window.innerWidth-420,y:20,width:400,height:300};function Qfe({printerId:t,printerName:e,viewerIndex:n=0,onClose:r}){const i=`${Wfe}${t}`,a=()=>{try{const Pe=localStorage.getItem(i);if(Pe){const ze=JSON.parse(Pe);return{x:Math.min(Math.max(0,ze.x),window.innerWidth-100),y:Math.min(Math.max(0,ze.y),window.innerHeight-100),width:Math.max(200,Math.min(ze.width,window.innerWidth-20)),height:Math.max(150,Math.min(ze.height,window.innerHeight-20))}}}catch{}const xe=n*30;return{...aT,x:Math.max(0,aT.x-xe),y:Math.max(0,aT.y+xe)}},[o,l]=_.useState(a),[c,u]=_.useState(!1),[d,f]=_.useState(!1),[p,m]=_.useState({x:0,y:0}),[x,b]=_.useState(!1),[v,y]=_.useState(!1),[S,k]=_.useState(1),[T,M]=_.useState({x:0,y:0}),[C,E]=_.useState(!1),[R,A]=_.useState({x:0,y:0}),[D,I]=_.useState(null),[F,z]=_.useState(null),[P,$]=_.useState(!1),[X,V]=_.useState(!0),[Q,Z]=_.useState(Date.now()),[se,H]=_.useState(0),[K,re]=_.useState(!1),[ne,be]=_.useState(0),me=_.useRef(null),de=_.useRef(null),Ce=_.useRef(null),ie=_.useRef(null),ke=_.useRef(null),{data:Oe}=ot({queryKey:["printer",t],queryFn:()=>ce.getPrinter(t),enabled:t>0});_.useEffect(()=>{const xe=setTimeout(()=>{localStorage.setItem(i,JSON.stringify(o))},500);return()=>clearTimeout(xe)},[o,i]);const pe=_.useRef(!1);_.useEffect(()=>{pe.current=!1;const xe=`/api/v1/printers/${t}/camera/stop`,Pe=()=>{t>0&&!pe.current&&(pe.current=!0,navigator.sendBeacon(xe))},ze=de.current;return()=>{ze&&(ze.src=""),Pe(),Ce.current&&clearTimeout(Ce.current),ie.current&&clearInterval(ie.current),ke.current&&clearInterval(ke.current)}},[t]),_.useEffect(()=>{if(X){const xe=setTimeout(()=>V(!1),3e3);return()=>clearTimeout(xe)}},[X,Q]);const We=_.useCallback(()=>{if(se>=Gz){re(!1),$(!0);return}const xe=Math.min(Kfe*Math.pow(2,se),Xfe);re(!0),be(Math.ceil(xe/1e3)),ie.current=setInterval(()=>{be(Pe=>Pe<=1?(ie.current&&clearInterval(ie.current),0):Pe-1)},1e3),Ce.current=setTimeout(()=>{H(Pe=>Pe+1),re(!1),V(!0),$(!1),de.current&&(de.current.src=""),Z(Date.now())},xe)},[se]);_.useEffect(()=>{if(X||K||x){ke.current&&(clearInterval(ke.current),ke.current=null);return}return ke.current=setInterval(async()=>{try{const xe=await ce.getCameraStatus(t);(xe.stalled||!xe.active&&!P)&&(ke.current&&(clearInterval(ke.current),ke.current=null),V(!1),We())}catch{}},Yfe),()=>{ke.current&&(clearInterval(ke.current),ke.current=null)}},[X,P,K,x,t,We]),_.useEffect(()=>{const xe=()=>{const Pe=!!document.fullscreenElement;y(Pe),Pe||(k(1),M({x:0,y:0}))};return document.addEventListener("fullscreenchange",xe),()=>document.removeEventListener("fullscreenchange",xe)},[]);const G=()=>{me.current&&(document.fullscreenElement?document.exitFullscreen():me.current.requestFullscreen())},Y=()=>{k(xe=>Math.min(xe+.5,4))},ue=()=>{k(xe=>{const Pe=Math.max(xe-.5,1);return Pe===1&&M({x:0,y:0}),Pe})},q=xe=>{xe.preventDefault(),xe.deltaY<0?Y():ue()},te=xe=>{S>1&&(xe.preventDefault(),E(!0),A({x:xe.clientX-T.x,y:xe.clientY-T.y}))},U=_.useCallback(()=>{if(!me.current||!de.current)return{x:200,y:150};const xe=me.current.getBoundingClientRect(),Pe=xe.width*(S-1)/2,ze=xe.height*(S-1)/2;return{x:Math.max(50,Pe),y:Math.max(50,ze)}},[S]),he=xe=>{if(C&&S>1){const Pe=xe.clientX-R.x,ze=xe.clientY-R.y,we=U();M({x:Math.max(-we.x,Math.min(we.x,Pe)),y:Math.max(-we.y,Math.min(we.y,ze))})}},Me=()=>{E(!1)},ge=xe=>{if(xe.length<2)return 0;const Pe=xe[0].clientX-xe[1].clientX,ze=xe[0].clientY-xe[1].clientY;return Math.sqrt(Pe*Pe+ze*ze)},B=xe=>xe.length<2?{x:xe[0].clientX,y:xe[0].clientY}:{x:(xe[0].clientX+xe[1].clientX)/2,y:(xe[0].clientY+xe[1].clientY)/2},O=xe=>{xe.touches.length===2?(xe.preventDefault(),I(ge(xe.touches)),z(B(xe.touches))):xe.touches.length===1&&S>1&&(xe.preventDefault(),E(!0),A({x:xe.touches[0].clientX-T.x,y:xe.touches[0].clientY-T.y}))},ee=xe=>{if(xe.touches.length===2&&D!==null){xe.preventDefault();const Pe=ge(xe.touches),ze=Pe/D;k(Xe=>{const Ne=Math.max(1,Math.min(4,Xe*ze));return Ne===1&&M({x:0,y:0}),Ne}),I(Pe);const we=B(xe.touches);if(F){const Xe=U();M(Ne=>({x:Math.max(-Xe.x,Math.min(Xe.x,Ne.x+(we.x-F.x))),y:Math.max(-Xe.y,Math.min(Xe.y,Ne.y+(we.y-F.y)))}))}z(we)}else if(xe.touches.length===1&&C&&S>1){xe.preventDefault();const Pe=xe.touches[0].clientX-R.x,ze=xe.touches[0].clientY-R.y,we=U();M({x:Math.max(-we.x,Math.min(we.x,Pe)),y:Math.max(-we.y,Math.min(we.y,ze))})}},le=xe=>{xe.touches.length<2&&(I(null),z(null)),xe.touches.length===0&&E(!1)},_e=()=>{k(1),M({x:0,y:0})},ve=()=>{V(!1),se<Gz?We():$(!0)},ae=()=>{V(!1),$(!1),H(0),re(!1),Ce.current&&clearTimeout(Ce.current),ie.current&&clearInterval(ie.current)},Fe=()=>{V(!0),$(!1),H(0),re(!1),Ce.current&&clearTimeout(Ce.current),ie.current&&clearInterval(ie.current),fetch(`/api/v1/printers/${t}/camera/stop`).catch(()=>{}),de.current&&(de.current.src=""),setTimeout(()=>Z(Date.now()),100)},Be=xe=>{xe.target.closest(".no-drag")||(u(!0),m({x:xe.clientX-o.x,y:xe.clientY-o.y}))},$e=xe=>{xe.stopPropagation(),f(!0)};_.useEffect(()=>{const xe=ze=>{if(c)l(we=>({...we,x:Math.max(0,Math.min(ze.clientX-p.x,window.innerWidth-we.width)),y:Math.max(0,Math.min(ze.clientY-p.y,window.innerHeight-we.height))}));else if(d&&me.current){const we=me.current.getBoundingClientRect();l(Xe=>({...Xe,width:Math.max(200,Math.min(ze.clientX-we.left,window.innerWidth-Xe.x-10)),height:Math.max(150,Math.min(ze.clientY-we.top,window.innerHeight-Xe.y-10))}))}},Pe=()=>{u(!1),f(!1)};if(c||d)return document.addEventListener("mousemove",xe),document.addEventListener("mouseup",Pe),()=>{document.removeEventListener("mousemove",xe),document.removeEventListener("mouseup",Pe)}},[c,d,p]);const He=`/api/v1/printers/${t}/camera/stream?fps=15&t=${Q}`;return s.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:[s.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:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-white truncate",children:[s.jsx(zg,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:Oe?.name||e})]}),s.jsxs("div",{className:"flex items-center gap-1 no-drag",children:[s.jsx("button",{onClick:Fe,disabled:X||K,className:"p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:"Refresh stream",children:s.jsx(Dr,{className:`w-3.5 h-3.5 text-bambu-gray ${X?"animate-spin":""}`})}),s.jsx("button",{onClick:G,className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:v?"Exit fullscreen":"Fullscreen",children:v?s.jsx(kW,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(Wue,{className:"w-3.5 h-3.5 text-bambu-gray"})}),s.jsx("button",{onClick:()=>b(!x),className:"p-1 hover:bg-bambu-dark-tertiary rounded",title:x?"Expand":"Minimize",children:x?s.jsx(NW,{className:"w-3.5 h-3.5 text-bambu-gray"}):s.jsx(MW,{className:"w-3.5 h-3.5 text-bambu-gray"})}),s.jsx("button",{onClick:r,className:"p-1 hover:bg-red-500/20 rounded",title:"Close",children:s.jsx(Rt,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-red-400"})})]})]}),!x&&s.jsxs("div",{className:"relative w-full bg-black flex items-center justify-center overflow-hidden h-[calc(100%-40px)]",onWheel:q,onMouseMove:he,onMouseUp:Me,onMouseLeave:Me,onTouchStart:O,onTouchMove:ee,onTouchEnd:le,style:{touchAction:"none"},children:[X&&!K&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsx(Dr,{className:"w-6 h-6 text-bambu-gray animate-spin"})}),K&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:s.jsxs("div",{className:"text-center p-2",children:[s.jsx(sm,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Reconnecting in ",ne,"s..."]})]})}),P&&!K&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:s.jsxs("div",{className:"text-center p-2",children:[s.jsx(Sn,{className:"w-6 h-6 text-orange-400 mx-auto mb-2"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Camera unavailable"}),s.jsx("button",{onClick:Fe,className:"px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80",children:"Retry"})]})}),s.jsx("img",{ref:de,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:ve,onLoad:ae,onMouseDown:te,draggable:!1},Q),s.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:[s.jsx("button",{onClick:ue,disabled:S<=1,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom out",children:s.jsx(FR,{className:"w-3.5 h-3.5 text-white"})}),s.jsxs("button",{onClick:_e,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),"%"]}),s.jsx("button",{onClick:Y,disabled:S>=4,className:"p-1 hover:bg-white/10 rounded disabled:opacity-30",title:"Zoom in",children:s.jsx(LR,{className:"w-3.5 h-3.5 text-white"})})]}),!v&&s.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:$e,title:"Drag to resize",children:s.jsx("svg",{className:"w-6 h-6 text-bambu-gray/70 hover:text-bambu-gray",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("path",{d:"M22 22H20V20H22V22ZM22 18H20V16H22V18ZM18 22H16V20H18V22ZM22 14H20V12H22V14ZM18 18H16V16H18V18ZM14 22H12V20H14V22ZM22 10H20V8H22V10ZM18 14H16V12H18V14ZM14 18H12V16H14V18ZM10 22H8V20H10V22Z"})})})]})]})}function Zfe({printerId:t,printerName:e,onClose:n}){const{t:r}=Rn(),i=sn(),[a,o]=_.useState(!0),[l,c]=_.useState(new Set),[u,d]=_.useState(""),[f,p]=_.useState("all"),m=_.useRef(null),{data:x,isLoading:b,refetch:v}=ot({queryKey:["mqtt-logs",t],queryFn:()=>ce.getMQTTLogs(t),refetchInterval:1e3}),y=mt({mutationFn:()=>ce.enableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),S=mt({mutationFn:()=>ce.disableMQTTLogging(t),onSuccess:()=>{i.invalidateQueries({queryKey:["mqtt-logs",t]})}}),k=mt({mutationFn:()=>ce.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(()=>{a&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[x?.logs,a]);const T=D=>{c(I=>{const F=new Set(I);return F.has(D)?F.delete(D):F.add(D),F})},M=D=>new Date(D).toLocaleTimeString("en-US",{hour12:!1,fractionalSecondDigits:3}),C=(D,I)=>{if(D==null)return"<empty>";const F=typeof D=="string"?JSON.parse(D):D,z=JSON.stringify(F,null,I?2:0);return!I&&z.length>100?z.substring(0,100)+"...":z},E=x?.logging_enabled??!1,R=_.useMemo(()=>x?.logs??[],[x?.logs]),A=_.useMemo(()=>R.filter(D=>{if(f!=="all"&&D.direction!==f)return!1;if(u.trim()){const I=u.toLowerCase(),F=D.topic.toLowerCase().includes(I),P=JSON.stringify(D.payload).toLowerCase().includes(I);return F||P}return!0}),[R,u,f]);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r("mqttDebug.title")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:e})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[E?s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>S.mutate(),disabled:S.isPending,children:[s.jsx(ll,{className:"w-4 h-4"}),r("mqttDebug.stopLogging")]}):s.jsxs(Te,{size:"sm",onClick:()=>y.mutate(),disabled:y.isPending,children:[s.jsx(bo,{className:"w-4 h-4"}),r("mqttDebug.startLogging")]}),s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>k.mutate(),disabled:k.isPending||R.length===0,children:[s.jsx(an,{className:"w-4 h-4"}),r("mqttDebug.clearLog")]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>v(),disabled:b,children:s.jsx(Dr,{className:`w-4 h-4 ${b?"animate-spin":""}`})}),s.jsx("div",{className:"flex-1"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:a,onChange:D=>o(D.target.checked),className:"rounded border-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[A.length,"/",R.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ya,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.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&&s.jsx("button",{onClick:()=>d(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>p("all"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${f==="all"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:r("mqttDebug.all")}),s.jsxs("button",{onClick:()=>p("in"),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${f==="in"?"bg-blue-500 text-white":"text-bambu-gray hover:text-white"}`,children:[s.jsx(G0,{className:"w-3 h-3"}),r("mqttDebug.incoming")]}),s.jsxs("button",{onClick:()=>p("out"),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${f==="out"?"bg-green-500 text-white":"text-bambu-gray hover:text-white"}`,children:[s.jsx(Ig,{className:"w-3 h-3"}),r("mqttDebug.outgoing")]})]})]})]}),s.jsx("div",{ref:m,className:"flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]",children:R.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:r("mqttDebug.noMessages")}),!E&&s.jsx("p",{className:"text-sm",children:r("mqttDebug.startLoggingHint")})]}):A.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:r("mqttDebug.noMessagesMatch")}),s.jsx("p",{className:"text-sm",children:r("mqttDebug.adjustFilterHint")})]}):s.jsx("div",{className:"space-y-1",children:A.map((D,I)=>{const F=l.has(I),z=D.direction==="in";return s.jsxs("div",{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${F?"bg-bambu-dark-secondary":""}`,onClick:()=>T(I),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray shrink-0",children:M(D.timestamp)}),s.jsx("span",{className:`shrink-0 ${z?"text-blue-400":"text-green-400"}`,title:r(z?"mqttDebug.incoming":"mqttDebug.outgoing"),children:z?s.jsx(G0,{className:"w-3 h-3"}):s.jsx(Ig,{className:"w-3 h-3"})}),s.jsx("span",{className:"text-purple-400 shrink-0",children:D.topic})]}),F?s.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)}):s.jsx("pre",{className:"mt-1 text-white/80 truncate",children:C(D.payload,!1)})]},I)})})}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-sm text-bambu-gray",children:E?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),r("mqttDebug.loggingActive")]}):s.jsx("span",{children:r("mqttDebug.loggingStopped")})}),s.jsx(Te,{variant:"secondary",onClick:n,children:r("common.close")})]})]})})}const vj={"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 Jfe(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:$i};case 4:default:return{label:"Info",color:"text-blue-400",bgColor:"bg-blue-500/20",Icon:Zo}}}function wj(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 eme(t){return t.filter(e=>{const n=parseInt(e.code.replace("0x",""),16)||0,r=wj(e.attr,n);return vj[r]!==void 0})}function tme(){return"https://wiki.bambulab.com/en/hms/home"}function nme({printerName:t,errors:e,onClose:n}){const{t:r}=Rn();console.log("HMSErrorModal errors:",JSON.stringify(e,null,2));const i=e.filter(a=>{const o=parseInt(a.code.replace("0x",""),16)||0,l=wj(a.attr,o);return vj[l]!==void 0});return _.useEffect(()=>{const a=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Sn,{className:"w-5 h-5 text-orange-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:r("hmsErrors.title",{name:t})})]}),s.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:i.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx($i,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{children:r("hmsErrors.noErrors")})]}):s.jsx("div",{className:"space-y-3",children:i.map((a,o)=>{const{label:l,color:c,bgColor:u,Icon:d}=Jfe(a.severity),f=parseInt(a.code.replace("0x",""),16)||0,p=wj(a.attr,f),m=vj[p],x=tme(),b=p.replace("_","-");return s.jsx("div",{className:`p-4 rounded-lg ${u} border border-white/10`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(d,{className:`w-5 h-5 ${c} flex-shrink-0 mt-0.5`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.jsxs("span",{className:`font-mono text-sm ${c}`,children:["[",b,"]"]}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${u} ${c}`,children:l})]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:m}),s.jsxs("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-bambu-green hover:underline",children:[s.jsx(Xr,{className:"w-3 h-3"}),r("hmsErrors.viewOnWiki")]})]})]})},`${a.code}-${o}`)})})}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx("p",{className:"text-xs text-bambu-gray",children:r("hmsErrors.clearInstructions")})})]})})}function rme(t){if(!t)return"ASAP";const e=Ui(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 ime({printerId:t}){const{data:e}=ot({queryKey:["queue",t,"pending"],queryFn:()=>ce.getQueue(t,"pending"),refetchInterval:3e4}),n=e?.[0],r=e?.length||0;return r===0?null:s.jsx(Ds,{to:"/queue",className:"block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx(ti,{className:"w-5 h-5 text-yellow-400 flex-shrink-0"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Next in queue"}),s.jsx("p",{className:"text-sm text-white truncate",children:n?.archive_name||`Archive #${n?.archive_id}`})]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",children:[s.jsx(tr,{className:"w-3 h-3"}),rme(n?.scheduled_time||null)]}),r>1&&s.jsxs("span",{className:"text-xs px-1.5 py-0.5 bg-yellow-400/20 text-yellow-400 rounded",children:["+",r-1]}),s.jsx(gs,{className:"w-4 h-4 text-bambu-gray"})]})]})})}function zW(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=zW(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=zW(t))&&(r&&(r+=" "),r+=e);return r}var ame=["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 UR(t){if(typeof t!="string")return!1;var e=ame;return e.includes(t)}var sme=["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"],ome=new Set(sme);function BW(t){return typeof t!="string"?!1:ome.has(t)}function HW(t){return typeof t=="string"&&t.startsWith("data-")}function xs(t){if(typeof t!="object"||t===null)return{};var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(BW(n)||HW(n))&&(e[n]=t[n]);return e}function lm(t){if(t==null)return null;if(_.isValidElement(t)&&typeof t.props=="object"&&t.props!==null){var e=t.props;return xs(e)}return typeof t=="object"&&!Array.isArray(t)?xs(t):null}function Ba(t){var e={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(BW(n)||HW(n)||UR(n))&&(e[n]=t[n]);return e}function lme(t){return t==null?null:_.isValidElement(t)?Ba(t.props):typeof t=="object"&&!Array.isArray(t)?Ba(t):null}var cme=["children","width","height","viewBox","className","style","title","desc"];function _j(){return _j=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},_j.apply(null,arguments)}function ume(t,e){if(t==null)return{};var n,r,i=dme(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function dme(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var zR=_.forwardRef((t,e)=>{var{children:n,width:r,height:i,viewBox:a,className:o,style:l,title:c,desc:u}=t,d=ume(t,cme),f=a||{width:r,height:i,x:0,y:0},p=nr("recharts-surface",o);return _.createElement("svg",_j({},Ba(d),{className:p,width:r,height:i,style:l,viewBox:"".concat(f.x," ").concat(f.y," ").concat(f.width," ").concat(f.height),ref:e}),_.createElement("title",null,c),_.createElement("desc",null,u),n)}),hme=["children","className"];function Sj(){return Sj=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},Sj.apply(null,arguments)}function fme(t,e){if(t==null)return{};var n,r,i=mme(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function mme(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=fme(t,hme),a=nr("recharts-layer",r);return _.createElement("g",Sj({className:a},Ba(i),{ref:e}),n)}),$W=_.createContext(null),pme=()=>_.useContext($W);function Ir(t){return function(){return t}}const VW=Math.cos,Y1=Math.sin,Bl=Math.sqrt,Q1=Math.PI,vM=2*Q1,Nj=Math.PI,Mj=2*Nj,vf=1e-6,gme=Mj-vf;function GW(t){this._+=t[0];for(let e=1,n=t.length;e<n;++e)this._+=arguments[e]+t[e]}function xme(t){let e=Math.floor(t);if(!(e>=0))throw new Error(`invalid digits: ${t}`);if(e>15)return GW;const n=10**e;return function(r){this._+=r[0];for(let i=1,a=r.length;i<a;++i)this._+=Math.round(arguments[i]*n)/n+r[i]}}class bme{constructor(e){this._x0=this._y0=this._x1=this._y1=null,this._="",this._append=e==null?GW:xme(e)}moveTo(e,n){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}`}closePath(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._append`Z`)}lineTo(e,n){this._append`L${this._x1=+e},${this._y1=+n}`}quadraticCurveTo(e,n,r,i){this._append`Q${+e},${+n},${this._x1=+r},${this._y1=+i}`}bezierCurveTo(e,n,r,i,a,o){this._append`C${+e},${+n},${+r},${+i},${this._x1=+a},${this._y1=+o}`}arcTo(e,n,r,i,a){if(e=+e,n=+n,r=+r,i=+i,a=+a,a<0)throw new Error(`negative radius: ${a}`);let o=this._x1,l=this._y1,c=r-e,u=i-n,d=o-e,f=l-n,p=d*d+f*f;if(this._x1===null)this._append`M${this._x1=e},${this._y1=n}`;else if(p>vf)if(!(Math.abs(f*c-u*d)>vf)||!a)this._append`L${this._x1=e},${this._y1=n}`;else{let m=r-o,x=i-l,b=c*c+u*u,v=m*m+x*x,y=Math.sqrt(b),S=Math.sqrt(p),k=a*Math.tan((Nj-Math.acos((b+p-v)/(2*y*S)))/2),T=k/S,M=k/y;Math.abs(T-1)>vf&&this._append`L${e+T*d},${n+T*f}`,this._append`A${a},${a},0,0,${+(f*m>d*x)},${this._x1=e+M*c},${this._y1=n+M*u}`}}arc(e,n,r,i,a,o){if(e=+e,n=+n,r=+r,o=!!o,r<0)throw new Error(`negative radius: ${r}`);let l=r*Math.cos(i),c=r*Math.sin(i),u=e+l,d=n+c,f=1^o,p=o?i-a:a-i;this._x1===null?this._append`M${u},${d}`:(Math.abs(this._x1-u)>vf||Math.abs(this._y1-d)>vf)&&this._append`L${u},${d}`,r&&(p<0&&(p=p%Mj+Mj),p>gme?this._append`A${r},${r},0,1,${f},${e-l},${n-c}A${r},${r},0,1,${f},${this._x1=u},${this._y1=d}`:p>vf&&this._append`A${r},${r},0,${+(p>=Nj)},${f},${this._x1=e+r*Math.cos(a)},${this._y1=n+r*Math.sin(a)}`)}rect(e,n,r,i){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+n}h${r=+r}v${+i}h${-r}Z`}toString(){return this._}}function BR(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 bme(e)}function HR(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function qW(t){this._context=t}qW.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 wM(t){return new qW(t)}function WW(t){return t[0]}function KW(t){return t[1]}function XW(t,e){var n=Ir(!0),r=null,i=wM,a=null,o=BR(l);t=typeof t=="function"?t:t===void 0?WW:Ir(t),e=typeof e=="function"?e:e===void 0?KW:Ir(e);function l(c){var u,d=(c=HR(c)).length,f,p=!1,m;for(r==null&&(a=i(m=o())),u=0;u<=d;++u)!(u<d&&n(f=c[u],u,c))===p&&((p=!p)?a.lineStart():a.lineEnd()),p&&a.point(+t(f,u,c),+e(f,u,c));if(m)return a=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&&(a=i(r)),l):i},l.context=function(c){return arguments.length?(c==null?r=a=null:a=i(r=c),l):r},l}function Ow(t,e,n){var r=null,i=Ir(!0),a=null,o=wM,l=null,c=BR(u);t=typeof t=="function"?t:t===void 0?WW:Ir(+t),e=typeof e=="function"?e:Ir(e===void 0?0:+e),n=typeof n=="function"?n:n===void 0?KW:Ir(+n);function u(f){var p,m,x,b=(f=HR(f)).length,v,y=!1,S,k=new Array(b),T=new Array(b);for(a==null&&(l=o(S=c())),p=0;p<=b;++p){if(!(p<b&&i(v=f[p],p,f))===y)if(y=!y)m=p,l.areaStart(),l.lineStart();else{for(l.lineEnd(),l.lineStart(),x=p-1;x>=m;--x)l.point(k[x],T[x]);l.lineEnd(),l.areaEnd()}y&&(k[p]=+t(v,p,f),T[p]=+e(v,p,f),l.point(r?+r(v,p,f):k[p],n?+n(v,p,f):T[p]))}if(S)return l=null,S+""||null}function d(){return XW().defined(i).curve(o).context(a)}return u.x=function(f){return arguments.length?(t=typeof f=="function"?f:Ir(+f),r=null,u):t},u.x0=function(f){return arguments.length?(t=typeof f=="function"?f:Ir(+f),u):t},u.x1=function(f){return arguments.length?(r=f==null?null:typeof f=="function"?f:Ir(+f),u):r},u.y=function(f){return arguments.length?(e=typeof f=="function"?f:Ir(+f),n=null,u):e},u.y0=function(f){return arguments.length?(e=typeof f=="function"?f:Ir(+f),u):e},u.y1=function(f){return arguments.length?(n=f==null?null:typeof f=="function"?f:Ir(+f),u):n},u.lineX0=u.lineY0=function(){return d().x(t).y(e)},u.lineY1=function(){return d().x(t).y(n)},u.lineX1=function(){return d().x(r).y(e)},u.defined=function(f){return arguments.length?(i=typeof f=="function"?f:Ir(!!f),u):i},u.curve=function(f){return arguments.length?(o=f,a!=null&&(l=o(a)),u):o},u.context=function(f){return arguments.length?(f==null?a=l=null:l=o(a=f),u):a},u}class YW{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 yme(t){return new YW(t,!0)}function vme(t){return new YW(t,!1)}const $R={draw(t,e){const n=Bl(e/Q1);t.moveTo(n,0),t.arc(0,0,n,0,vM)}},wme={draw(t,e){const n=Bl(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()}},QW=Bl(1/3),_me=QW*2,Sme={draw(t,e){const n=Bl(e/_me),r=n*QW;t.moveTo(0,-n),t.lineTo(r,0),t.lineTo(0,n),t.lineTo(-r,0),t.closePath()}},Nme={draw(t,e){const n=Bl(e),r=-n/2;t.rect(r,r,n,n)}},Mme=.8908130915292852,ZW=Y1(Q1/10)/Y1(7*Q1/10),kme=Y1(vM/10)*ZW,Eme=-VW(vM/10)*ZW,Tme={draw(t,e){const n=Bl(e*Mme),r=kme*n,i=Eme*n;t.moveTo(0,-n),t.lineTo(r,i);for(let a=1;a<5;++a){const o=vM*a/5,l=VW(o),c=Y1(o);t.lineTo(c*n,-l*n),t.lineTo(l*r-c*i,c*r+l*i)}t.closePath()}},sT=Bl(3),Ame={draw(t,e){const n=-Bl(e/(sT*3));t.moveTo(0,n*2),t.lineTo(-sT*n,-n),t.lineTo(sT*n,-n),t.closePath()}},Ro=-.5,Oo=Bl(3)/2,kj=1/Bl(12),Cme=(kj/2+1)*3,Pme={draw(t,e){const n=Bl(e/Cme),r=n/2,i=n*kj,a=r,o=n*kj+n,l=-a,c=o;t.moveTo(r,i),t.lineTo(a,o),t.lineTo(l,c),t.lineTo(Ro*r-Oo*i,Oo*r+Ro*i),t.lineTo(Ro*a-Oo*o,Oo*a+Ro*o),t.lineTo(Ro*l-Oo*c,Oo*l+Ro*c),t.lineTo(Ro*r+Oo*i,Ro*i-Oo*r),t.lineTo(Ro*a+Oo*o,Ro*o-Oo*a),t.lineTo(Ro*l+Oo*c,Ro*c-Oo*l),t.closePath()}};function jme(t,e){let n=null,r=BR(i);t=typeof t=="function"?t:Ir(t||$R),e=typeof e=="function"?e:Ir(e===void 0?64:+e);function i(){let a;if(n||(n=a=r()),t.apply(this,arguments).draw(n,+e.apply(this,arguments)),a)return n=null,a+""||null}return i.type=function(a){return arguments.length?(t=typeof a=="function"?a:Ir(a),i):t},i.size=function(a){return arguments.length?(e=typeof a=="function"?a:Ir(+a),i):e},i.context=function(a){return arguments.length?(n=a??null,i):n},i}function Z1(){}function J1(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 JW(t){this._context=t}JW.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:J1(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:J1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Dme(t){return new JW(t)}function eK(t){this._context=t}eK.prototype={areaStart:Z1,areaEnd:Z1,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:J1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Rme(t){return new eK(t)}function tK(t){this._context=t}tK.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:J1(this,t,e);break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e}};function Ome(t){return new tK(t)}function nK(t){this._context=t}nK.prototype={areaStart:Z1,areaEnd:Z1,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 Lme(t){return new nK(t)}function qz(t){return t<0?-1:1}function Wz(t,e,n){var r=t._x1-t._x0,i=e-t._x1,a=(t._y1-t._y0)/(r||i<0&&-0),o=(n-t._y1)/(i||r<0&&-0),l=(a*i+o*r)/(r+i);return(qz(a)+qz(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(l))||0}function Kz(t,e){var n=t._x1-t._x0;return n?(3*(t._y1-t._y0)/n-e)/2:e}function oT(t,e,n){var r=t._x0,i=t._y0,a=t._x1,o=t._y1,l=(a-r)/3;t._context.bezierCurveTo(r+l,i+l*e,a-l,o-l*n,a,o)}function eS(t){this._context=t}eS.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:oT(this,this._t0,Kz(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,oT(this,Kz(this,n=Wz(this,t,e)),n);break;default:oT(this,this._t0,n=Wz(this,t,e));break}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=e,this._t0=n}}};function rK(t){this._context=new iK(t)}(rK.prototype=Object.create(eS.prototype)).point=function(t,e){eS.prototype.point.call(this,e,t)};function iK(t){this._context=t}iK.prototype={moveTo:function(t,e){this._context.moveTo(e,t)},closePath:function(){this._context.closePath()},lineTo:function(t,e){this._context.lineTo(e,t)},bezierCurveTo:function(t,e,n,r,i,a){this._context.bezierCurveTo(e,t,r,n,a,i)}};function Fme(t){return new eS(t)}function Ime(t){return new rK(t)}function aK(t){this._context=t}aK.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=Xz(t),i=Xz(e),a=0,o=1;o<n;++a,++o)this._context.bezierCurveTo(r[0][a],i[0][a],r[1][a],i[1][a],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 Xz(t){var e,n=t.length-1,r,i=new Array(n),a=new Array(n),o=new Array(n);for(i[0]=0,a[0]=2,o[0]=t[0]+2*t[1],e=1;e<n-1;++e)i[e]=1,a[e]=4,o[e]=4*t[e]+2*t[e+1];for(i[n-1]=2,a[n-1]=7,o[n-1]=8*t[n-1]+t[n],e=1;e<n;++e)r=i[e]/a[e-1],a[e]-=r,o[e]-=r*o[e-1];for(i[n-1]=o[n-1]/a[n-1],e=n-2;e>=0;--e)i[e]=(o[e]-i[e+1])/a[e];for(a[n-1]=(t[n]+i[n-1])/2,e=0;e<n-1;++e)a[e]=2*t[e+1]-i[e+1];return[i,a]}function Ume(t){return new aK(t)}function _M(t,e){this._context=t,this._t=e}_M.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 zme(t){return new _M(t,.5)}function Bme(t){return new _M(t,0)}function Hme(t){return new _M(t,1)}function $g(t,e){if((o=t.length)>1)for(var n=1,r,i,a=t[e[0]],o,l=a.length;n<o;++n)for(i=a,a=t[e[n]],r=0;r<l;++r)a[r][1]+=a[r][0]=isNaN(i[r][1])?i[r][0]:i[r][1]}function Ej(t){for(var e=t.length,n=new Array(e);--e>=0;)n[e]=e;return n}function $me(t,e){return t[e]}function Vme(t){const e=[];return e.key=t,e}function Gme(){var t=Ir([]),e=Ej,n=$g,r=$me;function i(a){var o=Array.from(t.apply(this,arguments),Vme),l,c=o.length,u=-1,d;for(const f of a)for(l=0,++u;l<c;++l)(o[l][u]=[0,+r(f,o[l].key,u,a)]).data=f;for(l=0,d=HR(e(o));l<c;++l)o[d[l]].index=l;return n(o,d),o}return i.keys=function(a){return arguments.length?(t=typeof a=="function"?a:Ir(Array.from(a)),i):t},i.value=function(a){return arguments.length?(r=typeof a=="function"?a:Ir(+a),i):r},i.order=function(a){return arguments.length?(e=a==null?Ej:typeof a=="function"?a:Ir(Array.from(a)),i):e},i.offset=function(a){return arguments.length?(n=a??$g,i):n},i}function qme(t,e){if((r=t.length)>0){for(var n,r,i=0,a=t[0].length,o;i<a;++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}$g(t,e)}}function Wme(t,e){if((i=t.length)>0){for(var n=0,r=t[e[0]],i,a=r.length;n<a;++n){for(var o=0,l=0;o<i;++o)l+=t[o][n][1]||0;r[n][1]+=r[n][0]=-l/2}$g(t,e)}}function Kme(t,e){if(!(!((o=t.length)>0)||!((a=(i=t[e[0]]).length)>0))){for(var n=0,r=1,i,a,o;r<a;++r){for(var l=0,c=0,u=0;l<o;++l){for(var d=t[e[l]],f=d[r][1]||0,p=d[r-1][1]||0,m=(f-p)/2,x=0;x<l;++x){var b=t[e[x]],v=b[r][1]||0,y=b[r-1][1]||0;m+=v-y}c+=f,u+=m*f}i[r-1][1]+=i[r-1][0]=n,c&&(n-=u/c)}i[r-1][1]+=i[r-1][0]=n,$g(t,e)}}var lT={},cT={},Yz;function Xme(){return Yz||(Yz=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n==="__proto__"}t.isUnsafeProperty=e})(cT)),cT}var uT={},Qz;function sK(){return Qz||(Qz=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})(uT)),uT}var dT={},Zz;function VR(){return Zz||(Zz=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})(dT)),dT}var hT={},fT={},Jz;function Yme(){return Jz||(Jz=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})(fT)),fT}var eB;function GR(){return eB||(eB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Yme(),n=VR();function r(i){if(Array.isArray(i))return i.map(n.toKey);if(typeof i=="symbol")return[i];i=e.toString(i);const a=[],o=i.length;if(o===0)return a;let l=0,c="",u="",d=!1;for(i.charCodeAt(0)===46&&(a.push(""),l++);l<o;){const f=i[l];u?f==="\\"&&l+1<o?(l++,c+=i[l]):f===u?u="":c+=f:d?f==='"'||f==="'"?u=f:f==="]"?(d=!1,a.push(c),c=""):c+=f:f==="["?(d=!0,c&&(a.push(c),c="")):f==="."?c&&(a.push(c),c=""):c+=f,l++}return c&&a.push(c),a}t.toPath=r})(hT)),hT}var tB;function qR(){return tB||(tB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Xme(),n=sK(),r=VR(),i=GR();function a(l,c,u){if(l==null)return u;switch(typeof c){case"string":{if(e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?n.isDeepKey(c)?a(l,i.toPath(c),u):u:d}case"number":case"symbol":{typeof c=="number"&&(c=r.toKey(c));const d=l[c];return d===void 0?u:d}default:{if(Array.isArray(c))return o(l,c,u);if(Object.is(c?.valueOf(),-0)?c="-0":c=String(c),e.isUnsafeProperty(c))return u;const d=l[c];return d===void 0?u:d}}}function o(l,c,u){if(c.length===0)return u;let d=l;for(let f=0;f<c.length;f++){if(d==null||e.isUnsafeProperty(c[f]))return u;d=d[c[f]]}return d===void 0?u:d}t.get=a})(lT)),lT}var mT,nB;function Qme(){return nB||(nB=1,mT=qR().get),mT}var Zme=Qme();const cm=hl(Zme);var va=t=>t===0?0:t>0?1:-1,Hs=t=>typeof t=="number"&&t!=+t,Lu=t=>typeof t=="string"&&t.indexOf("%")===t.length-1,zt=t=>(typeof t=="number"||t instanceof Number)&&!Hs(t),cl=t=>zt(t)||typeof t=="string",Jme=0,X0=t=>{var e=++Jme;return"".concat(t||"").concat(e)},es=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(!zt(e)&&typeof e!="string")return r;var a;if(Lu(e)){if(n==null)return r;var o=e.indexOf("%");a=n*parseFloat(e.slice(0,o))/100}else a=+e;return Hs(a)&&(a=r),i&&n!=null&&a>n&&(a=n),a},oK=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 zt(t)&&zt(e)?t+n*(e-t):e}function lK(t,e,n){if(!(!t||!t.length))return t.find(r=>r&&(typeof e=="function"?e(r):cm(r,e))===n)}var Yr=t=>t===null||typeof t>"u",Uy=t=>Yr(t)?t:"".concat(t.charAt(0).toUpperCase()).concat(t.slice(1));function epe(t){return t!=null}function zy(){}var tpe=["type","size","sizeType"];function Tj(){return Tj=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},Tj.apply(null,arguments)}function rB(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 iB(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?rB(Object(n),!0).forEach(function(r){npe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):rB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function npe(t,e,n){return(e=rpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function rpe(t){var e=ipe(t,"string");return typeof e=="symbol"?e:e+""}function ipe(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 ape(t,e){if(t==null)return{};var n,r,i=spe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function spe(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 cK={symbolCircle:$R,symbolCross:wme,symbolDiamond:Sme,symbolSquare:Nme,symbolStar:Tme,symbolTriangle:Ame,symbolWye:Pme},ope=Math.PI/180,lpe=t=>{var e="symbol".concat(Uy(t));return cK[e]||$R},cpe=(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*ope;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}},upe=(t,e)=>{cK["symbol".concat(Uy(t))]=e},WR=t=>{var{type:e="circle",size:n=64,sizeType:r="area"}=t,i=ape(t,tpe),a=iB(iB({},i),{},{type:e,size:n,sizeType:r}),o="circle";typeof e=="string"&&(o=e);var l=()=>{var p=lpe(o),m=jme().type(p).size(cpe(n,r,o)),x=m();if(x!==null)return x},{className:c,cx:u,cy:d}=a,f=Ba(a);return zt(u)&&zt(d)&&zt(n)?_.createElement("path",Tj({},f,{className:nr("recharts-symbols",c),transform:"translate(".concat(u,", ").concat(d,")"),d:l()})):null};WR.registerSymbol=upe;var uK=t=>"radius"in t&&"startAngle"in t&&"endAngle"in t,KR=(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=>{UR(i)&&(r[i]=(a=>n[i](n,a)))}),r},dpe=(t,e,n)=>r=>(t(e,n,r),null),By=(t,e,n)=>{if(t===null||typeof t!="object"&&typeof t!="function")return null;var r=null;return Object.keys(t).forEach(i=>{var a=t[i];UR(i)&&typeof a=="function"&&(r||(r={}),r[i]=dpe(a,e,n))}),r};function aB(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function hpe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?aB(Object(n),!0).forEach(function(r){fpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):aB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fpe(t,e,n){return(e=mpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mpe(t){var e=ppe(t,"string");return typeof e=="symbol"?e:e+""}function ppe(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=hpe({},t),r=e,i=Object.keys(e),a=i.reduce((o,l)=>(o[l]===void 0&&r[l]!==void 0&&(o[l]=r[l]),o),n);return a}function tS(){return tS=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},tS.apply(null,arguments)}function sB(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 gpe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?sB(Object(n),!0).forEach(function(r){xpe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):sB(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function xpe(t,e,n){return(e=bpe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bpe(t){var e=ype(t,"string");return typeof e=="symbol"?e:e+""}function ype(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 zo=32,vpe={align:"center",iconSize:14,inactiveColor:"#ccc",layout:"horizontal",verticalAlign:"middle"};function wpe(t){var{data:e,iconType:n,inactiveColor:r}=t,i=zo/2,a=zo/6,o=zo/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:zo,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,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(2*o,",").concat(i,`
- H`).concat(zo,"M").concat(2*o,",").concat(i,`
- A`).concat(a,",").concat(a,",0,1,1,").concat(o,",").concat(i),className:"recharts-legend-icon"});if(c==="rect")return _.createElement("path",{stroke:"none",fill:l,d:"M0,".concat(zo/8,"h").concat(zo,"v").concat(zo*3/4,"h").concat(-zo,"z"),className:"recharts-legend-icon"});if(_.isValidElement(e.legendIcon)){var d=gpe({},e);return delete d.legendIcon,_.cloneElement(e.legendIcon,d)}return _.createElement(WR,{fill:l,cx:i,cy:i,size:zo,sizeType:"diameter",type:c})}function _pe(t){var{payload:e,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:o}=t,l={x:0,y:0,width:zo,height:zo},c={display:r==="horizontal"?"inline-block":"block",marginRight:10},u={display:"inline-block",verticalAlign:"middle",marginRight:4};return e.map((d,f)=>{var p=d.formatter||i,m=nr({"recharts-legend-item":!0,["legend-item-".concat(f)]:!0,inactive:d.inactive});if(d.type==="none")return null;var x=d.inactive?a:d.color,b=p?p(d.value,d,f):d.value;return _.createElement("li",tS({className:m,style:c,key:"legend-item-".concat(f)},By(t,d,f)),_.createElement(zR,{width:n,height:n,viewBox:l,style:u,"aria-label":"".concat(b," legend icon")},_.createElement(wpe,{data:d,iconType:o,inactiveColor:a})),_.createElement("span",{className:"recharts-legend-item-text",style:{color:x}},b))})}var Spe=t=>{var e=ci(t,vpe),{payload:n,layout:r,align:i}=e;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r==="horizontal"?i:"left"};return _.createElement("ul",{className:"recharts-default-legend",style:a},_.createElement(_pe,tS({},e,{payload:n})))},pT={},gT={},oB;function Npe(){return oB||(oB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r){const i=new Map;for(let a=0;a<n.length;a++){const o=n[a],l=r(o);i.has(l)||i.set(l,o)}return Array.from(i.values())}t.uniqBy=e})(gT)),gT}var xT={},lB;function dK(){return lB||(lB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n}t.identity=e})(xT)),xT}var bT={},yT={},vT={},cB;function Mpe(){return cB||(cB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Number.isSafeInteger(n)&&n>=0}t.isLength=e})(vT)),vT}var uB;function XR(){return uB||(uB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Mpe();function n(r){return r!=null&&typeof r!="function"&&e.isLength(r.length)}t.isArrayLike=n})(yT)),yT}var wT={},dB;function kpe(){return dB||(dB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="object"&&n!==null}t.isObjectLike=e})(wT)),wT}var hB;function Epe(){return hB||(hB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=XR(),n=kpe();function r(i){return n.isObjectLike(i)&&e.isArrayLike(i)}t.isArrayLikeObject=r})(bT)),bT}var _T={},ST={},fB;function Tpe(){return fB||(fB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=qR();function n(r){return function(i){return e.get(i,r)}}t.property=n})(ST)),ST}var NT={},MT={},kT={},ET={},mB;function hK(){return mB||(mB=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})(ET)),ET}var TT={},pB;function fK(){return pB||(pB=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})(TT)),TT}var AT={},gB;function mK(){return gB||(gB=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})(AT)),AT}var xB;function Ape(){return xB||(xB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=hK(),n=fK(),r=mK();function i(d,f,p){return typeof p!="function"?i(d,f,()=>{}):a(d,f,function m(x,b,v,y,S,k){const T=p(x,b,v,y,S,k);return T!==void 0?!!T:a(x,b,m,k)},new Map)}function a(d,f,p,m){if(f===d)return!0;switch(typeof f){case"object":return o(d,f,p,m);case"function":return Object.keys(f).length>0?a(d,{...f},p,m):r.eq(d,f);default:return e.isObject(d)?typeof f=="string"?f==="":!0:r.eq(d,f)}}function o(d,f,p,m){if(f==null)return!0;if(Array.isArray(f))return c(d,f,p,m);if(f instanceof Map)return l(d,f,p,m);if(f instanceof Set)return u(d,f,p,m);const x=Object.keys(f);if(d==null)return x.length===0;if(x.length===0)return!0;if(m?.has(f))return m.get(f)===d;m?.set(f,d);try{for(let b=0;b<x.length;b++){const v=x[b];if(!n.isPrimitive(d)&&!(v in d)||f[v]===void 0&&d[v]!==void 0||f[v]===null&&d[v]!==null||!p(d[v],f[v],v,d,f,m))return!1}return!0}finally{m?.delete(f)}}function l(d,f,p,m){if(f.size===0)return!0;if(!(d instanceof Map))return!1;for(const[x,b]of f.entries()){const v=d.get(x);if(p(v,b,x,d,f,m)===!1)return!1}return!0}function c(d,f,p,m){if(f.length===0)return!0;if(!Array.isArray(d))return!1;const x=new Set;for(let b=0;b<f.length;b++){const v=f[b];let y=!1;for(let S=0;S<d.length;S++){if(x.has(S))continue;const k=d[S];let T=!1;if(p(k,v,b,d,f,m)&&(T=!0),T){x.add(S),y=!0;break}}if(!y)return!1}return!0}function u(d,f,p,m){return f.size===0?!0:d instanceof Set?c([...d],[...f],p,m):!1}t.isMatchWith=i,t.isSetMatch=u})(kT)),kT}var bB;function pK(){return bB||(bB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Ape();function n(r,i){return e.isMatchWith(r,i,()=>{})}t.isMatch=n})(MT)),MT}var CT={},PT={},jT={},yB;function Cpe(){return yB||(yB=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})(jT)),jT}var DT={},vB;function gK(){return vB||(vB=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})(DT)),DT}var RT={},wB;function xK(){return wB||(wB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e="[object RegExp]",n="[object String]",r="[object Number]",i="[object Boolean]",a="[object Arguments]",o="[object Symbol]",l="[object Date]",c="[object Map]",u="[object Set]",d="[object Array]",f="[object Function]",p="[object ArrayBuffer]",m="[object Object]",x="[object Error]",b="[object DataView]",v="[object Uint8Array]",y="[object Uint8ClampedArray]",S="[object Uint16Array]",k="[object Uint32Array]",T="[object BigUint64Array]",M="[object Int8Array]",C="[object Int16Array]",E="[object Int32Array]",R="[object BigInt64Array]",A="[object Float32Array]",D="[object Float64Array]";t.argumentsTag=a,t.arrayBufferTag=p,t.arrayTag=d,t.bigInt64ArrayTag=R,t.bigUint64ArrayTag=T,t.booleanTag=i,t.dataViewTag=b,t.dateTag=l,t.errorTag=x,t.float32ArrayTag=A,t.float64ArrayTag=D,t.functionTag=f,t.int16ArrayTag=C,t.int32ArrayTag=E,t.int8ArrayTag=M,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=k,t.uint8ArrayTag=v,t.uint8ClampedArrayTag=y})(RT)),RT}var OT={},_B;function Ppe(){return _B||(_B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)}t.isTypedArray=e})(OT)),OT}var SB;function bK(){return SB||(SB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Cpe(),n=gK(),r=xK(),i=fK(),a=Ppe();function o(d,f){return l(d,void 0,d,new Map,f)}function l(d,f,p,m=new Map,x=void 0){const b=x?.(d,f,p,m);if(b!==void 0)return b;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 y=0;y<d.length;y++)v[y]=l(d[y],y,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[y,S]of d)v.set(y,l(S,y,p,m,x));return v}if(d instanceof Set){const v=new Set;m.set(d,v);for(const y of d)v.add(l(y,void 0,p,m,x));return v}if(typeof Buffer<"u"&&Buffer.isBuffer(d))return d.subarray();if(a.isTypedArray(d)){const v=new(Object.getPrototypeOf(d)).constructor(d.length);m.set(d,v);for(let y=0;y<d.length;y++)v[y]=l(d[y],y,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,f,p=d,m,x){const b=[...Object.keys(f),...e.getSymbols(f)];for(let v=0;v<b.length;v++){const y=b[v],S=Object.getOwnPropertyDescriptor(d,y);(S==null||S.writable)&&(d[y]=l(f[y],y,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})(PT)),PT}var NB;function jpe(){return NB||(NB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=bK();function n(r){return e.cloneDeepWithImpl(r,void 0,r,new Map,void 0)}t.cloneDeep=n})(CT)),CT}var MB;function Dpe(){return MB||(MB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pK(),n=jpe();function r(i){return i=n.cloneDeep(i),a=>e.isMatch(a,i)}t.matches=r})(NT)),NT}var LT={},FT={},IT={},kB;function Rpe(){return kB||(kB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=bK(),n=xK();function r(i,a){return e.cloneDeepWith(i,(o,l,c,u)=>{const d=a?.(o,l,c,u);if(d!==void 0)return d;if(typeof i=="object")switch(Object.prototype.toString.call(i)){case n.numberTag:case n.stringTag:case n.booleanTag:{const f=new i.constructor(i?.valueOf());return e.copyProperties(f,i),f}case n.argumentsTag:{const f={};return e.copyProperties(f,i),f.length=i.length,f[Symbol.iterator]=i[Symbol.iterator],f}default:return}})}t.cloneDeepWith=r})(IT)),IT}var EB;function Ope(){return EB||(EB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Rpe();function n(r){return e.cloneDeepWith(r)}t.cloneDeep=n})(FT)),FT}var UT={},zT={},TB;function yK(){return TB||(TB=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})(zT)),zT}var BT={},AB;function Lpe(){return AB||(AB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=gK();function n(r){return r!==null&&typeof r=="object"&&e.getTag(r)==="[object Arguments]"}t.isArguments=n})(BT)),BT}var CB;function Fpe(){return CB||(CB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=sK(),n=yK(),r=Lpe(),i=GR();function a(o,l){let c;if(Array.isArray(l)?c=l:typeof l=="string"&&e.isDeepKey(l)&&o?.[l]==null?c=i.toPath(l):c=[l],c.length===0)return!1;let u=o;for(let d=0;d<c.length;d++){const f=c[d];if((u==null||!Object.hasOwn(u,f))&&!((Array.isArray(u)||r.isArguments(u))&&n.isIndex(f)&&f<u.length))return!1;u=u[f]}return!0}t.has=a})(UT)),UT}var PB;function Ipe(){return PB||(PB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=pK(),n=VR(),r=Ope(),i=qR(),a=Fpe();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?a.has(u,l):c===void 0?d===void 0:e.isMatch(d,c)}}t.matchesProperty=o})(LT)),LT}var jB;function Upe(){return jB||(jB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=dK(),n=Tpe(),r=Dpe(),i=Ipe();function a(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=a})(_T)),_T}var DB;function zpe(){return DB||(DB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Npe(),n=dK(),r=Epe(),i=Upe();function a(o,l=n.identity){return r.isArrayLikeObject(o)?e.uniqBy(Array.from(o),i.iteratee(l)):[]}t.uniqBy=a})(pT)),pT}var HT,RB;function Bpe(){return RB||(RB=1,HT=zpe().uniqBy),HT}var Hpe=Bpe();const OB=hl(Hpe);function vK(t,e,n){return e===!0?OB(t,n):typeof e=="function"?OB(t,e):t}var $T={exports:{}},VT={};var LB;function $pe(){if(LB)return VT;LB=1;var t=px(),e=Cq();function n(u,d){return u===d&&(u!==0||1/u===1/d)||u!==u&&d!==d}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,a=t.useRef,o=t.useEffect,l=t.useMemo,c=t.useDebugValue;return VT.useSyncExternalStoreWithSelector=function(u,d,f,p,m){var x=a(null);if(x.current===null){var b={hasValue:!1,value:null};x.current=b}else b=x.current;x=l(function(){function y(C){if(!S){if(S=!0,k=C,C=p(C),m!==void 0&&b.hasValue){var E=b.value;if(m(E,C))return T=E}return T=C}if(E=T,r(k,C))return E;var R=p(C);return m!==void 0&&m(E,R)?(k=C,E):(k=C,T=R)}var S=!1,k,T,M=f===void 0?null:f;return[function(){return y(d())},M===null?void 0:function(){return y(M())}]},[d,f,p,m]);var v=i(u,x[0],x[1]);return o(function(){b.hasValue=!0,b.value=v},[v]),c(v),v},VT}var FB;function Vpe(){return FB||(FB=1,$T.exports=$pe()),$T.exports}var wK=Vpe(),YR=_.createContext(null),Gpe=t=>t,Lr=()=>{var t=_.useContext(YR);return t?t.store.dispatch:Gpe},b1=()=>{},qpe=()=>b1,Wpe=(t,e)=>t===e;function It(t){var e=_.useContext(YR);return wK.useSyncExternalStoreWithSelector(e?e.subscription.addNestedSub:qpe,e?e.store.getState:b1,e?e.store.getState:b1,e?t:b1,Wpe)}function Kpe(t,e=`expected a function, instead received ${typeof t}`){if(typeof t!="function")throw new TypeError(e)}function Xpe(t,e=`expected an object, instead received ${typeof t}`){if(typeof t!="object")throw new TypeError(e)}function Ype(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 IB=t=>Array.isArray(t)?t:[t];function Qpe(t){const e=Array.isArray(t[0])?t[0]:t;return Ype(e,"createSelector expects all input-selectors to be functions, but received the following types: "),e}function Zpe(t,e){const n=[],{length:r}=t;for(let i=0;i<r;i++)n.push(t[i].apply(null,e));return n}var Jpe=class{constructor(t){this.value=t}deref(){return this.value}},ege=typeof WeakRef<"u"?WeakRef:Jpe,tge=0,UB=1;function Lw(){return{s:tge,v:void 0,o:null,p:null}}function _K(t,e={}){let n=Lw();const{resultEqualityCheck:r}=e;let i,a=0;function o(){let l=n;const{length:c}=arguments;for(let f=0,p=c;f<p;f++){const m=arguments[f];if(typeof m=="function"||typeof m=="object"&&m!==null){let x=l.o;x===null&&(l.o=x=new WeakMap);const b=x.get(m);b===void 0?(l=Lw(),x.set(m,l)):l=b}else{let x=l.p;x===null&&(l.p=x=new Map);const b=x.get(m);b===void 0?(l=Lw(),x.set(m,l)):l=b}}const u=l;let d;if(l.s===UB)d=l.v;else if(d=t.apply(null,arguments),a++,r){const f=i?.deref?.()??i;f!=null&&r(f,d)&&(d=f,a!==0&&a--),i=typeof d=="object"&&d!==null||typeof d=="function"?new ege(d):d}return u.s=UB,u.v=d,d}return o.clearCache=()=>{n=Lw(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function nge(t,...e){const n=typeof t=="function"?{memoize:t,memoizeOptions:e}:t,r=(...i)=>{let a=0,o=0,l,c={},u=i.pop();typeof u=="object"&&(c=u,u=i.pop()),Kpe(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);const d={...n,...c},{memoize:f,memoizeOptions:p=[],argsMemoize:m=_K,argsMemoizeOptions:x=[]}=d,b=IB(p),v=IB(x),y=Qpe(i),S=f(function(){return a++,u.apply(null,arguments)},...b),k=m(function(){o++;const M=Zpe(y,arguments);return l=S.apply(null,M),l},...v);return Object.assign(k,{resultFunc:u,memoizedResultFunc:S,dependencies:y,dependencyRecomputations:()=>o,resetDependencyRecomputations:()=>{o=0},lastResult:()=>l,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:f,argsMemoize:m})};return Object.assign(r,{withTypes:()=>r}),r}var it=nge(_K),rge=Object.assign((t,e=it)=>{Xpe(t,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof t}`);const n=Object.keys(t),r=n.map(a=>t[a]);return e(r,(...a)=>a.reduce((o,l,c)=>(o[n[c]]=l,o),{}))},{withTypes:()=>rge}),GT={},qT={},WT={},zB;function ige(){return zB||(zB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(r){return typeof r=="symbol"?1:r===null?2:r===void 0?3:r!==r?4:0}const n=(r,i,a)=>{if(r!==i){const o=e(r),l=e(i);if(o===l&&o===0){if(r<i)return a==="desc"?1:-1;if(r>i)return a==="desc"?-1:1}return a==="desc"?l-o:o-l}return 0};t.compareValues=n})(WT)),WT}var KT={},XT={},BB;function SK(){return BB||(BB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return typeof n=="symbol"||n instanceof Symbol}t.isSymbol=e})(XT)),XT}var HB;function age(){return HB||(HB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=SK(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,o){return Array.isArray(a)?!1:typeof a=="number"||typeof a=="boolean"||a==null||e.isSymbol(a)?!0:typeof a=="string"&&(r.test(a)||!n.test(a))||o!=null&&Object.hasOwn(o,a)}t.isKey=i})(KT)),KT}var $B;function sge(){return $B||($B=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=ige(),n=age(),r=GR();function i(a,o,l,c){if(a==null)return[];l=c?void 0:l,Array.isArray(a)||(a=Object.values(a)),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 b=m;for(let v=0;v<x.length&&b!=null;++v)b=b[x[v]];return b},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,f=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 a.map(m=>({original:m,criteria:f.map(x=>d(x,m))})).slice().sort((m,x)=>{for(let b=0;b<f.length;b++){const v=e.compareValues(m.criteria[b],x.criteria[b],l[b]);if(v!==0)return v}return 0}).map(m=>m.original)}t.orderBy=i})(qT)),qT}var YT={},VB;function oge(){return VB||(VB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r=1){const i=[],a=Math.floor(r),o=(l,c)=>{for(let u=0;u<l.length;u++){const d=l[u];Array.isArray(d)&&c<a?o(d,c+1):i.push(d)}};return o(n,0),i}t.flatten=e})(YT)),YT}var QT={},GB;function NK(){return GB||(GB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=yK(),n=XR(),r=hK(),i=mK();function a(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=a})(QT)),QT}var qB;function lge(){return qB||(qB=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=sge(),n=oge(),r=NK();function i(a,...o){const l=o.length;return l>1&&r.isIterateeCall(a,o[0],o[1])?o=[]:l>2&&r.isIterateeCall(o[0],o[1],o[2])&&(o=[o[0]]),e.orderBy(a,n.flatten(o),["asc"])}t.sortBy=i})(GT)),GT}var ZT,WB;function cge(){return WB||(WB=1,ZT=lge().sortBy),ZT}var uge=cge();const SM=hl(uge);var MK=t=>t.legend.settings,dge=t=>t.legend.size,hge=t=>t.legend.payload,fge=it([hge,MK],(t,e)=>{var{itemSorter:n}=e,r=t.flat(1);return n?SM(r,n):r});function mge(){return It(fge)}var Fw=1;function kK(){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 a=i.getBoundingClientRect(),o={height:a.height,left:a.left,top:a.top,width:a.width};(Math.abs(o.height-e.height)>Fw||Math.abs(o.left-e.left)>Fw||Math.abs(o.top-e.top)>Fw||Math.abs(o.width-e.width)>Fw)&&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 Da(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 pge=typeof Symbol=="function"&&Symbol.observable||"@@observable",KB=pge,JT=()=>Math.random().toString(36).substring(7).split("").join("."),gge={INIT:`@@redux/INIT${JT()}`,REPLACE:`@@redux/REPLACE${JT()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${JT()}`},nS=gge;function QR(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 EK(t,e,n){if(typeof t!="function")throw new Error(Da(2));if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(Da(0));if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(Da(1));return n(EK)(t,e)}let r=t,i=e,a=new Map,o=a,l=0,c=!1;function u(){o===a&&(o=new Map,a.forEach((v,y)=>{o.set(y,v)}))}function d(){if(c)throw new Error(Da(3));return i}function f(v){if(typeof v!="function")throw new Error(Da(4));if(c)throw new Error(Da(5));let y=!0;u();const S=l++;return o.set(S,v),function(){if(y){if(c)throw new Error(Da(6));y=!1,u(),o.delete(S),a=null}}}function p(v){if(!QR(v))throw new Error(Da(7));if(typeof v.type>"u")throw new Error(Da(8));if(typeof v.type!="string")throw new Error(Da(17));if(c)throw new Error(Da(9));try{c=!0,i=r(i,v)}finally{c=!1}return(a=o).forEach(S=>{S()}),v}function m(v){if(typeof v!="function")throw new Error(Da(10));r=v,p({type:nS.REPLACE})}function x(){const v=f;return{subscribe(y){if(typeof y!="object"||y===null)throw new Error(Da(11));function S(){const T=y;T.next&&T.next(d())}return S(),{unsubscribe:v(S)}},[KB](){return this}}}return p({type:nS.INIT}),{dispatch:p,subscribe:f,getState:d,replaceReducer:m,[KB]:x}}function xge(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:nS.INIT})>"u")throw new Error(Da(12));if(typeof n(void 0,{type:nS.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(Da(13))})}function TK(t){const e=Object.keys(t),n={};for(let a=0;a<e.length;a++){const o=e[a];typeof t[o]=="function"&&(n[o]=t[o])}const r=Object.keys(n);let i;try{xge(n)}catch(a){i=a}return function(o={},l){if(i)throw i;let c=!1;const u={};for(let d=0;d<r.length;d++){const f=r[d],p=n[f],m=o[f],x=p(m,l);if(typeof x>"u")throw l&&l.type,new Error(Da(14));u[f]=x,c=c||x!==m}return c=c||r.length!==Object.keys(o).length,c?u:o}}function rS(...t){return t.length===0?e=>e:t.length===1?t[0]:t.reduce((e,n)=>(...r)=>e(n(...r)))}function bge(...t){return e=>(n,r)=>{const i=e(n,r);let a=()=>{throw new Error(Da(15))};const o={getState:i.getState,dispatch:(c,...u)=>a(c,...u)},l=t.map(c=>c(o));return a=rS(...l)(i.dispatch),{...i,dispatch:a}}}function AK(t){return QR(t)&&"type"in t&&typeof t.type=="string"}var CK=Symbol.for("immer-nothing"),XB=Symbol.for("immer-draftable"),bs=Symbol.for("immer-state");function El(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var uo=Object,Vg=uo.getPrototypeOf,iS="constructor",NM="prototype",Aj="configurable",aS="enumerable",y1="writable",Y0="value",Fu=t=>!!t&&!!t[bs];function Ul(t){return t?PK(t)||MM(t)||!!t[XB]||!!t[iS]?.[XB]||kM(t)||EM(t):!1}var yge=uo[NM][iS].toString(),YB=new WeakMap;function PK(t){if(!t||!ZR(t))return!1;const e=Vg(t);if(e===null||e===uo[NM])return!0;const n=uo.hasOwnProperty.call(e,iS)&&e[iS];if(n===Object)return!0;if(!sg(n))return!1;let r=YB.get(n);return r===void 0&&(r=Function.toString.call(n),YB.set(n,r)),r===yge}function Hy(t,e,n=!0){$y(t)===0?(n?Reflect.ownKeys(t):uo.keys(t)).forEach(i=>{e(i,t[i],t)}):t.forEach((r,i)=>e(i,r,t))}function $y(t){const e=t[bs];return e?e.type_:MM(t)?1:kM(t)?2:EM(t)?3:0}var QB=(t,e,n=$y(t))=>n===2?t.has(e):uo[NM].hasOwnProperty.call(t,e),Cj=(t,e,n=$y(t))=>n===2?t.get(e):t[e],sS=(t,e,n,r=$y(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function vge(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var MM=Array.isArray,kM=t=>t instanceof Map,EM=t=>t instanceof Set,ZR=t=>typeof t=="object",sg=t=>typeof t=="function",eA=t=>typeof t=="boolean",hu=t=>t.copy_||t.base_,JR=t=>t.modified_?t.copy_:t.base_;function Pj(t,e){if(kM(t))return new Map(t);if(EM(t))return new Set(t);if(MM(t))return Array[NM].slice.call(t);const n=PK(t);if(e===!0||e==="class_only"&&!n){const r=uo.getOwnPropertyDescriptors(t);delete r[bs];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],l=r[o];l[y1]===!1&&(l[y1]=!0,l[Aj]=!0),(l.get||l.set)&&(r[o]={[Aj]:!0,[y1]:!0,[aS]:l[aS],[Y0]:t[o]})}return uo.create(Vg(t),r)}else{const r=Vg(t);if(r!==null&&n)return{...t};const i=uo.create(r);return uo.assign(i,t)}}function eO(t,e=!1){return TM(t)||Fu(t)||!Ul(t)||($y(t)>1&&uo.defineProperties(t,{set:Iw,add:Iw,clear:Iw,delete:Iw}),uo.freeze(t),e&&Hy(t,(n,r)=>{eO(r,!0)},!1)),t}function wge(){El(2)}var Iw={[Y0]:wge};function TM(t){return t===null||!ZR(t)?!0:uo.isFrozen(t)}var oS="MapSet",jj="Patches",jK={};function Gg(t){const e=jK[t];return e||El(0,t),e}var _ge=t=>!!jK[t],Q0,DK=()=>Q0,Sge=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:_ge(oS)?Gg(oS):void 0});function ZB(t,e){e&&(t.patchPlugin_=Gg(jj),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Dj(t){Rj(t),t.drafts_.forEach(Nge),t.drafts_=null}function Rj(t){t===Q0&&(Q0=t.parent_)}var JB=t=>Q0=Sge(Q0,t);function Nge(t){const e=t[bs];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function e8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[bs].modified_&&(Dj(e),El(4)),Ul(t)&&(t=t8(e,t));const{patchPlugin_:i}=e;i&&i.generateReplacementPatches_(n[bs].base_,t,e)}else t=t8(e,n);return Mge(e,t,!0),Dj(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==CK?t:void 0}function t8(t,e){if(TM(e))return e;const n=e[bs];if(!n)return tO(e,t.handledSet_,t);if(!AM(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);LK(n,t)}return n.copy_}function Mge(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&eO(e,n)}function RK(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var AM=(t,e)=>t.scope_===e,kge=[];function OK(t,e,n,r){const i=hu(t),a=t.type_;if(r!==void 0&&Cj(i,r,a)===e){sS(i,r,n,a);return}if(!t.draftLocations_){const l=t.draftLocations_=new Map;Hy(i,(c,u)=>{if(Fu(u)){const d=l.get(u)||[];d.push(c),l.set(u,d)}})}const o=t.draftLocations_.get(e)??kge;for(const l of o)sS(i,l,n,a)}function Ege(t,e,n){t.callbacks_.push(function(i){const a=e;if(!a||!AM(a,i))return;i.mapSetPlugin_?.fixSetContents(a);const o=JR(a);OK(t,a.draft_??a,o,n),LK(a,i)})}function LK(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)}RK(t)}}function Tge(t,e,n){const{scope_:r}=t;if(Fu(n)){const i=n[bs];AM(i,r)&&i.callbacks_.push(function(){v1(t);const o=JR(i);OK(t,n,o,e)})}else Ul(n)&&t.callbacks_.push(function(){const a=hu(t);Cj(a,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&tO(Cj(t.copy_,e,t.type_),r.handledSet_,r)})}function tO(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||Fu(t)||e.has(t)||!Ul(t)||TM(t)||(e.add(t),Hy(t,(r,i)=>{if(Fu(i)){const a=i[bs];if(AM(a,n)){const o=JR(a);sS(t,r,o,t.type_),RK(a)}}else Ul(i)&&tO(i,e,n)})),t}function Age(t,e){const n=MM(t),r={type_:n?1:0,scope_:e?e.scope_:DK(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let i=r,a=nO;n&&(i=[r],a=Z0);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,[l,r]}var nO={get(t,e){if(e===bs)return t;const n=hu(t);if(!QB(n,e,t.type_))return Cge(t,n,e);const r=n[e];if(t.finalized_||!Ul(r))return r;if(r===tA(t.base_,e)){v1(t);const i=t.type_===1?+e:e,a=Lj(t.scope_,r,t,i);return t.copy_[i]=a}return r},has(t,e){return e in hu(t)},ownKeys(t){return Reflect.ownKeys(hu(t))},set(t,e,n){const r=FK(hu(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=tA(hu(t),e),a=i?.[bs];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if(vge(n,i)&&(n!==void 0||QB(t.base_,e,t.type_)))return!0;v1(t),Oj(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),Tge(t,e,n)),!0},deleteProperty(t,e){return v1(t),tA(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),Oj(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=hu(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[y1]:!0,[Aj]:t.type_!==1||e!=="length",[aS]:r[aS],[Y0]:n[e]}},defineProperty(){El(11)},getPrototypeOf(t){return Vg(t.base_)},setPrototypeOf(){El(12)}},Z0={};Hy(nO,(t,e)=>{Z0[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}});Z0.deleteProperty=function(t,e){return Z0.set.call(this,t,e,void 0)};Z0.set=function(t,e,n){return nO.set.call(this,t[0],e,n,t[0])};function tA(t,e){const n=t[bs];return(n?hu(n):t)[e]}function Cge(t,e,n){const r=FK(e,n);return r?Y0 in r?r[Y0]:r.get?.call(t.draft_):void 0}function FK(t,e){if(!(e in t))return;let n=Vg(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=Vg(n)}}function Oj(t){t.modified_||(t.modified_=!0,t.parent_&&Oj(t.parent_))}function v1(t){t.copy_||(t.assigned_=new Map,t.copy_=Pj(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Pge=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(n,r,i)=>{if(sg(n)&&!sg(r)){const o=r;r=n;const l=this;return function(u=o,...d){return l.produce(u,f=>r.call(this,f,...d))}}sg(r)||El(6),i!==void 0&&!sg(i)&&El(7);let a;if(Ul(n)){const o=JB(this),l=Lj(o,n,void 0);let c=!0;try{a=r(l),c=!1}finally{c?Dj(o):Rj(o)}return ZB(o,i),e8(a,o)}else if(!n||!ZR(n)){if(a=r(n),a===void 0&&(a=n),a===CK&&(a=void 0),this.autoFreeze_&&eO(a,!0),i){const o=[],l=[];Gg(jj).generateReplacementPatches_(n,a,{patches_:o,inversePatches_:l}),i(o,l)}return a}else El(1,n)},this.produceWithPatches=(n,r)=>{if(sg(n))return(l,...c)=>this.produceWithPatches(l,u=>n(u,...c));let i,a;return[this.produce(n,r,(l,c)=>{i=l,a=c}),i,a]},eA(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),eA(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),eA(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){Ul(e)||El(8),Fu(e)&&(e=Ol(e));const n=JB(this),r=Lj(n,e,void 0);return r[bs].isManual_=!0,Rj(n),r}finishDraft(e,n){const r=e&&e[bs];(!r||!r.isManual_)&&El(9);const{scope_:i}=r;return ZB(i,n),e8(void 0,i)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,n){let r;for(r=n.length-1;r>=0;r--){const a=n[r];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}r>-1&&(n=n.slice(r+1));const i=Gg(jj).applyPatches_;return Fu(e)?i(e,n):this.produce(e,a=>i(a,n))}};function Lj(t,e,n,r){const[i,a]=kM(e)?Gg(oS).proxyMap_(e,n):EM(e)?Gg(oS).proxySet_(e,n):Age(e,n);return(n?.scope_??DK()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?Ege(n,a,r):a.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(a);const{patchPlugin_:u}=c;a.modified_&&u&&u.generatePatches_(a,[],c)}),i}function Ol(t){return Fu(t)||El(10,t),IK(t)}function IK(t){if(!Ul(t)||TM(t))return t;const e=t[bs];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=Pj(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=Pj(t,!0);return Hy(n,(i,a)=>{sS(n,i,IK(a))},r),e&&(e.finalized_=!1),n}var jge=new Pge,UK=jge.produce;function zK(t){return({dispatch:n,getState:r})=>i=>a=>typeof a=="function"?a(n,r,t):i(a)}var Dge=zK(),Rge=zK,Oge=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?rS:rS.apply(null,arguments)};function ul(t,e){function n(...r){if(e){let i=e(...r);if(!i)throw new Error(fo(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=>AK(r)&&r.type===t,n}var BK=class i0 extends Array{constructor(...e){super(...e),Object.setPrototypeOf(this,i0.prototype)}static get[Symbol.species](){return i0}concat(...e){return super.concat.apply(this,e)}prepend(...e){return e.length===1&&Array.isArray(e[0])?new i0(...e[0].concat(this)):new i0(...e.concat(this))}};function n8(t){return Ul(t)?UK(t,()=>{}):t}function Uw(t,e,n){return t.has(e)?t.get(e):t.set(e,n(e)).get(e)}function Lge(t){return typeof t=="boolean"}var Fge=()=>function(e){const{thunk:n=!0,immutableCheck:r=!0,serializableCheck:i=!0,actionCreatorCheck:a=!0}=e??{};let o=new BK;return n&&(Lge(n)?o.push(Dge):o.push(Rge(n.extraArgument))),o},HK="RTK_autoBatch",Jr=()=>t=>({payload:t,meta:{[HK]:!0}}),r8=t=>e=>{setTimeout(e,t)},$K=(t={type:"raf"})=>e=>(...n)=>{const r=e(...n);let i=!0,a=!1,o=!1;const l=new Set,c=t.type==="tick"?queueMicrotask:t.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame:r8(10):t.type==="callback"?t.queueNotification:r8(t.timeout),u=()=>{o=!1,a&&(a=!1,l.forEach(d=>d()))};return Object.assign({},r,{subscribe(d){const f=()=>i&&d(),p=r.subscribe(f);return l.add(d),()=>{p(),l.delete(d)}},dispatch(d){try{return i=!d?.meta?.[HK],a=!i,a&&(o||(o=!0,c(u))),r.dispatch(d)}finally{i=!0}}})},Ige=t=>function(n){const{autoBatch:r=!0}=n??{};let i=new BK(t);return r&&i.push($K(typeof r=="object"?r:void 0)),i};function Uge(t){const e=Fge(),{reducer:n=void 0,middleware:r,devTools:i=!0,preloadedState:a=void 0,enhancers:o=void 0}=t||{};let l;if(typeof n=="function")l=n;else if(QR(n))l=TK(n);else throw new Error(fo(1));let c;typeof r=="function"?c=r(e):c=e();let u=rS;i&&(u=Oge({trace:!1,...typeof i=="object"&&i}));const d=bge(...c),f=Ige(d);let p=typeof o=="function"?o(f):f();const m=u(...p);return EK(l,a,m)}function VK(t){const e={},n=[];let r;const i={addCase(a,o){const l=typeof a=="string"?a:a.type;if(!l)throw new Error(fo(28));if(l in e)throw new Error(fo(29));return e[l]=o,i},addAsyncThunk(a,o){return o.pending&&(e[a.pending.type]=o.pending),o.rejected&&(e[a.rejected.type]=o.rejected),o.fulfilled&&(e[a.fulfilled.type]=o.fulfilled),o.settled&&n.push({matcher:a.settled,reducer:o.settled}),i},addMatcher(a,o){return n.push({matcher:a,reducer:o}),i},addDefaultCase(a){return r=a,i}};return t(i),[e,n,r]}function zge(t){return typeof t=="function"}function Bge(t,e){let[n,r,i]=VK(e),a;if(zge(t))a=()=>n8(t());else{const l=n8(t);a=()=>l}function o(l=a(),c){let u=[n[c.type],...r.filter(({matcher:d})=>d(c)).map(({reducer:d})=>d)];return u.filter(d=>!!d).length===0&&(u=[i]),u.reduce((d,f)=>{if(f)if(Fu(d)){const m=f(d,c);return m===void 0?d:m}else{if(Ul(d))return UK(d,p=>f(p,c));{const p=f(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=a,o}var Hge="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",$ge=(t=21)=>{let e="",n=t;for(;n--;)e+=Hge[Math.random()*64|0];return e},Vge=Symbol.for("rtk-slice-createasyncthunk");function Gge(t,e){return`${t}/${e}`}function qge({creators:t}={}){const e=t?.asyncThunk?.[Vge];return function(r){const{name:i,reducerPath:a=i}=r;if(!i)throw new Error(fo(11));const o=(typeof r.reducers=="function"?r.reducers(Kge()):r.reducers)||{},l=Object.keys(o),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(k,T){const M=typeof k=="string"?k:k.type;if(!M)throw new Error(fo(12));if(M in c.sliceCaseReducersByType)throw new Error(fo(13));return c.sliceCaseReducersByType[M]=T,u},addMatcher(k,T){return c.sliceMatchers.push({matcher:k,reducer:T}),u},exposeAction(k,T){return c.actionCreators[k]=T,u},exposeCaseReducer(k,T){return c.sliceCaseReducersByName[k]=T,u}};l.forEach(k=>{const T=o[k],M={reducerName:k,type:Gge(i,k),createNotation:typeof r.reducers=="function"};Yge(T)?Zge(M,T,u,e):Xge(M,T,u)});function d(){const[k={},T=[],M=void 0]=typeof r.extraReducers=="function"?VK(r.extraReducers):[r.extraReducers],C={...k,...c.sliceCaseReducersByType};return Bge(r.initialState,E=>{for(let R in C)E.addCase(R,C[R]);for(let R of c.sliceMatchers)E.addMatcher(R.matcher,R.reducer);for(let R of T)E.addMatcher(R.matcher,R.reducer);M&&E.addDefaultCase(M)})}const f=k=>k,p=new Map,m=new WeakMap;let x;function b(k,T){return x||(x=d()),x(k,T)}function v(){return x||(x=d()),x.getInitialState()}function y(k,T=!1){function M(E){let R=E[k];return typeof R>"u"&&T&&(R=Uw(m,M,v)),R}function C(E=f){const R=Uw(p,T,()=>new WeakMap);return Uw(R,E,()=>{const A={};for(const[D,I]of Object.entries(r.selectors??{}))A[D]=Wge(I,E,()=>Uw(m,E,v),T);return A})}return{reducerPath:k,getSelectors:C,get selectors(){return C(M)},selectSlice:M}}const S={name:i,reducer:b,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:v,...y(a),injectInto(k,{reducerPath:T,...M}={}){const C=T??a;return k.inject({reducerPath:C,reducer:b},M),{...S,...y(C,!0)}}};return S}}function Wge(t,e,n,r){function i(a,...o){let l=e(a);return typeof l>"u"&&r&&(l=n()),t(l,...o)}return i.unwrapped=t,i}var $s=qge();function Kge(){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 Xge({type:t,reducerName:e,createNotation:n},r,i){let a,o;if("reducer"in r){if(n&&!Qge(r))throw new Error(fo(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(t,a).exposeCaseReducer(e,a).exposeAction(e,o?ul(t,o):ul(t))}function Yge(t){return t._reducerDefinitionType==="asyncThunk"}function Qge(t){return t._reducerDefinitionType==="reducerWithPrepare"}function Zge({type:t,reducerName:e},n,r,i){if(!i)throw new Error(fo(18));const{payloadCreator:a,fulfilled:o,pending:l,rejected:c,settled:u,options:d}=n,f=i(t,a,d);r.exposeAction(e,f),o&&r.addCase(f.fulfilled,o),l&&r.addCase(f.pending,l),c&&r.addCase(f.rejected,c),u&&r.addMatcher(f.settled,u),r.exposeCaseReducer(e,{fulfilled:o||zw,pending:l||zw,rejected:c||zw,settled:u||zw})}function zw(){}var Jge="task",GK="listener",qK="completed",rO="cancelled",exe=`task-${rO}`,txe=`task-${qK}`,Fj=`${GK}-${rO}`,nxe=`${GK}-${qK}`,CM=class{constructor(t){this.code=t,this.message=`${Jge} ${rO} (reason: ${t})`}name="TaskAbortError";message},iO=(t,e)=>{if(typeof t!="function")throw new TypeError(fo(32))},lS=()=>{},WK=(t,e=lS)=>(t.catch(e),t),KK=(t,e)=>(t.addEventListener("abort",e,{once:!0}),()=>t.removeEventListener("abort",e)),Bf=(t,e)=>{const n=t.signal;n.aborted||("reason"in n||Object.defineProperty(n,"reason",{enumerable:!0,value:e,configurable:!0,writable:!0}),t.abort(e))},Hf=t=>{if(t.aborted){const{reason:e}=t;throw new CM(e)}};function XK(t,e){let n=lS;return new Promise((r,i)=>{const a=()=>i(new CM(t.reason));if(t.aborted){a();return}n=KK(t,a),e.finally(()=>n()).then(r,i)}).finally(()=>{n=lS})}var rxe=async(t,e)=>{try{return await Promise.resolve(),{status:"ok",value:await t()}}catch(n){return{status:n instanceof CM?"cancelled":"rejected",error:n}}finally{e?.()}},cS=t=>e=>WK(XK(t,e).then(n=>(Hf(t),n))),YK=t=>{const e=cS(t);return n=>e(new Promise(r=>setTimeout(r,n)))},{assign:Mg}=Object,i8={},PM="listenerMiddleware",ixe=(t,e)=>{const n=r=>KK(t,()=>Bf(r,t.reason));return(r,i)=>{iO(r);const a=new AbortController;n(a);const o=rxe(async()=>{Hf(t),Hf(a.signal);const l=await r({pause:cS(a.signal),delay:YK(a.signal),signal:a.signal});return Hf(a.signal),l},()=>Bf(a,txe));return i?.autoJoin&&e.push(o.catch(lS)),{result:cS(t)(o),cancel(){Bf(a,exe)}}}},axe=(t,e)=>{const n=async(r,i)=>{Hf(e);let a=()=>{};const l=[new Promise((c,u)=>{let d=t({predicate:r,effect:(f,p)=>{p.unsubscribe(),c([f,p.getState(),p.getOriginalState()])}});a=()=>{d(),u()}})];i!=null&&l.push(new Promise(c=>setTimeout(c,i,null)));try{const c=await XK(e,Promise.race(l));return Hf(e),c}finally{a()}};return(r,i)=>WK(n(r,i))},QK=t=>{let{type:e,actionCreator:n,matcher:r,predicate:i,effect:a}=t;if(e)i=ul(e).match;else if(n)e=n.type,i=n.match;else if(r)i=r;else if(!i)throw new Error(fo(21));return iO(a),{predicate:i,type:e,effect:a}},ZK=Mg(t=>{const{type:e,predicate:n,effect:r}=QK(t);return{id:$ge(),effect:r,type:e,predicate:n,pending:new Set,unsubscribe:()=>{throw new Error(fo(22))}}},{withTypes:()=>ZK}),a8=(t,e)=>{const{type:n,effect:r,predicate:i}=QK(e);return Array.from(t.values()).find(a=>(typeof n=="string"?a.type===n:a.predicate===i)&&a.effect===r)},Ij=t=>{t.pending.forEach(e=>{Bf(e,Fj)})},sxe=(t,e)=>()=>{for(const n of e.keys())Ij(n);t.clear()},s8=(t,e,n)=>{try{t(e,n)}catch(r){setTimeout(()=>{throw r},0)}},JK=Mg(ul(`${PM}/add`),{withTypes:()=>JK}),oxe=ul(`${PM}/removeAll`),eX=Mg(ul(`${PM}/remove`),{withTypes:()=>eX}),lxe=(...t)=>{console.error(`${PM}/error`,...t)},Vy=(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:a,onError:o=lxe}=t;iO(o);const l=m=>(m.unsubscribe=()=>e.delete(m.id),e.set(m.id,m),x=>{m.unsubscribe(),x?.cancelActive&&Ij(m)}),c=m=>{const x=a8(e,m)??ZK(m);return l(x)};Mg(c,{withTypes:()=>c});const u=m=>{const x=a8(e,m);return x&&(x.unsubscribe(),m.cancelActive&&Ij(x)),!!x};Mg(u,{withTypes:()=>u});const d=async(m,x,b,v)=>{const y=new AbortController,S=axe(c,y.signal),k=[];try{m.pending.add(y),r(m),await Promise.resolve(m.effect(x,Mg({},b,{getOriginalState:v,condition:(T,M)=>S(T,M).then(Boolean),take:S,delay:YK(y.signal),pause:cS(y.signal),extra:a,signal:y.signal,fork:ixe(y.signal,k),unsubscribe:m.unsubscribe,subscribe:()=>{e.set(m.id,m)},cancelActiveListeners:()=>{m.pending.forEach((T,M,C)=>{T!==y&&(Bf(T,Fj),C.delete(T))})},cancel:()=>{Bf(y,Fj),m.pending.delete(y)},throwIfCancelled:()=>{Hf(y.signal)}})))}catch(T){T instanceof CM||s8(o,T,{raisedBy:"effect"})}finally{await Promise.all(k),Bf(y,nxe),i(m),m.pending.delete(y)}},f=sxe(e,n);return{middleware:m=>x=>b=>{if(!AK(b))return x(b);if(JK.match(b))return c(b.payload);if(oxe.match(b)){f();return}if(eX.match(b))return u(b.payload);let v=m.getState();const y=()=>{if(v===i8)throw new Error(fo(23));return v};let S;try{if(S=x(b),e.size>0){const k=m.getState(),T=Array.from(e.values());for(const M of T){let C=!1;try{C=M.predicate(b,k,v)}catch(E){C=!1,s8(o,E,{raisedBy:"predicate"})}C&&d(M,b,m,y)}}}finally{v=i8}return S},startListening:c,stopListening:u,clearListeners:f}};function fo(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 cxe={layoutType:"horizontal",width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},tX=$s({name:"chartLayout",initialState:cxe,reducers:{setLayout(t,e){t.layoutType=e.payload},setChartSize(t,e){t.width=e.payload.width,t.height=e.payload.height},setMargin(t,e){var n,r,i,a;t.margin.top=(n=e.payload.top)!==null&&n!==void 0?n:0,t.margin.right=(r=e.payload.right)!==null&&r!==void 0?r:0,t.margin.bottom=(i=e.payload.bottom)!==null&&i!==void 0?i:0,t.margin.left=(a=e.payload.left)!==null&&a!==void 0?a:0},setScale(t,e){t.scale=e.payload}}}),{setMargin:uxe,setLayout:dxe,setChartSize:hxe,setScale:fxe}=tX.actions,mxe=tX.reducer;function nX(t,e,n){return Array.isArray(t)&&t&&e+n!==0?t.slice(e,n+1):t}function o8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function pg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?o8(Object(n),!0).forEach(function(r){pxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):o8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function pxe(t,e,n){return(e=gxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function gxe(t){var e=xxe(t,"string");return typeof e=="symbol"?e:e+""}function xxe(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:cl(e)?cm(t,e,n):typeof e=="function"?e(t):n}var bxe=(t,e,n)=>{if(e&&n){var{width:r,height:i}=n,{align:a,verticalAlign:o,layout:l}=e;if((l==="vertical"||l==="horizontal"&&o==="middle")&&a!=="center"&&zt(t[a]))return pg(pg({},t),{},{[a]:t[a]+(r||0)});if((l==="horizontal"||l==="vertical"&&a==="center")&&o!=="middle"&&zt(t[o]))return pg(pg({},t),{},{[o]:t[o]+(i||0)})}return t},Ec=(t,e)=>t==="horizontal"&&e==="xAxis"||t==="vertical"&&e==="yAxis"||t==="centric"&&e==="angleAxis"||t==="radial"&&e==="radiusAxis",rX=(t,e,n,r)=>{if(r)return t.map(l=>l.coordinate);var i,a,o=t.map(l=>(l.coordinate===e&&(i=!0),l.coordinate===n&&(a=!0),l.coordinate));return i||o.push(e),a||o.push(n),o},iX=(t,e,n)=>{if(!t)return null;var{duplicateDomain:r,type:i,range:a,scale:o,realScaleType:l,isCategorical:c,categoricalDomain:u,tickCount:d,ticks:f,niceTicks:p,axisType:m}=t;if(!o)return null;var x=l==="scaleBand"&&o.bandwidth?o.bandwidth()/2:2,b=i==="category"&&o.bandwidth?o.bandwidth()/x:0;if(b=m==="angleAxis"&&a&&a.length>=2?va(a[0]-a[1])*2*b:b,f||p){var v=(f||p||[]).map((y,S)=>{var k=r?r.indexOf(y):y;return{coordinate:o(k)+b,value:y,offset:b,index:S}});return v.filter(y=>!Hs(y.coordinate))}return c&&u?u.map((y,S)=>({coordinate:o(y)+b,value:y,index:S,offset:b})):o.ticks&&d!=null?o.ticks(d).map((y,S)=>({coordinate:o(y)+b,value:y,offset:b,index:S})):o.domain().map((y,S)=>({coordinate:o(y)+b,value:r?r[y]:y,index:S,offset:b}))},l8=1e-4,yxe=t=>{var e=t.domain();if(!(!e||e.length<=2)){var n=e.length,r=t.range(),i=Math.min(r[0],r[1])-l8,a=Math.max(r[0],r[1])+l8,o=t(e[0]),l=t(e[n-1]);(o<i||o>a||l<i||l>a)&&t.domain([e[0],e[n-1]])}},vxe=(t,e)=>{if(!e||e.length!==2||!zt(e[0])||!zt(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(!zt(t[0])||t[0]<n)&&(i[0]=n),(!zt(t[1])||t[1]>r)&&(i[1]=r),i[0]>r&&(i[0]=r),i[1]<n&&(i[1]=n),i},wxe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0,o=0;o<e;++o){var l=Hs(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]=a,t[o][n][1]=a+l,a=t[o][n][1])}},_xe=t=>{var e=t.length;if(!(e<=0))for(var n=0,r=t[0].length;n<r;++n)for(var i=0,a=0;a<e;++a){var o=Hs(t[a][n][1])?t[a][n][0]:t[a][n][1];o>=0?(t[a][n][0]=i,t[a][n][1]=i+o,i=t[a][n][1]):(t[a][n][0]=0,t[a][n][1]=0)}},Sxe={sign:wxe,expand:qme,none:$g,silhouette:Wme,wiggle:Kme,positive:_xe},Nxe=(t,e,n)=>{var r=Sxe[n],i=Gme().keys(e).value((a,o)=>Number(yr(a,o,0))).order(Ej).offset(r);return i(t)};function aX(t){return t==null?void 0:String(t)}function uS(t){var{axis:e,ticks:n,bandSize:r,entry:i,index:a,dataKey:o}=t;if(e.type==="category"){if(!e.allowDuplicatedCategory&&e.dataKey&&!Yr(i[e.dataKey])){var l=lK(n,"value",i[e.dataKey]);if(l)return l.coordinate+r/2}return n[a]?n[a].coordinate+r/2:null}var c=yr(i,Yr(o)?e.dataKey:o);return Yr(c)?null:e.scale(c)}var c8=t=>{var{axis:e,ticks:n,offset:r,bandSize:i,entry:a,index:o}=t;if(e.type==="category")return n[o]?n[o].coordinate+r:null;var l=yr(a,e.dataKey,e.scale.domain()[o]);return Yr(l)?null:e.scale(l)-i/2+r},Mxe=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]},kxe=t=>{var e=t.flat(2).filter(zt);return[Math.min(...e),Math.max(...e)]},Exe=t=>[t[0]===1/0?0:t[0],t[1]===-1/0?0:t[1]],Txe=(t,e,n)=>{if(t!=null)return Exe(Object.keys(t).reduce((r,i)=>{var a=t[i],{stackedData:o}=a,l=o.reduce((c,u)=>{var d=nX(u,e,n),f=kxe(d);return[Math.min(c[0],f[0]),Math.max(c[1],f[1])]},[1/0,-1/0]);return[Math.min(l[0],r[0]),Math.max(l[1],r[1])]},[1/0,-1/0]))},u8=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,d8=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,wh=(t,e,n)=>{if(t&&t.scale&&t.scale.bandwidth){var r=t.scale.bandwidth();if(!n||r>0)return r}if(t&&e&&e.length>=2){for(var i=SM(e,d=>d.coordinate),a=1/0,o=1,l=i.length;o<l;o++){var c=i[o],u=i[o-1];a=Math.min((c.coordinate||0)-(u.coordinate||0),a)}return a===1/0?0:a}return n?void 0:0};function h8(t){var{tooltipEntrySettings:e,dataKey:n,payload:r,value:i,name:a}=t;return pg(pg({},e),{},{dataKey:n,payload:r,value:i,name:a})}function Lh(t,e){if(t)return String(t);if(typeof e=="string")return e}var Axe=(t,e)=>{if(e==="horizontal")return t.chartX;if(e==="vertical")return t.chartY},Cxe=(t,e)=>e==="centric"?t.angle:t.radius,qu=t=>t.layout.width,Wu=t=>t.layout.height,Pxe=t=>t.layout.scale,sX=t=>t.layout.margin,jM=it(t=>t.cartesianAxis.xAxis,t=>Object.values(t)),DM=it(t=>t.cartesianAxis.yAxis,t=>Object.values(t)),oX="data-recharts-item-index",lX="data-recharts-item-data-key",Gy=60;function f8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Bw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?f8(Object(n),!0).forEach(function(r){jxe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):f8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function jxe(t,e,n){return(e=Dxe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Dxe(t){var e=Rxe(t,"string");return typeof e=="symbol"?e:e+""}function Rxe(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 Oxe=t=>t.brush.height;function Lxe(t){var e=DM(t);return e.reduce((n,r)=>{if(r.orientation==="left"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Gy;return n+i}return n},0)}function Fxe(t){var e=DM(t);return e.reduce((n,r)=>{if(r.orientation==="right"&&!r.mirror&&!r.hide){var i=typeof r.width=="number"?r.width:Gy;return n+i}return n},0)}function Ixe(t){var e=jM(t);return e.reduce((n,r)=>r.orientation==="top"&&!r.mirror&&!r.hide?n+r.height:n,0)}function Uxe(t){var e=jM(t);return e.reduce((n,r)=>r.orientation==="bottom"&&!r.mirror&&!r.hide?n+r.height:n,0)}var ra=it([qu,Wu,sX,Oxe,Lxe,Fxe,Ixe,Uxe,MK,dge],(t,e,n,r,i,a,o,l,c,u)=>{var d={left:(n.left||0)+i,right:(n.right||0)+a},f={top:(n.top||0)+o,bottom:(n.bottom||0)+l},p=Bw(Bw({},f),d),m=p.bottom;p.bottom+=r,p=bxe(p,c,u);var x=t-p.left-p.right,b=e-p.top-p.bottom;return Bw(Bw({brushBottom:m},p),{},{width:Math.max(x,0),height:Math.max(b,0)})}),zxe=it(ra,t=>({x:t.left,y:t.top,width:t.width,height:t.height})),aO=it(qu,Wu,(t,e)=>({x:0,y:0,width:t,height:e})),Bxe=_.createContext(null),ia=()=>_.useContext(Bxe)!=null,RM=t=>t.brush,OM=it([RM,ra,sX],(t,e,n)=>({height:t.height,x:zt(t.x)?t.x:e.left,y:zt(t.y)?t.y:e.top+e.height+e.brushBottom-(n?.bottom||0),width:zt(t.width)?t.width:e.width})),nA={},rA={},iA={},m8;function Hxe(){return m8||(m8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n,r,{signal:i,edges:a}={}){let o,l=null;const c=a!=null&&a.includes("leading"),u=a==null||a.includes("trailing"),d=()=>{l!==null&&(n.apply(o,l),o=void 0,l=null)},f=()=>{u&&d(),b()};let p=null;const m=()=>{p!=null&&clearTimeout(p),p=setTimeout(()=>{p=null,f()},r)},x=()=>{p!==null&&(clearTimeout(p),p=null)},b=()=>{x(),o=void 0,l=null},v=()=>{d()},y=function(...S){if(i?.aborted)return;o=this,l=S;const k=p==null;m(),c&&k&&d()};return y.schedule=m,y.cancel=b,y.flush=v,i?.addEventListener("abort",b,{once:!0}),y}t.debounce=e})(iA)),iA}var p8;function $xe(){return p8||(p8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Hxe();function n(r,i=0,a={}){typeof a!="object"&&(a={});const{leading:o=!1,trailing:l=!0,maxWait:c}=a,u=Array(2);o&&(u[0]="leading"),l&&(u[1]="trailing");let d,f=null;const p=e.debounce(function(...b){d=r.apply(this,b),f=null},i,{edges:u}),m=function(...b){return c!=null&&(f===null&&(f=Date.now()),Date.now()-f>=c)?(d=r.apply(this,b),f=Date.now(),p.cancel(),p.schedule(),d):(p.apply(this,b),d)},x=()=>(p.flush(),d);return m.cancel=p.cancel,m.flush=x,m}t.debounce=n})(rA)),rA}var g8;function Vxe(){return g8||(g8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=$xe();function n(r,i=0,a={}){const{leading:o=!0,trailing:l=!0}=a;return e.debounce(r,i,{leading:o,maxWait:i,trailing:l})}t.throttle=n})(nA)),nA}var aA,x8;function Gxe(){return x8||(x8=1,aA=Vxe().throttle),aA}var qxe=Gxe();const Wxe=hl(qxe);var dS=function(e,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];if(typeof console<"u"&&console.warn&&(n===void 0&&console.warn("LogUtils requires an error message argument"),!e))if(n===void 0)console.warn("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var o=0;console.warn(n.replace(/%s/g,()=>i[o++]))}},cX=(t,e,n)=>{var{width:r="100%",height:i="100%",aspect:a,maxHeight:o}=n,l=Lu(r)?t:Number(r),c=Lu(i)?e:Number(i);return a&&a>0&&(l?c=l/a:c&&(l=c*a),o&&c!=null&&c>o&&(c=o)),{calculatedWidth:l,calculatedHeight:c}},Kxe={width:0,height:0,overflow:"visible"},Xxe={width:0,overflowX:"visible"},Yxe={height:0,overflowY:"visible"},Qxe={},Zxe=t=>{var{width:e,height:n}=t,r=Lu(e),i=Lu(n);return r&&i?Kxe:r?Xxe:i?Yxe:Qxe};function Jxe(t){var{width:e,height:n,aspect:r}=t,i=e,a=n;return i===void 0&&a===void 0?(i="100%",a="100%"):i===void 0?i=r&&r>0?void 0:"100%":a===void 0&&(a=r&&r>0?void 0:"100%"),{width:i,height:a}}function vr(t){return Number.isFinite(t)}function gc(t){return typeof t=="number"&&t>0&&Number.isFinite(t)}function Uj(){return Uj=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},Uj.apply(null,arguments)}function b8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function y8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?b8(Object(n),!0).forEach(function(r){ebe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):b8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ebe(t,e,n){return(e=tbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function tbe(t){var e=nbe(t,"string");return typeof e=="symbol"?e:e+""}function nbe(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 uX=_.createContext({width:-1,height:-1});function rbe(t){return gc(t.width)&&gc(t.height)}function dX(t){var{children:e,width:n,height:r}=t,i=_.useMemo(()=>({width:n,height:r}),[n,r]);return rbe(i)?_.createElement(uX.Provider,{value:i},e):null}var sO=()=>_.useContext(uX),ibe=_.forwardRef((t,e)=>{var{aspect:n,initialDimension:r={width:-1,height:-1},width:i,height:a,minWidth:o=0,minHeight:l,maxHeight:c,children:u,debounce:d=0,id:f,className:p,onResize:m,style:x={}}=t,b=_.useRef(null),v=_.useRef();v.current=m,_.useImperativeHandle(e,()=>b.current);var[y,S]=_.useState({containerWidth:r.width,containerHeight:r.height}),k=_.useCallback((R,A)=>{S(D=>{var I=Math.round(R),F=Math.round(A);return D.containerWidth===I&&D.containerHeight===F?D:{containerWidth:I,containerHeight:F}})},[]);_.useEffect(()=>{if(b.current==null||typeof ResizeObserver>"u")return zy;var R=F=>{var z,{width:P,height:$}=F[0].contentRect;k(P,$),(z=v.current)===null||z===void 0||z.call(v,P,$)};d>0&&(R=Wxe(R,d,{trailing:!0,leading:!1}));var A=new ResizeObserver(R),{width:D,height:I}=b.current.getBoundingClientRect();return k(D,I),A.observe(b.current),()=>{A.disconnect()}},[k,d]);var{containerWidth:T,containerHeight:M}=y;dS(!n||n>0,"The aspect(%s) must be greater than zero.",n);var{calculatedWidth:C,calculatedHeight:E}=cX(T,M,{width:i,height:a,aspect:n,maxHeight:c});return dS(C!=null&&C>0||E!=null&&E>0,`The width(%s) and height(%s) of chart should be greater than 0,
- please check the style of container, or the props width(%s) and height(%s),
- or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the
- height and width.`,C,E,i,a,o,l,n),_.createElement("div",{id:f?"".concat(f):void 0,className:nr("recharts-responsive-container",p),style:y8(y8({},x),{},{width:i,height:a,minWidth:o,minHeight:l,maxHeight:c}),ref:b},_.createElement("div",{style:Zxe({width:i,height:a})},_.createElement(dX,{width:C,height:E},u)))}),w1=_.forwardRef((t,e)=>{var n=sO();if(gc(n.width)&&gc(n.height))return t.children;var{width:r,height:i}=Jxe({width:t.width,height:t.height,aspect:t.aspect}),{calculatedWidth:a,calculatedHeight:o}=cX(void 0,void 0,{width:r,height:i,aspect:t.aspect,maxHeight:t.maxHeight});return zt(a)&&zt(o)?_.createElement(dX,{width:a,height:o},t.children):_.createElement(ibe,Uj({},t,{width:r,height:i,ref:e}))});function hX(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=ia(),n=It(zxe),r=It(OM),i=(t=It(RM))===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}},abe={top:0,bottom:0,left:0,right:0,width:0,height:0,brushBottom:0},fX=()=>{var t;return(t=It(ra))!==null&&t!==void 0?t:abe},oO=()=>It(qu),lO=()=>It(Wu),sbe=()=>It(t=>t.layout.margin),$n=t=>t.layout.layoutType,Em=()=>It($n),obe=()=>{var t=Em();if(t==="horizontal"||t==="vertical")return t},lbe=()=>{var t=Em();return t!==void 0},LM=t=>{var e=Lr(),n=ia(),{width:r,height:i}=t,a=sO(),o=r,l=i;return a&&(o=a.width>0?a.width:r,l=a.height>0?a.height:i),_.useEffect(()=>{!n&&gc(o)&&gc(l)&&e(hxe({width:o,height:l}))},[e,n,o,l]),null},mX=Symbol.for("immer-nothing"),v8=Symbol.for("immer-draftable"),yo=Symbol.for("immer-state");function Tl(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var J0=Object.getPrototypeOf;function qg(t){return!!t&&!!t[yo]}function um(t){return t?pX(t)||Array.isArray(t)||!!t[v8]||!!t.constructor?.[v8]||Wy(t)||IM(t):!1}var cbe=Object.prototype.constructor.toString(),w8=new WeakMap;function pX(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=w8.get(n);return r===void 0&&(r=Function.toString.call(n),w8.set(n,r)),r===cbe}function hS(t,e,n=!0){FM(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 FM(t){const e=t[yo];return e?e.type_:Array.isArray(t)?1:Wy(t)?2:IM(t)?3:0}function zj(t,e){return FM(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function gX(t,e,n){const r=FM(t);r===2?t.set(e,n):r===3?t.add(n):t[e]=n}function ube(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function Wy(t){return t instanceof Map}function IM(t){return t instanceof Set}function wf(t){return t.copy_||t.base_}function Bj(t,e){if(Wy(t))return new Map(t);if(IM(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=pX(t);if(e===!0||e==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(t);delete r[yo];let i=Reflect.ownKeys(r);for(let a=0;a<i.length;a++){const o=i[a],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(J0(t),r)}else{const r=J0(t);if(r!==null&&n)return{...t};const i=Object.create(r);return Object.assign(i,t)}}function cO(t,e=!1){return UM(t)||qg(t)||!um(t)||(FM(t)>1&&Object.defineProperties(t,{set:Hw,add:Hw,clear:Hw,delete:Hw}),Object.freeze(t),e&&Object.values(t).forEach(n=>cO(n,!0))),t}function dbe(){Tl(2)}var Hw={value:dbe};function UM(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var hbe={};function dm(t){const e=hbe[t];return e||Tl(0,t),e}var ey;function xX(){return ey}function fbe(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function _8(t,e){e&&(dm("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Hj(t){$j(t),t.drafts_.forEach(mbe),t.drafts_=null}function $j(t){t===ey&&(ey=t.parent_)}function S8(t){return ey=fbe(ey,t)}function mbe(t){const e=t[yo];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function N8(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];return t!==void 0&&t!==n?(n[yo].modified_&&(Hj(e),Tl(4)),um(t)&&(t=fS(e,t),e.parent_||mS(e,t)),e.patches_&&dm("Patches").generateReplacementPatches_(n[yo].base_,t,e.patches_,e.inversePatches_)):t=fS(e,n,[]),Hj(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==mX?t:void 0}function fS(t,e,n){if(UM(e))return e;const r=t.immer_.shouldUseStrictIteration(),i=e[yo];if(!i)return hS(e,(a,o)=>M8(t,i,e,a,o,n),r),e;if(i.scope_!==t)return e;if(!i.modified_)return mS(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const a=i.copy_;let o=a,l=!1;i.type_===3&&(o=new Set(a),a.clear(),l=!0),hS(o,(c,u)=>M8(t,i,a,c,u,n,l),r),mS(t,a,!1),n&&t.patches_&&dm("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function M8(t,e,n,r,i,a,o){if(i==null||typeof i!="object"&&!o)return;const l=UM(i);if(!(l&&!o)){if(qg(i)){const c=a&&e&&e.type_!==3&&!zj(e.assigned_,r)?a.concat(r):void 0,u=fS(t,i,c);if(gX(n,r,u),qg(u))t.canAutoFreeze_=!1;else return}else o&&n.add(i);if(um(i)&&!l){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===i&&l)return;fS(t,i),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(Wy(n)?n.has(r):Object.prototype.propertyIsEnumerable.call(n,r))&&mS(t,i)}}}function mS(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&cO(e,n)}function pbe(t,e){const n=Array.isArray(t),r={type_:n?1:0,scope_:e?e.scope_:xX(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let i=r,a=uO;n&&(i=[r],a=ty);const{revoke:o,proxy:l}=Proxy.revocable(i,a);return r.draft_=l,r.revoke_=o,l}var uO={get(t,e){if(e===yo)return t;const n=wf(t);if(!zj(n,e))return gbe(t,n,e);const r=n[e];return t.finalized_||!um(r)?r:r===sA(t.base_,e)?(oA(t),t.copy_[e]=Gj(r,t)):r},has(t,e){return e in wf(t)},ownKeys(t){return Reflect.ownKeys(wf(t))},set(t,e,n){const r=bX(wf(t),e);if(r?.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const i=sA(wf(t),e),a=i?.[yo];if(a&&a.base_===n)return t.copy_[e]=n,t.assigned_[e]=!1,!0;if(ube(n,i)&&(n!==void 0||zj(t.base_,e)))return!0;oA(t),Vj(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 sA(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,oA(t),Vj(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=wf(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:n[e]}},defineProperty(){Tl(11)},getPrototypeOf(t){return J0(t.base_)},setPrototypeOf(){Tl(12)}},ty={};hS(uO,(t,e)=>{ty[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});ty.deleteProperty=function(t,e){return ty.set.call(this,t,e,void 0)};ty.set=function(t,e,n){return uO.set.call(this,t[0],e,n,t[0])};function sA(t,e){const n=t[yo];return(n?wf(n):t)[e]}function gbe(t,e,n){const r=bX(e,n);return r?"value"in r?r.value:r.get?.call(t.draft_):void 0}function bX(t,e){if(!(e in t))return;let n=J0(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=J0(n)}}function Vj(t){t.modified_||(t.modified_=!0,t.parent_&&Vj(t.parent_))}function oA(t){t.copy_||(t.copy_=Bj(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var xbe=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,n,r)=>{if(typeof e=="function"&&typeof n!="function"){const a=n;n=e;const o=this;return function(c=a,...u){return o.produce(c,d=>n.call(this,d,...u))}}typeof n!="function"&&Tl(6),r!==void 0&&typeof r!="function"&&Tl(7);let i;if(um(e)){const a=S8(this),o=Gj(e,void 0);let l=!0;try{i=n(o),l=!1}finally{l?Hj(a):$j(a)}return _8(a,r),N8(i,a)}else if(!e||typeof e!="object"){if(i=n(e),i===void 0&&(i=e),i===mX&&(i=void 0),this.autoFreeze_&&cO(i,!0),r){const a=[],o=[];dm("Patches").generateReplacementPatches_(e,i,a,o),r(a,o)}return i}else Tl(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){um(t)||Tl(8),qg(t)&&(t=bbe(t));const e=S8(this),n=Gj(t,void 0);return n[yo].isManual_=!0,$j(e),n}finishDraft(t,e){const n=t&&t[yo];(!n||!n.isManual_)&&Tl(9);const{scope_:r}=n;return _8(r,e),N8(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=dm("Patches").applyPatches_;return qg(t)?r(t,e):this.produce(t,i=>r(i,e))}};function Gj(t,e){const n=Wy(t)?dm("MapSet").proxyMap_(t,e):IM(t)?dm("MapSet").proxySet_(t,e):pbe(t,e);return(e?e.scope_:xX()).drafts_.push(n),n}function bbe(t){return qg(t)||Tl(10,t),yX(t)}function yX(t){if(!um(t)||UM(t))return t;const e=t[yo];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=Bj(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=Bj(t,!0);return hS(n,(i,a)=>{gX(n,i,yX(a))},r),e&&(e.finalized_=!1),n}var ybe=new xbe;ybe.produce;var vbe={settings:{layout:"horizontal",align:"center",verticalAlign:"middle",itemSorter:"value"},size:{width:0,height:0},payload:[]},vX=$s({name:"legend",initialState:vbe,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=Ol(t).payload.indexOf(n);i>-1&&(t.payload[i]=r)},prepare:Jr()},removeLegendPayload:{reducer(t,e){var n=Ol(t).payload.indexOf(e.payload);n>-1&&t.payload.splice(n,1)},prepare:Jr()}}}),{setLegendSize:k8,setLegendSettings:wbe,addLegendPayload:wX,replaceLegendPayload:_X,removeLegendPayload:SX}=vX.actions,_be=vX.reducer,Sbe=["contextPayload"];function qj(){return qj=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},qj.apply(null,arguments)}function E8(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?E8(Object(n),!0).forEach(function(r){Nbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Nbe(t,e,n){return(e=Mbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Mbe(t){var e=kbe(t,"string");return typeof e=="symbol"?e:e+""}function kbe(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 Ebe(t,e){if(t==null)return{};var n,r,i=Tbe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Tbe(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 Abe(t){return t.value}function Cbe(t){var{contextPayload:e}=t,n=Ebe(t,Sbe),r=vK(e,t.payloadUniqBy,Abe),i=Wg(Wg({},n),{},{payload:r});return _.isValidElement(t.content)?_.cloneElement(t.content,i):typeof t.content=="function"?_.createElement(t.content,i):_.createElement(Spe,i)}function Pbe(t,e,n,r,i,a){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)-a.width)/2}:u=l==="right"?{right:n&&n.right||0}:{left:n&&n.left||0}),(!t||(t.top===void 0||t.top===null)&&(t.bottom===void 0||t.bottom===null))&&(c==="middle"?d={top:((i||0)-a.height)/2}:d=c==="bottom"?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),Wg(Wg({},u),d)}function jbe(t){var e=Lr();return _.useEffect(()=>{e(wbe(t))},[e,t]),null}function Dbe(t){var e=Lr();return _.useEffect(()=>(e(k8(t)),()=>{e(k8({width:0,height:0}))}),[e,t]),null}function Rbe(t,e,n,r){return t==="vertical"&&zt(e)?{height:e}:t==="horizontal"?{width:n||r}:null}var Obe={align:"center",iconSize:14,itemSorter:"value",layout:"horizontal",verticalAlign:"bottom"};function dO(t){var e=ci(t,Obe),n=mge(),r=pme(),i=sbe(),{width:a,height:o,wrapperStyle:l,portal:c}=e,[u,d]=kK([n]),f=oO(),p=lO();if(f==null||p==null)return null;var m=f-(i?.left||0)-(i?.right||0),x=Rbe(e.layout,o,a,m),b=c?l:Wg(Wg({position:"absolute",width:x?.width||a||"auto",height:x?.height||o||"auto"},Pbe(l,e,i,f,p,u)),l),v=c??r;if(v==null||n==null)return null;var y=_.createElement("div",{className:"recharts-legend-wrapper",style:b,ref:d},_.createElement(jbe,{layout:e.layout,align:e.align,verticalAlign:e.verticalAlign,itemSorter:e.itemSorter}),!c&&_.createElement(Dbe,{width:u.width,height:u.height}),_.createElement(Cbe,qj({},e,x,{margin:i,chartWidth:f,chartHeight:p,contextPayload:n})));return xu.createPortal(y,v)}dO.displayName="Legend";function Wj(){return Wj=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},Wj.apply(null,arguments)}function T8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function lA(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?T8(Object(n),!0).forEach(function(r){Lbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):T8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Lbe(t,e,n){return(e=Fbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Fbe(t){var e=Ibe(t,"string");return typeof e=="symbol"?e:e+""}function Ibe(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 Ube(t){return Array.isArray(t)&&cl(t[0])&&cl(t[1])?t.join(" ~ "):t}var zbe=t=>{var{separator:e=" : ",contentStyle:n={},itemStyle:r={},labelStyle:i={},payload:a,formatter:o,itemSorter:l,wrapperClassName:c,labelClassName:u,label:d,labelFormatter:f,accessibilityLayer:p=!1}=t,m=()=>{if(a&&a.length){var M={padding:0,margin:0},C=(l?SM(a,l):a).map((E,R)=>{if(E.type==="none")return null;var A=E.formatter||o||Ube,{value:D,name:I}=E,F=D,z=I;if(A){var P=A(D,I,E,R,a);if(Array.isArray(P))[F,z]=P;else if(P!=null)F=P;else return null}var $=lA({display:"block",paddingTop:4,paddingBottom:4,color:E.color||"#000"},r);return _.createElement("li",{className:"recharts-tooltip-item",key:"tooltip-item-".concat(R),style:$},cl(z)?_.createElement("span",{className:"recharts-tooltip-item-name"},z):null,cl(z)?_.createElement("span",{className:"recharts-tooltip-item-separator"},e):null,_.createElement("span",{className:"recharts-tooltip-item-value"},F),_.createElement("span",{className:"recharts-tooltip-item-unit"},E.unit||""))});return _.createElement("ul",{className:"recharts-tooltip-item-list",style:M},C)}return null},x=lA({margin:0,padding:10,backgroundColor:"#fff",border:"1px solid #ccc",whiteSpace:"nowrap"},n),b=lA({margin:0},i),v=!Yr(d),y=v?d:"",S=nr("recharts-default-tooltip",c),k=nr("recharts-tooltip-label",u);v&&f&&a!==void 0&&a!==null&&(y=f(d,a));var T=p?{role:"status","aria-live":"assertive"}:{};return _.createElement("div",Wj({className:S,style:x},T),_.createElement("p",{className:k,style:b},_.isValidElement(y)?y:"".concat(y)),m())},Pb="recharts-tooltip-wrapper",Bbe={visibility:"hidden"};function Hbe(t){var{coordinate:e,translateX:n,translateY:r}=t;return nr(Pb,{["".concat(Pb,"-right")]:zt(n)&&e&&zt(e.x)&&n>=e.x,["".concat(Pb,"-left")]:zt(n)&&e&&zt(e.x)&&n<e.x,["".concat(Pb,"-bottom")]:zt(r)&&e&&zt(e.y)&&r>=e.y,["".concat(Pb,"-top")]:zt(r)&&e&&zt(e.y)&&r<e.y})}function A8(t){var{allowEscapeViewBox:e,coordinate:n,key:r,offsetTopLeft:i,position:a,reverseDirection:o,tooltipDimension:l,viewBox:c,viewBoxDimension:u}=t;if(a&&zt(a[r]))return a[r];var d=n[r]-l-(i>0?i:0),f=n[r]+i;if(e[r])return o[r]?d:f;var p=c[r];if(p==null)return 0;if(o[r]){var m=d,x=p;return m<x?Math.max(f,p):Math.max(d,p)}if(u==null)return 0;var b=f+l,v=p+u;return b>v?Math.max(d,p):Math.max(f,p)}function $be(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 Vbe(t){var{allowEscapeViewBox:e,coordinate:n,offsetTopLeft:r,position:i,reverseDirection:a,tooltipBox:o,useTranslate3d:l,viewBox:c}=t,u,d,f;return o.height>0&&o.width>0&&n?(d=A8({allowEscapeViewBox:e,coordinate:n,key:"x",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.width,viewBox:c,viewBoxDimension:c.width}),f=A8({allowEscapeViewBox:e,coordinate:n,key:"y",offsetTopLeft:r,position:i,reverseDirection:a,tooltipDimension:o.height,viewBox:c,viewBoxDimension:c.height}),u=$be({translateX:d,translateY:f,useTranslate3d:l})):u=Bbe,{cssProperties:u,cssClasses:Hbe({translateX:d,translateY:f,coordinate:n})}}function C8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function $w(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?C8(Object(n),!0).forEach(function(r){Kj(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):C8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Kj(t,e,n){return(e=Gbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Gbe(t){var e=qbe(t,"string");return typeof e=="symbol"?e:e+""}function qbe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class Wbe extends _.PureComponent{constructor(){super(...arguments),Kj(this,"state",{dismissed:!1,dismissedAtCoordinate:{x:0,y:0}}),Kj(this,"handleKeyDown",e=>{if(e.key==="Escape"){var n,r,i,a;this.setState({dismissed:!0,dismissedAtCoordinate:{x:(n=(r=this.props.coordinate)===null||r===void 0?void 0:r.x)!==null&&n!==void 0?n:0,y:(i=(a=this.props.coordinate)===null||a===void 0?void 0:a.y)!==null&&i!==void 0?i:0}})}})}componentDidMount(){document.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.removeEventListener("keydown",this.handleKeyDown)}componentDidUpdate(){var e,n;this.state.dismissed&&(((e=this.props.coordinate)===null||e===void 0?void 0:e.x)!==this.state.dismissedAtCoordinate.x||((n=this.props.coordinate)===null||n===void 0?void 0:n.y)!==this.state.dismissedAtCoordinate.y)&&(this.state.dismissed=!1)}render(){var{active:e,allowEscapeViewBox:n,animationDuration:r,animationEasing:i,children:a,coordinate:o,hasPayload:l,isAnimationActive:c,offset:u,position:d,reverseDirection:f,useTranslate3d:p,viewBox:m,wrapperStyle:x,lastBoundingBox:b,innerRef:v,hasPortalFromProps:y}=this.props,{cssClasses:S,cssProperties:k}=Vbe({allowEscapeViewBox:n,coordinate:o,offsetTopLeft:u,position:d,reverseDirection:f,tooltipBox:{height:b.height,width:b.width},useTranslate3d:p,viewBox:m}),T=y?{}:$w($w({transition:c&&e?"transform ".concat(r,"ms ").concat(i):void 0},k),{},{pointerEvents:"none",visibility:!this.state.dismissed&&e&&l?"visible":"hidden",position:"absolute",top:0,left:0}),M=$w($w({},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:M,ref:v},a)}}var NX=()=>{var t;return(t=It(e=>e.rootProps.accessibilityLayer))!==null&&t!==void 0?t:!0};function Xj(){return Xj=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},Xj.apply(null,arguments)}function P8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function j8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?P8(Object(n),!0).forEach(function(r){Kbe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):P8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Kbe(t,e,n){return(e=Xbe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Xbe(t){var e=Ybe(t,"string");return typeof e=="symbol"?e:e+""}function Ybe(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 D8={curveBasisClosed:Rme,curveBasisOpen:Ome,curveBasis:Dme,curveBumpX:yme,curveBumpY:vme,curveLinearClosed:Lme,curveLinear:wM,curveMonotoneX:Fme,curveMonotoneY:Ime,curveNatural:Ume,curveStep:zme,curveStepAfter:Hme,curveStepBefore:Bme},pS=t=>vr(t.x)&&vr(t.y),R8=t=>t.base!=null&&pS(t.base)&&pS(t),jb=t=>t.x,Db=t=>t.y,Qbe=(t,e)=>{if(typeof t=="function")return t;var n="curve".concat(Uy(t));return(n==="curveMonotone"||n==="curveBump")&&e?D8["".concat(n).concat(e==="vertical"?"Y":"X")]:D8[n]||wM},Zbe=t=>{var{type:e="linear",points:n=[],baseLine:r,layout:i,connectNulls:a=!1}=t,o=Qbe(e,i),l=a?n.filter(pS):n,c;if(Array.isArray(r)){var u=n.map((m,x)=>j8(j8({},m),{},{base:r[x]}));i==="vertical"?c=Ow().y(Db).x1(jb).x0(m=>m.base.x):c=Ow().x(jb).y1(Db).y0(m=>m.base.y);var d=c.defined(R8).curve(o),f=a?u.filter(R8):u;return d(f)}i==="vertical"&&zt(r)?c=Ow().y(Db).x1(jb).x0(r):zt(r)?c=Ow().x(jb).y1(Db).y0(r):c=XW().x(jb).y(Db);var p=c.defined(pS).curve(o);return p(l)},kg=t=>{var{className:e,points:n,path:r,pathRef:i}=t;if((!n||!n.length)&&!r)return null;var a=n&&n.length?Zbe(t):r;return _.createElement("path",Xj({},xs(t),KR(t),{className:nr("recharts-curve",e),d:a===null?void 0:a,ref:i}))},Jbe=["x","y","top","left","width","height","className"];function Yj(){return Yj=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},Yj.apply(null,arguments)}function O8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function e0e(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?O8(Object(n),!0).forEach(function(r){t0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):O8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function t0e(t,e,n){return(e=n0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function n0e(t){var e=r0e(t,"string");return typeof e=="symbol"?e:e+""}function r0e(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 i0e(t,e){if(t==null)return{};var n,r,i=a0e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function a0e(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 s0e=(t,e,n,r,i,a)=>"M".concat(t,",").concat(i,"v").concat(r,"M").concat(a,",").concat(e,"h").concat(n),o0e=t=>{var{x:e=0,y:n=0,top:r=0,left:i=0,width:a=0,height:o=0,className:l}=t,c=i0e(t,Jbe),u=e0e({x:e,y:n,top:r,left:i,width:a,height:o},c);return!zt(e)||!zt(n)||!zt(a)||!zt(o)||!zt(r)||!zt(i)?null:_.createElement("path",Yj({},Ba(u),{className:nr("recharts-cross",l),d:s0e(e,n,a,o,r,i)}))};function l0e(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 L8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function F8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?L8(Object(n),!0).forEach(function(r){c0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function c0e(t,e,n){return(e=u0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function u0e(t){var e=d0e(t,"string");return typeof e=="symbol"?e:e+""}function d0e(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 h0e=t=>t.replace(/([A-Z])/g,e=>"-".concat(e.toLowerCase())),MX=(t,e,n)=>t.map(r=>"".concat(h0e(r)," ").concat(e,"ms ").concat(n)).join(","),f0e=(t,e)=>[Object.keys(t),Object.keys(e)].reduce((n,r)=>n.filter(i=>r.includes(i))),ny=(t,e)=>Object.keys(e).reduce((n,r)=>F8(F8({},n),{},{[r]:t(r,e[r])}),{});function I8(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?I8(Object(n),!0).forEach(function(r){m0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):I8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function m0e(t,e,n){return(e=p0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function p0e(t){var e=g0e(t,"string");return typeof e=="symbol"?e:e+""}function g0e(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 gS=(t,e,n)=>t+(e-t)*n,Qj=t=>{var{from:e,to:n}=t;return e!==n},kX=(t,e,n)=>{var r=ny((i,a)=>{if(Qj(a)){var[o,l]=t(a.from,a.to,a.velocity);return Xi(Xi({},a),{},{from:o,velocity:l})}return a},e);return n<1?ny((i,a)=>Qj(a)?Xi(Xi({},a),{},{velocity:gS(a.velocity,r[i].velocity,n),from:gS(a.from,r[i].from,n)}):a,e):kX(t,r,n-1)};function x0e(t,e,n,r,i,a){var o,l=r.reduce((p,m)=>Xi(Xi({},p),{},{[m]:{from:t[m],velocity:0,to:e[m]}}),{}),c=()=>ny((p,m)=>m.from,l),u=()=>!Object.values(l).filter(Qj).length,d=null,f=p=>{o||(o=p);var m=p-o,x=m/n.dt;l=kX(n,l,x),i(Xi(Xi(Xi({},t),e),c())),o=p,u()||(d=a.setTimeout(f))};return()=>(d=a.setTimeout(f),()=>{var p;(p=d)===null||p===void 0||p()})}function b0e(t,e,n,r,i,a,o){var l=null,c=i.reduce((f,p)=>Xi(Xi({},f),{},{[p]:[t[p],e[p]]}),{}),u,d=f=>{u||(u=f);var p=(f-u)/r,m=ny((b,v)=>gS(...v,n(p)),c);if(a(Xi(Xi(Xi({},t),e),m)),p<1)l=o.setTimeout(d);else{var x=ny((b,v)=>gS(...v,n(1)),c);a(Xi(Xi(Xi({},t),e),x))}};return()=>(l=o.setTimeout(d),()=>{var f;(f=l)===null||f===void 0||f()})}const y0e=(t,e,n,r,i,a)=>{var o=f0e(t,e);return n==null?()=>(i(Xi(Xi({},t),e)),()=>{}):n.isStepper===!0?x0e(t,e,n,o,i,a):b0e(t,e,n,r,o,i,a)};var xS=1e-4,EX=(t,e)=>[0,3*t,3*e-6*t,3*t-3*e+1],TX=(t,e)=>t.map((n,r)=>n*e**r).reduce((n,r)=>n+r),U8=(t,e)=>n=>{var r=EX(t,e);return TX(r,n)},v0e=(t,e)=>n=>{var r=EX(t,e),i=[...r.map((a,o)=>a*o).slice(1),0];return TX(i,n)},w0e=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(n.length===1)switch(n[0]){case"linear":return[0,0,1,1];case"ease":return[.25,.1,.25,1];case"ease-in":return[.42,0,1,1];case"ease-out":return[.42,0,.58,1];case"ease-in-out":return[0,0,.58,1];default:{var i,a=n[0].split("(");if(a[0]==="cubic-bezier"&&((i=a[1])===null||i===void 0?void 0:i.split(")")[0].split(",").length)===4){var o=a[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]},_0e=(t,e,n,r)=>{var i=U8(t,n),a=U8(e,r),o=v0e(t,n),l=u=>u>1?1:u<0?0:u,c=u=>{for(var d=u>1?1:u,f=d,p=0;p<8;++p){var m=i(f)-d,x=o(f);if(Math.abs(m-d)<xS||x<xS)return a(f);f=l(f-m/x)}return a(f)};return c.isStepper=!1,c},z8=function(){return _0e(...w0e(...arguments))},S0e=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{stiff:n=100,damping:r=8,dt:i=17}=e,a=(o,l,c)=>{var u=-(o-l)*n,d=c*r,f=c+(u-d)*i/1e3,p=c*i/1e3+o;return Math.abs(p-l)<xS&&Math.abs(f)<xS?[l,0]:[p,f]};return a.isStepper=!0,a.dt=i,a},N0e=t=>{if(typeof t=="string")switch(t){case"ease":case"ease-in-out":case"ease-out":case"ease-in":case"linear":return z8(t);case"spring":return S0e();default:if(t.split("(")[0]==="cubic-bezier")return z8(t)}return typeof t=="function"?t:null};function M0e(t){var e,n=()=>null,r=!1,i=null,a=o=>{if(!r){if(Array.isArray(o)){if(!o.length)return;var l=o,[c,...u]=l;if(typeof c=="number"){i=t.setTimeout(a.bind(null,u),c);return}a(c),i=t.setTimeout(a.bind(null,u));return}typeof 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),a(o)},subscribe:o=>(n=o,()=>{n=()=>null}),getTimeoutController:()=>t}}class k0e{setTimeout(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=performance.now(),i=null,a=o=>{o-r>=n?e(o):typeof requestAnimationFrame=="function"&&(i=requestAnimationFrame(a))};return i=requestAnimationFrame(a),()=>{i!=null&&cancelAnimationFrame(i)}}}function E0e(){return M0e(new k0e)}var T0e=_.createContext(E0e);function A0e(t,e){var n=_.useContext(T0e);return _.useMemo(()=>e??n(t),[t,e,n])}var C0e=()=>!(typeof window<"u"&&window.document&&window.document.createElement&&window.setTimeout),yx={devToolsEnabled:!1,isSsr:C0e()},P0e={begin:0,duration:1e3,easing:"ease",isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}},B8={t:0},cA={t:1};function vx(t){var e=ci(t,P0e),{isActive:n,canBegin:r,duration:i,easing:a,begin:o,onAnimationEnd:l,onAnimationStart:c,children:u}=e,d=n==="auto"?!yx.isSsr:n,f=A0e(e.animationId,e.animationManager),[p,m]=_.useState(d?B8:cA),x=_.useRef(null);return _.useEffect(()=>{d||m(cA)},[d]),_.useEffect(()=>{if(!d||!r)return zy;var b=y0e(B8,cA,N0e(a),i,m,f.getTimeoutController()),v=()=>{x.current=b()};return f.start([c,o,v,i,l]),()=>{f.stop(),x.current&&x.current(),l()}},[d,r,i,a,o,c,l,f]),u(p.t)}function wx(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"animation-",n=_.useRef(X0(e)),r=_.useRef(t);return r.current!==t&&(n.current=X0(e),r.current=t),n.current}var j0e=["radius"],D0e=["radius"];function H8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function $8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?H8(Object(n),!0).forEach(function(r){R0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):H8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function R0e(t,e,n){return(e=O0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function O0e(t){var e=L0e(t,"string");return typeof e=="symbol"?e:e+""}function L0e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function bS(){return bS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},bS.apply(null,arguments)}function V8(t,e){if(t==null)return{};var n,r,i=F0e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function F0e(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 G8=(t,e,n,r,i)=>{var a=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(a>0&&i instanceof Array){for(var d=[0,0,0,0],f=0,p=4;f<p;f++)d[f]=i[f]>a?a:i[f];u="M".concat(t,",").concat(e+o*d[0]),d[0]>0&&(u+="A ".concat(d[0],",").concat(d[0],",0,0,").concat(c,",").concat(t+l*d[0],",").concat(e)),u+="L ".concat(t+n-l*d[1],",").concat(e),d[1]>0&&(u+="A ".concat(d[1],",").concat(d[1],",0,0,").concat(c,`,
- `).concat(t+n,",").concat(e+o*d[1])),u+="L ".concat(t+n,",").concat(e+r-o*d[2]),d[2]>0&&(u+="A ".concat(d[2],",").concat(d[2],",0,0,").concat(c,`,
- `).concat(t+n-l*d[2],",").concat(e+r)),u+="L ".concat(t+l*d[3],",").concat(e+r),d[3]>0&&(u+="A ".concat(d[3],",").concat(d[3],",0,0,").concat(c,`,
- `).concat(t,",").concat(e+r-o*d[3])),u+="Z"}else if(a>0&&i===+i&&i>0){var m=Math.min(a,i);u="M ".concat(t,",").concat(e+o*m,`
- A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+l*m,",").concat(e,`
- L `).concat(t+n-l*m,",").concat(e,`
- A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+n,",").concat(e+o*m,`
- L `).concat(t+n,",").concat(e+r-o*m,`
- A `).concat(m,",").concat(m,",0,0,").concat(c,",").concat(t+n-l*m,",").concat(e+r,`
- L `).concat(t+l*m,",").concat(e+r,`
- 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},q8={x:0,y:0,width:0,height:0,radius:0,isAnimationActive:!1,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},AX=t=>{var e=ci(t,q8),n=_.useRef(null),[r,i]=_.useState(-1);_.useEffect(()=>{if(n.current&&n.current.getTotalLength)try{var V=n.current.getTotalLength();V&&i(V)}catch{}},[]);var{x:a,y:o,width:l,height:c,radius:u,className:d}=e,{animationEasing:f,animationDuration:p,animationBegin:m,isAnimationActive:x,isUpdateAnimationActive:b}=e,v=_.useRef(l),y=_.useRef(c),S=_.useRef(a),k=_.useRef(o),T=_.useMemo(()=>({x:a,y:o,width:l,height:c,radius:u}),[a,o,l,c,u]),M=wx(T,"rectangle-");if(a!==+a||o!==+o||l!==+l||c!==+c||l===0||c===0)return null;var C=nr("recharts-rectangle",d);if(!b){var E=Ba(e),{radius:R}=E,A=V8(E,j0e);return _.createElement("path",bS({},A,{radius:typeof u=="number"?u:void 0,className:C,d:G8(a,o,l,c,u)}))}var D=v.current,I=y.current,F=S.current,z=k.current,P="0px ".concat(r===-1?1:r,"px"),$="".concat(r,"px 0px"),X=MX(["strokeDasharray"],p,typeof f=="string"?f:q8.animationEasing);return _.createElement(vx,{animationId:M,key:M,canBegin:r>0,duration:p,easing:f,isActive:b,begin:m},V=>{var Q=mr(D,l,V),Z=mr(I,c,V),se=mr(F,a,V),H=mr(z,o,V);n.current&&(v.current=Q,y.current=Z,S.current=se,k.current=H);var K;x?V>0?K={transition:X,strokeDasharray:$}:K={strokeDasharray:P}:K={strokeDasharray:$};var re=Ba(e),{radius:ne}=re,be=V8(re,D0e);return _.createElement("path",bS({},be,{radius:typeof u=="number"?u:void 0,className:C,d:G8(se,H,Q,Z,u),ref:n,style:$8($8({},K),e.style)}))})};function W8(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function K8(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?W8(Object(n),!0).forEach(function(r){I0e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):W8(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function I0e(t,e,n){return(e=U0e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function U0e(t){var e=z0e(t,"string");return typeof e=="symbol"?e:e+""}function z0e(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 yS=Math.PI/180,B0e=t=>t*180/Math.PI,Bi=(t,e,n,r)=>({x:t+Math.cos(-yS*r)*n,y:e+Math.sin(-yS*r)*n}),CX=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},H0e=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return Math.sqrt((n-i)**2+(r-a)**2)},$0e=(t,e)=>{var{x:n,y:r}=t,{cx:i,cy:a}=e,o=H0e({x:n,y:r},{x:i,y:a});if(o<=0)return{radius:o,angle:0};var l=(n-i)/o,c=Math.acos(l);return r>a&&(c=2*Math.PI-c),{radius:o,angle:B0e(c),angleInRadian:c}},V0e=t=>{var{startAngle:e,endAngle:n}=t,r=Math.floor(e/360),i=Math.floor(n/360),a=Math.min(r,i);return{startAngle:e-a*360,endAngle:n-a*360}},G0e=(t,e)=>{var{startAngle:n,endAngle:r}=e,i=Math.floor(n/360),a=Math.floor(r/360),o=Math.min(i,a);return t+o*360},q0e=(t,e)=>{var{chartX:n,chartY:r}=t,{radius:i,angle:a}=$0e({x:n,y:r},e),{innerRadius:o,outerRadius:l}=e;if(i<o||i>l||i===0)return null;var{startAngle:c,endAngle:u}=V0e(e),d=a,f;if(c<=u){for(;d>u;)d-=360;for(;d<c;)d+=360;f=d>=c&&d<=u}else{for(;d>c;)d-=360;for(;d<u;)d+=360;f=d>=u&&d<=c}return f?K8(K8({},e),{},{radius:i,angle:G0e(d,e)}):null};function PX(t){var{cx:e,cy:n,radius:r,startAngle:i,endAngle:a}=t,o=Bi(e,n,r,i),l=Bi(e,n,r,a);return{points:[o,l],cx:e,cy:n,radius:r,startAngle:i,endAngle:a}}function Zj(){return Zj=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},Zj.apply(null,arguments)}var W0e=(t,e)=>{var n=va(e-t),r=Math.min(Math.abs(e-t),359.999);return n*r},Vw=t=>{var{cx:e,cy:n,radius:r,angle:i,sign:a,isExternal:o,cornerRadius:l,cornerIsExternal:c}=t,u=l*(o?1:-1)+r,d=Math.asin(l/u)/yS,f=c?i:i+a*d,p=Bi(e,n,u,f),m=Bi(e,n,r,f),x=c?i-a*d:i,b=Bi(e,n,u*Math.cos(d*yS),x);return{center:p,circleTangency:m,lineTangency:b,theta:d}},jX=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:a,endAngle:o}=t,l=W0e(a,o),c=a+l,u=Bi(e,n,i,a),d=Bi(e,n,i,c),f="M ".concat(u.x,",").concat(u.y,`
- A `).concat(i,",").concat(i,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(a>c),`,
- `).concat(d.x,",").concat(d.y,`
- `);if(r>0){var p=Bi(e,n,r,a),m=Bi(e,n,r,c);f+="L ".concat(m.x,",").concat(m.y,`
- A `).concat(r,",").concat(r,`,0,
- `).concat(+(Math.abs(l)>180),",").concat(+(a<=c),`,
- `).concat(p.x,",").concat(p.y," Z")}else f+="L ".concat(e,",").concat(n," Z");return f},K0e=t=>{var{cx:e,cy:n,innerRadius:r,outerRadius:i,cornerRadius:a,forceCornerRadius:o,cornerIsExternal:l,startAngle:c,endAngle:u}=t,d=va(u-c),{circleTangency:f,lineTangency:p,theta:m}=Vw({cx:e,cy:n,radius:i,angle:c,sign:d,cornerRadius:a,cornerIsExternal:l}),{circleTangency:x,lineTangency:b,theta:v}=Vw({cx:e,cy:n,radius:i,angle:u,sign:-d,cornerRadius:a,cornerIsExternal:l}),y=l?Math.abs(c-u):Math.abs(c-u)-m-v;if(y<0)return o?"M ".concat(p.x,",").concat(p.y,`
- a`).concat(a,",").concat(a,",0,0,1,").concat(a*2,`,0
- a`).concat(a,",").concat(a,",0,0,1,").concat(-a*2,`,0
- `):jX({cx:e,cy:n,innerRadius:r,outerRadius:i,startAngle:c,endAngle:u});var S="M ".concat(p.x,",").concat(p.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(f.x,",").concat(f.y,`
- A`).concat(i,",").concat(i,",0,").concat(+(y>180),",").concat(+(d<0),",").concat(x.x,",").concat(x.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(b.x,",").concat(b.y,`
- `);if(r>0){var{circleTangency:k,lineTangency:T,theta:M}=Vw({cx:e,cy:n,radius:r,angle:c,sign:d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),{circleTangency:C,lineTangency:E,theta:R}=Vw({cx:e,cy:n,radius:r,angle:u,sign:-d,isExternal:!0,cornerRadius:a,cornerIsExternal:l}),A=l?Math.abs(c-u):Math.abs(c-u)-M-R;if(A<0&&a===0)return"".concat(S,"L").concat(e,",").concat(n,"Z");S+="L".concat(E.x,",").concat(E.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(C.x,",").concat(C.y,`
- A`).concat(r,",").concat(r,",0,").concat(+(A>180),",").concat(+(d>0),",").concat(k.x,",").concat(k.y,`
- A`).concat(a,",").concat(a,",0,0,").concat(+(d<0),",").concat(T.x,",").concat(T.y,"Z")}else S+="L".concat(e,",").concat(n,"Z");return S},X0e={cx:0,cy:0,innerRadius:0,outerRadius:0,startAngle:0,endAngle:0,cornerRadius:0,forceCornerRadius:!1,cornerIsExternal:!1},DX=t=>{var e=ci(t,X0e),{cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:o,forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d,className:f}=e;if(a<i||u===d)return null;var p=nr("recharts-sector",f),m=a-i,x=es(o,m,0,!0),b;return x>0&&Math.abs(u-d)<360?b=K0e({cx:n,cy:r,innerRadius:i,outerRadius:a,cornerRadius:Math.min(x,m/2),forceCornerRadius:l,cornerIsExternal:c,startAngle:u,endAngle:d}):b=jX({cx:n,cy:r,innerRadius:i,outerRadius:a,startAngle:u,endAngle:d}),_.createElement("path",Zj({},Ba(e),{className:p,d:b}))};function Y0e(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(uK(e)){if(t==="centric"){var{cx:r,cy:i,innerRadius:a,outerRadius:o,angle:l}=e,c=Bi(r,i,a,l),u=Bi(r,i,o,l);return[{x:c.x,y:c.y},{x:u.x,y:u.y}]}return PX(e)}}var uA={},dA={},hA={},X8;function Q0e(){return X8||(X8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=SK();function n(r){return e.isSymbol(r)?NaN:Number(r)}t.toNumber=n})(hA)),hA}var Y8;function Z0e(){return Y8||(Y8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=Q0e();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})(dA)),dA}var Q8;function J0e(){return Q8||(Q8=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=NK(),n=Z0e();function r(i,a,o){o&&typeof o!="number"&&e.isIterateeCall(i,a,o)&&(a=o=void 0),i=n.toFinite(i),a===void 0?(a=i,i=0):a=n.toFinite(a),o=o===void 0?i<a?1:-1:n.toFinite(o);const l=Math.max(Math.ceil((a-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})(uA)),uA}var fA,Z8;function eye(){return Z8||(Z8=1,fA=J0e().range),fA}var tye=eye();const RX=hl(tye);function oh(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function nye(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function hO(t){let e,n,r;t.length!==2?(e=oh,n=(l,c)=>oh(t(l),c),r=(l,c)=>t(l)-c):(e=t===oh||t===nye?t:rye,n=t,r=t);function i(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(l[f],c)<0?u=f+1:d=f}while(u<d)}return u}function a(l,c,u=0,d=l.length){if(u<d){if(e(c,c)!==0)return d;do{const f=u+d>>>1;n(l[f],c)<=0?u=f+1:d=f}while(u<d)}return u}function o(l,c,u=0,d=l.length){const f=i(l,c,u,d-1);return f>u&&r(l[f-1],c)>-r(l[f],c)?f-1:f}return{left:i,center:o,right:a}}function rye(){return 0}function OX(t){return t===null?NaN:+t}function*iye(t,e){for(let n of t)n!=null&&(n=+n)>=n&&(yield n)}const aye=hO(oh),Ky=aye.right;hO(OX).center;class J8 extends Map{constructor(e,n=lye){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(e6(this,e))}has(e){return super.has(e6(this,e))}set(e,n){return super.set(sye(this,e),n)}delete(e){return super.delete(oye(this,e))}}function e6({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):n}function sye({_intern:t,_key:e},n){const r=e(n);return t.has(r)?t.get(r):(t.set(r,n),n)}function oye({_intern:t,_key:e},n){const r=e(n);return t.has(r)&&(n=t.get(r),t.delete(r)),n}function lye(t){return t!==null&&typeof t=="object"?t.valueOf():t}function cye(t=oh){if(t===oh)return LX;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 LX(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(t<e?-1:t>e?1:0)}const uye=Math.sqrt(50),dye=Math.sqrt(10),hye=Math.sqrt(2);function vS(t,e,n){const r=(e-t)/Math.max(0,n),i=Math.floor(Math.log10(r)),a=r/Math.pow(10,i),o=a>=uye?10:a>=dye?5:a>=hye?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?vS(t,e,n*2):[l,c,u]}function Jj(t,e,n){if(e=+e,t=+t,n=+n,!(n>0))return[];if(t===e)return[t];const r=e<t,[i,a,o]=r?vS(e,t,n):vS(t,e,n);if(!(a>=i))return[];const l=a-i+1,c=new Array(l);if(r)if(o<0)for(let u=0;u<l;++u)c[u]=(a-u)/-o;else for(let u=0;u<l;++u)c[u]=(a-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 e3(t,e,n){return e=+e,t=+t,n=+n,vS(t,e,n)[2]}function t3(t,e,n){e=+e,t=+t,n=+n;const r=e<t,i=r?e3(e,t,n):e3(t,e,n);return(r?-1:1)*(i<0?1/-i:i)}function t6(t,e){let n;for(const r of t)r!=null&&(n<r||n===void 0&&r>=r)&&(n=r);return n}function n6(t,e){let n;for(const r of t)r!=null&&(n>r||n===void 0&&r>=r)&&(n=r);return n}function FX(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?LX:cye(i);r>n;){if(r-n>600){const c=r-n+1,u=e-n+1,d=Math.log(c),f=.5*Math.exp(2*d/3),p=.5*Math.sqrt(d*f*(c-f)/c)*(u-c/2<0?-1:1),m=Math.max(n,Math.floor(e-u*f/c+p)),x=Math.min(r,Math.floor(e+(c-u)*f/c+p));FX(t,e,m,x,i)}const a=t[e];let o=n,l=r;for(Rb(t,n,e),i(t[r],a)>0&&Rb(t,n,r);o<l;){for(Rb(t,o,l),++o,--l;i(t[o],a)<0;)++o;for(;i(t[l],a)>0;)--l}i(t[n],a)===0?Rb(t,n,l):(++l,Rb(t,l,r)),l<=e&&(n=l+1),e<=l&&(r=l-1)}return t}function Rb(t,e,n){const r=t[e];t[e]=t[n],t[n]=r}function fye(t,e,n){if(t=Float64Array.from(iye(t)),!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return n6(t);if(e>=1)return t6(t);var r,i=(r-1)*e,a=Math.floor(i),o=t6(FX(t,a).subarray(0,a+1)),l=n6(t.subarray(a+1));return o+(l-o)*(i-a)}}function mye(t,e,n=OX){if(!(!(r=t.length)||isNaN(e=+e))){if(e<=0||r<2)return+n(t[0],0,t);if(e>=1)return+n(t[r-1],r-1,t);var r,i=(r-1)*e,a=Math.floor(i),o=+n(t[a],a,t),l=+n(t[a+1],a+1,t);return o+(l-o)*(i-a)}}function pye(t,e,n){t=+t,e=+e,n=(i=arguments.length)<2?(e=t,t=0,1):i<3?1:+n;for(var r=-1,i=Math.max(0,Math.ceil((e-t)/n))|0,a=new Array(i);++r<i;)a[r]=t+r*n;return a}function ml(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function Ku(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 n3=Symbol("implicit");function fO(){var t=new J8,e=[],n=[],r=n3;function i(a){let o=t.get(a);if(o===void 0){if(r!==n3)return r;t.set(a,o=e.push(a)-1)}return n[o%n.length]}return i.domain=function(a){if(!arguments.length)return e.slice();e=[],t=new J8;for(const o of a)t.has(o)||t.set(o,e.push(o)-1);return i},i.range=function(a){return arguments.length?(n=Array.from(a),i):n.slice()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return fO(e,n).unknown(r)},ml.apply(i,arguments),i}function mO(){var t=fO().unknown(void 0),e=t.domain,n=t.range,r=0,i=1,a,o,l=!1,c=0,u=0,d=.5;delete t.unknown;function f(){var p=e().length,m=i<r,x=m?i:r,b=m?r:i;a=(b-x)/Math.max(1,p-c+u*2),l&&(a=Math.floor(a)),x+=(b-x-a*(p-c))*d,o=a*(1-c),l&&(x=Math.round(x),o=Math.round(o));var v=pye(p).map(function(y){return x+a*y});return n(m?v.reverse():v)}return t.domain=function(p){return arguments.length?(e(p),f()):e()},t.range=function(p){return arguments.length?([r,i]=p,r=+r,i=+i,f()):[r,i]},t.rangeRound=function(p){return[r,i]=p,r=+r,i=+i,l=!0,f()},t.bandwidth=function(){return o},t.step=function(){return a},t.round=function(p){return arguments.length?(l=!!p,f()):l},t.padding=function(p){return arguments.length?(c=Math.min(1,u=+p),f()):c},t.paddingInner=function(p){return arguments.length?(c=Math.min(1,p),f()):c},t.paddingOuter=function(p){return arguments.length?(u=+p,f()):u},t.align=function(p){return arguments.length?(d=Math.max(0,Math.min(1,p)),f()):d},t.copy=function(){return mO(e(),[r,i]).round(l).paddingInner(c).paddingOuter(u).align(d)},ml.apply(f(),arguments)}function IX(t){var e=t.copy;return t.padding=t.paddingOuter,delete t.paddingInner,delete t.paddingOuter,t.copy=function(){return IX(e())},t}function gye(){return IX(mO.apply(null,arguments).paddingInner(1))}function pO(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function UX(t,e){var n=Object.create(t.prototype);for(var r in e)n[r]=e[r];return n}function Xy(){}var ry=.7,wS=1/ry,Eg="\\s*([+-]?\\d+)\\s*",iy="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",dc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",xye=/^#([0-9a-f]{3,8})$/,bye=new RegExp(`^rgb\\(${Eg},${Eg},${Eg}\\)$`),yye=new RegExp(`^rgb\\(${dc},${dc},${dc}\\)$`),vye=new RegExp(`^rgba\\(${Eg},${Eg},${Eg},${iy}\\)$`),wye=new RegExp(`^rgba\\(${dc},${dc},${dc},${iy}\\)$`),_ye=new RegExp(`^hsl\\(${iy},${dc},${dc}\\)$`),Sye=new RegExp(`^hsla\\(${iy},${dc},${dc},${iy}\\)$`),r6={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};pO(Xy,ay,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:i6,formatHex:i6,formatHex8:Nye,formatHsl:Mye,formatRgb:a6,toString:a6});function i6(){return this.rgb().formatHex()}function Nye(){return this.rgb().formatHex8()}function Mye(){return zX(this).formatHsl()}function a6(){return this.rgb().formatRgb()}function ay(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=xye.exec(t))?(n=e[1].length,e=parseInt(e[1],16),n===6?s6(e):n===3?new Fs(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):n===8?Gw(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):n===4?Gw(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=bye.exec(t))?new Fs(e[1],e[2],e[3],1):(e=yye.exec(t))?new Fs(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=vye.exec(t))?Gw(e[1],e[2],e[3],e[4]):(e=wye.exec(t))?Gw(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=_ye.exec(t))?c6(e[1],e[2]/100,e[3]/100,1):(e=Sye.exec(t))?c6(e[1],e[2]/100,e[3]/100,e[4]):r6.hasOwnProperty(t)?s6(r6[t]):t==="transparent"?new Fs(NaN,NaN,NaN,0):null}function s6(t){return new Fs(t>>16&255,t>>8&255,t&255,1)}function Gw(t,e,n,r){return r<=0&&(t=e=n=NaN),new Fs(t,e,n,r)}function kye(t){return t instanceof Xy||(t=ay(t)),t?(t=t.rgb(),new Fs(t.r,t.g,t.b,t.opacity)):new Fs}function r3(t,e,n,r){return arguments.length===1?kye(t):new Fs(t,e,n,r??1)}function Fs(t,e,n,r){this.r=+t,this.g=+e,this.b=+n,this.opacity=+r}pO(Fs,r3,UX(Xy,{brighter(t){return t=t==null?wS:Math.pow(wS,t),new Fs(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?ry:Math.pow(ry,t),new Fs(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Fs($f(this.r),$f(this.g),$f(this.b),_S(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:o6,formatHex:o6,formatHex8:Eye,formatRgb:l6,toString:l6}));function o6(){return`#${jf(this.r)}${jf(this.g)}${jf(this.b)}`}function Eye(){return`#${jf(this.r)}${jf(this.g)}${jf(this.b)}${jf((isNaN(this.opacity)?1:this.opacity)*255)}`}function l6(){const t=_S(this.opacity);return`${t===1?"rgb(":"rgba("}${$f(this.r)}, ${$f(this.g)}, ${$f(this.b)}${t===1?")":`, ${t})`}`}function _S(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function $f(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function jf(t){return t=$f(t),(t<16?"0":"")+t.toString(16)}function c6(t,e,n,r){return r<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Al(t,e,n,r)}function zX(t){if(t instanceof Al)return new Al(t.h,t.s,t.l,t.opacity);if(t instanceof Xy||(t=ay(t)),!t)return new Al;if(t instanceof Al)return t;t=t.rgb();var e=t.r/255,n=t.g/255,r=t.b/255,i=Math.min(e,n,r),a=Math.max(e,n,r),o=NaN,l=a-i,c=(a+i)/2;return l?(e===a?o=(n-r)/l+(n<r)*6:n===a?o=(r-e)/l+2:o=(e-n)/l+4,l/=c<.5?a+i:2-a-i,o*=60):l=c>0&&c<1?0:o,new Al(o,l,c,t.opacity)}function Tye(t,e,n,r){return arguments.length===1?zX(t):new Al(t,e,n,r??1)}function Al(t,e,n,r){this.h=+t,this.s=+e,this.l=+n,this.opacity=+r}pO(Al,Tye,UX(Xy,{brighter(t){return t=t==null?wS:Math.pow(wS,t),new Al(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?ry:Math.pow(ry,t),new Al(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 Fs(mA(t>=240?t-240:t+120,i,r),mA(t,i,r),mA(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Al(u6(this.h),qw(this.s),qw(this.l),_S(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=_S(this.opacity);return`${t===1?"hsl(":"hsla("}${u6(this.h)}, ${qw(this.s)*100}%, ${qw(this.l)*100}%${t===1?")":`, ${t})`}`}}));function u6(t){return t=(t||0)%360,t<0?t+360:t}function qw(t){return Math.max(0,Math.min(1,t||0))}function mA(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 Aye(t,e){return function(n){return t+n*e}}function Cye(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 Pye(t){return(t=+t)==1?BX:function(e,n){return n-e?Cye(e,n,t):gO(isNaN(e)?n:e)}}function BX(t,e){var n=e-t;return n?Aye(t,n):gO(isNaN(t)?e:t)}const d6=(function t(e){var n=Pye(e);function r(i,a){var o=n((i=r3(i)).r,(a=r3(a)).r),l=n(i.g,a.g),c=n(i.b,a.b),u=BX(i.opacity,a.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 jye(t,e){e||(e=[]);var n=t?Math.min(e.length,t.length):0,r=e.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=t[i]*(1-a)+e[i]*a;return r}}function Dye(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Rye(t,e){var n=e?e.length:0,r=t?Math.min(n,t.length):0,i=new Array(r),a=new Array(n),o;for(o=0;o<r;++o)i[o]=_x(t[o],e[o]);for(;o<n;++o)a[o]=e[o];return function(l){for(o=0;o<r;++o)a[o]=i[o](l);return a}}function Oye(t,e){var n=new Date;return t=+t,e=+e,function(r){return n.setTime(t*(1-r)+e*r),n}}function SS(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Lye(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]=_x(t[i],e[i]):r[i]=e[i];return function(a){for(i in n)r[i]=n[i](a);return r}}var i3=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,pA=new RegExp(i3.source,"g");function Fye(t){return function(){return t}}function Iye(t){return function(e){return t(e)+""}}function Uye(t,e){var n=i3.lastIndex=pA.lastIndex=0,r,i,a,o=-1,l=[],c=[];for(t=t+"",e=e+"";(r=i3.exec(t))&&(i=pA.exec(e));)(a=i.index)>n&&(a=e.slice(n,a),l[o]?l[o]+=a:l[++o]=a),(r=r[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,c.push({i:o,x:SS(r,i)})),n=pA.lastIndex;return n<e.length&&(a=e.slice(n),l[o]?l[o]+=a:l[++o]=a),l.length<2?c[0]?Iye(c[0].x):Fye(e):(e=c.length,function(u){for(var d=0,f;d<e;++d)l[(f=c[d]).i]=f.x(u);return l.join("")})}function _x(t,e){var n=typeof e,r;return e==null||n==="boolean"?gO(e):(n==="number"?SS:n==="string"?(r=ay(e))?(e=r,d6):Uye:e instanceof ay?d6:e instanceof Date?Oye:Dye(e)?jye:Array.isArray(e)?Rye:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Lye:SS)(t,e)}function xO(t,e){return t=+t,e=+e,function(n){return Math.round(t*(1-n)+e*n)}}function zye(t,e){e===void 0&&(e=t,t=_x);for(var n=0,r=e.length-1,i=e[0],a=new Array(r<0?0:r);n<r;)a[n]=t(i,i=e[++n]);return function(o){var l=Math.max(0,Math.min(r-1,Math.floor(o*=r)));return a[l](o-l)}}function Bye(t){return function(){return t}}function NS(t){return+t}var h6=[0,1];function fs(t){return t}function a3(t,e){return(e-=t=+t)?function(n){return(n-t)/e}:Bye(isNaN(e)?NaN:.5)}function Hye(t,e){var n;return t>e&&(n=t,t=e,e=n),function(r){return Math.max(t,Math.min(e,r))}}function $ye(t,e,n){var r=t[0],i=t[1],a=e[0],o=e[1];return i<r?(r=a3(i,r),a=n(o,a)):(r=a3(r,i),a=n(a,o)),function(l){return a(r(l))}}function Vye(t,e,n){var r=Math.min(t.length,e.length)-1,i=new Array(r),a=new Array(r),o=-1;for(t[r]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++o<r;)i[o]=a3(t[o],t[o+1]),a[o]=n(e[o],e[o+1]);return function(l){var c=Ky(t,l,1,r)-1;return a[c](i[c](l))}}function Yy(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function zM(){var t=h6,e=h6,n=_x,r,i,a,o=fs,l,c,u;function d(){var p=Math.min(t.length,e.length);return o!==fs&&(o=Hye(t[0],t[p-1])),l=p>2?Vye:$ye,c=u=null,f}function f(p){return p==null||isNaN(p=+p)?a:(c||(c=l(t.map(r),e,n)))(r(o(p)))}return f.invert=function(p){return o(i((u||(u=l(e,t.map(r),SS)))(p)))},f.domain=function(p){return arguments.length?(t=Array.from(p,NS),d()):t.slice()},f.range=function(p){return arguments.length?(e=Array.from(p),d()):e.slice()},f.rangeRound=function(p){return e=Array.from(p),n=xO,d()},f.clamp=function(p){return arguments.length?(o=p?!0:fs,d()):o!==fs},f.interpolate=function(p){return arguments.length?(n=p,d()):n},f.unknown=function(p){return arguments.length?(a=p,f):a},function(p,m){return r=p,i=m,d()}}function bO(){return zM()(fs,fs)}function Gye(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function MS(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 Kg(t){return t=MS(Math.abs(t)),t?t[1]:NaN}function qye(t,e){return function(n,r){for(var i=n.length,a=[],o=0,l=t[0],c=0;i>0&&l>0&&(c+l+1>r&&(l=Math.max(1,r-c)),a.push(n.substring(i-=l,i+l)),!((c+=l+1)>r));)l=t[o=(o+1)%t.length];return a.reverse().join(e)}}function Wye(t){return function(e){return e.replace(/[0-9]/g,function(n){return t[+n]})}}var Kye=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function sy(t){if(!(e=Kye.exec(t)))throw new Error("invalid format: "+t);var e;return new yO({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]})}sy.prototype=yO.prototype;function yO(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+""}yO.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 Xye(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 HX;function Yye(t,e){var n=MS(t,e);if(!n)return t+"";var r=n[0],i=n[1],a=i-(HX=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,o=r.length;return a===o?r:a>o?r+new Array(a-o+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+MS(t,Math.max(0,e+a-1))[0]}function f6(t,e){var n=MS(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 m6={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Gye,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)=>f6(t*100,e),r:f6,s:Yye,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function p6(t){return t}var g6=Array.prototype.map,x6=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Qye(t){var e=t.grouping===void 0||t.thousands===void 0?p6:qye(g6.call(t.grouping,Number),t.thousands+""),n=t.currency===void 0?"":t.currency[0]+"",r=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",a=t.numerals===void 0?p6:Wye(g6.call(t.numerals,String)),o=t.percent===void 0?"%":t.percent+"",l=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function u(f){f=sy(f);var p=f.fill,m=f.align,x=f.sign,b=f.symbol,v=f.zero,y=f.width,S=f.comma,k=f.precision,T=f.trim,M=f.type;M==="n"?(S=!0,M="g"):m6[M]||(k===void 0&&(k=12),T=!0,M="g"),(v||p==="0"&&m==="=")&&(v=!0,p="0",m="=");var C=b==="$"?n:b==="#"&&/[boxX]/.test(M)?"0"+M.toLowerCase():"",E=b==="$"?r:/[%p]/.test(M)?o:"",R=m6[M],A=/[defgprs%]/.test(M);k=k===void 0?6:/[gprs]/.test(M)?Math.max(1,Math.min(21,k)):Math.max(0,Math.min(20,k));function D(I){var F=C,z=E,P,$,X;if(M==="c")z=R(I)+z,I="";else{I=+I;var V=I<0||1/I<0;if(I=isNaN(I)?c:R(Math.abs(I),k),T&&(I=Xye(I)),V&&+I==0&&x!=="+"&&(V=!1),F=(V?x==="("?x:l:x==="-"||x==="("?"":x)+F,z=(M==="s"?x6[8+HX/3]:"")+z+(V&&x==="("?")":""),A){for(P=-1,$=I.length;++P<$;)if(X=I.charCodeAt(P),48>X||X>57){z=(X===46?i+I.slice(P+1):I.slice(P))+z,I=I.slice(0,P);break}}}S&&!v&&(I=e(I,1/0));var Q=F.length+I.length+z.length,Z=Q<y?new Array(y-Q+1).join(p):"";switch(S&&v&&(I=e(Z+I,Z.length?y-z.length:1/0),Z=""),m){case"<":I=F+I+z+Z;break;case"=":I=F+Z+I+z;break;case"^":I=Z.slice(0,Q=Z.length>>1)+F+I+z+Z.slice(Q);break;default:I=Z+F+I+z;break}return a(I)}return D.toString=function(){return f+""},D}function d(f,p){var m=u((f=sy(f),f.type="f",f)),x=Math.max(-8,Math.min(8,Math.floor(Kg(p)/3)))*3,b=Math.pow(10,-x),v=x6[8+x/3];return function(y){return m(b*y)+v}}return{format:u,formatPrefix:d}}var Ww,vO,$X;Zye({thousands:",",grouping:[3],currency:["$",""]});function Zye(t){return Ww=Qye(t),vO=Ww.format,$X=Ww.formatPrefix,Ww}function Jye(t){return Math.max(0,-Kg(Math.abs(t)))}function eve(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(Kg(e)/3)))*3-Kg(Math.abs(t)))}function tve(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,Kg(e)-Kg(t))+1}function VX(t,e,n,r){var i=t3(t,e,n),a;switch(r=sy(r??",f"),r.type){case"s":{var o=Math.max(Math.abs(t),Math.abs(e));return r.precision==null&&!isNaN(a=eve(i,o))&&(r.precision=a),$X(r,o)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(a=tve(i,Math.max(Math.abs(t),Math.abs(e))))&&(r.precision=a-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(a=Jye(i))&&(r.precision=a-(r.type==="%")*2);break}}return vO(r)}function Fh(t){var e=t.domain;return t.ticks=function(n){var r=e();return Jj(r[0],r[r.length-1],n??10)},t.tickFormat=function(n,r){var i=e();return VX(i[0],i[i.length-1],n??10,r)},t.nice=function(n){n==null&&(n=10);var r=e(),i=0,a=r.length-1,o=r[i],l=r[a],c,u,d=10;for(l<o&&(u=o,o=l,l=u,u=i,i=a,a=u);d-- >0;){if(u=e3(o,l,n),u===c)return r[i]=o,r[a]=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 GX(){var t=bO();return t.copy=function(){return Yy(t,GX())},ml.apply(t,arguments),Fh(t)}function qX(t){var e;function n(r){return r==null||isNaN(r=+r)?e:r}return n.invert=n,n.domain=n.range=function(r){return arguments.length?(t=Array.from(r,NS),n):t.slice()},n.unknown=function(r){return arguments.length?(e=r,n):e},n.copy=function(){return qX(t).unknown(e)},t=arguments.length?Array.from(t,NS):[0,1],Fh(n)}function WX(t,e){t=t.slice();var n=0,r=t.length-1,i=t[n],a=t[r],o;return a<i&&(o=n,n=r,r=o,o=i,i=a,a=o),t[n]=e.floor(i),t[r]=e.ceil(a),t}function b6(t){return Math.log(t)}function y6(t){return Math.exp(t)}function nve(t){return-Math.log(-t)}function rve(t){return-Math.exp(-t)}function ive(t){return isFinite(t)?+("1e"+t):t<0?0:t}function ave(t){return t===10?ive:t===Math.E?Math.exp:e=>Math.pow(t,e)}function sve(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 v6(t){return(e,n)=>-t(-e,n)}function wO(t){const e=t(b6,y6),n=e.domain;let r=10,i,a;function o(){return i=sve(r),a=ave(r),n()[0]<0?(i=v6(i),a=v6(a),t(nve,rve)):t(b6,y6),e}return e.base=function(l){return arguments.length?(r=+l,o()):r},e.domain=function(l){return arguments.length?(n(l),o()):n()},e.ticks=l=>{const c=n();let u=c[0],d=c[c.length-1];const f=d<u;f&&([u,d]=[d,u]);let p=i(u),m=i(d),x,b;const v=l==null?10:+l;let y=[];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(b=p<0?x/a(-p):x*a(p),!(b<u)){if(b>d)break;y.push(b)}}else for(;p<=m;++p)for(x=r-1;x>=1;--x)if(b=p>0?x/a(-p):x*a(p),!(b<u)){if(b>d)break;y.push(b)}y.length*2<v&&(y=Jj(u,d,v))}else y=Jj(p,m,Math.min(m-p,v)).map(a);return f?y.reverse():y},e.tickFormat=(l,c)=>{if(l==null&&(l=10),c==null&&(c=r===10?"s":","),typeof c!="function"&&(!(r%1)&&(c=sy(c)).precision==null&&(c.trim=!0),c=vO(c)),l===1/0)return c;const u=Math.max(1,r*l/e.ticks().length);return d=>{let f=d/a(Math.round(i(d)));return f*r<r-.5&&(f*=r),f<=u?c(d):""}},e.nice=()=>n(WX(n(),{floor:l=>a(Math.floor(i(l))),ceil:l=>a(Math.ceil(i(l)))})),e}function KX(){const t=wO(zM()).domain([1,10]);return t.copy=()=>Yy(t,KX()).base(t.base()),ml.apply(t,arguments),t}function w6(t){return function(e){return Math.sign(e)*Math.log1p(Math.abs(e/t))}}function _6(t){return function(e){return Math.sign(e)*Math.expm1(Math.abs(e))*t}}function _O(t){var e=1,n=t(w6(e),_6(e));return n.constant=function(r){return arguments.length?t(w6(e=+r),_6(e)):e},Fh(n)}function XX(){var t=_O(zM());return t.copy=function(){return Yy(t,XX()).constant(t.constant())},ml.apply(t,arguments)}function S6(t){return function(e){return e<0?-Math.pow(-e,t):Math.pow(e,t)}}function ove(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function lve(t){return t<0?-t*t:t*t}function SO(t){var e=t(fs,fs),n=1;function r(){return n===1?t(fs,fs):n===.5?t(ove,lve):t(S6(n),S6(1/n))}return e.exponent=function(i){return arguments.length?(n=+i,r()):n},Fh(e)}function NO(){var t=SO(zM());return t.copy=function(){return Yy(t,NO()).exponent(t.exponent())},ml.apply(t,arguments),t}function cve(){return NO.apply(null,arguments).exponent(.5)}function N6(t){return Math.sign(t)*t*t}function uve(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}function YX(){var t=bO(),e=[0,1],n=!1,r;function i(a){var o=uve(t(a));return isNaN(o)?r:n?Math.round(o):o}return i.invert=function(a){return t.invert(N6(a))},i.domain=function(a){return arguments.length?(t.domain(a),i):t.domain()},i.range=function(a){return arguments.length?(t.range((e=Array.from(a,NS)).map(N6)),i):e.slice()},i.rangeRound=function(a){return i.range(a).round(!0)},i.round=function(a){return arguments.length?(n=!!a,i):n},i.clamp=function(a){return arguments.length?(t.clamp(a),i):t.clamp()},i.unknown=function(a){return arguments.length?(r=a,i):r},i.copy=function(){return YX(t.domain(),e).round(n).clamp(t.clamp()).unknown(r)},ml.apply(i,arguments),Fh(i)}function QX(){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]=mye(t,o/l);return a}function a(o){return o==null||isNaN(o=+o)?r:e[Ky(n,o)]}return a.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]]},a.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(oh),i()},a.range=function(o){return arguments.length?(e=Array.from(o),i()):e.slice()},a.unknown=function(o){return arguments.length?(r=o,a):r},a.quantiles=function(){return n.slice()},a.copy=function(){return QX().domain(t).range(e).unknown(r)},ml.apply(a,arguments)}function ZX(){var t=0,e=1,n=1,r=[.5],i=[0,1],a;function o(c){return c!=null&&c<=c?i[Ky(r,c,0,n)]:a}function l(){var c=-1;for(r=new Array(n);++c<n;)r[c]=((c+1)*e-(c-n)*t)/(n+1);return 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&&(a=c),o},o.thresholds=function(){return r.slice()},o.copy=function(){return ZX().domain([t,e]).range(i).unknown(a)},ml.apply(Fh(o),arguments)}function JX(){var t=[.5],e=[0,1],n,r=1;function i(a){return a!=null&&a<=a?e[Ky(t,a,0,r)]:n}return i.domain=function(a){return arguments.length?(t=Array.from(a),r=Math.min(t.length,e.length-1),i):t.slice()},i.range=function(a){return arguments.length?(e=Array.from(a),r=Math.min(t.length,e.length-1),i):e.slice()},i.invertExtent=function(a){var o=e.indexOf(a);return[t[o-1],t[o]]},i.unknown=function(a){return arguments.length?(n=a,i):n},i.copy=function(){return JX().domain(t).range(e).unknown(n)},ml.apply(i,arguments)}const gA=new Date,xA=new Date;function aa(t,e,n,r){function i(a){return t(a=arguments.length===0?new Date:new Date(+a)),a}return i.floor=a=>(t(a=new Date(+a)),a),i.ceil=a=>(t(a=new Date(a-1)),e(a,1),t(a),a),i.round=a=>{const o=i(a),l=i.ceil(a);return a-o<l-a?o:l},i.offset=(a,o)=>(e(a=new Date(+a),o==null?1:Math.floor(o)),a),i.range=(a,o,l)=>{const c=[];if(a=i.ceil(a),l=l==null?1:Math.floor(l),!(a<o)||!(l>0))return c;let u;do c.push(u=new Date(+a)),e(a,l),t(a);while(u<a&&a<o);return c},i.filter=a=>aa(o=>{if(o>=o)for(;t(o),!a(o);)o.setTime(o-1)},(o,l)=>{if(o>=o)if(l<0)for(;++l<=0;)for(;e(o,-1),!a(o););else for(;--l>=0;)for(;e(o,1),!a(o););}),n&&(i.count=(a,o)=>(gA.setTime(+a),xA.setTime(+o),t(gA),t(xA),Math.floor(n(gA,xA))),i.every=a=>(a=Math.floor(a),!isFinite(a)||!(a>0)?null:a>1?i.filter(r?o=>r(o)%a===0:o=>i.count(0,o)%a===0):i)),i}const kS=aa(()=>{},(t,e)=>{t.setTime(+t+e)},(t,e)=>e-t);kS.every=t=>(t=Math.floor(t),!isFinite(t)||!(t>0)?null:t>1?aa(e=>{e.setTime(Math.floor(e/t)*t)},(e,n)=>{e.setTime(+e+n*t)},(e,n)=>(n-e)/t):kS);kS.range;const yu=1e3,Jo=yu*60,vu=Jo*60,Iu=vu*24,MO=Iu*7,M6=Iu*30,bA=Iu*365,Df=aa(t=>{t.setTime(t-t.getMilliseconds())},(t,e)=>{t.setTime(+t+e*yu)},(t,e)=>(e-t)/yu,t=>t.getUTCSeconds());Df.range;const kO=aa(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*yu)},(t,e)=>{t.setTime(+t+e*Jo)},(t,e)=>(e-t)/Jo,t=>t.getMinutes());kO.range;const EO=aa(t=>{t.setUTCSeconds(0,0)},(t,e)=>{t.setTime(+t+e*Jo)},(t,e)=>(e-t)/Jo,t=>t.getUTCMinutes());EO.range;const TO=aa(t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*yu-t.getMinutes()*Jo)},(t,e)=>{t.setTime(+t+e*vu)},(t,e)=>(e-t)/vu,t=>t.getHours());TO.range;const AO=aa(t=>{t.setUTCMinutes(0,0,0)},(t,e)=>{t.setTime(+t+e*vu)},(t,e)=>(e-t)/vu,t=>t.getUTCHours());AO.range;const Qy=aa(t=>t.setHours(0,0,0,0),(t,e)=>t.setDate(t.getDate()+e),(t,e)=>(e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*Jo)/Iu,t=>t.getDate()-1);Qy.range;const BM=aa(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Iu,t=>t.getUTCDate()-1);BM.range;const eY=aa(t=>{t.setUTCHours(0,0,0,0)},(t,e)=>{t.setUTCDate(t.getUTCDate()+e)},(t,e)=>(e-t)/Iu,t=>Math.floor(t/Iu));eY.range;function Tm(t){return aa(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())*Jo)/MO)}const HM=Tm(0),ES=Tm(1),dve=Tm(2),hve=Tm(3),Xg=Tm(4),fve=Tm(5),mve=Tm(6);HM.range;ES.range;dve.range;hve.range;Xg.range;fve.range;mve.range;function Am(t){return aa(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)/MO)}const $M=Am(0),TS=Am(1),pve=Am(2),gve=Am(3),Yg=Am(4),xve=Am(5),bve=Am(6);$M.range;TS.range;pve.range;gve.range;Yg.range;xve.range;bve.range;const CO=aa(t=>{t.setDate(1),t.setHours(0,0,0,0)},(t,e)=>{t.setMonth(t.getMonth()+e)},(t,e)=>e.getMonth()-t.getMonth()+(e.getFullYear()-t.getFullYear())*12,t=>t.getMonth());CO.range;const PO=aa(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());PO.range;const Uu=aa(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());Uu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:aa(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)});Uu.range;const zu=aa(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());zu.every=t=>!isFinite(t=Math.floor(t))||!(t>0)?null:aa(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)});zu.range;function tY(t,e,n,r,i,a){const o=[[Df,1,yu],[Df,5,5*yu],[Df,15,15*yu],[Df,30,30*yu],[a,1,Jo],[a,5,5*Jo],[a,15,15*Jo],[a,30,30*Jo],[i,1,vu],[i,3,3*vu],[i,6,6*vu],[i,12,12*vu],[r,1,Iu],[r,2,2*Iu],[n,1,MO],[e,1,M6],[e,3,3*M6],[t,1,bA]];function l(u,d,f){const p=d<u;p&&([u,d]=[d,u]);const m=f&&typeof f.range=="function"?f:c(u,d,f),x=m?m.range(u,+d+1):[];return p?x.reverse():x}function c(u,d,f){const p=Math.abs(d-u)/f,m=hO(([,,v])=>v).right(o,p);if(m===o.length)return t.every(t3(u/bA,d/bA,f));if(m===0)return kS.every(Math.max(t3(u,d,f),1));const[x,b]=o[p/o[m-1][2]<o[m][2]/p?m-1:m];return x.every(b)}return[l,c]}const[yve,vve]=tY(zu,PO,$M,eY,AO,EO),[wve,_ve]=tY(Uu,CO,HM,Qy,TO,kO);function yA(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 vA(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 Ob(t,e,n){return{y:t,m:e,d:n,H:0,M:0,S:0,L:0}}function Sve(t){var e=t.dateTime,n=t.date,r=t.time,i=t.periods,a=t.days,o=t.shortDays,l=t.months,c=t.shortMonths,u=Lb(i),d=Fb(i),f=Lb(a),p=Fb(a),m=Lb(o),x=Fb(o),b=Lb(l),v=Fb(l),y=Lb(c),S=Fb(c),k={a:V,A:Q,b:Z,B:se,c:null,d:P6,e:P6,f:qve,g:nwe,G:iwe,H:$ve,I:Vve,j:Gve,L:nY,m:Wve,M:Kve,p:H,q:K,Q:R6,s:O6,S:Xve,u:Yve,U:Qve,V:Zve,w:Jve,W:ewe,x:null,X:null,y:twe,Y:rwe,Z:awe,"%":D6},T={a:re,A:ne,b:be,B:me,c:null,d:j6,e:j6,f:cwe,g:ywe,G:wwe,H:swe,I:owe,j:lwe,L:iY,m:uwe,M:dwe,p:de,q:Ce,Q:R6,s:O6,S:hwe,u:fwe,U:mwe,V:pwe,w:gwe,W:xwe,x:null,X:null,y:bwe,Y:vwe,Z:_we,"%":D6},M={a:D,A:I,b:F,B:z,c:P,d:A6,e:A6,f:Uve,g:T6,G:E6,H:C6,I:C6,j:Ove,L:Ive,m:Rve,M:Lve,p:A,q:Dve,Q:Bve,s:Hve,S:Fve,u:Tve,U:Ave,V:Cve,w:Eve,W:Pve,x:$,X,y:T6,Y:E6,Z:jve,"%":zve};k.x=C(n,k),k.X=C(r,k),k.c=C(e,k),T.x=C(n,T),T.X=C(r,T),T.c=C(e,T);function C(ie,ke){return function(Oe){var pe=[],We=-1,G=0,Y=ie.length,ue,q,te;for(Oe instanceof Date||(Oe=new Date(+Oe));++We<Y;)ie.charCodeAt(We)===37&&(pe.push(ie.slice(G,We)),(q=k6[ue=ie.charAt(++We)])!=null?ue=ie.charAt(++We):q=ue==="e"?" ":"0",(te=ke[ue])&&(ue=te(Oe,q)),pe.push(ue),G=We+1);return pe.push(ie.slice(G,We)),pe.join("")}}function E(ie,ke){return function(Oe){var pe=Ob(1900,void 0,1),We=R(pe,ie,Oe+="",0),G,Y;if(We!=Oe.length)return null;if("Q"in pe)return new Date(pe.Q);if("s"in pe)return new Date(pe.s*1e3+("L"in pe?pe.L:0));if(ke&&!("Z"in pe)&&(pe.Z=0),"p"in pe&&(pe.H=pe.H%12+pe.p*12),pe.m===void 0&&(pe.m="q"in pe?pe.q:0),"V"in pe){if(pe.V<1||pe.V>53)return null;"w"in pe||(pe.w=1),"Z"in pe?(G=vA(Ob(pe.y,0,1)),Y=G.getUTCDay(),G=Y>4||Y===0?TS.ceil(G):TS(G),G=BM.offset(G,(pe.V-1)*7),pe.y=G.getUTCFullYear(),pe.m=G.getUTCMonth(),pe.d=G.getUTCDate()+(pe.w+6)%7):(G=yA(Ob(pe.y,0,1)),Y=G.getDay(),G=Y>4||Y===0?ES.ceil(G):ES(G),G=Qy.offset(G,(pe.V-1)*7),pe.y=G.getFullYear(),pe.m=G.getMonth(),pe.d=G.getDate()+(pe.w+6)%7)}else("W"in pe||"U"in pe)&&("w"in pe||(pe.w="u"in pe?pe.u%7:"W"in pe?1:0),Y="Z"in pe?vA(Ob(pe.y,0,1)).getUTCDay():yA(Ob(pe.y,0,1)).getDay(),pe.m=0,pe.d="W"in pe?(pe.w+6)%7+pe.W*7-(Y+5)%7:pe.w+pe.U*7-(Y+6)%7);return"Z"in pe?(pe.H+=pe.Z/100|0,pe.M+=pe.Z%100,vA(pe)):yA(pe)}}function R(ie,ke,Oe,pe){for(var We=0,G=ke.length,Y=Oe.length,ue,q;We<G;){if(pe>=Y)return-1;if(ue=ke.charCodeAt(We++),ue===37){if(ue=ke.charAt(We++),q=M[ue in k6?ke.charAt(We++):ue],!q||(pe=q(ie,Oe,pe))<0)return-1}else if(ue!=Oe.charCodeAt(pe++))return-1}return pe}function A(ie,ke,Oe){var pe=u.exec(ke.slice(Oe));return pe?(ie.p=d.get(pe[0].toLowerCase()),Oe+pe[0].length):-1}function D(ie,ke,Oe){var pe=m.exec(ke.slice(Oe));return pe?(ie.w=x.get(pe[0].toLowerCase()),Oe+pe[0].length):-1}function I(ie,ke,Oe){var pe=f.exec(ke.slice(Oe));return pe?(ie.w=p.get(pe[0].toLowerCase()),Oe+pe[0].length):-1}function F(ie,ke,Oe){var pe=y.exec(ke.slice(Oe));return pe?(ie.m=S.get(pe[0].toLowerCase()),Oe+pe[0].length):-1}function z(ie,ke,Oe){var pe=b.exec(ke.slice(Oe));return pe?(ie.m=v.get(pe[0].toLowerCase()),Oe+pe[0].length):-1}function P(ie,ke,Oe){return R(ie,e,ke,Oe)}function $(ie,ke,Oe){return R(ie,n,ke,Oe)}function X(ie,ke,Oe){return R(ie,r,ke,Oe)}function V(ie){return o[ie.getDay()]}function Q(ie){return a[ie.getDay()]}function Z(ie){return c[ie.getMonth()]}function se(ie){return l[ie.getMonth()]}function H(ie){return i[+(ie.getHours()>=12)]}function K(ie){return 1+~~(ie.getMonth()/3)}function re(ie){return o[ie.getUTCDay()]}function ne(ie){return a[ie.getUTCDay()]}function be(ie){return c[ie.getUTCMonth()]}function me(ie){return l[ie.getUTCMonth()]}function de(ie){return i[+(ie.getUTCHours()>=12)]}function Ce(ie){return 1+~~(ie.getUTCMonth()/3)}return{format:function(ie){var ke=C(ie+="",k);return ke.toString=function(){return ie},ke},parse:function(ie){var ke=E(ie+="",!1);return ke.toString=function(){return ie},ke},utcFormat:function(ie){var ke=C(ie+="",T);return ke.toString=function(){return ie},ke},utcParse:function(ie){var ke=E(ie+="",!0);return ke.toString=function(){return ie},ke}}}var k6={"-":"",_:" ",0:"0"},Ma=/^\s*\d+/,Nve=/^%/,Mve=/[\\^$*+?|[\]().{}]/g;function ur(t,e,n){var r=t<0?"-":"",i=(r?-t:t)+"",a=i.length;return r+(a<n?new Array(n-a+1).join(e)+i:i)}function kve(t){return t.replace(Mve,"\\$&")}function Lb(t){return new RegExp("^(?:"+t.map(kve).join("|")+")","i")}function Fb(t){return new Map(t.map((e,n)=>[e.toLowerCase(),n]))}function Eve(t,e,n){var r=Ma.exec(e.slice(n,n+1));return r?(t.w=+r[0],n+r[0].length):-1}function Tve(t,e,n){var r=Ma.exec(e.slice(n,n+1));return r?(t.u=+r[0],n+r[0].length):-1}function Ave(t,e,n){var r=Ma.exec(e.slice(n,n+2));return r?(t.U=+r[0],n+r[0].length):-1}function Cve(t,e,n){var r=Ma.exec(e.slice(n,n+2));return r?(t.V=+r[0],n+r[0].length):-1}function Pve(t,e,n){var r=Ma.exec(e.slice(n,n+2));return r?(t.W=+r[0],n+r[0].length):-1}function E6(t,e,n){var r=Ma.exec(e.slice(n,n+4));return r?(t.y=+r[0],n+r[0].length):-1}function T6(t,e,n){var r=Ma.exec(e.slice(n,n+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),n+r[0].length):-1}function jve(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 Dve(t,e,n){var r=Ma.exec(e.slice(n,n+1));return r?(t.q=r[0]*3-3,n+r[0].length):-1}function Rve(t,e,n){var r=Ma.exec(e.slice(n,n+2));return r?(t.m=r[0]-1,n+r[0].length):-1}function A6(t,e,n){var r=Ma.exec(e.slice(n,n+2));return r?(t.d=+r[0],n+r[0].length):-1}function Ove(t,e,n){var r=Ma.exec(e.slice(n,n+3));return r?(t.m=0,t.d=+r[0],n+r[0].length):-1}function C6(t,e,n){var r=Ma.exec(e.slice(n,n+2));return r?(t.H=+r[0],n+r[0].length):-1}function Lve(t,e,n){var r=Ma.exec(e.slice(n,n+2));return r?(t.M=+r[0],n+r[0].length):-1}function Fve(t,e,n){var r=Ma.exec(e.slice(n,n+2));return r?(t.S=+r[0],n+r[0].length):-1}function Ive(t,e,n){var r=Ma.exec(e.slice(n,n+3));return r?(t.L=+r[0],n+r[0].length):-1}function Uve(t,e,n){var r=Ma.exec(e.slice(n,n+6));return r?(t.L=Math.floor(r[0]/1e3),n+r[0].length):-1}function zve(t,e,n){var r=Nve.exec(e.slice(n,n+1));return r?n+r[0].length:-1}function Bve(t,e,n){var r=Ma.exec(e.slice(n));return r?(t.Q=+r[0],n+r[0].length):-1}function Hve(t,e,n){var r=Ma.exec(e.slice(n));return r?(t.s=+r[0],n+r[0].length):-1}function P6(t,e){return ur(t.getDate(),e,2)}function $ve(t,e){return ur(t.getHours(),e,2)}function Vve(t,e){return ur(t.getHours()%12||12,e,2)}function Gve(t,e){return ur(1+Qy.count(Uu(t),t),e,3)}function nY(t,e){return ur(t.getMilliseconds(),e,3)}function qve(t,e){return nY(t,e)+"000"}function Wve(t,e){return ur(t.getMonth()+1,e,2)}function Kve(t,e){return ur(t.getMinutes(),e,2)}function Xve(t,e){return ur(t.getSeconds(),e,2)}function Yve(t){var e=t.getDay();return e===0?7:e}function Qve(t,e){return ur(HM.count(Uu(t)-1,t),e,2)}function rY(t){var e=t.getDay();return e>=4||e===0?Xg(t):Xg.ceil(t)}function Zve(t,e){return t=rY(t),ur(Xg.count(Uu(t),t)+(Uu(t).getDay()===4),e,2)}function Jve(t){return t.getDay()}function ewe(t,e){return ur(ES.count(Uu(t)-1,t),e,2)}function twe(t,e){return ur(t.getFullYear()%100,e,2)}function nwe(t,e){return t=rY(t),ur(t.getFullYear()%100,e,2)}function rwe(t,e){return ur(t.getFullYear()%1e4,e,4)}function iwe(t,e){var n=t.getDay();return t=n>=4||n===0?Xg(t):Xg.ceil(t),ur(t.getFullYear()%1e4,e,4)}function awe(t){var e=t.getTimezoneOffset();return(e>0?"-":(e*=-1,"+"))+ur(e/60|0,"0",2)+ur(e%60,"0",2)}function j6(t,e){return ur(t.getUTCDate(),e,2)}function swe(t,e){return ur(t.getUTCHours(),e,2)}function owe(t,e){return ur(t.getUTCHours()%12||12,e,2)}function lwe(t,e){return ur(1+BM.count(zu(t),t),e,3)}function iY(t,e){return ur(t.getUTCMilliseconds(),e,3)}function cwe(t,e){return iY(t,e)+"000"}function uwe(t,e){return ur(t.getUTCMonth()+1,e,2)}function dwe(t,e){return ur(t.getUTCMinutes(),e,2)}function hwe(t,e){return ur(t.getUTCSeconds(),e,2)}function fwe(t){var e=t.getUTCDay();return e===0?7:e}function mwe(t,e){return ur($M.count(zu(t)-1,t),e,2)}function aY(t){var e=t.getUTCDay();return e>=4||e===0?Yg(t):Yg.ceil(t)}function pwe(t,e){return t=aY(t),ur(Yg.count(zu(t),t)+(zu(t).getUTCDay()===4),e,2)}function gwe(t){return t.getUTCDay()}function xwe(t,e){return ur(TS.count(zu(t)-1,t),e,2)}function bwe(t,e){return ur(t.getUTCFullYear()%100,e,2)}function ywe(t,e){return t=aY(t),ur(t.getUTCFullYear()%100,e,2)}function vwe(t,e){return ur(t.getUTCFullYear()%1e4,e,4)}function wwe(t,e){var n=t.getUTCDay();return t=n>=4||n===0?Yg(t):Yg.ceil(t),ur(t.getUTCFullYear()%1e4,e,4)}function _we(){return"+0000"}function D6(){return"%"}function R6(t){return+t}function O6(t){return Math.floor(+t/1e3)}var xp,sY,oY;Swe({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 Swe(t){return xp=Sve(t),sY=xp.format,xp.parse,oY=xp.utcFormat,xp.utcParse,xp}function Nwe(t){return new Date(t)}function Mwe(t){return t instanceof Date?+t:+new Date(+t)}function jO(t,e,n,r,i,a,o,l,c,u){var d=bO(),f=d.invert,p=d.domain,m=u(".%L"),x=u(":%S"),b=u("%I:%M"),v=u("%I %p"),y=u("%a %d"),S=u("%b %d"),k=u("%B"),T=u("%Y");function M(C){return(c(C)<C?m:l(C)<C?x:o(C)<C?b:a(C)<C?v:r(C)<C?i(C)<C?y:S:n(C)<C?k:T)(C)}return d.invert=function(C){return new Date(f(C))},d.domain=function(C){return arguments.length?p(Array.from(C,Mwe)):p().map(Nwe)},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?M: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(WX(E,C)):d},d.copy=function(){return Yy(d,jO(t,e,n,r,i,a,o,l,c,u))},d}function kwe(){return ml.apply(jO(wve,_ve,Uu,CO,HM,Qy,TO,kO,Df,sY).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)}function Ewe(){return ml.apply(jO(yve,vve,zu,PO,$M,BM,AO,EO,Df,oY).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)}function VM(){var t=0,e=1,n,r,i,a,o=fs,l=!1,c;function u(f){return f==null||isNaN(f=+f)?c:o(i===0?.5:(f=(a(f)-n)*i,l?Math.max(0,Math.min(1,f)):f))}u.domain=function(f){return arguments.length?([t,e]=f,n=a(t=+t),r=a(e=+e),i=n===r?0:1/(r-n),u):[t,e]},u.clamp=function(f){return arguments.length?(l=!!f,u):l},u.interpolator=function(f){return arguments.length?(o=f,u):o};function d(f){return function(p){var m,x;return arguments.length?([m,x]=p,o=f(m,x),u):[o(0),o(1)]}}return u.range=d(_x),u.rangeRound=d(xO),u.unknown=function(f){return arguments.length?(c=f,u):c},function(f){return a=f,n=f(t),r=f(e),i=n===r?0:1/(r-n),u}}function Ih(t,e){return e.domain(t.domain()).interpolator(t.interpolator()).clamp(t.clamp()).unknown(t.unknown())}function lY(){var t=Fh(VM()(fs));return t.copy=function(){return Ih(t,lY())},Ku.apply(t,arguments)}function cY(){var t=wO(VM()).domain([1,10]);return t.copy=function(){return Ih(t,cY()).base(t.base())},Ku.apply(t,arguments)}function uY(){var t=_O(VM());return t.copy=function(){return Ih(t,uY()).constant(t.constant())},Ku.apply(t,arguments)}function DO(){var t=SO(VM());return t.copy=function(){return Ih(t,DO()).exponent(t.exponent())},Ku.apply(t,arguments)}function Twe(){return DO.apply(null,arguments).exponent(.5)}function dY(){var t=[],e=fs;function n(r){if(r!=null&&!isNaN(r=+r))return e((Ky(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(oh),n},n.interpolator=function(r){return arguments.length?(e=r,n):e},n.range=function(){return t.map((r,i)=>e(i/(t.length-1)))},n.quantiles=function(r){return Array.from({length:r+1},(i,a)=>fye(t,a/r))},n.copy=function(){return dY(e).domain(t)},Ku.apply(n,arguments)}function GM(){var t=0,e=.5,n=1,r=1,i,a,o,l,c,u=fs,d,f=!1,p;function m(b){return isNaN(b=+b)?p:(b=.5+((b=+d(b))-a)*(r*b<r*a?l:c),u(f?Math.max(0,Math.min(1,b)):b))}m.domain=function(b){return arguments.length?([t,e,n]=b,i=d(t=+t),a=d(e=+e),o=d(n=+n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,m):[t,e,n]},m.clamp=function(b){return arguments.length?(f=!!b,m):f},m.interpolator=function(b){return arguments.length?(u=b,m):u};function x(b){return function(v){var y,S,k;return arguments.length?([y,S,k]=v,u=zye(b,[y,S,k]),m):[u(0),u(.5),u(1)]}}return m.range=x(_x),m.rangeRound=x(xO),m.unknown=function(b){return arguments.length?(p=b,m):p},function(b){return d=b,i=b(t),a=b(e),o=b(n),l=i===a?0:.5/(a-i),c=a===o?0:.5/(o-a),r=a<i?-1:1,m}}function hY(){var t=Fh(GM()(fs));return t.copy=function(){return Ih(t,hY())},Ku.apply(t,arguments)}function fY(){var t=wO(GM()).domain([.1,1,10]);return t.copy=function(){return Ih(t,fY()).base(t.base())},Ku.apply(t,arguments)}function mY(){var t=_O(GM());return t.copy=function(){return Ih(t,mY()).constant(t.constant())},Ku.apply(t,arguments)}function RO(){var t=SO(GM());return t.copy=function(){return Ih(t,RO()).exponent(t.exponent())},Ku.apply(t,arguments)}function Awe(){return RO.apply(null,arguments).exponent(.5)}const a0=Object.freeze(Object.defineProperty({__proto__:null,scaleBand:mO,scaleDiverging:hY,scaleDivergingLog:fY,scaleDivergingPow:RO,scaleDivergingSqrt:Awe,scaleDivergingSymlog:mY,scaleIdentity:qX,scaleImplicit:n3,scaleLinear:GX,scaleLog:KX,scaleOrdinal:fO,scalePoint:gye,scalePow:NO,scaleQuantile:QX,scaleQuantize:ZX,scaleRadial:YX,scaleSequential:lY,scaleSequentialLog:cY,scaleSequentialPow:DO,scaleSequentialQuantile:dY,scaleSequentialSqrt:Twe,scaleSequentialSymlog:uY,scaleSqrt:cve,scaleSymlog:XX,scaleThreshold:JX,scaleTime:kwe,scaleUtc:Ewe,tickFormat:VX},Symbol.toStringTag,{value:"Module"}));var Uh=t=>t.chartData,OO=it([Uh],t=>{var e=t.chartData!=null?t.chartData.length-1:0;return{chartData:t.chartData,computedData:t.computedData,dataEndIndex:e,dataStartIndex:0}}),Zy=(t,e,n,r)=>r?OO(t):Uh(t);function _h(t){if(Array.isArray(t)&&t.length===2){var[e,n]=t;if(vr(e)&&vr(n))return!0}return!1}function L6(t,e,n){return n?t:[Math.min(t[0],e[0]),Math.max(t[1],e[1])]}function pY(t,e){if(e&&typeof t!="function"&&Array.isArray(t)&&t.length===2){var[n,r]=t,i,a;if(vr(n))i=n;else if(typeof n=="function")return;if(vr(r))a=r;else if(typeof r=="function")return;var o=[i,a];if(_h(o))return o}}function Cwe(t,e,n){if(!(!n&&e==null)){if(typeof t=="function"&&e!=null)try{var r=t(e,n);if(_h(r))return L6(r,e,n)}catch{}if(Array.isArray(t)&&t.length===2){var[i,a]=t,o,l;if(i==="auto")e!=null&&(o=Math.min(...e));else if(zt(i))o=i;else if(typeof i=="function")try{e!=null&&(o=i(e?.[0]))}catch{}else if(typeof i=="string"&&u8.test(i)){var c=u8.exec(i);if(c==null||e==null)o=void 0;else{var u=+c[1];o=e[0]-u}}else o=e?.[0];if(a==="auto")e!=null&&(l=Math.max(...e));else if(zt(a))l=a;else if(typeof a=="function")try{e!=null&&(l=a(e?.[1]))}catch{}else if(typeof a=="string"&&d8.test(a)){var d=d8.exec(a);if(d==null||e==null)l=void 0;else{var f=+d[1];l=e[1]+f}}else l=e?.[1];var p=[o,l];if(_h(p))return e==null?p:L6(p,e,n)}}}var Sx=1e9,Pwe={precision:20,rounding:4,toExpNeg:-7,toExpPos:21,LN10:"2.302585092994045684017991454684364207601101488628772976033327900967572609677352480235997205089598298341967784042286"},FO,ni=!0,dl="[DecimalError] ",Vf=dl+"Invalid argument: ",LO=dl+"Exponent out of range: ",Nx=Math.floor,_f=Math.pow,jwe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,lo,ga=1e7,Wr=7,gY=9007199254740991,AS=Nx(gY/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,a=this;if(t=new a.constructor(t),a.s!==t.s)return a.s||-t.s;if(a.e!==t.e)return a.e>t.e^a.s<0?1:-1;for(r=a.d.length,i=t.d.length,e=0,n=r<i?r:i;e<n;++e)if(a.d[e]!==t.d[e])return a.d[e]>t.d[e]^a.s<0?1:-1;return r===i?0:r>i^a.s<0?1:-1};$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 Eu(this,new this.constructor(t))};$t.dividedToIntegerBy=$t.idiv=function(t){var e=this,n=e.constructor;return Or(Eu(e,new n(t),0,1),n.precision)};$t.equals=$t.eq=function(t){return!this.cmp(t)};$t.exponent=function(){return Vi(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,a=i+5;if(t===void 0)t=new r(10);else if(t=new r(t),t.s<1||t.eq(lo))throw Error(dl+"NaN");if(n.s<1)throw Error(dl+(n.s?"NaN":"-Infinity"));return n.eq(lo)?new r(0):(ni=!1,e=Eu(oy(n,a),oy(t,a),a),ni=!0,Or(e,i))};$t.minus=$t.sub=function(t){var e=this;return t=new e.constructor(t),e.s==t.s?yY(e,t):xY(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(dl+"NaN");return n.s?(ni=!1,e=Eu(n,t,0,1).times(t),ni=!0,n.minus(e)):Or(new r(n),i)};$t.naturalExponential=$t.exp=function(){return bY(this)};$t.naturalLogarithm=$t.ln=function(){return oy(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?xY(e,t):yY(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(Vf+t);if(e=Vi(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,a,o,l=this,c=l.constructor;if(l.s<1){if(!l.s)return new c(0);throw Error(dl+"NaN")}for(t=Vi(l),ni=!1,i=Math.sqrt(+l),i==0||i==1/0?(e=oc(l.d),(e.length+t)%2==0&&(e+="0"),i=Math.sqrt(e),t=Nx((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(a=r,r=a.plus(Eu(l,a,o+2)).times(.5),oc(a.d).slice(0,o)===(e=oc(r.d)).slice(0,o)){if(e=e.slice(o-3,o+1),i==o&&e=="4999"){if(Or(a,n+1,0),a.times(a).eq(l)){r=a;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,a,o,l,c,u,d=this,f=d.constructor,p=d.d,m=(t=new f(t)).d;if(!d.s||!t.s)return new f(0);for(t.s*=d.s,n=d.e+t.e,c=p.length,u=m.length,c<u&&(a=p,p=m,m=a,o=c,c=u,u=o),a=[],o=c+u,r=o;r--;)a.push(0);for(r=u;--r>=0;){for(e=0,i=c+r;i>r;)l=a[i]+m[r]*p[i-r-1]+e,a[i--]=l%ga|0,e=l/ga|0;a[i]=(a[i]+e)%ga|0}for(;!a[--o];)a.pop();return e?++n:a.shift(),t.d=a,t.e=n,ni?Or(t,f.precision):t};$t.toDecimalPlaces=$t.todp=function(t,e){var n=this,r=n.constructor;return n=new r(n),t===void 0?n:(xc(t,0,Sx),e===void 0?e=r.rounding:xc(e,0,8),Or(n,t+Vi(n)+1,e))};$t.toExponential=function(t,e){var n,r=this,i=r.constructor;return t===void 0?n=hm(r,!0):(xc(t,0,Sx),e===void 0?e=i.rounding:xc(e,0,8),r=Or(new i(r),t+1,e),n=hm(r,!0,t+1)),n};$t.toFixed=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?hm(i):(xc(t,0,Sx),e===void 0?e=a.rounding:xc(e,0,8),r=Or(new a(i),t+Vi(i)+1,e),n=hm(r.abs(),!1,t+Vi(r)+1),i.isneg()&&!i.isZero()?"-"+n:n)};$t.toInteger=$t.toint=function(){var t=this,e=t.constructor;return Or(new e(t),Vi(t)+1,e.rounding)};$t.toNumber=function(){return+this};$t.toPower=$t.pow=function(t){var e,n,r,i,a,o,l=this,c=l.constructor,u=12,d=+(t=new c(t));if(!t.s)return new c(lo);if(l=new c(l),!l.s){if(t.s<1)throw Error(dl+"Infinity");return l}if(l.eq(lo))return l;if(r=c.precision,t.eq(lo))return Or(l,r);if(e=t.e,n=t.d.length-1,o=e>=n,a=l.s,o){if((n=d<0?-d:d)<=gY){for(i=new c(lo),e=Math.ceil(r/Wr+4),ni=!1;n%2&&(i=i.times(l),I6(i.d,e)),n=Nx(n/2),n!==0;)l=l.times(l),I6(l.d,e);return ni=!0,t.s<0?new c(lo).div(i):Or(i,r)}}else if(a<0)throw Error(dl+"NaN");return a=a<0&&t.d[Math.max(e,n)]&1?-1:1,l.s=1,ni=!1,i=t.times(oy(l,r+u)),ni=!0,i=bY(i),i.s=a,i};$t.toPrecision=function(t,e){var n,r,i=this,a=i.constructor;return t===void 0?(n=Vi(i),r=hm(i,n<=a.toExpNeg||n>=a.toExpPos)):(xc(t,1,Sx),e===void 0?e=a.rounding:xc(e,0,8),i=Or(new a(i),t,e),n=Vi(i),r=hm(i,t<=n||n<=a.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):(xc(t,1,Sx),e===void 0?e=r.rounding:xc(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=Vi(t),n=t.constructor;return hm(t,e<=n.toExpNeg||e>=n.toExpPos)};function xY(t,e){var n,r,i,a,o,l,c,u,d=t.constructor,f=d.precision;if(!t.s||!e.s)return e.s||(e=new d(t)),ni?Or(e,f):e;if(c=t.d,u=e.d,o=t.e,i=e.e,c=c.slice(),a=o-i,a){for(a<0?(r=c,a=-a,l=u.length):(r=u,i=o,l=c.length),o=Math.ceil(f/Wr),l=o>l?o+1:l+1,a>l&&(a=l,r.length=1),r.reverse();a--;)r.push(0);r.reverse()}for(l=c.length,a=u.length,l-a<0&&(a=l,r=u,u=c,c=r),n=0;a;)n=(c[--a]=c[a]+u[a]+n)/ga|0,c[a]%=ga;for(n&&(c.unshift(n),++i),l=c.length;c[--l]==0;)c.pop();return e.d=c,e.e=i,ni?Or(e,f):e}function xc(t,e,n){if(t!==~~t||t<e||t>n)throw Error(Vf+t)}function oc(t){var e,n,r,i=t.length-1,a="",o=t[0];if(i>0){for(a+=o,e=1;e<i;e++)r=t[e]+"",n=Wr-r.length,n&&(a+=Ud(n)),a+=r;o=t[e],r=o+"",n=Wr-r.length,n&&(a+=Ud(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return a+o}var Eu=(function(){function t(r,i){var a,o=0,l=r.length;for(r=r.slice();l--;)a=r[l]*i+o,r[l]=a%ga|0,o=a/ga|0;return o&&r.unshift(o),r}function e(r,i,a,o){var l,c;if(a!=o)c=a>o?1:-1;else for(l=c=0;l<a;l++)if(r[l]!=i[l]){c=r[l]>i[l]?1:-1;break}return c}function n(r,i,a){for(var o=0;a--;)r[a]-=o,o=r[a]<i[a]?1:0,r[a]=o*ga+r[a]-i[a];for(;!r[0]&&r.length>1;)r.shift()}return function(r,i,a,o){var l,c,u,d,f,p,m,x,b,v,y,S,k,T,M,C,E,R,A=r.constructor,D=r.s==i.s?1:-1,I=r.d,F=i.d;if(!r.s)return new A(r);if(!i.s)throw Error(dl+"Division by zero");for(c=r.e-i.e,E=F.length,M=I.length,m=new A(D),x=m.d=[],u=0;F[u]==(I[u]||0);)++u;if(F[u]>(I[u]||0)&&--c,a==null?S=a=A.precision:o?S=a+(Vi(r)-Vi(i))+1:S=a,S<0)return new A(0);if(S=S/Wr+2|0,u=0,E==1)for(d=0,F=F[0],S++;(u<M||d)&&S--;u++)k=d*ga+(I[u]||0),x[u]=k/F|0,d=k%F|0;else{for(d=ga/(F[0]+1)|0,d>1&&(F=t(F,d),I=t(I,d),E=F.length,M=I.length),T=E,b=I.slice(0,E),v=b.length;v<E;)b[v++]=0;R=F.slice(),R.unshift(0),C=F[0],F[1]>=ga/2&&++C;do d=0,l=e(F,b,E,v),l<0?(y=b[0],E!=v&&(y=y*ga+(b[1]||0)),d=y/C|0,d>1?(d>=ga&&(d=ga-1),f=t(F,d),p=f.length,v=b.length,l=e(f,b,p,v),l==1&&(d--,n(f,E<p?R:F,p))):(d==0&&(l=d=1),f=F.slice()),p=f.length,p<v&&f.unshift(0),n(b,f,v),l==-1&&(v=b.length,l=e(F,b,E,v),l<1&&(d++,n(b,E<v?R:F,v))),v=b.length):l===0&&(d++,b=[0]),x[u++]=d,l&&b[0]?b[v++]=I[T]||0:(b=[I[T]],v=1);while((T++<M||b[0]!==void 0)&&S--)}return x[0]||x.shift(),m.e=c,Or(m,o?a+Vi(m)+1:a)}})();function bY(t,e){var n,r,i,a,o,l,c=0,u=0,d=t.constructor,f=d.precision;if(Vi(t)>16)throw Error(LO+Vi(t));if(!t.s)return new d(lo);for(ni=!1,l=f,o=new d(.03125);t.abs().gte(.1);)t=t.times(o),u+=5;for(r=Math.log(_f(2,u))/Math.LN10*2+5|0,l+=r,n=i=a=new d(lo),d.precision=l;;){if(i=Or(i.times(t),l),n=n.times(++c),o=a.plus(Eu(i,n,l)),oc(o.d).slice(0,l)===oc(a.d).slice(0,l)){for(;u--;)a=Or(a.times(a),l);return d.precision=f,e==null?(ni=!0,Or(a,f)):a}a=o}}function Vi(t){for(var e=t.e*Wr,n=t.d[0];n>=10;n/=10)e++;return e}function wA(t,e,n){if(e>t.LN10.sd())throw ni=!0,n&&(t.precision=n),Error(dl+"LN10 precision limit exceeded");return Or(new t(t.LN10),e)}function Ud(t){for(var e="";t--;)e+="0";return e}function oy(t,e){var n,r,i,a,o,l,c,u,d,f=1,p=10,m=t,x=m.d,b=m.constructor,v=b.precision;if(m.s<1)throw Error(dl+(m.s?"NaN":"-Infinity"));if(m.eq(lo))return new b(0);if(e==null?(ni=!1,u=v):u=e,m.eq(10))return e==null&&(ni=!0),wA(b,u);if(u+=p,b.precision=u,n=oc(x),r=n.charAt(0),a=Vi(m),Math.abs(a)<15e14){for(;r<7&&r!=1||r==1&&n.charAt(1)>3;)m=m.times(t),n=oc(m.d),r=n.charAt(0),f++;a=Vi(m),r>1?(m=new b("0."+n),a++):m=new b(r+"."+n.slice(1))}else return c=wA(b,u+2,v).times(a+""),m=oy(new b(r+"."+n.slice(1)),u-p).plus(c),b.precision=v,e==null?(ni=!0,Or(m,v)):m;for(l=o=m=Eu(m.minus(lo),m.plus(lo),u),d=Or(m.times(m),u),i=3;;){if(o=Or(o.times(d),u),c=l.plus(Eu(o,new b(i),u)),oc(c.d).slice(0,u)===oc(l.d).slice(0,u))return l=l.times(2),a!==0&&(l=l.plus(wA(b,u+2,v).times(a+""))),l=Eu(l,new b(f),u),b.precision=v,e==null?(ni=!0,Or(l,v)):l;l=c,i+=2}}function F6(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=Nx(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>AS||t.e<-AS))throw Error(LO+n)}else t.s=0,t.e=0,t.d=[0];return t}function Or(t,e,n){var r,i,a,o,l,c,u,d,f=t.d;for(o=1,a=f[0];a>=10;a/=10)o++;if(r=e-o,r<0)r+=Wr,i=e,u=f[d=0];else{if(d=Math.ceil((r+1)/Wr),a=f.length,d>=a)return t;for(u=a=f[d],o=1;a>=10;a/=10)o++;r%=Wr,i=r-Wr+o}if(n!==void 0&&(a=_f(10,o-i-1),l=u/a%10|0,c=e<0||f[d+1]!==void 0||u%a,c=n<4?(l||c)&&(n==0||n==(t.s<0?3:2)):l>5||l==5&&(n==4||c||n==6&&(r>0?i>0?u/_f(10,o-i):0:f[d-1])%10&1||n==(t.s<0?8:7))),e<1||!f[0])return c?(a=Vi(t),f.length=1,e=e-a-1,f[0]=_f(10,(Wr-e%Wr)%Wr),t.e=Nx(-e/Wr)||0):(f.length=1,f[0]=t.e=t.s=0),t;if(r==0?(f.length=d,a=1,d--):(f.length=d+1,a=_f(10,Wr-r),f[d]=i>0?(u/_f(10,o-i)%_f(10,i)|0)*a:0),c)for(;;)if(d==0){(f[0]+=a)==ga&&(f[0]=1,++t.e);break}else{if(f[d]+=a,f[d]!=ga)break;f[d--]=0,a=1}for(r=f.length;f[--r]===0;)f.pop();if(ni&&(t.e>AS||t.e<-AS))throw Error(LO+Vi(t));return t}function yY(t,e){var n,r,i,a,o,l,c,u,d,f,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,f=e.d,r=e.e,u=t.e,c=c.slice(),o=u-r,o){for(d=o<0,d?(n=c,o=-o,l=f.length):(n=f,r=u,l=c.length),i=Math.max(Math.ceil(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=f.length,d=i<l,d&&(l=i),i=0;i<l;i++)if(c[i]!=f[i]){d=c[i]<f[i];break}o=0}for(d&&(n=c,c=f,f=n,e.s=-e.s),l=c.length,i=f.length-l;i>0;--i)c[l++]=0;for(i=f.length;i>o;){if(c[--i]<f[i]){for(a=i;a&&c[--a]===0;)c[a]=ga-1;--c[a],c[i]+=ga}c[i]-=f[i]}for(;c[--l]===0;)c.pop();for(;c[0]===0;c.shift())--r;return c[0]?(e.d=c,e.e=r,ni?Or(e,m):e):new p(0)}function hm(t,e,n){var r,i=Vi(t),a=oc(t.d),o=a.length;return e?(n&&(r=n-o)>0?a=a.charAt(0)+"."+a.slice(1)+Ud(r):o>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(i<0?"e":"e+")+i):i<0?(a="0."+Ud(-i-1)+a,n&&(r=n-o)>0&&(a+=Ud(r))):i>=o?(a+=Ud(i+1-o),n&&(r=n-i-1)>0&&(a=a+"."+Ud(r))):((r=i+1)<o&&(a=a.slice(0,r)+"."+a.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(a+="."),a+=Ud(r))),t.s<0?"-"+a:a}function I6(t,e){if(t.length>e)return t.length=e,!0}function vY(t){var e,n,r;function i(a){var o=this;if(!(o instanceof i))return new i(a);if(o.constructor=i,a instanceof i){o.s=a.s,o.e=a.e,o.d=(a=a.d)?a.slice():a;return}if(typeof a=="number"){if(a*0!==0)throw Error(Vf+a);if(a>0)o.s=1;else if(a<0)a=-a,o.s=-1;else{o.s=0,o.e=0,o.d=[0];return}if(a===~~a&&a<1e7){o.e=0,o.d=[a];return}return F6(o,a.toString())}else if(typeof a!="string")throw Error(Vf+a);if(a.charCodeAt(0)===45?(a=a.slice(1),o.s=-1):o.s=1,jwe.test(a))F6(o,a);else throw Error(Vf+a)}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=vY,i.config=i.set=Dwe,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 Dwe(t){if(!t||typeof t!="object")throw Error(dl+"Object expected");var e,n,r,i=["precision",1,Sx,"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(Nx(r)===r&&r>=i[e+1]&&r<=i[e+2])this[n]=r;else throw Error(Vf+n+": "+r);if((r=t[n="LN10"])!==void 0)if(r==Math.LN10)this[n]=new this(r);else throw Error(Vf+n+": "+r);return this}var FO=vY(Pwe);lo=new FO(1);const br=FO;var Rwe=t=>t,wY={},_Y=t=>t===wY,U6=t=>function e(){return arguments.length===0||arguments.length===1&&_Y(arguments.length<=0?void 0:arguments[0])?e:t(...arguments)},SY=(t,e)=>t===1?e:U6(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];var a=r.filter(o=>o!==wY).length;return a>=t?e(...r):SY(t-a,U6(function(){for(var o=arguments.length,l=new Array(o),c=0;c<o;c++)l[c]=arguments[c];var u=r.map(d=>_Y(d)?l.shift():d);return e(...u,...l)}))}),Owe=t=>SY(t.length,t),s3=(t,e)=>{for(var n=[],r=t;r<e;++r)n[r-t]=r;return n},Lwe=Owe((t,e)=>Array.isArray(e)?e.map(t):Object.keys(e).map(n=>e[n]).map(t)),Fwe=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];if(!n.length)return Rwe;var i=n.reverse(),a=i[0],o=i.slice(1);return function(){return o.reduce((l,c)=>c(l),a(...arguments))}},o3=t=>Array.isArray(t)?t.reverse():t.split("").reverse().join("");function NY(t){var e;return t===0?e=1:e=Math.floor(new br(t).abs().log(10).toNumber())+1,e}function MY(t,e,n){for(var r=new br(t),i=0,a=[];r.lt(e)&&i<1e5;)a.push(r.toNumber()),r=r.add(n),i++;return a}var kY=t=>{var[e,n]=t,[r,i]=[e,n];return e>n&&([r,i]=[n,e]),[r,i]},EY=(t,e,n)=>{if(t.lte(0))return new br(0);var r=NY(t.toNumber()),i=new br(10).pow(r),a=t.div(i),o=r!==1?.05:.1,l=new br(Math.ceil(a.div(o).toNumber())).add(n).mul(o),c=l.mul(i);return e?new br(c.toNumber()):new br(Math.ceil(c.toNumber()))},Iwe=(t,e,n)=>{var r=new br(1),i=new br(t);if(!i.isint()&&n){var a=Math.abs(t);a<1?(r=new br(10).pow(NY(t)-1),i=new br(Math.floor(i.div(r).toNumber())).mul(r)):a>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=Fwe(Lwe(c=>i.add(new br(c-o).mul(r)).toNumber()),s3);return l(0,e)},TY=function(e,n,r,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0;if(!Number.isFinite((n-e)/(r-1)))return{step:new br(0),tickMin:new br(0),tickMax:new br(0)};var o=EY(new br(n).sub(e).div(r-1),i,a),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?TY(e,n,r,i,a+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))})},Uwe=function(e){var[n,r]=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:6,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,o=Math.max(i,2),[l,c]=kY([n,r]);if(l===-1/0||c===1/0){var u=c===1/0?[l,...s3(0,i-1).map(()=>1/0)]:[...s3(0,i-1).map(()=>-1/0),c];return n>r?o3(u):u}if(l===c)return Iwe(l,i,a);var{step:d,tickMin:f,tickMax:p}=TY(l,c,o,a,0),m=MY(f,p.add(new br(.1).mul(d)),d);return n>r?o3(m):m},zwe=function(e,n){var[r,i]=e,a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,[o,l]=kY([r,i]);if(o===-1/0||l===1/0)return[r,i];if(o===l)return[o];var c=Math.max(n,2),u=EY(new br(l).sub(o).div(c-1),a,0),d=[...MY(new br(o),new br(l),u),l];return a===!1&&(d=d.map(f=>Math.round(f))),r>i?o3(d):d},AY=t=>t.rootProps.maxBarSize,Bwe=t=>t.rootProps.barGap,CY=t=>t.rootProps.barCategoryGap,Hwe=t=>t.rootProps.barSize,Jy=t=>t.rootProps.stackOffset,PY=t=>t.rootProps.reverseStackOrder,IO=t=>t.options.chartName,UO=t=>t.rootProps.syncId,jY=t=>t.rootProps.syncMethod,zO=t=>t.options.eventEmitter,$we=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},fu={allowDuplicatedCategory:!0,angleAxisId:0,reversed:!1,scale:"auto",tick:!0,type:"category"},ao={allowDataOverflow:!1,allowDuplicatedCategory:!0,radiusAxisId:0,scale:"auto",tick:!0,tickCount:5,type:"number"},qM=(t,e)=>{if(!(!t||!e))return t!=null&&t.reversed?[e[1],e[0]]:e},Vwe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:!1,dataKey:void 0,domain:void 0,id:fu.angleAxisId,includeHidden:!1,name:void 0,reversed:fu.reversed,scale:fu.scale,tick:fu.tick,tickCount:void 0,ticks:void 0,type:fu.type,unit:void 0},Gwe={allowDataOverflow:ao.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:ao.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ao.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ao.scale,tick:ao.tick,tickCount:ao.tickCount,ticks:void 0,type:ao.type,unit:void 0},qwe={allowDataOverflow:!1,allowDecimals:!1,allowDuplicatedCategory:fu.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:fu.angleAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:fu.scale,tick:fu.tick,tickCount:void 0,ticks:void 0,type:"number",unit:void 0},Wwe={allowDataOverflow:ao.allowDataOverflow,allowDecimals:!1,allowDuplicatedCategory:ao.allowDuplicatedCategory,dataKey:void 0,domain:void 0,id:ao.radiusAxisId,includeHidden:!1,name:void 0,reversed:!1,scale:ao.scale,tick:ao.tick,tickCount:ao.tickCount,ticks:void 0,type:"category",unit:void 0},BO=(t,e)=>t.polarAxis.angleAxis[e]!=null?t.polarAxis.angleAxis[e]:t.layout.layoutType==="radial"?qwe:Vwe,HO=(t,e)=>t.polarAxis.radiusAxis[e]!=null?t.polarAxis.radiusAxis[e]:t.layout.layoutType==="radial"?Wwe:Gwe,WM=t=>t.polarOptions,$O=it([qu,Wu,ra],CX),DY=it([WM,$O],(t,e)=>{if(t!=null)return es(t.innerRadius,e,0)}),RY=it([WM,$O],(t,e)=>{if(t!=null)return es(t.outerRadius,e,e*.8)}),Kwe=t=>{if(t==null)return[0,0];var{startAngle:e,endAngle:n}=t;return[e,n]},OY=it([WM],Kwe);it([BO,OY],qM);var LY=it([$O,DY,RY],(t,e,n)=>{if(!(t==null||e==null||n==null))return[e,n]});it([HO,LY],qM);var FY=it([$n,WM,DY,RY,qu,Wu],(t,e,n,r,i,a)=>{if(!(t!=="centric"&&t!=="radial"||e==null||n==null||r==null)){var{cx:o,cy:l,startAngle:c,endAngle:u}=e;return{cx:es(o,i,i/2),cy:es(l,a,a/2),innerRadius:n,outerRadius:r,startAngle:c,endAngle:u,clockWise:!1}}}),ii=(t,e)=>e,ev=(t,e,n)=>n;function KM(t){return t?.id}function IY(t,e,n){var{chartData:r=[]}=e,{allowDuplicatedCategory:i,dataKey:a}=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=KM(l);u.forEach((f,p)=>{var m=a==null||i?p:String(yr(f,a,null)),x=yr(f,l.dataKey,0),b;o.has(m)?b=o.get(m):b={},Object.assign(b,{[d]:x}),o.set(m,b)})}}),Array.from(o.values())}function XM(t){return t.stackId!=null&&t.dataKey!=null}var YM=(t,e)=>t===e?!0:t==null||e==null?!1:t[0]===e[0]&&t[1]===e[1];function QM(t,e){return Array.isArray(t)&&Array.isArray(e)&&t.length===0&&e.length===0?!0:t===e}function Xwe(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 sa=t=>{var e=$n(t);return e==="horizontal"?"xAxis":e==="vertical"?"yAxis":e==="centric"?"angleAxis":"radiusAxis"},Mx=t=>t.tooltip.settings.axisId;function z6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function CS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?z6(Object(n),!0).forEach(function(r){Ywe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):z6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ywe(t,e,n){return(e=Qwe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Qwe(t){var e=Zwe(t,"string");return typeof e=="symbol"?e:e+""}function Zwe(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 l3=[0,"auto"],ma={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},UY=(t,e)=>t.cartesianAxis.xAxis[e],Tc=(t,e)=>{var n=UY(t,e);return n??ma},pa={allowDataOverflow:!1,allowDecimals:!0,allowDuplicatedCategory:!0,angle:0,dataKey:void 0,domain:l3,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:Gy},zY=(t,e)=>t.cartesianAxis.yAxis[e],Ac=(t,e)=>{var n=zY(t,e);return n??pa},Jwe={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:""},VO=(t,e)=>{var n=t.cartesianAxis.zAxis[e];return n??Jwe},ui=(t,e,n)=>{switch(e){case"xAxis":return Tc(t,n);case"yAxis":return Ac(t,n);case"zAxis":return VO(t,n);case"angleAxis":return BO(t,n);case"radiusAxis":return HO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},e_e=(t,e,n)=>{switch(e){case"xAxis":return Tc(t,n);case"yAxis":return Ac(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},tv=(t,e,n)=>{switch(e){case"xAxis":return Tc(t,n);case"yAxis":return Ac(t,n);case"angleAxis":return BO(t,n);case"radiusAxis":return HO(t,n);default:throw new Error("Unexpected axis type: ".concat(e))}},BY=t=>t.graphicalItems.cartesianItems.some(e=>e.type==="bar")||t.graphicalItems.polarItems.some(e=>e.type==="radialBar");function GO(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 nv=t=>t.graphicalItems.cartesianItems,t_e=it([ii,ev],GO),qO=(t,e,n)=>t.filter(n).filter(r=>e?.includeHidden===!0?!0:!r.hide),rv=it([nv,ui,t_e],qO,{memoizeOptions:{resultEqualityCheck:QM}}),HY=it([rv],t=>t.filter(e=>e.type==="area"||e.type==="bar").filter(XM)),$Y=t=>t.filter(e=>!("stackId"in e)||e.stackId===void 0),n_e=it([rv],$Y),WO=t=>t.map(e=>e.data).filter(Boolean).flat(1),r_e=it([rv],WO,{memoizeOptions:{resultEqualityCheck:QM}}),KO=(t,e)=>{var{chartData:n=[],dataStartIndex:r,dataEndIndex:i}=e;return t.length>0?t:n.slice(r,i+1)},XO=it([r_e,Zy],KO),YO=(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})),ZM=it([XO,ui,rv],YO);function VY(t,e){switch(t){case"xAxis":return e.direction==="x";case"yAxis":return e.direction==="y";default:return!1}}function _1(t){if(cl(t)||t instanceof Date){var e=Number(t);if(vr(e))return e}}function B6(t){if(Array.isArray(t)){var e=[_1(t[0]),_1(t[1])];return _h(e)?e:void 0}var n=_1(t);if(n!=null)return[n,n]}function Bu(t){return t.map(_1).filter(epe)}function i_e(t,e,n){return!n||typeof e!="number"||Hs(e)?[]:n.length?Bu(n.flatMap(r=>{var i=yr(t,r.dataKey),a,o;if(Array.isArray(i)?[a,o]=i:a=o=i,!(!vr(a)||!vr(o)))return[e-a,e+o]})):[]}var oa=t=>{var e=sa(t),n=Mx(t);return tv(t,e,n)},iv=it([oa],t=>t?.dataKey),a_e=it([HY,Zy,oa],IY),GY=(t,e,n,r)=>{var i={},a=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(a).map(o=>{var[l,c]=o,u=r?[...c].reverse():c,d=u.map(KM);return[l,{stackedData:Nxe(t,d,n),graphicalItems:u}]}))},ly=it([a_e,HY,Jy,PY],GY),qY=(t,e,n,r)=>{var{dataStartIndex:i,dataEndIndex:a}=e;if(r==null&&n!=="zAxis"){var o=Txe(t,i,a);if(!(o!=null&&o[0]===0&&o[1]===0))return o}},s_e=it([ui],t=>t.allowDataOverflow),QO=t=>{var e;if(t==null||!("domain"in t))return l3;if(t.domain!=null)return t.domain;if(t.ticks!=null){if(t.type==="number"){var n=Bu(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:l3},ZO=it([ui],QO),JO=it([ZO,s_e],pY),o_e=it([ly,Uh,ii,JO],qY,{memoizeOptions:{resultEqualityCheck:YM}}),JM=t=>t.errorBars,l_e=(t,e,n)=>t.flatMap(r=>e[r.id]).filter(Boolean).filter(r=>VY(n,r)),PS=function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];var i=n.filter(Boolean);if(i.length!==0){var a=i.flat(),o=Math.min(...a),l=Math.max(...a);return[o,l]}},e4=(t,e,n,r,i)=>{var a,o;if(n.length>0&&t.forEach(l=>{n.forEach(c=>{var u,d,f=(u=r[c.id])===null||u===void 0?void 0:u.filter(y=>VY(i,y)),p=yr(l,(d=e.dataKey)!==null&&d!==void 0?d:c.dataKey),m=i_e(l,p,f);if(m.length>=2){var x=Math.min(...m),b=Math.max(...m);(a==null||x<a)&&(a=x),(o==null||b>o)&&(o=b)}var v=B6(p);v!=null&&(a=a==null?v[0]:Math.min(a,v[0]),o=o==null?v[1]:Math.max(o,v[1]))})}),e?.dataKey!=null&&t.forEach(l=>{var c=B6(yr(l,e.dataKey));c!=null&&(a=a==null?c[0]:Math.min(a,c[0]),o=o==null?c[1]:Math.max(o,c[1]))}),vr(a)&&vr(o))return[a,o]},c_e=it([XO,ui,n_e,JM,ii],e4,{memoizeOptions:{resultEqualityCheck:YM}});function u_e(t){var{value:e}=t;if(cl(e)||e instanceof Date)return e}var d_e=(t,e,n)=>{var r=t.map(u_e).filter(i=>i!=null);return n&&(e.dataKey==null||e.allowDuplicatedCategory&&oK(r))?RX(0,t.length):e.allowDuplicatedCategory?r:Array.from(new Set(r))},WY=t=>t.referenceElements.dots,kx=(t,e,n)=>t.filter(r=>r.ifOverflow==="extendDomain").filter(r=>e==="xAxis"?r.xAxisId===n:r.yAxisId===n),h_e=it([WY,ii,ev],kx),KY=t=>t.referenceElements.areas,f_e=it([KY,ii,ev],kx),XY=t=>t.referenceElements.lines,m_e=it([XY,ii,ev],kx),YY=(t,e)=>{var n=Bu(t.map(r=>e==="xAxis"?r.x:r.y));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},p_e=it(h_e,ii,YY),QY=(t,e)=>{var n=Bu(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)]},g_e=it([f_e,ii],QY);function x_e(t){var e;if(t.x!=null)return Bu([t.x]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.x);return n==null||n.length===0?[]:Bu(n)}function b_e(t){var e;if(t.y!=null)return Bu([t.y]);var n=(e=t.segment)===null||e===void 0?void 0:e.map(r=>r.y);return n==null||n.length===0?[]:Bu(n)}var ZY=(t,e)=>{var n=t.flatMap(r=>e==="xAxis"?x_e(r):b_e(r));if(n.length!==0)return[Math.min(...n),Math.max(...n)]},y_e=it([m_e,ii],ZY),v_e=it(p_e,y_e,g_e,(t,e,n)=>PS(t,n,e)),t4=(t,e,n,r,i,a,o,l)=>{if(n!=null)return n;var c=o==="vertical"&&l==="xAxis"||o==="horizontal"&&l==="yAxis",u=c?PS(r,a,i):PS(a,i);return Cwe(e,u,t.allowDataOverflow)},w_e=it([ui,ZO,JO,o_e,c_e,v_e,$n,ii],t4,{memoizeOptions:{resultEqualityCheck:YM}}),__e=[0,1],n4=(t,e,n,r,i,a,o)=>{if(!((t==null||n==null||n.length===0)&&o===void 0)){var{dataKey:l,type:c}=t,u=Ec(e,a);if(u&&l==null){var d;return RX(0,(d=n?.length)!==null&&d!==void 0?d:0)}return c==="category"?d_e(r,t,u):i==="expand"?__e:o}},r4=it([ui,$n,XO,ZM,Jy,ii,w_e],n4),JY=(t,e,n,r,i)=>{if(t!=null){var{scale:a,type:o}=t;if(a==="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 a=="string"){var l="scale".concat(Uy(a));return l in a0?l:"point"}}},Ex=it([ui,$n,BY,IO,ii],JY);function S_e(t){if(t!=null){if(t in a0)return a0[t]();var e="scale".concat(Uy(t));if(e in a0)return a0[e]()}}function i4(t,e,n,r){if(!(n==null||r==null)){if(typeof t.scale=="function")return t.scale.copy().domain(n).range(r);var i=S_e(e);if(i!=null){var a=i.domain(n).range(r);return yxe(a),a}}}var a4=(t,e,n)=>{var r=QO(e);if(!(n!=="auto"&&n!=="linear")){if(e!=null&&e.tickCount&&Array.isArray(r)&&(r[0]==="auto"||r[1]==="auto")&&_h(t))return Uwe(t,e.tickCount,e.allowDecimals);if(e!=null&&e.tickCount&&e.type==="number"&&_h(t))return zwe(t,e.tickCount,e.allowDecimals)}},s4=it([r4,tv,Ex],a4),o4=(t,e,n,r)=>{if(r!=="angleAxis"&&t?.type==="number"&&_h(e)&&Array.isArray(n)&&n.length>0){var i=e[0],a=n[0],o=e[1],l=n[n.length-1];return[Math.min(i,a),Math.max(o,l)]}return e},N_e=it([ui,r4,s4,ii],o4),M_e=it(ZM,ui,(t,e)=>{if(!(!e||e.type!=="number")){var n=1/0,r=Array.from(Bu(t.map(l=>l.value))).sort((l,c)=>l-c);if(r.length<2)return 1/0;var i=r[r.length-1]-r[0];if(i===0)return 1/0;for(var a=0;a<r.length-1;a++){var o=r[a+1]-r[a];n=Math.min(n,o)}return n/i}}),eQ=it(M_e,$n,CY,ra,(t,e,n,r)=>r,(t,e,n,r,i)=>{if(!vr(t))return 0;var a=e==="vertical"?r.height:r.width;if(i==="gap")return t*a/2;if(i==="no-gap"){var o=es(n,t*a),l=t*a/2;return l-o-(l-o)/a*o}return 0}),k_e=(t,e)=>{var n=Tc(t,e);return n==null||typeof n.padding!="string"?0:eQ(t,"xAxis",e,n.padding)},E_e=(t,e)=>{var n=Ac(t,e);return n==null||typeof n.padding!="string"?0:eQ(t,"yAxis",e,n.padding)},T_e=it(Tc,k_e,(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}}),A_e=it(Ac,E_e,(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}}),C_e=it([ra,T_e,OM,RM,(t,e,n)=>n],(t,e,n,r,i)=>{var{padding:a}=r;return i?[a.left,n.width-a.right]:[t.left+e.left,t.left+t.width-e.right]}),P_e=it([ra,$n,A_e,OM,RM,(t,e,n)=>n],(t,e,n,r,i,a)=>{var{padding:o}=i;return a?[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]}),av=(t,e,n,r)=>{var i;switch(e){case"xAxis":return C_e(t,n,r);case"yAxis":return P_e(t,n,r);case"zAxis":return(i=VO(t,n))===null||i===void 0?void 0:i.range;case"angleAxis":return OY(t);case"radiusAxis":return LY(t,n);default:return}},tQ=it([ui,av],qM),Sh=it([ui,Ex,N_e,tQ],i4);it([rv,JM,ii],l_e);function nQ(t,e){return t.id<e.id?-1:t.id>e.id?1:0}var e2=(t,e)=>e,t2=(t,e,n)=>n,j_e=it(jM,e2,t2,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(nQ)),D_e=it(DM,e2,t2,(t,e,n)=>t.filter(r=>r.orientation===e).filter(r=>r.mirror===n).sort(nQ)),rQ=(t,e)=>({width:t.width,height:e.height}),R_e=(t,e)=>{var n=typeof e.width=="number"?e.width:Gy;return{width:n,height:t.height}},iQ=it(ra,Tc,rQ),O_e=(t,e,n)=>{switch(e){case"top":return t.top;case"bottom":return n-t.bottom;default:return 0}},L_e=(t,e,n)=>{switch(e){case"left":return t.left;case"right":return n-t.right;default:return 0}},F_e=it(Wu,ra,j_e,e2,t2,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=rQ(e,l);o==null&&(o=O_e(e,r,t));var u=r==="top"&&!i||r==="bottom"&&i;a[l.id]=o-Number(u)*c.height,o+=(u?-1:1)*c.height}),a}),I_e=it(qu,ra,D_e,e2,t2,(t,e,n,r,i)=>{var a={},o;return n.forEach(l=>{var c=R_e(e,l);o==null&&(o=L_e(e,r,t));var u=r==="left"&&!i||r==="right"&&i;a[l.id]=o-Number(u)*c.width,o+=(u?-1:1)*c.width}),a}),U_e=(t,e)=>{var n=Tc(t,e);if(n!=null)return F_e(t,n.orientation,n.mirror)},z_e=it([ra,Tc,U_e,(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}}}),B_e=(t,e)=>{var n=Ac(t,e);if(n!=null)return I_e(t,n.orientation,n.mirror)},H_e=it([ra,Ac,B_e,(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}}}),aQ=it(ra,Ac,(t,e)=>{var n=typeof e.width=="number"?e.width:Gy;return{width:n,height:t.height}}),H6=(t,e,n)=>{switch(e){case"xAxis":return iQ(t,n).width;case"yAxis":return aQ(t,n).height;default:return}},sQ=(t,e,n,r)=>{if(n!=null){var{allowDuplicatedCategory:i,type:a,dataKey:o}=n,l=Ec(t,r),c=e.map(u=>u.value);if(o&&l&&a==="category"&&i&&oK(c))return c}},l4=it([$n,ZM,ui,ii],sQ),oQ=(t,e,n,r)=>{if(!(n==null||n.dataKey==null)){var{type:i,scale:a}=n,o=Ec(t,r);if(o&&(i==="number"||a!=="auto"))return e.map(l=>l.value)}},c4=it([$n,ZM,tv,ii],oQ),$6=it([$n,e_e,Ex,Sh,l4,c4,av,s4,ii],(t,e,n,r,i,a,o,l,c)=>{if(e!=null){var u=Ec(t,c);return{angle:e.angle,interval:e.interval,minTickGap:e.minTickGap,orientation:e.orientation,tick:e.tick,tickCount:e.tickCount,tickFormatter:e.tickFormatter,ticks:e.ticks,type:e.type,unit:e.unit,axisType:c,categoricalDomain:a,duplicateDomain:i,isCategorical:u,niceTicks:l,range:o,realScaleType:n,scale:r}}}),$_e=(t,e,n,r,i,a,o,l,c)=>{if(!(e==null||r==null)){var u=Ec(t,c),{type:d,ticks:f,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"&&a!=null&&a.length>=2?va(a[0]-a[1])*2*x:x;var b=f||i;if(b){var v=b.map((y,S)=>{var k=o?o.indexOf(y):y;return{index:S,coordinate:r(k)+x,value:y,offset:x}});return v.filter(y=>vr(y.coordinate))}return u&&l?l.map((y,S)=>({coordinate:r(y)+x,value:y,index:S,offset:x})).filter(y=>vr(y.coordinate)):r.ticks?r.ticks(p).map(y=>({coordinate:r(y)+x,value:y,offset:x})):r.domain().map((y,S)=>({coordinate:r(y)+x,value:o?o[y]:y,index:S,offset:x}))}},lQ=it([$n,tv,Ex,Sh,s4,av,l4,c4,ii],$_e),V_e=(t,e,n,r,i,a,o)=>{if(!(e==null||n==null||r==null||r[0]===r[1])){var l=Ec(t,o),{tickCount:c}=e,u=0;return u=o==="angleAxis"&&r?.length>=2?va(r[0]-r[1])*2*u:u,l&&a?a.map((d,f)=>({coordinate:n(d)+u,value:d,index:f,offset:u})):n.ticks?n.ticks(c).map(d=>({coordinate:n(d)+u,value:d,offset:u})):n.domain().map((d,f)=>({coordinate:n(d)+u,value:i?i[d]:d,index:f,offset:u}))}},bc=it([$n,tv,Sh,av,l4,c4,ii],V_e),yc=it(ui,Sh,(t,e)=>{if(!(t==null||e==null))return CS(CS({},t),{},{scale:e})}),G_e=it([ui,Ex,r4,tQ],i4);it((t,e,n)=>VO(t,n),G_e,(t,e)=>{if(!(t==null||e==null))return CS(CS({},t),{},{scale:e})});var q_e=it([$n,jM,DM],(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}}),cQ=t=>t.options.defaultTooltipEventType,uQ=t=>t.options.validateTooltipEventTypes;function dQ(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=cQ(t),r=uQ(t);return dQ(e,n,r)}function W_e(t){return It(e=>u4(e,t))}var hQ=(t,e)=>{var n,r=Number(e);if(!(Hs(r)||e==null))return r>=0?t==null||(n=t[r])===null||n===void 0?void 0:n.value:void 0},K_e=t=>t.tooltip.settings,Wd={active:!1,index:null,dataKey:void 0,graphicalItemId:void 0,coordinate:void 0},X_e={itemInteraction:{click:Wd,hover:Wd},axisInteraction:{click:Wd,hover:Wd},keyboardInteraction:Wd,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}},fQ=$s({name:"tooltip",initialState:X_e,reducers:{addTooltipEntrySettings:{reducer(t,e){t.tooltipItemPayloads.push(e.payload)},prepare:Jr()},replaceTooltipEntrySettings:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ol(t).tooltipItemPayloads.indexOf(n);i>-1&&(t.tooltipItemPayloads[i]=r)},prepare:Jr()},removeTooltipEntrySettings:{reducer(t,e){var n=Ol(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:Y_e,replaceTooltipEntrySettings:Q_e,removeTooltipEntrySettings:Z_e,setTooltipSettingsState:J_e,setActiveMouseOverItemIndex:mQ,mouseLeaveItem:e1e,mouseLeaveChart:pQ,setActiveClickItemIndex:t1e,setMouseOverAxisIndex:gQ,setMouseClickAxisIndex:n1e,setSyncInteraction:c3,setKeyboardInteraction:u3}=fQ.actions,r1e=fQ.reducer;function V6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Kw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?V6(Object(n),!0).forEach(function(r){i1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):V6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function i1e(t,e,n){return(e=a1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a1e(t){var e=s1e(t,"string");return typeof e=="symbol"?e:e+""}function s1e(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 o1e(t,e,n){return e==="axis"?n==="click"?t.axisInteraction.click:t.axisInteraction.hover:n==="click"?t.itemInteraction.click:t.itemInteraction.hover}function l1e(t){return t.index!=null}var xQ=(t,e,n,r)=>{if(e==null)return Wd;var i=o1e(t,e,n);if(i==null)return Wd;if(i.active)return i;if(t.keyboardInteraction.active)return t.keyboardInteraction;if(t.syncInteraction.active&&t.syncInteraction.index!=null)return t.syncInteraction;var a=t.settings.active===!0;if(l1e(i)){if(a)return Kw(Kw({},i),{},{active:!0})}else if(r!=null)return{active:!0,coordinate:void 0,dataKey:void 0,index:r,graphicalItemId:void 0};return Kw(Kw({},Wd),{},{coordinate:i.coordinate})};function c1e(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 u1e(t,e){var n=c1e(t),r=e[0],i=e[1];if(n===void 0)return!1;var a=Math.min(r,i),o=Math.max(r,i);return n>=a&&n<=o}function d1e(t,e,n){if(n==null||e==null)return!0;var r=yr(t,e);return r==null||!_h(n)?!0:u1e(r,n)}var d4=(t,e,n,r)=>{var i=t?.index;if(i==null)return null;var a=Number(i);if(!vr(a))return i;var o=0,l=1/0;e.length>0&&(l=e.length-1);var c=Math.max(o,Math.min(a,l)),u=e[c];return u==null||d1e(u,n,r)?String(c):null},bQ=(t,e,n,r,i,a,o,l)=>{if(!(a==null||l==null)){var c=o[0],u=c==null?void 0:l(c.positions,a);if(u!=null)return u;var d=i?.[Number(a)];if(d)switch(n){case"horizontal":return{x:d.coordinate,y:(r.top+e)/2};default:return{x:(r.left+t)/2,y:d.coordinate}}}},yQ=(t,e,n,r)=>{if(e==="axis")return t.tooltipItemPayloads;if(t.tooltipItemPayloads.length===0)return[];var i;return n==="hover"?i=t.itemInteraction.hover.dataKey:i=t.itemInteraction.click.dataKey,i==null&&r!=null?[t.tooltipItemPayloads[0]]:t.tooltipItemPayloads.filter(a=>{var o;return((o=a.settings)===null||o===void 0?void 0:o.dataKey)===i})},sv=t=>t.options.tooltipPayloadSearcher,Tx=t=>t.tooltip;function G6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function q6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?G6(Object(n),!0).forEach(function(r){h1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):G6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function h1e(t,e,n){return(e=f1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function f1e(t){var e=m1e(t,"string");return typeof e=="symbol"?e:e+""}function m1e(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 p1e(t,e){return t??e}var vQ=(t,e,n,r,i,a,o)=>{if(!(e==null||a==null)){var{chartData:l,computedData:c,dataStartIndex:u,dataEndIndex:d}=n,f=[];return t.reduce((p,m)=>{var x,{dataDefinedOnItem:b,settings:v}=m,y=p1e(b,l),S=Array.isArray(y)?nX(y,u,d):y,k=(x=v?.dataKey)!==null&&x!==void 0?x:r,T=v?.nameKey,M;if(r&&Array.isArray(S)&&!Array.isArray(S[0])&&o==="axis"?M=lK(S,r,i):M=a(S,e,c,T),Array.isArray(M))M.forEach(E=>{var R=q6(q6({},v),{},{name:E.name,unit:E.unit,color:void 0,fill:void 0});p.push(h8({tooltipEntrySettings:R,dataKey:E.dataKey,payload:E.payload,value:yr(E.payload,E.dataKey),name:E.name}))});else{var C;p.push(h8({tooltipEntrySettings:v,dataKey:k,payload:M,value:yr(M,k),name:(C=yr(M,T))!==null&&C!==void 0?C:v?.name}))}return p},f)}},h4=it([oa,$n,BY,IO,sa],JY),g1e=it([t=>t.graphicalItems.cartesianItems,t=>t.graphicalItems.polarItems],(t,e)=>[...t,...e]),x1e=it([sa,Mx],GO),ov=it([g1e,oa,x1e],qO,{memoizeOptions:{resultEqualityCheck:QM}}),b1e=it([ov],t=>t.filter(XM)),y1e=it([ov],WO,{memoizeOptions:{resultEqualityCheck:QM}}),Ax=it([y1e,Uh],KO),v1e=it([b1e,Uh,oa],IY),f4=it([Ax,oa,ov],YO),wQ=it([oa],QO),w1e=it([oa],t=>t.allowDataOverflow),_Q=it([wQ,w1e],pY),_1e=it([ov],t=>t.filter(XM)),S1e=it([v1e,_1e,Jy,PY],GY),N1e=it([S1e,Uh,sa,_Q],qY),M1e=it([ov],$Y),k1e=it([Ax,oa,M1e,JM,sa],e4,{memoizeOptions:{resultEqualityCheck:YM}}),E1e=it([WY,sa,Mx],kx),T1e=it([E1e,sa],YY),A1e=it([KY,sa,Mx],kx),C1e=it([A1e,sa],QY),P1e=it([XY,sa,Mx],kx),j1e=it([P1e,sa],ZY),D1e=it([T1e,j1e,C1e],PS),R1e=it([oa,wQ,_Q,N1e,k1e,D1e,$n,sa],t4),lv=it([oa,$n,Ax,f4,Jy,sa,R1e],n4),O1e=it([lv,oa,h4],a4),L1e=it([oa,lv,O1e,sa],o4),SQ=t=>{var e=sa(t),n=Mx(t),r=!1;return av(t,e,n,r)},NQ=it([oa,SQ],qM),MQ=it([oa,h4,L1e,NQ],i4),F1e=it([$n,f4,oa,sa],sQ),I1e=it([$n,f4,oa,sa],oQ),U1e=(t,e,n,r,i,a,o,l)=>{if(e){var{type:c}=e,u=Ec(t,l);if(r){var d=n==="scaleBand"&&r.bandwidth?r.bandwidth()/2:2,f=c==="category"&&r.bandwidth?r.bandwidth()/d:0;return f=l==="angleAxis"&&i!=null&&i?.length>=2?va(i[0]-i[1])*2*f:f,u&&o?o.map((p,m)=>({coordinate:r(p)+f,value:p,index:m,offset:f})):r.domain().map((p,m)=>({coordinate:r(p)+f,value:a?a[p]:p,index:m,offset:f}))}}},Xu=it([$n,oa,h4,MQ,SQ,F1e,I1e,sa],U1e),m4=it([cQ,uQ,K_e],(t,e,n)=>dQ(n.shared,t,e)),kQ=t=>t.tooltip.settings.trigger,p4=t=>t.tooltip.settings.defaultIndex,cv=it([Tx,m4,kQ,p4],xQ),Nh=it([cv,Ax,iv,lv],d4),EQ=it([Xu,Nh],hQ),g4=it([cv],t=>{if(t)return t.dataKey}),z1e=it([cv],t=>{if(t)return t.graphicalItemId}),TQ=it([Tx,m4,kQ,p4],yQ),B1e=it([qu,Wu,$n,ra,Xu,p4,TQ,sv],bQ),H1e=it([cv,B1e],(t,e)=>t!=null&&t.coordinate?t.coordinate:e),$1e=it([cv],t=>t.active),V1e=it([TQ,Nh,Uh,iv,EQ,sv,m4],vQ),G1e=it([V1e],t=>{if(t!=null){var e=t.map(n=>n.payload).filter(n=>n!=null);return Array.from(new Set(e))}});function W6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function K6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?W6(Object(n),!0).forEach(function(r){q1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):W6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function q1e(t,e,n){return(e=W1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function W1e(t){var e=K1e(t,"string");return typeof e=="symbol"?e:e+""}function K1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var X1e=()=>It(oa),Y1e=()=>{var t=X1e(),e=It(Xu),n=It(MQ);return wh(!t||!n?void 0:K6(K6({},t),{},{scale:n}),e)};function X6(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 bp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?X6(Object(n),!0).forEach(function(r){Q1e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):X6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Q1e(t,e,n){return(e=Z1e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Z1e(t){var e=J1e(t,"string");return typeof e=="symbol"?e:e+""}function J1e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var eSe=(t,e,n,r)=>{var i=e.find(a=>a&&a.index===n);if(i){if(t==="horizontal")return{x:i.coordinate,y:r.chartY};if(t==="vertical")return{x:r.chartX,y:i.coordinate}}return{x:0,y:0}},tSe=(t,e,n,r)=>{var i=e.find(u=>u&&u.index===n);if(i){if(t==="centric"){var a=i.coordinate,{radius:o}=r;return bp(bp(bp({},r),Bi(r.cx,r.cy,o,a)),{},{angle:a,radius:o})}var l=i.coordinate,{angle:c}=r;return bp(bp(bp({},r),Bi(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 nSe(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 AQ=(t,e,n,r,i)=>{var a,o=-1,l=(a=e?.length)!==null&&a!==void 0?a:0;if(l<=1||t==null)return 0;if(r==="angleAxis"&&i!=null&&Math.abs(Math.abs(i[1]-i[0])-360)<=1e-6)for(var c=0;c<l;c++){var u=c>0?n[c-1].coordinate:n[l-1].coordinate,d=n[c].coordinate,f=c>=l-1?n[0].coordinate:n[c+1].coordinate,p=void 0;if(va(d-u)!==va(f-d)){var m=[];if(va(f-d)===va(i[1]-i[0])){p=f;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 b=f+i[1]-i[0];m[0]=Math.min(d,(b+d)/2),m[1]=Math.max(d,(b+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 y=Math.min(u,f),S=Math.max(u,f);if(t>(y+d)/2&&t<=(S+d)/2){({index:o}=n[c]);break}}}else if(e){for(var k=0;k<l;k++)if(k===0&&t<=(e[k].coordinate+e[k+1].coordinate)/2||k>0&&k<l-1&&t>(e[k].coordinate+e[k-1].coordinate)/2&&t<=(e[k].coordinate+e[k+1].coordinate)/2||k===l-1&&t>(e[k].coordinate+e[k-1].coordinate)/2){({index:o}=e[k]);break}}return o},CQ=()=>It(IO),x4=(t,e)=>e,PQ=(t,e,n)=>n,b4=(t,e,n,r)=>r,rSe=it(Xu,t=>SM(t,e=>e.coordinate)),y4=it([Tx,x4,PQ,b4],xQ),v4=it([y4,Ax,iv,lv],d4),iSe=(t,e,n)=>{if(e!=null){var r=Tx(t);return e==="axis"?n==="hover"?r.axisInteraction.hover.dataKey:r.axisInteraction.click.dataKey:n==="hover"?r.itemInteraction.hover.dataKey:r.itemInteraction.click.dataKey}},jQ=it([Tx,x4,PQ,b4],yQ),jS=it([qu,Wu,$n,ra,Xu,b4,jQ,sv],bQ),aSe=it([y4,jS],(t,e)=>{var n;return(n=t.coordinate)!==null&&n!==void 0?n:e}),DQ=it([Xu,v4],hQ),sSe=it([jQ,v4,Uh,iv,DQ,sv,x4],vQ),oSe=it([y4,v4],(t,e)=>({isActive:t.active&&e!=null,activeIndex:e})),lSe=(t,e,n,r,i,a,o)=>{if(!(!t||!n||!r||!i)&&nSe(t,o)){var l=Axe(t,e),c=AQ(l,a,i,n,r),u=eSe(e,i,c,t);return{activeIndex:String(c),activeCoordinate:u}}},cSe=(t,e,n,r,i,a,o)=>{if(!(!t||!r||!i||!a||!n)){var l=q0e(t,n);if(l){var c=Cxe(l,e),u=AQ(c,o,a,r,i),d=tSe(e,a,u,l);return{activeIndex:String(u),activeCoordinate:d}}}},uSe=(t,e,n,r,i,a,o,l)=>{if(!(!t||!e||!r||!i||!a))return e==="horizontal"||e==="vertical"?lSe(t,e,r,i,a,o,l):cSe(t,e,n,r,i,a,o)},dSe=it(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}}),hSe=it(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:Xwe}});function Y6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Q6(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Y6(Object(n),!0).forEach(function(r){fSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function fSe(t,e,n){return(e=mSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function mSe(t){var e=pSe(t,"string");return typeof e=="symbol"?e:e+""}function pSe(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 gSe={},xSe={zIndexMap:Object.values(vi).reduce((t,e)=>Q6(Q6({},t),{},{[e]:{elementId:void 0,panoramaElementId:void 0,consumers:0}}),gSe)},bSe=new Set(Object.values(vi));function ySe(t){return bSe.has(t)}var RQ=$s({name:"zIndex",initialState:xSe,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&&!ySe(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:vSe,unregisterZIndexPortal:wSe,registerZIndexPortalId:_Se,unregisterZIndexPortalId:SSe}=RQ.actions,NSe=RQ.reducer;function ts(t){var{zIndex:e,children:n}=t,r=lbe(),i=r&&e!==void 0&&e!==0,a=ia(),o=Lr();_.useLayoutEffect(()=>i?(o(vSe({zIndex:e})),()=>{o(wSe({zIndex:e}))}):zy,[o,e,i]);var l=It(u=>dSe(u,e,a));if(!i)return n;if(!l)return null;var c=document.getElementById(l);return c?xu.createPortal(n,c):null}function d3(){return d3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},d3.apply(null,arguments)}function Z6(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Xw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Z6(Object(n),!0).forEach(function(r){MSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Z6(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function MSe(t,e,n){return(e=kSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function kSe(t){var e=ESe(t,"string");return typeof e=="symbol"?e:e+""}function ESe(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 TSe(t){var{cursor:e,cursorComp:n,cursorProps:r}=t;return _.isValidElement(e)?_.cloneElement(e,r):_.createElement(n,r)}function ASe(t){var e,{coordinate:n,payload:r,index:i,offset:a,tooltipAxisBandSize:o,layout:l,cursor:c,tooltipEventType:u,chartName:d}=t,f=n,p=r,m=i;if(!c||!f||d!=="ScatterChart"&&u!=="axis")return null;var x,b,v;if(d==="ScatterChart")x=f,b=o0e,v=vi.cursorLine;else if(d==="BarChart")x=l0e(l,f,a,o),b=AX,v=vi.cursorRectangle;else if(l==="radial"&&uK(f)){var{cx:y,cy:S,radius:k,startAngle:T,endAngle:M}=PX(f);x={cx:y,cy:S,startAngle:T,endAngle:M,innerRadius:k,outerRadius:k},b=DX,v=vi.cursorLine}else x={points:Y0e(l,f,a)},b=kg,v=vi.cursorLine;var C=typeof c=="object"&&"className"in c?c.className:void 0,E=Xw(Xw(Xw(Xw({stroke:"#ccc",pointerEvents:"none"},a),x),lm(c)),{},{payload:p,payloadIndex:m,className:nr("recharts-tooltip-cursor",C)});return _.createElement(ts,{zIndex:(e=t.zIndex)!==null&&e!==void 0?e:v},_.createElement(TSe,{cursor:c,cursorComp:b,cursorProps:E}))}function CSe(t){var e=Y1e(),n=fX(),r=Em(),i=CQ();return e==null||n==null||r==null||i==null?null:_.createElement(ASe,d3({},t,{offset:n,layout:r,tooltipAxisBandSize:e,chartName:i}))}var OQ=_.createContext(null),PSe=()=>_.useContext(OQ),_A={exports:{}},J6;function jSe(){return J6||(J6=1,(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,u,d){this.fn=c,this.context=u,this.once=d||!1}function a(c,u,d,f,p){if(typeof d!="function")throw new TypeError("The listener must be a function");var m=new i(d,f||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,f;if(this._eventsCount===0)return u;for(f in d=this._events)e.call(d,f)&&u.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},l.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var p=0,m=f.length,x=new Array(m);p<m;p++)x[p]=f[p].fn;return x},l.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},l.prototype.emit=function(u,d,f,p,m,x){var b=n?n+u:u;if(!this._events[b])return!1;var v=this._events[b],y=arguments.length,S,k;if(v.fn){switch(v.once&&this.removeListener(u,v.fn,void 0,!0),y){case 1:return v.fn.call(v.context),!0;case 2:return v.fn.call(v.context,d),!0;case 3:return v.fn.call(v.context,d,f),!0;case 4:return v.fn.call(v.context,d,f,p),!0;case 5:return v.fn.call(v.context,d,f,p,m),!0;case 6:return v.fn.call(v.context,d,f,p,m,x),!0}for(k=1,S=new Array(y-1);k<y;k++)S[k-1]=arguments[k];v.fn.apply(v.context,S)}else{var T=v.length,M;for(k=0;k<T;k++)switch(v[k].once&&this.removeListener(u,v[k].fn,void 0,!0),y){case 1:v[k].fn.call(v[k].context);break;case 2:v[k].fn.call(v[k].context,d);break;case 3:v[k].fn.call(v[k].context,d,f);break;case 4:v[k].fn.call(v[k].context,d,f,p);break;default:if(!S)for(M=1,S=new Array(y-1);M<y;M++)S[M-1]=arguments[M];v[k].fn.apply(v[k].context,S)}}return!0},l.prototype.on=function(u,d,f){return a(this,u,d,f,!1)},l.prototype.once=function(u,d,f){return a(this,u,d,f,!0)},l.prototype.removeListener=function(u,d,f,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)&&(!f||x.context===f)&&o(this,m);else{for(var b=0,v=[],y=x.length;b<y;b++)(x[b].fn!==d||p&&!x[b].once||f&&x[b].context!==f)&&v.push(x[b]);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})(_A)),_A.exports}var DSe=jSe();const RSe=hl(DSe);var cy=new RSe,h3="recharts.syncEvent.tooltip",eH="recharts.syncEvent.brush";function n2(t,e){if(e){var n=Number.parseInt(e,10);if(!Hs(n))return t?.[n]}}var OSe={chartName:"",tooltipPayloadSearcher:void 0,eventEmitter:void 0,defaultTooltipEventType:"axis"},LQ=$s({name:"options",initialState:OSe,reducers:{createEventEmitter:t=>{t.eventEmitter==null&&(t.eventEmitter=Symbol("rechartsEventEmitter"))}}}),LSe=LQ.reducer,{createEventEmitter:FSe}=LQ.actions;function ISe(t){return t.tooltip.syncInteraction}var USe={chartData:void 0,computedData:void 0,dataStartIndex:0,dataEndIndex:0},FQ=$s({name:"chartData",initialState:USe,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:tH,setDataStartEndIndexes:zSe,setComputedData:UXe}=FQ.actions,BSe=FQ.reducer,HSe=["x","y"];function nH(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 yp(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?nH(Object(n),!0).forEach(function(r){$Se(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function $Se(t,e,n){return(e=VSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function VSe(t){var e=GSe(t,"string");return typeof e=="symbol"?e:e+""}function GSe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function qSe(t,e){if(t==null)return{};var n,r,i=WSe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function WSe(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 KSe(){var t=It(UO),e=It(zO),n=Lr(),r=It(jY),i=It(Xu),a=Em(),o=qy(),l=It(c=>c.rootProps.className);_.useEffect(()=>{if(t==null)return zy;var c=(u,d,f)=>{if(e!==f&&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:b}=m,v=qSe(m,HSe),{x:y,y:S,width:k,height:T}=d.payload.sourceViewBox,M=yp(yp({},v),{},{x:o.x+(k?(x-y)/k:0)*o.width,y:o.y+(T?(b-S)/T:0)*o.height});n(yp(yp({},d),{},{payload:yp(yp({},d.payload),{},{coordinate:M})}))}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},R=r(i,E);C=i[R]}else r==="value"&&(C=i.find(X=>String(X.value)===d.payload.label));var{coordinate:A}=d.payload;if(C==null||d.payload.active===!1||A==null||o==null){n(c3({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,F=Math.min(D,o.x+o.width),z=Math.min(I,o.y+o.height),P={x:a==="horizontal"?C.coordinate:F,y:a==="horizontal"?z:C.coordinate},$=c3({active:d.payload.active,coordinate:P,dataKey:d.payload.dataKey,index:String(C.index),label:d.payload.label,sourceViewBox:d.payload.sourceViewBox,graphicalItemId:d.payload.graphicalItemId});n($)}}};return cy.on(h3,c),()=>{cy.off(h3,c)}},[l,n,e,t,r,i,a,o])}function XSe(){var t=It(UO),e=It(zO),n=Lr();_.useEffect(()=>{if(t==null)return zy;var r=(i,a,o)=>{e!==o&&t===i&&n(zSe(a))};return cy.on(eH,r),()=>{cy.off(eH,r)}},[n,e,t])}function YSe(){var t=Lr();_.useEffect(()=>{t(FSe())},[t]),KSe(),XSe()}function QSe(t,e,n,r,i,a){var o=It(m=>iSe(m,t,e)),l=It(zO),c=It(UO),u=It(jY),d=It(ISe),f=d?.active,p=qy();_.useEffect(()=>{if(!f&&c!=null&&l!=null){var m=c3({active:a,coordinate:n,dataKey:o,index:i,label:typeof r=="number"?String(r):r,sourceViewBox:p,graphicalItemId:void 0});cy.emit(h3,c,m,l)}},[f,n,o,i,r,l,c,u,a,p])}function rH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function iH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?rH(Object(n),!0).forEach(function(r){ZSe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):rH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function ZSe(t,e,n){return(e=JSe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function JSe(t){var e=eNe(t,"string");return typeof e=="symbol"?e:e+""}function eNe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function tNe(t){return t.dataKey}function nNe(t,e){return _.isValidElement(t)?_.cloneElement(t,e):typeof t=="function"?_.createElement(t,e):_.createElement(zbe,e)}var aH=[],rNe={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 S1(t){var e,n,r=ci(t,rNe),{active:i,allowEscapeViewBox:a,animationDuration:o,animationEasing:l,content:c,filterNull:u,isAnimationActive:d,offset:f,payloadUniqBy:p,position:m,reverseDirection:x,useTranslate3d:b,wrapperStyle:v,cursor:y,shared:S,trigger:k,defaultIndex:T,portal:M,axisId:C}=r,E=Lr(),R=typeof T=="number"?String(T):T;_.useEffect(()=>{E(J_e({shared:S,trigger:k,axisId:C,active:i,defaultIndex:R}))},[E,S,k,C,i,R]);var A=qy(),D=NX(),I=W_e(S),{activeIndex:F,isActive:z}=(e=It(de=>oSe(de,I,k,R)))!==null&&e!==void 0?e:{},P=It(de=>sSe(de,I,k,R)),$=It(de=>DQ(de,I,k,R)),X=It(de=>aSe(de,I,k,R)),V=P,Q=PSe(),Z=(n=i??z)!==null&&n!==void 0?n:!1,[se,H]=kK([V,Z]),K=I==="axis"?$:void 0;QSe(I,k,X,K,F,Z);var re=M??Q;if(re==null||A==null||I==null)return null;var ne=V??aH;Z||(ne=aH),u&&ne.length&&(ne=vK(ne.filter(de=>de.value!=null&&(de.hide!==!0||r.includeHidden)),p,tNe));var be=ne.length>0,me=_.createElement(Wbe,{allowEscapeViewBox:a,animationDuration:o,animationEasing:l,isAnimationActive:d,active:Z,coordinate:X,hasPayload:be,offset:f,position:m,reverseDirection:x,useTranslate3d:b,viewBox:A,wrapperStyle:v,lastBoundingBox:se,innerRef:H,hasPortalFromProps:!!M},nNe(c,iH(iH({},r),{},{payload:ne,label:K,active:Z,activeIndex:F,coordinate:X,accessibilityLayer:D})));return _.createElement(_.Fragment,null,xu.createPortal(me,re),Z&&_.createElement(CSe,{cursor:y,tooltipEventType:I,coordinate:X,payload:ne,index:F}))}var uv=t=>null;uv.displayName="Cell";function iNe(t,e,n){return(e=aNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aNe(t){var e=sNe(t,"string");return typeof e=="symbol"?e:e+""}function sNe(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 oNe{constructor(e){iNe(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 sH(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 lNe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?sH(Object(n),!0).forEach(function(r){cNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):sH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function cNe(t,e,n){return(e=uNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function uNe(t){var e=dNe(t,"string");return typeof e=="symbol"?e:e+""}function dNe(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 hNe={cacheSize:2e3,enableCache:!0},IQ=lNe({},hNe),oH=new oNe(IQ.cacheSize),fNe={position:"absolute",top:"-20000px",left:0,padding:0,margin:0,border:"none",whiteSpace:"pre"},lH="recharts_measurement_span";function mNe(t,e){var n=e.fontSize||"",r=e.fontFamily||"",i=e.fontWeight||"",a=e.fontStyle||"",o=e.letterSpacing||"",l=e.textTransform||"";return"".concat(t,"|").concat(n,"|").concat(r,"|").concat(i,"|").concat(a,"|").concat(o,"|").concat(l)}var cH=(t,e)=>{try{var n=document.getElementById(lH);n||(n=document.createElement("span"),n.setAttribute("id",lH),n.setAttribute("aria-hidden","true"),document.body.appendChild(n)),Object.assign(n.style,fNe,e),n.textContent="".concat(t);var r=n.getBoundingClientRect();return{width:r.width,height:r.height}}catch{return{width:0,height:0}}},v0=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e==null||yx.isSsr)return{width:0,height:0};if(!IQ.enableCache)return cH(e,n);var r=mNe(e,n),i=oH.get(r);if(i)return i;var a=cH(e,n);return oH.set(r,a),a},uH=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([*/])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,dH=/(-?\d+(?:\.\d+)?[a-zA-Z%]*)([+-])(-?\d+(?:\.\d+)?[a-zA-Z%]*)/,pNe=/^px|cm|vh|vw|em|rem|%|mm|in|pt|pc|ex|ch|vmin|vmax|Q$/,gNe=/(-?\d+(?:\.\d+)?)([a-zA-Z%]+)?/,UQ={cm:96/2.54,mm:96/25.4,pt:96/72,pc:96/6,in:96,Q:96/(2.54*40),px:1},xNe=Object.keys(UQ),gg="NaN";function bNe(t,e){return t*UQ[e]}class js{static parse(e){var n,[,r,i]=(n=gNe.exec(e))!==null&&n!==void 0?n:[];return new js(parseFloat(r),i??"")}constructor(e,n){this.num=e,this.unit=n,this.num=e,this.unit=n,Hs(e)&&(this.unit=""),n!==""&&!pNe.test(n)&&(this.num=NaN,this.unit=""),xNe.includes(n)&&(this.num=bNe(e,n),this.unit="px")}add(e){return this.unit!==e.unit?new js(NaN,""):new js(this.num+e.num,this.unit)}subtract(e){return this.unit!==e.unit?new js(NaN,""):new js(this.num-e.num,this.unit)}multiply(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new js(NaN,""):new js(this.num*e.num,this.unit||e.unit)}divide(e){return this.unit!==""&&e.unit!==""&&this.unit!==e.unit?new js(NaN,""):new js(this.num/e.num,this.unit||e.unit)}toString(){return"".concat(this.num).concat(this.unit)}isNaN(){return Hs(this.num)}}function zQ(t){if(t.includes(gg))return gg;for(var e=t;e.includes("*")||e.includes("/");){var n,[,r,i,a]=(n=uH.exec(e))!==null&&n!==void 0?n:[],o=js.parse(r??""),l=js.parse(a??""),c=i==="*"?o.multiply(l):o.divide(l);if(c.isNaN())return gg;e=e.replace(uH,c.toString())}for(;e.includes("+")||/.-\d+(?:\.\d+)?/.test(e);){var u,[,d,f,p]=(u=dH.exec(e))!==null&&u!==void 0?u:[],m=js.parse(d??""),x=js.parse(p??""),b=f==="+"?m.add(x):m.subtract(x);if(b.isNaN())return gg;e=e.replace(dH,b.toString())}return e}var hH=/\(([^()]*)\)/;function yNe(t){for(var e=t,n;(n=hH.exec(e))!=null;){var[,r]=n;e=e.replace(hH,zQ(r))}return e}function vNe(t){var e=t.replace(/\s+/g,"");return e=yNe(e),e=zQ(e),e}function wNe(t){try{return vNe(t)}catch{return gg}}function SA(t){var e=wNe(t.slice(5,-1));return e===gg?"":e}var _Ne=["x","y","lineHeight","capHeight","fill","scaleToFit","textAnchor","verticalAnchor"],SNe=["dx","dy","angle","className","breakAll"];function f3(){return f3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},f3.apply(null,arguments)}function fH(t,e){if(t==null)return{};var n,r,i=NNe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function NNe(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 BQ=/[ \f\n\r\t\v\u2028\u2029]+/,HQ=t=>{var{children:e,breakAll:n,style:r}=t;try{var i=[];Yr(e)||(n?i=e.toString().split(""):i=e.toString().split(BQ));var a=i.map(l=>({word:l,width:v0(l,r).width})),o=n?0:v0(" ",r).width;return{wordsWithComputedWidth:a,spaceWidth:o}}catch{return null}};function MNe(t){return t==="start"||t==="middle"||t==="end"||t==="inherit"}var $Q=(t,e,n,r)=>t.reduce((i,a)=>{var{word:o,width:l}=a,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},[]),VQ=t=>t.reduce((e,n)=>e.width>n.width?e:n),kNe="…",mH=(t,e,n,r,i,a,o,l)=>{var c=t.slice(0,e),u=HQ({breakAll:n,style:r,children:c+kNe});if(!u)return[!1,[]];var d=$Q(u.wordsWithComputedWidth,a,o,l),f=d.length>i||VQ(d).width>Number(a);return[f,d]},ENe=(t,e,n,r,i)=>{var{maxLines:a,children:o,style:l,breakAll:c}=t,u=zt(a),d=String(o),f=$Q(e,r,n,i);if(!u||i)return f;var p=f.length>a||VQ(f).width>Number(r);if(!p)return f;for(var m=0,x=d.length-1,b=0,v;m<=x&&b<=d.length-1;){var y=Math.floor((m+x)/2),S=y-1,[k,T]=mH(d,S,c,l,a,r,n,i),[M]=mH(d,y,c,l,a,r,n,i);if(!k&&!M&&(m=y+1),k&&M&&(x=y-1),!k&&M){v=T;break}b++}return v||f},pH=t=>{var e=Yr(t)?[]:t.toString().split(BQ);return[{words:e,width:void 0}]},TNe=t=>{var{width:e,scaleToFit:n,children:r,style:i,breakAll:a,maxLines:o}=t;if((e||n)&&!yx.isSsr){var l,c,u=HQ({breakAll:a,children:r,style:i});if(u){var{wordsWithComputedWidth:d,spaceWidth:f}=u;l=d,c=f}else return pH(r);return ENe({breakAll:a,children:r,maxLines:o,style:i},l,c,e,!!n)}return pH(r)},GQ="#808080",ANe={angle:0,breakAll:!1,capHeight:"0.71em",fill:GQ,lineHeight:"1em",scaleToFit:!1,textAnchor:"start",verticalAnchor:"end",x:0,y:0},r2=_.forwardRef((t,e)=>{var n=ci(t,ANe),{x:r,y:i,lineHeight:a,capHeight:o,fill:l,scaleToFit:c,textAnchor:u,verticalAnchor:d}=n,f=fH(n,_Ne),p=_.useMemo(()=>TNe({breakAll:f.breakAll,children:f.children,maxLines:f.maxLines,scaleToFit:c,style:f.style,width:f.width}),[f.breakAll,f.children,f.maxLines,c,f.style,f.width]),{dx:m,dy:x,angle:b,className:v,breakAll:y}=f,S=fH(f,SNe);if(!cl(r)||!cl(i)||p.length===0)return null;var k=Number(r)+(zt(m)?m:0),T=Number(i)+(zt(x)?x:0);if(!vr(k)||!vr(T))return null;var M;switch(d){case"start":M=SA("calc(".concat(o,")"));break;case"middle":M=SA("calc(".concat((p.length-1)/2," * -").concat(a," + (").concat(o," / 2))"));break;default:M=SA("calc(".concat(p.length-1," * -").concat(a,")"));break}var C=[];if(c){var E=p[0].width,{width:R}=f;C.push("scale(".concat(zt(R)&&zt(E)?R/E:1,")"))}return b&&C.push("rotate(".concat(b,", ").concat(k,", ").concat(T,")")),C.length&&(S.transform=C.join(" ")),_.createElement("text",f3({},Ba(S),{ref:e,x:k,y:T,className:nr("recharts-text",v),textAnchor:u,fill:l.includes("url")?GQ:l}),p.map((A,D)=>{var I=A.words.join(y?"":" ");return _.createElement("tspan",{x:k,dy:D===0?M:a,key:"".concat(I,"-").concat(D)},I)}))});r2.displayName="Text";var CNe=["labelRef"];function PNe(t,e){if(t==null)return{};var n,r,i=jNe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function jNe(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 gH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ei(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gH(Object(n),!0).forEach(function(r){DNe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function DNe(t,e,n){return(e=RNe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function RNe(t){var e=ONe(t,"string");return typeof e=="symbol"?e:e+""}function ONe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function mu(){return mu=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},mu.apply(null,arguments)}var qQ=_.createContext(null),WQ=t=>{var{x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o,children:l}=t,c=_.useMemo(()=>({x:e,y:n,upperWidth:r,lowerWidth:i,width:a,height:o}),[e,n,r,i,a,o]);return _.createElement(qQ.Provider,{value:c},l)},KQ=()=>{var t=_.useContext(qQ),e=qy();return t||hX(e)},LNe=_.createContext(null),FNe=()=>{var t=_.useContext(LNe),e=It(FY);return t||e},INe=t=>{var{value:e,formatter:n}=t,r=Yr(t.children)?e:t.children;return typeof n=="function"?n(r):r},w4=t=>t!=null&&typeof t=="function",UNe=(t,e)=>{var n=va(e-t),r=Math.min(Math.abs(e-t),360);return n*r},zNe=(t,e,n,r,i)=>{var{offset:a,className:o}=t,{cx:l,cy:c,innerRadius:u,outerRadius:d,startAngle:f,endAngle:p,clockWise:m}=i,x=(u+d)/2,b=UNe(f,p),v=b>=0?1:-1,y,S;switch(e){case"insideStart":y=f+v*a,S=m;break;case"insideEnd":y=p-v*a,S=!m;break;case"end":y=p+v*a,S=m;break;default:throw new Error("Unsupported position ".concat(e))}S=b<=0?S:!S;var k=Bi(l,c,x,y),T=Bi(l,c,x,y+(S?1:-1)*359),M="M".concat(k.x,",").concat(k.y,`
- A`).concat(x,",").concat(x,",0,1,").concat(S?0:1,`,
- `).concat(T.x,",").concat(T.y),C=Yr(t.id)?X0("recharts-radial-line-"):t.id;return _.createElement("text",mu({},r,{dominantBaseline:"central",className:nr("recharts-radial-bar-label",o)}),_.createElement("defs",null,_.createElement("path",{id:C,d:M})),_.createElement("textPath",{xlinkHref:"#".concat(C)},n))},BNe=(t,e,n)=>{var{cx:r,cy:i,innerRadius:a,outerRadius:o,startAngle:l,endAngle:c}=t,u=(l+c)/2;if(n==="outside"){var{x:d,y:f}=Bi(r,i,o+e,u);return{x:d,y:f,textAnchor:d>=r?"start":"end",verticalAnchor:"middle"}}if(n==="center")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"middle"};if(n==="centerTop")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"start"};if(n==="centerBottom")return{x:r,y:i,textAnchor:"middle",verticalAnchor:"end"};var p=(a+o)/2,{x:m,y:x}=Bi(r,i,p,u);return{x:m,y:x,textAnchor:"middle",verticalAnchor:"middle"}},m3=t=>"cx"in t&&zt(t.cx),HNe=(t,e)=>{var{parentViewBox:n,offset:r,position:i}=t,a;n!=null&&!m3(n)&&(a=n);var{x:o,y:l,upperWidth:c,lowerWidth:u,height:d}=e,f=o,p=o+(c-u)/2,m=(f+p)/2,x=(c+u)/2,b=f+c/2,v=d>=0?1:-1,y=v*r,S=v>0?"end":"start",k=v>0?"start":"end",T=c>=0?1:-1,M=T*r,C=T>0?"end":"start",E=T>0?"start":"end";if(i==="top"){var R={x:f+c/2,y:l-y,textAnchor:"middle",verticalAnchor:S};return Ei(Ei({},R),a?{height:Math.max(l-a.y,0),width:c}:{})}if(i==="bottom"){var A={x:p+u/2,y:l+d+y,textAnchor:"middle",verticalAnchor:k};return Ei(Ei({},A),a?{height:Math.max(a.y+a.height-(l+d),0),width:u}:{})}if(i==="left"){var D={x:m-M,y:l+d/2,textAnchor:C,verticalAnchor:"middle"};return Ei(Ei({},D),a?{width:Math.max(D.x-a.x,0),height:d}:{})}if(i==="right"){var I={x:m+x+M,y:l+d/2,textAnchor:E,verticalAnchor:"middle"};return Ei(Ei({},I),a?{width:Math.max(a.x+a.width-I.x,0),height:d}:{})}var F=a?{width:x,height:d}:{};return i==="insideLeft"?Ei({x:m+M,y:l+d/2,textAnchor:E,verticalAnchor:"middle"},F):i==="insideRight"?Ei({x:m+x-M,y:l+d/2,textAnchor:C,verticalAnchor:"middle"},F):i==="insideTop"?Ei({x:f+c/2,y:l+y,textAnchor:"middle",verticalAnchor:k},F):i==="insideBottom"?Ei({x:p+u/2,y:l+d-y,textAnchor:"middle",verticalAnchor:S},F):i==="insideTopLeft"?Ei({x:f+M,y:l+y,textAnchor:E,verticalAnchor:k},F):i==="insideTopRight"?Ei({x:f+c-M,y:l+y,textAnchor:C,verticalAnchor:k},F):i==="insideBottomLeft"?Ei({x:p+M,y:l+d-y,textAnchor:E,verticalAnchor:S},F):i==="insideBottomRight"?Ei({x:p+u-M,y:l+d-y,textAnchor:C,verticalAnchor:S},F):i&&typeof i=="object"&&(zt(i.x)||Lu(i.x))&&(zt(i.y)||Lu(i.y))?Ei({x:o+es(i.x,x),y:l+es(i.y,d),textAnchor:"end",verticalAnchor:"end"},F):Ei({x:b,y:l+d/2,textAnchor:"middle",verticalAnchor:"middle"},F)},$Ne={angle:0,offset:5,zIndex:vi.label,position:"middle",textBreakAll:!1};function zd(t){var e=ci(t,$Ne),{viewBox:n,position:r,value:i,children:a,content:o,className:l="",textBreakAll:c,labelRef:u}=e,d=FNe(),f=KQ(),p=r==="center"?f:d??f,m,x,b;if(n==null?m=p:m3(n)?m=n:m=hX(n),!m||Yr(i)&&Yr(a)&&!_.isValidElement(o)&&typeof o!="function")return null;var v=Ei(Ei({},e),{},{viewBox:m});if(_.isValidElement(o)){var{labelRef:y}=v,S=PNe(v,CNe);return _.cloneElement(o,S)}if(typeof o=="function"){if(x=_.createElement(o,v),_.isValidElement(x))return x}else x=INe(e);var k=Ba(e);if(m3(m)){if(r==="insideStart"||r==="insideEnd"||r==="end")return zNe(e,r,x,k,m);b=BNe(m,e.offset,e.position)}else b=HNe(e,m);return _.createElement(ts,{zIndex:e.zIndex},_.createElement(r2,mu({ref:u,className:nr("recharts-label",l)},k,b,{textAnchor:MNe(k.textAnchor)?k.textAnchor:b.textAnchor,breakAll:c}),x))}zd.displayName="Label";var VNe=(t,e,n)=>{if(!t)return null;var r={viewBox:e,labelRef:n};return t===!0?_.createElement(zd,mu({key:"label-implicit"},r)):cl(t)?_.createElement(zd,mu({key:"label-implicit",value:t},r)):_.isValidElement(t)?t.type===zd?_.cloneElement(t,Ei({key:"label-implicit"},r)):_.createElement(zd,mu({key:"label-implicit",content:t},r)):w4(t)?_.createElement(zd,mu({key:"label-implicit",content:t},r)):t&&typeof t=="object"?_.createElement(zd,mu({},t,{key:"label-implicit"},r)):null};function XQ(t){var{label:e,labelRef:n}=t,r=KQ();return VNe(e,r,n)||null}var NA={},MA={},xH;function GNe(){return xH||(xH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return n[n.length-1]}t.last=e})(MA)),MA}var kA={},bH;function qNe(){return bH||(bH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){return Array.isArray(n)?n:Array.from(n)}t.toArray=e})(kA)),kA}var yH;function WNe(){return yH||(yH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});const e=GNe(),n=qNe(),r=XR();function i(a){if(r.isArrayLike(a))return e.last(n.toArray(a))}t.last=i})(NA)),NA}var EA,vH;function KNe(){return vH||(vH=1,EA=WNe().last),EA}var XNe=KNe();const YNe=hl(XNe);var QNe=["valueAccessor"],ZNe=["dataKey","clockWise","id","textBreakAll","zIndex"];function DS(){return DS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},DS.apply(null,arguments)}function wH(t,e){if(t==null)return{};var n,r,i=JNe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function JNe(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 eMe=t=>Array.isArray(t.value)?YNe(t.value):t.value,YQ=_.createContext(void 0),_4=YQ.Provider,QQ=_.createContext(void 0),tMe=QQ.Provider;function nMe(){return _.useContext(YQ)}function rMe(){return _.useContext(QQ)}function N1(t){var{valueAccessor:e=eMe}=t,n=wH(t,QNe),{dataKey:r,clockWise:i,id:a,textBreakAll:o,zIndex:l}=n,c=wH(n,ZNe),u=nMe(),d=rMe(),f=u||d;return!f||!f.length?null:_.createElement(ts,{zIndex:l??vi.label},_.createElement(li,{className:"recharts-label-list"},f.map((p,m)=>{var x,b=Yr(r)?e(p,m):yr(p&&p.payload,r),v=Yr(a)?{}:{id:"".concat(a,"-").concat(m)};return _.createElement(zd,DS({key:"label-".concat(m)},Ba(p),c,v,{fill:(x=n.fill)!==null&&x!==void 0?x:p.fill,parentViewBox:p.parentViewBox,value:b,textBreakAll:o,viewBox:p.viewBox,index:m,zIndex:0}))})))}N1.displayName="LabelList";function i2(t){var{label:e}=t;return e?e===!0?_.createElement(N1,{key:"labelList-implicit"}):_.isValidElement(e)||w4(e)?_.createElement(N1,{key:"labelList-implicit",content:e}):typeof e=="object"?_.createElement(N1,DS({key:"labelList-implicit"},e,{type:String(e.type)})):null:null}function p3(){return p3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},p3.apply(null,arguments)}var ZQ=t=>{var{cx:e,cy:n,r,className:i}=t,a=nr("recharts-dot",i);return zt(e)&&zt(n)&&zt(r)?_.createElement("circle",p3({},xs(t),KR(t),{className:a,cx:e,cy:n,r})):null},JQ=t=>t.graphicalItems.polarItems,iMe=it([ii,ev],GO),a2=it([JQ,ui,iMe],qO),aMe=it([a2],WO),s2=it([aMe,OO],KO),sMe=it([s2,ui,a2],YO);it([s2,ui,a2],(t,e,n)=>n.length>0?t.flatMap(r=>n.flatMap(i=>{var a,o=yr(r,(a=e.dataKey)!==null&&a!==void 0?a: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 _H=()=>{},oMe=it([s2,ui,a2,JM,ii],e4),lMe=it([ui,ZO,JO,_H,oMe,_H,$n,ii],t4),eZ=it([ui,$n,s2,sMe,Jy,ii,lMe],n4),cMe=it([eZ,ui,Ex],a4);it([ui,eZ,cMe,ii],o4);var uMe={radiusAxis:{},angleAxis:{}},tZ=$s({name:"polarAxis",initialState:uMe,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:zXe,removeRadiusAxis:BXe,addAngleAxis:HXe,removeAngleAxis:$Xe}=tZ.actions,dMe=tZ.reducer;function SH(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 NH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?SH(Object(n),!0).forEach(function(r){hMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):SH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function hMe(t,e,n){return(e=fMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function fMe(t){var e=mMe(t,"string");return typeof e=="symbol"?e:e+""}function mMe(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 pMe=(t,e)=>e,S4=it([JQ,pMe],(t,e)=>t.filter(n=>n.type==="pie").find(n=>n.id===e)),gMe=[],N4=(t,e,n)=>n?.length===0?gMe:n,nZ=it([OO,S4,N4],(t,e,n)=>{var{chartData:r}=t;if(e!=null){var i;if(e?.data!=null&&e.data.length>0?i=e.data:i=r,(!i||!i.length)&&n!=null&&(i=n.map(a=>NH(NH({},e.presentationProps),a.props))),i!=null)return i}}),xMe=it([nZ,S4,N4],(t,e,n)=>{if(!(t==null||e==null))return t.map((r,i)=>{var a,o=yr(r,e.nameKey,e.name),l;return n!=null&&(a=n[i])!==null&&a!==void 0&&(a=a.props)!==null&&a!==void 0&&a.fill?l=n[i].props.fill:typeof r=="object"&&r!=null&&"fill"in r?l=r.fill:l=e.fill,{value:Lh(o,e.dataKey),color:l,payload:r,type:e.legendType}})}),bMe=it([nZ,S4,N4,ra],(t,e,n,r)=>{if(!(e==null||t==null))return y2e({offset:r,pieSettings:e,displayedData:t,cells:n})}),TA={exports:{}},Nr={};var MH;function yMe(){if(MH)return Nr;MH=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.view_transition"),m=Symbol.for("react.client.reference");function x(b){if(typeof b=="object"&&b!==null){var v=b.$$typeof;switch(v){case t:switch(b=b.type,b){case n:case i:case r:case c:case u:case p:return b;default:switch(b=b&&b.$$typeof,b){case o:case l:case f:case d:return b;case a:return b;default:return v}}case e:return v}}}return Nr.ContextConsumer=a,Nr.ContextProvider=o,Nr.Element=t,Nr.ForwardRef=l,Nr.Fragment=n,Nr.Lazy=f,Nr.Memo=d,Nr.Portal=e,Nr.Profiler=i,Nr.StrictMode=r,Nr.Suspense=c,Nr.SuspenseList=u,Nr.isContextConsumer=function(b){return x(b)===a},Nr.isContextProvider=function(b){return x(b)===o},Nr.isElement=function(b){return typeof b=="object"&&b!==null&&b.$$typeof===t},Nr.isForwardRef=function(b){return x(b)===l},Nr.isFragment=function(b){return x(b)===n},Nr.isLazy=function(b){return x(b)===f},Nr.isMemo=function(b){return x(b)===d},Nr.isPortal=function(b){return x(b)===e},Nr.isProfiler=function(b){return x(b)===i},Nr.isStrictMode=function(b){return x(b)===r},Nr.isSuspense=function(b){return x(b)===c},Nr.isSuspenseList=function(b){return x(b)===u},Nr.isValidElementType=function(b){return typeof b=="string"||typeof b=="function"||b===n||b===i||b===r||b===c||b===u||typeof b=="object"&&b!==null&&(b.$$typeof===f||b.$$typeof===d||b.$$typeof===o||b.$$typeof===a||b.$$typeof===l||b.$$typeof===m||b.getModuleId!==void 0)},Nr.typeOf=x,Nr}var kH;function vMe(){return kH||(kH=1,TA.exports=yMe()),TA.exports}var wMe=vMe(),EH=t=>typeof t=="string"?t:t?t.displayName||t.name||"Component":"",TH=null,AA=null,rZ=t=>{if(t===TH&&Array.isArray(AA))return AA;var e=[];return _.Children.forEach(t,n=>{Yr(n)||(wMe.isFragment(n)?e=e.concat(rZ(n.props.children)):e.push(n))}),AA=e,TH=t,e};function M4(t,e){var n=[],r=[];return Array.isArray(e)?r=e.map(i=>EH(i)):r=[EH(e)],rZ(t).forEach(i=>{var a=cm(i,"type.displayName")||cm(i,"type.name");a&&r.indexOf(a)!==-1&&n.push(i)}),n}var k4=t=>t&&typeof t=="object"&&"clipDot"in t?!!t.clipDot:!0,CA={},AH;function _Me(){return AH||(AH=1,(function(t){Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});function e(n){if(typeof n!="object"||n==null)return!1;if(Object.getPrototypeOf(n)===null)return!0;if(Object.prototype.toString.call(n)!=="[object Object]"){const i=n[Symbol.toStringTag];return i==null||!Object.getOwnPropertyDescriptor(n,Symbol.toStringTag)?.writable?!1:n.toString()===`[object ${i}]`}let r=n;for(;Object.getPrototypeOf(r)!==null;)r=Object.getPrototypeOf(r);return Object.getPrototypeOf(n)===r}t.isPlainObject=e})(CA)),CA}var PA,CH;function SMe(){return CH||(CH=1,PA=_Me().isPlainObject),PA}var NMe=SMe();const MMe=hl(NMe);function PH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function jH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?PH(Object(n),!0).forEach(function(r){kMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):PH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function kMe(t,e,n){return(e=EMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function EMe(t){var e=TMe(t,"string");return typeof e=="symbol"?e:e+""}function TMe(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 RS(){return RS=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},RS.apply(null,arguments)}var DH=(t,e,n,r,i)=>{var a=n-r,o;return o="M ".concat(t,",").concat(e),o+="L ".concat(t+n,",").concat(e),o+="L ".concat(t+n-a/2,",").concat(e+i),o+="L ".concat(t+n-a/2-r,",").concat(e+i),o+="L ".concat(t,",").concat(e," Z"),o},AMe={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},CMe=t=>{var e=ci(t,AMe),{x:n,y:r,upperWidth:i,lowerWidth:a,height:o,className:l}=e,{animationEasing:c,animationDuration:u,animationBegin:d,isUpdateAnimationActive:f}=e,p=_.useRef(null),[m,x]=_.useState(-1),b=_.useRef(i),v=_.useRef(a),y=_.useRef(o),S=_.useRef(n),k=_.useRef(r),T=wx(t,"trapezoid-");if(_.useEffect(()=>{if(p.current&&p.current.getTotalLength)try{var P=p.current.getTotalLength();P&&x(P)}catch{}},[]),n!==+n||r!==+r||i!==+i||a!==+a||o!==+o||i===0&&a===0||o===0)return null;var M=nr("recharts-trapezoid",l);if(!f)return _.createElement("g",null,_.createElement("path",RS({},Ba(e),{className:M,d:DH(n,r,i,a,o)})));var C=b.current,E=v.current,R=y.current,A=S.current,D=k.current,I="0px ".concat(m===-1?1:m,"px"),F="".concat(m,"px 0px"),z=MX(["strokeDasharray"],u,c);return _.createElement(vx,{animationId:T,key:T,canBegin:m>0,duration:u,easing:c,isActive:f,begin:d},P=>{var $=mr(C,i,P),X=mr(E,a,P),V=mr(R,o,P),Q=mr(A,n,P),Z=mr(D,r,P);p.current&&(b.current=$,v.current=X,y.current=V,S.current=Q,k.current=Z);var se=P>0?{transition:z,strokeDasharray:F}:{strokeDasharray:I};return _.createElement("path",RS({},Ba(e),{className:M,d:DH(Q,Z,$,X,V),ref:p,style:jH(jH({},se),e.style)}))})},PMe=["option","shapeType","propTransformer","activeClassName"];function jMe(t,e){if(t==null)return{};var n,r,i=DMe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function DMe(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 RH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function OS(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?RH(Object(n),!0).forEach(function(r){RMe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):RH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function RMe(t,e,n){return(e=OMe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function OMe(t){var e=LMe(t,"string");return typeof e=="symbol"?e:e+""}function LMe(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 FMe(t,e){return OS(OS({},e),t)}function IMe(t,e){return t==="symbols"}function OH(t){var{shapeType:e,elementProps:n}=t;switch(e){case"rectangle":return _.createElement(AX,n);case"trapezoid":return _.createElement(CMe,n);case"sector":return _.createElement(DX,n);case"symbols":if(IMe(e))return _.createElement(WR,n);break;case"curve":return _.createElement(kg,n);default:return null}}function UMe(t){return _.isValidElement(t)?t.props:t}function E4(t){var{option:e,shapeType:n,propTransformer:r=FMe,activeClassName:i="recharts-active-shape"}=t,a=jMe(t,PMe),o;if(_.isValidElement(e))o=_.cloneElement(e,OS(OS({},a),UMe(e)));else if(typeof e=="function")o=e(a,a.index);else if(MMe(e)&&typeof e!="boolean"){var l=r(e,a);o=_.createElement(OH,{shapeType:n,elementProps:l})}else{var c=a;o=_.createElement(OH,{shapeType:n,elementProps:c})}return a.isActive?_.createElement(li,{className:i},o):o}var T4=(t,e,n)=>{var r=Lr();return(i,a)=>o=>{t?.(i,a,o),r(mQ({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}},A4=t=>{var e=Lr();return(n,r)=>i=>{t?.(n,r,i),e(e1e())}},C4=(t,e,n)=>{var r=Lr();return(i,a)=>o=>{t?.(i,a,o),r(t1e({activeIndex:String(a),activeDataKey:e,activeCoordinate:i.tooltipPosition,activeGraphicalItemId:n}))}};function o2(t){var{tooltipEntrySettings:e}=t,n=Lr(),r=ia(),i=_.useRef(null);return _.useLayoutEffect(()=>{r||(i.current===null?n(Y_e(e)):i.current!==e&&n(Q_e({prev:i.current,next:e})),i.current=e)},[e,n,r]),_.useLayoutEffect(()=>()=>{i.current&&(n(Z_e(i.current)),i.current=null)},[n]),null}function P4(t){var{legendPayload:e}=t,n=Lr(),r=ia(),i=_.useRef(null);return _.useLayoutEffect(()=>{r||(i.current===null?n(wX(e)):i.current!==e&&n(_X({prev:i.current,next:e})),i.current=e)},[n,r,e]),_.useLayoutEffect(()=>()=>{i.current&&(n(SX(i.current)),i.current=null)},[n]),null}function zMe(t){var{legendPayload:e}=t,n=Lr(),r=It($n),i=_.useRef(null);return _.useLayoutEffect(()=>{r!=="centric"&&r!=="radial"||(i.current===null?n(wX(e)):i.current!==e&&n(_X({prev:i.current,next:e})),i.current=e)},[n,r,e]),_.useLayoutEffect(()=>()=>{i.current&&(n(SX(i.current)),i.current=null)},[n]),null}var jA,BMe=()=>{var[t]=_.useState(()=>X0("uid-"));return t},HMe=(jA=Fae.useId)!==null&&jA!==void 0?jA:BMe;function iZ(t,e){var n=HMe();return e||(t?"".concat(t,"-").concat(n):n)}var $Me=_.createContext(void 0),l2=t=>{var{id:e,type:n,children:r}=t,i=iZ("recharts-".concat(n),e);return _.createElement($Me.Provider,{value:i},r(i))},VMe={cartesianItems:[],polarItems:[]},aZ=$s({name:"graphicalItems",initialState:VMe,reducers:{addCartesianGraphicalItem:{reducer(t,e){t.cartesianItems.push(e.payload)},prepare:Jr()},replaceCartesianGraphicalItem:{reducer(t,e){var{prev:n,next:r}=e.payload,i=Ol(t).cartesianItems.indexOf(n);i>-1&&(t.cartesianItems[i]=r)},prepare:Jr()},removeCartesianGraphicalItem:{reducer(t,e){var n=Ol(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=Ol(t).polarItems.indexOf(e.payload);n>-1&&t.polarItems.splice(n,1)},prepare:Jr()}}}),{addCartesianGraphicalItem:GMe,replaceCartesianGraphicalItem:qMe,removeCartesianGraphicalItem:WMe,addPolarGraphicalItem:KMe,removePolarGraphicalItem:XMe}=aZ.actions,YMe=aZ.reducer,QMe=t=>{var e=Lr(),n=_.useRef(null);return _.useLayoutEffect(()=>{n.current===null?e(GMe(t)):n.current!==t&&e(qMe({prev:n.current,next:t})),n.current=t},[e,t]),_.useLayoutEffect(()=>()=>{n.current&&(e(WMe(n.current)),n.current=null)},[e]),null},j4=_.memo(QMe);function ZMe(t){var e=Lr();return _.useLayoutEffect(()=>(e(KMe(t)),()=>{e(XMe(t))}),[e,t]),null}var JMe=["key"],e2e=["onMouseEnter","onClick","onMouseLeave"],t2e=["id"],n2e=["id"];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 xi(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){r2e(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 r2e(t,e,n){return(e=i2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function i2e(t){var e=a2e(t,"string");return typeof e=="symbol"?e:e+""}function a2e(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 Mh(){return Mh=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},Mh.apply(null,arguments)}function c2(t,e){if(t==null)return{};var n,r,i=s2e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function s2e(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 o2e(t){var e=_.useMemo(()=>M4(t.children,uv),[t.children]),n=It(r=>xMe(r,t.id,e));return n==null?null:_.createElement(zMe,{legendPayload:n})}var l2e=_.memo(t=>{var{dataKey:e,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:o,name:l,hide:c,tooltipType:u}=t,d={dataDefinedOnItem:r.map(f=>f.tooltipPayload),positions:r.map(f=>f.tooltipPosition),settings:{stroke:i,strokeWidth:a,fill:o,dataKey:e,nameKey:n,name:Lh(l,e),hide:c,type:u,color:o,unit:""}};return _.createElement(o2,{tooltipEntrySettings:d})}),c2e=(t,e)=>t>e?"start":t<e?"end":"middle",u2e=(t,e,n)=>es(typeof e=="function"?e(t):e,n,n*.8),d2e=(t,e,n)=>{var{top:r,left:i,width:a,height:o}=e,l=CX(a,o),c=i+es(t.cx,a,a/2),u=r+es(t.cy,o,o/2),d=es(t.innerRadius,l,0),f=u2e(n,t.outerRadius,l),p=t.maxRadius||Math.sqrt(a*a+o*o)/2;return{cx:c,cy:u,innerRadius:d,outerRadius:f,maxRadius:p}},h2e=(t,e)=>{var n=va(e-t),r=Math.min(Math.abs(e-t),360);return n*r};function f2e(t){return t&&typeof t=="object"&&"className"in t&&typeof t.className=="string"?t.className:""}var m2e=(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=c2(e,JMe);return _.createElement(kg,Mh({},i,{type:"linear",className:n}))},p2e=(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",f2e(t));return _.createElement(r2,Mh({},e,{alignmentBaseline:"middle",className:i}),r)};function g2e(t){var{sectors:e,props:n,showLabels:r}=t,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!e)return null;var l=xs(n),c=lm(i),u=lm(a),d=typeof i=="object"&&"offsetRadius"in i&&typeof i.offsetRadius=="number"&&i.offsetRadius||20,f=e.map((p,m)=>{var x=(p.startAngle+p.endAngle)/2,b=Bi(p.cx,p.cy,p.outerRadius+d,x),v=xi(xi(xi(xi({},l),p),{},{stroke:"none"},c),{},{index:m,textAnchor:c2e(b.x,p.cx)},b),y=xi(xi(xi(xi({},l),p),{},{fill:"none",stroke:p.fill},u),{},{index:m,points:[Bi(p.cx,p.cy,p.outerRadius,x),b],key:"line"});return _.createElement(ts,{zIndex:vi.label,key:"label-".concat(p.startAngle,"-").concat(p.endAngle,"-").concat(p.midAngle,"-").concat(m)},_.createElement(li,null,a&&m2e(a,y),p2e(i,v,yr(p,o))))});return _.createElement(li,{className:"recharts-pie-labels"},f)}function x2e(t){var{sectors:e,props:n,showLabels:r}=t,{label:i}=n;return typeof i=="object"&&i!=null&&"position"in i?_.createElement(i2,{label:i}):_.createElement(g2e,{sectors:e,props:n,showLabels:r})}function b2e(t){var{sectors:e,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=t,l=It(Nh),c=It(g4),u=It(z1e),{onMouseEnter:d,onClick:f,onMouseLeave:p}=i,m=c2(i,e2e),x=T4(d,i.dataKey,o),b=A4(p),v=C4(f,i.dataKey,o);return e==null||e.length===0?null:_.createElement(_.Fragment,null,e.map((y,S)=>{if(y?.startAngle===0&&y?.endAngle===0&&e.length!==1)return null;var k=u==null||u===o,T=String(S)===l&&(c==null||i.dataKey===c)&&k,M=l?r:null,C=n&&T?n:M,E=xi(xi({},y),{},{stroke:y.stroke,tabIndex:-1,[oX]:S,[lX]:i.dataKey});return _.createElement(li,Mh({key:"sector-".concat(y?.startAngle,"-").concat(y?.endAngle,"-").concat(y.midAngle,"-").concat(S),tabIndex:-1,className:"recharts-pie-sector"},By(m,y,S),{onMouseEnter:x(y,S),onMouseLeave:b(y,S),onClick:v(y,S)}),_.createElement(E4,Mh({option:a??C,index:S,shapeType:"sector",isActive:T},E)))}))}function y2e(t){var e,{pieSettings:n,displayedData:r,cells:i,offset:a}=t,{cornerRadius:o,startAngle:l,endAngle:c,dataKey:u,nameKey:d,tooltipType:f}=n,p=Math.abs(n.minAngle),m=h2e(l,c),x=Math.abs(m),b=r.length<=1?0:(e=n.paddingAngle)!==null&&e!==void 0?e:0,v=r.filter(C=>yr(C,u,0)!==0).length,y=(x>=360?v:v-1)*b,S=x-v*p-y,k=r.reduce((C,E)=>{var R=yr(E,u,0);return C+(zt(R)?R:0)},0),T;if(k>0){var M;T=r.map((C,E)=>{var R=yr(C,u,0),A=yr(C,d,E),D=d2e(n,a,C),I=(zt(R)?R:0)/k,F,z=xi(xi({},C),i&&i[E]&&i[E].props);E?F=M.endAngle+va(m)*b*(R!==0?1:0):F=l;var P=F+va(m)*((R!==0?p:0)+I*S),$=(F+P)/2,X=(D.innerRadius+D.outerRadius)/2,V=[{name:A,value:R,payload:z,dataKey:u,type:f}],Q=Bi(D.cx,D.cy,X,$);return M=xi(xi(xi(xi({},n.presentationProps),{},{percent:I,cornerRadius:typeof o=="string"?parseFloat(o):o,name:A,tooltipPayload:V,midAngle:$,middleRadius:X,tooltipPosition:Q},z),D),{},{value:R,dataKey:u,startAngle:F,endAngle:P,payload:z,paddingAngle:va(m)*b}),M})}return T}function v2e(t){var{showLabels:e,sectors:n,children:r}=t,i=_.useMemo(()=>!e||!n?[]:n.map(a=>({value:a.value,payload:a.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:a.cx,cy:a.cy,innerRadius:a.innerRadius,outerRadius:a.outerRadius,startAngle:a.startAngle,endAngle:a.endAngle,clockWise:!1},fill:a.fill})),[n,e]);return _.createElement(tMe,{value:e?i:void 0},r)}function w2e(t){var{props:e,previousSectorsRef:n,id:r}=t,{sectors:i,isAnimationActive:a,animationBegin:o,animationDuration:l,animationEasing:c,activeShape:u,inactiveShape:d,onAnimationStart:f,onAnimationEnd:p}=e,m=wx(e,"recharts-pie-"),x=n.current,[b,v]=_.useState(!1),y=_.useCallback(()=>{typeof p=="function"&&p(),v(!1)},[p]),S=_.useCallback(()=>{typeof f=="function"&&f(),v(!0)},[f]);return _.createElement(v2e,{showLabels:!b,sectors:i},_.createElement(vx,{animationId:m,begin:o,duration:l,isActive:a,easing:c,onAnimationStart:S,onAnimationEnd:y,key:m},k=>{var T=[],M=i&&i[0],C=M?.startAngle;return i?.forEach((E,R)=>{var A=x&&x[R],D=R>0?cm(E,"paddingAngle",0):0;if(A){var I=mr(A.endAngle-A.startAngle,E.endAngle-E.startAngle,k),F=xi(xi({},E),{},{startAngle:C+D,endAngle:C+I+D});T.push(F),C=F.endAngle}else{var{endAngle:z,startAngle:P}=E,$=mr(0,z-P,k),X=xi(xi({},E),{},{startAngle:C+D,endAngle:C+$+D});T.push(X),C=X.endAngle}}),n.current=T,_.createElement(li,null,_.createElement(b2e,{sectors:T,activeShape:u,inactiveShape:d,allOtherPieProps:e,shape:e.shape,id:r}))}),_.createElement(x2e,{showLabels:!b,sectors:i,props:e}),e.children)}var _2e={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 S2e(t){var{id:e}=t,n=c2(t,t2e),{hide:r,className:i,rootTabIndex:a}=t,o=_.useMemo(()=>M4(t.children,uv),[t.children]),l=It(d=>bMe(d,e,o)),c=_.useRef(null),u=nr("recharts-pie",i);return r||l==null?(c.current=null,_.createElement(li,{tabIndex:a,className:u})):_.createElement(ts,{zIndex:t.zIndex},_.createElement(l2e,{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:a,className:u},_.createElement(w2e,{props:xi(xi({},n),{},{sectors:l}),previousSectorsRef:c,id:e})))}function sZ(t){var e=ci(t,_2e),{id:n}=e,r=c2(e,n2e),i=xs(r);return _.createElement(l2,{id:n,type:"pie"},a=>_.createElement(_.Fragment,null,_.createElement(ZMe,{type:"pie",id:a,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:e.maxRadius}),_.createElement(o2e,Mh({},r,{id:a})),_.createElement(S2e,Mh({},r,{id:a}))))}sZ.displayName="Pie";var N2e=["points"];function FH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function DA(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?FH(Object(n),!0).forEach(function(r){M2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):FH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function M2e(t,e,n){return(e=k2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function k2e(t){var e=E2e(t,"string");return typeof e=="symbol"?e:e+""}function E2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function LS(){return LS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},LS.apply(null,arguments)}function T2e(t,e){if(t==null)return{};var n,r,i=A2e(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function A2e(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 C2e(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:""),a=n??{},{points:o}=a,l=T2e(a,N2e);return _.createElement(ZQ,LS({},l,{className:i}))}function P2e(t,e){return t==null?!1:e?!0:t.length===1}function oZ(t){var{points:e,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:l,clipPathId:c,zIndex:u=vi.scatter}=t;if(!P2e(e,n))return null;var d=k4(n),f=lme(n),p=e.map((x,b)=>{var v,y,S=DA(DA(DA({r:3},o),f),{},{index:b,cx:(v=x.x)!==null&&v!==void 0?v:void 0,cy:(y=x.y)!==null&&y!==void 0?y:void 0,dataKey:a,value:x.value,payload:x.payload,points:e});return _.createElement(C2e,{key:"dot-".concat(b),option:n,dotProps:S,className:i})}),m={};return l&&c!=null&&(m.clipPath="url(#clipPath-".concat(d?"":"dots-").concat(c,")")),_.createElement(ts,{zIndex:u},_.createElement(li,LS({className:r},m),p))}function IH(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 UH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?IH(Object(n),!0).forEach(function(r){j2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):IH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function j2e(t,e,n){return(e=D2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function D2e(t){var e=R2e(t,"string");return typeof e=="symbol"?e:e+""}function R2e(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 O2e={xAxis:{},yAxis:{},zAxis:{}},lZ=$s({name:"cartesianAxis",initialState:O2e,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 a=i.widthHistory||[];if(a.length===3&&a[0]===a[2]&&r===a[1]&&r!==i.width&&Math.abs(r-a[0])<=1)return;var o=[...a,r].slice(-3);t.yAxis[n]=UH(UH({},t.yAxis[n]),{},{width:r,widthHistory:o})}}}}),{addXAxis:L2e,replaceXAxis:F2e,removeXAxis:I2e,addYAxis:U2e,replaceYAxis:z2e,removeYAxis:B2e,addZAxis:VXe,replaceZAxis:GXe,removeZAxis:qXe,updateYAxisWidth:H2e}=lZ.actions,$2e=lZ.reducer,V2e=it([ra],t=>({top:t.top,bottom:t.bottom,left:t.left,right:t.right})),G2e=it([V2e,qu,Wu],(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)}}),u2=()=>It(G2e),q2e=()=>It(G1e);function zH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function RA(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?zH(Object(n),!0).forEach(function(r){W2e(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):zH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function W2e(t,e,n){return(e=K2e(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function K2e(t){var e=X2e(t,"string");return typeof e=="symbol"?e:e+""}function X2e(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Y2e=t=>{var{point:e,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=t;if(i===!1||e.x==null||e.y==null)return null;var l={index:n,dataKey:a,cx:e.x,cy:e.y,r:4,fill:r??"none",strokeWidth:2,stroke:"#fff",payload:e.payload,value:e.value},c=RA(RA(RA({},l),lm(i)),KR(i)),u;return _.isValidElement(i)?u=_.cloneElement(i,c):typeof i=="function"?u=i(c):u=_.createElement(ZQ,c),_.createElement(li,{className:"recharts-active-dot",clipPath:o},u)};function g3(t){var{points:e,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=vi.activeDot}=t,l=It(Nh),c=q2e();if(e==null||c==null)return null;var u=e.find(d=>c.includes(d.payload));return Yr(u)?null:_.createElement(ts,{zIndex:o},_.createElement(Y2e,{point:u,childIndex:Number(l),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var Q2e="Invariant failed";function Z2e(t,e){throw new Error(Q2e)}var J2e=["x","y"];function x3(){return x3=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},x3.apply(null,arguments)}function BH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ib(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?BH(Object(n),!0).forEach(function(r){eke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):BH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function eke(t,e,n){return(e=tke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function tke(t){var e=nke(t,"string");return typeof e=="symbol"?e:e+""}function nke(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 rke(t,e){if(t==null)return{};var n,r,i=ike(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function ike(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 ake(t,e){var{x:n,y:r}=t,i=rke(t,J2e),a="".concat(n),o=parseInt(a,10),l="".concat(r),c=parseInt(l,10),u="".concat(e.height||i.height),d=parseInt(u,10),f="".concat(e.width||i.width),p=parseInt(f,10);return Ib(Ib(Ib(Ib(Ib({},e),i),o?{x:o}:{}),c?{y:c}:{}),{},{height:d,width:p,name:e.name,radius:e.radius})}function FS(t){return _.createElement(E4,x3({shapeType:"rectangle",propTransformer:ake,activeClassName:"recharts-active-bar"},t))}var ske=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return(r,i)=>{if(zt(e))return e;var a=zt(r)||Yr(r);return a?e(r,i):(a||Z2e(),n)}},oke={},cZ=$s({name:"errorBars",initialState:oke,reducers:{addErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]||(t[n]=[]),t[n].push(r)},replaceErrorBar:(t,e)=>{var{itemId:n,prev:r,next:i}=e.payload;t[n]&&(t[n]=t[n].map(a=>a.dataKey===r.dataKey&&a.direction===r.direction?i:a))},removeErrorBar:(t,e)=>{var{itemId:n,errorBar:r}=e.payload;t[n]&&(t[n]=t[n].filter(i=>i.dataKey!==r.dataKey||i.direction!==r.direction))}}}),{addErrorBar:WXe,replaceErrorBar:KXe,removeErrorBar:XXe}=cZ.actions,lke=cZ.reducer,cke=["children"];function uke(t,e){if(t==null)return{};var n,r,i=dke(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function dke(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 hke={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},fke=_.createContext(hke);function uZ(t){var{children:e}=t,n=uke(t,cke);return _.createElement(fke.Provider,{value:n},e)}function d2(t,e){var n,r,i=It(u=>Tc(u,t)),a=It(u=>Ac(u,e)),o=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:ma.allowDataOverflow,l=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:pa.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function D4(t){var{xAxisId:e,yAxisId:n,clipPathId:r}=t,i=u2(),{needClipX:a,needClipY:o,needClip:l}=d2(e,n);if(!l||!i)return null;var{x:c,y:u,width:d,height:f}=i;return _.createElement("clipPath",{id:"clipPath-".concat(r)},_.createElement("rect",{x:a?c:c-d/2,y:o?u:u-f/2,width:a?d:d*2,height:o?f:f*2}))}function mke(t,e){return t&&typeof t=="object"&&"zIndex"in t&&typeof t.zIndex=="number"&&vr(t.zIndex)?t.zIndex:e}var OA={exports:{}},LA={};var HH;function pke(){if(HH)return LA;HH=1;var t=px();function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,i=t.useRef,a=t.useEffect,o=t.useMemo,l=t.useDebugValue;return LA.useSyncExternalStoreWithSelector=function(c,u,d,f,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(M){if(!y){if(y=!0,S=M,M=f(M),p!==void 0&&x.hasValue){var C=x.value;if(p(C,M))return k=C}return k=M}if(C=k,n(S,M))return C;var E=f(M);return p!==void 0&&p(C,E)?(S=M,C):(S=M,k=E)}var y=!1,S,k,T=d===void 0?null:d;return[function(){return v(u())},T===null?void 0:function(){return v(T())}]},[u,d,f,p]);var b=r(c,m[0],m[1]);return a(function(){x.hasValue=!0,x.value=b},[b]),l(b),b},LA}var $H;function gke(){return $H||($H=1,OA.exports=pke()),OA.exports}gke();function xke(t){t()}function bke(){let t=null,e=null;return{clear(){t=null,e=null},notify(){xke(()=>{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 VH={notify(){},get:()=>[]};function yke(t,e){let n,r=VH,i=0,a=!1;function o(b){d();const v=r.subscribe(b);let y=!1;return()=>{y||(y=!0,v(),f())}}function l(){r.notify()}function c(){x.onStateChange&&x.onStateChange()}function u(){return a}function d(){i++,n||(n=t.subscribe(c),r=bke())}function f(){i--,n&&i===0&&(n(),n=void 0,r.clear(),r=VH)}function p(){a||(a=!0,d())}function m(){a&&(a=!1,f())}const x={addNestedSub:o,notifyNestedSubs:l,handleChangeWrapper:c,isSubscribed:u,trySubscribe:p,tryUnsubscribe:m,getListeners:()=>r};return x}var vke=()=>typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",wke=vke(),_ke=()=>typeof navigator<"u"&&navigator.product==="ReactNative",Ske=_ke(),Nke=()=>wke||Ske?_.useLayoutEffect:_.useEffect,Mke=Nke();function GH(t,e){return t===e?t!==0||e!==0||1/t===1/e:t!==t&&e!==e}function kke(t,e){if(GH(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])||!GH(t[n[i]],e[n[i]]))return!1;return!0}var Eke=Symbol.for("react-redux-context"),Tke=typeof globalThis<"u"?globalThis:{};function Ake(){if(!_.createContext)return{};const t=Tke[Eke]??=new Map;let e=t.get(_.createContext);return e||(e=_.createContext(null),t.set(_.createContext,e)),e}var Cke=Ake();function Pke(t){const{children:e,context:n,serverState:r,store:i}=t,a=_.useMemo(()=>{const c=yke(i);return{store:i,subscription:c,getServerState:r?()=>r:void 0}},[i,r]),o=_.useMemo(()=>i.getState(),[i]);Mke(()=>{const{subscription:c}=a;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),o!==i.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[a,o]);const l=n||Cke;return _.createElement(l.Provider,{value:a},e)}var jke=Pke,Dke=new Set(["axisLine","tickLine","activeBar","activeDot","activeLabel","activeShape","allowEscapeViewBox","background","cursor","dot","label","line","margin","padding","position","shape","style","tick","wrapperStyle"]);function Rke(t,e){return t==null&&e==null?!0:typeof t=="number"&&typeof e=="number"?t===e||t!==t&&e!==e:t===e}function dv(t,e){var n=new Set([...Object.keys(t),...Object.keys(e)]);for(var r of n)if(Dke.has(r)){if(t[r]==null&&e[r]==null)continue;if(!kke(t[r],e[r]))return!1}else if(!Rke(t[r],e[r]))return!1;return!0}var Oke=["onMouseEnter","onMouseLeave","onClick"],Lke=["value","background","tooltipPosition"],Fke=["id"],Ike=["onMouseEnter","onClick","onMouseLeave"];function Hu(){return Hu=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},Hu.apply(null,arguments)}function qH(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 ds(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qH(Object(n),!0).forEach(function(r){Uke(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Uke(t,e,n){return(e=zke(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function zke(t){var e=Bke(t,"string");return typeof e=="symbol"?e:e+""}function Bke(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 IS(t,e){if(t==null)return{};var n,r,i=Hke(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function Hke(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 $ke=t=>{var{dataKey:e,name:n,fill:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Lh(n,e),payload:t}]},Vke=_.memo(t=>{var{dataKey:e,stroke:n,strokeWidth:r,fill:i,name:a,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:Lh(a,e),hide:o,type:c,color:i,unit:l}};return _.createElement(o2,{tooltipEntrySettings:u})});function Gke(t){var e=It(Nh),{data:n,dataKey:r,background:i,allOtherBarProps:a}=t,{onMouseEnter:o,onMouseLeave:l,onClick:c}=a,u=IS(a,Oke),d=T4(o,r),f=A4(l),p=C4(c,r);if(!i||n==null)return null;var m=lm(i);return _.createElement(ts,{zIndex:mke(i,vi.barBackground)},n.map((x,b)=>{var{value:v,background:y,tooltipPosition:S}=x,k=IS(x,Lke);if(!y)return null;var T=d(x,b),M=f(x,b),C=p(x,b),E=ds(ds(ds(ds(ds({option:i,isActive:String(b)===e},k),{},{fill:"#eee"},y),m),By(u,x,b)),{},{onMouseEnter:T,onMouseLeave:M,onClick:C,dataKey:r,index:b,className:"recharts-bar-background-rectangle"});return _.createElement(FS,Hu({key:"background-bar-".concat(b)},E))}))}function qke(t){var{showLabels:e,children:n,rects:r}=t,i=r?.map(a=>{var o={x:a.x,y:a.y,width:a.width,lowerWidth:a.width,upperWidth:a.width,height:a.height};return ds(ds({},o),{},{value:a.value,payload:a.payload,parentViewBox:a.parentViewBox,viewBox:o,fill:a.fill})});return _.createElement(_4,{value:e?i:void 0},n)}function Wke(t){var{shape:e,activeBar:n,baseProps:r,entry:i,index:a,dataKey:o}=t,l=It(Nh),c=It(g4),u=n&&String(a)===l&&(c==null||o===c),d=u?n:e;return u?_.createElement(ts,{zIndex:vi.activeBar},_.createElement(FS,Hu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))):_.createElement(FS,Hu({},r,{name:String(r.name)},i,{isActive:u,option:d,index:a,dataKey:o}))}function Kke(t){var{shape:e,baseProps:n,entry:r,index:i,dataKey:a}=t;return _.createElement(FS,Hu({},n,{name:String(n.name)},r,{isActive:!1,option:e,index:i,dataKey:a}))}function Xke(t){var e,{data:n,props:r}=t,i=(e=xs(r))!==null&&e!==void 0?e:{},{id:a}=i,o=IS(i,Fke),{shape:l,dataKey:c,activeBar:u}=r,{onMouseEnter:d,onClick:f,onMouseLeave:p}=r,m=IS(r,Ike),x=T4(d,c),b=A4(p),v=C4(f,c);return n?_.createElement(_.Fragment,null,n.map((y,S)=>_.createElement(li,Hu({key:"rectangle-".concat(y?.x,"-").concat(y?.y,"-").concat(y?.value,"-").concat(S),className:"recharts-bar-rectangle"},By(m,y,S),{onMouseEnter:x(y,S),onMouseLeave:b(y,S),onClick:v(y,S)}),u?_.createElement(Wke,{shape:l,activeBar:u,baseProps:o,entry:y,index:S,dataKey:c}):_.createElement(Kke,{shape:l,baseProps:o,entry:y,index:S,dataKey:c})))):null}function Yke(t){var{props:e,previousRectanglesRef:n}=t,{data:r,layout:i,isAnimationActive:a,animationBegin:o,animationDuration:l,animationEasing:c,onAnimationEnd:u,onAnimationStart:d}=e,f=n.current,p=wx(e,"recharts-bar-"),[m,x]=_.useState(!1),b=!m,v=_.useCallback(()=>{typeof u=="function"&&u(),x(!1)},[u]),y=_.useCallback(()=>{typeof d=="function"&&d(),x(!0)},[d]);return _.createElement(qke,{showLabels:b,rects:r},_.createElement(vx,{animationId:p,begin:o,duration:l,isActive:a,easing:c,onAnimationEnd:v,onAnimationStart:y,key:p},S=>{var k=S===1?r:r?.map((T,M)=>{var C=f&&f[M];if(C)return ds(ds({},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),R=mr(T.stackedBarStart,T.y,S);return ds(ds({},T),{},{y:R,height:E})}var A=mr(0,T.width,S),D=mr(T.stackedBarStart,T.x,S);return ds(ds({},T),{},{width:A,x:D})});return S>0&&(n.current=k??null),k==null?null:_.createElement(li,null,_.createElement(Xke,{props:e,data:k}))}),_.createElement(i2,{label:e.label}),e.children)}function Qke(t){var e=_.useRef(null);return _.createElement(Yke,{previousRectanglesRef:e,props:t})}var dZ=0,Zke=(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 Jke extends _.PureComponent{render(){var{hide:e,data:n,dataKey:r,className:i,xAxisId:a,yAxisId:o,needClip:l,background:c,id:u}=this.props;if(e||n==null)return null;var d=nr("recharts-bar",i),f=u;return _.createElement(li,{className:d,id:u},l&&_.createElement("defs",null,_.createElement(D4,{clipPathId:f,xAxisId:a,yAxisId:o})),_.createElement(li,{className:"recharts-bar-rectangles",clipPath:l?"url(#clipPath-".concat(f,")"):void 0},_.createElement(Gke,{data:n,dataKey:r,background:c,allOtherBarProps:this.props}),_.createElement(Qke,this.props)))}}var eEe={activeBar:!1,animationBegin:0,animationDuration:400,animationEasing:"ease",background:!1,hide:!1,isAnimationActive:"auto",label:!1,legendType:"rect",minPointSize:dZ,xAxisId:0,yAxisId:0,zIndex:vi.bar};function tEe(t){var{xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d}=t,{needClip:f}=d2(e,n),p=Em(),m=ia(),x=M4(t.children,uv),b=It(S=>AEe(S,e,n,m,t.id,x));if(p!=="vertical"&&p!=="horizontal")return null;var v,y=b?.[0];return y==null||y.height==null||y.width==null?v=0:v=p==="vertical"?y.height/2:y.width/2,_.createElement(uZ,{xAxisId:e,yAxisId:n,data:b,dataPointFormatter:Zke,errorBarOffset:v},_.createElement(Jke,Hu({},t,{layout:p,needClip:f,data:b,xAxisId:e,yAxisId:n,hide:r,legendType:i,minPointSize:a,activeBar:o,animationBegin:l,animationDuration:c,animationEasing:u,isAnimationActive:d})))}function nEe(t){var{layout:e,barSettings:{dataKey:n,minPointSize:r},pos:i,bandSize:a,xAxis:o,yAxis:l,xAxisTicks:c,yAxisTicks:u,stackedData:d,displayedData:f,offset:p,cells:m,parentViewBox:x,dataStartIndex:b}=t,v=e==="horizontal"?l:o,y=d?v.scale.domain():null,S=Mxe({numericAxis:v}),k=v.scale(S);return f.map((T,M)=>{var C,E,R,A,D,I;d?C=vxe(d[M+b],y):(C=yr(T,n),Array.isArray(C)||(C=[S,C]));var F=ske(r,dZ)(C[1],M);if(e==="horizontal"){var z,[P,$]=[l.scale(C[0]),l.scale(C[1])];E=c8({axis:o,ticks:c,bandSize:a,offset:i.offset,entry:T,index:M}),R=(z=$??P)!==null&&z!==void 0?z:void 0,A=i.size;var X=P-$;if(D=Hs(X)?0:X,I={x:E,y:p.top,width:A,height:p.height},Math.abs(F)>0&&Math.abs(D)<Math.abs(F)){var V=va(D||F)*(Math.abs(F)-Math.abs(D));R-=V,D+=V}}else{var[Q,Z]=[o.scale(C[0]),o.scale(C[1])];if(E=Q,R=c8({axis:l,ticks:u,bandSize:a,offset:i.offset,entry:T,index:M}),A=Z-Q,D=i.size,I={x:p.left,y:R,width:p.width,height:D},Math.abs(F)>0&&Math.abs(A)<Math.abs(F)){var se=va(A||F)*(Math.abs(F)-Math.abs(A));A+=se}}if(E==null||R==null||A==null||D==null)return null;var H=ds(ds({},T),{},{stackedBarStart:k,x:E,y:R,width:A,height:D,value:d?C:C[1],payload:T,background:I,tooltipPosition:{x:E+A/2,y:R+D/2},parentViewBox:x},m&&m[M]&&m[M].props);return H}).filter(Boolean)}function rEe(t){var e=ci(t,eEe),n=ia();return _.createElement(l2,{id:e.id,type:"bar"},r=>_.createElement(_.Fragment,null,_.createElement(P4,{legendPayload:$ke(e)}),_.createElement(Vke,{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(j4,{type:"bar",id:r,data:void 0,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,stackId:aX(e.stackId),hide:e.hide,barSize:e.barSize,minPointSize:e.minPointSize,maxBarSize:e.maxBarSize,isPanorama:n}),_.createElement(ts,{zIndex:e.zIndex},_.createElement(tEe,Hu({},e,{id:r})))))}var hZ=_.memo(rEe,dv);hZ.displayName="Bar";function WH(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 Yw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?WH(Object(n),!0).forEach(function(r){iEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):WH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function iEe(t,e,n){return(e=aEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function aEe(t){var e=sEe(t,"string");return typeof e=="symbol"?e:e+""}function sEe(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 oEe=(t,e)=>e,lEe=(t,e,n)=>n,cEe=(t,e,n,r)=>r,uEe=(t,e,n,r,i)=>i,hv=it([nv,uEe],(t,e)=>t.filter(n=>n.type==="bar").find(n=>n.id===e)),dEe=it([hv],t=>t?.maxBarSize),hEe=(t,e,n,r,i,a)=>a,KH=(t,e,n)=>{var r=n??t;if(!Yr(r))return es(r,e,0)},fEe=it([$n,nv,oEe,lEe,cEe],(t,e,n,r,i)=>e.filter(a=>t==="horizontal"?a.xAxisId===n:a.yAxisId===r).filter(a=>a.isPanorama===i).filter(a=>a.hide===!1).filter(a=>a.type==="bar")),mEe=(t,e,n,r)=>{var i=$n(t);return i==="horizontal"?ly(t,"yAxis",n,r):ly(t,"xAxis",e,r)},pEe=(t,e,n)=>{var r=$n(t);return r==="horizontal"?H6(t,"xAxis",e):H6(t,"yAxis",n)},gEe=(t,e,n)=>{var r={},i=t.filter(XM),a=t.filter(u=>u.stackId==null),o=i.reduce((u,d)=>(u[d.stackId]||(u[d.stackId]=[]),u[d.stackId].push(d),u),r),l=Object.entries(o).map(u=>{var[d,f]=u,p=f.map(x=>x.dataKey),m=KH(e,n,f[0].barSize);return{stackId:d,dataKeys:p,barSize:m}}),c=a.map(u=>{var d=[u.dataKey].filter(p=>p!=null),f=KH(e,n,u.barSize);return{stackId:void 0,dataKeys:d,barSize:f}});return[...l,...c]},xEe=it([fEe,Hwe,pEe],gEe),bEe=(t,e,n,r,i)=>{var a,o,l=hv(t,e,n,r,i);if(l!=null){var c=$n(t),u=AY(t),{maxBarSize:d}=l,f=Yr(d)?u:d,p,m;return c==="horizontal"?(p=yc(t,"xAxis",e,r),m=bc(t,"xAxis",e,r)):(p=yc(t,"yAxis",n,r),m=bc(t,"yAxis",n,r)),(a=(o=wh(p,m,!0))!==null&&o!==void 0?o:f)!==null&&a!==void 0?a:0}},fZ=(t,e,n,r)=>{var i=$n(t),a,o;return i==="horizontal"?(a=yc(t,"xAxis",e,r),o=bc(t,"xAxis",e,r)):(a=yc(t,"yAxis",n,r),o=bc(t,"yAxis",n,r)),wh(a,o)};function yEe(t,e,n,r,i){var a=r.length;if(!(a<1)){var o=es(t,n,0,!0),l,c=[];if(vr(r[0].barSize)){var u=!1,d=n/a,f=r.reduce((y,S)=>y+(S.barSize||0),0);f+=(a-1)*o,f>=n&&(f-=(a-1)*o,o=0),f>=n&&d>0&&(u=!0,d*=.9,f=a*d);var p=(n-f)/2>>0,m={offset:p-o,size:0};l=r.reduce((y,S)=>{var k,T={stackId:S.stackId,dataKeys:S.dataKeys,position:{offset:m.offset+m.size+o,size:u?d:(k=S.barSize)!==null&&k!==void 0?k:0}},M=[...y,T];return m=M[M.length-1].position,M},c)}else{var x=es(e,n,0,!0);n-2*x-(a-1)*o<=0&&(o=0);var b=(n-2*x-(a-1)*o)/a;b>1&&(b>>=0);var v=vr(i)?Math.min(b,i):b;l=r.reduce((y,S,k)=>[...y,{stackId:S.stackId,dataKeys:S.dataKeys,position:{offset:x+(b+o)*k+(b-v)/2,size:v}}],c)}return l}}var vEe=(t,e,n,r,i,a,o)=>{var l=Yr(o)?e:o,c=yEe(n,r,i!==a?i:a,t,l);return i!==a&&c!=null&&(c=c.map(u=>Yw(Yw({},u),{},{position:Yw(Yw({},u.position),{},{offset:u.position.offset-i/2})}))),c},wEe=it([xEe,AY,Bwe,CY,bEe,fZ,dEe],vEe),_Ee=(t,e,n,r)=>yc(t,"xAxis",e,r),SEe=(t,e,n,r)=>yc(t,"yAxis",n,r),NEe=(t,e,n,r)=>bc(t,"xAxis",e,r),MEe=(t,e,n,r)=>bc(t,"yAxis",n,r),kEe=it([wEe,hv],(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}}),EEe=(t,e)=>{var n=KM(e);if(!(!t||n==null||e==null)){var{stackId:r}=e;if(r!=null){var i=t[r];if(i){var{stackedData:a}=i;if(a)return a.find(o=>o.key===n)}}}},TEe=it([mEe,hv],EEe),AEe=it([ra,aO,_Ee,SEe,NEe,MEe,kEe,$n,Zy,fZ,TEe,hv,hEe],(t,e,n,r,i,a,o,l,c,u,d,f,p)=>{var{chartData:m,dataStartIndex:x,dataEndIndex:b}=c;if(!(f==null||o==null||e==null||l!=="horizontal"&&l!=="vertical"||n==null||r==null||i==null||a==null||u==null)){var{data:v}=f,y;if(v!=null&&v.length>0?y=v:y=m?.slice(x,b+1),y!=null)return nEe({layout:l,barSettings:f,pos:o,parentViewBox:e,bandSize:u,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,stackedData:d,displayedData:y,offset:t,cells:p,dataStartIndex:x})}}),mZ=t=>{var{chartData:e}=t,n=Lr(),r=ia();return _.useEffect(()=>r?()=>{}:(n(tH(e)),()=>{n(tH(void 0))}),[e,n,r]),null},XH={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},pZ=$s({name:"brush",initialState:XH,reducers:{setBrushSettings(t,e){return e.payload==null?XH:e.payload}}}),{setBrushSettings:YXe}=pZ.actions,CEe=pZ.reducer;function YH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Qw(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?YH(Object(n),!0).forEach(function(r){gZ(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):YH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function gZ(t,e,n){return(e=PEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function PEe(t){var e=jEe(t,"string");return typeof e=="symbol"?e:e+""}function jEe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var DEe=(t,e)=>{var{x:n,y:r}=t,{x:i,y:a}=e;return{x:Math.min(n,i),y:Math.min(r,a),width:Math.abs(i-n),height:Math.abs(a-r)}},REe=t=>{var{x1:e,y1:n,x2:r,y2:i}=t;return DEe({x:e,y:n},{x:r,y:i})};class h2{static create(e){return new h2(e)}constructor(e){this.scale=e}get domain(){return this.scale.domain}get range(){return this.scale.range}get rangeMin(){return this.range()[0]}get rangeMax(){return this.range()[1]}get bandwidth(){return this.scale.bandwidth}apply(e){var{bandAware:n,position:r}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e!==void 0){if(r)switch(r){case"start":return this.scale(e);case"middle":{var i=this.bandwidth?this.bandwidth()/2:0;return this.scale(e)+i}case"end":{var a=this.bandwidth?this.bandwidth():0;return this.scale(e)+a}default:return this.scale(e)}if(n){var 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}}gZ(h2,"EPS",1e-4);var OEe=t=>{var e=Object.keys(t).reduce((n,r)=>Qw(Qw({},n),{},{[r]:h2.create(t[r])}),{});return Qw(Qw({},e),{},{apply(n){var{bandAware:r,position:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.fromEntries(Object.entries(n).map(a=>{var[o,l]=a;return[o,e[o].apply(l,{bandAware:r,position:i})]}))},isInRange(n){return Object.keys(n).every(r=>e[r].isInRange(n[r]))}})};function LEe(t){return(t%180+180)%180}var FEe=function(e){var{width:n,height:r}=e,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,a=LEe(i),o=a*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)},IEe={dots:[],areas:[],lines:[]},xZ=$s({name:"referenceElements",initialState:IEe,reducers:{addDot:(t,e)=>{t.dots.push(e.payload)},removeDot:(t,e)=>{var n=Ol(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=Ol(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=Ol(t).lines.findIndex(r=>r===e.payload);n!==-1&&t.lines.splice(n,1)}}}),{addDot:QXe,removeDot:ZXe,addArea:JXe,removeArea:eYe,addLine:UEe,removeLine:zEe}=xZ.actions,BEe=xZ.reducer,bZ=_.createContext(void 0),HEe=t=>{var{children:e}=t,[n]=_.useState("".concat(X0("recharts"),"-clip")),r=u2();if(r==null)return null;var{x:i,y:a,width:o,height:l}=r;return _.createElement(bZ.Provider,{value:n},_.createElement("defs",null,_.createElement("clipPath",{id:n},_.createElement("rect",{x:i,y:a,height:l,width:o}))),e)},$Ee=()=>_.useContext(bZ);function QH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function ZH(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?QH(Object(n),!0).forEach(function(r){VEe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):QH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function VEe(t,e,n){return(e=GEe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function GEe(t){var e=qEe(t,"string");return typeof e=="symbol"?e:e+""}function qEe(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 US(){return US=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},US.apply(null,arguments)}var WEe=(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",US({},e,{className:"recharts-reference-line-line"}))}return n},KEe=(t,e,n,r,i,a)=>{var{x:o,width:l}=a,c=i.y.apply(t,{position:n});if(Hs(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},XEe=(t,e,n,r,i,a)=>{var{y:o,height:l}=a,c=i.x.apply(t,{position:n});if(Hs(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},YEe=(t,e,n,r)=>{var i=t.map(a=>r.apply(a,{position:n}));return e==="discard"&&i.some(a=>!r.isInRange(a))?null:i},QEe=(t,e,n,r,i,a)=>{var{x:o,y:l,segment:c,ifOverflow:u}=a,d=cl(o),f=cl(l);return f?KEe(l,u,n,i,t,e):d?XEe(o,u,n,r,t,e):c!=null&&c.length===2?YEe(c,u,n,t):null};function ZEe(t){var e=Lr();return _.useEffect(()=>(e(UEe(t)),()=>{e(zEe(t))})),null}function JEe(t){var{xAxisId:e,yAxisId:n,shape:r,className:i,ifOverflow:a}=t,o=ia(),l=$Ee(),c=It(C=>Tc(C,e)),u=It(C=>Ac(C,n)),d=It(C=>Sh(C,"xAxis",e,o)),f=It(C=>Sh(C,"yAxis",n,o)),p=qy();if(!l||!p||c==null||u==null||d==null||f==null)return null;var m=OEe({x:d,y:f}),x=QEe(m,p,t.position,c.orientation,u.orientation,t);if(!x)return null;var[{x:b,y:v},{x:y,y:S}]=x,k=a==="hidden"?"url(#".concat(l,")"):void 0,T=ZH(ZH({clipPath:k},Ba(t)),{},{x1:b,y1:v,x2:y,y2:S}),M=REe({x1:b,y1:v,x2:y,y2:S});return _.createElement(ts,{zIndex:t.zIndex},_.createElement(li,{className:nr("recharts-reference-line",i)},WEe(r,T),_.createElement(WQ,US({},M,{lowerWidth:M.width,upperWidth:M.width}),_.createElement(XQ,{label:t.label}),t.children)))}var eTe={ifOverflow:"discard",xAxisId:0,yAxisId:0,fill:"none",stroke:"#ccc",fillOpacity:1,strokeWidth:1,position:"middle",zIndex:vi.line};function s0(t){var e=ci(t,eTe);return _.createElement(_.Fragment,null,_.createElement(ZEe,{yAxisId:e.yAxisId,xAxisId:e.xAxisId,ifOverflow:e.ifOverflow,x:e.x,y:e.y,segment:e.segment}),_.createElement(JEe,e))}s0.displayName="ReferenceLine";function yZ(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 tTe(t,e,n){var r={width:t.width+e.width,height:t.height+e.height};return FEe(r,n)}function nTe(t,e,n){var r=n==="width",{x:i,y:a,width:o,height:l}=t;return e===1?{start:r?i:a,end:r?i+o:a+l}:{start:r?i+o:a+l,end:r?i:a}}function zS(t,e,n,r,i){if(t*e<t*r||t*e>t*i)return!1;var a=n();return t*(e-t*a/2-r)>=0&&t*(e+t*a/2-i)<=0}function rTe(t,e){return yZ(t,e+1)}function iTe(t,e,n,r,i){for(var a=(r||[]).slice(),{start:o,end:l}=e,c=0,u=1,d=o,f=function(){var x=r?.[c];if(x===void 0)return{v:yZ(r,u)};var b=c,v,y=()=>(v===void 0&&(v=n(x,b)),v),S=x.coordinate,k=c===0||zS(t,S,y,d,l);k||(c=0,d=o,u+=1),k&&(d=S+t*(y()/2+i),c+=u)},p;u<=a.length;)if(p=f(),p)return p.v;return[]}function JH(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Ka(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?JH(Object(n),!0).forEach(function(r){aTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):JH(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function aTe(t,e,n){return(e=sTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function sTe(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)}function lTe(t,e,n,r,i){for(var a=(r||[]).slice(),o=a.length,{start:l}=e,{end:c}=e,u=function(p){var m=a[p],x,b=()=>(x===void 0&&(x=n(m,p)),x);if(p===o-1){var v=t*(m.coordinate+t*b()/2-c);a[p]=m=Ka(Ka({},m),{},{tickCoord:v>0?m.coordinate-v*t:m.coordinate})}else a[p]=m=Ka(Ka({},m),{},{tickCoord:m.coordinate});if(m.tickCoord!=null){var y=zS(t,m.tickCoord,b,l,c);y&&(c=m.tickCoord-t*(b()/2+i),a[p]=Ka(Ka({},m),{},{isShow:!0}))}},d=o-1;d>=0;d--)u(d);return a}function cTe(t,e,n,r,i,a){var o=(r||[]).slice(),l=o.length,{start:c,end:u}=e;if(a){var d=r[l-1],f=n(d,l-1),p=t*(d.coordinate+t*f/2-u);if(o[l-1]=d=Ka(Ka({},d),{},{tickCoord:p>0?d.coordinate-p*t:d.coordinate}),d.tickCoord!=null){var m=zS(t,d.tickCoord,()=>f,c,u);m&&(u=d.tickCoord-t*(f/2+i),o[l-1]=Ka(Ka({},d),{},{isShow:!0}))}}for(var x=a?l-1:l,b=function(S){var k=o[S],T,M=()=>(T===void 0&&(T=n(k,S)),T);if(S===0){var C=t*(k.coordinate-t*M()/2-c);o[S]=k=Ka(Ka({},k),{},{tickCoord:C<0?k.coordinate-C*t:k.coordinate})}else o[S]=k=Ka(Ka({},k),{},{tickCoord:k.coordinate});if(k.tickCoord!=null){var E=zS(t,k.tickCoord,M,c,u);E&&(c=k.tickCoord+t*(M()/2+i),o[S]=Ka(Ka({},k),{},{isShow:!0}))}},v=0;v<x;v++)b(v);return o}function R4(t,e,n){var{tick:r,ticks:i,viewBox:a,minTickGap:o,orientation:l,interval:c,tickFormatter:u,unit:d,angle:f}=t;if(!i||!i.length||!r)return[];if(zt(c)||yx.isSsr){var p;return(p=rTe(i,zt(c)?c:0))!==null&&p!==void 0?p:[]}var m=[],x=l==="top"||l==="bottom"?"width":"height",b=d&&x==="width"?v0(d,{fontSize:e,letterSpacing:n}):{width:0,height:0},v=(k,T)=>{var M=typeof u=="function"?u(k.value,T):k.value;return x==="width"?tTe(v0(M,{fontSize:e,letterSpacing:n}),b,f):v0(M,{fontSize:e,letterSpacing:n})[x]},y=i.length>=2?va(i[1].coordinate-i[0].coordinate):1,S=nTe(a,y,x);return c==="equidistantPreserveStart"?iTe(y,S,v,i,o):(c==="preserveStart"||c==="preserveStartEnd"?m=cTe(y,S,v,i,o,c==="preserveStartEnd"):m=lTe(y,S,v,i,o),m.filter(k=>k.isShow))}var uTe=t=>{var{ticks:e,label:n,labelGapWithTick:r=5,tickSize:i=0,tickMargin:a=0}=t,o=0;if(e){Array.from(e).forEach(d=>{if(d){var f=d.getBoundingClientRect();f.width>o&&(o=f.width)}});var l=n?n.getBoundingClientRect().width:0,c=i+a,u=o+c+l+(n?r:0);return Math.round(u)}return 0},dTe=["axisLine","width","height","className","hide","ticks","axisType"];function hTe(t,e){if(t==null)return{};var n,r,i=fTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function fTe(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 fm(){return fm=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},fm.apply(null,arguments)}function e$(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?e$(Object(n),!0).forEach(function(r){mTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):e$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function mTe(t,e,n){return(e=pTe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function pTe(t){var e=gTe(t,"string");return typeof e=="symbol"?e:e+""}function gTe(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 Tu={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 xTe(t){var{x:e,y:n,width:r,height:i,orientation:a,mirror:o,axisLine:l,otherSvgProps:c}=t;if(!l)return null;var u=Ii(Ii(Ii({},c),xs(l)),{},{fill:"none"});if(a==="top"||a==="bottom"){var d=+(a==="top"&&!o||a==="bottom"&&o);u=Ii(Ii({},u),{},{x1:e,y1:n+d*i,x2:e+r,y2:n+d*i})}else{var f=+(a==="left"&&!o||a==="right"&&o);u=Ii(Ii({},u),{},{x1:e+f*r,y1:n,x2:e+f*r,y2:n+i})}return _.createElement("line",fm({},u,{className:nr("recharts-cartesian-axis-line",cm(l,"className"))}))}function bTe(t,e,n,r,i,a,o,l,c){var u,d,f,p,m,x,b=l?-1:1,v=t.tickSize||o,y=zt(t.tickCoord)?t.tickCoord:t.coordinate;switch(a){case"top":u=d=t.coordinate,p=n+ +!l*i,f=p-b*v,x=f-b*c,m=y;break;case"left":f=p=t.coordinate,d=e+ +!l*r,u=d-b*v,m=u-b*c,x=y;break;case"right":f=p=t.coordinate,d=e+ +l*r,u=d+b*v,m=u+b*c,x=y;break;default:u=d=t.coordinate,p=n+ +l*i,f=p+b*v,x=f+b*c,m=y;break}return{line:{x1:u,y1:f,x2:d,y2:p},tick:{x:m,y:x}}}function yTe(t,e){switch(t){case"left":return e?"start":"end";case"right":return e?"end":"start";default:return"middle"}}function vTe(t,e){switch(t){case"left":case"right":return"middle";case"top":return e?"start":"end";default:return e?"end":"start"}}function wTe(t){var{option:e,tickProps:n,value:r}=t,i,a=nr(n.className,"recharts-cartesian-axis-tick-value");if(_.isValidElement(e))i=_.cloneElement(e,Ii(Ii({},n),{},{className:a}));else if(typeof e=="function")i=e(Ii(Ii({},n),{},{className:a}));else{var o="recharts-cartesian-axis-tick-value";typeof e!="boolean"&&(o=nr(o,e?.className)),i=_.createElement(r2,fm({},n,{className:o}),r)}return i}var _Te=_.forwardRef((t,e)=>{var{ticks:n=[],tick:r,tickLine:i,stroke:a,tickFormatter:o,unit:l,padding:c,tickTextProps:u,orientation:d,mirror:f,x:p,y:m,width:x,height:b,tickSize:v,tickMargin:y,fontSize:S,letterSpacing:k,getTicksConfig:T,events:M,axisType:C}=t,E=R4(Ii(Ii({},T),{},{ticks:n}),S,k),R=yTe(d,f),A=vTe(d,f),D=xs(T),I=lm(r),F={};typeof i=="object"&&(F=i);var z=Ii(Ii({},D),{},{fill:"none"},F),P=E.map(V=>Ii({entry:V},bTe(V,p,m,x,b,d,v,f,y))),$=P.map(V=>{var{entry:Q,line:Z}=V;return _.createElement(li,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(Q.value,"-").concat(Q.coordinate,"-").concat(Q.tickCoord)},i&&_.createElement("line",fm({},z,Z,{className:nr("recharts-cartesian-axis-tick-line",cm(i,"className"))})))}),X=P.map((V,Q)=>{var{entry:Z,tick:se}=V,H=Ii(Ii(Ii(Ii({textAnchor:R,verticalAnchor:A},D),{},{stroke:"none",fill:a},I),se),{},{index:Q,payload:Z,visibleTicksCount:E.length,tickFormatter:o,padding:c},u);return _.createElement(li,fm({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(Z.value,"-").concat(Z.coordinate,"-").concat(Z.tickCoord)},By(M,Z,Q)),r&&_.createElement(wTe,{option:r,tickProps:H,value:"".concat(typeof o=="function"?o(Z.value,Q):Z.value).concat(l||"")}))});return _.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(C,"-ticks")},X.length>0&&_.createElement(ts,{zIndex:vi.label},_.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(C,"-tick-labels"),ref:e},X)),$.length>0&&_.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(C,"-tick-lines")},$))}),STe=_.forwardRef((t,e)=>{var{axisLine:n,width:r,height:i,className:a,hide:o,ticks:l,axisType:c}=t,u=hTe(t,dTe),[d,f]=_.useState(""),[p,m]=_.useState(""),x=_.useRef(null);_.useImperativeHandle(e,()=>({getCalculatedWidth:()=>{var v;return uTe({ticks:x.current,label:(v=t.labelRef)===null||v===void 0?void 0:v.current,labelGapWithTick:5,tickSize:t.tickSize,tickMargin:t.tickMargin})}}));var b=_.useCallback(v=>{if(v){var y=v.getElementsByClassName("recharts-cartesian-axis-tick-value");x.current=y;var S=y[0];if(S){var k=window.getComputedStyle(S),T=k.fontSize,M=k.letterSpacing;(T!==d||M!==p)&&(f(T),m(M))}}},[d,p]);return o||r!=null&&r<=0||i!=null&&i<=0?null:_.createElement(ts,{zIndex:t.zIndex},_.createElement(li,{className:nr("recharts-cartesian-axis",a)},_.createElement(xTe,{x:t.x,y:t.y,width:r,height:i,orientation:t.orientation,mirror:t.mirror,axisLine:n,otherSvgProps:xs(t)}),_.createElement(_Te,{ref:b,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(WQ,{x:t.x,y:t.y,width:t.width,height:t.height,lowerWidth:t.width,upperWidth:t.width},_.createElement(XQ,{label:t.label,labelRef:t.labelRef}),t.children)))}),O4=_.forwardRef((t,e)=>{var n=ci(t,Tu);return _.createElement(STe,fm({},n,{ref:e}))});O4.displayName="CartesianAxis";var NTe=["x1","y1","x2","y2","key"],MTe=["offset"],kTe=["xAxisId","yAxisId"],ETe=["xAxisId","yAxisId"];function t$(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 Qa(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?t$(Object(n),!0).forEach(function(r){TTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):t$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function TTe(t,e,n){return(e=ATe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function ATe(t){var e=CTe(t,"string");return typeof e=="symbol"?e:e+""}function CTe(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 Rf(){return Rf=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},Rf.apply(null,arguments)}function BS(t,e){if(t==null)return{};var n,r,i=PTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function PTe(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 jTe=t=>{var{fill:e}=t;if(!e||e==="none")return null;var{fillOpacity:n,x:r,y:i,width:a,height:o,ry:l}=t;return _.createElement("rect",{x:r,y:i,ry:l,width:a,height:o,stroke:"none",fill:e,fillOpacity:n,className:"recharts-cartesian-grid-bg"})};function vZ(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:a,y1:o,x2:l,y2:c,key:u}=n,d=BS(n,NTe),f=(i=xs(d))!==null&&i!==void 0?i:{},{offset:p}=f,m=BS(f,MTe);r=_.createElement("line",Rf({},m,{x1:a,y1:o,x2:l,y2:c,fill:"none",key:u}))}return r}function DTe(t){var{x:e,width:n,horizontal:r=!0,horizontalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=t,l=BS(t,kTe),c=i.map((u,d)=>{var f=Qa(Qa({},l),{},{x1:e,y1:u,x2:e+n,y2:u,key:"line-".concat(d),index:d});return _.createElement(vZ,{key:"line-".concat(d),option:r,lineItemProps:f})});return _.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function RTe(t){var{y:e,height:n,vertical:r=!0,verticalPoints:i}=t;if(!r||!i||!i.length)return null;var{xAxisId:a,yAxisId:o}=t,l=BS(t,ETe),c=i.map((u,d)=>{var f=Qa(Qa({},l),{},{x1:u,y1:e,x2:u,y2:e+n,key:"line-".concat(d),index:d});return _.createElement(vZ,{option:r,lineItemProps:f,key:"line-".concat(d)})});return _.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function OTe(t){var{horizontalFill:e,fillOpacity:n,x:r,y:i,width:a,height:o,horizontalPoints:l,horizontal:c=!0}=t;if(!c||!e||!e.length||l==null)return null;var u=l.map(f=>Math.round(f+i-i)).sort((f,p)=>f-p);i!==u[0]&&u.unshift(0);var d=u.map((f,p)=>{var m=!u[p+1],x=m?i+o-f:u[p+1]-f;if(x<=0)return null;var b=p%e.length;return _.createElement("rect",{key:"react-".concat(p),y:f,x:r,height:x,width:a,stroke:"none",fill:e[b],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return _.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},d)}function LTe(t){var{vertical:e=!0,verticalFill:n,fillOpacity:r,x:i,y:a,width:o,height:l,verticalPoints:c}=t;if(!e||!n||!n.length)return null;var u=c.map(f=>Math.round(f+i-i)).sort((f,p)=>f-p);i!==u[0]&&u.unshift(0);var d=u.map((f,p)=>{var m=!u[p+1],x=m?i+o-f:u[p+1]-f;if(x<=0)return null;var b=p%n.length;return _.createElement("rect",{key:"react-".concat(p),x:f,y:a,width:x,height:l,stroke:"none",fill:n[b],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return _.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},d)}var FTe=(t,e)=>{var{xAxis:n,width:r,height:i,offset:a}=t;return rX(R4(Qa(Qa(Qa({},Tu),n),{},{ticks:iX(n),viewBox:{x:0,y:0,width:r,height:i}})),a.left,a.left+a.width,e)},ITe=(t,e)=>{var{yAxis:n,width:r,height:i,offset:a}=t;return rX(R4(Qa(Qa(Qa({},Tu),n),{},{ticks:iX(n),viewBox:{x:0,y:0,width:r,height:i}})),a.top,a.top+a.height,e)},UTe={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:vi.grid};function HS(t){var e=oO(),n=lO(),r=fX(),i=Qa(Qa({},ci(t,UTe)),{},{x:zt(t.x)?t.x:r.left,y:zt(t.y)?t.y:r.top,width:zt(t.width)?t.width:r.width,height:zt(t.height)?t.height:r.height}),{xAxisId:a,yAxisId:o,x:l,y:c,width:u,height:d,syncWithTicks:f,horizontalValues:p,verticalValues:m}=i,x=ia(),b=It(A=>$6(A,"xAxis",a,x)),v=It(A=>$6(A,"yAxis",o,x));if(!gc(u)||!gc(d)||!zt(l)||!zt(c))return null;var y=i.verticalCoordinatesGenerator||FTe,S=i.horizontalCoordinatesGenerator||ITe,{horizontalPoints:k,verticalPoints:T}=i;if((!k||!k.length)&&typeof S=="function"){var M=p&&p.length,C=S({yAxis:v?Qa(Qa({},v),{},{ticks:M?p:v.ticks}):void 0,width:e??u,height:n??d,offset:r},M?!0:f);dS(Array.isArray(C),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof C,"]")),Array.isArray(C)&&(k=C)}if((!T||!T.length)&&typeof y=="function"){var E=m&&m.length,R=y({xAxis:b?Qa(Qa({},b),{},{ticks:E?m:b.ticks}):void 0,width:e??u,height:n??d,offset:r},E?!0:f);dS(Array.isArray(R),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof R,"]")),Array.isArray(R)&&(T=R)}return _.createElement(ts,{zIndex:i.zIndex},_.createElement("g",{className:"recharts-cartesian-grid"},_.createElement(jTe,{fill:i.fill,fillOpacity:i.fillOpacity,x:i.x,y:i.y,width:i.width,height:i.height,ry:i.ry}),_.createElement(OTe,Rf({},i,{horizontalPoints:k})),_.createElement(LTe,Rf({},i,{verticalPoints:T})),_.createElement(DTe,Rf({},i,{offset:r,horizontalPoints:k,xAxis:b,yAxis:v})),_.createElement(RTe,Rf({},i,{offset:r,verticalPoints:T,xAxis:b,yAxis:v}))))}HS.displayName="CartesianGrid";var wZ=(t,e,n,r)=>yc(t,"xAxis",e,r),_Z=(t,e,n,r)=>bc(t,"xAxis",e,r),SZ=(t,e,n,r)=>yc(t,"yAxis",n,r),NZ=(t,e,n,r)=>bc(t,"yAxis",n,r),zTe=it([$n,wZ,SZ,_Z,NZ],(t,e,n,r,i)=>Ec(t,"xAxis")?wh(e,r,!1):wh(n,i,!1)),BTe=(t,e,n,r,i)=>i;function HTe(t){return t.type==="line"}var $Te=it([nv,BTe],(t,e)=>t.filter(HTe).find(n=>n.id===e)),VTe=it([$n,wZ,SZ,_Z,NZ,$Te,zTe,Zy],(t,e,n,r,i,a,o,l)=>{var{chartData:c,dataStartIndex:u,dataEndIndex:d}=l;if(!(a==null||e==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||t!=="horizontal"&&t!=="vertical")){var{dataKey:f,data:p}=a,m;if(p!=null&&p.length>0?m=p:m=c?.slice(u,d+1),m!=null)return uAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:f,bandSize:o,displayedData:m})}});function MZ(t){var e=lm(t),n=3,r=2;if(e!=null){var{r:i,strokeWidth:a}=e,o=Number(i),l=Number(a);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 GTe=["id"],qTe=["type","layout","connectNulls","needClip","shape"],WTe=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function uy(){return uy=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},uy.apply(null,arguments)}function n$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function nc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?n$(Object(n),!0).forEach(function(r){KTe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):n$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function KTe(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=YTe(t,"string");return typeof e=="symbol"?e:e+""}function YTe(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 L4(t,e){if(t==null)return{};var n,r,i=QTe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function QTe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var ZTe=t=>{var{dataKey:e,name:n,stroke:r,legendType:i,hide:a}=t;return[{inactive:a,dataKey:e,type:i,color:r,value:Lh(n,e),payload:t}]},JTe=_.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Lh(o,e),hide:l,type:u,color:r,unit:c}};return _.createElement(o2,{tooltipEntrySettings:d})}),kZ=(t,e)=>"".concat(e,"px ").concat(t-e,"px");function eAe(t,e){for(var n=t.length%2!==0?[...t,0]:t,r=[],i=0;i<e;++i)r=[...r,...n];return r}var tAe=(t,e,n)=>{var r=n.reduce((f,p)=>f+p);if(!r)return kZ(e,t);for(var i=Math.floor(t/r),a=t%r,o=e-t,l=[],c=0,u=0;c<n.length;u+=n[c],++c)if(u+n[c]>a){l=[...n.slice(0,c),a-u];break}var d=l.length%2===0?[0,o]:[o];return[...eAe(n,i),...l,...d].map(f=>"".concat(f,"px")).join(", ")};function nAe(t){var{clipPathId:e,points:n,props:r}=t,{dot:i,dataKey:a,needClip:o}=r,{id:l}=r,c=L4(r,GTe),u=xs(c);return _.createElement(oZ,{points:n,dot:i,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:a,baseProps:u,needClip:o,clipPathId:e})}function rAe(t){var{showLabels:e,children:n,points:r}=t,i=_.useMemo(()=>r?.map(a=>{var o,l,c={x:(o=a.x)!==null&&o!==void 0?o:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return nc(nc({},c),{},{value:a.value,payload:a.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[r]);return _.createElement(_4,{value:e?i:void 0},n)}function r$(t){var{clipPathId:e,pathRef:n,points:r,strokeDasharray:i,props:a}=t,{type:o,layout:l,connectNulls:c,needClip:u,shape:d}=a,f=L4(a,qTe),p=nc(nc({},Ba(f)),{},{fill:"none",className:"recharts-line-curve",clipPath:u?"url(#clipPath-".concat(e,")"):void 0,points:r,type:o,layout:l,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return _.createElement(_.Fragment,null,r?.length>1&&_.createElement(E4,uy({shapeType:"curve",option:d},p,{pathRef:n})),_.createElement(nAe,{points:r,clipPathId:e,props:a}))}function iAe(t){try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}function aAe(t){var{clipPathId:e,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=t,{points:o,strokeDasharray:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,animateNewValues:p,width:m,height:x,onAnimationEnd:b,onAnimationStart:v}=n,y=i.current,S=wx(o,"recharts-line-"),k=_.useRef(S),[T,M]=_.useState(!1),C=!T,E=_.useCallback(()=>{typeof b=="function"&&b(),M(!1)},[b]),R=_.useCallback(()=>{typeof v=="function"&&v(),M(!0)},[v]),A=iAe(r.current),D=_.useRef(0);k.current!==S&&(D.current=a.current,k.current=S);var I=D.current;return _.createElement(rAe,{points:o,showLabels:C},n.children,_.createElement(vx,{animationId:S,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:E,onAnimationStart:R,key:S},F=>{var z=mr(I,A+I,F),P=Math.min(z,A),$;if(c)if(l){var X="".concat(l).split(/[,\s]+/gim).map(Z=>parseFloat(Z));$=tAe(P,A,X)}else $=kZ(A,P);else $=l==null?void 0:String(l);if(F>0&&A>0&&(i.current=o,a.current=Math.max(a.current,P)),y){var V=y.length/o.length,Q=F===1?o:o.map((Z,se)=>{var H=Math.floor(se*V);if(y[H]){var K=y[H];return nc(nc({},Z),{},{x:mr(K.x,Z.x,F),y:mr(K.y,Z.y,F)})}return p?nc(nc({},Z),{},{x:mr(m*2,Z.x,F),y:mr(x/2,Z.y,F)}):nc(nc({},Z),{},{x:Z.x,y:Z.y})});return i.current=Q,_.createElement(r$,{props:n,points:Q,clipPathId:e,pathRef:r,strokeDasharray:$})}return _.createElement(r$,{props:n,points:o,clipPathId:e,pathRef:r,strokeDasharray:$})}),_.createElement(i2,{label:n.label}))}function sAe(t){var{clipPathId:e,props:n}=t,r=_.useRef(null),i=_.useRef(0),a=_.useRef(null);return _.createElement(aAe,{props:n,clipPathId:e,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var oAe=(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 lAe extends _.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:l,left:c,width:u,height:d,id:f,needClip:p,zIndex:m}=this.props;if(e)return null;var x=nr("recharts-line",i),b=f,{r:v,strokeWidth:y}=MZ(n),S=k4(n),k=v*2+y,T=p?"url(#clipPath-".concat(S?"":"dots-").concat(b,")"):void 0;return _.createElement(ts,{zIndex:m},_.createElement(li,{className:x},p&&_.createElement("defs",null,_.createElement(D4,{clipPathId:b,xAxisId:a,yAxisId:o}),!S&&_.createElement("clipPath",{id:"clipPath-dots-".concat(b)},_.createElement("rect",{x:c-k/2,y:l-k/2,width:u+k,height:d+k}))),_.createElement(uZ,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:oAe,errorBarOffset:0},_.createElement(sAe,{props:this.props,clipPathId:b}))),_.createElement(g3,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:T}))}}var EZ={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 cAe(t){var e=ci(t,EZ),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,hide:u,isAnimationActive:d,label:f,legendType:p,xAxisId:m,yAxisId:x,id:b}=e,v=L4(e,WTe),{needClip:y}=d2(m,x),S=u2(),k=Em(),T=ia(),M=It(D=>VTe(D,m,x,T,b));if(k!=="horizontal"&&k!=="vertical"||M==null||S==null)return null;var{height:C,width:E,x:R,y:A}=S;return _.createElement(lAe,uy({},v,{id:b,connectNulls:l,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:d,hide:u,label:f,legendType:p,xAxisId:m,yAxisId:x,points:M,layout:k,height:C,width:E,left:R,top:A,needClip:y}))}function uAe(t){var{layout:e,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:l,displayedData:c}=t;return c.map((u,d)=>{var f=yr(u,o);if(e==="horizontal"){var p=uS({axis:n,ticks:i,bandSize:l,entry:u,index:d}),m=Yr(f)?null:r.scale(f);return{x:p,y:m,value:f,payload:u}}var x=Yr(f)?null:n.scale(f),b=uS({axis:r,ticks:a,bandSize:l,entry:u,index:d});return x==null||b==null?null:{x,y:b,value:f,payload:u}}).filter(Boolean)}function dAe(t){var e=ci(t,EZ),n=ia();return _.createElement(l2,{id:e.id,type:"line"},r=>_.createElement(_.Fragment,null,_.createElement(P4,{legendPayload:ZTe(e)}),_.createElement(JTe,{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(j4,{type:"line",id:r,data:e.data,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,dataKey:e.dataKey,hide:e.hide,isPanorama:n}),_.createElement(cAe,uy({},e,{id:r}))))}var TZ=_.memo(dAe,dv);TZ.displayName="Line";var AZ=(t,e,n,r)=>yc(t,"xAxis",e,r),CZ=(t,e,n,r)=>bc(t,"xAxis",e,r),PZ=(t,e,n,r)=>yc(t,"yAxis",n,r),jZ=(t,e,n,r)=>bc(t,"yAxis",n,r),hAe=it([$n,AZ,PZ,CZ,jZ],(t,e,n,r,i)=>Ec(t,"xAxis")?wh(e,r,!1):wh(n,i,!1)),fAe=(t,e,n,r,i)=>i,DZ=it([nv,fAe],(t,e)=>t.filter(n=>n.type==="area").find(n=>n.id===e)),mAe=(t,e,n,r,i)=>{var a,o=DZ(t,e,n,r,i);if(o!=null){var l=$n(t),c=Ec(l,"xAxis"),u;if(c?u=ly(t,"yAxis",n,r):u=ly(t,"xAxis",e,r),u!=null){var{stackId:d}=o,f=KM(o);if(!(d==null||f==null)){var p=(a=u[d])===null||a===void 0?void 0:a.stackedData;return p?.find(m=>m.key===f)}}}},pAe=it([$n,AZ,PZ,CZ,jZ,mAe,Zy,hAe,DZ,$we],(t,e,n,r,i,a,o,l,c,u)=>{var{chartData:d,dataStartIndex:f,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(f,p+1),x!=null)return RAe({layout:t,xAxis:e,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:x,chartBaseValue:u,bandSize:l})}}),gAe=["id"],xAe=["activeDot","animationBegin","animationDuration","animationEasing","connectNulls","dot","fill","fillOpacity","hide","isAnimationActive","legendType","stroke","xAxisId","yAxisId"];function Gf(){return Gf=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},Gf.apply(null,arguments)}function RZ(t,e){if(t==null)return{};var n,r,i=bAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function bAe(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 i$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function xg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?i$(Object(n),!0).forEach(function(r){yAe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function yAe(t,e,n){return(e=vAe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function vAe(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)}function $S(t,e){return t&&t!=="none"?t:e}var _Ae=t=>{var{dataKey:e,name:n,stroke:r,fill:i,legendType:a,hide:o}=t;return[{inactive:o,dataKey:e,type:a,color:$S(r,i),value:Lh(n,e),payload:t}]},SAe=_.memo(t=>{var{dataKey:e,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:l,unit:c,tooltipType:u}=t,d={dataDefinedOnItem:n,positions:void 0,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:e,nameKey:void 0,name:Lh(o,e),hide:l,type:u,color:$S(r,a),unit:c}};return _.createElement(o2,{tooltipEntrySettings:d})});function NAe(t){var{clipPathId:e,points:n,props:r}=t,{needClip:i,dot:a,dataKey:o}=r,l=xs(r);return _.createElement(oZ,{points:n,dot:a,className:"recharts-area-dots",dotClassName:"recharts-area-dot",dataKey:o,baseProps:l,needClip:i,clipPathId:e})}function MAe(t){var{showLabels:e,children:n,points:r}=t,i=r.map(a=>{var o,l,c={x:(o=a.x)!==null&&o!==void 0?o:0,y:(l=a.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return xg(xg({},c),{},{value:a.value,payload:a.payload,parentViewBox:void 0,viewBox:c,fill:void 0})});return _.createElement(_4,{value:e?i:void 0},n)}function a$(t){var{points:e,baseLine:n,needClip:r,clipPathId:i,props:a}=t,{layout:o,type:l,stroke:c,connectNulls:u,isRange:d}=a,{id:f}=a,p=RZ(a,gAe),m=xs(p),x=Ba(p);return _.createElement(_.Fragment,null,e?.length>1&&_.createElement(li,{clipPath:r?"url(#clipPath-".concat(i,")"):void 0},_.createElement(kg,Gf({},x,{id:f,points:e,connectNulls:u,type:l,baseLine:n,layout:o,stroke:"none",className:"recharts-area-area"})),c!=="none"&&_.createElement(kg,Gf({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:e})),c!=="none"&&d&&_.createElement(kg,Gf({},m,{className:"recharts-area-curve",layout:o,type:l,connectNulls:u,fill:"none",points:n}))),_.createElement(NAe,{points:e,props:p,clipPathId:i}))}function kAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].y,o=r[r.length-1].y;if(!vr(a)||!vr(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.x||0));return zt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.x||0),c)),zt(c)?_.createElement("rect",{x:0,y:a<o?a:a-l,width:c+(i?parseInt("".concat(i),10):1),height:Math.floor(l)}):null}function EAe(t){var{alpha:e,baseLine:n,points:r,strokeWidth:i}=t,a=r[0].x,o=r[r.length-1].x;if(!vr(a)||!vr(o))return null;var l=e*Math.abs(a-o),c=Math.max(...r.map(u=>u.y||0));return zt(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(u=>u.y||0),c)),zt(c)?_.createElement("rect",{x:a<o?a:a-l,y:0,width:l,height:Math.floor(c+(i?parseInt("".concat(i),10):1))}):null}function TAe(t){var{alpha:e,layout:n,points:r,baseLine:i,strokeWidth:a}=t;return n==="vertical"?_.createElement(kAe,{alpha:e,points:r,baseLine:i,strokeWidth:a}):_.createElement(EAe,{alpha:e,points:r,baseLine:i,strokeWidth:a})}function AAe(t){var{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a}=t,{points:o,baseLine:l,isAnimationActive:c,animationBegin:u,animationDuration:d,animationEasing:f,onAnimationStart:p,onAnimationEnd:m}=r,x=_.useMemo(()=>({points:o,baseLine:l}),[o,l]),b=wx(x,"recharts-area-"),v=obe(),[y,S]=_.useState(!1),k=!y,T=_.useCallback(()=>{typeof m=="function"&&m(),S(!1)},[m]),M=_.useCallback(()=>{typeof p=="function"&&p(),S(!0)},[p]);if(v==null)return null;var C=i.current,E=a.current;return _.createElement(MAe,{showLabels:k,points:o},r.children,_.createElement(vx,{animationId:b,begin:u,duration:d,isActive:c,easing:f,onAnimationEnd:T,onAnimationStart:M,key:b},R=>{if(C){var A=C.length/o.length,D=R===1?o:o.map((F,z)=>{var P=Math.floor(z*A);if(C[P]){var $=C[P];return xg(xg({},F),{},{x:mr($.x,F.x,R),y:mr($.y,F.y,R)})}return F}),I;return zt(l)?I=mr(E,l,R):Yr(l)||Hs(l)?I=mr(E,0,R):I=l.map((F,z)=>{var P=Math.floor(z*A);if(Array.isArray(E)&&E[P]){var $=E[P];return xg(xg({},F),{},{x:mr($.x,F.x,R),y:mr($.y,F.y,R)})}return F}),R>0&&(i.current=D,a.current=I),_.createElement(a$,{points:D,baseLine:I,needClip:e,clipPathId:n,props:r})}return R>0&&(i.current=o,a.current=l),_.createElement(li,null,c&&_.createElement("defs",null,_.createElement("clipPath",{id:"animationClipPath-".concat(n)},_.createElement(TAe,{alpha:R,points:o,baseLine:l,layout:v,strokeWidth:r.strokeWidth}))),_.createElement(li,{clipPath:"url(#animationClipPath-".concat(n,")")},_.createElement(a$,{points:o,baseLine:l,needClip:e,clipPathId:n,props:r})))}),_.createElement(i2,{label:r.label}))}function CAe(t){var{needClip:e,clipPathId:n,props:r}=t,i=_.useRef(null),a=_.useRef();return _.createElement(AAe,{needClip:e,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}class PAe extends _.PureComponent{render(){var{hide:e,dot:n,points:r,className:i,top:a,left:o,needClip:l,xAxisId:c,yAxisId:u,width:d,height:f,id:p,baseLine:m,zIndex:x}=this.props;if(e)return null;var b=nr("recharts-area",i),v=p,{r:y,strokeWidth:S}=MZ(n),k=k4(n),T=y*2+S,M=l?"url(#clipPath-".concat(k?"":"dots-").concat(v,")"):void 0;return _.createElement(ts,{zIndex:x},_.createElement(li,{className:b},l&&_.createElement("defs",null,_.createElement(D4,{clipPathId:v,xAxisId:c,yAxisId:u}),!k&&_.createElement("clipPath",{id:"clipPath-dots-".concat(v)},_.createElement("rect",{x:o-T/2,y:a-T/2,width:d+T,height:f+T}))),_.createElement(CAe,{needClip:l,clipPathId:v,props:this.props})),_.createElement(g3,{points:r,mainColor:$S(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:M}),this.props.isRange&&Array.isArray(m)&&_.createElement(g3,{points:m,mainColor:$S(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:M}))}}var OZ={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 jAe(t){var e,n=ci(t,OZ),{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:l,dot:c,fill:u,fillOpacity:d,hide:f,isAnimationActive:p,legendType:m,stroke:x,xAxisId:b,yAxisId:v}=n,y=RZ(n,xAe),S=Em(),k=CQ(),{needClip:T}=d2(b,v),M=ia(),{points:C,isRange:E,baseLine:R}=(e=It(P=>pAe(P,b,v,M,t.id)))!==null&&e!==void 0?e:{},A=u2();if(S!=="horizontal"&&S!=="vertical"||A==null||k!=="AreaChart"&&k!=="ComposedChart")return null;var{height:D,width:I,x:F,y:z}=A;return!C||!C.length?null:_.createElement(PAe,Gf({},y,{activeDot:r,animationBegin:i,animationDuration:a,animationEasing:o,baseLine:R,connectNulls:l,dot:c,fill:u,fillOpacity:d,height:D,hide:f,layout:S,isAnimationActive:p==="auto"?!yx.isSsr:p,isRange:E,legendType:m,needClip:T,points:C,stroke:x,width:I,left:F,top:z,xAxisId:b,yAxisId:v}))}var DAe=(t,e,n,r,i)=>{var a=n??e;if(zt(a))return a;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 a==="dataMin"?u:a==="dataMax"||c<0?c:Math.max(Math.min(l[0],l[1]),0)}return a==="dataMin"?l[0]:a==="dataMax"?l[1]:l[0]};function RAe(t){var{areaSettings:{connectNulls:e,baseValue:n,dataKey:r},stackedData:i,layout:a,chartBaseValue:o,xAxis:l,yAxis:c,displayedData:u,dataStartIndex:d,xAxisTicks:f,yAxisTicks:p,bandSize:m}=t,x=i&&i.length,b=DAe(a,o,n,l,c),v=a==="horizontal",y=!1,S=u.map((T,M)=>{var C;x?C=i[d+M]:(C=yr(T,r),Array.isArray(C)?y=!0:C=[b,C]);var E=C[1]==null||x&&!e&&yr(T,r)==null;return v?{x:uS({axis:l,ticks:f,bandSize:m,entry:T,index:M}),y:E?null:c.scale(C[1]),value:C,payload:T}:{x:E?null:l.scale(C[1]),y:uS({axis:c,ticks:p,bandSize:m,entry:T,index:M}),value:C,payload:T}}),k;return x||y?k=S.map(T=>{var M=Array.isArray(T.value)?T.value[0]:null;return v?{x:T.x,y:M!=null&&T.y!=null?c.scale(M):null,payload:T.payload}:{x:M!=null?l.scale(M):null,y:T.y,payload:T.payload}}):k=v?c.scale(b):l.scale(b),{points:S,baseLine:k,isRange:y}}function OAe(t){var e=ci(t,OZ),n=ia();return _.createElement(l2,{id:e.id,type:"area"},r=>_.createElement(_.Fragment,null,_.createElement(P4,{legendPayload:_Ae(e)}),_.createElement(SAe,{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(j4,{type:"area",id:r,data:e.data,dataKey:e.dataKey,xAxisId:e.xAxisId,yAxisId:e.yAxisId,zAxisId:0,stackId:aX(e.stackId),hide:e.hide,barSize:void 0,baseValue:e.baseValue,isPanorama:n,connectNulls:e.connectNulls}),_.createElement(jAe,Gf({},e,{id:r}))))}var LZ=_.memo(OAe,dv);LZ.displayName="Area";var LAe=["domain","range"],FAe=["domain","range"];function s$(t,e){if(t==null)return{};var n,r,i=IAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function IAe(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 o$(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 FZ(t,e){if(t===e)return!0;var{domain:n,range:r}=t,i=s$(t,LAe),{domain:a,range:o}=e,l=s$(e,FAe);return!o$(n,a)||!o$(r,o)?!1:dv(i,l)}var UAe=["dangerouslySetInnerHTML","ticks"],zAe=["id"];function b3(){return b3=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},b3.apply(null,arguments)}function l$(t,e){if(t==null)return{};var n,r,i=BAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function BAe(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 HAe(t){var e=Lr(),n=_.useRef(null);return _.useLayoutEffect(()=>{n.current===null?e(L2e(t)):n.current!==t&&e(F2e({prev:n.current,next:t})),n.current=t},[t,e]),_.useLayoutEffect(()=>()=>{n.current&&(e(I2e(n.current)),n.current=null)},[e]),null}var $Ae=t=>{var{xAxisId:e,className:n}=t,r=It(aO),i=ia(),a="xAxis",o=It(v=>Sh(v,a,e,i)),l=It(v=>lQ(v,a,e,i)),c=It(v=>iQ(v,e)),u=It(v=>z_e(v,e)),d=It(v=>UY(v,e));if(c==null||u==null||d==null)return null;var{dangerouslySetInnerHTML:f,ticks:p}=t,m=l$(t,UAe),{id:x}=d,b=l$(d,zAe);return _.createElement(O4,b3({},m,b,{scale:o,x:u.x,y:u.y,width:c.width,height:c.height,className:nr("recharts-".concat(a," ").concat(a),n),viewBox:r,ticks:l,axisType:a}))},VAe={allowDataOverflow:ma.allowDataOverflow,allowDecimals:ma.allowDecimals,allowDuplicatedCategory:ma.allowDuplicatedCategory,angle:ma.angle,axisLine:Tu.axisLine,height:ma.height,hide:!1,includeHidden:ma.includeHidden,interval:ma.interval,minTickGap:ma.minTickGap,mirror:ma.mirror,orientation:ma.orientation,padding:ma.padding,reversed:ma.reversed,scale:ma.scale,tick:ma.tick,tickCount:ma.tickCount,tickLine:Tu.tickLine,tickSize:Tu.tickSize,type:ma.type,xAxisId:0},GAe=t=>{var e=ci(t,VAe);return _.createElement(_.Fragment,null,_.createElement(HAe,{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($Ae,e))},VS=_.memo(GAe,FZ);VS.displayName="XAxis";var qAe=["dangerouslySetInnerHTML","ticks"],WAe=["id"];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 c$(t,e){if(t==null)return{};var n,r,i=KAe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function KAe(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 XAe(t){var e=Lr(),n=_.useRef(null);return _.useLayoutEffect(()=>{n.current===null?e(U2e(t)):n.current!==t&&e(z2e({prev:n.current,next:t})),n.current=t},[t,e]),_.useLayoutEffect(()=>()=>{n.current&&(e(B2e(n.current)),n.current=null)},[e]),null}var YAe=t=>{var{yAxisId:e,className:n,width:r,label:i}=t,a=_.useRef(null),o=_.useRef(null),l=It(aO),c=ia(),u=Lr(),d="yAxis",f=It(M=>Sh(M,d,e,c)),p=It(M=>aQ(M,e)),m=It(M=>H_e(M,e)),x=It(M=>lQ(M,d,e,c)),b=It(M=>zY(M,e));if(_.useLayoutEffect(()=>{if(!(r!=="auto"||!p||w4(i)||_.isValidElement(i)||b==null)){var M=a.current;if(M){var C=M.getCalculatedWidth();Math.round(p.width)!==Math.round(C)&&u(H2e({id:e,width:C}))}}},[x,p,u,i,e,r,b]),p==null||m==null||b==null)return null;var{dangerouslySetInnerHTML:v,ticks:y}=t,S=c$(t,qAe),{id:k}=b,T=c$(b,WAe);return _.createElement(O4,y3({},S,T,{ref:a,labelRef:o,scale:f,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}))},QAe={allowDataOverflow:pa.allowDataOverflow,allowDecimals:pa.allowDecimals,allowDuplicatedCategory:pa.allowDuplicatedCategory,angle:pa.angle,axisLine:Tu.axisLine,hide:!1,includeHidden:pa.includeHidden,interval:pa.interval,minTickGap:pa.minTickGap,mirror:pa.mirror,orientation:pa.orientation,padding:pa.padding,reversed:pa.reversed,scale:pa.scale,tick:pa.tick,tickCount:pa.tickCount,tickLine:Tu.tickLine,tickSize:Tu.tickSize,type:pa.type,width:pa.width,yAxisId:0},ZAe=t=>{var e=ci(t,QAe);return _.createElement(_.Fragment,null,_.createElement(XAe,{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(YAe,e))},GS=_.memo(ZAe,FZ);GS.displayName="YAxis";var JAe=(t,e)=>e,F4=it([JAe,$n,FY,sa,NQ,Xu,rSe,ra],uSe),I4=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)}},IZ=ul("mouseClick"),UZ=Vy();UZ.startListening({actionCreator:IZ,effect:(t,e)=>{var n=t.payload,r=F4(e.getState(),I4(n));r?.activeIndex!=null&&e.dispatch(n1e({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var v3=ul("mouseMove"),zZ=Vy(),Zw=null;zZ.startListening({actionCreator:v3,effect:(t,e)=>{var n=t.payload;Zw!==null&&cancelAnimationFrame(Zw);var r=I4(n);Zw=requestAnimationFrame(()=>{var i=e.getState(),a=u4(i,i.tooltip.settings.shared);if(a==="axis"){var o=F4(i,r);o?.activeIndex!=null?e.dispatch(gQ({activeIndex:o.activeIndex,activeDataKey:void 0,activeCoordinate:o.activeCoordinate})):e.dispatch(pQ())}Zw=null})}});var u$={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},BZ=$s({name:"rootProps",initialState:u$,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:u$.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}}}),eCe=BZ.reducer,{updateOptions:tCe}=BZ.actions,HZ=$s({name:"polarOptions",initialState:null,reducers:{updatePolarOptions:(t,e)=>e.payload}}),{updatePolarOptions:nCe}=HZ.actions,rCe=HZ.reducer,$Z=ul("keyDown"),VZ=ul("focus"),U4=Vy();U4.startListening({actionCreator:$Z,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip,a=t.payload;if(!(a!=="ArrowRight"&&a!=="ArrowLeft"&&a!=="Enter")){var o=d4(i,Ax(n),iv(n),lv(n)),l=o==null?-1:Number(o);if(!(!Number.isFinite(l)||l<0)){var c=Xu(n);if(a==="Enter"){var u=jS(n,"axis","hover",String(i.index));e.dispatch(u3({active:!i.active,activeIndex:i.index,activeDataKey:i.dataKey,activeCoordinate:u}));return}var d=q_e(n),f=d==="left-to-right"?1:-1,p=a==="ArrowRight"?1:-1,m=l+p*f;if(!(c==null||m>=c.length||m<0)){var x=jS(n,"axis","hover",String(m));e.dispatch(u3({active:!0,activeIndex:m.toString(),activeDataKey:void 0,activeCoordinate:x}))}}}}}});U4.startListening({actionCreator:VZ,effect:(t,e)=>{var n=e.getState(),r=n.rootProps.accessibilityLayer!==!1;if(r){var{keyboardInteraction:i}=n.tooltip;if(!i.active&&i.index==null){var a="0",o=jS(n,"axis","hover",String(a));e.dispatch(u3({activeDataKey:void 0,active:!0,activeIndex:a,activeCoordinate:o}))}}}});var Uo=ul("externalEvent"),GZ=Vy(),FA=new Map;GZ.startListening({actionCreator:Uo,effect:(t,e)=>{var{handler:n,reactEvent:r}=t.payload;if(n!=null){r.persist();var i=r.type,a=FA.get(i);a!==void 0&&cancelAnimationFrame(a);var o=requestAnimationFrame(()=>{try{var l=e.getState(),c={activeCoordinate:H1e(l),activeDataKey:g4(l),activeIndex:Nh(l),activeLabel:EQ(l),activeTooltipIndex:Nh(l),isTooltipActive:$1e(l)};n(c,r)}finally{FA.delete(i)}});FA.set(i,o)}}});var iCe=it([Tx],t=>t.tooltipItemPayloads),aCe=it([iCe,sv,(t,e,n)=>e,(t,e,n)=>n],(t,e,n,r)=>{var i=t.find(l=>l.settings.dataKey===r);if(i!=null){var{positions:a}=i;if(a!=null){var o=e(a,n);return o}}}),qZ=ul("touchMove"),WZ=Vy();WZ.startListening({actionCreator:qZ,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 a=F4(r,I4({clientX:n.touches[0].clientX,clientY:n.touches[0].clientY,currentTarget:n.currentTarget}));a?.activeIndex!=null&&e.dispatch(gQ({activeIndex:a.activeIndex,activeDataKey:void 0,activeCoordinate:a.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(oX),d=(o=c.getAttribute(lX))!==null&&o!==void 0?o:void 0,f=aCe(e.getState(),u,d);e.dispatch(mQ({activeDataKey:d,activeIndex:u,activeCoordinate:f}))}}}});var sCe=TK({brush:CEe,cartesianAxis:$2e,chartData:BSe,errorBars:lke,graphicalItems:YMe,layout:mxe,legend:_be,options:LSe,polarAxis:dMe,polarOptions:rCe,referenceElements:BEe,rootProps:eCe,tooltip:r1e,zIndex:NSe}),oCe=function(e){return Uge({reducer:sCe,preloadedState:e,middleware:n=>{var r;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((r="es6")!==null&&r!==void 0?r:"")}).concat([UZ.middleware,zZ.middleware,U4.middleware,GZ.middleware,WZ.middleware])},enhancers:n=>{var r=n;return typeof n=="function"&&(r=n()),r.concat($K({type:"raf"}))},devTools:yx.devToolsEnabled})};function KZ(t){var{preloadedState:e,children:n,reduxStoreName:r}=t,i=ia(),a=_.useRef(null);if(i)return n;a.current==null&&(a.current=oCe(e));var o=YR;return _.createElement(jke,{context:o,store:a.current},n)}function lCe(t){var{layout:e,margin:n}=t,r=Lr(),i=ia();return _.useEffect(()=>{i||(r(dxe(e)),r(uxe(n)))},[r,i,e,n]),null}var XZ=_.memo(lCe,dv);function YZ(t){var e=Lr();return _.useEffect(()=>{e(tCe(t))},[e,t]),null}function d$(t){var{zIndex:e,isPanorama:n}=t,r=n?"recharts-zindex-panorama-":"recharts-zindex-",i=iZ("".concat(r).concat(e)),a=Lr();return _.useLayoutEffect(()=>(a(_Se({zIndex:e,elementId:i,isPanorama:n})),()=>{a(SSe({zIndex:e,isPanorama:n}))}),[a,e,i,n]),_.createElement("g",{tabIndex:-1,id:i})}function h$(t){var{children:e,isPanorama:n}=t,r=It(hSe);if(!r||r.length===0)return e;var i=r.filter(o=>o<0),a=r.filter(o=>o>0);return _.createElement(_.Fragment,null,i.map(o=>_.createElement(d$,{key:o,zIndex:o,isPanorama:n})),e,a.map(o=>_.createElement(d$,{key:o,zIndex:o,isPanorama:n})))}var cCe=["children"];function uCe(t,e){if(t==null)return{};var n,r,i=dCe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function dCe(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function qS(){return qS=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},qS.apply(null,arguments)}var hCe={width:"100%",height:"100%",display:"block"},fCe=_.forwardRef((t,e)=>{var n=oO(),r=lO(),i=NX();if(!gc(n)||!gc(r))return null;var{children:a,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(zR,qS({},o,{title:l,desc:c,role:d,tabIndex:u,width:n,height:r,style:hCe,ref:e}),a)}),mCe=t=>{var{children:e}=t,n=It(OM);if(!n)return null;var{width:r,height:i,y:a,x:o}=n;return _.createElement(zR,{width:r,height:i,x:o,y:a},e)},f$=_.forwardRef((t,e)=>{var{children:n}=t,r=uCe(t,cCe),i=ia();return i?_.createElement(mCe,null,_.createElement(h$,{isPanorama:!0},n)):_.createElement(fCe,qS({ref:e},r),_.createElement(h$,{isPanorama:!1},n))});function pCe(){var t=Lr(),[e,n]=_.useState(null),r=It(Pxe);return _.useEffect(()=>{if(e!=null){var i=e.getBoundingClientRect(),a=i.width/e.offsetWidth;vr(a)&&a!==r&&t(fxe(a))}},[e,t,r]),n}function m$(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function gCe(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?m$(Object(n),!0).forEach(function(r){xCe(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):m$(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function xCe(t,e,n){return(e=bCe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function bCe(t){var e=yCe(t,"string");return typeof e=="symbol"?e:e+""}function yCe(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 mm(){return mm=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},mm.apply(null,arguments)}var vCe=()=>(YSe(),null);function WS(t){if(typeof t=="number")return t;if(typeof t=="string"){var e=parseFloat(t);if(!Number.isNaN(e))return e}return 0}var wCe=_.forwardRef((t,e)=>{var n,r,i=_.useRef(null),[a,o]=_.useState({containerWidth:WS((n=t.style)===null||n===void 0?void 0:n.width),containerHeight:WS((r=t.style)===null||r===void 0?void 0:r.height)}),l=_.useCallback((u,d)=>{o(f=>{var p=Math.round(u),m=Math.round(d);return f.containerWidth===p&&f.containerHeight===m?f:{containerWidth:p,containerHeight:m}})},[]),c=_.useCallback(u=>{if(typeof e=="function"&&e(u),u!=null&&typeof ResizeObserver<"u"){var{width:d,height:f}=u.getBoundingClientRect();l(d,f);var p=x=>{var{width:b,height:v}=x[0].contentRect;l(b,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(LM,{width:a.containerWidth,height:a.containerHeight}),_.createElement("div",mm({ref:c},t)))}),_Ce=_.forwardRef((t,e)=>{var{width:n,height:r}=t,[i,a]=_.useState({containerWidth:WS(n),containerHeight:WS(r)}),o=_.useCallback((c,u)=>{a(d=>{var f=Math.round(c),p=Math.round(u);return d.containerWidth===f&&d.containerHeight===p?d:{containerWidth:f,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(LM,{width:i.containerWidth,height:i.containerHeight}),_.createElement("div",mm({ref:l},t)))}),SCe=_.forwardRef((t,e)=>{var{width:n,height:r}=t;return _.createElement(_.Fragment,null,_.createElement(LM,{width:n,height:r}),_.createElement("div",mm({ref:e},t)))}),NCe=_.forwardRef((t,e)=>{var{width:n,height:r}=t;return Lu(n)||Lu(r)?_.createElement(_Ce,mm({},t,{ref:e})):_.createElement(SCe,mm({},t,{ref:e}))});function MCe(t){return t===!0?wCe:NCe}var kCe=_.forwardRef((t,e)=>{var{children:n,className:r,height:i,onClick:a,onContextMenu:o,onDoubleClick:l,onMouseDown:c,onMouseEnter:u,onMouseLeave:d,onMouseMove:f,onMouseUp:p,onTouchEnd:m,onTouchMove:x,onTouchStart:b,style:v,width:y,responsive:S,dispatchTouchEvents:k=!0}=t,T=_.useRef(null),M=Lr(),[C,E]=_.useState(null),[R,A]=_.useState(null),D=pCe(),I=sO(),F=I?.width>0?I.width:y,z=I?.height>0?I.height:i,P=_.useCallback(ie=>{D(ie),typeof e=="function"&&e(ie),E(ie),A(ie),ie!=null&&(T.current=ie)},[D,e,E,A]),$=_.useCallback(ie=>{M(IZ(ie)),M(Uo({handler:a,reactEvent:ie}))},[M,a]),X=_.useCallback(ie=>{M(v3(ie)),M(Uo({handler:u,reactEvent:ie}))},[M,u]),V=_.useCallback(ie=>{M(pQ()),M(Uo({handler:d,reactEvent:ie}))},[M,d]),Q=_.useCallback(ie=>{M(v3(ie)),M(Uo({handler:f,reactEvent:ie}))},[M,f]),Z=_.useCallback(()=>{M(VZ())},[M]),se=_.useCallback(ie=>{M($Z(ie.key))},[M]),H=_.useCallback(ie=>{M(Uo({handler:o,reactEvent:ie}))},[M,o]),K=_.useCallback(ie=>{M(Uo({handler:l,reactEvent:ie}))},[M,l]),re=_.useCallback(ie=>{M(Uo({handler:c,reactEvent:ie}))},[M,c]),ne=_.useCallback(ie=>{M(Uo({handler:p,reactEvent:ie}))},[M,p]),be=_.useCallback(ie=>{M(Uo({handler:b,reactEvent:ie}))},[M,b]),me=_.useCallback(ie=>{k&&M(qZ(ie)),M(Uo({handler:x,reactEvent:ie}))},[M,k,x]),de=_.useCallback(ie=>{M(Uo({handler:m,reactEvent:ie}))},[M,m]),Ce=MCe(S);return _.createElement(OQ.Provider,{value:C},_.createElement($W.Provider,{value:R},_.createElement(Ce,{width:F??v?.width,height:z??v?.height,className:nr("recharts-wrapper",r),style:gCe({position:"relative",cursor:"default",width:F,height:z},v),onClick:$,onContextMenu:H,onDoubleClick:K,onFocus:Z,onKeyDown:se,onMouseDown:re,onMouseEnter:X,onMouseLeave:V,onMouseMove:Q,onMouseUp:ne,onTouchEnd:de,onTouchMove:me,onTouchStart:be,ref:P},_.createElement(vCe,null),n)))}),ECe=["width","height","responsive","children","className","style","compact","title","desc"];function TCe(t,e){if(t==null)return{};var n,r,i=ACe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function ACe(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 QZ=_.forwardRef((t,e)=>{var{width:n,height:r,responsive:i,children:a,className:o,style:l,compact:c,title:u,desc:d}=t,f=TCe(t,ECe),p=xs(f);return c?_.createElement(_.Fragment,null,_.createElement(LM,{width:n,height:r}),_.createElement(f$,{otherAttributes:p,title:u,desc:d},a)):_.createElement(kCe,{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(f$,{otherAttributes:p,title:u,desc:d,ref:e},_.createElement(HEe,null,a)))});function w3(){return w3=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},w3.apply(null,arguments)}var CCe={top:5,right:5,bottom:5,left:5},PCe={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:CCe,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},z4=_.forwardRef(function(e,n){var r,i=ci(e.categoricalChartProps,PCe),{chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:u}=e,d={chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return _.createElement(KZ,{preloadedState:{options:d},reduxStoreName:(r=u.id)!==null&&r!==void 0?r:a},_.createElement(mZ,{chartData:u.data}),_.createElement(XZ,{layout:i.layout,margin:i.margin}),_.createElement(YZ,{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(QZ,w3({},i,{ref:n})))}),jCe=["axis"],DCe=_.forwardRef((t,e)=>_.createElement(z4,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:jCe,tooltipPayloadSearcher:n2,categoricalChartProps:t,ref:e})),RCe=["axis","item"],OCe=_.forwardRef((t,e)=>_.createElement(z4,{chartName:"BarChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:RCe,tooltipPayloadSearcher:n2,categoricalChartProps:t,ref:e}));function LCe(t){var e=Lr();return _.useEffect(()=>{e(nCe(t))},[e,t]),null}var FCe=["layout"];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 ICe(t,e){if(t==null)return{};var n,r,i=UCe(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(r=0;r<a.length;r++)n=a[r],e.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function UCe(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 zCe={top:5,right:5,bottom:5,left:5},ZZ={accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:zCe,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},BCe=_.forwardRef(function(e,n){var r,i=ci(e.categoricalChartProps,ZZ),{layout:a}=i,o=ICe(i,FCe),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d}=e,f={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:u,tooltipPayloadSearcher:d,eventEmitter:void 0};return _.createElement(KZ,{preloadedState:{options:f},reduxStoreName:(r=i.id)!==null&&r!==void 0?r:l},_.createElement(mZ,{chartData:i.data}),_.createElement(XZ,{layout:a,margin:i.margin}),_.createElement(YZ,{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(LCe,{cx:i.cx,cy:i.cy,startAngle:i.startAngle,endAngle:i.endAngle,innerRadius:i.innerRadius,outerRadius:i.outerRadius}),_.createElement(QZ,_3({},o,{ref:n})))});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 g$(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){HCe(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 HCe(t,e,n){return(e=$Ce(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function $Ce(t){var e=VCe(t,"string");return typeof e=="symbol"?e:e+""}function VCe(t,e){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var GCe=["item"],qCe=g$(g$({},ZZ),{},{layout:"centric",startAngle:0,endAngle:360}),WCe=_.forwardRef((t,e)=>{var n=ci(t,qCe);return _.createElement(BCe,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:GCe,tooltipPayloadSearcher:n2,categoricalChartProps:n,ref:e})}),KCe=["axis"],XCe=_.forwardRef((t,e)=>_.createElement(z4,{chartName:"AreaChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:KCe,tooltipPayloadSearcher:n2,categoricalChartProps:t,ref:e}));const x$=[{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 YCe({isOpen:t,onClose:e,printerId:n,printerName:r,amsId:i,amsLabel:a,initialMode:o="humidity",thresholds:l}){const{t:c}=Rn(),{mode:u}=Oh(),[d,f]=_.useState("24h"),[p,m]=_.useState(o),x=u==="dark",{data:b}=ot({queryKey:["settings"],queryFn:ce.getSettings}),v=b?.time_format||"system";_.useEffect(()=>{if(!t)return;const ne=be=>{be.key==="Escape"&&e()};return window.addEventListener("keydown",ne),()=>window.removeEventListener("keydown",ne)},[t,e]);const y=x$.find(ne=>ne.value===d)?.hours||24,{data:S,isLoading:k,error:T}=ot({queryKey:["ams-history",n,i,y],queryFn:()=>ce.getAMSHistory(n,i,y),enabled:t,refetchInterval:6e4});if(!t)return null;const M=S?.data.map(ne=>{const be=Ui(ne.recorded_at)||new Date,me={hour:"2-digit",minute:"2-digit",...y>24?{day:"numeric",month:"short"}:{}};return{time:be.getTime(),humidity:ne.humidity,temperature:ne.temperature,timeLabel:be.toLocaleTimeString([],y0(me,v))}})||[],C=l?.humidityGood||40,E=l?.humidityFair||60,R=l?.tempGood||30,A=l?.tempFair||35,D=M[M.length-1],I=D?.humidity,F=D?.temperature,z=ne=>{const be=ne.filter(Oe=>Oe!=null);if(be.length<4)return"stable";const me=be.slice(0,Math.floor(be.length/4)),de=be.slice(-Math.floor(be.length/4)),Ce=me.reduce((Oe,pe)=>Oe+pe,0)/me.length,ke=de.reduce((Oe,pe)=>Oe+pe,0)/de.length-Ce;return Math.abs(ke)<2?"stable":ke>0?"up":"down"},P=z(M.map(ne=>ne.humidity)),$=z(M.map(ne=>ne.temperature)),X=({trend:ne})=>ne==="up"?s.jsx(yj,{className:"w-4 h-4 text-red-400"}):ne==="down"?s.jsx(DW,{className:"w-4 h-4 text-green-400"}):s.jsx(xj,{className:"w-4 h-4 text-gray-400 dark:text-bambu-gray"}),V=ne=>ne==null?"#9ca3af":ne<=C?"#22a352":ne<=E?"#d4a017":"#c62828",Q=ne=>ne==null?"#9ca3af":ne<=R?"#22a352":ne<=A?"#d4a017":"#c62828",Z=x?"#2d2d2d":"#ffffff",se=x?"#1d1d1d":"#f3f4f6",H=x?"#3d3d3d":"#e5e7eb",K=x?"#ffffff":"#111827",re=x?"#9ca3af":"#4b5563";return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsxs("div",{className:"rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl",style:{backgroundColor:Z},onClick:ne=>ne.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b",style:{borderColor:H},children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold",style:{color:K},children:[a," ",c("common.history","History")]}),s.jsx("p",{className:"text-sm",style:{color:re},children:r})]}),s.jsx("button",{onClick:e,className:"p-2 rounded-lg transition-colors",style:{color:re},children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:se},children:[s.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:re}:void 0,children:[s.jsx(AR,{className:"w-4 h-4"}),c("common.humidity","Humidity")]}),s.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:re}:void 0,children:[s.jsx(bM,{className:"w-4 h-4"}),c("common.temperature","Temperature")]})]}),s.jsx("div",{className:"flex gap-1 rounded-lg p-1",style:{backgroundColor:se},children:x$.map(ne=>s.jsx("button",{onClick:()=>f(ne.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===ne.value?"bg-bambu-green text-white":""}`,style:d!==ne.value?{color:re}:void 0,children:ne.label},ne.value))})]}),s.jsx("div",{className:"grid grid-cols-4 gap-4",children:p==="humidity"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[s.jsx("p",{className:"text-xs",style:{color:re},children:c("common.current","Current")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-2xl font-bold",style:{color:V(I)},children:I!=null?`${I}%`:"—"}),s.jsx(X,{trend:P})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[s.jsx("p",{className:"text-xs",style:{color:re},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:K},children:S?.avg_humidity!=null?`${S.avg_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[s.jsx("p",{className:"text-xs",style:{color:re},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-green-500",children:S?.min_humidity!=null?`${S.min_humidity}%`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[s.jsx("p",{className:"text-xs",style:{color:re},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_humidity!=null?`${S.max_humidity}%`:"—"})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[s.jsx("p",{className:"text-xs",style:{color:re},children:c("common.current","Current")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-2xl font-bold",style:{color:Q(F)},children:F!=null?`${F}°C`:"—"}),s.jsx(X,{trend:$})]})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[s.jsx("p",{className:"text-xs",style:{color:re},children:c("common.average","Average")}),s.jsx("p",{className:"text-2xl font-bold",style:{color:K},children:S?.avg_temperature!=null?`${S.avg_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[s.jsx("p",{className:"text-xs",style:{color:re},children:c("common.min","Min")}),s.jsx("p",{className:"text-2xl font-bold text-blue-500",children:S?.min_temperature!=null?`${S.min_temperature}°C`:"—"})]}),s.jsxs("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:[s.jsx("p",{className:"text-xs",style:{color:re},children:c("common.max","Max")}),s.jsx("p",{className:"text-2xl font-bold text-red-500",children:S?.max_temperature!=null?`${S.max_temperature}°C`:"—"})]})]})}),s.jsx("div",{className:"rounded-lg p-4",style:{backgroundColor:se},children:k?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:re},children:c("common.loading","Loading...")}):T?s.jsx("div",{className:"h-[300px] flex items-center justify-center text-red-500",children:c("common.error","Error loading data")}):M.length===0?s.jsx("div",{className:"h-[300px] flex items-center justify-center",style:{color:re},children:c("common.noData","No data available for this time range")}):s.jsx(w1,{width:"100%",height:300,children:s.jsxs(DCe,{data:M,children:[s.jsx(HS,{strokeDasharray:"3 3",stroke:x?"#3d3d3d":"#e5e7eb"}),s.jsx(VS,{dataKey:"time",type:"number",domain:["dataMin","dataMax"],tickFormatter:ne=>{const be=new Date(ne);return y>24?be.toLocaleDateString([],{day:"numeric",month:"short"}):be.toLocaleTimeString([],y0({hour:"2-digit",minute:"2-digit"},v))},stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12}}),s.jsx(GS,{stroke:x?"#9ca3af":"#6b7280",tick:{fontSize:12},domain:p==="humidity"?[0,100]:["auto","auto"],tickFormatter:ne=>p==="humidity"?`${ne}%`:`${ne}°C`}),s.jsx(S1,{contentStyle:{backgroundColor:x?"#2d2d2d":"#ffffff",border:`1px solid ${x?"#3d3d3d":"#e5e7eb"}`,borderRadius:"8px",color:x?"#fff":"#000"},labelFormatter:ne=>new Date(ne).toLocaleString(void 0,y0({year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"},v)),formatter:ne=>[p==="humidity"?`${ne??0}%`:`${ne??0}°C`,p==="humidity"?"Humidity":"Temperature"]}),s.jsx(dO,{}),p==="humidity"?s.jsxs(s.Fragment,{children:[s.jsx(s0,{y:C,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(s0,{y:E,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}):s.jsxs(s.Fragment,{children:[s.jsx(s0,{y:R,stroke:"#22a352",strokeDasharray:"5 5",label:{value:"Good",fill:"#22a352",fontSize:10}}),s.jsx(s0,{y:A,stroke:"#d4a017",strokeDasharray:"5 5",label:{value:"Fair",fill:"#d4a017",fontSize:10}})]}),s.jsx(TZ,{type:"monotone",dataKey:p,name:p==="humidity"?"Humidity":"Temperature",stroke:p==="humidity"?"#3b82f6":"#f97316",strokeWidth:2,dot:!1,activeDot:{r:4}})]})})}),s.jsx("div",{className:"text-xs text-center",style:{color:re},children:c("amsHistory.recordingInfo","Data is recorded every 5 minutes while the printer is connected")})]})]})})}function IA({data:t,children:e,disabled:n,className:r="",spoolman:i,configureSlot:a}){const{t:o}=Rn(),[l,c]=_.useState(!1),[u,d]=_.useState("top"),[f,p]=_.useState(!1),m=_.useRef(null),x=_.useRef(null),b=_.useRef(null),v=()=>{const E=t.trayUuid;E&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(E).then(()=>{p(!0),setTimeout(()=>p(!1),2e3)}).catch(()=>{y(E)}):y(E))},y=E=>{const R=document.createElement("textarea");R.value=E,R.style.position="fixed",R.style.opacity="0",document.body.appendChild(R),R.select();try{document.execCommand("copy"),p(!0),setTimeout(()=>p(!1),2e3)}catch{console.error("Failed to copy to clipboard")}document.body.removeChild(R)};_.useEffect(()=>{if(l&&m.current&&x.current){const E=m.current.getBoundingClientRect(),R=x.current.offsetHeight,A=E.top,D=window.innerHeight-E.bottom;A<R+12&&D>A?d("bottom"):d("top")}},[l]);const S=()=>{n||(b.current&&clearTimeout(b.current),b.current=setTimeout(()=>c(!0),80))},k=()=>{b.current&&clearTimeout(b.current),b.current=setTimeout(()=>c(!1),100)};_.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const T=E=>E<=15?"#ef4444":E<=30?"#f97316":E<=50?"#eab308":"#22c55e",M=E=>{if(!E)return!1;const R=E.replace("#",""),A=parseInt(R.slice(0,2),16),D=parseInt(R.slice(2,4),16),I=parseInt(R.slice(4,6),16);return(.299*A+.587*D+.114*I)/255>.6},C=t.colorHex?`#${t.colorHex.replace("#","")}`:null;return s.jsxs("div",{ref:m,className:`relative ${r}`,onMouseEnter:S,onMouseLeave:k,children:[e,l&&s.jsxs("div",{ref:x,className:`
- absolute left-1/2 -translate-x-1/2 z-50
- ${u==="top"?"bottom-full mb-2":"top-full mt-2"}
- animate-in fade-in-0 zoom-in-95 duration-150
- `,style:{maxWidth:"calc(100vw - 24px)"},children:[s.jsxs("div",{className:`
- w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-lg shadow-xl overflow-hidden
- backdrop-blur-sm
- `,children:[s.jsxs("div",{className:"h-12 relative overflow-hidden",style:{backgroundColor:C||"#3d3d3d"},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white/10 to-transparent"}),s.jsx("div",{className:`
- absolute inset-0 flex items-center justify-center
- font-semibold text-sm tracking-wide
- ${M(C)?"text-black/80":"text-white/90"}
- `,children:t.colorName}),s.jsx("div",{className:`
- absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
- ${t.vendor==="Bambu Lab"?"bg-black/60 text-white":"bg-black/50 text-white/90"}
- `,children:t.vendor==="Bambu Lab"?"BBL":"GEN"})]}),s.jsxs("div",{className:"p-3 space-y-2.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:o("ams.profile")}),s.jsx("span",{className:"text-xs text-white font-semibold truncate max-w-[120px]",children:t.profile})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:o("ams.kFactor")}),s.jsx("span",{className:"text-xs text-bambu-green font-mono font-bold",children:t.kFactor})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium flex items-center gap-1",children:[s.jsx(AR,{className:"w-3 h-3"}),o("ams.fill")]}),s.jsx("span",{className:"text-xs text-white font-semibold",children:t.fillLevel!==null?`${t.fillLevel}%`:"—"})]}),s.jsx("div",{className:"h-1.5 bg-black/40 rounded-full overflow-hidden",children:t.fillLevel!==null?s.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${t.fillLevel}%`,backgroundColor:T(t.fillLevel)}}):s.jsx("div",{className:"h-full w-full bg-bambu-gray/30 rounded-full"})})]}),i?.enabled&&t.trayUuid&&s.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:o("spoolman.spoolId")}),s.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:[s.jsxs("span",{className:"font-mono text-[10px] truncate max-w-[80px]",children:[t.trayUuid.slice(0,8),"..."]}),f?s.jsx(Na,{className:"w-3 h-3 text-bambu-green"}):s.jsx(Fl,{className:"w-3 h-3"})]})]}),i.linkedSpoolId&&i.spoolmanUrl&&s.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:[s.jsx(Xr,{className:"w-3.5 h-3.5"}),o("spoolman.openInSpoolman")]}),!i.linkedSpoolId&&i.onLinkSpool&&s.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:[s.jsx(uc,{className:"w-3.5 h-3.5"}),o("spoolman.linkToSpoolman")]})]}),a?.enabled&&s.jsx("div",{className:`${i?.enabled&&t.trayUuid?"":"pt-2 mt-2 border-t border-bambu-dark-tertiary"}`,children:s.jsxs("button",{onClick:E=>{E.stopPropagation(),a.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:[s.jsx(bh,{className:"w-3.5 h-3.5"}),o("ams.configure")]})})]})]}),s.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 w-0 h-0
- border-l-[6px] border-l-transparent
- border-r-[6px] border-r-transparent
- ${u==="top"?"top-full border-t-[6px] border-t-bambu-dark-tertiary":"bottom-full border-b-[6px] border-b-bambu-dark-tertiary"}
- `})]})]})}function b$({children:t,className:e="",configureSlot:n}){const{t:r}=Rn(),[i,a]=_.useState(!1),o=_.useRef(null),l=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>a(!0),80)},c=()=>{o.current&&clearTimeout(o.current),o.current=setTimeout(()=>a(!1),100)};return _.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]),s.jsxs("div",{className:`relative ${e}`,onMouseEnter:l,onMouseLeave:c,children:[t,i&&s.jsxs("div",{className:`
- absolute left-1/2 -translate-x-1/2 bottom-full mb-2 z-50
- animate-in fade-in-0 zoom-in-95 duration-150
- `,children:[s.jsxs("div",{className:`
- bg-bambu-dark-secondary border border-bambu-dark-tertiary
- rounded-md shadow-lg overflow-hidden
- `,children:[s.jsx("div",{className:"px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap",children:r("ams.emptySlot")}),n?.enabled&&s.jsx("div",{className:"px-2 pb-2",children:s.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:[s.jsx(bh,{className:"w-3.5 h-3.5"}),r("ams.configure")]})})]}),s.jsx("div",{className:`
- absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
- border-l-[5px] border-l-transparent
- border-r-[5px] border-r-transparent
- border-t-[5px] border-t-bambu-dark-tertiary
- `})]})]})}function QCe({isOpen:t,onClose:e,trayUuid:n,trayInfo:r}){const{t:i}=Rn(),a=sn(),{showToast:o}=Hn(),[l,c]=_.useState(null),{data:u,isLoading:d}=ot({queryKey:["unlinked-spools"],queryFn:ce.getUnlinkedSpools,enabled:t}),f=mt({mutationFn:m=>ce.linkSpool(m,n),onSuccess:()=>{a.invalidateQueries({queryKey:["unlinked-spools"]}),a.invalidateQueries({queryKey:["linked-spools"]}),a.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&&f.mutate(l)};return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),s.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:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(uc,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("spoolman.linkToSpoolman")})]}),s.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[r&&s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Linking AMS tray:"}),s.jsxs("div",{className:"flex items-center gap-2",children:[r.color&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.color}`}}),s.jsx("span",{className:"text-white font-medium",children:r.type}),s.jsxs("span",{className:"text-bambu-gray",children:["(",r.location,")"]})]})]}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("p",{className:"text-xs text-bambu-gray mb-1",children:[i("spoolman.spoolId"),":"]}),s.jsx("code",{className:"text-xs text-bambu-green font-mono break-all",children:n})]}),s.jsxs("div",{children:[s.jsxs("p",{className:"text-sm text-bambu-gray mb-2",children:[i("spoolman.selectSpool"),":"]}),d?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-2",children:u.map(m=>s.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:s.jsxs("div",{className:"flex items-center gap-2",children:[m.filament_color_hex&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20 flex-shrink-0",style:{backgroundColor:`#${m.filament_color_hex}`}}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:m.filament_name||"Unknown filament"}),s.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&&s.jsx(Na,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]})},m.id))}):s.jsx("div",{className:"text-center py-8 text-bambu-gray",children:s.jsx("p",{children:i("spoolman.noUnlinkedSpools")})})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:e,children:i("common.cancel")}),s.jsx(Te,{onClick:p,disabled:!l||f.isPending,children:f.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),i("spoolman.syncing")]}):s.jsxs(s.Fragment,{children:[s.jsx(uc,{className:"w-4 h-4"}),i("spoolman.linkToSpoolman")]})})]}),f.isError&&s.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:f.error.message})]})]})}function ZCe(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 y$(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 JCe=["PLA","PETG","ABS","ASA","TPU","PC","PA","NYLON","PVA","HIPS","PP","PET"];function v$(t){const e=t.replace(/@.+$/,"").trim(),n=e.toUpperCase();for(const i of JCe){const a=new RegExp(`\\b${i}\\b`,"i");if(a.test(n)){const o=e.split(a),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 UA(t){return!t.startsWith("GF")&&!t.startsWith("P1")}const ePe={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"},tPe=[{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"}],nPe=[{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 rPe(t){const e=t.toLowerCase().trim();return ePe[e]||null}function iPe({isOpen:t,onClose:e,printerId:n,slotInfo:r,nozzleDiameter:i="0.4",onSuccess:a}){const[o,l]=_.useState(""),[c,u]=_.useState(null),[d,f]=_.useState(""),[p,m]=_.useState(""),[x,b]=_.useState(""),[v,y]=_.useState(!1),[S,k]=_.useState(!1),{data:T,isLoading:M}=ot({queryKey:["cloudSettings"],queryFn:()=>ce.getCloudSettings(),enabled:t}),{data:C,isLoading:E}=ot({queryKey:["kprofiles",n,i],queryFn:()=>ce.getKProfiles(n,i),enabled:t&&!!n}),R=mt({mutationFn:async()=>{if(!o)throw new Error("No filament preset selected");const Q=T?.filament.find(ie=>ie.setting_id===o);if(!Q)throw new Error("Selected preset not found");const Z=v$(Q.name),se=c?.slot_id??-1,H=d||r.trayColor?.slice(0,6)||"FFFFFF",K=Q.name.replace(/@.+$/,"").trim();let re=y$(o);if(!o.startsWith("GFS"))try{const ie=await ce.getCloudSettingDetail(o);ie.filament_id?re=ie.filament_id:ie.base_id&&(re=y$(ie.base_id),console.log(`Derived tray_info_idx from base_id: ${ie.base_id} -> ${re}`))}catch(ie){console.warn("Failed to fetch preset detail for filament_id:",ie)}let ne=190,be=230;const me=Z.material.toUpperCase();me.includes("PLA")?(ne=190,be=230):me.includes("PETG")?(ne=220,be=260):me.includes("ABS")||me.includes("ASA")?(ne=240,be=280):me.includes("TPU")?(ne=200,be=240):me.includes("PC")?(ne=260,be=300):(me.includes("PA")||me.includes("NYLON"))&&(ne=250,be=290);const de=c?.k_value?parseFloat(c.k_value):0,Ce=await ce.configureAmsSlot(n,r.amsId,r.trayId,{tray_info_idx:re,tray_type:Z.material||"PLA",tray_sub_brands:K,tray_color:H+"FF",nozzle_temp_min:ne,nozzle_temp_max:be,cali_idx:se,nozzle_diameter:i,setting_id:o,kprofile_filament_id:c?.filament_id,kprofile_setting_id:c?.setting_id||void 0,k_value:de});try{await ce.saveSlotPreset(n,r.amsId,r.trayId,o,K)}catch(ie){console.warn("Failed to save slot preset mapping:",ie)}return Ce},onSuccess:()=>{y(!0),a?.(),setTimeout(()=>{y(!1),e()},1500)}}),A=mt({mutationFn:async()=>ce.resetAmsSlot(n,r.amsId,r.trayId),onSuccess:()=>{y(!0),a?.(),setTimeout(()=>{y(!1),e()},1500)}}),D=_.useMemo(()=>{if(!T?.filament)return[];const Q=x.toLowerCase();return T.filament.filter(Z=>Q?Z.name.toLowerCase().includes(Q):!0).sort((Z,se)=>{const H=UA(Z.setting_id),K=UA(se.setting_id);return H&&!K?-1:!H&&K?1:Z.name.localeCompare(se.name)})},[T?.filament,x]),I=_.useMemo(()=>{if(!o||!T?.filament)return null;const Q=T.filament.find(H=>H.setting_id===o);if(!Q)return null;let Z=Q.name.replace(/@.+$/,"").trim();Z.startsWith("# ")&&(Z=Z.slice(2).trim());const se=v$(Z);return{fullName:Z,material:se.material,brand:se.brand}},[o,T?.filament]),F=I?.fullName||"",z=_.useMemo(()=>{if(!C?.profiles||!I)return[];const{fullName:Q,material:Z,brand:se}=I,H=Q.toUpperCase(),K=Z.toUpperCase(),re=se.toUpperCase();if(!K||K.length<2)return[];const ne=C.profiles.filter(me=>{const de=me.name.toUpperCase();if(re)return!(!de.includes(re)||!de.includes(K));if(de.includes(H)||de.includes(K))return!0;const ie={NYLON:["PA","PA-CF","PA6"],PA:["NYLON"]}[K]||[];for(const ke of ie)if(de.includes(ke))return!0;return!1}),be=new Map;for(const me of ne){const de=`${me.name}|${me.k_value}`,Ce=be.get(de);Ce?me.extruder_id===1&&Ce.extruder_id===0&&be.set(de,me):be.set(de,me)}return Array.from(be.values())},[C?.profiles,I]);_.useEffect(()=>{if(t&&T?.filament){if(r.trayInfoIdx){const Q=T.filament.find(Z=>Z.setting_id===r.trayInfoIdx);Q&&l(Q.setting_id)}}else t||(l(""),u(null),f(""),m(""),b(""),y(!1))},[t,T?.filament,r.trayInfoIdx]),_.useEffect(()=>{z.length>0?u(z[0]):u(null)},[o,z]);const P=_.useCallback(Q=>{Q.key==="Escape"&&e()},[e]);if(_.useEffect(()=>{if(t)return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[t,P]),!t)return null;const $=M||E,X=o&&!R.isPending,V=d||r.trayColor?.slice(0,6)||"FFFFFF";return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:e}),s.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:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(bh,{className:"w-5 h-5 text-bambu-blue"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Configure AMS Slot"})]}),s.jsx("button",{onClick:e,className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4 max-h-[60vh] overflow-y-auto",children:[v&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-secondary/95 z-10 flex items-center justify-center rounded-xl",children:s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx(oM,{className:"w-16 h-16 text-bambu-green mx-auto"}),s.jsx("p",{className:"text-lg font-semibold text-white",children:"Slot Configured!"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Settings sent to printer"})]})}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Configuring slot:"}),s.jsxs("div",{className:"flex items-center gap-2",children:[r.trayColor&&s.jsx("span",{className:"w-4 h-4 rounded-full border border-white/20",style:{backgroundColor:`#${r.trayColor.slice(0,6)}`}}),s.jsxs("span",{className:"text-white font-medium",children:[ZCe(r.amsId,r.trayCount)," Slot ",r.trayId+1]}),r.traySubBrands&&s.jsxs("span",{className:"text-bambu-gray",children:["(",r.traySubBrands,")"]})]})]}),$?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["Filament Profile ",s.jsx("span",{className:"text-red-400",children:"*"})]}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{type:"text",placeholder:"Search presets...",value:x,onChange:Q=>b(Q.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"}),s.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:D.length===0?s.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(Q=>s.jsx("button",{onClick:()=>l(Q.setting_id),className:`w-full p-2 rounded-lg border text-left transition-colors ${o===Q.setting_id?"bg-bambu-green/20 border-bambu-green":"bg-bambu-dark border-bambu-dark-tertiary hover:border-bambu-gray"}`,children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-white text-sm truncate",children:Q.name}),UA(Q.setting_id)&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bambu-blue/20 text-bambu-blue",children:"Custom"})]})},Q.setting_id))})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-2",children:["K Profile (Pressure Advance)",F&&s.jsxs("span",{className:"ml-2 text-xs text-bambu-blue",children:["Filtering for: ",F]})]}),z.length>0?s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:c?.name||"",onChange:Q=>{const Z=z.find(se=>se.name===Q.target.value);u(Z||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:[s.jsx("option",{value:"",children:"No K profile (use default 0.020)"}),z.map(Q=>s.jsxs("option",{value:Q.name,children:[Q.name," (K=",Q.k_value,")"]},`${Q.name}-${Q.extruder_id}`))]}),s.jsx(Kr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}):o?s.jsx("p",{className:"text-sm text-bambu-gray italic py-2",children:"No matching K profiles found. Default K=0.020 will be used."}):s.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&&s.jsxs("p",{className:"text-xs text-bambu-green mt-1",children:["K=",c.k_value," from printer calibration"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Custom Color (optional)"}),s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[tPe.map(Q=>s.jsx("button",{onClick:()=>{f(Q.hex),m(Q.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Q.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Q.hex}`},title:Q.name},Q.hex)),s.jsx("button",{onClick:()=>k(!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&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:nPe.map(Q=>s.jsx("button",{onClick:()=>{f(Q.hex),m(Q.name)},className:`w-7 h-7 rounded-md border-2 transition-all ${d===Q.hex?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:`#${Q.hex}`},title:Q.name},Q.hex))}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg border-2 border-white/20 flex-shrink-0",style:{backgroundColor:`#${V}`}}),s.jsx("input",{type:"text",placeholder:"Color name or hex (e.g., brown, FF8800)",value:p,onChange:Q=>{const Z=Q.target.value;m(Z);const se=rPe(Z);if(se)f(se);else{const H=Z.replace(/[^0-9A-Fa-f]/g,"").toUpperCase();H.length===6?f(H):H.length===3&&f(H.split("").map(K=>K+K).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&&s.jsx("button",{onClick:()=>{f(""),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&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-1.5",children:["Hex: #",d]})]})]})]}),s.jsxs("div",{className:"flex justify-between p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:()=>A.mutate(),disabled:A.isPending||R.isPending,className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:A.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Resetting..."]}):s.jsxs(s.Fragment,{children:[s.jsx(Rh,{className:"w-4 h-4"}),"Reset Slot"]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(Te,{onClick:()=>R.mutate(),disabled:!X,children:R.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Configuring..."]}):s.jsxs(s.Fragment,{children:[s.jsx(bh,{className:"w-4 h-4"}),"Configure Slot"]})})]})]}),(R.isError||A.isError)&&s.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:R.error?.message||A.error?.message})]})]})}function aPe({on:t,className:e="w-5 h-5"}){const n=t?"#facc15":"none",r=t?"#78350f":"currentColor",i=t?1:0;return s.jsxs("svg",{viewBox:"0 0 32 32",fill:"none",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[s.jsxs("g",{stroke:r,opacity:i,children:[s.jsx("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),s.jsx("line",{x1:"6.1",y1:"6.1",x2:"8.9",y2:"8.9"}),s.jsx("line",{x1:"25.9",y1:"6.1",x2:"23.1",y2:"8.9"}),s.jsx("line",{x1:"2",y1:"16",x2:"6",y2:"16"}),s.jsx("line",{x1:"30",y1:"16",x2:"26",y2:"16"})]}),s.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}),s.jsx("path",{d:"M12 24h8",stroke:r}),s.jsx("path",{d:"M12 27h8",stroke:r}),s.jsx("path",{d:"M13 30h6",stroke:r})]})}const w$=({className:t})=>s.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[s.jsx("rect",{x:"2",y:"15",width:"5",height:"5",rx:"0.5"}),s.jsx("rect",{x:"9.5",y:"15",width:"5",height:"5",rx:"0.5",fill:"currentColor",opacity:"0.3"}),s.jsx("rect",{x:"17",y:"15",width:"5",height:"5",rx:"0.5"}),s.jsx("path",{d:"M4 12 C4 6, 14 6, 14 12"}),s.jsx("polyline",{points:"12,10 14,12 12,14"})]}),_$={"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"},sPe={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 zA(t){if(!t)return null;if(_$[t])return _$[t];const e=t.split("-");if(e.length<2)return null;const n=e[1];return sPe[n]||null}function BA(t){if(!t||t.length<6)return"Unknown";const e=parseInt(t.substring(0,2),16),n=parseInt(t.substring(2,4),16),r=parseInt(t.substring(4,6),16),i=Math.max(e,n,r)/255,a=Math.min(e,n,r)/255,o=(i+a)/2;let l=0,c=0;if(i!==a){const u=i-a;c=o>.5?u/(2-i-a):u/(i+a);const d=e/255,f=n/255,p=r/255;i===d?l=((f-p)/u+(f<p?6:0))/6:i===f?l=((p-d)/u+2)/6:l=((d-f)/u+4)/6}return l=l*360,o<.15?"Black":o>.85?"White":c<.15?o<.4?"Dark Gray":o>.6?"Light Gray":"Gray":l>=15&&l<45&&o<.45||l>=45&&l<70&&o<.4?"Brown":l<15||l>=345?"Red":l<45?"Orange":l<70?"Yellow":l<150?"Green":l<200?"Cyan":l<260?"Blue":l<290?"Purple":l<345?"Pink":"Unknown"}function HA(t){return(t??.02).toFixed(3)}function S$({side:t}){const{mode:e}=Oh(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return s.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 N$({className:t}){return s.jsx("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.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 oPe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 35 53",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.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"}),s.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 lPe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 36 54",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.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"}),s.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 cPe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.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"}),s.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:"#C3C2C1",strokeWidth:"1",fill:"none"})]})}function uPe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"8",width:"3",height:"4.5",fill:"#d4a017",rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#d4a017"}),s.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 dPe({className:t}){return s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:"#c62828",rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:"#c62828"}),s.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 $A({className:t,color:e,isHeating:n}){const i={"text-orange-400":"#fb923c","text-blue-400":"#60a5fa","text-green-400":"#4ade80"}[e]||"#888",a=n?{filter:`drop-shadow(0 0 4px ${i}) drop-shadow(0 0 8px ${i})`}:{};return n?s.jsxs("svg",{className:t,style:a,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.jsx("rect",{x:"4.5",y:"3",width:"3",height:"9.5",fill:i,rx:"0.5"}),s.jsx("circle",{cx:"6",cy:"15",r:"2",fill:i}),s.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"})]}):s.jsxs("svg",{className:t,viewBox:"0 0 12 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[s.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"}),s.jsx("circle",{cx:"6",cy:"15",r:"2.5",stroke:i,strokeWidth:"1",fill:"none"})]})}function M$({humidity:t,goodThreshold:e=40,fairThreshold:n=60,onClick:r,compact:i}){const a=typeof t=="string"?parseInt(t,10):t,o=typeof e=="number"?e:40,l=typeof n=="number"?n:60;let c,u;isNaN(a)?(c="#C3C2C1",u="Unknown"):a<=o?(c="#22a352",u="Good"):a<=l?(c="#d4a017",u="Fair"):(c="#c62828",u="Bad");let d;return isNaN(a)||a<=o?d=N$:a<=l?d=oPe:d=lPe,s.jsxs("button",{type:"button",onClick:r,className:`flex items-center gap-1 ${r?"cursor-pointer hover:opacity-80 transition-opacity":""}`,title:`Humidity: ${a}% - ${u}${r?" (click for history)":""}`,children:[s.jsx(d,{className:i?"w-2.5 h-3":"w-3 h-4"}),s.jsxs("span",{className:`font-medium tabular-nums ${i?"text-[10px]":"text-xs"}`,style:{color:c},children:[a,"%"]})]})}function k$({temp:t,goodThreshold:e=28,fairThreshold:n=35,onClick:r,compact:i}){const a=typeof e=="number"?e:28,o=typeof n=="number"?n:35;let l,c,u;return t<=a?(l="#22a352",c="Good",u=cPe):t<=o?(l="#d4a017",c="Fair",u=uPe):(l="#c62828",c="Bad",u=dPe),s.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:[s.jsx(u,{className:i?"w-2.5 h-3":"w-3 h-4"}),s.jsxs("span",{className:`tabular-nums text-right ${i?"text-[10px] w-8":"w-12"}`,style:{color:l},children:[t,"°C"]})]})}function _d(t,e){const n=typeof t=="string"?parseInt(t,10):t,r=isNaN(n)?0:n,i=e===1,a=r>=128?r-128:r,o=String.fromCharCode(65+a);return i?`HT-${o}`:`AMS-${o}`}function E$(t){return t>50?"#00ae42":t>=15?"#f59e0b":"#ef4444"}function hPe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function fPe(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 a=new Date(r);a.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((a.getTime()-i.getTime())/(1e3*60*60*24));return c===0?l:c===1?`Tomorrow ${l}`:r.toLocaleDateString([],{weekday:"short"})+" "+l}function mPe(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 pPe(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 VA(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 gPe({url:t,printName:e}){const{t:n}=Rn(),[r,i]=_.useState(!1),[a,o]=_.useState(!1),[l,c]=_.useState(!1);return s.jsxs(s.Fragment,{children:[s.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&&!a?s.jsxs(s.Fragment,{children:[s.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&&s.jsx(oo,{className:"w-8 h-8 text-bambu-gray"})]}):s.jsx(oo,{className:"w-8 h-8 text-bambu-gray"})}),l&&t&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8",onClick:()=>c(!1),children:s.jsxs("div",{className:"relative max-w-2xl max-h-full",children:[s.jsx("img",{src:t,alt:n("printers.printPreview"),className:"max-w-full max-h-[80vh] rounded-lg shadow-2xl"}),e&&s.jsx("p",{className:"text-white text-center mt-4 text-lg",children:e})]})})]})}function xPe({printers:t}){const{t:e}=Rn(),n=sn(),r=_.useMemo(()=>{let a=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"?a++:o++:l++}),{printing:a,idle:o,offline:l,loading:c,total:t?.length||0}},[t,n]),[,i]=_.useState(0);return _.useEffect(()=>{let a=!1;const o=n.getQueryCache().subscribe(()=>{a||(a=!0,requestAnimationFrame(()=>{i(l=>l+1),a=!1}))});return()=>o()},[n]),t?.length?s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[r.printing>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:r.printing})," ",e("printers.status.printing").toLowerCase()]})]}),r.idle>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:r.idle})," ",e("printers.status.idle").toLowerCase()]})]}),r.offline>0&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-gray-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white font-medium",children:r.offline})," ",e("printers.status.offline").toLowerCase()]})]})]}):null}function T$(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 A$({printer:t,hideIfDisconnected:e,maintenanceInfo:n,viewMode:r="expanded",cardSize:i=2,amsThresholds:a,spoolmanEnabled:o=!1,hasUnlinkedSpools:l=!1,linkedSpools:c,spoolmanUrl:u,timeFormat:d="system",cameraViewMode:f="window",onOpenEmbeddedCamera:p,checkPrinterFirmware:m=!0}){const{t:x}=Rn(),b=sn(),v=kc(),{showToast:y}=Hn(),{hasPermission:S}=Ci(),[k,T]=_.useState(!1),[M,C]=_.useState(!1),[E,R]=_.useState(!0),[A,D]=_.useState(!1),[I,F]=_.useState(!1),[z,P]=_.useState(!1),[$,X]=_.useState(!1),[V,Q]=_.useState(!1),[Z,se]=_.useState(!1),[H,K]=_.useState(!1),[re,ne]=_.useState(!1),[be,me]=_.useState(!1),[de,Ce]=_.useState(!1),[ie,ke]=_.useState(null),[Oe,pe]=_.useState(null),[We,G]=_.useState(null),[Y,ue]=_.useState(!1),[q,te]=_.useState(null),[U,he]=_.useState(!1),[Me,ge]=_.useState(!1),[B,O]=_.useState(null),[ee,le]=_.useState(!1),[_e,ve]=_.useState(!1),{data:ae}=ot({queryKey:["printerStatus",t.id],queryFn:()=>ce.getPrinterStatus(t.id),refetchInterval:3e4}),{data:Fe}=ot({queryKey:["firmwareUpdate",t.id],queryFn:()=>x1.checkPrinterUpdate(t.id),staleTime:300*1e3,refetchInterval:300*1e3,enabled:m}),Be=_.useMemo(()=>{const nt=new Set;if(ae?.ams)for(const Pt of ae.ams)for(const qt of Pt.tray||[])qt.tray_info_idx&&nt.add(qt.tray_info_idx);return ae?.vt_tray?.tray_info_idx&&nt.add(ae.vt_tray.tray_info_idx),Array.from(nt)},[ae?.ams,ae?.vt_tray]),{data:$e}=ot({queryKey:["filamentInfo",Be],queryFn:()=>ce.getFilamentInfo(Be),enabled:Be.length>0,staleTime:300*1e3}),{data:He}=ot({queryKey:["slotPresets",t.id],queryFn:()=>ce.getSlotPresets(t.id),staleTime:120*1e3}),[xe,Pe]=_.useState(null);_.useEffect(()=>{ae?.wifi_signal!=null&&Pe(ae.wifi_signal)},[ae?.wifi_signal]);const ze=ae?.wifi_signal??xe,we=_.useRef(void 0);_.useEffect(()=>{ae?.connected!==void 0&&(we.current=ae.connected)},[ae?.connected]);const Xe=ae?.connected??we.current,Ne=_.useRef({});_.useEffect(()=>{ae?.ams_extruder_map&&Object.keys(ae.ams_extruder_map).length>0&&(Ne.current=ae.ams_extruder_map)},[ae?.ams_extruder_map]);const rt=ae?.ams_extruder_map&&Object.keys(ae.ams_extruder_map).length>0?ae.ams_extruder_map:Ne.current,Ee=_.useRef([]);_.useEffect(()=>{ae?.ams&&ae.ams.length>0&&(Ee.current=ae.ams)},[ae?.ams]);const Ke=ae?.ams&&ae.ams.length>0?ae.ams:Ee.current,Ue=_.useRef(255),W=ae?.tray_now;W!==void 0&&W!==255&&(Ue.current=W);const je=W===void 0||W===255?Ue.current:W,{data:Ye}=ot({queryKey:["smartPlugByPrinter",t.id],queryFn:()=>ce.getSmartPlugByPrinter(t.id)}),{data:bt}=ot({queryKey:["scriptPlugsByPrinter",t.id],queryFn:()=>ce.getScriptPlugsByPrinter(t.id)}),{data:pt}=ot({queryKey:["smartPlugStatus",Ye?.id],queryFn:()=>Ye?ce.getSmartPlugStatus(Ye.id):null,enabled:!!Ye,refetchInterval:1e4}),{data:Bt}=ot({queryKey:["queue",t.id,"pending"],queryFn:()=>ce.getQueue(t.id,"pending")}),Lt=Bt?.length||0,{data:vn}=ot({queryKey:["queue",t.id,"printing"],queryFn:()=>ce.getQueue(t.id,"printing"),enabled:ae?.state==="RUNNING"}),{data:cn}=ot({queryKey:["currentPrintUser",t.id],queryFn:()=>ce.getCurrentPrintUser(t.id),enabled:ae?.state==="RUNNING"}),rr=vn?.[0]?.created_by_username||cn?.username,{data:Vn}=ot({queryKey:["archives",t.id,"last"],queryFn:()=>ce.getArchives(t.id,1,0),enabled:ae?.connected&&ae?.state!=="RUNNING"}),Jn=Vn?.[0],gn=e&&Xe===!1,sr=mt({mutationFn:nt=>ce.deletePrinter(t.id,nt.deleteArchives),onSuccess:()=>{b.invalidateQueries({queryKey:["printers"]}),b.invalidateQueries({queryKey:["archives"]}),b.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:nt=>y(nt.message||x("printers.toast.failedToDelete"),"error")}),Gn=mt({mutationFn:()=>ce.connectPrinter(t.id),onSuccess:()=>{b.invalidateQueries({queryKey:["printerStatus",t.id]})}}),Xn=mt({mutationFn:nt=>Ye?ce.controlSmartPlug(Ye.id,nt):Promise.reject("No plug"),onSuccess:()=>{b.invalidateQueries({queryKey:["smartPlugStatus",Ye?.id]})}}),Nn=mt({mutationFn:nt=>Ye?ce.updateSmartPlug(Ye.id,{auto_off:nt}):Promise.reject("No plug"),onSuccess:()=>{b.invalidateQueries({queryKey:["smartPlugByPrinter",t.id]}),b.invalidateQueries({queryKey:["smart-plugs"]})}}),hi=mt({mutationFn:nt=>ce.controlSmartPlug(nt,"on"),onSuccess:()=>{y(x("printers.toast.scriptTriggered"))},onError:nt=>y(nt.message||x("printers.toast.failedToRunScript"),"error")}),ai=mt({mutationFn:()=>ce.stopPrint(t.id),onSuccess:()=>{y(x("printers.toast.printStopped")),b.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:nt=>y(nt.message||x("printers.toast.failedToStopPrint"),"error")}),Ae=mt({mutationFn:()=>ce.pausePrint(t.id),onSuccess:()=>{y(x("printers.toast.printPaused")),b.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:nt=>y(nt.message||x("printers.toast.failedToPausePrint"),"error")}),et=mt({mutationFn:()=>ce.resumePrint(t.id),onSuccess:()=>{y(x("printers.toast.printResumed")),b.invalidateQueries({queryKey:["printerStatus",t.id]})},onError:nt=>y(nt.message||x("printers.toast.failedToResumePrint"),"error")}),ct=mt({mutationFn:nt=>ce.setChamberLight(t.id,nt),onMutate:async nt=>{await b.cancelQueries({queryKey:["printerStatus",t.id]});const Pt=b.getQueryData(["printerStatus",t.id]);return b.setQueryData(["printerStatus",t.id],qt=>({...qt,chamber_light:nt})),{previousStatus:Pt}},onSuccess:(nt,Pt)=>{y(`Chamber light ${Pt?"on":"off"}`)},onError:(nt,Pt,qt)=>{qt?.previousStatus&&b.setQueryData(["printerStatus",t.id],qt.previousStatus),y(nt.message||x("printers.toast.failedToControlChamberLight"),"error")}}),ut=mt({mutationFn:nt=>ce.updatePrinter(t.id,{plate_detection_enabled:nt}),onSuccess:()=>{b.invalidateQueries({queryKey:["printers"]}),y(ut.variables?x("printers.toast.plateCheckEnabled"):x("printers.toast.plateCheckDisabled"))},onError:nt=>y(nt.message||x("printers.toast.failedToUpdateSetting"),"error")}),lt=(ae?.state==="RUNNING"||ae?.state==="PAUSE"||ae?.state==="PAUSED")&&(ae?.printable_objects_count??0)>=2,{data:Et,refetch:fe}=ot({queryKey:["printableObjects",t.id],queryFn:()=>ce.getPrintableObjects(t.id),enabled:de||lt,refetchInterval:de?5e3:lt?3e4:!1}),De=mt({mutationFn:nt=>ce.skipObjects(t.id,nt),onSuccess:nt=>{y(nt.message||x("printers.skipObjects.objectsSkipped")),fe()},onError:nt=>y(nt.message||x("printers.toast.failedToSkipObjects"),"error")}),[Ve,Se]=_.useState(null),Le=_.useRef(!1),tt=_.useRef(null),Qe=_.useRef(!1),Tt=mt({mutationFn:({amsId:nt,slotId:Pt})=>ce.refreshAmsSlot(t.id,nt,Pt),onMutate:({amsId:nt,slotId:Pt})=>{tt.current&&clearTimeout(tt.current),Le.current=!1,Qe.current=!1,Se({amsId:nt,slotId:Pt}),setTimeout(()=>{Qe.current=!0},2e3),tt.current=setTimeout(()=>{Se(null)},3e4)},onSuccess:nt=>{y(nt.message||x("printers.toast.rfidRereadInitiated"))},onError:nt=>{y(nt.message||x("printers.toast.failedToRereadRfid"),"error"),tt.current&&clearTimeout(tt.current),Se(null)}}),[At,Ft]=_.useState(null),[jt,Mt]=_.useState(null),Jt=async()=>{try{const nt=await ce.getPlateReferences(t.id);Ft(nt)}catch{}},Ht=()=>{ut.mutate(!t.plate_detection_enabled)},hn=async()=>{he(!0),te(null);const nt=ae?.chamber_light===!1;ve(nt),nt&&(await ce.setChamberLight(t.id,!0),await new Promise(Pt=>setTimeout(Pt,2500)));try{const Pt=await ce.checkPlateEmpty(t.id,{includeDebugImage:!0});te(Pt),Jt()}catch(Pt){y(Pt instanceof Error?Pt.message:x("printers.toast.failedToCheckPlate"),"error"),nt&&(await ce.setChamberLight(t.id,!1),ve(!1))}finally{he(!1)}},un=_.useCallback(async()=>{te(null),_e&&(await ce.setChamberLight(t.id,!1),ve(!1))},[_e,t.id]),Mn=async nt=>{ge(!0);try{const Pt=await ce.calibratePlateDetection(t.id,{label:nt});if(Pt.success){y(Pt.message||x("printers.toast.calibrationSaved"),"success"),Jt();const qt=await ce.checkPlateEmpty(t.id,{includeDebugImage:!0});te(qt)}else y(Pt.message||x("printers.toast.calibrationFailed"),"error")}catch(Pt){y(Pt instanceof Error?Pt.message:x("printers.toast.calibrationFailed"),"error")}finally{ge(!1)}},Gt=async(nt,Pt)=>{try{await ce.updatePlateReferenceLabel(t.id,nt,Pt),Mt(null),Jt()}catch(qt){y(qt instanceof Error?qt.message:x("printers.toast.failedToUpdateLabel"),"error")}},on=async nt=>{try{await ce.deletePlateReference(t.id,nt),y(x("printers.toast.referenceDeleted"),"success"),Jt();const Pt=await ce.checkPlateEmpty(t.id,{includeDebugImage:!0});te(Pt)}catch(Pt){y(Pt instanceof Error?Pt.message:x("printers.toast.failedToDeleteReference"),"error")}},dn=async()=>{if(B){le(!0);try{await ce.updatePrinter(t.id,{plate_detection_roi:B}),y(x("printers.toast.detectionAreaSaved"),"success"),O(null);const nt=await ce.checkPlateEmpty(t.id,{includeDebugImage:!0});te(nt)}catch(nt){y(nt instanceof Error?nt.message:x("printers.toast.failedToSaveDetectionArea"),"error")}finally{le(!1)}}};_.useEffect(()=>{const nt=Pt=>{Pt.key==="Escape"&&q&&un()};return window.addEventListener("keydown",nt),()=>window.removeEventListener("keydown",nt)},[q,un]);const Yt=_.useRef(null);_.useEffect(()=>{if(!Ve)return;const nt=ae?.ams_status_main??0;return nt!==0&&(Le.current=!0,Yt.current&&(clearTimeout(Yt.current),Yt.current=null)),Le.current&&nt===0&&(Qe.current?(tt.current&&clearTimeout(tt.current),Se(null)):Yt.current||(Yt.current=setTimeout(()=>{tt.current&&clearTimeout(tt.current),Se(null)},2e3))),()=>{Yt.current&&clearTimeout(Yt.current)}},[ae?.ams_status_main,Ve]);const[ir,jn]=_.useState(null);if(gn)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 s.jsxs(St,{className:"relative",children:[s.jsxs(Nt,{className:i>=3?"p-5":"",children:[s.jsxs("div",{className:dr(),children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("img",{src:mPe(t.model),alt:t.model||x("common.printer"),className:`object-contain rounded-lg bg-bambu-dark flex-shrink-0 ${si()}`}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:`font-semibold text-white ${ar()}`,children:t.name}),r==="compact"&&s.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")})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[t.model||"Unknown Model",r==="expanded"&&ae?.nozzles&&ae.nozzles[0]?.nozzle_diameter&&s.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&&s.jsxs("span",{className:"ml-2 text-bambu-gray",children:[s.jsx(tr,{className:"w-3 h-3 inline-block mr-1"}),Math.round(n.total_print_hours),"h"]})]})]})]}),s.jsxs("div",{className:"relative flex-shrink-0",children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>T(!k),children:s.jsx(ih,{className:"w-4 h-4"})}),k&&s.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:[s.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:[s.jsx(Zi,{className:"w-4 h-4"}),x("common.edit")]}),s.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:[s.jsx(Dr,{className:"w-4 h-4"}),x("printers.reconnect")]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2",onClick:()=>{P(!0),T(!1)},children:[s.jsx(jW,{className:"w-4 h-4"}),x("printers.mqttDebug")]}),s.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:[s.jsx(an,{className:"w-4 h-4"}),x("common.delete")]})]})]})]}),r==="expanded"&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[s.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?s.jsx(Iy,{className:"w-3 h-3"}):s.jsx(RR,{className:"w-3 h-3"}),ae?.connected?x("printers.connection.connected"):x("printers.connection.offline")]}),ae?.connected&&ze!=null&&s.jsxs("span",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${ze>=-50||ze>=-60?"bg-status-ok/20 text-status-ok":ze>=-70?"bg-status-warning/20 text-status-warning":ze>=-80?"bg-orange-500/20 text-orange-600":"bg-status-error/20 text-status-error"}`,title:`WiFi: ${ze} dBm - ${x(pPe(ze).labelKey)}`,children:[s.jsx(Che,{className:"w-3 h-3"}),ze,"dBm"]}),ae?.connected&&(()=>{const nt=ae.hms_errors?eme(ae.hms_errors):[];return s.jsxs("button",{onClick:()=>se(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${nt.length>0?nt.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:[s.jsx(Sn,{className:"w-3 h-3"}),nt.length>0?nt.length:"OK"]})})(),n&&s.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:[s.jsx(om,{className:"w-3 h-3"}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:"OK"]}),Lt>0&&s.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:Lt}),children:[s.jsx(sl,{className:"w-3 h-3"}),Lt]}),Fe?.update_available&&s.jsxs("button",{onClick:()=>ue(!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:Fe.current_version,latest:Fe.latest_version}),children:[s.jsx(wi,{className:"w-3 h-3"}),x("printers.firmwareUpdateButton")]})]})]}),M&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(St,{className:"w-full max-w-md mx-4",children:s.jsxs(Nt,{children:[s.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[s.jsx("div",{className:"p-2 rounded-full bg-red-500/20",children:s.jsx(Sn,{className:"w-5 h-5 text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:x("printers.confirm.deleteTitle")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:x("printers.confirm.deleteMessage",{name:t.name})})]})]}),s.jsx("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:s.jsxs("label",{className:"flex items-start gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E,onChange:nt=>R(nt.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"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:x("printers.deleteArchives")}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:x(E?"printers.confirm.deleteArchivesNote":"printers.confirm.keepArchivesNote")})]})]})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{C(!1),R(!0)},children:x("common.cancel")}),s.jsx(Te,{variant:"danger",onClick:()=>{sr.mutate({deleteArchives:E}),C(!1),R(!0)},children:"Delete"})]})]})})}),ae?.connected&&s.jsxs(s.Fragment,{children:[r==="compact"?s.jsx("div",{className:"mt-2",children:ae.state==="RUNNING"?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-1.5",children:s.jsx("div",{className:"bg-bambu-green h-1.5 rounded-full transition-all",style:{width:`${ae.progress||0}%`}})}),s.jsxs("span",{className:"text-xs text-white",children:[Math.round(ae.progress||0),"%"]})]}):s.jsx("p",{className:"text-xs text-bambu-gray",children:T$(ae.state,ae.stg_cur_name)})}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"mb-4 p-3 bg-bambu-dark rounded-lg relative",children:[s.jsxs("button",{onClick:()=>Ce(!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:[s.jsx(w$,{className:"w-4 h-4"}),Et&&Et.skipped_count>0&&s.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})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(gPe,{url:ae.state==="RUNNING"?ae.cover_url:null,printName:ae.state==="RUNNING"&&(ae.subtask_name||ae.current_print)||void 0}),s.jsx("div",{className:"flex-1 min-w-0",children:ae.current_print&&ae.state==="RUNNING"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:ae.stg_cur_name||"Printing"}),s.jsx("p",{className:"text-white text-sm mb-2 truncate",children:ae.subtask_name||ae.current_print}),s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all",style:{width:`${ae.progress||0}%`}})}),s.jsxs("span",{className:"text-white",children:[Math.round(ae.progress||0),"%"]})]}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-bambu-gray",children:[ae.remaining_time!=null&&ae.remaining_time>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(tr,{className:"w-3 h-3"}),hPe(ae.remaining_time*60)]}),s.jsxs("span",{className:"text-bambu-green font-medium",title:x("printers.estimatedCompletion"),children:["ETA ",fPe(ae.remaining_time,d)]})]}),ae.layer_num!=null&&ae.total_layers!=null&&ae.total_layers>0&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(sl,{className:"w-3 h-3"}),ae.layer_num,"/",ae.total_layers]}),rr&&s.jsxs("span",{className:"flex items-center gap-1",title:`Started by ${rr}`,children:[s.jsx(am,{className:"w-3 h-3"}),rr]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-1",children:x("printers.sort.status")}),s.jsx("p",{className:"text-white text-sm mb-2",children:T$(ae.state,ae.stg_cur_name)}),s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex-1 bg-bambu-dark-tertiary rounded-full h-2 mr-3",children:s.jsx("div",{className:"bg-bambu-dark-tertiary h-2 rounded-full"})}),s.jsx("span",{className:"text-bambu-gray",children:"—"})]}),Jn?s.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&&s.jsxs("span",{className:"ml-1 text-bambu-gray/60",children:["• ",Bg(Jn.completed_at,{month:"short",day:"numeric"})]})]}):s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:x("printers.readyToPrint")})]})})]})]}),ae.state!=="RUNNING"&&s.jsx(ime,{printerId:t.id})]}),ae.temperatures&&r==="expanded"&&(()=>{const nt=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 s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx($A,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-orange-400",isHeating:nt}),ae.temperatures.nozzle_2!==void 0?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[9px] text-bambu-gray",children:"L / R"}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.nozzle||0),"° / ",Math.round(ae.temperatures.nozzle_2||0),"°"]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.nozzle")}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.nozzle||0),"°C"]})]})]}),s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx($A,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-blue-400",isHeating:Pt}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.bed")}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.bed||0),"°C"]})]}),ae.temperatures.chamber!==void 0&&s.jsxs("div",{className:"text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1",children:[s.jsx($A,{className:"w-3.5 h-3.5 mx-auto mb-0.5",color:"text-green-400",isHeating:qt}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.chamber")}),s.jsxs("p",{className:"text-[11px] text-white",children:[Math.round(ae.temperatures.chamber||0),"°C"]})]}),vt&&s.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:[s.jsx("p",{className:`text-[11px] font-bold ${wn==="L"?"text-amber-400":"text-gray-500"}`,children:"L"}),s.jsx("p",{className:"text-[9px] text-bambu-gray",children:x("printers.temperatures.nozzle")}),s.jsx("p",{className:`text-[11px] font-bold ${wn==="R"?"text-amber-400":"text-gray-500"}`,children:"R"})]})]})})(),r==="expanded"&&(()=>{const nt=ae.state==="RUNNING",Pt=ae.state==="PAUSED"||ae.state==="PAUSE",qt=nt||Pt,vt=ai.isPending||Ae.isPending||et.isPending,wn=ae.cooling_fan_speed,Fr=ae.big_fan1_speed,Qr=ae.big_fan2_speed;return s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:x("printers.controls")}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.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:[s.jsx(vW,{className:`w-3.5 h-3.5 ${wn&&wn>0?"text-cyan-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${wn&&wn>0?"text-cyan-400":"text-bambu-gray/50"}`,children:[wn??0,"%"]})]}),s.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:[s.jsx(RW,{className:`w-3.5 h-3.5 ${Fr&&Fr>0?"text-blue-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Fr&&Fr>0?"text-blue-400":"text-bambu-gray/50"}`,children:[Fr??0,"%"]})]}),s.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:[s.jsx(oce,{className:`w-3.5 h-3.5 ${Qr&&Qr>0?"text-green-400":"text-bambu-gray/50"}`}),s.jsxs("span",{className:`text-[10px] ${Qr&&Qr>0?"text-green-400":"text-bambu-gray/50"}`,children:[Qr??0,"%"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>K(!0),disabled:!qt||vt||!S("printers:control"),className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${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"}
- `,title:S("printers:control")?x("printers.stop"):x("printers.permission.noControl"),children:[s.jsx(ll,{className:"w-3 h-3"}),x("printers.stop")]}),s.jsxs("button",{onClick:()=>Pt?me(!0):ne(!0),disabled:!qt||vt||!S("printers:control"),className:`
- flex items-center justify-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium
- transition-colors
- ${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"}
- `,title:S("printers:control")?x(Pt?"printers.resume":"printers.pause"):x("printers.permission.noControl"),children:[Pt?s.jsx(bo,{className:"w-3 h-3"}):s.jsx(CR,{className:"w-3 h-3"}),x(Pt?"printers.resume":"printers.pause")]})]})]})]})})(),Ke&&Ke.length>0&&r==="expanded"&&(()=>{const nt=Ke.filter(vt=>vt.tray.length>1),Pt=Ke.filter(vt=>vt.tray.length===1),qt=t.nozzle_count===2||ae?.temperatures?.nozzle_2!==void 0;return s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wider text-bambu-gray font-medium",children:x("printers.filaments")}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary/30"})]}),s.jsxs("div",{className:"space-y-3",children:[nt.length>0&&s.jsx("div",{className:"grid grid-cols-2 gap-3",children:nt.map(vt=>{const wn=rt[String(vt.id)],Fr=vt.id>=128?vt.id-128:vt.id,Qr=wn!==void 0?wn:Fr,Br=Qr===1,qs=Qr===0;return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[10px] text-white font-medium",children:_d(vt.id,vt.tray.length)}),qt&&(Br||qs)&&s.jsx(S$,{side:Br?"L":"R"})]}),(vt.humidity!=null||vt.temp!=null)&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[vt.humidity!=null&&s.jsx(M$,{humidity:vt.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>ke({amsId:vt.id,amsLabel:_d(vt.id,vt.tray.length),mode:"humidity"}),compact:!0}),vt.temp!=null&&s.jsx(k$,{temp:vt.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>ke({amsId:vt.id,amsLabel:_d(vt.id,vt.tray.length),mode:"temperature"}),compact:!0})]})]}),s.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,Ss=!ln?.tray_type,_o=vt.id*4+nn,So=je===_o,No=ln?.tray_info_idx?$e?.[ln.tray_info_idx]:null,Ns=He?.[_o],Ni=ln?.tray_type?{vendor:VA(ln)?"Bambu Lab":"Generic",profile:No?.name||Ns?.preset_name||ln.tray_sub_brands||ln.tray_type,colorName:zA(ln.tray_id_name)||BA(ln.tray_color),colorHex:ln.tray_color||null,kFactor:HA(ln.k),fillLevel:Si?ln.remain:null,trayUuid:ln.tray_uuid||null}:null,Ws=Ve?.amsId===vt.id&&Ve?.slotId===nn,ca=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Ss?"opacity-50":""} ${So?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.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:Ss?"#666":"rgba(255,255,255,0.1)",borderStyle:Ss?"dashed":"solid"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:ln?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:Si&&ln?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${ln.remain}%`,backgroundColor:E$(ln.remain)}}):ln?.tray_type?s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return s.jsxs("div",{className:"relative group",children:[Ws&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(Dr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),ae?.state!=="RUNNING"&&s.jsx("button",{onClick:Hr=>{Hr.stopPropagation(),jn(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:s.jsx(ih,{className:"w-2.5 h-2.5 text-bambu-gray"})}),ae?.state!=="RUNNING"&&ir?.amsId===vt.id&&ir?.slotId===nn&&s.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:s.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}),jn(null))},disabled:Ws||!S("printers:ams_rfid"),title:S("printers:ams_rfid")?void 0:x("printers.permission.noAmsRfid"),children:[s.jsx(Dr,{className:`w-3 h-3 ${Ws?"animate-spin":""}`}),x("printers.rfid.reread")]})}),Ni?s.jsx(IA,{data:Ni,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Ni.trayUuid?c?.[Ni.trayUuid.toUpperCase()]:void 0,spoolmanUrl:u,onLinkSpool:o&&Ni.trayUuid?Hr=>{pe({trayUuid:Hr,trayInfo:{type:Ni.profile,color:Ni.colorHex||"",location:`${_d(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:ca}):s.jsx(b$,{configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:vt.id,trayId:nn,trayCount:vt.tray.length})},children:ca})]},nn)})})]},vt.id)})}),(Pt.length>0||ae.vt_tray&&ae.vt_tray.tray_type)&&s.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[Pt.map(vt=>{const wn=rt[String(vt.id)],Fr=vt.id>=128?vt.id-128:vt.id,Qr=wn!==void 0?wn:Fr,Br=Qr===1,qs=Qr===0,nn=vt.tray[0],ln=nn?.tray_type&&nn.remain>=0,Si=!nn?.tray_type,Ss=vt.id*4+(nn?.id??0),_o=je===Ss,So=nn?.tray_info_idx?$e?.[nn.tray_info_idx]:null,No=He?.[Ss],Ns=nn?.tray_type?{vendor:VA(nn)?"Bambu Lab":"Generic",profile:So?.name||No?.preset_name||nn.tray_sub_brands||nn.tray_type,colorName:zA(nn.tray_id_name)||BA(nn.tray_color),colorHex:nn.tray_color||null,kFactor:HA(nn.k),fillLevel:ln?nn.remain:null,trayUuid:nn.tray_uuid||null}:null,Ni=nn?.id??0,Ws=Ve?.amsId===vt.id&&Ve?.slotId===Ni,ca=s.jsxs("div",{className:`bg-bambu-dark-tertiary rounded p-1 text-center ${Si?"opacity-50":""} ${_o?"ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark":""}`,children:[s.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"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:nn?.tray_type||"—"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:ln?s.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${nn.remain}%`,backgroundColor:E$(nn.remain)}}):nn?.tray_type?s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"}):null})]});return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[s.jsx("span",{className:"text-[10px] text-white font-medium",children:_d(vt.id,vt.tray.length)}),qt&&(Br||qs)&&s.jsx(S$,{side:Br?"L":"R"})]}),s.jsxs("div",{className:"flex gap-1.5",children:[s.jsxs("div",{className:"relative group flex-1",children:[Ws&&s.jsx("div",{className:"absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20",children:s.jsx(Dr,{className:"w-4 h-4 text-bambu-green animate-spin"})}),ae?.state!=="RUNNING"&&s.jsx("button",{onClick:Hr=>{Hr.stopPropagation(),jn(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:s.jsx(ih,{className:"w-2.5 h-2.5 text-bambu-gray"})}),ae?.state!=="RUNNING"&&ir?.amsId===vt.id&&ir?.slotId===Ni&&s.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:s.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}),jn(null))},disabled:Ws||!S("printers:ams_rfid"),title:S("printers:ams_rfid")?void 0:x("printers.permission.noAmsRfid"),children:[s.jsx(Dr,{className:`w-3 h-3 ${Ws?"animate-spin":""}`}),x("printers.rfid.reread")]})}),Ns?s.jsx(IA,{data:Ns,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Ns.trayUuid?c?.[Ns.trayUuid.toUpperCase()]:void 0,spoolmanUrl:u,onLinkSpool:o&&Ns.trayUuid?Hr=>{pe({trayUuid:Hr,trayInfo:{type:Ns.profile,color:Ns.colorHex||"",location:_d(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:ca}):s.jsx(b$,{configureSlot:{enabled:S("printers:control"),onConfigure:()=>G({amsId:vt.id,trayId:Ni,trayCount:vt.tray.length})},children:ca})]}),(vt.humidity!=null||vt.temp!=null)&&s.jsxs("div",{className:"flex flex-col justify-center gap-1 shrink-0",children:[vt.temp!=null&&s.jsx(k$,{temp:vt.temp,goodThreshold:a?.tempGood,fairThreshold:a?.tempFair,onClick:()=>ke({amsId:vt.id,amsLabel:_d(vt.id,vt.tray.length),mode:"temperature"}),compact:!0}),vt.humidity!=null&&s.jsx(M$,{humidity:vt.humidity,goodThreshold:a?.humidityGood,fairThreshold:a?.humidityFair,onClick:()=>ke({amsId:vt.id,amsLabel:_d(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=je===254,Fr=vt.tray_info_idx?$e?.[vt.tray_info_idx]:null,Qr=He?.[1020],Br={vendor:VA(vt)?"Bambu Lab":"Generic",profile:Fr?.name||Qr?.preset_name||vt.tray_sub_brands||vt.tray_type||"Unknown",colorName:zA(vt.tray_id_name)||BA(vt.tray_color),colorHex:vt.tray_color||null,kFactor:HA(vt.k),fillLevel:null,trayUuid:vt.tray_uuid||null},qs=s.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:[s.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)"}}),s.jsx("div",{className:"text-[9px] text-white font-bold truncate",children:vt.tray_type||"Spool"}),s.jsx("div",{className:"mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full w-full rounded-full bg-white/50 dark:bg-gray-500/40"})})]});return s.jsxs("div",{className:"p-2.5 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary/30",children:[s.jsx("div",{className:"flex items-center gap-1 mb-2",children:s.jsx("span",{className:"text-[10px] text-white font-medium",children:x("printers.external")})}),s.jsx(IA,{data:Br,spoolman:{enabled:o,hasUnlinkedSpools:l,linkedSpoolId:Br.trayUuid?c?.[Br.trayUuid.toUpperCase()]:void 0,spoolmanUrl:u,onLinkSpool:o&&Br.trayUuid?nn=>{pe({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:qs})]})})()]})]})]})})()]}),Ye&&r==="expanded"&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(vh,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"text-sm text-white truncate",children:Ye.name}),pt&&s.jsxs("span",{className:`text-xs px-1.5 py-0.5 rounded flex-shrink-0 ${pt.state==="ON"?"bg-bambu-green/20 text-bambu-green":pt.state==="OFF"?"bg-red-500/20 text-red-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:[pt.state||"?",pt.state==="ON"&&pt.energy?.power!=null&&s.jsxs("span",{className:"text-yellow-400 ml-1.5",children:["· ",pt.energy.power,"W"]})]})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{onClick:()=>X(!0),disabled:Xn.isPending||pt?.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")?pt?.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:[s.jsx(Gu,{className:"w-3 h-3"}),"On"]}),s.jsxs("button",{onClick:()=>Q(!0),disabled:Xn.isPending||pt?.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")?pt?.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:[s.jsx(gM,{className:"w-3 h-3"}),"Off"]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.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"}),s.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:s.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"}`})})]})]}),bt&&bt.length>0&&s.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-bambu-dark-tertiary/50",children:[s.jsx(Fy,{className:"w-3.5 h-3.5 text-blue-400 flex-shrink-0"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"HA:"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:bt.map(nt=>s.jsxs("button",{onClick:()=>hi.mutate(nt.id),disabled:hi.isPending,title:`Run ${nt.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:[s.jsx(bo,{className:"w-2.5 h-2.5"}),nt.name]},nt.id))})]})]}),r==="expanded"&&s.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:[s.jsxs("div",{className:"text-xs text-bambu-gray",children:[s.jsx("p",{children:t.ip_address}),s.jsx("p",{className:"truncate",children:t.serial_number})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>ct.mutate(!ae?.chamber_light),disabled:!ae?.connected||ct.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:s.jsx(aPe,{on:ae?.chamber_light??!1,className:"w-4 h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>{if(f==="embedded"&&p)p(t.id,t.name);else{const nt=localStorage.getItem("cameraWindowState"),Pt=nt?JSON.parse(nt):{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(f==="embedded"?"printers.openCameraOverlay":"printers.openCameraWindow"),children:s.jsx(OR,{className:"w-4 h-4"})}),s.jsxs("div",{className:`inline-flex rounded-md ${t.plate_detection_enabled?"ring-1 ring-green-500":""}`,children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:Ht,disabled:!ae?.connected||ut.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:ut.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(X1,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:hn,disabled:!ae?.connected||U||!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:U?s.jsx(ft,{className:"w-3 h-3 animate-spin"}):s.jsx(Kr,{className:"w-3 h-3"})})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>F(!0),disabled:!S("printers:files"),title:S("printers:files")?x("printers.browseFiles"):x("printers.permission.noFiles"),children:[s.jsx(fM,{className:"w-4 h-4"}),"Files"]})]})]})]}),I&&s.jsx(qfe,{printerId:t.id,printerName:t.name,onClose:()=>F(!1)}),z&&s.jsx(Zfe,{printerId:t.id,printerName:t.name,onClose:()=>P(!1)}),q&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>un(),children:s.jsxs("div",{className:"bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full",onClick:nt=>nt.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[q.needs_calibration?s.jsx(X1,{className:"w-5 h-5 text-blue-500"}):q.is_empty?s.jsx(Ar,{className:"w-5 h-5 text-green-500"}):s.jsx(Qi,{className:"w-5 h-5 text-yellow-500"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Build Plate Check"}),q.reference_count!==void 0&&q.max_references&&s.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"]})]}),s.jsx("button",{onClick:()=>un(),className:"p-1 text-bambu-gray hover:text-white rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[q.needs_calibration?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-3 rounded-lg bg-blue-500/20 border border-blue-500/50",children:[s.jsx("p",{className:"font-medium text-blue-400",children:x("printers.plateDetection.calibrationRequired")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",dangerouslySetInnerHTML:{__html:x("printers.plateDetection.calibrationInstructions")}})]}),s.jsxs("div",{className:"text-sm text-bambu-gray space-y-2",children:[s.jsx("p",{children:x("printers.plateDetection.calibrationDescription")}),s.jsx("p",{dangerouslySetInnerHTML:{__html:x("printers.plateDetection.calibrationTip")}})]})]}):s.jsxs(s.Fragment,{children:[s.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:[s.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")}),s.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&&s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:x("printers.plateDetection.analysisPreview")}),s.jsx("img",{src:q.debug_image_url,alt:x("printers.plateDetection.analysisPreview"),className:"w-full rounded-lg border border-bambu-dark-tertiary"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:x("printers.plateDetection.analysisLegend")})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:q.message})]}),At&&At.references.length>0&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm font-medium text-white mb-2",children:x("printers.plateDetection.savedReferences",{count:At.references.length,max:At.max_references})}),s.jsx("div",{className:"grid grid-cols-5 gap-2",children:At.references.map(nt=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:ce.getPlateReferenceThumbnailUrl(t.id,nt.index),alt:nt.label||`Reference ${nt.index+1}`,className:"w-full aspect-video object-cover rounded border border-bambu-dark-tertiary"}),s.jsx("button",{onClick:()=>on(nt.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:s.jsx(Rt,{className:"w-3 h-3 text-white"})}),jt?.index===nt.index?s.jsx("input",{type:"text",value:jt.label,onChange:Pt=>Mt({...jt,label:Pt.target.value}),onBlur:()=>Gt(nt.index,jt.label),onKeyDown:Pt=>{Pt.key==="Enter"&&Gt(nt.index,jt.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")}):s.jsx("p",{className:"text-xs text-bambu-gray mt-1 truncate cursor-pointer hover:text-white",onClick:()=>Mt({index:nt.index,label:nt.label}),title:nt.label?x("printers.plateDetection.clickToEdit",{label:nt.label}):x("printers.plateDetection.clickToAddLabel"),children:nt.label||s.jsx("span",{className:"italic opacity-50",children:x("printers.noLabel")})}),s.jsx("p",{className:"text-[10px] text-bambu-gray/60",children:nt.timestamp?new Date(nt.timestamp).toLocaleDateString():""})]},nt.index))})]}),!q.needs_calibration&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:x("printers.roi.title")}),B?s.jsxs("div",{className:"flex gap-1",children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>O(null),disabled:ee,children:x("common.cancel")}),s.jsx(Te,{size:"sm",onClick:dn,disabled:ee,children:ee?s.jsx(ft,{className:"w-3 h-3 animate-spin"}):x("common.save")})]}):s.jsxs(Te,{variant:"ghost",size:"sm",onClick:()=>O(q.roi||{x:.15,y:.35,w:.7,h:.55}),children:[s.jsx(Zi,{className:"w-3 h-3 mr-1"}),x("common.edit")]})]}),B?s.jsxs("div",{className:"space-y-3 bg-bambu-dark-tertiary/50 p-3 rounded-lg",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:x("printers.roi.xStart")}),s.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:B.x,onChange:nt=>O({...B,x:parseFloat(nt.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(B.x*100),"%"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:x("printers.roi.yStart")}),s.jsx("input",{type:"range",min:"0",max:"0.9",step:"0.01",value:B.y,onChange:nt=>O({...B,y:parseFloat(nt.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(B.y*100),"%"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:x("printers.width")}),s.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:B.w,onChange:nt=>O({...B,w:parseFloat(nt.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(B.w*100),"%"]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-bambu-gray",children:x("printers.height")}),s.jsx("input",{type:"range",min:"0.1",max:"1",step:"0.01",value:B.h,onChange:nt=>O({...B,h:parseFloat(nt.target.value)}),className:"w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500"}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[Math.round(B.h*100),"%"]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:x("printers.roi.instruction")})]}):s.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),"%"]})]})]}),s.jsx("div",{className:"flex justify-end gap-2 p-4 border-t border-bambu-dark-tertiary",children:q.needs_calibration?s.jsxs(s.Fragment,{children:[s.jsx(Te,{variant:"ghost",onClick:()=>un(),children:x("common.cancel")}),s.jsx(Te,{onClick:()=>Mn(),disabled:Me,children:Me?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}),"Calibrating..."]}):"Calibrate Empty Plate"})]}):s.jsxs(s.Fragment,{children:[s.jsx(Te,{variant:"ghost",onClick:()=>Mn(),disabled:Me,children:Me?"Adding...":`Add Reference (${At?.references.length||0}/${At?.max_references||5})`}),s.jsx(Te,{onClick:()=>un(),children:"Close"})]})})]})}),$&&Ye&&s.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"),X(!1)},onCancel:()=>X(!1)}),V&&Ye&&s.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"),Q(!1)},onCancel:()=>Q(!1)}),H&&s.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(),K(!1)},onCancel:()=>K(!1)}),re&&s.jsx(Zn,{title:x("printers.confirm.pauseTitle"),message:x("printers.confirm.pauseMessage",{name:t.name}),confirmText:x("printers.confirm.pauseButton"),variant:"default",onConfirm:()=>{Ae.mutate(),ne(!1)},onCancel:()=>ne(!1)}),be&&s.jsx(Zn,{title:x("printers.confirm.resumeTitle"),message:x("printers.confirm.resumeMessage",{name:t.name}),confirmText:x("printers.confirm.resumeButton"),variant:"default",onConfirm:()=>{et.mutate(),me(!1)},onCancel:()=>me(!1)}),de&&s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>Ce(!1),onKeyDown:nt=>nt.key==="Escape"&&Ce(!1),tabIndex:-1,ref:nt=>nt?.focus(),children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 z-0"}),s.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:nt=>nt.stopPropagation(),children:[s.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:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(w$,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:x("printers.skipObjects.title")})]}),s.jsx("button",{onClick:()=>Ce(!1),className:"p-1 text-gray-500 dark:text-bambu-gray hover:text-gray-900 dark:hover:text-white rounded transition-colors",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),Et?Et.objects.length===0?s.jsxs("div",{className:"text-center py-8 px-4 text-bambu-gray",children:[s.jsx("p",{className:"text-sm",children:x("printers.noObjectsFound")}),s.jsx("p",{className:"text-xs mt-1 opacity-70",children:x("printers.objectsLoadedOnPrintStart")})]}):s.jsxs("div",{className:"flex flex-col overflow-hidden",children:[s.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:[s.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:s.jsx(Wde,{className:"w-4 h-4 text-blue-500 dark:text-blue-400"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-xs text-blue-600 dark:text-blue-300",children:x("printers.skipObjects.matchIdsInfo")}),s.jsx("p",{className:"text-[10px] text-blue-500/70 dark:text-blue-300/60",children:x("printers.skipObjects.printerShowsIds")})]}),s.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&&s.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:[s.jsx($i,{className:"w-4 h-4 text-amber-500 dark:text-amber-400 flex-shrink-0"}),s.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400",children:x("printers.skipObjects.waitForLayer",{layer:ae?.layer_num??0})})]}),s.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[s.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:s.jsxs("div",{className:"relative",children:[ae?.cover_url?s.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"}):s.jsx("div",{className:"w-full aspect-square rounded-lg bg-gray-100 dark:bg-bambu-dark flex items-center justify-center",children:s.jsx(oo,{className:"w-8 h-8 text-gray-300 dark:text-bambu-gray/30"})}),Et.objects.length>0&&s.jsx("div",{className:"absolute inset-0 pointer-events-none",children:Et.objects.map((nt,Pt)=>{let qt,vt;if(nt.x!=null&&nt.y!=null&&Et.bbox_all){const[wn,Fr,Qr,Br]=Et.bbox_all,qs=Qr-wn,nn=Br-Fr,ln=8,Si=100-ln*2;qt=ln+(nt.x-wn)/qs*Si,vt=ln+(Br-nt.y)/nn*Si,qt=Math.max(5,Math.min(95,qt)),vt=Math.max(5,Math.min(95,vt))}else if(nt.x!=null&&nt.y!=null)qt=nt.x/256*100,vt=100-nt.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 s.jsx("div",{className:`absolute flex items-center justify-center w-6 h-6 rounded-full text-[10px] font-bold shadow-lg ${nt.skipped?"bg-red-500 text-white line-through":"bg-bambu-green text-black"}`,style:{left:`${qt}%`,top:`${vt}%`,transform:"translate(-50%, -50%)"},title:nt.name,children:nt.id},nt.id)})}),s.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(nt=>!nt.skipped).length})})]})}),s.jsx("div",{className:"flex-1 min-w-0 overflow-y-auto",children:Et.objects.map(nt=>s.jsxs("div",{className:`
- flex items-center gap-3 px-4 py-3 border-b border-gray-200 dark:border-bambu-dark-tertiary/50 last:border-0
- ${nt.skipped?"bg-red-50 dark:bg-red-500/10":"hover:bg-gray-50 dark:hover:bg-bambu-dark/50"}
- `,children:[s.jsxs("div",{className:`
- w-12 h-12 flex-shrink-0 rounded-lg flex flex-col items-center justify-center
- ${nt.skipped?"bg-red-100 dark:bg-red-500/20 border border-red-300 dark:border-red-500/40":"bg-green-100 dark:bg-bambu-green/20 border border-green-300 dark:border-bambu-green/40"}
- `,children:[s.jsx("span",{className:`text-lg font-mono font-bold ${nt.skipped?"text-red-500 dark:text-red-400":"text-green-600 dark:text-bambu-green"}`,children:nt.id}),s.jsx("span",{className:`text-[8px] uppercase tracking-wider ${nt.skipped?"text-red-400/60":"text-green-500/60 dark:text-bambu-green/60"}`,children:"ID"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:`block text-sm truncate ${nt.skipped?"text-red-500 dark:text-red-400 line-through":"text-gray-900 dark:text-white"}`,children:nt.name}),nt.skipped&&s.jsx("span",{className:"text-[10px] text-red-400/60",children:x("printers.willBeSkipped")})]}),nt.skipped?s.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")}):s.jsx("button",{onClick:()=>De.mutate([nt.id]),disabled:De.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")})]},nt.id))})]})]}):s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ft,{className:"w-5 h-5 animate-spin text-bambu-gray"})})]})]}),Z&&s.jsx(nme,{printerName:t.name,errors:ae?.hms_errors||[],onClose:()=>se(!1)}),ie&&s.jsx(YCe,{isOpen:!!ie,onClose:()=>ke(null),printerId:t.id,printerName:t.name,amsId:ie.amsId,amsLabel:ie.amsLabel,initialMode:ie.mode,thresholds:a}),Oe&&s.jsx(QCe,{isOpen:!!Oe,onClose:()=>pe(null),trayUuid:Oe.trayUuid,trayInfo:Oe.trayInfo}),We&&s.jsx(iPe,{isOpen:!!We,onClose:()=>G(null),printerId:t.id,slotInfo:We,onSuccess:()=>{b.invalidateQueries({queryKey:["slotPresets",t.id]}),b.invalidateQueries({queryKey:["printerStatus",t.id]})}}),A&&s.jsx(vPe,{printer:t,onClose:()=>D(!1)}),Y&&Fe&&s.jsx(yPe,{printer:t,firmwareInfo:Fe,onClose:()=>ue(!1)}),ir&&s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>jn(null)})]})}function bPe({onClose:t,onAdd:e,existingSerials:n}){const{t:r}=Rn(),[i,a]=_.useState({name:"",serial_number:"",ip_address:"",access_code:"",model:"",location:"",auto_archive:!0}),[o,l]=_.useState(!1),[c,u]=_.useState([]),[d,f]=_.useState(""),[p,m]=_.useState(!1),[x,b]=_.useState(!1),[v,y]=_.useState("192.168.1.0/24"),[S,k]=_.useState({scanned:0,total:0});_.useEffect(()=>{Xl.getInfo().then(R=>{b(R.is_docker)}).catch(()=>{})},[]);const T=c.filter(R=>!n.includes(R.serial)),M=async()=>{f(""),u([]),l(!0),m(!1),k({scanned:0,total:0});try{if(x){await Xl.startSubnetScan(v);const R=setInterval(async()=>{try{const A=await Xl.getScanStatus();k({scanned:A.scanned,total:A.total});const D=await Xl.getDiscoveredPrinters();u(D),A.running||(clearInterval(R),l(!1),m(!0))}catch(A){console.error("Failed to get scan status:",A)}},500)}else{await Xl.startDiscovery(10);const R=setInterval(async()=>{try{const A=await Xl.getDiscoveredPrinters();u(A)}catch(A){console.error("Failed to get discovered printers:",A)}},1e3);setTimeout(async()=>{clearInterval(R);try{await Xl.stopDiscovery()}catch{}l(!1),m(!0);try{const A=await Xl.getDiscoveredPrinters();u(A)}catch(A){console.error("Failed to get final discovered printers:",A)}},1e4)}}catch(R){console.error("Failed to start discovery:",R),f(R instanceof Error?R.message:r("printers.discovery.failedToStart")),l(!1),m(!0)}},C=R=>R?{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"}[R]||R:"",E=R=>{const A=R.serial.startsWith("unknown-")?"":R.serial;a({...i,name:R.name||"",serial_number:A,ip_address:R.ip_address,model:C(R.model)}),u([])};return _.useEffect(()=>()=>{Xl.stopDiscovery().catch(()=>{}),Xl.stopSubnetScan().catch(()=>{})},[]),_.useEffect(()=>{const R=A=>{A.key==="Escape"&&t()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:t,children:s.jsx(St,{className:"w-full max-w-md",onClick:R=>R.stopPropagation(),children:s.jsxs(Nt,{children:[s.jsx("h2",{className:"text-xl font-semibold mb-4",children:r("printers.addPrinter")}),s.jsxs("div",{className:"mb-4 pb-4 border-b border-bambu-dark-tertiary",children:[x&&s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.discovery.subnetToScan")}),s.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:R=>y(R.target.value),placeholder:"192.168.1.0/24",disabled:o}),s.jsx("p",{className:"mt-1 text-xs text-bambu-gray",children:r("printers.discovery.dockerNote")})]}),s.jsx(Te,{type:"button",variant:"secondary",onClick:M,disabled:o,className:"w-full",children:o?s.jsxs(s.Fragment,{children:[s.jsx(ft,{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")]}):s.jsxs(s.Fragment,{children:[s.jsx(ya,{className:"w-4 h-4"}),r(x?"printers.discovery.scanSubnet":"printers.discovery.discoverNetwork")]})}),d&&s.jsx("div",{className:"mt-2 text-sm text-red-400",children:d}),T.length>0&&s.jsx("div",{className:"mt-3 space-y-2 max-h-40 overflow-y-auto",children:T.map(R=>s.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(R),children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"font-medium text-white text-sm truncate",children:R.name||R.serial}),s.jsxs("p",{className:"text-xs text-bambu-gray truncate",children:[C(R.model)||r("printers.discovery.unknown")," • ",R.ip_address,R.serial.startsWith("unknown-")&&s.jsxs("span",{className:"text-yellow-500",children:[" • ",r("printers.discovery.serialRequired")]})]})]}),s.jsx(Kr,{className:"w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2"})]},R.serial))}),o&&s.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&&s.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&&s.jsx("p",{className:"mt-2 text-sm text-bambu-gray text-center",children:r("printers.discovery.allConfigured")})]}),s.jsxs("form",{onSubmit:R=>{R.preventDefault(),e(i)},className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.name")}),s.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:R=>a({...i,name:R.target.value}),placeholder:r("printers.modal.myPrinter")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.ipAddress")}),s.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:R=>a({...i,ip_address:R.target.value}),placeholder:"192.168.1.100"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.serialNumber")}),s.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:R=>a({...i,serial_number:R.target.value}),placeholder:"01P00A000000000"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.accessCode")}),s.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:R=>a({...i,access_code:R.target.value}),placeholder:r("printers.modal.fromPrinterSettings")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.modal.modelOptional")}),s.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:R=>a({...i,model:R.target.value}),children:[s.jsx("option",{value:"",children:r("printers.modal.selectModel")}),s.jsxs("optgroup",{label:"H2 Series",children:[s.jsx("option",{value:"H2C",children:"H2C"}),s.jsx("option",{value:"H2D",children:"H2D"}),s.jsx("option",{value:"H2D Pro",children:"H2D Pro"}),s.jsx("option",{value:"H2S",children:"H2S"})]}),s.jsxs("optgroup",{label:"X1 Series",children:[s.jsx("option",{value:"X1E",children:"X1E"}),s.jsx("option",{value:"X1C",children:"X1 Carbon"}),s.jsx("option",{value:"X1",children:"X1"})]}),s.jsxs("optgroup",{label:"P Series",children:[s.jsx("option",{value:"P2S",children:"P2S"}),s.jsx("option",{value:"P1S",children:"P1S"}),s.jsx("option",{value:"P1P",children:"P1P"})]}),s.jsxs("optgroup",{label:"A1 Series",children:[s.jsx("option",{value:"A1",children:"A1"}),s.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("printers.modal.locationGroup")}),s.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:R=>a({...i,location:R.target.value}),placeholder:r("printers.modal.locationPlaceholder")}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r("printers.locationHelp")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"auto_archive",checked:i.auto_archive,onChange:R=>a({...i,auto_archive:R.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"auto_archive",className:"text-sm text-bambu-gray",children:r("printers.modal.autoArchiveLabel")})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),s.jsx(Te,{type:"submit",className:"flex-1",children:r("printers.addPrinter")})]})]})]})})})}function yPe({printer:t,firmwareInfo:e,onClose:n}){const{t:r}=Rn(),i=sn(),{showToast:a}=Hn(),[o,l]=_.useState(null),[c,u]=_.useState(!1),[d,f]=_.useState(null),{data:p,isLoading:m}=ot({queryKey:["firmwarePrepare",t.id],queryFn:()=>x1.prepareUpload(t.id),staleTime:3e4}),x=mt({mutationFn:()=>x1.startUpload(t.id),onSuccess:()=>{u(!0);const v=setInterval(async()=>{try{const y=await x1.getUploadStatus(t.id);l(y),(y.status==="complete"||y.status==="error")&&(clearInterval(v),f(null),u(!1),y.status==="complete"&&(a(r("printers.firmwareModal.uploadedToast"),"success"),i.invalidateQueries({queryKey:["firmwareUpdate",t.id]})))}catch{}},2e3);f(v)},onError:v=>{a(`Failed to start upload: ${v.message}`,"error"),u(!1)}});_.useEffect(()=>()=>{d&&clearInterval(d)},[d]);const b=()=>{l(null),x.mutate()};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsx(St,{className:"w-full max-w-md mx-4",children:s.jsxs(Nt,{children:[s.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[s.jsx("div",{className:"p-2 rounded-full bg-orange-500/20",children:s.jsx(wi,{className:"w-5 h-5 text-orange-400"})}),s.jsxs("div",{className:"flex-1",children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:r("printers.firmwareModal.title")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:t.name})]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3 mb-4",children:[s.jsxs("div",{className:"flex justify-between items-center text-sm",children:[s.jsx("span",{className:"text-bambu-gray",children:r("printers.firmwareModal.currentVersion")}),s.jsx("span",{className:"text-white font-mono",children:e.current_version||r("common.unknown")})]}),s.jsxs("div",{className:"flex justify-between items-center text-sm mt-1",children:[s.jsx("span",{className:"text-bambu-gray",children:r("printers.firmwareModal.latestVersion")}),s.jsx("span",{className:"text-orange-400 font-mono",children:e.latest_version})]}),e.release_notes&&s.jsxs("details",{className:"mt-3 text-sm",children:[s.jsx("summary",{className:"text-orange-400 cursor-pointer hover:underline",children:r("printers.firmwareModal.releaseNotes")}),s.jsx("div",{className:"mt-2 text-bambu-gray text-xs max-h-40 overflow-y-auto whitespace-pre-wrap",children:e.release_notes})]})]}),m?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm mb-4",children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),r("printers.firmwareModal.checkingPrereqs")]}):p&&!c&&!o?s.jsx("div",{className:"mb-4",children:p.can_proceed?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-green text-sm",children:[s.jsx(oo,{className:"w-4 h-4"}),r("printers.firmwareModal.sdCardReady")]}):s.jsx("div",{className:"space-y-1",children:p.errors.map((v,y)=>s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx($i,{className:"w-4 h-4 flex-shrink-0"}),v]},y))})}):null,(c||o)&&o&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray capitalize",children:o.status}),s.jsxs("span",{className:"text-white",children:[o.progress,"%"]})]}),s.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.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}%`}})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:o.message}),o.error&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:o.error})]}),o?.status==="complete"&&s.jsxs("div",{className:"bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4",children:[s.jsx("p",{className:"text-sm text-bambu-green font-medium mb-2",children:r("printers.firmwareModal.uploadedSuccess")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:r("printers.firmwareModal.applyInstructions")}),s.jsxs("ol",{className:"text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1",children:[s.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step1")}}),s.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step2")}}),s.jsx("li",{dangerouslySetInnerHTML:{__html:r("printers.firmwareModal.step3")}}),s.jsx("li",{children:r("printers.firmwareModal.step4")})]})]}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx(Te,{variant:"secondary",onClick:n,children:o?.status==="complete"?r("printers.firmwareModal.done"):r("common.cancel")}),p?.can_proceed&&!c&&o?.status!=="complete"&&s.jsx(Te,{onClick:b,disabled:x.isPending,children:x.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin mr-2"}),r("printers.firmwareModal.starting")]}):s.jsxs(s.Fragment,{children:[s.jsx(wi,{className:"w-4 h-4 mr-2"}),r("printers.firmwareModal.uploadFirmware")]})})]})]})})})}function vPe({printer:t,onClose:e}){const{t:n}=Rn(),r=sn(),{showToast:i}=Hn(),[a,o]=_.useState({name:t.name,ip_address:t.ip_address,access_code:"",model:t.model||"",location:t.location||"",auto_archive:t.auto_archive}),l=mt({mutationFn:u=>ce.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:a.name,ip_address:a.ip_address,model:a.model||void 0,location:a.location||void 0,auto_archive:a.auto_archive};a.access_code&&(d.access_code=a.access_code),l.mutate(d)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:e,children:s.jsx(St,{className:"w-full max-w-md",onClick:u=>u.stopPropagation(),children:s.jsxs(Nt,{children:[s.jsx("h2",{className:"text-xl font-semibold mb-4",children:n("printers.editPrinter")}),s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.name")}),s.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:a.name,onChange:u=>o({...a,name:u.target.value}),placeholder:n("printers.modal.myPrinter")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.ipAddress")}),s.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:a.ip_address,onChange:u=>o({...a,ip_address:u.target.value}),placeholder:"192.168.1.100"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.serialNumber")}),s.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}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("printers.serialCannotBeChanged")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.accessCode")}),s.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:a.access_code,onChange:u=>o({...a,access_code:u.target.value}),placeholder:n("printers.accessCodePlaceholder")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:n("printers.model")}),s.jsxs("select",{className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",value:a.model,onChange:u=>o({...a,model:u.target.value}),children:[s.jsx("option",{value:"",children:n("printers.modal.selectModel")}),s.jsxs("optgroup",{label:"H2 Series",children:[s.jsx("option",{value:"H2C",children:"H2C"}),s.jsx("option",{value:"H2D",children:"H2D"}),s.jsx("option",{value:"H2D Pro",children:"H2D Pro"}),s.jsx("option",{value:"H2S",children:"H2S"})]}),s.jsxs("optgroup",{label:"X1 Series",children:[s.jsx("option",{value:"X1E",children:"X1E"}),s.jsx("option",{value:"X1C",children:"X1 Carbon"}),s.jsx("option",{value:"X1",children:"X1"})]}),s.jsxs("optgroup",{label:"P Series",children:[s.jsx("option",{value:"P2S",children:"P2S"}),s.jsx("option",{value:"P1S",children:"P1S"}),s.jsx("option",{value:"P1P",children:"P1P"})]}),s.jsxs("optgroup",{label:"A1 Series",children:[s.jsx("option",{value:"A1",children:"A1"}),s.jsx("option",{value:"A1 Mini",children:"A1 Mini"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Location / Group"}),s.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:a.location,onChange:u=>o({...a,location:u.target.value}),placeholder:n("printers.modal.locationPlaceholder")}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:n("printers.locationHelp")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"edit_auto_archive",checked:a.auto_archive,onChange:u=>o({...a,auto_archive:u.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("label",{htmlFor:"edit_auto_archive",className:"text-sm text-bambu-gray",children:n("printers.modal.autoArchiveLabel")})]}),s.jsxs("div",{className:"flex gap-3 pt-4",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:n("common.cancel")}),s.jsx(Te,{type:"submit",className:"flex-1",disabled:l.isPending,children:l.isPending?n("common.saving"):n("printers.modal.saveChanges")})]})]})]})})})}function wPe(t){const{data:e}=ot({queryKey:["printerStatus",t],queryFn:()=>ce.getPrinterStatus(t),refetchInterval:3e4});return!e?.connected}function _Pe({printer:t,plug:e,onPowerOn:n,isPowering:r}){const i=wPe(t.id),{data:a}=ot({queryKey:["smartPlugStatus",e.id],queryFn:()=>ce.getSmartPlugStatus(e.id),refetchInterval:1e4});return i?s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"text-sm text-gray-900 dark:text-white truncate",children:t.name}),a&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${a.state==="ON"?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:a.state||"?"})]}),s.jsxs("button",{onClick:()=>n(e.id),disabled:r||a?.state==="ON",className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${a?.state==="ON"?"bg-bambu-green/20 text-bambu-green cursor-default":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white"}`,children:[s.jsx(Gu,{className:"w-3 h-3"}),r?"...":"On"]})]}):null}function SPe(){const{t}=Rn(),[e,n]=_.useState(!1),[r,i]=_.useState(()=>localStorage.getItem("hideDisconnectedPrinters")==="true"),[a,o]=_.useState(!1),[l,c]=_.useState(null),[u,d]=_.useState(()=>localStorage.getItem("printerSortBy")||"name"),[f,p]=_.useState(()=>localStorage.getItem("printerSortAsc")!=="false"),[m,x]=_.useState(()=>{const de=localStorage.getItem("printerCardSize");return de?parseInt(de,10):2}),b=m===1?"compact":"expanded",v=sn(),{showToast:y}=Hn(),{hasPermission:S}=Ci(),[k,T]=_.useState(()=>{const de=localStorage.getItem("openEmbeddedCameras");if(de)try{const Ce=JSON.parse(de);return new Map(Ce.map(ie=>[ie.id,ie]))}catch{return new Map}return new Map});_.useEffect(()=>{const de=Array.from(k.values());de.length>0?localStorage.setItem("openEmbeddedCameras",JSON.stringify(de)):localStorage.removeItem("openEmbeddedCameras")},[k]);const{data:M,isLoading:C}=ot({queryKey:["printers"],queryFn:ce.getPrinters}),{data:E}=ot({queryKey:["settings"],queryFn:ce.getSettings});_.useEffect(()=>{E?.camera_view_mode==="window"&&k.size>0&&T(new Map)},[E?.camera_view_mode,k.size]);const{data:R}=ot({queryKey:["smart-plugs"],queryFn:ce.getSmartPlugs}),{data:A}=ot({queryKey:["maintenanceOverview"],queryFn:ce.getMaintenanceOverview,staleTime:60*1e3}),{data:D}=ot({queryKey:["spoolman-status"],queryFn:ce.getSpoolmanStatus,staleTime:60*1e3}),I=D?.enabled&&D?.connected,{data:F}=ot({queryKey:["unlinked-spools"],queryFn:ce.getUnlinkedSpools,enabled:!!I,staleTime:30*1e3}),z=F&&F.length>0,{data:P}=ot({queryKey:["linked-spools"],queryFn:ce.getLinkedSpools,enabled:!!I,staleTime:30*1e3}),$=P?.linked,X=A?.reduce((de,Ce)=>(de[Ce.printer_id]={due_count:Ce.due_count,warning_count:Ce.warning_count,total_print_hours:Ce.total_print_hours},de),{})||{},V=R?.reduce((de,Ce)=>(Ce.printer_id&&(de[Ce.printer_id]=Ce),de),{})||{},Q=mt({mutationFn:ce.createPrinter,onSuccess:()=>{v.invalidateQueries({queryKey:["printers"]}),v.invalidateQueries({queryKey:["maintenanceOverview"]}),n(!1)},onError:de=>y(de.message||t("printers.toast.failedToAdd"),"error")}),Z=mt({mutationFn:de=>ce.controlSmartPlug(de,"on"),onSuccess:()=>{v.invalidateQueries({queryKey:["smart-plugs"]}),c(null)},onError:()=>{c(null)}}),se=()=>{const de=!r;i(de),localStorage.setItem("hideDisconnectedPrinters",String(de))},H=de=>{d(de),localStorage.setItem("printerSortBy",de)},K=()=>{const de=!f;p(de),localStorage.setItem("printerSortAsc",String(de))},re=()=>{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"}},ne=["S","M","L","XL"],be=_.useMemo(()=>{if(!M)return[];const de=[...M];switch(u){case"name":de.sort((Ce,ie)=>Ce.name.localeCompare(ie.name));break;case"model":de.sort((Ce,ie)=>(Ce.model||"").localeCompare(ie.model||""));break;case"location":de.sort((Ce,ie)=>{const ke=Ce.location||"",Oe=ie.location||"";return!ke&&Oe?1:ke&&!Oe?-1:ke.localeCompare(Oe)||Ce.name.localeCompare(ie.name)});break;case"status":de.sort((Ce,ie)=>{const ke=v.getQueryData(["printerStatus",Ce.id]),Oe=v.getQueryData(["printerStatus",ie.id]),pe=We=>We?.connected?We.state==="RUNNING"?0:1:2;return pe(ke)-pe(Oe)});break}return f||de.reverse(),de},[M,u,f,v]),me=_.useMemo(()=>{if(u!=="location")return null;const de={};return be.forEach(Ce=>{const ie=Ce.location||"Ungrouped";de[ie]||(de[ie]=[]),de[ie].push(Ce)}),de},[u,be]);return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("printers.title")}),s.jsx(xPe,{printers:M})]}),s.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 flex-wrap",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("select",{value:u,onChange:de=>H(de.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:[s.jsx("option",{value:"name",children:t("printers.sort.name")}),s.jsx("option",{value:"status",children:t("printers.sort.status")}),s.jsx("option",{value:"model",children:t("printers.sort.model")}),s.jsx("option",{value:"location",children:t("printers.sort.location")})]}),s.jsx("button",{onClick:K,className:"p-1.5 rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:t(f?"printers.sort.descending":"printers.sort.ascending"),children:f?s.jsx(Ig,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(G0,{className:"w-4 h-4 text-bambu-gray"})})]}),s.jsx("div",{className:"flex items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:ne.map((de,Ce)=>{const ie=Ce+1,ke=m===ie;return s.jsx("button",{onClick:()=>{x(ie),localStorage.setItem("printerCardSize",String(ie))},className:`px-2 py-1.5 text-xs font-medium transition-colors ${Ce===0?"rounded-l-lg":""} ${Ce===ne.length-1?"rounded-r-lg":""} ${ke?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary hover:text-white"}`,title:t(de==="S"?"printers.cardSize.small":de==="M"?"printers.cardSize.medium":de==="L"?"printers.cardSize.large":"printers.cardSize.extraLarge"),children:de},de)})}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:r,onChange:se,className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),t("printers.hideOffline")]}),r&&Object.keys(V).length>0&&s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>o(!a),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:[s.jsx(Gu,{className:"w-4 h-4"}),t("printers.powerOn"),s.jsx(Kr,{className:`w-3 h-3 transition-transform ${a?"rotate-180":""}`})]}),a&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>o(!1)}),s.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:[s.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")}),M?.filter(de=>V[de.id]).map(de=>s.jsx(_Pe,{printer:de,plug:V[de.id],onPowerOn:Ce=>{c(Ce),Z.mutate(Ce)},isPowering:l===V[de.id]?.id},de.id)),M?.filter(de=>V[de.id]).length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No printers with smart plugs"})]})]})]}),s.jsxs(Te,{onClick:()=>n(!0),disabled:!S("printers:create"),title:S("printers:create")?void 0:t("printers.permission.noAdd"),children:[s.jsx(fr,{className:"w-4 h-4"}),t("printers.addPrinter")]})]})]}),C?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):M?.length===0?s.jsx(St,{children:s.jsxs(Nt,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:t("printers.noPrintersConfigured")}),s.jsxs(Te,{onClick:()=>n(!0),disabled:!S("printers:create"),title:S("printers:create")?void 0:t("printers.permission.noAdd"),children:[s.jsx(fr,{className:"w-4 h-4"}),t("printers.addPrinter")]})]})}):me?s.jsx("div",{className:"space-y-6",children:Object.entries(me).map(([de,Ce])=>s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white mb-3 flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full bg-bambu-green"}),de,s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",Ce.length,")"]})]}),s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${re()}`,children:Ce.map(ie=>s.jsx(A$,{printer:ie,hideIfDisconnected:r,maintenanceInfo:X[ie.id],viewMode:b,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:z,linkedSpools:$,spoolmanUrl:D?.url,timeFormat:E?.time_format||"system",cameraViewMode:E?.camera_view_mode||"window",onOpenEmbeddedCamera:(ke,Oe)=>T(pe=>new Map(pe).set(ke,{id:ke,name:Oe})),checkPrinterFirmware:E?.check_printer_firmware!==!1},ie.id))})]},de))}):s.jsx("div",{className:`grid gap-4 ${m>=3?"gap-6":""} ${re()}`,children:be.map(de=>s.jsx(A$,{printer:de,hideIfDisconnected:r,maintenanceInfo:X[de.id],viewMode:b,cardSize:m,spoolmanEnabled:I,hasUnlinkedSpools:z,linkedSpools:$,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:(Ce,ie)=>T(ke=>new Map(ke).set(Ce,{id:Ce,name:ie})),checkPrinterFirmware:E?.check_printer_firmware!==!1},de.id))}),e&&s.jsx(bPe,{onClose:()=>n(!1),onAdd:de=>Q.mutate(de),existingSerials:M?.map(de=>de.serial_number)||[]}),Array.from(k.values()).map((de,Ce)=>s.jsx(Qfe,{printerId:de.id,printerName:de.name,viewerIndex:Ce,onClose:()=>T(ie=>{const ke=new Map(ie);return ke.delete(de.id),ke})},de.id))]})}function NPe(){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 MPe(){switch(NPe()){case"windows":return"bambustudio://";case"macos":case"linux":default:return"bambustudioopen://"}}function pu(t){const e=MPe();window.location.href=`${e}${encodeURIComponent(t)}`}const B4="181",Tg={ROTATE:0,DOLLY:1,PAN:2},bg={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},kPe=0,C$=1,EPe=2,JZ=1,TPe=2,lu=3,kh=0,Is=1,ic=2,Au=0,Ag=1,P$=2,j$=3,D$=4,APe=5,Nf=100,CPe=101,PPe=102,jPe=103,DPe=104,RPe=200,OPe=201,LPe=202,FPe=203,S3=204,N3=205,IPe=206,UPe=207,zPe=208,BPe=209,HPe=210,$Pe=211,VPe=212,GPe=213,qPe=214,M3=0,k3=1,E3=2,Qg=3,T3=4,A3=5,C3=6,P3=7,H4=0,WPe=1,KPe=2,lh=0,XPe=1,YPe=2,QPe=3,ZPe=4,JPe=5,eje=6,tje=7,eJ=300,Zg=301,Jg=302,j3=303,D3=304,f2=306,R3=1e3,wu=1001,O3=1002,mo=1003,nje=1004,Jw=1005,el=1006,GA=1007,Of=1008,vc=1009,tJ=1010,nJ=1011,dy=1012,$4=1013,pm=1014,_u=1015,Cx=1016,V4=1017,G4=1018,hy=1020,rJ=35902,iJ=35899,aJ=1021,sJ=1022,jl=1023,fy=1026,my=1027,oJ=1028,q4=1029,W4=1030,K4=1031,X4=1033,M1=33776,k1=33777,E1=33778,T1=33779,L3=35840,F3=35841,I3=35842,U3=35843,z3=36196,B3=37492,H3=37496,$3=37808,V3=37809,G3=37810,q3=37811,W3=37812,K3=37813,X3=37814,Y3=37815,Q3=37816,Z3=37817,J3=37818,eD=37819,tD=37820,nD=37821,rD=36492,iD=36494,aD=36495,sD=36283,oD=36284,lD=36285,cD=36286,rje=3200,ije=3201,lJ=0,aje=1,Kd="",Vo="srgb",ex="srgb-linear",KS="linear",Mr="srgb",vp=7680,R$=519,sje=512,oje=513,lje=514,cJ=515,cje=516,uje=517,dje=518,hje=519,O$=35044,L$="300 es",lc=2e3,XS=2001;function uJ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function YS(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function fje(){const t=YS("canvas");return t.style.display="block",t}const F$={};function I$(...t){const e="THREE."+t.shift();console.log(e,...t)}function xn(...t){const e="THREE."+t.shift();console.warn(e,...t)}function Ti(...t){const e="THREE."+t.shift();console.error(e,...t)}function py(...t){const e=t.join(" ");e in F$||(F$[e]=!0,xn(...t))}function mje(t,e,n){return new Promise(function(r,i){function a(){switch(t.clientWaitSync(e,t.SYNC_FLUSH_COMMANDS_BIT,0)){case t.WAIT_FAILED:i();break;case t.TIMEOUT_EXPIRED:setTimeout(a,n);break;default:r()}}setTimeout(a,n)})}let Cm=class{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){const r=this._listeners;return r===void 0?!1:r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){const r=this._listeners;if(r===void 0)return;const i=r[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){const n=this._listeners;if(n===void 0)return;const r=n[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,o=i.length;a<o;a++)i[a].call(this,e);e.target=null}}};const $a=["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"],A1=Math.PI/180,uD=180/Math.PI;function fv(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return($a[t&255]+$a[t>>8&255]+$a[t>>16&255]+$a[t>>24&255]+"-"+$a[e&255]+$a[e>>8&255]+"-"+$a[e>>16&15|64]+$a[e>>24&255]+"-"+$a[n&63|128]+$a[n>>8&255]+"-"+$a[n>>16&255]+$a[n>>24&255]+$a[r&255]+$a[r>>8&255]+$a[r>>16&255]+$a[r>>24&255]).toLowerCase()}function zn(t,e,n){return Math.max(e,Math.min(n,t))}function pje(t,e){return(t%e+e)%e}function qA(t,e,n){return(1-n)*t+n*e}function Ub(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 Cs(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 gje={DEG2RAD:A1};let Cn=class dJ{constructor(e=0,n=0){dJ.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=zn(this.x,e.x,n.x),this.y=zn(this.y,e.y,n.y),this}clampScalar(e,n){return this.x=zn(this.x,e,n),this.y=zn(this.y,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(zn(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(zn(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,o=this.y-e.y;return this.x=a*r-o*i+e.x,this.y=a*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}},gm=class{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3],p=a[o+0],m=a[o+1],x=a[o+2],b=a[o+3];if(l<=0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l>=1){e[n+0]=p,e[n+1]=m,e[n+2]=x,e[n+3]=b;return}if(f!==b||c!==p||u!==m||d!==x){let v=c*p+u*m+d*x+f*b;v<0&&(p=-p,m=-m,x=-x,b=-b,v=-v);let y=1-l;if(v<.9995){const S=Math.acos(v),k=Math.sin(S);y=Math.sin(y*S)/k,l=Math.sin(l*S)/k,c=c*y+p*l,u=u*y+m*l,d=d*y+x*l,f=f*y+b*l}else{c=c*y+p*l,u=u*y+m*l,d=d*y+x*l,f=f*y+b*l;const S=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=S,u*=S,d*=S,f*=S}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[o],p=a[o+1],m=a[o+2],x=a[o+3];return e[n]=l*x+d*f+c*m-u*p,e[n+1]=c*x+d*p+u*f-l*m,e[n+2]=u*x+d*m+l*p-c*f,e[n+3]=d*x-l*f-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,a=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),p=c(r/2),m=c(i/2),x=c(a/2);switch(o){case"XYZ":this._x=p*d*f+u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f-p*m*x;break;case"YXZ":this._x=p*d*f+u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f+p*m*x;break;case"ZXY":this._x=p*d*f-u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f-p*m*x;break;case"ZYX":this._x=p*d*f-u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f+p*m*x;break;case"YZX":this._x=p*d*f+u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f-p*m*x;break;case"XZY":this._x=p*d*f-u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f+p*m*x;break;default:xn("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],a=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],p=r+l+f;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(d-c)*m,this._y=(a-u)*m,this._z=(o-i)*m}else if(r>l&&r>f){const m=2*Math.sqrt(1+r-l-f);this._w=(d-c)/m,this._x=.25*m,this._y=(i+o)/m,this._z=(a+u)/m}else if(l>f){const m=2*Math.sqrt(1+l-r-f);this._w=(a-u)/m,this._x=(i+o)/m,this._y=.25*m,this._z=(c+d)/m}else{const m=2*Math.sqrt(1+f-r-l);this._w=(o-i)/m,this._x=(a+u)/m,this._y=(c+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<1e-8?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(zn(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-a*c,this._y=i*d+o*c+a*l-r*u,this._z=a*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n<=0)return this;if(n>=1)return this.copy(e);let r=e._x,i=e._y,a=e._z,o=e._w,l=this.dot(e);l<0&&(r=-r,i=-i,a=-a,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+a*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+a*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),a=Math.sqrt(r);return this.set(i*Math.sin(e),i*Math.cos(e),a*Math.sin(n),a*Math.cos(n))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}},ht=class hJ{constructor(e=0,n=0,r=0){hJ.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(U$.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(U$.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,o=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*o,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*o,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-a*i),f=2*(a*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*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,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=zn(this.x,e.x,n.x),this.y=zn(this.y,e.y,n.y),this.z=zn(this.z,e.z,n.z),this}clampScalar(e,n){return this.x=zn(this.x,e,n),this.y=zn(this.y,e,n),this.z=zn(this.z,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(zn(r,e,n))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*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 WA.copy(this).projectOnVector(e),this.sub(WA)}reflect(e){return this.sub(WA.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(zn(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 WA=new ht,U$=new gm;let Dn=class fJ{constructor(e,n,r,i,a,o,l,c,u){fJ.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u)}set(e,n,r,i,a,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=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,a=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],p=r[2],m=r[5],x=r[8],b=i[0],v=i[3],y=i[6],S=i[1],k=i[4],T=i[7],M=i[2],C=i[5],E=i[8];return a[0]=o*b+l*S+c*M,a[3]=o*v+l*k+c*C,a[6]=o*y+l*T+c*E,a[1]=u*b+d*S+f*M,a[4]=u*v+d*k+f*C,a[7]=u*y+d*T+f*E,a[2]=p*b+m*S+x*M,a[5]=p*v+m*k+x*C,a[8]=p*y+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],a=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*a*d+r*l*c+i*a*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,p=l*c-d*a,m=u*a-o*c,x=n*f+r*p+i*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const b=1/x;return e[0]=f*b,e[1]=(i*u-d*r)*b,e[2]=(l*r-i*o)*b,e[3]=p*b,e[4]=(d*n-i*c)*b,e[5]=(i*a-l*n)*b,e[6]=m*b,e[7]=(r*c-u*n)*b,e[8]=(o*n-r*a)*b,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,o,l){const c=Math.cos(a),u=Math.sin(a);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(KA.makeScale(e,n)),this}rotate(e){return this.premultiply(KA.makeRotation(-e)),this}translate(e,n){return this.premultiply(KA.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 KA=new Dn,z$=new Dn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),B$=new Dn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function xje(){const t={enabled:!0,workingColorSpace:ex,spaces:{},convert:function(i,a,o){return this.enabled===!1||a===o||!a||!o||(this.spaces[a].transfer===Mr&&(i.r=Cu(i.r),i.g=Cu(i.g),i.b=Cu(i.b)),this.spaces[a].primaries!==this.spaces[o].primaries&&(i.applyMatrix3(this.spaces[a].toXYZ),i.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===Mr&&(i.r=Cg(i.r),i.g=Cg(i.g),i.b=Cg(i.b))),i},workingToColorSpace:function(i,a){return this.convert(i,this.workingColorSpace,a)},colorSpaceToWorking:function(i,a){return this.convert(i,a,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===Kd?KS:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,a=this.workingColorSpace){return i.fromArray(this.spaces[a].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,a,o){return i.copy(this.spaces[a].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,a){return py("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),t.workingToColorSpace(i,a)},toWorkingColorSpace:function(i,a){return py("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),t.colorSpaceToWorking(i,a)}},e=[.64,.33,.3,.6,.15,.06],n=[.2126,.7152,.0722],r=[.3127,.329];return t.define({[ex]:{primaries:e,whitePoint:r,transfer:KS,toXYZ:z$,fromXYZ:B$,luminanceCoefficients:n,workingColorSpaceConfig:{unpackColorSpace:Vo},outputColorSpaceConfig:{drawingBufferColorSpace:Vo}},[Vo]:{primaries:e,whitePoint:r,transfer:Mr,toXYZ:z$,fromXYZ:B$,luminanceCoefficients:n,outputColorSpaceConfig:{drawingBufferColorSpace:Vo}}}),t}const cr=xje();function Cu(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function Cg(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let wp,bje=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{wp===void 0&&(wp=YS("canvas")),wp.width=e.width,wp.height=e.height;const i=wp.getContext("2d");e instanceof ImageData?i.putImageData(e,0,0):i.drawImage(e,0,0,e.width,e.height),r=wp}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=YS("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let o=0;o<a.length;o++)a[o]=Cu(a[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(Cu(n[r]/255)*255):n[r]=Cu(n[r]);return{data:n,width:e.width,height:e.height}}else return xn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}},yje=0,Y4=class{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:yje++}),this.uuid=fv(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const n=this.data;return typeof HTMLVideoElement<"u"&&n instanceof HTMLVideoElement?e.set(n.videoWidth,n.videoHeight,0):n instanceof VideoFrame?e.set(n.displayHeight,n.displayWidth,0):n!==null?e.set(n.width,n.height,n.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?a.push(XA(i[o].image)):a.push(XA(i[o]))}else a=XA(i);r.url=a}return n||(e.images[this.uuid]=r),r}};function XA(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?bje.getDataURL(t):t.data?{data:Array.from(t.data),width:t.width,height:t.height,type:t.data.constructor.name}:(xn("Texture: Unable to serialize Texture."),{})}let vje=0;const YA=new ht;let Hl=class C1 extends Cm{constructor(e=C1.DEFAULT_IMAGE,n=C1.DEFAULT_MAPPING,r=wu,i=wu,a=el,o=Of,l=jl,c=vc,u=C1.DEFAULT_ANISOTROPY,d=Kd){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:vje++}),this.uuid=fv(),this.name="",this.source=new Y4(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,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(YA).x}get height(){return this.source.getSize(YA).y}get depth(){return this.source.getSize(YA).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){xn(`Texture.setValues(): parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){xn(`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!==eJ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case R3:e.x=e.x-Math.floor(e.x);break;case wu:e.x=e.x<0?0:1;break;case O3:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case R3:e.y=e.y-Math.floor(e.y);break;case wu:e.y=e.y<0?0:1;break;case O3:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}};Hl.DEFAULT_IMAGE=null;Hl.DEFAULT_MAPPING=eJ;Hl.DEFAULT_ANISOTROPY=1;let zi=class mJ{constructor(e=0,n=0,r=0,i=1){mJ.prototype.isVector4=!0,this.x=e,this.y=n,this.z=r,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,r,i){return this.x=e,this.y=n,this.z=r,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*a,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*a,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*a,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*a,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],p=c[1],m=c[5],x=c[9],b=c[2],v=c[6],y=c[10];if(Math.abs(d-p)<.01&&Math.abs(f-b)<.01&&Math.abs(x-v)<.01){if(Math.abs(d+p)<.1&&Math.abs(f+b)<.1&&Math.abs(x+v)<.1&&Math.abs(u+m+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const k=(u+1)/2,T=(m+1)/2,M=(y+1)/2,C=(d+p)/4,E=(f+b)/4,R=(x+v)/4;return k>T&&k>M?k<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(k),i=C/r,a=E/r):T>M?T<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(T),r=C/i,a=R/i):M<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(M),r=E/a,i=R/a),this.set(r,i,a,n),this}let S=Math.sqrt((v-x)*(v-x)+(f-b)*(f-b)+(p-d)*(p-d));return Math.abs(S)<.001&&(S=1),this.x=(v-x)/S,this.y=(f-b)/S,this.z=(p-d)/S,this.w=Math.acos((u+m+y-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=zn(this.x,e.x,n.x),this.y=zn(this.y,e.y,n.y),this.z=zn(this.z,e.z,n.z),this.w=zn(this.w,e.w,n.w),this}clampScalar(e,n){return this.x=zn(this.x,e,n),this.y=zn(this.y,e,n),this.z=zn(this.z,e,n),this.w=zn(this.w,e,n),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(zn(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}},wje=class extends Cm{constructor(e=1,n=1,r={}){super(),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:el,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 zi(0,0,e,n),this.scissorTest=!1,this.viewport=new zi(0,0,e,n);const i={width:e,height:n,depth:r.depth},a=new Hl(i);this.textures=[];const o=r.count;for(let l=0;l<o;l++)this.textures[l]=a.clone(),this.textures[l].isRenderTargetTexture=!0,this.textures[l].renderTarget=this;this._setTextureOptions(r),this.depthBuffer=r.depthBuffer,this.stencilBuffer=r.stencilBuffer,this.resolveDepthBuffer=r.resolveDepthBuffer,this.resolveStencilBuffer=r.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=r.depthTexture,this.samples=r.samples,this.multiview=r.multiview}_setTextureOptions(e={}){const n={minFilter:el,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(n.mapping=e.mapping),e.wrapS!==void 0&&(n.wrapS=e.wrapS),e.wrapT!==void 0&&(n.wrapT=e.wrapT),e.wrapR!==void 0&&(n.wrapR=e.wrapR),e.magFilter!==void 0&&(n.magFilter=e.magFilter),e.minFilter!==void 0&&(n.minFilter=e.minFilter),e.format!==void 0&&(n.format=e.format),e.type!==void 0&&(n.type=e.type),e.anisotropy!==void 0&&(n.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(n.colorSpace=e.colorSpace),e.flipY!==void 0&&(n.flipY=e.flipY),e.generateMipmaps!==void 0&&(n.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(n.internalFormat=e.internalFormat);for(let r=0;r<this.textures.length;r++)this.textures[r].setValues(n)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,n,r=1){if(this.width!==e||this.height!==n||this.depth!==r){this.width=e,this.height=n,this.depth=r;for(let i=0,a=this.textures.length;i<a;i++)this.textures[i].image.width=e,this.textures[i].image.height=n,this.textures[i].image.depth=r,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let n=0,r=e.textures.length;n<r;n++){this.textures[n]=e.textures[n].clone(),this.textures[n].isRenderTargetTexture=!0,this.textures[n].renderTarget=this;const i=Object.assign({},e.textures[n].image);this.textures[n].source=new Y4(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"})}},xm=class extends wje{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}},pJ=class extends Hl{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=mo,this.minFilter=mo,this.wrapR=wu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}},_je=class extends Hl{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=mo,this.minFilter=mo,this.wrapR=wu,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}},bm=class{constructor(e=new ht(1/0,1/0,1/0),n=new ht(-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(vl.fromArray(e,n));return this}setFromBufferAttribute(e){this.makeEmpty();for(let n=0,r=e.count;n<r;n++)this.expandByPoint(vl.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=vl.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(r),this.max.copy(e).add(r),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const r=e.geometry;if(r!==void 0){const a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=a.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,vl):vl.fromBufferAttribute(a,o),vl.applyMatrix4(e.matrixWorld),this.expandByPoint(vl);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),e_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),e_.copy(r.boundingBox)),e_.applyMatrix4(e.matrixWorld),this.union(e_)}const i=e.children;for(let a=0,o=i.length;a<o;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,vl),vl.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(zb),t_.subVectors(this.max,zb),_p.subVectors(e.a,zb),Sp.subVectors(e.b,zb),Np.subVectors(e.c,zb),Sd.subVectors(Sp,_p),Nd.subVectors(Np,Sp),of.subVectors(_p,Np);let n=[0,-Sd.z,Sd.y,0,-Nd.z,Nd.y,0,-of.z,of.y,Sd.z,0,-Sd.x,Nd.z,0,-Nd.x,of.z,0,-of.x,-Sd.y,Sd.x,0,-Nd.y,Nd.x,0,-of.y,of.x,0];return!QA(n,_p,Sp,Np,t_)||(n=[1,0,0,0,1,0,0,0,1],!QA(n,_p,Sp,Np,t_))?!1:(n_.crossVectors(Sd,Nd),n=[n_.x,n_.y,n_.z],QA(n,_p,Sp,Np,t_))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,vl).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(vl).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:(Wc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Wc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Wc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Wc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Wc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Wc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Wc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Wc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Wc),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 Wc=[new ht,new ht,new ht,new ht,new ht,new ht,new ht,new ht],vl=new ht,e_=new bm,_p=new ht,Sp=new ht,Np=new ht,Sd=new ht,Nd=new ht,of=new ht,zb=new ht,t_=new ht,n_=new ht,lf=new ht;function QA(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){lf.fromArray(t,a);const l=i.x*Math.abs(lf.x)+i.y*Math.abs(lf.y)+i.z*Math.abs(lf.z),c=e.dot(lf),u=n.dot(lf),d=r.dot(lf);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const Sje=new bm,Bb=new ht,ZA=new ht;let m2=class{constructor(e=new ht,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):Sje.setFromPoints(e).getCenter(r);let i=0;for(let a=0,o=e.length;a<o;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Bb.subVectors(e,this.center);const n=Bb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Bb,i/r),this.radius+=i}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(ZA.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Bb.copy(e.center).add(ZA)),this.expandByPoint(Bb.copy(e.center).sub(ZA))),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 Kc=new ht,JA=new ht,r_=new ht,Md=new ht,eC=new ht,i_=new ht,tC=new ht;let Q4=class{constructor(e=new ht,n=new ht(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,Kc)),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=Kc.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(Kc.copy(this.origin).addScaledVector(this.direction,n),Kc.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){JA.copy(e).add(n).multiplyScalar(.5),r_.copy(n).sub(e).normalize(),Md.copy(this.origin).sub(JA);const a=e.distanceTo(n)*.5,o=-this.direction.dot(r_),l=Md.dot(this.direction),c=-Md.dot(r_),u=Md.lengthSq(),d=Math.abs(1-o*o);let f,p,m,x;if(d>0)if(f=o*c-l,p=o*l-c,x=a*d,f>=0)if(p>=-x)if(p<=x){const b=1/d;f*=b,p*=b,m=f*(f+o*p+2*l)+p*(o*f+p+2*c)+u}else p=a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;else p=-a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;else p<=-x?(f=Math.max(0,-(-o*a+l)),p=f>0?-a:Math.min(Math.max(-a,-c),a),m=-f*f+p*(p+2*c)+u):p<=x?(f=0,p=Math.min(Math.max(-a,-c),a),m=p*(p+2*c)+u):(f=Math.max(0,-(o*a+l)),p=f>0?a:Math.min(Math.max(-a,-c),a),m=-f*f+p*(p+2*c)+u);else p=o>0?-a:a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(JA).addScaledVector(r_,p),m}intersectSphere(e,n){Kc.subVectors(e.center,this.origin);const r=Kc.dot(this.direction),i=Kc.dot(Kc)-r*r,a=e.radius*e.radius;if(i>a)return null;const o=Math.sqrt(a-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,a,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=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?(a=(e.min.y-p.y)*d,o=(e.max.y-p.y)*d):(a=(e.max.y-p.y)*d,o=(e.min.y-p.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-p.z)*f,c=(e.max.z-p.z)*f):(l=(e.max.z-p.z)*f,c=(e.min.z-p.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,Kc)!==null}intersectTriangle(e,n,r,i,a){eC.subVectors(n,e),i_.subVectors(r,e),tC.crossVectors(eC,i_);let o=this.direction.dot(tC),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(i_.crossVectors(Md,i_));if(c<0)return null;const u=l*this.direction.dot(eC.cross(Md));if(u<0||c+u>o)return null;const d=-l*Md.dot(tC);return d<0?null:this.at(d/o,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}},Gi=class dD{constructor(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,v){dD.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,v)}set(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,v){const y=this.elements;return y[0]=e,y[4]=n,y[8]=r,y[12]=i,y[1]=a,y[5]=o,y[9]=l,y[13]=c,y[2]=u,y[6]=d,y[10]=f,y[14]=p,y[3]=m,y[7]=x,y[11]=b,y[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 dD().fromArray(this.elements)}copy(e){const n=this.elements,r=e.elements;return n[0]=r[0],n[1]=r[1],n[2]=r[2],n[3]=r[3],n[4]=r[4],n[5]=r[5],n[6]=r[6],n[7]=r[7],n[8]=r[8],n[9]=r[9],n[10]=r[10],n[11]=r[11],n[12]=r[12],n[13]=r[13],n[14]=r[14],n[15]=r[15],this}copyPosition(e){const n=this.elements,r=e.elements;return n[12]=r[12],n[13]=r[13],n[14]=r[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,r){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this}makeBasis(e,n,r){return this.set(e.x,n.x,r.x,0,e.y,n.y,r.y,0,e.z,n.z,r.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,r=e.elements,i=1/Mp.setFromMatrixColumn(e,0).length(),a=1/Mp.setFromMatrixColumn(e,1).length(),o=1/Mp.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,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,a=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const p=o*d,m=o*f,x=l*d,b=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=m+x*u,n[5]=p-b*u,n[9]=-l*c,n[2]=b-p*u,n[6]=x+m*u,n[10]=o*c}else if(e.order==="YXZ"){const p=c*d,m=c*f,x=u*d,b=u*f;n[0]=p+b*l,n[4]=x*l-m,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=m*l-x,n[6]=b+p*l,n[10]=o*c}else if(e.order==="ZXY"){const p=c*d,m=c*f,x=u*d,b=u*f;n[0]=p-b*l,n[4]=-o*f,n[8]=x+m*l,n[1]=m+x*l,n[5]=o*d,n[9]=b-p*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const p=o*d,m=o*f,x=l*d,b=l*f;n[0]=c*d,n[4]=x*u-m,n[8]=p*u+b,n[1]=c*f,n[5]=b*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,b=l*u;n[0]=c*d,n[4]=b-p*f,n[8]=x*f+m,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=m*f+x,n[10]=p-b*f}else if(e.order==="XZY"){const p=o*c,m=o*u,x=l*c,b=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=p*f+b,n[5]=o*d,n[9]=m*f-x,n[2]=x*f-m,n[6]=l*d,n[10]=b*f+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(Nje,e,Mje)}lookAt(e,n,r){const i=this.elements;return to.subVectors(e,n),to.lengthSq()===0&&(to.z=1),to.normalize(),kd.crossVectors(r,to),kd.lengthSq()===0&&(Math.abs(r.z)===1?to.x+=1e-4:to.z+=1e-4,to.normalize(),kd.crossVectors(r,to)),kd.normalize(),a_.crossVectors(to,kd),i[0]=kd.x,i[4]=a_.x,i[8]=to.x,i[1]=kd.y,i[5]=a_.y,i[9]=to.y,i[2]=kd.z,i[6]=a_.z,i[10]=to.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],p=r[9],m=r[13],x=r[2],b=r[6],v=r[10],y=r[14],S=r[3],k=r[7],T=r[11],M=r[15],C=i[0],E=i[4],R=i[8],A=i[12],D=i[1],I=i[5],F=i[9],z=i[13],P=i[2],$=i[6],X=i[10],V=i[14],Q=i[3],Z=i[7],se=i[11],H=i[15];return a[0]=o*C+l*D+c*P+u*Q,a[4]=o*E+l*I+c*$+u*Z,a[8]=o*R+l*F+c*X+u*se,a[12]=o*A+l*z+c*V+u*H,a[1]=d*C+f*D+p*P+m*Q,a[5]=d*E+f*I+p*$+m*Z,a[9]=d*R+f*F+p*X+m*se,a[13]=d*A+f*z+p*V+m*H,a[2]=x*C+b*D+v*P+y*Q,a[6]=x*E+b*I+v*$+y*Z,a[10]=x*R+b*F+v*X+y*se,a[14]=x*A+b*z+v*V+y*H,a[3]=S*C+k*D+T*P+M*Q,a[7]=S*E+k*I+T*$+M*Z,a[11]=S*R+k*F+T*X+M*se,a[15]=S*A+k*z+T*V+M*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],p=e[10],m=e[14],x=e[3],b=e[7],v=e[11],y=e[15];return x*(+a*c*f-i*u*f-a*l*p+r*u*p+i*l*m-r*c*m)+b*(+n*c*m-n*u*p+a*o*p-i*o*m+i*u*d-a*c*d)+v*(+n*u*f-n*l*m-a*o*f+r*o*m+a*l*d-r*u*d)+y*(-i*l*d-n*c*f+n*l*p+i*o*f-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],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],p=e[10],m=e[11],x=e[12],b=e[13],v=e[14],y=e[15],S=f*v*u-b*p*u+b*c*m-l*v*m-f*c*y+l*p*y,k=x*p*u-d*v*u-x*c*m+o*v*m+d*c*y-o*p*y,T=d*b*u-x*f*u+x*l*m-o*b*m-d*l*y+o*f*y,M=x*f*c-d*b*c-x*l*p+o*b*p+d*l*v-o*f*v,C=n*S+r*k+i*T+a*M;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]=(b*p*a-f*v*a-b*i*m+r*v*m+f*i*y-r*p*y)*E,e[2]=(l*v*a-b*c*a+b*i*u-r*v*u-l*i*y+r*c*y)*E,e[3]=(f*c*a-l*p*a-f*i*u+r*p*u+l*i*m-r*c*m)*E,e[4]=k*E,e[5]=(d*v*a-x*p*a+x*i*m-n*v*m-d*i*y+n*p*y)*E,e[6]=(x*c*a-o*v*a-x*i*u+n*v*u+o*i*y-n*c*y)*E,e[7]=(o*p*a-d*c*a+d*i*u-n*p*u-o*i*m+n*c*m)*E,e[8]=T*E,e[9]=(x*f*a-d*b*a-x*r*m+n*b*m+d*r*y-n*f*y)*E,e[10]=(o*b*a-x*l*a+x*r*u-n*b*u-o*r*y+n*l*y)*E,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*m-n*l*m)*E,e[12]=M*E,e[13]=(d*b*i-x*f*i+x*r*p-n*b*p-d*r*v+n*f*v)*E,e[14]=(x*l*i-o*b*i-x*r*c+n*b*c+o*r*v-n*l*v)*E,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*p+n*l*p)*E,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,o=e.x,l=e.y,c=e.z,u=a*o,d=a*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,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,o){return this.set(1,r,a,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,o=n._y,l=n._z,c=n._w,u=a+a,d=o+o,f=l+l,p=a*u,m=a*d,x=a*f,b=o*d,v=o*f,y=l*f,S=c*u,k=c*d,T=c*f,M=r.x,C=r.y,E=r.z;return i[0]=(1-(b+y))*M,i[1]=(m+T)*M,i[2]=(x-k)*M,i[3]=0,i[4]=(m-T)*C,i[5]=(1-(p+y))*C,i[6]=(v+S)*C,i[7]=0,i[8]=(x+k)*E,i[9]=(v-S)*E,i[10]=(1-(p+b))*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 a=Mp.set(i[0],i[1],i[2]).length();const o=Mp.set(i[4],i[5],i[6]).length(),l=Mp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],wl.copy(this);const u=1/a,d=1/o,f=1/l;return wl.elements[0]*=u,wl.elements[1]*=u,wl.elements[2]*=u,wl.elements[4]*=d,wl.elements[5]*=d,wl.elements[6]*=d,wl.elements[8]*=f,wl.elements[9]*=f,wl.elements[10]*=f,n.setFromRotationMatrix(wl),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=lc,c=!1){const u=this.elements,d=2*a/(n-e),f=2*a/(r-i),p=(n+e)/(n-e),m=(r+i)/(r-i);let x,b;if(c)x=a/(o-a),b=o*a/(o-a);else if(l===lc)x=-(o+a)/(o-a),b=-2*o*a/(o-a);else if(l===XS)x=-o/(o-a),b=-o*a/(o-a);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]=f,u[9]=m,u[13]=0,u[2]=0,u[6]=0,u[10]=x,u[14]=b,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(e,n,r,i,a,o,l=lc,c=!1){const u=this.elements,d=2/(n-e),f=2/(r-i),p=-(n+e)/(n-e),m=-(r+i)/(r-i);let x,b;if(c)x=1/(o-a),b=o/(o-a);else if(l===lc)x=-2/(o-a),b=-(o+a)/(o-a);else if(l===XS)x=-1/(o-a),b=-a/(o-a);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]=f,u[9]=0,u[13]=m,u[2]=0,u[6]=0,u[10]=x,u[14]=b,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 Mp=new ht,wl=new Gi,Nje=new ht(0,0,0),Mje=new ht(1,1,1),kd=new ht,a_=new ht,to=new ht,H$=new Gi,$$=new gm;let Eh=class gJ{constructor(e=0,n=0,r=0,i=gJ.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],p=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(zn(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(p,u),this._z=0);break;case"YXZ":this._x=Math.asin(-zn(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(zn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-zn(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(zn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(l,m));break;case"XZY":this._z=Math.asin(-zn(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,m),this._y=0);break;default:xn("Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return H$.makeRotationFromQuaternion(e),this.setFromRotationMatrix(H$,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return $$.setFromEuler(this),this.setFromQuaternion($$,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}};Eh.DEFAULT_ORDER="XYZ";let xJ=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}},kje=0;const V$=new ht,kp=new gm,Xc=new Gi,s_=new ht,Hb=new ht,Eje=new ht,Tje=new gm,G$=new ht(1,0,0),q$=new ht(0,1,0),W$=new ht(0,0,1),K$={type:"added"},Aje={type:"removed"},Ep={type:"childadded",child:null},nC={type:"childremoved",child:null};let vo=class P1 extends Cm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:kje++}),this.uuid=fv(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=P1.DEFAULT_UP.clone();const e=new ht,n=new Eh,r=new gm,i=new ht(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),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=P1.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=P1.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new xJ,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 kp.setFromAxisAngle(e,n),this.quaternion.multiply(kp),this}rotateOnWorldAxis(e,n){return kp.setFromAxisAngle(e,n),this.quaternion.premultiply(kp),this}rotateX(e){return this.rotateOnAxis(G$,e)}rotateY(e){return this.rotateOnAxis(q$,e)}rotateZ(e){return this.rotateOnAxis(W$,e)}translateOnAxis(e,n){return V$.copy(e).applyQuaternion(this.quaternion),this.position.add(V$.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(G$,e)}translateY(e){return this.translateOnAxis(q$,e)}translateZ(e){return this.translateOnAxis(W$,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Xc.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?s_.copy(e):s_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Hb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Xc.lookAt(Hb,s_,this.up):Xc.lookAt(s_,Hb,this.up),this.quaternion.setFromRotationMatrix(Xc),i&&(Xc.extractRotation(i.matrixWorld),kp.setFromRotationMatrix(Xc),this.quaternion.premultiply(kp.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(K$),Ep.child=e,this.dispatchEvent(Ep),Ep.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(Aje),nC.child=e,this.dispatchEvent(nC),nC.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),Xc.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Xc.multiply(e.parent.matrixWorld)),e.applyMatrix4(Xc),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(K$),Ep.child=e,this.dispatchEvent(Ep),Ep.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let r=0,i=this.children.length;r<i;r++){const o=this.children[r].getObjectByProperty(e,n);if(o!==void 0)return o}}getObjectsByProperty(e,n,r=[]){this[e]===n&&r.push(this);const i=this.children;for(let a=0,o=i.length;a<o;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hb,e,Eje),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hb,Tje,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].updateMatrixWorld(e)}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),n===!0){const i=this.children;for(let a=0,o=i.length;a<o;a++)i[a].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(l=>({...l,boundingBox:l.boundingBox?l.boundingBox.toJSON():void 0,boundingSphere:l.boundingSphere?l.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(l=>({...l})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(e),i.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function a(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(a(e.materials,this.material[c]));i.material=l}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(a(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),f=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),f.length>0&&(r.shapes=f),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}};vo.DEFAULT_UP=new ht(0,1,0);vo.DEFAULT_MATRIX_AUTO_UPDATE=!0;vo.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const _l=new ht,Yc=new ht,rC=new ht,Qc=new ht,Tp=new ht,Ap=new ht,X$=new ht,iC=new ht,aC=new ht,sC=new ht,oC=new zi,lC=new zi,cC=new zi;let $b=class og{constructor(e=new ht,n=new ht,r=new ht){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),_l.subVectors(e,n),i.cross(_l);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){_l.subVectors(i,n),Yc.subVectors(r,n),rC.subVectors(e,n);const o=_l.dot(_l),l=_l.dot(Yc),c=_l.dot(rC),u=Yc.dot(Yc),d=Yc.dot(rC),f=o*u-l*l;if(f===0)return a.set(0,0,0),null;const p=1/f,m=(u*c-l*d)*p,x=(o*d-l*c)*p;return a.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,Qc)===null?!1:Qc.x>=0&&Qc.y>=0&&Qc.x+Qc.y<=1}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,Qc)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(a,Qc.x),c.addScaledVector(o,Qc.y),c.addScaledVector(l,Qc.z),c)}static getInterpolatedAttribute(e,n,r,i,a,o){return oC.setScalar(0),lC.setScalar(0),cC.setScalar(0),oC.fromBufferAttribute(e,n),lC.fromBufferAttribute(e,r),cC.fromBufferAttribute(e,i),o.setScalar(0),o.addScaledVector(oC,a.x),o.addScaledVector(lC,a.y),o.addScaledVector(cC,a.z),o}static isFrontFacing(e,n,r,i){return _l.subVectors(r,n),Yc.subVectors(e,n),_l.cross(Yc).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 _l.subVectors(this.c,this.b),Yc.subVectors(this.a,this.b),_l.cross(Yc).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,a){return og.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}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,a=this.c;let o,l;Tp.subVectors(i,r),Ap.subVectors(a,r),iC.subVectors(e,r);const c=Tp.dot(iC),u=Ap.dot(iC);if(c<=0&&u<=0)return n.copy(r);aC.subVectors(e,i);const d=Tp.dot(aC),f=Ap.dot(aC);if(d>=0&&f<=d)return n.copy(i);const p=c*f-d*u;if(p<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector(Tp,o);sC.subVectors(e,a);const m=Tp.dot(sC),x=Ap.dot(sC);if(x>=0&&m<=x)return n.copy(a);const b=m*u-c*x;if(b<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Ap,l);const v=d*x-m*f;if(v<=0&&f-d>=0&&m-x>=0)return X$.subVectors(a,i),l=(f-d)/(f-d+(m-x)),n.copy(i).addScaledVector(X$,l);const y=1/(v+b+p);return o=b*y,l=p*y,n.copy(r).addScaledVector(Tp,o).addScaledVector(Ap,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}};const bJ={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Ed={h:0,s:0,l:0},o_={h:0,s:0,l:0};function uC(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let Bn=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=Vo){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=pje(e,1),n=zn(n,0,1),r=zn(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=uC(o,a,e+1/3),this.g=uC(o,a,e),this.b=uC(o,a,e-1/3)}return cr.colorSpaceToWorking(this,i),this}setStyle(e,n=Vo){function r(a){a!==void 0&&parseFloat(a)<1&&xn("Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:xn("Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],o=a.length;if(o===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(a,16),n);xn("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=Vo){const r=bJ[e.toLowerCase()];return r!==void 0?this.setHex(r,n):xn("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=Cu(e.r),this.g=Cu(e.g),this.b=Cu(e.b),this}copyLinearToSRGB(e){return this.r=Cg(e.r),this.g=Cg(e.g),this.b=Cg(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Vo){return cr.workingToColorSpace(Va.copy(this),e),Math.round(zn(Va.r*255,0,255))*65536+Math.round(zn(Va.g*255,0,255))*256+Math.round(zn(Va.b*255,0,255))}getHexString(e=Vo){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=cr.workingColorSpace){cr.workingToColorSpace(Va.copy(this),n);const r=Va.r,i=Va.g,a=Va.b,o=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=cr.workingColorSpace){return cr.workingToColorSpace(Va.copy(this),n),e.r=Va.r,e.g=Va.g,e.b=Va.b,e}getStyle(e=Vo){cr.workingToColorSpace(Va.copy(this),e);const n=Va.r,r=Va.g,i=Va.b;return e!==Vo?`color(${e} ${n.toFixed(3)} ${r.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(n*255)},${Math.round(r*255)},${Math.round(i*255)})`}offsetHSL(e,n,r){return this.getHSL(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(o_);const r=qA(Ed.h,o_.h,n),i=qA(Ed.s,o_.s,n),a=qA(Ed.l,o_.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const Va=new Bn;Bn.NAMES=bJ;let Cje=0,Px=class extends Cm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Cje++}),this.uuid=fv(),this.name="",this.type="Material",this.blending=Ag,this.side=kh,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=S3,this.blendDst=N3,this.blendEquation=Nf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Bn(0,0,0),this.blendAlpha=0,this.depthFunc=Qg,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=R$,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=vp,this.stencilZFail=vp,this.stencilZPass=vp,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){xn(`Material: parameter '${n}' has value of undefined.`);continue}const i=this[n];if(i===void 0){xn(`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!==Ag&&(r.blending=this.blending),this.side!==kh&&(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!==S3&&(r.blendSrc=this.blendSrc),this.blendDst!==N3&&(r.blendDst=this.blendDst),this.blendEquation!==Nf&&(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!==Qg&&(r.depthFunc=this.depthFunc),this.depthTest===!1&&(r.depthTest=this.depthTest),this.depthWrite===!1&&(r.depthWrite=this.depthWrite),this.colorWrite===!1&&(r.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(r.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==R$&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==vp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==vp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==vp&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(n){const a=i(e.textures),o=i(e.images);a.length>0&&(r.textures=a),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 a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}},Z4=class extends Px{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Bn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Eh,this.combine=H4,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 ht,l_=new Cn;let Pje=0,nl=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:Pje++}),this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=r,this.usage=O$,this.updateRanges=[],this.gpuType=_u,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)l_.fromBufferAttribute(this,n),l_.applyMatrix3(e),this.setXY(n,l_.x,l_.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=Ub(r,this.array)),r}setComponent(e,n,r){return this.normalized&&(r=Cs(r,this.array)),this.array[e*this.itemSize+n]=r,this}getX(e){let n=this.array[e*this.itemSize];return this.normalized&&(n=Ub(n,this.array)),n}setX(e,n){return this.normalized&&(n=Cs(n,this.array)),this.array[e*this.itemSize]=n,this}getY(e){let n=this.array[e*this.itemSize+1];return this.normalized&&(n=Ub(n,this.array)),n}setY(e,n){return this.normalized&&(n=Cs(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=Ub(n,this.array)),n}setZ(e,n){return this.normalized&&(n=Cs(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=Ub(n,this.array)),n}setW(e,n){return this.normalized&&(n=Cs(n,this.array)),this.array[e*this.itemSize+3]=n,this}setXY(e,n,r){return e*=this.itemSize,this.normalized&&(n=Cs(n,this.array),r=Cs(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=Cs(n,this.array),r=Cs(r,this.array),i=Cs(i,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this}setXYZW(e,n,r,i,a){return e*=this.itemSize,this.normalized&&(n=Cs(n,this.array),r=Cs(r,this.array),i=Cs(i,this.array),a=Cs(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==O$&&(e.usage=this.usage),e}},yJ=class extends nl{constructor(e,n,r){super(new Uint16Array(e),n,r)}},vJ=class extends nl{constructor(e,n,r){super(new Uint32Array(e),n,r)}},Ll=class extends nl{constructor(e,n,r){super(new Float32Array(e),n,r)}},jje=0;const Lo=new Gi,dC=new vo,Cp=new ht,no=new bm,Vb=new bm,ha=new ht;let Cc=class wJ extends Cm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:jje++}),this.uuid=fv(),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(uJ(e)?vJ:yJ)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new Dn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Lo.makeRotationFromQuaternion(e),this.applyMatrix4(Lo),this}rotateX(e){return Lo.makeRotationX(e),this.applyMatrix4(Lo),this}rotateY(e){return Lo.makeRotationY(e),this.applyMatrix4(Lo),this}rotateZ(e){return Lo.makeRotationZ(e),this.applyMatrix4(Lo),this}translate(e,n,r){return Lo.makeTranslation(e,n,r),this.applyMatrix4(Lo),this}scale(e,n,r){return Lo.makeScale(e,n,r),this.applyMatrix4(Lo),this}lookAt(e){return dC.lookAt(e),dC.updateMatrix(),this.applyMatrix4(dC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Cp).negate(),this.translate(Cp.x,Cp.y,Cp.z),this}setFromPoints(e){const n=this.getAttribute("position");if(n===void 0){const r=[];for(let i=0,a=e.length;i<a;i++){const o=e[i];r.push(o.x,o.y,o.z||0)}this.setAttribute("position",new Ll(r,3))}else{const r=Math.min(e.length,n.count);for(let i=0;i<r;i++){const a=e[i];n.setXYZ(i,a.x,a.y,a.z||0)}e.length>n.count&&xn("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 bm);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 ht(-1/0,-1/0,-1/0),new ht(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];no.setFromBufferAttribute(a),this.morphTargetsRelative?(ha.addVectors(this.boundingBox.min,no.min),this.boundingBox.expandByPoint(ha),ha.addVectors(this.boundingBox.max,no.max),this.boundingBox.expandByPoint(ha)):(this.boundingBox.expandByPoint(no.min),this.boundingBox.expandByPoint(no.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 m2);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 ht,1/0);return}if(e){const r=this.boundingSphere.center;if(no.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];Vb.setFromBufferAttribute(l),this.morphTargetsRelative?(ha.addVectors(no.min,Vb.min),no.expandByPoint(ha),ha.addVectors(no.max,Vb.max),no.expandByPoint(ha)):(no.expandByPoint(Vb.min),no.expandByPoint(Vb.max))}no.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)ha.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(ha));if(n)for(let a=0,o=n.length;a<o;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)ha.fromBufferAttribute(l,u),c&&(Cp.fromBufferAttribute(e,u),ha.add(Cp)),i=Math.max(i,r.distanceToSquared(ha))}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,a=n.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new nl(new Float32Array(4*r.count),4));const o=this.getAttribute("tangent"),l=[],c=[];for(let R=0;R<r.count;R++)l[R]=new ht,c[R]=new ht;const u=new ht,d=new ht,f=new ht,p=new Cn,m=new Cn,x=new Cn,b=new ht,v=new ht;function y(R,A,D){u.fromBufferAttribute(r,R),d.fromBufferAttribute(r,A),f.fromBufferAttribute(r,D),p.fromBufferAttribute(a,R),m.fromBufferAttribute(a,A),x.fromBufferAttribute(a,D),d.sub(u),f.sub(u),m.sub(p),x.sub(p);const I=1/(m.x*x.y-x.x*m.y);isFinite(I)&&(b.copy(d).multiplyScalar(x.y).addScaledVector(f,-m.y).multiplyScalar(I),v.copy(f).multiplyScalar(m.x).addScaledVector(d,-x.x).multiplyScalar(I),l[R].add(b),l[A].add(b),l[D].add(b),c[R].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 R=0,A=S.length;R<A;++R){const D=S[R],I=D.start,F=D.count;for(let z=I,P=I+F;z<P;z+=3)y(e.getX(z+0),e.getX(z+1),e.getX(z+2))}const k=new ht,T=new ht,M=new ht,C=new ht;function E(R){M.fromBufferAttribute(i,R),C.copy(M);const A=l[R];k.copy(A),k.sub(M.multiplyScalar(M.dot(A))).normalize(),T.crossVectors(C,A);const I=T.dot(c[R])<0?-1:1;o.setXYZW(R,k.x,k.y,k.z,I)}for(let R=0,A=S.length;R<A;++R){const D=S[R],I=D.start,F=D.count;for(let z=I,P=I+F;z<P;z+=3)E(e.getX(z+0)),E(e.getX(z+1)),E(e.getX(z+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 nl(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 ht,a=new ht,o=new ht,l=new ht,c=new ht,u=new ht,d=new ht,f=new ht;if(e)for(let p=0,m=e.count;p<m;p+=3){const x=e.getX(p+0),b=e.getX(p+1),v=e.getX(p+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,b),o.fromBufferAttribute(n,v),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,b),u.fromBufferAttribute(r,v),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(b,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),a.fromBufferAttribute(n,p+1),o.fromBufferAttribute(n,p+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),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++)ha.fromBufferAttribute(e,n),ha.normalize(),e.setXYZ(n,ha.x,ha.y,ha.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,p=new u.constructor(c.length*d);let m=0,x=0;for(let b=0,v=c.length;b<v;b++){l.isInterleavedBufferAttribute?m=c[b]*l.data.stride+l.offset:m=c[b]*d;for(let y=0;y<d;y++)p[x++]=u[m++]}return new nl(p,d,f)}if(this.index===null)return xn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new wJ,r=this.index.array,i=this.attributes;for(const l in i){const c=i[l],u=e(c,r);n.setAttribute(l,u)}const a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;d++){const 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 a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,p=u.length;f<p;f++){const m=u[f];d.push(m.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const 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 a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let p=0,m=f.length;p<m;p++)d.push(f[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 f=o[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}};const Y$=new Gi,cf=new Q4,c_=new m2,Q$=new ht,u_=new ht,d_=new ht,h_=new ht,hC=new ht,f_=new ht,Z$=new ht,m_=new ht;let wc=class extends vo{constructor(e=new Cc,n=new Z4){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){f_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(hC.fromBufferAttribute(f,e),o?f_.addScaledVector(hC,d):f_.addScaledVector(hC.sub(n),d))}n.add(f_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),c_.copy(r.boundingSphere),c_.applyMatrix4(a),cf.copy(e.ray).recast(e.near),!(c_.containsPoint(cf.origin)===!1&&(cf.intersectSphere(c_,Q$)===null||cf.origin.distanceToSquared(Q$)>(e.far-e.near)**2))&&(Y$.copy(a).invert(),cf.copy(e.ray).applyMatrix4(Y$),!(r.boundingBox!==null&&cf.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,cf)))}_computeIntersections(e,n,r){let i;const a=this.geometry,o=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,p=a.groups,m=a.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,b=p.length;x<b;x++){const v=p[x],y=o[v.materialIndex],S=Math.max(v.start,m.start),k=Math.min(l.count,Math.min(v.start+v.count,m.start+m.count));for(let T=S,M=k;T<M;T+=3){const C=l.getX(T),E=l.getX(T+1),R=l.getX(T+2);i=p_(this,y,e,r,u,d,f,C,E,R),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),b=Math.min(l.count,m.start+m.count);for(let v=x,y=b;v<y;v+=3){const S=l.getX(v),k=l.getX(v+1),T=l.getX(v+2);i=p_(this,o,e,r,u,d,f,S,k,T),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,b=p.length;x<b;x++){const v=p[x],y=o[v.materialIndex],S=Math.max(v.start,m.start),k=Math.min(c.count,Math.min(v.start+v.count,m.start+m.count));for(let T=S,M=k;T<M;T+=3){const C=T,E=T+1,R=T+2;i=p_(this,y,e,r,u,d,f,C,E,R),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),b=Math.min(c.count,m.start+m.count);for(let v=x,y=b;v<y;v+=3){const S=v,k=v+1,T=v+2;i=p_(this,o,e,r,u,d,f,S,k,T),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}};function Dje(t,e,n,r,i,a,o,l){let c;if(e.side===Is?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===kh,l),c===null)return null;m_.copy(l),m_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(m_);return u<n.near||u>n.far?null:{distance:u,point:m_.clone(),object:t}}function p_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,u_),t.getVertexPosition(c,d_),t.getVertexPosition(u,h_);const d=Dje(t,e,n,r,u_,d_,h_,Z$);if(d){const f=new ht;$b.getBarycoord(Z$,u_,d_,h_,f),i&&(d.uv=$b.getInterpolatedAttribute(i,l,c,u,f,new Cn)),a&&(d.uv1=$b.getInterpolatedAttribute(a,l,c,u,f,new Cn)),o&&(d.normal=$b.getInterpolatedAttribute(o,l,c,u,f,new ht),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const p={a:l,b:c,c:u,normal:new ht,materialIndex:0};$b.getNormal(u_,d_,h_,p.normal),d.face=p,d.barycoord=f}return d}let J4=class _J extends Cc{constructor(e=1,n=1,r=1,i=1,a=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};const l=this;i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);const c=[],u=[],d=[],f=[];let p=0,m=0;x("z","y","x",-1,-1,r,n,e,o,a,0),x("z","y","x",1,-1,r,n,-e,o,a,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,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Ll(u,3)),this.setAttribute("normal",new Ll(d,3)),this.setAttribute("uv",new Ll(f,2));function x(b,v,y,S,k,T,M,C,E,R,A){const D=T/E,I=M/R,F=T/2,z=M/2,P=C/2,$=E+1,X=R+1;let V=0,Q=0;const Z=new ht;for(let se=0;se<X;se++){const H=se*I-z;for(let K=0;K<$;K++){const re=K*D-F;Z[b]=re*S,Z[v]=H*k,Z[y]=P,u.push(Z.x,Z.y,Z.z),Z[b]=0,Z[v]=0,Z[y]=C>0?1:-1,d.push(Z.x,Z.y,Z.z),f.push(K/E),f.push(1-se/R),V+=1}}for(let se=0;se<R;se++)for(let H=0;H<E;H++){const K=p+H+$*se,re=p+H+$*(se+1),ne=p+(H+1)+$*(se+1),be=p+(H+1)+$*se;c.push(K,re,be),c.push(re,ne,be),Q+=6}l.addGroup(m,Q,A),m+=Q,p+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _J(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}};function tx(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?(xn("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 cs(t){const e={};for(let n=0;n<t.length;n++){const r=tx(t[n]);for(const i in r)e[i]=r[i]}return e}function Rje(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function SJ(t){const e=t.getRenderTarget();return e===null?t.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:cr.workingColorSpace}const Oje={clone:tx,merge:cs};var Lje=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,Fje=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;let $u=class extends Px{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Lje,this.fragmentShader=Fje,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=tx(e.uniforms),this.uniformsGroups=Rje(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}},NJ=class extends vo{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Gi,this.projectionMatrix=new Gi,this.projectionMatrixInverse=new Gi,this.coordinateSystem=lc,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 ht,J$=new Cn,eV=new Cn;let Wo=class extends NJ{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=uD*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(A1*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return uD*2*Math.atan(Math.tan(A1*.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,J$,eV),n.subVectors(eV,J$)}setViewOffset(e,n,r,i,a,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=a,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(A1*.5*this.fov)/this.zoom,r=2*n,i=this.aspect*r,a=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;a+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(a+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}};const Pp=-90,jp=1;let Ije=class extends vo{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Wo(Pp,jp,e,n);i.layers=this.layers,this.add(i);const a=new Wo(Pp,jp,e,n);a.layers=this.layers,this.add(a);const o=new Wo(Pp,jp,e,n);o.layers=this.layers,this.add(o);const l=new Wo(Pp,jp,e,n);l.layers=this.layers,this.add(l);const c=new Wo(Pp,jp,e,n);c.layers=this.layers,this.add(c);const u=new Wo(Pp,jp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,o,l,c]=n;for(const u of n)this.remove(u);if(e===lc)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),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===XS)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),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[a,o,l,c,u,d]=this.children,f=e.getRenderTarget(),p=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const b=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),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=b,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,p,m),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}},MJ=class extends Hl{constructor(e=[],n=Zg,r,i,a,o,l,c,u,d){super(e,n,r,i,a,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}},Uje=class extends xm{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 MJ(i),this._setTextureOptions(n),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new J4(5,5,5),a=new $u({name:"CubemapFromEquirect",uniforms:tx(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Is,blending:Au});a.uniforms.tEquirect.value=n;const o=new wc(i,a),l=n.minFilter;return n.minFilter===Of&&(n.minFilter=el),new Ije(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 a=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(a)}},o0=class extends vo{constructor(){super(),this.isGroup=!0,this.type="Group"}};const zje={type:"move"};let fC=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new o0,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 o0,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ht,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ht),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new o0,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ht,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ht),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=null,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 b of e.hand.values()){const v=n.getJointPose(b,r),y=this._getHandJoint(u,b);v!==null&&(y.matrix.fromArray(v.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,y.jointRadius=v.radius),y.visible=v!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],p=d.position.distanceTo(f.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&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(zje)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new o0;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}},Bje=class extends vo{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 Eh,this.environmentIntensity=1,this.environmentRotation=new Eh,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}},Hje=class extends Hl{constructor(e=null,n=1,r=1,i,a,o,l,c,u=mo,d=mo,f,p){super(null,o,l,c,u,d,i,a,f,p),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}};const mC=new ht,$je=new ht,Vje=new Dn;let Bd=class{constructor(e=new ht(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=mC.subVectors(r,n).cross($je.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(mC),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||Vje.getNormalMatrix(e),i=this.coplanarPoint(mC).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};const uf=new m2,Gje=new Cn(.5,.5),g_=new ht;let eL=class{constructor(e=new Bd,n=new Bd,r=new Bd,i=new Bd,a=new Bd,o=new Bd){this.planes=[e,n,r,i,a,o]}set(e,n,r,i,a,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(a),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=lc,r=!1){const i=this.planes,a=e.elements,o=a[0],l=a[1],c=a[2],u=a[3],d=a[4],f=a[5],p=a[6],m=a[7],x=a[8],b=a[9],v=a[10],y=a[11],S=a[12],k=a[13],T=a[14],M=a[15];if(i[0].setComponents(u-o,m-d,y-x,M-S).normalize(),i[1].setComponents(u+o,m+d,y+x,M+S).normalize(),i[2].setComponents(u+l,m+f,y+b,M+k).normalize(),i[3].setComponents(u-l,m-f,y-b,M-k).normalize(),r)i[4].setComponents(c,p,v,T).normalize(),i[5].setComponents(u-c,m-p,y-v,M-T).normalize();else if(i[4].setComponents(u-c,m-p,y-v,M-T).normalize(),n===lc)i[5].setComponents(u+c,m+p,y+v,M+T).normalize();else if(n===XS)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(),uf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),uf.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(uf)}intersectsSprite(e){uf.center.set(0,0,0);const n=Gje.distanceTo(e.center);return uf.radius=.7071067811865476+n,uf.applyMatrix4(e.matrixWorld),this.intersectsSphere(uf)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(g_.x=i.normal.x>0?e.max.x:e.min.x,g_.y=i.normal.y>0?e.max.y:e.min.y,g_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(g_)<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)}},kJ=class extends Px{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Bn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}};const QS=new ht,ZS=new ht,tV=new Gi,Gb=new Q4,x_=new m2,pC=new ht,nV=new ht;let qje=class extends vo{constructor(e=new Cc,n=new kJ){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,a=n.count;i<a;i++)QS.fromBufferAttribute(n,i-1),ZS.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=QS.distanceTo(ZS);e.setAttribute("lineDistance",new Ll(r,1))}else xn("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const r=this.geometry,i=this.matrixWorld,a=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),x_.copy(r.boundingSphere),x_.applyMatrix4(i),x_.radius+=a,e.ray.intersectsSphere(x_)===!1)return;tV.copy(i).invert(),Gb.copy(e.ray).applyMatrix4(tV);const l=a/((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 b=m,v=x-1;b<v;b+=u){const y=d.getX(b),S=d.getX(b+1),k=b_(this,e,Gb,c,y,S,b);k&&n.push(k)}if(this.isLineLoop){const b=d.getX(x-1),v=d.getX(m),y=b_(this,e,Gb,c,b,v,x-1);y&&n.push(y)}}else{const m=Math.max(0,o.start),x=Math.min(p.count,o.start+o.count);for(let b=m,v=x-1;b<v;b+=u){const y=b_(this,e,Gb,c,b,b+1,b);y&&n.push(y)}if(this.isLineLoop){const b=b_(this,e,Gb,c,x-1,m,x-1);b&&n.push(b)}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}};function b_(t,e,n,r,i,a,o){const l=t.geometry.attributes.position;if(QS.fromBufferAttribute(l,i),ZS.fromBufferAttribute(l,a),n.distanceSqToSegment(QS,ZS,pC,nV)>r)return;pC.applyMatrix4(t.matrixWorld);const u=e.ray.origin.distanceTo(pC);if(!(u<e.near||u>e.far))return{distance:u,point:nV.clone().applyMatrix4(t.matrixWorld),index:o,face:null,faceIndex:null,barycoord:null,object:t}}const rV=new ht,iV=new ht;let Wje=class extends qje{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,a=n.count;i<a;i+=2)rV.fromBufferAttribute(n,i),iV.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+rV.distanceTo(iV);e.setAttribute("lineDistance",new Ll(r,1))}else xn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}},EJ=class extends Hl{constructor(e,n,r=pm,i,a,o,l=mo,c=mo,u,d=fy,f=1){if(d!==fy&&d!==my)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const p={width:e,height:n,depth:f};super(p,i,a,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 Y4(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 TJ extends Hl{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}let tL=class AJ extends Cc{constructor(e=1,n=1,r=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:r,heightSegments:i};const a=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,p=n/c,m=[],x=[],b=[],v=[];for(let y=0;y<d;y++){const S=y*p-o;for(let k=0;k<u;k++){const T=k*f-a;x.push(T,-S,0),b.push(0,0,1),v.push(k/l),v.push(1-y/c)}}for(let y=0;y<c;y++)for(let S=0;S<l;S++){const k=S+u*y,T=S+u*(y+1),M=S+1+u*(y+1),C=S+1+u*y;m.push(k,T,C),m.push(T,M,C)}this.setIndex(m),this.setAttribute("position",new Ll(x,3)),this.setAttribute("normal",new Ll(b,3)),this.setAttribute("uv",new Ll(v,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new AJ(e.width,e.height,e.widthSegments,e.heightSegments)}};class Kje extends Px{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Bn(16777215),this.specular=new Bn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Bn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=lJ,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 Eh,this.combine=H4,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 Xje=class extends Px{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=rje,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}},Yje=class extends Px{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}},CJ=class extends vo{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Bn(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(n.object.target=this.target.uuid),n}};const gC=new Gi,aV=new ht,sV=new ht;let Qje=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=vc,this.map=null,this.mapPass=null,this.matrix=new Gi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new eL,this._frameExtents=new Cn(1,1),this._viewportCount=1,this._viewports=[new zi(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,r=this.matrix;aV.setFromMatrixPosition(e.matrixWorld),n.position.copy(aV),sV.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(sV),n.updateMatrixWorld(),gC.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(gC,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(gC)}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}},PJ=class extends NJ{constructor(e=-1,n=1,r=1,i=-1,a=.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=a,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,a,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=a,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 a=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;a+=u*this.view.offsetX,o=a+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,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 Zje extends Qje{constructor(){super(new PJ(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class oV extends CJ{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(vo.DEFAULT_UP),this.updateMatrix(),this.target=new vo,this.shadow=new Zje}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}let Jje=class extends CJ{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}},e3e=class extends Wo{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}},lV=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=zn(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(zn(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}};class t3e extends Wje{constructor(e=10,n=10,r=4473924,i=8947848){r=new Bn(r),i=new Bn(i);const a=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 b=p===a?r:i;b.toArray(u,m),m+=3,b.toArray(u,m),m+=3,b.toArray(u,m),m+=3,b.toArray(u,m),m+=3}const d=new Cc;d.setAttribute("position",new Ll(c,3)),d.setAttribute("color",new Ll(u,3));const f=new kJ({vertexColors:!0,toneMapped:!1});super(d,f),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class n3e extends Cm{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){xn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function cV(t,e,n,r){const i=r3e(r);switch(n){case aJ:return t*e;case oJ:return t*e/i.components*i.byteLength;case q4:return t*e/i.components*i.byteLength;case W4:return t*e*2/i.components*i.byteLength;case K4:return t*e*2/i.components*i.byteLength;case sJ:return t*e*3/i.components*i.byteLength;case jl:return t*e*4/i.components*i.byteLength;case X4:return t*e*4/i.components*i.byteLength;case M1:case k1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case E1:case T1:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case F3:case U3:return Math.max(t,16)*Math.max(e,8)/4;case L3:case I3:return Math.max(t,8)*Math.max(e,8)/2;case z3:case B3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*8;case H3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case $3:return Math.floor((t+3)/4)*Math.floor((e+3)/4)*16;case V3:return Math.floor((t+4)/5)*Math.floor((e+3)/4)*16;case G3:return Math.floor((t+4)/5)*Math.floor((e+4)/5)*16;case q3:return Math.floor((t+5)/6)*Math.floor((e+4)/5)*16;case W3:return Math.floor((t+5)/6)*Math.floor((e+5)/6)*16;case K3:return Math.floor((t+7)/8)*Math.floor((e+4)/5)*16;case X3:return Math.floor((t+7)/8)*Math.floor((e+5)/6)*16;case Y3:return Math.floor((t+7)/8)*Math.floor((e+7)/8)*16;case Q3:return Math.floor((t+9)/10)*Math.floor((e+4)/5)*16;case Z3:return Math.floor((t+9)/10)*Math.floor((e+5)/6)*16;case J3:return Math.floor((t+9)/10)*Math.floor((e+7)/8)*16;case eD:return Math.floor((t+9)/10)*Math.floor((e+9)/10)*16;case tD:return Math.floor((t+11)/12)*Math.floor((e+9)/10)*16;case nD:return Math.floor((t+11)/12)*Math.floor((e+11)/12)*16;case rD:case iD:case aD:return Math.ceil(t/4)*Math.ceil(e/4)*16;case sD:case oD:return Math.ceil(t/4)*Math.ceil(e/4)*8;case lD:case cD:return Math.ceil(t/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${n} format.`)}function r3e(t){switch(t){case vc:case tJ:return{byteLength:1,components:1};case dy:case nJ:case Cx:return{byteLength:2,components:1};case V4:case G4:return{byteLength:2,components:4};case pm:case $4:case _u:return{byteLength:4,components:1};case rJ:case iJ:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${t}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:B4}}));typeof window<"u"&&(window.__THREE__?xn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=B4);function jJ(){let t=null,e=!1,n=null,r=null;function i(a,o){n(a,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(a){n=a},setContext:function(a){t=a}}}function i3e(t){const e=new WeakMap;function n(l,c){const u=l.array,d=l.usage,f=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:f}}function r(l,c,u){const d=c.array,f=c.updateRanges;if(t.bindBuffer(u,l),f.length===0)t.bufferSubData(u,0,d);else{f.sort((m,x)=>m.start-x.start);let p=0;for(let m=1;m<f.length;m++){const x=f[p],b=f[m];b.start<=x.start+x.count+1?x.count=Math.max(x.count,b.start+b.count-x.start):(++p,f[p]=b)}f.length=p+1;for(let m=0,x=f.length;m<x;m++){const b=f[m];t.bufferSubData(u,b.start*d.BYTES_PER_ELEMENT,d,b.start,b.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(l){return l.isInterleavedBufferAttribute&&(l=l.data),e.get(l)}function a(l){l.isInterleavedBufferAttribute&&(l=l.data);const c=e.get(l);c&&(t.deleteBuffer(c.buffer),e.delete(l))}function 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:a,update:o}}var a3e=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,s3e=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,o3e=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,l3e=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,c3e=`#ifdef USE_ALPHATEST
- #ifdef ALPHA_TO_COVERAGE
- diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- if ( diffuseColor.a < alphaTest ) discard;
- #endif
- #endif`,u3e=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,d3e=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,h3e=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,f3e=`#ifdef USE_BATCHING
- #if ! defined( GL_ANGLE_multi_draw )
- #define gl_DrawID _gl_DrawID
- uniform int _gl_DrawID;
- #endif
- uniform highp sampler2D batchingTexture;
- uniform highp usampler2D batchingIdTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- float getIndirectIndex( const in int i ) {
- int size = textureSize( batchingIdTexture, 0 ).x;
- int x = i % size;
- int y = i / size;
- return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
- }
- #endif
- #ifdef USE_BATCHING_COLOR
- uniform sampler2D batchingColorTexture;
- vec3 getBatchingColor( const in float i ) {
- int size = textureSize( batchingColorTexture, 0 ).x;
- int j = int( i );
- int x = j % size;
- int y = j / size;
- return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
- }
- #endif`,m3e=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
- #endif`,p3e=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,g3e=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,x3e=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,b3e=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,y3e=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,v3e=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #ifdef ALPHA_TO_COVERAGE
- float distanceToPlane, distanceGradient;
- float clipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- if ( clipOpacity == 0.0 ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- float unionClipOpacity = 1.0;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
- distanceGradient = fwidth( distanceToPlane ) / 2.0;
- unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
- }
- #pragma unroll_loop_end
- clipOpacity *= 1.0 - unionClipOpacity;
- #endif
- diffuseColor.a *= clipOpacity;
- if ( diffuseColor.a == 0.0 ) discard;
- #else
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif
- #endif`,w3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,_3e=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,S3e=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,N3e=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,M3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,k3e=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- varying vec3 vColor;
- #endif`,E3e=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif
- #ifdef USE_BATCHING_COLOR
- vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
- vColor.xyz *= batchingColor.xyz;
- #endif`,T3e=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,A3e=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,C3e=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,P3e=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,j3e=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,D3e=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
- emissiveColor = sRGBTransferEOTF( emissiveColor );
- #endif
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,R3e=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,O3e="gl_FragColor = linearToOutputTexel( gl_FragColor );",L3e=`vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferEOTF( in vec4 value ) {
- return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }`,F3e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,I3e=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- uniform mat3 envMapRotation;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
- #endif`,U3e=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,z3e=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,B3e=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,H3e=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,$3e=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,V3e=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,G3e=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,q3e=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,W3e=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,K3e=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,X3e=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Y3e=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,Q3e=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,Z3e=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,J3e=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,eDe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,tDe=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,nDe=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_DISPERSION
- material.dispersion = dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,rDe=`uniform sampler2D dfgLUT;
- struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- float dispersion;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 uv = vec2( roughness, dotNV );
- return texture2D( dfgLUT, uv ).rg;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
- vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
- vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
- vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
- float Ess_V = dfgV.x + dfgV.y;
- float Ess_L = dfgL.x + dfgL.y;
- float Ems_V = 1.0 - Ess_V;
- float Ems_L = 1.0 - Ess_L;
- vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
- vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
- float compensationFactor = Ems_V * Ems_L;
- vec3 multiScatter = Fms * compensationFactor;
- return singleScatter + multiScatter;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,iDe=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,aDe=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,sDe=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,oDe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,lDe=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,cDe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,uDe=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #endif`,dDe=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,hDe=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,fDe=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,mDe=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,pDe=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,gDe=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,xDe=`#ifdef USE_INSTANCING_MORPH
- float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
- }
- #endif`,bDe=`#if defined( USE_MORPHCOLORS )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,yDe=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,vDe=`#ifdef USE_MORPHTARGETS
- #ifndef USE_INSTANCING_MORPH
- uniform float morphTargetBaseInfluence;
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- #endif
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #endif`,wDe=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #endif`,_De=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,SDe=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,NDe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,MDe=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,kDe=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,EDe=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,TDe=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,ADe=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,CDe=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,PDe=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,jDe=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,DDe=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
- const float Inv255 = 1. / 255.;
- const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
- const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
- const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
- const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
- vec4 packDepthToRGBA( const in float v ) {
- if( v <= 0.0 )
- return vec4( 0., 0., 0., 0. );
- if( v >= 1.0 )
- return vec4( 1., 1., 1., 1. );
- float vuf;
- float af = modf( v * PackFactors.a, vuf );
- float bf = modf( vuf * ShiftRight8, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
- }
- vec3 packDepthToRGB( const in float v ) {
- if( v <= 0.0 )
- return vec3( 0., 0., 0. );
- if( v >= 1.0 )
- return vec3( 1., 1., 1. );
- float vuf;
- float bf = modf( v * PackFactors.b, vuf );
- float gf = modf( vuf * ShiftRight8, vuf );
- return vec3( vuf * Inv255, gf * PackUpscale, bf );
- }
- vec2 packDepthToRG( const in float v ) {
- if( v <= 0.0 )
- return vec2( 0., 0. );
- if( v >= 1.0 )
- return vec2( 1., 1. );
- float vuf;
- float gf = modf( v * 256., vuf );
- return vec2( vuf * Inv255, gf );
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors4 );
- }
- float unpackRGBToDepth( const in vec3 v ) {
- return dot( v, UnpackFactors3 );
- }
- float unpackRGToDepth( const in vec2 v ) {
- return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
- }
- vec4 pack2HalfToRGBA( const in vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( const in vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,RDe=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,ODe=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,LDe=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,FDe=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,IDe=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,UDe=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,zDe=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- return step( depth, compare );
- #else
- return step( compare, depth );
- #endif
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float hard_shadow = step( distribution.x, compare );
- #else
- float hard_shadow = step( compare, distribution.x );
- #endif
- if ( hard_shadow != 1.0 ) {
- float distance = compare - distribution.x;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- float shadow = 1.0;
- vec3 lightToPosition = shadowCoord.xyz;
-
- float lightToPositionLength = length( lightToPosition );
- if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
- float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- shadow = (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- return mix( 1.0, shadow, shadowIntensity );
- }
- #endif`,BDe=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowIntensity;
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,HDe=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,$De=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,VDe=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,GDe=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,qDe=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,WDe=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,KDe=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,XDe=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,YDe=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,QDe=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 CineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
- vec3( 1.6605, - 0.1246, - 0.0182 ),
- vec3( - 0.5876, 1.1329, - 0.1006 ),
- vec3( - 0.0728, - 0.0083, 1.1187 )
- );
- const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
- vec3( 0.6274, 0.0691, 0.0164 ),
- vec3( 0.3293, 0.9195, 0.0880 ),
- vec3( 0.0433, 0.0113, 0.8956 )
- );
- vec3 agxDefaultContrastApprox( vec3 x ) {
- vec3 x2 = x * x;
- vec3 x4 = x2 * x2;
- return + 15.5 * x4 * x2
- - 40.14 * x4 * x
- + 31.96 * x4
- - 6.868 * x2 * x
- + 0.4298 * x2
- + 0.1191 * x
- - 0.00232;
- }
- vec3 AgXToneMapping( vec3 color ) {
- const mat3 AgXInsetMatrix = mat3(
- vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
- vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
- vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
- );
- const mat3 AgXOutsetMatrix = mat3(
- vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
- vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
- vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
- );
- const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
- color *= toneMappingExposure;
- color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
- color = AgXInsetMatrix * color;
- color = max( color, 1e-10 ); color = log2( color );
- color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
- color = clamp( color, 0.0, 1.0 );
- color = agxDefaultContrastApprox( color );
- color = AgXOutsetMatrix * color;
- color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
- color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
- color = clamp( color, 0.0, 1.0 );
- return color;
- }
- vec3 NeutralToneMapping( vec3 color ) {
- const float StartCompression = 0.8 - 0.04;
- const float Desaturation = 0.15;
- color *= toneMappingExposure;
- float x = min( color.r, min( color.g, color.b ) );
- float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
- color -= offset;
- float peak = max( color.r, max( color.g, color.b ) );
- if ( peak < StartCompression ) return color;
- float d = 1. - StartCompression;
- float newPeak = 1. - d * d / ( peak + d - StartCompression );
- color *= newPeak / peak;
- float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
- return mix( color, vec3( newPeak ), g );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,ZDe=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,JDe=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec4 transmittedLight;
- vec3 transmittance;
- #ifdef USE_DISPERSION
- float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
- vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
- for ( int i = 0; i < 3; i ++ ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
- transmittedLight[ i ] = transmissionSample[ i ];
- transmittedLight.a += transmissionSample.a;
- transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
- }
- transmittedLight.a /= 3.0;
- #else
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- #endif
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,eRe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,tRe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,nRe=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,rRe=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const iRe=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,aRe=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,sRe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,oRe=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- uniform mat3 backgroundRotation;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,lRe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,cRe=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,uRe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,dRe=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- #ifdef USE_REVERSED_DEPTH_BUFFER
- float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
- #else
- float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
- #endif
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #elif DEPTH_PACKING == 3202
- gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
- #elif DEPTH_PACKING == 3203
- gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
- #endif
- }`,hRe=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #include <morphinstance_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,fRe=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- vec4 diffuseColor = vec4( 1.0 );
- #include <clipping_planes_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,mRe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,pRe=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,gRe=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,xRe=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,bRe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,yRe=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,vRe=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,wRe=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,_Re=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,SRe=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,NRe=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,MRe=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,kRe=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,ERe=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,TRe=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,ARe=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_DISPERSION
- uniform float dispersion;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,CRe=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,PRe=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,jRe=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphinstance_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,DRe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,RRe=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphinstance_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,ORe=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,LRe=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix[ 3 ];
- vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,FRe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,Tn={alphahash_fragment:a3e,alphahash_pars_fragment:s3e,alphamap_fragment:o3e,alphamap_pars_fragment:l3e,alphatest_fragment:c3e,alphatest_pars_fragment:u3e,aomap_fragment:d3e,aomap_pars_fragment:h3e,batching_pars_vertex:f3e,batching_vertex:m3e,begin_vertex:p3e,beginnormal_vertex:g3e,bsdfs:x3e,iridescence_fragment:b3e,bumpmap_pars_fragment:y3e,clipping_planes_fragment:v3e,clipping_planes_pars_fragment:w3e,clipping_planes_pars_vertex:_3e,clipping_planes_vertex:S3e,color_fragment:N3e,color_pars_fragment:M3e,color_pars_vertex:k3e,color_vertex:E3e,common:T3e,cube_uv_reflection_fragment:A3e,defaultnormal_vertex:C3e,displacementmap_pars_vertex:P3e,displacementmap_vertex:j3e,emissivemap_fragment:D3e,emissivemap_pars_fragment:R3e,colorspace_fragment:O3e,colorspace_pars_fragment:L3e,envmap_fragment:F3e,envmap_common_pars_fragment:I3e,envmap_pars_fragment:U3e,envmap_pars_vertex:z3e,envmap_physical_pars_fragment:Q3e,envmap_vertex:B3e,fog_vertex:H3e,fog_pars_vertex:$3e,fog_fragment:V3e,fog_pars_fragment:G3e,gradientmap_pars_fragment:q3e,lightmap_pars_fragment:W3e,lights_lambert_fragment:K3e,lights_lambert_pars_fragment:X3e,lights_pars_begin:Y3e,lights_toon_fragment:Z3e,lights_toon_pars_fragment:J3e,lights_phong_fragment:eDe,lights_phong_pars_fragment:tDe,lights_physical_fragment:nDe,lights_physical_pars_fragment:rDe,lights_fragment_begin:iDe,lights_fragment_maps:aDe,lights_fragment_end:sDe,logdepthbuf_fragment:oDe,logdepthbuf_pars_fragment:lDe,logdepthbuf_pars_vertex:cDe,logdepthbuf_vertex:uDe,map_fragment:dDe,map_pars_fragment:hDe,map_particle_fragment:fDe,map_particle_pars_fragment:mDe,metalnessmap_fragment:pDe,metalnessmap_pars_fragment:gDe,morphinstance_vertex:xDe,morphcolor_vertex:bDe,morphnormal_vertex:yDe,morphtarget_pars_vertex:vDe,morphtarget_vertex:wDe,normal_fragment_begin:_De,normal_fragment_maps:SDe,normal_pars_fragment:NDe,normal_pars_vertex:MDe,normal_vertex:kDe,normalmap_pars_fragment:EDe,clearcoat_normal_fragment_begin:TDe,clearcoat_normal_fragment_maps:ADe,clearcoat_pars_fragment:CDe,iridescence_pars_fragment:PDe,opaque_fragment:jDe,packing:DDe,premultiplied_alpha_fragment:RDe,project_vertex:ODe,dithering_fragment:LDe,dithering_pars_fragment:FDe,roughnessmap_fragment:IDe,roughnessmap_pars_fragment:UDe,shadowmap_pars_fragment:zDe,shadowmap_pars_vertex:BDe,shadowmap_vertex:HDe,shadowmask_pars_fragment:$De,skinbase_vertex:VDe,skinning_pars_vertex:GDe,skinning_vertex:qDe,skinnormal_vertex:WDe,specularmap_fragment:KDe,specularmap_pars_fragment:XDe,tonemapping_fragment:YDe,tonemapping_pars_fragment:QDe,transmission_fragment:ZDe,transmission_pars_fragment:JDe,uv_pars_fragment:eRe,uv_pars_vertex:tRe,uv_vertex:nRe,worldpos_vertex:rRe,background_vert:iRe,background_frag:aRe,backgroundCube_vert:sRe,backgroundCube_frag:oRe,cube_vert:lRe,cube_frag:cRe,depth_vert:uRe,depth_frag:dRe,distanceRGBA_vert:hRe,distanceRGBA_frag:fRe,equirect_vert:mRe,equirect_frag:pRe,linedashed_vert:gRe,linedashed_frag:xRe,meshbasic_vert:bRe,meshbasic_frag:yRe,meshlambert_vert:vRe,meshlambert_frag:wRe,meshmatcap_vert:_Re,meshmatcap_frag:SRe,meshnormal_vert:NRe,meshnormal_frag:MRe,meshphong_vert:kRe,meshphong_frag:ERe,meshphysical_vert:TRe,meshphysical_frag:ARe,meshtoon_vert:CRe,meshtoon_frag:PRe,points_vert:jRe,points_frag:DRe,shadow_vert:RRe,shadow_frag:ORe,sprite_vert:LRe,sprite_frag:FRe},Ot={common:{diffuse:{value:new Bn(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 Bn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Bn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Dn},alphaTest:{value:0},uvTransform:{value:new Dn}},sprite:{diffuse:{value:new Bn(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}}},rc={basic:{uniforms:cs([Ot.common,Ot.specularmap,Ot.envmap,Ot.aomap,Ot.lightmap,Ot.fog]),vertexShader:Tn.meshbasic_vert,fragmentShader:Tn.meshbasic_frag},lambert:{uniforms:cs([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 Bn(0)}}]),vertexShader:Tn.meshlambert_vert,fragmentShader:Tn.meshlambert_frag},phong:{uniforms:cs([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 Bn(0)},specular:{value:new Bn(1118481)},shininess:{value:30}}]),vertexShader:Tn.meshphong_vert,fragmentShader:Tn.meshphong_frag},standard:{uniforms:cs([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 Bn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Tn.meshphysical_vert,fragmentShader:Tn.meshphysical_frag},toon:{uniforms:cs([Ot.common,Ot.aomap,Ot.lightmap,Ot.emissivemap,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.gradientmap,Ot.fog,Ot.lights,{emissive:{value:new Bn(0)}}]),vertexShader:Tn.meshtoon_vert,fragmentShader:Tn.meshtoon_frag},matcap:{uniforms:cs([Ot.common,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,Ot.fog,{matcap:{value:null}}]),vertexShader:Tn.meshmatcap_vert,fragmentShader:Tn.meshmatcap_frag},points:{uniforms:cs([Ot.points,Ot.fog]),vertexShader:Tn.points_vert,fragmentShader:Tn.points_frag},dashed:{uniforms:cs([Ot.common,Ot.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Tn.linedashed_vert,fragmentShader:Tn.linedashed_frag},depth:{uniforms:cs([Ot.common,Ot.displacementmap]),vertexShader:Tn.depth_vert,fragmentShader:Tn.depth_frag},normal:{uniforms:cs([Ot.common,Ot.bumpmap,Ot.normalmap,Ot.displacementmap,{opacity:{value:1}}]),vertexShader:Tn.meshnormal_vert,fragmentShader:Tn.meshnormal_frag},sprite:{uniforms:cs([Ot.sprite,Ot.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:cs([Ot.common,Ot.displacementmap,{referencePosition:{value:new ht},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Tn.distanceRGBA_vert,fragmentShader:Tn.distanceRGBA_frag},shadow:{uniforms:cs([Ot.lights,Ot.fog,{color:{value:new Bn(0)},opacity:{value:1}}]),vertexShader:Tn.shadow_vert,fragmentShader:Tn.shadow_frag}};rc.physical={uniforms:cs([rc.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 Bn(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 Bn(0)},specularColor:{value:new Bn(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 y_={r:0,b:0,g:0},df=new Eh,IRe=new Gi;function URe(t,e,n,r,i,a,o){const l=new Bn(0);let c=a===!0?0:1,u,d,f=null,p=0,m=null;function x(k){let T=k.isScene===!0?k.background:null;return T&&T.isTexture&&(T=(k.backgroundBlurriness>0?n:e).get(T)),T}function b(k){let T=!1;const M=x(k);M===null?y(l,c):M&&M.isColor&&(y(M,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(k,T){const M=x(T);M&&(M.isCubeTexture||M.mapping===f2)?(d===void 0&&(d=new wc(new J4(1,1,1),new $u({name:"BackgroundCubeMaterial",uniforms:tx(rc.backgroundCube.uniforms),vertexShader:rc.backgroundCube.vertexShader,fragmentShader:rc.backgroundCube.fragmentShader,side:Is,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(C,E,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(d.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(d)),df.copy(T.backgroundRotation),df.x*=-1,df.y*=-1,df.z*=-1,M.isCubeTexture&&M.isRenderTargetTexture===!1&&(df.y*=-1,df.z*=-1),d.material.uniforms.envMap.value=M,d.material.uniforms.flipEnvMap.value=M.isCubeTexture&&M.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,d.material.uniforms.backgroundRotation.value.setFromMatrix4(IRe.makeRotationFromEuler(df)),d.material.toneMapped=cr.getTransfer(M.colorSpace)!==Mr,(f!==M||p!==M.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=M,p=M.version,m=t.toneMapping),d.layers.enableAll(),k.unshift(d,d.geometry,d.material,0,0,null)):M&&M.isTexture&&(u===void 0&&(u=new wc(new tL(2,2),new $u({name:"BackgroundMaterial",uniforms:tx(rc.background.uniforms),vertexShader:rc.background.vertexShader,fragmentShader:rc.background.fragmentShader,side:kh,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=M,u.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,u.material.toneMapped=cr.getTransfer(M.colorSpace)!==Mr,M.matrixAutoUpdate===!0&&M.updateMatrix(),u.material.uniforms.uvTransform.value.copy(M.matrix),(f!==M||p!==M.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=M,p=M.version,m=t.toneMapping),u.layers.enableAll(),k.unshift(u,u.geometry,u.material,0,0,null))}function y(k,T){k.getRGB(y_,SJ(t)),r.buffers.color.setClear(y_.r,y_.g,y_.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(k,T=1){l.set(k),c=T,y(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(k){c=k,y(l,c)},render:b,addToRenderList:v,dispose:S}}function zRe(t,e){const n=t.getParameter(t.MAX_VERTEX_ATTRIBS),r={},i=p(null);let a=i,o=!1;function l(D,I,F,z,P){let $=!1;const X=f(z,F,I);a!==X&&(a=X,u(a.object)),$=m(D,z,F,P),$&&x(D,z,F,P),P!==null&&e.update(P,t.ELEMENT_ARRAY_BUFFER),($||o)&&(o=!1,T(D,I,F,z),P!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e.get(P).buffer))}function c(){return t.createVertexArray()}function u(D){return t.bindVertexArray(D)}function d(D){return t.deleteVertexArray(D)}function f(D,I,F){const z=F.wireframe===!0;let P=r[D.id];P===void 0&&(P={},r[D.id]=P);let $=P[I.id];$===void 0&&($={},P[I.id]=$);let X=$[z];return X===void 0&&(X=p(c()),$[z]=X),X}function p(D){const I=[],F=[],z=[];for(let P=0;P<n;P++)I[P]=0,F[P]=0,z[P]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:F,attributeDivisors:z,object:D,attributes:{},index:null}}function m(D,I,F,z){const P=a.attributes,$=I.attributes;let X=0;const V=F.getAttributes();for(const Q in V)if(V[Q].location>=0){const se=P[Q];let H=$[Q];if(H===void 0&&(Q==="instanceMatrix"&&D.instanceMatrix&&(H=D.instanceMatrix),Q==="instanceColor"&&D.instanceColor&&(H=D.instanceColor)),se===void 0||se.attribute!==H||H&&se.data!==H.data)return!0;X++}return a.attributesNum!==X||a.index!==z}function x(D,I,F,z){const P={},$=I.attributes;let X=0;const V=F.getAttributes();for(const Q in V)if(V[Q].location>=0){let se=$[Q];se===void 0&&(Q==="instanceMatrix"&&D.instanceMatrix&&(se=D.instanceMatrix),Q==="instanceColor"&&D.instanceColor&&(se=D.instanceColor));const H={};H.attribute=se,se&&se.data&&(H.data=se.data),P[Q]=H,X++}a.attributes=P,a.attributesNum=X,a.index=z}function b(){const D=a.newAttributes;for(let I=0,F=D.length;I<F;I++)D[I]=0}function v(D){y(D,0)}function y(D,I){const F=a.newAttributes,z=a.enabledAttributes,P=a.attributeDivisors;F[D]=1,z[D]===0&&(t.enableVertexAttribArray(D),z[D]=1),P[D]!==I&&(t.vertexAttribDivisor(D,I),P[D]=I)}function S(){const D=a.newAttributes,I=a.enabledAttributes;for(let F=0,z=I.length;F<z;F++)I[F]!==D[F]&&(t.disableVertexAttribArray(F),I[F]=0)}function k(D,I,F,z,P,$,X){X===!0?t.vertexAttribIPointer(D,I,F,P,$):t.vertexAttribPointer(D,I,F,z,P,$)}function T(D,I,F,z){b();const P=z.attributes,$=F.getAttributes(),X=I.defaultAttributeValues;for(const V in $){const Q=$[V];if(Q.location>=0){let Z=P[V];if(Z===void 0&&(V==="instanceMatrix"&&D.instanceMatrix&&(Z=D.instanceMatrix),V==="instanceColor"&&D.instanceColor&&(Z=D.instanceColor)),Z!==void 0){const se=Z.normalized,H=Z.itemSize,K=e.get(Z);if(K===void 0)continue;const re=K.buffer,ne=K.type,be=K.bytesPerElement,me=ne===t.INT||ne===t.UNSIGNED_INT||Z.gpuType===$4;if(Z.isInterleavedBufferAttribute){const de=Z.data,Ce=de.stride,ie=Z.offset;if(de.isInstancedInterleavedBuffer){for(let ke=0;ke<Q.locationSize;ke++)y(Q.location+ke,de.meshPerAttribute);D.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=de.meshPerAttribute*de.count)}else for(let ke=0;ke<Q.locationSize;ke++)v(Q.location+ke);t.bindBuffer(t.ARRAY_BUFFER,re);for(let ke=0;ke<Q.locationSize;ke++)k(Q.location+ke,H/Q.locationSize,ne,se,Ce*be,(ie+H/Q.locationSize*ke)*be,me)}else{if(Z.isInstancedBufferAttribute){for(let de=0;de<Q.locationSize;de++)y(Q.location+de,Z.meshPerAttribute);D.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=Z.meshPerAttribute*Z.count)}else for(let de=0;de<Q.locationSize;de++)v(Q.location+de);t.bindBuffer(t.ARRAY_BUFFER,re);for(let de=0;de<Q.locationSize;de++)k(Q.location+de,H/Q.locationSize,ne,se,H*be,H/Q.locationSize*de*be,me)}}else if(X!==void 0){const se=X[V];if(se!==void 0)switch(se.length){case 2:t.vertexAttrib2fv(Q.location,se);break;case 3:t.vertexAttrib3fv(Q.location,se);break;case 4:t.vertexAttrib4fv(Q.location,se);break;default:t.vertexAttrib1fv(Q.location,se)}}}}S()}function M(){R();for(const D in r){const I=r[D];for(const F in I){const z=I[F];for(const P in z)d(z[P].object),delete z[P];delete I[F]}delete r[D]}}function C(D){if(r[D.id]===void 0)return;const I=r[D.id];for(const F in I){const z=I[F];for(const P in z)d(z[P].object),delete z[P];delete I[F]}delete r[D.id]}function E(D){for(const I in r){const F=r[I];if(F[D.id]===void 0)continue;const z=F[D.id];for(const P in z)d(z[P].object),delete z[P];delete F[D.id]}}function R(){A(),o=!0,a!==i&&(a=i,u(a.object))}function A(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:l,reset:R,resetDefaultState:A,dispose:M,releaseStatesOfGeometry:C,releaseStatesOfProgram:E,initAttributes:b,enableAttribute:v,disableUnusedAttributes:S}}function BRe(t,e,n){let r;function i(u){r=u}function a(u,d){t.drawArrays(r,u,d),n.update(d,r,1)}function o(u,d,f){f!==0&&(t.drawArraysInstanced(r,u,d,f),n.update(d,r,f))}function l(u,d,f){if(f===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,u,0,d,0,f);let m=0;for(let x=0;x<f;x++)m+=d[x];n.update(m,r,1)}function c(u,d,f,p){if(f===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,f);let x=0;for(let b=0;b<f;b++)x+=d[b]*p[b];n.update(x,r,1)}}this.setMode=i,this.render=a,this.renderInstances=o,this.renderMultiDraw=l,this.renderMultiDrawInstances=c}function HRe(t,e,n,r){let i;function a(){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!==jl&&r.convert(E)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_FORMAT))}function l(E){const R=E===Cx&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(E!==vc&&r.convert(E)!==t.getParameter(t.IMPLEMENTATION_COLOR_READ_TYPE)&&E!==_u&&!R)}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&&(xn("WebGLRenderer:",u,"not supported, using",d,"instead."),u=d);const f=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),b=t.getParameter(t.MAX_TEXTURE_SIZE),v=t.getParameter(t.MAX_CUBE_MAP_TEXTURE_SIZE),y=t.getParameter(t.MAX_VERTEX_ATTRIBS),S=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),k=t.getParameter(t.MAX_VARYING_VECTORS),T=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),M=x>0,C=t.getParameter(t.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:c,textureFormatReadable:o,textureTypeReadable:l,precision:u,logarithmicDepthBuffer:f,reversedDepthBuffer:p,maxTextures:m,maxVertexTextures:x,maxTextureSize:b,maxCubemapSize:v,maxAttributes:y,maxVertexUniforms:S,maxVaryings:k,maxFragmentUniforms:T,vertexTextures:M,maxSamples:C}}function $Re(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new Bd,l=new Dn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p){const m=f.length!==0||p||r!==0||i;return i=p,r=f.length,m},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,p){n=d(f,p,0)},this.setState=function(f,p,m){const x=f.clippingPlanes,b=f.clipIntersection,v=f.clipShadows,y=t.get(f);if(!i||x===null||x.length===0||a&&!v)a?d(null):u();else{const S=a?0:r,k=S*4;let T=y.clippingState||null;c.value=T,T=d(x,p,k,m);for(let M=0;M!==k;++M)T[M]=n[M];y.clippingState=T,this.numIntersection=b?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(f,p,m,x){const b=f!==null?f.length:0;let v=null;if(b!==0){if(v=c.value,x!==!0||v===null){const y=m+b*4,S=p.matrixWorldInverse;l.getNormalMatrix(S),(v===null||v.length<y)&&(v=new Float32Array(y));for(let k=0,T=m;k!==b;++k,T+=4)o.copy(f[k]).applyMatrix4(S,l),o.normal.toArray(v,T),v[T+3]=o.constant}c.value=v,c.needsUpdate=!0}return e.numPlanes=b,e.numIntersection=0,v}}function VRe(t){let e=new WeakMap;function n(o,l){return l===j3?o.mapping=Zg:l===D3&&(o.mapping=Jg),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===j3||l===D3)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 Uje(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 a(){e=new WeakMap}return{get:r,dispose:a}}const Qd=4,uV=[.125,.215,.35,.446,.526,.582],Mf=20,GRe=256,qb=new PJ,dV=new Bn;let xC=null,bC=0,yC=0,vC=!1;const qRe=new ht;let hV=class{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,n=0,r=.1,i=100,a={}){const{size:o=256,position:l=qRe}=a;xC=this._renderer.getRenderTarget(),bC=this._renderer.getActiveCubeFace(),yC=this._renderer.getActiveMipmapLevel(),vC=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=pV(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=mV(),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(xC,bC,yC),this._renderer.xr.enabled=vC,e.scissorTest=!1,Dp(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===Zg||e.mapping===Jg?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),xC=this._renderer.getRenderTarget(),bC=this._renderer.getActiveCubeFace(),yC=this._renderer.getActiveMipmapLevel(),vC=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const r=n||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,r={magFilter:el,minFilter:el,generateMipmaps:!1,type:Cx,format:jl,colorSpace:ex,depthBuffer:!1},i=fV(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=fV(e,n,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=WRe(a)),this._blurMaterial=XRe(a,e,n),this._ggxMaterial=KRe(a,e,n)}return i}_compileMaterial(e){const n=new wc(new Cc,e);this._renderer.compile(n,qb)}_sceneToCubeUV(e,n,r,i,a){const c=new Wo(90,1,n,r),u=[1,-1,1,1,1,1],d=[1,1,1,-1,-1,-1],f=this._renderer,p=f.autoClear,m=f.toneMapping;f.getClearColor(dV),f.toneMapping=lh,f.autoClear=!1,f.state.buffers.depth.getReversed()&&(f.setRenderTarget(i),f.clearDepth(),f.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new wc(new J4,new Z4({name:"PMREM.Background",side:Is,depthWrite:!1,depthTest:!1})));const b=this._backgroundBox,v=b.material;let y=!1;const S=e.background;S?S.isColor&&(v.color.copy(S),e.background=null,y=!0):(v.color.copy(dV),y=!0);for(let k=0;k<6;k++){const T=k%3;T===0?(c.up.set(0,u[k],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x+d[k],a.y,a.z)):T===1?(c.up.set(0,0,u[k]),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y+d[k],a.z)):(c.up.set(0,u[k],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y,a.z+d[k]));const M=this._cubeSize;Dp(i,T*M,k>2?M:0,M,M),f.setRenderTarget(i),y&&f.render(b,c),f.render(e,c)}f.toneMapping=m,f.autoClear=p,e.background=S}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===Zg||e.mapping===Jg;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=pV()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=mV());const a=i?this._cubemapMaterial:this._equirectMaterial,o=this._lodMeshes[0];o.material=a;const l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;Dp(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,qb)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;const i=this._lodMeshes.length;for(let a=1;a<i;a++)this._applyGGXFilter(e,a-1,a);n.autoClear=r}_applyGGXFilter(e,n,r){const i=this._renderer,a=this._pingPongRenderTarget,o=this._ggxMaterial,l=this._lodMeshes[r];l.material=o;const c=o.uniforms,u=r/(this._lodMeshes.length-1),d=n/(this._lodMeshes.length-1),f=Math.sqrt(u*u-d*d),p=.05+u*.95,m=f*p,{_lodMax:x}=this,b=this._sizeLods[r],v=3*b*(r>x-Qd?r-x+Qd:0),y=4*(this._cubeSize-b);c.envMap.value=e.texture,c.roughness.value=m,c.mipInt.value=x-n,Dp(a,v,y,3*b,2*b),i.setRenderTarget(a),i.render(l,qb),c.envMap.value=a.texture,c.roughness.value=0,c.mipInt.value=x-r,Dp(e,v,y,3*b,2*b),i.setRenderTarget(e),i.render(l,qb)}_blur(e,n,r,i,a){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",a),this._halfBlur(o,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,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,f=this._lodMeshes[i];f.material=u;const p=u.uniforms,m=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*m):2*Math.PI/(2*Mf-1),b=a/x,v=isFinite(a)?1+Math.floor(d*b):Mf;v>Mf&&xn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Mf}`);const y=[];let S=0;for(let E=0;E<Mf;++E){const R=E/b,A=Math.exp(-R*R/2);y.push(A),E===0?S+=A:E<v&&(S+=2*A)}for(let E=0;E<y.length;E++)y[E]=y[E]/S;p.envMap.value=e.texture,p.samples.value=v,p.weights.value=y,p.latitudinal.value=o==="latitudinal",l&&(p.poleAxis.value=l);const{_lodMax:k}=this;p.dTheta.value=x,p.mipInt.value=k-r;const T=this._sizeLods[i],M=3*T*(i>k-Qd?i-k+Qd:0),C=4*(this._cubeSize-T);Dp(n,M,C,3*T,2*T),c.setRenderTarget(n),c.render(f,qb)}};function WRe(t){const e=[],n=[],r=[];let i=t;const a=t-Qd+1+uV.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);e.push(l);let c=1/l;o>t-Qd?c=uV[o-t+Qd-1]:o===0&&(c=0),n.push(c);const u=1/(l-2),d=-u,f=1+u,p=[d,d,f,d,f,f,d,d,f,f,d,f],m=6,x=6,b=3,v=2,y=1,S=new Float32Array(b*x*m),k=new Float32Array(v*x*m),T=new Float32Array(y*x*m);for(let C=0;C<m;C++){const E=C%3*2/3-1,R=C>2?0:-1,A=[E,R,0,E+2/3,R,0,E+2/3,R+1,0,E,R,0,E+2/3,R+1,0,E,R+1,0];S.set(A,b*x*C),k.set(p,v*x*C);const D=[C,C,C,C,C,C];T.set(D,y*x*C)}const M=new Cc;M.setAttribute("position",new nl(S,b)),M.setAttribute("uv",new nl(k,v)),M.setAttribute("faceIndex",new nl(T,y)),r.push(new wc(M,null)),i>Qd&&i--}return{lodMeshes:r,sizeLods:e,sigmas:n}}function fV(t,e,n){const r=new xm(t,e,n);return r.texture.mapping=f2,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Dp(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function KRe(t,e,n){return new $u({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:GRe,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:p2(),fragmentShader:`
- precision highp float;
- precision highp int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform float roughness;
- uniform float mipInt;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- #define PI 3.14159265359
- // Van der Corput radical inverse
- float radicalInverse_VdC(uint bits) {
- bits = (bits << 16u) | (bits >> 16u);
- bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
- bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
- bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
- bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
- return float(bits) * 2.3283064365386963e-10; // / 0x100000000
- }
- // Hammersley sequence
- vec2 hammersley(uint i, uint N) {
- return vec2(float(i) / float(N), radicalInverse_VdC(i));
- }
- // GGX VNDF importance sampling (Eric Heitz 2018)
- // "Sampling the GGX Distribution of Visible Normals"
- // https://jcgt.org/published/0007/04/01/
- vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
- float alpha = roughness * roughness;
- // Section 3.2: Transform view direction to hemisphere configuration
- vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
- // Section 4.1: Orthonormal basis
- float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
- vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
- vec3 T2 = cross(Vh, T1);
- // Section 4.2: Parameterization of projected area
- float r = sqrt(Xi.x);
- float phi = 2.0 * PI * Xi.y;
- float t1 = r * cos(phi);
- float t2 = r * sin(phi);
- float s = 0.5 * (1.0 + Vh.z);
- t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
- // Section 4.3: Reprojection onto hemisphere
- vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
- // Section 3.4: Transform back to ellipsoid configuration
- return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
- }
- void main() {
- vec3 N = normalize(vOutputDirection);
- vec3 V = N; // Assume view direction equals normal for pre-filtering
- vec3 prefilteredColor = vec3(0.0);
- float totalWeight = 0.0;
- // For very low roughness, just sample the environment directly
- if (roughness < 0.001) {
- gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
- return;
- }
- // Tangent space basis for VNDF sampling
- vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
- vec3 tangent = normalize(cross(up, N));
- vec3 bitangent = cross(N, tangent);
- for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
- vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
- // For PMREM, V = N, so in tangent space V is always (0, 0, 1)
- vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
- // Transform H back to world space
- vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
- vec3 L = normalize(2.0 * dot(V, H) * H - V);
- float NdotL = max(dot(N, L), 0.0);
- if(NdotL > 0.0) {
- // Sample environment at fixed mip level
- // VNDF importance sampling handles the distribution filtering
- vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
- // Weight by NdotL for the split-sum approximation
- // VNDF PDF naturally accounts for the visible microfacet distribution
- prefilteredColor += sampleColor * NdotL;
- totalWeight += NdotL;
- }
- }
- if (totalWeight > 0.0) {
- prefilteredColor = prefilteredColor / totalWeight;
- }
- gl_FragColor = vec4(prefilteredColor, 1.0);
- }
- `,blending:Au,depthTest:!1,depthWrite:!1})}function XRe(t,e,n){const r=new Float32Array(Mf),i=new ht(0,1,0);return new $u({name:"SphericalGaussianBlur",defines:{n:Mf,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:p2(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:Au,depthTest:!1,depthWrite:!1})}function mV(){return new $u({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:p2(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:Au,depthTest:!1,depthWrite:!1})}function pV(){return new $u({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:p2(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:Au,depthTest:!1,depthWrite:!1})}function p2(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function YRe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===j3||c===D3,d=c===Zg||c===Jg;if(u||d){let f=e.get(l);const p=f!==void 0?f.texture.pmremVersion:0;if(l.isRenderTargetTexture&&l.pmremVersion!==p)return n===null&&(n=new hV(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),f.texture;if(f!==void 0)return f.texture;{const m=l.image;return u&&m&&m.height>0||d&&m&&i(m)?(n===null&&(n=new hV(t)),f=u?n.fromEquirectangular(l):n.fromCubemap(l),f.texture.pmremVersion=l.pmremVersion,e.set(l,f),l.addEventListener("dispose",a),f.texture):null}}}return l}function i(l){let c=0;const u=6;for(let d=0;d<u;d++)l[d]!==void 0&&c++;return c===u}function a(l){const c=l.target;c.removeEventListener("dispose",a);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:r,dispose:o}}function QRe(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&&py("WebGLRenderer: "+r+" extension not supported."),i}}}function ZRe(t,e,n,r){const i={},a=new WeakMap;function o(f){const p=f.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=a.get(p);m&&(e.remove(m),a.delete(p)),r.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function l(f,p){return i[p.id]===!0||(p.addEventListener("dispose",o),i[p.id]=!0,n.memory.geometries++),p}function c(f){const p=f.attributes;for(const m in p)e.update(p[m],t.ARRAY_BUFFER)}function u(f){const p=[],m=f.index,x=f.attributes.position;let b=0;if(m!==null){const S=m.array;b=m.version;for(let k=0,T=S.length;k<T;k+=3){const M=S[k+0],C=S[k+1],E=S[k+2];p.push(M,C,C,E,E,M)}}else if(x!==void 0){const S=x.array;b=x.version;for(let k=0,T=S.length/3-1;k<T;k+=3){const M=k+0,C=k+1,E=k+2;p.push(M,C,C,E,E,M)}}else return;const v=new(uJ(p)?vJ:yJ)(p,1);v.version=b;const y=a.get(f);y&&e.remove(y),a.set(f,v)}function d(f){const p=a.get(f);if(p){const m=f.index;m!==null&&p.version<m.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function JRe(t,e,n){let r;function i(p){r=p}let a,o;function l(p){a=p.type,o=p.bytesPerElement}function c(p,m){t.drawElements(r,m,a,p*o),n.update(m,r,1)}function u(p,m,x){x!==0&&(t.drawElementsInstanced(r,m,a,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,a,p,0,x);let v=0;for(let y=0;y<x;y++)v+=m[y];n.update(v,r,1)}function f(p,m,x,b){if(x===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let y=0;y<p.length;y++)u(p[y]/o,m[y],b[y]);else{v.multiDrawElementsInstancedWEBGL(r,m,0,a,p,0,b,0,x);let y=0;for(let S=0;S<x;S++)y+=m[S]*b[S];n.update(y,r,1)}}this.setMode=i,this.setIndex=l,this.render=c,this.renderInstances=u,this.renderMultiDraw=d,this.renderMultiDrawInstances=f}function eOe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(a/3);break;case t.LINES:n.lines+=l*(a/2);break;case t.LINE_STRIP:n.lines+=l*(a-1);break;case t.LINE_LOOP:n.lines+=l*a;break;case t.POINTS:n.points+=l*a;break;default: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 tOe(t,e,n){const r=new WeakMap,i=new zi;function a(o,l,c){const u=o.morphTargetInfluences,d=l.morphAttributes.position||l.morphAttributes.normal||l.morphAttributes.color,f=d!==void 0?d.length:0;let p=r.get(l);if(p===void 0||p.count!==f){let D=function(){R.dispose(),r.delete(l),l.removeEventListener("dispose",D)};var m=D;p!==void 0&&p.texture.dispose();const x=l.morphAttributes.position!==void 0,b=l.morphAttributes.normal!==void 0,v=l.morphAttributes.color!==void 0,y=l.morphAttributes.position||[],S=l.morphAttributes.normal||[],k=l.morphAttributes.color||[];let T=0;x===!0&&(T=1),b===!0&&(T=2),v===!0&&(T=3);let M=l.attributes.position.count*T,C=1;M>e.maxTextureSize&&(C=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const E=new Float32Array(M*C*4*f),R=new pJ(E,M,C,f);R.type=_u,R.needsUpdate=!0;const A=T*4;for(let I=0;I<f;I++){const F=y[I],z=S[I],P=k[I],$=M*C*4*I;for(let X=0;X<F.count;X++){const V=X*A;x===!0&&(i.fromBufferAttribute(F,X),E[$+V+0]=i.x,E[$+V+1]=i.y,E[$+V+2]=i.z,E[$+V+3]=0),b===!0&&(i.fromBufferAttribute(z,X),E[$+V+4]=i.x,E[$+V+5]=i.y,E[$+V+6]=i.z,E[$+V+7]=0),v===!0&&(i.fromBufferAttribute(P,X),E[$+V+8]=i.x,E[$+V+9]=i.y,E[$+V+10]=i.z,E[$+V+11]=P.itemSize===4?i.w:1)}}p={count:f,texture:R,size:new Cn(M,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 b=l.morphTargetsRelative?1:1-x;c.getUniforms().setValue(t,"morphTargetBaseInfluence",b),c.getUniforms().setValue(t,"morphTargetInfluences",u)}c.getUniforms().setValue(t,"morphTargetsTexture",p.texture,n),c.getUniforms().setValue(t,"morphTargetsTextureSize",p.size)}return{update:a}}function nOe(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const p=c.skeleton;i.get(p)!==u&&(p.update(),i.set(p,u))}return f}function o(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:o}}const DJ=new Hl,gV=new EJ(1,1),RJ=new pJ,OJ=new _je,LJ=new MJ,xV=[],bV=[],yV=new Float32Array(16),vV=new Float32Array(9),wV=new Float32Array(4);function jx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=xV[i];if(a===void 0&&(a=new Float32Array(i),xV[i]=a),e!==0){r.toArray(a,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(a,l)}return a}function Ji(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 ea(t,e){for(let n=0,r=e.length;n<r;n++)t[n]=e[n]}function g2(t,e){let n=bV[e];n===void 0&&(n=new Int32Array(e),bV[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function rOe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function iOe(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(Ji(n,e))return;t.uniform2fv(this.addr,e),ea(n,e)}}function aOe(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(Ji(n,e))return;t.uniform3fv(this.addr,e),ea(n,e)}}function sOe(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(Ji(n,e))return;t.uniform4fv(this.addr,e),ea(n,e)}}function oOe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ji(n,e))return;t.uniformMatrix2fv(this.addr,!1,e),ea(n,e)}else{if(Ji(n,r))return;wV.set(r),t.uniformMatrix2fv(this.addr,!1,wV),ea(n,r)}}function lOe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ji(n,e))return;t.uniformMatrix3fv(this.addr,!1,e),ea(n,e)}else{if(Ji(n,r))return;vV.set(r),t.uniformMatrix3fv(this.addr,!1,vV),ea(n,r)}}function cOe(t,e){const n=this.cache,r=e.elements;if(r===void 0){if(Ji(n,e))return;t.uniformMatrix4fv(this.addr,!1,e),ea(n,e)}else{if(Ji(n,r))return;yV.set(r),t.uniformMatrix4fv(this.addr,!1,yV),ea(n,r)}}function uOe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function dOe(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(Ji(n,e))return;t.uniform2iv(this.addr,e),ea(n,e)}}function hOe(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(Ji(n,e))return;t.uniform3iv(this.addr,e),ea(n,e)}}function fOe(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(Ji(n,e))return;t.uniform4iv(this.addr,e),ea(n,e)}}function mOe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function pOe(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(Ji(n,e))return;t.uniform2uiv(this.addr,e),ea(n,e)}}function gOe(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(Ji(n,e))return;t.uniform3uiv(this.addr,e),ea(n,e)}}function xOe(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(Ji(n,e))return;t.uniform4uiv(this.addr,e),ea(n,e)}}function bOe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);let a;this.type===t.SAMPLER_2D_SHADOW?(gV.compareFunction=cJ,a=gV):a=DJ,n.setTexture2D(e||a,i)}function yOe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||OJ,i)}function vOe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||LJ,i)}function wOe(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||RJ,i)}function _Oe(t){switch(t){case 5126:return rOe;case 35664:return iOe;case 35665:return aOe;case 35666:return sOe;case 35674:return oOe;case 35675:return lOe;case 35676:return cOe;case 5124:case 35670:return uOe;case 35667:case 35671:return dOe;case 35668:case 35672:return hOe;case 35669:case 35673:return fOe;case 5125:return mOe;case 36294:return pOe;case 36295:return gOe;case 36296:return xOe;case 35678:case 36198:case 36298:case 36306:case 35682:return bOe;case 35679:case 36299:case 36307:return yOe;case 35680:case 36300:case 36308:case 36293:return vOe;case 36289:case 36303:case 36311:case 36292:return wOe}}function SOe(t,e){t.uniform1fv(this.addr,e)}function NOe(t,e){const n=jx(e,this.size,2);t.uniform2fv(this.addr,n)}function MOe(t,e){const n=jx(e,this.size,3);t.uniform3fv(this.addr,n)}function kOe(t,e){const n=jx(e,this.size,4);t.uniform4fv(this.addr,n)}function EOe(t,e){const n=jx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function TOe(t,e){const n=jx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function AOe(t,e){const n=jx(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function COe(t,e){t.uniform1iv(this.addr,e)}function POe(t,e){t.uniform2iv(this.addr,e)}function jOe(t,e){t.uniform3iv(this.addr,e)}function DOe(t,e){t.uniform4iv(this.addr,e)}function ROe(t,e){t.uniform1uiv(this.addr,e)}function OOe(t,e){t.uniform2uiv(this.addr,e)}function LOe(t,e){t.uniform3uiv(this.addr,e)}function FOe(t,e){t.uniform4uiv(this.addr,e)}function IOe(t,e,n){const r=this.cache,i=e.length,a=g2(n,i);Ji(r,a)||(t.uniform1iv(this.addr,a),ea(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||DJ,a[o])}function UOe(t,e,n){const r=this.cache,i=e.length,a=g2(n,i);Ji(r,a)||(t.uniform1iv(this.addr,a),ea(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||OJ,a[o])}function zOe(t,e,n){const r=this.cache,i=e.length,a=g2(n,i);Ji(r,a)||(t.uniform1iv(this.addr,a),ea(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||LJ,a[o])}function BOe(t,e,n){const r=this.cache,i=e.length,a=g2(n,i);Ji(r,a)||(t.uniform1iv(this.addr,a),ea(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||RJ,a[o])}function HOe(t){switch(t){case 5126:return SOe;case 35664:return NOe;case 35665:return MOe;case 35666:return kOe;case 35674:return EOe;case 35675:return TOe;case 35676:return AOe;case 5124:case 35670:return COe;case 35667:case 35671:return POe;case 35668:case 35672:return jOe;case 35669:case 35673:return DOe;case 5125:return ROe;case 36294:return OOe;case 36295:return LOe;case 36296:return FOe;case 35678:case 36198:case 36298:case 36306:case 35682:return IOe;case 35679:case 36299:case 36307:return UOe;case 35680:case 36300:case 36308:case 36293:return zOe;case 36289:case 36303:case 36311:case 36292:return BOe}}let $Oe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=_Oe(n.type)}},VOe=class{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=HOe(n.type)}},GOe=class{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,o=i.length;a!==o;++a){const l=i[a];l.setValue(e,n[l.id],r)}}};const wC=/(\w+)(\])?(\[|\.)?/g;function _V(t,e){t.seq.push(e),t.map[e.id]=e}function qOe(t,e,n){const r=t.name,i=r.length;for(wC.lastIndex=0;;){const a=wC.exec(r),o=wC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){_V(n,u===void 0?new $Oe(l,t,e):new VOe(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new GOe(l),_V(n,f)),n=f}}}let j1=class{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),o=e.getUniformLocation(n,a.name);qOe(a,o,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,o=n.length;a!==o;++a){const l=n[a],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const o=e[i];o.id in n&&r.push(o)}return r}};function SV(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const WOe=37297;let KOe=0;function XOe(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let o=i;o<a;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
- `)}const NV=new Dn;function YOe(t){cr._getMatrix(NV,cr.workingColorSpace,t);const e=`mat3( ${NV.elements.map(n=>n.toFixed(4))} )`;switch(cr.getTransfer(t)){case KS:return[e,"LinearTransferOETF"];case Mr:return[e,"sRGBTransferOETF"];default:return xn("WebGLProgram: Unsupported color space: ",t),[e,"LinearTransferOETF"]}}function MV(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),a=(t.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const o=/ERROR: 0:(\d+)/.exec(a);if(o){const l=parseInt(o[1]);return n.toUpperCase()+`
- `+a+`
- `+XOe(t.getShaderSource(e),l)}else return a}function QOe(t,e){const n=YOe(e);return[`vec4 ${t}( vec4 value ) {`,` return ${n[1]}( vec4( value.rgb * ${n[0]}, value.a ) );`,"}"].join(`
- `)}function ZOe(t,e){let n;switch(e){case XPe:n="Linear";break;case YPe:n="Reinhard";break;case QPe:n="Cineon";break;case ZPe:n="ACESFilmic";break;case eje:n="AgX";break;case tje:n="Neutral";break;case JPe:n="Custom";break;default:xn("WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}const v_=new ht;function JOe(){cr.getLuminanceCoefficients(v_);const t=v_.x.toFixed(4),e=v_.y.toFixed(4),n=v_.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${t}, ${e}, ${n} );`," return dot( weights, rgb );","}"].join(`
- `)}function e4e(t){return[t.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",t.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(l0).join(`
- `)}function t4e(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function n4e(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),o=a.name;let l=1;a.type===t.FLOAT_MAT2&&(l=2),a.type===t.FLOAT_MAT3&&(l=3),a.type===t.FLOAT_MAT4&&(l=4),n[o]={type:a.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function l0(t){return t!==""}function kV(t,e){const n=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return t.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function EV(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const r4e=/^[ \t]*#include +<([\w\d./]+)>/gm;function hD(t){return t.replace(r4e,a4e)}const i4e=new Map;function a4e(t,e){let n=Tn[e];if(n===void 0){const r=i4e.get(e);if(r!==void 0)n=Tn[r],xn('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return hD(n)}const s4e=/#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 TV(t){return t.replace(s4e,o4e)}function o4e(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function AV(t){let e=`precision ${t.precision} float;
- precision ${t.precision} int;
- precision ${t.precision} sampler2D;
- precision ${t.precision} samplerCube;
- precision ${t.precision} sampler3D;
- precision ${t.precision} sampler2DArray;
- precision ${t.precision} sampler2DShadow;
- precision ${t.precision} samplerCubeShadow;
- precision ${t.precision} sampler2DArrayShadow;
- precision ${t.precision} isampler2D;
- precision ${t.precision} isampler3D;
- precision ${t.precision} isamplerCube;
- precision ${t.precision} isampler2DArray;
- precision ${t.precision} usampler2D;
- precision ${t.precision} usampler3D;
- precision ${t.precision} usamplerCube;
- precision ${t.precision} usampler2DArray;
- `;return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function l4e(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===JZ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===TPe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===lu&&(e="SHADOWMAP_TYPE_VSM"),e}function c4e(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case Zg:case Jg:e="ENVMAP_TYPE_CUBE";break;case f2:e="ENVMAP_TYPE_CUBE_UV";break}return e}function u4e(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case Jg:e="ENVMAP_MODE_REFRACTION";break}return e}function d4e(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case H4:e="ENVMAP_BLENDING_MULTIPLY";break;case WPe:e="ENVMAP_BLENDING_MIX";break;case KPe:e="ENVMAP_BLENDING_ADD";break}return e}function h4e(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 f4e(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=l4e(n),u=c4e(n),d=u4e(n),f=d4e(n),p=h4e(n),m=e4e(n),x=t4e(a),b=i.createProgram();let v,y,S=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(l0).join(`
- `),v.length>0&&(v+=`
- `),y=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(l0).join(`
- `),y.length>0&&(y+=`
- `)):(v=[AV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",n.batching?"#define USE_BATCHING":"",n.batchingColor?"#define USE_BATCHING_COLOR":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.instancingMorph?"#define USE_INSTANCING_MORPH":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",n.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(l0).join(`
- `),y=[AV(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",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?ZOe("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",Tn.colorspace_pars_fragment,QOe("linearToOutputTexel",n.outputColorSpace),JOe(),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(l0).join(`
- `)),o=hD(o),o=kV(o,n),o=EV(o,n),l=hD(l),l=kV(l,n),l=EV(l,n),o=TV(o),l=TV(l),n.isRawShaderMaterial!==!0&&(S=`#version 300 es
- `,v=[m,"#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+v,y=["#define varying in",n.glslVersion===L$?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===L$?"":"#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(`
- `)+`
- `+y);const k=S+v+o,T=S+y+l,M=SV(i,i.VERTEX_SHADER,k),C=SV(i,i.FRAGMENT_SHADER,T);i.attachShader(b,M),i.attachShader(b,C),n.index0AttributeName!==void 0?i.bindAttribLocation(b,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(b,0,"position"),i.linkProgram(b);function E(I){if(t.debug.checkShaderErrors){const F=i.getProgramInfoLog(b)||"",z=i.getShaderInfoLog(M)||"",P=i.getShaderInfoLog(C)||"",$=F.trim(),X=z.trim(),V=P.trim();let Q=!0,Z=!0;if(i.getProgramParameter(b,i.LINK_STATUS)===!1)if(Q=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,b,M,C);else{const se=MV(i,M,"vertex"),H=MV(i,C,"fragment");Ti("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(b,i.VALIDATE_STATUS)+`
- Material Name: `+I.name+`
- Material Type: `+I.type+`
- Program Info Log: `+$+`
- `+se+`
- `+H)}else $!==""?xn("WebGLProgram: Program Info Log:",$):(X===""||V==="")&&(Z=!1);Z&&(I.diagnostics={runnable:Q,programLog:$,vertexShader:{log:X,prefix:v},fragmentShader:{log:V,prefix:y}})}i.deleteShader(M),i.deleteShader(C),R=new j1(i,b),A=n4e(i,b)}let R;this.getUniforms=function(){return R===void 0&&E(this),R};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(b,WOe)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(b),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=KOe++,this.cacheKey=e,this.usedTimes=1,this.program=b,this.vertexShader=M,this.fragmentShader=C,this}let m4e=0,p4e=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),a=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(a)===!1&&(o.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new g4e(e),n.set(e,r)),r}},g4e=class{constructor(e){this.id=m4e++,this.code=e,this.usedTimes=0}};function x4e(t,e,n,r,i,a,o){const l=new xJ,c=new p4e,u=new Set,d=[],f=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 b(A){return u.add(A),A===0?"uv":`uv${A}`}function v(A,D,I,F,z){const P=F.fog,$=z.geometry,X=A.isMeshStandardMaterial?F.environment:null,V=(A.isMeshStandardMaterial?n:e).get(A.envMap||X),Q=V&&V.mapping===f2?V.image.height:null,Z=x[A.type];A.precision!==null&&(m=i.getMaxPrecision(A.precision),m!==A.precision&&xn("WebGLProgram.getParameters:",A.precision,"not supported, using",m,"instead."));const se=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,H=se!==void 0?se.length:0;let K=0;$.morphAttributes.position!==void 0&&(K=1),$.morphAttributes.normal!==void 0&&(K=2),$.morphAttributes.color!==void 0&&(K=3);let re,ne,be,me;if(Z){const pt=rc[Z];re=pt.vertexShader,ne=pt.fragmentShader}else re=A.vertexShader,ne=A.fragmentShader,c.update(A),be=c.getVertexShaderID(A),me=c.getFragmentShaderID(A);const de=t.getRenderTarget(),Ce=t.state.buffers.depth.getReversed(),ie=z.isInstancedMesh===!0,ke=z.isBatchedMesh===!0,Oe=!!A.map,pe=!!A.matcap,We=!!V,G=!!A.aoMap,Y=!!A.lightMap,ue=!!A.bumpMap,q=!!A.normalMap,te=!!A.displacementMap,U=!!A.emissiveMap,he=!!A.metalnessMap,Me=!!A.roughnessMap,ge=A.anisotropy>0,B=A.clearcoat>0,O=A.dispersion>0,ee=A.iridescence>0,le=A.sheen>0,_e=A.transmission>0,ve=ge&&!!A.anisotropyMap,ae=B&&!!A.clearcoatMap,Fe=B&&!!A.clearcoatNormalMap,Be=B&&!!A.clearcoatRoughnessMap,$e=ee&&!!A.iridescenceMap,He=ee&&!!A.iridescenceThicknessMap,xe=le&&!!A.sheenColorMap,Pe=le&&!!A.sheenRoughnessMap,ze=!!A.specularMap,we=!!A.specularColorMap,Xe=!!A.specularIntensityMap,Ne=_e&&!!A.transmissionMap,rt=_e&&!!A.thicknessMap,Ee=!!A.gradientMap,Ke=!!A.alphaMap,Ue=A.alphaTest>0,W=!!A.alphaHash,je=!!A.extensions;let Ye=lh;A.toneMapped&&(de===null||de.isXRRenderTarget===!0)&&(Ye=t.toneMapping);const bt={shaderID:Z,shaderType:A.type,shaderName:A.name,vertexShader:re,fragmentShader:ne,defines:A.defines,customVertexShaderID:be,customFragmentShaderID:me,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:m,batching:ke,batchingColor:ke&&z._colorsTexture!==null,instancing:ie,instancingColor:ie&&z.instanceColor!==null,instancingMorph:ie&&z.morphTexture!==null,supportsVertexTextures:p,outputColorSpace:de===null?t.outputColorSpace:de.isXRRenderTarget===!0?de.texture.colorSpace:ex,alphaToCoverage:!!A.alphaToCoverage,map:Oe,matcap:pe,envMap:We,envMapMode:We&&V.mapping,envMapCubeUVHeight:Q,aoMap:G,lightMap:Y,bumpMap:ue,normalMap:q,displacementMap:p&&te,emissiveMap:U,normalMapObjectSpace:q&&A.normalMapType===aje,normalMapTangentSpace:q&&A.normalMapType===lJ,metalnessMap:he,roughnessMap:Me,anisotropy:ge,anisotropyMap:ve,clearcoat:B,clearcoatMap:ae,clearcoatNormalMap:Fe,clearcoatRoughnessMap:Be,dispersion:O,iridescence:ee,iridescenceMap:$e,iridescenceThicknessMap:He,sheen:le,sheenColorMap:xe,sheenRoughnessMap:Pe,specularMap:ze,specularColorMap:we,specularIntensityMap:Xe,transmission:_e,transmissionMap:Ne,thicknessMap:rt,gradientMap:Ee,opaque:A.transparent===!1&&A.blending===Ag&&A.alphaToCoverage===!1,alphaMap:Ke,alphaTest:Ue,alphaHash:W,combine:A.combine,mapUv:Oe&&b(A.map.channel),aoMapUv:G&&b(A.aoMap.channel),lightMapUv:Y&&b(A.lightMap.channel),bumpMapUv:ue&&b(A.bumpMap.channel),normalMapUv:q&&b(A.normalMap.channel),displacementMapUv:te&&b(A.displacementMap.channel),emissiveMapUv:U&&b(A.emissiveMap.channel),metalnessMapUv:he&&b(A.metalnessMap.channel),roughnessMapUv:Me&&b(A.roughnessMap.channel),anisotropyMapUv:ve&&b(A.anisotropyMap.channel),clearcoatMapUv:ae&&b(A.clearcoatMap.channel),clearcoatNormalMapUv:Fe&&b(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:Be&&b(A.clearcoatRoughnessMap.channel),iridescenceMapUv:$e&&b(A.iridescenceMap.channel),iridescenceThicknessMapUv:He&&b(A.iridescenceThicknessMap.channel),sheenColorMapUv:xe&&b(A.sheenColorMap.channel),sheenRoughnessMapUv:Pe&&b(A.sheenRoughnessMap.channel),specularMapUv:ze&&b(A.specularMap.channel),specularColorMapUv:we&&b(A.specularColorMap.channel),specularIntensityMapUv:Xe&&b(A.specularIntensityMap.channel),transmissionMapUv:Ne&&b(A.transmissionMap.channel),thicknessMapUv:rt&&b(A.thicknessMap.channel),alphaMapUv:Ke&&b(A.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(q||ge),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,pointsUvs:z.isPoints===!0&&!!$.attributes.uv&&(Oe||Ke),fog:!!P,useFog:A.fog===!0,fogExp2:!!P&&P.isFogExp2,flatShading:A.flatShading===!0&&A.wireframe===!1,sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:f,reversedDepthBuffer:Ce,skinning:z.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:K,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:Oe&&A.map.isVideoTexture===!0&&cr.getTransfer(A.map.colorSpace)===Mr,decodeVideoTextureEmissive:U&&A.emissiveMap.isVideoTexture===!0&&cr.getTransfer(A.emissiveMap.colorSpace)===Mr,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===ic,flipSided:A.side===Is,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionClipCullDistance:je&&A.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(je&&A.extensions.multiDraw===!0||ke)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:A.customProgramCacheKey()};return bt.vertexUv1s=u.has(1),bt.vertexUv2s=u.has(2),bt.vertexUv3s=u.has(3),u.clear(),bt}function y(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),k(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 k(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 F=rc[D];I=Oje.clone(F.uniforms)}else I=A.uniforms;return I}function M(A,D){let I;for(let F=0,z=d.length;F<z;F++){const P=d[F];if(P.cacheKey===D){I=P,++I.usedTimes;break}}return I===void 0&&(I=new f4e(t,D,A,a),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 R(){c.dispose()}return{getParameters:v,getProgramCacheKey:y,getUniforms:T,acquireProgram:M,releaseProgram:C,releaseShaderCache:E,programs:d,dispose:R}}function b4e(){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 a(){t=new WeakMap}return{has:e,get:n,remove:r,update:i,dispose:a}}function y4e(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 CV(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 PV(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function o(f,p,m,x,b,v){let y=t[e];return y===void 0?(y={id:f.id,object:f,geometry:p,material:m,groupOrder:x,renderOrder:f.renderOrder,z:b,group:v},t[e]=y):(y.id=f.id,y.object=f,y.geometry=p,y.material=m,y.groupOrder=x,y.renderOrder=f.renderOrder,y.z=b,y.group=v),e++,y}function l(f,p,m,x,b,v){const y=o(f,p,m,x,b,v);m.transmission>0?r.push(y):m.transparent===!0?i.push(y):n.push(y)}function c(f,p,m,x,b,v){const y=o(f,p,m,x,b,v);m.transmission>0?r.unshift(y):m.transparent===!0?i.unshift(y):n.unshift(y)}function u(f,p){n.length>1&&n.sort(f||y4e),r.length>1&&r.sort(p||CV),i.length>1&&i.sort(p||CV)}function d(){for(let f=e,p=t.length;f<p;f++){const m=t[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function v4e(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new PV,t.set(r,[o])):i>=a.length?(o=new PV,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function w4e(){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 ht,color:new Bn};break;case"SpotLight":n={position:new ht,direction:new ht,color:new Bn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new ht,color:new Bn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new ht,skyColor:new Bn,groundColor:new Bn};break;case"RectAreaLight":n={color:new Bn,position:new ht,halfWidth:new ht,halfHeight:new ht};break}return t[e.id]=n,n}}}function _4e(){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 S4e=0;function N4e(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function M4e(t){const e=new w4e,n=_4e(),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 ht);const i=new ht,a=new Gi,o=new Gi;function l(u){let d=0,f=0,p=0;for(let A=0;A<9;A++)r.probe[A].set(0,0,0);let m=0,x=0,b=0,v=0,y=0,S=0,k=0,T=0,M=0,C=0,E=0;u.sort(N4e);for(let A=0,D=u.length;A<D;A++){const I=u[A],F=I.color,z=I.intensity,P=I.distance,$=I.shadow&&I.shadow.map?I.shadow.map.texture:null;if(I.isAmbientLight)d+=F.r*z,f+=F.g*z,p+=F.b*z;else if(I.isLightProbe){for(let X=0;X<9;X++)r.probe[X].addScaledVector(I.sh.coefficients[X],z);E++}else if(I.isDirectionalLight){const X=e.get(I);if(X.color.copy(I.color).multiplyScalar(I.intensity),I.castShadow){const V=I.shadow,Q=n.get(I);Q.shadowIntensity=V.intensity,Q.shadowBias=V.bias,Q.shadowNormalBias=V.normalBias,Q.shadowRadius=V.radius,Q.shadowMapSize=V.mapSize,r.directionalShadow[m]=Q,r.directionalShadowMap[m]=$,r.directionalShadowMatrix[m]=I.shadow.matrix,S++}r.directional[m]=X,m++}else if(I.isSpotLight){const X=e.get(I);X.position.setFromMatrixPosition(I.matrixWorld),X.color.copy(F).multiplyScalar(z),X.distance=P,X.coneCos=Math.cos(I.angle),X.penumbraCos=Math.cos(I.angle*(1-I.penumbra)),X.decay=I.decay,r.spot[b]=X;const V=I.shadow;if(I.map&&(r.spotLightMap[M]=I.map,M++,V.updateMatrices(I),I.castShadow&&C++),r.spotLightMatrix[b]=V.matrix,I.castShadow){const Q=n.get(I);Q.shadowIntensity=V.intensity,Q.shadowBias=V.bias,Q.shadowNormalBias=V.normalBias,Q.shadowRadius=V.radius,Q.shadowMapSize=V.mapSize,r.spotShadow[b]=Q,r.spotShadowMap[b]=$,T++}b++}else if(I.isRectAreaLight){const X=e.get(I);X.color.copy(F).multiplyScalar(z),X.halfWidth.set(I.width*.5,0,0),X.halfHeight.set(0,I.height*.5,0),r.rectArea[v]=X,v++}else if(I.isPointLight){const X=e.get(I);if(X.color.copy(I.color).multiplyScalar(I.intensity),X.distance=I.distance,X.decay=I.decay,I.castShadow){const V=I.shadow,Q=n.get(I);Q.shadowIntensity=V.intensity,Q.shadowBias=V.bias,Q.shadowNormalBias=V.normalBias,Q.shadowRadius=V.radius,Q.shadowMapSize=V.mapSize,Q.shadowCameraNear=V.camera.near,Q.shadowCameraFar=V.camera.far,r.pointShadow[x]=Q,r.pointShadowMap[x]=$,r.pointShadowMatrix[x]=I.shadow.matrix,k++}r.point[x]=X,x++}else if(I.isHemisphereLight){const X=e.get(I);X.skyColor.copy(I.color).multiplyScalar(z),X.groundColor.copy(I.groundColor).multiplyScalar(z),r.hemi[y]=X,y++}}v>0&&(t.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=Ot.LTC_FLOAT_1,r.rectAreaLTC2=Ot.LTC_FLOAT_2):(r.rectAreaLTC1=Ot.LTC_HALF_1,r.rectAreaLTC2=Ot.LTC_HALF_2)),r.ambient[0]=d,r.ambient[1]=f,r.ambient[2]=p;const R=r.hash;(R.directionalLength!==m||R.pointLength!==x||R.spotLength!==b||R.rectAreaLength!==v||R.hemiLength!==y||R.numDirectionalShadows!==S||R.numPointShadows!==k||R.numSpotShadows!==T||R.numSpotMaps!==M||R.numLightProbes!==E)&&(r.directional.length=m,r.spot.length=b,r.rectArea.length=v,r.point.length=x,r.hemi.length=y,r.directionalShadow.length=S,r.directionalShadowMap.length=S,r.pointShadow.length=k,r.pointShadowMap.length=k,r.spotShadow.length=T,r.spotShadowMap.length=T,r.directionalShadowMatrix.length=S,r.pointShadowMatrix.length=k,r.spotLightMatrix.length=T+M-C,r.spotLightMap.length=M,r.numSpotLightShadowsWithMaps=C,r.numLightProbes=E,R.directionalLength=m,R.pointLength=x,R.spotLength=b,R.rectAreaLength=v,R.hemiLength=y,R.numDirectionalShadows=S,R.numPointShadows=k,R.numSpotShadows=T,R.numSpotMaps=M,R.numLightProbes=E,r.version=S4e++)}function c(u,d){let f=0,p=0,m=0,x=0,b=0;const v=d.matrixWorldInverse;for(let y=0,S=u.length;y<S;y++){const k=u[y];if(k.isDirectionalLight){const T=r.directional[f];T.direction.setFromMatrixPosition(k.matrixWorld),i.setFromMatrixPosition(k.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(v),f++}else if(k.isSpotLight){const T=r.spot[m];T.position.setFromMatrixPosition(k.matrixWorld),T.position.applyMatrix4(v),T.direction.setFromMatrixPosition(k.matrixWorld),i.setFromMatrixPosition(k.target.matrixWorld),T.direction.sub(i),T.direction.transformDirection(v),m++}else if(k.isRectAreaLight){const T=r.rectArea[x];T.position.setFromMatrixPosition(k.matrixWorld),T.position.applyMatrix4(v),o.identity(),a.copy(k.matrixWorld),a.premultiply(v),o.extractRotation(a),T.halfWidth.set(k.width*.5,0,0),T.halfHeight.set(0,k.height*.5,0),T.halfWidth.applyMatrix4(o),T.halfHeight.applyMatrix4(o),x++}else if(k.isPointLight){const T=r.point[p];T.position.setFromMatrixPosition(k.matrixWorld),T.position.applyMatrix4(v),p++}else if(k.isHemisphereLight){const T=r.hemi[b];T.direction.setFromMatrixPosition(k.matrixWorld),T.direction.transformDirection(v),b++}}}return{setup:l,setupView:c,state:r}}function jV(t){const e=new M4e(t),n=[],r=[];function i(d){u.camera=d,n.length=0,r.length=0}function a(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:a,pushShadow:o}}function k4e(t){let e=new WeakMap;function n(i,a=0){const o=e.get(i);let l;return o===void 0?(l=new jV(t),e.set(i,[l])):a>=o.length?(l=new jV(t),o.push(l)):l=o[a],l}function r(){e=new WeakMap}return{get:n,dispose:r}}const E4e=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,T4e=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function A4e(t,e,n){let r=new eL;const i=new Cn,a=new Cn,o=new zi,l=new Xje({depthPacking:ije}),c=new Yje,u={},d=n.maxTextureSize,f={[kh]:Is,[Is]:kh,[ic]:ic},p=new $u({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Cn},radius:{value:4}},vertexShader:E4e,fragmentShader:T4e}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const x=new Cc;x.setAttribute("position",new nl(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new wc(x,p),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=JZ;let y=this.type;this.render=function(C,E,R){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||C.length===0)return;const A=t.getRenderTarget(),D=t.getActiveCubeFace(),I=t.getActiveMipmapLevel(),F=t.state;F.setBlending(Au),F.buffers.depth.getReversed()===!0?F.buffers.color.setClear(0,0,0,0):F.buffers.color.setClear(1,1,1,1),F.buffers.depth.setTest(!0),F.setScissorTest(!1);const z=y!==lu&&this.type===lu,P=y===lu&&this.type!==lu;for(let $=0,X=C.length;$<X;$++){const V=C[$],Q=V.shadow;if(Q===void 0){xn("WebGLShadowMap:",V,"has no shadow.");continue}if(Q.autoUpdate===!1&&Q.needsUpdate===!1)continue;i.copy(Q.mapSize);const Z=Q.getFrameExtents();if(i.multiply(Z),a.copy(Q.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Z.x),i.x=a.x*Z.x,Q.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Z.y),i.y=a.y*Z.y,Q.mapSize.y=a.y)),Q.map===null||z===!0||P===!0){const H=this.type!==lu?{minFilter:mo,magFilter:mo}:{};Q.map!==null&&Q.map.dispose(),Q.map=new xm(i.x,i.y,H),Q.map.texture.name=V.name+".shadowMap",Q.camera.updateProjectionMatrix()}t.setRenderTarget(Q.map),t.clear();const se=Q.getViewportCount();for(let H=0;H<se;H++){const K=Q.getViewport(H);o.set(a.x*K.x,a.y*K.y,a.x*K.z,a.y*K.w),F.viewport(o),Q.updateMatrices(V,H),r=Q.getFrustum(),T(E,R,Q.camera,V,this.type)}Q.isPointLightShadow!==!0&&this.type===lu&&S(Q,R),Q.needsUpdate=!1}y=this.type,v.needsUpdate=!1,t.setRenderTarget(A,D,I)};function S(C,E){const R=e.update(b);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 xm(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,R,p,b,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,R,m,b,null)}function k(C,E,R,A){let D=null;const I=R.isPointLight===!0?C.customDistanceMaterial:C.customDepthMaterial;if(I!==void 0)D=I;else if(D=R.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 F=D.uuid,z=E.uuid;let P=u[F];P===void 0&&(P={},u[F]=P);let $=P[z];$===void 0&&($=D.clone(),P[z]=$,E.addEventListener("dispose",M)),D=$}if(D.visible=E.visible,D.wireframe=E.wireframe,A===lu?D.side=E.shadowSide!==null?E.shadowSide:E.side:D.side=E.shadowSide!==null?E.shadowSide:f[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,R.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const F=t.properties.get(D);F.light=R}return D}function T(C,E,R,A,D){if(C.visible===!1)return;if(C.layers.test(E.layers)&&(C.isMesh||C.isLine||C.isPoints)&&(C.castShadow||C.receiveShadow&&D===lu)&&(!C.frustumCulled||r.intersectsObject(C))){C.modelViewMatrix.multiplyMatrices(R.matrixWorldInverse,C.matrixWorld);const z=e.update(C),P=C.material;if(Array.isArray(P)){const $=z.groups;for(let X=0,V=$.length;X<V;X++){const Q=$[X],Z=P[Q.materialIndex];if(Z&&Z.visible){const se=k(C,Z,A,D);C.onBeforeShadow(t,C,E,R,z,se,Q),t.renderBufferDirect(R,null,z,se,C,Q),C.onAfterShadow(t,C,E,R,z,se,Q)}}}else if(P.visible){const $=k(C,P,A,D);C.onBeforeShadow(t,C,E,R,z,$,null),t.renderBufferDirect(R,null,z,$,C,null),C.onAfterShadow(t,C,E,R,z,$,null)}}const F=C.children;for(let z=0,P=F.length;z<P;z++)T(F[z],E,R,A,D)}function M(C){C.target.removeEventListener("dispose",M);for(const R in u){const A=u[R],D=C.target.uuid;D in A&&(A[D].dispose(),delete A[D])}}}const C4e={[M3]:k3,[E3]:C3,[T3]:P3,[Qg]:A3,[k3]:M3,[C3]:E3,[P3]:T3,[A3]:Qg};function P4e(t,e){function n(){let Ne=!1;const rt=new zi;let Ee=null;const Ke=new zi(0,0,0,0);return{setMask:function(Ue){Ee!==Ue&&!Ne&&(t.colorMask(Ue,Ue,Ue,Ue),Ee=Ue)},setLocked:function(Ue){Ne=Ue},setClear:function(Ue,W,je,Ye,bt){bt===!0&&(Ue*=Ye,W*=Ye,je*=Ye),rt.set(Ue,W,je,Ye),Ke.equals(rt)===!1&&(t.clearColor(Ue,W,je,Ye),Ke.copy(rt))},reset:function(){Ne=!1,Ee=null,Ke.set(-1,0,0,0)}}}function r(){let Ne=!1,rt=!1,Ee=null,Ke=null,Ue=null;return{setReversed:function(W){if(rt!==W){const je=e.get("EXT_clip_control");W?je.clipControlEXT(je.LOWER_LEFT_EXT,je.ZERO_TO_ONE_EXT):je.clipControlEXT(je.LOWER_LEFT_EXT,je.NEGATIVE_ONE_TO_ONE_EXT),rt=W;const Ye=Ue;Ue=null,this.setClear(Ye)}},getReversed:function(){return rt},setTest:function(W){W?de(t.DEPTH_TEST):Ce(t.DEPTH_TEST)},setMask:function(W){Ee!==W&&!Ne&&(t.depthMask(W),Ee=W)},setFunc:function(W){if(rt&&(W=C4e[W]),Ke!==W){switch(W){case M3:t.depthFunc(t.NEVER);break;case k3:t.depthFunc(t.ALWAYS);break;case E3:t.depthFunc(t.LESS);break;case Qg:t.depthFunc(t.LEQUAL);break;case T3:t.depthFunc(t.EQUAL);break;case A3:t.depthFunc(t.GEQUAL);break;case C3:t.depthFunc(t.GREATER);break;case P3:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ke=W}},setLocked:function(W){Ne=W},setClear:function(W){Ue!==W&&(rt&&(W=1-W),t.clearDepth(W),Ue=W)},reset:function(){Ne=!1,Ee=null,Ke=null,Ue=null,rt=!1}}}function i(){let Ne=!1,rt=null,Ee=null,Ke=null,Ue=null,W=null,je=null,Ye=null,bt=null;return{setTest:function(pt){Ne||(pt?de(t.STENCIL_TEST):Ce(t.STENCIL_TEST))},setMask:function(pt){rt!==pt&&!Ne&&(t.stencilMask(pt),rt=pt)},setFunc:function(pt,Bt,Lt){(Ee!==pt||Ke!==Bt||Ue!==Lt)&&(t.stencilFunc(pt,Bt,Lt),Ee=pt,Ke=Bt,Ue=Lt)},setOp:function(pt,Bt,Lt){(W!==pt||je!==Bt||Ye!==Lt)&&(t.stencilOp(pt,Bt,Lt),W=pt,je=Bt,Ye=Lt)},setLocked:function(pt){Ne=pt},setClear:function(pt){bt!==pt&&(t.clearStencil(pt),bt=pt)},reset:function(){Ne=!1,rt=null,Ee=null,Ke=null,Ue=null,W=null,je=null,Ye=null,bt=null}}}const a=new n,o=new r,l=new i,c=new WeakMap,u=new WeakMap;let d={},f={},p=new WeakMap,m=[],x=null,b=!1,v=null,y=null,S=null,k=null,T=null,M=null,C=null,E=new Bn(0,0,0),R=0,A=!1,D=null,I=null,F=null,z=null,P=null;const $=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let X=!1,V=0;const Q=t.getParameter(t.VERSION);Q.indexOf("WebGL")!==-1?(V=parseFloat(/^WebGL (\d)/.exec(Q)[1]),X=V>=1):Q.indexOf("OpenGL ES")!==-1&&(V=parseFloat(/^OpenGL ES (\d)/.exec(Q)[1]),X=V>=2);let Z=null,se={};const H=t.getParameter(t.SCISSOR_BOX),K=t.getParameter(t.VIEWPORT),re=new zi().fromArray(H),ne=new zi().fromArray(K);function be(Ne,rt,Ee,Ke){const Ue=new Uint8Array(4),W=t.createTexture();t.bindTexture(Ne,W),t.texParameteri(Ne,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(Ne,t.TEXTURE_MAG_FILTER,t.NEAREST);for(let je=0;je<Ee;je++)Ne===t.TEXTURE_3D||Ne===t.TEXTURE_2D_ARRAY?t.texImage3D(rt,0,t.RGBA,1,1,Ke,0,t.RGBA,t.UNSIGNED_BYTE,Ue):t.texImage2D(rt+je,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,Ue);return W}const me={};me[t.TEXTURE_2D]=be(t.TEXTURE_2D,t.TEXTURE_2D,1),me[t.TEXTURE_CUBE_MAP]=be(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),me[t.TEXTURE_2D_ARRAY]=be(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),me[t.TEXTURE_3D]=be(t.TEXTURE_3D,t.TEXTURE_3D,1,1),a.setClear(0,0,0,1),o.setClear(1),l.setClear(0),de(t.DEPTH_TEST),o.setFunc(Qg),ue(!1),q(C$),de(t.CULL_FACE),G(Au);function de(Ne){d[Ne]!==!0&&(t.enable(Ne),d[Ne]=!0)}function Ce(Ne){d[Ne]!==!1&&(t.disable(Ne),d[Ne]=!1)}function ie(Ne,rt){return f[Ne]!==rt?(t.bindFramebuffer(Ne,rt),f[Ne]=rt,Ne===t.DRAW_FRAMEBUFFER&&(f[t.FRAMEBUFFER]=rt),Ne===t.FRAMEBUFFER&&(f[t.DRAW_FRAMEBUFFER]=rt),!0):!1}function ke(Ne,rt){let Ee=m,Ke=!1;if(Ne){Ee=p.get(rt),Ee===void 0&&(Ee=[],p.set(rt,Ee));const Ue=Ne.textures;if(Ee.length!==Ue.length||Ee[0]!==t.COLOR_ATTACHMENT0){for(let W=0,je=Ue.length;W<je;W++)Ee[W]=t.COLOR_ATTACHMENT0+W;Ee.length=Ue.length,Ke=!0}}else Ee[0]!==t.BACK&&(Ee[0]=t.BACK,Ke=!0);Ke&&t.drawBuffers(Ee)}function Oe(Ne){return x!==Ne?(t.useProgram(Ne),x=Ne,!0):!1}const pe={[Nf]:t.FUNC_ADD,[CPe]:t.FUNC_SUBTRACT,[PPe]:t.FUNC_REVERSE_SUBTRACT};pe[jPe]=t.MIN,pe[DPe]=t.MAX;const We={[RPe]:t.ZERO,[OPe]:t.ONE,[LPe]:t.SRC_COLOR,[S3]:t.SRC_ALPHA,[HPe]:t.SRC_ALPHA_SATURATE,[zPe]:t.DST_COLOR,[IPe]:t.DST_ALPHA,[FPe]:t.ONE_MINUS_SRC_COLOR,[N3]:t.ONE_MINUS_SRC_ALPHA,[BPe]:t.ONE_MINUS_DST_COLOR,[UPe]:t.ONE_MINUS_DST_ALPHA,[$Pe]:t.CONSTANT_COLOR,[VPe]:t.ONE_MINUS_CONSTANT_COLOR,[GPe]:t.CONSTANT_ALPHA,[qPe]:t.ONE_MINUS_CONSTANT_ALPHA};function G(Ne,rt,Ee,Ke,Ue,W,je,Ye,bt,pt){if(Ne===Au){b===!0&&(Ce(t.BLEND),b=!1);return}if(b===!1&&(de(t.BLEND),b=!0),Ne!==APe){if(Ne!==v||pt!==A){if((y!==Nf||T!==Nf)&&(t.blendEquation(t.FUNC_ADD),y=Nf,T=Nf),pt)switch(Ne){case Ag:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case P$:t.blendFunc(t.ONE,t.ONE);break;case j$:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case D$:t.blendFuncSeparate(t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ZERO,t.ONE);break;default:Ti("WebGLState: Invalid blending: ",Ne);break}else switch(Ne){case Ag:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case P$:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE);break;case j$:Ti("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case D$:Ti("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ti("WebGLState: Invalid blending: ",Ne);break}S=null,k=null,M=null,C=null,E.set(0,0,0),R=0,v=Ne,A=pt}return}Ue=Ue||rt,W=W||Ee,je=je||Ke,(rt!==y||Ue!==T)&&(t.blendEquationSeparate(pe[rt],pe[Ue]),y=rt,T=Ue),(Ee!==S||Ke!==k||W!==M||je!==C)&&(t.blendFuncSeparate(We[Ee],We[Ke],We[W],We[je]),S=Ee,k=Ke,M=W,C=je),(Ye.equals(E)===!1||bt!==R)&&(t.blendColor(Ye.r,Ye.g,Ye.b,bt),E.copy(Ye),R=bt),v=Ne,A=!1}function Y(Ne,rt){Ne.side===ic?Ce(t.CULL_FACE):de(t.CULL_FACE);let Ee=Ne.side===Is;rt&&(Ee=!Ee),ue(Ee),Ne.blending===Ag&&Ne.transparent===!1?G(Au):G(Ne.blending,Ne.blendEquation,Ne.blendSrc,Ne.blendDst,Ne.blendEquationAlpha,Ne.blendSrcAlpha,Ne.blendDstAlpha,Ne.blendColor,Ne.blendAlpha,Ne.premultipliedAlpha),o.setFunc(Ne.depthFunc),o.setTest(Ne.depthTest),o.setMask(Ne.depthWrite),a.setMask(Ne.colorWrite);const Ke=Ne.stencilWrite;l.setTest(Ke),Ke&&(l.setMask(Ne.stencilWriteMask),l.setFunc(Ne.stencilFunc,Ne.stencilRef,Ne.stencilFuncMask),l.setOp(Ne.stencilFail,Ne.stencilZFail,Ne.stencilZPass)),U(Ne.polygonOffset,Ne.polygonOffsetFactor,Ne.polygonOffsetUnits),Ne.alphaToCoverage===!0?de(t.SAMPLE_ALPHA_TO_COVERAGE):Ce(t.SAMPLE_ALPHA_TO_COVERAGE)}function ue(Ne){D!==Ne&&(Ne?t.frontFace(t.CW):t.frontFace(t.CCW),D=Ne)}function q(Ne){Ne!==kPe?(de(t.CULL_FACE),Ne!==I&&(Ne===C$?t.cullFace(t.BACK):Ne===EPe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):Ce(t.CULL_FACE),I=Ne}function te(Ne){Ne!==F&&(X&&t.lineWidth(Ne),F=Ne)}function U(Ne,rt,Ee){Ne?(de(t.POLYGON_OFFSET_FILL),(z!==rt||P!==Ee)&&(t.polygonOffset(rt,Ee),z=rt,P=Ee)):Ce(t.POLYGON_OFFSET_FILL)}function he(Ne){Ne?de(t.SCISSOR_TEST):Ce(t.SCISSOR_TEST)}function Me(Ne){Ne===void 0&&(Ne=t.TEXTURE0+$-1),Z!==Ne&&(t.activeTexture(Ne),Z=Ne)}function ge(Ne,rt,Ee){Ee===void 0&&(Z===null?Ee=t.TEXTURE0+$-1:Ee=Z);let Ke=se[Ee];Ke===void 0&&(Ke={type:void 0,texture:void 0},se[Ee]=Ke),(Ke.type!==Ne||Ke.texture!==rt)&&(Z!==Ee&&(t.activeTexture(Ee),Z=Ee),t.bindTexture(Ne,rt||me[Ne]),Ke.type=Ne,Ke.texture=rt)}function B(){const Ne=se[Z];Ne!==void 0&&Ne.type!==void 0&&(t.bindTexture(Ne.type,null),Ne.type=void 0,Ne.texture=void 0)}function O(){try{t.compressedTexImage2D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function ee(){try{t.compressedTexImage3D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function le(){try{t.texSubImage2D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function _e(){try{t.texSubImage3D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function ve(){try{t.compressedTexSubImage2D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function ae(){try{t.compressedTexSubImage3D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function Fe(){try{t.texStorage2D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function Be(){try{t.texStorage3D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function $e(){try{t.texImage2D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function He(){try{t.texImage3D(...arguments)}catch(Ne){Ne("WebGLState:",Ne)}}function xe(Ne){re.equals(Ne)===!1&&(t.scissor(Ne.x,Ne.y,Ne.z,Ne.w),re.copy(Ne))}function Pe(Ne){ne.equals(Ne)===!1&&(t.viewport(Ne.x,Ne.y,Ne.z,Ne.w),ne.copy(Ne))}function ze(Ne,rt){let Ee=u.get(rt);Ee===void 0&&(Ee=new WeakMap,u.set(rt,Ee));let Ke=Ee.get(Ne);Ke===void 0&&(Ke=t.getUniformBlockIndex(rt,Ne.name),Ee.set(Ne,Ke))}function we(Ne,rt){const Ke=u.get(rt).get(Ne);c.get(rt)!==Ke&&(t.uniformBlockBinding(rt,Ke,Ne.__bindingPointIndex),c.set(rt,Ke))}function Xe(){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={},Z=null,se={},f={},p=new WeakMap,m=[],x=null,b=!1,v=null,y=null,S=null,k=null,T=null,M=null,C=null,E=new Bn(0,0,0),R=0,A=!1,D=null,I=null,F=null,z=null,P=null,re.set(0,0,t.canvas.width,t.canvas.height),ne.set(0,0,t.canvas.width,t.canvas.height),a.reset(),o.reset(),l.reset()}return{buffers:{color:a,depth:o,stencil:l},enable:de,disable:Ce,bindFramebuffer:ie,drawBuffers:ke,useProgram:Oe,setBlending:G,setMaterial:Y,setFlipSided:ue,setCullFace:q,setLineWidth:te,setPolygonOffset:U,setScissorTest:he,activeTexture:Me,bindTexture:ge,unbindTexture:B,compressedTexImage2D:O,compressedTexImage3D:ee,texImage2D:$e,texImage3D:He,updateUBOMapping:ze,uniformBlockBinding:we,texStorage2D:Fe,texStorage3D:Be,texSubImage2D:le,texSubImage3D:_e,compressedTexSubImage2D:ve,compressedTexSubImage3D:ae,scissor:xe,viewport:Pe,reset:Xe}}function j4e(t,e,n,r,i,a,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 f;const p=new WeakMap;let m=!1;try{m=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(B,O){return m?new OffscreenCanvas(B,O):YS("canvas")}function b(B,O,ee){let le=1;const _e=ge(B);if((_e.width>ee||_e.height>ee)&&(le=ee/Math.max(_e.width,_e.height)),le<1)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap||typeof VideoFrame<"u"&&B instanceof VideoFrame){const ve=Math.floor(le*_e.width),ae=Math.floor(le*_e.height);f===void 0&&(f=x(ve,ae));const Fe=O?x(ve,ae):f;return Fe.width=ve,Fe.height=ae,Fe.getContext("2d").drawImage(B,0,0,ve,ae),xn("WebGLRenderer: Texture has been resized from ("+_e.width+"x"+_e.height+") to ("+ve+"x"+ae+")."),Fe}else return"data"in B&&xn("WebGLRenderer: Image in DataTexture is too big ("+_e.width+"x"+_e.height+")."),B;return B}function v(B){return B.generateMipmaps}function y(B){t.generateMipmap(B)}function S(B){return B.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:B.isWebGL3DRenderTarget?t.TEXTURE_3D:B.isWebGLArrayRenderTarget||B.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:t.TEXTURE_2D}function k(B,O,ee,le,_e=!1){if(B!==null){if(t[B]!==void 0)return t[B];xn("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let ve=O;if(O===t.RED&&(ee===t.FLOAT&&(ve=t.R32F),ee===t.HALF_FLOAT&&(ve=t.R16F),ee===t.UNSIGNED_BYTE&&(ve=t.R8)),O===t.RED_INTEGER&&(ee===t.UNSIGNED_BYTE&&(ve=t.R8UI),ee===t.UNSIGNED_SHORT&&(ve=t.R16UI),ee===t.UNSIGNED_INT&&(ve=t.R32UI),ee===t.BYTE&&(ve=t.R8I),ee===t.SHORT&&(ve=t.R16I),ee===t.INT&&(ve=t.R32I)),O===t.RG&&(ee===t.FLOAT&&(ve=t.RG32F),ee===t.HALF_FLOAT&&(ve=t.RG16F),ee===t.UNSIGNED_BYTE&&(ve=t.RG8)),O===t.RG_INTEGER&&(ee===t.UNSIGNED_BYTE&&(ve=t.RG8UI),ee===t.UNSIGNED_SHORT&&(ve=t.RG16UI),ee===t.UNSIGNED_INT&&(ve=t.RG32UI),ee===t.BYTE&&(ve=t.RG8I),ee===t.SHORT&&(ve=t.RG16I),ee===t.INT&&(ve=t.RG32I)),O===t.RGB_INTEGER&&(ee===t.UNSIGNED_BYTE&&(ve=t.RGB8UI),ee===t.UNSIGNED_SHORT&&(ve=t.RGB16UI),ee===t.UNSIGNED_INT&&(ve=t.RGB32UI),ee===t.BYTE&&(ve=t.RGB8I),ee===t.SHORT&&(ve=t.RGB16I),ee===t.INT&&(ve=t.RGB32I)),O===t.RGBA_INTEGER&&(ee===t.UNSIGNED_BYTE&&(ve=t.RGBA8UI),ee===t.UNSIGNED_SHORT&&(ve=t.RGBA16UI),ee===t.UNSIGNED_INT&&(ve=t.RGBA32UI),ee===t.BYTE&&(ve=t.RGBA8I),ee===t.SHORT&&(ve=t.RGBA16I),ee===t.INT&&(ve=t.RGBA32I)),O===t.RGB&&(ee===t.UNSIGNED_INT_5_9_9_9_REV&&(ve=t.RGB9_E5),ee===t.UNSIGNED_INT_10F_11F_11F_REV&&(ve=t.R11F_G11F_B10F)),O===t.RGBA){const ae=_e?KS:cr.getTransfer(le);ee===t.FLOAT&&(ve=t.RGBA32F),ee===t.HALF_FLOAT&&(ve=t.RGBA16F),ee===t.UNSIGNED_BYTE&&(ve=ae===Mr?t.SRGB8_ALPHA8:t.RGBA8),ee===t.UNSIGNED_SHORT_4_4_4_4&&(ve=t.RGBA4),ee===t.UNSIGNED_SHORT_5_5_5_1&&(ve=t.RGB5_A1)}return(ve===t.R16F||ve===t.R32F||ve===t.RG16F||ve===t.RG32F||ve===t.RGBA16F||ve===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ve}function T(B,O){let ee;return B?O===null||O===pm||O===hy?ee=t.DEPTH24_STENCIL8:O===_u?ee=t.DEPTH32F_STENCIL8:O===dy&&(ee=t.DEPTH24_STENCIL8,xn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):O===null||O===pm||O===hy?ee=t.DEPTH_COMPONENT24:O===_u?ee=t.DEPTH_COMPONENT32F:O===dy&&(ee=t.DEPTH_COMPONENT16),ee}function M(B,O){return v(B)===!0||B.isFramebufferTexture&&B.minFilter!==mo&&B.minFilter!==el?Math.log2(Math.max(O.width,O.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?O.mipmaps.length:1}function C(B){const O=B.target;O.removeEventListener("dispose",C),R(O),O.isVideoTexture&&d.delete(O)}function E(B){const O=B.target;O.removeEventListener("dispose",E),D(O)}function R(B){const O=r.get(B);if(O.__webglInit===void 0)return;const ee=B.source,le=p.get(ee);if(le){const _e=le[O.__cacheKey];_e.usedTimes--,_e.usedTimes===0&&A(B),Object.keys(le).length===0&&p.delete(ee)}r.remove(B)}function A(B){const O=r.get(B);t.deleteTexture(O.__webglTexture);const ee=B.source,le=p.get(ee);delete le[O.__cacheKey],o.memory.textures--}function D(B){const O=r.get(B);if(B.depthTexture&&(B.depthTexture.dispose(),r.remove(B.depthTexture)),B.isWebGLCubeRenderTarget)for(let le=0;le<6;le++){if(Array.isArray(O.__webglFramebuffer[le]))for(let _e=0;_e<O.__webglFramebuffer[le].length;_e++)t.deleteFramebuffer(O.__webglFramebuffer[le][_e]);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 ee=B.textures;for(let le=0,_e=ee.length;le<_e;le++){const ve=r.get(ee[le]);ve.__webglTexture&&(t.deleteTexture(ve.__webglTexture),o.memory.textures--),r.remove(ee[le])}r.remove(B)}let I=0;function F(){I=0}function z(){const B=I;return B>=i.maxTextures&&xn("WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+i.maxTextures),I+=1,B}function P(B){const O=[];return O.push(B.wrapS),O.push(B.wrapT),O.push(B.wrapR||0),O.push(B.magFilter),O.push(B.minFilter),O.push(B.anisotropy),O.push(B.internalFormat),O.push(B.format),O.push(B.type),O.push(B.generateMipmaps),O.push(B.premultiplyAlpha),O.push(B.flipY),O.push(B.unpackAlignment),O.push(B.colorSpace),O.join()}function $(B,O){const ee=r.get(B);if(B.isVideoTexture&&he(B),B.isRenderTargetTexture===!1&&B.isExternalTexture!==!0&&B.version>0&&ee.__version!==B.version){const le=B.image;if(le===null)xn("WebGLRenderer: Texture marked for update but no image data found.");else if(le.complete===!1)xn("WebGLRenderer: Texture marked for update but image is incomplete");else{me(ee,B,O);return}}else B.isExternalTexture&&(ee.__webglTexture=B.sourceTexture?B.sourceTexture:null);n.bindTexture(t.TEXTURE_2D,ee.__webglTexture,t.TEXTURE0+O)}function X(B,O){const ee=r.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&ee.__version!==B.version){me(ee,B,O);return}else B.isExternalTexture&&(ee.__webglTexture=B.sourceTexture?B.sourceTexture:null);n.bindTexture(t.TEXTURE_2D_ARRAY,ee.__webglTexture,t.TEXTURE0+O)}function V(B,O){const ee=r.get(B);if(B.isRenderTargetTexture===!1&&B.version>0&&ee.__version!==B.version){me(ee,B,O);return}n.bindTexture(t.TEXTURE_3D,ee.__webglTexture,t.TEXTURE0+O)}function Q(B,O){const ee=r.get(B);if(B.version>0&&ee.__version!==B.version){de(ee,B,O);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ee.__webglTexture,t.TEXTURE0+O)}const Z={[R3]:t.REPEAT,[wu]:t.CLAMP_TO_EDGE,[O3]:t.MIRRORED_REPEAT},se={[mo]:t.NEAREST,[nje]:t.NEAREST_MIPMAP_NEAREST,[Jw]:t.NEAREST_MIPMAP_LINEAR,[el]:t.LINEAR,[GA]:t.LINEAR_MIPMAP_NEAREST,[Of]:t.LINEAR_MIPMAP_LINEAR},H={[sje]:t.NEVER,[hje]:t.ALWAYS,[oje]:t.LESS,[cJ]:t.LEQUAL,[lje]:t.EQUAL,[dje]:t.GEQUAL,[cje]:t.GREATER,[uje]:t.NOTEQUAL};function K(B,O){if(O.type===_u&&e.has("OES_texture_float_linear")===!1&&(O.magFilter===el||O.magFilter===GA||O.magFilter===Jw||O.magFilter===Of||O.minFilter===el||O.minFilter===GA||O.minFilter===Jw||O.minFilter===Of)&&xn("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),t.texParameteri(B,t.TEXTURE_WRAP_S,Z[O.wrapS]),t.texParameteri(B,t.TEXTURE_WRAP_T,Z[O.wrapT]),(B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY)&&t.texParameteri(B,t.TEXTURE_WRAP_R,Z[O.wrapR]),t.texParameteri(B,t.TEXTURE_MAG_FILTER,se[O.magFilter]),t.texParameteri(B,t.TEXTURE_MIN_FILTER,se[O.minFilter]),O.compareFunction&&(t.texParameteri(B,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(B,t.TEXTURE_COMPARE_FUNC,H[O.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(O.magFilter===mo||O.minFilter!==Jw&&O.minFilter!==Of||O.type===_u&&e.has("OES_texture_float_linear")===!1)return;if(O.anisotropy>1||r.get(O).__currentAnisotropy){const ee=e.get("EXT_texture_filter_anisotropic");t.texParameterf(B,ee.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy}}}function re(B,O){let ee=!1;B.__webglInit===void 0&&(B.__webglInit=!0,O.addEventListener("dispose",C));const le=O.source;let _e=p.get(le);_e===void 0&&(_e={},p.set(le,_e));const ve=P(O);if(ve!==B.__cacheKey){_e[ve]===void 0&&(_e[ve]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,ee=!0),_e[ve].usedTimes++;const ae=_e[B.__cacheKey];ae!==void 0&&(_e[B.__cacheKey].usedTimes--,ae.usedTimes===0&&A(O)),B.__cacheKey=ve,B.__webglTexture=_e[ve].texture}return ee}function ne(B,O,ee){return Math.floor(Math.floor(B/ee)/O)}function be(B,O,ee,le){const ve=B.updateRanges;if(ve.length===0)n.texSubImage2D(t.TEXTURE_2D,0,0,0,O.width,O.height,ee,le,O.data);else{ve.sort((He,xe)=>He.start-xe.start);let ae=0;for(let He=1;He<ve.length;He++){const xe=ve[ae],Pe=ve[He],ze=xe.start+xe.count,we=ne(Pe.start,O.width,4),Xe=ne(xe.start,O.width,4);Pe.start<=ze+1&&we===Xe&&ne(Pe.start+Pe.count-1,O.width,4)===we?xe.count=Math.max(xe.count,Pe.start+Pe.count-xe.start):(++ae,ve[ae]=Pe)}ve.length=ae+1;const Fe=t.getParameter(t.UNPACK_ROW_LENGTH),Be=t.getParameter(t.UNPACK_SKIP_PIXELS),$e=t.getParameter(t.UNPACK_SKIP_ROWS);t.pixelStorei(t.UNPACK_ROW_LENGTH,O.width);for(let He=0,xe=ve.length;He<xe;He++){const Pe=ve[He],ze=Math.floor(Pe.start/4),we=Math.ceil(Pe.count/4),Xe=ze%O.width,Ne=Math.floor(ze/O.width),rt=we,Ee=1;t.pixelStorei(t.UNPACK_SKIP_PIXELS,Xe),t.pixelStorei(t.UNPACK_SKIP_ROWS,Ne),n.texSubImage2D(t.TEXTURE_2D,0,Xe,Ne,rt,Ee,ee,le,O.data)}B.clearUpdateRanges(),t.pixelStorei(t.UNPACK_ROW_LENGTH,Fe),t.pixelStorei(t.UNPACK_SKIP_PIXELS,Be),t.pixelStorei(t.UNPACK_SKIP_ROWS,$e)}}function me(B,O,ee){let le=t.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(le=t.TEXTURE_2D_ARRAY),O.isData3DTexture&&(le=t.TEXTURE_3D);const _e=re(B,O),ve=O.source;n.bindTexture(le,B.__webglTexture,t.TEXTURE0+ee);const ae=r.get(ve);if(ve.version!==ae.__version||_e===!0){n.activeTexture(t.TEXTURE0+ee);const Fe=cr.getPrimaries(cr.workingColorSpace),Be=O.colorSpace===Kd?null:cr.getPrimaries(O.colorSpace),$e=O.colorSpace===Kd||Fe===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,$e);let He=b(O.image,!1,i.maxTextureSize);He=Me(O,He);const xe=a.convert(O.format,O.colorSpace),Pe=a.convert(O.type);let ze=k(O.internalFormat,xe,Pe,O.colorSpace,O.isVideoTexture);K(le,O);let we;const Xe=O.mipmaps,Ne=O.isVideoTexture!==!0,rt=ae.__version===void 0||_e===!0,Ee=ve.dataReady,Ke=M(O,He);if(O.isDepthTexture)ze=T(O.format===my,O.type),rt&&(Ne?n.texStorage2D(t.TEXTURE_2D,1,ze,He.width,He.height):n.texImage2D(t.TEXTURE_2D,0,ze,He.width,He.height,0,xe,Pe,null));else if(O.isDataTexture)if(Xe.length>0){Ne&&rt&&n.texStorage2D(t.TEXTURE_2D,Ke,ze,Xe[0].width,Xe[0].height);for(let Ue=0,W=Xe.length;Ue<W;Ue++)we=Xe[Ue],Ne?Ee&&n.texSubImage2D(t.TEXTURE_2D,Ue,0,0,we.width,we.height,xe,Pe,we.data):n.texImage2D(t.TEXTURE_2D,Ue,ze,we.width,we.height,0,xe,Pe,we.data);O.generateMipmaps=!1}else Ne?(rt&&n.texStorage2D(t.TEXTURE_2D,Ke,ze,He.width,He.height),Ee&&be(O,He,xe,Pe)):n.texImage2D(t.TEXTURE_2D,0,ze,He.width,He.height,0,xe,Pe,He.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Ne&&rt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ke,ze,Xe[0].width,Xe[0].height,He.depth);for(let Ue=0,W=Xe.length;Ue<W;Ue++)if(we=Xe[Ue],O.format!==jl)if(xe!==null)if(Ne){if(Ee)if(O.layerUpdates.size>0){const je=cV(we.width,we.height,O.format,O.type);for(const Ye of O.layerUpdates){const bt=we.data.subarray(Ye*je/we.data.BYTES_PER_ELEMENT,(Ye+1)*je/we.data.BYTES_PER_ELEMENT);n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ue,0,0,Ye,we.width,we.height,1,xe,bt)}O.clearLayerUpdates()}else n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,Ue,0,0,0,we.width,we.height,He.depth,xe,we.data)}else n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,Ue,ze,we.width,we.height,He.depth,0,we.data,0,0);else xn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ne?Ee&&n.texSubImage3D(t.TEXTURE_2D_ARRAY,Ue,0,0,0,we.width,we.height,He.depth,xe,Pe,we.data):n.texImage3D(t.TEXTURE_2D_ARRAY,Ue,ze,we.width,we.height,He.depth,0,xe,Pe,we.data)}else{Ne&&rt&&n.texStorage2D(t.TEXTURE_2D,Ke,ze,Xe[0].width,Xe[0].height);for(let Ue=0,W=Xe.length;Ue<W;Ue++)we=Xe[Ue],O.format!==jl?xe!==null?Ne?Ee&&n.compressedTexSubImage2D(t.TEXTURE_2D,Ue,0,0,we.width,we.height,xe,we.data):n.compressedTexImage2D(t.TEXTURE_2D,Ue,ze,we.width,we.height,0,we.data):xn("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ne?Ee&&n.texSubImage2D(t.TEXTURE_2D,Ue,0,0,we.width,we.height,xe,Pe,we.data):n.texImage2D(t.TEXTURE_2D,Ue,ze,we.width,we.height,0,xe,Pe,we.data)}else if(O.isDataArrayTexture)if(Ne){if(rt&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ke,ze,He.width,He.height,He.depth),Ee)if(O.layerUpdates.size>0){const Ue=cV(He.width,He.height,O.format,O.type);for(const W of O.layerUpdates){const je=He.data.subarray(W*Ue/He.data.BYTES_PER_ELEMENT,(W+1)*Ue/He.data.BYTES_PER_ELEMENT);n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,W,He.width,He.height,1,xe,Pe,je)}O.clearLayerUpdates()}else n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,He.width,He.height,He.depth,xe,Pe,He.data)}else n.texImage3D(t.TEXTURE_2D_ARRAY,0,ze,He.width,He.height,He.depth,0,xe,Pe,He.data);else if(O.isData3DTexture)Ne?(rt&&n.texStorage3D(t.TEXTURE_3D,Ke,ze,He.width,He.height,He.depth),Ee&&n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,He.width,He.height,He.depth,xe,Pe,He.data)):n.texImage3D(t.TEXTURE_3D,0,ze,He.width,He.height,He.depth,0,xe,Pe,He.data);else if(O.isFramebufferTexture){if(rt)if(Ne)n.texStorage2D(t.TEXTURE_2D,Ke,ze,He.width,He.height);else{let Ue=He.width,W=He.height;for(let je=0;je<Ke;je++)n.texImage2D(t.TEXTURE_2D,je,ze,Ue,W,0,xe,Pe,null),Ue>>=1,W>>=1}}else if(Xe.length>0){if(Ne&&rt){const Ue=ge(Xe[0]);n.texStorage2D(t.TEXTURE_2D,Ke,ze,Ue.width,Ue.height)}for(let Ue=0,W=Xe.length;Ue<W;Ue++)we=Xe[Ue],Ne?Ee&&n.texSubImage2D(t.TEXTURE_2D,Ue,0,0,xe,Pe,we):n.texImage2D(t.TEXTURE_2D,Ue,ze,xe,Pe,we);O.generateMipmaps=!1}else if(Ne){if(rt){const Ue=ge(He);n.texStorage2D(t.TEXTURE_2D,Ke,ze,Ue.width,Ue.height)}Ee&&n.texSubImage2D(t.TEXTURE_2D,0,0,0,xe,Pe,He)}else n.texImage2D(t.TEXTURE_2D,0,ze,xe,Pe,He);v(O)&&y(le),ae.__version=ve.version,O.onUpdate&&O.onUpdate(O)}B.__version=O.version}function de(B,O,ee){if(O.image.length!==6)return;const le=re(B,O),_e=O.source;n.bindTexture(t.TEXTURE_CUBE_MAP,B.__webglTexture,t.TEXTURE0+ee);const ve=r.get(_e);if(_e.version!==ve.__version||le===!0){n.activeTexture(t.TEXTURE0+ee);const ae=cr.getPrimaries(cr.workingColorSpace),Fe=O.colorSpace===Kd?null:cr.getPrimaries(O.colorSpace),Be=O.colorSpace===Kd||ae===Fe?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 $e=O.isCompressedTexture||O.image[0].isCompressedTexture,He=O.image[0]&&O.image[0].isDataTexture,xe=[];for(let W=0;W<6;W++)!$e&&!He?xe[W]=b(O.image[W],!0,i.maxCubemapSize):xe[W]=He?O.image[W].image:O.image[W],xe[W]=Me(O,xe[W]);const Pe=xe[0],ze=a.convert(O.format,O.colorSpace),we=a.convert(O.type),Xe=k(O.internalFormat,ze,we,O.colorSpace),Ne=O.isVideoTexture!==!0,rt=ve.__version===void 0||le===!0,Ee=_e.dataReady;let Ke=M(O,Pe);K(t.TEXTURE_CUBE_MAP,O);let Ue;if($e){Ne&&rt&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ke,Xe,Pe.width,Pe.height);for(let W=0;W<6;W++){Ue=xe[W].mipmaps;for(let je=0;je<Ue.length;je++){const Ye=Ue[je];O.format!==jl?ze!==null?Ne?Ee&&n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,je,0,0,Ye.width,Ye.height,ze,Ye.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,je,Xe,Ye.width,Ye.height,0,Ye.data):xn("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):Ne?Ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,je,0,0,Ye.width,Ye.height,ze,we,Ye.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,je,Xe,Ye.width,Ye.height,0,ze,we,Ye.data)}}}else{if(Ue=O.mipmaps,Ne&&rt){Ue.length>0&&Ke++;const W=ge(xe[0]);n.texStorage2D(t.TEXTURE_CUBE_MAP,Ke,Xe,W.width,W.height)}for(let W=0;W<6;W++)if(He){Ne?Ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,xe[W].width,xe[W].height,ze,we,xe[W].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,Xe,xe[W].width,xe[W].height,0,ze,we,xe[W].data);for(let je=0;je<Ue.length;je++){const bt=Ue[je].image[W].image;Ne?Ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,je+1,0,0,bt.width,bt.height,ze,we,bt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,je+1,Xe,bt.width,bt.height,0,ze,we,bt.data)}}else{Ne?Ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,ze,we,xe[W]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,Xe,ze,we,xe[W]);for(let je=0;je<Ue.length;je++){const Ye=Ue[je];Ne?Ee&&n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,je+1,0,0,ze,we,Ye.image[W]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,je+1,Xe,ze,we,Ye.image[W])}}}v(O)&&y(t.TEXTURE_CUBE_MAP),ve.__version=_e.version,O.onUpdate&&O.onUpdate(O)}B.__version=O.version}function Ce(B,O,ee,le,_e,ve){const ae=a.convert(ee.format,ee.colorSpace),Fe=a.convert(ee.type),Be=k(ee.internalFormat,ae,Fe,ee.colorSpace),$e=r.get(O),He=r.get(ee);if(He.__renderTarget=O,!$e.__hasExternalTextures){const xe=Math.max(1,O.width>>ve),Pe=Math.max(1,O.height>>ve);_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?n.texImage3D(_e,ve,Be,xe,Pe,O.depth,0,ae,Fe,null):n.texImage2D(_e,ve,Be,xe,Pe,0,ae,Fe,null)}n.bindFramebuffer(t.FRAMEBUFFER,B),U(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,le,_e,He.__webglTexture,0,te(O)):(_e===t.TEXTURE_2D||_e>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,le,_e,He.__webglTexture,ve),n.bindFramebuffer(t.FRAMEBUFFER,null)}function ie(B,O,ee){if(t.bindRenderbuffer(t.RENDERBUFFER,B),O.depthBuffer){const le=O.depthTexture,_e=le&&le.isDepthTexture?le.type:null,ve=T(O.stencilBuffer,_e),ae=O.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Fe=te(O);U(O)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,Fe,ve,O.width,O.height):ee?t.renderbufferStorageMultisample(t.RENDERBUFFER,Fe,ve,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,ve,O.width,O.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,ae,t.RENDERBUFFER,B)}else{const le=O.textures;for(let _e=0;_e<le.length;_e++){const ve=le[_e],ae=a.convert(ve.format,ve.colorSpace),Fe=a.convert(ve.type),Be=k(ve.internalFormat,ae,Fe,ve.colorSpace),$e=te(O);ee&&U(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,$e,Be,O.width,O.height):U(O)?l.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,$e,Be,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,Be,O.width,O.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function ke(B,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,B),!(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),$(O.depthTexture,0);const _e=le.__webglTexture,ve=te(O);if(O.depthTexture.format===fy)U(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,_e,0,ve):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,_e,0);else if(O.depthTexture.format===my)U(O)?l.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,_e,0,ve):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,_e,0);else throw new Error("Unknown depthTexture format")}function Oe(B){const O=r.get(B),ee=B.isWebGLCubeRenderTarget===!0;if(O.__boundDepthTexture!==B.depthTexture){const le=B.depthTexture;if(O.__depthDisposeCallback&&O.__depthDisposeCallback(),le){const _e=()=>{delete O.__boundDepthTexture,delete O.__depthDisposeCallback,le.removeEventListener("dispose",_e)};le.addEventListener("dispose",_e),O.__depthDisposeCallback=_e}O.__boundDepthTexture=le}if(B.depthTexture&&!O.__autoAllocateDepthBuffer){if(ee)throw new Error("target.depthTexture not supported in Cube render targets");const le=B.texture.mipmaps;le&&le.length>0?ke(O.__webglFramebuffer[0],B):ke(O.__webglFramebuffer,B)}else if(ee){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],B,!1);else{const _e=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ve=O.__webglDepthbuffer[le];t.bindRenderbuffer(t.RENDERBUFFER,ve),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,ve)}}else{const le=B.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,B,!1);else{const _e=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ve=O.__webglDepthbuffer;t.bindRenderbuffer(t.RENDERBUFFER,ve),t.framebufferRenderbuffer(t.FRAMEBUFFER,_e,t.RENDERBUFFER,ve)}}n.bindFramebuffer(t.FRAMEBUFFER,null)}function pe(B,O,ee){const le=r.get(B);O!==void 0&&Ce(le.__webglFramebuffer,B,B.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ee!==void 0&&Oe(B)}function We(B){const O=B.texture,ee=r.get(B),le=r.get(O);B.addEventListener("dispose",E);const _e=B.textures,ve=B.isWebGLCubeRenderTarget===!0,ae=_e.length>1;if(ae||(le.__webglTexture===void 0&&(le.__webglTexture=t.createTexture()),le.__version=O.version,o.memory.textures++),ve){ee.__webglFramebuffer=[];for(let Fe=0;Fe<6;Fe++)if(O.mipmaps&&O.mipmaps.length>0){ee.__webglFramebuffer[Fe]=[];for(let Be=0;Be<O.mipmaps.length;Be++)ee.__webglFramebuffer[Fe][Be]=t.createFramebuffer()}else ee.__webglFramebuffer[Fe]=t.createFramebuffer()}else{if(O.mipmaps&&O.mipmaps.length>0){ee.__webglFramebuffer=[];for(let Fe=0;Fe<O.mipmaps.length;Fe++)ee.__webglFramebuffer[Fe]=t.createFramebuffer()}else ee.__webglFramebuffer=t.createFramebuffer();if(ae)for(let Fe=0,Be=_e.length;Fe<Be;Fe++){const $e=r.get(_e[Fe]);$e.__webglTexture===void 0&&($e.__webglTexture=t.createTexture(),o.memory.textures++)}if(B.samples>0&&U(B)===!1){ee.__webglMultisampledFramebuffer=t.createFramebuffer(),ee.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ee.__webglMultisampledFramebuffer);for(let Fe=0;Fe<_e.length;Fe++){const Be=_e[Fe];ee.__webglColorRenderbuffer[Fe]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ee.__webglColorRenderbuffer[Fe]);const $e=a.convert(Be.format,Be.colorSpace),He=a.convert(Be.type),xe=k(Be.internalFormat,$e,He,Be.colorSpace,B.isXRRenderTarget===!0),Pe=te(B);t.renderbufferStorageMultisample(t.RENDERBUFFER,Pe,xe,B.width,B.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Fe,t.RENDERBUFFER,ee.__webglColorRenderbuffer[Fe])}t.bindRenderbuffer(t.RENDERBUFFER,null),B.depthBuffer&&(ee.__webglDepthRenderbuffer=t.createRenderbuffer(),ie(ee.__webglDepthRenderbuffer,B,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(ve){n.bindTexture(t.TEXTURE_CUBE_MAP,le.__webglTexture),K(t.TEXTURE_CUBE_MAP,O);for(let Fe=0;Fe<6;Fe++)if(O.mipmaps&&O.mipmaps.length>0)for(let Be=0;Be<O.mipmaps.length;Be++)Ce(ee.__webglFramebuffer[Fe][Be],B,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Fe,Be);else Ce(ee.__webglFramebuffer[Fe],B,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Fe,0);v(O)&&y(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ae){for(let Fe=0,Be=_e.length;Fe<Be;Fe++){const $e=_e[Fe],He=r.get($e);let xe=t.TEXTURE_2D;(B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(xe=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(xe,He.__webglTexture),K(xe,$e),Ce(ee.__webglFramebuffer,B,$e,t.COLOR_ATTACHMENT0+Fe,xe,0),v($e)&&y(xe)}n.unbindTexture()}else{let Fe=t.TEXTURE_2D;if((B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(Fe=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY),n.bindTexture(Fe,le.__webglTexture),K(Fe,O),O.mipmaps&&O.mipmaps.length>0)for(let Be=0;Be<O.mipmaps.length;Be++)Ce(ee.__webglFramebuffer[Be],B,O,t.COLOR_ATTACHMENT0,Fe,Be);else Ce(ee.__webglFramebuffer,B,O,t.COLOR_ATTACHMENT0,Fe,0);v(O)&&y(Fe),n.unbindTexture()}B.depthBuffer&&Oe(B)}function G(B){const O=B.textures;for(let ee=0,le=O.length;ee<le;ee++){const _e=O[ee];if(v(_e)){const ve=S(B),ae=r.get(_e).__webglTexture;n.bindTexture(ve,ae),y(ve),n.unbindTexture()}}}const Y=[],ue=[];function q(B){if(B.samples>0){if(U(B)===!1){const O=B.textures,ee=B.width,le=B.height;let _e=t.COLOR_BUFFER_BIT;const ve=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,ae=r.get(B),Fe=O.length>1;if(Fe)for(let $e=0;$e<O.length;$e++)n.bindFramebuffer(t.FRAMEBUFFER,ae.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+$e,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,ae.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+$e,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,ae.__webglMultisampledFramebuffer);const Be=B.texture.mipmaps;Be&&Be.length>0?n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ae.__webglFramebuffer[0]):n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ae.__webglFramebuffer);for(let $e=0;$e<O.length;$e++){if(B.resolveDepthBuffer&&(B.depthBuffer&&(_e|=t.DEPTH_BUFFER_BIT),B.stencilBuffer&&B.resolveStencilBuffer&&(_e|=t.STENCIL_BUFFER_BIT)),Fe){t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,ae.__webglColorRenderbuffer[$e]);const He=r.get(O[$e]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,He,0)}t.blitFramebuffer(0,0,ee,le,0,0,ee,le,_e,t.NEAREST),c===!0&&(Y.length=0,ue.length=0,Y.push(t.COLOR_ATTACHMENT0+$e),B.depthBuffer&&B.resolveDepthBuffer===!1&&(Y.push(ve),ue.push(ve),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,ue)),t.invalidateFramebuffer(t.READ_FRAMEBUFFER,Y))}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Fe)for(let $e=0;$e<O.length;$e++){n.bindFramebuffer(t.FRAMEBUFFER,ae.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+$e,t.RENDERBUFFER,ae.__webglColorRenderbuffer[$e]);const He=r.get(O[$e]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,ae.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+$e,t.TEXTURE_2D,He,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,ae.__webglMultisampledFramebuffer)}else if(B.depthBuffer&&B.resolveDepthBuffer===!1&&c){const O=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[O])}}}function te(B){return Math.min(i.maxSamples,B.samples)}function U(B){const O=r.get(B);return B.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function he(B){const O=o.render.frame;d.get(B)!==O&&(d.set(B,O),B.update())}function Me(B,O){const ee=B.colorSpace,le=B.format,_e=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||ee!==ex&&ee!==Kd&&(cr.getTransfer(ee)===Mr?(le!==jl||_e!==vc)&&xn("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ti("WebGLTextures: Unsupported texture color space:",ee)),O}function ge(B){return typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement?(u.width=B.naturalWidth||B.width,u.height=B.naturalHeight||B.height):typeof VideoFrame<"u"&&B instanceof VideoFrame?(u.width=B.displayWidth,u.height=B.displayHeight):(u.width=B.width,u.height=B.height),u}this.allocateTextureUnit=z,this.resetTextureUnits=F,this.setTexture2D=$,this.setTexture2DArray=X,this.setTexture3D=V,this.setTextureCube=Q,this.rebindTextures=pe,this.setupRenderTarget=We,this.updateRenderTargetMipmap=G,this.updateMultisampleRenderTarget=q,this.setupDepthRenderbuffer=Oe,this.setupFrameBufferTexture=Ce,this.useMultisampledRTT=U}function D4e(t,e){function n(r,i=Kd){let a;const o=cr.getTransfer(i);if(r===vc)return t.UNSIGNED_BYTE;if(r===V4)return t.UNSIGNED_SHORT_4_4_4_4;if(r===G4)return t.UNSIGNED_SHORT_5_5_5_1;if(r===rJ)return t.UNSIGNED_INT_5_9_9_9_REV;if(r===iJ)return t.UNSIGNED_INT_10F_11F_11F_REV;if(r===tJ)return t.BYTE;if(r===nJ)return t.SHORT;if(r===dy)return t.UNSIGNED_SHORT;if(r===$4)return t.INT;if(r===pm)return t.UNSIGNED_INT;if(r===_u)return t.FLOAT;if(r===Cx)return t.HALF_FLOAT;if(r===aJ)return t.ALPHA;if(r===sJ)return t.RGB;if(r===jl)return t.RGBA;if(r===fy)return t.DEPTH_COMPONENT;if(r===my)return t.DEPTH_STENCIL;if(r===oJ)return t.RED;if(r===q4)return t.RED_INTEGER;if(r===W4)return t.RG;if(r===K4)return t.RG_INTEGER;if(r===X4)return t.RGBA_INTEGER;if(r===M1||r===k1||r===E1||r===T1)if(o===Mr)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===M1)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===k1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===E1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===T1)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===M1)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===k1)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===E1)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===T1)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===L3||r===F3||r===I3||r===U3)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===L3)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===F3)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===I3)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===U3)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===z3||r===B3||r===H3)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===z3||r===B3)return o===Mr?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===H3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===$3||r===V3||r===G3||r===q3||r===W3||r===K3||r===X3||r===Y3||r===Q3||r===Z3||r===J3||r===eD||r===tD||r===nD)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===$3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===V3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===G3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===q3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===W3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===K3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===X3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===Y3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===Q3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===Z3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===J3)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===eD)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===tD)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===nD)return o===Mr?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===rD||r===iD||r===aD)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===rD)return o===Mr?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===iD)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===aD)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===sD||r===oD||r===lD||r===cD)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===sD)return a.COMPRESSED_RED_RGTC1_EXT;if(r===oD)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===lD)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===cD)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===hy?t.UNSIGNED_INT_24_8:t[r]!==void 0?t[r]:null}return{convert:n}}const R4e=`
- void main() {
- gl_Position = vec4( position, 1.0 );
- }`,O4e=`
- uniform sampler2DArray depthColor;
- uniform float depthWidth;
- uniform float depthHeight;
- void main() {
- vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
- if ( coord.x >= 1.0 ) {
- gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
- } else {
- gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
- }
- }`;class L4e{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,n){if(this.texture===null){const r=new TJ(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 $u({vertexShader:R4e,fragmentShader:O4e,uniforms:{depthColor:{value:this.texture},depthWidth:{value:n.z},depthHeight:{value:n.w}}});this.mesh=new wc(new tL(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}let F4e=class extends Cm{constructor(e,n){super();const r=this;let i=null,a=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,p=null,m=null,x=null;const b=typeof XRWebGLBinding<"u",v=new L4e,y={},S=n.getContextAttributes();let k=null,T=null;const M=[],C=[],E=new Cn;let R=null;const A=new Wo;A.viewport=new zi;const D=new Wo;D.viewport=new zi;const I=[A,D],F=new e3e;let z=null,P=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(me){let de=M[me];return de===void 0&&(de=new fC,M[me]=de),de.getTargetRaySpace()},this.getControllerGrip=function(me){let de=M[me];return de===void 0&&(de=new fC,M[me]=de),de.getGripSpace()},this.getHand=function(me){let de=M[me];return de===void 0&&(de=new fC,M[me]=de),de.getHandSpace()};function $(me){const de=C.indexOf(me.inputSource);if(de===-1)return;const Ce=M[de];Ce!==void 0&&(Ce.update(me.inputSource,me.frame,u||o),Ce.dispatchEvent({type:me.type,data:me.inputSource}))}function X(){i.removeEventListener("select",$),i.removeEventListener("selectstart",$),i.removeEventListener("selectend",$),i.removeEventListener("squeeze",$),i.removeEventListener("squeezestart",$),i.removeEventListener("squeezeend",$),i.removeEventListener("end",X),i.removeEventListener("inputsourceschange",V);for(let me=0;me<M.length;me++){const de=C[me];de!==null&&(C[me]=null,M[me].disconnect(de))}z=null,P=null,v.reset();for(const me in y)delete y[me];e.setRenderTarget(k),m=null,p=null,f=null,i=null,T=null,be.stop(),r.isPresenting=!1,e.setPixelRatio(R),e.setSize(E.width,E.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(me){a=me,r.isPresenting===!0&&xn("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(me){l=me,r.isPresenting===!0&&xn("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 f===null&&b&&(f=new XRWebGLBinding(i,n)),f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(me){if(i=me,i!==null){if(k=e.getRenderTarget(),i.addEventListener("select",$),i.addEventListener("selectstart",$),i.addEventListener("selectend",$),i.addEventListener("squeeze",$),i.addEventListener("squeezestart",$),i.addEventListener("squeezeend",$),i.addEventListener("end",X),i.addEventListener("inputsourceschange",V),S.xrCompatible!==!0&&await n.makeXRCompatible(),R=e.getPixelRatio(),e.getSize(E),b&&"createProjectionLayer"in XRWebGLBinding.prototype){let Ce=null,ie=null,ke=null;S.depth&&(ke=S.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,Ce=S.stencil?my:fy,ie=S.stencil?hy:pm);const Oe={colorFormat:n.RGBA8,depthFormat:ke,scaleFactor:a};f=this.getBinding(),p=f.createProjectionLayer(Oe),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),T=new xm(p.textureWidth,p.textureHeight,{format:jl,type:vc,depthTexture:new EJ(p.textureWidth,p.textureHeight,ie,void 0,void 0,void 0,void 0,void 0,void 0,Ce),stencilBuffer:S.stencil,colorSpace:e.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}else{const Ce={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(i,n,Ce),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),T=new xm(m.framebufferWidth,m.framebufferHeight,{format:jl,type:vc,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),be.setContext(i),be.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return v.getDepthTexture()};function V(me){for(let de=0;de<me.removed.length;de++){const Ce=me.removed[de],ie=C.indexOf(Ce);ie>=0&&(C[ie]=null,M[ie].disconnect(Ce))}for(let de=0;de<me.added.length;de++){const Ce=me.added[de];let ie=C.indexOf(Ce);if(ie===-1){for(let Oe=0;Oe<M.length;Oe++)if(Oe>=C.length){C.push(Ce),ie=Oe;break}else if(C[Oe]===null){C[Oe]=Ce,ie=Oe;break}if(ie===-1)break}const ke=M[ie];ke&&ke.connect(Ce)}}const Q=new ht,Z=new ht;function se(me,de,Ce){Q.setFromMatrixPosition(de.matrixWorld),Z.setFromMatrixPosition(Ce.matrixWorld);const ie=Q.distanceTo(Z),ke=de.projectionMatrix.elements,Oe=Ce.projectionMatrix.elements,pe=ke[14]/(ke[10]-1),We=ke[14]/(ke[10]+1),G=(ke[9]+1)/ke[5],Y=(ke[9]-1)/ke[5],ue=(ke[8]-1)/ke[0],q=(Oe[8]+1)/Oe[0],te=pe*ue,U=pe*q,he=ie/(-ue+q),Me=he*-ue;if(de.matrixWorld.decompose(me.position,me.quaternion,me.scale),me.translateX(Me),me.translateZ(he),me.matrixWorld.compose(me.position,me.quaternion,me.scale),me.matrixWorldInverse.copy(me.matrixWorld).invert(),ke[10]===-1)me.projectionMatrix.copy(de.projectionMatrix),me.projectionMatrixInverse.copy(de.projectionMatrixInverse);else{const ge=pe+he,B=We+he,O=te-Me,ee=U+(ie-Me),le=G*We/B*ge,_e=Y*We/B*ge;me.projectionMatrix.makePerspective(O,ee,le,_e,ge,B),me.projectionMatrixInverse.copy(me.projectionMatrix).invert()}}function H(me,de){de===null?me.matrixWorld.copy(me.matrix):me.matrixWorld.multiplyMatrices(de.matrixWorld,me.matrix),me.matrixWorldInverse.copy(me.matrixWorld).invert()}this.updateCamera=function(me){if(i===null)return;let de=me.near,Ce=me.far;v.texture!==null&&(v.depthNear>0&&(de=v.depthNear),v.depthFar>0&&(Ce=v.depthFar)),F.near=D.near=A.near=de,F.far=D.far=A.far=Ce,(z!==F.near||P!==F.far)&&(i.updateRenderState({depthNear:F.near,depthFar:F.far}),z=F.near,P=F.far),F.layers.mask=me.layers.mask|6,A.layers.mask=F.layers.mask&3,D.layers.mask=F.layers.mask&5;const ie=me.parent,ke=F.cameras;H(F,ie);for(let Oe=0;Oe<ke.length;Oe++)H(ke[Oe],ie);ke.length===2?se(F,A,D):F.projectionMatrix.copy(A.projectionMatrix),K(me,F,ie)};function K(me,de,Ce){Ce===null?me.matrix.copy(de.matrixWorld):(me.matrix.copy(Ce.matrixWorld),me.matrix.invert(),me.matrix.multiply(de.matrixWorld)),me.matrix.decompose(me.position,me.quaternion,me.scale),me.updateMatrixWorld(!0),me.projectionMatrix.copy(de.projectionMatrix),me.projectionMatrixInverse.copy(de.projectionMatrixInverse),me.isPerspectiveCamera&&(me.fov=uD*2*Math.atan(1/me.projectionMatrix.elements[5]),me.zoom=1)}this.getCamera=function(){return F},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(F)},this.getCameraTexture=function(me){return y[me]};let re=null;function ne(me,de){if(d=de.getViewerPose(u||o),x=de,d!==null){const Ce=d.views;m!==null&&(e.setRenderTargetFramebuffer(T,m.framebuffer),e.setRenderTarget(T));let ie=!1;Ce.length!==F.cameras.length&&(F.cameras.length=0,ie=!0);for(let We=0;We<Ce.length;We++){const G=Ce[We];let Y=null;if(m!==null)Y=m.getViewport(G);else{const q=f.getViewSubImage(p,G);Y=q.viewport,We===0&&(e.setRenderTargetTextures(T,q.colorTexture,q.depthStencilTexture),e.setRenderTarget(T))}let ue=I[We];ue===void 0&&(ue=new Wo,ue.layers.enable(We),ue.viewport=new zi,I[We]=ue),ue.matrix.fromArray(G.transform.matrix),ue.matrix.decompose(ue.position,ue.quaternion,ue.scale),ue.projectionMatrix.fromArray(G.projectionMatrix),ue.projectionMatrixInverse.copy(ue.projectionMatrix).invert(),ue.viewport.set(Y.x,Y.y,Y.width,Y.height),We===0&&(F.matrix.copy(ue.matrix),F.matrix.decompose(F.position,F.quaternion,F.scale)),ie===!0&&F.cameras.push(ue)}const ke=i.enabledFeatures;if(ke&&ke.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&b){f=r.getBinding();const We=f.getDepthInformation(Ce[0]);We&&We.isValid&&We.texture&&v.init(We,i.renderState)}if(ke&&ke.includes("camera-access")&&b){e.state.unbindTexture(),f=r.getBinding();for(let We=0;We<Ce.length;We++){const G=Ce[We].camera;if(G){let Y=y[G];Y||(Y=new TJ,y[G]=Y);const ue=f.getCameraImage(G);Y.sourceTexture=ue}}}}for(let Ce=0;Ce<M.length;Ce++){const ie=C[Ce],ke=M[Ce];ie!==null&&ke!==void 0&&ke.update(ie,de,u||o)}re&&re(me,de),de.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:de}),x=null}const be=new jJ;be.setAnimationLoop(ne),this.setAnimationLoop=function(me){re=me},this.dispose=function(){}}};const hf=new Eh,I4e=new Gi;function U4e(t,e){function n(v,y){v.matrixAutoUpdate===!0&&v.updateMatrix(),y.value.copy(v.matrix)}function r(v,y){y.color.getRGB(v.fogColor.value,SJ(t)),y.isFog?(v.fogNear.value=y.near,v.fogFar.value=y.far):y.isFogExp2&&(v.fogDensity.value=y.density)}function i(v,y,S,k,T){y.isMeshBasicMaterial||y.isMeshLambertMaterial?a(v,y):y.isMeshToonMaterial?(a(v,y),f(v,y)):y.isMeshPhongMaterial?(a(v,y),d(v,y)):y.isMeshStandardMaterial?(a(v,y),p(v,y),y.isMeshPhysicalMaterial&&m(v,y,T)):y.isMeshMatcapMaterial?(a(v,y),x(v,y)):y.isMeshDepthMaterial?a(v,y):y.isMeshDistanceMaterial?(a(v,y),b(v,y)):y.isMeshNormalMaterial?a(v,y):y.isLineBasicMaterial?(o(v,y),y.isLineDashedMaterial&&l(v,y)):y.isPointsMaterial?c(v,y,S,k):y.isSpriteMaterial?u(v,y):y.isShadowMaterial?(v.color.value.copy(y.color),v.opacity.value=y.opacity):y.isShaderMaterial&&(y.uniformsNeedUpdate=!1)}function a(v,y){v.opacity.value=y.opacity,y.color&&v.diffuse.value.copy(y.color),y.emissive&&v.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity),y.map&&(v.map.value=y.map,n(y.map,v.mapTransform)),y.alphaMap&&(v.alphaMap.value=y.alphaMap,n(y.alphaMap,v.alphaMapTransform)),y.bumpMap&&(v.bumpMap.value=y.bumpMap,n(y.bumpMap,v.bumpMapTransform),v.bumpScale.value=y.bumpScale,y.side===Is&&(v.bumpScale.value*=-1)),y.normalMap&&(v.normalMap.value=y.normalMap,n(y.normalMap,v.normalMapTransform),v.normalScale.value.copy(y.normalScale),y.side===Is&&v.normalScale.value.negate()),y.displacementMap&&(v.displacementMap.value=y.displacementMap,n(y.displacementMap,v.displacementMapTransform),v.displacementScale.value=y.displacementScale,v.displacementBias.value=y.displacementBias),y.emissiveMap&&(v.emissiveMap.value=y.emissiveMap,n(y.emissiveMap,v.emissiveMapTransform)),y.specularMap&&(v.specularMap.value=y.specularMap,n(y.specularMap,v.specularMapTransform)),y.alphaTest>0&&(v.alphaTest.value=y.alphaTest);const S=e.get(y),k=S.envMap,T=S.envMapRotation;k&&(v.envMap.value=k,hf.copy(T),hf.x*=-1,hf.y*=-1,hf.z*=-1,k.isCubeTexture&&k.isRenderTargetTexture===!1&&(hf.y*=-1,hf.z*=-1),v.envMapRotation.value.setFromMatrix4(I4e.makeRotationFromEuler(hf)),v.flipEnvMap.value=k.isCubeTexture&&k.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=y.reflectivity,v.ior.value=y.ior,v.refractionRatio.value=y.refractionRatio),y.lightMap&&(v.lightMap.value=y.lightMap,v.lightMapIntensity.value=y.lightMapIntensity,n(y.lightMap,v.lightMapTransform)),y.aoMap&&(v.aoMap.value=y.aoMap,v.aoMapIntensity.value=y.aoMapIntensity,n(y.aoMap,v.aoMapTransform))}function o(v,y){v.diffuse.value.copy(y.color),v.opacity.value=y.opacity,y.map&&(v.map.value=y.map,n(y.map,v.mapTransform))}function l(v,y){v.dashSize.value=y.dashSize,v.totalSize.value=y.dashSize+y.gapSize,v.scale.value=y.scale}function c(v,y,S,k){v.diffuse.value.copy(y.color),v.opacity.value=y.opacity,v.size.value=y.size*S,v.scale.value=k*.5,y.map&&(v.map.value=y.map,n(y.map,v.uvTransform)),y.alphaMap&&(v.alphaMap.value=y.alphaMap,n(y.alphaMap,v.alphaMapTransform)),y.alphaTest>0&&(v.alphaTest.value=y.alphaTest)}function u(v,y){v.diffuse.value.copy(y.color),v.opacity.value=y.opacity,v.rotation.value=y.rotation,y.map&&(v.map.value=y.map,n(y.map,v.mapTransform)),y.alphaMap&&(v.alphaMap.value=y.alphaMap,n(y.alphaMap,v.alphaMapTransform)),y.alphaTest>0&&(v.alphaTest.value=y.alphaTest)}function d(v,y){v.specular.value.copy(y.specular),v.shininess.value=Math.max(y.shininess,1e-4)}function f(v,y){y.gradientMap&&(v.gradientMap.value=y.gradientMap)}function p(v,y){v.metalness.value=y.metalness,y.metalnessMap&&(v.metalnessMap.value=y.metalnessMap,n(y.metalnessMap,v.metalnessMapTransform)),v.roughness.value=y.roughness,y.roughnessMap&&(v.roughnessMap.value=y.roughnessMap,n(y.roughnessMap,v.roughnessMapTransform)),y.envMap&&(v.envMapIntensity.value=y.envMapIntensity)}function m(v,y,S){v.ior.value=y.ior,y.sheen>0&&(v.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),v.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(v.sheenColorMap.value=y.sheenColorMap,n(y.sheenColorMap,v.sheenColorMapTransform)),y.sheenRoughnessMap&&(v.sheenRoughnessMap.value=y.sheenRoughnessMap,n(y.sheenRoughnessMap,v.sheenRoughnessMapTransform))),y.clearcoat>0&&(v.clearcoat.value=y.clearcoat,v.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(v.clearcoatMap.value=y.clearcoatMap,n(y.clearcoatMap,v.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,n(y.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(v.clearcoatNormalMap.value=y.clearcoatNormalMap,n(y.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===Is&&v.clearcoatNormalScale.value.negate())),y.dispersion>0&&(v.dispersion.value=y.dispersion),y.iridescence>0&&(v.iridescence.value=y.iridescence,v.iridescenceIOR.value=y.iridescenceIOR,v.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(v.iridescenceMap.value=y.iridescenceMap,n(y.iridescenceMap,v.iridescenceMapTransform)),y.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=y.iridescenceThicknessMap,n(y.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),y.transmission>0&&(v.transmission.value=y.transmission,v.transmissionSamplerMap.value=S.texture,v.transmissionSamplerSize.value.set(S.width,S.height),y.transmissionMap&&(v.transmissionMap.value=y.transmissionMap,n(y.transmissionMap,v.transmissionMapTransform)),v.thickness.value=y.thickness,y.thicknessMap&&(v.thicknessMap.value=y.thicknessMap,n(y.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=y.attenuationDistance,v.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(v.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(v.anisotropyMap.value=y.anisotropyMap,n(y.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=y.specularIntensity,v.specularColor.value.copy(y.specularColor),y.specularColorMap&&(v.specularColorMap.value=y.specularColorMap,n(y.specularColorMap,v.specularColorMapTransform)),y.specularIntensityMap&&(v.specularIntensityMap.value=y.specularIntensityMap,n(y.specularIntensityMap,v.specularIntensityMapTransform))}function x(v,y){y.matcap&&(v.matcap.value=y.matcap)}function b(v,y){const S=e.get(y).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 z4e(t,e,n,r){let i={},a={},o=[];const l=t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS);function c(S,k){const T=k.program;r.uniformBlockBinding(S,T)}function u(S,k){let T=i[S.id];T===void 0&&(x(S),T=d(S),i[S.id]=T,S.addEventListener("dispose",v));const M=k.program;r.updateUBOMapping(S,M);const C=e.render.frame;a[S.id]!==C&&(p(S),a[S.id]=C)}function d(S){const k=f();S.__bindingPointIndex=k;const T=t.createBuffer(),M=S.__size,C=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,M,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,k,T),T}function f(){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 k=i[S.id],T=S.uniforms,M=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,k);for(let C=0,E=T.length;C<E;C++){const R=Array.isArray(T[C])?T[C]:[T[C]];for(let A=0,D=R.length;A<D;A++){const I=R[A];if(m(I,C,A,M)===!0){const F=I.__offset,z=Array.isArray(I.value)?I.value:[I.value];let P=0;for(let $=0;$<z.length;$++){const X=z[$],V=b(X);typeof X=="number"||typeof X=="boolean"?(I.__data[0]=X,t.bufferSubData(t.UNIFORM_BUFFER,F+P,I.__data)):X.isMatrix3?(I.__data[0]=X.elements[0],I.__data[1]=X.elements[1],I.__data[2]=X.elements[2],I.__data[3]=0,I.__data[4]=X.elements[3],I.__data[5]=X.elements[4],I.__data[6]=X.elements[5],I.__data[7]=0,I.__data[8]=X.elements[6],I.__data[9]=X.elements[7],I.__data[10]=X.elements[8],I.__data[11]=0):(X.toArray(I.__data,P),P+=V.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,F,I.__data)}}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(S,k,T,M){const C=S.value,E=k+"_"+T;if(M[E]===void 0)return typeof C=="number"||typeof C=="boolean"?M[E]=C:M[E]=C.clone(),!0;{const R=M[E];if(typeof C=="number"||typeof C=="boolean"){if(R!==C)return M[E]=C,!0}else if(R.equals(C)===!1)return R.copy(C),!0}return!1}function x(S){const k=S.uniforms;let T=0;const M=16;for(let E=0,R=k.length;E<R;E++){const A=Array.isArray(k[E])?k[E]:[k[E]];for(let D=0,I=A.length;D<I;D++){const F=A[D],z=Array.isArray(F.value)?F.value:[F.value];for(let P=0,$=z.length;P<$;P++){const X=z[P],V=b(X),Q=T%M,Z=Q%V.boundary,se=Q+Z;T+=Z,se!==0&&M-se<V.storage&&(T+=M-se),F.__data=new Float32Array(V.storage/Float32Array.BYTES_PER_ELEMENT),F.__offset=T,T+=V.storage}}}const C=T%M;return C>0&&(T+=M-C),S.__size=T,S.__cache={},this}function b(S){const k={boundary:0,storage:0};return typeof S=="number"||typeof S=="boolean"?(k.boundary=4,k.storage=4):S.isVector2?(k.boundary=8,k.storage=8):S.isVector3||S.isColor?(k.boundary=16,k.storage=12):S.isVector4?(k.boundary=16,k.storage=16):S.isMatrix3?(k.boundary=48,k.storage=48):S.isMatrix4?(k.boundary=64,k.storage=64):S.isTexture?xn("WebGLRenderer: Texture samplers can not be part of an uniforms group."):xn("WebGLRenderer: Unsupported uniform value type.",S),k}function v(S){const k=S.target;k.removeEventListener("dispose",v);const T=o.indexOf(k.__bindingPointIndex);o.splice(T,1),t.deleteBuffer(i[k.id]),delete i[k.id],delete a[k.id]}function y(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},a={}}return{bind:c,update:u,dispose:y}}const B4e=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 Zc=null;function H4e(){return Zc===null&&(Zc=new Hje(B4e,32,32,W4,Cx),Zc.minFilter=el,Zc.magFilter=el,Zc.wrapS=wu,Zc.wrapT=wu,Zc.generateMipmaps=!1,Zc.needsUpdate=!0),Zc}let $4e=class{constructor(e={}){const{canvas:n=fje(),context:r=null,depth:i=!0,stencil:a=!1,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!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([X4,K4,q4]),b=new Set([vc,pm,dy,hy,V4,G4]),v=new Uint32Array(4),y=new Int32Array(4);let S=null,k=null;const T=[],M=[];this.domElement=n,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=lh,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let E=!1;this._outputColorSpace=Vo;let R=0,A=0,D=null,I=-1,F=null;const z=new zi,P=new zi;let $=null;const X=new Bn(0);let V=0,Q=n.width,Z=n.height,se=1,H=null,K=null;const re=new zi(0,0,Q,Z),ne=new zi(0,0,Q,Z);let be=!1;const me=new eL;let de=!1,Ce=!1;const ie=new Gi,ke=new ht,Oe=new zi,pe={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let We=!1;function G(){return D===null?se:1}let Y=r;function ue(fe,De){return n.getContext(fe,De)}try{const fe={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${B4}`),n.addEventListener("webglcontextlost",Ue,!1),n.addEventListener("webglcontextrestored",W,!1),n.addEventListener("webglcontextcreationerror",je,!1),Y===null){const De="webgl2";if(Y=ue(De,fe),Y===null)throw ue(De)?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,te,U,he,Me,ge,B,O,ee,le,_e,ve,ae,Fe,Be,$e,He,xe,Pe,ze,we,Xe,Ne,rt;function Ee(){q=new QRe(Y),q.init(),Xe=new D4e(Y,q),te=new HRe(Y,q,e,Xe),U=new P4e(Y,q),te.reversedDepthBuffer&&p&&U.buffers.depth.setReversed(!0),he=new eOe(Y),Me=new b4e,ge=new j4e(Y,q,U,Me,te,Xe,he),B=new VRe(C),O=new YRe(C),ee=new i3e(Y),Ne=new zRe(Y,ee),le=new ZRe(Y,ee,he,Ne),_e=new nOe(Y,le,ee,he),Pe=new tOe(Y,te,ge),$e=new $Re(Me),ve=new x4e(C,B,O,q,te,Ne,$e),ae=new U4e(C,Me),Fe=new v4e,Be=new k4e(q),xe=new URe(C,B,O,U,_e,m,c),He=new A4e(C,_e,te),rt=new z4e(Y,he,te,U),ze=new BRe(Y,q,he),we=new JRe(Y,q,he),he.programs=ve.programs,C.capabilities=te,C.extensions=q,C.properties=Me,C.renderLists=Fe,C.shadowMap=He,C.state=U,C.info=he}Ee();const Ke=new F4e(C,Y);this.xr=Ke,this.getContext=function(){return Y},this.getContextAttributes=function(){return Y.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 se},this.setPixelRatio=function(fe){fe!==void 0&&(se=fe,this.setSize(Q,Z,!1))},this.getSize=function(fe){return fe.set(Q,Z)},this.setSize=function(fe,De,Ve=!0){if(Ke.isPresenting){xn("WebGLRenderer: Can't change size while VR device is presenting.");return}Q=fe,Z=De,n.width=Math.floor(fe*se),n.height=Math.floor(De*se),Ve===!0&&(n.style.width=fe+"px",n.style.height=De+"px"),this.setViewport(0,0,fe,De)},this.getDrawingBufferSize=function(fe){return fe.set(Q*se,Z*se).floor()},this.setDrawingBufferSize=function(fe,De,Ve){Q=fe,Z=De,se=Ve,n.width=Math.floor(fe*Ve),n.height=Math.floor(De*Ve),this.setViewport(0,0,fe,De)},this.getCurrentViewport=function(fe){return fe.copy(z)},this.getViewport=function(fe){return fe.copy(re)},this.setViewport=function(fe,De,Ve,Se){fe.isVector4?re.set(fe.x,fe.y,fe.z,fe.w):re.set(fe,De,Ve,Se),U.viewport(z.copy(re).multiplyScalar(se).round())},this.getScissor=function(fe){return fe.copy(ne)},this.setScissor=function(fe,De,Ve,Se){fe.isVector4?ne.set(fe.x,fe.y,fe.z,fe.w):ne.set(fe,De,Ve,Se),U.scissor(P.copy(ne).multiplyScalar(se).round())},this.getScissorTest=function(){return be},this.setScissorTest=function(fe){U.setScissorTest(be=fe)},this.setOpaqueSort=function(fe){H=fe},this.setTransparentSort=function(fe){K=fe},this.getClearColor=function(fe){return fe.copy(xe.getClearColor())},this.setClearColor=function(){xe.setClearColor(...arguments)},this.getClearAlpha=function(){return xe.getClearAlpha()},this.setClearAlpha=function(){xe.setClearAlpha(...arguments)},this.clear=function(fe=!0,De=!0,Ve=!0){let Se=0;if(fe){let Le=!1;if(D!==null){const tt=D.texture.format;Le=x.has(tt)}if(Le){const tt=D.texture.type,Qe=b.has(tt),Tt=xe.getClearColor(),At=xe.getClearAlpha(),Ft=Tt.r,jt=Tt.g,Mt=Tt.b;Qe?(v[0]=Ft,v[1]=jt,v[2]=Mt,v[3]=At,Y.clearBufferuiv(Y.COLOR,0,v)):(y[0]=Ft,y[1]=jt,y[2]=Mt,y[3]=At,Y.clearBufferiv(Y.COLOR,0,y))}else Se|=Y.COLOR_BUFFER_BIT}De&&(Se|=Y.DEPTH_BUFFER_BIT),Ve&&(Se|=Y.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),Y.clear(Se)},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",Ue,!1),n.removeEventListener("webglcontextrestored",W,!1),n.removeEventListener("webglcontextcreationerror",je,!1),xe.dispose(),Fe.dispose(),Be.dispose(),Me.dispose(),B.dispose(),O.dispose(),_e.dispose(),Ne.dispose(),rt.dispose(),ve.dispose(),Ke.dispose(),Ke.removeEventListener("sessionstart",cn),Ke.removeEventListener("sessionend",rr),Vn.stop()};function Ue(fe){fe.preventDefault(),I$("WebGLRenderer: Context Lost."),E=!0}function W(){I$("WebGLRenderer: Context Restored."),E=!1;const fe=he.autoReset,De=He.enabled,Ve=He.autoUpdate,Se=He.needsUpdate,Le=He.type;Ee(),he.autoReset=fe,He.enabled=De,He.autoUpdate=Ve,He.needsUpdate=Se,He.type=Le}function je(fe){Ti("WebGLRenderer: A WebGL context could not be created. Reason: ",fe.statusMessage)}function Ye(fe){const De=fe.target;De.removeEventListener("dispose",Ye),bt(De)}function bt(fe){pt(fe),Me.remove(fe)}function pt(fe){const De=Me.get(fe).programs;De!==void 0&&(De.forEach(function(Ve){ve.releaseProgram(Ve)}),fe.isShaderMaterial&&ve.releaseShaderCache(fe))}this.renderBufferDirect=function(fe,De,Ve,Se,Le,tt){De===null&&(De=pe);const Qe=Le.isMesh&&Le.matrixWorld.determinant()<0,Tt=Ae(fe,De,Ve,Se,Le);U.setMaterial(Se,Qe);let At=Ve.index,Ft=1;if(Se.wireframe===!0){if(At=le.getWireframeAttribute(Ve),At===void 0)return;Ft=2}const jt=Ve.drawRange,Mt=Ve.attributes.position;let Jt=jt.start*Ft,Ht=(jt.start+jt.count)*Ft;tt!==null&&(Jt=Math.max(Jt,tt.start*Ft),Ht=Math.min(Ht,(tt.start+tt.count)*Ft)),At!==null?(Jt=Math.max(Jt,0),Ht=Math.min(Ht,At.count)):Mt!=null&&(Jt=Math.max(Jt,0),Ht=Math.min(Ht,Mt.count));const hn=Ht-Jt;if(hn<0||hn===1/0)return;Ne.setup(Le,Se,Tt,Ve,At);let un,Mn=ze;if(At!==null&&(un=ee.get(At),Mn=we,Mn.setIndex(un)),Le.isMesh)Se.wireframe===!0?(U.setLineWidth(Se.wireframeLinewidth*G()),Mn.setMode(Y.LINES)):Mn.setMode(Y.TRIANGLES);else if(Le.isLine){let Gt=Se.linewidth;Gt===void 0&&(Gt=1),U.setLineWidth(Gt*G()),Le.isLineSegments?Mn.setMode(Y.LINES):Le.isLineLoop?Mn.setMode(Y.LINE_LOOP):Mn.setMode(Y.LINE_STRIP)}else Le.isPoints?Mn.setMode(Y.POINTS):Le.isSprite&&Mn.setMode(Y.TRIANGLES);if(Le.isBatchedMesh)if(Le._multiDrawInstances!==null)py("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Mn.renderMultiDrawInstances(Le._multiDrawStarts,Le._multiDrawCounts,Le._multiDrawCount,Le._multiDrawInstances);else if(q.get("WEBGL_multi_draw"))Mn.renderMultiDraw(Le._multiDrawStarts,Le._multiDrawCounts,Le._multiDrawCount);else{const Gt=Le._multiDrawStarts,on=Le._multiDrawCounts,dn=Le._multiDrawCount,Yt=At?ee.get(At).bytesPerElement:1,ir=Me.get(Se).currentProgram.getUniforms();for(let jn=0;jn<dn;jn++)ir.setValue(Y,"_gl_DrawID",jn),Mn.render(Gt[jn]/Yt,on[jn])}else if(Le.isInstancedMesh)Mn.renderInstances(Jt,hn,Le.count);else if(Ve.isInstancedBufferGeometry){const Gt=Ve._maxInstanceCount!==void 0?Ve._maxInstanceCount:1/0,on=Math.min(Ve.instanceCount,Gt);Mn.renderInstances(Jt,hn,on)}else Mn.render(Jt,hn)};function Bt(fe,De,Ve){fe.transparent===!0&&fe.side===ic&&fe.forceSinglePass===!1?(fe.side=Is,fe.needsUpdate=!0,Nn(fe,De,Ve),fe.side=kh,fe.needsUpdate=!0,Nn(fe,De,Ve),fe.side=ic):Nn(fe,De,Ve)}this.compile=function(fe,De,Ve=null){Ve===null&&(Ve=fe),k=Be.get(Ve),k.init(De),M.push(k),Ve.traverseVisible(function(Le){Le.isLight&&Le.layers.test(De.layers)&&(k.pushLight(Le),Le.castShadow&&k.pushShadow(Le))}),fe!==Ve&&fe.traverseVisible(function(Le){Le.isLight&&Le.layers.test(De.layers)&&(k.pushLight(Le),Le.castShadow&&k.pushShadow(Le))}),k.setupLights();const Se=new Set;return fe.traverse(function(Le){if(!(Le.isMesh||Le.isPoints||Le.isLine||Le.isSprite))return;const tt=Le.material;if(tt)if(Array.isArray(tt))for(let Qe=0;Qe<tt.length;Qe++){const Tt=tt[Qe];Bt(Tt,Ve,Le),Se.add(Tt)}else Bt(tt,Ve,Le),Se.add(tt)}),k=M.pop(),Se},this.compileAsync=function(fe,De,Ve=null){const Se=this.compile(fe,De,Ve);return new Promise(Le=>{function tt(){if(Se.forEach(function(Qe){Me.get(Qe).currentProgram.isReady()&&Se.delete(Qe)}),Se.size===0){Le(fe);return}setTimeout(tt,10)}q.get("KHR_parallel_shader_compile")!==null?tt():setTimeout(tt,10)})};let Lt=null;function vn(fe){Lt&&Lt(fe)}function cn(){Vn.stop()}function rr(){Vn.start()}const Vn=new jJ;Vn.setAnimationLoop(vn),typeof self<"u"&&Vn.setContext(self),this.setAnimationLoop=function(fe){Lt=fe,Ke.setAnimationLoop(fe),fe===null?Vn.stop():Vn.start()},Ke.addEventListener("sessionstart",cn),Ke.addEventListener("sessionend",rr),this.render=function(fe,De){if(De!==void 0&&De.isCamera!==!0){Ti("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(E===!0)return;if(fe.matrixWorldAutoUpdate===!0&&fe.updateMatrixWorld(),De.parent===null&&De.matrixWorldAutoUpdate===!0&&De.updateMatrixWorld(),Ke.enabled===!0&&Ke.isPresenting===!0&&(Ke.cameraAutoUpdate===!0&&Ke.updateCamera(De),De=Ke.getCamera()),fe.isScene===!0&&fe.onBeforeRender(C,fe,De,D),k=Be.get(fe,M.length),k.init(De),M.push(k),ie.multiplyMatrices(De.projectionMatrix,De.matrixWorldInverse),me.setFromProjectionMatrix(ie,lc,De.reversedDepth),Ce=this.localClippingEnabled,de=$e.init(this.clippingPlanes,Ce),S=Fe.get(fe,T.length),S.init(),T.push(S),Ke.enabled===!0&&Ke.isPresenting===!0){const tt=C.xr.getDepthSensingMesh();tt!==null&&Jn(tt,De,-1/0,C.sortObjects)}Jn(fe,De,0,C.sortObjects),S.finish(),C.sortObjects===!0&&S.sort(H,K),We=Ke.enabled===!1||Ke.isPresenting===!1||Ke.hasDepthSensing()===!1,We&&xe.addToRenderList(S,fe),this.info.render.frame++,de===!0&&$e.beginShadows();const Ve=k.state.shadowsArray;He.render(Ve,fe,De),de===!0&&$e.endShadows(),this.info.autoReset===!0&&this.info.reset();const Se=S.opaque,Le=S.transmissive;if(k.setupLights(),De.isArrayCamera){const tt=De.cameras;if(Le.length>0)for(let Qe=0,Tt=tt.length;Qe<Tt;Qe++){const At=tt[Qe];sr(Se,Le,fe,At)}We&&xe.render(fe);for(let Qe=0,Tt=tt.length;Qe<Tt;Qe++){const At=tt[Qe];gn(S,fe,At,At.viewport)}}else Le.length>0&&sr(Se,Le,fe,De),We&&xe.render(fe),gn(S,fe,De);D!==null&&A===0&&(ge.updateMultisampleRenderTarget(D),ge.updateRenderTargetMipmap(D)),fe.isScene===!0&&fe.onAfterRender(C,fe,De),Ne.resetDefaultState(),I=-1,F=null,M.pop(),M.length>0?(k=M[M.length-1],de===!0&&$e.setGlobalState(C.clippingPlanes,k.state.camera)):k=null,T.pop(),T.length>0?S=T[T.length-1]:S=null};function Jn(fe,De,Ve,Se){if(fe.visible===!1)return;if(fe.layers.test(De.layers)){if(fe.isGroup)Ve=fe.renderOrder;else if(fe.isLOD)fe.autoUpdate===!0&&fe.update(De);else if(fe.isLight)k.pushLight(fe),fe.castShadow&&k.pushShadow(fe);else if(fe.isSprite){if(!fe.frustumCulled||me.intersectsSprite(fe)){Se&&Oe.setFromMatrixPosition(fe.matrixWorld).applyMatrix4(ie);const Qe=_e.update(fe),Tt=fe.material;Tt.visible&&S.push(fe,Qe,Tt,Ve,Oe.z,null)}}else if((fe.isMesh||fe.isLine||fe.isPoints)&&(!fe.frustumCulled||me.intersectsObject(fe))){const Qe=_e.update(fe),Tt=fe.material;if(Se&&(fe.boundingSphere!==void 0?(fe.boundingSphere===null&&fe.computeBoundingSphere(),Oe.copy(fe.boundingSphere.center)):(Qe.boundingSphere===null&&Qe.computeBoundingSphere(),Oe.copy(Qe.boundingSphere.center)),Oe.applyMatrix4(fe.matrixWorld).applyMatrix4(ie)),Array.isArray(Tt)){const At=Qe.groups;for(let Ft=0,jt=At.length;Ft<jt;Ft++){const Mt=At[Ft],Jt=Tt[Mt.materialIndex];Jt&&Jt.visible&&S.push(fe,Qe,Jt,Ve,Oe.z,Mt)}}else Tt.visible&&S.push(fe,Qe,Tt,Ve,Oe.z,null)}}const tt=fe.children;for(let Qe=0,Tt=tt.length;Qe<Tt;Qe++)Jn(tt[Qe],De,Ve,Se)}function gn(fe,De,Ve,Se){const{opaque:Le,transmissive:tt,transparent:Qe}=fe;k.setupLightsView(Ve),de===!0&&$e.setGlobalState(C.clippingPlanes,Ve),Se&&U.viewport(z.copy(Se)),Le.length>0&&Gn(Le,De,Ve),tt.length>0&&Gn(tt,De,Ve),Qe.length>0&&Gn(Qe,De,Ve),U.buffers.depth.setTest(!0),U.buffers.depth.setMask(!0),U.buffers.color.setMask(!0),U.setPolygonOffset(!1)}function sr(fe,De,Ve,Se){if((Ve.isScene===!0?Ve.overrideMaterial:null)!==null)return;k.state.transmissionRenderTarget[Se.id]===void 0&&(k.state.transmissionRenderTarget[Se.id]=new xm(1,1,{generateMipmaps:!0,type:q.has("EXT_color_buffer_half_float")||q.has("EXT_color_buffer_float")?Cx:vc,minFilter:Of,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:cr.workingColorSpace}));const tt=k.state.transmissionRenderTarget[Se.id],Qe=Se.viewport||z;tt.setSize(Qe.z*C.transmissionResolutionScale,Qe.w*C.transmissionResolutionScale);const Tt=C.getRenderTarget(),At=C.getActiveCubeFace(),Ft=C.getActiveMipmapLevel();C.setRenderTarget(tt),C.getClearColor(X),V=C.getClearAlpha(),V<1&&C.setClearColor(16777215,.5),C.clear(),We&&xe.render(Ve);const jt=C.toneMapping;C.toneMapping=lh;const Mt=Se.viewport;if(Se.viewport!==void 0&&(Se.viewport=void 0),k.setupLightsView(Se),de===!0&&$e.setGlobalState(C.clippingPlanes,Se),Gn(fe,Ve,Se),ge.updateMultisampleRenderTarget(tt),ge.updateRenderTargetMipmap(tt),q.has("WEBGL_multisampled_render_to_texture")===!1){let Jt=!1;for(let Ht=0,hn=De.length;Ht<hn;Ht++){const un=De[Ht],{object:Mn,geometry:Gt,material:on,group:dn}=un;if(on.side===ic&&Mn.layers.test(Se.layers)){const Yt=on.side;on.side=Is,on.needsUpdate=!0,Xn(Mn,Ve,Se,Gt,on,dn),on.side=Yt,on.needsUpdate=!0,Jt=!0}}Jt===!0&&(ge.updateMultisampleRenderTarget(tt),ge.updateRenderTargetMipmap(tt))}C.setRenderTarget(Tt,At,Ft),C.setClearColor(X,V),Mt!==void 0&&(Se.viewport=Mt),C.toneMapping=jt}function Gn(fe,De,Ve){const Se=De.isScene===!0?De.overrideMaterial:null;for(let Le=0,tt=fe.length;Le<tt;Le++){const Qe=fe[Le],{object:Tt,geometry:At,group:Ft}=Qe;let jt=Qe.material;jt.allowOverride===!0&&Se!==null&&(jt=Se),Tt.layers.test(Ve.layers)&&Xn(Tt,De,Ve,At,jt,Ft)}}function Xn(fe,De,Ve,Se,Le,tt){fe.onBeforeRender(C,De,Ve,Se,Le,tt),fe.modelViewMatrix.multiplyMatrices(Ve.matrixWorldInverse,fe.matrixWorld),fe.normalMatrix.getNormalMatrix(fe.modelViewMatrix),Le.onBeforeRender(C,De,Ve,Se,fe,tt),Le.transparent===!0&&Le.side===ic&&Le.forceSinglePass===!1?(Le.side=Is,Le.needsUpdate=!0,C.renderBufferDirect(Ve,De,Se,Le,fe,tt),Le.side=kh,Le.needsUpdate=!0,C.renderBufferDirect(Ve,De,Se,Le,fe,tt),Le.side=ic):C.renderBufferDirect(Ve,De,Se,Le,fe,tt),fe.onAfterRender(C,De,Ve,Se,Le,tt)}function Nn(fe,De,Ve){De.isScene!==!0&&(De=pe);const Se=Me.get(fe),Le=k.state.lights,tt=k.state.shadowsArray,Qe=Le.state.version,Tt=ve.getParameters(fe,Le.state,tt,De,Ve),At=ve.getProgramCacheKey(Tt);let Ft=Se.programs;Se.environment=fe.isMeshStandardMaterial?De.environment:null,Se.fog=De.fog,Se.envMap=(fe.isMeshStandardMaterial?O:B).get(fe.envMap||Se.environment),Se.envMapRotation=Se.environment!==null&&fe.envMap===null?De.environmentRotation:fe.envMapRotation,Ft===void 0&&(fe.addEventListener("dispose",Ye),Ft=new Map,Se.programs=Ft);let jt=Ft.get(At);if(jt!==void 0){if(Se.currentProgram===jt&&Se.lightsStateVersion===Qe)return ai(fe,Tt),jt}else Tt.uniforms=ve.getUniforms(fe),fe.onBeforeCompile(Tt,C),jt=ve.acquireProgram(Tt,At),Ft.set(At,jt),Se.uniforms=Tt.uniforms;const Mt=Se.uniforms;return(!fe.isShaderMaterial&&!fe.isRawShaderMaterial||fe.clipping===!0)&&(Mt.clippingPlanes=$e.uniform),ai(fe,Tt),Se.needsLights=ct(fe),Se.lightsStateVersion=Qe,Se.needsLights&&(Mt.ambientLightColor.value=Le.state.ambient,Mt.lightProbe.value=Le.state.probe,Mt.directionalLights.value=Le.state.directional,Mt.directionalLightShadows.value=Le.state.directionalShadow,Mt.spotLights.value=Le.state.spot,Mt.spotLightShadows.value=Le.state.spotShadow,Mt.rectAreaLights.value=Le.state.rectArea,Mt.ltc_1.value=Le.state.rectAreaLTC1,Mt.ltc_2.value=Le.state.rectAreaLTC2,Mt.pointLights.value=Le.state.point,Mt.pointLightShadows.value=Le.state.pointShadow,Mt.hemisphereLights.value=Le.state.hemi,Mt.directionalShadowMap.value=Le.state.directionalShadowMap,Mt.directionalShadowMatrix.value=Le.state.directionalShadowMatrix,Mt.spotShadowMap.value=Le.state.spotShadowMap,Mt.spotLightMatrix.value=Le.state.spotLightMatrix,Mt.spotLightMap.value=Le.state.spotLightMap,Mt.pointShadowMap.value=Le.state.pointShadowMap,Mt.pointShadowMatrix.value=Le.state.pointShadowMatrix),Se.currentProgram=jt,Se.uniformsList=null,jt}function hi(fe){if(fe.uniformsList===null){const De=fe.currentProgram.getUniforms();fe.uniformsList=j1.seqWithValue(De.seq,fe.uniforms)}return fe.uniformsList}function ai(fe,De){const Ve=Me.get(fe);Ve.outputColorSpace=De.outputColorSpace,Ve.batching=De.batching,Ve.batchingColor=De.batchingColor,Ve.instancing=De.instancing,Ve.instancingColor=De.instancingColor,Ve.instancingMorph=De.instancingMorph,Ve.skinning=De.skinning,Ve.morphTargets=De.morphTargets,Ve.morphNormals=De.morphNormals,Ve.morphColors=De.morphColors,Ve.morphTargetsCount=De.morphTargetsCount,Ve.numClippingPlanes=De.numClippingPlanes,Ve.numIntersection=De.numClipIntersection,Ve.vertexAlphas=De.vertexAlphas,Ve.vertexTangents=De.vertexTangents,Ve.toneMapping=De.toneMapping}function Ae(fe,De,Ve,Se,Le){De.isScene!==!0&&(De=pe),ge.resetTextureUnits();const tt=De.fog,Qe=Se.isMeshStandardMaterial?De.environment:null,Tt=D===null?C.outputColorSpace:D.isXRRenderTarget===!0?D.texture.colorSpace:ex,At=(Se.isMeshStandardMaterial?O:B).get(Se.envMap||Qe),Ft=Se.vertexColors===!0&&!!Ve.attributes.color&&Ve.attributes.color.itemSize===4,jt=!!Ve.attributes.tangent&&(!!Se.normalMap||Se.anisotropy>0),Mt=!!Ve.morphAttributes.position,Jt=!!Ve.morphAttributes.normal,Ht=!!Ve.morphAttributes.color;let hn=lh;Se.toneMapped&&(D===null||D.isXRRenderTarget===!0)&&(hn=C.toneMapping);const un=Ve.morphAttributes.position||Ve.morphAttributes.normal||Ve.morphAttributes.color,Mn=un!==void 0?un.length:0,Gt=Me.get(Se),on=k.state.lights;if(de===!0&&(Ce===!0||fe!==F)){const Pt=fe===F&&Se.id===I;$e.setState(Se,fe,Pt)}let dn=!1;Se.version===Gt.__version?(Gt.needsLights&&Gt.lightsStateVersion!==on.state.version||Gt.outputColorSpace!==Tt||Le.isBatchedMesh&&Gt.batching===!1||!Le.isBatchedMesh&&Gt.batching===!0||Le.isBatchedMesh&&Gt.batchingColor===!0&&Le.colorTexture===null||Le.isBatchedMesh&&Gt.batchingColor===!1&&Le.colorTexture!==null||Le.isInstancedMesh&&Gt.instancing===!1||!Le.isInstancedMesh&&Gt.instancing===!0||Le.isSkinnedMesh&&Gt.skinning===!1||!Le.isSkinnedMesh&&Gt.skinning===!0||Le.isInstancedMesh&&Gt.instancingColor===!0&&Le.instanceColor===null||Le.isInstancedMesh&&Gt.instancingColor===!1&&Le.instanceColor!==null||Le.isInstancedMesh&&Gt.instancingMorph===!0&&Le.morphTexture===null||Le.isInstancedMesh&&Gt.instancingMorph===!1&&Le.morphTexture!==null||Gt.envMap!==At||Se.fog===!0&&Gt.fog!==tt||Gt.numClippingPlanes!==void 0&&(Gt.numClippingPlanes!==$e.numPlanes||Gt.numIntersection!==$e.numIntersection)||Gt.vertexAlphas!==Ft||Gt.vertexTangents!==jt||Gt.morphTargets!==Mt||Gt.morphNormals!==Jt||Gt.morphColors!==Ht||Gt.toneMapping!==hn||Gt.morphTargetsCount!==Mn)&&(dn=!0):(dn=!0,Gt.__version=Se.version);let Yt=Gt.currentProgram;dn===!0&&(Yt=Nn(Se,De,Le));let ir=!1,jn=!1,si=!1;const ar=Yt.getUniforms(),dr=Gt.uniforms;if(U.useProgram(Yt.program)&&(ir=!0,jn=!0,si=!0),Se.id!==I&&(I=Se.id,jn=!0),ir||F!==fe){U.buffers.depth.getReversed()&&fe.reversedDepth!==!0&&(fe._reversedDepth=!0,fe.updateProjectionMatrix()),ar.setValue(Y,"projectionMatrix",fe.projectionMatrix),ar.setValue(Y,"viewMatrix",fe.matrixWorldInverse);const qt=ar.map.cameraPosition;qt!==void 0&&qt.setValue(Y,ke.setFromMatrixPosition(fe.matrixWorld)),te.logarithmicDepthBuffer&&ar.setValue(Y,"logDepthBufFC",2/(Math.log(fe.far+1)/Math.LN2)),(Se.isMeshPhongMaterial||Se.isMeshToonMaterial||Se.isMeshLambertMaterial||Se.isMeshBasicMaterial||Se.isMeshStandardMaterial||Se.isShaderMaterial)&&ar.setValue(Y,"isOrthographic",fe.isOrthographicCamera===!0),F!==fe&&(F=fe,jn=!0,si=!0)}if(Le.isSkinnedMesh){ar.setOptional(Y,Le,"bindMatrix"),ar.setOptional(Y,Le,"bindMatrixInverse");const Pt=Le.skeleton;Pt&&(Pt.boneTexture===null&&Pt.computeBoneTexture(),ar.setValue(Y,"boneTexture",Pt.boneTexture,ge))}Le.isBatchedMesh&&(ar.setOptional(Y,Le,"batchingTexture"),ar.setValue(Y,"batchingTexture",Le._matricesTexture,ge),ar.setOptional(Y,Le,"batchingIdTexture"),ar.setValue(Y,"batchingIdTexture",Le._indirectTexture,ge),ar.setOptional(Y,Le,"batchingColorTexture"),Le._colorsTexture!==null&&ar.setValue(Y,"batchingColorTexture",Le._colorsTexture,ge));const nt=Ve.morphAttributes;if((nt.position!==void 0||nt.normal!==void 0||nt.color!==void 0)&&Pe.update(Le,Ve,Yt),(jn||Gt.receiveShadow!==Le.receiveShadow)&&(Gt.receiveShadow=Le.receiveShadow,ar.setValue(Y,"receiveShadow",Le.receiveShadow)),Se.isMeshGouraudMaterial&&Se.envMap!==null&&(dr.envMap.value=At,dr.flipEnvMap.value=At.isCubeTexture&&At.isRenderTargetTexture===!1?-1:1),Se.isMeshStandardMaterial&&Se.envMap===null&&De.environment!==null&&(dr.envMapIntensity.value=De.environmentIntensity),dr.dfgLUT!==void 0&&(dr.dfgLUT.value=H4e()),jn&&(ar.setValue(Y,"toneMappingExposure",C.toneMappingExposure),Gt.needsLights&&et(dr,si),tt&&Se.fog===!0&&ae.refreshFogUniforms(dr,tt),ae.refreshMaterialUniforms(dr,Se,se,Z,k.state.transmissionRenderTarget[fe.id]),j1.upload(Y,hi(Gt),dr,ge)),Se.isShaderMaterial&&Se.uniformsNeedUpdate===!0&&(j1.upload(Y,hi(Gt),dr,ge),Se.uniformsNeedUpdate=!1),Se.isSpriteMaterial&&ar.setValue(Y,"center",Le.center),ar.setValue(Y,"modelViewMatrix",Le.modelViewMatrix),ar.setValue(Y,"normalMatrix",Le.normalMatrix),ar.setValue(Y,"modelMatrix",Le.matrixWorld),Se.isShaderMaterial||Se.isRawShaderMaterial){const Pt=Se.uniformsGroups;for(let qt=0,vt=Pt.length;qt<vt;qt++){const wn=Pt[qt];rt.update(wn,Yt),rt.bind(wn,Yt)}}return Yt}function et(fe,De){fe.ambientLightColor.needsUpdate=De,fe.lightProbe.needsUpdate=De,fe.directionalLights.needsUpdate=De,fe.directionalLightShadows.needsUpdate=De,fe.pointLights.needsUpdate=De,fe.pointLightShadows.needsUpdate=De,fe.spotLights.needsUpdate=De,fe.spotLightShadows.needsUpdate=De,fe.rectAreaLights.needsUpdate=De,fe.hemisphereLights.needsUpdate=De}function ct(fe){return fe.isMeshLambertMaterial||fe.isMeshToonMaterial||fe.isMeshPhongMaterial||fe.isMeshStandardMaterial||fe.isShadowMaterial||fe.isShaderMaterial&&fe.lights===!0}this.getActiveCubeFace=function(){return R},this.getActiveMipmapLevel=function(){return A},this.getRenderTarget=function(){return D},this.setRenderTargetTextures=function(fe,De,Ve){const Se=Me.get(fe);Se.__autoAllocateDepthBuffer=fe.resolveDepthBuffer===!1,Se.__autoAllocateDepthBuffer===!1&&(Se.__useRenderToTexture=!1),Me.get(fe.texture).__webglTexture=De,Me.get(fe.depthTexture).__webglTexture=Se.__autoAllocateDepthBuffer?void 0:Ve,Se.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(fe,De){const Ve=Me.get(fe);Ve.__webglFramebuffer=De,Ve.__useDefaultFramebuffer=De===void 0};const ut=Y.createFramebuffer();this.setRenderTarget=function(fe,De=0,Ve=0){D=fe,R=De,A=Ve;let Se=!0,Le=null,tt=!1,Qe=!1;if(fe){const At=Me.get(fe);if(At.__useDefaultFramebuffer!==void 0)U.bindFramebuffer(Y.FRAMEBUFFER,null),Se=!1;else if(At.__webglFramebuffer===void 0)ge.setupRenderTarget(fe);else if(At.__hasExternalTextures)ge.rebindTextures(fe,Me.get(fe.texture).__webglTexture,Me.get(fe.depthTexture).__webglTexture);else if(fe.depthBuffer){const Mt=fe.depthTexture;if(At.__boundDepthTexture!==Mt){if(Mt!==null&&Me.has(Mt)&&(fe.width!==Mt.image.width||fe.height!==Mt.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");ge.setupDepthRenderbuffer(fe)}}const Ft=fe.texture;(Ft.isData3DTexture||Ft.isDataArrayTexture||Ft.isCompressedArrayTexture)&&(Qe=!0);const jt=Me.get(fe).__webglFramebuffer;fe.isWebGLCubeRenderTarget?(Array.isArray(jt[De])?Le=jt[De][Ve]:Le=jt[De],tt=!0):fe.samples>0&&ge.useMultisampledRTT(fe)===!1?Le=Me.get(fe).__webglMultisampledFramebuffer:Array.isArray(jt)?Le=jt[Ve]:Le=jt,z.copy(fe.viewport),P.copy(fe.scissor),$=fe.scissorTest}else z.copy(re).multiplyScalar(se).floor(),P.copy(ne).multiplyScalar(se).floor(),$=be;if(Ve!==0&&(Le=ut),U.bindFramebuffer(Y.FRAMEBUFFER,Le)&&Se&&U.drawBuffers(fe,Le),U.viewport(z),U.scissor(P),U.setScissorTest($),tt){const At=Me.get(fe.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_CUBE_MAP_POSITIVE_X+De,At.__webglTexture,Ve)}else if(Qe){const At=De;for(let Ft=0;Ft<fe.textures.length;Ft++){const jt=Me.get(fe.textures[Ft]);Y.framebufferTextureLayer(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0+Ft,jt.__webglTexture,Ve,At)}}else if(fe!==null&&Ve!==0){const At=Me.get(fe.texture);Y.framebufferTexture2D(Y.FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,At.__webglTexture,Ve)}I=-1},this.readRenderTargetPixels=function(fe,De,Ve,Se,Le,tt,Qe,Tt=0){if(!(fe&&fe.isWebGLRenderTarget)){Ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let At=Me.get(fe).__webglFramebuffer;if(fe.isWebGLCubeRenderTarget&&Qe!==void 0&&(At=At[Qe]),At){U.bindFramebuffer(Y.FRAMEBUFFER,At);try{const Ft=fe.textures[Tt],jt=Ft.format,Mt=Ft.type;if(!te.textureFormatReadable(jt)){Ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!te.textureTypeReadable(Mt)){Ti("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}De>=0&&De<=fe.width-Se&&Ve>=0&&Ve<=fe.height-Le&&(fe.textures.length>1&&Y.readBuffer(Y.COLOR_ATTACHMENT0+Tt),Y.readPixels(De,Ve,Se,Le,Xe.convert(jt),Xe.convert(Mt),tt))}finally{const Ft=D!==null?Me.get(D).__webglFramebuffer:null;U.bindFramebuffer(Y.FRAMEBUFFER,Ft)}}},this.readRenderTargetPixelsAsync=async function(fe,De,Ve,Se,Le,tt,Qe,Tt=0){if(!(fe&&fe.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let At=Me.get(fe).__webglFramebuffer;if(fe.isWebGLCubeRenderTarget&&Qe!==void 0&&(At=At[Qe]),At)if(De>=0&&De<=fe.width-Se&&Ve>=0&&Ve<=fe.height-Le){U.bindFramebuffer(Y.FRAMEBUFFER,At);const Ft=fe.textures[Tt],jt=Ft.format,Mt=Ft.type;if(!te.textureFormatReadable(jt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!te.textureTypeReadable(Mt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Jt=Y.createBuffer();Y.bindBuffer(Y.PIXEL_PACK_BUFFER,Jt),Y.bufferData(Y.PIXEL_PACK_BUFFER,tt.byteLength,Y.STREAM_READ),fe.textures.length>1&&Y.readBuffer(Y.COLOR_ATTACHMENT0+Tt),Y.readPixels(De,Ve,Se,Le,Xe.convert(jt),Xe.convert(Mt),0);const Ht=D!==null?Me.get(D).__webglFramebuffer:null;U.bindFramebuffer(Y.FRAMEBUFFER,Ht);const hn=Y.fenceSync(Y.SYNC_GPU_COMMANDS_COMPLETE,0);return Y.flush(),await mje(Y,hn,4),Y.bindBuffer(Y.PIXEL_PACK_BUFFER,Jt),Y.getBufferSubData(Y.PIXEL_PACK_BUFFER,0,tt),Y.deleteBuffer(Jt),Y.deleteSync(hn),tt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(fe,De=null,Ve=0){const Se=Math.pow(2,-Ve),Le=Math.floor(fe.image.width*Se),tt=Math.floor(fe.image.height*Se),Qe=De!==null?De.x:0,Tt=De!==null?De.y:0;ge.setTexture2D(fe,0),Y.copyTexSubImage2D(Y.TEXTURE_2D,Ve,0,0,Qe,Tt,Le,tt),U.unbindTexture()};const lt=Y.createFramebuffer(),Et=Y.createFramebuffer();this.copyTextureToTexture=function(fe,De,Ve=null,Se=null,Le=0,tt=null){tt===null&&(Le!==0?(py("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),tt=Le,Le=0):tt=0);let Qe,Tt,At,Ft,jt,Mt,Jt,Ht,hn;const un=fe.isCompressedTexture?fe.mipmaps[tt]:fe.image;if(Ve!==null)Qe=Ve.max.x-Ve.min.x,Tt=Ve.max.y-Ve.min.y,At=Ve.isBox3?Ve.max.z-Ve.min.z:1,Ft=Ve.min.x,jt=Ve.min.y,Mt=Ve.isBox3?Ve.min.z:0;else{const nt=Math.pow(2,-Le);Qe=Math.floor(un.width*nt),Tt=Math.floor(un.height*nt),fe.isDataArrayTexture?At=un.depth:fe.isData3DTexture?At=Math.floor(un.depth*nt):At=1,Ft=0,jt=0,Mt=0}Se!==null?(Jt=Se.x,Ht=Se.y,hn=Se.z):(Jt=0,Ht=0,hn=0);const Mn=Xe.convert(De.format),Gt=Xe.convert(De.type);let on;De.isData3DTexture?(ge.setTexture3D(De,0),on=Y.TEXTURE_3D):De.isDataArrayTexture||De.isCompressedArrayTexture?(ge.setTexture2DArray(De,0),on=Y.TEXTURE_2D_ARRAY):(ge.setTexture2D(De,0),on=Y.TEXTURE_2D),Y.pixelStorei(Y.UNPACK_FLIP_Y_WEBGL,De.flipY),Y.pixelStorei(Y.UNPACK_PREMULTIPLY_ALPHA_WEBGL,De.premultiplyAlpha),Y.pixelStorei(Y.UNPACK_ALIGNMENT,De.unpackAlignment);const dn=Y.getParameter(Y.UNPACK_ROW_LENGTH),Yt=Y.getParameter(Y.UNPACK_IMAGE_HEIGHT),ir=Y.getParameter(Y.UNPACK_SKIP_PIXELS),jn=Y.getParameter(Y.UNPACK_SKIP_ROWS),si=Y.getParameter(Y.UNPACK_SKIP_IMAGES);Y.pixelStorei(Y.UNPACK_ROW_LENGTH,un.width),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,un.height),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,Ft),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,jt),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,Mt);const ar=fe.isDataArrayTexture||fe.isData3DTexture,dr=De.isDataArrayTexture||De.isData3DTexture;if(fe.isDepthTexture){const nt=Me.get(fe),Pt=Me.get(De),qt=Me.get(nt.__renderTarget),vt=Me.get(Pt.__renderTarget);U.bindFramebuffer(Y.READ_FRAMEBUFFER,qt.__webglFramebuffer),U.bindFramebuffer(Y.DRAW_FRAMEBUFFER,vt.__webglFramebuffer);for(let wn=0;wn<At;wn++)ar&&(Y.framebufferTextureLayer(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Me.get(fe).__webglTexture,Le,Mt+wn),Y.framebufferTextureLayer(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Me.get(De).__webglTexture,tt,hn+wn)),Y.blitFramebuffer(Ft,jt,Qe,Tt,Jt,Ht,Qe,Tt,Y.DEPTH_BUFFER_BIT,Y.NEAREST);U.bindFramebuffer(Y.READ_FRAMEBUFFER,null),U.bindFramebuffer(Y.DRAW_FRAMEBUFFER,null)}else if(Le!==0||fe.isRenderTargetTexture||Me.has(fe)){const nt=Me.get(fe),Pt=Me.get(De);U.bindFramebuffer(Y.READ_FRAMEBUFFER,lt),U.bindFramebuffer(Y.DRAW_FRAMEBUFFER,Et);for(let qt=0;qt<At;qt++)ar?Y.framebufferTextureLayer(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,nt.__webglTexture,Le,Mt+qt):Y.framebufferTexture2D(Y.READ_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,nt.__webglTexture,Le),dr?Y.framebufferTextureLayer(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Pt.__webglTexture,tt,hn+qt):Y.framebufferTexture2D(Y.DRAW_FRAMEBUFFER,Y.COLOR_ATTACHMENT0,Y.TEXTURE_2D,Pt.__webglTexture,tt),Le!==0?Y.blitFramebuffer(Ft,jt,Qe,Tt,Jt,Ht,Qe,Tt,Y.COLOR_BUFFER_BIT,Y.NEAREST):dr?Y.copyTexSubImage3D(on,tt,Jt,Ht,hn+qt,Ft,jt,Qe,Tt):Y.copyTexSubImage2D(on,tt,Jt,Ht,Ft,jt,Qe,Tt);U.bindFramebuffer(Y.READ_FRAMEBUFFER,null),U.bindFramebuffer(Y.DRAW_FRAMEBUFFER,null)}else dr?fe.isDataTexture||fe.isData3DTexture?Y.texSubImage3D(on,tt,Jt,Ht,hn,Qe,Tt,At,Mn,Gt,un.data):De.isCompressedArrayTexture?Y.compressedTexSubImage3D(on,tt,Jt,Ht,hn,Qe,Tt,At,Mn,un.data):Y.texSubImage3D(on,tt,Jt,Ht,hn,Qe,Tt,At,Mn,Gt,un):fe.isDataTexture?Y.texSubImage2D(Y.TEXTURE_2D,tt,Jt,Ht,Qe,Tt,Mn,Gt,un.data):fe.isCompressedTexture?Y.compressedTexSubImage2D(Y.TEXTURE_2D,tt,Jt,Ht,un.width,un.height,Mn,un.data):Y.texSubImage2D(Y.TEXTURE_2D,tt,Jt,Ht,Qe,Tt,Mn,Gt,un);Y.pixelStorei(Y.UNPACK_ROW_LENGTH,dn),Y.pixelStorei(Y.UNPACK_IMAGE_HEIGHT,Yt),Y.pixelStorei(Y.UNPACK_SKIP_PIXELS,ir),Y.pixelStorei(Y.UNPACK_SKIP_ROWS,jn),Y.pixelStorei(Y.UNPACK_SKIP_IMAGES,si),tt===0&&De.generateMipmaps&&Y.generateMipmap(on),U.unbindTexture()},this.initRenderTarget=function(fe){Me.get(fe).__webglFramebuffer===void 0&&ge.setupRenderTarget(fe)},this.initTexture=function(fe){fe.isCubeTexture?ge.setTextureCube(fe,0):fe.isData3DTexture?ge.setTexture3D(fe,0):fe.isDataArrayTexture||fe.isCompressedArrayTexture?ge.setTexture2DArray(fe,0):ge.setTexture2D(fe,0),U.unbindTexture()},this.resetState=function(){R=0,A=0,D=null,U.reset(),Ne.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return lc}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 DV={type:"change"},nL={type:"start"},FJ={type:"end"},w_=new Q4,RV=new Bd,V4e=Math.cos(70*gje.DEG2RAD),Ki=new ht,Ps=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},_C=1e-6;class G4e extends n3e{constructor(e,n=null){super(e,n),this.state=Tr.NONE,this.target=new ht,this.cursor=new ht,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:Tg.ROTATE,MIDDLE:Tg.DOLLY,RIGHT:Tg.PAN},this.touches={ONE:bg.ROTATE,TWO:bg.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new ht,this._lastQuaternion=new gm,this._lastTargetPosition=new ht,this._quat=new gm().setFromUnitVectors(e.up,new ht(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new lV,this._sphericalDelta=new lV,this._scale=1,this._panOffset=new ht,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 ht,this._mouse=new Cn,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=W4e.bind(this),this._onPointerDown=q4e.bind(this),this._onPointerUp=K4e.bind(this),this._onContextMenu=tLe.bind(this),this._onMouseWheel=Q4e.bind(this),this._onKeyDown=Z4e.bind(this),this._onTouchStart=J4e.bind(this),this._onTouchMove=eLe.bind(this),this._onMouseDown=X4e.bind(this),this._onMouseMove=Y4e.bind(this),this._interceptControlDown=nLe.bind(this),this._interceptControlUp=rLe.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(DV),this.update(),this.state=Tr.NONE}update(e=null){const n=this.object.position;Ki.copy(n).sub(this.target),Ki.applyQuaternion(this._quat),this._spherical.setFromVector3(Ki),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+=Ps:r>Math.PI&&(r-=Ps),i<-Math.PI?i+=Ps:i>Math.PI&&(i-=Ps),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=o!=this._spherical.radius}if(Ki.setFromSpherical(this._spherical),Ki.applyQuaternion(this._quatInverse),n.copy(this.target).add(Ki),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=Ki.length();o=this._clampDistance(l*this._scale);const c=l-o;this.object.position.addScaledVector(this._dollyDirection,c),this.object.updateMatrixWorld(),a=!!c}else if(this.object.isOrthographicCamera){const l=new ht(this._mouse.x,this._mouse.y,0);l.unproject(this.object);const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=c!==this.object.zoom;const u=new ht(this._mouse.x,this._mouse.y,0);u.unproject(this.object),this.object.position.sub(u).add(l),this.object.updateMatrixWorld(),o=Ki.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(w_.origin.copy(this.object.position),w_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(w_.direction))<V4e?this.object.lookAt(this.target):(RV.setFromNormalAndCoplanarPoint(this.object.up,this.target),w_.intersectPlane(RV,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(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>_C||8*(1-this._lastQuaternion.dot(this.object.quaternion))>_C||this._lastTargetPosition.distanceToSquared(this.target)>_C?(this.dispatchEvent(DV),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ps/60*this.autoRotateSpeed*e:Ps/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){Ki.setFromMatrixColumn(n,0),Ki.multiplyScalar(-e),this._panOffset.add(Ki)}_panUp(e,n){this.screenSpacePanning===!0?Ki.setFromMatrixColumn(n,1):(Ki.setFromMatrixColumn(n,0),Ki.crossVectors(this.object.up,Ki)),Ki.multiplyScalar(e),this._panOffset.add(Ki)}_pan(e,n){const r=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;Ki.copy(i).sub(this.target);let a=Ki.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/r.clientHeight,this.object.matrix),this._panUp(2*n*a/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(n*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,n){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),i=e-r.left,a=n-r.top,o=r.width,l=r.height;this._mouse.x=i/o*2-1,this._mouse.y=-(a/l)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Ps*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ps*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(Ps*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(-Ps*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(Ps*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(-Ps*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),n=!0;break}n&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateStart.set(r,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panStart.set(r,i)}}_handleTouchStartDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),i=.5*(e.pageX+r.x),a=.5*(e.pageY+r.y);this._rotateEnd.set(i,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const n=this.domElement;this._rotateLeft(Ps*this._rotateDelta.x/n.clientHeight),this._rotateUp(Ps*this._rotateDelta.y/n.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._panEnd.set(r,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const n=this._getSecondPointerPosition(e),r=e.pageX-n.x,i=e.pageY-n.y,a=Math.sqrt(r*r+i*i);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const 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 q4e(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 W4e(t){this.enabled!==!1&&(t.pointerType==="touch"?this._onTouchMove(t):this._onMouseMove(t))}function K4e(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(FJ),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 X4e(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 Tg.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(t),this.state=Tr.DOLLY;break;case Tg.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 Tg.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(nL)}function Y4e(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 Q4e(t){this.enabled===!1||this.enableZoom===!1||this.state!==Tr.NONE||(t.preventDefault(),this.dispatchEvent(nL),this._handleMouseWheel(this._customWheelEvent(t)),this.dispatchEvent(FJ))}function Z4e(t){this.enabled!==!1&&this._handleKeyDown(t)}function J4e(t){switch(this._trackPointer(t),this._pointers.length){case 1:switch(this.touches.ONE){case bg.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(t),this.state=Tr.TOUCH_ROTATE;break;case bg.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 bg.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(t),this.state=Tr.TOUCH_DOLLY_PAN;break;case bg.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(nL)}function eLe(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 tLe(t){this.enabled!==!1&&t.preventDefault()}function nLe(t){t.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function rLe(t){t.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function iLe(t,e=!1){const n=t[0].index!==null,r=new Set(Object.keys(t[0].attributes)),i=new Set(Object.keys(t[0].morphAttributes)),a={},o={},l=t[0].morphTargetsRelative,c=new Cc;let u=0;for(let d=0;d<t.length;++d){const f=t[d];let p=0;if(n!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const m in f.attributes){if(!r.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+'. All geometries must have compatible attributes; make sure "'+m+'" attribute exists among all geometries, or in none of them.'),null;a[m]===void 0&&(a[m]=[]),a[m].push(f.attributes[m]),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!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const m in f.morphAttributes){if(!i.has(m))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". .morphAttributes must be consistent throughout all geometries."),null;o[m]===void 0&&(o[m]=[]),o[m].push(f.morphAttributes[m])}if(e){let m;if(n)m=f.index.count;else if(f.attributes.position!==void 0)m=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+d+". The geometry must have either an index or a position attribute"),null;c.addGroup(u,m,d),u+=m}}if(n){let d=0;const f=[];for(let p=0;p<t.length;++p){const m=t[p].index;for(let x=0;x<m.count;++x)f.push(m.getX(x)+d);d+=t[p].attributes.position.count}c.setIndex(f)}for(const d in a){const f=OV(a[d]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+d+" attribute."),null;c.setAttribute(d,f)}for(const d in o){const f=o[d][0].length;if(f===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[d]=[];for(let p=0;p<f;++p){const m=[];for(let b=0;b<o[d].length;++b)m.push(o[d][b][p]);const x=OV(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 OV(t){let e,n,r,i=-1,a=0;for(let u=0;u<t.length;++u){const d=t[u];if(e===void 0&&(e=d.array.constructor),e!==d.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(n===void 0&&(n=d.itemSize),n!==d.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(r===void 0&&(r=d.normalized),r!==d.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=d.gpuType),i!==d.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;a+=d.count*n}const o=new e(a),l=new nl(o,n,r);let c=0;for(let u=0;u<t.length;++u){const d=t[u];if(d.isInterleavedBufferAttribute){const f=c/n;for(let p=0,m=d.count;p<m;p++)for(let x=0;x<n;x++){const b=d.getComponent(p,x);l.setComponent(p+f,x,b)}}else o.set(d.array,c);c+=d.count*n}return i!==void 0&&(l.gpuType=i),l}function __(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 SC={exports:{}};var LV;function aLe(){return LV||(LV=1,(function(t,e){(function(n){t.exports=n()})(function(){return(function n(r,i,a){function o(u,d){if(!i[u]){if(!r[u]){var f=typeof __=="function"&&__;if(!d&&f)return f(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 b=r[u][1][x];return o(b||x)},m,m.exports,n,r,i,a)}return i[u].exports}for(var l=typeof __=="function"&&__,c=0;c<a.length;c++)o(a[c]);return o})({1:[function(n,r,i){var a=n("./utils"),o=n("./support"),l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(c){for(var u,d,f,p,m,x,b,v=[],y=0,S=c.length,k=S,T=a.getTypeOf(c)!=="string";y<c.length;)k=S-y,f=T?(u=c[y++],d=y<S?c[y++]:0,y<S?c[y++]:0):(u=c.charCodeAt(y++),d=y<S?c.charCodeAt(y++):0,y<S?c.charCodeAt(y++):0),p=u>>2,m=(3&u)<<4|d>>4,x=1<k?(15&d)<<2|f>>6:64,b=2<k?63&f:64,v.push(l.charAt(p)+l.charAt(m)+l.charAt(x)+l.charAt(b));return v.join("")},i.decode=function(c){var u,d,f,p,m,x,b=0,v=0,y="data:";if(c.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var S,k=3*(c=c.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(c.charAt(c.length-1)===l.charAt(64)&&k--,c.charAt(c.length-2)===l.charAt(64)&&k--,k%1!=0)throw new Error("Invalid base64 input, bad content length.");for(S=o.uint8array?new Uint8Array(0|k):new Array(0|k);b<c.length;)u=l.indexOf(c.charAt(b++))<<2|(p=l.indexOf(c.charAt(b++)))>>4,d=(15&p)<<4|(m=l.indexOf(c.charAt(b++)))>>2,f=(3&m)<<6|(x=l.indexOf(c.charAt(b++))),S[v++]=u,m!==64&&(S[v++]=d),x!==64&&(S[v++]=f);return S}},{"./support":30,"./utils":32}],2:[function(n,r,i){var a=n("./external"),o=n("./stream/DataWorker"),l=n("./stream/Crc32Probe"),c=n("./stream/DataLengthProbe");function u(d,f,p,m,x){this.compressedSize=d,this.uncompressedSize=f,this.crc32=p,this.compression=m,this.compressedContent=x}u.prototype={getContentWorker:function(){var d=new o(a.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new c("data_length")),f=this;return d.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),d},getCompressedWorker:function(){return new o(a.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},u.createWorkerFrom=function(d,f,p){return d.pipe(new l).pipe(new c("uncompressedSize")).pipe(f.compressWorker(p)).pipe(new c("compressedSize")).withStreamInfo("compression",f)},r.exports=u},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(n,r,i){var a=n("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new a("STORE compression")},uncompressWorker:function(){return new a("STORE decompression")}},i.DEFLATE=n("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(n,r,i){var a=n("./utils"),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?a.getTypeOf(l)!=="string"?(function(u,d,f,p){var m=o,x=p+f;u^=-1;for(var b=p;b<x;b++)u=u>>>8^m[255&(u^d[b])];return-1^u})(0|c,l,l.length,0):(function(u,d,f,p){var m=o,x=p+f;u^=-1;for(var b=p;b<x;b++)u=u>>>8^m[255&(u^d.charCodeAt(b))];return-1^u})(0|c,l,l.length,0):0}},{"./utils":32}],5:[function(n,r,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(n,r,i){var a=null;a=typeof Promise<"u"?Promise:n("lie"),r.exports={Promise:a}},{lie:37}],7:[function(n,r,i){var a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=n("pako"),l=n("./utils"),c=n("./stream/GenericWorker"),u=a?"uint8array":"array";function d(f,p){c.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=p,this.meta={}}i.magic="\b\0",l.inherits(d,c),d.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(l.transformTo(u,f.data),!1)},d.prototype.flush=function(){c.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},d.prototype.cleanUp=function(){c.prototype.cleanUp.call(this),this._pako=null},d.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(p){f.push({data:p,meta:f.meta})}},i.compressWorker=function(f){return new d("Deflate",f)},i.uncompressWorker=function(){return new d("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(n,r,i){function a(m,x){var b,v="";for(b=0;b<x;b++)v+=String.fromCharCode(255&m),m>>>=8;return v}function o(m,x,b,v,y,S){var k,T,M=m.file,C=m.compression,E=S!==u.utf8encode,R=l.transformTo("string",S(M.name)),A=l.transformTo("string",u.utf8encode(M.name)),D=M.comment,I=l.transformTo("string",S(D)),F=l.transformTo("string",u.utf8encode(D)),z=A.length!==M.name.length,P=F.length!==D.length,$="",X="",V="",Q=M.dir,Z=M.date,se={crc32:0,compressedSize:0,uncompressedSize:0};x&&!b||(se.crc32=m.crc32,se.compressedSize=m.compressedSize,se.uncompressedSize=m.uncompressedSize);var H=0;x&&(H|=8),E||!z&&!P||(H|=2048);var K=0,re=0;Q&&(K|=16),y==="UNIX"?(re=798,K|=(function(be,me){var de=be;return be||(de=me?16893:33204),(65535&de)<<16})(M.unixPermissions,Q)):(re=20,K|=(function(be){return 63&(be||0)})(M.dosPermissions)),k=Z.getUTCHours(),k<<=6,k|=Z.getUTCMinutes(),k<<=5,k|=Z.getUTCSeconds()/2,T=Z.getUTCFullYear()-1980,T<<=4,T|=Z.getUTCMonth()+1,T<<=5,T|=Z.getUTCDate(),z&&(X=a(1,1)+a(d(R),4)+A,$+="up"+a(X.length,2)+X),P&&(V=a(1,1)+a(d(I),4)+F,$+="uc"+a(V.length,2)+V);var ne="";return ne+=`
- \0`,ne+=a(H,2),ne+=C.magic,ne+=a(k,2),ne+=a(T,2),ne+=a(se.crc32,4),ne+=a(se.compressedSize,4),ne+=a(se.uncompressedSize,4),ne+=a(R.length,2),ne+=a($.length,2),{fileRecord:f.LOCAL_FILE_HEADER+ne+R+$,dirRecord:f.CENTRAL_FILE_HEADER+a(re,2)+ne+a(I.length,2)+"\0\0\0\0"+a(K,4)+a(v,4)+R+$+I}}var l=n("../utils"),c=n("../stream/GenericWorker"),u=n("../utf8"),d=n("../crc32"),f=n("../signature");function p(m,x,b,v){c.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=x,this.zipPlatform=b,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,b=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:b?(x+100*(b-v-1))/b: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 b=o(m,x,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:b.fileRecord,meta:{percent:0}})}else this.accumulate=!0},p.prototype.closedSource=function(m){this.accumulate=!1;var x=this.streamFiles&&!m.file.dir,b=o(m,x,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(b.dirRecord),x)this.push({data:(function(v){return f.DATA_DESCRIPTOR+a(v.crc32,4)+a(v.compressedSize,4)+a(v.uncompressedSize,4)})(m),meta:{percent:100}});else for(this.push({data:b.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 b=this.bytesWritten-m,v=(function(y,S,k,T,M){var C=l.transformTo("string",M(T));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+a(y,2)+a(y,2)+a(S,4)+a(k,4)+a(C.length,2)+C})(this.dirRecords.length,b,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(b){x.processChunk(b)}),m.on("end",function(){x.closedSource(x.previous.streamInfo),x._sources.length?x.prepareNextSource():x.end()}),m.on("error",function(b){x.error(b)}),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 b=0;b<x.length;b++)try{x[b].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 a=n("../compressions"),o=n("./ZipFileWorker");i.generateWorker=function(l,c,u){var d=new o(c.streamFiles,u,c.platform,c.encodeFileName),f=0;try{l.forEach(function(p,m){f++;var x=(function(S,k){var T=S||k,M=a[T];if(!M)throw new Error(T+" is not a valid compression method !");return M})(m.options.compression,c.compression),b=m.options.compressionOptions||c.compressionOptions||{},v=m.dir,y=m.date;m._compressWorker(x,b).withStreamInfo("file",{name:p,dir:v,date:y,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(d)}),d.entriesCount=f}catch(p){d.error(p)}return d}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(n,r,i){function a(){if(!(this instanceof a))return new a;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new a;for(var l in this)typeof this[l]!="function"&&(o[l]=this[l]);return o}}(a.prototype=n("./object")).loadAsync=n("./load"),a.support=n("./support"),a.defaults=n("./defaults"),a.version="3.10.1",a.loadAsync=function(o,l){return new a().loadAsync(o,l)},a.external=n("./external"),r.exports=a},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(n,r,i){var a=n("./utils"),o=n("./external"),l=n("./utf8"),c=n("./zipEntries"),u=n("./stream/Crc32Probe"),d=n("./nodejsUtils");function f(p){return new o.Promise(function(m,x){var b=p.decompressed.getContentWorker().pipe(new u);b.on("error",function(v){x(v)}).on("end",function(){b.streamInfo.crc32!==p.decompressed.crc32?x(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}r.exports=function(p,m){var x=this;return m=a.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.")):a.prepareContent("the loaded zip file",p,!0,m.optimizedBinaryString,m.base64).then(function(b){var v=new c(m);return v.load(b),v}).then(function(b){var v=[o.Promise.resolve(b)],y=b.files;if(m.checkCRC32)for(var S=0;S<y.length;S++)v.push(f(y[S]));return o.Promise.all(v)}).then(function(b){for(var v=b.shift(),y=v.files,S=0;S<y.length;S++){var k=y[S],T=k.fileNameStr,M=a.resolve(k.fileNameStr);x.file(M,k.decompressed,{binary:!0,optimizedBinaryString:!0,date:k.date,dir:k.dir,comment:k.fileCommentStr.length?k.fileCommentStr:null,unixPermissions:k.unixPermissions,dosPermissions:k.dosPermissions,createFolders:m.createFolders}),k.dir||(x.file(M).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 a=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)}a.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 a=n("readable-stream").Readable;function o(l,c,u){a.call(this,c),this._helper=l;var d=this;l.on("data",function(f,p){d.push(f)||d._helper.pause(),u&&u(p)}).on("error",function(f){d.emit("error",f)}).on("end",function(){d.push(null)})}n("../utils").inherits(o,a),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(a,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(a,o);if(typeof a=="number")throw new Error('The "data" argument must not be a number');return new Buffer(a,o)},allocBuffer:function(a){if(Buffer.alloc)return Buffer.alloc(a);var o=new Buffer(a);return o.fill(0),o},isBuffer:function(a){return Buffer.isBuffer(a)},isStream:function(a){return a&&typeof a.on=="function"&&typeof a.pause=="function"&&typeof a.resume=="function"}}},{}],15:[function(n,r,i){function a(M,C,E){var R,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&&(M=y(M)),D.createFolders&&(R=v(M))&&S.call(this,R,!0);var I=A==="string"&&D.binary===!1&&D.base64===!1;E&&E.binary!==void 0||(D.binary=!I),(C instanceof f&&C.uncompressedSize===0||D.dir||!C||C.length===0)&&(D.base64=!1,D.binary=!0,C="",D.compression="STORE",A="string");var F=null;F=C instanceof f||C instanceof c?C:x.isNode&&x.isStream(C)?new b(M,C):l.prepareContent(M,C,D.binary,D.optimizedBinaryString,D.base64);var z=new p(M,F,D);this.files[M]=z}var o=n("./utf8"),l=n("./utils"),c=n("./stream/GenericWorker"),u=n("./stream/StreamHelper"),d=n("./defaults"),f=n("./compressedObject"),p=n("./zipObject"),m=n("./generate"),x=n("./nodejsUtils"),b=n("./nodejs/NodejsStreamInputAdapter"),v=function(M){M.slice(-1)==="/"&&(M=M.substring(0,M.length-1));var C=M.lastIndexOf("/");return 0<C?M.substring(0,C):""},y=function(M){return M.slice(-1)!=="/"&&(M+="/"),M},S=function(M,C){return C=C!==void 0?C:d.createFolders,M=y(M),this.files[M]||a.call(this,M,null,{dir:!0,createFolders:C}),this.files[M]};function k(M){return Object.prototype.toString.call(M)==="[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(M){var C,E,R;for(C in this.files)R=this.files[C],(E=C.slice(this.root.length,C.length))&&C.slice(0,this.root.length)===this.root&&M(E,R)},filter:function(M){var C=[];return this.forEach(function(E,R){M(E,R)&&C.push(R)}),C},file:function(M,C,E){if(arguments.length!==1)return M=this.root+M,a.call(this,M,C,E),this;if(k(M)){var R=M;return this.filter(function(D,I){return!I.dir&&R.test(D)})}var A=this.files[this.root+M];return A&&!A.dir?A:null},folder:function(M){if(!M)return this;if(k(M))return this.filter(function(A,D){return D.dir&&M.test(A)});var C=this.root+M,E=S.call(this,C),R=this.clone();return R.root=E.name,R},remove:function(M){M=this.root+M;var C=this.files[M];if(C||(M.slice(-1)!=="/"&&(M+="/"),C=this.files[M]),C&&!C.dir)delete this.files[M];else for(var E=this.filter(function(A,D){return D.name.slice(0,M.length)===M}),R=0;R<E.length;R++)delete this.files[E[R].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(M){var C,E={};try{if((E=l.extend(M||{},{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 R=E.comment||this.comment||"";C=m.generateWorker(this,E,R)}catch(A){(C=new c("error")).error(A)}return new u(C,E.type||"string",E.mimeType)},generateAsync:function(M,C){return this.generateInternalStream(M).accumulate(C)},generateNodeStream:function(M,C){return(M=M||{}).type||(M.type="nodebuffer"),this.generateInternalStream(M).toNodejsStream(C)}};r.exports=T},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(n,r,i){r.exports=n("stream")},{stream:void 0}],17:[function(n,r,i){var a=n("./DataReader");function o(l){a.call(this,l);for(var c=0;c<this.data.length;c++)l[c]=255&l[c]}n("../utils").inherits(o,a),o.prototype.byteAt=function(l){return this.data[this.zero+l]},o.prototype.lastIndexOfSignature=function(l){for(var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),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]===f)return p-this.zero;return-1},o.prototype.readAndCheckSignature=function(l){var c=l.charCodeAt(0),u=l.charCodeAt(1),d=l.charCodeAt(2),f=l.charCodeAt(3),p=this.readData(4);return c===p[0]&&u===p[1]&&d===p[2]&&f===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 a=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 a.transformTo("string",this.readData(l))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var l=this.readInt(4);return new Date(Date.UTC(1980+(l>>25&127),(l>>21&15)-1,l>>16&31,l>>11&31,l>>5&63,(31&l)<<1))}},r.exports=o},{"../utils":32}],19:[function(n,r,i){var a=n("./Uint8ArrayReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),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 a=n("./DataReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),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 a=n("./ArrayReader");function o(l){a.call(this,l)}n("../utils").inherits(o,a),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 a=n("../utils"),o=n("../support"),l=n("./ArrayReader"),c=n("./StringReader"),u=n("./NodeBufferReader"),d=n("./Uint8ArrayReader");r.exports=function(f){var p=a.getTypeOf(f);return a.checkSupport(p),p!=="string"||o.uint8array?p==="nodebuffer"?new u(f):o.uint8array?new d(a.transformTo("uint8array",f)):new l(a.transformTo("array",f)):new c(f)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(n,r,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(n,r,i){var a=n("./GenericWorker"),o=n("../utils");function l(c){a.call(this,"ConvertWorker to "+c),this.destType=c}o.inherits(l,a),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 a=n("./GenericWorker"),o=n("../crc32");function l(){a.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}n("../utils").inherits(l,a),l.prototype.processChunk=function(c){this.streamInfo.crc32=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 a=n("../utils"),o=n("./GenericWorker");function l(c){o.call(this,"DataLengthProbe for "+c),this.propName=c,this.withStreamInfo(c,0)}a.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 a=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=a.getTypeOf(d),u.isPaused||u._tickAndRepeat()},function(d){u.error(d)})}a.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,a.delay(this._tickAndRepeat,[],this)),!0)},l.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(a.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},l.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var c=null,u=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":c=this.data.substring(this.index,u);break;case"uint8array":c=this.data.subarray(this.index,u);break;case"array":case"nodebuffer":c=this.data.slice(this.index,u)}return this.index=u,this.push({data:c,meta:{percent:this.max?this.index/this.max*100:0}})},r.exports=l},{"../utils":32,"./GenericWorker":28}],28:[function(n,r,i){function a(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}a.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=a},{}],29:[function(n,r,i){var a=n("../utils"),o=n("./ConvertWorker"),l=n("./GenericWorker"),c=n("../base64"),u=n("../support"),d=n("../external"),f=null;if(u.nodestream)try{f=n("../nodejs/NodejsStreamOutputAdapter")}catch{}function p(x,b){return new d.Promise(function(v,y){var S=[],k=x._internalType,T=x._outputType,M=x._mimeType;x.on("data",function(C,E){S.push(C),b&&b(E)}).on("error",function(C){S=[],y(C)}).on("end",function(){try{var C=(function(E,R,A){switch(E){case"blob":return a.newBlob(a.transformTo("arraybuffer",R),A);case"base64":return c.encode(R);default:return a.transformTo(E,R)}})(T,(function(E,R){var A,D=0,I=null,F=0;for(A=0;A<R.length;A++)F+=R[A].length;switch(E){case"string":return R.join("");case"array":return Array.prototype.concat.apply([],R);case"uint8array":for(I=new Uint8Array(F),A=0;A<R.length;A++)I.set(R[A],D),D+=R[A].length;return I;case"nodebuffer":return Buffer.concat(R);default:throw new Error("concat : unsupported type '"+E+"'")}})(k,S),M);v(C)}catch(E){y(E)}S=[]}).resume()})}function m(x,b,v){var y=b;switch(b){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=b,this._mimeType=v,a.checkSupport(y),this._worker=x.pipe(new o(y)),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,b){var v=this;return x==="data"?this._worker.on(x,function(y){b.call(v,y.data,y.meta)}):this._worker.on(x,function(){a.delay(b,arguments,v)}),this},resume:function(){return a.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(x){if(a.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},x)}},r.exports=m},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(n,r,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var a=new ArrayBuffer(0);try{i.blob=new Blob([a],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(a),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 a=n("./utils"),o=n("./support"),l=n("./nodejsUtils"),c=n("./stream/GenericWorker"),u=new Array(256),d=0;d<256;d++)u[d]=252<=d?6:248<=d?5:240<=d?4:224<=d?3:192<=d?2:1;u[254]=u[254]=1;function f(){c.call(this,"utf-8 decode"),this.leftOver=null}function p(){c.call(this,"utf-8 encode")}i.utf8encode=function(m){return o.nodebuffer?l.newBufferFrom(m,"utf-8"):(function(x){var b,v,y,S,k,T=x.length,M=0;for(S=0;S<T;S++)(64512&(v=x.charCodeAt(S)))==55296&&S+1<T&&(64512&(y=x.charCodeAt(S+1)))==56320&&(v=65536+(v-55296<<10)+(y-56320),S++),M+=v<128?1:v<2048?2:v<65536?3:4;for(b=o.uint8array?new Uint8Array(M):new Array(M),S=k=0;k<M;S++)(64512&(v=x.charCodeAt(S)))==55296&&S+1<T&&(64512&(y=x.charCodeAt(S+1)))==56320&&(v=65536+(v-55296<<10)+(y-56320),S++),v<128?b[k++]=v:(v<2048?b[k++]=192|v>>>6:(v<65536?b[k++]=224|v>>>12:(b[k++]=240|v>>>18,b[k++]=128|v>>>12&63),b[k++]=128|v>>>6&63),b[k++]=128|63&v);return b})(m)},i.utf8decode=function(m){return o.nodebuffer?a.transformTo("nodebuffer",m).toString("utf-8"):(function(x){var b,v,y,S,k=x.length,T=new Array(2*k);for(b=v=0;b<k;)if((y=x[b++])<128)T[v++]=y;else if(4<(S=u[y]))T[v++]=65533,b+=S-1;else{for(y&=S===2?31:S===3?15:7;1<S&&b<k;)y=y<<6|63&x[b++],S--;1<S?T[v++]=65533:y<65536?T[v++]=y:(y-=65536,T[v++]=55296|y>>10&1023,T[v++]=56320|1023&y)}return T.length!==v&&(T.subarray?T=T.subarray(0,v):T.length=v),a.applyFromCharCode(T)})(m=a.transformTo(o.uint8array?"uint8array":"array",m))},a.inherits(f,c),f.prototype.processChunk=function(m){var x=a.transformTo(o.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var b=x;(x=new Uint8Array(b.length+this.leftOver.length)).set(this.leftOver,0),x.set(b,this.leftOver.length)}else x=this.leftOver.concat(x);this.leftOver=null}var v=(function(S,k){var T;for((k=k||S.length)>S.length&&(k=S.length),T=k-1;0<=T&&(192&S[T])==128;)T--;return T<0||T===0?k:T+u[S[T]]>k?T:k})(x),y=x;v!==x.length&&(o.uint8array?(y=x.subarray(0,v),this.leftOver=x.subarray(v,x.length)):(y=x.slice(0,v),this.leftOver=x.slice(v,x.length))),this.push({data:i.utf8decode(y),meta:m.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,a.inherits(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 a=n("./support"),o=n("./base64"),l=n("./nodejsUtils"),c=n("./external");function u(b){return b}function d(b,v){for(var y=0;y<b.length;++y)v[y]=255&b.charCodeAt(y);return v}n("setimmediate"),i.newBlob=function(b,v){i.checkSupport("blob");try{return new Blob([b],{type:v})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(b),y.getBlob(v)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(b,v,y){var S=[],k=0,T=b.length;if(T<=y)return String.fromCharCode.apply(null,b);for(;k<T;)v==="array"||v==="nodebuffer"?S.push(String.fromCharCode.apply(null,b.slice(k,Math.min(k+y,T)))):S.push(String.fromCharCode.apply(null,b.subarray(k,Math.min(k+y,T)))),k+=y;return S.join("")},stringifyByChar:function(b){for(var v="",y=0;y<b.length;y++)v+=String.fromCharCode(b[y]);return v},applyCanBeUsed:{uint8array:(function(){try{return a.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return a.nodebuffer&&String.fromCharCode.apply(null,l.allocBuffer(1)).length===1}catch{return!1}})()}};function p(b){var v=65536,y=i.getTypeOf(b),S=!0;if(y==="uint8array"?S=f.applyCanBeUsed.uint8array:y==="nodebuffer"&&(S=f.applyCanBeUsed.nodebuffer),S)for(;1<v;)try{return f.stringifyByChunk(b,y,v)}catch{v=Math.floor(v/2)}return f.stringifyByChar(b)}function m(b,v){for(var y=0;y<b.length;y++)v[y]=b[y];return v}i.applyFromCharCode=p;var x={};x.string={string:u,array:function(b){return d(b,new Array(b.length))},arraybuffer:function(b){return x.string.uint8array(b).buffer},uint8array:function(b){return d(b,new Uint8Array(b.length))},nodebuffer:function(b){return d(b,l.allocBuffer(b.length))}},x.array={string:p,array:u,arraybuffer:function(b){return new Uint8Array(b).buffer},uint8array:function(b){return new Uint8Array(b)},nodebuffer:function(b){return l.newBufferFrom(b)}},x.arraybuffer={string:function(b){return p(new Uint8Array(b))},array:function(b){return m(new Uint8Array(b),new Array(b.byteLength))},arraybuffer:u,uint8array:function(b){return new Uint8Array(b)},nodebuffer:function(b){return l.newBufferFrom(new Uint8Array(b))}},x.uint8array={string:p,array:function(b){return m(b,new Array(b.length))},arraybuffer:function(b){return b.buffer},uint8array:u,nodebuffer:function(b){return l.newBufferFrom(b)}},x.nodebuffer={string:p,array:function(b){return m(b,new Array(b.length))},arraybuffer:function(b){return x.nodebuffer.uint8array(b).buffer},uint8array:function(b){return m(b,new Uint8Array(b.length))},nodebuffer:u},i.transformTo=function(b,v){if(v=v||"",!b)return v;i.checkSupport(b);var y=i.getTypeOf(v);return x[y][b](v)},i.resolve=function(b){for(var v=b.split("/"),y=[],S=0;S<v.length;S++){var k=v[S];k==="."||k===""&&S!==0&&S!==v.length-1||(k===".."?y.pop():y.push(k))}return y.join("/")},i.getTypeOf=function(b){return typeof b=="string"?"string":Object.prototype.toString.call(b)==="[object Array]"?"array":a.nodebuffer&&l.isBuffer(b)?"nodebuffer":a.uint8array&&b instanceof Uint8Array?"uint8array":a.arraybuffer&&b instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(b){if(!a[b.toLowerCase()])throw new Error(b+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(b){var v,y,S="";for(y=0;y<(b||"").length;y++)S+="\\x"+((v=b.charCodeAt(y))<16?"0":"")+v.toString(16).toUpperCase();return S},i.delay=function(b,v,y){setImmediate(function(){b.apply(y||null,v||[])})},i.inherits=function(b,v){function y(){}y.prototype=v.prototype,b.prototype=new y},i.extend=function(){var b,v,y={};for(b=0;b<arguments.length;b++)for(v in arguments[b])Object.prototype.hasOwnProperty.call(arguments[b],v)&&y[v]===void 0&&(y[v]=arguments[b][v]);return y},i.prepareContent=function(b,v,y,S,k){return c.Promise.resolve(v).then(function(T){return a.blob&&(T instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(T))!==-1)&&typeof FileReader<"u"?new c.Promise(function(M,C){var E=new FileReader;E.onload=function(R){M(R.target.result)},E.onerror=function(R){C(R.target.error)},E.readAsArrayBuffer(T)}):T}).then(function(T){var M=i.getTypeOf(T);return M?(M==="arraybuffer"?T=i.transformTo("uint8array",T):M==="string"&&(k?T=o.decode(T):y&&S!==!0&&(T=(function(C){return d(C,a.uint8array?new Uint8Array(C.length):new Array(C.length))})(T))),T):c.Promise.reject(new Error("Can't read the data of '"+b+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(n,r,i){var a=n("./reader/readerFor"),o=n("./utils"),l=n("./signature"),c=n("./zipEntry"),u=n("./support");function d(f){this.files=[],this.loadOptions=f}d.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var p=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(p)+", expected "+o.pretty(f)+")")}},isSignature:function(f,p){var m=this.reader.index;this.reader.setIndex(f);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 f=this.reader.readData(this.zipCommentLength),p=u.uint8array?"uint8array":"array",m=o.transformTo(p,f);this.zipComment=this.loadOptions.decodeFileName(m)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var f,p,m,x=this.zip64EndOfCentralSize-44;0<x;)f=this.reader.readInt(2),p=this.reader.readInt(4),m=this.reader.readData(p),this.zip64ExtensibleData[f]={id:f,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 f,p;for(f=0;f<this.files.length;f++)p=this.files[f],this.reader.setIndex(p.localHeaderOffset),this.checkSignature(l.LOCAL_FILE_HEADER),p.readLocalPart(this.reader),p.handleUTF8(),p.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(l.CENTRAL_FILE_HEADER);)(f=new c({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var f=this.reader.lastIndexOfSignature(l.CENTRAL_DIRECTORY_END);if(f<0)throw this.isSignature(0,l.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(f);var p=f;if(this.checkSignature(l.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(f=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(f),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,l.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(l.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var 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(f){this.reader=a(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},r.exports=d},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(n,r,i){var a=n("./reader/readerFor"),o=n("./utils"),l=n("./compressedObject"),c=n("./crc32"),u=n("./utf8"),d=n("./compressions"),f=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,b;if(m.skip(22),this.fileNameLength=m.readInt(2),b=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.skip(b),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 y in d)if(Object.prototype.hasOwnProperty.call(d,y)&&d[y].magic===v)return d[y];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=a(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,b,v,y=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<y;)x=m.readInt(2),b=m.readInt(2),v=m.readData(b),this.extraFields[x]={id:x,length:b,value:v};m.setIndex(y)},handleUTF8:function(){var m=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=u.utf8decode(this.fileName),this.fileCommentStr=u.utf8decode(this.fileComment);else{var x=this.findExtraFieldUnicodePath();if(x!==null)this.fileNameStr=x;else{var b=o.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(b)}var v=this.findExtraFieldUnicodeComment();if(v!==null)this.fileCommentStr=v;else{var y=o.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var x=a(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=a(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 a(x,b,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=b,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");a.prototype={internalStream:function(x){var b=null,v="string";try{if(!x)throw new Error("No output type specified.");var y=(v=x.toLowerCase())==="string"||v==="text";v!=="binarystring"&&v!=="text"||(v="string"),b=this._decompressWorker();var S=!this._dataBinary;S&&!y&&(b=b.pipe(new c.Utf8EncodeWorker)),!S&&y&&(b=b.pipe(new c.Utf8DecodeWorker))}catch(k){(b=new d("error")).error(k)}return new o(b,v,"")},async:function(x,b){return this.internalStream(x).accumulate(b)},nodeStream:function(x,b){return this.internalStream(x||"nodebuffer").toNodejsStream(b)},_compressWorker:function(x,b){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,b)},_decompressWorker:function(){return this._data instanceof u?this._data.getContentWorker():this._data instanceof d?this._data:new l(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],p=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<f.length;m++)a.prototype[f[m]]=p;r.exports=a},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(n,r,i){(function(a){var o,l,c=a.MutationObserver||a.WebKitMutationObserver;if(c){var u=0,d=new c(x),f=a.document.createTextNode("");d.observe(f,{characterData:!0}),o=function(){f.data=u=++u%2}}else if(a.setImmediate||a.MessageChannel===void 0)o="document"in a&&"onreadystatechange"in a.document.createElement("script")?function(){var b=a.document.createElement("script");b.onreadystatechange=function(){x(),b.onreadystatechange=null,b.parentNode.removeChild(b),b=null},a.document.documentElement.appendChild(b)}:function(){setTimeout(x,0)};else{var p=new a.MessageChannel;p.port1.onmessage=x,o=function(){p.port2.postMessage(0)}}var m=[];function x(){var b,v;l=!0;for(var y=m.length;y;){for(v=m,m=[],b=-1;++b<y;)v[b]();y=m.length}l=!1}r.exports=function(b){m.push(b)!==1||l||o()}}).call(this,typeof Cw<"u"?Cw:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(n,r,i){var a=n("immediate");function o(){}var l={},c=["REJECTED"],u=["FULFILLED"],d=["PENDING"];function f(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=d,this.queue=[],this.outcome=void 0,y!==o&&b(this,y)}function p(y,S,k){this.promise=y,typeof S=="function"&&(this.onFulfilled=S,this.callFulfilled=this.otherCallFulfilled),typeof k=="function"&&(this.onRejected=k,this.callRejected=this.otherCallRejected)}function m(y,S,k){a(function(){var T;try{T=S(k)}catch(M){return l.reject(y,M)}T===y?l.reject(y,new TypeError("Cannot resolve promise with itself")):l.resolve(y,T)})}function x(y){var S=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof S=="function")return function(){S.apply(y,arguments)}}function b(y,S){var k=!1;function T(E){k||(k=!0,l.reject(y,E))}function M(E){k||(k=!0,l.resolve(y,E))}var C=v(function(){S(M,T)});C.status==="error"&&T(C.value)}function v(y,S){var k={};try{k.value=y(S),k.status="success"}catch(T){k.status="error",k.value=T}return k}(r.exports=f).prototype.finally=function(y){if(typeof y!="function")return this;var S=this.constructor;return this.then(function(k){return S.resolve(y()).then(function(){return k})},function(k){return S.resolve(y()).then(function(){throw k})})},f.prototype.catch=function(y){return this.then(null,y)},f.prototype.then=function(y,S){if(typeof y!="function"&&this.state===u||typeof S!="function"&&this.state===c)return this;var k=new this.constructor(o);return this.state!==d?m(k,this.state===u?y:S,this.outcome):this.queue.push(new p(k,y,S)),k},p.prototype.callFulfilled=function(y){l.resolve(this.promise,y)},p.prototype.otherCallFulfilled=function(y){m(this.promise,this.onFulfilled,y)},p.prototype.callRejected=function(y){l.reject(this.promise,y)},p.prototype.otherCallRejected=function(y){m(this.promise,this.onRejected,y)},l.resolve=function(y,S){var k=v(x,S);if(k.status==="error")return l.reject(y,k.value);var T=k.value;if(T)b(y,T);else{y.state=u,y.outcome=S;for(var M=-1,C=y.queue.length;++M<C;)y.queue[M].callFulfilled(S)}return y},l.reject=function(y,S){y.state=c,y.outcome=S;for(var k=-1,T=y.queue.length;++k<T;)y.queue[k].callRejected(S);return y},f.resolve=function(y){return y instanceof this?y:l.resolve(new this(o),y)},f.reject=function(y){var S=new this(o);return l.reject(S,y)},f.all=function(y){var S=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=y.length,T=!1;if(!k)return this.resolve([]);for(var M=new Array(k),C=0,E=-1,R=new this(o);++E<k;)A(y[E],E);return R;function A(D,I){S.resolve(D).then(function(F){M[I]=F,++C!==k||T||(T=!0,l.resolve(R,M))},function(F){T||(T=!0,l.reject(R,F))})}},f.race=function(y){var S=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var k=y.length,T=!1;if(!k)return this.resolve([]);for(var M=-1,C=new this(o);++M<k;)E=y[M],S.resolve(E).then(function(R){T||(T=!0,l.resolve(C,R))},function(R){T||(T=!0,l.reject(C,R))});var E;return C}},{immediate:36}],38:[function(n,r,i){var a={};(0,n("./lib/utils/common").assign)(a,n("./lib/deflate"),n("./lib/inflate"),n("./lib/zlib/constants")),r.exports=a},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(n,r,i){var a=n("./zlib/deflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/messages"),u=n("./zlib/zstream"),d=Object.prototype.toString,f=0,p=-1,m=0,x=8;function b(y){if(!(this instanceof b))return new b(y);this.options=o.assign({level:p,method:x,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},y||{});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 k=a.deflateInit2(this.strm,S.level,S.method,S.windowBits,S.memLevel,S.strategy);if(k!==f)throw new Error(c[k]);if(S.header&&a.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,(k=a.deflateSetDictionary(this.strm,T))!==f)throw new Error(c[k]);this._dict_set=!0}}function v(y,S){var k=new b(S);if(k.push(y,!0),k.err)throw k.msg||c[k.err];return k.result}b.prototype.push=function(y,S){var k,T,M=this.strm,C=this.options.chunkSize;if(this.ended)return!1;T=S===~~S?S:S===!0?4:0,typeof y=="string"?M.input=l.string2buf(y):d.call(y)==="[object ArrayBuffer]"?M.input=new Uint8Array(y):M.input=y,M.next_in=0,M.avail_in=M.input.length;do{if(M.avail_out===0&&(M.output=new o.Buf8(C),M.next_out=0,M.avail_out=C),(k=a.deflate(M,T))!==1&&k!==f)return this.onEnd(k),!(this.ended=!0);M.avail_out!==0&&(M.avail_in!==0||T!==4&&T!==2)||(this.options.to==="string"?this.onData(l.buf2binstring(o.shrinkBuf(M.output,M.next_out))):this.onData(o.shrinkBuf(M.output,M.next_out)))}while((0<M.avail_in||M.avail_out===0)&&k!==1);return T===4?(k=a.deflateEnd(this.strm),this.onEnd(k),this.ended=!0,k===f):T!==2||(this.onEnd(f),!(M.avail_out=0))},b.prototype.onData=function(y){this.chunks.push(y)},b.prototype.onEnd=function(y){y===f&&(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.Deflate=b,i.deflate=v,i.deflateRaw=function(y,S){return(S=S||{}).raw=!0,v(y,S)},i.gzip=function(y,S){return(S=S||{}).gzip=!0,v(y,S)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(n,r,i){var a=n("./zlib/inflate"),o=n("./utils/common"),l=n("./utils/strings"),c=n("./zlib/constants"),u=n("./zlib/messages"),d=n("./zlib/zstream"),f=n("./zlib/gzheader"),p=Object.prototype.toString;function m(b){if(!(this instanceof m))return new m(b);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},b||{});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)||b&&b.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 y=a.inflateInit2(this.strm,v.windowBits);if(y!==c.Z_OK)throw new Error(u[y]);this.header=new f,a.inflateGetHeader(this.strm,this.header)}function x(b,v){var y=new m(v);if(y.push(b,!0),y.err)throw y.msg||u[y.err];return y.result}m.prototype.push=function(b,v){var y,S,k,T,M,C,E=this.strm,R=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 b=="string"?E.input=l.binstring2buf(b):p.call(b)==="[object ArrayBuffer]"?E.input=new Uint8Array(b):E.input=b,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new o.Buf8(R),E.next_out=0,E.avail_out=R),(y=a.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,y=a.inflateSetDictionary(this.strm,C)),y===c.Z_BUF_ERROR&&D===!0&&(y=c.Z_OK,D=!1),y!==c.Z_STREAM_END&&y!==c.Z_OK)return this.onEnd(y),!(this.ended=!0);E.next_out&&(E.avail_out!==0&&y!==c.Z_STREAM_END&&(E.avail_in!==0||S!==c.Z_FINISH&&S!==c.Z_SYNC_FLUSH)||(this.options.to==="string"?(k=l.utf8border(E.output,E.next_out),T=E.next_out-k,M=l.buf2string(E.output,k),E.next_out=T,E.avail_out=R-T,T&&o.arraySet(E.output,E.output,k,T,0),this.onData(M)):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)&&y!==c.Z_STREAM_END);return y===c.Z_STREAM_END&&(S=c.Z_FINISH),S===c.Z_FINISH?(y=a.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===c.Z_OK):S!==c.Z_SYNC_FLUSH||(this.onEnd(c.Z_OK),!(E.avail_out=0))},m.prototype.onData=function(b){this.chunks.push(b)},m.prototype.onEnd=function(b){b===c.Z_OK&&(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.Inflate=m,i.inflate=x,i.inflateRaw=function(b,v){return(v=v||{}).raw=!0,x(b,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 a=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(c){for(var u=Array.prototype.slice.call(arguments,1);u.length;){var d=u.shift();if(d){if(typeof d!="object")throw new TypeError(d+"must be non-object");for(var f in d)d.hasOwnProperty(f)&&(c[f]=d[f])}}return c},i.shrinkBuf=function(c,u){return c.length===u?c:c.subarray?c.subarray(0,u):(c.length=u,c)};var o={arraySet:function(c,u,d,f,p){if(u.subarray&&c.subarray)c.set(u.subarray(d,d+f),p);else for(var m=0;m<f;m++)c[p+m]=u[d+m]},flattenChunks:function(c){var u,d,f,p,m,x;for(u=f=0,d=c.length;u<d;u++)f+=c[u].length;for(x=new Uint8Array(f),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,f,p){for(var m=0;m<f;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(a)},{}],42:[function(n,r,i){var a=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 a.Buf8(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function d(f,p){if(p<65537&&(f.subarray&&l||!f.subarray&&o))return String.fromCharCode.apply(null,a.shrinkBuf(f,p));for(var m="",x=0;x<p;x++)m+=String.fromCharCode(f[x]);return m}c[254]=c[254]=1,i.string2buf=function(f){var p,m,x,b,v,y=f.length,S=0;for(b=0;b<y;b++)(64512&(m=f.charCodeAt(b)))==55296&&b+1<y&&(64512&(x=f.charCodeAt(b+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),b++),S+=m<128?1:m<2048?2:m<65536?3:4;for(p=new a.Buf8(S),b=v=0;v<S;b++)(64512&(m=f.charCodeAt(b)))==55296&&b+1<y&&(64512&(x=f.charCodeAt(b+1)))==56320&&(m=65536+(m-55296<<10)+(x-56320),b++),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(f){return d(f,f.length)},i.binstring2buf=function(f){for(var p=new a.Buf8(f.length),m=0,x=p.length;m<x;m++)p[m]=f.charCodeAt(m);return p},i.buf2string=function(f,p){var m,x,b,v,y=p||f.length,S=new Array(2*y);for(m=x=0;m<y;)if((b=f[m++])<128)S[x++]=b;else if(4<(v=c[b]))S[x++]=65533,m+=v-1;else{for(b&=v===2?31:v===3?15:7;1<v&&m<y;)b=b<<6|63&f[m++],v--;1<v?S[x++]=65533:b<65536?S[x++]=b:(b-=65536,S[x++]=55296|b>>10&1023,S[x++]=56320|1023&b)}return d(S,x)},i.utf8border=function(f,p){var m;for((p=p||f.length)>f.length&&(p=f.length),m=p-1;0<=m&&(192&f[m])==128;)m--;return m<0||m===0?p:m+c[f[m]]>p?m:p}},{"./common":41}],43:[function(n,r,i){r.exports=function(a,o,l,c){for(var u=65535&a|0,d=a>>>16&65535|0,f=0;l!==0;){for(l-=f=2e3<l?2e3:l;d=d+(u=u+o[c++]|0)|0,--f;);u%=65521,d%=65521}return u|d<<16|0}},{}],44:[function(n,r,i){r.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(n,r,i){var a=(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=a,f=u+c;o^=-1;for(var p=u;p<f;p++)o=o>>>8^d[255&(o^l[p])];return-1^o}},{}],46:[function(n,r,i){var a,o=n("../utils/common"),l=n("./trees"),c=n("./adler32"),u=n("./crc32"),d=n("./messages"),f=0,p=4,m=0,x=-2,b=-1,v=4,y=2,S=8,k=9,T=286,M=30,C=19,E=2*T+1,R=15,A=3,D=258,I=D+A+1,F=42,z=113,P=1,$=2,X=3,V=4;function Q(G,Y){return G.msg=d[Y],Y}function Z(G){return(G<<1)-(4<G?9:0)}function se(G){for(var Y=G.length;0<=--Y;)G[Y]=0}function H(G){var Y=G.state,ue=Y.pending;ue>G.avail_out&&(ue=G.avail_out),ue!==0&&(o.arraySet(G.output,Y.pending_buf,Y.pending_out,ue,G.next_out),G.next_out+=ue,Y.pending_out+=ue,G.total_out+=ue,G.avail_out-=ue,Y.pending-=ue,Y.pending===0&&(Y.pending_out=0))}function K(G,Y){l._tr_flush_block(G,0<=G.block_start?G.block_start:-1,G.strstart-G.block_start,Y),G.block_start=G.strstart,H(G.strm)}function re(G,Y){G.pending_buf[G.pending++]=Y}function ne(G,Y){G.pending_buf[G.pending++]=Y>>>8&255,G.pending_buf[G.pending++]=255&Y}function be(G,Y){var ue,q,te=G.max_chain_length,U=G.strstart,he=G.prev_length,Me=G.nice_match,ge=G.strstart>G.w_size-I?G.strstart-(G.w_size-I):0,B=G.window,O=G.w_mask,ee=G.prev,le=G.strstart+D,_e=B[U+he-1],ve=B[U+he];G.prev_length>=G.good_match&&(te>>=2),Me>G.lookahead&&(Me=G.lookahead);do if(B[(ue=Y)+he]===ve&&B[ue+he-1]===_e&&B[ue]===B[U]&&B[++ue]===B[U+1]){U+=2,ue++;do;while(B[++U]===B[++ue]&&B[++U]===B[++ue]&&B[++U]===B[++ue]&&B[++U]===B[++ue]&&B[++U]===B[++ue]&&B[++U]===B[++ue]&&B[++U]===B[++ue]&&B[++U]===B[++ue]&&U<le);if(q=D-(le-U),U=le-D,he<q){if(G.match_start=Y,Me<=(he=q))break;_e=B[U+he-1],ve=B[U+he]}}while((Y=ee[Y&O])>ge&&--te!=0);return he<=G.lookahead?he:G.lookahead}function me(G){var Y,ue,q,te,U,he,Me,ge,B,O,ee=G.w_size;do{if(te=G.window_size-G.lookahead-G.strstart,G.strstart>=ee+(ee-I)){for(o.arraySet(G.window,G.window,ee,ee,0),G.match_start-=ee,G.strstart-=ee,G.block_start-=ee,Y=ue=G.hash_size;q=G.head[--Y],G.head[Y]=ee<=q?q-ee:0,--ue;);for(Y=ue=ee;q=G.prev[--Y],G.prev[Y]=ee<=q?q-ee:0,--ue;);te+=ee}if(G.strm.avail_in===0)break;if(he=G.strm,Me=G.window,ge=G.strstart+G.lookahead,B=te,O=void 0,O=he.avail_in,B<O&&(O=B),ue=O===0?0:(he.avail_in-=O,o.arraySet(Me,he.input,he.next_in,O,ge),he.state.wrap===1?he.adler=c(he.adler,Me,O,ge):he.state.wrap===2&&(he.adler=u(he.adler,Me,O,ge)),he.next_in+=O,he.total_in+=O,O),G.lookahead+=ue,G.lookahead+G.insert>=A)for(U=G.strstart-G.insert,G.ins_h=G.window[U],G.ins_h=(G.ins_h<<G.hash_shift^G.window[U+1])&G.hash_mask;G.insert&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[U+A-1])&G.hash_mask,G.prev[U&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=U,U++,G.insert--,!(G.lookahead+G.insert<A)););}while(G.lookahead<I&&G.strm.avail_in!==0)}function de(G,Y){for(var ue,q;;){if(G.lookahead<I){if(me(G),G.lookahead<I&&Y===f)return P;if(G.lookahead===0)break}if(ue=0,G.lookahead>=A&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+A-1])&G.hash_mask,ue=G.prev[G.strstart&G.w_mask]=G.head[G.ins_h],G.head[G.ins_h]=G.strstart),ue!==0&&G.strstart-ue<=G.w_size-I&&(G.match_length=be(G,ue)),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,ue=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&&(K(G,!1),G.strm.avail_out===0))return P}return G.insert=G.strstart<A-1?G.strstart:A-1,Y===p?(K(G,!0),G.strm.avail_out===0?X:V):G.last_lit&&(K(G,!1),G.strm.avail_out===0)?P:$}function Ce(G,Y){for(var ue,q,te;;){if(G.lookahead<I){if(me(G),G.lookahead<I&&Y===f)return P;if(G.lookahead===0)break}if(ue=0,G.lookahead>=A&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+A-1])&G.hash_mask,ue=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,ue!==0&&G.prev_length<G.max_lazy_match&&G.strstart-ue<=G.w_size-I&&(G.match_length=be(G,ue),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(te=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<=te&&(G.ins_h=(G.ins_h<<G.hash_shift^G.window[G.strstart+A-1])&G.hash_mask,ue=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&&(K(G,!1),G.strm.avail_out===0))return P}else if(G.match_available){if((q=l._tr_tally(G,0,G.window[G.strstart-1]))&&K(G,!1),G.strstart++,G.lookahead--,G.strm.avail_out===0)return P}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,Y===p?(K(G,!0),G.strm.avail_out===0?X:V):G.last_lit&&(K(G,!1),G.strm.avail_out===0)?P:$}function ie(G,Y,ue,q,te){this.good_length=G,this.max_lazy=Y,this.nice_length=ue,this.max_chain=q,this.func=te}function ke(){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*M+1)),this.bl_tree=new o.Buf16(2*(2*C+1)),se(this.dyn_ltree),se(this.dyn_dtree),se(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(R+1),this.heap=new o.Buf16(2*T+1),se(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(2*T+1),se(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 Oe(G){var Y;return G&&G.state?(G.total_in=G.total_out=0,G.data_type=y,(Y=G.state).pending=0,Y.pending_out=0,Y.wrap<0&&(Y.wrap=-Y.wrap),Y.status=Y.wrap?F:z,G.adler=Y.wrap===2?0:1,Y.last_flush=f,l._tr_init(Y),m):Q(G,x)}function pe(G){var Y=Oe(G);return Y===m&&(function(ue){ue.window_size=2*ue.w_size,se(ue.head),ue.max_lazy_match=a[ue.level].max_lazy,ue.good_match=a[ue.level].good_length,ue.nice_match=a[ue.level].nice_length,ue.max_chain_length=a[ue.level].max_chain,ue.strstart=0,ue.block_start=0,ue.lookahead=0,ue.insert=0,ue.match_length=ue.prev_length=A-1,ue.match_available=0,ue.ins_h=0})(G.state),Y}function We(G,Y,ue,q,te,U){if(!G)return x;var he=1;if(Y===b&&(Y=6),q<0?(he=0,q=-q):15<q&&(he=2,q-=16),te<1||k<te||ue!==S||q<8||15<q||Y<0||9<Y||U<0||v<U)return Q(G,x);q===8&&(q=9);var Me=new ke;return(G.state=Me).strm=G,Me.wrap=he,Me.gzhead=null,Me.w_bits=q,Me.w_size=1<<Me.w_bits,Me.w_mask=Me.w_size-1,Me.hash_bits=te+7,Me.hash_size=1<<Me.hash_bits,Me.hash_mask=Me.hash_size-1,Me.hash_shift=~~((Me.hash_bits+A-1)/A),Me.window=new o.Buf8(2*Me.w_size),Me.head=new o.Buf16(Me.hash_size),Me.prev=new o.Buf16(Me.w_size),Me.lit_bufsize=1<<te+6,Me.pending_buf_size=4*Me.lit_bufsize,Me.pending_buf=new o.Buf8(Me.pending_buf_size),Me.d_buf=1*Me.lit_bufsize,Me.l_buf=3*Me.lit_bufsize,Me.level=Y,Me.strategy=U,Me.method=ue,pe(G)}a=[new ie(0,0,0,0,function(G,Y){var ue=65535;for(ue>G.pending_buf_size-5&&(ue=G.pending_buf_size-5);;){if(G.lookahead<=1){if(me(G),G.lookahead===0&&Y===f)return P;if(G.lookahead===0)break}G.strstart+=G.lookahead,G.lookahead=0;var q=G.block_start+ue;if((G.strstart===0||G.strstart>=q)&&(G.lookahead=G.strstart-q,G.strstart=q,K(G,!1),G.strm.avail_out===0)||G.strstart-G.block_start>=G.w_size-I&&(K(G,!1),G.strm.avail_out===0))return P}return G.insert=0,Y===p?(K(G,!0),G.strm.avail_out===0?X:V):(G.strstart>G.block_start&&(K(G,!1),G.strm.avail_out),P)}),new ie(4,4,8,4,de),new ie(4,5,16,8,de),new ie(4,6,32,32,de),new ie(4,4,16,16,Ce),new ie(8,16,32,32,Ce),new ie(8,16,128,128,Ce),new ie(8,32,128,256,Ce),new ie(32,128,258,1024,Ce),new ie(32,258,258,4096,Ce)],i.deflateInit=function(G,Y){return We(G,Y,S,15,8,0)},i.deflateInit2=We,i.deflateReset=pe,i.deflateResetKeep=Oe,i.deflateSetHeader=function(G,Y){return G&&G.state?G.state.wrap!==2?x:(G.state.gzhead=Y,m):x},i.deflate=function(G,Y){var ue,q,te,U;if(!G||!G.state||5<Y||Y<0)return G?Q(G,x):x;if(q=G.state,!G.output||!G.input&&G.avail_in!==0||q.status===666&&Y!==p)return Q(G,G.avail_out===0?-5:x);if(q.strm=G,ue=q.last_flush,q.last_flush=Y,q.status===F)if(q.wrap===2)G.adler=0,re(q,31),re(q,139),re(q,8),q.gzhead?(re(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)),re(q,255&q.gzhead.time),re(q,q.gzhead.time>>8&255),re(q,q.gzhead.time>>16&255),re(q,q.gzhead.time>>24&255),re(q,q.level===9?2:2<=q.strategy||q.level<2?4:0),re(q,255&q.gzhead.os),q.gzhead.extra&&q.gzhead.extra.length&&(re(q,255&q.gzhead.extra.length),re(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):(re(q,0),re(q,0),re(q,0),re(q,0),re(q,0),re(q,q.level===9?2:2<=q.strategy||q.level<2?4:0),re(q,3),q.status=z);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=z,ne(q,he),q.strstart!==0&&(ne(q,G.adler>>>16),ne(q,65535&G.adler)),G.adler=1}if(q.status===69)if(q.gzhead.extra){for(te=q.pending;q.gzindex<(65535&q.gzhead.extra.length)&&(q.pending!==q.pending_buf_size||(q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),H(G),te=q.pending,q.pending!==q.pending_buf_size));)re(q,255&q.gzhead.extra[q.gzindex]),q.gzindex++;q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),q.gzindex===q.gzhead.extra.length&&(q.gzindex=0,q.status=73)}else q.status=73;if(q.status===73)if(q.gzhead.name){te=q.pending;do{if(q.pending===q.pending_buf_size&&(q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),H(G),te=q.pending,q.pending===q.pending_buf_size)){U=1;break}U=q.gzindex<q.gzhead.name.length?255&q.gzhead.name.charCodeAt(q.gzindex++):0,re(q,U)}while(U!==0);q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),U===0&&(q.gzindex=0,q.status=91)}else q.status=91;if(q.status===91)if(q.gzhead.comment){te=q.pending;do{if(q.pending===q.pending_buf_size&&(q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),H(G),te=q.pending,q.pending===q.pending_buf_size)){U=1;break}U=q.gzindex<q.gzhead.comment.length?255&q.gzhead.comment.charCodeAt(q.gzindex++):0,re(q,U)}while(U!==0);q.gzhead.hcrc&&q.pending>te&&(G.adler=u(G.adler,q.pending_buf,q.pending-te,te)),U===0&&(q.status=103)}else q.status=103;if(q.status===103&&(q.gzhead.hcrc?(q.pending+2>q.pending_buf_size&&H(G),q.pending+2<=q.pending_buf_size&&(re(q,255&G.adler),re(q,G.adler>>8&255),G.adler=0,q.status=z)):q.status=z),q.pending!==0){if(H(G),G.avail_out===0)return q.last_flush=-1,m}else if(G.avail_in===0&&Z(Y)<=Z(ue)&&Y!==p)return Q(G,-5);if(q.status===666&&G.avail_in!==0)return Q(G,-5);if(G.avail_in!==0||q.lookahead!==0||Y!==f&&q.status!==666){var Me=q.strategy===2?(function(ge,B){for(var O;;){if(ge.lookahead===0&&(me(ge),ge.lookahead===0)){if(B===f)return P;break}if(ge.match_length=0,O=l._tr_tally(ge,0,ge.window[ge.strstart]),ge.lookahead--,ge.strstart++,O&&(K(ge,!1),ge.strm.avail_out===0))return P}return ge.insert=0,B===p?(K(ge,!0),ge.strm.avail_out===0?X:V):ge.last_lit&&(K(ge,!1),ge.strm.avail_out===0)?P:$})(q,Y):q.strategy===3?(function(ge,B){for(var O,ee,le,_e,ve=ge.window;;){if(ge.lookahead<=D){if(me(ge),ge.lookahead<=D&&B===f)return P;if(ge.lookahead===0)break}if(ge.match_length=0,ge.lookahead>=A&&0<ge.strstart&&(ee=ve[le=ge.strstart-1])===ve[++le]&&ee===ve[++le]&&ee===ve[++le]){_e=ge.strstart+D;do;while(ee===ve[++le]&&ee===ve[++le]&&ee===ve[++le]&&ee===ve[++le]&&ee===ve[++le]&&ee===ve[++le]&&ee===ve[++le]&&ee===ve[++le]&&le<_e);ge.match_length=D-(_e-le),ge.match_length>ge.lookahead&&(ge.match_length=ge.lookahead)}if(ge.match_length>=A?(O=l._tr_tally(ge,1,ge.match_length-A),ge.lookahead-=ge.match_length,ge.strstart+=ge.match_length,ge.match_length=0):(O=l._tr_tally(ge,0,ge.window[ge.strstart]),ge.lookahead--,ge.strstart++),O&&(K(ge,!1),ge.strm.avail_out===0))return P}return ge.insert=0,B===p?(K(ge,!0),ge.strm.avail_out===0?X:V):ge.last_lit&&(K(ge,!1),ge.strm.avail_out===0)?P:$})(q,Y):a[q.level].func(q,Y);if(Me!==X&&Me!==V||(q.status=666),Me===P||Me===X)return G.avail_out===0&&(q.last_flush=-1),m;if(Me===$&&(Y===1?l._tr_align(q):Y!==5&&(l._tr_stored_block(q,0,0,!1),Y===3&&(se(q.head),q.lookahead===0&&(q.strstart=0,q.block_start=0,q.insert=0))),H(G),G.avail_out===0))return q.last_flush=-1,m}return Y!==p?m:q.wrap<=0?1:(q.wrap===2?(re(q,255&G.adler),re(q,G.adler>>8&255),re(q,G.adler>>16&255),re(q,G.adler>>24&255),re(q,255&G.total_in),re(q,G.total_in>>8&255),re(q,G.total_in>>16&255),re(q,G.total_in>>24&255)):(ne(q,G.adler>>>16),ne(q,65535&G.adler)),H(G),0<q.wrap&&(q.wrap=-q.wrap),q.pending!==0?m:1)},i.deflateEnd=function(G){var Y;return G&&G.state?(Y=G.state.status)!==F&&Y!==69&&Y!==73&&Y!==91&&Y!==103&&Y!==z&&Y!==666?Q(G,x):(G.state=null,Y===z?Q(G,-3):m):x},i.deflateSetDictionary=function(G,Y){var ue,q,te,U,he,Me,ge,B,O=Y.length;if(!G||!G.state||(U=(ue=G.state).wrap)===2||U===1&&ue.status!==F||ue.lookahead)return x;for(U===1&&(G.adler=c(G.adler,Y,O,0)),ue.wrap=0,O>=ue.w_size&&(U===0&&(se(ue.head),ue.strstart=0,ue.block_start=0,ue.insert=0),B=new o.Buf8(ue.w_size),o.arraySet(B,Y,O-ue.w_size,ue.w_size,0),Y=B,O=ue.w_size),he=G.avail_in,Me=G.next_in,ge=G.input,G.avail_in=O,G.next_in=0,G.input=Y,me(ue);ue.lookahead>=A;){for(q=ue.strstart,te=ue.lookahead-(A-1);ue.ins_h=(ue.ins_h<<ue.hash_shift^ue.window[q+A-1])&ue.hash_mask,ue.prev[q&ue.w_mask]=ue.head[ue.ins_h],ue.head[ue.ins_h]=q,q++,--te;);ue.strstart=q,ue.lookahead=A-1,me(ue)}return ue.strstart+=ue.lookahead,ue.block_start=ue.strstart,ue.insert=ue.lookahead,ue.lookahead=0,ue.match_length=ue.prev_length=A-1,ue.match_available=0,G.next_in=Me,G.input=ge,G.avail_in=he,ue.wrap=U,m},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(n,r,i){r.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(n,r,i){r.exports=function(a,o){var l,c,u,d,f,p,m,x,b,v,y,S,k,T,M,C,E,R,A,D,I,F,z,P,$;l=a.state,c=a.next_in,P=a.input,u=c+(a.avail_in-5),d=a.next_out,$=a.output,f=d-(o-a.avail_out),p=d+(a.avail_out-257),m=l.dmax,x=l.wsize,b=l.whave,v=l.wnext,y=l.window,S=l.hold,k=l.bits,T=l.lencode,M=l.distcode,C=(1<<l.lenbits)-1,E=(1<<l.distbits)-1;e:do{k<15&&(S+=P[c++]<<k,k+=8,S+=P[c++]<<k,k+=8),R=T[S&C];t:for(;;){if(S>>>=A=R>>>24,k-=A,(A=R>>>16&255)===0)$[d++]=65535&R;else{if(!(16&A)){if((64&A)==0){R=T[(65535&R)+(S&(1<<A)-1)];continue t}if(32&A){l.mode=12;break e}a.msg="invalid literal/length code",l.mode=30;break e}D=65535&R,(A&=15)&&(k<A&&(S+=P[c++]<<k,k+=8),D+=S&(1<<A)-1,S>>>=A,k-=A),k<15&&(S+=P[c++]<<k,k+=8,S+=P[c++]<<k,k+=8),R=M[S&E];n:for(;;){if(S>>>=A=R>>>24,k-=A,!(16&(A=R>>>16&255))){if((64&A)==0){R=M[(65535&R)+(S&(1<<A)-1)];continue n}a.msg="invalid distance code",l.mode=30;break e}if(I=65535&R,k<(A&=15)&&(S+=P[c++]<<k,(k+=8)<A&&(S+=P[c++]<<k,k+=8)),m<(I+=S&(1<<A)-1)){a.msg="invalid distance too far back",l.mode=30;break e}if(S>>>=A,k-=A,(A=d-f)<I){if(b<(A=I-A)&&l.sane){a.msg="invalid distance too far back",l.mode=30;break e}if(z=y,(F=0)===v){if(F+=x-A,A<D){for(D-=A;$[d++]=y[F++],--A;);F=d-I,z=$}}else if(v<A){if(F+=x+v-A,(A-=v)<D){for(D-=A;$[d++]=y[F++],--A;);if(F=0,v<D){for(D-=A=v;$[d++]=y[F++],--A;);F=d-I,z=$}}}else if(F+=v-A,A<D){for(D-=A;$[d++]=y[F++],--A;);F=d-I,z=$}for(;2<D;)$[d++]=z[F++],$[d++]=z[F++],$[d++]=z[F++],D-=3;D&&($[d++]=z[F++],1<D&&($[d++]=z[F++]))}else{for(F=d-I;$[d++]=$[F++],$[d++]=$[F++],$[d++]=$[F++],2<(D-=3););D&&($[d++]=$[F++],1<D&&($[d++]=$[F++]))}break}}break}}while(c<u&&d<p);c-=D=k>>3,S&=(1<<(k-=D<<3))-1,a.next_in=c,a.next_out=d,a.avail_in=c<u?u-c+5:5-(c-u),a.avail_out=d<p?p-d+257:257-(d-p),l.hold=S,l.bits=k}},{}],49:[function(n,r,i){var a=n("../utils/common"),o=n("./adler32"),l=n("./crc32"),c=n("./inffast"),u=n("./inftrees"),d=1,f=2,p=0,m=-2,x=1,b=852,v=592;function y(F){return(F>>>24&255)+(F>>>8&65280)+((65280&F)<<8)+((255&F)<<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 a.Buf16(320),this.work=new a.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function k(F){var z;return F&&F.state?(z=F.state,F.total_in=F.total_out=z.total=0,F.msg="",z.wrap&&(F.adler=1&z.wrap),z.mode=x,z.last=0,z.havedict=0,z.dmax=32768,z.head=null,z.hold=0,z.bits=0,z.lencode=z.lendyn=new a.Buf32(b),z.distcode=z.distdyn=new a.Buf32(v),z.sane=1,z.back=-1,p):m}function T(F){var z;return F&&F.state?((z=F.state).wsize=0,z.whave=0,z.wnext=0,k(F)):m}function M(F,z){var P,$;return F&&F.state?($=F.state,z<0?(P=0,z=-z):(P=1+(z>>4),z<48&&(z&=15)),z&&(z<8||15<z)?m:($.window!==null&&$.wbits!==z&&($.window=null),$.wrap=P,$.wbits=z,T(F))):m}function C(F,z){var P,$;return F?($=new S,(F.state=$).window=null,(P=M(F,z))!==p&&(F.state=null),P):m}var E,R,A=!0;function D(F){if(A){var z;for(E=new a.Buf32(512),R=new a.Buf32(32),z=0;z<144;)F.lens[z++]=8;for(;z<256;)F.lens[z++]=9;for(;z<280;)F.lens[z++]=7;for(;z<288;)F.lens[z++]=8;for(u(d,F.lens,0,288,E,0,F.work,{bits:9}),z=0;z<32;)F.lens[z++]=5;u(f,F.lens,0,32,R,0,F.work,{bits:5}),A=!1}F.lencode=E,F.lenbits=9,F.distcode=R,F.distbits=5}function I(F,z,P,$){var X,V=F.state;return V.window===null&&(V.wsize=1<<V.wbits,V.wnext=0,V.whave=0,V.window=new a.Buf8(V.wsize)),$>=V.wsize?(a.arraySet(V.window,z,P-V.wsize,V.wsize,0),V.wnext=0,V.whave=V.wsize):($<(X=V.wsize-V.wnext)&&(X=$),a.arraySet(V.window,z,P-$,X,V.wnext),($-=X)?(a.arraySet(V.window,z,P-$,$,0),V.wnext=$,V.whave=V.wsize):(V.wnext+=X,V.wnext===V.wsize&&(V.wnext=0),V.whave<V.wsize&&(V.whave+=X))),0}i.inflateReset=T,i.inflateReset2=M,i.inflateResetKeep=k,i.inflateInit=function(F){return C(F,15)},i.inflateInit2=C,i.inflate=function(F,z){var P,$,X,V,Q,Z,se,H,K,re,ne,be,me,de,Ce,ie,ke,Oe,pe,We,G,Y,ue,q,te=0,U=new a.Buf8(4),he=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!F||!F.state||!F.output||!F.input&&F.avail_in!==0)return m;(P=F.state).mode===12&&(P.mode=13),Q=F.next_out,X=F.output,se=F.avail_out,V=F.next_in,$=F.input,Z=F.avail_in,H=P.hold,K=P.bits,re=Z,ne=se,Y=p;e:for(;;)switch(P.mode){case x:if(P.wrap===0){P.mode=13;break}for(;K<16;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}if(2&P.wrap&&H===35615){U[P.check=0]=255&H,U[1]=H>>>8&255,P.check=l(P.check,U,2,0),K=H=0,P.mode=2;break}if(P.flags=0,P.head&&(P.head.done=!1),!(1&P.wrap)||(((255&H)<<8)+(H>>8))%31){F.msg="incorrect header check",P.mode=30;break}if((15&H)!=8){F.msg="unknown compression method",P.mode=30;break}if(K-=4,G=8+(15&(H>>>=4)),P.wbits===0)P.wbits=G;else if(G>P.wbits){F.msg="invalid window size",P.mode=30;break}P.dmax=1<<G,F.adler=P.check=1,P.mode=512&H?10:12,K=H=0;break;case 2:for(;K<16;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}if(P.flags=H,(255&P.flags)!=8){F.msg="unknown compression method",P.mode=30;break}if(57344&P.flags){F.msg="unknown header flags set",P.mode=30;break}P.head&&(P.head.text=H>>8&1),512&P.flags&&(U[0]=255&H,U[1]=H>>>8&255,P.check=l(P.check,U,2,0)),K=H=0,P.mode=3;case 3:for(;K<32;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}P.head&&(P.head.time=H),512&P.flags&&(U[0]=255&H,U[1]=H>>>8&255,U[2]=H>>>16&255,U[3]=H>>>24&255,P.check=l(P.check,U,4,0)),K=H=0,P.mode=4;case 4:for(;K<16;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}P.head&&(P.head.xflags=255&H,P.head.os=H>>8),512&P.flags&&(U[0]=255&H,U[1]=H>>>8&255,P.check=l(P.check,U,2,0)),K=H=0,P.mode=5;case 5:if(1024&P.flags){for(;K<16;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}P.length=H,P.head&&(P.head.extra_len=H),512&P.flags&&(U[0]=255&H,U[1]=H>>>8&255,P.check=l(P.check,U,2,0)),K=H=0}else P.head&&(P.head.extra=null);P.mode=6;case 6:if(1024&P.flags&&(Z<(be=P.length)&&(be=Z),be&&(P.head&&(G=P.head.extra_len-P.length,P.head.extra||(P.head.extra=new Array(P.head.extra_len)),a.arraySet(P.head.extra,$,V,be,G)),512&P.flags&&(P.check=l(P.check,$,be,V)),Z-=be,V+=be,P.length-=be),P.length))break e;P.length=0,P.mode=7;case 7:if(2048&P.flags){if(Z===0)break e;for(be=0;G=$[V+be++],P.head&&G&&P.length<65536&&(P.head.name+=String.fromCharCode(G)),G&&be<Z;);if(512&P.flags&&(P.check=l(P.check,$,be,V)),Z-=be,V+=be,G)break e}else P.head&&(P.head.name=null);P.length=0,P.mode=8;case 8:if(4096&P.flags){if(Z===0)break e;for(be=0;G=$[V+be++],P.head&&G&&P.length<65536&&(P.head.comment+=String.fromCharCode(G)),G&&be<Z;);if(512&P.flags&&(P.check=l(P.check,$,be,V)),Z-=be,V+=be,G)break e}else P.head&&(P.head.comment=null);P.mode=9;case 9:if(512&P.flags){for(;K<16;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}if(H!==(65535&P.check)){F.msg="header crc mismatch",P.mode=30;break}K=H=0}P.head&&(P.head.hcrc=P.flags>>9&1,P.head.done=!0),F.adler=P.check=0,P.mode=12;break;case 10:for(;K<32;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}F.adler=P.check=y(H),K=H=0,P.mode=11;case 11:if(P.havedict===0)return F.next_out=Q,F.avail_out=se,F.next_in=V,F.avail_in=Z,P.hold=H,P.bits=K,2;F.adler=P.check=1,P.mode=12;case 12:if(z===5||z===6)break e;case 13:if(P.last){H>>>=7&K,K-=7&K,P.mode=27;break}for(;K<3;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}switch(P.last=1&H,K-=1,3&(H>>>=1)){case 0:P.mode=14;break;case 1:if(D(P),P.mode=20,z!==6)break;H>>>=2,K-=2;break e;case 2:P.mode=17;break;case 3:F.msg="invalid block type",P.mode=30}H>>>=2,K-=2;break;case 14:for(H>>>=7&K,K-=7&K;K<32;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}if((65535&H)!=(H>>>16^65535)){F.msg="invalid stored block lengths",P.mode=30;break}if(P.length=65535&H,K=H=0,P.mode=15,z===6)break e;case 15:P.mode=16;case 16:if(be=P.length){if(Z<be&&(be=Z),se<be&&(be=se),be===0)break e;a.arraySet(X,$,V,be,Q),Z-=be,V+=be,se-=be,Q+=be,P.length-=be;break}P.mode=12;break;case 17:for(;K<14;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}if(P.nlen=257+(31&H),H>>>=5,K-=5,P.ndist=1+(31&H),H>>>=5,K-=5,P.ncode=4+(15&H),H>>>=4,K-=4,286<P.nlen||30<P.ndist){F.msg="too many length or distance symbols",P.mode=30;break}P.have=0,P.mode=18;case 18:for(;P.have<P.ncode;){for(;K<3;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}P.lens[he[P.have++]]=7&H,H>>>=3,K-=3}for(;P.have<19;)P.lens[he[P.have++]]=0;if(P.lencode=P.lendyn,P.lenbits=7,ue={bits:P.lenbits},Y=u(0,P.lens,0,19,P.lencode,0,P.work,ue),P.lenbits=ue.bits,Y){F.msg="invalid code lengths set",P.mode=30;break}P.have=0,P.mode=19;case 19:for(;P.have<P.nlen+P.ndist;){for(;ie=(te=P.lencode[H&(1<<P.lenbits)-1])>>>16&255,ke=65535&te,!((Ce=te>>>24)<=K);){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}if(ke<16)H>>>=Ce,K-=Ce,P.lens[P.have++]=ke;else{if(ke===16){for(q=Ce+2;K<q;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}if(H>>>=Ce,K-=Ce,P.have===0){F.msg="invalid bit length repeat",P.mode=30;break}G=P.lens[P.have-1],be=3+(3&H),H>>>=2,K-=2}else if(ke===17){for(q=Ce+3;K<q;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}K-=Ce,G=0,be=3+(7&(H>>>=Ce)),H>>>=3,K-=3}else{for(q=Ce+7;K<q;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}K-=Ce,G=0,be=11+(127&(H>>>=Ce)),H>>>=7,K-=7}if(P.have+be>P.nlen+P.ndist){F.msg="invalid bit length repeat",P.mode=30;break}for(;be--;)P.lens[P.have++]=G}}if(P.mode===30)break;if(P.lens[256]===0){F.msg="invalid code -- missing end-of-block",P.mode=30;break}if(P.lenbits=9,ue={bits:P.lenbits},Y=u(d,P.lens,0,P.nlen,P.lencode,0,P.work,ue),P.lenbits=ue.bits,Y){F.msg="invalid literal/lengths set",P.mode=30;break}if(P.distbits=6,P.distcode=P.distdyn,ue={bits:P.distbits},Y=u(f,P.lens,P.nlen,P.ndist,P.distcode,0,P.work,ue),P.distbits=ue.bits,Y){F.msg="invalid distances set",P.mode=30;break}if(P.mode=20,z===6)break e;case 20:P.mode=21;case 21:if(6<=Z&&258<=se){F.next_out=Q,F.avail_out=se,F.next_in=V,F.avail_in=Z,P.hold=H,P.bits=K,c(F,ne),Q=F.next_out,X=F.output,se=F.avail_out,V=F.next_in,$=F.input,Z=F.avail_in,H=P.hold,K=P.bits,P.mode===12&&(P.back=-1);break}for(P.back=0;ie=(te=P.lencode[H&(1<<P.lenbits)-1])>>>16&255,ke=65535&te,!((Ce=te>>>24)<=K);){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}if(ie&&(240&ie)==0){for(Oe=Ce,pe=ie,We=ke;ie=(te=P.lencode[We+((H&(1<<Oe+pe)-1)>>Oe)])>>>16&255,ke=65535&te,!(Oe+(Ce=te>>>24)<=K);){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}H>>>=Oe,K-=Oe,P.back+=Oe}if(H>>>=Ce,K-=Ce,P.back+=Ce,P.length=ke,ie===0){P.mode=26;break}if(32&ie){P.back=-1,P.mode=12;break}if(64&ie){F.msg="invalid literal/length code",P.mode=30;break}P.extra=15&ie,P.mode=22;case 22:if(P.extra){for(q=P.extra;K<q;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}P.length+=H&(1<<P.extra)-1,H>>>=P.extra,K-=P.extra,P.back+=P.extra}P.was=P.length,P.mode=23;case 23:for(;ie=(te=P.distcode[H&(1<<P.distbits)-1])>>>16&255,ke=65535&te,!((Ce=te>>>24)<=K);){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}if((240&ie)==0){for(Oe=Ce,pe=ie,We=ke;ie=(te=P.distcode[We+((H&(1<<Oe+pe)-1)>>Oe)])>>>16&255,ke=65535&te,!(Oe+(Ce=te>>>24)<=K);){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}H>>>=Oe,K-=Oe,P.back+=Oe}if(H>>>=Ce,K-=Ce,P.back+=Ce,64&ie){F.msg="invalid distance code",P.mode=30;break}P.offset=ke,P.extra=15&ie,P.mode=24;case 24:if(P.extra){for(q=P.extra;K<q;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}P.offset+=H&(1<<P.extra)-1,H>>>=P.extra,K-=P.extra,P.back+=P.extra}if(P.offset>P.dmax){F.msg="invalid distance too far back",P.mode=30;break}P.mode=25;case 25:if(se===0)break e;if(be=ne-se,P.offset>be){if((be=P.offset-be)>P.whave&&P.sane){F.msg="invalid distance too far back",P.mode=30;break}me=be>P.wnext?(be-=P.wnext,P.wsize-be):P.wnext-be,be>P.length&&(be=P.length),de=P.window}else de=X,me=Q-P.offset,be=P.length;for(se<be&&(be=se),se-=be,P.length-=be;X[Q++]=de[me++],--be;);P.length===0&&(P.mode=21);break;case 26:if(se===0)break e;X[Q++]=P.length,se--,P.mode=21;break;case 27:if(P.wrap){for(;K<32;){if(Z===0)break e;Z--,H|=$[V++]<<K,K+=8}if(ne-=se,F.total_out+=ne,P.total+=ne,ne&&(F.adler=P.check=P.flags?l(P.check,X,ne,Q-ne):o(P.check,X,ne,Q-ne)),ne=se,(P.flags?H:y(H))!==P.check){F.msg="incorrect data check",P.mode=30;break}K=H=0}P.mode=28;case 28:if(P.wrap&&P.flags){for(;K<32;){if(Z===0)break e;Z--,H+=$[V++]<<K,K+=8}if(H!==(4294967295&P.total)){F.msg="incorrect length check",P.mode=30;break}K=H=0}P.mode=29;case 29:Y=1;break e;case 30:Y=-3;break e;case 31:return-4;case 32:default:return m}return F.next_out=Q,F.avail_out=se,F.next_in=V,F.avail_in=Z,P.hold=H,P.bits=K,(P.wsize||ne!==F.avail_out&&P.mode<30&&(P.mode<27||z!==4))&&I(F,F.output,F.next_out,ne-F.avail_out)?(P.mode=31,-4):(re-=F.avail_in,ne-=F.avail_out,F.total_in+=re,F.total_out+=ne,P.total+=ne,P.wrap&&ne&&(F.adler=P.check=P.flags?l(P.check,X,ne,F.next_out-ne):o(P.check,X,ne,F.next_out-ne)),F.data_type=P.bits+(P.last?64:0)+(P.mode===12?128:0)+(P.mode===20||P.mode===15?256:0),(re==0&&ne===0||z===4)&&Y===p&&(Y=-5),Y)},i.inflateEnd=function(F){if(!F||!F.state)return m;var z=F.state;return z.window&&(z.window=null),F.state=null,p},i.inflateGetHeader=function(F,z){var P;return F&&F.state?(2&(P=F.state).wrap)==0?m:((P.head=z).done=!1,p):m},i.inflateSetDictionary=function(F,z){var P,$=z.length;return F&&F.state?(P=F.state).wrap!==0&&P.mode!==11?m:P.mode===11&&o(1,z,$,0)!==P.check?-3:I(F,z,$,$)?(P.mode=31,-4):(P.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 a=n("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],l=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],c=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],u=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];r.exports=function(d,f,p,m,x,b,v,y){var S,k,T,M,C,E,R,A,D,I=y.bits,F=0,z=0,P=0,$=0,X=0,V=0,Q=0,Z=0,se=0,H=0,K=null,re=0,ne=new a.Buf16(16),be=new a.Buf16(16),me=null,de=0;for(F=0;F<=15;F++)ne[F]=0;for(z=0;z<m;z++)ne[f[p+z]]++;for(X=I,$=15;1<=$&&ne[$]===0;$--);if($<X&&(X=$),$===0)return x[b++]=20971520,x[b++]=20971520,y.bits=1,0;for(P=1;P<$&&ne[P]===0;P++);for(X<P&&(X=P),F=Z=1;F<=15;F++)if(Z<<=1,(Z-=ne[F])<0)return-1;if(0<Z&&(d===0||$!==1))return-1;for(be[1]=0,F=1;F<15;F++)be[F+1]=be[F]+ne[F];for(z=0;z<m;z++)f[p+z]!==0&&(v[be[f[p+z]]++]=z);if(E=d===0?(K=me=v,19):d===1?(K=o,re-=257,me=l,de-=257,256):(K=c,me=u,-1),F=P,C=b,Q=z=H=0,T=-1,M=(se=1<<(V=X))-1,d===1&&852<se||d===2&&592<se)return 1;for(;;){for(R=F-Q,D=v[z]<E?(A=0,v[z]):v[z]>E?(A=me[de+v[z]],K[re+v[z]]):(A=96,0),S=1<<F-Q,P=k=1<<V;x[C+(H>>Q)+(k-=S)]=R<<24|A<<16|D|0,k!==0;);for(S=1<<F-1;H&S;)S>>=1;if(S!==0?(H&=S-1,H+=S):H=0,z++,--ne[F]==0){if(F===$)break;F=f[p+v[z]]}if(X<F&&(H&M)!==T){for(Q===0&&(Q=X),C+=P,Z=1<<(V=F-Q);V+Q<$&&!((Z-=ne[V+Q])<=0);)V++,Z<<=1;if(se+=1<<V,d===1&&852<se||d===2&&592<se)return 1;x[T=H&M]=X<<24|V<<16|C-b|0}}return H!==0&&(x[C+H]=F-Q<<24|64<<16|0),y.bits=X,0}},{"../utils/common":41}],51:[function(n,r,i){r.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(n,r,i){var a=n("../utils/common"),o=0,l=1;function c(te){for(var U=te.length;0<=--U;)te[U]=0}var u=0,d=29,f=256,p=f+1+d,m=30,x=19,b=2*p+1,v=15,y=16,S=7,k=256,T=16,M=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],R=[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 F=new Array(2*m);c(F);var z=new Array(512);c(z);var P=new Array(256);c(P);var $=new Array(d);c($);var X,V,Q,Z=new Array(m);function se(te,U,he,Me,ge){this.static_tree=te,this.extra_bits=U,this.extra_base=he,this.elems=Me,this.max_length=ge,this.has_stree=te&&te.length}function H(te,U){this.dyn_tree=te,this.max_code=0,this.stat_desc=U}function K(te){return te<256?z[te]:z[256+(te>>>7)]}function re(te,U){te.pending_buf[te.pending++]=255&U,te.pending_buf[te.pending++]=U>>>8&255}function ne(te,U,he){te.bi_valid>y-he?(te.bi_buf|=U<<te.bi_valid&65535,re(te,te.bi_buf),te.bi_buf=U>>y-te.bi_valid,te.bi_valid+=he-y):(te.bi_buf|=U<<te.bi_valid&65535,te.bi_valid+=he)}function be(te,U,he){ne(te,he[2*U],he[2*U+1])}function me(te,U){for(var he=0;he|=1&te,te>>>=1,he<<=1,0<--U;);return he>>>1}function de(te,U,he){var Me,ge,B=new Array(v+1),O=0;for(Me=1;Me<=v;Me++)B[Me]=O=O+he[Me-1]<<1;for(ge=0;ge<=U;ge++){var ee=te[2*ge+1];ee!==0&&(te[2*ge]=me(B[ee]++,ee))}}function Ce(te){var U;for(U=0;U<p;U++)te.dyn_ltree[2*U]=0;for(U=0;U<m;U++)te.dyn_dtree[2*U]=0;for(U=0;U<x;U++)te.bl_tree[2*U]=0;te.dyn_ltree[2*k]=1,te.opt_len=te.static_len=0,te.last_lit=te.matches=0}function ie(te){8<te.bi_valid?re(te,te.bi_buf):0<te.bi_valid&&(te.pending_buf[te.pending++]=te.bi_buf),te.bi_buf=0,te.bi_valid=0}function ke(te,U,he,Me){var ge=2*U,B=2*he;return te[ge]<te[B]||te[ge]===te[B]&&Me[U]<=Me[he]}function Oe(te,U,he){for(var Me=te.heap[he],ge=he<<1;ge<=te.heap_len&&(ge<te.heap_len&&ke(U,te.heap[ge+1],te.heap[ge],te.depth)&&ge++,!ke(U,Me,te.heap[ge],te.depth));)te.heap[he]=te.heap[ge],he=ge,ge<<=1;te.heap[he]=Me}function pe(te,U,he){var Me,ge,B,O,ee=0;if(te.last_lit!==0)for(;Me=te.pending_buf[te.d_buf+2*ee]<<8|te.pending_buf[te.d_buf+2*ee+1],ge=te.pending_buf[te.l_buf+ee],ee++,Me===0?be(te,ge,U):(be(te,(B=P[ge])+f+1,U),(O=E[B])!==0&&ne(te,ge-=$[B],O),be(te,B=K(--Me),he),(O=R[B])!==0&&ne(te,Me-=Z[B],O)),ee<te.last_lit;);be(te,k,U)}function We(te,U){var he,Me,ge,B=U.dyn_tree,O=U.stat_desc.static_tree,ee=U.stat_desc.has_stree,le=U.stat_desc.elems,_e=-1;for(te.heap_len=0,te.heap_max=b,he=0;he<le;he++)B[2*he]!==0?(te.heap[++te.heap_len]=_e=he,te.depth[he]=0):B[2*he+1]=0;for(;te.heap_len<2;)B[2*(ge=te.heap[++te.heap_len]=_e<2?++_e:0)]=1,te.depth[ge]=0,te.opt_len--,ee&&(te.static_len-=O[2*ge+1]);for(U.max_code=_e,he=te.heap_len>>1;1<=he;he--)Oe(te,B,he);for(ge=le;he=te.heap[1],te.heap[1]=te.heap[te.heap_len--],Oe(te,B,1),Me=te.heap[1],te.heap[--te.heap_max]=he,te.heap[--te.heap_max]=Me,B[2*ge]=B[2*he]+B[2*Me],te.depth[ge]=(te.depth[he]>=te.depth[Me]?te.depth[he]:te.depth[Me])+1,B[2*he+1]=B[2*Me+1]=ge,te.heap[1]=ge++,Oe(te,B,1),2<=te.heap_len;);te.heap[--te.heap_max]=te.heap[1],(function(ve,ae){var Fe,Be,$e,He,xe,Pe,ze=ae.dyn_tree,we=ae.max_code,Xe=ae.stat_desc.static_tree,Ne=ae.stat_desc.has_stree,rt=ae.stat_desc.extra_bits,Ee=ae.stat_desc.extra_base,Ke=ae.stat_desc.max_length,Ue=0;for(He=0;He<=v;He++)ve.bl_count[He]=0;for(ze[2*ve.heap[ve.heap_max]+1]=0,Fe=ve.heap_max+1;Fe<b;Fe++)Ke<(He=ze[2*ze[2*(Be=ve.heap[Fe])+1]+1]+1)&&(He=Ke,Ue++),ze[2*Be+1]=He,we<Be||(ve.bl_count[He]++,xe=0,Ee<=Be&&(xe=rt[Be-Ee]),Pe=ze[2*Be],ve.opt_len+=Pe*(He+xe),Ne&&(ve.static_len+=Pe*(Xe[2*Be+1]+xe)));if(Ue!==0){do{for(He=Ke-1;ve.bl_count[He]===0;)He--;ve.bl_count[He]--,ve.bl_count[He+1]+=2,ve.bl_count[Ke]--,Ue-=2}while(0<Ue);for(He=Ke;He!==0;He--)for(Be=ve.bl_count[He];Be!==0;)we<($e=ve.heap[--Fe])||(ze[2*$e+1]!==He&&(ve.opt_len+=(He-ze[2*$e+1])*ze[2*$e],ze[2*$e+1]=He),Be--)}})(te,U),de(B,_e,te.bl_count)}function G(te,U,he){var Me,ge,B=-1,O=U[1],ee=0,le=7,_e=4;for(O===0&&(le=138,_e=3),U[2*(he+1)+1]=65535,Me=0;Me<=he;Me++)ge=O,O=U[2*(Me+1)+1],++ee<le&&ge===O||(ee<_e?te.bl_tree[2*ge]+=ee:ge!==0?(ge!==B&&te.bl_tree[2*ge]++,te.bl_tree[2*T]++):ee<=10?te.bl_tree[2*M]++:te.bl_tree[2*C]++,B=ge,_e=(ee=0)===O?(le=138,3):ge===O?(le=6,3):(le=7,4))}function Y(te,U,he){var Me,ge,B=-1,O=U[1],ee=0,le=7,_e=4;for(O===0&&(le=138,_e=3),Me=0;Me<=he;Me++)if(ge=O,O=U[2*(Me+1)+1],!(++ee<le&&ge===O)){if(ee<_e)for(;be(te,ge,te.bl_tree),--ee!=0;);else ge!==0?(ge!==B&&(be(te,ge,te.bl_tree),ee--),be(te,T,te.bl_tree),ne(te,ee-3,2)):ee<=10?(be(te,M,te.bl_tree),ne(te,ee-3,3)):(be(te,C,te.bl_tree),ne(te,ee-11,7));B=ge,_e=(ee=0)===O?(le=138,3):ge===O?(le=6,3):(le=7,4)}}c(Z);var ue=!1;function q(te,U,he,Me){ne(te,(u<<1)+(Me?1:0),3),(function(ge,B,O,ee){ie(ge),re(ge,O),re(ge,~O),a.arraySet(ge.pending_buf,ge.window,B,O,ge.pending),ge.pending+=O})(te,U,he)}i._tr_init=function(te){ue||((function(){var U,he,Me,ge,B,O=new Array(v+1);for(ge=Me=0;ge<d-1;ge++)for($[ge]=Me,U=0;U<1<<E[ge];U++)P[Me++]=ge;for(P[Me-1]=ge,ge=B=0;ge<16;ge++)for(Z[ge]=B,U=0;U<1<<R[ge];U++)z[B++]=ge;for(B>>=7;ge<m;ge++)for(Z[ge]=B<<7,U=0;U<1<<R[ge]-7;U++)z[256+B++]=ge;for(he=0;he<=v;he++)O[he]=0;for(U=0;U<=143;)I[2*U+1]=8,U++,O[8]++;for(;U<=255;)I[2*U+1]=9,U++,O[9]++;for(;U<=279;)I[2*U+1]=7,U++,O[7]++;for(;U<=287;)I[2*U+1]=8,U++,O[8]++;for(de(I,p+1,O),U=0;U<m;U++)F[2*U+1]=5,F[2*U]=me(U,5);X=new se(I,E,f+1,p,v),V=new se(F,R,0,m,v),Q=new se(new Array(0),A,0,x,S)})(),ue=!0),te.l_desc=new H(te.dyn_ltree,X),te.d_desc=new H(te.dyn_dtree,V),te.bl_desc=new H(te.bl_tree,Q),te.bi_buf=0,te.bi_valid=0,Ce(te)},i._tr_stored_block=q,i._tr_flush_block=function(te,U,he,Me){var ge,B,O=0;0<te.level?(te.strm.data_type===2&&(te.strm.data_type=(function(ee){var le,_e=4093624447;for(le=0;le<=31;le++,_e>>>=1)if(1&_e&&ee.dyn_ltree[2*le]!==0)return o;if(ee.dyn_ltree[18]!==0||ee.dyn_ltree[20]!==0||ee.dyn_ltree[26]!==0)return l;for(le=32;le<f;le++)if(ee.dyn_ltree[2*le]!==0)return l;return o})(te)),We(te,te.l_desc),We(te,te.d_desc),O=(function(ee){var le;for(G(ee,ee.dyn_ltree,ee.l_desc.max_code),G(ee,ee.dyn_dtree,ee.d_desc.max_code),We(ee,ee.bl_desc),le=x-1;3<=le&&ee.bl_tree[2*D[le]+1]===0;le--);return ee.opt_len+=3*(le+1)+5+5+4,le})(te),ge=te.opt_len+3+7>>>3,(B=te.static_len+3+7>>>3)<=ge&&(ge=B)):ge=B=he+5,he+4<=ge&&U!==-1?q(te,U,he,Me):te.strategy===4||B===ge?(ne(te,2+(Me?1:0),3),pe(te,I,F)):(ne(te,4+(Me?1:0),3),(function(ee,le,_e,ve){var ae;for(ne(ee,le-257,5),ne(ee,_e-1,5),ne(ee,ve-4,4),ae=0;ae<ve;ae++)ne(ee,ee.bl_tree[2*D[ae]+1],3);Y(ee,ee.dyn_ltree,le-1),Y(ee,ee.dyn_dtree,_e-1)})(te,te.l_desc.max_code+1,te.d_desc.max_code+1,O+1),pe(te,te.dyn_ltree,te.dyn_dtree)),Ce(te),Me&&ie(te)},i._tr_tally=function(te,U,he){return te.pending_buf[te.d_buf+2*te.last_lit]=U>>>8&255,te.pending_buf[te.d_buf+2*te.last_lit+1]=255&U,te.pending_buf[te.l_buf+te.last_lit]=255&he,te.last_lit++,U===0?te.dyn_ltree[2*he]++:(te.matches++,U--,te.dyn_ltree[2*(P[he]+f+1)]++,te.dyn_dtree[2*K(U)]++),te.last_lit===te.lit_bufsize-1},i._tr_align=function(te){ne(te,2,3),be(te,k,I),(function(U){U.bi_valid===16?(re(U,U.bi_buf),U.bi_buf=0,U.bi_valid=0):8<=U.bi_valid&&(U.pending_buf[U.pending++]=255&U.bi_buf,U.bi_buf>>=8,U.bi_valid-=8)})(te)}},{"../utils/common":41}],53:[function(n,r,i){r.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(n,r,i){(function(a){(function(o,l){if(!o.setImmediate){var c,u,d,f,p=1,m={},x=!1,b=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,M=o.onmessage;return o.onmessage=function(){T=!1},o.postMessage("","*"),o.onmessage=M,T}})()?(f="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",k,!1):o.attachEvent("onmessage",k),function(T){o.postMessage(f+T,"*")}):o.MessageChannel?((d=new MessageChannel).port1.onmessage=function(T){S(T.data)},function(T){d.port2.postMessage(T)}):b&&"onreadystatechange"in b.createElement("script")?(u=b.documentElement,function(T){var M=b.createElement("script");M.onreadystatechange=function(){S(T),M.onreadystatechange=null,u.removeChild(M),M=null},u.appendChild(M)}):function(T){setTimeout(S,0,T)},v.setImmediate=function(T){typeof T!="function"&&(T=new Function(""+T));for(var M=new Array(arguments.length-1),C=0;C<M.length;C++)M[C]=arguments[C+1];var E={callback:T,args:M};return m[p]=E,c(p),p++},v.clearImmediate=y}function y(T){delete m[T]}function S(T){if(x)setTimeout(S,0,T);else{var M=m[T];if(M){x=!0;try{(function(C){var E=C.callback,R=C.args;switch(R.length){case 0:E();break;case 1:E(R[0]);break;case 2:E(R[0],R[1]);break;case 3:E(R[0],R[1],R[2]);break;default:E.apply(l,R)}})(M)}finally{y(T),x=!1}}}}function k(T){T.source===o&&typeof T.data=="string"&&T.data.indexOf(f)===0&&S(+T.data.slice(f.length))}})(typeof self>"u"?a===void 0?this:a:self)}).call(this,typeof Cw<"u"?Cw:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(SC)),SC.exports}var sLe=aLe();const oLe=hl(sLe);function lLe(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 FV=lLe;async function IV(t,e=0){const n=[],r=t.getElementsByTagName("mesh");for(let i=0;i<r.length;i++){const a=r[i],o=[],l=[],c=a.getElementsByTagName("vertex");for(let d=0;d<c.length;d++){const f=c[d];o.push(parseFloat(f.getAttribute("x")||"0"),parseFloat(f.getAttribute("y")||"0"),parseFloat(f.getAttribute("z")||"0"))}const u=a.getElementsByTagName("triangle");for(let d=0;d<u.length;d++){const f=u[d];l.push(parseInt(f.getAttribute("v1")||"0"),parseInt(f.getAttribute("v2")||"0"),parseInt(f.getAttribute("v3")||"0"))}o.length>0&&l.length>0&&n.push({vertices:o,triangles:l,extruder:e})}return n}async function cLe(t){const e=await oLe.loadAsync(t),n=new Map,r=[],i=new DOMParser;async function a(m){const x=m.startsWith("/")?m.slice(1):m,b=e.files[x];if(!b)return null;const v=await b.async("string");return i.parseFromString(v,"application/xml")}const o=new Map,l=new Map,c=e.files["Metadata/model_settings.config"];if(c)try{const m=await c.async("string"),b=i.parseFromString(m,"application/xml").getElementsByTagName("object");for(let v=0;v<b.length;v++){const y=b[v],S=y.getAttribute("id");if(!S)continue;const k=Array.from(y.children).filter(M=>M.tagName==="metadata"&&M.getAttribute("key")==="extruder");if(k.length>0){const M=k[0].getAttribute("value");M&&o.set(S,Math.max(0,parseInt(M,10)-1))}const T=y.getElementsByTagName("part");for(let M=0;M<T.length;M++){const C=T[M],E=C.getAttribute("id");if(!E)continue;const R=Array.from(C.children).filter(A=>A.tagName==="metadata"&&A.getAttribute("key")==="extruder");if(R.length>0){const A=R[0].getAttribute("value");A&&l.set(`${S}:${E}`,Math.max(0,parseInt(A,10)-1))}}}}catch{}const u=Object.keys(e.files).find(m=>m==="3D/3dmodel.model"||m.endsWith("/3dmodel.model"));if(!u){const m=Object.keys(e.files).find(x=>x.endsWith(".model"));if(m){const x=await a(m);if(x){const b=await IV(x,0);b.length>0&&n.set("1",{id:"1",meshes:b,defaultExtruder:0})}}return{objects:n,buildItems:r}}const d=await a(u);if(!d)return{objects:n,buildItems:r};const f=d.getElementsByTagName("object");for(let m=0;m<f.length;m++){const x=f[m],b=x.getAttribute("id");if(!b)continue;let v=o.get(b)??-1;if(v<0){const T=x.getAttribute("p:extruder")||x.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","extruder")||"1";v=Math.max(0,parseInt(T,10)-1)}const y=[],S=x.getElementsByTagName("mesh");for(let T=0;T<S.length;T++){const M=S[T],C=[],E=[],R=M.getElementsByTagName("vertex");for(let D=0;D<R.length;D++){const I=R[D];C.push(parseFloat(I.getAttribute("x")||"0"),parseFloat(I.getAttribute("y")||"0"),parseFloat(I.getAttribute("z")||"0"))}const A=M.getElementsByTagName("triangle");for(let D=0;D<A.length;D++){const I=A[D];E.push(parseInt(I.getAttribute("v1")||"0"),parseInt(I.getAttribute("v2")||"0"),parseInt(I.getAttribute("v3")||"0"))}C.length>0&&E.length>0&&y.push({vertices:C,triangles:E,extruder:v})}const k=x.getElementsByTagName("component");for(let T=0;T<k.length;T++){const M=k[T],C=M.getAttribute("p:path")||M.getAttributeNS("http://schemas.microsoft.com/3dmanufacturing/production/2015/06","path"),E=M.getAttribute("objectid");if(C){const R=await a(C);if(R){const A=E?`${b}:${E}`:null,D=A?l.get(A)??v:v,I=await IV(R,D),F=M.getAttribute("transform"),z=FV(F);for(const P of I)if(F){const $=[];for(let X=0;X<P.vertices.length;X+=3){const V=new ht(P.vertices[X],P.vertices[X+1],P.vertices[X+2]);V.applyMatrix4(z),$.push(V.x,V.y,V.z)}y.push({vertices:$,triangles:P.triangles,extruder:P.extruder})}else y.push(P)}}}y.length>0&&n.set(b,{id:b,meshes:y,defaultExtruder:v})}const p=d.getElementsByTagName("build");if(p.length>0){const m=p[0].getElementsByTagName("item");for(let x=0;x<m.length;x++){const b=m[x],v=b.getAttribute("objectid");if(!v)continue;const y=FV(b.getAttribute("transform"));r.push({objectId:v,transform:y})}}return{objects:n,buildItems:r}}function UV(t){const e=new Cc,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 nl(n,3)),e.setIndex(t.triangles),e.computeVertexNormals(),e}function uLe({url:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=_.useRef(null),a=_.useRef(null),o=_.useRef(null),l=_.useRef(null),c=_.useRef(null),[u,d]=_.useState(!0),[f,p]=_.useState(null);_.useEffect(()=>{if(!i.current)return;const b=i.current,v=b.clientWidth,y=b.clientHeight,S=new Bje;S.background=new Bn(1710618),o.current=S;const k=new Wo(45,v/y,.1,1e4);k.position.set(150,150,150),l.current=k;const T=new $4e({antialias:!0});T.setSize(v,y),T.setPixelRatio(window.devicePixelRatio),b.appendChild(T.domElement),a.current=T;const M=new G4e(k,T.domElement);M.enableDamping=!0,M.dampingFactor=.05,c.current=M;const C=new Jje(16777215,.6);S.add(C);const E=new oV(16777215,.8);E.position.set(100,100,100),S.add(E);const R=new oV(16777215,.4);R.position.set(-100,50,-100),S.add(R);const A=Math.max(e.x,e.y),D=Math.ceil(A/16),I=new t3e(A,D,4473924,3355443);S.add(I);const F=new tL(e.x,e.y),z=new Z4({color:44610,transparent:!0,opacity:.15,side:ic}),P=new wc(F,z);P.rotation.x=-Math.PI/2,P.position.y=-.5,S.add(P);let $;const X=()=>{$=requestAnimationFrame(X),M.update(),T.render(S,k)};X(),fetch(t).then(Q=>{if(!Q.ok)throw new Error("Failed to load file");return Q.arrayBuffer()}).then(cLe).then(({objects:Q,buildItems:Z})=>{if(Q.size===0)throw new Error("No meshes found in 3MF file");const se=ke=>{const pe=n?.[ke]||"#00ae42",We=new Bn(pe);return new Kje({color:We,shininess:30,flatShading:!1})},H=new o0,K=new Map;if(Z.length>0)for(const ke of Z){const Oe=Q.get(ke.objectId);if(Oe)for(const pe of Oe.meshes){const We=ke.extruder??pe.extruder,G=[];for(let ue=0;ue<pe.vertices.length;ue+=3){const q=new ht(pe.vertices[ue],pe.vertices[ue+1],pe.vertices[ue+2]);q.applyMatrix4(ke.transform),G.push(q.x,q.y,q.z)}const Y=UV({vertices:G,triangles:pe.triangles});K.has(We)||K.set(We,[]),K.get(We).push(Y)}}else for(const ke of Q.values())for(const Oe of ke.meshes){const pe=Oe.extruder,We=UV(Oe);K.has(pe)||K.set(pe,[]),K.get(pe).push(We)}for(const[ke,Oe]of K){if(Oe.length===0)continue;const pe=Oe.length===1?Oe[0]:iLe(Oe,!1);if(pe){const We=se(ke),G=new wc(pe,We);H.add(G)}if(Oe.length>1)for(const We of Oe)We.dispose()}const re=new bm().setFromObject(H),ne=re.getCenter(new ht);H.position.y=-re.min.y,Z.length===0&&(H.position.x=-ne.x,H.position.z=-ne.z),S.add(H);const be=new bm().setFromObject(H),me=be.getCenter(new ht),de=be.getSize(new ht),ie=Math.max(de.x,de.y,de.z)*1.8;k.position.set(me.x+ie*.7,me.y+ie*.5,me.z+ie*.7),M.target.copy(me),M.update(),d(!1)}).catch(Q=>{p(Q.message),d(!1)});const V=()=>{if(!b)return;const Q=b.clientWidth,Z=b.clientHeight;k.aspect=Q/Z,k.updateProjectionMatrix(),T.setSize(Q,Z)};return window.addEventListener("resize",V),()=>{window.removeEventListener("resize",V),cancelAnimationFrame($),M.dispose(),T.dispose(),b.removeChild(T.domElement)}},[t,e,n]);const m=()=>{l.current&&c.current&&(l.current.position.set(150,150,150),c.current.target.set(0,50,0),c.current.update())},x=b=>{l.current&&l.current.position.multiplyScalar(b)};return s.jsxs("div",{className:`relative ${r}`,children:[s.jsx("div",{ref:i,className:"w-full h-full min-h-[400px]"}),u&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}),f&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx("p",{className:"text-red-400",children:f})}),!u&&!f&&s.jsxs("div",{className:"absolute bottom-4 right-4 flex gap-2",children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>x(.8),children:s.jsx(LR,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>x(1.25),children:s.jsx(FR,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:m,children:s.jsx(Rh,{className:"w-4 h-4"})})]})]})}const x2="159",Rp={ROTATE:0,DOLLY:1,PAN:2},Op={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},dLe=0,zV=1,hLe=2,IJ=1,fLe=2,cu=3,Th=0,Us=1,gu=2,ch=0,Pg=1,BV=2,HV=3,$V=4,mLe=5,kf=100,pLe=101,gLe=102,VV=103,GV=104,xLe=200,bLe=201,yLe=202,vLe=203,fD=204,mD=205,wLe=206,_Le=207,SLe=208,NLe=209,MLe=210,kLe=211,ELe=212,TLe=213,ALe=214,CLe=0,PLe=1,jLe=2,JS=3,DLe=4,RLe=5,OLe=6,LLe=7,rL=0,FLe=1,ILe=2,uh=0,ULe=1,zLe=2,BLe=3,HLe=4,$Le=5,UJ=300,nx=301,rx=302,pD=303,gD=304,b2=306,xD=1e3,Cl=1001,bD=1002,Oa=1003,qV=1004,NC=1005,Ko=1006,VLe=1007,gy=1008,dh=1009,GLe=1010,qLe=1011,iL=1012,zJ=1013,Zd=1014,Su=1015,xy=1016,BJ=1017,HJ=1018,qf=1020,WLe=1021,Xo=1023,KLe=1024,XLe=1025,Wf=1026,ix=1027,YLe=1028,$J=1029,QLe=1030,VJ=1031,GJ=1033,MC=33776,kC=33777,EC=33778,TC=33779,WV=35840,KV=35841,XV=35842,YV=35843,qJ=36196,QV=37492,ZV=37496,JV=37808,eG=37809,tG=37810,nG=37811,rG=37812,iG=37813,aG=37814,sG=37815,oG=37816,lG=37817,cG=37818,uG=37819,dG=37820,hG=37821,AC=36492,fG=36494,mG=36495,ZLe=36283,pG=36284,gG=36285,xG=36286,WJ=3e3,Kf=3001,JLe=3200,eFe=3201,KJ=0,tFe=1,Yo="",La="srgb",Vu="srgb-linear",aL="display-p3",y2="display-p3-linear",eN="linear",Gr="srgb",tN="rec709",nN="p3",Lp=7680,bG=519,nFe=512,rFe=513,iFe=514,XJ=515,aFe=516,sFe=517,oFe=518,lFe=519,yD=35044,yG="300 es",vD=1035,cc=2e3,by=2001;class Pm{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const r=this._listeners;r[e]===void 0&&(r[e]=[]),r[e].indexOf(n)===-1&&r[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const r=this._listeners;return r[e]!==void 0&&r[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const a=i.indexOf(n);a!==-1&&i.splice(a,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const r=this._listeners[e.type];if(r!==void 0){e.target=this;const i=r.slice(0);for(let a=0,o=i.length;a<o;a++)i[a].call(this,e);e.target=null}}}const Ga=["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 vG=1234567;const w0=Math.PI/180,yy=180/Math.PI;function Pu(){const t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,r=Math.random()*4294967295|0;return(Ga[t&255]+Ga[t>>8&255]+Ga[t>>16&255]+Ga[t>>24&255]+"-"+Ga[e&255]+Ga[e>>8&255]+"-"+Ga[e>>16&15|64]+Ga[e>>24&255]+"-"+Ga[n&63|128]+Ga[n>>8&255]+"-"+Ga[n>>16&255]+Ga[n>>24&255]+Ga[r&255]+Ga[r>>8&255]+Ga[r>>16&255]+Ga[r>>24&255]).toLowerCase()}function Fa(t,e,n){return Math.max(e,Math.min(n,t))}function sL(t,e){return(t%e+e)%e}function cFe(t,e,n,r,i){return r+(t-e)*(i-r)/(n-e)}function uFe(t,e,n){return t!==e?(n-t)/(e-t):0}function _0(t,e,n){return(1-n)*t+n*e}function dFe(t,e,n,r){return _0(t,e,1-Math.exp(-n*r))}function hFe(t,e=1){return e-Math.abs(sL(t,e*2)-e)}function fFe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*(3-2*t))}function mFe(t,e,n){return t<=e?0:t>=n?1:(t=(t-e)/(n-e),t*t*t*(t*(t*6-15)+10))}function pFe(t,e){return t+Math.floor(Math.random()*(e-t+1))}function gFe(t,e){return t+Math.random()*(e-t)}function xFe(t){return t*(.5-Math.random())}function bFe(t){t!==void 0&&(vG=t);let e=vG+=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 yFe(t){return t*w0}function vFe(t){return t*yy}function wD(t){return(t&t-1)===0&&t!==0}function wFe(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}function rN(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function _Fe(t,e,n,r,i){const a=Math.cos,o=Math.sin,l=a(n/2),c=o(n/2),u=a((e+r)/2),d=o((e+r)/2),f=a((e-r)/2),p=o((e-r)/2),m=a((r-e)/2),x=o((r-e)/2);switch(i){case"XYX":t.set(l*d,c*f,c*p,l*u);break;case"YZY":t.set(c*p,l*d,c*f,l*u);break;case"ZXZ":t.set(c*f,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 ac(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 YJ={DEG2RAD:w0,RAD2DEG:yy,generateUUID:Pu,clamp:Fa,euclideanModulo:sL,mapLinear:cFe,inverseLerp:uFe,lerp:_0,damp:dFe,pingpong:hFe,smoothstep:fFe,smootherstep:mFe,randInt:pFe,randFloat:gFe,randFloatSpread:xFe,seededRandom:bFe,degToRad:yFe,radToDeg:vFe,isPowerOfTwo:wD,ceilPowerOfTwo:wFe,floorPowerOfTwo:rN,setQuaternionFromProperEuler:_Fe,normalize:kr,denormalize:ac};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(Fa(r,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,r=this.y-e.y;return n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n){return this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const r=Math.cos(n),i=Math.sin(n),a=this.x-e.x,o=this.y-e.y;return this.x=a*r-o*i+e.x,this.y=a*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 Fn{constructor(e,n,r,i,a,o,l,c,u){Fn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,n,r,i,a,o,l,c,u)}set(e,n,r,i,a,o,l,c,u){const d=this.elements;return d[0]=e,d[1]=i,d[2]=l,d[3]=n,d[4]=a,d[5]=c,d[6]=r,d[7]=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,a=this.elements,o=r[0],l=r[3],c=r[6],u=r[1],d=r[4],f=r[7],p=r[2],m=r[5],x=r[8],b=i[0],v=i[3],y=i[6],S=i[1],k=i[4],T=i[7],M=i[2],C=i[5],E=i[8];return a[0]=o*b+l*S+c*M,a[3]=o*v+l*k+c*C,a[6]=o*y+l*T+c*E,a[1]=u*b+d*S+f*M,a[4]=u*v+d*k+f*C,a[7]=u*y+d*T+f*E,a[2]=p*b+m*S+x*M,a[5]=p*v+m*k+x*C,a[8]=p*y+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],a=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*a*d+r*l*c+i*a*u-i*o*c}invert(){const e=this.elements,n=e[0],r=e[1],i=e[2],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=d*o-l*u,p=l*c-d*a,m=u*a-o*c,x=n*f+r*p+i*m;if(x===0)return this.set(0,0,0,0,0,0,0,0,0);const b=1/x;return e[0]=f*b,e[1]=(i*u-d*r)*b,e[2]=(l*r-i*o)*b,e[3]=p*b,e[4]=(d*n-i*c)*b,e[5]=(i*a-l*n)*b,e[6]=m*b,e[7]=(r*c-u*n)*b,e[8]=(o*n-r*a)*b,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,r,i,a,o,l){const c=Math.cos(a),u=Math.sin(a);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(CC.makeScale(e,n)),this}rotate(e){return this.premultiply(CC.makeRotation(-e)),this}translate(e,n){return this.premultiply(CC.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 CC=new Fn;function QJ(t){for(let e=t.length-1;e>=0;--e)if(t[e]>=65535)return!0;return!1}function iN(t){return document.createElementNS("http://www.w3.org/1999/xhtml",t)}function SFe(){const t=iN("canvas");return t.style.display="block",t}const wG={};function S0(t){t in wG||(wG[t]=!0,console.warn(t))}const _G=new Fn().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),SG=new Fn().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),S_={[Vu]:{transfer:eN,primaries:tN,toReference:t=>t,fromReference:t=>t},[La]:{transfer:Gr,primaries:tN,toReference:t=>t.convertSRGBToLinear(),fromReference:t=>t.convertLinearToSRGB()},[y2]:{transfer:eN,primaries:nN,toReference:t=>t.applyMatrix3(SG),fromReference:t=>t.applyMatrix3(_G)},[aL]:{transfer:Gr,primaries:nN,toReference:t=>t.convertSRGBToLinear().applyMatrix3(SG),fromReference:t=>t.applyMatrix3(_G).convertLinearToSRGB()}},NFe=new Set([Vu,y2]),Er={enabled:!0,_workingColorSpace:Vu,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(!NFe.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===Yo?eN:S_[t].transfer}};function jg(t){return t<.04045?t*.0773993808:Math.pow(t*.9478672986+.0521327014,2.4)}function PC(t){return t<.0031308?t*12.92:1.055*Math.pow(t,.41666)-.055}let Fp;class ZJ{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{Fp===void 0&&(Fp=iN("canvas")),Fp.width=e.width,Fp.height=e.height;const r=Fp.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Fp}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=iN("canvas");n.width=e.width,n.height=e.height;const r=n.getContext("2d");r.drawImage(e,0,0,e.width,e.height);const i=r.getImageData(0,0,e.width,e.height),a=i.data;for(let o=0;o<a.length;o++)a[o]=jg(a[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 MFe=0;class JJ{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:MFe++}),this.uuid=Pu(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const r={uuid:this.uuid,url:""},i=this.data;if(i!==null){let a;if(Array.isArray(i)){a=[];for(let o=0,l=i.length;o<l;o++)i[o].isDataTexture?a.push(jC(i[o].image)):a.push(jC(i[o]))}else a=jC(i);r.url=a}return n||(e.images[this.uuid]=r),r}}function jC(t){return typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap?ZJ.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 kFe=0;class zs extends Pm{constructor(e=zs.DEFAULT_IMAGE,n=zs.DEFAULT_MAPPING,r=Cl,i=Cl,a=Ko,o=gy,l=Xo,c=dh,u=zs.DEFAULT_ANISOTROPY,d=Yo){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:kFe++}),this.uuid=Pu(),this.name="",this.source=new JJ(e),this.mipmaps=[],this.mapping=n,this.channel=0,this.wrapS=r,this.wrapT=i,this.magFilter=a,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 Fn,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===Kf?La:Yo),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!==UJ)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case xD:e.x=e.x-Math.floor(e.x);break;case Cl:e.x=e.x<0?0:1;break;case bD: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 xD:e.y=e.y-Math.floor(e.y);break;case Cl:e.y=e.y<0?0:1;break;case bD: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===La?Kf:WJ}set encoding(e){S0("THREE.Texture: Property .encoding has been replaced by .colorSpace."),this.colorSpace=e===Kf?La:Yo}}zs.DEFAULT_IMAGE=null;zs.DEFAULT_MAPPING=UJ;zs.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,a=this.w,o=e.elements;return this.x=o[0]*n+o[4]*r+o[8]*i+o[12]*a,this.y=o[1]*n+o[5]*r+o[9]*i+o[13]*a,this.z=o[2]*n+o[6]*r+o[10]*i+o[14]*a,this.w=o[3]*n+o[7]*r+o[11]*i+o[15]*a,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,r,i,a;const c=e.elements,u=c[0],d=c[4],f=c[8],p=c[1],m=c[5],x=c[9],b=c[2],v=c[6],y=c[10];if(Math.abs(d-p)<.01&&Math.abs(f-b)<.01&&Math.abs(x-v)<.01){if(Math.abs(d+p)<.1&&Math.abs(f+b)<.1&&Math.abs(x+v)<.1&&Math.abs(u+m+y-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const k=(u+1)/2,T=(m+1)/2,M=(y+1)/2,C=(d+p)/4,E=(f+b)/4,R=(x+v)/4;return k>T&&k>M?k<.01?(r=0,i=.707106781,a=.707106781):(r=Math.sqrt(k),i=C/r,a=E/r):T>M?T<.01?(r=.707106781,i=0,a=.707106781):(i=Math.sqrt(T),r=C/i,a=R/i):M<.01?(r=.707106781,i=.707106781,a=0):(a=Math.sqrt(M),r=E/a,i=R/a),this.set(r,i,a,n),this}let S=Math.sqrt((v-x)*(v-x)+(f-b)*(f-b)+(p-d)*(p-d));return Math.abs(S)<.001&&(S=1),this.x=(v-x)/S,this.y=(f-b)/S,this.z=(p-d)/S,this.w=Math.acos((u+m+y-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 EFe extends Pm{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===Kf?La:Yo),r=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Ko,depthBuffer:!0,stencilBuffer:!1,depthTexture:null,samples:0},r),this.texture=new zs(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 JJ(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 ym extends EFe{constructor(e=1,n=1,r={}){super(e,n,r),this.isWebGLRenderTarget=!0}}class eee extends zs{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=Oa,this.minFilter=Oa,this.wrapR=Cl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class TFe extends zs{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=Oa,this.minFilter=Oa,this.wrapR=Cl,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class vm{constructor(e=0,n=0,r=0,i=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=r,this._w=i}static slerpFlat(e,n,r,i,a,o,l){let c=r[i+0],u=r[i+1],d=r[i+2],f=r[i+3];const p=a[o+0],m=a[o+1],x=a[o+2],b=a[o+3];if(l===0){e[n+0]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f;return}if(l===1){e[n+0]=p,e[n+1]=m,e[n+2]=x,e[n+3]=b;return}if(f!==b||c!==p||u!==m||d!==x){let v=1-l;const y=c*p+u*m+d*x+f*b,S=y>=0?1:-1,k=1-y*y;if(k>Number.EPSILON){const M=Math.sqrt(k),C=Math.atan2(M,y*S);v=Math.sin(v*C)/M,l=Math.sin(l*C)/M}const T=l*S;if(c=c*v+p*T,u=u*v+m*T,d=d*v+x*T,f=f*v+b*T,v===1-l){const M=1/Math.sqrt(c*c+u*u+d*d+f*f);c*=M,u*=M,d*=M,f*=M}}e[n]=c,e[n+1]=u,e[n+2]=d,e[n+3]=f}static multiplyQuaternionsFlat(e,n,r,i,a,o){const l=r[i],c=r[i+1],u=r[i+2],d=r[i+3],f=a[o],p=a[o+1],m=a[o+2],x=a[o+3];return e[n]=l*x+d*f+c*m-u*p,e[n+1]=c*x+d*p+u*f-l*m,e[n+2]=u*x+d*m+l*p-c*f,e[n+3]=d*x-l*f-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,a=e._z,o=e._order,l=Math.cos,c=Math.sin,u=l(r/2),d=l(i/2),f=l(a/2),p=c(r/2),m=c(i/2),x=c(a/2);switch(o){case"XYZ":this._x=p*d*f+u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f-p*m*x;break;case"YXZ":this._x=p*d*f+u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f+p*m*x;break;case"ZXY":this._x=p*d*f-u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f-p*m*x;break;case"ZYX":this._x=p*d*f-u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f+p*m*x;break;case"YZX":this._x=p*d*f+u*m*x,this._y=u*m*f+p*d*x,this._z=u*d*x-p*m*f,this._w=u*d*f-p*m*x;break;case"XZY":this._x=p*d*f-u*m*x,this._y=u*m*f-p*d*x,this._z=u*d*x+p*m*f,this._w=u*d*f+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],a=n[8],o=n[1],l=n[5],c=n[9],u=n[2],d=n[6],f=n[10],p=r+l+f;if(p>0){const m=.5/Math.sqrt(p+1);this._w=.25/m,this._x=(d-c)*m,this._y=(a-u)*m,this._z=(o-i)*m}else if(r>l&&r>f){const m=2*Math.sqrt(1+r-l-f);this._w=(d-c)/m,this._x=.25*m,this._y=(i+o)/m,this._z=(a+u)/m}else if(l>f){const m=2*Math.sqrt(1+l-r-f);this._w=(a-u)/m,this._x=(i+o)/m,this._y=.25*m,this._z=(c+d)/m}else{const m=2*Math.sqrt(1+f-r-l);this._w=(o-i)/m,this._x=(a+u)/m,this._y=(c+d)/m,this._z=.25*m}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let r=e.dot(n)+1;return r<Number.EPSILON?(r=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=r):(this._x=0,this._y=-e.z,this._z=e.y,this._w=r)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=r),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Fa(this.dot(e),-1,1)))}rotateTowards(e,n){const r=this.angleTo(e);if(r===0)return this;const i=Math.min(1,n/r);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const r=e._x,i=e._y,a=e._z,o=e._w,l=n._x,c=n._y,u=n._z,d=n._w;return this._x=r*d+o*l+i*u-a*c,this._y=i*d+o*c+a*l-r*u,this._z=a*d+o*u+r*c-i*l,this._w=o*d-r*l-i*c-a*u,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const r=this._x,i=this._y,a=this._z,o=this._w;let l=o*e._w+r*e._x+i*e._y+a*e._z;if(l<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,l=-l):this.copy(e),l>=1)return this._w=o,this._x=r,this._y=i,this._z=a,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*a+n*this._z,this.normalize(),this._onChangeCallback(),this}const u=Math.sqrt(c),d=Math.atan2(u,l),f=Math.sin((1-n)*d)/u,p=Math.sin(n*d)/u;return this._w=o*f+this._w*p,this._x=r*f+this._x*p,this._y=i*f+this._y*p,this._z=a*f+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(),a=2*Math.PI*Math.random();return this.set(n*Math.cos(i),r*Math.sin(a),r*Math.cos(a),n*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class qe{constructor(e=0,n=0,r=0){qe.prototype.isVector3=!0,this.x=e,this.y=n,this.z=r}set(e,n,r){return r===void 0&&(r=this.z),this.x=e,this.y=n,this.z=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return this.applyQuaternion(NG.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(NG.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,r=this.y,i=this.z,a=e.elements;return this.x=a[0]*n+a[3]*r+a[6]*i,this.y=a[1]*n+a[4]*r+a[7]*i,this.z=a[2]*n+a[5]*r+a[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,r=this.y,i=this.z,a=e.elements,o=1/(a[3]*n+a[7]*r+a[11]*i+a[15]);return this.x=(a[0]*n+a[4]*r+a[8]*i+a[12])*o,this.y=(a[1]*n+a[5]*r+a[9]*i+a[13])*o,this.z=(a[2]*n+a[6]*r+a[10]*i+a[14])*o,this}applyQuaternion(e){const n=this.x,r=this.y,i=this.z,a=e.x,o=e.y,l=e.z,c=e.w,u=2*(o*i-l*r),d=2*(l*n-a*i),f=2*(a*r-o*n);return this.x=n+c*u+o*f-l*d,this.y=r+c*d+l*u-a*f,this.z=i+c*f+a*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,a=e.elements;return this.x=a[0]*n+a[4]*r+a[8]*i,this.y=a[1]*n+a[5]*r+a[9]*i,this.z=a[2]*n+a[6]*r+a[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(e,Math.min(n,r)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,r){return this.x=e.x+(n.x-e.x)*r,this.y=e.y+(n.y-e.y)*r,this.z=e.z+(n.z-e.z)*r,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,n){const r=e.x,i=e.y,a=e.z,o=n.x,l=n.y,c=n.z;return this.x=i*c-a*l,this.y=a*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 DC.copy(this).projectOnVector(e),this.sub(DC)}reflect(e){return this.sub(DC.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(Fa(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 DC=new qe,NG=new vm;class rl{constructor(e=new qe(1/0,1/0,1/0),n=new qe(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){this.makeEmpty();for(let n=0,r=e.length;n<r;n+=3)this.expandByPoint(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 a=r.getAttribute("position");if(n===!0&&a!==void 0&&e.isInstancedMesh!==!0)for(let o=0,l=a.count;o<l;o++)e.isMesh===!0?e.getVertexPosition(o,Sl):Sl.fromBufferAttribute(a,o),Sl.applyMatrix4(e.matrixWorld),this.expandByPoint(Sl);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),N_.copy(e.boundingBox)):(r.boundingBox===null&&r.computeBoundingBox(),N_.copy(r.boundingBox)),N_.applyMatrix4(e.matrixWorld),this.union(N_)}const i=e.children;for(let a=0,o=i.length;a<o;a++)this.expandByObject(i[a],n);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,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(Wb),M_.subVectors(this.max,Wb),Ip.subVectors(e.a,Wb),Up.subVectors(e.b,Wb),zp.subVectors(e.c,Wb),Ad.subVectors(Up,Ip),Cd.subVectors(zp,Up),ff.subVectors(Ip,zp);let n=[0,-Ad.z,Ad.y,0,-Cd.z,Cd.y,0,-ff.z,ff.y,Ad.z,0,-Ad.x,Cd.z,0,-Cd.x,ff.z,0,-ff.x,-Ad.y,Ad.x,0,-Cd.y,Cd.x,0,-ff.y,ff.x,0];return!RC(n,Ip,Up,zp,M_)||(n=[1,0,0,0,1,0,0,0,1],!RC(n,Ip,Up,zp,M_))?!1:(k_.crossVectors(Ad,Cd),n=[k_.x,k_.y,k_.z],RC(n,Ip,Up,zp,M_))}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:(Jc[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Jc[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Jc[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Jc[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Jc[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Jc[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Jc[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Jc[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Jc),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 Jc=[new qe,new qe,new qe,new qe,new qe,new qe,new qe,new qe],Sl=new qe,N_=new rl,Ip=new qe,Up=new qe,zp=new qe,Ad=new qe,Cd=new qe,ff=new qe,Wb=new qe,M_=new qe,k_=new qe,mf=new qe;function RC(t,e,n,r,i){for(let a=0,o=t.length-3;a<=o;a+=3){mf.fromArray(t,a);const l=i.x*Math.abs(mf.x)+i.y*Math.abs(mf.y)+i.z*Math.abs(mf.z),c=e.dot(mf),u=n.dot(mf),d=r.dot(mf);if(Math.max(-Math.max(c,u,d),Math.min(c,u,d))>l)return!1}return!0}const AFe=new rl,Kb=new qe,OC=new qe;class hc{constructor(e=new qe,n=-1){this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const r=this.center;n!==void 0?r.copy(n):AFe.setFromPoints(e).getCenter(r);let i=0;for(let a=0,o=e.length;a<o;a++)i=Math.max(i,r.distanceToSquared(e[a]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const r=this.center.distanceToSquared(e);return n.copy(e),r>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Kb.subVectors(e,this.center);const n=Kb.lengthSq();if(n>this.radius*this.radius){const r=Math.sqrt(n),i=(r-this.radius)*.5;this.center.addScaledVector(Kb,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):(OC.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Kb.copy(e.center).add(OC)),this.expandByPoint(Kb.copy(e.center).sub(OC))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const eu=new qe,LC=new qe,E_=new qe,Pd=new qe,FC=new qe,T_=new qe,IC=new qe;class oL{constructor(e=new qe,n=new qe(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,eu)),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=eu.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(eu.copy(this.origin).addScaledVector(this.direction,n),eu.distanceToSquared(e))}distanceSqToSegment(e,n,r,i){LC.copy(e).add(n).multiplyScalar(.5),E_.copy(n).sub(e).normalize(),Pd.copy(this.origin).sub(LC);const a=e.distanceTo(n)*.5,o=-this.direction.dot(E_),l=Pd.dot(this.direction),c=-Pd.dot(E_),u=Pd.lengthSq(),d=Math.abs(1-o*o);let f,p,m,x;if(d>0)if(f=o*c-l,p=o*l-c,x=a*d,f>=0)if(p>=-x)if(p<=x){const b=1/d;f*=b,p*=b,m=f*(f+o*p+2*l)+p*(o*f+p+2*c)+u}else p=a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;else p=-a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;else p<=-x?(f=Math.max(0,-(-o*a+l)),p=f>0?-a:Math.min(Math.max(-a,-c),a),m=-f*f+p*(p+2*c)+u):p<=x?(f=0,p=Math.min(Math.max(-a,-c),a),m=p*(p+2*c)+u):(f=Math.max(0,-(o*a+l)),p=f>0?a:Math.min(Math.max(-a,-c),a),m=-f*f+p*(p+2*c)+u);else p=o>0?-a:a,f=Math.max(0,-(o*p+l)),m=-f*f+p*(p+2*c)+u;return r&&r.copy(this.origin).addScaledVector(this.direction,f),i&&i.copy(LC).addScaledVector(E_,p),m}intersectSphere(e,n){eu.subVectors(e.center,this.origin);const r=eu.dot(this.direction),i=eu.dot(eu)-r*r,a=e.radius*e.radius;if(i>a)return null;const o=Math.sqrt(a-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,a,o,l,c;const u=1/this.direction.x,d=1/this.direction.y,f=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?(a=(e.min.y-p.y)*d,o=(e.max.y-p.y)*d):(a=(e.max.y-p.y)*d,o=(e.min.y-p.y)*d),r>o||a>i||((a>r||isNaN(r))&&(r=a),(o<i||isNaN(i))&&(i=o),f>=0?(l=(e.min.z-p.z)*f,c=(e.max.z-p.z)*f):(l=(e.max.z-p.z)*f,c=(e.min.z-p.z)*f),r>c||l>i)||((l>r||r!==r)&&(r=l),(c<i||i!==i)&&(i=c),i<0)?null:this.at(r>=0?r:i,n)}intersectsBox(e){return this.intersectBox(e,eu)!==null}intersectTriangle(e,n,r,i,a){FC.subVectors(n,e),T_.subVectors(r,e),IC.crossVectors(FC,T_);let o=this.direction.dot(IC),l;if(o>0){if(i)return null;l=1}else if(o<0)l=-1,o=-o;else return null;Pd.subVectors(this.origin,e);const c=l*this.direction.dot(T_.crossVectors(Pd,T_));if(c<0)return null;const u=l*this.direction.dot(FC.cross(Pd));if(u<0||c+u>o)return null;const d=-l*Pd.dot(IC);return d<0?null:this.at(d/o,a)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class zr{constructor(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,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,a,o,l,c,u,d,f,p,m,x,b,v)}set(e,n,r,i,a,o,l,c,u,d,f,p,m,x,b,v){const y=this.elements;return y[0]=e,y[4]=n,y[8]=r,y[12]=i,y[1]=a,y[5]=o,y[9]=l,y[13]=c,y[2]=u,y[6]=d,y[10]=f,y[14]=p,y[3]=m,y[7]=x,y[11]=b,y[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/Bp.setFromMatrixColumn(e,0).length(),a=1/Bp.setFromMatrixColumn(e,1).length(),o=1/Bp.setFromMatrixColumn(e,2).length();return n[0]=r[0]*i,n[1]=r[1]*i,n[2]=r[2]*i,n[3]=0,n[4]=r[4]*a,n[5]=r[5]*a,n[6]=r[6]*a,n[7]=0,n[8]=r[8]*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,a=e.z,o=Math.cos(r),l=Math.sin(r),c=Math.cos(i),u=Math.sin(i),d=Math.cos(a),f=Math.sin(a);if(e.order==="XYZ"){const p=o*d,m=o*f,x=l*d,b=l*f;n[0]=c*d,n[4]=-c*f,n[8]=u,n[1]=m+x*u,n[5]=p-b*u,n[9]=-l*c,n[2]=b-p*u,n[6]=x+m*u,n[10]=o*c}else if(e.order==="YXZ"){const p=c*d,m=c*f,x=u*d,b=u*f;n[0]=p+b*l,n[4]=x*l-m,n[8]=o*u,n[1]=o*f,n[5]=o*d,n[9]=-l,n[2]=m*l-x,n[6]=b+p*l,n[10]=o*c}else if(e.order==="ZXY"){const p=c*d,m=c*f,x=u*d,b=u*f;n[0]=p-b*l,n[4]=-o*f,n[8]=x+m*l,n[1]=m+x*l,n[5]=o*d,n[9]=b-p*l,n[2]=-o*u,n[6]=l,n[10]=o*c}else if(e.order==="ZYX"){const p=o*d,m=o*f,x=l*d,b=l*f;n[0]=c*d,n[4]=x*u-m,n[8]=p*u+b,n[1]=c*f,n[5]=b*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,b=l*u;n[0]=c*d,n[4]=b-p*f,n[8]=x*f+m,n[1]=f,n[5]=o*d,n[9]=-l*d,n[2]=-u*d,n[6]=m*f+x,n[10]=p-b*f}else if(e.order==="XZY"){const p=o*c,m=o*u,x=l*c,b=l*u;n[0]=c*d,n[4]=-f,n[8]=u*d,n[1]=p*f+b,n[5]=o*d,n[9]=m*f-x,n[2]=x*f-m,n[6]=l*d,n[10]=b*f+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(CFe,e,PFe)}lookAt(e,n,r){const i=this.elements;return ro.subVectors(e,n),ro.lengthSq()===0&&(ro.z=1),ro.normalize(),jd.crossVectors(r,ro),jd.lengthSq()===0&&(Math.abs(r.z)===1?ro.x+=1e-4:ro.z+=1e-4,ro.normalize(),jd.crossVectors(r,ro)),jd.normalize(),A_.crossVectors(ro,jd),i[0]=jd.x,i[4]=A_.x,i[8]=ro.x,i[1]=jd.y,i[5]=A_.y,i[9]=ro.y,i[2]=jd.z,i[6]=A_.z,i[10]=ro.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const r=e.elements,i=n.elements,a=this.elements,o=r[0],l=r[4],c=r[8],u=r[12],d=r[1],f=r[5],p=r[9],m=r[13],x=r[2],b=r[6],v=r[10],y=r[14],S=r[3],k=r[7],T=r[11],M=r[15],C=i[0],E=i[4],R=i[8],A=i[12],D=i[1],I=i[5],F=i[9],z=i[13],P=i[2],$=i[6],X=i[10],V=i[14],Q=i[3],Z=i[7],se=i[11],H=i[15];return a[0]=o*C+l*D+c*P+u*Q,a[4]=o*E+l*I+c*$+u*Z,a[8]=o*R+l*F+c*X+u*se,a[12]=o*A+l*z+c*V+u*H,a[1]=d*C+f*D+p*P+m*Q,a[5]=d*E+f*I+p*$+m*Z,a[9]=d*R+f*F+p*X+m*se,a[13]=d*A+f*z+p*V+m*H,a[2]=x*C+b*D+v*P+y*Q,a[6]=x*E+b*I+v*$+y*Z,a[10]=x*R+b*F+v*X+y*se,a[14]=x*A+b*z+v*V+y*H,a[3]=S*C+k*D+T*P+M*Q,a[7]=S*E+k*I+T*$+M*Z,a[11]=S*R+k*F+T*X+M*se,a[15]=S*A+k*z+T*V+M*H,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],r=e[4],i=e[8],a=e[12],o=e[1],l=e[5],c=e[9],u=e[13],d=e[2],f=e[6],p=e[10],m=e[14],x=e[3],b=e[7],v=e[11],y=e[15];return x*(+a*c*f-i*u*f-a*l*p+r*u*p+i*l*m-r*c*m)+b*(+n*c*m-n*u*p+a*o*p-i*o*m+i*u*d-a*c*d)+v*(+n*u*f-n*l*m-a*o*f+r*o*m+a*l*d-r*u*d)+y*(-i*l*d-n*c*f+n*l*p+i*o*f-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],a=e[3],o=e[4],l=e[5],c=e[6],u=e[7],d=e[8],f=e[9],p=e[10],m=e[11],x=e[12],b=e[13],v=e[14],y=e[15],S=f*v*u-b*p*u+b*c*m-l*v*m-f*c*y+l*p*y,k=x*p*u-d*v*u-x*c*m+o*v*m+d*c*y-o*p*y,T=d*b*u-x*f*u+x*l*m-o*b*m-d*l*y+o*f*y,M=x*f*c-d*b*c-x*l*p+o*b*p+d*l*v-o*f*v,C=n*S+r*k+i*T+a*M;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]=(b*p*a-f*v*a-b*i*m+r*v*m+f*i*y-r*p*y)*E,e[2]=(l*v*a-b*c*a+b*i*u-r*v*u-l*i*y+r*c*y)*E,e[3]=(f*c*a-l*p*a-f*i*u+r*p*u+l*i*m-r*c*m)*E,e[4]=k*E,e[5]=(d*v*a-x*p*a+x*i*m-n*v*m-d*i*y+n*p*y)*E,e[6]=(x*c*a-o*v*a-x*i*u+n*v*u+o*i*y-n*c*y)*E,e[7]=(o*p*a-d*c*a+d*i*u-n*p*u-o*i*m+n*c*m)*E,e[8]=T*E,e[9]=(x*f*a-d*b*a-x*r*m+n*b*m+d*r*y-n*f*y)*E,e[10]=(o*b*a-x*l*a+x*r*u-n*b*u-o*r*y+n*l*y)*E,e[11]=(d*l*a-o*f*a-d*r*u+n*f*u+o*r*m-n*l*m)*E,e[12]=M*E,e[13]=(d*b*i-x*f*i+x*r*p-n*b*p-d*r*v+n*f*v)*E,e[14]=(x*l*i-o*b*i-x*r*c+n*b*c+o*r*v-n*l*v)*E,e[15]=(o*f*i-d*l*i+d*r*c-n*f*c-o*r*p+n*l*p)*E,this}scale(e){const n=this.elements,r=e.x,i=e.y,a=e.z;return n[0]*=r,n[4]*=i,n[8]*=a,n[1]*=r,n[5]*=i,n[9]*=a,n[2]*=r,n[6]*=i,n[10]*=a,n[3]*=r,n[7]*=i,n[11]*=a,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],r=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,r,i))}makeTranslation(e,n,r){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,n,0,0,1,r,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),r=Math.sin(e);return this.set(1,0,0,0,0,n,-r,0,0,r,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,0,r,0,0,1,0,0,-r,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),r=Math.sin(e);return this.set(n,-r,0,0,r,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const r=Math.cos(n),i=Math.sin(n),a=1-r,o=e.x,l=e.y,c=e.z,u=a*o,d=a*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,a*c*c+r,0,0,0,0,1),this}makeScale(e,n,r){return this.set(e,0,0,0,0,n,0,0,0,0,r,0,0,0,0,1),this}makeShear(e,n,r,i,a,o){return this.set(1,r,a,0,e,1,o,0,n,i,1,0,0,0,0,1),this}compose(e,n,r){const i=this.elements,a=n._x,o=n._y,l=n._z,c=n._w,u=a+a,d=o+o,f=l+l,p=a*u,m=a*d,x=a*f,b=o*d,v=o*f,y=l*f,S=c*u,k=c*d,T=c*f,M=r.x,C=r.y,E=r.z;return i[0]=(1-(b+y))*M,i[1]=(m+T)*M,i[2]=(x-k)*M,i[3]=0,i[4]=(m-T)*C,i[5]=(1-(p+y))*C,i[6]=(v+S)*C,i[7]=0,i[8]=(x+k)*E,i[9]=(v-S)*E,i[10]=(1-(p+b))*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 a=Bp.set(i[0],i[1],i[2]).length();const o=Bp.set(i[4],i[5],i[6]).length(),l=Bp.set(i[8],i[9],i[10]).length();this.determinant()<0&&(a=-a),e.x=i[12],e.y=i[13],e.z=i[14],Nl.copy(this);const u=1/a,d=1/o,f=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]*=f,Nl.elements[9]*=f,Nl.elements[10]*=f,n.setFromRotationMatrix(Nl),r.x=a,r.y=o,r.z=l,this}makePerspective(e,n,r,i,a,o,l=cc){const c=this.elements,u=2*a/(n-e),d=2*a/(r-i),f=(n+e)/(n-e),p=(r+i)/(r-i);let m,x;if(l===cc)m=-(o+a)/(o-a),x=-2*o*a/(o-a);else if(l===by)m=-o/(o-a),x=-o*a/(o-a);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+l);return c[0]=u,c[4]=0,c[8]=f,c[12]=0,c[1]=0,c[5]=d,c[9]=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,a,o,l=cc){const c=this.elements,u=1/(n-e),d=1/(r-i),f=1/(o-a),p=(n+e)*u,m=(r+i)*d;let x,b;if(l===cc)x=(o+a)*f,b=-2*f;else if(l===by)x=a*f,b=-1*f;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+l);return c[0]=2*u,c[4]=0,c[8]=0,c[12]=-p,c[1]=0,c[5]=2*d,c[9]=0,c[13]=-m,c[2]=0,c[6]=0,c[10]=b,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 Bp=new qe,Nl=new zr,CFe=new qe(0,0,0),PFe=new qe(1,1,1),jd=new qe,A_=new qe,ro=new qe,MG=new zr,kG=new vm;class mv{constructor(e=0,n=0,r=0,i=mv.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=n,this._z=r,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,r,i=this._order){return this._x=e,this._y=n,this._z=r,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,r=!0){const i=e.elements,a=i[0],o=i[4],l=i[8],c=i[1],u=i[5],d=i[9],f=i[2],p=i[6],m=i[10];switch(n){case"XYZ":this._y=Math.asin(Fa(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,m),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(p,u),this._z=0);break;case"YXZ":this._x=Math.asin(-Fa(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(l,m),this._z=Math.atan2(c,u)):(this._y=Math.atan2(-f,a),this._z=0);break;case"ZXY":this._x=Math.asin(Fa(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-f,m),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(c,a));break;case"ZYX":this._y=Math.asin(-Fa(f,-1,1)),Math.abs(f)<.9999999?(this._x=Math.atan2(p,m),this._z=Math.atan2(c,a)):(this._x=0,this._z=Math.atan2(-o,u));break;case"YZX":this._z=Math.asin(Fa(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-d,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(l,m));break;case"XZY":this._z=Math.asin(-Fa(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,u),this._y=Math.atan2(l,a)):(this._x=Math.atan2(-d,m),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,r===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,r){return MG.makeRotationFromQuaternion(e),this.setFromRotationMatrix(MG,n,r)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return kG.setFromEuler(this),this.setFromQuaternion(kG,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}}mv.DEFAULT_ORDER="XYZ";class tee{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 jFe=0;const EG=new qe,Hp=new vm,tu=new zr,C_=new qe,Xb=new qe,DFe=new qe,RFe=new vm,TG=new qe(1,0,0),AG=new qe(0,1,0),CG=new qe(0,0,1),OFe={type:"added"},LFe={type:"removed"};class ps extends Pm{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:jFe++}),this.uuid=Pu(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=ps.DEFAULT_UP.clone();const e=new qe,n=new mv,r=new vm,i=new qe(1,1,1);function a(){r.setFromEuler(n,!1)}function o(){n.setFromQuaternion(r,void 0,!1)}n._onChange(a),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 Fn}}),this.matrix=new zr,this.matrixWorld=new zr,this.matrixAutoUpdate=ps.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=ps.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new tee,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 Hp.setFromAxisAngle(e,n),this.quaternion.multiply(Hp),this}rotateOnWorldAxis(e,n){return Hp.setFromAxisAngle(e,n),this.quaternion.premultiply(Hp),this}rotateX(e){return this.rotateOnAxis(TG,e)}rotateY(e){return this.rotateOnAxis(AG,e)}rotateZ(e){return this.rotateOnAxis(CG,e)}translateOnAxis(e,n){return EG.copy(e).applyQuaternion(this.quaternion),this.position.add(EG.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(TG,e)}translateY(e){return this.translateOnAxis(AG,e)}translateZ(e){return this.translateOnAxis(CG,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(tu.copy(this.matrixWorld).invert())}lookAt(e,n,r){e.isVector3?C_.copy(e):C_.set(e,n,r);const i=this.parent;this.updateWorldMatrix(!0,!1),Xb.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?tu.lookAt(Xb,C_,this.up):tu.lookAt(C_,Xb,this.up),this.quaternion.setFromRotationMatrix(tu),i&&(tu.extractRotation(i.matrixWorld),Hp.setFromRotationMatrix(tu),this.quaternion.premultiply(Hp.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(OFe)):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(LFe)),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),tu.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),tu.multiply(e.parent.matrixWorld)),e.applyMatrix4(tu),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 a=0,o=i.length;a<o;a++)i[a].getObjectsByProperty(e,n,r);return r}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Xb,e,DFe),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Xb,RFe,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let r=0,i=n.length;r<i;r++)n[r].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let r=0,i=n.length;r<i;r++){const a=n[r];(a.matrixWorldAutoUpdate===!0||e===!0)&&a.updateMatrixWorld(e)}}updateWorldMatrix(e,n){const r=this.parent;if(e===!0&&r!==null&&r.matrixWorldAutoUpdate===!0&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0){const i=this.children;for(let a=0,o=i.length;a<o;a++){const l=i[a];l.matrixWorldAutoUpdate===!0&&l.updateWorldMatrix(!1,!0)}}}toJSON(e){const n=e===void 0||typeof e=="string",r={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},r.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map(l=>({boxInitialized:l.boxInitialized,boxMin:l.box.min.toArray(),boxMax:l.box.max.toArray(),sphereInitialized:l.sphereInitialized,sphereRadius:l.sphere.radius,sphereCenter:l.sphere.center.toArray()})),i.maxGeometryCount=this._maxGeometryCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),this.boundingSphere!==null&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),this.boundingBox!==null&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()}));function a(l,c){return l[c.uuid]===void 0&&(l[c.uuid]=c.toJSON(e)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=a(e.geometries,this.geometry);const l=this.geometry.parameters;if(l!==void 0&&l.shapes!==void 0){const c=l.shapes;if(Array.isArray(c))for(let u=0,d=c.length;u<d;u++){const f=c[u];a(e.shapes,f)}else a(e.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(a(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const l=[];for(let c=0,u=this.material.length;c<u;c++)l.push(a(e.materials,this.material[c]));i.material=l}else i.material=a(e.materials,this.material);if(this.children.length>0){i.children=[];for(let l=0;l<this.children.length;l++)i.children.push(this.children[l].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let l=0;l<this.animations.length;l++){const c=this.animations[l];i.animations.push(a(e.animations,c))}}if(n){const l=o(e.geometries),c=o(e.materials),u=o(e.textures),d=o(e.images),f=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),f.length>0&&(r.shapes=f),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}}ps.DEFAULT_UP=new qe(0,1,0);ps.DEFAULT_MATRIX_AUTO_UPDATE=!0;ps.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Ml=new qe,nu=new qe,UC=new qe,ru=new qe,$p=new qe,Vp=new qe,PG=new qe,zC=new qe,BC=new qe,HC=new qe;let P_=!1;class kl{constructor(e=new qe,n=new qe,r=new qe){this.a=e,this.b=n,this.c=r}static getNormal(e,n,r,i){i.subVectors(r,n),Ml.subVectors(e,n),i.cross(Ml);const a=i.lengthSq();return a>0?i.multiplyScalar(1/Math.sqrt(a)):i.set(0,0,0)}static getBarycoord(e,n,r,i,a){Ml.subVectors(i,n),nu.subVectors(r,n),UC.subVectors(e,n);const o=Ml.dot(Ml),l=Ml.dot(nu),c=Ml.dot(UC),u=nu.dot(nu),d=nu.dot(UC),f=o*u-l*l;if(f===0)return a.set(-2,-1,-1);const p=1/f,m=(u*c-l*d)*p,x=(o*d-l*c)*p;return a.set(1-m-x,x,m)}static containsPoint(e,n,r,i){return this.getBarycoord(e,n,r,i,ru),ru.x>=0&&ru.y>=0&&ru.x+ru.y<=1}static getUV(e,n,r,i,a,o,l,c){return P_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),P_=!0),this.getInterpolation(e,n,r,i,a,o,l,c)}static getInterpolation(e,n,r,i,a,o,l,c){return this.getBarycoord(e,n,r,i,ru),c.setScalar(0),c.addScaledVector(a,ru.x),c.addScaledVector(o,ru.y),c.addScaledVector(l,ru.z),c}static isFrontFacing(e,n,r,i){return Ml.subVectors(r,n),nu.subVectors(e,n),Ml.cross(nu).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),nu.subVectors(this.a,this.b),Ml.cross(nu).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return kl.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return kl.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,r,i,a){return P_===!1&&(console.warn("THREE.Triangle.getUV() has been renamed to THREE.Triangle.getInterpolation()."),P_=!0),kl.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}getInterpolation(e,n,r,i,a){return kl.getInterpolation(e,this.a,this.b,this.c,n,r,i,a)}containsPoint(e){return kl.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return kl.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const r=this.a,i=this.b,a=this.c;let o,l;$p.subVectors(i,r),Vp.subVectors(a,r),zC.subVectors(e,r);const c=$p.dot(zC),u=Vp.dot(zC);if(c<=0&&u<=0)return n.copy(r);BC.subVectors(e,i);const d=$p.dot(BC),f=Vp.dot(BC);if(d>=0&&f<=d)return n.copy(i);const p=c*f-d*u;if(p<=0&&c>=0&&d<=0)return o=c/(c-d),n.copy(r).addScaledVector($p,o);HC.subVectors(e,a);const m=$p.dot(HC),x=Vp.dot(HC);if(x>=0&&m<=x)return n.copy(a);const b=m*u-c*x;if(b<=0&&u>=0&&x<=0)return l=u/(u-x),n.copy(r).addScaledVector(Vp,l);const v=d*x-m*f;if(v<=0&&f-d>=0&&m-x>=0)return PG.subVectors(a,i),l=(f-d)/(f-d+(m-x)),n.copy(i).addScaledVector(PG,l);const y=1/(v+b+p);return o=b*y,l=p*y,n.copy(r).addScaledVector($p,o).addScaledVector(Vp,l)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const nee={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},j_={h:0,s:0,l:0};function $C(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*6*(2/3-n):t}let Zt=class{constructor(e,n,r){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,n,r)}set(e,n,r){if(n===void 0&&r===void 0){const i=e;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(e,n,r);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=La){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=sL(e,1),n=Fa(n,0,1),r=Fa(r,0,1),n===0)this.r=this.g=this.b=r;else{const a=r<=.5?r*(1+n):r+n-r*n,o=2*r-a;this.r=$C(o,a,e+1/3),this.g=$C(o,a,e),this.b=$C(o,a,e-1/3)}return Er.toWorkingColorSpace(this,i),this}setStyle(e,n=La){function r(a){a!==void 0&&parseFloat(a)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let a;const o=i[1],l=i[2];switch(o){case"rgb":case"rgba":if(a=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(255,parseInt(a[1],10))/255,Math.min(255,parseInt(a[2],10))/255,Math.min(255,parseInt(a[3],10))/255,n);if(a=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setRGB(Math.min(100,parseInt(a[1],10))/100,Math.min(100,parseInt(a[2],10))/100,Math.min(100,parseInt(a[3],10))/100,n);break;case"hsl":case"hsla":if(a=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(l))return r(a[4]),this.setHSL(parseFloat(a[1])/360,parseFloat(a[2])/100,parseFloat(a[3])/100,n);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const a=i[1],o=a.length;if(o===3)return this.setRGB(parseInt(a.charAt(0),16)/15,parseInt(a.charAt(1),16)/15,parseInt(a.charAt(2),16)/15,n);if(o===6)return this.setHex(parseInt(a,16),n);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,n);return this}setColorName(e,n=La){const r=nee[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=PC(e.r),this.g=PC(e.g),this.b=PC(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=La){return Er.fromWorkingColorSpace(qa.copy(this),e),Math.round(Fa(qa.r*255,0,255))*65536+Math.round(Fa(qa.g*255,0,255))*256+Math.round(Fa(qa.b*255,0,255))}getHexString(e=La){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=Er.workingColorSpace){Er.fromWorkingColorSpace(qa.copy(this),n);const r=qa.r,i=qa.g,a=qa.b,o=Math.max(r,i,a),l=Math.min(r,i,a);let c,u;const d=(l+o)/2;if(l===o)c=0,u=0;else{const f=o-l;switch(u=d<=.5?f/(o+l):f/(2-o-l),o){case r:c=(i-a)/f+(i<a?6:0);break;case i:c=(a-r)/f+2;break;case a:c=(r-i)/f+4;break}c/=6}return e.h=c,e.s=u,e.l=d,e}getRGB(e,n=Er.workingColorSpace){return Er.fromWorkingColorSpace(qa.copy(this),n),e.r=qa.r,e.g=qa.g,e.b=qa.b,e}getStyle(e=La){Er.fromWorkingColorSpace(qa.copy(this),e);const n=qa.r,r=qa.g,i=qa.b;return e!==La?`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(j_);const r=_0(Dd.h,j_.h,n),i=_0(Dd.s,j_.s,n),a=_0(Dd.l,j_.l,n);return this.setHSL(r,i,a),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const n=this.r,r=this.g,i=this.b,a=e.elements;return this.r=a[0]*n+a[3]*r+a[6]*i,this.g=a[1]*n+a[4]*r+a[7]*i,this.b=a[2]*n+a[5]*r+a[8]*i,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}};const qa=new Zt;Zt.NAMES=nee;let FFe=0;class Dx extends Pm{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:FFe++}),this.uuid=Pu(),this.name="",this.type="Material",this.blending=Pg,this.side=Th,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=fD,this.blendDst=mD,this.blendEquation=kf,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Zt(0,0,0),this.blendAlpha=0,this.depthFunc=JS,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=bG,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Lp,this.stencilZFail=Lp,this.stencilZPass=Lp,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!==Pg&&(r.blending=this.blending),this.side!==Th&&(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!==fD&&(r.blendSrc=this.blendSrc),this.blendDst!==mD&&(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!==JS&&(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!==bG&&(r.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(r.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(r.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Lp&&(r.stencilFail=this.stencilFail),this.stencilZFail!==Lp&&(r.stencilZFail=this.stencilZFail),this.stencilZPass!==Lp&&(r.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(r.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(r.rotation=this.rotation),this.polygonOffset===!0&&(r.polygonOffset=!0),this.polygonOffsetFactor!==0&&(r.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(r.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(r.linewidth=this.linewidth),this.dashSize!==void 0&&(r.dashSize=this.dashSize),this.gapSize!==void 0&&(r.gapSize=this.gapSize),this.scale!==void 0&&(r.scale=this.scale),this.dithering===!0&&(r.dithering=!0),this.alphaTest>0&&(r.alphaTest=this.alphaTest),this.alphaHash===!0&&(r.alphaHash=!0),this.alphaToCoverage===!0&&(r.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(r.premultipliedAlpha=!0),this.forceSinglePass===!0&&(r.forceSinglePass=!0),this.wireframe===!0&&(r.wireframe=!0),this.wireframeLinewidth>1&&(r.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(r.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(r.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(r.flatShading=!0),this.visible===!1&&(r.visible=!1),this.toneMapped===!1&&(r.toneMapped=!1),this.fog===!1&&(r.fog=!1),Object.keys(this.userData).length>0&&(r.userData=this.userData);function i(a){const o=[];for(const l in a){const c=a[l];delete c.metadata,o.push(c)}return o}if(n){const a=i(e.textures),o=i(e.images);a.length>0&&(r.textures=a),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 a=0;a!==i;++a)r[a]=n[a].clone()}return this.clippingPlanes=r,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class ree extends Dx{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Zt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=rL,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 qe,D_=new bn;class po{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=yD,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Su,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.BufferAttribute: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,n,r){e*=this.itemSize,r*=n.itemSize;for(let i=0,a=this.itemSize;i<a;i++)this.array[e+i]=n.array[r+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,r=this.count;n<r;n++)D_.fromBufferAttribute(this,n),D_.applyMatrix3(e),this.setXY(n,D_.x,D_.y);else if(this.itemSize===3)for(let n=0,r=this.count;n<r;n++)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=ac(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=ac(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=ac(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=ac(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=ac(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,a){return e*=this.itemSize,this.normalized&&(n=kr(n,this.array),r=kr(r,this.array),i=kr(i,this.array),a=kr(a,this.array)),this.array[e+0]=n,this.array[e+1]=r,this.array[e+2]=i,this.array[e+3]=a,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==yD&&(e.usage=this.usage),e}}class iee extends po{constructor(e,n,r){super(new Uint16Array(e),n,r)}}class aee extends po{constructor(e,n,r){super(new Uint32Array(e),n,r)}}class Ai extends po{constructor(e,n,r){super(new Float32Array(e),n,r)}}let IFe=0;const Fo=new zr,VC=new ps,Gp=new qe,io=new rl,Yb=new rl,fa=new qe;class ns extends Pm{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:IFe++}),this.uuid=Pu(),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(QJ(e)?aee:iee)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,r=0){this.groups.push({start:e,count:n,materialIndex:r})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const r=this.attributes.normal;if(r!==void 0){const a=new Fn().getNormalMatrix(e);r.applyNormalMatrix(a),r.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(e),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Fo.makeRotationFromQuaternion(e),this.applyMatrix4(Fo),this}rotateX(e){return Fo.makeRotationX(e),this.applyMatrix4(Fo),this}rotateY(e){return Fo.makeRotationY(e),this.applyMatrix4(Fo),this}rotateZ(e){return Fo.makeRotationZ(e),this.applyMatrix4(Fo),this}translate(e,n,r){return Fo.makeTranslation(e,n,r),this.applyMatrix4(Fo),this}scale(e,n,r){return Fo.makeScale(e,n,r),this.applyMatrix4(Fo),this}lookAt(e){return VC.lookAt(e),VC.updateMatrix(),this.applyMatrix4(VC.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Gp).negate(),this.translate(Gp.x,Gp.y,Gp.z),this}setFromPoints(e){const n=[];for(let r=0,i=e.length;r<i;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}return this.setAttribute("position",new Ai(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new rl);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new qe(-1/0,-1/0,-1/0),new qe(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let r=0,i=n.length;r<i;r++){const a=n[r];io.setFromBufferAttribute(a),this.morphTargetsRelative?(fa.addVectors(this.boundingBox.min,io.min),this.boundingBox.expandByPoint(fa),fa.addVectors(this.boundingBox.max,io.max),this.boundingBox.expandByPoint(fa)):(this.boundingBox.expandByPoint(io.min),this.boundingBox.expandByPoint(io.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 hc);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new qe,1/0);return}if(e){const r=this.boundingSphere.center;if(io.setFromBufferAttribute(e),n)for(let a=0,o=n.length;a<o;a++){const l=n[a];Yb.setFromBufferAttribute(l),this.morphTargetsRelative?(fa.addVectors(io.min,Yb.min),io.expandByPoint(fa),fa.addVectors(io.max,Yb.max),io.expandByPoint(fa)):(io.expandByPoint(Yb.min),io.expandByPoint(Yb.max))}io.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)fa.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(fa));if(n)for(let a=0,o=n.length;a<o;a++){const l=n[a],c=this.morphTargetsRelative;for(let u=0,d=l.count;u<d;u++)fa.fromBufferAttribute(l,u),c&&(Gp.fromBufferAttribute(e,u),fa.add(Gp)),i=Math.max(i,r.distanceToSquared(fa))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const r=e.array,i=n.position.array,a=n.normal.array,o=n.uv.array,l=i.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new po(new Float32Array(4*l),4));const c=this.getAttribute("tangent").array,u=[],d=[];for(let D=0;D<l;D++)u[D]=new qe,d[D]=new qe;const f=new qe,p=new qe,m=new qe,x=new bn,b=new bn,v=new bn,y=new qe,S=new qe;function k(D,I,F){f.fromArray(i,D*3),p.fromArray(i,I*3),m.fromArray(i,F*3),x.fromArray(o,D*2),b.fromArray(o,I*2),v.fromArray(o,F*2),p.sub(f),m.sub(f),b.sub(x),v.sub(x);const z=1/(b.x*v.y-v.x*b.y);isFinite(z)&&(y.copy(p).multiplyScalar(v.y).addScaledVector(m,-b.y).multiplyScalar(z),S.copy(m).multiplyScalar(b.x).addScaledVector(p,-v.x).multiplyScalar(z),u[D].add(y),u[I].add(y),u[F].add(y),d[D].add(S),d[I].add(S),d[F].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 F=T[D],z=F.start,P=F.count;for(let $=z,X=z+P;$<X;$+=3)k(r[$+0],r[$+1],r[$+2])}const M=new qe,C=new qe,E=new qe,R=new qe;function A(D){E.fromArray(a,D*3),R.copy(E);const I=u[D];M.copy(I),M.sub(E.multiplyScalar(E.dot(I))).normalize(),C.crossVectors(R,I);const z=C.dot(d[D])<0?-1:1;c[D*4]=M.x,c[D*4+1]=M.y,c[D*4+2]=M.z,c[D*4+3]=z}for(let D=0,I=T.length;D<I;++D){const F=T[D],z=F.start,P=F.count;for(let $=z,X=z+P;$<X;$+=3)A(r[$+0]),A(r[$+1]),A(r[$+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 po(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 qe,a=new qe,o=new qe,l=new qe,c=new qe,u=new qe,d=new qe,f=new qe;if(e)for(let p=0,m=e.count;p<m;p+=3){const x=e.getX(p+0),b=e.getX(p+1),v=e.getX(p+2);i.fromBufferAttribute(n,x),a.fromBufferAttribute(n,b),o.fromBufferAttribute(n,v),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),l.fromBufferAttribute(r,x),c.fromBufferAttribute(r,b),u.fromBufferAttribute(r,v),l.add(d),c.add(d),u.add(d),r.setXYZ(x,l.x,l.y,l.z),r.setXYZ(b,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),a.fromBufferAttribute(n,p+1),o.fromBufferAttribute(n,p+2),d.subVectors(o,a),f.subVectors(i,a),d.cross(f),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++)fa.fromBufferAttribute(e,n),fa.normalize(),e.setXYZ(n,fa.x,fa.y,fa.z)}toNonIndexed(){function e(l,c){const u=l.array,d=l.itemSize,f=l.normalized,p=new u.constructor(c.length*d);let m=0,x=0;for(let b=0,v=c.length;b<v;b++){l.isInterleavedBufferAttribute?m=c[b]*l.data.stride+l.offset:m=c[b]*d;for(let y=0;y<d;y++)p[x++]=u[m++]}return new po(p,d,f)}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 a=this.morphAttributes;for(const l in a){const c=[],u=a[l];for(let d=0,f=u.length;d<f;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 a=!1;for(const c in this.morphAttributes){const u=this.morphAttributes[c],d=[];for(let f=0,p=u.length;f<p;f++){const m=u[f];d.push(m.toJSON(e.data))}d.length>0&&(i[c]=d,a=!0)}a&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const 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 a=e.morphAttributes;for(const u in a){const d=[],f=a[u];for(let p=0,m=f.length;p<m;p++)d.push(f[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 f=o[u];this.addGroup(f.start,f.count,f.materialIndex)}const l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());const c=e.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const jG=new zr,pf=new oL,R_=new hc,DG=new qe,qp=new qe,Wp=new qe,Kp=new qe,GC=new qe,O_=new qe,L_=new bn,F_=new bn,I_=new bn,RG=new qe,OG=new qe,LG=new qe,U_=new qe,z_=new qe;class Dl extends ps{constructor(e=new ns,n=new ree){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}getVertexPosition(e,n){const r=this.geometry,i=r.attributes.position,a=r.morphAttributes.position,o=r.morphTargetsRelative;n.fromBufferAttribute(i,e);const l=this.morphTargetInfluences;if(a&&l){O_.set(0,0,0);for(let c=0,u=a.length;c<u;c++){const d=l[c],f=a[c];d!==0&&(GC.fromBufferAttribute(f,e),o?O_.addScaledVector(GC,d):O_.addScaledVector(GC.sub(n),d))}n.add(O_)}return n}raycast(e,n){const r=this.geometry,i=this.material,a=this.matrixWorld;i!==void 0&&(r.boundingSphere===null&&r.computeBoundingSphere(),R_.copy(r.boundingSphere),R_.applyMatrix4(a),pf.copy(e.ray).recast(e.near),!(R_.containsPoint(pf.origin)===!1&&(pf.intersectSphere(R_,DG)===null||pf.origin.distanceToSquared(DG)>(e.far-e.near)**2))&&(jG.copy(a).invert(),pf.copy(e.ray).applyMatrix4(jG),!(r.boundingBox!==null&&pf.intersectsBox(r.boundingBox)===!1)&&this._computeIntersections(e,n,pf)))}_computeIntersections(e,n,r){let i;const a=this.geometry,o=this.material,l=a.index,c=a.attributes.position,u=a.attributes.uv,d=a.attributes.uv1,f=a.attributes.normal,p=a.groups,m=a.drawRange;if(l!==null)if(Array.isArray(o))for(let x=0,b=p.length;x<b;x++){const v=p[x],y=o[v.materialIndex],S=Math.max(v.start,m.start),k=Math.min(l.count,Math.min(v.start+v.count,m.start+m.count));for(let T=S,M=k;T<M;T+=3){const C=l.getX(T),E=l.getX(T+1),R=l.getX(T+2);i=B_(this,y,e,r,u,d,f,C,E,R),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),b=Math.min(l.count,m.start+m.count);for(let v=x,y=b;v<y;v+=3){const S=l.getX(v),k=l.getX(v+1),T=l.getX(v+2);i=B_(this,o,e,r,u,d,f,S,k,T),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}else if(c!==void 0)if(Array.isArray(o))for(let x=0,b=p.length;x<b;x++){const v=p[x],y=o[v.materialIndex],S=Math.max(v.start,m.start),k=Math.min(c.count,Math.min(v.start+v.count,m.start+m.count));for(let T=S,M=k;T<M;T+=3){const C=T,E=T+1,R=T+2;i=B_(this,y,e,r,u,d,f,C,E,R),i&&(i.faceIndex=Math.floor(T/3),i.face.materialIndex=v.materialIndex,n.push(i))}}else{const x=Math.max(0,m.start),b=Math.min(c.count,m.start+m.count);for(let v=x,y=b;v<y;v+=3){const S=v,k=v+1,T=v+2;i=B_(this,o,e,r,u,d,f,S,k,T),i&&(i.faceIndex=Math.floor(v/3),n.push(i))}}}}function UFe(t,e,n,r,i,a,o,l){let c;if(e.side===Us?c=r.intersectTriangle(o,a,i,!0,l):c=r.intersectTriangle(i,a,o,e.side===Th,l),c===null)return null;z_.copy(l),z_.applyMatrix4(t.matrixWorld);const u=n.ray.origin.distanceTo(z_);return u<n.near||u>n.far?null:{distance:u,point:z_.clone(),object:t}}function B_(t,e,n,r,i,a,o,l,c,u){t.getVertexPosition(l,qp),t.getVertexPosition(c,Wp),t.getVertexPosition(u,Kp);const d=UFe(t,e,n,r,qp,Wp,Kp,U_);if(d){i&&(L_.fromBufferAttribute(i,l),F_.fromBufferAttribute(i,c),I_.fromBufferAttribute(i,u),d.uv=kl.getInterpolation(U_,qp,Wp,Kp,L_,F_,I_,new bn)),a&&(L_.fromBufferAttribute(a,l),F_.fromBufferAttribute(a,c),I_.fromBufferAttribute(a,u),d.uv1=kl.getInterpolation(U_,qp,Wp,Kp,L_,F_,I_,new bn),d.uv2=d.uv1),o&&(RG.fromBufferAttribute(o,l),OG.fromBufferAttribute(o,c),LG.fromBufferAttribute(o,u),d.normal=kl.getInterpolation(U_,qp,Wp,Kp,RG,OG,LG,new qe),d.normal.dot(r.direction)>0&&d.normal.multiplyScalar(-1));const f={a:l,b:c,c:u,normal:new qe,materialIndex:0};kl.getNormal(qp,Wp,Kp,f.normal),d.face=f}return d}class pv extends ns{constructor(e=1,n=1,r=1,i=1,a=1,o=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:r,widthSegments:i,heightSegments:a,depthSegments:o};const l=this;i=Math.floor(i),a=Math.floor(a),o=Math.floor(o);const c=[],u=[],d=[],f=[];let p=0,m=0;x("z","y","x",-1,-1,r,n,e,o,a,0),x("z","y","x",1,-1,r,n,-e,o,a,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,a,4),x("x","y","z",-1,-1,e,n,-r,i,a,5),this.setIndex(c),this.setAttribute("position",new Ai(u,3)),this.setAttribute("normal",new Ai(d,3)),this.setAttribute("uv",new Ai(f,2));function x(b,v,y,S,k,T,M,C,E,R,A){const D=T/E,I=M/R,F=T/2,z=M/2,P=C/2,$=E+1,X=R+1;let V=0,Q=0;const Z=new qe;for(let se=0;se<X;se++){const H=se*I-z;for(let K=0;K<$;K++){const re=K*D-F;Z[b]=re*S,Z[v]=H*k,Z[y]=P,u.push(Z.x,Z.y,Z.z),Z[b]=0,Z[v]=0,Z[y]=C>0?1:-1,d.push(Z.x,Z.y,Z.z),f.push(K/E),f.push(1-se/R),V+=1}}for(let se=0;se<R;se++)for(let H=0;H<E;H++){const K=p+H+$*se,re=p+H+$*(se+1),ne=p+(H+1)+$*(se+1),be=p+(H+1)+$*se;c.push(K,re,be),c.push(re,ne,be),Q+=6}l.addGroup(m,Q,A),m+=Q,p+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new pv(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function ax(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 us(t){const e={};for(let n=0;n<t.length;n++){const r=ax(t[n]);for(const i in r)e[i]=r[i]}return e}function zFe(t){const e=[];for(let n=0;n<t.length;n++)e.push(t[n].clone());return e}function see(t){return t.getRenderTarget()===null?t.outputColorSpace:Er.workingColorSpace}const lL={clone:ax,merge:us};var BFe=`void main() {
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
- }`,HFe=`void main() {
- gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
- }`;class Ah extends Dx{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=BFe,this.fragmentShader=HFe,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=ax(e.uniforms),this.uniformsGroups=zFe(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 oee extends ps{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new zr,this.projectionMatrix=new zr,this.projectionMatrixInverse=new zr,this.coordinateSystem=cc}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 so extends oee{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=yy*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(w0*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return yy*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,a,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=a,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,a=-.5*i;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,u=o.fullHeight;a+=o.offsetX*i/c,n-=o.offsetY*r/u,i*=o.width/c,r*=o.height/u}const l=this.filmOffset;l!==0&&(a+=e*l/this.getFilmWidth()),this.projectionMatrix.makePerspective(a,a+i,n,n-r,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const Xp=-90,Yp=1;class $Fe extends ps{constructor(e,n,r){super(),this.type="CubeCamera",this.renderTarget=r,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new so(Xp,Yp,e,n);i.layers=this.layers,this.add(i);const a=new so(Xp,Yp,e,n);a.layers=this.layers,this.add(a);const o=new so(Xp,Yp,e,n);o.layers=this.layers,this.add(o);const l=new so(Xp,Yp,e,n);l.layers=this.layers,this.add(l);const c=new so(Xp,Yp,e,n);c.layers=this.layers,this.add(c);const u=new so(Xp,Yp,e,n);u.layers=this.layers,this.add(u)}updateCoordinateSystem(){const e=this.coordinateSystem,n=this.children.concat(),[r,i,a,o,l,c]=n;for(const u of n)this.remove(u);if(e===cc)r.up.set(0,1,0),r.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),a.up.set(0,0,-1),a.lookAt(0,1,0),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===by)r.up.set(0,-1,0),r.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),a.up.set(0,0,1),a.lookAt(0,1,0),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[a,o,l,c,u,d]=this.children,f=e.getRenderTarget(),p=e.getActiveCubeFace(),m=e.getActiveMipmapLevel(),x=e.xr.enabled;e.xr.enabled=!1;const b=r.texture.generateMipmaps;r.texture.generateMipmaps=!1,e.setRenderTarget(r,0,i),e.render(n,a),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=b,e.setRenderTarget(r,5,i),e.render(n,d),e.setRenderTarget(f,p,m),e.xr.enabled=x,r.texture.needsPMREMUpdate=!0}}class lee extends zs{constructor(e,n,r,i,a,o,l,c,u,d){e=e!==void 0?e:[],n=n!==void 0?n:nx,super(e,n,r,i,a,o,l,c,u,d),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class VFe extends ym{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===Kf?La:Yo),this.texture=new lee(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:Ko}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.colorSpace=n.colorSpace,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const r={uniforms:{tEquirect:{value:null}},vertexShader:`
- varying vec3 vWorldDirection;
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }
- `,fragmentShader:`
- uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- }
- `},i=new pv(5,5,5),a=new Ah({name:"CubemapFromEquirect",uniforms:ax(r.uniforms),vertexShader:r.vertexShader,fragmentShader:r.fragmentShader,side:Us,blending:ch});a.uniforms.tEquirect.value=n;const o=new Dl(i,a),l=n.minFilter;return n.minFilter===gy&&(n.minFilter=Ko),new $Fe(1,10,this).update(e,o),n.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,n,r,i){const a=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(n,r,i);e.setRenderTarget(a)}}const qC=new qe,GFe=new qe,qFe=new Fn;class Hd{constructor(e=new qe(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,r,i){return this.normal.set(e,n,r),this.constant=i,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,r){const i=qC.subVectors(r,n).cross(GFe.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(qC),i=this.normal.dot(r);if(i===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/i;return a<0||a>1?null:n.copy(e.start).addScaledVector(r,a)}intersectsLine(e){const n=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return n<0&&r>0||r<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const r=n||qFe.getNormalMatrix(e),i=this.coplanarPoint(qC).applyMatrix4(e),a=this.normal.applyMatrix3(r).normalize();return this.constant=-i.dot(a),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const gf=new hc,H_=new qe;class v2{constructor(e=new Hd,n=new Hd,r=new Hd,i=new Hd,a=new Hd,o=new Hd){this.planes=[e,n,r,i,a,o]}set(e,n,r,i,a,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(a),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=cc){const r=this.planes,i=e.elements,a=i[0],o=i[1],l=i[2],c=i[3],u=i[4],d=i[5],f=i[6],p=i[7],m=i[8],x=i[9],b=i[10],v=i[11],y=i[12],S=i[13],k=i[14],T=i[15];if(r[0].setComponents(c-a,p-u,v-m,T-y).normalize(),r[1].setComponents(c+a,p+u,v+m,T+y).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-f,v-b,T-k).normalize(),n===cc)r[5].setComponents(c+l,p+f,v+b,T+k).normalize();else if(n===by)r[5].setComponents(l,f,b,k).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(),gf.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const n=e.geometry;n.boundingSphere===null&&n.computeBoundingSphere(),gf.copy(n.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(gf)}intersectsSprite(e){return gf.center.set(0,0,0),gf.radius=.7071067811865476,gf.applyMatrix4(e.matrixWorld),this.intersectsSphere(gf)}intersectsSphere(e){const n=this.planes,r=e.center,i=-e.radius;for(let a=0;a<6;a++)if(n[a].distanceToPoint(r)<i)return!1;return!0}intersectsBox(e){const n=this.planes;for(let r=0;r<6;r++){const i=n[r];if(H_.x=i.normal.x>0?e.max.x:e.min.x,H_.y=i.normal.y>0?e.max.y:e.min.y,H_.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(H_)<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 cee(){let t=null,e=!1,n=null,r=null;function i(a,o){n(a,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(a){n=a},setContext:function(a){t=a}}}function WFe(t,e){const n=e.isWebGL2,r=new WeakMap;function i(u,d){const f=u.array,p=u.usage,m=f.byteLength,x=t.createBuffer();t.bindBuffer(d,x),t.bufferData(d,f,p),u.onUploadCallback();let b;if(f instanceof Float32Array)b=t.FLOAT;else if(f instanceof Uint16Array)if(u.isFloat16BufferAttribute)if(n)b=t.HALF_FLOAT;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else b=t.UNSIGNED_SHORT;else if(f instanceof Int16Array)b=t.SHORT;else if(f instanceof Uint32Array)b=t.UNSIGNED_INT;else if(f instanceof Int32Array)b=t.INT;else if(f instanceof Int8Array)b=t.BYTE;else if(f instanceof Uint8Array)b=t.UNSIGNED_BYTE;else if(f instanceof Uint8ClampedArray)b=t.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+f);return{buffer:x,type:b,bytesPerElement:f.BYTES_PER_ELEMENT,version:u.version,size:m}}function a(u,d,f){const p=d.array,m=d._updateRange,x=d.updateRanges;if(t.bindBuffer(f,u),m.count===-1&&x.length===0&&t.bufferSubData(f,0,p),x.length!==0){for(let b=0,v=x.length;b<v;b++){const y=x[b];n?t.bufferSubData(f,y.start*p.BYTES_PER_ELEMENT,p,y.start,y.count):t.bufferSubData(f,y.start*p.BYTES_PER_ELEMENT,p.subarray(y.start,y.start+y.count))}d.clearUpdateRanges()}m.count!==-1&&(n?t.bufferSubData(f,m.offset*p.BYTES_PER_ELEMENT,p,m.offset,m.count):t.bufferSubData(f,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 f=r.get(u);if(f===void 0)r.set(u,i(u,d));else if(f.version<u.version){if(f.size!==u.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");a(f.buffer,u,d),f.version=u.version}}return{get:o,remove:l,update:c}}class cL 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 a=e/2,o=n/2,l=Math.floor(r),c=Math.floor(i),u=l+1,d=c+1,f=e/l,p=n/c,m=[],x=[],b=[],v=[];for(let y=0;y<d;y++){const S=y*p-o;for(let k=0;k<u;k++){const T=k*f-a;x.push(T,-S,0),b.push(0,0,1),v.push(k/l),v.push(1-y/c)}}for(let y=0;y<c;y++)for(let S=0;S<l;S++){const k=S+u*y,T=S+u*(y+1),M=S+1+u*(y+1),C=S+1+u*y;m.push(k,T,C),m.push(T,M,C)}this.setIndex(m),this.setAttribute("position",new Ai(x,3)),this.setAttribute("normal",new Ai(b,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 cL(e.width,e.height,e.widthSegments,e.heightSegments)}}var KFe=`#ifdef USE_ALPHAHASH
- if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
- #endif`,XFe=`#ifdef USE_ALPHAHASH
- const float ALPHA_HASH_SCALE = 0.05;
- float hash2D( vec2 value ) {
- return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
- }
- float hash3D( vec3 value ) {
- return hash2D( vec2( hash2D( value.xy ), value.z ) );
- }
- float getAlphaHashThreshold( vec3 position ) {
- float maxDeriv = max(
- length( dFdx( position.xyz ) ),
- length( dFdy( position.xyz ) )
- );
- float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
- vec2 pixScales = vec2(
- exp2( floor( log2( pixScale ) ) ),
- exp2( ceil( log2( pixScale ) ) )
- );
- vec2 alpha = vec2(
- hash3D( floor( pixScales.x * position.xyz ) ),
- hash3D( floor( pixScales.y * position.xyz ) )
- );
- float lerpFactor = fract( log2( pixScale ) );
- float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
- float a = min( lerpFactor, 1.0 - lerpFactor );
- vec3 cases = vec3(
- x * x / ( 2.0 * a * ( 1.0 - a ) ),
- ( x - 0.5 * a ) / ( 1.0 - a ),
- 1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
- );
- float threshold = ( x < ( 1.0 - a ) )
- ? ( ( x < a ) ? cases.x : cases.y )
- : cases.z;
- return clamp( threshold , 1.0e-6, 1.0 );
- }
- #endif`,YFe=`#ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
- #endif`,QFe=`#ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,ZFe=`#ifdef USE_ALPHATEST
- if ( diffuseColor.a < alphaTest ) discard;
- #endif`,JFe=`#ifdef USE_ALPHATEST
- uniform float alphaTest;
- #endif`,eIe=`#ifdef USE_AOMAP
- float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
- reflectedLight.indirectDiffuse *= ambientOcclusion;
- #if defined( USE_CLEARCOAT )
- clearcoatSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_SHEEN )
- sheenSpecularIndirect *= ambientOcclusion;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD )
- float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
- reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
- #endif
- #endif`,tIe=`#ifdef USE_AOMAP
- uniform sampler2D aoMap;
- uniform float aoMapIntensity;
- #endif`,nIe=`#ifdef USE_BATCHING
- attribute float batchId;
- uniform highp sampler2D batchingTexture;
- mat4 getBatchingMatrix( const in float i ) {
- int size = textureSize( batchingTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,rIe=`#ifdef USE_BATCHING
- mat4 batchingMatrix = getBatchingMatrix( batchId );
- #endif`,iIe=`vec3 transformed = vec3( position );
- #ifdef USE_ALPHAHASH
- vPosition = vec3( position );
- #endif`,aIe=`vec3 objectNormal = vec3( normal );
- #ifdef USE_TANGENT
- vec3 objectTangent = vec3( tangent.xyz );
- #endif`,sIe=`float G_BlinnPhong_Implicit( ) {
- return 0.25;
- }
- float D_BlinnPhong( const in float shininess, const in float dotNH ) {
- return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
- }
- vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( specularColor, 1.0, dotVH );
- float G = G_BlinnPhong_Implicit( );
- float D = D_BlinnPhong( shininess, dotNH );
- return F * ( G * D );
- } // validated`,oIe=`#ifdef USE_IRIDESCENCE
- const mat3 XYZ_TO_REC709 = mat3(
- 3.2404542, -0.9692660, 0.0556434,
- -1.5371385, 1.8760108, -0.2040259,
- -0.4985314, 0.0415560, 1.0572252
- );
- vec3 Fresnel0ToIor( vec3 fresnel0 ) {
- vec3 sqrtF0 = sqrt( fresnel0 );
- return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
- }
- vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
- }
- float IorToFresnel0( float transmittedIor, float incidentIor ) {
- return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
- }
- vec3 evalSensitivity( float OPD, vec3 shift ) {
- float phase = 2.0 * PI * OPD * 1.0e-9;
- vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
- vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
- vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
- vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
- xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
- xyz /= 1.0685e-7;
- vec3 rgb = XYZ_TO_REC709 * xyz;
- return rgb;
- }
- vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
- vec3 I;
- float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
- float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
- float cosTheta2Sq = 1.0 - sinTheta2Sq;
- if ( cosTheta2Sq < 0.0 ) {
- return vec3( 1.0 );
- }
- float cosTheta2 = sqrt( cosTheta2Sq );
- float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
- float R12 = F_Schlick( R0, 1.0, cosTheta1 );
- float T121 = 1.0 - R12;
- float phi12 = 0.0;
- if ( iridescenceIOR < outsideIOR ) phi12 = PI;
- float phi21 = PI - phi12;
- vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
- vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
- vec3 phi23 = vec3( 0.0 );
- if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
- if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
- if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
- float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
- vec3 phi = vec3( phi21 ) + phi23;
- vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
- vec3 r123 = sqrt( R123 );
- vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
- vec3 C0 = R12 + Rs;
- I = C0;
- vec3 Cm = Rs - T121;
- for ( int m = 1; m <= 2; ++ m ) {
- Cm *= r123;
- vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
- I += Cm * Sm;
- }
- return max( I, vec3( 0.0 ) );
- }
- #endif`,lIe=`#ifdef USE_BUMPMAP
- uniform sampler2D bumpMap;
- uniform float bumpScale;
- vec2 dHdxy_fwd() {
- vec2 dSTdx = dFdx( vBumpMapUv );
- vec2 dSTdy = dFdy( vBumpMapUv );
- float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
- float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
- float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
- return vec2( dBx, dBy );
- }
- vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
- vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
- vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
- vec3 vN = surf_norm;
- vec3 R1 = cross( vSigmaY, vN );
- vec3 R2 = cross( vN, vSigmaX );
- float fDet = dot( vSigmaX, R1 ) * faceDirection;
- vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
- return normalize( abs( fDet ) * surf_norm - vGrad );
- }
- #endif`,cIe=`#if NUM_CLIPPING_PLANES > 0
- vec4 plane;
- #pragma unroll_loop_start
- for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
- }
- #pragma unroll_loop_end
- #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
- bool clipped = true;
- #pragma unroll_loop_start
- for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
- plane = clippingPlanes[ i ];
- clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
- }
- #pragma unroll_loop_end
- if ( clipped ) discard;
- #endif
- #endif`,uIe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
- #endif`,dIe=`#if NUM_CLIPPING_PLANES > 0
- varying vec3 vClipPosition;
- #endif`,hIe=`#if NUM_CLIPPING_PLANES > 0
- vClipPosition = - mvPosition.xyz;
- #endif`,fIe=`#if defined( USE_COLOR_ALPHA )
- diffuseColor *= vColor;
- #elif defined( USE_COLOR )
- diffuseColor.rgb *= vColor;
- #endif`,mIe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR )
- varying vec3 vColor;
- #endif`,pIe=`#if defined( USE_COLOR_ALPHA )
- varying vec4 vColor;
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- varying vec3 vColor;
- #endif`,gIe=`#if defined( USE_COLOR_ALPHA )
- vColor = vec4( 1.0 );
- #elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
- vColor = vec3( 1.0 );
- #endif
- #ifdef USE_COLOR
- vColor *= color;
- #endif
- #ifdef USE_INSTANCING_COLOR
- vColor.xyz *= instanceColor.xyz;
- #endif`,xIe=`#define PI 3.141592653589793
- #define PI2 6.283185307179586
- #define PI_HALF 1.5707963267948966
- #define RECIPROCAL_PI 0.3183098861837907
- #define RECIPROCAL_PI2 0.15915494309189535
- #define EPSILON 1e-6
- #ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- #define whiteComplement( a ) ( 1.0 - saturate( a ) )
- float pow2( const in float x ) { return x*x; }
- vec3 pow2( const in vec3 x ) { return x*x; }
- float pow3( const in float x ) { return x*x*x; }
- float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
- float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
- float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
- highp float rand( const in vec2 uv ) {
- const highp float a = 12.9898, b = 78.233, c = 43758.5453;
- highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
- return fract( sin( sn ) * c );
- }
- #ifdef HIGH_PRECISION
- float precisionSafeLength( vec3 v ) { return length( v ); }
- #else
- float precisionSafeLength( vec3 v ) {
- float maxComponent = max3( abs( v ) );
- return length( v / maxComponent ) * maxComponent;
- }
- #endif
- struct IncidentLight {
- vec3 color;
- vec3 direction;
- bool visible;
- };
- struct ReflectedLight {
- vec3 directDiffuse;
- vec3 directSpecular;
- vec3 indirectDiffuse;
- vec3 indirectSpecular;
- };
- #ifdef USE_ALPHAHASH
- varying vec3 vPosition;
- #endif
- vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
- }
- vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
- return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
- }
- mat3 transposeMat3( const in mat3 m ) {
- mat3 tmp;
- tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
- tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
- tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
- return tmp;
- }
- float luminance( const in vec3 rgb ) {
- const vec3 weights = vec3( 0.2126729, 0.7151522, 0.0721750 );
- return dot( weights, rgb );
- }
- bool isPerspectiveMatrix( mat4 m ) {
- return m[ 2 ][ 3 ] == - 1.0;
- }
- vec2 equirectUv( in vec3 dir ) {
- float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
- float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
- return vec2( u, v );
- }
- vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
- return RECIPROCAL_PI * diffuseColor;
- }
- vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- }
- float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
- float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
- return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
- } // validated`,bIe=`#ifdef ENVMAP_TYPE_CUBE_UV
- #define cubeUV_minMipLevel 4.0
- #define cubeUV_minTileSize 16.0
- float getFace( vec3 direction ) {
- vec3 absDirection = abs( direction );
- float face = - 1.0;
- if ( absDirection.x > absDirection.z ) {
- if ( absDirection.x > absDirection.y )
- face = direction.x > 0.0 ? 0.0 : 3.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- } else {
- if ( absDirection.z > absDirection.y )
- face = direction.z > 0.0 ? 2.0 : 5.0;
- else
- face = direction.y > 0.0 ? 1.0 : 4.0;
- }
- return face;
- }
- vec2 getUV( vec3 direction, float face ) {
- vec2 uv;
- if ( face == 0.0 ) {
- uv = vec2( direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 1.0 ) {
- uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
- } else if ( face == 2.0 ) {
- uv = vec2( - direction.x, direction.y ) / abs( direction.z );
- } else if ( face == 3.0 ) {
- uv = vec2( - direction.z, direction.y ) / abs( direction.x );
- } else if ( face == 4.0 ) {
- uv = vec2( - direction.x, direction.z ) / abs( direction.y );
- } else {
- uv = vec2( direction.x, direction.y ) / abs( direction.z );
- }
- return 0.5 * ( uv + 1.0 );
- }
- vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
- float face = getFace( direction );
- float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
- mipInt = max( mipInt, cubeUV_minMipLevel );
- float faceSize = exp2( mipInt );
- highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
- if ( face > 2.0 ) {
- uv.y += faceSize;
- face -= 3.0;
- }
- uv.x += face * faceSize;
- uv.x += filterInt * 3.0 * cubeUV_minTileSize;
- uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
- uv.x *= CUBEUV_TEXEL_WIDTH;
- uv.y *= CUBEUV_TEXEL_HEIGHT;
- #ifdef texture2DGradEXT
- return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
- #else
- return texture2D( envMap, uv ).rgb;
- #endif
- }
- #define cubeUV_r0 1.0
- #define cubeUV_v0 0.339
- #define cubeUV_m0 - 2.0
- #define cubeUV_r1 0.8
- #define cubeUV_v1 0.276
- #define cubeUV_m1 - 1.0
- #define cubeUV_r4 0.4
- #define cubeUV_v4 0.046
- #define cubeUV_m4 2.0
- #define cubeUV_r5 0.305
- #define cubeUV_v5 0.016
- #define cubeUV_m5 3.0
- #define cubeUV_r6 0.21
- #define cubeUV_v6 0.0038
- #define cubeUV_m6 4.0
- float roughnessToMip( float roughness ) {
- float mip = 0.0;
- if ( roughness >= cubeUV_r1 ) {
- mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
- } else if ( roughness >= cubeUV_r4 ) {
- mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
- } else if ( roughness >= cubeUV_r5 ) {
- mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
- } else if ( roughness >= cubeUV_r6 ) {
- mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
- } else {
- mip = - 2.0 * log2( 1.16 * roughness ); }
- return mip;
- }
- vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
- float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
- float mipF = fract( mip );
- float mipInt = floor( mip );
- vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
- if ( mipF == 0.0 ) {
- return vec4( color0, 1.0 );
- } else {
- vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
- return vec4( mix( color0, color1, mipF ), 1.0 );
- }
- }
- #endif`,yIe=`vec3 transformedNormal = objectNormal;
- #ifdef USE_TANGENT
- vec3 transformedTangent = objectTangent;
- #endif
- #ifdef USE_BATCHING
- mat3 bm = mat3( batchingMatrix );
- transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
- transformedNormal = bm * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = bm * transformedTangent;
- #endif
- #endif
- #ifdef USE_INSTANCING
- mat3 im = mat3( instanceMatrix );
- transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
- transformedNormal = im * transformedNormal;
- #ifdef USE_TANGENT
- transformedTangent = im * transformedTangent;
- #endif
- #endif
- transformedNormal = normalMatrix * transformedNormal;
- #ifdef FLIP_SIDED
- transformedNormal = - transformedNormal;
- #endif
- #ifdef USE_TANGENT
- transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
- #ifdef FLIP_SIDED
- transformedTangent = - transformedTangent;
- #endif
- #endif`,vIe=`#ifdef USE_DISPLACEMENTMAP
- uniform sampler2D displacementMap;
- uniform float displacementScale;
- uniform float displacementBias;
- #endif`,wIe=`#ifdef USE_DISPLACEMENTMAP
- transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
- #endif`,_Ie=`#ifdef USE_EMISSIVEMAP
- vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
- totalEmissiveRadiance *= emissiveColor.rgb;
- #endif`,SIe=`#ifdef USE_EMISSIVEMAP
- uniform sampler2D emissiveMap;
- #endif`,NIe="gl_FragColor = linearToOutputTexel( gl_FragColor );",MIe=`
- const mat3 LINEAR_SRGB_TO_LINEAR_DISPLAY_P3 = mat3(
- vec3( 0.8224621, 0.177538, 0.0 ),
- vec3( 0.0331941, 0.9668058, 0.0 ),
- vec3( 0.0170827, 0.0723974, 0.9105199 )
- );
- const mat3 LINEAR_DISPLAY_P3_TO_LINEAR_SRGB = mat3(
- vec3( 1.2249401, - 0.2249404, 0.0 ),
- vec3( - 0.0420569, 1.0420571, 0.0 ),
- vec3( - 0.0196376, - 0.0786361, 1.0982735 )
- );
- vec4 LinearSRGBToLinearDisplayP3( in vec4 value ) {
- return vec4( value.rgb * LINEAR_SRGB_TO_LINEAR_DISPLAY_P3, value.a );
- }
- vec4 LinearDisplayP3ToLinearSRGB( in vec4 value ) {
- return vec4( value.rgb * LINEAR_DISPLAY_P3_TO_LINEAR_SRGB, value.a );
- }
- vec4 LinearTransferOETF( in vec4 value ) {
- return value;
- }
- vec4 sRGBTransferOETF( in vec4 value ) {
- return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
- }
- vec4 LinearToLinear( in vec4 value ) {
- return value;
- }
- vec4 LinearTosRGB( in vec4 value ) {
- return sRGBTransferOETF( value );
- }`,kIe=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vec3 cameraToFrag;
- if ( isOrthographic ) {
- cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToFrag = normalize( vWorldPosition - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vec3 reflectVec = reflect( cameraToFrag, worldNormal );
- #else
- vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
- #endif
- #else
- vec3 reflectVec = vReflect;
- #endif
- #ifdef ENVMAP_TYPE_CUBE
- vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
- #else
- vec4 envColor = vec4( 0.0 );
- #endif
- #ifdef ENVMAP_BLENDING_MULTIPLY
- outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_MIX )
- outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
- #elif defined( ENVMAP_BLENDING_ADD )
- outgoingLight += envColor.xyz * specularStrength * reflectivity;
- #endif
- #endif`,EIe=`#ifdef USE_ENVMAP
- uniform float envMapIntensity;
- uniform float flipEnvMap;
- #ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #else
- uniform sampler2D envMap;
- #endif
-
- #endif`,TIe=`#ifdef USE_ENVMAP
- uniform float reflectivity;
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
- varying vec3 vWorldPosition;
- uniform float refractionRatio;
- #else
- varying vec3 vReflect;
- #endif
- #endif`,AIe=`#ifdef USE_ENVMAP
- #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
- #define ENV_WORLDPOS
- #endif
- #ifdef ENV_WORLDPOS
-
- varying vec3 vWorldPosition;
- #else
- varying vec3 vReflect;
- uniform float refractionRatio;
- #endif
- #endif`,CIe=`#ifdef USE_ENVMAP
- #ifdef ENV_WORLDPOS
- vWorldPosition = worldPosition.xyz;
- #else
- vec3 cameraToVertex;
- if ( isOrthographic ) {
- cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
- } else {
- cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
- }
- vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- #ifdef ENVMAP_MODE_REFLECTION
- vReflect = reflect( cameraToVertex, worldNormal );
- #else
- vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
- #endif
- #endif
- #endif`,PIe=`#ifdef USE_FOG
- vFogDepth = - mvPosition.z;
- #endif`,jIe=`#ifdef USE_FOG
- varying float vFogDepth;
- #endif`,DIe=`#ifdef USE_FOG
- #ifdef FOG_EXP2
- float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
- #else
- float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
- #endif
- gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
- #endif`,RIe=`#ifdef USE_FOG
- uniform vec3 fogColor;
- varying float vFogDepth;
- #ifdef FOG_EXP2
- uniform float fogDensity;
- #else
- uniform float fogNear;
- uniform float fogFar;
- #endif
- #endif`,OIe=`#ifdef USE_GRADIENTMAP
- uniform sampler2D gradientMap;
- #endif
- vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
- float dotNL = dot( normal, lightDirection );
- vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
- #ifdef USE_GRADIENTMAP
- return vec3( texture2D( gradientMap, coord ).r );
- #else
- vec2 fw = fwidth( coord ) * 0.5;
- return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
- #endif
- }`,LIe=`#ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- reflectedLight.indirectDiffuse += lightMapIrradiance;
- #endif`,FIe=`#ifdef USE_LIGHTMAP
- uniform sampler2D lightMap;
- uniform float lightMapIntensity;
- #endif`,IIe=`LambertMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularStrength = specularStrength;`,UIe=`varying vec3 vViewPosition;
- struct LambertMaterial {
- vec3 diffuseColor;
- float specularStrength;
- };
- void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Lambert
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,zIe=`uniform bool receiveShadow;
- uniform vec3 ambientLightColor;
- #if defined( USE_LIGHT_PROBES )
- uniform vec3 lightProbe[ 9 ];
- #endif
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
- float x = normal.x, y = normal.y, z = normal.z;
- vec3 result = shCoefficients[ 0 ] * 0.886227;
- result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
- result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
- result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
- result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
- result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
- result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
- result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
- result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
- return result;
- }
- vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
- return irradiance;
- }
- vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
- vec3 irradiance = ambientLightColor;
- return irradiance;
- }
- float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
- #if defined ( LEGACY_LIGHTS )
- if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
- return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
- }
- return 1.0;
- #else
- float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
- if ( cutoffDistance > 0.0 ) {
- distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
- }
- return distanceFalloff;
- #endif
- }
- float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
- return smoothstep( coneCosine, penumbraCosine, angleCosine );
- }
- #if NUM_DIR_LIGHTS > 0
- struct DirectionalLight {
- vec3 direction;
- vec3 color;
- };
- uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
- void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
- light.color = directionalLight.color;
- light.direction = directionalLight.direction;
- light.visible = true;
- }
- #endif
- #if NUM_POINT_LIGHTS > 0
- struct PointLight {
- vec3 position;
- vec3 color;
- float distance;
- float decay;
- };
- uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
- void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = pointLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float lightDistance = length( lVector );
- light.color = pointLight.color;
- light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- }
- #endif
- #if NUM_SPOT_LIGHTS > 0
- struct SpotLight {
- vec3 position;
- vec3 direction;
- vec3 color;
- float distance;
- float decay;
- float coneCos;
- float penumbraCos;
- };
- uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
- void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
- vec3 lVector = spotLight.position - geometryPosition;
- light.direction = normalize( lVector );
- float angleCos = dot( light.direction, spotLight.direction );
- float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
- if ( spotAttenuation > 0.0 ) {
- float lightDistance = length( lVector );
- light.color = spotLight.color * spotAttenuation;
- light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
- light.visible = ( light.color != vec3( 0.0 ) );
- } else {
- light.color = vec3( 0.0 );
- light.visible = false;
- }
- }
- #endif
- #if NUM_RECT_AREA_LIGHTS > 0
- struct RectAreaLight {
- vec3 color;
- vec3 position;
- vec3 halfWidth;
- vec3 halfHeight;
- };
- uniform sampler2D ltc_1; uniform sampler2D ltc_2;
- uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
- #endif
- #if NUM_HEMI_LIGHTS > 0
- struct HemisphereLight {
- vec3 direction;
- vec3 skyColor;
- vec3 groundColor;
- };
- uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
- vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
- float dotNL = dot( normal, hemiLight.direction );
- float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
- vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
- return irradiance;
- }
- #endif`,BIe=`#ifdef USE_ENVMAP
- vec3 getIBLIrradiance( const in vec3 normal ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
- return PI * envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 reflectVec = reflect( - viewDir, normal );
- reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
- reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
- vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
- return envMapColor.rgb * envMapIntensity;
- #else
- return vec3( 0.0 );
- #endif
- }
- #ifdef USE_ANISOTROPY
- vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
- #ifdef ENVMAP_TYPE_CUBE_UV
- vec3 bentNormal = cross( bitangent, viewDir );
- bentNormal = normalize( cross( bentNormal, bitangent ) );
- bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
- return getIBLRadiance( viewDir, bentNormal, roughness );
- #else
- return vec3( 0.0 );
- #endif
- }
- #endif
- #endif`,HIe=`ToonMaterial material;
- material.diffuseColor = diffuseColor.rgb;`,$Ie=`varying vec3 vViewPosition;
- struct ToonMaterial {
- vec3 diffuseColor;
- };
- void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_Toon
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,VIe=`BlinnPhongMaterial material;
- material.diffuseColor = diffuseColor.rgb;
- material.specularColor = specular;
- material.specularShininess = shininess;
- material.specularStrength = specularStrength;`,GIe=`varying vec3 vViewPosition;
- struct BlinnPhongMaterial {
- vec3 diffuseColor;
- vec3 specularColor;
- float specularShininess;
- float specularStrength;
- };
- void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
- }
- void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- #define RE_Direct RE_Direct_BlinnPhong
- #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,qIe=`PhysicalMaterial material;
- material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
- vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
- float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
- material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
- material.roughness = min( material.roughness, 1.0 );
- #ifdef IOR
- material.ior = ior;
- #ifdef USE_SPECULAR
- float specularIntensityFactor = specularIntensity;
- vec3 specularColorFactor = specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
- #endif
- material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
- #else
- float specularIntensityFactor = 1.0;
- vec3 specularColorFactor = vec3( 1.0 );
- material.specularF90 = 1.0;
- #endif
- material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
- #else
- material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
- material.specularF90 = 1.0;
- #endif
- #ifdef USE_CLEARCOAT
- material.clearcoat = clearcoat;
- material.clearcoatRoughness = clearcoatRoughness;
- material.clearcoatF0 = vec3( 0.04 );
- material.clearcoatF90 = 1.0;
- #ifdef USE_CLEARCOATMAP
- material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
- #endif
- material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
- material.clearcoatRoughness += geometryRoughness;
- material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
- #endif
- #ifdef USE_IRIDESCENCE
- material.iridescence = iridescence;
- material.iridescenceIOR = iridescenceIOR;
- #ifdef USE_IRIDESCENCEMAP
- material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
- #else
- material.iridescenceThickness = iridescenceThicknessMaximum;
- #endif
- #endif
- #ifdef USE_SHEEN
- material.sheenColor = sheenColor;
- #ifdef USE_SHEEN_COLORMAP
- material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
- #endif
- material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
- #ifdef USE_SHEEN_ROUGHNESSMAP
- material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- #ifdef USE_ANISOTROPYMAP
- mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
- vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
- vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
- #else
- vec2 anisotropyV = anisotropyVector;
- #endif
- material.anisotropy = length( anisotropyV );
- if( material.anisotropy == 0.0 ) {
- anisotropyV = vec2( 1.0, 0.0 );
- } else {
- anisotropyV /= material.anisotropy;
- material.anisotropy = saturate( material.anisotropy );
- }
- material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
- material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
- material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
- #endif`,WIe=`struct PhysicalMaterial {
- vec3 diffuseColor;
- float roughness;
- vec3 specularColor;
- float specularF90;
- #ifdef USE_CLEARCOAT
- float clearcoat;
- float clearcoatRoughness;
- vec3 clearcoatF0;
- float clearcoatF90;
- #endif
- #ifdef USE_IRIDESCENCE
- float iridescence;
- float iridescenceIOR;
- float iridescenceThickness;
- vec3 iridescenceFresnel;
- vec3 iridescenceF0;
- #endif
- #ifdef USE_SHEEN
- vec3 sheenColor;
- float sheenRoughness;
- #endif
- #ifdef IOR
- float ior;
- #endif
- #ifdef USE_TRANSMISSION
- float transmission;
- float transmissionAlpha;
- float thickness;
- float attenuationDistance;
- vec3 attenuationColor;
- #endif
- #ifdef USE_ANISOTROPY
- float anisotropy;
- float alphaT;
- vec3 anisotropyT;
- vec3 anisotropyB;
- #endif
- };
- vec3 clearcoatSpecularDirect = vec3( 0.0 );
- vec3 clearcoatSpecularIndirect = vec3( 0.0 );
- vec3 sheenSpecularDirect = vec3( 0.0 );
- vec3 sheenSpecularIndirect = vec3(0.0 );
- vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
- float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
- float x2 = x * x;
- float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
- return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
- }
- float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
- float a2 = pow2( alpha );
- float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
- float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
- return 0.5 / max( gv + gl, EPSILON );
- }
- float D_GGX( const in float alpha, const in float dotNH ) {
- float a2 = pow2( alpha );
- float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
- return RECIPROCAL_PI * a2 / pow2( denom );
- }
- #ifdef USE_ANISOTROPY
- float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
- float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
- float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
- float v = 0.5 / ( gv + gl );
- return saturate(v);
- }
- float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
- float a2 = alphaT * alphaB;
- highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
- highp float v2 = dot( v, v );
- float w2 = a2 / v2;
- return RECIPROCAL_PI * a2 * pow2 ( w2 );
- }
- #endif
- #ifdef USE_CLEARCOAT
- vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
- vec3 f0 = material.clearcoatF0;
- float f90 = material.clearcoatF90;
- float roughness = material.clearcoatRoughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- return F * ( V * D );
- }
- #endif
- vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
- vec3 f0 = material.specularColor;
- float f90 = material.specularF90;
- float roughness = material.roughness;
- float alpha = pow2( roughness );
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float dotVH = saturate( dot( viewDir, halfDir ) );
- vec3 F = F_Schlick( f0, f90, dotVH );
- #ifdef USE_IRIDESCENCE
- F = mix( F, material.iridescenceFresnel, material.iridescence );
- #endif
- #ifdef USE_ANISOTROPY
- float dotTL = dot( material.anisotropyT, lightDir );
- float dotTV = dot( material.anisotropyT, viewDir );
- float dotTH = dot( material.anisotropyT, halfDir );
- float dotBL = dot( material.anisotropyB, lightDir );
- float dotBV = dot( material.anisotropyB, viewDir );
- float dotBH = dot( material.anisotropyB, halfDir );
- float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
- float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
- #else
- float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
- float D = D_GGX( alpha, dotNH );
- #endif
- return F * ( V * D );
- }
- vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
- const float LUT_SIZE = 64.0;
- const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
- const float LUT_BIAS = 0.5 / LUT_SIZE;
- float dotNV = saturate( dot( N, V ) );
- vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
- uv = uv * LUT_SCALE + LUT_BIAS;
- return uv;
- }
- float LTC_ClippedSphereFormFactor( const in vec3 f ) {
- float l = length( f );
- return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
- }
- vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
- float x = dot( v1, v2 );
- float y = abs( x );
- float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
- float b = 3.4175940 + ( 4.1616724 + y ) * y;
- float v = a / b;
- float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
- return cross( v1, v2 ) * theta_sintheta;
- }
- vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
- vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
- vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
- vec3 lightNormal = cross( v1, v2 );
- if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
- vec3 T1, T2;
- T1 = normalize( V - N * dot( V, N ) );
- T2 = - cross( N, T1 );
- mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
- vec3 coords[ 4 ];
- coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
- coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
- coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
- coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
- coords[ 0 ] = normalize( coords[ 0 ] );
- coords[ 1 ] = normalize( coords[ 1 ] );
- coords[ 2 ] = normalize( coords[ 2 ] );
- coords[ 3 ] = normalize( coords[ 3 ] );
- vec3 vectorFormFactor = vec3( 0.0 );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
- vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
- float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
- return vec3( result );
- }
- #if defined( USE_SHEEN )
- float D_Charlie( float roughness, float dotNH ) {
- float alpha = pow2( roughness );
- float invAlpha = 1.0 / alpha;
- float cos2h = dotNH * dotNH;
- float sin2h = max( 1.0 - cos2h, 0.0078125 );
- return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
- }
- float V_Neubelt( float dotNV, float dotNL ) {
- return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
- }
- vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
- vec3 halfDir = normalize( lightDir + viewDir );
- float dotNL = saturate( dot( normal, lightDir ) );
- float dotNV = saturate( dot( normal, viewDir ) );
- float dotNH = saturate( dot( normal, halfDir ) );
- float D = D_Charlie( sheenRoughness, dotNH );
- float V = V_Neubelt( dotNV, dotNL );
- return sheenColor * ( D * V );
- }
- #endif
- float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- float r2 = roughness * roughness;
- float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
- float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
- float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
- return saturate( DG * RECIPROCAL_PI );
- }
- vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
- float dotNV = saturate( dot( normal, viewDir ) );
- const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
- const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
- vec4 r = roughness * c0 + c1;
- float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
- vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
- return fab;
- }
- vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- return specularColor * fab.x + specularF90 * fab.y;
- }
- #ifdef USE_IRIDESCENCE
- void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #else
- void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
- #endif
- vec2 fab = DFGApprox( normal, viewDir, roughness );
- #ifdef USE_IRIDESCENCE
- vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
- #else
- vec3 Fr = specularColor;
- #endif
- vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
- float Ess = fab.x + fab.y;
- float Ems = 1.0 - Ess;
- vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
- singleScatter += FssEss;
- multiScatter += Fms * Ems;
- }
- #if NUM_RECT_AREA_LIGHTS > 0
- void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- vec3 normal = geometryNormal;
- vec3 viewDir = geometryViewDir;
- vec3 position = geometryPosition;
- vec3 lightPos = rectAreaLight.position;
- vec3 halfWidth = rectAreaLight.halfWidth;
- vec3 halfHeight = rectAreaLight.halfHeight;
- vec3 lightColor = rectAreaLight.color;
- float roughness = material.roughness;
- vec3 rectCoords[ 4 ];
- rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
- rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
- rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
- vec2 uv = LTC_Uv( normal, viewDir, roughness );
- vec4 t1 = texture2D( ltc_1, uv );
- vec4 t2 = texture2D( ltc_2, uv );
- mat3 mInv = mat3(
- vec3( t1.x, 0, t1.y ),
- vec3( 0, 1, 0 ),
- vec3( t1.z, 0, t1.w )
- );
- vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
- reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
- reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
- }
- #endif
- void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
- vec3 irradiance = dotNL * directLight.color;
- #ifdef USE_CLEARCOAT
- float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
- vec3 ccIrradiance = dotNLcc * directLight.color;
- clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
- #endif
- reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
- reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
- reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
- }
- void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
- #ifdef USE_CLEARCOAT
- clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
- #endif
- #ifdef USE_SHEEN
- sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
- #endif
- vec3 singleScattering = vec3( 0.0 );
- vec3 multiScattering = vec3( 0.0 );
- vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
- #ifdef USE_IRIDESCENCE
- computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
- #else
- computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
- #endif
- vec3 totalScattering = singleScattering + multiScattering;
- vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
- reflectedLight.indirectSpecular += radiance * singleScattering;
- reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
- reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
- }
- #define RE_Direct RE_Direct_Physical
- #define RE_Direct_RectArea RE_Direct_RectArea_Physical
- #define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
- #define RE_IndirectSpecular RE_IndirectSpecular_Physical
- float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
- return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
- }`,KIe=`
- vec3 geometryPosition = - vViewPosition;
- vec3 geometryNormal = normal;
- vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
- vec3 geometryClearcoatNormal = vec3( 0.0 );
- #ifdef USE_CLEARCOAT
- geometryClearcoatNormal = clearcoatNormal;
- #endif
- #ifdef USE_IRIDESCENCE
- float dotNVi = saturate( dot( normal, geometryViewDir ) );
- if ( material.iridescenceThickness == 0.0 ) {
- material.iridescence = 0.0;
- } else {
- material.iridescence = saturate( material.iridescence );
- }
- if ( material.iridescence > 0.0 ) {
- material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
- material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
- }
- #endif
- IncidentLight directLight;
- #if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
- PointLight pointLight;
- #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
- pointLight = pointLights[ i ];
- getPointLightInfo( pointLight, geometryPosition, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
- pointLightShadow = pointLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
- SpotLight spotLight;
- vec4 spotColor;
- vec3 spotLightCoord;
- bool inSpotLightMap;
- #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
- spotLight = spotLights[ i ];
- getSpotLightInfo( spotLight, geometryPosition, directLight );
- #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
- #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
- #else
- #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
- #endif
- #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
- spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
- inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
- spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
- directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
- #endif
- #undef SPOT_LIGHT_MAP_INDEX
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- spotLightShadow = spotLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
- DirectionalLight directionalLight;
- #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLightShadow;
- #endif
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
- directionalLight = directionalLights[ i ];
- getDirectionalLightInfo( directionalLight, directLight );
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
- directionalLightShadow = directionalLightShadows[ i ];
- directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- #endif
- RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
- RectAreaLight rectAreaLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
- rectAreaLight = rectAreaLights[ i ];
- RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- }
- #pragma unroll_loop_end
- #endif
- #if defined( RE_IndirectDiffuse )
- vec3 iblIrradiance = vec3( 0.0 );
- vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
- #if defined( USE_LIGHT_PROBES )
- irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
- #endif
- #if ( NUM_HEMI_LIGHTS > 0 )
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
- irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if defined( RE_IndirectSpecular )
- vec3 radiance = vec3( 0.0 );
- vec3 clearcoatRadiance = vec3( 0.0 );
- #endif`,XIe=`#if defined( RE_IndirectDiffuse )
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
- irradiance += lightMapIrradiance;
- #endif
- #if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
- iblIrradiance += getIBLIrradiance( geometryNormal );
- #endif
- #endif
- #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
- #ifdef USE_ANISOTROPY
- radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
- #else
- radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
- #endif
- #ifdef USE_CLEARCOAT
- clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
- #endif
- #endif`,YIe=`#if defined( RE_IndirectDiffuse )
- RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif
- #if defined( RE_IndirectSpecular )
- RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
- #endif`,QIe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
- #endif`,ZIe=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
- uniform float logDepthBufFC;
- varying float vFragDepth;
- varying float vIsPerspective;
- #endif`,JIe=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- varying float vFragDepth;
- varying float vIsPerspective;
- #else
- uniform float logDepthBufFC;
- #endif
- #endif`,e5e=`#ifdef USE_LOGDEPTHBUF
- #ifdef USE_LOGDEPTHBUF_EXT
- vFragDepth = 1.0 + gl_Position.w;
- vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
- #else
- if ( isPerspectiveMatrix( projectionMatrix ) ) {
- gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
- gl_Position.z *= gl_Position.w;
- }
- #endif
- #endif`,t5e=`#ifdef USE_MAP
- vec4 sampledDiffuseColor = texture2D( map, vMapUv );
- #ifdef DECODE_VIDEO_TEXTURE
- sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
-
- #endif
- diffuseColor *= sampledDiffuseColor;
- #endif`,n5e=`#ifdef USE_MAP
- uniform sampler2D map;
- #endif`,r5e=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- #if defined( USE_POINTS_UV )
- vec2 uv = vUv;
- #else
- vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
- #endif
- #endif
- #ifdef USE_MAP
- diffuseColor *= texture2D( map, uv );
- #endif
- #ifdef USE_ALPHAMAP
- diffuseColor.a *= texture2D( alphaMap, uv ).g;
- #endif`,i5e=`#if defined( USE_POINTS_UV )
- varying vec2 vUv;
- #else
- #if defined( USE_MAP ) || defined( USE_ALPHAMAP )
- uniform mat3 uvTransform;
- #endif
- #endif
- #ifdef USE_MAP
- uniform sampler2D map;
- #endif
- #ifdef USE_ALPHAMAP
- uniform sampler2D alphaMap;
- #endif`,a5e=`float metalnessFactor = metalness;
- #ifdef USE_METALNESSMAP
- vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
- metalnessFactor *= texelMetalness.b;
- #endif`,s5e=`#ifdef USE_METALNESSMAP
- uniform sampler2D metalnessMap;
- #endif`,o5e=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
- vColor *= morphTargetBaseInfluence;
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- #if defined( USE_COLOR_ALPHA )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
- #elif defined( USE_COLOR )
- if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
- #endif
- }
- #endif`,l5e=`#ifdef USE_MORPHNORMALS
- objectNormal *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
- objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
- objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
- objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
- #endif
- #endif`,c5e=`#ifdef USE_MORPHTARGETS
- uniform float morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
- uniform sampler2DArray morphTargetsTexture;
- uniform ivec2 morphTargetsTextureSize;
- vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
- int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
- int y = texelIndex / morphTargetsTextureSize.x;
- int x = texelIndex - y * morphTargetsTextureSize.x;
- ivec3 morphUV = ivec3( x, y, morphTargetIndex );
- return texelFetch( morphTargetsTexture, morphUV, 0 );
- }
- #else
- #ifndef USE_MORPHNORMALS
- uniform float morphTargetInfluences[ 8 ];
- #else
- uniform float morphTargetInfluences[ 4 ];
- #endif
- #endif
- #endif`,u5e=`#ifdef USE_MORPHTARGETS
- transformed *= morphTargetBaseInfluence;
- #ifdef MORPHTARGETS_TEXTURE
- for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
- if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
- }
- #else
- transformed += morphTarget0 * morphTargetInfluences[ 0 ];
- transformed += morphTarget1 * morphTargetInfluences[ 1 ];
- transformed += morphTarget2 * morphTargetInfluences[ 2 ];
- transformed += morphTarget3 * morphTargetInfluences[ 3 ];
- #ifndef USE_MORPHNORMALS
- transformed += morphTarget4 * morphTargetInfluences[ 4 ];
- transformed += morphTarget5 * morphTargetInfluences[ 5 ];
- transformed += morphTarget6 * morphTargetInfluences[ 6 ];
- transformed += morphTarget7 * morphTargetInfluences[ 7 ];
- #endif
- #endif
- #endif`,d5e=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
- #ifdef FLAT_SHADED
- vec3 fdx = dFdx( vViewPosition );
- vec3 fdy = dFdy( vViewPosition );
- vec3 normal = normalize( cross( fdx, fdy ) );
- #else
- vec3 normal = normalize( vNormal );
- #ifdef DOUBLE_SIDED
- normal *= faceDirection;
- #endif
- #endif
- #if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
- #ifdef USE_TANGENT
- mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn = getTangentFrame( - vViewPosition, normal,
- #if defined( USE_NORMALMAP )
- vNormalMapUv
- #elif defined( USE_CLEARCOAT_NORMALMAP )
- vClearcoatNormalMapUv
- #else
- vUv
- #endif
- );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn[0] *= faceDirection;
- tbn[1] *= faceDirection;
- #endif
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- #ifdef USE_TANGENT
- mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
- #else
- mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
- #endif
- #if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
- tbn2[0] *= faceDirection;
- tbn2[1] *= faceDirection;
- #endif
- #endif
- vec3 nonPerturbedNormal = normal;`,h5e=`#ifdef USE_NORMALMAP_OBJECTSPACE
- normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- #ifdef FLIP_SIDED
- normal = - normal;
- #endif
- #ifdef DOUBLE_SIDED
- normal = normal * faceDirection;
- #endif
- normal = normalize( normalMatrix * normal );
- #elif defined( USE_NORMALMAP_TANGENTSPACE )
- vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
- mapN.xy *= normalScale;
- normal = normalize( tbn * mapN );
- #elif defined( USE_BUMPMAP )
- normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
- #endif`,f5e=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,m5e=`#ifndef FLAT_SHADED
- varying vec3 vNormal;
- #ifdef USE_TANGENT
- varying vec3 vTangent;
- varying vec3 vBitangent;
- #endif
- #endif`,p5e=`#ifndef FLAT_SHADED
- vNormal = normalize( transformedNormal );
- #ifdef USE_TANGENT
- vTangent = normalize( transformedTangent );
- vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
- #endif
- #endif`,g5e=`#ifdef USE_NORMALMAP
- uniform sampler2D normalMap;
- uniform vec2 normalScale;
- #endif
- #ifdef USE_NORMALMAP_OBJECTSPACE
- uniform mat3 normalMatrix;
- #endif
- #if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
- mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
- vec3 q0 = dFdx( eye_pos.xyz );
- vec3 q1 = dFdy( eye_pos.xyz );
- vec2 st0 = dFdx( uv.st );
- vec2 st1 = dFdy( uv.st );
- vec3 N = surf_norm;
- vec3 q1perp = cross( q1, N );
- vec3 q0perp = cross( N, q0 );
- vec3 T = q1perp * st0.x + q0perp * st1.x;
- vec3 B = q1perp * st0.y + q0perp * st1.y;
- float det = max( dot( T, T ), dot( B, B ) );
- float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
- return mat3( T * scale, B * scale, N );
- }
- #endif`,x5e=`#ifdef USE_CLEARCOAT
- vec3 clearcoatNormal = nonPerturbedNormal;
- #endif`,b5e=`#ifdef USE_CLEARCOAT_NORMALMAP
- vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
- clearcoatMapN.xy *= clearcoatNormalScale;
- clearcoatNormal = normalize( tbn2 * clearcoatMapN );
- #endif`,y5e=`#ifdef USE_CLEARCOATMAP
- uniform sampler2D clearcoatMap;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform sampler2D clearcoatNormalMap;
- uniform vec2 clearcoatNormalScale;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform sampler2D clearcoatRoughnessMap;
- #endif`,v5e=`#ifdef USE_IRIDESCENCEMAP
- uniform sampler2D iridescenceMap;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform sampler2D iridescenceThicknessMap;
- #endif`,w5e=`#ifdef OPAQUE
- diffuseColor.a = 1.0;
- #endif
- #ifdef USE_TRANSMISSION
- diffuseColor.a *= material.transmissionAlpha;
- #endif
- gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,_5e=`vec3 packNormalToRGB( const in vec3 normal ) {
- return normalize( normal ) * 0.5 + 0.5;
- }
- vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 2.0 * rgb.xyz - 1.0;
- }
- const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
- const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
- const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
- const float ShiftRight8 = 1. / 256.;
- vec4 packDepthToRGBA( const in float v ) {
- vec4 r = vec4( fract( v * PackFactors ), v );
- r.yzw -= r.xyz * ShiftRight8; return r * PackUpscale;
- }
- float unpackRGBAToDepth( const in vec4 v ) {
- return dot( v, UnpackFactors );
- }
- vec2 packDepthToRG( in highp float v ) {
- return packDepthToRGBA( v ).yx;
- }
- float unpackRGToDepth( const in highp vec2 v ) {
- return unpackRGBAToDepth( vec4( v.xy, 0.0, 0.0 ) );
- }
- vec4 pack2HalfToRGBA( vec2 v ) {
- vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
- return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
- }
- vec2 unpackRGBATo2Half( vec4 v ) {
- return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
- }
- float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
- return ( viewZ + near ) / ( near - far );
- }
- float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return depth * ( near - far ) - near;
- }
- float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
- return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
- }
- float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
- return ( near * far ) / ( ( far - near ) * depth - far );
- }`,S5e=`#ifdef PREMULTIPLIED_ALPHA
- gl_FragColor.rgb *= gl_FragColor.a;
- #endif`,N5e=`vec4 mvPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- mvPosition = batchingMatrix * mvPosition;
- #endif
- #ifdef USE_INSTANCING
- mvPosition = instanceMatrix * mvPosition;
- #endif
- mvPosition = modelViewMatrix * mvPosition;
- gl_Position = projectionMatrix * mvPosition;`,M5e=`#ifdef DITHERING
- gl_FragColor.rgb = dithering( gl_FragColor.rgb );
- #endif`,k5e=`#ifdef DITHERING
- vec3 dithering( vec3 color ) {
- float grid_position = rand( gl_FragCoord.xy );
- vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
- dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
- return color + dither_shift_RGB;
- }
- #endif`,E5e=`float roughnessFactor = roughness;
- #ifdef USE_ROUGHNESSMAP
- vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
- roughnessFactor *= texelRoughness.g;
- #endif`,T5e=`#ifdef USE_ROUGHNESSMAP
- uniform sampler2D roughnessMap;
- #endif`,A5e=`#if NUM_SPOT_LIGHT_COORDS > 0
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #if NUM_SPOT_LIGHT_MAPS > 0
- uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
- return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
- }
- vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
- return unpackRGBATo2Half( texture2D( shadow, uv ) );
- }
- float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
- float occlusion = 1.0;
- vec2 distribution = texture2DDistribution( shadow, uv );
- float hard_shadow = step( compare , distribution.x );
- if (hard_shadow != 1.0 ) {
- float distance = compare - distribution.x ;
- float variance = max( 0.00000, distribution.y * distribution.y );
- float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
- }
- return occlusion;
- }
- float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
- float shadow = 1.0;
- shadowCoord.xyz /= shadowCoord.w;
- shadowCoord.z += shadowBias;
- bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
- bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
- if ( frustumTest ) {
- #if defined( SHADOWMAP_TYPE_PCF )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx0 = - texelSize.x * shadowRadius;
- float dy0 = - texelSize.y * shadowRadius;
- float dx1 = + texelSize.x * shadowRadius;
- float dy1 = + texelSize.y * shadowRadius;
- float dx2 = dx0 / 2.0;
- float dy2 = dy0 / 2.0;
- float dx3 = dx1 / 2.0;
- float dy3 = dy1 / 2.0;
- shadow = (
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
- ) * ( 1.0 / 17.0 );
- #elif defined( SHADOWMAP_TYPE_PCF_SOFT )
- vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
- float dx = texelSize.x;
- float dy = texelSize.y;
- vec2 uv = shadowCoord.xy;
- vec2 f = fract( uv * shadowMapSize + 0.5 );
- uv -= f * texelSize;
- shadow = (
- texture2DCompare( shadowMap, uv, shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
- texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
- f.x ) +
- mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
- f.y ) +
- mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
- f.x ),
- mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
- texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
- f.x ),
- f.y )
- ) * ( 1.0 / 9.0 );
- #elif defined( SHADOWMAP_TYPE_VSM )
- shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
- #else
- shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
- #endif
- }
- return shadow;
- }
- vec2 cubeToUV( vec3 v, float texelSizeY ) {
- vec3 absV = abs( v );
- float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
- absV *= scaleToCube;
- v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
- vec2 planar = v.xy;
- float almostATexel = 1.5 * texelSizeY;
- float almostOne = 1.0 - almostATexel;
- if ( absV.z >= almostOne ) {
- if ( v.z > 0.0 )
- planar.x = 4.0 - v.x;
- } else if ( absV.x >= almostOne ) {
- float signX = sign( v.x );
- planar.x = v.z * signX + 2.0 * signX;
- } else if ( absV.y >= almostOne ) {
- float signY = sign( v.y );
- planar.x = v.x + 2.0 * signY + 2.0;
- planar.y = v.z * signY - 2.0;
- }
- return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
- }
- float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
- vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
- vec3 lightToPosition = shadowCoord.xyz;
- float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
- vec3 bd3D = normalize( lightToPosition );
- #if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
- vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
- return (
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
- texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
- ) * ( 1.0 / 9.0 );
- #else
- return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
- #endif
- }
- #endif`,C5e=`#if NUM_SPOT_LIGHT_COORDS > 0
- uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
- varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
- #endif
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
- varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
- struct DirectionalLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- struct SpotLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- };
- uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
- varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
- struct PointLightShadow {
- float shadowBias;
- float shadowNormalBias;
- float shadowRadius;
- vec2 shadowMapSize;
- float shadowCameraNear;
- float shadowCameraFar;
- };
- uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
- #endif
- #endif`,P5e=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
- vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
- vec4 shadowWorldPosition;
- #endif
- #if defined( USE_SHADOWMAP )
- #if NUM_DIR_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
- vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
- vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- #if NUM_SPOT_LIGHT_COORDS > 0
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
- shadowWorldPosition = worldPosition;
- #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
- shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
- #endif
- vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
- }
- #pragma unroll_loop_end
- #endif`,j5e=`float getShadowMask() {
- float shadow = 1.0;
- #ifdef USE_SHADOWMAP
- #if NUM_DIR_LIGHT_SHADOWS > 0
- DirectionalLightShadow directionalLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
- directionalLight = directionalLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_SPOT_LIGHT_SHADOWS > 0
- SpotLightShadow spotLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
- spotLight = spotLightShadows[ i ];
- shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #if NUM_POINT_LIGHT_SHADOWS > 0
- PointLightShadow pointLight;
- #pragma unroll_loop_start
- for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
- pointLight = pointLightShadows[ i ];
- shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
- }
- #pragma unroll_loop_end
- #endif
- #endif
- return shadow;
- }`,D5e=`#ifdef USE_SKINNING
- mat4 boneMatX = getBoneMatrix( skinIndex.x );
- mat4 boneMatY = getBoneMatrix( skinIndex.y );
- mat4 boneMatZ = getBoneMatrix( skinIndex.z );
- mat4 boneMatW = getBoneMatrix( skinIndex.w );
- #endif`,R5e=`#ifdef USE_SKINNING
- uniform mat4 bindMatrix;
- uniform mat4 bindMatrixInverse;
- uniform highp sampler2D boneTexture;
- mat4 getBoneMatrix( const in float i ) {
- int size = textureSize( boneTexture, 0 ).x;
- int j = int( i ) * 4;
- int x = j % size;
- int y = j / size;
- vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
- vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
- vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
- vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
- return mat4( v1, v2, v3, v4 );
- }
- #endif`,O5e=`#ifdef USE_SKINNING
- vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
- vec4 skinned = vec4( 0.0 );
- skinned += boneMatX * skinVertex * skinWeight.x;
- skinned += boneMatY * skinVertex * skinWeight.y;
- skinned += boneMatZ * skinVertex * skinWeight.z;
- skinned += boneMatW * skinVertex * skinWeight.w;
- transformed = ( bindMatrixInverse * skinned ).xyz;
- #endif`,L5e=`#ifdef USE_SKINNING
- mat4 skinMatrix = mat4( 0.0 );
- skinMatrix += skinWeight.x * boneMatX;
- skinMatrix += skinWeight.y * boneMatY;
- skinMatrix += skinWeight.z * boneMatZ;
- skinMatrix += skinWeight.w * boneMatW;
- skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
- objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
- #ifdef USE_TANGENT
- objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
- #endif
- #endif`,F5e=`float specularStrength;
- #ifdef USE_SPECULARMAP
- vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
- specularStrength = texelSpecular.r;
- #else
- specularStrength = 1.0;
- #endif`,I5e=`#ifdef USE_SPECULARMAP
- uniform sampler2D specularMap;
- #endif`,U5e=`#if defined( TONE_MAPPING )
- gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
- #endif`,z5e=`#ifndef saturate
- #define saturate( a ) clamp( a, 0.0, 1.0 )
- #endif
- uniform float toneMappingExposure;
- vec3 LinearToneMapping( vec3 color ) {
- return saturate( toneMappingExposure * color );
- }
- vec3 ReinhardToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- return saturate( color / ( vec3( 1.0 ) + color ) );
- }
- vec3 OptimizedCineonToneMapping( vec3 color ) {
- color *= toneMappingExposure;
- color = max( vec3( 0.0 ), color - 0.004 );
- return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
- }
- vec3 RRTAndODTFit( vec3 v ) {
- vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
- vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
- return a / b;
- }
- vec3 ACESFilmicToneMapping( vec3 color ) {
- const mat3 ACESInputMat = mat3(
- vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
- vec3( 0.04823, 0.01566, 0.83777 )
- );
- const mat3 ACESOutputMat = mat3(
- vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
- vec3( -0.07367, -0.00605, 1.07602 )
- );
- color *= toneMappingExposure / 0.6;
- color = ACESInputMat * color;
- color = RRTAndODTFit( color );
- color = ACESOutputMat * color;
- return saturate( color );
- }
- vec3 CustomToneMapping( vec3 color ) { return color; }`,B5e=`#ifdef USE_TRANSMISSION
- material.transmission = transmission;
- material.transmissionAlpha = 1.0;
- material.thickness = thickness;
- material.attenuationDistance = attenuationDistance;
- material.attenuationColor = attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
- #endif
- #ifdef USE_THICKNESSMAP
- material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
- #endif
- vec3 pos = vWorldPosition;
- vec3 v = normalize( cameraPosition - pos );
- vec3 n = inverseTransformDirection( normal, viewMatrix );
- vec4 transmitted = getIBLVolumeRefraction(
- n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
- pos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,
- material.attenuationColor, material.attenuationDistance );
- material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
- totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
- #endif`,H5e=`#ifdef USE_TRANSMISSION
- uniform float transmission;
- uniform float thickness;
- uniform float attenuationDistance;
- uniform vec3 attenuationColor;
- #ifdef USE_TRANSMISSIONMAP
- uniform sampler2D transmissionMap;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform sampler2D thicknessMap;
- #endif
- uniform vec2 transmissionSamplerSize;
- uniform sampler2D transmissionSamplerMap;
- uniform mat4 modelMatrix;
- uniform mat4 projectionMatrix;
- varying vec3 vWorldPosition;
- float w0( float a ) {
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
- }
- float w1( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
- }
- float w2( float a ){
- return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
- }
- float w3( float a ) {
- return ( 1.0 / 6.0 ) * ( a * a * a );
- }
- float g0( float a ) {
- return w0( a ) + w1( a );
- }
- float g1( float a ) {
- return w2( a ) + w3( a );
- }
- float h0( float a ) {
- return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
- }
- float h1( float a ) {
- return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
- }
- vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
- uv = uv * texelSize.zw + 0.5;
- vec2 iuv = floor( uv );
- vec2 fuv = fract( uv );
- float g0x = g0( fuv.x );
- float g1x = g1( fuv.x );
- float h0x = h0( fuv.x );
- float h1x = h1( fuv.x );
- float h0y = h0( fuv.y );
- float h1y = h1( fuv.y );
- vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
- vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
- return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
- g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
- }
- vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
- vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
- vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
- vec2 fLodSizeInv = 1.0 / fLodSize;
- vec2 cLodSizeInv = 1.0 / cLodSize;
- vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
- vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
- return mix( fSample, cSample, fract( lod ) );
- }
- vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
- vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
- vec3 modelScale;
- modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
- modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
- modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
- return normalize( refractionVector ) * thickness * modelScale;
- }
- float applyIorToRoughness( const in float roughness, const in float ior ) {
- return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
- }
- vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
- float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
- return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
- }
- vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
- if ( isinf( attenuationDistance ) ) {
- return vec3( 1.0 );
- } else {
- vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
- vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
- }
- }
- vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
- const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
- const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
- const in vec3 attenuationColor, const in float attenuationDistance ) {
- vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
- vec3 refractedRayExit = position + transmissionRay;
- vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
- vec2 refractionCoords = ndcPos.xy / ndcPos.w;
- refractionCoords += 1.0;
- refractionCoords /= 2.0;
- vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
- vec3 transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
- vec3 attenuatedColor = transmittance * transmittedLight.rgb;
- vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
- float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
- return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
- }
- #endif`,$5e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,V5e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- varying vec2 vUv;
- #endif
- #ifdef USE_MAP
- uniform mat3 mapTransform;
- varying vec2 vMapUv;
- #endif
- #ifdef USE_ALPHAMAP
- uniform mat3 alphaMapTransform;
- varying vec2 vAlphaMapUv;
- #endif
- #ifdef USE_LIGHTMAP
- uniform mat3 lightMapTransform;
- varying vec2 vLightMapUv;
- #endif
- #ifdef USE_AOMAP
- uniform mat3 aoMapTransform;
- varying vec2 vAoMapUv;
- #endif
- #ifdef USE_BUMPMAP
- uniform mat3 bumpMapTransform;
- varying vec2 vBumpMapUv;
- #endif
- #ifdef USE_NORMALMAP
- uniform mat3 normalMapTransform;
- varying vec2 vNormalMapUv;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- uniform mat3 displacementMapTransform;
- varying vec2 vDisplacementMapUv;
- #endif
- #ifdef USE_EMISSIVEMAP
- uniform mat3 emissiveMapTransform;
- varying vec2 vEmissiveMapUv;
- #endif
- #ifdef USE_METALNESSMAP
- uniform mat3 metalnessMapTransform;
- varying vec2 vMetalnessMapUv;
- #endif
- #ifdef USE_ROUGHNESSMAP
- uniform mat3 roughnessMapTransform;
- varying vec2 vRoughnessMapUv;
- #endif
- #ifdef USE_ANISOTROPYMAP
- uniform mat3 anisotropyMapTransform;
- varying vec2 vAnisotropyMapUv;
- #endif
- #ifdef USE_CLEARCOATMAP
- uniform mat3 clearcoatMapTransform;
- varying vec2 vClearcoatMapUv;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- uniform mat3 clearcoatNormalMapTransform;
- varying vec2 vClearcoatNormalMapUv;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- uniform mat3 clearcoatRoughnessMapTransform;
- varying vec2 vClearcoatRoughnessMapUv;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- uniform mat3 sheenColorMapTransform;
- varying vec2 vSheenColorMapUv;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform mat3 sheenRoughnessMapTransform;
- varying vec2 vSheenRoughnessMapUv;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- uniform mat3 iridescenceMapTransform;
- varying vec2 vIridescenceMapUv;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- uniform mat3 iridescenceThicknessMapTransform;
- varying vec2 vIridescenceThicknessMapUv;
- #endif
- #ifdef USE_SPECULARMAP
- uniform mat3 specularMapTransform;
- varying vec2 vSpecularMapUv;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- uniform mat3 specularColorMapTransform;
- varying vec2 vSpecularColorMapUv;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform mat3 specularIntensityMapTransform;
- varying vec2 vSpecularIntensityMapUv;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- uniform mat3 transmissionMapTransform;
- varying vec2 vTransmissionMapUv;
- #endif
- #ifdef USE_THICKNESSMAP
- uniform mat3 thicknessMapTransform;
- varying vec2 vThicknessMapUv;
- #endif`,G5e=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
- vUv = vec3( uv, 1 ).xy;
- #endif
- #ifdef USE_MAP
- vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ALPHAMAP
- vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_LIGHTMAP
- vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_AOMAP
- vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_BUMPMAP
- vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_NORMALMAP
- vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_DISPLACEMENTMAP
- vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_EMISSIVEMAP
- vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_METALNESSMAP
- vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ROUGHNESSMAP
- vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_ANISOTROPYMAP
- vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOATMAP
- vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_NORMALMAP
- vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_CLEARCOAT_ROUGHNESSMAP
- vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCEMAP
- vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_IRIDESCENCE_THICKNESSMAP
- vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_COLORMAP
- vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULARMAP
- vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_COLORMAP
- vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_TRANSMISSIONMAP
- vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
- #endif
- #ifdef USE_THICKNESSMAP
- vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
- #endif`,q5e=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
- vec4 worldPosition = vec4( transformed, 1.0 );
- #ifdef USE_BATCHING
- worldPosition = batchingMatrix * worldPosition;
- #endif
- #ifdef USE_INSTANCING
- worldPosition = instanceMatrix * worldPosition;
- #endif
- worldPosition = modelMatrix * worldPosition;
- #endif`;const W5e=`varying vec2 vUv;
- uniform mat3 uvTransform;
- void main() {
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- gl_Position = vec4( position.xy, 1.0, 1.0 );
- }`,K5e=`uniform sampler2D t2D;
- uniform float backgroundIntensity;
- varying vec2 vUv;
- void main() {
- vec4 texColor = texture2D( t2D, vUv );
- #ifdef DECODE_VIDEO_TEXTURE
- texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,X5e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,Y5e=`#ifdef ENVMAP_TYPE_CUBE
- uniform samplerCube envMap;
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- uniform sampler2D envMap;
- #endif
- uniform float flipEnvMap;
- uniform float backgroundBlurriness;
- uniform float backgroundIntensity;
- varying vec3 vWorldDirection;
- #include <cube_uv_reflection_fragment>
- void main() {
- #ifdef ENVMAP_TYPE_CUBE
- vec4 texColor = textureCube( envMap, vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
- #elif defined( ENVMAP_TYPE_CUBE_UV )
- vec4 texColor = textureCubeUV( envMap, vWorldDirection, backgroundBlurriness );
- #else
- vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- #endif
- texColor.rgb *= backgroundIntensity;
- gl_FragColor = texColor;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,Q5e=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- gl_Position.z = gl_Position.w;
- }`,Z5e=`uniform samplerCube tCube;
- uniform float tFlip;
- uniform float opacity;
- varying vec3 vWorldDirection;
- void main() {
- vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
- gl_FragColor = texColor;
- gl_FragColor.a *= opacity;
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,J5e=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vHighPrecisionZW = gl_Position.zw;
- }`,eUe=`#if DEPTH_PACKING == 3200
- uniform float opacity;
- #endif
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- varying vec2 vHighPrecisionZW;
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #if DEPTH_PACKING == 3200
- diffuseColor.a = opacity;
- #endif
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <logdepthbuf_fragment>
- float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
- #if DEPTH_PACKING == 3200
- gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
- #elif DEPTH_PACKING == 3201
- gl_FragColor = packDepthToRGBA( fragCoordZ );
- #endif
- }`,tUe=`#define DISTANCE
- varying vec3 vWorldPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <skinbase_vertex>
- #ifdef USE_DISPLACEMENTMAP
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <worldpos_vertex>
- #include <clipping_planes_vertex>
- vWorldPosition = worldPosition.xyz;
- }`,nUe=`#define DISTANCE
- uniform vec3 referencePosition;
- uniform float nearDistance;
- uniform float farDistance;
- varying vec3 vWorldPosition;
- #include <common>
- #include <packing>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main () {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( 1.0 );
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- float dist = length( vWorldPosition - referencePosition );
- dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
- dist = saturate( dist );
- gl_FragColor = packDepthToRGBA( dist );
- }`,rUe=`varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vWorldDirection = transformDirection( position, modelMatrix );
- #include <begin_vertex>
- #include <project_vertex>
- }`,iUe=`uniform sampler2D tEquirect;
- varying vec3 vWorldDirection;
- #include <common>
- void main() {
- vec3 direction = normalize( vWorldDirection );
- vec2 sampleUV = equirectUv( direction );
- gl_FragColor = texture2D( tEquirect, sampleUV );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- }`,aUe=`uniform float scale;
- attribute float lineDistance;
- varying float vLineDistance;
- #include <common>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- vLineDistance = scale * lineDistance;
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,sUe=`uniform vec3 diffuse;
- uniform float opacity;
- uniform float dashSize;
- uniform float totalSize;
- varying float vLineDistance;
- #include <common>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- if ( mod( vLineDistance, totalSize ) > dashSize ) {
- discard;
- }
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,oUe=`#include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #endif
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <fog_vertex>
- }`,lUe=`uniform vec3 diffuse;
- uniform float opacity;
- #ifndef FLAT_SHADED
- varying vec3 vNormal;
- #endif
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- #ifdef USE_LIGHTMAP
- vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
- reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
- #else
- reflectedLight.indirectDiffuse += vec3( 1.0 );
- #endif
- #include <aomap_fragment>
- reflectedLight.indirectDiffuse *= diffuseColor.rgb;
- vec3 outgoingLight = reflectedLight.indirectDiffuse;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,cUe=`#define LAMBERT
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,uUe=`#define LAMBERT
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_lambert_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_lambert_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,dUe=`#define MATCAP
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <color_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- vViewPosition = - mvPosition.xyz;
- }`,hUe=`#define MATCAP
- uniform vec3 diffuse;
- uniform float opacity;
- uniform sampler2D matcap;
- varying vec3 vViewPosition;
- #include <common>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- vec3 viewDir = normalize( vViewPosition );
- vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
- vec3 y = cross( viewDir, x );
- vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
- #ifdef USE_MATCAP
- vec4 matcapColor = texture2D( matcap, uv );
- #else
- vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
- #endif
- vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,fUe=`#define NORMAL
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- vViewPosition = - mvPosition.xyz;
- #endif
- }`,mUe=`#define NORMAL
- uniform float opacity;
- #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
- varying vec3 vViewPosition;
- #endif
- #include <packing>
- #include <uv_pars_fragment>
- #include <normal_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- #include <logdepthbuf_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
- #ifdef OPAQUE
- gl_FragColor.a = 1.0;
- #endif
- }`,pUe=`#define PHONG
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <envmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <envmap_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,gUe=`#define PHONG
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform vec3 specular;
- uniform float shininess;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_phong_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <specularmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <specularmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_phong_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
- #include <envmap_fragment>
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,xUe=`#define STANDARD
- varying vec3 vViewPosition;
- #ifdef USE_TRANSMISSION
- varying vec3 vWorldPosition;
- #endif
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- #ifdef USE_TRANSMISSION
- vWorldPosition = worldPosition.xyz;
- #endif
- }`,bUe=`#define STANDARD
- #ifdef PHYSICAL
- #define IOR
- #define USE_SPECULAR
- #endif
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float roughness;
- uniform float metalness;
- uniform float opacity;
- #ifdef IOR
- uniform float ior;
- #endif
- #ifdef USE_SPECULAR
- uniform float specularIntensity;
- uniform vec3 specularColor;
- #ifdef USE_SPECULAR_COLORMAP
- uniform sampler2D specularColorMap;
- #endif
- #ifdef USE_SPECULAR_INTENSITYMAP
- uniform sampler2D specularIntensityMap;
- #endif
- #endif
- #ifdef USE_CLEARCOAT
- uniform float clearcoat;
- uniform float clearcoatRoughness;
- #endif
- #ifdef USE_IRIDESCENCE
- uniform float iridescence;
- uniform float iridescenceIOR;
- uniform float iridescenceThicknessMinimum;
- uniform float iridescenceThicknessMaximum;
- #endif
- #ifdef USE_SHEEN
- uniform vec3 sheenColor;
- uniform float sheenRoughness;
- #ifdef USE_SHEEN_COLORMAP
- uniform sampler2D sheenColorMap;
- #endif
- #ifdef USE_SHEEN_ROUGHNESSMAP
- uniform sampler2D sheenRoughnessMap;
- #endif
- #endif
- #ifdef USE_ANISOTROPY
- uniform vec2 anisotropyVector;
- #ifdef USE_ANISOTROPYMAP
- uniform sampler2D anisotropyMap;
- #endif
- #endif
- varying vec3 vViewPosition;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <iridescence_fragment>
- #include <cube_uv_reflection_fragment>
- #include <envmap_common_pars_fragment>
- #include <envmap_physical_pars_fragment>
- #include <fog_pars_fragment>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_physical_pars_fragment>
- #include <transmission_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <clearcoat_pars_fragment>
- #include <iridescence_pars_fragment>
- #include <roughnessmap_pars_fragment>
- #include <metalnessmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <roughnessmap_fragment>
- #include <metalnessmap_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <clearcoat_normal_fragment_begin>
- #include <clearcoat_normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_physical_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
- vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
- #include <transmission_fragment>
- vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
- #ifdef USE_SHEEN
- float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
- outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
- #endif
- #ifdef USE_CLEARCOAT
- float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
- vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
- outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
- #endif
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,yUe=`#define TOON
- varying vec3 vViewPosition;
- #include <common>
- #include <batching_pars_vertex>
- #include <uv_pars_vertex>
- #include <displacementmap_pars_vertex>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <normal_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <shadowmap_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <normal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <displacementmap_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- vViewPosition = - mvPosition.xyz;
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,vUe=`#define TOON
- uniform vec3 diffuse;
- uniform vec3 emissive;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <dithering_pars_fragment>
- #include <color_pars_fragment>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <aomap_pars_fragment>
- #include <lightmap_pars_fragment>
- #include <emissivemap_pars_fragment>
- #include <gradientmap_pars_fragment>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <normal_pars_fragment>
- #include <lights_toon_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <bumpmap_pars_fragment>
- #include <normalmap_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec4 diffuseColor = vec4( diffuse, opacity );
- ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
- vec3 totalEmissiveRadiance = emissive;
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <color_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- #include <normal_fragment_begin>
- #include <normal_fragment_maps>
- #include <emissivemap_fragment>
- #include <lights_toon_fragment>
- #include <lights_fragment_begin>
- #include <lights_fragment_maps>
- #include <lights_fragment_end>
- #include <aomap_fragment>
- vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- #include <dithering_fragment>
- }`,wUe=`uniform float size;
- uniform float scale;
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- #ifdef USE_POINTS_UV
- varying vec2 vUv;
- uniform mat3 uvTransform;
- #endif
- void main() {
- #ifdef USE_POINTS_UV
- vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
- #endif
- #include <color_vertex>
- #include <morphcolor_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <project_vertex>
- gl_PointSize = size;
- #ifdef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
- #endif
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <worldpos_vertex>
- #include <fog_vertex>
- }`,_Ue=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <color_pars_fragment>
- #include <map_particle_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_particle_fragment>
- #include <color_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }`,SUe=`#include <common>
- #include <batching_pars_vertex>
- #include <fog_pars_vertex>
- #include <morphtarget_pars_vertex>
- #include <skinning_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <shadowmap_pars_vertex>
- void main() {
- #include <batching_vertex>
- #include <beginnormal_vertex>
- #include <morphnormal_vertex>
- #include <skinbase_vertex>
- #include <skinnormal_vertex>
- #include <defaultnormal_vertex>
- #include <begin_vertex>
- #include <morphtarget_vertex>
- #include <skinning_vertex>
- #include <project_vertex>
- #include <logdepthbuf_vertex>
- #include <worldpos_vertex>
- #include <shadowmap_vertex>
- #include <fog_vertex>
- }`,NUe=`uniform vec3 color;
- uniform float opacity;
- #include <common>
- #include <packing>
- #include <fog_pars_fragment>
- #include <bsdfs>
- #include <lights_pars_begin>
- #include <logdepthbuf_pars_fragment>
- #include <shadowmap_pars_fragment>
- #include <shadowmask_pars_fragment>
- void main() {
- #include <logdepthbuf_fragment>
- gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,MUe=`uniform float rotation;
- uniform vec2 center;
- #include <common>
- #include <uv_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- void main() {
- #include <uv_vertex>
- vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
- vec2 scale;
- scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
- scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
- #ifndef USE_SIZEATTENUATION
- bool isPerspective = isPerspectiveMatrix( projectionMatrix );
- if ( isPerspective ) scale *= - mvPosition.z;
- #endif
- vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
- vec2 rotatedPosition;
- rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
- rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
- mvPosition.xy += rotatedPosition;
- gl_Position = projectionMatrix * mvPosition;
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }`,kUe=`uniform vec3 diffuse;
- uniform float opacity;
- #include <common>
- #include <uv_pars_fragment>
- #include <map_pars_fragment>
- #include <alphamap_pars_fragment>
- #include <alphatest_pars_fragment>
- #include <alphahash_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- void main() {
- #include <clipping_planes_fragment>
- vec3 outgoingLight = vec3( 0.0 );
- vec4 diffuseColor = vec4( diffuse, opacity );
- #include <logdepthbuf_fragment>
- #include <map_fragment>
- #include <alphamap_fragment>
- #include <alphatest_fragment>
- #include <alphahash_fragment>
- outgoingLight = diffuseColor.rgb;
- #include <opaque_fragment>
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- }`,An={alphahash_fragment:KFe,alphahash_pars_fragment:XFe,alphamap_fragment:YFe,alphamap_pars_fragment:QFe,alphatest_fragment:ZFe,alphatest_pars_fragment:JFe,aomap_fragment:eIe,aomap_pars_fragment:tIe,batching_pars_vertex:nIe,batching_vertex:rIe,begin_vertex:iIe,beginnormal_vertex:aIe,bsdfs:sIe,iridescence_fragment:oIe,bumpmap_pars_fragment:lIe,clipping_planes_fragment:cIe,clipping_planes_pars_fragment:uIe,clipping_planes_pars_vertex:dIe,clipping_planes_vertex:hIe,color_fragment:fIe,color_pars_fragment:mIe,color_pars_vertex:pIe,color_vertex:gIe,common:xIe,cube_uv_reflection_fragment:bIe,defaultnormal_vertex:yIe,displacementmap_pars_vertex:vIe,displacementmap_vertex:wIe,emissivemap_fragment:_Ie,emissivemap_pars_fragment:SIe,colorspace_fragment:NIe,colorspace_pars_fragment:MIe,envmap_fragment:kIe,envmap_common_pars_fragment:EIe,envmap_pars_fragment:TIe,envmap_pars_vertex:AIe,envmap_physical_pars_fragment:BIe,envmap_vertex:CIe,fog_vertex:PIe,fog_pars_vertex:jIe,fog_fragment:DIe,fog_pars_fragment:RIe,gradientmap_pars_fragment:OIe,lightmap_fragment:LIe,lightmap_pars_fragment:FIe,lights_lambert_fragment:IIe,lights_lambert_pars_fragment:UIe,lights_pars_begin:zIe,lights_toon_fragment:HIe,lights_toon_pars_fragment:$Ie,lights_phong_fragment:VIe,lights_phong_pars_fragment:GIe,lights_physical_fragment:qIe,lights_physical_pars_fragment:WIe,lights_fragment_begin:KIe,lights_fragment_maps:XIe,lights_fragment_end:YIe,logdepthbuf_fragment:QIe,logdepthbuf_pars_fragment:ZIe,logdepthbuf_pars_vertex:JIe,logdepthbuf_vertex:e5e,map_fragment:t5e,map_pars_fragment:n5e,map_particle_fragment:r5e,map_particle_pars_fragment:i5e,metalnessmap_fragment:a5e,metalnessmap_pars_fragment:s5e,morphcolor_vertex:o5e,morphnormal_vertex:l5e,morphtarget_pars_vertex:c5e,morphtarget_vertex:u5e,normal_fragment_begin:d5e,normal_fragment_maps:h5e,normal_pars_fragment:f5e,normal_pars_vertex:m5e,normal_vertex:p5e,normalmap_pars_fragment:g5e,clearcoat_normal_fragment_begin:x5e,clearcoat_normal_fragment_maps:b5e,clearcoat_pars_fragment:y5e,iridescence_pars_fragment:v5e,opaque_fragment:w5e,packing:_5e,premultiplied_alpha_fragment:S5e,project_vertex:N5e,dithering_fragment:M5e,dithering_pars_fragment:k5e,roughnessmap_fragment:E5e,roughnessmap_pars_fragment:T5e,shadowmap_pars_fragment:A5e,shadowmap_pars_vertex:C5e,shadowmap_vertex:P5e,shadowmask_pars_fragment:j5e,skinbase_vertex:D5e,skinning_pars_vertex:R5e,skinning_vertex:O5e,skinnormal_vertex:L5e,specularmap_fragment:F5e,specularmap_pars_fragment:I5e,tonemapping_fragment:U5e,tonemapping_pars_fragment:z5e,transmission_fragment:B5e,transmission_pars_fragment:H5e,uv_pars_fragment:$5e,uv_pars_vertex:V5e,uv_vertex:G5e,worldpos_vertex:q5e,background_vert:W5e,background_frag:K5e,backgroundCube_vert:X5e,backgroundCube_frag:Y5e,cube_vert:Q5e,cube_frag:Z5e,depth_vert:J5e,depth_frag:eUe,distanceRGBA_vert:tUe,distanceRGBA_frag:nUe,equirect_vert:rUe,equirect_frag:iUe,linedashed_vert:aUe,linedashed_frag:sUe,meshbasic_vert:oUe,meshbasic_frag:lUe,meshlambert_vert:cUe,meshlambert_frag:uUe,meshmatcap_vert:dUe,meshmatcap_frag:hUe,meshnormal_vert:fUe,meshnormal_frag:mUe,meshphong_vert:pUe,meshphong_frag:gUe,meshphysical_vert:xUe,meshphysical_frag:bUe,meshtoon_vert:yUe,meshtoon_frag:vUe,points_vert:wUe,points_frag:_Ue,shadow_vert:SUe,shadow_frag:NUe,sprite_vert:MUe,sprite_frag:kUe},Dt={common:{diffuse:{value:new Zt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Fn},alphaMap:{value:null},alphaMapTransform:{value:new Fn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Fn}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Fn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Fn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Fn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Fn},normalScale:{value:new bn(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Fn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Fn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Fn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Fn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Zt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Zt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Fn},alphaTest:{value:0},uvTransform:{value:new Fn}},sprite:{diffuse:{value:new Zt(16777215)},opacity:{value:1},center:{value:new bn(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Fn},alphaMap:{value:null},alphaMapTransform:{value:new Fn},alphaTest:{value:0}}},Rs={basic:{uniforms:us([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.fog]),vertexShader:An.meshbasic_vert,fragmentShader:An.meshbasic_frag},lambert:{uniforms:us([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,Dt.lights,{emissive:{value:new Zt(0)}}]),vertexShader:An.meshlambert_vert,fragmentShader:An.meshlambert_frag},phong:{uniforms:us([Dt.common,Dt.specularmap,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,Dt.lights,{emissive:{value:new Zt(0)},specular:{value:new Zt(1118481)},shininess:{value:30}}]),vertexShader:An.meshphong_vert,fragmentShader:An.meshphong_frag},standard:{uniforms:us([Dt.common,Dt.envmap,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.roughnessmap,Dt.metalnessmap,Dt.fog,Dt.lights,{emissive:{value:new Zt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:An.meshphysical_vert,fragmentShader:An.meshphysical_frag},toon:{uniforms:us([Dt.common,Dt.aomap,Dt.lightmap,Dt.emissivemap,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.gradientmap,Dt.fog,Dt.lights,{emissive:{value:new Zt(0)}}]),vertexShader:An.meshtoon_vert,fragmentShader:An.meshtoon_frag},matcap:{uniforms:us([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,Dt.fog,{matcap:{value:null}}]),vertexShader:An.meshmatcap_vert,fragmentShader:An.meshmatcap_frag},points:{uniforms:us([Dt.points,Dt.fog]),vertexShader:An.points_vert,fragmentShader:An.points_frag},dashed:{uniforms:us([Dt.common,Dt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:An.linedashed_vert,fragmentShader:An.linedashed_frag},depth:{uniforms:us([Dt.common,Dt.displacementmap]),vertexShader:An.depth_vert,fragmentShader:An.depth_frag},normal:{uniforms:us([Dt.common,Dt.bumpmap,Dt.normalmap,Dt.displacementmap,{opacity:{value:1}}]),vertexShader:An.meshnormal_vert,fragmentShader:An.meshnormal_frag},sprite:{uniforms:us([Dt.sprite,Dt.fog]),vertexShader:An.sprite_vert,fragmentShader:An.sprite_frag},background:{uniforms:{uvTransform:{value:new Fn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:An.background_vert,fragmentShader:An.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:An.backgroundCube_vert,fragmentShader:An.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:An.cube_vert,fragmentShader:An.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:An.equirect_vert,fragmentShader:An.equirect_frag},distanceRGBA:{uniforms:us([Dt.common,Dt.displacementmap,{referencePosition:{value:new qe},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:An.distanceRGBA_vert,fragmentShader:An.distanceRGBA_frag},shadow:{uniforms:us([Dt.lights,Dt.fog,{color:{value:new Zt(0)},opacity:{value:1}}]),vertexShader:An.shadow_vert,fragmentShader:An.shadow_frag}};Rs.physical={uniforms:us([Rs.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Fn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Fn},clearcoatNormalScale:{value:new bn(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Fn},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Fn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Fn},sheen:{value:0},sheenColor:{value:new Zt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Fn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Fn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Fn},transmissionSamplerSize:{value:new bn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Fn},attenuationDistance:{value:0},attenuationColor:{value:new Zt(0)},specularColor:{value:new Zt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Fn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Fn},anisotropyVector:{value:new bn},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Fn}}]),vertexShader:An.meshphysical_vert,fragmentShader:An.meshphysical_frag};const $_={r:0,b:0,g:0};function EUe(t,e,n,r,i,a,o){const l=new Zt(0);let c=a===!0?0:1,u,d,f=null,p=0,m=null;function x(v,y){let S=!1,k=y.isScene===!0?y.background:null;k&&k.isTexture&&(k=(y.backgroundBlurriness>0?n:e).get(k)),k===null?b(l,c):k&&k.isColor&&(b(k,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),k&&(k.isCubeTexture||k.mapping===b2)?(d===void 0&&(d=new Dl(new pv(1,1,1),new Ah({name:"BackgroundCubeMaterial",uniforms:ax(Rs.backgroundCube.uniforms),vertexShader:Rs.backgroundCube.vertexShader,fragmentShader:Rs.backgroundCube.fragmentShader,side:Us,depthTest:!1,depthWrite:!1,fog:!1})),d.geometry.deleteAttribute("normal"),d.geometry.deleteAttribute("uv"),d.onBeforeRender=function(M,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=k,d.material.uniforms.flipEnvMap.value=k.isCubeTexture&&k.isRenderTargetTexture===!1?-1:1,d.material.uniforms.backgroundBlurriness.value=y.backgroundBlurriness,d.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,d.material.toneMapped=Er.getTransfer(k.colorSpace)!==Gr,(f!==k||p!==k.version||m!==t.toneMapping)&&(d.material.needsUpdate=!0,f=k,p=k.version,m=t.toneMapping),d.layers.enableAll(),v.unshift(d,d.geometry,d.material,0,0,null)):k&&k.isTexture&&(u===void 0&&(u=new Dl(new cL(2,2),new Ah({name:"BackgroundMaterial",uniforms:ax(Rs.background.uniforms),vertexShader:Rs.background.vertexShader,fragmentShader:Rs.background.fragmentShader,side:Th,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=k,u.material.uniforms.backgroundIntensity.value=y.backgroundIntensity,u.material.toneMapped=Er.getTransfer(k.colorSpace)!==Gr,k.matrixAutoUpdate===!0&&k.updateMatrix(),u.material.uniforms.uvTransform.value.copy(k.matrix),(f!==k||p!==k.version||m!==t.toneMapping)&&(u.material.needsUpdate=!0,f=k,p=k.version,m=t.toneMapping),u.layers.enableAll(),v.unshift(u,u.geometry,u.material,0,0,null))}function b(v,y){v.getRGB($_,see(t)),r.buffers.color.setClear($_.r,$_.g,$_.b,y,o)}return{getClearColor:function(){return l},setClearColor:function(v,y=1){l.set(v),c=y,b(l,c)},getClearAlpha:function(){return c},setClearAlpha:function(v){c=v,b(l,c)},render:x}}function TUe(t,e,n,r){const i=t.getParameter(t.MAX_VERTEX_ATTRIBS),a=r.isWebGL2?null:e.get("OES_vertex_array_object"),o=r.isWebGL2||a!==null,l={},c=v(null);let u=c,d=!1;function f(P,$,X,V,Q){let Z=!1;if(o){const se=b(V,X,$);u!==se&&(u=se,m(u.object)),Z=y(P,V,X,Q),Z&&S(P,V,X,Q)}else{const se=$.wireframe===!0;(u.geometry!==V.id||u.program!==X.id||u.wireframe!==se)&&(u.geometry=V.id,u.program=X.id,u.wireframe=se,Z=!0)}Q!==null&&n.update(Q,t.ELEMENT_ARRAY_BUFFER),(Z||d)&&(d=!1,R(P,$,X,V),Q!==null&&t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,n.get(Q).buffer))}function p(){return r.isWebGL2?t.createVertexArray():a.createVertexArrayOES()}function m(P){return r.isWebGL2?t.bindVertexArray(P):a.bindVertexArrayOES(P)}function x(P){return r.isWebGL2?t.deleteVertexArray(P):a.deleteVertexArrayOES(P)}function b(P,$,X){const V=X.wireframe===!0;let Q=l[P.id];Q===void 0&&(Q={},l[P.id]=Q);let Z=Q[$.id];Z===void 0&&(Z={},Q[$.id]=Z);let se=Z[V];return se===void 0&&(se=v(p()),Z[V]=se),se}function v(P){const $=[],X=[],V=[];for(let Q=0;Q<i;Q++)$[Q]=0,X[Q]=0,V[Q]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:$,enabledAttributes:X,attributeDivisors:V,object:P,attributes:{},index:null}}function y(P,$,X,V){const Q=u.attributes,Z=$.attributes;let se=0;const H=X.getAttributes();for(const K in H)if(H[K].location>=0){const ne=Q[K];let be=Z[K];if(be===void 0&&(K==="instanceMatrix"&&P.instanceMatrix&&(be=P.instanceMatrix),K==="instanceColor"&&P.instanceColor&&(be=P.instanceColor)),ne===void 0||ne.attribute!==be||be&&ne.data!==be.data)return!0;se++}return u.attributesNum!==se||u.index!==V}function S(P,$,X,V){const Q={},Z=$.attributes;let se=0;const H=X.getAttributes();for(const K in H)if(H[K].location>=0){let ne=Z[K];ne===void 0&&(K==="instanceMatrix"&&P.instanceMatrix&&(ne=P.instanceMatrix),K==="instanceColor"&&P.instanceColor&&(ne=P.instanceColor));const be={};be.attribute=ne,ne&&ne.data&&(be.data=ne.data),Q[K]=be,se++}u.attributes=Q,u.attributesNum=se,u.index=V}function k(){const P=u.newAttributes;for(let $=0,X=P.length;$<X;$++)P[$]=0}function T(P){M(P,0)}function M(P,$){const X=u.newAttributes,V=u.enabledAttributes,Q=u.attributeDivisors;X[P]=1,V[P]===0&&(t.enableVertexAttribArray(P),V[P]=1),Q[P]!==$&&((r.isWebGL2?t:e.get("ANGLE_instanced_arrays"))[r.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](P,$),Q[P]=$)}function C(){const P=u.newAttributes,$=u.enabledAttributes;for(let X=0,V=$.length;X<V;X++)$[X]!==P[X]&&(t.disableVertexAttribArray(X),$[X]=0)}function E(P,$,X,V,Q,Z,se){se===!0?t.vertexAttribIPointer(P,$,X,Q,Z):t.vertexAttribPointer(P,$,X,V,Q,Z)}function R(P,$,X,V){if(r.isWebGL2===!1&&(P.isInstancedMesh||V.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;k();const Q=V.attributes,Z=X.getAttributes(),se=$.defaultAttributeValues;for(const H in Z){const K=Z[H];if(K.location>=0){let re=Q[H];if(re===void 0&&(H==="instanceMatrix"&&P.instanceMatrix&&(re=P.instanceMatrix),H==="instanceColor"&&P.instanceColor&&(re=P.instanceColor)),re!==void 0){const ne=re.normalized,be=re.itemSize,me=n.get(re);if(me===void 0)continue;const de=me.buffer,Ce=me.type,ie=me.bytesPerElement,ke=r.isWebGL2===!0&&(Ce===t.INT||Ce===t.UNSIGNED_INT||re.gpuType===zJ);if(re.isInterleavedBufferAttribute){const Oe=re.data,pe=Oe.stride,We=re.offset;if(Oe.isInstancedInterleavedBuffer){for(let G=0;G<K.locationSize;G++)M(K.location+G,Oe.meshPerAttribute);P.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=Oe.meshPerAttribute*Oe.count)}else for(let G=0;G<K.locationSize;G++)T(K.location+G);t.bindBuffer(t.ARRAY_BUFFER,de);for(let G=0;G<K.locationSize;G++)E(K.location+G,be/K.locationSize,Ce,ne,pe*ie,(We+be/K.locationSize*G)*ie,ke)}else{if(re.isInstancedBufferAttribute){for(let Oe=0;Oe<K.locationSize;Oe++)M(K.location+Oe,re.meshPerAttribute);P.isInstancedMesh!==!0&&V._maxInstanceCount===void 0&&(V._maxInstanceCount=re.meshPerAttribute*re.count)}else for(let Oe=0;Oe<K.locationSize;Oe++)T(K.location+Oe);t.bindBuffer(t.ARRAY_BUFFER,de);for(let Oe=0;Oe<K.locationSize;Oe++)E(K.location+Oe,be/K.locationSize,Ce,ne,be*ie,be/K.locationSize*Oe*ie,ke)}}else if(se!==void 0){const ne=se[H];if(ne!==void 0)switch(ne.length){case 2:t.vertexAttrib2fv(K.location,ne);break;case 3:t.vertexAttrib3fv(K.location,ne);break;case 4:t.vertexAttrib4fv(K.location,ne);break;default:t.vertexAttrib1fv(K.location,ne)}}}}C()}function A(){F();for(const P in l){const $=l[P];for(const X in $){const V=$[X];for(const Q in V)x(V[Q].object),delete V[Q];delete $[X]}delete l[P]}}function D(P){if(l[P.id]===void 0)return;const $=l[P.id];for(const X in $){const V=$[X];for(const Q in V)x(V[Q].object),delete V[Q];delete $[X]}delete l[P.id]}function I(P){for(const $ in l){const X=l[$];if(X[P.id]===void 0)continue;const V=X[P.id];for(const Q in V)x(V[Q].object),delete V[Q];delete X[P.id]}}function F(){z(),d=!0,u!==c&&(u=c,m(u.object))}function z(){c.geometry=null,c.program=null,c.wireframe=!1}return{setup:f,reset:F,resetDefaultState:z,dispose:A,releaseStatesOfGeometry:D,releaseStatesOfProgram:I,initAttributes:k,enableAttribute:T,disableUnusedAttributes:C}}function AUe(t,e,n,r){const i=r.isWebGL2;let a;function o(d){a=d}function l(d,f){t.drawArrays(a,d,f),n.update(f,a,1)}function c(d,f,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](a,d,f,p),n.update(f,a,p)}function u(d,f,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],f[x]);else{m.multiDrawArraysWEBGL(a,d,0,f,0,p);let x=0;for(let b=0;b<p;b++)x+=f[b];n.update(x,a,1)}}this.setMode=o,this.render=l,this.renderInstances=c,this.renderMultiDraw=u}function CUe(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 a(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=a(l);c!==l&&(console.warn("THREE.WebGLRenderer:",l,"not supported, using",c,"instead."),l=c);const u=o||e.has("WEBGL_draw_buffers"),d=n.logarithmicDepthBuffer===!0,f=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),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),b=t.getParameter(t.MAX_VERTEX_ATTRIBS),v=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),y=t.getParameter(t.MAX_VARYING_VECTORS),S=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),k=p>0,T=o||e.has("OES_texture_float"),M=k&&T,C=o?t.getParameter(t.MAX_SAMPLES):0;return{isWebGL2:o,drawBuffers:u,getMaxAnisotropy:i,getMaxPrecision:a,precision:l,logarithmicDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:m,maxCubemapSize:x,maxAttributes:b,maxVertexUniforms:v,maxVaryings:y,maxFragmentUniforms:S,vertexTextures:k,floatFragmentTextures:T,floatVertexTextures:M,maxSamples:C}}function PUe(t){const e=this;let n=null,r=0,i=!1,a=!1;const o=new Hd,l=new Fn,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(f,p){const m=f.length!==0||p||r!==0||i;return i=p,r=f.length,m},this.beginShadows=function(){a=!0,d(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(f,p){n=d(f,p,0)},this.setState=function(f,p,m){const x=f.clippingPlanes,b=f.clipIntersection,v=f.clipShadows,y=t.get(f);if(!i||x===null||x.length===0||a&&!v)a?d(null):u();else{const S=a?0:r,k=S*4;let T=y.clippingState||null;c.value=T,T=d(x,p,k,m);for(let M=0;M!==k;++M)T[M]=n[M];y.clippingState=T,this.numIntersection=b?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(f,p,m,x){const b=f!==null?f.length:0;let v=null;if(b!==0){if(v=c.value,x!==!0||v===null){const y=m+b*4,S=p.matrixWorldInverse;l.getNormalMatrix(S),(v===null||v.length<y)&&(v=new Float32Array(y));for(let k=0,T=m;k!==b;++k,T+=4)o.copy(f[k]).applyMatrix4(S,l),o.normal.toArray(v,T),v[T+3]=o.constant}c.value=v,c.needsUpdate=!0}return e.numPlanes=b,e.numIntersection=0,v}}function jUe(t){let e=new WeakMap;function n(o,l){return l===pD?o.mapping=nx:l===gD&&(o.mapping=rx),o}function r(o){if(o&&o.isTexture){const l=o.mapping;if(l===pD||l===gD)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 VFe(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 a(){e=new WeakMap}return{get:r,dispose:a}}class DUe extends oee{constructor(e=-1,n=1,r=1,i=-1,a=.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=a,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,a,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=a,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 a=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;a+=u*this.view.offsetX,o=a+u*this.view.width,l-=d*this.view.offsetY,c=l-d*this.view.height}this.projectionMatrix.makeOrthographic(a,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 yg=4,FG=[.125,.215,.35,.446,.526,.582],Ef=20,WC=new DUe,IG=new Zt;let KC=null,XC=0,YC=0;const Sf=(1+Math.sqrt(5))/2,Qp=1/Sf,UG=[new qe(1,1,1),new qe(-1,1,1),new qe(1,1,-1),new qe(-1,1,-1),new qe(0,Sf,Qp),new qe(0,Sf,-Qp),new qe(Qp,0,Sf),new qe(-Qp,0,Sf),new qe(Sf,Qp,0),new qe(-Sf,Qp,0)];class zG{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){KC=this._renderer.getRenderTarget(),XC=this._renderer.getActiveCubeFace(),YC=this._renderer.getActiveMipmapLevel(),this._setSize(256);const a=this._allocateTargets();return a.depthBuffer=!0,this._sceneToCubeUV(e,r,i,a),n>0&&this._blur(a,0,0,n),this._applyPMREM(a),this._cleanup(a),a}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=$G(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=HG(),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(KC,XC,YC),e.scissorTest=!1,V_(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===nx||e.mapping===rx?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),KC=this._renderer.getRenderTarget(),XC=this._renderer.getActiveCubeFace(),YC=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:Ko,minFilter:Ko,generateMipmaps:!1,type:xy,format:Xo,colorSpace:Vu,depthBuffer:!1},i=BG(e,n,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==n){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=BG(e,n,r);const{_lodMax:a}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=RUe(a)),this._blurMaterial=OUe(a,e,n)}return i}_compileMaterial(e){const n=new Dl(this._lodPlanes[0],e);this._renderer.compile(n,WC)}_sceneToCubeUV(e,n,r,i){const l=new so(90,1,n,r),c=[1,-1,1,1,1,1],u=[1,1,1,-1,-1,-1],d=this._renderer,f=d.autoClear,p=d.toneMapping;d.getClearColor(IG),d.toneMapping=uh,d.autoClear=!1;const m=new ree({name:"PMREM.Background",side:Us,depthWrite:!1,depthTest:!1}),x=new Dl(new pv,m);let b=!1;const v=e.background;v?v.isColor&&(m.color.copy(v),e.background=null,b=!0):(m.color.copy(IG),b=!0);for(let y=0;y<6;y++){const S=y%3;S===0?(l.up.set(0,c[y],0),l.lookAt(u[y],0,0)):S===1?(l.up.set(0,0,c[y]),l.lookAt(0,u[y],0)):(l.up.set(0,c[y],0),l.lookAt(0,0,u[y]));const k=this._cubeSize;V_(i,S*k,y>2?k:0,k,k),d.setRenderTarget(i),b&&d.render(x,l),d.render(e,l)}x.geometry.dispose(),x.material.dispose(),d.toneMapping=p,d.autoClear=f,e.background=v}_textureToCubeUV(e,n){const r=this._renderer,i=e.mapping===nx||e.mapping===rx;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=$G()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=HG());const a=i?this._cubemapMaterial:this._equirectMaterial,o=new Dl(this._lodPlanes[0],a),l=a.uniforms;l.envMap.value=e;const c=this._cubeSize;V_(n,0,0,3*c,2*c),r.setRenderTarget(n),r.render(o,WC)}_applyPMREM(e){const n=this._renderer,r=n.autoClear;n.autoClear=!1;for(let i=1;i<this._lodPlanes.length;i++){const a=Math.sqrt(this._sigmas[i]*this._sigmas[i]-this._sigmas[i-1]*this._sigmas[i-1]),o=UG[(i-1)%UG.length];this._blur(e,i-1,i,a,o)}n.autoClear=r}_blur(e,n,r,i,a){const o=this._pingPongRenderTarget;this._halfBlur(e,o,n,r,i,"latitudinal",a),this._halfBlur(o,e,r,r,i,"longitudinal",a)}_halfBlur(e,n,r,i,a,o,l){const c=this._renderer,u=this._blurMaterial;o!=="latitudinal"&&o!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const d=3,f=new Dl(this._lodPlanes[i],u),p=u.uniforms,m=this._sizeLods[r]-1,x=isFinite(a)?Math.PI/(2*m):2*Math.PI/(2*Ef-1),b=a/x,v=isFinite(a)?1+Math.floor(d*b):Ef;v>Ef&&console.warn(`sigmaRadians, ${a}, is too large and will clip, as it requested ${v} samples when the maximum is set to ${Ef}`);const y=[];let S=0;for(let E=0;E<Ef;++E){const R=E/b,A=Math.exp(-R*R/2);y.push(A),E===0?S+=A:E<v&&(S+=2*A)}for(let E=0;E<y.length;E++)y[E]=y[E]/S;p.envMap.value=e.texture,p.samples.value=v,p.weights.value=y,p.latitudinal.value=o==="latitudinal",l&&(p.poleAxis.value=l);const{_lodMax:k}=this;p.dTheta.value=x,p.mipInt.value=k-r;const T=this._sizeLods[i],M=3*T*(i>k-yg?i-k+yg:0),C=4*(this._cubeSize-T);V_(n,M,C,3*T,2*T),c.setRenderTarget(n),c.render(f,WC)}}function RUe(t){const e=[],n=[],r=[];let i=t;const a=t-yg+1+FG.length;for(let o=0;o<a;o++){const l=Math.pow(2,i);n.push(l);let c=1/l;o>t-yg?c=FG[o-t+yg-1]:o===0&&(c=0),r.push(c);const u=1/(l-2),d=-u,f=1+u,p=[d,d,f,d,f,f,d,d,f,f,d,f],m=6,x=6,b=3,v=2,y=1,S=new Float32Array(b*x*m),k=new Float32Array(v*x*m),T=new Float32Array(y*x*m);for(let C=0;C<m;C++){const E=C%3*2/3-1,R=C>2?0:-1,A=[E,R,0,E+2/3,R,0,E+2/3,R+1,0,E,R,0,E+2/3,R+1,0,E,R+1,0];S.set(A,b*x*C),k.set(p,v*x*C);const D=[C,C,C,C,C,C];T.set(D,y*x*C)}const M=new ns;M.setAttribute("position",new po(S,b)),M.setAttribute("uv",new po(k,v)),M.setAttribute("faceIndex",new po(T,y)),e.push(M),i>yg&&i--}return{lodPlanes:e,sizeLods:n,sigmas:r}}function BG(t,e,n){const r=new ym(t,e,n);return r.texture.mapping=b2,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function V_(t,e,n,r,i){t.viewport.set(e,n,r,i),t.scissor.set(e,n,r,i)}function OUe(t,e,n){const r=new Float32Array(Ef),i=new qe(0,1,0);return new Ah({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:uL(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- uniform int samples;
- uniform float weights[ n ];
- uniform bool latitudinal;
- uniform float dTheta;
- uniform float mipInt;
- uniform vec3 poleAxis;
- #define ENVMAP_TYPE_CUBE_UV
- #include <cube_uv_reflection_fragment>
- vec3 getSample( float theta, vec3 axis ) {
- float cosTheta = cos( theta );
- // Rodrigues' axis-angle rotation
- vec3 sampleDirection = vOutputDirection * cosTheta
- + cross( axis, vOutputDirection ) * sin( theta )
- + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
- return bilinearCubeUV( envMap, sampleDirection, mipInt );
- }
- void main() {
- vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
- if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
- axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
- }
- axis = normalize( axis );
- gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
- gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
- for ( int i = 1; i < n; i++ ) {
- if ( i >= samples ) {
- break;
- }
- float theta = dTheta * float( i );
- gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
- gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
- }
- }
- `,blending:ch,depthTest:!1,depthWrite:!1})}function HG(){return new Ah({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:uL(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- varying vec3 vOutputDirection;
- uniform sampler2D envMap;
- #include <common>
- void main() {
- vec3 outputDirection = normalize( vOutputDirection );
- vec2 uv = equirectUv( outputDirection );
- gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
- }
- `,blending:ch,depthTest:!1,depthWrite:!1})}function $G(){return new Ah({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:uL(),fragmentShader:`
- precision mediump float;
- precision mediump int;
- uniform float flipEnvMap;
- varying vec3 vOutputDirection;
- uniform samplerCube envMap;
- void main() {
- gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
- }
- `,blending:ch,depthTest:!1,depthWrite:!1})}function uL(){return`
- precision mediump float;
- precision mediump int;
- attribute float faceIndex;
- varying vec3 vOutputDirection;
- // RH coordinate system; PMREM face-indexing convention
- vec3 getDirection( vec2 uv, float face ) {
- uv = 2.0 * uv - 1.0;
- vec3 direction = vec3( uv, 1.0 );
- if ( face == 0.0 ) {
- direction = direction.zyx; // ( 1, v, u ) pos x
- } else if ( face == 1.0 ) {
- direction = direction.xzy;
- direction.xz *= -1.0; // ( -u, 1, -v ) pos y
- } else if ( face == 2.0 ) {
- direction.x *= -1.0; // ( -u, v, 1 ) pos z
- } else if ( face == 3.0 ) {
- direction = direction.zyx;
- direction.xz *= -1.0; // ( -1, v, -u ) neg x
- } else if ( face == 4.0 ) {
- direction = direction.xzy;
- direction.xy *= -1.0; // ( -u, -1, v ) neg y
- } else if ( face == 5.0 ) {
- direction.z *= -1.0; // ( u, v, -1 ) neg z
- }
- return direction;
- }
- void main() {
- vOutputDirection = getDirection( uv, faceIndex );
- gl_Position = vec4( position, 1.0 );
- }
- `}function LUe(t){let e=new WeakMap,n=null;function r(l){if(l&&l.isTexture){const c=l.mapping,u=c===pD||c===gD,d=c===nx||c===rx;if(u||d)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let f=e.get(l);return n===null&&(n=new zG(t)),f=u?n.fromEquirectangular(l,f):n.fromCubemap(l,f),e.set(l,f),f.texture}else{if(e.has(l))return e.get(l).texture;{const f=l.image;if(u&&f&&f.height>0||d&&f&&i(f)){n===null&&(n=new zG(t));const p=u?n.fromEquirectangular(l):n.fromCubemap(l);return e.set(l,p),l.addEventListener("dispose",a),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 a(l){const c=l.target;c.removeEventListener("dispose",a);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 FUe(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 IUe(t,e,n,r){const i={},a=new WeakMap;function o(f){const p=f.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 b=p.morphAttributes[x];for(let v=0,y=b.length;v<y;v++)e.remove(b[v])}p.removeEventListener("dispose",o),delete i[p.id];const m=a.get(p);m&&(e.remove(m),a.delete(p)),r.releaseStatesOfGeometry(p),p.isInstancedBufferGeometry===!0&&delete p._maxInstanceCount,n.memory.geometries--}function l(f,p){return i[p.id]===!0||(p.addEventListener("dispose",o),i[p.id]=!0,n.memory.geometries++),p}function c(f){const p=f.attributes;for(const x in p)e.update(p[x],t.ARRAY_BUFFER);const m=f.morphAttributes;for(const x in m){const b=m[x];for(let v=0,y=b.length;v<y;v++)e.update(b[v],t.ARRAY_BUFFER)}}function u(f){const p=[],m=f.index,x=f.attributes.position;let b=0;if(m!==null){const S=m.array;b=m.version;for(let k=0,T=S.length;k<T;k+=3){const M=S[k+0],C=S[k+1],E=S[k+2];p.push(M,C,C,E,E,M)}}else if(x!==void 0){const S=x.array;b=x.version;for(let k=0,T=S.length/3-1;k<T;k+=3){const M=k+0,C=k+1,E=k+2;p.push(M,C,C,E,E,M)}}else return;const v=new(QJ(p)?aee:iee)(p,1);v.version=b;const y=a.get(f);y&&e.remove(y),a.set(f,v)}function d(f){const p=a.get(f);if(p){const m=f.index;m!==null&&p.version<m.version&&u(f)}else u(f);return a.get(f)}return{get:l,update:c,getWireframeAttribute:d}}function UUe(t,e,n,r){const i=r.isWebGL2;let a;function o(m){a=m}let l,c;function u(m){l=m.type,c=m.bytesPerElement}function d(m,x){t.drawElements(a,x,l,m*c),n.update(x,a,1)}function f(m,x,b){if(b===0)return;let v,y;if(i)v=t,y="drawElementsInstanced";else if(v=e.get("ANGLE_instanced_arrays"),y="drawElementsInstancedANGLE",v===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}v[y](a,x,l,m*c,b),n.update(x,a,b)}function p(m,x,b){if(b===0)return;const v=e.get("WEBGL_multi_draw");if(v===null)for(let y=0;y<b;y++)this.render(m[y]/c,x[y]);else{v.multiDrawElementsWEBGL(a,x,0,l,m,0,b);let y=0;for(let S=0;S<b;S++)y+=x[S];n.update(y,a,1)}}this.setMode=o,this.setIndex=u,this.render=d,this.renderInstances=f,this.renderMultiDraw=p}function zUe(t){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,o,l){switch(n.calls++,o){case t.TRIANGLES:n.triangles+=l*(a/3);break;case t.LINES:n.lines+=l*(a/2);break;case t.LINE_STRIP:n.lines+=l*(a-1);break;case t.LINE_LOOP:n.lines+=l*a;break;case t.POINTS:n.points+=l*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",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 BUe(t,e){return t[0]-e[0]}function HUe(t,e){return Math.abs(e[1])-Math.abs(t[1])}function $Ue(t,e,n){const r={},i=new Float32Array(8),a=new WeakMap,o=new Cr,l=[];for(let u=0;u<8;u++)l[u]=[u,0];function c(u,d,f){const p=u.morphTargetInfluences;if(e.isWebGL2===!0){const x=d.morphAttributes.position||d.morphAttributes.normal||d.morphAttributes.color,b=x!==void 0?x.length:0;let v=a.get(d);if(v===void 0||v.count!==b){let $=function(){z.dispose(),a.delete(d),d.removeEventListener("dispose",$)};var m=$;v!==void 0&&v.texture.dispose();const k=d.morphAttributes.position!==void 0,T=d.morphAttributes.normal!==void 0,M=d.morphAttributes.color!==void 0,C=d.morphAttributes.position||[],E=d.morphAttributes.normal||[],R=d.morphAttributes.color||[];let A=0;k===!0&&(A=1),T===!0&&(A=2),M===!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 F=new Float32Array(D*I*4*b),z=new eee(F,D,I,b);z.type=Su,z.needsUpdate=!0;const P=A*4;for(let X=0;X<b;X++){const V=C[X],Q=E[X],Z=R[X],se=D*I*4*X;for(let H=0;H<V.count;H++){const K=H*P;k===!0&&(o.fromBufferAttribute(V,H),F[se+K+0]=o.x,F[se+K+1]=o.y,F[se+K+2]=o.z,F[se+K+3]=0),T===!0&&(o.fromBufferAttribute(Q,H),F[se+K+4]=o.x,F[se+K+5]=o.y,F[se+K+6]=o.z,F[se+K+7]=0),M===!0&&(o.fromBufferAttribute(Z,H),F[se+K+8]=o.x,F[se+K+9]=o.y,F[se+K+10]=o.z,F[se+K+11]=Z.itemSize===4?o.w:1)}}v={count:b,texture:z,size:new bn(D,I)},a.set(d,v),d.addEventListener("dispose",$)}let y=0;for(let k=0;k<p.length;k++)y+=p[k];const S=d.morphTargetsRelative?1:1-y;f.getUniforms().setValue(t,"morphTargetBaseInfluence",S),f.getUniforms().setValue(t,"morphTargetInfluences",p),f.getUniforms().setValue(t,"morphTargetsTexture",v.texture,n),f.getUniforms().setValue(t,"morphTargetsTextureSize",v.size)}else{const x=p===void 0?0:p.length;let b=r[d.id];if(b===void 0||b.length!==x){b=[];for(let T=0;T<x;T++)b[T]=[T,0];r[d.id]=b}for(let T=0;T<x;T++){const M=b[T];M[0]=T,M[1]=p[T]}b.sort(HUe);for(let T=0;T<8;T++)T<x&&b[T][1]?(l[T][0]=b[T][0],l[T][1]=b[T][1]):(l[T][0]=Number.MAX_SAFE_INTEGER,l[T][1]=0);l.sort(BUe);const v=d.morphAttributes.position,y=d.morphAttributes.normal;let S=0;for(let T=0;T<8;T++){const M=l[T],C=M[0],E=M[1];C!==Number.MAX_SAFE_INTEGER&&E?(v&&d.getAttribute("morphTarget"+T)!==v[C]&&d.setAttribute("morphTarget"+T,v[C]),y&&d.getAttribute("morphNormal"+T)!==y[C]&&d.setAttribute("morphNormal"+T,y[C]),i[T]=E,S+=E):(v&&d.hasAttribute("morphTarget"+T)===!0&&d.deleteAttribute("morphTarget"+T),y&&d.hasAttribute("morphNormal"+T)===!0&&d.deleteAttribute("morphNormal"+T),i[T]=0)}const k=d.morphTargetsRelative?1:1-S;f.getUniforms().setValue(t,"morphTargetBaseInfluence",k),f.getUniforms().setValue(t,"morphTargetInfluences",i)}}return{update:c}}function VUe(t,e,n,r){let i=new WeakMap;function a(c){const u=r.render.frame,d=c.geometry,f=e.get(c,d);if(i.get(f)!==u&&(e.update(f),i.set(f,u)),c.isInstancedMesh&&(c.hasEventListener("dispose",l)===!1&&c.addEventListener("dispose",l),i.get(c)!==u&&(n.update(c.instanceMatrix,t.ARRAY_BUFFER),c.instanceColor!==null&&n.update(c.instanceColor,t.ARRAY_BUFFER),i.set(c,u))),c.isSkinnedMesh){const p=c.skeleton;i.get(p)!==u&&(p.update(),i.set(p,u))}return f}function o(){i=new WeakMap}function l(c){const u=c.target;u.removeEventListener("dispose",l),n.remove(u.instanceMatrix),u.instanceColor!==null&&n.remove(u.instanceColor)}return{update:a,dispose:o}}class uee extends zs{constructor(e,n,r,i,a,o,l,c,u,d){if(d=d!==void 0?d:Wf,d!==Wf&&d!==ix)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");r===void 0&&d===Wf&&(r=Zd),r===void 0&&d===ix&&(r=qf),super(null,i,a,o,l,c,d,r,u),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=l!==void 0?l:Oa,this.minFilter=c!==void 0?c:Oa,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 dee=new zs,hee=new uee(1,1);hee.compareFunction=XJ;const fee=new eee,mee=new TFe,pee=new lee,VG=[],GG=[],qG=new Float32Array(16),WG=new Float32Array(9),KG=new Float32Array(4);function Rx(t,e,n){const r=t[0];if(r<=0||r>0)return t;const i=e*n;let a=VG[i];if(a===void 0&&(a=new Float32Array(i),VG[i]=a),e!==0){r.toArray(a,0);for(let o=1,l=0;o!==e;++o)l+=n,t[o].toArray(a,l)}return a}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 w2(t,e){let n=GG[e];n===void 0&&(n=new Int32Array(e),GG[e]=n);for(let r=0;r!==e;++r)n[r]=t.allocateTextureUnit();return n}function GUe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1f(this.addr,e),n[0]=e)}function qUe(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 WUe(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 KUe(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 XUe(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;KG.set(r),t.uniformMatrix2fv(this.addr,!1,KG),na(n,r)}}function YUe(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;WG.set(r),t.uniformMatrix3fv(this.addr,!1,WG),na(n,r)}}function QUe(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;qG.set(r),t.uniformMatrix4fv(this.addr,!1,qG),na(n,r)}}function ZUe(t,e){const n=this.cache;n[0]!==e&&(t.uniform1i(this.addr,e),n[0]=e)}function JUe(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 eze(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 tze(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 nze(t,e){const n=this.cache;n[0]!==e&&(t.uniform1ui(this.addr,e),n[0]=e)}function rze(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 ize(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 aze(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 sze(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i);const a=this.type===t.SAMPLER_2D_SHADOW?hee:dee;n.setTexture2D(e||a,i)}function oze(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture3D(e||mee,i)}function lze(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTextureCube(e||pee,i)}function cze(t,e,n){const r=this.cache,i=n.allocateTextureUnit();r[0]!==i&&(t.uniform1i(this.addr,i),r[0]=i),n.setTexture2DArray(e||fee,i)}function uze(t){switch(t){case 5126:return GUe;case 35664:return qUe;case 35665:return WUe;case 35666:return KUe;case 35674:return XUe;case 35675:return YUe;case 35676:return QUe;case 5124:case 35670:return ZUe;case 35667:case 35671:return JUe;case 35668:case 35672:return eze;case 35669:case 35673:return tze;case 5125:return nze;case 36294:return rze;case 36295:return ize;case 36296:return aze;case 35678:case 36198:case 36298:case 36306:case 35682:return sze;case 35679:case 36299:case 36307:return oze;case 35680:case 36300:case 36308:case 36293:return lze;case 36289:case 36303:case 36311:case 36292:return cze}}function dze(t,e){t.uniform1fv(this.addr,e)}function hze(t,e){const n=Rx(e,this.size,2);t.uniform2fv(this.addr,n)}function fze(t,e){const n=Rx(e,this.size,3);t.uniform3fv(this.addr,n)}function mze(t,e){const n=Rx(e,this.size,4);t.uniform4fv(this.addr,n)}function pze(t,e){const n=Rx(e,this.size,4);t.uniformMatrix2fv(this.addr,!1,n)}function gze(t,e){const n=Rx(e,this.size,9);t.uniformMatrix3fv(this.addr,!1,n)}function xze(t,e){const n=Rx(e,this.size,16);t.uniformMatrix4fv(this.addr,!1,n)}function bze(t,e){t.uniform1iv(this.addr,e)}function yze(t,e){t.uniform2iv(this.addr,e)}function vze(t,e){t.uniform3iv(this.addr,e)}function wze(t,e){t.uniform4iv(this.addr,e)}function _ze(t,e){t.uniform1uiv(this.addr,e)}function Sze(t,e){t.uniform2uiv(this.addr,e)}function Nze(t,e){t.uniform3uiv(this.addr,e)}function Mze(t,e){t.uniform4uiv(this.addr,e)}function kze(t,e,n){const r=this.cache,i=e.length,a=w2(n,i);ta(r,a)||(t.uniform1iv(this.addr,a),na(r,a));for(let o=0;o!==i;++o)n.setTexture2D(e[o]||dee,a[o])}function Eze(t,e,n){const r=this.cache,i=e.length,a=w2(n,i);ta(r,a)||(t.uniform1iv(this.addr,a),na(r,a));for(let o=0;o!==i;++o)n.setTexture3D(e[o]||mee,a[o])}function Tze(t,e,n){const r=this.cache,i=e.length,a=w2(n,i);ta(r,a)||(t.uniform1iv(this.addr,a),na(r,a));for(let o=0;o!==i;++o)n.setTextureCube(e[o]||pee,a[o])}function Aze(t,e,n){const r=this.cache,i=e.length,a=w2(n,i);ta(r,a)||(t.uniform1iv(this.addr,a),na(r,a));for(let o=0;o!==i;++o)n.setTexture2DArray(e[o]||fee,a[o])}function Cze(t){switch(t){case 5126:return dze;case 35664:return hze;case 35665:return fze;case 35666:return mze;case 35674:return pze;case 35675:return gze;case 35676:return xze;case 5124:case 35670:return bze;case 35667:case 35671:return yze;case 35668:case 35672:return vze;case 35669:case 35673:return wze;case 5125:return _ze;case 36294:return Sze;case 36295:return Nze;case 36296:return Mze;case 35678:case 36198:case 36298:case 36306:case 35682:return kze;case 35679:case 36299:case 36307:return Eze;case 35680:case 36300:case 36308:case 36293:return Tze;case 36289:case 36303:case 36311:case 36292:return Aze}}class Pze{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.setValue=uze(n.type)}}class jze{constructor(e,n,r){this.id=e,this.addr=r,this.cache=[],this.type=n.type,this.size=n.size,this.setValue=Cze(n.type)}}class Dze{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,r){const i=this.seq;for(let a=0,o=i.length;a!==o;++a){const l=i[a];l.setValue(e,n[l.id],r)}}}const QC=/(\w+)(\])?(\[|\.)?/g;function XG(t,e){t.seq.push(e),t.map[e.id]=e}function Rze(t,e,n){const r=t.name,i=r.length;for(QC.lastIndex=0;;){const a=QC.exec(r),o=QC.lastIndex;let l=a[1];const c=a[2]==="]",u=a[3];if(c&&(l=l|0),u===void 0||u==="["&&o+2===i){XG(n,u===void 0?new Pze(l,t,e):new jze(l,t,e));break}else{let f=n.map[l];f===void 0&&(f=new Dze(l),XG(n,f)),n=f}}}class D1{constructor(e,n){this.seq=[],this.map={};const r=e.getProgramParameter(n,e.ACTIVE_UNIFORMS);for(let i=0;i<r;++i){const a=e.getActiveUniform(n,i),o=e.getUniformLocation(n,a.name);Rze(a,o,this)}}setValue(e,n,r,i){const a=this.map[n];a!==void 0&&a.setValue(e,r,i)}setOptional(e,n,r){const i=n[r];i!==void 0&&this.setValue(e,r,i)}static upload(e,n,r,i){for(let a=0,o=n.length;a!==o;++a){const l=n[a],c=r[l.id];c.needsUpdate!==!1&&l.setValue(e,c.value,i)}}static seqWithValue(e,n){const r=[];for(let i=0,a=e.length;i!==a;++i){const o=e[i];o.id in n&&r.push(o)}return r}}function YG(t,e,n){const r=t.createShader(e);return t.shaderSource(r,n),t.compileShader(r),r}const Oze=37297;let Lze=0;function Fze(t,e){const n=t.split(`
- `),r=[],i=Math.max(e-6,0),a=Math.min(e+6,n.length);for(let o=i;o<a;o++){const l=o+1;r.push(`${l===e?">":" "} ${l}: ${n[o]}`)}return r.join(`
- `)}function Ize(t){const e=Er.getPrimaries(Er.workingColorSpace),n=Er.getPrimaries(t);let r;switch(e===n?r="":e===nN&&n===tN?r="LinearDisplayP3ToLinearSRGB":e===tN&&n===nN&&(r="LinearSRGBToLinearDisplayP3"),t){case Vu:case y2:return[r,"LinearTransferOETF"];case La:case aL:return[r,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space:",t),[r,"LinearTransferOETF"]}}function QG(t,e,n){const r=t.getShaderParameter(e,t.COMPILE_STATUS),i=t.getShaderInfoLog(e).trim();if(r&&i==="")return"";const a=/ERROR: 0:(\d+)/.exec(i);if(a){const o=parseInt(a[1]);return n.toUpperCase()+`
- `+i+`
- `+Fze(t.getShaderSource(e),o)}else return i}function Uze(t,e){const n=Ize(e);return`vec4 ${t}( vec4 value ) { return ${n[0]}( ${n[1]}( value ) ); }`}function zze(t,e){let n;switch(e){case ULe:n="Linear";break;case zLe:n="Reinhard";break;case BLe:n="OptimizedCineon";break;case HLe:n="ACESFilmic";break;case $Le:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+t+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function Bze(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(c0).join(`
- `)}function Hze(t){const e=[];for(const n in t){const r=t[n];r!==!1&&e.push("#define "+n+" "+r)}return e.join(`
- `)}function $ze(t,e){const n={},r=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let i=0;i<r;i++){const a=t.getActiveAttrib(e,i),o=a.name;let l=1;a.type===t.FLOAT_MAT2&&(l=2),a.type===t.FLOAT_MAT3&&(l=3),a.type===t.FLOAT_MAT4&&(l=4),n[o]={type:a.type,location:t.getAttribLocation(e,o),locationSize:l}}return n}function c0(t){return t!==""}function ZG(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 JG(t,e){return t.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const Vze=/^[ \t]*#include +<([\w\d./]+)>/gm;function _D(t){return t.replace(Vze,qze)}const Gze=new Map([["encodings_fragment","colorspace_fragment"],["encodings_pars_fragment","colorspace_pars_fragment"],["output_fragment","opaque_fragment"]]);function qze(t,e){let n=An[e];if(n===void 0){const r=Gze.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 _D(n)}const Wze=/#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 e7(t){return t.replace(Wze,Kze)}function Kze(t,e,n,r){let i="";for(let a=parseInt(e);a<parseInt(n);a++)i+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return i}function t7(t){let e="precision "+t.precision+` float;
- precision `+t.precision+" int;";return t.precision==="highp"?e+=`
- #define HIGH_PRECISION`:t.precision==="mediump"?e+=`
- #define MEDIUM_PRECISION`:t.precision==="lowp"&&(e+=`
- #define LOW_PRECISION`),e}function Xze(t){let e="SHADOWMAP_TYPE_BASIC";return t.shadowMapType===IJ?e="SHADOWMAP_TYPE_PCF":t.shadowMapType===fLe?e="SHADOWMAP_TYPE_PCF_SOFT":t.shadowMapType===cu&&(e="SHADOWMAP_TYPE_VSM"),e}function Yze(t){let e="ENVMAP_TYPE_CUBE";if(t.envMap)switch(t.envMapMode){case nx:case rx:e="ENVMAP_TYPE_CUBE";break;case b2:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Qze(t){let e="ENVMAP_MODE_REFLECTION";if(t.envMap)switch(t.envMapMode){case rx:e="ENVMAP_MODE_REFRACTION";break}return e}function Zze(t){let e="ENVMAP_BLENDING_NONE";if(t.envMap)switch(t.combine){case rL:e="ENVMAP_BLENDING_MULTIPLY";break;case FLe:e="ENVMAP_BLENDING_MIX";break;case ILe:e="ENVMAP_BLENDING_ADD";break}return e}function Jze(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 eBe(t,e,n,r){const i=t.getContext(),a=n.defines;let o=n.vertexShader,l=n.fragmentShader;const c=Xze(n),u=Yze(n),d=Qze(n),f=Zze(n),p=Jze(n),m=n.isWebGL2?"":Bze(n),x=Hze(a),b=i.createProgram();let v,y,S=n.glslVersion?"#version "+n.glslVersion+`
- `:"";n.isRawShaderMaterial?(v=["#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(c0).join(`
- `),v.length>0&&(v+=`
- `),y=[m,"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x].filter(c0).join(`
- `),y.length>0&&(y+=`
- `)):(v=[t7(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.batching?"#define USE_BATCHING":"",n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",n.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",n.displacementMap?"#define USE_DISPLACEMENTMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.anisotropy?"#define USE_ANISOTROPY":"",n.anisotropyMap?"#define USE_ANISOTROPYMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",n.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaHash?"#define USE_ALPHAHASH":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",n.mapUv?"#define MAP_UV "+n.mapUv:"",n.alphaMapUv?"#define ALPHAMAP_UV "+n.alphaMapUv:"",n.lightMapUv?"#define LIGHTMAP_UV "+n.lightMapUv:"",n.aoMapUv?"#define AOMAP_UV "+n.aoMapUv:"",n.emissiveMapUv?"#define EMISSIVEMAP_UV "+n.emissiveMapUv:"",n.bumpMapUv?"#define BUMPMAP_UV "+n.bumpMapUv:"",n.normalMapUv?"#define NORMALMAP_UV "+n.normalMapUv:"",n.displacementMapUv?"#define DISPLACEMENTMAP_UV "+n.displacementMapUv:"",n.metalnessMapUv?"#define METALNESSMAP_UV "+n.metalnessMapUv:"",n.roughnessMapUv?"#define ROUGHNESSMAP_UV "+n.roughnessMapUv:"",n.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+n.anisotropyMapUv:"",n.clearcoatMapUv?"#define CLEARCOATMAP_UV "+n.clearcoatMapUv:"",n.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+n.clearcoatNormalMapUv:"",n.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+n.clearcoatRoughnessMapUv:"",n.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+n.iridescenceMapUv:"",n.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+n.iridescenceThicknessMapUv:"",n.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+n.sheenColorMapUv:"",n.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+n.sheenRoughnessMapUv:"",n.specularMapUv?"#define SPECULARMAP_UV "+n.specularMapUv:"",n.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+n.specularColorMapUv:"",n.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+n.specularIntensityMapUv:"",n.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+n.transmissionMapUv:"",n.thicknessMapUv?"#define THICKNESSMAP_UV "+n.thicknessMapUv:"",n.vertexTangents&&n.flatShading===!1?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUv1s?"#define USE_UV1":"",n.vertexUv2s?"#define USE_UV2":"",n.vertexUv3s?"#define USE_UV3":"",n.pointsUvs?"#define USE_POINTS_UV":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+c:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.numLightProbes>0?"#define USE_LIGHT_PROBES":"",n.useLegacyLights?"#define LEGACY_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
- `].filter(c0).join(`
- `),y=[m,t7(n),"#define SHADER_TYPE "+n.shaderType,"#define SHADER_NAME "+n.shaderName,x,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+u:"",n.envMap?"#define "+d:"",n.envMap?"#define "+f:"",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!==uh?"#define TONE_MAPPING":"",n.toneMapping!==uh?An.tonemapping_pars_fragment:"",n.toneMapping!==uh?zze("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",An.colorspace_pars_fragment,Uze("linearToOutputTexel",n.outputColorSpace),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
- `].filter(c0).join(`
- `)),o=_D(o),o=ZG(o,n),o=JG(o,n),l=_D(l),l=ZG(l,n),l=JG(l,n),o=e7(o),l=e7(l),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(S=`#version 300 es
- `,v=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
- `)+`
- `+v,y=["precision mediump sampler2DArray;","#define varying in",n.glslVersion===yG?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===yG?"":"#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(`
- `)+`
- `+y);const k=S+v+o,T=S+y+l,M=YG(i,i.VERTEX_SHADER,k),C=YG(i,i.FRAGMENT_SHADER,T);i.attachShader(b,M),i.attachShader(b,C),n.index0AttributeName!==void 0?i.bindAttribLocation(b,0,n.index0AttributeName):n.morphTargets===!0&&i.bindAttribLocation(b,0,"position"),i.linkProgram(b);function E(I){if(t.debug.checkShaderErrors){const F=i.getProgramInfoLog(b).trim(),z=i.getShaderInfoLog(M).trim(),P=i.getShaderInfoLog(C).trim();let $=!0,X=!0;if(i.getProgramParameter(b,i.LINK_STATUS)===!1)if($=!1,typeof t.debug.onShaderError=="function")t.debug.onShaderError(i,b,M,C);else{const V=QG(i,M,"vertex"),Q=QG(i,C,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(b,i.VALIDATE_STATUS)+`
- Program Info Log: `+F+`
- `+V+`
- `+Q)}else F!==""?console.warn("THREE.WebGLProgram: Program Info Log:",F):(z===""||P==="")&&(X=!1);X&&(I.diagnostics={runnable:$,programLog:F,vertexShader:{log:z,prefix:v},fragmentShader:{log:P,prefix:y}})}i.deleteShader(M),i.deleteShader(C),R=new D1(i,b),A=$ze(i,b)}let R;this.getUniforms=function(){return R===void 0&&E(this),R};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(b,Oze)),D},this.destroy=function(){r.releaseStatesOfProgram(this),i.deleteProgram(b),this.program=void 0},this.type=n.shaderType,this.name=n.shaderName,this.id=Lze++,this.cacheKey=e,this.usedTimes=1,this.program=b,this.vertexShader=M,this.fragmentShader=C,this}let tBe=0;class nBe{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,r=e.fragmentShader,i=this._getShaderStage(n),a=this._getShaderStage(r),o=this._getShaderCacheForMaterial(e);return o.has(i)===!1&&(o.add(i),i.usedTimes++),o.has(a)===!1&&(o.add(a),a.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const r of n)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;let r=n.get(e);return r===void 0&&(r=new Set,n.set(e,r)),r}_getShaderStage(e){const n=this.shaderCache;let r=n.get(e);return r===void 0&&(r=new rBe(e),n.set(e,r)),r}}class rBe{constructor(e){this.id=tBe++,this.code=e,this.usedTimes=0}}function iBe(t,e,n,r,i,a,o){const l=new tee,c=new nBe,u=[],d=i.isWebGL2,f=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 b(A){return A===0?"uv":`uv${A}`}function v(A,D,I,F,z){const P=F.fog,$=z.geometry,X=A.isMeshStandardMaterial?F.environment:null,V=(A.isMeshStandardMaterial?n:e).get(A.envMap||X),Q=V&&V.mapping===b2?V.image.height:null,Z=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 se=$.morphAttributes.position||$.morphAttributes.normal||$.morphAttributes.color,H=se!==void 0?se.length:0;let K=0;$.morphAttributes.position!==void 0&&(K=1),$.morphAttributes.normal!==void 0&&(K=2),$.morphAttributes.color!==void 0&&(K=3);let re,ne,be,me;if(Z){const Bt=Rs[Z];re=Bt.vertexShader,ne=Bt.fragmentShader}else re=A.vertexShader,ne=A.fragmentShader,c.update(A),be=c.getVertexShaderID(A),me=c.getFragmentShaderID(A);const de=t.getRenderTarget(),Ce=z.isInstancedMesh===!0,ie=z.isBatchedMesh===!0,ke=!!A.map,Oe=!!A.matcap,pe=!!V,We=!!A.aoMap,G=!!A.lightMap,Y=!!A.bumpMap,ue=!!A.normalMap,q=!!A.displacementMap,te=!!A.emissiveMap,U=!!A.metalnessMap,he=!!A.roughnessMap,Me=A.anisotropy>0,ge=A.clearcoat>0,B=A.iridescence>0,O=A.sheen>0,ee=A.transmission>0,le=Me&&!!A.anisotropyMap,_e=ge&&!!A.clearcoatMap,ve=ge&&!!A.clearcoatNormalMap,ae=ge&&!!A.clearcoatRoughnessMap,Fe=B&&!!A.iridescenceMap,Be=B&&!!A.iridescenceThicknessMap,$e=O&&!!A.sheenColorMap,He=O&&!!A.sheenRoughnessMap,xe=!!A.specularMap,Pe=!!A.specularColorMap,ze=!!A.specularIntensityMap,we=ee&&!!A.transmissionMap,Xe=ee&&!!A.thicknessMap,Ne=!!A.gradientMap,rt=!!A.alphaMap,Ee=A.alphaTest>0,Ke=!!A.alphaHash,Ue=!!A.extensions,W=!!$.attributes.uv1,je=!!$.attributes.uv2,Ye=!!$.attributes.uv3;let bt=uh;return A.toneMapped&&(de===null||de.isXRRenderTarget===!0)&&(bt=t.toneMapping),{isWebGL2:d,shaderID:Z,shaderType:A.type,shaderName:A.name,vertexShader:re,fragmentShader:ne,defines:A.defines,customVertexShaderID:be,customFragmentShaderID:me,isRawShaderMaterial:A.isRawShaderMaterial===!0,glslVersion:A.glslVersion,precision:m,batching:ie,instancing:Ce,instancingColor:Ce&&z.instanceColor!==null,supportsVertexTextures:p,outputColorSpace:de===null?t.outputColorSpace:de.isXRRenderTarget===!0?de.texture.colorSpace:Vu,map:ke,matcap:Oe,envMap:pe,envMapMode:pe&&V.mapping,envMapCubeUVHeight:Q,aoMap:We,lightMap:G,bumpMap:Y,normalMap:ue,displacementMap:p&&q,emissiveMap:te,normalMapObjectSpace:ue&&A.normalMapType===tFe,normalMapTangentSpace:ue&&A.normalMapType===KJ,metalnessMap:U,roughnessMap:he,anisotropy:Me,anisotropyMap:le,clearcoat:ge,clearcoatMap:_e,clearcoatNormalMap:ve,clearcoatRoughnessMap:ae,iridescence:B,iridescenceMap:Fe,iridescenceThicknessMap:Be,sheen:O,sheenColorMap:$e,sheenRoughnessMap:He,specularMap:xe,specularColorMap:Pe,specularIntensityMap:ze,transmission:ee,transmissionMap:we,thicknessMap:Xe,gradientMap:Ne,opaque:A.transparent===!1&&A.blending===Pg,alphaMap:rt,alphaTest:Ee,alphaHash:Ke,combine:A.combine,mapUv:ke&&b(A.map.channel),aoMapUv:We&&b(A.aoMap.channel),lightMapUv:G&&b(A.lightMap.channel),bumpMapUv:Y&&b(A.bumpMap.channel),normalMapUv:ue&&b(A.normalMap.channel),displacementMapUv:q&&b(A.displacementMap.channel),emissiveMapUv:te&&b(A.emissiveMap.channel),metalnessMapUv:U&&b(A.metalnessMap.channel),roughnessMapUv:he&&b(A.roughnessMap.channel),anisotropyMapUv:le&&b(A.anisotropyMap.channel),clearcoatMapUv:_e&&b(A.clearcoatMap.channel),clearcoatNormalMapUv:ve&&b(A.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ae&&b(A.clearcoatRoughnessMap.channel),iridescenceMapUv:Fe&&b(A.iridescenceMap.channel),iridescenceThicknessMapUv:Be&&b(A.iridescenceThicknessMap.channel),sheenColorMapUv:$e&&b(A.sheenColorMap.channel),sheenRoughnessMapUv:He&&b(A.sheenRoughnessMap.channel),specularMapUv:xe&&b(A.specularMap.channel),specularColorMapUv:Pe&&b(A.specularColorMap.channel),specularIntensityMapUv:ze&&b(A.specularIntensityMap.channel),transmissionMapUv:we&&b(A.transmissionMap.channel),thicknessMapUv:Xe&&b(A.thicknessMap.channel),alphaMapUv:rt&&b(A.alphaMap.channel),vertexTangents:!!$.attributes.tangent&&(ue||Me),vertexColors:A.vertexColors,vertexAlphas:A.vertexColors===!0&&!!$.attributes.color&&$.attributes.color.itemSize===4,vertexUv1s:W,vertexUv2s:je,vertexUv3s:Ye,pointsUvs:z.isPoints===!0&&!!$.attributes.uv&&(ke||rt),fog:!!P,useFog:A.fog===!0,fogExp2:P&&P.isFogExp2,flatShading:A.flatShading===!0,sizeAttenuation:A.sizeAttenuation===!0,logarithmicDepthBuffer:f,skinning:z.isSkinnedMesh===!0,morphTargets:$.morphAttributes.position!==void 0,morphNormals:$.morphAttributes.normal!==void 0,morphColors:$.morphAttributes.color!==void 0,morphTargetsCount:H,morphTextureStride:K,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:bt,useLegacyLights:t._useLegacyLights,decodeVideoTexture:ke&&A.map.isVideoTexture===!0&&Er.getTransfer(A.map.colorSpace)===Gr,premultipliedAlpha:A.premultipliedAlpha,doubleSided:A.side===gu,flipSided:A.side===Us,useDepthPacking:A.depthPacking>=0,depthPacking:A.depthPacking||0,index0AttributeName:A.index0AttributeName,extensionDerivatives:Ue&&A.extensions.derivatives===!0,extensionFragDepth:Ue&&A.extensions.fragDepth===!0,extensionDrawBuffers:Ue&&A.extensions.drawBuffers===!0,extensionShaderTextureLOD:Ue&&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 y(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),k(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 k(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 F=Rs[D];I=lL.clone(F.uniforms)}else I=A.uniforms;return I}function M(A,D){let I;for(let F=0,z=u.length;F<z;F++){const P=u[F];if(P.cacheKey===D){I=P,++I.usedTimes;break}}return I===void 0&&(I=new eBe(t,D,A,a),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 R(){c.dispose()}return{getParameters:v,getProgramCacheKey:y,getUniforms:T,acquireProgram:M,releaseProgram:C,releaseShaderCache:E,programs:u,dispose:R}}function aBe(){let t=new WeakMap;function e(a){let o=t.get(a);return o===void 0&&(o={},t.set(a,o)),o}function n(a){t.delete(a)}function r(a,o,l){t.get(a)[o]=l}function i(){t=new WeakMap}return{get:e,remove:n,update:r,dispose:i}}function sBe(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 n7(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 r7(){const t=[];let e=0;const n=[],r=[],i=[];function a(){e=0,n.length=0,r.length=0,i.length=0}function o(f,p,m,x,b,v){let y=t[e];return y===void 0?(y={id:f.id,object:f,geometry:p,material:m,groupOrder:x,renderOrder:f.renderOrder,z:b,group:v},t[e]=y):(y.id=f.id,y.object=f,y.geometry=p,y.material=m,y.groupOrder=x,y.renderOrder=f.renderOrder,y.z=b,y.group=v),e++,y}function l(f,p,m,x,b,v){const y=o(f,p,m,x,b,v);m.transmission>0?r.push(y):m.transparent===!0?i.push(y):n.push(y)}function c(f,p,m,x,b,v){const y=o(f,p,m,x,b,v);m.transmission>0?r.unshift(y):m.transparent===!0?i.unshift(y):n.unshift(y)}function u(f,p){n.length>1&&n.sort(f||sBe),r.length>1&&r.sort(p||n7),i.length>1&&i.sort(p||n7)}function d(){for(let f=e,p=t.length;f<p;f++){const m=t[f];if(m.id===null)break;m.id=null,m.object=null,m.geometry=null,m.material=null,m.group=null}}return{opaque:n,transmissive:r,transparent:i,init:a,push:l,unshift:c,finish:d,sort:u}}function oBe(){let t=new WeakMap;function e(r,i){const a=t.get(r);let o;return a===void 0?(o=new r7,t.set(r,[o])):i>=a.length?(o=new r7,a.push(o)):o=a[i],o}function n(){t=new WeakMap}return{get:e,dispose:n}}function lBe(){const t={};return{get:function(e){if(t[e.id]!==void 0)return t[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new qe,color:new Zt};break;case"SpotLight":n={position:new qe,direction:new qe,color:new Zt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new qe,color:new Zt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new qe,skyColor:new Zt,groundColor:new Zt};break;case"RectAreaLight":n={color:new Zt,position:new qe,halfWidth:new qe,halfHeight:new qe};break}return t[e.id]=n,n}}}function cBe(){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 uBe=0;function dBe(t,e){return(e.castShadow?2:0)-(t.castShadow?2:0)+(e.map?1:0)-(t.map?1:0)}function hBe(t,e){const n=new lBe,r=cBe(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let d=0;d<9;d++)i.probe.push(new qe);const a=new qe,o=new zr,l=new zr;function c(d,f){let p=0,m=0,x=0;for(let F=0;F<9;F++)i.probe[F].set(0,0,0);let b=0,v=0,y=0,S=0,k=0,T=0,M=0,C=0,E=0,R=0,A=0;d.sort(dBe);const D=f===!0?Math.PI:1;for(let F=0,z=d.length;F<z;F++){const P=d[F],$=P.color,X=P.intensity,V=P.distance,Q=P.shadow&&P.shadow.map?P.shadow.map.texture:null;if(P.isAmbientLight)p+=$.r*X*D,m+=$.g*X*D,x+=$.b*X*D;else if(P.isLightProbe){for(let Z=0;Z<9;Z++)i.probe[Z].addScaledVector(P.sh.coefficients[Z],X);A++}else if(P.isDirectionalLight){const Z=n.get(P);if(Z.color.copy(P.color).multiplyScalar(P.intensity*D),P.castShadow){const se=P.shadow,H=r.get(P);H.shadowBias=se.bias,H.shadowNormalBias=se.normalBias,H.shadowRadius=se.radius,H.shadowMapSize=se.mapSize,i.directionalShadow[b]=H,i.directionalShadowMap[b]=Q,i.directionalShadowMatrix[b]=P.shadow.matrix,T++}i.directional[b]=Z,b++}else if(P.isSpotLight){const Z=n.get(P);Z.position.setFromMatrixPosition(P.matrixWorld),Z.color.copy($).multiplyScalar(X*D),Z.distance=V,Z.coneCos=Math.cos(P.angle),Z.penumbraCos=Math.cos(P.angle*(1-P.penumbra)),Z.decay=P.decay,i.spot[y]=Z;const se=P.shadow;if(P.map&&(i.spotLightMap[E]=P.map,E++,se.updateMatrices(P),P.castShadow&&R++),i.spotLightMatrix[y]=se.matrix,P.castShadow){const H=r.get(P);H.shadowBias=se.bias,H.shadowNormalBias=se.normalBias,H.shadowRadius=se.radius,H.shadowMapSize=se.mapSize,i.spotShadow[y]=H,i.spotShadowMap[y]=Q,C++}y++}else if(P.isRectAreaLight){const Z=n.get(P);Z.color.copy($).multiplyScalar(X),Z.halfWidth.set(P.width*.5,0,0),Z.halfHeight.set(0,P.height*.5,0),i.rectArea[S]=Z,S++}else if(P.isPointLight){const Z=n.get(P);if(Z.color.copy(P.color).multiplyScalar(P.intensity*D),Z.distance=P.distance,Z.decay=P.decay,P.castShadow){const se=P.shadow,H=r.get(P);H.shadowBias=se.bias,H.shadowNormalBias=se.normalBias,H.shadowRadius=se.radius,H.shadowMapSize=se.mapSize,H.shadowCameraNear=se.camera.near,H.shadowCameraFar=se.camera.far,i.pointShadow[v]=H,i.pointShadowMap[v]=Q,i.pointShadowMatrix[v]=P.shadow.matrix,M++}i.point[v]=Z,v++}else if(P.isHemisphereLight){const Z=n.get(P);Z.skyColor.copy(P.color).multiplyScalar(X*D),Z.groundColor.copy(P.groundColor).multiplyScalar(X*D),i.hemi[k]=Z,k++}}S>0&&(e.isWebGL2||t.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Dt.LTC_FLOAT_1,i.rectAreaLTC2=Dt.LTC_FLOAT_2):t.has("OES_texture_half_float_linear")===!0?(i.rectAreaLTC1=Dt.LTC_HALF_1,i.rectAreaLTC2=Dt.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!==b||I.pointLength!==v||I.spotLength!==y||I.rectAreaLength!==S||I.hemiLength!==k||I.numDirectionalShadows!==T||I.numPointShadows!==M||I.numSpotShadows!==C||I.numSpotMaps!==E||I.numLightProbes!==A)&&(i.directional.length=b,i.spot.length=y,i.rectArea.length=S,i.point.length=v,i.hemi.length=k,i.directionalShadow.length=T,i.directionalShadowMap.length=T,i.pointShadow.length=M,i.pointShadowMap.length=M,i.spotShadow.length=C,i.spotShadowMap.length=C,i.directionalShadowMatrix.length=T,i.pointShadowMatrix.length=M,i.spotLightMatrix.length=C+E-R,i.spotLightMap.length=E,i.numSpotLightShadowsWithMaps=R,i.numLightProbes=A,I.directionalLength=b,I.pointLength=v,I.spotLength=y,I.rectAreaLength=S,I.hemiLength=k,I.numDirectionalShadows=T,I.numPointShadows=M,I.numSpotShadows=C,I.numSpotMaps=E,I.numLightProbes=A,i.version=uBe++)}function u(d,f){let p=0,m=0,x=0,b=0,v=0;const y=f.matrixWorldInverse;for(let S=0,k=d.length;S<k;S++){const T=d[S];if(T.isDirectionalLight){const M=i.directional[p];M.direction.setFromMatrixPosition(T.matrixWorld),a.setFromMatrixPosition(T.target.matrixWorld),M.direction.sub(a),M.direction.transformDirection(y),p++}else if(T.isSpotLight){const M=i.spot[x];M.position.setFromMatrixPosition(T.matrixWorld),M.position.applyMatrix4(y),M.direction.setFromMatrixPosition(T.matrixWorld),a.setFromMatrixPosition(T.target.matrixWorld),M.direction.sub(a),M.direction.transformDirection(y),x++}else if(T.isRectAreaLight){const M=i.rectArea[b];M.position.setFromMatrixPosition(T.matrixWorld),M.position.applyMatrix4(y),l.identity(),o.copy(T.matrixWorld),o.premultiply(y),l.extractRotation(o),M.halfWidth.set(T.width*.5,0,0),M.halfHeight.set(0,T.height*.5,0),M.halfWidth.applyMatrix4(l),M.halfHeight.applyMatrix4(l),b++}else if(T.isPointLight){const M=i.point[m];M.position.setFromMatrixPosition(T.matrixWorld),M.position.applyMatrix4(y),m++}else if(T.isHemisphereLight){const M=i.hemi[v];M.direction.setFromMatrixPosition(T.matrixWorld),M.direction.transformDirection(y),v++}}}return{setup:c,setupView:u,state:i}}function i7(t,e){const n=new hBe(t,e),r=[],i=[];function a(){r.length=0,i.length=0}function o(f){r.push(f)}function l(f){i.push(f)}function c(f){n.setup(r,f)}function u(f){n.setupView(r,f)}return{init:a,state:{lightsArray:r,shadowsArray:i,lights:n},setupLights:c,setupLightsView:u,pushLight:o,pushShadow:l}}function fBe(t,e){let n=new WeakMap;function r(a,o=0){const l=n.get(a);let c;return l===void 0?(c=new i7(t,e),n.set(a,[c])):o>=l.length?(c=new i7(t,e),l.push(c)):c=l[o],c}function i(){n=new WeakMap}return{get:r,dispose:i}}class mBe extends Dx{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=JLe,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 pBe extends Dx{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 gBe=`void main() {
- gl_Position = vec4( position, 1.0 );
- }`,xBe=`uniform sampler2D shadow_pass;
- uniform vec2 resolution;
- uniform float radius;
- #include <packing>
- void main() {
- const float samples = float( VSM_SAMPLES );
- float mean = 0.0;
- float squared_mean = 0.0;
- float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
- float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
- for ( float i = 0.0; i < samples; i ++ ) {
- float uvOffset = uvStart + i * uvStride;
- #ifdef HORIZONTAL_PASS
- vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
- mean += distribution.x;
- squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
- #else
- float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
- mean += depth;
- squared_mean += depth * depth;
- #endif
- }
- mean = mean / samples;
- squared_mean = squared_mean / samples;
- float std_dev = sqrt( squared_mean - mean * mean );
- gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
- }`;function bBe(t,e,n){let r=new v2;const i=new bn,a=new bn,o=new Cr,l=new mBe({depthPacking:eFe}),c=new pBe,u={},d=n.maxTextureSize,f={[Th]:Us,[Us]:Th,[gu]:gu},p=new Ah({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new bn},radius:{value:4}},vertexShader:gBe,fragmentShader:xBe}),m=p.clone();m.defines.HORIZONTAL_PASS=1;const x=new ns;x.setAttribute("position",new po(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const b=new Dl(x,p),v=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=IJ;let y=this.type;this.render=function(M,C,E){if(v.enabled===!1||v.autoUpdate===!1&&v.needsUpdate===!1||M.length===0)return;const R=t.getRenderTarget(),A=t.getActiveCubeFace(),D=t.getActiveMipmapLevel(),I=t.state;I.setBlending(ch),I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const F=y!==cu&&this.type===cu,z=y===cu&&this.type!==cu;for(let P=0,$=M.length;P<$;P++){const X=M[P],V=X.shadow;if(V===void 0){console.warn("THREE.WebGLShadowMap:",X,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;i.copy(V.mapSize);const Q=V.getFrameExtents();if(i.multiply(Q),a.copy(V.mapSize),(i.x>d||i.y>d)&&(i.x>d&&(a.x=Math.floor(d/Q.x),i.x=a.x*Q.x,V.mapSize.x=a.x),i.y>d&&(a.y=Math.floor(d/Q.y),i.y=a.y*Q.y,V.mapSize.y=a.y)),V.map===null||F===!0||z===!0){const se=this.type!==cu?{minFilter:Oa,magFilter:Oa}:{};V.map!==null&&V.map.dispose(),V.map=new ym(i.x,i.y,se),V.map.texture.name=X.name+".shadowMap",V.camera.updateProjectionMatrix()}t.setRenderTarget(V.map),t.clear();const Z=V.getViewportCount();for(let se=0;se<Z;se++){const H=V.getViewport(se);o.set(a.x*H.x,a.y*H.y,a.x*H.z,a.y*H.w),I.viewport(o),V.updateMatrices(X,se),r=V.getFrustum(),T(C,E,V.camera,X,this.type)}V.isPointLightShadow!==!0&&this.type===cu&&S(V,E),V.needsUpdate=!1}y=this.type,v.needsUpdate=!1,t.setRenderTarget(R,A,D)};function S(M,C){const E=e.update(b);p.defines.VSM_SAMPLES!==M.blurSamples&&(p.defines.VSM_SAMPLES=M.blurSamples,m.defines.VSM_SAMPLES=M.blurSamples,p.needsUpdate=!0,m.needsUpdate=!0),M.mapPass===null&&(M.mapPass=new ym(i.x,i.y)),p.uniforms.shadow_pass.value=M.map.texture,p.uniforms.resolution.value=M.mapSize,p.uniforms.radius.value=M.radius,t.setRenderTarget(M.mapPass),t.clear(),t.renderBufferDirect(C,null,E,p,b,null),m.uniforms.shadow_pass.value=M.mapPass.texture,m.uniforms.resolution.value=M.mapSize,m.uniforms.radius.value=M.radius,t.setRenderTarget(M.map),t.clear(),t.renderBufferDirect(C,null,E,m,b,null)}function k(M,C,E,R){let A=null;const D=E.isPointLight===!0?M.customDistanceMaterial:M.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,F=C.uuid;let z=u[I];z===void 0&&(z={},u[I]=z);let P=z[F];P===void 0&&(P=A.clone(),z[F]=P),A=P}if(A.visible=C.visible,A.wireframe=C.wireframe,R===cu?A.side=C.shadowSide!==null?C.shadowSide:C.side:A.side=C.shadowSide!==null?C.shadowSide:f[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(M,C,E,R,A){if(M.visible===!1)return;if(M.layers.test(C.layers)&&(M.isMesh||M.isLine||M.isPoints)&&(M.castShadow||M.receiveShadow&&A===cu)&&(!M.frustumCulled||r.intersectsObject(M))){M.modelViewMatrix.multiplyMatrices(E.matrixWorldInverse,M.matrixWorld);const F=e.update(M),z=M.material;if(Array.isArray(z)){const P=F.groups;for(let $=0,X=P.length;$<X;$++){const V=P[$],Q=z[V.materialIndex];if(Q&&Q.visible){const Z=k(M,Q,R,A);M.onBeforeShadow(t,M,C,E,F,Z,V),t.renderBufferDirect(E,null,F,Z,M,V),M.onAfterShadow(t,M,C,E,F,Z,V)}}}else if(z.visible){const P=k(M,z,R,A);M.onBeforeShadow(t,M,C,E,F,P,null),t.renderBufferDirect(E,null,F,P,M,null),M.onAfterShadow(t,M,C,E,F,P,null)}}const I=M.children;for(let F=0,z=I.length;F<z;F++)T(I[F],C,E,R,A)}}function yBe(t,e,n){const r=n.isWebGL2;function i(){let Ee=!1;const Ke=new Cr;let Ue=null;const W=new Cr(0,0,0,0);return{setMask:function(je){Ue!==je&&!Ee&&(t.colorMask(je,je,je,je),Ue=je)},setLocked:function(je){Ee=je},setClear:function(je,Ye,bt,pt,Bt){Bt===!0&&(je*=pt,Ye*=pt,bt*=pt),Ke.set(je,Ye,bt,pt),W.equals(Ke)===!1&&(t.clearColor(je,Ye,bt,pt),W.copy(Ke))},reset:function(){Ee=!1,Ue=null,W.set(-1,0,0,0)}}}function a(){let Ee=!1,Ke=null,Ue=null,W=null;return{setTest:function(je){je?ie(t.DEPTH_TEST):ke(t.DEPTH_TEST)},setMask:function(je){Ke!==je&&!Ee&&(t.depthMask(je),Ke=je)},setFunc:function(je){if(Ue!==je){switch(je){case CLe:t.depthFunc(t.NEVER);break;case PLe:t.depthFunc(t.ALWAYS);break;case jLe:t.depthFunc(t.LESS);break;case JS:t.depthFunc(t.LEQUAL);break;case DLe:t.depthFunc(t.EQUAL);break;case RLe:t.depthFunc(t.GEQUAL);break;case OLe:t.depthFunc(t.GREATER);break;case LLe:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}Ue=je}},setLocked:function(je){Ee=je},setClear:function(je){W!==je&&(t.clearDepth(je),W=je)},reset:function(){Ee=!1,Ke=null,Ue=null,W=null}}}function o(){let Ee=!1,Ke=null,Ue=null,W=null,je=null,Ye=null,bt=null,pt=null,Bt=null;return{setTest:function(Lt){Ee||(Lt?ie(t.STENCIL_TEST):ke(t.STENCIL_TEST))},setMask:function(Lt){Ke!==Lt&&!Ee&&(t.stencilMask(Lt),Ke=Lt)},setFunc:function(Lt,vn,cn){(Ue!==Lt||W!==vn||je!==cn)&&(t.stencilFunc(Lt,vn,cn),Ue=Lt,W=vn,je=cn)},setOp:function(Lt,vn,cn){(Ye!==Lt||bt!==vn||pt!==cn)&&(t.stencilOp(Lt,vn,cn),Ye=Lt,bt=vn,pt=cn)},setLocked:function(Lt){Ee=Lt},setClear:function(Lt){Bt!==Lt&&(t.clearStencil(Lt),Bt=Lt)},reset:function(){Ee=!1,Ke=null,Ue=null,W=null,je=null,Ye=null,bt=null,pt=null,Bt=null}}}const l=new i,c=new a,u=new o,d=new WeakMap,f=new WeakMap;let p={},m={},x=new WeakMap,b=[],v=null,y=!1,S=null,k=null,T=null,M=null,C=null,E=null,R=null,A=new Zt(0,0,0),D=0,I=!1,F=null,z=null,P=null,$=null,X=null;const V=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Q=!1,Z=0;const se=t.getParameter(t.VERSION);se.indexOf("WebGL")!==-1?(Z=parseFloat(/^WebGL (\d)/.exec(se)[1]),Q=Z>=1):se.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(se)[1]),Q=Z>=2);let H=null,K={};const re=t.getParameter(t.SCISSOR_BOX),ne=t.getParameter(t.VIEWPORT),be=new Cr().fromArray(re),me=new Cr().fromArray(ne);function de(Ee,Ke,Ue,W){const je=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 bt=0;bt<Ue;bt++)r&&(Ee===t.TEXTURE_3D||Ee===t.TEXTURE_2D_ARRAY)?t.texImage3D(Ke,0,t.RGBA,1,1,W,0,t.RGBA,t.UNSIGNED_BYTE,je):t.texImage2D(Ke+bt,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,je);return Ye}const Ce={};Ce[t.TEXTURE_2D]=de(t.TEXTURE_2D,t.TEXTURE_2D,1),Ce[t.TEXTURE_CUBE_MAP]=de(t.TEXTURE_CUBE_MAP,t.TEXTURE_CUBE_MAP_POSITIVE_X,6),r&&(Ce[t.TEXTURE_2D_ARRAY]=de(t.TEXTURE_2D_ARRAY,t.TEXTURE_2D_ARRAY,1,1),Ce[t.TEXTURE_3D]=de(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(JS),te(!1),U(zV),ie(t.CULL_FACE),ue(ch);function ie(Ee){p[Ee]!==!0&&(t.enable(Ee),p[Ee]=!0)}function ke(Ee){p[Ee]!==!1&&(t.disable(Ee),p[Ee]=!1)}function Oe(Ee,Ke){return m[Ee]!==Ke?(t.bindFramebuffer(Ee,Ke),m[Ee]=Ke,r&&(Ee===t.DRAW_FRAMEBUFFER&&(m[t.FRAMEBUFFER]=Ke),Ee===t.FRAMEBUFFER&&(m[t.DRAW_FRAMEBUFFER]=Ke)),!0):!1}function pe(Ee,Ke){let Ue=b,W=!1;if(Ee)if(Ue=x.get(Ke),Ue===void 0&&(Ue=[],x.set(Ke,Ue)),Ee.isWebGLMultipleRenderTargets){const je=Ee.texture;if(Ue.length!==je.length||Ue[0]!==t.COLOR_ATTACHMENT0){for(let Ye=0,bt=je.length;Ye<bt;Ye++)Ue[Ye]=t.COLOR_ATTACHMENT0+Ye;Ue.length=je.length,W=!0}}else Ue[0]!==t.COLOR_ATTACHMENT0&&(Ue[0]=t.COLOR_ATTACHMENT0,W=!0);else Ue[0]!==t.BACK&&(Ue[0]=t.BACK,W=!0);W&&(n.isWebGL2?t.drawBuffers(Ue):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(Ue))}function We(Ee){return v!==Ee?(t.useProgram(Ee),v=Ee,!0):!1}const G={[kf]:t.FUNC_ADD,[pLe]:t.FUNC_SUBTRACT,[gLe]:t.FUNC_REVERSE_SUBTRACT};if(r)G[VV]=t.MIN,G[GV]=t.MAX;else{const Ee=e.get("EXT_blend_minmax");Ee!==null&&(G[VV]=Ee.MIN_EXT,G[GV]=Ee.MAX_EXT)}const Y={[xLe]:t.ZERO,[bLe]:t.ONE,[yLe]:t.SRC_COLOR,[fD]:t.SRC_ALPHA,[MLe]:t.SRC_ALPHA_SATURATE,[SLe]:t.DST_COLOR,[wLe]:t.DST_ALPHA,[vLe]:t.ONE_MINUS_SRC_COLOR,[mD]:t.ONE_MINUS_SRC_ALPHA,[NLe]:t.ONE_MINUS_DST_COLOR,[_Le]:t.ONE_MINUS_DST_ALPHA,[kLe]:t.CONSTANT_COLOR,[ELe]:t.ONE_MINUS_CONSTANT_COLOR,[TLe]:t.CONSTANT_ALPHA,[ALe]:t.ONE_MINUS_CONSTANT_ALPHA};function ue(Ee,Ke,Ue,W,je,Ye,bt,pt,Bt,Lt){if(Ee===ch){y===!0&&(ke(t.BLEND),y=!1);return}if(y===!1&&(ie(t.BLEND),y=!0),Ee!==mLe){if(Ee!==S||Lt!==I){if((k!==kf||C!==kf)&&(t.blendEquation(t.FUNC_ADD),k=kf,C=kf),Lt)switch(Ee){case Pg:t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case BV:t.blendFunc(t.ONE,t.ONE);break;case HV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case $V: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 Pg:t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA);break;case BV:t.blendFunc(t.SRC_ALPHA,t.ONE);break;case HV:t.blendFuncSeparate(t.ZERO,t.ONE_MINUS_SRC_COLOR,t.ZERO,t.ONE);break;case $V:t.blendFunc(t.ZERO,t.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",Ee);break}T=null,M=null,E=null,R=null,A.set(0,0,0),D=0,S=Ee,I=Lt}return}je=je||Ke,Ye=Ye||Ue,bt=bt||W,(Ke!==k||je!==C)&&(t.blendEquationSeparate(G[Ke],G[je]),k=Ke,C=je),(Ue!==T||W!==M||Ye!==E||bt!==R)&&(t.blendFuncSeparate(Y[Ue],Y[W],Y[Ye],Y[bt]),T=Ue,M=W,E=Ye,R=bt),(pt.equals(A)===!1||Bt!==D)&&(t.blendColor(pt.r,pt.g,pt.b,Bt),A.copy(pt),D=Bt),S=Ee,I=!1}function q(Ee,Ke){Ee.side===gu?ke(t.CULL_FACE):ie(t.CULL_FACE);let Ue=Ee.side===Us;Ke&&(Ue=!Ue),te(Ue),Ee.blending===Pg&&Ee.transparent===!1?ue(ch):ue(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 W=Ee.stencilWrite;u.setTest(W),W&&(u.setMask(Ee.stencilWriteMask),u.setFunc(Ee.stencilFunc,Ee.stencilRef,Ee.stencilFuncMask),u.setOp(Ee.stencilFail,Ee.stencilZFail,Ee.stencilZPass)),Me(Ee.polygonOffset,Ee.polygonOffsetFactor,Ee.polygonOffsetUnits),Ee.alphaToCoverage===!0?ie(t.SAMPLE_ALPHA_TO_COVERAGE):ke(t.SAMPLE_ALPHA_TO_COVERAGE)}function te(Ee){F!==Ee&&(Ee?t.frontFace(t.CW):t.frontFace(t.CCW),F=Ee)}function U(Ee){Ee!==dLe?(ie(t.CULL_FACE),Ee!==z&&(Ee===zV?t.cullFace(t.BACK):Ee===hLe?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):ke(t.CULL_FACE),z=Ee}function he(Ee){Ee!==P&&(Q&&t.lineWidth(Ee),P=Ee)}function Me(Ee,Ke,Ue){Ee?(ie(t.POLYGON_OFFSET_FILL),($!==Ke||X!==Ue)&&(t.polygonOffset(Ke,Ue),$=Ke,X=Ue)):ke(t.POLYGON_OFFSET_FILL)}function ge(Ee){Ee?ie(t.SCISSOR_TEST):ke(t.SCISSOR_TEST)}function B(Ee){Ee===void 0&&(Ee=t.TEXTURE0+V-1),H!==Ee&&(t.activeTexture(Ee),H=Ee)}function O(Ee,Ke,Ue){Ue===void 0&&(H===null?Ue=t.TEXTURE0+V-1:Ue=H);let W=K[Ue];W===void 0&&(W={type:void 0,texture:void 0},K[Ue]=W),(W.type!==Ee||W.texture!==Ke)&&(H!==Ue&&(t.activeTexture(Ue),H=Ue),t.bindTexture(Ee,Ke||Ce[Ee]),W.type=Ee,W.texture=Ke)}function ee(){const Ee=K[H];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 _e(){try{t.compressedTexImage3D.apply(t,arguments)}catch(Ee){console.error("THREE.WebGLState:",Ee)}}function ve(){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 Fe(){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 $e(){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 xe(){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 ze(Ee){be.equals(Ee)===!1&&(t.scissor(Ee.x,Ee.y,Ee.z,Ee.w),be.copy(Ee))}function we(Ee){me.equals(Ee)===!1&&(t.viewport(Ee.x,Ee.y,Ee.z,Ee.w),me.copy(Ee))}function Xe(Ee,Ke){let Ue=f.get(Ke);Ue===void 0&&(Ue=new WeakMap,f.set(Ke,Ue));let W=Ue.get(Ee);W===void 0&&(W=t.getUniformBlockIndex(Ke,Ee.name),Ue.set(Ee,W))}function Ne(Ee,Ke){const W=f.get(Ke).get(Ee);d.get(Ke)!==W&&(t.uniformBlockBinding(Ke,W,Ee.__bindingPointIndex),d.set(Ke,W))}function rt(){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={},H=null,K={},m={},x=new WeakMap,b=[],v=null,y=!1,S=null,k=null,T=null,M=null,C=null,E=null,R=null,A=new Zt(0,0,0),D=0,I=!1,F=null,z=null,P=null,$=null,X=null,be.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:ke,bindFramebuffer:Oe,drawBuffers:pe,useProgram:We,setBlending:ue,setMaterial:q,setFlipSided:te,setCullFace:U,setLineWidth:he,setPolygonOffset:Me,setScissorTest:ge,activeTexture:B,bindTexture:O,unbindTexture:ee,compressedTexImage2D:le,compressedTexImage3D:_e,texImage2D:xe,texImage3D:Pe,updateUBOMapping:Xe,uniformBlockBinding:Ne,texStorage2D:$e,texStorage3D:He,texSubImage2D:ve,texSubImage3D:ae,compressedTexSubImage2D:Fe,compressedTexSubImage3D:Be,scissor:ze,viewport:we,reset:rt}}function vBe(t,e,n,r,i,a,o){const l=i.isWebGL2,c=i.maxTextures,u=i.maxCubemapSize,d=i.maxTextureSize,f=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 b;const v=new WeakMap;let y=!1;try{y=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function S(B,O){return y?new OffscreenCanvas(B,O):iN("canvas")}function k(B,O,ee,le){let _e=1;if((B.width>le||B.height>le)&&(_e=le/Math.max(B.width,B.height)),_e<1||O===!0)if(typeof HTMLImageElement<"u"&&B instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&B instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&B instanceof ImageBitmap){const ve=O?rN:Math.floor,ae=ve(_e*B.width),Fe=ve(_e*B.height);b===void 0&&(b=S(ae,Fe));const Be=ee?S(ae,Fe):b;return Be.width=ae,Be.height=Fe,Be.getContext("2d").drawImage(B,0,0,ae,Fe),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+B.width+"x"+B.height+") to ("+ae+"x"+Fe+")."),Be}else return"data"in B&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+B.width+"x"+B.height+")."),B;return B}function T(B){return wD(B.width)&&wD(B.height)}function M(B){return l?!1:B.wrapS!==Cl||B.wrapT!==Cl||B.minFilter!==Oa&&B.minFilter!==Ko}function C(B,O){return B.generateMipmaps&&O&&B.minFilter!==Oa&&B.minFilter!==Ko}function E(B){t.generateMipmap(B)}function R(B,O,ee,le,_e=!1){if(l===!1)return O;if(B!==null){if(t[B]!==void 0)return t[B];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+B+"'")}let ve=O;if(O===t.RED&&(ee===t.FLOAT&&(ve=t.R32F),ee===t.HALF_FLOAT&&(ve=t.R16F),ee===t.UNSIGNED_BYTE&&(ve=t.R8)),O===t.RED_INTEGER&&(ee===t.UNSIGNED_BYTE&&(ve=t.R8UI),ee===t.UNSIGNED_SHORT&&(ve=t.R16UI),ee===t.UNSIGNED_INT&&(ve=t.R32UI),ee===t.BYTE&&(ve=t.R8I),ee===t.SHORT&&(ve=t.R16I),ee===t.INT&&(ve=t.R32I)),O===t.RG&&(ee===t.FLOAT&&(ve=t.RG32F),ee===t.HALF_FLOAT&&(ve=t.RG16F),ee===t.UNSIGNED_BYTE&&(ve=t.RG8)),O===t.RGBA){const ae=_e?eN:Er.getTransfer(le);ee===t.FLOAT&&(ve=t.RGBA32F),ee===t.HALF_FLOAT&&(ve=t.RGBA16F),ee===t.UNSIGNED_BYTE&&(ve=ae===Gr?t.SRGB8_ALPHA8:t.RGBA8),ee===t.UNSIGNED_SHORT_4_4_4_4&&(ve=t.RGBA4),ee===t.UNSIGNED_SHORT_5_5_5_1&&(ve=t.RGB5_A1)}return(ve===t.R16F||ve===t.R32F||ve===t.RG16F||ve===t.RG32F||ve===t.RGBA16F||ve===t.RGBA32F)&&e.get("EXT_color_buffer_float"),ve}function A(B,O,ee){return C(B,ee)===!0||B.isFramebufferTexture&&B.minFilter!==Oa&&B.minFilter!==Ko?Math.log2(Math.max(O.width,O.height))+1:B.mipmaps!==void 0&&B.mipmaps.length>0?B.mipmaps.length:B.isCompressedTexture&&Array.isArray(B.image)?O.mipmaps.length:1}function D(B){return B===Oa||B===qV||B===NC?t.NEAREST:t.LINEAR}function I(B){const O=B.target;O.removeEventListener("dispose",I),z(O),O.isVideoTexture&&x.delete(O)}function F(B){const O=B.target;O.removeEventListener("dispose",F),$(O)}function z(B){const O=r.get(B);if(O.__webglInit===void 0)return;const ee=B.source,le=v.get(ee);if(le){const _e=le[O.__cacheKey];_e.usedTimes--,_e.usedTimes===0&&P(B),Object.keys(le).length===0&&v.delete(ee)}r.remove(B)}function P(B){const O=r.get(B);t.deleteTexture(O.__webglTexture);const ee=B.source,le=v.get(ee);delete le[O.__cacheKey],o.memory.textures--}function $(B){const O=B.texture,ee=r.get(B),le=r.get(O);if(le.__webglTexture!==void 0&&(t.deleteTexture(le.__webglTexture),o.memory.textures--),B.depthTexture&&B.depthTexture.dispose(),B.isWebGLCubeRenderTarget)for(let _e=0;_e<6;_e++){if(Array.isArray(ee.__webglFramebuffer[_e]))for(let ve=0;ve<ee.__webglFramebuffer[_e].length;ve++)t.deleteFramebuffer(ee.__webglFramebuffer[_e][ve]);else t.deleteFramebuffer(ee.__webglFramebuffer[_e]);ee.__webglDepthbuffer&&t.deleteRenderbuffer(ee.__webglDepthbuffer[_e])}else{if(Array.isArray(ee.__webglFramebuffer))for(let _e=0;_e<ee.__webglFramebuffer.length;_e++)t.deleteFramebuffer(ee.__webglFramebuffer[_e]);else t.deleteFramebuffer(ee.__webglFramebuffer);if(ee.__webglDepthbuffer&&t.deleteRenderbuffer(ee.__webglDepthbuffer),ee.__webglMultisampledFramebuffer&&t.deleteFramebuffer(ee.__webglMultisampledFramebuffer),ee.__webglColorRenderbuffer)for(let _e=0;_e<ee.__webglColorRenderbuffer.length;_e++)ee.__webglColorRenderbuffer[_e]&&t.deleteRenderbuffer(ee.__webglColorRenderbuffer[_e]);ee.__webglDepthRenderbuffer&&t.deleteRenderbuffer(ee.__webglDepthRenderbuffer)}if(B.isWebGLMultipleRenderTargets)for(let _e=0,ve=O.length;_e<ve;_e++){const ae=r.get(O[_e]);ae.__webglTexture&&(t.deleteTexture(ae.__webglTexture),o.memory.textures--),r.remove(O[_e])}r.remove(O),r.remove(B)}let X=0;function V(){X=0}function Q(){const B=X;return B>=c&&console.warn("THREE.WebGLTextures: Trying to use "+B+" texture units while this GPU supports only "+c),X+=1,B}function Z(B){const O=[];return O.push(B.wrapS),O.push(B.wrapT),O.push(B.wrapR||0),O.push(B.magFilter),O.push(B.minFilter),O.push(B.anisotropy),O.push(B.internalFormat),O.push(B.format),O.push(B.type),O.push(B.generateMipmaps),O.push(B.premultiplyAlpha),O.push(B.flipY),O.push(B.unpackAlignment),O.push(B.colorSpace),O.join()}function se(B,O){const ee=r.get(B);if(B.isVideoTexture&&Me(B),B.isRenderTargetTexture===!1&&B.version>0&&ee.__version!==B.version){const le=B.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(ee,B,O);return}}n.bindTexture(t.TEXTURE_2D,ee.__webglTexture,t.TEXTURE0+O)}function H(B,O){const ee=r.get(B);if(B.version>0&&ee.__version!==B.version){ie(ee,B,O);return}n.bindTexture(t.TEXTURE_2D_ARRAY,ee.__webglTexture,t.TEXTURE0+O)}function K(B,O){const ee=r.get(B);if(B.version>0&&ee.__version!==B.version){ie(ee,B,O);return}n.bindTexture(t.TEXTURE_3D,ee.__webglTexture,t.TEXTURE0+O)}function re(B,O){const ee=r.get(B);if(B.version>0&&ee.__version!==B.version){ke(ee,B,O);return}n.bindTexture(t.TEXTURE_CUBE_MAP,ee.__webglTexture,t.TEXTURE0+O)}const ne={[xD]:t.REPEAT,[Cl]:t.CLAMP_TO_EDGE,[bD]:t.MIRRORED_REPEAT},be={[Oa]:t.NEAREST,[qV]:t.NEAREST_MIPMAP_NEAREST,[NC]:t.NEAREST_MIPMAP_LINEAR,[Ko]:t.LINEAR,[VLe]:t.LINEAR_MIPMAP_NEAREST,[gy]:t.LINEAR_MIPMAP_LINEAR},me={[nFe]:t.NEVER,[lFe]:t.ALWAYS,[rFe]:t.LESS,[XJ]:t.LEQUAL,[iFe]:t.EQUAL,[oFe]:t.GEQUAL,[aFe]:t.GREATER,[sFe]:t.NOTEQUAL};function de(B,O,ee){if(ee?(t.texParameteri(B,t.TEXTURE_WRAP_S,ne[O.wrapS]),t.texParameteri(B,t.TEXTURE_WRAP_T,ne[O.wrapT]),(B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY)&&t.texParameteri(B,t.TEXTURE_WRAP_R,ne[O.wrapR]),t.texParameteri(B,t.TEXTURE_MAG_FILTER,be[O.magFilter]),t.texParameteri(B,t.TEXTURE_MIN_FILTER,be[O.minFilter])):(t.texParameteri(B,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(B,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),(B===t.TEXTURE_3D||B===t.TEXTURE_2D_ARRAY)&&t.texParameteri(B,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(B,t.TEXTURE_MAG_FILTER,D(O.magFilter)),t.texParameteri(B,t.TEXTURE_MIN_FILTER,D(O.minFilter)),O.minFilter!==Oa&&O.minFilter!==Ko&&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(B,t.TEXTURE_COMPARE_MODE,t.COMPARE_REF_TO_TEXTURE),t.texParameteri(B,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===Oa||O.minFilter!==NC&&O.minFilter!==gy||O.type===Su&&e.has("OES_texture_float_linear")===!1||l===!1&&O.type===xy&&e.has("OES_texture_half_float_linear")===!1)return;(O.anisotropy>1||r.get(O).__currentAnisotropy)&&(t.texParameterf(B,le.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(O.anisotropy,i.getMaxAnisotropy())),r.get(O).__currentAnisotropy=O.anisotropy)}}function Ce(B,O){let ee=!1;B.__webglInit===void 0&&(B.__webglInit=!0,O.addEventListener("dispose",I));const le=O.source;let _e=v.get(le);_e===void 0&&(_e={},v.set(le,_e));const ve=Z(O);if(ve!==B.__cacheKey){_e[ve]===void 0&&(_e[ve]={texture:t.createTexture(),usedTimes:0},o.memory.textures++,ee=!0),_e[ve].usedTimes++;const ae=_e[B.__cacheKey];ae!==void 0&&(_e[B.__cacheKey].usedTimes--,ae.usedTimes===0&&P(O)),B.__cacheKey=ve,B.__webglTexture=_e[ve].texture}return ee}function ie(B,O,ee){let le=t.TEXTURE_2D;(O.isDataArrayTexture||O.isCompressedArrayTexture)&&(le=t.TEXTURE_2D_ARRAY),O.isData3DTexture&&(le=t.TEXTURE_3D);const _e=Ce(B,O),ve=O.source;n.bindTexture(le,B.__webglTexture,t.TEXTURE0+ee);const ae=r.get(ve);if(ve.version!==ae.__version||_e===!0){n.activeTexture(t.TEXTURE0+ee);const Fe=Er.getPrimaries(Er.workingColorSpace),Be=O.colorSpace===Yo?null:Er.getPrimaries(O.colorSpace),$e=O.colorSpace===Yo||Fe===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,$e);const He=M(O)&&T(O.image)===!1;let xe=k(O.image,He,!1,d);xe=ge(O,xe);const Pe=T(xe)||l,ze=a.convert(O.format,O.colorSpace);let we=a.convert(O.type),Xe=R(O.internalFormat,ze,we,O.colorSpace,O.isVideoTexture);de(le,O,Pe);let Ne;const rt=O.mipmaps,Ee=l&&O.isVideoTexture!==!0&&Xe!==qJ,Ke=ae.__version===void 0||_e===!0,Ue=A(O,xe,Pe);if(O.isDepthTexture)Xe=t.DEPTH_COMPONENT,l?O.type===Su?Xe=t.DEPTH_COMPONENT32F:O.type===Zd?Xe=t.DEPTH_COMPONENT24:O.type===qf?Xe=t.DEPTH24_STENCIL8:Xe=t.DEPTH_COMPONENT16:O.type===Su&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),O.format===Wf&&Xe===t.DEPTH_COMPONENT&&O.type!==iL&&O.type!==Zd&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),O.type=Zd,we=a.convert(O.type)),O.format===ix&&Xe===t.DEPTH_COMPONENT&&(Xe=t.DEPTH_STENCIL,O.type!==qf&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),O.type=qf,we=a.convert(O.type))),Ke&&(Ee?n.texStorage2D(t.TEXTURE_2D,1,Xe,xe.width,xe.height):n.texImage2D(t.TEXTURE_2D,0,Xe,xe.width,xe.height,0,ze,we,null));else if(O.isDataTexture)if(rt.length>0&&Pe){Ee&&Ke&&n.texStorage2D(t.TEXTURE_2D,Ue,Xe,rt[0].width,rt[0].height);for(let W=0,je=rt.length;W<je;W++)Ne=rt[W],Ee?n.texSubImage2D(t.TEXTURE_2D,W,0,0,Ne.width,Ne.height,ze,we,Ne.data):n.texImage2D(t.TEXTURE_2D,W,Xe,Ne.width,Ne.height,0,ze,we,Ne.data);O.generateMipmaps=!1}else Ee?(Ke&&n.texStorage2D(t.TEXTURE_2D,Ue,Xe,xe.width,xe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,xe.width,xe.height,ze,we,xe.data)):n.texImage2D(t.TEXTURE_2D,0,Xe,xe.width,xe.height,0,ze,we,xe.data);else if(O.isCompressedTexture)if(O.isCompressedArrayTexture){Ee&&Ke&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,Xe,rt[0].width,rt[0].height,xe.depth);for(let W=0,je=rt.length;W<je;W++)Ne=rt[W],O.format!==Xo?ze!==null?Ee?n.compressedTexSubImage3D(t.TEXTURE_2D_ARRAY,W,0,0,0,Ne.width,Ne.height,xe.depth,ze,Ne.data,0,0):n.compressedTexImage3D(t.TEXTURE_2D_ARRAY,W,Xe,Ne.width,Ne.height,xe.depth,0,Ne.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ee?n.texSubImage3D(t.TEXTURE_2D_ARRAY,W,0,0,0,Ne.width,Ne.height,xe.depth,ze,we,Ne.data):n.texImage3D(t.TEXTURE_2D_ARRAY,W,Xe,Ne.width,Ne.height,xe.depth,0,ze,we,Ne.data)}else{Ee&&Ke&&n.texStorage2D(t.TEXTURE_2D,Ue,Xe,rt[0].width,rt[0].height);for(let W=0,je=rt.length;W<je;W++)Ne=rt[W],O.format!==Xo?ze!==null?Ee?n.compressedTexSubImage2D(t.TEXTURE_2D,W,0,0,Ne.width,Ne.height,ze,Ne.data):n.compressedTexImage2D(t.TEXTURE_2D,W,Xe,Ne.width,Ne.height,0,Ne.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ee?n.texSubImage2D(t.TEXTURE_2D,W,0,0,Ne.width,Ne.height,ze,we,Ne.data):n.texImage2D(t.TEXTURE_2D,W,Xe,Ne.width,Ne.height,0,ze,we,Ne.data)}else if(O.isDataArrayTexture)Ee?(Ke&&n.texStorage3D(t.TEXTURE_2D_ARRAY,Ue,Xe,xe.width,xe.height,xe.depth),n.texSubImage3D(t.TEXTURE_2D_ARRAY,0,0,0,0,xe.width,xe.height,xe.depth,ze,we,xe.data)):n.texImage3D(t.TEXTURE_2D_ARRAY,0,Xe,xe.width,xe.height,xe.depth,0,ze,we,xe.data);else if(O.isData3DTexture)Ee?(Ke&&n.texStorage3D(t.TEXTURE_3D,Ue,Xe,xe.width,xe.height,xe.depth),n.texSubImage3D(t.TEXTURE_3D,0,0,0,0,xe.width,xe.height,xe.depth,ze,we,xe.data)):n.texImage3D(t.TEXTURE_3D,0,Xe,xe.width,xe.height,xe.depth,0,ze,we,xe.data);else if(O.isFramebufferTexture){if(Ke)if(Ee)n.texStorage2D(t.TEXTURE_2D,Ue,Xe,xe.width,xe.height);else{let W=xe.width,je=xe.height;for(let Ye=0;Ye<Ue;Ye++)n.texImage2D(t.TEXTURE_2D,Ye,Xe,W,je,0,ze,we,null),W>>=1,je>>=1}}else if(rt.length>0&&Pe){Ee&&Ke&&n.texStorage2D(t.TEXTURE_2D,Ue,Xe,rt[0].width,rt[0].height);for(let W=0,je=rt.length;W<je;W++)Ne=rt[W],Ee?n.texSubImage2D(t.TEXTURE_2D,W,0,0,ze,we,Ne):n.texImage2D(t.TEXTURE_2D,W,Xe,ze,we,Ne);O.generateMipmaps=!1}else Ee?(Ke&&n.texStorage2D(t.TEXTURE_2D,Ue,Xe,xe.width,xe.height),n.texSubImage2D(t.TEXTURE_2D,0,0,0,ze,we,xe)):n.texImage2D(t.TEXTURE_2D,0,Xe,ze,we,xe);C(O,Pe)&&E(le),ae.__version=ve.version,O.onUpdate&&O.onUpdate(O)}B.__version=O.version}function ke(B,O,ee){if(O.image.length!==6)return;const le=Ce(B,O),_e=O.source;n.bindTexture(t.TEXTURE_CUBE_MAP,B.__webglTexture,t.TEXTURE0+ee);const ve=r.get(_e);if(_e.version!==ve.__version||le===!0){n.activeTexture(t.TEXTURE0+ee);const ae=Er.getPrimaries(Er.workingColorSpace),Fe=O.colorSpace===Yo?null:Er.getPrimaries(O.colorSpace),Be=O.colorSpace===Yo||ae===Fe?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 $e=O.isCompressedTexture||O.image[0].isCompressedTexture,He=O.image[0]&&O.image[0].isDataTexture,xe=[];for(let W=0;W<6;W++)!$e&&!He?xe[W]=k(O.image[W],!1,!0,u):xe[W]=He?O.image[W].image:O.image[W],xe[W]=ge(O,xe[W]);const Pe=xe[0],ze=T(Pe)||l,we=a.convert(O.format,O.colorSpace),Xe=a.convert(O.type),Ne=R(O.internalFormat,we,Xe,O.colorSpace),rt=l&&O.isVideoTexture!==!0,Ee=ve.__version===void 0||le===!0;let Ke=A(O,Pe,ze);de(t.TEXTURE_CUBE_MAP,O,ze);let Ue;if($e){rt&&Ee&&n.texStorage2D(t.TEXTURE_CUBE_MAP,Ke,Ne,Pe.width,Pe.height);for(let W=0;W<6;W++){Ue=xe[W].mipmaps;for(let je=0;je<Ue.length;je++){const Ye=Ue[je];O.format!==Xo?we!==null?rt?n.compressedTexSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,je,0,0,Ye.width,Ye.height,we,Ye.data):n.compressedTexImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,je,Ne,Ye.width,Ye.height,0,Ye.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):rt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,je,0,0,Ye.width,Ye.height,we,Xe,Ye.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,je,Ne,Ye.width,Ye.height,0,we,Xe,Ye.data)}}}else{Ue=O.mipmaps,rt&&Ee&&(Ue.length>0&&Ke++,n.texStorage2D(t.TEXTURE_CUBE_MAP,Ke,Ne,xe[0].width,xe[0].height));for(let W=0;W<6;W++)if(He){rt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,xe[W].width,xe[W].height,we,Xe,xe[W].data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,Ne,xe[W].width,xe[W].height,0,we,Xe,xe[W].data);for(let je=0;je<Ue.length;je++){const bt=Ue[je].image[W].image;rt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,je+1,0,0,bt.width,bt.height,we,Xe,bt.data):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,je+1,Ne,bt.width,bt.height,0,we,Xe,bt.data)}}else{rt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,0,0,we,Xe,xe[W]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,0,Ne,we,Xe,xe[W]);for(let je=0;je<Ue.length;je++){const Ye=Ue[je];rt?n.texSubImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,je+1,0,0,we,Xe,Ye.image[W]):n.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+W,je+1,Ne,we,Xe,Ye.image[W])}}}C(O,ze)&&E(t.TEXTURE_CUBE_MAP),ve.__version=_e.version,O.onUpdate&&O.onUpdate(O)}B.__version=O.version}function Oe(B,O,ee,le,_e,ve){const ae=a.convert(ee.format,ee.colorSpace),Fe=a.convert(ee.type),Be=R(ee.internalFormat,ae,Fe,ee.colorSpace);if(!r.get(O).__hasExternalTextures){const He=Math.max(1,O.width>>ve),xe=Math.max(1,O.height>>ve);_e===t.TEXTURE_3D||_e===t.TEXTURE_2D_ARRAY?n.texImage3D(_e,ve,Be,He,xe,O.depth,0,ae,Fe,null):n.texImage2D(_e,ve,Be,He,xe,0,ae,Fe,null)}n.bindFramebuffer(t.FRAMEBUFFER,B),he(O)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,le,_e,r.get(ee).__webglTexture,0,U(O)):(_e===t.TEXTURE_2D||_e>=t.TEXTURE_CUBE_MAP_POSITIVE_X&&_e<=t.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&t.framebufferTexture2D(t.FRAMEBUFFER,le,_e,r.get(ee).__webglTexture,ve),n.bindFramebuffer(t.FRAMEBUFFER,null)}function pe(B,O,ee){if(t.bindRenderbuffer(t.RENDERBUFFER,B),O.depthBuffer&&!O.stencilBuffer){let le=l===!0?t.DEPTH_COMPONENT24:t.DEPTH_COMPONENT16;if(ee||he(O)){const _e=O.depthTexture;_e&&_e.isDepthTexture&&(_e.type===Su?le=t.DEPTH_COMPONENT32F:_e.type===Zd&&(le=t.DEPTH_COMPONENT24));const ve=U(O);he(O)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,ve,le,O.width,O.height):t.renderbufferStorageMultisample(t.RENDERBUFFER,ve,le,O.width,O.height)}else t.renderbufferStorage(t.RENDERBUFFER,le,O.width,O.height);t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.RENDERBUFFER,B)}else if(O.depthBuffer&&O.stencilBuffer){const le=U(O);ee&&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,B)}else{const le=O.isWebGLMultipleRenderTargets===!0?O.texture:[O.texture];for(let _e=0;_e<le.length;_e++){const ve=le[_e],ae=a.convert(ve.format,ve.colorSpace),Fe=a.convert(ve.type),Be=R(ve.internalFormat,ae,Fe,ve.colorSpace),$e=U(O);ee&&he(O)===!1?t.renderbufferStorageMultisample(t.RENDERBUFFER,$e,Be,O.width,O.height):he(O)?p.renderbufferStorageMultisampleEXT(t.RENDERBUFFER,$e,Be,O.width,O.height):t.renderbufferStorage(t.RENDERBUFFER,Be,O.width,O.height)}}t.bindRenderbuffer(t.RENDERBUFFER,null)}function We(B,O){if(O&&O.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(t.FRAMEBUFFER,B),!(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),se(O.depthTexture,0);const le=r.get(O.depthTexture).__webglTexture,_e=U(O);if(O.depthTexture.format===Wf)he(O)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,le,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_ATTACHMENT,t.TEXTURE_2D,le,0);else if(O.depthTexture.format===ix)he(O)?p.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,le,0,_e):t.framebufferTexture2D(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.TEXTURE_2D,le,0);else throw new Error("Unknown depthTexture format")}function G(B){const O=r.get(B),ee=B.isWebGLCubeRenderTarget===!0;if(B.depthTexture&&!O.__autoAllocateDepthBuffer){if(ee)throw new Error("target.depthTexture not supported in Cube render targets");We(O.__webglFramebuffer,B)}else if(ee){O.__webglDepthbuffer=[];for(let le=0;le<6;le++)n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer[le]),O.__webglDepthbuffer[le]=t.createRenderbuffer(),pe(O.__webglDepthbuffer[le],B,!1)}else n.bindFramebuffer(t.FRAMEBUFFER,O.__webglFramebuffer),O.__webglDepthbuffer=t.createRenderbuffer(),pe(O.__webglDepthbuffer,B,!1);n.bindFramebuffer(t.FRAMEBUFFER,null)}function Y(B,O,ee){const le=r.get(B);O!==void 0&&Oe(le.__webglFramebuffer,B,B.texture,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,0),ee!==void 0&&G(B)}function ue(B){const O=B.texture,ee=r.get(B),le=r.get(O);B.addEventListener("dispose",F),B.isWebGLMultipleRenderTargets!==!0&&(le.__webglTexture===void 0&&(le.__webglTexture=t.createTexture()),le.__version=O.version,o.memory.textures++);const _e=B.isWebGLCubeRenderTarget===!0,ve=B.isWebGLMultipleRenderTargets===!0,ae=T(B)||l;if(_e){ee.__webglFramebuffer=[];for(let Fe=0;Fe<6;Fe++)if(l&&O.mipmaps&&O.mipmaps.length>0){ee.__webglFramebuffer[Fe]=[];for(let Be=0;Be<O.mipmaps.length;Be++)ee.__webglFramebuffer[Fe][Be]=t.createFramebuffer()}else ee.__webglFramebuffer[Fe]=t.createFramebuffer()}else{if(l&&O.mipmaps&&O.mipmaps.length>0){ee.__webglFramebuffer=[];for(let Fe=0;Fe<O.mipmaps.length;Fe++)ee.__webglFramebuffer[Fe]=t.createFramebuffer()}else ee.__webglFramebuffer=t.createFramebuffer();if(ve)if(i.drawBuffers){const Fe=B.texture;for(let Be=0,$e=Fe.length;Be<$e;Be++){const He=r.get(Fe[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&&B.samples>0&&he(B)===!1){const Fe=ve?O:[O];ee.__webglMultisampledFramebuffer=t.createFramebuffer(),ee.__webglColorRenderbuffer=[],n.bindFramebuffer(t.FRAMEBUFFER,ee.__webglMultisampledFramebuffer);for(let Be=0;Be<Fe.length;Be++){const $e=Fe[Be];ee.__webglColorRenderbuffer[Be]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,ee.__webglColorRenderbuffer[Be]);const He=a.convert($e.format,$e.colorSpace),xe=a.convert($e.type),Pe=R($e.internalFormat,He,xe,$e.colorSpace,B.isXRRenderTarget===!0),ze=U(B);t.renderbufferStorageMultisample(t.RENDERBUFFER,ze,Pe,B.width,B.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+Be,t.RENDERBUFFER,ee.__webglColorRenderbuffer[Be])}t.bindRenderbuffer(t.RENDERBUFFER,null),B.depthBuffer&&(ee.__webglDepthRenderbuffer=t.createRenderbuffer(),pe(ee.__webglDepthRenderbuffer,B,!0)),n.bindFramebuffer(t.FRAMEBUFFER,null)}}if(_e){n.bindTexture(t.TEXTURE_CUBE_MAP,le.__webglTexture),de(t.TEXTURE_CUBE_MAP,O,ae);for(let Fe=0;Fe<6;Fe++)if(l&&O.mipmaps&&O.mipmaps.length>0)for(let Be=0;Be<O.mipmaps.length;Be++)Oe(ee.__webglFramebuffer[Fe][Be],B,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Fe,Be);else Oe(ee.__webglFramebuffer[Fe],B,O,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+Fe,0);C(O,ae)&&E(t.TEXTURE_CUBE_MAP),n.unbindTexture()}else if(ve){const Fe=B.texture;for(let Be=0,$e=Fe.length;Be<$e;Be++){const He=Fe[Be],xe=r.get(He);n.bindTexture(t.TEXTURE_2D,xe.__webglTexture),de(t.TEXTURE_2D,He,ae),Oe(ee.__webglFramebuffer,B,He,t.COLOR_ATTACHMENT0+Be,t.TEXTURE_2D,0),C(He,ae)&&E(t.TEXTURE_2D)}n.unbindTexture()}else{let Fe=t.TEXTURE_2D;if((B.isWebGL3DRenderTarget||B.isWebGLArrayRenderTarget)&&(l?Fe=B.isWebGL3DRenderTarget?t.TEXTURE_3D:t.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(Fe,le.__webglTexture),de(Fe,O,ae),l&&O.mipmaps&&O.mipmaps.length>0)for(let Be=0;Be<O.mipmaps.length;Be++)Oe(ee.__webglFramebuffer[Be],B,O,t.COLOR_ATTACHMENT0,Fe,Be);else Oe(ee.__webglFramebuffer,B,O,t.COLOR_ATTACHMENT0,Fe,0);C(O,ae)&&E(Fe),n.unbindTexture()}B.depthBuffer&&G(B)}function q(B){const O=T(B)||l,ee=B.isWebGLMultipleRenderTargets===!0?B.texture:[B.texture];for(let le=0,_e=ee.length;le<_e;le++){const ve=ee[le];if(C(ve,O)){const ae=B.isWebGLCubeRenderTarget?t.TEXTURE_CUBE_MAP:t.TEXTURE_2D,Fe=r.get(ve).__webglTexture;n.bindTexture(ae,Fe),E(ae),n.unbindTexture()}}}function te(B){if(l&&B.samples>0&&he(B)===!1){const O=B.isWebGLMultipleRenderTargets?B.texture:[B.texture],ee=B.width,le=B.height;let _e=t.COLOR_BUFFER_BIT;const ve=[],ae=B.stencilBuffer?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT,Fe=r.get(B),Be=B.isWebGLMultipleRenderTargets===!0;if(Be)for(let $e=0;$e<O.length;$e++)n.bindFramebuffer(t.FRAMEBUFFER,Fe.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+$e,t.RENDERBUFFER,null),n.bindFramebuffer(t.FRAMEBUFFER,Fe.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+$e,t.TEXTURE_2D,null,0);n.bindFramebuffer(t.READ_FRAMEBUFFER,Fe.__webglMultisampledFramebuffer),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Fe.__webglFramebuffer);for(let $e=0;$e<O.length;$e++){ve.push(t.COLOR_ATTACHMENT0+$e),B.depthBuffer&&ve.push(ae);const He=Fe.__ignoreDepthValues!==void 0?Fe.__ignoreDepthValues:!1;if(He===!1&&(B.depthBuffer&&(_e|=t.DEPTH_BUFFER_BIT),B.stencilBuffer&&(_e|=t.STENCIL_BUFFER_BIT)),Be&&t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,Fe.__webglColorRenderbuffer[$e]),He===!0&&(t.invalidateFramebuffer(t.READ_FRAMEBUFFER,[ae]),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,[ae])),Be){const xe=r.get(O[$e]).__webglTexture;t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,xe,0)}t.blitFramebuffer(0,0,ee,le,0,0,ee,le,_e,t.NEAREST),m&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,ve)}if(n.bindFramebuffer(t.READ_FRAMEBUFFER,null),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),Be)for(let $e=0;$e<O.length;$e++){n.bindFramebuffer(t.FRAMEBUFFER,Fe.__webglMultisampledFramebuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+$e,t.RENDERBUFFER,Fe.__webglColorRenderbuffer[$e]);const He=r.get(O[$e]).__webglTexture;n.bindFramebuffer(t.FRAMEBUFFER,Fe.__webglFramebuffer),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+$e,t.TEXTURE_2D,He,0)}n.bindFramebuffer(t.DRAW_FRAMEBUFFER,Fe.__webglMultisampledFramebuffer)}}function U(B){return Math.min(f,B.samples)}function he(B){const O=r.get(B);return l&&B.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&O.__useRenderToTexture!==!1}function Me(B){const O=o.render.frame;x.get(B)!==O&&(x.set(B,O),B.update())}function ge(B,O){const ee=B.colorSpace,le=B.format,_e=B.type;return B.isCompressedTexture===!0||B.isVideoTexture===!0||B.format===vD||ee!==Vu&&ee!==Yo&&(Er.getTransfer(ee)===Gr?l===!1?e.has("EXT_sRGB")===!0&&le===Xo?(B.format=vD,B.minFilter=Ko,B.generateMipmaps=!1):O=ZJ.sRGBToLinear(O):(le!==Xo||_e!==dh)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",ee)),O}this.allocateTextureUnit=Q,this.resetTextureUnits=V,this.setTexture2D=se,this.setTexture2DArray=H,this.setTexture3D=K,this.setTextureCube=re,this.rebindTextures=Y,this.setupRenderTarget=ue,this.updateRenderTargetMipmap=q,this.updateMultisampleRenderTarget=te,this.setupDepthRenderbuffer=G,this.setupFrameBufferTexture=Oe,this.useMultisampledRTT=he}function wBe(t,e,n){const r=n.isWebGL2;function i(a,o=Yo){let l;const c=Er.getTransfer(o);if(a===dh)return t.UNSIGNED_BYTE;if(a===BJ)return t.UNSIGNED_SHORT_4_4_4_4;if(a===HJ)return t.UNSIGNED_SHORT_5_5_5_1;if(a===GLe)return t.BYTE;if(a===qLe)return t.SHORT;if(a===iL)return t.UNSIGNED_SHORT;if(a===zJ)return t.INT;if(a===Zd)return t.UNSIGNED_INT;if(a===Su)return t.FLOAT;if(a===xy)return r?t.HALF_FLOAT:(l=e.get("OES_texture_half_float"),l!==null?l.HALF_FLOAT_OES:null);if(a===WLe)return t.ALPHA;if(a===Xo)return t.RGBA;if(a===KLe)return t.LUMINANCE;if(a===XLe)return t.LUMINANCE_ALPHA;if(a===Wf)return t.DEPTH_COMPONENT;if(a===ix)return t.DEPTH_STENCIL;if(a===vD)return l=e.get("EXT_sRGB"),l!==null?l.SRGB_ALPHA_EXT:null;if(a===YLe)return t.RED;if(a===$J)return t.RED_INTEGER;if(a===QLe)return t.RG;if(a===VJ)return t.RG_INTEGER;if(a===GJ)return t.RGBA_INTEGER;if(a===MC||a===kC||a===EC||a===TC)if(c===Gr)if(l=e.get("WEBGL_compressed_texture_s3tc_srgb"),l!==null){if(a===MC)return l.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(a===kC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(a===EC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(a===TC)return l.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(l=e.get("WEBGL_compressed_texture_s3tc"),l!==null){if(a===MC)return l.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===kC)return l.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===EC)return l.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===TC)return l.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(a===WV||a===KV||a===XV||a===YV)if(l=e.get("WEBGL_compressed_texture_pvrtc"),l!==null){if(a===WV)return l.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===KV)return l.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===XV)return l.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===YV)return l.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(a===qJ)return l=e.get("WEBGL_compressed_texture_etc1"),l!==null?l.COMPRESSED_RGB_ETC1_WEBGL:null;if(a===QV||a===ZV)if(l=e.get("WEBGL_compressed_texture_etc"),l!==null){if(a===QV)return c===Gr?l.COMPRESSED_SRGB8_ETC2:l.COMPRESSED_RGB8_ETC2;if(a===ZV)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:l.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(a===JV||a===eG||a===tG||a===nG||a===rG||a===iG||a===aG||a===sG||a===oG||a===lG||a===cG||a===uG||a===dG||a===hG)if(l=e.get("WEBGL_compressed_texture_astc"),l!==null){if(a===JV)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:l.COMPRESSED_RGBA_ASTC_4x4_KHR;if(a===eG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:l.COMPRESSED_RGBA_ASTC_5x4_KHR;if(a===tG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:l.COMPRESSED_RGBA_ASTC_5x5_KHR;if(a===nG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:l.COMPRESSED_RGBA_ASTC_6x5_KHR;if(a===rG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:l.COMPRESSED_RGBA_ASTC_6x6_KHR;if(a===iG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:l.COMPRESSED_RGBA_ASTC_8x5_KHR;if(a===aG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:l.COMPRESSED_RGBA_ASTC_8x6_KHR;if(a===sG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:l.COMPRESSED_RGBA_ASTC_8x8_KHR;if(a===oG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:l.COMPRESSED_RGBA_ASTC_10x5_KHR;if(a===lG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:l.COMPRESSED_RGBA_ASTC_10x6_KHR;if(a===cG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:l.COMPRESSED_RGBA_ASTC_10x8_KHR;if(a===uG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:l.COMPRESSED_RGBA_ASTC_10x10_KHR;if(a===dG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:l.COMPRESSED_RGBA_ASTC_12x10_KHR;if(a===hG)return c===Gr?l.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:l.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(a===AC||a===fG||a===mG)if(l=e.get("EXT_texture_compression_bptc"),l!==null){if(a===AC)return c===Gr?l.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:l.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(a===fG)return l.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(a===mG)return l.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(a===ZLe||a===pG||a===gG||a===xG)if(l=e.get("EXT_texture_compression_rgtc"),l!==null){if(a===AC)return l.COMPRESSED_RED_RGTC1_EXT;if(a===pG)return l.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(a===gG)return l.COMPRESSED_RED_GREEN_RGTC2_EXT;if(a===xG)return l.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return a===qf?r?t.UNSIGNED_INT_24_8:(l=e.get("WEBGL_depth_texture"),l!==null?l.UNSIGNED_INT_24_8_WEBGL:null):t[a]!==void 0?t[a]:null}return{convert:i}}class _Be extends so{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class u0 extends ps{constructor(){super(),this.isGroup=!0,this.type="Group"}}const SBe={type:"move"};class ZC{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new u0,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 u0,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new qe,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new qe),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new u0,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new qe,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new qe),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const n=this._hand;if(n)for(const r of e.hand.values())this._getHandJoint(n,r)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,r){let i=null,a=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 b of e.hand.values()){const v=n.getJointPose(b,r),y=this._getHandJoint(u,b);v!==null&&(y.matrix.fromArray(v.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,y.jointRadius=v.radius),y.visible=v!==null}const d=u.joints["index-finger-tip"],f=u.joints["thumb-tip"],p=d.position.distanceTo(f.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&&(a=n.getPose(e.gripSpace,r),a!==null&&(c.matrix.fromArray(a.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,a.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(a.linearVelocity)):c.hasLinearVelocity=!1,a.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(a.angularVelocity)):c.hasAngularVelocity=!1));l!==null&&(i=n.getPose(e.targetRaySpace,r),i===null&&a!==null&&(i=a),i!==null&&(l.matrix.fromArray(i.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,i.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(i.linearVelocity)):l.hasLinearVelocity=!1,i.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(i.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(SBe)))}return l!==null&&(l.visible=i!==null),c!==null&&(c.visible=a!==null),u!==null&&(u.visible=o!==null),this}_getHandJoint(e,n){if(e.joints[n.jointName]===void 0){const r=new u0;r.matrixAutoUpdate=!1,r.visible=!1,e.joints[n.jointName]=r,e.add(r)}return e.joints[n.jointName]}}class NBe extends Pm{constructor(e,n){super();const r=this;let i=null,a=1,o=null,l="local-floor",c=1,u=null,d=null,f=null,p=null,m=null,x=null;const b=n.getContextAttributes();let v=null,y=null;const S=[],k=[],T=new bn;let M=null;const C=new so;C.layers.enable(1),C.viewport=new Cr;const E=new so;E.layers.enable(2),E.viewport=new Cr;const R=[C,E],A=new _Be;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(re){let ne=S[re];return ne===void 0&&(ne=new ZC,S[re]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(re){let ne=S[re];return ne===void 0&&(ne=new ZC,S[re]=ne),ne.getGripSpace()},this.getHand=function(re){let ne=S[re];return ne===void 0&&(ne=new ZC,S[re]=ne),ne.getHandSpace()};function F(re){const ne=k.indexOf(re.inputSource);if(ne===-1)return;const be=S[ne];be!==void 0&&(be.update(re.inputSource,re.frame,u||o),be.dispatchEvent({type:re.type,data:re.inputSource}))}function z(){i.removeEventListener("select",F),i.removeEventListener("selectstart",F),i.removeEventListener("selectend",F),i.removeEventListener("squeeze",F),i.removeEventListener("squeezestart",F),i.removeEventListener("squeezeend",F),i.removeEventListener("end",z),i.removeEventListener("inputsourceschange",P);for(let re=0;re<S.length;re++){const ne=k[re];ne!==null&&(k[re]=null,S[re].disconnect(ne))}D=null,I=null,e.setRenderTarget(v),m=null,p=null,f=null,i=null,y=null,K.stop(),r.isPresenting=!1,e.setPixelRatio(M),e.setSize(T.width,T.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(re){a=re,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(re){l=re,r.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return u||o},this.setReferenceSpace=function(re){u=re},this.getBaseLayer=function(){return p!==null?p:m},this.getBinding=function(){return f},this.getFrame=function(){return x},this.getSession=function(){return i},this.setSession=async function(re){if(i=re,i!==null){if(v=e.getRenderTarget(),i.addEventListener("select",F),i.addEventListener("selectstart",F),i.addEventListener("selectend",F),i.addEventListener("squeeze",F),i.addEventListener("squeezestart",F),i.addEventListener("squeezeend",F),i.addEventListener("end",z),i.addEventListener("inputsourceschange",P),b.xrCompatible!==!0&&await n.makeXRCompatible(),M=e.getPixelRatio(),e.getSize(T),i.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const ne={antialias:i.renderState.layers===void 0?b.antialias:!0,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:a};m=new XRWebGLLayer(i,n,ne),i.updateRenderState({baseLayer:m}),e.setPixelRatio(1),e.setSize(m.framebufferWidth,m.framebufferHeight,!1),y=new ym(m.framebufferWidth,m.framebufferHeight,{format:Xo,type:dh,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil})}else{let ne=null,be=null,me=null;b.depth&&(me=b.stencil?n.DEPTH24_STENCIL8:n.DEPTH_COMPONENT24,ne=b.stencil?ix:Wf,be=b.stencil?qf:Zd);const de={colorFormat:n.RGBA8,depthFormat:me,scaleFactor:a};f=new XRWebGLBinding(i,n),p=f.createProjectionLayer(de),i.updateRenderState({layers:[p]}),e.setPixelRatio(1),e.setSize(p.textureWidth,p.textureHeight,!1),y=new ym(p.textureWidth,p.textureHeight,{format:Xo,type:dh,depthTexture:new uee(p.textureWidth,p.textureHeight,be,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0});const Ce=e.properties.get(y);Ce.__ignoreDepthValues=p.ignoreDepthValues}y.isXRRenderTarget=!0,this.setFoveation(c),u=null,o=await i.requestReferenceSpace(l),K.setContext(i),K.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode};function P(re){for(let ne=0;ne<re.removed.length;ne++){const be=re.removed[ne],me=k.indexOf(be);me>=0&&(k[me]=null,S[me].disconnect(be))}for(let ne=0;ne<re.added.length;ne++){const be=re.added[ne];let me=k.indexOf(be);if(me===-1){for(let Ce=0;Ce<S.length;Ce++)if(Ce>=k.length){k.push(be),me=Ce;break}else if(k[Ce]===null){k[Ce]=be,me=Ce;break}if(me===-1)break}const de=S[me];de&&de.connect(be)}}const $=new qe,X=new qe;function V(re,ne,be){$.setFromMatrixPosition(ne.matrixWorld),X.setFromMatrixPosition(be.matrixWorld);const me=$.distanceTo(X),de=ne.projectionMatrix.elements,Ce=be.projectionMatrix.elements,ie=de[14]/(de[10]-1),ke=de[14]/(de[10]+1),Oe=(de[9]+1)/de[5],pe=(de[9]-1)/de[5],We=(de[8]-1)/de[0],G=(Ce[8]+1)/Ce[0],Y=ie*We,ue=ie*G,q=me/(-We+G),te=q*-We;ne.matrixWorld.decompose(re.position,re.quaternion,re.scale),re.translateX(te),re.translateZ(q),re.matrixWorld.compose(re.position,re.quaternion,re.scale),re.matrixWorldInverse.copy(re.matrixWorld).invert();const U=ie+q,he=ke+q,Me=Y-te,ge=ue+(me-te),B=Oe*ke/he*U,O=pe*ke/he*U;re.projectionMatrix.makePerspective(Me,ge,B,O,U,he),re.projectionMatrixInverse.copy(re.projectionMatrix).invert()}function Q(re,ne){ne===null?re.matrixWorld.copy(re.matrix):re.matrixWorld.multiplyMatrices(ne.matrixWorld,re.matrix),re.matrixWorldInverse.copy(re.matrixWorld).invert()}this.updateCamera=function(re){if(i===null)return;A.near=E.near=C.near=re.near,A.far=E.far=C.far=re.far,(D!==A.near||I!==A.far)&&(i.updateRenderState({depthNear:A.near,depthFar:A.far}),D=A.near,I=A.far);const ne=re.parent,be=A.cameras;Q(A,ne);for(let me=0;me<be.length;me++)Q(be[me],ne);be.length===2?V(A,C,E):A.projectionMatrix.copy(C.projectionMatrix),Z(re,A,ne)};function Z(re,ne,be){be===null?re.matrix.copy(ne.matrixWorld):(re.matrix.copy(be.matrixWorld),re.matrix.invert(),re.matrix.multiply(ne.matrixWorld)),re.matrix.decompose(re.position,re.quaternion,re.scale),re.updateMatrixWorld(!0),re.projectionMatrix.copy(ne.projectionMatrix),re.projectionMatrixInverse.copy(ne.projectionMatrixInverse),re.isPerspectiveCamera&&(re.fov=yy*2*Math.atan(1/re.projectionMatrix.elements[5]),re.zoom=1)}this.getCamera=function(){return A},this.getFoveation=function(){if(!(p===null&&m===null))return c},this.setFoveation=function(re){c=re,p!==null&&(p.fixedFoveation=re),m!==null&&m.fixedFoveation!==void 0&&(m.fixedFoveation=re)};let se=null;function H(re,ne){if(d=ne.getViewerPose(u||o),x=ne,d!==null){const be=d.views;m!==null&&(e.setRenderTargetFramebuffer(y,m.framebuffer),e.setRenderTarget(y));let me=!1;be.length!==A.cameras.length&&(A.cameras.length=0,me=!0);for(let de=0;de<be.length;de++){const Ce=be[de];let ie=null;if(m!==null)ie=m.getViewport(Ce);else{const Oe=f.getViewSubImage(p,Ce);ie=Oe.viewport,de===0&&(e.setRenderTargetTextures(y,Oe.colorTexture,p.ignoreDepthValues?void 0:Oe.depthStencilTexture),e.setRenderTarget(y))}let ke=R[de];ke===void 0&&(ke=new so,ke.layers.enable(de),ke.viewport=new Cr,R[de]=ke),ke.matrix.fromArray(Ce.transform.matrix),ke.matrix.decompose(ke.position,ke.quaternion,ke.scale),ke.projectionMatrix.fromArray(Ce.projectionMatrix),ke.projectionMatrixInverse.copy(ke.projectionMatrix).invert(),ke.viewport.set(ie.x,ie.y,ie.width,ie.height),de===0&&(A.matrix.copy(ke.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),me===!0&&A.cameras.push(ke)}}for(let be=0;be<S.length;be++){const me=k[be],de=S[be];me!==null&&de!==void 0&&de.update(me,ne,u||o)}se&&se(re,ne),ne.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:ne}),x=null}const K=new cee;K.setAnimationLoop(H),this.setAnimationLoop=function(re){se=re},this.dispose=function(){}}}function MBe(t,e){function n(v,y){v.matrixAutoUpdate===!0&&v.updateMatrix(),y.value.copy(v.matrix)}function r(v,y){y.color.getRGB(v.fogColor.value,see(t)),y.isFog?(v.fogNear.value=y.near,v.fogFar.value=y.far):y.isFogExp2&&(v.fogDensity.value=y.density)}function i(v,y,S,k,T){y.isMeshBasicMaterial||y.isMeshLambertMaterial?a(v,y):y.isMeshToonMaterial?(a(v,y),f(v,y)):y.isMeshPhongMaterial?(a(v,y),d(v,y)):y.isMeshStandardMaterial?(a(v,y),p(v,y),y.isMeshPhysicalMaterial&&m(v,y,T)):y.isMeshMatcapMaterial?(a(v,y),x(v,y)):y.isMeshDepthMaterial?a(v,y):y.isMeshDistanceMaterial?(a(v,y),b(v,y)):y.isMeshNormalMaterial?a(v,y):y.isLineBasicMaterial?(o(v,y),y.isLineDashedMaterial&&l(v,y)):y.isPointsMaterial?c(v,y,S,k):y.isSpriteMaterial?u(v,y):y.isShadowMaterial?(v.color.value.copy(y.color),v.opacity.value=y.opacity):y.isShaderMaterial&&(y.uniformsNeedUpdate=!1)}function a(v,y){v.opacity.value=y.opacity,y.color&&v.diffuse.value.copy(y.color),y.emissive&&v.emissive.value.copy(y.emissive).multiplyScalar(y.emissiveIntensity),y.map&&(v.map.value=y.map,n(y.map,v.mapTransform)),y.alphaMap&&(v.alphaMap.value=y.alphaMap,n(y.alphaMap,v.alphaMapTransform)),y.bumpMap&&(v.bumpMap.value=y.bumpMap,n(y.bumpMap,v.bumpMapTransform),v.bumpScale.value=y.bumpScale,y.side===Us&&(v.bumpScale.value*=-1)),y.normalMap&&(v.normalMap.value=y.normalMap,n(y.normalMap,v.normalMapTransform),v.normalScale.value.copy(y.normalScale),y.side===Us&&v.normalScale.value.negate()),y.displacementMap&&(v.displacementMap.value=y.displacementMap,n(y.displacementMap,v.displacementMapTransform),v.displacementScale.value=y.displacementScale,v.displacementBias.value=y.displacementBias),y.emissiveMap&&(v.emissiveMap.value=y.emissiveMap,n(y.emissiveMap,v.emissiveMapTransform)),y.specularMap&&(v.specularMap.value=y.specularMap,n(y.specularMap,v.specularMapTransform)),y.alphaTest>0&&(v.alphaTest.value=y.alphaTest);const S=e.get(y).envMap;if(S&&(v.envMap.value=S,v.flipEnvMap.value=S.isCubeTexture&&S.isRenderTargetTexture===!1?-1:1,v.reflectivity.value=y.reflectivity,v.ior.value=y.ior,v.refractionRatio.value=y.refractionRatio),y.lightMap){v.lightMap.value=y.lightMap;const k=t._useLegacyLights===!0?Math.PI:1;v.lightMapIntensity.value=y.lightMapIntensity*k,n(y.lightMap,v.lightMapTransform)}y.aoMap&&(v.aoMap.value=y.aoMap,v.aoMapIntensity.value=y.aoMapIntensity,n(y.aoMap,v.aoMapTransform))}function o(v,y){v.diffuse.value.copy(y.color),v.opacity.value=y.opacity,y.map&&(v.map.value=y.map,n(y.map,v.mapTransform))}function l(v,y){v.dashSize.value=y.dashSize,v.totalSize.value=y.dashSize+y.gapSize,v.scale.value=y.scale}function c(v,y,S,k){v.diffuse.value.copy(y.color),v.opacity.value=y.opacity,v.size.value=y.size*S,v.scale.value=k*.5,y.map&&(v.map.value=y.map,n(y.map,v.uvTransform)),y.alphaMap&&(v.alphaMap.value=y.alphaMap,n(y.alphaMap,v.alphaMapTransform)),y.alphaTest>0&&(v.alphaTest.value=y.alphaTest)}function u(v,y){v.diffuse.value.copy(y.color),v.opacity.value=y.opacity,v.rotation.value=y.rotation,y.map&&(v.map.value=y.map,n(y.map,v.mapTransform)),y.alphaMap&&(v.alphaMap.value=y.alphaMap,n(y.alphaMap,v.alphaMapTransform)),y.alphaTest>0&&(v.alphaTest.value=y.alphaTest)}function d(v,y){v.specular.value.copy(y.specular),v.shininess.value=Math.max(y.shininess,1e-4)}function f(v,y){y.gradientMap&&(v.gradientMap.value=y.gradientMap)}function p(v,y){v.metalness.value=y.metalness,y.metalnessMap&&(v.metalnessMap.value=y.metalnessMap,n(y.metalnessMap,v.metalnessMapTransform)),v.roughness.value=y.roughness,y.roughnessMap&&(v.roughnessMap.value=y.roughnessMap,n(y.roughnessMap,v.roughnessMapTransform)),e.get(y).envMap&&(v.envMapIntensity.value=y.envMapIntensity)}function m(v,y,S){v.ior.value=y.ior,y.sheen>0&&(v.sheenColor.value.copy(y.sheenColor).multiplyScalar(y.sheen),v.sheenRoughness.value=y.sheenRoughness,y.sheenColorMap&&(v.sheenColorMap.value=y.sheenColorMap,n(y.sheenColorMap,v.sheenColorMapTransform)),y.sheenRoughnessMap&&(v.sheenRoughnessMap.value=y.sheenRoughnessMap,n(y.sheenRoughnessMap,v.sheenRoughnessMapTransform))),y.clearcoat>0&&(v.clearcoat.value=y.clearcoat,v.clearcoatRoughness.value=y.clearcoatRoughness,y.clearcoatMap&&(v.clearcoatMap.value=y.clearcoatMap,n(y.clearcoatMap,v.clearcoatMapTransform)),y.clearcoatRoughnessMap&&(v.clearcoatRoughnessMap.value=y.clearcoatRoughnessMap,n(y.clearcoatRoughnessMap,v.clearcoatRoughnessMapTransform)),y.clearcoatNormalMap&&(v.clearcoatNormalMap.value=y.clearcoatNormalMap,n(y.clearcoatNormalMap,v.clearcoatNormalMapTransform),v.clearcoatNormalScale.value.copy(y.clearcoatNormalScale),y.side===Us&&v.clearcoatNormalScale.value.negate())),y.iridescence>0&&(v.iridescence.value=y.iridescence,v.iridescenceIOR.value=y.iridescenceIOR,v.iridescenceThicknessMinimum.value=y.iridescenceThicknessRange[0],v.iridescenceThicknessMaximum.value=y.iridescenceThicknessRange[1],y.iridescenceMap&&(v.iridescenceMap.value=y.iridescenceMap,n(y.iridescenceMap,v.iridescenceMapTransform)),y.iridescenceThicknessMap&&(v.iridescenceThicknessMap.value=y.iridescenceThicknessMap,n(y.iridescenceThicknessMap,v.iridescenceThicknessMapTransform))),y.transmission>0&&(v.transmission.value=y.transmission,v.transmissionSamplerMap.value=S.texture,v.transmissionSamplerSize.value.set(S.width,S.height),y.transmissionMap&&(v.transmissionMap.value=y.transmissionMap,n(y.transmissionMap,v.transmissionMapTransform)),v.thickness.value=y.thickness,y.thicknessMap&&(v.thicknessMap.value=y.thicknessMap,n(y.thicknessMap,v.thicknessMapTransform)),v.attenuationDistance.value=y.attenuationDistance,v.attenuationColor.value.copy(y.attenuationColor)),y.anisotropy>0&&(v.anisotropyVector.value.set(y.anisotropy*Math.cos(y.anisotropyRotation),y.anisotropy*Math.sin(y.anisotropyRotation)),y.anisotropyMap&&(v.anisotropyMap.value=y.anisotropyMap,n(y.anisotropyMap,v.anisotropyMapTransform))),v.specularIntensity.value=y.specularIntensity,v.specularColor.value.copy(y.specularColor),y.specularColorMap&&(v.specularColorMap.value=y.specularColorMap,n(y.specularColorMap,v.specularColorMapTransform)),y.specularIntensityMap&&(v.specularIntensityMap.value=y.specularIntensityMap,n(y.specularIntensityMap,v.specularIntensityMapTransform))}function x(v,y){y.matcap&&(v.matcap.value=y.matcap)}function b(v,y){const S=e.get(y).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 kBe(t,e,n,r){let i={},a={},o=[];const l=n.isWebGL2?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0;function c(S,k){const T=k.program;r.uniformBlockBinding(S,T)}function u(S,k){let T=i[S.id];T===void 0&&(x(S),T=d(S),i[S.id]=T,S.addEventListener("dispose",v));const M=k.program;r.updateUBOMapping(S,M);const C=e.render.frame;a[S.id]!==C&&(p(S),a[S.id]=C)}function d(S){const k=f();S.__bindingPointIndex=k;const T=t.createBuffer(),M=S.__size,C=S.usage;return t.bindBuffer(t.UNIFORM_BUFFER,T),t.bufferData(t.UNIFORM_BUFFER,M,C),t.bindBuffer(t.UNIFORM_BUFFER,null),t.bindBufferBase(t.UNIFORM_BUFFER,k,T),T}function f(){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 k=i[S.id],T=S.uniforms,M=S.__cache;t.bindBuffer(t.UNIFORM_BUFFER,k);for(let C=0,E=T.length;C<E;C++){const R=T[C];if(m(R,C,M)===!0){const A=R.__offset,D=Array.isArray(R.value)?R.value:[R.value];let I=0;for(let F=0;F<D.length;F++){const z=D[F],P=b(z);typeof z=="number"?(R.__data[0]=z,t.bufferSubData(t.UNIFORM_BUFFER,A+I,R.__data)):z.isMatrix3?(R.__data[0]=z.elements[0],R.__data[1]=z.elements[1],R.__data[2]=z.elements[2],R.__data[3]=z.elements[0],R.__data[4]=z.elements[3],R.__data[5]=z.elements[4],R.__data[6]=z.elements[5],R.__data[7]=z.elements[0],R.__data[8]=z.elements[6],R.__data[9]=z.elements[7],R.__data[10]=z.elements[8],R.__data[11]=z.elements[0]):(z.toArray(R.__data,I),I+=P.storage/Float32Array.BYTES_PER_ELEMENT)}t.bufferSubData(t.UNIFORM_BUFFER,A,R.__data)}}t.bindBuffer(t.UNIFORM_BUFFER,null)}function m(S,k,T){const M=S.value;if(T[k]===void 0){if(typeof M=="number")T[k]=M;else{const C=Array.isArray(M)?M:[M],E=[];for(let R=0;R<C.length;R++)E.push(C[R].clone());T[k]=E}return!0}else if(typeof M=="number"){if(T[k]!==M)return T[k]=M,!0}else{const C=Array.isArray(T[k])?T[k]:[T[k]],E=Array.isArray(M)?M:[M];for(let R=0;R<C.length;R++){const A=C[R];if(A.equals(E[R])===!1)return A.copy(E[R]),!0}}return!1}function x(S){const k=S.uniforms;let T=0;const M=16;let C=0;for(let E=0,R=k.length;E<R;E++){const A=k[E],D={boundary:0,storage:0},I=Array.isArray(A.value)?A.value:[A.value];for(let F=0,z=I.length;F<z;F++){const P=I[F],$=b(P);D.boundary+=$.boundary,D.storage+=$.storage}if(A.__data=new Float32Array(D.storage/Float32Array.BYTES_PER_ELEMENT),A.__offset=T,E>0){C=T%M;const F=M-C;C!==0&&F-D.boundary<0&&(T+=M-C,A.__offset=T)}T+=D.storage}return C=T%M,C>0&&(T+=M-C),S.__size=T,S.__cache={},this}function b(S){const k={boundary:0,storage:0};return typeof S=="number"?(k.boundary=4,k.storage=4):S.isVector2?(k.boundary=8,k.storage=8):S.isVector3||S.isColor?(k.boundary=16,k.storage=12):S.isVector4?(k.boundary=16,k.storage=16):S.isMatrix3?(k.boundary=48,k.storage=48):S.isMatrix4?(k.boundary=64,k.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),k}function v(S){const k=S.target;k.removeEventListener("dispose",v);const T=o.indexOf(k.__bindingPointIndex);o.splice(T,1),t.deleteBuffer(i[k.id]),delete i[k.id],delete a[k.id]}function y(){for(const S in i)t.deleteBuffer(i[S]);o=[],i={},a={}}return{bind:c,update:u,dispose:y}}class SD{constructor(e={}){const{canvas:n=SFe(),context:r=null,depth:i=!0,stencil:a=!0,alpha:o=!1,antialias:l=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:u=!1,powerPreference:d="default",failIfMajorPerformanceCaveat:f=!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 b=null,v=null;const y=[],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=La,this._useLegacyLights=!1,this.toneMapping=uh,this.toneMappingExposure=1;const k=this;let T=!1,M=0,C=0,E=null,R=-1,A=null;const D=new Cr,I=new Cr;let F=null;const z=new Zt(0);let P=0,$=n.width,X=n.height,V=1,Q=null,Z=null;const se=new Cr(0,0,$,X),H=new Cr(0,0,$,X);let K=!1;const re=new v2;let ne=!1,be=!1,me=null;const de=new zr,Ce=new bn,ie=new qe,ke={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Oe(){return E===null?V:1}let pe=r;function We(Ae,et){for(let ct=0;ct<Ae.length;ct++){const ut=Ae[ct],lt=n.getContext(ut,et);if(lt!==null)return lt}return null}try{const Ae={alpha:!0,depth:i,stencil:a,antialias:l,premultipliedAlpha:c,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if("setAttribute"in n&&n.setAttribute("data-engine",`three.js r${x2}`),n.addEventListener("webglcontextlost",rt,!1),n.addEventListener("webglcontextrestored",Ee,!1),n.addEventListener("webglcontextcreationerror",Ke,!1),pe===null){const et=["webgl2","webgl","experimental-webgl"];if(k.isWebGL1Renderer===!0&&et.shift(),pe=We(et,Ae),pe===null)throw We(et)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext<"u"&&pe instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),pe.getShaderPrecisionFormat===void 0&&(pe.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Ae){throw console.error("THREE.WebGLRenderer: "+Ae.message),Ae}let G,Y,ue,q,te,U,he,Me,ge,B,O,ee,le,_e,ve,ae,Fe,Be,$e,He,xe,Pe,ze,we;function Xe(){G=new FUe(pe),Y=new CUe(pe,G,e),G.init(Y),Pe=new wBe(pe,G,Y),ue=new yBe(pe,G,Y),q=new zUe(pe),te=new aBe,U=new vBe(pe,G,ue,te,Y,Pe,q),he=new jUe(k),Me=new LUe(k),ge=new WFe(pe,Y),ze=new TUe(pe,G,ge,Y),B=new IUe(pe,ge,q,ze),O=new VUe(pe,B,ge,q),$e=new $Ue(pe,Y,U),ae=new PUe(te),ee=new iBe(k,he,Me,G,Y,ze,ae),le=new MBe(k,te),_e=new oBe,ve=new fBe(G,Y),Be=new EUe(k,he,Me,ue,O,p,c),Fe=new bBe(k,O,Y),we=new kBe(pe,q,Y,ue),He=new AUe(pe,G,q,Y),xe=new UUe(pe,G,q,Y),q.programs=ee.programs,k.capabilities=Y,k.extensions=G,k.properties=te,k.renderLists=_e,k.shadowMap=Fe,k.state=ue,k.info=q}Xe();const Ne=new NBe(k,pe);this.xr=Ne,this.getContext=function(){return pe},this.getContextAttributes=function(){return pe.getContextAttributes()},this.forceContextLoss=function(){const Ae=G.get("WEBGL_lose_context");Ae&&Ae.loseContext()},this.forceContextRestore=function(){const Ae=G.get("WEBGL_lose_context");Ae&&Ae.restoreContext()},this.getPixelRatio=function(){return V},this.setPixelRatio=function(Ae){Ae!==void 0&&(V=Ae,this.setSize($,X,!1))},this.getSize=function(Ae){return Ae.set($,X)},this.setSize=function(Ae,et,ct=!0){if(Ne.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}$=Ae,X=et,n.width=Math.floor(Ae*V),n.height=Math.floor(et*V),ct===!0&&(n.style.width=Ae+"px",n.style.height=et+"px"),this.setViewport(0,0,Ae,et)},this.getDrawingBufferSize=function(Ae){return Ae.set($*V,X*V).floor()},this.setDrawingBufferSize=function(Ae,et,ct){$=Ae,X=et,V=ct,n.width=Math.floor(Ae*ct),n.height=Math.floor(et*ct),this.setViewport(0,0,Ae,et)},this.getCurrentViewport=function(Ae){return Ae.copy(D)},this.getViewport=function(Ae){return Ae.copy(se)},this.setViewport=function(Ae,et,ct,ut){Ae.isVector4?se.set(Ae.x,Ae.y,Ae.z,Ae.w):se.set(Ae,et,ct,ut),ue.viewport(D.copy(se).multiplyScalar(V).floor())},this.getScissor=function(Ae){return Ae.copy(H)},this.setScissor=function(Ae,et,ct,ut){Ae.isVector4?H.set(Ae.x,Ae.y,Ae.z,Ae.w):H.set(Ae,et,ct,ut),ue.scissor(I.copy(H).multiplyScalar(V).floor())},this.getScissorTest=function(){return K},this.setScissorTest=function(Ae){ue.setScissorTest(K=Ae)},this.setOpaqueSort=function(Ae){Q=Ae},this.setTransparentSort=function(Ae){Z=Ae},this.getClearColor=function(Ae){return Ae.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(Ae=!0,et=!0,ct=!0){let ut=0;if(Ae){let lt=!1;if(E!==null){const Et=E.texture.format;lt=Et===GJ||Et===VJ||Et===$J}if(lt){const Et=E.texture.type,fe=Et===dh||Et===Zd||Et===iL||Et===qf||Et===BJ||Et===HJ,De=Be.getClearColor(),Ve=Be.getClearAlpha(),Se=De.r,Le=De.g,tt=De.b;fe?(m[0]=Se,m[1]=Le,m[2]=tt,m[3]=Ve,pe.clearBufferuiv(pe.COLOR,0,m)):(x[0]=Se,x[1]=Le,x[2]=tt,x[3]=Ve,pe.clearBufferiv(pe.COLOR,0,x))}else ut|=pe.COLOR_BUFFER_BIT}et&&(ut|=pe.DEPTH_BUFFER_BIT),ct&&(ut|=pe.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),pe.clear(ut)},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",rt,!1),n.removeEventListener("webglcontextrestored",Ee,!1),n.removeEventListener("webglcontextcreationerror",Ke,!1),_e.dispose(),ve.dispose(),te.dispose(),he.dispose(),Me.dispose(),O.dispose(),ze.dispose(),we.dispose(),ee.dispose(),Ne.dispose(),Ne.removeEventListener("sessionstart",Bt),Ne.removeEventListener("sessionend",Lt),me&&(me.dispose(),me=null),vn.stop()};function rt(Ae){Ae.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),T=!0}function Ee(){console.log("THREE.WebGLRenderer: Context Restored."),T=!1;const Ae=q.autoReset,et=Fe.enabled,ct=Fe.autoUpdate,ut=Fe.needsUpdate,lt=Fe.type;Xe(),q.autoReset=Ae,Fe.enabled=et,Fe.autoUpdate=ct,Fe.needsUpdate=ut,Fe.type=lt}function Ke(Ae){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",Ae.statusMessage)}function Ue(Ae){const et=Ae.target;et.removeEventListener("dispose",Ue),W(et)}function W(Ae){je(Ae),te.remove(Ae)}function je(Ae){const et=te.get(Ae).programs;et!==void 0&&(et.forEach(function(ct){ee.releaseProgram(ct)}),Ae.isShaderMaterial&&ee.releaseShaderCache(Ae))}this.renderBufferDirect=function(Ae,et,ct,ut,lt,Et){et===null&&(et=ke);const fe=lt.isMesh&<.matrixWorld.determinant()<0,De=Nn(Ae,et,ct,ut,lt);ue.setMaterial(ut,fe);let Ve=ct.index,Se=1;if(ut.wireframe===!0){if(Ve=B.getWireframeAttribute(ct),Ve===void 0)return;Se=2}const Le=ct.drawRange,tt=ct.attributes.position;let Qe=Le.start*Se,Tt=(Le.start+Le.count)*Se;Et!==null&&(Qe=Math.max(Qe,Et.start*Se),Tt=Math.min(Tt,(Et.start+Et.count)*Se)),Ve!==null?(Qe=Math.max(Qe,0),Tt=Math.min(Tt,Ve.count)):tt!=null&&(Qe=Math.max(Qe,0),Tt=Math.min(Tt,tt.count));const At=Tt-Qe;if(At<0||At===1/0)return;ze.setup(lt,ut,De,ct,Ve);let Ft,jt=He;if(Ve!==null&&(Ft=ge.get(Ve),jt=xe,jt.setIndex(Ft)),lt.isMesh)ut.wireframe===!0?(ue.setLineWidth(ut.wireframeLinewidth*Oe()),jt.setMode(pe.LINES)):jt.setMode(pe.TRIANGLES);else if(lt.isLine){let Mt=ut.linewidth;Mt===void 0&&(Mt=1),ue.setLineWidth(Mt*Oe()),lt.isLineSegments?jt.setMode(pe.LINES):lt.isLineLoop?jt.setMode(pe.LINE_LOOP):jt.setMode(pe.LINE_STRIP)}else lt.isPoints?jt.setMode(pe.POINTS):lt.isSprite&&jt.setMode(pe.TRIANGLES);if(lt.isBatchedMesh)jt.renderMultiDraw(lt._multiDrawStarts,lt._multiDrawCounts,lt._multiDrawCount);else if(lt.isInstancedMesh)jt.renderInstances(Qe,At,lt.count);else if(ct.isInstancedBufferGeometry){const Mt=ct._maxInstanceCount!==void 0?ct._maxInstanceCount:1/0,Jt=Math.min(ct.instanceCount,Mt);jt.renderInstances(Qe,At,Jt)}else jt.render(Qe,At)};function Ye(Ae,et,ct){Ae.transparent===!0&&Ae.side===gu&&Ae.forceSinglePass===!1?(Ae.side=Us,Ae.needsUpdate=!0,sr(Ae,et,ct),Ae.side=Th,Ae.needsUpdate=!0,sr(Ae,et,ct),Ae.side=gu):sr(Ae,et,ct)}this.compile=function(Ae,et,ct=null){ct===null&&(ct=Ae),v=ve.get(ct),v.init(),S.push(v),ct.traverseVisible(function(lt){lt.isLight&<.layers.test(et.layers)&&(v.pushLight(lt),lt.castShadow&&v.pushShadow(lt))}),Ae!==ct&&Ae.traverseVisible(function(lt){lt.isLight&<.layers.test(et.layers)&&(v.pushLight(lt),lt.castShadow&&v.pushShadow(lt))}),v.setupLights(k._useLegacyLights);const ut=new Set;return Ae.traverse(function(lt){const Et=lt.material;if(Et)if(Array.isArray(Et))for(let fe=0;fe<Et.length;fe++){const De=Et[fe];Ye(De,ct,lt),ut.add(De)}else Ye(Et,ct,lt),ut.add(Et)}),S.pop(),v=null,ut},this.compileAsync=function(Ae,et,ct=null){const ut=this.compile(Ae,et,ct);return new Promise(lt=>{function Et(){if(ut.forEach(function(fe){te.get(fe).currentProgram.isReady()&&ut.delete(fe)}),ut.size===0){lt(Ae);return}setTimeout(Et,10)}G.get("KHR_parallel_shader_compile")!==null?Et():setTimeout(Et,10)})};let bt=null;function pt(Ae){bt&&bt(Ae)}function Bt(){vn.stop()}function Lt(){vn.start()}const vn=new cee;vn.setAnimationLoop(pt),typeof self<"u"&&vn.setContext(self),this.setAnimationLoop=function(Ae){bt=Ae,Ne.setAnimationLoop(Ae),Ae===null?vn.stop():vn.start()},Ne.addEventListener("sessionstart",Bt),Ne.addEventListener("sessionend",Lt),this.render=function(Ae,et){if(et!==void 0&&et.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(T===!0)return;Ae.matrixWorldAutoUpdate===!0&&Ae.updateMatrixWorld(),et.parent===null&&et.matrixWorldAutoUpdate===!0&&et.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(et),et=Ne.getCamera()),Ae.isScene===!0&&Ae.onBeforeRender(k,Ae,et,E),v=ve.get(Ae,S.length),v.init(),S.push(v),de.multiplyMatrices(et.projectionMatrix,et.matrixWorldInverse),re.setFromProjectionMatrix(de),be=this.localClippingEnabled,ne=ae.init(this.clippingPlanes,be),b=_e.get(Ae,y.length),b.init(),y.push(b),cn(Ae,et,0,k.sortObjects),b.finish(),k.sortObjects===!0&&b.sort(Q,Z),this.info.render.frame++,ne===!0&&ae.beginShadows();const ct=v.state.shadowsArray;if(Fe.render(ct,Ae,et),ne===!0&&ae.endShadows(),this.info.autoReset===!0&&this.info.reset(),Be.render(b,Ae),v.setupLights(k._useLegacyLights),et.isArrayCamera){const ut=et.cameras;for(let lt=0,Et=ut.length;lt<Et;lt++){const fe=ut[lt];rr(b,Ae,fe,fe.viewport)}}else rr(b,Ae,et);E!==null&&(U.updateMultisampleRenderTarget(E),U.updateRenderTargetMipmap(E)),Ae.isScene===!0&&Ae.onAfterRender(k,Ae,et),ze.resetDefaultState(),R=-1,A=null,S.pop(),S.length>0?v=S[S.length-1]:v=null,y.pop(),y.length>0?b=y[y.length-1]:b=null};function cn(Ae,et,ct,ut){if(Ae.visible===!1)return;if(Ae.layers.test(et.layers)){if(Ae.isGroup)ct=Ae.renderOrder;else if(Ae.isLOD)Ae.autoUpdate===!0&&Ae.update(et);else if(Ae.isLight)v.pushLight(Ae),Ae.castShadow&&v.pushShadow(Ae);else if(Ae.isSprite){if(!Ae.frustumCulled||re.intersectsSprite(Ae)){ut&&ie.setFromMatrixPosition(Ae.matrixWorld).applyMatrix4(de);const fe=O.update(Ae),De=Ae.material;De.visible&&b.push(Ae,fe,De,ct,ie.z,null)}}else if((Ae.isMesh||Ae.isLine||Ae.isPoints)&&(!Ae.frustumCulled||re.intersectsObject(Ae))){const fe=O.update(Ae),De=Ae.material;if(ut&&(Ae.boundingSphere!==void 0?(Ae.boundingSphere===null&&Ae.computeBoundingSphere(),ie.copy(Ae.boundingSphere.center)):(fe.boundingSphere===null&&fe.computeBoundingSphere(),ie.copy(fe.boundingSphere.center)),ie.applyMatrix4(Ae.matrixWorld).applyMatrix4(de)),Array.isArray(De)){const Ve=fe.groups;for(let Se=0,Le=Ve.length;Se<Le;Se++){const tt=Ve[Se],Qe=De[tt.materialIndex];Qe&&Qe.visible&&b.push(Ae,fe,Qe,ct,ie.z,tt)}}else De.visible&&b.push(Ae,fe,De,ct,ie.z,null)}}const Et=Ae.children;for(let fe=0,De=Et.length;fe<De;fe++)cn(Et[fe],et,ct,ut)}function rr(Ae,et,ct,ut){const lt=Ae.opaque,Et=Ae.transmissive,fe=Ae.transparent;v.setupLightsView(ct),ne===!0&&ae.setGlobalState(k.clippingPlanes,ct),Et.length>0&&Vn(lt,Et,et,ct),ut&&ue.viewport(D.copy(ut)),lt.length>0&&Jn(lt,et,ct),Et.length>0&&Jn(Et,et,ct),fe.length>0&&Jn(fe,et,ct),ue.buffers.depth.setTest(!0),ue.buffers.depth.setMask(!0),ue.buffers.color.setMask(!0),ue.setPolygonOffset(!1)}function Vn(Ae,et,ct,ut){if((ct.isScene===!0?ct.overrideMaterial:null)!==null)return;const Et=Y.isWebGL2;me===null&&(me=new ym(1,1,{generateMipmaps:!0,type:G.has("EXT_color_buffer_half_float")?xy:dh,minFilter:gy,samples:Et?4:0})),k.getDrawingBufferSize(Ce),Et?me.setSize(Ce.x,Ce.y):me.setSize(rN(Ce.x),rN(Ce.y));const fe=k.getRenderTarget();k.setRenderTarget(me),k.getClearColor(z),P=k.getClearAlpha(),P<1&&k.setClearColor(16777215,.5),k.clear();const De=k.toneMapping;k.toneMapping=uh,Jn(Ae,ct,ut),U.updateMultisampleRenderTarget(me),U.updateRenderTargetMipmap(me);let Ve=!1;for(let Se=0,Le=et.length;Se<Le;Se++){const tt=et[Se],Qe=tt.object,Tt=tt.geometry,At=tt.material,Ft=tt.group;if(At.side===gu&&Qe.layers.test(ut.layers)){const jt=At.side;At.side=Us,At.needsUpdate=!0,gn(Qe,ct,ut,Tt,At,Ft),At.side=jt,At.needsUpdate=!0,Ve=!0}}Ve===!0&&(U.updateMultisampleRenderTarget(me),U.updateRenderTargetMipmap(me)),k.setRenderTarget(fe),k.setClearColor(z,P),k.toneMapping=De}function Jn(Ae,et,ct){const ut=et.isScene===!0?et.overrideMaterial:null;for(let lt=0,Et=Ae.length;lt<Et;lt++){const fe=Ae[lt],De=fe.object,Ve=fe.geometry,Se=ut===null?fe.material:ut,Le=fe.group;De.layers.test(ct.layers)&&gn(De,et,ct,Ve,Se,Le)}}function gn(Ae,et,ct,ut,lt,Et){Ae.onBeforeRender(k,et,ct,ut,lt,Et),Ae.modelViewMatrix.multiplyMatrices(ct.matrixWorldInverse,Ae.matrixWorld),Ae.normalMatrix.getNormalMatrix(Ae.modelViewMatrix),lt.onBeforeRender(k,et,ct,ut,Ae,Et),lt.transparent===!0&<.side===gu&<.forceSinglePass===!1?(lt.side=Us,lt.needsUpdate=!0,k.renderBufferDirect(ct,et,ut,lt,Ae,Et),lt.side=Th,lt.needsUpdate=!0,k.renderBufferDirect(ct,et,ut,lt,Ae,Et),lt.side=gu):k.renderBufferDirect(ct,et,ut,lt,Ae,Et),Ae.onAfterRender(k,et,ct,ut,lt,Et)}function sr(Ae,et,ct){et.isScene!==!0&&(et=ke);const ut=te.get(Ae),lt=v.state.lights,Et=v.state.shadowsArray,fe=lt.state.version,De=ee.getParameters(Ae,lt.state,Et,et,ct),Ve=ee.getProgramCacheKey(De);let Se=ut.programs;ut.environment=Ae.isMeshStandardMaterial?et.environment:null,ut.fog=et.fog,ut.envMap=(Ae.isMeshStandardMaterial?Me:he).get(Ae.envMap||ut.environment),Se===void 0&&(Ae.addEventListener("dispose",Ue),Se=new Map,ut.programs=Se);let Le=Se.get(Ve);if(Le!==void 0){if(ut.currentProgram===Le&&ut.lightsStateVersion===fe)return Xn(Ae,De),Le}else De.uniforms=ee.getUniforms(Ae),Ae.onBuild(ct,De,k),Ae.onBeforeCompile(De,k),Le=ee.acquireProgram(De,Ve),Se.set(Ve,Le),ut.uniforms=De.uniforms;const tt=ut.uniforms;return(!Ae.isShaderMaterial&&!Ae.isRawShaderMaterial||Ae.clipping===!0)&&(tt.clippingPlanes=ae.uniform),Xn(Ae,De),ut.needsLights=ai(Ae),ut.lightsStateVersion=fe,ut.needsLights&&(tt.ambientLightColor.value=lt.state.ambient,tt.lightProbe.value=lt.state.probe,tt.directionalLights.value=lt.state.directional,tt.directionalLightShadows.value=lt.state.directionalShadow,tt.spotLights.value=lt.state.spot,tt.spotLightShadows.value=lt.state.spotShadow,tt.rectAreaLights.value=lt.state.rectArea,tt.ltc_1.value=lt.state.rectAreaLTC1,tt.ltc_2.value=lt.state.rectAreaLTC2,tt.pointLights.value=lt.state.point,tt.pointLightShadows.value=lt.state.pointShadow,tt.hemisphereLights.value=lt.state.hemi,tt.directionalShadowMap.value=lt.state.directionalShadowMap,tt.directionalShadowMatrix.value=lt.state.directionalShadowMatrix,tt.spotShadowMap.value=lt.state.spotShadowMap,tt.spotLightMatrix.value=lt.state.spotLightMatrix,tt.spotLightMap.value=lt.state.spotLightMap,tt.pointShadowMap.value=lt.state.pointShadowMap,tt.pointShadowMatrix.value=lt.state.pointShadowMatrix),ut.currentProgram=Le,ut.uniformsList=null,Le}function Gn(Ae){if(Ae.uniformsList===null){const et=Ae.currentProgram.getUniforms();Ae.uniformsList=D1.seqWithValue(et.seq,Ae.uniforms)}return Ae.uniformsList}function Xn(Ae,et){const ct=te.get(Ae);ct.outputColorSpace=et.outputColorSpace,ct.batching=et.batching,ct.instancing=et.instancing,ct.instancingColor=et.instancingColor,ct.skinning=et.skinning,ct.morphTargets=et.morphTargets,ct.morphNormals=et.morphNormals,ct.morphColors=et.morphColors,ct.morphTargetsCount=et.morphTargetsCount,ct.numClippingPlanes=et.numClippingPlanes,ct.numIntersection=et.numClipIntersection,ct.vertexAlphas=et.vertexAlphas,ct.vertexTangents=et.vertexTangents,ct.toneMapping=et.toneMapping}function Nn(Ae,et,ct,ut,lt){et.isScene!==!0&&(et=ke),U.resetTextureUnits();const Et=et.fog,fe=ut.isMeshStandardMaterial?et.environment:null,De=E===null?k.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:Vu,Ve=(ut.isMeshStandardMaterial?Me:he).get(ut.envMap||fe),Se=ut.vertexColors===!0&&!!ct.attributes.color&&ct.attributes.color.itemSize===4,Le=!!ct.attributes.tangent&&(!!ut.normalMap||ut.anisotropy>0),tt=!!ct.morphAttributes.position,Qe=!!ct.morphAttributes.normal,Tt=!!ct.morphAttributes.color;let At=uh;ut.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(At=k.toneMapping);const Ft=ct.morphAttributes.position||ct.morphAttributes.normal||ct.morphAttributes.color,jt=Ft!==void 0?Ft.length:0,Mt=te.get(ut),Jt=v.state.lights;if(ne===!0&&(be===!0||Ae!==A)){const ir=Ae===A&&ut.id===R;ae.setState(ut,Ae,ir)}let Ht=!1;ut.version===Mt.__version?(Mt.needsLights&&Mt.lightsStateVersion!==Jt.state.version||Mt.outputColorSpace!==De||lt.isBatchedMesh&&Mt.batching===!1||!lt.isBatchedMesh&&Mt.batching===!0||lt.isInstancedMesh&&Mt.instancing===!1||!lt.isInstancedMesh&&Mt.instancing===!0||lt.isSkinnedMesh&&Mt.skinning===!1||!lt.isSkinnedMesh&&Mt.skinning===!0||lt.isInstancedMesh&&Mt.instancingColor===!0&<.instanceColor===null||lt.isInstancedMesh&&Mt.instancingColor===!1&<.instanceColor!==null||Mt.envMap!==Ve||ut.fog===!0&&Mt.fog!==Et||Mt.numClippingPlanes!==void 0&&(Mt.numClippingPlanes!==ae.numPlanes||Mt.numIntersection!==ae.numIntersection)||Mt.vertexAlphas!==Se||Mt.vertexTangents!==Le||Mt.morphTargets!==tt||Mt.morphNormals!==Qe||Mt.morphColors!==Tt||Mt.toneMapping!==At||Y.isWebGL2===!0&&Mt.morphTargetsCount!==jt)&&(Ht=!0):(Ht=!0,Mt.__version=ut.version);let hn=Mt.currentProgram;Ht===!0&&(hn=sr(ut,et,lt));let un=!1,Mn=!1,Gt=!1;const on=hn.getUniforms(),dn=Mt.uniforms;if(ue.useProgram(hn.program)&&(un=!0,Mn=!0,Gt=!0),ut.id!==R&&(R=ut.id,Mn=!0),un||A!==Ae){on.setValue(pe,"projectionMatrix",Ae.projectionMatrix),on.setValue(pe,"viewMatrix",Ae.matrixWorldInverse);const ir=on.map.cameraPosition;ir!==void 0&&ir.setValue(pe,ie.setFromMatrixPosition(Ae.matrixWorld)),Y.logarithmicDepthBuffer&&on.setValue(pe,"logDepthBufFC",2/(Math.log(Ae.far+1)/Math.LN2)),(ut.isMeshPhongMaterial||ut.isMeshToonMaterial||ut.isMeshLambertMaterial||ut.isMeshBasicMaterial||ut.isMeshStandardMaterial||ut.isShaderMaterial)&&on.setValue(pe,"isOrthographic",Ae.isOrthographicCamera===!0),A!==Ae&&(A=Ae,Mn=!0,Gt=!0)}if(lt.isSkinnedMesh){on.setOptional(pe,lt,"bindMatrix"),on.setOptional(pe,lt,"bindMatrixInverse");const ir=lt.skeleton;ir&&(Y.floatVertexTextures?(ir.boneTexture===null&&ir.computeBoneTexture(),on.setValue(pe,"boneTexture",ir.boneTexture,U)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}lt.isBatchedMesh&&(on.setOptional(pe,lt,"batchingTexture"),on.setValue(pe,"batchingTexture",lt._matricesTexture,U));const Yt=ct.morphAttributes;if((Yt.position!==void 0||Yt.normal!==void 0||Yt.color!==void 0&&Y.isWebGL2===!0)&&$e.update(lt,ct,hn),(Mn||Mt.receiveShadow!==lt.receiveShadow)&&(Mt.receiveShadow=lt.receiveShadow,on.setValue(pe,"receiveShadow",lt.receiveShadow)),ut.isMeshGouraudMaterial&&ut.envMap!==null&&(dn.envMap.value=Ve,dn.flipEnvMap.value=Ve.isCubeTexture&&Ve.isRenderTargetTexture===!1?-1:1),Mn&&(on.setValue(pe,"toneMappingExposure",k.toneMappingExposure),Mt.needsLights&&hi(dn,Gt),Et&&ut.fog===!0&&le.refreshFogUniforms(dn,Et),le.refreshMaterialUniforms(dn,ut,V,X,me),D1.upload(pe,Gn(Mt),dn,U)),ut.isShaderMaterial&&ut.uniformsNeedUpdate===!0&&(D1.upload(pe,Gn(Mt),dn,U),ut.uniformsNeedUpdate=!1),ut.isSpriteMaterial&&on.setValue(pe,"center",lt.center),on.setValue(pe,"modelViewMatrix",lt.modelViewMatrix),on.setValue(pe,"normalMatrix",lt.normalMatrix),on.setValue(pe,"modelMatrix",lt.matrixWorld),ut.isShaderMaterial||ut.isRawShaderMaterial){const ir=ut.uniformsGroups;for(let jn=0,si=ir.length;jn<si;jn++)if(Y.isWebGL2){const ar=ir[jn];we.update(ar,hn),we.bind(ar,hn)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return hn}function hi(Ae,et){Ae.ambientLightColor.needsUpdate=et,Ae.lightProbe.needsUpdate=et,Ae.directionalLights.needsUpdate=et,Ae.directionalLightShadows.needsUpdate=et,Ae.pointLights.needsUpdate=et,Ae.pointLightShadows.needsUpdate=et,Ae.spotLights.needsUpdate=et,Ae.spotLightShadows.needsUpdate=et,Ae.rectAreaLights.needsUpdate=et,Ae.hemisphereLights.needsUpdate=et}function ai(Ae){return Ae.isMeshLambertMaterial||Ae.isMeshToonMaterial||Ae.isMeshPhongMaterial||Ae.isMeshStandardMaterial||Ae.isShadowMaterial||Ae.isShaderMaterial&&Ae.lights===!0}this.getActiveCubeFace=function(){return M},this.getActiveMipmapLevel=function(){return C},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(Ae,et,ct){te.get(Ae.texture).__webglTexture=et,te.get(Ae.depthTexture).__webglTexture=ct;const ut=te.get(Ae);ut.__hasExternalTextures=!0,ut.__hasExternalTextures&&(ut.__autoAllocateDepthBuffer=ct===void 0,ut.__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"),ut.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(Ae,et){const ct=te.get(Ae);ct.__webglFramebuffer=et,ct.__useDefaultFramebuffer=et===void 0},this.setRenderTarget=function(Ae,et=0,ct=0){E=Ae,M=et,C=ct;let ut=!0,lt=null,Et=!1,fe=!1;if(Ae){const Ve=te.get(Ae);Ve.__useDefaultFramebuffer!==void 0?(ue.bindFramebuffer(pe.FRAMEBUFFER,null),ut=!1):Ve.__webglFramebuffer===void 0?U.setupRenderTarget(Ae):Ve.__hasExternalTextures&&U.rebindTextures(Ae,te.get(Ae.texture).__webglTexture,te.get(Ae.depthTexture).__webglTexture);const Se=Ae.texture;(Se.isData3DTexture||Se.isDataArrayTexture||Se.isCompressedArrayTexture)&&(fe=!0);const Le=te.get(Ae).__webglFramebuffer;Ae.isWebGLCubeRenderTarget?(Array.isArray(Le[et])?lt=Le[et][ct]:lt=Le[et],Et=!0):Y.isWebGL2&&Ae.samples>0&&U.useMultisampledRTT(Ae)===!1?lt=te.get(Ae).__webglMultisampledFramebuffer:Array.isArray(Le)?lt=Le[ct]:lt=Le,D.copy(Ae.viewport),I.copy(Ae.scissor),F=Ae.scissorTest}else D.copy(se).multiplyScalar(V).floor(),I.copy(H).multiplyScalar(V).floor(),F=K;if(ue.bindFramebuffer(pe.FRAMEBUFFER,lt)&&Y.drawBuffers&&ut&&ue.drawBuffers(Ae,lt),ue.viewport(D),ue.scissor(I),ue.setScissorTest(F),Et){const Ve=te.get(Ae.texture);pe.framebufferTexture2D(pe.FRAMEBUFFER,pe.COLOR_ATTACHMENT0,pe.TEXTURE_CUBE_MAP_POSITIVE_X+et,Ve.__webglTexture,ct)}else if(fe){const Ve=te.get(Ae.texture),Se=et||0;pe.framebufferTextureLayer(pe.FRAMEBUFFER,pe.COLOR_ATTACHMENT0,Ve.__webglTexture,ct||0,Se)}R=-1},this.readRenderTargetPixels=function(Ae,et,ct,ut,lt,Et,fe){if(!(Ae&&Ae.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let De=te.get(Ae).__webglFramebuffer;if(Ae.isWebGLCubeRenderTarget&&fe!==void 0&&(De=De[fe]),De){ue.bindFramebuffer(pe.FRAMEBUFFER,De);try{const Ve=Ae.texture,Se=Ve.format,Le=Ve.type;if(Se!==Xo&&Pe.convert(Se)!==pe.getParameter(pe.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const tt=Le===xy&&(G.has("EXT_color_buffer_half_float")||Y.isWebGL2&&G.has("EXT_color_buffer_float"));if(Le!==dh&&Pe.convert(Le)!==pe.getParameter(pe.IMPLEMENTATION_COLOR_READ_TYPE)&&!(Le===Su&&(Y.isWebGL2||G.has("OES_texture_float")||G.has("WEBGL_color_buffer_float")))&&!tt){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}et>=0&&et<=Ae.width-ut&&ct>=0&&ct<=Ae.height-lt&&pe.readPixels(et,ct,ut,lt,Pe.convert(Se),Pe.convert(Le),Et)}finally{const Ve=E!==null?te.get(E).__webglFramebuffer:null;ue.bindFramebuffer(pe.FRAMEBUFFER,Ve)}}},this.copyFramebufferToTexture=function(Ae,et,ct=0){const ut=Math.pow(2,-ct),lt=Math.floor(et.image.width*ut),Et=Math.floor(et.image.height*ut);U.setTexture2D(et,0),pe.copyTexSubImage2D(pe.TEXTURE_2D,ct,0,0,Ae.x,Ae.y,lt,Et),ue.unbindTexture()},this.copyTextureToTexture=function(Ae,et,ct,ut=0){const lt=et.image.width,Et=et.image.height,fe=Pe.convert(ct.format),De=Pe.convert(ct.type);U.setTexture2D(ct,0),pe.pixelStorei(pe.UNPACK_FLIP_Y_WEBGL,ct.flipY),pe.pixelStorei(pe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ct.premultiplyAlpha),pe.pixelStorei(pe.UNPACK_ALIGNMENT,ct.unpackAlignment),et.isDataTexture?pe.texSubImage2D(pe.TEXTURE_2D,ut,Ae.x,Ae.y,lt,Et,fe,De,et.image.data):et.isCompressedTexture?pe.compressedTexSubImage2D(pe.TEXTURE_2D,ut,Ae.x,Ae.y,et.mipmaps[0].width,et.mipmaps[0].height,fe,et.mipmaps[0].data):pe.texSubImage2D(pe.TEXTURE_2D,ut,Ae.x,Ae.y,fe,De,et.image),ut===0&&ct.generateMipmaps&&pe.generateMipmap(pe.TEXTURE_2D),ue.unbindTexture()},this.copyTextureToTexture3D=function(Ae,et,ct,ut,lt=0){if(k.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const Et=Ae.max.x-Ae.min.x+1,fe=Ae.max.y-Ae.min.y+1,De=Ae.max.z-Ae.min.z+1,Ve=Pe.convert(ut.format),Se=Pe.convert(ut.type);let Le;if(ut.isData3DTexture)U.setTexture3D(ut,0),Le=pe.TEXTURE_3D;else if(ut.isDataArrayTexture)U.setTexture2DArray(ut,0),Le=pe.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}pe.pixelStorei(pe.UNPACK_FLIP_Y_WEBGL,ut.flipY),pe.pixelStorei(pe.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ut.premultiplyAlpha),pe.pixelStorei(pe.UNPACK_ALIGNMENT,ut.unpackAlignment);const tt=pe.getParameter(pe.UNPACK_ROW_LENGTH),Qe=pe.getParameter(pe.UNPACK_IMAGE_HEIGHT),Tt=pe.getParameter(pe.UNPACK_SKIP_PIXELS),At=pe.getParameter(pe.UNPACK_SKIP_ROWS),Ft=pe.getParameter(pe.UNPACK_SKIP_IMAGES),jt=ct.isCompressedTexture?ct.mipmaps[0]:ct.image;pe.pixelStorei(pe.UNPACK_ROW_LENGTH,jt.width),pe.pixelStorei(pe.UNPACK_IMAGE_HEIGHT,jt.height),pe.pixelStorei(pe.UNPACK_SKIP_PIXELS,Ae.min.x),pe.pixelStorei(pe.UNPACK_SKIP_ROWS,Ae.min.y),pe.pixelStorei(pe.UNPACK_SKIP_IMAGES,Ae.min.z),ct.isDataTexture||ct.isData3DTexture?pe.texSubImage3D(Le,lt,et.x,et.y,et.z,Et,fe,De,Ve,Se,jt.data):ct.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),pe.compressedTexSubImage3D(Le,lt,et.x,et.y,et.z,Et,fe,De,Ve,jt.data)):pe.texSubImage3D(Le,lt,et.x,et.y,et.z,Et,fe,De,Ve,Se,jt),pe.pixelStorei(pe.UNPACK_ROW_LENGTH,tt),pe.pixelStorei(pe.UNPACK_IMAGE_HEIGHT,Qe),pe.pixelStorei(pe.UNPACK_SKIP_PIXELS,Tt),pe.pixelStorei(pe.UNPACK_SKIP_ROWS,At),pe.pixelStorei(pe.UNPACK_SKIP_IMAGES,Ft),lt===0&&ut.generateMipmaps&&pe.generateMipmap(Le),ue.unbindTexture()},this.initTexture=function(Ae){Ae.isCubeTexture?U.setTextureCube(Ae,0):Ae.isData3DTexture?U.setTexture3D(Ae,0):Ae.isDataArrayTexture||Ae.isCompressedArrayTexture?U.setTexture2DArray(Ae,0):U.setTexture2D(Ae,0),ue.unbindTexture()},this.resetState=function(){M=0,C=0,E=null,ue.reset(),ze.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return cc}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const n=this.getContext();n.drawingBufferColorSpace=e===aL?"display-p3":"srgb",n.unpackColorSpace=Er.workingColorSpace===y2?"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===La?Kf:WJ}set outputEncoding(e){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=e===Kf?La:Vu}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 EBe extends SD{}EBe.prototype.isWebGL1Renderer=!0;class dL{constructor(e,n=1,r=1e3){this.isFog=!0,this.name="",this.color=new Zt(e),this.near=n,this.far=r}clone(){return new dL(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class TBe extends ps{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 ABe{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=yD,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=Pu()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}get updateRange(){return console.warn('THREE.InterleavedBuffer: "updateRange" is deprecated and removed in r169. Use "addUpdateRange()" instead.'),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,n){this.updateRanges.push({start:e,count:n})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,n,r){e*=this.stride,r*=n.stride;for(let i=0,a=this.stride;i<a;i++)this.array[e+i]=n.array[r+i];return this}set(e,n=0){return this.array.set(e,n),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Pu()),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=Pu()),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 ls=new qe;class Jd{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++)ls.fromBufferAttribute(this,n),ls.applyMatrix4(e),this.setXYZ(n,ls.x,ls.y,ls.z);return this}applyNormalMatrix(e){for(let n=0,r=this.count;n<r;n++)ls.fromBufferAttribute(this,n),ls.applyNormalMatrix(e),this.setXYZ(n,ls.x,ls.y,ls.z);return this}transformDirection(e){for(let n=0,r=this.count;n<r;n++)ls.fromBufferAttribute(this,n),ls.transformDirection(e),this.setXYZ(n,ls.x,ls.y,ls.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=ac(n,this.array)),n}getY(e){let n=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(n=ac(n,this.array)),n}getZ(e){let n=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(n=ac(n,this.array)),n}getW(e){let n=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(n=ac(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,a){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),a=kr(a,this.array)),this.data.array[e+0]=n,this.data.array[e+1]=r,this.data.array[e+2]=i,this.data.array[e+3]=a,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[i+a])}return new po(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 Jd(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const n=[];for(let r=0;r<this.count;r++){const i=r*this.data.stride+this.offset;for(let a=0;a<this.itemSize;a++)n.push(this.data.array[i+a])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:n,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class CBe extends zs{constructor(e=null,n=1,r=1,i,a,o,l,c,u=Oa,d=Oa,f,p){super(null,o,l,c,u,d,i,a,f,p),this.isDataTexture=!0,this.image={data:e,width:n,height:r},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}function PBe(t,e){return t.z-e.z}function jBe(t,e){return e.z-t.z}class DBe{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,n){const r=this.pool,i=this.list;this.index>=r.length&&r.push({start:-1,count:-1,z:-1});const a=r[this.index];i.push(a),this.index++,a.start=e.start,a.count=e.count,a.z=n}reset(){this.list.length=0,this.index=0}}const Zp="batchId",Rd=new zr,a7=new zr,RBe=new zr,s7=new zr,JC=new v2,G_=new rl,xf=new hc,Qb=new qe,eP=new DBe,Wa=new Dl,q_=[];function OBe(t,e,n=0){const r=e.itemSize;if(t.isInterleavedBufferAttribute||t.array.constructor!==e.array.constructor){const i=t.count;for(let a=0;a<i;a++)for(let o=0;o<r;o++)e.setComponent(a+n,o,t.getComponent(a,o))}else e.array.set(t.array,n*r);e.needsUpdate=!0}class LBe extends Dl{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 CBe(n,e,e,Xo,Su);this._matricesTexture=r}_initializeGeometry(e){const n=this.geometry,r=this._maxVertexCount,i=this._maxGeometryCount,a=this._maxIndexCount;if(this._geometryInitialized===!1){for(const l in e.attributes){const c=e.getAttribute(l),{array:u,itemSize:d,normalized:f}=c,p=new u.constructor(r*d),m=new c.constructor(p,d,f);m.setUsage(c.usage),n.setAttribute(l,m)}if(e.getIndex()!==null){const l=r>65536?new Uint32Array(a):new Uint16Array(a);n.setIndex(new po(l,1))}const o=i>65536?new Uint32Array(r):new Uint16Array(r);n.setAttribute(Zp,new po(o,1)),this._geometryInitialized=!0}}_validateGeometry(e){if(e.getAttribute(Zp))throw new Error(`BatchedMesh: Geometry cannot use attribute "${Zp}"`);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===Zp)continue;if(!e.hasAttribute(r))throw new Error(`BatchedMesh: Added geometry missing "${r}". All geometries must have consistent attributes.`);const i=e.getAttribute(r),a=n.getAttribute(r);if(i.itemSize!==a.itemSize||i.normalized!==a.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new rl);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,G_).applyMatrix4(Rd),n.union(G_))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new hc);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,xf).applyMatrix4(Rd),n.union(xf))}addGeometry(e,n=-1,r=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._geometryCount>=this._maxGeometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let a=null;const o=this._reservedRanges,l=this._drawRanges,c=this._bounds;this._geometryCount!==0&&(a=o[o.length-1]),n===-1?i.vertexCount=e.getAttribute("position").count:i.vertexCount=n,a===null?i.vertexStart=0:i.vertexStart=a.vertexStart+a.vertexCount;const u=e.getIndex(),d=u!==null;if(d&&(r===-1?i.indexCount=u.count:i.indexCount=r,a===null?i.indexStart=0:i.indexStart=a.indexStart+a.indexCount),i.indexStart!==-1&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const f=this._visibility,p=this._active,m=this._matricesTexture,x=this._matricesTexture.image.data;f.push(!0),p.push(!0);const b=this._geometryCount;this._geometryCount++,RBe.toArray(x,b*16),m.needsUpdate=!0,o.push(i),l.push({start:d?i.indexStart:i.vertexStart,count:-1}),c.push({boxInitialized:!1,box:new rl,sphereInitialized:!1,sphere:new hc});const v=this.geometry.getAttribute(Zp);for(let y=0;y<i.vertexCount;y++)v.setX(i.vertexStart+y,b);return v.needsUpdate=!0,this.setGeometryAt(b,e),b}setGeometryAt(e,n){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(n);const r=this.geometry,i=r.getIndex()!==null,a=r.getIndex(),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===Zp)continue;const x=n.getAttribute(m),b=r.getAttribute(m);OBe(x,b,c);const v=x.itemSize;for(let y=x.count,S=u;y<S;y++){const k=c+y;for(let T=0;T<v;T++)b.setComponent(k,T,0)}b.needsUpdate=!0}if(i){const m=l.indexStart;for(let x=0;x<o.count;x++)a.setX(m+x,c+o.getX(x));for(let x=o.count,b=l.indexCount;x<b;x++)a.setX(m+x,c);a.needsUpdate=!0}const d=this._bounds[e];n.boundingBox!==null?(d.box.copy(n.boundingBox),d.boxInitialized=!0):d.boxInitialized=!1,n.boundingSphere!==null?(d.sphere.copy(n.boundingSphere),d.sphereInitialized=!0):d.sphereInitialized=!1;const f=this._drawRanges[e],p=n.getAttribute("position");return f.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],a=i.box,o=this.geometry;if(i.boxInitialized===!1){a.makeEmpty();const l=o.index,c=o.attributes.position,u=this._drawRanges[e];for(let d=u.start,f=u.start+u.count;d<f;d++){let p=d;l&&(p=l.getX(p)),a.expandByPoint(Qb.fromBufferAttribute(c,p))}i.boxInitialized=!0}return n.copy(a),n}getBoundingSphereAt(e,n){if(this._active[e]===!1)return this;const i=this._bounds[e],a=i.sphere,o=this.geometry;if(i.sphereInitialized===!1){a.makeEmpty(),this.getBoundingBoxAt(e,G_),G_.getCenter(a.center);const l=o.index,c=o.attributes.position,u=this._drawRanges[e];let d=0;for(let f=u.start,p=u.start+u.count;f<p;f++){let m=f;l&&(m=l.getX(m)),Qb.fromBufferAttribute(c,m),d=Math.max(d,a.center.distanceToSquared(Qb))}a.radius=Math.sqrt(d),i.sphereInitialized=!0}return n.copy(a),n}setMatrixAt(e,n){const r=this._active,i=this._matricesTexture,a=this._matricesTexture.image.data,o=this._geometryCount;return e>=o||r[e]===!1?this:(n.toArray(a,e*16),i.needsUpdate=!0,this)}getMatrixAt(e,n){const r=this._active,i=this._matricesTexture.image.data,a=this._geometryCount;return e>=a||r[e]===!1?null:n.fromArray(i,e*16)}setVisibleAt(e,n){const r=this._visibility,i=this._active,a=this._geometryCount;return e>=a||i[e]===!1||r[e]===n?this:(r[e]=n,this._visibilityChanged=!0,this)}getVisibleAt(e){const n=this._visibility,r=this._active,i=this._geometryCount;return e>=i||r[e]===!1?!1:n[e]}raycast(e,n){const r=this._visibility,i=this._active,a=this._drawRanges,o=this._geometryCount,l=this.matrixWorld,c=this.geometry;Wa.material=this.material,Wa.geometry.index=c.index,Wa.geometry.attributes=c.attributes,Wa.geometry.boundingBox===null&&(Wa.geometry.boundingBox=new rl),Wa.geometry.boundingSphere===null&&(Wa.geometry.boundingSphere=new hc);for(let u=0;u<o;u++){if(!r[u]||!i[u])continue;const d=a[u];Wa.geometry.setDrawRange(d.start,d.count),this.getMatrixAt(u,Wa.matrixWorld).premultiply(l),this.getBoundingBoxAt(u,Wa.geometry.boundingBox),this.getBoundingSphereAt(u,Wa.geometry.boundingSphere),Wa.raycast(e,q_);for(let f=0,p=q_.length;f<p;f++){const m=q_[f];m.object=this,m.batchId=u,n.push(m)}q_.length=0}Wa.material=null,Wa.geometry.index=null,Wa.geometry.attributes={},Wa.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._drawRanges=e._drawRanges.map(n=>({...n})),this._reservedRanges=e._reservedRanges.map(n=>({...n})),this._visibility=e._visibility.slice(),this._active=e._active.slice(),this._bounds=e._bounds.map(n=>({boxInitialized:n.boxInitialized,box:n.box.clone(),sphereInitialized:n.sphereInitialized,sphere:n.sphere.clone()})),this._maxGeometryCount=e._maxGeometryCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.slice(),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this}onBeforeRender(e,n,r,i,a){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const o=i.getIndex(),l=o===null?1:o.array.BYTES_PER_ELEMENT,c=this._visibility,u=this._multiDrawStarts,d=this._multiDrawCounts,f=this._drawRanges,p=this.perObjectFrustumCulled;p&&(s7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse).multiply(this.matrixWorld),JC.setFromProjectionMatrix(s7,e.isWebGPURenderer?by:cc));let m=0;if(this.sortObjects){a7.copy(this.matrixWorld).invert(),Qb.setFromMatrixPosition(r.matrixWorld).applyMatrix4(a7);for(let v=0,y=c.length;v<y;v++)if(c[v]){this.getMatrixAt(v,Rd),this.getBoundingSphereAt(v,xf).applyMatrix4(Rd);let S=!1;if(p&&(S=!JC.intersectsSphere(xf)),!S){const k=Qb.distanceTo(xf.center);eP.push(f[v],k)}}const x=eP.list,b=this.customSort;b===null?x.sort(a.transparent?jBe:PBe):b.call(this,x,r);for(let v=0,y=x.length;v<y;v++){const S=x[v];u[m]=S.start*l,d[m]=S.count,m++}eP.reset()}else for(let x=0,b=c.length;x<b;x++)if(c[x]){let v=!1;if(p&&(this.getMatrixAt(x,Rd),this.getBoundingSphereAt(x,xf).applyMatrix4(Rd),v=!JC.intersectsSphere(xf)),!v){const y=f[x];u[m]=y.start*l,d[m]=y.count,m++}}this._multiDrawCount=m,this._visibilityChanged=!1}onBeforeShadow(e,n,r,i,a,o){this.onBeforeRender(e,null,i,a,o)}}class gv extends Dx{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Zt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const o7=new qe,l7=new qe,c7=new zr,tP=new oL,W_=new hc;class FBe extends ps{constructor(e=new ns,n=new gv){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[0];for(let i=1,a=n.count;i<a;i++)o7.fromBufferAttribute(n,i-1),l7.fromBufferAttribute(n,i),r[i]=r[i-1],r[i]+=o7.distanceTo(l7);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,a=e.params.Line.threshold,o=r.drawRange;if(r.boundingSphere===null&&r.computeBoundingSphere(),W_.copy(r.boundingSphere),W_.applyMatrix4(i),W_.radius+=a,e.ray.intersectsSphere(W_)===!1)return;c7.copy(i).invert(),tP.copy(e.ray).applyMatrix4(c7);const l=a/((this.scale.x+this.scale.y+this.scale.z)/3),c=l*l,u=new qe,d=new qe,f=new qe,p=new qe,m=this.isLineSegments?2:1,x=r.index,v=r.attributes.position;if(x!==null){const y=Math.max(0,o.start),S=Math.min(x.count,o.start+o.count);for(let k=y,T=S-1;k<T;k+=m){const M=x.getX(k),C=x.getX(k+1);if(u.fromBufferAttribute(v,M),d.fromBufferAttribute(v,C),tP.distanceSqToSegment(u,d,p,f)>c)continue;p.applyMatrix4(this.matrixWorld);const R=e.ray.origin.distanceTo(p);R<e.near||R>e.far||n.push({distance:R,point:f.clone().applyMatrix4(this.matrixWorld),index:k,face:null,faceIndex:null,object:this})}}else{const y=Math.max(0,o.start),S=Math.min(v.count,o.start+o.count);for(let k=y,T=S-1;k<T;k+=m){if(u.fromBufferAttribute(v,k),d.fromBufferAttribute(v,k+1),tP.distanceSqToSegment(u,d,p,f)>c)continue;p.applyMatrix4(this.matrixWorld);const C=e.ray.origin.distanceTo(p);C<e.near||C>e.far||n.push({distance:C,point:f.clone().applyMatrix4(this.matrixWorld),index:k,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,r=Object.keys(n);if(r.length>0){const i=n[r[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let a=0,o=i.length;a<o;a++){const l=i[a].name||String(a);this.morphTargetInfluences.push(0),this.morphTargetDictionary[l]=a}}}}}const u7=new qe,d7=new qe;class _2 extends FBe{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,r=[];for(let i=0,a=n.count;i<a;i+=2)u7.fromBufferAttribute(n,i),d7.fromBufferAttribute(n,i+1),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+u7.distanceTo(d7);e.setAttribute("lineDistance",new Ai(r,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class IBe extends ns{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],r=new Set,i=new qe,a=new qe;if(e.index!==null){const o=e.attributes.position,l=e.index;let c=e.groups;c.length===0&&(c=[{start:0,count:l.count,materialIndex:0}]);for(let u=0,d=c.length;u<d;++u){const f=c[u],p=f.start,m=f.count;for(let x=p,b=p+m;x<b;x+=3)for(let v=0;v<3;v++){const y=l.getX(x+v),S=l.getX(x+(v+1)%3);i.fromBufferAttribute(o,y),a.fromBufferAttribute(o,S),h7(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}}else{const o=e.attributes.position;for(let l=0,c=o.count/3;l<c;l++)for(let u=0;u<3;u++){const d=3*l+u,f=3*l+(u+1)%3;i.fromBufferAttribute(o,d),a.fromBufferAttribute(o,f),h7(i,a,r)===!0&&(n.push(i.x,i.y,i.z),n.push(a.x,a.y,a.z))}}this.setAttribute("position",new Ai(n,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function h7(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 UBe extends Dx{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Zt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=KJ,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=rL,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 zBe extends gv{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 gee extends ps{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Zt(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),n}}const nP=new zr,f7=new qe,m7=new qe;class BBe{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 v2,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;f7.setFromMatrixPosition(e.matrixWorld),n.position.copy(f7),m7.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(m7),n.updateMatrixWorld(),nP.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(nP),r.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),r.multiply(nP)}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 p7=new zr,Zb=new qe,rP=new qe;class HBe extends BBe{constructor(){super(new so(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 qe(1,0,0),new qe(-1,0,0),new qe(0,0,1),new qe(0,0,-1),new qe(0,1,0),new qe(0,-1,0)],this._cubeUps=[new qe(0,1,0),new qe(0,1,0),new qe(0,1,0),new qe(0,1,0),new qe(0,0,1),new qe(0,0,-1)]}updateMatrices(e,n=0){const r=this.camera,i=this.matrix,a=e.distance||r.far;a!==r.far&&(r.far=a,r.updateProjectionMatrix()),Zb.setFromMatrixPosition(e.matrixWorld),r.position.copy(Zb),rP.copy(r.position),rP.add(this._cubeDirections[n]),r.up.copy(this._cubeUps[n]),r.lookAt(rP),r.updateMatrixWorld(),i.makeTranslation(-Zb.x,-Zb.y,-Zb.z),p7.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),this._frustum.setFromProjectionMatrix(p7)}}class $Be extends gee{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 HBe}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 VBe extends gee{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class GBe 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 ND extends ABe{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 g7{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(Fa(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const x7=new qe,K_=new qe;class qBe{constructor(e=new qe,n=new qe){this.start=e,this.end=n}set(e,n){return this.start.copy(e),this.end.copy(n),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,n){return this.delta(n).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,n){x7.subVectors(e,this.start),K_.subVectors(this.end,this.start);const r=K_.dot(K_);let a=K_.dot(x7)/r;return n&&(a=Fa(a,0,1)),a}closestPointToPoint(e,n,r){const i=this.closestPointToPointParameter(e,n);return this.delta(r).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}class WBe extends _2{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 a=new gv({vertexColors:!0,toneMapped:!1});super(i,a),this.type="AxesHelper"}setColors(e,n,r){const i=new Zt,a=this.geometry.attributes.color.array;return i.set(e),i.toArray(a,0),i.toArray(a,3),i.set(n),i.toArray(a,6),i.toArray(a,9),i.set(r),i.toArray(a,12),i.toArray(a,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:x2}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=x2);class fc{constructor(e,n,r,i,a="div"){this.parent=e,this.object=n,this.property=r,this._disabled=!1,this._hidden=!1,this.initialValue=this.getValue(),this.domElement=document.createElement(a),this.domElement.classList.add("controller"),this.domElement.classList.add(i),this.$name=document.createElement("div"),this.$name.classList.add("name"),fc.nextNameID=fc.nextNameID||0,this.$name.id=`lil-gui-name-${++fc.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 KBe extends fc{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 MD(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 XBe={isPrimitive:!0,match:t=>typeof t=="string",fromHexString:MD,toHexString:MD},vy={isPrimitive:!0,match:t=>typeof t=="number",fromHexString:t=>parseInt(t.substring(1),16),toHexString:t=>"#"+t.toString(16).padStart(6,0)},YBe={isPrimitive:!1,match:t=>Array.isArray(t),fromHexString(t,e,n=1){const r=vy.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 vy.toHexString(i)}},QBe={isPrimitive:!1,match:t=>Object(t)===t,fromHexString(t,e,n=1){const r=vy.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 vy.toHexString(i)}},ZBe=[XBe,vy,YBe,QBe];function JBe(t){return ZBe.find(e=>e.match(t))}class e8e extends fc{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=JBe(this.initialValue),this._rgbScale=i,this._initialValueHexString=this.save(),this._textFocused=!1,this.$input.addEventListener("input",()=>{this._setValueFromHexString(this.$input.value)}),this.$input.addEventListener("blur",()=>{this._callOnFinishChange()}),this.$text.addEventListener("input",()=>{const a=MD(this.$text.value);a&&this._setValueFromHexString(a)}),this.$text.addEventListener("focus",()=>{this._textFocused=!0,this.$text.select()}),this.$text.addEventListener("blur",()=>{this._textFocused=!1,this.updateDisplay(),this._callOnFinishChange()}),this.$disable=this.$text,this.updateDisplay()}reset(){return this._setValueFromHexString(this._initialValueHexString),this}_setValueFromHexString(e){if(this._format.isPrimitive){const n=this._format.fromHexString(e);this.setValue(n)}else this._format.fromHexString(e,this.getValue(),this._rgbScale),this._callOnChange(),this.updateDisplay()}save(){return this._format.toHexString(this.getValue(),this._rgbScale)}load(e){return this._setValueFromHexString(e),this._callOnFinishChange(),this}updateDisplay(){return this.$input.value=this._format.toHexString(this.getValue(),this._rgbScale),this._textFocused||(this.$text.value=this.$input.value.substring(1)),this.$display.style.backgroundColor=this.$input.value,this}}class iP extends fc{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 t8e extends fc{constructor(e,n,r,i,a,o){super(e,n,r,"number"),this._initInput(),this.min(i),this.max(a);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 k=parseFloat(this.$input.value);isNaN(k)||(this._snapClampSetValue(k+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))},a=S=>{this._inputFocused&&(S.preventDefault(),r(this._step*this._normalizeMouseWheel(S)))};let o=!1,l,c,u,d,f;const p=5,m=S=>{l=S.clientX,c=u=S.clientY,o=!0,d=this.getValue(),f=0,window.addEventListener("mousemove",x),window.addEventListener("mouseup",b)},x=S=>{if(o){const k=S.clientX-l,T=S.clientY-c;Math.abs(T)>p?(S.preventDefault(),this.$input.blur(),o=!1,this._setDraggingStyle(!0,"vertical")):Math.abs(k)>p&&b()}if(!o){const k=S.clientY-u;f-=k*this._step*this._arrowKeyMultiplier(S),d+f>this._max?f=this._max-d:d+f<this._min&&(f=this._min-d),this._snapClampSetValue(d+f)}u=S.clientY},b=()=>{this._setDraggingStyle(!1,"vertical"),this._callOnFinishChange(),window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",b)},v=()=>{this._inputFocused=!0},y=()=>{this._inputFocused=!1,this.updateDisplay(),this._callOnFinishChange()};this.$input.addEventListener("input",n),this.$input.addEventListener("keydown",i),this.$input.addEventListener("wheel",a,{passive:!1}),this.$input.addEventListener("mousedown",m),this.$input.addEventListener("focus",v),this.$input.addEventListener("blur",y)}_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=(y,S,k,T,M)=>(y-S)/(k-S)*(M-T)+T,n=y=>{const S=this.$slider.getBoundingClientRect();let k=e(y,S.left,S.right,this._min,this._max);this._snapClampSetValue(k)},r=y=>{this._setDraggingStyle(!0),n(y.clientX),window.addEventListener("mousemove",i),window.addEventListener("mouseup",a)},i=y=>{n(y.clientX)},a=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("mousemove",i),window.removeEventListener("mouseup",a)};let o=!1,l,c;const u=y=>{y.preventDefault(),this._setDraggingStyle(!0),n(y.touches[0].clientX),o=!1},d=y=>{y.touches.length>1||(this._hasScrollBar?(l=y.touches[0].clientX,c=y.touches[0].clientY,o=!0):u(y),window.addEventListener("touchmove",f,{passive:!1}),window.addEventListener("touchend",p))},f=y=>{if(o){const S=y.touches[0].clientX-l,k=y.touches[0].clientY-c;Math.abs(S)>Math.abs(k)?u(y):(window.removeEventListener("touchmove",f),window.removeEventListener("touchend",p))}else y.preventDefault(),n(y.touches[0].clientX)},p=()=>{this._callOnFinishChange(),this._setDraggingStyle(!1),window.removeEventListener("touchmove",f),window.removeEventListener("touchend",p)},m=this._callOnFinishChange.bind(this),x=400;let b;const v=y=>{if(Math.abs(y.deltaX)<Math.abs(y.deltaY)&&this._hasScrollBar)return;y.preventDefault();const k=this._normalizeMouseWheel(y)*this._step;this._snapClampSetValue(this.getValue()+k),this.$input.value=this.getValue(),clearTimeout(b),b=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 n8e extends fc{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 r8e extends fc{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 i8e=`.lil-gui {
- font-family: var(--font-family);
- font-size: var(--font-size);
- line-height: 1;
- font-weight: normal;
- font-style: normal;
- text-align: left;
- color: var(--text-color);
- user-select: none;
- -webkit-user-select: none;
- touch-action: manipulation;
- --background-color: #1f1f1f;
- --text-color: #ebebeb;
- --title-background-color: #111111;
- --title-text-color: #ebebeb;
- --widget-color: #424242;
- --hover-color: #4f4f4f;
- --focus-color: #595959;
- --number-color: #2cc9ff;
- --string-color: #a2db3c;
- --font-size: 11px;
- --input-font-size: 11px;
- --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
- --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
- --padding: 4px;
- --spacing: 4px;
- --widget-height: 20px;
- --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
- --name-width: 45%;
- --slider-knob-width: 2px;
- --slider-input-width: 27%;
- --color-input-width: 27%;
- --slider-input-min-width: 45px;
- --color-input-min-width: 45px;
- --folder-indent: 7px;
- --widget-padding: 0 0 0 3px;
- --widget-border-radius: 2px;
- --checkbox-size: calc(0.75 * var(--widget-height));
- --scrollbar-width: 5px;
- }
- .lil-gui, .lil-gui * {
- box-sizing: border-box;
- margin: 0;
- padding: 0;
- }
- .lil-gui.root {
- width: var(--width, 245px);
- display: flex;
- flex-direction: column;
- background: var(--background-color);
- }
- .lil-gui.root > .title {
- background: var(--title-background-color);
- color: var(--title-text-color);
- }
- .lil-gui.root > .children {
- overflow-x: hidden;
- overflow-y: auto;
- }
- .lil-gui.root > .children::-webkit-scrollbar {
- width: var(--scrollbar-width);
- height: var(--scrollbar-width);
- background: var(--background-color);
- }
- .lil-gui.root > .children::-webkit-scrollbar-thumb {
- border-radius: var(--scrollbar-width);
- background: var(--focus-color);
- }
- @media (pointer: coarse) {
- .lil-gui.allow-touch-styles, .lil-gui.allow-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- }
- .lil-gui.force-touch-styles, .lil-gui.force-touch-styles .lil-gui {
- --widget-height: 28px;
- --padding: 6px;
- --spacing: 6px;
- --font-size: 13px;
- --input-font-size: 16px;
- --folder-indent: 10px;
- --scrollbar-width: 7px;
- --slider-input-min-width: 50px;
- --color-input-min-width: 65px;
- }
- .lil-gui.autoPlace {
- max-height: 100%;
- position: fixed;
- top: 0;
- right: 15px;
- z-index: 1001;
- }
- .lil-gui .controller {
- display: flex;
- align-items: center;
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- }
- .lil-gui .controller.disabled {
- opacity: 0.5;
- }
- .lil-gui .controller.disabled, .lil-gui .controller.disabled * {
- pointer-events: none !important;
- }
- .lil-gui .controller > .name {
- min-width: var(--name-width);
- flex-shrink: 0;
- white-space: pre;
- padding-right: var(--spacing);
- line-height: var(--widget-height);
- }
- .lil-gui .controller .widget {
- position: relative;
- display: flex;
- align-items: center;
- width: 100%;
- min-height: var(--widget-height);
- }
- .lil-gui .controller.string input {
- color: var(--string-color);
- }
- .lil-gui .controller.boolean {
- cursor: pointer;
- }
- .lil-gui .controller.color .display {
- width: 100%;
- height: var(--widget-height);
- border-radius: var(--widget-border-radius);
- position: relative;
- }
- @media (hover: hover) {
- .lil-gui .controller.color .display:hover:before {
- content: " ";
- display: block;
- position: absolute;
- border-radius: var(--widget-border-radius);
- border: 1px solid #fff9;
- top: 0;
- right: 0;
- bottom: 0;
- left: 0;
- }
- }
- .lil-gui .controller.color input[type=color] {
- opacity: 0;
- width: 100%;
- height: 100%;
- cursor: pointer;
- }
- .lil-gui .controller.color input[type=text] {
- margin-left: var(--spacing);
- font-family: var(--font-family-mono);
- min-width: var(--color-input-min-width);
- width: var(--color-input-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.option select {
- opacity: 0;
- position: absolute;
- width: 100%;
- max-width: 100%;
- }
- .lil-gui .controller.option .display {
- position: relative;
- pointer-events: none;
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- line-height: var(--widget-height);
- max-width: 100%;
- overflow: hidden;
- word-break: break-all;
- padding-left: 0.55em;
- padding-right: 1.75em;
- background: var(--widget-color);
- }
- @media (hover: hover) {
- .lil-gui .controller.option .display.focus {
- background: var(--focus-color);
- }
- }
- .lil-gui .controller.option .display.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.option .display:after {
- font-family: "lil-gui";
- content: "↕";
- position: absolute;
- top: 0;
- right: 0;
- bottom: 0;
- padding-right: 0.375em;
- }
- .lil-gui .controller.option .widget,
- .lil-gui .controller.option select {
- cursor: pointer;
- }
- @media (hover: hover) {
- .lil-gui .controller.option .widget:hover .display {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number input {
- color: var(--number-color);
- }
- .lil-gui .controller.number.hasSlider input {
- margin-left: var(--spacing);
- width: var(--slider-input-width);
- min-width: var(--slider-input-min-width);
- flex-shrink: 0;
- }
- .lil-gui .controller.number .slider {
- width: 100%;
- height: var(--widget-height);
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- padding-right: var(--slider-knob-width);
- overflow: hidden;
- cursor: ew-resize;
- touch-action: pan-y;
- }
- @media (hover: hover) {
- .lil-gui .controller.number .slider:hover {
- background: var(--hover-color);
- }
- }
- .lil-gui .controller.number .slider.active {
- background: var(--focus-color);
- }
- .lil-gui .controller.number .slider.active .fill {
- opacity: 0.95;
- }
- .lil-gui .controller.number .fill {
- height: 100%;
- border-right: var(--slider-knob-width) solid var(--number-color);
- box-sizing: content-box;
- }
- .lil-gui-dragging .lil-gui {
- --hover-color: var(--widget-color);
- }
- .lil-gui-dragging * {
- cursor: ew-resize !important;
- }
- .lil-gui-dragging.lil-gui-vertical * {
- cursor: ns-resize !important;
- }
- .lil-gui .title {
- height: var(--title-height);
- line-height: calc(var(--title-height) - 4px);
- font-weight: 600;
- padding: 0 var(--padding);
- -webkit-tap-highlight-color: transparent;
- cursor: pointer;
- outline: none;
- text-decoration-skip: objects;
- }
- .lil-gui .title:before {
- font-family: "lil-gui";
- content: "▾";
- padding-right: 2px;
- display: inline-block;
- }
- .lil-gui .title:active {
- background: var(--title-background-color);
- opacity: 0.75;
- }
- @media (hover: hover) {
- body:not(.lil-gui-dragging) .lil-gui .title:hover {
- background: var(--title-background-color);
- opacity: 0.85;
- }
- .lil-gui .title:focus {
- text-decoration: underline var(--focus-color);
- }
- }
- .lil-gui.root > .title:focus {
- text-decoration: none !important;
- }
- .lil-gui.closed > .title:before {
- content: "▸";
- }
- .lil-gui.closed > .children {
- transform: translateY(-7px);
- opacity: 0;
- }
- .lil-gui.closed:not(.transition) > .children {
- display: none;
- }
- .lil-gui.transition > .children {
- transition-duration: 300ms;
- transition-property: height, opacity, transform;
- transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
- overflow: hidden;
- pointer-events: none;
- }
- .lil-gui .children:empty:before {
- content: "Empty";
- padding: 0 var(--padding);
- margin: var(--spacing) 0;
- display: block;
- height: var(--widget-height);
- font-style: italic;
- line-height: var(--widget-height);
- opacity: 0.5;
- }
- .lil-gui.root > .children > .lil-gui > .title {
- border: 0 solid var(--widget-color);
- border-width: 1px 0;
- transition: border-color 300ms;
- }
- .lil-gui.root > .children > .lil-gui.closed > .title {
- border-bottom-color: transparent;
- }
- .lil-gui + .controller {
- border-top: 1px solid var(--widget-color);
- margin-top: 0;
- padding-top: var(--spacing);
- }
- .lil-gui .lil-gui .lil-gui > .title {
- border: none;
- }
- .lil-gui .lil-gui .lil-gui > .children {
- border: none;
- margin-left: var(--folder-indent);
- border-left: 2px solid var(--widget-color);
- }
- .lil-gui .lil-gui .controller {
- border: none;
- }
- .lil-gui label, .lil-gui input, .lil-gui button {
- -webkit-tap-highlight-color: transparent;
- }
- .lil-gui input {
- border: 0;
- outline: none;
- font-family: var(--font-family);
- font-size: var(--input-font-size);
- border-radius: var(--widget-border-radius);
- height: var(--widget-height);
- background: var(--widget-color);
- color: var(--text-color);
- width: 100%;
- }
- @media (hover: hover) {
- .lil-gui input:hover {
- background: var(--hover-color);
- }
- .lil-gui input:active {
- background: var(--focus-color);
- }
- }
- .lil-gui input:disabled {
- opacity: 1;
- }
- .lil-gui input[type=text],
- .lil-gui input[type=number] {
- padding: var(--widget-padding);
- -moz-appearance: textfield;
- }
- .lil-gui input[type=text]:focus,
- .lil-gui input[type=number]:focus {
- background: var(--focus-color);
- }
- .lil-gui input[type=checkbox] {
- appearance: none;
- width: var(--checkbox-size);
- height: var(--checkbox-size);
- border-radius: var(--widget-border-radius);
- text-align: center;
- cursor: pointer;
- }
- .lil-gui input[type=checkbox]:checked:before {
- font-family: "lil-gui";
- content: "✓";
- font-size: var(--checkbox-size);
- line-height: var(--checkbox-size);
- }
- @media (hover: hover) {
- .lil-gui input[type=checkbox]:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button {
- outline: none;
- cursor: pointer;
- font-family: var(--font-family);
- font-size: var(--font-size);
- color: var(--text-color);
- width: 100%;
- height: var(--widget-height);
- text-transform: none;
- background: var(--widget-color);
- border-radius: var(--widget-border-radius);
- border: none;
- }
- @media (hover: hover) {
- .lil-gui button:hover {
- background: var(--hover-color);
- }
- .lil-gui button:focus {
- box-shadow: inset 0 0 0 1px var(--focus-color);
- }
- }
- .lil-gui button:active {
- background: var(--focus-color);
- }
- @font-face {
- font-family: "lil-gui";
- src: url("data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAUsAAsAAAAACJwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAAH4AAADAImwmYE9TLzIAAAGIAAAAPwAAAGBKqH5SY21hcAAAAcgAAAD0AAACrukyyJBnbHlmAAACvAAAAF8AAACEIZpWH2hlYWQAAAMcAAAAJwAAADZfcj2zaGhlYQAAA0QAAAAYAAAAJAC5AHhobXR4AAADXAAAABAAAABMAZAAAGxvY2EAAANsAAAAFAAAACgCEgIybWF4cAAAA4AAAAAeAAAAIAEfABJuYW1lAAADoAAAASIAAAIK9SUU/XBvc3QAAATEAAAAZgAAAJCTcMc2eJxVjbEOgjAURU+hFRBK1dGRL+ALnAiToyMLEzFpnPz/eAshwSa97517c/MwwJmeB9kwPl+0cf5+uGPZXsqPu4nvZabcSZldZ6kfyWnomFY/eScKqZNWupKJO6kXN3K9uCVoL7iInPr1X5baXs3tjuMqCtzEuagm/AAlzQgPAAB4nGNgYRBlnMDAysDAYM/gBiT5oLQBAwuDJAMDEwMrMwNWEJDmmsJwgCFeXZghBcjlZMgFCzOiKOIFAB71Bb8AeJy1kjFuwkAQRZ+DwRAwBtNQRUGKQ8OdKCAWUhAgKLhIuAsVSpWz5Bbkj3dEgYiUIszqWdpZe+Z7/wB1oCYmIoboiwiLT2WjKl/jscrHfGg/pKdMkyklC5Zs2LEfHYpjcRoPzme9MWWmk3dWbK9ObkWkikOetJ554fWyoEsmdSlt+uR0pCJR34b6t/TVg1SY3sYvdf8vuiKrpyaDXDISiegp17p7579Gp3p++y7HPAiY9pmTibljrr85qSidtlg4+l25GLCaS8e6rRxNBmsnERunKbaOObRz7N72ju5vdAjYpBXHgJylOAVsMseDAPEP8LYoUHicY2BiAAEfhiAGJgZWBgZ7RnFRdnVJELCQlBSRlATJMoLV2DK4glSYs6ubq5vbKrJLSbGrgEmovDuDJVhe3VzcXFwNLCOILB/C4IuQ1xTn5FPilBTj5FPmBAB4WwoqAHicY2BkYGAA4sk1sR/j+W2+MnAzpDBgAyEMQUCSg4EJxAEAwUgFHgB4nGNgZGBgSGFggJMhDIwMqEAYAByHATJ4nGNgAIIUNEwmAABl3AGReJxjYAACIQYlBiMGJ3wQAEcQBEV4nGNgZGBgEGZgY2BiAAEQyQWEDAz/wXwGAAsPATIAAHicXdBNSsNAHAXwl35iA0UQXYnMShfS9GPZA7T7LgIu03SSpkwzYTIt1BN4Ak/gKTyAeCxfw39jZkjymzcvAwmAW/wgwHUEGDb36+jQQ3GXGot79L24jxCP4gHzF/EIr4jEIe7wxhOC3g2TMYy4Q7+Lu/SHuEd/ivt4wJd4wPxbPEKMX3GI5+DJFGaSn4qNzk8mcbKSR6xdXdhSzaOZJGtdapd4vVPbi6rP+cL7TGXOHtXKll4bY1Xl7EGnPtp7Xy2n00zyKLVHfkHBa4IcJ2oD3cgggWvt/V/FbDrUlEUJhTn/0azVWbNTNr0Ens8de1tceK9xZmfB1CPjOmPH4kitmvOubcNpmVTN3oFJyjzCvnmrwhJTzqzVj9jiSX911FjeAAB4nG3HMRKCMBBA0f0giiKi4DU8k0V2GWbIZDOh4PoWWvq6J5V8If9NVNQcaDhyouXMhY4rPTcG7jwYmXhKq8Wz+p762aNaeYXom2n3m2dLTVgsrCgFJ7OTmIkYbwIbC6vIB7WmFfAAAA==") format("woff");
- }`;function a8e(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 b7=!1;class aN{constructor({parent:e,autoPlace:n=e===void 0,container:r,width:i,title:a="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(a),this.parent){this.parent.children.push(this),this.parent.folders.push(this),this.parent.$children.appendChild(this.domElement);return}this.domElement.classList.add("root"),c&&this.domElement.classList.add("allow-touch-styles"),!b7&&l&&(a8e(i8e),b7=!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,a){if(Object(r)===r)return new n8e(this,e,n,r);const o=e[n];switch(typeof o){case"number":return new t8e(this,e,n,r,i,a);case"boolean":return new KBe(this,e,n);case"string":return new r8e(this,e,n);case"function":return new iP(this,e,n)}console.error(`gui.add failed
- property:`,n,`
- object:`,e,`
- value:`,o)}addColor(e,n,r=1){return new e8e(this,e,n,r)}addFolder(e){const n=new aN({parent:this,title:e});return this.root._closeFolders&&n.close(),n}load(e,n=!0){return e.controllers&&this.controllers.forEach(r=>{r instanceof iP||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 iP)){if(r._name in n.controllers)throw new Error(`Cannot save GUI with duplicate property "${r._name}"`);n.controllers[r._name]=r.save()}}),e&&this.folders.forEach(r=>{if(r._title in n.folders)throw new Error(`Cannot save GUI with duplicate folder "${r._title}"`);n.folders[r._title]=r.save()}),n}open(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),this.domElement.classList.toggle("closed",this._closed),this}close(){return this.open(!1)}_setClosed(e){this._closed!==e&&(this._closed=e,this._callOnOpenClose(this))}show(e=!0){return this._hidden=!e,this.domElement.style.display=this._hidden?"none":"",this}hide(){return this.show(!1)}openAnimated(e=!0){return this._setClosed(!e),this.$title.setAttribute("aria-expanded",!this._closed),requestAnimationFrame(()=>{const n=this.$children.clientHeight;this.$children.style.height=n+"px",this.domElement.classList.add("transition");const r=a=>{a.target===this.$children&&(this.$children.style.height="",this.domElement.classList.remove("transition"),this.$children.removeEventListener("transitionend",r))};this.$children.addEventListener("transitionend",r);const i=e?this.$children.scrollHeight:0;this.domElement.classList.toggle("closed",!e),requestAnimationFrame(()=>{this.$children.style.height=i+"px"})}),this}title(e){return this._title=e,this.$title.textContent=e,this}reset(e=!0){return(e?this.controllersRecursive():this.controllers).forEach(r=>r.reset()),this}onChange(e){return this._onChange=e,this}_callOnChange(e){this.parent&&this.parent._callOnChange(e),this._onChange!==void 0&&this._onChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onFinishChange(e){return this._onFinishChange=e,this}_callOnFinishChange(e){this.parent&&this.parent._callOnFinishChange(e),this._onFinishChange!==void 0&&this._onFinishChange.call(this,{object:e.object,property:e.property,value:e.getValue(),controller:e})}onOpenClose(e){return this._onOpenClose=e,this}_callOnOpenClose(e){this.parent&&this.parent._callOnOpenClose(e),this._onOpenClose!==void 0&&this._onOpenClose.call(this,e)}destroy(){this.parent&&(this.parent.children.splice(this.parent.children.indexOf(this),1),this.parent.folders.splice(this.parent.folders.indexOf(this),1)),this.domElement.parentElement&&this.domElement.parentElement.removeChild(this.domElement),Array.from(this.children).forEach(e=>e.destroy())}controllersRecursive(){let e=Array.from(this.controllers);return this.folders.forEach(n=>{e=e.concat(n.controllersRecursive())}),e}foldersRecursive(){let e=Array.from(this.folders);return this.folders.forEach(n=>{e=e.concat(n.foldersRecursive())}),e}}function aP(t,e,n,r){return new(n||(n=Promise))((function(i,a){function o(u){try{c(r.next(u))}catch(d){a(d)}}function l(u){try{c(r.throw(u))}catch(d){a(d)}}function c(u){var d;u.done?i(u.value):(d=u.value,d instanceof n?d:new n((function(f){f(d)}))).then(o,l)}c((r=r.apply(t,[])).next())}))}class hL{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 hL(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 fL{constructor(e,n,r,i){this.src=e,this.gcode=n,this.params=r,this.comment=i}}class y7 extends fL{constructor(e,n,r,i){super(e,n,r,i),this.params=r}}class Od extends fL{constructor(e,n,r,i){super(e,n,void 0,r),this.toolIndex=i}}class v7{constructor(e,n,r,i=0){this.layer=e,this.commands=n,this.lineNumber=r,this.height=i}}class sN{constructor(e){this.lines=[],this.preamble=new v7(-1,[],0),this.layers=[],this.curZ=0,this.maxZ=0,this.metadata={thumbnails:{}},this.tolerance=0,this.tolerance=e??this.tolerance}parseGCode(e){const n=Array.isArray(e)?e:e.split(`
- `);this.lines=this.lines.concat(n);const r=this.lines2commands(n);this.groupIntoLayers(r);const i=this.parseMetadata(r.filter((a=>a.comment))).thumbnails;for(const[a,o]of Object.entries(i))this.metadata.thumbnails[a]=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(";"),a=i[0],o=n&&i[1]||void 0,l=a.split(/([a-zA-Z])/g).slice(1).map((d=>d.trim())),c=l.length?`${(r=l[0])===null||r===void 0?void 0:r.toLowerCase()}${l[1]}`:"",u=this.parseParams(l.slice(2));switch(c){case"g0":case"g00":case"g1":case"g01":case"g2":case"g02":case"g3":case"g03":return new y7(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 fL(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,a)=>{if(i%2==0)return n;let o=a[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 y7){const a=i.params;if(a.z&&(this.curZ=a.z),((n=a.e)!==null&&n!==void 0?n:0)>0&&(a.x!=null||a.y!=null)&&Math.abs(this.curZ-(this.maxZ||-1/0))>this.tolerance){const o=Math.abs(this.curZ-this.maxZ);this.maxZ=this.curZ,this.layers.push(new v7(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 a=i.comment;if(!a)continue;const o=a.indexOf("thumbnail begin"),l=a.indexOf("thumbnail end");o>-1?r=hL.parse(a.slice(o+15).trim()):r&&(l==-1?r.chars+=a.trim():(r.isValid&&(n[r.size]=r),r=void 0))}return{thumbnails:n}}}sN.prototype.parseGcode=sN.prototype.parseGCode;const w7={type:"change"},sP={type:"start"},_7={type:"end"},X_=new oL,S7=new Hd,s8e=Math.cos(70*YJ.DEG2RAD);class o8e extends Pm{constructor(e,n){super(),this.object=e,this.domElement=n,this.domElement.style.touchAction="none",this.enabled=!0,this.target=new qe,this.cursor=new qe,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:Rp.ROTATE,MIDDLE:Rp.DOLLY,RIGHT:Rp.PAN},this.touches={ONE:Op.ROTATE,TWO:Op.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(Y){Y.addEventListener("keydown",Oe),this._domElementKeyEvents=Y},this.stopListenToKeyEvents=function(){this._domElementKeyEvents.removeEventListener("keydown",Oe),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(w7),r.update(),a=i.NONE},this.update=(function(){const Y=new qe,ue=new vm().setFromUnitVectors(e.up,new qe(0,1,0)),q=ue.clone().invert(),te=new qe,U=new vm,he=new qe,Me=2*Math.PI;return function(ge=null){const B=r.object.position;Y.copy(B).sub(r.target),Y.applyQuaternion(ue),l.setFromVector3(Y),r.autoRotate&&a===i.NONE&&D((function(_e){return _e!==null?2*Math.PI/60*r.autoRotateSpeed*_e:2*Math.PI/60/60*r.autoRotateSpeed})(ge)),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,ee=r.maxAzimuthAngle;isFinite(O)&&isFinite(ee)&&(O<-Math.PI?O+=Me:O>Math.PI&&(O-=Me),ee<-Math.PI?ee+=Me:ee>Math.PI&&(ee-=Me),l.theta=O<=ee?Math.max(O,Math.min(ee,l.theta)):l.theta>(O+ee)/2?Math.max(O,l.theta):Math.min(ee,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=Q(l.radius):l.radius=Q(l.radius*u),Y.setFromSpherical(l),Y.applyQuaternion(q),B.copy(r.target).add(Y),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 _e=null;if(r.object.isPerspectiveCamera){const ve=Y.length();_e=Q(ve*u);const ae=ve-_e;r.object.position.addScaledVector(T,ae),r.object.updateMatrixWorld()}else if(r.object.isOrthographicCamera){const ve=new qe(M.x,M.y,0);ve.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 qe(M.x,M.y,0);ae.unproject(r.object),r.object.position.sub(ae).add(ve),r.object.updateMatrixWorld(),_e=Y.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),r.zoomToCursor=!1;_e!==null&&(this.screenSpacePanning?r.target.set(0,0,-1).transformDirection(r.object.matrix).multiplyScalar(_e).add(r.object.position):(X_.origin.copy(r.object.position),X_.direction.set(0,0,-1).transformDirection(r.object.matrix),Math.abs(r.object.up.dot(X_.direction))<s8e?e.lookAt(r.target):(S7.setFromNormalAndCoplanarPoint(r.object.up,r.target),X_.intersectPlane(S7,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||te.distanceToSquared(r.object.position)>o||8*(1-U.dot(r.object.quaternion))>o||he.distanceToSquared(r.target)>0)&&(r.dispatchEvent(w7),te.copy(r.object.position),U.copy(r.object.quaternion),he.copy(r.target),!0)}})(),this.dispose=function(){r.domElement.removeEventListener("contextmenu",pe),r.domElement.removeEventListener("pointerdown",de),r.domElement.removeEventListener("pointercancel",ie),r.domElement.removeEventListener("wheel",ke),r.domElement.removeEventListener("pointermove",Ce),r.domElement.removeEventListener("pointerup",ie),r._domElementKeyEvents!==null&&(r._domElementKeyEvents.removeEventListener("keydown",Oe),r._domElementKeyEvents=null)};const r=this,i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let a=i.NONE;const o=1e-6,l=new g7,c=new g7;let u=1;const d=new qe,f=new bn,p=new bn,m=new bn,x=new bn,b=new bn,v=new bn,y=new bn,S=new bn,k=new bn,T=new qe,M=new bn;let C=!1;const E=[],R={};function A(){return Math.pow(.95,r.zoomSpeed)}function D(Y){c.theta-=Y}function I(Y){c.phi-=Y}const F=(function(){const Y=new qe;return function(ue,q){Y.setFromMatrixColumn(q,0),Y.multiplyScalar(-ue),d.add(Y)}})(),z=(function(){const Y=new qe;return function(ue,q){r.screenSpacePanning===!0?Y.setFromMatrixColumn(q,1):(Y.setFromMatrixColumn(q,0),Y.crossVectors(r.object.up,Y)),Y.multiplyScalar(ue),d.add(Y)}})(),P=(function(){const Y=new qe;return function(ue,q){const te=r.domElement;if(r.object.isPerspectiveCamera){const U=r.object.position;Y.copy(U).sub(r.target);let he=Y.length();he*=Math.tan(r.object.fov/2*Math.PI/180),F(2*ue*he/te.clientHeight,r.object.matrix),z(2*q*he/te.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(F(ue*(r.object.right-r.object.left)/r.object.zoom/te.clientWidth,r.object.matrix),z(q*(r.object.top-r.object.bottom)/r.object.zoom/te.clientHeight,r.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),r.enablePan=!1)}})();function $(Y){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u/=Y:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function X(Y){r.object.isPerspectiveCamera||r.object.isOrthographicCamera?u*=Y:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),r.enableZoom=!1)}function V(Y){if(!r.zoomToCursor)return;C=!0;const ue=r.domElement.getBoundingClientRect(),q=Y.clientX-ue.left,te=Y.clientY-ue.top,U=ue.width,he=ue.height;M.x=q/U*2-1,M.y=-te/he*2+1,T.set(M.x,M.y,1).unproject(r.object).sub(r.object.position).normalize()}function Q(Y){return Math.max(r.minDistance,Math.min(r.maxDistance,Y))}function Z(Y){f.set(Y.clientX,Y.clientY)}function se(Y){x.set(Y.clientX,Y.clientY)}function H(){if(E.length===1)f.set(E[0].pageX,E[0].pageY);else{const Y=.5*(E[0].pageX+E[1].pageX),ue=.5*(E[0].pageY+E[1].pageY);f.set(Y,ue)}}function K(){if(E.length===1)x.set(E[0].pageX,E[0].pageY);else{const Y=.5*(E[0].pageX+E[1].pageX),ue=.5*(E[0].pageY+E[1].pageY);x.set(Y,ue)}}function re(){const Y=E[0].pageX-E[1].pageX,ue=E[0].pageY-E[1].pageY,q=Math.sqrt(Y*Y+ue*ue);y.set(0,q)}function ne(Y){if(E.length==1)p.set(Y.pageX,Y.pageY);else{const q=G(Y),te=.5*(Y.pageX+q.x),U=.5*(Y.pageY+q.y);p.set(te,U)}m.subVectors(p,f).multiplyScalar(r.rotateSpeed);const ue=r.domElement;D(2*Math.PI*m.x/ue.clientHeight),I(2*Math.PI*m.y/ue.clientHeight),f.copy(p)}function be(Y){if(E.length===1)b.set(Y.pageX,Y.pageY);else{const ue=G(Y),q=.5*(Y.pageX+ue.x),te=.5*(Y.pageY+ue.y);b.set(q,te)}v.subVectors(b,x).multiplyScalar(r.panSpeed),P(v.x,v.y),x.copy(b)}function me(Y){const ue=G(Y),q=Y.pageX-ue.x,te=Y.pageY-ue.y,U=Math.sqrt(q*q+te*te);S.set(0,U),k.set(0,Math.pow(S.y/y.y,r.zoomSpeed)),$(k.y),y.copy(S)}function de(Y){r.enabled!==!1&&(E.length===0&&(r.domElement.setPointerCapture(Y.pointerId),r.domElement.addEventListener("pointermove",Ce),r.domElement.addEventListener("pointerup",ie)),(function(ue){E.push(ue)})(Y),Y.pointerType==="touch"?(function(ue){switch(We(ue),E.length){case 1:switch(r.touches.ONE){case Op.ROTATE:if(r.enableRotate===!1)return;H(),a=i.TOUCH_ROTATE;break;case Op.PAN:if(r.enablePan===!1)return;K(),a=i.TOUCH_PAN;break;default:a=i.NONE}break;case 2:switch(r.touches.TWO){case Op.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;r.enableZoom&&re(),r.enablePan&&K(),a=i.TOUCH_DOLLY_PAN;break;case Op.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;r.enableZoom&&re(),r.enableRotate&&H(),a=i.TOUCH_DOLLY_ROTATE;break;default:a=i.NONE}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(sP)})(Y):(function(ue){let q;switch(ue.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 Rp.DOLLY:if(r.enableZoom===!1)return;(function(te){V(te),y.set(te.clientX,te.clientY)})(ue),a=i.DOLLY;break;case Rp.ROTATE:if(ue.ctrlKey||ue.metaKey||ue.shiftKey){if(r.enablePan===!1)return;se(ue),a=i.PAN}else{if(r.enableRotate===!1)return;Z(ue),a=i.ROTATE}break;case Rp.PAN:if(ue.ctrlKey||ue.metaKey||ue.shiftKey){if(r.enableRotate===!1)return;Z(ue),a=i.ROTATE}else{if(r.enablePan===!1)return;se(ue),a=i.PAN}break;default:a=i.NONE}a!==i.NONE&&r.dispatchEvent(sP)})(Y))}function Ce(Y){r.enabled!==!1&&(Y.pointerType==="touch"?(function(ue){switch(We(ue),a){case i.TOUCH_ROTATE:if(r.enableRotate===!1)return;ne(ue),r.update();break;case i.TOUCH_PAN:if(r.enablePan===!1)return;be(ue),r.update();break;case i.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;(function(q){r.enableZoom&&me(q),r.enablePan&&be(q)})(ue),r.update();break;case i.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;(function(q){r.enableZoom&&me(q),r.enableRotate&&ne(q)})(ue),r.update();break;default:a=i.NONE}})(Y):(function(ue){switch(a){case i.ROTATE:if(r.enableRotate===!1)return;(function(q){p.set(q.clientX,q.clientY),m.subVectors(p,f).multiplyScalar(r.rotateSpeed);const te=r.domElement;D(2*Math.PI*m.x/te.clientHeight),I(2*Math.PI*m.y/te.clientHeight),f.copy(p),r.update()})(ue);break;case i.DOLLY:if(r.enableZoom===!1)return;(function(q){S.set(q.clientX,q.clientY),k.subVectors(S,y),k.y>0?$(A()):k.y<0&&X(A()),y.copy(S),r.update()})(ue);break;case i.PAN:if(r.enablePan===!1)return;(function(q){b.set(q.clientX,q.clientY),v.subVectors(b,x).multiplyScalar(r.panSpeed),P(v.x,v.y),x.copy(b),r.update()})(ue)}})(Y))}function ie(Y){(function(ue){delete R[ue.pointerId];for(let q=0;q<E.length;q++)if(E[q].pointerId==ue.pointerId)return void E.splice(q,1)})(Y),E.length===0&&(r.domElement.releasePointerCapture(Y.pointerId),r.domElement.removeEventListener("pointermove",Ce),r.domElement.removeEventListener("pointerup",ie)),r.dispatchEvent(_7),a=i.NONE}function ke(Y){r.enabled!==!1&&r.enableZoom!==!1&&a===i.NONE&&(Y.preventDefault(),r.dispatchEvent(sP),(function(ue){V(ue),ue.deltaY<0?X(A()):ue.deltaY>0&&$(A()),r.update()})(Y),r.dispatchEvent(_7))}function Oe(Y){r.enabled!==!1&&r.enablePan!==!1&&(function(ue){let q=!1;switch(ue.code){case r.keys.UP:ue.ctrlKey||ue.metaKey||ue.shiftKey?I(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):P(0,r.keyPanSpeed),q=!0;break;case r.keys.BOTTOM:ue.ctrlKey||ue.metaKey||ue.shiftKey?I(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):P(0,-r.keyPanSpeed),q=!0;break;case r.keys.LEFT:ue.ctrlKey||ue.metaKey||ue.shiftKey?D(2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):P(r.keyPanSpeed,0),q=!0;break;case r.keys.RIGHT:ue.ctrlKey||ue.metaKey||ue.shiftKey?D(-2*Math.PI*r.rotateSpeed/r.domElement.clientHeight):P(-r.keyPanSpeed,0),q=!0}q&&(ue.preventDefault(),r.update())})(Y)}function pe(Y){r.enabled!==!1&&Y.preventDefault()}function We(Y){let ue=R[Y.pointerId];ue===void 0&&(ue=new bn,R[Y.pointerId]=ue),ue.set(Y.pageX,Y.pageY)}function G(Y){const ue=Y.pointerId===E[0].pointerId?E[1]:E[0];return R[ue.pointerId]}r.domElement.addEventListener("contextmenu",pe),r.domElement.addEventListener("pointerdown",de),r.domElement.addEventListener("pointercancel",ie),r.domElement.addEventListener("wheel",ke,{passive:!1}),this.update()}}Dt.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}},Rs.line={uniforms:lL.merge([Dt.common,Dt.fog,Dt.line]),vertexShader:`
- #include <common>
- #include <color_pars_vertex>
- #include <fog_pars_vertex>
- #include <logdepthbuf_pars_vertex>
- #include <clipping_planes_pars_vertex>
- uniform float linewidth;
- uniform vec2 resolution;
- attribute vec3 instanceStart;
- attribute vec3 instanceEnd;
- attribute vec3 instanceColorStart;
- attribute vec3 instanceColorEnd;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #ifdef USE_DASH
- uniform float dashScale;
- attribute float instanceDistanceStart;
- attribute float instanceDistanceEnd;
- varying float vLineDistance;
- #endif
- void trimSegment( const in vec4 start, inout vec4 end ) {
- // trim end segment so it terminates between the camera plane and the near plane
- // conservative estimate of the near plane
- float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
- float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
- float nearEstimate = - 0.5 * b / a;
- float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
- end.xyz = mix( start.xyz, end.xyz, alpha );
- }
- void main() {
- #ifdef USE_COLOR
- vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
- #endif
- #ifdef USE_DASH
- vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
- vUv = uv;
- #endif
- float aspect = resolution.x / resolution.y;
- // camera space
- vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
- vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
- #ifdef WORLD_UNITS
- worldStart = start.xyz;
- worldEnd = end.xyz;
- #else
- vUv = uv;
- #endif
- // special case for perspective projection, and segments that terminate either in, or behind, the camera plane
- // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
- // but we need to perform ndc-space calculations in the shader, so we must address this issue directly
- // perhaps there is a more elegant solution -- WestLangley
- bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
- if ( perspective ) {
- if ( start.z < 0.0 && end.z >= 0.0 ) {
- trimSegment( start, end );
- } else if ( end.z < 0.0 && start.z >= 0.0 ) {
- trimSegment( end, start );
- }
- }
- // clip space
- vec4 clipStart = projectionMatrix * start;
- vec4 clipEnd = projectionMatrix * end;
- // ndc space
- vec3 ndcStart = clipStart.xyz / clipStart.w;
- vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
- // direction
- vec2 dir = ndcEnd.xy - ndcStart.xy;
- // account for clip-space aspect ratio
- dir.x *= aspect;
- dir = normalize( dir );
- #ifdef WORLD_UNITS
- // get the offset direction as perpendicular to the view vector
- vec3 worldDir = normalize( end.xyz - start.xyz );
- vec3 offset;
- if ( position.y < 0.5 ) {
- offset = normalize( cross( start.xyz, worldDir ) );
- } else {
- offset = normalize( cross( end.xyz, worldDir ) );
- }
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- float forwardOffset = dot( worldDir, vec3( 0.0, 0.0, 1.0 ) );
- // don't extend the line if we're rendering dashes because we
- // won't be rendering the endcaps
- #ifndef USE_DASH
- // extend the line bounds to encompass endcaps
- start.xyz += - worldDir * linewidth * 0.5;
- end.xyz += worldDir * linewidth * 0.5;
- // shift the position of the quad so it hugs the forward edge of the line
- offset.xy -= dir * forwardOffset;
- offset.z += 0.5;
- #endif
- // endcaps
- if ( position.y > 1.0 || position.y < 0.0 ) {
- offset.xy += dir * 2.0 * forwardOffset;
- }
- // adjust for linewidth
- offset *= linewidth * 0.5;
- // set the world position
- worldPos = ( position.y < 0.5 ) ? start : end;
- worldPos.xyz += offset;
- // project the worldpos
- vec4 clip = projectionMatrix * worldPos;
- // shift the depth of the projected points so the line
- // segments overlap neatly
- vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
- clip.z = clipPose.z * clip.w;
- #else
- vec2 offset = vec2( dir.y, - dir.x );
- // undo aspect ratio adjustment
- dir.x /= aspect;
- offset.x /= aspect;
- // sign flip
- if ( position.x < 0.0 ) offset *= - 1.0;
- // endcaps
- if ( position.y < 0.0 ) {
- offset += - dir;
- } else if ( position.y > 1.0 ) {
- offset += dir;
- }
- // adjust for linewidth
- offset *= linewidth;
- // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
- offset /= resolution.y;
- // select end
- vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
- // back to clip space
- offset *= clip.w;
- clip.xy += offset;
- #endif
- gl_Position = clip;
- vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
- #include <logdepthbuf_vertex>
- #include <clipping_planes_vertex>
- #include <fog_vertex>
- }
- `,fragmentShader:`
- uniform vec3 diffuse;
- uniform float opacity;
- uniform float linewidth;
- #ifdef USE_DASH
- uniform float dashOffset;
- uniform float dashSize;
- uniform float gapSize;
- #endif
- varying float vLineDistance;
- #ifdef WORLD_UNITS
- varying vec4 worldPos;
- varying vec3 worldStart;
- varying vec3 worldEnd;
- #ifdef USE_DASH
- varying vec2 vUv;
- #endif
- #else
- varying vec2 vUv;
- #endif
- #include <common>
- #include <color_pars_fragment>
- #include <fog_pars_fragment>
- #include <logdepthbuf_pars_fragment>
- #include <clipping_planes_pars_fragment>
- vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
- float mua;
- float mub;
- vec3 p13 = p1 - p3;
- vec3 p43 = p4 - p3;
- vec3 p21 = p2 - p1;
- float d1343 = dot( p13, p43 );
- float d4321 = dot( p43, p21 );
- float d1321 = dot( p13, p21 );
- float d4343 = dot( p43, p43 );
- float d2121 = dot( p21, p21 );
- float denom = d2121 * d4343 - d4321 * d4321;
- float numer = d1343 * d4321 - d1321 * d4343;
- mua = numer / denom;
- mua = clamp( mua, 0.0, 1.0 );
- mub = ( d1343 + d4321 * ( mua ) ) / d4343;
- mub = clamp( mub, 0.0, 1.0 );
- return vec2( mua, mub );
- }
- void main() {
- #include <clipping_planes_fragment>
- #ifdef USE_DASH
- if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
- if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
- #endif
- float alpha = opacity;
- #ifdef WORLD_UNITS
- // Find the closest points on the view ray and the line segment
- vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
- vec3 lineDir = worldEnd - worldStart;
- vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
- vec3 p1 = worldStart + lineDir * params.x;
- vec3 p2 = rayEnd * params.y;
- vec3 delta = p1 - p2;
- float len = length( delta );
- float norm = len / linewidth;
- #ifndef USE_DASH
- #ifdef USE_ALPHA_TO_COVERAGE
- float dnorm = fwidth( norm );
- alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
- #else
- if ( norm > 0.5 ) {
- discard;
- }
- #endif
- #endif
- #else
- #ifdef USE_ALPHA_TO_COVERAGE
- // artifacts appear on some hardware if a derivative is taken within a conditional
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- float dlen = fwidth( len2 );
- if ( abs( vUv.y ) > 1.0 ) {
- alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
- }
- #else
- if ( abs( vUv.y ) > 1.0 ) {
- float a = vUv.x;
- float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
- float len2 = a * a + b * b;
- if ( len2 > 1.0 ) discard;
- }
- #endif
- #endif
- vec4 diffuseColor = vec4( diffuse, alpha );
- #include <logdepthbuf_fragment>
- #include <color_fragment>
- gl_FragColor = vec4( diffuseColor.rgb, alpha );
- #include <tonemapping_fragment>
- #include <colorspace_fragment>
- #include <fog_fragment>
- #include <premultiplied_alpha_fragment>
- }
- `};class xee extends Ah{constructor(e){super({type:"LineMaterial",uniforms:lL.clone(Rs.line.uniforms),vertexShader:Rs.line.vertexShader,fragmentShader:Rs.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return"WORLD_UNITS"in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS="":delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return"USE_DASH"in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return"USE_ALPHA_TO_COVERAGE"in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?(this.defines.USE_ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.USE_ALPHA_TO_COVERAGE,this.extensions.derivatives=!1))}}const N7=new rl,Y_=new qe;class bee extends GBe{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 ND(n,6,1);return this.setAttribute("instanceStart",new Jd(r,3,0)),this.setAttribute("instanceEnd",new Jd(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 ND(n,6,1);return this.setAttribute("instanceColorStart",new Jd(r,3,0)),this.setAttribute("instanceColorEnd",new Jd(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 IBe(e.geometry)),this}fromLineSegments(e){const n=e.geometry;return this.setPositions(n.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new rl);const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;e!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(e),N7.setFromBufferAttribute(n),this.boundingBox.union(N7))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new hc),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(e!==void 0&&n!==void 0){const r=this.boundingSphere.center;this.boundingBox.getCenter(r);let i=0;for(let a=0,o=e.count;a<o;a++)Y_.fromBufferAttribute(e,a),i=Math.max(i,r.distanceToSquared(Y_)),Y_.fromBufferAttribute(n,a),i=Math.max(i,r.distanceToSquared(Y_));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 M7=new qe,k7=new qe,Ca=new Cr,Pa=new Cr,Yl=new Cr,oP=new qe,lP=new zr,ja=new qBe,E7=new qe,Q_=new rl,Z_=new hc,Ql=new Cr;let Zl,Tf;function T7(t,e,n){return Ql.set(0,0,-e,1).applyMatrix4(t.projectionMatrix),Ql.multiplyScalar(1/Ql.w),Ql.x=Tf/n.width,Ql.y=Tf/n.height,Ql.applyMatrix4(t.projectionMatrixInverse),Ql.multiplyScalar(1/Ql.w),Math.abs(Math.max(Ql.x,Ql.y))}class l8e extends Dl{constructor(e=new bee,n=new xee({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)M7.fromBufferAttribute(n,o),k7.fromBufferAttribute(r,o),i[l]=l===0?0:i[l-1],i[l+1]=i[l]+M7.distanceTo(k7);const a=new ND(i,2,1);return e.setAttribute("instanceDistanceStart",new Jd(a,1,0)),e.setAttribute("instanceDistanceEnd",new Jd(a,1,1)),this}raycast(e,n){const r=this.material.worldUnits,i=e.camera;i!==null||r||console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.');const a=e.params.Line2!==void 0&&e.params.Line2.threshold||0;Zl=e.ray;const o=this.matrixWorld,l=this.geometry,c=this.material;let u,d;Tf=c.linewidth+a,l.boundingSphere===null&&l.computeBoundingSphere(),Z_.copy(l.boundingSphere).applyMatrix4(o),r?u=.5*Tf:u=T7(i,Math.max(i.near,Z_.distanceToPoint(Zl.origin)),c.resolution),Z_.radius+=u,Zl.intersectsSphere(Z_)!==!1&&(l.boundingBox===null&&l.computeBoundingBox(),Q_.copy(l.boundingBox).applyMatrix4(o),r?d=.5*Tf:d=T7(i,Math.max(i.near,Q_.distanceToPoint(Zl.origin)),c.resolution),Q_.expandByScalar(d),Zl.intersectsBox(Q_)!==!1&&(r?(function(f,p){const m=f.matrixWorld,x=f.geometry,b=x.attributes.instanceStart,v=x.attributes.instanceEnd;for(let y=0,S=Math.min(x.instanceCount,b.count);y<S;y++){ja.start.fromBufferAttribute(b,y),ja.end.fromBufferAttribute(v,y),ja.applyMatrix4(m);const k=new qe,T=new qe;Zl.distanceSqToSegment(ja.start,ja.end,T,k),T.distanceTo(k)<.5*Tf&&p.push({point:T,pointOnLine:k,distance:Zl.origin.distanceTo(T),object:f,face:null,faceIndex:y,uv:null,uv1:null})}})(this,n):(function(f,p,m){const x=p.projectionMatrix,b=f.material.resolution,v=f.matrixWorld,y=f.geometry,S=y.attributes.instanceStart,k=y.attributes.instanceEnd,T=Math.min(y.instanceCount,S.count),M=-p.near;Zl.at(1,Yl),Yl.w=1,Yl.applyMatrix4(p.matrixWorldInverse),Yl.applyMatrix4(x),Yl.multiplyScalar(1/Yl.w),Yl.x*=b.x/2,Yl.y*=b.y/2,Yl.z=0,oP.copy(Yl),lP.multiplyMatrices(p.matrixWorldInverse,v);for(let C=0,E=T;C<E;C++){if(Ca.fromBufferAttribute(S,C),Pa.fromBufferAttribute(k,C),Ca.w=1,Pa.w=1,Ca.applyMatrix4(lP),Pa.applyMatrix4(lP),Ca.z>M&&Pa.z>M)continue;if(Ca.z>M){const F=Ca.z-Pa.z,z=(Ca.z-M)/F;Ca.lerp(Pa,z)}else if(Pa.z>M){const F=Pa.z-Ca.z,z=(Pa.z-M)/F;Pa.lerp(Ca,z)}Ca.applyMatrix4(x),Pa.applyMatrix4(x),Ca.multiplyScalar(1/Ca.w),Pa.multiplyScalar(1/Pa.w),Ca.x*=b.x/2,Ca.y*=b.y/2,Pa.x*=b.x/2,Pa.y*=b.y/2,ja.start.copy(Ca),ja.start.z=0,ja.end.copy(Pa),ja.end.z=0;const R=ja.closestPointToPointParameter(oP,!0);ja.at(R,E7);const A=YJ.lerp(Ca.z,Pa.z,R),D=A>=-1&&A<=1,I=oP.distanceTo(E7)<.5*Tf;if(D&&I){ja.start.fromBufferAttribute(S,C),ja.end.fromBufferAttribute(k,C),ja.start.applyMatrix4(v),ja.end.applyMatrix4(v);const F=new qe,z=new qe;Zl.distanceSqToSegment(ja.start,ja.end,z,F),m.push({point:z,pointOnLine:F,distance:Zl.origin.distanceTo(z),object:f,face:null,faceIndex:C,uv:null,uv1:null})}}})(this,i,n)))}}class c8e extends _2{constructor(e,n,r,i,a=4473924,o=8947848){a=new Zt(a),o=new Zt(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?a: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?a: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 f=new ns;f.setAttribute("position",new Ai(c,3)),f.setAttribute("color",new Ai(u,3)),super(f,new gv({vertexColors:!0,toneMapped:!1}))}}function u8e(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),a=new _2(i,new zBe({color:new Zt(r),dashSize:3,gapSize:1}));return a.computeLineDistances(),a}var N0=function(){var t=0,e=document.createElement("div");function n(d){return e.appendChild(d.dom),d}function r(d){for(var f=0;f<e.children.length;f++)e.children[f].style.display=f===d?"block":"none";t=d}e.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",e.addEventListener("click",(function(d){d.preventDefault(),r(++t%e.children.length)}),!1);var i=(performance||Date).now(),a=i,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>=a+1e3&&(l.update(1e3*o/(d-a),100),a=d,o=0,u)){var f=performance.memory;u.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return d},update:function(){i=this.end()},domElement:e,setMode:r}};N0.Panel=function(t,e,n){var r=1/0,i=0,a=Math.round,o=a(window.devicePixelRatio||1),l=80*o,c=48*o,u=3*o,d=2*o,f=3*o,p=15*o,m=74*o,x=30*o,b=document.createElement("canvas");b.width=l,b.height=c,b.style.cssText="width:80px;height:48px";var v=b.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(f,p,m,x),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(f,p,m,x),{dom:b,update:function(y,S){r=Math.min(r,y),i=Math.max(i,y),v.fillStyle=n,v.globalAlpha=1,v.fillRect(0,0,l,p),v.fillStyle=e,v.fillText(a(y)+" "+t+" ("+a(r)+"-"+a(i)+")",u,d),v.drawImage(b,f+o,p,m-o,x,f,p,m-o,x),v.fillRect(f+m-o,p,o,x),v.fillStyle=n,v.globalAlpha=.9,v.fillRect(f+m-o,p,o,a((1-y/S)*x))}}};var d8e=N0;class A7{constructor(e,n){this.openFolders=[],this.watchedObject=e,this.options=n,this.gui=new aN,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 aN,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 h8e extends ns{constructor(e=[new qe],n=.6,r=.2,i=8){super(),this.type="ExtrusionGeometry",this.parameters={points:e,lineWidth:n,lineHeight:r,radialSegments:i,closed:!1};const a=new qe,o=new qe,l=new bn,c=[],u=[],d=[],f=[];function p(m){const[x,b,v]=(function(y){const S=e[y],k=new qe,T=new qe,M=new qe,C=new qe;k.copy(S).sub(e[y-1]||S).normalize().add((e[y+1]||S).clone().sub(S).normalize()).normalize();let E=Number.MAX_VALUE;const R=Math.abs(k.x),A=Math.abs(k.y),D=Math.abs(k.z);return R<=E&&(E=R,T.set(1,0,0)),A<=E&&(E=A,T.set(0,1,0)),D<=E&&T.set(0,0,1),C.crossVectors(k,T).normalize(),T.crossVectors(k,C),M.crossVectors(k,T),[S,T,M]})(m);for(let y=0;y<=i;y++){const S=y/i*Math.PI*2,k=Math.sin(S),T=-Math.cos(S);o.x=T*b.x+k*v.x,o.y=T*b.y+k*v.y,o.z=T*b.z+k*v.z,o.normalize(),u.push(o.x,o.y,o.z),a.x=x.x+n*o.x*.5,a.y=x.y+n*o.y*.5,a.z=x.z+r*o.z*.5,c.push(a.x,a.y,a.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 b=(i+1)*(m-1)+(x-1),v=(i+1)*m+(x-1),y=(i+1)*m+x,S=(i+1)*(m-1)+x;f.push(b,v,S),f.push(v,y,S)}})()})(),this.setIndex(f),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 cP={h:0,s:0,l:0};class Dg{constructor(e){var n,r,i,a,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=Dg.defaultExtrusionColor,this.renderLayerIndex=0,this._geometries={},this._backgroundColor=new Zt(14737632),this._travelColor=new Zt(10027008),this._toolColors={},this.devMode=!1,this._lastRenderTime=0,this._wireframe=!1,this.minLayerThreshold=(n=e.minLayerThreshold)!==null&&n!==void 0?n:this.minLayerThreshold,this.parser=new sN(this.minLayerThreshold),this.scene=new TBe,this.scene.background=this._backgroundColor,e.backgroundColor!==void 0&&(this.backgroundColor=new Zt(e.backgroundColor)),this.targetId=e.targetId,this.endLayer=e.endLayer,this.startLayer=e.startLayer,this.lineWidth=e.lineWidth,this.lineHeight=e.lineHeight,this.buildVolume=e.buildVolume,this.initialCameraPosition=(r=e.initialCameraPosition)!==null&&r!==void 0?r:this.initialCameraPosition,this.debug=(i=e.debug)!==null&&i!==void 0?i:this.debug,this.renderExtrusion=(a=e.renderExtrusion)!==null&&a!==void 0?a:this.renderExtrusion,this.renderTravel=(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 d8e:void 0,e.extrusionColor!==void 0&&(this.extrusionColor=e.extrusionColor),e.travelColor!==void 0&&(this.travelColor=new Zt(e.travelColor)),e.topLayerColor!==void 0&&(this.topLayerColor=new Zt(e.topLayerColor)),e.lastSegmentColor!==void 0&&(this.lastSegmentColor=new Zt(e.lastSegmentColor)),e.toolColors){this._toolColors={};for(const[m,x]of Object.entries(e.toolColors))this._toolColors[parseInt(m)]=new Zt(x)}if(e.disableGradient!==void 0&&(this.disableGradient=e.disableGradient),console.info("Using THREE r"+x2),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 SD({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 SD({preserveDrawingBuffer:!0}),this.canvas=this.renderer.domElement,m.appendChild(this.canvas)}this.camera=new so(25,this.canvas.offsetWidth/this.canvas.offsetHeight,10,5e3),this.camera.position.fromArray(this.initialCameraPosition);const f=this.camera.far,p=.8*f;this.scene.fog=new dL(this._backgroundColor,p,f),this.resize(),this.controls=new o8e(this.camera,this.renderer.domElement),this.initScene(),this.animate(),e.allowDragNDrop&&this._enableDropHandler(),this.initStats()}get extrusionColor(){return this._extrusionColor}set extrusionColor(e){if(Array.isArray(e)){this._extrusionColor=[];for(const[n,r]of e.entries())this._extrusionColor[n]=new Zt(r)}else this._extrusionColor=new Zt(e)}get currentToolColor(){var e;return this._extrusionColor===void 0?Dg.defaultExtrusionColor:this._extrusionColor instanceof Zt?this._extrusionColor:(e=this._extrusionColor[this.state.t])!==null&&e!==void 0?e:Dg.defaultExtrusionColor}get backgroundColor(){return this._backgroundColor}set backgroundColor(e){this._backgroundColor=new Zt(e),this.scene.background=this._backgroundColor}get travelColor(){return this._travelColor}set travelColor(e){this._travelColor=new Zt(e)}get topLayerColor(){return this._topLayerColor}set topLayerColor(e){this._topLayerColor=e!==void 0?new Zt(e):void 0}get lastSegmentColor(){return this._lastSegmentColor}set lastSegmentColor(e){this._lastSegmentColor=e!==void 0?new Zt(e):void 0}get layers(){return[this.parser.preamble].concat(this.parser.layers.concat())}get maxLayerIndex(){var e;return((e=this.endLayer)!==null&&e!==void 0?e:this.layers.length)-1}get minLayerIndex(){var e;return this.singleLayerMode?this.maxLayerIndex:((e=this.startLayer)!==null&&e!==void 0?e:0)-1}animate(){var e;this.animationFrameId=requestAnimationFrame((()=>this.animate())),this.controls.update(),this.renderer.render(this.scene,this.camera),(e=this.stats)===null||e===void 0||e.update()}processGCode(e){this.parser.parseGCode(e),this.render()}initScene(){for(;this.scene.children.length>0;)this.scene.remove(this.scene.children[0]);for(;this.disposables.length>0;){const e=this.disposables.pop();e&&e.dispose()}if(this.debug&&this.buildVolume){const e=new WBe(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 VBe(13421772,.3*Math.PI),n=new $Be(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 u0;return n.name=e,n.quaternion.setFromEuler(new mv(-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 aP(this,void 0,void 0,(function*(){return this.initScene(),this.renderLayerIndex=0,this.renderFrameLoop(e>0?e:1)}))}renderFrameLoop(e){return new Promise((n=>{const r=()=>{this.renderLayerIndex>this.layers.length-1?n():(this.renderFrame(e),requestAnimationFrame(r))};r()}))}renderFrame(e){this.group=this.createGroup("layer"+this.renderLayerIndex);for(let n=0;n<e&&this.renderLayerIndex+n<this.layers.length;n++)this.renderLayer(this.renderLayerIndex),this.renderLayerIndex++;this.batchGeometries(),this.scene.add(this.group)}renderLayer(e){var n,r,i,a,o,l,c,u;if(e>this.maxLayerIndex)return;const d=this.layers[e],f={extrusion:[],travel:[],z:this.state.z,height:d.height};for(const p of d.commands)if(p.gcode!="g20"){if(p.gcode.startsWith("t")){this.doRenderExtrusion(f,e),f.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:(a=m.params.r)!==null&&a!==void 0?a: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 b=((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)&&(b&&this.renderExtrusion||!b&&this.renderTravel)&&(p.gcode=="g2"||p.gcode=="g3"||p.gcode=="g02"||p.gcode=="g03"?this.addArcSegment(f,this.state,x,b,p.gcode=="g2"||p.gcode=="g02"):this.addLineSegment(f,this.state,x,b))}this.state.x=x.x,this.state.y=x.y,this.state.z=x.z,this.beyondFirstMove||(this.beyondFirstMove=!0)}}else this.setInches();this.doRenderExtrusion(f,e)}doRenderExtrusion(e,n){var r,i;if(this.renderExtrusion){let a=this.currentToolColor;if(!this.singleLayerMode&&!this.renderTubes&&!this.disableGradient){const o=.1+.7*n/this.layers.length;a.getHSL(cP),a=new Zt().setHSL(cP.h,cP.s,o)}if(n==this.layers.length-1){const o=(r=this._topLayerColor)!==null&&r!==void 0?r:a,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,a.getHex(),e.height):this.addLine(e.extrusion,a.getHex())}this.renderTravel&&this.addLine(e.travel,this._travelColor.getHex())}setInches(){this.beyondFirstMove?console.warn("Switching units after movement is already made is discouraged and is not supported."):this.inches=!0}drawBuildVolume(){if(!this.buildVolume)return;this.scene.add(new c8e(this.buildVolume.x,10,this.buildVolume.y,10));const e=u8e(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 sN(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,a){const o=i?e.extrusion:e.travel,l=n.x,c=n.y,u=n.z,d=r.x,f=r.y,p=r.z;let m=r.r,x=r.i,b=r.j;if(m){const $=d-l,X=f-c,V=Math.sqrt(Math.pow($/2,2)+Math.pow(X/2,2));m=Math.max(m,V);const Q=Math.pow($,2)+Math.pow(X,2),Z=Math.pow(m,2)-Q/4;let se=Math.sqrt(Z/Q);(a&&m<0||!a&&m>0)&&(se=-se),x=$/2+X*se,b=X/2-$*se}const v=l==d&&c==f,y=l+x,S=c+b,k=Math.sqrt(x*x+b*b),T=Math.atan2(-b,-x),M=Math.atan2(f-S,d-y);let C;v?C=2*Math.PI:(C=a?T-M:M-T,C<0&&(C+=2*Math.PI));let E=k*C/1.8;this.inches&&(E*=25),E<1&&(E=1);let R=C/E;R*=a?-1:1;const A=[];A.push({x:l,y:c,z:u});const D=(u-p)/E;let I=l,F=c,z=u,P=T;for(let $=0;$<E-1;$++)P+=R,I=y+k*Math.cos(P),F=S+k*Math.sin(P),z+=D,A.push({x:I,y:F,z});A.push({x:r.x,y:r.y,z:r.z});for(let $=0;$<A.length-1;$++)o.push(A[$].x,A[$].y,A[$].z,A[$+1].x,A[$+1].y,A[$+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 a=new gv({color:n});this.disposables.push(a);const o=new _2(i,a);(r=this.group)===null||r===void 0||r.add(o)}addTubeLine(e,n,r=.2){let i=[];const a=[];for(let o=0;o<e.length;o+=6){const l=e.slice(o,o+9),c=new qe(l[0],l[1],l[2]),u=new qe(l[3],l[4],l[5]),d=new qe(l[6],l[7],l[8]);i.push(c),u.equals(d)||(i.push(u),a.push(i),i=[])}a.forEach((o=>{var l;const c=new h8e(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 bee;this.disposables.push(i);const a=new xee({color:n,linewidth:this.lineWidth/(1e3*window.devicePixelRatio)});this.disposables.push(a),i.setPositions(e);const o=new l8e(i,a);(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=>aP(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 UBe({color:e,wireframe:this._wireframe});this.disposables.push(i);const a=r.reduce(((l,c)=>3*c.attributes.position.count+l),0),o=new LBe(r.length,a,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 aP(this,void 0,void 0,(function*(){const i=e.getReader();let a,o="",l=0;do{console.debug("reading from stream"),a=yield i.read(),l+=(r=(n=a.value)===null||n===void 0?void 0:n.length)!==null&&r!==void 0?r:0;const u=(c=a.value,new TextDecoder("utf-8").decode(c)),d=u.lastIndexOf(`
- `),f=u.slice(0,d);this.parser.parseGCode(o+f),o=u.slice(d)}while(!a.done);var c;console.debug("read from stream",l)}))}initGui(){typeof this.devMode=="boolean"&&this.devMode===!0?this.devGui=new A7(this):typeof this.devMode=="object"&&(this.devGui=new A7(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())}}Dg.defaultExtrusionColor=new Zt("hotpink");function f8e({gcodeUrl:t,buildVolume:e={x:256,y:256,z:256},filamentColors:n,className:r=""}){const i=_.useRef(null),a=_.useRef(null),o=_.useRef(null),l=_.useRef(!1),[c,u]=_.useState(!0),[d,f]=_.useState(null),[p,m]=_.useState(!1),[x,b]=_.useState(0),[v,y]=_.useState(0),S=_.useMemo(()=>JSON.stringify(n),[n]);_.useEffect(()=>{if(!i.current||l.current)return;l.current=!0;const M=i.current,C=M.parentElement?.getBoundingClientRect();C&&(M.width=C.width,M.height=C.height);const E=n&&n.length>1,R=n?.[0]||"#00ae42",A=new Dg({canvas:M,buildVolume:e,backgroundColor:1710618,extrusionColor:E?n:R,disableGradient:!0,lineHeight:.2,lineWidth:2,renderTravel:!1,renderExtrusion:!0});a.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 F=new Set,z=/^(\s*)T(\d+)(\s*;.*)?$/gim;let P;for(;(P=z.exec(I))!==null;){const se=parseInt(P[2],10);se<=15&&F.add(se)}const $=new Map,X=Array.from(F).sort((se,H)=>se-H);X.forEach((se,H)=>{$.set(se,H%8)});const V=[];X.forEach((se,H)=>{const K=n?.[se]||"#00ae42";V[H%8]=K});const Q=I.split(`
- `).map(se=>{const H=se.match(/^(\s*)T(\d+)(\s*;.*)?$/i);if(H){const K=parseInt(H[2],10);if(K>15)return`; FILTERED: ${se.trim()}`;const re=$.get(K)??0;return`${H[1]}T${re}${H[3]||""}`}return se}).join(`
- `);V.length>0&&(A.extrusionColor=V),A.processGCode(Q);const Z=A.layers?.length||0;y(Z),b(Z),A.render(),u(!1)}).catch(I=>{I.message!=="not_sliced"&&f(I.message),u(!1)});const D=()=>{if(M.parentElement&&a.current){const I=M.parentElement.getBoundingClientRect();M.width=I.width,M.height=I.height,a.current.resize()}};return window.addEventListener("resize",D),()=>{window.removeEventListener("resize",D),o.current&&cancelAnimationFrame(o.current),a.current&&(a.current.dispose(),a.current=null),l.current=!1}},[t,S]);const k=_.useCallback(M=>{if(!a.current)return;const C=Math.max(1,Math.min(M,v));b(C),o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(()=>{a.current&&(a.current.endLayer=C,a.current.render())})},[v]),T=M=>{k(parseInt(M.target.value,10))};return s.jsxs("div",{className:`relative flex flex-col h-full ${r}`,children:[s.jsxs("div",{className:"flex-1 relative bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("canvas",{ref:i,className:"w-full h-full"}),c&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsxs("div",{className:"text-center",children:[s.jsx(ft,{className:"w-8 h-8 animate-spin text-bambu-green mx-auto mb-2"}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"Loading G-code..."})]})}),p&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsxs("div",{className:"text-center max-w-sm px-4",children:[s.jsx(jue,{className:"w-12 h-12 text-bambu-gray mx-auto mb-3"}),s.jsx("p",{className:"text-white font-medium mb-2",children:"G-code not available"}),s.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&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-bambu-dark/80",children:s.jsx("div",{className:"text-center text-red-400",children:s.jsx("p",{className:"text-sm",children:d})})})]}),!c&&!d&&!p&&v>0&&s.jsx("div",{className:"mt-4 px-2",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(sl,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("button",{onClick:()=>k(x-1),disabled:x<=1,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(gh,{className:"w-4 h-4"})}),s.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"}),s.jsx("button",{onClick:()=>k(x+1),disabled:x>=v,className:"p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-30 disabled:cursor-not-allowed",children:s.jsx(gs,{className:"w-4 h-4"})}),s.jsxs("span",{className:"text-sm text-bambu-gray min-w-[80px] text-right",children:[x," / ",v]})]})})]})}function yee({archiveId:t,title:e,onClose:n}){const[r,i]=_.useState(null),[a,o]=_.useState(null),[l,c]=_.useState(!0);_.useEffect(()=>{const d=f=>{f.key==="Escape"&&n()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),_.useEffect(()=>{ce.getArchiveCapabilities(t).then(d=>{o(d),d.has_model?i("3d"):d.has_gcode&&i("gcode"),c(!1)}).catch(()=>{o({has_model:!0,has_gcode:!1,has_source:!1,build_volume:{x:256,y:256,z:256},filament_colors:[]}),i("3d"),c(!1)})},[t]);const u=()=>{const d=e||"model",f=`${window.location.origin}${ce.getArchiveForSlicer(t,d)}`;pu(f)};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-8",onClick:n,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col",onClick:d=>d.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white truncate flex-1 mr-4",children:e}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:u,children:[s.jsx(Xr,{className:"w-4 h-4"}),"Open in Slicer"]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:n,children:s.jsx(Rt,{className:"w-5 h-5"})})]})]}),a&&s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[s.jsxs("button",{onClick:()=>a.has_model&&i("3d"),disabled:!a.has_model,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="3d"?"text-bambu-green border-b-2 border-bambu-green":a.has_model?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[s.jsx(oo,{className:"w-4 h-4"}),"3D Model",!a.has_model&&s.jsx("span",{className:"text-xs",children:"(not available)"})]}),s.jsxs("button",{onClick:()=>a.has_gcode&&i("gcode"),disabled:!a.has_gcode,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${r==="gcode"?"text-bambu-green border-b-2 border-bambu-green":a.has_gcode?"text-bambu-gray hover:text-white":"text-bambu-gray/30 cursor-not-allowed"}`,children:[s.jsx(sue,{className:"w-4 h-4"}),"G-code Preview",!a.has_gcode&&s.jsx("span",{className:"text-xs",children:"(not sliced)"})]})]}),s.jsx("div",{className:"flex-1 overflow-hidden p-4",children:l?s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(ft,{className:"w-8 h-8 animate-spin text-bambu-green"})}):r==="3d"&&a?s.jsx(uLe,{url:a.has_source?ce.getSource3mfDownloadUrl(t):ce.getArchiveDownload(t),buildVolume:a.build_volume,filamentColors:a.filament_colors,className:"w-full h-full"}):r==="gcode"&&a?s.jsx(f8e,{gcodeUrl:ce.getArchiveGcode(t),filamentColors:a.filament_colors,className:"w-full h-full"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:"No preview available for this file"})})]})})}const C7={"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 m8e(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),a=Math.max(n,r,i)/255,o=Math.min(n,r,i)/255,l=(a+o)/2;let c=0,u=0;if(a!==o){const d=a-o;u=l>.5?d/(2-a-o):d/(a+o);const f=n/255,p=r/255,m=i/255;a===f?c=((p-m)/d+(p<m?6:0))/6:a===p?c=((m-f)/d+2)/6:c=((f-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 sx(t){const e=t.replace("#","").toLowerCase().substring(0,6);return C7[e]?C7[e]:m8e(t)}function oN(t){return t?`#${t.replace("#","").substring(0,6)}`:"#808080"}function wa(t){return t?t.replace("#","").toLowerCase().substring(0,6):""}function Ch(t,e,n=40){const r=wa(t),i=wa(e);if(!r||!i||r.length<6||i.length<6)return!1;const a=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(a-c)<=n&&Math.abs(o-u)<=n&&Math.abs(l-d)<=n}function vee(t,e,n,r){const i=String.fromCharCode(65+(t>=128?t-128:t));return n?`HT-${i}`:`AMS-${i} Slot ${e+1}`}function wee(t,e,n){return t*4+e}function p8e(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 P7(t){if(!t)return!1;const e=Date.now()+4320*60*60*1e3;return new Date(t).getTime()>e}function mL(t){const e=[];if(t?.ams?.forEach(n=>{const r=n.tray.length===1;n.tray.forEach(i=>{if(i.tray_type){const a=oN(i.tray_color);e.push({type:i.tray_type,color:a,colorName:sx(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:vee(n.id,i.id,r),globalTrayId:wee(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=oN(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:sx(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e}function j7(t,e){if(!t?.filaments||t.filaments.length===0)return;const n=mL(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()&&wa(p.color)===wa(l.color)),u=!c&&n.find(p=>!r.has(p.globalTrayId)&&p.type?.toUpperCase()===l.type?.toUpperCase()&&Ch(p.color,l.color)),d=!c&&!u&&n.find(p=>!r.has(p.globalTrayId)&&p.type?.toUpperCase()===l.type?.toUpperCase()),f=c||u||d||void 0;return f&&r.add(f.globalTrayId),{slot_id:l.slot_id,globalTrayId:f?.globalTrayId??-1}}),a=Math.max(...i.map(l=>l.slot_id||0));if(a<=0)return;const o=new Array(a).fill(-1);return i.forEach(l=>{l.slot_id&&l.slot_id>0&&(o[l.slot_id-1]=l.globalTrayId)}),o}function g8e(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 a=oN(i.tray_color);e.push({type:i.tray_type,color:a,colorName:sx(a),amsId:n.id,trayId:i.id,isHt:r,isExternal:!1,label:vee(n.id,i.id,r),globalTrayId:wee(n.id,i.id)})}})}),t?.vt_tray?.tray_type){const n=oN(t.vt_tray.tray_color);e.push({type:t.vt_tray.tray_type,color:n,colorName:sx(n),amsId:-1,trayId:0,isHt:!1,isExternal:!0,label:"External",globalTrayId:254})}return e},[t])}function _ee(t,e,n){const r=g8e(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 k=n[d],T=r.find(M=>M.globalTrayId===k);if(T){const M=T.type?.toUpperCase()===u.type?.toUpperCase(),C=wa(T.color)===wa(u.color)||Ch(T.color,u.color);let E;return M&&C?E="match":M?E="type_only":E="mismatch",{...u,loaded:T,hasFilament:!0,typeMatch:M,colorMatch:C,status:E,isManual:!0}}}const f=r.find(k=>!c.has(k.globalTrayId)&&k.type?.toUpperCase()===u.type?.toUpperCase()&&wa(k.color)===wa(u.color)),p=!f&&r.find(k=>!c.has(k.globalTrayId)&&k.type?.toUpperCase()===u.type?.toUpperCase()&&Ch(k.color,u.color)),m=!f&&!p&&r.find(k=>!c.has(k.globalTrayId)&&k.type?.toUpperCase()===u.type?.toUpperCase()),x=f||p||m||void 0;x&&c.add(x.globalTrayId);const b=!!x,v=b,y=!!f||!!p;let S;return f||p?S="match":m?S="type_only":S="mismatch",{...u,loaded:x,hasFilament:b,typeMatch:v,colorMatch:y,status:S,isManual:!1}})},[t,r,n]),a=_.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:a,hasTypeMismatch:o,hasColorMismatch:l}}function x8e(t,e,n){if(!t||t.length===0)return{exactMatches:0,typeOnlyMatches:0,missingTypes:0,totalSlots:0,status:"full"};let r=0,i=0,a=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 b=n[d],v=e.find(y=>y.globalTrayId===b);if(v){const y=v.type?.toUpperCase()===u.type?.toUpperCase(),S=wa(v.color)===wa(u.color)||Ch(v.color,u.color);y&&S?r++:y?i++:a++;continue}}const f=e.find(b=>!o.has(b.globalTrayId)&&b.type?.toUpperCase()===u.type?.toUpperCase()&&wa(b.color)===wa(u.color)),p=f?void 0:e.find(b=>!o.has(b.globalTrayId)&&b.type?.toUpperCase()===u.type?.toUpperCase()&&Ch(b.color,u.color)),m=f||p?void 0:e.find(b=>!o.has(b.globalTrayId)&&b.type?.toUpperCase()===u.type?.toUpperCase()),x=f??p??m;x&&o.add(x.globalTrayId),f||p?r++:m?i++:a++}const l=t.length;let c="full";return a>0?c="missing":i>0&&(c="partial"),{exactMatches:r,typeOnlyMatches:i,missingTypes:a,totalSlots:l,status:c}}function b8e(t,e,n){if(!t?.filaments||t.filaments.length===0)return;const r=mL(e);if(r.length===0)return;const i=new Set(Object.values(n)),a=[];for(const c of t.filaments){const u=c.slot_id||0;if(u>0&&n[u]!==void 0){a.push({slot_id:u,globalTrayId:n[u]});continue}const d=r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()&&wa(x.color)===wa(c.color)),f=d?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()&&Ch(x.color,c.color)),p=d||f?void 0:r.find(x=>!i.has(x.globalTrayId)&&x.type?.toUpperCase()===c.type?.toUpperCase()),m=d??f??p;m&&i.add(m.globalTrayId),a.push({slot_id:u,globalTrayId:m?.globalTrayId??-1})}const o=Math.max(...a.map(c=>c.slot_id||0));if(o<=0)return;const l=new Array(o).fill(-1);return a.forEach(c=>{c.slot_id&&c.slot_id>0&&(l[c.slot_id-1]=c.globalTrayId)}),l}const D7={useDefault:!0,manualMappings:{},autoConfigured:!1};function y8e(t,e,n,r,i,a){const o=pW({queries:t.map(x=>({queryKey:["printer-status",x],queryFn:()=>ce.getPrinterStatus(x),enabled:t.length>0,staleTime:5e3}))}),l=_.useMemo(()=>t.map((x,b)=>{const v=o[b],y=v?.data,k=e?.find(D=>D.id===x)?.name||`Printer ${x}`,T=mL(y),M=i[x]||D7,C=j7(n,y),E=M.useDefault?r:M.manualMappings,R=b8e(n,y,E),A=x8e(n?.filaments,T,E);return{printerId:x,printerName:k,status:y,isLoading:v?.isLoading??!1,loadedFilaments:T,autoMapping:C,finalMapping:R,matchStatus:A.status,exactMatches:A.exactMatches,typeOnlyMatches:A.typeOnlyMatches,missingTypes:A.missingTypes,totalSlots:A.totalSlots,config:M}}),[t,o,e,n,i,r]),c=o.some(x=>x.isLoading),u=(x,b)=>{a(v=>({...v,[x]:{...v[x]||D7,...b}}))},d=x=>{const b=l.find(S=>S.printerId===x);if(!b||!b.status||!n?.filaments)return;const v=j7(n,b.status);if(!v)return;const y={};v.forEach((S,k)=>{S!==-1&&(y[k+1]=S)}),u(x,{useDefault:!1,manualMappings:y,autoConfigured:!0})},f=()=>{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:f,autoConfigurePrinter:d,getFinalMapping:p,allPrintersReady:m}}function v8e({printerResult:t,filamentReqs:e,onUpdateConfig:n}){const r=sn(),[i,a]=_.useState(!1),o=(u,d)=>{if(u<=0)return;const f={...t.config.manualMappings};d===""?delete f[u]:f[u]=parseInt(d,10),n({useDefault:!1,manualMappings:f,autoConfigured:!1})},l=async()=>{a(!0);try{await ce.refreshPrinterStatus(t.printerId),await new Promise(u=>setTimeout(u,500)),await r.refetchQueries({queryKey:["printer-status",t.printerId]})}finally{a(!1)}},c=e.map(u=>{const d=u.slot_id||0,f=t.config.manualMappings[d];let p,m=!1;if(f!==void 0)p=t.loadedFilaments.find(b=>b.globalTrayId===f),m=!0;else{const b=new Set(Object.values(t.config.manualMappings)),v=t.loadedFilaments.find(k=>!b.has(k.globalTrayId)&&k.type?.toUpperCase()===u.type?.toUpperCase()&&wa(k.color)===wa(u.color)),y=v?void 0:t.loadedFilaments.find(k=>!b.has(k.globalTrayId)&&k.type?.toUpperCase()===u.type?.toUpperCase()&&Ch(k.color,u.color)),S=v||y?void 0:t.loadedFilaments.find(k=>!b.has(k.globalTrayId)&&k.type?.toUpperCase()===u.type?.toUpperCase());p=v??y??S}let x="mismatch";if(p){const b=p.type?.toUpperCase()===u.type?.toUpperCase(),v=wa(p.color)===wa(u.color)||Ch(p.color,u.color);b&&v?x="match":b&&(x="type_only")}return{req:u,loaded:p,status:x,isManual:m}});return s.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom slot mapping"}),s.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:[s.jsx(Dr,{className:`w-3 h-3 ${i?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),c.map(({req:u,loaded:d,status:f,isManual:p},m)=>s.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[s.jsx("span",{title:`Required: ${u.type} - ${sx(u.color)}`,children:s.jsx(dj,{className:"w-3 h-3",fill:u.color,stroke:u.color})}),s.jsxs("span",{className:"text-white truncate",children:[u.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",u.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:d?.globalTrayId??"",onChange:x=>o(u.slot_id||0,x.target.value),className:`flex-1 px-2 py-1 rounded border text-xs bg-bambu-dark-secondary focus:outline-none focus:ring-1 focus:ring-bambu-green ${f==="match"?"border-bambu-green/50 text-bambu-green":f==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${p?"ring-1 ring-blue-400/50":""}`,title:p?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),t.loadedFilaments.map(x=>s.jsxs("option",{value:x.globalTrayId,className:"bg-bambu-dark text-white",children:[x.label,": ",x.type," (",x.colorName,")"]},x.globalTrayId))]}),f==="match"?s.jsx(Na,{className:"w-3 h-3 text-bambu-green"}):f==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(Sn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(Sn,{className:"w-3 h-3 text-orange-400"})})]},m))]})}function w8e({printers:t,selectedPrinterIds:e,onMultiSelect:n,isLoading:r=!1,allowMultiple:i=!1,showInactive:a=!1,printerMappingResults:o,filamentReqs:l,onAutoConfigurePrinter:c,onUpdatePrinterConfig:u,assignmentMode:d="printer",onAssignmentModeChange:f,targetModel:p,onTargetModelChange:m,targetLocation:x,onTargetLocationChange:b,slicedForModel:v}){const[y,S]=_.useState(!1),k=a?t:t.filter(V=>V.is_active),T=_.useMemo(()=>{if(d!=="printer"||!v||y)return k;const V=k.filter(Q=>Q.model===v);return V.length>0?V:k},[k,d,v,y]),M=k.length-T.length,C=_.useMemo(()=>{const V=k.map(Q=>Q.model).filter(Q=>!!Q);return[...new Set(V)].sort()},[k]),E=_.useMemo(()=>{if(!p)return[];const V=k.filter(Q=>Q.model===p&&Q.location).map(Q=>Q.location).filter(Q=>!!Q);return[...new Set(V)].sort()},[k,p]),R=f&&m&&C.length>0,A=i&&e.length>1&&o&&l?.filaments&&l.filaments.length>0&&c&&u;if(r)return s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(T.length===0)return s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm mb-4",children:[s.jsx($i,{className:"w-4 h-4"}),"No ",a?"":"active ","printers available"]});const D=V=>{i?e.includes(V)?n(e.filter(Q=>Q!==V)):n([...e,V]):n([V])},I=()=>{n(T.map(V=>V.id))},F=()=>{n([])},z=(V,Q,Z)=>{Z.stopPropagation(),!(!c||!u)&&(Q?c(V):u(V,{useDefault:!0,manualMappings:{},autoConfigured:!1}))},P=V=>e.includes(V),$=e.length,X=V=>o?.find(Q=>Q.printerId===V);return s.jsxs("div",{className:"space-y-2 mb-6",children:[R&&s.jsxs("div",{className:"flex gap-2 mb-4",children:[s.jsxs("button",{type:"button",onClick:()=>{f("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:[s.jsx(Ur,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm",children:"Specific Printer"})]}),s.jsxs("button",{type:"button",onClick:()=>{f("model"),n([]);const V=v&&C.includes(v)?v:C[0];m(V)},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:[s.jsx(mg,{className:"w-4 h-4"}),s.jsxs("span",{className:"text-sm",children:["Any ",v||"Model"]})]})]}),d==="model"&&R&&s.jsxs("div",{className:"space-y-3 mb-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Target Model"}),s.jsxs("select",{value:p||"",onChange:V=>{m(V.target.value||null),b&&b(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:[s.jsx("option",{value:"",children:"Select a model..."}),C.map(V=>s.jsx("option",{value:V,children:V},V))]})]}),p&&E.length>0&&b&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Location Filter (optional)"}),s.jsxs("select",{value:x||"",onChange:V=>b(V.target.value||null),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm",children:[s.jsx("option",{value:"",children:"Any location"}),E.map(V=>s.jsx("option",{value:V,children:V},V))]})]}),p&&s.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&&s.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray mb-2",children:[s.jsx("span",{children:$===0?"Select printers":`${$} printer${$!==1?"s":""} selected`}),s.jsxs("div",{className:"flex gap-2",children:[$<T.length&&s.jsx("button",{type:"button",onClick:I,className:"text-bambu-green hover:text-bambu-green/80 transition-colors",children:"Select all"}),$>0&&s.jsx("button",{type:"button",onClick:F,className:"text-bambu-gray hover:text-white transition-colors",children:"Clear"})]})]}),d==="printer"&&T.map(V=>{const Q=P(V.id),Z=X(V.id),se=Z&&!Z.config.useDefault;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>D(V.id),className:`w-full flex items-center gap-3 p-3 rounded-lg border transition-colors ${Q?"border-bambu-green bg-bambu-green/10":"border-bambu-dark-tertiary bg-bambu-dark hover:border-bambu-gray"} ${V.is_active?"":"opacity-60"}`,children:[s.jsx("div",{className:`p-2 rounded-lg ${Q?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:s.jsx(Ur,{className:`w-5 h-5 ${Q?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{className:"text-left flex-1",children:[s.jsxs("p",{className:"text-white font-medium",children:[V.name,!V.is_active&&s.jsx("span",{className:"text-bambu-gray text-xs ml-2",children:"(inactive)"})]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[V.model||"Unknown model"," • ",V.ip_address]})]}),i&&s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center transition-colors ${Q?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:Q&&s.jsx(Na,{className:"w-3 h-3 text-white"})})]}),Q&&A&&Z&&s.jsxs("div",{className:"ml-4 mt-2 mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",onClick:H=>H.stopPropagation(),children:[s.jsx("input",{type:"checkbox",checked:se,onChange:H=>z(V.id,H.target.checked,H),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"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"Custom mapping"})]}),s.jsxs("span",{className:`text-xs ml-2 ${Z.matchStatus==="full"?"text-bambu-green":Z.matchStatus==="partial"?"text-yellow-400":"text-orange-400"}`,children:["(",Z.exactMatches,"/",Z.totalSlots," matched)"]}),Z.isLoading&&s.jsx(Dr,{className:"w-3 h-3 text-bambu-gray animate-spin"}),se&&s.jsxs("button",{type:"button",onClick:H=>{H.stopPropagation(),c(V.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:[s.jsx(gfe,{className:"w-3 h-3"}),"Auto"]})]}),se&&s.jsx(v8e,{printerResult:Z,filamentReqs:l.filaments,onUpdateConfig:H=>u(V.id,H)})]})]},V.id)}),d==="printer"&&M>0&&!y&&s.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:[s.jsx(Sn,{className:"w-3 h-3 text-yellow-400"}),M," other printer",M>1?"s":""," hidden (different model) —",s.jsx("span",{className:"underline",children:"show all"})]}),d==="printer"&&y&&v&&s.jsx("button",{type:"button",onClick:()=>S(!1),className:"text-xs text-bambu-gray hover:text-white transition-colors mt-2",children:s.jsxs("span",{className:"underline",children:["Show only ",v," printers"]})}),d==="printer"&&$===0&&s.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[s.jsx($i,{className:"w-3 h-3"}),"Select at least one printer"]}),d==="model"&&!p&&s.jsxs("p",{className:"text-xs text-orange-400 mt-1 flex items-center gap-1",children:[s.jsx($i,{className:"w-3 h-3"}),"Select a target printer model"]})]})}function _8e({plates:t,isMultiPlate:e,selectedPlate:n,onSelect:r}){return!e||t.length<=1?null:s.jsxs("div",{className:"mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(sl,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Select Plate to Print"}),!n&&s.jsxs("span",{className:"text-xs text-orange-400 flex items-center gap-1",children:[s.jsx(Sn,{className:"w-3 h-3"}),"Selection required"]})]}),s.jsx("div",{className:"grid grid-cols-2 gap-2",children:t.map(i=>s.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?s.jsx("img",{src:i.thumbnail_url,alt:`Plate ${i.index}`,className:"w-10 h-10 rounded object-cover bg-bambu-dark-tertiary"}):s.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:s.jsx(sl,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm text-white font-medium truncate",children:i.name||`Plate ${i.index}`}),s.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?` • ${p8e(i.print_time_seconds)}`:""]})]}),n===i.index&&s.jsx(Na,{className:"w-4 h-4 text-bambu-green flex-shrink-0"})]},i.index))})]})}function S8e({printerId:t,filamentReqs:e,manualMappings:n,onManualMappingChange:r,defaultExpanded:i=!1}){const a=sn(),[o,l]=_.useState(!1),[c,u]=_.useState(i),{data:d}=ot({queryKey:["printer-status",t],queryFn:()=>ce.getPrinterStatus(t),enabled:!!t}),{loadedFilaments:f,filamentComparison:p,hasTypeMismatch:m,hasColorMismatch:x}=_ee(e,d,n);if(!(e?.filaments&&e.filaments.length>0)||!d)return null;const v=m?"#f97316":x?"#facc15":"#00ae42",y=(k,T)=>{if(k>0)if(T===""){const M={...n};delete M[k],r(M)}else r({...n,[k]:parseInt(T,10)})},S=async()=>{l(!0);try{await ce.refreshPrinterStatus(t),await new Promise(k=>setTimeout(k,500)),await a.refetchQueries({queryKey:["printer-status",t]})}finally{l(!1)}};return s.jsxs("div",{className:"mb-4",children:[s.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:[s.jsx(dj,{className:"w-4 h-4",fill:v,stroke:"none"}),s.jsx("span",{children:"Filament Mapping"}),m?s.jsx("span",{className:"text-xs text-orange-400",children:"(Type not found)"}):x?s.jsx("span",{className:"text-xs text-yellow-400",children:"(Color mismatch)"}):s.jsx("span",{className:"text-xs text-bambu-green",children:"(Ready)"}),c?s.jsx(xh,{className:"w-4 h-4 ml-auto"}):s.jsx(Kr,{className:"w-4 h-4 ml-auto"})]}),c&&s.jsxs("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Click to change slot assignment"}),s.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:[s.jsx(Dr,{className:`w-3 h-3 ${o?"animate-spin":""}`}),s.jsx("span",{children:"Re-read"})]})]}),p.map((k,T)=>s.jsxs("div",{className:"grid items-center gap-2 text-xs",style:{gridTemplateColumns:"16px minmax(70px, 1fr) auto 2fr 16px"},children:[s.jsx("span",{title:`Required: ${k.type} - ${sx(k.color)}`,children:s.jsx(dj,{className:"w-3 h-3",fill:k.color,stroke:k.color})}),s.jsxs("span",{className:"text-white truncate",children:[k.type," ",s.jsxs("span",{className:"text-bambu-gray",children:["(",k.used_grams,"g)"]})]}),s.jsx("span",{className:"text-bambu-gray",children:"→"}),s.jsxs("select",{value:k.loaded?.globalTrayId??"",onChange:M=>y(k.slot_id||0,M.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 ${k.status==="match"?"border-bambu-green/50 text-bambu-green":k.status==="type_only"?"border-yellow-400/50 text-yellow-400":"border-orange-400/50 text-orange-400"} ${k.isManual?"ring-1 ring-blue-400/50":""}`,title:k.isManual?"Manually selected":"Auto-matched",children:[s.jsx("option",{value:"",className:"bg-bambu-dark text-bambu-gray",children:"-- Select slot --"}),f.map(M=>s.jsxs("option",{value:M.globalTrayId,className:"bg-bambu-dark text-white",children:[M.label,": ",M.type," (",M.colorName,")"]},M.globalTrayId))]}),k.status==="match"?s.jsx(Na,{className:"w-3 h-3 text-bambu-green"}):k.status==="type_only"?s.jsx("span",{title:"Same type, different color",children:s.jsx(Sn,{className:"w-3 h-3 text-yellow-400"})}):s.jsx("span",{title:"Filament type not loaded",children:s.jsx(Sn,{className:"w-3 h-3 text-orange-400"})})]},T)),m&&s.jsx("p",{className:"text-xs text-orange-400 mt-2",children:"Required filament type not found in printer."})]})]})}const N8e=[{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 M8e({options:t,onChange:e,defaultExpanded:n=!1}){const[r,i]=_.useState(n),a=o=>{e({...t,[o]:!t[o]})};return s.jsxs("div",{className:"mb-4",children:[s.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:[s.jsx(xM,{className:"w-4 h-4"}),s.jsx("span",{children:"Print Options"}),r?s.jsx(xh,{className:"w-4 h-4 ml-auto"}):s.jsx(Kr,{className:"w-4 h-4 ml-auto"})]}),r&&s.jsx("div",{className:"mt-2 bg-bambu-dark rounded-lg p-3 space-y-2",children:N8e.map(({key:o,label:l,desc:c})=>s.jsxs("label",{className:"flex items-center justify-between cursor-pointer group",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:l}),s.jsx("p",{className:"text-xs text-bambu-gray",children:c})]}),s.jsx("div",{className:`relative w-10 h-5 rounded-full transition-colors ${t[o]?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,onClick:()=>a(o),children:s.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 k8e({options:t,onChange:e,dateFormat:n="system",timeFormat:r="system"}){const[i,a]=_.useState(""),[o,l]=_.useState(""),[c,u]=_.useState(!0),[d,f]=_.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:$z(T)})),a(Bz(T,n)),l(Hz(T,r)),u(!0),f(!0)}},[t.scheduleType,t.scheduledTime,n,r,e,t]);const x=T=>{e({...t,scheduleType:T})},b=(T,M)=>{const C=zfe(T,n),E=Bfe(M);u(!!C),f(!!E),C&&E&&(C.setHours(E.hours,E.minutes,0,0),C>new Date&&e({...t,scheduledTime:$z(C)}))},v=T=>{a(T),b(T,o)},y=T=>{l(T),b(i,T)},S=T=>{const M=T.target.value;if(M){const C=new Date(M);isNaN(C.getTime())||(a(Bz(C,n)),l(Hz(C,r)),u(!0),f(!0),e({...t,scheduledTime:M}))}},k=()=>{p.current?.showPicker()};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"When to print"}),s.jsxs("div",{className:"flex gap-2",children:[s.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:[s.jsx(tr,{className:"w-4 h-4"}),"ASAP"]}),s.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:[s.jsx(ti,{className:"w-4 h-4"}),"Scheduled"]}),s.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:[s.jsx(_W,{className:"w-4 h-4"}),"Queue Only"]})]})]}),t.scheduleType==="scheduled"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date & Time"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"flex-1 relative",children:[s.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:Ife(n)}),s.jsx("button",{type:"button",onClick:k,className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",title:"Open calendar",children:s.jsx(ti,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"w-32",children:s.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=>y(T.target.value),placeholder:Ufe(r)})})]}),s.jsx("input",{ref:p,type:"datetime-local",className:"sr-only",value:t.scheduledTime,onChange:S,tabIndex:-1}),(!c||!d)&&s.jsx("p",{className:"mt-1 text-xs text-red-400",children:"Please enter a valid date and time"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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"}),s.jsx("label",{htmlFor:"requirePrevious",className:"text-sm text-bambu-gray",children:"Only start if previous print succeeded"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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"}),s.jsxs("label",{htmlFor:"autoOffAfter",className:"text-sm text-bambu-gray flex items-center gap-1",children:[s.jsx(Gu,{className:"w-3.5 h-3.5"}),"Power off printer when done"]})]}),s.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 Jp={bed_levelling:!0,flow_cali:!1,vibration_cali:!0,layer_inspect:!1,timelapse:!1},E8e={scheduleType:"asap",scheduledTime:"",requirePreviousSuccess:!1,autoOffAfter:!1};function Ph({mode:t,archiveId:e,libraryFileId:n,archiveName:r,queueItem:i,onClose:a,onSuccess:o}){const{t:l}=Rn(),c=sn(),{showToast:u}=Hn(),d=!!n&&!e,[f,p]=_.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[m,x]=_.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[b,v]=_.useState(()=>t==="edit-queue-item"&&i?{bed_levelling:i.bed_levelling??Jp.bed_levelling,flow_cali:i.flow_cali??Jp.flow_cali,vibration_cali:i.vibration_cali??Jp.vibration_cali,layer_inspect:i.layer_inspect??Jp.layer_inspect,timelapse:i.timelapse??Jp.timelapse}:Jp),[y,S]=_.useState(()=>{if(t==="edit-queue-item"&&i){let $e="asap";i.manual_start?$e="manual":i.scheduled_time&&!P7(i.scheduled_time)&&($e="scheduled");let He="";return i.scheduled_time&&!P7(i.scheduled_time)&&(He=new Date(i.scheduled_time).toISOString().slice(0,16)),{scheduleType:$e,scheduledTime:He,requirePreviousSuccess:i.require_previous_success,autoOffAfter:i.auto_off_after}}return E8e}),[k,T]=_.useState(()=>{if(t==="edit-queue-item"&&i?.ams_mapping&&Array.isArray(i.ams_mapping)){const $e={};return i.ams_mapping.forEach((He,xe)=>{He!==-1&&($e[xe+1]=He)}),$e}return{}}),[M,C]=_.useState({}),[E,R]=_.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,F]=_.useState(()=>t==="edit-queue-item"&&i?.target_location?i.target_location:null),[z]=_.useState(()=>t==="edit-queue-item"&&i?.printer_id?[i.printer_id]:[]),[P]=_.useState(()=>t==="edit-queue-item"&&i?i.plate_id:null),[$,X]=_.useState(!1),[V,Q]=_.useState({current:0,total:0}),[Z,se]=_.useState(new Set),H=f.length,K=f.length>0?f[0]:null,{data:re}=ot({queryKey:["settings"],queryFn:ce.getSettings}),{data:ne,isLoading:be}=ot({queryKey:["printers"],queryFn:ce.getPrinters}),{data:me}=ot({queryKey:["archive",e],queryFn:()=>ce.getArchive(e),enabled:!!e&&!d}),de=me?.sliced_for_model||null,{data:Ce,isError:ie}=ot({queryKey:["archive-plates",e],queryFn:()=>ce.getArchivePlates(e),enabled:!!e&&!d,retry:!1}),{data:ke}=ot({queryKey:["library-file-plates",n],queryFn:()=>ce.getLibraryFilePlates(n),enabled:d&&!!n}),Oe=d?ke:Ce,{data:pe,isError:We}=ot({queryKey:["archive-filaments",e,m],queryFn:()=>ce.getArchiveFilamentRequirements(e,m??void 0),enabled:!!e&&!d&&(m!==null||!Oe?.is_multi_plate),retry:!1}),{data:G}=ot({queryKey:["library-file-filaments",n,m],queryFn:()=>ce.getLibraryFileFilamentRequirements(n,m??void 0),enabled:d&&!!n&&(m!==null||!Oe?.is_multi_plate)}),Y=!d&&(ie||We),ue=d?G:pe,{data:q}=ot({queryKey:["printer-status",K],queryFn:()=>ce.getPrinterStatus(K),enabled:!!K}),{amsMapping:te}=_ee(ue,q,k),U=y8e(f,ne,ue,k,M,C);_.useEffect(()=>{Oe?.plates?.length===1&&!m&&x(Oe.plates[0].index)},[Oe,m]),_.useEffect(()=>{if(t==="edit-queue-item")return;const $e=ne?.filter(He=>He.is_active)||[];$e.length===1&&f.length===0&&p([$e[0].id])},[t,ne,f.length]),_.useEffect(()=>{t==="edit-queue-item"?(JSON.stringify(f.sort())!==JSON.stringify(z.sort())||m!==P)&&(T({}),C({}),se(new Set)):(T({}),C({}),se(new Set))},[t,f,m,z,P]),_.useEffect(()=>{if(!re?.per_printer_mapping_expanded||f.length<=1)return;const $e=f.filter(He=>{if(Z.has(He))return!1;const xe=U.printerResults.find(Pe=>Pe.printerId===He);return xe&&xe.status&&!xe.isLoading});$e.length>0&&(se(He=>{const xe=new Set(He);return $e.forEach(Pe=>xe.add(Pe)),xe}),$e.forEach(He=>{U.autoConfigurePrinter(He)}))},[re?.per_printer_mapping_expanded,f,Z,U]),_.useEffect(()=>{const $e=He=>{He.key==="Escape"&&!$&&a()};return window.addEventListener("keydown",$e),()=>window.removeEventListener("keydown",$e)},[a,$]);const he=Oe?.is_multi_plate??!1,Me=Oe?.plates??[],ge=mt({mutationFn:$e=>ce.addToQueue($e)}),B=mt({mutationFn:$e=>ce.updateQueueItem(i.id,$e),onSuccess:()=>{c.invalidateQueries({queryKey:["queue"]}),u("Queue item updated"),o?.(),a()},onError:$e=>{u($e.message||"Failed to update queue item","error")}}),O=async $e=>{if($e?.preventDefault(),E==="printer"&&f.length===0){u("Please select at least one printer","error");return}if(E==="model"&&!A){u("Please select a target printer model","error");return}X(!0);const He=E==="model"?1:f.length;Q({current:0,total:He});const xe={success:0,failed:0,errors:[]},Pe=we=>{if(f.length>1){const Xe=M[we];if(Xe&&!Xe.useDefault)return U.getFinalMapping(we)}return te},ze=we=>({printer_id:E==="printer"?we: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:y.requirePreviousSuccess,auto_off_after:y.autoOffAfter,manual_start:y.scheduleType==="manual",ams_mapping:we?Pe(we):void 0,plate_id:m,scheduled_time:y.scheduleType==="scheduled"&&y.scheduledTime?new Date(y.scheduledTime).toISOString():void 0,...b});if(E==="model"){Q({current:1,total:1});try{if(t==="reprint"){u("Model-based assignment only works with queue mode","error"),X(!1);return}else if(t==="edit-queue-item"){const we={printer_id:null,target_model:A,target_location:I,require_previous_success:y.requirePreviousSuccess,auto_off_after:y.autoOffAfter,manual_start:y.scheduleType==="manual",ams_mapping:void 0,plate_id:m,scheduled_time:y.scheduleType==="scheduled"&&y.scheduledTime?new Date(y.scheduledTime).toISOString():null,...b};await B.mutateAsync(we)}else await ge.mutateAsync(ze(null));xe.success++}catch(we){xe.failed++,xe.errors.push(we.message)}}else for(let we=0;we<f.length;we++){const Xe=f[we];Q({current:we+1,total:f.length});try{if(t==="reprint"){const Ne=Pe(Xe);d?await ce.printLibraryFile(n,Xe,{ams_mapping:Ne,...b}):await ce.reprintArchive(e,Xe,{plate_id:m??void 0,ams_mapping:Ne,...b})}else if(t==="edit-queue-item"&&we===0){const Ne=Pe(Xe),rt={printer_id:Xe,target_model:null,target_location:null,require_previous_success:y.requirePreviousSuccess,auto_off_after:y.autoOffAfter,manual_start:y.scheduleType==="manual",ams_mapping:Ne,plate_id:m,scheduled_time:y.scheduleType==="scheduled"&&y.scheduledTime?new Date(y.scheduledTime).toISOString():null,...b};await B.mutateAsync(rt)}else await ge.mutateAsync(ze(Xe));xe.success++}catch(Ne){xe.failed++;const rt=ne?.find(Ee=>Ee.id===Xe)?.name||`Printer ${Xe}`;xe.errors.push(`${rt}: ${Ne.message}`)}}if(X(!1),xe.failed===0){if(E==="model")u(t==="edit-queue-item"?"Queue item updated":`Queued for any ${A}`);else{const we=t==="reprint"?"sent to":t==="edit-queue-item"?"updated/queued for":"queued for";xe.success===1?u(t==="edit-queue-item"?"Queue item updated":`Print ${we} printer`):u(`Print ${we} ${xe.success} printers`)}c.invalidateQueries({queryKey:["queue"]}),o?.(),a()}else xe.success===0?u(`Failed: ${xe.errors[0]}`,"error"):(u(`${xe.success} succeeded, ${xe.failed} failed`,"error"),c.invalidateQueries({queryKey:["queue"]}))},ee=$||B.isPending,le=_.useMemo(()=>!(ee||E==="printer"&&f.length===0||E==="model"&&!A||E==="model"&&t==="reprint"||!d&&he&&!m),[f.length,E,A,t,he,m,ee,d]),ve=(()=>{const $e=f.length;return t==="reprint"?{title:l(d?"queue.print":"queue.reprint"),icon:Ur,submitText:$e>1?l("queue.printToPrinters",{count:$e}):l("queue.print"),submitIcon:Ur,loadingText:V.total>1?l("queue.sendingProgress",{current:V.current,total:V.total}):l("queue.sending")}:t==="add-to-queue"?{title:l("queue.schedulePrint"),icon:ti,submitText:$e>1?l("queue.queueToPrinters",{count:$e}):l("queue.addToQueue"),submitIcon:ti,loadingText:V.total>1?l("queue.addingProgress",{current:V.current,total:V.total}):l("queue.adding")}:{title:l("queue.editQueueItem"),icon:Zi,submitText:l("common.save"),submitIcon:Zi,loadingText:V.total>1?l("queue.savingProgress",{current:V.current,total:V.total}):l("common.saving")}})(),ae=ve.icon,Fe=ve.submitIcon,Be=K&&(d||(he?m!==null:!0));return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:$?void 0:a,children:s.jsx(St,{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto",onClick:$e=>$e.stopPropagation(),children:s.jsxs(Nt,{className:t==="reprint"?"":"p-0",children:[s.jsxs("div",{className:`flex items-center justify-between ${t==="reprint"?"mb-4":"p-4 border-b border-bambu-dark-tertiary"}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ae,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:ve.title})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:a,disabled:$,children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:O,className:t==="reprint"?"":"p-4 space-y-4",children:[s.jsx("p",{className:`text-sm text-bambu-gray ${t==="reprint"?"mb-4":""}`,children:t==="reprint"?s.jsxs(s.Fragment,{children:["Send ",s.jsx("span",{className:"text-white",children:r})," to printer(s)"]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"block text-bambu-gray mb-1",children:"Print Job"}),s.jsx("span",{className:"text-white font-medium truncate block",children:r})]})}),s.jsx(_8e,{plates:Me,isMultiPlate:he,selectedPlate:m,onSelect:x}),s.jsx(w8e,{printers:ne||[],selectedPrinterIds:f,onMultiSelect:p,isLoading:be,allowMultiple:!0,showInactive:t==="edit-queue-item",printerMappingResults:U.printerResults,filamentReqs:ue,onAutoConfigurePrinter:U.autoConfigurePrinter,onUpdatePrinterConfig:U.updatePrinterConfig,assignmentMode:t==="reprint"?"printer":E,onAssignmentModeChange:t!=="reprint"?R:void 0,targetModel:A,onTargetModelChange:t!=="reprint"?D:void 0,targetLocation:I,onTargetLocationChange:t!=="reprint"?F:void 0,slicedForModel:de}),de&&E==="printer"&&f.length===1&&(()=>{const $e=ne?.find(He=>He.id===f[0]);return $e&&$e.model&&de!==$e.model?s.jsxs("div",{className:"p-3 mb-2 bg-yellow-500/10 border border-yellow-500/30 rounded-lg flex items-center gap-2",children:[s.jsx(Sn,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),s.jsxs("span",{className:"text-sm text-yellow-400",children:["File was sliced for ",de,", but printing on ",$e.model]})]}):null})(),Y&&s.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:[s.jsx($i,{className:"w-4 h-4 text-orange-400 mt-0.5 flex-shrink-0"}),s.jsx("p",{className:"text-orange-400",children:"Archive data unavailable. The source file may have been deleted. Filament mapping is disabled."})]}),Be&&!Y&&f.length===1&&s.jsx(S8e,{printerId:K,filamentReqs:ue,manualMappings:k,onManualMappingChange:T,defaultExpanded:re?.per_printer_mapping_expanded??!1}),(t==="reprint"||H>0||E==="model"&&A)&&s.jsx(M8e,{options:b,onChange:v}),t!=="reprint"&&s.jsx(k8e,{options:y,onChange:S,dateFormat:re?.date_format||"system",timeFormat:re?.time_format||"system"}),B.isError&&s.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:B.error?.message||"Failed to complete operation"}),s.jsxs("div",{className:`flex gap-3 ${t==="reprint"?"":"pt-2"}`,children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:a,className:"flex-1",disabled:$,children:"Cancel"}),s.jsx(Te,{type:"submit",disabled:!le,className:"flex-1",children:ee?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),ve.loadingText]}):s.jsxs(s.Fragment,{children:[s.jsx(Fe,{className:"w-4 h-4"}),ve.submitText]})})]})]})]})})})}function T8e({onClose:t,initialFiles:e}){const{t:n}=Rn(),r=sn(),{showToast:i}=Hn(),a=_.useRef(null),[o,l]=_.useState(()=>e?.filter(M=>M.name.endsWith(".3mf")).map(M=>({file:M,status:"pending"}))||[]),[c,u]=_.useState(!1),[d,f]=_.useState(null);_.useEffect(()=>{const M=C=>{C.key==="Escape"&&t()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[t]);const p=mt({mutationFn:M=>ce.uploadArchivesBulk(M),onSuccess:M=>{f(M),r.invalidateQueries({queryKey:["archives"]}),r.invalidateQueries({queryKey:["archiveStats"]}),l(C=>C.map(E=>{const R=M.results.find(D=>D.filename===E.file.name),A=M.errors.find(D=>D.filename===E.file.name);return R?{...E,status:"success",archiveId:R.id}:A?{...E,status:"error",error:A.error}:E})),M.failed===0?i(`${M.uploaded} file${M.uploaded!==1?"s":""} uploaded`):M.uploaded===0?i(`Failed to upload ${M.failed} file${M.failed!==1?"s":""}`,"error"):i(`${M.uploaded} uploaded, ${M.failed} failed`,"warning")},onError:()=>{l(M=>M.map(C=>({...C,status:"error",error:"Upload failed"}))),i("Upload failed","error")}}),m=_.useCallback(M=>{M.preventDefault(),u(!0)},[]),x=_.useCallback(M=>{M.preventDefault(),u(!1)},[]),b=_.useCallback(M=>{M.preventDefault(),u(!1);const C=Array.from(M.dataTransfer.files).filter(E=>E.name.endsWith(".3mf"));C.length>0&&l(E=>[...E,...C.map(R=>({file:R,status:"pending"}))])},[]),v=_.useCallback(M=>{const C=Array.from(M.target.files||[]).filter(E=>E.name.endsWith(".3mf"));C.length>0&&l(E=>[...E,...C.map(R=>({file:R,status:"pending"}))]),a.current&&(a.current.value="")},[]),y=_.useCallback(M=>{l(C=>C.filter((E,R)=>R!==M))},[]),S=()=>{if(o.length===0)return;const M=o.filter(C=>C.status==="pending");M.length!==0&&(l(C=>C.map(E=>E.status==="pending"?{...E,status:"uploading"}:E)),p.mutate(M.map(C=>C.file)))},k=o.filter(M=>M.status==="pending").length,T=p.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(St,{className:"w-full max-w-2xl max-h-[90vh] flex flex-col",children:s.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:n("uploadModal.title")}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"p-4",children:s.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:b,children:[s.jsx(za,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray"}),s.jsx("p",{className:"text-white mb-2",children:n("uploadModal.dragDrop")}),s.jsx("p",{className:"text-bambu-gray text-sm mb-4",children:n("uploadModal.or")}),s.jsx(Te,{variant:"secondary",onClick:()=>a.current?.click(),disabled:T,children:n("uploadModal.browseFiles")}),s.jsx("input",{ref:a,type:"file",accept:".3mf",multiple:!0,className:"hidden",onChange:v})]})}),s.jsx("div",{className:"px-4 pb-4",children:s.jsx("p",{className:"text-xs text-bambu-gray",children:n("uploadModal.extractionInfo")})}),o.length>0&&s.jsx("div",{className:"px-4 pb-4 max-h-60 overflow-y-auto",children:s.jsx("div",{className:"space-y-2",children:o.map((M,C)=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(uM,{className:"w-5 h-5 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"flex-1 text-white text-sm truncate",children:M.file.name}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[(M.file.size/(1024*1024)).toFixed(1)," MB"]}),M.status==="pending"&&s.jsx("button",{onClick:()=>y(C),className:"text-bambu-gray hover:text-red-400 transition-colors",disabled:T,children:s.jsx(Rt,{className:"w-4 h-4"})}),M.status==="uploading"&&s.jsx(ft,{className:"w-4 h-4 text-bambu-green animate-spin"}),M.status==="success"&&s.jsx(Ar,{className:"w-4 h-4 text-bambu-green"}),M.status==="error"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-red-400",children:M.error}),s.jsx($i,{className:"w-4 h-4 text-red-400"})]})]},`${M.file.name}-${C}`))})}),d&&s.jsx("div",{className:"px-4 pb-4",children:s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:[s.jsx("span",{className:"text-bambu-green",children:d.uploaded})," ",n("uploadModal.uploaded"),d.failed>0&&s.jsxs(s.Fragment,{children:[", ",s.jsx("span",{className:"text-red-400",children:d.failed})," ",n("uploadModal.failed")]})]})})}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:t,className:"flex-1",children:n(d?"common.close":"common.cancel")}),!d&&s.jsx(Te,{onClick:S,disabled:k===0||T,className:"flex-1",children:T?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),n("uploadModal.uploading")]}):s.jsxs(s.Fragment,{children:[s.jsx(za,{className:"w-4 h-4"}),n("uploadModal.upload")," ",k>0&&`(${k})`]})})]})]})})})}const A8e=["adhesionFailure","spaghettiDetached","layerShift","cloggedNozzle","filamentRunout","warping","stringing","underExtrusion","powerFailure","userCancelled","other"],C8e=["completed","failed","aborted","printing"];function See({archive:t,onClose:e,existingTags:n=[]}){const{t:r}=Rn();_.useEffect(()=>{const ie=ke=>{ke.key==="Escape"&&e()};return window.addEventListener("keydown",ie),()=>window.removeEventListener("keydown",ie)},[e]);const i=sn(),[a,o]=_.useState(t.print_name||""),[l,c]=_.useState(t.printer_id),[u,d]=_.useState(t.project_id??null),[f,p]=_.useState(t.notes||""),[m,x]=_.useState(t.tags||""),[b,v]=_.useState(t.failure_reason||""),[y,S]=_.useState(t.status),[k,T]=_.useState(t.quantity??1),[M,C]=_.useState(t.photos||[]),[E,R]=_.useState(t.external_url||""),[A,D]=_.useState(!1),[I,F]=_.useState(!1),z=_.useRef(null),P=_.useRef(null),$=_.useRef(null),{data:X}=ot({queryKey:["printers"],queryFn:ce.getPrinters}),{data:V}=ot({queryKey:["projects"],queryFn:()=>ce.getProjects()}),{data:Q}=ot({queryKey:["tags"],queryFn:ce.getTags,enabled:n.length===0}),Z=n.length>0?n:Q?.map(ie=>ie.name)||[],se=m.split(",").map(ie=>ie.trim()).filter(Boolean),H=m.includes(",")?m.substring(m.lastIndexOf(",")+1).trim().toLowerCase():m.trim().toLowerCase(),K=Z.filter(ie=>!se.includes(ie)&&(H===""||ie.toLowerCase().includes(H))),re=ie=>{let ke;if(H&&!Z.includes(H)?ke=m.includes(",")?m.substring(0,m.lastIndexOf(",")).split(",").map(Oe=>Oe.trim()).filter(Boolean):[]:ke=se,!ke.includes(ie)){const Oe=[...ke,ie].join(", ");x(Oe)}$.current!==null&&clearTimeout($.current),z.current?.focus()},ne=ie=>{const ke=se.filter(Oe=>Oe!==ie).join(", ");x(ke)},be=mt({mutationFn:ie=>ce.updateArchive(t.id,ie),onSuccess:()=>{i.invalidateQueries({queryKey:["archives"]}),i.invalidateQueries({queryKey:["projects"]}),e()}}),me=async ie=>{const ke=ie.target.files?.[0];if(ke){D(!0);try{const Oe=await ce.uploadArchivePhoto(t.id,ke);C(Oe.photos),i.invalidateQueries({queryKey:["archives"]})}catch(Oe){console.error("Failed to upload photo:",Oe)}finally{D(!1),P.current&&(P.current.value="")}}},de=async ie=>{try{const ke=await ce.deleteArchivePhoto(t.id,ie);C(ke.photos||[]),i.invalidateQueries({queryKey:["archives"]})}catch(ke){console.error("Failed to delete photo:",ke)}},Ce=ie=>{ie.preventDefault();const ke={print_name:a||void 0,printer_id:l,project_id:u,notes:f||void 0,tags:m||void 0,quantity:k,external_url:E||null};y!==t.status&&(ke.status=y),y==="failed"||y==="aborted"?ke.failure_reason=b||void 0:(t.status==="failed"||t.status==="aborted")&&(ke.failure_reason=null),be.mutate(ke)};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.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:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r("editArchive.title")}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:Ce,className:"p-6 space-y-4 overflow-y-auto flex-1",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.name")}),s.jsx("input",{type:"text",value:a,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")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.printer")}),s.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:[s.jsx("option",{value:"",children:r("editArchive.noPrinter")}),X?.map(ie=>s.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Ja,{className:"w-4 h-4 inline mr-1"}),r("editArchive.project")]}),s.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:[s.jsx("option",{value:"",children:r("editArchive.noProject")}),V?.map(ie=>s.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(ade,{className:"w-4 h-4 inline mr-1"}),r("editArchive.itemsPrinted")]}),s.jsx("input",{type:"number",min:1,value:k,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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r("editArchive.itemsPrintedHelp")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.notes")}),s.jsx("textarea",{value:f,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")})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Iy,{className:"w-4 h-4 inline mr-1"}),r("editArchive.externalLink")]}),s.jsx("input",{type:"url",value:E,onChange:ie=>R(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/..."}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:r("editArchive.externalLinkHelp")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.tags")}),se.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:se.map(ie=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bambu-dark-tertiary rounded text-sm text-white",children:[s.jsx(yh,{className:"w-3 h-3"}),ie,s.jsx("button",{type:"button",onClick:()=>ne(ie),className:"ml-0.5 text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-3 h-3"})})]},ie))}),s.jsxs("div",{className:"relative",children:[s.jsx("input",{ref:z,type:"text",value:m,onChange:ie=>x(ie.target.value),onFocus:()=>{$.current!==null&&clearTimeout($.current),F(!0)},onBlur:()=>{$.current=window.setTimeout(()=>F(!1),200)},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",placeholder:se.length>0?r("editArchive.addMoreTags"):r("editArchive.tagsPlaceholder")}),I&&K.length>0&&s.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:[s.jsxs("div",{className:"p-2 text-xs text-bambu-gray border-b border-bambu-dark-tertiary",children:[H?r("editArchive.matchingTags",{query:H}):r("editArchive.existingTags")," ",r("editArchive.clickToAdd")]}),s.jsx("div",{className:"p-2 flex flex-wrap gap-1.5",children:K.map(ie=>s.jsx("button",{type:"button",onClick:()=>re(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))})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.status")}),s.jsx("select",{value:y,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:C8e.map(ie=>s.jsx("option",{value:ie,children:r(`editArchive.statuses.${ie}`)},ie))})]}),(y==="failed"||y==="aborted")&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("editArchive.failureReason")}),s.jsxs("select",{value:b,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:[s.jsx("option",{value:"",children:r("editArchive.selectReason")}),A8e.map(ie=>s.jsx("option",{value:r(`editArchive.failureReasons.${ie}`),children:r(`editArchive.failureReasons.${ie}`)},ie))]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(Ug,{className:"w-4 h-4 inline mr-1"}),r("editArchive.photos")]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[M.map(ie=>s.jsxs("div",{className:"relative group",children:[s.jsx("img",{src:ce.getArchivePhotoUrl(t.id,ie),alt:r("editArchive.printResult"),className:"w-20 h-20 object-cover rounded-lg border border-bambu-dark-tertiary"}),s.jsx("button",{type:"button",onClick:()=>de(ie),className:"absolute -top-1 -right-1 p-1 bg-red-500 rounded-full opacity-0 group-hover:opacity-100 transition-opacity",children:s.jsx(an,{className:"w-3 h-3 text-white"})})]},ie)),s.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:[s.jsx("input",{ref:P,type:"file",accept:"image/jpeg,image/png,image/webp",onChange:me,className:"hidden",disabled:A}),A?s.jsx(ft,{className:"w-6 h-6 text-bambu-gray animate-spin"}):s.jsx(fr,{className:"w-6 h-6 text-bambu-gray"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:r("editArchive.photosHelp")})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:r("common.cancel")}),s.jsxs(Te,{type:"submit",disabled:be.isPending,className:"flex-1",children:[s.jsx(hs,{className:"w-4 h-4"}),be.isPending?r("common.saving"):r("common.save")]})]})]})]})})}function Nee({x:t,y:e,items:n,onClose:r}){const i=_.useRef(null),[a,o]=_.useState(null),l=_.useRef(null),[c,u]=_.useState({x:t,y:e,visible:!1}),[d,f]=_.useState(!1),[p,m]=_.useState({});_.useEffect(()=>{const v=k=>{i.current&&!i.current.contains(k.target)&&r()},y=k=>{k.key==="Escape"&&r()},S=()=>{r()};return document.addEventListener("mousedown",v),document.addEventListener("keydown",y),document.addEventListener("scroll",S,!0),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",y),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(),y=window.innerWidth,S=window.innerHeight,k=8;let T=t,M=e;t+v.width>y-k&&(T=Math.max(k,y-v.width-k)),T<k&&(T=k),e+v.height>S-k&&(M=Math.max(k,S-v.height-k)),M<k&&(M=k);const C=180,E=y-T-v.width,R=T;f(E<C&&R>C),u({x:T,y:M,visible:!0})}},[t,e]);const x=(v,y)=>{l.current&&(clearTimeout(l.current),l.current=null);const S=y.getBoundingClientRect(),k=window.innerHeight,T=300,E=k-S.top-8<T&&S.top>T;m(R=>({...R,[v]:E?"bottom":"top"})),o(v)},b=()=>{l.current=window.setTimeout(()=>{o(null)},150)};return s.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,y)=>{if(v.divider)return s.jsx("div",{className:"my-1 border-t border-bambu-dark-tertiary"},y);const S=v.submenu&&v.submenu.length>0;return s.jsxs("div",{className:"relative",onMouseEnter:k=>S&&x(y,k.currentTarget),onMouseLeave:()=>S&&b(),children:[s.jsxs("button",{onMouseEnter:k=>S&&x(y,k.currentTarget.parentElement),onClick:()=>{S?o(a===y?null:y):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&&a===y?"bg-bambu-dark-tertiary":""}`,children:[v.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:v.icon}),s.jsx("span",{className:"flex-1",children:v.label}),S&&s.jsx(gs,{className:"w-4 h-4 text-bambu-gray"})]}),S&&a===y&&s.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[y]==="bottom"?"bottom-0":"top-0"}`,onMouseEnter:()=>{l.current&&(clearTimeout(l.current),l.current=null)},onMouseLeave:()=>b(),children:v.submenu.map((k,T)=>s.jsxs("button",{onClick:()=>{k.disabled||(k.onClick(),r())},disabled:k.disabled,className:`w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors ${k.disabled?"text-bambu-gray cursor-not-allowed":k.danger?"text-red-400 hover:bg-red-400/10":"text-white hover:bg-bambu-dark-tertiary"}`,children:[k.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:k.icon}),k.label]},T))})]},y)})})}function P8e({selectedIds:t,existingTags:e,onClose:n}){const r=sn(),{showToast:i}=Hn(),[a,o]=_.useState(""),[l,c]=_.useState(new Set),[u,d]=_.useState("add");_.useEffect(()=>{const b=v=>{v.key==="Escape"&&n()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[n]);const f=mt({mutationFn:async()=>{const b=Array.from(l);let v=0;for(const y of t)try{const S=await ce.getArchive(y),k=S.tags?S.tags.split(",").map(M=>M.trim()).filter(Boolean):[];let T;u==="add"?T=[...new Set([...k,...b])]:T=k.filter(M=>!l.has(M)),await ce.updateArchive(y,{tags:T.join(", ")}),v++}catch(S){throw console.error(`Failed to update archive ${y}:`,S),new Error(`Failed on archive ${y}: ${S instanceof Error?S.message:"Unknown error"}`)}return{count:v,mode:u,tags:b}},onSuccess:({count:b,mode:v,tags:y})=>{r.invalidateQueries({queryKey:["archives"]}),i(`${v==="add"?"Added":"Removed"} ${y.length} tag${y.length!==1?"s":""} ${v==="add"?"to":"from"} ${b} archive${b!==1?"s":""}`),n()},onError:b=>{i(b.message||"Failed to update tags","error")}}),p=b=>{c(v=>{const y=new Set(v);return y.has(b)?y.delete(b):y.add(b),y})},m=()=>{a.trim()&&!l.has(a.trim())&&(c(b=>new Set([...b,a.trim()])),o(""))},x=b=>{b.key==="Enter"&&(b.preventDefault(),m())};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(St,{className:"w-full max-w-md",children:s.jsxs(Nt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yh,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:u==="add"?"Add Tags":"Remove Tags"})]}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:[u==="add"?"Add":"Remove"," tags for ",t.length," selected archive",t.length!==1?"s":""]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{size:"sm",variant:u==="add"?"primary":"secondary",onClick:()=>d("add"),children:"Add Tags"}),s.jsx(Te,{size:"sm",variant:u==="remove"?"primary":"secondary",onClick:()=>d("remove"),children:"Remove Tags"})]}),u==="add"&&s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",placeholder:"Enter new tag...",className:"flex-1 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:a,onChange:b=>o(b.target.value),onKeyDown:x}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:m,disabled:!a.trim(),children:s.jsx(fr,{className:"w-4 h-4"})})]}),e.length>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:"Existing tags:"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:e.map(b=>s.jsx("button",{onClick:()=>p(b),className:`px-2 py-1 rounded text-sm transition-colors ${l.has(b)?"bg-bambu-green text-white":"bg-bambu-dark-tertiary text-bambu-gray-light hover:bg-bambu-dark"}`,children:b},b))})]}),l.size>0&&s.jsxs("div",{children:[s.jsxs("p",{className:"text-xs text-bambu-gray mb-2",children:["Tags to ",u==="add"?"add":"remove",":"]}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Array.from(l).map(b=>s.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:[b,s.jsx("button",{onClick:()=>p(b),className:"hover:opacity-70",children:s.jsx(Rt,{className:"w-3 h-3"})})]},b))})]})]}),s.jsxs("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:n,className:"flex-1",children:"Cancel"}),s.jsx(Te,{onClick:()=>f.mutate(),disabled:l.size===0||f.isPending,className:"flex-1",children:f.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(yh,{className:"w-4 h-4"}),u==="add"?"Add Tags":"Remove Tags"]})})]})]})})})}function j8e({selectedIds:t,onClose:e}){const n=sn(),{showToast:r}=Hn(),{data:i,isLoading:a}=ot({queryKey:["projects"],queryFn:()=>ce.getProjects()});_.useEffect(()=>{const d=f=>{f.key==="Escape"&&e()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[e]);const o=()=>{n.invalidateQueries({queryKey:["archives"]}),n.invalidateQueries({queryKey:["projects"]}),n.invalidateQueries({queryKey:["project"]}),n.invalidateQueries({queryKey:["project-archives"]})},l=mt({mutationFn:async d=>(await ce.addArchivesToProject(d,t),d),onSuccess:d=>{const f=i?.find(p=>p.id===d);o(),r(`Added ${t.length} archive${t.length!==1?"s":""} to "${f?.name}"`),e()},onError:()=>{r("Failed to assign project","error")}}),c=mt({mutationFn:async()=>{for(const d of t)await ce.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 s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(St,{className:"w-full max-w-md max-h-[80vh] flex flex-col",children:s.jsxs(Nt,{className:"p-0 flex flex-col min-h-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ja,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Assign to Project"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",disabled:u,children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 space-y-3 overflow-y-auto min-h-0",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Assign ",t.length," selected archive",t.length!==1?"s":""," to a project"]}),a?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):s.jsxs("div",{className:"space-y-2",children:[s.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:[s.jsx("div",{className:"w-8 h-8 rounded-full bg-red-500/20 flex items-center justify-center shrink-0",children:s.jsx(Qi,{className:"w-4 h-4 text-red-400"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium",children:"Remove from project"}),s.jsx("p",{className:"text-sm text-bambu-gray truncate",children:"Clear project assignment"})]}),c.isPending&&s.jsx(ft,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]}),i&&i.length>0&&s.jsxs("div",{className:"flex items-center gap-2 py-2",children:[s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"}),s.jsx("span",{className:"text-xs text-bambu-gray",children:"or assign to"}),s.jsx("div",{className:"flex-1 h-px bg-bambu-dark-tertiary"})]}),i?.map(d=>s.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:[s.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:s.jsx(Ja,{className:"w-4 h-4",style:{color:d.color||"rgb(var(--bambu-green))"}})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium truncate",children:d.name}),s.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&&s.jsx(ft,{className:"w-4 h-4 animate-spin text-bambu-gray shrink-0"})]},d.id)),(!i||i.length===0)&&s.jsx("p",{className:"text-center text-bambu-gray py-4",children:"No projects yet. Create one from the Projects page."})]})]}),s.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary shrink-0",children:s.jsx(Te,{variant:"secondary",onClick:e,className:"flex-1",disabled:u,children:"Cancel"})})]})})})}function D8e(t,e){return new Date(t,e+1,0).getDate()}function R8e(t,e){return new Date(t,e,1).getDay()}const O8e=["January","February","March","April","May","June","July","August","September","October","November","December"],L8e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function F8e({archives:t,onArchiveClick:e,highlightedArchiveId:n}){const r=new Date,[i,a]=_.useState(r.getMonth()),[o,l]=_.useState(r.getFullYear()),[c,u]=_.useState(null),[d,f]=_.useState(null),p=_.useMemo(()=>{const M=new Map;return t.forEach(C=>{const E=Ui(C.completed_at||C.created_at)||new Date,R=`${E.getFullYear()}-${String(E.getMonth()+1).padStart(2,"0")}-${String(E.getDate()).padStart(2,"0")}`,A=M.get(R)||[];A.push(C),M.set(R,A)}),M},[t]),m=D8e(o,i),x=R8e(o,i),b=()=>{i===0?(a(11),l(o-1)):a(i-1)},v=()=>{i===11?(a(0),l(o+1)):a(i+1)},y=()=>{a(r.getMonth()),l(r.getFullYear())},S=[];for(let M=0;M<x;M++)S.push(null);for(let M=1;M<=m;M++)S.push(M);const k=c?p.get(c)||[]:[],T=M=>{M!==c&&f(null),u(M)};return s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("button",{onClick:b,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(gh,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:[O8e[i]," ",o]}),s.jsx("button",{onClick:y,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"})]}),s.jsx("button",{onClick:v,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(gs,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsx("div",{className:"grid grid-cols-7 gap-1 mb-1",children:L8e.map(M=>s.jsx("div",{className:"text-center text-xs text-bambu-gray py-2",children:M},M))}),s.jsx("div",{className:"grid grid-cols-7 gap-1",children:S.map((M,C)=>{if(M===null)return s.jsx("div",{className:"aspect-square"},`empty-${C}`);const E=`${o}-${String(i+1).padStart(2,"0")}-${String(M).padStart(2,"0")}`,R=p.get(E)||[],A=R.length>0,D=M===r.getDate()&&i===r.getMonth()&&o===r.getFullYear(),I=E===c,F=R.filter(P=>P.status==="completed").length,z=R.filter(P=>P.status==="failed").length;return s.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:[s.jsx("span",{className:`text-sm font-medium ${D&&!I?"text-bambu-green":""}`,children:M}),A&&s.jsxs("div",{className:"absolute bottom-1 left-1/2 -translate-x-1/2 flex items-center gap-1",children:[s.jsx("div",{className:`w-2 h-2 rounded-full ${z>0&&F===0?"bg-red-400":z>0?"bg-yellow-400":"bg-green-400"}`}),s.jsx("span",{className:"text-xs font-medium",children:R.length})]})]},M)})}),s.jsx("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-white",children:t.filter(M=>{const C=new Date(M.completed_at||M.created_at);return C.getMonth()===i&&C.getFullYear()===o}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Prints this month"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-green-400",children:t.filter(M=>{const C=new Date(M.completed_at||M.created_at);return C.getMonth()===i&&C.getFullYear()===o&&M.status==="completed"}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Successful"})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-2xl font-bold text-red-400",children:t.filter(M=>{const C=new Date(M.completed_at||M.created_at);return C.getMonth()===i&&C.getFullYear()===o&&M.status==="failed"}).length}),s.jsx("div",{className:"text-xs text-bambu-gray",children:"Failed"})]})]})})]}),s.jsx("div",{className:"lg:w-80 bg-bambu-dark rounded-xl p-4",children:c?s.jsxs(s.Fragment,{children:[s.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"})}),k.length>0?s.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:k.map(M=>{const C=M.id===d||M.id===n;return s.jsxs("button",{onClick:()=>{f(M.id),e?.(M)},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:[M.thumbnail_path?s.jsx("img",{src:ce.getArchiveThumbnail(M.id),alt:"",className:"w-12 h-12 rounded object-cover"}):s.jsx("div",{className:"w-12 h-12 rounded bg-bambu-dark-tertiary flex items-center justify-center",children:s.jsx("span",{className:"text-xs text-bambu-gray",children:"3MF"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:M.print_name||M.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:M.status==="failed"?"text-red-400":"text-green-400",children:M.status==="failed"?"Failed":"Completed"}),M.filament_color&&s.jsx("div",{className:"flex gap-0.5",children:M.filament_color.split(",").map((E,R)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:E}},R))})]})]})]},M.id)})}):s.jsx("p",{className:"text-sm text-bambu-gray",children:"No prints on this day"})]}):s.jsx("div",{className:"text-center py-8",children:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Select a day to see prints"})})})]})}function Mee({archiveId:t,archiveName:e,onClose:n}){const r=ce.getArchiveQRCodeUrl(t,300);_.useEffect(()=>{const a=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]);const i=()=>{const a=document.createElement("a");a.href=r,a.download=`${e}_qrcode.png`,a.click()};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:n,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-sm",onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:"QR Code"}),s.jsx("button",{onClick:n,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-6 flex flex-col items-center",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4 text-center truncate max-w-full",children:e}),s.jsx("div",{className:"bg-white p-4 rounded-lg mb-4",children:s.jsx("img",{src:r,alt:"QR Code",className:"w-64 h-64"})}),s.jsx("p",{className:"text-xs text-bambu-gray mb-4 text-center",children:"Scan to open this archive"}),s.jsxs(Te,{onClick:i,className:"w-full",children:[s.jsx(wi,{className:"w-4 h-4"}),"Download QR Code"]})]})]})})}function kee({archiveId:t,archiveName:e,photos:n,onClose:r,onDelete:i}){const[a,o]=_.useState(0),[l,c]=_.useState(!1);if(_.useEffect(()=>{const m=x=>{x.key==="Escape"&&r(),x.key==="ArrowLeft"&&o(b=>Math.max(0,b-1)),x.key==="ArrowRight"&&o(b=>Math.min(n.length-1,b+1))};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r,n.length]),_.useEffect(()=>{a>=n.length&&o(Math.max(0,n.length-1))},[n.length,a]),n.length===0)return r(),null;const u=n[a],d=ce.getArchivePhotoUrl(t,u),f=()=>{const m=document.createElement("a");m.href=d,m.download=`${e}_photo_${a+1}.jpg`,m.click()},p=()=>{i&&c(!0)};return s.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-50",onClick:r,children:[s.jsxs("div",{className:"relative w-full h-full flex flex-col",onClick:m=>m.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 bg-black/50",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:e}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Photo ",a+1," of ",n.length]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:f,children:[s.jsx(wi,{className:"w-4 h-4"}),"Download"]}),i&&s.jsx(Te,{variant:"secondary",size:"sm",onClick:p,className:"text-red-400 hover:text-red-300",children:s.jsx(an,{className:"w-4 h-4"})}),s.jsx("button",{onClick:r,className:"p-2 text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-6 h-6"})})]})]}),s.jsxs("div",{className:"flex-1 min-h-0 flex items-center justify-center p-4 relative overflow-hidden",children:[a>0&&s.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:s.jsx(gh,{className:"w-8 h-8 text-white"})}),s.jsx("img",{src:d,alt:`Photo ${a+1}`,className:"max-w-full max-h-full object-contain rounded-lg",style:{maxHeight:"calc(100vh - 200px)"}}),a<n.length-1&&s.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:s.jsx(gs,{className:"w-8 h-8 text-white"})})]}),n.length>1&&s.jsx("div",{className:"flex justify-center gap-2 p-4 bg-black/50",children:n.map((m,x)=>s.jsx("button",{onClick:()=>o(x),className:`w-16 h-16 rounded-lg overflow-hidden border-2 transition-colors ${x===a?"border-bambu-green":"border-transparent hover:border-bambu-gray"}`,children:s.jsx("img",{src:ce.getArchivePhotoUrl(t,m),alt:`Thumbnail ${x+1}`,className:"w-full h-full object-cover"})},m))})]}),l&&s.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 Ra(t){this.content=t}Ra.prototype={constructor:Ra,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),a=r.content.slice();return i==-1?a.push(n||t,e):(a[i+1]=e,n&&(a[i]=n)),new Ra(a)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Ra(n)},addToStart:function(t,e){return new Ra([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Ra(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),a=r.find(t);return i.splice(a==-1?i.length:a,0,e,n),new Ra(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=Ra.from(t),t.size?new Ra(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Ra.from(t),t.size?new Ra(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Ra.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}};Ra.from=function(t){if(t instanceof Ra)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Ra(e)};function Eee(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),a=e.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let o=0;i.text[o]==a.text[o];o++)n++;return n}if(i.content.size||a.content.size){let o=Eee(i.content,a.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Tee(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=t.child(--i),l=e.child(--a),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=Tee(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,a){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,a||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 a="",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:a+=r),a+=u},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<e.content.length;a++)i.push(e.content[a]);return new 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 a=0,o=0;o<n;a++){let l=this.content[a],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(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new kt(i,a)}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 Eee(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Tee(this,e,n,r)}findIndex(e){if(e==0)return J_(0,e);if(e==this.size)return J_(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),a=r+i.nodeSize;if(a>=e)return a==e?J_(n+1,a):J_(n,r);r=a}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return 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 a=e[i];r+=a.nodeSize,i&&a.isText&&e[i-1].sameMarkup(a)?(n||(n=e.slice(0,i)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new 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 uP={index:0,offset:0};function J_(t,e){return uP.index=t,uP.offset=e,uP}function lN(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(!lN(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!lN(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Rr=class kD{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,i));else{if(a.type.excludes(this.type))return e;!r&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(a)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&lN(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 kD.none;if(e instanceof kD)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Rr.none=[];class cN extends Error{}class Ut{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=Cee(this.content,e+this.openStart,n);return r&&new Ut(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Ut(Aee(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 Ut.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 Ut(kt.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)r++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new Ut(e,r,i)}}Ut.empty=new Ut(kt.empty,0,0);function Aee(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||a.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,a.copy(Aee(a.content,e-i-1,n-i-1)))}function Cee(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),o=t.maybeChild(i);if(a==e||o.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=Cee(o.content,e-a-1,n,o);return l&&t.replaceChild(i,o.copy(l))}function I8e(t,e,n){if(n.openStart>t.depth)throw new cN("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new cN("Inconsistent open depths");return Pee(t,e,n,0)}function Pee(t,e,n,r){let i=t.index(r),a=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=Pee(t,e,n,r+1);return a.copy(a.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 Yf(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=U8e(n,t);return Yf(a,Dee(t,o,l,e,r))}else return Yf(a,uN(t,e,r))}function jee(t,e){if(!e.type.compatibleContent(t.type))throw new cN("Cannot join "+e.type.name+" onto "+t.type.name)}function ED(t,e,n){let r=t.node(n);return jee(r,e.node(n)),r}function Xf(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 k0(t,e,n,r){let i=(e||t).node(n),a=0,o=e?e.index(n):i.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(Xf(t.nodeAfter,r),a++));for(let l=a;l<o;l++)Xf(i.child(l),r);e&&e.depth==n&&e.textOffset&&Xf(e.nodeBefore,r)}function Yf(t,e){return t.type.checkContent(e),t.copy(e)}function Dee(t,e,n,r,i){let a=t.depth>i&&ED(t,e,i+1),o=r.depth>i&&ED(n,r,i+1),l=[];return k0(null,t,i,l),a&&o&&e.index(i)==n.index(i)?(jee(a,o),Xf(Yf(a,Dee(t,e,n,r,i+1)),l)):(a&&Xf(Yf(a,uN(t,e,i+1)),l),k0(e,n,i,l),o&&Xf(Yf(o,uN(n,r,i+1)),l)),k0(r,null,i,l),new kt(l)}function uN(t,e,n){let r=[];if(k0(null,t,n,r),t.depth>n){let i=ED(t,e,n+1);Xf(Yf(i,uN(t,e,n+1)),r)}return k0(e,null,n,r),new kt(r)}function U8e(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)i=e.node(a).copy(kt.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class wy{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)i+=r.child(a).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return 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 a=r.marks;for(var o=0;o<a.length;o++)a[o].type.spec.inclusive===!1&&(!i||!a[o].isInSet(i.marks))&&(a=a[o--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var a=0;a<r.length;a++)r[a].type.spec.inclusive===!1&&(!i||!r[a].isInSet(i.marks))&&(r=r[a--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new dN(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,a=n;for(let o=e;;){let{index:l,offset:c}=o.content.findIndex(a),u=a-c;if(r.push(o,l,i+c),!u||(o=o.child(l),o.isText))break;a=u-1,i+=c+1}return new wy(n,r,a)}static resolveCached(e,n){let r=R7.get(e);if(r)for(let a=0;a<r.elts.length;a++){let o=r.elts[a];if(o.pos==n)return o}else R7.set(e,r=new z8e);let i=r.elts[r.i]=wy.resolve(e,n);return r.i=(r.i+1)%B8e,i}}class z8e{constructor(){this.elts=[],this.i=0}}const B8e=12,R7=new WeakMap;class dN{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 H8e=Object.create(null);let hh=class TD{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&&lN(this.attrs,n||e.defaultAttrs||H8e)&&Rr.sameSet(this.marks,r||Rr.none)}copy(e=null){return e==this.content?this:new TD(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new TD(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 Ut.empty;let i=this.resolve(e),a=this.resolve(n),o=r?0:i.sharedDepth(n),l=i.start(o),u=i.node(o).content.cut(i.pos-l,a.pos-l);return new Ut(u,i.depth-o,a.depth-o)}replace(e,n,r){return I8e(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 wy.resolveCached(this,e)}resolveNoCache(e){return wy.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,a=>(r.isInSet(a.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Ree(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,a=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,a),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let c=i;c<a;c++)if(!this.type.allowsMarks(r.child(c).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let a=this.contentMatchAt(e).matchType(r),o=a&&a.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),a=e.nodeType(n.type).create(n.attrs,i,r);return a.type.checkAttrs(a.attrs),a}};hh.prototype.text=void 0;class hN extends hh{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):Ree(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 hN(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new hN(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 Ree(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class wm{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new $8e(e,n);if(r.next==null)return wm.empty;let i=Oee(r);r.next&&r.err("Unexpected trailing text");let a=Y8e(X8e(i));return Q8e(a,r),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let a=n;i&&a<r;a++)i=i.matchType(e.child(a).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function a(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:f}=o.next[u];if(!(d.isText||d.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let p=a(f,l.concat(d));if(p)return p}}return null}return a(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),a=i.match;if(a.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<a.next.length;o++){let{type:l,next:c}=a.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 a=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)a+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return a}).join(`
- `)}}wm.empty=new wm(!0);class $8e{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 Oee(t){let e=[];do e.push(V8e(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function V8e(t){let e=[];do e.push(G8e(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function G8e(t){let e=K8e(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=q8e(t,e);else break;return e}function O7(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function q8e(t,e){let n=O7(t),r=n;return t.eat(",")&&(t.next!="}"?r=O7(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function W8e(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let a in n){let o=n[a];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function K8e(t){if(t.eat("(")){let e=Oee(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=W8e(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 X8e(t){let e=[[]];return i(a(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 a(o,l){if(o.type=="choice")return o.exprs.reduce((c,u)=>c.concat(a(u,l)),[]);if(o.type=="seq")for(let c=0;;c++){let u=a(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(a(o.expr,c),c),[r(c)]}else if(o.type=="plus"){let c=n();return i(a(o.expr,l),c),i(a(o.expr,c),c),[r(c)]}else{if(o.type=="opt")return[r(l)].concat(a(o.expr,l));if(o.type=="range"){let c=l;for(let u=0;u<o.min;u++){let d=n();i(a(o.expr,c),d),c=d}if(o.max==-1)i(a(o.expr,c),c);else for(let u=o.min;u<o.max;u++){let d=n();r(c,d),i(a(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 Lee(t,e){return e-t}function L7(t,e){let n=[];return r(e),n.sort(Lee);function r(i){let a=t[i];if(a.length==1&&!a[0].term)return r(a[0].to);n.push(i);for(let o=0;o<a.length;o++){let{term:l,to:c}=a[o];!l&&n.indexOf(c)==-1&&r(c)}}}function Y8e(t){let e=Object.create(null);return n(L7(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]);L7(t,c).forEach(d=>{u||i.push([l,u=[]]),u.indexOf(d)==-1&&u.push(d)})})});let a=e[r.join(",")]=new wm(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Lee);a.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return a}}function Q8e(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],a=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:c,next:u}=i.next[l];o.push(c.name),a&&!(c.isText||c.hasRequiredAttrs())&&(a=!1),r.indexOf(u)==-1&&r.push(u)}a&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Fee(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 Iee(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let a=t[r];if(a.hasDefault)i=a.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function Uee(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let a=t[i];a.validate&&a.validate(e[i])}}function zee(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new J8e(t,r,e[r]);return n}let F7=class Bee{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=zee(e,r.attrs),this.defaultAttrs=Fee(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==wm.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:Iee(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new hh(this,this.computeAttrs(e),kt.from(n),Rr.setFrom(r))}createChecked(e=null,n,r){return n=kt.from(n),this.checkContent(n),new hh(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),a=i&&i.fillBefore(kt.empty,!0);return a?new hh(this,e,n.append(a),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){Uee(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((a,o)=>r[a]=new Bee(a,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 a in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Z8e(t,e,n){let r=n.split("|");return i=>{let a=i===null?"null":typeof i;if(r.indexOf(a)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${a}`)}}class J8e{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Z8e(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class S2{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=zee(e,i.attrs),this.excluded=null;let a=Fee(this.attrs);this.instance=a?new Rr(this,a):null}create(e=null){return!e&&this.instance?this.instance:new Rr(this,Iee(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((a,o)=>r[a]=new S2(a,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){Uee(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Hee{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=Ra.from(e.nodes),n.marks=Ra.from(e.marks||{}),this.nodes=F7.compile(this.spec.nodes,this),this.marks=S2.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let a=this.nodes[i],o=a.spec.content||"",l=a.spec.marks;if(a.contentMatch=r[o]||(r[o]=wm.parse(o,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=l=="_"?null:l?I7(this,l.split(" ")):l==""||!a.inlineContent?[]:null}for(let i in this.marks){let a=this.marks[i],o=a.spec.excludes;a.excluded=o==null?[a]:o==""?[]:I7(this,o.split(" "))}this.nodeFromJSON=i=>hh.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 F7){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 hN(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 I7(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t.marks[i],o=a;if(a)n.push(a);else for(let l in t.marks){let c=t.marks[l];(i=="_"||c.spec.group&&c.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=c)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function e6e(t){return t.tag!=null}function t6e(t){return t.style!=null}let E0=class AD{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(e6e(i))this.tags.push(i);else if(t6e(i)){let a=/[^=]*/.exec(i.style)[0];r.indexOf(a)<0&&r.push(a),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let a=e.nodes[i.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let r=new z7(this,n,!1);return r.addAll(e,Rr.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new z7(this,n,!0);return r.addAll(e,Rr.none,n.from,n.to),Ut.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let a=this.tags[i];if(i6e(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let o=a.getAttrs(e);if(o===!1)continue;a.attrs=o||void 0}return a}}}matchStyle(e,n,r,i){for(let a=i?this.styles.indexOf(i)+1:0;a<this.styles.length;a++){let o=this.styles[a],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 a=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<a)break}n.splice(o,0,i)}for(let i in e.marks){let a=e.marks[i].spec.parseDOM;a&&a.forEach(o=>{r(o=B7(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(o=>{r(o=B7(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new AD(e,AD.schemaRules(e)))}};const $ee={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},n6e={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Vee={ol:!0,ul:!0},_y=1,CD=2,T0=4;function U7(t,e,n){return e!=null?(e?_y:0)|(e==="full"?CD:0):t&&t.whitespace=="pre"?_y|CD:n&~T0}class e1{constructor(e,n,r,i,a,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=Rr.none,this.match=a||(o&T0?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&_y)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let a=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-i[0].length))}}let n=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&&!$ee.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class z7{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,a,o=U7(null,n.preserveWhitespace,0)|(r?T0:0);i?a=new e1(i.type,i.attrs,Rr.none,!0,n.topMatch||i.type.contentMatch,o):r?a=new e1(null,null,Rr.none,!0,null,o):a=new e1(e.schema.topNodeType,null,Rr.none,!0,null,o),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,a=i.options&CD?"full":this.localPreserveWS||(i.options&_y)>0,{schema:o}=this.parser;if(a==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(a)if(a==="full")r=r.replace(/\r\n?/g,`
- `);else if(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,a=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Vee.hasOwnProperty(o)&&this.parser.normalizeLists&&r6e(e);let c=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(c?c.ignore:n6e.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($ee.hasOwnProperty(o))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),u=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=c&&c.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(a),this.needsBlock=d}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,c,u,c.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let a=this.parser.matchedStyles[i],o=r.getPropertyValue(a);if(o)for(let l=void 0;;){let c=this.parser.matchStyle(a,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 a,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&&(a=!0,r=c)}else{let c=this.parser.schema.marks[n.mark];r=r.concat(c.create(n.attrs))}let l=this.top;if(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)}a&&this.sync(l)&&this.open--}addAll(e,n,r,i){let a=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(o,n);this.findAtPoint(e,a)}findPlace(e,n,r){let i,a;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,a=c,!u.length))break;if(c.solid){if(r)break;l+=2}}if(!i)return null;this.sync(a);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 a=this.textblockFromContext();a&&(n=this.enterInner(a,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let a=this.top;a.match&&(a.match=a.match.matchType(e.type));let o=Rr.none;for(let l of i.concat(e.marks))(a.type?a.type.allowsMarkType(l.type):H7(l.type,e.type))&&(o=l.addToSet(o));return a.content.push(e.mark(o)),!0}return!1}enter(e,n,r,i){let a=this.findPlace(e.create(n),r,!1);return a&&(a=this.enterInner(e,n,r,!0,i)),a}enterInner(e,n,r,i=!1,a){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=U7(e,a,o.options);o.options&T0&&o.content.length==0&&(l|=T0);let c=Rr.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):H7(u.type,e))?(c=u.addToSet(c),!1):!0),this.nodes.push(new e1(e,n,c,i,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=_y)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),a=-(r?r.depth+1:0)+(i?0:1),o=(l,c)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;c>=a;c--)if(o(l-1,c))return!0;return!1}else{let d=c>0||c==0&&i?this.nodes[c].type:r&&c>=a?r.node(c-a).type:null;if(!d||d.name!=u&&!d.isInGroup(u))return!1;c--}}return!0};return 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 r6e(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Vee.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function i6e(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function B7(t){let e={};for(let n in t)e[n]=t[n];return e}function H7(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let a=[],o=l=>{a.push(l);for(let c=0;c<l.edgeCount;c++){let{type:u,next:d}=l.edge(c);if(u==e||a.indexOf(d)<0&&o(d))return!0}};if(o(i.contentMatch))return!0}}class jm{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=dP(n).createDocumentFragment());let i=r,a=[];return e.forEach(o=>{if(a.length||o.marks.length){let l=0,c=0;for(;l<a.length&&c<o.marks.length;){let u=o.marks[c];if(!this.marks[u.type.name]){c++;continue}if(!u.eq(a[l][0])||u.type.spec.spanning===!1)break;l++,c++}for(;l<a.length;)i=a.pop()[1];for(;c<o.marks.length;){let u=o.marks[c++],d=this.serializeMark(u,o.isInline,n);d&&(a.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}=R1(dP(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let a=this.serializeMark(e.marks[i],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(r),r=a.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&R1(dP(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return R1(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new jm(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=$7(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return $7(e.marks)}}function $7(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function dP(t){return t.document||window.document}const V7=new WeakMap;function a6e(t){let e=V7.get(t);return e===void 0&&V7.set(t,e=s6e(t)),e}function s6e(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 R1(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],a;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(a=a6e(r))&&a.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let l,c=n?t.createElementNS(n,i):t.createElement(i),u=e[1],d=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){d=2;for(let f in u)if(u[f]!=null){let p=f.indexOf(" ");p>0?c.setAttributeNS(f.slice(0,p),f.slice(p+1),u[f]):f=="style"&&c.style?c.style.cssText=u[f]:c.setAttribute(f,u[f])}}for(let f=d;f<e.length;f++){let p=e[f];if(p===0){if(f<e.length-1||f>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}else{let{dom:m,contentDOM:x}=R1(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 Gee=65535,qee=Math.pow(2,16);function o6e(t,e){return t+e*qee}function G7(t){return t&Gee}function l6e(t){return(t-(t&Gee))/qee}const Wee=1,Kee=2,O1=4,Xee=8;class PD{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Xee)>0}get deletedBefore(){return(this.delInfo&(Wee|O1))>0}get deletedAfter(){return(this.delInfo&(Kee|O1))>0}get deletedAcross(){return(this.delInfo&O1)>0}}class co{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&co.empty)return co.empty}recover(e){let n=0,r=G7(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+l6e(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,a=this.inverted?2:1,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+a],d=this.ranges[l+o],f=c+u;if(e<=f){let p=u?e==c?-1:e==f?1:n:n,m=c+i+(p<0?0:d);if(r)return m;let x=e==(n<0?c:f)?null:o6e(l/3,e-c),b=e==c?Kee:e==f?Wee:O1;return(n<0?e!=c:e!=f)&&(b|=Xee),new PD(m,b,x)}i+=d-u}return r?e+i:new PD(e+i,0,null)}touches(e,n){let r=0,i=G7(n),a=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+a],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,a=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?a:0),c=o+(this.inverted?0:a),u=this.ranges[i+n],d=this.ranges[i+r];e(l,l+u,c,c+d),a+=d-u}}invert(){return new co(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?co.empty:new co(e<0?[0,-e,0]:[0,0,e])}}co.empty=new co([]);class Sy{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 Sy(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 Sy;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let a=this.from;a<this.to;a++){let o=this._maps[a],l=o.mapResult(e,n);if(l.recover!=null){let c=this.getMirror(a);if(c!=null&&c>a&&c<this.to){a=c,e=this._maps[c].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new PD(e,i,null)}}const hP=Object.create(null);class rs{getMap(){return co.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=hP[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 hP)throw new RangeError("Duplicate use of step JSON ID "+e);return hP[e]=n,n.prototype.jsonID=e,n}}class Hi{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Hi(e,null)}static fail(e){return new Hi(null,e)}static fromReplace(e,n,r,i){try{return Hi.ok(e.replace(n,r,i))}catch(a){if(a instanceof cN)return Hi.fail(a.message);throw a}}}function pL(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(pL(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return kt.fromArray(r)}class eh extends rs{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),a=new Ut(pL(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 Hi.fromReplace(e,this.from,this.to,a)}invert(){return new Rl(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 eh(n.pos,r.pos,this.mark)}merge(e){return e instanceof eh&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new eh(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 eh(n.from,n.to,e.markFromJSON(n.mark))}}rs.jsonID("addMark",eh);class Rl extends rs{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 Ut(pL(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Hi.fromReplace(e,this.from,this.to,r)}invert(){return new eh(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 Rl(n.pos,r.pos,this.mark)}merge(e){return e instanceof Rl&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Rl(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 Rl(n.from,n.to,e.markFromJSON(n.mark))}}rs.jsonID("removeMark",Rl);class th extends rs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Hi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Hi.fromReplace(e,this.pos,this.pos+1,new Ut(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 th(this.pos,n.marks[i]);return new th(this.pos,this.mark)}}return new _m(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new th(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 th(n.pos,e.markFromJSON(n.mark))}}rs.jsonID("addNodeMark",th);class _m extends rs{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Hi.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Hi.fromReplace(e,this.pos,this.pos+1,new Ut(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 th(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new _m(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 _m(n.pos,e.markFromJSON(n.mark))}}rs.jsonID("removeNodeMark",_m);class ba extends rs{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&jD(e,this.from,this.to)?Hi.fail("Structure replace would overwrite content"):Hi.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new co([this.from,this.to-this.from,this.slice.size])}invert(e){return new ba(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 ba(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ba)||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?Ut.empty:new Ut(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ba(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?Ut.empty:new Ut(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ba(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 ba(n.from,n.to,Ut.fromJSON(e,n.slice),!!n.structure)}}rs.jsonID("replace",ba);class _a extends rs{constructor(e,n,r,i,a,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,this.insert=o,this.structure=l}apply(e){if(this.structure&&(jD(e,this.from,this.gapFrom)||jD(e,this.gapTo,this.to)))return Hi.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Hi.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Hi.fromReplace(e,this.from,this.to,r):Hi.fail("Content does not fit in gap")}getMap(){return new co([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 _a(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new _a(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new _a(n.from,n.to,n.gapFrom,n.gapTo,Ut.fromJSON(e,n.slice),n.insert,!!n.structure)}}rs.jsonID("replaceAround",_a);function jD(t,e,n){let r=t.resolve(e),i=n-e,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let o=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function c6e(t,e,n,r){let i=[],a=[],o,l;t.doc.nodesBetween(e,n,(c,u,d)=>{if(!c.isInline)return;let f=c.marks;if(!r.isInSet(f)&&d.type.allowsMarkType(r.type)){let p=Math.max(u,e),m=Math.min(u+c.nodeSize,n),x=r.addToSet(f);for(let b=0;b<f.length;b++)f[b].isInSet(x)||(o&&o.to==p&&o.mark.eq(f[b])?o.to=m:i.push(o=new Rl(p,m,f[b])));l&&l.to==p?l.to=m:a.push(l=new eh(p,m,r))}}),i.forEach(c=>t.step(c)),a.forEach(c=>t.step(c))}function u6e(t,e,n,r){let i=[],a=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;a++;let c=null;if(r instanceof S2){let u=o.marks,d;for(;d=r.isInSet(u);)(c||(c=[])).push(d),u=d.removeFromSet(u)}else r?r.isInSet(o.marks)&&(c=[r]):c=o.marks;if(c&&c.length){let u=Math.min(l+o.nodeSize,n);for(let d=0;d<c.length;d++){let f=c[d],p;for(let m=0;m<i.length;m++){let x=i[m];x.step==a-1&&f.eq(i[m].style)&&(p=x)}p?(p.to=u,p.step=a):i.push({style:f,from:Math.max(l,e),to:u,step:a})}}}),i.forEach(o=>t.step(new Rl(o.from,o.to,o.style)))}function gL(t,e,n,r=n.contentMatch,i=!0){let a=t.doc.nodeAt(e),o=[],l=e+1;for(let c=0;c<a.childCount;c++){let u=a.child(c),d=l+u.nodeSize,f=r.matchType(u.type);if(!f)o.push(new ba(l,d,Ut.empty));else{r=f;for(let p=0;p<u.marks.length;p++)n.allowsMarkType(u.marks[p].type)||t.step(new Rl(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 Ut(kt.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new ba(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 Ut(c,0,0))}for(let c=o.length-1;c>=0;c--)t.step(o[c])}function d6e(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Ox(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,a=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+i,c=t.$to.indexAfter(r)-a;if(r<t.depth&&o.canReplace(l,c,n))return r;if(r==0||o.type.spec.isolating||!d6e(o,l,c))break;l&&(i=1),c<o.childCount&&(a=1)}return null}function h6e(t,e,n){let{$from:r,$to:i,depth:a}=e,o=r.before(a+1),l=i.after(a+1),c=o,u=l,d=kt.empty,f=0;for(let x=a,b=!1;x>n;x--)b||r.index(x)>0?(b=!0,d=kt.from(r.node(x).copy(d)),f++):c--;let p=kt.empty,m=0;for(let x=a,b=!1;x>n;x--)b||i.after(x+1)<i.end(x)?(b=!0,p=kt.from(i.node(x).copy(p)),m++):u++;t.step(new _a(c,u,o,l,new Ut(d.append(p),f,m),d.size-f,!0))}function xL(t,e,n=null,r=t){let i=f6e(t,e),a=i&&m6e(r,e);return a?i.map(q7).concat({type:e,attrs:n}).concat(a.map(q7)):null}function q7(t){return{type:t,attrs:null}}function f6e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.contentMatchAt(r).findWrapping(e);if(!a)return null;let o=a.length?a[0]:e;return n.canReplaceWith(r,i,o)?a:null}function m6e(t,e){let{parent:n,startIndex:r,endIndex:i}=t,a=n.child(r),o=e.contentMatch.findWrapping(a.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 p6e(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,a=e.end;t.step(new _a(i,a,i,a,new Ut(r,0,0),n.length,!0))}function g6e(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let c=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,c)&&x6e(t.doc,t.mapping.slice(a).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&&Qee(t,o,l,a),gL(t,t.mapping.slice(a).map(l,1),r,void 0,u===null);let d=t.mapping.slice(a),f=d.map(l,1),p=d.map(l+o.nodeSize,1);return t.step(new _a(f,p,f+1,p-1,new Ut(kt.from(r.create(c,null,o.marks)),0,0),1,!0)),u===!0&&Yee(t,o,l,a),!1}})}function Yee(t,e,n,r){e.forEach((i,a)=>{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+a+o.index);t.replaceWith(c,c+1,e.type.schema.linebreakReplacement.create())}}})}function Qee(t,e,n,r){e.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+a);t.replaceWith(o,o+1,e.type.schema.text(`
- `))}})}function x6e(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function b6e(t,e,n,r,i){let a=t.doc.nodeAt(e);if(!a)throw new RangeError("No node at given position");n||(n=a.type);let o=n.create(r,null,i||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,o);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new _a(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new Ut(kt.from(o),0,0),1,!0))}function ju(t,e,n=1,r){let i=t.resolve(e),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<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>a;u--,d--){let f=i.node(u),p=i.index(u);if(f.type.spec.isolating)return!1;let m=f.content.cutByIndex(p,f.childCount),x=r&&r[d+1];x&&(m=m.replaceChild(0,x.type.create(x.attrs)));let b=r&&r[d]||f;if(!f.canReplace(p+1,f.childCount)||!b.type.validContent(m))return!1}let l=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(l,l,c?c.type:i.node(a+1).type)}function y6e(t,e,n=1,r){let i=t.doc.resolve(e),a=kt.empty,o=kt.empty;for(let l=i.depth,c=i.depth-n,u=n-1;l>c;l--,u--){a=kt.from(i.node(l).copy(a));let d=r&&r[u];o=kt.from(d?d.type.create(d.attrs,o):i.node(l).copy(o))}t.step(new ba(e,e,new Ut(a.append(o),n,n),!0))}function zh(t,e){let n=t.resolve(e),r=n.index();return Zee(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function v6e(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let a=e.child(i),o=a.type==r?t.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(a.marks))return!1}return n.validEnd}function Zee(t,e){return!!(t&&e&&!t.isLeaf&&v6e(t,e))}function N2(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let a,o,l=r.index(i);if(i==r.depth?(a=r.nodeBefore,o=r.nodeAfter):n>0?(a=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(a=r.node(i).maybeChild(l-1),o=r.node(i+1)),a&&!a.isTextblock&&Zee(a,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function w6e(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,a=t.doc.resolve(e-n),o=a.node().type;if(i&&o.inlineContent){let d=o.whitespace=="pre",f=!!o.contentMatch.matchType(i);d&&!f?r=!1:!d&&f&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);Qee(t,d.node(),d.before(),l)}o.inlineContent&&gL(t,e+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=t.mapping.slice(l),u=c.map(e-n);if(t.step(new ba(u,c.map(e+n,-1),Ut.empty,!0)),r===!0){let d=t.doc.resolve(u);Yee(t,d.node(),d.before(),t.steps.length)}return t}function _6e(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let a=r.index(i);if(r.node(i).canReplaceWith(a,a,n))return r.before(i+1);if(a>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let a=r.indexAfter(i);if(r.node(i).canReplaceWith(a,a,n))return r.after(i+1);if(a<r.node(i).childCount)return null}return null}function Jee(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let a=0;a<n.openStart;a++)i=i.firstChild.content;for(let a=1;a<=(n.openStart==0&&n.size?2:1);a++)for(let 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(a==1)d=u.canReplace(c,c,i);else{let f=u.contentMatchAt(c).findWrapping(i.firstChild.type);d=f&&u.canReplaceWith(c,c,f[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function M2(t,e,n=e,r=Ut.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),a=t.resolve(n);return ete(i,a,r)?new ba(e,n,r):new S6e(i,a,r).fit()}function ete(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class S6e{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 a=e.node(i);this.frontier.push({type:a.type,match:a.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=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 a=this.placed,o=r.depth,l=i.depth;for(;o&&l&&a.childCount==1;)a=a.firstChild.content,o--,l--;let c=new Ut(a,o,l);return e>-1?new _a(r.pos,e,this.$to.pos,this.$to.end(),c,n):c.size||r.pos!=this.$to.pos?new ba(r.pos,i.pos,c):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let a=n.firstChild;if(n.childCount>1&&(i=0),a.type.spec.isolating&&i<=r){e=r;break}n=a.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,a=null;r?(a=fP(this.unplaced.content,r-1).firstChild,i=a.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:c,match:u}=this.frontier[l],d,f=null;if(n==1&&(o?u.matchType(o.type)||(f=u.fillBefore(kt.from(o),!1)):a&&c.compatibleContent(a.type)))return{sliceDepth:r,frontierDepth:l,parent:a,inject:f};if(n==2&&o&&(d=u.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:a,wrap:d};if(a&&u.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=fP(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Ut(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=fP(e,n);if(i.childCount<=1&&n>0){let a=e.size-n<=n+i.size;this.unplaced=new Ut(d0(e,n-1,1),n-1,a?n-1:r)}else this.unplaced=new Ut(d0(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let b=0;b<a.length;b++)this.openFrontierNode(a[b]);let o=this.unplaced,l=r?r.content:o.content,c=o.openStart-e,u=0,d=[],{match:f,type:p}=this.frontier[n];if(i){for(let b=0;b<i.childCount;b++)d.push(i.child(b));f=f.matchFragment(i)}let m=l.size+e-(o.content.size-o.openEnd);for(;u<l.childCount;){let b=l.child(u),v=f.matchType(b.type);if(!v)break;u++,(u>1||c==0||b.content.size)&&(f=v,d.push(tte(b.mark(p.allowedMarks(b.marks)),u==1?c:0,u==l.childCount?m:-1)))}let x=u==l.childCount;x||(m=-1),this.placed=h0(this.placed,n,kt.from(d)),this.frontier[n].match=f,x&&m<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,v=l;b<m;b++){let y=v.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),v=y.content}this.unplaced=x?e==0?Ut.empty:new Ut(d0(o.content,e-1,1),e-1,m<0?o.openEnd:e-1):new Ut(d0(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||!mP(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],a=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=mP(e,n,i,r,a);if(o){for(let l=n-1;l>=0;l--){let{match:c,type:u}=this.frontier[l],d=mP(e,l,u,c,!0);if(!d||d.childCount)continue e}return{depth:n,fit:o,move:a?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=h0(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),a=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,a)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=h0(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=h0(this.placed,this.frontier.length,n))}}function d0(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(d0(t.firstChild.content,e-1,n)))}function h0(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(h0(t.lastChild.content,e-1,n)))}function fP(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function tte(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,tte(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 mP(t,e,n,r,i){let a=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let l=r.fillBefore(a.content,!0,o);return l&&!N6e(n,a.content,o)?l:null}function N6e(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function M6e(t){return t.spec.defining||t.spec.definingForContent}function k6e(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),a=t.doc.resolve(n);if(ete(i,a,r))return t.step(new ba(e,n,r));let o=rte(i,a);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=M6e(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 b=0;b<o.length;b++){let v=o[(b+c)%o.length],y=!0;v<0&&(y=!1,v=-v);let S=i.node(v-1),k=i.index(v-1);if(S.canReplaceWith(k,k,x.type,x.marks))return t.replace(i.before(v),y?a.after(v):n,new Ut(nte(r.content,0,r.openStart,m),m,r.openEnd))}}let f=t.steps.length;for(let p=o.length-1;p>=0&&(t.replace(e,n,r),!(t.steps.length>f));p--){let m=o[p];m<0||(e=i.before(m),n=a.after(m))}}function nte(t,e,n,r,i){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(nte(a.content,e+1,n,r,a)))}if(e>r){let a=i.contentMatchAt(0),o=a.fillBefore(t).append(t);t=o.append(a.matchFragment(o).fillBefore(kt.empty,!0))}return t}function E6e(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=_6e(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Ut(kt.from(r),0,0))}function T6e(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),a=rte(r,i);for(let o=0;o<a.length;o++){let l=a[o],c=o==a.length-1;if(c&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(c||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let 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 rte(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let a=t.start(i);if(a<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(a==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==a-1)&&n.push(i)}return n}class Rg extends rs{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 Hi.fail("No node at attribute step's position");let r=Object.create(null);for(let a in n.attrs)r[a]=n.attrs[a];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return Hi.fromReplace(e,this.pos,this.pos+1,new Ut(kt.from(i),0,n.isLeaf?0:1))}getMap(){return co.empty}invert(e){return new Rg(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 Rg(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 Rg(n.pos,n.attr,n.value)}}rs.jsonID("attr",Rg);class Ny extends rs{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 Hi.ok(r)}getMap(){return co.empty}invert(e){return new Ny(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 Ny(n.attr,n.value)}}rs.jsonID("docAttr",Ny);let ox=class extends Error{};ox=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};ox.prototype=Object.create(Error.prototype);ox.prototype.constructor=ox;ox.prototype.name="TransformError";class ite{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Sy}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new ox(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=Ut.empty){let i=M2(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Ut(kt.from(r),0,0))}delete(e,n){return this.replace(e,n,Ut.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return k6e(this,e,n,r),this}replaceRangeWith(e,n,r){return E6e(this,e,n,r),this}deleteRange(e,n){return T6e(this,e,n),this}lift(e,n){return h6e(this,e,n),this}join(e,n=1){return w6e(this,e,n),this}wrap(e,n){return p6e(this,e,n),this}setBlockType(e,n=e,r,i=null){return g6e(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return b6e(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Rg(e,n,r)),this}setDocAttribute(e,n){return this.step(new Ny(e,n)),this}addNodeMark(e,n){return this.step(new th(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 _m(e,n));else{let i=r.marks,a,o=[];for(;a=n.isInSet(i);)o.push(new _m(e,a)),i=a.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return y6e(this,e,n,r),this}addMark(e,n,r){return c6e(this,e,n,r),this}removeMark(e,n,r){return u6e(this,e,n,r),this}clearIncompatible(e,n,r){return gL(this,e,n,r),this}}const pP=Object.create(null);class Pn{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new A6e(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=Ut.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let a=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:c,$to:u}=o[l],d=e.mapping.slice(a);e.replaceRange(d.map(c.pos),d.map(u.pos),l?Ut.empty:n),l==0&&X7(e,a,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:o,$to:l}=i[a],c=e.mapping.slice(r),u=c.map(o.pos),d=c.map(l.pos);a?e.deleteRange(u,d):(e.replaceRangeWith(u,d,n),X7(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new pn(e):lg(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let a=e.depth-1;a>=0;a--){let o=n<0?lg(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):lg(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new go(e.node(0))}static atStart(e){return lg(e,e,0,0,1)||new go(e)}static atEnd(e){return lg(e,e,e.content.size,e.childCount,-1)||new go(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=pP[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 pP)throw new RangeError("Duplicate use of selection JSON ID "+e);return pP[e]=n,n.prototype.jsonID=e,n}getBookmark(){return pn.between(this.$anchor,this.$head).getBookmark()}}Pn.prototype.visible=!0;class A6e{constructor(e,n){this.$from=e,this.$to=n}}let W7=!1;function K7(t){!W7&&!t.parent.inlineContent&&(W7=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class pn extends Pn{constructor(e,n=e){K7(e),K7(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 Pn.near(r);let i=e.resolve(n.map(this.anchor));return new pn(i.parent.inlineContent?i:r,r)}replace(e,n=Ut.empty){if(super.replace(e,n),n==Ut.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof pn&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new k2(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 pn(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let a=Pn.findFrom(n,r,!0)||Pn.findFrom(n,-r,!0);if(a)n=a.$head;else return Pn.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(Pn.findFrom(e,-r,!0)||Pn.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new pn(e,n)}}Pn.jsonID("text",pn);class k2{constructor(e,n){this.anchor=e,this.head=n}map(e){return new k2(e.map(this.anchor),e.map(this.head))}resolve(e){return pn.between(e.resolve(this.anchor),e.resolve(this.head))}}class Qt extends Pn{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=e.resolve(i);return r?Pn.near(a):new Qt(a)}content(){return new Ut(kt.from(this.node),0,0)}eq(e){return e instanceof Qt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new bL(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Qt(e.resolve(n.anchor))}static create(e,n){return new Qt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Qt.prototype.visible=!1;Pn.jsonID("node",Qt);class bL{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new k2(r,r):new bL(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Qt.isSelectable(r)?new Qt(n):Pn.near(n)}}class go extends Pn{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Ut.empty){if(n==Ut.empty){e.delete(0,e.doc.content.size);let r=Pn.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new go(e)}map(e){return new go(e)}eq(e){return e instanceof go}getBookmark(){return C6e}}Pn.jsonID("all",go);const C6e={map(){return this},resolve(t){return new go(t)}};function lg(t,e,n,r,i,a=!1){if(e.inlineContent)return pn.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(!a&&Qt.isSelectable(l))return Qt.create(t,n-(i<0?l.nodeSize:0))}else{let c=lg(t,l,n+i,i<0?l.childCount:0,i,a);if(c)return c}n+=l.nodeSize*i}return null}function X7(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof ba||i instanceof _a))return;let a=t.mapping.maps[r],o;a.forEach((l,c,u,d)=>{o==null&&(o=d)}),t.setSelection(Pn.near(t.doc.resolve(o),n))}const Y7=1,t1=2,Q7=4;class P6e extends ite{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|Y7)&~t1,this.storedMarks=null,this}get selectionSet(){return(this.updated&Y7)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=t1,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&t1)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~t1,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||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 a=this.storedMarks;if(!a){let o=this.doc.resolve(n);a=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,a)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Pn.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|=Q7,this}get scrolledIntoView(){return(this.updated&Q7)>0}}function Z7(t,e){return!e||!t?t:t.bind(e)}class f0{constructor(e,n,r){this.name=e,this.init=Z7(n.init,r),this.apply=Z7(n.apply,r)}}const j6e=[new f0("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new f0("selection",{init(t,e){return t.selection||Pn.atStart(e.doc)},apply(t){return t.selection}}),new f0("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new f0("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class gP{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=j6e.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 f0(r.key,r.spec.state,r))})}}class vg{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let a=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let c=i?i[o].n:0,u=i?i[o].state:this,d=c<n.length&&l.spec.appendTransaction.call(l,c?n.slice(c):n,u,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let f=0;f<this.config.plugins.length;f++)i.push(f<o?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),a=!0}i&&(i[o]={state:r,n:n.length})}}if(!a)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new vg(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let a=r[i];n[a.name]=a.apply(e,this[a.name],this,n)}return n}get tr(){return new P6e(this)}static create(e){let n=new gP(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new vg(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 gP(this.schema,e.plugins),r=n.fields,i=new vg(n);for(let a=0;a<r.length;a++){let o=r[a].name;i[o]=this.hasOwnProperty(o)?this[o]:r[a].init(e,i)}return i}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],a=i.spec.state;a&&a.toJSON&&(n[r]=a.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new gP(e.schema,e.plugins),a=new vg(i);return i.fields.forEach(o=>{if(o.name=="doc")a.doc=hh.fromJSON(e.schema,n.doc);else if(o.name=="selection")a.selection=Pn.fromJSON(a.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let c=r[l],u=c.spec.state;if(c.key==o.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){a[o.name]=u.fromJSON.call(c,e,n[l],a);return}}a[o.name]=o.init(e,a)}}),a}}function ate(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=ate(i,e,{})),n[r]=i}return n}class di{constructor(e){this.spec=e,this.props={},e.props&&ate(e.props,this,this.props),this.key=e.key?e.key.key:ste("plugin")}getState(e){return e[this.key]}}const xP=Object.create(null);function ste(t){return t in xP?t+"$"+ ++xP[t]:(xP[t]=0,t+"$")}class la{constructor(e="key"){this.key=ste(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const yL=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function ote(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const lte=(t,e,n)=>{let r=ote(t,n);if(!r)return!1;let i=vL(r);if(!i){let o=r.blockRange(),l=o&&Ox(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let a=i.nodeBefore;if(xte(t,i,e,-1))return!0;if(r.parent.content.size==0&&(lx(a,"end")||Qt.isSelectable(a)))for(let o=r.depth;;o--){let l=M2(t.doc,r.before(o),r.after(o),Ut.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(lx(a,"end")?Pn.findFrom(c.doc.resolve(c.mapping.map(i.pos,-1)),-1):Qt.create(c.doc,i.pos-a.nodeSize)),e(c.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1},D6e=(t,e,n)=>{let r=ote(t,n);if(!r)return!1;let i=vL(r);return i?cte(t,i,e):!1},R6e=(t,e,n)=>{let r=dte(t,n);if(!r)return!1;let i=wL(r);return i?cte(t,i,e):!1};function cte(t,e,n){let r=e.nodeBefore,i=r,a=e.pos-1;for(;!i.isTextblock;a--){if(i.type.spec.isolating)return!1;let d=i.lastChild;if(!d)return!1;i=d}let 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=M2(t.doc,a,c,Ut.empty);if(!u||u.from!=a||u instanceof ba&&u.slice.size>=c-a)return!1;if(n){let d=t.tr.step(u);d.setSelection(pn.create(d.doc,a)),n(d.scrollIntoView())}return!0}function lx(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 ute=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;a=vL(r)}let o=a&&a.nodeBefore;return!o||!Qt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Qt.create(t.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function vL(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 dte(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const hte=(t,e,n)=>{let r=dte(t,n);if(!r)return!1;let i=wL(r);if(!i)return!1;let a=i.nodeAfter;if(xte(t,i,e,1))return!0;if(r.parent.content.size==0&&(lx(a,"start")||Qt.isSelectable(a))){let o=M2(t.doc,r.before(),r.after(),Ut.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(lx(a,"start")?Pn.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):Qt.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},fte=(t,e,n)=>{let{$head:r,empty:i}=t.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;a=wL(r)}let o=a&&a.nodeAfter;return!o||!Qt.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Qt.create(t.doc,a.pos)).scrollIntoView()),!0)};function wL(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 O6e=(t,e)=>{let n=t.selection,r=n instanceof Qt,i;if(r){if(n.node.isTextblock||!zh(t.doc,n.from))return!1;i=n.from}else if(i=N2(t.doc,n.from,-1),i==null)return!1;if(e){let a=t.tr.join(i);r&&a.setSelection(Qt.create(a.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(a.scrollIntoView())}return!0},L6e=(t,e)=>{let n=t.selection,r;if(n instanceof Qt){if(n.node.isTextblock||!zh(t.doc,n.to))return!1;r=n.to}else if(r=N2(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},F6e=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),a=i&&Ox(i);return a==null?!1:(e&&e(t.tr.lift(i,a).scrollIntoView()),!0)},mte=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
- `).scrollIntoView()),!0)};function _L(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 I6e=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=_L(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(e){let l=n.after(),c=t.tr.replaceWith(l,l,o.createAndFill());c.setSelection(Pn.near(c.doc.resolve(l),1)),e(c.scrollIntoView())}return!0},pte=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof go||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=_L(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(o,a.createAndFill());l.setSelection(pn.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},gte=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let a=n.before();if(ju(t.doc,a))return e&&e(t.tr.split(a).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Ox(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function U6e(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof Qt&&e.selection.node.isBlock)return!r.parentOffset||!ju(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],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=_L(r.node(m-1).contentMatchAt(r.indexAfter(m-1))),a.unshift(c&&l?{type:l}:null),o=m;break}else{if(m==1)return!1;a.unshift(null)}let d=e.tr;(e.selection instanceof pn||e.selection instanceof go)&&d.deleteSelection();let f=d.mapping.map(r.pos),p=ju(d.doc,f,a.length,a);if(p||(a[0]=l?{type:l}:null,p=ju(d.doc,f,a.length,a)),!p)return!1;if(d.split(f,a.length,a),!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 z6e=U6e(),B6e=(t,e)=>{let{$from:n,to:r}=t.selection,i,a=n.sharedDepth(r);return a==0?!1:(i=n.before(a),e&&e(t.tr.setSelection(Qt.create(t.doc,i))),!0)};function H6e(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,a=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(a-1,a)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(a,a+1)||!(i.isTextblock||zh(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function xte(t,e,n,r){let i=e.nodeBefore,a=e.nodeAfter,o,l,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&H6e(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(a.type))&&l.matchType(o[0]||a.type).validEnd){if(n){let m=e.pos+a.nodeSize,x=kt.empty;for(let y=o.length-1;y>=0;y--)x=kt.from(o[y].create(null,x));x=kt.from(i.copy(x));let b=t.tr.step(new _a(e.pos-1,m,e.pos,m,new Ut(x,1,0),o.length,!0)),v=b.doc.resolve(m+2*o.length);v.nodeAfter&&v.nodeAfter.type==i.type&&zh(b.doc,v.pos)&&b.join(v.pos),n(b.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&c?null:Pn.findFrom(e,1),f=d&&d.$from.blockRange(d.$to),p=f&&Ox(f);if(p!=null&&p>=e.depth)return n&&n(t.tr.lift(f,p).scrollIntoView()),!0;if(u&&lx(a,"start",!0)&&lx(i,"end")){let m=i,x=[];for(;x.push(m),!m.isTextblock;)m=m.lastChild;let b=a,v=1;for(;!b.isTextblock;b=b.firstChild)v++;if(m.canReplace(m.childCount,m.childCount,b.content)){if(n){let y=kt.empty;for(let k=x.length-1;k>=0;k--)y=kt.from(x[k].copy(y));let S=t.tr.step(new _a(e.pos-x.length,e.pos+a.nodeSize,e.pos+v,e.pos+a.nodeSize-v,new Ut(y,x.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function bte(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(e.tr.setSelection(pn.create(e.doc,t<0?i.start(a):i.end(a)))),!0):!1}}const $6e=bte(-1),V6e=bte(1);function G6e(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a),l=o&&xL(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function J7(t,e=null){return function(n,r){let i=!1;for(let a=0;a<n.selection.ranges.length&&!i;a++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[a];n.doc.nodesBetween(o,l,(c,u)=>{if(i)return!1;if(!(!c.isTextblock||c.hasMarkup(t,e)))if(c.type==t)i=!0;else{let d=n.doc.resolve(u),f=d.index();i=d.parent.canReplaceWith(f,f+1,t)}})}if(!i)return!1;if(r){let a=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[o];a.setBlockType(l,c,t,e)}r(a.scrollIntoView())}return!0}}function SL(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}SL(yL,lte,ute);SL(yL,hte,fte);SL(mte,pte,gte,z6e);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function q6e(t,e=null){return function(n,r){let{$from:i,$to:a}=n.selection,o=i.blockRange(a);if(!o)return!1;let l=r?n.tr:null;return W6e(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function W6e(t,e,n,r=null){let i=!1,a=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);a=new dN(c,c,e.depth),e.endIndex<e.parent.childCount&&(e=new dN(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=xL(a,n,r,e);return l?(t&&K6e(t,e,l,i,n),!0):!1}function K6e(t,e,n,r,i){let a=kt.empty;for(let d=n.length-1;d>=0;d--)a=kt.from(n[d].type.create(n[d].attrs,a));t.step(new _a(e.start-(r?2:0),e.end,e.start,e.end,new Ut(a,0,0),n.length,!0));let o=0;for(let d=0;d<n.length;d++)n[d].type==i&&(o=d+1);let l=n.length-o,c=e.start+n.length-(r?2:0),u=e.parent;for(let d=e.startIndex,f=e.endIndex,p=!0;d<f;d++,p=!1)!p&&ju(t.doc,c,l)&&(t.split(c,l),c+=2*l),c+=u.child(d).nodeSize;return t}function X6e(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==t);return a?n?r.node(a.depth-1).type==t?Y6e(e,n,t,a):Q6e(e,n,a):!0:!1}}function Y6e(t,e,n,r){let i=t.tr,a=r.end,o=r.$to.end(r.depth);a<o&&(i.step(new _a(a-1,o,a,o,new Ut(kt.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new dN(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=Ox(r);if(l==null)return!1;i.lift(r,l);let c=i.doc.resolve(i.mapping.map(a,-1)-1);return zh(i.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&i.join(c.pos),e(i.scrollIntoView()),!0}function Q6e(t,e,n){let r=t.tr,i=n.parent;for(let m=n.end,x=n.endIndex-1,b=n.startIndex;x>b;x--)m-=i.child(x).nodeSize,r.delete(m-1,m+1);let a=r.doc.resolve(n.start),o=a.nodeAfter;if(r.mapping.map(n.end)!=n.start+a.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,c=n.endIndex==i.childCount,u=a.node(-1),d=a.index(-1);if(!u.canReplace(d+(l?0:1),d+1,o.content.append(c?kt.empty:kt.from(i))))return!1;let f=a.pos,p=f+o.nodeSize;return r.step(new _a(f-(l?1:0),p+(c?1:0),f+1,p-1,new Ut((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 Z6e(t){return function(e,n){let{$from:r,$to:i}=e.selection,a=r.blockRange(i,u=>u.childCount>0&&u.firstChild.type==t);if(!a)return!1;let o=a.startIndex;if(o==0)return!1;let l=a.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),f=new Ut(kt.from(t.create(null,kt.from(l.type.create(null,d)))),u?3:1,0),p=a.start,m=a.end;n(e.tr.step(new _a(p-(u?3:1),m,p,m,f,1,!0)).scrollIntoView())}return!0}}const Ia=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},cx=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let DD=null;const du=function(t,e,n){let r=DD||(DD=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},J6e=function(){DD=null},Sm=function(t,e,n,r){return n&&(e9(t,e,n,r,-1)||e9(t,e,n,r,1))},eHe=/^(img|br|input|textarea|hr)$/i;function e9(t,e,n,r,i){for(var a;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Qo(t))){let o=t.parentNode;if(!o||o.nodeType!=1||xv(t)||eHe.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ia(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(!((a=o.pmViewDesc)===null||a===void 0)&&a.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?Qo(t):0}else return!1}}function Qo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function tHe(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=Qo(t)}else if(t.parentNode&&!xv(t))e=Ia(t),t=t.parentNode;else return null}}function nHe(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&&!xv(t))e=Ia(t)+1,t=t.parentNode;else return null}}function rHe(t,e,n){for(let r=e==0,i=e==Qo(t);r||i;){if(t==n)return!0;let a=Ia(t);if(t=t.parentNode,!t)return!1;r=r&&a==0,i=i&&a==Qo(t)}}function xv(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 E2=function(t){return t.focusNode&&Sm(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Af(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function iHe(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function aHe(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Qo(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Qo(r.startContainer),r.startOffset)}}}const _c=typeof navigator<"u"?navigator:null,t9=typeof document<"u"?document:null,Bh=_c&&_c.userAgent||"",RD=/Edge\/(\d+)/.exec(Bh),yte=/MSIE \d/.exec(Bh),OD=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Bh),Bs=!!(yte||OD||RD),fh=yte?document.documentMode:OD?+OD[1]:RD?+RD[1]:0,il=!Bs&&/gecko\/(\d+)/i.test(Bh);il&&+(/Firefox\/(\d+)/.exec(Bh)||[0,0])[1];const LD=!Bs&&/Chrome\/(\d+)/.exec(Bh),Za=!!LD,vte=LD?+LD[1]:0,ys=!Bs&&!!_c&&/Apple Computer/.test(_c.vendor),ux=ys&&(/Mobile\/\w+/.test(Bh)||!!_c&&_c.maxTouchPoints>2),Go=ux||(_c?/Mac/.test(_c.platform):!1),sHe=_c?/Win/.test(_c.platform):!1,Nu=/Android \d/.test(Bh),bv=!!t9&&"webkitFontSmoothing"in t9.documentElement.style,oHe=bv?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function lHe(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 iu(t,e){return typeof t=="number"?t:t[e]}function cHe(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 n9(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=cx(o);continue}let l=o,c=l==a.body,u=c?lHe(a):cHe(l),d=0,f=0;if(e.top<u.top+iu(r,"top")?f=-(u.top-e.top+iu(i,"top")):e.bottom>u.bottom-iu(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+iu(i,"top")-u.top:e.bottom-u.bottom+iu(i,"bottom")),e.left<u.left+iu(r,"left")?d=-(u.left-e.left+iu(i,"left")):e.right>u.right-iu(r,"right")&&(d=e.right-u.right+iu(i,"right")),d||f)if(c)a.defaultView.scrollBy(d,f);else{let m=l.scrollLeft,x=l.scrollTop;f&&(l.scrollTop+=f),d&&(l.scrollLeft+=d);let b=l.scrollLeft-m,v=l.scrollTop-x;e={left:e.left-b,top:e.top-v,right:e.right-b,bottom:e.bottom-v}}let p=c?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(p))break;o=p=="absolute"?o.offsetParent:cx(o)}}function uHe(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let a=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(a,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:wte(t.dom)}}function wte(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=cx(r));return e}function dHe({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;_te(n,r==0?0:r-e)}function _te(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:a}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=a&&(r.scrollLeft=a)}}let eg=null;function hHe(t){if(t.setActive)return t.setActive();if(eg)return t.focus(eg);let e=wte(t);t.focus(eg==null?{get preventScroll(){return eg={preventScroll:!0},!0}}:void 0),eg||(eg=!1,_te(e,0))}function Ste(t,e){let n,r=2e8,i,a=0,o=e.top,l=e.top,c,u;for(let d=t.firstChild,f=0;d;d=d.nextSibling,f++){let p;if(d.nodeType==1)p=d.getClientRects();else if(d.nodeType==3)p=du(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 b=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(b<r){n=d,r=b,i=b&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,d.nodeType==1&&b&&(a=f+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!c&&x.left<=e.left&&x.right>=e.left&&(c=d,u={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(a=f+1)}}return!n&&c&&(n=c,i=u,r=0),n&&n.nodeType==3?fHe(n,i):!n||r&&n.nodeType==1?{node:t,offset:a}:Ste(n,i)}function fHe(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let a=Id(r,1);if(a.top!=a.bottom&&NL(e,a))return{node:t,offset:i+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function NL(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function mHe(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function pHe(t,e,n){let{node:r,offset:i}=Ste(e,n),a=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();a=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,a)}function gHe(t,e,n,r){let i=-1;for(let a=e,o=!1;a!=t.dom;){let l=t.docView.nearestDesc(a,!0),c;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((c=l.dom.getBoundingClientRect()).width||c.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!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;a=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function Nte(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let o=t.childNodes[a];if(o.nodeType==1){let l=o.getClientRects();for(let c=0;c<l.length;c++){let u=l[c];if(NL(e,u))return Nte(o,e,u)}}if((a=(a+1)%r)==i)break}return t}function xHe(t,e){let n=t.dom.ownerDocument,r,i=0,a=aHe(n,e.left,e.top);a&&({node:r,offset:i}=a);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(!NL(e,u)||(o=Nte(t.dom,e,u),!o))return null}if(ys)for(let u=o;r&&u;u=cx(u))u.draggable&&(r=void 0);if(o=mHe(o,e),r){if(il&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let d=r.childNodes[i],f;d.nodeName=="IMG"&&(f=d.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&i++}let u;bv&&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=gHe(t,r,i,e))}l==null&&(l=pHe(t,o,e));let c=t.docView.nearestDesc(o,!0);return{pos:l,inside:c?c.posAtStart-c.border:-1}}function r9(t){return t.top<t.bottom||t.left<t.right}function Id(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(r9(r))return r}return Array.prototype.find.call(n,r9)||t.getBoundingClientRect()}const bHe=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Mte(t,e,n){let{node:r,offset:i,atom:a}=t.docView.domFromPos(e,n<0?-1:1),o=bv||il;if(r.nodeType==3)if(o&&(bHe.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let c=Id(du(r,i,i),n);if(il&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let u=Id(du(r,i-1,i-1),-1);if(u.top==c.top){let d=Id(du(r,i,i+1),-1);if(d.top!=c.top)return Jb(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++,Jb(Id(du(r,c,u),d),d<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==Qo(r))){let c=r.childNodes[i-1];if(c.nodeType==1)return bP(c.getBoundingClientRect(),!1)}if(a==null&&i<Qo(r)){let c=r.childNodes[i];if(c.nodeType==1)return bP(c.getBoundingClientRect(),!0)}return bP(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==Qo(r))){let c=r.childNodes[i-1],u=c.nodeType==3?du(c,Qo(c)-(o?0:1)):c.nodeType==1&&(c.nodeName!="BR"||!c.nextSibling)?c:null;if(u)return Jb(Id(u,1),!1)}if(a==null&&i<Qo(r)){let c=r.childNodes[i];for(;c.pmViewDesc&&c.pmViewDesc.ignoreForCoords;)c=c.nextSibling;let u=c?c.nodeType==3?du(c,0,o?0:1):c.nodeType==1?c:null:null;if(u)return Jb(Id(u,-1),!0)}return Jb(Id(r.nodeType==3?du(r):r,-n),n>=0)}function Jb(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 bP(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 kte(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 yHe(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return kte(t,e,()=>{let{node:a}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(a,!0);if(!l)break;if(l.node.isBlock){a=l.contentDOM||l.dom;break}a=l.dom.parentNode}let o=Mte(t,i.pos,1);for(let l=a.firstChild;l;l=l.nextSibling){let c;if(l.nodeType==1)c=l.getClientRects();else if(l.nodeType==3)c=du(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 vHe=/[\u0590-\u08ac]/;function wHe(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,l=t.domSelection();return l?!vHe.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:o:kte(t,e,()=>{let{focusNode:c,focusOffset:u,anchorNode:d,anchorOffset:f}=t.domSelectionRange(),p=l.caretBidiLevel;l.modify("move",n,"character");let m=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:b}=t.domSelectionRange(),v=x&&!m.contains(x.nodeType==1?x:x.parentNode)||c==x&&u==b;try{l.collapse(d,f),c&&(c!=d||u!=f)&&l.extend&&l.extend(c,u)}catch{}return p!=null&&(l.caretBidiLevel=p),v}):r.pos==r.start()||r.pos==r.end()}let i9=null,a9=null,s9=!1;function _He(t,e,n){return i9==e&&a9==n?s9:(i9=e,a9=n,s9=n=="up"||n=="down"?yHe(t,e,n):wHe(t,e,n))}const al=0,o9=1,Lf=2,Sc=3;class yv{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=al,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let a,o;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(o)+o.size:this.posAtStart}else{let a,o;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((o=a.pmViewDesc)&&o.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>Ia(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!1;break}if(a.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){i=!0;break}if(a.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let a=this.getDesc(i),o;if(a&&(!n||a.node))if(r&&(o=a.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return a}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let a=this.getDesc(i);if(a)return a.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],a=r+i.size;if(r==e&&a!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<a)return i.descAt(e-r-i.border);r=a}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let a=0;r<this.children.length;r++){let o=this.children[r],l=a+o.size;if(l>e||o instanceof Tte){i=e-a;break}a=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let a;r&&!(a=this.children[r-1]).size&&a instanceof Ete&&a.side>=0;r--);if(n<=0){let a,o=!0;for(;a=r?this.children[r-1]:null,!(!a||a.dom.parentNode==this.contentDOM);r--,o=!1);return a&&n&&o&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?Ia(a.dom)+1:0}}else{let a,o=!0;for(;a=r<this.children.length?this.children[r]:null,!(!a||a.dom.parentNode==this.contentDOM);r++,o=!1);return a&&o&&!a.border&&!a.domAtom?a.domFromPos(0,n):{node:this.contentDOM,offset:a?Ia(a.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,a=-1;for(let o=r,l=0;;l++){let c=this.children[l],u=o+c.size;if(i==-1&&e<=u){let d=o+c.border;if(e>=d&&n<=u-c.border&&c.node&&c.contentDOM&&this.contentDOM.contains(c.contentDOM))return c.parseRange(e,n,d);e=o;for(let f=l;f>0;f--){let p=this.children[f-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){i=Ia(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 f=this.children[d];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){a=Ia(f.dom);break}n+=f.size}a==-1&&(a=this.contentDOM.childNodes.length);break}o=u}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:a}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,i=!1){let a=Math.min(e,n),o=Math.max(e,n);for(let m=0,x=0;m<this.children.length;m++){let b=this.children[m],v=x+b.size;if(a>x&&o<v)return b.setSelection(e-x-b.border,n-x-b.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(),f=!1;if((il||ys)&&e==n){let{node:m,offset:x}=l;if(m.nodeType==3){if(f=!!(x&&m.nodeValue[x-1]==`
- `),f&&x==m.nodeValue.length)for(let b=m,v;b;b=b.parentNode){if(v=b.nextSibling){v.nodeName=="BR"&&(l=c={node:v.parentNode,offset:Ia(v)+1});break}let y=b.pmViewDesc;if(y&&y.node&&y.node.isBlock)break}}else{let b=m.childNodes[x-1];f=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(il&&d.focusNode&&d.focusNode!=c.node&&d.focusNode.nodeType==1){let m=d.focusNode.childNodes[d.focusOffset];m&&m.contentEditable=="false"&&(i=!0)}if(!(i||f&&ys)&&Sm(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Sm(c.node,c.offset,d.focusNode,d.focusOffset))return;let p=!1;if((u.extend||e==n)&&!(f&&il)){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 a=this.children[i],o=r+a.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+a.border,c=o-a.border;if(e>=l&&n<=c){this.dirty=e==r||n==o?Lf:o9,e==l&&n==c&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=Sc:a.markDirty(e-l,n-l);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?Lf:Sc}r=o}this.dirty=Lf}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Lf:o9;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Ete extends yv{constructor(e,n,r,i){let a,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)})),!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,a=this}matchesWidget(e){return this.dirty==al&&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 SHe extends yv{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 Nm extends yv{constructor(e,n,r,i,a){super(e,[],r,i),this.mark=n,this.spec=a}static create(e,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=jm.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Nm(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Sc||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Sc&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=al){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=al}}slice(e,n,r){let i=Nm.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=ID(a,n,o,r)),e>0&&(a=ID(a,0,e,r));for(let l=0;l<a.length;l++)a[l].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class mh extends yv{constructor(e,n,r,i,a,o,l,c,u){super(e,[],a,o),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,a,o){let l=a.nodeViews[n.type.name],c,u=l&&l(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),d=u&&u.dom,f=u&&u.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:f}=jm.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!f&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let p=d;return d=Pte(d,r,n),u?c=new NHe(e,n,r,i,d,f||null,p,u,a,o+1):n.isText?new T2(e,n,r,i,d,p,a):new mh(e,n,r,i,d,f||null,p,a,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==al&&e.eq(this.node)&&fN(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,a=e.composing?this.localCompositionInfo(e,n):null,o=a&&a.pos>-1?a:null,l=a&&a.pos<0,c=new kHe(this,o&&o.node,e);AHe(this.node,this.innerDeco,(u,d,f)=>{u.spec.marks?c.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&c.syncToMarks(d==this.node.childCount?Rr.none:this.node.child(d).marks,r,e),c.placeWidget(u,e,i)},(u,d,f,p)=>{c.syncToMarks(u.marks,r,e);let m;c.findNodeMatch(u,d,f,p)||l&&e.state.selection.from>i&&e.state.selection.to<i+u.nodeSize&&(m=c.findIndexWithChild(a.node))>-1&&c.updateNodeAt(u,d,f,m,e)||c.updateNextNode(u,d,f,e,p,i)||c.addNode(u,d,f,e,i),i+=u.nodeSize}),c.syncToMarks([],r,e),this.node.isTextblock&&c.addTextblockHacks(),c.destroyRest(),(c.changed||this.dirty==Lf)&&(o&&this.protectLocalComposition(e,o),Ate(this.contentDOM,this.children,e),ux&&CHe(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof pn)||r<n||i>n+this.node.content.size)return null;let a=e.input.compositionNode;if(!a||!this.dom.contains(a.parentNode))return null;if(this.node.inlineContent){let o=a.nodeValue,l=PHe(this.node.content,o,r-n,i-n);return l<0?null:{node:a,pos:l,text:o}}else return{node:a,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let a=n;for(;a.parentNode!=this.contentDOM;a=a.parentNode){for(;a.previousSibling;)a.parentNode.removeChild(a.previousSibling);for(;a.nextSibling;)a.parentNode.removeChild(a.nextSibling);a.pmViewDesc&&(a.pmViewDesc=void 0)}let o=new SHe(this,a,n,i);e.input.compositionNodes.push(o),this.children=ID(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==Sc||!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=al}updateOuterDeco(e){if(fN(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Cte(this.dom,this.nodeDOM,FD(this.outerDeco,this.node,n),FD(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 l9(t,e,n,r,i){Pte(r,e,t);let a=new mh(void 0,t,e,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}class T2 extends mh{constructor(e,n,r,i,a,o,l){super(e,n,r,i,a,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==Sc||this.dirty!=al&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=al||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=al,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),a=document.createTextNode(i.text);return new T2(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Sc)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Tte extends yv{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==al&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class NHe extends mh{constructor(e,n,r,i,a,o,l,c,u,d){super(e,n,r,i,a,o,l,u,d),this.spec=c}update(e,n,r,i){if(this.dirty==Sc)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let a=this.spec.update(e,n,r);return a&&this.updateInner(e,n,r,i),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Ate(t,e,n){let r=t.firstChild,i=!1;for(let a=0;a<e.length;a++){let o=e[a],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=c9(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof Nm){let c=r?r.previousSibling:t.lastChild;Ate(o.contentDOM,o.children,n),r=c?c.nextSibling:t.firstChild}}for(;r;)r=c9(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const A0=function(t){t&&(this.nodeName=t)};A0.prototype=Object.create(null);const Ff=[new A0];function FD(t,e,n){if(t.length==0)return Ff;let r=n?Ff[0]:new A0,i=[r];for(let a=0;a<t.length;a++){let o=t[a].type.attrs;if(o){o.nodeName&&i.push(r=new A0(o.nodeName));for(let l in o){let c=o[l];c!=null&&(n&&i.length==1&&i.push(r=new A0(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 Cte(t,e,n,r){if(n==Ff&&r==Ff)return e;let i=e;for(let a=0;a<r.length;a++){let o=r[a],l=n[a];if(a){let c;l&&l.nodeName==o.nodeName&&i!=t&&(c=i.parentNode)&&c.nodeName.toLowerCase()==o.nodeName||(c=document.createElement(o.nodeName),c.pmIsDeco=!0,c.appendChild(i),l=Ff[0]),i=c}MHe(i,l||Ff[0],o)}return i}function MHe(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let a=0;a<r.length;a++)i.indexOf(r[a])==-1&&t.classList.remove(r[a]);for(let a=0;a<i.length;a++)r.indexOf(i[a])==-1&&t.classList.add(i[a]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function Pte(t,e,n){return Cte(t,t,Ff,FD(e,n,t.nodeType!=1))}function fN(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 c9(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class kHe{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=EHe(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=al,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let c=this.index;c<Math.min(this.index+3,this.top.children.length);c++){let u=this.top.children[c];if(u.matchesMark(e[a])&&!this.isLocked(u.dom)){l=c;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let c=Nm.create(this.top,e[a],n,r);this.top.children.splice(this.index,0,c),this.top=c,this.changed=!0}this.index=0,a++}}findNodeMatch(e,n,r,i){let a=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))a=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)){a=l;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,r,i,a){let o=this.top.children[i];return o.dirty==Sc&&o.dom==o.contentDOM&&(o.dirty=Lf),o.update(e,n,r,a)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,a,o){for(let l=this.index;l<this.top.children.length;l++){let c=this.top.children[l];if(c instanceof mh){let u=this.preMatch.matched.get(c);if(u!=null&&u!=a)return!1;let d=c.dom,f,p=this.isLocked(d)&&!(e.isText&&c.node&&c.node.isText&&c.nodeDOM.nodeValue==e.text&&c.dirty!=Sc&&fN(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&&(f=this.recreateWrapper(c,e,n,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=Lf,f.updateChildren(i,o+1),f.dirty=al),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,a,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!fN(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=mh.create(this.top,n,r,i,a,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,a){let o=mh.create(this.top,e,n,r,i,a);o.contentDOM&&o.updateChildren(i,a+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 a=new Ete(this.top,e,n,r);this.top.children.splice(this.index++,0,a),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Nm;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof T2)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ys||Za)&&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 Tte(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 EHe(t,e){let n=e,r=n.children.length,i=t.childCount,a=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof Nm)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let c=l.node;if(c){if(c!=t.child(i-1))break;--i,a.set(l,i),o.push(l)}}return{index:i,matched:a,matches:o.reverse()}}function THe(t,e){return t.type.side-e.type.side}function AHe(t,e,n,r){let i=e.locals(t),a=0;if(i.length==0){for(let u=0;u<t.childCount;u++){let d=t.child(u);r(d,i,e.forChild(a,d),u),a+=d.nodeSize}return}let o=0,l=[],c=null;for(let u=0;;){let d,f;for(;o<i.length&&i[o].to==a;){let v=i[o++];v.widget&&(d?(f||(f=[d])).push(v):d=v)}if(d)if(f){f.sort(THe);for(let v=0;v<f.length;v++)n(f[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<=a&&l.splice(v--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)l.push(i[o++]);let x=a+p.nodeSize;if(p.isText){let v=x;o<i.length&&i[o].from<v&&(v=i[o].from);for(let y=0;y<l.length;y++)l[y].to<v&&(v=l[y].to);v<x&&(c=p.cut(v-a),p=p.cut(0,v-a),x=v,m=-1)}else for(;o<i.length&&i[o].to<x;)o++;let b=p.isInline&&!p.isLeaf?l.filter(v=>!v.inline):l.slice();r(p,b,e.forChild(a,p),m),a=x}}function CHe(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 PHe(t,e,n,r){for(let i=0,a=0;i<t.childCount&&a<=r;){let o=t.child(i++),l=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<t.childCount;){let u=t.child(i++);if(a+=u.nodeSize,!u.isText)break;c+=u.text}if(a>=n){if(a>=r&&c.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l<r?c.lastIndexOf(e,r-l-1):-1;if(u>=0&&u+e.length+l>=n)return l+u;if(n==r&&c.length>=r+e.length-l&&c.slice(r-l,r-l+e.length)==e)return r}}return-1}function ID(t,e,n,r,i){let a=[];for(let o=0,l=0;o<t.length;o++){let c=t[o],u=l,d=l+=c.size;u>=n||d<=e?a.push(c):(u<e&&a.push(c.slice(0,e-u,r)),i&&(a.push(i),i=void 0),d>n&&a.push(c.slice(n-u,c.size,r)))}return a}function ML(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),c,u;if(E2(n)){for(c=o;i&&!i.node;)i=i.parent;let f=i.node;if(i&&f.isAtom&&Qt.isSelectable(f)&&i.parent&&!(f.isInline&&rHe(n.focusNode,n.focusOffset,i.dom))){let p=i.posBefore;u=new Qt(o==p?l:r.resolve(p))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let f=o,p=o;for(let m=0;m<n.rangeCount;m++){let x=n.getRangeAt(m);f=Math.min(f,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),p=Math.max(p,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(f<0)return null;[c,o]=p==t.state.selection.anchor?[p,f]:[f,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 f=e=="pointer"||t.state.selection.head<l.pos&&!a?1:-1;u=kL(t,d,l,f)}return u}function jte(t){return t.editable?t.hasFocus():Rte(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Du(t,e=!1){let n=t.state.selection;if(Dte(t,n),!!jte(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Za){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&Sm(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)DHe(t);else{let{anchor:r,head:i}=n,a,o;u9&&!(n instanceof pn)&&(n.$from.parent.inlineContent||(a=d9(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=d9(t,n.to))),t.docView.setSelection(r,i,t,e),u9&&(a&&h9(a),o&&h9(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&jHe(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const u9=ys||Za&&vte<63;function d9(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(ys&&i&&i.contentEditable=="false")return yP(i);if((!i||i.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(i)return yP(i);if(a)return yP(a)}}function yP(t){return t.contentEditable="true",ys&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function h9(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function jHe(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(()=>{(!jte(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function DHe(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ia(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Bs&&fh<=11&&(n.disabled=!0,n.disabled=!1)}function Dte(t,e){if(e instanceof Qt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(f9(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else f9(t)}function f9(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function kL(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||pn.between(e,n,r)}function m9(t){return t.editable&&!t.hasFocus()?!1:Rte(t)}function Rte(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 RHe(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Sm(e.node,e.offset,n.anchorNode,n.anchorOffset)}function UD(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return a&&Pn.findFrom(a,e)}function $d(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function p9(t,e,n){let r=t.state.selection;if(r instanceof pn)if(n.indexOf("s")>-1){let{$head:i}=r,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+a.nodeSize*(e<0?-1:1));return $d(t,new pn(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=UD(t.state,e);return i&&i instanceof Qt?$d(t,i):!1}else if(!(Go&&n.indexOf("m")>-1)){let i=r.$head,a=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!a||a.isText)return!1;let l=e<0?i.pos-a.nodeSize:i.pos;return a.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?Qt.isSelectable(a)?$d(t,new Qt(e<0?t.state.doc.resolve(i.pos-a.nodeSize):i)):bv?$d(t,new pn(t.state.doc.resolve(e<0?l:l+a.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Qt&&r.node.isInline)return $d(t,new pn(e>0?r.$to:r.$from));{let i=UD(t.state,e);return i?$d(t,i):!1}}}function mN(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function C0(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function tg(t,e){return e<0?OHe(t):LHe(t)}function OHe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,a,o=!1;for(il&&n.nodeType==1&&r<mN(n)&&C0(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(C0(l,-1))i=n,a=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(Ote(n))break;{let l=n.previousSibling;for(;l&&C0(l,-1);)i=n.parentNode,a=Ia(l),l=l.previousSibling;if(l)n=l,r=mN(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?zD(t,n,r):i&&zD(t,i,a)}function LHe(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=mN(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(C0(l,1))a=n,o=++r;else break}else{if(Ote(n))break;{let l=n.nextSibling;for(;l&&C0(l,1);)a=l.parentNode,o=Ia(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=mN(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}a&&zD(t,a,o)}function Ote(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function FHe(t,e){for(;t&&e==t.childNodes.length&&!xv(t);)e=Ia(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 IHe(t,e){for(;t&&!e&&!xv(t);)e=Ia(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 zD(t,e,n){if(e.nodeType!=3){let a,o;(o=FHe(e,n))?(e=o,n=0):(a=IHe(e,n))&&(e=a,n=a.nodeValue.length)}let r=t.domSelection();if(!r)return;if(E2(r)){let a=document.createRange();a.setEnd(e,n),a.setStart(e,n),r.removeAllRanges(),r.addRange(a)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&Du(t)},50)}function g9(t,e){let n=t.state.doc.resolve(e);if(!(Za||sHe)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),o=(a.top+a.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(a.left-i.left)>1)return a.left<i.left?"ltr":"rtl"}if(e<n.end()){let a=t.coordsAtPos(e+1),o=(a.top+a.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(a.left-i.left)>1)return a.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function x9(t,e,n){let r=t.state.selection;if(r instanceof pn&&!r.empty||n.indexOf("s")>-1||Go&&n.indexOf("m")>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=UD(t.state,e);if(o&&o instanceof Qt)return $d(t,o)}if(!i.parent.inlineContent){let o=e<0?i:a,l=r instanceof go?Pn.near(o,e):Pn.findFrom(o,e);return l?$d(t,l):!1}return!1}function b9(t,e){if(!(t.state.selection instanceof pn))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let a=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let o=t.state.tr;return e<0?o.delete(n.pos-a.nodeSize,n.pos):o.delete(n.pos,n.pos+a.nodeSize),t.dispatch(o),!0}return!1}function y9(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function UHe(t){if(!ys||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;y9(t,r,"true"),setTimeout(()=>y9(t,r,"false"),20)}return!1}function zHe(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function BHe(t,e){let n=e.keyCode,r=zHe(e);if(n==8||Go&&n==72&&r=="c")return b9(t,-1)||tg(t,-1);if(n==46&&!e.shiftKey||Go&&n==68&&r=="c")return b9(t,1)||tg(t,1);if(n==13||n==27)return!0;if(n==37||Go&&n==66&&r=="c"){let i=n==37?g9(t,t.state.selection.from)=="ltr"?-1:1:-1;return p9(t,i,r)||tg(t,i)}else if(n==39||Go&&n==70&&r=="c"){let i=n==39?g9(t,t.state.selection.from)=="ltr"?1:-1:1;return p9(t,i,r)||tg(t,i)}else{if(n==38||Go&&n==80&&r=="c")return x9(t,-1,r)||tg(t,-1);if(n==40||Go&&n==78&&r=="c")return UHe(t)||x9(t,1,r)||tg(t,1);if(r==(Go?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function EL(t,e){t.someProp("transformCopied",m=>{e=m(e,t)});let n=[],{content:r,openStart:i,openEnd:a}=e;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let m=r.firstChild;n.push(m.type.name,m.attrs!=m.type.defaultAttrs?m.attrs:null),r=m.content}let o=t.someProp("clipboardSerializer")||jm.fromSchema(t.state.schema),l=Bte(),c=l.createElement("div");c.appendChild(o.serializeFragment(r,{document:l}));let u=c.firstChild,d,f=0;for(;u&&u.nodeType==1&&(d=zte[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),f++}u=c.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${a}${f?` -${f}`:""} ${JSON.stringify(n)}`);let p=t.someProp("clipboardTextSerializer",m=>m(e,t))||e.content.textBetween(0,e.content.size,`
- `);return{dom:c,text:p,slice:e}}function Lte(t,e,n,r,i){let a=i.parent.type.spec.code,o,l;if(!n&&!e)return null;let c=!!e&&(r||a||!n);if(c){if(t.someProp("transformPastedText",p=>{e=p(e,a||r,t)}),a)return l=new Ut(kt.from(t.state.schema.text(e.replace(/\r\n?/g,`
- `))),0,0),t.someProp("transformPasted",p=>{l=p(l,t,!0)}),l;let f=t.someProp("clipboardTextParser",p=>p(e,i,r,t));if(f)l=f;else{let p=i.marks(),{schema:m}=t.state,x=jm.fromSchema(m);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let v=o.appendChild(document.createElement("p"));b&&v.appendChild(x.serializeNode(m.text(b,p)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),o=GHe(n),bv&&qHe(o);let u=o&&o.querySelector("[data-pm-slice]"),d=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let f=+d[3];f>0;f--){let 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")||E0.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||d),context:i,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!HHe.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=WHe(v9(l,+d[1],+d[2]),d[4]);else if(l=Ut.maxOpen($He(l.content,i),!0),l.openStart||l.openEnd){let f=0,p=0;for(let m=l.content.firstChild;f<l.openStart&&!m.type.spec.isolating;f++,m=m.firstChild);for(let m=l.content.lastChild;p<l.openEnd&&!m.type.spec.isolating;p++,m=m.lastChild);l=v9(l,f,p)}return t.someProp("transformPasted",f=>{l=f(l,t,c)}),l}const HHe=/^(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 $He(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),a,o=[];if(t.forEach(l=>{if(!o)return;let c=i.findWrapping(l.type),u;if(!c)return o=null;if(u=o.length&&a.length&&Ite(c,a,l,o[o.length-1],0))o[o.length-1]=u;else{o.length&&(o[o.length-1]=Ute(o[o.length-1],a.length));let d=Fte(l,c);o.push(d),i=i.matchType(d.type),a=c}}),o)return kt.from(o)}return t}function Fte(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,kt.from(t));return t}function Ite(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let a=Ite(t,e,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(kt.from(Fte(n,t,i+1))))}}function Ute(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,Ute(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(kt.empty,!0);return t.copy(n.append(r))}function BD(t,e,n,r,i,a){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(a=0),i<r-1&&(l=BD(l,e,n,r,i+1,a)),i>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,a<=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 v9(t,e,n){return e<t.openStart&&(t=new Ut(BD(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Ut(BD(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const zte={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 w9=null;function Bte(){return w9||(w9=document.implementation.createHTMLDocument("title"))}let vP=null;function VHe(t){let e=window.trustedTypes;return e?(vP||(vP=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),vP.createHTML(t)):t}function GHe(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Bte().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&zte[r[1].toLowerCase()])&&(t=i.map(a=>"<"+a+">").join("")+t+i.map(a=>"</"+a+">").reverse().join("")),n.innerHTML=VHe(t),i)for(let a=0;a<i.length;a++)n=n.querySelector(i[a])||n;return n}function qHe(t){let e=t.querySelectorAll(Za?"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 WHe(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:i,openStart:a,openEnd: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)),a++,o++}return new Ut(i,a,o)}const vs={},ws={},KHe={touchstart:!0,touchmove:!0};class XHe{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 YHe(t){for(let e in vs){let n=vs[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{ZHe(t,r)&&!TL(t,r)&&(t.editable||!(r.type in ws))&&n(t,r)},KHe[e]?{passive:!0}:void 0)}ys&&t.dom.addEventListener("input",()=>null),HD(t)}function nh(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function QHe(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 HD(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>TL(t,r))})}function TL(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function ZHe(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 JHe(t,e){!TL(t,e)&&vs[e.type]&&(t.editable||!(e.type in ws))&&vs[e.type](t,e)}ws.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!$te(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Nu&&Za&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ux&&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,Af(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||BHe(t,n)?n.preventDefault():nh(t,"key")};ws.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ws.keypress=(t,e)=>{let n=e;if($te(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Go&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof pn)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),a=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,a))&&t.dispatch(a()),n.preventDefault()}};function A2(t){return{left:t.clientX,top:t.clientY}}function e$e(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function AL(t,e,n,r,i){if(r==-1)return!1;let a=t.state.doc.resolve(r);for(let o=a.depth+1;o>0;o--)if(t.someProp(e,l=>o>a.depth?l(t,n,a.nodeAfter,a.before(o),i,!0):l(t,n,a.node(o),a.before(o),i,!1)))return!0;return!1}function Og(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 t$e(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Qt.isSelectable(r)?(Og(t,new Qt(n)),!0):!1}function n$e(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof Qt&&(r=n.node);let a=t.state.doc.resolve(e);for(let o=a.depth+1;o>0;o--){let l=o>a.depth?a.nodeAfter:a.node(o);if(Qt.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?i=a.before(n.$from.depth):i=a.before(o);break}}return i!=null?(Og(t,Qt.create(t.state.doc,i)),!0):!1}function r$e(t,e,n,r,i){return AL(t,"handleClickOn",e,n,r)||t.someProp("handleClick",a=>a(t,e,r))||(i?n$e(t,n):t$e(t,n))}function i$e(t,e,n,r){return AL(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function a$e(t,e,n,r){return AL(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||s$e(t,n,r)}function s$e(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Og(t,pn.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let a=i.depth+1;a>0;a--){let o=a>i.depth?i.nodeAfter:i.node(a),l=i.before(a);if(o.inlineContent)Og(t,pn.create(r,l+1,l+1+o.content.size));else if(Qt.isSelectable(o))Og(t,Qt.create(r,l));else continue;return!0}}function CL(t){return pN(t)}const Hte=Go?"metaKey":"ctrlKey";vs.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=CL(t),i=Date.now(),a="singleClick";i-t.input.lastClick.time<500&&e$e(n,t.input.lastClick)&&!n[Hte]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?a="doubleClick":t.input.lastClick.type=="doubleClick"&&(a="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=t.posAtCoords(A2(n));o&&(a=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new o$e(t,o,n,!!r)):(a=="doubleClick"?i$e:a$e)(t,o.pos,o.inside,n)?n.preventDefault():nh(t,"pointer"))};class o$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[Hte],this.allowDefault=r.shiftKey;let a,o;if(n.inside>-1)a=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);a=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&&a.type.spec.draggable&&a.type.spec.selectable!==!1||u instanceof Qt&&u.from<=o&&u.to>o)&&(this.mightDrag={node:a,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&il&&!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)),nh(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(()=>Du(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(A2(e))),this.updateAllowDefault(e),this.allowDefault||!n?nh(this.view,"pointer"):r$e(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ys&&this.mightDrag&&!this.mightDrag.node.isAtom||Za&&!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)?(Og(this.view,Pn.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):nh(this.view,"pointer")}move(e){this.updateAllowDefault(e),nh(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)}}vs.touchstart=t=>{t.input.lastTouch=Date.now(),CL(t),nh(t,"pointer")};vs.touchmove=t=>{t.input.lastTouch=Date.now(),nh(t,"pointer")};vs.contextmenu=t=>CL(t);function $te(t,e){return t.composing?!0:ys&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const l$e=Nu?5e3:-1;ws.compositionstart=ws.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof pn&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),pN(t,!0),t.markCursor=null;else if(pN(t,!e.selection.empty),il&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,a=r.focusOffset;i&&i.nodeType==1&&a!=0;){let o=a<0?i.lastChild:i.childNodes[a-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,a=-1}}t.input.composing=!0}Vte(t,l$e)};ws.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++,Vte(t,20))};function Vte(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>pN(t),e))}function Gte(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=u$e());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function c$e(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=tHe(e.focusNode,e.focusOffset),r=nHe(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,a=t.domObserver.lastChangedTextNode;if(n==a||r==a)return a;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function u$e(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function pN(t,e=!1){if(!(Nu&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Gte(t),e||t.docView&&t.docView.dirty){let n=ML(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 d$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 My=Bs&&fh<15||ux&&oHe<604;vs.copy=ws.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let a=My?null:n.clipboardData,o=r.content(),{dom:l,text:c}=EL(t,o);a?(n.preventDefault(),a.clearData(),a.setData("text/html",l.innerHTML),a.setData("text/plain",c)):d$e(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function h$e(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function f$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?ky(t,r.value,null,i,e):ky(t,r.textContent,r.innerHTML,i,e)},50)}function ky(t,e,n,r,i){let a=Lte(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",c=>c(t,i,a||Ut.empty)))return!0;if(!a)return!1;let o=h$e(a),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(a);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function qte(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," "):""}ws.paste=(t,e)=>{let n=e;if(t.composing&&!Nu)return;let r=My?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&ky(t,qte(r),r.getData("text/html"),i,n)?n.preventDefault():f$e(t,n)};class Wte{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const m$e=Go?"altKey":"ctrlKey";function Kte(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[m$e]}vs.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,a=i.empty?null:t.posAtCoords(A2(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof Qt?i.to-1:i.to))){if(r&&r.mightDrag)o=Qt.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let f=t.docView.nearestDesc(n.target,!0);f&&f.node.type.spec.draggable&&f!=t.docView&&(o=Qt.create(t.state.doc,f.posBefore))}}let l=(o||t.state.selection).content(),{dom:c,text:u,slice:d}=EL(t,l);(!n.dataTransfer.files.length||!Za||vte>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(My?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",My||n.dataTransfer.setData("text/plain",u),t.dragging=new Wte(d,Kte(t,n),o)};vs.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ws.dragover=ws.dragenter=(t,e)=>e.preventDefault();ws.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(A2(n));if(!i)return;let a=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",x=>{o=x(o,t,!1)}):o=Lte(t,qte(n.dataTransfer),My?null:n.dataTransfer.getData("text/html"),!1,a);let l=!!(r&&Kte(t,n));if(t.someProp("handleDrop",x=>x(t,n,o||Ut.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let c=o?Jee(t.state.doc,a.pos,o):a.pos;c==null&&(c=a.pos);let u=t.state.tr;if(l){let{node:x}=r;x?x.replace(u):u.deleteSelection()}let d=u.mapping.map(c),f=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,p=u.doc;if(f?u.replaceRangeWith(d,d,o.content.firstChild):u.replaceRange(d,d,o),u.doc.eq(p))return;let m=u.doc.resolve(d);if(f&&Qt.isSelectable(o.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(o.content.firstChild))u.setSelection(new Qt(m));else{let x=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((b,v,y,S)=>x=S),u.setSelection(kL(t,m,u.doc.resolve(x)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};vs.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())&&Du(t)},20))};vs.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)};vs.beforeinput=(t,e)=>{if(Za&&Nu&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",a=>a(t,Af(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 ws)vs[t]=ws[t];function Ey(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 gN{constructor(e,n){this.toDOM=e,this.spec=n||Qf,this.side=this.spec.side||0}map(e,n,r,i){let{pos:a,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new ms(a-r,a-r,this)}valid(){return!0}eq(e){return this==e||e instanceof gN&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ey(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ph{constructor(e,n){this.attrs=e,this.spec=n||Qf}map(e,n,r,i){let a=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return a>=o?null:new ms(a,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof ph&&Ey(this.attrs,e.attrs)&&Ey(this.spec,e.spec)}static is(e){return e.type instanceof ph}destroy(){}}class PL{constructor(e,n){this.attrs=e,this.spec=n||Qf}map(e,n,r,i){let a=e.mapResult(n.from+i,1);if(a.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=a.pos?null:new ms(a.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),a;return i==n.from&&!(a=e.child(r)).isText&&i+a.nodeSize==n.to}eq(e){return this==e||e instanceof PL&&Ey(this.attrs,e.attrs)&&Ey(this.spec,e.spec)}destroy(){}}class ms{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new ms(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 ms(e,e,new gN(n,r))}static inline(e,n,r,i){return new ms(e,n,new ph(r,i))}static node(e,n,r,i){return new ms(e,n,new PL(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof ph}get widget(){return this.type instanceof gN}}const cg=[],Qf={};class oi{constructor(e,n){this.local=e.length?e:cg,this.children=n.length?n:cg}static create(e,n){return n.length?xN(n,e,0,Qf):Xa}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,a){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!a||a(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,a)}}map(e,n,r){return this==Xa||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Qf)}mapInner(e,n,r,i,a){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):a.onRemove&&a.onRemove(this.local[l].spec)}return this.children.length?p$e(this.children,o||[],e,n,r,i,a):o?new oi(o.sort(Zf),cg):Xa}add(e,n){return n.length?this==Xa?oi.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,a=0;e.forEach((l,c)=>{let u=c+r,d;if(d=Yte(n,l,u)){for(i||(i=this.children.slice());a<i.length&&i[a]<c;)a+=3;i[a]==c?i[a+2]=i[a+2].addInner(l,d,u+1):i.splice(a,0,c,c+l.nodeSize,xN(d,l,u+1,Qf)),a+=3}});let o=Xte(a?Qte(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(Zf):this.local,i||this.children)}remove(e){return e.length==0||this==Xa?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let a=0;a<r.length;a+=3){let o,l=r[a]+n,c=r[a+1]+n;for(let d=0,f;d<e.length;d++)(f=e[d])&&f.from>l&&f.to<c&&(e[d]=null,(o||(o=[])).push(f));if(!o)continue;r==this.children&&(r=this.children.slice());let u=r[a+2].removeInner(o,l+1);u!=Xa?r[a+2]=u:(r.splice(a,3),a-=3)}if(i.length){for(let a=0,o;a<e.length;a++)if(o=e[a])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):Xa}forChild(e,n){if(this==Xa)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 a=e+1,o=a+n.content.size;for(let l=0;l<this.local.length;l++){let c=this.local[l];if(c.from<o&&c.to>a&&c.type instanceof ph){let u=Math.max(a,c.from)-a,d=Math.min(o,c.to)-a;u<d&&(i||(i=[])).push(c.copy(u,d))}}if(i){let l=new oi(i.sort(Zf),cg);return r?new Xd([l,r]):l}return r||Xa}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 jL(this.localsInner(e))}localsInner(e){if(this==Xa)return cg;if(e.inlineContent||!this.local.some(ph.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof ph||n.push(this.local[r]);return n}forEachSet(e){e(this)}}oi.empty=new oi([],[]);oi.removeOverlap=jL;const Xa=oi.empty;class Xd{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Qf));return Xd.from(r)}forChild(e,n){if(n.isLeaf)return oi.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(e,n);a!=Xa&&(a instanceof Xd?r=r.concat(a.members):r.push(a))}return Xd.from(r)}eq(e){if(!(e instanceof Xd)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let i=0;i<this.members.length;i++){let a=this.members[i].localsInner(e);if(a.length)if(!n)n=a;else{r&&(n=n.slice(),r=!1);for(let o=0;o<a.length;o++)n.push(a[o])}}return n?jL(r?n:n.sort(Zf)):cg}static from(e){switch(e.length){case 0:return Xa;case 1:return e[0];default:return new Xd(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 p$e(t,e,n,r,i,a,o){let l=t.slice();for(let u=0,d=a;u<n.maps.length;u++){let f=0;n.maps[u].forEach((p,m,x,b)=>{let v=b-x-(m-p);for(let y=0;y<l.length;y+=3){let S=l[y+1];if(S<0||p>S+d-f)continue;let k=l[y]+d-f;m>=k?l[y+1]=p<=k?-2:-1:p>=d&&v&&(l[y]+=v,l[y+1]+=v)}f+=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]+a),f=d-i;if(f<0||f>=r.content.size){c=!0;continue}let p=n.map(t[u+1]+a,-1),m=p-i,{index:x,offset:b}=r.content.findIndex(f),v=r.maybeChild(x);if(v&&b==f&&b+v.nodeSize==m){let y=l[u+2].mapInner(n,v,d+1,t[u]+a+1,o);y!=Xa?(l[u]=f,l[u+1]=m,l[u+2]=y):(l[u+1]=-2,c=!0)}else c=!0}if(c){let u=g$e(l,t,e,n,i,a,o),d=xN(u,r,0,o);e=d.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,p=0;f<d.children.length;f+=3){let m=d.children[f];for(;p<l.length&&l[p]<m;)p+=3;l.splice(p,0,d.children[f],d.children[f+1],d.children[f+2])}}return new oi(e.sort(Zf),l)}function Xte(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 ms(i.from+e,i.to+e,i.type))}return n}function g$e(t,e,n,r,i,a,o){function l(c,u){for(let d=0;d<c.local.length;d++){let f=c.local[d].map(r,i,u);f?n.push(f):o.onRemove&&o.onRemove(c.local[d].spec)}for(let d=0;d<c.children.length;d+=3)l(c.children[d+2],c.children[d]+u+1)}for(let c=0;c<t.length;c+=3)t[c+1]==-1&&l(t[c+2],e[c]+a+1);return n}function Yte(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let a=0,o;a<t.length;a++)(o=t[a])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),t[a]=null);return i}function Qte(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function xN(t,e,n,r){let i=[],a=!1;e.forEach((l,c)=>{let u=Yte(t,l,c+n);if(u){a=!0;let d=xN(u,l,n+c+1,r);d!=Xa&&i.push(c,c+l.nodeSize,d)}});let o=Xte(a?Qte(t):t,-n).sort(Zf);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):Xa}function Zf(t,e){return t.from-e.from||t.to-e.to}function jL(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let a=e[i];if(a.from==r.from){a.to!=r.to&&(e==t&&(e=t.slice()),e[i]=a.copy(a.from,r.to),_9(e,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,a.from),_9(e,i,r.copy(a.from,r.to)));break}}}return e}function _9(t,e,n){for(;e<t.length&&Zf(n,t[e])>0;)e++;t.splice(e,0,n)}function wP(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Xa&&e.push(r)}),t.cursorWrapper&&e.push(oi.create(t.state.doc,[t.cursorWrapper.deco])),Xd.from(e)}const x$e={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},b$e=Bs&&fh<=11;class y$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 v$e{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new y$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]);Bs&&fh<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),b$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,x$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(m9(this.view)){if(this.suppressingSelectionUpdates)return Du(this.view);if(Bs&&fh<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Sm(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let a=e.focusNode;a;a=cx(a))n.add(a);for(let a=e.anchorNode;a;a=cx(a))if(n.has(a)){r=a;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&m9(e)&&!this.ignoreSelectionChange(r),a=-1,o=-1,l=!1,c=[];if(e.editable)for(let d=0;d<n.length;d++){let f=this.registerMutation(n[d],c);f&&(a=a<0?f.from:Math.min(f.from,a),o=o<0?f.to:Math.max(f.to,o),f.typeOver&&(l=!0))}if(il&&c.length){let d=c.filter(f=>f.nodeName=="BR");if(d.length==2){let[f,p]=d;f.parentNode&&f.parentNode.parentNode==p.parentNode?p.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let p of d){let m=p.parentNode;m&&m.nodeName=="LI"&&(!f||S$e(e,f)!=m)&&p.remove()}}}let u=null;a<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&E2(r)&&(u=ML(e))&&u.eq(Pn.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Du(e),this.currentSelection.set(r),e.scrollToSelection()):(a>-1||i)&&(a>-1&&(e.docView.markDirty(a,o),w$e(e)),this.handleDOMChange(a,o,l,c),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Du(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];n.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,a=e.nextSibling;if(Bs&&fh<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:f,nextSibling:p}=e.addedNodes[d];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(i=f),(!p||Array.prototype.indexOf.call(e.addedNodes,p)<0)&&(a=p)}let o=i&&i.parentNode==e.target?Ia(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),c=a&&a.parentNode==e.target?Ia(a):e.target.childNodes.length,u=r.localPosFromDOM(e.target,c,1);return{from:l,to:u}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let S9=new WeakMap,N9=!1;function w$e(t){if(!S9.has(t)&&(S9.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=il,N9)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."),N9=!0}}function M9(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,a=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Sm(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function _$e(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return M9(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?M9(t,n):null}function S$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 N$e(t,e,n){let{node:r,fromOffset:i,toOffset:a,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}],E2(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Za&&t.input.lastKeyCode===8)for(let v=a;v>i;v--){let y=r.childNodes[v-1],S=y.pmViewDesc;if(y.nodeName=="BR"&&!S){a=v;break}if(!S||S.size)break}let f=t.state.doc,p=t.someProp("domParser")||E0.fromSchema(t.state.schema),m=f.resolve(o),x=null,b=p.parse(r,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:i,to:a,preserveWhitespace:m.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:M$e,context:m});if(u&&u[0].pos!=null){let v=u[0].pos,y=u[1]&&u[1].pos;y==null&&(y=v),x={anchor:v+o,head:y+o}}return{doc:b,sel:x,from:o,to:l}}function M$e(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(ys&&/^(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||ys&&/^(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 k$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 E$e(t,e,n,r,i){let a=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,R=ML(t,E);if(R&&!t.state.selection.eq(R)){if(Za&&Nu&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",D=>D(t,Af(13,"Enter"))))return;let A=t.state.tr.setSelection(R);E=="pointer"?A.setMeta("pointer",!0):E=="key"&&A.scrollIntoView(),a&&A.setMeta("composition",a),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=N$e(t,e,n),d=t.state.doc,f=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=C$e(f.content,u.doc.content,u.from,p,m);if(x&&t.input.domChangeCount++,(ux&&t.input.lastIOSEnter>Date.now()-225||Nu)&&i.some(E=>E.nodeType==1&&!k$e.test(E.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",E=>E(t,Af(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&c instanceof pn&&!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=k9(t,t.state.doc,u.sel);if(E&&!E.eq(t.state.selection)){let R=t.state.tr.setSelection(E);a&&R.setMeta("composition",a),t.dispatch(R)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof pn&&(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)),Bs&&fh<=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 b=u.doc.resolveNoCache(x.start-u.from),v=u.doc.resolveNoCache(x.endB-u.from),y=d.resolve(x.start),S=b.sameParent(v)&&b.parent.inlineContent&&y.end()>=x.endA;if((ux&&t.input.lastIOSEnter>Date.now()-225&&(!S||i.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!S&&b.pos<u.doc.content.size&&(!b.sameParent(v)||!b.parent.inlineContent)&&b.pos<v.pos&&!/\S/.test(u.doc.textBetween(b.pos,v.pos,"","")))&&t.someProp("handleKeyDown",E=>E(t,Af(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&A$e(d,x.start,x.endA,b,v)&&t.someProp("handleKeyDown",E=>E(t,Af(8,"Backspace")))){Nu&&Za&&t.domObserver.suppressSelectionUpdates();return}Za&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),Nu&&!S&&b.start()!=v.start()&&v.parentOffset==0&&b.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,Af(13,"Enter"))})},20));let k=x.start,T=x.endA,M=E=>{let R=E||t.state.tr.replace(k,T,u.doc.slice(x.start-u.from,x.endB-u.from));if(u.sel){let A=k9(t,R.doc,u.sel);A&&!(Za&&t.composing&&A.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(A.head==k||A.head==R.mapping.map(T)-1)||Bs&&A.empty&&A.head==k)&&R.setSelection(A)}return a&&R.setMeta("composition",a),R.scrollIntoView()},C;if(S)if(b.pos==v.pos){Bs&&fh<=11&&b.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Du(t),20));let E=M(t.state.tr.delete(k,T)),R=d.resolve(x.start).marksAcross(d.resolve(x.endA));R&&E.ensureMarks(R),t.dispatch(E)}else if(x.endA==x.endB&&(C=T$e(b.parent.content.cut(b.parentOffset,v.parentOffset),y.parent.content.cut(y.parentOffset,x.endA-y.start())))){let E=M(t.state.tr);C.type=="add"?E.addMark(k,T,C.mark):E.removeMark(k,T,C.mark),t.dispatch(E)}else if(b.parent.child(b.index()).isText&&b.index()==v.index()-(v.textOffset?0:1)){let E=b.parent.textBetween(b.parentOffset,v.parentOffset),R=()=>M(t.state.tr.insertText(E,k,T));t.someProp("handleTextInput",A=>A(t,k,T,E,R))||t.dispatch(R())}else t.dispatch(M());else t.dispatch(M())}function k9(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:kL(t,e.resolve(n.anchor),e.resolve(n.head))}function T$e(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,a=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++)a=n[d].removeFromSet(a);if(i.length==1&&a.length==0)l=i[0],o="add",c=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&a.length==1)l=a[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 A$e(t,e,n,r,i){if(n-e<=i.pos-r.pos||_P(r,!0,!1)<i.pos)return!1;let a=t.resolve(e);if(!r.parent.isTextblock){let l=a.nodeAfter;return l!=null&&n==e+l.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=t.resolve(_P(a,!0,!0));return!o.parent.isTextblock||o.pos>n||_P(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function _P(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let a=t.node(r).maybeChild(t.indexAfter(r));for(;a&&!a.isLeaf;)a=a.firstChild,i++}return i}function C$e(t,e,n,r,i){let a=t.findDiffStart(e,n);if(a==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,a-Math.min(o,l));r-=o+c-a}if(o<a&&t.size<e.size){let c=r<=a&&r>=o?a-r:0;a-=c,a&&a<e.size&&E9(e.textBetween(a-1,a+1))&&(a+=c?1:-1),l=a+(l-o),o=a}else if(l<a){let c=r<=a&&r>=l?a-r:0;a-=c,a&&a<t.size&&E9(t.textBetween(a-1,a+1))&&(a+=c?1:-1),o=a+(o-l),l=a}return{start:a,endA:o,endB:l}}function E9(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 Zte{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 XHe,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(j9),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=C9(this),A9(this),this.nodeViews=P9(this),this.docView=l9(this.state.doc,T9(this),wP(this),this.dom,this),this.domObserver=new v$e(this,(r,i,a,o)=>E$e(this,r,i,a,o)),this.domObserver.start(),YHe(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&&HD(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(j9),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,a=!1,o=!1;e.storedMarks&&this.composing&&(Gte(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=P9(this);j$e(m,this.nodeViews)&&(this.nodeViews=m,a=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&HD(this),this.editable=C9(this),A9(this);let c=wP(this),u=T9(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=a||!this.docView.matchesNode(e.doc,u,c);(f||!e.selection.eq(i.selection))&&(o=!0);let p=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&uHe(this);if(o){this.domObserver.stop();let m=f&&(Bs||Za)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&P$e(i.selection,e.selection);if(f){let x=Za?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=c$e(this)),(a||!this.docView.update(e.doc,u,c,this))&&(this.docView.updateOuterDeco(u),this.docView.destroy(),this.docView=l9(e.doc,u,c,this.dom,this)),x&&!this.trackWrites&&(m=!0)}m||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&RHe(this))?Du(this,m):(Dte(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&&dHe(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 Qt){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&n9(this,n.getBoundingClientRect(),e)}else n9(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let a=r.from+(this.state.doc.content.size-n.doc.content.size);(a>0&&this.state.doc.nodeAt(a))==r.node&&(i=a)}this.dragging=new Wte(e.slice,e.move,i<0?void 0:Qt.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 a=this.state.plugins;if(a)for(let o=0;o<a.length;o++){let l=a[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(Bs){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&&hHe(this.dom),Du(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 xHe(this,e)}coordsAtPos(e,n=1){return Mte(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 _He(this,n||this.state,e)}pasteHTML(e,n){return ky(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return ky(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return EL(this,e)}destroy(){this.docView&&(QHe(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],wP(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,J6e())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return JHe(this,e)}domSelectionRange(){let e=this.domSelection();return e?ys&&this.root.nodeType===11&&iHe(this.dom.ownerDocument)==this.dom&&_$e(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Zte.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function T9(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"),[ms.node(0,t.state.doc.content.size,e)]}function A9(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:ms.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function C9(t){return!t.someProp("editable",e=>e(t.state)===!1)}function P$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 P9(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 j$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 j9(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 jh={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:"'"},bN={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},D$e=typeof navigator<"u"&&/Mac/.test(navigator.platform),R$e=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Ua=0;Ua<10;Ua++)jh[48+Ua]=jh[96+Ua]=String(Ua);for(var Ua=1;Ua<=24;Ua++)jh[Ua+111]="F"+Ua;for(var Ua=65;Ua<=90;Ua++)jh[Ua]=String.fromCharCode(Ua+32),bN[Ua]=String.fromCharCode(Ua);for(var SP in jh)bN.hasOwnProperty(SP)||(bN[SP]=jh[SP]);function O$e(t){var e=D$e&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||R$e&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?bN:jh)[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 L$e=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),F$e=typeof navigator<"u"&&/Win/.test(navigator.platform);function I$e(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,a,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))a=!0;else if(/^mod$/i.test(c))L$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),a&&(n="Shift-"+n),n}function U$e(t){let e=Object.create(null);for(let n in t)e[I$e(n)]=t[n];return e}function NP(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 z$e(t){return new di({props:{handleKeyDown:Jte(t)}})}function Jte(t){let e=U$e(t);return function(n,r){let i=O$e(r),a,o=e[NP(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[NP(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(F$e&&r.ctrlKey&&r.altKey)&&(a=jh[r.keyCode])&&a!=i){let l=e[NP(a,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var B$e=Object.defineProperty,DL=(t,e)=>{for(var n in e)B$e(t,n,{get:e[n],enumerable:!0})};function C2(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:a}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}var 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,a=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...u)=>{const d=l(...u)(a);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o=[],l=!!t,c=t||i.tr,u=()=>(!l&&e&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(c),o.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(n).map(([f,p])=>[f,(...x)=>{const b=this.buildProps(c,e),v=p(...x)(b);return o.push(v),d}])),run:u};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,a=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,c])=>[l,(...u)=>c(...u)({...a,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:a}=r,o={tr:t,editor:r,view:a,state:C2({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}},ene={};DL(ene,{blur:()=>H$e,clearContent:()=>$$e,clearNodes:()=>V$e,command:()=>G$e,createParagraphNear:()=>q$e,cut:()=>W$e,deleteCurrentNode:()=>K$e,deleteNode:()=>X$e,deleteRange:()=>Y$e,deleteSelection:()=>Q$e,enter:()=>Z$e,exitCode:()=>J$e,extendMarkRange:()=>eVe,first:()=>tVe,focus:()=>rVe,forEach:()=>iVe,insertContent:()=>aVe,insertContentAt:()=>lVe,joinBackward:()=>dVe,joinDown:()=>uVe,joinForward:()=>hVe,joinItemBackward:()=>fVe,joinItemForward:()=>mVe,joinTextblockBackward:()=>pVe,joinTextblockForward:()=>gVe,joinUp:()=>cVe,keyboardShortcut:()=>bVe,lift:()=>yVe,liftEmptyBlock:()=>vVe,liftListItem:()=>wVe,newlineInCode:()=>_Ve,resetAttributes:()=>SVe,scrollIntoView:()=>NVe,selectAll:()=>MVe,selectNodeBackward:()=>kVe,selectNodeForward:()=>EVe,selectParentNode:()=>TVe,selectTextblockEnd:()=>AVe,selectTextblockStart:()=>CVe,setContent:()=>PVe,setMark:()=>XVe,setMeta:()=>YVe,setNode:()=>QVe,setNodeSelection:()=>ZVe,setTextDirection:()=>JVe,setTextSelection:()=>eGe,sinkListItem:()=>tGe,splitBlock:()=>nGe,splitListItem:()=>rGe,toggleList:()=>iGe,toggleMark:()=>aGe,toggleNode:()=>sGe,toggleWrap:()=>oGe,undoInputRule:()=>lGe,unsetAllMarks:()=>cGe,unsetMark:()=>uGe,unsetTextDirection:()=>dGe,updateAttributes:()=>hGe,wrapIn:()=>fGe,wrapInList:()=>mGe});var H$e=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),$$e=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),V$e=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:a,$to:o})=>{t.doc.nodesBetween(a.pos,o.pos,(l,c)=>{if(l.type.isText)return;const{doc:u,mapping:d}=e,f=u.resolve(d.map(c)),p=u.resolve(d.map(c+l.nodeSize)),m=f.blockRange(p);if(!m)return;const x=Ox(m);if(l.type.isTextblock){const{defaultType:b}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(m.start,b)}(x||x===0)&&e.lift(m,x)})}),!0},G$e=t=>e=>t(e),q$e=()=>({state:t,dispatch:e})=>pte(t,e),W$e=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,a=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,a.content),r.setSelection(new pn(r.doc.resolve(Math.max(o-1,0)))),!0},K$e=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===r.type){if(e){const l=i.before(a),c=i.after(a);t.delete(l,c).scrollIntoView()}return!0}return!1};function qi(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 X$e=t=>({tr:e,state:n,dispatch:r})=>{const i=qi(t,n.schema),a=e.selection.$anchor;for(let o=a.depth;o>0;o-=1)if(a.node(o).type===i){if(r){const c=a.before(o),u=a.after(o);e.delete(c,u).scrollIntoView()}return!0}return!1},Y$e=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},Q$e=()=>({state:t,dispatch:e})=>yL(t,e),Z$e=()=>({commands:t})=>t.keyboardShortcut("Enter"),J$e=()=>({state:t,dispatch:e})=>I6e(t,e);function RL(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function yN(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:RL(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function tne(t,e,n={}){return t.find(r=>r.type===e&&yN(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function D9(t,e,n={}){return!!tne(t,e,n)}function OL(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),!tne([...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&&D9([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&D9([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function Yu(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 eVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=Yu(t,r.schema),{doc:o,selection:l}=n,{$from:c,from:u,to:d}=l;if(i){const f=OL(c,a,e);if(f&&f.from<=u&&f.to>=d){const p=pn.create(o,f.from,f.to);n.setSelection(p)}}return!0},tVe=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 nne(t){return t instanceof pn}function If(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function rne(t,e=null){if(!e)return null;const n=Pn.atStart(t),r=Pn.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,a=r.to;return e==="all"?pn.create(t,If(0,i,a),If(t.content.size,i,a)):pn.create(t,If(e,i,a),If(e,i,a))}function nVe(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function LL(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var rVe=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{e={scrollIntoView:!0,...e};const o=()=>{(LL()||nVe())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(a&&t===null&&!nne(n.state.selection))return o(),!0;const l=rne(i.doc,t)||n.state.selection,c=n.state.selection.eq(l);return a&&(c||i.setSelection(l),c&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},iVe=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),aVe=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),ine=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&&ine(r)}return t};function n1(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 ine(n)}function Ty(t,e,n){if(t instanceof hh||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(a){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:a});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",a),Ty("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const c=new Hee({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?E0.fromSchema(c).parseSlice(n1(t),n.parseOptions):E0.fromSchema(c).parse(n1(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const a=E0.fromSchema(e);return n.slice?a.parseSlice(n1(t),n.parseOptions).content:a.parse(n1(t),n.parseOptions)}return Ty("",e,n)}function sVe(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof ba||i instanceof _a))return;const a=t.mapping.maps[r];let o=0;a.forEach((l,c,u,d)=>{o===0&&(o=d)}),t.setSelection(Pn.near(t.doc.resolve(o),n))}var oVe=t=>!("type"in t),lVe=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{var o;if(i){n={parseOptions:a.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const c=v=>{a.emit("contentError",{editor:a,error:v,disableCollaboration:()=>{"collaboration"in a.storage&&typeof a.storage.collaboration=="object"&&a.storage.collaboration&&(a.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!a.options.enableContentCheck&&a.options.emitContentError)try{Ty(e,a.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(v){c(v)}try{l=Ty(e,a.schema,{parseOptions:u,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:a.options.enableContentCheck})}catch(v){return c(v),!1}let{from:d,to:f}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},p=!0,m=!0;if((oVe(l)?l:[l]).forEach(v=>{v.check(),p=p?v.isText&&v.marks.length===0:!1,m=m?v.isBlock:!1}),d===f&&m){const{parent:v}=r.doc.resolve(d);v.isTextblock&&!v.type.spec.code&&!v.childCount&&(d-=1,f+=1)}let b;if(p){if(Array.isArray(e))b=e.map(v=>v.text||"").join("");else if(e instanceof kt){let v="";e.forEach(y=>{y.text&&(v+=y.text)}),b=v}else typeof e=="object"&&e&&e.text?b=e.text:b=e;r.insertText(b,d,f)}else{b=l;const v=r.doc.resolve(d),y=v.node(),S=v.parentOffset===0,k=y.isText||y.isTextblock,T=y.content.size>0;S&&k&&T&&(d=Math.max(0,d-1)),r.replaceWith(d,f,b)}n.updateSelection&&sVe(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:b}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:b})}return!0},cVe=()=>({state:t,dispatch:e})=>O6e(t,e),uVe=()=>({state:t,dispatch:e})=>L6e(t,e),dVe=()=>({state:t,dispatch:e})=>lte(t,e),hVe=()=>({state:t,dispatch:e})=>hte(t,e),fVe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=N2(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},mVe=()=>({state:t,dispatch:e,tr:n})=>{try{const r=N2(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},pVe=()=>({state:t,dispatch:e})=>D6e(t,e),gVe=()=>({state:t,dispatch:e})=>R6e(t,e);function ane(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function xVe(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,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))a=!0;else if(/^mod$/i.test(c))LL()||ane()?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}`),a&&(n=`Shift-${n}`),n}var bVe=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=xVe(t).split(/-(?!$)/),o=a.find(u=>!["Alt","Ctrl","Meta","Shift"].includes(u)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),c=e.captureTransaction(()=>{n.someProp("handleKeyDown",u=>u(n,l))});return c?.steps.forEach(u=>{const d=u.map(r.mapping);d&&i&&r.maybeStep(d)}),!0};function Dh(t,e,n={}){const{from:r,to:i,empty:a}=t.selection,o=e?qi(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(f,p)=>{if(f.isText)return;const m=Math.max(r,p),x=Math.min(i,p+f.nodeSize);l.push({node:f,from:m,to:x})});const c=i-r,u=l.filter(f=>o?o.name===f.node.type.name:!0).filter(f=>yN(f.node.attrs,n,{strict:!1}));return a?!!u.length:u.reduce((f,p)=>f+p.to-p.from,0)>=c}var yVe=(t,e={})=>({state:n,dispatch:r})=>{const i=qi(t,n.schema);return Dh(n,i,e)?F6e(n,r):!1},vVe=()=>({state:t,dispatch:e})=>gte(t,e),wVe=t=>({state:e,dispatch:n})=>{const r=qi(t,e.schema);return X6e(r)(e,n)},_Ve=()=>({state:t,dispatch:e})=>mte(t,e);function j2(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function R9(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 SVe=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=j2(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=qi(t,r.schema)),l==="mark"&&(o=Yu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,f)=>{a&&a===d.type&&(c=!0,i&&n.setNodeMarkup(f,void 0,R9(d.attrs,e))),o&&d.marks.length&&d.marks.forEach(p=>{o===p.type&&(c=!0,i&&n.addMark(f,f+d.nodeSize,o.create(R9(p.attrs,e))))})})}),c},NVe=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),MVe=()=>({tr:t,dispatch:e})=>{if(e){const n=new go(t.doc);t.setSelection(n)}return!0},kVe=()=>({state:t,dispatch:e})=>ute(t,e),EVe=()=>({state:t,dispatch:e})=>fte(t,e),TVe=()=>({state:t,dispatch:e})=>B6e(t,e),AVe=()=>({state:t,dispatch:e})=>V6e(t,e),CVe=()=>({state:t,dispatch:e})=>$6e(t,e);function $D(t,e,n={},r={}){return Ty(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var PVe=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:a,dispatch:o,commands:l})=>{const{doc:c}=a;if(r.preserveWhitespace!=="full"){const u=$D(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&a.replaceWith(0,c.content.size,u).setMeta("preventUpdate",!n),!0}return o&&a.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:c.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function sne(t,e){const n=Yu(e,t.schema),{from:r,to:i,empty:a}=t.selection,o=[];a?(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 one(t,e){const n=new ite(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function jVe(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 DVe(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,a)=>{n(i)&&r.push({node:i,pos:a})}),r}function RVe(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 D2(t){return e=>RVe(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 FL(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Xt(e,"addExtensions",n);return r?[e,...FL(r())]:e}).flat(10)}function IL(t,e){const n=jm.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function lne(t){return typeof t=="function"}function xr(t,e=void 0,...n){return lne(t)?e?t.bind(e)(...n):t(...n):t}function OVe(t={}){return Object.keys(t).length===0&&t.constructor===Object}function dx(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 cne(t){const e=[],{nodeExtensions:n,markExtensions:r}=dx(t),i=[...n,...r],a={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(f=>{Object.entries(d.attributes).forEach(([p,m])=>{e.push({type:f,name:p,attribute:{...a,...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,f])=>{const p={...a,...f};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,a])=>{if(!r[i]){r[i]=a;return}if(i==="class"){const l=a?String(a).split(" "):[],c=r[i]?r[i].split(" "):[],u=l.filter(d=>!c.includes(d));r[i]=[...c,...u].join(" ")}else if(i==="style"){const l=a?a.split(";").map(d=>d.trim()).filter(Boolean):[],c=r[i]?r[i].split(";").map(d=>d.trim()).filter(Boolean):[],u=new Map;c.forEach(d=>{const[f,p]=d.split(":").map(m=>m.trim());u.set(f,p)}),l.forEach(d=>{const[f,p]=d.split(":").map(m=>m.trim());u.set(f,p)}),r[i]=Array.from(u.entries()).map(([d,f])=>`${d}: ${f}`).join("; ")}else r[i]=a}),r},{})}function vN(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 LVe(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function O9(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((a,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):LVe(n.getAttribute(o.name));return l==null?a:{...a,[o.name]:l}},{});return{...r,...i}}}}function L9(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&OVe(n)?!1:n!=null))}function F9(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 FVe(t,e){var n;const r=cne(t),{nodeExtensions:i,markExtensions:a}=dx(t),o=(n=i.find(u=>Xt(u,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(u=>{const d=r.filter(y=>y.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},p=t.reduce((y,S)=>{const k=Xt(S,"extendNodeSchema",f);return{...y,...k?k(u):{}}},{}),m=L9({...p,content:xr(Xt(u,"content",f)),marks:xr(Xt(u,"marks",f)),group:xr(Xt(u,"group",f)),inline:xr(Xt(u,"inline",f)),atom:xr(Xt(u,"atom",f)),selectable:xr(Xt(u,"selectable",f)),draggable:xr(Xt(u,"draggable",f)),code:xr(Xt(u,"code",f)),whitespace:xr(Xt(u,"whitespace",f)),linebreakReplacement:xr(Xt(u,"linebreakReplacement",f)),defining:xr(Xt(u,"defining",f)),isolating:xr(Xt(u,"isolating",f)),attrs:Object.fromEntries(d.map(F9))}),x=xr(Xt(u,"parseHTML",f));x&&(m.parseDOM=x.map(y=>O9(y,d)));const b=Xt(u,"renderHTML",f);b&&(m.toDOM=y=>b({node:y,HTMLAttributes:vN(y,d)}));const v=Xt(u,"renderText",f);return v&&(m.toText=v),[u.name,m]})),c=Object.fromEntries(a.map(u=>{const d=r.filter(v=>v.type===u.name),f={name:u.name,options:u.options,storage:u.storage,editor:e},p=t.reduce((v,y)=>{const S=Xt(y,"extendMarkSchema",f);return{...v,...S?S(u):{}}},{}),m=L9({...p,inclusive:xr(Xt(u,"inclusive",f)),excludes:xr(Xt(u,"excludes",f)),group:xr(Xt(u,"group",f)),spanning:xr(Xt(u,"spanning",f)),code:xr(Xt(u,"code",f)),attrs:Object.fromEntries(d.map(F9))}),x=xr(Xt(u,"parseHTML",f));x&&(m.parseDOM=x.map(v=>O9(v,d)));const b=Xt(u,"renderHTML",f);return b&&(m.toDOM=v=>b({mark:v,HTMLAttributes:vN(v,d)})),[u.name,m]}));return new Hee({topNode:o,nodes:l,marks:c})}function IVe(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function UL(t){return t.sort((n,r)=>{const i=Xt(n,"priority")||100,a=Xt(r,"priority")||100;return i>a?-1:i<a?1:0})}function une(t){const e=UL(FL(t)),n=IVe(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 dne(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
- `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(c,u,d,f)=>{var p;c.isBlock&&u>r&&(l+=a);const m=o?.[c.type.name];if(m)return d&&(l+=m({node:c,pos:u,parent:d,index:f,range:e})),!1;c.isText&&(l+=(p=c?.text)==null?void 0:p.slice(Math.max(r,u)-u,i-u))}),l}function UVe(t,e){const n={from:0,to:t.content.size};return dne(t,n,e)}function hne(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function zVe(t,e){const n=qi(e,t.schema),{from:r,to:i}=t.selection,a=[];t.doc.nodesBetween(r,i,l=>{a.push(l)});const o=a.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function fne(t,e){const n=j2(typeof e=="string"?e:e.name,t.schema);return n==="node"?zVe(t,e):n==="mark"?sne(t,e):{}}function BVe(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 HVe(t){const e=BVe(t);return e.length===1?e:e.filter((n,r)=>!e.filter((a,o)=>o!==r).some(a=>n.oldRange.from>=a.oldRange.from&&n.oldRange.to<=a.oldRange.to&&n.newRange.from>=a.newRange.from&&n.newRange.to<=a.newRange.to))}function mne(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,a)=>{const o=[];if(i.ranges.length)i.forEach((l,c)=>{o.push({from:l,to:c})});else{const{from:l,to:c}=n[a];if(l===void 0||c===void 0)return;o.push({from:l,to:c})}o.forEach(({from:l,to:c})=>{const u=e.slice(a).map(l,-1),d=e.slice(a).map(c),f=e.invert().map(u,-1),p=e.invert().map(d);r.push({oldRange:{from:f,to:p},newRange:{from:u,to:d}})})}),HVe(r)}function zL(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const a=n.resolve(t),o=OL(a,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,a)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:a,to:a+i.nodeSize,mark:o})))}),r}var $Ve=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let a=r,o=null;for(;a>0&&o===null;){const l=i.node(a);l?.type.name===e?o=l:a-=1}return[o,a]};function MP(t,e){return e.nodes[t]||e.marks[t]||null}function L1(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(a=>a.type===e&&a.name===r);return i?i.attribute.keepOnSplit:!1}))}var VVe=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,a,o,l)=>{var c,u;const d=((u=(c=i.type.spec).toText)==null?void 0:u.call(c,{node:i,pos:a,parent:o,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?d:d.slice(0,Math.max(0,r-a))}),n};function VD(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?Yu(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(f=>a?a.name===f.type.name:!0).find(f=>yN(f.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:f,$to:p})=>{const m=f.pos,x=p.pos;t.doc.nodesBetween(m,x,(b,v)=>{if(!b.isText&&!b.marks.length)return;const y=Math.max(m,v),S=Math.min(x,v+b.nodeSize),k=S-y;o+=k,l.push(...b.marks.map(T=>({mark:T,from:y,to:S})))})}),o===0)return!1;const c=l.filter(f=>a?a.name===f.mark.type.name:!0).filter(f=>yN(f.mark.attrs,n,{strict:!1})).reduce((f,p)=>f+p.to-p.from,0),u=l.filter(f=>a?f.mark.type!==a&&f.mark.type.excludes(a):!0).reduce((f,p)=>f+p.to-p.from,0);return(c>0?c+u:c)>=o}function GVe(t,e,n={}){if(!e)return Dh(t,null,n)||VD(t,null,n);const r=j2(e,t.schema);return r==="node"?Dh(t,e,n):r==="mark"?VD(t,e,n):!1}var qVe=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const a=D2(l=>l.type.name===e)(t.selection);if(!a)return!1;const o=t.doc.resolve(a.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},WVe=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function I9(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function U9(t,e){const{nodeExtensions:n}=dx(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=xr(Xt(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function R2(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let i=!0;return t.content.forEach(a=>{i!==!1&&(R2(a,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function pne(t){return t instanceof Qt}function KVe(t,e,n){var r;const{selection:i}=e;let a=null;if(nne(i)&&(a=i.$cursor),a){const l=(r=t.storedMarks)!=null?r:a.marks();return a.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(u=>u.type.excludes(n)))}const{ranges:o}=i;return o.some(({$from:l,$to:c})=>{let u=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,c.pos,(d,f,p)=>{if(u)return!1;if(d.isInline){const m=!p||p.type.allowsMarkType(n),x=!!n.isInSet(d.marks)||!d.marks.some(b=>b.type.excludes(n));u=m&&x}return!u}),u})}var XVe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:o,ranges:l}=a,c=Yu(t,r.schema);if(i)if(o){const u=sne(r,c);n.addStoredMark(c.create({...u,...e}))}else l.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;r.doc.nodesBetween(d,f,(p,m)=>{const x=Math.max(m,d),b=Math.min(m+p.nodeSize,f);p.marks.find(y=>y.type===c)?p.marks.forEach(y=>{c===y.type&&n.addMark(x,b,c.create({...y.attrs,...e}))}):n.addMark(x,b,c.create(e))})});return KVe(r,n,c)},YVe=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),QVe=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=qi(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),a.isTextblock?i().command(({commands:l})=>J7(a,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>J7(a,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ZVe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=If(t,0,r.content.size),a=Qt.create(r,i);e.setSelection(a)}return!0},JVe=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=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=a.from,l=a.to),i&&n.doc.nodesBetween(o,l,(c,u)=>{c.isText||n.setNodeMarkup(u,void 0,{...c.attrs,dir:t})}),!0},eGe=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,o=pn.atStart(r).from,l=pn.atEnd(r).to,c=If(i,o,l),u=If(a,o,l),d=pn.create(r,c,u);e.setSelection(d)}return!0},tGe=t=>({state:e,dispatch:n})=>{const r=qi(t,e.schema);return Z6e(r)(e,n)};function z9(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 nGe=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:o}=e,{$from:l,$to:c}=a,u=i.extensionManager.attributes,d=L1(u,l.node().type.name,l.node().attrs);if(a instanceof Qt&&a.node.isBlock)return!l.parentOffset||!ju(o,l.pos)?!1:(r&&(t&&z9(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=c.parentOffset===c.parent.content.size,p=l.depth===0?void 0:jVe(l.node(-1).contentMatchAt(l.indexAfter(-1)));let m=f&&p?[{type:p,attrs:d}]:void 0,x=ju(e.doc,e.mapping.map(l.pos),1,m);if(!m&&!x&&ju(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&&(a instanceof pn&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,m),p&&!f&&!l.parentOffset&&l.parent.type!==p)){const b=e.mapping.map(l.before()),v=e.doc.resolve(b);l.node(-1).canReplaceWith(v.index(),v.index()+1,p)&&e.setNodeMarkup(e.mapping.map(l.before()),p)}t&&z9(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},rGe=(t,e={})=>({tr:n,state:r,dispatch:i,editor:a})=>{var o;const l=qi(t,r.schema),{$from:c,$to:u}=r.selection,d=r.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const f=c.node(-1);if(f.type!==l)return!1;const p=a.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(i){let y=kt.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let R=c.depth-S;R>=c.depth-3;R-=1)y=kt.from(c.node(R).copy(y));const k=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,T={...L1(p,c.node().type.name,c.node().attrs),...e},M=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(T))||void 0;y=y.append(kt.from(l.createAndFill(null,M)||void 0));const C=c.before(c.depth-(S-1));n.replace(C,c.after(-k),new Ut(y,4-S,0));let E=-1;n.doc.nodesBetween(C,n.doc.content.size,(R,A)=>{if(E>-1)return!1;R.isTextblock&&R.content.size===0&&(E=A+1)}),E>-1&&n.setSelection(pn.near(n.doc.resolve(E))),n.scrollIntoView()}return!0}const m=u.pos===c.end()?f.contentMatchAt(0).defaultType:null,x={...L1(p,f.type.name,f.attrs),...e},b={...L1(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:b}]:[{type:l,attrs:x}];if(!ju(n.doc,c.pos,2))return!1;if(i){const{selection:y,storedMarks:S}=r,{splittableMarks:k}=a.extensionManager,T=S||y.$to.parentOffset&&y.$from.marks();if(n.split(c.pos,2,v).scrollIntoView(),!T||!i)return!0;const M=T.filter(C=>k.includes(C.type.name));n.ensureMarks(M)}return!0},kP=(t,e)=>{const n=D2(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&&zh(t.doc,n.pos)&&t.join(n.pos),!0},EP=(t,e)=>{const n=D2(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&&zh(t.doc,r)&&t.join(r),!0},iGe=(t,e,n,r={})=>({editor:i,tr:a,state:o,dispatch:l,chain:c,commands:u,can:d})=>{const{extensions:f,splittableMarks:p}=i.extensionManager,m=qi(t,o.schema),x=qi(e,o.schema),{selection:b,storedMarks:v}=o,{$from:y,$to:S}=b,k=y.blockRange(S),T=v||b.$to.parentOffset&&b.$from.marks();if(!k)return!1;const M=D2(C=>U9(C.type.name,f))(b);if(k.depth>=1&&M&&k.depth-M.depth<=1){if(M.node.type===m)return u.liftListItem(x);if(U9(M.node.type.name,f)&&m.validContent(M.node.content)&&l)return c().command(()=>(a.setNodeMarkup(M.pos,m),!0)).command(()=>kP(a,m)).command(()=>EP(a,m)).run()}return!n||!T||!l?c().command(()=>d().wrapInList(m,r)?!0:u.clearNodes()).wrapInList(m,r).command(()=>kP(a,m)).command(()=>EP(a,m)).run():c().command(()=>{const C=d().wrapInList(m,r),E=T.filter(R=>p.includes(R.type.name));return a.ensureMarks(E),C?!0:u.clearNodes()}).wrapInList(m,r).command(()=>kP(a,m)).command(()=>EP(a,m)).run()},aGe=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,o=Yu(t,r.schema);return VD(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:a}):i.setMark(o,e)},sGe=(t,e,n={})=>({state:r,commands:i})=>{const a=qi(t,r.schema),o=qi(e,r.schema),l=Dh(r,a,n);let c;return r.selection.$anchor.sameParent(r.selection.$head)&&(c=r.selection.$anchor.parent.attrs),l?i.setNode(o,c):i.setNode(a,{...c,...n})},oGe=(t,e={})=>({state:n,commands:r})=>{const i=qi(t,n.schema);return Dh(n,i,e)?r.lift(i):r.wrapIn(i,e)},lGe=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let a;if(i.spec.isInputRules&&(a=i.getState(t))){if(e){const o=t.tr,l=a.transform;for(let c=l.steps.length-1;c>=0;c-=1)o.step(l.steps[c].invert(l.docs[c]));if(a.text){const c=o.doc.resolve(a.from).marks();o.replaceWith(a.from,a.to,t.schema.text(a.text,c))}else o.delete(a.from,a.to)}return!0}}return!1},cGe=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},uGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,c=Yu(t,r.schema),{$from:u,empty:d,ranges:f}=l;if(!i)return!0;if(d&&o){let{from:p,to:m}=l;const x=(a=u.marks().find(v=>v.type===c))==null?void 0:a.attrs,b=OL(u,c,x);b&&(p=b.from,m=b.to),n.removeMark(p,m,c)}else f.forEach(p=>{n.removeMark(p.$from.pos,p.$to.pos,c)});return n.removeStoredMark(c),!0},dGe=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let a,o;return typeof t=="number"?(a=t,o=t):t&&"from"in t&&"to"in t?(a=t.from,o=t.to):(a=i.from,o=i.to),r&&e.doc.nodesBetween(a,o,(l,c)=>{if(l.isText)return;const u={...l.attrs};delete u.dir,e.setNodeMarkup(c,void 0,u)}),!0},hGe=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let a=null,o=null;const l=j2(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(a=qi(t,r.schema)),l==="mark"&&(o=Yu(t,r.schema));let c=!1;return n.selection.ranges.forEach(u=>{const d=u.$from.pos,f=u.$to.pos;let p,m,x,b;n.selection.empty?r.doc.nodesBetween(d,f,(v,y)=>{a&&a===v.type&&(c=!0,x=Math.max(y,d),b=Math.min(y+v.nodeSize,f),p=y,m=v)}):r.doc.nodesBetween(d,f,(v,y)=>{y<d&&a&&a===v.type&&(c=!0,x=Math.max(y,d),b=Math.min(y+v.nodeSize,f),p=y,m=v),y>=d&&y<=f&&(a&&a===v.type&&(c=!0,i&&n.setNodeMarkup(y,void 0,{...v.attrs,...e})),o&&v.marks.length&&v.marks.forEach(S=>{if(o===S.type&&(c=!0,i)){const k=Math.max(y,d),T=Math.min(y+v.nodeSize,f);n.addMark(k,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,b,o.create({...v.attrs,...e}))}))}),c},fGe=(t,e={})=>({state:n,dispatch:r})=>{const i=qi(t,n.schema);return G6e(i,e)(n,r)},mGe=(t,e={})=>({state:n,dispatch:r})=>{const i=qi(t,n.schema);return q6e(i,e)(n,r)},pGe=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={}}},O2=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},gGe=(t,e)=>{if(RL(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 r1(t){var e;const{editor:n,from:r,to:i,text:a,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 f=VVe(u)+a;return o.forEach(p=>{if(d)return;const m=gGe(f,p.find);if(!m)return;const x=c.state.tr,b=C2({state:c.state,transaction:x}),v={from:r-(m[0].length-a.length),to:i},{commands:y,chain:S,can:k}=new P2({editor:n,state:b});p.handler({state:b,range:v,match:m,commands:y,chain:S,can:k})===null||!x.steps.length||(p.undoable&&x.setMeta(l,{transform:x,from:r,to:i,text:a}),c.dispatch(x),d=!0)}),d}function xGe(t){const{editor:e,rules:n}=t,r=new di({state:{init(){return null},apply(i,a,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=IL(kt.from(d),o.schema);const{from:f}=c,p=f+d.length;r1({editor:e,from:f,to:p,text:d,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:a}},props:{handleTextInput(i,a,o,l){return r1({editor:e,from:a,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:a}=i.state.selection;a&&r1({editor:e,from:a.pos,to:a.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,a){if(a.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?r1({editor:e,from:o.pos,to:o.pos,text:`
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function bGe(t){return Object.prototype.toString.call(t).slice(8,-1)}function i1(t){return bGe(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function gne(t,e){const n={...t};return i1(t)&&i1(e)&&Object.keys(e).forEach(r=>{i1(e[r])&&i1(t[r])?n[r]=gne(t[r],e[r]):n[r]=e[r]}),n}var BL=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:()=>gne(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}},Hh=class xne extends BL{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new xne(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 yGe(t){return typeof t=="number"}var vGe=class{constructor(t){this.find=t.find,this.handler=t.handler}},wGe=(t,e,n)=>{if(RL(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const a=[i.text];return a.index=i.index,a.input=t,a.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),a.push(i.replaceWith)),a}):[]};function _Ge(t){const{editor:e,state:n,from:r,to:i,rule:a,pasteEvent:o,dropEvent:l}=t,{commands:c,chain:u,can:d}=new P2({editor:e,state:n}),f=[];return n.doc.nodesBetween(r,i,(m,x)=>{var b,v,y,S,k;if((v=(b=m.type)==null?void 0:b.spec)!=null&&v.code||!(m.isText||m.isTextblock||m.isInline))return;const T=(k=(S=(y=m.content)==null?void 0:y.size)!=null?S:m.nodeSize)!=null?k:0,M=Math.max(r,x),C=Math.min(i,x+T);if(M>=C)return;const E=m.isText?m.text||"":m.textBetween(M-x,C-x,void 0,"");wGe(E,a.find,o).forEach(A=>{if(A.index===void 0)return;const D=M+A.index+1,I=D+A[0].length,F={from:n.tr.mapping.map(D),to:n.tr.mapping.map(I)},z=a.handler({state:n,range:F,match:A,commands:c,chain:u,can:d,pasteEvent:o,dropEvent:l});f.push(z)})}),f.every(m=>m!==null)}var a1=null,SGe=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function NGe(t){const{editor:e,rules:n}=t;let r=null,i=!1,a=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const c=({state:d,from:f,to:p,rule:m,pasteEvt:x})=>{const b=d.tr,v=C2({state:d,transaction:b});if(!(!_Ge({editor:e,state:v,from:Math.max(f-1,0),to:p.b-1,rule:m,pasteEvent:x,dropEvent:l})||!b.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,b}};return n.map(d=>new di({view(f){const p=x=>{var b;r=(b=f.dom.parentElement)!=null&&b.contains(x.target)?f.dom.parentElement:null,r&&(a1=e)},m=()=>{a1&&(a1=null)};return window.addEventListener("dragstart",p),window.addEventListener("dragend",m),{destroy(){window.removeEventListener("dragstart",p),window.removeEventListener("dragend",m)}}},props:{handleDOMEvents:{drop:(f,p)=>{if(a=r===f.dom.parentElement,l=p,!a){const m=a1;m?.isEditable&&setTimeout(()=>{const x=m.state.selection;x&&m.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(f,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:(f,p,m)=>{const x=f[0],b=x.getMeta("uiEvent")==="paste"&&!i,v=x.getMeta("uiEvent")==="drop"&&!a,y=x.getMeta("applyPasteRules"),S=!!y;if(!b&&!v&&!S)return;if(S){let{text:M}=y;typeof M=="string"?M=M:M=IL(kt.from(M),m.schema);const{from:C}=y,E=C+M.length,R=SGe(M);return c({rule:d,state:m,from:C,to:{b:E},pasteEvt:R})}const k=p.doc.content.findDiffStart(m.doc.content),T=p.doc.content.findDiffEnd(m.doc.content);if(!(!yGe(k)||!T||k===T.b))return c({rule:d,state:m,from:k,to:T,pasteEvt:o})}}))}var L2=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=une(t),this.schema=FVe(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:MP(e.name,this.schema)},r=Xt(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return UL([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:MP(r.name,this.schema)},a=[],o=Xt(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&Xt(r,"exitable",i)&&(l.ArrowRight=()=>Hh.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=z$e(l);a.push(c);const u=Xt(r,"addInputRules",i);if(I9(r,t.options.enableInputRules)&&u){const p=u();if(p&&p.length){const m=xGe({editor:t,rules:p}),x=Array.isArray(m)?m:[m];a.push(...x)}}const d=Xt(r,"addPasteRules",i);if(I9(r,t.options.enablePasteRules)&&d){const p=d();if(p&&p.length){const m=NGe({editor:t,rules:p});a.push(...m)}}const f=Xt(r,"addProseMirrorPlugins",i);if(f){const p=f();a.push(...p)}return a})}get attributes(){return cne(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=dx(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:qi(n.name,this.schema)},a=Xt(n,"addNodeView",i);if(!a)return[];const o=a();if(!o)return[];const l=(c,u,d,f,p)=>{const m=vN(c,r);return o({node:c,view:u,getPos:d,decorations:f,innerDecorations:p,editor:t,extension:n,HTMLAttributes:m})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=dx(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:Yu(n.name,this.schema)},a=Xt(n,"addMarkView",i);if(!a)return[];const o=(l,c,u)=>{const d=vN(l,r);return a()({mark:l,view:c,inline:u,editor:t,extension:n,HTMLAttributes:d,updateAttributes:f=>{UGe(l,t,f)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:MP(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),a=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),f=Xt(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),a&&this.editor.on("create",a),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),f&&this.editor.on("destroy",f)})}};L2.resolve=une;L2.sort=UL;L2.flatten=FL;var MGe={};DL(MGe,{ClipboardTextSerializer:()=>yne,Commands:()=>vne,Delete:()=>wne,Drop:()=>_ne,Editable:()=>Sne,FocusEvents:()=>Mne,Keymap:()=>kne,Paste:()=>Ene,Tabindex:()=>Tne,TextDirection:()=>Ane,focusEventsPluginKey:()=>Nne});var Pr=class bne extends BL{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new bne(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},yne=Pr.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new di({key:new la("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,o=Math.min(...a.map(d=>d.$from.pos)),l=Math.max(...a.map(d=>d.$to.pos)),c=hne(n);return dne(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:c})}}})]}}),vne=Pr.create({name:"commands",addCommands(){return{...ene}}}),wne=Pr.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const a=()=>{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=one(t.before,[t,...e]);mne(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,b)=>{const v=b+x.nodeSize-2,y=m.oldRange.from<=b&&v<=m.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:b,to:v,newFrom:d.mapping.map(b),newTo:d.mapping.map(v),deletedRange:m.oldRange,newRange:m.newRange,partial:!y,editor:this.editor,transaction:t,combinedTransform:d})})});const p=d.mapping;d.steps.forEach((m,x)=>{var b,v;if(m instanceof Rl){const y=p.slice(x).map(m.from,-1),S=p.slice(x).map(m.to),k=p.invert().map(y,-1),T=p.invert().map(S),M=(b=d.doc.nodeAt(y-1))==null?void 0:b.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:k,to:T},newRange:{from:y,to:S},partial:!!(C||M),editor:this.editor,transaction:t,combinedTransform:d})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(a,0):a()}}),_ne=Pr.create({name:"drop",addProseMirrorPlugins(){return[new di({key:new la("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Sne=Pr.create({name:"editable",addProseMirrorPlugins(){return[new di({key:new la("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Nne=new la("focusEvents"),Mne=Pr.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new di({key:Nne,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}}}})]}}),kne=Pr.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:c,doc:u}=l,{empty:d,$anchor:f}=c,{pos:p,parent:m}=f,x=f.parent.isTextblock&&p>0?l.doc.resolve(p-1):f,b=x.parent.type.spec.isolating,v=f.pos-f.parentOffset,y=b&&x.parent.childCount===1?v===f.pos:Pn.atStart(u).from===p;return!d||!m.type.isTextblock||m.textContent.length||!y||y&&f.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},a={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return LL()||ane()?a:i},addProseMirrorPlugins(){return[new di({key:new la("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(b=>b.getMeta("composition")))return;const r=t.some(b=>b.docChanged)&&!e.doc.eq(n.doc),i=t.some(b=>b.getMeta("preventClearDocument"));if(!r||i)return;const{empty:a,from:o,to:l}=e.selection,c=Pn.atStart(e.doc).from,u=Pn.atEnd(e.doc).to;if(a||!(o===c&&l===u)||!R2(n.doc))return;const p=n.tr,m=C2({state:n,transaction:p}),{commands:x}=new P2({editor:this.editor,state:m});if(x.clearNodes(),!!p.steps.length)return p}})]}}),Ene=Pr.create({name:"paste",addProseMirrorPlugins(){return[new di({key:new la("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Tne=Pr.create({name:"tabindex",addProseMirrorPlugins(){return[new di({key:new la("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Ane=Pr.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=dx(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 la("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),kGe=class ug{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 ug(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 ug(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 ug(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,a=n.isAtom&&!n.isText,o=this.pos+r+(a?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 ug(l,this.editor,i,i?n:null);i&&(c.actualDepth=this.depth+1),e.push(new ug(l,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const a=i.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const c=o[l];if(a[c]!==n[c])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const a=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&a.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)}},EGe=`.ProseMirror {
- position: relative;
- }
- .ProseMirror {
- word-wrap: break-word;
- white-space: pre-wrap;
- white-space: break-spaces;
- -webkit-font-variant-ligatures: none;
- font-variant-ligatures: none;
- font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
- }
- .ProseMirror [contenteditable="false"] {
- white-space: normal;
- }
- .ProseMirror [contenteditable="false"] [contenteditable="true"] {
- white-space: pre-wrap;
- }
- .ProseMirror pre {
- white-space: pre-wrap;
- }
- img.ProseMirror-separator {
- display: inline !important;
- border: none !important;
- margin: 0 !important;
- width: 0 !important;
- height: 0 !important;
- }
- .ProseMirror-gapcursor {
- display: none;
- pointer-events: none;
- position: absolute;
- margin: 0;
- }
- .ProseMirror-gapcursor:after {
- content: "";
- display: block;
- position: absolute;
- top: -2px;
- width: 20px;
- border-top: 1px solid black;
- animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
- }
- @keyframes ProseMirror-cursor-blink {
- to {
- visibility: hidden;
- }
- }
- .ProseMirror-hideselection *::selection {
- background: transparent;
- }
- .ProseMirror-hideselection *::-moz-selection {
- background: transparent;
- }
- .ProseMirror-hideselection * {
- caret-color: transparent;
- }
- .ProseMirror-focused .ProseMirror-gapcursor {
- display: block;
- }`;function TGe(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 AGe=class extends pGe{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:r,slice:i,moved:a})=>this.options.onDrop(r,i,a)),this.on("paste",({event:r,slice:i})=>this.options.onPaste(r,i)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=rne(e,this.options.autofocus);this.editorState=vg.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=TGe(EGe,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=lne(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(i=>{const a=typeof i=="string"?`${i}$`:i.key;n=n.filter(o=>!o.key.startsWith(a))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[Sne,yne.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),vne,Mne,kne,Tne,_ne,Ene,wne,Ane.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 L2(r,this)}createCommandManager(){this.commandManager=new P2({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=$D(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=$D(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){var e;this.editorView=new Zte(t,{...this.options.editorProps,attributes:{role:"textbox",...(e=this.options.editorProps)==null?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.prependClass(),this.injectCSS();const r=this.view.dom;r.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),a=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const 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)||a.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return fne(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return GVe(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return IL(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
- `,textSerializers:n={}}=t||{};return UVe(this.state.doc,{blockSeparator:e,textSerializers:{...hne(this.schema),...n}})}get isEmpty(){return R2(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 kGe(e,this)}get $doc(){return this.$pos(0)}};function hx(t){return new O2({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:a}=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(zL(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(b=>b===t.type&&b!==m.mark.type)).filter(m=>m.to>u).length)return null;d<n.to&&a.delete(d,n.to),u>n.from&&a.delete(n.from+c,u);const p=n.from+c+o.length;a.addMark(n.from+c,p,t.type.create(i||{})),a.removeStoredMark(t.type)}},undoable:t.undoable})}function Cne(t){return new O2({find:t.find,handler:({state:e,range:n,match:r})=>{const i=xr(t.getAttributes,void 0,r)||{},{tr:a}=e,o=n.from;let l=n.to;const c=t.type.create(i);if(r[1]){const u=r[0].lastIndexOf(r[1]);let d=o+u;d>l?d=l:l=d+r[1].length;const f=r[0][r[0].length-1];a.insertText(f,o+r[0].length-1),a.replaceWith(d,l,c)}else if(r[0]){const u=t.type.isInline?o:o-1;a.insert(u,t.type.create(i)).delete(a.mapping.map(o),a.mapping.map(l))}a.scrollIntoView()},undoable:t.undoable})}function GD(t){return new O2({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),a=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,a)},undoable:t.undoable})}function fx(t){return new O2({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const a=xr(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),c=o.doc.resolve(n.from).blockRange(),u=c&&xL(c,t.type,a);if(!u)return null;if(o.wrap(c,u),t.keepMarks&&t.editor){const{selection:f,storedMarks:p}=e,{splittableMarks:m}=t.editor.extensionManager,x=p||f.$to.parentOffset&&f.$from.marks();if(x){const b=x.filter(v=>m.includes(v.type.name));o.ensureMarks(b)}}if(t.keepAttributes){const f=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(f,a).run()}const d=o.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&zh(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var CGe=t=>"touches"in t,PGe=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,a;this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(a=t.options)!=null&&a.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",t.style.justifyContent="flex-start",t.style.alignItems="flex-start",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),i=e.includes("left"),a=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),a&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{const e=this.createHandle(t);this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.wrapper.appendChild(e)})}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,CGe(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:i}=this.calculateNewDimensions(this.activeHandle,t,e),a=this.applyConstraints(r,i,n);this.element.style.width=`${a.width}px`,this.element.style.height=`${a.height}px`,this.onResize&&this.onResize(a.width,a.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const a=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),c=t.includes("top");return a?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+(a?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,a,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),(a=this.maxSize)!=null&&a.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 jGe(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Qt){const a=r.index();return r.parent.canReplaceWith(a,a+1,e)}let i=r.depth;for(;i>=0;){const a=r.index(i);if(r.node(i).contentMatchAt(a).matchType(e))return!0;i-=1}return!1}var DGe={};DL(DGe,{createAtomBlockMarkdownSpec:()=>RGe,createBlockMarkdownSpec:()=>OGe,createInlineMarkdownSpec:()=>IGe,parseAttributes:()=>HL,parseIndentedBlocks:()=>qD,renderNestedMarkdownContent:()=>VL,serializeAttributes:()=>$L});function HL(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,u=>(n.push(u),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(i){const u=i.map(d=>d.trim().slice(1));e.class=u.join(" ")}const a=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);a&&(e.id=a[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,u,d])=>{var f;const p=parseInt(((f=d.match(/__QUOTED_(\d+)__/))==null?void 0:f[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 $L(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 RGe(t){const{nodeName:e,name:n,parseAttributes:r=HL,serializeAttributes:i=$L,defaultAttributes:a={},requiredAttributes:o=[],allowedAttributes:l}=t,c=n||e,u=d=>{if(!l)return d;const f={};return l.forEach(p=>{p in d&&(f[p]=d[p])}),f};return{parseMarkdown:(d,f)=>{const p={...a,...d.attributes};return f.createNode(e,p,[])},markdownTokenizer:{name:e,level:"block",start(d){var f;const p=new RegExp(`^:::${c}(?:\\s|$)`,"m"),m=(f=d.match(p))==null?void 0:f.index;return m!==void 0?m:-1},tokenize(d,f,p){const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=d.match(m);if(!x)return;const b=x[1]||"",v=r(b);if(!o.find(S=>!(S in v)))return{type:e,raw:x[0],attributes:v}}},renderMarkdown:d=>{const f=u(d.attrs||{}),p=i(f),m=p?` {${p}}`:"";return`:::${c}${m} :::`}}}function OGe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=HL,serializeAttributes:a=$L,defaultAttributes:o={},content:l="block",allowedAttributes:c}=t,u=n||e,d=f=>{if(!c)return f;const p={};return c.forEach(m=>{m in f&&(p[m]=f[m])}),p};return{parseMarkdown:(f,p)=>{let m;if(r){const b=r(f);m=typeof b=="string"?[{type:"text",text:b}]:b}else l==="block"?m=p.parseChildren(f.tokens||[]):m=p.parseInline(f.tokens||[]);const x={...o,...f.attributes};return p.createNode(e,x,m)},markdownTokenizer:{name:e,level:"block",start(f){var p;const m=new RegExp(`^:::${u}`,"m"),x=(p=f.match(m))==null?void 0:p.index;return x!==void 0?x:-1},tokenize(f,p,m){var x;const b=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),v=f.match(b);if(!v)return;const[y,S=""]=v,k=i(S);let T=1;const M=y.length;let C="";const E=/^:::([\w-]*)(\s.*)?/gm,R=f.slice(M);for(E.lastIndex=0;;){const A=E.exec(R);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 F=R.slice(0,D);C=F.trim();const z=f.slice(0,M+D+A[0].length);let P=[];if(C)if(l==="block")for(P=m.blockTokens(F),P.forEach($=>{$.text&&(!$.tokens||$.tokens.length===0)&&($.tokens=m.inlineTokens($.text))});P.length>0;){const $=P[P.length-1];if($.type==="paragraph"&&(!$.text||$.text.trim()===""))P.pop();else break}else P=m.inlineTokens(C);return{type:e,raw:z,attributes:k,content:C,tokens:P}}}}}},renderMarkdown:(f,p)=>{const m=d(f.attrs||{}),x=a(m),b=x?` {${x}}`:"",v=p.renderChildren(f.content||[],`
- `);return`:::${u}${b}
- ${v}
- :::`}}}function LGe(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,a,o]=r;e[i]=a||o,r=n.exec(t)}return e}function FGe(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function IGe(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=LGe,serializeAttributes:a=FGe,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},f=u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(p,m)=>{const x={...o,...p.attributes};if(l)return m.createNode(e,x);const b=r?r(p):p.content||"";return b?m.createNode(e,x,[m.createTextNode(b)]):m.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(p){const m=l?new RegExp(`\\[${f}\\s*[^\\]]*\\]`):new RegExp(`\\[${f}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${f}\\]`),x=p.match(m),b=x?.index;return b!==void 0?b:-1},tokenize(p,m,x){const b=l?new RegExp(`^\\[${f}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${f}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${f}\\]`),v=p.match(b);if(!v)return;let y="",S="";if(l){const[,T]=v;S=T}else{const[,T,M]=v;S=T,y=M||""}const k=i(S.trim());return{type:e,raw:v[0],content:y.trim(),attributes:k}}},renderMarkdown:p=>{let m="";r?m=r(p):p.content&&p.content.length>0&&(m=p.content.filter(y=>y.type==="text").map(y=>y.text).join(""));const x=d(p.attrs||{}),b=a(x),v=b?` ${b}`:"";return l?`[${u}${v}]`:`[${u}${v}]${m}[/${u}]`}}}function qD(t,e,n){var r,i,a,o;const l=t.split(`
- `),c=[];let u="",d=0;const f=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}
- `;continue}else return}const x=e.extractItemData(m),{indentLevel:b,mainContent:v}=x;u=`${u}${p}
- `;const y=[v];for(d+=1;d<l.length;){const M=l[d];if(M.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)>b){y.push(M),u=`${u}${M}
- `,d+=1;continue}else break}if((((o=(a=M.match(/^(\s*)/))==null?void 0:a[1])==null?void 0:o.length)||0)>b)y.push(M),u=`${u}${M}
- `,d+=1;else break}let S;const k=y.slice(1);if(k.length>0){const M=k.map(C=>C.slice(b+f)).join(`
- `);M.trim()&&(e.customNestedParser?S=e.customNestedParser(M):S=n.blockTokens(M))}const T=e.createToken(x,S);c.push(T)}if(c.length!==0)return{items:c,raw:u}}function VL(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[a,...o]=t.content,l=e.renderChildren([a]),c=[`${i}${l}`];return o&&o.length>0&&o.forEach(u=>{const d=e.renderChildren([u]);if(d){const f=d.split(`
- `).map(p=>p?e.indent(p):"").join(`
- `);c.push(f)}}),c.join(`
- `)}function UGe(t,e,n={}){const{state:r}=e,{doc:i,tr:a}=r,o=t;i.descendants((l,c)=>{const u=a.mapping.map(c),d=a.mapping.map(c)+l.nodeSize;let f=null;if(l.marks.forEach(m=>{if(m!==o)return!1;f=m}),!f)return;let p=!1;if(Object.keys(n).forEach(m=>{n[m]!==f.attrs[m]&&(p=!0)}),p){const m=t.type.create({...t.attrs,...n});a.removeMark(u,d,t.type),a.addMark(u,d,m)}}),a.docChanged&&e.view.dispatch(a)}var Vs=class Pne extends BL{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Pne(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Mm(t){return new vGe({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const a=xr(t.getAttributes,void 0,r,i);if(a===!1||a===null)return null;const{tr:o}=e,l=r[r.length-1],c=r[0];let u=n.to;if(l){const d=c.search(/\S/),f=n.from+c.indexOf(l),p=f+l.length;if(zL(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>f).length)return null;p<n.to&&o.delete(p,n.to),f>n.from&&o.delete(n.from+d,f),u=n.from+d+l.length,o.addMark(n.from+d,u,t.type.create(a||{})),o.removeStoredMark(t.type)}}})}var TP,B9;function zGe(){return B9||(B9=1,TP=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!t(e[i],n[i]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;for(i of e.entries())if(!t(i[1],n.get(i[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(i of e.entries())if(!n.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(i=r;i--!==0;)if(e[i]!==n[i])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(a=Object.keys(e),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!(o==="_owner"&&e.$$typeof)&&!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),TP}var BGe=zGe();const HGe=hl(BGe);var $Ge=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},VGe=({contentComponent:t})=>{const e=fR.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return s.jsx(s.Fragment,{children:Object.values(e)})};function GGe(){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]:kle.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 qGe=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=GGe(),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 s.jsxs(s.Fragment,{children:[s.jsx("div",{ref:$Ge(e,this.editorContentRef),...n}),t?.contentComponent&&s.jsx(VGe,{contentComponent:t.contentComponent})]})}},WGe=_.forwardRef((t,e)=>{const n=ei.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return ei.createElement(qGe,{key:n,innerRef:e,...t})}),KGe=ei.memo(WGe),XGe=typeof window<"u"?_.useLayoutEffect:_.useEffect,YGe=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 QGe(t){var e;const[n]=_.useState(()=>new YGe(t.editor)),r=wK.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:HGe);return XGe(()=>n.watch(t.editor),[t.editor,n]),_.useDebugValue(r),r}var ZGe=!1,WD=typeof window>"u",JGe=WD||!!(typeof window<"u"&&window.next),e7e=class jne{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?WD||JGe?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onBeforeCreate)==null?void 0:a.call(i,...r)},onBlur:(...r)=>{var i,a;return(a=(i=this.options.current).onBlur)==null?void 0:a.call(i,...r)},onCreate:(...r)=>{var i,a;return(a=(i=this.options.current).onCreate)==null?void 0:a.call(i,...r)},onDestroy:(...r)=>{var i,a;return(a=(i=this.options.current).onDestroy)==null?void 0:a.call(i,...r)},onFocus:(...r)=>{var i,a;return(a=(i=this.options.current).onFocus)==null?void 0:a.call(i,...r)},onSelectionUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onSelectionUpdate)==null?void 0:a.call(i,...r)},onTransaction:(...r)=>{var i,a;return(a=(i=this.options.current).onTransaction)==null?void 0:a.call(i,...r)},onUpdate:(...r)=>{var i,a;return(a=(i=this.options.current).onUpdate)==null?void 0:a.call(i,...r)},onContentError:(...r)=>{var i,a;return(a=(i=this.options.current).onContentError)==null?void 0:a.call(i,...r)},onDrop:(...r)=>{var i,a;return(a=(i=this.options.current).onDrop)==null?void 0:a.call(i,...r)},onPaste:(...r)=>{var i,a;return(a=(i=this.options.current).onPaste)==null?void 0:a.call(i,...r)},onDelete:(...r)=>{var i,a;return(a=(i=this.options.current).onDelete)==null?void 0:a.call(i,...r)}};return new AGe(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((i,a)=>{var o;return i===((o=n.extensions)==null?void 0:o[a])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?jne.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 t7e(t={},e=[]){const n=_.useRef(t);n.current=t;const[r]=_.useState(()=>new e7e(n)),i=fR.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return _.useDebugValue(i),_.useEffect(r.onRender(e)),QGe({editor:i,selector:({transactionNumber:a})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&a===0?0:a+1}),i}var n7e=_.createContext({editor:null});n7e.Consumer;var r7e=_.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),i7e=()=>_.useContext(r7e);ei.forwardRef((t,e)=>{const{onDragStart:n}=i7e(),r=t.as||"div";return s.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});ei.createContext({markViewContentRef:()=>{}});var wN=(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]},a7e=/^\s*>\s$/,s7e=Vs.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return wN("blockquote",{..._i(this.options.HTMLAttributes,t),children:wN("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(i=>{const l=e.renderChildren([i]).split(`
- `).map(c=>c.trim()===""?n:`${n} ${c}`);r.push(l.join(`
- `))}),r.join(`
- ${n}
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[fx({find:a7e,type:this.type})]}}),o7e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,l7e=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,c7e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,u7e=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,d7e=Hh.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 wN("strong",{..._i(this.options.HTMLAttributes,t),children:wN("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[hx({find:o7e,type:this.type}),hx({find:c7e,type:this.type})]},addPasteRules(){return[Mm({find:l7e,type:this.type}),Mm({find:u7e,type:this.type})]}}),h7e=/(^|[^`])`([^`]+)`(?!`)$/,f7e=/(^|[^`])`([^`]+)`(?!`)/g,m7e=Hh.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[hx({find:h7e,type:this.type})]},addPasteRules(){return[Mm({find:f7e,type:this.type})]}}),AP=4,p7e=/^```([a-z]+)?[\s\n]$/,g7e=/^~~~([a-z]+)?[\s\n]$/,x7e=Vs.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:AP,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const a=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return a||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(`
- `):r=`\`\`\`${i}
- \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:AP,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;if(a.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,`
- `,`
- `).split(`
- `).map(x=>l+x).join(`
- `);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:AP,{state:r}=t,{selection:i}=r,{$from:a,empty:o}=i;return a.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var c;const{pos:u}=a,d=a.start(),f=a.end(),m=r.doc.textBetween(d,f,`
- `,`
- `).split(`
- `);let x=0,b=0;const v=u-d;for(let C=0;C<m.length;C+=1){if(b+m[C].length>=v){x=C;break}b+=m[C].length+1}const S=((c=m[x].match(/^ */))==null?void 0:c[0])||"",k=Math.min(S.length,n);if(k===0)return!0;let T=d;for(let C=0;C<x;C+=1)T+=m[C].length+1;return l.delete(T,T+k),u-T<=k&&l.setSelection(pn.create(l.doc,T)),!0}):t.commands.command(({tr:l})=>{const{from:c,to:u}=i,p=r.doc.textBetween(c,u,`
- `,`
- `).split(`
- `).map(m=>{var x;const b=((x=m.match(/^ */))==null?void 0:x[0])||"",v=Math.min(b.length,n);return m.slice(v)}).join(`
- `);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 a=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
- `);return!a||!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:a}=n;if(!a||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const l=i.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:u})=>(u.setSelection(Pn.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[GD({find:p7e,type:this.type,getAttributes:t=>({language:t[1]})}),GD({find:g7e,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new di({key:new la("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,a=i?.mode;if(!n||!a)return!1;const{tr:o,schema:l}=t.state,c=l.text(n.replace(/\r\n?/g,`
- `));return o.replaceSelectionWith(this.type.create({language:a},c)),o.selection.$from.parent.type!==this.type&&o.setSelection(pn.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),b7e=Vs.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):""}),y7e=Vs.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`
- `},renderMarkdown:()=>`
- `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:a}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,c=a||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:u,dispatch:d})=>{if(d&&c&&o){const f=c.filter(p=>l.includes(p.type.name));u.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),v7e=Vs.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=>GD({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),w7e=Vs.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(!jGe(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return pne(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:a,tr:o,dispatch:l})=>{if(l){const{$to:c}=o.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?o.setSelection(pn.create(o.doc,c.pos+1)):c.nodeAfter.isBlock?o.setSelection(Qt.create(o.doc,c.pos)):o.setSelection(pn.create(o.doc,c.pos));else{const d=a.schema.nodes[this.options.nextNodeType]||c.parent.type.contentMatch.defaultType,f=d?.create();f&&(o.insert(u,f),o.setSelection(pn.create(o.doc,u+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Cne({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),_7e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,S7e=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,N7e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,M7e=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,k7e=Hh.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[hx({find:_7e,type:this.type}),hx({find:N7e,type:this.type})]},addPasteRules(){return[Mm({find:S7e,type:this.type}),Mm({find:M7e,type:this.type})]}});const E7e="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",T7e="ελ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",KD="numeric",XD="ascii",YD="alpha",P0="asciinumeric",m0="alphanumeric",QD="domain",Dne="emoji",A7e="scheme",C7e="slashscheme",CP="whitespace";function P7e(t,e){return t in e||(e[t]=[]),e[t]}function Uf(t,e,n){e[KD]&&(e[P0]=!0,e[m0]=!0),e[XD]&&(e[P0]=!0,e[YD]=!0),e[P0]&&(e[m0]=!0),e[YD]&&(e[m0]=!0),e[m0]&&(e[QD]=!0),e[Dne]&&(e[QD]=!0);for(const r in e){const i=P7e(r,n);i.indexOf(t)<0&&i.push(t)}}function j7e(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Os(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Os.groups={};Os.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],a=e.jr[r][1];if(a&&i.test(t))return a}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||Os.groups;let i;return e&&e.j?i=e:(i=new Os(e),n&&r&&Uf(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const a=t.length;if(!a)return i;for(let o=0;o<a-1;o++)i=i.tt(t[o]);return i.tt(t[a-1],e,n,r)},tt(t,e,n,r){r=r||Os.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const a=e;let o,l=i.go(t);if(l?(o=new Os,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Os,a){if(r)if(o.t&&typeof o.t=="string"){const c=Object.assign(j7e(o.t,r),n);Uf(a,c,r)}else n&&Uf(a,n,r);o.t=a}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),H9=(t,e,n,r,i)=>t.ts(e,n,r,i),Ct=(t,e,n,r,i)=>t.tt(e,n,r,i),uu="WORD",ZD="UWORD",Rne="ASCIINUMERICAL",One="ALPHANUMERICAL",Ay="LOCALHOST",JD="TLD",eR="UTLD",F1="SCHEME",dg="SLASH_SCHEME",GL="NUM",tR="WS",qL="NL",j0="OPENBRACE",D0="CLOSEBRACE",_N="OPENBRACKET",SN="CLOSEBRACKET",NN="OPENPAREN",MN="CLOSEPAREN",kN="OPENANGLEBRACKET",EN="CLOSEANGLEBRACKET",TN="FULLWIDTHLEFTPAREN",AN="FULLWIDTHRIGHTPAREN",CN="LEFTCORNERBRACKET",PN="RIGHTCORNERBRACKET",jN="LEFTWHITECORNERBRACKET",DN="RIGHTWHITECORNERBRACKET",RN="FULLWIDTHLESSTHAN",ON="FULLWIDTHGREATERTHAN",LN="AMPERSAND",FN="APOSTROPHE",IN="ASTERISK",Vd="AT",UN="BACKSLASH",zN="BACKTICK",BN="CARET",Yd="COLON",WL="COMMA",HN="DOLLAR",Jl="DOT",$N="EQUALS",KL="EXCLAMATION",Bo="HYPHEN",R0="PERCENT",VN="PIPE",GN="PLUS",qN="POUND",O0="QUERY",XL="QUOTE",Lne="FULLWIDTHMIDDLEDOT",YL="SEMI",ec="SLASH",L0="TILDE",WN="UNDERSCORE",Fne="EMOJI",KN="SYM";var Ine=Object.freeze({__proto__:null,ALPHANUMERICAL:One,AMPERSAND:LN,APOSTROPHE:FN,ASCIINUMERICAL:Rne,ASTERISK:IN,AT:Vd,BACKSLASH:UN,BACKTICK:zN,CARET:BN,CLOSEANGLEBRACKET:EN,CLOSEBRACE:D0,CLOSEBRACKET:SN,CLOSEPAREN:MN,COLON:Yd,COMMA:WL,DOLLAR:HN,DOT:Jl,EMOJI:Fne,EQUALS:$N,EXCLAMATION:KL,FULLWIDTHGREATERTHAN:ON,FULLWIDTHLEFTPAREN:TN,FULLWIDTHLESSTHAN:RN,FULLWIDTHMIDDLEDOT:Lne,FULLWIDTHRIGHTPAREN:AN,HYPHEN:Bo,LEFTCORNERBRACKET:CN,LEFTWHITECORNERBRACKET:jN,LOCALHOST:Ay,NL:qL,NUM:GL,OPENANGLEBRACKET:kN,OPENBRACE:j0,OPENBRACKET:_N,OPENPAREN:NN,PERCENT:R0,PIPE:VN,PLUS:GN,POUND:qN,QUERY:O0,QUOTE:XL,RIGHTCORNERBRACKET:PN,RIGHTWHITECORNERBRACKET:DN,SCHEME:F1,SEMI:YL,SLASH:ec,SLASH_SCHEME:dg,SYM:KN,TILDE:L0,TLD:JD,UNDERSCORE:WN,UTLD:eR,UWORD:ZD,WORD:uu,WS:tR});const au=/[a-z]/,e0=new RegExp("\\p{L}","u"),PP=new RegExp("\\p{Emoji}","u"),su=/\d/,jP=/\s/,$9="\r",DP=`
- `,D7e="️",R7e="",RP="";let s1=null,o1=null;function O7e(t=[]){const e={};Os.groups=e;const n=new Os;s1==null&&(s1=V9(E7e)),o1==null&&(o1=V9(T7e)),Ct(n,"'",FN),Ct(n,"{",j0),Ct(n,"}",D0),Ct(n,"[",_N),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,"」",PN),Ct(n,"『",jN),Ct(n,"』",DN),Ct(n,"<",RN),Ct(n,">",ON),Ct(n,"&",LN),Ct(n,"*",IN),Ct(n,"@",Vd),Ct(n,"`",zN),Ct(n,"^",BN),Ct(n,":",Yd),Ct(n,",",WL),Ct(n,"$",HN),Ct(n,".",Jl),Ct(n,"=",$N),Ct(n,"!",KL),Ct(n,"-",Bo),Ct(n,"%",R0),Ct(n,"|",VN),Ct(n,"+",GN),Ct(n,"#",qN),Ct(n,"?",O0),Ct(n,'"',XL),Ct(n,"/",ec),Ct(n,";",YL),Ct(n,"~",L0),Ct(n,"_",WN),Ct(n,"\\",UN),Ct(n,"・",Lne);const r=pi(n,su,GL,{[KD]:!0});pi(r,su,r);const i=pi(r,au,Rne,{[P0]:!0}),a=pi(r,e0,One,{[m0]:!0}),o=pi(n,au,uu,{[XD]:!0});pi(o,su,i),pi(o,au,o),pi(i,su,i),pi(i,au,i);const l=pi(n,e0,ZD,{[YD]:!0});pi(l,au),pi(l,su,a),pi(l,e0,l),pi(a,su,a),pi(a,au),pi(a,e0,a);const c=Ct(n,DP,qL,{[CP]:!0}),u=Ct(n,$9,tR,{[CP]:!0}),d=pi(n,jP,tR,{[CP]:!0});Ct(n,RP,d),Ct(u,DP,c),Ct(u,RP,d),pi(u,jP,d),Ct(d,$9),Ct(d,DP),pi(d,jP,d),Ct(d,RP,d);const f=pi(n,PP,Fne,{[Dne]:!0});Ct(f,"#"),pi(f,PP,f),Ct(f,D7e,f);const p=Ct(f,R7e);Ct(p,"#"),pi(p,PP,f);const m=[[au,o],[su,i]],x=[[au,null],[e0,l],[su,a]];for(let b=0;b<s1.length;b++)Ld(n,s1[b],JD,uu,m);for(let b=0;b<o1.length;b++)Ld(n,o1[b],eR,ZD,x);Uf(JD,{tld:!0,ascii:!0},e),Uf(eR,{utld:!0,alpha:!0},e),Ld(n,"file",F1,uu,m),Ld(n,"mailto",F1,uu,m),Ld(n,"http",dg,uu,m),Ld(n,"https",dg,uu,m),Ld(n,"ftp",dg,uu,m),Ld(n,"ftps",dg,uu,m),Uf(F1,{scheme:!0,ascii:!0},e),Uf(dg,{slashscheme:!0,ascii:!0},e),t=t.sort((b,v)=>b[0]>v[0]?1:-1);for(let b=0;b<t.length;b++){const v=t[b][0],S=t[b][1]?{[A7e]:!0}:{[C7e]:!0};v.indexOf("-")>=0?S[QD]=!0:au.test(v)?su.test(v)?S[P0]=!0:S[XD]=!0:S[KD]=!0,H9(n,v,v,S)}return H9(n,"localhost",Ay,{ascii:!0}),n.jd=new Os(KN),{start:n,tokens:Object.assign({groups:e},Ine)}}function Une(t,e){const n=L7e(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let a=0,o=0;for(;o<r;){let l=t,c=null,u=0,d=null,f=-1,p=-1;for(;o<r&&(c=l.go(n[o]));)l=c,l.accepts()?(f=0,p=0,d=l):f>=0&&(f+=n[o].length,p++),u+=n[o].length,a+=n[o].length,o++;a-=f,o-=p,u-=f,i.push({t:d.t,v:e.slice(a-u,a),s:a-u,e:a})}return i}function L7e(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),a,o=i<55296||i>56319||r+1===n||(a=t.charCodeAt(r+1))<56320||a>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Ld(t,e,n,r,i){let a;const o=e.length;for(let l=0;l<o-1;l++){const c=e[l];t.j[c]?a=t.j[c]:(a=new Os(r),a.jr=i.slice(),t.j[c]=a),t=a}return a=new Os(n),a.jr=i.slice(),t.j[e[o-1]]=a,a}function V9(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let a=0;for(;i.indexOf(t[r+a])>=0;)a++;if(a>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+a),10);o>0;o--)n.pop();r+=a}else n.push(t[r]),r++}return e}const Cy={defaultProtocol:"http",events:null,format:G9,formatHref:G9,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function QL(t,e=null){let n=Object.assign({},Cy);t&&(n=Object.assign(n,t instanceof QL?t.o:t));const r=n.ignoreTags,i=[];for(let a=0;a<r.length;a++)i.push(r[a].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}QL.prototype={o:Cy,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]:Cy[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 G9(t){return t}function zne(t,e){this.t="token",this.v=t,this.tk=e}zne.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=Cy.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),a=this.toFormattedString(t),o={},l=t.get("className",n,e),c=t.get("target",n,e),u=t.get("rel",n,e),d=t.getObj("attributes",n,e),f=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),c&&(o.target=c),u&&(o.rel=u),d&&Object.assign(o,d),{tagName:i,attributes:o,content:a,eventListeners:f}}};function F2(t,e){class n extends zne{constructor(i,a){super(i,a),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const q9=F2("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),W9=F2("text"),F7e=F2("nl"),l1=F2("url",{isLink:!0,toHref(t=Cy.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Ay&&t[1].t===Yd}}),Io=t=>new Os(t);function I7e({groups:t}){const e=t.domain.concat([LN,IN,Vd,UN,zN,BN,HN,$N,Bo,GL,R0,VN,GN,qN,ec,KN,L0,WN]),n=[FN,Yd,WL,Jl,KL,R0,O0,XL,YL,kN,EN,j0,D0,SN,_N,NN,MN,TN,AN,CN,PN,jN,DN,RN,ON],r=[LN,FN,IN,UN,zN,BN,HN,$N,Bo,j0,D0,R0,VN,GN,qN,O0,ec,KN,L0,WN],i=Io(),a=Ct(i,L0);En(a,r,a),En(a,t.domain,a);const o=Io(),l=Io(),c=Io();En(i,t.domain,o),En(i,t.scheme,l),En(i,t.slashscheme,c),En(o,r,a),En(o,t.domain,o);const u=Ct(o,Vd);Ct(a,Vd,u),Ct(l,Vd,u),Ct(c,Vd,u);const d=Ct(a,Jl);En(d,r,a),En(d,t.domain,a);const f=Io();En(u,t.domain,f),En(f,t.domain,f);const p=Ct(f,Jl);En(p,t.domain,f);const m=Io(q9);En(p,t.tld,m),En(p,t.utld,m),Ct(u,Ay,m);const x=Ct(f,Bo);Ct(x,Bo,x),En(x,t.domain,f),En(m,t.domain,f),Ct(m,Jl,p),Ct(m,Bo,x);const b=Ct(m,Yd);En(b,t.numeric,q9);const v=Ct(o,Bo),y=Ct(o,Jl);Ct(v,Bo,v),En(v,t.domain,o),En(y,r,a),En(y,t.domain,o);const S=Io(l1);En(y,t.tld,S),En(y,t.utld,S),En(S,t.domain,o),En(S,r,a),Ct(S,Jl,y),Ct(S,Bo,v),Ct(S,Vd,u);const k=Ct(S,Yd),T=Io(l1);En(k,t.numeric,T);const M=Io(l1),C=Io();En(M,e,M),En(M,n,C),En(C,e,M),En(C,n,C),Ct(S,ec,M),Ct(T,ec,M);const E=Ct(l,Yd),R=Ct(c,Yd),A=Ct(R,ec),D=Ct(A,ec);En(l,t.domain,o),Ct(l,Jl,y),Ct(l,Bo,v),En(c,t.domain,o),Ct(c,Jl,y),Ct(c,Bo,v),En(E,t.domain,M),Ct(E,ec,M),Ct(E,O0,M),En(D,t.domain,M),En(D,e,M),Ct(D,ec,M);const I=[[j0,D0],[_N,SN],[NN,MN],[kN,EN],[TN,AN],[CN,PN],[jN,DN],[RN,ON]];for(let F=0;F<I.length;F++){const[z,P]=I[F],$=Ct(M,z);Ct(C,z,$),Ct($,P,M);const X=Io(l1);En($,e,X);const V=Io();En($,n),En(X,e,X),En(X,n,V),En(V,e,X),En(V,n,V),Ct(X,P,M),Ct(V,P,M)}return Ct(i,Ay,S),Ct(i,qL,F7e),{start:i,tokens:Ine}}function U7e(t,e,n){let r=n.length,i=0,a=[],o=[];for(;i<r;){let l=t,c=null,u=null,d=0,f=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,f=l):p>=0&&p++,i++,d++;if(p<0)i-=d,i<r&&(o.push(n[i]),i++);else{o.length>0&&(a.push(OP(W9,e,o)),o=[]),i-=p,d-=p;const m=f.t,x=n.slice(i-d,i);a.push(OP(m,e,x))}}return o.length>0&&a.push(OP(W9,e,o)),a}function OP(t,e,n){const r=n[0].s,i=n[n.length-1].e,a=e.slice(r,i);return new t(a,n)}const z7e=typeof console<"u"&&console&&console.warn||(()=>{}),B7e="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 H7e(){return Os.groups={},qr.scanner=null,qr.parser=null,qr.tokenQueue=[],qr.pluginQueue=[],qr.customSchemes=[],qr.initialized=!1,qr}function K9(t,e=!1){if(qr.initialized&&z7e(`linkifyjs: already initialized - will not register custom scheme "${t}" ${B7e}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
- 1. Must only contain digits, lowercase ASCII letters or "-"
- 2. Cannot start or end with "-"
- 3. "-" cannot repeat`);qr.customSchemes.push([t,e])}function $7e(){qr.scanner=O7e(qr.customSchemes);for(let t=0;t<qr.tokenQueue.length;t++)qr.tokenQueue[t][1]({scanner:qr.scanner});qr.parser=I7e(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 ZL(t){return qr.initialized||$7e(),U7e(qr.parser.start,t,Une(qr.scanner.start,t))}ZL.scan=Une;function Bne(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 QL(n),i=ZL(t),a=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&a.push(l.toFormattedObject(r))}return a}var JL="[\0- -\u2029 ]",V7e=new RegExp(JL),G7e=new RegExp(`${JL}$`),q7e=new RegExp(JL,"g");function W7e(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function K7e(t){return new di({key:new la("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(u=>u.docChanged)&&!n.doc.eq(r.doc),a=e.some(u=>u.getMeta("preventAutolink"));if(!i||a)return;const{tr:o}=r,l=one(n.doc,[...e]);if(mne(l).forEach(({newRange:u})=>{const d=DVe(r.doc,u,m=>m.isTextblock);let f,p;if(d.length>1)f=d[0],p=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ");else if(d.length){const m=r.doc.textBetween(u.from,u.to," "," ");if(!G7e.test(m))return;f=d[0],p=r.doc.textBetween(f.pos,u.to,void 0," ")}if(f&&p){const m=p.split(V7e).filter(Boolean);if(m.length<=0)return!1;const x=m[m.length-1],b=f.pos+p.lastIndexOf(x);if(!x)return!1;const v=ZL(x).map(y=>y.toObject(t.defaultProtocol));if(!W7e(v))return!1;v.filter(y=>y.isLink).map(y=>({...y,from:b+y.start+1,to:b+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>t.validate(y.value)).filter(y=>t.shouldAutoLink(y.value)).forEach(y=>{zL(y.from,y.to,r.doc).some(S=>S.mark.type===t.type)||o.addMark(y.from,y.to,t.type.create({href:y.href}))})}}),!!o.steps.length)return o}})}function X7e(t){return new di({key:new la("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,a;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let d=r.target;const f=[];for(;d.nodeName!=="DIV";)f.push(d),d=d.parentNode;o=f.find(p=>p.nodeName==="A")}if(!o)return!1;const l=fne(e.state,t.type.name),c=(i=o?.href)!=null?i:l.href,u=(a=o?.target)!=null?a:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),o&&c?(window.open(c,u),!0):!1}}})}function Y7e(t){return new di({key:new la("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:a}=e,{selection:o}=a,{empty:l}=o;if(l)return!1;let c="";r.content.forEach(d=>{c+=d.textContent});const u=Bne(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 bf(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(q7e,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Hne=Hh.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"){K9(t);return}K9(t.scheme,t.optionalSlashes)})},onDestroy(){H7e()},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)=>!!bf(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=>!!bf(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=>!!bf(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=>!!bf(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=>!!bf(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[Mm({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,i=Bne(t).filter(a=>a.isLink&&this.options.isAllowedUri(a.value,{defaultValidate:o=>!!bf(o,n),protocols:n,defaultProtocol:r}));i.length&&i.forEach(a=>{this.options.shouldAutoLink(a.value)&&e.push({text:a.value,data:{href:a.href},index:a.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(K7e({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!bf(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(X7e({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(Y7e({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),Q7e=Hne,Z7e=Object.defineProperty,J7e=(t,e)=>{for(var n in e)Z7e(t,n,{get:e[n],enumerable:!0})},e9e="listItem",X9="textStyle",Y9=/^\s*([-+*])\s$/,$ne=Vs.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,`
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(e9e,this.editor.getAttributes(X9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=fx({find:Y9,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=fx({find:Y9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(X9),editor:this.editor})),[t]}}),Vne=Vs.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)=>VL(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)}}}),t9e={};J7e(t9e,{findListItemPos:()=>vv,getNextListDepth:()=>eF,handleBackspace:()=>nR,handleDelete:()=>rR,hasListBefore:()=>Gne,hasListItemAfter:()=>n9e,hasListItemBefore:()=>qne,listItemHasSubList:()=>Wne,nextListIsDeeper:()=>Kne,nextListIsHigher:()=>Xne});var vv=(t,e)=>{const{$from:n}=e.selection,r=qi(t,e.schema);let i=null,a=n.depth,o=n.pos,l=null;for(;a>0&&l===null;)i=n.node(a),i.type===r?l=a:(a-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},eF=(t,e)=>{const n=vv(t,e);if(!n)return!1;const[,r]=$Ve(e,t,n.$pos.pos+4);return r},Gne=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),a=t.doc.resolve(i).node();return!(!a||!n.includes(a.type.name))},qne=(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)},Wne=(t,e,n)=>{if(!n)return!1;const r=qi(t,e.schema);let i=!1;return n.descendants(a=>{a.type===r&&(i=!0)}),i},nR=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Dh(t.state,e)&&Gne(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 f=t.state.doc.resolve(c.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},f.end()).joinForward().run()}if(!Dh(t.state,e)||!WVe(t.state))return!1;const r=vv(e,t.state);if(!r)return!1;const a=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Wne(e,t.state,a);return qne(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Kne=(t,e)=>{const n=eF(t,e),r=vv(t,e);return!r||!n?!1:n>r.depth},Xne=(t,e)=>{const n=eF(t,e),r=vv(t,e);return!r||!n?!1:n<r.depth},rR=(t,e)=>{if(!Dh(t.state,e)||!qVe(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:Kne(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Xne(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},n9e=(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)},Yne=Pr.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&&rR(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&&rR(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&&nR(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&&nR(t,n,r)&&(e=!0)}),e}}}}),Q9=/^(\s*)(\d+)\.\s+(.*)$/,r9e=/^\s/;function i9e(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],a=i.match(Q9);if(!a)break;const[,o,l,c]=a,u=o.length;let d=c,f=n+1;const p=[i];for(;f<t.length;){const m=t[f];if(m.match(Q9))break;if(m.trim()==="")p.push(m),d+=`
- `,f+=1;else if(m.match(r9e))p.push(m),d+=`
- ${m.slice(u+2)}`,f+=1;else break}e.push({indent:u,number:parseInt(l,10),content:d.trim(),raw:p.join(`
- `)}),r=f,n=f}return[e,r]}function Qne(t,e,n){var r;const i=[];let a=0;for(;a<t.length;){const o=t[a];if(o.indent===e){const l=o.content.split(`
- `),c=((r=l[0])==null?void 0:r.trim())||"",u=[];c&&u.push({type:"paragraph",raw:c,tokens:n.inlineTokens(c)});const d=l.slice(1).join(`
- `).trim();if(d){const m=n.blockTokens(d);u.push(...m)}let f=a+1;const p=[];for(;f<t.length&&t[f].indent>e;)p.push(t[f]),f+=1;if(p.length>0){const m=Math.min(...p.map(b=>b.indent)),x=Qne(p,m,n);u.push({type:"list",ordered:!0,start:p[0].number,items:x,raw:p.map(b=>b.raw).join(`
- `)})}i.push({type:"list_item",raw:o.raw,tokens:u}),a=f}else a+=1}return i}function a9e(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const a=e.parseChildren([i]);r.push({type:"paragraph",content:a})}else{const a=e.parseChildren([i]);a.length>0&&r.push(...a)}}),{type:"listItem",content:r}})}var s9e="listItem",Z9="textStyle",J9=/^(\d+)\.\s$/,Zne=Vs.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?a9e(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
- `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const i=t.split(`
- `),[a,o]=i9e(i);if(a.length===0)return;const l=Qne(a,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=a[0])==null?void 0:r.number)||1,items:l,raw:i.slice(0,o).join(`
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(s9e,this.editor.getAttributes(Z9)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=fx({find:J9,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=fx({find:J9,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Z9)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),o9e=/^\s*(\[([( |x])?\])\s$/,l9e=Vs.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 VL(t,e,i)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),a=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),c=document.createElement("div"),u=d=>{var f,p;l.ariaLabel=((p=(f=this.options.a11y)==null?void 0:f.checkboxLabel)==null?void 0:p.call(f,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return u(t),a.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:f}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr: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:f}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,f)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,f])=>{i.setAttribute(d,f)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,a.append(l,o),i.append(a,c),Object.entries(e).forEach(([d,f])=>{i.setAttribute(d,f)}),{dom:i,contentDOM:c,update:d=>d.type!==this.type?!1:(i.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,u(d),!0)}}},addInputRules(){return[fx({find:o9e,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),c9e=Vs.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,`
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=a=>{const o=qD(a,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,c)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:c}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(a)},i=qD(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:a=>({indentLevel:a[1].length,mainContent:a[4],checked:a[3].toLowerCase()==="x"}),createToken:(a,o)=>({type:"taskItem",raw:"",mainContent:a.mainContent,indentLevel:a.indentLevel,checked:a.checked,text:a.mainContent,tokens:n.inlineTokens(a.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()}}});Pr.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push($ne.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Vne.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Yne.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Zne.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(l9e.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(c9e.configure(this.options.taskList)),t}});var u9e=Vs.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()}}}),d9e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,h9e=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,f9e=Hh.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[hx({find:d9e,type:this.type})]},addPasteRules(){return[Mm({find:h9e,type:this.type})]}}),m9e=Vs.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Jne=Hh.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 a=i[2].trim();return{type:"underline",raw:i[0],text:a,tokens:n.inlineTokens(a)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),p9e=Jne;function g9e(t={}){return new di({view(e){return new x9e(e,t)}})}class x9e{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let a=o=>{this[i](o)};return e.dom.addEventListener(i,a),{name:i,handler:a}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,a=i.getBoundingClientRect(),o=a.width/i.offsetWidth,l=a.height/i.offsetHeight;if(n){let f=e.nodeBefore,p=e.nodeAfter;if(f||p){let m=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(m){let x=m.getBoundingClientRect(),b=f?x.bottom:x.top;f&&p&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let v=this.width/2*l;r={left:x.left,right:x.right,top:b-v,bottom:b+v}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*o;r={left:f.left-p,right:f.left+p,top:f.top,bottom:f.bottom}}let c=this.editorView.dom.offsetParent;this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let u,d;if(!c||c==document.body&&getComputedStyle(c).position=="static")u=-pageXOffset,d=-pageYOffset;else{let f=c.getBoundingClientRect(),p=f.width/c.offsetWidth,m=f.height/c.offsetHeight;u=f.left-c.scrollLeft*p,d=f.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,a=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!a){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Jee(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 Pn{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return bi.valid(r)?new bi(r):Pn.near(r)}content(){return Ut.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 tF(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!b9e(e)||!y9e(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,a=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){a=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?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!Qt.isSelectable(a)){e=e.doc.resolve(i+a.nodeSize*n),r=!1;continue e}break}a=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;Pn.jsonID("gapcursor",bi);class tF{constructor(e){this.pos=e}map(e){return new tF(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return bi.valid(n)?new bi(n):Pn.near(n)}}function ere(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function b9e(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||ere(i.type))return!0;if(i.inlineContent)return!1}}return!0}function y9e(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||ere(i.type))return!0;if(i.inlineContent)return!1}}return!0}function v9e(){return new di({props:{decorations:N9e,createSelectionBetween(t,e,n){return e.pos==n.pos&&bi.valid(n)?new bi(n):null},handleClick:_9e,handleKeyDown:w9e,handleDOMEvents:{beforeinput:S9e}}})}const w9e=Jte({ArrowLeft:c1("horiz",-1),ArrowRight:c1("horiz",1),ArrowUp:c1("vert",-1),ArrowDown:c1("vert",1)});function c1(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,a){let o=r.selection,l=e>0?o.$to:o.$from,c=o.empty;if(o instanceof pn){if(!a.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 _9e(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&&Qt.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new bi(r))),!0)}function S9e(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 a=t.state.tr.replace(n.pos,n.pos,new Ut(i,0,0));return a.setSelection(pn.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function N9e(t){if(!(t.selection instanceof bi))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",oi.create(t.doc,[ms.widget(t.selection.head,e,{key:"gapcursor"})])}var XN=200,Sa=function(){};Sa.prototype.append=function(e){return e.length?(e=Sa.from(e),!this.length&&e||e.length<XN&&this.leafAppend(e)||this.length<XN&&e.leafPrepend(this)||this.appendInner(e)):this};Sa.prototype.prepend=function(e){return e.length?Sa.from(e).append(this):this};Sa.prototype.appendInner=function(e){return new M9e(this,e)};Sa.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Sa.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Sa.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Sa.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)};Sa.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(a,o){return i.push(e(a,o))},n,r),i};Sa.from=function(e){return e instanceof Sa?e:e&&e.length?new tre(e):Sa.empty};var tre=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,a){return i==0&&a==this.length?this:new e(this.values.slice(i,a))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,a,o,l){for(var c=a;c<o;c++)if(i(this.values[c],l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(i,a,o,l){for(var c=a-1;c>=o;c--)if(i(this.values[c],l+c)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=XN)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=XN)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})(Sa);Sa.empty=new tre([]);var M9e=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,i,a,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(a,l),o)===!1||a>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,a)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,a,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(a,l)-l,o+l)===!1||a<l&&this.left.forEachInvertedInner(r,Math.min(i,l),a,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var a=this.left.length;return i<=a?this.left.slice(r,i):r>=a?this.right.slice(r-a,i-a):this.left.slice(r,a).append(this.right.slice(0,i-a))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(Sa);const k9e=500;class Pl{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=e.tr,l,c,u=[],d=[];return this.items.forEach((f,p)=>{if(!f.step){i||(i=this.remapping(r,p+1),a=i.maps.length),a--,d.push(f);return}if(i){d.push(new tc(f.map));let m=f.step.map(i.slice(a)),x;m&&o.maybeStep(m).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],u.push(new tc(x,void 0,void 0,u.length+d.length))),a--,x&&i.appendMap(x,a)}else o.maybeStep(f.step);if(f.selection)return l=i?f.selection.map(i.slice(a)):f.selection,c=new Pl(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 a=[],o=this.eventCount,l=this.items,c=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let f=e.steps[d].invert(e.docs[d]),p=new tc(e.mapping.maps[d],f,n),m;(m=c&&c.merge(p))&&(p=m,d?a.pop():l=l.slice(0,l.length-1)),a.push(p),n&&(o++,n=void 0),i||(c=p)}let u=o-r.depth;return u>T9e&&(l=E9e(l,u),o-=u),new Pl(l.append(a),o)}remapping(e,n){let r=new Sy;return this.items.forEach((i,a)=>{let o=i.mirrorOffset!=null&&a-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 Pl(this.items.append(e.map(n=>new tc(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=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=a.getMirror(--c);if(m==null)return;o=Math.min(o,m);let x=a.maps[m];if(p.step){let b=e.steps[m].invert(e.docs[m]),v=p.selection&&p.selection.map(a.slice(c+1,m));v&&l++,r.push(new tc(x,b,v))}else r.push(new tc(x))},i);let u=[];for(let p=n;p<o;p++)u.push(new tc(a.maps[p]));let d=this.items.slice(0,i).append(u).append(r),f=new Pl(d,l);return f.emptyItemCount()>k9e&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],a=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&a++;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&&a++;let f=new tc(u.invert(),c,d),p,m=i.length-1;(p=i.length&&i[m].merge(f))?i[m]=p:i.push(f)}}else o.map&&r--},this.items.length,0),new Pl(Sa.from(i.reverse()),a)}}Pl.empty=new Pl(Sa.empty,0);function E9e(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class tc{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 tc(n.getMap().invert(),n,this.selection)}}}class Gd{constructor(e,n,r,i,a){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=a}}const T9e=20;function A9e(t,e,n,r){let i=n.getMeta(Jf),a;if(i)return i.historyState;n.getMeta(j9e)&&(t=new Gd(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Jf))return o.getMeta(Jf).redo?new Gd(t.done.addTransform(n,void 0,r,I1(e)),t.undone,eq(n.mapping.maps),t.prevTime,t.prevComposition):new Gd(t.done,t.undone.addTransform(n,void 0,r,I1(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||!C9e(n,t.prevRanges)),u=o?LP(t.prevRanges,n.mapping):eq(n.mapping.maps);return new Gd(t.done.addTransform(n,c?e.selection.getBookmark():void 0,r,I1(e)),Pl.empty,u,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Gd(t.done.rebased(n,a),t.undone.rebased(n,a),LP(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Gd(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),LP(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function C9e(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let a=0;a<e.length;a+=2)r<=e[a+1]&&i>=e[a]&&(n=!0)}),n}function eq(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,a,o)=>e.push(a,o));return e}function LP(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),a=e.map(t[r+1],-1);i<=a&&n.push(i,a)}return n}function P9e(t,e,n){let r=I1(e),i=Jf.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),l=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),i,r),c=new Gd(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(o).setMeta(Jf,{redo:n,historyState:c})}let FP=!1,tq=null;function I1(t){let e=t.plugins;if(tq!=e){FP=!1,tq=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){FP=!0;break}}return FP}const Jf=new la("history"),j9e=new la("closeHistory");function D9e(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new di({key:Jf,state:{init(){return new Gd(Pl.empty,Pl.empty,null,0,-1)},apply(e,n,r){return A9e(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?rre:r=="historyRedo"?ire:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function nre(t,e){return(n,r)=>{let i=Jf.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let a=P9e(i,n,t);a&&r(e?a.scrollIntoView():a)}return!0}}const rre=nre(!1,!0),ire=nre(!0,!0);Pr.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 la("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit;if(i==null||i===0){t=!0;return}const a=this.storage.characters({node:r.doc});if(a>i){const o=a-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}),a=this.storage.characters({node:e.doc});if(a<=r||i>r&&a>r&&a<=i)return!0;if(i>r&&a>r&&a>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,c=a-r,u=l-c,d=l;return e.deleteRange(u,d),!(this.storage.characters({node:e.doc})>r)}})]}});var R9e=Pr.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[g9e(this.options)]}});Pr.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new di({key:new la("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,a=[];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";a.push(ms.node(u,u+c.nodeSize,{class:this.options.className}))}),oi.create(t,a)}}})]}});var O9e=Pr.create({name:"gapCursor",addProseMirrorPlugins(){return[v9e()]},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}}});Pr.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 la("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,i=[];if(!n)return null;const a=this.editor.isEmpty;return t.descendants((o,l)=>{const c=r>=l&&r<=l+o.nodeSize,u=!o.isLeaf&&R2(o);if((c||!this.options.showOnlyCurrent)&&u){const d=[this.options.emptyNodeClass];a&&d.push(this.options.emptyEditorClass);const f=ms.node(l,l+o.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:c}):this.options.placeholder});i.push(f)}return this.options.includeChildren}),oi.create(t,i)}}})]}});Pr.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new di({key:new la("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||pne(n.selection)||t.view.dragging?null:oi.create(n.doc,[ms.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function nq({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var L9e=Pr.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new la(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,a,o)=>{const{doc:l,tr:c,schema:u}=o,d=e.getState(o),f=l.content.size,p=u.nodes[n];if(d)return c.insert(f,p.create())},state:{init:(i,a)=>{const o=a.tr.doc.lastChild;return!nq({node:o,types:r})},apply:(i,a)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return a;const o=i.doc.lastChild;return!nq({node:o,types:r})}}})]}}),F9e=Pr.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>rre(t,e),redo:()=>({state:t,dispatch:e})=>ire(t,e)}},addProseMirrorPlugins(){return[D9e(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()}}}),I9e=Pr.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(d7e.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(s7e.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push($ne.configure(this.options.bulletList)),this.options.code!==!1&&i.push(m7e.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(x7e.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(b7e.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(R9e.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(O9e.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(y7e.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(v7e.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(F9e.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(w7e.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(k7e.configure(this.options.italic)),this.options.listItem!==!1&&i.push(Vne.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Yne.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(Hne.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Zne.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(u9e.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(f9e.configure(this.options.strike)),this.options.text!==!1&&i.push(m9e.configure(this.options.text)),this.options.underline!==!1&&i.push(Jne.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(L9e.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),U9e=I9e,z9e=Pr.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")}}}),B9e=z9e,H9e=20,are=(t,e=0)=>{const n=[];return!t.children.length||e>H9e||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...are(r,e+1))}),n},$9e=t=>{if(!t.children.length)return;const e=are(t);e&&e.forEach(n=>{var r,i;const a=n.getAttribute("style"),o=(i=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:i.getAttribute("style");n.setAttribute("style",`${o};${a}`)})},sre=Hh.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&$9e(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(a=>!!a))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),V9e=Pr.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const o=a[0].trim().toLowerCase(),l=a.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()}}}),ore=Pr.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(i=>i.trim()).filter(Boolean);for(let i=r.length-1;i>=0;i-=1){const a=r[i].split(":");if(a.length>=2){const o=a[0].trim().toLowerCase(),l=a.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()}}}),G9e=Pr.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()}}}),q9e=Pr.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()}}}),W9e=Pr.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()}}});Pr.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(V9e.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(ore.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(G9e.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(q9e.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(W9e.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(sre.configure(this.options.textStyle)),t}});var K9e=ore,X9e=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,Y9e=Vs.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,a,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=(a=t.attrs)==null?void 0:a.title)!=null?o:"";return u?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:i,getPos:a,HTMLAttributes:o})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,f])=>{if(f!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,f);break}}),l.src=o.src;const c=new PGe({element:l,node:i,getPos:a,onResize:(d,f)=>{l.style.width=`${d}px`,l.style.height=`${f}px`},onCommit:(d,f)=>{const p=a();p!==void 0&&this.editor.chain().setNodeSelection(p).updateAttributes(this.name,{width:d,height:f}).run()},onUpdate:(d,f,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[Cne({find:X9e,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Q9e=Y9e;function iR({content:t,onChange:e,placeholder:n}){const r=t7e({extensions:[U9e.configure({heading:!1,codeBlock:!1,code:!1}),p9e,Q7e.configure({openOnClick:!1,HTMLAttributes:{target:"_blank",rel:"noopener noreferrer"}}),B9e.configure({types:["paragraph"]}),sre,K9e,Q9e.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})=>s.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}),a=()=>{const o=window.prompt("Enter URL:");o&&r.chain().focus().setLink({href:o}).run()};return s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden bg-bambu-dark",children:[s.jsxs("div",{className:"flex items-center gap-0.5 p-1.5 border-b border-bambu-dark-tertiary bg-bambu-dark-secondary",children:[s.jsx(i,{onClick:()=>r.chain().focus().toggleBold().run(),isActive:r.isActive("bold"),title:"Bold",children:s.jsx(_ce,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleItalic().run(),isActive:r.isActive("italic"),title:"Italic",children:s.jsx(pde,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleUnderline().run(),isActive:r.isActive("underline"),title:"Underline",children:s.jsx(afe,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:()=>r.chain().focus().toggleBulletList().run(),isActive:r.isActive("bulletList"),title:"Bullet List",children:s.jsx(pM,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().toggleOrderedList().run(),isActive:r.isActive("orderedList"),title:"Numbered List",children:s.jsx(SW,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("left").run(),isActive:r.isActive({textAlign:"left"}),title:"Align Left",children:s.jsx(Qhe,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("center").run(),isActive:r.isActive({textAlign:"center"}),title:"Align Center",children:s.jsx(Whe,{className:"w-4 h-4"})}),s.jsx(i,{onClick:()=>r.chain().focus().setTextAlign("right").run(),isActive:r.isActive({textAlign:"right"}),title:"Align Right",children:s.jsx(Xhe,{className:"w-4 h-4"})}),s.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary mx-1"}),s.jsx(i,{onClick:a,isActive:r.isActive("link"),title:"Add Link",children:s.jsx(Iy,{className:"w-4 h-4"})}),r.isActive("link")&&s.jsx(i,{onClick:()=>r.chain().focus().unsetLink().run(),title:"Remove Link",children:s.jsx(RR,{className:"w-4 h-4"})})]}),s.jsx(KGe,{editor:r})]})}function lre({archiveId:t,archiveName:e,onClose:n}){const r=sn(),[i,a]=_.useState(!1),[o,l]=_.useState(null),[c,u]=_.useState({}),{data:d,isLoading:f,error:p}=ot({queryKey:["archive-project-page",t],queryFn:()=>ce.getArchiveProjectPage(t)}),m=mt({mutationFn:M=>ce.updateArchiveProjectPage(t,M),onSuccess:()=>{r.invalidateQueries({queryKey:["archive-project-page",t]}),a(!1),u({})}});_.useEffect(()=>{const M=C=>{C.key==="Escape"&&(o!==null?l(null):i?y():n())};return document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)},[o,i,n]);const x=[...d?.model_pictures||[],...d?.profile_pictures||[]],b=()=>{u({title:d?.title||"",description:d?.description||"",designer:d?.designer||"",license:d?.license||"",profile_title:d?.profile_title||"",profile_description:d?.profile_description||""}),a(!0)},v=()=>{m.mutate(c)},y=()=>{a(!1),u({})},S=M=>{const C=["p","br","b","strong","i","em","u","a","ul","ol","li","figure","img"],E=new DOMParser().parseFromString(M,"text/html"),R=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(R).join("");let F="";if(I==="a"&&D.getAttribute("href")){const P=D.getAttribute("href");P?.toLowerCase().startsWith("http")&&(F=` href="${P}" target="_blank" rel="noopener noreferrer"`)}if(I==="img"){const P=D.getAttribute("src");if(!P?.toLowerCase().startsWith("http"))return"";F=` src="${P}" style="max-width: 100%; height: auto;"`}const z=Array.from(D.childNodes).map(R).join("");return["br","img"].includes(I)?`<${I}${F} />`:`<${I}${F}>${z}</${I}>`}return""};return Array.from(E.body.childNodes).map(R).join("")},k=d&&(d.title||d.description||d.designer||d.profile_title||x.length>0),T=M=>{M.target===M.currentTarget&&n()};return s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:T,children:[s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl max-w-4xl w-full max-h-[90vh] overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ls,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Project Page",e&&s.jsxs("span",{className:"text-bambu-gray ml-2",children:["- ",e]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!i&&k&&s.jsxs(Te,{variant:"ghost",size:"sm",onClick:b,children:[s.jsx(rm,{className:"w-4 h-4 mr-1"}),"Edit"]}),i&&s.jsxs(s.Fragment,{children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:y,children:"Cancel"}),s.jsxs(Te,{variant:"primary",size:"sm",onClick:v,disabled:m.isPending,children:[s.jsx(hs,{className:"w-4 h-4 mr-1"}),"Save"]})]}),s.jsx("button",{onClick:n,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[f&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-bambu-green border-t-transparent"})}),p&&s.jsx("div",{className:"text-red-400 text-center py-12",children:"Failed to load project page data"}),d&&!k&&s.jsxs("div",{className:"text-bambu-gray text-center py-12",children:[s.jsx(Ls,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),s.jsx("p",{children:"No project page data found in this 3MF file."}),s.jsx("p",{className:"text-sm mt-2",children:"Project pages are typically included in files downloaded from MakerWorld."})]}),d&&k&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-4",children:[i?s.jsx("input",{type:"text",value:c.title||"",onChange:M=>u({...c,title:M.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&&s.jsx("h3",{className:"text-xl font-semibold text-white",children:d.title}),s.jsxs("div",{className:"flex flex-wrap gap-4 text-sm",children:[i?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(am,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.designer||"",onChange:M=>u({...c,designer:M.target.value}),placeholder:"Designer",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.designer&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(am,{className:"w-4 h-4"}),s.jsx("span",{children:d.designer}),d.designer_user_id&&s.jsx("a",{href:`https://makerworld.com/en/@${d.designer_user_id}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline",children:s.jsx(Xr,{className:"w-3 h-3"})})]}),d.creation_date&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(ti,{className:"w-4 h-4"}),s.jsx("span",{children:d.creation_date})]}),i?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ls,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c.license||"",onChange:M=>u({...c,license:M.target.value}),placeholder:"License",className:"bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-white"})]}):d.license&&s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray",children:[s.jsx(Ls,{className:"w-4 h-4"}),s.jsx("span",{children:d.license})]}),d.origin&&s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark rounded text-bambu-gray",children:d.origin})]})]}),(d.description||i)&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Description"}),i?s.jsx(iR,{content:c.description||"",onChange:M=>u({...c,description:M}),placeholder:"Enter description..."}):s.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)&&s.jsxs("div",{className:"space-y-2 p-4 bg-bambu-dark rounded-lg",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide",children:"Print Profile"}),i?s.jsxs("div",{className:"space-y-2",children:[s.jsx("input",{type:"text",value:c.profile_title||"",onChange:M=>u({...c,profile_title:M.target.value}),placeholder:"Profile Title",className:"w-full bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded px-3 py-2 text-white"}),s.jsx(iR,{content:c.profile_description||"",onChange:M=>u({...c,profile_description:M}),placeholder:"Profile description..."})]}):s.jsxs(s.Fragment,{children:[d.profile_title&&s.jsx("p",{className:"text-white font-medium",children:d.profile_title}),d.profile_description&&s.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&&s.jsxs("p",{className:"text-sm text-bambu-gray",children:["by ",d.profile_user_name]})]})]}),x.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("h4",{className:"text-sm font-medium text-bambu-gray uppercase tracking-wide flex items-center gap-2",children:[s.jsx(Ou,{className:"w-4 h-4"}),"Images (",x.length,")"]}),s.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 gap-2",children:x.map((M,C)=>s.jsx("button",{onClick:()=>l(C),className:"aspect-square rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors",children:s.jsx("img",{src:M.url,alt:M.name,className:"w-full h-full object-cover"})},M.path))})]}),d.design_model_id&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.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:[s.jsx(Xr,{className:"w-4 h-4"}),"View on MakerWorld"]})})]})]})]}),o!==null&&x[o]&&s.jsxs("div",{className:"fixed inset-0 bg-black/90 flex items-center justify-center z-60",onClick:()=>l(null),children:[s.jsx("button",{onClick:M=>{M.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:s.jsx(gh,{className:"w-6 h-6 text-white"})}),s.jsx("img",{src:x[o].url,alt:x[o].name,className:"max-w-[90vw] max-h-[90vh] object-contain",onClick:M=>M.stopPropagation()}),s.jsx("button",{onClick:M=>{M.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:s.jsx(gs,{className:"w-6 h-6 text-white"})}),s.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:s.jsx(Rt,{className:"w-6 h-6 text-white"})}),s.jsxs("div",{className:"absolute bottom-4 text-white text-sm",children:[o+1," / ",x.length]})]})]})}const Z9e=[.25,.5,.75,1,1.5,2,3,4];function ng(t){const e=Math.floor(t/60),n=Math.floor(t%60);return`${e}:${n.toString().padStart(2,"0")}`}function J9e({archiveId:t,timelapseSrc:e,onClose:n,onSave:r}){const{showToast:i}=Hn(),a=_.useRef(null),o=_.useRef(null),[l,c]=_.useState(!1),[u,d]=_.useState(0),[f,p]=_.useState(0),[m,x]=_.useState(0),[b,v]=_.useState(0),[y,S]=_.useState(1),[k,T]=_.useState(null),[M,C]=_.useState(null),[E,R]=_.useState(.8),[A,D]=_.useState(!1),{data:I,isLoading:F}=ot({queryKey:["timelapse-info",t],queryFn:()=>ce.getTimelapseInfo(t)}),{data:z}=ot({queryKey:["timelapse-thumbnails",t],queryFn:()=>ce.getTimelapseThumbnails(t,15)}),P=mt({mutationFn:()=>ce.processTimelapse(t,{trimStart:m,trimEnd:b,speed:y,saveMode:"replace"},k||void 0),onSuccess:H=>{i(H.message,"success"),r?.(),n()},onError:H=>{i(H.message||"Processing failed","error")}});_.useEffect(()=>{I?.duration&&b===0&&v(I.duration)},[I?.duration,b]),_.useEffect(()=>{const H=K=>{K.key==="Escape"&&n()};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[n]),_.useEffect(()=>{const H=a.current;if(!H)return;const K=()=>{const me=H.currentTime;d(me),me>=b&&(H.currentTime=m)},re=()=>{p(H.duration),b===0&&v(H.duration)},ne=()=>c(!0),be=()=>c(!1);return H.addEventListener("timeupdate",K),H.addEventListener("durationchange",re),H.addEventListener("play",ne),H.addEventListener("pause",be),()=>{H.removeEventListener("timeupdate",K),H.removeEventListener("durationchange",re),H.removeEventListener("play",ne),H.removeEventListener("pause",be)}},[m,b]),_.useEffect(()=>{const H=o.current,K=a.current;!H||!K||!M||(H.currentTime=K.currentTime,H.playbackRate=K.playbackRate,l&&!A?H.play().catch(()=>{}):H.pause())},[l,M,A]),_.useEffect(()=>{o.current&&(o.current.volume=A?0:E)},[E,A]),_.useEffect(()=>{a.current&&(a.current.playbackRate=y),o.current&&(o.current.playbackRate=y)},[y]);const $=_.useCallback(()=>{const H=a.current;H&&(l?H.pause():(H.currentTime<m&&(H.currentTime=m),H.play()))},[l,m]),X=H=>{const K=a.current;K&&(K.currentTime=Math.max(m,Math.min(b,H)))},V=H=>{const K=H.target.files?.[0];K&&(M&&URL.revokeObjectURL(M),T(K),C(URL.createObjectURL(K)))},Q=()=>{M&&URL.revokeObjectURL(M),T(null),C(null)};_.useEffect(()=>()=>{M&&URL.revokeObjectURL(M)},[M]);const Z=b-m,se=Z/y;return F?s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:s.jsxs("div",{className:"flex items-center gap-3 text-white",children:[s.jsx(ft,{className:"w-6 h-6 animate-spin"}),"Loading video info..."]})}):s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:s.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:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(ah,{className:"w-5 h-5 text-bambu-green"}),"Edit Timelapse"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Te,{variant:"primary",size:"sm",onClick:()=>P.mutate(),disabled:P.isPending,children:P.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Processing..."]}):s.jsxs(s.Fragment,{children:[s.jsx(hs,{className:"w-4 h-4"}),"Save"]})}),s.jsx("button",{onClick:n,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4",children:[s.jsxs("div",{className:"relative",children:[s.jsx("video",{ref:a,src:e,className:"w-full rounded-lg bg-black",onClick:$,muted:!!M}),!l&&s.jsx("button",{onClick:$,className:"absolute inset-0 flex items-center justify-center bg-black/30 hover:bg-black/40 transition-colors",children:s.jsx("div",{className:"p-4 bg-bambu-green rounded-full",children:s.jsx(bo,{className:"w-8 h-8 text-white"})})}),M&&s.jsx("audio",{ref:o,src:M,loop:!0})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(whe,{className:"w-4 h-4"}),s.jsx("span",{children:"Trim"}),s.jsxs("span",{className:"ml-auto",children:[ng(m)," - ",ng(b)," (",ng(Z),")"]})]}),s.jsxs("div",{className:"relative h-16 bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 flex",children:z?.thumbnails.map((H,K)=>s.jsx("div",{className:"flex-1 bg-cover bg-center",style:{backgroundImage:`url(data:image/jpeg;base64,${H})`}},K))}),s.jsx("div",{className:"absolute inset-y-0 left-0 bg-black/60",style:{width:`${m/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 right-0 bg-black/60",style:{width:`${(f-b)/f*100}%`}}),s.jsx("div",{className:"absolute inset-y-0 border-2 border-bambu-green",style:{left:`${m/f*100}%`,right:`${(f-b)/f*100}%`}}),s.jsx("div",{className:"absolute top-0 bottom-0 w-0.5 bg-white shadow-lg",style:{left:`${u/f*100}%`}}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:m,onChange:H=>{const K=parseFloat(H.target.value);K<b-1&&(x(K),a.current&&a.current.currentTime<K&&(a.current.currentTime=K))},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 50% 0 0)"}}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:b,onChange:H=>{const K=parseFloat(H.target.value);K>m+1&&v(K)},className:"absolute inset-0 w-full opacity-0 cursor-ew-resize",style:{clipPath:"inset(0 0 0 50%)"}})]}),s.jsx("input",{type:"range",min:0,max:f,step:.1,value:u,onChange:H=>X(parseFloat(H.target.value)),className:`w-full h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),s.jsx("div",{className:"flex items-center justify-center gap-2",children:s.jsx("button",{onClick:$,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(CR,{className:"w-5 h-5 text-white"}):s.jsx(bo,{className:"w-5 h-5 text-white"})})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(hM,{className:"w-4 h-4"}),s.jsx("span",{children:"Speed"}),s.jsxs("span",{className:"ml-auto",children:[y,"x (output: ",ng(se),")"]})]}),s.jsx("div",{className:"flex gap-1",children:Z9e.map(H=>s.jsxs("button",{onClick:()=>S(H),className:`flex-1 px-2 py-2 text-sm rounded transition-colors ${y===H?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[H,"x"]},H))})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(bj,{className:"w-4 h-4"}),s.jsx("span",{children:"Music Overlay"})]}),k?s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx(bj,{className:"w-5 h-5 text-bambu-green"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:k.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(k.size/1024/1024).toFixed(1)," MB"]})]}),s.jsx("button",{onClick:()=>D(!A),className:"p-2 hover:bg-bambu-dark-tertiary rounded transition-colors",children:A?s.jsx(mfe,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(hfe,{className:"w-4 h-4 text-bambu-green"})}),s.jsx("input",{type:"range",min:0,max:1,step:.1,value:E,onChange:H=>R(parseFloat(H.target.value)),className:`w-20 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full`}),s.jsx("button",{onClick:Q,className:"p-2 hover:bg-red-500/20 rounded transition-colors",children:s.jsx(an,{className:"w-4 h-4 text-red-400"})})]}):s.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:[s.jsx(za,{className:"w-8 h-8 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:"Drop audio file or click to upload"}),s.jsx("span",{className:"text-xs text-bambu-gray/60",children:"MP3, WAV, M4A, AAC, OGG"}),s.jsx("input",{type:"file",accept:".mp3,.wav,.m4a,.aac,.ogg,audio/*",onChange:V,className:"hidden"})]})]}),s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg text-sm space-y-1",children:[s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Original:"})," ",ng(f)," @ ",I?.width,"x",I?.height]}),s.jsxs("p",{className:"text-bambu-gray",children:[s.jsx("span",{className:"text-white",children:"Output:"})," ",ng(se)," @ ",y,"x speed",k&&" + music overlay"]})]})]}),P.isPending&&s.jsxs("div",{className:"absolute inset-0 bg-black/80 flex flex-col items-center justify-center gap-4",children:[s.jsx(ft,{className:"w-12 h-12 text-bambu-green animate-spin"}),s.jsx("p",{className:"text-white text-lg",children:"Processing timelapse..."}),s.jsx("p",{className:"text-bambu-gray text-sm",children:"This may take a few moments"})]})]})})}const eqe=[.25,.5,.75,1,1.5,2,3,4];function cre({src:t,title:e,downloadFilename:n,archiveId:r,onClose:i,onEdit:a}){const o=_.useRef(null),[l,c]=_.useState(!0),[u,d]=_.useState(1),[f,p]=_.useState(0),[m,x]=_.useState(0),[b,v]=_.useState(!1);_.useEffect(()=>{const E=o.current;E&&(E.playbackRate=u)},[u]),_.useEffect(()=>{const E=R=>{R.key==="Escape"&&i()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[i]),_.useEffect(()=>{const E=o.current;if(!E)return;const R=()=>p(E.currentTime),A=()=>x(E.duration),D=()=>c(!0),I=()=>c(!1);return E.addEventListener("timeupdate",R),E.addEventListener("durationchange",A),E.addEventListener("play",D),E.addEventListener("pause",I),()=>{E.removeEventListener("timeupdate",R),E.removeEventListener("durationchange",A),E.removeEventListener("play",D),E.removeEventListener("pause",I)}},[]);const y=()=>{const E=o.current;E&&(l?E.pause():E.play())},S=E=>{const R=o.current;R&&(R.currentTime=parseFloat(E.target.value))},k=()=>{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))},M=E=>{const R=Math.floor(E/60),A=Math.floor(E%60);return`${R}:${A.toString().padStart(2,"0")}`},C=()=>{const E=document.createElement("a");E.href=t,E.download=n,E.click()};return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80",children:[s.jsxs("div",{className:"relative bg-bambu-dark-secondary rounded-xl max-w-4xl w-full mx-4 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(ah,{className:"w-5 h-5 text-bambu-green"}),e]}),s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>v(!0),children:[s.jsx(Zi,{className:"w-4 h-4"}),"Edit"]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:C,children:[s.jsx(wi,{className:"w-4 h-4"}),"Download"]}),s.jsx("button",{onClick:i,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]})]}),s.jsxs("div",{className:"p-4",children:[s.jsx("video",{ref:o,src:t,autoPlay:!0,className:"w-full rounded-lg",onClick:y}),s.jsxs("div",{className:"mt-4 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-bambu-gray w-12 text-right",children:M(f)}),s.jsx("input",{type:"range",min:0,max:m||100,value:f,onChange:S,className:`flex-1 h-1 bg-bambu-dark-tertiary rounded-lg appearance-none cursor-pointer
- [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3
- [&::-webkit-slider-thumb]:bg-bambu-green [&::-webkit-slider-thumb]:rounded-full
- [&::-webkit-slider-thumb]:cursor-pointer`}),s.jsx("span",{className:"text-xs text-bambu-gray w-12",children:M(m)})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:k,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip back 5s",children:s.jsx(jhe,{className:"w-5 h-5 text-bambu-gray"})}),s.jsx("button",{onClick:y,className:"p-2 bg-bambu-green hover:bg-bambu-green-dark rounded-lg transition-colors",children:l?s.jsx(CR,{className:"w-5 h-5 text-white"}):s.jsx(bo,{className:"w-5 h-5 text-white"})}),s.jsx("button",{onClick:T,className:"p-2 hover:bg-bambu-dark-tertiary rounded-lg transition-colors",title:"Skip forward 5s",children:s.jsx(DR,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Speed:"}),s.jsx("div",{className:"flex gap-1",children:eqe.map(E=>s.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))})]})]})]})]})]}),b&&r&&s.jsx(J9e,{archiveId:r,timelapseSrc:t,onClose:()=>v(!1),onSave:a})]})}function tqe({archiveIds:t,onClose:e}){_.useEffect(()=>{const a=o=>{o.key==="Escape"&&e()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e]);const{data:n,isLoading:r,error:i}=ot({queryKey:["archive-comparison",t],queryFn:()=>ce.compareArchives(t)});return s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[90vh] flex flex-col border border-bambu-dark-tertiary",onClick:a=>a.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white",children:["Compare Archives (",t.length,")"]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white p-1",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4 bg-bambu-dark-secondary",children:r?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):i?s.jsxs("div",{className:"text-center py-12 text-red-400",children:[s.jsx(Sn,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),s.jsx("p",{children:"Failed to load comparison"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:i instanceof Error?i.message:"Unknown error"})]}):n?s.jsx(nqe,{comparison:n}):null}),s.jsx("div",{className:"p-4 border-t border-bambu-dark-tertiary",children:s.jsx(Te,{variant:"secondary",onClick:e,className:"w-full",children:"Close"})})]})})}function nqe({comparison:t}){return s.jsxs("div",{className:"space-y-6",children:[s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.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=>s.jsxs("th",{className:"text-left text-sm font-medium pb-2 px-2 min-w-[120px]",children:[s.jsx("div",{className:"text-white truncate max-w-[150px]",title:e.print_name,children:e.print_name}),s.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))]})}),s.jsx("tbody",{className:"divide-y divide-bambu-gray/20",children:t.comparison.map(e=>s.jsxs("tr",{className:e.has_difference?"bg-yellow-500/5":"",children:[s.jsx("td",{className:"py-2 pr-4 text-sm",children:s.jsxs("div",{className:"flex items-center gap-2",children:[e.has_difference&&s.jsx(Sn,{className:"w-3 h-3 text-yellow-400 flex-shrink-0"}),s.jsx("span",{className:e.has_difference?"text-yellow-400":"text-bambu-gray",children:e.label})]})}),e.values.map((n,r)=>s.jsxs("td",{className:"py-2 px-2 text-sm text-white",children:[n??s.jsx("span",{className:"text-bambu-gray/50",children:"-"}),e.unit&&n!==null&&s.jsx("span",{className:"text-bambu-gray ml-1",children:e.unit})]},r))]},e.field))})]})}),t.differences.length>0&&s.jsxs("div",{className:"p-4 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsxs("h4",{className:"text-sm font-medium text-yellow-400 mb-2 flex items-center gap-2",children:[s.jsx(Sn,{className:"w-4 h-4"}),t.differences.length," Difference",t.differences.length>1?"s":""," Found"]}),s.jsxs("ul",{className:"text-sm text-white/80 space-y-1",children:[t.differences.slice(0,5).map(e=>s.jsxs("li",{children:[s.jsx("span",{className:"text-yellow-400",children:e.label}),": ",e.values.join(" vs ")," ",e.unit||""]},e.field)),t.differences.length>5&&s.jsxs("li",{className:"text-bambu-gray",children:["...and ",t.differences.length-5," more"]})]})]}),t.success_correlation.has_both_outcomes?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("h4",{className:"text-sm font-medium text-white mb-3 flex items-center gap-2",children:[s.jsx(Na,{className:"w-4 h-4 text-bambu-green"}),"Success/Failure Analysis"]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm mb-3",children:[s.jsxs("span",{className:"text-bambu-green",children:[t.success_correlation.successful_count," successful"]}),s.jsxs("span",{className:"text-red-400",children:[t.success_correlation.failed_count," failed"]})]}),t.success_correlation.insights&&t.success_correlation.insights.length>0?s.jsx("div",{className:"space-y-2",children:t.success_correlation.insights.map(e=>s.jsxs("div",{className:"text-sm p-2 bg-bambu-dark-secondary rounded",children:[s.jsxs("span",{className:"text-white font-medium",children:[e.label,":"]})," ",s.jsx("span",{className:"text-white/80",children:e.insight})]},e.field))}):s.jsx("p",{className:"text-sm text-bambu-gray",children:"No clear correlations found between settings and outcomes."})]}):s.jsx("div",{className:"p-4 bg-bambu-dark rounded-lg text-sm text-bambu-gray",children:s.jsx("p",{children:t.success_correlation.message||"Need both successful and failed prints for correlation analysis."})})]})}function rqe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function iqe(t){const e=new Date(t),r=new Date().getTime()-e.getTime(),i=Math.floor(r/6e4);if(i<1)return"Just now";if(i<60)return`${i}m ago`;const a=Math.floor(i/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function aqe({upload:t,projects:e,onArchive:n,onDiscard:r,isArchiving:i,isDiscarding:a}){const[o,l]=_.useState(!1),[c,u]=_.useState(t.tags||""),[d,f]=_.useState(t.notes||""),[p,m]=_.useState(t.project_id),[x,b]=_.useState(!1);return s.jsx(St,{children:s.jsxs(Nt,{className:"py-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(zf,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:t.filename}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[s.jsx("span",{children:rqe(t.file_size)}),s.jsx("span",{children:"·"}),s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(tr,{className:"w-3 h-3"}),iqe(t.uploaded_at)]}),t.source_ip&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"·"}),s.jsxs("span",{children:["from ",t.source_ip]})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>l(!o),className:"p-1 text-bambu-gray hover:text-white transition-colors",children:o?s.jsx(xh,{className:"w-5 h-5"}):s.jsx(Kr,{className:"w-5 h-5"})}),s.jsx(Te,{variant:"primary",size:"sm",onClick:()=>n(t.id,{tags:c,notes:d,project_id:p||void 0}),disabled:i,children:i?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(ho,{className:"w-4 h-4"}),"Archive"]})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>b(!0),disabled:a,children:a?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(an,{className:"w-4 h-4 text-red-400"})})]})]}),x&&s.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),b(!1)},onCancel:()=>b(!1)}),o&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Tags"}),s.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Notes"}),s.jsx("textarea",{value:d,onChange:v=>f(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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Project"}),s.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:[s.jsx("option",{value:"",children:"No project"}),e.map(v=>s.jsx("option",{value:v.id,children:v.name},v.id))]})]})]})]})})}function sqe(){const t=sn(),{showToast:e}=Hn(),[n,r]=_.useState(!1),[i,a]=_.useState(!1),[o,l]=_.useState(new Set),[c,u]=_.useState(new Set),{data:d,isLoading:f}=ot({queryKey:["pending-uploads"],queryFn:ag.list,refetchInterval:1e4}),{data:p}=ot({queryKey:["projects"],queryFn:()=>ce.getProjects()}),m=mt({mutationFn:({id:y,data:S})=>ag.archive(y,S),onMutate:({id:y})=>{l(S=>new Set(S).add(y))},onSettled:(y,S,{id:k})=>{l(T=>{const M=new Set(T);return M.delete(k),M})},onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived: ${y.print_name}`)},onError:y=>{e(y.message||"Failed to archive","error")}}),x=mt({mutationFn:y=>ag.discard(y),onMutate:y=>{u(S=>new Set(S).add(y))},onSettled:(y,S,k)=>{u(T=>{const M=new Set(T);return M.delete(k),M})},onSuccess:()=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e("Upload discarded")},onError:y=>{e(y.message||"Failed to discard","error")}}),b=mt({mutationFn:ag.archiveAll,onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),t.invalidateQueries({queryKey:["archives"]}),e(`Archived ${y.archived} files${y.failed>0?`, ${y.failed} failed`:""}`)},onError:y=>{e(y.message||"Failed to archive all","error")}}),v=mt({mutationFn:ag.discardAll,onSuccess:y=>{t.invalidateQueries({queryKey:["pending-uploads"]}),e(`Discarded ${y.discarded} files`)},onError:y=>{e(y.message||"Failed to discard all","error")}});return f?s.jsx(St,{children:s.jsx(Nt,{className:"py-8 flex justify-center",children:s.jsx(ft,{className:"w-6 h-6 animate-spin text-bambu-green"})})}):!d||d.length===0?null:s.jsxs("div",{className:"mb-6",children:[s.jsxs(St,{className:"border-l-4 border-l-yellow-500",children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(za,{className:"w-5 h-5 text-yellow-500"}),s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Pending Uploads (",d.length,")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Te,{variant:"primary",size:"sm",onClick:()=>r(!0),disabled:b.isPending,children:b.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(ho,{className:"w-4 h-4"}),"Archive All"]})}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>a(!0),disabled:v.isPending,children:v.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(an,{className:"w-4 h-4"}),"Discard All"]})})]})]})}),s.jsxs(Nt,{children:[s.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."}),s.jsx("div",{className:"space-y-3",children:d.map(y=>s.jsx(aqe,{upload:y,projects:p||[],onArchive:(S,k)=>m.mutate({id:S,data:k}),onDiscard:S=>x.mutate(S),isArchiving:o.has(y.id),isDiscarding:c.has(y.id)},y.id))})]})]}),n&&s.jsx(Zn,{title:"Archive All Uploads",message:`Are you sure you want to archive all ${d.length} pending uploads?`,confirmText:"Archive All",onConfirm:()=>{b.mutate(),r(!1)},onCancel:()=>r(!1)}),i&&s.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(),a(!1)},onCancel:()=>a(!1)})]})}function oqe({onClose:t}){const e=sn(),{showToast:n}=Hn(),[r,i]=_.useState(""),[a,o]=_.useState(null),[l,c]=_.useState(""),[u,d]=_.useState(null),[f,p]=_.useState("count");_.useEffect(()=>{const A=D=>{D.key==="Escape"&&(a?o(null):u?d(null):t())};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[t,a,u]);const{data:m,isLoading:x}=ot({queryKey:["tags"],queryFn:ce.getTags}),b=mt({mutationFn:({oldName:A,newName:D})=>ce.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=mt({mutationFn:A=>ce.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")}}),y=A=>{o(A.name),c(A.name),d(null)},S=()=>{o(null),c("")},k=()=>{if(!a||!l.trim())return;const A=l.trim();if(A===a){S();return}b.mutate({oldName:a,newName:A})},T=A=>{A.key==="Enter"?(A.preventDefault(),k()):A.key==="Escape"&&(A.preventDefault(),S())},M=A=>{d(A),o(null)},C=()=>{u&&v.mutate(u)},E=m?.filter(A=>A.name.toLowerCase().includes(r.toLowerCase())).sort((A,D)=>f==="count"&&D.count-A.count||A.name.localeCompare(D.name)),R=m?.reduce((A,D)=>A+D.count,0)||0;return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(St,{className:"w-full max-w-lg max-h-[80vh] flex flex-col",children:s.jsxs(Nt,{className:"p-0 flex flex-col min-h-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yh,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:"Manage Tags"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ya,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.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)})]}),s.jsxs("select",{className:"px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",value:f,onChange:A=>p(A.target.value),children:[s.jsx("option",{value:"count",children:"Sort by Count"}),s.jsx("option",{value:"name",children:"Sort by Name"})]})]}),m&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[m.length," tag",m.length!==1?"s":""," across ",R," usage",R!==1?"s":""]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto min-h-0 p-4",children:x?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 animate-spin text-bambu-gray"})}):E?.length?s.jsx("div",{className:"space-y-2",children:E.map(A=>s.jsx("div",{className:"flex items-center gap-2 p-2 rounded-lg bg-bambu-dark hover:bg-bambu-dark-tertiary transition-colors group",children:a===A.name?s.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[s.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}),s.jsx(Te,{size:"sm",variant:"primary",onClick:k,disabled:!l.trim()||b.isPending,className:"p-1.5",children:b.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Na,{className:"w-4 h-4"})}),s.jsx(Te,{size:"sm",variant:"ghost",onClick:S,className:"p-1.5",children:s.jsx(Rt,{className:"w-4 h-4"})})]}):u===A.name?s.jsxs("div",{className:"flex-1 flex items-center gap-2",children:[s.jsx(Sn,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),s.jsxs("span",{className:"text-sm text-bambu-gray-light flex-1",children:['Delete "',A.name,'" from ',A.count," archive",A.count!==1?"s":"","?"]}),s.jsx(Te,{size:"sm",variant:"danger",onClick:C,disabled:v.isPending,className:"p-1.5",children:v.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(an,{className:"w-4 h-4"})}),s.jsx(Te,{size:"sm",variant:"ghost",onClick:()=>d(null),className:"p-1.5",children:s.jsx(Rt,{className:"w-4 h-4"})})]}):s.jsxs(s.Fragment,{children:[s.jsx(yh,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"text-white flex-1 truncate",children:A.name}),s.jsx("span",{className:"px-2 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray text-xs",children:A.count}),s.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity",children:[s.jsx("button",{onClick:()=>y(A),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-white transition-colors",title:"Rename tag",children:s.jsx(Zi,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>M(A.name),className:"p-1.5 rounded hover:bg-bambu-dark text-bambu-gray hover:text-red-400 transition-colors",title:"Delete tag",children:s.jsx(an,{className:"w-4 h-4"})})]})]})},A.name))}):s.jsx("div",{className:"text-center py-8 text-bambu-gray",children:r?"No tags match your search":"No tags found"})}),s.jsx("div",{className:"flex gap-3 p-4 border-t border-bambu-dark-tertiary flex-shrink-0",children:s.jsx(Te,{variant:"secondary",onClick:t,className:"flex-1",children:"Close"})})]})})})}function YN(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function t0(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function Cf(t){if(!t)return!1;const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function lqe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o,timeFormat:l="system",t:c}){o&&console.log("ArchiveCard isHighlighted=true for archive:",t.id);const u=sn(),{showToast:d}=Hn(),{hasPermission:f,canModify:p}=Ci(),m=IR(),[x,b]=_.useState(!1),[v,y]=_.useState(!1),[S,k]=_.useState(!1),[T,M]=_.useState(!1),[C,E]=_.useState(!1),[R,A]=_.useState(!1),[D,I]=_.useState([]),[F,z]=_.useState(!1),[P,$]=_.useState(!1),[X,V]=_.useState(!1),[Q,Z]=_.useState(!1),[se,H]=_.useState(!1),[K,re]=_.useState(!1),[ne,be]=_.useState(null),[me,de]=_.useState(null),[Ce,ie]=_.useState(!1),ke=_.useRef(null),Oe=_.useRef(null),{data:pe}=ot({queryKey:["archive-plates",t.id],queryFn:()=>ce.getArchivePlates(t.id),enabled:Ce,staleTime:300*1e3}),We=pe?.plates??[],G=pe?.is_multi_plate??!1,Y=me??0,ue=mt({mutationFn:ae=>ce.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=mt({mutationFn:()=>ce.deleteSource3mf(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.source3mfRemoved"))},onError:ae=>{d(ae.message||c("archives.toast.failedRemoveSource3mf"),"error")}}),te=mt({mutationFn:ae=>ce.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")}}),U=mt({mutationFn:()=>ce.deleteF3d(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.f3dRemoved"))},onError:ae=>{d(ae.message||c("archives.toast.failedRemoveF3d"),"error")}}),he=mt({mutationFn:()=>ce.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")}}),Me=mt({mutationFn:ae=>ce.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")}}),ge=mt({mutationFn:()=>ce.deleteArchive(t.id),onSuccess:()=>{u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.archiveDeleted"))},onError:()=>{d(c("archives.toast.failedDeleteArchive"),"error")}}),B=mt({mutationFn:()=>ce.toggleFavorite(t.id),onSuccess:ae=>{u.invalidateQueries({queryKey:["archives"]}),d(ae.is_favorite?c("archives.toast.addedToFavorites"):c("archives.toast.removedFromFavorites"))}}),{data:O}=ot({queryKey:["archive-folders",t.id],queryFn:()=>ce.getLibraryFoldersByArchive(t.id)}),ee=mt({mutationFn:ae=>ce.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(),be({x:ae.clientX,y:ae.clientY})},ve=[...Cf(t.filename)?[{label:c("archives.menu.print"),icon:s.jsx(Ur,{className:"w-4 h-4"}),onClick:()=>y(!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:s.jsx(ti,{className:"w-4 h-4"}),onClick:()=>Z(!0),disabled:!f("queue:create"),title:f("queue:create")?void 0:c("archives.permission.noAddToQueue")},{label:c("archives.menu.openInBambuStudio"),icon:s.jsx(Xr,{className:"w-4 h-4"}),onClick:()=>{const ae=t.print_name||t.filename||"model",Fe=`${window.location.origin}${ce.getArchiveForSlicer(t.id,ae)}`;pu(Fe)}}]:[{label:c("archives.menu.slice"),icon:s.jsx(Xr,{className:"w-4 h-4"}),onClick:()=>{const ae=t.print_name||t.filename||"model",Fe=`${window.location.origin}${ce.getArchiveForSlicer(t.id,ae)}`;pu(Fe)}}],{label:t.external_url?c("archives.menu.externalLink"):c("archives.menu.viewOnMakerWorld"),icon:s.jsx(sh,{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:s.jsx(oo,{className:"w-4 h-4"}),onClick:()=>b(!0)},{label:c("archives.menu.viewTimelapse"),icon:s.jsx(ah,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!t.timelapse_path},{label:c("archives.menu.scanForTimelapse"),icon:s.jsx(X1,{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:s.jsx(q1,{className:"w-4 h-4"}),onClick:()=>{t.source_3mf_path?ce.downloadSource3mf(t.id).catch(ae=>{console.error("Source 3MF download failed:",ae)}):ke.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:s.jsx(za,{className:"w-4 h-4"}),onClick:()=>ke.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:s.jsx(an,{className:"w-4 h-4"}),onClick:()=>H(!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:s.jsx(oo,{className:"w-4 h-4"}),onClick:()=>Oe.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:s.jsx(wi,{className:"w-4 h-4"}),onClick:()=>{ce.downloadF3d(t.id).catch(ae=>{console.error("F3D download failed:",ae)})}},{label:c("archives.menu.removeF3d"),icon:s.jsx(an,{className:"w-4 h-4"}),onClick:()=>re(!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:s.jsx(wi,{className:"w-4 h-4"}),onClick:()=>{ce.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(ae=>{console.error("Archive download failed:",ae)})},disabled:!f("archives:read"),title:f("archives:read")?void 0:c("archives.permission.noDownload")},{label:c("archives.menu.copyDownloadLink"),icon:s.jsx(Fl,{className:"w-4 h-4"}),onClick:()=>{const ae=`${window.location.origin}${ce.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(ae).then(()=>{d(c("archives.toast.linkCopied"))}).catch(()=>{d(c("archives.toast.failedCopyLink"),"error")})},disabled:!f("archives:read"),title:f("archives:read")?void 0:c("archives.permission.noCopyLink")},{label:c("archives.menu.qrCode"),icon:s.jsx(TW,{className:"w-4 h-4"}),onClick:()=>z(!0)},{label:t.photos?.length?c("archives.menu.viewPhotosCount",{count:t.photos.length}):c("archives.menu.viewPhotos"),icon:s.jsx(Ug,{className:"w-4 h-4"}),onClick:()=>$(!0),disabled:!t.photos?.length},{label:c("archives.menu.projectPage"),icon:s.jsx(Ls,{className:"w-4 h-4"}),onClick:()=>V(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?c("archives.menu.removeFromFavorites"):c("archives.menu.addToFavorites"),icon:s.jsx(im,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>B.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:s.jsx(Zi,{className:"w-4 h-4"}),onClick:()=>M(!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:s.jsx(Ja,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:c("archives.menu.addToProject"),icon:s.jsx(Ja,{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:s.jsx(Rt,{className:"w-4 h-4"}),onClick:()=>ee.mutate(null),disabled:!p("archives","update",t.created_by_id)}),!a)ae.push({label:c("archives.menu.loading"),icon:s.jsx(ft,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const Fe=a.filter(Be=>Be.status==="active");Fe.length===0?ae.push({label:c("archives.menu.noProjectsAvailable"),icon:s.jsx(Ja,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):Fe.forEach(Be=>{ae.push({label:Be.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Be.color||"#888"}}),onClick:()=>ee.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?s.jsx(ol,{className:"w-4 h-4"}):s.jsx(ll,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:c("archives.menu.delete"),icon:s.jsx(an,{className:"w-4 h-4"}),onClick:()=>k(!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 s.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&&s.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?s.jsx(ol,{className:"w-5 h-5 text-bambu-green"}):s.jsx(ll,{className:"w-5 h-5 text-white"})}),s.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?s.jsx("img",{src:me!==null&&We.length>0?ce.getArchivePlateThumbnail(t.id,We[Y]?.index??0):ce.getArchiveThumbnail(t.id),alt:t.print_name||t.filename,className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(Ou,{className:"w-12 h-12 text-bambu-dark-tertiary"})}),G&&We.length>1&&s.jsxs(s.Fragment,{children:[s.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(),de(Fe=>{const Be=Fe??0;return Be>0?Be-1:We.length-1})},title:c("archives.card.previousPlate"),children:s.jsx(gh,{className:"w-4 h-4 text-white"})}),s.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(),de(Fe=>{const Be=Fe??0;return Be<We.length-1?Be+1:0})},title:c("archives.card.nextPlate"),children:s.jsx(gs,{className:"w-4 h-4 text-white"})}),s.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:We.map((ae,Fe)=>s.jsx("button",{className:`w-2 h-2 rounded-full transition-colors ${Fe===Y?"bg-bambu-green":"bg-white/50 hover:bg-white/80"}`,onClick:Be=>{Be.stopPropagation(),de(Fe)},title:ae.name||c("archives.card.plateNumber",{index:ae.index})},ae.index))})]}),s.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 Fe=ae.currentTarget.getBoundingClientRect();be({x:Fe.left,y:Fe.bottom+4})},title:c("archives.card.moreOptions"),children:s.jsx(ih,{className:"w-5 h-5 text-white"})}),s.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)&&B.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:s.jsx(im,{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")&&s.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&&s.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:[s.jsx(Fl,{className:"w-3 h-3"}),c("archives.card.duplicate")]}),t.source_3mf_path&&s.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 Fe=(t.print_name||t.filename||"source").replace(/\.gcode\.3mf$/i,"")+"_source",Be=`${window.location.origin}${ce.getSource3mfForSlicer(t.id,Fe)}`;pu(Be)},title:c("archives.card.openSource3mf"),children:s.jsx(q1,{className:"w-4 h-4 text-orange-400"})}),t.f3d_path&&s.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(),ce.downloadF3d(t.id).catch(Fe=>{console.error("F3D download failed:",Fe)})},title:c("archives.card.downloadF3d"),children:s.jsx(oo,{className:"w-4 h-4 text-cyan-400"})}),t.timelapse_path&&s.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:s.jsx(ah,{className:"w-4 h-4 text-bambu-green"})}),t.photos&&t.photos.length>0&&s.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(),$(!0)},title:t.photos.length===1?c("archives.card.viewPhoto"):c("archives.card.viewPhotos",{count:t.photos.length}),children:[s.jsx(Ug,{className:"w-4 h-4 text-blue-400"}),t.photos.length>1&&s.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&&s.jsx(Ds,{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:s.jsx(Il,{className:"w-4 h-4 text-yellow-400"})})]}),s.jsxs(Nt,{className:"p-4 flex-1 flex flex-col",children:[s.jsx("h3",{className:"font-medium text-white mb-1 truncate",children:t.print_name||t.filename}),s.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:e}),s.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${Cf(t.filename)?"bg-bambu-green/20 text-bambu-green":"bg-orange-500/20 text-orange-400"}`,title:Cf(t.filename)?c("archives.card.slicedFile"):c("archives.card.sourceFile"),children:Cf(t.filename)?c("archives.card.gcode"):c("archives.card.source")}),t.project_name&&s.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full truncate max-w-[120px]",style:{backgroundColor:`${a?.find(ae=>ae.id===t.project_id)?.color||"#6b7280"}20`,color:a?.find(ae=>ae.id===t.project_id)?.color||"#6b7280"},title:c("archives.card.project",{name:t.project_name}),children:t.project_name})]}),s.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)&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:t.time_accuracy?`Estimated: ${t0(t.print_time_seconds||0)}
- Actual: ${t0(t.actual_time_seconds||0)}
- Accuracy: ${t.time_accuracy.toFixed(0)}%`:t.actual_time_seconds?`Actual: ${t0(t.actual_time_seconds)}`:`Estimated: ${t0(t.print_time_seconds||0)}`,children:[s.jsx(tr,{className:"w-3 h-3"}),t0(t.actual_time_seconds||t.print_time_seconds||0),t.time_accuracy&&s.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&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(pc,{className:"w-3 h-3"}),t.filament_used_grams.toFixed(1),"g"]}),(t.layer_height||t.total_layers)&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(sl,{className:"w-3 h-3"}),t.total_layers&&s.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&&s.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.layer_height&&s.jsxs("span",{children:[t.layer_height,"mm"]})]}),t.object_count!=null&&t.object_count>0&&s.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:[s.jsx(oo,{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&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",title:c("archives.card.slicedFor",{model:t.sliced_for_model}),children:[s.jsx(Ur,{className:"w-3 h-3"}),t.sliced_for_model]}),t.filament_type&&s.jsxs("div",{className:"flex items-center gap-1.5 col-span-2",children:[s.jsx("span",{className:"text-bambu-gray text-xs",children:t.filament_type}),t.filament_color&&s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((ae,Fe)=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:ae},title:ae},Fe))})]})]}),(t.tags||t.notes)&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mb-3",children:[t.notes&&s.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:s.jsx(CW,{className:"w-3 h-3"})}),t.tags?.split(",").map((ae,Fe)=>s.jsx("span",{className:"px-1.5 py-0.5 bg-bambu-dark-tertiary text-bambu-gray-light rounded text-xs",children:ae.trim()},Fe))]}),s.jsx("div",{className:"flex-1"}),s.jsxs("div",{className:"flex items-center justify-between text-xs text-bambu-gray border-t border-bambu-dark-tertiary pt-3",children:[s.jsx("span",{children:Hg(t.created_at,l)}),s.jsxs("div",{className:"flex items-center gap-2",children:[t.created_by_username&&s.jsxs("span",{className:"flex items-center gap-1",title:c("archives.card.uploadedBy",{name:t.created_by_username}),children:[s.jsx(am,{className:"w-3 h-3"}),t.created_by_username]}),s.jsx("span",{children:YN(t.file_size)})]})]}),s.jsxs("div",{className:"flex gap-1 mt-3",children:[Cf(t.filename)?s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>y(!0),disabled:!p("archives","reprint",t.created_by_id),title:p("archives","reprint",t.created_by_id)?void 0:c("archives.card.noPermissionReprint"),children:[s.jsx(Ur,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:c("archives.card.reprint")})]}),s.jsxs(Te,{variant:"secondary",size:"sm",className:"flex-1 min-w-0",onClick:()=>Z(!0),disabled:!f("queue:create"),title:f("queue:create")?c("archives.card.schedulePrint"):c("archives.permission.noAddToQueue"),children:[s.jsx(ti,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:c("archives.card.schedule")})]}),s.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{const ae=t.print_name||t.filename||"model",Fe=`${window.location.origin}${ce.getArchiveForSlicer(t.id,ae)}`;pu(Fe)},title:c("archives.card.openInBambuStudio"),children:s.jsx(Xr,{className:"w-3 h-3 sm:w-4 sm:h-4"})})]}):s.jsxs(Te,{variant:"primary",size:"sm",className:"flex-1 min-w-0",onClick:()=>{const ae=t.print_name||t.filename||"model",Fe=`${window.location.origin}${ce.getArchiveForSlicer(t.id,ae)}`;pu(Fe)},title:c("archives.card.openInBambuStudioToSlice"),children:[s.jsx(Xr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"hidden sm:inline",children:c("archives.card.slice")})]}),s.jsx(Te,{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:s.jsx(sh,{className:`w-3 h-3 sm:w-4 sm:h-4 ${!t.external_url&&!t.makerworld_url?"opacity-20":""}`})}),s.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>b(!0),title:c("archives.card.preview3d"),children:s.jsx(oo,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Te,{variant:"secondary",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>{ce.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(ae=>{console.error("Archive download failed:",ae)})},title:c("archives.card.download"),children:s.jsx(wi,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>M(!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:s.jsx(Zi,{className:"w-3 h-3 sm:w-4 sm:h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",className:"min-w-0 p-1 sm:p-1.5",onClick:()=>k(!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:s.jsx(an,{className:"w-3 h-3 sm:w-4 sm:h-4 text-red-400"})})]})]}),T&&s.jsx(See,{archive:t,onClose:()=>M(!1)}),x&&s.jsx(yee,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>b(!1)}),v&&s.jsx(Ph,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>y(!1)}),S&&s.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:()=>{ge.mutate(),k(!1)},onCancel:()=>k(!1)}),se&&s.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(),H(!1)},onCancel:()=>H(!1)}),K&&s.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:()=>{U.mutate(),re(!1)},onCancel:()=>re(!1)}),ne&&s.jsx(Nee,{x:ne.x,y:ne.y,items:ve,onClose:()=>be(null)}),C&&t.timelapse_path&&s.jsx(cre,{src:ce.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)}}),R&&D.length>0&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),s.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),s.jsx("button",{onClick:()=>{A(!1),I([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:D.map(ae=>s.jsxs("button",{onClick:()=>Me.mutate(ae.name),disabled:Me.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:[s.jsx(ah,{className:"w-8 h-8 text-bambu-green flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:ae.name}),s.jsxs("p",{className:"text-sm text-gray-400",children:[YN(ae.size),ae.mtime&&` • ${Hg(ae.mtime,l)}`]})]})]},ae.name))}),s.jsx("div",{className:"p-4 border-t border-gray-700",children:s.jsx(Te,{variant:"secondary",onClick:()=>{A(!1),I([])},className:"w-full",children:"Cancel"})})]})}),F&&s.jsx(Mee,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>z(!1)}),P&&t.photos&&t.photos.length>0&&s.jsx(kee,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>$(!1),onDelete:async ae=>{try{await ce.deleteArchivePhoto(t.id,ae),u.invalidateQueries({queryKey:["archives"]}),d(c("archives.toast.photoDeleted"))}catch{d(c("archives.toast.failedDeletePhoto"),"error")}}}),X&&s.jsx(lre,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>V(!1)}),Q&&s.jsx(Ph,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>Z(!1)}),s.jsx("input",{ref:ke,type:"file",accept:".3mf",className:"hidden",onChange:ae=>{const Fe=ae.target.files?.[0];Fe&&ue.mutate(Fe),ae.target.value=""}}),s.jsx("input",{ref:Oe,type:"file",accept:".f3d",className:"hidden",onChange:ae=>{const Fe=ae.target.files?.[0];Fe&&te.mutate(Fe),ae.target.value=""}})]})}function cqe({archive:t,printerName:e,isSelected:n,onSelect:r,selectionMode:i,projects:a,isHighlighted:o,t:l}){const c=sn(),{showToast:u}=Hn(),{hasPermission:d,canModify:f}=Ci(),[p,m]=_.useState(!1),[x,b]=_.useState(!1),[v,y]=_.useState(!1),[S,k]=_.useState(!1),[T,M]=_.useState(!1),[C,E]=_.useState(!1),[R,A]=_.useState(!1),[D,I]=_.useState([]),[F,z]=_.useState(!1),[P,$]=_.useState(!1),[X,V]=_.useState(!1),[Q,Z]=_.useState(!1),[se,H]=_.useState(!1),[K,re]=_.useState(null),ne=_.useRef(null),be=_.useRef(null),me=mt({mutationFn:U=>ce.uploadSource3mf(t.id,U),onSuccess:U=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.source3mfAttached",{filename:U.filename}))},onError:U=>{u(U.message||l("archives.toast.failedUploadSource3mf"),"error")}}),de=mt({mutationFn:()=>ce.deleteSource3mf(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.source3mfRemoved"))},onError:U=>{u(U.message||l("archives.toast.failedRemoveSource3mf"),"error")}}),Ce=mt({mutationFn:U=>ce.uploadF3d(t.id,U),onSuccess:U=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.f3dAttached",{filename:U.filename}))},onError:U=>{u(U.message||l("archives.toast.failedUploadF3d"),"error")}}),ie=mt({mutationFn:()=>ce.deleteF3d(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.f3dRemoved"))},onError:U=>{u(U.message||l("archives.toast.failedRemoveF3d"),"error")}}),ke=mt({mutationFn:()=>ce.scanArchiveTimelapse(t.id),onSuccess:U=>{U.status==="attached"?(c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.timelapseAttached",{filename:U.filename}))):U.status==="exists"?u(l("archives.toast.timelapseAlreadyAttached")):U.status==="not_found"&&U.available_files&&U.available_files.length>0?(I(U.available_files),A(!0)):u(U.message||l("archives.toast.noMatchingTimelapse"),"warning")},onError:U=>{u(U.message||l("archives.toast.failedScanTimelapse"),"error")}}),Oe=mt({mutationFn:U=>ce.selectArchiveTimelapse(t.id,U),onSuccess:U=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.timelapseAttached",{filename:U.filename})),A(!1),I([])},onError:U=>{u(U.message||l("archives.toast.failedAttachTimelapse"),"error")}}),pe=mt({mutationFn:()=>ce.deleteArchive(t.id),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.archiveDeleted"))},onError:()=>{u(l("archives.toast.failedDeleteArchive"),"error")}}),We=mt({mutationFn:()=>ce.toggleFavorite(t.id),onSuccess:U=>{c.invalidateQueries({queryKey:["archives"]}),u(U.is_favorite?l("archives.toast.addedToFavorites"):l("archives.toast.removedFromFavorites"))}}),{data:G}=ot({queryKey:["archive-folders",t.id],queryFn:()=>ce.getLibraryFoldersByArchive(t.id)}),Y=mt({mutationFn:U=>ce.updateArchive(t.id,{project_id:U}),onSuccess:()=>{c.invalidateQueries({queryKey:["archives"]}),c.invalidateQueries({queryKey:["projects"]}),u(l("archives.toast.projectUpdated"))},onError:()=>{u(l("archives.toast.failedUpdateProject"),"error")}}),ue=U=>{U.preventDefault(),re({x:U.clientX,y:U.clientY})},te=[...Cf(t.filename)?[{label:l("archives.menu.print"),icon:s.jsx(Ur,{className:"w-4 h-4"}),onClick:()=>y(!0),disabled:!f("archives","reprint",t.created_by_id),title:f("archives","reprint",t.created_by_id)?void 0:l("archives.permission.noReprint")},{label:l("archives.menu.schedule"),icon:s.jsx(ti,{className:"w-4 h-4"}),onClick:()=>k(!0),disabled:!d("queue:create"),title:d("queue:create")?void 0:l("archives.permission.noAddToQueue")},{label:l("archives.menu.openInBambuStudio"),icon:s.jsx(Xr,{className:"w-4 h-4"}),onClick:()=>{const U=t.print_name||t.filename||"model",he=`${window.location.origin}${ce.getArchiveForSlicer(t.id,U)}`;pu(he)}}]:[{label:l("archives.menu.slice"),icon:s.jsx(Xr,{className:"w-4 h-4"}),onClick:()=>{const U=t.print_name||t.filename||"model",he=`${window.location.origin}${ce.getArchiveForSlicer(t.id,U)}`;pu(he)}}],{label:t.external_url?l("archives.menu.externalLink"):l("archives.menu.viewOnMakerWorld"),icon:s.jsx(sh,{className:"w-4 h-4"}),onClick:()=>{const U=t.external_url||t.makerworld_url;U&&window.open(U,"_blank")},disabled:!t.external_url&&!t.makerworld_url},{label:"",divider:!0,onClick:()=>{}},{label:l("archives.menu.preview3d"),icon:s.jsx(oo,{className:"w-4 h-4"}),onClick:()=>M(!0)},{label:l("archives.menu.viewTimelapse"),icon:s.jsx(ah,{className:"w-4 h-4"}),onClick:()=>E(!0),disabled:!t.timelapse_path},{label:l("archives.menu.scanForTimelapse"),icon:s.jsx(X1,{className:"w-4 h-4"}),onClick:()=>ke.mutate(),disabled:!t.printer_id||!!t.timelapse_path||ke.isPending||!f("archives","update",t.created_by_id),title:f("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:s.jsx(q1,{className:"w-4 h-4"}),onClick:()=>{t.source_3mf_path?ce.downloadSource3mf(t.id).catch(U=>{console.error("Source 3MF download failed:",U)}):ne.current?.click()},disabled:!t.source_3mf_path&&!f("archives","update",t.created_by_id),title:!t.source_3mf_path&&!f("archives","update",t.created_by_id)?l("archives.permission.noUploadFiles"):void 0},...t.source_3mf_path?[{label:l("archives.menu.replaceSource3mf"),icon:s.jsx(za,{className:"w-4 h-4"}),onClick:()=>ne.current?.click(),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},{label:l("archives.menu.removeSource3mf"),icon:s.jsx(an,{className:"w-4 h-4"}),onClick:()=>Z(!0),danger:!0,disabled:!f("archives","update",t.created_by_id),title:f("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:s.jsx(oo,{className:"w-4 h-4"}),onClick:()=>be.current?.click(),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},...t.f3d_path?[{label:l("archives.menu.downloadF3d"),icon:s.jsx(wi,{className:"w-4 h-4"}),onClick:()=>{ce.downloadF3d(t.id).catch(U=>{console.error("F3D download failed:",U)})}},{label:l("archives.menu.removeF3d"),icon:s.jsx(an,{className:"w-4 h-4"}),onClick:()=>H(!0),danger:!0,disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")}]:[],{label:"",divider:!0,onClick:()=>{}},{label:l("archives.menu.download"),icon:s.jsx(wi,{className:"w-4 h-4"}),onClick:()=>{ce.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(U=>{console.error("Archive download failed:",U)})},disabled:!d("archives:read"),title:d("archives:read")?void 0:l("archives.permission.noDownload")},{label:l("archives.menu.copyDownloadLink"),icon:s.jsx(Fl,{className:"w-4 h-4"}),onClick:()=>{const U=`${window.location.origin}${ce.getArchiveDownload(t.id)}`;navigator.clipboard.writeText(U).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:s.jsx(TW,{className:"w-4 h-4"}),onClick:()=>z(!0)},{label:t.photos?.length?l("archives.menu.viewPhotosCount",{count:t.photos.length}):l("archives.menu.viewPhotos"),icon:s.jsx(Ug,{className:"w-4 h-4"}),onClick:()=>$(!0),disabled:!t.photos?.length},{label:l("archives.menu.projectPage"),icon:s.jsx(Ls,{className:"w-4 h-4"}),onClick:()=>V(!0)},{label:"",divider:!0,onClick:()=>{}},{label:t.is_favorite?l("archives.menu.removeFromFavorites"):l("archives.menu.addToFavorites"),icon:s.jsx(im,{className:`w-4 h-4 ${t.is_favorite?"fill-yellow-400 text-yellow-400":""}`}),onClick:()=>We.mutate(),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?void 0:l("archives.permission.noUpdateArchives")},{label:l("archives.menu.edit"),icon:s.jsx(Zi,{className:"w-4 h-4"}),onClick:()=>m(!0),disabled:!f("archives","update",t.created_by_id),title:f("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:s.jsx(Ja,{className:"w-4 h-4 text-bambu-green"}),onClick:()=>window.location.href="/projects"}]:[],{label:l("archives.menu.addToProject"),icon:s.jsx(Ja,{className:"w-4 h-4"}),onClick:()=>{},submenu:(()=>{const U=[];if(t.project_id&&U.push({label:l("archives.menu.removeFromProject"),icon:s.jsx(Rt,{className:"w-4 h-4"}),onClick:()=>Y.mutate(null)}),!a)U.push({label:l("archives.menu.loading"),icon:s.jsx(ft,{className:"w-4 h-4 animate-spin"}),onClick:()=>{},disabled:!0});else{const he=a.filter(Me=>Me.status==="active");he.length===0?U.push({label:l("archives.menu.noProjectsAvailable"),icon:s.jsx(Ja,{className:"w-4 h-4 opacity-50"}),onClick:()=>{},disabled:!0}):he.forEach(Me=>{U.push({label:Me.name,icon:s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:Me.color||"#888"}}),onClick:()=>Y.mutate(Me.id),disabled:t.project_id===Me.id})})}return U})()},{label:l(n?"archives.menu.deselect":"archives.menu.select"),icon:n?s.jsx(ol,{className:"w-4 h-4"}):s.jsx(ll,{className:"w-4 h-4"}),onClick:()=>r(t.id)},{label:"",divider:!0,onClick:()=>{}},{label:l("archives.menu.delete"),icon:s.jsx(an,{className:"w-4 h-4"}),onClick:()=>b(!0),danger:!0,disabled:!f("archives","delete",t.created_by_id),title:f("archives","delete",t.created_by_id)?void 0:l("archives.permission.noDelete")}];return s.jsxs(s.Fragment,{children:[s.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:ue,children:[s.jsxs("div",{className:"col-span-1 flex items-center gap-2",children:[i&&s.jsx("button",{onClick:()=>r(t.id),children:n?s.jsx(ol,{className:"w-4 h-4 text-bambu-green"}):s.jsx(ll,{className:"w-4 h-4 text-bambu-gray"})}),t.thumbnail_path?s.jsx("img",{src:ce.getArchiveThumbnail(t.id),alt:"",className:"w-10 h-10 object-cover rounded"}):s.jsx("div",{className:"w-10 h-10 bg-bambu-dark rounded flex items-center justify-center",children:s.jsx(Ou,{className:"w-5 h-5 text-bambu-dark-tertiary"})})]}),s.jsxs("div",{className:"col-span-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("p",{className:"text-white text-sm truncate",children:t.print_name||t.filename}),t.timelapse_path&&s.jsx("span",{title:l("archives.list.hasTimelapse"),children:s.jsx(ah,{className:"w-3.5 h-3.5 text-bambu-green flex-shrink-0"})}),G&&G.length>0&&s.jsx(Ds,{to:`/files?folder=${G[0].id}`,className:"flex-shrink-0",title:l("archives.card.openFolder",{name:G[0].name}),onClick:U=>U.stopPropagation(),children:s.jsx(Il,{className:"w-3.5 h-3.5 text-yellow-400"})})]}),(t.filament_type||t.sliced_for_model)&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.sliced_for_model&&s.jsxs("span",{className:"text-xs text-bambu-gray flex items-center gap-1",title:l("archives.card.slicedFor",{model:t.sliced_for_model}),children:[s.jsx(Ur,{className:"w-2.5 h-2.5"}),t.sliced_for_model]}),t.sliced_for_model&&t.filament_type&&s.jsx("span",{className:"text-bambu-gray/50",children:"·"}),t.filament_type&&s.jsx("span",{className:"text-xs text-bambu-gray",children:t.filament_type}),t.filament_color&&s.jsx("div",{className:"flex items-center gap-0.5 flex-wrap",children:t.filament_color.split(",").map((U,he)=>s.jsx("div",{className:"w-2.5 h-2.5 rounded-full border border-white/20",style:{backgroundColor:U},title:U},he))})]})]}),s.jsx("div",{className:"col-span-2 text-sm text-bambu-gray truncate",children:e}),s.jsxs("div",{className:"col-span-2 text-sm text-bambu-gray",children:[s.jsx("div",{children:Bg(t.created_at)}),t.created_by_username&&s.jsxs("div",{className:"flex items-center gap-1 text-xs opacity-75",title:l("archives.card.uploadedBy",{name:t.created_by_username}),children:[s.jsx(am,{className:"w-3 h-3"}),t.created_by_username]})]}),s.jsx("div",{className:"col-span-1 text-sm text-bambu-gray",children:YN(t.file_size)}),s.jsxs("div",{className:"col-span-2 flex justify-end gap-1",children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{const U=t.print_name||t.filename||"model",he=`${window.location.origin}${ce.getArchiveForSlicer(t.id,U)}`;pu(he)},title:l("archives.card.openInBambuStudio"),children:s.jsx(Xr,{className:"w-4 h-4"})}),(t.external_url||t.makerworld_url)&&s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>window.open(t.external_url||t.makerworld_url,"_blank"),title:t.external_url?l("archives.card.externalLink"):"MakerWorld",children:s.jsx(sh,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{ce.downloadArchive(t.id,`${t.print_name||t.filename}.3mf`).catch(U=>{console.error("Archive download failed:",U)})},title:l("archives.card.download"),children:s.jsx(wi,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>m(!0),disabled:!f("archives","update",t.created_by_id),title:f("archives","update",t.created_by_id)?l("archives.card.edit"):l("archives.card.noPermissionEdit"),children:s.jsx(Zi,{className:"w-4 h-4"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>b(!0),disabled:!f("archives","delete",t.created_by_id),title:f("archives","delete",t.created_by_id)?l("archives.card.delete"):l("archives.card.noPermissionDelete"),children:s.jsx(an,{className:"w-4 h-4 text-red-400"})}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:U=>{const he=U.currentTarget.getBoundingClientRect();re({x:he.left,y:he.bottom+4})},title:l("archives.card.moreOptions"),children:s.jsx(ih,{className:"w-4 h-4"})})]})]}),p&&s.jsx(See,{archive:t,onClose:()=>m(!1)}),T&&s.jsx(yee,{archiveId:t.id,title:t.print_name||t.filename,onClose:()=>M(!1)}),v&&s.jsx(Ph,{mode:"reprint",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>y(!1)}),x&&s.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:()=>{pe.mutate(),b(!1)},onCancel:()=>b(!1)}),Q&&s.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:()=>{de.mutate(),Z(!1)},onCancel:()=>Z(!1)}),se&&s.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(),H(!1)},onCancel:()=>H(!1)}),K&&s.jsx(Nee,{x:K.x,y:K.y,items:te,onClose:()=>re(null)}),C&&t.timelapse_path&&s.jsx(cre,{src:ce.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)}}),R&&D.length>0&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-card-dark rounded-lg max-w-lg w-full max-h-[80vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-700",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Select Timelapse"}),s.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"No auto-match found. Select the timelapse for this print:"})]}),s.jsx("button",{onClick:()=>{A(!1),I([])},className:"text-gray-400 hover:text-white p-1",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"overflow-y-auto flex-1 p-2",children:D.map(U=>s.jsxs("button",{onClick:()=>Oe.mutate(U.name),disabled:Oe.isPending,className:"w-full text-left p-3 rounded-lg hover:bg-gray-700 transition-colors mb-1",children:[s.jsx("div",{className:"font-medium text-white",children:U.name}),s.jsxs("div",{className:"text-sm text-gray-400 flex gap-3",children:[s.jsx("span",{children:YN(U.size)}),U.mtime&&s.jsx("span",{children:Bg(U.mtime)})]})]},U.name))})]})}),F&&s.jsx(Mee,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>z(!1)}),P&&t.photos&&s.jsx(kee,{archiveId:t.id,archiveName:t.print_name||t.filename,photos:t.photos,onClose:()=>$(!1),onDelete:async U=>{try{await ce.deleteArchivePhoto(t.id,U),c.invalidateQueries({queryKey:["archives"]}),u(l("archives.toast.photoDeleted"))}catch{u(l("archives.toast.failedDeletePhoto"),"error")}}}),X&&s.jsx(lre,{archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>V(!1)}),S&&s.jsx(Ph,{mode:"add-to-queue",archiveId:t.id,archiveName:t.print_name||t.filename,onClose:()=>k(!1)}),s.jsx("input",{ref:ne,type:"file",accept:".3mf",className:"hidden",onChange:U=>{const he=U.target.files?.[0];he&&me.mutate(he),U.target.value=""}}),s.jsx("input",{ref:be,type:"file",accept:".f3d",className:"hidden",onChange:U=>{const he=U.target.files?.[0];he&&Ce.mutate(he),U.target.value=""}})]})}const uqe=[{id:"all",label:"All Archives",icon:s.jsx(Il,{className:"w-4 h-4"})},{id:"recent",label:"Last 24 Hours",icon:s.jsx(tr,{className:"w-4 h-4"})},{id:"this-week",label:"This Week",icon:s.jsx(ti,{className:"w-4 h-4"})},{id:"this-month",label:"This Month",icon:s.jsx(ti,{className:"w-4 h-4"})},{id:"favorites",label:"Favorites",icon:s.jsx(im,{className:"w-4 h-4"})},{id:"failed",label:"Failed Prints",icon:s.jsx($i,{className:"w-4 h-4"})},{id:"duplicates",label:"Duplicates",icon:s.jsx(Fl,{className:"w-4 h-4"})}];function dqe(){const{t}=Rn(),e=sn(),{showToast:n}=Hn(),{hasPermission:r,hasAnyPermission:i}=Ci(),a=_.useRef(null),[o,l]=_.useState(""),[c,u]=_.useState(()=>{const W=localStorage.getItem("archiveFilterPrinter");return W?Number(W):null}),[d,f]=_.useState(()=>localStorage.getItem("archiveFilterMaterial")),[p,m]=_.useState(()=>{const W=localStorage.getItem("archiveFilterColors");return W?new Set(JSON.parse(W)):new Set}),[x,b]=_.useState(()=>localStorage.getItem("archiveColorFilterMode")||"or"),[v,y]=_.useState(()=>localStorage.getItem("archiveFilterFavorites")==="true"),[S,k]=_.useState(()=>localStorage.getItem("archiveHideFailed")==="true"),[T,M]=_.useState(()=>localStorage.getItem("archiveFilterTag")),[C,E]=_.useState(()=>localStorage.getItem("archiveFilterFileType")||"all"),[R,A]=_.useState(!1),[D,I]=_.useState([]),[F,z]=_.useState(!1),[P,$]=_.useState(new Set),[X,V]=_.useState(!1),[Q,Z]=_.useState(!1),[se,H]=_.useState(!1),[K,re]=_.useState(!1),[ne,be]=_.useState(()=>localStorage.getItem("archiveViewMode")||"grid"),[me,de]=_.useState(()=>localStorage.getItem("archiveSortBy")||"date-desc"),[Ce,ie]=_.useState(()=>localStorage.getItem("archiveCollection")||"all"),[ke,Oe]=_.useState(!1),[pe,We]=_.useState(!1),[G,Y]=_.useState(!1),[ue,q]=_.useState(!1),[te,U]=_.useState(null);_.useEffect(()=>{if(te){const W=setTimeout(()=>{const Ye=document.querySelector(`[data-archive-id="${te}"]`);Ye&&Ye.scrollIntoView({behavior:"smooth",block:"center"})},100),je=setTimeout(()=>U(null),5e3);return()=>{clearTimeout(W),clearTimeout(je)}}},[te]);const{data:he,isLoading:Me}=ot({queryKey:["archives",c],queryFn:()=>ce.getArchives(c||void 0)}),{data:ge}=ot({queryKey:["printers"],queryFn:ce.getPrinters}),{data:B}=ot({queryKey:["projects"],queryFn:()=>ce.getProjects()}),{data:O}=ot({queryKey:["settings"],queryFn:ce.getSettings}),ee=O?.time_format||"system",le=mt({mutationFn:async W=>(await Promise.all(W.map(je=>ce.deleteArchive(je))),W.length),onSuccess:W=>{e.invalidateQueries({queryKey:["archives"]}),$(new Set),n(`${W} archive${W!==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",ne)},[ne]),_.useEffect(()=>{localStorage.setItem("archiveSortBy",me)},[me]),_.useEffect(()=>{localStorage.setItem("archiveCollection",Ce)},[Ce]);const _e=new Map(ge?.map(W=>[W.id,W.name])||[]),ve=[...new Set(he?.flatMap(W=>W.filament_type?.split(", ")||[]).filter(Boolean)||[])].sort(),ae=[...new Set(he?.flatMap(W=>W.filament_color?.split(",")||[]).filter(Boolean)||[])],Fe=[...new Set(he?.flatMap(W=>W.tags?.split(",").map(je=>je.trim())||[]).filter(Boolean)||[])].sort(),Be=he?.filter(W=>{const je=new Date,Ye=Ui(W.created_at)||new Date(0);let bt=!0;switch(Ce){case"recent":bt=je.getTime()-Ye.getTime()<1440*60*1e3;break;case"this-week":bt=je.getTime()-Ye.getTime()<10080*60*1e3;break;case"this-month":bt=Ye.getMonth()===je.getMonth()&&Ye.getFullYear()===je.getFullYear();break;case"favorites":bt=W.is_favorite===!0;break;case"failed":bt=W.status==="failed"||W.status==="aborted";break;case"duplicates":bt=W.duplicate_count>0;break}const pt=(W.print_name||W.filename).toLowerCase().includes(o.toLowerCase()),Bt=!d||W.filament_type?.split(", ").includes(d),Lt=W.filament_color?.split(",")||[],vn=p.size===0||(x==="or"?Lt.some(Gn=>p.has(Gn)):[...p].every(Gn=>Lt.includes(Gn))),cn=Ce==="favorites"||!v||W.is_favorite,rr=Ce==="failed"||!S||W.status!=="failed"&&W.status!=="aborted",Vn=W.tags?.split(",").map(Gn=>Gn.trim())||[],Jn=!T||Vn.includes(T),gn=Cf(W.filename);return bt&&pt&&Bt&&vn&&cn&&rr&&Jn&&(C==="all"||C==="gcode"&&gn||C==="source"&&!gn)}).sort((W,je)=>{switch(me){case"date-desc":return(Ui(je.created_at)?.getTime()||0)-(Ui(W.created_at)?.getTime()||0);case"date-asc":return(Ui(W.created_at)?.getTime()||0)-(Ui(je.created_at)?.getTime()||0);case"name-asc":return(W.print_name||W.filename).localeCompare(je.print_name||je.filename);case"name-desc":return(je.print_name||je.filename).localeCompare(W.print_name||W.filename);case"size-desc":return je.file_size-W.file_size;case"size-asc":return W.file_size-je.file_size;default:return 0}}),$e=X||P.size>0,He=W=>{$(je=>{const Ye=new Set(je);return Ye.has(W)?Ye.delete(W):Ye.add(W),Ye})},xe=()=>{Be&&$(new Set(Be.map(W=>W.id)))},Pe=()=>{$(new Set),V(!1)},ze=W=>{m(je=>{const Ye=new Set(je);return Ye.has(W)?Ye.delete(W):Ye.add(W),Ye})},we=()=>{m(new Set)},Xe=()=>{l(""),u(null),f(null),y(!1),k(!1),M(null),E("all")},Ne=o||c||d||v||S||T||C!=="all",rt=_.useCallback(W=>{W.preventDefault(),W.dataTransfer.types.includes("Files")&&z(!0)},[]),Ee=_.useCallback(W=>{W.preventDefault(),W.currentTarget===W.target&&z(!1)},[]),Ke=_.useCallback(W=>{W.preventDefault(),z(!1);const je=Array.from(W.dataTransfer.files).filter(Ye=>Ye.name.endsWith(".3mf"));je.length>0?(I(je),A(!0)):W.dataTransfer.files.length>0&&n(t("archives.page.only3mfSupported"),"warning")},[n,t]),Ue=_.useCallback(W=>{const je=W.target;if(je.tagName==="INPUT"||je.tagName==="TEXTAREA"||je.isContentEditable){W.key==="Escape"&&je.blur();return}switch(W.key){case"/":W.preventDefault(),a.current?.focus();break;case"u":case"U":!W.metaKey&&!W.ctrlKey&&(W.preventDefault(),A(!0));break;case"Escape":$e&&Pe();break}},[$e]);return _.useEffect(()=>(document.addEventListener("keydown",Ue),()=>document.removeEventListener("keydown",Ue)),[Ue]),s.jsxs("div",{className:"p-4 md:p-8 relative min-h-full",onDragOver:rt,onDragLeave:Ee,onDrop:Ke,children:[F&&s.jsx("div",{className:"fixed inset-0 z-50 bg-bambu-dark/90 flex items-center justify-center pointer-events-none",children:s.jsxs("div",{className:"border-4 border-dashed border-bambu-green rounded-xl p-12 text-center",children:[s.jsx(za,{className:"w-16 h-16 mx-auto mb-4 text-bambu-green"}),s.jsx("p",{className:"text-2xl font-semibold text-white mb-2",children:"Drop .3mf files here"}),s.jsx("p",{className:"text-bambu-gray",children:t("archives.releaseToUpload")})]})}),$e&&s.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:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:Pe,children:[s.jsx(Rt,{className:"w-4 h-4"}),"Close"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs("span",{className:"text-white font-medium",children:[P.size," selected"]}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:xe,children:"Select All"}),s.jsx("div",{className:"w-px h-6 bg-bambu-dark-tertiary"}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>H(!0),disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),children:[s.jsx(yh,{className:"w-4 h-4"}),"Tags"]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>re(!0),disabled:!i("archives:update_own","archives:update_all"),title:i("archives:update_own","archives:update_all")?void 0:t("archives.permission.noUpdateArchives"),children:[s.jsx(Ja,{className:"w-4 h-4"}),"Project"]}),s.jsxs(Te,{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 W=Array.from(P);Promise.all(W.map(je=>ce.toggleFavorite(je))).then(()=>{e.invalidateQueries({queryKey:["archives"]}),n(`Toggled favorites for ${W.length} archive${W.length!==1?"s":""}`)}).catch(()=>{n(t("archives.toast.failedUpdateFavorites"),"error")})},children:[s.jsx(im,{className:"w-4 h-4"}),"Favorite"]}),s.jsxs(Te,{size:"sm",className:"bg-red-500 hover:bg-red-600",onClick:()=>Z(!0),disabled:!i("archives:delete_own","archives:delete_all"),title:i("archives:delete_own","archives:delete_all")?void 0:t("archives.permission.noDelete"),children:[s.jsx(an,{className:"w-4 h-4"}),"Delete"]})]}),s.jsxs("div",{className:"flex items-center justify-between mb-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:"Archives"}),s.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:Ce,onChange:W=>ie(W.target.value),children:uqe.map(W=>s.jsx("option",{value:W.id,children:W.label},W.id))})]}),s.jsxs("p",{className:"text-bambu-gray",children:[Be?.length||0," of ",he?.length||0," prints"]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsxs(Te,{variant:"secondary",onClick:()=>Oe(!ke),disabled:pe,children:[pe?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(W1,{className:"w-4 h-4"}),"Export"]}),ke&&s.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:[s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-t-lg",onClick:async()=>{Oe(!1),We(!0);try{const{blob:W,filename:je}=await ce.exportArchives({format:"csv",printerId:c||void 0,status:Ce==="failed"?"failed":void 0,search:o||void 0}),Ye=URL.createObjectURL(W),bt=document.createElement("a");bt.href=Ye,bt.download=je,bt.click(),URL.revokeObjectURL(Ye),n(t("archives.toast.exportDownloaded"))}catch{n(t("archives.toast.exportFailed"),"error")}finally{We(!1)}},children:[s.jsx(Ls,{className:"w-4 h-4"}),"Export as CSV"]}),s.jsxs("button",{className:"w-full px-4 py-2 text-left text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center gap-2 rounded-b-lg",onClick:async()=>{Oe(!1),We(!0);try{const{blob:W,filename:je}=await ce.exportArchives({format:"xlsx",printerId:c||void 0,status:Ce==="failed"?"failed":void 0,search:o||void 0}),Ye=URL.createObjectURL(W),bt=document.createElement("a");bt.href=Ye,bt.download=je,bt.click(),URL.revokeObjectURL(Ye),n(t("archives.toast.exportDownloaded"))}catch{n(t("archives.toast.exportFailed"),"error")}finally{We(!1)}},children:[s.jsx(W1,{className:"w-4 h-4"}),"Export as Excel"]})]})]}),P.size>=2&&P.size<=5&&s.jsxs(Te,{variant:"secondary",onClick:()=>Y(!0),children:[s.jsx(_g,{className:"w-4 h-4"}),"Compare (",P.size,")"]}),!$e&&s.jsxs(Te,{variant:"secondary",onClick:()=>V(!0),children:[s.jsx(ol,{className:"w-4 h-4"}),"Select"]}),s.jsxs(Te,{onClick:()=>A(!0),disabled:!r("archives:create"),title:r("archives:create")?void 0:t("archives.permission.noCreate"),children:[s.jsx(za,{className:"w-4 h-4"}),"Upload 3MF"]})]})]}),s.jsx(St,{className:"mb-6",children:s.jsxs(Nt,{className:"py-4",children:[s.jsxs("div",{className:"flex flex-col md:flex-row gap-3 md:gap-4 md:items-center md:flex-wrap",children:[s.jsxs("div",{className:"w-full md:flex-1 relative md:min-w-[200px]",children:[s.jsx(ya,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{ref:a,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:W=>l(W.target.value)})]}),s.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:[s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(dM,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:W=>u(W.target.value?Number(W.target.value):null),children:[s.jsx("option",{value:"",children:"All Printers"}),ge?.map(W=>s.jsx("option",{value:W.id,children:W.name},W.id))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(pc,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:W=>f(W.target.value||null),children:[s.jsx("option",{value:"",children:"All Materials"}),ve.map(W=>s.jsx("option",{value:W,children:W},W))]})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(q1,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:W=>E(W.target.value),children:[s.jsx("option",{value:"all",children:"All Files"}),s.jsx("option",{value:"gcode",children:"Sliced (GCODE)"}),s.jsx("option",{value:"source",children:"Source Only"})]})]}),s.jsxs("button",{onClick:()=>y(!v),className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors flex-shrink-0 ${v?"bg-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:[s.jsx(im,{className:`w-4 h-4 ${v?"fill-yellow-400":""}`}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Favorites"})]}),s.jsxs("button",{onClick:()=>k(!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:[s.jsx($i,{className:"w-4 h-4 "}),s.jsx("span",{className:"text-sm hidden md:inline",children:"Hide Failed"})]}),Fe.length>0&&s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(yh,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:W=>M(W.target.value||null),children:[s.jsx("option",{value:"",children:"All Tags"}),Fe.map(W=>s.jsx("option",{value:W,children:W},W))]}),s.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:s.jsx(xM,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx(xW,{className:"w-4 h-4 text-bambu-gray hidden md:block"}),s.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:W=>de(W.target.value),children:[s.jsx("option",{value:"date-desc",children:t("archives.sortNewest")}),s.jsx("option",{value:"date-asc",children:t("archives.sortOldest")}),s.jsxs("option",{value:"name-asc",children:[t("archives.sortName")," A-Z"]}),s.jsxs("option",{value:"name-desc",children:[t("archives.sortName")," Z-A"]}),s.jsx("option",{value:"size-desc",children:t("archives.sortLargest")}),s.jsx("option",{value:"size-asc",children:t("archives.sortSmallest")})]})]}),s.jsxs("div",{className:"flex items-center border border-bambu-dark-tertiary rounded-lg overflow-hidden flex-shrink-0",children:[s.jsx("button",{className:`p-2 ${ne==="grid"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>be("grid"),title:t("archives.gridView"),children:s.jsx(mM,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${ne==="list"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>be("list"),title:t("archives.listView"),children:s.jsx(pM,{className:"w-4 h-4"})}),s.jsx("button",{className:`p-2 ${ne==="calendar"?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,onClick:()=>be("calendar"),title:t("archives.calendarView"),children:s.jsx(Oce,{className:"w-4 h-4"})})]})]}),Ne&&s.jsxs(Te,{variant:"ghost",size:"sm",onClick:Xe,className:"text-bambu-gray hover:text-white",children:[s.jsx(Rt,{className:"w-4 h-4"}),"Reset"]})]}),ae.length>0&&s.jsxs("div",{className:"flex items-center gap-3 mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Colors:"}),p.size>1&&s.jsx("button",{onClick:()=>b(W=>W==="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()}),s.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:ae.map(W=>s.jsx("button",{onClick:()=>ze(W),className:`w-6 h-6 rounded-full border-2 transition-all ${p.has(W)?"border-bambu-green scale-110":"border-white/20 hover:border-white/40"}`,style:{backgroundColor:W},title:W},W))}),p.size>0&&s.jsxs("button",{onClick:we,className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1",children:[s.jsx(Rt,{className:"w-3 h-3"}),"Clear"]})]})]})}),s.jsx(sqe,{}),Me?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("archives.loadingArchives")}):Be?.length===0?s.jsx(St,{children:s.jsxs(Nt,{className:"text-center py-12",children:[s.jsx("p",{className:"text-bambu-gray",children:t(o?"archives.noArchivesSearch":"archives.noArchivesYet")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2",children:"Archives are created automatically when prints complete"})]})}):ne==="calendar"?s.jsx(St,{className:"p-6",children:s.jsx(F8e,{archives:Be||[],onArchiveClick:W=>{l(""),be("grid"),U(W.id)},highlightedArchiveId:te})}):ne==="grid"?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:Be?.map(W=>s.jsx(lqe,{archive:W,printerName:W.printer_id?_e.get(W.printer_id)||"Unknown":W.sliced_for_model?`Sliced for ${W.sliced_for_model}`:"No Printer",isSelected:P.has(W.id),onSelect:He,selectionMode:$e,projects:B,isHighlighted:W.id===te,timeFormat:ee,t},W.id))}):ne==="list"?s.jsx(St,{children:s.jsxs("div",{className:"divide-y divide-bambu-dark-tertiary",children:[s.jsxs("div",{className:"grid grid-cols-12 gap-4 px-4 py-3 text-xs text-bambu-gray font-medium",children:[s.jsx("div",{className:"col-span-1"}),s.jsx("div",{className:"col-span-4",children:"Name"}),s.jsx("div",{className:"col-span-2",children:"Printer"}),s.jsx("div",{className:"col-span-2",children:"Date"}),s.jsx("div",{className:"col-span-1",children:"Size"}),s.jsx("div",{className:"col-span-2 text-right",children:"Actions"})]}),Be?.map(W=>s.jsx(cqe,{archive:W,printerName:W.printer_id?_e.get(W.printer_id)||"Unknown":W.sliced_for_model?`Sliced for ${W.sliced_for_model}`:"No Printer",isSelected:P.has(W.id),onSelect:He,selectionMode:$e,projects:B,isHighlighted:W.id===te,t},W.id))]})}):null,R&&s.jsx(T8e,{onClose:()=>{A(!1),I([])},initialFiles:D}),Q&&s.jsx(Zn,{title:t("archives.modal.deleteArchives"),message:t("archives.modal.deleteArchivesConfirm",{count:P.size}),confirmText:t("archives.modal.deleteCount",{count:P.size}),variant:"danger",onConfirm:()=>{le.mutate(Array.from(P)),Z(!1)},onCancel:()=>Z(!1)}),se&&s.jsx(P8e,{selectedIds:Array.from(P),existingTags:Fe,onClose:()=>H(!1)}),K&&s.jsx(j8e,{selectedIds:Array.from(P),onClose:()=>re(!1)}),G&&P.size>=2&&P.size<=5&&s.jsx(tqe,{archiveIds:Array.from(P),onClose:()=>{Y(!1),$(new Set),V(!1)}}),ue&&s.jsx(oqe,{onClose:()=>q(!1)})]})}function hqe(){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 I2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Lx(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function nF(t){return"nodeType"in t}function Gs(t){var e,n;return t?Lx(t)?t:nF(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function rF(t){const{Document:e}=Gs(t);return t instanceof e}function wv(t){return Lx(t)?!1:t instanceof Gs(t).HTMLElement}function ure(t){return t instanceof Gs(t).SVGElement}function Fx(t){return t?Lx(t)?t.document:nF(t)?rF(t)?t:wv(t)||ure(t)?t.ownerDocument:document:document:document}const Nc=I2?_.useLayoutEffect:_.useEffect;function iF(t){const e=_.useRef(t);return Nc(()=>{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 fqe(){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 Nc(()=>{n.current!==t&&(n.current=t)},e),n}function _v(t,e){const n=_.useRef();return _.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function QN(t){const e=iF(t),n=_.useRef(null),r=_.useCallback(i=>{i!==n.current&&e?.(i,n.current),n.current=i},[]);return[n,r]}function aR(t){const e=_.useRef();return _.useEffect(()=>{e.current=t},[t]),e.current}let IP={};function Sv(t,e){return _.useMemo(()=>{if(e)return e;const n=IP[t]==null?0:IP[t]+1;return IP[t]=n,t+"-"+n},[t,e])}function dre(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((a,o)=>{const l=Object.entries(o);for(const[c,u]of l){const d=a[c];d!=null&&(a[c]=d+t*u)}return a},{...e})}}const Lg=dre(1),jy=dre(-1);function mqe(t){return"clientX"in t&&"clientY"in t}function aF(t){if(!t)return!1;const{KeyboardEvent:e}=Gs(t.target);return e&&t instanceof e}function pqe(t){if(!t)return!1;const{TouchEvent:e}=Gs(t.target);return e&&t instanceof e}function sR(t){if(pqe(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 mqe(t)?{x:t.clientX,y:t.clientY}:null}const mx=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[mx.Translate.toString(t),mx.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),rq="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function gqe(t){return t.matches(rq)?t:t.querySelector(rq)}const xqe={display:"none"};function bqe(t){let{id:e,value:n}=t;return ei.createElement("div",{id:e,style:xqe},n)}function yqe(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 vqe(){const[t,e]=_.useState("");return{announce:_.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const hre=_.createContext(null);function wqe(t){const e=_.useContext(hre);_.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function _qe(){const[t]=_.useState(()=>new Set),e=_.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[_.useCallback(r=>{let{type:i,event:a}=r;t.forEach(o=>{var l;return(l=o[i])==null?void 0:l.call(o,a)})},[t]),e]}const Sqe={draggable:`
- To pick up a draggable item, press the space bar.
- While dragging, use the arrow keys to move the item.
- Press space again to drop the item in its new position, or press escape to cancel.
- `},Nqe={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 Mqe(t){let{announcements:e=Nqe,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Sqe}=t;const{announce:a,announcement:o}=vqe(),l=Sv("DndLiveRegion"),[c,u]=_.useState(!1);if(_.useEffect(()=>{u(!0)},[]),wqe(_.useMemo(()=>({onDragStart(f){let{active:p}=f;a(e.onDragStart({active:p}))},onDragMove(f){let{active:p,over:m}=f;e.onDragMove&&a(e.onDragMove({active:p,over:m}))},onDragOver(f){let{active:p,over:m}=f;a(e.onDragOver({active:p,over:m}))},onDragEnd(f){let{active:p,over:m}=f;a(e.onDragEnd({active:p,over:m}))},onDragCancel(f){let{active:p,over:m}=f;a(e.onDragCancel({active:p,over:m}))}}),[a,e])),!c)return null;const d=ei.createElement(ei.Fragment,null,ei.createElement(bqe,{id:r,value:i.draggable}),ei.createElement(yqe,{id:l,announcement:o}));return n?xu.createPortal(d,n):d}var Yi;(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"})(Yi||(Yi={}));function ZN(){}function JN(t,e){return _.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function fre(){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 zl=Object.freeze({x:0,y:0});function mre(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function pre(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function kqe(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function iq(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 gre(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function aq(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 xre=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=aq(e,e.left,e.top),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=mre(aq(c),i);a.push({id:l,data:{droppableContainer:o,value:u}})}}return a.sort(pre)},Eqe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=iq(e),a=[];for(const o of r){const{id:l}=o,c=n.get(l);if(c){const u=iq(c),d=i.reduce((p,m,x)=>p+mre(u[x],m),0),f=Number((d/4).toFixed(4));a.push({id:l,data:{droppableContainer:o,value:f}})}}return a.sort(pre)};function Tqe(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),i=Math.min(e.left+e.width,t.left+t.width),a=Math.min(e.top+e.height,t.top+t.height),o=i-r,l=a-n;if(r<i&&n<a){const c=e.width*e.height,u=t.width*t.height,d=o*l,f=d/(c+u-d);return Number(f.toFixed(4))}return 0}const Aqe=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const i=[];for(const a of r){const{id:o}=a,l=n.get(o);if(l){const c=Tqe(l,e);c>0&&i.push({id:o,data:{droppableContainer:a,value:c}})}}return i.sort(kqe)};function Cqe(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function bre(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:zl}function Pqe(t){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),a=1;a<r;a++)i[a-1]=arguments[a];return i.reduce((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 jqe=Pqe(1);function Dqe(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 Rqe(t,e,n){const r=Dqe(e);if(!r)return t;const{scaleX:i,scaleY:a,x:o,y:l}=r,c=t.left-o-(1-i)*parseFloat(n),u=t.top-l-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),d=i?t.width/i:t.width,f=a?t.height/a:t.height;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c}}const Oqe={ignoreTransform:!1};function Ix(t,e){e===void 0&&(e=Oqe);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:d}=Gs(t).getComputedStyle(t);u&&(n=Rqe(n,u,d))}const{top:r,left:i,width:a,height:o,bottom:l,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:l,right:c}}function sq(t){return Ix(t,{ignoreTransform:!0})}function Lqe(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function Fqe(t,e){return e===void 0&&(e=Gs(t).getComputedStyle(t)),e.position==="fixed"}function Iqe(t,e){e===void 0&&(e=Gs(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const a=e[i];return typeof a=="string"?n.test(a):!1})}function U2(t,e){const n=[];function r(i){if(e!=null&&n.length>=e||!i)return n;if(rF(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!wv(i)||ure(i)||n.includes(i))return n;const a=Gs(t).getComputedStyle(i);return i!==t&&Iqe(i,a)&&n.push(i),Fqe(i,a)?n:r(i.parentNode)}return t?r(t):n}function yre(t){const[e]=U2(t,1);return e??null}function UP(t){return!I2||!t?null:Lx(t)?t:nF(t)?rF(t)||t===Fx(t).scrollingElement?window:wv(t)?t:null:null}function vre(t){return Lx(t)?t.scrollX:t.scrollLeft}function wre(t){return Lx(t)?t.scrollY:t.scrollTop}function oR(t){return{x:vre(t),y:wre(t)}}var xa;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(xa||(xa={}));function _re(t){return!I2||!t?!1:t===document.scrollingElement}function Sre(t){const e={x:0,y:0},n=_re(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},i=t.scrollTop<=e.y,a=t.scrollLeft<=e.x,o=t.scrollTop>=r.y,l=t.scrollLeft>=r.x;return{isTop:i,isLeft:a,isBottom:o,isRight:l,maxScroll:r,minScroll:e}}const Uqe={x:.2,y:.2};function zqe(t,e,n,r,i){let{top:a,left:o,right:l,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Uqe);const{isTop:u,isBottom:d,isLeft:f,isRight:p}=Sre(t),m={x:0,y:0},x={x:0,y:0},b={height:e.height*i.y,width:e.width*i.x};return!u&&a<=e.top+b.height?(m.y=xa.Backward,x.y=r*Math.abs((e.top+b.height-a)/b.height)):!d&&c>=e.bottom-b.height&&(m.y=xa.Forward,x.y=r*Math.abs((e.bottom-b.height-c)/b.height)),!p&&l>=e.right-b.width?(m.x=xa.Forward,x.x=r*Math.abs((e.right-b.width-l)/b.width)):!f&&o<=e.left+b.width&&(m.x=xa.Backward,x.x=r*Math.abs((e.left+b.width-o)/b.width)),{direction:m,speed:x}}function Bqe(t){if(t===document.scrollingElement){const{innerWidth:a,innerHeight:o}=window;return{top:0,left:0,right:a,bottom:o,width:a,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 Nre(t){return t.reduce((e,n)=>Lg(e,oR(n)),zl)}function Hqe(t){return t.reduce((e,n)=>e+vre(n),0)}function $qe(t){return t.reduce((e,n)=>e+wre(n),0)}function Vqe(t,e){if(e===void 0&&(e=Ix),!t)return;const{top:n,left:r,bottom:i,right:a}=e(t);yre(t)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const Gqe=[["x",["left","right"],Hqe],["y",["top","bottom"],$qe]];class sF{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=U2(n),i=Nre(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[a,o,l]of Gqe)for(const c of o)Object.defineProperty(this,c,{get:()=>{const u=l(r),d=i[a]-u;return this.rect[c]+d},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class F0{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 qqe(t){const{EventTarget:e}=Gs(t);return t instanceof e?t:Fx(t)}function zP(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 qo;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(qo||(qo={}));function oq(t){t.preventDefault()}function Wqe(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 Mre={start:[Qn.Space,Qn.Enter],cancel:[Qn.Esc],end:[Qn.Space,Qn.Enter,Qn.Tab]},Kqe=(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 z2{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 F0(Fx(n)),this.windowListeners=new F0(Gs(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(qo.Resize,this.handleCancel),this.windowListeners.add(qo.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(qo.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&Vqe(r),n(zl)}handleKeyDown(e){if(aF(e)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:a=Mre,coordinateGetter:o=Kqe,scrollBehavior:l="smooth"}=i,{code:c}=e;if(a.end.includes(c)){this.handleEnd(e);return}if(a.cancel.includes(c)){this.handleCancel(e);return}const{collisionRect:u}=r.current,d=u?{x:u.left,y:u.top}:zl;this.referenceCoordinates||(this.referenceCoordinates=d);const f=o(e,{active:n,context:r.current,currentCoordinates:d});if(f){const p=jy(f,d),m={x:0,y:0},{scrollableAncestors:x}=r.current;for(const b of x){const v=e.code,{isTop:y,isRight:S,isLeft:k,isBottom:T,maxScroll:M,minScroll:C}=Sre(b),E=Bqe(b),R={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,f.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,f.y))},A=v===Qn.Right&&!S||v===Qn.Left&&!k,D=v===Qn.Down&&!T||v===Qn.Up&&!y;if(A&&R.x!==f.x){const I=b.scrollLeft+p.x,F=v===Qn.Right&&I<=M.x||v===Qn.Left&&I>=C.x;if(F&&!p.y){b.scrollTo({left:I,behavior:l});return}F?m.x=b.scrollLeft-I:m.x=v===Qn.Right?b.scrollLeft-M.x:b.scrollLeft-C.x,m.x&&b.scrollBy({left:-m.x,behavior:l});break}else if(D&&R.y!==f.y){const I=b.scrollTop+p.y,F=v===Qn.Down&&I<=M.y||v===Qn.Up&&I>=C.y;if(F&&!p.x){b.scrollTo({top:I,behavior:l});return}F?m.y=b.scrollTop-I:m.y=v===Qn.Down?b.scrollTop-M.y:b.scrollTop-C.y,m.y&&b.scrollBy({top:-m.y,behavior:l});break}}this.handleMove(e,Lg(jy(f,this.referenceCoordinates),m))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}z2.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=Mre,onActivation:i}=e,{active:a}=n;const{code:o}=t.nativeEvent;if(r.start.includes(o)){const l=a.activatorNode.current;return l&&t.target!==l?!1:(t.preventDefault(),i?.({event:t.nativeEvent}),!0)}return!1}}];function lq(t){return!!(t&&"distance"in t)}function cq(t){return!!(t&&"delay"in t)}class oF{constructor(e,n,r){var i;r===void 0&&(r=qqe(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:a}=e,{target:o}=a;this.props=e,this.events=n,this.document=Fx(o),this.documentListeners=new F0(this.document),this.listeners=new F0(r),this.windowListeners=new F0(Gs(o)),this.initialCoordinates=(i=sR(a))!=null?i:zl,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(qo.Resize,this.handleCancel),this.windowListeners.add(qo.DragStart,oq),this.windowListeners.add(qo.VisibilityChange,this.handleCancel),this.windowListeners.add(qo.ContextMenu,oq),this.documentListeners.add(qo.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(cq(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(lq(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(qo.Click,Wqe,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(qo.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:i,props:a}=this,{onMove:o,options:{activationConstraint:l}}=a;if(!i)return;const c=(n=sR(e))!=null?n:zl,u=jy(i,c);if(!r&&l){if(lq(l)){if(l.tolerance!=null&&zP(u,l.tolerance))return this.handleCancel();if(zP(u,l.distance))return this.handleStart()}if(cq(l)&&zP(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 Xqe={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class B2 extends oF{constructor(e){const{event:n}=e,r=Fx(n.target);super(e,Xqe,r)}}B2.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 Yqe={move:{name:"mousemove"},end:{name:"mouseup"}};var lR;(function(t){t[t.RightClick=2]="RightClick"})(lR||(lR={}));class Qqe extends oF{constructor(e){super(e,Yqe,Fx(e.event.target))}}Qqe.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===lR.RightClick?!1:(r?.({event:n}),!0)}}];const BP={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Zqe extends oF{constructor(e){super(e,BP)}static setup(){return window.addEventListener(BP.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(BP.move.name,e)};function e(){}}}Zqe.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 I0;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(I0||(I0={}));var eM;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(eM||(eM={}));function Jqe(t){let{acceleration:e,activator:n=I0.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:l=eM.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:p}=t;const m=tWe({delta:f,disabled:!a}),[x,b]=fqe(),v=_.useRef({x:0,y:0}),y=_.useRef({x:0,y:0}),S=_.useMemo(()=>{switch(n){case I0.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case I0.DraggableRect:return i}},[n,i,c]),k=_.useRef(null),T=_.useCallback(()=>{const C=k.current;if(!C)return;const E=v.current.x*y.current.x,R=v.current.y*y.current.y;C.scrollBy(E,R)},[]),M=_.useMemo(()=>l===eM.TreeOrder?[...u].reverse():u,[l,u]);_.useEffect(()=>{if(!a||!u.length||!S){b();return}for(const C of M){if(r?.(C)===!1)continue;const E=u.indexOf(C),R=d[E];if(!R)continue;const{direction:A,speed:D}=zqe(C,R,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){b(),k.current=C,x(T,o),v.current=D,y.current=A;return}}v.current={x:0,y:0},y.current={x:0,y:0},b()},[e,T,r,b,a,o,JSON.stringify(S),JSON.stringify(m),x,u,M,d,JSON.stringify(p)])}const eWe={x:{[xa.Backward]:!1,[xa.Forward]:!1},y:{[xa.Backward]:!1,[xa.Forward]:!1}};function tWe(t){let{delta:e,disabled:n}=t;const r=aR(e);return _v(i=>{if(n||!r||!i)return eWe;const a={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[xa.Backward]:i.x[xa.Backward]||a.x===-1,[xa.Forward]:i.x[xa.Forward]||a.x===1},y:{[xa.Backward]:i.y[xa.Backward]||a.y===-1,[xa.Forward]:i.y[xa.Forward]||a.y===1}}},[n,e,r])}function nWe(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return _v(i=>{var a;return e==null?null:(a=r??i)!=null?a:null},[r,e])}function rWe(t,e){return _.useMemo(()=>t.reduce((n,r)=>{const{sensor:i}=r,a=i.activators.map(o=>({eventName:o.eventName,handler:e(o.handler,r)}));return[...n,...a]},[]),[t,e])}var Dy;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Dy||(Dy={}));var cR;(function(t){t.Optimized="optimized"})(cR||(cR={}));const uq=new Map;function iWe(t,e){let{dragging:n,dependencies:r,config:i}=e;const[a,o]=_.useState(null),{frequency:l,measure:c,strategy:u}=i,d=_.useRef(t),f=v(),p=Py(f),m=_.useCallback(function(y){y===void 0&&(y=[]),!p.current&&o(S=>S===null?y:S.concat(y.filter(k=>!S.includes(k))))},[p]),x=_.useRef(null),b=_v(y=>{if(f&&!n)return uq;if(!y||y===uq||d.current!==t||a!=null){const S=new Map;for(let k of t){if(!k)continue;if(a&&a.length>0&&!a.includes(k.id)&&k.rect.current){S.set(k.id,k.rect.current);continue}const T=k.node.current,M=T?new sF(c(T),T):null;k.rect.current=M,M&&S.set(k.id,M)}return S}return y},[t,a,n,f,c]);return _.useEffect(()=>{d.current=t},[t]),_.useEffect(()=>{f||m()},[n,f]),_.useEffect(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),_.useEffect(()=>{f||typeof l!="number"||x.current!==null||(x.current=setTimeout(()=>{m(),x.current=null},l))},[l,f,m,...r]),{droppableRects:b,measureDroppableContainers:m,measuringScheduled:a!=null};function v(){switch(u){case Dy.Always:return!1;case Dy.BeforeDragging:return n;default:return!n}}}function kre(t,e){return _v(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function aWe(t,e){return kre(t,e)}function sWe(t){let{callback:e,disabled:n}=t;const r=iF(e),i=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(r)},[r,n]);return _.useEffect(()=>()=>i?.disconnect(),[i]),i}function H2(t){let{callback:e,disabled:n}=t;const r=iF(e),i=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(r)},[n]);return _.useEffect(()=>()=>i?.disconnect(),[i]),i}function oWe(t){return new sF(Ix(t),t)}function dq(t,e,n){e===void 0&&(e=oWe);const[r,i]=_.useState(null);function a(){i(c=>{if(!t)return null;if(t.isConnected===!1){var u;return(u=c??n)!=null?u:null}const d=e(t);return JSON.stringify(c)===JSON.stringify(d)?c:d})}const o=sWe({callback(c){if(t)for(const u of c){const{type:d,target:f}=u;if(d==="childList"&&f instanceof HTMLElement&&f.contains(t)){a();break}}}}),l=H2({callback:a});return Nc(()=>{a(),t?(l?.observe(t),o?.observe(document.body,{childList:!0,subtree:!0})):(l?.disconnect(),o?.disconnect())},[t]),r}function lWe(t){const e=kre(t);return bre(t,e)}const hq=[];function cWe(t){const e=_.useRef(t),n=_v(r=>t?r&&r!==hq&&t&&e.current&&t.parentNode===e.current.parentNode?r:U2(t):hq,[t]);return _.useEffect(()=>{e.current=t},[t]),n}function uWe(t){const[e,n]=_.useState(null),r=_.useRef(t),i=_.useCallback(a=>{const o=UP(a.target);o&&n(l=>l?(l.set(o,oR(o)),new Map(l)):null)},[]);return _.useEffect(()=>{const a=r.current;if(t!==a){o(a);const l=t.map(c=>{const u=UP(c);return u?(u.addEventListener("scroll",i,{passive:!0}),[u,oR(u)]):null}).filter(c=>c!=null);n(l.length?new Map(l):null),r.current=t}return()=>{o(t),o(a)};function o(l){l.forEach(c=>{const u=UP(c);u?.removeEventListener("scroll",i)})}},[i,t]),_.useMemo(()=>t.length?e?Array.from(e.values()).reduce((a,o)=>Lg(a,o),zl):Nre(t):zl,[t,e])}function fq(t,e){e===void 0&&(e=[]);const n=_.useRef(null);return _.useEffect(()=>{n.current=null},e),_.useEffect(()=>{const r=t!==zl;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?jy(t,n.current):zl}function dWe(t){_.useEffect(()=>{if(!I2)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 hWe(t,e){return _.useMemo(()=>t.reduce((n,r)=>{let{eventName:i,handler:a}=r;return n[i]=o=>{a(o,e)},n},{}),[t,e])}function Ere(t){return _.useMemo(()=>t?Lqe(t):null,[t])}const mq=[];function fWe(t,e){e===void 0&&(e=Ix);const[n]=t,r=Ere(n?Gs(n):null),[i,a]=_.useState(mq);function o(){a(()=>t.length?t.map(c=>_re(c)?r:new sF(e(c),c)):mq)}const l=H2({callback:o});return Nc(()=>{l?.disconnect(),o(),t.forEach(c=>l?.observe(c))},[t]),i}function mWe(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return wv(e)?e:t}function pWe(t){let{measure:e}=t;const[n,r]=_.useState(null),i=_.useCallback(u=>{for(const{target:d}of u)if(wv(d)){r(f=>{const p=e(d);return f?{...f,width:p.width,height:p.height}:p});break}},[e]),a=H2({callback:i}),o=_.useCallback(u=>{const d=mWe(u);a?.disconnect(),d&&a?.observe(d),r(d?e(d):null)},[e,a]),[l,c]=QN(o);return _.useMemo(()=>({nodeRef:l,rect:n,setRef:c}),[n,l,c])}const gWe=[{sensor:B2,options:{}},{sensor:z2,options:{}}],xWe={current:{}},U1={draggable:{measure:sq},droppable:{measure:sq,strategy:Dy.WhileDragging,frequency:cR.Optimized},dragOverlay:{measure:Ix}};class U0 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 bWe={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new U0,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ZN},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:U1,measureDroppableContainers:ZN,windowRect:null,measuringScheduled:!1},yWe={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ZN,draggableNodes:new Map,over:null,measureDroppableContainers:ZN},$2=_.createContext(yWe),Tre=_.createContext(bWe);function vWe(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new U0}}}function wWe(t,e){switch(e.type){case Yi.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Yi.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 Yi.DragEnd:case Yi.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Yi.RegisterDroppable:{const{element:n}=e,{id:r}=n,i=new U0(t.droppable.containers);return i.set(r,n),{...t,droppable:{...t.droppable,containers:i}}}case Yi.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=e,a=t.droppable.containers.get(n);if(!a||r!==a.key)return t;const o=new U0(t.droppable.containers);return o.set(n,{...a,disabled:i}),{...t,droppable:{...t.droppable,containers:o}}}case Yi.UnregisterDroppable:{const{id:n,key:r}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const a=new U0(t.droppable.containers);return a.delete(n),{...t,droppable:{...t.droppable,containers:a}}}default:return t}}function _We(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:i}=_.useContext($2),a=aR(r),o=aR(n?.id);return _.useEffect(()=>{if(!e&&!r&&a&&o!=null){if(!aF(a)||document.activeElement===a.target)return;const l=i.get(o);if(!l)return;const{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const d of[c.current,u.current]){if(!d)continue;const f=gqe(d);if(f){f.focus();break}}})}},[r,e,i,o,a]),null}function SWe(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((i,a)=>a({transform:i,...r}),n):n}function NWe(t){return _.useMemo(()=>({draggable:{...U1.draggable,...t?.draggable},droppable:{...U1.droppable,...t?.droppable},dragOverlay:{...U1.dragOverlay,...t?.dragOverlay}}),[t?.draggable,t?.droppable,t?.dragOverlay])}function MWe(t){let{activeNode:e,measure:n,initialRect:r,config:i=!0}=t;const a=_.useRef(!1),{x:o,y:l}=typeof i=="boolean"?{x:i,y:i}:i;Nc(()=>{if(!o&&!l||!e){a.current=!1;return}if(a.current||!r)return;const u=e?.node.current;if(!u||u.isConnected===!1)return;const d=n(u),f=bre(d,r);if(o||(f.x=0),l||(f.y=0),a.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const p=yre(u);p&&p.scrollBy({top:f.y,left:f.x})}},[e,o,l,r,n])}const Are=_.createContext({...zl,scaleX:1,scaleY:1});var qd;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(qd||(qd={}));const Cre=_.memo(function(e){var n,r,i,a;let{id:o,accessibility:l,autoScroll:c=!0,children:u,sensors:d=gWe,collisionDetection:f=Aqe,measuring:p,modifiers:m,...x}=e;const b=_.useReducer(wWe,void 0,vWe),[v,y]=b,[S,k]=_qe(),[T,M]=_.useState(qd.Uninitialized),C=T===qd.Initialized,{draggable:{active:E,nodes:R,translate:A},droppable:{containers:D}}=v,I=E!=null?R.get(E):null,F=_.useRef({initial:null,translated:null}),z=_.useMemo(()=>{var Ke;return E!=null?{id:E,data:(Ke=I?.data)!=null?Ke:xWe,rect:F}:null},[E,I]),P=_.useRef(null),[$,X]=_.useState(null),[V,Q]=_.useState(null),Z=Py(x,Object.values(x)),se=Sv("DndDescribedBy",o),H=_.useMemo(()=>D.getEnabled(),[D]),K=NWe(p),{droppableRects:re,measureDroppableContainers:ne,measuringScheduled:be}=iWe(H,{dragging:C,dependencies:[A.x,A.y],config:K.droppable}),me=nWe(R,E),de=_.useMemo(()=>V?sR(V):null,[V]),Ce=Ee(),ie=aWe(me,K.draggable.measure);MWe({activeNode:E!=null?R.get(E):null,config:Ce.layoutShiftCompensation,initialRect:ie,measure:K.draggable.measure});const ke=dq(me,K.draggable.measure,ie),Oe=dq(me?me.parentElement:null),pe=_.useRef({activatorEvent:null,active:null,activeNode:me,collisionRect:null,collisions:null,droppableRects:re,draggableNodes:R,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),We=D.getNodeFor((n=pe.current.over)==null?void 0:n.id),G=pWe({measure:K.dragOverlay.measure}),Y=(r=G.nodeRef.current)!=null?r:me,ue=C?(i=G.rect)!=null?i:ke:null,q=!!(G.nodeRef.current&&G.rect),te=lWe(q?null:ke),U=Ere(Y?Gs(Y):null),he=cWe(C?We??me:null),Me=fWe(he),ge=SWe(m,{transform:{x:A.x-te.x,y:A.y-te.y,scaleX:1,scaleY:1},activatorEvent:V,active:z,activeNodeRect:ke,containerNodeRect:Oe,draggingNodeRect:ue,over:pe.current.over,overlayNodeRect:G.rect,scrollableAncestors:he,scrollableAncestorRects:Me,windowRect:U}),B=de?Lg(de,A):null,O=uWe(he),ee=fq(O),le=fq(O,[ke]),_e=Lg(ge,ee),ve=ue?jqe(ue,ge):null,ae=z&&ve?f({active:z,collisionRect:ve,droppableRects:re,droppableContainers:H,pointerCoordinates:B}):null,Fe=gre(ae,"id"),[Be,$e]=_.useState(null),He=q?ge:Lg(ge,le),xe=Cqe(He,(a=Be?.rect)!=null?a:null,ke),Pe=_.useRef(null),ze=_.useCallback((Ke,Ue)=>{let{sensor:W,options:je}=Ue;if(P.current==null)return;const Ye=R.get(P.current);if(!Ye)return;const bt=Ke.nativeEvent,pt=new W({active:P.current,activeNode:Ye,event:bt,options:je,context:pe,onAbort(Lt){if(!R.get(Lt))return;const{onDragAbort:cn}=Z.current,rr={id:Lt};cn?.(rr),S({type:"onDragAbort",event:rr})},onPending(Lt,vn,cn,rr){if(!R.get(Lt))return;const{onDragPending:Jn}=Z.current,gn={id:Lt,constraint:vn,initialCoordinates:cn,offset:rr};Jn?.(gn),S({type:"onDragPending",event:gn})},onStart(Lt){const vn=P.current;if(vn==null)return;const cn=R.get(vn);if(!cn)return;const{onDragStart:rr}=Z.current,Vn={activatorEvent:bt,active:{id:vn,data:cn.data,rect:F}};xu.unstable_batchedUpdates(()=>{rr?.(Vn),M(qd.Initializing),y({type:Yi.DragStart,initialCoordinates:Lt,active:vn}),S({type:"onDragStart",event:Vn}),X(Pe.current),Q(bt)})},onMove(Lt){y({type:Yi.DragMove,coordinates:Lt})},onEnd:Bt(Yi.DragEnd),onCancel:Bt(Yi.DragCancel)});Pe.current=pt;function Bt(Lt){return async function(){const{active:cn,collisions:rr,over:Vn,scrollAdjustedTranslate:Jn}=pe.current;let gn=null;if(cn&&Jn){const{cancelDrop:sr}=Z.current;gn={activatorEvent:bt,active:cn,collisions:rr,delta:Jn,over:Vn},Lt===Yi.DragEnd&&typeof sr=="function"&&await Promise.resolve(sr(gn))&&(Lt=Yi.DragCancel)}P.current=null,xu.unstable_batchedUpdates(()=>{y({type:Lt}),M(qd.Uninitialized),$e(null),X(null),Q(null),Pe.current=null;const sr=Lt===Yi.DragEnd?"onDragEnd":"onDragCancel";if(gn){const Gn=Z.current[sr];Gn?.(gn),S({type:sr,event:gn})}})}}},[R]),we=_.useCallback((Ke,Ue)=>(W,je)=>{const Ye=W.nativeEvent,bt=R.get(je);if(P.current!==null||!bt||Ye.dndKit||Ye.defaultPrevented)return;const pt={active:bt};Ke(W,Ue.options,pt)===!0&&(Ye.dndKit={capturedBy:Ue.sensor},P.current=je,ze(W,Ue))},[R,ze]),Xe=rWe(d,we);dWe(d),Nc(()=>{ke&&T===qd.Initializing&&M(qd.Initialized)},[ke,T]),_.useEffect(()=>{const{onDragMove:Ke}=Z.current,{active:Ue,activatorEvent:W,collisions:je,over:Ye}=pe.current;if(!Ue||!W)return;const bt={active:Ue,activatorEvent:W,collisions:je,delta:{x:_e.x,y:_e.y},over:Ye};xu.unstable_batchedUpdates(()=>{Ke?.(bt),S({type:"onDragMove",event:bt})})},[_e.x,_e.y]),_.useEffect(()=>{const{active:Ke,activatorEvent:Ue,collisions:W,droppableContainers:je,scrollAdjustedTranslate:Ye}=pe.current;if(!Ke||P.current==null||!Ue||!Ye)return;const{onDragOver:bt}=Z.current,pt=je.get(Fe),Bt=pt&&pt.rect.current?{id:pt.id,rect:pt.rect.current,data:pt.data,disabled:pt.disabled}:null,Lt={active:Ke,activatorEvent:Ue,collisions:W,delta:{x:Ye.x,y:Ye.y},over:Bt};xu.unstable_batchedUpdates(()=>{$e(Bt),bt?.(Lt),S({type:"onDragOver",event:Lt})})},[Fe]),Nc(()=>{pe.current={activatorEvent:V,active:z,activeNode:me,collisionRect:ve,collisions:ae,droppableRects:re,draggableNodes:R,draggingNode:Y,draggingNodeRect:ue,droppableContainers:D,over:Be,scrollableAncestors:he,scrollAdjustedTranslate:_e},F.current={initial:ue,translated:ve}},[z,me,ae,ve,R,Y,ue,re,D,Be,he,_e]),Jqe({...Ce,delta:A,draggingRect:ve,pointerCoordinates:B,scrollableAncestors:he,scrollableAncestorRects:Me});const Ne=_.useMemo(()=>({active:z,activeNode:me,activeNodeRect:ke,activatorEvent:V,collisions:ae,containerNodeRect:Oe,dragOverlay:G,draggableNodes:R,droppableContainers:D,droppableRects:re,over:Be,measureDroppableContainers:ne,scrollableAncestors:he,scrollableAncestorRects:Me,measuringConfiguration:K,measuringScheduled:be,windowRect:U}),[z,me,ke,V,ae,Oe,G,R,D,re,Be,ne,he,Me,K,be,U]),rt=_.useMemo(()=>({activatorEvent:V,activators:Xe,active:z,activeNodeRect:ke,ariaDescribedById:{draggable:se},dispatch:y,draggableNodes:R,over:Be,measureDroppableContainers:ne}),[V,Xe,z,ke,y,se,R,Be,ne]);return ei.createElement(hre.Provider,{value:k},ei.createElement($2.Provider,{value:rt},ei.createElement(Tre.Provider,{value:Ne},ei.createElement(Are.Provider,{value:xe},u)),ei.createElement(_We,{disabled:l?.restoreFocus===!1})),ei.createElement(Mqe,{...l,hiddenTextDescribedById:se}));function Ee(){const Ke=$?.autoScrollEnabled===!1,Ue=typeof c=="object"?c.enabled===!1:c===!1,W=C&&!Ke&&!Ue;return typeof c=="object"?{...c,enabled:W}:{enabled:W}}}),kWe=_.createContext(null),pq="button",EWe="Draggable";function TWe(t){let{id:e,data:n,disabled:r=!1,attributes:i}=t;const a=Sv(EWe),{activators:o,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:p}=_.useContext($2),{role:m=pq,roleDescription:x="draggable",tabIndex:b=0}=i??{},v=c?.id===e,y=_.useContext(v?Are:kWe),[S,k]=QN(),[T,M]=QN(),C=hWe(o,e),E=Py(n);Nc(()=>(f.set(e,{id:e,key:a,node:S,activatorNode:T,data:E}),()=>{const A=f.get(e);A&&A.key===a&&f.delete(e)}),[f,e]);const R=_.useMemo(()=>({role:m,tabIndex:b,"aria-disabled":r,"aria-pressed":v&&m===pq?!0:void 0,"aria-roledescription":x,"aria-describedby":d.draggable}),[r,m,b,v,x,d.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:R,isDragging:v,listeners:r?void 0:C,node:S,over:p,setNodeRef:k,setActivatorNodeRef:M,transform:y}}function AWe(){return _.useContext(Tre)}const CWe="Droppable",PWe={timeout:25};function jWe(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const a=Sv(CWe),{active:o,dispatch:l,over:c,measureDroppableContainers:u}=_.useContext($2),d=_.useRef({disabled:n}),f=_.useRef(!1),p=_.useRef(null),m=_.useRef(null),{disabled:x,updateMeasurementsFor:b,timeout:v}={...PWe,...i},y=Py(b??r),S=_.useCallback(()=>{if(!f.current){f.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(y.current)?y.current:[y.current]),m.current=null},v)},[v]),k=H2({callback:S,disabled:x||!o}),T=_.useCallback((R,A)=>{k&&(A&&(k.unobserve(A),f.current=!1),R&&k.observe(R))},[k]),[M,C]=QN(T),E=Py(e);return _.useEffect(()=>{!k||!M.current||(k.disconnect(),f.current=!1,k.observe(M.current))},[M,k]),_.useEffect(()=>(l({type:Yi.RegisterDroppable,element:{id:r,key:a,disabled:n,node:M,rect:p,data:E}}),()=>l({type:Yi.UnregisterDroppable,key:a,id:r})),[r]),_.useEffect(()=>{n!==d.current.disabled&&(l({type:Yi.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,l]),{active:o,rect:p,isOver:c?.id===r,node:M,over:c,setNodeRef:C}}function V2(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function DWe(t,e){return t.reduce((n,r,i)=>{const a=e.get(r);return a&&(n[i]=a),n},Array(t.length))}function u1(t){return t!==null&&t>=0}function RWe(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 OWe(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const lF=t=>{let{rects:e,activeIndex:n,overIndex:r,index:i}=t;const a=V2(e,r,n),o=e[i],l=a[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}},d1={scaleX:1,scaleY:1},LWe=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:i,rects:a,overIndex:o}=t;const l=(e=a[n])!=null?e:r;if(!l)return null;if(i===n){const u=a[o];return u?{x:0,y:n<o?u.top+u.height-(l.top+l.height):u.top-l.top,...d1}:null}const c=FWe(a,i,n);return i>n&&i<=o?{x:0,y:-l.height-c,...d1}:i<n&&i>=o?{x:0,y:l.height+c,...d1}:{x:0,y:0,...d1}};function FWe(t,e,n){const r=t[e],i=t[e-1],a=t[e+1];return r?n<e?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}const Pre="Sortable",jre=ei.createContext({activeIndex:-1,containerId:Pre,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:lF,disabled:{draggable:!1,droppable:!1}});function Dre(t){let{children:e,id:n,items:r,strategy:i=lF,disabled:a=!1}=t;const{active:o,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:d}=AWe(),f=Sv(Pre,n),p=l.rect!==null,m=_.useMemo(()=>r.map(C=>typeof C=="object"&&"id"in C?C.id:C),[r]),x=o!=null,b=o?m.indexOf(o.id):-1,v=u?m.indexOf(u.id):-1,y=_.useRef(m),S=!RWe(m,y.current),k=v!==-1&&b===-1||S,T=OWe(a);Nc(()=>{S&&x&&d(m)},[S,m,x,d]),_.useEffect(()=>{y.current=m},[m]);const M=_.useMemo(()=>({activeIndex:b,containerId:f,disabled:T,disableTransforms:k,items:m,overIndex:v,useDragOverlay:p,sortedRects:DWe(m,c),strategy:i}),[b,f,T.draggable,T.droppable,k,m,v,c,p,i]);return ei.createElement(jre.Provider,{value:M},e)}const IWe=t=>{let{id:e,items:n,activeIndex:r,overIndex:i}=t;return V2(n,r,i).indexOf(e)},UWe=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:l,previousContainerId:c,transition:u}=t;return!u||!r||l!==a&&i===o?!1:n?!0:o!==i&&e===c},zWe={duration:200,easing:"ease"},Rre="transform",BWe=mx.Transition.toString({property:Rre,duration:0,easing:"linear"}),HWe={roleDescription:"sortable"};function $We(t){let{disabled:e,index:n,node:r,rect:i}=t;const[a,o]=_.useState(null),l=_.useRef(n);return Nc(()=>{if(!e&&n!==l.current&&r.current){const c=i.current;if(c){const u=Ix(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(()=>{a&&o(null)},[a]),a}function Ore(t){let{animateLayoutChanges:e=UWe,attributes:n,disabled:r,data:i,getNewIndex:a=IWe,id:o,strategy:l,resizeObserverConfig:c,transition:u=zWe}=t;const{items:d,containerId:f,activeIndex:p,disabled:m,disableTransforms:x,sortedRects:b,overIndex:v,useDragOverlay:y,strategy:S}=_.useContext(jre),k=VWe(r,m),T=d.indexOf(o),M=_.useMemo(()=>({sortable:{containerId:f,index:T,items:d},...i}),[f,i,T,d]),C=_.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:E,node:R,isOver:A,setNodeRef:D}=jWe({id:o,data:M,disabled:k.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:I,activatorEvent:F,activeNodeRect:z,attributes:P,setNodeRef:$,listeners:X,isDragging:V,over:Q,setActivatorNodeRef:Z,transform:se}=TWe({id:o,data:M,attributes:{...HWe,...n},disabled:k.draggable}),H=hqe(D,$),K=!!I,re=K&&!x&&u1(p)&&u1(v),ne=!y&&V,be=ne&&re?se:null,de=re?be??(l??S)({rects:b,activeNodeRect:z,activeIndex:p,overIndex:v,index:T}):null,Ce=u1(p)&&u1(v)?a({id:o,items:d,activeIndex:p,overIndex:v}):T,ie=I?.id,ke=_.useRef({activeId:ie,items:d,newIndex:Ce,containerId:f}),Oe=d!==ke.current.items,pe=e({active:I,containerId:f,isDragging:V,isSorting:K,id:o,index:T,items:d,newIndex:ke.current.newIndex,previousItems:ke.current.items,previousContainerId:ke.current.containerId,transition:u,wasDragging:ke.current.activeId!=null}),We=$We({disabled:!pe,index:T,node:R,rect:E});return _.useEffect(()=>{K&&ke.current.newIndex!==Ce&&(ke.current.newIndex=Ce),f!==ke.current.containerId&&(ke.current.containerId=f),d!==ke.current.items&&(ke.current.items=d)},[K,Ce,f,d]),_.useEffect(()=>{if(ie===ke.current.activeId)return;if(ie!=null&&ke.current.activeId==null){ke.current.activeId=ie;return}const Y=setTimeout(()=>{ke.current.activeId=ie},50);return()=>clearTimeout(Y)},[ie]),{active:I,activeIndex:p,attributes:P,data:M,rect:E,index:T,newIndex:Ce,items:d,isOver:A,isSorting:K,isDragging:V,listeners:X,node:R,overIndex:v,over:Q,setNodeRef:H,setActivatorNodeRef:Z,setDroppableNodeRef:D,setDraggableNodeRef:$,transform:We??de,transition:G()};function G(){if(We||Oe&&ke.current.newIndex===T)return BWe;if(!(ne&&!aF(F)||!u)&&(K||pe))return mx.Transition.toString({...u,property:Rre})}}function VWe(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 tM(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 GWe=[Qn.Down,Qn.Right,Qn.Up,Qn.Left],Lre=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:l}}=e;if(GWe.includes(t.code)){if(t.preventDefault(),!n||!r)return;const c=[];a.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const p=i.get(f.id);if(p)switch(t.code){case Qn.Down:r.top<p.top&&c.push(f);break;case Qn.Up:r.top>p.top&&c.push(f);break;case Qn.Left:r.left>p.left&&c.push(f);break;case Qn.Right:r.left<p.left&&c.push(f);break}});const u=Eqe({collisionRect:r,droppableRects:i,droppableContainers:c});let d=gre(u,"id");if(d===o?.id&&u.length>1&&(d=u[1].id),d!=null){const f=a.get(n.id),p=a.get(d),m=p?i.get(p.id):null,x=p?.node.current;if(x&&m&&f&&p){const v=U2(x).some((C,E)=>l[E]!==C),y=Fre(f,p),S=qWe(f,p),k=v||!y?{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 k.x&&k.y?T:jy(T,k)}}}};function Fre(t,e){return!tM(t)||!tM(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function qWe(t,e){return!tM(t)||!tM(e)||!Fre(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}function Ire(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 WWe(t,e="system",n){if(!t)return n?.("queue.time.asap")??"ASAP";const r=Ui(t);if(!r)return n?.("queue.time.asap")??"ASAP";const i=new Date,a=r.getTime()-i.getTime();return a<-6e4?n?.("queue.time.overdue")??"Overdue":a<0?n?.("queue.time.now")??"Now":a<6e4?n?.("queue.time.lessThanMinute")??"In less than a minute":a<36e5?n?.("queue.time.inMinutes",{count:Math.round(a/6e4)})??`In ${Math.round(a/6e4)} min`:a<864e5?n?.("queue.time.inHours",{count:Math.round(a/36e5)})??`In ${Math.round(a/36e5)} hours`:Hg(t,e)}function KWe({status:t,waitingReason:e,t:n}){if(t==="pending"&&e)return s.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:[s.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:bo,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:Qi,color:"text-status-error bg-status-error/10 border-status-error/20",label:n("queue.status.failed")},skipped:{icon:DR,color:"text-orange-400 bg-orange-400/10 border-orange-400/20",label:n("queue.status.skipped")},cancelled:{icon:Rt,color:"text-gray-400 bg-gray-400/10 border-gray-400/20",label:n("queue.status.cancelled")}},{icon:i,color:a,label:o}=r[t];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${a}`,children:[s.jsx(i,{className:"w-3.5 h-3.5"}),o]})}function XWe({selectedCount:t,printers:e,onSave:n,onClose:r,isSaving:i,t:a}){const[o,l]=_.useState("unchanged"),[c,u]=_.useState("unchanged"),[d,f]=_.useState("unchanged"),[p,m]=_.useState("unchanged"),[x,b]=_.useState("unchanged"),[v,y]=_.useState("unchanged"),[S,k]=_.useState("unchanged"),[T,M]=_.useState("unchanged"),[C,E]=_.useState("unchanged"),[R,A]=_.useState("unchanged"),D=()=>{const F={};o!=="unchanged"&&(F.printer_id=o),c!=="unchanged"&&(F.manual_start=c),d!=="unchanged"&&(F.auto_off_after=d),p!=="unchanged"&&(F.require_previous_success=p),x!=="unchanged"&&(F.bed_levelling=x),v!=="unchanged"&&(F.flow_cali=v),S!=="unchanged"&&(F.vibration_cali=S),T!=="unchanged"&&(F.layer_inspect=T),C!=="unchanged"&&(F.timelapse=C),R!=="unchanged"&&(F.use_ams=R),n(F)},I=o!=="unchanged"||c!=="unchanged"||d!=="unchanged"||p!=="unchanged"||x!=="unchanged"||v!=="unchanged"||S!=="unchanged"||T!=="unchanged"||C!=="unchanged"||R!=="unchanged";return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",children:s.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:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:a("queue.bulkEdit.title",{count:t})}),s.jsx("button",{onClick:r,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:a("queue.bulkEdit.description")}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:a("queue.bulkEdit.printer")}),s.jsxs("select",{value:o===null?"null":o==="unchanged"?"unchanged":String(o),onChange:F=>{const z=F.target.value;l(z==="unchanged"?"unchanged":z==="null"?null:Number(z))},className:"w-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:[s.jsx("option",{value:"unchanged",children:a("queue.bulkEdit.noChange")}),s.jsx("option",{value:"null",children:a("queue.filter.unassigned")}),e.map(F=>s.jsx("option",{value:F.id,children:F.name},F.id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:a("queue.bulkEdit.queueOptions")}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ou,{label:a("queue.bulkEdit.staged"),value:c,onChange:u,t:a}),s.jsx(ou,{label:a("queue.bulkEdit.autoPowerOff"),value:d,onChange:f,t:a}),s.jsx(ou,{label:a("queue.bulkEdit.requirePrevious"),value:p,onChange:m,t:a})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:a("queue.bulkEdit.printOptions")}),s.jsxs("div",{className:"space-y-2",children:[s.jsx(ou,{label:a("queue.bulkEdit.bedLevelling"),value:x,onChange:b,t:a}),s.jsx(ou,{label:a("queue.bulkEdit.flowCalibration"),value:v,onChange:y,t:a}),s.jsx(ou,{label:a("queue.bulkEdit.vibrationCalibration"),value:S,onChange:k,t:a}),s.jsx(ou,{label:a("queue.bulkEdit.layerInspection"),value:T,onChange:M,t:a}),s.jsx(ou,{label:a("queue.bulkEdit.timelapse"),value:C,onChange:E,t:a}),s.jsx(ou,{label:a("queue.bulkEdit.useAms"),value:R,onChange:A,t:a})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 p-4 border-t border-bambu-dark-tertiary",children:[s.jsx(Te,{variant:"secondary",onClick:r,children:a("common.cancel")}),s.jsx(Te,{onClick:D,disabled:!I||i,children:a(i?"common.saving":"queue.bulkEdit.applyChanges")})]})]})})}function ou({label:t,value:e,onChange:n,t:r}){return s.jsxs("div",{className:"flex items-center justify-between py-1",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:t}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark rounded-lg p-0.5",children:[s.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:"—"}),s.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")}),s.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 HP({item:t,position:e,onEdit:n,onCancel:r,onRemove:i,onStop:a,onRequeue:o,onStart:l,timeFormat:c="system",isSelected:u=!1,onToggleSelect:d,hasPermission:f,canModify:p,t:m}){const x=f("queue:reorder"),{attributes:b,listeners:v,setNodeRef:y,transform:S,transition:k,isDragging:T}=Ore({id:t.id,disabled:t.status!=="pending"||!x}),M={transform:mx.Transform.toString(S),transition:k},C=t.status==="printing",E=t.status==="pending",R=["completed","failed","skipped","cancelled"].includes(t.status);return s.jsx("div",{ref:y,style:M,className:`
- group relative bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary
- transition-all duration-200 hover:border-bambu-dark-tertiary/80
- ${T?"opacity-50 scale-[1.02] shadow-xl z-50":""}
- ${C?"border-blue-500/30 bg-gradient-to-r from-blue-500/5 to-transparent":""}
- `,children:s.jsxs("div",{className:"flex items-center gap-4 p-4",children:[E&&d&&s.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&&s.jsx(Na,{className:"w-4 h-4"})}),E?s.jsx("div",{...b,...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:s.jsx(zg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}):e!==void 0?s.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]}):s.jsx("div",{className:"w-8"}),s.jsx("div",{className:"w-14 h-14 flex-shrink-0 bg-bambu-dark rounded-lg overflow-hidden",children:t.archive_thumbnail?s.jsx("img",{src:t.plate_id!=null?ce.getArchivePlateThumbnail(t.archive_id,t.plate_id):ce.getArchiveThumbnail(t.archive_id),alt:"",className:"w-full h-full object-cover"}):t.library_file_thumbnail?s.jsx("img",{src:t.plate_id!=null?ce.getLibraryFilePlateThumbnail(t.library_file_id,t.plate_id):ce.getLibraryFileThumbnailUrl(t.library_file_id),alt:"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s.jsx(sl,{className:"w-6 h-6"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[s.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?s.jsx(Ds,{to:`/archives?highlight=${t.archive_id}`,className:"text-bambu-gray hover:text-bambu-green transition-colors flex-shrink-0",title:m("queue.viewArchive"),children:s.jsx(Xr,{className:"w-3.5 h-3.5"})}):t.library_file_id?s.jsx(Ds,{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:s.jsx(Xr,{className:"w-3.5 h-3.5"})}):null]}),s.jsxs("div",{className:"flex items-center gap-3 text-sm text-bambu-gray",children:[s.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:[s.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&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(bu,{className:"w-3.5 h-3.5"}),Ire(t.print_time_seconds)]}),t.created_by_username&&s.jsxs("span",{className:"flex items-center gap-1.5",title:m("queue.addedBy",{name:t.created_by_username}),children:[s.jsx(am,{className:"w-3.5 h-3.5"}),t.created_by_username]}),E&&!t.manual_start&&s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx(tr,{className:"w-3.5 h-3.5"}),WWe(t.scheduled_time,c,m)]})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[t.manual_start&&s.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:[s.jsx(_W,{className:"w-3 h-3"}),m("queue.badges.staged")]}),t.require_previous_success&&s.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&&s.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:[s.jsx(Gu,{className:"w-3 h-3"}),m("queue.badges.autoPowerOff")]})]}),C&&s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-gradient-to-r from-blue-500 to-blue-400 animate-pulse w-full opacity-50"})}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:m("queue.printingInProgress")})]}),t.waiting_reason&&t.status==="pending"&&s.jsxs("p",{className:"text-xs text-purple-400 mt-2 flex items-start gap-1",children:[s.jsx($i,{className:"w-3 h-3 mt-0.5 flex-shrink-0"}),s.jsx("span",{children:t.waiting_reason})]}),t.error_message&&s.jsxs("p",{className:"text-xs text-red-400 mt-2 flex items-center gap-1",children:[s.jsx($i,{className:"w-3 h-3"}),t.error_message]})]}),s.jsx(KWe,{status:t.status,waitingReason:t.waiting_reason,t:m}),s.jsxs("div",{className:"flex items-center gap-1",children:[C&&s.jsx(Te,{variant:"ghost",size:"sm",onClick:a,disabled:!f("printers:control"),title:f("printers:control")?m("queue.actions.stopPrint"):m("queue.permissions.noStopPrint"),className:"text-red-400 hover:text-red-300 hover:bg-red-500/10",children:s.jsx(eue,{className:"w-4 h-4"})}),E&&s.jsxs(s.Fragment,{children:[t.manual_start&&s.jsx(Te,{variant:"ghost",size:"sm",onClick:l,disabled:!f("printers:control"),title:f("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:s.jsx(bo,{className:"w-4 h-4"})}),s.jsx(Te,{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:s.jsx(Zi,{className:"w-4 h-4"})}),s.jsx(Te,{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:s.jsx(Rt,{className:"w-4 h-4"})})]}),R&&s.jsxs(s.Fragment,{children:[s.jsx(Te,{variant:"ghost",size:"sm",onClick:o,disabled:!f("queue:create"),title:f("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:s.jsx(Dr,{className:"w-4 h-4"})}),s.jsx(Te,{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:s.jsx(an,{className:"w-4 h-4"})})]})]})]})})}function YWe(){const{t}=Rn(),e=sn(),{showToast:n}=Hn(),{hasPermission:r,hasAnyPermission:i,canModify:a}=Ci(),[o,l]=_.useState(null),[c,u]=_.useState(""),[d,f]=_.useState(""),[p,m]=_.useState(!1),[x,b]=_.useState(null),[v,y]=_.useState(null),[S,k]=_.useState(null),[T,M]=_.useState([]),[C,E]=_.useState(!1),[R,A]=_.useState(()=>localStorage.getItem("queue.historySortBy")||"date"),[D,I]=_.useState(()=>{const U=localStorage.getItem("queue.historySortAsc");return U!==null?U==="true":!1}),[F,z]=_.useState(()=>localStorage.getItem("queue.pendingSortBy")||"position"),[P,$]=_.useState(()=>{const U=localStorage.getItem("queue.pendingSortAsc");return U!==null?U==="true":!0});_.useEffect(()=>{localStorage.setItem("queue.historySortBy",R)},[R]),_.useEffect(()=>{localStorage.setItem("queue.historySortAsc",String(D))},[D]),_.useEffect(()=>{localStorage.setItem("queue.pendingSortBy",F)},[F]),_.useEffect(()=>{localStorage.setItem("queue.pendingSortAsc",String(P))},[P]);const X=fre(JN(B2,{activationConstraint:{distance:8}}),JN(z2,{coordinateGetter:Lre})),{data:V}=ot({queryKey:["settings"],queryFn:ce.getSettings}),Q=V?.time_format||"system",{data:Z,isLoading:se}=ot({queryKey:["queue",o,c],queryFn:()=>ce.getQueue(o||void 0,c||void 0),refetchInterval:5e3}),{data:H}=ot({queryKey:["printers"],queryFn:()=>ce.getPrinters()}),K=mt({mutationFn:U=>ce.cancelQueueItem(U),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.cancelled"))},onError:()=>n(t("queue.toast.cancelFailed"),"error")}),re=mt({mutationFn:U=>ce.removeFromQueue(U),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.removed"))},onError:()=>n(t("queue.toast.removeFailed"),"error")}),ne=mt({mutationFn:U=>ce.stopQueueItem(U),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.stopped"))},onError:()=>n(t("queue.toast.stopFailed"),"error")}),be=mt({mutationFn:U=>ce.startQueueItem(U),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.released"))},onError:()=>n(t("queue.toast.startFailed"),"error")}),me=mt({mutationFn:U=>ce.reorderQueue(U),onSuccess:()=>{e.invalidateQueries({queryKey:["queue"]})},onError:()=>n(t("queue.toast.reorderFailed"),"error")}),de=mt({mutationFn:async()=>{const U=Z?.filter(he=>["completed","failed","skipped","cancelled"].includes(he.status))||[];for(const he of U)await ce.removeFromQueue(he.id);return U.length},onSuccess:U=>{e.invalidateQueries({queryKey:["queue"]}),n(t("queue.toast.historyCleared",{count:U}))},onError:()=>n(t("queue.toast.clearHistoryFailed"),"error")}),Ce=mt({mutationFn:U=>ce.bulkUpdateQueue(U),onSuccess:U=>{e.invalidateQueries({queryKey:["queue"]}),M([]),E(!1),n(U.message)},onError:()=>n(t("queue.toast.updateFailed"),"error")}),ie=mt({mutationFn:async U=>{for(const he of U)await ce.cancelQueueItem(he);return U.length},onSuccess:U=>{e.invalidateQueries({queryKey:["queue"]}),M([]),n(t("queue.toast.bulkCancelled",{count:U}))},onError:()=>n(t("queue.toast.bulkCancelFailed"),"error")}),ke=U=>{M(he=>he.includes(U)?he.filter(Me=>Me!==U):[...he,U])},Oe=_.useMemo(()=>{const U=new Set;return H?.forEach(he=>{he.location&&U.add(he.location)}),Z?.forEach(he=>{he.target_location&&U.add(he.target_location)}),Array.from(U).sort()},[H,Z]),pe=_.useCallback(U=>d?U.target_location?U.target_location===d:U.printer_id?H?.find(Me=>Me.id===U.printer_id)?.location===d:!1:!0,[d,H]),We=_.useMemo(()=>{let U=Z?.filter(Me=>Me.status==="pending")||[];d&&(U=U.filter(pe));const he=Me=>{if(!Me.scheduled_time)return 0;const ge=new Date(Me.scheduled_time).getTime(),B=Date.now()+4320*60*60*1e3;return ge>B?0:ge};return[...U].sort((Me,ge)=>{let B;if(F==="name"){const O=Me.archive_name||Me.library_file_name||"",ee=ge.archive_name||ge.library_file_name||"";B=O.localeCompare(ee)}else F==="printer"?B=(Me.printer_name||"").localeCompare(ge.printer_name||""):F==="time"?B=he(Me)-he(ge):B=Me.position-ge.position;return P?B:-B})},[Z,F,P,pe,d]),G=()=>{const U=We.map(he=>he.id);T.length===U.length?M([]):M(U)},Y=_.useMemo(()=>{let U=Z?.filter(he=>he.status==="printing")||[];return d&&(U=U.filter(pe)),U},[Z,d,pe]),ue=_.useMemo(()=>{let U=Z?.filter(he=>["completed","failed","skipped","cancelled"].includes(he.status))||[];return d&&(U=U.filter(pe)),[...U].sort((he,Me)=>{let ge;if(R==="name"){const B=he.archive_name||he.library_file_name||"",O=Me.archive_name||Me.library_file_name||"";ge=B.localeCompare(O)}else R==="printer"?ge=(he.printer_name||"").localeCompare(Me.printer_name||""):ge=new Date(Me.completed_at||Me.created_at).getTime()-new Date(he.completed_at||he.created_at).getTime();return D?-ge:ge})},[Z,R,D,pe,d]),q=_.useMemo(()=>We.reduce((U,he)=>U+(he.print_time_seconds||0),0),[We]),te=U=>{const{active:he,over:Me}=U;if(!Me||he.id===Me.id)return;const ge=We.findIndex(O=>O.id===he.id),B=We.findIndex(O=>O.id===Me.id);if(ge!==-1&&B!==-1){const ee=V2(We,ge,B).map((le,_e)=>({id:le.id,position:_e+1}));me.mutate(ee)}};return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsx("div",{className:"flex items-center justify-between mb-8",children:s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx(SW,{className:"w-7 h-7 text-bambu-green"}),t("queue.title")]}),s.jsx("p",{className:"text-bambu-gray mt-1",children:t("queue.subtitle")})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8",children:[s.jsx(St,{className:"bg-gradient-to-br from-blue-500/10 to-transparent border-blue-500/20",children:s.jsx(Nt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-blue-500/20 flex items-center justify-center",children:s.jsx(bo,{className:"w-5 h-5 text-blue-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:Y.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.printing")})]})]})})}),s.jsx(St,{className:"bg-gradient-to-br from-yellow-500/10 to-transparent border-yellow-500/20",children:s.jsx(Nt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-yellow-500/20 flex items-center justify-center",children:s.jsx(tr,{className:"w-5 h-5 text-yellow-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:We.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.queued")})]})]})})}),s.jsx(St,{className:"bg-gradient-to-br from-bambu-green/10 to-transparent border-bambu-green/20",children:s.jsx(Nt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-bambu-green/20 flex items-center justify-center",children:s.jsx(bu,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:Ire(q)}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.totalTime")})]})]})})}),s.jsx(St,{className:"bg-gradient-to-br from-gray-500/10 to-transparent border-gray-500/20",children:s.jsx(Nt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-10 h-10 rounded-lg bg-gray-500/20 flex items-center justify-center",children:s.jsx(Ar,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-bold text-white",children:ue.length}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("queue.summary.history")})]})]})})})]}),s.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[s.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:U=>{const he=U.target.value;l(he==="unassigned"?-1:he===""?null:Number(he))},children:[s.jsx("option",{value:"",children:t("queue.filter.allPrinters")}),s.jsx("option",{value:"unassigned",children:t("queue.filter.unassigned")}),H?.map(U=>s.jsx("option",{value:U.id,children:U.name},U.id))]}),s.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:U=>u(U.target.value),children:[s.jsx("option",{value:"",children:t("queue.filter.allStatus")}),s.jsx("option",{value:"pending",children:t("queue.status.pending")}),s.jsx("option",{value:"printing",children:t("queue.status.printing")}),s.jsx("option",{value:"completed",children:t("queue.status.completed")}),s.jsx("option",{value:"failed",children:t("queue.status.failed")}),s.jsx("option",{value:"skipped",children:t("queue.status.skipped")}),s.jsx("option",{value:"cancelled",children:t("queue.status.cancelled")})]}),Oe.length>0&&s.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:U=>f(U.target.value),children:[s.jsx("option",{value:"",children:t("queue.filter.allLocations")}),Oe.map(U=>s.jsx("option",{value:U,children:U},U))]}),s.jsx("div",{className:"flex-1"}),ue.length>0&&s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>m(!0),disabled:!r("queue:delete_all"),title:r("queue:delete_all")?void 0:t("queue.permissions.noClearHistory"),children:[s.jsx(an,{className:"w-4 h-4"}),t("queue.clearHistory")]})]}),se?s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("common.loading")}):Z?.length===0?s.jsxs(St,{className:"p-12 text-center border-dashed",children:[s.jsx(ti,{className:"w-16 h-16 text-bambu-gray mx-auto mb-4 opacity-50"}),s.jsx("h3",{className:"text-xl font-medium text-white mb-2",children:t("queue.empty.title")}),s.jsx("p",{className:"text-bambu-gray max-w-md mx-auto",children:t("queue.empty.description")})]}):s.jsxs("div",{className:"space-y-8",children:[Y.length>0&&s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white mb-4 flex items-center gap-2",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-400 animate-pulse"}),t("queue.sections.currentlyPrinting")]}),s.jsx("div",{className:"space-y-3",children:Y.map(U=>s.jsx(HP,{item:U,onEdit:()=>{},onCancel:()=>{},onRemove:()=>{},onStop:()=>k({type:"stop",item:U}),onRequeue:()=>{},onStart:()=>{},timeFormat:Q,hasPermission:r,canModify:a,t},U.id))})]}),We.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(tr,{className:"w-5 h-5 text-yellow-400"}),t("queue.sections.queued"),s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:We.length}),")"]}),s.jsx("span",{className:"text-xs text-bambu-gray ml-2",title:t("queue.reorderHint"),children:t("queue.dragToReorder")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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:F,onChange:U=>z(U.target.value),children:[s.jsx("option",{value:"position",children:t("queue.sort.byPosition")}),s.jsx("option",{value:"name",children:t("queue.sort.byName")}),s.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")}),s.jsx("option",{value:"time",children:t("queue.sort.bySchedule")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>$(!P),title:t(P?"common.ascending":"common.descending"),className:"px-2",children:P?s.jsx(Ig,{className:"w-4 h-4"}):s.jsx(G0,{className:"w-4 h-4"})})]})]}),s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-bambu-dark rounded-lg",children:[s.jsxs(Te,{variant:"ghost",size:"sm",onClick:G,className:"flex items-center gap-2",children:[T.length===We.length&&We.length>0?s.jsx(ol,{className:"w-4 h-4 text-bambu-green"}):s.jsx(ll,{className:"w-4 h-4"}),T.length===We.length&&We.length>0?t("queue.bulkEdit.deselectAll"):t("queue.bulkEdit.selectAll")]}),T.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:t("queue.bulkEdit.selected",{count:T.length})}),s.jsx("div",{className:"h-4 w-px bg-bambu-dark-tertiary"}),s.jsxs(Te,{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:[s.jsx(Zi,{className:"w-4 h-4"}),t("queue.bulkEdit.editSelected")]}),s.jsxs(Te,{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:[s.jsx(Rt,{className:"w-4 h-4"}),t("queue.bulkEdit.cancelSelected")]})]})]}),s.jsx(Cre,{sensors:X,collisionDetection:xre,onDragEnd:te,children:s.jsx(Dre,{items:We.map(U=>U.id),strategy:LWe,children:s.jsx("div",{className:"space-y-3",children:We.map((U,he)=>s.jsx(HP,{item:U,position:he+1,onEdit:()=>b(U),onCancel:()=>k({type:"cancel",item:U}),onRemove:()=>{},onStop:()=>{},onRequeue:()=>{},onStart:()=>be.mutate(U.id),timeFormat:Q,isSelected:T.includes(U.id),onToggleSelect:()=>ke(U.id),hasPermission:r,canModify:a,t},U.id))})})})]}),ue.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ar,{className:"w-5 h-5 text-bambu-gray"}),t("queue.sections.history"),s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",t("queue.itemCount",{count:ue.length}),")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.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:R,onChange:U=>A(U.target.value),children:[s.jsx("option",{value:"date",children:t("queue.sort.byDate")}),s.jsx("option",{value:"name",children:t("queue.sort.byName")}),s.jsx("option",{value:"printer",children:t("queue.sort.byPrinter")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>I(!D),title:t(D?"queue.sort.ascendingOldest":"queue.sort.descendingNewest"),className:"px-2",children:D?s.jsx(Ig,{className:"w-4 h-4"}):s.jsx(G0,{className:"w-4 h-4"})})]})]}),s.jsx("div",{className:"space-y-3",children:ue.slice(0,20).map((U,he)=>s.jsx(HP,{item:U,position:he+1,onEdit:()=>{},onCancel:()=>{},onRemove:()=>k({type:"remove",item:U}),onStop:()=>{},onRequeue:()=>y(U),onStart:()=>{},timeFormat:Q,hasPermission:r,canModify:a,t},U.id))})]})]}),x&&s.jsx(Ph,{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:()=>b(null)}),v&&s.jsx(Ph,{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:()=>y(null)}),S&&s.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"?K.mutate(S.item.id):S.type==="stop"?ne.mutate(S.item.id):re.mutate(S.item.id),k(null)},onCancel:()=>k(null)}),p&&s.jsx(Zn,{title:t("queue.confirm.clearHistoryTitle"),message:t("queue.confirm.clearHistoryMessage",{count:ue.length}),confirmText:t("queue.clearHistory"),variant:"danger",onConfirm:()=>{de.mutate(),m(!1)},onCancel:()=>m(!1)}),C&&s.jsx(XWe,{selectedCount:T.length,printers:H?.map(U=>({id:U.id,name:U.name}))||[],onSave:U=>{Object.keys(U).length>0&&Ce.mutate({item_ids:T,...U})},onClose:()=>E(!1),isSaving:Ce.isPending,t})]})}function QWe({printDates:t,months:e=3}){const n=_.useRef(null),[r,i]=_.useState(0);_.useEffect(()=>{const S=n.current;if(!S)return;const k=new ResizeObserver(T=>{const M=T[0]?.contentRect.width||0;i(M)});return k.observe(S),()=>k.disconnect()},[]);const{weeks:a,monthLabels:o,printCounts:l}=_.useMemo(()=>{const S={};t.forEach(I=>{const F=I.split("T")[0];S[F]=(S[F]||0)+1});const k=new Date,T=new Date(k);T.setMonth(T.getMonth()-e),T.setDate(T.getDate()-T.getDay());const M=[],C=[];let E=[],R=-1;const A=new Date(T);let D=0;for(;A<=k;)A.getDay()===0&&E.length>0&&(M.push(E),E=[],D++),A.getMonth()!==R&&(C.push({month:A.toLocaleDateString("en-US",{month:"short"}),weekIndex:D}),R=A.getMonth()),E.push(new Date(A)),A.setDate(A.getDate()+1);return E.length>0&&M.push(E),{weeks:M,monthLabels:C,printCounts:S}},[t,e]),c=Math.max(1,...Object.values(l)),u=S=>{if(S===0)return"bg-bambu-dark";const k=S/c;return k<=.25?"bg-bambu-green/30":k<=.5?"bg-bambu-green/50":k<=.75?"bg-bambu-green/75":"bg-bambu-green"},d=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],f=a.length,p=32,m=2,x=r-p-16,b=f>0?Math.floor((x-(f-1)*m)/f):12,v=Math.max(8,Math.min(20,b)),y=v<=10?10:12;return s.jsx("div",{ref:n,className:"w-full flex justify-center",children:r>0&&s.jsxs("div",{children:[s.jsx("div",{className:"flex mb-1",style:{marginLeft:p+4},children:o.map(({month:S,weekIndex:k},T)=>s.jsx("div",{className:"text-bambu-gray",style:{fontSize:y,marginLeft:T===0?0:`${(k-(o[T-1]?.weekIndex||0))*(v+m)-24}px`},children:S},T))}),s.jsxs("div",{className:"flex",style:{gap:m},children:[s.jsx("div",{className:"flex flex-col",style:{gap:m,marginRight:4,width:p},children:d.map((S,k)=>s.jsx("div",{className:"text-bambu-gray flex items-center",style:{width:p,height:v,fontSize:y,visibility:k%2===1?"visible":"hidden"},children:S},S))}),a.map((S,k)=>s.jsx("div",{className:"flex flex-col",style:{gap:m},children:[0,1,2,3,4,5,6].map(T=>{const M=S.find(A=>A.getDay()===T);if(!M)return s.jsx("div",{style:{width:v,height:v}},T);const C=M.toISOString().split("T")[0],E=l[C]||0,R=C===new Date().toISOString().split("T")[0];return s.jsx("div",{className:`rounded-sm ${u(E)} ${R?"ring-1 ring-white":""}`,style:{width:v,height:v},title:`${M.toLocaleDateString()}: ${E} print${E!==1?"s":""}`},T)})},k))]}),s.jsxs("div",{className:"flex items-center gap-2 mt-3 text-bambu-gray",style:{fontSize:y},children:[s.jsx("span",{children:"Less"}),s.jsxs("div",{className:"flex",style:{gap:m},children:[s.jsx("div",{className:"rounded-sm bg-bambu-dark",style:{width:v,height:v}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/30",style:{width:v,height:v}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/50",style:{width:v,height:v}}),s.jsx("div",{className:"rounded-sm bg-bambu-green/75",style:{width:v,height:v}}),s.jsx("div",{className:"rounded-sm bg-bambu-green",style:{width:v,height:v}})]}),s.jsx("span",{children:"More"})]})]})})}const h1=["#00ae42","#3b82f6","#f59e0b","#ef4444","#8b5cf6","#ec4899","#14b8a6","#f97316"];function ZWe(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 JWe({archives:t,currency:e="$"}){const[n,r]=_.useState("30d"),i=_.useMemo(()=>{const m=ZWe(n);return t.filter(x=>(Ui(x.completed_at||x.created_at)||new Date(0))>=m)},[t,n]),a=_.useMemo(()=>{const m=new Map;return i.forEach(x=>{const b=Ui(x.completed_at||x.created_at)||new Date,v=`${b.getFullYear()}-${String(b.getMonth()+1).padStart(2,"0")}-${String(b.getDate()).padStart(2,"0")}`,y=m.get(v)||{date:v,filament:0,cost:0,prints:0},S=x.quantity||1;y.filament+=(x.filament_used_grams||0)*S,y.cost+=x.cost||0,y.prints+=S,m.set(v,y)}),Array.from(m.values()).sort((x,b)=>x.date.localeCompare(b.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 a;const m=new Map;return i.forEach(x=>{const b=Ui(x.completed_at||x.created_at)||new Date,v=new Date(b);v.setDate(b.getDate()-b.getDay());const y=`${v.getFullYear()}-${String(v.getMonth()+1).padStart(2,"0")}-${String(v.getDate()).padStart(2,"0")}`,S=m.get(y)||{week:y,filament:0,cost:0,prints:0},k=x.quantity||1;S.filament+=(x.filament_used_grams||0)*k,S.cost+=x.cost||0,S.prints+=k,m.set(y,S)}),Array.from(m.values()).sort((x,b)=>x.week.localeCompare(b.week)).map(x=>({date:x.week,dateLabel:`Week of ${new Date(x.week).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`,...x}))},[i,a,n]),l=_.useMemo(()=>{const m=new Map;return i.forEach(x=>{const b=x.filament_type||"Unknown",v=x.quantity||1,y=b.split(", ");y.forEach(S=>{const k=(x.filament_used_grams||0)*v/y.length;m.set(S,(m.get(S)||0)+k)})}),Array.from(m.entries()).map(([x,b])=>({name:x,value:Math.round(b)})).sort((x,b)=>b.value-x.value)},[i]),c=_.useMemo(()=>{const m=new Date,x=[];for(let b=5;b>=0;b--){const v=new Date(m.getFullYear(),m.getMonth()-b,1),y=new Date(m.getFullYear(),m.getMonth()-b+1,0),S=v.toLocaleDateString("en-US",{month:"short",year:"2-digit"}),k=t.filter(T=>{const M=Ui(T.completed_at||T.created_at)||new Date(0);return M>=v&&M<=y});x.push({month:S,filament:Math.round(k.reduce((T,M)=>T+(M.filament_used_grams||0)*(M.quantity||1),0)),cost:k.reduce((T,M)=>T+(M.cost||0),0),prints:k.reduce((T,M)=>T+(M.quantity||1),0)})}return x},[t]),u=n==="7d"||n==="30d"?a:o,d=i.reduce((m,x)=>m+(x.filament_used_grams||0)*(x.quantity||1),0),f=i.reduce((m,x)=>m+(x.cost||0),0),p=i.reduce((m,x)=>m+(x.quantity||1),0);return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:"Filament Usage Trends"}),s.jsx("div",{className:"flex gap-1 bg-bambu-dark rounded-lg p-1",children:["7d","30d","90d","365d","all"].map(m=>s.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))})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Filament"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[(d/1e3).toFixed(2),"kg"]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[d.toFixed(0),"g total"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Period Cost"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[e,f.toFixed(2)]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[p," prints"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Avg per Print"}),s.jsxs("p",{className:"text-2xl font-bold text-white",children:[p>0?(d/p).toFixed(0):0,"g"]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[e,p>0?(f/p).toFixed(2):"0.00"," avg"]})]})]}),u.length>0?s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Usage Over Time"}),s.jsx(w1,{width:"100%",height:250,children:s.jsxs(XCe,{data:u,children:[s.jsx("defs",{children:s.jsxs("linearGradient",{id:"colorFilament",x1:"0",y1:"0",x2:"0",y2:"1",children:[s.jsx("stop",{offset:"5%",stopColor:"#00ae42",stopOpacity:.3}),s.jsx("stop",{offset:"95%",stopColor:"#00ae42",stopOpacity:0})]})}),s.jsx(HS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(VS,{dataKey:"dateLabel",stroke:"#9ca3af",tick:{fontSize:12},interval:"preserveStartEnd"}),s.jsx(GS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(S1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},labelStyle:{color:"#fff"},formatter:m=>[`${Number(m??0).toFixed(0)}g`,"Filament"]}),s.jsx(LZ,{type:"monotone",dataKey:"filament",stroke:"#00ae42",strokeWidth:2,fillOpacity:1,fill:"url(#colorFilament)"})]})})]}):s.jsx("div",{className:"bg-bambu-dark rounded-lg p-8 text-center text-bambu-gray",children:"No data for selected time range"}),s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"By Filament Type"}),l.length>0?s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(w1,{width:160,height:160,children:s.jsxs(WCe,{children:[s.jsx(sZ,{data:l,cx:"50%",cy:"50%",innerRadius:40,outerRadius:70,paddingAngle:2,dataKey:"value",children:l.map((m,x)=>s.jsx(uv,{fill:h1[x%h1.length]},`cell-${x}`))}),s.jsx(S1,{contentStyle:{backgroundColor:"#2d2d2d",border:"1px solid #3d3d3d",borderRadius:"8px"},formatter:m=>[`${m??0}g`,"Usage"]})]})}),s.jsx("div",{className:"flex-1 space-y-2 overflow-hidden",children:l.map((m,x)=>{const b=l.reduce((y,S)=>y+S.value,0),v=b>0?(m.value/b*100).toFixed(0):0;return s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("div",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:h1[x%h1.length]}}),s.jsx("span",{className:"text-white truncate flex-1",children:m.name}),s.jsxs("span",{className:"text-bambu-gray flex-shrink-0",children:[v,"%"]})]},m.name)})})]}):s.jsx("div",{className:"h-[160px] flex items-center justify-center text-bambu-gray",children:"No filament data"})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4",children:[s.jsx("h4",{className:"text-sm font-medium text-bambu-gray mb-4",children:"Monthly Comparison"}),s.jsx(w1,{width:"100%",height:200,children:s.jsxs(OCe,{data:c,children:[s.jsx(HS,{strokeDasharray:"3 3",stroke:"#3d3d3d"}),s.jsx(VS,{dataKey:"month",stroke:"#9ca3af",tick:{fontSize:12}}),s.jsx(GS,{stroke:"#9ca3af",tick:{fontSize:12},tickFormatter:m=>`${m}g`}),s.jsx(S1,{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"]}),s.jsx(dO,{}),s.jsx(hZ,{dataKey:"filament",name:"Filament (g)",fill:"#00ae42",radius:[4,4,0,0]})]})})]})]})]})}function eKe({id:t,title:e,component:n,isHidden:r,size:i,onToggleVisibility:a,onToggleSize:o}){const{attributes:l,listeners:c,setNodeRef:u,transform:d,transition:f,isDragging:p}=Ore({id:t}),m={transform:mx.Transform.toString(d),transition:f,opacity:p?.5:1};return r?null:s.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:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/30",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.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:s.jsx(zg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray"})}),s.jsx("h3",{className:"text-sm font-medium text-white",children:e})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.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?s.jsx(MW,{className:"w-4 h-4 text-bambu-gray hover:text-white"}):s.jsx(NW,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),s.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",title:"Hide widget",children:s.jsx(cM,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]})]}),s.jsx("div",{className:"p-4",children:typeof n=="function"?n(i):n})]})}function tKe({widgets:t,storageKey:e,columns:n=4,hideControls:r=!1,onResetLayout:i,renderControls:a}){const o=()=>{const T={};return t.forEach(M=>{T[M.id]=M.defaultSize||4}),T},[l,c]=_.useState(()=>{const T=localStorage.getItem(e);if(T)try{const M=JSON.parse(T);return M.sizes||(M.sizes=o()),M}catch{}return{order:t.map(M=>M.id),hidden:t.filter(M=>M.defaultVisible===!1).map(M=>M.id),sizes:o()}}),[u,d]=_.useState(!1);_.useEffect(()=>{const T=()=>d(M=>!M);return window.addEventListener("toggle-hidden-panel",T),()=>window.removeEventListener("toggle-hidden-panel",T)},[]),_.useEffect(()=>{localStorage.setItem(e,JSON.stringify(l))},[l,e]),_.useEffect(()=>{const M=t.map(C=>C.id).filter(C=>!l.order.includes(C));M.length>0&&c(C=>({...C,order:[...C.order,...M]}))},[t,l.order]);const f=fre(JN(B2,{activationConstraint:{distance:8}}),JN(z2,{coordinateGetter:Lre})),p=T=>{const{active:M,over:C}=T;C&&M.id!==C.id&&c(E=>{const R=E.order.indexOf(M.id),A=E.order.indexOf(C.id);return{...E,order:V2(E.order,R,A)}})},m=T=>{c(M=>({...M,hidden:M.hidden.includes(T)?M.hidden.filter(C=>C!==T):[...M.hidden,T]}))},x=T=>{c(M=>{const C=M.sizes[T]||4,E=C===1?2:C===2?4:1;return{...M,sizes:{...M.sizes,[T]:E}}})},b=()=>{const T={order:t.map(M=>M.id),hidden:t.filter(M=>M.defaultVisible===!1).map(M=>M.id),sizes:o()};c(T),i?.()},v=l.order.map(T=>t.find(M=>M.id===T)).filter(Boolean),y=v.filter(T=>!l.hidden.includes(T.id)),S=v.filter(T=>l.hidden.includes(T.id)),k=a?.({hiddenCount:S.length,showHiddenPanel:u,setShowHiddenPanel:d,resetLayout:b});return s.jsxs("div",{className:"space-y-4",children:[k,!r&&!a&&s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:b,children:[s.jsx(Rh,{className:"w-4 h-4"}),"Reset Layout"]}),S.length>0&&s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>d(!u),children:[s.jsx(mc,{className:"w-4 h-4"}),S.length," Hidden"]})]}),u&&S.length>0&&s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-xl border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:"Hidden widgets (click to show):"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:S.map(T=>s.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:[s.jsx(mc,{className:"w-3 h-3"}),T.title]},T.id))})]}),s.jsx(Cre,{sensors:f,collisionDetection:xre,onDragEnd:p,children:s.jsx(Dre,{items:y.map(T=>T.id),strategy:lF,children:s.jsx("div",{className:"grid gap-6",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`},children:y.map(T=>s.jsx(eKe,{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))})})}),y.length===0&&s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx("p",{children:"All widgets are hidden."}),s.jsx(Te,{className:"mt-4",onClick:b,children:"Reset Layout"})]})]})}function nKe({stats:t,currency:e,t:n}){return s.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-4",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:s.jsx(pc,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.totalPrints")}),s.jsx("p",{className:"text-xl font-bold text-white",children:t?.total_prints||0})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-blue-400",children:s.jsx(tr,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.printTime")}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_print_time_hours.toFixed(1)||0,"h"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-orange-400",children:s.jsx(pc,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentUsed")}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[((t?.total_filament_grams||0)/1e3).toFixed(2),"kg"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-green-400",children:s.jsx(hj,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.filamentCost")}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_cost.toFixed(2)||"0.00"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-400",children:s.jsx(vh,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyUsed")}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[t?.total_energy_kwh.toFixed(2)||"0.00"," kWh"]})]})]}),s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-yellow-500",children:s.jsx(hj,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:n("stats.energyCost")}),s.jsxs("p",{className:"text-xl font-bold text-white",children:[e," ",t?.total_energy_cost.toFixed(2)||"0.00"]})]})]})]})}function rKe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.total_prints?Math.round(t.successful_prints/t.total_prints*100):0,a=n===1?112:n===2?128:144,o=a/2-8,l=o*2*Math.PI;return s.jsxs("div",{className:"flex items-center gap-6",children:[s.jsxs("div",{className:"relative flex-shrink-0",style:{width:a,height:a},children:[s.jsxs("svg",{className:"w-full h-full -rotate-90",children:[s.jsx("circle",{cx:a/2,cy:a/2,r:o,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),s.jsx("circle",{cx:a/2,cy:a/2,r:o,fill:"none",stroke:"#00ae42",strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${i/100*l} ${l}`})]}),s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:s.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[i,"%"]})})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ar,{className:"w-4 h-4 text-status-ok flex-shrink-0"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.successful")}),s.jsx("span",{className:"text-sm text-white font-medium",children:t?.successful_prints||0})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qi,{className:"w-4 h-4 text-status-error flex-shrink-0"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:r("stats.failed")}),s.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&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:r("stats.printsByPrinter")}),s.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])=>s.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[s.jsx("span",{className:"text-bambu-gray truncate max-w-[120px]",children:e.get(c)||`${r("common.printer")} ${c}`}),s.jsx("span",{className:"text-white font-medium",children:u})]},c))})]})]})]})}function iKe({stats:t,printerMap:e,size:n=1,t:r}){const i=t?.average_time_accuracy;if(i==null)return s.jsx("div",{className:"flex items-center justify-center h-full",children:s.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=(b=>b>=95&&b<=105?"#00ae42":b>105?"#3b82f6":"#f97316")(i),u=i-100,d=n===1?112:n===2?128:144,f=d/2-8,p=f*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 s.jsxs("div",{className:"flex items-center gap-6",children:[s.jsxs("div",{className:"relative flex-shrink-0",style:{width:d,height:d},children:[s.jsxs("svg",{className:"w-full h-full -rotate-90",children:[s.jsx("circle",{cx:d/2,cy:d/2,r:f,fill:"none",stroke:"#3d3d3d",strokeWidth:"10"}),s.jsx("circle",{cx:d/2,cy:d/2,r:f,fill:"none",stroke:c,strokeWidth:"10",strokeLinecap:"round",strokeDasharray:`${o/100*p} ${p}`})]}),s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[s.jsxs("span",{className:`font-bold text-white ${n>=2?"text-2xl":"text-xl"}`,children:[i.toFixed(0),"%"]}),s.jsxs("span",{className:`text-xs ${u>=0?"text-blue-400":"text-orange-400"}`,children:[u>=0?"+":"",u.toFixed(0),"%"]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-bambu-gray",children:[s.jsx(PW,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{children:r("stats.perfectEstimate")})]}),x.length>0&&s.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(([b,v])=>s.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[s.jsx("span",{className:"text-bambu-gray truncate max-w-[100px]",children:e.get(b)||`${r("common.printer")} ${b}`}),s.jsxs("span",{className:`font-medium ${v>=95&&v<=105?"text-status-ok":v>105?"text-blue-400":"text-status-warning"}`,children:[v.toFixed(0),"%"]})]},b))})]})]})}function aKe({stats:t,size:e=1,t:n}){if(!t?.prints_by_filament_type||Object.keys(t.prints_by_filament_type).length===0)return s.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,a=r.slice(0,i),o=r.length>i;return e===4&&a.length>4?s.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:a.map(([l,c])=>{const u=Math.round(c/(t.total_prints||1)*100);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-white truncate max-w-[120px]",children:l}),s.jsx("span",{className:"text-bambu-gray",children:c})]}),s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:s.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${u}%`}})})]},l)})}):s.jsxs("div",{className:"space-y-3",children:[a.map(([l,c])=>{const u=Math.round(c/(t.total_prints||1)*100);return s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-white",children:l}),s.jsxs("span",{className:"text-bambu-gray",children:[c," ",n("common.prints")]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark rounded-full",children:s.jsx("div",{className:"h-full bg-bambu-green rounded-full transition-all",style:{width:`${u}%`}})})]},l)}),o&&s.jsx("p",{className:"text-xs text-bambu-gray text-center pt-1",children:n("common.more",{count:r.length-i})})]})}function sKe({printDates:t,size:e=2}){const n=e===1?3:e===2?6:12;return s.jsx(QWe,{printDates:t,months:n})}function oKe({stats:t,printerMap:e,t:n}){return!t?.prints_by_printer||Object.keys(t.prints_by_printer).length===0?s.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrinterData")}):s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:Object.entries(t.prints_by_printer).map(([r,i])=>s.jsxs("div",{className:"flex items-center gap-3 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("div",{className:"p-2 bg-bambu-dark-tertiary rounded-lg",children:s.jsx(Ur,{className:"w-4 h-4 text-bambu-green"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium text-sm",children:e.get(r)||`${n("common.printer")} ${r}`}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[i," ",n("common.prints")]})]})]},r))})}function lKe({archives:t,currency:e,t:n}){return!t||t.length===0?s.jsx("p",{className:"text-bambu-gray text-center py-4",children:n("stats.noPrintData")}):s.jsx(JWe,{archives:t,currency:e})}function cKe({size:t=1,t:e}){const{data:n,isLoading:r}=ot({queryKey:["failureAnalysis"],queryFn:()=>ce.getFailureAnalysis({days:30})});if(r)return s.jsx("div",{className:"flex justify-center py-4",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})});if(!n||n.total_prints===0)return s.jsx("p",{className:"text-bambu-gray text-center py-4",children:e("stats.noPrintDataLast30Days")});const i=t===1?5:t===2?8:999,a=Object.entries(n.failures_by_reason).sort(([,c],[,u])=>u-c),o=a.slice(0,i),l=a.length>i;return s.jsxs("div",{className:`${t>=2?"flex gap-8":"space-y-4"}`,children:[s.jsxs("div",{className:t>=2?"flex-shrink-0":"",children:[s.jsx("div",{className:"flex items-center gap-4",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Sn,{className:`w-5 h-5 ${n.failure_rate>20?"text-status-error":n.failure_rate>10?"text-status-warning":"text-status-ok"}`}),s.jsxs("span",{className:`font-bold text-white ${t>=2?"text-3xl":"text-2xl"}`,children:[n.failure_rate.toFixed(1),"%"]})]})}),s.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&&s.jsx("div",{className:`${t>=2?"mt-4":"mt-2 pt-2 border-t border-bambu-dark-tertiary"}`,children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(DW,{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"}`}),s.jsx("span",{className:"text-bambu-gray",children:e("stats.lastWeekRate",{rate:n.trend[n.trend.length-1].failure_rate.toFixed(1)})})]})})]}),o.length>0&&s.jsxs("div",{className:`flex-1 ${t>=2?"border-l border-bambu-dark-tertiary pl-8":"pt-2"}`,children:[s.jsx("p",{className:"text-xs text-bambu-gray font-medium mb-2",children:t>=2?e("stats.failureReasons"):e("stats.topFailureReasons")}),s.jsx("div",{className:`${t===4?"grid grid-cols-2 gap-x-6 gap-y-1":"space-y-1"}`,children:o.map(([c,u])=>s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("span",{className:`text-white truncate ${t===4?"max-w-[200px]":"max-w-[160px]"}`,children:c||e("common.unknown")}),s.jsx("span",{className:"text-bambu-gray ml-2",children:u})]},c))}),l&&s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:e("common.more",{count:a.length-i})})]})]})}function uKe(){const{t}=Rn(),{showToast:e}=Hn(),{hasPermission:n}=Ci(),[r,i]=_.useState(!1),[a,o]=_.useState(!1),[l,c]=_.useState(0),[u,d]=_.useState(0),[f,p]=_.useState(!1);_.useEffect(()=>{const A=()=>{try{const I=localStorage.getItem("bambusy-dashboard-layout");if(I){const F=JSON.parse(I);d(F.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:b}=ot({queryKey:["archiveStats"],queryFn:ce.getArchiveStats}),{data:v}=ot({queryKey:["printers"],queryFn:ce.getPrinters}),{data:y}=ot({queryKey:["archives"],queryFn:()=>ce.getArchives(void 0,void 0,1e3,0)}),{data:S}=ot({queryKey:["settings"],queryFn:ce.getSettings}),k=async A=>{o(!1),i(!0);try{const{blob:D,filename:I}=await ce.exportStats({format:A,days:90}),F=URL.createObjectURL(D),z=document.createElement("a");z.href=F,z.download=I,z.click(),URL.revokeObjectURL(F),e(t("stats.exportDownloaded"))}catch{e(t("stats.exportFailed"),"error")}finally{i(!1)}},T=async()=>{p(!0);try{const A=await ce.recalculateCosts();await b(),e(t("stats.recalculatedCosts",{count:A.updated}))}catch{e(t("stats.recalculateFailed"),"error")}finally{p(!1)}},M=S?.currency||"$",C=new Map(v?.map(A=>[String(A.id),A.name])||[]),E=y?.map(A=>A.created_at)||[];if(x)return s.jsx("div",{className:"p-4 md:p-8",children:s.jsx("div",{className:"text-center py-12 text-bambu-gray",children:t("stats.loadingStats")})});const R=[{id:"quick-stats",title:t("stats.quickStats"),component:s.jsx(nKe,{stats:m,currency:M,t}),defaultSize:2},{id:"success-rate",title:t("stats.successRate"),component:A=>s.jsx(rKe,{stats:m,printerMap:C,size:A,t}),defaultSize:1},{id:"time-accuracy",title:t("stats.timeAccuracy"),component:A=>s.jsx(iKe,{stats:m,printerMap:C,size:A,t}),defaultSize:1},{id:"filament-types",title:t("stats.filamentTypes"),component:A=>s.jsx(aKe,{stats:m,size:A,t}),defaultSize:1},{id:"failure-analysis",title:t("stats.failureAnalysis"),component:A=>s.jsx(cKe,{size:A,t}),defaultSize:1},{id:"print-activity",title:t("stats.printActivity"),component:A=>s.jsx(sKe,{printDates:E,size:A}),defaultSize:2},{id:"prints-by-printer",title:t("stats.printsByPrinter"),component:s.jsx(oKe,{stats:m,printerMap:C,t}),defaultSize:2},{id:"filament-trends",title:t("stats.filamentTrends"),component:s.jsx(lKe,{archives:y||[],currency:M,t}),defaultSize:4}];return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("stats.title")}),s.jsx("p",{className:"text-bambu-gray",children:t("stats.subtitle")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[u>0&&s.jsxs(Te,{variant:"secondary",onClick:()=>{window.dispatchEvent(new CustomEvent("toggle-hidden-panel"))},children:[s.jsx(mc,{className:"w-4 h-4"}),t("stats.hiddenCount",{count:u})]}),s.jsxs(Te,{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:[s.jsx(Rh,{className:"w-4 h-4"}),t("stats.resetLayout")]}),s.jsxs(Te,{variant:"secondary",onClick:T,disabled:f||!n("archives:update_all"),title:n("archives:update_all")?t("stats.recalculateCostsHint"):t("stats.noPermissionRecalculate"),children:[f?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Dce,{className:"w-4 h-4"}),t("stats.recalculateCosts")]}),s.jsxs("div",{className:"relative",children:[s.jsxs(Te,{variant:"secondary",onClick:()=>o(!a),disabled:r,children:[r?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(W1,{className:"w-4 h-4"}),t("stats.exportStats")]}),a&&s.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:[s.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:()=>k("csv"),children:[s.jsx(Ls,{className:"w-4 h-4"}),t("stats.exportAsCsv")]}),s.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:()=>k("xlsx"),children:[s.jsx(W1,{className:"w-4 h-4"}),t("stats.exportAsExcel")]})]})]})]})]}),s.jsx(tKe,{widgets:R,storageKey:"bambusy-dashboard-layout",hideControls:!0},l)]})}function dKe({plug:t,onEdit:e}){const n=sn(),{showToast:r}=Hn(),[i,a]=_.useState(!1),[o,l]=_.useState(!1),[c,u]=_.useState(!1),[d,f]=_.useState(!1),{data:p,isLoading:m}=ot({queryKey:["smart-plug-status",t.id],queryFn:()=>ce.getSmartPlugStatus(t.id),refetchInterval:3e4}),{data:x}=ot({queryKey:["printers"],queryFn:ce.getPrinters}),b=x?.find(A=>A.id===t.printer_id),v=mt({mutationFn:A=>ce.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],F=>({...F,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)}}),y=mt({mutationFn:A=>ce.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=mt({mutationFn:()=>ce.deleteSmartPlug(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),t.printer_id&&n.invalidateQueries({queryKey:["scriptPlugsByPrinter",t.printer_id]})}}),k=p?.state==="ON",T=t.plug_type==="mqtt"&&p?.energy?.power!==null&&p?.energy?.power!==void 0,M=(p?.reachable??!1)||T,C=v.isPending,R=(()=>{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 s.jsxs(s.Fragment,{children:[s.jsx(St,{className:"relative",children:s.jsxs(Nt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2 mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("div",{className:`p-2 rounded-lg flex-shrink-0 ${t.plug_type==="mqtt"?M?"bg-teal-500/20":"bg-red-500/20":M?k?"bg-bambu-green/20":"bg-bambu-dark":"bg-red-500/20"}`,children:t.plug_type==="mqtt"?s.jsx(PR,{className:`w-5 h-5 ${M?"text-teal-400":"text-red-400"}`}):t.plug_type==="homeassistant"?s.jsx(Fy,{className:`w-5 h-5 ${M?k?"text-bambu-green":"text-bambu-gray":"text-red-400"}`}):s.jsx(tl,{className:`w-5 h-5 ${M?k?"text-bambu-green":"text-bambu-gray":"text-red-400"}`})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"font-medium text-white truncate",children:t.name}),s.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})]})]}),s.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[m?s.jsx(ft,{className:"w-4 h-4 text-bambu-gray animate-spin"}):t.plug_type==="mqtt"?s.jsxs("div",{className:"flex items-center gap-1.5 text-sm whitespace-nowrap",children:[s.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"}),M&&s.jsx("span",{className:"text-status-ok",children:"✓"})]}):t.plug_type==="homeassistant"?s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx("span",{className:"px-1 py-0.5 bg-blue-500/20 text-blue-400 text-[10px] font-medium rounded",children:"HA"}),s.jsx("span",{className:M?k?"text-status-ok":"text-bambu-gray":"text-status-error",children:M?p?.state||"?":"Offline"})]}):M?s.jsxs("div",{className:"flex items-center gap-1 text-sm",children:[s.jsx(Sg,{className:"w-4 h-4 text-status-ok"}),s.jsx("span",{className:k?"text-status-ok":"text-bambu-gray",children:p?.state||"Unknown"})]}):s.jsxs("div",{className:"flex items-center gap-1 text-sm text-status-error",children:[s.jsx(sm,{className:"w-4 h-4"}),s.jsx("span",{children:"Offline"})]}),R&&s.jsxs("a",{href:R,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:[s.jsx(Xr,{className:"w-3 h-3"}),"Admin"]})]})]}),b&&s.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Linked to: "}),s.jsx("span",{className:"text-sm text-white",children:b.name})]}),(t.power_alert_enabled||t.schedule_enabled||t.plug_type==="mqtt")&&s.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-3",children:[t.plug_type==="mqtt"&&s.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:[s.jsx(mc,{className:"w-3 h-3"}),"Monitor Only"]}),t.power_alert_enabled&&s.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:[s.jsx(wg,{className:"w-3 h-3"}),"Alerts"]}),t.schedule_enabled&&s.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:[s.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"&&s.jsxs("div",{className:"flex gap-2 mb-3",children:[s.jsxs(Te,{size:"sm",variant:k?"primary":"secondary",disabled:!M||C,onClick:()=>l(!0),className:"flex-1",children:[C?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Gu,{className:"w-4 h-4"}),"On"]}),s.jsxs(Te,{size:"sm",variant:k?"secondary":"primary",disabled:!M||C,onClick:()=>u(!0),className:"flex-1",children:[C?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(gM,{className:"w-4 h-4"}),"Off"]})]}),t.plug_type==="mqtt"&&p?.energy&&s.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&&s.jsxs("div",{className:"flex-1 text-center",children:[s.jsxs("p",{className:"text-lg font-semibold text-white",children:[Math.round(p.energy.power),"W"]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Power"})]}),p.energy.today!==null&&p.energy.today!==void 0&&s.jsxs("div",{className:"flex-1 text-center border-l border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-lg font-semibold text-white",children:p.energy.today.toFixed(2)}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"kWh Today"})]})]}),s.jsxs("button",{onClick:()=>f(!d),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(bh,{className:"w-4 h-4"}),t.plug_type==="mqtt"?"Settings":"Automation Settings"]}),s.jsx("span",{children:d?"-":"+"})]}),d&&s.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mM,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Show in Switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.show_in_switchbar,onChange:A=>y.mutate({show_in_switchbar:A.target.checked}),className:"sr-only peer"}),s.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"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Enabled"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Enable automation for this plug"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.enabled,onChange:A=>y.mutate({enabled:A.target.checked}),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Auto On"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn on when print starts"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.auto_on,onChange:A=>y.mutate({auto_on:A.target.checked}),className:"sr-only peer"}),s.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"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Auto Off"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Turn off when print completes (one-shot)"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t.auto_off,onChange:A=>y.mutate({auto_off:A.target.checked}),className:"sr-only peer"}),s.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&&s.jsxs("div",{className:"space-y-3 pl-4 border-l-2 border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white mb-2",children:"Turn Off Delay Mode"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:()=>y.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:[s.jsx(tr,{className:"w-4 h-4"}),"Time"]}),s.jsxs("button",{onClick:()=>y.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:[s.jsx(bM,{className:"w-4 h-4"}),"Temp"]})]})]}),t.off_delay_mode==="time"?s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Delay (minutes)"}),s.jsx("input",{type:"number",min:"1",max:"60",value:t.off_delay_minutes,onChange:A=>y.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"})]}):s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Temperature threshold (C)"}),s.jsx("input",{type:"number",min:"30",max:"100",value:t.off_temp_threshold,onChange:A=>y.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Turns off when nozzle cools below this temperature"})]})]})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(fg,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>a(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(an,{className:"w-4 h-4"})})]})]})]})}),i&&s.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(),a(!1)},onCancel:()=>a(!1)}),o&&s.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&&s.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 hKe({plug:t,onClose:e}){const n=sn(),r=!!t,[i,a]=_.useState(t?.plug_type||"tasmota"),[o,l]=_.useState(t?.name||""),[c,u]=_.useState(t?.ip_address||""),[d,f]=_.useState(t?.username||""),[p,m]=_.useState(t?.password||""),[x,b]=_.useState(t?.ha_entity_id||""),[v,y]=_.useState(t?.mqtt_power_topic||t?.mqtt_topic||""),[S,k]=_.useState(t?.mqtt_power_path||""),[T,M]=_.useState((t?.mqtt_power_multiplier??t?.mqtt_multiplier??1).toString()),[C,E]=_.useState(t?.mqtt_energy_topic||""),[R,A]=_.useState(t?.mqtt_energy_path||""),[D,I]=_.useState((t?.mqtt_energy_multiplier??1).toString()),[F,z]=_.useState(t?.mqtt_state_topic||""),[P,$]=_.useState(t?.mqtt_state_path||""),[X,V]=_.useState(t?.mqtt_state_on_value||""),[Q,Z]=_.useState(t?.ha_power_entity||""),[se,H]=_.useState(t?.ha_energy_today_entity||""),[K,re]=_.useState(t?.ha_energy_total_entity||""),[ne,be]=_.useState(""),[me,de]=_.useState(""),[Ce,ie]=_.useState(!1),ke=_.useRef(null),[Oe,pe]=_.useState(""),[We,G]=_.useState(!1),Y=_.useRef(null),[ue,q]=_.useState(""),[te,U]=_.useState(!1),he=_.useRef(null),[Me,ge]=_.useState(""),[B,O]=_.useState(!1),ee=_.useRef(null),[le,_e]=_.useState(t?.printer_id||null),[ve,ae]=_.useState(null),[Fe,Be]=_.useState(null),[$e,He]=_.useState(t?.power_alert_enabled||!1),[xe,Pe]=_.useState(t?.power_alert_high?.toString()||""),[ze,we]=_.useState(t?.power_alert_low?.toString()||""),[Xe,Ne]=_.useState(t?.schedule_enabled||!1),[rt,Ee]=_.useState(t?.schedule_on_time||""),[Ke,Ue]=_.useState(t?.schedule_off_time||""),[W,je]=_.useState(t?.show_in_switchbar||!1),[Ye,bt]=_.useState(t?.show_on_printer_card??!0),[pt,Bt]=_.useState(!1),[Lt,vn]=_.useState({scanned:0,total:0}),[cn,rr]=_.useState([]),Vn=_.useRef(null),{data:Jn}=ot({queryKey:["printers"],queryFn:ce.getPrinters}),{data:gn}=ot({queryKey:["smart-plugs"],queryFn:ce.getSmartPlugs}),{data:sr}=ot({queryKey:["settings"],queryFn:ce.getSettings}),Gn=!!(sr?.ha_enabled&&sr?.ha_url&&sr?.ha_token);_.useEffect(()=>{const Se=setTimeout(()=>{de(ne)},300);return()=>clearTimeout(Se)},[ne]),_.useEffect(()=>{const Se=Le=>{ke.current&&!ke.current.contains(Le.target)&&ie(!1),Y.current&&!Y.current.contains(Le.target)&&G(!1),he.current&&!he.current.contains(Le.target)&&U(!1),ee.current&&!ee.current.contains(Le.target)&&O(!1)};return document.addEventListener("mousedown",Se),()=>document.removeEventListener("mousedown",Se)},[]);const{data:Xn,isLoading:Nn,error:hi}=ot({queryKey:["ha-entities",me],queryFn:()=>ce.getHAEntities(me||void 0),enabled:i==="homeassistant"&&Gn,retry:!1,staleTime:0}),{data:ai}=ot({queryKey:["ha-sensor-entities"],queryFn:ce.getHASensorEntities,enabled:i==="homeassistant"&&Gn,retry:!1,staleTime:0});_.useEffect(()=>{const Se=Le=>{Le.key==="Escape"&&e()};return window.addEventListener("keydown",Se),()=>{window.removeEventListener("keydown",Se),Vn.current&&clearInterval(Vn.current)}},[e]);const Ae=async()=>{Bt(!0),rr([]),vn({scanned:0,total:0}),Be(null);try{await ce.startTasmotaScan();const Se=async()=>{try{const Le=await ce.getTasmotaScanStatus();vn({scanned:Le.scanned,total:Le.total});const tt=await ce.getDiscoveredTasmotaDevices();rr(tt),Le.running||(Bt(!1),Vn.current&&(clearInterval(Vn.current),Vn.current=null))}catch(Le){console.error("Polling error:",Le)}};await Se(),Vn.current=setInterval(Se,500)}catch(Se){Bt(!1);const Le=Se instanceof Error?Se.message:typeof Se=="string"?Se:JSON.stringify(Se);Be(Le||"Failed to start scan")}},et=async()=>{try{await ce.stopTasmotaScan()}catch{}Bt(!1),Vn.current&&(clearInterval(Vn.current),Vn.current=null)},ct=Se=>{u(Se.ip_address),l(Se.name),ae(null)},ut=mt({mutationFn:()=>ce.testSmartPlugConnection(c,d||null,p||null),onSuccess:Se=>{ae(Se),Be(null),!o&&Se.device_name&&l(Se.device_name)},onError:Se=>{ae(null),Be(Se.message)}}),lt=mt({mutationFn:Se=>ce.createSmartPlug(Se),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),n.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:Se=>{Be(Se.message)}}),Et=mt({mutationFn:Se=>ce.updateSmartPlug(t.id,Se),onSuccess:()=>{n.invalidateQueries({queryKey:["smart-plugs"]}),n.invalidateQueries({queryKey:["scriptPlugsByPrinter"]}),e()},onError:Se=>{Be(Se.message)}}),fe=Jn?.filter(Se=>i==="tasmota"?!gn?.some(tt=>tt.printer_id===Se.id&&tt.id!==t?.id&&tt.plug_type==="tasmota"):!0),De=Se=>{if(Se.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 tt=v.trim(),Qe=C.trim(),Tt=F.trim();if(!tt&&!Qe&&!Tt){Be("At least one MQTT topic must be configured for power, energy, or state monitoring");return}}const Le={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"&&Q||null,ha_energy_today_entity:i==="homeassistant"&&se||null,ha_energy_total_entity:i==="homeassistant"&&K||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"&&R.trim()||null,mqtt_energy_multiplier:i==="mqtt"&&parseFloat(D)||1,mqtt_state_topic:i==="mqtt"&&F.trim()||null,mqtt_state_path:i==="mqtt"&&P.trim()||null,mqtt_state_on_value:i==="mqtt"&&X.trim()||null,username:i==="tasmota"&&d.trim()||null,password:i==="tasmota"&&p.trim()||null,printer_id:le,power_alert_enabled:$e,power_alert_high:xe?parseFloat(xe):null,power_alert_low:ze?parseFloat(ze):null,schedule_enabled:Xe,schedule_on_time:rt||null,schedule_off_time:Ke||null,show_in_switchbar:W,show_on_printer_card:Ye};r?Et.mutate(Le):lt.mutate(Le)},Ve=lt.isPending||Et.isPending;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.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:Se=>Se.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary flex-shrink-0",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Smart Plug":"Add Smart Plug"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:De,className:"p-6 space-y-4 overflow-y-auto",children:[Fe&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:Fe}),!r&&s.jsxs("div",{className:"flex gap-2 mb-2",children:[s.jsxs("button",{type:"button",onClick:()=>{a("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:[s.jsx(tl,{className:"w-4 h-4"}),"Tasmota"]}),s.jsxs("button",{type:"button",onClick:()=>{a("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:[s.jsx(Fy,{className:"w-4 h-4"}),"HA"]}),s.jsxs("button",{type:"button",onClick:()=>{a("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:[s.jsx(PR,{className:"w-4 h-4"}),"MQTT"]})]}),!r&&i==="tasmota"&&s.jsxs("div",{className:"space-y-3",children:[pt?s.jsxs(Te,{type:"button",variant:"secondary",onClick:et,className:"w-full",children:[s.jsx(Rt,{className:"w-4 h-4"}),"Stop Scanning"]}):s.jsxs(Te,{type:"button",variant:"primary",onClick:Ae,className:"w-full",children:[s.jsx(ya,{className:"w-4 h-4"}),"Discover Tasmota Devices"]}),pt&&Lt.total>0&&s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray",children:[s.jsx("span",{children:"Scanning network..."}),s.jsxs("span",{children:[Lt.scanned," / ",Lt.total]})]}),s.jsx("div",{className:"w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${Lt.scanned/Lt.total*100}%`}})})]}),cn.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-xs text-bambu-gray",children:["Found ",cn.length," device(s) - click to select:"]}),s.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:cn.map(Se=>s.jsxs("button",{type:"button",onClick:()=>ct(Se),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:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(tl,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:Se.name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:Se.ip_address})]})]}),Se.state&&s.jsxs("span",{className:`flex items-center gap-1 text-xs ${Se.state==="ON"?"text-bambu-green":"text-bambu-gray"}`,children:[s.jsx(Gu,{className:"w-3 h-3"}),Se.state]})]},Se.ip_address))})]}),!pt&&cn.length===0&&Lt.total>0&&s.jsx("p",{className:"text-xs text-bambu-gray text-center py-2",children:"No Tasmota devices found on your network"})]}),i==="homeassistant"&&s.jsxs("div",{className:"space-y-3",children:[!Gn&&s.jsxs("div",{className:"space-y-3",children:[s.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"," ",s.jsx("span",{className:"font-medium",children:"Settings → Network → Home Assistant"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1 opacity-50",children:"Select Entity *"}),s.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:s.jsx("option",{children:"Choose an entity..."})})]})]}),Gn&&s.jsxs(s.Fragment,{children:[Nn&&s.jsxs("div",{className:"flex items-center justify-center py-4 text-bambu-gray",children:[s.jsx(ft,{className:"w-5 h-5 animate-spin mr-2"}),"Loading entities..."]}),hi&&s.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 Se=gn?.filter(Qe=>Qe.ha_entity_id&&Qe.id!==t?.id).map(Qe=>Qe.ha_entity_id)||[],Le=(Xn||[]).filter(Qe=>!Se.includes(Qe.entity_id)),tt=Xn?.find(Qe=>Qe.entity_id===x);return s.jsxs("div",{ref:ke,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Select Entity *"}),s.jsxs("div",{className:"relative",children:[s.jsx(ya,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:Ce?ne:tt?`${tt.friendly_name} (${tt.entity_id})`:"",onChange:Qe=>{be(Qe.target.value),Ce||ie(!0)},onFocus:()=>{ie(!0),be("")},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&&!Ce&&s.jsx("button",{type:"button",onClick:()=>{b(""),be("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})}),Nn&&s.jsx(ft,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray animate-spin"})]}),Ce&&s.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&&s.jsxs("div",{className:"px-3 py-2 text-sm text-bambu-gray flex items-center gap-2",children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Loading..."]}),!Nn&&Le.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:me?`No entities found matching "${me}"`:"No entities available"}),!Nn&&Le.map(Qe=>s.jsxs("button",{type:"button",onClick:()=>{b(Qe.entity_id),ie(!1),be(""),o||l(Qe.friendly_name)},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary transition-colors ${Qe.entity_id===x?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Qe.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray flex items-center justify-between",children:[s.jsx("span",{children:Qe.entity_id}),s.jsx("span",{className:Qe.state==="on"?"text-bambu-green":"",children:Qe.state})]})]},Qe.entity_id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:me?`Searching all entities (${Le.length} found)`:`Showing switch, light, input_boolean (${Le.length} available)`})]})})(),x&&ai&&ai.length>0&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4 space-y-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium mb-1",children:"Energy Monitoring (Optional)"}),s.jsx("p",{className:"text-xs text-bambu-gray mb-3",children:"Search and select sensors that provide power/energy data."})]}),(()=>{const Se=ai.filter(Qe=>Qe.unit_of_measurement==="W"||Qe.unit_of_measurement==="kW"||Qe.unit_of_measurement==="mW"),Le=Oe?Se.filter(Qe=>Qe.entity_id.toLowerCase().includes(Oe.toLowerCase())||Qe.friendly_name.toLowerCase().includes(Oe.toLowerCase())):Se,tt=ai.find(Qe=>Qe.entity_id===Q);return s.jsxs("div",{ref:Y,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Power Sensor (W)"}),s.jsxs("div",{className:"relative",children:[s.jsx(ya,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:We?Oe:tt?`${tt.friendly_name} (${tt.state} ${tt.unit_of_measurement})`:"",onChange:Qe=>{pe(Qe.target.value),We||G(!0)},onFocus:()=>{G(!0),pe("")},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"}),Q&&!We&&s.jsx("button",{type:"button",onClick:()=>{Z(""),pe("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),We&&s.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:[s.jsx("button",{type:"button",onClick:()=>{Z(""),G(!1),pe("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Le.map(Qe=>s.jsxs("button",{type:"button",onClick:()=>{Z(Qe.entity_id),G(!1),pe("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Qe.entity_id===Q?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Qe.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Qe.entity_id," • ",Qe.state," ",Qe.unit_of_measurement]})]},Qe.entity_id)),Le.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const Se=ai.filter(Qe=>Qe.unit_of_measurement==="kWh"||Qe.unit_of_measurement==="Wh"||Qe.unit_of_measurement==="MWh"),Le=ue?Se.filter(Qe=>Qe.entity_id.toLowerCase().includes(ue.toLowerCase())||Qe.friendly_name.toLowerCase().includes(ue.toLowerCase())):Se,tt=ai.find(Qe=>Qe.entity_id===se);return s.jsxs("div",{ref:he,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy Today (kWh)"}),s.jsxs("div",{className:"relative",children:[s.jsx(ya,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:te?ue:tt?`${tt.friendly_name} (${tt.state} ${tt.unit_of_measurement})`:"",onChange:Qe=>{q(Qe.target.value),te||U(!0)},onFocus:()=>{U(!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"}),se&&!te&&s.jsx("button",{type:"button",onClick:()=>{H(""),q("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),te&&s.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:[s.jsx("button",{type:"button",onClick:()=>{H(""),U(!1),q("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Le.map(Qe=>s.jsxs("button",{type:"button",onClick:()=>{H(Qe.entity_id),U(!1),q("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Qe.entity_id===se?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Qe.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Qe.entity_id," • ",Qe.state," ",Qe.unit_of_measurement]})]},Qe.entity_id)),Le.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})(),(()=>{const Se=ai.filter(Qe=>Qe.unit_of_measurement==="kWh"||Qe.unit_of_measurement==="Wh"||Qe.unit_of_measurement==="MWh"),Le=Me?Se.filter(Qe=>Qe.entity_id.toLowerCase().includes(Me.toLowerCase())||Qe.friendly_name.toLowerCase().includes(Me.toLowerCase())):Se,tt=ai.find(Qe=>Qe.entity_id===K);return s.jsxs("div",{ref:ee,className:"relative",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Total Energy (kWh)"}),s.jsxs("div",{className:"relative",children:[s.jsx(ya,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"}),s.jsx("input",{type:"text",value:B?Me:tt?`${tt.friendly_name} (${tt.state} ${tt.unit_of_measurement})`:"",onChange:Qe=>{ge(Qe.target.value),B||O(!0)},onFocus:()=>{O(!0),ge("")},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"}),K&&!B&&s.jsx("button",{type:"button",onClick:()=>{re(""),ge("")},className:"absolute right-2 top-1/2 -translate-y-1/2 p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Rt,{className:"w-4 h-4 text-bambu-gray hover:text-white"})})]}),B&&s.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:[s.jsx("button",{type:"button",onClick:()=>{re(""),O(!1),ge("")},className:"w-full px-3 py-2 text-left text-sm text-bambu-gray hover:bg-bambu-dark-tertiary",children:"None"}),Le.map(Qe=>s.jsxs("button",{type:"button",onClick:()=>{re(Qe.entity_id),O(!1),ge("")},className:`w-full px-3 py-2 text-left text-sm hover:bg-bambu-dark-tertiary ${Qe.entity_id===K?"bg-bambu-green/20 text-bambu-green":"text-white"}`,children:[s.jsx("div",{className:"font-medium",children:Qe.friendly_name}),s.jsxs("div",{className:"text-xs text-bambu-gray",children:[Qe.entity_id," • ",Qe.state," ",Qe.unit_of_measurement]})]},Qe.entity_id)),Le.length===0&&s.jsx("div",{className:"px-3 py-2 text-sm text-bambu-gray",children:"No matching sensors"})]})]})})()]})]})]}),i==="mqtt"&&s.jsxs("div",{className:"space-y-3",children:[!sr?.mqtt_broker&&s.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"," ",s.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&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg text-sm text-blue-300",children:[s.jsx("p",{className:"font-medium mb-1",children:"Monitor Only"}),s.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."})]}),s.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-white font-medium text-sm",children:"Power Monitoring"}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),s.jsx("input",{type:"text",value:v,onChange:Se=>y(Se.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"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),s.jsx("input",{type:"text",value:S,onChange:Se=>k(Se.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),s.jsx("input",{type:"text",value:T,onChange:Se=>M(Se.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"})]})]}),s.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.',s.jsx("br",{}),"Use multiplier 0.001 for mW→W, 1000 for kW→W."]})]}),s.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("p",{className:"text-white font-medium text-sm",children:["Energy Monitoring ",s.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),s.jsx("input",{type:"text",value:C,onChange:Se=>E(Se.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"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),s.jsx("input",{type:"text",value:R,onChange:Se=>A(Se.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Multiplier"}),s.jsx("input",{type:"text",value:D,onChange:Se=>I(Se.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"})]})]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",s.jsx("br",{}),"Use multiplier 0.001 for Wh→kWh, 1000 for MWh→kWh."]})]}),s.jsxs("div",{className:"space-y-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("p",{className:"text-white font-medium text-sm",children:["State Monitoring ",s.jsx("span",{className:"text-bambu-gray font-normal",children:"(optional)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic"}),s.jsx("input",{type:"text",value:F,onChange:Se=>z(Se.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"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"JSON Path"}),s.jsx("input",{type:"text",value:P,onChange:Se=>$(Se.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"ON Value"}),s.jsx("input",{type:"text",value:X,onChange:Se=>V(Se.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"})]})]}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:["JSON path extracts value from JSON payload. Leave empty for raw values.",s.jsx("br",{}),'ON value: the exact string that means "ON". Leave empty for auto-detect (ON, true, 1).']})]})]})]}),i==="tasmota"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"IP Address *"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:c,onChange:Se=>{u(Se.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"}),s.jsxs(Te,{type:"button",variant:"secondary",onClick:()=>ut.mutate(),disabled:!c.trim()||ut.isPending,children:[ut.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Sg,{className:"w-4 h-4"}),"Test"]})]})]}),i==="tasmota"&&ve&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ve.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:ve.success?s.jsxs(s.Fragment,{children:[s.jsx(Ar,{className:"w-5 h-5"}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium",children:"Connected!"}),s.jsxs("p",{className:"text-sm opacity-80",children:[ve.device_name&&`Device: ${ve.device_name} - `,"State: ",ve.state]})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(sm,{className:"w-5 h-5"}),s.jsx("span",{children:"Connection failed"})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:o,onChange:Se=>l(Se.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"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username"}),s.jsx("input",{type:"text",value:d,onChange:Se=>f(Se.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password"}),s.jsx("input",{type:"password",value:p,onChange:Se=>m(Se.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"})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray -mt-2",children:"Leave empty if your Tasmota device doesn't require authentication"})]}),i!=="mqtt"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Link to Printer"}),s.jsxs("select",{value:le??"",onChange:Se=>_e(Se.target.value?Number(Se.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:[s.jsx("option",{value:"",children:"No printer (manual control only)"}),fe?.map(Se=>s.jsx("option",{value:Se.id,children:Se.name},Se.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Linking enables automatic on/off when prints start/complete"})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(wg,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-white font-medium",children:"Power Alerts"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:$e,onChange:Se=>He(Se.target.checked),className:"sr-only peer"}),s.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&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if above (W)"}),s.jsx("input",{type:"number",value:xe,onChange:Se=>Pe(Se.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Alert if below (W)"}),s.jsx("input",{type:"number",value:ze,onChange:Se=>we(Se.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"})]})]}),s.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"&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(tr,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"text-white font-medium",children:"Daily Schedule"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:Xe,onChange:Se=>Ne(Se.target.checked),className:"sr-only peer"}),s.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"})]})]}),Xe&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn On at"}),s.jsx("input",{type:"time",value:rt,onChange:Se=>Ee(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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Turn Off at"}),s.jsx("input",{type:"time",value:Ke,onChange:Se=>Ue(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"})]})]}),s.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."})]})]}),s.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mM,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white font-medium",children:"Show in Switchbar"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Quick access from sidebar"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:W,onChange:Se=>je(Se.target.checked),className:"sr-only peer"}),s.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"&&s.jsx("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mc,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white font-medium",children:"Show on Printer Card"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Display button on printer card"})]})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:Ye,onChange:Se=>bt(Se.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{type:"submit",disabled:Ve,className:"flex-1",children:[Ve?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(hs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function Ln({checked:t,onChange:e,disabled:n}){const r=i=>{i.preventDefault(),i.stopPropagation(),n||e(!t)};return s.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:s.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 fKe={callmebot:"CallMeBot/WhatsApp",ntfy:"ntfy",pushover:"Pushover",telegram:"Telegram",email:"Email",discord:"Discord",webhook:"Webhook"};function mKe({provider:t,onEdit:e}){const n=sn(),[r,i]=_.useState(!1),[a,o]=_.useState(!1),[l,c]=_.useState(null),{data:u}=ot({queryKey:["printers"],queryFn:ce.getPrinters}),d=u?.find(b=>b.id===t.printer_id),f=mt({mutationFn:b=>ce.updateNotificationProvider(t.id,b),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),p=mt({mutationFn:()=>ce.deleteNotificationProvider(t.id),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]})}}),m=mt({mutationFn:()=>ce.testNotificationProvider(t.id),onSuccess:b=>{c(b),n.invalidateQueries({queryKey:["notification-providers"]})},onError:b=>{c({success:!1,message:b.message})}}),x=b=>b||"";return s.jsxs(s.Fragment,{children:[s.jsx(St,{className:"relative",children:s.jsxs(Nt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${t.enabled?"bg-bambu-green/20":"bg-bambu-dark"}`,children:s.jsx(wg,{className:`w-5 h-5 ${t.enabled?"text-bambu-green":"text-bambu-gray"}`})}),s.jsxs("div",{children:[s.jsx("h3",{className:"font-medium text-white",children:t.name}),s.jsx("p",{className:"text-sm text-bambu-gray",children:fKe[t.provider_type]||t.provider_type})]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[t.last_success&&s.jsxs("span",{className:"text-xs text-status-ok hidden sm:inline",children:["Last: ",Bg(t.last_success)]}),t.last_error&&t.last_error_at&&(!t.last_success||(Ui(t.last_error_at)?.getTime()||0)>(Ui(t.last_success)?.getTime()||0))&&s.jsx("span",{className:"text-xs text-status-error",title:t.last_error,children:"Error"}),s.jsx(Ln,{checked:t.enabled,onChange:b=>f.mutate({enabled:b})})]})]}),d&&s.jsxs("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Printer: "}),s.jsx("span",{className:"text-sm text-white",children:d.name})]}),!d&&!t.printer_id&&s.jsx("div",{className:"mb-3 px-2 py-1.5 bg-bambu-dark rounded-lg",children:s.jsx("span",{className:"text-xs text-bambu-gray",children:"All printers"})}),s.jsxs("div",{className:"mb-3 flex flex-wrap gap-1",children:[t.on_print_start&&s.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&&s.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&&s.jsx("span",{className:"px-2 py-0.5 bg-bambu-green/20 text-bambu-green text-xs rounded",children:"Complete"}),t.on_print_failed&&s.jsx("span",{className:"px-2 py-0.5 bg-red-500/20 text-red-400 text-xs rounded",children:"Failed"}),t.on_print_stopped&&s.jsx("span",{className:"px-2 py-0.5 bg-orange-500/20 text-orange-400 text-xs rounded",children:"Stopped"}),t.on_print_progress&&s.jsx("span",{className:"px-2 py-0.5 bg-yellow-500/20 text-yellow-400 text-xs rounded",children:"Progress"}),t.on_printer_offline&&s.jsx("span",{className:"px-2 py-0.5 bg-gray-500/20 text-gray-400 text-xs rounded",children:"Offline"}),t.on_printer_error&&s.jsx("span",{className:"px-2 py-0.5 bg-rose-500/20 text-rose-400 text-xs rounded",children:"Error"}),t.on_filament_low&&s.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&&s.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&&s.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&&s.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&&s.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&&s.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&&s.jsxs("span",{className:"px-2 py-0.5 bg-indigo-500/20 text-indigo-400 text-xs rounded flex items-center gap-1",children:[s.jsx(K1,{className:"w-3 h-3"}),"Quiet"]}),t.daily_digest_enabled&&s.jsxs("span",{className:"px-2 py-0.5 bg-emerald-500/20 text-emerald-400 text-xs rounded flex items-center gap-1",children:[s.jsx(ti,{className:"w-3 h-3"}),"Digest ",t.daily_digest_time]})]}),s.jsx("div",{className:"mb-3",children:s.jsxs(Te,{size:"sm",variant:"secondary",disabled:m.isPending,onClick:()=>{c(null),m.mutate()},className:"w-full",children:[m.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(jR,{className:"w-4 h-4"}),"Send Test Notification"]})}),l&&s.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?s.jsx(Ar,{className:"w-4 h-4"}):s.jsx(Qi,{className:"w-4 h-4"}),s.jsx("span",{children:l.message})]}),s.jsxs("button",{onClick:()=>o(!a),className:"w-full flex items-center justify-between py-2 text-sm text-bambu-gray hover:text-white transition-colors border-t border-bambu-dark-tertiary",children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(bh,{className:"w-4 h-4"}),"Event Settings"]}),a?s.jsx(xh,{className:"w-4 h-4"}):s.jsx(Kr,{className:"w-4 h-4"})]}),a&&s.jsxs("div",{className:"pt-3 border-t border-bambu-dark-tertiary space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Enabled"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Send notifications from this provider"})]}),s.jsx(Ln,{checked:t.enabled,onChange:b=>f.mutate({enabled:b})})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Events"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Started"}),s.jsx(Ln,{checked:t.on_print_start,onChange:b=>f.mutate({on_print_start:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Plate Not Empty"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Objects detected before print"})]}),s.jsx(Ln,{checked:t.on_plate_not_empty??!0,onChange:b=>f.mutate({on_plate_not_empty:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Completed"}),s.jsx(Ln,{checked:t.on_print_complete,onChange:b=>f.mutate({on_print_complete:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Failed"}),s.jsx(Ln,{checked:t.on_print_failed,onChange:b=>f.mutate({on_print_failed:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Print Stopped"}),s.jsx(Ln,{checked:t.on_print_stopped,onChange:b=>f.mutate({on_print_stopped:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Progress Milestones"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify at 25%, 50%, 75%"})]}),s.jsx(Ln,{checked:t.on_print_progress,onChange:b=>f.mutate({on_print_progress:b})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Printer Status"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Offline"}),s.jsx(Ln,{checked:t.on_printer_offline,onChange:b=>f.mutate({on_printer_offline:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Printer Error"}),s.jsx(Ln,{checked:t.on_printer_error,onChange:b=>f.mutate({on_printer_error:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("p",{className:"text-sm text-white",children:"Low Filament"}),s.jsx(Ln,{checked:t.on_filament_low,onChange:b=>f.mutate({on_filament_low:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Maintenance Due"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Notify when maintenance is needed"})]}),s.jsx(Ln,{checked:t.on_maintenance_due??!1,onChange:b=>f.mutate({on_maintenance_due:b})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS Alarms"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS Humidity High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS humidity exceeds threshold"})]}),s.jsx(Ln,{checked:t.on_ams_humidity_high??!1,onChange:b=>f.mutate({on_ams_humidity_high:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS Temperature High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Regular AMS temperature exceeds threshold"})]}),s.jsx(Ln,{checked:t.on_ams_temperature_high??!1,onChange:b=>f.mutate({on_ams_temperature_high:b})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"AMS-HT Alarms"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS-HT Humidity High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT humidity exceeds threshold"})]}),s.jsx(Ln,{checked:t.on_ams_ht_humidity_high??!1,onChange:b=>f.mutate({on_ams_ht_humidity_high:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"AMS-HT Temperature High"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"AMS-HT temperature exceeds threshold"})]}),s.jsx(Ln,{checked:t.on_ams_ht_temperature_high??!1,onChange:b=>f.mutate({on_ams_ht_temperature_high:b})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide",children:"Print Queue"}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Added"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Job added to queue"})]}),s.jsx(Ln,{checked:t.on_queue_job_added??!1,onChange:b=>f.mutate({on_queue_job_added:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Assigned"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Model-based job assigned to printer"})]}),s.jsx(Ln,{checked:t.on_queue_job_assigned??!1,onChange:b=>f.mutate({on_queue_job_assigned:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Started"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Queue job started printing"})]}),s.jsx(Ln,{checked:t.on_queue_job_started??!1,onChange:b=>f.mutate({on_queue_job_started:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Waiting"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Job waiting for filament"})]}),s.jsx(Ln,{checked:t.on_queue_job_waiting??!0,onChange:b=>f.mutate({on_queue_job_waiting:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Skipped"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Job skipped (previous failed)"})]}),s.jsx(Ln,{checked:t.on_queue_job_skipped??!0,onChange:b=>f.mutate({on_queue_job_skipped:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Job Failed"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Job failed to start"})]}),s.jsx(Ln,{checked:t.on_queue_job_failed??!0,onChange:b=>f.mutate({on_queue_job_failed:b})})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Queue Complete"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"All queue jobs finished"})]}),s.jsx(Ln,{checked:t.on_queue_completed??!1,onChange:b=>f.mutate({on_queue_completed:b})})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(K1,{className:"w-4 h-4 text-purple-400"}),s.jsx("p",{className:"text-sm text-white",children:"Quiet Hours"})]}),s.jsx(Ln,{checked:t.quiet_hours_enabled,onChange:b=>f.mutate({quiet_hours_enabled:b})})]}),t.quiet_hours_enabled&&s.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"No notifications during these hours"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(tr,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:[x(t.quiet_hours_start)||"22:00"," - ",x(t.quiet_hours_end)||"07:00"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change quiet hours"})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ti,{className:"w-4 h-4 text-emerald-400"}),s.jsx("p",{className:"text-sm text-white",children:"Daily Digest"})]}),s.jsx(Ln,{checked:t.daily_digest_enabled,onChange:b=>f.mutate({daily_digest_enabled:b})})]}),t.daily_digest_enabled&&s.jsxs("div",{className:"pl-4 border-l-2 border-bambu-dark-tertiary space-y-2",children:[s.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(tr,{className:"w-4 h-4 text-bambu-gray"}),s.jsxs("span",{className:"text-sm text-white",children:["Send at ",x(t.daily_digest_time)||"08:00"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Edit provider to change digest time"})]})]}),s.jsxs("div",{className:"flex gap-2 pt-2",children:[s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>e(t),className:"flex-1",children:[s.jsx(fg,{className:"w-4 h-4"}),"Edit"]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>i(!0),className:"text-red-400 hover:text-red-300",children:s.jsx(an,{className:"w-4 h-4"})})]})]})]})}),r&&s.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 gq=[{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 pKe({provider:t,onClose:e}){const n=sn(),r=!!t,[i,a]=_.useState(t?.name||""),[o,l]=_.useState(t?.provider_type||"email"),[c,u]=_.useState(t?.printer_id||null),[d,f]=_.useState(t?.quiet_hours_enabled||!1),[p,m]=_.useState(t?.quiet_hours_start||"22:00"),[x,b]=_.useState(t?.quiet_hours_end||"07:00"),[v,y]=_.useState(t?.daily_digest_enabled||!1),[S,k]=_.useState(t?.daily_digest_time||"08:00"),[T,M]=_.useState(t?.on_print_start??!1),[C,E]=_.useState(t?.on_print_complete??!0),[R,A]=_.useState(t?.on_print_failed??!0),[D,I]=_.useState(t?.on_print_stopped??!0),[F,z]=_.useState(t?.on_print_progress??!1),[P,$]=_.useState(t?.on_printer_offline??!1),[X,V]=_.useState(t?.on_printer_error??!1),[Q,Z]=_.useState(t?.on_filament_low??!1),[se,H]=_.useState(t?.on_maintenance_due??!1),[K,re]=_.useState(t?.config?Object.fromEntries(Object.entries(t.config).map(([q,te])=>[q,String(te)])):{}),[ne,be]=_.useState(null),[me,de]=_.useState(null),{data:Ce}=ot({queryKey:["printers"],queryFn:ce.getPrinters});_.useEffect(()=>{const q=te=>{te.key==="Escape"&&e()};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[e]);const ie=mt({mutationFn:()=>ce.testNotificationConfig({provider_type:o,config:K}),onSuccess:q=>{be(q),de(null)},onError:q=>{be({success:!1,message:q.message})}}),ke=mt({mutationFn:q=>ce.createNotificationProvider(q),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:q=>{de(q.message)}}),Oe=mt({mutationFn:q=>ce.updateNotificationProvider(t.id,q),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-providers"]}),e()},onError:q=>{de(q.message)}}),pe=q=>{if(q.preventDefault(),de(null),!i.trim()){de("Name is required");return}const te=Y(o);for(const he of te)if(!K[he.key]?.trim()){de(`${he.label} is required`);return}const U={name:i.trim(),provider_type:o,config:K,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:R,on_print_stopped:D,on_print_progress:F,on_printer_offline:P,on_printer_error:X,on_filament_low:Q,on_maintenance_due:se};r?Oe.mutate(U):ke.mutate(U)},We=ke.isPending||Oe.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:te=>te.payload_format!=="slack"},{key:"field_message",label:"Message Field Name",placeholder:"message",type:"text",required:!1,showIf:te=>te.payload_format!=="slack"}];default:return[]}},Y=q=>G(q).filter(te=>te.required),ue=G(o);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4 overflow-y-auto",onClick:e,children:s.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:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r?"Edit Notification Provider":"Add Notification Provider"}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:pe,className:"p-6 space-y-4",children:[me&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:me}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.jsx("input",{type:"text",value:i,onChange:q=>a(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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Provider Type *"}),s.jsx("select",{value:o,onChange:q=>{l(q.target.value),re({}),be(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:gq.map(q=>s.jsx("option",{value:q.value,children:q.label},q.value))}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:gq.find(q=>q.value===o)?.description})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Configuration"}),ue.filter(q=>!("showIf"in q)||q.showIf?.(K)!==!1).map(q=>s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[q.label," ",q.required&&"*"]}),q.type==="select"&&"options"in q&&q.options?s.jsx("select",{value:K[q.key]||q.options[0]?.value||"",onChange:te=>{re({...K,[q.key]:te.target.value}),be(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(te=>s.jsx("option",{value:te.value,children:te.label},te.value))}):s.jsx("input",{type:q.type,value:K[q.key]||"",onChange:te=>{re({...K,[q.key]:te.target.value}),be(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))]}),s.jsx("div",{className:"flex gap-2",children:s.jsxs(Te,{type:"button",variant:"secondary",onClick:()=>{be(null),ie.mutate()},disabled:ie.isPending||!K[Y(o)[0]?.key],className:"flex-1",children:[ie.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(jR,{className:"w-4 h-4"}),"Test Configuration"]})}),ne&&s.jsx("div",{className:`p-3 rounded-lg flex items-center gap-2 ${ne.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:ne.success?s.jsxs(s.Fragment,{children:[s.jsx(Ar,{className:"w-5 h-5"}),s.jsx("span",{children:ne.message})]}):s.jsxs(s.Fragment,{children:[s.jsx(Qi,{className:"w-5 h-5"}),s.jsx("span",{children:ne.message})]})}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Printer Filter"}),s.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:[s.jsx("option",{value:"",children:"All printers"}),Ce?.map(q=>s.jsx("option",{value:q.id,children:q.name},q.id))]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Only send notifications for events from this printer"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("label",{className:"text-sm text-white",children:"Quiet Hours (Do Not Disturb)"}),s.jsx(Ln,{checked:d,onChange:f})]}),d&&s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Start"}),s.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"End"}),s.jsx("input",{type:"time",value:x,onChange:q=>b(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"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-white",children:"Daily Digest"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Batch notifications into a single daily summary"})]}),s.jsx(Ln,{checked:v,onChange:y})]}),v&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Send digest at"}),s.jsx("input",{type:"time",value:S,onChange:q=>k(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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Events will be collected and sent as a single summary at this time"})]})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Notification Events"}),s.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Print Events"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Start"}),s.jsx(Ln,{checked:T,onChange:M})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Complete"}),s.jsx(Ln,{checked:C,onChange:E})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Failed"}),s.jsx(Ln,{checked:R,onChange:A})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Stopped"}),s.jsx(Ln,{checked:D,onChange:I})]}),s.jsxs("div",{className:"flex items-center justify-between col-span-2",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-white",children:"Progress"}),s.jsx("span",{className:"text-xs text-bambu-gray ml-1",children:"(25%, 50%, 75%)"})]}),s.jsx(Ln,{checked:F,onChange:z})]})]})]}),s.jsxs("div",{className:"space-y-2 p-3 bg-bambu-dark rounded-lg",children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase tracking-wide mb-2",children:"Printer Status"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Offline"}),s.jsx(Ln,{checked:P,onChange:$})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Error"}),s.jsx(Ln,{checked:X,onChange:V})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Low Filament"}),s.jsx(Ln,{checked:Q,onChange:Z})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-sm text-white",children:"Maintenance"}),s.jsx(Ln,{checked:se,onChange:H})]})]})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{type:"submit",disabled:We,className:"flex-1",children:[We?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(hs,{className:"w-4 h-4"}),r?"Save":"Add"]})]})]})]})})}function gKe({template:t,onClose:e}){const n=sn(),r=_.useRef(null),[i,a]=_.useState(t.title_template),[o,l]=_.useState(t.body_template),[c,u]=_.useState(null),[d,f]=_.useState(!0),{data:p}=ot({queryKey:["template-variables"],queryFn:ce.getTemplateVariables}),m=p?.find(M=>M.event_type===t.event_type),{data:x,isLoading:b}=ot({queryKey:["template-preview",t.event_type,i,o],queryFn:()=>ce.previewTemplate({event_type:t.event_type,title_template:i,body_template:o}),enabled:d&&i.length>0&&o.length>0});_.useEffect(()=>{const M=C=>{C.key==="Escape"&&e()};return window.addEventListener("keydown",M),()=>window.removeEventListener("keydown",M)},[e]);const v=mt({mutationFn:M=>ce.updateNotificationTemplate(t.id,M),onSuccess:()=>{n.invalidateQueries({queryKey:["notification-templates"]}),e()},onError:M=>{u(M.message)}}),y=mt({mutationFn:()=>ce.resetNotificationTemplate(t.id),onSuccess:M=>{a(M.title_template),l(M.body_template),n.invalidateQueries({queryKey:["notification-templates"]})},onError:M=>{u(M.message)}}),S=M=>{if(M.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})},k=M=>{const C=r.current;if(!C)return;const E=C.selectionStart,R=C.selectionEnd,A=o,D=A.substring(0,E),I=A.substring(R),F=D+`{${M}}`+I;l(F),setTimeout(()=>{C.focus();const z=E+M.length+2;C.setSelectionRange(z,z)},0)},T=i!==t.title_template||o!==t.body_template;return s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-2xl max-h-[90vh] flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary shrink-0",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white",children:["Edit Template: ",t.name]}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark-tertiary rounded transition-colors",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("form",{onSubmit:S,className:"flex-1 overflow-y-auto p-4 space-y-4",children:[c&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded text-red-400 text-sm",children:c}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Title"}),s.jsx("input",{type:"text",value:i,onChange:M=>a(M.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..."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-1",children:"Body"}),s.jsx("textarea",{ref:r,value:o,onChange:M=>l(M.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&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-bambu-gray mb-2",children:"Available Variables"}),s.jsx("div",{className:"flex flex-wrap gap-2",children:m.variables.map(M=>s.jsxs("button",{type:"button",onClick:()=>k(M),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:[s.jsx(fr,{className:"w-3 h-3"}),M]},M))}),s.jsx("p",{className:"text-xs text-bambu-gray/60 mt-1",children:"Click to insert at cursor position in body"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("label",{className:"text-sm font-medium text-bambu-gray flex items-center gap-2",children:[s.jsx(mc,{className:"w-4 h-4"}),"Live Preview"]}),s.jsx("button",{type:"button",onClick:()=>f(!d),className:"text-xs text-bambu-green hover:text-bambu-green-light",children:d?"Hide":"Show"})]}),d&&s.jsx("div",{className:"bg-bambu-dark border border-bambu-dark-tertiary rounded p-3 space-y-2",children:b?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-sm",children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Loading preview..."]}):x?s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Title:"}),s.jsx("div",{className:"text-white font-medium",children:x.title})]}),s.jsxs("div",{children:[s.jsx("span",{className:"text-xs text-bambu-gray",children:"Body:"}),s.jsx("div",{className:"text-white whitespace-pre-wrap text-sm",children:x.body})]})]}):s.jsx("div",{className:"text-bambu-gray text-sm",children:"Enter template content to see preview"})})]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 border-t border-bambu-dark-tertiary shrink-0",children:[s.jsxs(Te,{type:"button",variant:"ghost",onClick:()=>y.mutate(),disabled:y.isPending,className:"text-orange-400 hover:text-orange-300",children:[y.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(Rh,{className:"w-4 h-4 mr-2"}),"Reset to Default"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,children:"Cancel"}),s.jsxs(Te,{onClick:S,disabled:v.isPending||!T,children:[v.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(hs,{className:"w-4 h-4 mr-2"}),"Save"]})]})]})]})})}const xKe={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"},bKe={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 yKe({onClose:t}){const e=sn(),{showToast:n}=Hn(),[r,i]=_.useState(7),[a,o]=_.useState(null),[l,c]=_.useState(!1),{data:u}=ot({queryKey:["settings"],queryFn:ce.getSettings}),d=u?.time_format||"system",{data:f,isLoading:p,refetch:m,isRefetching:x}=ot({queryKey:["notification-logs",r,l],queryFn:()=>ce.getNotificationLogs({days:r,limit:100,success:l?!1:void 0})}),{data:b}=ot({queryKey:["notification-log-stats",r],queryFn:()=>ce.getNotificationLogStats(r)}),v=mt({mutationFn:()=>ce.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")}}),y=S=>{const k=Ui(S);if(!k)return"";const M=new Date().getTime()-k.getTime();return M<6e4?"Just now":M<36e5?`${Math.floor(M/6e4)}m ago`:M<864e5?`${Math.floor(M/36e5)}h ago`:k.toLocaleDateString()+" "+Hfe(k,d)};return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.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:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(q0,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Notification Log"})]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white transition-colors",children:"×"})]}),b&&s.jsx("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50",children:s.jsxs("div",{className:"flex items-center gap-6 text-sm",children:[s.jsxs("span",{className:"text-bambu-gray",children:["Last ",r," days: ",s.jsx("span",{className:"text-white font-medium",children:b.total})," notifications"]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[s.jsx(Ar,{className:"w-4 h-4"}),b.success_count," sent"]}),b.failure_count>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Qi,{className:"w-4 h-4"}),b.failure_count," failed"]})]})}),s.jsxs("div",{className:"px-4 py-3 border-b border-bambu-dark-tertiary flex items-center gap-4",children:[s.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:[s.jsx("option",{value:1,children:"Last 24 hours"}),s.jsx("option",{value:7,children:"Last 7 days"}),s.jsx("option",{value:30,children:"Last 30 days"}),s.jsx("option",{value:90,children:"Last 90 days"})]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.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"]}),s.jsx("div",{className:"flex-1"}),s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>m(),disabled:x,children:[x?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Refresh"]}),s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>v.mutate(),disabled:v.isPending,className:"text-red-400 hover:text-red-300",children:[v.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(an,{className:"w-4 h-4"}),"Clear Old"]})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:p?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):f&&f.length>0?s.jsx("div",{className:"space-y-2",children:f.map(S=>s.jsx(vKe,{log:S,isExpanded:a===S.id,onToggle:()=>o(a===S.id?null:S.id),formatDate:y,formatFullDate:k=>Hg(k,d)},S.id))}):s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(q0,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm",children:l?"No failed notifications":"No notifications logged"})]})})]})})}function vKe({log:t,isExpanded:e,onToggle:n,formatDate:r,formatFullDate:i}){return s.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:[s.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?s.jsx(Ar,{className:"w-4 h-4 text-bambu-green shrink-0"}):s.jsx(Qi,{className:"w-4 h-4 text-red-400 shrink-0"}),s.jsx("span",{className:`text-xs font-medium ${bKe[t.event_type]||"text-bambu-gray"}`,children:xKe[t.event_type]||t.event_type}),s.jsx("span",{className:"text-sm text-white truncate flex-1",children:t.provider_name||"Unknown Provider"}),t.printer_name&&s.jsx("span",{className:"text-xs text-bambu-gray",children:t.printer_name}),s.jsx("span",{className:"text-xs text-bambu-gray shrink-0",children:r(t.created_at)}),e?s.jsx(xh,{className:"w-4 h-4 text-bambu-gray shrink-0"}):s.jsx(Kr,{className:"w-4 h-4 text-bambu-gray shrink-0"})]}),e&&s.jsxs("div",{className:"px-3 py-2 border-t border-bambu-dark-tertiary bg-bambu-dark/20 space-y-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Title"}),s.jsx("p",{className:"text-sm text-white",children:t.title})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-1",children:"Message"}),s.jsx("p",{className:"text-sm text-white whitespace-pre-wrap",children:t.message})]}),!t.success&&t.error_message&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-red-400 mb-1",children:"Error"}),s.jsx("p",{className:"text-sm text-red-300",children:t.error_message})]}),s.jsxs("div",{className:"flex gap-4 text-xs text-bambu-gray pt-1",children:[s.jsxs("span",{children:["Provider: ",t.provider_type]}),s.jsxs("span",{children:["Time: ",i(t.created_at)]})]})]})]})}function wKe(){const t=sn(),[e,n]=_.useState(!1),[r,i]=_.useState(""),[a,o]=_.useState("auto"),[l,c]=_.useState(!1),[u,d]=_.useState("all"),[f,p]=_.useState(!1),[m,x]=_.useState(!1),{data:b,isLoading:v}=ot({queryKey:["spoolman-settings"],queryFn:ce.getSpoolmanSettings}),{data:y,isLoading:S,refetch:k}=ot({queryKey:["spoolman-status"],queryFn:ce.getSpoolmanStatus,refetchInterval:3e4}),{data:T}=ot({queryKey:["printers"],queryFn:ce.getPrinters});_.useEffect(()=>{b&&(n(b.spoolman_enabled==="true"),i(b.spoolman_url||""),o(b.spoolman_sync_mode||"auto"),p(!0))},[b]),_.useEffect(()=>{if(!f||!b)return;if(b.spoolman_enabled==="true"!==e||(b.spoolman_url||"")!==r||(b.spoolman_sync_mode||"auto")!==a){const $=setTimeout(()=>{M.mutate()},500);return()=>clearTimeout($)}},[e,r,a,f]);const M=mt({mutationFn:()=>ce.updateSpoolmanSettings({spoolman_enabled:e?"true":"false",spoolman_url:r,spoolman_sync_mode:a}),onSuccess:()=>{t.invalidateQueries({queryKey:["spoolman-settings"]}),t.invalidateQueries({queryKey:["spoolman-status"]}),c(!0),setTimeout(()=>c(!1),2e3)}}),C=mt({mutationFn:ce.connectSpoolman,onSuccess:()=>{k()}}),E=mt({mutationFn:ce.disconnectSpoolman,onSuccess:()=>{k()}}),R=mt({mutationFn:ce.syncAllPrintersAms,onSuccess:P=>{P.success}}),A=mt({mutationFn:P=>ce.syncPrinterAms(P),onSuccess:P=>{P.success}}),D=()=>{u==="all"?R.mutate():A.mutate(u)},I=R.isPending||A.isPending,F=u==="all"?R.data:A.data,z=u==="all"?R.isSuccess:A.isSuccess;return v?s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ku,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]})}),s.jsx(Nt,{children:s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})})})]}):s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ku,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Spoolman Integration"})]}),M.isPending&&s.jsx(ft,{className:"w-4 h-4 text-bambu-green animate-spin"}),l&&s.jsx(Na,{className:"w-4 h-4 text-bambu-green"})]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Connect to Spoolman for filament inventory tracking. AMS data will sync automatically."}),s.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Zo,{className:"w-4 h-4 text-blue-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-xs text-blue-300",children:[s.jsx("p",{className:"font-medium mb-1",children:"How Sync Works"}),s.jsxs("ul",{className:"list-disc list-inside space-y-0.5 text-blue-300/80",children:[s.jsx("li",{children:"Only official Bambu Lab spools with RFID are synced"}),s.jsx("li",{children:"New spools are auto-created in Spoolman on first sync"}),s.jsx("li",{children:"Non-Bambu Lab spools (third-party, refilled) are skipped"})]}),s.jsx("p",{className:"font-medium mt-2 mb-1",children:"Linking Existing Spools"}),s.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".'})]})]})}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Enable Spoolman"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Sync filament data with Spoolman server"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e,onChange:P=>n(P.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Spoolman URL"}),s.jsx("input",{type:"text",placeholder:"http://192.168.1.100:7912",value:r,onChange:P=>i(P.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"URL of your Spoolman server (e.g., http://localhost:7912)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Sync Mode"}),s.jsxs("select",{value:a,onChange:P=>o(P.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:[s.jsx("option",{value:"auto",children:"Automatic"}),s.jsx("option",{value:"manual",children:"Manual Only"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:a==="auto"?"AMS data syncs automatically when changes are detected":"Only sync when manually triggered"})]}),e&&s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Status:"}),S?s.jsx(ft,{className:"w-4 h-4 text-bambu-gray animate-spin"}):y?.connected?s.jsxs("span",{className:"flex items-center gap-1 text-sm text-green-500",children:[s.jsx(Na,{className:"w-4 h-4"}),"Connected"]}):s.jsxs("span",{className:"flex items-center gap-1 text-sm text-red-500",children:[s.jsx(Rt,{className:"w-4 h-4"}),"Disconnected"]})]}),s.jsx("div",{className:"flex gap-2",children:y?.connected?s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>E.mutate(),disabled:E.isPending,children:[E.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(wde,{className:"w-4 h-4"}),"Disconnect"]}):s.jsxs(Te,{size:"sm",onClick:()=>C.mutate(),disabled:C.isPending||!r,children:[C.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(uc,{className:"w-4 h-4"}),"Connect"]})})]}),C.isError&&s.jsx("div",{className:"mb-3 p-2 bg-red-500/20 border border-red-500/50 rounded text-sm text-red-400",children:C.error.message}),y?.connected&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-white",children:"Sync AMS Data"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Manually sync printer AMS data to Spoolman"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsxs("select",{value:u,onChange:P=>d(P.target.value==="all"?"all":Number(P.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:[s.jsx("option",{value:"all",children:"All Printers"}),T?.map(P=>s.jsx("option",{value:P.id,children:P.name},P.id))]}),s.jsx(Kr,{className:"absolute right-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:D,disabled:I,children:[I?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Sync"]})]})]}),z&&F&&s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsx("div",{className:`p-2 rounded text-sm ${F.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:F.success?`Synced ${F.synced_count} spool${F.synced_count!==1?"s":""} successfully`:`Synced ${F.synced_count} spool${F.synced_count!==1?"s":""} with ${F.errors.length} error${F.errors.length!==1?"s":""}`}),F.skipped_count>0&&s.jsxs("div",{className:"p-2 bg-amber-500/10 border border-amber-500/30 rounded text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between text-amber-400 mb-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Sn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{className:"font-medium",children:[F.skipped_count," spool",F.skipped_count!==1?"s":""," skipped"]})]}),F.skipped_count>5&&s.jsx("button",{onClick:()=>x(!m),className:"text-xs text-amber-400 hover:text-amber-300 underline",children:m?"Show less":"Show all"})]}),s.jsxs("ul",{className:"text-xs text-amber-300/80 space-y-0.5",children:[(m?F.skipped:F.skipped.slice(0,5)).map((P,$)=>s.jsxs("li",{className:"flex items-center gap-2",children:[P.color&&s.jsx("span",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:`#${P.color}`}}),s.jsx("span",{children:P.location}),s.jsxs("span",{className:"text-amber-300/60",children:["- ",P.reason]})]},$)),!m&&F.skipped_count>5&&s.jsxs("li",{className:"text-amber-300/60 italic",children:["...and ",F.skipped_count-5," more"]})]})]}),F.errors.length>0&&s.jsxs("div",{className:"p-2 bg-red-500/10 border border-red-500/30 rounded text-sm",children:[s.jsx("div",{className:"text-red-400 font-medium mb-1",children:"Errors:"}),s.jsx("ul",{className:"text-xs text-red-300/80 space-y-0.5",children:F.errors.map((P,$)=>s.jsx("li",{children:P},$))})]})]})]})]})]})}function _Ke({link:t,onClose:e}){const n=sn(),{mode:r}=Oh(),i=!!t,a=_.useRef(null),[o,l]=_.useState(t?.name||""),[c,u]=_.useState(t?.url||""),[d,f]=_.useState(t?.icon||"link"),[p,m]=_.useState(!!t?.custom_icon),[x,b]=_.useState(t?.custom_icon?ce.getExternalLinkIconUrl(t.id):null),[v,y]=_.useState(null),[S,k]=_.useState(null);_.useEffect(()=>{const I=F=>{F.key==="Escape"&&e()};return window.addEventListener("keydown",I),()=>window.removeEventListener("keydown",I)},[e]);const T=mt({mutationFn:async I=>{const F=await ce.createExternalLink(I);return v?await ce.uploadExternalLinkIcon(F.id,v):F},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:I=>{k(I.message)}}),M=mt({mutationFn:async I=>{let F=await ce.updateExternalLink(t.id,I);return v?F=await ce.uploadExternalLinkIcon(t.id,v):!p&&t?.custom_icon&&(F=await ce.deleteExternalLinkIcon(t.id)),F},onSuccess:()=>{n.invalidateQueries({queryKey:["external-links"]}),e()},onError:I=>{k(I.message)}}),C=I=>{const F=I.target.files?.[0];if(F){if(!["image/png","image/jpeg","image/gif","image/svg+xml","image/webp","image/x-icon"].includes(F.type)){k("Please select a valid image file (PNG, JPG, GIF, SVG, WebP, or ICO)");return}if(F.size>1024*1024){k("Image file must be less than 1MB");return}y(F),m(!0);const P=new FileReader;P.onload=$=>{b($.target?.result)},P.readAsDataURL(F)}},E=()=>{y(null),b(null),m(!1),a.current&&(a.current.value="")},R=I=>{if(I.preventDefault(),k(null),!o.trim()){k("Name is required");return}if(!c.trim()){k("URL is required");return}if(!c.startsWith("http://")&&!c.startsWith("https://")){k("URL must start with http:// or https://");return}const F={name:o.trim(),url:c.trim(),icon:d};i?M.mutate(F):T.mutate(F)},A=T.isPending||M.isPending,D=yM(d);return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:e,children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-md",onClick:I=>I.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-full bg-bambu-green/20 text-bambu-green",children:p&&x?s.jsx("img",{src:x,alt:"",className:`w-5 h-5 rounded ${r==="dark"?"invert opacity-[0.65]":"opacity-60"}`}):s.jsx(D,{className:"w-5 h-5"})}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i?"Edit Link":"Add External Link"})]}),s.jsx("button",{onClick:e,className:"text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:R,className:"p-6 space-y-4",children:[S&&s.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:S}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Name *"}),s.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"URL *"}),s.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"})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray",children:"Icon"}),s.jsxs("div",{className:"p-3 rounded-lg bg-bambu-dark border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-white",children:"Custom Icon"}),s.jsx("input",{ref:a,type:"file",accept:"image/png,image/jpeg,image/gif,image/svg+xml,image/webp,image/x-icon",className:"hidden",onChange:C}),p&&x?s.jsxs("div",{className:"flex items-center gap-2",children:[s.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"}`}),s.jsx("button",{type:"button",onClick:E,className:"p-1 text-red-400 hover:text-red-300 transition-colors",title:"Remove custom icon",children:s.jsx(an,{className:"w-4 h-4"})})]}):s.jsxs(Te,{type:"button",variant:"secondary",size:"sm",onClick:()=>a.current?.click(),children:[s.jsx(za,{className:"w-4 h-4"}),"Upload"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"PNG, JPG, GIF, SVG, WebP, or ICO. Max 1MB."})]}),!p&&s.jsxs("div",{children:[s.jsx("span",{className:"text-sm text-bambu-gray block mb-2",children:"Or choose a preset icon"}),s.jsx(Afe,{value:d,onChange:f})]})]}),s.jsxs("div",{className:"flex gap-3 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,className:"flex-1",children:"Cancel"}),s.jsxs(Te,{type:"submit",disabled:A,className:"flex-1",children:[A?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(hs,{className:"w-4 h-4"}),i?"Save":"Add"]})]})]})]})})}function SKe(){const t=sn(),[e,n]=_.useState(!1),[r,i]=_.useState(null),[a,o]=_.useState(null),[l,c]=_.useState(null),{data:u,isLoading:d}=ot({queryKey:["external-links"],queryFn:ce.getExternalLinks}),f=mt({mutationFn:S=>ce.deleteExternalLink(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),p=mt({mutationFn:S=>ce.reorderExternalLinks(S),onSuccess:()=>{t.invalidateQueries({queryKey:["external-links"]})}}),m=(S,k)=>{c(k),S.dataTransfer.effectAllowed="move"},x=S=>{S.preventDefault(),S.dataTransfer.dropEffect="move"},b=(S,k)=>{if(S.preventDefault(),l===null||l===k||!u)return;const T=u.map(R=>R.id),M=T.indexOf(l),C=T.indexOf(k);if(M===-1||C===-1)return;const E=[...T];E.splice(M,1),E.splice(C,0,l),p.mutate(E),c(null)},v=S=>{o(S)},y=()=>{a&&(f.mutate(a.id),o(null))};return s.jsxs(s.Fragment,{children:[s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(uc,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Sidebar Links"})]}),s.jsxs(Te,{size:"sm",onClick:()=>n(!0),children:[s.jsx(fr,{className:"w-4 h-4"}),"Add Link"]})]})}),s.jsxs(Nt,{children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:"Add external links to the sidebar navigation. Drag to reorder."}),d?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):u&&u.length>0?s.jsx("div",{className:"space-y-2",children:u.map(S=>{const k=yM(S.icon);return s.jsxs("div",{draggable:!0,onDragStart:T=>m(T,S.id),onDragOver:x,onDrop:T=>b(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:[s.jsx(zg,{className:"w-6 h-6 md:w-4 md:h-4 text-bambu-gray cursor-grab flex-shrink-0"}),s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-gray",children:s.jsx(k,{className:"w-4 h-4"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-white font-medium truncate",children:S.name}),s.jsx(Xr,{className:"w-3 h-3 text-bambu-gray flex-shrink-0"})]}),s.jsx("span",{className:"text-sm text-bambu-gray truncate block",children:S.url})]}),s.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[s.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:s.jsx(Zi,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>v(S),disabled:f.isPending,className:"p-2 rounded-lg hover:bg-red-500/20 text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50",title:"Delete",children:s.jsx(an,{className:"w-4 h-4"})})]})]},S.id)})}):s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(uc,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:"No external links configured"}),s.jsx("p",{className:"text-sm",children:'Click "Add Link" to add one'})]})]})]}),(e||r)&&s.jsx(_Ke,{link:r,onClose:()=>{n(!1),i(null)}}),a&&s.jsx(Zn,{title:"Delete Link",message:`Are you sure you want to delete "${a.name}"? This action cannot be undone.`,confirmText:"Delete",cancelText:"Cancel",variant:"danger",onConfirm:y,onCancel:()=>o(null)})]})}function NKe(){const{t}=Rn(),e=sn(),{showToast:n}=Hn(),[r,i]=_.useState(!1),[a,o]=_.useState(""),[l,c]=_.useState("immediate"),[u,d]=_.useState("3DPrinter-X1-Carbon"),[f,p]=_.useState(null),[m,x]=_.useState(!1),[b,v]=_.useState(null),{data:y,isLoading:S}=ot({queryKey:["virtual-printer-settings"],queryFn:g1.getSettings,refetchInterval:1e4}),{data:k}=ot({queryKey:["virtual-printer-models"],queryFn:g1.getModels}),{data:T}=ot({queryKey:["printers"],queryFn:ce.getPrinters});_.useEffect(()=>{if(y){i(y.enabled);let z=y.mode==="queue"?"review":y.mode;z!=="immediate"&&z!=="review"&&z!=="print_queue"&&z!=="proxy"&&(z="immediate"),c(z),d(y.model),p(y.target_printer_id)}},[y]);const M=mt({mutationFn:z=>g1.updateSettings(z),onSuccess:()=>{e.invalidateQueries({queryKey:["virtual-printer-settings"]}),n(t("virtualPrinter.toast.updated")),v(null)},onError:z=>{if(n(z.message||t("virtualPrinter.toast.failedToUpdate"),"error"),y){i(y.enabled);const P=y.mode==="queue"?"review":y.mode;c(["immediate","review","print_queue","proxy"].includes(P)?P:"immediate"),d(y.model),p(y.target_printer_id)}v(null)}}),C=()=>{const z=!r;if(z){if(l==="proxy"){if(!f){n(t("virtualPrinter.toast.targetPrinterRequired"),"error");return}}else if(!a&&!y?.access_code_set){n(t("virtualPrinter.toast.accessCodeRequired"),"error");return}}i(z),v("toggle"),M.mutate({enabled:z,access_code:l!=="proxy"&&a||void 0,mode:l,target_printer_id:l==="proxy"?f??void 0:void 0})},E=()=>{if(!a){n(t("virtualPrinter.toast.accessCodeEmpty"),"error");return}if(a.length!==8){n(t("virtualPrinter.toast.accessCodeLength"),"error");return}v("accessCode"),M.mutate({access_code:a}),o("")},R=z=>{c(z),v("mode"),M.mutate({mode:z})},A=z=>{p(z),v("targetPrinter"),M.mutate({target_printer_id:z})},D=z=>{d(z),v("model"),M.mutate({model:z})};if(S)return s.jsx(St,{children:s.jsx(Nt,{className:"py-8 flex justify-center",children:s.jsx(ft,{className:"w-6 h-6 animate-spin text-bambu-green"})})});const I=y?.status,F=I?.running||!1;return s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsx("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ur,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:t("virtualPrinter.title")})]}),I&&s.jsxs("div",{className:`flex items-center gap-2 text-sm ${F?"text-green-400":"text-bambu-gray"}`,children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${F?"bg-green-400 animate-pulse":"bg-gray-500"}`}),t(F?"virtualPrinter.running":"virtualPrinter.stopped")]})]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:t(l==="proxy"?"virtualPrinter.description.proxy":"virtualPrinter.description.default")}),s.jsxs("div",{className:"flex items-center justify-between py-3 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-white font-medium",children:t("virtualPrinter.enable.title")}),s.jsx("div",{className:"text-sm text-bambu-gray",children:F?l==="proxy"?t("virtualPrinter.enable.proxyingTo",{name:T?.find(z=>z.id===f)?.name||"printer"}):t("virtualPrinter.enable.visibleInSlicer"):t("virtualPrinter.enable.notActive")})]}),s.jsx("button",{onClick:C,disabled:b==="toggle",className:`relative w-12 h-6 rounded-full transition-colors ${r?"bg-bambu-green":"bg-bambu-dark-tertiary"} ${b==="toggle"?"opacity-50":""}`,children:s.jsx("span",{className:`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${r?"translate-x-6":""}`})})]}),l!=="proxy"&&s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.model.title")}),s.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:t("virtualPrinter.model.description")}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:u,onChange:z=>D(z.target.value),disabled:b==="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:k?.models&&Object.entries(k.models).sort(([,z],[,P])=>z.localeCompare(P)).map(([z,P])=>s.jsx("option",{value:z,children:P},z))}),s.jsx(Kr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),r&&F&&s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[s.jsx(Zo,{className:"w-3 h-3 inline mr-1"}),t("virtualPrinter.model.restartWarning")]})]}),l!=="proxy"&&s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.accessCode.title")}),s.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:y?.access_code_set?s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(Na,{className:"w-4 h-4"}),t("virtualPrinter.accessCode.isSet")]}):s.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[s.jsx(Sn,{className:"w-4 h-4"}),t("virtualPrinter.accessCode.notSet")]})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx("input",{type:m?"text":"password",value:a,onChange:z=>o(z.target.value),placeholder:y?.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"}),s.jsx("button",{onClick:()=>x(!m),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:m?s.jsx(cM,{className:"w-4 h-4"}):s.jsx(mc,{className:"w-4 h-4"})})]}),s.jsx(Te,{onClick:E,disabled:!a||b==="accessCode",variant:"primary",children:b==="accessCode"?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):t("common.save")})]}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-2",children:[t("virtualPrinter.accessCode.hint"),a&&s.jsxs("span",{className:a.length===8?"text-green-400":"text-yellow-400",children:[" ",t("virtualPrinter.accessCode.charCount",{count:a.length})]})]})]}),l==="proxy"&&s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.targetPrinter.title")}),s.jsx("div",{className:"text-sm text-bambu-gray mb-3",children:f?s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(Na,{className:"w-4 h-4"}),t("virtualPrinter.targetPrinter.configured")]}):s.jsxs("span",{className:"flex items-center gap-1 text-yellow-400",children:[s.jsx(Sn,{className:"w-4 h-4"}),t("virtualPrinter.targetPrinter.notConfigured")]})}),s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:f??"",onChange:z=>{const P=parseInt(z.target.value,10);isNaN(P)||A(P)},disabled:b==="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:[s.jsx("option",{value:"",children:t("virtualPrinter.targetPrinter.placeholder")}),T?.map(z=>s.jsxs("option",{value:z.id,children:[z.name," (",z.ip_address,")"]},z.id))]}),s.jsx(Kr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:t("virtualPrinter.targetPrinter.hint")}),!T?.length&&s.jsxs("p",{className:"text-xs text-yellow-400 mt-2",children:[s.jsx(Sn,{className:"w-3 h-3 inline mr-1"}),t("virtualPrinter.targetPrinter.noPrinters")]})]}),s.jsxs("div",{className:"py-3 border-t border-bambu-dark-tertiary",children:[s.jsx("div",{className:"text-white font-medium mb-2",children:t("virtualPrinter.mode.title")}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{onClick:()=>R("immediate"),disabled:b==="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:[s.jsx("div",{className:"text-white font-medium",children:t("virtualPrinter.mode.archive")}),s.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.archiveDesc")})]}),s.jsxs("button",{onClick:()=>R("review"),disabled:b==="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:[s.jsx("div",{className:"text-white font-medium",children:t("virtualPrinter.mode.review")}),s.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.reviewDesc")})]}),s.jsxs("button",{onClick:()=>R("print_queue"),disabled:b==="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:[s.jsx("div",{className:"text-white font-medium",children:t("virtualPrinter.mode.queue")}),s.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.queueDesc")})]}),s.jsxs("button",{onClick:()=>R("proxy"),disabled:b==="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:[s.jsxs("div",{className:"flex items-center gap-1.5 text-white font-medium",children:[s.jsx(Dz,{className:"w-4 h-4"}),t("virtualPrinter.mode.proxy")]}),s.jsx("div",{className:"text-xs text-bambu-gray",children:t("virtualPrinter.mode.proxyDesc")})]})]})]})]})]})}),s.jsxs("div",{className:"space-y-6 lg:w-[480px] lg:flex-shrink-0",children:[s.jsx(St,{className:"border-l-4 border-l-yellow-500",children:s.jsx(Nt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Sn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"text-white font-medium mb-2",children:t("virtualPrinter.setupRequired.title")}),s.jsx("p",{className:"text-bambu-gray mb-3",children:t("virtualPrinter.setupRequired.description")}),s.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:[s.jsx(Xr,{className:"w-4 h-4"}),t("virtualPrinter.setupRequired.readGuide")]})]})]})})}),s.jsx(St,{children:s.jsx(Nt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Zo,{className:"w-5 h-5 text-blue-400 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:s.jsxs("strong",{className:"text-white",children:[t(l==="proxy"?"virtualPrinter.howItWorks.titleProxy":"virtualPrinter.howItWorks.title"),":"]})}),l==="proxy"?s.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[s.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep1")}),s.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep2")}),s.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep3")}),s.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep4")}),s.jsx("li",{children:t("virtualPrinter.howItWorks.proxyStep5")})]}):s.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[s.jsx("li",{children:t("virtualPrinter.howItWorks.step1")}),s.jsx("li",{children:t("virtualPrinter.howItWorks.step2")}),s.jsx("li",{children:t("virtualPrinter.howItWorks.step3")}),s.jsx("li",{children:t("virtualPrinter.howItWorks.step4")}),s.jsx("li",{children:t("virtualPrinter.howItWorks.step5")}),s.jsx("li",{children:t("virtualPrinter.howItWorks.step6")})]})]})]})})}),I&&F&&s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsx("h3",{className:"text-md font-semibold text-white",children:t("virtualPrinter.status.title")})}),s.jsx(Nt,{children:I.mode==="proxy"&&I.proxy?s.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.targetPrinter")}),s.jsx("div",{className:"text-white",children:T?.find(z=>z.id===f)?.name||I.proxy.target_host}),s.jsx("div",{className:"text-xs text-bambu-gray font-mono",children:I.proxy.target_host})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mode")}),s.jsxs("div",{className:"text-white flex items-center gap-1.5",children:[s.jsx(Dz,{className:"w-4 h-4"}),t("virtualPrinter.mode.proxy")]})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.ftpPort")}),s.jsx("div",{className:"text-white font-mono",children:I.proxy.ftp_port})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mqttPort")}),s.jsx("div",{className:"text-white font-mono",children:I.proxy.mqtt_port})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.ftpConnections")}),s.jsx("div",{className:"text-white",children:I.proxy.ftp_connections})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mqttConnections")}),s.jsx("div",{className:"text-white",children:I.proxy.mqtt_connections})]})]}):s.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.printerName")}),s.jsx("div",{className:"text-white",children:I.name})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.model")}),s.jsx("div",{className:"text-white",children:I.model_name||I.model})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.serialNumber")}),s.jsx("div",{className:"text-white font-mono",children:I.serial})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.mode")}),s.jsx("div",{className:"text-white capitalize",children:I.mode})]}),s.jsxs("div",{children:[s.jsx("div",{className:"text-bambu-gray",children:t("virtualPrinter.status.pendingFiles")}),s.jsx("div",{className:"text-white",children:I.pending_files})]})]})})]})]})]})}function xq({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:s.jsx(Ar,{className:"w-3 h-3"}),failed:s.jsx(Qi,{className:"w-3 h-3"}),skipped:s.jsx(DR,{className:"w-3 h-3"}),running:s.jsx(ft,{className:"w-3 h-3 animate-spin"})};return s.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 MKe(t){return t?new Date(t).toLocaleString():"-"}function bq(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 a=Math.abs(i);if(a<60)return`${a}m ago`;const o=Math.floor(a/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}else{if(i<60)return`in ${i}m`;const a=Math.floor(i/60);return a<24?`in ${a}h`:`in ${Math.floor(a/24)}d`}}function kKe(){const t=sn(),{showToast:e}=Hn(),{t:n}=Rn(),[r,i]=_.useState(""),[a,o]=_.useState(""),[l,c]=_.useState("main"),[u,d]=_.useState(!1),[f,p]=_.useState("daily"),[m,x]=_.useState(!0),[b,v]=_.useState(!0),[y,S]=_.useState(!1),[k,T]=_.useState(!0),[M,C]=_.useState(!1),[E,R]=_.useState(!1),[A,D]=_.useState(""),[I,F]=_.useState(!1),[z,P]=_.useState(null),[$,X]=_.useState(null),V=_.useRef(null);_.useEffect(()=>{if(M||E){const B=O=>(O.preventDefault(),O.returnValue="A backup operation is in progress. Are you sure you want to leave?",O.returnValue);return window.addEventListener("beforeunload",B),()=>window.removeEventListener("beforeunload",B)}},[M,E]);const[Q,Z]=_.useState(!1),[se,H]=_.useState(null),K=_.useRef(null),re=_.useRef(!1),{data:ne,isLoading:be}=ot({queryKey:["github-backup-config"],queryFn:ce.getGitHubBackupConfig}),{data:me}=ot({queryKey:["github-backup-status"],queryFn:ce.getGitHubBackupStatus,refetchInterval:ge=>ge.state.data?.is_running?500:1e4}),{data:de}=ot({queryKey:["github-backup-logs"],queryFn:()=>ce.getGitHubBackupLogs(20)}),{data:Ce}=ot({queryKey:["cloud-status"],queryFn:ce.getCloudStatus}),{data:ie}=ot({queryKey:["printers"],queryFn:ce.getPrinters}),ke=pW({queries:(ie??[]).map(ge=>({queryKey:["printerStatus",ge.id],queryFn:()=>ce.getPrinterStatus(ge.id),staleTime:1e4,refetchInterval:3e4}))}),Oe=(ie??[]).map((ge,B)=>({printer:ge,connected:ke[B]?.data?.connected??!1})),pe=Oe.length,We=Oe.filter(ge=>ge.connected).length,G=pe>0&&We===0,Y=We>0&&We<pe;_.useEffect(()=>{ne&&(i(ne.repository_url),c(ne.branch),d(ne.schedule_enabled),p(ne.schedule_type),x(ne.backup_kprofiles),v(ne.backup_cloud_profiles),S(ne.backup_settings),T(ne.enabled),o(""),setTimeout(()=>{re.current=!0},100))},[ne]);const ue=_.useCallback(async(ge=!1)=>{if(ne?.has_token)try{ge&&a?(await ce.saveGitHubBackupConfig({repository_url:r,access_token:a,branch:l,schedule_enabled:u,schedule_type:f,backup_kprofiles:m,backup_cloud_profiles:b,backup_settings:y,enabled:k}),o(""),e("Token updated")):(await ce.updateGitHubBackupConfig({repository_url:r,branch:l,schedule_enabled:u,schedule_type:f,backup_kprofiles:m,backup_cloud_profiles:b,backup_settings:y,enabled:k}),e("Settings saved")),t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]})}catch(B){e(`Failed to save: ${B.message}`,"error")}},[ne?.has_token,r,a,l,u,f,m,b,y,k,t,e]);_.useEffect(()=>{if(!(!re.current||!ne?.has_token))return K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{ue(!1)},500),()=>{K.current&&clearTimeout(K.current)}},[r,l,u,f,m,b,y,k,ue,ne?.has_token]),_.useEffect(()=>{if(!(!re.current||!ne?.has_token||!a))return K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{ue(!0)},1e3),()=>{K.current&&clearTimeout(K.current)}},[a,ue,ne?.has_token]);const q=mt({mutationFn:ge=>ce.saveGitHubBackupConfig(ge),onSuccess:()=>{t.invalidateQueries({queryKey:["github-backup-config"]}),t.invalidateQueries({queryKey:["github-backup-status"]}),e("GitHub backup enabled"),o(""),re.current=!0},onError:ge=>{e(`Failed to save: ${ge.message}`,"error")}}),te=mt({mutationFn:ce.triggerGitHubBackup,onSuccess:ge=>{t.invalidateQueries({queryKey:["github-backup-status"]}),t.invalidateQueries({queryKey:["github-backup-logs"]}),ge.success?ge.files_changed>0?e(`Backup complete - ${ge.files_changed} files updated`):e("Backup skipped - no changes"):e(`Backup failed: ${ge.message}`,"error")},onError:ge=>{e(`Backup failed: ${ge.message}`,"error")}}),U=mt({mutationFn:()=>ce.clearGitHubBackupLogs(0),onSuccess:ge=>{t.invalidateQueries({queryKey:["github-backup-logs"]}),e(`Cleared ${ge.deleted} logs`)},onError:ge=>{e(`Failed to clear logs: ${ge.message}`,"error")}}),he=async()=>{Z(!0),H(null);try{let ge;if(a){if(!r){e("Enter repository URL","error"),Z(!1);return}ge=await ce.testGitHubConnection(r,a)}else if(ne?.has_token)ge=await ce.testGitHubStoredConnection();else{e("Enter repository URL and access token","error"),Z(!1);return}H({success:ge.success,message:ge.message})}catch(ge){H({success:!1,message:ge.message})}finally{Z(!1)}},Me=()=>{if(!r){e("Repository URL is required","error");return}if(!a){e("Access token is required","error");return}q.mutate({repository_url:r,access_token:a,branch:l,schedule_enabled:u,schedule_type:f,backup_kprofiles:m,backup_cloud_profiles:b,backup_settings:y,enabled:k})};return be?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx(ft,{className:"w-8 h-8 animate-spin text-bambu-green"})}):s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-6",children:[s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(fj,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"GitHub Backup"})]}),ne&&Ce?.is_authenticated&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:"Enabled"}),s.jsx(Ln,{checked:k,onChange:T})]})]})}),s.jsx(Nt,{className:"space-y-4",children:Ce?.is_authenticated?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically sync your profiles to a private GitHub repository for backup and version history."}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Repository URL"}),s.jsx("input",{type:"text",value:r,onChange:ge=>{i(ge.target.value),H(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"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:["Personal Access Token ",ne?.has_token&&s.jsx("span",{className:"text-green-400",children:"(saved)"})]}),s.jsx("input",{type:"password",value:a,onChange:ge=>{o(ge.target.value),H(null)},placeholder:ne?.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Fine-grained token with Contents read/write permission"})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Branch"}),s.jsx("input",{type:"text",value:l,onChange:ge=>c(ge.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Auto-backup"}),s.jsxs("select",{value:u?f:"disabled",onChange:ge=>{ge.target.value==="disabled"?d(!1):(d(!0),p(ge.target.value))},className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"disabled",children:"Manual only"}),s.jsx("option",{value:"hourly",children:"Hourly"}),s.jsx("option",{value:"daily",children:"Daily"}),s.jsx("option",{value:"weekly",children:"Weekly"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:"Include in backup"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:`flex items-start gap-2 ${G?"cursor-not-allowed opacity-60":"cursor-pointer"}`,children:[s.jsx("input",{type:"checkbox",checked:m,onChange:ge=>x(ge.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}),s.jsxs("div",{className:"flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`text-sm ${G?"text-bambu-gray":"text-white"}`,children:"K-Profiles"}),G&&s.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:[s.jsx(Sn,{className:"w-3 h-3"}),"No printers connected"]}),Y&&s.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:[s.jsx(Sn,{className:"w-3 h-3"}),We,"/",pe," connected"]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Pressure advance calibration from connected printers"})]})]}),s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:b,onChange:ge=>v(ge.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:!Ce?.is_authenticated}),s.jsxs("div",{children:[s.jsx("span",{className:`text-sm ${Ce?.is_authenticated?"text-white":"text-bambu-gray"}`,children:"Cloud Profiles"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Filament, printer, and process presets from Bambu Cloud"})]})]}),s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:ge=>S(ge.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"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white text-sm",children:"App Settings"}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Bambuddy configuration (excludes sensitive data)"})]})]})]})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 space-y-3",children:[me?.configured&&s.jsxs("div",{className:"flex items-center justify-between text-sm",children:[s.jsx("div",{className:"flex items-center gap-2 text-bambu-gray",children:me.last_backup_at?s.jsxs(s.Fragment,{children:[s.jsxs("span",{children:["Last backup: ",bq(me.last_backup_at)]}),s.jsx(xq,{status:me.last_backup_status})]}):s.jsx("span",{children:"No backups yet"})}),me.next_scheduled_run&&s.jsxs("span",{className:"text-bambu-gray",children:[s.jsx(tr,{className:"w-3 h-3 inline mr-1"}),"Next: ",bq(me.next_scheduled_run)]})]}),se&&s.jsxs("div",{className:`text-sm flex items-center gap-1 ${se.success?"text-green-400":"text-red-400"}`,children:[se.success?s.jsx(Ar,{className:"w-4 h-4"}):s.jsx(Qi,{className:"w-4 h-4"}),se.message]}),s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:me?.configured?s.jsx(s.Fragment,{children:te.isPending||me.is_running?s.jsxs("div",{className:"flex items-center gap-2 text-bambu-green",children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{className:"text-sm",children:me.progress||"Starting backup..."})]}):s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"primary",size:"sm",onClick:()=>te.mutate(),disabled:!ne?.enabled,children:[s.jsx(bo,{className:"w-4 h-4"}),"Backup Now"]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:he,disabled:Q,children:[Q?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Test"]})]})}):s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"primary",size:"sm",onClick:Me,disabled:q.isPending||!r||!a,children:[q.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Ar,{className:"w-4 h-4"}),"Enable Backup"]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:he,disabled:Q||!r||!a,children:[Q?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Test Connection"]})]})})]})]}):s.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsx(Sn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),s.jsx("p",{className:"text-sm text-yellow-400",children:"Bambu Cloud login required. Sign in under Profiles → Cloud Profiles to enable GitHub backup."})]})})]}),de&&de.length>0&&s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(q0,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"History"})]}),s.jsxs(Te,{variant:"ghost",size:"sm",onClick:()=>U.mutate(),disabled:U.isPending,children:[s.jsx(an,{className:"w-4 h-4"}),"Clear"]})]})}),s.jsx(Nt,{children:s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-bambu-gray border-b border-bambu-dark-tertiary",children:[s.jsx("th",{className:"text-left py-2 px-2",children:"Date"}),s.jsx("th",{className:"text-left py-2 px-2",children:"Status"}),s.jsx("th",{className:"text-left py-2 px-2",children:"Commit"})]})}),s.jsx("tbody",{children:de.slice(0,10).map(ge=>s.jsxs("tr",{className:"border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-secondary",children:[s.jsx("td",{className:"py-2 px-2 text-white",children:MKe(ge.started_at)}),s.jsx("td",{className:"py-2 px-2",children:s.jsx(xq,{status:ge.status})}),s.jsx("td",{className:"py-2 px-2",children:ge.commit_sha?s.jsxs("a",{href:`${ne?.repository_url}/commit/${ge.commit_sha}`,target:"_blank",rel:"noopener noreferrer",className:"text-bambu-green hover:underline inline-flex items-center gap-1",children:[ge.commit_sha.substring(0,7),s.jsx(Xr,{className:"w-3 h-3"})]}):s.jsx("span",{className:"text-bambu-gray",children:"-"})})]},ge.id))})]})})})]})]}),s.jsx("div",{className:"space-y-6",children:s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ku,{className:"w-5 h-5 text-gray-400"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Local Backup"})]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.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."}),s.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Download Backup"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Complete backup: database + all files (ZIP)"})]}),s.jsxs(Te,{variant:"secondary",size:"sm",disabled:M||E,onClick:async()=>{C(!0),D("Preparing backup...");try{D("Creating backup archive... This may take a while for large archives.");const{blob:ge,filename:B}=await ce.exportBackup();D("Downloading backup file...");const O=URL.createObjectURL(ge),ee=document.createElement("a");ee.href=O,ee.download=B,ee.click(),URL.revokeObjectURL(O),e("Backup downloaded successfully")}catch(ge){e(`Failed to create backup: ${ge instanceof Error?ge.message:"Unknown error"}`,"error")}finally{C(!1),D("")}},children:[s.jsx(wi,{className:"w-4 h-4"}),"Download"]})]}),s.jsxs("div",{className:"flex items-center justify-between py-3 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:n("backup.restoreBackup")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n("backup.restoreDescription")}),s.jsx("p",{className:"text-xs text-bambu-gray-light mt-1",children:n("backup.restoreNote")})]}),s.jsx("input",{ref:V,type:"file",accept:".zip",className:"hidden",onChange:ge=>{const B=ge.target.files?.[0];B&&(P(B),F(!0)),ge.target.value=""}}),s.jsxs(Te,{variant:"secondary",size:"sm",disabled:E||M,onClick:()=>V.current?.click(),children:[s.jsx(za,{className:"w-4 h-4"}),"Restore"]})]}),$&&s.jsx("div",{className:`p-3 rounded-lg ${$.success?"bg-green-500/10 border border-green-500/30":"bg-red-500/10 border border-red-500/30"}`,children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[$.success?s.jsx(Ar,{className:"w-4 h-4 text-green-400 mt-0.5 flex-shrink-0"}):s.jsx(Qi,{className:"w-4 h-4 text-red-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:$.success?"text-green-200":"text-red-200",children:[$.message,$.success&&s.jsx("div",{className:"mt-2",children:s.jsxs(Te,{size:"sm",onClick:()=>window.location.reload(),children:[s.jsx(Rh,{className:"w-3 h-3"}),"Reload Now"]})})]})]})}),s.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(Sn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-yellow-200",children:[s.jsx("span",{className:"font-medium",children:"Restore replaces all data."})," ",s.jsx("span",{className:"text-yellow-200/70",children:"Your current database and files will be completely replaced. A restart is required after restore."})]})]})})]})]})}),I&&z&&s.jsx(Zn,{title:"Restore Backup",message:`Are you sure you want to restore from "${z.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()=>{F(!1),R(!0),X(null);try{D("Uploading backup file...");const ge=await ce.importBackup(z);X(ge),ge.success?e("Backup restored. Please restart Bambuddy.","success"):e(ge.message,"error")}catch(ge){const B=ge instanceof Error?ge.message:"Failed to restore backup";X({success:!1,message:B}),e(B,"error")}finally{R(!1),D(""),P(null)}},onCancel:()=>{F(!1),P(null)}}),(M||E)&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-[100]",children:s.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:[s.jsx("div",{className:"flex justify-center mb-4",children:s.jsxs("div",{className:"relative",children:[s.jsx("div",{className:"w-16 h-16 border-4 border-bambu-dark-tertiary rounded-full"}),s.jsx("div",{className:"w-16 h-16 border-4 border-bambu-green border-t-transparent rounded-full absolute inset-0 animate-spin"})]})}),s.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:M?"Creating Backup":"Restoring Backup"}),s.jsx("p",{className:"text-bambu-gray mb-4",children:A||(M?"Preparing...":"Processing...")}),s.jsx("div",{className:"p-3 rounded-lg bg-yellow-500/10 border border-yellow-500/30",children:s.jsxs("div",{className:"flex items-start gap-2 text-sm",children:[s.jsx(Sn,{className:"w-4 h-4 text-yellow-400 mt-0.5 flex-shrink-0"}),s.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 EKe={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 TKe(t,e){const n=e.replace("#/","").split("/");let r=t;for(const i of n)r=r[i];return r}function p0(t,e,n=0){if(n>5)return"...";if(e.$ref)return p0(t,TKe(t,e.$ref),n+1);if(e.allOf){const r={};for(const i of e.allOf){const a=p0(t,i,n+1);typeof a=="object"&&a!==null&&Object.assign(r,a)}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?[p0(t,e.items,n+1)]:[];case"object":if(e.properties){const r={};for(const[i,a]of Object.entries(e.properties))r[i]=p0(t,a,n+1);return r}return{};default:return null}}function AKe({path:t,method:e,spec:n,schema:r,apiKey:i}){const[a,o]=_.useState(!1),[l,c]=_.useState({}),[u,d]=_.useState(""),[f,p]=_.useState(null),[m,x]=_.useState(!1),[b,v]=_.useState(!1);_.useEffect(()=>{if(a&&n.parameters){const R={};for(const A of n.parameters)A.schema?.default!==void 0&&(R[A.name]=String(A.schema.default));c(A=>({...R,...A}))}},[a,n.parameters]),_.useEffect(()=>{if(a&&n.requestBody?.content?.["application/json"]?.schema&&!u){const R=n.requestBody.content["application/json"].schema,A=p0(r,R);d(JSON.stringify(A,null,2))}},[a,n.requestBody,r,u]);const S=(()=>{const R=[];for(const A of n.parameters||[])if(A.in==="path"||A.required){const D=l[A.name];(D===void 0||D==="")&&R.push(A.name)}return R})(),k=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 R=t;const A=new URLSearchParams;for(const se of n.parameters||[]){const H=l[se.name];H!==void 0&&H!==""&&(se.in==="path"?R=R.replace(`{${se.name}}`,encodeURIComponent(H)):se.in==="query"&&A.append(se.name,H))}const D=A.toString(),I=`${R}${D?`?${D}`:""}`,F={"Content-Type":"application/json"};i&&(F["X-API-Key"]=i);const z={method:e.toUpperCase(),headers:F};["post","put","patch"].includes(e)&&u&&(z.body=u);const P=performance.now(),$=await fetch(I,z),X=Math.round(performance.now()-P),V={};$.headers.forEach((se,H)=>{V[H]=se});let Q;$.headers.get("content-type")?.includes("application/json")?Q=await $.json():Q=await $.text(),p({status:$.status,statusText:$.statusText,headers:V,body:Q,duration:X})}catch(R){p({status:0,statusText:"Network Error",headers:{},body:R instanceof Error?R.message:"Unknown error",duration:0})}finally{x(!1)}},T=async()=>{if(f){const R=typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2);try{await navigator.clipboard.writeText(R),v(!0),setTimeout(()=>v(!1),2e3)}catch{const A=document.createElement("textarea");A.value=R,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)}}},M=(n.parameters||[]).filter(R=>R.in==="path"),C=(n.parameters||[]).filter(R=>R.in==="query"),E=["post","put","patch"].includes(e)&&n.requestBody;return s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>o(!a),className:"w-full flex items-center gap-3 p-3 hover:bg-bambu-dark-tertiary/50 transition-colors text-left",children:[a?s.jsx(Kr,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}):s.jsx(gs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:`px-2 py-0.5 text-xs font-mono font-semibold uppercase rounded border ${EKe[e]||"bg-gray-500/20 text-gray-400"}`,children:e}),s.jsx("code",{className:"text-sm text-white font-mono flex-1 truncate",children:t}),n.summary&&s.jsx("span",{className:"text-sm text-bambu-gray truncate max-w-[40%]",children:n.summary})]}),a&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary p-4 space-y-4 bg-bambu-dark/50",children:[n.description&&s.jsx("p",{className:"text-sm text-bambu-gray",children:n.description}),M.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Path Parameters"}),s.jsx("div",{className:"space-y-2",children:M.map(R=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[R.name,R.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),s.jsx("input",{type:"text",value:l[R.name]||"",onChange:A=>c(D=>({...D,[R.name]:A.target.value})),placeholder:R.description||R.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"})]},R.name))})]}),C.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Query Parameters"}),s.jsx("div",{className:"space-y-2",children:C.map(R=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("label",{className:"text-sm text-bambu-gray w-32 flex-shrink-0",children:[R.name,R.required&&s.jsx("span",{className:"text-red-400 ml-1",children:"*"})]}),R.schema?.enum?s.jsxs("select",{value:l[R.name]||"",onChange:A=>c(D=>({...D,[R.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:[s.jsx("option",{value:"",children:"-- Select --"}),R.schema.enum.map(A=>s.jsx("option",{value:A,children:A},A))]}):s.jsx("input",{type:"text",value:l[R.name]||"",onChange:A=>c(D=>({...D,[R.name]:A.target.value})),placeholder:R.description||R.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"})]},R.name))})]}),E&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("h4",{className:"text-sm font-medium text-white",children:"Request Body"}),s.jsx("textarea",{value:u,onChange:R=>d(R.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..."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Te,{onClick:k,disabled:m,children:[m?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(bo,{className:"w-4 h-4"}),"Execute"]}),S.length>0&&s.jsxs("span",{className:"text-xs text-yellow-400 flex items-center gap-1",children:[s.jsx($i,{className:"w-3 h-3"}),"Fill in: ",S.join(", ")]})]}),f&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h4",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Response",s.jsxs("span",{className:`px-2 py-0.5 text-xs rounded ${f.status>=200&&f.status<300?"bg-green-500/20 text-green-400":f.status>=400?"bg-red-500/20 text-red-400":"bg-yellow-500/20 text-yellow-400"}`,children:[f.status," ",f.statusText]}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:[f.duration,"ms"]})]}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:T,children:b?s.jsx(Ar,{className:"w-3 h-3 text-green-400"}):s.jsx(Fl,{className:"w-3 h-3"})})]}),s.jsx("pre",{className:"p-3 bg-bambu-dark rounded-lg text-sm font-mono text-white overflow-auto max-h-96 border border-bambu-dark-tertiary",children:typeof f.body=="string"?f.body:JSON.stringify(f.body,null,2)})]})]})]})}function CKe({apiKey:t=""}){const[e,n]=_.useState(null),[r,i]=_.useState(!0),[a,o]=_.useState(null),[l,c]=_.useState(new Set),[u,d]=_.useState("");if(_.useEffect(()=>{async function v(){try{const y=await fetch("/openapi.json");if(!y.ok)throw new Error("Failed to fetch OpenAPI schema");const S=await y.json();n(S)}catch(y){o(y instanceof Error?y.message:"Unknown error")}finally{i(!1)}}v()},[]),r)return s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(a||!e)return s.jsx(St,{children:s.jsx(Nt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-red-400",children:[s.jsx($i,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),s.jsx("p",{children:"Failed to load API schema"}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:a})]})})});const f={};for(const[v,y]of Object.entries(e.paths))for(const[S,k]of Object.entries(y)){if(S==="parameters")continue;const T=k.tags||["Other"];for(const M of T)f[M]||(f[M]=[]),f[M].push({path:v,method:S,spec:k})}const p=Object.entries(f).map(([v,y])=>{if(!u)return{tag:v,endpoints:y};const S=y.filter(({path:k,method:T,spec:M})=>{const C=u.toLowerCase();return k.toLowerCase().includes(C)||T.toLowerCase().includes(C)||(M.summary?.toLowerCase()||"").includes(C)||(M.description?.toLowerCase()||"").includes(C)});return{tag:v,endpoints:S}}).filter(({endpoints:v})=>v.length>0).sort((v,y)=>v.tag.localeCompare(y.tag)),m=v=>{c(y=>{const S=new Set(y);return S.has(v)?S.delete(v):S.add(v),S})},x=()=>{c(new Set(p.map(v=>v.tag)))},b=()=>{c(new Set)};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("div",{className:"flex-1",children:s.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"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:x,children:"Expand All"}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:b,children:"Collapse All"}),s.jsxs("a",{href:"/docs",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-sm text-bambu-green hover:underline",children:[s.jsx(Xr,{className:"w-4 h-4"}),"Swagger UI"]})]})]}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:[p.reduce((v,y)=>v+y.endpoints.length,0)," endpoints in ",p.length," categories"]}),s.jsx("div",{className:"space-y-3",children:p.map(({tag:v,endpoints:y})=>s.jsxs(St,{children:[s.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:s.jsxs("div",{className:"flex items-center gap-2",children:[l.has(v)?s.jsx(Kr,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(gs,{className:"w-5 h-5 text-bambu-gray"}),s.jsx("h3",{className:"text-base font-semibold text-white capitalize",children:v.replace(/-/g," ")}),s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-2 py-0.5 rounded-full text-bambu-gray",children:y.length})]})}),l.has(v)&&s.jsx(Nt,{className:"pt-0 space-y-2",children:y.map(({path:S,method:k,spec:T})=>s.jsx(AKe,{path:S,method:k,spec:T,schema:e,apiKey:t},`${k}-${S}`))})]},v))})]})}const PKe=["general","network","plugs","notifications","filament","apikeys","virtual-printer","users","backup"];function jKe(){const t=sn(),e=kc(),[n,r]=wR(),{t:i,i18n:a}=Rn(),{showToast:o}=Hn(),{authEnabled:l,user:c,refreshAuth:u}=Ci(),{mode:d,darkStyle:f,darkBackground:p,darkAccent:m,lightStyle:x,lightBackground:b,lightAccent:v,setDarkStyle:y,setDarkBackground:S,setDarkAccent:k,setLightStyle:T,setLightBackground:M,setLightAccent:C}=Oh(),[E,R]=_.useState(null),[A,D]=_.useState(!1),[I,F]=_.useState(null),[z,P]=_.useState(!1),[$,X]=_.useState(null),[V,Q]=_.useState(null),[Z,se]=_.useState(!1),[H,K]=_.useState(UW()),re=n.get("tab"),ne=re&&PKe.includes(re)?re:"general",[be,me]=_.useState(ne),de=oe=>{me(oe),oe==="general"?n.delete("tab"):n.set("tab",oe),r(n,{replace:!0})},[Ce,ie]=_.useState(!1),[ke,Oe]=_.useState(""),[pe,We]=_.useState({can_queue:!0,can_control_printer:!1,can_read_status:!0}),[G,Y]=_.useState(null),[ue,q]=_.useState(null),[te,U]=_.useState(""),[he,Me]=_.useState(!1),[ge,B]=_.useState(!1),[O,ee]=_.useState(null),[le,_e]=_.useState(!1),[ve,ae]=_.useState(!1),[Fe,Be]=_.useState(!1),[$e,He]=_.useState({currentPassword:"",newPassword:"",confirmPassword:""}),[xe,Pe]=_.useState(!1),[ze,we]=_.useState(!1),[Xe,Ne]=_.useState(!1),[rt,Ee]=_.useState(null),[Ke,Ue]=_.useState(null),[W,je]=_.useState(null),[Ye,bt]=_.useState(!1),[pt,Bt]=_.useState({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]}),[Lt,vn]=_.useState(!1),[cn,rr]=_.useState(null),[Vn,Jn]=_.useState(null),[gn,sr]=_.useState({name:"",description:"",permissions:[]}),[Gn,Xn]=_.useState(new Set),[Nn,hi]=_.useState(null),[ai,Ae]=_.useState(!1),[et,ct]=_.useState({}),[ut,lt]=_.useState({}),Et=oe=>{K(oe),Lfe(oe),o(i("settings.toast.settingsSaved"),"success")},fe=()=>{localStorage.removeItem("sidebarOrder"),window.location.reload()},{data:De,isLoading:Ve}=ot({queryKey:["settings"],queryFn:ce.getSettings}),{data:Se,isLoading:Le}=ot({queryKey:["smart-plugs"],queryFn:ce.getSmartPlugs}),{data:tt,isLoading:Qe}=ot({queryKey:["smart-plugs-energy",Se?.map(oe=>oe.id)],queryFn:async()=>{if(!Se||Se.length===0)return null;const oe=await Promise.all(Se.filter(is=>is.enabled).map(async is=>{try{const as=await ce.getSmartPlugStatus(is.id);return{plug:is,status:as}}catch{return{plug:is,status:null}}}));let _t=0,On=0,er=0,Mo=0,Ju=0;for(const{plug:is,status:as}of oe){const $x=is.plug_type==="mqtt"&&as?.energy?.power!=null;(as?.reachable||$x)&&as?.energy&&(Ju++,as.energy?.power!=null&&(_t+=as.energy.power),as.energy?.today!=null&&(On+=as.energy.today),as.energy?.yesterday!=null&&(er+=as.energy.yesterday),as.energy?.total!=null&&(Mo+=as.energy.total))}return{totalPower:_t,totalToday:On,totalYesterday:er,totalLifetime:Mo,reachableCount:Ju,totalPlugs:Se.filter(is=>is.enabled).length}},enabled:be==="plugs"&&!!Se&&Se.length>0,refetchInterval:be==="plugs"?1e4:!1}),{data:Tt,isLoading:At}=ot({queryKey:["notification-providers"],queryFn:ce.getNotificationProviders}),{data:Ft,isLoading:jt}=ot({queryKey:["api-keys"],queryFn:ce.getAPIKeys}),Mt=mt({mutationFn:oe=>ce.createAPIKey(oe),onSuccess:oe=>{Y(oe.key||null),ie(!1),Oe(""),t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyCreated"))},onError:oe=>{o(`Failed to create API key: ${oe.message}`,"error")}}),Jt=mt({mutationFn:oe=>ce.deleteAPIKey(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["api-keys"]}),o(i("settings.toast.apiKeyDeleted"))},onError:oe=>{o(`Failed to delete API key: ${oe.message}`,"error")}}),{data:Ht}=ot({queryKey:["printers"],queryFn:ce.getPrinters}),{data:hn,isLoading:un}=ot({queryKey:["notification-templates"],queryFn:ce.getNotificationTemplates}),{data:Mn}=ot({queryKey:["virtual-printer-settings"],queryFn:g1.getSettings,refetchInterval:1e4}),Gt=Mn?.status?.running??!1,{data:on}=ot({queryKey:["ffmpeg-status"],queryFn:ce.checkFfmpeg}),{data:dn}=ot({queryKey:["version"],queryFn:ce.getVersion}),{data:Yt,refetch:ir,isRefetching:jn}=ot({queryKey:["updateCheck"],queryFn:ce.checkForUpdates,staleTime:300*1e3}),{data:si,refetch:ar}=ot({queryKey:["updateStatus"],queryFn:ce.getUpdateStatus,refetchInterval:oe=>{const _t=oe.state.data;return _t?.status==="downloading"||_t?.status==="installing"?1e3:!1}}),{data:dr}=ot({queryKey:["mqtt-status"],queryFn:ce.getMQTTStatus,refetchInterval:be==="network"?5e3:!1}),{data:nt}=ot({queryKey:["github-backup-status"],queryFn:ce.getGitHubBackupStatus}),{data:Pt}=ot({queryKey:["cloud-status"],queryFn:ce.getCloudStatus}),{hasPermission:qt}=Ci(),{data:vt=[],isLoading:wn}=ot({queryKey:["users"],queryFn:()=>ce.getUsers(),enabled:l&&qt("users:read")}),{data:Fr=[],isLoading:Qr}=ot({queryKey:["groups"],queryFn:()=>ce.getGroups(),enabled:l&&qt("groups:read")}),{data:Br}=ot({queryKey:["permissions"],queryFn:()=>ce.getPermissions(),enabled:l&&qt("groups:read")}),qs=mt({mutationFn:oe=>ce.createUser(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),we(!1),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userCreated"))},onError:oe=>{o(oe.message,"error")}}),nn=mt({mutationFn:({id:oe,data:_t})=>ce.updateUser(oe,_t),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),t.invalidateQueries({queryKey:["groups"]}),Ne(!1),Ee(null),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]}),o(i("settings.toast.userUpdated"))},onError:oe=>{o(oe.message,"error")}}),ln=mt({mutationFn:({id:oe,deleteItems:_t})=>ce.deleteUser(oe,_t),onSuccess:()=>{t.invalidateQueries({queryKey:["users"]}),o(i("settings.toast.userDeleted")),Ue(null),je(null)},onError:oe=>{o(oe.message,"error")}}),Si=async oe=>{Ue(oe),bt(!0);try{const _t=await ce.getUserItemsCount(oe);je(_t)}catch{je({archives:0,queue_items:0,library_files:0})}finally{bt(!1)}},Ss=mt({mutationFn:oe=>ce.createGroup(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),vn(!1),ca(),o(i("settings.toast.groupCreated"))},onError:oe=>{o(oe.message,"error")}}),_o=mt({mutationFn:({id:oe,data:_t})=>ce.updateGroup(oe,_t),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),rr(null),ca(),o(i("settings.toast.groupUpdated"))},onError:oe=>{o(oe.message,"error")}}),So=mt({mutationFn:oe=>ce.deleteGroup(oe),onSuccess:()=>{t.invalidateQueries({queryKey:["groups"]}),o(i("settings.toast.groupDeleted"))},onError:oe=>{o(oe.message,"error")}}),No=()=>{if(!pt.username||!pt.password){o(i("settings.toast.fillRequiredFields"),"error");return}if(pt.password!==pt.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(pt.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}qs.mutate({username:pt.username,password:pt.password,role:pt.role,group_ids:pt.group_ids.length>0?pt.group_ids:void 0})},Ns=oe=>{if(pt.password){if(pt.password!==pt.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if(pt.password.length<6){o(i("settings.toast.passwordTooShort"),"error");return}}const _t={username:pt.username||void 0,password:pt.password||void 0,role:pt.role,group_ids:pt.group_ids};_t.password||delete _t.password,nn.mutate({id:oe,data:_t})},Ni=oe=>{Ee(oe.id),Bt({username:oe.username,password:"",confirmPassword:"",role:oe.role,group_ids:oe.groups?.map(_t=>_t.id)||[]}),Ne(!0)},Ws=oe=>{Bt(_t=>({..._t,group_ids:_t.group_ids.includes(oe)?_t.group_ids.filter(On=>On!==oe):[..._t.group_ids,oe]}))},ca=()=>{sr({name:"",description:"",permissions:[]}),Xn(new Set)},Hr=()=>{if(!gn.name.trim()){o(i("settings.toast.enterGroupName"),"error");return}Ss.mutate({name:gn.name,description:gn.description||void 0,permissions:gn.permissions})},Ux=()=>{if(cn){if(!gn.name.trim()){o(i("settings.toast.enterGroupName"),"error");return}_o.mutate({id:cn.id,data:{name:gn.name!==cn.name?gn.name:void 0,description:gn.description,permissions:gn.permissions}})}},$h=oe=>{rr(oe),sr({name:oe.name,description:oe.description||"",permissions:oe.permissions});const _t=new Set;Br?.categories.forEach(On=>{On.permissions.some(er=>oe.permissions.includes(er.value))&&_t.add(On.name)}),Xn(_t)},$l=oe=>{Xn(_t=>{const On=new Set(_t);return On.has(oe)?On.delete(oe):On.add(oe),On})},zx=oe=>{sr(_t=>{const On=_t.permissions.includes(oe)?_t.permissions.filter(er=>er!==oe):[..._t.permissions,oe];return{..._t,permissions:On}})},Dm=(oe,_t)=>{sr(On=>{const er=oe.permissions.map(is=>is.value),Mo=On.permissions.filter(is=>!er.includes(is)),Ju=_t?[...Mo,...er]:Mo;return{...On,permissions:Ju}})},Rm=oe=>oe.permissions.every(_t=>gn.permissions.includes(_t.value)),Vh=oe=>{const _t=oe.permissions.filter(On=>gn.permissions.includes(On.value));return _t.length>0&&_t.length<oe.permissions.length},Qu=mt({mutationFn:ce.applyUpdate,onSuccess:oe=>{oe.is_docker?o(oe.message,"error"):ar()}}),[Pc,ua]=_.useState(null),pl=mt({mutationFn:ce.testAllNotificationProviders,onSuccess:oe=>{ua(oe),t.invalidateQueries({queryKey:["notification-providers"]}),oe.failed===0?o(`All ${oe.tested} providers tested successfully!`,"success"):o(`${oe.success}/${oe.tested} providers succeeded`,oe.failed>0?"error":"success")},onError:oe=>{o(`Failed to test providers: ${oe.message}`,"error")}}),Vl=mt({mutationFn:async oe=>{if(!Se)return{success:0,failed:0};const _t=Se.filter(er=>er.enabled),On=await Promise.all(_t.map(async er=>{try{return await ce.controlSmartPlug(er.id,oe),{success:!0}}catch{return{success:!1}}}));return{success:On.filter(er=>er.success).length,failed:On.filter(er=>!er.success).length}},onSuccess:(oe,_t)=>{t.invalidateQueries({queryKey:["smart-plugs"]}),t.invalidateQueries({queryKey:["smart-plugs-energy"]}),oe.failed===0?o(`All ${oe.success} plugs turned ${_t}`,"success"):o(`${oe.success} plugs turned ${_t}, ${oe.failed} failed`,"error")},onError:oe=>{o(`Failed: ${oe.message}`,"error")}}),gl=_.useRef(null),Om=_.useRef(!1),Lm=_.useRef(!0);_.useEffect(()=>{if(De&&!E){const oe={...De,external_url:De.external_url||window.location.origin};R(oe),setTimeout(()=>{Lm.current=!1},100)}},[De,E]);const Fm=mt({mutationFn:ce.updateSettings,onSuccess:oe=>{t.setQueryData(["settings"],oe),R(oe),t.invalidateQueries({queryKey:["archiveStats"]}),o(i("settings.toast.settingsSaved"),"success")},onError:oe=>{o(`Failed to save: ${oe.message}`,"error")},onSettled:()=>{Om.current=!1}}),Zu=mt({mutationFn:({id:oe,data:_t})=>ce.updatePrinter(oe,_t),onSuccess:()=>{t.invalidateQueries({queryKey:["printers"]}),o(i("settings.toast.cameraSettingsSaved"),"success")},onError:oe=>{o(`Failed to update printer: ${oe.message}`,"error")}});_.useEffect(()=>{if(!(Lm.current||!E||!De||!(De.auto_archive!==E.auto_archive||De.save_thumbnails!==E.save_thumbnails||De.capture_finish_photo!==E.capture_finish_photo||De.default_filament_cost!==E.default_filament_cost||De.currency!==E.currency||De.energy_cost_per_kwh!==E.energy_cost_per_kwh||De.energy_tracking_mode!==E.energy_tracking_mode||De.check_updates!==E.check_updates||(De.check_printer_firmware??!0)!==(E.check_printer_firmware??!0)||De.notification_language!==E.notification_language||De.ams_humidity_good!==E.ams_humidity_good||De.ams_humidity_fair!==E.ams_humidity_fair||De.ams_temp_good!==E.ams_temp_good||De.ams_temp_fair!==E.ams_temp_fair||De.ams_history_retention_days!==E.ams_history_retention_days||De.per_printer_mapping_expanded!==E.per_printer_mapping_expanded||De.date_format!==E.date_format||De.time_format!==E.time_format||De.default_printer_id!==E.default_printer_id||De.ftp_retry_enabled!==E.ftp_retry_enabled||De.ftp_retry_count!==E.ftp_retry_count||De.ftp_retry_delay!==E.ftp_retry_delay||De.ftp_timeout!==E.ftp_timeout||De.mqtt_enabled!==E.mqtt_enabled||De.mqtt_broker!==E.mqtt_broker||De.mqtt_port!==E.mqtt_port||De.mqtt_username!==E.mqtt_username||De.mqtt_password!==E.mqtt_password||De.mqtt_topic_prefix!==E.mqtt_topic_prefix||De.mqtt_use_tls!==E.mqtt_use_tls||De.external_url!==E.external_url||De.ha_enabled!==E.ha_enabled||De.ha_url!==E.ha_url||De.ha_token!==E.ha_token||(De.library_archive_mode??"ask")!==(E.library_archive_mode??"ask")||Number(De.library_disk_warning_gb??5)!==Number(E.library_disk_warning_gb??5)||(De.camera_view_mode??"window")!==(E.camera_view_mode??"window")||De.prometheus_enabled!==E.prometheus_enabled||De.prometheus_token!==E.prometheus_token))&&!Om.current)return gl.current&&clearTimeout(gl.current),gl.current=setTimeout(()=>{if(Om.current)return;Om.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};Fm.mutate(_t)},500),()=>{gl.current&&clearTimeout(gl.current)}},[E,De,Fm]);const fn=_.useCallback((oe,_t)=>{R(On=>On?{...On,[oe]:_t}:null)},[]),Nv=async(oe,_t,On)=>{if(!_t){o(i("settings.toast.enterCameraUrl"),"error");return}lt(er=>({...er,[oe]:!0})),ct(er=>({...er,[oe]:null}));try{const er=await ce.testExternalCamera(oe,_t,On);ct(Mo=>({...Mo,[oe]:er})),er.success?o(i("settings.toast.cameraConnected",{resolution:er.resolution||""}),"success"):o(er.error||i("settings.toast.connectionFailed"),"error")}catch(er){const Mo=er instanceof Error?er.message:i("settings.toast.testFailed");ct(Ju=>({...Ju,[oe]:{success:!1,error:Mo}})),o(Mo,"error")}finally{lt(er=>({...er,[oe]:!1}))}},[Bx,Mv]=_.useState({}),Hx=_.useRef({}),Im=_.useRef(new Set);_.useEffect(()=>{if(Ht){const oe={};Ht.forEach(_t=>{_t.external_camera_url&&!Im.current.has(_t.id)&&(oe[_t.id]=_t.external_camera_url,Im.current.add(_t.id))}),Object.keys(oe).length>0&&Mv(_t=>({..._t,...oe}))}},[Ht]);const G2=(oe,_t)=>{Mv(On=>({...On,[oe]:_t})),Hx.current[oe]&&clearTimeout(Hx.current[oe]),Hx.current[oe]=setTimeout(()=>{Zu.mutate({id:oe,data:{external_camera_url:_t||null}})},800)},kv=(oe,_t)=>{const On={};_t.type!==void 0&&(On.external_camera_type=_t.type||null),_t.enabled!==void 0&&(On.external_camera_enabled=_t.enabled),Zu.mutate({id:oe,data:On})};return Ve||!E?s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"mb-8",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:i("settings.title")}),s.jsx("p",{className:"text-bambu-gray",children:i("settings.configureBambuddy")})]}),s.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary overflow-x-auto",children:[s.jsx("button",{onClick:()=>de("general"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${be==="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")}),s.jsxs("button",{onClick:()=>de("plugs"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="plugs"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(tl,{className:"w-4 h-4"}),i("settings.tabs.smartPlugs"),Se&&Se.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Se.length})]}),s.jsxs("button",{onClick:()=>de("notifications"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="notifications"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(wg,{className:"w-4 h-4"}),i("settings.tabs.notifications"),Tt&&Tt.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Tt.length})]}),s.jsxs("button",{onClick:()=>de("filament"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="filament"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(xue,{className:"w-4 h-4"}),i("settings.tabs.filament")]}),s.jsxs("button",{onClick:()=>de("network"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="network"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Sg,{className:"w-4 h-4"}),i("settings.tabs.network"),s.jsx("span",{className:`w-2 h-2 rounded-full ${dr?.enabled?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>de("apikeys"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="apikeys"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx($o,{className:"w-4 h-4"}),i("settings.tabs.apiKeys"),Ft&&Ft.length>0&&s.jsx("span",{className:"text-xs bg-bambu-dark-tertiary px-1.5 py-0.5 rounded-full",children:Ft.length})]}),s.jsxs("button",{onClick:()=>de("virtual-printer"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="virtual-printer"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(Ur,{className:"w-4 h-4"}),i("settings.tabs.virtualPrinter"),s.jsx("span",{className:`w-2 h-2 rounded-full ${Gt?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>de("users"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="users"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(mg,{className:"w-4 h-4"}),i("settings.tabs.users"),l&&s.jsx("span",{className:`w-2 h-2 rounded-full ${l?"bg-green-400":"bg-gray-500"}`})]}),s.jsxs("button",{onClick:()=>de("backup"),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px flex items-center gap-2 ${be==="backup"?"text-bambu-green border-bambu-green":"text-bambu-gray hover:text-gray-900 dark:hover:text-white border-transparent"}`,children:[s.jsx(ku,{className:"w-4 h-4"}),i("settings.tabs.backup"),s.jsx("span",{className:`w-2 h-2 rounded-full ${Pt?.is_authenticated&&nt?.configured&&nt?.enabled?"bg-green-400":"bg-gray-500"}`})]})]}),be==="general"&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-xl",children:[s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.general")})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[s.jsx(sh,{className:"w-4 h-4 inline mr-1"}),i("settings.language")]}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:a.language,onChange:oe=>{a.changeLanguage(oe.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:mz.map(oe=>s.jsxs("option",{value:oe.code,children:[oe.nativeName," (",oe.name,")"]},oe.code))}),s.jsx(Kr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.languageDescription")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.defaultView")}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:H,onChange:oe=>Et(oe.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:K0.map(oe=>s.jsx("option",{value:oe.to,children:i(oe.labelKey)},oe.id))}),s.jsx(Kr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("settings.defaultViewDescription")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Date Format"}),s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:E.date_format||"system",onChange:oe=>fn("date_format",oe.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:[s.jsx("option",{value:"system",children:i("settings.systemDefault")}),s.jsx("option",{value:"us",children:"US (MM/DD/YYYY)"}),s.jsx("option",{value:"eu",children:"EU (DD/MM/YYYY)"}),s.jsx("option",{value:"iso",children:"ISO (YYYY-MM-DD)"})]}),s.jsx(Kr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Time Format"}),s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:E.time_format||"system",onChange:oe=>fn("time_format",oe.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:[s.jsx("option",{value:"system",children:i("settings.systemDefault")}),s.jsx("option",{value:"12h",children:"12-hour (3:30 PM)"}),s.jsx("option",{value:"24h",children:"24-hour (15:30)"})]}),s.jsx(Kr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default Printer"}),s.jsxs("div",{className:"relative",children:[s.jsxs("select",{value:E.default_printer_id??"",onChange:oe=>fn("default_printer_id",oe.target.value?Number(oe.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:[s.jsx("option",{value:"",children:i("settings.noDefaultPrinter")}),Ht?.map(oe=>s.jsx("option",{value:oe.id,children:oe.name},oe.id))]}),s.jsx(Kr,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray pointer-events-none"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Pre-select this printer for uploads, reprints, and other operations."})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.sidebarOrder")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Drag items in the sidebar to reorder. Reset to default order here."})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:fe,children:[s.jsx(Rh,{className:"w-4 h-4"}),"Reset"]})]})]})]}),s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(EW,{className:"w-5 h-5"}),"Appearance"]})}),s.jsxs(Nt,{className:"space-y-6",children:[s.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:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Dark Mode",d==="dark"&&s.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),s.jsxs("select",{value:p,onChange:oe=>{S(oe.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:[s.jsx("option",{value:"neutral",children:"Neutral"}),s.jsx("option",{value:"warm",children:"Warm"}),s.jsx("option",{value:"cool",children:"Cool"}),s.jsx("option",{value:"oled",children:"OLED Black"}),s.jsx("option",{value:"slate",children:"Slate Blue"}),s.jsx("option",{value:"forest",children:"Forest Green"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),s.jsxs("select",{value:m,onChange:oe=>{k(oe.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:[s.jsx("option",{value:"green",children:"Green"}),s.jsx("option",{value:"teal",children:"Teal"}),s.jsx("option",{value:"blue",children:"Blue"}),s.jsx("option",{value:"orange",children:"Orange"}),s.jsx("option",{value:"purple",children:"Purple"}),s.jsx("option",{value:"red",children:"Red"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),s.jsxs("select",{value:f,onChange:oe=>{y(oe.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:[s.jsx("option",{value:"classic",children:"Classic"}),s.jsx("option",{value:"glow",children:"Glow"}),s.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),s.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:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:["Light Mode",d==="light"&&s.jsx("span",{className:"text-xs text-bambu-green",children:"(active)"})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Background"}),s.jsxs("select",{value:b,onChange:oe=>{M(oe.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:[s.jsx("option",{value:"neutral",children:"Neutral"}),s.jsx("option",{value:"warm",children:"Warm"}),s.jsx("option",{value:"cool",children:"Cool"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Accent"}),s.jsxs("select",{value:v,onChange:oe=>{C(oe.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:[s.jsx("option",{value:"green",children:"Green"}),s.jsx("option",{value:"teal",children:"Teal"}),s.jsx("option",{value:"blue",children:"Blue"}),s.jsx("option",{value:"orange",children:"Orange"}),s.jsx("option",{value:"purple",children:"Purple"}),s.jsx("option",{value:"red",children:"Red"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1",children:"Style"}),s.jsxs("select",{value:x,onChange:oe=>{T(oe.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:[s.jsx("option",{value:"classic",children:"Classic"}),s.jsx("option",{value:"glow",children:"Glow"}),s.jsx("option",{value:"vibrant",children:"Vibrant"})]})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:"Toggle between dark and light mode using the sun/moon icon in the sidebar."})]})]}),s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.archiveSettings")})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Auto-archive prints"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically save 3MF files when prints complete"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.auto_archive,onChange:oe=>fn("auto_archive",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.saveThumbnails")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Extract and save preview images from 3MF files"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.save_thumbnails,onChange:oe=>fn("save_thumbnails",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.captureFinishPhoto")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Take a photo from printer camera when print completes"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.capture_finish_photo,onChange:oe=>fn("capture_finish_photo",oe.target.checked),className:"sr-only peer"}),s.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&&s.jsxs("div",{className:"flex items-start gap-2 p-3 bg-yellow-500/10 border border-yellow-500/30 rounded-lg",children:[s.jsx(Sn,{className:"w-5 h-5 text-yellow-500 flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"text-sm",children:[s.jsx("p",{className:"text-yellow-500 font-medium",children:"ffmpeg not installed"}),s.jsxs("p",{className:"text-bambu-gray mt-1",children:["Camera capture requires ffmpeg. Install it via"," ",s.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"brew install ffmpeg"})," (macOS) or"," ",s.jsx("code",{className:"bg-bambu-dark-tertiary px-1 rounded",children:"apt install ffmpeg"})," (Linux)."]})]})]})]})]})]}),s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-md",children:[s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(OR,{className:"w-5 h-5 text-bambu-green"}),"Camera"]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Camera View Mode"}),s.jsxs("select",{value:E.camera_view_mode??"window",onChange:oe=>fn("camera_view_mode",oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"window",children:i("settings.newWindow")}),s.jsx("option",{value:"embedded",children:i("settings.embeddedOverlay")})]}),s.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"})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4 mt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-2",children:i("settings.externalCameras")}),s.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?s.jsx("div",{className:"space-y-3",children:Ht.map(oe=>s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-white font-medium text-sm",children:oe.name}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:oe.external_camera_enabled,onChange:_t=>kv(oe.id,{enabled:_t.target.checked}),className:"sr-only peer"}),s.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"})]})]}),oe.external_camera_enabled&&s.jsxs("div",{className:"space-y-2 mt-2",children:[s.jsx("input",{type:"text",placeholder:oe.external_camera_type==="usb"?"Device path (/dev/video0)":"Camera URL (rtsp://... or http://...)",value:Bx[oe.id]??oe.external_camera_url??"",onChange:_t=>G2(oe.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"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{value:oe.external_camera_type||"mjpeg",onChange:_t=>kv(oe.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:[s.jsx("option",{value:"mjpeg",children:"MJPEG Stream"}),s.jsx("option",{value:"rtsp",children:"RTSP Stream"}),s.jsx("option",{value:"snapshot",children:"HTTP Snapshot"}),s.jsx("option",{value:"usb",children:"USB Camera (V4L2)"})]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>Nv(oe.id,Bx[oe.id]??oe.external_camera_url??"",oe.external_camera_type||"mjpeg"),disabled:ut[oe.id]||!(Bx[oe.id]??oe.external_camera_url),children:ut[oe.id]?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):"Test"})]}),et[oe.id]&&s.jsx("div",{className:`text-xs flex items-center gap-1 ${et[oe.id]?.success?"text-green-500":"text-red-500"}`,children:et[oe.id]?.success?s.jsxs(s.Fragment,{children:[s.jsx(Ar,{className:"w-3 h-3"}),"Connected",et[oe.id]?.resolution&&` (${et[oe.id]?.resolution})`]}):s.jsxs(s.Fragment,{children:[s.jsx(Qi,{className:"w-3 h-3"}),et[oe.id]?.error||i("settings.toast.connectionFailed")]})})]})]},oe.id))}):s.jsx("p",{className:"text-xs text-bambu-gray italic",children:i("settings.noPrintersConfigured")})]})]})]}),s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.costTracking")})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Default filament cost (per kg)"}),s.jsx("input",{type:"number",step:"0.01",min:"0",value:E.default_filament_cost,onChange:oe=>fn("default_filament_cost",parseFloat(oe.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Currency"}),s.jsxs("select",{value:E.currency,onChange:oe=>fn("currency",oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"USD",children:"USD ($)"}),s.jsx("option",{value:"EUR",children:"EUR (€)"}),s.jsx("option",{value:"GBP",children:"GBP (£)"}),s.jsx("option",{value:"CHF",children:"CHF (Fr.)"}),s.jsx("option",{value:"JPY",children:"JPY (¥)"}),s.jsx("option",{value:"CNY",children:"CNY (¥)"}),s.jsx("option",{value:"CAD",children:"CAD ($)"}),s.jsx("option",{value:"AUD",children:"AUD ($)"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Electricity cost per kWh"}),s.jsx("input",{type:"number",step:"0.01",min:"0",value:E.energy_cost_per_kwh,onChange:oe=>fn("energy_cost_per_kwh",parseFloat(oe.target.value)||0),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Energy display mode"}),s.jsxs("select",{value:E.energy_tracking_mode||"total",onChange:oe=>fn("energy_tracking_mode",oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"print",children:i("settings.printsOnly")}),s.jsx("option",{value:"total",children:i("settings.totalConsumption")})]}),s.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"})]})]})]}),s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ls,{className:"w-5 h-5 text-bambu-green"}),"File Manager"]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Create Archive Entry When Printing"}),s.jsxs("select",{value:E.library_archive_mode??"ask",onChange:oe=>fn("library_archive_mode",oe.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"always",children:i("settings.archiveMode.always")}),s.jsx("option",{value:"never",children:i("settings.archiveMode.never")}),s.jsx("option",{value:"ask",children:i("settings.archiveMode.ask")})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"When printing from File Manager, optionally create an archive entry"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Low Disk Space Warning"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0.5",max:"100",step:"0.5",value:E.library_disk_warning_gb??5,onChange:oe=>fn("library_disk_warning_gb",parseFloat(oe.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"}),s.jsx("span",{className:"text-bambu-gray",children:"GB"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Show warning when free disk space falls below this threshold"})]})]})]})]}),s.jsxs("div",{className:"space-y-6 flex-1 lg:max-w-sm",children:[s.jsx(SKe,{}),s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:"Updates"})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.checkForUpdatesLabel")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically check for new versions on startup"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.check_updates,onChange:oe=>fn("check_updates",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.checkPrinterFirmware")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Check for printer firmware updates from Bambu Lab"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.check_printer_firmware??!0,onChange:oe=>fn("check_printer_firmware",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]}),s.jsxs("div",{className:"border-t border-bambu-dark-tertiary pt-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.currentVersion")}),s.jsxs("p",{className:"text-sm text-bambu-gray",children:["v",dn?.version||"..."]})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>ir(),disabled:jn,children:[jn?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Dr,{className:"w-4 h-4"}),"Check now"]})]}),Yt?.update_available?s.jsxs("div",{className:"mt-4 p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:[s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{children:[s.jsxs("p",{className:"text-bambu-green font-medium",children:["Update available: v",Yt.latest_version]}),Yt.release_name&&Yt.release_name!==Yt.latest_version&&s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:Yt.release_name})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[Yt.release_notes&&s.jsx("button",{onClick:()=>_e(!0),className:"text-bambu-gray hover:text-white transition-colors text-sm underline",children:"Release Notes"}),Yt.release_url&&s.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:s.jsx(Xr,{className:"w-4 h-4"})})]})]}),si?.status==="downloading"||si?.status==="installing"?s.jsxs("div",{className:"mt-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),s.jsx("span",{children:si.message})]}),s.jsx("div",{className:"mt-2 w-full bg-bambu-dark-tertiary rounded-full h-2",children:s.jsx("div",{className:"bg-bambu-green h-2 rounded-full transition-all duration-300",style:{width:`${si.progress}%`}})})]}):si?.status==="complete"?s.jsx("div",{className:"mt-3 p-2 bg-bambu-green/20 rounded text-sm text-bambu-green",children:si.message}):si?.status==="error"?s.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?s.jsxs("div",{className:"mt-3 p-3 bg-bambu-dark-tertiary rounded-lg",children:[s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:"Update via Docker Compose:"}),s.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"})]}):s.jsxs(Te,{className:"mt-3",onClick:()=>Qu.mutate(),disabled:Qu.isPending,children:[Qu.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(wi,{className:"w-4 h-4"}),"Install Update"]})]}):Yt?.error?s.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?s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:"You're running the latest version"}):null]})]})]}),s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.dataManagement")})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.clearNotificationLogs")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.clearNotificationLogsDescription")})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>Me(!0),children:[s.jsx(an,{className:"w-4 h-4"}),i("common.clear")]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.resetUiPreferences")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.resetUiPreferencesDescription")})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>B(!0),children:[s.jsx(an,{className:"w-4 h-4"}),"Reset"]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:"Backup & Restore"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Export/import settings and configure GitHub backup"})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>de("backup"),children:[s.jsx(ku,{className:"w-4 h-4"}),"Go to Backup"]})]})]})]})]})]}),be==="network"&&E&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6",children:[s.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(sh,{className:"w-5 h-5 text-blue-400"}),"External URL"]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:"The external URL where Bambuddy is accessible. Used for notification images and external integrations."}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bambuddy URL"}),s.jsx("input",{type:"text",value:E.external_url??"",onChange:oe=>fn("external_url",oe.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Include protocol and port (e.g., http://192.168.1.100:8000)"})]})]})]}),s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Dr,{className:"w-5 h-5 text-blue-400"}),"FTP Retry"]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.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."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.enableRetry")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Automatically retry failed FTP operations"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.ftp_retry_enabled??!0,onChange:oe=>fn("ftp_retry_enabled",oe.target.checked),className:"sr-only peer"}),s.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&&s.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry attempts"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"10",value:E.ftp_retry_count??3,onChange:oe=>fn("ftp_retry_count",Math.min(10,Math.max(1,parseInt(oe.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"}),s.jsx("span",{className:"text-bambu-gray",children:"times"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Number of retry attempts before giving up (1-10)"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Retry delay"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"30",value:E.ftp_retry_delay??2,onChange:oe=>fn("ftp_retry_delay",Math.min(30,Math.max(1,parseInt(oe.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"}),s.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:"Wait time between retries (1-30)"})]})]}),s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Connection timeout"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"10",max:"120",value:E.ftp_timeout??30,onChange:oe=>fn("ftp_timeout",Math.min(120,Math.max(10,parseInt(oe.target.value)||30))),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"seconds"})]}),s.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)"})]})]})]})]}),s.jsxs("div",{className:"flex-1 lg:max-w-xl space-y-4",children:[s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Fy,{className:"w-5 h-5 text-bambu-green"}),"Home Assistant"]}),E.ha_enabled&&Nn&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${Nn.success?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${Nn.success?"text-green-400":"text-red-400"}`,children:Nn.success?"Connected":"Disconnected"})]})]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.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."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.enableHomeAssistant")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.homeAssistantDescription")})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.ha_enabled??!1,onChange:oe=>fn("ha_enabled",oe.target.checked),className:"sr-only peer"}),s.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&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Home Assistant URL"}),s.jsx("input",{type:"text",value:E.ha_url??"",onChange:oe=>fn("ha_url",oe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Long-Lived Access Token"}),s.jsx("input",{type:"password",value:E.ha_token??"",onChange:oe=>fn("ha_token",oe.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"}),s.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&&s.jsx("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:s.jsxs(Te,{variant:"secondary",size:"sm",disabled:ai,onClick:async()=>{Ae(!0),hi(null);try{const oe=await ce.testHAConnection(E.ha_url,E.ha_token);hi(oe)}catch(oe){hi({success:!1,message:null,error:oe instanceof Error?oe.message:i("common.unknownError")})}finally{Ae(!1)}},children:[ai?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Sg,{className:"w-4 h-4"}),i("settings.testConnection")]})})]})]})]}),s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Sg,{className:"w-5 h-5 text-blue-400"}),"MQTT Publishing"]}),dr?.enabled&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${dr.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:`text-sm ${dr.connected?"text-green-400":"text-red-400"}`,children:dr.connected?"Connected":"Disconnected"})]})]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.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."}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.enableMqtt")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:"Publish events to external MQTT broker"})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.mqtt_enabled??!1,onChange:oe=>fn("mqtt_enabled",oe.target.checked),className:"sr-only peer"}),s.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&&s.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Broker hostname"}),s.jsx("input",{type:"text",value:E.mqtt_broker??"",onChange:oe=>fn("mqtt_broker",oe.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"})]}),s.jsxs("div",{className:"flex items-end gap-4",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Port"}),s.jsx("input",{type:"number",min:"1",max:"65535",value:E.mqtt_port??1883,onChange:oe=>fn("mqtt_port",Math.min(65535,Math.max(1,parseInt(oe.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"})]}),s.jsxs("div",{className:"flex items-center gap-3 pb-2",children:[s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.mqtt_use_tls??!1,onChange:oe=>{const _t=oe.target.checked;fn("mqtt_use_tls",_t);const On=E.mqtt_port??1883;_t&&On===1883?fn("mqtt_port",8883):!_t&&On===8883&&fn("mqtt_port",1883)},className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]}),s.jsx("span",{className:"text-white text-sm",children:i("settings.useTls")})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Username (optional)"}),s.jsx("input",{type:"text",value:E.mqtt_username??"",onChange:oe=>fn("mqtt_username",oe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Password (optional)"}),s.jsx("input",{type:"password",value:E.mqtt_password??"",onChange:oe=>fn("mqtt_password",oe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Topic prefix"}),s.jsx("input",{type:"text",value:E.mqtt_topic_prefix??"bambuddy",onChange:oe=>fn("mqtt_topic_prefix",oe.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"}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["Topics will be: ",E.mqtt_topic_prefix||"bambuddy","/printers/<serial>/status, etc."]})]}),dr&&s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:`w-2 h-2 rounded-full ${dr.connected?"bg-green-400":"bg-red-400"}`}),s.jsx("span",{className:"text-bambu-gray",children:dr.connected?s.jsxs(s.Fragment,{children:[i("settings.mqttConnectedTo")," ",s.jsxs("span",{className:"text-white",children:[dr.broker,":",dr.port]})]}):i("settings.spoolmanDisconnected")})]})})]})]})]})]}),s.jsx("div",{className:"flex-1 lg:max-w-md space-y-4",children:s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(yj,{className:"w-5 h-5 text-orange-400"}),"Prometheus Metrics"]})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("p",{className:"text-sm text-bambu-gray",children:["Expose printer metrics at ",s.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"/api/v1/metrics"})," for Prometheus/Grafana monitoring."]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white",children:i("settings.enableMetricsEndpoint")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.prometheusDescription")})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.prometheus_enabled??!1,onChange:oe=>fn("prometheus_enabled",oe.target.checked),className:"sr-only peer"}),s.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&&s.jsxs("div",{className:"space-y-4 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:"Bearer Token (optional)"}),s.jsx("input",{type:"password",value:E.prometheus_token??"",onChange:oe=>fn("prometheus_token",oe.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"}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:["If set, requests must include ",s.jsx("code",{className:"bg-bambu-dark px-1 rounded",children:"Authorization: Bearer <token>"})]})]}),s.jsxs("div",{className:"pt-2 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-sm text-white mb-2",children:i("settings.availableMetrics")}),s.jsxs("div",{className:"text-xs text-bambu-gray space-y-1",children:[s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_connected"})," - Connection status"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_printer_state"})," - Printer state (idle/printing/etc)"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_print_progress"})," - Print progress 0-100%"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_bed_temp_celsius"})," - Bed temperature"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_nozzle_temp_celsius"})," - Nozzle temperature"]}),s.jsxs("p",{children:[s.jsx("code",{className:"text-orange-400",children:"bambuddy_prints_total"})," - Total prints by result"]}),s.jsx("p",{className:"text-bambu-gray/70 italic",children:"...and more (layers, fans, queue, filament usage)"})]})]})]})]})]})})]}),Nn&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-6 max-w-md w-full mx-4",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[Nn.success?s.jsx(Ar,{className:"w-8 h-8 text-green-400"}):s.jsx(Qi,{className:"w-8 h-8 text-red-400"}),s.jsx("h3",{className:"text-lg font-medium text-white",children:Nn.success?"Connection Successful":"Connection Failed"})]}),s.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."}),s.jsx("div",{className:"flex justify-end",children:s.jsx(Te,{variant:"primary",onClick:()=>hi(null),children:"OK"})})]})}),be==="plugs"&&s.jsxs("div",{className:"max-w-4xl",children:[s.jsxs("div",{className:"flex items-start justify-between mb-6",children:[s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(tl,{className:"w-5 h-5 text-bambu-green"}),"Smart Plugs"]}),s.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."})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-1 shrink-0",children:[Se&&Se.filter(oe=>oe.enabled).length>1&&s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>ee("on"),disabled:Vl.isPending,title:i("settings.turnAllPlugsOn"),children:[Vl.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Gu,{className:"w-4 h-4 text-bambu-green"}),"All On"]}),s.jsxs(Te,{variant:"secondary",size:"sm",className:"whitespace-nowrap",onClick:()=>ee("off"),disabled:Vl.isPending,title:i("settings.turnAllPlugsOff"),children:[Vl.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(gM,{className:"w-4 h-4 text-red-400"}),"All Off"]})]}),s.jsxs(Te,{className:"whitespace-nowrap",onClick:()=>{F(null),D(!0)},children:[s.jsx(fr,{className:"w-4 h-4"}),"Add Smart Plug"]})]})]}),Se&&Se.length>0&&s.jsxs(St,{className:"mb-6",children:[s.jsx(Kn,{children:s.jsxs("h3",{className:"text-base font-semibold text-white flex items-center gap-2",children:[s.jsx(vh,{className:"w-4 h-4 text-yellow-400"}),"Energy Summary",Qe&&s.jsx(ft,{className:"w-4 h-4 animate-spin text-bambu-gray ml-2"})]})}),s.jsx(Nt,{children:tt?s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(vh,{className:"w-3 h-3"}),"Current Power"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[tt.totalPower.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"W"})]}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[tt.reachableCount,"/",tt.totalPlugs," plugs online"]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(ti,{className:"w-3 h-3"}),"Today"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[tt.totalToday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),E&&E.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(tt.totalToday*E.energy_cost_per_kwh).toFixed(2)," ",E.currency]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(yj,{className:"w-3 h-3"}),"Yesterday"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[tt.totalYesterday.toFixed(2),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),E&&E.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(tt.totalYesterday*E.energy_cost_per_kwh).toFixed(2)," ",E.currency]})]}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-bambu-gray text-xs mb-1",children:[s.jsx(hj,{className:"w-3 h-3"}),"Total"]}),s.jsxs("div",{className:"text-xl font-bold text-white",children:[tt.totalLifetime.toFixed(1),s.jsx("span",{className:"text-sm font-normal text-bambu-gray ml-1",children:"kWh"})]}),E&&E.energy_cost_per_kwh>0&&s.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:["~",(tt.totalLifetime*E.energy_cost_per_kwh).toFixed(2)," ",E.currency]})]})]}):Qe?null:s.jsx("p",{className:"text-sm text-bambu-gray",children:"Enable plugs to see energy summary"})})]}),Le?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Se&&Se.length>0?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Se.map(oe=>s.jsx(dKe,{plug:oe,onEdit:_t=>{F(_t),D(!0)}},oe.id))}):s.jsx(St,{children:s.jsx(Nt,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(tl,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:i("settings.noSmartPlugsTitle")}),s.jsx("p",{className:"text-sm mb-4",children:i("settings.noSmartPlugsDescription")}),s.jsxs(Te,{onClick:()=>{F(null),D(!0)},children:[s.jsx(fr,{className:"w-4 h-4"}),i("settings.addFirstSmartPlug")]})]})})})]}),be==="notifications"&&s.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(wg,{className:"w-5 h-5 text-bambu-green"}),i("settings.providers")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>se(!0),children:[s.jsx(q0,{className:"w-4 h-4"}),i("settings.log")]}),Tt&&Tt.length>0&&s.jsxs(Te,{size:"sm",variant:"secondary",onClick:()=>{ua(null),pl.mutate()},disabled:pl.isPending,children:[pl.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(jR,{className:"w-4 h-4"}),i("settings.testAll")]}),s.jsxs(Te,{size:"sm",onClick:()=>{X(null),P(!0)},children:[s.jsx(fr,{className:"w-4 h-4"}),"Add"]})]})]}),s.jsx(St,{className:"mb-4",children:s.jsx(Nt,{className:"py-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-white text-sm font-medium",children:i("settings.notificationLanguage")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.notificationLanguageDescription")})]}),s.jsx("select",{value:E.notification_language||"en",onChange:oe=>fn("notification_language",oe.target.value),className:"px-2 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:ring-1 focus:ring-bambu-green",children:mz.map(oe=>s.jsx("option",{value:oe.code,children:oe.nativeName},oe.code))})]})})}),Pc&&s.jsx(St,{className:"mb-4",children:s.jsxs(Nt,{className:"py-3",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm font-medium text-white",children:i("settings.testResults")}),s.jsx("button",{onClick:()=>ua(null),className:"text-bambu-gray hover:text-white text-xs",children:i("common.dismiss")})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm mb-2",children:[s.jsxs("span",{className:"flex items-center gap-1 text-bambu-green",children:[s.jsx(Ar,{className:"w-4 h-4"}),i("settings.testPassedCount",{count:Pc.success})]}),Pc.failed>0&&s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(Qi,{className:"w-4 h-4"}),i("settings.testFailedCount",{count:Pc.failed})]})]}),Pc.results.filter(oe=>!oe.success).length>0&&s.jsx("div",{className:"space-y-1 mt-2 pt-2 border-t border-bambu-dark-tertiary",children:Pc.results.filter(oe=>!oe.success).map(oe=>s.jsxs("div",{className:"text-xs text-red-400",children:[s.jsxs("span",{className:"font-medium",children:[oe.provider_name,":"]})," ",oe.message]},oe.provider_id))})]})}),At?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Tt&&Tt.length>0?s.jsx("div",{className:"space-y-3",children:Tt.map(oe=>s.jsx(mKe,{provider:oe,onEdit:_t=>{X(_t),P(!0)}},oe.id))}):s.jsx(St,{children:s.jsx(Nt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(wg,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm font-medium text-white mb-2",children:i("settings.noProvidersTitle")}),s.jsx("p",{className:"text-xs mb-3",children:i("settings.noProvidersDescription")}),s.jsxs(Te,{size:"sm",onClick:()=>{X(null),P(!0)},children:[s.jsx(fr,{className:"w-4 h-4"}),i("settings.addProvider")]})]})})})]}),s.jsxs("div",{children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-4",children:[s.jsx(Ls,{className:"w-5 h-5 text-bambu-green"}),i("settings.messageTemplates")]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:i("settings.messageTemplatesDescription")}),un?s.jsx("div",{className:"flex justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):hn&&hn.length>0?s.jsx("div",{className:"space-y-2",children:hn.map(oe=>s.jsx(St,{className:"cursor-pointer hover:border-bambu-green/50 transition-colors",onClick:()=>Q(oe),children:s.jsx(Nt,{className:"py-2.5 px-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-white font-medium text-sm truncate",children:oe.name}),s.jsx("p",{className:"text-bambu-gray text-xs truncate mt-0.5",children:oe.title_template})]}),s.jsx("button",{className:"p-1.5 hover:bg-bambu-dark-tertiary rounded transition-colors shrink-0 ml-2",onClick:_t=>{_t.stopPropagation(),Q(oe)},children:s.jsx(fg,{className:"w-4 h-4 text-bambu-gray"})})]})})},oe.id))}):s.jsx(St,{children:s.jsx(Nt,{className:"py-8",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx(Ls,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),s.jsx("p",{className:"text-sm",children:i("settings.noTemplatesAvailable")})]})})})]})]}),be==="apikeys"&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[s.jsxs("div",{className:"flex-1",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx($o,{className:"w-5 h-5 text-bambu-green"}),i("settings.apiKeys")]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.apiKeysDescription")})]}),s.jsxs(Te,{size:"sm",onClick:()=>ie(!0),className:"flex-shrink-0",children:[s.jsx(fr,{className:"w-4 h-4"}),i("settings.createKey")]})]}),G&&s.jsx(St,{className:"mb-6 border-bambu-green",children:s.jsx(Nt,{className:"py-4",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Ar,{className:"w-5 h-5 text-bambu-green flex-shrink-0 mt-0.5"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-white font-medium mb-1",children:i("settings.apiKeyCreated")}),s.jsx("p",{className:"text-sm text-bambu-gray mb-2",children:i("settings.apiKeyCopyWarning")}),s.jsxs("div",{className:"flex items-center gap-2 bg-bambu-dark rounded-lg p-2",children:[s.jsx("code",{className:"flex-1 text-sm text-bambu-green font-mono break-all",children:G}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(G);else{const oe=document.createElement("textarea");oe.value=G,oe.style.position="fixed",oe.style.left="-999999px",document.body.appendChild(oe),oe.select(),document.execCommand("copy"),document.body.removeChild(oe)}o(i("settings.toast.keyCopied"))}catch{o(i("settings.toast.copyFailed"),"error")}},children:s.jsx(Fl,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex gap-2 mt-3",children:[s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>{U(G),o(i("settings.toast.keyAddedToBrowser"))},children:i("settings.useInApiBrowser")}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>Y(null),children:i("common.dismiss")})]})]})]})})}),Ce&&s.jsxs(St,{className:"mb-6",children:[s.jsx(Kn,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.createNewApiKey")})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.keyName")}),s.jsx("input",{type:"text",value:ke,onChange:oe=>Oe(oe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:i("common.permissions")}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:pe.can_read_status,onChange:oe=>We(_t=>({..._t,can_read_status:oe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:i("settings.readStatus")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.readStatusDescription")})]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:pe.can_queue,onChange:oe=>We(_t=>({..._t,can_queue:oe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:i("settings.manageQueue")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.manageQueueDescription")})]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:pe.can_control_printer,onChange:oe=>We(_t=>({..._t,can_control_printer:oe.target.checked})),className:"w-4 h-4 text-bambu-green rounded border-bambu-dark-tertiary bg-bambu-dark focus:ring-bambu-green"}),s.jsxs("div",{children:[s.jsx("span",{className:"text-white",children:i("settings.controlPrinter")}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.controlPrinterDescription")})]})]})]})]}),s.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[s.jsxs(Te,{onClick:()=>Mt.mutate({name:ke||i("settings.unnamedKey"),...pe}),disabled:Mt.isPending,children:[Mt.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(fr,{className:"w-4 h-4"}),i("settings.createKey")]}),s.jsx(Te,{variant:"secondary",onClick:()=>ie(!1),children:i("common.cancel")})]})]})]}),jt?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):Ft&&Ft.length>0?s.jsx("div",{className:"space-y-3",children:Ft.map(oe=>s.jsx(St,{children:s.jsx(Nt,{className:"py-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx($o,{className:`w-5 h-5 ${oe.enabled?"text-bambu-green":"text-bambu-gray"}`}),s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium",children:oe.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[oe.key_prefix,"••••••••",oe.last_used&&` · ${i("settings.lastUsed")}: ${Bg(oe.last_used)}`]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex gap-1 text-xs",children:[oe.can_read_status&&s.jsx("span",{className:"px-1.5 py-0.5 bg-blue-500/20 text-blue-400 rounded",children:i("settings.read")}),oe.can_queue&&s.jsx("span",{className:"px-1.5 py-0.5 bg-green-500/20 text-green-400 rounded",children:i("queue.title")}),oe.can_control_printer&&s.jsx("span",{className:"px-1.5 py-0.5 bg-orange-500/20 text-orange-400 rounded",children:i("settings.control")})]}),s.jsx(Te,{variant:"secondary",size:"sm",onClick:()=>q(oe.id),children:s.jsx(an,{className:"w-4 h-4 text-red-400"})})]})]})})},oe.id))}):s.jsx(St,{children:s.jsx(Nt,{className:"py-12",children:s.jsxs("div",{className:"text-center text-bambu-gray",children:[s.jsx($o,{className:"w-16 h-16 mx-auto mb-4 opacity-30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:i("settings.apiKeysEmptyTitle")}),s.jsx("p",{className:"text-sm mb-4",children:i("settings.apiKeysEmptyDescription")}),s.jsxs(Te,{onClick:()=>ie(!0),children:[s.jsx(fr,{className:"w-4 h-4"}),i("settings.createFirstKey")]})]})})}),s.jsxs(St,{className:"mt-6",children:[s.jsx(Kn,{children:s.jsx("h3",{className:"text-base font-semibold text-white",children:i("settings.webhookEndpoints")})}),s.jsxs(Nt,{className:"space-y-3 text-sm",children:[s.jsx("p",{className:"text-bambu-gray",children:i("settings.webhookApiKeyHint")}),s.jsxs("div",{className:"space-y-2 font-mono text-xs",children:[s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-blue-400",children:"GET"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/status"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.getAllStatus")]})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-blue-400",children:"GET"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/status/:id"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.getSpecificStatus")]})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-green-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/queue"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.addToQueue")]})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-orange-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/pause"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.pausePrint")]})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-orange-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/resume"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.resumePrint")]})]}),s.jsxs("div",{className:"p-2 bg-bambu-dark rounded",children:[s.jsx("span",{className:"text-red-400",children:"POST"})," ",s.jsx("span",{className:"text-white",children:"/api/v1/webhook/printer/:id/stop"}),s.jsxs("span",{className:"text-bambu-gray",children:[" - ",i("settings.webhook.stopPrint")]})]})]})]})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(sh,{className:"w-5 h-5 text-bambu-green"}),i("settings.apiBrowser")]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:i("settings.apiBrowserDescription")})]}),s.jsx(St,{className:"mb-4",children:s.jsxs(Nt,{className:"py-3",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-2",children:i("settings.apiKeyForTesting")}),s.jsx("input",{type:"text",value:te,onChange:oe=>U(oe.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-2",children:i("settings.apiKeyHint")})]})}),s.jsx(CKe,{apiKey:te})]})]}),be==="virtual-printer"&&s.jsx(NKe,{}),be==="filament"&&E&&s.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[s.jsx("div",{className:"flex-1 lg:max-w-xl",children:s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.amsDisplayThresholds")})}),s.jsxs(Nt,{className:"space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.amsThresholdsDescription")}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(AR,{className:"w-4 h-4 text-blue-400"}),s.jsx("span",{className:"font-medium",children:i("settings.humidity")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.goodGreen")," ≤"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0",max:"100",value:E.ams_humidity_good??40,onChange:oe=>fn("ams_humidity_good",parseInt(oe.target.value)||40),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"%"})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.fairOrange")," ≤"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"0",max:"100",value:E.ams_humidity_fair??60,onChange:oe=>fn("ams_humidity_fair",parseInt(oe.target.value)||60),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"%"})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.aboveFairBad")})]}),s.jsxs("div",{className:"space-y-3 pt-2 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(bM,{className:"w-4 h-4 text-orange-400"}),s.jsx("span",{className:"font-medium",children:i("settings.temperature")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.goodBlue")," ≤"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:E.ams_temp_good??28,onChange:oe=>fn("ams_temp_good",parseFloat(oe.target.value)||28),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-bambu-gray mb-1",children:[i("settings.fairOrange")," ≤"]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",step:"0.5",min:"0",max:"60",value:E.ams_temp_fair??35,onChange:oe=>fn("ams_temp_fair",parseFloat(oe.target.value)||35),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:"°C"})]})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.aboveFairHot")})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(ku,{className:"w-4 h-4 text-purple-400"}),s.jsx("span",{className:"font-medium",children:i("settings.historyRetention")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:i("settings.keepSensorHistory")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",min:"1",max:"365",value:E.ams_history_retention_days??30,onChange:oe=>fn("ams_history_retention_days",parseInt(oe.target.value)||30),className:"w-24 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none"}),s.jsx("span",{className:"text-bambu-gray",children:i("common.days")})]})]}),s.jsx("p",{className:"text-xs text-bambu-gray",children:i("settings.historyRetentionDescription")})]}),s.jsxs("div",{className:"space-y-3 pt-4 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 text-white",children:[s.jsx(Ur,{className:"w-4 h-4 text-bambu-green"}),s.jsx("span",{className:"font-medium",children:i("settings.printModal")})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-white",children:i("settings.expandCustomMapping")}),s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:i("settings.expandCustomMappingDescription")})]}),s.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.per_printer_mapping_expanded??!1,onChange:oe=>fn("per_printer_mapping_expanded",oe.target.checked),className:"sr-only peer"}),s.jsx("div",{className:"w-11 h-6 bg-bambu-dark-tertiary peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-bambu-green"})]})]})]})]})]})}),s.jsx("div",{className:"flex-1 lg:max-w-xl",children:s.jsx(wKe,{})})]}),ue!==null&&s.jsx(Zn,{title:i("settings.deleteApiKeyTitle"),message:i("settings.deleteApiKeyMessage"),confirmText:i("settings.deleteKey"),variant:"danger",onConfirm:()=>{Jt.mutate(ue),q(null)},onCancel:()=>q(null)}),A&&s.jsx(hKe,{plug:I,onClose:()=>{D(!1),F(null)}}),z&&s.jsx(pKe,{provider:$,onClose:()=>{P(!1),X(null)}}),V&&s.jsx(gKe,{template:V,onClose:()=>Q(null)}),Z&&s.jsx(yKe,{onClose:()=>se(!1)}),he&&s.jsx(Zn,{title:i("settings.clearNotificationLogs"),message:i("settings.clearLogsMessage"),confirmText:i("settings.clearLogs"),variant:"warning",onConfirm:async()=>{Me(!1);try{const oe=await ce.clearNotificationLogs(30);o(oe.message,"success")}catch{o(i("settings.toast.clearLogsFailed"),"error")}},onCancel:()=>Me(!1)}),ge&&s.jsx(Zn,{title:i("settings.resetUiPreferences"),message:i("settings.resetUiPreferencesMessage"),confirmText:i("settings.resetPreferences"),variant:"default",onConfirm:()=>{B(!1),localStorage.clear(),o(i("settings.toast.uiPreferencesReset"),"success"),setTimeout(()=>window.location.reload(),1e3)},onCancel:()=>B(!1)}),O&&s.jsx(Zn,{title:`Turn All Plugs ${O==="on"?"On":"Off"}`,message:`This will turn ${O==="on"?"ON":"OFF"} all ${Se?.filter(oe=>oe.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 oe=O;ee(null),Vl.mutate(oe)},onCancel:()=>ee(null)}),le&&Yt?.release_notes&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",onClick:()=>_e(!1),children:s.jsxs(St,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",onClick:oe=>oe.stopPropagation(),children:[s.jsxs(Kn,{className:"flex flex-row items-center justify-between shrink-0",children:[s.jsxs("div",{children:[s.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&&s.jsx("p",{className:"text-sm text-bambu-gray",children:Yt.release_name})]}),s.jsx("button",{onClick:()=>_e(!1),className:"p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx(Nt,{className:"overflow-y-auto flex-1",children:s.jsx("pre",{className:"text-sm text-bambu-gray whitespace-pre-wrap font-sans",children:Yt.release_notes})}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary shrink-0 flex gap-2",children:[Yt.release_url&&s.jsx("a",{href:Yt.release_url,target:"_blank",rel:"noopener noreferrer",className:"flex-1",children:s.jsxs(Te,{variant:"secondary",className:"w-full",children:[s.jsx(Xr,{className:"w-4 h-4"}),"View on GitHub"]})}),s.jsx(Te,{onClick:()=>_e(!1),className:"flex-1",children:"Close"})]})]})}),be==="users"&&s.jsxs("div",{className:"space-y-6",children:[s.jsx(St,{children:s.jsx(Nt,{className:"py-4",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.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?s.jsx(nT,{className:"w-5 h-5 text-green-400"}):s.jsx(tT,{className:"w-5 h-5 text-gray-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white font-medium",children:i("settings.authentication")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:i(l?"settings.authEnabledDescription":"settings.authDisabledDescription")})]})]}),l?c?.is_admin&&s.jsxs(Te,{variant:"secondary",onClick:()=>ae(!0),children:[s.jsx(tT,{className:"w-4 h-4"}),i("common.disable")]}):s.jsxs(Te,{onClick:()=>e("/setup"),children:[s.jsx(nT,{className:"w-4 h-4"}),i("common.enable")]})]})})}),l&&s.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-6",children:[s.jsxs("div",{className:"space-y-6",children:[c&&s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(mg,{className:"w-5 h-5 text-bambu-green"}),i("settings.currentUser")]}),s.jsxs(Te,{size:"sm",variant:"ghost",onClick:()=>Be(!0),children:[s.jsx($o,{className:"w-4 h-4"}),i("settings.changePassword")]})]})}),s.jsx(Nt,{children:s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{children:[s.jsx("p",{className:"text-white font-medium text-lg",children:c.username}),s.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[c.is_admin&&s.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(oe=>s.jsx("span",{className:`px-2 py-0.5 rounded-full text-xs font-medium ${oe.name==="Administrators"?"bg-purple-500/20 text-purple-300":oe.name==="Operators"?"bg-blue-500/20 text-blue-300":oe.name==="Viewers"?"bg-green-500/20 text-green-300":"bg-gray-500/20 text-gray-300"}`,children:oe.name},oe.id))]})]})})})]}),s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(mg,{className:"w-5 h-5 text-bambu-green"}),i("settings.users")]}),qt("users:create")&&s.jsxs(Te,{size:"sm",onClick:()=>{we(!0),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:[s.jsx(fr,{className:"w-4 h-4"}),i("settings.addUser")]})]})}),s.jsx(Nt,{children:wn?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):vt.length===0?s.jsx("p",{className:"text-center text-bambu-gray py-8",children:i("settings.noUsersFound")}):s.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:vt.map(oe=>s.jsxs("div",{className:"py-3 flex items-center justify-between",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-white font-medium truncate",children:oe.username}),s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[oe.is_admin&&s.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")}),oe.groups?.map(_t=>s.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))]})]}),s.jsxs("div",{className:"flex items-center gap-1 ml-4",children:[qt("users:update")&&s.jsx(Te,{size:"sm",variant:"ghost",onClick:()=>Ni(oe),children:s.jsx(fg,{className:"w-4 h-4"})}),qt("users:delete")&&oe.id!==c?.id&&s.jsx(Te,{size:"sm",variant:"ghost",onClick:()=>Si(oe.id),children:s.jsx(an,{className:"w-4 h-4"})})]})]},oe.id))})})]})]}),s.jsx("div",{children:s.jsxs(St,{children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("h3",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(rT,{className:"w-5 h-5 text-bambu-green"}),i("settings.groups")]}),qt("groups:create")&&s.jsxs(Te,{size:"sm",onClick:()=>{vn(!0),ca()},children:[s.jsx(fr,{className:"w-4 h-4"}),i("settings.addGroup")]})]})}),s.jsx(Nt,{children:Qr?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 text-bambu-green animate-spin"})}):Fr.length===0?s.jsx("p",{className:"text-center text-bambu-gray py-8",children:i("settings.noGroupsFound")}):s.jsx("div",{className:"divide-y divide-bambu-dark-tertiary",children:Fr.map(oe=>s.jsxs("div",{className:"py-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(rT,{className:`w-4 h-4 ${oe.name==="Administrators"?"text-purple-400":oe.name==="Operators"?"text-blue-400":oe.name==="Viewers"?"text-green-400":"text-bambu-gray"}`}),s.jsx("span",{className:"text-white font-medium",children:oe.name}),oe.is_system&&s.jsx("span",{className:"px-2 py-0.5 rounded text-xs bg-yellow-500/20 text-yellow-400",children:i("settings.system")})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[qt("groups:update")&&s.jsx(Te,{size:"sm",variant:"ghost",onClick:()=>$h(oe),children:s.jsx(fg,{className:"w-4 h-4"})}),qt("groups:delete")&&!oe.is_system&&s.jsx(Te,{size:"sm",variant:"ghost",onClick:()=>Jn(oe.id),children:s.jsx(an,{className:"w-4 h-4"})})]})]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-6",children:oe.description||i("settings.noDescription")}),s.jsxs("div",{className:"flex items-center gap-4 mt-2 ml-6 text-xs text-bambu-gray",children:[s.jsx("span",{children:i("settings.userCount",{count:oe.user_count})}),s.jsx("span",{children:i("settings.permissionCount",{count:oe.permissions.length})})]})]},oe.id))})})]})})]}),!l&&s.jsx(St,{children:s.jsx(Nt,{className:"py-6",children:s.jsxs("div",{className:"text-center",children:[s.jsx(tT,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:i("settings.authDisabledTitle")}),s.jsx("p",{className:"text-sm text-bambu-gray mb-4 max-w-md mx-auto",children:i("settings.authDisabledMessage")}),s.jsxs("ul",{className:"space-y-2 text-sm text-bambu-gray mb-6 text-left max-w-xs mx-auto",children:[s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:i("settings.authDisabledFeature1")})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:i("settings.authDisabledFeature2")})]}),s.jsxs("li",{className:"flex items-start gap-2",children:[s.jsx(Ar,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsx("span",{children:i("settings.authDisabledFeature3")})]})]}),s.jsxs(Te,{onClick:()=>e("/setup"),children:[s.jsx(nT,{className:"w-4 h-4"}),i("settings.enableAuthentication")]})]})})})]}),ze&&s.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{we(!1),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:s.jsxs(St,{className:"w-full max-w-md",onClick:oe=>oe.stopPropagation(),children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(mg,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.createUser")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{we(!1),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:s.jsx(Rt,{className:"w-5 h-5"})})]})}),s.jsxs(Nt,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.username")}),s.jsx("input",{type:"text",value:pt.username,onChange:oe=>Bt({...pt,username:oe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.password")}),s.jsx("input",{type:"password",value:pt.password,onChange:oe=>Bt({...pt,password:oe.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.confirmPassword")}),s.jsx("input",{type:"password",value:pt.confirmPassword,onChange:oe=>Bt({...pt,confirmPassword:oe.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 ${pt.confirmPassword&&pt.password!==pt.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmPasswordPlaceholder"),autoComplete:"new-password",minLength:6}),pt.confirmPassword&&pt.password!==pt.confirmPassword&&s.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Groups"}),s.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(oe=>s.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:pt.group_ids.includes(oe.id),onChange:()=>Ws(oe.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),s.jsx("span",{className:"text-sm text-white",children:oe.name}),oe.is_system&&s.jsx("span",{className:"text-xs text-yellow-400",children:"(System)"})]},oe.id)),Fr.length===0&&s.jsx("p",{className:"text-sm text-bambu-gray",children:i("settings.noGroupsAvailable")})]})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{we(!1),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:"Cancel"}),s.jsx(Te,{onClick:No,disabled:qs.isPending||!pt.username||!pt.password||pt.password!==pt.confirmPassword||pt.password.length<6,children:qs.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):s.jsxs(s.Fragment,{children:[s.jsx(fr,{className:"w-4 h-4"}),"Create User"]})})]})]})]})}),Xe&&rt!==null&&s.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{Ne(!1),Ee(null),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:s.jsxs(St,{className:"w-full max-w-md",onClick:oe=>oe.stopPropagation(),children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(fg,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.editUser")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{Ne(!1),Ee(null),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:s.jsx(Rt,{className:"w-5 h-5"})})]})}),s.jsxs(Nt,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.username")}),s.jsx("input",{type:"text",value:pt.username,onChange:oe=>Bt({...pt,username:oe.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"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:["Password ",s.jsx("span",{className:"text-bambu-gray font-normal",children:"(leave blank to keep current)"})]}),s.jsx("input",{type:"password",value:pt.password,onChange:oe=>Bt({...pt,password:oe.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})]}),pt.password&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.confirmPassword")}),s.jsx("input",{type:"password",value:pt.confirmPassword,onChange:oe=>Bt({...pt,confirmPassword:oe.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 ${pt.confirmPassword&&pt.password!==pt.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),pt.confirmPassword&&pt.password!==pt.confirmPassword&&s.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Groups"}),s.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(oe=>s.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-tertiary cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:pt.group_ids.includes(oe.id),onChange:()=>Ws(oe.id),className:"w-4 h-4 rounded border-bambu-gray text-bambu-green focus:ring-bambu-green focus:ring-offset-0 bg-bambu-dark"}),s.jsx("span",{className:"text-sm text-white",children:oe.name}),oe.is_system&&s.jsx("span",{className:"text-xs text-yellow-400",children:"(System)"})]},oe.id))})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{Ne(!1),Ee(null),Bt({username:"",password:"",confirmPassword:"",role:"user",group_ids:[]})},children:"Cancel"}),s.jsx(Te,{onClick:()=>Ns(rt),disabled:nn.isPending||!pt.username||!!(pt.password&&(pt.password!==pt.confirmPassword||pt.password.length<6)),children:nn.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Saving..."]}):s.jsxs(s.Fragment,{children:[s.jsx(hs,{className:"w-4 h-4"}),"Save Changes"]})})]})]})]})}),Ke!==null&&s.jsx("div",{className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",onClick:()=>{Ue(null),je(null)},children:s.jsxs(St,{className:"w-full max-w-md",onClick:oe=>oe.stopPropagation(),children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center gap-2 text-red-400",children:[s.jsx(an,{className:"w-5 h-5"}),s.jsx("h3",{className:"text-lg font-semibold",children:i("settings.deleteUserTitle")})]})}),s.jsx(Nt,{className:"space-y-4",children:Ye?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-2 border-bambu-green border-t-transparent"})}):W&&W.archives+W.queue_items+W.library_files>0?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-white",children:i("settings.userHasCreated")}),s.jsxs("ul",{className:"list-disc list-inside text-bambu-gray space-y-1",children:[W.archives>0&&s.jsxs("li",{children:[W.archives," archive",W.archives!==1?"s":""]}),W.queue_items>0&&s.jsxs("li",{children:[W.queue_items," queue item",W.queue_items!==1?"s":""]}),W.library_files>0&&s.jsxs("li",{children:[W.library_files," library file",W.library_files!==1?"s":""]})]}),s.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.userItemsQuestion")}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(Te,{variant:"danger",onClick:()=>ln.mutate({id:Ke,deleteItems:!0}),disabled:ln.isPending,className:"justify-center",children:"Delete user AND their items"}),s.jsx(Te,{variant:"secondary",onClick:()=>ln.mutate({id:Ke,deleteItems:!1}),disabled:ln.isPending,className:"justify-center",children:"Delete user, keep items (become ownerless)"}),s.jsx(Te,{variant:"ghost",onClick:()=>{Ue(null),je(null)},disabled:ln.isPending,className:"justify-center",children:"Cancel"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-white",children:i("settings.deleteUserConfirm")}),s.jsx("p",{className:"text-bambu-gray text-sm",children:i("settings.actionCannotBeUndone")}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx(Te,{variant:"ghost",onClick:()=>{Ue(null),je(null)},disabled:ln.isPending,children:"Cancel"}),s.jsx(Te,{variant:"danger",onClick:()=>ln.mutate({id:Ke,deleteItems:!1}),disabled:ln.isPending,children:"Delete User"})]})]})})]})}),(Lt||cn)&&s.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>{vn(!1),rr(null),ca()},children:s.jsxs(St,{className:"w-full max-w-2xl max-h-[90vh] overflow-y-auto",onClick:oe=>oe.stopPropagation(),children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(rT,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:cn?"Edit Group":"Create Group"})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{vn(!1),rr(null),ca()},children:s.jsx(Rt,{className:"w-5 h-5"})})]})}),s.jsxs(Nt,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:i("settings.groupName")}),s.jsx("input",{type:"text",value:gn.name,onChange:oe=>sr({...gn,name:oe.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&&s.jsx("p",{className:"text-xs text-yellow-400 mt-1",children:i("settings.systemGroupWarning")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Description"}),s.jsx("textarea",{value:gn.description,onChange:oe=>sr({...gn,description:oe.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")})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm font-medium text-white mb-2",children:["Permissions (",gn.permissions.length," selected)"]}),s.jsx("div",{className:"space-y-2 max-h-96 overflow-y-auto",children:Br?.categories.map(oe=>s.jsxs("div",{className:"border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[s.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:()=>$l(oe.name),children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{type:"button",onClick:_t=>{_t.stopPropagation(),Dm(oe,!Rm(oe))},className:`w-5 h-5 rounded border flex items-center justify-center transition-colors ${Rm(oe)?"bg-bambu-green border-bambu-green":Vh(oe)?"bg-bambu-green/50 border-bambu-green":"border-bambu-gray hover:border-white"}`,children:(Rm(oe)||Vh(oe))&&s.jsx(Na,{className:"w-3 h-3 text-white"})}),s.jsx("span",{className:"text-white font-medium",children:oe.name}),s.jsxs("span",{className:"text-xs text-bambu-gray",children:["(",oe.permissions.filter(_t=>gn.permissions.includes(_t.value)).length,"/",oe.permissions.length,")"]})]}),Gn.has(oe.name)?s.jsx(Kr,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(gs,{className:"w-4 h-4 text-bambu-gray"})]}),Gn.has(oe.name)&&s.jsx("div",{className:"p-3 bg-bambu-dark space-y-2",children:oe.permissions.map(_t=>s.jsxs("label",{className:"flex items-center gap-3 px-2 py-1.5 rounded hover:bg-bambu-dark-secondary cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:gn.permissions.includes(_t.value),onChange:()=>zx(_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"}),s.jsx("span",{className:"text-sm text-bambu-gray",children:_t.label})]},_t.value))})]},oe.name))})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{vn(!1),rr(null),ca()},children:"Cancel"}),s.jsx(Te,{onClick:cn?Ux:Hr,disabled:Ss.isPending||_o.isPending||!gn.name.trim(),children:Ss.isPending||_o.isPending?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),cn?"Saving...":"Creating..."]}):s.jsxs(s.Fragment,{children:[s.jsx(hs,{className:"w-4 h-4"}),cn?"Save Changes":"Create Group"]})})]})]})]})}),Vn!==null&&s.jsx(Zn,{title:i("settings.deleteGroupTitle"),message:i("settings.deleteGroupMessage"),confirmText:i("settings.deleteGroup"),variant:"danger",onConfirm:()=>{So.mutate(Vn),Jn(null)},onCancel:()=>Jn(null)}),be==="backup"&&s.jsx(kKe,{}),ve&&s.jsx(Zn,{title:i("settings.disableAuthenticationTitle"),message:i("settings.disableAuthenticationMessage"),confirmText:i("settings.disableAuthentication"),variant:"danger",onConfirm:async()=>{try{await ce.disableAuth(),o(i("settings.toast.authDisabled"),"success"),await u(),ae(!1),window.location.href="/"}catch(oe){const _t=oe instanceof Error?oe.message:i("settings.toast.authDisableFailed");o(_t,"error")}},onCancel:()=>ae(!1)}),Fe&&s.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:s.jsxs(St,{className:"w-full max-w-md",onClick:oe=>oe.stopPropagation(),children:[s.jsx(Kn,{children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($o,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("settings.changePassword")})]}),s.jsx(Te,{variant:"ghost",size:"sm",onClick:()=>{Be(!1),He({currentPassword:"",newPassword:"",confirmPassword:""})},children:s.jsx(Rt,{className:"w-5 h-5"})})]})}),s.jsxs(Nt,{children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Current Password"}),s.jsx("input",{type:"password",value:$e.currentPassword,onChange:oe=>He({...$e,currentPassword:oe.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"New Password"}),s.jsx("input",{type:"password",value:$e.newPassword,onChange:oe=>He({...$e,newPassword:oe.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Confirm New Password"}),s.jsx("input",{type:"password",value:$e.confirmPassword,onChange:oe=>He({...$e,confirmPassword:oe.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 ${$e.confirmPassword&&$e.newPassword!==$e.confirmPassword?"border-red-500":"border-bambu-dark-tertiary"}`,placeholder:i("settings.confirmNewPassword"),autoComplete:"new-password",minLength:6}),$e.confirmPassword&&$e.newPassword!==$e.confirmPassword&&s.jsx("p",{className:"text-red-400 text-xs mt-1",children:i("settings.passwordsDoNotMatch")})]})]}),s.jsxs("div",{className:"mt-6 flex justify-end gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>{Be(!1),He({currentPassword:"",newPassword:"",confirmPassword:""})},children:"Cancel"}),s.jsx(Te,{onClick:async()=>{if($e.newPassword!==$e.confirmPassword){o(i("settings.toast.passwordsDoNotMatch"),"error");return}if($e.newPassword.length<6){o(i("settings.toast.passwordTooShort"),"error");return}Pe(!0);try{await ce.changePassword($e.currentPassword,$e.newPassword),o(i("settings.toast.passwordChanged"),"success"),Be(!1),He({currentPassword:"",newPassword:"",confirmPassword:""})}catch(oe){const _t=oe instanceof Error?oe.message:"Failed to change password";o(_t,"error")}finally{Pe(!1)}},disabled:xe||!$e.currentPassword||!$e.newPassword||$e.newPassword!==$e.confirmPassword||$e.newPassword.length<6,children:xe?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 animate-spin"}),"Changing..."]}):s.jsxs(s.Fragment,{children:[s.jsx($o,{className:"w-4 h-4"}),"Change Password"]})})]})]})]})})]})}const Ure=t=>{const e=parseFloat(t);return(Math.trunc(e*1e3)/1e3).toFixed(3)},DKe=t=>t.startsWith("HH")?"HF":"S",RKe=t=>{const e=t.match(/^([A-Z]{2}\d{2})/);return e?e[1]:"HH00"},uR=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 $P({profile:t,onEdit:e,onCopy:n,selectionMode:r,isSelected:i,onToggleSelect:a,note:o}){const l=DKe(t.nozzle_id),c=t.nozzle_diameter,u=()=>{r&&a?a():e()};return s.jsxs("div",{className:"flex items-center gap-2",children:[r&&s.jsx("button",{onClick:a,className:"text-bambu-gray hover:text-white transition-colors p-1",children:i?s.jsx(ol,{className:"w-4 h-4 text-bambu-green"}):s.jsx(ll,{className:"w-4 h-4"})}),s.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:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-bambu-green font-mono text-sm font-bold whitespace-nowrap",children:Ure(t.k_value)}),s.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name||"Unnamed"}),o&&s.jsx("span",{title:"Has note",children:s.jsx(CW,{className:"w-3 h-3 text-yellow-500"})}),s.jsxs("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:[l," ",c]})]}),o&&s.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&&s.jsx("button",{onClick:d=>{d.stopPropagation(),n()},className:"text-bambu-gray hover:text-white transition-colors p-1",title:"Copy profile",children:s.jsx(Fl,{className:"w-4 h-4"})})]})}function VP({profile:t,printerId:e,nozzleDiameter:n,existingProfiles:r=[],isDualNozzle:i=!1,initialNote:a="",initialNoteKey:o=null,onClose:l,onSave:c,onSaveNote:u,hasPermission:d}){const{t:f}=Rn(),{showToast:p}=Hn(),[m,x]=_.useState(t?.name||""),[b,v]=_.useState(t?.k_value?Ure(t.k_value):"0.020"),[y,S]=_.useState(t?.filament_id||""),[k,T]=_.useState(t?.nozzle_id?RKe(t.nozzle_id):"HH00"),[M,C]=_.useState(t?.nozzle_diameter||n),[E,R]=_.useState(t?[t.extruder_id]:i?[0,1]:[0]),[A,D]=_.useState(!1),[I,F]=_.useState({current:0,total:0}),[z,P]=_.useState(a),$=ei.useMemo(()=>{const K=new Map;for(const re of r)if(re.filament_id&&!K.has(re.filament_id)){const ne=uR(re.name||"");K.set(re.filament_id,{id:re.filament_id,name:ne||re.filament_id})}return Array.from(K.values()).sort((re,ne)=>re.name.localeCompare(ne.name))},[r]),X=mt({mutationFn:K=>(console.log("[KProfile] Calling API..."),ce.setKProfile(e,K)),onSuccess:K=>{if(console.log("[KProfile] Save success:",K),p(f("kProfiles.toast.profileSaved")),u&&z!==a){let re;z===""&&o?re=o:t&&t.slot_id>0?re=t.setting_id||`slot_${t.slot_id}_${t.filament_id}_${t.extruder_id}`:re=`name_${m}_${y}`,u(re,z)}D(!0),setTimeout(()=>{D(!1),c()},2500)},onError:K=>{console.error("[KProfile] Save error:",K),p(K.message,"error"),D(!1)}}),V=mt({mutationFn:K=>(console.log("[KProfile] Deleting profile..."),ce.deleteKProfile(e,K)),onSuccess:K=>{console.log("[KProfile] Delete success:",K),p(f("kProfiles.toast.profileDeleted")),D(!0),setTimeout(()=>{D(!1),l()},4e3)},onError:K=>{console.error("[KProfile] Delete error:",K),p(K.message,"error"),D(!1)}}),[Q,Z]=_.useState(!1),se=()=>{t&&V.mutate({slot_id:t.slot_id,extruder_id:t.extruder_id,nozzle_id:t.nozzle_id,nozzle_diameter:t.nozzle_diameter,filament_id:t.filament_id,setting_id:t.setting_id})},H=async K=>{if(K.preventDefault(),i&&!t&&E.length===0){p(f("kProfiles.toast.selectAtLeastOneExtruder"),"error");return}const re=parseFloat(b).toFixed(6),ne=`${k}-${M}`;if(t||E.length===1){const me={name:m,k_value:re,filament_id:y,nozzle_id:ne,nozzle_diameter:M,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),X.mutate(me);return}D(!0),F({current:1,total:E.length});const be=E.map(me=>({name:m,k_value:re,filament_id:y,nozzle_id:ne,nozzle_diameter:M,extruder_id:me,setting_id:void 0,slot_id:0}));console.log(`[KProfile] Saving ${be.length} profiles in batch:`,be);try{if(await ce.setKProfilesBatch(e,be),p(f("kProfiles.toast.profilesSaved",{count:E.length})),u&&z){const me=`name_${m}_${y}`;u(me,z)}}catch(me){console.error("[KProfile] Failed to save batch:",me),p(f("kProfiles.toast.failedToSaveBatch"),"error"),D(!1),F({current:0,total:0});return}F({current:E.length,total:E.length}),setTimeout(()=>{D(!1),F({current:0,total:0}),c()},3e3)};return s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:[s.jsxs(St,{className:"w-full max-w-md relative",children:[A&&s.jsxs("div",{className:"absolute inset-0 bg-bambu-dark-secondary/90 flex flex-col items-center justify-center z-10 rounded-lg",children:[s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:I.total>1?f("kProfiles.modal.savingExtruder",{current:I.current,total:I.total}):f("kProfiles.modal.syncing")}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:f("kProfiles.modal.pleaseWait")})]}),s.jsxs(Nt,{className:"p-0",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:f(t?"kProfiles.modal.editTitle":"kProfiles.modal.addTitle")}),s.jsx("button",{onClick:l,className:"text-bambu-gray hover:text-white transition-colors",disabled:A,children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("form",{onSubmit:H,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.profileName")}),s.jsx("input",{type:"text",value:m,onChange:K=>x(K.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:f("kProfiles.modal.profileNamePlaceholder"),required:!t})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.kValue")}),s.jsx("input",{type:"text",inputMode:"decimal",value:b,onChange:K=>{const re=K.target.value;(re===""||/^\d*\.?\d*$/.test(re))&&v(re)},onBlur:K=>{const re=parseFloat(K.target.value);isNaN(re)||v((Math.trunc(re*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:f("kProfiles.modal.kValuePlaceholder"),required:!0}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:f("kProfiles.modal.kValueHelp")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.filament")}),s.jsxs("select",{value:y,onChange:K=>{const re=K.target.value;if(S(re),!t&&re&&!m){const ne=$.find(be=>be.id===re);ne&&x(`${k==="HH00"?"HF":"S"} ${ne.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:[s.jsx("option",{value:"",children:f("kProfiles.modal.selectFilament")}),t?.filament_id&&s.jsx("option",{value:t.filament_id,children:$.find(K=>K.id===t.filament_id)?.name||t.filament_id},t.filament_id),!t&&$.map(K=>s.jsx("option",{value:K.id,children:K.name},K.id))]}),!t&&$.length===0&&s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:f("kProfiles.modal.noFilamentsHelp")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.flowType")}),s.jsxs("select",{value:k,onChange:K=>{const re=K.target.value;if(T(re),!t&&y&&!m){const ne=$.find(be=>be.id===y);ne&&x(`${re==="HS00"?"HF":"S"} ${ne.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:[s.jsx("option",{value:"HH00",children:f("kProfiles.modal.highFlow")}),s.jsx("option",{value:"HS00",children:f("kProfiles.modal.standard")})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.nozzleSize")}),s.jsxs("select",{value:M,onChange:K=>C(K.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:[s.jsx("option",{value:"0.2",children:"0.2mm"}),s.jsx("option",{value:"0.4",children:"0.4mm"}),s.jsx("option",{value:"0.6",children:"0.6mm"}),s.jsx("option",{value:"0.8",children:"0.8mm"})]})]})]}),i&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f(t?"kProfiles.modal.extruder":"kProfiles.modal.extruders")}),t?s.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?f("kProfiles.modal.left"):f("kProfiles.modal.right")}):s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.includes(1),onChange:K=>{K.target.checked?R([...E,1]):R(E.filter(re=>re!==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"}),s.jsx("span",{className:"text-white",children:f("kProfiles.modal.left")})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:E.includes(0),onChange:K=>{K.target.checked?R([...E,0]):R(E.filter(re=>re!==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"}),s.jsx("span",{className:"text-white",children:f("kProfiles.modal.right")})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:f("kProfiles.modal.notes")}),s.jsx("textarea",{value:z,onChange:K=>P(K.target.value),placeholder:f("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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:f("kProfiles.modal.notesHelp")})]}),s.jsxs("div",{className:"flex gap-2 pt-4",children:[t&&s.jsx(Te,{type:"button",variant:"secondary",onClick:()=>Z(!0),disabled:V.isPending||A||!d("kprofiles:delete"),title:d("kprofiles:delete")?void 0:f("kProfiles.permission.noDelete"),className:"text-red-500 hover:bg-red-500/10",children:V.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(an,{className:"w-4 h-4"})}),s.jsx(Te,{type:"button",variant:"secondary",onClick:l,disabled:A,className:"flex-1",children:f("common.cancel")}),s.jsxs(Te,{type:"submit",disabled:X.isPending||A||!d(t?"kprofiles:update":"kprofiles:create"),title:d(t?"kprofiles:update":"kprofiles:create")?void 0:f(t?"kProfiles.permission.noUpdate":"kProfiles.permission.noCreate"),className:"flex-1",children:[X.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(hM,{className:"w-4 h-4"}),f("common.save")]})]})]})]})]}),Q&&s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[60]",children:s.jsx(St,{className:"w-full max-w-sm",children:s.jsxs(Nt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:s.jsx(an,{className:"w-5 h-5 text-red-500"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:f("kProfiles.deleteConfirm.title")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:f("kProfiles.deleteConfirm.cannotUndo")})]})]}),s.jsx("p",{className:"text-bambu-gray mb-6",children:f("kProfiles.deleteConfirm.message",{name:t?.name})}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>Z(!1),className:"flex-1",children:f("common.cancel")}),s.jsxs(Te,{onClick:()=>{Z(!1),se()},disabled:V.isPending,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[V.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(an,{className:"w-4 h-4"}),f("common.delete")]})]})]})})})]})}const f1={NOZZLE_DIAMETER:"bambusy_kprofiles_nozzle",SORT_OPTION:"bambusy_kprofiles_sort"};function OKe(){const{t}=Rn(),{showToast:e}=Hn(),{hasPermission:n}=Ci(),[r,i]=_.useState(null),[a,o]=_.useState(()=>localStorage.getItem(f1.NOZZLE_DIAMETER)||"0.4"),[l,c]=_.useState(null),[u,d]=_.useState(!1),[f,p]=_.useState(null),[m,x]=_.useState(""),[b,v]=_.useState("all"),[y,S]=_.useState("all"),[k,T]=_.useState(()=>localStorage.getItem(f1.SORT_OPTION)||"name"),[M,C]=_.useState(!1),[E,R]=_.useState(new Set),[A,D]=_.useState(!1),[I,F]=_.useState(!1),z=_.useCallback(U=>`${U.slot_id}_${U.extruder_id}`,[]);_.useEffect(()=>{localStorage.setItem(f1.NOZZLE_DIAMETER,a)},[a]),_.useEffect(()=>{localStorage.setItem(f1.SORT_OPTION,k)},[k]);const{data:P,isLoading:$}=ot({queryKey:["printers"],queryFn:ce.getPrinters}),{data:X,isLoading:V,isFetching:Q,error:Z,refetch:se}=ot({queryKey:["kprofiles",r,a],queryFn:async()=>{console.log("[KProfiles] Fetching profiles for printer",r,"nozzle",a);const U=await ce.getKProfiles(r,a);return console.log("[KProfiles] Received profiles:",U?.profiles?.length||0,"profiles"),U},enabled:!!r,retry:!1,staleTime:0,gcTime:0,refetchOnMount:"always"}),{data:H}=ot({queryKey:["kprofiles",r,"0.4"],queryFn:()=>ce.getKProfiles(r,"0.4"),enabled:!!r,staleTime:6e4}),{data:K,refetch:re}=ot({queryKey:["kprofile-notes",r],queryFn:()=>ce.getKProfileNotes(r),enabled:!!r,staleTime:3e4}),ne=Z?.message?.includes("not connected");_.useEffect(()=>{if(!r&&P&&P.length>0){const U=P.find(he=>he.is_active);U&&i(U.id)}},[r,P]),_.useEffect(()=>{if(r){const U=setTimeout(()=>{se()},150);return()=>clearTimeout(U)}},[r,a]);const be=P?.filter(U=>U.is_active)||[],me=ei.useMemo(()=>X?.profiles?X.profiles.filter(he=>{const Me=m.toLowerCase(),ge=!Me||he.name.toLowerCase().includes(Me)||he.filament_id.toLowerCase().includes(Me),B=b==="all"||b==="left"&&he.extruder_id===1||b==="right"&&he.extruder_id===0,O=y==="all"||y==="hf"&&he.nozzle_id.startsWith("HH")||y==="s"&&he.nozzle_id.startsWith("HS");return ge&&B&&O}).sort((he,Me)=>{switch(k){case"k_value":return parseFloat(he.k_value)-parseFloat(Me.k_value);case"filament":return uR(he.name).localeCompare(uR(Me.name));case"name":default:return he.name.localeCompare(Me.name)}}):[],[X?.profiles,m,b,y,k]),de=P?.find(U=>U.id===r),Ce=de?.nozzle_count===2;_.useEffect(()=>{const U=he=>{he.target instanceof HTMLInputElement||he.target instanceof HTMLTextAreaElement||he.target instanceof HTMLSelectElement||l||u||f||(he.key==="r"||he.key==="R"?(he.preventDefault(),se()):he.key==="n"||he.key==="N"?(he.preventDefault(),d(!0)):he.key==="Escape"&&M&&(he.preventDefault(),C(!1),R(new Set)))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[l,u,f,M,se]);const ie=_.useCallback(()=>{if(!X?.profiles||X.profiles.length===0){e(t("kProfiles.toast.noProfilesToExport"),"error");return}const U={version:1,exported_at:new Date().toISOString(),printer:de?.name||"Unknown",nozzle_diameter:a,profiles:X.profiles.map(B=>({name:B.name,k_value:B.k_value,filament_id:B.filament_id,nozzle_id:B.nozzle_id,nozzle_diameter:B.nozzle_diameter,extruder_id:B.extruder_id}))},he=new Blob([JSON.stringify(U,null,2)],{type:"application/json"}),Me=URL.createObjectURL(he),ge=document.createElement("a");ge.href=Me,ge.download=`kprofiles_${de?.name||"printer"}_${a}mm_${new Date().toISOString().split("T")[0]}.json`,document.body.appendChild(ge),ge.click(),document.body.removeChild(ge),URL.revokeObjectURL(Me),e(t("kProfiles.toast.exportedProfiles",{count:X.profiles.length}))},[X?.profiles,de,a,e,t]),ke=_.useCallback(()=>{const U=document.createElement("input");U.type="file",U.accept=".json",U.onchange=async he=>{const Me=he.target.files?.[0];if(Me)try{const ge=await Me.text(),B=JSON.parse(ge);if(!B.profiles||!Array.isArray(B.profiles)){e(t("kProfiles.toast.invalidFileFormat"),"error");return}let O=0;for(const ee of B.profiles)if(!(!ee.name||!ee.k_value||!ee.filament_id))try{await ce.setKProfile(r,{name:ee.name,k_value:parseFloat(ee.k_value).toFixed(6),filament_id:ee.filament_id,nozzle_id:ee.nozzle_id||`HH00-${a}`,nozzle_diameter:ee.nozzle_diameter||a,extruder_id:ee.extruder_id??0,slot_id:0}),O++,await new Promise(le=>setTimeout(le,500))}catch(le){console.error("Failed to import profile:",ee.name,le)}e(t("kProfiles.toast.importedProfiles",{count:O,total:B.profiles.length})),se()}catch(ge){console.error("Import error:",ge),e(t("kProfiles.toast.failedToParseImport"),"error")}},U.click()},[r,a,e,se,t]),Oe=_.useCallback(U=>{R(he=>{const Me=new Set(he);return Me.has(U)?Me.delete(U):Me.add(U),Me})},[]),pe=_.useCallback(()=>{R(new Set(me.map(U=>z(U))))},[me,z]),We=_.useCallback(()=>{E.size!==0&&D(!0)},[E.size]),G=_.useCallback(async()=>{const U=me.filter(Me=>E.has(z(Me)));F(!0);let he=0;for(const Me of U)try{await ce.deleteKProfile(r,{slot_id:Me.slot_id,extruder_id:Me.extruder_id,nozzle_id:Me.nozzle_id,nozzle_diameter:Me.nozzle_diameter,filament_id:Me.filament_id,setting_id:Me.setting_id}),he++,await new Promise(ge=>setTimeout(ge,300))}catch(ge){console.error("Failed to delete profile:",Me.name,ge)}e(t("kProfiles.toast.profilesDeleted",{count:he})),F(!1),D(!1),C(!1),R(new Set),se()},[r,E,me,e,se,z,t]),Y=_.useCallback(U=>{const he=[];return U.setting_id&&he.push(U.setting_id),he.push(`slot_${U.slot_id}_${U.filament_id}_${U.extruder_id}`),he.push(`name_${U.name}_${U.filament_id}`),he},[]),ue=_.useCallback(async(U,he)=>{if(r)try{await ce.setKProfileNote(r,U,he),re()}catch(Me){console.error("Failed to save note:",Me),e(t("kProfiles.toast.failedToSaveNote"),"error")}},[r,re,e,t]),q=_.useCallback(U=>{if(!K?.notes)return{note:"",key:null};const he=Y(U);for(const Me of he)if(K.notes[Me])return{note:K.notes[Me],key:Me};return{note:"",key:null}},[K,Y]),te=_.useCallback(U=>q(U).note,[q]);return $?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):!P||P.length===0?s.jsx(St,{children:s.jsxs(Nt,{className:"py-12 text-center",children:[s.jsx($i,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noPrintersConfigured")}),s.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.addPrinterInSettings")})]})}):be.length===0?s.jsx(St,{children:s.jsxs(Nt,{className:"py-12 text-center",children:[s.jsx(Ur,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noActivePrinters")}),s.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.enablePrinterConnection")})]})}):s.jsxs(s.Fragment,{children:[Q&&!V&&s.jsxs("div",{className:"fixed inset-0 bg-black/50 flex flex-col items-center justify-center z-40",children:[s.jsx(ft,{className:"w-10 h-10 text-bambu-green animate-spin mb-3"}),s.jsx("p",{className:"text-white font-medium",children:t("kProfiles.loadingProfiles")})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 mb-6",children:[s.jsxs("div",{className:"flex-1 min-w-48",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("kProfiles.printer")}),s.jsx("select",{value:r||"",onChange:U=>i(parseInt(U.target.value)),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:be.map(U=>s.jsx("option",{value:U.id,children:U.name},U.id))})]}),s.jsxs("div",{className:"w-32",children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:t("kProfiles.nozzle")}),s.jsxs("select",{value:a,onChange:U=>o(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"0.2",children:"0.2mm"}),s.jsx("option",{value:"0.4",children:"0.4mm"}),s.jsx("option",{value:"0.6",children:"0.6mm"}),s.jsx("option",{value:"0.8",children:"0.8mm"})]})]}),s.jsxs("div",{className:"flex items-end gap-2",children:[s.jsxs(Te,{variant:"secondary",onClick:()=>se(),disabled:Q||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noRead"),children:[s.jsx(Dr,{className:`w-4 h-4 ${Q?"animate-spin":""}`}),t("kProfiles.refresh")]}),s.jsxs(Te,{onClick:()=>d(!0),disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noCreate"),children:[s.jsx(fr,{className:"w-4 h-4"}),t("kProfiles.addProfile")]})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-4 mb-4",children:[s.jsxs("div",{className:"flex-1 min-w-48 relative",children:[s.jsx(ya,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:m,onChange:U=>x(U.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"})]}),Ce&&s.jsx("div",{className:"w-36",children:s.jsxs("select",{value:b,onChange:U=>v(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"all",children:t("kProfiles.allExtruders")}),s.jsx("option",{value:"left",children:t("kProfiles.leftOnly")}),s.jsx("option",{value:"right",children:t("kProfiles.rightOnly")})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:y,onChange:U=>S(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"all",children:t("kProfiles.allFlow")}),s.jsx("option",{value:"hf",children:t("kProfiles.hfOnly")}),s.jsx("option",{value:"s",children:t("kProfiles.sOnly")})]})}),s.jsx("div",{className:"w-32",children:s.jsxs("select",{value:k,onChange:U=>T(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none",children:[s.jsx("option",{value:"name",children:t("kProfiles.sortName")}),s.jsx("option",{value:"k_value",children:t("kProfiles.sortKValue")}),s.jsx("option",{value:"filament",children:t("kProfiles.sortFilament")})]})})]}),s.jsxs("div",{className:"flex flex-wrap gap-2 mb-6",children:[s.jsxs(Te,{variant:"secondary",onClick:ie,disabled:!X?.profiles?.length||!n("kprofiles:read"),title:n("kprofiles:read")?void 0:t("kProfiles.permission.noExport"),children:[s.jsx(wi,{className:"w-4 h-4"}),t("kProfiles.export")]}),s.jsxs(Te,{variant:"secondary",onClick:ke,disabled:!n("kprofiles:create"),title:n("kprofiles:create")?void 0:t("kProfiles.permission.noImport"),children:[s.jsx(za,{className:"w-4 h-4"}),t("kProfiles.import")]}),s.jsx("div",{className:"flex-1"}),M?s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"secondary",onClick:pe,children:[s.jsx(ol,{className:"w-4 h-4"}),t("kProfiles.selectAll")]}),s.jsxs(Te,{variant:"secondary",onClick:We,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:[s.jsx(an,{className:"w-4 h-4"}),t("kProfiles.delete")," (",E.size,")"]}),s.jsxs(Te,{variant:"secondary",onClick:()=>{C(!1),R(new Set)},children:[s.jsx(Rt,{className:"w-4 h-4"}),t("common.cancel")]})]}):s.jsxs(Te,{variant:"secondary",onClick:()=>C(!0),disabled:!me.length||!n("kprofiles:delete"),title:n("kprofiles:delete")?void 0:t("kProfiles.permission.noDelete"),children:[s.jsx(ol,{className:"w-4 h-4"}),t("kProfiles.select")]})]}),V?s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):ne?s.jsx(St,{children:s.jsxs(Nt,{className:"py-12 text-center",children:[s.jsx(sm,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.printerOffline")}),s.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.printerOfflineDesc")}),s.jsxs(Te,{variant:"secondary",onClick:()=>se(),children:[s.jsx(Dr,{className:"w-4 h-4"}),t("common.refresh")]})]})}):me.length>0?Ce?s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:t("kProfiles.leftExtruder")}),s.jsx("div",{className:"space-y-1",children:me.filter(U=>U.extruder_id===1).map(U=>s.jsx($P,{profile:U,onEdit:()=>c(U),onCopy:()=>p(U),selectionMode:M,isSelected:E.has(z(U)),onToggleSelect:()=>Oe(z(U)),note:te(U)},z(U)))})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-bambu-gray mb-2 px-1",children:t("kProfiles.rightExtruder")}),s.jsx("div",{className:"space-y-1",children:me.filter(U=>U.extruder_id===0).map(U=>s.jsx($P,{profile:U,onEdit:()=>c(U),onCopy:()=>p(U),selectionMode:M,isSelected:E.has(z(U)),onToggleSelect:()=>Oe(z(U)),note:te(U)},z(U)))})]})]}):s.jsx("div",{className:"space-y-1",children:me.map(U=>s.jsx($P,{profile:U,onEdit:()=>c(U),onCopy:()=>p(U),selectionMode:M,isSelected:E.has(z(U)),onToggleSelect:()=>Oe(z(U)),note:te(U)},z(U)))}):m||b!=="all"||y!=="all"?s.jsx(St,{children:s.jsxs(Nt,{className:"py-12 text-center",children:[s.jsx(ya,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noMatchingProfiles")}),s.jsx("p",{className:"text-bambu-gray",children:t("kProfiles.noMatchingProfilesDesc")})]})}):s.jsx(St,{children:s.jsxs(Nt,{className:"py-12 text-center",children:[s.jsx(hM,{className:"w-12 h-12 text-bambu-gray mx-auto mb-4"}),s.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:t("kProfiles.noKProfiles")}),s.jsx("p",{className:"text-bambu-gray mb-4",children:t("kProfiles.noKProfilesDesc",{diameter:a})}),s.jsxs(Te,{onClick:()=>d(!0),children:[s.jsx(fr,{className:"w-4 h-4"}),t("kProfiles.createFirstProfile")]})]})}),l&&r&&(()=>{const{note:U,key:he}=q(l);return s.jsx(VP,{profile:l,printerId:r,nozzleDiameter:a,existingProfiles:H?.profiles||X?.profiles,isDualNozzle:Ce,initialNote:U,initialNoteKey:he,onSaveNote:ue,hasPermission:n,onClose:()=>{console.log("[KProfiles] Edit modal onClose - refetching profiles..."),c(null),se()},onSave:()=>{c(null),se()}})})(),u&&r&&s.jsx(VP,{printerId:r,nozzleDiameter:a,existingProfiles:H?.profiles||X?.profiles,isDualNozzle:Ce,onSaveNote:ue,hasPermission:n,onClose:()=>{d(!1),se()},onSave:()=>{d(!1),se()}}),f&&r&&s.jsx(VP,{printerId:r,nozzleDiameter:a,existingProfiles:H?.profiles||X?.profiles,isDualNozzle:Ce,onSaveNote:ue,hasPermission:n,profile:{...f,slot_id:0,name:`${f.name} (Copy)`},onClose:()=>{p(null),se()},onSave:()=>{p(null),se()}}),A&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(St,{className:"w-full max-w-sm",children:s.jsxs(Nt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/20 flex items-center justify-center",children:s.jsx(an,{className:"w-5 h-5 text-red-500"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:t("kProfiles.bulkDelete.title")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("kProfiles.bulkDelete.cannotUndo")})]})]}),s.jsx("p",{className:"text-bambu-gray mb-6",children:t("kProfiles.bulkDelete.message",{count:E.size})}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(Te,{variant:"secondary",onClick:()=>D(!1),disabled:I,className:"flex-1",children:t("common.cancel")}),s.jsxs(Te,{onClick:G,disabled:I,className:"flex-1 bg-red-500 hover:bg-red-600 text-white",children:[I?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(an,{className:"w-4 h-4"}),t("common.delete")]})]})]})})})]})}function cF(t,e){const n=`${t} ${e||""}`,r=n.match(/@?\s*(?:BBL\s+)?(?:Bambu\s+Lab\s+)?([XPAH][1-9][A-Z]?(?:\s*(?:Carbon|mini))?|H2D)/i),i=r?r[1].trim():null,a=n.match(/(\d+\.?\d*)\s*(?:mm\s*)?nozzle|nozzle\s*(\d+\.?\d*)/i),o=a?(a[1]||a[2])+"mm":null,l=n.match(/(\d+\.?\d*)mm\s*(?:Standard|Fine|Extra Fine|Draft|Quality)?/i),c=l?l[1]+"mm":null,u=n.match(/\b(PLA|PETG|ABS|ASA|TPU|PC|PA|PVA|HIPS|PP|PET(?:-?CF)?|PA(?:-?CF)?|PLA(?:-?CF)?)\b/i),d=u?u[1].toUpperCase():null;return{printer:i,nozzle:o,layerHeight:c,filamentType:d}}function Ry(t){return/^(P[FPM]US|PF\d|PP\d)/.test(t)}function LKe(t,e){const n=Ui(t);if(!n)return"";const i=new Date().getTime()-n.getTime(),a=Math.floor(i/6e4),o=Math.floor(i/36e5),l=Math.floor(i/864e5);return a<1?e("profiles.time.justNow"):a<60?e("profiles.time.minsAgo",{count:a}):o<24?e("profiles.time.hoursAgo",{count:o}):l<7?e("profiles.time.daysAgo",{count:l}):n.toLocaleDateString()}function FKe({onSuccess:t,t:e}){const{showToast:n}=Hn(),[r,i]=_.useState("email"),[a,o]=_.useState(""),[l,c]=_.useState(""),[u,d]=_.useState(""),[f,p]=_.useState(""),[m,x]=_.useState("global"),[b,v]=_.useState(null),[y,S]=_.useState(null),k=mt({mutationFn:()=>ce.cloudLogin(a,l,m),onSuccess:R=>{R.success?(n(e("profiles.login.toast.loggedIn")),t()):R.needs_verification?(v(R.verification_type||"email"),S(R.tfa_key||null),R.verification_type==="totp"?n(e("profiles.login.toast.enterTotp")):n(e("profiles.login.toast.codeSent")),i("code")):n(R.message,"error")},onError:R=>n(R.message,"error")}),T=mt({mutationFn:()=>ce.cloudVerify(a,u,y||void 0),onSuccess:R=>{R.success?(n(e("profiles.login.toast.loggedIn")),t()):n(R.message,"error")},onError:R=>n(R.message,"error")}),M=mt({mutationFn:()=>ce.cloudSetToken(f),onSuccess:()=>{n(e("profiles.login.toast.tokenSet")),t()},onError:R=>n(R.message,"error")}),C=R=>{R.preventDefault(),r==="email"?k.mutate():r==="code"?T.mutate():r==="token"&&M.mutate()},E=k.isPending||T.isPending||M.isPending;return s.jsx(St,{className:"max-w-md mx-auto",children:s.jsxs(Nt,{children:[s.jsxs("div",{className:"text-center mb-6",children:[s.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-xl bg-bambu-green/20 mb-3",children:s.jsx(lM,{className:"w-6 h-6 text-bambu-green"})}),s.jsx("h2",{className:"text-xl font-semibold text-white",children:e("profiles.login.title")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:e("profiles.login.subtitle")})]}),s.jsxs("form",{onSubmit:C,className:"space-y-4",children:[r==="email"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.email")}),s.jsx("input",{type:"email",value:a,onChange:R=>o(R.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.password")}),s.jsx("input",{type:"password",value:l,onChange:R=>c(R.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.region")}),s.jsxs("select",{value:m,onChange:R=>x(R.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:[s.jsx("option",{value:"global",children:e("profiles.login.regionGlobal")}),s.jsx("option",{value:"china",children:e("profiles.login.regionChina")})]})]})]}),r==="code"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e(b==="totp"?"profiles.login.totpCode":"profiles.login.verificationCode")}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:b==="totp"?e("profiles.login.enterTotpHint"):e("profiles.login.checkEmail",{email:a})}),s.jsx("input",{type:"text",value:u,onChange:R=>d(R.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"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:e("profiles.login.accessToken")}),s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:e("profiles.login.accessTokenHint")}),s.jsx("textarea",{value:f,onChange:R=>p(R.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})]}),s.jsxs("div",{className:"flex gap-2",children:[r==="code"&&s.jsx(Te,{type:"button",variant:"secondary",onClick:()=>i("email"),className:"flex-1",children:e("profiles.login.back")}),s.jsxs(Te,{type:"submit",disabled:E,className:"flex-1",children:[E?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(Rz,{className:"w-4 h-4"}),e(r==="email"?"profiles.login.loginButton":r==="code"?"profiles.login.verifyButton":"profiles.login.setTokenButton")]})]}),r==="email"&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("button",{type:"button",onClick:()=>i("token"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[s.jsx($o,{className:"w-4 h-4"}),e("profiles.login.useToken")]})}),r==="token"&&s.jsx("div",{className:"pt-4 border-t border-bambu-dark-tertiary",children:s.jsxs("button",{type:"button",onClick:()=>i("email"),className:"text-sm text-bambu-gray hover:text-white flex items-center gap-2 transition-colors",children:[s.jsx(Rz,{className:"w-4 h-4"}),e("profiles.login.useEmail")]})})]})]})})}function rg({label:t,value:e,options:n,onChange:r}){const[i,a]=_.useState(!1),o=n.find(l=>l.value===e);return s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>a(!i),className:"flex items-center gap-2 px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-sm text-white hover:border-bambu-gray-dark transition-colors",children:[s.jsxs("span",{className:"text-bambu-gray",children:[t,":"]}),s.jsx("span",{children:o?.label||"All"}),s.jsx(Kr,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?"rotate-180":""}`})]}),i&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>a(!1)}),s.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=>s.jsxs("button",{onClick:()=>{r(l.value),a(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-bambu-dark-tertiary transition-colors ${e===l.value?"text-bambu-green":"text-white"}`,children:[s.jsx("span",{children:l.label}),l.count!==void 0&&s.jsx("span",{className:"text-bambu-gray text-xs",children:l.count})]},l.value))})]})]})}function IKe(){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?s.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:s.jsx(Ig,{className:"w-5 h-5"})}):null}function GP({setting:t,onClick:e,onDuplicate:n,compareMode:r,isCompareSelected:i,compareIndex:a,compareDisabled:o,t:l}){const c=cF(t.name),u=Ry(t.setting_id);return s.jsxs("div",{className:"flex items-center gap-2 group",children:[s.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:s.jsxs("div",{className:"flex items-center gap-2",children:[i&&a!==void 0&&s.jsx("span",{className:"flex-shrink-0 w-5 h-5 rounded-full bg-blue-500 text-white text-xs flex items-center justify-center font-medium",children:a+1}),!i&&u&&s.jsx("span",{className:"flex-shrink-0 w-1.5 h-1.5 rounded-full bg-bambu-green",title:l("profiles.presets.myPreset")}),s.jsx("span",{className:"text-white text-sm truncate flex-1",title:t.name,children:t.name}),c.filamentType&&t.type==="filament"&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.filamentType}),c.layerHeight&&t.type==="process"&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.layerHeight}),c.printer&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:c.printer})]})}),s.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:s.jsx(Fl,{className:"w-4 h-4"})})]})}function dR(t,e=0){const n=" ".repeat(e);if(t===null)return"null";if(t===void 0)return"undefined";if(typeof t=="string"){if(t.includes("\\n")||t.includes(`
- `)){const i=t.replace(/\\n/g,`
- `).replace(/\\"/g,'"').replace(/\\t/g," ").split(`
- `);if(i.length>1)return`"""
- `+i.map(a=>n+" "+a).join(`
- `)+`
- `+n+'"""'}return JSON.stringify(t)}if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t))return t.length===0?"[]":`[
- `+t.map(i=>n+" "+dR(i,e+1)).join(`,
- `)+`
- `+n+"]";if(typeof t=="object"){const r=Object.entries(t);return r.length===0?"{}":`{
- `+r.map(([a,o])=>n+" "+JSON.stringify(a)+": "+dR(o,e+1)).join(`,
- `)+`
- `+n+"}"}return String(t)}function UKe({setting:t,onClose:e,onDeleted:n,onDuplicate:r,onEdit:i,hasPermission:a,t:o}){const{showToast:l}=Hn(),c=sn(),[u,d]=_.useState(!1),{data:f,isLoading:p}=ot({queryKey:["cloudSettingDetail",t.setting_id],queryFn:()=>ce.getCloudSettingDetail(t.setting_id)}),m=mt({mutationFn:()=>ce.deleteCloudSetting(t.setting_id),onSuccess:()=>{l(o("profiles.presets.toast.deleted")),c.invalidateQueries({queryKey:["cloudSettings"]}),n()},onError:v=>l(v.message,"error")}),x=Ry(t.setting_id),b=cF(t.name,f?.setting?.inherits);return s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:s.jsx(St,{className:"w-full max-w-3xl max-h-[90vh] flex flex-col overflow-hidden",children:s.jsxs(Nt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h2",{className:"text-xl font-semibold text-white truncate",children:t.name}),x&&s.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")})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 text-sm text-bambu-gray",children:[s.jsx("span",{className:"capitalize",children:o(`profiles.presets.types.${t.type}`)}),b.printer&&s.jsxs(s.Fragment,{children:[s.jsx("span",{children:"•"}),s.jsx("span",{children:b.printer})]})]})]}),s.jsx("button",{onClick:e,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto p-4",children:p?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):f?s.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:dR(f)}):s.jsx("div",{className:"text-center py-16 text-bambu-gray",children:o("profiles.presets.failedToLoadDetails")})}),u?s.jsxs("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary bg-red-500/5",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 text-red-400",children:[s.jsx(Sn,{className:"w-5 h-5"}),s.jsx("span",{className:"font-medium",children:o("profiles.presets.deleteConfirm")})]}),s.jsx("p",{className:"text-sm text-bambu-gray mb-4",children:o("profiles.presets.deleteWarning",{name:t.name})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:()=>d(!1),disabled:m.isPending,className:"flex-1",children:o("common.cancel")}),s.jsxs(Te,{variant:"danger",onClick:()=>m.mutate(),disabled:m.isPending,className:"flex-1",children:[m.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):s.jsx(an,{className:"w-4 h-4"}),o("common.delete")]})]})]}):s.jsx("div",{className:"flex-shrink-0 p-4 border-t border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:e,className:"flex-1",children:o("common.close")}),s.jsxs(Te,{variant:"secondary",onClick:r,disabled:!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.presets.noDuplicatePermission"),children:[s.jsx(Fl,{className:"w-4 h-4"}),o("profiles.presets.duplicate")]}),x&&s.jsxs(s.Fragment,{children:[s.jsxs(Te,{variant:"secondary",onClick:i,disabled:p||!f||!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.presets.noEditPermission"),children:[s.jsx(Zi,{className:"w-4 h-4"}),o("common.edit")]}),s.jsx(Te,{variant:"danger",onClick:()=>d(!0),disabled:!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.presets.noDeletePermission"),children:s.jsx(an,{className:"w-4 h-4"})})]})]})})]})})})}function zre(){try{const t=localStorage.getItem("bambusy_preset_templates");return t?JSON.parse(t):[]}catch{return[]}}function Bre(t){localStorage.setItem("bambusy_preset_templates",JSON.stringify(t))}function zKe({onClose:t,onApply:e,t:n}){const{showToast:r}=Hn(),[i,a]=_.useState(zre),[o,l]=_.useState("all"),[c,u]=_.useState(null),[d,f]=_.useState(""),[p,m]=_.useState(""),[x,b]=_.useState("{}"),[v,y]=_.useState(null),[S,k]=_.useState(null),T=o==="all"?i:i.filter(z=>z.type===o),M=z=>{a(z),Bre(z)},C=z=>{const P=i.filter($=>$.id!==z);M(P),k(null),r(n("profiles.templates.toast.deleted"))},E=z=>{u(z.id),f(z.name),m(z.description),b(JSON.stringify(z.settings,null,2)),y(null)},R=()=>{if(!(!c||!d.trim()))try{const z=JSON.parse(x),P=i.map($=>$.id===c?{...$,name:d.trim(),description:p.trim(),settings:z}:$);M(P),u(null),r(n("profiles.templates.toast.updated"))}catch(z){y(z.message)}},A=()=>{u(null),f(""),m(""),b("{}"),y(null)},D=z=>{const P=i.map($=>$.id===z?{...$,showInModal:!$.showInModal}:$);M(P)},I={filament:{label:n("profiles.presets.types.filament"),icon:TR,color:"text-amber-400"},print:{label:n("profiles.presets.types.process"),icon:bh,color:"text-blue-400"},printer:{label:n("profiles.presets.types.printer"),icon:Ur,color:"text-purple-400"}},F=S?i.find(z=>z.id===S):null;return _.useEffect(()=>{const z=P=>{P.key==="Escape"&&(S?k(null):c?A():t())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[S,c,t]),s.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:[F&&s.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-60",children:s.jsx(St,{className:"w-full max-w-md",children:s.jsxs(Nt,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[s.jsx("div",{className:"p-2 bg-red-500/20 rounded-lg",children:s.jsx(Sn,{className:"w-6 h-6 text-red-400"})}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-lg font-semibold text-white",children:n("profiles.templates.deleteTitle")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n("profiles.templates.deleteWarning")})]})]}),s.jsx("p",{className:"text-white mb-6",children:n("profiles.templates.deleteConfirm",{name:F.name})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:()=>k(null),className:"flex-1",children:n("common.cancel")}),s.jsxs(Te,{onClick:()=>C(S),className:"flex-1 bg-red-500 hover:bg-red-600",children:[s.jsx(an,{className:"w-4 h-4"}),n("common.delete")]})]})]})})}),s.jsx(St,{className:"w-full max-w-2xl max-h-[80vh] flex flex-col",children:s.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(W0,{className:"w-5 h-5 text-amber-400"}),n("profiles.templates.title")]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex items-center gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:n("profiles.templates.typeFilter")}),["all","filament","print","printer"].map(z=>s.jsx("button",{onClick:()=>l(z),className:`px-3 py-1 text-sm rounded-lg transition-colors ${o===z?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:z==="all"?n("common.all"):I[z].label},z))]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:T.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(W0,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:n("profiles.templates.noTemplates")}),s.jsx("p",{className:"text-sm mt-1",children:n("profiles.templates.createFirst")})]}):s.jsx("div",{className:"space-y-2",children:T.map(z=>{const P=I[z.type],$=P.icon;return c===z.id?s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg border border-bambu-green",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-3",children:[s.jsx("input",{type:"text",value:d,onChange:X=>f(X.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}),s.jsx("input",{type:"text",value:p,onChange:X=>m(X.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"})]}),s.jsxs("div",{className:"mb-3",children:[s.jsx("label",{className:"text-xs text-bambu-gray mb-1 block",children:n("profiles.templates.settingsJson")}),s.jsx("textarea",{value:x,onChange:X=>{b(X.target.value),y(null)},rows:6,className:`w-full px-3 py-2 bg-bambu-dark-secondary border rounded text-white text-sm font-mono focus:outline-none ${v?"border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`}),v&&s.jsx("p",{className:"text-xs text-red-400 mt-1",children:v})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{size:"sm",onClick:R,disabled:!d.trim(),children:[s.jsx(hs,{className:"w-4 h-4"}),"Save"]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:A,children:"Cancel"})]})]},z.id):s.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:[s.jsx($,{className:`w-5 h-5 ${P.color} flex-shrink-0`}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:z.name}),s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:z.description})]}),s.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(z.settings).length})}),s.jsx("button",{onClick:()=>D(z.id),className:`p-1 transition-colors ${z.showInModal?"text-bambu-green hover:text-bambu-green/70":"text-bambu-gray hover:text-white"}`,title:z.showInModal?n("profiles.templates.shownInModals"):n("profiles.templates.hiddenInModals"),children:z.showInModal?s.jsx(mc,{className:"w-4 h-4"}):s.jsx(cM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>e(z),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")}),s.jsx("button",{onClick:()=>E(z),className:"p-1 text-bambu-gray hover:text-white",title:n("common.edit"),children:s.jsx(Zi,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>k(z.id),className:"p-1 text-bambu-gray hover:text-red-400",title:n("common.delete"),children:s.jsx(an,{className:"w-4 h-4"})})]},z.id)})})})]})})]})}function Hre({onClose:t,leftPreset:e,rightPreset:n,leftLabel:r,rightLabel:i,t:a}){const[o,l]=_.useState("changes"),[c,u]=_.useState(""),d=_.useMemo(()=>{const x=new Set([...Object.keys(e),...Object.keys(n)]),b=[];for(const v of x){if(v==="inherits"||v==="version")continue;const y=e[v],S=n[v],k=v in e,T=v in n;let M;!k&&T?M="added":k&&!T?M="removed":JSON.stringify(y)!==JSON.stringify(S)?M="changed":M="same",b.push({key:v,left:y,right:S,status:M})}return b.sort((v,y)=>{const S={changed:0,added:1,removed:2,same:3};return S[v.status]!==S[y.status]?S[v.status]-S[y.status]:v.key.localeCompare(y.key)})},[e,n]),f=_.useMemo(()=>{let x=[...d];if(o==="changes"&&(x=x.filter(b=>b.status!=="same")),c){const b=c.toLowerCase();x=x.filter(v=>v.key.toLowerCase().includes(b)||String(v.left).toLowerCase().includes(b)||String(v.right).toLowerCase().includes(b))}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 b=String(x);if(b.includes("\\n")||b.length>100){const v=b.split("\\n").length;if(v>1)return`[${v} lines of G-code/script]`;if(b.length>100)return b.substring(0,100)+"…"}return b};return _.useEffect(()=>{const x=b=>{b.key==="Escape"&&t()};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[t]),s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsx(St,{className:"w-full max-w-4xl max-h-[85vh] flex flex-col overflow-hidden",children:s.jsxs(Nt,{className:"p-0 flex flex-col min-h-0 flex-1",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(_g,{className:"w-5 h-5 text-blue-400"}),a("profiles.diff.title")]}),s.jsx("button",{onClick:t,className:"text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"flex-shrink-0 grid grid-cols-2 gap-4 p-4 border-b border-bambu-dark-tertiary bg-bambu-dark",children:[s.jsxs("div",{className:"text-center",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:a("profiles.diff.left")}),s.jsx("p",{className:"text-white font-medium truncate",children:r})]}),s.jsxs("div",{className:"text-center",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:a("profiles.diff.right")}),s.jsx("p",{className:"text-white font-medium truncate",children:i})]})]}),s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[s.jsxs("span",{className:"flex items-center gap-1 text-green-400",children:[s.jsx(fr,{className:"w-3.5 h-3.5"}),p.added," ",a("profiles.diff.added")]}),s.jsxs("span",{className:"flex items-center gap-1 text-red-400",children:[s.jsx(xj,{className:"w-3.5 h-3.5"}),p.removed," ",a("profiles.diff.removed")]}),s.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[s.jsx(uj,{className:"w-3.5 h-3.5"}),p.changed," ",a("profiles.diff.changed")]}),s.jsxs("span",{className:"flex items-center gap-1 text-bambu-gray",children:[s.jsx(eT,{className:"w-3.5 h-3.5"}),p.same," ",a("profiles.diff.same")]})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"relative",children:[s.jsx(ya,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:c,onChange:x=>u(x.target.value),placeholder:a("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&&s.jsxs("div",{className:"flex rounded overflow-hidden border border-bambu-dark-tertiary",children:[s.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:a("profiles.diff.changes")}),s.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:a("common.all")})]})]})]}),s.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:f.length===0?s.jsxs("div",{className:"text-center py-12 text-bambu-gray",children:[s.jsx(eT,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),s.jsx("p",{children:a(o==="changes"?"profiles.diff.noDifferences":"profiles.diff.noFieldsMatch")})]}):s.jsxs("table",{className:"w-full",children:[s.jsx("thead",{className:"sticky top-0 bg-bambu-dark-secondary",children:s.jsxs("tr",{className:"text-sm text-bambu-gray border-b border-bambu-dark-tertiary",children:[s.jsx("th",{className:"text-left p-3 w-1/3",children:a("profiles.diff.field")}),s.jsx("th",{className:"text-left p-3 w-1/3",children:r}),s.jsx("th",{className:"text-left p-3 w-1/3",children:i})]})}),s.jsx("tbody",{children:f.map(x=>{const b={added:"bg-green-500/10",removed:"bg-red-500/10",changed:"bg-amber-500/10",same:""}[x.status],v={added:s.jsx(fr,{className:"w-3.5 h-3.5 text-green-400"}),removed:s.jsx(xj,{className:"w-3.5 h-3.5 text-red-400"}),changed:s.jsx(uj,{className:"w-3.5 h-3.5 text-amber-400"}),same:s.jsx(eT,{className:"w-3.5 h-3.5 text-bambu-gray-dark"})}[x.status];return s.jsxs("tr",{className:`border-b border-bambu-dark-tertiary ${b}`,children:[s.jsx("td",{className:"p-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[v,s.jsx("span",{className:"text-sm text-white font-mono",children:x.key})]})}),s.jsx("td",{className:"p-3",children:s.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)})}),s.jsx("td",{className:"p-3",children:s.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 BKe({onClose:t,initialData:e,allPresets:n,t:r}){const{showToast:i}=Hn(),a=sn(),o=!!e?.setting_id,[l,c]=_.useState("common"),[u,d]=_.useState(e?.type||"filament"),[f,p]=_.useState(e?.name?o?e.name:`${e.name} (Copy)`:""),[m,x]=_.useState(e?.base_id||""),[b,v]=_.useState(""),[y,S]=_.useState(e?.setting||{inherits:""}),[k,T]=_.useState(JSON.stringify(e?.setting||{inherits:""},null,2)),[M,C]=_.useState(null),[E,R]=_.useState(""),[A,D]=_.useState(!1),[I,F]=_.useState(""),[z,P]=_.useState(!1),[$,X]=_.useState(zre),[V,Q]=_.useState(!1),[Z,se]=_.useState(""),[H,K]=_.useState(""),[re,ne]=_.useState(!0),[be,me]=_.useState(null),[de,Ce]=_.useState(!1),ie=_.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer})[u]||[],[n,u]),ke=_.useMemo(()=>ie.filter(Pe=>Ry(Pe.setting_id)),[ie]),{data:Oe}=ot({queryKey:["cloudFields",u],queryFn:()=>ce.getCloudFields(u==="print"?"process":u),staleTime:1e3*60*60}),{data:pe}=ot({queryKey:["allPresetDetails",u,ke.map(Pe=>Pe.setting_id).join(",")],queryFn:async()=>{const Pe={};for(let we=0;we<ke.length;we+=5){const Xe=ke.slice(we,we+5);(await Promise.all(Xe.map(async rt=>{try{const Ee=await ce.getCloudSettingDetail(rt.setting_id);return{id:rt.setting_id,detail:Ee}}catch{return null}}))).forEach(rt=>{rt&&(Pe[rt.id]=rt.detail)})}return Pe},enabled:ke.length>0,staleTime:1e3*60*10}),{data:We,isLoading:G}=ot({queryKey:["cloudSettingDetail",m],queryFn:()=>ce.getCloudSettingDetail(m),enabled:!!m});_.useEffect(()=>{l!=="json"&&T(JSON.stringify(y,null,2))},[y,l]);const Y=_.useMemo(()=>({filament:n.filament,print:n.process,printer:n.printer}[u]||[]).filter(ze=>!Ry(ze.setting_id)).sort((ze,we)=>ze.name.localeCompare(we.name)),[n,u]);_.useEffect(()=>{if(!m)return;const Pe=Y.find(ze=>ze.setting_id===m);Pe&&(v(Pe.name),o||(S({inherits:Pe.name}),T(JSON.stringify({inherits:Pe.name},null,2))))},[m,Y,o]);const ue=_.useMemo(()=>{const Pe=Oe?.fields||[],ze=new Set(Pe.map(rt=>rt.key)),we=new Set,Xe=new Set(["inherits","updated_time","compatible_printers","compatible_prints"]);pe&&Object.values(pe).forEach(rt=>{rt?.setting&&Object.keys(rt.setting).forEach(Ee=>{!ze.has(Ee)&&!Xe.has(Ee)&&we.add(Ee)})}),Object.keys(y).forEach(rt=>{!ze.has(rt)&&!Xe.has(rt)&&we.add(rt)});const Ne=Array.from(we).sort().map(rt=>({key:rt,label:rt.replace(/_/g," ").replace(/\b\w/g,Ee=>Ee.toUpperCase()),type:"text",category:"discovered",description:r("profiles.presets.discoveredFromPresets")}));return[...Pe,...Ne]},[Oe,pe,y,r]),q=ue.filter(Pe=>Pe.label.toLowerCase().includes(E.toLowerCase())||Pe.key.toLowerCase().includes(E.toLowerCase())),te=()=>{if(I.trim()){const Pe=I.trim().toLowerCase().replace(/\s+/g,"_");U(Pe,""),F(""),P(!1),i(r("profiles.presets.toast.fieldAdded",{key:Pe}))}},U=(Pe,ze)=>{S(we=>{const Xe={...we};return ze===""||ze===void 0?delete Xe[Pe]:Xe[Pe]=ze,Xe})},he=Pe=>{S(ze=>({...ze,...Pe.settings})),me(Pe.name),i(r("profiles.templates.toast.applied"))},Me=()=>{if(!Z.trim())return;const Pe={...y};if(delete Pe.inherits,Object.keys(Pe).length===0){i(r("profiles.presets.noOverridesToSave"),"error");return}const ze={id:Date.now().toString(),name:Z.trim(),description:H.trim()||r("profiles.presets.customTemplate"),type:u,settings:Pe,showInModal:re},we=[...$,ze];X(we),Bre(we),Q(!1),se(""),K(""),ne(!0),i(r("profiles.templates.toast.created"))},ge=_.useMemo(()=>$.filter(Pe=>Pe.type===u&&Pe.showInModal),[u,$]),B=Pe=>{T(Pe);try{const ze=JSON.parse(Pe);S(ze),C(null)}catch(ze){C(ze.message)}},O=Pe=>{Pe.preventDefault(),D(!1);const ze=Pe.dataTransfer.files[0];if(ze&&ze.name.endsWith(".json")){const we=new FileReader;we.onload=Xe=>{try{const Ne=Xe.target?.result,rt=JSON.parse(Ne),Ee=rt.setting||rt;S(Ke=>({...Ke,...Ee})),T(JSON.stringify({...y,...Ee},null,2)),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJsonFile"),"error")}},we.readAsText(ze)}},ee=mt({mutationFn:()=>{const Pe={...y},ze=u==="filament"?"filament_settings_id":u==="print"?"print_settings_id":"printer_settings_id";Pe[ze]=`"${f}"`;const we={type:u,name:f,base_id:m,setting:Pe};return ce.createCloudSetting(we)},onSuccess:async()=>{i(r("profiles.presets.toast.created")),await a.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:Pe=>i(Pe.message,"error")}),le=mt({mutationFn:()=>{if(!e?.setting_id)throw new Error(r("profiles.presets.noSettingId"));return ce.updateCloudSetting(e.setting_id,{name:f,setting:y})},onSuccess:async()=>{i(r("profiles.presets.toast.updated")),a.removeQueries({queryKey:["cloudSettingDetail"]}),await a.refetchQueries({queryKey:["cloudSettings"]}),t()},onError:Pe=>i(Pe.message,"error")}),_e=o?le:ee,ve=We?.setting?.inherits,ae=ve?Y.find(Pe=>Pe.name===ve):void 0,{data:Fe}=ot({queryKey:["cloudSettingDetail",ae?.setting_id],queryFn:()=>ce.getCloudSettingDetail(ae.setting_id),enabled:!!ae?.setting_id}),Be=_.useMemo(()=>{const Pe=Fe?.setting||{},ze=We?.setting||{},we=m&&pe?.[m]?.setting?pe[m].setting:{};return{...Pe,...ze,...we}},[m,We,Fe,pe]),$e=Pe=>{if(Pe==null)return"";if(Array.isArray(Pe)){const ze=[...new Set(Pe.map(we=>String(we)))];return ze.length===1?ze[0]:Pe.join(", ")}return String(Pe)},He=Pe=>{const ze=y[Pe.key],we=Be[Pe.key],Xe=$e(we),Ne=G?r("common.loading"):Xe||"",rt="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=ze==="1"||ze===void 0&&we==="1";return s.jsx("button",{type:"button",onClick:()=>U(Pe.key,ze==="1"?"0":"1"),className:`w-8 h-5 rounded-full transition-colors ${Ee?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,children:s.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"?s.jsxs("select",{value:ze||"",onChange:Ee=>U(Pe.key,Ee.target.value),className:rt,children:[s.jsx("option",{value:"",children:Ne}),Pe.options?.map(Ee=>s.jsx("option",{value:Ee.value,children:Ee.label},Ee.value))]}):s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:Pe.type==="number"?"number":"text",value:ze!==void 0?String(ze):"",onChange:Ee=>U(Pe.key,Ee.target.value),step:Pe.step,min:Pe.min,max:Pe.max,placeholder:Ne,className:rt}),Pe.unit&&s.jsx("span",{className:"text-xs text-bambu-gray whitespace-nowrap",children:Pe.unit})]})},xe=_.useMemo(()=>We?.setting?We.setting:{},[We]);return s.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:[de&&m&&s.jsx(Hre,{onClose:()=>Ce(!1),leftPreset:xe,rightPreset:y,leftLabel:r("profiles.presets.baseLabel",{name:b||m}),rightLabel:r("profiles.presets.currentLabel",{name:f||r("profiles.presets.newPreset")}),t:r}),s.jsx(St,{className:"w-full max-w-6xl max-h-[90vh] flex flex-col",children:s.jsxs(Nt,{className:"p-0 flex flex-col h-full",children:[s.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:r(o?"profiles.presets.editPreset":e?"profiles.presets.duplicatePreset":"profiles.presets.createNewPreset")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("profiles.presets.customizeSettings")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[m&&s.jsxs("button",{onClick:()=>Ce(!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:[s.jsx(_g,{className:"w-4 h-4"}),r("profiles.presets.compare")]}),s.jsx("button",{onClick:t,className:"p-2 text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary rounded-lg transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]})]}),A&&s.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:s.jsxs("div",{className:"text-center",children:[s.jsx(za,{className:"w-12 h-12 text-bambu-green mx-auto mb-2"}),s.jsx("p",{className:"text-bambu-green font-medium",children:r("profiles.presets.dropJsonToImport")})]})}),s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("common.type")}),s.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:[s.jsx("option",{value:"filament",children:r("profiles.presets.types.filament")}),s.jsx("option",{value:"print",children:r("profiles.presets.types.process")}),s.jsx("option",{value:"printer",children:r("profiles.presets.types.printer")})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.basePreset")}),s.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:[s.jsx("option",{value:"",children:r("profiles.presets.selectBasePreset")}),Y.map(Pe=>s.jsx("option",{value:Pe.setting_id,children:Pe.name},Pe.setting_id))]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-bambu-gray mb-1",children:r("profiles.presets.presetName")}),s.jsx("input",{type:"text",value:f,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")})]})]}),b&&s.jsx("div",{className:"text-xs text-bambu-gray",children:s.jsxs("p",{className:"flex items-center gap-1",children:[s.jsx(Na,{className:"w-3 h-3 text-bambu-green"}),r("profiles.presets.inheritsFrom")," ",s.jsx("span",{className:"text-white",children:b}),G&&s.jsx(ft,{className:"w-3 h-3 animate-spin ml-1"})]})})]}),s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary",children:[s.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:[s.jsx(Oz,{className:"w-4 h-4"}),r("profiles.presets.tabs.common")]}),s.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:[s.jsx(pM,{className:"w-4 h-4"}),r("profiles.presets.tabs.allFields")]}),s.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:[s.jsx(yW,{className:"w-4 h-4"}),"JSON",M&&s.jsx($i,{className:"w-3 h-3 text-red-400"})]}),s.jsx("div",{className:"flex-1"}),s.jsxs("button",{onClick:()=>{const Pe={name:f,type:u,base_id:m,setting:y},ze=new Blob([JSON.stringify(Pe,null,2)],{type:"application/json"}),we=URL.createObjectURL(ze),Xe=document.createElement("a");Xe.href=we,Xe.download=`${f||"preset"}.json`,document.body.appendChild(Xe),Xe.click(),document.body.removeChild(Xe),URL.revokeObjectURL(we),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:[s.jsx(wi,{className:"w-4 h-4"}),r("common.download")]}),s.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:[s.jsx(za,{className:"w-4 h-4"}),r("common.upload")]}),s.jsx("input",{id:"file-import",type:"file",accept:".json",className:"hidden",onChange:Pe=>{const ze=Pe.target.files?.[0];if(ze){const we=new FileReader;we.onload=Xe=>{try{const Ne=JSON.parse(Xe.target?.result),rt=Ne.setting||Ne;S(Ee=>({...Ee,...rt})),i(r("profiles.presets.fileImported"))}catch{i(r("profiles.presets.invalidJson"),"error")}},we.readAsText(ze)}}})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-4",children:[l==="common"&&s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h3",{className:"text-sm font-medium text-white flex items-center gap-2",children:[s.jsx(W0,{className:"w-4 h-4 text-amber-400"}),r("profiles.templates.title")]}),Object.keys(y).filter(Pe=>Pe!=="inherits").length>0&&s.jsxs("button",{onClick:()=>Q(!V),className:"text-xs text-bambu-gray hover:text-white flex items-center gap-1 transition-colors",children:[s.jsx(hs,{className:"w-3 h-3"}),r("profiles.presets.saveAsTemplate")]})]}),V&&s.jsxs("div",{className:"mb-3 p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[s.jsx("input",{type:"text",value:Z,onChange:Pe=>se(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}),s.jsx("input",{type:"text",value:H,onChange:Pe=>K(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"})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{size:"sm",onClick:Me,disabled:!Z.trim(),children:[s.jsx(hs,{className:"w-3 h-3"}),r("common.save")]}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>Q(!1),children:r("common.cancel")})]}),s.jsxs("button",{onClick:()=>ne(!re),className:`flex items-center gap-1.5 text-xs transition-colors ${re?"text-bambu-green":"text-bambu-gray hover:text-white"}`,children:[re?s.jsx(mc,{className:"w-3.5 h-3.5"}):s.jsx(cM,{className:"w-3.5 h-3.5"}),r(re?"profiles.templates.shownInModals":"profiles.templates.hiddenInModals")]})]})]}),be&&s.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:[s.jsx(Na,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("span",{className:"text-sm text-bambu-green",children:[r("profiles.presets.templateApplied")," ",s.jsx("span",{className:"font-medium",children:be})]}),s.jsx("button",{onClick:()=>me(null),className:"ml-auto text-bambu-green/70 hover:text-bambu-green",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[ge.map(Pe=>s.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:[s.jsx("p",{className:"text-sm font-medium text-white",children:Pe.name}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:Pe.description})]},Pe.id)),ge.length===0&&s.jsx("p",{className:"col-span-3 text-center text-bambu-gray text-sm py-4",children:r("profiles.presets.noTemplatesSelected")})]}),s.jsx("p",{className:"text-xs text-bambu-gray-dark mt-2 text-center",children:r("profiles.presets.manageTemplatesHint")})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.commonSettings")}),s.jsx("div",{className:"grid grid-cols-2 gap-x-6 gap-y-3",children:ue.slice(0,10).map(Pe=>s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("label",{className:"text-sm text-bambu-gray flex-shrink-0",children:Pe.label}),s.jsx("div",{className:"w-48",children:He(Pe)})]},Pe.key))})]}),Object.keys(y).length>1&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:r("profiles.presets.currentOverrides")}),s.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(y).filter(([Pe])=>Pe!=="inherits").map(([Pe,ze])=>s.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(ze).slice(0,20),s.jsx("button",{onClick:()=>U(Pe,void 0),className:"hover:text-white",children:s.jsx(Rt,{className:"w-3 h-3"})})]},Pe))})]})]}),l==="fields"&&s.jsxs("div",{className:"grid grid-cols-2 gap-6",style:{height:"400px"},children:[s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.availableFields")}),s.jsx("span",{className:"text-xs text-bambu-gray",children:pe?r("profiles.templates.fieldsCount",{count:ue.length}):r("common.loading")})]}),s.jsxs("div",{className:"relative mb-3 flex-shrink-0",children:[s.jsx(ya,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",value:E,onChange:Pe=>R(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"})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-1 pr-2 min-h-0",children:[q.filter(Pe=>!(Pe.key in y)).map(Pe=>{const ze=Be[Pe.key],we=$e(ze);return s.jsxs("div",{onClick:()=>{S(Xe=>({...Xe,[Pe.key]:we||""}))},className:"flex items-center justify-between gap-2 p-2 rounded-lg hover:bg-bambu-dark-tertiary transition-colors cursor-pointer group",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"text-sm text-white truncate",children:Pe.label}),s.jsx("p",{className:"text-xs text-bambu-gray-dark truncate",children:Pe.key})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[we&&s.jsxs("span",{className:"text-xs text-bambu-gray bg-bambu-dark px-2 py-0.5 rounded max-w-32 truncate",title:we,children:[we.slice(0,20),we.length>20?"...":""]}),s.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:s.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 y)).length===0&&s.jsx("p",{className:"text-center text-bambu-gray py-4 text-sm",children:r(E?"profiles.presets.noMatchingFields":"profiles.presets.allFieldsAdded")})]}),s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:z?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:I,onChange:Pe=>F(Pe.target.value),onKeyDown:Pe=>Pe.key==="Enter"&&te(),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}),s.jsx(Te,{size:"sm",onClick:te,disabled:!I.trim(),children:s.jsx(fr,{className:"w-4 h-4"})}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>{P(!1),F("")},children:s.jsx(Rt,{className:"w-4 h-4"})})]}):s.jsxs("button",{onClick:()=>P(!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:[s.jsx(fr,{className:"w-4 h-4"}),r("profiles.presets.addCustomField")]})})]}),s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3 flex-shrink-0",children:[s.jsx("h3",{className:"text-sm font-medium text-white",children:r("profiles.presets.yourOverrides")}),s.jsx("span",{className:"text-xs text-bambu-gray",children:r("profiles.templates.fieldsCount",{count:Object.keys(y).filter(Pe=>Pe!=="inherits").length})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto space-y-2 pr-2 min-h-0",children:[Object.entries(y).filter(([Pe])=>Pe!=="inherits").map(([Pe,ze])=>{const we=ue.find(Xe=>Xe.key===Pe);return s.jsxs("div",{className:"p-3 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-white",children:we?.label||Pe}),s.jsx("p",{className:"text-xs text-bambu-gray-dark",children:Pe})]}),s.jsx("button",{onClick:()=>U(Pe,void 0),className:"p-1 text-bambu-gray hover:text-red-400 transition-colors",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),we?He(we):s.jsx("input",{type:"text",value:String(ze),onChange:Xe=>U(Pe,Xe.target.value),className:"w-full px-3 py-1.5 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:border-bambu-green focus:outline-none"})]},Pe)}),Object.keys(y).filter(Pe=>Pe!=="inherits").length===0&&s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(Oz,{className:"w-8 h-8 mx-auto mb-2 opacity-50"}),s.jsx("p",{className:"text-sm",children:r("profiles.presets.noOverridesYet")}),s.jsx("p",{className:"text-xs mt-1",children:r("profiles.presets.clickFieldsToAdd")})]})]}),Object.keys(y).filter(Pe=>Pe!=="inherits").length>0&&s.jsx("div",{className:"pt-3 mt-3 border-t border-bambu-dark-tertiary flex-shrink-0",children:s.jsxs("button",{onClick:()=>{Q(!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:[s.jsx(hs,{className:"w-4 h-4"}),r("profiles.presets.saveAsTemplate")]})})]})]}),l==="json"&&s.jsxs("div",{className:"space-y-2",children:[M&&s.jsxs("div",{className:"flex items-center gap-2 text-red-400 text-sm",children:[s.jsx($i,{className:"w-4 h-4"}),M]}),s.jsx("textarea",{value:k,onChange:Pe=>B(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 ${M?"border-red-500 focus:border-red-500":"border-bambu-dark-tertiary focus:border-bambu-green"}`,spellCheck:!1}),s.jsx("p",{className:"text-xs text-bambu-gray",children:r("profiles.presets.jsonTip")})]})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:t,className:"flex-1",children:r("common.cancel")}),s.jsxs(Te,{onClick:()=>_e.mutate(),disabled:_e.isPending||!f.trim()||!o&&!m||!!M,className:"flex-1",children:[_e.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):o?s.jsx(hs,{className:"w-4 h-4"}):s.jsx(fr,{className:"w-4 h-4"}),r(o?"common.save":e?"common.duplicate":"common.create")]})]})]})})]})}function HKe({settings:t,lastSyncTime:e,onRefresh:n,isRefreshing:r,printers:i,hasPermission:a,t:o}){const[l,c]=_.useState(""),[u,d]=_.useState("all"),[f,p]=_.useState("all"),[m,x]=_.useState("all"),[b,v]=_.useState("all"),[y,S]=_.useState("all"),[k,T]=_.useState("all"),[M,C]=_.useState(null),[E,R]=_.useState(!1),[A,D]=_.useState(!1),[I,F]=_.useState(null),[z,P]=_.useState(null),[$,X]=_.useState(null),[V,Q]=_.useState(!1),[Z,se]=_.useState([null,null]),[H,K]=_.useState(!1),[re,ne]=_.useState(null),be=sn(),me=_.useMemo(()=>[...t.filament.map(te=>({...te,type:"filament"})),...t.printer.map(te=>({...te,type:"printer"})),...t.process.map(te=>({...te,type:"process"}))].map(te=>({...te,meta:cF(te.name)})),[t]),de=_.useMemo(()=>{const q=new Set,te=new Set,U=new Set;return me.forEach(he=>{he.meta.nozzle&&q.add(he.meta.nozzle),he.meta.filamentType&&te.add(he.meta.filamentType),he.meta.layerHeight&&U.add(he.meta.layerHeight)}),{printers:i.map(he=>({id:he.id.toString(),name:he.name})),nozzles:Array.from(q).sort((he,Me)=>parseFloat(he)-parseFloat(Me)),filaments:Array.from(te).sort(),layerHeights:Array.from(U).sort((he,Me)=>parseFloat(he)-parseFloat(Me))}},[me,i]),Ce=_.useMemo(()=>m==="all"?null:i.find(te=>te.id.toString()===m)?.model||null,[m,i]),ie=_.useMemo(()=>me.filter(q=>u==="all"||q.type===u).filter(q=>{if(f==="all")return!0;const te=Ry(q.setting_id);return f==="custom"?te:!te}).filter(q=>{if(m==="all"||!Ce)return!0;const te=q.meta.printer?.toLowerCase()||"",U=Ce.toLowerCase();return te.includes(U)||U.includes(te)}).filter(q=>b==="all"||q.meta.nozzle===b).filter(q=>y==="all"||q.meta.filamentType===y).filter(q=>k==="all"||q.meta.layerHeight===k).filter(q=>l===""||q.name.toLowerCase().includes(l.toLowerCase())).sort((q,te)=>q.name.localeCompare(te.name)),[me,u,f,m,Ce,b,y,k,l]),ke=q=>{if(V){const te=Z[0]?.setting_id===q.setting_id,U=Z[1]?.setting_id===q.setting_id;if(te)se([Z[1],null]);else if(U)se([Z[0],null]);else if(!Z[0])se([q,null]);else if(Z[1]){if(Z[0].type!==q.type)return;se([Z[0],q])}else{if(Z[0].type!==q.type)return;se([Z[0],q])}}else C(q)},Oe=q=>{if(Z[0]?.setting_id===q.setting_id)return 0;if(Z[1]?.setting_id===q.setting_id)return 1},pe=async q=>{try{const te=await ce.getCloudSettingDetail(q.setting_id),U=q.type==="process"?"print":q.type;F({type:U,name:q.name,base_id:te.base_id||"GFSA00",setting:te.setting||{}}),C(null)}catch(te){console.error("Failed to fetch preset details for duplication:",te)}},We=async q=>{try{be.removeQueries({queryKey:["cloudSettingDetail",q.setting_id]});const te=await ce.getCloudSettingDetail(q.setting_id),U=q.type==="process"?"print":q.type;P({type:U,name:q.name,base_id:te.base_id||"GFSA00",setting:te.setting||{},setting_id:q.setting_id}),C(null)}catch(te){console.error("Failed to fetch preset details for editing:",te)}},G=()=>{d("all"),p("all"),x("all"),v("all"),S("all"),T("all"),c("")},Y=u!=="all"||f!=="all"||m!=="all"||b!=="all"||y!=="all"||k!=="all"||l!=="",ue=t.filament.length+t.printer.length+t.process.length;return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-4 mb-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ya,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.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"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{variant:V?"primary":"secondary",onClick:()=>{V?(Q(!1),se([null,null])):Q(!0)},children:[s.jsx(_g,{className:"w-4 h-4"}),o(V?"common.cancel":"profiles.presets.compare")]}),s.jsxs(Te,{variant:"secondary",onClick:()=>D(!0),disabled:!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.cloudView.noTemplatesPermission"),children:[s.jsx(W0,{className:"w-4 h-4"}),o("profiles.cloudView.templates")]}),s.jsxs(Te,{variant:"secondary",onClick:n,disabled:r||!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.cloudView.noRefreshPermission"),children:[s.jsx(Dr,{className:`w-4 h-4 ${r?"animate-spin":""}`}),o("profiles.cloudView.refresh")]}),s.jsxs(Te,{onClick:()=>R(!0),disabled:!a("cloud:auth"),title:a("cloud:auth")?void 0:o("profiles.cloudView.noCreatePermission"),children:[s.jsx(fr,{className:"w-4 h-4"}),o("profiles.cloudView.newPreset")]})]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(dM,{className:"w-4 h-4 text-bambu-gray"}),s.jsx(rg,{label:o("profiles.cloudView.filters.type"),value:u,options:[{value:"all",label:o("profiles.cloudView.filters.all"),count:ue},{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)}),s.jsx(rg,{label:o("profiles.cloudView.filters.owner"),value:f,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)}),de.printers.length>0&&s.jsx(rg,{label:o("profiles.cloudView.filters.printer"),value:m,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...de.printers.map(q=>({value:q.id,label:q.name}))],onChange:x}),de.nozzles.length>0&&s.jsx(rg,{label:o("profiles.cloudView.filters.nozzle"),value:b,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...de.nozzles.map(q=>({value:q,label:q}))],onChange:v}),de.filaments.length>0&&(u==="all"||u==="filament")&&s.jsx(rg,{label:o("profiles.cloudView.filters.filament"),value:y,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...de.filaments.map(q=>({value:q,label:q}))],onChange:S}),de.layerHeights.length>0&&(u==="all"||u==="process")&&s.jsx(rg,{label:o("profiles.cloudView.filters.layer"),value:k,options:[{value:"all",label:o("profiles.cloudView.filters.all")},...de.layerHeights.map(q=>({value:q,label:q}))],onChange:T}),Y&&s.jsx("button",{onClick:G,className:"px-3 py-2 text-sm text-bambu-gray hover:text-white transition-colors",children:o("profiles.cloudView.clearFilters")})]})]}),V&&s.jsx("div",{className:"mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(_g,{className:"w-5 h-5 text-blue-400"}),s.jsx("span",{className:"text-white font-medium",children:o("profiles.cloudView.compareMode")}),s.jsx("span",{className:"text-bambu-gray",children:Z[0]?o("profiles.cloudView.selectAnotherPreset",{type:Z[0].type}):o("profiles.cloudView.clickTwoPresets")})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Z[0]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Z[0]?Z[0].name:o("profiles.cloudView.selectFirst")}),s.jsx(uj,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:`px-2 py-1 text-sm rounded truncate max-w-[200px] ${Z[1]?"bg-blue-500/30 text-blue-700 dark:text-blue-300":"bg-bambu-dark text-bambu-gray"}`,children:Z[1]?Z[1].name:o("profiles.cloudView.selectSecond")})]}),Z[0]&&Z[1]&&s.jsxs(Te,{size:"sm",onClick:async()=>{try{const[q,te]=await Promise.all([ce.getCloudSettingDetail(Z[0].setting_id),ce.getCloudSettingDetail(Z[1].setting_id)]);ne([q.setting||{},te.setting||{}]),K(!0)}catch{}},children:[s.jsx(_g,{className:"w-4 h-4"}),o("profiles.cloudView.compareNow")]})]})]})}),s.jsxs("div",{className:"flex flex-wrap items-center gap-4 mb-4 text-sm text-bambu-gray",children:[e&&s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(tr,{className:"w-3 h-3"}),o("profiles.cloudView.lastSynced")," ",LKe(e.toISOString(),o)]}),s.jsx("span",{children:o("profiles.cloudView.showingCount",{showing:ie.length,total:ue})}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-bambu-green"}),s.jsxs("span",{children:["= ",o("profiles.presets.myPreset")]})]})]}),ie.length===0?s.jsxs("div",{className:"text-center py-16",children:[s.jsx(sl,{className:"w-12 h-12 text-bambu-gray-dark mx-auto mb-4"}),s.jsx("p",{className:"text-bambu-gray",children:o("profiles.cloudView.noPresetsFound")}),Y&&s.jsx("button",{onClick:G,className:"mt-2 text-sm text-bambu-green hover:text-bambu-green-light",children:o("profiles.cloudView.clearFilters")})]}):s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(TR,{className:"w-4 h-4 text-amber-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.filament")}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ie.filter(q=>q.type==="filament").length,")"]})]}),s.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=>s.jsx(GP,{setting:q,onClick:()=>ke(q),onDuplicate:()=>pe(q),compareMode:V,isCompareSelected:Oe(q)!==void 0,compareIndex:Oe(q),compareDisabled:V&&!!Z[0]&&Z[0].type!==q.type,t:o},q.setting_id)),ie.filter(q=>q.type==="filament").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noFilamentPresets")})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(bh,{className:"w-4 h-4 text-blue-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.process")}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ie.filter(q=>q.type==="process").length,")"]})]}),s.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=>s.jsx(GP,{setting:q,onClick:()=>ke(q),onDuplicate:()=>pe(q),compareMode:V,isCompareSelected:Oe(q)!==void 0,compareIndex:Oe(q),compareDisabled:V&&!!Z[0]&&Z[0].type!==q.type,t:o},q.setting_id)),ie.filter(q=>q.type==="process").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noProcessPresets")})]})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 px-1",children:[s.jsx(Ur,{className:"w-4 h-4 text-purple-400"}),s.jsx("h3",{className:"text-sm font-medium text-bambu-gray",children:o("profiles.cloudView.columns.printer")}),s.jsxs("span",{className:"text-xs text-bambu-gray-dark",children:["(",ie.filter(q=>q.type==="printer").length,")"]})]}),s.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=>s.jsx(GP,{setting:q,onClick:()=>ke(q),onDuplicate:()=>pe(q),compareMode:V,isCompareSelected:Oe(q)!==void 0,compareIndex:Oe(q),compareDisabled:V&&!!Z[0]&&Z[0].type!==q.type,t:o},q.setting_id)),ie.filter(q=>q.type==="printer").length===0&&s.jsx("p",{className:"text-xs text-bambu-gray-dark px-3 py-2",children:o("profiles.cloudView.noPrinterPresets")})]})]})]}),M&&s.jsx(UKe,{setting:M,onClose:()=>C(null),onDeleted:()=>C(null),onDuplicate:()=>pe(M),onEdit:()=>We(M),hasPermission:a,t:o}),(E||I||z||$)&&s.jsx(BKe,{onClose:()=>{R(!1),F(null),P(null),X(null)},initialData:z||I||($?{type:$.type,name:"",base_id:"",setting:$.setting}:void 0),allPresets:t,t:o}),A&&s.jsx(zKe,{onClose:()=>D(!1),onApply:q=>{X({type:q.type,setting:q.settings}),D(!1)},t:o}),H&&re&&Z[0]&&Z[1]&&s.jsx(Hre,{onClose:()=>{K(!1),ne(null)},leftPreset:re[0],rightPreset:re[1],leftLabel:Z[0].name,rightLabel:Z[1].name,t:o})]})}function $Ke(){const{t}=Rn(),e=sn(),{showToast:n}=Hn(),{hasPermission:r}=Ci(),[i,a]=_.useState("cloud"),[o,l]=_.useState(),{data:c,isLoading:u}=ot({queryKey:["cloudStatus"],queryFn:ce.getCloudStatus}),{data:d=[]}=ot({queryKey:["printers"],queryFn:ce.getPrinters}),{data:f,isLoading:p,refetch:m,dataUpdatedAt:x}=ot({queryKey:["cloudSettings"],queryFn:()=>ce.getCloudSettings(),enabled:!!c?.is_authenticated,retry:!1,staleTime:1e3*60*5});_.useEffect(()=>{x&&l(new Date(x))},[x]);const b=mt({mutationFn:ce.cloudLogout,onSuccess:()=>{e.invalidateQueries({queryKey:["cloudStatus"]}),e.removeQueries({queryKey:["cloudSettings"]}),n(t("profiles.toast.loggedOut"))}}),v=()=>{e.invalidateQueries({queryKey:["cloudStatus"]})};return u?s.jsx("div",{className:"p-4 md:p-8 flex items-center justify-center min-h-[400px]",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):s.jsxs("div",{className:"p-6 lg:p-8",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("profiles.title")}),s.jsx("p",{className:"text-bambu-gray",children:t("profiles.subtitle")})]}),s.jsxs("div",{className:"flex border-b border-bambu-dark-tertiary mb-6",children:[s.jsxs("button",{onClick:()=>a("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:[s.jsx(lM,{className:"w-4 h-4"}),t("profiles.tabs.cloud")]}),s.jsxs("button",{onClick:()=>a("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:[s.jsx(hM,{className:"w-4 h-4"}),t("profiles.tabs.kprofiles")]})]}),i==="cloud"&&s.jsxs(s.Fragment,{children:[c?.is_authenticated&&s.jsxs("div",{className:"flex items-center justify-between p-3 mb-6 bg-bambu-dark rounded-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green animate-pulse"}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[t("profiles.connectedAs")," ",s.jsx("span",{className:"text-white",children:c.email})]})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>b.mutate(),disabled:b.isPending||!r("cloud:auth"),title:r("cloud:auth")?void 0:t("profiles.noLogoutPermission"),children:[s.jsx(gj,{className:"w-4 h-4"}),t("profiles.logout")]})]}),c?.is_authenticated?p?s.jsx("div",{className:"flex items-center justify-center py-16",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):f?s.jsx(HKe,{settings:f,lastSyncTime:o,onRefresh:()=>m(),isRefreshing:p,printers:d,hasPermission:r,t}):s.jsxs("div",{className:"text-center py-16",children:[s.jsx("p",{className:"text-bambu-gray mb-4",children:t("profiles.failedToLoad")}),s.jsx(Te,{onClick:()=>m(),children:t("profiles.retry")})]}):s.jsx(FKe,{onSuccess:v,t})]}),i==="kprofiles"&&s.jsx(OKe,{}),s.jsx(IKe,{})]})}const g0={Droplet:TR,Flame:Iue,Ruler:xhe,Sparkles:W0,Square:ll,Cable:Pce,Wrench:om,Calendar:ti,Timer:bu,Cog:due,Fan:vW,Zap:vh,Wind:RW,Thermometer:bM,Layers:sl,Box:oo,Target:PW,RefreshCw:Dr,Settings:xM,Filter:dM,CircleDot:Yce};function z0(t){return t&&g0[t]||om}function ig(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 qP(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 VKe(t,e){const n=(e||"").toUpperCase().replace(/[- ]/g,""),r=n.includes("X1"),i=n.includes("P1"),a=n.includes("A1MINI"),o=n.includes("A1")&&!a,l=n.includes("H2D"),c=n.includes("H2C"),u=n.includes("H2S"),d=l||c||u,f=n.includes("P2S");switch(t){case"Lubricate Linear Rails":return r?"https://wiki.bambulab.com/en/x1/maintenance/basic-maintenance":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":a?"https://wiki.bambulab.com/en/a1-mini/maintenance/lubricate-y-axis":o?"https://wiki.bambulab.com/en/a1/maintenance/lubricate-y-axis":d?"https://wiki.bambulab.com/en/h2/maintenance/x-axis-lubrication":f?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/general/lead-screws-lubrication";case"Clean Nozzle/Hotend":return r||i?"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog":a||o?"https://wiki.bambulab.com/en/a1-mini/troubleshooting/nozzle-clog":d?"https://wiki.bambulab.com/en/h2/maintenance/nozzl-cold-pull-maintenance-and-cleaning":f?"https://wiki.bambulab.com/en/p2s/maintenance/cold-pull-maintenance-hotend":"https://wiki.bambulab.com/en/x1/troubleshooting/nozzle-clog";case"Check Belt Tension":return r?"https://wiki.bambulab.com/en/x1/maintenance/belt-tension":i?"https://wiki.bambulab.com/en/p1/maintenance/p1p-maintenance":a?"https://wiki.bambulab.com/en/a1-mini/maintenance/belt_tension":o?"https://wiki.bambulab.com/en/a1/maintenance/belt_tension":l?"https://wiki.bambulab.com/en/h2/maintenance/belt-tension":c?"https://wiki.bambulab.com/en/h2c/maintenance/belt-tension":u?"https://wiki.bambulab.com/en/h2s/maintenance/belt-tension":f?"https://wiki.bambulab.com/en/p2s/maintenance/belt-tension":"https://wiki.bambulab.com/en/x1/maintenance/belt-tension";case"Clean Carbon Rods":return r||i?"https://wiki.bambulab.com/en/general/carbon-rods-clearance":a||o||d||f?null:"https://wiki.bambulab.com/en/general/carbon-rods-clearance";case"Clean Build Plate":return"https://wiki.bambulab.com/en/filament-acc/acc/pei-plate-clean-guide";case"Check PTFE Tube":return r||i?"https://wiki.bambulab.com/en/x1/maintenance/replace-ptfe-tube":a||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 GKe({item:t,onPerform:e,onToggle:n,hasPermission:r,t:i}){const a=z0(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",f=()=>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:ig(Math.abs(m),"days",i)}):t.is_warning?i("maintenance.dueIn",{duration:ig(m,"days",i)}):i("maintenance.timeLeft",{duration:ig(m,"days",i)})}else return t.is_due?i("maintenance.overdueBy",{duration:ig(Math.abs(t.hours_until_due),"hours",i)}):t.is_warning?i("maintenance.dueIn",{duration:ig(t.hours_until_due,"hours",i)}):i("maintenance.timeLeft",{duration:ig(t.hours_until_due,"hours",i)})};return s.jsx("div",{className:`rounded-xl border p-4 transition-all ${f()}`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.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:[s.jsx(a,{className:`w-5 h-5 ${u()}`}),t.enabled&&(t.is_due||t.is_warning)&&s.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`})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:`font-medium truncate ${t.enabled?"text-white":"text-bambu-gray"}`,children:t.maintenance_type_name}),o==="days"&&s.jsx("span",{title:i("maintenance.timeBasedInterval"),children:s.jsx(ti,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"})}),(()=>{const m=t.maintenance_type_wiki_url||VKe(t.maintenance_type_name,t.printer_model);return m?s.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:s.jsx(Xr,{className:"w-3.5 h-3.5"})}):null})()]}),s.jsx("div",{className:"mt-2 mb-1.5",children:s.jsx("div",{className:"w-full h-1.5 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${d()}`,style:{width:`${c}%`}})})}),s.jsxs("div",{className:`text-xs flex items-center gap-1 ${u()}`,children:[t.is_due&&s.jsx(Sn,{className:"w-3 h-3"}),t.is_warning&&!t.is_due&&s.jsx(tr,{className:"w-3 h-3"}),!t.is_due&&!t.is_warning&&t.enabled&&s.jsx(Na,{className:"w-3 h-3"}),p()]})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx("span",{title:r("maintenance:update")?void 0:i("maintenance.noPermissionUpdate"),children:s.jsx(Ln,{checked:t.enabled,onChange:m=>n(t.id,m),disabled:!r("maintenance:update")})}),s.jsxs(Te,{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:[s.jsx(Rh,{className:"w-3.5 h-3.5"}),i("common.reset")]})]})]})})}function qKe({overview:t,onPerform:e,onToggle:n,onSetHours:r,hasPermission:i,t:a}){const[o,l]=_.useState(!0),[c,u]=_.useState(!1),[d,f]=_.useState(t.total_print_hours.toFixed(1)),p=[...t.maintenance_items].sort((b,v)=>b.is_due&&!v.is_due?-1:!b.is_due&&v.is_due?1:b.is_warning&&!v.is_warning?-1:!b.is_warning&&v.is_warning?1:b.maintenance_type_id-v.maintenance_type_id),m=p.find(b=>b.enabled&&(b.is_due||b.is_warning)),x=()=>{const b=parseFloat(d);!isNaN(b)&&b>=0&&(r(t.printer_id,b),u(!1))};return s.jsxs(St,{className:"overflow-hidden",children:[s.jsxs("div",{className:"p-5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("h2",{className:"text-xl font-semibold text-white",children:t.printer_name}),s.jsxs("div",{className:"flex items-center gap-2",children:[t.due_count>0&&s.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:[s.jsx(Sn,{className:"w-3 h-3"}),a("maintenance.overdueCount",{count:t.due_count})]}),t.warning_count>0&&s.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:[s.jsx(tr,{className:"w-3 h-3"}),a("maintenance.dueSoonCount",{count:t.warning_count})]}),t.due_count===0&&t.warning_count===0&&s.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:[s.jsx(Na,{className:"w-3 h-3"}),a("maintenance.allGood")]})]})]}),s.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?s.jsx(xh,{className:"w-4 h-4"}):s.jsx(Kr,{className:"w-4 h-4"}),a(o?"common.collapse":"common.expand")]})]}),s.jsxs("div",{className:"flex items-center gap-6 mt-4",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 bg-bambu-dark/50 rounded-lg",children:s.jsx(bu,{className:"w-4 h-4 text-bambu-gray"})}),c?s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"number",value:d,onChange:b=>f(b.target.value),onKeyDown:b=>{b.key==="Enter"&&x(),b.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}),s.jsx("span",{className:"text-xs text-bambu-gray",children:a("common.hours")}),s.jsx(Te,{size:"sm",onClick:x,children:a("common.save")}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>u(!1),children:a("common.cancel")})]}):s.jsxs("button",{onClick:()=>{i("maintenance:update")&&(f(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:a("maintenance.noPermissionEditHours"),children:[s.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)," ",a("common.hours"),s.jsx(rm,{className:`w-3 h-3 text-bambu-gray ${i("maintenance:update")?"group-hover:text-bambu-green":""}`})]}),s.jsx("div",{className:"text-xs text-bambu-gray",children:a("maintenance.totalPrintTime")})]})]}),s.jsx("div",{className:"w-px h-10 bg-bambu-dark-tertiary"}),m&&s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${m.is_due?"bg-red-500/20":"bg-amber-500/20"}`,children:(()=>{const b=z0(m.maintenance_type_icon);return s.jsx(b,{className:`w-4 h-4 ${m.is_due?"text-red-400":"text-amber-400"}`})})()}),s.jsxs("div",{children:[s.jsx("div",{className:`text-sm font-medium ${m.is_due?"text-red-400":"text-amber-400"}`,children:m.maintenance_type_name}),s.jsx("div",{className:`text-xs ${m.is_due?"text-red-400/70":"text-amber-400/70"}`,children:m.is_due?a("common.overdue"):a("maintenance.dueSoon")})]})]})]})]}),o&&s.jsx(Nt,{className:"pt-0 border-t border-bambu-dark-tertiary",children:s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-3 pt-4",children:p.map(b=>s.jsx(GKe,{item:b,onPerform:e,onToggle:n,hasPermission:i,t:a},b.id))})})]})}function WKe({overview:t,types:e,onUpdateInterval:n,onAddType:r,onUpdateType:i,onDeleteType:a,onAssignType:o,onRemoveItem:l,hasPermission:c,t:u}){const[d,f]=_.useState(null),[p,m]=_.useState(""),[x,b]=_.useState("hours"),[v,y]=_.useState(!1),[S,k]=_.useState(""),[T,M]=_.useState("100"),[C,E]=_.useState("hours"),[R,A]=_.useState("Wrench"),[D,I]=_.useState(""),[F,z]=_.useState(new Set),[P,$]=_.useState(null),X=_.useMemo(()=>t?t.map(U=>({id:U.printer_id,name:U.printer_name})):[],[t]),V=U=>t?t.filter(he=>he.maintenance_items.some(Me=>Me.maintenance_type_id===U)).map(he=>({printerId:he.printer_id,printerName:he.printer_name,itemId:he.maintenance_items.find(Me=>Me.maintenance_type_id===U)?.id})):[],Q=U=>{if(!t)return[];const he=new Set(V(U).map(Me=>Me.printerId));return X.filter(Me=>!he.has(Me.id))},[Z,se]=_.useState(null),[H,K]=_.useState(""),[re,ne]=_.useState(""),[be,me]=_.useState("hours"),[de,Ce]=_.useState("Wrench"),[ie,ke]=_.useState(""),Oe=U=>{se(U),K(U.name),ne(U.default_interval_hours.toString()),me(U.interval_type||"hours"),Ce(U.icon||"Wrench"),ke(U.wiki_url||"")},pe=()=>{Z&&H.trim()&&parseFloat(re)>0&&(i(Z.id,{name:H.trim(),default_interval_hours:parseFloat(re),interval_type:be,icon:de,wiki_url:ie.trim()||null}),se(null))},We=(U,he,Me)=>{const ge=parseFloat(p);if(!isNaN(ge)&&ge>0){const B=Math.abs(ge-he)<.01?null:ge;n(U,{custom_interval_hours:B,custom_interval_type:x!==Me?x:null})}f(null)},G=U=>{U.preventDefault(),S.trim()&&parseFloat(T)>0&&F.size>0&&(r({name:S.trim(),default_interval_hours:parseFloat(T),interval_type:C,icon:R,wiki_url:D.trim()||null},Array.from(F)),k(""),M("100"),E("hours"),I(""),z(new Set),y(!1))},Y=U=>{z(he=>{const Me=new Set(he);return Me.has(U)?Me.delete(U):Me.add(U),Me})},ue=t?.map(U=>({printerId:U.printer_id,printerName:U.printer_name,items:U.maintenance_items.sort((he,Me)=>he.maintenance_type_id-Me.maintenance_type_id)})).sort((U,he)=>U.printerName.localeCompare(he.printerName))||[],q=e.filter(U=>U.is_system),te=e.filter(U=>!U.is_system);return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:u("maintenance.maintenanceTypes")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:u("maintenance.maintenanceTypesDescription")})]}),s.jsxs(Te,{onClick:()=>y(!v),disabled:!c("maintenance:create"),title:c("maintenance:create")?void 0:u("maintenance.noPermissionEditTypes"),children:[s.jsx(fr,{className:"w-4 h-4"}),u("maintenance.addCustomType")]})]}),v&&s.jsx(St,{className:"mb-6",children:s.jsx(Nt,{className:"py-4",children:s.jsxs("form",{onSubmit:G,children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[s.jsxs("div",{className:"lg:col-span-2",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("common.name")}),s.jsx("input",{type:"text",value:S,onChange:U=>k(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:u("maintenance.exampleName"),autoFocus:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.intervalType")}),s.jsxs("select",{value:C,onChange:U=>{E(U.target.value),U.target.value==="days"?M("30"):M("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:[s.jsx("option",{value:"hours",children:u("maintenance.printHours")}),s.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]})]}),s.jsxs("div",{children:[s.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")})}),s.jsx("input",{type:"number",value:T,onChange:U=>M(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",min:"1"})]})]}),s.jsx("div",{className:"mt-4 flex items-end justify-between",children:s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.icon")}),s.jsx("div",{className:"flex gap-1",children:Object.keys(g0).map(U=>{const he=g0[U];return s.jsx("button",{type:"button",onClick:()=>A(U),className:`p-2 rounded-lg transition-colors ${R===U?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:s.jsx(he,{className:"w-4 h-4"})},U)})})]})}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.documentationLink")}),s.jsx("input",{type:"url",value:D,onChange:U=>I(U.target.value),className:"w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none",placeholder:"https://wiki.bambulab.com/..."})]}),s.jsxs("div",{className:"mt-4",children:[s.jsx("label",{className:"block text-xs text-bambu-gray mb-1.5",children:u("maintenance.assignToPrinters")}),s.jsx("div",{className:"flex flex-wrap gap-2",children:X.map(U=>s.jsx("button",{type:"button",onClick:()=>Y(U.id),className:`px-3 py-1.5 rounded-lg text-sm transition-colors ${F.has(U.id)?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary"}`,children:U.name},U.id))}),F.size===0&&s.jsx("p",{className:"text-xs text-orange-400 mt-1",children:u("maintenance.selectAtLeastOnePrinter")})]}),s.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:()=>{y(!1),z(new Set)},children:u("common.cancel")}),s.jsx(Te,{type:"submit",disabled:!S.trim()||F.size===0,children:u("maintenance.addType")})]})]})})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:[q.map(U=>{const he=z0(U.icon),Me=U.interval_type||"hours";return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-dark-tertiary",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-dark rounded-lg",children:s.jsx(he,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-white truncate",children:U.name}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[Me==="days"?s.jsx(ti,{className:"w-3 h-3"}):s.jsx(bu,{className:"w-3 h-3"}),qP(U.default_interval_hours,Me,u)]})]})]})},U.id)}),te.map(U=>{const he=z0(U.icon),Me=U.interval_type||"hours";if(Z?.id===U.id)return s.jsx("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx("input",{type:"text",value:H,onChange:le=>K(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}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("select",{value:be,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:[s.jsx("option",{value:"hours",children:u("maintenance.printHours")}),s.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]}),s.jsx("input",{type:"number",value:re,onChange:le=>ne(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"})]}),s.jsx("div",{className:"flex flex-wrap gap-1",children:Object.keys(g0).map(le=>{const _e=g0[le];return s.jsx("button",{type:"button",onClick:()=>Ce(le),className:`p-1.5 rounded transition-colors ${de===le?"bg-bambu-green text-white":"bg-bambu-dark text-bambu-gray hover:text-white"}`,children:s.jsx(_e,{className:"w-3.5 h-3.5"})},le)})}),s.jsx("input",{type:"url",value:ie,onChange:le=>ke(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")}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx(Te,{size:"sm",onClick:pe,disabled:!H.trim(),children:u("common.save")}),s.jsx(Te,{size:"sm",variant:"secondary",onClick:()=>se(null),children:u("common.cancel")})]})]})},U.id);const B=V(U.id),O=Q(U.id),ee=P===U.id;return s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-xl p-4 border border-bambu-green/30",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/20 rounded-lg",children:s.jsx(he,{className:"w-5 h-5 text-bambu-green"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm font-medium text-white truncate",children:U.name}),s.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")})]}),s.jsxs("div",{className:"text-xs text-bambu-gray mt-0.5 flex items-center gap-1",children:[Me==="days"?s.jsx(ti,{className:"w-3 h-3"}):s.jsx(bu,{className:"w-3 h-3"}),qP(U.default_interval_hours,Me,u)]})]}),s.jsxs("button",{onClick:()=>$(ee?null:U.id),className:`px-2 py-1 rounded-lg border transition-colors flex items-center gap-1 ${B.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:B.length}),children:[s.jsx(Ur,{className:"w-3 h-3"}),s.jsx("span",{className:"text-xs font-medium",children:B.length}),s.jsx(Kr,{className:`w-3 h-3 transition-transform ${ee?"rotate-180":""}`})]}),s.jsx("button",{onClick:()=>Oe(U),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:s.jsx(rm,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>{confirm(u("maintenance.deleteTypeConfirm",{name:U.name}))&&a(U.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:s.jsx(an,{className:"w-4 h-4"})})]}),ee&&s.jsxs("div",{className:"mt-3 pt-3 border-t border-bambu-dark-tertiary",children:[s.jsx("p",{className:"text-xs text-bambu-gray mb-2",children:u("maintenance.assignedToPrinters")}),B.length===0?s.jsx("p",{className:"text-xs text-orange-400",children:u("maintenance.noPrintersAssigned")}):s.jsx("div",{className:"flex flex-wrap gap-1 mb-2",children:B.map(le=>s.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-1 bg-bambu-dark rounded text-xs text-white",children:[le.printerName,s.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&&s.jsxs("div",{className:"flex flex-wrap gap-1",children:[s.jsx("span",{className:"text-xs text-bambu-gray mr-1",children:u("maintenance.addPrinterShort")}),O.map(le=>s.jsxs("button",{onClick:()=>o(le.id,U.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))]})]})]},U.id)})]})]}),ue.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:u("maintenance.intervalOverrides")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:u("maintenance.intervalOverridesDescription")})]}),s.jsx("div",{className:"space-y-4",children:ue.map(U=>s.jsx(St,{children:s.jsxs(Nt,{className:"py-4",children:[s.jsx("h3",{className:"text-sm font-medium text-white mb-3",children:U.printerName}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-2",children:U.items.map(he=>{const Me=z0(he.maintenance_type_icon),ge=e.find(_e=>_e.id===he.maintenance_type_id),B=ge?.default_interval_hours||he.interval_hours,O=ge?.interval_type||"hours",ee=he.interval_type||"hours",le=d===he.id;return s.jsxs("div",{className:"flex items-center gap-2 p-2.5 bg-bambu-dark rounded-lg",children:[s.jsx(Me,{className:"w-4 h-4 text-bambu-gray shrink-0"}),s.jsx("span",{className:"text-xs text-bambu-gray flex-1 truncate",children:he.maintenance_type_name}),le?s.jsxs("div",{className:"flex items-center gap-1",children:[x==="days"?s.jsx(ti,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}):s.jsx(bu,{className:"w-3.5 h-3.5 text-bambu-gray shrink-0"}),s.jsxs("select",{value:x,onChange:_e=>b(_e.target.value),className:"px-1.5 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",children:[s.jsx("option",{value:"hours",children:u("maintenance.printHours")}),s.jsx("option",{value:"days",children:u("maintenance.calendarDays")})]}),s.jsx("input",{type:"number",value:p,onChange:_e=>m(_e.target.value),onKeyDown:_e=>{_e.key==="Enter"&&We(he.id,B,O),_e.key==="Escape"&&f(null)},className:"w-16 px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-xs",min:"1"}),s.jsx(Te,{size:"sm",onClick:()=>We(he.id,B,O),children:"OK"})]}):s.jsxs("button",{onClick:()=>{c("maintenance:update")&&(f(he.id),m(he.interval_hours.toString()),b(ee))},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:[ee==="days"?s.jsx(ti,{className:"w-3 h-3"}):s.jsx(bu,{className:"w-3 h-3"}),qP(he.interval_hours,ee,u),s.jsx(rm,{className:"w-3 h-3 text-bambu-gray"})]})]},he.id)})})]})},U.printerId))})]}),ue.length===0&&s.jsx(St,{children:s.jsxs(Nt,{className:"text-center py-12",children:[s.jsx(tr,{className:"w-12 h-12 mx-auto mb-4 text-bambu-gray/30"}),s.jsx("p",{className:"text-bambu-gray",children:u("common.noPrinters")}),s.jsx("p",{className:"text-sm text-bambu-gray/70 mt-1",children:u("maintenance.intervalOverridesDescription")})]})})]})}function KKe(){const{t}=Rn(),e=sn(),{showToast:n}=Hn(),{hasPermission:r}=Ci(),[i,a]=_.useState("status"),{data:o,isLoading:l}=ot({queryKey:["maintenanceOverview"],queryFn:ce.getMaintenanceOverview}),{data:c}=ot({queryKey:["maintenanceTypes"],queryFn:ce.getMaintenanceTypes}),u=mt({mutationFn:({id:M,notes:C})=>ce.performMaintenance(M,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.maintenanceComplete"))},onError:M=>{n(M.message,"error")}}),d=mt({mutationFn:({id:M,data:C})=>ce.updateMaintenanceItem(M,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]})},onError:M=>{n(M.message,"error")}}),f=mt({mutationFn:({id:M,data:C})=>ce.updateMaintenanceType(M,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onError:M=>{n(M.message,"error")}}),p=mt({mutationFn:ce.deleteMaintenanceType,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeDeleted"))},onError:M=>{n(M.message,"error")}}),m=mt({mutationFn:({printerId:M,hours:C})=>ce.setPrinterHours(M,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),e.invalidateQueries({queryKey:["maintenanceSummary"]}),n(t("maintenance.printHoursUpdated"))},onError:M=>{n(M.message,"error")}}),x=mt({mutationFn:({printerId:M,typeId:C})=>ce.assignMaintenanceType(M,C),onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerAssigned"))},onError:M=>{n(M.message,"error")}}),b=mt({mutationFn:ce.removeMaintenanceItem,onSuccess:()=>{e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.printerRemoved"))},onError:M=>{n(M.message,"error")}}),v=M=>{u.mutate({id:M})},y=(M,C)=>{d.mutate({id:M,data:{enabled:C}})},S=(M,C)=>{m.mutate({printerId:M,hours:C})};if(l)return s.jsx("div",{className:"p-4 md:p-8 flex justify-center",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})});const k=o?.reduce((M,C)=>M+C.due_count,0)||0,T=o?.reduce((M,C)=>M+C.warning_count,0)||0;return s.jsxs("div",{className:"p-4 md:p-8",children:[s.jsxs("div",{className:"mb-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("maintenance.title")}),s.jsx("p",{className:"text-bambu-gray text-sm mt-1",children:i==="status"?s.jsxs(s.Fragment,{children:[k>0&&s.jsx("span",{className:"text-red-400",children:t("maintenance.dueCount",{count:k})}),k>0&&T>0&&" · ",T>0&&s.jsx("span",{className:"text-amber-400",children:t("maintenance.warningCount",{count:T})}),k===0&&T===0&&s.jsx("span",{className:"text-bambu-green",children:t("maintenance.allOk")})]}):t("maintenance.configureSettings")})]}),s.jsxs("div",{className:"flex gap-1 mb-6 border-b border-bambu-dark-tertiary",children:[s.jsx("button",{onClick:()=>a("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")}),s.jsx("button",{onClick:()=>a("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"?s.jsx("div",{className:"space-y-6",children:o&&o.length>0?[...o].sort((M,C)=>{const E=M.due_count*10+M.warning_count,R=C.due_count*10+C.warning_count;return E!==R?R-E:M.printer_name.localeCompare(C.printer_name)}).map(M=>s.jsx(qKe,{overview:M,onPerform:v,onToggle:y,onSetHours:S,hasPermission:r,t},M.printer_id)):s.jsx(St,{children:s.jsxs(Nt,{className:"text-center py-16",children:[s.jsx(om,{className:"w-16 h-16 mx-auto mb-4 text-bambu-gray/30"}),s.jsx("p",{className:"text-lg font-medium text-white mb-2",children:t("common.noPrinters")}),s.jsx("p",{className:"text-bambu-gray",children:t("maintenance.configureSettings")})]})})}):s.jsx(WKe,{overview:o,types:c||[],onUpdateInterval:(M,C)=>d.mutate({id:M,data:C}),onAddType:async(M,C)=>{const E=await ce.createMaintenanceType(M);for(const R of C)await ce.assignMaintenanceType(R,E.id);e.invalidateQueries({queryKey:["maintenanceTypes"]}),e.invalidateQueries({queryKey:["maintenanceOverview"]}),n(t("maintenance.typeUpdated"))},onUpdateType:(M,C)=>f.mutate({id:M,data:C}),onDeleteType:M=>p.mutate(M),onAssignType:(M,C)=>x.mutate({printerId:M,typeId:C}),onRemoveItem:M=>b.mutate(M),hasPermission:r,t})]})}const yq=["#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#6b7280"];function $re({project:t,onClose:e,onSave:n,isLoading:r,t:i}){const[a,o]=_.useState(t?.name||""),[l,c]=_.useState(t?.description||""),[u,d]=_.useState(t?.color||yq[0]),[f,p]=_.useState(t?.target_count?.toString()||""),[m,x]=_.useState(t?.target_parts_count?.toString()||""),[b,v]=_.useState(t?.status||"active"),[y,S]=_.useState(t?.tags||""),[k,T]=_.useState(t?.due_date?.split("T")[0]||""),[M,C]=_.useState(t?.priority||"normal"),E=R=>{R.preventDefault(),n({name:a.trim(),description:l.trim()||void 0,color:u,target_count:f?parseInt(f,10):void 0,target_parts_count:m?parseInt(m,10):void 0,tags:y.trim()||void 0,due_date:k||void 0,priority:M,...t&&{status:b}})};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i(t?"projects.editProject":"projects.newProject")})}),s.jsxs("form",{onSubmit:E,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.name")}),s.jsx("input",{type:"text",value:a,onChange:R=>o(R.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.description")}),s.jsx("textarea",{value:l,onChange:R=>c(R.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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.color")}),s.jsx("div",{className:"flex gap-2 flex-wrap",children:yq.map(R=>s.jsx("button",{type:"button",onClick:()=>d(R),className:`w-8 h-8 rounded-full transition-transform ${u===R?"ring-2 ring-white ring-offset-2 ring-offset-bambu-dark-secondary scale-110":""}`,style:{backgroundColor:R}},R))})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetPlates")}),s.jsx("input",{type:"number",value:f,onChange:R=>p(R.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPlatesHelp")})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.targetParts")}),s.jsx("input",{type:"number",value:m,onChange:R=>x(R.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"}),s.jsx("p",{className:"text-xs text-bambu-gray mt-1",children:i("projects.targetPartsHelp")})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.tagsLabel")}),s.jsx("input",{type:"text",value:y,onChange:R=>S(R.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")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.dueDate")}),s.jsx("input",{type:"date",value:k,onChange:R=>T(R.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"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("projects.priority")}),s.jsxs("select",{value:M,onChange:R=>C(R.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:[s.jsx("option",{value:"low",children:i("projects.priorityLow")}),s.jsx("option",{value:"normal",children:i("projects.priorityNormal")}),s.jsx("option",{value:"high",children:i("projects.priorityHigh")}),s.jsx("option",{value:"urgent",children:i("projects.priorityUrgent")})]})]})]}),t&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("common.status")}),s.jsxs("select",{value:b,onChange:R=>v(R.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:[s.jsx("option",{value:"active",children:i("projects.statusActive")}),s.jsx("option",{value:"completed",children:i("projects.statusCompleted")}),s.jsx("option",{value:"archived",children:i("projects.statusArchived")})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),s.jsx(Te,{type:"submit",disabled:!a.trim()||r,children:r?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):i(t?"common.save":"projects.create")})]})]})]})})}function XKe({project:t,onClick:e,onEdit:n,onDelete:r,hasPermission:i,t:a}){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,f]=_.useState(!1),m=c?{icon:oM,color:"text-bambu-green",bg:"bg-bambu-green/10"}:u?{icon:ho,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:Ja,color:"text-bambu-gray",bg:"bg-bambu-gray/10"};return s.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:[s.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`}}),s.jsxs("div",{className:"p-5 pl-6",children:[s.jsxs("div",{className:"flex items-start justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("div",{className:`p-2 rounded-lg ${m.bg} flex-shrink-0`,children:s.jsx(m.icon,{className:`w-5 h-5 ${m.color}`})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h3",{className:"font-semibold text-white truncate",children:t.name}),t.target_parts_count?s.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," ",a("projects.parts")]}):t.target_count?s.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," ",a("projects.plates")]}):t.completed_count>0?s.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," ",a("projects.parts")]}):null,c&&s.jsx("span",{className:"text-xs bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full whitespace-nowrap",children:a("projects.done")}),u&&s.jsx("span",{className:"text-xs bg-bambu-gray/20 text-bambu-gray px-2 py-0.5 rounded-full whitespace-nowrap",children:a("projects.statusArchived")})]}),t.description&&s.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(k=>k.trim())).filter(Boolean),b=[...new Set(x)],v=t.archives.map(S=>S.filament_color).filter(Boolean).flatMap(S=>S.split(",").map(k=>k.trim())).filter(S=>S.startsWith("#")||/^[0-9A-Fa-f]{6}$/.test(S)),y=[...new Set(v)];return b.length===0&&y.length===0?null:s.jsxs("div",{className:"flex items-center gap-2 mt-1.5",children:[b.slice(0,3).map(S=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-bambu-dark text-bambu-gray rounded",children:S},S)),y.length>0&&s.jsxs("div",{className:"flex items-center gap-0.5",children:[y.slice(0,5).map(S=>s.jsx("div",{className:"w-3 h-3 rounded-full border border-white/20",style:{backgroundColor:S.startsWith("#")?S:`#${S}`},title:S},S)),y.length>5&&s.jsxs("span",{className:"text-[10px] text-bambu-gray ml-0.5",children:["+",y.length-5]})]})]})})()]})]}),s.jsxs("div",{className:"relative",onClick:x=>x.stopPropagation(),children:[s.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:()=>f(!d),children:s.jsx(ih,{className:"w-4 h-4"})}),d&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>f(!1)}),s.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:[s.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(),f(!1))},disabled:!i("projects:update"),title:i("projects:update")?void 0:a("projects.noEditPermission"),children:[s.jsx(rm,{className:"w-4 h-4"}),a("common.edit")]}),s.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(),f(!1))},disabled:!i("projects:delete"),title:i("projects:delete")?void 0:a("projects.noDeletePermission"),children:[s.jsx(an,{className:"w-4 h-4"}),a("common.delete")]})]})]})]})]}),s.jsx("div",{className:"mb-4",children:t.target_count||t.target_parts_count?s.jsxs("div",{className:"space-y-3",children:[t.target_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:a("projects.plates")}),s.jsxs("span",{className:o>=100?"text-bambu-green font-medium":"text-white",children:[t.archive_count," / ",t.target_count]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:s.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&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between text-xs mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:a("projects.parts")}),s.jsxs("span",{className:l>=100?"text-bambu-green font-medium":"text-white",children:[t.completed_count," / ",t.target_parts_count]})]}),s.jsx("div",{className:"h-2 bg-bambu-dark/80 rounded-full overflow-hidden backdrop-blur-sm",children:s.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&&s.jsxs("div",{className:"text-xs text-red-400",children:[t.failed_count," ",a("projects.failed")]})]}):t.completed_count>0||t.failed_count>0?s.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.completed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-bambu-gray",children:[s.jsx(ho,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.completed_count," ",a("projects.completed")]})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",children:[s.jsx(Sn,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.failed_count," ",a("projects.failed")]})]}),t.queue_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-blue-400",children:[s.jsx(tr,{className:"w-3.5 h-3.5"}),s.jsxs("span",{children:[t.queue_count," ",a("projects.inQueue")]})]})]}):s.jsx("div",{className:"text-xs text-bambu-gray/60 italic",children:a("projects.noPrintsYet")})}),t.archives&&t.archives.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsx("div",{className:"grid grid-cols-4 gap-1.5",children:t.archives.slice(0,4).map(x=>s.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?s.jsx("img",{src:ce.getArchiveThumbnail(x.id),alt:x.print_name||"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray/50",children:s.jsx(pc,{className:"w-6 h-6"})}),x.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/40 flex items-center justify-center",children:s.jsx(Sn,{className:"w-4 h-4 text-white"})})]},x.id))}),t.archive_count>4&&s.jsx("p",{className:"text-xs text-bambu-gray mt-1.5 text-center",children:a("common.more",{count:t.archive_count-4})})]}),s.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-4 text-xs text-bambu-gray",children:[s.jsxs("div",{className:"flex items-center gap-1.5",title:a("projects.printJobs"),children:[s.jsx(sl,{className:"w-3.5 h-3.5 text-blue-400"}),s.jsxs("span",{children:[t.archive_count," ",a("projects.plates")]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",title:a("projects.partsPrinted"),children:[s.jsx(pc,{className:"w-3.5 h-3.5 text-bambu-green"}),s.jsxs("span",{children:[t.completed_count," ",a("projects.parts")]})]}),t.failed_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-red-400",title:a("projects.failedParts"),children:[s.jsx(Sn,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.failed_count})]}),t.queue_count>0&&s.jsxs("div",{className:"flex items-center gap-1.5 text-yellow-400",title:a("projects.inQueue"),children:[s.jsx(pj,{className:"w-3.5 h-3.5"}),s.jsx("span",{children:t.queue_count})]})]}),s.jsx(gs,{className:"w-4 h-4 text-bambu-gray/50 group-hover:text-bambu-gray transition-colors"})]})]})]})}function YKe(){const{t}=Rn(),e=kc(),n=sn(),{showToast:r}=Hn(),{hasPermission:i}=Ci(),[a,o]=_.useState(!1),[l,c]=_.useState(),[u,d]=_.useState("active"),[f,p]=_.useState(null),{data:m,isLoading:x}=ot({queryKey:["projects",u==="all"?void 0:u],queryFn:()=>ce.getProjects(u==="all"?void 0:u)}),b=mt({mutationFn:z=>ce.createProject(z),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),r(t("projects.toast.created"),"success")},onError:z=>{r(z.message,"error")}}),v=mt({mutationFn:({id:z,data:P})=>ce.updateProject(z,P),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),o(!1),c(void 0),r(t("projects.toast.updated"),"success")},onError:z=>{r(z.message,"error")}}),y=mt({mutationFn:z=>ce.deleteProject(z),onSuccess:()=>{p(null),r(t("projects.toast.deleted"),"success"),setTimeout(()=>window.location.reload(),100)},onError:z=>{p(null),r(z.message,"error")}}),S=mt({mutationFn:z=>ce.importProject(z),onSuccess:()=>{n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success")},onError:z=>{r(z.message,"error")}}),k=_.useRef(null),T=async()=>{try{const z=await ce.getProjects(),P=await Promise.all(z.map(async Q=>await ce.exportProjectJson(Q.id))),$=new Blob([JSON.stringify(P,null,2)],{type:"application/json"}),X=URL.createObjectURL($),V=document.createElement("a");V.href=X,V.download=`bambuddy_projects_${new Date().toISOString().split("T")[0]}.json`,V.click(),URL.revokeObjectURL(X),r(t("projects.toast.exported"),"success")}catch(z){r(z.message,"error")}},M=()=>{k.current?.click()},C=async z=>{const P=z.target.files?.[0];if(P){try{if(P.name.toLowerCase().endsWith(".zip"))await ce.importProjectFile(P),n.invalidateQueries({queryKey:["projects"]}),r(t("projects.toast.imported"),"success");else{const X=await P.text(),V=JSON.parse(X),Q=Array.isArray(V)?V:[V];for(const Z of Q)await S.mutateAsync(Z);Q.length>1&&r(t("projects.toast.multipleImported",{count:Q.length}),"success")}}catch($){r(`${t("projects.toast.importFailed")}: ${$.message}`,"error")}z.target.value=""}},E=z=>{l?v.mutate({id:l.id,data:z}):b.mutate(z)},R=z=>{c(z),o(!0)},A=z=>{e(`/projects/${z.id}`)},D=z=>{p(z)},I=()=>{f!==null&&y.mutate(f)},F=m?.reduce((z,P)=>(z[P.status]=(z[P.status]||0)+1,z.all=(z.all||0)+1,z),{})||{};return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsx("input",{ref:k,type:"file",accept:".json,.zip",onChange:C,className:"hidden"}),s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:s.jsx(Ja,{className:"w-6 h-6 text-bambu-green"})}),t("projects.title")]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("projects.subtitle")})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{variant:"secondary",onClick:M,disabled:!i("projects:create"),title:i("projects:create")?t("projects.importProject"):t("projects.noImportPermission"),children:[s.jsx(za,{className:"w-4 h-4 mr-2"}),t("projects.import")]}),s.jsxs(Te,{variant:"secondary",onClick:T,disabled:!i("projects:read"),title:i("projects:read")?t("projects.exportAll"):t("projects.noExportPermission"),children:[s.jsx(wi,{className:"w-4 h-4 mr-2"}),t("projects.export")]}),s.jsxs(Te,{onClick:()=>o(!0),className:"sm:w-auto w-full",disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[s.jsx(fr,{className:"w-4 h-4 mr-2"}),t("projects.newProject")]})]})]}),s.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:oM},{key:"archived",label:t("projects.statusArchived"),icon:ho},{key:"all",label:t("common.all"),icon:Ja}].map(({key:z,label:P,icon:$})=>s.jsxs("button",{onClick:()=>d(z),className:`flex items-center gap-2 px-4 py-2 text-sm rounded-lg transition-all ${u===z?"bg-bambu-card text-white shadow-sm":"text-bambu-gray hover:text-white"}`,children:[s.jsx($,{className:"w-4 h-4"}),s.jsx("span",{children:P}),F[z]>0&&s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${u===z?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary"}`,children:F[z]})]},z))}),x?s.jsx("div",{className:"flex items-center justify-center py-20",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(ft,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("projects.loading")})]})}):m?.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-20 px-4",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(Ja,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:u==="all"?t("projects.noProjects"):t("projects.noProjectsFiltered",{status:u})}),s.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"&&s.jsxs(Te,{onClick:()=>o(!0),disabled:!i("projects:create"),title:i("projects:create")?void 0:t("projects.noCreatePermission"),children:[s.jsx(fr,{className:"w-4 h-4 mr-2"}),t("projects.createFirstButton")]})]}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-8",children:m?.map(z=>s.jsx(XKe,{project:z,onClick:()=>A(z),onEdit:()=>R(z),onDelete:()=>D(z.id),hasPermission:i,t},z.id))}),f!==null&&s.jsx(Zn,{title:t("projects.deleteProject"),message:t("projects.deleteConfirm"),confirmText:t("projects.deleteProject"),variant:"danger",onConfirm:I,onCancel:()=>p(null)}),a&&s.jsx($re,{project:l,onClose:()=>{o(!1),c(void 0)},onSave:E,isLoading:b.isPending||v.isPending,t})]})}function QKe(t){if(t<1)return`${Math.round(t*60)}m`;const e=Math.floor(t),n=Math.round((t-e)*60);return n>0?`${e}h ${n}m`:`${e}h`}function ZKe(t){return t>=1e3?`${(t/1e3).toFixed(2)}kg`:`${Math.round(t)}g`}function JKe({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 s.jsx("span",{className:`px-2 py-1 rounded text-sm font-medium ${r}`,children:i[t]||t.charAt(0).toUpperCase()+t.slice(1)})}function vq({icon:t,label:e,value:n,subValue:r,hint:i,color:a="text-bambu-gray"}){return s.jsx(St,{children:s.jsx(Nt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",title:i,children:[s.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark ${a}`,children:s.jsx(t,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:e}),s.jsx("p",{className:"text-xl font-semibold text-white",children:n}),r&&s.jsx("p",{className:"text-xs text-bambu-gray/70",children:r})]})]})})})}function eXe({archives:t,t:e}){return t.length===0?s.jsxs("div",{className:"text-center py-8 text-bambu-gray",children:[s.jsx(pc,{className:"w-12 h-12 mx-auto mb-2 opacity-50"}),s.jsx("p",{children:e("projectDetail.noPrints")})]}):s.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=>s.jsxs(Ds,{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?s.jsx("img",{src:ce.getArchiveThumbnail(n.id),alt:n.print_name||"Print",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center text-bambu-gray",children:s.jsx(pc,{className:"w-8 h-8"})}),n.status==="failed"&&s.jsx("div",{className:"absolute inset-0 bg-red-500/30 flex items-center justify-center",children:s.jsx(Qi,{className:"w-8 h-8 text-white"})}),n.status==="completed"&&s.jsx("div",{className:"absolute top-1 right-1",children:s.jsx(Ar,{className:"w-4 h-4 text-bambu-green"})}),s.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:s.jsx("p",{className:"text-xs text-white truncate",children:n.print_name||"Unknown"})})]},n.id))})}function tXe({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 s.jsxs("span",{className:`px-2 py-1 rounded text-xs font-medium flex items-center gap-1 ${r}`,children:[t==="urgent"&&s.jsx(Sn,{className:"w-3 h-3"}),i]})}function nXe(t){return t?Bg(t,{year:"numeric",month:"short",day:"numeric"}):""}function WP(t,e){if(!t)return null;const n=Ui(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 rXe(){const{id:t}=iM(),e=kc(),{t:n}=Rn(),r=sn(),{showToast:i}=Hn(),{hasPermission:a}=Ci(),[o,l]=_.useState(!1),[c,u]=_.useState(!1),[d,f]=_.useState(""),p=parseInt(t||"0",10),{data:m,isLoading:x,error:b}=ot({queryKey:["project",p],queryFn:()=>ce.getProject(p),enabled:p>0}),{data:v,isLoading:y}=ot({queryKey:["project-archives",p],queryFn:()=>ce.getProjectArchives(p),enabled:p>0}),{data:S,isLoading:k}=ot({queryKey:["project-bom",p],queryFn:()=>ce.getProjectBOM(p),enabled:p>0}),{data:T,isLoading:M}=ot({queryKey:["project-timeline",p],queryFn:()=>ce.getProjectTimeline(p,20),enabled:p>0}),{data:C}=ot({queryKey:["settings"],queryFn:ce.getSettings}),{data:E}=ot({queryKey:["project-folders",p],queryFn:()=>ce.getLibraryFoldersByProject(p),enabled:p>0}),R=C?.currency||"$",A=C?.time_format||"system",D=mt({mutationFn:we=>ce.updateProject(p,we),onSuccess:()=>{r.invalidateQueries({queryKey:["project",p]}),r.invalidateQueries({queryKey:["projects"]}),l(!1),u(!1),i(n("projectDetail.toast.projectUpdated"),"success")},onError:we=>{i(we.message,"error")}}),I=()=>{f(m?.notes||""),u(!0)},F=()=>{D.mutate({notes:d})},z=()=>{u(!1),f("")},[P,$]=_.useState(""),[X,V]=_.useState(1),[Q,Z]=_.useState(""),[se,H]=_.useState(""),[K,re]=_.useState(""),[ne,be]=_.useState(!1),[me,de]=_.useState(!1),[Ce,ie]=_.useState(null),[ke,Oe]=_.useState(""),[pe,We]=_.useState(1),[G,Y]=_.useState(""),[ue,q]=_.useState(""),[te,U]=_.useState(""),[he,Me]=_.useState({isOpen:!1,title:"",message:"",onConfirm:()=>{}}),ge=mt({mutationFn:we=>ce.createBOMItem(p,we),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),$(""),V(1),Z(""),H(""),re(""),be(!1),i(n("projectDetail.toast.partAdded"),"success")},onError:we=>i(we.message,"error")}),B=mt({mutationFn:({itemId:we,data:Xe})=>ce.updateBOMItem(p,we,Xe),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),ie(null)},onError:we=>i(we.message,"error")}),O=mt({mutationFn:we=>ce.deleteBOMItem(p,we),onSuccess:()=>{r.invalidateQueries({queryKey:["project-bom",p]}),r.invalidateQueries({queryKey:["project",p]}),i(n("projectDetail.toast.partRemoved"),"success")},onError:we=>i(we.message,"error")}),ee=we=>{we.preventDefault(),P.trim()&&ge.mutate({name:P.trim(),quantity_needed:X,unit_price:Q?parseFloat(Q):void 0,sourcing_url:se.trim()||void 0,remarks:K.trim()||void 0})},le=we=>{const Xe=we.is_complete?0:we.quantity_needed;B.mutate({itemId:we.id,data:{quantity_acquired:Xe}})},_e=(we,Xe)=>{Me({isOpen:!0,title:n("projectDetail.bom.deletePart"),message:n("projectDetail.bom.deleteConfirm",{name:Xe}),onConfirm:()=>{Me(Ne=>({...Ne,isOpen:!1})),O.mutate(we)}})},ve=we=>{ie(we),Oe(we.name),We(we.quantity_needed),Y(we.unit_price?.toString()||""),q(we.sourcing_url||""),U(we.remarks||"")},ae=we=>{we.preventDefault(),!(!Ce||!ke.trim())&&B.mutate({itemId:Ce.id,data:{name:ke.trim(),quantity_needed:pe,unit_price:G?parseFloat(G):void 0,sourcing_url:ue.trim()||void 0,remarks:te.trim()||void 0}})},Fe=()=>{ie(null)},Be=async()=>{try{const{blob:we,filename:Xe}=await ce.exportProjectZip(Number(p)),Ne=URL.createObjectURL(we),rt=document.createElement("a");rt.href=Ne,rt.download=Xe||`${m?.name||"project"}_${new Date().toISOString().split("T")[0]}.zip`,rt.click(),URL.revokeObjectURL(Ne),i(n("projectDetail.toast.projectExported"),"success")}catch(we){i(we.message,"error")}},$e=mt({mutationFn:()=>ce.createTemplateFromProject(p),onSuccess:()=>{r.invalidateQueries({queryKey:["projects"]}),i(n("projectDetail.toast.templateCreated"),"success")},onError:we=>i(we.message,"error")}),He=we=>Hg(we,A,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});if(x)return s.jsx("div",{className:"flex items-center justify-center py-24",children:s.jsx(ft,{className:"w-8 h-8 animate-spin text-bambu-green"})});if(b||!m)return s.jsxs("div",{className:"text-center py-24",children:[s.jsx("p",{className:"text-bambu-gray",children:b?`${n("common.error")}: ${b.message}`:n("projectDetail.notFound")}),s.jsx(Te,{variant:"secondary",className:"mt-4",onClick:()=>e("/projects"),children:n("projectDetail.backToProjects")})]});const xe=m.stats,Pe=xe?.progress_percent??0,ze=xe?.parts_progress_percent??0;return s.jsxs("div",{className:"p-4 md:p-8 space-y-8",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm text-bambu-gray",children:[s.jsx(Ds,{to:"/projects",className:"hover:text-white transition-colors",children:n("navigation.projects")}),s.jsx(gs,{className:"w-4 h-4"}),s.jsx("span",{className:"text-white",children:m.name})]}),s.jsxs("div",{className:"flex items-start justify-between",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("button",{onClick:()=>e("/projects"),className:"p-2 rounded-lg bg-bambu-card hover:bg-bambu-dark-tertiary transition-colors",children:s.jsx(fce,{className:"w-5 h-5 text-bambu-gray"})}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:m.color||"#6b7280"}}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:m.name}),m.description&&s.jsx("p",{className:"text-bambu-gray mt-1",children:m.description})]})]}),s.jsx(JKe,{status:m.status,t:n})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{variant:"secondary",onClick:Be,disabled:!a("projects:read"),title:a("projects:read")?n("projectDetail.exportProject"):n("projectDetail.noExportPermission"),children:[s.jsx(wi,{className:"w-4 h-4 mr-2"}),n("projectDetail.export")]}),s.jsxs(Te,{onClick:()=>l(!0),disabled:!a("projects:update"),title:a("projects:update")?void 0:n("projectDetail.noEditPermission"),children:[s.jsx(rm,{className:"w-4 h-4 mr-2"}),n("common.edit")]})]})]}),(m.target_count||m.target_parts_count)&&s.jsx(St,{children:s.jsxs(Nt,{className:"p-4 space-y-4",children:[m.target_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.platesProgress")}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[xe?.total_archives||0," / ",m.target_count," ",n("projectDetail.progress.printJobs")]})]}),s.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(Pe,100)}%`,backgroundColor:Pe>=100?"#22c55e":m.color||"#6b7280"}})}),s.jsxs("div",{className:"flex justify-between mt-1",children:[s.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:Pe.toFixed(0)})}),xe?.remaining_prints!=null&&xe.remaining_prints>0&&s.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:xe.remaining_prints})})]})]}),m.target_parts_count&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm text-bambu-gray",children:n("projectDetail.progress.partsProgress")}),s.jsxs("span",{className:"text-sm font-medium text-white",children:[xe?.completed_prints||0," / ",m.target_parts_count," ",n("projectDetail.progress.parts")]})]}),s.jsx("div",{className:"h-3 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${Math.min(ze,100)}%`,backgroundColor:ze>=100?"#22c55e":m.color||"#6b7280"}})}),s.jsxs("div",{className:"flex justify-between mt-1",children:[s.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.percentComplete",{percent:ze.toFixed(0)})}),xe?.remaining_parts!=null&&xe.remaining_parts>0&&s.jsx("span",{className:"text-xs text-bambu-gray/70",children:n("projectDetail.progress.remaining",{count:xe.remaining_parts})})]})]})]})}),xe&&s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(St,{children:s.jsx(Nt,{className:"p-4",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark text-bambu-green",children:s.jsx(pc,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.printJobs")}),s.jsxs("p",{className:"text-xl font-semibold text-white",children:[xe.total_archives," ",s.jsx("span",{className:"text-sm font-normal text-bambu-gray",children:n("projectDetail.stats.total")})]}),xe.failed_prints>0&&s.jsx("p",{className:"text-sm text-status-error",children:n("projectDetail.stats.failed",{count:xe.failed_prints})}),s.jsx("p",{className:"text-sm text-bambu-gray",children:n("projectDetail.stats.partsPrinted",{count:xe.completed_prints})})]})]})})}),s.jsx(vq,{icon:tr,label:n("projectDetail.stats.printTime"),value:QKe(xe.total_print_time_hours),color:"text-yellow-400"}),s.jsx(vq,{icon:Ur,label:n("projectDetail.stats.filamentUsed"),value:ZKe(xe.total_filament_grams),color:"text-purple-400"})]}),xe&&(xe.estimated_cost>0||m.budget)&&s.jsx(St,{children:s.jsxs(Nt,{className:"p-4",children:[s.jsx("h2",{className:"text-lg font-semibold text-white mb-3",children:n("projectDetail.cost.title")}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.filamentCost")}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[R,xe.estimated_cost.toFixed(2)]})]}),xe.total_energy_kwh>0&&s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.energy")}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[xe.total_energy_kwh.toFixed(2)," kWh",xe.total_energy_cost>0&&s.jsxs("span",{className:"text-sm text-bambu-gray ml-1",children:["(",R,xe.total_energy_cost.toFixed(2),")"]})]})]}),m.budget&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.budget")}),s.jsxs("p",{className:"text-lg font-semibold text-white",children:[R,m.budget.toFixed(2)]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.cost.remaining")}),s.jsxs("p",{className:`text-lg font-semibold ${m.budget-xe.estimated_cost>=0?"text-bambu-green":"text-red-400"}`,children:[R,(m.budget-xe.estimated_cost).toFixed(2)]})]})]})]})]})}),m.children&&m.children.length>0&&s.jsx(St,{children:s.jsxs(Nt,{className:"p-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2 mb-3",children:[s.jsx(Vue,{className:"w-5 h-5"}),n("projectDetail.subProjects.title",{count:m.children.length})]}),s.jsx("div",{className:"space-y-2",children:m.children.map(we=>s.jsxs(Ds,{to:`/projects/${we.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:we.color||"#6b7280"}}),s.jsx("span",{className:"text-white",children:we.name}),s.jsx("span",{className:`text-xs px-2 py-0.5 rounded ${we.status==="completed"?"bg-status-ok/20 text-status-ok":we.status==="archived"?"bg-bambu-gray/20 text-bambu-gray":"bg-blue-500/20 text-blue-400"}`,children:we.status})]}),we.progress_percent!==null&&s.jsxs("span",{className:"text-sm text-bambu-gray",children:[we.progress_percent.toFixed(0),"%"]})]},we.id))})]})}),m.parent_id&&m.parent_name&&s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(sl,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.partOf")}),s.jsx(Ds,{to:`/projects/${m.parent_id}`,className:"text-bambu-green hover:underline",children:m.parent_name})]}),(m.tags||m.due_date||m.priority!=="normal")&&s.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[m.priority&&m.priority!=="normal"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-bambu-gray uppercase",children:n("projectDetail.priorityLabel")}),s.jsx(tXe,{priority:m.priority,t:n})]}),m.due_date&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ti,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("span",{className:"text-sm text-white",children:nXe(m.due_date)}),WP(m.due_date,n)&&s.jsxs("span",{className:`text-xs ${WP(m.due_date,n).color}`,children:["(",WP(m.due_date,n).label,")"]})]}),m.tags&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(yh,{className:"w-4 h-4 text-bambu-gray"}),s.jsx("div",{className:"flex flex-wrap gap-1",children:m.tags.split(",").map((we,Xe)=>s.jsx("span",{className:"px-2 py-0.5 bg-bambu-dark-tertiary text-bambu-gray text-xs rounded",children:we.trim()},Xe))})]})]}),s.jsx(St,{children:s.jsxs(Nt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Ls,{className:"w-5 h-5"}),n("projectDetail.notes.title")]}),c?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(Te,{variant:"secondary",size:"sm",onClick:z,disabled:D.isPending,children:[s.jsx(Rt,{className:"w-4 h-4 mr-1"}),n("common.cancel")]}),s.jsxs(Te,{size:"sm",onClick:F,disabled:D.isPending,children:[D.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin mr-1"}):s.jsx(hs,{className:"w-4 h-4 mr-1"}),n("common.save")]})]}):s.jsxs(Te,{variant:"secondary",size:"sm",onClick:I,disabled:!a("projects:update"),title:a("projects:update")?void 0:n("projectDetail.notes.noEditPermission"),children:[s.jsx(rm,{className:"w-4 h-4 mr-1"}),n("common.edit")]})]}),c?s.jsx(iR,{content:d,onChange:f,placeholder:n("projectDetail.notes.placeholder")}):m.notes?s.jsx("div",{className:"prose prose-invert prose-sm max-w-none",dangerouslySetInnerHTML:{__html:m.notes}}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.notes.empty")})]})}),s.jsx(St,{children:s.jsxs(Nt,{className:"p-4",children:[s.jsx("div",{className:"flex items-center justify-between mb-3",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(Il,{className:"w-5 h-5"}),n("projectDetail.files.title")]})}),s.jsxs("p",{className:"text-xs text-bambu-gray mb-3",children:[s.jsx(Ds,{to:"/files",className:"text-bambu-green hover:underline",children:n("projectDetail.files.linkFolders")})," ",n("projectDetail.files.forQuickAccess")]}),E&&E.length>0?s.jsx("div",{className:"space-y-2",children:E.map(we=>s.jsxs(Ds,{to:`/files?folder=${we.id}`,className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsx(Il,{className:"w-5 h-5 text-bambu-green flex-shrink-0"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:we.name}),s.jsx("p",{className:"text-xs text-bambu-gray",children:n("projectDetail.files.fileCount",{count:we.file_count})})]})]}),s.jsx(gs,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"})]},we.id))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.files.empty")})]})}),s.jsx(St,{children:s.jsxs(Nt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(AW,{className:"w-5 h-5"}),n("projectDetail.bom.title"),xe&&xe.bom_total_items>0&&s.jsxs("span",{className:"text-sm font-normal text-bambu-gray",children:["(",n("projectDetail.bom.acquired",{completed:xe.bom_completed_items,total:xe.bom_total_items}),")"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[S&&S.some(we=>we.is_complete)&&s.jsx("button",{onClick:()=>de(!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")}),!ne&&s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>be(!0),disabled:!a("projects:update"),title:a("projects:update")?void 0:n("projectDetail.bom.noAddPermission"),children:[s.jsx(fr,{className:"w-4 h-4 mr-1"}),n("projectDetail.bom.addPart")]})]})]}),ne&&s.jsxs("form",{onSubmit:ee,className:"bg-bambu-dark rounded-lg p-4 mb-4 space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.jsx("input",{type:"text",value:P,onChange:we=>$(we.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}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"number",value:X,onChange:we=>V(parseInt(we.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")}),s.jsx("input",{type:"number",step:"0.01",value:Q,onChange:we=>Z(we.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:R})})]})]}),s.jsx("input",{type:"url",value:se,onChange:we=>H(we.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")}),s.jsx("input",{type:"text",value:K,onChange:we=>re(we.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")}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Te,{type:"button",variant:"secondary",size:"sm",onClick:()=>be(!1),children:n("common.cancel")}),s.jsx(Te,{type:"submit",size:"sm",disabled:!P.trim()||ge.isPending,children:ge.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):n("projectDetail.bom.addPart")})]})]}),k?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(ft,{className:"w-6 h-6 animate-spin text-bambu-green"})}):S&&S.length>0?s.jsxs("div",{className:"space-y-2",children:[S.filter(we=>!me||!we.is_complete).map(we=>s.jsx("div",{className:`p-3 rounded-lg transition-colors ${we.is_complete?"bg-status-ok/10":"bg-bambu-dark"}`,children:Ce?.id===we.id?s.jsxs("form",{onSubmit:ae,className:"space-y-3",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[s.jsx("input",{type:"text",value:ke,onChange:Xe=>Oe(Xe.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}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"number",value:pe,onChange:Xe=>We(parseInt(Xe.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")}),s.jsx("input",{type:"number",step:"0.01",value:G,onChange:Xe=>Y(Xe.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:R})})]})]}),s.jsx("input",{type:"url",value:ue,onChange:Xe=>q(Xe.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")}),s.jsx("input",{type:"text",value:te,onChange:Xe=>U(Xe.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")}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(Te,{type:"button",variant:"secondary",size:"sm",onClick:Fe,children:n("common.cancel")}),s.jsx(Te,{type:"submit",size:"sm",disabled:!ke.trim()||B.isPending,children:B.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):n("common.save")})]})]}):s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("button",{onClick:()=>a("projects:update")&&le(we),disabled:B.isPending||!a("projects:update"),title:a("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 ${we.is_complete?"bg-status-ok border-status-ok text-white":a("projects:update")?"border-bambu-gray hover:border-bambu-green":"border-bambu-gray/50 cursor-not-allowed"}`,children:we.is_complete&&s.jsx(Ar,{className:"w-3 h-3"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsxs("p",{className:`text-sm font-medium ${we.is_complete?"text-bambu-gray line-through":"text-white"}`,children:[we.name,s.jsxs("span",{className:"text-bambu-gray font-normal ml-2",children:["x",we.quantity_needed]})]}),we.unit_price!==null&&s.jsxs("span",{className:"text-xs text-bambu-green whitespace-nowrap",children:[R,(we.unit_price*we.quantity_needed).toFixed(2)]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>a("projects:update")&&ve(we),disabled:!a("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${a("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:a("projects:update")?n("common.edit"):n("projectDetail.bom.noEditPermission"),children:s.jsx(Zi,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>a("projects:update")&&_e(we.id,we.name),disabled:!a("projects:update"),className:`p-1 rounded transition-colors flex-shrink-0 ${a("projects:update")?"hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:a("projects:update")?n("common.delete"):n("projectDetail.bom.noDeletePermission"),children:s.jsx(an,{className:"w-4 h-4"})})]})]}),we.sourcing_url&&s.jsxs("a",{href:we.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:Xe=>Xe.stopPropagation(),children:[s.jsx(Xr,{className:"w-3 h-3 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:(()=>{try{return new URL(we.sourcing_url).hostname.replace("www.","")}catch{return we.sourcing_url}})()})]}),we.remarks&&s.jsx("p",{className:"mt-1 text-xs text-bambu-gray/80 italic",children:we.remarks})]})]})},we.id)),S.some(we=>we.unit_price!==null)&&s.jsxs("div",{className:"pt-2 mt-2 border-t border-bambu-dark-tertiary flex justify-between text-sm",children:[s.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.bom.totalCost")}),s.jsxs("span",{className:"text-white font-medium",children:[R,S.reduce((we,Xe)=>we+(Xe.unit_price||0)*Xe.quantity_needed,0).toFixed(2)]})]})]}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.bom.empty")})]})}),s.jsx(St,{children:s.jsxs(Nt,{className:"p-4",children:[s.jsx("div",{className:"flex items-center justify-between mb-3",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(q0,{className:"w-5 h-5"}),n("projectDetail.timeline.title")]})}),M?s.jsx("div",{className:"flex items-center justify-center py-4",children:s.jsx(ft,{className:"w-6 h-6 animate-spin text-bambu-green"})}):T&&T.length>0?s.jsx("div",{className:"space-y-3",children:T.slice(0,10).map((we,Xe)=>s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("div",{className:`w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0 ${we.event_type==="print_completed"?"bg-status-ok/20 text-status-ok":we.event_type==="print_failed"?"bg-status-error/20 text-status-error":we.event_type==="print_started"?"bg-yellow-500/20 text-yellow-400":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[we.event_type==="print_completed"&&s.jsx(Ar,{className:"w-4 h-4"}),we.event_type==="print_failed"&&s.jsx(Qi,{className:"w-4 h-4"}),we.event_type==="print_started"&&s.jsx(Ur,{className:"w-4 h-4"}),we.event_type==="queued"&&s.jsx(pj,{className:"w-4 h-4"}),we.event_type==="project_created"&&s.jsx(fr,{className:"w-4 h-4"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white",children:we.title}),we.description&&s.jsx("p",{className:"text-xs text-bambu-gray truncate",children:we.description}),s.jsx("p",{className:"text-xs text-bambu-gray/70",children:He(we.timestamp)})]})]},Xe))}):s.jsx("p",{className:"text-bambu-gray/70 text-sm italic",children:n("projectDetail.timeline.empty")})]})}),!m.is_template&&s.jsx("div",{className:"flex justify-end",children:s.jsxs(Te,{variant:"secondary",size:"sm",onClick:()=>$e.mutate(),disabled:$e.isPending||!a("projects:create"),title:a("projects:create")?void 0:n("projectDetail.template.noCreatePermission"),children:[$e.isPending?s.jsx(ft,{className:"w-4 h-4 animate-spin mr-2"}):s.jsx(Fl,{className:"w-4 h-4 mr-2"}),n("projectDetail.template.saveAsTemplate")]})}),xe&&(xe.queued_prints>0||xe.in_progress_prints>0)&&s.jsx(St,{children:s.jsxs(Nt,{className:"p-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(pj,{className:"w-5 h-5"}),n("projectDetail.queue.title")]}),s.jsx(Ds,{to:`/queue?project=${p}`,className:"text-sm text-bambu-green hover:underline",children:n("projectDetail.queue.viewAll")})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm",children:[xe.in_progress_prints>0&&s.jsx("span",{className:"text-yellow-400",children:n("projectDetail.queue.printing",{count:xe.in_progress_prints})}),xe.queued_prints>0&&s.jsx("span",{className:"text-bambu-gray",children:n("projectDetail.queue.queued",{count:xe.queued_prints})})]})]})}),s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-between mb-4",children:s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(pc,{className:"w-5 h-5"}),n("projectDetail.prints.title",{count:v?.length||0})]})}),y?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(ft,{className:"w-6 h-6 animate-spin text-bambu-green"})}):s.jsx(eXe,{archives:v||[],t:n})]}),o&&s.jsx($re,{t:n,project:{...m,archive_count:xe?.total_archives||0,total_items:xe?.total_items||0,completed_count:xe?.completed_prints||0,failed_count:xe?.failed_prints||0,queue_count:xe?.queued_prints||0,progress_percent:xe?.progress_percent||null,archives:[]},onClose:()=>l(!1),onSave:we=>D.mutate(we),isLoading:D.isPending}),he.isOpen&&s.jsx(Zn,{title:he.title,message:he.message,confirmText:n("common.delete"),variant:"danger",onConfirm:he.onConfirm,onCancel:()=>Me(we=>({...we,isOpen:!1}))})]})}function hg(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 iXe(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 aXe({parentId:t,onClose:e,onSave:n,isLoading:r,t:i}){const[a,o]=_.useState(""),l=c=>{c.preventDefault(),n({name:a.trim(),parent_id:t})};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:i("fileManager.newFolder")})}),s.jsxs("form",{onSubmit:l,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:i("fileManager.folderName")}),s.jsx("input",{type:"text",value:a,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})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:e,children:i("common.cancel")}),s.jsx(Te,{type:"submit",disabled:!a.trim()||r,children:r?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):i("common.create")})]})]})]})})}function sXe({type:t,currentName:e,onClose:n,onSave:r,isLoading:i,t:a}){const[o,l]=_.useState(e),c=u=>{u.preventDefault(),o.trim()&&o.trim()!==e&&r(o.trim())};return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:a(t==="file"?"fileManager.renameFile":"fileManager.renameFolder")})}),s.jsxs("form",{onSubmit:c,className:"p-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-white mb-1",children:a("common.name")}),s.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})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:n,children:a("common.cancel")}),s.jsx(Te,{type:"submit",disabled:!o.trim()||o.trim()===e||i,children:i?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):a("common.rename")})]})]})]})})}function oXe({folders:t,selectedFiles:e,currentFolderId:n,onClose:r,onMove:i,isLoading:a,t:o}){const[l,c]=_.useState(null),u=(f,p=0)=>{const m=[];for(const x of f)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 s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-sm border border-bambu-dark-tertiary",children:[s.jsx("div",{className:"p-4 border-b border-bambu-dark-tertiary",children:s.jsx("h2",{className:"text-lg font-semibold text-white",children:o("fileManager.moveFiles",{count:e.length})})}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1",children:d.map(f=>s.jsxs("button",{onClick:()=>c(f.id),disabled:f.id===n,className:`w-full text-left px-3 py-2 rounded transition-colors flex items-center gap-2 ${l===f.id?"bg-bambu-green/20 text-bambu-green":f.id===n?"opacity-50 cursor-not-allowed text-bambu-gray":"hover:bg-bambu-dark text-white"}`,style:{paddingLeft:`${12+f.depth*16}px`},children:[s.jsx(Il,{className:"w-4 h-4"}),f.name,f.id===n&&s.jsxs("span",{className:"text-xs text-bambu-gray ml-auto",children:["(",o("fileManager.current"),")"]})]},f.id??"root"))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(Te,{type:"button",variant:"secondary",onClick:r,children:o("common.cancel")}),s.jsx(Te,{onClick:()=>i(l),disabled:a,children:a?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):o("common.move")})]})]})]})})}function lXe({folder:t,onClose:e,onLink:n,isLoading:r,t:i}){const[a,o]=_.useState("project"),[l,c]=_.useState(t.project_id||t.archive_id||null);_.useState(()=>{t.archive_id&&o("archive")});const{data:u}=ot({queryKey:["projects"],queryFn:()=>ce.getProjects()}),{data:d}=ot({queryKey:["archives-for-link"],queryFn:()=>ce.getArchives(void 0,void 0,100)}),f=()=>{n(a==="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 s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-md border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsxs("h2",{className:"text-lg font-semibold text-white flex items-center gap-2",children:[s.jsx(uc,{className:"w-5 h-5 text-bambu-green"}),i("fileManager.linkFolder")]}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:i("fileManager.linkFolderDescription",{name:t.name})}),s.jsxs("div",{className:"flex gap-2",children:[s.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 ${a==="project"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[s.jsx(bW,{className:"w-4 h-4"}),i("fileManager.project")]}),s.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 ${a==="archive"?"border-bambu-green bg-bambu-green/10 text-bambu-green":"border-bambu-dark-tertiary text-bambu-gray hover:text-white"}`,children:[s.jsx(ho,{className:"w-4 h-4"}),i("fileManager.archive")]})]}),s.jsx("div",{className:"max-h-64 overflow-y-auto space-y-1 bg-bambu-dark rounded-lg p-2",children:a==="project"?u&&u.length>0?u.map(x=>s.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:[s.jsx("div",{className:"w-3 h-3 rounded-full flex-shrink-0",style:{backgroundColor:x.color||"#00ae42"}}),s.jsx("span",{className:"truncate",children:x.name})]},x.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noProjectsFound")}):d&&d.length>0?d.map(x=>s.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:[s.jsx(zf,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsx("span",{className:"truncate",children:x.print_name||x.filename})]},x.id)):s.jsx("p",{className:"text-sm text-bambu-gray text-center py-4",children:i("fileManager.noArchivesFound")})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-between",children:[m&&s.jsxs(Te,{variant:"danger",onClick:p,disabled:r,children:[s.jsx(RR,{className:"w-4 h-4 mr-2"}),i("fileManager.unlink")]}),s.jsxs("div",{className:`flex gap-2 ${m?"":"ml-auto"}`,children:[s.jsx(Te,{variant:"secondary",onClick:e,children:i("common.cancel")}),s.jsx(Te,{onClick:f,disabled:!l||r,children:r?s.jsx(ft,{className:"w-4 h-4 animate-spin"}):i("fileManager.link")})]})]})]})})}function cXe({folderId:t,onClose:e,onUploadComplete:n,t:r}){const[i,a]=_.useState([]),[o,l]=_.useState(!1),[c,u]=_.useState(!1),[d,f]=_.useState(!0),[p,m]=_.useState(!1),[x,b]=_.useState(!0),v=_.useRef(null),y=P=>{P.preventDefault(),l(!0)},S=P=>{P.preventDefault(),l(!1)},k=P=>{P.preventDefault(),l(!1);const $=Array.from(P.dataTransfer.files);M($)},T=P=>{P.target.files&&M(Array.from(P.target.files))},M=P=>{const $=P.map(X=>({file:X,status:"pending",isZip:X.name.toLowerCase().endsWith(".zip")}));a(X=>[...X,...$])},C=P=>{a($=>$.filter((X,V)=>V!==P))},E=i.some(P=>P.isZip&&P.status==="pending"),R=i.some(P=>P.file.name.toLowerCase().endsWith(".stl")&&P.status==="pending"),A=async()=>{if(i.length!==0){u(!0);for(let P=0;P<i.length;P++)if(i[P].status==="pending"){a($=>$.map((X,V)=>V===P?{...X,status:"uploading"}:X));try{if(i[P].isZip){const $=await ce.extractZipFile(i[P].file,t,d,p,x);a(X=>X.map((V,Q)=>Q===P?{...V,status:$.errors.length>0&&$.extracted===0?"error":"success",extractedCount:$.extracted,error:$.errors.length>0?`${$.errors.length} files failed`:void 0}:V))}else await ce.uploadLibraryFile(i[P].file,t,x),a($=>$.map((X,V)=>V===P?{...X,status:"success"}:X))}catch($){a(X=>X.map((V,Q)=>Q===P?{...V,status:"error",error:$ instanceof Error?$.message:"Upload failed"}:V))}}u(!1),n(),e()}},D=i.filter(P=>P.status==="pending").length,I=i.filter(P=>P.status==="success").length,F=i.filter(P=>P.status==="error").length,z=i.length>0&&D===0&&!c;return s.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",children:s.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg w-full max-w-lg border border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"p-4 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsx("h2",{className:"text-lg font-semibold text-white",children:r("fileManager.uploadFiles")}),s.jsx("button",{onClick:e,className:"p-1 hover:bg-bambu-dark rounded",children:s.jsx(Rt,{className:"w-5 h-5 text-bambu-gray"})})]}),s.jsxs("div",{className:"p-4 space-y-4",children:[s.jsxs("div",{onDragOver:y,onDragLeave:S,onDrop:k,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:[s.jsx(za,{className:`w-10 h-10 mx-auto mb-3 ${o?"text-bambu-green":"text-bambu-gray"}`}),s.jsx("p",{className:"text-white font-medium",children:r(o?"fileManager.dropFilesHere":"fileManager.dragDropFiles")}),s.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:r("fileManager.orClickToBrowse")}),s.jsx("p",{className:"text-xs text-bambu-gray/70 mt-2",children:r("fileManager.allFileTypesSupported")})]}),s.jsx("input",{ref:v,type:"file",multiple:!0,className:"hidden",onChange:T}),E&&s.jsx("div",{className:"p-3 bg-blue-500/10 border border-blue-500/30 rounded-lg",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(ho,{className:"w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-blue-300 font-medium",children:r("fileManager.zipFilesDetected")}),s.jsx("p",{className:"text-xs text-blue-300/70 mt-1",children:r("fileManager.zipExtractOptions")}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:d,onChange:P=>f(P.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("span",{className:"text-sm text-white",children:r("fileManager.preserveZipStructure")})]}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:p,onChange:P=>m(P.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("span",{className:"text-sm text-white",children:r("fileManager.createFolderFromZip")})]})]})]})}),(R||E)&&s.jsx("div",{className:"p-3 bg-bambu-green/10 border border-bambu-green/30 rounded-lg",children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(Ou,{className:"w-5 h-5 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-bambu-green font-medium",children:r("fileManager.stlThumbnailGeneration")}),s.jsx("p",{className:"text-xs text-bambu-green/70 mt-1",children:r(E&&!R?"fileManager.zipMayContainStl":"fileManager.thumbnailsCanBeGenerated")}),s.jsxs("label",{className:"flex items-center gap-2 mt-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:x,onChange:P=>b(P.target.checked),className:"w-4 h-4 rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),s.jsx("span",{className:"text-sm text-white",children:r("fileManager.generateThumbnailsForStl")})]})]})]})}),i.length>0&&s.jsx("div",{className:"max-h-48 overflow-y-auto space-y-2",children:i.map((P,$)=>s.jsxs("div",{className:"flex items-center gap-3 p-2 bg-bambu-dark rounded-lg",children:[P.isZip?s.jsx(ho,{className:"w-4 h-4 text-blue-400 flex-shrink-0"}):s.jsx(uM,{className:"w-4 h-4 text-bambu-gray flex-shrink-0"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-white truncate",children:P.file.name}),s.jsxs("p",{className:"text-xs text-bambu-gray",children:[(P.file.size/1024/1024).toFixed(2)," MB",P.isZip&&P.status==="pending"&&s.jsxs("span",{className:"text-blue-400 ml-2",children:["• ",r("fileManager.willBeExtracted")]}),P.extractedCount!==void 0&&s.jsxs("span",{className:"text-green-400 ml-2",children:["• ",r("fileManager.filesExtracted",{count:P.extractedCount})]})]})]}),P.status==="pending"&&s.jsx("button",{onClick:()=>C($),className:"p-1 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(Rt,{className:"w-4 h-4 text-bambu-gray"})}),P.status==="uploading"&&s.jsx(ft,{className:"w-4 h-4 text-bambu-green animate-spin"}),P.status==="success"&&s.jsx(Ar,{className:"w-4 h-4 text-green-500"}),P.status==="error"&&s.jsx("span",{title:P.error,children:s.jsx(Qi,{className:"w-4 h-4 text-red-500"})})]},$))}),z&&s.jsx("div",{className:"p-3 bg-bambu-dark rounded-lg",children:s.jsxs("p",{className:"text-sm text-white",children:[r("fileManager.uploadComplete",{succeeded:I}),F>0&&s.jsxs("span",{className:"text-red-400",children:[", ",r("fileManager.uploadFailed",{count:F})]})]})})]}),s.jsxs("div",{className:"p-4 border-t border-bambu-dark-tertiary flex justify-end gap-2",children:[s.jsx(Te,{variant:"secondary",onClick:e,children:r(z?"common.close":"common.cancel")}),!z&&s.jsx(Te,{onClick:A,disabled:D===0||c,children:c?s.jsxs(s.Fragment,{children:[s.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}),r("fileManager.uploading")]}):s.jsxs(s.Fragment,{children:[s.jsx(za,{className:"w-4 h-4 mr-2"}),r("common.upload")," ",D>0?`(${D})`:""]})})]})]})})}function Vre({folder:t,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o=0,wrapNames:l=!1,hasPermission:c,t:u}){const[d,f]=_.useState(!0),[p,m]=_.useState(!1),x=t.children.length>0,b=t.project_id||t.archive_id;return s.jsxs("div",{children:[s.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?s.jsx("button",{onClick:v=>{v.stopPropagation(),f(!d)},className:"p-0.5 hover:bg-bambu-dark-tertiary rounded",children:s.jsx(gs,{className:`w-3.5 h-3.5 transition-transform ${d?"rotate-90":""}`})}):s.jsx("div",{className:"w-4.5"}),s.jsx(Il,{className:"w-4 h-4 text-bambu-green flex-shrink-0"}),s.jsx("span",{className:`text-sm flex-1 min-w-0 ${l?"break-all":"truncate"}`,title:t.name,children:t.name}),b&&s.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:[s.jsx(uc,{className:"w-3 h-3"}),t.project_name?s.jsx(bW,{className:"w-3 h-3"}):s.jsx(ho,{className:"w-3 h-3"})]}),t.file_count>0&&s.jsx("span",{className:"flex-shrink-0 text-xs text-bambu-gray",children:t.file_count}),!b&&s.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:s.jsx(uc,{className:"w-3.5 h-3.5 text-bambu-gray hover:text-bambu-green"})}),s.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:s.jsxs("div",{className:"relative",children:[s.jsx("button",{onClick:()=>m(!p),className:"p-1 rounded hover:bg-bambu-dark-tertiary",children:s.jsx(ih,{className:"w-3.5 h-3.5 text-bambu-gray"})}),p&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>m(!1)}),s.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:[s.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")&&(a(t),m(!1))},disabled:!c("library:update_all"),title:c("library:update_all")?void 0:u("fileManager.noPermissionRenameFolder"),children:[s.jsx(Zi,{className:"w-3.5 h-3.5"}),u("common.rename")]}),s.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:[s.jsx(uc,{className:"w-3.5 h-3.5"}),u(b?"fileManager.changeLink":"fileManager.linkTo")]}),s.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:[s.jsx(an,{className:"w-3.5 h-3.5"}),u("common.delete")]})]})]})]})})]}),x&&d&&s.jsx("div",{children:t.children.map(v=>s.jsx(Vre,{folder:v,selectedFolderId:e,onSelect:n,onDelete:r,onLink:i,onRename:a,depth:o+1,wrapNames:l,hasPermission:c,t:u},v.id))})]})}function hR(t){const e=t.toLowerCase();return e.endsWith(".gcode")||e.includes(".gcode.")}function uXe({file:t,isSelected:e,isMobile:n,onSelect:r,onDelete:i,onDownload:a,onAddToQueue:o,onPrint:l,onRename:c,onGenerateThumbnail:u,thumbnailVersion:d,hasPermission:f,canModify:p,t:m}){const[x,b]=_.useState(!1);return s.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:[s.jsxs("div",{className:"aspect-square bg-bambu-dark flex items-center justify-center overflow-hidden",children:[t.thumbnail_path?s.jsx("img",{src:`${ce.getLibraryFileThumbnailUrl(t.id)}${d?`?v=${d}`:""}`,alt:t.filename,className:"w-full h-full object-cover"}):s.jsx(zf,{className:"w-12 h-12 text-bambu-gray/30"}),s.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()})]}),s.jsxs("div",{className:"p-3",children:[s.jsx("h3",{className:"text-sm font-medium text-white truncate",title:t.print_name||t.filename,children:t.print_name||t.filename}),s.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-bambu-gray",children:[s.jsx("span",{children:hg(t.file_size)}),t.print_time_seconds&&s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx(tr,{className:"w-3 h-3"}),iXe(t.print_time_seconds)]})]}),t.print_count>0&&s.jsx("div",{className:"mt-1 text-xs text-bambu-green",children:m("fileManager.printedCount",{count:t.print_count})}),t.created_by_username&&s.jsx("div",{className:"mt-1 text-xs text-bambu-gray",children:m("fileManager.uploadedBy",{name:t.created_by_username})})]}),s.jsxs("div",{className:`absolute bottom-2 right-2 transition-opacity ${n?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:v=>v.stopPropagation(),children:[s.jsx("button",{onClick:()=>b(!x),className:"p-1.5 rounded bg-bambu-dark-secondary/90 hover:bg-bambu-dark-tertiary",children:s.jsx(ih,{className:"w-4 h-4 text-bambu-gray"})}),x&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>b(!1)}),s.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&&hR(t.filename)&&s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("printers:control")?"text-bambu-green hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("printers:control")&&(l(t),b(!1))},disabled:!f("printers:control"),title:f("printers:control")?void 0:m("fileManager.noPermissionPrint"),children:[s.jsx(Ur,{className:"w-3.5 h-3.5"}),m("common.print")]}),o&&hR(t.filename)&&s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("queue:create")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("queue:create")&&(o(t.id),b(!1))},disabled:!f("queue:create"),title:f("queue:create")?void 0:m("fileManager.noPermissionAddToQueue"),children:[s.jsx(tr,{className:"w-3.5 h-3.5"}),m("fileManager.addToQueue")]}),s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${f("library:read")?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{f("library:read")&&(a(t.id),b(!1))},disabled:!f("library:read"),title:f("library:read")?void 0:m("fileManager.noPermissionDownload"),children:[s.jsx(wi,{className:"w-3.5 h-3.5"}),m("common.download")]}),c&&s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","update",t.created_by_id)&&(c(t),b(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:m("fileManager.noPermissionRenameFile"),children:[s.jsx(Zi,{className:"w-3.5 h-3.5"}),m("common.rename")]}),u&&t.file_type==="stl"&&s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","update",t.created_by_id)?"text-white hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","update",t.created_by_id)&&(u(t),b(!1))},disabled:!p("library","update",t.created_by_id),title:p("library","update",t.created_by_id)?void 0:m("fileManager.noPermissionGenerateThumbnail"),children:[s.jsx(Ou,{className:"w-3.5 h-3.5"}),m("fileManager.generateThumbnail")]}),s.jsxs("button",{className:`w-full px-3 py-1.5 text-left text-sm flex items-center gap-2 ${p("library","delete",t.created_by_id)?"text-red-400 hover:bg-bambu-dark":"text-bambu-gray cursor-not-allowed"}`,onClick:()=>{p("library","delete",t.created_by_id)&&(i(t.id),b(!1))},disabled:!p("library","delete",t.created_by_id),title:p("library","delete",t.created_by_id)?void 0:m("fileManager.noPermissionDeleteFile"),children:[s.jsx(an,{className:"w-3.5 h-3.5"}),m("common.delete")]})]})]})]}),s.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&&s.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})})]})}function dXe(){const{t}=Rn(),e=sn(),{showToast:n}=Hn(),{hasPermission:r,hasAnyPermission:i,canModify:a}=Ci(),[o]=wR(),l=o.get("folder"),c=l?parseInt(l,10):null,[u,d]=_.useState(c),[f,p]=_.useState([]),[m,x]=_.useState(!1),[b,v]=_.useState(!1),[y,S]=_.useState(!1),[k,T]=_.useState(null),[M,C]=_.useState(null),[E,R]=_.useState(null),[A,D]=_.useState(null),[I,F]=_.useState(null),[z,P]=_.useState({}),[$,X]=_.useState(()=>localStorage.getItem("library-view-mode")||"grid"),[V,Q]=_.useState(()=>localStorage.getItem("library-wrap-folders")==="true"),[Z,se]=_.useState(()=>{const W=localStorage.getItem("library-sidebar-width");return W?parseInt(W,10):256}),[H,K]=_.useState(!1),re=_.useRef(null);_.useEffect(()=>{if(!H)return;document.body.style.userSelect="none",document.body.style.cursor="col-resize";const W=Ye=>{if(!re.current)return;const bt=re.current.parentElement?.getBoundingClientRect();if(!bt)return;const pt=Ye.clientX-bt.left,Bt=Math.min(500,Math.max(200,pt));se(Bt)},je=()=>{K(!1),document.body.style.userSelect="",document.body.style.cursor="",localStorage.setItem("library-sidebar-width",String(Z))};return document.addEventListener("mousemove",W),document.addEventListener("mouseup",je),()=>{document.removeEventListener("mousemove",W),document.removeEventListener("mouseup",je),document.body.style.userSelect="",document.body.style.cursor=""}},[H,Z]);const[ne,be]=_.useState(""),[me,de]=_.useState("all"),[Ce,ie]=_.useState(()=>localStorage.getItem("library-sort-field")||"name"),[ke,Oe]=_.useState(()=>localStorage.getItem("library-sort-direction")||"asc"),pe=IR();_.useEffect(()=>{const W=o.get("folder");if(W){const je=parseInt(W,10);d(je)}},[o]);const{data:We}=ot({queryKey:["settings"],queryFn:()=>ce.getSettings()}),{data:G,isLoading:Y}=ot({queryKey:["library-folders"],queryFn:()=>ce.getLibraryFolders()}),{data:ue,isLoading:q}=ot({queryKey:["library-files",u],queryFn:()=>ce.getLibraryFiles(u,u===null)}),{data:te}=ot({queryKey:["library-stats"],queryFn:()=>ce.getLibraryStats()}),U=_.useMemo(()=>{if(!ue)return[];const W=new Set(ue.map(je=>je.file_type));return Array.from(W).sort()},[ue]),he=_.useMemo(()=>{if(!ue)return[];let W=[...ue];if(ne.trim()){const je=ne.toLowerCase();W=W.filter(Ye=>Ye.filename.toLowerCase().includes(je)||Ye.print_name&&Ye.print_name.toLowerCase().includes(je))}return me!=="all"&&(W=W.filter(je=>je.file_type===me)),W.sort((je,Ye)=>{let bt=0;switch(Ce){case"name":bt=(je.print_name||je.filename).localeCompare(Ye.print_name||Ye.filename);break;case"date":bt=new Date(je.created_at).getTime()-new Date(Ye.created_at).getTime();break;case"size":bt=je.file_size-Ye.file_size;break;case"type":bt=je.file_type.localeCompare(Ye.file_type);break;case"prints":bt=je.print_count-Ye.print_count;break}return ke==="asc"?bt:-bt}),W},[ue,ne,me,Ce,ke]),Me=_.useMemo(()=>{if(!te||!We)return!1;const W=(We.library_disk_warning_gb||5)*1024*1024*1024;return te.disk_free_bytes<W},[te,We]),ge=mt({mutationFn:W=>ce.createLibraryFolder(W),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),x(!1),n(t("fileManager.toast.folderCreated"),"success")},onError:W=>n(W.message,"error")}),B=mt({mutationFn:W=>ce.deleteLibraryFolder(W),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-stats"]}),u===M?.id&&d(null),C(null),n(t("fileManager.toast.folderDeleted"),"success")},onError:W=>{C(null),n(W.message,"error")}}),O=mt({mutationFn:W=>ce.deleteLibraryFile(W),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]}),p(W=>W.filter(je=>je!==M?.id)),C(null),n(t("fileManager.toast.fileDeleted"),"success")},onError:W=>{C(null),n(W.message,"error")}}),ee=mt({mutationFn:W=>ce.bulkDeleteLibrary(W,[]),onSuccess:(W,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:W=>{C(null),n(W.message,"error")}}),le=mt({mutationFn:({fileIds:W,folderId:je})=>ce.moveLibraryFiles(W,je),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),p([]),v(!1),n(t("fileManager.toast.filesMoved"),"success")},onError:W=>n(W.message,"error")}),_e=mt({mutationFn:({id:W,data:je})=>ce.updateLibraryFolder(W,je),onSuccess:(W,je)=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["project-folders"]}),e.invalidateQueries({queryKey:["archive-folders"]}),T(null);const Ye=je.data.project_id===0&&je.data.archive_id===0;n(t(Ye?"fileManager.toast.folderUnlinked":"fileManager.toast.folderLinked"),"success")},onError:W=>n(W.message,"error")}),ve=mt({mutationFn:W=>ce.addLibraryFilesToQueue(W),onSuccess:W=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["queue"]}),e.invalidateQueries({queryKey:["archives"]}),p([]),W.added.length>0&&W.errors.length===0?n(t("fileManager.toast.addedToQueue",{count:W.added.length}),"success"):W.added.length>0&&W.errors.length>0?n(t("fileManager.toast.addedToQueuePartial",{added:W.added.length,failed:W.errors.length}),"success"):n(t("fileManager.toast.failedToAddToQueue",{error:W.errors[0]?.error||"Unknown error"}),"error")},onError:W=>n(W.message,"error")}),ae=mt({mutationFn:({id:W,filename:je})=>ce.updateLibraryFile(W,{filename:je}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-files"]}),F(null),n(t("fileManager.toast.fileRenamed"),"success")},onError:W=>{F(null),n(W.message,"error")}}),Fe=mt({mutationFn:({id:W,name:je})=>ce.updateLibraryFolder(W,{name:je}),onSuccess:()=>{e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-files"]}),F(null),n(t("fileManager.toast.folderRenamed"),"success")},onError:W=>{F(null),n(W.message,"error")}}),Be=mt({mutationFn:()=>ce.batchGenerateStlThumbnails({all_missing:!0}),onSuccess:W=>{if(e.invalidateQueries({queryKey:["library-files"]}),W.succeeded>0){const je=Date.now(),Ye={};W.results.forEach(bt=>{bt.success&&(Ye[bt.file_id]=je)}),P(bt=>({...bt,...Ye}))}W.succeeded>0&&W.failed===0?n(t("fileManager.toast.thumbnailsGenerated",{count:W.succeeded}),"success"):W.succeeded>0&&W.failed>0?n(t("fileManager.toast.thumbnailsGeneratedPartial",{succeeded:W.succeeded,failed:W.failed}),"success"):W.processed===0?n(t("fileManager.toast.noStlMissingThumbnails"),"info"):n(t("fileManager.toast.failedToGenerateThumbnails",{error:W.results[0]?.error||"Unknown error"}),"error")},onError:W=>n(W.message,"error")}),$e=mt({mutationFn:W=>ce.batchGenerateStlThumbnails({file_ids:[W]}),onSuccess:W=>{if(e.invalidateQueries({queryKey:["library-files"]}),W.succeeded>0){const je=W.results[0]?.file_id;je&&P(Ye=>({...Ye,[je]:Date.now()})),n(t("fileManager.toast.thumbnailGenerated"),"success")}else n(t("fileManager.toast.failedToGenerateThumbnail",{error:W.results[0]?.error||"Unknown error"}),"error")},onError:W=>n(W.message,"error")}),He=_.useCallback(W=>{const je=W.toLowerCase();return je.endsWith(".gcode")||je.includes(".gcode.")},[]),xe=_.useMemo(()=>ue?ue.filter(W=>f.includes(W.id)&&He(W.filename)):[],[ue,f,He]),Pe=_.useCallback(W=>{p(je=>je.includes(W)?je.filter(Ye=>Ye!==W):[...je,W])},[]),ze=_.useCallback(()=>{he.length>0&&p(he.map(W=>W.id))},[he]),we=_.useCallback(()=>{p([])},[]),Xe=()=>{e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["library-folders"]}),e.invalidateQueries({queryKey:["library-stats"]})},Ne=W=>{ce.downloadLibraryFile(W).catch(je=>{console.error("Library file download failed:",je)})},rt=()=>{M&&(M.type==="file"?O.mutate(M.id):M.type==="folder"?B.mutate(M.id):M.type==="bulk"&&ee.mutate(f))},Ee=B.isPending||O.isPending||ee.isPending,Ke=W=>{X(W),localStorage.setItem("library-view-mode",W)},Ue=Y||q;return s.jsxs("div",{className:"p-4 md:p-8 min-h-[calc(100vh-64px)] lg:h-[calc(100vh-64px)] flex flex-col",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"text-2xl font-bold text-white flex items-center gap-3",children:[s.jsx("div",{className:"p-2.5 bg-bambu-green/10 rounded-xl",children:s.jsx(Il,{className:"w-6 h-6 text-bambu-green"})}),t("fileManager.title")]}),s.jsx("p",{className:"text-sm text-bambu-gray mt-2 ml-14",children:t("fileManager.subtitle")})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex items-center bg-bambu-dark rounded-lg p-1",children:[s.jsx("button",{onClick:()=>Ke("grid"),className:`p-1.5 rounded transition-colors ${$==="grid"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.gridView"),children:s.jsx(mM,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>Ke("list"),className:`p-1.5 rounded transition-colors ${$==="list"?"bg-bambu-card text-white":"text-bambu-gray hover:text-white"}`,title:t("fileManager.listView"),children:s.jsx(pM,{className:"w-4 h-4"})})]}),s.jsxs(Te,{variant:"secondary",onClick:()=>Be.mutate(),disabled:Be.isPending||!i("library:update_own","library:update_all"),title:i("library:update_own","library:update_all")?t("fileManager.generateThumbnailsForMissing"):t("fileManager.noPermissionGenerateThumbnail"),children:[Be.isPending?s.jsx(ft,{className:"w-4 h-4 mr-2 animate-spin"}):s.jsx(Ou,{className:"w-4 h-4 mr-2"}),t("fileManager.generateThumbnails")]}),s.jsxs(Te,{variant:"secondary",onClick:()=>x(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionCreateFolder"),children:[s.jsx(Hue,{className:"w-4 h-4 mr-2"}),t("fileManager.newFolder")]}),s.jsxs(Te,{onClick:()=>S(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[s.jsx(za,{className:"w-4 h-4 mr-2"}),t("common.upload")]})]})]}),Me&&te&&We&&s.jsxs("div",{className:"flex items-center gap-3 mb-4 p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:[s.jsx(Sn,{className:"w-5 h-5 text-amber-500 flex-shrink-0"}),s.jsxs("div",{className:"flex-1",children:[s.jsx("p",{className:"text-sm text-amber-500 font-medium",children:t("fileManager.lowDiskSpaceWarning")}),s.jsx("p",{className:"text-xs text-amber-500/80",children:t("fileManager.lowDiskSpaceDetails",{free:hg(te.disk_free_bytes),total:hg(te.disk_total_bytes),threshold:We.library_disk_warning_gb})})]})]}),te&&s.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:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(uM,{className:"w-4 h-4 text-bambu-green"}),s.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.files"),":"]}),s.jsx("span",{className:"text-white font-medium",children:te.total_files})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(Il,{className:"w-4 h-4 text-blue-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.folders"),":"]}),s.jsx("span",{className:"text-white font-medium",children:te.total_folders})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(fM,{className:"w-4 h-4 text-amber-400"}),s.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.size"),":"]}),s.jsx("span",{className:"text-white font-medium",children:hg(te.total_size_bytes)})]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm sm:ml-auto",children:[s.jsxs("span",{className:"text-bambu-gray",children:[t("fileManager.free"),":"]}),s.jsx("span",{className:`font-medium ${Me?"text-amber-500":"text-white"}`,children:hg(te.disk_free_bytes)})]})]}),s.jsxs("div",{className:"flex-1 flex flex-col lg:flex-row gap-4 lg:gap-6 min-h-0",children:[s.jsx("div",{className:"lg:hidden",children:s.jsxs("select",{value:u??"",onChange:W=>d(W.target.value?parseInt(W.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:[s.jsxs("option",{value:"",children:["📁 ",t("fileManager.allFiles")]}),G&&(()=>{const W=(je,Ye=0)=>{const bt=[];for(const pt of je)bt.push({id:pt.id,name:pt.name,fileCount:pt.file_count,depth:Ye}),pt.children.length>0&&bt.push(...W(pt.children,Ye+1));return bt};return W(G).map(je=>s.jsxs("option",{value:je.id,children:["│ ".repeat(je.depth),"📂 ",je.name," ",je.fileCount>0?`(${je.fileCount})`:""]},je.id))})()]})}),s.jsxs("div",{ref:re,className:"hidden lg:flex flex-shrink-0 bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden flex-col relative",style:{width:`${Z}px`},children:[s.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 ${H?"bg-bambu-green":"hover:bg-bambu-green/50"}`,onMouseDown:W=>{W.preventDefault(),K(!0)},onDoubleClick:()=>{se(256),localStorage.setItem("library-sidebar-width","256")},title:t("fileManager.dragToResizeTooltip"),children:s.jsxs("div",{className:`flex flex-col gap-1 opacity-0 group-hover/resize:opacity-100 transition-opacity ${H?"opacity-100":""}`,children:[s.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),s.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"}),s.jsx("div",{className:"w-0.5 h-0.5 rounded-full bg-white/70"})]})}),s.jsxs("div",{className:"p-3 border-b border-bambu-dark-tertiary flex items-center justify-between",children:[s.jsx("h2",{className:"text-sm font-medium text-white",children:t("fileManager.folders")}),s.jsx("button",{onClick:()=>{const W=!V;Q(W),localStorage.setItem("library-wrap-folders",String(W))},className:`text-xs px-1.5 py-0.5 rounded transition-colors ${V?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:text-white hover:bg-bambu-dark"}`,title:t(V?"fileManager.disableTextWrapping":"fileManager.enableTextWrapping"),children:t("fileManager.wrap")})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-2",children:[s.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:[s.jsx(zf,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm",children:t("fileManager.allFiles")})]}),G?.map(W=>s.jsx(Vre,{folder:W,selectedFolderId:u,onSelect:d,onDelete:je=>C({type:"folder",id:je}),onLink:T,onRename:je=>F({type:"folder",id:je.id,name:je.name}),wrapNames:V,hasPermission:r,t},W.id))]})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0 min-h-0",children:[ue&&ue.length>0&&s.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:[s.jsxs("div",{className:"relative w-full sm:w-auto sm:flex-1 sm:max-w-xs",children:[s.jsx(ya,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:t("fileManager.searchFiles"),value:ne,onChange:W=>be(W.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"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(dM,{className:"w-4 h-4 text-bambu-gray hidden sm:block"}),s.jsxs("select",{value:me,onChange:W=>de(W.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:[s.jsx("option",{value:"all",children:t("fileManager.allTypes")}),U.map(W=>s.jsx("option",{value:W,children:W.toUpperCase()},W))]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("select",{value:Ce,onChange:W=>{const je=W.target.value;ie(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:[s.jsx("option",{value:"name",children:t("common.name")}),s.jsx("option",{value:"date",children:t("common.date")}),s.jsx("option",{value:"size",children:t("fileManager.size")}),s.jsx("option",{value:"type",children:t("common.type")}),s.jsx("option",{value:"prints",children:t("fileManager.prints")})]}),s.jsx("button",{onClick:()=>Oe(W=>{const je=W==="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(ke==="asc"?"fileManager.ascending":"fileManager.descending"),children:ke==="asc"?s.jsx(bce,{className:"w-4 h-4 text-white"}):s.jsx(uce,{className:"w-4 h-4 text-white"})})]}),(ne||me!=="all")&&s.jsx("span",{className:"text-sm text-bambu-gray hidden sm:inline",children:t("fileManager.resultsCount",{showing:he.length,total:ue.length})})]}),he.length>0&&s.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:[f.length===he.length&&f.length>0?s.jsxs(Te,{variant:"secondary",size:"sm",onClick:we,children:[s.jsx(ll,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("fileManager.deselectAll")})]}):s.jsxs(Te,{variant:"secondary",size:"sm",onClick:ze,children:[s.jsx(ol,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("fileManager.selectAll")})]}),f.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-sm text-bambu-gray ml-2",children:t("fileManager.selected",{count:f.length})}),s.jsx("div",{className:"hidden sm:block flex-1"}),s.jsxs("div",{className:"w-full sm:w-auto flex flex-wrap items-center gap-2 mt-2 sm:mt-0",children:[xe.length===1&&s.jsxs(Te,{variant:"primary",size:"sm",onClick:()=>D(xe[0]),disabled:!r("printers:control"),title:r("printers:control")?void 0:t("fileManager.noPermissionPrint"),children:[s.jsx(bo,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("common.print")})]}),xe.length>0&&s.jsxs(Te,{variant:xe.length===1?"secondary":"primary",size:"sm",onClick:()=>ve.mutate(xe.map(W=>W.id)),disabled:ve.isPending||!r("queue:create"),title:r("queue:create")?void 0:t("fileManager.noPermissionAddToQueue"),children:[s.jsx(tr,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:ve.isPending?t("fileManager.adding"):`${t("fileManager.addToQueue")}${xe.length<f.length?` (${xe.length})`:""}`})]}),s.jsxs(Te,{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:[s.jsx(Yde,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("common.move")})]}),s.jsxs(Te,{variant:"danger",size:"sm",onClick:()=>{f.length===1?C({type:"file",id:f[0]}):C({type:"bulk",id:0,count:f.length})},disabled:!i("library:delete_own","library:delete_all"),title:i("library:delete_own","library:delete_all")?void 0:t("fileManager.noPermissionDeleteFiles"),children:[s.jsx(an,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("common.delete")})]}),s.jsxs(Te,{variant:"secondary",size:"sm",onClick:we,children:[s.jsx(Rt,{className:"w-4 h-4 sm:mr-1"}),s.jsx("span",{className:"hidden sm:inline",children:t("common.clear")})]})]})]})]}),Ue?s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsxs("div",{className:"flex flex-col items-center gap-3",children:[s.jsx(ft,{className:"w-8 h-8 animate-spin text-bambu-green"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("fileManager.loadingFiles")})]})}):ue?.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(zf,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t(u!==null?"fileManager.folderIsEmpty":"fileManager.noFilesYet")}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t(u!==null?"fileManager.folderEmptyDescription":"fileManager.noFilesDescription")}),s.jsxs(Te,{onClick:()=>S(!0),disabled:!r("library:upload"),title:r("library:upload")?void 0:t("fileManager.noPermissionUpload"),children:[s.jsx(fr,{className:"w-4 h-4 mr-2"}),t("fileManager.uploadFiles")]})]}):he.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center",children:[s.jsx("div",{className:"p-4 bg-bambu-dark rounded-2xl mb-4",children:s.jsx(ya,{className:"w-12 h-12 text-bambu-gray/50"})}),s.jsx("h3",{className:"text-lg font-medium text-white mb-2",children:t("fileManager.noMatchingFiles")}),s.jsx("p",{className:"text-bambu-gray text-center max-w-md mb-6",children:t("fileManager.noMatchingFilesDescription")}),s.jsx(Te,{variant:"secondary",onClick:()=>{be(""),de("all")},children:t("fileManager.clearFilters")})]}):$==="grid"?s.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:s.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:he.map(W=>s.jsx(uXe,{file:W,isSelected:f.includes(W.id),isMobile:pe,t,onSelect:Pe,onDelete:je=>C({type:"file",id:je}),onDownload:Ne,onAddToQueue:je=>ve.mutate([je]),onPrint:R,onRename:je=>F({type:"file",id:je.id,name:je.filename}),onGenerateThumbnail:je=>$e.mutate(je.id),thumbnailVersion:z[W.id],hasPermission:r,canModify:a},W.id))})}):s.jsx("div",{className:"flex-1 lg:overflow-y-auto",children:s.jsxs("div",{className:"bg-bambu-card rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[s.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:[s.jsx("div",{className:"w-6"}),s.jsx("div",{children:t("common.name")}),s.jsx("div",{children:t("common.type")}),s.jsx("div",{children:t("fileManager.size")}),s.jsx("div",{children:t("fileManager.prints")}),s.jsx("div",{})]}),he.map(W=>s.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 ${f.includes(W.id)?"bg-bambu-green/10":""}`,onClick:()=>Pe(W.id),children:[s.jsx("div",{className:`w-5 h-5 rounded border-2 flex items-center justify-center ${f.includes(W.id)?"bg-bambu-green border-bambu-green":"border-bambu-gray/50"}`,children:f.includes(W.id)&&s.jsx("div",{className:"w-2 h-2 bg-white rounded-sm"})}),s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsxs("div",{className:"relative group/thumb",children:[s.jsx("div",{className:"w-10 h-10 rounded bg-bambu-dark flex-shrink-0 overflow-hidden",children:W.thumbnail_path?s.jsx("img",{src:`${ce.getLibraryFileThumbnailUrl(W.id)}${z[W.id]?`?v=${z[W.id]}`:""}`,alt:"",className:"w-full h-full object-cover"}):s.jsx("div",{className:"w-full h-full flex items-center justify-center",children:s.jsx(zf,{className:"w-5 h-5 text-bambu-gray/50"})})}),W.thumbnail_path&&s.jsx("div",{className:"absolute left-0 top-full mt-2 z-50 hidden group-hover/thumb:block",children:s.jsx("div",{className:"w-48 h-48 rounded-lg bg-bambu-dark-secondary border border-bambu-dark-tertiary shadow-xl overflow-hidden",children:s.jsx("img",{src:`${ce.getLibraryFileThumbnailUrl(W.id)}${z[W.id]?`?v=${z[W.id]}`:""}`,alt:W.filename,className:"w-full h-full object-contain"})})})]}),s.jsx("div",{className:"min-w-0",children:s.jsx("div",{className:"text-sm text-white truncate",children:W.print_name||W.filename})})]}),s.jsx("div",{children:s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${W.file_type==="3mf"?"bg-bambu-green/20 text-bambu-green":W.file_type==="gcode"?"bg-blue-500/20 text-blue-400":W.file_type==="stl"?"bg-purple-500/20 text-purple-400":"bg-bambu-gray/20 text-bambu-gray"}`,children:W.file_type.toUpperCase()})}),s.jsx("div",{className:"text-sm text-bambu-gray",children:hg(W.file_size)}),s.jsx("div",{className:"text-sm text-bambu-gray",children:W.print_count>0?`${W.print_count}x`:"-"}),s.jsxs("div",{className:"flex items-center gap-1",onClick:je=>je.stopPropagation(),children:[hR(W.filename)&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>r("printers:control")&&R(W),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:s.jsx(Ur,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>r("queue:create")&&ve.mutate([W.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:ve.isPending||!r("queue:create"),children:s.jsx(tr,{className:"w-4 h-4"})})]}),s.jsx("button",{onClick:()=>r("library:read")&&Ne(W.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:s.jsx(wi,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>a("library","update",W.created_by_id)&&F({type:"file",id:W.id,name:W.filename}),className:`p-1.5 rounded transition-colors ${a("library","update",W.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-white":"text-bambu-gray/50 cursor-not-allowed"}`,title:a("library","update",W.created_by_id)?t("common.rename"):t("fileManager.noPermissionRenameFile"),disabled:!a("library","update",W.created_by_id),children:s.jsx(Zi,{className:"w-4 h-4"})}),W.file_type==="stl"&&s.jsx("button",{onClick:()=>a("library","update",W.created_by_id)&&$e.mutate(W.id),className:`p-1.5 rounded transition-colors ${a("library","update",W.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green":"text-bambu-gray/50 cursor-not-allowed"}`,title:a("library","update",W.created_by_id)?t("fileManager.generateThumbnail"):t("fileManager.noPermissionGenerateThumbnail"),disabled:$e.isPending||!a("library","update",W.created_by_id),children:s.jsx(Ou,{className:"w-4 h-4"})}),s.jsx("button",{onClick:()=>a("library","delete",W.created_by_id)&&C({type:"file",id:W.id}),className:`p-1.5 rounded transition-colors ${a("library","delete",W.created_by_id)?"hover:bg-bambu-dark text-bambu-gray hover:text-red-400":"text-bambu-gray/50 cursor-not-allowed"}`,title:a("library","delete",W.created_by_id)?t("common.delete"):t("fileManager.noPermissionDeleteFile"),disabled:!a("library","delete",W.created_by_id),children:s.jsx(an,{className:"w-4 h-4"})})]})]},W.id))]})})]})]}),m&&s.jsx(aXe,{parentId:u,onClose:()=>x(!1),onSave:W=>ge.mutate(W),isLoading:ge.isPending,t}),b&&G&&s.jsx(oXe,{folders:G,selectedFiles:f,currentFolderId:u,onClose:()=>v(!1),onMove:W=>le.mutate({fileIds:f,folderId:W}),isLoading:le.isPending,t}),y&&s.jsx(cXe,{folderId:u,onClose:()=>S(!1),onUploadComplete:Xe,t}),k&&s.jsx(lXe,{folder:k,onClose:()=>T(null),onLink:W=>_e.mutate({id:k.id,data:W}),isLoading:_e.isPending,t}),M&&s.jsx(Zn,{title:M.type==="folder"?t("fileManager.deleteFolder"):M.type==="bulk"?t("fileManager.deleteFilesCount",{count:M.count}):t("fileManager.deleteFile"),message:M.type==="folder"?t("fileManager.deleteFolderConfirm"):M.type==="bulk"?t("fileManager.deleteFilesConfirm",{count:M.count}):t("fileManager.deleteFileConfirm"),confirmText:t("common.delete"),variant:"danger",isLoading:Ee,loadingText:t("fileManager.deleting"),onConfirm:rt,onCancel:()=>C(null)}),E&&s.jsx(Ph,{mode:"reprint",libraryFileId:E.id,archiveName:E.print_name||E.filename,onClose:()=>R(null),onSuccess:()=>{R(null),e.invalidateQueries({queryKey:["library-files"]}),e.invalidateQueries({queryKey:["archives"]})}}),A&&s.jsx(Ph,{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"]})}}),I&&s.jsx(sXe,{type:I.type,currentName:I.name,onClose:()=>F(null),onSave:W=>{I.type==="file"?ae.mutate({id:I.id,filename:W}):Fe.mutate({id:I.id,name:W})},isLoading:ae.isPending||Fe.isPending,t})]})}const KP=5,hXe=2e3,fXe=3e4,mXe=5e3;function pXe(){const{t}=Rn(),{printerId:e}=iM(),n=parseInt(e||"0",10),[r,i]=_.useState("stream"),[a,o]=_.useState(!1),[l,c]=_.useState(!0),[u,d]=_.useState(Date.now()),[f,p]=_.useState(!1),[m,x]=_.useState(!1),[b,v]=_.useState(0),[y,S]=_.useState(!1),[k,T]=_.useState(0),[M,C]=_.useState(1),[E,R]=_.useState({x:0,y:0}),[A,D]=_.useState(!1),[I,F]=_.useState({x:0,y:0}),[z,P]=_.useState(null),[$,X]=_.useState(null),V=_.useRef(null),Q=_.useRef(null),Z=_.useRef(null),se=_.useRef(null),H=_.useRef(null),{data:K}=ot({queryKey:["printer",n],queryFn:()=>ce.getPrinter(n),enabled:n>0});_.useEffect(()=>(K&&(document.title=`${K.name} - Camera`),()=>{document.title="Bambuddy"}),[K]);const re=_.useRef(!1);_.useEffect(()=>{const le=`/api/v1/printers/${n}/camera/stop`;re.current=!1;const _e=()=>{n>0&&!re.current&&(re.current=!0,navigator.sendBeacon(le))},ve=()=>{_e()};window.addEventListener("beforeunload",ve);const ae=V.current;return()=>{window.removeEventListener("beforeunload",ve),ae&&(ae.src=""),_e()}},[n]),_.useEffect(()=>{if(l&&!f){const _e=setTimeout(()=>{c(!1)},r==="stream"?3e3:2e4);return()=>clearTimeout(_e)}},[r,l,u,f]),_.useEffect(()=>{const le=()=>{const _e=!!document.fullscreenElement;x(_e),C(1),R({x:0,y:0}),r==="stream"&&!f&&(V.current&&(V.current.src=""),setTimeout(()=>{c(!0),d(Date.now())},200))};return document.addEventListener("fullscreenchange",le),()=>document.removeEventListener("fullscreenchange",le)},[r,f]),_.useEffect(()=>{let le;const _e=()=>{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",_e),()=>{clearTimeout(le),window.removeEventListener("resize",_e)}},[]),_.useEffect(()=>()=>{Z.current&&clearTimeout(Z.current),se.current&&clearInterval(se.current),H.current&&clearInterval(H.current)},[]);const ne=_.useCallback(()=>{if(b>=KP){S(!1),o(!0);return}const le=Math.min(hXe*Math.pow(2,b),fXe);S(!0),T(Math.ceil(le/1e3)),se.current=setInterval(()=>{T(_e=>_e<=1?(se.current&&clearInterval(se.current),0):_e-1)},1e3),Z.current=setTimeout(()=>{v(_e=>_e+1),S(!1),c(!0),o(!1),V.current&&(V.current.src=""),d(Date.now())},le)},[b]);_.useEffect(()=>{if(r!=="stream"||l||y||f){H.current&&(clearInterval(H.current),H.current=null);return}return H.current=setInterval(async()=>{try{const le=await ce.getCameraStatus(n);(le.stalled||!le.active&&!a)&&(console.log(`Stream issue detected: stalled=${le.stalled}, active=${le.active}, reconnecting...`),H.current&&(clearInterval(H.current),H.current=null),c(!1),ne())}catch{}},mXe),()=>{H.current&&(clearInterval(H.current),H.current=null)}},[r,l,a,y,f,n,ne]);const be=()=>{c(!1),r==="stream"&&b<KP?ne():o(!0)},me=()=>{if(c(!1),o(!1),v(0),S(!1),Z.current&&clearTimeout(Z.current),se.current&&clearInterval(se.current),V.current&&!localStorage.getItem("cameraWindowState")){const le=V.current,_e=le.naturalWidth,ve=le.naturalHeight;if(_e>0&&ve>0){const Be=window.outerWidth-window.innerWidth,$e=window.outerHeight-window.innerHeight,He=_e+16+Be,xe=ve+45+16+$e;try{window.resizeTo(He,xe)}catch{}}}},de=()=>{n>0&&fetch(`/api/v1/printers/${n}/camera/stop`).catch(()=>{})},Ce=le=>{r===le||f||(p(!0),c(!0),o(!1),v(0),S(!1),C(1),R({x:0,y:0}),Z.current&&clearTimeout(Z.current),se.current&&clearInterval(se.current),V.current&&(V.current.src=""),r==="stream"&&de(),setTimeout(()=>{i(le),d(Date.now()),p(!1)},100))},ie=()=>{f||(p(!0),c(!0),o(!1),v(0),S(!1),Z.current&&clearTimeout(Z.current),se.current&&clearInterval(se.current),V.current&&(V.current.src=""),r==="stream"&&de(),setTimeout(()=>{d(Date.now()),p(!1)},100))},ke=()=>{Q.current&&(document.fullscreenElement?document.exitFullscreen():Q.current.requestFullscreen())},Oe=()=>{C(le=>Math.min(le+.5,4))},pe=()=>{C(le=>{const _e=Math.max(le-.5,1);return _e===1&&R({x:0,y:0}),_e})},We=le=>{le.preventDefault(),le.deltaY<0?Oe():pe()},G=le=>{M>1&&(le.preventDefault(),D(!0),F({x:le.clientX-E.x,y:le.clientY-E.y}))},Y=_.useCallback(()=>{if(!Q.current)return{x:300,y:200};const le=Q.current.getBoundingClientRect(),_e=le.width*(M-1)/2,ve=le.height*(M-1)/2;return{x:Math.max(50,_e),y:Math.max(50,ve)}},[M]),ue=le=>{if(A&&M>1){const _e=le.clientX-I.x,ve=le.clientY-I.y,ae=Y();R({x:Math.max(-ae.x,Math.min(ae.x,_e)),y:Math.max(-ae.y,Math.min(ae.y,ve))})}},q=()=>{D(!1)},te=le=>{if(le.length<2)return 0;const _e=le[0].clientX-le[1].clientX,ve=le[0].clientY-le[1].clientY;return Math.sqrt(_e*_e+ve*ve)},U=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(),P(te(le.touches)),X(U(le.touches))):le.touches.length===1&&M>1&&(le.preventDefault(),D(!0),F({x:le.touches[0].clientX-E.x,y:le.touches[0].clientY-E.y}))},Me=le=>{if(le.touches.length===2&&z!==null){le.preventDefault();const _e=te(le.touches),ve=_e/z;C(Fe=>{const Be=Math.max(1,Math.min(4,Fe*ve));return Be===1&&R({x:0,y:0}),Be}),P(_e);const ae=U(le.touches);if($){const Fe=Y();R(Be=>({x:Math.max(-Fe.x,Math.min(Fe.x,Be.x+(ae.x-$.x))),y:Math.max(-Fe.y,Math.min(Fe.y,Be.y+(ae.y-$.y)))}))}X(ae)}else if(le.touches.length===1&&A&&M>1){le.preventDefault();const _e=le.touches[0].clientX-I.x,ve=le.touches[0].clientY-I.y,ae=Y();R({x:Math.max(-ae.x,Math.min(ae.x,_e)),y:Math.max(-ae.y,Math.min(ae.y,ve))})}},ge=le=>{le.touches.length<2&&(P(null),X(null)),le.touches.length===0&&D(!1)},B=()=>{C(1),R({x:0,y:0})},O=f?"":r==="stream"?`/api/v1/printers/${n}/camera/stream?fps=15&t=${u}`:`/api/v1/printers/${n}/camera/snapshot?t=${u}`,ee=l||f||y;return n?s.jsxs("div",{ref:Q,className:"min-h-screen bg-black flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary",children:[s.jsxs("h1",{className:"text-sm font-medium text-white flex items-center gap-2",children:[s.jsx(Ug,{className:"w-4 h-4"}),K?.name||`Printer ${n}`]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"flex bg-bambu-dark rounded p-0.5",children:[s.jsx("button",{onClick:()=>Ce("stream"),disabled:ee,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")}),s.jsx("button",{onClick:()=>Ce("snapshot"),disabled:ee,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")})]}),s.jsx("button",{onClick:ie,disabled:ee,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50",title:t(r==="stream"?"camera.restartStream":"camera.refreshSnapshot"),children:s.jsx(Dr,{className:`w-4 h-4 text-bambu-gray ${ee?"animate-spin":""}`})}),s.jsx("button",{onClick:ke,className:"p-1.5 hover:bg-bambu-dark-tertiary rounded",title:t(m?"camera.exitFullscreen":"camera.fullscreen"),children:m?s.jsx(kW,{className:"w-4 h-4 text-bambu-gray"}):s.jsx(Ide,{className:"w-4 h-4 text-bambu-gray"})})]})]}),s.jsx("div",{className:"flex-1 flex items-center justify-center p-2 overflow-hidden",onWheel:We,onMouseMove:ue,onMouseUp:q,onMouseLeave:q,onTouchStart:he,onTouchMove:Me,onTouchEnd:ge,style:{touchAction:"none"},children:s.jsxs("div",{className:"relative w-full h-full flex items-center justify-center",children:[(l||f)&&!y&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 z-10",children:s.jsxs("div",{className:"text-center",children:[s.jsx(Dr,{className:"w-8 h-8 text-bambu-gray animate-spin mx-auto mb-2"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t(r==="stream"?"camera.connectingToCamera":"camera.capturingSnapshot")})]})}),y&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/80 z-10",children:s.jsxs("div",{className:"text-center p-4",children:[s.jsx(sm,{className:"w-10 h-10 text-orange-400 mx-auto mb-3"}),s.jsx("p",{className:"text-white mb-2",children:t("camera.connectionLost")}),s.jsx("p",{className:"text-sm text-bambu-gray mb-3",children:t("camera.reconnecting",{countdown:k,attempt:b+1,max:KP})}),s.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")})]})}),a&&!y&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black z-10",children:s.jsxs("div",{className:"text-center p-4",children:[s.jsx(Sn,{className:"w-12 h-12 text-orange-400 mx-auto mb-3"}),s.jsx("p",{className:"text-white mb-2",children:t("camera.cameraUnavailable")}),s.jsx("p",{className:"text-xs text-bambu-gray mb-4 max-w-md",children:t("camera.cameraUnavailableDesc")}),s.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")})]})}),s.jsx("img",{ref:V,src:O,alt:t("camera.cameraStream"),className:"max-w-full max-h-full object-contain select-none",style:{transform:`scale(${M}) translate(${E.x/M}px, ${E.y/M}px)`,cursor:M>1?A?"grabbing":"grab":"default"},onError:O?be:void 0,onLoad:O?me:void 0,onMouseDown:G,draggable:!1},u),s.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:[s.jsx("button",{onClick:pe,disabled:M<=1,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomOut"),children:s.jsx(FR,{className:"w-4 h-4 text-white"})}),s.jsxs("button",{onClick:B,className:"px-2 py-1 text-sm text-white hover:bg-white/10 rounded min-w-[48px]",title:t("camera.resetZoom"),children:[Math.round(M*100),"%"]}),s.jsx("button",{onClick:Oe,disabled:M>=4,className:"p-1.5 hover:bg-white/10 rounded disabled:opacity-30",title:t("camera.zoomIn"),children:s.jsx(LR,{className:"w-4 h-4 text-white"})})]})]})})]}):s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.jsx("p",{className:"text-white",children:t("camera.invalidPrinterId")})})}function gXe(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"),a=i!=="false"&&i!=="0";return{size:t.get("size")||"medium",fps:r,showCamera:a,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 xXe(t){const e=Math.floor(t/3600),n=Math.floor(t%3600/60);return e>0?`${e}h ${n}m`:`${n}m`}function bXe(t,e){const n=new Date,r=new Date(n.getTime()+t*60*1e3),i=new Date;i.setHours(0,0,0,0);const a=new Date(r);a.setHours(0,0,0,0);const o=r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return a.getTime()===i.getTime()?o:a.getTime()===i.getTime()+864e5?`${e("streamOverlay.tomorrow")} ${o}`:r.toLocaleDateString([],{weekday:"short"})+" "+o}function yXe(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 vXe(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 wXe(){const{printerId:t}=iM(),[e]=wR(),{t:n}=Rn(),r=sn(),i=parseInt(t||"0",10),[a,o]=_.useState(Date.now()),l=_.useMemo(()=>gXe(e),[e]),c=vXe(l.size),{data:u}=ot({queryKey:["printer",i],queryFn:()=>ce.getPrinter(i),enabled:i>0}),{data:d}=ot({queryKey:["printerStatus",i],queryFn:()=>ce.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`,y=new WebSocket(v);return y.onmessage=S=>{try{const k=JSON.parse(S.data);k.type==="printer_status"&&k.printer_id===i&&r.setQueryData(["printerStatus",i],k.status)}catch{}},y.onerror=()=>{},()=>{y.close()}},[i,r]),_.useEffect(()=>(document.title=u?`${u.name} - ${n("streamOverlay.title")}`:n("streamOverlay.title"),()=>{document.title="Bambuddy"}),[u,n]);const f=()=>{setTimeout(()=>{o(Date.now())},3e3)};if(!i)return s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.jsx("p",{className:"text-white",children:n("streamOverlay.invalidPrinterId")})});if(!d)return s.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:s.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=${a}`;return s.jsxs("div",{className:"min-h-screen bg-black relative overflow-hidden",children:[l.showCamera&&s.jsx("img",{src:x,alt:n("streamOverlay.cameraStream"),className:"absolute inset-0 w-full h-full object-contain",onError:f},a),s.jsx("a",{href:"https://github.com/maziggy/bambuddy",target:"_blank",rel:"noopener noreferrer",className:"absolute top-4 right-4 z-10",children:s.jsx("img",{src:"/img/bambuddy_logo_dark_transparent.png",alt:"Bambuddy",className:`${c.logoHeight} object-contain drop-shadow-lg hover:scale-105 transition-transform`})}),s.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:s.jsxs("div",{className:`${c.container}`,children:[l.showPrinter&&u&&s.jsxs("div",{className:`flex items-center ${c.gap} mb-2`,children:[s.jsx(Ur,{className:`${c.icon} text-white/70`}),s.jsx("span",{className:`${c.text} text-white font-medium`,children:u.name})]}),l.showFilename&&d.current_print&&s.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&&s.jsx("div",{className:`${c.text} text-white/70 mb-2`,children:yXe(d,n)}),l.showProgress&&p&&s.jsxs("div",{className:"mb-3",children:[s.jsxs("div",{className:`flex items-center justify-between mb-1 ${c.text}`,children:[s.jsx("span",{className:"text-white/70",children:n("streamOverlay.progress")}),s.jsxs("span",{className:"text-white font-bold",children:[Math.round(m),"%"]})]}),s.jsx("div",{className:`w-full bg-white/20 rounded-full ${c.progressHeight}`,children:s.jsx("div",{className:`bg-bambu-green ${c.progressHeight} rounded-full transition-all duration-500`,style:{width:`${m}%`}})})]}),p&&(l.showLayers||l.showEta)&&s.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&&s.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[s.jsx(sl,{className:c.icon}),s.jsxs("span",{className:c.text,children:[s.jsx("span",{className:"text-white",children:d.layer_num}),s.jsx("span",{className:"mx-1",children:"/"}),s.jsx("span",{children:d.total_layers})]})]}),l.showEta&&d.remaining_time!=null&&d.remaining_time>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[s.jsx(bu,{className:c.icon}),s.jsx("span",{className:`${c.text} text-white`,children:xXe(d.remaining_time*60)})]}),s.jsxs("div",{className:`flex items-center ${c.gap} text-white/70`,children:[s.jsx(tr,{className:c.icon}),s.jsxs("span",{className:`${c.text} text-white`,children:[n("streamOverlay.eta")," ",bXe(d.remaining_time,n)]})]})]})]}),!p&&s.jsx("div",{className:`${c.text} text-white/70 py-2`,children:d.connected?n("streamOverlay.printerIdle"):n("streamOverlay.printerOffline")})]})})]})}function _Xe(){const{t}=Rn(),{id:e}=iM(),{mode:n}=Oh(),{data:r,isLoading:i,error:a}=ot({queryKey:["external-link",e],queryFn:()=>ce.getExternalLink(Number(e)),enabled:!!e});return i?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})}):a||!r?s.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 text-bambu-gray",children:[s.jsx(Sn,{className:"w-12 h-12"}),s.jsx("p",{children:t("common.linkNotFound")})]}):s.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 wq=["DEBUG","INFO","WARNING","ERROR"],XP={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},SXe={DEBUG:sM,INFO:Zo,WARNING:Sn,ERROR:$i};function NXe(){const t=sn(),[e,n]=_.useState(!0),[r,i]=_.useState(new Set),[a,o]=_.useState(""),[l,c]=_.useState("ALL"),[u,d]=_.useState(!1),[f,p]=_.useState(!1),m=_.useRef(null),{data:x,isLoading:b,refetch:v}=ot({queryKey:["application-logs",l,a],queryFn:()=>Ng.getLogs({limit:200,level:l==="ALL"?void 0:l,search:a||void 0}),refetchInterval:f?2e3:!1,enabled:u});_.useEffect(()=>{u||p(!1)},[u]);const y=mt({mutationFn:()=>Ng.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(R=>{const A=new Set(R);return A.has(E)?A.delete(E):A.add(E),A})},k=E=>{const R=E.split(" ");return R.length>=2?R[1]:E},T=_.useMemo(()=>x?.entries??[],[x?.entries]),M=_.useMemo(()=>[...T].reverse(),[T]),C=({level:E})=>{const R=SXe[E]||Zo;return s.jsx(R,{className:`w-3.5 h-3.5 ${XP[E]||"text-gray-400"}`})};return s.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[s.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${f?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s.jsx(sM,{className:"w-5 h-5"})}),s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"font-medium text-white",children:"Application Logs"}),s.jsx("p",{className:"text-sm text-bambu-gray",children:f?`Live streaming - ${x?.filtered_count??0} entries`:"View and filter application logs"})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[f&&s.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs",children:[s.jsx("span",{className:"w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse"}),"Live"]}),u?s.jsx(xh,{className:"w-5 h-5 text-bambu-gray"}):s.jsx(Kr,{className:"w-5 h-5 text-bambu-gray"})]})]}),u&&s.jsxs("div",{className:"border-t border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[f?s.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:[s.jsx(ll,{className:"w-4 h-4"}),"Stop"]}):s.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:[s.jsx(bo,{className:"w-4 h-4"}),"Start"]}),s.jsxs("button",{onClick:()=>y.mutate(),disabled:y.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:[s.jsx(an,{className:"w-4 h-4"}),"Clear"]}),s.jsx("button",{onClick:()=>v(),disabled:b,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:s.jsx(Dr,{className:`w-4 h-4 ${b?"animate-spin":""}`})}),s.jsx("div",{className:"flex-1"}),s.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e,onChange:E=>n(E.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary"}),"Auto-scroll"]}),s.jsxs("span",{className:"text-sm text-bambu-gray",children:[x?.filtered_count??0,"/",x?.total_in_file??0]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1",children:[s.jsx(ya,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),s.jsx("input",{type:"text",placeholder:"Search message or logger name...",value:a,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"}),a&&s.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:s.jsx(Rt,{className:"w-4 h-4"})})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary",children:[s.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"}),wq.map((E,R)=>s.jsx("button",{onClick:()=>c(E),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${R===wq.length-1?"rounded-r":""} ${l===E?`${XP[E]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:E},E))]})]})]}),s.jsx("div",{ref:m,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:T.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center h-[300px] text-bambu-gray",children:[s.jsx("p",{className:"mb-2",children:"No log entries found"}),s.jsx("p",{className:"text-sm",children:"Log file may be empty or cleared"})]}):s.jsx("div",{className:"divide-y divide-bambu-dark-tertiary/30",children:M.map((E,R)=>{const A=r.has(R),D=E.message.includes(`
- `);return s.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${A?"bg-bambu-dark-secondary/30":""}`,onClick:()=>D&&S(R),children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:k(E.timestamp)}),s.jsx("span",{className:"shrink-0",children:s.jsx(C,{level:E.level})}),s.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:E.logger_name,children:["[",E.logger_name,"]"]}),s.jsx("span",{className:`flex-1 ${XP[E.level]||"text-white/80"} ${!A&&D?"truncate":""}`,children:A?s.jsx("pre",{className:"whitespace-pre-wrap break-all",children:E.message}):E.message.split(`
- `)[0]}),D&&s.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:A?s.jsx(xh,{className:"w-3.5 h-3.5"}):s.jsx(Kr,{className:"w-3.5 h-3.5"})})]})},R)})})}),s.jsx("div",{className:"flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray",children:f?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Auto-refreshing every 2 seconds"]}):s.jsx("span",{children:"Click Start to enable live log streaming"})})]})]})}function MXe(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function gi({icon:t,label:e,value:n,subValue:r,color:i="text-bambu-green"}){return s.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[s.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${i}`,children:s.jsx(t,{className:"w-5 h-5"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm text-bambu-gray",children:e}),s.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&s.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function _q({percent:t,color:e="bg-bambu-green"}){return s.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:s.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function Fd({title:t,icon:e,children:n}){return s.jsxs(St,{className:"p-6",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[s.jsx(e,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function kXe(){const{t}=Rn(),e=sn(),[n,r]=_.useState(null),[i,a]=_.useState(!1),[o,l]=_.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:f}=ot({queryKey:["systemInfo"],queryFn:ce.getSystemInfo,refetchInterval:3e4}),{data:p}=ot({queryKey:["debugLogging"],queryFn:Ng.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:m}=ot({queryKey:["settings"],queryFn:ce.getSettings}),{data:x}=ot({queryKey:["library-stats"],queryFn:ce.getLibraryStats}),b=m?.time_format||"system",v=async()=>{l(!0);try{const T=await Ng.setDebugLogging(!p?.enabled);e.setQueryData(["debugLogging"],T)}catch(T){console.error("Failed to toggle debug logging:",T)}finally{l(!1)}},y=async()=>{r(null),a(!0);try{await Ng.downloadSupportBundle()}catch(T){r(T instanceof Error?T.message:"Failed to download support bundle")}finally{a(!1)}};if(u)return s.jsx("div",{className:"flex items-center justify-center h-64",children:s.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!c)return s.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",k=c.memory.percent_used>90?"bg-red-500":c.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return s.jsxs("div",{className:"p-6 space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),s.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),s.jsxs("button",{onClick:()=>d(),disabled:f,className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50",children:[s.jsx(Dr,{className:`w-4 h-4 ${f?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),s.jsx(Fd,{title:t("system.application","Application"),icon:yf,children:s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(gi,{icon:yf,label:t("system.version","Version"),value:`v${c.app.version}`}),s.jsx(gi,{icon:tr,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),s.jsx(gi,{icon:yf,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),s.jsx(Fd,{title:t("support.title","Support & Troubleshooting"),icon:ode,children:s.jsxs("div",{className:"space-y-4",children:[s.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.")}),s.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:`p-2 rounded-lg ${p?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:s.jsx(sM,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:t("support.debugLogging","Debug Logging")}),s.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&&s.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(p.duration_seconds/60),"m ",p.duration_seconds%60,"s)"]})]})]})]}),s.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&&s.jsx(ft,{className:"w-4 h-4 animate-spin"}),p?.enabled?t("support.disableDebug","Disable"):t("support.enableDebug","Enable")]})]}),s.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green",children:s.jsx(wi,{className:"w-5 h-5"})}),s.jsxs("div",{children:[s.jsx("p",{className:"font-medium text-white",children:t("support.supportBundle","Support Bundle")}),s.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.supportBundleDescription","Download system info and logs as a ZIP file")})]})]}),s.jsxs("button",{onClick:y,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&&s.jsx(ft,{className:"w-4 h-4 animate-spin"}),t("common.download","Download")]})]}),n&&s.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&&s.jsx("div",{className:"p-4 bg-bambu-dark-tertiary/50 rounded-lg",children:s.jsxs("p",{className:"text-sm text-bambu-gray",children:[s.jsx("span",{className:"text-amber-400 font-medium",children:t("support.instructions","To report an issue:")}),s.jsx("br",{}),"1. ",t("support.step1","Enable debug logging"),s.jsx("br",{}),"2. ",t("support.step2","Reproduce the issue"),s.jsx("br",{}),"3. ",t("support.step3","Download the support bundle"),s.jsx("br",{}),"4. ",t("support.step4","Attach the ZIP file to your issue report")]})}),s.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg space-y-3",children:[s.jsx("p",{className:"text-sm font-medium text-white",children:t("support.privacyTitle","What's in the support bundle?")}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-bambu-green font-medium mb-1",children:t("support.collected","Collected:")}),s.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[s.jsxs("li",{children:["• ",t("support.collectItem1","App version and debug mode")]}),s.jsxs("li",{children:["• ",t("support.collectItem2","OS, architecture, Python version")]}),s.jsxs("li",{children:["• ",t("support.collectItem3","Database statistics (counts only)")]}),s.jsxs("li",{children:["• ",t("support.collectItem4","Printer models and nozzle counts")]}),s.jsxs("li",{children:["• ",t("support.collectItem5","Non-sensitive settings (themes, formats)")]}),s.jsxs("li",{children:["• ",t("support.collectItem6","Debug logs (sanitized)")]})]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-red-400 font-medium mb-1",children:t("support.notCollected","NOT collected:")}),s.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[s.jsxs("li",{children:["• ",t("support.notItem1","Printer names, IPs, serial numbers")]}),s.jsxs("li",{children:["• ",t("support.notItem2","Access codes and passwords")]}),s.jsxs("li",{children:["• ",t("support.notItem3","Email addresses")]}),s.jsxs("li",{children:["• ",t("support.notItem4","API keys and tokens")]}),s.jsxs("li",{children:["• ",t("support.notItem5","Webhook URLs")]}),s.jsxs("li",{children:["• ",t("support.notItem6","Your hostname or username")]})]})]})]}),s.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].")})]}),s.jsx(NXe,{})]})}),s.jsxs(Fd,{title:t("system.database","Database"),icon:ku,children:[s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[s.jsx(gi,{icon:ho,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),s.jsx(gi,{icon:oM,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),s.jsx(gi,{icon:Qi,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),s.jsx(gi,{icon:ft,label:t("system.printing","Printing"),value:c.database.archives_printing,color:"text-yellow-500"})]}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(gi,{icon:Ur,label:t("system.printers","Printers"),value:c.database.printers}),s.jsx(gi,{icon:EW,label:t("system.filaments","Filaments"),value:c.database.filaments}),s.jsx(gi,{icon:Ja,label:t("system.projects","Projects"),value:c.database.projects}),s.jsx(gi,{icon:tl,label:t("system.smartPlugs","Smart Plugs"),value:c.database.smart_plugs})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[s.jsx(gi,{icon:tr,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),s.jsx(gi,{icon:ho,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),s.jsxs(Fd,{title:t("system.connectedPrinters","Connected Printers"),icon:Ur,children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[s.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:c.printers.connected}),s.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?s.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(T=>s.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),s.jsx("span",{className:"font-medium text-white",children:T.name})]}),s.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[s.jsx("span",{children:T.model}),s.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))}):s.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),s.jsx(Fd,{title:t("system.storage","Storage"),icon:fM,children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),s.jsxs("span",{className:"text-white",children:[c.storage.disk_used_formatted," / ",c.storage.disk_total_formatted]})]}),s.jsx(_q,{percent:c.storage.disk_percent_used,color:S}),s.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),"%)"]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[s.jsx(gi,{icon:ho,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),s.jsx(gi,{icon:ku,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),x&&s.jsx(gi,{icon:Il,label:t("system.fileManagerStorage","File Manager"),value:MXe(x.total_size_bytes),subValue:`${x.total_files} files, ${x.total_folders} folders`})]})]})}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[s.jsx(Fd,{title:t("system.memory","Memory"),icon:zde,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{children:[s.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[s.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),s.jsxs("span",{className:"text-white",children:[c.memory.used_formatted," / ",c.memory.total_formatted]})]}),s.jsx(_q,{percent:c.memory.percent_used,color:k}),s.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),s.jsx(Fd,{title:t("system.cpu","CPU"),icon:Rw,children:s.jsx("div",{className:"space-y-4",children:s.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[s.jsx(gi,{icon:Rw,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),s.jsx(gi,{icon:Rw,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),s.jsx(Fd,{title:t("system.systemDetails","System Details"),icon:yf,children:s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[s.jsx(gi,{icon:yf,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),s.jsx(gi,{icon:Rw,label:t("system.architecture","Architecture"),value:c.system.architecture}),s.jsx(gi,{icon:yf,label:t("system.python","Python"),value:c.system.python_version}),s.jsx(gi,{icon:tr,label:t("system.bootTime","Boot Time"),value:Hg(c.system.boot_time,b)})]})})]})}function EXe(){const t=kc(),{t:e}=Rn(),{login:n}=Ci(),{showToast:r}=Hn(),{mode:i}=Oh(),[a,o]=_.useState(""),[l,c]=_.useState(""),[u,d]=_.useState(!1),f=mt({mutationFn:()=>n(a,l),onSuccess:()=>{r(e("login.loginSuccess")),t("/")},onError:m=>{r(m.message||e("login.loginFailed"),"error")}}),p=m=>{if(m.preventDefault(),!a||!l){r(e("login.enterCredentials"),"error");return}f.mutate()};return s.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:[s.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:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"flex items-center justify-center mb-6",children:s.jsx("img",{src:i==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),s.jsx("h2",{className:"text-3xl font-bold text-white",children:e("login.title")}),s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("login.subtitle")})]}),s.jsxs("form",{className:"mt-8 space-y-6",onSubmit:p,children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-white mb-2",children:e("login.username")}),s.jsx("input",{id:"username",type:"text",required:!0,value:a,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"})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-white mb-2",children:e("login.password")}),s.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"})]})]}),s.jsx("div",{children:s.jsx("button",{type:"submit",disabled:f.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:f.isPending?e("login.signingIn"):e("login.signIn")})}),s.jsx("div",{className:"text-center",children:s.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-sm text-bambu-gray hover:text-bambu-green transition-colors",children:e("login.forgotPassword")})})]})]}),u&&s.jsx("div",{className:"fixed inset-0 bg-black flex items-center justify-center z-50 p-4",onClick:()=>d(!1),children:s.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:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Zce,{className:"w-5 h-5 text-bambu-green"}),s.jsx("h2",{className:"text-lg font-semibold text-white",children:e("login.forgotPasswordTitle")})]}),s.jsx("button",{onClick:()=>d(!1),className:"p-1 rounded-lg hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",children:s.jsx(Rt,{className:"w-5 h-5"})})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx("p",{className:"text-bambu-gray",children:e("login.forgotPasswordMessage")}),s.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4 space-y-2",children:[s.jsx("p",{className:"text-sm text-white font-medium",children:e("login.howToReset")}),s.jsxs("ol",{className:"text-sm text-bambu-gray space-y-1 list-decimal list-inside",children:[s.jsx("li",{children:e("login.resetStep1")}),s.jsx("li",{children:e("login.resetStep2")}),s.jsx("li",{children:e("login.resetStep3")}),s.jsx("li",{children:e("login.resetStep4")})]})]}),s.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 TXe(){const t=kc(),{t:e}=Rn(),{showToast:n}=Hn(),{mode:r}=Oh(),{refreshAuth:i}=Ci(),[a,o]=_.useState(!1),[l,c]=_.useState(""),[u,d]=_.useState(""),[f,p]=_.useState(""),m=mt({mutationFn:()=>ce.setupAuth({auth_enabled:a,admin_username:a?l:void 0,admin_password:a?u:void 0}),onSuccess:async b=>{await i(),b.auth_enabled?b.admin_created?(n(e("setup.toast.authEnabledAdminCreated")),t("/login")):(n(e("setup.toast.authEnabledExistingAdmins")),t("/login")):(n(e("setup.toast.setupCompleted")),t("/"))},onError:b=>{n(b.message,"error")}}),x=b=>{if(b.preventDefault(),a&&(l||u)){if(!l||!u){n(e("setup.toast.enterBothCredentials"),"error");return}if(u!==f){n(e("setup.toast.passwordsDoNotMatch"),"error");return}if(u.length<6){n(e("setup.toast.passwordTooShort"),"error");return}}m.mutate()};return s.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:s.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:[s.jsxs("div",{className:"text-center",children:[s.jsx("div",{className:"flex items-center justify-center mb-6",children:s.jsx("img",{src:r==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),s.jsx("h2",{className:"text-3xl font-bold text-white",children:e("setup.title")}),s.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("setup.subtitle")})]}),s.jsxs("form",{className:"mt-8 space-y-6",onSubmit:x,children:[s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center p-4 bg-bambu-dark-secondary/50 rounded-lg border border-bambu-dark-tertiary",children:[s.jsx("input",{id:"auth-enabled",type:"checkbox",checked:a,onChange:b=>o(b.target.checked),className:"h-4 w-4 text-bambu-green focus:ring-bambu-green border-bambu-dark-tertiary rounded bg-bambu-dark-secondary"}),s.jsx("label",{htmlFor:"auth-enabled",className:"ml-3 block text-sm font-medium text-white",children:e("setup.enableAuth")})]}),a&&s.jsxs("div",{className:"space-y-4 mt-4",children:[s.jsx("div",{className:"p-3 bg-bambu-dark-secondary/50 border border-bambu-dark-tertiary rounded-lg",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx(Zo,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),s.jsxs("div",{className:"text-sm text-bambu-gray",children:[s.jsx("p",{className:"text-white font-medium mb-1",children:e("setup.adminAccount")}),s.jsx("p",{children:e("setup.adminAccountDesc")})]})]})}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminUsername")," ",s.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),s.jsx("input",{id:"admin-username",type:"text",value:l,onChange:b=>c(b.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"})]}),s.jsxs("div",{children:[s.jsxs("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminPassword")," ",s.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),s.jsx("input",{id:"admin-password",type:"password",value:u,onChange:b=>d(b.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&&s.jsxs("div",{children:[s.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:e("setup.confirmPassword")}),s.jsx("input",{id:"confirm-password",type:"password",value:f,onChange:b=>p(b.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"})]})]})]}),s.jsx("div",{children:s.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 AXe(){const t=_.useRef(null),e=_.useRef(null),n=sn(),[r,i]=_.useState(!1),a=_.useRef(new Set),o=_.useRef(null),l=_.useRef(new Map),c=_.useRef(null),u=_.useRef([]),d=_.useRef(!1),f=_.useRef(()=>{}),p=_.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const S=()=>{const k=u.current.shift();k?requestAnimationFrame(()=>{f.current(k),u.current.length>0?setTimeout(S,16):d.current=!1}):d.current=!1};S()},[]),m=_.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const k=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,T=new WebSocket(k);let M=null;T.onopen=()=>{console.log("[WebSocket] Connected"),i(!0),M=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?f.current(E):(u.current.push(E),p())}catch{}},T.onclose=C=>{console.log("[WebSocket] Closed",C.code,C.reason),M&&(clearInterval(M),M=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,k)=>{const T=l.current.get(S)||{};l.current.set(S,{...T,...k}),c.current||(c.current=window.setTimeout(()=>{const M=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{M.forEach((C,E)=>{n.setQueryData(["printerStatus",E],R=>{const A={...R,...C};return A.wifi_signal==null&&R?.wifi_signal!=null&&(A.wifi_signal=R.wifi_signal),A})})})},100))},[n]),b=_.useCallback(S=>{a.current.add(S),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const k=Array.from(a.current);a.current.clear(),o.current=null;let T=0;k.forEach(M=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[M]})})},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":b("archives"),b("archiveStats");break;case"archive_created":b("archives"),b("archiveStats");break;case"archive_updated":b("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,b,x]);_.useEffect(()=>{f.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 y=_.useCallback(S=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(S))},[]);return{isConnected:r,sendMessage:y}}const CXe=new Yle({defaultOptions:{queries:{staleTime:1e3*60,retry:1}}});function PXe({children:t}){return AXe(),s.jsx(s.Fragment,{children:t})}function jXe({children:t}){const{authEnabled:e,loading:n,user:r}=Ci();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e&&!r?s.jsx(Fg,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function DXe({children:t}){const{authEnabled:e,loading:n,user:r,isAdmin:i}=Ci();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?r?i?s.jsx(s.Fragment,{children:t}):s.jsx(Fg,{to:"/",replace:!0}):s.jsx(Fg,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function RXe({children:t}){const{authEnabled:e,loading:n}=Ci();return n?s.jsx("div",{className:"min-h-screen flex items-center justify-center",children:"Loading..."}):e?s.jsx(Fg,{to:"/login",replace:!0}):s.jsx(s.Fragment,{children:t})}function OXe(){return s.jsx(Mfe,{children:s.jsx(Dfe,{children:s.jsx(Qle,{client:CXe,children:s.jsx(Cfe,{children:s.jsx(xle,{children:s.jsxs(qoe,{children:[s.jsx(Fi,{path:"/setup",element:s.jsx(RXe,{children:s.jsx(TXe,{})})}),s.jsx(Fi,{path:"/login",element:s.jsx(EXe,{})}),s.jsx(Fi,{path:"/camera/:printerId",element:s.jsx(pXe,{})}),s.jsx(Fi,{path:"/overlay/:printerId",element:s.jsx(wXe,{})}),s.jsxs(Fi,{element:s.jsx(jXe,{children:s.jsx(PXe,{children:s.jsx(Ffe,{})})}),children:[s.jsx(Fi,{index:!0,element:s.jsx(SPe,{})}),s.jsx(Fi,{path:"archives",element:s.jsx(dqe,{})}),s.jsx(Fi,{path:"queue",element:s.jsx(YWe,{})}),s.jsx(Fi,{path:"stats",element:s.jsx(uKe,{})}),s.jsx(Fi,{path:"profiles",element:s.jsx($Ke,{})}),s.jsx(Fi,{path:"maintenance",element:s.jsx(KKe,{})}),s.jsx(Fi,{path:"projects",element:s.jsx(YKe,{})}),s.jsx(Fi,{path:"projects/:id",element:s.jsx(rXe,{})}),s.jsx(Fi,{path:"files",element:s.jsx(dXe,{})}),s.jsx(Fi,{path:"settings",element:s.jsx(DXe,{children:s.jsx(jKe,{})})}),s.jsx(Fi,{path:"users",element:s.jsx(Fg,{to:"/settings?tab=users",replace:!0})}),s.jsx(Fi,{path:"groups",element:s.jsx(Fg,{to:"/settings?tab=users",replace:!0})}),s.jsx(Fi,{path:"system",element:s.jsx(kXe,{})}),s.jsx(Fi,{path:"external/:id",element:s.jsx(_Xe,{})})]})]})})})})})})}$ae.createRoot(document.getElementById("root")).render(s.jsx(_.StrictMode,{children:s.jsx(OXe,{})}));
|