@vueuse_core.js 255 KB

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