index.iife.js 291 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650
  1. (function(exports, _vueuse_shared, vue) {
  2. Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
  3. //#region computedAsync/index.ts
  4. function computedAsync(evaluationCallback, initialState, optionsOrRef) {
  5. var _globalThis$reportErr;
  6. let options;
  7. if ((0, vue.isRef)(optionsOrRef)) options = { evaluating: optionsOrRef };
  8. else options = optionsOrRef || {};
  9. const { lazy = false, flush = "sync", evaluating = void 0, shallow = true, onError = (_globalThis$reportErr = globalThis.reportError) !== null && _globalThis$reportErr !== void 0 ? _globalThis$reportErr : _vueuse_shared.noop } = options;
  10. const started = (0, vue.shallowRef)(!lazy);
  11. const current = shallow ? (0, vue.shallowRef)(initialState) : (0, vue.ref)(initialState);
  12. let counter = 0;
  13. (0, vue.watchEffect)(async (onInvalidate) => {
  14. if (!started.value) return;
  15. counter++;
  16. const counterAtBeginning = counter;
  17. let hasFinished = false;
  18. if (evaluating) Promise.resolve().then(() => {
  19. evaluating.value = true;
  20. });
  21. try {
  22. const result = await evaluationCallback((cancelCallback) => {
  23. onInvalidate(() => {
  24. if (evaluating) evaluating.value = false;
  25. if (!hasFinished) cancelCallback();
  26. });
  27. });
  28. if (counterAtBeginning === counter) current.value = result;
  29. } catch (e) {
  30. onError(e);
  31. } finally {
  32. if (evaluating && counterAtBeginning === counter) evaluating.value = false;
  33. hasFinished = true;
  34. }
  35. }, { flush });
  36. if (lazy) return (0, vue.computed)(() => {
  37. started.value = true;
  38. return current.value;
  39. });
  40. else return current;
  41. }
  42. /** @deprecated use `computedAsync` instead */
  43. const asyncComputed = computedAsync;
  44. //#endregion
  45. //#region computedInject/index.ts
  46. function computedInject(key, options, defaultSource, treatDefaultAsFactory) {
  47. let source = (0, vue.inject)(key);
  48. if (defaultSource) source = (0, vue.inject)(key, defaultSource);
  49. if (treatDefaultAsFactory) source = (0, vue.inject)(key, defaultSource, treatDefaultAsFactory);
  50. if (typeof options === "function") return (0, vue.computed)((oldValue) => options(source, oldValue));
  51. else return (0, vue.computed)({
  52. get: (oldValue) => options.get(source, oldValue),
  53. set: options.set
  54. });
  55. }
  56. //#endregion
  57. //#region createReusableTemplate/index.ts
  58. /**
  59. * This function creates `define` and `reuse` components in pair,
  60. * It also allow to pass a generic to bind with type.
  61. *
  62. * @see https://vueuse.org/createReusableTemplate
  63. *
  64. * @__NO_SIDE_EFFECTS__
  65. */
  66. function createReusableTemplate(options = {}) {
  67. const { inheritAttrs = true, name = "ReusableTemplate" } = options;
  68. const render = (0, vue.shallowRef)();
  69. const define = (0, vue.defineComponent)({
  70. name: `${name}.define`,
  71. setup(_, { slots }) {
  72. return () => {
  73. render.value = slots.default;
  74. };
  75. }
  76. });
  77. const reuse = (0, vue.defineComponent)({
  78. inheritAttrs,
  79. name: `${name}.reuse`,
  80. props: options.props,
  81. setup(props, { attrs, slots }) {
  82. return () => {
  83. var _render$value;
  84. if (!render.value && true) throw new Error("[VueUse] Failed to find the definition of reusable template");
  85. const vnode = (_render$value = render.value) === null || _render$value === void 0 ? void 0 : _render$value.call(render, {
  86. ...options.props == null ? keysToCamelKebabCase(attrs) : props,
  87. $slots: slots
  88. });
  89. return inheritAttrs && (vnode === null || vnode === void 0 ? void 0 : vnode.length) === 1 ? vnode[0] : vnode;
  90. };
  91. }
  92. });
  93. return (0, _vueuse_shared.makeDestructurable)({
  94. define,
  95. reuse
  96. }, [define, reuse]);
  97. }
  98. function keysToCamelKebabCase(obj) {
  99. const newObj = {};
  100. for (const key in obj) newObj[(0, _vueuse_shared.camelize)(key)] = obj[key];
  101. return newObj;
  102. }
  103. //#endregion
  104. //#region createTemplatePromise/index.ts
  105. /**
  106. * Creates a template promise component.
  107. *
  108. * @see https://vueuse.org/createTemplatePromise
  109. *
  110. * @__NO_SIDE_EFFECTS__
  111. */
  112. function createTemplatePromise(options = {}) {
  113. let index = 0;
  114. const instances = (0, vue.ref)([]);
  115. function create(...args) {
  116. const props = (0, vue.shallowReactive)({
  117. key: index++,
  118. args,
  119. promise: void 0,
  120. resolve: () => {},
  121. reject: () => {},
  122. isResolving: false,
  123. options
  124. });
  125. instances.value.push(props);
  126. props.promise = new Promise((_resolve, _reject) => {
  127. props.resolve = (v) => {
  128. props.isResolving = true;
  129. return _resolve(v);
  130. };
  131. props.reject = _reject;
  132. }).finally(() => {
  133. props.promise = void 0;
  134. const index = instances.value.indexOf(props);
  135. if (index !== -1) instances.value.splice(index, 1);
  136. });
  137. return props.promise;
  138. }
  139. function start(...args) {
  140. if (options.singleton && instances.value.length > 0) return instances.value[0].promise;
  141. return create(...args);
  142. }
  143. const component = (0, vue.defineComponent)((_, { slots }) => {
  144. const renderList = () => instances.value.map((props) => {
  145. var _slots$default;
  146. return (0, vue.h)(vue.Fragment, { key: props.key }, (_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots, props));
  147. });
  148. if (options.transition) return () => (0, vue.h)(vue.TransitionGroup, options.transition, renderList);
  149. return renderList;
  150. });
  151. component.start = start;
  152. return component;
  153. }
  154. //#endregion
  155. //#region createUnrefFn/index.ts
  156. /**
  157. * Make a plain function accepting ref and raw values as arguments.
  158. * Returns the same value the unconverted function returns, with proper typing.
  159. *
  160. * @__NO_SIDE_EFFECTS__
  161. */
  162. function createUnrefFn(fn) {
  163. return function(...args) {
  164. return fn.apply(this, args.map((i) => (0, vue.toValue)(i)));
  165. };
  166. }
  167. //#endregion
  168. //#region _configurable.ts
  169. const defaultWindow = _vueuse_shared.isClient ? window : void 0;
  170. const defaultDocument = _vueuse_shared.isClient ? window.document : void 0;
  171. const defaultNavigator = _vueuse_shared.isClient ? window.navigator : void 0;
  172. const defaultLocation = _vueuse_shared.isClient ? window.location : void 0;
  173. //#endregion
  174. //#region unrefElement/index.ts
  175. /**
  176. * Get the dom element of a ref of element or Vue component instance
  177. *
  178. * @param elRef
  179. */
  180. function unrefElement(elRef) {
  181. var _$el;
  182. const plain = (0, vue.toValue)(elRef);
  183. return (_$el = plain === null || plain === void 0 ? void 0 : plain.$el) !== null && _$el !== void 0 ? _$el : plain;
  184. }
  185. //#endregion
  186. //#region useEventListener/index.ts
  187. function useEventListener(...args) {
  188. const register = (el, event, listener, options) => {
  189. el.addEventListener(event, listener, options);
  190. return () => el.removeEventListener(event, listener, options);
  191. };
  192. const firstParamTargets = (0, vue.computed)(() => {
  193. const test = (0, _vueuse_shared.toArray)((0, vue.toValue)(args[0])).filter((e) => e != null);
  194. return test.every((e) => typeof e !== "string") ? test : void 0;
  195. });
  196. return (0, _vueuse_shared.watchImmediate)(() => {
  197. var _firstParamTargets$va, _firstParamTargets$va2;
  198. return [
  199. (_firstParamTargets$va = (_firstParamTargets$va2 = firstParamTargets.value) === null || _firstParamTargets$va2 === void 0 ? void 0 : _firstParamTargets$va2.map((e) => unrefElement(e))) !== null && _firstParamTargets$va !== void 0 ? _firstParamTargets$va : [defaultWindow].filter((e) => e != null),
  200. (0, _vueuse_shared.toArray)((0, vue.toValue)(firstParamTargets.value ? args[1] : args[0])),
  201. (0, _vueuse_shared.toArray)((0, vue.unref)(firstParamTargets.value ? args[2] : args[1])),
  202. (0, vue.toValue)(firstParamTargets.value ? args[3] : args[2])
  203. ];
  204. }, ([raw_targets, raw_events, raw_listeners, raw_options], _, onCleanup) => {
  205. if (!(raw_targets === null || raw_targets === void 0 ? void 0 : raw_targets.length) || !(raw_events === null || raw_events === void 0 ? void 0 : raw_events.length) || !(raw_listeners === null || raw_listeners === void 0 ? void 0 : raw_listeners.length)) return;
  206. const optionsClone = (0, _vueuse_shared.isObject)(raw_options) ? { ...raw_options } : raw_options;
  207. const cleanups = raw_targets.flatMap((el) => raw_events.flatMap((event) => raw_listeners.map((listener) => register(el, event, listener, optionsClone))));
  208. onCleanup(() => {
  209. cleanups.forEach((fn) => fn());
  210. });
  211. }, { flush: "post" });
  212. }
  213. //#endregion
  214. //#region onClickOutside/index.ts
  215. let _iOSWorkaround = false;
  216. function onClickOutside(target, handler, options = {}) {
  217. const { window = defaultWindow, ignore = [], capture = true, detectIframe = false, controls = false } = options;
  218. if (!window) return controls ? {
  219. stop: _vueuse_shared.noop,
  220. cancel: _vueuse_shared.noop,
  221. trigger: _vueuse_shared.noop
  222. } : _vueuse_shared.noop;
  223. if (_vueuse_shared.isIOS && !_iOSWorkaround) {
  224. _iOSWorkaround = true;
  225. const listenerOptions = { passive: true };
  226. Array.from(window.document.body.children).forEach((el) => el.addEventListener("click", _vueuse_shared.noop, listenerOptions));
  227. window.document.documentElement.addEventListener("click", _vueuse_shared.noop, listenerOptions);
  228. }
  229. let shouldListen = true;
  230. const shouldIgnore = (event) => {
  231. return (0, vue.toValue)(ignore).some((target) => {
  232. if (typeof target === "string") return Array.from(window.document.querySelectorAll(target)).some((el) => el === event.target || event.composedPath().includes(el));
  233. else {
  234. const el = unrefElement(target);
  235. return el && (event.target === el || event.composedPath().includes(el));
  236. }
  237. });
  238. };
  239. /**
  240. * Determines if the given target has multiple root elements.
  241. * Referenced from: https://github.com/vuejs/test-utils/blob/ccb460be55f9f6be05ab708500a41ec8adf6f4bc/src/vue-wrapper.ts#L21
  242. */
  243. function hasMultipleRoots(target) {
  244. const vm = (0, vue.toValue)(target);
  245. return vm && vm.$.subTree.shapeFlag === 16;
  246. }
  247. function checkMultipleRoots(target, event) {
  248. const vm = (0, vue.toValue)(target);
  249. const children = vm.$.subTree && vm.$.subTree.children;
  250. if (children == null || !Array.isArray(children)) return false;
  251. return children.some((child) => child.el === event.target || event.composedPath().includes(child.el));
  252. }
  253. const listener = (event) => {
  254. const el = unrefElement(target);
  255. if (event.target == null) return;
  256. if (!(el instanceof Element) && hasMultipleRoots(target) && checkMultipleRoots(target, event)) return;
  257. if (!el || el === event.target || event.composedPath().includes(el)) return;
  258. if ("detail" in event && event.detail === 0) shouldListen = !shouldIgnore(event);
  259. if (!shouldListen) {
  260. shouldListen = true;
  261. return;
  262. }
  263. handler(event);
  264. };
  265. let isProcessingClick = false;
  266. const cleanup = [
  267. useEventListener(window, "click", (event) => {
  268. if (!isProcessingClick) {
  269. isProcessingClick = true;
  270. setTimeout(() => {
  271. isProcessingClick = false;
  272. }, 0);
  273. listener(event);
  274. }
  275. }, {
  276. passive: true,
  277. capture
  278. }),
  279. useEventListener(window, "pointerdown", (e) => {
  280. const el = unrefElement(target);
  281. shouldListen = !shouldIgnore(e) && !!(el && !e.composedPath().includes(el));
  282. }, { passive: true }),
  283. detectIframe && useEventListener(window, "blur", (event) => {
  284. setTimeout(() => {
  285. const el = unrefElement(target);
  286. let activeEl = window.document.activeElement;
  287. while (activeEl === null || activeEl === void 0 ? void 0 : activeEl.shadowRoot) activeEl = activeEl.shadowRoot.activeElement;
  288. if ((activeEl === null || activeEl === void 0 ? void 0 : activeEl.tagName) === "IFRAME" && !(el === null || el === void 0 ? void 0 : el.contains(window.document.activeElement))) handler(event);
  289. }, 0);
  290. }, { passive: true })
  291. ].filter(Boolean);
  292. const stop = () => cleanup.forEach((fn) => fn());
  293. if (controls) return {
  294. stop,
  295. cancel: () => {
  296. shouldListen = false;
  297. },
  298. trigger: (event) => {
  299. shouldListen = true;
  300. listener(event);
  301. shouldListen = false;
  302. }
  303. };
  304. return stop;
  305. }
  306. //#endregion
  307. //#region useMounted/index.ts
  308. /**
  309. * Mounted state in ref.
  310. *
  311. * @see https://vueuse.org/useMounted
  312. *
  313. * @__NO_SIDE_EFFECTS__
  314. */
  315. function useMounted() {
  316. const isMounted = (0, vue.shallowRef)(false);
  317. const instance = (0, vue.getCurrentInstance)();
  318. if (instance) (0, vue.onMounted)(() => {
  319. isMounted.value = true;
  320. }, instance);
  321. return isMounted;
  322. }
  323. //#endregion
  324. //#region useSupported/index.ts
  325. /* @__NO_SIDE_EFFECTS__ */
  326. function useSupported(callback) {
  327. const isMounted = useMounted();
  328. return (0, vue.computed)(() => {
  329. isMounted.value;
  330. return Boolean(callback());
  331. });
  332. }
  333. //#endregion
  334. //#region useMutationObserver/index.ts
  335. /**
  336. * Watch for changes being made to the DOM tree.
  337. *
  338. * @see https://vueuse.org/useMutationObserver
  339. * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver MutationObserver MDN
  340. * @param target
  341. * @param callback
  342. * @param options
  343. */
  344. function useMutationObserver(target, callback, options = {}) {
  345. const { window = defaultWindow, ...mutationOptions } = options;
  346. let observer;
  347. const isSupported = /* @__PURE__ */ useSupported(() => window && "MutationObserver" in window);
  348. const cleanup = () => {
  349. if (observer) {
  350. observer.disconnect();
  351. observer = void 0;
  352. }
  353. };
  354. const stopWatch = (0, vue.watch)((0, vue.computed)(() => {
  355. const items = (0, _vueuse_shared.toArray)((0, vue.toValue)(target)).map(unrefElement).filter(_vueuse_shared.notNullish);
  356. return new Set(items);
  357. }), (newTargets) => {
  358. cleanup();
  359. if (isSupported.value && newTargets.size) {
  360. observer = new MutationObserver(callback);
  361. newTargets.forEach((el) => observer.observe(el, mutationOptions));
  362. }
  363. }, {
  364. immediate: true,
  365. flush: "post"
  366. });
  367. const takeRecords = () => {
  368. return observer === null || observer === void 0 ? void 0 : observer.takeRecords();
  369. };
  370. const stop = () => {
  371. stopWatch();
  372. cleanup();
  373. };
  374. (0, _vueuse_shared.tryOnScopeDispose)(stop);
  375. return {
  376. isSupported,
  377. stop,
  378. takeRecords
  379. };
  380. }
  381. //#endregion
  382. //#region onElementRemoval/index.ts
  383. /**
  384. * Fires when the element or any element containing it is removed.
  385. *
  386. * @param target
  387. * @param callback
  388. * @param options
  389. */
  390. function onElementRemoval(target, callback, options = {}) {
  391. const { window = defaultWindow, document = window === null || window === void 0 ? void 0 : window.document, flush = "sync" } = options;
  392. if (!window || !document) return _vueuse_shared.noop;
  393. let stopFn;
  394. const cleanupAndUpdate = (fn) => {
  395. stopFn === null || stopFn === void 0 || stopFn();
  396. stopFn = fn;
  397. };
  398. const stopWatch = (0, vue.watchEffect)(() => {
  399. const el = unrefElement(target);
  400. if (el) {
  401. const { stop } = useMutationObserver(document, (mutationsList) => {
  402. if (mutationsList.map((mutation) => [...mutation.removedNodes]).flat().some((node) => node === el || node.contains(el))) callback(mutationsList);
  403. }, {
  404. window,
  405. childList: true,
  406. subtree: true
  407. });
  408. cleanupAndUpdate(stop);
  409. }
  410. }, { flush });
  411. const stopHandle = () => {
  412. stopWatch();
  413. cleanupAndUpdate();
  414. };
  415. (0, _vueuse_shared.tryOnScopeDispose)(stopHandle);
  416. return stopHandle;
  417. }
  418. //#endregion
  419. //#region onKeyStroke/index.ts
  420. function createKeyPredicate(keyFilter) {
  421. if (typeof keyFilter === "function") return keyFilter;
  422. else if (typeof keyFilter === "string") return (event) => event.key === keyFilter;
  423. else if (Array.isArray(keyFilter)) return (event) => keyFilter.includes(event.key);
  424. return () => true;
  425. }
  426. function onKeyStroke(...args) {
  427. let key;
  428. let handler;
  429. let options = {};
  430. if (args.length === 3) {
  431. key = args[0];
  432. handler = args[1];
  433. options = args[2];
  434. } else if (args.length === 2) if (typeof args[1] === "object") {
  435. key = true;
  436. handler = args[0];
  437. options = args[1];
  438. } else {
  439. key = args[0];
  440. handler = args[1];
  441. }
  442. else {
  443. key = true;
  444. handler = args[0];
  445. }
  446. const { target = defaultWindow, eventName = "keydown", passive = false, dedupe = false } = options;
  447. const predicate = createKeyPredicate(key);
  448. const listener = (e) => {
  449. if (e.repeat && (0, vue.toValue)(dedupe)) return;
  450. if (predicate(e)) handler(e);
  451. };
  452. return useEventListener(target, eventName, listener, passive);
  453. }
  454. /**
  455. * Listen to the keydown event of the given key.
  456. *
  457. * @see https://vueuse.org/onKeyStroke
  458. * @param key
  459. * @param handler
  460. * @param options
  461. */
  462. function onKeyDown(key, handler, options = {}) {
  463. return onKeyStroke(key, handler, {
  464. ...options,
  465. eventName: "keydown"
  466. });
  467. }
  468. /**
  469. * Listen to the keypress event of the given key.
  470. *
  471. * @see https://vueuse.org/onKeyStroke
  472. * @param key
  473. * @param handler
  474. * @param options
  475. */
  476. function onKeyPressed(key, handler, options = {}) {
  477. return onKeyStroke(key, handler, {
  478. ...options,
  479. eventName: "keypress"
  480. });
  481. }
  482. /**
  483. * Listen to the keyup event of the given key.
  484. *
  485. * @see https://vueuse.org/onKeyStroke
  486. * @param key
  487. * @param handler
  488. * @param options
  489. */
  490. function onKeyUp(key, handler, options = {}) {
  491. return onKeyStroke(key, handler, {
  492. ...options,
  493. eventName: "keyup"
  494. });
  495. }
  496. //#endregion
  497. //#region onLongPress/index.ts
  498. const DEFAULT_DELAY = 500;
  499. const DEFAULT_THRESHOLD = 10;
  500. function onLongPress(target, handler, options) {
  501. var _options$modifiers10, _options$modifiers11;
  502. const elementRef = (0, vue.computed)(() => unrefElement(target));
  503. let timeout;
  504. let posStart;
  505. let startTimestamp;
  506. let hasLongPressed = false;
  507. function clear() {
  508. if (timeout) {
  509. clearTimeout(timeout);
  510. timeout = void 0;
  511. }
  512. posStart = void 0;
  513. startTimestamp = void 0;
  514. hasLongPressed = false;
  515. }
  516. function getDelay(ev) {
  517. const delay = options === null || options === void 0 ? void 0 : options.delay;
  518. if (typeof delay === "function") return delay(ev);
  519. return delay !== null && delay !== void 0 ? delay : DEFAULT_DELAY;
  520. }
  521. function onRelease(ev) {
  522. var _options$modifiers, _options$modifiers2, _options$modifiers3;
  523. const [_startTimestamp, _posStart, _hasLongPressed] = [
  524. startTimestamp,
  525. posStart,
  526. hasLongPressed
  527. ];
  528. clear();
  529. if (!(options === null || options === void 0 ? void 0 : options.onMouseUp) || !_posStart || !_startTimestamp) return;
  530. if ((options === null || options === void 0 || (_options$modifiers = options.modifiers) === null || _options$modifiers === void 0 ? void 0 : _options$modifiers.self) && ev.target !== elementRef.value) return;
  531. if (options === null || options === void 0 || (_options$modifiers2 = options.modifiers) === null || _options$modifiers2 === void 0 ? void 0 : _options$modifiers2.prevent) ev.preventDefault();
  532. if (options === null || options === void 0 || (_options$modifiers3 = options.modifiers) === null || _options$modifiers3 === void 0 ? void 0 : _options$modifiers3.stop) ev.stopPropagation();
  533. const dx = ev.x - _posStart.x;
  534. const dy = ev.y - _posStart.y;
  535. const distance = Math.sqrt(dx * dx + dy * dy);
  536. options.onMouseUp(ev.timeStamp - _startTimestamp, distance, _hasLongPressed, ev);
  537. }
  538. function onDown(ev) {
  539. var _options$modifiers4, _options$modifiers5, _options$modifiers6;
  540. if ((options === null || options === void 0 || (_options$modifiers4 = options.modifiers) === null || _options$modifiers4 === void 0 ? void 0 : _options$modifiers4.self) && ev.target !== elementRef.value) return;
  541. clear();
  542. if (options === null || options === void 0 || (_options$modifiers5 = options.modifiers) === null || _options$modifiers5 === void 0 ? void 0 : _options$modifiers5.prevent) ev.preventDefault();
  543. if (options === null || options === void 0 || (_options$modifiers6 = options.modifiers) === null || _options$modifiers6 === void 0 ? void 0 : _options$modifiers6.stop) ev.stopPropagation();
  544. posStart = {
  545. x: ev.x,
  546. y: ev.y
  547. };
  548. startTimestamp = ev.timeStamp;
  549. timeout = setTimeout(() => {
  550. hasLongPressed = true;
  551. handler(ev);
  552. }, getDelay(ev));
  553. }
  554. function onMove(ev) {
  555. var _options$modifiers7, _options$modifiers8, _options$modifiers9, _options$distanceThre;
  556. if ((options === null || options === void 0 || (_options$modifiers7 = options.modifiers) === null || _options$modifiers7 === void 0 ? void 0 : _options$modifiers7.self) && ev.target !== elementRef.value) return;
  557. if (!posStart || (options === null || options === void 0 ? void 0 : options.distanceThreshold) === false) return;
  558. if (options === null || options === void 0 || (_options$modifiers8 = options.modifiers) === null || _options$modifiers8 === void 0 ? void 0 : _options$modifiers8.prevent) ev.preventDefault();
  559. if (options === null || options === void 0 || (_options$modifiers9 = options.modifiers) === null || _options$modifiers9 === void 0 ? void 0 : _options$modifiers9.stop) ev.stopPropagation();
  560. const dx = ev.x - posStart.x;
  561. const dy = ev.y - posStart.y;
  562. if (Math.sqrt(dx * dx + dy * dy) >= ((_options$distanceThre = options === null || options === void 0 ? void 0 : options.distanceThreshold) !== null && _options$distanceThre !== void 0 ? _options$distanceThre : DEFAULT_THRESHOLD)) clear();
  563. }
  564. const listenerOptions = {
  565. capture: options === null || options === void 0 || (_options$modifiers10 = options.modifiers) === null || _options$modifiers10 === void 0 ? void 0 : _options$modifiers10.capture,
  566. once: options === null || options === void 0 || (_options$modifiers11 = options.modifiers) === null || _options$modifiers11 === void 0 ? void 0 : _options$modifiers11.once
  567. };
  568. const cleanup = [
  569. useEventListener(elementRef, "pointerdown", onDown, listenerOptions),
  570. useEventListener(elementRef, "pointermove", onMove, listenerOptions),
  571. useEventListener(elementRef, ["pointerup", "pointerleave"], onRelease, listenerOptions)
  572. ];
  573. const stop = () => cleanup.forEach((fn) => fn());
  574. return stop;
  575. }
  576. //#endregion
  577. //#region onStartTyping/index.ts
  578. function isFocusedElementEditable() {
  579. const { activeElement, body } = document;
  580. if (!activeElement) return false;
  581. if (activeElement === body) return false;
  582. switch (activeElement.tagName) {
  583. case "INPUT":
  584. case "TEXTAREA": return true;
  585. }
  586. return activeElement.hasAttribute("contenteditable");
  587. }
  588. function isTypedCharValid({ keyCode, metaKey, ctrlKey, altKey }) {
  589. if (metaKey || ctrlKey || altKey) return false;
  590. if (keyCode >= 48 && keyCode <= 57 || keyCode >= 96 && keyCode <= 105) return true;
  591. if (keyCode >= 65 && keyCode <= 90) return true;
  592. return false;
  593. }
  594. /**
  595. * Fires when users start typing on non-editable elements.
  596. *
  597. * @see https://vueuse.org/onStartTyping
  598. * @param callback
  599. * @param options
  600. */
  601. function onStartTyping(callback, options = {}) {
  602. const { document = defaultDocument } = options;
  603. const keydown = (event) => {
  604. if (!isFocusedElementEditable() && isTypedCharValid(event)) callback(event);
  605. };
  606. if (document) useEventListener(document, "keydown", keydown, { passive: true });
  607. }
  608. //#endregion
  609. //#region templateRef/index.ts
  610. /**
  611. * @deprecated Use Vue's built-in `useTemplateRef` instead.
  612. *
  613. * Shorthand for binding ref to template element.
  614. *
  615. * @see https://vueuse.org/templateRef
  616. * @param key
  617. * @param initialValue
  618. *
  619. * @__NO_SIDE_EFFECTS__
  620. */
  621. function templateRef(key, initialValue = null) {
  622. const instance = (0, vue.getCurrentInstance)();
  623. let _trigger = () => {};
  624. const element = (0, vue.customRef)((track, trigger) => {
  625. _trigger = trigger;
  626. return {
  627. get() {
  628. var _instance$proxy$$refs, _instance$proxy;
  629. track();
  630. return (_instance$proxy$$refs = instance === null || instance === void 0 || (_instance$proxy = instance.proxy) === null || _instance$proxy === void 0 ? void 0 : _instance$proxy.$refs[key]) !== null && _instance$proxy$$refs !== void 0 ? _instance$proxy$$refs : initialValue;
  631. },
  632. set() {}
  633. };
  634. });
  635. (0, _vueuse_shared.tryOnMounted)(_trigger);
  636. (0, vue.onUpdated)(_trigger);
  637. return element;
  638. }
  639. //#endregion
  640. //#region useActiveElement/index.ts
  641. /**
  642. * Reactive `document.activeElement`
  643. *
  644. * @see https://vueuse.org/useActiveElement
  645. * @param options
  646. *
  647. * @__NO_SIDE_EFFECTS__
  648. */
  649. function useActiveElement(options = {}) {
  650. var _options$document;
  651. const { window = defaultWindow, deep = true, triggerOnRemoval = false } = options;
  652. const document = (_options$document = options.document) !== null && _options$document !== void 0 ? _options$document : window === null || window === void 0 ? void 0 : window.document;
  653. const getDeepActiveElement = () => {
  654. let element = document === null || document === void 0 ? void 0 : document.activeElement;
  655. if (deep) {
  656. var _element$shadowRoot;
  657. while (element === null || element === void 0 ? void 0 : element.shadowRoot) element = element === null || element === void 0 || (_element$shadowRoot = element.shadowRoot) === null || _element$shadowRoot === void 0 ? void 0 : _element$shadowRoot.activeElement;
  658. }
  659. return element;
  660. };
  661. const activeElement = (0, vue.shallowRef)();
  662. const trigger = () => {
  663. activeElement.value = getDeepActiveElement();
  664. };
  665. if (window) {
  666. const listenerOptions = {
  667. capture: true,
  668. passive: true
  669. };
  670. useEventListener(window, "blur", (event) => {
  671. if (event.relatedTarget !== null) return;
  672. trigger();
  673. }, listenerOptions);
  674. useEventListener(window, "focus", trigger, listenerOptions);
  675. }
  676. if (triggerOnRemoval) onElementRemoval(activeElement, trigger, { document });
  677. trigger();
  678. return activeElement;
  679. }
  680. //#endregion
  681. //#region useRafFn/index.ts
  682. /**
  683. * Call function on every `requestAnimationFrame`. With controls of pausing and resuming.
  684. *
  685. * @see https://vueuse.org/useRafFn
  686. * @param fn
  687. * @param options
  688. */
  689. function useRafFn(fn, options = {}) {
  690. const { immediate = true, fpsLimit = null, window = defaultWindow, once = false } = options;
  691. const isActive = (0, vue.shallowRef)(false);
  692. const intervalLimit = (0, vue.computed)(() => {
  693. const limit = (0, vue.toValue)(fpsLimit);
  694. return limit ? 1e3 / limit : null;
  695. });
  696. let previousFrameTimestamp = 0;
  697. let rafId = null;
  698. function loop(timestamp) {
  699. if (!isActive.value || !window) return;
  700. if (!previousFrameTimestamp) previousFrameTimestamp = timestamp;
  701. const delta = timestamp - previousFrameTimestamp;
  702. if (intervalLimit.value && delta < intervalLimit.value) {
  703. rafId = window.requestAnimationFrame(loop);
  704. return;
  705. }
  706. previousFrameTimestamp = timestamp;
  707. fn({
  708. delta,
  709. timestamp
  710. });
  711. if (once) {
  712. isActive.value = false;
  713. rafId = null;
  714. return;
  715. }
  716. rafId = window.requestAnimationFrame(loop);
  717. }
  718. function resume() {
  719. if (!isActive.value && window) {
  720. isActive.value = true;
  721. previousFrameTimestamp = 0;
  722. rafId = window.requestAnimationFrame(loop);
  723. }
  724. }
  725. function pause() {
  726. isActive.value = false;
  727. if (rafId != null && window) {
  728. window.cancelAnimationFrame(rafId);
  729. rafId = null;
  730. }
  731. }
  732. if (immediate) resume();
  733. (0, _vueuse_shared.tryOnScopeDispose)(pause);
  734. return {
  735. isActive: (0, vue.shallowReadonly)(isActive),
  736. pause,
  737. resume
  738. };
  739. }
  740. //#endregion
  741. //#region useAnimate/index.ts
  742. /**
  743. * Reactive Web Animations API
  744. *
  745. * @see https://vueuse.org/useAnimate
  746. * @param target
  747. * @param keyframes
  748. * @param options
  749. */
  750. function useAnimate(target, keyframes, options) {
  751. let config;
  752. let animateOptions;
  753. if ((0, _vueuse_shared.isObject)(options)) {
  754. config = options;
  755. animateOptions = (0, _vueuse_shared.objectOmit)(options, [
  756. "window",
  757. "immediate",
  758. "commitStyles",
  759. "persist",
  760. "onReady",
  761. "onError"
  762. ]);
  763. } else {
  764. config = { duration: options };
  765. animateOptions = options;
  766. }
  767. const { window = defaultWindow, immediate = true, commitStyles, persist, playbackRate: _playbackRate = 1, onReady, onError = (e) => {
  768. console.error(e);
  769. } } = config;
  770. const isSupported = /* @__PURE__ */ useSupported(() => window && HTMLElement && "animate" in HTMLElement.prototype);
  771. const animate = (0, vue.shallowRef)(void 0);
  772. const store = (0, vue.shallowReactive)({
  773. startTime: null,
  774. currentTime: null,
  775. timeline: null,
  776. playbackRate: _playbackRate,
  777. pending: false,
  778. playState: immediate ? "idle" : "paused",
  779. replaceState: "active"
  780. });
  781. const pending = (0, vue.computed)(() => store.pending);
  782. const playState = (0, vue.computed)(() => store.playState);
  783. const replaceState = (0, vue.computed)(() => store.replaceState);
  784. const startTime = (0, vue.computed)({
  785. get() {
  786. return store.startTime;
  787. },
  788. set(value) {
  789. store.startTime = value;
  790. if (animate.value) animate.value.startTime = value;
  791. }
  792. });
  793. const currentTime = (0, vue.computed)({
  794. get() {
  795. return store.currentTime;
  796. },
  797. set(value) {
  798. store.currentTime = value;
  799. if (animate.value) {
  800. animate.value.currentTime = value;
  801. syncResume();
  802. }
  803. }
  804. });
  805. const timeline = (0, vue.computed)({
  806. get() {
  807. return store.timeline;
  808. },
  809. set(value) {
  810. store.timeline = value;
  811. if (animate.value) animate.value.timeline = value;
  812. }
  813. });
  814. const playbackRate = (0, vue.computed)({
  815. get() {
  816. return store.playbackRate;
  817. },
  818. set(value) {
  819. store.playbackRate = value;
  820. if (animate.value) animate.value.playbackRate = value;
  821. }
  822. });
  823. const play = () => {
  824. if (animate.value) try {
  825. animate.value.play();
  826. syncResume();
  827. } catch (e) {
  828. syncPause();
  829. onError(e);
  830. }
  831. else update();
  832. };
  833. const pause = () => {
  834. try {
  835. var _animate$value;
  836. (_animate$value = animate.value) === null || _animate$value === void 0 || _animate$value.pause();
  837. syncPause();
  838. } catch (e) {
  839. onError(e);
  840. }
  841. };
  842. const reverse = () => {
  843. if (!animate.value) update();
  844. try {
  845. var _animate$value2;
  846. (_animate$value2 = animate.value) === null || _animate$value2 === void 0 || _animate$value2.reverse();
  847. syncResume();
  848. } catch (e) {
  849. syncPause();
  850. onError(e);
  851. }
  852. };
  853. const finish = () => {
  854. try {
  855. var _animate$value3;
  856. (_animate$value3 = animate.value) === null || _animate$value3 === void 0 || _animate$value3.finish();
  857. syncPause();
  858. } catch (e) {
  859. onError(e);
  860. }
  861. };
  862. const cancel = () => {
  863. try {
  864. var _animate$value4;
  865. (_animate$value4 = animate.value) === null || _animate$value4 === void 0 || _animate$value4.cancel();
  866. syncPause();
  867. } catch (e) {
  868. onError(e);
  869. }
  870. };
  871. (0, vue.watch)(() => unrefElement(target), (el) => {
  872. if (el) update(true);
  873. else animate.value = void 0;
  874. });
  875. (0, vue.watch)(() => keyframes, (value) => {
  876. if (animate.value) {
  877. update();
  878. const targetEl = unrefElement(target);
  879. if (targetEl) animate.value.effect = new KeyframeEffect(targetEl, (0, vue.toValue)(value), animateOptions);
  880. }
  881. }, { deep: true });
  882. (0, _vueuse_shared.tryOnMounted)(() => update(true), false);
  883. (0, _vueuse_shared.tryOnScopeDispose)(cancel);
  884. function update(init) {
  885. const el = unrefElement(target);
  886. if (!isSupported.value || !el) return;
  887. if (!animate.value) animate.value = el.animate((0, vue.toValue)(keyframes), animateOptions);
  888. if (persist) animate.value.persist();
  889. if (_playbackRate !== 1) animate.value.playbackRate = _playbackRate;
  890. if (init && !immediate) animate.value.pause();
  891. else syncResume();
  892. onReady === null || onReady === void 0 || onReady(animate.value);
  893. }
  894. const listenerOptions = { passive: true };
  895. useEventListener(animate, [
  896. "cancel",
  897. "finish",
  898. "remove"
  899. ], syncPause, listenerOptions);
  900. useEventListener(animate, "finish", () => {
  901. var _animate$value5;
  902. if (commitStyles) (_animate$value5 = animate.value) === null || _animate$value5 === void 0 || _animate$value5.commitStyles();
  903. }, listenerOptions);
  904. const { resume: resumeRef, pause: pauseRef } = useRafFn(() => {
  905. if (!animate.value) return;
  906. store.pending = animate.value.pending;
  907. store.playState = animate.value.playState;
  908. store.replaceState = animate.value.replaceState;
  909. store.startTime = animate.value.startTime;
  910. store.currentTime = animate.value.currentTime;
  911. store.timeline = animate.value.timeline;
  912. store.playbackRate = animate.value.playbackRate;
  913. }, { immediate: false });
  914. function syncResume() {
  915. if (isSupported.value) resumeRef();
  916. }
  917. function syncPause() {
  918. if (isSupported.value && window) window.requestAnimationFrame(pauseRef);
  919. }
  920. return {
  921. isSupported,
  922. animate,
  923. play,
  924. pause,
  925. reverse,
  926. finish,
  927. cancel,
  928. pending,
  929. playState,
  930. replaceState,
  931. startTime,
  932. currentTime,
  933. timeline,
  934. playbackRate
  935. };
  936. }
  937. //#endregion
  938. //#region useAsyncQueue/index.ts
  939. /**
  940. * Asynchronous queue task controller.
  941. *
  942. * @see https://vueuse.org/useAsyncQueue
  943. * @param tasks
  944. * @param options
  945. */
  946. function useAsyncQueue(tasks, options) {
  947. const { interrupt = true, onError = _vueuse_shared.noop, onFinished = _vueuse_shared.noop, signal } = options || {};
  948. const promiseState = {
  949. aborted: "aborted",
  950. fulfilled: "fulfilled",
  951. pending: "pending",
  952. rejected: "rejected"
  953. };
  954. const result = (0, vue.reactive)(Array.from(Array.from({ length: tasks.length }), () => ({
  955. state: promiseState.pending,
  956. data: null
  957. })));
  958. const activeIndex = (0, vue.shallowRef)(-1);
  959. if (!tasks || tasks.length === 0) {
  960. onFinished();
  961. return {
  962. activeIndex,
  963. result
  964. };
  965. }
  966. function updateResult(state, res) {
  967. activeIndex.value++;
  968. result[activeIndex.value].data = res;
  969. result[activeIndex.value].state = state;
  970. }
  971. tasks.reduce((prev, curr) => {
  972. return prev.then((prevRes) => {
  973. var _result$activeIndex$v;
  974. if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
  975. updateResult(promiseState.aborted, /* @__PURE__ */ new Error("aborted"));
  976. return;
  977. }
  978. if (((_result$activeIndex$v = result[activeIndex.value]) === null || _result$activeIndex$v === void 0 ? void 0 : _result$activeIndex$v.state) === promiseState.rejected && interrupt) {
  979. onFinished();
  980. return;
  981. }
  982. const done = curr(prevRes).then((currentRes) => {
  983. updateResult(promiseState.fulfilled, currentRes);
  984. if (activeIndex.value === tasks.length - 1) onFinished();
  985. return currentRes;
  986. });
  987. if (!signal) return done;
  988. return Promise.race([done, whenAborted(signal)]);
  989. }).catch((e) => {
  990. if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
  991. updateResult(promiseState.aborted, e);
  992. return e;
  993. }
  994. updateResult(promiseState.rejected, e);
  995. onError();
  996. if (activeIndex.value === tasks.length - 1) onFinished();
  997. return e;
  998. });
  999. }, Promise.resolve());
  1000. return {
  1001. activeIndex,
  1002. result
  1003. };
  1004. }
  1005. function whenAborted(signal) {
  1006. return new Promise((resolve, reject) => {
  1007. const error = /* @__PURE__ */ new Error("aborted");
  1008. if (signal.aborted) reject(error);
  1009. else signal.addEventListener("abort", () => reject(error), { once: true });
  1010. });
  1011. }
  1012. //#endregion
  1013. //#region useAsyncState/index.ts
  1014. /**
  1015. * Reactive async state. Will not block your setup function and will trigger changes once
  1016. * the promise is ready.
  1017. *
  1018. * @see https://vueuse.org/useAsyncState
  1019. * @param promise The promise / async function to be resolved
  1020. * @param initialState The initial state, used until the first evaluation finishes
  1021. * @param options
  1022. */
  1023. function useAsyncState(promise, initialState, options) {
  1024. var _globalThis$reportErr;
  1025. const { immediate = true, delay = 0, onError = (_globalThis$reportErr = globalThis.reportError) !== null && _globalThis$reportErr !== void 0 ? _globalThis$reportErr : _vueuse_shared.noop, onSuccess = _vueuse_shared.noop, resetOnExecute = true, shallow = true, throwError } = options !== null && options !== void 0 ? options : {};
  1026. const state = shallow ? (0, vue.shallowRef)(initialState) : (0, vue.ref)(initialState);
  1027. const isReady = (0, vue.shallowRef)(false);
  1028. const isLoading = (0, vue.shallowRef)(false);
  1029. const error = (0, vue.shallowRef)(void 0);
  1030. let executionsCount = 0;
  1031. async function execute(delay = 0, ...args) {
  1032. const executionId = executionsCount += 1;
  1033. if (resetOnExecute) state.value = (0, vue.toValue)(initialState);
  1034. error.value = void 0;
  1035. isReady.value = false;
  1036. isLoading.value = true;
  1037. if (delay > 0) await (0, _vueuse_shared.promiseTimeout)(delay);
  1038. const _promise = typeof promise === "function" ? promise(...args) : promise;
  1039. try {
  1040. const data = await _promise;
  1041. if (executionId === executionsCount) {
  1042. state.value = data;
  1043. isReady.value = true;
  1044. }
  1045. onSuccess(data);
  1046. return data;
  1047. } catch (e) {
  1048. if (executionId === executionsCount) error.value = e;
  1049. onError(e);
  1050. if (throwError) throw e;
  1051. } finally {
  1052. if (executionId === executionsCount) isLoading.value = false;
  1053. }
  1054. }
  1055. if (immediate) execute(delay);
  1056. const shell = {
  1057. state,
  1058. isReady,
  1059. isLoading,
  1060. error,
  1061. execute,
  1062. executeImmediate: (...args) => execute(0, ...args)
  1063. };
  1064. function waitUntilIsLoaded() {
  1065. return new Promise((resolve, reject) => {
  1066. (0, _vueuse_shared.until)(isLoading).toBe(false).then(() => resolve(shell)).catch(reject);
  1067. });
  1068. }
  1069. return {
  1070. ...shell,
  1071. then(onFulfilled, onRejected) {
  1072. return waitUntilIsLoaded().then(onFulfilled, onRejected);
  1073. }
  1074. };
  1075. }
  1076. //#endregion
  1077. //#region useBase64/serialization.ts
  1078. const defaults = {
  1079. array: (v) => JSON.stringify(v),
  1080. object: (v) => JSON.stringify(v),
  1081. set: (v) => JSON.stringify(Array.from(v)),
  1082. map: (v) => JSON.stringify(Object.fromEntries(v)),
  1083. null: () => ""
  1084. };
  1085. function getDefaultSerialization(target) {
  1086. if (!target) return defaults.null;
  1087. if (target instanceof Map) return defaults.map;
  1088. else if (target instanceof Set) return defaults.set;
  1089. else if (Array.isArray(target)) return defaults.array;
  1090. else return defaults.object;
  1091. }
  1092. //#endregion
  1093. //#region useBase64/index.ts
  1094. function useBase64(target, options) {
  1095. const base64 = (0, vue.shallowRef)("");
  1096. const promise = (0, vue.shallowRef)();
  1097. function execute() {
  1098. if (!_vueuse_shared.isClient) return;
  1099. promise.value = new Promise((resolve, reject) => {
  1100. try {
  1101. const _target = (0, vue.toValue)(target);
  1102. if (_target == null) resolve("");
  1103. else if (typeof _target === "string") resolve(blobToBase64(new Blob([_target], { type: "text/plain" })));
  1104. else if (_target instanceof Blob) resolve(blobToBase64(_target));
  1105. else if (_target instanceof ArrayBuffer) resolve(window.btoa(String.fromCharCode(...new Uint8Array(_target))));
  1106. else if (_target instanceof HTMLCanvasElement) resolve(_target.toDataURL(options === null || options === void 0 ? void 0 : options.type, options === null || options === void 0 ? void 0 : options.quality));
  1107. else if (_target instanceof HTMLImageElement) {
  1108. const img = _target.cloneNode(false);
  1109. img.crossOrigin = "Anonymous";
  1110. imgLoaded(img).then(() => {
  1111. const canvas = document.createElement("canvas");
  1112. const ctx = canvas.getContext("2d");
  1113. canvas.width = img.width;
  1114. canvas.height = img.height;
  1115. ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
  1116. resolve(canvas.toDataURL(options === null || options === void 0 ? void 0 : options.type, options === null || options === void 0 ? void 0 : options.quality));
  1117. }).catch(reject);
  1118. } else if (typeof _target === "object") {
  1119. const serialized = ((options === null || options === void 0 ? void 0 : options.serializer) || getDefaultSerialization(_target))(_target);
  1120. return resolve(blobToBase64(new Blob([serialized], { type: "application/json" })));
  1121. } else reject(/* @__PURE__ */ new Error("target is unsupported types"));
  1122. } catch (error) {
  1123. reject(error);
  1124. }
  1125. });
  1126. promise.value.then((res) => {
  1127. base64.value = (options === null || options === void 0 ? void 0 : options.dataUrl) === false ? res.replace(/^data:.*?;base64,/, "") : res;
  1128. });
  1129. return promise.value;
  1130. }
  1131. if ((0, vue.isRef)(target) || typeof target === "function") (0, vue.watch)(target, execute, { immediate: true });
  1132. else execute();
  1133. return {
  1134. base64,
  1135. promise,
  1136. execute
  1137. };
  1138. }
  1139. function imgLoaded(img) {
  1140. return new Promise((resolve, reject) => {
  1141. if (!img.complete) {
  1142. img.onload = () => {
  1143. resolve();
  1144. };
  1145. img.onerror = reject;
  1146. } else resolve();
  1147. });
  1148. }
  1149. function blobToBase64(blob) {
  1150. return new Promise((resolve, reject) => {
  1151. const fr = new FileReader();
  1152. fr.onload = (e) => {
  1153. resolve(e.target.result);
  1154. };
  1155. fr.onerror = reject;
  1156. fr.readAsDataURL(blob);
  1157. });
  1158. }
  1159. //#endregion
  1160. //#region useBattery/index.ts
  1161. /**
  1162. * Reactive Battery Status API.
  1163. *
  1164. * @see https://vueuse.org/useBattery
  1165. *
  1166. * @__NO_SIDE_EFFECTS__
  1167. */
  1168. function useBattery(options = {}) {
  1169. const { navigator = defaultNavigator } = options;
  1170. const events = [
  1171. "chargingchange",
  1172. "chargingtimechange",
  1173. "dischargingtimechange",
  1174. "levelchange"
  1175. ];
  1176. const isSupported = /* @__PURE__ */ useSupported(() => navigator && "getBattery" in navigator && typeof navigator.getBattery === "function");
  1177. const charging = (0, vue.shallowRef)(false);
  1178. const chargingTime = (0, vue.shallowRef)(0);
  1179. const dischargingTime = (0, vue.shallowRef)(0);
  1180. const level = (0, vue.shallowRef)(1);
  1181. let battery;
  1182. function updateBatteryInfo() {
  1183. charging.value = this.charging;
  1184. chargingTime.value = this.chargingTime || 0;
  1185. dischargingTime.value = this.dischargingTime || 0;
  1186. level.value = this.level;
  1187. }
  1188. if (isSupported.value) navigator.getBattery().then((_battery) => {
  1189. battery = _battery;
  1190. updateBatteryInfo.call(battery);
  1191. useEventListener(battery, events, updateBatteryInfo, { passive: true });
  1192. });
  1193. return {
  1194. isSupported,
  1195. charging,
  1196. chargingTime,
  1197. dischargingTime,
  1198. level
  1199. };
  1200. }
  1201. //#endregion
  1202. //#region useBluetooth/index.ts
  1203. /* @__NO_SIDE_EFFECTS__ */
  1204. function useBluetooth(options) {
  1205. let { acceptAllDevices = false } = options || {};
  1206. const { filters = void 0, optionalServices = void 0, navigator = defaultNavigator } = options || {};
  1207. const isSupported = /* @__PURE__ */ useSupported(() => navigator && "bluetooth" in navigator);
  1208. const device = (0, vue.shallowRef)();
  1209. const error = (0, vue.shallowRef)(null);
  1210. (0, vue.watch)(device, () => {
  1211. connectToBluetoothGATTServer();
  1212. });
  1213. async function requestDevice() {
  1214. if (!isSupported.value) return;
  1215. error.value = null;
  1216. if (filters && filters.length > 0) acceptAllDevices = false;
  1217. try {
  1218. device.value = await (navigator === null || navigator === void 0 ? void 0 : navigator.bluetooth.requestDevice({
  1219. acceptAllDevices,
  1220. filters,
  1221. optionalServices
  1222. }));
  1223. } catch (err) {
  1224. error.value = err;
  1225. }
  1226. }
  1227. const server = (0, vue.shallowRef)();
  1228. const isConnected = (0, vue.shallowRef)(false);
  1229. function reset() {
  1230. isConnected.value = false;
  1231. device.value = void 0;
  1232. server.value = void 0;
  1233. }
  1234. async function connectToBluetoothGATTServer() {
  1235. error.value = null;
  1236. if (device.value && device.value.gatt) {
  1237. useEventListener(device, "gattserverdisconnected", reset, { passive: true });
  1238. try {
  1239. server.value = await device.value.gatt.connect();
  1240. isConnected.value = server.value.connected;
  1241. } catch (err) {
  1242. error.value = err;
  1243. }
  1244. }
  1245. }
  1246. (0, _vueuse_shared.tryOnMounted)(() => {
  1247. var _device$value$gatt;
  1248. if (device.value) (_device$value$gatt = device.value.gatt) === null || _device$value$gatt === void 0 || _device$value$gatt.connect();
  1249. });
  1250. (0, _vueuse_shared.tryOnScopeDispose)(() => {
  1251. var _device$value$gatt2;
  1252. if (device.value) (_device$value$gatt2 = device.value.gatt) === null || _device$value$gatt2 === void 0 || _device$value$gatt2.disconnect();
  1253. });
  1254. return {
  1255. isSupported,
  1256. isConnected: (0, vue.shallowReadonly)(isConnected),
  1257. device,
  1258. requestDevice,
  1259. server,
  1260. error
  1261. };
  1262. }
  1263. //#endregion
  1264. //#region useSSRWidth/index.ts
  1265. const ssrWidthSymbol = Symbol("vueuse-ssr-width");
  1266. /* @__NO_SIDE_EFFECTS__ */
  1267. function useSSRWidth() {
  1268. const ssrWidth = (0, vue.hasInjectionContext)() ? (0, _vueuse_shared.injectLocal)(ssrWidthSymbol, null) : null;
  1269. return typeof ssrWidth === "number" ? ssrWidth : void 0;
  1270. }
  1271. function provideSSRWidth(width, app) {
  1272. if (app !== void 0) app.provide(ssrWidthSymbol, width);
  1273. else (0, _vueuse_shared.provideLocal)(ssrWidthSymbol, width);
  1274. }
  1275. //#endregion
  1276. //#region useMediaQuery/index.ts
  1277. /**
  1278. * Reactive Media Query.
  1279. *
  1280. * @see https://vueuse.org/useMediaQuery
  1281. * @param query
  1282. * @param options
  1283. */
  1284. function useMediaQuery(query, options = {}) {
  1285. const { window = defaultWindow, ssrWidth = /* @__PURE__ */ useSSRWidth() } = options;
  1286. const isSupported = /* @__PURE__ */ useSupported(() => window && "matchMedia" in window && typeof window.matchMedia === "function");
  1287. const ssrSupport = (0, vue.shallowRef)(typeof ssrWidth === "number");
  1288. const mediaQuery = (0, vue.shallowRef)();
  1289. const matches = (0, vue.shallowRef)(false);
  1290. const handler = (event) => {
  1291. matches.value = event.matches;
  1292. };
  1293. (0, vue.watchEffect)(() => {
  1294. if (ssrSupport.value) {
  1295. ssrSupport.value = !isSupported.value;
  1296. matches.value = (0, vue.toValue)(query).split(",").some((queryString) => {
  1297. const not = queryString.includes("not all");
  1298. const minWidth = queryString.match(/\(\s*min-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
  1299. const maxWidth = queryString.match(/\(\s*max-width:\s*(-?\d+(?:\.\d*)?[a-z]+\s*)\)/);
  1300. let res = Boolean(minWidth || maxWidth);
  1301. if (minWidth && res) res = ssrWidth >= (0, _vueuse_shared.pxValue)(minWidth[1]);
  1302. if (maxWidth && res) res = ssrWidth <= (0, _vueuse_shared.pxValue)(maxWidth[1]);
  1303. return not ? !res : res;
  1304. });
  1305. return;
  1306. }
  1307. if (!isSupported.value) return;
  1308. mediaQuery.value = window.matchMedia((0, vue.toValue)(query));
  1309. matches.value = mediaQuery.value.matches;
  1310. });
  1311. useEventListener(mediaQuery, "change", handler, { passive: true });
  1312. return (0, vue.computed)(() => matches.value);
  1313. }
  1314. //#endregion
  1315. //#region useBreakpoints/breakpoints.ts
  1316. /**
  1317. * Breakpoints from Tailwind V2
  1318. *
  1319. * @see https://tailwindcss.com/docs/breakpoints
  1320. */
  1321. const breakpointsTailwind = {
  1322. "sm": 640,
  1323. "md": 768,
  1324. "lg": 1024,
  1325. "xl": 1280,
  1326. "2xl": 1536
  1327. };
  1328. /**
  1329. * Breakpoints from Bootstrap V5
  1330. *
  1331. * @see https://getbootstrap.com/docs/5.0/layout/breakpoints
  1332. */
  1333. const breakpointsBootstrapV5 = {
  1334. xs: 0,
  1335. sm: 576,
  1336. md: 768,
  1337. lg: 992,
  1338. xl: 1200,
  1339. xxl: 1400
  1340. };
  1341. /**
  1342. * Breakpoints from Vuetify V2
  1343. *
  1344. * @see https://v2.vuetifyjs.com/en/features/breakpoints/
  1345. */
  1346. const breakpointsVuetifyV2 = {
  1347. xs: 0,
  1348. sm: 600,
  1349. md: 960,
  1350. lg: 1264,
  1351. xl: 1904
  1352. };
  1353. /**
  1354. * Breakpoints from Vuetify V3
  1355. *
  1356. * @see https://vuetifyjs.com/en/styles/float/#overview
  1357. */
  1358. const breakpointsVuetifyV3 = {
  1359. xs: 0,
  1360. sm: 600,
  1361. md: 960,
  1362. lg: 1280,
  1363. xl: 1920,
  1364. xxl: 2560
  1365. };
  1366. /**
  1367. * Alias to `breakpointsVuetifyV2`
  1368. *
  1369. * @deprecated explictly use `breakpointsVuetifyV2` or `breakpointsVuetifyV3` instead
  1370. */
  1371. const breakpointsVuetify = breakpointsVuetifyV2;
  1372. /**
  1373. * Breakpoints from Ant Design
  1374. *
  1375. * @see https://ant.design/components/layout/#breakpoint-width
  1376. */
  1377. const breakpointsAntDesign = {
  1378. xs: 480,
  1379. sm: 576,
  1380. md: 768,
  1381. lg: 992,
  1382. xl: 1200,
  1383. xxl: 1600
  1384. };
  1385. /**
  1386. * Breakpoints from Quasar V2
  1387. *
  1388. * @see https://quasar.dev/style/breakpoints
  1389. */
  1390. const breakpointsQuasar = {
  1391. xs: 0,
  1392. sm: 600,
  1393. md: 1024,
  1394. lg: 1440,
  1395. xl: 1920
  1396. };
  1397. /**
  1398. * Sematic Breakpoints
  1399. */
  1400. const breakpointsSematic = {
  1401. mobileS: 320,
  1402. mobileM: 375,
  1403. mobileL: 425,
  1404. tablet: 768,
  1405. laptop: 1024,
  1406. laptopL: 1440,
  1407. desktop4K: 2560
  1408. };
  1409. /**
  1410. * Breakpoints from Master CSS
  1411. *
  1412. * @see https://docs.master.co/css/breakpoints
  1413. */
  1414. const breakpointsMasterCss = {
  1415. "3xs": 360,
  1416. "2xs": 480,
  1417. "xs": 600,
  1418. "sm": 768,
  1419. "md": 1024,
  1420. "lg": 1280,
  1421. "xl": 1440,
  1422. "2xl": 1600,
  1423. "3xl": 1920,
  1424. "4xl": 2560
  1425. };
  1426. /**
  1427. * Breakpoints from PrimeFlex
  1428. *
  1429. * @see https://primeflex.org/installation
  1430. */
  1431. const breakpointsPrimeFlex = {
  1432. sm: 576,
  1433. md: 768,
  1434. lg: 992,
  1435. xl: 1200
  1436. };
  1437. /**
  1438. * Breakpoints from ElementUI/ElementPlus
  1439. *
  1440. * @see https://element.eleme.io/#/en-US/component/layout
  1441. * @see https://element-plus.org/en-US/component/layout.html
  1442. */
  1443. const breakpointsElement = {
  1444. xs: 0,
  1445. sm: 768,
  1446. md: 992,
  1447. lg: 1200,
  1448. xl: 1920
  1449. };
  1450. //#endregion
  1451. //#region useBreakpoints/index.ts
  1452. /**
  1453. * Reactively viewport breakpoints
  1454. *
  1455. * @see https://vueuse.org/useBreakpoints
  1456. *
  1457. * @__NO_SIDE_EFFECTS__
  1458. */
  1459. function useBreakpoints(breakpoints, options = {}) {
  1460. function getValue(k, delta) {
  1461. let v = (0, vue.toValue)(breakpoints[(0, vue.toValue)(k)]);
  1462. if (delta != null) v = (0, _vueuse_shared.increaseWithUnit)(v, delta);
  1463. if (typeof v === "number") v = `${v}px`;
  1464. return v;
  1465. }
  1466. const { window = defaultWindow, strategy = "min-width", ssrWidth = /* @__PURE__ */ useSSRWidth() } = options;
  1467. const ssrSupport = typeof ssrWidth === "number";
  1468. const mounted = ssrSupport ? (0, vue.shallowRef)(false) : { value: true };
  1469. if (ssrSupport) (0, _vueuse_shared.tryOnMounted)(() => mounted.value = !!window);
  1470. function match(query, size) {
  1471. if (!mounted.value && ssrSupport) return query === "min" ? ssrWidth >= (0, _vueuse_shared.pxValue)(size) : ssrWidth <= (0, _vueuse_shared.pxValue)(size);
  1472. if (!window) return false;
  1473. return window.matchMedia(`(${query}-width: ${size})`).matches;
  1474. }
  1475. const greaterOrEqual = (k) => {
  1476. return useMediaQuery(() => `(min-width: ${getValue(k)})`, options);
  1477. };
  1478. const smallerOrEqual = (k) => {
  1479. return useMediaQuery(() => `(max-width: ${getValue(k)})`, options);
  1480. };
  1481. const shortcutMethods = Object.keys(breakpoints).reduce((shortcuts, k) => {
  1482. Object.defineProperty(shortcuts, k, {
  1483. get: () => strategy === "min-width" ? greaterOrEqual(k) : smallerOrEqual(k),
  1484. enumerable: true,
  1485. configurable: true
  1486. });
  1487. return shortcuts;
  1488. }, {});
  1489. function current() {
  1490. const points = Object.keys(breakpoints).map((k) => [
  1491. k,
  1492. shortcutMethods[k],
  1493. (0, _vueuse_shared.pxValue)(getValue(k))
  1494. ]).sort((a, b) => a[2] - b[2]);
  1495. return (0, vue.computed)(() => points.filter(([, v]) => v.value).map(([k]) => k));
  1496. }
  1497. return Object.assign(shortcutMethods, {
  1498. greaterOrEqual,
  1499. smallerOrEqual,
  1500. greater(k) {
  1501. return useMediaQuery(() => `(min-width: ${getValue(k, .1)})`, options);
  1502. },
  1503. smaller(k) {
  1504. return useMediaQuery(() => `(max-width: ${getValue(k, -.1)})`, options);
  1505. },
  1506. between(a, b) {
  1507. return useMediaQuery(() => `(min-width: ${getValue(a)}) and (max-width: ${getValue(b, -.1)})`, options);
  1508. },
  1509. isGreater(k) {
  1510. return match("min", getValue(k, .1));
  1511. },
  1512. isGreaterOrEqual(k) {
  1513. return match("min", getValue(k));
  1514. },
  1515. isSmaller(k) {
  1516. return match("max", getValue(k, -.1));
  1517. },
  1518. isSmallerOrEqual(k) {
  1519. return match("max", getValue(k));
  1520. },
  1521. isInBetween(a, b) {
  1522. return match("min", getValue(a)) && match("max", getValue(b, -.1));
  1523. },
  1524. current,
  1525. active() {
  1526. const bps = current();
  1527. return (0, vue.computed)(() => bps.value.length === 0 ? "" : bps.value.at(strategy === "min-width" ? -1 : 0));
  1528. }
  1529. });
  1530. }
  1531. //#endregion
  1532. //#region useBroadcastChannel/index.ts
  1533. /**
  1534. * Reactive BroadcastChannel
  1535. *
  1536. * @see https://vueuse.org/useBroadcastChannel
  1537. * @see https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel
  1538. * @param options
  1539. *
  1540. */
  1541. function useBroadcastChannel(options) {
  1542. const { name, window = defaultWindow } = options;
  1543. const isSupported = /* @__PURE__ */ useSupported(() => window && "BroadcastChannel" in window);
  1544. const isClosed = (0, vue.shallowRef)(false);
  1545. const channel = (0, vue.shallowRef)();
  1546. const data = (0, vue.shallowRef)();
  1547. const error = (0, vue.shallowRef)(null);
  1548. const post = (data) => {
  1549. if (channel.value) channel.value.postMessage(data);
  1550. };
  1551. const close = () => {
  1552. if (channel.value) channel.value.close();
  1553. isClosed.value = true;
  1554. };
  1555. if (isSupported.value) (0, _vueuse_shared.tryOnMounted)(() => {
  1556. error.value = null;
  1557. channel.value = new BroadcastChannel(name);
  1558. const listenerOptions = { passive: true };
  1559. useEventListener(channel, "message", (e) => {
  1560. data.value = e.data;
  1561. }, listenerOptions);
  1562. useEventListener(channel, "messageerror", (e) => {
  1563. error.value = e;
  1564. }, listenerOptions);
  1565. useEventListener(channel, "close", () => {
  1566. isClosed.value = true;
  1567. }, listenerOptions);
  1568. });
  1569. (0, _vueuse_shared.tryOnScopeDispose)(() => {
  1570. close();
  1571. });
  1572. return {
  1573. isSupported,
  1574. channel,
  1575. data,
  1576. post,
  1577. close,
  1578. error,
  1579. isClosed
  1580. };
  1581. }
  1582. //#endregion
  1583. //#region useBrowserLocation/index.ts
  1584. const WRITABLE_PROPERTIES = [
  1585. "hash",
  1586. "host",
  1587. "hostname",
  1588. "href",
  1589. "pathname",
  1590. "port",
  1591. "protocol",
  1592. "search"
  1593. ];
  1594. /**
  1595. * Reactive browser location.
  1596. *
  1597. * @see https://vueuse.org/useBrowserLocation
  1598. *
  1599. * @__NO_SIDE_EFFECTS__
  1600. */
  1601. function useBrowserLocation(options = {}) {
  1602. const { window = defaultWindow } = options;
  1603. const refs = Object.fromEntries(WRITABLE_PROPERTIES.map((key) => [key, (0, vue.ref)()]));
  1604. for (const [key, ref] of (0, _vueuse_shared.objectEntries)(refs)) (0, vue.watch)(ref, (value) => {
  1605. if (!(window === null || window === void 0 ? void 0 : window.location) || window.location[key] === value) return;
  1606. window.location[key] = value;
  1607. });
  1608. const buildState = (trigger) => {
  1609. var _window$location;
  1610. const { state, length } = (window === null || window === void 0 ? void 0 : window.history) || {};
  1611. const { origin } = (window === null || window === void 0 ? void 0 : window.location) || {};
  1612. for (const key of WRITABLE_PROPERTIES) refs[key].value = window === null || window === void 0 || (_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location[key];
  1613. return (0, vue.reactive)({
  1614. trigger,
  1615. state,
  1616. length,
  1617. origin,
  1618. ...refs
  1619. });
  1620. };
  1621. const state = (0, vue.ref)(buildState("load"));
  1622. if (window) {
  1623. const listenerOptions = { passive: true };
  1624. useEventListener(window, "popstate", () => state.value = buildState("popstate"), listenerOptions);
  1625. useEventListener(window, "hashchange", () => state.value = buildState("hashchange"), listenerOptions);
  1626. }
  1627. return state;
  1628. }
  1629. //#endregion
  1630. //#region useCached/index.ts
  1631. function useCached(refValue, comparator = (newSourceValue, cachedValue) => newSourceValue === cachedValue, options) {
  1632. const { deepRefs = true, ...watchOptions } = options || {};
  1633. const cachedValue = (0, _vueuse_shared.createRef)(refValue.value, deepRefs);
  1634. (0, vue.watch)(() => refValue.value, (value) => {
  1635. if (!comparator(value, cachedValue.value)) cachedValue.value = value;
  1636. }, watchOptions);
  1637. return cachedValue;
  1638. }
  1639. //#endregion
  1640. //#region usePermission/index.ts
  1641. /**
  1642. * Reactive Permissions API.
  1643. *
  1644. * @see https://vueuse.org/usePermission
  1645. *
  1646. * @__NO_SIDE_EFFECTS__
  1647. */
  1648. function usePermission(permissionDesc, options = {}) {
  1649. const { controls = false, navigator = defaultNavigator } = options;
  1650. const isSupported = /* @__PURE__ */ useSupported(() => navigator && "permissions" in navigator);
  1651. const permissionStatus = (0, vue.shallowRef)();
  1652. const desc = typeof permissionDesc === "string" ? { name: permissionDesc } : permissionDesc;
  1653. const state = (0, vue.shallowRef)();
  1654. const update = () => {
  1655. var _permissionStatus$val, _permissionStatus$val2;
  1656. state.value = (_permissionStatus$val = (_permissionStatus$val2 = permissionStatus.value) === null || _permissionStatus$val2 === void 0 ? void 0 : _permissionStatus$val2.state) !== null && _permissionStatus$val !== void 0 ? _permissionStatus$val : "prompt";
  1657. };
  1658. useEventListener(permissionStatus, "change", update, { passive: true });
  1659. const query = (0, _vueuse_shared.createSingletonPromise)(async () => {
  1660. if (!isSupported.value) return;
  1661. if (!permissionStatus.value) try {
  1662. permissionStatus.value = await navigator.permissions.query(desc);
  1663. } catch (_unused) {
  1664. permissionStatus.value = void 0;
  1665. } finally {
  1666. update();
  1667. }
  1668. if (controls) return (0, vue.toRaw)(permissionStatus.value);
  1669. });
  1670. query();
  1671. if (controls) return {
  1672. state,
  1673. isSupported,
  1674. query
  1675. };
  1676. else return state;
  1677. }
  1678. //#endregion
  1679. //#region useClipboard/index.ts
  1680. function useClipboard(options = {}) {
  1681. const { navigator = defaultNavigator, read = false, source, copiedDuring = 1500, legacy = false } = options;
  1682. const isClipboardApiSupported = /* @__PURE__ */ useSupported(() => navigator && "clipboard" in navigator);
  1683. const permissionRead = usePermission("clipboard-read");
  1684. const permissionWrite = usePermission("clipboard-write");
  1685. const isSupported = (0, vue.computed)(() => isClipboardApiSupported.value || legacy);
  1686. const text = (0, vue.shallowRef)("");
  1687. const copied = (0, vue.shallowRef)(false);
  1688. const copyPending = (0, vue.shallowRef)(false);
  1689. const timeout = (0, _vueuse_shared.useTimeoutFn)(() => copied.value = false, copiedDuring, { immediate: false });
  1690. let lastLegacyId = 0;
  1691. async function updateText() {
  1692. let useLegacy = !(isClipboardApiSupported.value && isAllowed(permissionRead.value));
  1693. if (!useLegacy) try {
  1694. text.value = await navigator.clipboard.readText();
  1695. } catch (_unused) {
  1696. useLegacy = true;
  1697. }
  1698. if (useLegacy) text.value = legacyRead();
  1699. }
  1700. if (isSupported.value && read) useEventListener(["copy", "cut"], updateText, { passive: true });
  1701. async function copy(value) {
  1702. const resolvedValue = value !== null && value !== void 0 ? value : (0, vue.toValue)(source);
  1703. if (isSupported.value && resolvedValue != null) {
  1704. copyPending.value = true;
  1705. let useLegacy = !(isClipboardApiSupported.value && isAllowed(permissionWrite.value));
  1706. if (!useLegacy) try {
  1707. const clipboardItem = createClipboardItem(resolvedValue);
  1708. await navigator.clipboard.write([clipboardItem]);
  1709. } catch (_unused2) {
  1710. useLegacy = true;
  1711. }
  1712. if (useLegacy) if (typeof resolvedValue === "string") {
  1713. text.value = resolvedValue;
  1714. legacyCopy(resolvedValue);
  1715. } else {
  1716. const currentId = ++lastLegacyId;
  1717. const resolvedText = await resolvedValue();
  1718. if (resolvedText != null && currentId === lastLegacyId) {
  1719. text.value = resolvedText;
  1720. legacyCopy(resolvedText);
  1721. }
  1722. }
  1723. copied.value = true;
  1724. timeout.start();
  1725. copyPending.value = false;
  1726. }
  1727. }
  1728. function createClipboardItem(value) {
  1729. if (typeof value === "string") {
  1730. text.value = value;
  1731. return new ClipboardItem({ "text/plain": value });
  1732. } else return new ClipboardItem({ "text/plain": value().then((resolvedText = "") => {
  1733. text.value = resolvedText;
  1734. return new Blob([resolvedText], { type: "text/plain" });
  1735. }) });
  1736. }
  1737. function legacyCopy(value) {
  1738. const ta = document.createElement("textarea");
  1739. ta.value = value;
  1740. ta.style.position = "absolute";
  1741. ta.style.opacity = "0";
  1742. ta.setAttribute("readonly", "");
  1743. document.body.appendChild(ta);
  1744. ta.select();
  1745. document.execCommand("copy");
  1746. ta.remove();
  1747. }
  1748. function legacyRead() {
  1749. var _document$getSelectio, _document, _document$getSelectio2;
  1750. return (_document$getSelectio = (_document = document) === null || _document === void 0 || (_document$getSelectio2 = _document.getSelection) === null || _document$getSelectio2 === void 0 || (_document$getSelectio2 = _document$getSelectio2.call(_document)) === null || _document$getSelectio2 === void 0 ? void 0 : _document$getSelectio2.toString()) !== null && _document$getSelectio !== void 0 ? _document$getSelectio : "";
  1751. }
  1752. function isAllowed(status) {
  1753. return status === "granted" || status === "prompt";
  1754. }
  1755. return {
  1756. copyPending: (0, vue.shallowReadonly)(copyPending),
  1757. isSupported,
  1758. text: (0, vue.shallowReadonly)(text),
  1759. copied: (0, vue.shallowReadonly)(copied),
  1760. copy
  1761. };
  1762. }
  1763. //#endregion
  1764. //#region useClipboardItems/index.ts
  1765. function useClipboardItems(options = {}) {
  1766. const { navigator = defaultNavigator, read = false, source, copiedDuring = 1500 } = options;
  1767. const isSupported = /* @__PURE__ */ useSupported(() => navigator && "clipboard" in navigator);
  1768. const content = (0, vue.shallowRef)([]);
  1769. const copied = (0, vue.shallowRef)(false);
  1770. const timeout = (0, _vueuse_shared.useTimeoutFn)(() => copied.value = false, copiedDuring, { immediate: false });
  1771. function updateContent() {
  1772. if (isSupported.value) navigator.clipboard.read().then((items) => {
  1773. content.value = items;
  1774. });
  1775. }
  1776. if (isSupported.value && read) useEventListener(["copy", "cut"], updateContent, { passive: true });
  1777. async function copy(value = (0, vue.toValue)(source)) {
  1778. if (isSupported.value && value != null) {
  1779. await navigator.clipboard.write(value);
  1780. content.value = value;
  1781. copied.value = true;
  1782. timeout.start();
  1783. }
  1784. }
  1785. return {
  1786. isSupported,
  1787. content: (0, vue.shallowReadonly)(content),
  1788. copied: (0, vue.shallowReadonly)(copied),
  1789. copy,
  1790. read: updateContent
  1791. };
  1792. }
  1793. //#endregion
  1794. //#region useCloned/index.ts
  1795. function cloneFnJSON(source) {
  1796. return JSON.parse(JSON.stringify(source));
  1797. }
  1798. function useCloned(source, options = {}) {
  1799. const cloned = (0, vue.ref)({});
  1800. const isModified = (0, vue.shallowRef)(false);
  1801. let _lastSync = false;
  1802. const { manual, clone = cloneFnJSON, deep = true, immediate = true } = options;
  1803. (0, vue.watch)(cloned, () => {
  1804. if (_lastSync) {
  1805. _lastSync = false;
  1806. return;
  1807. }
  1808. isModified.value = true;
  1809. }, {
  1810. deep: true,
  1811. flush: "sync"
  1812. });
  1813. function sync() {
  1814. _lastSync = true;
  1815. isModified.value = false;
  1816. cloned.value = clone((0, vue.toValue)(source));
  1817. }
  1818. if (!manual && ((0, vue.isRef)(source) || typeof source === "function")) (0, vue.watch)(source, sync, {
  1819. ...options,
  1820. deep,
  1821. immediate
  1822. });
  1823. else sync();
  1824. return {
  1825. cloned,
  1826. isModified,
  1827. sync
  1828. };
  1829. }
  1830. //#endregion
  1831. //#region ssr-handlers.ts
  1832. const _global = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
  1833. const globalKey = "__vueuse_ssr_handlers__";
  1834. const handlers = /* @__PURE__ */ getHandlers();
  1835. function getHandlers() {
  1836. if (!(globalKey in _global)) _global[globalKey] = _global[globalKey] || {};
  1837. return _global[globalKey];
  1838. }
  1839. function getSSRHandler(key, fallback) {
  1840. return handlers[key] || fallback;
  1841. }
  1842. function setSSRHandler(key, fn) {
  1843. handlers[key] = fn;
  1844. }
  1845. //#endregion
  1846. //#region usePreferredDark/index.ts
  1847. /**
  1848. * Reactive dark theme preference.
  1849. *
  1850. * @see https://vueuse.org/usePreferredDark
  1851. * @param [options]
  1852. *
  1853. * @__NO_SIDE_EFFECTS__
  1854. */
  1855. function usePreferredDark(options) {
  1856. return useMediaQuery("(prefers-color-scheme: dark)", options);
  1857. }
  1858. //#endregion
  1859. //#region useStorage/guess.ts
  1860. function guessSerializerType(rawInit) {
  1861. return rawInit == null ? "any" : rawInit instanceof Set ? "set" : rawInit instanceof Map ? "map" : rawInit instanceof Date ? "date" : typeof rawInit === "boolean" ? "boolean" : typeof rawInit === "string" ? "string" : typeof rawInit === "object" ? "object" : !Number.isNaN(rawInit) ? "number" : "any";
  1862. }
  1863. //#endregion
  1864. //#region useStorage/index.ts
  1865. const StorageSerializers = {
  1866. boolean: {
  1867. read: (v) => v === "true",
  1868. write: (v) => String(v)
  1869. },
  1870. object: {
  1871. read: (v) => JSON.parse(v),
  1872. write: (v) => JSON.stringify(v)
  1873. },
  1874. number: {
  1875. read: (v) => Number.parseFloat(v),
  1876. write: (v) => String(v)
  1877. },
  1878. any: {
  1879. read: (v) => v,
  1880. write: (v) => String(v)
  1881. },
  1882. string: {
  1883. read: (v) => v,
  1884. write: (v) => String(v)
  1885. },
  1886. map: {
  1887. read: (v) => new Map(JSON.parse(v)),
  1888. write: (v) => JSON.stringify(Array.from(v.entries()))
  1889. },
  1890. set: {
  1891. read: (v) => new Set(JSON.parse(v)),
  1892. write: (v) => JSON.stringify(Array.from(v))
  1893. },
  1894. date: {
  1895. read: (v) => new Date(v),
  1896. write: (v) => v.toISOString()
  1897. }
  1898. };
  1899. const customStorageEventName = "vueuse-storage";
  1900. /**
  1901. * Reactive LocalStorage/SessionStorage.
  1902. *
  1903. * @see https://vueuse.org/useStorage
  1904. */
  1905. function useStorage(key, defaults, storage, options = {}) {
  1906. var _options$serializer;
  1907. const { flush = "pre", deep = true, listenToStorageChanges = true, writeDefaults = true, mergeDefaults = false, shallow, window = defaultWindow, eventFilter, onError = (e) => {
  1908. console.error(e);
  1909. }, initOnMounted } = options;
  1910. const data = (shallow ? vue.shallowRef : vue.ref)(typeof defaults === "function" ? defaults() : defaults);
  1911. const keyComputed = (0, vue.computed)(() => (0, vue.toValue)(key));
  1912. if (!storage) try {
  1913. storage = getSSRHandler("getDefaultStorage", () => defaultWindow === null || defaultWindow === void 0 ? void 0 : defaultWindow.localStorage)();
  1914. } catch (e) {
  1915. onError(e);
  1916. }
  1917. if (!storage) return data;
  1918. const rawInit = (0, vue.toValue)(defaults);
  1919. const type = guessSerializerType(rawInit);
  1920. const serializer = (_options$serializer = options.serializer) !== null && _options$serializer !== void 0 ? _options$serializer : StorageSerializers[type];
  1921. const { pause: pauseWatch, resume: resumeWatch } = (0, _vueuse_shared.watchPausable)(data, (newValue) => write(newValue), {
  1922. flush,
  1923. deep,
  1924. eventFilter
  1925. });
  1926. (0, vue.watch)(keyComputed, () => update(), { flush });
  1927. let firstMounted = false;
  1928. const onStorageEvent = (ev) => {
  1929. if (initOnMounted && !firstMounted) return;
  1930. update(ev);
  1931. };
  1932. const onStorageCustomEvent = (ev) => {
  1933. if (initOnMounted && !firstMounted) return;
  1934. updateFromCustomEvent(ev);
  1935. };
  1936. /**
  1937. * The custom event is needed for same-document syncing when using custom
  1938. * storage backends, but it doesn't work across different documents.
  1939. *
  1940. * TODO: Consider implementing a BroadcastChannel-based solution that fixes this.
  1941. */
  1942. if (window && listenToStorageChanges) if (storage instanceof Storage) useEventListener(window, "storage", onStorageEvent, { passive: true });
  1943. else useEventListener(window, customStorageEventName, onStorageCustomEvent);
  1944. if (initOnMounted) (0, _vueuse_shared.tryOnMounted)(() => {
  1945. firstMounted = true;
  1946. update();
  1947. });
  1948. else update();
  1949. function dispatchWriteEvent(oldValue, newValue) {
  1950. if (window) {
  1951. const payload = {
  1952. key: keyComputed.value,
  1953. oldValue,
  1954. newValue,
  1955. storageArea: storage
  1956. };
  1957. window.dispatchEvent(storage instanceof Storage ? new StorageEvent("storage", payload) : new CustomEvent(customStorageEventName, { detail: payload }));
  1958. }
  1959. }
  1960. function write(v) {
  1961. try {
  1962. const oldValue = storage.getItem(keyComputed.value);
  1963. if (v == null) {
  1964. dispatchWriteEvent(oldValue, null);
  1965. storage.removeItem(keyComputed.value);
  1966. } else {
  1967. const serialized = serializer.write(v);
  1968. if (oldValue !== serialized) {
  1969. storage.setItem(keyComputed.value, serialized);
  1970. dispatchWriteEvent(oldValue, serialized);
  1971. }
  1972. }
  1973. } catch (e) {
  1974. onError(e);
  1975. }
  1976. }
  1977. function read(event) {
  1978. const rawValue = event ? event.newValue : storage.getItem(keyComputed.value);
  1979. if (rawValue == null) {
  1980. if (writeDefaults && rawInit != null) storage.setItem(keyComputed.value, serializer.write(rawInit));
  1981. return rawInit;
  1982. } else if (!event && mergeDefaults) {
  1983. const value = serializer.read(rawValue);
  1984. if (typeof mergeDefaults === "function") return mergeDefaults(value, rawInit);
  1985. else if (type === "object" && !Array.isArray(value)) return {
  1986. ...rawInit,
  1987. ...value
  1988. };
  1989. return value;
  1990. } else if (typeof rawValue !== "string") return rawValue;
  1991. else return serializer.read(rawValue);
  1992. }
  1993. function update(event) {
  1994. if (event && event.storageArea !== storage) return;
  1995. if (event && event.key == null) {
  1996. data.value = rawInit;
  1997. return;
  1998. }
  1999. if (event && event.key !== keyComputed.value) return;
  2000. pauseWatch();
  2001. try {
  2002. const serializedData = serializer.write(data.value);
  2003. if (event === void 0 || (event === null || event === void 0 ? void 0 : event.newValue) !== serializedData) data.value = read(event);
  2004. } catch (e) {
  2005. onError(e);
  2006. } finally {
  2007. if (event) (0, vue.nextTick)(resumeWatch);
  2008. else resumeWatch();
  2009. }
  2010. }
  2011. function updateFromCustomEvent(event) {
  2012. update(event.detail);
  2013. }
  2014. return data;
  2015. }
  2016. //#endregion
  2017. //#region useColorMode/index.ts
  2018. const CSS_DISABLE_TRANS = "*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}";
  2019. /**
  2020. * Reactive color mode with auto data persistence.
  2021. *
  2022. * @see https://vueuse.org/useColorMode
  2023. * @param options
  2024. */
  2025. function useColorMode(options = {}) {
  2026. const { selector = "html", attribute = "class", initialValue = "auto", window = defaultWindow, storage, storageKey = "vueuse-color-scheme", listenToStorageChanges = true, storageRef, emitAuto, disableTransition = true } = options;
  2027. const modes = {
  2028. auto: "",
  2029. light: "light",
  2030. dark: "dark",
  2031. ...options.modes || {}
  2032. };
  2033. const preferredDark = usePreferredDark({ window });
  2034. const system = (0, vue.computed)(() => preferredDark.value ? "dark" : "light");
  2035. const store = storageRef || (storageKey == null ? (0, _vueuse_shared.toRef)(initialValue) : useStorage(storageKey, initialValue, storage, {
  2036. window,
  2037. listenToStorageChanges
  2038. }));
  2039. const state = (0, vue.computed)(() => store.value === "auto" ? system.value : store.value);
  2040. const updateHTMLAttrs = getSSRHandler("updateHTMLAttrs", (selector, attribute, value) => {
  2041. const el = typeof selector === "string" ? window === null || window === void 0 ? void 0 : window.document.querySelector(selector) : unrefElement(selector);
  2042. if (!el) return;
  2043. const classesToAdd = /* @__PURE__ */ new Set();
  2044. const classesToRemove = /* @__PURE__ */ new Set();
  2045. let attributeToChange = null;
  2046. if (attribute === "class") {
  2047. const current = value.split(/\s/g);
  2048. Object.values(modes).flatMap((i) => (i || "").split(/\s/g)).filter(Boolean).forEach((v) => {
  2049. if (current.includes(v)) classesToAdd.add(v);
  2050. else classesToRemove.add(v);
  2051. });
  2052. } else attributeToChange = {
  2053. key: attribute,
  2054. value
  2055. };
  2056. if (classesToAdd.size === 0 && classesToRemove.size === 0 && attributeToChange === null) return;
  2057. let style;
  2058. if (disableTransition) {
  2059. style = window.document.createElement("style");
  2060. style.appendChild(document.createTextNode(CSS_DISABLE_TRANS));
  2061. window.document.head.appendChild(style);
  2062. }
  2063. for (const c of classesToAdd) el.classList.add(c);
  2064. for (const c of classesToRemove) el.classList.remove(c);
  2065. if (attributeToChange) el.setAttribute(attributeToChange.key, attributeToChange.value);
  2066. if (disableTransition) {
  2067. window.getComputedStyle(style).opacity;
  2068. document.head.removeChild(style);
  2069. }
  2070. });
  2071. function defaultOnChanged(mode) {
  2072. var _modes$mode;
  2073. updateHTMLAttrs(selector, attribute, (_modes$mode = modes[mode]) !== null && _modes$mode !== void 0 ? _modes$mode : mode);
  2074. }
  2075. function onChanged(mode) {
  2076. if (options.onChanged) options.onChanged(mode, defaultOnChanged);
  2077. else defaultOnChanged(mode);
  2078. }
  2079. (0, vue.watch)(state, onChanged, {
  2080. flush: "post",
  2081. immediate: true
  2082. });
  2083. (0, _vueuse_shared.tryOnMounted)(() => onChanged(state.value));
  2084. const auto = (0, vue.computed)({
  2085. get() {
  2086. return emitAuto ? store.value : state.value;
  2087. },
  2088. set(v) {
  2089. store.value = v;
  2090. }
  2091. });
  2092. return Object.assign(auto, {
  2093. store,
  2094. system,
  2095. state
  2096. });
  2097. }
  2098. //#endregion
  2099. //#region useConfirmDialog/index.ts
  2100. /**
  2101. * Hooks for creating confirm dialogs. Useful for modal windows, popups and logins.
  2102. *
  2103. * @see https://vueuse.org/useConfirmDialog/
  2104. * @param revealed `boolean` `ref` that handles a modal window
  2105. *
  2106. * @__NO_SIDE_EFFECTS__
  2107. */
  2108. function useConfirmDialog(revealed = (0, vue.shallowRef)(false)) {
  2109. const confirmHook = (0, _vueuse_shared.createEventHook)();
  2110. const cancelHook = (0, _vueuse_shared.createEventHook)();
  2111. const revealHook = (0, _vueuse_shared.createEventHook)();
  2112. let _resolve = _vueuse_shared.noop;
  2113. const reveal = (data) => {
  2114. revealHook.trigger(data);
  2115. revealed.value = true;
  2116. return new Promise((resolve) => {
  2117. _resolve = resolve;
  2118. });
  2119. };
  2120. const confirm = (data) => {
  2121. revealed.value = false;
  2122. confirmHook.trigger(data);
  2123. _resolve({
  2124. data,
  2125. isCanceled: false
  2126. });
  2127. };
  2128. const cancel = (data) => {
  2129. revealed.value = false;
  2130. cancelHook.trigger(data);
  2131. _resolve({
  2132. data,
  2133. isCanceled: true
  2134. });
  2135. };
  2136. return {
  2137. isRevealed: (0, vue.computed)(() => revealed.value),
  2138. reveal,
  2139. confirm,
  2140. cancel,
  2141. onReveal: revealHook.on,
  2142. onConfirm: confirmHook.on,
  2143. onCancel: cancelHook.on
  2144. };
  2145. }
  2146. //#endregion
  2147. //#region useCountdown/index.ts
  2148. function getDefaultScheduler$8(options) {
  2149. if ("interval" in options || "immediate" in options) {
  2150. const { interval = 1e3, immediate = false } = options;
  2151. return (cb) => (0, _vueuse_shared.useIntervalFn)(cb, interval, { immediate });
  2152. }
  2153. return (cb) => (0, _vueuse_shared.useIntervalFn)(cb, 1e3, { immediate: false });
  2154. }
  2155. /**
  2156. * Reactive countdown timer in seconds.
  2157. *
  2158. * @param initialCountdown
  2159. * @param options
  2160. *
  2161. * @see https://vueuse.org/useCountdown
  2162. */
  2163. function useCountdown(initialCountdown, options = {}) {
  2164. const remaining = (0, vue.shallowRef)((0, vue.toValue)(initialCountdown));
  2165. const { scheduler = getDefaultScheduler$8(options), onTick, onComplete } = options;
  2166. const controls = scheduler(() => {
  2167. const value = remaining.value - 1;
  2168. remaining.value = value < 0 ? 0 : value;
  2169. onTick === null || onTick === void 0 || onTick();
  2170. if (remaining.value <= 0) {
  2171. controls.pause();
  2172. onComplete === null || onComplete === void 0 || onComplete();
  2173. }
  2174. });
  2175. const reset = (countdown) => {
  2176. var _toValue;
  2177. remaining.value = (_toValue = (0, vue.toValue)(countdown)) !== null && _toValue !== void 0 ? _toValue : (0, vue.toValue)(initialCountdown);
  2178. };
  2179. const stop = () => {
  2180. controls.pause();
  2181. reset();
  2182. };
  2183. const resume = () => {
  2184. if (!controls.isActive.value) {
  2185. if (remaining.value > 0) controls.resume();
  2186. }
  2187. };
  2188. const start = (countdown) => {
  2189. reset(countdown);
  2190. controls.resume();
  2191. };
  2192. return {
  2193. remaining,
  2194. reset,
  2195. stop,
  2196. start,
  2197. pause: controls.pause,
  2198. resume,
  2199. isActive: controls.isActive
  2200. };
  2201. }
  2202. //#endregion
  2203. //#region useCssSupports/index.ts
  2204. function useCssSupports(...args) {
  2205. let options = {};
  2206. if (typeof (0, vue.toValue)(args.at(-1)) === "object") options = args.pop();
  2207. const [prop, value] = args;
  2208. const { window = defaultWindow, ssrValue = false } = options;
  2209. const isMounted = useMounted();
  2210. return { isSupported: (0, vue.computed)(() => {
  2211. if (!_vueuse_shared.isClient || !isMounted.value) return ssrValue;
  2212. return args.length === 2 ? window === null || window === void 0 ? void 0 : window.CSS.supports((0, vue.toValue)(prop), (0, vue.toValue)(value)) : window === null || window === void 0 ? void 0 : window.CSS.supports((0, vue.toValue)(prop));
  2213. }) };
  2214. }
  2215. //#endregion
  2216. //#region useCssVar/index.ts
  2217. /**
  2218. * Manipulate CSS variables.
  2219. *
  2220. * @see https://vueuse.org/useCssVar
  2221. * @param prop
  2222. * @param target
  2223. * @param options
  2224. */
  2225. function useCssVar(prop, target, options = {}) {
  2226. const { window = defaultWindow, initialValue, observe = false } = options;
  2227. const variable = (0, vue.shallowRef)(initialValue);
  2228. const elRef = (0, vue.computed)(() => {
  2229. var _window$document;
  2230. return unrefElement(target) || (window === null || window === void 0 || (_window$document = window.document) === null || _window$document === void 0 ? void 0 : _window$document.documentElement);
  2231. });
  2232. function updateCssVar() {
  2233. const key = (0, vue.toValue)(prop);
  2234. const el = (0, vue.toValue)(elRef);
  2235. if (el && window && key) {
  2236. var _window$getComputedSt;
  2237. variable.value = ((_window$getComputedSt = window.getComputedStyle(el).getPropertyValue(key)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.trim()) || variable.value || initialValue;
  2238. }
  2239. }
  2240. if (observe) useMutationObserver(elRef, updateCssVar, {
  2241. attributeFilter: ["style", "class"],
  2242. window
  2243. });
  2244. (0, vue.watch)([elRef, () => (0, vue.toValue)(prop)], (_, old) => {
  2245. if (old[0] && old[1]) old[0].style.removeProperty(old[1]);
  2246. updateCssVar();
  2247. }, { immediate: true });
  2248. (0, vue.watch)([variable, elRef], ([val, el]) => {
  2249. const raw_prop = (0, vue.toValue)(prop);
  2250. if ((el === null || el === void 0 ? void 0 : el.style) && raw_prop) if (val == null) el.style.removeProperty(raw_prop);
  2251. else el.style.setProperty(raw_prop, val);
  2252. }, { immediate: true });
  2253. return variable;
  2254. }
  2255. //#endregion
  2256. //#region useCurrentElement/index.ts
  2257. function useCurrentElement(rootComponent) {
  2258. const vm = (0, vue.getCurrentInstance)();
  2259. const currentElement = (0, _vueuse_shared.computedWithControl)(() => null, () => rootComponent ? unrefElement(rootComponent) : vm.proxy.$el);
  2260. (0, vue.onUpdated)(currentElement.trigger);
  2261. (0, vue.onMounted)(currentElement.trigger);
  2262. return currentElement;
  2263. }
  2264. //#endregion
  2265. //#region useCycleList/index.ts
  2266. /**
  2267. * Cycle through a list of items
  2268. *
  2269. * @see https://vueuse.org/useCycleList
  2270. */
  2271. function useCycleList(list, options) {
  2272. const state = (0, vue.shallowRef)(getInitialValue());
  2273. const listRef = (0, _vueuse_shared.toRef)(list);
  2274. const index = (0, vue.computed)({
  2275. get() {
  2276. var _options$fallbackInde;
  2277. const targetList = listRef.value;
  2278. let index = (options === null || options === void 0 ? void 0 : options.getIndexOf) ? options.getIndexOf(state.value, targetList) : targetList.indexOf(state.value);
  2279. if (index < 0) index = (_options$fallbackInde = options === null || options === void 0 ? void 0 : options.fallbackIndex) !== null && _options$fallbackInde !== void 0 ? _options$fallbackInde : 0;
  2280. return index;
  2281. },
  2282. set(v) {
  2283. set(v);
  2284. }
  2285. });
  2286. function set(i) {
  2287. const targetList = listRef.value;
  2288. const length = targetList.length;
  2289. const value = targetList[(i % length + length) % length];
  2290. state.value = value;
  2291. return value;
  2292. }
  2293. function shift(delta = 1) {
  2294. return set(index.value + delta);
  2295. }
  2296. function next(n = 1) {
  2297. return shift(n);
  2298. }
  2299. function prev(n = 1) {
  2300. return shift(-n);
  2301. }
  2302. function getInitialValue() {
  2303. var _toValue, _options$initialValue;
  2304. return (_toValue = (0, vue.toValue)((_options$initialValue = options === null || options === void 0 ? void 0 : options.initialValue) !== null && _options$initialValue !== void 0 ? _options$initialValue : (0, vue.toValue)(list)[0])) !== null && _toValue !== void 0 ? _toValue : void 0;
  2305. }
  2306. (0, vue.watch)(listRef, () => set(index.value));
  2307. return {
  2308. state,
  2309. index,
  2310. next,
  2311. prev,
  2312. go: set
  2313. };
  2314. }
  2315. //#endregion
  2316. //#region useDark/index.ts
  2317. /**
  2318. * Reactive dark mode with auto data persistence.
  2319. *
  2320. * @see https://vueuse.org/useDark
  2321. * @param options
  2322. */
  2323. function useDark(options = {}) {
  2324. const { valueDark = "dark", valueLight = "" } = options;
  2325. const mode = useColorMode({
  2326. ...options,
  2327. onChanged: (mode, defaultHandler) => {
  2328. var _options$onChanged;
  2329. if (options.onChanged) (_options$onChanged = options.onChanged) === null || _options$onChanged === void 0 || _options$onChanged.call(options, mode === "dark", defaultHandler, mode);
  2330. else defaultHandler(mode);
  2331. },
  2332. modes: {
  2333. dark: valueDark,
  2334. light: valueLight
  2335. }
  2336. });
  2337. const system = (0, vue.computed)(() => mode.system.value);
  2338. return (0, vue.computed)({
  2339. get() {
  2340. return mode.value === "dark";
  2341. },
  2342. set(v) {
  2343. const modeVal = v ? "dark" : "light";
  2344. if (system.value === modeVal) mode.value = "auto";
  2345. else mode.value = modeVal;
  2346. }
  2347. });
  2348. }
  2349. //#endregion
  2350. //#region useManualRefHistory/index.ts
  2351. function fnBypass(v) {
  2352. return v;
  2353. }
  2354. function fnSetSource(source, value) {
  2355. return source.value = value;
  2356. }
  2357. function defaultDump(clone) {
  2358. return clone ? typeof clone === "function" ? clone : cloneFnJSON : fnBypass;
  2359. }
  2360. function defaultParse(clone) {
  2361. return clone ? typeof clone === "function" ? clone : cloneFnJSON : fnBypass;
  2362. }
  2363. /**
  2364. * Track the change history of a ref, also provides undo and redo functionality.
  2365. *
  2366. * @see https://vueuse.org/useManualRefHistory
  2367. * @param source
  2368. * @param options
  2369. */
  2370. function useManualRefHistory(source, options = {}) {
  2371. const { clone = false, dump = defaultDump(clone), parse = defaultParse(clone), setSource = fnSetSource } = options;
  2372. function _createHistoryRecord() {
  2373. return (0, vue.markRaw)({
  2374. snapshot: dump(source.value),
  2375. timestamp: (0, _vueuse_shared.timestamp)()
  2376. });
  2377. }
  2378. const last = (0, vue.ref)(_createHistoryRecord());
  2379. const undoStack = (0, vue.ref)([]);
  2380. const redoStack = (0, vue.ref)([]);
  2381. const _setSource = (record) => {
  2382. setSource(source, parse(record.snapshot));
  2383. last.value = record;
  2384. };
  2385. const commit = () => {
  2386. undoStack.value.unshift(last.value);
  2387. last.value = _createHistoryRecord();
  2388. if (options.capacity && undoStack.value.length > options.capacity) undoStack.value.splice(options.capacity, Number.POSITIVE_INFINITY);
  2389. if (redoStack.value.length) redoStack.value.splice(0, redoStack.value.length);
  2390. };
  2391. const clear = () => {
  2392. undoStack.value.splice(0, undoStack.value.length);
  2393. redoStack.value.splice(0, redoStack.value.length);
  2394. };
  2395. const undo = () => {
  2396. const state = undoStack.value.shift();
  2397. if (state) {
  2398. redoStack.value.unshift(last.value);
  2399. _setSource(state);
  2400. }
  2401. };
  2402. const redo = () => {
  2403. const state = redoStack.value.shift();
  2404. if (state) {
  2405. undoStack.value.unshift(last.value);
  2406. _setSource(state);
  2407. }
  2408. };
  2409. const reset = () => {
  2410. _setSource(last.value);
  2411. };
  2412. return {
  2413. source,
  2414. undoStack,
  2415. redoStack,
  2416. last,
  2417. history: (0, vue.computed)(() => [last.value, ...undoStack.value]),
  2418. canUndo: (0, vue.computed)(() => undoStack.value.length > 0),
  2419. canRedo: (0, vue.computed)(() => redoStack.value.length > 0),
  2420. clear,
  2421. commit,
  2422. reset,
  2423. undo,
  2424. redo
  2425. };
  2426. }
  2427. //#endregion
  2428. //#region useRefHistory/index.ts
  2429. /**
  2430. * Track the change history of a ref, also provides undo and redo functionality.
  2431. *
  2432. * @see https://vueuse.org/useRefHistory
  2433. * @param source
  2434. * @param options
  2435. */
  2436. function useRefHistory(source, options = {}) {
  2437. const { deep = false, flush = "pre", eventFilter, shouldCommit = () => true } = options;
  2438. const { eventFilter: composedFilter, pause, resume: resumeTracking, isActive: isTracking } = (0, _vueuse_shared.pausableFilter)(eventFilter);
  2439. let lastRawValue = source.value;
  2440. const { ignoreUpdates, ignorePrevAsyncUpdates, stop } = (0, _vueuse_shared.watchIgnorable)(source, commit, {
  2441. deep,
  2442. flush,
  2443. eventFilter: composedFilter
  2444. });
  2445. function setSource(source, value) {
  2446. ignorePrevAsyncUpdates();
  2447. ignoreUpdates(() => {
  2448. source.value = value;
  2449. lastRawValue = value;
  2450. });
  2451. }
  2452. const manualHistory = useManualRefHistory(source, {
  2453. ...options,
  2454. clone: options.clone || deep,
  2455. setSource
  2456. });
  2457. const { clear, commit: manualCommit } = manualHistory;
  2458. function commit() {
  2459. ignorePrevAsyncUpdates();
  2460. if (!shouldCommit(lastRawValue, source.value)) return;
  2461. lastRawValue = source.value;
  2462. manualCommit();
  2463. }
  2464. function resume(commitNow) {
  2465. resumeTracking();
  2466. if (commitNow) commit();
  2467. }
  2468. function batch(fn) {
  2469. let canceled = false;
  2470. const cancel = () => canceled = true;
  2471. ignoreUpdates(() => {
  2472. fn(cancel);
  2473. });
  2474. if (!canceled) commit();
  2475. }
  2476. function dispose() {
  2477. stop();
  2478. clear();
  2479. }
  2480. return {
  2481. ...manualHistory,
  2482. isTracking,
  2483. pause,
  2484. resume,
  2485. commit,
  2486. batch,
  2487. dispose
  2488. };
  2489. }
  2490. //#endregion
  2491. //#region useDebouncedRefHistory/index.ts
  2492. /**
  2493. * Shorthand for [useRefHistory](https://vueuse.org/useRefHistory) with debounce filter.
  2494. *
  2495. * @see https://vueuse.org/useDebouncedRefHistory
  2496. * @param source
  2497. * @param options
  2498. */
  2499. function useDebouncedRefHistory(source, options = {}) {
  2500. const filter = options.debounce ? (0, _vueuse_shared.debounceFilter)(options.debounce) : void 0;
  2501. return { ...useRefHistory(source, {
  2502. ...options,
  2503. eventFilter: filter
  2504. }) };
  2505. }
  2506. //#endregion
  2507. //#region useDeviceMotion/index.ts
  2508. /**
  2509. * Reactive DeviceMotionEvent.
  2510. *
  2511. * @see https://vueuse.org/useDeviceMotion
  2512. * @param options
  2513. */
  2514. function useDeviceMotion(options = {}) {
  2515. const { window = defaultWindow, requestPermissions = false, eventFilter = _vueuse_shared.bypassFilter } = options;
  2516. const isSupported = /* @__PURE__ */ useSupported(() => typeof DeviceMotionEvent !== "undefined");
  2517. const requirePermissions = /* @__PURE__ */ useSupported(() => isSupported.value && "requestPermission" in DeviceMotionEvent && typeof DeviceMotionEvent.requestPermission === "function");
  2518. const permissionGranted = (0, vue.shallowRef)(false);
  2519. const acceleration = (0, vue.ref)({
  2520. x: null,
  2521. y: null,
  2522. z: null
  2523. });
  2524. const rotationRate = (0, vue.ref)({
  2525. alpha: null,
  2526. beta: null,
  2527. gamma: null
  2528. });
  2529. const interval = (0, vue.shallowRef)(0);
  2530. const accelerationIncludingGravity = (0, vue.ref)({
  2531. x: null,
  2532. y: null,
  2533. z: null
  2534. });
  2535. function init() {
  2536. if (window) useEventListener(window, "devicemotion", (0, _vueuse_shared.createFilterWrapper)(eventFilter, (event) => {
  2537. var _event$acceleration, _event$acceleration2, _event$acceleration3, _event$accelerationIn, _event$accelerationIn2, _event$accelerationIn3, _event$rotationRate, _event$rotationRate2, _event$rotationRate3;
  2538. acceleration.value = {
  2539. x: ((_event$acceleration = event.acceleration) === null || _event$acceleration === void 0 ? void 0 : _event$acceleration.x) || null,
  2540. y: ((_event$acceleration2 = event.acceleration) === null || _event$acceleration2 === void 0 ? void 0 : _event$acceleration2.y) || null,
  2541. z: ((_event$acceleration3 = event.acceleration) === null || _event$acceleration3 === void 0 ? void 0 : _event$acceleration3.z) || null
  2542. };
  2543. accelerationIncludingGravity.value = {
  2544. x: ((_event$accelerationIn = event.accelerationIncludingGravity) === null || _event$accelerationIn === void 0 ? void 0 : _event$accelerationIn.x) || null,
  2545. y: ((_event$accelerationIn2 = event.accelerationIncludingGravity) === null || _event$accelerationIn2 === void 0 ? void 0 : _event$accelerationIn2.y) || null,
  2546. z: ((_event$accelerationIn3 = event.accelerationIncludingGravity) === null || _event$accelerationIn3 === void 0 ? void 0 : _event$accelerationIn3.z) || null
  2547. };
  2548. rotationRate.value = {
  2549. alpha: ((_event$rotationRate = event.rotationRate) === null || _event$rotationRate === void 0 ? void 0 : _event$rotationRate.alpha) || null,
  2550. beta: ((_event$rotationRate2 = event.rotationRate) === null || _event$rotationRate2 === void 0 ? void 0 : _event$rotationRate2.beta) || null,
  2551. gamma: ((_event$rotationRate3 = event.rotationRate) === null || _event$rotationRate3 === void 0 ? void 0 : _event$rotationRate3.gamma) || null
  2552. };
  2553. interval.value = event.interval;
  2554. }), { passive: true });
  2555. }
  2556. const ensurePermissions = async () => {
  2557. if (!requirePermissions.value) permissionGranted.value = true;
  2558. if (permissionGranted.value) return;
  2559. if (requirePermissions.value) {
  2560. const requestPermission = DeviceMotionEvent.requestPermission;
  2561. try {
  2562. if (await requestPermission() === "granted") {
  2563. permissionGranted.value = true;
  2564. init();
  2565. }
  2566. } catch (error) {
  2567. console.error(error);
  2568. }
  2569. }
  2570. };
  2571. if (isSupported.value) if (requestPermissions && requirePermissions.value) ensurePermissions().then(() => init());
  2572. else init();
  2573. return {
  2574. acceleration,
  2575. accelerationIncludingGravity,
  2576. rotationRate,
  2577. interval,
  2578. isSupported,
  2579. requirePermissions,
  2580. ensurePermissions,
  2581. permissionGranted
  2582. };
  2583. }
  2584. //#endregion
  2585. //#region useDeviceOrientation/index.ts
  2586. /**
  2587. * Reactive DeviceOrientationEvent.
  2588. *
  2589. * @see https://vueuse.org/useDeviceOrientation
  2590. * @param options
  2591. *
  2592. * @__NO_SIDE_EFFECTS__
  2593. */
  2594. function useDeviceOrientation(options = {}) {
  2595. const { window = defaultWindow } = options;
  2596. const isSupported = /* @__PURE__ */ useSupported(() => window && "DeviceOrientationEvent" in window);
  2597. const isAbsolute = (0, vue.shallowRef)(false);
  2598. const alpha = (0, vue.shallowRef)(null);
  2599. const beta = (0, vue.shallowRef)(null);
  2600. const gamma = (0, vue.shallowRef)(null);
  2601. if (window && isSupported.value) useEventListener(window, "deviceorientation", (event) => {
  2602. isAbsolute.value = event.absolute;
  2603. alpha.value = event.alpha;
  2604. beta.value = event.beta;
  2605. gamma.value = event.gamma;
  2606. }, { passive: true });
  2607. return {
  2608. isSupported,
  2609. isAbsolute,
  2610. alpha,
  2611. beta,
  2612. gamma
  2613. };
  2614. }
  2615. //#endregion
  2616. //#region useDevicePixelRatio/index.ts
  2617. /**
  2618. * Reactively track `window.devicePixelRatio`.
  2619. *
  2620. * @see https://vueuse.org/useDevicePixelRatio
  2621. *
  2622. * @__NO_SIDE_EFFECTS__
  2623. */
  2624. function useDevicePixelRatio(options = {}) {
  2625. const { window = defaultWindow } = options;
  2626. const pixelRatio = (0, vue.shallowRef)(1);
  2627. const query = useMediaQuery(() => `(resolution: ${pixelRatio.value}dppx)`, options);
  2628. let stop = _vueuse_shared.noop;
  2629. if (window) stop = (0, _vueuse_shared.watchImmediate)(query, () => pixelRatio.value = window.devicePixelRatio);
  2630. return {
  2631. pixelRatio: (0, vue.shallowReadonly)(pixelRatio),
  2632. stop
  2633. };
  2634. }
  2635. //#endregion
  2636. //#region useDevicesList/index.ts
  2637. /**
  2638. * Reactive `enumerateDevices` listing available input/output devices
  2639. *
  2640. * @see https://vueuse.org/useDevicesList
  2641. * @param options
  2642. */
  2643. function useDevicesList(options = {}) {
  2644. const { navigator = defaultNavigator, requestPermissions = false, constraints = {
  2645. audio: true,
  2646. video: true
  2647. }, onUpdated } = options;
  2648. const devices = (0, vue.shallowRef)([]);
  2649. const videoInputs = (0, vue.computed)(() => devices.value.filter((i) => i.kind === "videoinput"));
  2650. const audioInputs = (0, vue.computed)(() => devices.value.filter((i) => i.kind === "audioinput"));
  2651. const audioOutputs = (0, vue.computed)(() => devices.value.filter((i) => i.kind === "audiooutput"));
  2652. const isSupported = /* @__PURE__ */ useSupported(() => navigator && navigator.mediaDevices && navigator.mediaDevices.enumerateDevices);
  2653. const permissionGranted = (0, vue.shallowRef)(false);
  2654. let stream;
  2655. async function update() {
  2656. if (!isSupported.value) return;
  2657. devices.value = await navigator.mediaDevices.enumerateDevices();
  2658. onUpdated === null || onUpdated === void 0 || onUpdated(devices.value);
  2659. if (stream) {
  2660. stream.getTracks().forEach((t) => t.stop());
  2661. stream = null;
  2662. }
  2663. }
  2664. async function ensurePermissions() {
  2665. const deviceName = constraints.video ? "camera" : "microphone";
  2666. if (!isSupported.value) return false;
  2667. if (permissionGranted.value) return true;
  2668. const { state, query } = usePermission(deviceName, { controls: true });
  2669. await query();
  2670. if (state.value !== "granted") {
  2671. let granted = true;
  2672. try {
  2673. const allDevices = await navigator.mediaDevices.enumerateDevices();
  2674. const hasCamera = allDevices.some((device) => device.kind === "videoinput");
  2675. const hasMicrophone = allDevices.some((device) => device.kind === "audioinput" || device.kind === "audiooutput");
  2676. constraints.video = hasCamera ? constraints.video : false;
  2677. constraints.audio = hasMicrophone ? constraints.audio : false;
  2678. stream = await navigator.mediaDevices.getUserMedia(constraints);
  2679. } catch (_unused) {
  2680. stream = null;
  2681. granted = false;
  2682. }
  2683. update();
  2684. permissionGranted.value = granted;
  2685. } else permissionGranted.value = true;
  2686. return permissionGranted.value;
  2687. }
  2688. if (isSupported.value) {
  2689. if (requestPermissions) ensurePermissions();
  2690. useEventListener(navigator.mediaDevices, "devicechange", update, { passive: true });
  2691. update();
  2692. }
  2693. return {
  2694. devices,
  2695. ensurePermissions,
  2696. permissionGranted,
  2697. videoInputs,
  2698. audioInputs,
  2699. audioOutputs,
  2700. isSupported
  2701. };
  2702. }
  2703. //#endregion
  2704. //#region useDisplayMedia/index.ts
  2705. /**
  2706. * Reactive `mediaDevices.getDisplayMedia` streaming
  2707. *
  2708. * @see https://vueuse.org/useDisplayMedia
  2709. * @param options
  2710. */
  2711. function useDisplayMedia(options = {}) {
  2712. var _options$enabled;
  2713. const enabled = (0, vue.shallowRef)((_options$enabled = options.enabled) !== null && _options$enabled !== void 0 ? _options$enabled : false);
  2714. const video = options.video;
  2715. const audio = options.audio;
  2716. const { navigator = defaultNavigator } = options;
  2717. const isSupported = /* @__PURE__ */ useSupported(() => {
  2718. var _navigator$mediaDevic;
  2719. return navigator === null || navigator === void 0 || (_navigator$mediaDevic = navigator.mediaDevices) === null || _navigator$mediaDevic === void 0 ? void 0 : _navigator$mediaDevic.getDisplayMedia;
  2720. });
  2721. const constraint = {
  2722. audio,
  2723. video
  2724. };
  2725. const stream = (0, vue.shallowRef)();
  2726. async function _start() {
  2727. var _stream$value;
  2728. if (!isSupported.value || stream.value) return;
  2729. stream.value = await navigator.mediaDevices.getDisplayMedia(constraint);
  2730. (_stream$value = stream.value) === null || _stream$value === void 0 || _stream$value.getTracks().forEach((t) => useEventListener(t, "ended", stop, { passive: true }));
  2731. return stream.value;
  2732. }
  2733. async function _stop() {
  2734. var _stream$value2;
  2735. (_stream$value2 = stream.value) === null || _stream$value2 === void 0 || _stream$value2.getTracks().forEach((t) => t.stop());
  2736. stream.value = void 0;
  2737. }
  2738. function stop() {
  2739. _stop();
  2740. enabled.value = false;
  2741. }
  2742. async function start() {
  2743. await _start();
  2744. if (stream.value) enabled.value = true;
  2745. return stream.value;
  2746. }
  2747. (0, vue.watch)(enabled, (v) => {
  2748. if (v) _start();
  2749. else _stop();
  2750. }, { immediate: true });
  2751. return {
  2752. isSupported,
  2753. stream,
  2754. start,
  2755. stop,
  2756. enabled
  2757. };
  2758. }
  2759. //#endregion
  2760. //#region useDocumentVisibility/index.ts
  2761. /**
  2762. * Reactively track `document.visibilityState`.
  2763. *
  2764. * @see https://vueuse.org/useDocumentVisibility
  2765. *
  2766. * @__NO_SIDE_EFFECTS__
  2767. */
  2768. function useDocumentVisibility(options = {}) {
  2769. const { document = defaultDocument } = options;
  2770. if (!document) return (0, vue.shallowRef)("visible");
  2771. const visibility = (0, vue.shallowRef)(document.visibilityState);
  2772. useEventListener(document, "visibilitychange", () => {
  2773. visibility.value = document.visibilityState;
  2774. }, { passive: true });
  2775. return visibility;
  2776. }
  2777. //#endregion
  2778. //#region useDraggable/index.ts
  2779. const defaultScrollConfig = {
  2780. speed: 2,
  2781. margin: 30,
  2782. direction: "both"
  2783. };
  2784. function clampContainerScroll(container) {
  2785. if (container.scrollLeft > container.scrollWidth - container.clientWidth) container.scrollLeft = Math.max(0, container.scrollWidth - container.clientWidth);
  2786. if (container.scrollTop > container.scrollHeight - container.clientHeight) container.scrollTop = Math.max(0, container.scrollHeight - container.clientHeight);
  2787. }
  2788. /**
  2789. * Make elements draggable.
  2790. *
  2791. * @see https://vueuse.org/useDraggable
  2792. * @param target
  2793. * @param options
  2794. */
  2795. function useDraggable(target, options = {}) {
  2796. var _toValue, _toValue2, _toValue3, _scrollConfig$directi;
  2797. const { pointerTypes, preventDefault, stopPropagation, exact, onMove, onEnd, onStart, initialValue, axis = "both", draggingElement = defaultWindow, containerElement, handle: draggingHandle = target, buttons = [0], restrictInView, autoScroll = false } = options;
  2798. const position = (0, vue.ref)((_toValue = (0, vue.toValue)(initialValue)) !== null && _toValue !== void 0 ? _toValue : {
  2799. x: 0,
  2800. y: 0
  2801. });
  2802. const pressedDelta = (0, vue.ref)();
  2803. const filterEvent = (e) => {
  2804. if (pointerTypes) return pointerTypes.includes(e.pointerType);
  2805. return true;
  2806. };
  2807. const handleEvent = (e) => {
  2808. if ((0, vue.toValue)(preventDefault)) e.preventDefault();
  2809. if ((0, vue.toValue)(stopPropagation)) e.stopPropagation();
  2810. };
  2811. const scrollConfig = (0, vue.toValue)(autoScroll);
  2812. const scrollSettings = typeof scrollConfig === "object" ? {
  2813. speed: (_toValue2 = (0, vue.toValue)(scrollConfig.speed)) !== null && _toValue2 !== void 0 ? _toValue2 : defaultScrollConfig.speed,
  2814. margin: (_toValue3 = (0, vue.toValue)(scrollConfig.margin)) !== null && _toValue3 !== void 0 ? _toValue3 : defaultScrollConfig.margin,
  2815. direction: (_scrollConfig$directi = scrollConfig.direction) !== null && _scrollConfig$directi !== void 0 ? _scrollConfig$directi : defaultScrollConfig.direction
  2816. } : defaultScrollConfig;
  2817. const getScrollAxisValues = (value) => typeof value === "number" ? [value, value] : [value.x, value.y];
  2818. const handleAutoScroll = (container, targetRect, position) => {
  2819. const { clientWidth, clientHeight, scrollLeft, scrollTop, scrollWidth, scrollHeight } = container;
  2820. const [marginX, marginY] = getScrollAxisValues(scrollSettings.margin);
  2821. const [speedX, speedY] = getScrollAxisValues(scrollSettings.speed);
  2822. let deltaX = 0;
  2823. let deltaY = 0;
  2824. if (scrollSettings.direction === "x" || scrollSettings.direction === "both") {
  2825. if (position.x < marginX && scrollLeft > 0) deltaX = -speedX;
  2826. else if (position.x + targetRect.width > clientWidth - marginX && scrollLeft < scrollWidth - clientWidth) deltaX = speedX;
  2827. }
  2828. if (scrollSettings.direction === "y" || scrollSettings.direction === "both") {
  2829. if (position.y < marginY && scrollTop > 0) deltaY = -speedY;
  2830. else if (position.y + targetRect.height > clientHeight - marginY && scrollTop < scrollHeight - clientHeight) deltaY = speedY;
  2831. }
  2832. if (deltaX || deltaY) container.scrollBy({
  2833. left: deltaX,
  2834. top: deltaY,
  2835. behavior: "auto"
  2836. });
  2837. };
  2838. let autoScrollInterval = null;
  2839. const startAutoScroll = () => {
  2840. const container = (0, vue.toValue)(containerElement);
  2841. if (container && !autoScrollInterval) autoScrollInterval = setInterval(() => {
  2842. const targetRect = (0, vue.toValue)(target).getBoundingClientRect();
  2843. const { x, y } = position.value;
  2844. const relativePosition = {
  2845. x: x - container.scrollLeft,
  2846. y: y - container.scrollTop
  2847. };
  2848. if (relativePosition.x >= 0 && relativePosition.y >= 0) {
  2849. handleAutoScroll(container, targetRect, relativePosition);
  2850. relativePosition.x += container.scrollLeft;
  2851. relativePosition.y += container.scrollTop;
  2852. position.value = relativePosition;
  2853. }
  2854. }, 1e3 / 60);
  2855. };
  2856. const stopAutoScroll = () => {
  2857. if (autoScrollInterval) {
  2858. clearInterval(autoScrollInterval);
  2859. autoScrollInterval = null;
  2860. }
  2861. };
  2862. const isPointerNearEdge = (pointer, container, margin, targetRect) => {
  2863. const [marginX, marginY] = typeof margin === "number" ? [margin, margin] : [margin.x, margin.y];
  2864. const { clientWidth, clientHeight } = container;
  2865. return pointer.x < marginX || pointer.x + targetRect.width > clientWidth - marginX || pointer.y < marginY || pointer.y + targetRect.height > clientHeight - marginY;
  2866. };
  2867. const checkAutoScroll = () => {
  2868. if ((0, vue.toValue)(options.disabled) || !pressedDelta.value) return;
  2869. const container = (0, vue.toValue)(containerElement);
  2870. if (!container) return;
  2871. const targetRect = (0, vue.toValue)(target).getBoundingClientRect();
  2872. const { x, y } = position.value;
  2873. if (isPointerNearEdge({
  2874. x: x - container.scrollLeft,
  2875. y: y - container.scrollTop
  2876. }, container, scrollSettings.margin, targetRect)) startAutoScroll();
  2877. else stopAutoScroll();
  2878. };
  2879. if ((0, vue.toValue)(autoScroll)) (0, vue.watch)(position, checkAutoScroll);
  2880. const start = (e) => {
  2881. var _container$getBoundin;
  2882. if (!(0, vue.toValue)(buttons).includes(e.button)) return;
  2883. if ((0, vue.toValue)(options.disabled) || !filterEvent(e)) return;
  2884. if ((0, vue.toValue)(exact) && e.target !== (0, vue.toValue)(target)) return;
  2885. const container = (0, vue.toValue)(containerElement);
  2886. const containerRect = container === null || container === void 0 || (_container$getBoundin = container.getBoundingClientRect) === null || _container$getBoundin === void 0 ? void 0 : _container$getBoundin.call(container);
  2887. const targetRect = (0, vue.toValue)(target).getBoundingClientRect();
  2888. const pos = {
  2889. x: e.clientX - (container ? targetRect.left - containerRect.left + (autoScroll ? 0 : container.scrollLeft) : targetRect.left),
  2890. y: e.clientY - (container ? targetRect.top - containerRect.top + (autoScroll ? 0 : container.scrollTop) : targetRect.top)
  2891. };
  2892. if ((onStart === null || onStart === void 0 ? void 0 : onStart(pos, e)) === false) return;
  2893. pressedDelta.value = pos;
  2894. handleEvent(e);
  2895. };
  2896. const move = (e) => {
  2897. if ((0, vue.toValue)(options.disabled) || !filterEvent(e)) return;
  2898. if (!pressedDelta.value) return;
  2899. const container = (0, vue.toValue)(containerElement);
  2900. if (container instanceof HTMLElement) clampContainerScroll(container);
  2901. const targetRect = (0, vue.toValue)(target).getBoundingClientRect();
  2902. let { x, y } = position.value;
  2903. if (axis === "x" || axis === "both") {
  2904. x = e.clientX - pressedDelta.value.x;
  2905. if (container) x = Math.min(Math.max(0, x), container.scrollWidth - targetRect.width);
  2906. }
  2907. if (axis === "y" || axis === "both") {
  2908. y = e.clientY - pressedDelta.value.y;
  2909. if (container) y = Math.min(Math.max(0, y), container.scrollHeight - targetRect.height);
  2910. }
  2911. if ((0, vue.toValue)(autoScroll) && container) {
  2912. if (autoScrollInterval === null) handleAutoScroll(container, targetRect, {
  2913. x,
  2914. y
  2915. });
  2916. x += container.scrollLeft;
  2917. y += container.scrollTop;
  2918. }
  2919. if (container && (restrictInView || autoScroll)) {
  2920. if (axis !== "y") {
  2921. const relativeX = x - container.scrollLeft;
  2922. if (relativeX < 0) x = container.scrollLeft;
  2923. else if (relativeX > container.clientWidth - targetRect.width) x = container.clientWidth - targetRect.width + container.scrollLeft;
  2924. }
  2925. if (axis !== "x") {
  2926. const relativeY = y - container.scrollTop;
  2927. if (relativeY < 0) y = container.scrollTop;
  2928. else if (relativeY > container.clientHeight - targetRect.height) y = container.clientHeight - targetRect.height + container.scrollTop;
  2929. }
  2930. }
  2931. position.value = {
  2932. x,
  2933. y
  2934. };
  2935. onMove === null || onMove === void 0 || onMove(position.value, e);
  2936. handleEvent(e);
  2937. };
  2938. const end = (e) => {
  2939. if ((0, vue.toValue)(options.disabled) || !filterEvent(e)) return;
  2940. if (!pressedDelta.value) return;
  2941. pressedDelta.value = void 0;
  2942. if (autoScroll) stopAutoScroll();
  2943. onEnd === null || onEnd === void 0 || onEnd(position.value, e);
  2944. handleEvent(e);
  2945. };
  2946. if (_vueuse_shared.isClient) {
  2947. const config = () => {
  2948. var _options$capture;
  2949. return {
  2950. capture: (_options$capture = options.capture) !== null && _options$capture !== void 0 ? _options$capture : true,
  2951. passive: !(0, vue.toValue)(preventDefault)
  2952. };
  2953. };
  2954. useEventListener(draggingHandle, "pointerdown", start, config);
  2955. useEventListener(draggingElement, "pointermove", move, config);
  2956. useEventListener(draggingElement, "pointerup", end, config);
  2957. }
  2958. return {
  2959. ...(0, _vueuse_shared.toRefs)(position),
  2960. position,
  2961. isDragging: (0, vue.computed)(() => !!pressedDelta.value),
  2962. style: (0, vue.computed)(() => `
  2963. left: ${position.value.x}px;
  2964. top: ${position.value.y}px;
  2965. ${autoScroll ? "text-wrap: nowrap;" : ""}
  2966. `)
  2967. };
  2968. }
  2969. //#endregion
  2970. //#region useDropZone/index.ts
  2971. function useDropZone(target, options = {}) {
  2972. const isOverDropZone = (0, vue.shallowRef)(false);
  2973. const files = (0, vue.shallowRef)(null);
  2974. let counter = 0;
  2975. let isValid = true;
  2976. if (_vueuse_shared.isClient) {
  2977. var _options$multiple, _options$preventDefau;
  2978. const _options = typeof options === "function" ? { onDrop: options } : options;
  2979. const multiple = (_options$multiple = _options.multiple) !== null && _options$multiple !== void 0 ? _options$multiple : true;
  2980. const preventDefaultForUnhandled = (_options$preventDefau = _options.preventDefaultForUnhandled) !== null && _options$preventDefau !== void 0 ? _options$preventDefau : false;
  2981. const getFiles = (event) => {
  2982. var _event$dataTransfer$f, _event$dataTransfer;
  2983. const list = Array.from((_event$dataTransfer$f = (_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 ? void 0 : _event$dataTransfer.files) !== null && _event$dataTransfer$f !== void 0 ? _event$dataTransfer$f : []);
  2984. return list.length === 0 ? null : multiple ? list : [list[0]];
  2985. };
  2986. const checkDataTypes = (types) => {
  2987. const dataTypes = (0, vue.unref)(_options.dataTypes);
  2988. if (typeof dataTypes === "function") return dataTypes(types);
  2989. if (!(dataTypes === null || dataTypes === void 0 ? void 0 : dataTypes.length)) return true;
  2990. if (types.length === 0) return false;
  2991. return types.every((type) => dataTypes.some((allowedType) => type.includes(allowedType)));
  2992. };
  2993. const checkValidity = (items) => {
  2994. if (_options.checkValidity) return _options.checkValidity(items);
  2995. const dataTypesValid = checkDataTypes(Array.from(items !== null && items !== void 0 ? items : []).map((item) => item.type));
  2996. const multipleFilesValid = multiple || items.length <= 1;
  2997. return dataTypesValid && multipleFilesValid;
  2998. };
  2999. const isSafari = () => /^(?:(?!chrome|android).)*safari/i.test(navigator.userAgent) && !("chrome" in window);
  3000. const handleDragEvent = (event, eventType) => {
  3001. var _event$dataTransfer2, _ref;
  3002. const dataTransferItemList = (_event$dataTransfer2 = event.dataTransfer) === null || _event$dataTransfer2 === void 0 ? void 0 : _event$dataTransfer2.items;
  3003. isValid = (_ref = dataTransferItemList && checkValidity(dataTransferItemList)) !== null && _ref !== void 0 ? _ref : false;
  3004. if (preventDefaultForUnhandled) event.preventDefault();
  3005. if (!isSafari() && !isValid) {
  3006. if (event.dataTransfer) event.dataTransfer.dropEffect = "none";
  3007. return;
  3008. }
  3009. event.preventDefault();
  3010. if (event.dataTransfer) event.dataTransfer.dropEffect = "copy";
  3011. const currentFiles = getFiles(event);
  3012. switch (eventType) {
  3013. case "enter":
  3014. var _options$onEnter;
  3015. counter += 1;
  3016. isOverDropZone.value = true;
  3017. (_options$onEnter = _options.onEnter) === null || _options$onEnter === void 0 || _options$onEnter.call(_options, null, event);
  3018. break;
  3019. case "over":
  3020. var _options$onOver;
  3021. (_options$onOver = _options.onOver) === null || _options$onOver === void 0 || _options$onOver.call(_options, null, event);
  3022. break;
  3023. case "leave":
  3024. var _options$onLeave;
  3025. counter -= 1;
  3026. if (counter === 0) isOverDropZone.value = false;
  3027. (_options$onLeave = _options.onLeave) === null || _options$onLeave === void 0 || _options$onLeave.call(_options, null, event);
  3028. break;
  3029. case "drop":
  3030. counter = 0;
  3031. isOverDropZone.value = false;
  3032. if (isValid) {
  3033. var _options$onDrop;
  3034. files.value = currentFiles;
  3035. (_options$onDrop = _options.onDrop) === null || _options$onDrop === void 0 || _options$onDrop.call(_options, currentFiles, event);
  3036. }
  3037. break;
  3038. }
  3039. };
  3040. useEventListener(target, "dragenter", (event) => handleDragEvent(event, "enter"));
  3041. useEventListener(target, "dragover", (event) => handleDragEvent(event, "over"));
  3042. useEventListener(target, "dragleave", (event) => handleDragEvent(event, "leave"));
  3043. useEventListener(target, "drop", (event) => handleDragEvent(event, "drop"));
  3044. }
  3045. return {
  3046. files,
  3047. isOverDropZone
  3048. };
  3049. }
  3050. //#endregion
  3051. //#region useResizeObserver/index.ts
  3052. /**
  3053. * Reports changes to the dimensions of an Element's content or the border-box
  3054. *
  3055. * @see https://vueuse.org/useResizeObserver
  3056. * @param target
  3057. * @param callback
  3058. * @param options
  3059. */
  3060. function useResizeObserver(target, callback, options = {}) {
  3061. const { window = defaultWindow, ...observerOptions } = options;
  3062. let observer;
  3063. const isSupported = /* @__PURE__ */ useSupported(() => window && "ResizeObserver" in window);
  3064. const cleanup = () => {
  3065. if (observer) {
  3066. observer.disconnect();
  3067. observer = void 0;
  3068. }
  3069. };
  3070. const stopWatch = (0, vue.watch)((0, vue.computed)(() => {
  3071. const _targets = (0, vue.toValue)(target);
  3072. return Array.isArray(_targets) ? _targets.map((el) => unrefElement(el)) : [unrefElement(_targets)];
  3073. }), (els) => {
  3074. cleanup();
  3075. if (isSupported.value && window) {
  3076. observer = new ResizeObserver(callback);
  3077. for (const _el of els) if (_el) observer.observe(_el, observerOptions);
  3078. }
  3079. }, {
  3080. immediate: true,
  3081. flush: "post"
  3082. });
  3083. const stop = () => {
  3084. cleanup();
  3085. stopWatch();
  3086. };
  3087. (0, _vueuse_shared.tryOnScopeDispose)(stop);
  3088. return {
  3089. isSupported,
  3090. stop
  3091. };
  3092. }
  3093. //#endregion
  3094. //#region useElementBounding/index.ts
  3095. /**
  3096. * Reactive bounding box of an HTML element.
  3097. *
  3098. * @see https://vueuse.org/useElementBounding
  3099. * @param target
  3100. */
  3101. function useElementBounding(target, options = {}) {
  3102. const { reset = true, windowResize = true, windowScroll = true, immediate = true, updateTiming = "sync" } = options;
  3103. const height = (0, vue.shallowRef)(0);
  3104. const bottom = (0, vue.shallowRef)(0);
  3105. const left = (0, vue.shallowRef)(0);
  3106. const right = (0, vue.shallowRef)(0);
  3107. const top = (0, vue.shallowRef)(0);
  3108. const width = (0, vue.shallowRef)(0);
  3109. const x = (0, vue.shallowRef)(0);
  3110. const y = (0, vue.shallowRef)(0);
  3111. function recalculate() {
  3112. const el = unrefElement(target);
  3113. if (!el) {
  3114. if (reset) {
  3115. height.value = 0;
  3116. bottom.value = 0;
  3117. left.value = 0;
  3118. right.value = 0;
  3119. top.value = 0;
  3120. width.value = 0;
  3121. x.value = 0;
  3122. y.value = 0;
  3123. }
  3124. return;
  3125. }
  3126. const rect = el.getBoundingClientRect();
  3127. height.value = rect.height;
  3128. bottom.value = rect.bottom;
  3129. left.value = rect.left;
  3130. right.value = rect.right;
  3131. top.value = rect.top;
  3132. width.value = rect.width;
  3133. x.value = rect.x;
  3134. y.value = rect.y;
  3135. }
  3136. function update() {
  3137. if (updateTiming === "sync") recalculate();
  3138. else if (updateTiming === "next-frame") requestAnimationFrame(() => recalculate());
  3139. }
  3140. useResizeObserver(target, update);
  3141. (0, vue.watch)(() => unrefElement(target), (ele) => !ele && update());
  3142. useMutationObserver(target, update, { attributeFilter: ["style", "class"] });
  3143. if (windowScroll) useEventListener("scroll", update, {
  3144. capture: true,
  3145. passive: true
  3146. });
  3147. if (windowResize) useEventListener("resize", update, { passive: true });
  3148. (0, _vueuse_shared.tryOnMounted)(() => {
  3149. if (immediate) update();
  3150. });
  3151. return {
  3152. height,
  3153. bottom,
  3154. left,
  3155. right,
  3156. top,
  3157. width,
  3158. x,
  3159. y,
  3160. update
  3161. };
  3162. }
  3163. //#endregion
  3164. //#region useElementByPoint/index.ts
  3165. function getDefaultScheduler$7(options) {
  3166. if ("interval" in options || "immediate" in options) {
  3167. const { interval = "requestAnimationFrame", immediate = true } = options;
  3168. return interval === "requestAnimationFrame" ? (cb) => useRafFn(cb, { immediate }) : (cb) => (0, _vueuse_shared.useIntervalFn)(cb, interval, { immediate });
  3169. }
  3170. return useRafFn;
  3171. }
  3172. /**
  3173. * Reactive element by point.
  3174. *
  3175. * @see https://vueuse.org/useElementByPoint
  3176. * @param options - UseElementByPointOptions
  3177. */
  3178. function useElementByPoint(options) {
  3179. const { x, y, document = defaultDocument, multiple, scheduler = getDefaultScheduler$7(options) } = options;
  3180. const isSupported = /* @__PURE__ */ useSupported(() => {
  3181. if ((0, vue.toValue)(multiple)) return document && "elementsFromPoint" in document;
  3182. return document && "elementFromPoint" in document;
  3183. });
  3184. const element = (0, vue.shallowRef)(null);
  3185. return {
  3186. isSupported,
  3187. element,
  3188. ...scheduler(() => {
  3189. var _document$elementsFro, _document$elementFrom;
  3190. element.value = (0, vue.toValue)(multiple) ? (_document$elementsFro = document === null || document === void 0 ? void 0 : document.elementsFromPoint((0, vue.toValue)(x), (0, vue.toValue)(y))) !== null && _document$elementsFro !== void 0 ? _document$elementsFro : [] : (_document$elementFrom = document === null || document === void 0 ? void 0 : document.elementFromPoint((0, vue.toValue)(x), (0, vue.toValue)(y))) !== null && _document$elementFrom !== void 0 ? _document$elementFrom : null;
  3191. })
  3192. };
  3193. }
  3194. //#endregion
  3195. //#region useElementHover/index.ts
  3196. function useElementHover(el, options = {}) {
  3197. const { delayEnter = 0, delayLeave = 0, triggerOnRemoval = false, window = defaultWindow } = options;
  3198. const isHovered = (0, vue.shallowRef)(false);
  3199. let timer;
  3200. const toggle = (entering) => {
  3201. const delay = entering ? delayEnter : delayLeave;
  3202. if (timer) {
  3203. clearTimeout(timer);
  3204. timer = void 0;
  3205. }
  3206. if (delay) timer = setTimeout(() => isHovered.value = entering, delay);
  3207. else isHovered.value = entering;
  3208. };
  3209. if (!window) return isHovered;
  3210. useEventListener(el, "mouseenter", () => toggle(true), { passive: true });
  3211. useEventListener(el, "mouseleave", () => toggle(false), { passive: true });
  3212. if (triggerOnRemoval) onElementRemoval((0, vue.computed)(() => unrefElement(el)), () => toggle(false));
  3213. return isHovered;
  3214. }
  3215. //#endregion
  3216. //#region useElementSize/index.ts
  3217. /**
  3218. * Reactive size of an HTML element.
  3219. *
  3220. * @see https://vueuse.org/useElementSize
  3221. */
  3222. function useElementSize(target, initialSize = {
  3223. width: 0,
  3224. height: 0
  3225. }, options = {}) {
  3226. const { window = defaultWindow, box = "content-box" } = options;
  3227. const isSVG = (0, vue.computed)(() => {
  3228. var _unrefElement;
  3229. return (_unrefElement = unrefElement(target)) === null || _unrefElement === void 0 || (_unrefElement = _unrefElement.namespaceURI) === null || _unrefElement === void 0 ? void 0 : _unrefElement.includes("svg");
  3230. });
  3231. const width = (0, vue.shallowRef)(initialSize.width);
  3232. const height = (0, vue.shallowRef)(initialSize.height);
  3233. const { stop: stop1 } = useResizeObserver(target, ([entry]) => {
  3234. const boxSize = box === "border-box" ? entry.borderBoxSize : box === "content-box" ? entry.contentBoxSize : entry.devicePixelContentBoxSize;
  3235. if (window && isSVG.value) {
  3236. const $elem = unrefElement(target);
  3237. if ($elem) {
  3238. const rect = $elem.getBoundingClientRect();
  3239. width.value = rect.width;
  3240. height.value = rect.height;
  3241. }
  3242. } else if (boxSize) {
  3243. const formatBoxSize = (0, _vueuse_shared.toArray)(boxSize);
  3244. width.value = formatBoxSize.reduce((acc, { inlineSize }) => acc + inlineSize, 0);
  3245. height.value = formatBoxSize.reduce((acc, { blockSize }) => acc + blockSize, 0);
  3246. } else {
  3247. width.value = entry.contentRect.width;
  3248. height.value = entry.contentRect.height;
  3249. }
  3250. }, options);
  3251. (0, _vueuse_shared.tryOnMounted)(() => {
  3252. const ele = unrefElement(target);
  3253. if (ele) {
  3254. width.value = "offsetWidth" in ele ? ele.offsetWidth : initialSize.width;
  3255. height.value = "offsetHeight" in ele ? ele.offsetHeight : initialSize.height;
  3256. }
  3257. });
  3258. const stop2 = (0, vue.watch)(() => unrefElement(target), (ele) => {
  3259. width.value = ele ? initialSize.width : 0;
  3260. height.value = ele ? initialSize.height : 0;
  3261. });
  3262. function stop() {
  3263. stop1();
  3264. stop2();
  3265. }
  3266. return {
  3267. width,
  3268. height,
  3269. stop
  3270. };
  3271. }
  3272. //#endregion
  3273. //#region useIntersectionObserver/index.ts
  3274. /**
  3275. * Detects changes to a target element's visibility.
  3276. *
  3277. * @see https://vueuse.org/useIntersectionObserver
  3278. * @param target
  3279. * @param callback
  3280. * @param options
  3281. */
  3282. function useIntersectionObserver(target, callback, options = {}) {
  3283. const { root, rootMargin, threshold = 0, window = defaultWindow, immediate = true } = options;
  3284. const isSupported = /* @__PURE__ */ useSupported(() => window && "IntersectionObserver" in window);
  3285. const targets = (0, vue.computed)(() => {
  3286. return (0, _vueuse_shared.toArray)((0, vue.toValue)(target)).map(unrefElement).filter(_vueuse_shared.notNullish);
  3287. });
  3288. let cleanup = _vueuse_shared.noop;
  3289. const isActive = (0, vue.shallowRef)(immediate);
  3290. const stopWatch = isSupported.value ? (0, vue.watch)(() => [
  3291. targets.value,
  3292. unrefElement(root),
  3293. (0, vue.toValue)(rootMargin),
  3294. isActive.value
  3295. ], ([targets, root, rootMargin]) => {
  3296. cleanup();
  3297. if (!isActive.value) return;
  3298. if (!targets.length) return;
  3299. const observer = new IntersectionObserver(callback, {
  3300. root: unrefElement(root),
  3301. rootMargin,
  3302. threshold
  3303. });
  3304. targets.forEach((el) => el && observer.observe(el));
  3305. cleanup = () => {
  3306. observer.disconnect();
  3307. cleanup = _vueuse_shared.noop;
  3308. };
  3309. }, {
  3310. immediate,
  3311. flush: "post"
  3312. }) : _vueuse_shared.noop;
  3313. const stop = () => {
  3314. cleanup();
  3315. stopWatch();
  3316. isActive.value = false;
  3317. };
  3318. (0, _vueuse_shared.tryOnScopeDispose)(stop);
  3319. return {
  3320. isSupported,
  3321. isActive,
  3322. pause() {
  3323. cleanup();
  3324. isActive.value = false;
  3325. },
  3326. resume() {
  3327. isActive.value = true;
  3328. },
  3329. stop
  3330. };
  3331. }
  3332. //#endregion
  3333. //#region useElementVisibility/index.ts
  3334. function useElementVisibility(element, options = {}) {
  3335. const { window = defaultWindow, scrollTarget, threshold = 0, rootMargin, once = false, initialValue = false } = options;
  3336. const isVisible = (0, vue.shallowRef)(initialValue);
  3337. const observerController = useIntersectionObserver(element, (intersectionObserverEntries) => {
  3338. let isIntersecting = isVisible.value;
  3339. let latestTime = 0;
  3340. for (const entry of intersectionObserverEntries) if (entry.time >= latestTime) {
  3341. latestTime = entry.time;
  3342. isIntersecting = entry.isIntersecting;
  3343. }
  3344. isVisible.value = isIntersecting;
  3345. if (once) (0, _vueuse_shared.watchOnce)(isVisible, () => {
  3346. observerController.stop();
  3347. });
  3348. }, {
  3349. root: scrollTarget,
  3350. window,
  3351. threshold,
  3352. rootMargin
  3353. });
  3354. return options.controls ? {
  3355. ...observerController,
  3356. isVisible
  3357. } : isVisible;
  3358. }
  3359. //#endregion
  3360. //#region useEventBus/internal.ts
  3361. /* #__PURE__ */
  3362. const events = /* @__PURE__ */ new Map();
  3363. //#endregion
  3364. //#region useEventBus/index.ts
  3365. /* @__NO_SIDE_EFFECTS__ */
  3366. function useEventBus(key) {
  3367. const scope = (0, vue.getCurrentScope)();
  3368. function on(listener) {
  3369. var _scope$cleanups;
  3370. const listeners = events.get(key) || /* @__PURE__ */ new Set();
  3371. listeners.add(listener);
  3372. events.set(key, listeners);
  3373. const _off = () => off(listener);
  3374. scope === null || scope === void 0 || (_scope$cleanups = scope.cleanups) === null || _scope$cleanups === void 0 || _scope$cleanups.push(_off);
  3375. return _off;
  3376. }
  3377. function once(listener) {
  3378. function _listener(...args) {
  3379. off(_listener);
  3380. listener(...args);
  3381. }
  3382. return on(_listener);
  3383. }
  3384. function off(listener) {
  3385. const listeners = events.get(key);
  3386. if (!listeners) return;
  3387. listeners.delete(listener);
  3388. if (!listeners.size) reset();
  3389. }
  3390. function reset() {
  3391. events.delete(key);
  3392. }
  3393. function emit(event, payload) {
  3394. var _events$get;
  3395. (_events$get = events.get(key)) === null || _events$get === void 0 || _events$get.forEach((v) => v(event, payload));
  3396. }
  3397. return {
  3398. on,
  3399. once,
  3400. off,
  3401. emit,
  3402. reset
  3403. };
  3404. }
  3405. //#endregion
  3406. //#region useEventSource/index.ts
  3407. function resolveNestedOptions$1(options) {
  3408. if (options === true) return {};
  3409. return options;
  3410. }
  3411. /**
  3412. * Reactive wrapper for EventSource.
  3413. *
  3414. * @see https://vueuse.org/useEventSource
  3415. * @see https://developer.mozilla.org/en-US/docs/Web/API/EventSource/EventSource EventSource
  3416. * @param url
  3417. * @param events
  3418. * @param options
  3419. */
  3420. function useEventSource(url, events = [], options = {}) {
  3421. const event = (0, vue.shallowRef)(null);
  3422. const data = (0, vue.shallowRef)(null);
  3423. const status = (0, vue.shallowRef)("CONNECTING");
  3424. const eventSource = (0, vue.shallowRef)(null);
  3425. const error = (0, vue.shallowRef)(null);
  3426. const urlRef = (0, _vueuse_shared.toRef)(url);
  3427. const lastEventId = (0, vue.shallowRef)(null);
  3428. let explicitlyClosed = false;
  3429. let retried = 0;
  3430. const { withCredentials = false, immediate = true, autoConnect = true, autoReconnect, serializer = { read: (v) => v } } = options;
  3431. const close = () => {
  3432. if (_vueuse_shared.isClient && eventSource.value) {
  3433. eventSource.value.close();
  3434. eventSource.value = null;
  3435. status.value = "CLOSED";
  3436. explicitlyClosed = true;
  3437. }
  3438. };
  3439. const _init = () => {
  3440. if (explicitlyClosed || typeof urlRef.value === "undefined") return;
  3441. const es = new EventSource(urlRef.value, { withCredentials });
  3442. status.value = "CONNECTING";
  3443. eventSource.value = es;
  3444. es.onopen = () => {
  3445. status.value = "OPEN";
  3446. error.value = null;
  3447. };
  3448. es.onerror = (e) => {
  3449. status.value = "CLOSED";
  3450. error.value = e;
  3451. if (es.readyState === 2 && !explicitlyClosed && autoReconnect) {
  3452. es.close();
  3453. const { retries = -1, delay = 1e3, onFailed } = resolveNestedOptions$1(autoReconnect);
  3454. retried += 1;
  3455. if (typeof retries === "number" && (retries < 0 || retried < retries)) setTimeout(_init, delay);
  3456. else if (typeof retries === "function" && retries()) setTimeout(_init, delay);
  3457. else onFailed === null || onFailed === void 0 || onFailed();
  3458. }
  3459. };
  3460. es.onmessage = (e) => {
  3461. var _serializer$read;
  3462. event.value = null;
  3463. data.value = (_serializer$read = serializer.read(e.data)) !== null && _serializer$read !== void 0 ? _serializer$read : null;
  3464. lastEventId.value = e.lastEventId;
  3465. };
  3466. for (const event_name of events) useEventListener(es, event_name, (e) => {
  3467. var _serializer$read2, _e$lastEventId;
  3468. event.value = event_name;
  3469. data.value = (_serializer$read2 = serializer.read(e.data)) !== null && _serializer$read2 !== void 0 ? _serializer$read2 : null;
  3470. lastEventId.value = (_e$lastEventId = e.lastEventId) !== null && _e$lastEventId !== void 0 ? _e$lastEventId : null;
  3471. }, { passive: true });
  3472. };
  3473. const open = () => {
  3474. if (!_vueuse_shared.isClient) return;
  3475. close();
  3476. explicitlyClosed = false;
  3477. retried = 0;
  3478. _init();
  3479. };
  3480. if (immediate) open();
  3481. if (autoConnect) (0, vue.watch)(urlRef, open);
  3482. (0, _vueuse_shared.tryOnScopeDispose)(close);
  3483. return {
  3484. eventSource,
  3485. event,
  3486. data,
  3487. status,
  3488. error,
  3489. open,
  3490. close,
  3491. lastEventId
  3492. };
  3493. }
  3494. //#endregion
  3495. //#region useEyeDropper/index.ts
  3496. /**
  3497. * Reactive [EyeDropper API](https://developer.mozilla.org/en-US/docs/Web/API/EyeDropper_API)
  3498. *
  3499. * @see https://vueuse.org/useEyeDropper
  3500. *
  3501. * @__NO_SIDE_EFFECTS__
  3502. */
  3503. function useEyeDropper(options = {}) {
  3504. const { initialValue = "" } = options;
  3505. const isSupported = /* @__PURE__ */ useSupported(() => typeof window !== "undefined" && "EyeDropper" in window);
  3506. const sRGBHex = (0, vue.shallowRef)(initialValue);
  3507. async function open(openOptions) {
  3508. if (!isSupported.value) return;
  3509. const result = await new window.EyeDropper().open(openOptions);
  3510. sRGBHex.value = result.sRGBHex;
  3511. return result;
  3512. }
  3513. return {
  3514. isSupported,
  3515. sRGBHex,
  3516. open
  3517. };
  3518. }
  3519. //#endregion
  3520. //#region useFavicon/index.ts
  3521. function useFavicon(newIcon = null, options = {}) {
  3522. const { baseUrl = "", rel = "icon", document = defaultDocument } = options;
  3523. const favicon = (0, _vueuse_shared.toRef)(newIcon);
  3524. const applyIcon = (icon) => {
  3525. const elements = document === null || document === void 0 ? void 0 : document.head.querySelectorAll(`link[rel*="${rel}"]`);
  3526. if (!elements || elements.length === 0) {
  3527. const link = document === null || document === void 0 ? void 0 : document.createElement("link");
  3528. if (link) {
  3529. link.rel = rel;
  3530. link.href = `${baseUrl}${icon}`;
  3531. link.type = `image/${icon.split(".").pop()}`;
  3532. document === null || document === void 0 || document.head.append(link);
  3533. }
  3534. return;
  3535. }
  3536. elements === null || elements === void 0 || elements.forEach((el) => el.href = `${baseUrl}${icon}`);
  3537. };
  3538. (0, vue.watch)(favicon, (i, o) => {
  3539. if (typeof i === "string" && i !== o) applyIcon(i);
  3540. }, { immediate: true });
  3541. return favicon;
  3542. }
  3543. //#endregion
  3544. //#region useFetch/index.ts
  3545. const payloadMapping = {
  3546. json: "application/json",
  3547. text: "text/plain"
  3548. };
  3549. /**
  3550. * !!!IMPORTANT!!!
  3551. *
  3552. * If you update the UseFetchOptions interface, be sure to update this object
  3553. * to include the new options
  3554. */
  3555. function isFetchOptions(obj) {
  3556. return obj && (0, _vueuse_shared.containsProp)(obj, "immediate", "refetch", "initialData", "timeout", "beforeFetch", "afterFetch", "onFetchError", "fetch", "updateDataOnError");
  3557. }
  3558. const reAbsolute = /^(?:[a-z][a-z\d+\-.]*:)?\/\//i;
  3559. function isAbsoluteURL(url) {
  3560. return reAbsolute.test(url);
  3561. }
  3562. function headersToObject(headers) {
  3563. if (typeof Headers !== "undefined" && headers instanceof Headers) return Object.fromEntries(headers.entries());
  3564. return headers;
  3565. }
  3566. function combineCallbacks(combination, ...callbacks) {
  3567. if (combination === "overwrite") return async (ctx) => {
  3568. let callback;
  3569. for (let i = callbacks.length - 1; i >= 0; i--) if (callbacks[i] != null) {
  3570. callback = callbacks[i];
  3571. break;
  3572. }
  3573. if (callback) return {
  3574. ...ctx,
  3575. ...await callback(ctx)
  3576. };
  3577. return ctx;
  3578. };
  3579. else return async (ctx) => {
  3580. for (const callback of callbacks) if (callback) ctx = {
  3581. ...ctx,
  3582. ...await callback(ctx)
  3583. };
  3584. return ctx;
  3585. };
  3586. }
  3587. function createFetch(config = {}) {
  3588. const _combination = config.combination || "chain";
  3589. const _options = config.options || {};
  3590. const _fetchOptions = config.fetchOptions || {};
  3591. function useFactoryFetch(url, ...args) {
  3592. const computedUrl = (0, vue.computed)(() => {
  3593. const baseUrl = (0, vue.toValue)(config.baseUrl);
  3594. const targetUrl = (0, vue.toValue)(url);
  3595. return baseUrl && !isAbsoluteURL(targetUrl) ? joinPaths(baseUrl, targetUrl) : targetUrl;
  3596. });
  3597. let options = _options;
  3598. let fetchOptions = _fetchOptions;
  3599. if (args.length > 0) if (isFetchOptions(args[0])) options = {
  3600. ...options,
  3601. ...args[0],
  3602. beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[0].beforeFetch),
  3603. afterFetch: combineCallbacks(_combination, _options.afterFetch, args[0].afterFetch),
  3604. onFetchError: combineCallbacks(_combination, _options.onFetchError, args[0].onFetchError)
  3605. };
  3606. else fetchOptions = {
  3607. ...fetchOptions,
  3608. ...args[0],
  3609. headers: {
  3610. ...headersToObject(fetchOptions.headers) || {},
  3611. ...headersToObject(args[0].headers) || {}
  3612. }
  3613. };
  3614. if (args.length > 1 && isFetchOptions(args[1])) options = {
  3615. ...options,
  3616. ...args[1],
  3617. beforeFetch: combineCallbacks(_combination, _options.beforeFetch, args[1].beforeFetch),
  3618. afterFetch: combineCallbacks(_combination, _options.afterFetch, args[1].afterFetch),
  3619. onFetchError: combineCallbacks(_combination, _options.onFetchError, args[1].onFetchError)
  3620. };
  3621. return useFetch(computedUrl, fetchOptions, options);
  3622. }
  3623. return useFactoryFetch;
  3624. }
  3625. function useFetch(url, ...args) {
  3626. var _defaultWindow$fetch, _globalThis;
  3627. const supportsAbort = typeof AbortController === "function";
  3628. let fetchOptions = {};
  3629. let options = {
  3630. immediate: true,
  3631. refetch: false,
  3632. timeout: 0,
  3633. updateDataOnError: false
  3634. };
  3635. const config = {
  3636. method: "GET",
  3637. type: "text",
  3638. payload: void 0
  3639. };
  3640. if (args.length > 0) if (isFetchOptions(args[0])) options = {
  3641. ...options,
  3642. ...args[0]
  3643. };
  3644. else fetchOptions = args[0];
  3645. if (args.length > 1) {
  3646. if (isFetchOptions(args[1])) options = {
  3647. ...options,
  3648. ...args[1]
  3649. };
  3650. }
  3651. const { fetch = (_defaultWindow$fetch = defaultWindow === null || defaultWindow === void 0 ? void 0 : defaultWindow.fetch) !== null && _defaultWindow$fetch !== void 0 ? _defaultWindow$fetch : (_globalThis = globalThis) === null || _globalThis === void 0 ? void 0 : _globalThis.fetch, initialData, timeout } = options;
  3652. const responseEvent = (0, _vueuse_shared.createEventHook)();
  3653. const errorEvent = (0, _vueuse_shared.createEventHook)();
  3654. const finallyEvent = (0, _vueuse_shared.createEventHook)();
  3655. const isFinished = (0, vue.shallowRef)(false);
  3656. const isFetching = (0, vue.shallowRef)(false);
  3657. const aborted = (0, vue.shallowRef)(false);
  3658. const statusCode = (0, vue.shallowRef)(null);
  3659. const response = (0, vue.shallowRef)(null);
  3660. const error = (0, vue.shallowRef)(null);
  3661. const data = (0, vue.shallowRef)(initialData || null);
  3662. const canAbort = (0, vue.computed)(() => supportsAbort && isFetching.value);
  3663. let controller;
  3664. let timer;
  3665. const abort = (reason) => {
  3666. if (supportsAbort) {
  3667. controller === null || controller === void 0 || controller.abort(reason);
  3668. controller = new AbortController();
  3669. controller.signal.onabort = () => aborted.value = true;
  3670. fetchOptions = {
  3671. ...fetchOptions,
  3672. signal: controller.signal
  3673. };
  3674. }
  3675. };
  3676. const loading = (isLoading) => {
  3677. isFetching.value = isLoading;
  3678. isFinished.value = !isLoading;
  3679. };
  3680. if (timeout) timer = (0, _vueuse_shared.useTimeoutFn)(abort, timeout, { immediate: false });
  3681. let executeCounter = 0;
  3682. const execute = async (throwOnFailed = false) => {
  3683. var _context$options;
  3684. abort();
  3685. loading(true);
  3686. error.value = null;
  3687. statusCode.value = null;
  3688. aborted.value = false;
  3689. executeCounter += 1;
  3690. const currentExecuteCounter = executeCounter;
  3691. const defaultFetchOptions = {
  3692. method: config.method,
  3693. headers: {}
  3694. };
  3695. const payload = (0, vue.toValue)(config.payload);
  3696. if (payload) {
  3697. var _payloadMapping$confi;
  3698. const headers = headersToObject(defaultFetchOptions.headers);
  3699. const proto = Object.getPrototypeOf(payload);
  3700. if (!config.payloadType && payload && (proto === Object.prototype || Array.isArray(proto)) && !(payload instanceof FormData)) config.payloadType = "json";
  3701. if (config.payloadType) headers["Content-Type"] = (_payloadMapping$confi = payloadMapping[config.payloadType]) !== null && _payloadMapping$confi !== void 0 ? _payloadMapping$confi : config.payloadType;
  3702. defaultFetchOptions.body = config.payloadType === "json" ? JSON.stringify(payload) : payload;
  3703. }
  3704. let isCanceled = false;
  3705. const context = {
  3706. url: (0, vue.toValue)(url),
  3707. options: {
  3708. ...defaultFetchOptions,
  3709. ...fetchOptions
  3710. },
  3711. cancel: () => {
  3712. isCanceled = true;
  3713. }
  3714. };
  3715. if (options.beforeFetch) Object.assign(context, await options.beforeFetch(context));
  3716. if (isCanceled || !fetch) {
  3717. loading(false);
  3718. return Promise.resolve(null);
  3719. }
  3720. let responseData = null;
  3721. if (timer) timer.start();
  3722. return fetch(context.url, {
  3723. ...defaultFetchOptions,
  3724. ...context.options,
  3725. headers: {
  3726. ...headersToObject(defaultFetchOptions.headers),
  3727. ...headersToObject((_context$options = context.options) === null || _context$options === void 0 ? void 0 : _context$options.headers)
  3728. }
  3729. }).then(async (fetchResponse) => {
  3730. response.value = fetchResponse;
  3731. statusCode.value = fetchResponse.status;
  3732. responseData = await fetchResponse.clone()[config.type]();
  3733. if (!fetchResponse.ok) {
  3734. data.value = initialData || null;
  3735. throw new Error(fetchResponse.statusText);
  3736. }
  3737. if (options.afterFetch) ({data: responseData} = await options.afterFetch({
  3738. data: responseData,
  3739. response: fetchResponse,
  3740. context,
  3741. execute
  3742. }));
  3743. data.value = responseData;
  3744. responseEvent.trigger(fetchResponse);
  3745. return fetchResponse;
  3746. }).catch(async (fetchError) => {
  3747. let errorData = fetchError.message || fetchError.name;
  3748. if (options.onFetchError) ({error: errorData, data: responseData} = await options.onFetchError({
  3749. data: responseData,
  3750. error: fetchError,
  3751. response: response.value,
  3752. context,
  3753. execute
  3754. }));
  3755. error.value = errorData;
  3756. if (options.updateDataOnError) data.value = responseData;
  3757. errorEvent.trigger(fetchError);
  3758. if (throwOnFailed) throw fetchError;
  3759. return null;
  3760. }).finally(() => {
  3761. if (currentExecuteCounter === executeCounter) loading(false);
  3762. if (timer) timer.stop();
  3763. finallyEvent.trigger(null);
  3764. });
  3765. };
  3766. const refetch = (0, _vueuse_shared.toRef)(options.refetch);
  3767. (0, vue.watch)([refetch, (0, _vueuse_shared.toRef)(url)], ([refetch]) => refetch && execute(), { deep: true });
  3768. const shell = {
  3769. isFinished: (0, vue.shallowReadonly)(isFinished),
  3770. isFetching: (0, vue.shallowReadonly)(isFetching),
  3771. statusCode,
  3772. response,
  3773. error,
  3774. data,
  3775. canAbort,
  3776. aborted,
  3777. abort,
  3778. execute,
  3779. onFetchResponse: responseEvent.on,
  3780. onFetchError: errorEvent.on,
  3781. onFetchFinally: finallyEvent.on,
  3782. get: setMethod("GET"),
  3783. put: setMethod("PUT"),
  3784. post: setMethod("POST"),
  3785. delete: setMethod("DELETE"),
  3786. patch: setMethod("PATCH"),
  3787. head: setMethod("HEAD"),
  3788. options: setMethod("OPTIONS"),
  3789. json: setType("json"),
  3790. text: setType("text"),
  3791. blob: setType("blob"),
  3792. arrayBuffer: setType("arrayBuffer"),
  3793. formData: setType("formData")
  3794. };
  3795. function setMethod(method) {
  3796. return (payload, payloadType) => {
  3797. if (!isFetching.value) {
  3798. config.method = method;
  3799. config.payload = payload;
  3800. config.payloadType = payloadType;
  3801. if ((0, vue.isRef)(config.payload)) (0, vue.watch)([refetch, (0, _vueuse_shared.toRef)(config.payload)], ([refetch]) => refetch && execute(), { deep: true });
  3802. return {
  3803. ...shell,
  3804. then(onFulfilled, onRejected) {
  3805. return waitUntilFinished().then(onFulfilled, onRejected);
  3806. }
  3807. };
  3808. }
  3809. };
  3810. }
  3811. function waitUntilFinished() {
  3812. return new Promise((resolve, reject) => {
  3813. (0, _vueuse_shared.until)(isFinished).toBe(true).then(() => resolve(shell)).catch(reject);
  3814. });
  3815. }
  3816. function setType(type) {
  3817. return () => {
  3818. if (!isFetching.value) {
  3819. config.type = type;
  3820. return {
  3821. ...shell,
  3822. then(onFulfilled, onRejected) {
  3823. return waitUntilFinished().then(onFulfilled, onRejected);
  3824. }
  3825. };
  3826. }
  3827. };
  3828. }
  3829. if (options.immediate) Promise.resolve().then(() => execute());
  3830. return {
  3831. ...shell,
  3832. then(onFulfilled, onRejected) {
  3833. return waitUntilFinished().then(onFulfilled, onRejected);
  3834. }
  3835. };
  3836. }
  3837. function joinPaths(start, end) {
  3838. if (!start.endsWith("/") && !end.startsWith("/")) return `${start}/${end}`;
  3839. if (start.endsWith("/") && end.startsWith("/")) return `${start.slice(0, -1)}${end}`;
  3840. return `${start}${end}`;
  3841. }
  3842. //#endregion
  3843. //#region useFileDialog/index.ts
  3844. const DEFAULT_OPTIONS = {
  3845. multiple: true,
  3846. accept: "*",
  3847. reset: false,
  3848. directory: false
  3849. };
  3850. function prepareInitialFiles(files) {
  3851. if (!files) return null;
  3852. if (files instanceof FileList) return files;
  3853. const dt = new DataTransfer();
  3854. for (const file of files) dt.items.add(file);
  3855. return dt.files;
  3856. }
  3857. /**
  3858. * Open file dialog with ease.
  3859. *
  3860. * @see https://vueuse.org/useFileDialog
  3861. * @param options
  3862. */
  3863. function useFileDialog(options = {}) {
  3864. const { document = defaultDocument } = options;
  3865. const files = (0, vue.ref)(prepareInitialFiles(options.initialFiles));
  3866. const { on: onChange, trigger: changeTrigger } = (0, _vueuse_shared.createEventHook)();
  3867. const { on: onCancel, trigger: cancelTrigger } = (0, _vueuse_shared.createEventHook)();
  3868. const inputRef = (0, vue.computed)(() => {
  3869. var _unrefElement;
  3870. const input = (_unrefElement = unrefElement(options.input)) !== null && _unrefElement !== void 0 ? _unrefElement : document ? document.createElement("input") : void 0;
  3871. if (input) {
  3872. input.type = "file";
  3873. input.onchange = (event) => {
  3874. files.value = event.target.files;
  3875. changeTrigger(files.value);
  3876. };
  3877. input.oncancel = () => {
  3878. cancelTrigger();
  3879. };
  3880. }
  3881. return input;
  3882. });
  3883. const reset = () => {
  3884. files.value = null;
  3885. if (inputRef.value && inputRef.value.value) {
  3886. inputRef.value.value = "";
  3887. changeTrigger(null);
  3888. }
  3889. };
  3890. const applyOptions = (options) => {
  3891. const el = inputRef.value;
  3892. if (!el) return;
  3893. el.multiple = (0, vue.toValue)(options.multiple);
  3894. el.accept = (0, vue.toValue)(options.accept);
  3895. el.webkitdirectory = (0, vue.toValue)(options.directory);
  3896. if ((0, _vueuse_shared.hasOwn)(options, "capture")) el.capture = (0, vue.toValue)(options.capture);
  3897. };
  3898. const open = (localOptions) => {
  3899. const el = inputRef.value;
  3900. if (!el) return;
  3901. const mergedOptions = {
  3902. ...DEFAULT_OPTIONS,
  3903. ...options,
  3904. ...localOptions
  3905. };
  3906. applyOptions(mergedOptions);
  3907. if ((0, vue.toValue)(mergedOptions.reset)) reset();
  3908. el.click();
  3909. };
  3910. (0, vue.watchEffect)(() => {
  3911. applyOptions(options);
  3912. });
  3913. return {
  3914. files: (0, vue.readonly)(files),
  3915. open,
  3916. reset,
  3917. onCancel,
  3918. onChange
  3919. };
  3920. }
  3921. //#endregion
  3922. //#region useFileSystemAccess/index.ts
  3923. function useFileSystemAccess(options = {}) {
  3924. const { window: _window = defaultWindow, dataType = "Text" } = options;
  3925. const window = _window;
  3926. const isSupported = /* @__PURE__ */ useSupported(() => window && "showSaveFilePicker" in window && "showOpenFilePicker" in window);
  3927. const fileHandle = (0, vue.shallowRef)();
  3928. const data = (0, vue.shallowRef)();
  3929. const file = (0, vue.shallowRef)();
  3930. const fileName = (0, vue.computed)(() => {
  3931. var _file$value$name, _file$value;
  3932. return (_file$value$name = (_file$value = file.value) === null || _file$value === void 0 ? void 0 : _file$value.name) !== null && _file$value$name !== void 0 ? _file$value$name : "";
  3933. });
  3934. const fileMIME = (0, vue.computed)(() => {
  3935. var _file$value$type, _file$value2;
  3936. return (_file$value$type = (_file$value2 = file.value) === null || _file$value2 === void 0 ? void 0 : _file$value2.type) !== null && _file$value$type !== void 0 ? _file$value$type : "";
  3937. });
  3938. const fileSize = (0, vue.computed)(() => {
  3939. var _file$value$size, _file$value3;
  3940. return (_file$value$size = (_file$value3 = file.value) === null || _file$value3 === void 0 ? void 0 : _file$value3.size) !== null && _file$value$size !== void 0 ? _file$value$size : 0;
  3941. });
  3942. const fileLastModified = (0, vue.computed)(() => {
  3943. var _file$value$lastModif, _file$value4;
  3944. return (_file$value$lastModif = (_file$value4 = file.value) === null || _file$value4 === void 0 ? void 0 : _file$value4.lastModified) !== null && _file$value$lastModif !== void 0 ? _file$value$lastModif : 0;
  3945. });
  3946. async function open(_options = {}) {
  3947. if (!isSupported.value) return;
  3948. const [handle] = await window.showOpenFilePicker({
  3949. ...(0, vue.toValue)(options),
  3950. ..._options
  3951. });
  3952. fileHandle.value = handle;
  3953. await updateData();
  3954. }
  3955. async function create(_options = {}) {
  3956. if (!isSupported.value) return;
  3957. fileHandle.value = await window.showSaveFilePicker({
  3958. ...options,
  3959. ..._options
  3960. });
  3961. data.value = void 0;
  3962. await updateData();
  3963. }
  3964. async function save(_options = {}) {
  3965. if (!isSupported.value) return;
  3966. if (!fileHandle.value) return saveAs(_options);
  3967. if (data.value) {
  3968. const writableStream = await fileHandle.value.createWritable();
  3969. await writableStream.write(data.value);
  3970. await writableStream.close();
  3971. }
  3972. await updateFile();
  3973. }
  3974. async function saveAs(_options = {}) {
  3975. if (!isSupported.value) return;
  3976. fileHandle.value = await window.showSaveFilePicker({
  3977. ...options,
  3978. ..._options
  3979. });
  3980. if (data.value) {
  3981. const writableStream = await fileHandle.value.createWritable();
  3982. await writableStream.write(data.value);
  3983. await writableStream.close();
  3984. }
  3985. await updateFile();
  3986. }
  3987. async function updateFile() {
  3988. var _fileHandle$value;
  3989. file.value = await ((_fileHandle$value = fileHandle.value) === null || _fileHandle$value === void 0 ? void 0 : _fileHandle$value.getFile());
  3990. }
  3991. async function updateData() {
  3992. var _file$value5, _file$value6;
  3993. await updateFile();
  3994. const type = (0, vue.toValue)(dataType);
  3995. if (type === "Text") data.value = await ((_file$value5 = file.value) === null || _file$value5 === void 0 ? void 0 : _file$value5.text());
  3996. else if (type === "ArrayBuffer") data.value = await ((_file$value6 = file.value) === null || _file$value6 === void 0 ? void 0 : _file$value6.arrayBuffer());
  3997. else if (type === "Blob") data.value = file.value;
  3998. }
  3999. (0, vue.watch)(() => (0, vue.toValue)(dataType), updateData);
  4000. return {
  4001. isSupported,
  4002. data,
  4003. file,
  4004. fileName,
  4005. fileMIME,
  4006. fileSize,
  4007. fileLastModified,
  4008. open,
  4009. create,
  4010. save,
  4011. saveAs,
  4012. updateData
  4013. };
  4014. }
  4015. //#endregion
  4016. //#region useFocus/index.ts
  4017. /**
  4018. * Track or set the focus state of a DOM element.
  4019. *
  4020. * @see https://vueuse.org/useFocus
  4021. * @param target The target element for the focus and blur events.
  4022. * @param options
  4023. */
  4024. function useFocus(target, options = {}) {
  4025. const { initialValue = false, focusVisible = false, preventScroll = false } = options;
  4026. const innerFocused = (0, vue.shallowRef)(false);
  4027. const targetElement = (0, vue.computed)(() => unrefElement(target));
  4028. const listenerOptions = { passive: true };
  4029. useEventListener(targetElement, "focus", (event) => {
  4030. var _matches, _ref;
  4031. if (!focusVisible || ((_matches = (_ref = event.target).matches) === null || _matches === void 0 ? void 0 : _matches.call(_ref, ":focus-visible"))) innerFocused.value = true;
  4032. }, listenerOptions);
  4033. useEventListener(targetElement, "blur", () => innerFocused.value = false, listenerOptions);
  4034. const focused = (0, vue.computed)({
  4035. get: () => innerFocused.value,
  4036. set(value) {
  4037. var _targetElement$value, _targetElement$value2;
  4038. if (!value && innerFocused.value) (_targetElement$value = targetElement.value) === null || _targetElement$value === void 0 || _targetElement$value.blur();
  4039. else if (value && !innerFocused.value) (_targetElement$value2 = targetElement.value) === null || _targetElement$value2 === void 0 || _targetElement$value2.focus({ preventScroll });
  4040. }
  4041. });
  4042. (0, vue.watch)(targetElement, () => {
  4043. focused.value = initialValue;
  4044. }, {
  4045. immediate: true,
  4046. flush: "post"
  4047. });
  4048. return { focused };
  4049. }
  4050. //#endregion
  4051. //#region useFocusWithin/index.ts
  4052. const EVENT_FOCUS_IN = "focusin";
  4053. const EVENT_FOCUS_OUT = "focusout";
  4054. const PSEUDO_CLASS_FOCUS_WITHIN = ":focus-within";
  4055. /**
  4056. * Track if focus is contained within the target element
  4057. *
  4058. * @see https://vueuse.org/useFocusWithin
  4059. * @param target The target element to track
  4060. * @param options Focus within options
  4061. */
  4062. function useFocusWithin(target, options = {}) {
  4063. const { window = defaultWindow } = options;
  4064. const targetElement = (0, vue.computed)(() => unrefElement(target));
  4065. const _focused = (0, vue.shallowRef)(false);
  4066. const focused = (0, vue.computed)(() => _focused.value);
  4067. const activeElement = useActiveElement(options);
  4068. if (!window || !activeElement.value) return { focused };
  4069. const listenerOptions = { passive: true };
  4070. useEventListener(targetElement, EVENT_FOCUS_IN, () => _focused.value = true, listenerOptions);
  4071. useEventListener(targetElement, EVENT_FOCUS_OUT, () => {
  4072. var _targetElement$value$, _targetElement$value, _targetElement$value$2;
  4073. return _focused.value = (_targetElement$value$ = (_targetElement$value = targetElement.value) === null || _targetElement$value === void 0 || (_targetElement$value$2 = _targetElement$value.matches) === null || _targetElement$value$2 === void 0 ? void 0 : _targetElement$value$2.call(_targetElement$value, PSEUDO_CLASS_FOCUS_WITHIN)) !== null && _targetElement$value$ !== void 0 ? _targetElement$value$ : false;
  4074. }, listenerOptions);
  4075. return { focused };
  4076. }
  4077. //#endregion
  4078. //#region useFps/index.ts
  4079. /* @__NO_SIDE_EFFECTS__ */
  4080. function useFps(options) {
  4081. var _options$every;
  4082. const fps = (0, vue.shallowRef)(0);
  4083. if (typeof performance === "undefined") return fps;
  4084. const every = (_options$every = options === null || options === void 0 ? void 0 : options.every) !== null && _options$every !== void 0 ? _options$every : 10;
  4085. let last = performance.now();
  4086. let ticks = 0;
  4087. useRafFn(() => {
  4088. ticks += 1;
  4089. if (ticks >= every) {
  4090. const now = performance.now();
  4091. const diff = now - last;
  4092. fps.value = Math.round(1e3 / (diff / ticks));
  4093. last = now;
  4094. ticks = 0;
  4095. }
  4096. });
  4097. return fps;
  4098. }
  4099. //#endregion
  4100. //#region useFullscreen/index.ts
  4101. const eventHandlers = [
  4102. "fullscreenchange",
  4103. "webkitfullscreenchange",
  4104. "webkitendfullscreen",
  4105. "mozfullscreenchange",
  4106. "MSFullscreenChange"
  4107. ];
  4108. /**
  4109. * Reactive Fullscreen API.
  4110. *
  4111. * @see https://vueuse.org/useFullscreen
  4112. * @param target
  4113. * @param options
  4114. */
  4115. function useFullscreen(target, options = {}) {
  4116. const { document = defaultDocument, autoExit = false } = options;
  4117. const targetRef = (0, vue.computed)(() => {
  4118. var _unrefElement;
  4119. return (_unrefElement = unrefElement(target)) !== null && _unrefElement !== void 0 ? _unrefElement : document === null || document === void 0 ? void 0 : document.documentElement;
  4120. });
  4121. const isFullscreen = (0, vue.shallowRef)(false);
  4122. const requestMethod = (0, vue.computed)(() => {
  4123. return [
  4124. "requestFullscreen",
  4125. "webkitRequestFullscreen",
  4126. "webkitEnterFullscreen",
  4127. "webkitEnterFullScreen",
  4128. "webkitRequestFullScreen",
  4129. "mozRequestFullScreen",
  4130. "msRequestFullscreen"
  4131. ].find((m) => document && m in document || targetRef.value && m in targetRef.value);
  4132. });
  4133. const exitMethod = (0, vue.computed)(() => {
  4134. return [
  4135. "exitFullscreen",
  4136. "webkitExitFullscreen",
  4137. "webkitExitFullScreen",
  4138. "webkitCancelFullScreen",
  4139. "mozCancelFullScreen",
  4140. "msExitFullscreen"
  4141. ].find((m) => document && m in document || targetRef.value && m in targetRef.value);
  4142. });
  4143. const fullscreenEnabled = (0, vue.computed)(() => {
  4144. return [
  4145. "fullScreen",
  4146. "webkitIsFullScreen",
  4147. "webkitDisplayingFullscreen",
  4148. "mozFullScreen",
  4149. "msFullscreenElement"
  4150. ].find((m) => document && m in document || targetRef.value && m in targetRef.value);
  4151. });
  4152. const fullscreenElementMethod = [
  4153. "fullscreenElement",
  4154. "webkitFullscreenElement",
  4155. "mozFullScreenElement",
  4156. "msFullscreenElement"
  4157. ].find((m) => document && m in document);
  4158. const isSupported = /* @__PURE__ */ useSupported(() => targetRef.value && document && requestMethod.value !== void 0 && exitMethod.value !== void 0 && fullscreenEnabled.value !== void 0);
  4159. const isCurrentElementFullScreen = () => {
  4160. if (fullscreenElementMethod) return (document === null || document === void 0 ? void 0 : document[fullscreenElementMethod]) === targetRef.value;
  4161. return false;
  4162. };
  4163. const isElementFullScreen = () => {
  4164. if (fullscreenEnabled.value) if (document && document[fullscreenEnabled.value] != null) return document[fullscreenEnabled.value];
  4165. else {
  4166. const target = targetRef.value;
  4167. if ((target === null || target === void 0 ? void 0 : target[fullscreenEnabled.value]) != null) return Boolean(target[fullscreenEnabled.value]);
  4168. }
  4169. return false;
  4170. };
  4171. async function exit() {
  4172. if (!isSupported.value || !isFullscreen.value) return;
  4173. if (exitMethod.value) if ((document === null || document === void 0 ? void 0 : document[exitMethod.value]) != null) await document[exitMethod.value]();
  4174. else {
  4175. const target = targetRef.value;
  4176. if ((target === null || target === void 0 ? void 0 : target[exitMethod.value]) != null) await target[exitMethod.value]();
  4177. }
  4178. isFullscreen.value = false;
  4179. }
  4180. async function enter() {
  4181. if (!isSupported.value || isFullscreen.value) return;
  4182. if (isElementFullScreen()) await exit();
  4183. const target = targetRef.value;
  4184. if (requestMethod.value && (target === null || target === void 0 ? void 0 : target[requestMethod.value]) != null) {
  4185. await target[requestMethod.value]();
  4186. isFullscreen.value = true;
  4187. }
  4188. }
  4189. async function toggle() {
  4190. await (isFullscreen.value ? exit() : enter());
  4191. }
  4192. const handlerCallback = () => {
  4193. const isElementFullScreenValue = isElementFullScreen();
  4194. if (!isElementFullScreenValue || isElementFullScreenValue && isCurrentElementFullScreen()) isFullscreen.value = isElementFullScreenValue;
  4195. };
  4196. const listenerOptions = {
  4197. capture: false,
  4198. passive: true
  4199. };
  4200. useEventListener(document, eventHandlers, handlerCallback, listenerOptions);
  4201. useEventListener(() => unrefElement(targetRef), eventHandlers, handlerCallback, listenerOptions);
  4202. (0, _vueuse_shared.tryOnMounted)(handlerCallback, false);
  4203. if (autoExit) (0, _vueuse_shared.tryOnScopeDispose)(exit);
  4204. return {
  4205. isSupported,
  4206. isFullscreen,
  4207. enter,
  4208. exit,
  4209. toggle
  4210. };
  4211. }
  4212. //#endregion
  4213. //#region useGamepad/index.ts
  4214. /**
  4215. * Maps a standard standard gamepad to an Xbox 360 Controller.
  4216. */
  4217. function mapGamepadToXbox360Controller(gamepad) {
  4218. return (0, vue.computed)(() => {
  4219. if (gamepad.value) return {
  4220. buttons: {
  4221. a: gamepad.value.buttons[0],
  4222. b: gamepad.value.buttons[1],
  4223. x: gamepad.value.buttons[2],
  4224. y: gamepad.value.buttons[3]
  4225. },
  4226. bumper: {
  4227. left: gamepad.value.buttons[4],
  4228. right: gamepad.value.buttons[5]
  4229. },
  4230. triggers: {
  4231. left: gamepad.value.buttons[6],
  4232. right: gamepad.value.buttons[7]
  4233. },
  4234. stick: {
  4235. left: {
  4236. horizontal: gamepad.value.axes[0],
  4237. vertical: gamepad.value.axes[1],
  4238. button: gamepad.value.buttons[10]
  4239. },
  4240. right: {
  4241. horizontal: gamepad.value.axes[2],
  4242. vertical: gamepad.value.axes[3],
  4243. button: gamepad.value.buttons[11]
  4244. }
  4245. },
  4246. dpad: {
  4247. up: gamepad.value.buttons[12],
  4248. down: gamepad.value.buttons[13],
  4249. left: gamepad.value.buttons[14],
  4250. right: gamepad.value.buttons[15]
  4251. },
  4252. back: gamepad.value.buttons[8],
  4253. start: gamepad.value.buttons[9]
  4254. };
  4255. return null;
  4256. });
  4257. }
  4258. /* @__NO_SIDE_EFFECTS__ */
  4259. function useGamepad(options = {}) {
  4260. const { navigator = defaultNavigator } = options;
  4261. const isSupported = /* @__PURE__ */ useSupported(() => navigator && "getGamepads" in navigator);
  4262. const gamepads = (0, vue.ref)([]);
  4263. const onConnectedHook = (0, _vueuse_shared.createEventHook)();
  4264. const onDisconnectedHook = (0, _vueuse_shared.createEventHook)();
  4265. const stateFromGamepad = (gamepad) => {
  4266. const hapticActuators = [];
  4267. const vibrationActuator = "vibrationActuator" in gamepad ? gamepad.vibrationActuator : null;
  4268. if (vibrationActuator) hapticActuators.push(vibrationActuator);
  4269. if (gamepad.hapticActuators) hapticActuators.push(...gamepad.hapticActuators);
  4270. return {
  4271. id: gamepad.id,
  4272. index: gamepad.index,
  4273. connected: gamepad.connected,
  4274. mapping: gamepad.mapping,
  4275. timestamp: gamepad.timestamp,
  4276. vibrationActuator: gamepad.vibrationActuator,
  4277. hapticActuators,
  4278. axes: gamepad.axes.map((axes) => axes),
  4279. buttons: gamepad.buttons.map((button) => ({
  4280. pressed: button.pressed,
  4281. touched: button.touched,
  4282. value: button.value
  4283. }))
  4284. };
  4285. };
  4286. const updateGamepadState = () => {
  4287. const _gamepads = (navigator === null || navigator === void 0 ? void 0 : navigator.getGamepads()) || [];
  4288. for (const gamepad of _gamepads) if (gamepad && gamepads.value[gamepad.index]) gamepads.value[gamepad.index] = stateFromGamepad(gamepad);
  4289. };
  4290. const { isActive, pause, resume } = useRafFn(updateGamepadState);
  4291. const onGamepadConnected = (gamepad) => {
  4292. if (!gamepads.value.some(({ index }) => index === gamepad.index)) {
  4293. gamepads.value.push(stateFromGamepad(gamepad));
  4294. onConnectedHook.trigger(gamepad.index);
  4295. }
  4296. resume();
  4297. };
  4298. const onGamepadDisconnected = (gamepad) => {
  4299. gamepads.value = gamepads.value.filter((x) => x.index !== gamepad.index);
  4300. onDisconnectedHook.trigger(gamepad.index);
  4301. };
  4302. const listenerOptions = { passive: true };
  4303. useEventListener("gamepadconnected", (e) => onGamepadConnected(e.gamepad), listenerOptions);
  4304. useEventListener("gamepaddisconnected", (e) => onGamepadDisconnected(e.gamepad), listenerOptions);
  4305. (0, _vueuse_shared.tryOnMounted)(() => {
  4306. const _gamepads = (navigator === null || navigator === void 0 ? void 0 : navigator.getGamepads()) || [];
  4307. for (const gamepad of _gamepads) if (gamepad && gamepads.value[gamepad.index]) onGamepadConnected(gamepad);
  4308. });
  4309. pause();
  4310. return {
  4311. isSupported,
  4312. onConnected: onConnectedHook.on,
  4313. onDisconnected: onDisconnectedHook.on,
  4314. gamepads,
  4315. pause,
  4316. resume,
  4317. isActive
  4318. };
  4319. }
  4320. //#endregion
  4321. //#region useGeolocation/index.ts
  4322. /**
  4323. * Reactive Geolocation API.
  4324. *
  4325. * @see https://vueuse.org/useGeolocation
  4326. * @param options
  4327. */
  4328. function useGeolocation(options = {}) {
  4329. const { enableHighAccuracy = true, maximumAge = 3e4, timeout = 27e3, navigator = defaultNavigator, immediate = true } = options;
  4330. const isSupported = /* @__PURE__ */ useSupported(() => navigator && "geolocation" in navigator);
  4331. const locatedAt = (0, vue.shallowRef)(null);
  4332. const error = (0, vue.shallowRef)(null);
  4333. const coords = (0, vue.shallowRef)({
  4334. accuracy: 0,
  4335. latitude: Number.POSITIVE_INFINITY,
  4336. longitude: Number.POSITIVE_INFINITY,
  4337. altitude: null,
  4338. altitudeAccuracy: null,
  4339. heading: null,
  4340. speed: null
  4341. });
  4342. function updatePosition(position) {
  4343. locatedAt.value = position.timestamp;
  4344. coords.value = position.coords;
  4345. error.value = null;
  4346. }
  4347. let watcher;
  4348. function resume() {
  4349. if (isSupported.value) watcher = navigator.geolocation.watchPosition(updatePosition, (err) => error.value = err, {
  4350. enableHighAccuracy,
  4351. maximumAge,
  4352. timeout
  4353. });
  4354. }
  4355. if (immediate) resume();
  4356. function pause() {
  4357. if (watcher && navigator) navigator.geolocation.clearWatch(watcher);
  4358. }
  4359. (0, _vueuse_shared.tryOnScopeDispose)(() => {
  4360. pause();
  4361. });
  4362. return {
  4363. isSupported,
  4364. coords,
  4365. locatedAt,
  4366. error,
  4367. resume,
  4368. pause
  4369. };
  4370. }
  4371. //#endregion
  4372. //#region useIdle/index.ts
  4373. const defaultEvents$1 = [
  4374. "mousemove",
  4375. "mousedown",
  4376. "resize",
  4377. "keydown",
  4378. "touchstart",
  4379. "wheel"
  4380. ];
  4381. const oneMinute = 6e4;
  4382. /**
  4383. * Tracks whether the user is being inactive.
  4384. *
  4385. * @see https://vueuse.org/useIdle
  4386. * @param timeout default to 1 minute
  4387. * @param options IdleOptions
  4388. */
  4389. function useIdle(timeout = oneMinute, options = {}) {
  4390. const { initialState = false, listenForVisibilityChange = true, events = defaultEvents$1, window = defaultWindow, eventFilter = (0, _vueuse_shared.throttleFilter)(50) } = options;
  4391. const idle = (0, vue.shallowRef)(initialState);
  4392. const lastActive = (0, vue.shallowRef)((0, _vueuse_shared.timestamp)());
  4393. const isPending = (0, vue.shallowRef)(false);
  4394. let timer;
  4395. const reset = () => {
  4396. idle.value = false;
  4397. clearTimeout(timer);
  4398. timer = setTimeout(() => idle.value = true, timeout);
  4399. };
  4400. const onEvent = (0, _vueuse_shared.createFilterWrapper)(eventFilter, () => {
  4401. lastActive.value = (0, _vueuse_shared.timestamp)();
  4402. reset();
  4403. });
  4404. if (window) {
  4405. const document = window.document;
  4406. const listenerOptions = { passive: true };
  4407. for (const event of events) useEventListener(window, event, () => {
  4408. if (!isPending.value) return;
  4409. onEvent();
  4410. }, listenerOptions);
  4411. if (listenForVisibilityChange) useEventListener(document, "visibilitychange", () => {
  4412. if (document.hidden || !isPending.value) return;
  4413. onEvent();
  4414. }, listenerOptions);
  4415. start();
  4416. }
  4417. function start() {
  4418. if (isPending.value) return;
  4419. isPending.value = true;
  4420. if (!initialState) reset();
  4421. }
  4422. function stop() {
  4423. idle.value = initialState;
  4424. clearTimeout(timer);
  4425. isPending.value = false;
  4426. }
  4427. return {
  4428. idle,
  4429. lastActive,
  4430. reset,
  4431. stop,
  4432. start,
  4433. isPending: (0, vue.shallowReadonly)(isPending)
  4434. };
  4435. }
  4436. //#endregion
  4437. //#region useImage/index.ts
  4438. async function loadImage(options) {
  4439. return new Promise((resolve, reject) => {
  4440. const img = new Image();
  4441. const { src, srcset, sizes, class: clazz, loading, crossorigin, referrerPolicy, width, height, decoding, fetchPriority, ismap, usemap } = options;
  4442. img.src = src;
  4443. if (srcset != null) img.srcset = srcset;
  4444. if (sizes != null) img.sizes = sizes;
  4445. if (clazz != null) img.className = clazz;
  4446. if (loading != null) img.loading = loading;
  4447. if (crossorigin != null) img.crossOrigin = crossorigin;
  4448. if (referrerPolicy != null) img.referrerPolicy = referrerPolicy;
  4449. if (width != null) img.width = width;
  4450. if (height != null) img.height = height;
  4451. if (decoding != null) img.decoding = decoding;
  4452. if (fetchPriority != null) img.fetchPriority = fetchPriority;
  4453. if (ismap != null) img.isMap = ismap;
  4454. if (usemap != null) img.useMap = usemap;
  4455. img.onload = () => resolve(img);
  4456. img.onerror = reject;
  4457. });
  4458. }
  4459. /**
  4460. * Reactive load an image in the browser, you can wait the result to display it or show a fallback.
  4461. *
  4462. * @see https://vueuse.org/useImage
  4463. * @param options Image attributes, as used in the <img> tag
  4464. * @param asyncStateOptions
  4465. */
  4466. function useImage(options, asyncStateOptions = {}) {
  4467. const state = useAsyncState(() => loadImage((0, vue.toValue)(options)), void 0, {
  4468. resetOnExecute: true,
  4469. ...asyncStateOptions
  4470. });
  4471. (0, vue.watch)(() => (0, vue.toValue)(options), () => state.execute(asyncStateOptions.delay), { deep: true });
  4472. return state;
  4473. }
  4474. //#endregion
  4475. //#region _resolve-element.ts
  4476. /**
  4477. * Resolves an element from a given element, window, or document.
  4478. *
  4479. * @internal
  4480. */
  4481. function resolveElement(el) {
  4482. if (typeof Window !== "undefined" && el instanceof Window) return el.document.documentElement;
  4483. if (typeof Document !== "undefined" && el instanceof Document) return el.documentElement;
  4484. return el;
  4485. }
  4486. //#endregion
  4487. //#region useScroll/index.ts
  4488. /**
  4489. * We have to check if the scroll amount is close enough to some threshold in order to
  4490. * more accurately calculate arrivedState. This is because scrollTop/scrollLeft are non-rounded
  4491. * numbers, while scrollHeight/scrollWidth and clientHeight/clientWidth are rounded.
  4492. * https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#determine_if_an_element_has_been_totally_scrolled
  4493. */
  4494. const ARRIVED_STATE_THRESHOLD_PIXELS = 1;
  4495. /**
  4496. * Reactive scroll.
  4497. *
  4498. * @see https://vueuse.org/useScroll
  4499. * @param element
  4500. * @param options
  4501. */
  4502. function useScroll(element, options = {}) {
  4503. const { throttle = 0, idle = 200, onStop = _vueuse_shared.noop, onScroll = _vueuse_shared.noop, offset = {
  4504. left: 0,
  4505. right: 0,
  4506. top: 0,
  4507. bottom: 0
  4508. }, observe: _observe = { mutation: false }, eventListenerOptions = {
  4509. capture: false,
  4510. passive: true
  4511. }, behavior = "auto", window = defaultWindow, onError = (e) => {
  4512. console.error(e);
  4513. } } = options;
  4514. const observe = typeof _observe === "boolean" ? { mutation: _observe } : _observe;
  4515. const internalX = (0, vue.shallowRef)(0);
  4516. const internalY = (0, vue.shallowRef)(0);
  4517. const x = (0, vue.computed)({
  4518. get() {
  4519. return internalX.value;
  4520. },
  4521. set(x) {
  4522. scrollTo(x, void 0);
  4523. }
  4524. });
  4525. const y = (0, vue.computed)({
  4526. get() {
  4527. return internalY.value;
  4528. },
  4529. set(y) {
  4530. scrollTo(void 0, y);
  4531. }
  4532. });
  4533. function scrollTo(_x, _y) {
  4534. var _ref, _toValue, _toValue2, _document;
  4535. if (!window) return;
  4536. const _element = (0, vue.toValue)(element);
  4537. if (!_element) return;
  4538. (_ref = _element instanceof Document ? window.document.body : _element) === null || _ref === void 0 || _ref.scrollTo({
  4539. top: (_toValue = (0, vue.toValue)(_y)) !== null && _toValue !== void 0 ? _toValue : y.value,
  4540. left: (_toValue2 = (0, vue.toValue)(_x)) !== null && _toValue2 !== void 0 ? _toValue2 : x.value,
  4541. behavior: (0, vue.toValue)(behavior)
  4542. });
  4543. const scrollContainer = (_element === null || _element === void 0 || (_document = _element.document) === null || _document === void 0 ? void 0 : _document.documentElement) || (_element === null || _element === void 0 ? void 0 : _element.documentElement) || _element;
  4544. if (x != null) internalX.value = scrollContainer.scrollLeft;
  4545. if (y != null) internalY.value = scrollContainer.scrollTop;
  4546. }
  4547. const isScrolling = (0, vue.shallowRef)(false);
  4548. const arrivedState = (0, vue.reactive)({
  4549. left: true,
  4550. right: false,
  4551. top: true,
  4552. bottom: false
  4553. });
  4554. const directions = (0, vue.reactive)({
  4555. left: false,
  4556. right: false,
  4557. top: false,
  4558. bottom: false
  4559. });
  4560. const onScrollEnd = (e) => {
  4561. if (!isScrolling.value) return;
  4562. isScrolling.value = false;
  4563. directions.left = false;
  4564. directions.right = false;
  4565. directions.top = false;
  4566. directions.bottom = false;
  4567. onStop(e);
  4568. };
  4569. const onScrollEndDebounced = (0, _vueuse_shared.useDebounceFn)(onScrollEnd, throttle + idle);
  4570. const setArrivedState = (target) => {
  4571. var _document2;
  4572. if (!window) return;
  4573. const el = (target === null || target === void 0 || (_document2 = target.document) === null || _document2 === void 0 ? void 0 : _document2.documentElement) || (target === null || target === void 0 ? void 0 : target.documentElement) || unrefElement(target);
  4574. const { display, flexDirection, direction } = window.getComputedStyle(el);
  4575. const directionMultipler = direction === "rtl" ? -1 : 1;
  4576. const scrollLeft = el.scrollLeft;
  4577. directions.left = scrollLeft < internalX.value;
  4578. directions.right = scrollLeft > internalX.value;
  4579. const left = Math.abs(scrollLeft * directionMultipler) <= (offset.left || 0);
  4580. const right = Math.abs(scrollLeft * directionMultipler) + el.clientWidth >= el.scrollWidth - (offset.right || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
  4581. if (display === "flex" && flexDirection === "row-reverse") {
  4582. arrivedState.left = right;
  4583. arrivedState.right = left;
  4584. } else {
  4585. arrivedState.left = left;
  4586. arrivedState.right = right;
  4587. }
  4588. internalX.value = scrollLeft;
  4589. let scrollTop = el.scrollTop;
  4590. if (target === window.document && !scrollTop) scrollTop = window.document.body.scrollTop;
  4591. directions.top = scrollTop < internalY.value;
  4592. directions.bottom = scrollTop > internalY.value;
  4593. const top = Math.abs(scrollTop) <= (offset.top || 0);
  4594. const bottom = Math.abs(scrollTop) + el.clientHeight >= el.scrollHeight - (offset.bottom || 0) - ARRIVED_STATE_THRESHOLD_PIXELS;
  4595. /**
  4596. * reverse columns and rows behave exactly the other way around,
  4597. * bottom is treated as top and top is treated as the negative version of bottom
  4598. */
  4599. if (display === "flex" && flexDirection === "column-reverse") {
  4600. arrivedState.top = bottom;
  4601. arrivedState.bottom = top;
  4602. } else {
  4603. arrivedState.top = top;
  4604. arrivedState.bottom = bottom;
  4605. }
  4606. internalY.value = scrollTop;
  4607. };
  4608. const onScrollHandler = (e) => {
  4609. var _documentElement;
  4610. if (!window) return;
  4611. setArrivedState((_documentElement = e.target.documentElement) !== null && _documentElement !== void 0 ? _documentElement : e.target);
  4612. isScrolling.value = true;
  4613. onScrollEndDebounced(e);
  4614. onScroll(e);
  4615. };
  4616. useEventListener(element, "scroll", throttle ? (0, _vueuse_shared.useThrottleFn)(onScrollHandler, throttle, true, false) : onScrollHandler, eventListenerOptions);
  4617. (0, _vueuse_shared.tryOnMounted)(() => {
  4618. try {
  4619. const _element = (0, vue.toValue)(element);
  4620. if (!_element) return;
  4621. setArrivedState(_element);
  4622. } catch (e) {
  4623. onError(e);
  4624. }
  4625. });
  4626. if ((observe === null || observe === void 0 ? void 0 : observe.mutation) && element != null && element !== window && element !== document) useMutationObserver(element, () => {
  4627. const _element = (0, vue.toValue)(element);
  4628. if (!_element) return;
  4629. setArrivedState(_element);
  4630. }, {
  4631. attributes: true,
  4632. childList: true,
  4633. subtree: true
  4634. });
  4635. useEventListener(element, "scrollend", onScrollEnd, eventListenerOptions);
  4636. return {
  4637. x,
  4638. y,
  4639. isScrolling,
  4640. arrivedState,
  4641. directions,
  4642. measure() {
  4643. const _element = (0, vue.toValue)(element);
  4644. if (window && _element) setArrivedState(_element);
  4645. }
  4646. };
  4647. }
  4648. //#endregion
  4649. //#region useInfiniteScroll/index.ts
  4650. /**
  4651. * Reactive infinite scroll.
  4652. *
  4653. * @see https://vueuse.org/useInfiniteScroll
  4654. */
  4655. function useInfiniteScroll(element, onLoadMore, options = {}) {
  4656. var _options$distance;
  4657. const { direction = "bottom", interval = 100, canLoadMore = () => true } = options;
  4658. const state = (0, vue.reactive)(useScroll(element, {
  4659. ...options,
  4660. offset: {
  4661. [direction]: (_options$distance = options.distance) !== null && _options$distance !== void 0 ? _options$distance : 0,
  4662. ...options.offset
  4663. }
  4664. }));
  4665. const promise = (0, vue.shallowRef)();
  4666. const isLoading = (0, vue.computed)(() => !!promise.value);
  4667. const observedElement = (0, vue.computed)(() => {
  4668. return resolveElement((0, vue.toValue)(element));
  4669. });
  4670. const isElementVisible = useElementVisibility(observedElement);
  4671. const canLoad = (0, vue.computed)(() => {
  4672. if (!observedElement.value) return false;
  4673. return canLoadMore(observedElement.value);
  4674. });
  4675. function checkAndLoad() {
  4676. state.measure();
  4677. if (!observedElement.value || !isElementVisible.value || !canLoad.value || promise.value) return;
  4678. const { scrollHeight, clientHeight, scrollWidth, clientWidth } = observedElement.value;
  4679. const isNarrower = direction === "bottom" || direction === "top" ? scrollHeight <= clientHeight : scrollWidth <= clientWidth;
  4680. if (state.arrivedState[direction] || isNarrower) promise.value = Promise.all([onLoadMore(state), new Promise((resolve) => setTimeout(resolve, interval))]).finally(() => {
  4681. promise.value = null;
  4682. (0, vue.nextTick)(() => checkAndLoad());
  4683. });
  4684. }
  4685. (0, _vueuse_shared.tryOnUnmounted)((0, vue.watch)(() => [
  4686. state.arrivedState[direction],
  4687. isElementVisible.value,
  4688. canLoad.value
  4689. ], checkAndLoad, {
  4690. immediate: true,
  4691. flush: "post"
  4692. }));
  4693. return {
  4694. isLoading,
  4695. reset() {
  4696. (0, vue.nextTick)(() => checkAndLoad());
  4697. }
  4698. };
  4699. }
  4700. //#endregion
  4701. //#region useKeyModifier/index.ts
  4702. const defaultEvents = [
  4703. "mousedown",
  4704. "mouseup",
  4705. "keydown",
  4706. "keyup"
  4707. ];
  4708. /* @__NO_SIDE_EFFECTS__ */
  4709. function useKeyModifier(modifier, options = {}) {
  4710. const { events = defaultEvents, document = defaultDocument, initial = null } = options;
  4711. const state = (0, vue.shallowRef)(initial);
  4712. if (document) events.forEach((listenerEvent) => {
  4713. useEventListener(document, listenerEvent, (evt) => {
  4714. if (typeof evt.getModifierState === "function") state.value = evt.getModifierState(modifier);
  4715. }, { passive: true });
  4716. });
  4717. return state;
  4718. }
  4719. //#endregion
  4720. //#region useLocalStorage/index.ts
  4721. /**
  4722. * Reactive LocalStorage.
  4723. *
  4724. * @see https://vueuse.org/useLocalStorage
  4725. * @param key
  4726. * @param initialValue
  4727. * @param options
  4728. */
  4729. function useLocalStorage(key, initialValue, options = {}) {
  4730. const { window = defaultWindow } = options;
  4731. return useStorage(key, initialValue, window === null || window === void 0 ? void 0 : window.localStorage, options);
  4732. }
  4733. //#endregion
  4734. //#region useMagicKeys/aliasMap.ts
  4735. const DefaultMagicKeysAliasMap = {
  4736. ctrl: "control",
  4737. command: "meta",
  4738. cmd: "meta",
  4739. option: "alt",
  4740. up: "arrowup",
  4741. down: "arrowdown",
  4742. left: "arrowleft",
  4743. right: "arrowright"
  4744. };
  4745. //#endregion
  4746. //#region useMagicKeys/index.ts
  4747. /**
  4748. * Reactive keys pressed state, with magical keys combination support.
  4749. *
  4750. * @see https://vueuse.org/useMagicKeys
  4751. */
  4752. function useMagicKeys(options = {}) {
  4753. const { reactive: useReactive = false, target = defaultWindow, aliasMap = DefaultMagicKeysAliasMap, passive = true, onEventFired = _vueuse_shared.noop } = options;
  4754. const current = (0, vue.reactive)(/* @__PURE__ */ new Set());
  4755. const obj = {
  4756. toJSON() {
  4757. return {};
  4758. },
  4759. current
  4760. };
  4761. const refs = useReactive ? (0, vue.reactive)(obj) : obj;
  4762. const metaDeps = /* @__PURE__ */ new Set();
  4763. const depsMap = new Map([
  4764. ["Meta", metaDeps],
  4765. ["Shift", /* @__PURE__ */ new Set()],
  4766. ["Alt", /* @__PURE__ */ new Set()]
  4767. ]);
  4768. const usedKeys = /* @__PURE__ */ new Set();
  4769. function setRefs(key, value) {
  4770. if (key in refs) if (useReactive) refs[key] = value;
  4771. else refs[key].value = value;
  4772. }
  4773. function reset() {
  4774. current.clear();
  4775. for (const key of usedKeys) setRefs(key, false);
  4776. }
  4777. function updateDeps(value, e, keys) {
  4778. if (!value || typeof e.getModifierState !== "function") return;
  4779. for (const [modifier, depsSet] of depsMap) if (e.getModifierState(modifier)) {
  4780. keys.forEach((key) => depsSet.add(key));
  4781. break;
  4782. }
  4783. }
  4784. function clearDeps(value, key) {
  4785. if (value) return;
  4786. const depsMapKey = `${key[0].toUpperCase()}${key.slice(1)}`;
  4787. const deps = depsMap.get(depsMapKey);
  4788. if (!["shift", "alt"].includes(key) || !deps) return;
  4789. const depsArray = Array.from(deps);
  4790. const depsIndex = depsArray.indexOf(key);
  4791. depsArray.forEach((key, index) => {
  4792. if (index >= depsIndex) {
  4793. current.delete(key);
  4794. setRefs(key, false);
  4795. }
  4796. });
  4797. deps.clear();
  4798. }
  4799. function updateRefs(e, value) {
  4800. var _e$key, _e$code;
  4801. const key = (_e$key = e.key) === null || _e$key === void 0 ? void 0 : _e$key.toLowerCase();
  4802. const values = [(_e$code = e.code) === null || _e$code === void 0 ? void 0 : _e$code.toLowerCase(), key].filter(Boolean);
  4803. if (!key) return;
  4804. if (key) if (value) current.add(key);
  4805. else current.delete(key);
  4806. for (const key of values) {
  4807. usedKeys.add(key);
  4808. setRefs(key, value);
  4809. }
  4810. updateDeps(value, e, [...current, ...values]);
  4811. clearDeps(value, key);
  4812. if (key === "meta" && !value) {
  4813. metaDeps.forEach((key) => {
  4814. current.delete(key);
  4815. setRefs(key, false);
  4816. });
  4817. metaDeps.clear();
  4818. }
  4819. }
  4820. useEventListener(target, "keydown", (e) => {
  4821. updateRefs(e, true);
  4822. return onEventFired(e);
  4823. }, { passive });
  4824. useEventListener(target, "keyup", (e) => {
  4825. updateRefs(e, false);
  4826. return onEventFired(e);
  4827. }, { passive });
  4828. useEventListener("blur", reset, { passive });
  4829. useEventListener("focus", reset, { passive });
  4830. const proxy = new Proxy(refs, { get(target, prop, rec) {
  4831. if (typeof prop !== "string") return Reflect.get(target, prop, rec);
  4832. prop = prop.toLowerCase();
  4833. if (prop in aliasMap) prop = aliasMap[prop];
  4834. if (!(prop in refs)) if (/[+_-]/.test(prop)) {
  4835. const keys = prop.split(/[+_-]/g).map((i) => i.trim());
  4836. refs[prop] = (0, vue.computed)(() => keys.map((key) => (0, vue.toValue)(proxy[key])).every(Boolean));
  4837. } else refs[prop] = (0, vue.shallowRef)(false);
  4838. const r = Reflect.get(target, prop, rec);
  4839. return useReactive ? (0, vue.toValue)(r) : r;
  4840. } });
  4841. return proxy;
  4842. }
  4843. //#endregion
  4844. //#region useMediaControls/index.ts
  4845. /**
  4846. * Automatically check if the ref exists and if it does run the cb fn
  4847. */
  4848. function usingElRef(source, cb) {
  4849. if ((0, vue.toValue)(source)) cb((0, vue.toValue)(source));
  4850. }
  4851. /**
  4852. * Converts a TimeRange object to an array
  4853. */
  4854. function timeRangeToArray(timeRanges) {
  4855. let ranges = [];
  4856. for (let i = 0; i < timeRanges.length; ++i) ranges = [...ranges, [timeRanges.start(i), timeRanges.end(i)]];
  4857. return ranges;
  4858. }
  4859. /**
  4860. * Converts a TextTrackList object to an array of `UseMediaTextTrack`
  4861. */
  4862. function tracksToArray(tracks) {
  4863. return Array.from(tracks).map(({ label, kind, language, mode, activeCues, cues, inBandMetadataTrackDispatchType }, id) => ({
  4864. id,
  4865. label,
  4866. kind,
  4867. language,
  4868. mode,
  4869. activeCues,
  4870. cues,
  4871. inBandMetadataTrackDispatchType
  4872. }));
  4873. }
  4874. const defaultOptions = {
  4875. src: "",
  4876. tracks: []
  4877. };
  4878. function useMediaControls(target, options = {}) {
  4879. target = (0, _vueuse_shared.toRef)(target);
  4880. options = {
  4881. ...defaultOptions,
  4882. ...options
  4883. };
  4884. const { document = defaultDocument } = options;
  4885. const listenerOptions = { passive: true };
  4886. const currentTime = (0, vue.shallowRef)(0);
  4887. const duration = (0, vue.shallowRef)(0);
  4888. const seeking = (0, vue.shallowRef)(false);
  4889. const volume = (0, vue.shallowRef)(1);
  4890. const waiting = (0, vue.shallowRef)(false);
  4891. const ended = (0, vue.shallowRef)(false);
  4892. const playing = (0, vue.shallowRef)(false);
  4893. const rate = (0, vue.shallowRef)(1);
  4894. const stalled = (0, vue.shallowRef)(false);
  4895. const buffered = (0, vue.shallowRef)([]);
  4896. const tracks = (0, vue.shallowRef)([]);
  4897. const selectedTrack = (0, vue.shallowRef)(-1);
  4898. const isPictureInPicture = (0, vue.shallowRef)(false);
  4899. const muted = (0, vue.shallowRef)(false);
  4900. const supportsPictureInPicture = Boolean(document && "pictureInPictureEnabled" in document);
  4901. const sourceErrorEvent = (0, _vueuse_shared.createEventHook)();
  4902. const playbackErrorEvent = (0, _vueuse_shared.createEventHook)();
  4903. /**
  4904. * Disables the specified track. If no track is specified then
  4905. * all tracks will be disabled
  4906. *
  4907. * @param track The id of the track to disable
  4908. */
  4909. const disableTrack = (track) => {
  4910. usingElRef(target, (el) => {
  4911. if (track) {
  4912. const id = typeof track === "number" ? track : track.id;
  4913. el.textTracks[id].mode = "disabled";
  4914. } else for (let i = 0; i < el.textTracks.length; ++i) el.textTracks[i].mode = "disabled";
  4915. selectedTrack.value = -1;
  4916. });
  4917. };
  4918. /**
  4919. * Enables the specified track and disables the
  4920. * other tracks unless otherwise specified
  4921. *
  4922. * @param track The track of the id of the track to enable
  4923. * @param disableTracks Disable all other tracks
  4924. */
  4925. const enableTrack = (track, disableTracks = true) => {
  4926. usingElRef(target, (el) => {
  4927. const id = typeof track === "number" ? track : track.id;
  4928. if (disableTracks) disableTrack();
  4929. el.textTracks[id].mode = "showing";
  4930. selectedTrack.value = id;
  4931. });
  4932. };
  4933. /**
  4934. * Toggle picture in picture mode for the player.
  4935. */
  4936. const togglePictureInPicture = () => {
  4937. return new Promise((resolve, reject) => {
  4938. usingElRef(target, async (el) => {
  4939. if (supportsPictureInPicture) if (!isPictureInPicture.value) el.requestPictureInPicture().then(resolve).catch(reject);
  4940. else document.exitPictureInPicture().then(resolve).catch(reject);
  4941. });
  4942. });
  4943. };
  4944. /**
  4945. * This will automatically inject sources to the media element. The sources will be
  4946. * appended as children to the media element as `<source>` elements.
  4947. */
  4948. (0, vue.watchEffect)(() => {
  4949. if (!document) return;
  4950. const el = (0, vue.toValue)(target);
  4951. if (!el) return;
  4952. const src = (0, vue.toValue)(options.src);
  4953. let sources = [];
  4954. if (!src) return;
  4955. if (typeof src === "string") sources = [{ src }];
  4956. else if (Array.isArray(src)) sources = src;
  4957. else if ((0, _vueuse_shared.isObject)(src)) sources = [src];
  4958. el.querySelectorAll("source").forEach((e) => {
  4959. e.remove();
  4960. });
  4961. sources.forEach(({ src, type, media }) => {
  4962. const source = document.createElement("source");
  4963. source.setAttribute("src", src);
  4964. source.setAttribute("type", type || "");
  4965. source.setAttribute("media", media || "");
  4966. useEventListener(source, "error", sourceErrorEvent.trigger, listenerOptions);
  4967. el.appendChild(source);
  4968. });
  4969. el.load();
  4970. });
  4971. /**
  4972. * Apply composable state to the element, also when element is changed
  4973. */
  4974. (0, vue.watch)([target, volume], () => {
  4975. const el = (0, vue.toValue)(target);
  4976. if (!el) return;
  4977. el.volume = volume.value;
  4978. });
  4979. (0, vue.watch)([target, muted], () => {
  4980. const el = (0, vue.toValue)(target);
  4981. if (!el) return;
  4982. el.muted = muted.value;
  4983. });
  4984. (0, vue.watch)([target, rate], () => {
  4985. const el = (0, vue.toValue)(target);
  4986. if (!el) return;
  4987. el.playbackRate = rate.value;
  4988. });
  4989. /**
  4990. * Load Tracks
  4991. */
  4992. (0, vue.watchEffect)(() => {
  4993. if (!document) return;
  4994. const textTracks = (0, vue.toValue)(options.tracks);
  4995. const el = (0, vue.toValue)(target);
  4996. if (!textTracks || !textTracks.length || !el) return;
  4997. /**
  4998. * The MediaAPI provides an API for adding text tracks, but they don't currently
  4999. * have an API for removing text tracks, so instead we will just create and remove
  5000. * the tracks manually using the HTML api.
  5001. */
  5002. el.querySelectorAll("track").forEach((e) => e.remove());
  5003. textTracks.forEach(({ default: isDefault, kind, label, src, srcLang }, i) => {
  5004. const track = document.createElement("track");
  5005. track.default = isDefault || false;
  5006. track.kind = kind;
  5007. track.label = label;
  5008. track.src = src;
  5009. track.srclang = srcLang;
  5010. if (track.default) selectedTrack.value = i;
  5011. el.appendChild(track);
  5012. });
  5013. });
  5014. /**
  5015. * This will allow us to update the current time from the timeupdate event
  5016. * without setting the medias current position, but if the user changes the
  5017. * current time via the ref, then the media will seek.
  5018. *
  5019. * If we did not use an ignorable watch, then the current time update from
  5020. * the timeupdate event would cause the media to stutter.
  5021. */
  5022. const { ignoreUpdates: ignoreCurrentTimeUpdates } = (0, _vueuse_shared.watchIgnorable)(currentTime, (time) => {
  5023. const el = (0, vue.toValue)(target);
  5024. if (!el) return;
  5025. el.currentTime = time;
  5026. });
  5027. /**
  5028. * Using an ignorable watch so we can control the play state using a ref and not
  5029. * a function
  5030. */
  5031. const { ignoreUpdates: ignorePlayingUpdates } = (0, _vueuse_shared.watchIgnorable)(playing, (isPlaying) => {
  5032. const el = (0, vue.toValue)(target);
  5033. if (!el) return;
  5034. if (isPlaying) el.play().catch((e) => {
  5035. playbackErrorEvent.trigger(e);
  5036. throw e;
  5037. });
  5038. else el.pause();
  5039. });
  5040. useEventListener(target, "timeupdate", () => ignoreCurrentTimeUpdates(() => currentTime.value = (0, vue.toValue)(target).currentTime), listenerOptions);
  5041. useEventListener(target, "durationchange", () => duration.value = (0, vue.toValue)(target).duration, listenerOptions);
  5042. useEventListener(target, "progress", () => buffered.value = timeRangeToArray((0, vue.toValue)(target).buffered), listenerOptions);
  5043. useEventListener(target, "seeking", () => seeking.value = true, listenerOptions);
  5044. useEventListener(target, "seeked", () => seeking.value = false, listenerOptions);
  5045. useEventListener(target, ["waiting", "loadstart"], () => {
  5046. waiting.value = true;
  5047. ignorePlayingUpdates(() => playing.value = false);
  5048. }, listenerOptions);
  5049. useEventListener(target, "loadeddata", () => waiting.value = false, listenerOptions);
  5050. useEventListener(target, "playing", () => {
  5051. waiting.value = false;
  5052. ended.value = false;
  5053. ignorePlayingUpdates(() => playing.value = true);
  5054. }, listenerOptions);
  5055. useEventListener(target, "ratechange", () => rate.value = (0, vue.toValue)(target).playbackRate, listenerOptions);
  5056. useEventListener(target, "stalled", () => stalled.value = true, listenerOptions);
  5057. useEventListener(target, "ended", () => ended.value = true, listenerOptions);
  5058. useEventListener(target, "pause", () => ignorePlayingUpdates(() => playing.value = false), listenerOptions);
  5059. useEventListener(target, "play", () => ignorePlayingUpdates(() => playing.value = true), listenerOptions);
  5060. useEventListener(target, "enterpictureinpicture", () => isPictureInPicture.value = true, listenerOptions);
  5061. useEventListener(target, "leavepictureinpicture", () => isPictureInPicture.value = false, listenerOptions);
  5062. useEventListener(target, "volumechange", () => {
  5063. const el = (0, vue.toValue)(target);
  5064. if (!el) return;
  5065. volume.value = el.volume;
  5066. muted.value = el.muted;
  5067. }, listenerOptions);
  5068. /**
  5069. * The following listeners need to listen to a nested
  5070. * object on the target, so we will have to use a nested
  5071. * watch and manually remove the listeners
  5072. */
  5073. const listeners = [];
  5074. const stop = (0, vue.watch)([target], () => {
  5075. const el = (0, vue.toValue)(target);
  5076. if (!el) return;
  5077. stop();
  5078. listeners[0] = useEventListener(el.textTracks, "addtrack", () => tracks.value = tracksToArray(el.textTracks), listenerOptions);
  5079. listeners[1] = useEventListener(el.textTracks, "removetrack", () => tracks.value = tracksToArray(el.textTracks), listenerOptions);
  5080. listeners[2] = useEventListener(el.textTracks, "change", () => tracks.value = tracksToArray(el.textTracks), listenerOptions);
  5081. });
  5082. (0, _vueuse_shared.tryOnScopeDispose)(() => listeners.forEach((listener) => listener()));
  5083. return {
  5084. currentTime,
  5085. duration,
  5086. waiting,
  5087. seeking,
  5088. ended,
  5089. stalled,
  5090. buffered,
  5091. playing,
  5092. rate,
  5093. volume,
  5094. muted,
  5095. tracks,
  5096. selectedTrack,
  5097. enableTrack,
  5098. disableTrack,
  5099. supportsPictureInPicture,
  5100. togglePictureInPicture,
  5101. isPictureInPicture,
  5102. onSourceError: sourceErrorEvent.on,
  5103. onPlaybackError: playbackErrorEvent.on
  5104. };
  5105. }
  5106. //#endregion
  5107. //#region useMemoize/index.ts
  5108. /**
  5109. * Reactive function result cache based on arguments
  5110. *
  5111. * @__NO_SIDE_EFFECTS__
  5112. */
  5113. function useMemoize(resolver, options) {
  5114. const initCache = () => {
  5115. if (options === null || options === void 0 ? void 0 : options.cache) return (0, vue.shallowReactive)(options.cache);
  5116. return (0, vue.shallowReactive)(/* @__PURE__ */ new Map());
  5117. };
  5118. const cache = initCache();
  5119. /**
  5120. * Generate key from args
  5121. */
  5122. const generateKey = (...args) => (options === null || options === void 0 ? void 0 : options.getKey) ? options.getKey(...args) : JSON.stringify(args);
  5123. /**
  5124. * Load data and save in cache
  5125. */
  5126. const _loadData = (key, ...args) => {
  5127. cache.set(key, resolver(...args));
  5128. return cache.get(key);
  5129. };
  5130. const loadData = (...args) => _loadData(generateKey(...args), ...args);
  5131. /**
  5132. * Delete key from cache
  5133. */
  5134. const deleteData = (...args) => {
  5135. cache.delete(generateKey(...args));
  5136. };
  5137. /**
  5138. * Clear cached data
  5139. */
  5140. const clearData = () => {
  5141. cache.clear();
  5142. };
  5143. const memoized = (...args) => {
  5144. const key = generateKey(...args);
  5145. if (cache.has(key)) return cache.get(key);
  5146. return _loadData(key, ...args);
  5147. };
  5148. memoized.load = loadData;
  5149. memoized.delete = deleteData;
  5150. memoized.clear = clearData;
  5151. memoized.generateKey = generateKey;
  5152. memoized.cache = cache;
  5153. return memoized;
  5154. }
  5155. //#endregion
  5156. //#region useMemory/index.ts
  5157. function getDefaultScheduler$6(options) {
  5158. if ("interval" in options || "immediate" in options || "immediateCallback" in options) {
  5159. const { interval = 1e3, immediate, immediateCallback } = options;
  5160. return (cb) => (0, _vueuse_shared.useIntervalFn)(cb, interval, {
  5161. immediate,
  5162. immediateCallback
  5163. });
  5164. }
  5165. return _vueuse_shared.useIntervalFn;
  5166. }
  5167. /**
  5168. * Reactive Memory Info.
  5169. *
  5170. * @see https://vueuse.org/useMemory
  5171. * @param options
  5172. *
  5173. * @__NO_SIDE_EFFECTS__
  5174. */
  5175. function useMemory(options = {}) {
  5176. const memory = (0, vue.shallowRef)();
  5177. const isSupported = /* @__PURE__ */ useSupported(() => typeof performance !== "undefined" && "memory" in performance);
  5178. if (isSupported.value) {
  5179. const { scheduler = getDefaultScheduler$6 } = options;
  5180. scheduler(() => {
  5181. memory.value = performance.memory;
  5182. });
  5183. }
  5184. return {
  5185. isSupported,
  5186. memory
  5187. };
  5188. }
  5189. //#endregion
  5190. //#region useMouse/index.ts
  5191. const UseMouseBuiltinExtractors = {
  5192. page: (event) => [event.pageX, event.pageY],
  5193. client: (event) => [event.clientX, event.clientY],
  5194. screen: (event) => [event.screenX, event.screenY],
  5195. movement: (event) => event instanceof MouseEvent ? [event.movementX, event.movementY] : null
  5196. };
  5197. /**
  5198. * Reactive mouse position.
  5199. *
  5200. * @see https://vueuse.org/useMouse
  5201. * @param options
  5202. */
  5203. function useMouse(options = {}) {
  5204. const { type = "page", touch = true, resetOnTouchEnds = false, initialValue = {
  5205. x: 0,
  5206. y: 0
  5207. }, window = defaultWindow, target = window, scroll = true, eventFilter } = options;
  5208. let _prevMouseEvent = null;
  5209. let _prevScrollX = 0;
  5210. let _prevScrollY = 0;
  5211. const x = (0, vue.shallowRef)(initialValue.x);
  5212. const y = (0, vue.shallowRef)(initialValue.y);
  5213. const sourceType = (0, vue.shallowRef)(null);
  5214. const extractor = typeof type === "function" ? type : UseMouseBuiltinExtractors[type];
  5215. const mouseHandler = (event) => {
  5216. const result = extractor(event);
  5217. _prevMouseEvent = event;
  5218. if (result) {
  5219. [x.value, y.value] = result;
  5220. sourceType.value = "mouse";
  5221. }
  5222. if (window) {
  5223. _prevScrollX = window.scrollX;
  5224. _prevScrollY = window.scrollY;
  5225. }
  5226. };
  5227. const touchHandler = (event) => {
  5228. if (event.touches.length > 0) {
  5229. const result = extractor(event.touches[0]);
  5230. if (result) {
  5231. [x.value, y.value] = result;
  5232. sourceType.value = "touch";
  5233. }
  5234. }
  5235. };
  5236. const scrollHandler = () => {
  5237. if (!_prevMouseEvent || !window) return;
  5238. const pos = extractor(_prevMouseEvent);
  5239. if (_prevMouseEvent instanceof MouseEvent && pos) {
  5240. x.value = pos[0] + window.scrollX - _prevScrollX;
  5241. y.value = pos[1] + window.scrollY - _prevScrollY;
  5242. }
  5243. };
  5244. const reset = () => {
  5245. x.value = initialValue.x;
  5246. y.value = initialValue.y;
  5247. };
  5248. const mouseHandlerWrapper = eventFilter ? (event) => eventFilter(() => mouseHandler(event), {}) : (event) => mouseHandler(event);
  5249. const touchHandlerWrapper = eventFilter ? (event) => eventFilter(() => touchHandler(event), {}) : (event) => touchHandler(event);
  5250. const scrollHandlerWrapper = eventFilter ? () => eventFilter(() => scrollHandler(), {}) : () => scrollHandler();
  5251. if (target) {
  5252. const listenerOptions = { passive: true };
  5253. useEventListener(target, ["mousemove", "dragover"], mouseHandlerWrapper, listenerOptions);
  5254. if (touch && type !== "movement") {
  5255. useEventListener(target, ["touchstart", "touchmove"], touchHandlerWrapper, listenerOptions);
  5256. if (resetOnTouchEnds) useEventListener(target, "touchend", reset, listenerOptions);
  5257. }
  5258. if (scroll && type === "page") useEventListener(window, "scroll", scrollHandlerWrapper, listenerOptions);
  5259. }
  5260. return {
  5261. x,
  5262. y,
  5263. sourceType
  5264. };
  5265. }
  5266. //#endregion
  5267. //#region useMouseInElement/index.ts
  5268. /**
  5269. * Reactive mouse position related to an element.
  5270. *
  5271. * @see https://vueuse.org/useMouseInElement
  5272. * @param target
  5273. * @param options
  5274. */
  5275. function useMouseInElement(target, options = {}) {
  5276. const { windowResize = true, windowScroll = true, handleOutside = true, window = defaultWindow } = options;
  5277. const type = options.type || "page";
  5278. const { x, y, sourceType } = useMouse(options);
  5279. const targetRef = (0, vue.shallowRef)(target !== null && target !== void 0 ? target : window === null || window === void 0 ? void 0 : window.document.body);
  5280. const elementX = (0, vue.shallowRef)(0);
  5281. const elementY = (0, vue.shallowRef)(0);
  5282. const elementPositionX = (0, vue.shallowRef)(0);
  5283. const elementPositionY = (0, vue.shallowRef)(0);
  5284. const elementHeight = (0, vue.shallowRef)(0);
  5285. const elementWidth = (0, vue.shallowRef)(0);
  5286. const isOutside = (0, vue.shallowRef)(true);
  5287. function update() {
  5288. if (!window) return;
  5289. const el = unrefElement(targetRef);
  5290. if (!el || !(el instanceof Element)) return;
  5291. for (const rect of el.getClientRects()) {
  5292. const { left, top, width, height } = rect;
  5293. elementPositionX.value = left + (type === "page" ? window.pageXOffset : 0);
  5294. elementPositionY.value = top + (type === "page" ? window.pageYOffset : 0);
  5295. elementHeight.value = height;
  5296. elementWidth.value = width;
  5297. const elX = x.value - elementPositionX.value;
  5298. const elY = y.value - elementPositionY.value;
  5299. isOutside.value = width === 0 || height === 0 || elX < 0 || elY < 0 || elX > width || elY > height;
  5300. if (handleOutside || !isOutside.value) {
  5301. elementX.value = elX;
  5302. elementY.value = elY;
  5303. }
  5304. if (!isOutside.value) break;
  5305. }
  5306. }
  5307. const stopFnList = [];
  5308. function stop() {
  5309. stopFnList.forEach((fn) => fn());
  5310. stopFnList.length = 0;
  5311. }
  5312. (0, _vueuse_shared.tryOnMounted)(() => {
  5313. update();
  5314. });
  5315. if (window) {
  5316. const { stop: stopResizeObserver } = useResizeObserver(targetRef, update);
  5317. const { stop: stopMutationObserver } = useMutationObserver(targetRef, update, { attributeFilter: ["style", "class"] });
  5318. const stopWatch = (0, vue.watch)([
  5319. targetRef,
  5320. x,
  5321. y
  5322. ], update);
  5323. stopFnList.push(stopResizeObserver, stopMutationObserver, stopWatch);
  5324. useEventListener(document, "mouseleave", () => isOutside.value = true, { passive: true });
  5325. if (windowScroll) stopFnList.push(useEventListener("scroll", update, {
  5326. capture: true,
  5327. passive: true
  5328. }));
  5329. if (windowResize) stopFnList.push(useEventListener("resize", update, { passive: true }));
  5330. }
  5331. return {
  5332. x,
  5333. y,
  5334. sourceType,
  5335. elementX,
  5336. elementY,
  5337. elementPositionX,
  5338. elementPositionY,
  5339. elementHeight,
  5340. elementWidth,
  5341. isOutside,
  5342. stop
  5343. };
  5344. }
  5345. //#endregion
  5346. //#region useMousePressed/index.ts
  5347. /**
  5348. * Reactive mouse pressing state.
  5349. *
  5350. * @see https://vueuse.org/useMousePressed
  5351. * @param options
  5352. */
  5353. function useMousePressed(options = {}) {
  5354. const { touch = true, drag = true, capture = false, initialValue = false, window = defaultWindow } = options;
  5355. const pressed = (0, vue.shallowRef)(initialValue);
  5356. const sourceType = (0, vue.shallowRef)(null);
  5357. if (!window) return {
  5358. pressed,
  5359. sourceType
  5360. };
  5361. const onPressed = (srcType) => (event) => {
  5362. var _options$onPressed;
  5363. pressed.value = true;
  5364. sourceType.value = srcType;
  5365. (_options$onPressed = options.onPressed) === null || _options$onPressed === void 0 || _options$onPressed.call(options, event);
  5366. };
  5367. const onReleased = (event) => {
  5368. var _options$onReleased;
  5369. pressed.value = false;
  5370. sourceType.value = null;
  5371. (_options$onReleased = options.onReleased) === null || _options$onReleased === void 0 || _options$onReleased.call(options, event);
  5372. };
  5373. const target = (0, vue.computed)(() => unrefElement(options.target) || window);
  5374. const listenerOptions = {
  5375. passive: true,
  5376. capture
  5377. };
  5378. useEventListener(target, "mousedown", onPressed("mouse"), listenerOptions);
  5379. useEventListener(window, "mouseleave", onReleased, listenerOptions);
  5380. useEventListener(window, "mouseup", onReleased, listenerOptions);
  5381. if (drag) {
  5382. useEventListener(target, "dragstart", onPressed("mouse"), listenerOptions);
  5383. useEventListener(window, "drop", onReleased, listenerOptions);
  5384. useEventListener(window, "dragend", onReleased, listenerOptions);
  5385. }
  5386. if (touch) {
  5387. useEventListener(target, "touchstart", onPressed("touch"), listenerOptions);
  5388. useEventListener(window, "touchend", onReleased, listenerOptions);
  5389. useEventListener(window, "touchcancel", onReleased, listenerOptions);
  5390. }
  5391. return {
  5392. pressed,
  5393. sourceType
  5394. };
  5395. }
  5396. //#endregion
  5397. //#region useNavigatorLanguage/index.ts
  5398. /**
  5399. *
  5400. * Reactive useNavigatorLanguage
  5401. *
  5402. * Detects the currently selected user language and returns a reactive language
  5403. * @see https://vueuse.org/useNavigatorLanguage
  5404. *
  5405. * @__NO_SIDE_EFFECTS__
  5406. */
  5407. function useNavigatorLanguage(options = {}) {
  5408. const { window = defaultWindow } = options;
  5409. const navigator = window === null || window === void 0 ? void 0 : window.navigator;
  5410. const isSupported = /* @__PURE__ */ useSupported(() => navigator && "language" in navigator);
  5411. const language = (0, vue.shallowRef)(navigator === null || navigator === void 0 ? void 0 : navigator.language);
  5412. useEventListener(window, "languagechange", () => {
  5413. if (navigator) language.value = navigator.language;
  5414. }, { passive: true });
  5415. return {
  5416. isSupported,
  5417. language
  5418. };
  5419. }
  5420. //#endregion
  5421. //#region useNetwork/index.ts
  5422. /**
  5423. * Reactive Network status.
  5424. *
  5425. * @see https://vueuse.org/useNetwork
  5426. * @param options
  5427. *
  5428. * @__NO_SIDE_EFFECTS__
  5429. */
  5430. function useNetwork(options = {}) {
  5431. const { window = defaultWindow } = options;
  5432. const navigator = window === null || window === void 0 ? void 0 : window.navigator;
  5433. const isSupported = /* @__PURE__ */ useSupported(() => navigator && "connection" in navigator);
  5434. const isOnline = (0, vue.shallowRef)(true);
  5435. const saveData = (0, vue.shallowRef)(false);
  5436. const offlineAt = (0, vue.shallowRef)(void 0);
  5437. const onlineAt = (0, vue.shallowRef)(void 0);
  5438. const downlink = (0, vue.shallowRef)(void 0);
  5439. const downlinkMax = (0, vue.shallowRef)(void 0);
  5440. const rtt = (0, vue.shallowRef)(void 0);
  5441. const effectiveType = (0, vue.shallowRef)(void 0);
  5442. const type = (0, vue.shallowRef)("unknown");
  5443. const connection = isSupported.value && navigator.connection;
  5444. function updateNetworkInformation() {
  5445. if (!navigator) return;
  5446. isOnline.value = navigator.onLine;
  5447. offlineAt.value = isOnline.value ? void 0 : Date.now();
  5448. onlineAt.value = isOnline.value ? Date.now() : void 0;
  5449. if (connection) {
  5450. downlink.value = connection.downlink;
  5451. downlinkMax.value = connection.downlinkMax;
  5452. effectiveType.value = connection.effectiveType;
  5453. rtt.value = connection.rtt;
  5454. saveData.value = connection.saveData;
  5455. type.value = connection.type;
  5456. }
  5457. }
  5458. const listenerOptions = { passive: true };
  5459. if (window) {
  5460. useEventListener(window, "offline", () => {
  5461. isOnline.value = false;
  5462. offlineAt.value = Date.now();
  5463. }, listenerOptions);
  5464. useEventListener(window, "online", () => {
  5465. isOnline.value = true;
  5466. onlineAt.value = Date.now();
  5467. }, listenerOptions);
  5468. }
  5469. if (connection) useEventListener(connection, "change", updateNetworkInformation, listenerOptions);
  5470. updateNetworkInformation();
  5471. return {
  5472. isSupported,
  5473. isOnline: (0, vue.shallowReadonly)(isOnline),
  5474. saveData: (0, vue.shallowReadonly)(saveData),
  5475. offlineAt: (0, vue.shallowReadonly)(offlineAt),
  5476. onlineAt: (0, vue.shallowReadonly)(onlineAt),
  5477. downlink: (0, vue.shallowReadonly)(downlink),
  5478. downlinkMax: (0, vue.shallowReadonly)(downlinkMax),
  5479. effectiveType: (0, vue.shallowReadonly)(effectiveType),
  5480. rtt: (0, vue.shallowReadonly)(rtt),
  5481. type: (0, vue.shallowReadonly)(type)
  5482. };
  5483. }
  5484. //#endregion
  5485. //#region useNow/index.ts
  5486. function getDefaultScheduler$5(options) {
  5487. if ("interval" in options || "immediate" in options) {
  5488. const { interval = "requestAnimationFrame", immediate = true } = options;
  5489. return interval === "requestAnimationFrame" ? (fn) => useRafFn(fn, { immediate }) : (fn) => (0, _vueuse_shared.useIntervalFn)(fn, interval, options);
  5490. }
  5491. return useRafFn;
  5492. }
  5493. /**
  5494. * Reactive current Date instance.
  5495. *
  5496. * @see https://vueuse.org/useNow
  5497. * @param options
  5498. *
  5499. * @__NO_SIDE_EFFECTS__
  5500. */
  5501. function useNow(options = {}) {
  5502. const { controls: exposeControls = false, scheduler = getDefaultScheduler$5(options) } = options;
  5503. const now = (0, vue.shallowRef)(/* @__PURE__ */ new Date());
  5504. const update = () => now.value = /* @__PURE__ */ new Date();
  5505. const controls = scheduler(update);
  5506. if (exposeControls) return {
  5507. now,
  5508. ...controls
  5509. };
  5510. else return now;
  5511. }
  5512. //#endregion
  5513. //#region useObjectUrl/index.ts
  5514. /**
  5515. * Reactive URL representing an object.
  5516. *
  5517. * @see https://vueuse.org/useObjectUrl
  5518. * @param object
  5519. */
  5520. function useObjectUrl(object) {
  5521. const url = (0, vue.shallowRef)();
  5522. const release = () => {
  5523. if (url.value) URL.revokeObjectURL(url.value);
  5524. url.value = void 0;
  5525. };
  5526. (0, vue.watch)(() => (0, vue.toValue)(object), (newObject) => {
  5527. release();
  5528. if (newObject) url.value = URL.createObjectURL(newObject);
  5529. }, { immediate: true });
  5530. (0, _vueuse_shared.tryOnScopeDispose)(release);
  5531. return (0, vue.shallowReadonly)(url);
  5532. }
  5533. //#endregion
  5534. //#region ../math/useClamp/index.ts
  5535. /**
  5536. * Reactively clamp a value between two other values.
  5537. *
  5538. * @see https://vueuse.org/useClamp
  5539. * @param value number
  5540. * @param min
  5541. * @param max
  5542. *
  5543. * @__NO_SIDE_EFFECTS__
  5544. */
  5545. function useClamp(value, min, max) {
  5546. if (typeof value === "function" || (0, vue.isReadonly)(value)) return (0, vue.computed)(() => (0, _vueuse_shared.clamp)((0, vue.toValue)(value), (0, vue.toValue)(min), (0, vue.toValue)(max)));
  5547. const _value = (0, vue.ref)(value);
  5548. return (0, vue.computed)({
  5549. get() {
  5550. return _value.value = (0, _vueuse_shared.clamp)(_value.value, (0, vue.toValue)(min), (0, vue.toValue)(max));
  5551. },
  5552. set(value) {
  5553. _value.value = (0, _vueuse_shared.clamp)(value, (0, vue.toValue)(min), (0, vue.toValue)(max));
  5554. }
  5555. });
  5556. }
  5557. //#endregion
  5558. //#region useOffsetPagination/index.ts
  5559. function useOffsetPagination(options) {
  5560. const { total = Number.POSITIVE_INFINITY, pageSize = 10, page = 1, onPageChange = _vueuse_shared.noop, onPageSizeChange = _vueuse_shared.noop, onPageCountChange = _vueuse_shared.noop } = options;
  5561. const currentPageSize = useClamp(pageSize, 1, Number.POSITIVE_INFINITY);
  5562. const pageCount = (0, vue.computed)(() => Math.max(1, Math.ceil((0, vue.toValue)(total) / (0, vue.toValue)(currentPageSize))));
  5563. const currentPage = useClamp(page, 1, pageCount);
  5564. const isFirstPage = (0, vue.computed)(() => currentPage.value === 1);
  5565. const isLastPage = (0, vue.computed)(() => currentPage.value === pageCount.value);
  5566. if ((0, vue.isRef)(page)) (0, _vueuse_shared.syncRef)(page, currentPage, { direction: (0, vue.isReadonly)(page) ? "ltr" : "both" });
  5567. if ((0, vue.isRef)(pageSize)) (0, _vueuse_shared.syncRef)(pageSize, currentPageSize, { direction: (0, vue.isReadonly)(pageSize) ? "ltr" : "both" });
  5568. function prev() {
  5569. currentPage.value--;
  5570. }
  5571. function next() {
  5572. currentPage.value++;
  5573. }
  5574. const returnValue = {
  5575. currentPage,
  5576. currentPageSize,
  5577. pageCount,
  5578. isFirstPage,
  5579. isLastPage,
  5580. prev,
  5581. next
  5582. };
  5583. (0, vue.watch)(currentPage, () => {
  5584. onPageChange((0, vue.reactive)(returnValue));
  5585. });
  5586. (0, vue.watch)(currentPageSize, () => {
  5587. onPageSizeChange((0, vue.reactive)(returnValue));
  5588. });
  5589. (0, vue.watch)(pageCount, () => {
  5590. onPageCountChange((0, vue.reactive)(returnValue));
  5591. });
  5592. return returnValue;
  5593. }
  5594. //#endregion
  5595. //#region useOnline/index.ts
  5596. /**
  5597. * Reactive online state.
  5598. *
  5599. * @see https://vueuse.org/useOnline
  5600. * @param options
  5601. *
  5602. * @__NO_SIDE_EFFECTS__
  5603. */
  5604. function useOnline(options = {}) {
  5605. const { isOnline } = useNetwork(options);
  5606. return isOnline;
  5607. }
  5608. //#endregion
  5609. //#region usePageLeave/index.ts
  5610. /**
  5611. * Reactive state to show whether mouse leaves the page.
  5612. *
  5613. * @see https://vueuse.org/usePageLeave
  5614. * @param options
  5615. *
  5616. * @__NO_SIDE_EFFECTS__
  5617. */
  5618. function usePageLeave(options = {}) {
  5619. const { window = defaultWindow } = options;
  5620. const isLeft = (0, vue.shallowRef)(false);
  5621. const handler = (event) => {
  5622. if (!window) return;
  5623. event = event || window.event;
  5624. isLeft.value = !(event.relatedTarget || event.toElement);
  5625. };
  5626. if (window) {
  5627. const listenerOptions = { passive: true };
  5628. useEventListener(window, "mouseout", handler, listenerOptions);
  5629. useEventListener(window.document, "mouseleave", handler, listenerOptions);
  5630. useEventListener(window.document, "mouseenter", handler, listenerOptions);
  5631. }
  5632. return isLeft;
  5633. }
  5634. //#endregion
  5635. //#region useScreenOrientation/index.ts
  5636. /**
  5637. * Reactive screen orientation
  5638. *
  5639. * @see https://vueuse.org/useScreenOrientation
  5640. *
  5641. * @__NO_SIDE_EFFECTS__
  5642. */
  5643. function useScreenOrientation(options = {}) {
  5644. const { window = defaultWindow } = options;
  5645. const isSupported = /* @__PURE__ */ useSupported(() => window && "screen" in window && "orientation" in window.screen);
  5646. const screenOrientation = isSupported.value ? window.screen.orientation : {};
  5647. const orientation = (0, vue.shallowRef)(screenOrientation.type);
  5648. const angle = (0, vue.shallowRef)(screenOrientation.angle || 0);
  5649. if (isSupported.value) useEventListener(window, "orientationchange", () => {
  5650. orientation.value = screenOrientation.type;
  5651. angle.value = screenOrientation.angle;
  5652. }, { passive: true });
  5653. const lockOrientation = (type) => {
  5654. if (isSupported.value && typeof screenOrientation.lock === "function") return screenOrientation.lock(type);
  5655. return Promise.reject(/* @__PURE__ */ new Error("Not supported"));
  5656. };
  5657. const unlockOrientation = () => {
  5658. if (isSupported.value && typeof screenOrientation.unlock === "function") screenOrientation.unlock();
  5659. };
  5660. return {
  5661. isSupported,
  5662. orientation,
  5663. angle,
  5664. lockOrientation,
  5665. unlockOrientation
  5666. };
  5667. }
  5668. //#endregion
  5669. //#region useParallax/index.ts
  5670. /**
  5671. * Create parallax effect easily. It uses `useDeviceOrientation` and fallback to `useMouse`
  5672. * if orientation is not supported.
  5673. *
  5674. * @param target
  5675. * @param options
  5676. */
  5677. function useParallax(target, options = {}) {
  5678. const { deviceOrientationTiltAdjust = (i) => i, deviceOrientationRollAdjust = (i) => i, mouseTiltAdjust = (i) => i, mouseRollAdjust = (i) => i, window = defaultWindow } = options;
  5679. const orientation = (0, vue.reactive)(useDeviceOrientation({ window }));
  5680. const screenOrientation = (0, vue.reactive)(useScreenOrientation({ window }));
  5681. const { elementX: x, elementY: y, elementWidth: width, elementHeight: height } = useMouseInElement(target, {
  5682. handleOutside: false,
  5683. window
  5684. });
  5685. const source = (0, vue.computed)(() => {
  5686. if (orientation.isSupported && (orientation.alpha != null && orientation.alpha !== 0 || orientation.gamma != null && orientation.gamma !== 0)) return "deviceOrientation";
  5687. return "mouse";
  5688. });
  5689. return {
  5690. roll: (0, vue.computed)(() => {
  5691. if (source.value === "deviceOrientation") {
  5692. let value;
  5693. switch (screenOrientation.orientation) {
  5694. case "landscape-primary":
  5695. value = orientation.gamma / 90;
  5696. break;
  5697. case "landscape-secondary":
  5698. value = -orientation.gamma / 90;
  5699. break;
  5700. case "portrait-primary":
  5701. value = -orientation.beta / 90;
  5702. break;
  5703. case "portrait-secondary":
  5704. value = orientation.beta / 90;
  5705. break;
  5706. default: value = -orientation.beta / 90;
  5707. }
  5708. return deviceOrientationRollAdjust(value);
  5709. } else return mouseRollAdjust(-(y.value - height.value / 2) / height.value);
  5710. }),
  5711. tilt: (0, vue.computed)(() => {
  5712. if (source.value === "deviceOrientation") {
  5713. let value;
  5714. switch (screenOrientation.orientation) {
  5715. case "landscape-primary":
  5716. value = orientation.beta / 90;
  5717. break;
  5718. case "landscape-secondary":
  5719. value = -orientation.beta / 90;
  5720. break;
  5721. case "portrait-primary":
  5722. value = orientation.gamma / 90;
  5723. break;
  5724. case "portrait-secondary":
  5725. value = -orientation.gamma / 90;
  5726. break;
  5727. default: value = orientation.gamma / 90;
  5728. }
  5729. return deviceOrientationTiltAdjust(value);
  5730. } else return mouseTiltAdjust((x.value - width.value / 2) / width.value);
  5731. }),
  5732. source
  5733. };
  5734. }
  5735. //#endregion
  5736. //#region useParentElement/index.ts
  5737. function useParentElement(element = useCurrentElement()) {
  5738. const parentElement = (0, vue.shallowRef)();
  5739. const update = () => {
  5740. const el = unrefElement(element);
  5741. if (el) parentElement.value = el.parentElement;
  5742. };
  5743. (0, _vueuse_shared.tryOnMounted)(update);
  5744. (0, vue.watch)(() => (0, vue.toValue)(element), update);
  5745. return parentElement;
  5746. }
  5747. //#endregion
  5748. //#region usePerformanceObserver/index.ts
  5749. /**
  5750. * Observe performance metrics.
  5751. *
  5752. * @see https://vueuse.org/usePerformanceObserver
  5753. * @param options
  5754. */
  5755. function usePerformanceObserver(options, callback) {
  5756. const { window = defaultWindow, immediate = true, ...performanceOptions } = options;
  5757. const isSupported = /* @__PURE__ */ useSupported(() => window && "PerformanceObserver" in window);
  5758. let observer;
  5759. const stop = () => {
  5760. observer === null || observer === void 0 || observer.disconnect();
  5761. };
  5762. const start = () => {
  5763. if (isSupported.value) {
  5764. stop();
  5765. observer = new PerformanceObserver(callback);
  5766. observer.observe(performanceOptions);
  5767. }
  5768. };
  5769. (0, _vueuse_shared.tryOnScopeDispose)(stop);
  5770. if (immediate) start();
  5771. return {
  5772. isSupported,
  5773. start,
  5774. stop
  5775. };
  5776. }
  5777. //#endregion
  5778. //#region usePointer/index.ts
  5779. const defaultState = ( /* #__PURE__ */ {
  5780. x: 0,
  5781. y: 0,
  5782. pointerId: 0,
  5783. pressure: 0,
  5784. tiltX: 0,
  5785. tiltY: 0,
  5786. width: 0,
  5787. height: 0,
  5788. twist: 0,
  5789. pointerType: null
  5790. });
  5791. const keys = /* @__PURE__ */ Object.keys(defaultState);
  5792. /**
  5793. * Reactive pointer state.
  5794. *
  5795. * @see https://vueuse.org/usePointer
  5796. * @param options
  5797. */
  5798. function usePointer(options = {}) {
  5799. const { target = defaultWindow } = options;
  5800. const isInside = (0, vue.shallowRef)(false);
  5801. const state = (0, vue.shallowRef)(options.initialValue || {});
  5802. Object.assign(state.value, defaultState, state.value);
  5803. const handler = (event) => {
  5804. isInside.value = true;
  5805. if (options.pointerTypes && !options.pointerTypes.includes(event.pointerType)) return;
  5806. state.value = (0, _vueuse_shared.objectPick)(event, keys, false);
  5807. };
  5808. if (target) {
  5809. const listenerOptions = { passive: true };
  5810. useEventListener(target, [
  5811. "pointerdown",
  5812. "pointermove",
  5813. "pointerup"
  5814. ], handler, listenerOptions);
  5815. useEventListener(target, "pointerleave", () => isInside.value = false, listenerOptions);
  5816. }
  5817. return {
  5818. ...(0, _vueuse_shared.toRefs)(state),
  5819. isInside
  5820. };
  5821. }
  5822. //#endregion
  5823. //#region usePointerLock/index.ts
  5824. /**
  5825. * Reactive pointer lock.
  5826. *
  5827. * @see https://vueuse.org/usePointerLock
  5828. * @param target
  5829. * @param options
  5830. *
  5831. * @__NO_SIDE_EFFECTS__
  5832. */
  5833. function usePointerLock(target, options = {}) {
  5834. const { document = defaultDocument } = options;
  5835. const isSupported = /* @__PURE__ */ useSupported(() => document && "pointerLockElement" in document);
  5836. const element = (0, vue.shallowRef)();
  5837. const triggerElement = (0, vue.shallowRef)();
  5838. let targetElement;
  5839. if (isSupported.value) {
  5840. const listenerOptions = { passive: true };
  5841. useEventListener(document, "pointerlockchange", () => {
  5842. var _pointerLockElement;
  5843. const currentElement = (_pointerLockElement = document.pointerLockElement) !== null && _pointerLockElement !== void 0 ? _pointerLockElement : element.value;
  5844. if (targetElement && currentElement === targetElement) {
  5845. element.value = document.pointerLockElement;
  5846. if (!element.value) targetElement = triggerElement.value = null;
  5847. }
  5848. }, listenerOptions);
  5849. useEventListener(document, "pointerlockerror", () => {
  5850. var _pointerLockElement2;
  5851. const currentElement = (_pointerLockElement2 = document.pointerLockElement) !== null && _pointerLockElement2 !== void 0 ? _pointerLockElement2 : element.value;
  5852. if (targetElement && currentElement === targetElement) {
  5853. const action = document.pointerLockElement ? "release" : "acquire";
  5854. throw new Error(`Failed to ${action} pointer lock.`);
  5855. }
  5856. }, listenerOptions);
  5857. }
  5858. async function lock(e) {
  5859. var _unrefElement;
  5860. if (!isSupported.value) throw new Error("Pointer Lock API is not supported by your browser.");
  5861. triggerElement.value = e instanceof Event ? e.currentTarget : null;
  5862. targetElement = e instanceof Event ? (_unrefElement = unrefElement(target)) !== null && _unrefElement !== void 0 ? _unrefElement : triggerElement.value : unrefElement(e);
  5863. if (!targetElement) throw new Error("Target element undefined.");
  5864. targetElement.requestPointerLock();
  5865. return await (0, _vueuse_shared.until)(element).toBe(targetElement);
  5866. }
  5867. async function unlock() {
  5868. if (!element.value) return false;
  5869. document.exitPointerLock();
  5870. await (0, _vueuse_shared.until)(element).toBeNull();
  5871. return true;
  5872. }
  5873. return {
  5874. isSupported,
  5875. element,
  5876. triggerElement,
  5877. lock,
  5878. unlock
  5879. };
  5880. }
  5881. //#endregion
  5882. //#region usePointerSwipe/index.ts
  5883. /**
  5884. * Reactive swipe detection based on PointerEvents.
  5885. *
  5886. * @see https://vueuse.org/usePointerSwipe
  5887. * @param target
  5888. * @param options
  5889. */
  5890. function usePointerSwipe(target, options = {}) {
  5891. const targetRef = (0, _vueuse_shared.toRef)(target);
  5892. const { threshold = 50, onSwipe, onSwipeEnd, onSwipeStart, disableTextSelect = false } = options;
  5893. const posStart = (0, vue.reactive)({
  5894. x: 0,
  5895. y: 0
  5896. });
  5897. const updatePosStart = (x, y) => {
  5898. posStart.x = x;
  5899. posStart.y = y;
  5900. };
  5901. const posEnd = (0, vue.reactive)({
  5902. x: 0,
  5903. y: 0
  5904. });
  5905. const updatePosEnd = (x, y) => {
  5906. posEnd.x = x;
  5907. posEnd.y = y;
  5908. };
  5909. const distanceX = (0, vue.computed)(() => posStart.x - posEnd.x);
  5910. const distanceY = (0, vue.computed)(() => posStart.y - posEnd.y);
  5911. const { max, abs } = Math;
  5912. const isThresholdExceeded = (0, vue.computed)(() => max(abs(distanceX.value), abs(distanceY.value)) >= threshold);
  5913. const isSwiping = (0, vue.shallowRef)(false);
  5914. const isPointerDown = (0, vue.shallowRef)(false);
  5915. const direction = (0, vue.computed)(() => {
  5916. if (!isThresholdExceeded.value) return "none";
  5917. if (abs(distanceX.value) > abs(distanceY.value)) return distanceX.value > 0 ? "left" : "right";
  5918. else return distanceY.value > 0 ? "up" : "down";
  5919. });
  5920. const eventIsAllowed = (e) => {
  5921. var _ref, _options$pointerTypes, _options$pointerTypes2;
  5922. const isReleasingButton = e.buttons === 0;
  5923. const isPrimaryButton = e.buttons === 1;
  5924. return (_ref = (_options$pointerTypes = (_options$pointerTypes2 = options.pointerTypes) === null || _options$pointerTypes2 === void 0 ? void 0 : _options$pointerTypes2.includes(e.pointerType)) !== null && _options$pointerTypes !== void 0 ? _options$pointerTypes : isReleasingButton || isPrimaryButton) !== null && _ref !== void 0 ? _ref : true;
  5925. };
  5926. const listenerOptions = { passive: true };
  5927. const stops = [
  5928. useEventListener(target, "pointerdown", (e) => {
  5929. if (!eventIsAllowed(e)) return;
  5930. isPointerDown.value = true;
  5931. const eventTarget = e.target;
  5932. eventTarget === null || eventTarget === void 0 || eventTarget.setPointerCapture(e.pointerId);
  5933. const { clientX: x, clientY: y } = e;
  5934. updatePosStart(x, y);
  5935. updatePosEnd(x, y);
  5936. onSwipeStart === null || onSwipeStart === void 0 || onSwipeStart(e);
  5937. }, listenerOptions),
  5938. useEventListener(target, "pointermove", (e) => {
  5939. if (!eventIsAllowed(e)) return;
  5940. if (!isPointerDown.value) return;
  5941. const { clientX: x, clientY: y } = e;
  5942. updatePosEnd(x, y);
  5943. if (!isSwiping.value && isThresholdExceeded.value) isSwiping.value = true;
  5944. if (isSwiping.value) onSwipe === null || onSwipe === void 0 || onSwipe(e);
  5945. }, listenerOptions),
  5946. useEventListener(target, "pointerup", (e) => {
  5947. if (!eventIsAllowed(e)) return;
  5948. if (isSwiping.value) onSwipeEnd === null || onSwipeEnd === void 0 || onSwipeEnd(e, direction.value);
  5949. isPointerDown.value = false;
  5950. isSwiping.value = false;
  5951. }, listenerOptions)
  5952. ];
  5953. (0, _vueuse_shared.tryOnMounted)(() => {
  5954. var _targetRef$value;
  5955. (_targetRef$value = targetRef.value) === null || _targetRef$value === void 0 || (_targetRef$value = _targetRef$value.style) === null || _targetRef$value === void 0 || _targetRef$value.setProperty("touch-action", "pan-y");
  5956. if (disableTextSelect) {
  5957. var _targetRef$value2, _targetRef$value3, _targetRef$value4;
  5958. (_targetRef$value2 = targetRef.value) === null || _targetRef$value2 === void 0 || (_targetRef$value2 = _targetRef$value2.style) === null || _targetRef$value2 === void 0 || _targetRef$value2.setProperty("-webkit-user-select", "none");
  5959. (_targetRef$value3 = targetRef.value) === null || _targetRef$value3 === void 0 || (_targetRef$value3 = _targetRef$value3.style) === null || _targetRef$value3 === void 0 || _targetRef$value3.setProperty("-ms-user-select", "none");
  5960. (_targetRef$value4 = targetRef.value) === null || _targetRef$value4 === void 0 || (_targetRef$value4 = _targetRef$value4.style) === null || _targetRef$value4 === void 0 || _targetRef$value4.setProperty("user-select", "none");
  5961. }
  5962. });
  5963. const stop = () => stops.forEach((s) => s());
  5964. return {
  5965. isSwiping: (0, vue.shallowReadonly)(isSwiping),
  5966. direction: (0, vue.shallowReadonly)(direction),
  5967. posStart: (0, vue.readonly)(posStart),
  5968. posEnd: (0, vue.readonly)(posEnd),
  5969. distanceX,
  5970. distanceY,
  5971. stop
  5972. };
  5973. }
  5974. //#endregion
  5975. //#region usePreferredColorScheme/index.ts
  5976. /**
  5977. * Reactive prefers-color-scheme media query.
  5978. *
  5979. * @see https://vueuse.org/usePreferredColorScheme
  5980. * @param [options]
  5981. *
  5982. * @__NO_SIDE_EFFECTS__
  5983. */
  5984. function usePreferredColorScheme(options) {
  5985. const isLight = useMediaQuery("(prefers-color-scheme: light)", options);
  5986. const isDark = useMediaQuery("(prefers-color-scheme: dark)", options);
  5987. return (0, vue.computed)(() => {
  5988. if (isDark.value) return "dark";
  5989. if (isLight.value) return "light";
  5990. return "no-preference";
  5991. });
  5992. }
  5993. //#endregion
  5994. //#region usePreferredContrast/index.ts
  5995. /**
  5996. * Reactive prefers-contrast media query.
  5997. *
  5998. * @see https://vueuse.org/usePreferredContrast
  5999. * @param [options]
  6000. *
  6001. * @__NO_SIDE_EFFECTS__
  6002. */
  6003. function usePreferredContrast(options) {
  6004. const isMore = useMediaQuery("(prefers-contrast: more)", options);
  6005. const isLess = useMediaQuery("(prefers-contrast: less)", options);
  6006. const isCustom = useMediaQuery("(prefers-contrast: custom)", options);
  6007. return (0, vue.computed)(() => {
  6008. if (isMore.value) return "more";
  6009. if (isLess.value) return "less";
  6010. if (isCustom.value) return "custom";
  6011. return "no-preference";
  6012. });
  6013. }
  6014. //#endregion
  6015. //#region usePreferredLanguages/index.ts
  6016. /**
  6017. * Reactive Navigator Languages.
  6018. *
  6019. * @see https://vueuse.org/usePreferredLanguages
  6020. * @param options
  6021. *
  6022. * @__NO_SIDE_EFFECTS__
  6023. */
  6024. function usePreferredLanguages(options = {}) {
  6025. const { window = defaultWindow } = options;
  6026. if (!window) return (0, vue.shallowRef)(["en"]);
  6027. const navigator = window.navigator;
  6028. const value = (0, vue.shallowRef)(navigator.languages);
  6029. useEventListener(window, "languagechange", () => {
  6030. value.value = navigator.languages;
  6031. }, { passive: true });
  6032. return value;
  6033. }
  6034. //#endregion
  6035. //#region usePreferredReducedMotion/index.ts
  6036. /**
  6037. * Reactive prefers-reduced-motion media query.
  6038. *
  6039. * @see https://vueuse.org/usePreferredReducedMotion
  6040. * @param [options]
  6041. *
  6042. * @__NO_SIDE_EFFECTS__
  6043. */
  6044. function usePreferredReducedMotion(options) {
  6045. const isReduced = useMediaQuery("(prefers-reduced-motion: reduce)", options);
  6046. return (0, vue.computed)(() => {
  6047. if (isReduced.value) return "reduce";
  6048. return "no-preference";
  6049. });
  6050. }
  6051. //#endregion
  6052. //#region usePreferredReducedTransparency/index.ts
  6053. /**
  6054. * Reactive prefers-reduced-transparency media query.
  6055. *
  6056. * @see https://vueuse.org/usePreferredReducedTransparency
  6057. * @param [options]
  6058. *
  6059. * @__NO_SIDE_EFFECTS__
  6060. */
  6061. function usePreferredReducedTransparency(options) {
  6062. const isReduced = useMediaQuery("(prefers-reduced-transparency: reduce)", options);
  6063. return (0, vue.computed)(() => {
  6064. if (isReduced.value) return "reduce";
  6065. return "no-preference";
  6066. });
  6067. }
  6068. //#endregion
  6069. //#region usePrevious/index.ts
  6070. function usePrevious(value, initialValue) {
  6071. const previous = (0, vue.shallowRef)(initialValue);
  6072. (0, vue.watch)((0, _vueuse_shared.toRef)(value), (_, oldValue) => {
  6073. previous.value = oldValue;
  6074. }, { flush: "sync" });
  6075. return (0, vue.readonly)(previous);
  6076. }
  6077. //#endregion
  6078. //#region useScreenSafeArea/index.ts
  6079. const topVarName = "--vueuse-safe-area-top";
  6080. const rightVarName = "--vueuse-safe-area-right";
  6081. const bottomVarName = "--vueuse-safe-area-bottom";
  6082. const leftVarName = "--vueuse-safe-area-left";
  6083. /**
  6084. * Reactive `env(safe-area-inset-*)`
  6085. *
  6086. * @see https://vueuse.org/useScreenSafeArea
  6087. */
  6088. function useScreenSafeArea() {
  6089. const top = (0, vue.shallowRef)("");
  6090. const right = (0, vue.shallowRef)("");
  6091. const bottom = (0, vue.shallowRef)("");
  6092. const left = (0, vue.shallowRef)("");
  6093. if (_vueuse_shared.isClient) {
  6094. const topCssVar = useCssVar(topVarName);
  6095. const rightCssVar = useCssVar(rightVarName);
  6096. const bottomCssVar = useCssVar(bottomVarName);
  6097. const leftCssVar = useCssVar(leftVarName);
  6098. topCssVar.value = "env(safe-area-inset-top, 0px)";
  6099. rightCssVar.value = "env(safe-area-inset-right, 0px)";
  6100. bottomCssVar.value = "env(safe-area-inset-bottom, 0px)";
  6101. leftCssVar.value = "env(safe-area-inset-left, 0px)";
  6102. (0, _vueuse_shared.tryOnMounted)(update);
  6103. useEventListener("resize", (0, _vueuse_shared.useDebounceFn)(update), { passive: true });
  6104. }
  6105. function update() {
  6106. top.value = getValue(topVarName);
  6107. right.value = getValue(rightVarName);
  6108. bottom.value = getValue(bottomVarName);
  6109. left.value = getValue(leftVarName);
  6110. }
  6111. return {
  6112. top,
  6113. right,
  6114. bottom,
  6115. left,
  6116. update
  6117. };
  6118. }
  6119. function getValue(position) {
  6120. return getComputedStyle(document.documentElement).getPropertyValue(position);
  6121. }
  6122. //#endregion
  6123. //#region useScriptTag/index.ts
  6124. /**
  6125. * Async script tag loading.
  6126. *
  6127. * @see https://vueuse.org/useScriptTag
  6128. * @param src
  6129. * @param onLoaded
  6130. * @param options
  6131. */
  6132. function useScriptTag(src, onLoaded = _vueuse_shared.noop, options = {}) {
  6133. const { immediate = true, manual = false, type = "text/javascript", async = true, crossOrigin, referrerPolicy, noModule, defer, document = defaultDocument, attrs = {}, nonce = void 0 } = options;
  6134. const scriptTag = (0, vue.shallowRef)(null);
  6135. let _promise = null;
  6136. /**
  6137. * Load the script specified via `src`.
  6138. *
  6139. * @param waitForScriptLoad Whether if the Promise should resolve once the "load" event is emitted by the <script> attribute, or right after appending it to the DOM.
  6140. * @returns Promise<HTMLScriptElement>
  6141. */
  6142. const loadScript = (waitForScriptLoad) => new Promise((resolve, reject) => {
  6143. const resolveWithElement = (el) => {
  6144. scriptTag.value = el;
  6145. resolve(el);
  6146. return el;
  6147. };
  6148. if (!document) {
  6149. resolve(false);
  6150. return;
  6151. }
  6152. let shouldAppend = false;
  6153. let el = document.querySelector(`script[src="${(0, vue.toValue)(src)}"]`);
  6154. if (!el) {
  6155. el = document.createElement("script");
  6156. el.type = type;
  6157. el.async = async;
  6158. el.src = (0, vue.toValue)(src);
  6159. if (defer) el.defer = defer;
  6160. if (crossOrigin) el.crossOrigin = crossOrigin;
  6161. if (noModule) el.noModule = noModule;
  6162. if (referrerPolicy) el.referrerPolicy = referrerPolicy;
  6163. if (nonce) el.nonce = nonce;
  6164. Object.entries(attrs).forEach(([name, value]) => el === null || el === void 0 ? void 0 : el.setAttribute(name, value));
  6165. shouldAppend = true;
  6166. } else if (el.hasAttribute("data-loaded")) resolveWithElement(el);
  6167. const listenerOptions = { passive: true };
  6168. useEventListener(el, "error", (event) => reject(event), listenerOptions);
  6169. useEventListener(el, "abort", (event) => reject(event), listenerOptions);
  6170. useEventListener(el, "load", () => {
  6171. el.setAttribute("data-loaded", "true");
  6172. onLoaded(el);
  6173. resolveWithElement(el);
  6174. }, listenerOptions);
  6175. if (shouldAppend) el = document.head.appendChild(el);
  6176. if (!waitForScriptLoad) resolveWithElement(el);
  6177. });
  6178. /**
  6179. * Exposed singleton wrapper for `loadScript`, avoiding calling it twice.
  6180. *
  6181. * @param waitForScriptLoad Whether if the Promise should resolve once the "load" event is emitted by the <script> attribute, or right after appending it to the DOM.
  6182. * @returns Promise<HTMLScriptElement>
  6183. */
  6184. const load = (waitForScriptLoad = true) => {
  6185. if (!_promise) _promise = loadScript(waitForScriptLoad);
  6186. return _promise;
  6187. };
  6188. /**
  6189. * Unload the script specified by `src`.
  6190. */
  6191. const unload = () => {
  6192. if (!document) return;
  6193. _promise = null;
  6194. if (scriptTag.value) scriptTag.value = null;
  6195. const el = document.querySelector(`script[src="${(0, vue.toValue)(src)}"]`);
  6196. if (el) document.head.removeChild(el);
  6197. };
  6198. if (immediate && !manual) (0, _vueuse_shared.tryOnMounted)(load);
  6199. if (!manual) (0, _vueuse_shared.tryOnUnmounted)(unload);
  6200. return {
  6201. scriptTag,
  6202. load,
  6203. unload
  6204. };
  6205. }
  6206. //#endregion
  6207. //#region useScrollLock/index.ts
  6208. function checkOverflowScroll(ele) {
  6209. const style = window.getComputedStyle(ele);
  6210. if (style.overflowX === "scroll" || style.overflowY === "scroll" || style.overflowX === "auto" && ele.clientWidth < ele.scrollWidth || style.overflowY === "auto" && ele.clientHeight < ele.scrollHeight) return true;
  6211. else {
  6212. const parent = ele.parentNode;
  6213. if (!parent || parent.tagName === "BODY") return false;
  6214. return checkOverflowScroll(parent);
  6215. }
  6216. }
  6217. function preventDefault(rawEvent) {
  6218. const e = rawEvent || window.event;
  6219. const _target = e.target;
  6220. if (checkOverflowScroll(_target)) return false;
  6221. if (e.touches.length > 1) return true;
  6222. if (e.preventDefault) e.preventDefault();
  6223. return false;
  6224. }
  6225. const elInitialOverflow = /* @__PURE__ */ new WeakMap();
  6226. /**
  6227. * Lock scrolling of the element.
  6228. *
  6229. * @see https://vueuse.org/useScrollLock
  6230. * @param element
  6231. */
  6232. function useScrollLock(element, initialState = false) {
  6233. const isLocked = (0, vue.shallowRef)(initialState);
  6234. let stopTouchMoveListener = null;
  6235. let initialOverflow = "";
  6236. (0, vue.watch)((0, _vueuse_shared.toRef)(element), (el) => {
  6237. const target = resolveElement((0, vue.toValue)(el));
  6238. if (target) {
  6239. const ele = target;
  6240. if (!elInitialOverflow.get(ele)) elInitialOverflow.set(ele, ele.style.overflow);
  6241. if (ele.style.overflow !== "hidden") initialOverflow = ele.style.overflow;
  6242. if (ele.style.overflow === "hidden") return isLocked.value = true;
  6243. if (isLocked.value) return ele.style.overflow = "hidden";
  6244. }
  6245. }, { immediate: true });
  6246. const lock = () => {
  6247. const el = resolveElement((0, vue.toValue)(element));
  6248. if (!el || isLocked.value) return;
  6249. if (_vueuse_shared.isIOS) stopTouchMoveListener = useEventListener(el, "touchmove", (e) => {
  6250. preventDefault(e);
  6251. }, { passive: false });
  6252. el.style.overflow = "hidden";
  6253. isLocked.value = true;
  6254. };
  6255. const unlock = () => {
  6256. const el = resolveElement((0, vue.toValue)(element));
  6257. if (!el || !isLocked.value) return;
  6258. if (_vueuse_shared.isIOS) stopTouchMoveListener === null || stopTouchMoveListener === void 0 || stopTouchMoveListener();
  6259. el.style.overflow = initialOverflow;
  6260. elInitialOverflow.delete(el);
  6261. isLocked.value = false;
  6262. };
  6263. (0, _vueuse_shared.tryOnScopeDispose)(unlock);
  6264. return (0, vue.computed)({
  6265. get() {
  6266. return isLocked.value;
  6267. },
  6268. set(v) {
  6269. if (v) lock();
  6270. else unlock();
  6271. }
  6272. });
  6273. }
  6274. //#endregion
  6275. //#region useSessionStorage/index.ts
  6276. /**
  6277. * Reactive SessionStorage.
  6278. *
  6279. * @see https://vueuse.org/useSessionStorage
  6280. * @param key
  6281. * @param initialValue
  6282. * @param options
  6283. */
  6284. function useSessionStorage(key, initialValue, options = {}) {
  6285. const { window = defaultWindow } = options;
  6286. return useStorage(key, initialValue, window === null || window === void 0 ? void 0 : window.sessionStorage, options);
  6287. }
  6288. //#endregion
  6289. //#region useShare/index.ts
  6290. /**
  6291. * Reactive Web Share API.
  6292. *
  6293. * @see https://vueuse.org/useShare
  6294. * @param shareOptions
  6295. * @param options
  6296. *
  6297. * @__NO_SIDE_EFFECTS__
  6298. */
  6299. function useShare(shareOptions = {}, options = {}) {
  6300. const { navigator = defaultNavigator } = options;
  6301. const _navigator = navigator;
  6302. const isSupported = /* @__PURE__ */ useSupported(() => _navigator && "canShare" in _navigator);
  6303. const share = async (overrideOptions = {}) => {
  6304. if (isSupported.value) {
  6305. const data = {
  6306. ...(0, vue.toValue)(shareOptions),
  6307. ...(0, vue.toValue)(overrideOptions)
  6308. };
  6309. let granted = false;
  6310. if (_navigator.canShare) granted = _navigator.canShare(data);
  6311. if (granted) return _navigator.share(data);
  6312. }
  6313. };
  6314. return {
  6315. isSupported,
  6316. share
  6317. };
  6318. }
  6319. //#endregion
  6320. //#region useSorted/index.ts
  6321. const defaultSortFn = (source, compareFn) => source.sort(compareFn);
  6322. const defaultCompare = (a, b) => a - b;
  6323. function useSorted(...args) {
  6324. const [source] = args;
  6325. let compareFn = defaultCompare;
  6326. let options = {};
  6327. if (args.length === 2) if (typeof args[1] === "object") {
  6328. var _options$compareFn;
  6329. options = args[1];
  6330. compareFn = (_options$compareFn = options.compareFn) !== null && _options$compareFn !== void 0 ? _options$compareFn : defaultCompare;
  6331. } else {
  6332. var _args$;
  6333. compareFn = (_args$ = args[1]) !== null && _args$ !== void 0 ? _args$ : defaultCompare;
  6334. }
  6335. else if (args.length > 2) {
  6336. var _args$2, _args$3;
  6337. compareFn = (_args$2 = args[1]) !== null && _args$2 !== void 0 ? _args$2 : defaultCompare;
  6338. options = (_args$3 = args[2]) !== null && _args$3 !== void 0 ? _args$3 : {};
  6339. }
  6340. const { dirty = false, sortFn = defaultSortFn } = options;
  6341. if (!dirty) return (0, vue.computed)(() => sortFn([...(0, vue.toValue)(source)], compareFn));
  6342. (0, vue.watchEffect)(() => {
  6343. const result = sortFn((0, vue.toValue)(source), compareFn);
  6344. if ((0, vue.isRef)(source)) source.value = result;
  6345. else source.splice(0, source.length, ...result);
  6346. });
  6347. return source;
  6348. }
  6349. //#endregion
  6350. //#region useSpeechRecognition/index.ts
  6351. /**
  6352. * Reactive SpeechRecognition.
  6353. *
  6354. * @see https://vueuse.org/useSpeechRecognition
  6355. * @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition SpeechRecognition
  6356. * @param options
  6357. */
  6358. function useSpeechRecognition(options = {}) {
  6359. const { interimResults = true, continuous = true, maxAlternatives = 1, window = defaultWindow } = options;
  6360. const lang = (0, _vueuse_shared.toRef)(options.lang || "en-US");
  6361. const isListening = (0, vue.shallowRef)(false);
  6362. const isFinal = (0, vue.shallowRef)(false);
  6363. const result = (0, vue.shallowRef)("");
  6364. const error = (0, vue.shallowRef)(void 0);
  6365. let recognition;
  6366. const start = () => {
  6367. isListening.value = true;
  6368. };
  6369. const stop = () => {
  6370. isListening.value = false;
  6371. };
  6372. const toggle = (value = !isListening.value) => {
  6373. if (value) start();
  6374. else stop();
  6375. };
  6376. const SpeechRecognition = window && (window.SpeechRecognition || window.webkitSpeechRecognition);
  6377. const isSupported = /* @__PURE__ */ useSupported(() => SpeechRecognition);
  6378. if (isSupported.value) {
  6379. recognition = new SpeechRecognition();
  6380. recognition.continuous = continuous;
  6381. recognition.interimResults = interimResults;
  6382. recognition.lang = (0, vue.toValue)(lang);
  6383. recognition.maxAlternatives = maxAlternatives;
  6384. recognition.onstart = () => {
  6385. isListening.value = true;
  6386. isFinal.value = false;
  6387. };
  6388. (0, vue.watch)(lang, (lang) => {
  6389. if (recognition && !isListening.value) recognition.lang = lang;
  6390. });
  6391. recognition.onresult = (event) => {
  6392. const currentResult = event.results[event.resultIndex];
  6393. const { transcript } = currentResult[0];
  6394. isFinal.value = currentResult.isFinal;
  6395. result.value = transcript;
  6396. error.value = void 0;
  6397. };
  6398. recognition.onerror = (event) => {
  6399. error.value = event;
  6400. };
  6401. recognition.onend = () => {
  6402. isListening.value = false;
  6403. recognition.lang = (0, vue.toValue)(lang);
  6404. };
  6405. (0, vue.watch)(isListening, (newValue, oldValue) => {
  6406. if (newValue === oldValue) return;
  6407. try {
  6408. if (newValue) recognition.start();
  6409. else recognition.stop();
  6410. } catch (err) {
  6411. error.value = err;
  6412. }
  6413. });
  6414. }
  6415. (0, _vueuse_shared.tryOnScopeDispose)(() => {
  6416. stop();
  6417. });
  6418. return {
  6419. isSupported,
  6420. isListening,
  6421. isFinal,
  6422. recognition,
  6423. result,
  6424. error,
  6425. toggle,
  6426. start,
  6427. stop
  6428. };
  6429. }
  6430. //#endregion
  6431. //#region useSpeechSynthesis/index.ts
  6432. /**
  6433. * Reactive SpeechSynthesis.
  6434. *
  6435. * @see https://vueuse.org/useSpeechSynthesis
  6436. * @see https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis SpeechSynthesis
  6437. */
  6438. function useSpeechSynthesis(text, options = {}) {
  6439. const { pitch = 1, rate = 1, volume = 1, window = defaultWindow, onBoundary } = options;
  6440. const synth = window && window.speechSynthesis;
  6441. const isSupported = /* @__PURE__ */ useSupported(() => synth);
  6442. const isPlaying = (0, vue.shallowRef)(false);
  6443. const status = (0, vue.shallowRef)("init");
  6444. const spokenText = (0, _vueuse_shared.toRef)(text || "");
  6445. const lang = (0, _vueuse_shared.toRef)(options.lang || "en-US");
  6446. const error = (0, vue.shallowRef)(void 0);
  6447. const toggle = (value = !isPlaying.value) => {
  6448. isPlaying.value = value;
  6449. };
  6450. const bindEventsForUtterance = (utterance) => {
  6451. utterance.lang = (0, vue.toValue)(lang);
  6452. utterance.voice = (0, vue.toValue)(options.voice) || null;
  6453. utterance.pitch = (0, vue.toValue)(pitch);
  6454. utterance.rate = (0, vue.toValue)(rate);
  6455. utterance.volume = (0, vue.toValue)(volume);
  6456. utterance.onstart = () => {
  6457. isPlaying.value = true;
  6458. status.value = "play";
  6459. };
  6460. utterance.onpause = () => {
  6461. isPlaying.value = false;
  6462. status.value = "pause";
  6463. };
  6464. utterance.onresume = () => {
  6465. isPlaying.value = true;
  6466. status.value = "play";
  6467. };
  6468. utterance.onend = () => {
  6469. isPlaying.value = false;
  6470. status.value = "end";
  6471. };
  6472. utterance.onerror = (event) => {
  6473. error.value = event;
  6474. };
  6475. utterance.onboundary = (event) => {
  6476. onBoundary === null || onBoundary === void 0 || onBoundary(event);
  6477. };
  6478. };
  6479. const utterance = (0, vue.computed)(() => {
  6480. isPlaying.value = false;
  6481. status.value = "init";
  6482. const newUtterance = new SpeechSynthesisUtterance(spokenText.value);
  6483. bindEventsForUtterance(newUtterance);
  6484. return newUtterance;
  6485. });
  6486. const speak = () => {
  6487. synth.cancel();
  6488. if (utterance) synth.speak(utterance.value);
  6489. };
  6490. const stop = () => {
  6491. synth.cancel();
  6492. isPlaying.value = false;
  6493. };
  6494. if (isSupported.value) {
  6495. bindEventsForUtterance(utterance.value);
  6496. (0, vue.watch)(lang, (lang) => {
  6497. if (utterance.value && !isPlaying.value) utterance.value.lang = lang;
  6498. });
  6499. if (options.voice) (0, vue.watch)(options.voice, () => {
  6500. synth.cancel();
  6501. });
  6502. (0, vue.watch)(isPlaying, () => {
  6503. if (isPlaying.value) synth.resume();
  6504. else synth.pause();
  6505. });
  6506. }
  6507. (0, _vueuse_shared.tryOnScopeDispose)(() => {
  6508. isPlaying.value = false;
  6509. });
  6510. return {
  6511. isSupported,
  6512. isPlaying,
  6513. status,
  6514. utterance,
  6515. error,
  6516. stop,
  6517. toggle,
  6518. speak
  6519. };
  6520. }
  6521. //#endregion
  6522. //#region useStepper/index.ts
  6523. /* @__NO_SIDE_EFFECTS__ */
  6524. function useStepper(steps, initialStep) {
  6525. const stepsRef = (0, vue.ref)(steps);
  6526. const stepNames = (0, vue.computed)(() => Array.isArray(stepsRef.value) ? stepsRef.value : Object.keys(stepsRef.value));
  6527. const index = (0, vue.ref)(stepNames.value.indexOf(initialStep !== null && initialStep !== void 0 ? initialStep : stepNames.value[0]));
  6528. const current = (0, vue.computed)(() => at(index.value));
  6529. const isFirst = (0, vue.computed)(() => index.value === 0);
  6530. const isLast = (0, vue.computed)(() => index.value === stepNames.value.length - 1);
  6531. const next = (0, vue.computed)(() => stepNames.value[index.value + 1]);
  6532. const previous = (0, vue.computed)(() => stepNames.value[index.value - 1]);
  6533. function at(index) {
  6534. if (Array.isArray(stepsRef.value)) return stepsRef.value[index];
  6535. return stepsRef.value[stepNames.value[index]];
  6536. }
  6537. function get(step) {
  6538. if (!stepNames.value.includes(step)) return;
  6539. return at(stepNames.value.indexOf(step));
  6540. }
  6541. function goTo(step) {
  6542. if (stepNames.value.includes(step)) index.value = stepNames.value.indexOf(step);
  6543. }
  6544. function goToNext() {
  6545. if (isLast.value) return;
  6546. index.value++;
  6547. }
  6548. function goToPrevious() {
  6549. if (isFirst.value) return;
  6550. index.value--;
  6551. }
  6552. function goBackTo(step) {
  6553. if (isAfter(step)) goTo(step);
  6554. }
  6555. function isNext(step) {
  6556. return stepNames.value.indexOf(step) === index.value + 1;
  6557. }
  6558. function isPrevious(step) {
  6559. return stepNames.value.indexOf(step) === index.value - 1;
  6560. }
  6561. function isCurrent(step) {
  6562. return stepNames.value.indexOf(step) === index.value;
  6563. }
  6564. function isBefore(step) {
  6565. return index.value < stepNames.value.indexOf(step);
  6566. }
  6567. function isAfter(step) {
  6568. return index.value > stepNames.value.indexOf(step);
  6569. }
  6570. return {
  6571. steps: stepsRef,
  6572. stepNames,
  6573. index,
  6574. current,
  6575. next,
  6576. previous,
  6577. isFirst,
  6578. isLast,
  6579. at,
  6580. get,
  6581. goTo,
  6582. goToNext,
  6583. goToPrevious,
  6584. goBackTo,
  6585. isNext,
  6586. isPrevious,
  6587. isCurrent,
  6588. isBefore,
  6589. isAfter
  6590. };
  6591. }
  6592. //#endregion
  6593. //#region useStorageAsync/index.ts
  6594. /**
  6595. * Reactive Storage with async support.
  6596. *
  6597. * @see https://vueuse.org/useStorageAsync
  6598. * @param key
  6599. * @param initialValue
  6600. * @param storage
  6601. * @param options
  6602. */
  6603. function useStorageAsync(key, initialValue, storage, options = {}) {
  6604. var _options$serializer;
  6605. const { flush = "pre", deep = true, listenToStorageChanges = true, writeDefaults = true, mergeDefaults = false, shallow, window = defaultWindow, eventFilter, onError = (e) => {
  6606. console.error(e);
  6607. }, onReady } = options;
  6608. const rawInit = (0, vue.toValue)(initialValue);
  6609. const type = guessSerializerType(rawInit);
  6610. const data = (shallow ? vue.shallowRef : vue.ref)((0, vue.toValue)(initialValue));
  6611. const serializer = (_options$serializer = options.serializer) !== null && _options$serializer !== void 0 ? _options$serializer : StorageSerializers[type];
  6612. if (!storage) try {
  6613. storage = getSSRHandler("getDefaultStorageAsync", () => defaultWindow === null || defaultWindow === void 0 ? void 0 : defaultWindow.localStorage)();
  6614. } catch (e) {
  6615. onError(e);
  6616. }
  6617. async function read(event) {
  6618. if (!storage || event && event.key !== key) return;
  6619. try {
  6620. const rawValue = event ? event.newValue : await storage.getItem(key);
  6621. if (rawValue == null) {
  6622. data.value = rawInit;
  6623. if (writeDefaults && rawInit !== null) await storage.setItem(key, await serializer.write(rawInit));
  6624. } else if (mergeDefaults) {
  6625. const value = await serializer.read(rawValue);
  6626. if (typeof mergeDefaults === "function") data.value = mergeDefaults(value, rawInit);
  6627. else if (type === "object" && !Array.isArray(value)) data.value = {
  6628. ...rawInit,
  6629. ...value
  6630. };
  6631. else data.value = value;
  6632. } else data.value = await serializer.read(rawValue);
  6633. } catch (e) {
  6634. onError(e);
  6635. }
  6636. }
  6637. const promise = new Promise((resolve) => {
  6638. read().then(() => {
  6639. onReady === null || onReady === void 0 || onReady(data.value);
  6640. resolve(data);
  6641. });
  6642. });
  6643. if (window && listenToStorageChanges) useEventListener(window, "storage", (e) => Promise.resolve().then(() => read(e)), { passive: true });
  6644. if (storage) (0, _vueuse_shared.watchWithFilter)(data, async () => {
  6645. try {
  6646. if (data.value == null) await storage.removeItem(key);
  6647. else await storage.setItem(key, await serializer.write(data.value));
  6648. } catch (e) {
  6649. onError(e);
  6650. }
  6651. }, {
  6652. flush,
  6653. deep,
  6654. eventFilter
  6655. });
  6656. Object.assign(data, {
  6657. then: promise.then.bind(promise),
  6658. catch: promise.catch.bind(promise)
  6659. });
  6660. return data;
  6661. }
  6662. //#endregion
  6663. //#region useStyleTag/index.ts
  6664. let _id = 0;
  6665. /**
  6666. * Inject <style> element in head.
  6667. *
  6668. * Overload: Omitted id
  6669. *
  6670. * @see https://vueuse.org/useStyleTag
  6671. * @param css
  6672. * @param options
  6673. */
  6674. function useStyleTag(css, options = {}) {
  6675. const isLoaded = (0, vue.shallowRef)(false);
  6676. const { document = defaultDocument, immediate = true, manual = false, id = `vueuse_styletag_${++_id}` } = options;
  6677. const cssRef = (0, vue.shallowRef)(css);
  6678. let stop = () => {};
  6679. const load = () => {
  6680. if (!document) return;
  6681. const el = document.getElementById(id) || document.createElement("style");
  6682. if (!el.isConnected) {
  6683. el.id = id;
  6684. if (options.nonce) el.nonce = options.nonce;
  6685. if (options.media) el.media = options.media;
  6686. document.head.appendChild(el);
  6687. }
  6688. if (isLoaded.value) return;
  6689. stop = (0, vue.watch)(cssRef, (value) => {
  6690. el.textContent = value;
  6691. }, { immediate: true });
  6692. isLoaded.value = true;
  6693. };
  6694. const unload = () => {
  6695. if (!document || !isLoaded.value) return;
  6696. stop();
  6697. document.head.removeChild(document.getElementById(id));
  6698. isLoaded.value = false;
  6699. };
  6700. if (immediate && !manual) (0, _vueuse_shared.tryOnMounted)(load);
  6701. if (!manual) (0, _vueuse_shared.tryOnScopeDispose)(unload);
  6702. return {
  6703. id,
  6704. css: cssRef,
  6705. unload,
  6706. load,
  6707. isLoaded: (0, vue.shallowReadonly)(isLoaded)
  6708. };
  6709. }
  6710. //#endregion
  6711. //#region useSwipe/index.ts
  6712. /**
  6713. * Reactive swipe detection.
  6714. *
  6715. * @see https://vueuse.org/useSwipe
  6716. * @param target
  6717. * @param options
  6718. */
  6719. function useSwipe(target, options = {}) {
  6720. const { threshold = 50, onSwipe, onSwipeEnd, onSwipeStart, passive = true } = options;
  6721. const coordsStart = (0, vue.reactive)({
  6722. x: 0,
  6723. y: 0
  6724. });
  6725. const coordsEnd = (0, vue.reactive)({
  6726. x: 0,
  6727. y: 0
  6728. });
  6729. const diffX = (0, vue.computed)(() => coordsStart.x - coordsEnd.x);
  6730. const diffY = (0, vue.computed)(() => coordsStart.y - coordsEnd.y);
  6731. const { max, abs } = Math;
  6732. const isThresholdExceeded = (0, vue.computed)(() => max(abs(diffX.value), abs(diffY.value)) >= threshold);
  6733. const isSwiping = (0, vue.shallowRef)(false);
  6734. const direction = (0, vue.computed)(() => {
  6735. if (!isThresholdExceeded.value) return "none";
  6736. if (abs(diffX.value) > abs(diffY.value)) return diffX.value > 0 ? "left" : "right";
  6737. else return diffY.value > 0 ? "up" : "down";
  6738. });
  6739. const getTouchEventCoords = (e) => [e.touches[0].clientX, e.touches[0].clientY];
  6740. const updateCoordsStart = (x, y) => {
  6741. coordsStart.x = x;
  6742. coordsStart.y = y;
  6743. };
  6744. const updateCoordsEnd = (x, y) => {
  6745. coordsEnd.x = x;
  6746. coordsEnd.y = y;
  6747. };
  6748. const listenerOptions = {
  6749. passive,
  6750. capture: !passive
  6751. };
  6752. const onTouchEnd = (e) => {
  6753. if (isSwiping.value) onSwipeEnd === null || onSwipeEnd === void 0 || onSwipeEnd(e, direction.value);
  6754. isSwiping.value = false;
  6755. };
  6756. const stops = [
  6757. useEventListener(target, "touchstart", (e) => {
  6758. if (e.touches.length !== 1) return;
  6759. const [x, y] = getTouchEventCoords(e);
  6760. updateCoordsStart(x, y);
  6761. updateCoordsEnd(x, y);
  6762. onSwipeStart === null || onSwipeStart === void 0 || onSwipeStart(e);
  6763. }, listenerOptions),
  6764. useEventListener(target, "touchmove", (e) => {
  6765. if (e.touches.length !== 1) return;
  6766. const [x, y] = getTouchEventCoords(e);
  6767. updateCoordsEnd(x, y);
  6768. if (listenerOptions.capture && !listenerOptions.passive && Math.abs(diffX.value) > Math.abs(diffY.value)) e.preventDefault();
  6769. if (!isSwiping.value && isThresholdExceeded.value) isSwiping.value = true;
  6770. if (isSwiping.value) onSwipe === null || onSwipe === void 0 || onSwipe(e);
  6771. }, listenerOptions),
  6772. useEventListener(target, ["touchend", "touchcancel"], onTouchEnd, listenerOptions)
  6773. ];
  6774. const stop = () => stops.forEach((s) => s());
  6775. return {
  6776. isSwiping,
  6777. direction,
  6778. coordsStart,
  6779. coordsEnd,
  6780. lengthX: diffX,
  6781. lengthY: diffY,
  6782. stop
  6783. };
  6784. }
  6785. //#endregion
  6786. //#region useTemplateRefsList/index.ts
  6787. /* @__NO_SIDE_EFFECTS__ */
  6788. function useTemplateRefsList() {
  6789. const refs = (0, vue.ref)([]);
  6790. refs.value.set = (el) => {
  6791. if (el) refs.value.push(el);
  6792. };
  6793. (0, vue.onBeforeUpdate)(() => {
  6794. refs.value.length = 0;
  6795. });
  6796. return refs;
  6797. }
  6798. //#endregion
  6799. //#region useTextDirection/index.ts
  6800. /**
  6801. * Reactive dir of the element's text.
  6802. *
  6803. * @see https://vueuse.org/useTextDirection
  6804. *
  6805. * @__NO_SIDE_EFFECTS__
  6806. */
  6807. function useTextDirection(options = {}) {
  6808. const { document = defaultDocument, selector = "html", observe = false, initialValue = "ltr" } = options;
  6809. function getValue() {
  6810. var _ref, _document$querySelect;
  6811. return (_ref = document === null || document === void 0 || (_document$querySelect = document.querySelector(selector)) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.getAttribute("dir")) !== null && _ref !== void 0 ? _ref : initialValue;
  6812. }
  6813. const dir = (0, vue.shallowRef)(getValue());
  6814. (0, _vueuse_shared.tryOnMounted)(() => dir.value = getValue());
  6815. if (observe && document) useMutationObserver(document.querySelector(selector), () => dir.value = getValue(), { attributes: true });
  6816. return (0, vue.computed)({
  6817. get() {
  6818. return dir.value;
  6819. },
  6820. set(v) {
  6821. var _document$querySelect2, _document$querySelect3;
  6822. dir.value = v;
  6823. if (!document) return;
  6824. if (dir.value) (_document$querySelect2 = document.querySelector(selector)) === null || _document$querySelect2 === void 0 || _document$querySelect2.setAttribute("dir", dir.value);
  6825. else (_document$querySelect3 = document.querySelector(selector)) === null || _document$querySelect3 === void 0 || _document$querySelect3.removeAttribute("dir");
  6826. }
  6827. });
  6828. }
  6829. //#endregion
  6830. //#region useTextSelection/index.ts
  6831. function getRangesFromSelection(selection) {
  6832. var _selection$rangeCount;
  6833. const rangeCount = (_selection$rangeCount = selection.rangeCount) !== null && _selection$rangeCount !== void 0 ? _selection$rangeCount : 0;
  6834. return Array.from({ length: rangeCount }, (_, i) => selection.getRangeAt(i));
  6835. }
  6836. /**
  6837. * Reactively track user text selection based on [`Window.getSelection`](https://developer.mozilla.org/en-US/docs/Web/API/Window/getSelection).
  6838. *
  6839. * @see https://vueuse.org/useTextSelection
  6840. *
  6841. * @__NO_SIDE_EFFECTS__
  6842. */
  6843. function useTextSelection(options = {}) {
  6844. var _window$getSelection;
  6845. const { window = defaultWindow } = options;
  6846. const selection = (0, vue.shallowRef)((_window$getSelection = window === null || window === void 0 ? void 0 : window.getSelection()) !== null && _window$getSelection !== void 0 ? _window$getSelection : null);
  6847. const text = (0, vue.computed)(() => {
  6848. var _selection$value$toSt, _selection$value;
  6849. return (_selection$value$toSt = (_selection$value = selection.value) === null || _selection$value === void 0 ? void 0 : _selection$value.toString()) !== null && _selection$value$toSt !== void 0 ? _selection$value$toSt : "";
  6850. });
  6851. const ranges = (0, vue.computed)(() => selection.value ? getRangesFromSelection(selection.value) : []);
  6852. const rects = (0, vue.computed)(() => ranges.value.map((range) => range.getBoundingClientRect()));
  6853. function onSelectionChange() {
  6854. selection.value = null;
  6855. if (window) selection.value = window.getSelection();
  6856. }
  6857. if (window) useEventListener(window.document, "selectionchange", onSelectionChange, { passive: true });
  6858. return {
  6859. text,
  6860. rects,
  6861. ranges,
  6862. selection
  6863. };
  6864. }
  6865. //#endregion
  6866. //#region useTextareaAutosize/index.ts
  6867. /**
  6868. * Call window.requestAnimationFrame(), if not available, just call the function
  6869. *
  6870. * @param window
  6871. * @param fn
  6872. */
  6873. function tryRequestAnimationFrame(window = defaultWindow, fn) {
  6874. if (window && typeof window.requestAnimationFrame === "function") window.requestAnimationFrame(fn);
  6875. else fn();
  6876. }
  6877. function useTextareaAutosize(options = {}) {
  6878. var _options$input, _options$styleProp;
  6879. const { window = defaultWindow } = options;
  6880. const textarea = (0, _vueuse_shared.toRef)(options === null || options === void 0 ? void 0 : options.element);
  6881. const input = (0, _vueuse_shared.toRef)((_options$input = options === null || options === void 0 ? void 0 : options.input) !== null && _options$input !== void 0 ? _options$input : "");
  6882. const styleProp = (_options$styleProp = options === null || options === void 0 ? void 0 : options.styleProp) !== null && _options$styleProp !== void 0 ? _options$styleProp : "height";
  6883. const textareaScrollHeight = (0, vue.shallowRef)(1);
  6884. const textareaOldWidth = (0, vue.shallowRef)(0);
  6885. function triggerResize() {
  6886. var _textarea$value;
  6887. if (!textarea.value) return;
  6888. let height = "";
  6889. const maxHeight = options === null || options === void 0 ? void 0 : options.maxHeight;
  6890. textarea.value.style[styleProp] = "1px";
  6891. textareaScrollHeight.value = (_textarea$value = textarea.value) === null || _textarea$value === void 0 ? void 0 : _textarea$value.scrollHeight;
  6892. const _styleTarget = (0, vue.toValue)(options === null || options === void 0 ? void 0 : options.styleTarget);
  6893. const styleHeight = maxHeight != null ? `${Math.min(textareaScrollHeight.value, maxHeight)}px` : `${textareaScrollHeight.value}px`;
  6894. if (_styleTarget) _styleTarget.style[styleProp] = styleHeight;
  6895. else height = styleHeight;
  6896. textarea.value.style[styleProp] = height;
  6897. }
  6898. (0, vue.watch)([input, textarea], () => (0, vue.nextTick)(triggerResize), { immediate: true });
  6899. (0, vue.watch)(textareaScrollHeight, () => {
  6900. var _options$onResize;
  6901. return options === null || options === void 0 || (_options$onResize = options.onResize) === null || _options$onResize === void 0 ? void 0 : _options$onResize.call(options);
  6902. });
  6903. useResizeObserver(textarea, ([{ contentRect }]) => {
  6904. if (textareaOldWidth.value === contentRect.width) return;
  6905. tryRequestAnimationFrame(window, () => {
  6906. textareaOldWidth.value = contentRect.width;
  6907. triggerResize();
  6908. });
  6909. });
  6910. if (options === null || options === void 0 ? void 0 : options.watch) (0, vue.watch)(options.watch, triggerResize, {
  6911. immediate: true,
  6912. deep: true
  6913. });
  6914. return {
  6915. textarea,
  6916. input,
  6917. triggerResize
  6918. };
  6919. }
  6920. //#endregion
  6921. //#region useThrottledRefHistory/index.ts
  6922. /**
  6923. * Shorthand for [useRefHistory](https://vueuse.org/useRefHistory) with throttled filter.
  6924. *
  6925. * @see https://vueuse.org/useThrottledRefHistory
  6926. * @param source
  6927. * @param options
  6928. */
  6929. function useThrottledRefHistory(source, options = {}) {
  6930. const { throttle = 200, trailing = true } = options;
  6931. const filter = (0, _vueuse_shared.throttleFilter)(throttle, trailing);
  6932. return { ...useRefHistory(source, {
  6933. ...options,
  6934. eventFilter: filter
  6935. }) };
  6936. }
  6937. //#endregion
  6938. //#region useTimeAgo/index.ts
  6939. const DEFAULT_UNITS = [
  6940. {
  6941. max: 6e4,
  6942. value: 1e3,
  6943. name: "second"
  6944. },
  6945. {
  6946. max: 276e4,
  6947. value: 6e4,
  6948. name: "minute"
  6949. },
  6950. {
  6951. max: 72e6,
  6952. value: 36e5,
  6953. name: "hour"
  6954. },
  6955. {
  6956. max: 5184e5,
  6957. value: 864e5,
  6958. name: "day"
  6959. },
  6960. {
  6961. max: 24192e5,
  6962. value: 6048e5,
  6963. name: "week"
  6964. },
  6965. {
  6966. max: 28512e6,
  6967. value: 2592e6,
  6968. name: "month"
  6969. },
  6970. {
  6971. max: Number.POSITIVE_INFINITY,
  6972. value: 31536e6,
  6973. name: "year"
  6974. }
  6975. ];
  6976. const DEFAULT_MESSAGES = {
  6977. justNow: "just now",
  6978. past: (n) => /\d/.test(n) ? `${n} ago` : n,
  6979. future: (n) => /\d/.test(n) ? `in ${n}` : n,
  6980. month: (n, past) => n === 1 ? past ? "last month" : "next month" : `${n} month${n > 1 ? "s" : ""}`,
  6981. year: (n, past) => n === 1 ? past ? "last year" : "next year" : `${n} year${n > 1 ? "s" : ""}`,
  6982. day: (n, past) => n === 1 ? past ? "yesterday" : "tomorrow" : `${n} day${n > 1 ? "s" : ""}`,
  6983. week: (n, past) => n === 1 ? past ? "last week" : "next week" : `${n} week${n > 1 ? "s" : ""}`,
  6984. hour: (n) => `${n} hour${n > 1 ? "s" : ""}`,
  6985. minute: (n) => `${n} minute${n > 1 ? "s" : ""}`,
  6986. second: (n) => `${n} second${n > 1 ? "s" : ""}`,
  6987. invalid: ""
  6988. };
  6989. function DEFAULT_FORMATTER(date) {
  6990. return date.toISOString().slice(0, 10);
  6991. }
  6992. function getDefaultScheduler$4(options) {
  6993. if ("updateInterval" in options) {
  6994. const { updateInterval = 3e4 } = options;
  6995. return (cb) => (0, _vueuse_shared.useIntervalFn)(cb, updateInterval);
  6996. }
  6997. return (cb) => (0, _vueuse_shared.useIntervalFn)(cb, 3e4);
  6998. }
  6999. /**
  7000. * Reactive time ago formatter.
  7001. *
  7002. * @see https://vueuse.org/useTimeAgo
  7003. *
  7004. * @__NO_SIDE_EFFECTS__
  7005. */
  7006. function useTimeAgo(time, options = {}) {
  7007. const { controls: exposeControls = false, scheduler = getDefaultScheduler$4(options) } = options;
  7008. const { now, ...controls } = useNow({
  7009. scheduler,
  7010. controls: true
  7011. });
  7012. const timeAgo = (0, vue.computed)(() => formatTimeAgo(new Date((0, vue.toValue)(time)), options, (0, vue.toValue)(now)));
  7013. if (exposeControls) return {
  7014. timeAgo,
  7015. ...controls
  7016. };
  7017. else return timeAgo;
  7018. }
  7019. function formatTimeAgo(from, options = {}, now = Date.now()) {
  7020. const { max, messages = DEFAULT_MESSAGES, fullDateFormatter = DEFAULT_FORMATTER, units = DEFAULT_UNITS, showSecond = false, rounding = "round" } = options;
  7021. const roundFn = typeof rounding === "number" ? (n) => +n.toFixed(rounding) : Math[rounding];
  7022. const diff = +now - +from;
  7023. const absDiff = Math.abs(diff);
  7024. function getValue(diff, unit) {
  7025. return roundFn(Math.abs(diff) / unit.value);
  7026. }
  7027. function format(diff, unit) {
  7028. const val = getValue(diff, unit);
  7029. const past = diff > 0;
  7030. const str = applyFormat(unit.name, val, past);
  7031. return applyFormat(past ? "past" : "future", str, past);
  7032. }
  7033. function applyFormat(name, val, isPast) {
  7034. const formatter = messages[name];
  7035. if (typeof formatter === "function") return formatter(val, isPast);
  7036. return formatter.replace("{0}", val.toString());
  7037. }
  7038. if (absDiff < 6e4 && !showSecond) return messages.justNow;
  7039. if (typeof max === "number" && absDiff > max) return fullDateFormatter(new Date(from));
  7040. if (typeof max === "string") {
  7041. var _units$find;
  7042. const unitMax = (_units$find = units.find((i) => i.name === max)) === null || _units$find === void 0 ? void 0 : _units$find.max;
  7043. if (unitMax && absDiff > unitMax) return fullDateFormatter(new Date(from));
  7044. }
  7045. for (const [idx, unit] of units.entries()) {
  7046. if (getValue(diff, unit) <= 0 && units[idx - 1]) return format(diff, units[idx - 1]);
  7047. if (absDiff < unit.max) return format(diff, unit);
  7048. }
  7049. return messages.invalid;
  7050. }
  7051. //#endregion
  7052. //#region useTimeAgoIntl/index.ts
  7053. const UNITS = [
  7054. {
  7055. name: "year",
  7056. ms: 31536e6
  7057. },
  7058. {
  7059. name: "month",
  7060. ms: 2592e6
  7061. },
  7062. {
  7063. name: "week",
  7064. ms: 6048e5
  7065. },
  7066. {
  7067. name: "day",
  7068. ms: 864e5
  7069. },
  7070. {
  7071. name: "hour",
  7072. ms: 36e5
  7073. },
  7074. {
  7075. name: "minute",
  7076. ms: 6e4
  7077. },
  7078. {
  7079. name: "second",
  7080. ms: 1e3
  7081. }
  7082. ];
  7083. function getDefaultScheduler$3(options) {
  7084. if ("updateInterval" in options) {
  7085. const { updateInterval = 3e4 } = options;
  7086. return (cb) => (0, _vueuse_shared.useIntervalFn)(cb, updateInterval);
  7087. }
  7088. return (cb) => (0, _vueuse_shared.useIntervalFn)(cb, 3e4);
  7089. }
  7090. function useTimeAgoIntl(time, options = {}) {
  7091. const { controls: exposeControls = false, scheduler = getDefaultScheduler$3(options) } = options;
  7092. const { now, ...controls } = useNow({
  7093. scheduler,
  7094. controls: true
  7095. });
  7096. const result = (0, vue.computed)(() => getTimeAgoIntlResult(new Date((0, vue.toValue)(time)), options, (0, vue.toValue)(now)));
  7097. const parts = (0, vue.computed)(() => result.value.parts);
  7098. const timeAgoIntl = (0, vue.computed)(() => formatTimeAgoIntlParts(parts.value, {
  7099. ...options,
  7100. locale: result.value.resolvedLocale
  7101. }));
  7102. return exposeControls ? {
  7103. timeAgoIntl,
  7104. parts,
  7105. ...controls
  7106. } : timeAgoIntl;
  7107. }
  7108. /**
  7109. * Non-reactive version of useTimeAgoIntl
  7110. */
  7111. function formatTimeAgoIntl(from, options = {}, now = Date.now()) {
  7112. const { parts, resolvedLocale } = getTimeAgoIntlResult(from, options, now);
  7113. return formatTimeAgoIntlParts(parts, {
  7114. ...options,
  7115. locale: resolvedLocale
  7116. });
  7117. }
  7118. /**
  7119. * Get parts from `Intl.RelativeTimeFormat.formatToParts`.
  7120. */
  7121. function getTimeAgoIntlResult(from, options = {}, now = Date.now()) {
  7122. var _options$units;
  7123. const { locale, relativeTimeFormatOptions = { numeric: "auto" } } = options;
  7124. const rtf = new Intl.RelativeTimeFormat(locale, relativeTimeFormatOptions);
  7125. const { locale: resolvedLocale } = rtf.resolvedOptions();
  7126. const diff = +from - +now;
  7127. const absDiff = Math.abs(diff);
  7128. const units = (_options$units = options.units) !== null && _options$units !== void 0 ? _options$units : UNITS;
  7129. for (const { name, ms } of units) if (absDiff >= ms) return {
  7130. resolvedLocale,
  7131. parts: rtf.formatToParts(Math.round(diff / ms), name)
  7132. };
  7133. return {
  7134. resolvedLocale,
  7135. parts: rtf.formatToParts(0, units[units.length - 1].name)
  7136. };
  7137. }
  7138. /**
  7139. * Format parts into a string
  7140. */
  7141. function formatTimeAgoIntlParts(parts, options = {}) {
  7142. const { insertSpace = true, joinParts, locale } = options;
  7143. if (typeof joinParts === "function") return joinParts(parts, locale);
  7144. if (!insertSpace) return parts.map((part) => part.value).join("");
  7145. return parts.map((part) => part.value.trim()).join(" ");
  7146. }
  7147. //#endregion
  7148. //#region useTimeoutPoll/index.ts
  7149. function useTimeoutPoll(fn, interval, options = {}) {
  7150. const { immediate = true, immediateCallback = false } = options;
  7151. const { start } = (0, _vueuse_shared.useTimeoutFn)(loop, interval, { immediate });
  7152. const isActive = (0, vue.shallowRef)(false);
  7153. async function loop() {
  7154. if (!isActive.value) return;
  7155. await fn();
  7156. start();
  7157. }
  7158. function resume() {
  7159. if (!isActive.value) {
  7160. isActive.value = true;
  7161. if (immediateCallback) fn();
  7162. start();
  7163. }
  7164. }
  7165. function pause() {
  7166. isActive.value = false;
  7167. }
  7168. if (immediate && _vueuse_shared.isClient) resume();
  7169. (0, _vueuse_shared.tryOnScopeDispose)(pause);
  7170. return {
  7171. isActive,
  7172. pause,
  7173. resume
  7174. };
  7175. }
  7176. //#endregion
  7177. //#region useTimestamp/index.ts
  7178. function getDefaultScheduler$2(options) {
  7179. if ("interval" in options || "immediate" in options) {
  7180. const { interval = "requestAnimationFrame", immediate = true } = options;
  7181. return interval === "requestAnimationFrame" ? (cb) => useRafFn(cb, { immediate }) : (cb) => (0, _vueuse_shared.useIntervalFn)(cb, interval, { immediate });
  7182. }
  7183. return useRafFn;
  7184. }
  7185. function useTimestamp(options = {}) {
  7186. const { controls: exposeControls = false, offset = 0, scheduler = getDefaultScheduler$2(options), callback } = options;
  7187. const ts = (0, vue.shallowRef)((0, _vueuse_shared.timestamp)() + offset);
  7188. const update = () => ts.value = (0, _vueuse_shared.timestamp)() + offset;
  7189. const controls = scheduler(callback ? () => {
  7190. update();
  7191. callback(ts.value);
  7192. } : update);
  7193. if (exposeControls) return {
  7194. timestamp: ts,
  7195. ...controls
  7196. };
  7197. else return ts;
  7198. }
  7199. //#endregion
  7200. //#region useTitle/index.ts
  7201. function useTitle(newTitle = null, options = {}) {
  7202. var _document$title, _ref;
  7203. const { document = defaultDocument, restoreOnUnmount = (t) => t } = options;
  7204. const originalTitle = (_document$title = document === null || document === void 0 ? void 0 : document.title) !== null && _document$title !== void 0 ? _document$title : "";
  7205. const title = (0, _vueuse_shared.toRef)((_ref = newTitle !== null && newTitle !== void 0 ? newTitle : document === null || document === void 0 ? void 0 : document.title) !== null && _ref !== void 0 ? _ref : null);
  7206. const isReadonly = !!(newTitle && typeof newTitle === "function");
  7207. function format(t) {
  7208. if (!("titleTemplate" in options)) return t;
  7209. const template = options.titleTemplate || "%s";
  7210. return typeof template === "function" ? template(t) : (0, vue.toValue)(template).replace(/%s/g, t);
  7211. }
  7212. (0, vue.watch)(title, (newValue, oldValue) => {
  7213. if (newValue !== oldValue && document) document.title = format(newValue !== null && newValue !== void 0 ? newValue : "");
  7214. }, { immediate: true });
  7215. if (options.observe && !options.titleTemplate && document && !isReadonly) {
  7216. var _document$head;
  7217. useMutationObserver((_document$head = document.head) === null || _document$head === void 0 ? void 0 : _document$head.querySelector("title"), () => {
  7218. if (document && document.title !== title.value) title.value = format(document.title);
  7219. }, { childList: true });
  7220. }
  7221. (0, _vueuse_shared.tryOnScopeDispose)(() => {
  7222. if (restoreOnUnmount) {
  7223. const restoredTitle = restoreOnUnmount(originalTitle, title.value || "");
  7224. if (restoredTitle != null && document) document.title = restoredTitle;
  7225. }
  7226. });
  7227. return title;
  7228. }
  7229. /**
  7230. * Common transitions
  7231. *
  7232. * @see https://easings.net
  7233. */
  7234. const TransitionPresets = /* @__PURE__ */ Object.assign({}, { linear: _vueuse_shared.identity }, {
  7235. easeInSine: [
  7236. .12,
  7237. 0,
  7238. .39,
  7239. 0
  7240. ],
  7241. easeOutSine: [
  7242. .61,
  7243. 1,
  7244. .88,
  7245. 1
  7246. ],
  7247. easeInOutSine: [
  7248. .37,
  7249. 0,
  7250. .63,
  7251. 1
  7252. ],
  7253. easeInQuad: [
  7254. .11,
  7255. 0,
  7256. .5,
  7257. 0
  7258. ],
  7259. easeOutQuad: [
  7260. .5,
  7261. 1,
  7262. .89,
  7263. 1
  7264. ],
  7265. easeInOutQuad: [
  7266. .45,
  7267. 0,
  7268. .55,
  7269. 1
  7270. ],
  7271. easeInCubic: [
  7272. .32,
  7273. 0,
  7274. .67,
  7275. 0
  7276. ],
  7277. easeOutCubic: [
  7278. .33,
  7279. 1,
  7280. .68,
  7281. 1
  7282. ],
  7283. easeInOutCubic: [
  7284. .65,
  7285. 0,
  7286. .35,
  7287. 1
  7288. ],
  7289. easeInQuart: [
  7290. .5,
  7291. 0,
  7292. .75,
  7293. 0
  7294. ],
  7295. easeOutQuart: [
  7296. .25,
  7297. 1,
  7298. .5,
  7299. 1
  7300. ],
  7301. easeInOutQuart: [
  7302. .76,
  7303. 0,
  7304. .24,
  7305. 1
  7306. ],
  7307. easeInQuint: [
  7308. .64,
  7309. 0,
  7310. .78,
  7311. 0
  7312. ],
  7313. easeOutQuint: [
  7314. .22,
  7315. 1,
  7316. .36,
  7317. 1
  7318. ],
  7319. easeInOutQuint: [
  7320. .83,
  7321. 0,
  7322. .17,
  7323. 1
  7324. ],
  7325. easeInExpo: [
  7326. .7,
  7327. 0,
  7328. .84,
  7329. 0
  7330. ],
  7331. easeOutExpo: [
  7332. .16,
  7333. 1,
  7334. .3,
  7335. 1
  7336. ],
  7337. easeInOutExpo: [
  7338. .87,
  7339. 0,
  7340. .13,
  7341. 1
  7342. ],
  7343. easeInCirc: [
  7344. .55,
  7345. 0,
  7346. 1,
  7347. .45
  7348. ],
  7349. easeOutCirc: [
  7350. 0,
  7351. .55,
  7352. .45,
  7353. 1
  7354. ],
  7355. easeInOutCirc: [
  7356. .85,
  7357. 0,
  7358. .15,
  7359. 1
  7360. ],
  7361. easeInBack: [
  7362. .36,
  7363. 0,
  7364. .66,
  7365. -.56
  7366. ],
  7367. easeOutBack: [
  7368. .34,
  7369. 1.56,
  7370. .64,
  7371. 1
  7372. ],
  7373. easeInOutBack: [
  7374. .68,
  7375. -.6,
  7376. .32,
  7377. 1.6
  7378. ]
  7379. });
  7380. /**
  7381. * Create an easing function from cubic bezier points.
  7382. */
  7383. function createEasingFunction([p0, p1, p2, p3]) {
  7384. const a = (a1, a2) => 1 - 3 * a2 + 3 * a1;
  7385. const b = (a1, a2) => 3 * a2 - 6 * a1;
  7386. const c = (a1) => 3 * a1;
  7387. const calcBezier = (t, a1, a2) => ((a(a1, a2) * t + b(a1, a2)) * t + c(a1)) * t;
  7388. const getSlope = (t, a1, a2) => 3 * a(a1, a2) * t * t + 2 * b(a1, a2) * t + c(a1);
  7389. const getTforX = (x) => {
  7390. let aGuessT = x;
  7391. for (let i = 0; i < 4; ++i) {
  7392. const currentSlope = getSlope(aGuessT, p0, p2);
  7393. if (currentSlope === 0) return aGuessT;
  7394. const currentX = calcBezier(aGuessT, p0, p2) - x;
  7395. aGuessT -= currentX / currentSlope;
  7396. }
  7397. return aGuessT;
  7398. };
  7399. return (x) => p0 === p1 && p2 === p3 ? x : calcBezier(getTforX(x), p1, p3);
  7400. }
  7401. function lerp(a, b, alpha) {
  7402. return a + alpha * (b - a);
  7403. }
  7404. function defaultInterpolation(a, b, t) {
  7405. const aVal = (0, vue.toValue)(a);
  7406. const bVal = (0, vue.toValue)(b);
  7407. if (typeof aVal === "number" && typeof bVal === "number") return lerp(aVal, bVal, t);
  7408. if (Array.isArray(aVal) && Array.isArray(bVal)) return aVal.map((v, i) => lerp(v, (0, vue.toValue)(bVal[i]), t));
  7409. throw new TypeError("Unknown transition type, specify an interpolation function.");
  7410. }
  7411. function normalizeEasing(easing) {
  7412. var _toValue;
  7413. return typeof easing === "function" ? easing : (_toValue = (0, vue.toValue)(easing)) !== null && _toValue !== void 0 ? _toValue : _vueuse_shared.identity;
  7414. }
  7415. /**
  7416. * Transition from one value to another.
  7417. *
  7418. * @param source
  7419. * @param from
  7420. * @param to
  7421. * @param options
  7422. */
  7423. function transition(source, from, to, options = {}) {
  7424. var _toValue2;
  7425. const { window = defaultWindow } = options;
  7426. const fromVal = (0, vue.toValue)(from);
  7427. const toVal = (0, vue.toValue)(to);
  7428. const duration = (_toValue2 = (0, vue.toValue)(options.duration)) !== null && _toValue2 !== void 0 ? _toValue2 : 1e3;
  7429. const startedAt = Date.now();
  7430. const endAt = Date.now() + duration;
  7431. const interpolation = typeof options.interpolation === "function" ? options.interpolation : defaultInterpolation;
  7432. const trans = typeof options.easing !== "undefined" ? normalizeEasing(options.easing) : normalizeEasing(options.transition);
  7433. const ease = typeof trans === "function" ? trans : createEasingFunction(trans);
  7434. return new Promise((resolve) => {
  7435. source.value = fromVal;
  7436. const tick = () => {
  7437. var _options$abort;
  7438. if ((_options$abort = options.abort) === null || _options$abort === void 0 ? void 0 : _options$abort.call(options)) {
  7439. resolve();
  7440. return;
  7441. }
  7442. const now = Date.now();
  7443. source.value = interpolation(fromVal, toVal, ease((now - startedAt) / duration));
  7444. if (now < endAt) window === null || window === void 0 || window.requestAnimationFrame(tick);
  7445. else {
  7446. source.value = toVal;
  7447. resolve();
  7448. }
  7449. };
  7450. tick();
  7451. });
  7452. }
  7453. /**
  7454. * Transition from one value to another.
  7455. * @deprecated The `executeTransition` function is deprecated, use `transition` instead.
  7456. *
  7457. * @param source
  7458. * @param from
  7459. * @param to
  7460. * @param options
  7461. */
  7462. function executeTransition(source, from, to, options = {}) {
  7463. return transition(source, from, to, options);
  7464. }
  7465. /**
  7466. * Follow value with a transition.
  7467. *
  7468. * @see https://vueuse.org/useTransition
  7469. * @param source
  7470. * @param options
  7471. */
  7472. function useTransition(source, options = {}) {
  7473. let currentId = 0;
  7474. const sourceVal = () => {
  7475. const v = (0, vue.toValue)(source);
  7476. return typeof options.interpolation === "undefined" && Array.isArray(v) ? v.map(vue.toValue) : v;
  7477. };
  7478. const outputRef = (0, vue.shallowRef)(sourceVal());
  7479. (0, vue.watch)(sourceVal, async (to) => {
  7480. var _options$onStarted, _options$onFinished;
  7481. if ((0, vue.toValue)(options.disabled)) return;
  7482. const id = ++currentId;
  7483. if (options.delay) await (0, _vueuse_shared.promiseTimeout)((0, vue.toValue)(options.delay));
  7484. if (id !== currentId) return;
  7485. (_options$onStarted = options.onStarted) === null || _options$onStarted === void 0 || _options$onStarted.call(options);
  7486. await transition(outputRef, outputRef.value, to, {
  7487. ...options,
  7488. abort: () => {
  7489. var _options$abort2;
  7490. return id !== currentId || ((_options$abort2 = options.abort) === null || _options$abort2 === void 0 ? void 0 : _options$abort2.call(options));
  7491. }
  7492. });
  7493. (_options$onFinished = options.onFinished) === null || _options$onFinished === void 0 || _options$onFinished.call(options);
  7494. }, { deep: true });
  7495. (0, vue.watch)(() => (0, vue.toValue)(options.disabled), (disabled) => {
  7496. if (disabled) {
  7497. currentId++;
  7498. outputRef.value = sourceVal();
  7499. }
  7500. });
  7501. (0, _vueuse_shared.tryOnScopeDispose)(() => {
  7502. currentId++;
  7503. });
  7504. return (0, vue.computed)(() => (0, vue.toValue)(options.disabled) ? sourceVal() : outputRef.value);
  7505. }
  7506. //#endregion
  7507. //#region useUrlSearchParams/index.ts
  7508. /**
  7509. * Reactive URLSearchParams
  7510. *
  7511. * @see https://vueuse.org/useUrlSearchParams
  7512. * @param mode
  7513. * @param options
  7514. */
  7515. function useUrlSearchParams(mode = "history", options = {}) {
  7516. const { initialValue = {}, removeNullishValues = true, removeFalsyValues = false, write: enableWrite = true, writeMode = "replace", window = defaultWindow, stringify = (params) => params.toString() } = options;
  7517. if (!window) return (0, vue.reactive)(initialValue);
  7518. const state = (0, vue.reactive)({});
  7519. function getRawParams() {
  7520. if (mode === "history") return window.location.search || "";
  7521. else if (mode === "hash") {
  7522. const hash = window.location.hash || "";
  7523. const index = hash.indexOf("?");
  7524. return index > 0 ? hash.slice(index) : "";
  7525. } else return (window.location.hash || "").replace(/^#/, "");
  7526. }
  7527. function constructQuery(params) {
  7528. const stringified = stringify(params);
  7529. if (mode === "history") return `${stringified ? `?${stringified}` : ""}${window.location.hash || ""}`;
  7530. if (mode === "hash-params") return `${window.location.search || ""}${stringified ? `#${stringified}` : ""}`;
  7531. const hash = window.location.hash || "#";
  7532. const index = hash.indexOf("?");
  7533. if (index > 0) return `${window.location.search || ""}${hash.slice(0, index)}${stringified ? `?${stringified}` : ""}`;
  7534. return `${window.location.search || ""}${hash}${stringified ? `?${stringified}` : ""}`;
  7535. }
  7536. function read() {
  7537. return new URLSearchParams(getRawParams());
  7538. }
  7539. function updateState(params) {
  7540. const unusedKeys = new Set(Object.keys(state));
  7541. for (const key of params.keys()) {
  7542. const paramsForKey = params.getAll(key);
  7543. state[key] = paramsForKey.length > 1 ? paramsForKey : params.get(key) || "";
  7544. unusedKeys.delete(key);
  7545. }
  7546. Array.from(unusedKeys).forEach((key) => delete state[key]);
  7547. }
  7548. const { pause, resume } = (0, _vueuse_shared.watchPausable)(state, () => {
  7549. const params = new URLSearchParams("");
  7550. Object.keys(state).forEach((key) => {
  7551. const mapEntry = state[key];
  7552. if (Array.isArray(mapEntry)) mapEntry.forEach((value) => params.append(key, value));
  7553. else if (removeNullishValues && mapEntry == null) params.delete(key);
  7554. else if (removeFalsyValues && !mapEntry) params.delete(key);
  7555. else params.set(key, mapEntry);
  7556. });
  7557. write(params, false);
  7558. }, { deep: true });
  7559. function write(params, shouldUpdate, shouldWriteHistory = true) {
  7560. pause();
  7561. if (shouldUpdate) updateState(params);
  7562. if (writeMode === "replace") window.history.replaceState(window.history.state, window.document.title, window.location.pathname + constructQuery(params));
  7563. else if (shouldWriteHistory) window.history.pushState(window.history.state, window.document.title, window.location.pathname + constructQuery(params));
  7564. (0, vue.nextTick)(() => resume());
  7565. }
  7566. function onChanged() {
  7567. if (!enableWrite) return;
  7568. write(read(), true, false);
  7569. }
  7570. const listenerOptions = { passive: true };
  7571. useEventListener(window, "popstate", onChanged, listenerOptions);
  7572. if (mode !== "history") useEventListener(window, "hashchange", onChanged, listenerOptions);
  7573. const initial = read();
  7574. if (initial.keys().next().value) updateState(initial);
  7575. else Object.assign(state, initialValue);
  7576. return state;
  7577. }
  7578. //#endregion
  7579. //#region useUserMedia/index.ts
  7580. /**
  7581. * Reactive `mediaDevices.getUserMedia` streaming
  7582. *
  7583. * @see https://vueuse.org/useUserMedia
  7584. * @param options
  7585. */
  7586. function useUserMedia(options = {}) {
  7587. var _options$enabled, _options$autoSwitch;
  7588. const enabled = (0, vue.shallowRef)((_options$enabled = options.enabled) !== null && _options$enabled !== void 0 ? _options$enabled : false);
  7589. const autoSwitch = (0, vue.shallowRef)((_options$autoSwitch = options.autoSwitch) !== null && _options$autoSwitch !== void 0 ? _options$autoSwitch : true);
  7590. const constraints = (0, vue.ref)(options.constraints);
  7591. const { navigator = defaultNavigator } = options;
  7592. const isSupported = /* @__PURE__ */ useSupported(() => {
  7593. var _navigator$mediaDevic;
  7594. return navigator === null || navigator === void 0 || (_navigator$mediaDevic = navigator.mediaDevices) === null || _navigator$mediaDevic === void 0 ? void 0 : _navigator$mediaDevic.getUserMedia;
  7595. });
  7596. const stream = (0, vue.shallowRef)();
  7597. function getDeviceOptions(type) {
  7598. switch (type) {
  7599. case "video":
  7600. if (constraints.value) return constraints.value.video || false;
  7601. break;
  7602. case "audio":
  7603. if (constraints.value) return constraints.value.audio || false;
  7604. break;
  7605. }
  7606. }
  7607. async function _start() {
  7608. if (!isSupported.value || stream.value) return;
  7609. stream.value = await navigator.mediaDevices.getUserMedia({
  7610. video: getDeviceOptions("video"),
  7611. audio: getDeviceOptions("audio")
  7612. });
  7613. return stream.value;
  7614. }
  7615. function _stop() {
  7616. var _stream$value;
  7617. (_stream$value = stream.value) === null || _stream$value === void 0 || _stream$value.getTracks().forEach((t) => t.stop());
  7618. stream.value = void 0;
  7619. }
  7620. function stop() {
  7621. _stop();
  7622. enabled.value = false;
  7623. }
  7624. async function start() {
  7625. await _start();
  7626. if (stream.value) enabled.value = true;
  7627. return stream.value;
  7628. }
  7629. async function restart() {
  7630. _stop();
  7631. return await start();
  7632. }
  7633. (0, vue.watch)(enabled, (v) => {
  7634. if (v) _start();
  7635. else _stop();
  7636. }, { immediate: true });
  7637. (0, vue.watch)(constraints, () => {
  7638. if (autoSwitch.value && stream.value) restart();
  7639. }, {
  7640. immediate: true,
  7641. deep: true
  7642. });
  7643. (0, _vueuse_shared.tryOnScopeDispose)(() => {
  7644. stop();
  7645. });
  7646. return {
  7647. isSupported,
  7648. stream,
  7649. start,
  7650. stop,
  7651. restart,
  7652. constraints,
  7653. enabled,
  7654. autoSwitch
  7655. };
  7656. }
  7657. //#endregion
  7658. //#region useVModel/index.ts
  7659. /**
  7660. * Shorthand for v-model binding, props + emit -> ref
  7661. *
  7662. * @see https://vueuse.org/useVModel
  7663. * @param props
  7664. * @param key (default 'modelValue')
  7665. * @param emit
  7666. * @param options
  7667. *
  7668. * @__NO_SIDE_EFFECTS__
  7669. */
  7670. function useVModel(props, key, emit, options = {}) {
  7671. var _vm$$emit, _vm$proxy;
  7672. const { clone = false, passive = false, eventName, deep = false, defaultValue, shouldEmit } = options;
  7673. const vm = (0, vue.getCurrentInstance)();
  7674. const _emit = emit || (vm === null || vm === void 0 ? void 0 : vm.emit) || (vm === null || vm === void 0 || (_vm$$emit = vm.$emit) === null || _vm$$emit === void 0 ? void 0 : _vm$$emit.bind(vm)) || (vm === null || vm === void 0 || (_vm$proxy = vm.proxy) === null || _vm$proxy === void 0 || (_vm$proxy = _vm$proxy.$emit) === null || _vm$proxy === void 0 ? void 0 : _vm$proxy.bind(vm === null || vm === void 0 ? void 0 : vm.proxy));
  7675. let event = eventName;
  7676. if (!key) key = "modelValue";
  7677. event = event || `update:${key.toString()}`;
  7678. const cloneFn = (val) => !clone ? val : typeof clone === "function" ? clone(val) : cloneFnJSON(val);
  7679. const getValue = () => (0, _vueuse_shared.isDef)(props[key]) ? cloneFn(props[key]) : defaultValue;
  7680. const triggerEmit = (value) => {
  7681. if (shouldEmit) {
  7682. if (shouldEmit(value)) _emit(event, value);
  7683. } else _emit(event, value);
  7684. };
  7685. if (passive) {
  7686. const proxy = (0, vue.ref)(getValue());
  7687. let isUpdating = false;
  7688. (0, vue.watch)(() => props[key], (v) => {
  7689. if (!isUpdating) {
  7690. isUpdating = true;
  7691. proxy.value = cloneFn(v);
  7692. (0, vue.nextTick)(() => isUpdating = false);
  7693. }
  7694. });
  7695. (0, vue.watch)(proxy, (v) => {
  7696. if (!isUpdating && (v !== props[key] || deep)) triggerEmit(v);
  7697. }, { deep });
  7698. return proxy;
  7699. } else return (0, vue.computed)({
  7700. get() {
  7701. return getValue();
  7702. },
  7703. set(value) {
  7704. triggerEmit(value);
  7705. }
  7706. });
  7707. }
  7708. //#endregion
  7709. //#region useVModels/index.ts
  7710. /**
  7711. * Shorthand for props v-model binding. Think like `toRefs(props)` but changes will also emit out.
  7712. *
  7713. * @see https://vueuse.org/useVModels
  7714. * @param props
  7715. * @param emit
  7716. * @param options
  7717. *
  7718. * @__NO_SIDE_EFFECTS__
  7719. */
  7720. function useVModels(props, emit, options = {}) {
  7721. const ret = {};
  7722. for (const key in props) ret[key] = useVModel(props, key, emit, options);
  7723. return ret;
  7724. }
  7725. //#endregion
  7726. //#region useVibrate/index.ts
  7727. function getDefaultScheduler$1(options = { interval: 0 }) {
  7728. const { interval } = options;
  7729. if (interval === 0) return;
  7730. return (fn) => (0, _vueuse_shared.useIntervalFn)(fn, interval, {
  7731. immediate: false,
  7732. immediateCallback: false
  7733. });
  7734. }
  7735. /**
  7736. * Reactive vibrate
  7737. *
  7738. * @see https://vueuse.org/useVibrate
  7739. * @see https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API
  7740. * @param options
  7741. *
  7742. * @__NO_SIDE_EFFECTS__
  7743. */
  7744. function useVibrate(options) {
  7745. const { pattern = [], scheduler = getDefaultScheduler$1(options), navigator = defaultNavigator } = options || {};
  7746. const isSupported = /* @__PURE__ */ useSupported(() => typeof navigator !== "undefined" && "vibrate" in navigator);
  7747. const patternRef = (0, _vueuse_shared.toRef)(pattern);
  7748. const vibrate = (pattern = patternRef.value) => {
  7749. if (isSupported.value) navigator.vibrate(pattern);
  7750. };
  7751. const intervalControls = scheduler === null || scheduler === void 0 ? void 0 : scheduler(vibrate);
  7752. const stop = () => {
  7753. if (isSupported.value) navigator.vibrate(0);
  7754. intervalControls === null || intervalControls === void 0 || intervalControls.pause();
  7755. };
  7756. return {
  7757. isSupported,
  7758. pattern,
  7759. intervalControls,
  7760. vibrate,
  7761. stop
  7762. };
  7763. }
  7764. //#endregion
  7765. //#region useVirtualList/index.ts
  7766. /**
  7767. * Please consider using [`vue-virtual-scroller`](https://github.com/Akryum/vue-virtual-scroller) if you are looking for more features.
  7768. */
  7769. function useVirtualList(list, options) {
  7770. const { containerStyle, wrapperProps, scrollTo, calculateRange, currentList, containerRef } = "itemHeight" in options ? useVerticalVirtualList(options, list) : useHorizontalVirtualList(options, list);
  7771. return {
  7772. list: currentList,
  7773. scrollTo,
  7774. containerProps: {
  7775. ref: containerRef,
  7776. onScroll: () => {
  7777. calculateRange();
  7778. },
  7779. style: containerStyle
  7780. },
  7781. wrapperProps
  7782. };
  7783. }
  7784. function useVirtualListResources(list) {
  7785. const containerRef = (0, vue.shallowRef)(null);
  7786. const size = useElementSize(containerRef);
  7787. const currentList = (0, vue.ref)([]);
  7788. const source = (0, vue.shallowRef)(list);
  7789. return {
  7790. state: (0, vue.ref)({
  7791. start: 0,
  7792. end: 10
  7793. }),
  7794. source,
  7795. currentList,
  7796. size,
  7797. containerRef
  7798. };
  7799. }
  7800. function createGetViewCapacity(state, source, itemSize) {
  7801. return (containerSize) => {
  7802. if (typeof itemSize === "number") return Math.ceil(containerSize / itemSize);
  7803. const { start = 0 } = state.value;
  7804. let sum = 0;
  7805. let capacity = 0;
  7806. for (let i = start; i < source.value.length; i++) {
  7807. const size = itemSize(i);
  7808. sum += size;
  7809. capacity = i;
  7810. if (sum > containerSize) break;
  7811. }
  7812. return capacity - start;
  7813. };
  7814. }
  7815. function createGetOffset(source, itemSize) {
  7816. return (scrollDirection) => {
  7817. if (typeof itemSize === "number") return Math.floor(scrollDirection / itemSize) + 1;
  7818. let sum = 0;
  7819. let offset = 0;
  7820. for (let i = 0; i < source.value.length; i++) {
  7821. const size = itemSize(i);
  7822. sum += size;
  7823. if (sum >= scrollDirection) {
  7824. offset = i;
  7825. break;
  7826. }
  7827. }
  7828. return offset + 1;
  7829. };
  7830. }
  7831. function createCalculateRange(type, overscan, getOffset, getViewCapacity, { containerRef, state, currentList, source }) {
  7832. return () => {
  7833. const element = containerRef.value;
  7834. if (element) {
  7835. const offset = getOffset(type === "vertical" ? element.scrollTop : element.scrollLeft);
  7836. const viewCapacity = getViewCapacity(type === "vertical" ? element.clientHeight : element.clientWidth);
  7837. const from = offset - overscan;
  7838. const to = offset + viewCapacity + overscan;
  7839. state.value = {
  7840. start: from < 0 ? 0 : from,
  7841. end: to > source.value.length ? source.value.length : to
  7842. };
  7843. currentList.value = source.value.slice(state.value.start, state.value.end).map((ele, index) => ({
  7844. data: ele,
  7845. index: index + state.value.start
  7846. }));
  7847. }
  7848. };
  7849. }
  7850. function createGetDistance(itemSize, source) {
  7851. return (index) => {
  7852. if (typeof itemSize === "number") return index * itemSize;
  7853. return source.value.slice(0, index).reduce((sum, _, i) => sum + itemSize(i), 0);
  7854. };
  7855. }
  7856. function useWatchForSizes(size, listRef, containerRef, calculateRange) {
  7857. (0, vue.watch)([
  7858. size.width,
  7859. size.height,
  7860. listRef,
  7861. containerRef
  7862. ], () => {
  7863. calculateRange();
  7864. });
  7865. }
  7866. function createComputedTotalSize(itemSize, source) {
  7867. return (0, vue.computed)(() => {
  7868. if (typeof itemSize === "number") return source.value.length * itemSize;
  7869. return source.value.reduce((sum, _, index) => sum + itemSize(index), 0);
  7870. });
  7871. }
  7872. const scrollToDictionaryForElementScrollKey = {
  7873. horizontal: "scrollLeft",
  7874. vertical: "scrollTop"
  7875. };
  7876. function createScrollTo(type, calculateRange, getDistance, containerRef) {
  7877. return (index) => {
  7878. if (containerRef.value) {
  7879. containerRef.value[scrollToDictionaryForElementScrollKey[type]] = getDistance(index);
  7880. calculateRange();
  7881. }
  7882. };
  7883. }
  7884. function useHorizontalVirtualList(options, list) {
  7885. const resources = useVirtualListResources(list);
  7886. const { state, source, currentList, size, containerRef } = resources;
  7887. const containerStyle = { overflowX: "auto" };
  7888. const { itemWidth, overscan = 5 } = options;
  7889. const getViewCapacity = createGetViewCapacity(state, source, itemWidth);
  7890. const calculateRange = createCalculateRange("horizontal", overscan, createGetOffset(source, itemWidth), getViewCapacity, resources);
  7891. const getDistanceLeft = createGetDistance(itemWidth, source);
  7892. const offsetLeft = (0, vue.computed)(() => getDistanceLeft(state.value.start));
  7893. const totalWidth = createComputedTotalSize(itemWidth, source);
  7894. useWatchForSizes(size, source, containerRef, calculateRange);
  7895. return {
  7896. scrollTo: createScrollTo("horizontal", calculateRange, getDistanceLeft, containerRef),
  7897. calculateRange,
  7898. wrapperProps: (0, vue.computed)(() => {
  7899. return { style: {
  7900. height: "100%",
  7901. width: `${totalWidth.value - offsetLeft.value}px`,
  7902. marginLeft: `${offsetLeft.value}px`,
  7903. display: "flex"
  7904. } };
  7905. }),
  7906. containerStyle,
  7907. currentList,
  7908. containerRef
  7909. };
  7910. }
  7911. function useVerticalVirtualList(options, list) {
  7912. const resources = useVirtualListResources(list);
  7913. const { state, source, currentList, size, containerRef } = resources;
  7914. const containerStyle = { overflowY: "auto" };
  7915. const { itemHeight, overscan = 5 } = options;
  7916. const getViewCapacity = createGetViewCapacity(state, source, itemHeight);
  7917. const calculateRange = createCalculateRange("vertical", overscan, createGetOffset(source, itemHeight), getViewCapacity, resources);
  7918. const getDistanceTop = createGetDistance(itemHeight, source);
  7919. const offsetTop = (0, vue.computed)(() => getDistanceTop(state.value.start));
  7920. const totalHeight = createComputedTotalSize(itemHeight, source);
  7921. useWatchForSizes(size, source, containerRef, calculateRange);
  7922. return {
  7923. calculateRange,
  7924. scrollTo: createScrollTo("vertical", calculateRange, getDistanceTop, containerRef),
  7925. containerStyle,
  7926. wrapperProps: (0, vue.computed)(() => {
  7927. return { style: {
  7928. width: "100%",
  7929. height: `${totalHeight.value - offsetTop.value}px`,
  7930. marginTop: `${offsetTop.value}px`
  7931. } };
  7932. }),
  7933. currentList,
  7934. containerRef
  7935. };
  7936. }
  7937. //#endregion
  7938. //#region useWakeLock/index.ts
  7939. /**
  7940. * Reactive Screen Wake Lock API.
  7941. *
  7942. * @see https://vueuse.org/useWakeLock
  7943. * @param options
  7944. *
  7945. * @__NO_SIDE_EFFECTS__
  7946. */
  7947. function useWakeLock(options = {}) {
  7948. const { navigator = defaultNavigator, document = defaultDocument } = options;
  7949. const requestedType = (0, vue.shallowRef)(false);
  7950. const sentinel = (0, vue.shallowRef)(null);
  7951. const documentVisibility = useDocumentVisibility({ document });
  7952. const isSupported = /* @__PURE__ */ useSupported(() => navigator && "wakeLock" in navigator);
  7953. const isActive = (0, vue.computed)(() => !!sentinel.value && documentVisibility.value === "visible");
  7954. if (isSupported.value) {
  7955. useEventListener(sentinel, "release", () => {
  7956. var _sentinel$value$type, _sentinel$value;
  7957. requestedType.value = (_sentinel$value$type = (_sentinel$value = sentinel.value) === null || _sentinel$value === void 0 ? void 0 : _sentinel$value.type) !== null && _sentinel$value$type !== void 0 ? _sentinel$value$type : false;
  7958. }, { passive: true });
  7959. (0, _vueuse_shared.whenever)(() => documentVisibility.value === "visible" && (document === null || document === void 0 ? void 0 : document.visibilityState) === "visible" && requestedType.value, (type) => {
  7960. requestedType.value = false;
  7961. forceRequest(type);
  7962. });
  7963. }
  7964. async function forceRequest(type) {
  7965. var _sentinel$value2;
  7966. await ((_sentinel$value2 = sentinel.value) === null || _sentinel$value2 === void 0 ? void 0 : _sentinel$value2.release());
  7967. sentinel.value = isSupported.value ? await navigator.wakeLock.request(type) : null;
  7968. }
  7969. async function request(type) {
  7970. if (documentVisibility.value === "visible") await forceRequest(type);
  7971. else requestedType.value = type;
  7972. }
  7973. async function release() {
  7974. requestedType.value = false;
  7975. const s = sentinel.value;
  7976. sentinel.value = null;
  7977. await (s === null || s === void 0 ? void 0 : s.release());
  7978. }
  7979. (0, _vueuse_shared.tryOnScopeDispose)(() => {
  7980. release();
  7981. });
  7982. return {
  7983. sentinel,
  7984. isSupported,
  7985. isActive,
  7986. request,
  7987. forceRequest,
  7988. release
  7989. };
  7990. }
  7991. //#endregion
  7992. //#region useWebNotification/index.ts
  7993. /**
  7994. * Reactive useWebNotification
  7995. *
  7996. * @see https://vueuse.org/useWebNotification
  7997. * @see https://developer.mozilla.org/en-US/docs/Web/API/notification
  7998. */
  7999. function useWebNotification(options = {}) {
  8000. const { window = defaultWindow, requestPermissions: _requestForPermissions = true } = options;
  8001. const defaultWebNotificationOptions = options;
  8002. const isSupported = /* @__PURE__ */ useSupported(() => {
  8003. if (!window || !("Notification" in window)) return false;
  8004. if (Notification.permission === "granted") return true;
  8005. try {
  8006. const notification = new Notification("");
  8007. notification.onshow = () => {
  8008. notification.close();
  8009. };
  8010. } catch (e) {
  8011. if (e.name === "TypeError") return false;
  8012. }
  8013. return true;
  8014. });
  8015. const permissionGranted = (0, vue.shallowRef)(isSupported.value && "permission" in Notification && Notification.permission === "granted");
  8016. const notification = (0, vue.shallowRef)(null);
  8017. const ensurePermissions = async () => {
  8018. if (!isSupported.value) return;
  8019. if (!permissionGranted.value && Notification.permission !== "denied") {
  8020. if (await Notification.requestPermission() === "granted") permissionGranted.value = true;
  8021. }
  8022. return permissionGranted.value;
  8023. };
  8024. const { on: onClick, trigger: clickTrigger } = (0, _vueuse_shared.createEventHook)();
  8025. const { on: onShow, trigger: showTrigger } = (0, _vueuse_shared.createEventHook)();
  8026. const { on: onError, trigger: errorTrigger } = (0, _vueuse_shared.createEventHook)();
  8027. const { on: onClose, trigger: closeTrigger } = (0, _vueuse_shared.createEventHook)();
  8028. const show = async (overrides) => {
  8029. if (!isSupported.value || !permissionGranted.value) return;
  8030. const options = Object.assign({}, defaultWebNotificationOptions, overrides);
  8031. notification.value = new Notification(options.title || "", options);
  8032. notification.value.onclick = clickTrigger;
  8033. notification.value.onshow = showTrigger;
  8034. notification.value.onerror = errorTrigger;
  8035. notification.value.onclose = closeTrigger;
  8036. return notification.value;
  8037. };
  8038. const close = () => {
  8039. if (notification.value) notification.value.close();
  8040. notification.value = null;
  8041. };
  8042. if (_requestForPermissions) (0, _vueuse_shared.tryOnMounted)(ensurePermissions);
  8043. (0, _vueuse_shared.tryOnScopeDispose)(close);
  8044. if (isSupported.value && window) {
  8045. const document = window.document;
  8046. useEventListener(document, "visibilitychange", (e) => {
  8047. e.preventDefault();
  8048. if (document.visibilityState === "visible") close();
  8049. });
  8050. }
  8051. return {
  8052. isSupported,
  8053. notification,
  8054. ensurePermissions,
  8055. permissionGranted,
  8056. show,
  8057. close,
  8058. onClick,
  8059. onShow,
  8060. onError,
  8061. onClose
  8062. };
  8063. }
  8064. //#endregion
  8065. //#region useWebSocket/index.ts
  8066. const DEFAULT_PING_MESSAGE = "ping";
  8067. function resolveNestedOptions(options) {
  8068. if (options === true) return {};
  8069. return options;
  8070. }
  8071. function getDefaultScheduler(options) {
  8072. if ("interval" in options) {
  8073. const { interval = 1e3 } = options;
  8074. return (cb) => (0, _vueuse_shared.useIntervalFn)(cb, interval, { immediate: false });
  8075. }
  8076. return (cb) => (0, _vueuse_shared.useIntervalFn)(cb, 1e3, { immediate: false });
  8077. }
  8078. /**
  8079. * Reactive WebSocket client.
  8080. *
  8081. * @see https://vueuse.org/useWebSocket
  8082. * @param url
  8083. */
  8084. function useWebSocket(url, options = {}) {
  8085. const { onConnected, onDisconnected, onError, onMessage, immediate = true, autoConnect = true, autoClose = true, protocols = [] } = options;
  8086. const data = (0, vue.shallowRef)(null);
  8087. const status = (0, vue.shallowRef)("CLOSED");
  8088. const wsRef = (0, vue.shallowRef)();
  8089. const urlRef = (0, _vueuse_shared.toRef)(url);
  8090. let heartbeatPause;
  8091. let heartbeatResume;
  8092. let explicitlyClosed = false;
  8093. let retried = 0;
  8094. let bufferedData = [];
  8095. let retryTimeout;
  8096. let pongTimeoutWait;
  8097. const _sendBuffer = () => {
  8098. if (bufferedData.length && wsRef.value && status.value === "OPEN") {
  8099. for (const buffer of bufferedData) wsRef.value.send(buffer);
  8100. bufferedData = [];
  8101. }
  8102. };
  8103. const resetRetry = () => {
  8104. if (retryTimeout != null) {
  8105. clearTimeout(retryTimeout);
  8106. retryTimeout = void 0;
  8107. }
  8108. };
  8109. const resetHeartbeat = () => {
  8110. clearTimeout(pongTimeoutWait);
  8111. pongTimeoutWait = void 0;
  8112. };
  8113. const close = (code = 1e3, reason) => {
  8114. resetRetry();
  8115. if (!_vueuse_shared.isClient && !_vueuse_shared.isWorker || !wsRef.value) return;
  8116. explicitlyClosed = true;
  8117. resetHeartbeat();
  8118. heartbeatPause === null || heartbeatPause === void 0 || heartbeatPause();
  8119. wsRef.value.close(code, reason);
  8120. wsRef.value = void 0;
  8121. };
  8122. const send = (data, useBuffer = true) => {
  8123. if (!wsRef.value || status.value !== "OPEN") {
  8124. if (useBuffer) bufferedData.push(data);
  8125. return false;
  8126. }
  8127. _sendBuffer();
  8128. wsRef.value.send(data);
  8129. return true;
  8130. };
  8131. const _init = () => {
  8132. if (explicitlyClosed || typeof urlRef.value === "undefined") return;
  8133. const ws = new WebSocket(urlRef.value, protocols);
  8134. wsRef.value = ws;
  8135. status.value = "CONNECTING";
  8136. ws.onopen = () => {
  8137. if (wsRef.value !== ws) return;
  8138. status.value = "OPEN";
  8139. retried = 0;
  8140. onConnected === null || onConnected === void 0 || onConnected(ws);
  8141. heartbeatResume === null || heartbeatResume === void 0 || heartbeatResume();
  8142. _sendBuffer();
  8143. };
  8144. ws.onclose = (ev) => {
  8145. if (wsRef.value === ws) status.value = "CLOSED";
  8146. resetHeartbeat();
  8147. heartbeatPause === null || heartbeatPause === void 0 || heartbeatPause();
  8148. onDisconnected === null || onDisconnected === void 0 || onDisconnected(ws, ev);
  8149. if (!explicitlyClosed && options.autoReconnect && (wsRef.value == null || ws === wsRef.value)) {
  8150. const { retries = -1, delay = 1e3, onFailed } = resolveNestedOptions(options.autoReconnect);
  8151. if ((typeof retries === "function" ? retries : () => typeof retries === "number" && (retries < 0 || retried < retries))(retried)) {
  8152. retried += 1;
  8153. const delayTime = typeof delay === "function" ? delay(retried) : delay;
  8154. retryTimeout = setTimeout(_init, delayTime);
  8155. } else onFailed === null || onFailed === void 0 || onFailed();
  8156. }
  8157. };
  8158. ws.onerror = (e) => {
  8159. onError === null || onError === void 0 || onError(ws, e);
  8160. };
  8161. ws.onmessage = (e) => {
  8162. if (options.heartbeat) {
  8163. resetHeartbeat();
  8164. const { message = DEFAULT_PING_MESSAGE, responseMessage = message } = resolveNestedOptions(options.heartbeat);
  8165. if (e.data === (0, vue.toValue)(responseMessage)) return;
  8166. }
  8167. data.value = e.data;
  8168. onMessage === null || onMessage === void 0 || onMessage(ws, e);
  8169. };
  8170. };
  8171. if (options.heartbeat) {
  8172. const { message = DEFAULT_PING_MESSAGE, scheduler = getDefaultScheduler(resolveNestedOptions(options.heartbeat)), pongTimeout = 1e3 } = resolveNestedOptions(options.heartbeat);
  8173. const { pause, resume } = scheduler(() => {
  8174. send((0, vue.toValue)(message), false);
  8175. if (pongTimeoutWait != null) return;
  8176. pongTimeoutWait = setTimeout(() => {
  8177. close();
  8178. explicitlyClosed = false;
  8179. }, pongTimeout);
  8180. });
  8181. heartbeatPause = pause;
  8182. heartbeatResume = resume;
  8183. }
  8184. if (autoClose) {
  8185. if (_vueuse_shared.isClient) useEventListener("beforeunload", () => close(), { passive: true });
  8186. (0, _vueuse_shared.tryOnScopeDispose)(close);
  8187. }
  8188. const open = () => {
  8189. if (!_vueuse_shared.isClient && !_vueuse_shared.isWorker) return;
  8190. close();
  8191. explicitlyClosed = false;
  8192. retried = 0;
  8193. _init();
  8194. };
  8195. if (immediate) open();
  8196. if (autoConnect) (0, vue.watch)(urlRef, open);
  8197. return {
  8198. data,
  8199. status,
  8200. close,
  8201. send,
  8202. open,
  8203. ws: wsRef
  8204. };
  8205. }
  8206. //#endregion
  8207. //#region useWebWorker/index.ts
  8208. function useWebWorker(arg0, workerOptions, options) {
  8209. const { window = defaultWindow } = options !== null && options !== void 0 ? options : {};
  8210. const data = (0, vue.shallowRef)(null);
  8211. const worker = (0, vue.shallowRef)();
  8212. const post = (...args) => {
  8213. if (!worker.value) return;
  8214. worker.value.postMessage(...args);
  8215. };
  8216. const terminate = function terminate() {
  8217. if (!worker.value) return;
  8218. worker.value.terminate();
  8219. };
  8220. if (window) {
  8221. if (typeof arg0 === "string") worker.value = new Worker(arg0, workerOptions);
  8222. else if (typeof arg0 === "function") worker.value = arg0();
  8223. else worker.value = arg0;
  8224. worker.value.onmessage = (e) => {
  8225. data.value = e.data;
  8226. };
  8227. (0, _vueuse_shared.tryOnScopeDispose)(() => {
  8228. if (worker.value) worker.value.terminate();
  8229. });
  8230. }
  8231. return {
  8232. data,
  8233. post,
  8234. terminate,
  8235. worker
  8236. };
  8237. }
  8238. //#endregion
  8239. //#region useWebWorkerFn/lib/depsParser.ts
  8240. /**
  8241. *
  8242. * Concatenates the dependencies into a comma separated string.
  8243. * this string will then be passed as an argument to the "importScripts" function
  8244. *
  8245. * @param deps array of string
  8246. * @param localDeps array of function
  8247. * @returns a string composed by the concatenation of the array
  8248. * elements "deps" and "importScripts".
  8249. *
  8250. * @example
  8251. * depsParser(['demo1', 'demo2']) // return importScripts('demo1', 'demo2')
  8252. */
  8253. function depsParser(deps, localDeps) {
  8254. if (deps.length === 0 && localDeps.length === 0) return "";
  8255. const depsString = deps.map((dep) => `'${dep}'`).toString();
  8256. const depsFunctionString = localDeps.filter((dep) => typeof dep === "function").map((fn) => {
  8257. const str = fn.toString();
  8258. if (str.trim().startsWith("function")) return str;
  8259. else return `const ${fn.name} = ${str}`;
  8260. }).join(";");
  8261. const importString = `importScripts(${depsString});`;
  8262. return `${depsString.trim() === "" ? "" : importString} ${depsFunctionString}`;
  8263. }
  8264. //#endregion
  8265. //#region useWebWorkerFn/lib/jobRunner.ts
  8266. /**
  8267. * This function accepts as a parameter a function "userFunc"
  8268. * And as a result returns an anonymous function.
  8269. * This anonymous function, accepts as arguments,
  8270. * the parameters to pass to the function "useArgs" and returns a Promise
  8271. * This function can be used as a wrapper, only inside a Worker
  8272. * because it depends by "postMessage".
  8273. *
  8274. * @param userFunc {Function} fn the function to run with web worker
  8275. *
  8276. * @returns returns a function that accepts the parameters
  8277. * to be passed to the "userFunc" function
  8278. */
  8279. function jobRunner(userFunc) {
  8280. return (e) => {
  8281. const userFuncArgs = e.data[0];
  8282. return Promise.resolve(userFunc.apply(void 0, userFuncArgs)).then((result) => {
  8283. postMessage(["SUCCESS", result]);
  8284. }).catch((error) => {
  8285. postMessage(["ERROR", error]);
  8286. });
  8287. };
  8288. }
  8289. //#endregion
  8290. //#region useWebWorkerFn/lib/createWorkerBlobUrl.ts
  8291. /**
  8292. * Converts the "fn" function into the syntax needed to be executed within a web worker
  8293. *
  8294. * @param fn the function to run with web worker
  8295. * @param deps array of strings, imported into the worker through "importScripts"
  8296. * @param localDeps array of function, local dependencies
  8297. *
  8298. * @returns a blob url, containing the code of "fn" as a string
  8299. *
  8300. * @example
  8301. * createWorkerBlobUrl((a,b) => a+b, [])
  8302. * // return "onmessage=return Promise.resolve((a,b) => a + b)
  8303. * .then(postMessage(['SUCCESS', result]))
  8304. * .catch(postMessage(['ERROR', error])"
  8305. */
  8306. function createWorkerBlobUrl(fn, deps, localDeps) {
  8307. const blobCode = `${depsParser(deps, localDeps)}; onmessage=(${jobRunner})(${fn})`;
  8308. const blob = new Blob([blobCode], { type: "text/javascript" });
  8309. return URL.createObjectURL(blob);
  8310. }
  8311. //#endregion
  8312. //#region useWebWorkerFn/index.ts
  8313. /**
  8314. * Run expensive function without blocking the UI, using a simple syntax that makes use of Promise.
  8315. *
  8316. * @see https://vueuse.org/useWebWorkerFn
  8317. * @param fn
  8318. * @param options
  8319. */
  8320. function useWebWorkerFn(fn, options = {}) {
  8321. const { dependencies = [], localDependencies = [], timeout, window = defaultWindow } = options;
  8322. let worker;
  8323. const workerStatus = (0, vue.shallowRef)("PENDING");
  8324. const promise = (0, vue.shallowRef)({});
  8325. const timeoutId = (0, vue.shallowRef)();
  8326. const workerTerminate = (status = "PENDING") => {
  8327. if (worker && worker._url && window) {
  8328. worker.terminate();
  8329. URL.revokeObjectURL(worker._url);
  8330. promise.value = {};
  8331. worker = void 0;
  8332. window.clearTimeout(timeoutId.value);
  8333. workerStatus.value = status;
  8334. }
  8335. };
  8336. workerTerminate();
  8337. (0, _vueuse_shared.tryOnScopeDispose)(workerTerminate);
  8338. const generateWorker = () => {
  8339. const blobUrl = createWorkerBlobUrl(fn, dependencies, localDependencies);
  8340. const newWorker = new Worker(blobUrl);
  8341. newWorker._url = blobUrl;
  8342. newWorker.onmessage = (e) => {
  8343. const { resolve = () => {}, reject = () => {} } = promise.value;
  8344. const [status, result] = e.data;
  8345. switch (status) {
  8346. case "SUCCESS":
  8347. resolve(result);
  8348. workerTerminate(status);
  8349. break;
  8350. default:
  8351. reject(result);
  8352. workerTerminate("ERROR");
  8353. break;
  8354. }
  8355. };
  8356. newWorker.onerror = (e) => {
  8357. const { reject = () => {} } = promise.value;
  8358. e.preventDefault();
  8359. reject(e);
  8360. workerTerminate("ERROR");
  8361. };
  8362. if (timeout) timeoutId.value = setTimeout(workerTerminate, timeout, "TIMEOUT_EXPIRED");
  8363. return newWorker;
  8364. };
  8365. const callWorker = (...fnArgs) => new Promise((resolve, reject) => {
  8366. promise.value = {
  8367. resolve,
  8368. reject
  8369. };
  8370. worker === null || worker === void 0 || worker.postMessage([[...fnArgs]]);
  8371. workerStatus.value = "RUNNING";
  8372. });
  8373. const workerFn = (...fnArgs) => {
  8374. if (workerStatus.value === "RUNNING") {
  8375. console.error("[useWebWorkerFn] You can only run one instance of the worker at a time.");
  8376. return Promise.reject();
  8377. }
  8378. worker = generateWorker();
  8379. return callWorker(...fnArgs);
  8380. };
  8381. return {
  8382. workerFn,
  8383. workerStatus,
  8384. workerTerminate
  8385. };
  8386. }
  8387. //#endregion
  8388. //#region useWindowFocus/index.ts
  8389. /**
  8390. * Reactively track window focus with `window.onfocus` and `window.onblur`.
  8391. *
  8392. * @see https://vueuse.org/useWindowFocus
  8393. *
  8394. * @__NO_SIDE_EFFECTS__
  8395. */
  8396. function useWindowFocus(options = {}) {
  8397. const { window = defaultWindow } = options;
  8398. if (!window) return (0, vue.shallowRef)(false);
  8399. const focused = (0, vue.shallowRef)(window.document.hasFocus());
  8400. const listenerOptions = { passive: true };
  8401. useEventListener(window, "blur", () => {
  8402. focused.value = false;
  8403. }, listenerOptions);
  8404. useEventListener(window, "focus", () => {
  8405. focused.value = true;
  8406. }, listenerOptions);
  8407. return focused;
  8408. }
  8409. //#endregion
  8410. //#region useWindowScroll/index.ts
  8411. /**
  8412. * Reactive window scroll.
  8413. *
  8414. * @see https://vueuse.org/useWindowScroll
  8415. * @param options
  8416. */
  8417. function useWindowScroll(options = {}) {
  8418. const { window = defaultWindow, ...rest } = options;
  8419. return useScroll(window, rest);
  8420. }
  8421. //#endregion
  8422. //#region useWindowSize/index.ts
  8423. /**
  8424. * Reactive window size.
  8425. *
  8426. * @see https://vueuse.org/useWindowSize
  8427. * @param options
  8428. *
  8429. * @__NO_SIDE_EFFECTS__
  8430. */
  8431. function useWindowSize(options = {}) {
  8432. const { window = defaultWindow, initialWidth = Number.POSITIVE_INFINITY, initialHeight = Number.POSITIVE_INFINITY, listenOrientation = true, includeScrollbar = true, type = "inner" } = options;
  8433. const width = (0, vue.shallowRef)(initialWidth);
  8434. const height = (0, vue.shallowRef)(initialHeight);
  8435. const update = () => {
  8436. if (window) if (type === "outer") {
  8437. width.value = window.outerWidth;
  8438. height.value = window.outerHeight;
  8439. } else if (type === "visual" && window.visualViewport) {
  8440. const { width: visualViewportWidth, height: visualViewportHeight, scale } = window.visualViewport;
  8441. width.value = Math.round(visualViewportWidth * scale);
  8442. height.value = Math.round(visualViewportHeight * scale);
  8443. } else if (includeScrollbar) {
  8444. width.value = window.innerWidth;
  8445. height.value = window.innerHeight;
  8446. } else {
  8447. width.value = window.document.documentElement.clientWidth;
  8448. height.value = window.document.documentElement.clientHeight;
  8449. }
  8450. };
  8451. update();
  8452. (0, _vueuse_shared.tryOnMounted)(update);
  8453. const listenerOptions = { passive: true };
  8454. useEventListener("resize", update, listenerOptions);
  8455. if (window && type === "visual" && window.visualViewport) useEventListener(window.visualViewport, "resize", update, listenerOptions);
  8456. if (listenOrientation) (0, vue.watch)(useMediaQuery("(orientation: portrait)"), () => update());
  8457. return {
  8458. width,
  8459. height
  8460. };
  8461. }
  8462. //#endregion
  8463. exports.DefaultMagicKeysAliasMap = DefaultMagicKeysAliasMap;
  8464. exports.StorageSerializers = StorageSerializers;
  8465. exports.TransitionPresets = TransitionPresets;
  8466. exports.asyncComputed = asyncComputed;
  8467. exports.breakpointsAntDesign = breakpointsAntDesign;
  8468. exports.breakpointsBootstrapV5 = breakpointsBootstrapV5;
  8469. exports.breakpointsElement = breakpointsElement;
  8470. exports.breakpointsMasterCss = breakpointsMasterCss;
  8471. exports.breakpointsPrimeFlex = breakpointsPrimeFlex;
  8472. exports.breakpointsQuasar = breakpointsQuasar;
  8473. exports.breakpointsSematic = breakpointsSematic;
  8474. exports.breakpointsTailwind = breakpointsTailwind;
  8475. exports.breakpointsVuetify = breakpointsVuetify;
  8476. exports.breakpointsVuetifyV2 = breakpointsVuetifyV2;
  8477. exports.breakpointsVuetifyV3 = breakpointsVuetifyV3;
  8478. exports.cloneFnJSON = cloneFnJSON;
  8479. exports.computedAsync = computedAsync;
  8480. exports.computedInject = computedInject;
  8481. exports.createFetch = createFetch;
  8482. exports.createReusableTemplate = createReusableTemplate;
  8483. exports.createTemplatePromise = createTemplatePromise;
  8484. exports.createUnrefFn = createUnrefFn;
  8485. exports.customStorageEventName = customStorageEventName;
  8486. exports.defaultDocument = defaultDocument;
  8487. exports.defaultLocation = defaultLocation;
  8488. exports.defaultNavigator = defaultNavigator;
  8489. exports.defaultWindow = defaultWindow;
  8490. exports.executeTransition = executeTransition;
  8491. exports.formatTimeAgo = formatTimeAgo;
  8492. exports.formatTimeAgoIntl = formatTimeAgoIntl;
  8493. exports.formatTimeAgoIntlParts = formatTimeAgoIntlParts;
  8494. exports.getSSRHandler = getSSRHandler;
  8495. exports.mapGamepadToXbox360Controller = mapGamepadToXbox360Controller;
  8496. exports.onClickOutside = onClickOutside;
  8497. exports.onElementRemoval = onElementRemoval;
  8498. exports.onKeyDown = onKeyDown;
  8499. exports.onKeyPressed = onKeyPressed;
  8500. exports.onKeyStroke = onKeyStroke;
  8501. exports.onKeyUp = onKeyUp;
  8502. exports.onLongPress = onLongPress;
  8503. exports.onStartTyping = onStartTyping;
  8504. exports.provideSSRWidth = provideSSRWidth;
  8505. exports.setSSRHandler = setSSRHandler;
  8506. exports.templateRef = templateRef;
  8507. exports.transition = transition;
  8508. exports.unrefElement = unrefElement;
  8509. exports.useActiveElement = useActiveElement;
  8510. exports.useAnimate = useAnimate;
  8511. exports.useAsyncQueue = useAsyncQueue;
  8512. exports.useAsyncState = useAsyncState;
  8513. exports.useBase64 = useBase64;
  8514. exports.useBattery = useBattery;
  8515. exports.useBluetooth = useBluetooth;
  8516. exports.useBreakpoints = useBreakpoints;
  8517. exports.useBroadcastChannel = useBroadcastChannel;
  8518. exports.useBrowserLocation = useBrowserLocation;
  8519. exports.useCached = useCached;
  8520. exports.useClipboard = useClipboard;
  8521. exports.useClipboardItems = useClipboardItems;
  8522. exports.useCloned = useCloned;
  8523. exports.useColorMode = useColorMode;
  8524. exports.useConfirmDialog = useConfirmDialog;
  8525. exports.useCountdown = useCountdown;
  8526. exports.useCssSupports = useCssSupports;
  8527. exports.useCssVar = useCssVar;
  8528. exports.useCurrentElement = useCurrentElement;
  8529. exports.useCycleList = useCycleList;
  8530. exports.useDark = useDark;
  8531. exports.useDebouncedRefHistory = useDebouncedRefHistory;
  8532. exports.useDeviceMotion = useDeviceMotion;
  8533. exports.useDeviceOrientation = useDeviceOrientation;
  8534. exports.useDevicePixelRatio = useDevicePixelRatio;
  8535. exports.useDevicesList = useDevicesList;
  8536. exports.useDisplayMedia = useDisplayMedia;
  8537. exports.useDocumentVisibility = useDocumentVisibility;
  8538. exports.useDraggable = useDraggable;
  8539. exports.useDropZone = useDropZone;
  8540. exports.useElementBounding = useElementBounding;
  8541. exports.useElementByPoint = useElementByPoint;
  8542. exports.useElementHover = useElementHover;
  8543. exports.useElementSize = useElementSize;
  8544. exports.useElementVisibility = useElementVisibility;
  8545. exports.useEventBus = useEventBus;
  8546. exports.useEventListener = useEventListener;
  8547. exports.useEventSource = useEventSource;
  8548. exports.useEyeDropper = useEyeDropper;
  8549. exports.useFavicon = useFavicon;
  8550. exports.useFetch = useFetch;
  8551. exports.useFileDialog = useFileDialog;
  8552. exports.useFileSystemAccess = useFileSystemAccess;
  8553. exports.useFocus = useFocus;
  8554. exports.useFocusWithin = useFocusWithin;
  8555. exports.useFps = useFps;
  8556. exports.useFullscreen = useFullscreen;
  8557. exports.useGamepad = useGamepad;
  8558. exports.useGeolocation = useGeolocation;
  8559. exports.useIdle = useIdle;
  8560. exports.useImage = useImage;
  8561. exports.useInfiniteScroll = useInfiniteScroll;
  8562. exports.useIntersectionObserver = useIntersectionObserver;
  8563. exports.useKeyModifier = useKeyModifier;
  8564. exports.useLocalStorage = useLocalStorage;
  8565. exports.useMagicKeys = useMagicKeys;
  8566. exports.useManualRefHistory = useManualRefHistory;
  8567. exports.useMediaControls = useMediaControls;
  8568. exports.useMediaQuery = useMediaQuery;
  8569. exports.useMemoize = useMemoize;
  8570. exports.useMemory = useMemory;
  8571. exports.useMounted = useMounted;
  8572. exports.useMouse = useMouse;
  8573. exports.useMouseInElement = useMouseInElement;
  8574. exports.useMousePressed = useMousePressed;
  8575. exports.useMutationObserver = useMutationObserver;
  8576. exports.useNavigatorLanguage = useNavigatorLanguage;
  8577. exports.useNetwork = useNetwork;
  8578. exports.useNow = useNow;
  8579. exports.useObjectUrl = useObjectUrl;
  8580. exports.useOffsetPagination = useOffsetPagination;
  8581. exports.useOnline = useOnline;
  8582. exports.usePageLeave = usePageLeave;
  8583. exports.useParallax = useParallax;
  8584. exports.useParentElement = useParentElement;
  8585. exports.usePerformanceObserver = usePerformanceObserver;
  8586. exports.usePermission = usePermission;
  8587. exports.usePointer = usePointer;
  8588. exports.usePointerLock = usePointerLock;
  8589. exports.usePointerSwipe = usePointerSwipe;
  8590. exports.usePreferredColorScheme = usePreferredColorScheme;
  8591. exports.usePreferredContrast = usePreferredContrast;
  8592. exports.usePreferredDark = usePreferredDark;
  8593. exports.usePreferredLanguages = usePreferredLanguages;
  8594. exports.usePreferredReducedMotion = usePreferredReducedMotion;
  8595. exports.usePreferredReducedTransparency = usePreferredReducedTransparency;
  8596. exports.usePrevious = usePrevious;
  8597. exports.useRafFn = useRafFn;
  8598. exports.useRefHistory = useRefHistory;
  8599. exports.useResizeObserver = useResizeObserver;
  8600. exports.useSSRWidth = useSSRWidth;
  8601. exports.useScreenOrientation = useScreenOrientation;
  8602. exports.useScreenSafeArea = useScreenSafeArea;
  8603. exports.useScriptTag = useScriptTag;
  8604. exports.useScroll = useScroll;
  8605. exports.useScrollLock = useScrollLock;
  8606. exports.useSessionStorage = useSessionStorage;
  8607. exports.useShare = useShare;
  8608. exports.useSorted = useSorted;
  8609. exports.useSpeechRecognition = useSpeechRecognition;
  8610. exports.useSpeechSynthesis = useSpeechSynthesis;
  8611. exports.useStepper = useStepper;
  8612. exports.useStorage = useStorage;
  8613. exports.useStorageAsync = useStorageAsync;
  8614. exports.useStyleTag = useStyleTag;
  8615. exports.useSupported = useSupported;
  8616. exports.useSwipe = useSwipe;
  8617. exports.useTemplateRefsList = useTemplateRefsList;
  8618. exports.useTextDirection = useTextDirection;
  8619. exports.useTextSelection = useTextSelection;
  8620. exports.useTextareaAutosize = useTextareaAutosize;
  8621. exports.useThrottledRefHistory = useThrottledRefHistory;
  8622. exports.useTimeAgo = useTimeAgo;
  8623. exports.useTimeAgoIntl = useTimeAgoIntl;
  8624. exports.useTimeoutPoll = useTimeoutPoll;
  8625. exports.useTimestamp = useTimestamp;
  8626. exports.useTitle = useTitle;
  8627. exports.useTransition = useTransition;
  8628. exports.useUrlSearchParams = useUrlSearchParams;
  8629. exports.useUserMedia = useUserMedia;
  8630. exports.useVModel = useVModel;
  8631. exports.useVModels = useVModels;
  8632. exports.useVibrate = useVibrate;
  8633. exports.useVirtualList = useVirtualList;
  8634. exports.useWakeLock = useWakeLock;
  8635. exports.useWebNotification = useWebNotification;
  8636. exports.useWebSocket = useWebSocket;
  8637. exports.useWebWorker = useWebWorker;
  8638. exports.useWebWorkerFn = useWebWorkerFn;
  8639. exports.useWindowFocus = useWindowFocus;
  8640. exports.useWindowScroll = useWindowScroll;
  8641. exports.useWindowSize = useWindowSize;
  8642. Object.keys(_vueuse_shared).forEach(function(k) {
  8643. if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
  8644. enumerable: true,
  8645. get: function() {
  8646. return _vueuse_shared[k];
  8647. }
  8648. });
  8649. });
  8650. })(this.VueUse = this.VueUse || {}, VueUse, Vue);