@vueuse_core.js 269 KB

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