uni-h5.es.js 721 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868
  1. import { withModifiers, createVNode, getCurrentInstance, ref, defineComponent, openBlock, createElementBlock, provide, computed, watch, onUnmounted, inject, onBeforeUnmount, mergeProps, injectHook, reactive, onActivated, onMounted, nextTick, onBeforeMount, withDirectives, vModelDynamic, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, Comment, h, createTextVNode, createBlock, onBeforeActivate, onBeforeDeactivate, renderList, onDeactivated, createApp, isReactive, Transition, effectScope, withCtx, KeepAlive, resolveDynamicComponent, createElementVNode, normalizeStyle, renderSlot } from "vue";
  2. import { isArray, isString, extend, remove, stringifyStyle, parseStringStyle, isPlainObject, isFunction, capitalize, camelize, hasOwn, isObject, toRawType, makeMap as makeMap$1, isPromise, hyphenate, invokeArrayFns as invokeArrayFns$1 } from "@vue/shared";
  3. import { once, UNI_STORAGE_LOCALE, I18N_JSON_DELIMITERS, Emitter, passive, initCustomDatasetOnce, resolveComponentInstance, normalizeStyles, addLeadingSlash, invokeArrayFns, removeLeadingSlash, resolveOwnerVm, resolveOwnerEl, ON_WXS_INVOKE_CALL_METHOD, normalizeTarget, ON_RESIZE, ON_APP_ENTER_FOREGROUND, ON_APP_ENTER_BACKGROUND, ON_SHOW, ON_HIDE, ON_PAGE_SCROLL, ON_REACH_BOTTOM, EventChannel, SCHEME_RE, DATA_RE, getCustomDataset, LINEFEED, ON_ERROR, callOptions, ON_UNHANDLE_REJECTION, ON_PAGE_NOT_FOUND, PRIMARY_COLOR, getLen, debounce, isUniLifecycleHook, ON_LOAD, UniLifecycleHooks, invokeCreateErrorHandler, invokeCreateVueAppHook, parseQuery, NAVBAR_HEIGHT, ON_UNLOAD, ON_REACH_BOTTOM_DISTANCE, decodedQuery, WEB_INVOKE_APPSERVICE, ON_WEB_INVOKE_APP_SERVICE, ON_THEME_CHANGE, updateElementStyle, sortObject, OFF_THEME_CHANGE, ON_BACK_PRESS, parseUrl, addFont, ON_NAVIGATION_BAR_CHANGE, scrollTo, RESPONSIVE_MIN_WIDTH, onCreateVueApp, formatDateTime, ON_NAVIGATION_BAR_BUTTON_TAP, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, ON_PULL_DOWN_REFRESH } from "@dcloudio/uni-shared";
  4. import { onCreateVueApp as onCreateVueApp2 } from "@dcloudio/uni-shared";
  5. import { initVueI18n, isI18nStr, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT } from "@dcloudio/uni-i18n";
  6. import { useRoute, createRouter, createWebHistory, createWebHashHistory, useRouter, isNavigationFailure, RouterView } from "vue-router";
  7. const isEnableLocale = /* @__PURE__ */ once(
  8. () => typeof __uniConfig !== "undefined" && __uniConfig.locales && !!Object.keys(__uniConfig.locales).length
  9. );
  10. let i18n;
  11. function getLocaleMessage() {
  12. const locale = uni.getLocale();
  13. const locales = __uniConfig.locales;
  14. return locales[locale] || locales[__uniConfig.fallbackLocale] || locales.en || {};
  15. }
  16. function formatI18n(message) {
  17. if (isI18nStr(message, I18N_JSON_DELIMITERS)) {
  18. return useI18n().f(message, getLocaleMessage(), I18N_JSON_DELIMITERS);
  19. }
  20. return message;
  21. }
  22. function resolveJsonObj(jsonObj, names) {
  23. if (names.length === 1) {
  24. if (jsonObj) {
  25. const _isI18nStr = (value2) => isString(value2) && isI18nStr(value2, I18N_JSON_DELIMITERS);
  26. const _name = names[0];
  27. let filterJsonObj = [];
  28. if (isArray(jsonObj) && (filterJsonObj = jsonObj.filter((item) => _isI18nStr(item[_name]))).length) {
  29. return filterJsonObj;
  30. }
  31. const value = jsonObj[names[0]];
  32. if (_isI18nStr(value)) {
  33. return jsonObj;
  34. }
  35. }
  36. return;
  37. }
  38. const name = names.shift();
  39. return resolveJsonObj(jsonObj && jsonObj[name], names);
  40. }
  41. function defineI18nProperties(obj, names) {
  42. return names.map((name) => defineI18nProperty(obj, name));
  43. }
  44. function defineI18nProperty(obj, names) {
  45. const jsonObj = resolveJsonObj(obj, names);
  46. if (!jsonObj) {
  47. return false;
  48. }
  49. const prop = names[names.length - 1];
  50. if (isArray(jsonObj)) {
  51. jsonObj.forEach((item) => defineI18nProperty(item, [prop]));
  52. } else {
  53. let value = jsonObj[prop];
  54. Object.defineProperty(jsonObj, prop, {
  55. get() {
  56. return formatI18n(value);
  57. },
  58. set(v2) {
  59. value = v2;
  60. }
  61. });
  62. }
  63. return true;
  64. }
  65. function useI18n() {
  66. if (!i18n) {
  67. let locale;
  68. {
  69. {
  70. locale = navigator.cookieEnabled && window.localStorage && localStorage[UNI_STORAGE_LOCALE] || __uniConfig.locale || navigator.language;
  71. }
  72. }
  73. i18n = initVueI18n(locale);
  74. if (isEnableLocale()) {
  75. const localeKeys = Object.keys(__uniConfig.locales || {});
  76. if (localeKeys.length) {
  77. localeKeys.forEach(
  78. (locale2) => i18n.add(locale2, __uniConfig.locales[locale2])
  79. );
  80. }
  81. i18n.setLocale(locale);
  82. }
  83. }
  84. return i18n;
  85. }
  86. function normalizeMessages(module, keys, values) {
  87. return keys.reduce((res, name, index2) => {
  88. res[module + name] = values[index2];
  89. return res;
  90. }, {});
  91. }
  92. const initI18nAsyncMsgsOnce = /* @__PURE__ */ once(() => {
  93. const name = "uni.async.";
  94. const keys = ["error"];
  95. if (__UNI_FEATURE_I18N_EN__) {
  96. useI18n().add(
  97. LOCALE_EN,
  98. normalizeMessages(name, keys, [
  99. "The connection timed out, click the screen to try again."
  100. ]),
  101. false
  102. );
  103. }
  104. if (__UNI_FEATURE_I18N_ES__) {
  105. useI18n().add(
  106. LOCALE_ES,
  107. normalizeMessages(name, keys, [
  108. "Se agotó el tiempo de conexión, haga clic en la pantalla para volver a intentarlo."
  109. ]),
  110. false
  111. );
  112. }
  113. if (__UNI_FEATURE_I18N_FR__) {
  114. useI18n().add(
  115. LOCALE_FR,
  116. normalizeMessages(name, keys, [
  117. "La connexion a expiré, cliquez sur l'écran pour réessayer."
  118. ]),
  119. false
  120. );
  121. }
  122. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  123. useI18n().add(
  124. LOCALE_ZH_HANS,
  125. normalizeMessages(name, keys, ["连接服务器超时,点击屏幕重试"]),
  126. false
  127. );
  128. }
  129. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  130. useI18n().add(
  131. LOCALE_ZH_HANT,
  132. normalizeMessages(name, keys, ["連接服務器超時,點擊屏幕重試"]),
  133. false
  134. );
  135. }
  136. });
  137. const initI18nShowActionSheetMsgsOnce = /* @__PURE__ */ once(() => {
  138. const name = "uni.showActionSheet.";
  139. const keys = ["cancel"];
  140. if (__UNI_FEATURE_I18N_EN__) {
  141. useI18n().add(LOCALE_EN, normalizeMessages(name, keys, ["Cancel"]), false);
  142. }
  143. if (__UNI_FEATURE_I18N_ES__) {
  144. useI18n().add(LOCALE_ES, normalizeMessages(name, keys, ["Cancelar"]), false);
  145. }
  146. if (__UNI_FEATURE_I18N_FR__) {
  147. useI18n().add(LOCALE_FR, normalizeMessages(name, keys, ["Annuler"]), false);
  148. }
  149. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  150. useI18n().add(
  151. LOCALE_ZH_HANS,
  152. normalizeMessages(name, keys, ["取消"]),
  153. false
  154. );
  155. }
  156. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  157. useI18n().add(
  158. LOCALE_ZH_HANT,
  159. normalizeMessages(name, keys, ["取消"]),
  160. false
  161. );
  162. }
  163. });
  164. const initI18nShowToastMsgsOnce = /* @__PURE__ */ once(() => {
  165. const name = "uni.showToast.";
  166. const keys = ["unpaired"];
  167. if (__UNI_FEATURE_I18N_EN__) {
  168. useI18n().add(
  169. LOCALE_EN,
  170. normalizeMessages(name, keys, [
  171. "Please note showToast must be paired with hideToast"
  172. ]),
  173. false
  174. );
  175. }
  176. if (__UNI_FEATURE_I18N_ES__) {
  177. useI18n().add(
  178. LOCALE_ES,
  179. normalizeMessages(name, keys, [
  180. "Tenga en cuenta que showToast debe estar emparejado con hideToast"
  181. ]),
  182. false
  183. );
  184. }
  185. if (__UNI_FEATURE_I18N_FR__) {
  186. useI18n().add(
  187. LOCALE_FR,
  188. normalizeMessages(name, keys, [
  189. "Veuillez noter que showToast doit être associé à hideToast"
  190. ]),
  191. false
  192. );
  193. }
  194. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  195. useI18n().add(
  196. LOCALE_ZH_HANS,
  197. normalizeMessages(name, keys, [
  198. "请注意 showToast 与 hideToast 必须配对使用"
  199. ]),
  200. false
  201. );
  202. }
  203. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  204. useI18n().add(
  205. LOCALE_ZH_HANT,
  206. normalizeMessages(name, keys, [
  207. "請注意 showToast 與 hideToast 必須配對使用"
  208. ]),
  209. false
  210. );
  211. }
  212. });
  213. const initI18nShowLoadingMsgsOnce = /* @__PURE__ */ once(() => {
  214. const name = "uni.showLoading.";
  215. const keys = ["unpaired"];
  216. if (__UNI_FEATURE_I18N_EN__) {
  217. useI18n().add(
  218. LOCALE_EN,
  219. normalizeMessages(name, keys, [
  220. "Please note showLoading must be paired with hideLoading"
  221. ]),
  222. false
  223. );
  224. }
  225. if (__UNI_FEATURE_I18N_ES__) {
  226. useI18n().add(
  227. LOCALE_ES,
  228. normalizeMessages(name, keys, [
  229. "Tenga en cuenta que showLoading debe estar emparejado con hideLoading"
  230. ]),
  231. false
  232. );
  233. }
  234. if (__UNI_FEATURE_I18N_FR__) {
  235. useI18n().add(
  236. LOCALE_FR,
  237. normalizeMessages(name, keys, [
  238. "Veuillez noter que showLoading doit être associé à hideLoading"
  239. ]),
  240. false
  241. );
  242. }
  243. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  244. useI18n().add(
  245. LOCALE_ZH_HANS,
  246. normalizeMessages(name, keys, [
  247. "请注意 showLoading 与 hideLoading 必须配对使用"
  248. ]),
  249. false
  250. );
  251. }
  252. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  253. useI18n().add(
  254. LOCALE_ZH_HANT,
  255. normalizeMessages(name, keys, [
  256. "請注意 showLoading 與 hideLoading 必須配對使用"
  257. ]),
  258. false
  259. );
  260. }
  261. });
  262. const initI18nShowModalMsgsOnce = /* @__PURE__ */ once(() => {
  263. const name = "uni.showModal.";
  264. const keys = ["cancel", "confirm"];
  265. if (__UNI_FEATURE_I18N_EN__) {
  266. useI18n().add(
  267. LOCALE_EN,
  268. normalizeMessages(name, keys, ["Cancel", "OK"]),
  269. false
  270. );
  271. }
  272. if (__UNI_FEATURE_I18N_ES__) {
  273. useI18n().add(
  274. LOCALE_ES,
  275. normalizeMessages(name, keys, ["Cancelar", "OK"]),
  276. false
  277. );
  278. }
  279. if (__UNI_FEATURE_I18N_FR__) {
  280. useI18n().add(
  281. LOCALE_FR,
  282. normalizeMessages(name, keys, ["Annuler", "OK"]),
  283. false
  284. );
  285. }
  286. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  287. useI18n().add(
  288. LOCALE_ZH_HANS,
  289. normalizeMessages(name, keys, ["取消", "确定"]),
  290. false
  291. );
  292. }
  293. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  294. useI18n().add(
  295. LOCALE_ZH_HANT,
  296. normalizeMessages(name, keys, ["取消", "確定"]),
  297. false
  298. );
  299. }
  300. });
  301. const initI18nChooseFileMsgsOnce = /* @__PURE__ */ once(() => {
  302. const name = "uni.chooseFile.";
  303. const keys = ["notUserActivation"];
  304. if (__UNI_FEATURE_I18N_EN__) {
  305. useI18n().add(
  306. LOCALE_EN,
  307. normalizeMessages(name, keys, [
  308. "File chooser dialog can only be shown with a user activation"
  309. ]),
  310. false
  311. );
  312. }
  313. if (__UNI_FEATURE_I18N_ES__) {
  314. useI18n().add(
  315. LOCALE_ES,
  316. normalizeMessages(name, keys, [
  317. "El cuadro de diálogo del selector de archivos solo se puede mostrar con la activación del usuario"
  318. ]),
  319. false
  320. );
  321. }
  322. if (__UNI_FEATURE_I18N_FR__) {
  323. useI18n().add(
  324. LOCALE_FR,
  325. normalizeMessages(name, keys, [
  326. "La boîte de dialogue du sélecteur de fichier ne peut être affichée qu'avec une activation par l'utilisateur"
  327. ]),
  328. false
  329. );
  330. }
  331. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  332. useI18n().add(
  333. LOCALE_ZH_HANS,
  334. normalizeMessages(name, keys, ["文件选择器对话框只能在由用户激活时显示"]),
  335. false
  336. );
  337. }
  338. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  339. useI18n().add(
  340. LOCALE_ZH_HANT,
  341. normalizeMessages(name, keys, ["文件選擇器對話框只能在由用戶激活時顯示"]),
  342. false
  343. );
  344. }
  345. });
  346. const initI18nSetClipboardDataMsgsOnce = /* @__PURE__ */ once(() => {
  347. const name = "uni.setClipboardData.";
  348. const keys = ["success", "fail"];
  349. if (__UNI_FEATURE_I18N_EN__) {
  350. useI18n().add(
  351. LOCALE_EN,
  352. normalizeMessages(name, keys, [
  353. "Content copied",
  354. "Copy failed, please copy manually"
  355. ]),
  356. false
  357. );
  358. }
  359. if (__UNI_FEATURE_I18N_ES__) {
  360. useI18n().add(
  361. LOCALE_ES,
  362. normalizeMessages(name, keys, [
  363. "Contenido copiado",
  364. "Error al copiar, copie manualmente"
  365. ]),
  366. false
  367. );
  368. }
  369. if (__UNI_FEATURE_I18N_FR__) {
  370. useI18n().add(
  371. LOCALE_FR,
  372. normalizeMessages(name, keys, [
  373. "Contenu copié",
  374. "Échec de la copie, copiez manuellement"
  375. ]),
  376. false
  377. );
  378. }
  379. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  380. useI18n().add(
  381. LOCALE_ZH_HANS,
  382. normalizeMessages(name, keys, ["内容已复制", "复制失败,请手动复制"]),
  383. false
  384. );
  385. }
  386. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  387. useI18n().add(
  388. LOCALE_ZH_HANT,
  389. normalizeMessages(name, keys, ["內容已復制", "復制失敗,請手動復製"]),
  390. false
  391. );
  392. }
  393. });
  394. const initI18nGetClipboardDataMsgsOnce = /* @__PURE__ */ once(() => {
  395. const name = "uni.getClipboardData.";
  396. const keys = ["fail"];
  397. if (__UNI_FEATURE_I18N_EN__) {
  398. useI18n().add(
  399. LOCALE_EN,
  400. normalizeMessages(name, keys, ["Reading failed, please paste manually"]),
  401. false
  402. );
  403. }
  404. if (__UNI_FEATURE_I18N_ES__) {
  405. useI18n().add(
  406. LOCALE_ES,
  407. normalizeMessages(name, keys, ["Error de lectura, pegue manualmente"]),
  408. false
  409. );
  410. }
  411. if (__UNI_FEATURE_I18N_FR__) {
  412. useI18n().add(
  413. LOCALE_FR,
  414. normalizeMessages(name, keys, [
  415. "Échec de la lecture, veuillez coller manuellement"
  416. ]),
  417. false
  418. );
  419. }
  420. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  421. useI18n().add(
  422. LOCALE_ZH_HANS,
  423. normalizeMessages(name, keys, ["读取失败,请手动粘贴"]),
  424. false
  425. );
  426. }
  427. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  428. useI18n().add(
  429. LOCALE_ZH_HANT,
  430. normalizeMessages(name, keys, ["讀取失敗,請手動粘貼"]),
  431. false
  432. );
  433. }
  434. });
  435. const initI18nPickerMsgsOnce = /* @__PURE__ */ once(() => {
  436. const name = "uni.picker.";
  437. const keys = ["done", "cancel"];
  438. if (__UNI_FEATURE_I18N_EN__) {
  439. useI18n().add(
  440. LOCALE_EN,
  441. normalizeMessages(name, keys, ["Done", "Cancel"]),
  442. false
  443. );
  444. }
  445. if (__UNI_FEATURE_I18N_ES__) {
  446. useI18n().add(
  447. LOCALE_ES,
  448. normalizeMessages(name, keys, ["OK", "Cancelar"]),
  449. false
  450. );
  451. }
  452. if (__UNI_FEATURE_I18N_FR__) {
  453. useI18n().add(
  454. LOCALE_FR,
  455. normalizeMessages(name, keys, ["OK", "Annuler"]),
  456. false
  457. );
  458. }
  459. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  460. useI18n().add(
  461. LOCALE_ZH_HANS,
  462. normalizeMessages(name, keys, ["完成", "取消"]),
  463. false
  464. );
  465. }
  466. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  467. useI18n().add(
  468. LOCALE_ZH_HANT,
  469. normalizeMessages(name, keys, ["完成", "取消"]),
  470. false
  471. );
  472. }
  473. });
  474. const initI18nVideoMsgsOnce = /* @__PURE__ */ once(() => {
  475. const name = "uni.video.";
  476. const keys = ["danmu", "volume"];
  477. if (__UNI_FEATURE_I18N_EN__) {
  478. useI18n().add(
  479. LOCALE_EN,
  480. normalizeMessages(name, keys, ["Danmu", "Volume"]),
  481. false
  482. );
  483. }
  484. if (__UNI_FEATURE_I18N_ES__) {
  485. useI18n().add(
  486. LOCALE_ES,
  487. normalizeMessages(name, keys, ["Danmu", "Volumen"]),
  488. false
  489. );
  490. }
  491. if (__UNI_FEATURE_I18N_FR__) {
  492. useI18n().add(
  493. LOCALE_FR,
  494. normalizeMessages(name, keys, ["Danmu", "Le Volume"]),
  495. false
  496. );
  497. }
  498. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  499. useI18n().add(
  500. LOCALE_ZH_HANS,
  501. normalizeMessages(name, keys, ["弹幕", "音量"]),
  502. false
  503. );
  504. }
  505. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  506. useI18n().add(
  507. LOCALE_ZH_HANT,
  508. normalizeMessages(name, keys, ["彈幕", "音量"]),
  509. false
  510. );
  511. }
  512. });
  513. const initI18nChooseLocationMsgsOnce = /* @__PURE__ */ once(() => {
  514. const name = "uni.chooseLocation.";
  515. const keys = ["search", "cancel"];
  516. if (__UNI_FEATURE_I18N_EN__) {
  517. useI18n().add(
  518. LOCALE_EN,
  519. normalizeMessages(name, keys, ["Find Place", "Cancel"]),
  520. false
  521. );
  522. }
  523. if (__UNI_FEATURE_I18N_ES__) {
  524. useI18n().add(
  525. LOCALE_ES,
  526. normalizeMessages(name, keys, ["Encontrar", "Cancelar"]),
  527. false
  528. );
  529. }
  530. if (__UNI_FEATURE_I18N_FR__) {
  531. useI18n().add(
  532. LOCALE_FR,
  533. normalizeMessages(name, keys, ["Trouve", "Annuler"]),
  534. false
  535. );
  536. }
  537. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  538. useI18n().add(
  539. LOCALE_ZH_HANS,
  540. normalizeMessages(name, keys, ["搜索地点", "取消"]),
  541. false
  542. );
  543. }
  544. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  545. useI18n().add(
  546. LOCALE_ZH_HANT,
  547. normalizeMessages(name, keys, ["搜索地點", "取消"]),
  548. false
  549. );
  550. }
  551. });
  552. function initNavigationBarI18n(navigationBar) {
  553. if (isEnableLocale()) {
  554. return defineI18nProperties(navigationBar, [
  555. ["titleText"],
  556. ["searchInput", "placeholder"],
  557. ["buttons", "text"]
  558. ]);
  559. }
  560. }
  561. function initTabBarI18n(tabBar2) {
  562. if (isEnableLocale() && tabBar2.list) {
  563. tabBar2.list.forEach((item) => {
  564. defineI18nProperty(item, ["text"]);
  565. });
  566. }
  567. return tabBar2;
  568. }
  569. function initBridge(subscribeNamespace) {
  570. const emitter2 = new Emitter();
  571. return {
  572. on(event, callback) {
  573. return emitter2.on(event, callback);
  574. },
  575. once(event, callback) {
  576. return emitter2.once(event, callback);
  577. },
  578. off(event, callback) {
  579. return emitter2.off(event, callback);
  580. },
  581. emit(event, ...args) {
  582. return emitter2.emit(event, ...args);
  583. },
  584. subscribe(event, callback, once2 = false) {
  585. emitter2[once2 ? "once" : "on"](`${subscribeNamespace}.${event}`, callback);
  586. },
  587. unsubscribe(event, callback) {
  588. emitter2.off(`${subscribeNamespace}.${event}`, callback);
  589. },
  590. subscribeHandler(event, args, pageId) {
  591. emitter2.emit(`${subscribeNamespace}.${event}`, args, pageId);
  592. }
  593. };
  594. }
  595. const INVOKE_VIEW_API = "invokeViewApi";
  596. const INVOKE_SERVICE_API = "invokeServiceApi";
  597. let invokeServiceMethodId = 1;
  598. const invokeServiceMethod = (name, args, callback) => {
  599. const { subscribe, publishHandler } = UniViewJSBridge;
  600. const id2 = callback ? invokeServiceMethodId++ : 0;
  601. callback && subscribe(INVOKE_SERVICE_API + "." + id2, callback, true);
  602. publishHandler(INVOKE_SERVICE_API, { id: id2, name, args });
  603. };
  604. const viewMethods = /* @__PURE__ */ Object.create(null);
  605. function normalizeViewMethodName(pageId, name) {
  606. return pageId + "." + name;
  607. }
  608. function subscribeViewMethod(pageId, wrapper2) {
  609. UniViewJSBridge.subscribe(
  610. normalizeViewMethodName(pageId, INVOKE_VIEW_API),
  611. wrapper2 ? wrapper2(onInvokeViewMethod) : onInvokeViewMethod
  612. );
  613. }
  614. function unsubscribeViewMethod(pageId) {
  615. UniViewJSBridge.unsubscribe(normalizeViewMethodName(pageId, INVOKE_VIEW_API));
  616. Object.keys(viewMethods).forEach((name) => {
  617. if (name.indexOf(pageId + ".") === 0) {
  618. delete viewMethods[name];
  619. }
  620. });
  621. }
  622. function registerViewMethod(pageId, name, fn) {
  623. name = normalizeViewMethodName(pageId, name);
  624. if (!viewMethods[name]) {
  625. viewMethods[name] = fn;
  626. }
  627. }
  628. function unregisterViewMethod(pageId, name) {
  629. name = normalizeViewMethodName(pageId, name);
  630. delete viewMethods[name];
  631. }
  632. function onInvokeViewMethod({
  633. id: id2,
  634. name,
  635. args
  636. }, pageId) {
  637. name = normalizeViewMethodName(pageId, name);
  638. const publish = (res) => {
  639. id2 && UniViewJSBridge.publishHandler(INVOKE_VIEW_API + "." + id2, res);
  640. };
  641. const handler = viewMethods[name];
  642. if (handler) {
  643. handler(args, publish);
  644. } else {
  645. publish({});
  646. }
  647. }
  648. const ViewJSBridge = /* @__PURE__ */ extend(
  649. /* @__PURE__ */ initBridge("service"),
  650. {
  651. invokeServiceMethod
  652. }
  653. );
  654. const LONGPRESS_TIMEOUT = 350;
  655. const LONGPRESS_THRESHOLD = 10;
  656. const passiveOptions$2 = /* @__PURE__ */ passive(true);
  657. let longPressTimer;
  658. function clearLongPressTimer() {
  659. if (longPressTimer) {
  660. clearTimeout(longPressTimer);
  661. longPressTimer = null;
  662. }
  663. }
  664. let startPageX = 0;
  665. let startPageY = 0;
  666. function touchstart(evt) {
  667. clearLongPressTimer();
  668. if (evt.touches.length !== 1) {
  669. return;
  670. }
  671. const { pageX, pageY } = evt.touches[0];
  672. startPageX = pageX;
  673. startPageY = pageY;
  674. longPressTimer = setTimeout(function() {
  675. const customEvent = new CustomEvent("longpress", {
  676. bubbles: true,
  677. cancelable: true,
  678. // @ts-ignore
  679. target: evt.target,
  680. currentTarget: evt.currentTarget
  681. });
  682. customEvent.touches = evt.touches;
  683. customEvent.changedTouches = evt.changedTouches;
  684. evt.target.dispatchEvent(customEvent);
  685. }, LONGPRESS_TIMEOUT);
  686. }
  687. function touchmove(evt) {
  688. if (!longPressTimer) {
  689. return;
  690. }
  691. if (evt.touches.length !== 1) {
  692. return clearLongPressTimer();
  693. }
  694. const { pageX, pageY } = evt.touches[0];
  695. if (Math.abs(pageX - startPageX) > LONGPRESS_THRESHOLD || Math.abs(pageY - startPageY) > LONGPRESS_THRESHOLD) {
  696. return clearLongPressTimer();
  697. }
  698. }
  699. function initLongPress() {
  700. window.addEventListener("touchstart", touchstart, passiveOptions$2);
  701. window.addEventListener("touchmove", touchmove, passiveOptions$2);
  702. window.addEventListener("touchend", clearLongPressTimer, passiveOptions$2);
  703. window.addEventListener("touchcancel", clearLongPressTimer, passiveOptions$2);
  704. }
  705. function checkValue$1(value, defaultValue) {
  706. const newValue = Number(value);
  707. return isNaN(newValue) ? defaultValue : newValue;
  708. }
  709. function getWindowWidth$1() {
  710. const screenFix = /^Apple/.test(navigator.vendor) && typeof window.orientation === "number";
  711. const landscape = screenFix && Math.abs(window.orientation) === 90;
  712. var screenWidth = screenFix ? Math[landscape ? "max" : "min"](screen.width, screen.height) : screen.width;
  713. var windowWidth = Math.min(
  714. window.innerWidth,
  715. document.documentElement.clientWidth,
  716. screenWidth
  717. ) || screenWidth;
  718. return windowWidth;
  719. }
  720. function useRem() {
  721. const config = __uniConfig.globalStyle || {};
  722. const maxWidth2 = checkValue$1(config.rpxCalcMaxDeviceWidth, 960);
  723. const baseWidth2 = checkValue$1(config.rpxCalcBaseDeviceWidth, 375);
  724. function updateRem() {
  725. let width = getWindowWidth$1();
  726. width = width <= maxWidth2 ? width : baseWidth2;
  727. document.documentElement.style.fontSize = width / 23.4375 + "px";
  728. }
  729. updateRem();
  730. document.addEventListener("DOMContentLoaded", updateRem);
  731. window.addEventListener("load", updateRem);
  732. window.addEventListener("resize", updateRem);
  733. }
  734. function initView() {
  735. useRem();
  736. initCustomDatasetOnce();
  737. if (__UNI_FEATURE_LONGPRESS__) {
  738. initLongPress();
  739. }
  740. }
  741. function getDefaultExportFromCjs(x) {
  742. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
  743. }
  744. var attrs = ["top", "left", "right", "bottom"];
  745. var inited$1;
  746. var elementComputedStyle = {};
  747. var support;
  748. function getSupport() {
  749. if (!("CSS" in window) || typeof CSS.supports != "function") {
  750. support = "";
  751. } else if (CSS.supports("top: env(safe-area-inset-top)")) {
  752. support = "env";
  753. } else if (CSS.supports("top: constant(safe-area-inset-top)")) {
  754. support = "constant";
  755. } else {
  756. support = "";
  757. }
  758. return support;
  759. }
  760. function init() {
  761. support = typeof support === "string" ? support : getSupport();
  762. if (!support) {
  763. attrs.forEach(function(attr2) {
  764. elementComputedStyle[attr2] = 0;
  765. });
  766. return;
  767. }
  768. function setStyle(el, style) {
  769. var elStyle = el.style;
  770. Object.keys(style).forEach(function(key) {
  771. var val = style[key];
  772. elStyle[key] = val;
  773. });
  774. }
  775. var cbs = [];
  776. function parentReady(callback) {
  777. if (callback) {
  778. cbs.push(callback);
  779. } else {
  780. cbs.forEach(function(cb) {
  781. cb();
  782. });
  783. }
  784. }
  785. var passiveEvents = false;
  786. try {
  787. var opts = Object.defineProperty({}, "passive", {
  788. get: function() {
  789. passiveEvents = { passive: true };
  790. }
  791. });
  792. window.addEventListener("test", null, opts);
  793. } catch (e2) {
  794. }
  795. function addChild(parent, attr2) {
  796. var a1 = document.createElement("div");
  797. var a2 = document.createElement("div");
  798. var a1Children = document.createElement("div");
  799. var a2Children = document.createElement("div");
  800. var W = 100;
  801. var MAX = 1e4;
  802. var aStyle = {
  803. position: "absolute",
  804. width: W + "px",
  805. height: "200px",
  806. boxSizing: "border-box",
  807. overflow: "hidden",
  808. paddingBottom: support + "(safe-area-inset-" + attr2 + ")"
  809. };
  810. setStyle(a1, aStyle);
  811. setStyle(a2, aStyle);
  812. setStyle(a1Children, {
  813. transition: "0s",
  814. animation: "none",
  815. width: "400px",
  816. height: "400px"
  817. });
  818. setStyle(a2Children, {
  819. transition: "0s",
  820. animation: "none",
  821. width: "250%",
  822. height: "250%"
  823. });
  824. a1.appendChild(a1Children);
  825. a2.appendChild(a2Children);
  826. parent.appendChild(a1);
  827. parent.appendChild(a2);
  828. parentReady(function() {
  829. a1.scrollTop = a2.scrollTop = MAX;
  830. var a1LastScrollTop = a1.scrollTop;
  831. var a2LastScrollTop = a2.scrollTop;
  832. function onScroll() {
  833. if (this.scrollTop === (this === a1 ? a1LastScrollTop : a2LastScrollTop)) {
  834. return;
  835. }
  836. a1.scrollTop = a2.scrollTop = MAX;
  837. a1LastScrollTop = a1.scrollTop;
  838. a2LastScrollTop = a2.scrollTop;
  839. attrChange(attr2);
  840. }
  841. a1.addEventListener("scroll", onScroll, passiveEvents);
  842. a2.addEventListener("scroll", onScroll, passiveEvents);
  843. });
  844. var computedStyle = getComputedStyle(a1);
  845. Object.defineProperty(elementComputedStyle, attr2, {
  846. configurable: true,
  847. get: function() {
  848. return parseFloat(computedStyle.paddingBottom);
  849. }
  850. });
  851. }
  852. var parentDiv = document.createElement("div");
  853. setStyle(parentDiv, {
  854. position: "absolute",
  855. left: "0",
  856. top: "0",
  857. width: "0",
  858. height: "0",
  859. zIndex: "-1",
  860. overflow: "hidden",
  861. visibility: "hidden"
  862. });
  863. attrs.forEach(function(key) {
  864. addChild(parentDiv, key);
  865. });
  866. document.body.appendChild(parentDiv);
  867. parentReady();
  868. inited$1 = true;
  869. }
  870. function getAttr(attr2) {
  871. if (!inited$1) {
  872. init();
  873. }
  874. return elementComputedStyle[attr2];
  875. }
  876. var changeAttrs = [];
  877. function attrChange(attr2) {
  878. if (!changeAttrs.length) {
  879. setTimeout(function() {
  880. var style = {};
  881. changeAttrs.forEach(function(attr3) {
  882. style[attr3] = elementComputedStyle[attr3];
  883. });
  884. changeAttrs.length = 0;
  885. callbacks.forEach(function(callback) {
  886. callback(style);
  887. });
  888. }, 0);
  889. }
  890. changeAttrs.push(attr2);
  891. }
  892. var callbacks = [];
  893. function onChange(callback) {
  894. if (!getSupport()) {
  895. return;
  896. }
  897. if (!inited$1) {
  898. init();
  899. }
  900. if (typeof callback === "function") {
  901. callbacks.push(callback);
  902. }
  903. }
  904. function offChange(callback) {
  905. var index2 = callbacks.indexOf(callback);
  906. if (index2 >= 0) {
  907. callbacks.splice(index2, 1);
  908. }
  909. }
  910. var safeAreaInsets = {
  911. get support() {
  912. return (typeof support === "string" ? support : getSupport()).length != 0;
  913. },
  914. get top() {
  915. return getAttr("top");
  916. },
  917. get left() {
  918. return getAttr("left");
  919. },
  920. get right() {
  921. return getAttr("right");
  922. },
  923. get bottom() {
  924. return getAttr("bottom");
  925. },
  926. onChange,
  927. offChange
  928. };
  929. var out = safeAreaInsets;
  930. const safeAreaInsets$1 = /* @__PURE__ */ getDefaultExportFromCjs(out);
  931. const onEventPrevent = /* @__PURE__ */ withModifiers(() => {
  932. }, ["prevent"]);
  933. const onEventStop = /* @__PURE__ */ withModifiers(
  934. (_event) => {
  935. },
  936. ["stop"]
  937. );
  938. function getWindowOffsetCssVar(style, name) {
  939. return parseInt((style.getPropertyValue(name).match(/\d+/) || ["0"])[0]);
  940. }
  941. function getWindowTop() {
  942. const style = document.documentElement.style;
  943. const top = getWindowOffsetCssVar(style, "--window-top");
  944. return top ? top + safeAreaInsets$1.top : 0;
  945. }
  946. function getWindowOffset() {
  947. const style = document.documentElement.style;
  948. const top = getWindowTop();
  949. const bottom = getWindowOffsetCssVar(style, "--window-bottom");
  950. const left = getWindowOffsetCssVar(style, "--window-left");
  951. const right = getWindowOffsetCssVar(style, "--window-right");
  952. const topWindowHeight = getWindowOffsetCssVar(style, "--top-window-height");
  953. return {
  954. top,
  955. bottom: bottom ? bottom + safeAreaInsets$1.bottom : 0,
  956. left: left ? left + safeAreaInsets$1.left : 0,
  957. right: right ? right + safeAreaInsets$1.right : 0,
  958. topWindowHeight: topWindowHeight || 0
  959. };
  960. }
  961. function updateCssVar(cssVars) {
  962. const style = document.documentElement.style;
  963. Object.keys(cssVars).forEach((name) => {
  964. style.setProperty(name, cssVars[name]);
  965. });
  966. }
  967. function updatePageCssVar(cssVars) {
  968. return updateCssVar(cssVars);
  969. }
  970. const sheetsMap = /* @__PURE__ */ new Map();
  971. function updateStyle(id2, content) {
  972. let style = sheetsMap.get(id2);
  973. if (style && !(style instanceof HTMLStyleElement)) {
  974. removeStyle(id2);
  975. style = void 0;
  976. }
  977. if (!style) {
  978. style = document.createElement("style");
  979. style.setAttribute("type", "text/css");
  980. style.innerHTML = content;
  981. document.head.appendChild(style);
  982. } else {
  983. style.innerHTML = content;
  984. }
  985. sheetsMap.set(id2, style);
  986. }
  987. function removeStyle(id2) {
  988. let style = sheetsMap.get(id2);
  989. if (style) {
  990. if (style instanceof CSSStyleSheet) {
  991. document.adoptedStyleSheets.indexOf(style);
  992. document.adoptedStyleSheets = document.adoptedStyleSheets.filter(
  993. (s) => s !== style
  994. );
  995. } else {
  996. document.head.removeChild(style);
  997. }
  998. sheetsMap.delete(id2);
  999. }
  1000. }
  1001. function PolySymbol(name) {
  1002. return Symbol(process.env.NODE_ENV !== "production" ? "[uni-app]: " + name : name);
  1003. }
  1004. function hasRpx(str) {
  1005. str = str + "";
  1006. return str.indexOf("rpx") !== -1 || str.indexOf("upx") !== -1;
  1007. }
  1008. function rpx2px(str, replace = false) {
  1009. if (replace) {
  1010. return rpx2pxWithReplace(str);
  1011. }
  1012. if (isString(str)) {
  1013. const res = parseInt(str) || 0;
  1014. if (hasRpx(str)) {
  1015. return uni.upx2px(res);
  1016. }
  1017. return res;
  1018. }
  1019. return str;
  1020. }
  1021. function rpx2pxWithReplace(str) {
  1022. if (!hasRpx(str)) {
  1023. return str;
  1024. }
  1025. return str.replace(/(\d+(\.\d+)?)[ru]px/g, (_a, b) => {
  1026. return uni.upx2px(parseFloat(b)) + "px";
  1027. });
  1028. }
  1029. const ICON_PATH_CANCEL = "M20.928 10.176l-4.928 4.928-4.928-4.928-0.896 0.896 4.928 4.928-4.928 4.928 0.896 0.896 4.928-4.928 4.928 4.928 0.896-0.896-4.928-4.928 4.928-4.928-0.896-0.896zM16 2.080q-3.776 0-7.040 1.888-3.136 1.856-4.992 4.992-1.888 3.264-1.888 7.040t1.888 7.040q1.856 3.136 4.992 4.992 3.264 1.888 7.040 1.888t7.040-1.888q3.136-1.856 4.992-4.992 1.888-3.264 1.888-7.040t-1.888-7.040q-1.856-3.136-4.992-4.992-3.264-1.888-7.040-1.888zM16 28.64q-3.424 0-6.4-1.728-2.848-1.664-4.512-4.512-1.728-2.976-1.728-6.4t1.728-6.4q1.664-2.848 4.512-4.512 2.976-1.728 6.4-1.728t6.4 1.728q2.848 1.664 4.512 4.512 1.728 2.976 1.728 6.4t-1.728 6.4q-1.664 2.848-4.512 4.512-2.976 1.728-6.4 1.728z";
  1030. const ICON_PATH_CLEAR = "M16 0q-4.352 0-8.064 2.176-3.616 2.144-5.76 5.76-2.176 3.712-2.176 8.064t2.176 8.064q2.144 3.616 5.76 5.76 3.712 2.176 8.064 2.176t8.064-2.176q3.616-2.144 5.76-5.76 2.176-3.712 2.176-8.064t-2.176-8.064q-2.144-3.616-5.76-5.76-3.712-2.176-8.064-2.176zM22.688 21.408q0.32 0.32 0.304 0.752t-0.336 0.736-0.752 0.304-0.752-0.32l-5.184-5.376-5.376 5.184q-0.32 0.32-0.752 0.304t-0.736-0.336-0.304-0.752 0.32-0.752l5.376-5.184-5.184-5.376q-0.32-0.32-0.304-0.752t0.336-0.752 0.752-0.304 0.752 0.336l5.184 5.376 5.376-5.184q0.32-0.32 0.752-0.304t0.752 0.336 0.304 0.752-0.336 0.752l-5.376 5.184 5.184 5.376z";
  1031. const ICON_PATH_DOWNLOAD = "M15.808 1.696q-3.776 0-7.072 1.984-3.2 1.888-5.088 5.152-1.952 3.392-1.952 7.36 0 3.776 1.952 7.072 1.888 3.2 5.088 5.088 3.296 1.952 7.072 1.952 3.968 0 7.36-1.952 3.264-1.888 5.152-5.088 1.984-3.296 1.984-7.072 0-4-1.984-7.36-1.888-3.264-5.152-5.152-3.36-1.984-7.36-1.984zM20.864 18.592l-3.776 4.928q-0.448 0.576-1.088 0.576t-1.088-0.576l-3.776-4.928q-0.448-0.576-0.24-0.992t0.944-0.416h2.976v-8.928q0-0.256 0.176-0.432t0.4-0.176h1.216q0.224 0 0.4 0.176t0.176 0.432v8.928h2.976q0.736 0 0.944 0.416t-0.24 0.992z";
  1032. const ICON_PATH_INFO = "M15.808 0.128q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.176 3.776-2.176 8.16 0 4.224 2.176 7.872 2.080 3.552 5.632 5.632 3.648 2.176 7.872 2.176 4.384 0 8.16-2.176 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.416-2.176-8.16-2.112-3.616-5.728-5.728-3.744-2.176-8.16-2.176zM16.864 23.776q0 0.064-0.064 0.064h-1.568q-0.096 0-0.096-0.064l-0.256-11.328q0-0.064 0.064-0.064h2.112q0.096 0 0.064 0.064l-0.256 11.328zM16 10.88q-0.576 0-0.976-0.4t-0.4-0.96 0.4-0.96 0.976-0.4 0.976 0.4 0.4 0.96-0.4 0.96-0.976 0.4z";
  1033. const ICON_PATH_SEARCH = "M20.928 22.688q-1.696 1.376-3.744 2.112-2.112 0.768-4.384 0.768-3.488 0-6.464-1.728-2.88-1.696-4.576-4.608-1.76-2.976-1.76-6.464t1.76-6.464q1.696-2.88 4.576-4.576 2.976-1.76 6.464-1.76t6.464 1.76q2.912 1.696 4.608 4.576 1.728 2.976 1.728 6.464 0 2.272-0.768 4.384-0.736 2.048-2.112 3.744l9.312 9.28-1.824 1.824-9.28-9.312zM12.8 23.008q2.784 0 5.184-1.376 2.304-1.376 3.68-3.68 1.376-2.4 1.376-5.184t-1.376-5.152q-1.376-2.336-3.68-3.68-2.4-1.408-5.184-1.408t-5.152 1.408q-2.336 1.344-3.68 3.68-1.408 2.368-1.408 5.152t1.408 5.184q1.344 2.304 3.68 3.68 2.368 1.376 5.152 1.376zM12.8 23.008v0z";
  1034. const ICON_PATH_SUCCESS_NO_CIRCLE = "M1.952 18.080q-0.32-0.352-0.416-0.88t0.128-0.976l0.16-0.352q0.224-0.416 0.64-0.528t0.8 0.176l6.496 4.704q0.384 0.288 0.912 0.272t0.88-0.336l17.312-14.272q0.352-0.288 0.848-0.256t0.848 0.352l-0.416-0.416q0.32 0.352 0.32 0.816t-0.32 0.816l-18.656 18.912q-0.32 0.352-0.8 0.352t-0.8-0.32l-7.936-8.064z";
  1035. const ICON_PATH_SUCCESS = "M15.808 0.16q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.144 3.744-2.144 8.128 0 4.192 2.144 7.872 2.112 3.52 5.632 5.632 3.68 2.144 7.872 2.144 4.384 0 8.128-2.144 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.384-2.176-8.128-2.112-3.616-5.728-5.728-3.744-2.176-8.128-2.176zM24.832 11.328l-11.264 11.104q-0.032 0.032-0.112 0.032t-0.112-0.032l-5.216-5.376q-0.096-0.128 0-0.288l0.704-0.96q0.032-0.064 0.112-0.064t0.112 0.032l4.256 3.264q0.064 0.032 0.144 0.032t0.112-0.032l10.336-8.608q0.064-0.064 0.144-0.064t0.112 0.064l0.672 0.672q0.128 0.128 0 0.224z";
  1036. const ICON_PATH_WAITING = "M15.84 0.096q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.144 3.744-2.144 8.128 0 4.192 2.144 7.872 2.112 3.52 5.632 5.632 3.68 2.144 7.872 2.144 4.384 0 8.128-2.144 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.384-2.176-8.128-2.112-3.616-5.728-5.728-3.744-2.176-8.128-2.176zM23.008 21.92l-0.512 0.896q-0.096 0.128-0.224 0.064l-8-3.808q-0.096-0.064-0.16-0.128-0.128-0.096-0.128-0.288l0.512-12.096q0-0.064 0.048-0.112t0.112-0.048h1.376q0.064 0 0.112 0.048t0.048 0.112l0.448 10.848 6.304 4.256q0.064 0.064 0.080 0.128t-0.016 0.128z";
  1037. const ICON_PATH_WARN = "M15.808 0.16q-4.224 0-7.872 2.176-3.552 2.112-5.632 5.728-2.144 3.744-2.144 8.128 0 4.192 2.144 7.872 2.112 3.52 5.632 5.632 3.68 2.144 7.872 2.144 4.384 0 8.128-2.144 3.616-2.080 5.728-5.632 2.176-3.648 2.176-7.872 0-4.384-2.176-8.128-2.112-3.616-5.728-5.728-3.744-2.176-8.128-2.176zM15.136 8.672h1.728q0.128 0 0.224 0.096t0.096 0.256l-0.384 10.24q0 0.064-0.048 0.112t-0.112 0.048h-1.248q-0.096 0-0.144-0.048t-0.048-0.112l-0.384-10.24q0-0.16 0.096-0.256t0.224-0.096zM16 23.328q-0.48 0-0.832-0.352t-0.352-0.848 0.352-0.848 0.832-0.352 0.832 0.352 0.352 0.848-0.352 0.848-0.832 0.352z";
  1038. const ICON_PATH_BACK = "M21.781 7.844l-9.063 8.594 9.063 8.594q0.25 0.25 0.25 0.609t-0.25 0.578q-0.25 0.25-0.578 0.25t-0.578-0.25l-9.625-9.125q-0.156-0.125-0.203-0.297t-0.047-0.359q0-0.156 0.047-0.328t0.203-0.297l9.625-9.125q0.25-0.25 0.578-0.25t0.578 0.25q0.25 0.219 0.25 0.578t-0.25 0.578z";
  1039. const ICON_PATH_CLOSE = "M17.25 16.156l7.375-7.313q0.281-0.281 0.281-0.641t-0.281-0.641q-0.25-0.25-0.625-0.25t-0.625 0.25l-7.375 7.344-7.313-7.344q-0.25-0.25-0.625-0.25t-0.625 0.25q-0.281 0.25-0.281 0.625t0.281 0.625l7.313 7.344-7.375 7.344q-0.281 0.25-0.281 0.625t0.281 0.625q0.125 0.125 0.281 0.188t0.344 0.063q0.156 0 0.328-0.063t0.297-0.188l7.375-7.344 7.375 7.406q0.125 0.156 0.297 0.219t0.328 0.063q0.188 0 0.344-0.078t0.281-0.203q0.281-0.25 0.281-0.609t-0.281-0.641l-7.375-7.406z";
  1040. const ICON_PATH_CONFIRM = "M31.562 4.9966666659375q0.435 0.399 0.435 0.87 0.036 0.58-0.399 0.98l-18.61 19.917q-0.145 0.145-0.327 0.217-0.073 0.037-0.145 0.11-0.254 0.035-0.472 0.035-0.29 0-0.544-0.036l-0.145-0.072q-0.109-0.073-0.217-0.182l-0.11-0.072L0.363 16.2786666659375q-0.327-0.399-0.363-0.907 0-0.544 0.363-1.016 0.435-0.326 0.961-0.362 0.527-0.036 0.962 0.362l9.722 9.542L29.712 5.0326666659375q0.399-0.363 0.943-0.363 0.544-0.036 0.907 0.327z";
  1041. function createSvgIconVNode(path, color = "#000", size = 27) {
  1042. return createVNode(
  1043. "svg",
  1044. {
  1045. width: size,
  1046. height: size,
  1047. viewBox: "0 0 32 32"
  1048. },
  1049. [
  1050. createVNode(
  1051. "path",
  1052. {
  1053. d: path,
  1054. fill: color
  1055. },
  1056. null,
  1057. 8,
  1058. ["d", "fill"]
  1059. )
  1060. ],
  1061. 8,
  1062. ["width", "height"]
  1063. );
  1064. }
  1065. function useCurrentPageId() {
  1066. {
  1067. const { $pageInstance } = getCurrentInstance();
  1068. return $pageInstance && $pageInstance.proxy.$page.id;
  1069. }
  1070. }
  1071. function getPageIdByVm(instance2) {
  1072. const vm = resolveComponentInstance(instance2);
  1073. if (vm.$page) {
  1074. return vm.$page.id;
  1075. }
  1076. if (!vm.$) {
  1077. return;
  1078. }
  1079. {
  1080. const { $pageInstance } = vm.$;
  1081. return $pageInstance && $pageInstance.proxy.$page.id;
  1082. }
  1083. }
  1084. function getCurrentPage() {
  1085. const pages = getCurrentPages();
  1086. const len = pages.length;
  1087. if (len) {
  1088. return pages[len - 1];
  1089. }
  1090. }
  1091. function getCurrentPageMeta() {
  1092. const page = getCurrentPage();
  1093. if (page) {
  1094. return page.$page.meta;
  1095. }
  1096. }
  1097. function getCurrentPageId() {
  1098. const meta = getCurrentPageMeta();
  1099. if (meta) {
  1100. return meta.id;
  1101. }
  1102. return -1;
  1103. }
  1104. function getCurrentPageVm() {
  1105. const page = getCurrentPage();
  1106. if (page) {
  1107. return page.$vm;
  1108. }
  1109. }
  1110. const PAGE_META_KEYS = ["navigationBar", "pullToRefresh"];
  1111. function initGlobalStyle() {
  1112. return JSON.parse(JSON.stringify(__uniConfig.globalStyle || {}));
  1113. }
  1114. function initRouteMeta(pageMeta, id2) {
  1115. const globalStyle = initGlobalStyle();
  1116. const res = extend({ id: id2 }, globalStyle, pageMeta);
  1117. PAGE_META_KEYS.forEach((name) => {
  1118. res[name] = extend({}, globalStyle[name], pageMeta[name]);
  1119. });
  1120. const { navigationBar } = res;
  1121. navigationBar.titleText && navigationBar.titleImage && (navigationBar.titleText = "");
  1122. return res;
  1123. }
  1124. function normalizePullToRefreshRpx(pullToRefresh) {
  1125. if (pullToRefresh.offset) {
  1126. pullToRefresh.offset = rpx2px(pullToRefresh.offset);
  1127. }
  1128. if (pullToRefresh.height) {
  1129. pullToRefresh.height = rpx2px(pullToRefresh.height);
  1130. }
  1131. if (pullToRefresh.range) {
  1132. pullToRefresh.range = rpx2px(pullToRefresh.range);
  1133. }
  1134. return pullToRefresh;
  1135. }
  1136. function initPageInternalInstance(openType, url, pageQuery, meta, eventChannel, themeMode) {
  1137. const { id: id2, route } = meta;
  1138. const titleColor = normalizeStyles(
  1139. meta.navigationBar,
  1140. __uniConfig.themeConfig,
  1141. themeMode
  1142. ).titleColor;
  1143. return {
  1144. id: id2,
  1145. path: addLeadingSlash(route),
  1146. route,
  1147. fullPath: url,
  1148. options: pageQuery,
  1149. meta,
  1150. openType,
  1151. eventChannel,
  1152. statusBarStyle: titleColor === "#ffffff" ? "light" : "dark"
  1153. };
  1154. }
  1155. function removeHook(vm, name, hook) {
  1156. const hooks = vm.$[name];
  1157. if (!isArray(hooks)) {
  1158. return;
  1159. }
  1160. if (hook.__weh) {
  1161. remove(hooks, hook.__weh);
  1162. }
  1163. }
  1164. function invokeHook(vm, name, args) {
  1165. if (isString(vm)) {
  1166. args = name;
  1167. name = vm;
  1168. vm = getCurrentPageVm();
  1169. } else if (typeof vm === "number") {
  1170. const page = getCurrentPages().find((page2) => page2.$page.id === vm);
  1171. if (page) {
  1172. vm = page.$vm;
  1173. } else {
  1174. vm = getCurrentPageVm();
  1175. }
  1176. }
  1177. if (!vm) {
  1178. return;
  1179. }
  1180. const hooks = vm.$[name];
  1181. return hooks && invokeArrayFns(hooks, args);
  1182. }
  1183. function disableScrollListener(evt) {
  1184. evt.preventDefault();
  1185. }
  1186. let testReachBottomTimer;
  1187. let lastScrollHeight = 0;
  1188. function createScrollListener({
  1189. onPageScroll,
  1190. onReachBottom,
  1191. onReachBottomDistance
  1192. }) {
  1193. let ticking = false;
  1194. let hasReachBottom = false;
  1195. let reachBottomLocking = true;
  1196. const isReachBottom = () => {
  1197. const { scrollHeight } = document.documentElement;
  1198. const windowHeight = window.innerHeight;
  1199. const scrollY = window.scrollY;
  1200. const isBottom = scrollY > 0 && scrollHeight > windowHeight && scrollY + windowHeight + onReachBottomDistance >= scrollHeight;
  1201. const heightChanged = Math.abs(scrollHeight - lastScrollHeight) > onReachBottomDistance;
  1202. if (isBottom && (!hasReachBottom || heightChanged)) {
  1203. lastScrollHeight = scrollHeight;
  1204. hasReachBottom = true;
  1205. return true;
  1206. }
  1207. if (!isBottom && hasReachBottom) {
  1208. hasReachBottom = false;
  1209. }
  1210. return false;
  1211. };
  1212. const trigger = () => {
  1213. onPageScroll && onPageScroll(window.pageYOffset);
  1214. function testReachBottom() {
  1215. if (isReachBottom()) {
  1216. onReachBottom && onReachBottom();
  1217. reachBottomLocking = false;
  1218. setTimeout(function() {
  1219. reachBottomLocking = true;
  1220. }, 350);
  1221. return true;
  1222. }
  1223. }
  1224. if (onReachBottom && reachBottomLocking) {
  1225. if (testReachBottom())
  1226. ;
  1227. else {
  1228. testReachBottomTimer = setTimeout(testReachBottom, 300);
  1229. }
  1230. }
  1231. ticking = false;
  1232. };
  1233. return function onScroll() {
  1234. clearTimeout(testReachBottomTimer);
  1235. if (!ticking) {
  1236. requestAnimationFrame(trigger);
  1237. }
  1238. ticking = true;
  1239. };
  1240. }
  1241. function normalizeRoute(toRoute) {
  1242. if (toRoute.indexOf("/") === 0) {
  1243. return toRoute;
  1244. }
  1245. let fromRoute = "";
  1246. const pages = getCurrentPages();
  1247. if (pages.length) {
  1248. fromRoute = pages[pages.length - 1].$page.route;
  1249. }
  1250. return getRealRoute(fromRoute, toRoute);
  1251. }
  1252. function getRealRoute(fromRoute, toRoute) {
  1253. if (toRoute.indexOf("/") === 0) {
  1254. return toRoute;
  1255. }
  1256. if (toRoute.indexOf("./") === 0) {
  1257. return getRealRoute(fromRoute, toRoute.slice(2));
  1258. }
  1259. const toRouteArray = toRoute.split("/");
  1260. const toRouteLength = toRouteArray.length;
  1261. let i = 0;
  1262. for (; i < toRouteLength && toRouteArray[i] === ".."; i++) {
  1263. }
  1264. toRouteArray.splice(0, i);
  1265. toRoute = toRouteArray.join("/");
  1266. const fromRouteArray = fromRoute.length > 0 ? fromRoute.split("/") : [];
  1267. fromRouteArray.splice(fromRouteArray.length - i - 1, i + 1);
  1268. return addLeadingSlash(fromRouteArray.concat(toRouteArray).join("/"));
  1269. }
  1270. function getRouteOptions(path, alias = false) {
  1271. if (alias) {
  1272. return __uniRoutes.find(
  1273. (route) => route.path === path || route.alias === path
  1274. );
  1275. }
  1276. return __uniRoutes.find((route) => route.path === path);
  1277. }
  1278. function normalizeTabBarRoute(index2, oldPagePath, newPagePath) {
  1279. const oldTabBarRoute = getRouteOptions(addLeadingSlash(oldPagePath));
  1280. if (oldTabBarRoute) {
  1281. const { meta } = oldTabBarRoute;
  1282. delete meta.tabBarIndex;
  1283. meta.isQuit = meta.isTabBar = false;
  1284. }
  1285. const newTabBarRoute = getRouteOptions(addLeadingSlash(newPagePath));
  1286. if (newTabBarRoute) {
  1287. const { meta } = newTabBarRoute;
  1288. meta.tabBarIndex = index2;
  1289. meta.isQuit = meta.isTabBar = true;
  1290. const tabBar2 = __uniConfig.tabBar;
  1291. if (tabBar2 && tabBar2.list && tabBar2.list[index2]) {
  1292. tabBar2.list[index2].pagePath = removeLeadingSlash(newPagePath);
  1293. }
  1294. }
  1295. }
  1296. class ComponentDescriptor {
  1297. constructor(vm) {
  1298. this.$bindClass = false;
  1299. this.$bindStyle = false;
  1300. this.$vm = vm;
  1301. {
  1302. this.$el = resolveOwnerEl(vm.$);
  1303. }
  1304. if (this.$el.getAttribute) {
  1305. this.$bindClass = !!this.$el.getAttribute("class");
  1306. this.$bindStyle = !!this.$el.getAttribute("style");
  1307. }
  1308. }
  1309. selectComponent(selector) {
  1310. if (!this.$el || !selector) {
  1311. return;
  1312. }
  1313. const wxsVm = getWxsVm(this.$el.querySelector(selector));
  1314. if (!wxsVm) {
  1315. return;
  1316. }
  1317. return createComponentDescriptor(wxsVm, false);
  1318. }
  1319. selectAllComponents(selector) {
  1320. if (!this.$el || !selector) {
  1321. return [];
  1322. }
  1323. const descriptors = [];
  1324. const els = this.$el.querySelectorAll(selector);
  1325. for (let i = 0; i < els.length; i++) {
  1326. const wxsVm = getWxsVm(els[i]);
  1327. if (wxsVm) {
  1328. descriptors.push(createComponentDescriptor(wxsVm, false));
  1329. }
  1330. }
  1331. return descriptors;
  1332. }
  1333. forceUpdate(type) {
  1334. if (type === "class") {
  1335. if (this.$bindClass) {
  1336. this.$el.__wxsClassChanged = true;
  1337. this.$vm.$forceUpdate();
  1338. } else {
  1339. this.updateWxsClass();
  1340. }
  1341. } else if (type === "style") {
  1342. if (this.$bindStyle) {
  1343. this.$el.__wxsStyleChanged = true;
  1344. this.$vm.$forceUpdate();
  1345. } else {
  1346. this.updateWxsStyle();
  1347. }
  1348. }
  1349. }
  1350. updateWxsClass() {
  1351. const { __wxsAddClass } = this.$el;
  1352. if (__wxsAddClass.length) {
  1353. this.$el.className = __wxsAddClass.join(" ");
  1354. }
  1355. }
  1356. updateWxsStyle() {
  1357. const { __wxsStyle } = this.$el;
  1358. if (__wxsStyle) {
  1359. this.$el.setAttribute("style", stringifyStyle(__wxsStyle));
  1360. }
  1361. }
  1362. setStyle(style) {
  1363. if (!this.$el || !style) {
  1364. return this;
  1365. }
  1366. if (isString(style)) {
  1367. style = parseStringStyle(style);
  1368. }
  1369. if (isPlainObject(style)) {
  1370. this.$el.__wxsStyle = style;
  1371. this.forceUpdate("style");
  1372. }
  1373. return this;
  1374. }
  1375. addClass(clazz2) {
  1376. if (!this.$el || !clazz2) {
  1377. return this;
  1378. }
  1379. const __wxsAddClass = this.$el.__wxsAddClass || (this.$el.__wxsAddClass = []);
  1380. if (__wxsAddClass.indexOf(clazz2) === -1) {
  1381. __wxsAddClass.push(clazz2);
  1382. this.forceUpdate("class");
  1383. }
  1384. return this;
  1385. }
  1386. removeClass(clazz2) {
  1387. if (!this.$el || !clazz2) {
  1388. return this;
  1389. }
  1390. const { __wxsAddClass } = this.$el;
  1391. if (__wxsAddClass) {
  1392. const index2 = __wxsAddClass.indexOf(clazz2);
  1393. if (index2 > -1) {
  1394. __wxsAddClass.splice(index2, 1);
  1395. }
  1396. }
  1397. const __wxsRemoveClass = this.$el.__wxsRemoveClass || (this.$el.__wxsRemoveClass = []);
  1398. if (__wxsRemoveClass.indexOf(clazz2) === -1) {
  1399. __wxsRemoveClass.push(clazz2);
  1400. this.forceUpdate("class");
  1401. }
  1402. return this;
  1403. }
  1404. hasClass(cls) {
  1405. return this.$el && this.$el.classList.contains(cls);
  1406. }
  1407. getDataset() {
  1408. return this.$el && this.$el.dataset;
  1409. }
  1410. callMethod(funcName, args = {}) {
  1411. const func = this.$vm[funcName];
  1412. if (isFunction(func)) {
  1413. func(JSON.parse(JSON.stringify(args)));
  1414. } else if (this.$vm.ownerId) {
  1415. UniViewJSBridge.publishHandler(ON_WXS_INVOKE_CALL_METHOD, {
  1416. nodeId: this.$el.__id,
  1417. ownerId: this.$vm.ownerId,
  1418. method: funcName,
  1419. args
  1420. });
  1421. }
  1422. }
  1423. requestAnimationFrame(callback) {
  1424. return window.requestAnimationFrame(callback);
  1425. }
  1426. getState() {
  1427. return this.$el && (this.$el.__wxsState || (this.$el.__wxsState = {}));
  1428. }
  1429. triggerEvent(eventName, detail = {}) {
  1430. return this.$vm.$emit(eventName, detail), this;
  1431. }
  1432. getComputedStyle(names) {
  1433. if (this.$el) {
  1434. const styles = window.getComputedStyle(this.$el);
  1435. if (names && names.length) {
  1436. return names.reduce((res, n) => {
  1437. res[n] = styles[n];
  1438. return res;
  1439. }, {});
  1440. }
  1441. return styles;
  1442. }
  1443. return {};
  1444. }
  1445. setTimeout(handler, timeout) {
  1446. return window.setTimeout(handler, timeout);
  1447. }
  1448. clearTimeout(handle) {
  1449. return window.clearTimeout(handle);
  1450. }
  1451. getBoundingClientRect() {
  1452. return this.$el.getBoundingClientRect();
  1453. }
  1454. }
  1455. function createComponentDescriptor(vm, isOwnerInstance = true) {
  1456. {
  1457. if (isOwnerInstance && vm) {
  1458. vm = resolveOwnerVm(vm.$);
  1459. }
  1460. }
  1461. if (vm && vm.$el) {
  1462. if (!vm.$el.__wxsComponentDescriptor) {
  1463. vm.$el.__wxsComponentDescriptor = new ComponentDescriptor(vm);
  1464. }
  1465. return vm.$el.__wxsComponentDescriptor;
  1466. }
  1467. }
  1468. function getComponentDescriptor(instance2, isOwnerInstance) {
  1469. return createComponentDescriptor(instance2, isOwnerInstance);
  1470. }
  1471. function resolveOwnerComponentPublicInstance(eventValue, instance2, checkArgsLength = true) {
  1472. if (!instance2) {
  1473. return false;
  1474. }
  1475. if (checkArgsLength && eventValue.length < 2) {
  1476. return false;
  1477. }
  1478. const ownerVm = resolveOwnerVm(instance2);
  1479. if (!ownerVm) {
  1480. return false;
  1481. }
  1482. const type = ownerVm.$.type;
  1483. if (!type.$wxs && !type.$renderjs) {
  1484. return false;
  1485. }
  1486. return ownerVm;
  1487. }
  1488. function wrapperH5WxsEvent(event, eventValue, instance2, checkArgsLength = true) {
  1489. if (eventValue) {
  1490. if (!event.__instance) {
  1491. event.__instance = true;
  1492. Object.defineProperty(event, "instance", {
  1493. get() {
  1494. return getComponentDescriptor(instance2.proxy, false);
  1495. }
  1496. });
  1497. }
  1498. const ownerVm = resolveOwnerComponentPublicInstance(
  1499. eventValue,
  1500. instance2,
  1501. checkArgsLength
  1502. );
  1503. if (ownerVm) {
  1504. return [event, getComponentDescriptor(ownerVm, false)];
  1505. }
  1506. }
  1507. }
  1508. function getWxsVm(el) {
  1509. if (!el) {
  1510. return;
  1511. }
  1512. {
  1513. return el.__vueParentComponent && el.__vueParentComponent.proxy;
  1514. }
  1515. }
  1516. const isKeyboardEvent = (val) => !val.type.indexOf("key") && val instanceof KeyboardEvent;
  1517. const isClickEvent = (val) => val.type === "click";
  1518. const isMouseEvent = (val) => val.type.indexOf("mouse") === 0 || ["contextmenu"].includes(val.type);
  1519. const isTouchEvent = (val) => typeof TouchEvent !== "undefined" && val instanceof TouchEvent || val.type.indexOf("touch") === 0 || ["longpress"].indexOf(val.type) >= 0;
  1520. function $nne(evt, eventValue, instance2) {
  1521. const { currentTarget } = evt;
  1522. if (!(evt instanceof Event) || !(currentTarget instanceof HTMLElement)) {
  1523. return [evt];
  1524. }
  1525. const isHTMLTarget = currentTarget.tagName.indexOf("UNI-") !== 0;
  1526. {
  1527. if (isHTMLTarget) {
  1528. return wrapperH5WxsEvent(
  1529. evt,
  1530. eventValue,
  1531. instance2,
  1532. false
  1533. // 原生标签事件可能被cache,参数长度不准确,故默认不校验
  1534. ) || [evt];
  1535. }
  1536. }
  1537. const res = createNativeEvent(evt, isHTMLTarget);
  1538. if (isClickEvent(evt)) {
  1539. normalizeClickEvent(res, evt);
  1540. } else if (isMouseEvent(evt)) {
  1541. normalizeMouseEvent(res, evt);
  1542. } else if (isTouchEvent(evt)) {
  1543. const top = getWindowTop();
  1544. res.touches = normalizeTouchEvent(evt.touches, top);
  1545. res.changedTouches = normalizeTouchEvent(evt.changedTouches, top);
  1546. } else if (isKeyboardEvent(evt)) {
  1547. const proxyKeys = ["key", "code"];
  1548. proxyKeys.forEach((key) => {
  1549. Object.defineProperty(res, key, {
  1550. get() {
  1551. return evt[key];
  1552. }
  1553. });
  1554. });
  1555. }
  1556. {
  1557. return wrapperH5WxsEvent(
  1558. res,
  1559. eventValue,
  1560. instance2
  1561. ) || [res];
  1562. }
  1563. }
  1564. function findUniTarget(target) {
  1565. while (target && target.tagName.indexOf("UNI-") !== 0) {
  1566. target = target.parentElement;
  1567. }
  1568. return target;
  1569. }
  1570. function createNativeEvent(evt, htmlElement = false) {
  1571. const { type, timeStamp, target, currentTarget } = evt;
  1572. let realTarget, realCurrentTarget;
  1573. realTarget = normalizeTarget(
  1574. htmlElement ? target : findUniTarget(target)
  1575. );
  1576. realCurrentTarget = normalizeTarget(currentTarget);
  1577. const event = {
  1578. type,
  1579. timeStamp,
  1580. target: realTarget,
  1581. detail: {},
  1582. currentTarget: realCurrentTarget
  1583. };
  1584. if (evt._stopped) {
  1585. event._stopped = true;
  1586. }
  1587. if (evt.type.startsWith("touch")) {
  1588. event.touches = evt.touches;
  1589. event.changedTouches = evt.changedTouches;
  1590. }
  1591. {
  1592. wrapperEvent(event, evt);
  1593. }
  1594. return event;
  1595. }
  1596. function wrapperEvent(event, evt) {
  1597. extend(event, {
  1598. preventDefault() {
  1599. return evt.preventDefault();
  1600. },
  1601. stopPropagation() {
  1602. return evt.stopPropagation();
  1603. }
  1604. });
  1605. }
  1606. function normalizeClickEvent(evt, mouseEvt) {
  1607. const { x, y } = mouseEvt;
  1608. const top = getWindowTop();
  1609. evt.detail = { x, y: y - top };
  1610. evt.touches = evt.changedTouches = [createTouchEvent(mouseEvt, top)];
  1611. }
  1612. function normalizeMouseEvent(evt, mouseEvt) {
  1613. const top = getWindowTop();
  1614. evt.pageX = mouseEvt.pageX;
  1615. evt.pageY = mouseEvt.pageY - top;
  1616. evt.clientX = mouseEvt.clientX;
  1617. evt.clientY = mouseEvt.clientY - top;
  1618. evt.touches = evt.changedTouches = [createTouchEvent(mouseEvt, top)];
  1619. }
  1620. function createTouchEvent(evt, top) {
  1621. return {
  1622. force: 1,
  1623. identifier: 0,
  1624. clientX: evt.clientX,
  1625. clientY: evt.clientY - top,
  1626. pageX: evt.pageX,
  1627. pageY: evt.pageY - top
  1628. };
  1629. }
  1630. function normalizeTouchEvent(touches, top) {
  1631. const res = [];
  1632. for (let i = 0; i < touches.length; i++) {
  1633. const {
  1634. identifier,
  1635. pageX,
  1636. pageY,
  1637. clientX,
  1638. clientY,
  1639. force
  1640. } = touches[i];
  1641. res.push({
  1642. identifier,
  1643. pageX,
  1644. pageY: pageY - top,
  1645. clientX,
  1646. clientY: clientY - top,
  1647. force: force || 0
  1648. });
  1649. }
  1650. return res;
  1651. }
  1652. const instance = /* @__PURE__ */ Object.defineProperty({
  1653. __proto__: null,
  1654. $nne,
  1655. createNativeEvent
  1656. }, Symbol.toStringTag, { value: "Module" });
  1657. function initAppConfig$1(appConfig) {
  1658. const globalProperties = appConfig.globalProperties;
  1659. extend(globalProperties, instance);
  1660. if (__UNI_FEATURE_WXS__) {
  1661. globalProperties.$gcd = getComponentDescriptor;
  1662. }
  1663. }
  1664. function initViewPlugin(app) {
  1665. initAppConfig$1(app._context.config);
  1666. }
  1667. const invokeOnCallback = (name, res) => UniServiceJSBridge.emit("api." + name, res);
  1668. let invokeViewMethodId = 1;
  1669. function publishViewMethodName(pageId) {
  1670. return (pageId || getCurrentPageId()) + "." + INVOKE_VIEW_API;
  1671. }
  1672. const invokeViewMethod = (name, args, pageId, callback) => {
  1673. const { subscribe, publishHandler } = UniServiceJSBridge;
  1674. const id2 = callback ? invokeViewMethodId++ : 0;
  1675. callback && subscribe(INVOKE_VIEW_API + "." + id2, callback, true);
  1676. publishHandler(publishViewMethodName(pageId), { id: id2, name, args }, pageId);
  1677. };
  1678. const invokeViewMethodKeepAlive = (name, args, callback, pageId) => {
  1679. const { subscribe, unsubscribe, publishHandler } = UniServiceJSBridge;
  1680. const id2 = invokeViewMethodId++;
  1681. const subscribeName = INVOKE_VIEW_API + "." + id2;
  1682. subscribe(subscribeName, callback);
  1683. publishHandler(publishViewMethodName(pageId), { id: id2, name, args }, pageId);
  1684. return () => {
  1685. unsubscribe(subscribeName);
  1686. };
  1687. };
  1688. const ServiceJSBridge = /* @__PURE__ */ extend(
  1689. /* @__PURE__ */ initBridge(
  1690. "view"
  1691. /* view 指的是 service 层订阅的是 view 层事件 */
  1692. ),
  1693. {
  1694. invokeOnCallback,
  1695. invokeViewMethod,
  1696. invokeViewMethodKeepAlive
  1697. }
  1698. );
  1699. function initOn() {
  1700. const { on: on2 } = UniServiceJSBridge;
  1701. on2(ON_RESIZE, onResize$1);
  1702. on2(ON_APP_ENTER_FOREGROUND, onAppEnterForeground);
  1703. on2(ON_APP_ENTER_BACKGROUND, onAppEnterBackground);
  1704. }
  1705. function onResize$1(res) {
  1706. invokeHook(getCurrentPage(), ON_RESIZE, res);
  1707. UniServiceJSBridge.invokeOnCallback("onWindowResize", res);
  1708. }
  1709. function onAppEnterForeground(enterOptions2) {
  1710. const page = getCurrentPage();
  1711. invokeHook(getApp(), ON_SHOW, enterOptions2);
  1712. invokeHook(page, ON_SHOW);
  1713. }
  1714. function onAppEnterBackground() {
  1715. invokeHook(getApp(), ON_HIDE);
  1716. invokeHook(getCurrentPage(), ON_HIDE);
  1717. }
  1718. const SUBSCRIBE_LIFECYCLE_HOOKS = [ON_PAGE_SCROLL, ON_REACH_BOTTOM];
  1719. function initSubscribe() {
  1720. SUBSCRIBE_LIFECYCLE_HOOKS.forEach(
  1721. (name) => UniServiceJSBridge.subscribe(name, createPageEvent(name))
  1722. );
  1723. }
  1724. function createPageEvent(name) {
  1725. return (args, pageId) => {
  1726. invokeHook(parseInt(pageId), name, args);
  1727. };
  1728. }
  1729. function initService() {
  1730. {
  1731. initOn();
  1732. initSubscribe();
  1733. }
  1734. }
  1735. function initAppVm(appVm2) {
  1736. appVm2.$vm = appVm2;
  1737. appVm2.$mpType = "app";
  1738. const locale = ref(useI18n().getLocale());
  1739. Object.defineProperty(appVm2, "$locale", {
  1740. get() {
  1741. return locale.value;
  1742. },
  1743. set(v2) {
  1744. locale.value = v2;
  1745. }
  1746. });
  1747. }
  1748. function initPageVm(pageVm, page) {
  1749. pageVm.route = page.route;
  1750. pageVm.$vm = pageVm;
  1751. pageVm.$page = page;
  1752. pageVm.$mpType = "page";
  1753. if (page.meta.isTabBar) {
  1754. pageVm.$.__isTabBar = true;
  1755. pageVm.$.__isActive = true;
  1756. }
  1757. }
  1758. function querySelector(vm, selector) {
  1759. const el = vm.$el.querySelector(selector);
  1760. return el && el.__vue__;
  1761. }
  1762. function querySelectorAll(vm, selector) {
  1763. const nodeList = vm.$el.querySelectorAll(selector);
  1764. if (nodeList) {
  1765. return [...nodeList].map((node) => node.__vue__).filter(Boolean);
  1766. }
  1767. return [];
  1768. }
  1769. function createSelectorQuery$1() {
  1770. return uni.createSelectorQuery().in(this);
  1771. }
  1772. function createMediaQueryObserver$1() {
  1773. return uni.createMediaQueryObserver(this);
  1774. }
  1775. function createIntersectionObserver$1(options) {
  1776. return uni.createIntersectionObserver(this, options);
  1777. }
  1778. function selectComponent(selector) {
  1779. return querySelector(this, selector);
  1780. }
  1781. function selectAllComponents(selector) {
  1782. return querySelectorAll(this, selector);
  1783. }
  1784. const wxInstance = /* @__PURE__ */ Object.defineProperty({
  1785. __proto__: null,
  1786. createIntersectionObserver: createIntersectionObserver$1,
  1787. createMediaQueryObserver: createMediaQueryObserver$1,
  1788. createSelectorQuery: createSelectorQuery$1,
  1789. selectAllComponents,
  1790. selectComponent
  1791. }, Symbol.toStringTag, { value: "Module" });
  1792. function getOpenerEventChannel() {
  1793. {
  1794. if (this.$route) {
  1795. const meta = this.$route.meta;
  1796. if (!meta.eventChannel) {
  1797. meta.eventChannel = new EventChannel(this.$page.id);
  1798. }
  1799. return meta.eventChannel;
  1800. }
  1801. }
  1802. }
  1803. function initAppConfig(appConfig) {
  1804. const globalProperties = appConfig.globalProperties;
  1805. globalProperties.getOpenerEventChannel = getOpenerEventChannel;
  1806. if (__UNI_FEATURE_WX__) {
  1807. extend(globalProperties, wxInstance);
  1808. }
  1809. }
  1810. function initServicePlugin(app) {
  1811. initAppConfig(app._context.config);
  1812. }
  1813. function createLaunchOptions() {
  1814. return {
  1815. path: "",
  1816. query: {},
  1817. scene: 1001,
  1818. referrerInfo: {
  1819. appId: "",
  1820. extraData: {}
  1821. }
  1822. };
  1823. }
  1824. function defineGlobalData(app, defaultGlobalData) {
  1825. const options = app.$options || {};
  1826. options.globalData = extend(options.globalData || {}, defaultGlobalData);
  1827. Object.defineProperty(app, "globalData", {
  1828. get() {
  1829. return options.globalData;
  1830. },
  1831. set(newGlobalData) {
  1832. options.globalData = newGlobalData;
  1833. }
  1834. });
  1835. }
  1836. function converPx(value) {
  1837. if (/^-?\d+[ur]px$/i.test(value)) {
  1838. return value.replace(/(^-?\d+)[ur]px$/i, (text2, num) => {
  1839. return `${uni.upx2px(parseFloat(num))}px`;
  1840. });
  1841. } else if (/^-?[\d\.]+$/.test(value)) {
  1842. return `${value}px`;
  1843. }
  1844. return value || "";
  1845. }
  1846. function converType(type) {
  1847. return type.replace(/[A-Z]/g, (text2) => {
  1848. return `-${text2.toLowerCase()}`;
  1849. }).replace("webkit", "-webkit");
  1850. }
  1851. function getStyle(action) {
  1852. const animateTypes1 = [
  1853. "matrix",
  1854. "matrix3d",
  1855. "scale",
  1856. "scale3d",
  1857. "rotate3d",
  1858. "skew",
  1859. "translate",
  1860. "translate3d"
  1861. ];
  1862. const animateTypes2 = [
  1863. "scaleX",
  1864. "scaleY",
  1865. "scaleZ",
  1866. "rotate",
  1867. "rotateX",
  1868. "rotateY",
  1869. "rotateZ",
  1870. "skewX",
  1871. "skewY",
  1872. "translateX",
  1873. "translateY",
  1874. "translateZ"
  1875. ];
  1876. const animateTypes3 = ["opacity", "background-color"];
  1877. const animateTypes4 = ["width", "height", "left", "right", "top", "bottom"];
  1878. const animates = action.animates;
  1879. const option = action.option;
  1880. const transition = option.transition;
  1881. const style = {};
  1882. const transform = [];
  1883. animates.forEach((animate) => {
  1884. let type = animate.type;
  1885. let args = [...animate.args];
  1886. if (animateTypes1.concat(animateTypes2).includes(type)) {
  1887. if (type.startsWith("rotate") || type.startsWith("skew")) {
  1888. args = args.map((value) => parseFloat(value) + "deg");
  1889. } else if (type.startsWith("translate")) {
  1890. args = args.map(converPx);
  1891. }
  1892. if (animateTypes2.indexOf(type) >= 0) {
  1893. args.length = 1;
  1894. }
  1895. transform.push(`${type}(${args.join(",")})`);
  1896. } else if (animateTypes3.concat(animateTypes4).includes(args[0])) {
  1897. type = args[0];
  1898. const value = args[1];
  1899. style[type] = animateTypes4.includes(type) ? converPx(value) : value;
  1900. }
  1901. });
  1902. style.transform = style.webkitTransform = transform.join(" ");
  1903. style.transition = style.webkitTransition = Object.keys(style).map(
  1904. (type) => `${converType(type)} ${transition.duration}ms ${transition.timingFunction} ${transition.delay}ms`
  1905. ).join(",");
  1906. style.transformOrigin = style.webkitTransformOrigin = option.transformOrigin;
  1907. return style;
  1908. }
  1909. function startAnimation(context) {
  1910. const animation2 = context.animation;
  1911. if (!animation2 || !animation2.actions || !animation2.actions.length) {
  1912. return;
  1913. }
  1914. let index2 = 0;
  1915. const actions = animation2.actions;
  1916. const length = animation2.actions.length;
  1917. function animate() {
  1918. const action = actions[index2];
  1919. const transition = action.option.transition;
  1920. const style = getStyle(action);
  1921. Object.keys(style).forEach((key) => {
  1922. context.$el.style[key] = style[key];
  1923. });
  1924. index2 += 1;
  1925. if (index2 < length) {
  1926. setTimeout(animate, transition.duration + transition.delay);
  1927. }
  1928. }
  1929. setTimeout(() => {
  1930. animate();
  1931. }, 0);
  1932. }
  1933. const animation = {
  1934. props: ["animation"],
  1935. watch: {
  1936. animation: {
  1937. deep: true,
  1938. handler() {
  1939. startAnimation(this);
  1940. }
  1941. }
  1942. },
  1943. mounted() {
  1944. startAnimation(this);
  1945. }
  1946. };
  1947. const defineBuiltInComponent = (options) => {
  1948. options.__reserved = true;
  1949. const { props: props2, mixins } = options;
  1950. if (!props2 || !props2.animation) {
  1951. (mixins || (options.mixins = [])).push(animation);
  1952. }
  1953. return defineSystemComponent(options);
  1954. };
  1955. const defineSystemComponent = (options) => {
  1956. options.__reserved = true;
  1957. options.compatConfig = {
  1958. MODE: 3
  1959. // 标记为vue3
  1960. };
  1961. return defineComponent(options);
  1962. };
  1963. const defineUnsupportedComponent = (name) => {
  1964. return defineBuiltInComponent({
  1965. name: capitalize(camelize(name)),
  1966. setup() {
  1967. return () => (openBlock(), createElementBlock("uni-" + name, null, name + " is unsupported"));
  1968. }
  1969. });
  1970. };
  1971. function withWebEvent(fn) {
  1972. return fn.__wwe = true, fn;
  1973. }
  1974. function useCustomEvent(ref2, emit2) {
  1975. return (name, evt, detail) => {
  1976. if (ref2.value) {
  1977. emit2(name, normalizeCustomEvent(name, evt, ref2.value, detail || {}));
  1978. }
  1979. };
  1980. }
  1981. function useNativeEvent(emit2) {
  1982. return (name, evt) => {
  1983. emit2(name, createNativeEvent(evt));
  1984. };
  1985. }
  1986. function normalizeCustomEvent(name, domEvt, el, detail) {
  1987. let target;
  1988. target = normalizeTarget(el);
  1989. return {
  1990. type: detail.type || name,
  1991. timeStamp: domEvt.timeStamp || 0,
  1992. target,
  1993. currentTarget: target,
  1994. detail
  1995. };
  1996. }
  1997. const hoverProps = {
  1998. hoverClass: {
  1999. type: String,
  2000. default: "none"
  2001. },
  2002. hoverStopPropagation: {
  2003. type: Boolean,
  2004. default: false
  2005. },
  2006. hoverStartTime: {
  2007. type: [Number, String],
  2008. default: 50
  2009. },
  2010. hoverStayTime: {
  2011. type: [Number, String],
  2012. default: 400
  2013. }
  2014. };
  2015. function useHover(props2) {
  2016. const hovering = ref(false);
  2017. let hoverTouch = false;
  2018. let hoverStartTimer;
  2019. let hoverStayTimer;
  2020. function hoverReset() {
  2021. requestAnimationFrame(() => {
  2022. clearTimeout(hoverStayTimer);
  2023. hoverStayTimer = setTimeout(() => {
  2024. hovering.value = false;
  2025. }, parseInt(props2.hoverStayTime));
  2026. });
  2027. }
  2028. function onTouchstartPassive(evt) {
  2029. if (evt.touches.length > 1) {
  2030. return;
  2031. }
  2032. handleHoverStart(evt);
  2033. }
  2034. function onMousedown(evt) {
  2035. if (hoverTouch) {
  2036. return;
  2037. }
  2038. handleHoverStart(evt);
  2039. window.addEventListener("mouseup", handlePCHoverEnd);
  2040. }
  2041. function handleHoverStart(evt) {
  2042. if (evt._hoverPropagationStopped) {
  2043. return;
  2044. }
  2045. if (!props2.hoverClass || props2.hoverClass === "none" || props2.disabled) {
  2046. return;
  2047. }
  2048. if (props2.hoverStopPropagation) {
  2049. evt._hoverPropagationStopped = true;
  2050. }
  2051. hoverTouch = true;
  2052. hoverStartTimer = setTimeout(() => {
  2053. hovering.value = true;
  2054. if (!hoverTouch) {
  2055. hoverReset();
  2056. }
  2057. }, parseInt(props2.hoverStartTime));
  2058. }
  2059. function onTouchend() {
  2060. handleHoverEnd();
  2061. }
  2062. function onMouseup() {
  2063. if (!hoverTouch) {
  2064. return;
  2065. }
  2066. handlePCHoverEnd();
  2067. }
  2068. function handleHoverEnd() {
  2069. hoverTouch = false;
  2070. if (hovering.value) {
  2071. hoverReset();
  2072. }
  2073. }
  2074. function handlePCHoverEnd() {
  2075. handleHoverEnd();
  2076. window.removeEventListener("mouseup", handlePCHoverEnd);
  2077. }
  2078. function onTouchcancel() {
  2079. hoverTouch = false;
  2080. hovering.value = false;
  2081. clearTimeout(hoverStartTimer);
  2082. }
  2083. return {
  2084. hovering,
  2085. binding: {
  2086. onTouchstartPassive: withWebEvent(onTouchstartPassive),
  2087. onMousedown: withWebEvent(onMousedown),
  2088. onTouchend: withWebEvent(onTouchend),
  2089. onMouseup: withWebEvent(onMouseup),
  2090. onTouchcancel: withWebEvent(onTouchcancel)
  2091. }
  2092. };
  2093. }
  2094. function useBooleanAttr(props2, keys) {
  2095. if (isString(keys)) {
  2096. keys = [keys];
  2097. }
  2098. return keys.reduce((res, key) => {
  2099. if (props2[key]) {
  2100. res[key] = true;
  2101. }
  2102. return res;
  2103. }, /* @__PURE__ */ Object.create(null));
  2104. }
  2105. const uniFormKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniForm" : "uf");
  2106. const index$z = /* @__PURE__ */ defineBuiltInComponent({
  2107. name: "Form",
  2108. emits: ["submit", "reset"],
  2109. setup(_props, {
  2110. slots,
  2111. emit: emit2
  2112. }) {
  2113. const rootRef = ref(null);
  2114. provideForm(useCustomEvent(rootRef, emit2));
  2115. return () => createVNode("uni-form", {
  2116. "ref": rootRef
  2117. }, [createVNode("span", null, [slots.default && slots.default()])], 512);
  2118. }
  2119. });
  2120. function provideForm(trigger) {
  2121. const fields2 = [];
  2122. provide(uniFormKey, {
  2123. addField(field) {
  2124. fields2.push(field);
  2125. },
  2126. removeField(field) {
  2127. fields2.splice(fields2.indexOf(field), 1);
  2128. },
  2129. submit(evt) {
  2130. trigger("submit", evt, {
  2131. value: fields2.reduce((res, field) => {
  2132. if (field.submit) {
  2133. const [name, value] = field.submit();
  2134. name && (res[name] = value);
  2135. }
  2136. return res;
  2137. }, /* @__PURE__ */ Object.create(null))
  2138. });
  2139. },
  2140. reset(evt) {
  2141. fields2.forEach((field) => field.reset && field.reset());
  2142. trigger("reset", evt);
  2143. }
  2144. });
  2145. return fields2;
  2146. }
  2147. const labelProps = {
  2148. for: {
  2149. type: String,
  2150. default: ""
  2151. }
  2152. };
  2153. const uniLabelKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniLabel" : "ul");
  2154. function useProvideLabel() {
  2155. const handlers = [];
  2156. provide(uniLabelKey, {
  2157. addHandler(handler) {
  2158. handlers.push(handler);
  2159. },
  2160. removeHandler(handler) {
  2161. handlers.splice(handlers.indexOf(handler), 1);
  2162. }
  2163. });
  2164. return handlers;
  2165. }
  2166. const index$y = /* @__PURE__ */ defineBuiltInComponent({
  2167. name: "Label",
  2168. props: labelProps,
  2169. setup(props2, {
  2170. slots
  2171. }) {
  2172. const rootRef = ref(null);
  2173. const pageId = useCurrentPageId();
  2174. const handlers = useProvideLabel();
  2175. const pointer = computed(() => props2.for || slots.default && slots.default.length);
  2176. const _onClick = withWebEvent(($event) => {
  2177. const EventTarget = $event.target;
  2178. let stopPropagation = /^uni-(checkbox|radio|switch)-/.test(EventTarget.className);
  2179. if (!stopPropagation) {
  2180. stopPropagation = /^uni-(checkbox|radio|switch|button)$|^(svg|path)$/i.test(EventTarget.tagName);
  2181. }
  2182. if (stopPropagation) {
  2183. return;
  2184. }
  2185. if (props2.for) {
  2186. UniViewJSBridge.emit("uni-label-click-" + pageId + "-" + props2.for, $event, true);
  2187. } else {
  2188. handlers.length && handlers[0]($event, true);
  2189. }
  2190. });
  2191. return () => createVNode("uni-label", {
  2192. "ref": rootRef,
  2193. "class": {
  2194. "uni-label-pointer": pointer
  2195. },
  2196. "onClick": _onClick
  2197. }, [slots.default && slots.default()], 10, ["onClick"]);
  2198. }
  2199. });
  2200. function useListeners$1(props2, listeners2) {
  2201. _addListeners(props2.id, listeners2);
  2202. watch(
  2203. () => props2.id,
  2204. (newId, oldId) => {
  2205. _removeListeners(oldId, listeners2, true);
  2206. _addListeners(newId, listeners2, true);
  2207. }
  2208. );
  2209. onUnmounted(() => {
  2210. _removeListeners(props2.id, listeners2);
  2211. });
  2212. }
  2213. function _addListeners(id2, listeners2, watch2) {
  2214. const pageId = useCurrentPageId();
  2215. if (watch2 && !id2) {
  2216. return;
  2217. }
  2218. if (!isPlainObject(listeners2)) {
  2219. return;
  2220. }
  2221. Object.keys(listeners2).forEach((name) => {
  2222. if (watch2) {
  2223. if (name.indexOf("@") !== 0 && name.indexOf("uni-") !== 0) {
  2224. UniViewJSBridge.on(`uni-${name}-${pageId}-${id2}`, listeners2[name]);
  2225. }
  2226. } else {
  2227. if (name.indexOf("uni-") === 0) {
  2228. UniViewJSBridge.on(name, listeners2[name]);
  2229. } else if (id2) {
  2230. UniViewJSBridge.on(`uni-${name}-${pageId}-${id2}`, listeners2[name]);
  2231. }
  2232. }
  2233. });
  2234. }
  2235. function _removeListeners(id2, listeners2, watch2) {
  2236. const pageId = useCurrentPageId();
  2237. if (watch2 && !id2) {
  2238. return;
  2239. }
  2240. if (!isPlainObject(listeners2)) {
  2241. return;
  2242. }
  2243. Object.keys(listeners2).forEach((name) => {
  2244. if (watch2) {
  2245. if (name.indexOf("@") !== 0 && name.indexOf("uni-") !== 0) {
  2246. UniViewJSBridge.off(`uni-${name}-${pageId}-${id2}`, listeners2[name]);
  2247. }
  2248. } else {
  2249. if (name.indexOf("uni-") === 0) {
  2250. UniViewJSBridge.off(name, listeners2[name]);
  2251. } else if (id2) {
  2252. UniViewJSBridge.off(`uni-${name}-${pageId}-${id2}`, listeners2[name]);
  2253. }
  2254. }
  2255. });
  2256. }
  2257. const buttonProps = {
  2258. id: {
  2259. type: String,
  2260. default: ""
  2261. },
  2262. hoverClass: {
  2263. type: String,
  2264. default: "button-hover"
  2265. },
  2266. hoverStartTime: {
  2267. type: [Number, String],
  2268. default: 20
  2269. },
  2270. hoverStayTime: {
  2271. type: [Number, String],
  2272. default: 70
  2273. },
  2274. hoverStopPropagation: {
  2275. type: Boolean,
  2276. default: false
  2277. },
  2278. disabled: {
  2279. type: [Boolean, String],
  2280. default: false
  2281. },
  2282. formType: {
  2283. type: String,
  2284. default: ""
  2285. },
  2286. openType: {
  2287. type: String,
  2288. default: ""
  2289. },
  2290. loading: {
  2291. type: [Boolean, String],
  2292. default: false
  2293. },
  2294. plain: {
  2295. type: [Boolean, String],
  2296. default: false
  2297. }
  2298. };
  2299. const index$x = /* @__PURE__ */ defineBuiltInComponent({
  2300. name: "Button",
  2301. props: buttonProps,
  2302. setup(props2, {
  2303. slots
  2304. }) {
  2305. const rootRef = ref(null);
  2306. const uniForm = inject(uniFormKey, false);
  2307. const {
  2308. hovering,
  2309. binding
  2310. } = useHover(props2);
  2311. useI18n();
  2312. const onClick = withWebEvent((e2, isLabelClick) => {
  2313. if (props2.disabled) {
  2314. return e2.stopImmediatePropagation();
  2315. }
  2316. if (isLabelClick) {
  2317. rootRef.value.click();
  2318. }
  2319. const formType = props2.formType;
  2320. if (formType) {
  2321. if (!uniForm) {
  2322. return;
  2323. }
  2324. if (formType === "submit") {
  2325. uniForm.submit(e2);
  2326. } else if (formType === "reset") {
  2327. uniForm.reset(e2);
  2328. }
  2329. return;
  2330. }
  2331. });
  2332. const uniLabel = inject(uniLabelKey, false);
  2333. if (uniLabel) {
  2334. uniLabel.addHandler(onClick);
  2335. onBeforeUnmount(() => {
  2336. uniLabel.removeHandler(onClick);
  2337. });
  2338. }
  2339. useListeners$1(props2, {
  2340. "label-click": onClick
  2341. });
  2342. return () => {
  2343. const hoverClass = props2.hoverClass;
  2344. const booleanAttrs = useBooleanAttr(props2, "disabled");
  2345. const loadingAttrs = useBooleanAttr(props2, "loading");
  2346. const plainAttrs = useBooleanAttr(props2, "plain");
  2347. const hasHoverClass = hoverClass && hoverClass !== "none";
  2348. return createVNode("uni-button", mergeProps({
  2349. "ref": rootRef,
  2350. "onClick": onClick,
  2351. "id": props2.id,
  2352. "class": hasHoverClass && hovering.value ? hoverClass : ""
  2353. }, hasHoverClass && binding, booleanAttrs, loadingAttrs, plainAttrs), [slots.default && slots.default()], 16, ["onClick", "id"]);
  2354. };
  2355. }
  2356. });
  2357. function findElem(vm) {
  2358. return vm.$el;
  2359. }
  2360. function addBase(filePath) {
  2361. const { base: baseUrl } = __uniConfig.router;
  2362. if (addLeadingSlash(filePath).indexOf(baseUrl) === 0) {
  2363. return addLeadingSlash(filePath);
  2364. }
  2365. return baseUrl + filePath;
  2366. }
  2367. function getRealPath(filePath) {
  2368. const { base, assets } = __uniConfig.router;
  2369. if (base === "./") {
  2370. if (filePath.indexOf("./static/") === 0 || assets && filePath.indexOf("./" + assets + "/") === 0) {
  2371. filePath = filePath.slice(1);
  2372. }
  2373. }
  2374. if (filePath.indexOf("/") === 0) {
  2375. if (filePath.indexOf("//") === 0) {
  2376. filePath = "https:" + filePath;
  2377. } else {
  2378. return addBase(filePath.slice(1));
  2379. }
  2380. }
  2381. if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath) || filePath.indexOf("blob:") === 0) {
  2382. return filePath;
  2383. }
  2384. const pages = getCurrentPages();
  2385. if (pages.length) {
  2386. return addBase(
  2387. getRealRoute(pages[pages.length - 1].$page.route, filePath).slice(1)
  2388. );
  2389. }
  2390. return filePath;
  2391. }
  2392. const ua = navigator.userAgent;
  2393. const isAndroid = /* @__PURE__ */ /android/i.test(ua);
  2394. const isIOS$1 = /* @__PURE__ */ /iphone|ipad|ipod/i.test(ua);
  2395. const isWindows = /* @__PURE__ */ ua.match(/Windows NT ([\d|\d.\d]*)/i);
  2396. const isMac = /* @__PURE__ */ /Macintosh|Mac/i.test(ua);
  2397. const isLinux = /* @__PURE__ */ /Linux|X11/i.test(ua);
  2398. const isIPadOS = isMac && navigator.maxTouchPoints > 0;
  2399. function getScreenFix() {
  2400. return /^Apple/.test(navigator.vendor) && typeof window.orientation === "number";
  2401. }
  2402. function isLandscape(screenFix) {
  2403. return screenFix && Math.abs(window.orientation) === 90;
  2404. }
  2405. function getScreenWidth(screenFix, landscape) {
  2406. return screenFix ? Math[landscape ? "max" : "min"](screen.width, screen.height) : screen.width;
  2407. }
  2408. function getScreenHeight(screenFix, landscape) {
  2409. return screenFix ? Math[landscape ? "min" : "max"](screen.height, screen.width) : screen.height;
  2410. }
  2411. function getWindowWidth(screenWidth) {
  2412. return Math.min(
  2413. window.innerWidth,
  2414. document.documentElement.clientWidth,
  2415. screenWidth
  2416. ) || screenWidth;
  2417. }
  2418. function getBaseSystemInfo() {
  2419. const screenFix = getScreenFix();
  2420. const windowWidth = getWindowWidth(
  2421. getScreenWidth(screenFix, isLandscape(screenFix))
  2422. );
  2423. return {
  2424. platform: isIOS$1 ? "ios" : "other",
  2425. pixelRatio: window.devicePixelRatio,
  2426. windowWidth
  2427. };
  2428. }
  2429. function operateVideoPlayer(videoId, pageId, type, data) {
  2430. UniServiceJSBridge.invokeViewMethod(
  2431. "video." + videoId,
  2432. {
  2433. videoId,
  2434. type,
  2435. data
  2436. },
  2437. pageId
  2438. );
  2439. }
  2440. function operateMap(id2, pageId, type, data, operateMapCallback2) {
  2441. UniServiceJSBridge.invokeViewMethod(
  2442. "map." + id2,
  2443. {
  2444. type,
  2445. data
  2446. },
  2447. pageId,
  2448. operateMapCallback2
  2449. );
  2450. }
  2451. function getRootInfo(fields2) {
  2452. const info = {};
  2453. if (fields2.id) {
  2454. info.id = "";
  2455. }
  2456. if (fields2.dataset) {
  2457. info.dataset = {};
  2458. }
  2459. if (fields2.rect) {
  2460. info.left = 0;
  2461. info.right = 0;
  2462. info.top = 0;
  2463. info.bottom = 0;
  2464. }
  2465. if (fields2.size) {
  2466. info.width = document.documentElement.clientWidth;
  2467. info.height = document.documentElement.clientHeight;
  2468. }
  2469. if (fields2.scrollOffset) {
  2470. const documentElement2 = document.documentElement;
  2471. const body = document.body;
  2472. info.scrollLeft = documentElement2.scrollLeft || body.scrollLeft || 0;
  2473. info.scrollTop = documentElement2.scrollTop || body.scrollTop || 0;
  2474. info.scrollHeight = documentElement2.scrollHeight || body.scrollHeight || 0;
  2475. info.scrollWidth = documentElement2.scrollWidth || body.scrollWidth || 0;
  2476. }
  2477. return info;
  2478. }
  2479. function getNodeInfo(el, fields2) {
  2480. const info = {};
  2481. const { top, topWindowHeight } = getWindowOffset();
  2482. if (fields2.node) {
  2483. const tagName = el.tagName.split("-")[1];
  2484. if (tagName) {
  2485. info.node = el.querySelector(tagName);
  2486. }
  2487. }
  2488. if (fields2.id) {
  2489. info.id = el.id;
  2490. }
  2491. if (fields2.dataset) {
  2492. info.dataset = getCustomDataset(el);
  2493. }
  2494. if (fields2.rect || fields2.size) {
  2495. const rect = el.getBoundingClientRect();
  2496. if (fields2.rect) {
  2497. info.left = rect.left;
  2498. info.right = rect.right;
  2499. info.top = rect.top - top - topWindowHeight;
  2500. info.bottom = rect.bottom - top - topWindowHeight;
  2501. }
  2502. if (fields2.size) {
  2503. info.width = rect.width;
  2504. info.height = rect.height;
  2505. }
  2506. }
  2507. if (isArray(fields2.properties)) {
  2508. fields2.properties.forEach((prop) => {
  2509. prop = prop.replace(/-([a-z])/g, function(e2, t2) {
  2510. return t2.toUpperCase();
  2511. });
  2512. });
  2513. }
  2514. if (fields2.scrollOffset) {
  2515. if (el.tagName === "UNI-SCROLL-VIEW") {
  2516. const scroll = el.children[0].children[0];
  2517. info.scrollLeft = scroll.scrollLeft;
  2518. info.scrollTop = scroll.scrollTop;
  2519. info.scrollHeight = scroll.scrollHeight;
  2520. info.scrollWidth = scroll.scrollWidth;
  2521. } else {
  2522. info.scrollLeft = 0;
  2523. info.scrollTop = 0;
  2524. info.scrollHeight = 0;
  2525. info.scrollWidth = 0;
  2526. }
  2527. }
  2528. if (isArray(fields2.computedStyle)) {
  2529. const sytle = getComputedStyle(el);
  2530. fields2.computedStyle.forEach((name) => {
  2531. info[name] = sytle[name];
  2532. });
  2533. }
  2534. if (fields2.context) {
  2535. info.contextInfo = getContextInfo(el);
  2536. }
  2537. return info;
  2538. }
  2539. function findElm(component, pageVm) {
  2540. if (!component) {
  2541. return pageVm.$el;
  2542. }
  2543. return component.$el;
  2544. }
  2545. function matches(element, selectors) {
  2546. const matches2 = element.matches || element.matchesSelector || element.mozMatchesSelector || element.msMatchesSelector || element.oMatchesSelector || element.webkitMatchesSelector || function(selectors2) {
  2547. const matches3 = this.parentElement.querySelectorAll(
  2548. selectors2
  2549. );
  2550. let i = matches3.length;
  2551. while (--i >= 0 && matches3.item(i) !== this) {
  2552. }
  2553. return i > -1;
  2554. };
  2555. return matches2.call(element, selectors);
  2556. }
  2557. function getNodesInfo(pageVm, component, selector, single, fields2) {
  2558. const selfElement = findElm(component, pageVm);
  2559. const parentElement = selfElement.parentElement;
  2560. if (!parentElement) {
  2561. return single ? null : [];
  2562. }
  2563. const { nodeType } = selfElement;
  2564. const maybeFragment = nodeType === 3 || nodeType === 8;
  2565. if (single) {
  2566. const node = maybeFragment ? parentElement.querySelector(selector) : matches(selfElement, selector) ? selfElement : selfElement.querySelector(selector);
  2567. if (node) {
  2568. return getNodeInfo(node, fields2);
  2569. }
  2570. return null;
  2571. } else {
  2572. let infos = [];
  2573. const nodeList = (maybeFragment ? parentElement : selfElement).querySelectorAll(selector);
  2574. if (nodeList && nodeList.length) {
  2575. [].forEach.call(nodeList, (node) => {
  2576. infos.push(getNodeInfo(node, fields2));
  2577. });
  2578. }
  2579. if (!maybeFragment && matches(selfElement, selector)) {
  2580. infos.unshift(getNodeInfo(selfElement, fields2));
  2581. }
  2582. return infos;
  2583. }
  2584. }
  2585. function requestComponentInfo(page, reqs, callback) {
  2586. const result = [];
  2587. reqs.forEach(({ component, selector, single, fields: fields2 }) => {
  2588. if (component === null) {
  2589. result.push(getRootInfo(fields2));
  2590. } else {
  2591. result.push(getNodesInfo(page, component, selector, single, fields2));
  2592. }
  2593. });
  2594. callback(result);
  2595. }
  2596. function setCurrentPageMeta(_page, { pageStyle, rootFontSize }) {
  2597. if (pageStyle) {
  2598. const pageElm = document.querySelector("uni-page-body") || document.body;
  2599. pageElm.setAttribute("style", pageStyle);
  2600. }
  2601. if (rootFontSize && document.documentElement.style.fontSize !== rootFontSize) {
  2602. document.documentElement.style.fontSize = rootFontSize;
  2603. }
  2604. }
  2605. var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  2606. var lookup = /* @__PURE__ */ function() {
  2607. const lookup2 = new Uint8Array(256);
  2608. for (var i = 0; i < chars.length; i++) {
  2609. lookup2[chars.charCodeAt(i)] = i;
  2610. }
  2611. return lookup2;
  2612. }();
  2613. function encode$1(arraybuffer) {
  2614. var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = "";
  2615. for (i = 0; i < len; i += 3) {
  2616. base64 += chars[bytes[i] >> 2];
  2617. base64 += chars[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];
  2618. base64 += chars[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];
  2619. base64 += chars[bytes[i + 2] & 63];
  2620. }
  2621. if (len % 3 === 2) {
  2622. base64 = base64.substring(0, base64.length - 1) + "=";
  2623. } else if (len % 3 === 1) {
  2624. base64 = base64.substring(0, base64.length - 2) + "==";
  2625. }
  2626. return base64;
  2627. }
  2628. function decode(base64) {
  2629. var bufferLength = base64.length * 0.75, len = base64.length, i, p2 = 0, encoded1, encoded2, encoded3, encoded4;
  2630. if (base64[base64.length - 1] === "=") {
  2631. bufferLength--;
  2632. if (base64[base64.length - 2] === "=") {
  2633. bufferLength--;
  2634. }
  2635. }
  2636. var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);
  2637. for (i = 0; i < len; i += 4) {
  2638. encoded1 = lookup[base64.charCodeAt(i)];
  2639. encoded2 = lookup[base64.charCodeAt(i + 1)];
  2640. encoded3 = lookup[base64.charCodeAt(i + 2)];
  2641. encoded4 = lookup[base64.charCodeAt(i + 3)];
  2642. bytes[p2++] = encoded1 << 2 | encoded2 >> 4;
  2643. bytes[p2++] = (encoded2 & 15) << 4 | encoded3 >> 2;
  2644. bytes[p2++] = (encoded3 & 3) << 6 | encoded4 & 63;
  2645. }
  2646. return arraybuffer;
  2647. }
  2648. const CHOOSE_SIZE_TYPES = ["original", "compressed"];
  2649. const CHOOSE_SOURCE_TYPES = ["album", "camera"];
  2650. const HTTP_METHODS = [
  2651. "GET",
  2652. "OPTIONS",
  2653. "HEAD",
  2654. "POST",
  2655. "PUT",
  2656. "DELETE",
  2657. "TRACE",
  2658. "CONNECT",
  2659. "PATCH"
  2660. ];
  2661. function elemInArray(str, arr) {
  2662. if (!str || arr.indexOf(str) === -1) {
  2663. return arr[0];
  2664. }
  2665. return str;
  2666. }
  2667. function elemsInArray(strArr, optionalVal) {
  2668. if (!isArray(strArr) || strArr.length === 0 || strArr.find((val) => optionalVal.indexOf(val) === -1)) {
  2669. return optionalVal;
  2670. }
  2671. return strArr;
  2672. }
  2673. function validateProtocolFail(name, msg) {
  2674. console.warn(`${name}: ${msg}`);
  2675. }
  2676. function validateProtocol(name, data, protocol, onFail) {
  2677. if (!onFail) {
  2678. onFail = validateProtocolFail;
  2679. }
  2680. for (const key in protocol) {
  2681. const errMsg = validateProp(
  2682. key,
  2683. data[key],
  2684. protocol[key],
  2685. !hasOwn(data, key)
  2686. );
  2687. if (isString(errMsg)) {
  2688. onFail(name, errMsg);
  2689. }
  2690. }
  2691. }
  2692. function validateProtocols(name, args, protocol, onFail) {
  2693. if (!protocol) {
  2694. return;
  2695. }
  2696. if (!isArray(protocol)) {
  2697. return validateProtocol(
  2698. name,
  2699. args[0] || /* @__PURE__ */ Object.create(null),
  2700. protocol,
  2701. onFail
  2702. );
  2703. }
  2704. const len = protocol.length;
  2705. const argsLen = args.length;
  2706. for (let i = 0; i < len; i++) {
  2707. const opts = protocol[i];
  2708. const data = /* @__PURE__ */ Object.create(null);
  2709. if (argsLen > i) {
  2710. data[opts.name] = args[i];
  2711. }
  2712. validateProtocol(name, data, { [opts.name]: opts }, onFail);
  2713. }
  2714. }
  2715. function validateProp(name, value, prop, isAbsent) {
  2716. if (!isPlainObject(prop)) {
  2717. prop = { type: prop };
  2718. }
  2719. const { type, required, validator: validator2 } = prop;
  2720. if (required && isAbsent) {
  2721. return 'Missing required args: "' + name + '"';
  2722. }
  2723. if (value == null && !required) {
  2724. return;
  2725. }
  2726. if (type != null) {
  2727. let isValid = false;
  2728. const types = isArray(type) ? type : [type];
  2729. const expectedTypes = [];
  2730. for (let i = 0; i < types.length && !isValid; i++) {
  2731. const { valid, expectedType } = assertType(value, types[i]);
  2732. expectedTypes.push(expectedType || "");
  2733. isValid = valid;
  2734. }
  2735. if (!isValid) {
  2736. return getInvalidTypeMessage(name, value, expectedTypes);
  2737. }
  2738. }
  2739. if (validator2) {
  2740. return validator2(value);
  2741. }
  2742. }
  2743. const isSimpleType = /* @__PURE__ */ makeMap$1(
  2744. "String,Number,Boolean,Function,Symbol"
  2745. );
  2746. function assertType(value, type) {
  2747. let valid;
  2748. const expectedType = getType(type);
  2749. if (isSimpleType(expectedType)) {
  2750. const t2 = typeof value;
  2751. valid = t2 === expectedType.toLowerCase();
  2752. if (!valid && t2 === "object") {
  2753. valid = value instanceof type;
  2754. }
  2755. } else if (expectedType === "Object") {
  2756. valid = isObject(value);
  2757. } else if (expectedType === "Array") {
  2758. valid = isArray(value);
  2759. } else {
  2760. {
  2761. valid = value instanceof type;
  2762. }
  2763. }
  2764. return {
  2765. valid,
  2766. expectedType
  2767. };
  2768. }
  2769. function getInvalidTypeMessage(name, value, expectedTypes) {
  2770. let message = `Invalid args: type check failed for args "${name}". Expected ${expectedTypes.map(capitalize).join(", ")}`;
  2771. const expectedType = expectedTypes[0];
  2772. const receivedType = toRawType(value);
  2773. const expectedValue = styleValue(value, expectedType);
  2774. const receivedValue = styleValue(value, receivedType);
  2775. if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
  2776. message += ` with value ${expectedValue}`;
  2777. }
  2778. message += `, got ${receivedType} `;
  2779. if (isExplicable(receivedType)) {
  2780. message += `with value ${receivedValue}.`;
  2781. }
  2782. return message;
  2783. }
  2784. function getType(ctor) {
  2785. const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
  2786. return match ? match[1] : "";
  2787. }
  2788. function styleValue(value, type) {
  2789. if (type === "String") {
  2790. return `"${value}"`;
  2791. } else if (type === "Number") {
  2792. return `${Number(value)}`;
  2793. } else {
  2794. return `${value}`;
  2795. }
  2796. }
  2797. function isExplicable(type) {
  2798. const explicitTypes = ["string", "number", "boolean"];
  2799. return explicitTypes.some((elem) => type.toLowerCase() === elem);
  2800. }
  2801. function isBoolean(...args) {
  2802. return args.some((elem) => elem.toLowerCase() === "boolean");
  2803. }
  2804. function tryCatch(fn) {
  2805. return function() {
  2806. try {
  2807. return fn.apply(fn, arguments);
  2808. } catch (e2) {
  2809. console.error(e2);
  2810. }
  2811. };
  2812. }
  2813. let invokeCallbackId = 1;
  2814. const invokeCallbacks = {};
  2815. function addInvokeCallback(id2, name, callback, keepAlive = false) {
  2816. invokeCallbacks[id2] = {
  2817. name,
  2818. keepAlive,
  2819. callback
  2820. };
  2821. return id2;
  2822. }
  2823. function invokeCallback(id2, res, extras) {
  2824. if (typeof id2 === "number") {
  2825. const opts = invokeCallbacks[id2];
  2826. if (opts) {
  2827. if (!opts.keepAlive) {
  2828. delete invokeCallbacks[id2];
  2829. }
  2830. return opts.callback(res, extras);
  2831. }
  2832. }
  2833. return res;
  2834. }
  2835. function findInvokeCallbackByName(name) {
  2836. for (const key in invokeCallbacks) {
  2837. if (invokeCallbacks[key].name === name) {
  2838. return true;
  2839. }
  2840. }
  2841. return false;
  2842. }
  2843. function removeKeepAliveApiCallback(name, callback) {
  2844. for (const key in invokeCallbacks) {
  2845. const item = invokeCallbacks[key];
  2846. if (item.callback === callback && item.name === name) {
  2847. delete invokeCallbacks[key];
  2848. }
  2849. }
  2850. }
  2851. function offKeepAliveApiCallback(name) {
  2852. UniServiceJSBridge.off("api." + name);
  2853. }
  2854. function onKeepAliveApiCallback(name) {
  2855. UniServiceJSBridge.on("api." + name, (res) => {
  2856. for (const key in invokeCallbacks) {
  2857. const opts = invokeCallbacks[key];
  2858. if (opts.name === name) {
  2859. opts.callback(res);
  2860. }
  2861. }
  2862. });
  2863. }
  2864. function createKeepAliveApiCallback(name, callback) {
  2865. return addInvokeCallback(invokeCallbackId++, name, callback, true);
  2866. }
  2867. const API_SUCCESS = "success";
  2868. const API_FAIL = "fail";
  2869. const API_COMPLETE = "complete";
  2870. function getApiCallbacks(args) {
  2871. const apiCallbacks = {};
  2872. for (const name in args) {
  2873. const fn = args[name];
  2874. if (isFunction(fn)) {
  2875. apiCallbacks[name] = tryCatch(fn);
  2876. delete args[name];
  2877. }
  2878. }
  2879. return apiCallbacks;
  2880. }
  2881. function normalizeErrMsg$1(errMsg, name) {
  2882. if (!errMsg || errMsg.indexOf(":fail") === -1) {
  2883. return name + ":ok";
  2884. }
  2885. return name + errMsg.substring(errMsg.indexOf(":fail"));
  2886. }
  2887. function createAsyncApiCallback(name, args = {}, { beforeAll, beforeSuccess } = {}) {
  2888. if (!isPlainObject(args)) {
  2889. args = {};
  2890. }
  2891. const { success, fail, complete } = getApiCallbacks(args);
  2892. const hasSuccess = isFunction(success);
  2893. const hasFail = isFunction(fail);
  2894. const hasComplete = isFunction(complete);
  2895. const callbackId = invokeCallbackId++;
  2896. addInvokeCallback(callbackId, name, (res) => {
  2897. res = res || {};
  2898. res.errMsg = normalizeErrMsg$1(res.errMsg, name);
  2899. isFunction(beforeAll) && beforeAll(res);
  2900. if (res.errMsg === name + ":ok") {
  2901. isFunction(beforeSuccess) && beforeSuccess(res, args);
  2902. hasSuccess && success(res);
  2903. } else {
  2904. hasFail && fail(res);
  2905. }
  2906. hasComplete && complete(res);
  2907. });
  2908. return callbackId;
  2909. }
  2910. const HOOK_SUCCESS = "success";
  2911. const HOOK_FAIL = "fail";
  2912. const HOOK_COMPLETE = "complete";
  2913. const globalInterceptors = {};
  2914. const scopedInterceptors = {};
  2915. function wrapperHook(hook, params) {
  2916. return function(data) {
  2917. return hook(data, params) || data;
  2918. };
  2919. }
  2920. function queue(hooks, data, params) {
  2921. let promise = false;
  2922. for (let i = 0; i < hooks.length; i++) {
  2923. const hook = hooks[i];
  2924. if (promise) {
  2925. promise = Promise.resolve(wrapperHook(hook, params));
  2926. } else {
  2927. const res = hook(data, params);
  2928. if (isPromise(res)) {
  2929. promise = Promise.resolve(res);
  2930. }
  2931. if (res === false) {
  2932. return {
  2933. then() {
  2934. },
  2935. catch() {
  2936. }
  2937. };
  2938. }
  2939. }
  2940. }
  2941. return promise || {
  2942. then(callback) {
  2943. return callback(data);
  2944. },
  2945. catch() {
  2946. }
  2947. };
  2948. }
  2949. function wrapperOptions(interceptors2, options = {}) {
  2950. [HOOK_SUCCESS, HOOK_FAIL, HOOK_COMPLETE].forEach((name) => {
  2951. const hooks = interceptors2[name];
  2952. if (!isArray(hooks)) {
  2953. return;
  2954. }
  2955. const oldCallback = options[name];
  2956. options[name] = function callbackInterceptor(res) {
  2957. queue(hooks, res, options).then((res2) => {
  2958. return isFunction(oldCallback) && oldCallback(res2) || res2;
  2959. });
  2960. };
  2961. });
  2962. return options;
  2963. }
  2964. function wrapperReturnValue(method, returnValue) {
  2965. const returnValueHooks = [];
  2966. if (isArray(globalInterceptors.returnValue)) {
  2967. returnValueHooks.push(...globalInterceptors.returnValue);
  2968. }
  2969. const interceptor = scopedInterceptors[method];
  2970. if (interceptor && isArray(interceptor.returnValue)) {
  2971. returnValueHooks.push(...interceptor.returnValue);
  2972. }
  2973. returnValueHooks.forEach((hook) => {
  2974. returnValue = hook(returnValue) || returnValue;
  2975. });
  2976. return returnValue;
  2977. }
  2978. function getApiInterceptorHooks(method) {
  2979. const interceptor = /* @__PURE__ */ Object.create(null);
  2980. Object.keys(globalInterceptors).forEach((hook) => {
  2981. if (hook !== "returnValue") {
  2982. interceptor[hook] = globalInterceptors[hook].slice();
  2983. }
  2984. });
  2985. const scopedInterceptor = scopedInterceptors[method];
  2986. if (scopedInterceptor) {
  2987. Object.keys(scopedInterceptor).forEach((hook) => {
  2988. if (hook !== "returnValue") {
  2989. interceptor[hook] = (interceptor[hook] || []).concat(
  2990. scopedInterceptor[hook]
  2991. );
  2992. }
  2993. });
  2994. }
  2995. return interceptor;
  2996. }
  2997. function invokeApi(method, api2, options, params) {
  2998. const interceptor = getApiInterceptorHooks(method);
  2999. if (interceptor && Object.keys(interceptor).length) {
  3000. if (isArray(interceptor.invoke)) {
  3001. const res = queue(interceptor.invoke, options);
  3002. return res.then((options2) => {
  3003. return api2(
  3004. wrapperOptions(getApiInterceptorHooks(method), options2),
  3005. ...params
  3006. );
  3007. });
  3008. } else {
  3009. return api2(wrapperOptions(interceptor, options), ...params);
  3010. }
  3011. }
  3012. return api2(options, ...params);
  3013. }
  3014. function hasCallback(args) {
  3015. if (isPlainObject(args) && [API_SUCCESS, API_FAIL, API_COMPLETE].find(
  3016. (cb) => isFunction(args[cb])
  3017. )) {
  3018. return true;
  3019. }
  3020. return false;
  3021. }
  3022. function handlePromise(promise) {
  3023. return promise;
  3024. }
  3025. function promisify(name, fn) {
  3026. return (args = {}, ...rest) => {
  3027. if (hasCallback(args)) {
  3028. return wrapperReturnValue(name, invokeApi(name, fn, args, rest));
  3029. }
  3030. return wrapperReturnValue(
  3031. name,
  3032. handlePromise(
  3033. new Promise((resolve, reject) => {
  3034. invokeApi(
  3035. name,
  3036. fn,
  3037. extend(args, { success: resolve, fail: reject }),
  3038. rest
  3039. );
  3040. })
  3041. )
  3042. );
  3043. };
  3044. }
  3045. function formatApiArgs(args, options) {
  3046. const params = args[0];
  3047. if (!options || !isPlainObject(options.formatArgs) && isPlainObject(params)) {
  3048. return;
  3049. }
  3050. const formatArgs = options.formatArgs;
  3051. const keys = Object.keys(formatArgs);
  3052. for (let i = 0; i < keys.length; i++) {
  3053. const name = keys[i];
  3054. const formatterOrDefaultValue = formatArgs[name];
  3055. if (isFunction(formatterOrDefaultValue)) {
  3056. const errMsg = formatterOrDefaultValue(args[0][name], params);
  3057. if (isString(errMsg)) {
  3058. return errMsg;
  3059. }
  3060. } else {
  3061. if (!hasOwn(params, name)) {
  3062. params[name] = formatterOrDefaultValue;
  3063. }
  3064. }
  3065. }
  3066. }
  3067. function invokeSuccess(id2, name, res) {
  3068. const result = {
  3069. errMsg: name + ":ok"
  3070. };
  3071. return invokeCallback(id2, extend(res || {}, result));
  3072. }
  3073. function invokeFail(id2, name, errMsg, errRes = {}) {
  3074. const apiErrMsg = name + ":fail" + (errMsg ? " " + errMsg : "");
  3075. delete errRes.errCode;
  3076. return invokeCallback(
  3077. id2,
  3078. typeof UniError !== "undefined" ? typeof errRes.errCode !== "undefined" ? new UniError(name, errRes.errCode, apiErrMsg) : new UniError(apiErrMsg, errRes) : extend({ errMsg: apiErrMsg }, errRes)
  3079. );
  3080. }
  3081. function beforeInvokeApi(name, args, protocol, options) {
  3082. if (process.env.NODE_ENV !== "production") {
  3083. validateProtocols(name, args, protocol);
  3084. }
  3085. if (options && options.beforeInvoke) {
  3086. const errMsg2 = options.beforeInvoke(args);
  3087. if (isString(errMsg2)) {
  3088. return errMsg2;
  3089. }
  3090. }
  3091. const errMsg = formatApiArgs(args, options);
  3092. if (errMsg) {
  3093. return errMsg;
  3094. }
  3095. }
  3096. function checkCallback(callback) {
  3097. if (!isFunction(callback)) {
  3098. throw new Error(
  3099. 'Invalid args: type check failed for args "callback". Expected Function'
  3100. );
  3101. }
  3102. }
  3103. function wrapperOnApi(name, fn, options) {
  3104. return (callback) => {
  3105. checkCallback(callback);
  3106. const errMsg = beforeInvokeApi(name, [callback], void 0, options);
  3107. if (errMsg) {
  3108. throw new Error(errMsg);
  3109. }
  3110. const isFirstInvokeOnApi = !findInvokeCallbackByName(name);
  3111. createKeepAliveApiCallback(name, callback);
  3112. if (isFirstInvokeOnApi) {
  3113. onKeepAliveApiCallback(name);
  3114. fn();
  3115. }
  3116. };
  3117. }
  3118. function wrapperOffApi(name, fn, options) {
  3119. return (callback) => {
  3120. checkCallback(callback);
  3121. const errMsg = beforeInvokeApi(name, [callback], void 0, options);
  3122. if (errMsg) {
  3123. throw new Error(errMsg);
  3124. }
  3125. name = name.replace("off", "on");
  3126. removeKeepAliveApiCallback(name, callback);
  3127. const hasInvokeOnApi = findInvokeCallbackByName(name);
  3128. if (!hasInvokeOnApi) {
  3129. offKeepAliveApiCallback(name);
  3130. fn();
  3131. }
  3132. };
  3133. }
  3134. function normalizeErrMsg(errMsg) {
  3135. if (!errMsg || isString(errMsg)) {
  3136. return errMsg;
  3137. }
  3138. if (errMsg.stack) {
  3139. console.error(errMsg.message + LINEFEED + errMsg.stack);
  3140. return errMsg.message;
  3141. }
  3142. return errMsg;
  3143. }
  3144. function wrapperTaskApi(name, fn, protocol, options) {
  3145. return (args) => {
  3146. const id2 = createAsyncApiCallback(name, args, options);
  3147. const errMsg = beforeInvokeApi(name, [args], protocol, options);
  3148. if (errMsg) {
  3149. return invokeFail(id2, name, errMsg);
  3150. }
  3151. return fn(args, {
  3152. resolve: (res) => invokeSuccess(id2, name, res),
  3153. reject: (errMsg2, errRes) => invokeFail(id2, name, normalizeErrMsg(errMsg2), errRes)
  3154. });
  3155. };
  3156. }
  3157. function wrapperSyncApi(name, fn, protocol, options) {
  3158. return (...args) => {
  3159. const errMsg = beforeInvokeApi(name, args, protocol, options);
  3160. if (errMsg) {
  3161. throw new Error(errMsg);
  3162. }
  3163. return fn.apply(null, args);
  3164. };
  3165. }
  3166. function wrapperAsyncApi(name, fn, protocol, options) {
  3167. return wrapperTaskApi(name, fn, protocol, options);
  3168. }
  3169. function defineOnApi(name, fn, options) {
  3170. return wrapperOnApi(name, fn, options);
  3171. }
  3172. function defineOffApi(name, fn, options) {
  3173. return wrapperOffApi(name, fn, options);
  3174. }
  3175. function defineTaskApi(name, fn, protocol, options) {
  3176. return promisify(
  3177. name,
  3178. wrapperTaskApi(name, fn, process.env.NODE_ENV !== "production" ? protocol : void 0, options)
  3179. );
  3180. }
  3181. function defineSyncApi(name, fn, protocol, options) {
  3182. return wrapperSyncApi(
  3183. name,
  3184. fn,
  3185. process.env.NODE_ENV !== "production" ? protocol : void 0,
  3186. options
  3187. );
  3188. }
  3189. function defineAsyncApi(name, fn, protocol, options) {
  3190. return promisify(
  3191. name,
  3192. wrapperAsyncApi(name, fn, process.env.NODE_ENV !== "production" ? protocol : void 0, options)
  3193. );
  3194. }
  3195. function createUnsupportedMsg(name) {
  3196. return `method 'uni.${name}' not supported`;
  3197. }
  3198. function createUnsupportedSyncApi(name) {
  3199. return () => {
  3200. console.error(createUnsupportedMsg(name));
  3201. };
  3202. }
  3203. const createUnsupportedOnApi = createUnsupportedSyncApi;
  3204. function createUnsupportedAsyncApi(name) {
  3205. return (_args, { reject }) => {
  3206. return reject(createUnsupportedMsg(name));
  3207. };
  3208. }
  3209. const API_BASE64_TO_ARRAY_BUFFER = "base64ToArrayBuffer";
  3210. const Base64ToArrayBufferProtocol = [
  3211. {
  3212. name: "base64",
  3213. type: String,
  3214. required: true
  3215. }
  3216. ];
  3217. const API_ARRAY_BUFFER_TO_BASE64 = "arrayBufferToBase64";
  3218. const ArrayBufferToBase64Protocol = [
  3219. {
  3220. name: "arrayBuffer",
  3221. type: [ArrayBuffer, Uint8Array],
  3222. required: true
  3223. }
  3224. ];
  3225. const base64ToArrayBuffer = /* @__PURE__ */ defineSyncApi(
  3226. API_BASE64_TO_ARRAY_BUFFER,
  3227. (base64) => {
  3228. return decode(base64);
  3229. },
  3230. Base64ToArrayBufferProtocol
  3231. );
  3232. const arrayBufferToBase64 = /* @__PURE__ */ defineSyncApi(
  3233. API_ARRAY_BUFFER_TO_BASE64,
  3234. (arrayBuffer) => {
  3235. return encode$1(arrayBuffer);
  3236. },
  3237. ArrayBufferToBase64Protocol
  3238. );
  3239. const API_UPX2PX = "upx2px";
  3240. const Upx2pxProtocol = [
  3241. {
  3242. name: "upx",
  3243. type: [Number, String],
  3244. required: true
  3245. }
  3246. ];
  3247. const EPS = 1e-4;
  3248. const BASE_DEVICE_WIDTH = 750;
  3249. let isIOS = false;
  3250. let deviceWidth = 0;
  3251. let deviceDPR = 0;
  3252. let maxWidth = 960;
  3253. let baseWidth = 375;
  3254. let includeWidth = 750;
  3255. function checkDeviceWidth() {
  3256. const { platform, pixelRatio: pixelRatio2, windowWidth } = getBaseSystemInfo();
  3257. deviceWidth = windowWidth;
  3258. deviceDPR = pixelRatio2;
  3259. isIOS = platform === "ios";
  3260. }
  3261. function checkValue(value, defaultValue) {
  3262. const newValue = Number(value);
  3263. return isNaN(newValue) ? defaultValue : newValue;
  3264. }
  3265. function checkMaxWidth() {
  3266. const config = __uniConfig.globalStyle || {};
  3267. maxWidth = checkValue(config.rpxCalcMaxDeviceWidth, 960);
  3268. baseWidth = checkValue(config.rpxCalcBaseDeviceWidth, 375);
  3269. includeWidth = checkValue(config.rpxCalcBaseDeviceWidth, 750);
  3270. }
  3271. const upx2px = /* @__PURE__ */ defineSyncApi(
  3272. API_UPX2PX,
  3273. (number, newDeviceWidth) => {
  3274. if (deviceWidth === 0) {
  3275. checkDeviceWidth();
  3276. {
  3277. checkMaxWidth();
  3278. }
  3279. }
  3280. number = Number(number);
  3281. if (number === 0) {
  3282. return 0;
  3283. }
  3284. let width = newDeviceWidth || deviceWidth;
  3285. {
  3286. width = number === includeWidth || width <= maxWidth ? width : baseWidth;
  3287. }
  3288. let result = number / BASE_DEVICE_WIDTH * width;
  3289. if (result < 0) {
  3290. result = -result;
  3291. }
  3292. result = Math.floor(result + EPS);
  3293. if (result === 0) {
  3294. if (deviceDPR === 1 || !isIOS) {
  3295. result = 1;
  3296. } else {
  3297. result = 0.5;
  3298. }
  3299. }
  3300. return number < 0 ? -result : result;
  3301. },
  3302. Upx2pxProtocol
  3303. );
  3304. const API_ADD_INTERCEPTOR = "addInterceptor";
  3305. const API_REMOVE_INTERCEPTOR = "removeInterceptor";
  3306. const AddInterceptorProtocol = [
  3307. {
  3308. name: "method",
  3309. type: [String, Object],
  3310. required: true
  3311. }
  3312. ];
  3313. const RemoveInterceptorProtocol = AddInterceptorProtocol;
  3314. function mergeInterceptorHook(interceptors2, interceptor) {
  3315. Object.keys(interceptor).forEach((hook) => {
  3316. if (isFunction(interceptor[hook])) {
  3317. interceptors2[hook] = mergeHook(
  3318. interceptors2[hook],
  3319. interceptor[hook]
  3320. );
  3321. }
  3322. });
  3323. }
  3324. function removeInterceptorHook(interceptors2, interceptor) {
  3325. if (!interceptors2 || !interceptor) {
  3326. return;
  3327. }
  3328. Object.keys(interceptor).forEach((name) => {
  3329. const hooks = interceptors2[name];
  3330. const hook = interceptor[name];
  3331. if (isArray(hooks) && isFunction(hook)) {
  3332. remove(hooks, hook);
  3333. }
  3334. });
  3335. }
  3336. function mergeHook(parentVal, childVal) {
  3337. const res = childVal ? parentVal ? parentVal.concat(childVal) : isArray(childVal) ? childVal : [childVal] : parentVal;
  3338. return res ? dedupeHooks(res) : res;
  3339. }
  3340. function dedupeHooks(hooks) {
  3341. const res = [];
  3342. for (let i = 0; i < hooks.length; i++) {
  3343. if (res.indexOf(hooks[i]) === -1) {
  3344. res.push(hooks[i]);
  3345. }
  3346. }
  3347. return res;
  3348. }
  3349. const addInterceptor = /* @__PURE__ */ defineSyncApi(
  3350. API_ADD_INTERCEPTOR,
  3351. (method, interceptor) => {
  3352. if (isString(method) && isPlainObject(interceptor)) {
  3353. mergeInterceptorHook(
  3354. scopedInterceptors[method] || (scopedInterceptors[method] = {}),
  3355. interceptor
  3356. );
  3357. } else if (isPlainObject(method)) {
  3358. mergeInterceptorHook(globalInterceptors, method);
  3359. }
  3360. },
  3361. AddInterceptorProtocol
  3362. );
  3363. const removeInterceptor = /* @__PURE__ */ defineSyncApi(
  3364. API_REMOVE_INTERCEPTOR,
  3365. (method, interceptor) => {
  3366. if (isString(method)) {
  3367. if (isPlainObject(interceptor)) {
  3368. removeInterceptorHook(scopedInterceptors[method], interceptor);
  3369. } else {
  3370. delete scopedInterceptors[method];
  3371. }
  3372. } else if (isPlainObject(method)) {
  3373. removeInterceptorHook(globalInterceptors, method);
  3374. }
  3375. },
  3376. RemoveInterceptorProtocol
  3377. );
  3378. const interceptors = {};
  3379. const API_ON = "$on";
  3380. const OnProtocol = [
  3381. {
  3382. name: "event",
  3383. type: String,
  3384. required: true
  3385. },
  3386. {
  3387. name: "callback",
  3388. type: Function,
  3389. required: true
  3390. }
  3391. ];
  3392. const API_ONCE = "$once";
  3393. const OnceProtocol = OnProtocol;
  3394. const API_OFF = "$off";
  3395. const OffProtocol = [
  3396. {
  3397. name: "event",
  3398. type: [String, Array]
  3399. },
  3400. {
  3401. name: "callback",
  3402. type: Function
  3403. }
  3404. ];
  3405. const API_EMIT = "$emit";
  3406. const EmitProtocol = [
  3407. {
  3408. name: "event",
  3409. type: String,
  3410. required: true
  3411. }
  3412. ];
  3413. const emitter = new Emitter();
  3414. const $on = /* @__PURE__ */ defineSyncApi(
  3415. API_ON,
  3416. (name, callback) => {
  3417. emitter.on(name, callback);
  3418. return () => emitter.off(name, callback);
  3419. },
  3420. OnProtocol
  3421. );
  3422. const $once = /* @__PURE__ */ defineSyncApi(
  3423. API_ONCE,
  3424. (name, callback) => {
  3425. emitter.once(name, callback);
  3426. return () => emitter.off(name, callback);
  3427. },
  3428. OnceProtocol
  3429. );
  3430. const $off = /* @__PURE__ */ defineSyncApi(
  3431. API_OFF,
  3432. (name, callback) => {
  3433. if (!name) {
  3434. emitter.e = {};
  3435. return;
  3436. }
  3437. if (!isArray(name))
  3438. name = [name];
  3439. name.forEach((n) => emitter.off(n, callback));
  3440. },
  3441. OffProtocol
  3442. );
  3443. const $emit = /* @__PURE__ */ defineSyncApi(
  3444. API_EMIT,
  3445. (name, ...args) => {
  3446. emitter.emit(name, ...args);
  3447. },
  3448. EmitProtocol
  3449. );
  3450. const validator = [
  3451. {
  3452. name: "id",
  3453. type: String,
  3454. required: true
  3455. }
  3456. ];
  3457. const API_CREATE_VIDEO_CONTEXT = "createVideoContext";
  3458. const API_CREATE_MAP_CONTEXT = "createMapContext";
  3459. const CreateMapContextProtocol = validator;
  3460. const API_CREATE_CANVAS_CONTEXT = "createCanvasContext";
  3461. const CreateCanvasContextProtocol = [
  3462. {
  3463. name: "canvasId",
  3464. type: String,
  3465. required: true
  3466. },
  3467. {
  3468. name: "componentInstance",
  3469. type: Object
  3470. }
  3471. ];
  3472. const API_CREATE_INNER_AUDIO_CONTEXT = "createInnerAudioContext";
  3473. validator.concat({
  3474. name: "componentInstance",
  3475. type: Object
  3476. });
  3477. const RATES = [0.5, 0.8, 1, 1.25, 1.5, 2];
  3478. class VideoContext {
  3479. constructor(id2, pageId) {
  3480. this.id = id2;
  3481. this.pageId = pageId;
  3482. }
  3483. play() {
  3484. operateVideoPlayer(this.id, this.pageId, "play");
  3485. }
  3486. pause() {
  3487. operateVideoPlayer(this.id, this.pageId, "pause");
  3488. }
  3489. stop() {
  3490. operateVideoPlayer(this.id, this.pageId, "stop");
  3491. }
  3492. seek(position) {
  3493. operateVideoPlayer(this.id, this.pageId, "seek", {
  3494. position
  3495. });
  3496. }
  3497. sendDanmu(args) {
  3498. operateVideoPlayer(this.id, this.pageId, "sendDanmu", args);
  3499. }
  3500. playbackRate(rate) {
  3501. if (!~RATES.indexOf(rate)) {
  3502. rate = 1;
  3503. }
  3504. operateVideoPlayer(this.id, this.pageId, "playbackRate", {
  3505. rate
  3506. });
  3507. }
  3508. requestFullScreen(args = {}) {
  3509. operateVideoPlayer(this.id, this.pageId, "requestFullScreen", args);
  3510. }
  3511. exitFullScreen() {
  3512. operateVideoPlayer(this.id, this.pageId, "exitFullScreen");
  3513. }
  3514. showStatusBar() {
  3515. operateVideoPlayer(this.id, this.pageId, "showStatusBar");
  3516. }
  3517. hideStatusBar() {
  3518. operateVideoPlayer(this.id, this.pageId, "hideStatusBar");
  3519. }
  3520. }
  3521. const createVideoContext = /* @__PURE__ */ defineSyncApi(
  3522. API_CREATE_VIDEO_CONTEXT,
  3523. (id2, context) => {
  3524. if (context) {
  3525. return new VideoContext(id2, getPageIdByVm(context));
  3526. }
  3527. return new VideoContext(id2, getPageIdByVm(getCurrentPageVm()));
  3528. }
  3529. );
  3530. const operateMapCallback = (options, res) => {
  3531. const errMsg = res.errMsg || "";
  3532. if (new RegExp("\\:\\s*fail").test(errMsg)) {
  3533. options.fail && options.fail(res);
  3534. } else {
  3535. options.success && options.success(res);
  3536. }
  3537. options.complete && options.complete(res);
  3538. };
  3539. const operateMapWrap = (id2, pageId, type, options) => {
  3540. operateMap(id2, pageId, type, options, (res) => {
  3541. options && operateMapCallback(options, res);
  3542. });
  3543. };
  3544. class MapContext {
  3545. constructor(id2, pageId) {
  3546. this.id = id2;
  3547. this.pageId = pageId;
  3548. }
  3549. getCenterLocation(options) {
  3550. operateMapWrap(this.id, this.pageId, "getCenterLocation", options);
  3551. }
  3552. moveToLocation(options) {
  3553. operateMapWrap(this.id, this.pageId, "moveToLocation", options);
  3554. }
  3555. getScale(options) {
  3556. operateMapWrap(this.id, this.pageId, "getScale", options);
  3557. }
  3558. getRegion(options) {
  3559. operateMapWrap(this.id, this.pageId, "getRegion", options);
  3560. }
  3561. includePoints(options) {
  3562. operateMapWrap(this.id, this.pageId, "includePoints", options);
  3563. }
  3564. translateMarker(options) {
  3565. operateMapWrap(this.id, this.pageId, "translateMarker", options);
  3566. }
  3567. $getAppMap() {
  3568. }
  3569. addCustomLayer(options) {
  3570. operateMapWrap(this.id, this.pageId, "addCustomLayer", options);
  3571. }
  3572. removeCustomLayer(options) {
  3573. operateMapWrap(this.id, this.pageId, "removeCustomLayer", options);
  3574. }
  3575. addGroundOverlay(options) {
  3576. operateMapWrap(this.id, this.pageId, "addGroundOverlay", options);
  3577. }
  3578. removeGroundOverlay(options) {
  3579. operateMapWrap(this.id, this.pageId, "removeGroundOverlay", options);
  3580. }
  3581. updateGroundOverlay(options) {
  3582. operateMapWrap(this.id, this.pageId, "updateGroundOverlay", options);
  3583. }
  3584. initMarkerCluster(options) {
  3585. operateMapWrap(this.id, this.pageId, "initMarkerCluster", options);
  3586. }
  3587. addMarkers(options) {
  3588. operateMapWrap(this.id, this.pageId, "addMarkers", options);
  3589. }
  3590. removeMarkers(options) {
  3591. operateMapWrap(this.id, this.pageId, "removeMarkers", options);
  3592. }
  3593. moveAlong(options) {
  3594. operateMapWrap(this.id, this.pageId, "moveAlong", options);
  3595. }
  3596. setLocMarkerIcon(options) {
  3597. operateMapWrap(this.id, this.pageId, "setLocMarkerIcon", options);
  3598. }
  3599. openMapApp(options) {
  3600. operateMapWrap(this.id, this.pageId, "openMapApp", options);
  3601. }
  3602. on(name, callback) {
  3603. operateMapWrap(this.id, this.pageId, "on", { name, callback });
  3604. }
  3605. }
  3606. const createMapContext = /* @__PURE__ */ defineSyncApi(
  3607. API_CREATE_MAP_CONTEXT,
  3608. (id2, context) => {
  3609. if (context) {
  3610. return new MapContext(id2, getPageIdByVm(context));
  3611. }
  3612. return new MapContext(id2, getPageIdByVm(getCurrentPageVm()));
  3613. },
  3614. CreateMapContextProtocol
  3615. );
  3616. function getInt(name, defaultValue) {
  3617. return function(value, params) {
  3618. if (value) {
  3619. params[name] = Math.round(value);
  3620. } else if (typeof defaultValue !== "undefined") {
  3621. params[name] = defaultValue;
  3622. }
  3623. };
  3624. }
  3625. const formatWidth = getInt("width");
  3626. const formatHeight = getInt("height");
  3627. const API_CANVAS_GET_IMAGE_DATA = "canvasGetImageData";
  3628. const CanvasGetImageDataOptions = {
  3629. formatArgs: {
  3630. x: getInt("x"),
  3631. y: getInt("y"),
  3632. width: formatWidth,
  3633. height: formatHeight
  3634. }
  3635. };
  3636. const CanvasGetImageDataProtocol = {
  3637. canvasId: {
  3638. type: String,
  3639. required: true
  3640. },
  3641. x: {
  3642. type: Number,
  3643. required: true
  3644. },
  3645. y: {
  3646. type: Number,
  3647. required: true
  3648. },
  3649. width: {
  3650. type: Number,
  3651. required: true
  3652. },
  3653. height: {
  3654. type: Number,
  3655. required: true
  3656. }
  3657. };
  3658. const API_CANVAS_PUT_IMAGE_DATA = "canvasPutImageData";
  3659. const CanvasPutImageDataOptions = CanvasGetImageDataOptions;
  3660. const CanvasPutImageDataProtocol = /* @__PURE__ */ extend(
  3661. {
  3662. data: {
  3663. type: Uint8ClampedArray,
  3664. required: true
  3665. }
  3666. },
  3667. CanvasGetImageDataProtocol,
  3668. {
  3669. height: {
  3670. type: Number
  3671. }
  3672. }
  3673. );
  3674. const fileTypes = {
  3675. PNG: "png",
  3676. JPG: "jpg",
  3677. JPEG: "jpg"
  3678. };
  3679. const API_CANVAS_TO_TEMP_FILE_PATH = "canvasToTempFilePath";
  3680. const CanvasToTempFilePathOptions = {
  3681. formatArgs: {
  3682. x: getInt("x", 0),
  3683. y: getInt("y", 0),
  3684. width: formatWidth,
  3685. height: formatHeight,
  3686. destWidth: getInt("destWidth"),
  3687. destHeight: getInt("destHeight"),
  3688. fileType(value, params) {
  3689. value = (value || "").toUpperCase();
  3690. let type = fileTypes[value];
  3691. if (!type) {
  3692. type = fileTypes.PNG;
  3693. }
  3694. params.fileType = type;
  3695. },
  3696. quality(value, params) {
  3697. params.quality = value && value > 0 && value < 1 ? value : 1;
  3698. }
  3699. }
  3700. };
  3701. const CanvasToTempFilePathProtocol = {
  3702. x: Number,
  3703. y: Number,
  3704. width: Number,
  3705. height: Number,
  3706. destWidth: Number,
  3707. destHeight: Number,
  3708. canvasId: {
  3709. type: String,
  3710. required: true
  3711. },
  3712. fileType: String,
  3713. quality: Number
  3714. };
  3715. function operateCanvas(canvasId, pageId, type, data, callback) {
  3716. UniServiceJSBridge.invokeViewMethod(
  3717. `canvas.${canvasId}`,
  3718. {
  3719. type,
  3720. data
  3721. },
  3722. pageId,
  3723. (data2) => {
  3724. if (callback)
  3725. callback(data2);
  3726. }
  3727. );
  3728. }
  3729. var methods1 = ["scale", "rotate", "translate", "setTransform", "transform"];
  3730. var methods2 = [
  3731. "drawImage",
  3732. "fillText",
  3733. "fill",
  3734. "stroke",
  3735. "fillRect",
  3736. "strokeRect",
  3737. "clearRect",
  3738. "strokeText"
  3739. ];
  3740. var methods3 = [
  3741. "setFillStyle",
  3742. "setTextAlign",
  3743. "setStrokeStyle",
  3744. "setGlobalAlpha",
  3745. "setShadow",
  3746. "setFontSize",
  3747. "setLineCap",
  3748. "setLineJoin",
  3749. "setLineWidth",
  3750. "setMiterLimit",
  3751. "setTextBaseline",
  3752. "setLineDash"
  3753. ];
  3754. function measureText(text2, font2) {
  3755. const canvas = document.createElement("canvas");
  3756. const c2d = canvas.getContext("2d");
  3757. c2d.font = font2;
  3758. return c2d.measureText(text2).width || 0;
  3759. }
  3760. const predefinedColor = {
  3761. aliceblue: "#f0f8ff",
  3762. antiquewhite: "#faebd7",
  3763. aqua: "#00ffff",
  3764. aquamarine: "#7fffd4",
  3765. azure: "#f0ffff",
  3766. beige: "#f5f5dc",
  3767. bisque: "#ffe4c4",
  3768. black: "#000000",
  3769. blanchedalmond: "#ffebcd",
  3770. blue: "#0000ff",
  3771. blueviolet: "#8a2be2",
  3772. brown: "#a52a2a",
  3773. burlywood: "#deb887",
  3774. cadetblue: "#5f9ea0",
  3775. chartreuse: "#7fff00",
  3776. chocolate: "#d2691e",
  3777. coral: "#ff7f50",
  3778. cornflowerblue: "#6495ed",
  3779. cornsilk: "#fff8dc",
  3780. crimson: "#dc143c",
  3781. cyan: "#00ffff",
  3782. darkblue: "#00008b",
  3783. darkcyan: "#008b8b",
  3784. darkgoldenrod: "#b8860b",
  3785. darkgray: "#a9a9a9",
  3786. darkgrey: "#a9a9a9",
  3787. darkgreen: "#006400",
  3788. darkkhaki: "#bdb76b",
  3789. darkmagenta: "#8b008b",
  3790. darkolivegreen: "#556b2f",
  3791. darkorange: "#ff8c00",
  3792. darkorchid: "#9932cc",
  3793. darkred: "#8b0000",
  3794. darksalmon: "#e9967a",
  3795. darkseagreen: "#8fbc8f",
  3796. darkslateblue: "#483d8b",
  3797. darkslategray: "#2f4f4f",
  3798. darkslategrey: "#2f4f4f",
  3799. darkturquoise: "#00ced1",
  3800. darkviolet: "#9400d3",
  3801. deeppink: "#ff1493",
  3802. deepskyblue: "#00bfff",
  3803. dimgray: "#696969",
  3804. dimgrey: "#696969",
  3805. dodgerblue: "#1e90ff",
  3806. firebrick: "#b22222",
  3807. floralwhite: "#fffaf0",
  3808. forestgreen: "#228b22",
  3809. fuchsia: "#ff00ff",
  3810. gainsboro: "#dcdcdc",
  3811. ghostwhite: "#f8f8ff",
  3812. gold: "#ffd700",
  3813. goldenrod: "#daa520",
  3814. gray: "#808080",
  3815. grey: "#808080",
  3816. green: "#008000",
  3817. greenyellow: "#adff2f",
  3818. honeydew: "#f0fff0",
  3819. hotpink: "#ff69b4",
  3820. indianred: "#cd5c5c",
  3821. indigo: "#4b0082",
  3822. ivory: "#fffff0",
  3823. khaki: "#f0e68c",
  3824. lavender: "#e6e6fa",
  3825. lavenderblush: "#fff0f5",
  3826. lawngreen: "#7cfc00",
  3827. lemonchiffon: "#fffacd",
  3828. lightblue: "#add8e6",
  3829. lightcoral: "#f08080",
  3830. lightcyan: "#e0ffff",
  3831. lightgoldenrodyellow: "#fafad2",
  3832. lightgray: "#d3d3d3",
  3833. lightgrey: "#d3d3d3",
  3834. lightgreen: "#90ee90",
  3835. lightpink: "#ffb6c1",
  3836. lightsalmon: "#ffa07a",
  3837. lightseagreen: "#20b2aa",
  3838. lightskyblue: "#87cefa",
  3839. lightslategray: "#778899",
  3840. lightslategrey: "#778899",
  3841. lightsteelblue: "#b0c4de",
  3842. lightyellow: "#ffffe0",
  3843. lime: "#00ff00",
  3844. limegreen: "#32cd32",
  3845. linen: "#faf0e6",
  3846. magenta: "#ff00ff",
  3847. maroon: "#800000",
  3848. mediumaquamarine: "#66cdaa",
  3849. mediumblue: "#0000cd",
  3850. mediumorchid: "#ba55d3",
  3851. mediumpurple: "#9370db",
  3852. mediumseagreen: "#3cb371",
  3853. mediumslateblue: "#7b68ee",
  3854. mediumspringgreen: "#00fa9a",
  3855. mediumturquoise: "#48d1cc",
  3856. mediumvioletred: "#c71585",
  3857. midnightblue: "#191970",
  3858. mintcream: "#f5fffa",
  3859. mistyrose: "#ffe4e1",
  3860. moccasin: "#ffe4b5",
  3861. navajowhite: "#ffdead",
  3862. navy: "#000080",
  3863. oldlace: "#fdf5e6",
  3864. olive: "#808000",
  3865. olivedrab: "#6b8e23",
  3866. orange: "#ffa500",
  3867. orangered: "#ff4500",
  3868. orchid: "#da70d6",
  3869. palegoldenrod: "#eee8aa",
  3870. palegreen: "#98fb98",
  3871. paleturquoise: "#afeeee",
  3872. palevioletred: "#db7093",
  3873. papayawhip: "#ffefd5",
  3874. peachpuff: "#ffdab9",
  3875. peru: "#cd853f",
  3876. pink: "#ffc0cb",
  3877. plum: "#dda0dd",
  3878. powderblue: "#b0e0e6",
  3879. purple: "#800080",
  3880. rebeccapurple: "#663399",
  3881. red: "#ff0000",
  3882. rosybrown: "#bc8f8f",
  3883. royalblue: "#4169e1",
  3884. saddlebrown: "#8b4513",
  3885. salmon: "#fa8072",
  3886. sandybrown: "#f4a460",
  3887. seagreen: "#2e8b57",
  3888. seashell: "#fff5ee",
  3889. sienna: "#a0522d",
  3890. silver: "#c0c0c0",
  3891. skyblue: "#87ceeb",
  3892. slateblue: "#6a5acd",
  3893. slategray: "#708090",
  3894. slategrey: "#708090",
  3895. snow: "#fffafa",
  3896. springgreen: "#00ff7f",
  3897. steelblue: "#4682b4",
  3898. tan: "#d2b48c",
  3899. teal: "#008080",
  3900. thistle: "#d8bfd8",
  3901. tomato: "#ff6347",
  3902. turquoise: "#40e0d0",
  3903. violet: "#ee82ee",
  3904. wheat: "#f5deb3",
  3905. white: "#ffffff",
  3906. whitesmoke: "#f5f5f5",
  3907. yellow: "#ffff00",
  3908. yellowgreen: "#9acd32",
  3909. transparent: "#00000000"
  3910. };
  3911. function checkColor(e2) {
  3912. e2 = e2 || "#000000";
  3913. var t2 = null;
  3914. if ((t2 = /^#([0-9|A-F|a-f]{6})$/.exec(e2)) != null) {
  3915. const n = parseInt(t2[1].slice(0, 2), 16);
  3916. const o2 = parseInt(t2[1].slice(2, 4), 16);
  3917. const r = parseInt(t2[1].slice(4), 16);
  3918. return [n, o2, r, 255];
  3919. }
  3920. if ((t2 = /^#([0-9|A-F|a-f]{3})$/.exec(e2)) != null) {
  3921. let n = t2[1].slice(0, 1);
  3922. let o2 = t2[1].slice(1, 2);
  3923. let r = t2[1].slice(2, 3);
  3924. n = parseInt(n + n, 16);
  3925. o2 = parseInt(o2 + o2, 16);
  3926. r = parseInt(r + r, 16);
  3927. return [n, o2, r, 255];
  3928. }
  3929. if ((t2 = /^rgb\((.+)\)$/.exec(e2)) != null) {
  3930. return t2[1].split(",").map(function(e22) {
  3931. return Math.min(255, parseInt(e22.trim()));
  3932. }).concat(255);
  3933. }
  3934. if ((t2 = /^rgba\((.+)\)$/.exec(e2)) != null) {
  3935. return t2[1].split(",").map(function(e22, t22) {
  3936. return t22 === 3 ? Math.floor(255 * parseFloat(e22.trim())) : Math.min(255, parseInt(e22.trim()));
  3937. });
  3938. }
  3939. var i = e2.toLowerCase();
  3940. if (hasOwn(predefinedColor, i)) {
  3941. t2 = /^#([0-9|A-F|a-f]{6,8})$/.exec(predefinedColor[i]);
  3942. const n = parseInt(t2[1].slice(0, 2), 16);
  3943. const o2 = parseInt(t2[1].slice(2, 4), 16);
  3944. const r = parseInt(t2[1].slice(4, 6), 16);
  3945. let a2 = parseInt(t2[1].slice(6, 8), 16);
  3946. a2 = a2 >= 0 ? a2 : 255;
  3947. return [n, o2, r, a2];
  3948. }
  3949. console.error("unsupported color:" + e2);
  3950. return [0, 0, 0, 255];
  3951. }
  3952. class CanvasGradient {
  3953. constructor(type, data) {
  3954. this.type = type;
  3955. this.data = data;
  3956. this.colorStop = [];
  3957. }
  3958. addColorStop(position, color) {
  3959. this.colorStop.push([position, checkColor(color)]);
  3960. }
  3961. }
  3962. class Pattern {
  3963. constructor(image2, repetition) {
  3964. this.type = "pattern";
  3965. this.data = image2;
  3966. this.colorStop = repetition;
  3967. }
  3968. }
  3969. class TextMetrics {
  3970. constructor(width) {
  3971. this.width = width;
  3972. }
  3973. }
  3974. class CanvasContext {
  3975. constructor(id2, pageId) {
  3976. this.id = id2;
  3977. this.pageId = pageId;
  3978. this.actions = [];
  3979. this.path = [];
  3980. this.subpath = [];
  3981. this.drawingState = [];
  3982. this.state = {
  3983. lineDash: [0, 0],
  3984. shadowOffsetX: 0,
  3985. shadowOffsetY: 0,
  3986. shadowBlur: 0,
  3987. shadowColor: [0, 0, 0, 0],
  3988. font: "10px sans-serif",
  3989. fontSize: 10,
  3990. fontWeight: "normal",
  3991. fontStyle: "normal",
  3992. fontFamily: "sans-serif"
  3993. };
  3994. }
  3995. draw(reserve = false, callback) {
  3996. var actions = [...this.actions];
  3997. this.actions = [];
  3998. this.path = [];
  3999. operateCanvas(
  4000. this.id,
  4001. this.pageId,
  4002. "actionsChanged",
  4003. {
  4004. actions,
  4005. reserve
  4006. },
  4007. callback
  4008. );
  4009. }
  4010. createLinearGradient(x0, y0, x1, y1) {
  4011. return new CanvasGradient("linear", [x0, y0, x1, y1]);
  4012. }
  4013. createCircularGradient(x, y, r) {
  4014. return new CanvasGradient("radial", [x, y, r]);
  4015. }
  4016. createPattern(image2, repetition) {
  4017. if (void 0 === repetition) {
  4018. console.error(
  4019. "Failed to execute 'createPattern' on 'CanvasContext': 2 arguments required, but only 1 present."
  4020. );
  4021. } else if (["repeat", "repeat-x", "repeat-y", "no-repeat"].indexOf(repetition) < 0) {
  4022. console.error(
  4023. "Failed to execute 'createPattern' on 'CanvasContext': The provided type ('" + repetition + "') is not one of 'repeat', 'no-repeat', 'repeat-x', or 'repeat-y'."
  4024. );
  4025. } else {
  4026. return new Pattern(image2, repetition);
  4027. }
  4028. }
  4029. measureText(text2) {
  4030. const font2 = this.state.font;
  4031. let width = 0;
  4032. {
  4033. width = measureText(text2, font2);
  4034. }
  4035. return new TextMetrics(width);
  4036. }
  4037. save() {
  4038. this.actions.push({
  4039. method: "save",
  4040. data: []
  4041. });
  4042. this.drawingState.push(this.state);
  4043. }
  4044. restore() {
  4045. this.actions.push({
  4046. method: "restore",
  4047. data: []
  4048. });
  4049. this.state = this.drawingState.pop() || {
  4050. lineDash: [0, 0],
  4051. shadowOffsetX: 0,
  4052. shadowOffsetY: 0,
  4053. shadowBlur: 0,
  4054. shadowColor: [0, 0, 0, 0],
  4055. font: "10px sans-serif",
  4056. fontSize: 10,
  4057. fontWeight: "normal",
  4058. fontStyle: "normal",
  4059. fontFamily: "sans-serif"
  4060. };
  4061. }
  4062. beginPath() {
  4063. this.path = [];
  4064. this.subpath = [];
  4065. this.path.push({
  4066. method: "beginPath",
  4067. data: []
  4068. });
  4069. }
  4070. moveTo(x, y) {
  4071. this.path.push({
  4072. method: "moveTo",
  4073. data: [x, y]
  4074. });
  4075. this.subpath = [[x, y]];
  4076. }
  4077. lineTo(x, y) {
  4078. if (this.path.length === 0 && this.subpath.length === 0) {
  4079. this.path.push({
  4080. method: "moveTo",
  4081. data: [x, y]
  4082. });
  4083. } else {
  4084. this.path.push({
  4085. method: "lineTo",
  4086. data: [x, y]
  4087. });
  4088. }
  4089. this.subpath.push([x, y]);
  4090. }
  4091. quadraticCurveTo(cpx, cpy, x, y) {
  4092. this.path.push({
  4093. method: "quadraticCurveTo",
  4094. data: [cpx, cpy, x, y]
  4095. });
  4096. this.subpath.push([x, y]);
  4097. }
  4098. bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
  4099. this.path.push({
  4100. method: "bezierCurveTo",
  4101. data: [cp1x, cp1y, cp2x, cp2y, x, y]
  4102. });
  4103. this.subpath.push([x, y]);
  4104. }
  4105. arc(x, y, r, sAngle, eAngle, counterclockwise = false) {
  4106. this.path.push({
  4107. method: "arc",
  4108. data: [x, y, r, sAngle, eAngle, counterclockwise]
  4109. });
  4110. this.subpath.push([x, y]);
  4111. }
  4112. rect(x, y, width, height) {
  4113. this.path.push({
  4114. method: "rect",
  4115. data: [x, y, width, height]
  4116. });
  4117. this.subpath = [[x, y]];
  4118. }
  4119. arcTo(x1, y1, x2, y2, radius) {
  4120. this.path.push({
  4121. method: "arcTo",
  4122. data: [x1, y1, x2, y2, radius]
  4123. });
  4124. this.subpath.push([x2, y2]);
  4125. }
  4126. clip() {
  4127. this.actions.push({
  4128. method: "clip",
  4129. data: [...this.path]
  4130. });
  4131. }
  4132. closePath() {
  4133. this.path.push({
  4134. method: "closePath",
  4135. data: []
  4136. });
  4137. if (this.subpath.length) {
  4138. this.subpath = [this.subpath.shift()];
  4139. }
  4140. }
  4141. clearActions() {
  4142. this.actions = [];
  4143. this.path = [];
  4144. this.subpath = [];
  4145. }
  4146. getActions() {
  4147. var actions = [...this.actions];
  4148. this.clearActions();
  4149. return actions;
  4150. }
  4151. set lineDashOffset(value) {
  4152. this.actions.push({
  4153. method: "setLineDashOffset",
  4154. data: [value]
  4155. });
  4156. }
  4157. set globalCompositeOperation(type) {
  4158. this.actions.push({
  4159. method: "setGlobalCompositeOperation",
  4160. data: [type]
  4161. });
  4162. }
  4163. set shadowBlur(level) {
  4164. this.actions.push({
  4165. method: "setShadowBlur",
  4166. data: [level]
  4167. });
  4168. }
  4169. set shadowColor(color) {
  4170. this.actions.push({
  4171. method: "setShadowColor",
  4172. data: [color]
  4173. });
  4174. }
  4175. set shadowOffsetX(x) {
  4176. this.actions.push({
  4177. method: "setShadowOffsetX",
  4178. data: [x]
  4179. });
  4180. }
  4181. set shadowOffsetY(y) {
  4182. this.actions.push({
  4183. method: "setShadowOffsetY",
  4184. data: [y]
  4185. });
  4186. }
  4187. set font(value) {
  4188. var self = this;
  4189. this.state.font = value;
  4190. var fontFormat = value.match(
  4191. /^(([\w\-]+\s)*)(\d+r?px)(\/(\d+\.?\d*(r?px)?))?\s+(.*)/
  4192. );
  4193. if (fontFormat) {
  4194. var style = fontFormat[1].trim().split(/\s/);
  4195. var fontSize = parseFloat(fontFormat[3]);
  4196. var fontFamily = fontFormat[7];
  4197. var actions = [];
  4198. style.forEach(function(value2, index2) {
  4199. if (["italic", "oblique", "normal"].indexOf(value2) > -1) {
  4200. actions.push({
  4201. method: "setFontStyle",
  4202. data: [value2]
  4203. });
  4204. self.state.fontStyle = value2;
  4205. } else if (["bold", "normal"].indexOf(value2) > -1) {
  4206. actions.push({
  4207. method: "setFontWeight",
  4208. data: [value2]
  4209. });
  4210. self.state.fontWeight = value2;
  4211. } else if (index2 === 0) {
  4212. actions.push({
  4213. method: "setFontStyle",
  4214. data: ["normal"]
  4215. });
  4216. self.state.fontStyle = "normal";
  4217. } else if (index2 === 1) {
  4218. pushAction();
  4219. }
  4220. });
  4221. if (style.length === 1) {
  4222. pushAction();
  4223. }
  4224. style = actions.map(function(action) {
  4225. return action.data[0];
  4226. }).join(" ");
  4227. this.state.fontSize = fontSize;
  4228. this.state.fontFamily = fontFamily;
  4229. this.actions.push({
  4230. method: "setFont",
  4231. data: [`${style} ${fontSize}px ${fontFamily}`]
  4232. });
  4233. } else {
  4234. console.warn("Failed to set 'font' on 'CanvasContext': invalid format.");
  4235. }
  4236. function pushAction() {
  4237. actions.push({
  4238. method: "setFontWeight",
  4239. data: ["normal"]
  4240. });
  4241. self.state.fontWeight = "normal";
  4242. }
  4243. }
  4244. get font() {
  4245. return this.state.font;
  4246. }
  4247. set fillStyle(color) {
  4248. this.setFillStyle(color);
  4249. }
  4250. set strokeStyle(color) {
  4251. this.setStrokeStyle(color);
  4252. }
  4253. set globalAlpha(value) {
  4254. value = Math.floor(255 * parseFloat(value));
  4255. this.actions.push({
  4256. method: "setGlobalAlpha",
  4257. data: [value]
  4258. });
  4259. }
  4260. set textAlign(align2) {
  4261. this.actions.push({
  4262. method: "setTextAlign",
  4263. data: [align2]
  4264. });
  4265. }
  4266. set lineCap(type) {
  4267. this.actions.push({
  4268. method: "setLineCap",
  4269. data: [type]
  4270. });
  4271. }
  4272. set lineJoin(type) {
  4273. this.actions.push({
  4274. method: "setLineJoin",
  4275. data: [type]
  4276. });
  4277. }
  4278. set lineWidth(value) {
  4279. this.actions.push({
  4280. method: "setLineWidth",
  4281. data: [value]
  4282. });
  4283. }
  4284. set miterLimit(value) {
  4285. this.actions.push({
  4286. method: "setMiterLimit",
  4287. data: [value]
  4288. });
  4289. }
  4290. set textBaseline(type) {
  4291. this.actions.push({
  4292. method: "setTextBaseline",
  4293. data: [type]
  4294. });
  4295. }
  4296. }
  4297. const initCanvasContextProperty = /* @__PURE__ */ once(() => {
  4298. [...methods1, ...methods2].forEach(function(method) {
  4299. function get(method2) {
  4300. switch (method2) {
  4301. case "fill":
  4302. case "stroke":
  4303. return function() {
  4304. this.actions.push({
  4305. method: method2 + "Path",
  4306. // @ts-ignore
  4307. data: [...this.path]
  4308. });
  4309. };
  4310. case "fillRect":
  4311. return function(x, y, width, height) {
  4312. this.actions.push({
  4313. method: "fillPath",
  4314. data: [
  4315. {
  4316. method: "rect",
  4317. data: [x, y, width, height]
  4318. }
  4319. ]
  4320. });
  4321. };
  4322. case "strokeRect":
  4323. return function(x, y, width, height) {
  4324. this.actions.push({
  4325. method: "strokePath",
  4326. data: [
  4327. {
  4328. method: "rect",
  4329. data: [x, y, width, height]
  4330. }
  4331. ]
  4332. });
  4333. };
  4334. case "fillText":
  4335. case "strokeText":
  4336. return function(text2, x, y, maxWidth2) {
  4337. var data = [text2.toString(), x, y];
  4338. if (typeof maxWidth2 === "number") {
  4339. data.push(maxWidth2);
  4340. }
  4341. this.actions.push({
  4342. method: method2,
  4343. data
  4344. });
  4345. };
  4346. case "drawImage":
  4347. return function(imageResource, dx, dy, dWidth, dHeight, sx, sy, sWidth, sHeight) {
  4348. if (sHeight === void 0) {
  4349. sx = dx;
  4350. sy = dy;
  4351. sWidth = dWidth;
  4352. sHeight = dHeight;
  4353. dx = void 0;
  4354. dy = void 0;
  4355. dWidth = void 0;
  4356. dHeight = void 0;
  4357. }
  4358. var data;
  4359. function isNumber(e2) {
  4360. return typeof e2 === "number";
  4361. }
  4362. data = isNumber(dx) && isNumber(dy) && isNumber(dWidth) && isNumber(dHeight) ? [
  4363. imageResource,
  4364. sx,
  4365. sy,
  4366. sWidth,
  4367. sHeight,
  4368. dx,
  4369. dy,
  4370. dWidth,
  4371. dHeight
  4372. ] : isNumber(sWidth) && isNumber(sHeight) ? [imageResource, sx, sy, sWidth, sHeight] : [imageResource, sx, sy];
  4373. this.actions.push({
  4374. method: method2,
  4375. data
  4376. });
  4377. };
  4378. default:
  4379. return function(...data) {
  4380. this.actions.push({
  4381. method: method2,
  4382. data
  4383. });
  4384. };
  4385. }
  4386. }
  4387. CanvasContext.prototype[method] = get(method);
  4388. });
  4389. methods3.forEach(function(method) {
  4390. function get(method2) {
  4391. switch (method2) {
  4392. case "setFillStyle":
  4393. case "setStrokeStyle":
  4394. return function(color) {
  4395. if (typeof color !== "object") {
  4396. this.actions.push({
  4397. method: method2,
  4398. data: ["normal", checkColor(color)]
  4399. });
  4400. } else {
  4401. this.actions.push({
  4402. method: method2,
  4403. data: [color.type, color.data, color.colorStop]
  4404. });
  4405. }
  4406. };
  4407. case "setGlobalAlpha":
  4408. return function(alpha) {
  4409. alpha = Math.floor(255 * parseFloat(alpha));
  4410. this.actions.push({
  4411. method: method2,
  4412. data: [alpha]
  4413. });
  4414. };
  4415. case "setShadow":
  4416. return function(offsetX, offsetY, blur, color) {
  4417. color = checkColor(color);
  4418. this.actions.push({
  4419. method: method2,
  4420. data: [offsetX, offsetY, blur, color]
  4421. });
  4422. this.state.shadowBlur = blur;
  4423. this.state.shadowColor = color;
  4424. this.state.shadowOffsetX = offsetX;
  4425. this.state.shadowOffsetY = offsetY;
  4426. };
  4427. case "setLineDash":
  4428. return function(pattern, offset) {
  4429. pattern = pattern || [0, 0];
  4430. offset = offset || 0;
  4431. this.actions.push({
  4432. method: method2,
  4433. data: [pattern, offset]
  4434. });
  4435. this.state.lineDash = pattern;
  4436. };
  4437. case "setFontSize":
  4438. return function(fontSize) {
  4439. this.state.font = this.state.font.replace(
  4440. /\d+\.?\d*px/,
  4441. fontSize + "px"
  4442. );
  4443. this.state.fontSize = fontSize;
  4444. this.actions.push({
  4445. method: method2,
  4446. data: [fontSize]
  4447. });
  4448. };
  4449. default:
  4450. return function(...data) {
  4451. this.actions.push({
  4452. method: method2,
  4453. data
  4454. });
  4455. };
  4456. }
  4457. }
  4458. CanvasContext.prototype[method] = get(method);
  4459. });
  4460. });
  4461. const createCanvasContext = /* @__PURE__ */ defineSyncApi(
  4462. API_CREATE_CANVAS_CONTEXT,
  4463. (canvasId, componentInstance) => {
  4464. initCanvasContextProperty();
  4465. if (componentInstance) {
  4466. return new CanvasContext(canvasId, getPageIdByVm(componentInstance));
  4467. }
  4468. const pageId = getPageIdByVm(getCurrentPageVm());
  4469. if (pageId) {
  4470. return new CanvasContext(canvasId, pageId);
  4471. } else {
  4472. UniServiceJSBridge.emit(ON_ERROR, "createCanvasContext:fail");
  4473. }
  4474. },
  4475. CreateCanvasContextProtocol
  4476. );
  4477. const canvasGetImageData = /* @__PURE__ */ defineAsyncApi(
  4478. API_CANVAS_GET_IMAGE_DATA,
  4479. ({ canvasId, x, y, width, height }, { resolve, reject }) => {
  4480. const pageId = getPageIdByVm(getCurrentPageVm());
  4481. if (!pageId) {
  4482. reject();
  4483. return;
  4484. }
  4485. function callback(data) {
  4486. if (data.errMsg && data.errMsg.indexOf("fail") !== -1) {
  4487. reject("", data);
  4488. return;
  4489. }
  4490. let imgData = data.data;
  4491. if (imgData && imgData.length) {
  4492. data.data = new Uint8ClampedArray(imgData);
  4493. }
  4494. delete data.compressed;
  4495. resolve(data);
  4496. }
  4497. operateCanvas(
  4498. canvasId,
  4499. pageId,
  4500. "getImageData",
  4501. {
  4502. x,
  4503. y,
  4504. width,
  4505. height
  4506. },
  4507. callback
  4508. );
  4509. },
  4510. CanvasGetImageDataProtocol,
  4511. CanvasGetImageDataOptions
  4512. );
  4513. const canvasPutImageData = /* @__PURE__ */ defineAsyncApi(
  4514. API_CANVAS_PUT_IMAGE_DATA,
  4515. ({ canvasId, data, x, y, width, height }, { resolve, reject }) => {
  4516. var pageId = getPageIdByVm(getCurrentPageVm());
  4517. if (!pageId) {
  4518. reject();
  4519. return;
  4520. }
  4521. let compressed;
  4522. const operate = () => {
  4523. operateCanvas(
  4524. canvasId,
  4525. pageId,
  4526. "putImageData",
  4527. {
  4528. data,
  4529. x,
  4530. y,
  4531. width,
  4532. height,
  4533. compressed
  4534. },
  4535. (data2) => {
  4536. if (data2.errMsg && data2.errMsg.indexOf("fail") !== -1) {
  4537. reject();
  4538. return;
  4539. }
  4540. resolve(data2);
  4541. }
  4542. );
  4543. };
  4544. {
  4545. data = Array.prototype.slice.call(data);
  4546. }
  4547. operate();
  4548. },
  4549. CanvasPutImageDataProtocol,
  4550. CanvasPutImageDataOptions
  4551. );
  4552. const canvasToTempFilePath = /* @__PURE__ */ defineAsyncApi(
  4553. API_CANVAS_TO_TEMP_FILE_PATH,
  4554. ({
  4555. x = 0,
  4556. y = 0,
  4557. width,
  4558. height,
  4559. destWidth,
  4560. destHeight,
  4561. canvasId,
  4562. fileType,
  4563. quality
  4564. }, { resolve, reject }) => {
  4565. var pageId = getPageIdByVm(getCurrentPageVm());
  4566. if (!pageId) {
  4567. reject();
  4568. return;
  4569. }
  4570. const dirname = `${TEMP_PATH}/canvas`;
  4571. operateCanvas(
  4572. canvasId,
  4573. pageId,
  4574. "toTempFilePath",
  4575. {
  4576. x,
  4577. y,
  4578. width,
  4579. height,
  4580. destWidth,
  4581. destHeight,
  4582. fileType,
  4583. quality,
  4584. dirname
  4585. },
  4586. (res) => {
  4587. if (res.errMsg && res.errMsg.indexOf("fail") !== -1) {
  4588. reject("", res);
  4589. return;
  4590. }
  4591. resolve(res);
  4592. }
  4593. );
  4594. },
  4595. CanvasToTempFilePathProtocol,
  4596. CanvasToTempFilePathOptions
  4597. );
  4598. const innerAudioContextEventNames = [
  4599. "onCanplay",
  4600. "onPlay",
  4601. "onPause",
  4602. "onStop",
  4603. "onEnded",
  4604. "onTimeUpdate",
  4605. "onError",
  4606. "onWaiting",
  4607. "onSeeking",
  4608. "onSeeked"
  4609. ];
  4610. const innerAudioContextOffEventNames = [
  4611. "offCanplay",
  4612. "offPlay",
  4613. "offPause",
  4614. "offStop",
  4615. "offEnded",
  4616. "offTimeUpdate",
  4617. "offError",
  4618. "offWaiting",
  4619. "offSeeking",
  4620. "offSeeked"
  4621. ];
  4622. const defaultOptions = {
  4623. thresholds: [0],
  4624. initialRatio: 0,
  4625. observeAll: false
  4626. };
  4627. const MARGINS = ["top", "right", "bottom", "left"];
  4628. let reqComponentObserverId$1 = 1;
  4629. function normalizeRootMargin(margins = {}) {
  4630. return MARGINS.map(
  4631. (name) => `${Number(margins[name]) || 0}px`
  4632. ).join(" ");
  4633. }
  4634. class ServiceIntersectionObserver {
  4635. constructor(component, options) {
  4636. this._pageId = getPageIdByVm(component);
  4637. this._component = component;
  4638. this._options = extend({}, defaultOptions, options);
  4639. }
  4640. relativeTo(selector, margins) {
  4641. this._options.relativeToSelector = selector;
  4642. this._options.rootMargin = normalizeRootMargin(margins);
  4643. return this;
  4644. }
  4645. relativeToViewport(margins) {
  4646. this._options.relativeToSelector = void 0;
  4647. this._options.rootMargin = normalizeRootMargin(margins);
  4648. return this;
  4649. }
  4650. observe(selector, callback) {
  4651. if (!isFunction(callback)) {
  4652. return;
  4653. }
  4654. this._options.selector = selector;
  4655. this._reqId = reqComponentObserverId$1++;
  4656. addIntersectionObserver(
  4657. {
  4658. reqId: this._reqId,
  4659. component: this._component,
  4660. options: this._options,
  4661. callback
  4662. },
  4663. this._pageId
  4664. );
  4665. }
  4666. disconnect() {
  4667. this._reqId && removeIntersectionObserver(
  4668. { reqId: this._reqId, component: this._component },
  4669. this._pageId
  4670. );
  4671. }
  4672. }
  4673. const createIntersectionObserver = /* @__PURE__ */ defineSyncApi("createIntersectionObserver", (context, options) => {
  4674. context = resolveComponentInstance(context);
  4675. if (context && !getPageIdByVm(context)) {
  4676. options = context;
  4677. context = null;
  4678. }
  4679. if (context) {
  4680. return new ServiceIntersectionObserver(context, options);
  4681. }
  4682. return new ServiceIntersectionObserver(getCurrentPageVm(), options);
  4683. });
  4684. let reqComponentObserverId = 1;
  4685. class ServiceMediaQueryObserver {
  4686. constructor(component) {
  4687. this._pageId = component.$page && component.$page.id;
  4688. this._component = component;
  4689. }
  4690. observe(options, callback) {
  4691. if (!isFunction(callback)) {
  4692. return;
  4693. }
  4694. this._reqId = reqComponentObserverId++;
  4695. addMediaQueryObserver(
  4696. {
  4697. reqId: this._reqId,
  4698. component: this._component,
  4699. options,
  4700. callback
  4701. },
  4702. this._pageId
  4703. );
  4704. }
  4705. disconnect() {
  4706. this._reqId && removeMediaQueryObserver(
  4707. {
  4708. reqId: this._reqId,
  4709. component: this._component
  4710. },
  4711. this._pageId
  4712. );
  4713. }
  4714. }
  4715. const createMediaQueryObserver = /* @__PURE__ */ defineSyncApi("createMediaQueryObserver", (context) => {
  4716. context = resolveComponentInstance(context);
  4717. if (context && !getPageIdByVm(context)) {
  4718. context = null;
  4719. }
  4720. if (context) {
  4721. return new ServiceMediaQueryObserver(context);
  4722. }
  4723. return new ServiceMediaQueryObserver(getCurrentPageVm());
  4724. });
  4725. let index$w = 0;
  4726. let optionsCache = {};
  4727. function operateEditor(componentId, pageId, type, options) {
  4728. const data = { options };
  4729. const needCallOptions = options && ("success" in options || "fail" in options || "complete" in options);
  4730. if (needCallOptions) {
  4731. const callbackId = String(index$w++);
  4732. data.callbackId = callbackId;
  4733. optionsCache[callbackId] = options;
  4734. }
  4735. UniServiceJSBridge.invokeViewMethod(
  4736. `editor.${componentId}`,
  4737. {
  4738. type,
  4739. data
  4740. },
  4741. pageId,
  4742. ({ callbackId, data: data2 }) => {
  4743. if (needCallOptions) {
  4744. callOptions(optionsCache[callbackId], data2);
  4745. delete optionsCache[callbackId];
  4746. }
  4747. }
  4748. );
  4749. }
  4750. class EditorContext {
  4751. constructor(id2, pageId) {
  4752. this.id = id2;
  4753. this.pageId = pageId;
  4754. }
  4755. format(name, value) {
  4756. this._exec("format", {
  4757. name,
  4758. value
  4759. });
  4760. }
  4761. insertDivider() {
  4762. this._exec("insertDivider");
  4763. }
  4764. insertImage(options) {
  4765. this._exec("insertImage", options);
  4766. }
  4767. insertText(options) {
  4768. this._exec("insertText", options);
  4769. }
  4770. setContents(options) {
  4771. this._exec("setContents", options);
  4772. }
  4773. getContents(options) {
  4774. this._exec("getContents", options);
  4775. }
  4776. clear(options) {
  4777. this._exec("clear", options);
  4778. }
  4779. removeFormat(options) {
  4780. this._exec("removeFormat", options);
  4781. }
  4782. undo(options) {
  4783. this._exec("undo", options);
  4784. }
  4785. redo(options) {
  4786. this._exec("redo", options);
  4787. }
  4788. blur(options) {
  4789. this._exec("blur", options);
  4790. }
  4791. getSelectionText(options) {
  4792. this._exec("getSelectionText", options);
  4793. }
  4794. scrollIntoView(options) {
  4795. this._exec("scrollIntoView", options);
  4796. }
  4797. _exec(method, options) {
  4798. operateEditor(this.id, this.pageId, method, options);
  4799. }
  4800. }
  4801. const ContextClasss = {
  4802. canvas: CanvasContext,
  4803. map: MapContext,
  4804. video: VideoContext,
  4805. editor: EditorContext
  4806. };
  4807. function convertContext(result) {
  4808. if (result && result.contextInfo) {
  4809. const { id: id2, type, page } = result.contextInfo;
  4810. const ContextClass = ContextClasss[type];
  4811. result.context = new ContextClass(id2, page);
  4812. delete result.contextInfo;
  4813. }
  4814. }
  4815. class NodesRef {
  4816. constructor(selectorQuery, component, selector, single) {
  4817. this._selectorQuery = selectorQuery;
  4818. this._component = component;
  4819. this._selector = selector;
  4820. this._single = single;
  4821. }
  4822. boundingClientRect(callback) {
  4823. this._selectorQuery._push(
  4824. this._selector,
  4825. this._component,
  4826. this._single,
  4827. {
  4828. id: true,
  4829. dataset: true,
  4830. rect: true,
  4831. size: true
  4832. },
  4833. callback
  4834. );
  4835. return this._selectorQuery;
  4836. }
  4837. fields(fields2, callback) {
  4838. this._selectorQuery._push(
  4839. this._selector,
  4840. this._component,
  4841. this._single,
  4842. fields2,
  4843. callback
  4844. );
  4845. return this._selectorQuery;
  4846. }
  4847. scrollOffset(callback) {
  4848. this._selectorQuery._push(
  4849. this._selector,
  4850. this._component,
  4851. this._single,
  4852. {
  4853. id: true,
  4854. dataset: true,
  4855. scrollOffset: true
  4856. },
  4857. callback
  4858. );
  4859. return this._selectorQuery;
  4860. }
  4861. context(callback) {
  4862. this._selectorQuery._push(
  4863. this._selector,
  4864. this._component,
  4865. this._single,
  4866. {
  4867. context: true
  4868. },
  4869. callback
  4870. );
  4871. return this._selectorQuery;
  4872. }
  4873. node(callback) {
  4874. this._selectorQuery._push(
  4875. this._selector,
  4876. this._component,
  4877. this._single,
  4878. {
  4879. node: true
  4880. },
  4881. callback
  4882. );
  4883. return this._selectorQuery;
  4884. }
  4885. }
  4886. class SelectorQuery {
  4887. constructor(page) {
  4888. this._component = void 0;
  4889. this._page = page;
  4890. this._queue = [];
  4891. this._queueCb = [];
  4892. }
  4893. exec(callback) {
  4894. requestComponentInfo(
  4895. this._page,
  4896. this._queue,
  4897. (res) => {
  4898. const queueCbs = this._queueCb;
  4899. res.forEach((result, index2) => {
  4900. if (isArray(result)) {
  4901. result.forEach(convertContext);
  4902. } else {
  4903. convertContext(result);
  4904. }
  4905. const queueCb = queueCbs[index2];
  4906. if (isFunction(queueCb)) {
  4907. queueCb.call(this, result);
  4908. }
  4909. });
  4910. if (isFunction(callback)) {
  4911. callback.call(this, res);
  4912. }
  4913. }
  4914. );
  4915. return this._nodesRef;
  4916. }
  4917. in(component) {
  4918. this._component = resolveComponentInstance(component);
  4919. return this;
  4920. }
  4921. select(selector) {
  4922. return this._nodesRef = new NodesRef(
  4923. this,
  4924. this._component,
  4925. selector,
  4926. true
  4927. );
  4928. }
  4929. selectAll(selector) {
  4930. return this._nodesRef = new NodesRef(
  4931. this,
  4932. this._component,
  4933. selector,
  4934. false
  4935. );
  4936. }
  4937. selectViewport() {
  4938. return this._nodesRef = new NodesRef(this, null, "", true);
  4939. }
  4940. _push(selector, component, single, fields2, callback) {
  4941. this._queue.push({
  4942. component,
  4943. selector,
  4944. single,
  4945. fields: fields2
  4946. });
  4947. this._queueCb.push(callback);
  4948. }
  4949. }
  4950. const createSelectorQuery = /* @__PURE__ */ defineSyncApi("createSelectorQuery", (context) => {
  4951. context = resolveComponentInstance(context);
  4952. if (context && !getPageIdByVm(context)) {
  4953. context = null;
  4954. }
  4955. return new SelectorQuery(context || getCurrentPageVm());
  4956. });
  4957. const API_CREATE_ANIMATION = "createAnimation";
  4958. const CreateAnimationOptions = {
  4959. // 目前参数校验不支持此api校验
  4960. formatArgs: {
  4961. /* duration: 400,
  4962. timingFunction(timingFunction, params) {
  4963. params.timingFunction = elemInArray(timingFunction, timingFunctions)
  4964. },
  4965. delay: 0,
  4966. transformOrigin: '50% 50% 0', */
  4967. }
  4968. };
  4969. const CreateAnimationProtocol = {
  4970. duration: Number,
  4971. timingFunction: String,
  4972. delay: Number,
  4973. transformOrigin: String
  4974. };
  4975. const defaultOption = {
  4976. duration: 400,
  4977. timingFunction: "linear",
  4978. delay: 0,
  4979. transformOrigin: "50% 50% 0"
  4980. };
  4981. class MPAnimation {
  4982. constructor(option) {
  4983. this.actions = [];
  4984. this.currentTransform = {};
  4985. this.currentStepAnimates = [];
  4986. this.option = extend({}, defaultOption, option);
  4987. }
  4988. _getOption(option) {
  4989. const _option = {
  4990. transition: extend({}, this.option, option),
  4991. transformOrigin: ""
  4992. };
  4993. _option.transformOrigin = _option.transition.transformOrigin;
  4994. delete _option.transition.transformOrigin;
  4995. return _option;
  4996. }
  4997. _pushAnimates(type, args) {
  4998. this.currentStepAnimates.push({
  4999. type,
  5000. args
  5001. });
  5002. }
  5003. _converType(type) {
  5004. return type.replace(/[A-Z]/g, (text2) => {
  5005. return `-${text2.toLowerCase()}`;
  5006. });
  5007. }
  5008. _getValue(value) {
  5009. return typeof value === "number" ? `${value}px` : value;
  5010. }
  5011. export() {
  5012. const actions = this.actions;
  5013. this.actions = [];
  5014. return {
  5015. actions
  5016. };
  5017. }
  5018. step(option) {
  5019. this.currentStepAnimates.forEach((animate) => {
  5020. if (animate.type !== "style") {
  5021. this.currentTransform[animate.type] = animate;
  5022. } else {
  5023. this.currentTransform[`${animate.type}.${animate.args[0]}`] = animate;
  5024. }
  5025. });
  5026. this.actions.push({
  5027. animates: Object.values(
  5028. this.currentTransform
  5029. ),
  5030. option: this._getOption(option)
  5031. });
  5032. this.currentStepAnimates = [];
  5033. return this;
  5034. }
  5035. }
  5036. const initAnimationProperty = /* @__PURE__ */ once(() => {
  5037. const animateTypes1 = [
  5038. "matrix",
  5039. "matrix3d",
  5040. "rotate",
  5041. "rotate3d",
  5042. "rotateX",
  5043. "rotateY",
  5044. "rotateZ",
  5045. "scale",
  5046. "scale3d",
  5047. "scaleX",
  5048. "scaleY",
  5049. "scaleZ",
  5050. "skew",
  5051. "skewX",
  5052. "skewY",
  5053. "translate",
  5054. "translate3d",
  5055. "translateX",
  5056. "translateY",
  5057. "translateZ"
  5058. ];
  5059. const animateTypes2 = ["opacity", "backgroundColor"];
  5060. const animateTypes3 = ["width", "height", "left", "right", "top", "bottom"];
  5061. animateTypes1.concat(animateTypes2, animateTypes3).forEach((type) => {
  5062. MPAnimation.prototype[type] = function(...args) {
  5063. if (animateTypes2.concat(animateTypes3).includes(type)) {
  5064. this._pushAnimates("style", [
  5065. this._converType(type),
  5066. animateTypes3.includes(type) ? this._getValue(args[0]) : args[0]
  5067. ]);
  5068. } else {
  5069. this._pushAnimates(type, args);
  5070. }
  5071. return this;
  5072. };
  5073. });
  5074. });
  5075. const createAnimation$1 = /* @__PURE__ */ defineSyncApi(
  5076. API_CREATE_ANIMATION,
  5077. (option) => {
  5078. initAnimationProperty();
  5079. return new MPAnimation(option);
  5080. },
  5081. CreateAnimationProtocol,
  5082. CreateAnimationOptions
  5083. );
  5084. const API_ON_TAB_BAR_MID_BUTTON_TAP = "onTabBarMidButtonTap";
  5085. const onTabBarMidButtonTap = /* @__PURE__ */ defineOnApi(
  5086. API_ON_TAB_BAR_MID_BUTTON_TAP,
  5087. () => {
  5088. }
  5089. );
  5090. const API_ON_WINDOW_RESIZE = "onWindowResize";
  5091. const API_OFF_WINDOW_RESIZE = "offWindowResize";
  5092. const onWindowResize = /* @__PURE__ */ defineOnApi(
  5093. API_ON_WINDOW_RESIZE,
  5094. () => {
  5095. }
  5096. );
  5097. const offWindowResize = /* @__PURE__ */ defineOffApi(
  5098. API_OFF_WINDOW_RESIZE,
  5099. () => {
  5100. }
  5101. );
  5102. const API_SET_LOCALE = "setLocale";
  5103. const API_GET_LOCALE = "getLocale";
  5104. const API_ON_LOCALE_CHANGE = "onLocaleChange";
  5105. const getLocale = /* @__PURE__ */ defineSyncApi(
  5106. API_GET_LOCALE,
  5107. () => {
  5108. const app = getApp({ allowDefault: true });
  5109. if (app && app.$vm) {
  5110. return app.$vm.$locale;
  5111. }
  5112. return useI18n().getLocale();
  5113. }
  5114. );
  5115. const onLocaleChange = /* @__PURE__ */ defineOnApi(
  5116. API_ON_LOCALE_CHANGE,
  5117. () => {
  5118. }
  5119. );
  5120. const setLocale = /* @__PURE__ */ defineSyncApi(
  5121. API_SET_LOCALE,
  5122. (locale) => {
  5123. const app = getApp();
  5124. if (!app) {
  5125. return false;
  5126. }
  5127. const oldLocale = app.$vm.$locale;
  5128. if (oldLocale !== locale) {
  5129. app.$vm.$locale = locale;
  5130. {
  5131. navigator.cookieEnabled && window.localStorage && (localStorage[UNI_STORAGE_LOCALE] = locale);
  5132. }
  5133. UniServiceJSBridge.invokeOnCallback(API_ON_LOCALE_CHANGE, { locale });
  5134. return true;
  5135. }
  5136. return false;
  5137. }
  5138. );
  5139. const API_SET_PAGE_META = "setPageMeta";
  5140. const setPageMeta = /* @__PURE__ */ defineAsyncApi(
  5141. API_SET_PAGE_META,
  5142. (options, { resolve }) => {
  5143. resolve(setCurrentPageMeta(getCurrentPageVm(), options));
  5144. }
  5145. );
  5146. const API_GET_SELECTED_TEXT_RANGE = "getSelectedTextRange";
  5147. const getSelectedTextRange$1 = /* @__PURE__ */ defineAsyncApi(
  5148. API_GET_SELECTED_TEXT_RANGE,
  5149. (_, { resolve, reject }) => {
  5150. UniServiceJSBridge.invokeViewMethod(API_GET_SELECTED_TEXT_RANGE, {}, getCurrentPageId(), (res) => {
  5151. if (typeof res.end === "undefined" && typeof res.start === "undefined") {
  5152. reject("no focused");
  5153. } else {
  5154. resolve(res);
  5155. }
  5156. });
  5157. }
  5158. );
  5159. const appHooks = {
  5160. [ON_UNHANDLE_REJECTION]: [],
  5161. [ON_PAGE_NOT_FOUND]: [],
  5162. [ON_ERROR]: [],
  5163. [ON_SHOW]: [],
  5164. [ON_HIDE]: []
  5165. };
  5166. function onAppHook(type, hook) {
  5167. const app = getApp({ allowDefault: true });
  5168. if (app && app.$vm) {
  5169. return injectHook(type, hook, app.$vm.$);
  5170. }
  5171. appHooks[type].push(hook);
  5172. }
  5173. function injectAppHooks(appInstance) {
  5174. Object.keys(appHooks).forEach((type) => {
  5175. appHooks[type].forEach((hook) => {
  5176. injectHook(type, hook, appInstance);
  5177. });
  5178. });
  5179. }
  5180. function offAppHook(type, hook) {
  5181. const app = getApp({ allowDefault: true });
  5182. if (app && app.$vm) {
  5183. return removeHook(app.$vm, type, hook);
  5184. }
  5185. remove(appHooks[type], hook);
  5186. }
  5187. function onUnhandledRejection(hook) {
  5188. onAppHook(ON_UNHANDLE_REJECTION, hook);
  5189. }
  5190. function offUnhandledRejection(hook) {
  5191. offAppHook(ON_UNHANDLE_REJECTION, hook);
  5192. }
  5193. function onPageNotFound(hook) {
  5194. onAppHook(ON_PAGE_NOT_FOUND, hook);
  5195. }
  5196. function offPageNotFound(hook) {
  5197. offAppHook(ON_PAGE_NOT_FOUND, hook);
  5198. }
  5199. function onError(hook) {
  5200. onAppHook(ON_ERROR, hook);
  5201. }
  5202. function offError(hook) {
  5203. offAppHook(ON_ERROR, hook);
  5204. }
  5205. function onAppShow(hook) {
  5206. onAppHook(ON_SHOW, hook);
  5207. }
  5208. function offAppShow(hook) {
  5209. offAppHook(ON_SHOW, hook);
  5210. }
  5211. function onAppHide(hook) {
  5212. onAppHook(ON_HIDE, hook);
  5213. }
  5214. function offAppHide(hook) {
  5215. offAppHook(ON_HIDE, hook);
  5216. }
  5217. const API_GET_ENTER_OPTIONS_SYNC = "getEnterOptionsSync";
  5218. const getEnterOptionsSync = /* @__PURE__ */ defineSyncApi(
  5219. API_GET_ENTER_OPTIONS_SYNC,
  5220. () => {
  5221. return getEnterOptions();
  5222. }
  5223. );
  5224. const API_GET_LAUNCH_OPTIONS_SYNC = "getLaunchOptionsSync";
  5225. const getLaunchOptionsSync = /* @__PURE__ */ defineSyncApi(
  5226. API_GET_LAUNCH_OPTIONS_SYNC,
  5227. () => {
  5228. return getLaunchOptions();
  5229. }
  5230. );
  5231. let cid;
  5232. let cidErrMsg;
  5233. let enabled;
  5234. function normalizePushMessage(message) {
  5235. try {
  5236. return JSON.parse(message);
  5237. } catch (e2) {
  5238. }
  5239. return message;
  5240. }
  5241. function invokePushCallback(args) {
  5242. if (args.type === "enabled") {
  5243. enabled = true;
  5244. } else if (args.type === "clientId") {
  5245. cid = args.cid;
  5246. cidErrMsg = args.errMsg;
  5247. invokeGetPushCidCallbacks(cid, args.errMsg);
  5248. } else if (args.type === "pushMsg") {
  5249. const message = {
  5250. type: "receive",
  5251. data: normalizePushMessage(args.message)
  5252. };
  5253. for (let i = 0; i < onPushMessageCallbacks.length; i++) {
  5254. const callback = onPushMessageCallbacks[i];
  5255. callback(message);
  5256. if (message.stopped) {
  5257. break;
  5258. }
  5259. }
  5260. } else if (args.type === "click") {
  5261. onPushMessageCallbacks.forEach((callback) => {
  5262. callback({
  5263. type: "click",
  5264. data: normalizePushMessage(args.message)
  5265. });
  5266. });
  5267. }
  5268. }
  5269. const getPushCidCallbacks = [];
  5270. function invokeGetPushCidCallbacks(cid2, errMsg) {
  5271. getPushCidCallbacks.forEach((callback) => {
  5272. callback(cid2, errMsg);
  5273. });
  5274. getPushCidCallbacks.length = 0;
  5275. }
  5276. const API_GET_PUSH_CLIENT_ID = "getPushClientId";
  5277. const getPushClientId = /* @__PURE__ */ defineAsyncApi(
  5278. API_GET_PUSH_CLIENT_ID,
  5279. (_, { resolve, reject }) => {
  5280. Promise.resolve().then(() => {
  5281. if (typeof enabled === "undefined") {
  5282. enabled = false;
  5283. cid = "";
  5284. cidErrMsg = "uniPush is not enabled";
  5285. }
  5286. getPushCidCallbacks.push((cid2, errMsg) => {
  5287. if (cid2) {
  5288. resolve({ cid: cid2 });
  5289. } else {
  5290. reject(errMsg);
  5291. }
  5292. });
  5293. if (typeof cid !== "undefined") {
  5294. invokeGetPushCidCallbacks(cid, cidErrMsg);
  5295. }
  5296. });
  5297. }
  5298. );
  5299. const onPushMessageCallbacks = [];
  5300. const onPushMessage = (fn) => {
  5301. if (onPushMessageCallbacks.indexOf(fn) === -1) {
  5302. onPushMessageCallbacks.push(fn);
  5303. }
  5304. };
  5305. const offPushMessage = (fn) => {
  5306. if (!fn) {
  5307. onPushMessageCallbacks.length = 0;
  5308. } else {
  5309. const index2 = onPushMessageCallbacks.indexOf(fn);
  5310. if (index2 > -1) {
  5311. onPushMessageCallbacks.splice(index2, 1);
  5312. }
  5313. }
  5314. };
  5315. const API_CAN_I_USE = "canIUse";
  5316. const CanIUseProtocol = [
  5317. {
  5318. name: "schema",
  5319. type: String,
  5320. required: true
  5321. }
  5322. ];
  5323. const API_MAKE_PHONE_CALL = "makePhoneCall";
  5324. const MakePhoneCallProtocol = {
  5325. phoneNumber: String
  5326. };
  5327. const API_GET_CLIPBOARD_DATA = "getClipboardData";
  5328. const API_SET_CLIPBOARD_DATA = "setClipboardData";
  5329. const SetClipboardDataOptions = {
  5330. formatArgs: {
  5331. showToast: true
  5332. },
  5333. beforeInvoke() {
  5334. initI18nSetClipboardDataMsgsOnce();
  5335. },
  5336. beforeSuccess(res, params) {
  5337. if (!params.showToast)
  5338. return;
  5339. const { t: t2 } = useI18n();
  5340. const title = t2("uni.setClipboardData.success");
  5341. if (title) {
  5342. uni.showToast({
  5343. title,
  5344. icon: "success",
  5345. mask: false
  5346. });
  5347. }
  5348. }
  5349. };
  5350. const SetClipboardDataProtocol = {
  5351. data: {
  5352. type: String,
  5353. required: true
  5354. },
  5355. showToast: {
  5356. type: Boolean
  5357. }
  5358. };
  5359. const API_ON_ACCELEROMETER = "onAccelerometer";
  5360. const API_OFF_ACCELEROMETER = "offAccelerometer";
  5361. const API_START_ACCELEROMETER = "startAccelerometer";
  5362. const API_STOP_ACCELEROMETER = "stopAccelerometer";
  5363. const API_ON_COMPASS = "onCompass";
  5364. const API_OFF_COMPASS = "offCompass";
  5365. const API_START_COMPASS = "startCompass";
  5366. const API_STOP_COMPASS = "stopCompass";
  5367. const API_VIBRATE_SHORT = "vibrateShort";
  5368. const API_VIBRATE_LONG = "vibrateLong";
  5369. const API_GET_STORAGE = "getStorage";
  5370. const GetStorageProtocol = {
  5371. key: {
  5372. type: String,
  5373. required: true
  5374. }
  5375. };
  5376. const API_GET_STORAGE_SYNC = "getStorageSync";
  5377. const GetStorageSyncProtocol = [
  5378. {
  5379. name: "key",
  5380. type: String,
  5381. required: true
  5382. }
  5383. ];
  5384. const API_SET_STORAGE = "setStorage";
  5385. const SetStorageProtocol = {
  5386. key: {
  5387. type: String,
  5388. required: true
  5389. },
  5390. data: {
  5391. required: true
  5392. }
  5393. };
  5394. const API_SET_STORAGE_SYNC = "setStorageSync";
  5395. const SetStorageSyncProtocol = [
  5396. {
  5397. name: "key",
  5398. type: String,
  5399. required: true
  5400. },
  5401. {
  5402. name: "data",
  5403. required: true
  5404. }
  5405. ];
  5406. const API_REMOVE_STORAGE = "removeStorage";
  5407. const RemoveStorageProtocol = GetStorageProtocol;
  5408. const RemoveStorageSyncProtocol = GetStorageSyncProtocol;
  5409. const API_GET_FILE_INFO = "getFileInfo";
  5410. const GetFileInfoOptions = {
  5411. formatArgs: {
  5412. filePath(filePath, params) {
  5413. params.filePath = getRealPath(filePath);
  5414. }
  5415. }
  5416. };
  5417. const GetFileInfoProtocol = {
  5418. filePath: {
  5419. type: String,
  5420. required: true
  5421. }
  5422. };
  5423. const API_OPEN_DOCUMENT = "openDocument";
  5424. const OpenDocumentOptions = {
  5425. formatArgs: {
  5426. filePath(filePath, params) {
  5427. params.filePath = getRealPath(filePath);
  5428. }
  5429. }
  5430. };
  5431. const OpenDocumentProtocol = {
  5432. filePath: {
  5433. type: String,
  5434. required: true
  5435. },
  5436. fileType: String
  5437. };
  5438. const API_HIDE_KEYBOARD = "hideKeyboard";
  5439. const API_CHOOSE_LOCATION = "chooseLocation";
  5440. const ChooseLocationProtocol = {
  5441. keyword: String,
  5442. latitude: Number,
  5443. longitude: Number
  5444. };
  5445. const API_GET_LOCATION = "getLocation";
  5446. const coordTypes$1 = ["wgs84", "gcj02"];
  5447. const GetLocationOptions = {
  5448. formatArgs: {
  5449. type(value, params) {
  5450. value = (value || "").toLowerCase();
  5451. if (coordTypes$1.indexOf(value) === -1) {
  5452. params.type = coordTypes$1[0];
  5453. } else {
  5454. params.type = value;
  5455. }
  5456. },
  5457. altitude(value, params) {
  5458. params.altitude = value ? value : false;
  5459. }
  5460. }
  5461. };
  5462. const GetLocationProtocol = {
  5463. type: String,
  5464. altitude: Boolean
  5465. };
  5466. const API_OPEN_LOCATION = "openLocation";
  5467. const checkProps = (key, value) => {
  5468. if (value === void 0) {
  5469. return `${key} should not be empty.`;
  5470. }
  5471. if (typeof value !== "number") {
  5472. let receivedType = typeof value;
  5473. receivedType = receivedType[0].toUpperCase() + receivedType.substring(1);
  5474. return `Expected Number, got ${receivedType} with value ${JSON.stringify(
  5475. value
  5476. )}.`;
  5477. }
  5478. };
  5479. const OpenLocationOptions = {
  5480. formatArgs: {
  5481. latitude(value, params) {
  5482. const checkedInfo = checkProps("latitude", value);
  5483. if (checkedInfo) {
  5484. return checkedInfo;
  5485. }
  5486. params.latitude = value;
  5487. },
  5488. longitude(value, params) {
  5489. const checkedInfo = checkProps("longitude", value);
  5490. if (checkedInfo) {
  5491. return checkedInfo;
  5492. }
  5493. params.longitude = value;
  5494. },
  5495. scale(value, params) {
  5496. value = Math.floor(value);
  5497. params.scale = value >= 5 && value <= 18 ? value : 18;
  5498. }
  5499. }
  5500. };
  5501. const OpenLocationProtocol = {
  5502. latitude: Number,
  5503. longitude: Number,
  5504. scale: Number,
  5505. name: String,
  5506. address: String
  5507. };
  5508. const API_CHOOSE_IMAGE = "chooseImage";
  5509. const ChooseImageOptions = {
  5510. formatArgs: {
  5511. count(value, params) {
  5512. if (!value || value <= 0) {
  5513. params.count = 9;
  5514. }
  5515. },
  5516. sizeType(sizeType, params) {
  5517. params.sizeType = elemsInArray(sizeType, CHOOSE_SIZE_TYPES);
  5518. },
  5519. sourceType(sourceType, params) {
  5520. params.sourceType = elemsInArray(sourceType, CHOOSE_SOURCE_TYPES);
  5521. },
  5522. extension(extension, params) {
  5523. if (extension instanceof Array && extension.length === 0) {
  5524. return "param extension should not be empty.";
  5525. }
  5526. if (!extension)
  5527. params.extension = ["*"];
  5528. }
  5529. }
  5530. };
  5531. const ChooseImageProtocol = {
  5532. count: Number,
  5533. sizeType: [Array, String],
  5534. sourceType: Array,
  5535. extension: Array
  5536. };
  5537. const API_CHOOSE_VIDEO = "chooseVideo";
  5538. const ChooseVideoOptions = {
  5539. formatArgs: {
  5540. sourceType(sourceType, params) {
  5541. params.sourceType = elemsInArray(sourceType, CHOOSE_SOURCE_TYPES);
  5542. },
  5543. compressed: true,
  5544. maxDuration: 60,
  5545. camera: "back",
  5546. extension(extension, params) {
  5547. if (extension instanceof Array && extension.length === 0) {
  5548. return "param extension should not be empty.";
  5549. }
  5550. if (!extension)
  5551. params.extension = ["*"];
  5552. }
  5553. }
  5554. };
  5555. const ChooseVideoProtocol = {
  5556. sourceType: Array,
  5557. compressed: Boolean,
  5558. maxDuration: Number,
  5559. camera: String,
  5560. extension: Array
  5561. };
  5562. const API_CHOOSE_FILE = "chooseFile";
  5563. const CHOOSE_MEDIA_TYPE = [
  5564. "all",
  5565. "image",
  5566. "video"
  5567. ];
  5568. const ChooseFileOptions = {
  5569. formatArgs: {
  5570. count(count, params) {
  5571. if (!count || count <= 0) {
  5572. params.count = 100;
  5573. }
  5574. },
  5575. sourceType(sourceType, params) {
  5576. params.sourceType = elemsInArray(sourceType, CHOOSE_SOURCE_TYPES);
  5577. },
  5578. type(type, params) {
  5579. params.type = elemInArray(type, CHOOSE_MEDIA_TYPE);
  5580. },
  5581. extension(extension, params) {
  5582. if (extension instanceof Array && extension.length === 0) {
  5583. return "param extension should not be empty.";
  5584. }
  5585. if (!extension)
  5586. params.extension = [""];
  5587. }
  5588. }
  5589. };
  5590. const ChooseFileProtocol = {
  5591. count: Number,
  5592. sourceType: Array,
  5593. type: String,
  5594. extension: Array
  5595. };
  5596. const API_GET_IMAGE_INFO = "getImageInfo";
  5597. const GetImageInfoOptions = {
  5598. formatArgs: {
  5599. src(src, params) {
  5600. params.src = getRealPath(src);
  5601. }
  5602. }
  5603. };
  5604. const GetImageInfoProtocol = {
  5605. src: {
  5606. type: String,
  5607. required: true
  5608. }
  5609. };
  5610. const API_PREVIEW_IMAGE = "previewImage";
  5611. const PreviewImageOptions = {
  5612. formatArgs: {
  5613. urls(urls, params) {
  5614. params.urls = urls.map(
  5615. (url) => isString(url) && url ? getRealPath(url) : ""
  5616. );
  5617. },
  5618. current(current, params) {
  5619. if (typeof current === "number") {
  5620. params.current = current > 0 && current < params.urls.length ? current : 0;
  5621. } else if (isString(current) && current) {
  5622. params.current = getRealPath(current);
  5623. }
  5624. }
  5625. }
  5626. };
  5627. const PreviewImageProtocol = {
  5628. urls: {
  5629. type: Array,
  5630. required: true
  5631. },
  5632. current: {
  5633. type: [Number, String]
  5634. }
  5635. };
  5636. const API_CLOSE_PREVIEW_IMAGE = "closePreviewImage";
  5637. const API_GET_VIDEO_INFO = "getVideoInfo";
  5638. const GetVideoInfoOptions = {
  5639. formatArgs: {
  5640. src(src, params) {
  5641. params.src = getRealPath(src);
  5642. }
  5643. }
  5644. };
  5645. const GetVideoInfoProtocol = {
  5646. src: {
  5647. type: String,
  5648. required: true
  5649. }
  5650. };
  5651. const API_SAVE_IMAGE_TO_PHOTOS_ALBUM = "saveImageToPhotosAlbum";
  5652. const API_SAVE_VIDEO_TO_PHOTOS_ALBUM = "saveVideoToPhotosAlbum";
  5653. const API_REQUEST = "request";
  5654. const dataType = {
  5655. JSON: "json"
  5656. };
  5657. const RESPONSE_TYPE = ["text", "arraybuffer"];
  5658. const DEFAULT_RESPONSE_TYPE = "text";
  5659. const encode = encodeURIComponent;
  5660. function stringifyQuery(url, data) {
  5661. let str = url.split("#");
  5662. const hash = str[1] || "";
  5663. str = str[0].split("?");
  5664. let query = str[1] || "";
  5665. url = str[0];
  5666. const search = query.split("&").filter((item) => item);
  5667. const params = {};
  5668. search.forEach((item) => {
  5669. const part = item.split("=");
  5670. params[part[0]] = part[1];
  5671. });
  5672. for (const key in data) {
  5673. if (hasOwn(data, key)) {
  5674. let v2 = data[key];
  5675. if (typeof v2 === "undefined" || v2 === null) {
  5676. v2 = "";
  5677. } else if (isPlainObject(v2)) {
  5678. v2 = JSON.stringify(v2);
  5679. }
  5680. params[encode(key)] = encode(v2);
  5681. }
  5682. }
  5683. query = Object.keys(params).map((item) => `${item}=${params[item]}`).join("&");
  5684. return url + (query ? "?" + query : "") + (hash ? "#" + hash : "");
  5685. }
  5686. const RequestProtocol = {
  5687. method: String,
  5688. data: [Object, String, Array, ArrayBuffer],
  5689. url: {
  5690. type: String,
  5691. required: true
  5692. },
  5693. header: Object,
  5694. dataType: String,
  5695. responseType: String,
  5696. withCredentials: Boolean
  5697. };
  5698. const RequestOptions = {
  5699. formatArgs: {
  5700. method(value, params) {
  5701. params.method = elemInArray(
  5702. (value || "").toUpperCase(),
  5703. HTTP_METHODS
  5704. );
  5705. },
  5706. data(value, params) {
  5707. params.data = value || "";
  5708. },
  5709. url(value, params) {
  5710. if (params.method === HTTP_METHODS[0] && isPlainObject(params.data) && Object.keys(params.data).length) {
  5711. params.url = stringifyQuery(value, params.data);
  5712. }
  5713. },
  5714. header(value, params) {
  5715. const header = params.header = value || {};
  5716. if (params.method !== HTTP_METHODS[0]) {
  5717. if (!Object.keys(header).find(
  5718. (key) => key.toLowerCase() === "content-type"
  5719. )) {
  5720. header["Content-Type"] = "application/json";
  5721. }
  5722. }
  5723. },
  5724. dataType(value, params) {
  5725. params.dataType = (value || dataType.JSON).toLowerCase();
  5726. },
  5727. responseType(value, params) {
  5728. params.responseType = (value || "").toLowerCase();
  5729. if (RESPONSE_TYPE.indexOf(params.responseType) === -1) {
  5730. params.responseType = DEFAULT_RESPONSE_TYPE;
  5731. }
  5732. }
  5733. }
  5734. };
  5735. const API_DOWNLOAD_FILE = "downloadFile";
  5736. const DownloadFileOptions = {
  5737. formatArgs: {
  5738. header(value, params) {
  5739. params.header = value || {};
  5740. }
  5741. }
  5742. };
  5743. const DownloadFileProtocol = {
  5744. url: {
  5745. type: String,
  5746. required: true
  5747. },
  5748. header: Object,
  5749. timeout: Number
  5750. };
  5751. const API_UPLOAD_FILE = "uploadFile";
  5752. const UploadFileOptions = {
  5753. formatArgs: {
  5754. filePath(filePath, params) {
  5755. if (filePath) {
  5756. params.filePath = getRealPath(filePath);
  5757. }
  5758. },
  5759. header(value, params) {
  5760. params.header = value || {};
  5761. },
  5762. formData(value, params) {
  5763. params.formData = value || {};
  5764. }
  5765. }
  5766. };
  5767. const UploadFileProtocol = {
  5768. url: {
  5769. type: String,
  5770. required: true
  5771. },
  5772. files: Array,
  5773. filePath: String,
  5774. name: String,
  5775. header: Object,
  5776. formData: Object,
  5777. timeout: Number
  5778. };
  5779. const API_CONNECT_SOCKET = "connectSocket";
  5780. const ConnectSocketOptions = {
  5781. formatArgs: {
  5782. header(value, params) {
  5783. params.header = value || {};
  5784. },
  5785. method(value, params) {
  5786. params.method = elemInArray(
  5787. (value || "").toUpperCase(),
  5788. HTTP_METHODS
  5789. );
  5790. },
  5791. protocols(protocols, params) {
  5792. if (isString(protocols)) {
  5793. params.protocols = [protocols];
  5794. }
  5795. }
  5796. }
  5797. };
  5798. const ConnectSocketProtocol = {
  5799. url: {
  5800. type: String,
  5801. required: true
  5802. },
  5803. header: {
  5804. type: Object
  5805. },
  5806. method: String,
  5807. protocols: [Array, String]
  5808. };
  5809. const API_SEND_SOCKET_MESSAGE = "sendSocketMessage";
  5810. const SendSocketMessageProtocol = {
  5811. data: [String, ArrayBuffer]
  5812. };
  5813. const API_CLOSE_SOCKET = "closeSocket";
  5814. const CloseSocketProtocol = {
  5815. code: Number,
  5816. reason: String
  5817. };
  5818. const API_START_LOCATION_UPDATE = "startLocationUpdate";
  5819. const API_ON_LOCATION_CHANGE = "onLocationChange";
  5820. const API_STOP_LOCATION_UPDATE = "stopLocationUpdate";
  5821. const API_OFF_LOCATION_CHANGE = "offLocationChange";
  5822. const API_OFF_LOCATION_CHANGE_ERROR = "offLocationChangeError";
  5823. const API_ON_LOCATION_CHANGE_ERROR = "onLocationChangeError";
  5824. const coordTypes = ["wgs84", "gcj02"];
  5825. const StartLocationUpdateProtocol = {
  5826. type: String
  5827. };
  5828. const StartLocationUpdateOptions = {
  5829. formatArgs: {
  5830. type(value, params) {
  5831. value = (value || "").toLowerCase();
  5832. if (coordTypes.indexOf(value) === -1) {
  5833. params.type = coordTypes[1];
  5834. } else {
  5835. params.type = value;
  5836. }
  5837. }
  5838. }
  5839. };
  5840. function encodeQueryString(url) {
  5841. if (!isString(url)) {
  5842. return url;
  5843. }
  5844. const index2 = url.indexOf("?");
  5845. if (index2 === -1) {
  5846. return url;
  5847. }
  5848. const query = url.slice(index2 + 1).trim().replace(/^(\?|#|&)/, "");
  5849. if (!query) {
  5850. return url;
  5851. }
  5852. url = url.slice(0, index2);
  5853. const params = [];
  5854. query.split("&").forEach((param) => {
  5855. const parts = param.replace(/\+/g, " ").split("=");
  5856. const key = parts.shift();
  5857. const val = parts.length > 0 ? parts.join("=") : "";
  5858. params.push(key + "=" + encodeURIComponent(val));
  5859. });
  5860. return params.length ? url + "?" + params.join("&") : url;
  5861. }
  5862. const ANIMATION_IN$1 = [
  5863. "slide-in-right",
  5864. "slide-in-left",
  5865. "slide-in-top",
  5866. "slide-in-bottom",
  5867. "fade-in",
  5868. "zoom-out",
  5869. "zoom-fade-out",
  5870. "pop-in",
  5871. "none"
  5872. ];
  5873. const ANIMATION_OUT$1 = [
  5874. "slide-out-right",
  5875. "slide-out-left",
  5876. "slide-out-top",
  5877. "slide-out-bottom",
  5878. "fade-out",
  5879. "zoom-in",
  5880. "zoom-fade-in",
  5881. "pop-out",
  5882. "none"
  5883. ];
  5884. const BaseRouteProtocol = {
  5885. url: {
  5886. type: String,
  5887. required: true
  5888. }
  5889. };
  5890. const API_NAVIGATE_TO = "navigateTo";
  5891. const API_REDIRECT_TO = "redirectTo";
  5892. const API_RE_LAUNCH = "reLaunch";
  5893. const API_SWITCH_TAB = "switchTab";
  5894. const API_NAVIGATE_BACK = "navigateBack";
  5895. const API_PRELOAD_PAGE = "preloadPage";
  5896. const API_UN_PRELOAD_PAGE = "unPreloadPage";
  5897. const NavigateToProtocol = /* @__PURE__ */ extend(
  5898. {},
  5899. BaseRouteProtocol,
  5900. createAnimationProtocol(ANIMATION_IN$1)
  5901. );
  5902. const NavigateBackProtocol = /* @__PURE__ */ extend(
  5903. {
  5904. delta: {
  5905. type: Number
  5906. }
  5907. },
  5908. createAnimationProtocol(ANIMATION_OUT$1)
  5909. );
  5910. const RedirectToProtocol = BaseRouteProtocol;
  5911. const ReLaunchProtocol = BaseRouteProtocol;
  5912. const SwitchTabProtocol = BaseRouteProtocol;
  5913. const PreloadPageProtocol = BaseRouteProtocol;
  5914. const NavigateToOptions = /* @__PURE__ */ createRouteOptions(API_NAVIGATE_TO);
  5915. const RedirectToOptions = /* @__PURE__ */ createRouteOptions(API_REDIRECT_TO);
  5916. const ReLaunchOptions = /* @__PURE__ */ createRouteOptions(API_RE_LAUNCH);
  5917. const SwitchTabOptions = /* @__PURE__ */ createRouteOptions(API_SWITCH_TAB);
  5918. const NavigateBackOptions = {
  5919. formatArgs: {
  5920. delta(value, params) {
  5921. value = parseInt(value + "") || 1;
  5922. params.delta = Math.min(getCurrentPages().length - 1, value);
  5923. }
  5924. }
  5925. };
  5926. function createAnimationProtocol(animationTypes) {
  5927. return {
  5928. animationType: {
  5929. type: String,
  5930. validator(type) {
  5931. if (type && animationTypes.indexOf(type) === -1) {
  5932. return "`" + type + "` is not supported for `animationType` (supported values are: `" + animationTypes.join("`|`") + "`)";
  5933. }
  5934. }
  5935. },
  5936. animationDuration: {
  5937. type: Number
  5938. }
  5939. };
  5940. }
  5941. let navigatorLock;
  5942. function beforeRoute() {
  5943. navigatorLock = "";
  5944. }
  5945. function createRouteOptions(type) {
  5946. return {
  5947. formatArgs: {
  5948. url: createNormalizeUrl(type)
  5949. },
  5950. beforeAll: beforeRoute
  5951. };
  5952. }
  5953. function createNormalizeUrl(type) {
  5954. return function normalizeUrl(url, params) {
  5955. if (!url) {
  5956. return `Missing required args: "url"`;
  5957. }
  5958. url = normalizeRoute(url);
  5959. const pagePath = url.split("?")[0];
  5960. const routeOptions = getRouteOptions(pagePath, true);
  5961. if (!routeOptions) {
  5962. return "page `" + url + "` is not found";
  5963. }
  5964. if (type === API_NAVIGATE_TO || type === API_REDIRECT_TO) {
  5965. if (routeOptions.meta.isTabBar) {
  5966. return `can not ${type} a tabbar page`;
  5967. }
  5968. } else if (type === API_SWITCH_TAB) {
  5969. if (!routeOptions.meta.isTabBar) {
  5970. return "can not switch to no-tabBar page";
  5971. }
  5972. }
  5973. if ((type === API_SWITCH_TAB || type === API_PRELOAD_PAGE) && routeOptions.meta.isTabBar && params.openType !== "appLaunch") {
  5974. url = pagePath;
  5975. }
  5976. if (routeOptions.meta.isEntry) {
  5977. url = url.replace(routeOptions.alias, "/");
  5978. }
  5979. params.url = encodeQueryString(url);
  5980. if (type === API_UN_PRELOAD_PAGE) {
  5981. return;
  5982. } else if (type === API_PRELOAD_PAGE) {
  5983. if (routeOptions.meta.isTabBar) {
  5984. const pages = getCurrentPages();
  5985. const tabBarPagePath = routeOptions.path.slice(1);
  5986. if (pages.find((page) => page.route === tabBarPagePath)) {
  5987. return "tabBar page `" + tabBarPagePath + "` already exists";
  5988. }
  5989. }
  5990. return;
  5991. }
  5992. if (navigatorLock === url && params.openType !== "appLaunch") {
  5993. return `${navigatorLock} locked`;
  5994. }
  5995. if (__uniConfig.ready) {
  5996. navigatorLock = url;
  5997. }
  5998. };
  5999. }
  6000. const API_HIDE_LOADING = "hideLoading";
  6001. const API_HIDE_TOAST = "hideToast";
  6002. const API_LOAD_FONT_FACE = "loadFontFace";
  6003. const LoadFontFaceProtocol = {
  6004. family: {
  6005. type: String,
  6006. required: true
  6007. },
  6008. source: {
  6009. type: String,
  6010. required: true
  6011. },
  6012. desc: Object
  6013. };
  6014. const FRONT_COLORS = ["#ffffff", "#000000"];
  6015. const API_SET_NAVIGATION_BAR_COLOR = "setNavigationBarColor";
  6016. const SetNavigationBarColorOptions = {
  6017. formatArgs: {
  6018. animation(animation2, params) {
  6019. if (!animation2) {
  6020. animation2 = { duration: 0, timingFunc: "linear" };
  6021. }
  6022. params.animation = {
  6023. duration: animation2.duration || 0,
  6024. timingFunc: animation2.timingFunc || "linear"
  6025. };
  6026. }
  6027. }
  6028. };
  6029. const SetNavigationBarColorProtocol = {
  6030. frontColor: {
  6031. type: String,
  6032. required: true,
  6033. validator(frontColor) {
  6034. if (FRONT_COLORS.indexOf(frontColor) === -1) {
  6035. return `invalid frontColor "${frontColor}"`;
  6036. }
  6037. }
  6038. },
  6039. backgroundColor: {
  6040. type: String,
  6041. required: true
  6042. },
  6043. animation: Object
  6044. };
  6045. const API_SET_NAVIGATION_BAR_TITLE = "setNavigationBarTitle";
  6046. const SetNavigationBarTitleProtocol = {
  6047. title: {
  6048. type: String,
  6049. required: true
  6050. }
  6051. };
  6052. const API_SHOW_NAVIGATION_BAR_LOADING = "showNavigationBarLoading";
  6053. const API_HIDE_NAVIGATION_BAR_LOADING = "hideNavigationBarLoading";
  6054. const API_PAGE_SCROLL_TO = "pageScrollTo";
  6055. const PageScrollToProtocol = {
  6056. scrollTop: Number,
  6057. selector: String,
  6058. duration: Number
  6059. };
  6060. const PageScrollToOptions = {
  6061. formatArgs: {
  6062. duration: 300
  6063. }
  6064. };
  6065. const API_SHOW_ACTION_SHEET = "showActionSheet";
  6066. const ShowActionSheetProtocol = {
  6067. itemList: {
  6068. type: Array,
  6069. required: true
  6070. },
  6071. title: String,
  6072. itemColor: String,
  6073. popover: Object
  6074. };
  6075. const ShowActionSheetOptions = {
  6076. formatArgs: {
  6077. itemColor: "#000"
  6078. }
  6079. };
  6080. const API_SHOW_LOADING = "showLoading";
  6081. const ShowLoadingProtocol = {
  6082. title: String,
  6083. mask: Boolean
  6084. };
  6085. const ShowLoadingOptions = {
  6086. formatArgs: {
  6087. title: "",
  6088. mask: false
  6089. }
  6090. };
  6091. const API_SHOW_MODAL = "showModal";
  6092. const ShowModalProtocol = {
  6093. title: String,
  6094. content: String,
  6095. showCancel: Boolean,
  6096. cancelText: String,
  6097. cancelColor: String,
  6098. confirmText: String,
  6099. confirmColor: String
  6100. };
  6101. const ShowModalOptions = {
  6102. beforeInvoke() {
  6103. initI18nShowModalMsgsOnce();
  6104. },
  6105. formatArgs: {
  6106. title: "",
  6107. content: "",
  6108. placeholderText: "",
  6109. showCancel: true,
  6110. editable: false,
  6111. cancelText(_value, params) {
  6112. if (!hasOwn(params, "cancelText")) {
  6113. const { t: t2 } = useI18n();
  6114. params.cancelText = t2("uni.showModal.cancel");
  6115. }
  6116. },
  6117. cancelColor: "#000",
  6118. confirmText(_value, params) {
  6119. if (!hasOwn(params, "confirmText")) {
  6120. const { t: t2 } = useI18n();
  6121. params.confirmText = t2("uni.showModal.confirm");
  6122. }
  6123. },
  6124. confirmColor: PRIMARY_COLOR
  6125. }
  6126. };
  6127. const API_SHOW_TOAST = "showToast";
  6128. const SHOW_TOAST_ICON = [
  6129. "success",
  6130. "loading",
  6131. "none",
  6132. "error"
  6133. ];
  6134. const ShowToastProtocol = {
  6135. title: String,
  6136. icon: String,
  6137. image: String,
  6138. duration: Number,
  6139. mask: Boolean
  6140. };
  6141. const ShowToastOptions = {
  6142. formatArgs: {
  6143. title: "",
  6144. icon(type, params) {
  6145. params.icon = elemInArray(type, SHOW_TOAST_ICON);
  6146. },
  6147. image(value, params) {
  6148. if (value) {
  6149. params.image = getRealPath(value);
  6150. } else {
  6151. params.image = "";
  6152. }
  6153. },
  6154. duration: 1500,
  6155. mask: false
  6156. }
  6157. };
  6158. const API_START_PULL_DOWN_REFRESH = "startPullDownRefresh";
  6159. const API_STOP_PULL_DOWN_REFRESH = "stopPullDownRefresh";
  6160. const IndexProtocol = {
  6161. index: {
  6162. type: Number,
  6163. required: true
  6164. }
  6165. };
  6166. const IndexOptions = {
  6167. beforeInvoke() {
  6168. const pageMeta = getCurrentPageMeta();
  6169. if (pageMeta && !pageMeta.isTabBar) {
  6170. return "not TabBar page";
  6171. }
  6172. },
  6173. formatArgs: {
  6174. index(value) {
  6175. if (!__uniConfig.tabBar.list[value]) {
  6176. return "tabbar item not found";
  6177. }
  6178. }
  6179. }
  6180. };
  6181. const API_SET_TAB_BAR_ITEM = "setTabBarItem";
  6182. const SetTabBarItemProtocol = /* @__PURE__ */ extend(
  6183. {
  6184. text: String,
  6185. iconPath: String,
  6186. selectedIconPath: String,
  6187. pagePath: String
  6188. },
  6189. IndexProtocol
  6190. );
  6191. const SetTabBarItemOptions = {
  6192. beforeInvoke: IndexOptions.beforeInvoke,
  6193. formatArgs: /* @__PURE__ */ extend(
  6194. {
  6195. pagePath(value, params) {
  6196. if (value) {
  6197. params.pagePath = removeLeadingSlash(value);
  6198. }
  6199. }
  6200. },
  6201. IndexOptions.formatArgs
  6202. )
  6203. };
  6204. const API_SET_TAB_BAR_STYLE = "setTabBarStyle";
  6205. const SetTabBarStyleProtocol = {
  6206. color: String,
  6207. selectedColor: String,
  6208. backgroundColor: String,
  6209. backgroundImage: String,
  6210. backgroundRepeat: String,
  6211. borderStyle: String
  6212. };
  6213. const GRADIENT_RE = /^(linear|radial)-gradient\(.+?\);?$/;
  6214. const SetTabBarStyleOptions = {
  6215. beforeInvoke: IndexOptions.beforeInvoke,
  6216. formatArgs: {
  6217. backgroundImage(value, params) {
  6218. if (value && !GRADIENT_RE.test(value)) {
  6219. params.backgroundImage = getRealPath(value);
  6220. }
  6221. },
  6222. borderStyle(value, params) {
  6223. if (value) {
  6224. params.borderStyle = value === "white" ? "white" : "black";
  6225. }
  6226. }
  6227. }
  6228. };
  6229. const API_HIDE_TAB_BAR = "hideTabBar";
  6230. const HideTabBarProtocol = {
  6231. animation: Boolean
  6232. };
  6233. const API_SHOW_TAB_BAR = "showTabBar";
  6234. const ShowTabBarProtocol = HideTabBarProtocol;
  6235. const API_HIDE_TAB_BAR_RED_DOT = "hideTabBarRedDot";
  6236. const HideTabBarRedDotProtocol = IndexProtocol;
  6237. const HideTabBarRedDotOptions = IndexOptions;
  6238. const API_SHOW_TAB_BAR_RED_DOT = "showTabBarRedDot";
  6239. const ShowTabBarRedDotProtocol = IndexProtocol;
  6240. const ShowTabBarRedDotOptions = IndexOptions;
  6241. const API_REMOVE_TAB_BAR_BADGE = "removeTabBarBadge";
  6242. const RemoveTabBarBadgeProtocol = IndexProtocol;
  6243. const RemoveTabBarBadgeOptions = IndexOptions;
  6244. const API_SET_TAB_BAR_BADGE = "setTabBarBadge";
  6245. const SetTabBarBadgeProtocol = /* @__PURE__ */ extend(
  6246. {
  6247. text: {
  6248. type: String,
  6249. required: true
  6250. }
  6251. },
  6252. IndexProtocol
  6253. );
  6254. const SetTabBarBadgeOptions = {
  6255. beforeInvoke: IndexOptions.beforeInvoke,
  6256. formatArgs: /* @__PURE__ */ extend(
  6257. {
  6258. text(value, params) {
  6259. if (getLen(value) >= 4) {
  6260. params.text = "...";
  6261. }
  6262. }
  6263. },
  6264. IndexOptions.formatArgs
  6265. )
  6266. };
  6267. const initIntersectionObserverPolyfill = function() {
  6268. if (typeof window !== "object") {
  6269. return;
  6270. }
  6271. if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
  6272. if (!("isIntersecting" in window.IntersectionObserverEntry.prototype)) {
  6273. Object.defineProperty(
  6274. window.IntersectionObserverEntry.prototype,
  6275. "isIntersecting",
  6276. {
  6277. get: function() {
  6278. return this.intersectionRatio > 0;
  6279. }
  6280. }
  6281. );
  6282. }
  6283. return;
  6284. }
  6285. function getFrameElement(doc) {
  6286. try {
  6287. return doc.defaultView && doc.defaultView.frameElement || null;
  6288. } catch (e2) {
  6289. return null;
  6290. }
  6291. }
  6292. var document2 = function(startDoc) {
  6293. var doc = startDoc;
  6294. var frame = getFrameElement(doc);
  6295. while (frame) {
  6296. doc = frame.ownerDocument;
  6297. frame = getFrameElement(doc);
  6298. }
  6299. return doc;
  6300. }(window.document);
  6301. var registry = [];
  6302. var crossOriginUpdater = null;
  6303. var crossOriginRect = null;
  6304. function IntersectionObserverEntry(entry) {
  6305. this.time = entry.time;
  6306. this.target = entry.target;
  6307. this.rootBounds = ensureDOMRect(entry.rootBounds);
  6308. this.boundingClientRect = ensureDOMRect(entry.boundingClientRect);
  6309. this.intersectionRect = ensureDOMRect(
  6310. entry.intersectionRect || getEmptyRect()
  6311. );
  6312. this.isIntersecting = !!entry.intersectionRect;
  6313. var targetRect = this.boundingClientRect;
  6314. var targetArea = targetRect.width * targetRect.height;
  6315. var intersectionRect = this.intersectionRect;
  6316. var intersectionArea = intersectionRect.width * intersectionRect.height;
  6317. if (targetArea) {
  6318. this.intersectionRatio = Number(
  6319. (intersectionArea / targetArea).toFixed(4)
  6320. );
  6321. } else {
  6322. this.intersectionRatio = this.isIntersecting ? 1 : 0;
  6323. }
  6324. }
  6325. function IntersectionObserver2(callback, opt_options) {
  6326. var options = opt_options || {};
  6327. if (typeof callback != "function") {
  6328. throw new Error("callback must be a function");
  6329. }
  6330. if (options.root && options.root.nodeType != 1 && options.root.nodeType != 9) {
  6331. throw new Error("root must be a Document or Element");
  6332. }
  6333. this._checkForIntersections = throttle2(
  6334. this._checkForIntersections.bind(this),
  6335. this.THROTTLE_TIMEOUT
  6336. );
  6337. this._callback = callback;
  6338. this._observationTargets = [];
  6339. this._queuedEntries = [];
  6340. this._rootMarginValues = this._parseRootMargin(options.rootMargin);
  6341. this.thresholds = this._initThresholds(options.threshold);
  6342. this.root = options.root || null;
  6343. this.rootMargin = this._rootMarginValues.map(function(margin) {
  6344. return margin.value + margin.unit;
  6345. }).join(" ");
  6346. this._monitoringDocuments = [];
  6347. this._monitoringUnsubscribes = [];
  6348. }
  6349. IntersectionObserver2.prototype.THROTTLE_TIMEOUT = 100;
  6350. IntersectionObserver2.prototype.POLL_INTERVAL = null;
  6351. IntersectionObserver2.prototype.USE_MUTATION_OBSERVER = true;
  6352. IntersectionObserver2._setupCrossOriginUpdater = function() {
  6353. if (!crossOriginUpdater) {
  6354. crossOriginUpdater = function(boundingClientRect, intersectionRect) {
  6355. if (!boundingClientRect || !intersectionRect) {
  6356. crossOriginRect = getEmptyRect();
  6357. } else {
  6358. crossOriginRect = convertFromParentRect(
  6359. boundingClientRect,
  6360. intersectionRect
  6361. );
  6362. }
  6363. registry.forEach(function(observer) {
  6364. observer._checkForIntersections();
  6365. });
  6366. };
  6367. }
  6368. return crossOriginUpdater;
  6369. };
  6370. IntersectionObserver2._resetCrossOriginUpdater = function() {
  6371. crossOriginUpdater = null;
  6372. crossOriginRect = null;
  6373. };
  6374. IntersectionObserver2.prototype.observe = function(target) {
  6375. var isTargetAlreadyObserved = this._observationTargets.some(function(item) {
  6376. return item.element == target;
  6377. });
  6378. if (isTargetAlreadyObserved) {
  6379. return;
  6380. }
  6381. if (!(target && target.nodeType == 1)) {
  6382. throw new Error("target must be an Element");
  6383. }
  6384. this._registerInstance();
  6385. this._observationTargets.push({ element: target, entry: null });
  6386. this._monitorIntersections(target.ownerDocument);
  6387. this._checkForIntersections();
  6388. };
  6389. IntersectionObserver2.prototype.unobserve = function(target) {
  6390. this._observationTargets = this._observationTargets.filter(function(item) {
  6391. return item.element != target;
  6392. });
  6393. this._unmonitorIntersections(target.ownerDocument);
  6394. if (this._observationTargets.length == 0) {
  6395. this._unregisterInstance();
  6396. }
  6397. };
  6398. IntersectionObserver2.prototype.disconnect = function() {
  6399. this._observationTargets = [];
  6400. this._unmonitorAllIntersections();
  6401. this._unregisterInstance();
  6402. };
  6403. IntersectionObserver2.prototype.takeRecords = function() {
  6404. var records = this._queuedEntries.slice();
  6405. this._queuedEntries = [];
  6406. return records;
  6407. };
  6408. IntersectionObserver2.prototype._initThresholds = function(opt_threshold) {
  6409. var threshold = opt_threshold || [0];
  6410. if (!Array.isArray(threshold))
  6411. threshold = [threshold];
  6412. return threshold.sort().filter(function(t2, i, a2) {
  6413. if (typeof t2 != "number" || isNaN(t2) || t2 < 0 || t2 > 1) {
  6414. throw new Error(
  6415. "threshold must be a number between 0 and 1 inclusively"
  6416. );
  6417. }
  6418. return t2 !== a2[i - 1];
  6419. });
  6420. };
  6421. IntersectionObserver2.prototype._parseRootMargin = function(opt_rootMargin) {
  6422. var marginString = opt_rootMargin || "0px";
  6423. var margins = marginString.split(/\s+/).map(function(margin) {
  6424. var parts = /^(-?\d*\.?\d+)(px|%)$/.exec(margin);
  6425. if (!parts) {
  6426. throw new Error("rootMargin must be specified in pixels or percent");
  6427. }
  6428. return { value: parseFloat(parts[1]), unit: parts[2] };
  6429. });
  6430. margins[1] = margins[1] || margins[0];
  6431. margins[2] = margins[2] || margins[0];
  6432. margins[3] = margins[3] || margins[1];
  6433. return margins;
  6434. };
  6435. IntersectionObserver2.prototype._monitorIntersections = function(doc) {
  6436. var win = doc.defaultView;
  6437. if (!win) {
  6438. return;
  6439. }
  6440. if (this._monitoringDocuments.indexOf(doc) != -1) {
  6441. return;
  6442. }
  6443. var callback = this._checkForIntersections;
  6444. var monitoringInterval = null;
  6445. var domObserver = null;
  6446. if (this.POLL_INTERVAL) {
  6447. monitoringInterval = win.setInterval(callback, this.POLL_INTERVAL);
  6448. } else {
  6449. addEvent(win, "resize", callback, true);
  6450. addEvent(doc, "scroll", callback, true);
  6451. if (this.USE_MUTATION_OBSERVER && "MutationObserver" in win) {
  6452. domObserver = new win.MutationObserver(callback);
  6453. domObserver.observe(doc, {
  6454. attributes: true,
  6455. childList: true,
  6456. characterData: true,
  6457. subtree: true
  6458. });
  6459. }
  6460. }
  6461. this._monitoringDocuments.push(doc);
  6462. this._monitoringUnsubscribes.push(function() {
  6463. var win2 = doc.defaultView;
  6464. if (win2) {
  6465. if (monitoringInterval) {
  6466. win2.clearInterval(monitoringInterval);
  6467. }
  6468. removeEvent(win2, "resize", callback, true);
  6469. }
  6470. removeEvent(doc, "scroll", callback, true);
  6471. if (domObserver) {
  6472. domObserver.disconnect();
  6473. }
  6474. });
  6475. var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2;
  6476. if (doc != rootDoc) {
  6477. var frame = getFrameElement(doc);
  6478. if (frame) {
  6479. this._monitorIntersections(frame.ownerDocument);
  6480. }
  6481. }
  6482. };
  6483. IntersectionObserver2.prototype._unmonitorIntersections = function(doc) {
  6484. var index2 = this._monitoringDocuments.indexOf(doc);
  6485. if (index2 == -1) {
  6486. return;
  6487. }
  6488. var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2;
  6489. var hasDependentTargets = this._observationTargets.some(function(item) {
  6490. var itemDoc = item.element.ownerDocument;
  6491. if (itemDoc == doc) {
  6492. return true;
  6493. }
  6494. while (itemDoc && itemDoc != rootDoc) {
  6495. var frame2 = getFrameElement(itemDoc);
  6496. itemDoc = frame2 && frame2.ownerDocument;
  6497. if (itemDoc == doc) {
  6498. return true;
  6499. }
  6500. }
  6501. return false;
  6502. });
  6503. if (hasDependentTargets) {
  6504. return;
  6505. }
  6506. var unsubscribe = this._monitoringUnsubscribes[index2];
  6507. this._monitoringDocuments.splice(index2, 1);
  6508. this._monitoringUnsubscribes.splice(index2, 1);
  6509. unsubscribe();
  6510. if (doc != rootDoc) {
  6511. var frame = getFrameElement(doc);
  6512. if (frame) {
  6513. this._unmonitorIntersections(frame.ownerDocument);
  6514. }
  6515. }
  6516. };
  6517. IntersectionObserver2.prototype._unmonitorAllIntersections = function() {
  6518. var unsubscribes = this._monitoringUnsubscribes.slice(0);
  6519. this._monitoringDocuments.length = 0;
  6520. this._monitoringUnsubscribes.length = 0;
  6521. for (var i = 0; i < unsubscribes.length; i++) {
  6522. unsubscribes[i]();
  6523. }
  6524. };
  6525. IntersectionObserver2.prototype._checkForIntersections = function() {
  6526. if (!this.root && crossOriginUpdater && !crossOriginRect) {
  6527. return;
  6528. }
  6529. var rootIsInDom = this._rootIsInDom();
  6530. var rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect();
  6531. this._observationTargets.forEach(function(item) {
  6532. var target = item.element;
  6533. var targetRect = getBoundingClientRect(target);
  6534. var rootContainsTarget = this._rootContainsTarget(target);
  6535. var oldEntry = item.entry;
  6536. var intersectionRect = rootIsInDom && rootContainsTarget && this._computeTargetAndRootIntersection(target, targetRect, rootRect);
  6537. var rootBounds = null;
  6538. if (!this._rootContainsTarget(target)) {
  6539. rootBounds = getEmptyRect();
  6540. } else if (!crossOriginUpdater || this.root) {
  6541. rootBounds = rootRect;
  6542. }
  6543. var newEntry = item.entry = new IntersectionObserverEntry({
  6544. time: now(),
  6545. target,
  6546. boundingClientRect: targetRect,
  6547. rootBounds,
  6548. intersectionRect
  6549. });
  6550. if (!oldEntry) {
  6551. this._queuedEntries.push(newEntry);
  6552. } else if (rootIsInDom && rootContainsTarget) {
  6553. if (this._hasCrossedThreshold(oldEntry, newEntry)) {
  6554. this._queuedEntries.push(newEntry);
  6555. }
  6556. } else {
  6557. if (oldEntry && oldEntry.isIntersecting) {
  6558. this._queuedEntries.push(newEntry);
  6559. }
  6560. }
  6561. }, this);
  6562. if (this._queuedEntries.length) {
  6563. this._callback(this.takeRecords(), this);
  6564. }
  6565. };
  6566. IntersectionObserver2.prototype._computeTargetAndRootIntersection = function(target, targetRect, rootRect) {
  6567. if (window.getComputedStyle(target).display == "none")
  6568. return;
  6569. var intersectionRect = targetRect;
  6570. var parent = getParentNode(target);
  6571. var atRoot = false;
  6572. while (!atRoot && parent) {
  6573. var parentRect = null;
  6574. var parentComputedStyle = parent.nodeType == 1 ? window.getComputedStyle(parent) : {};
  6575. if (parentComputedStyle.display == "none")
  6576. return null;
  6577. if (parent == this.root || parent.nodeType == /* DOCUMENT */
  6578. 9) {
  6579. atRoot = true;
  6580. if (parent == this.root || parent == document2) {
  6581. if (crossOriginUpdater && !this.root) {
  6582. if (!crossOriginRect || crossOriginRect.width == 0 && crossOriginRect.height == 0) {
  6583. parent = null;
  6584. parentRect = null;
  6585. intersectionRect = null;
  6586. } else {
  6587. parentRect = crossOriginRect;
  6588. }
  6589. } else {
  6590. parentRect = rootRect;
  6591. }
  6592. } else {
  6593. var frame = getParentNode(parent);
  6594. var frameRect = frame && getBoundingClientRect(frame);
  6595. var frameIntersect = frame && this._computeTargetAndRootIntersection(frame, frameRect, rootRect);
  6596. if (frameRect && frameIntersect) {
  6597. parent = frame;
  6598. parentRect = convertFromParentRect(frameRect, frameIntersect);
  6599. } else {
  6600. parent = null;
  6601. intersectionRect = null;
  6602. }
  6603. }
  6604. } else {
  6605. var doc = parent.ownerDocument;
  6606. if (parent != doc.body && parent != doc.documentElement && parentComputedStyle.overflow != "visible") {
  6607. parentRect = getBoundingClientRect(parent);
  6608. }
  6609. }
  6610. if (parentRect) {
  6611. intersectionRect = computeRectIntersection(parentRect, intersectionRect);
  6612. }
  6613. if (!intersectionRect)
  6614. break;
  6615. parent = parent && getParentNode(parent);
  6616. }
  6617. return intersectionRect;
  6618. };
  6619. IntersectionObserver2.prototype._getRootRect = function() {
  6620. var rootRect;
  6621. if (this.root && !isDoc(this.root)) {
  6622. rootRect = getBoundingClientRect(this.root);
  6623. } else {
  6624. var doc = isDoc(this.root) ? this.root : document2;
  6625. var html = doc.documentElement;
  6626. var body = doc.body;
  6627. rootRect = {
  6628. top: 0,
  6629. left: 0,
  6630. right: html.clientWidth || body.clientWidth,
  6631. width: html.clientWidth || body.clientWidth,
  6632. bottom: html.clientHeight || body.clientHeight,
  6633. height: html.clientHeight || body.clientHeight
  6634. };
  6635. }
  6636. return this._expandRectByRootMargin(rootRect);
  6637. };
  6638. IntersectionObserver2.prototype._expandRectByRootMargin = function(rect) {
  6639. var margins = this._rootMarginValues.map(function(margin, i) {
  6640. return margin.unit == "px" ? margin.value : margin.value * (i % 2 ? rect.width : rect.height) / 100;
  6641. });
  6642. var newRect = {
  6643. top: rect.top - margins[0],
  6644. right: rect.right + margins[1],
  6645. bottom: rect.bottom + margins[2],
  6646. left: rect.left - margins[3]
  6647. };
  6648. newRect.width = newRect.right - newRect.left;
  6649. newRect.height = newRect.bottom - newRect.top;
  6650. return newRect;
  6651. };
  6652. IntersectionObserver2.prototype._hasCrossedThreshold = function(oldEntry, newEntry) {
  6653. var oldRatio = oldEntry && oldEntry.isIntersecting ? oldEntry.intersectionRatio || 0 : -1;
  6654. var newRatio = newEntry.isIntersecting ? newEntry.intersectionRatio || 0 : -1;
  6655. if (oldRatio === newRatio)
  6656. return;
  6657. for (var i = 0; i < this.thresholds.length; i++) {
  6658. var threshold = this.thresholds[i];
  6659. if (threshold == oldRatio || threshold == newRatio || threshold < oldRatio !== threshold < newRatio) {
  6660. return true;
  6661. }
  6662. }
  6663. };
  6664. IntersectionObserver2.prototype._rootIsInDom = function() {
  6665. return !this.root || containsDeep(document2, this.root);
  6666. };
  6667. IntersectionObserver2.prototype._rootContainsTarget = function(target) {
  6668. var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2;
  6669. return containsDeep(rootDoc, target) && (!this.root || rootDoc == target.ownerDocument);
  6670. };
  6671. IntersectionObserver2.prototype._registerInstance = function() {
  6672. if (registry.indexOf(this) < 0) {
  6673. registry.push(this);
  6674. }
  6675. };
  6676. IntersectionObserver2.prototype._unregisterInstance = function() {
  6677. var index2 = registry.indexOf(this);
  6678. if (index2 != -1)
  6679. registry.splice(index2, 1);
  6680. };
  6681. function now() {
  6682. return window.performance && performance.now && performance.now();
  6683. }
  6684. function throttle2(fn, timeout) {
  6685. var timer = null;
  6686. return function() {
  6687. if (!timer) {
  6688. timer = setTimeout(function() {
  6689. fn();
  6690. timer = null;
  6691. }, timeout);
  6692. }
  6693. };
  6694. }
  6695. function addEvent(node, event, fn, opt_useCapture) {
  6696. if (typeof node.addEventListener == "function") {
  6697. node.addEventListener(event, fn, opt_useCapture || false);
  6698. } else if (typeof node.attachEvent == "function") {
  6699. node.attachEvent("on" + event, fn);
  6700. }
  6701. }
  6702. function removeEvent(node, event, fn, opt_useCapture) {
  6703. if (typeof node.removeEventListener == "function") {
  6704. node.removeEventListener(event, fn, opt_useCapture || false);
  6705. } else if (typeof node.detatchEvent == "function") {
  6706. node.detatchEvent("on" + event, fn);
  6707. }
  6708. }
  6709. function computeRectIntersection(rect1, rect2) {
  6710. var top = Math.max(rect1.top, rect2.top);
  6711. var bottom = Math.min(rect1.bottom, rect2.bottom);
  6712. var left = Math.max(rect1.left, rect2.left);
  6713. var right = Math.min(rect1.right, rect2.right);
  6714. var width = right - left;
  6715. var height = bottom - top;
  6716. return width >= 0 && height >= 0 && {
  6717. top,
  6718. bottom,
  6719. left,
  6720. right,
  6721. width,
  6722. height
  6723. } || null;
  6724. }
  6725. function getBoundingClientRect(el) {
  6726. var rect;
  6727. try {
  6728. rect = el.getBoundingClientRect();
  6729. } catch (err) {
  6730. }
  6731. if (!rect)
  6732. return getEmptyRect();
  6733. if (!(rect.width && rect.height)) {
  6734. rect = {
  6735. top: rect.top,
  6736. right: rect.right,
  6737. bottom: rect.bottom,
  6738. left: rect.left,
  6739. width: rect.right - rect.left,
  6740. height: rect.bottom - rect.top
  6741. };
  6742. }
  6743. return rect;
  6744. }
  6745. function getEmptyRect() {
  6746. return {
  6747. top: 0,
  6748. bottom: 0,
  6749. left: 0,
  6750. right: 0,
  6751. width: 0,
  6752. height: 0
  6753. };
  6754. }
  6755. function ensureDOMRect(rect) {
  6756. if (!rect || "x" in rect) {
  6757. return rect;
  6758. }
  6759. return {
  6760. top: rect.top,
  6761. y: rect.top,
  6762. bottom: rect.bottom,
  6763. left: rect.left,
  6764. x: rect.left,
  6765. right: rect.right,
  6766. width: rect.width,
  6767. height: rect.height
  6768. };
  6769. }
  6770. function convertFromParentRect(parentBoundingRect, parentIntersectionRect) {
  6771. var top = parentIntersectionRect.top - parentBoundingRect.top;
  6772. var left = parentIntersectionRect.left - parentBoundingRect.left;
  6773. return {
  6774. top,
  6775. left,
  6776. height: parentIntersectionRect.height,
  6777. width: parentIntersectionRect.width,
  6778. bottom: top + parentIntersectionRect.height,
  6779. right: left + parentIntersectionRect.width
  6780. };
  6781. }
  6782. function containsDeep(parent, child) {
  6783. var node = child;
  6784. while (node) {
  6785. if (node == parent)
  6786. return true;
  6787. node = getParentNode(node);
  6788. }
  6789. return false;
  6790. }
  6791. function getParentNode(node) {
  6792. var parent = node.parentNode;
  6793. if (node.nodeType == /* DOCUMENT */
  6794. 9 && node != document2) {
  6795. return getFrameElement(node);
  6796. }
  6797. if (parent && parent.assignedSlot) {
  6798. parent = parent.assignedSlot.parentNode;
  6799. }
  6800. if (parent && parent.nodeType == 11 && parent.host) {
  6801. return parent.host;
  6802. }
  6803. return parent;
  6804. }
  6805. function isDoc(node) {
  6806. return node && node.nodeType === 9;
  6807. }
  6808. window.IntersectionObserver = IntersectionObserver2;
  6809. window.IntersectionObserverEntry = IntersectionObserverEntry;
  6810. };
  6811. function normalizeRect(rect) {
  6812. const { bottom, height, left, right, top, width } = rect || {};
  6813. return {
  6814. bottom,
  6815. height,
  6816. left,
  6817. right,
  6818. top,
  6819. width
  6820. };
  6821. }
  6822. function rectifyIntersectionRatio(entrie) {
  6823. const {
  6824. intersectionRatio,
  6825. boundingClientRect: { height: overAllHeight, width: overAllWidth },
  6826. intersectionRect: { height: intersectionHeight, width: intersectionWidth }
  6827. } = entrie;
  6828. if (intersectionRatio !== 0)
  6829. return intersectionRatio;
  6830. return intersectionHeight === overAllHeight ? intersectionWidth / overAllWidth : intersectionHeight / overAllHeight;
  6831. }
  6832. function requestComponentObserver($el, options, callback) {
  6833. initIntersectionObserverPolyfill();
  6834. const root = options.relativeToSelector ? $el.querySelector(options.relativeToSelector) : null;
  6835. const intersectionObserver = new IntersectionObserver(
  6836. (entries2) => {
  6837. entries2.forEach((entrie) => {
  6838. callback({
  6839. intersectionRatio: rectifyIntersectionRatio(entrie),
  6840. intersectionRect: normalizeRect(entrie.intersectionRect),
  6841. boundingClientRect: normalizeRect(entrie.boundingClientRect),
  6842. relativeRect: normalizeRect(entrie.rootBounds),
  6843. time: Date.now(),
  6844. dataset: getCustomDataset(entrie.target),
  6845. id: entrie.target.id
  6846. });
  6847. });
  6848. },
  6849. {
  6850. root,
  6851. rootMargin: options.rootMargin,
  6852. threshold: options.thresholds
  6853. }
  6854. );
  6855. if (options.observeAll) {
  6856. intersectionObserver.USE_MUTATION_OBSERVER = true;
  6857. const nodeList = $el.querySelectorAll(options.selector);
  6858. for (let i = 0; i < nodeList.length; i++) {
  6859. intersectionObserver.observe(nodeList[i]);
  6860. }
  6861. } else {
  6862. intersectionObserver.USE_MUTATION_OBSERVER = false;
  6863. const el = $el.querySelector(options.selector);
  6864. if (!el) {
  6865. console.warn(
  6866. `Node ${options.selector} is not found. Intersection observer will not trigger.`
  6867. );
  6868. } else {
  6869. intersectionObserver.observe(el);
  6870. }
  6871. }
  6872. return intersectionObserver;
  6873. }
  6874. function addIntersectionObserver({ reqId, component, options, callback }, _pageId) {
  6875. const $el = findElem(component);
  6876. ($el.__io || ($el.__io = {}))[reqId] = requestComponentObserver(
  6877. $el,
  6878. options,
  6879. callback
  6880. );
  6881. }
  6882. function removeIntersectionObserver({ reqId, component }, _pageId) {
  6883. const $el = findElem(component);
  6884. const intersectionObserver = $el.__io && $el.__io[reqId];
  6885. if (intersectionObserver) {
  6886. intersectionObserver.disconnect();
  6887. delete $el.__io[reqId];
  6888. }
  6889. }
  6890. let mediaQueryObservers = {};
  6891. let listeners = {};
  6892. function handleMediaQueryStr($props) {
  6893. const mediaQueryArr = [];
  6894. const propsMenu = [
  6895. "width",
  6896. "minWidth",
  6897. "maxWidth",
  6898. "height",
  6899. "minHeight",
  6900. "maxHeight",
  6901. "orientation"
  6902. ];
  6903. for (const item of propsMenu) {
  6904. if (item !== "orientation" && $props[item] && Number($props[item] >= 0)) {
  6905. mediaQueryArr.push(
  6906. `(${humpToLine(item)}: ${Number(
  6907. $props[item]
  6908. )}px)`
  6909. );
  6910. }
  6911. if (item === "orientation" && $props[item]) {
  6912. mediaQueryArr.push(`(${humpToLine(item)}: ${$props[item]})`);
  6913. }
  6914. }
  6915. const mediaQueryStr = mediaQueryArr.join(" and ");
  6916. return mediaQueryStr;
  6917. }
  6918. function humpToLine(name) {
  6919. return name.replace(/([A-Z])/g, "-$1").toLowerCase();
  6920. }
  6921. function addMediaQueryObserver({ reqId, component, options, callback }, _pageId) {
  6922. const mediaQueryObserver = mediaQueryObservers[reqId] = window.matchMedia(
  6923. handleMediaQueryStr(options)
  6924. );
  6925. const listener2 = listeners[reqId] = (observer) => callback(observer.matches);
  6926. listener2(mediaQueryObserver);
  6927. mediaQueryObserver.addListener(listener2);
  6928. }
  6929. function removeMediaQueryObserver({ reqId, component }, _pageId) {
  6930. const listener2 = listeners[reqId];
  6931. const mediaQueryObserver = mediaQueryObservers[reqId];
  6932. if (mediaQueryObserver) {
  6933. mediaQueryObserver.removeListener(listener2);
  6934. delete listeners[reqId];
  6935. delete mediaQueryObservers[reqId];
  6936. }
  6937. }
  6938. function saveImage(base64, dirname, callback) {
  6939. callback(null, base64);
  6940. }
  6941. const TEMP_PATH = "";
  6942. const files = {};
  6943. function urlToFile(url, local) {
  6944. const file = files[url];
  6945. if (file) {
  6946. return Promise.resolve(file);
  6947. }
  6948. if (/^data:[a-z-]+\/[a-z-]+;base64,/.test(url)) {
  6949. return Promise.resolve(base64ToFile(url));
  6950. }
  6951. if (local) {
  6952. return Promise.reject(new Error("not find"));
  6953. }
  6954. return new Promise((resolve, reject) => {
  6955. const xhr = new XMLHttpRequest();
  6956. xhr.open("GET", url, true);
  6957. xhr.responseType = "blob";
  6958. xhr.onload = function() {
  6959. resolve(this.response);
  6960. };
  6961. xhr.onerror = reject;
  6962. xhr.send();
  6963. });
  6964. }
  6965. function base64ToFile(base64) {
  6966. const base64Array = base64.split(",");
  6967. const res = base64Array[0].match(/:(.*?);/);
  6968. const type = res ? res[1] : "";
  6969. const str = atob(base64Array[1]);
  6970. let n = str.length;
  6971. const array = new Uint8Array(n);
  6972. while (n--) {
  6973. array[n] = str.charCodeAt(n);
  6974. }
  6975. return blobToFile(array, type);
  6976. }
  6977. function getExtname(type) {
  6978. const extname = type.split("/")[1];
  6979. return extname ? `.${extname}` : "";
  6980. }
  6981. function getFileName(url) {
  6982. url = url.split("#")[0].split("?")[0];
  6983. const array = url.split("/");
  6984. return array[array.length - 1];
  6985. }
  6986. function blobToFile(blob, type) {
  6987. let file;
  6988. if (blob instanceof File) {
  6989. file = blob;
  6990. } else {
  6991. type = type || blob.type || "";
  6992. const filename = `${Date.now()}${getExtname(type)}`;
  6993. try {
  6994. file = new File([blob], filename, { type });
  6995. } catch (error) {
  6996. blob = blob instanceof Blob ? blob : new Blob([blob], { type });
  6997. file = blob;
  6998. file.name = file.name || filename;
  6999. }
  7000. }
  7001. return file;
  7002. }
  7003. function fileToUrl(file) {
  7004. for (const key in files) {
  7005. if (hasOwn(files, key)) {
  7006. const oldFile = files[key];
  7007. if (oldFile === file) {
  7008. return key;
  7009. }
  7010. }
  7011. }
  7012. var url = (window.URL || window.webkitURL).createObjectURL(file);
  7013. files[url] = file;
  7014. return url;
  7015. }
  7016. function getSameOriginUrl(url) {
  7017. const a2 = document.createElement("a");
  7018. a2.href = url;
  7019. if (a2.origin === location.origin) {
  7020. return Promise.resolve(url);
  7021. }
  7022. return urlToFile(url).then(fileToUrl);
  7023. }
  7024. function revokeObjectURL(url) {
  7025. const URL = window.URL || window.webkitURL;
  7026. URL.revokeObjectURL(url);
  7027. delete files[url];
  7028. }
  7029. const launchOptions = /* @__PURE__ */ createLaunchOptions();
  7030. const enterOptions = /* @__PURE__ */ createLaunchOptions();
  7031. function getEnterOptions() {
  7032. return extend({}, enterOptions);
  7033. }
  7034. function getLaunchOptions() {
  7035. return extend({}, launchOptions);
  7036. }
  7037. function initLaunchOptions({
  7038. path,
  7039. query
  7040. }) {
  7041. extend(launchOptions, {
  7042. path,
  7043. query
  7044. });
  7045. extend(enterOptions, launchOptions);
  7046. return extend({}, launchOptions);
  7047. }
  7048. const inflateRaw = (...args) => {
  7049. };
  7050. const deflateRaw = (...args) => {
  7051. };
  7052. const ResizeSensor = /* @__PURE__ */ defineBuiltInComponent({
  7053. name: "ResizeSensor",
  7054. props: {
  7055. initial: {
  7056. type: Boolean,
  7057. default: false
  7058. }
  7059. },
  7060. emits: ["resize"],
  7061. setup(props2, {
  7062. emit: emit2
  7063. }) {
  7064. const rootRef = ref(null);
  7065. const reset = useResizeSensorReset(rootRef);
  7066. const update = useResizeSensorUpdate(rootRef, emit2, reset);
  7067. useResizeSensorLifecycle(rootRef, props2, update, reset);
  7068. return () => createVNode("uni-resize-sensor", {
  7069. "ref": rootRef,
  7070. "onAnimationstartOnce": update
  7071. }, [createVNode("div", {
  7072. "onScroll": update
  7073. }, [createVNode("div", null, null)], 40, ["onScroll"]), createVNode("div", {
  7074. "onScroll": update
  7075. }, [createVNode("div", null, null)], 40, ["onScroll"])], 40, ["onAnimationstartOnce"]);
  7076. }
  7077. });
  7078. function useResizeSensorUpdate(rootRef, emit2, reset) {
  7079. const size = reactive({
  7080. width: -1,
  7081. height: -1
  7082. });
  7083. watch(() => extend({}, size), (value) => emit2("resize", value));
  7084. return () => {
  7085. const rootEl = rootRef.value;
  7086. size.width = rootEl.offsetWidth;
  7087. size.height = rootEl.offsetHeight;
  7088. reset();
  7089. };
  7090. }
  7091. function useResizeSensorReset(rootRef) {
  7092. return () => {
  7093. const {
  7094. firstElementChild,
  7095. lastElementChild
  7096. } = rootRef.value;
  7097. firstElementChild.scrollLeft = 1e5;
  7098. firstElementChild.scrollTop = 1e5;
  7099. lastElementChild.scrollLeft = 1e5;
  7100. lastElementChild.scrollTop = 1e5;
  7101. };
  7102. }
  7103. function useResizeSensorLifecycle(rootRef, props2, update, reset) {
  7104. onActivated(reset);
  7105. onMounted(() => {
  7106. if (props2.initial) {
  7107. nextTick(update);
  7108. }
  7109. const rootEl = rootRef.value;
  7110. if (rootEl.offsetParent !== rootEl.parentElement) {
  7111. rootEl.parentElement.style.position = "relative";
  7112. }
  7113. if (!("AnimationEvent" in window)) {
  7114. reset();
  7115. }
  7116. });
  7117. }
  7118. const pixelRatio = /* @__PURE__ */ function() {
  7119. if (navigator.userAgent.includes("jsdom")) {
  7120. return 1;
  7121. }
  7122. const canvas = document.createElement("canvas");
  7123. canvas.height = canvas.width = 0;
  7124. const context = canvas.getContext("2d");
  7125. const backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1;
  7126. return (window.devicePixelRatio || 1) / backingStore;
  7127. }();
  7128. function wrapper(canvas, hidpi = true) {
  7129. const pixel_ratio = hidpi ? pixelRatio : 1;
  7130. canvas.width = canvas.offsetWidth * pixel_ratio;
  7131. canvas.height = canvas.offsetHeight * pixel_ratio;
  7132. canvas.getContext("2d").__hidpi__ = hidpi;
  7133. }
  7134. let isHidpi = false;
  7135. function initHidpi() {
  7136. if (isHidpi) {
  7137. return;
  7138. }
  7139. isHidpi = true;
  7140. const forEach = function(obj, func) {
  7141. for (const key in obj) {
  7142. if (hasOwn(obj, key)) {
  7143. func(obj[key], key);
  7144. }
  7145. }
  7146. };
  7147. const ratioArgs = {
  7148. fillRect: "all",
  7149. clearRect: "all",
  7150. strokeRect: "all",
  7151. moveTo: "all",
  7152. lineTo: "all",
  7153. arc: [0, 1, 2],
  7154. arcTo: "all",
  7155. bezierCurveTo: "all",
  7156. isPointinPath: "all",
  7157. isPointinStroke: "all",
  7158. quadraticCurveTo: "all",
  7159. rect: "all",
  7160. translate: "all",
  7161. createRadialGradient: "all",
  7162. createLinearGradient: "all",
  7163. transform: [4, 5],
  7164. setTransform: [4, 5]
  7165. };
  7166. const proto = CanvasRenderingContext2D.prototype;
  7167. proto.drawImageByCanvas = function(_super) {
  7168. return function(canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh, isScale) {
  7169. if (!this.__hidpi__) {
  7170. return _super.apply(this, arguments);
  7171. }
  7172. srcx *= pixelRatio;
  7173. srcy *= pixelRatio;
  7174. srcw *= pixelRatio;
  7175. srch *= pixelRatio;
  7176. desx *= pixelRatio;
  7177. desy *= pixelRatio;
  7178. desw = isScale ? desw * pixelRatio : desw;
  7179. desh = isScale ? desh * pixelRatio : desh;
  7180. _super.call(this, canvas, srcx, srcy, srcw, srch, desx, desy, desw, desh);
  7181. };
  7182. }(proto.drawImage);
  7183. if (pixelRatio !== 1) {
  7184. forEach(ratioArgs, function(value, key) {
  7185. proto[key] = function(_super) {
  7186. return function() {
  7187. if (!this.__hidpi__) {
  7188. return _super.apply(this, arguments);
  7189. }
  7190. let args = Array.prototype.slice.call(arguments);
  7191. if (value === "all") {
  7192. args = args.map(function(a2) {
  7193. return a2 * pixelRatio;
  7194. });
  7195. } else if (Array.isArray(value)) {
  7196. for (let i = 0; i < value.length; i++) {
  7197. args[value[i]] *= pixelRatio;
  7198. }
  7199. }
  7200. return _super.apply(this, args);
  7201. };
  7202. }(proto[key]);
  7203. });
  7204. proto.stroke = function(_super) {
  7205. return function() {
  7206. if (!this.__hidpi__) {
  7207. return _super.apply(this, arguments);
  7208. }
  7209. this.lineWidth *= pixelRatio;
  7210. _super.apply(this, arguments);
  7211. this.lineWidth /= pixelRatio;
  7212. };
  7213. }(proto.stroke);
  7214. proto.fillText = function(_super) {
  7215. return function() {
  7216. if (!this.__hidpi__) {
  7217. return _super.apply(this, arguments);
  7218. }
  7219. const args = Array.prototype.slice.call(arguments);
  7220. args[1] *= pixelRatio;
  7221. args[2] *= pixelRatio;
  7222. if (args[3] && typeof args[3] === "number") {
  7223. args[3] *= pixelRatio;
  7224. }
  7225. var font2 = this.font;
  7226. this.font = font2.replace(
  7227. /(\d+\.?\d*)(px|em|rem|pt)/g,
  7228. function(w, m, u) {
  7229. return m * pixelRatio + u;
  7230. }
  7231. );
  7232. _super.apply(this, args);
  7233. this.font = font2;
  7234. };
  7235. }(proto.fillText);
  7236. proto.strokeText = function(_super) {
  7237. return function() {
  7238. if (!this.__hidpi__) {
  7239. return _super.apply(this, arguments);
  7240. }
  7241. var args = Array.prototype.slice.call(arguments);
  7242. args[1] *= pixelRatio;
  7243. args[2] *= pixelRatio;
  7244. if (args[3] && typeof args[3] === "number") {
  7245. args[3] *= pixelRatio;
  7246. }
  7247. var font2 = this.font;
  7248. this.font = font2.replace(
  7249. /(\d+\.?\d*)(px|em|rem|pt)/g,
  7250. function(w, m, u) {
  7251. return m * pixelRatio + u;
  7252. }
  7253. );
  7254. _super.apply(this, args);
  7255. this.font = font2;
  7256. };
  7257. }(proto.strokeText);
  7258. proto.drawImage = function(_super) {
  7259. return function() {
  7260. if (!this.__hidpi__) {
  7261. return _super.apply(this, arguments);
  7262. }
  7263. this.scale(pixelRatio, pixelRatio);
  7264. _super.apply(this, arguments);
  7265. this.scale(1 / pixelRatio, 1 / pixelRatio);
  7266. };
  7267. }(proto.drawImage);
  7268. }
  7269. }
  7270. const initHidpiOnce = /* @__PURE__ */ once(() => {
  7271. return initHidpi();
  7272. });
  7273. function $getRealPath(src) {
  7274. return src ? getRealPath(src) : src;
  7275. }
  7276. function resolveColor(color) {
  7277. color = color.slice(0);
  7278. color[3] = color[3] / 255;
  7279. return "rgba(" + color.join(",") + ")";
  7280. }
  7281. function processTouches(rect, touches) {
  7282. Array.from(touches).forEach((touch) => {
  7283. touch.x = touch.clientX - rect.left;
  7284. touch.y = touch.clientY - rect.top;
  7285. });
  7286. }
  7287. let tempCanvas;
  7288. function getTempCanvas(width = 0, height = 0) {
  7289. if (!tempCanvas) {
  7290. tempCanvas = document.createElement("canvas");
  7291. }
  7292. tempCanvas.width = width;
  7293. tempCanvas.height = height;
  7294. return tempCanvas;
  7295. }
  7296. const props$x = {
  7297. canvasId: {
  7298. type: String,
  7299. default: ""
  7300. },
  7301. disableScroll: {
  7302. type: [Boolean, String],
  7303. default: false
  7304. },
  7305. hidpi: {
  7306. type: Boolean,
  7307. default: true
  7308. }
  7309. };
  7310. const index$v = /* @__PURE__ */ defineBuiltInComponent({
  7311. inheritAttrs: false,
  7312. name: "Canvas",
  7313. compatConfig: {
  7314. MODE: 3
  7315. },
  7316. props: props$x,
  7317. computed: {
  7318. id() {
  7319. return this.canvasId;
  7320. }
  7321. },
  7322. setup(props2, {
  7323. emit: emit2,
  7324. slots
  7325. }) {
  7326. initHidpiOnce();
  7327. const rootRef = ref(null);
  7328. const canvas = ref(null);
  7329. const sensor = ref(null);
  7330. const actionsWaiting = ref(false);
  7331. const trigger = useNativeEvent(emit2);
  7332. const {
  7333. $attrs,
  7334. $excludeAttrs,
  7335. $listeners
  7336. } = useAttrs({
  7337. excludeListeners: true
  7338. });
  7339. const {
  7340. _listeners
  7341. } = useListeners(props2, $listeners, trigger);
  7342. const {
  7343. _handleSubscribe,
  7344. _resize
  7345. } = useMethods(props2, canvas, actionsWaiting);
  7346. useSubscribe(_handleSubscribe, useContextInfo(props2.canvasId), true);
  7347. onMounted(() => {
  7348. _resize();
  7349. });
  7350. return () => {
  7351. const {
  7352. canvasId,
  7353. disableScroll
  7354. } = props2;
  7355. return createVNode("uni-canvas", mergeProps({
  7356. "ref": rootRef,
  7357. "canvas-id": canvasId,
  7358. "disable-scroll": disableScroll
  7359. }, $attrs.value, $excludeAttrs.value, _listeners.value), [createVNode("canvas", {
  7360. "ref": canvas,
  7361. "class": "uni-canvas-canvas",
  7362. "width": "300",
  7363. "height": "150"
  7364. }, null, 512), createVNode("div", {
  7365. "style": "position: absolute;top: 0;left: 0;width: 100%;height: 100%;overflow: hidden;"
  7366. }, [slots.default && slots.default()]), createVNode(ResizeSensor, {
  7367. "ref": sensor,
  7368. "onResize": _resize
  7369. }, null, 8, ["onResize"])], 16, ["canvas-id", "disable-scroll"]);
  7370. };
  7371. }
  7372. });
  7373. function useListeners(props2, Listeners, trigger) {
  7374. const _listeners = computed(() => {
  7375. let events = ["onTouchstart", "onTouchmove", "onTouchend"];
  7376. let _$listeners = Listeners.value;
  7377. let $listeners = extend({}, (() => {
  7378. let obj = {};
  7379. for (const key in _$listeners) {
  7380. if (hasOwn(_$listeners, key)) {
  7381. const event = _$listeners[key];
  7382. obj[key] = event;
  7383. }
  7384. }
  7385. return obj;
  7386. })());
  7387. events.forEach((event) => {
  7388. let existing = $listeners[event];
  7389. let eventHandler = [];
  7390. if (existing) {
  7391. eventHandler.push(withWebEvent(($event) => {
  7392. const rect = $event.currentTarget.getBoundingClientRect();
  7393. processTouches(rect, $event.touches);
  7394. processTouches(rect, $event.changedTouches);
  7395. trigger(event.replace("on", "").toLocaleLowerCase(), $event);
  7396. }));
  7397. }
  7398. if (props2.disableScroll && event === "onTouchmove") {
  7399. eventHandler.push(onEventPrevent);
  7400. }
  7401. $listeners[event] = eventHandler;
  7402. });
  7403. return $listeners;
  7404. });
  7405. return {
  7406. _listeners
  7407. };
  7408. }
  7409. function useMethods(props2, canvasRef, actionsWaiting) {
  7410. let _actionsDefer = [];
  7411. let _images = {};
  7412. const _pixelRatio = computed(() => props2.hidpi ? pixelRatio : 1);
  7413. function _resize(size) {
  7414. let canvas = canvasRef.value;
  7415. var hasChanged = !size || canvas.width !== Math.floor(size.width * _pixelRatio.value) || canvas.height !== Math.floor(size.height * _pixelRatio.value);
  7416. if (!hasChanged)
  7417. return;
  7418. if (canvas.width > 0 && canvas.height > 0) {
  7419. let context = canvas.getContext("2d");
  7420. let imageData = context.getImageData(0, 0, canvas.width, canvas.height);
  7421. wrapper(canvas, props2.hidpi);
  7422. context.putImageData(imageData, 0, 0);
  7423. } else {
  7424. wrapper(canvas, props2.hidpi);
  7425. }
  7426. }
  7427. function actionsChanged({
  7428. actions,
  7429. reserve
  7430. }, resolve) {
  7431. if (!actions) {
  7432. return;
  7433. }
  7434. if (actionsWaiting.value) {
  7435. _actionsDefer.push([actions, reserve]);
  7436. return;
  7437. }
  7438. let canvas = canvasRef.value;
  7439. let c2d = canvas.getContext("2d");
  7440. if (!reserve) {
  7441. c2d.fillStyle = "#000000";
  7442. c2d.strokeStyle = "#000000";
  7443. c2d.shadowColor = "#000000";
  7444. c2d.shadowBlur = 0;
  7445. c2d.shadowOffsetX = 0;
  7446. c2d.shadowOffsetY = 0;
  7447. c2d.setTransform(1, 0, 0, 1, 0, 0);
  7448. c2d.clearRect(0, 0, canvas.width, canvas.height);
  7449. }
  7450. preloadImage(actions);
  7451. for (let index2 = 0; index2 < actions.length; index2++) {
  7452. const action = actions[index2];
  7453. let method = action.method;
  7454. const data = action.data;
  7455. const actionType = data[0];
  7456. if (/^set/.test(method) && method !== "setTransform") {
  7457. const method1 = method[3].toLowerCase() + method.slice(4);
  7458. let color;
  7459. if (method1 === "fillStyle" || method1 === "strokeStyle") {
  7460. if (actionType === "normal") {
  7461. color = resolveColor(data[1]);
  7462. } else if (actionType === "linear") {
  7463. const LinearGradient = c2d.createLinearGradient(...data[1]);
  7464. data[2].forEach(function(data2) {
  7465. const offset = data2[0];
  7466. const color2 = resolveColor(data2[1]);
  7467. LinearGradient.addColorStop(offset, color2);
  7468. });
  7469. color = LinearGradient;
  7470. } else if (actionType === "radial") {
  7471. let _data = data[1];
  7472. const x = _data[0];
  7473. const y = _data[1];
  7474. const r = _data[2];
  7475. const LinearGradient = c2d.createRadialGradient(x, y, 0, x, y, r);
  7476. data[2].forEach(function(data2) {
  7477. const offset = data2[0];
  7478. const color2 = resolveColor(data2[1]);
  7479. LinearGradient.addColorStop(offset, color2);
  7480. });
  7481. color = LinearGradient;
  7482. } else if (actionType === "pattern") {
  7483. const loaded = checkImageLoaded(data[1], actions.slice(index2 + 1), resolve, function(image2) {
  7484. if (image2) {
  7485. c2d[method1] = c2d.createPattern(image2, data[2]);
  7486. }
  7487. });
  7488. if (!loaded) {
  7489. break;
  7490. }
  7491. continue;
  7492. }
  7493. c2d[method1] = color;
  7494. } else if (method1 === "globalAlpha") {
  7495. c2d[method1] = Number(actionType) / 255;
  7496. } else if (method1 === "shadow") {
  7497. let shadowArray = ["shadowOffsetX", "shadowOffsetY", "shadowBlur", "shadowColor"];
  7498. data.forEach(function(color_, method_) {
  7499. c2d[shadowArray[method_]] = shadowArray[method_] === "shadowColor" ? resolveColor(color_) : color_;
  7500. });
  7501. } else if (method1 === "fontSize") {
  7502. const font2 = c2d.__font__ || c2d.font;
  7503. c2d.__font__ = c2d.font = font2.replace(/\d+\.?\d*px/, actionType + "px");
  7504. } else if (method1 === "lineDash") {
  7505. c2d.setLineDash(actionType);
  7506. c2d.lineDashOffset = data[1] || 0;
  7507. } else if (method1 === "textBaseline") {
  7508. if (actionType === "normal") {
  7509. data[0] = "alphabetic";
  7510. }
  7511. c2d[method1] = actionType;
  7512. } else if (method1 === "font") {
  7513. c2d.__font__ = c2d.font = actionType;
  7514. } else {
  7515. c2d[method1] = actionType;
  7516. }
  7517. } else if (method === "fillPath" || method === "strokePath") {
  7518. method = method.replace(/Path/, "");
  7519. c2d.beginPath();
  7520. data.forEach(function(data_) {
  7521. c2d[data_.method].apply(c2d, data_.data);
  7522. });
  7523. c2d[method]();
  7524. } else if (method === "fillText") {
  7525. c2d.fillText.apply(c2d, data);
  7526. } else if (method === "drawImage") {
  7527. let drawImage = function() {
  7528. let dataArray = [...data];
  7529. let url = dataArray[0];
  7530. let otherData = dataArray.slice(1);
  7531. _images = _images || {};
  7532. if (!checkImageLoaded(url, actions.slice(index2 + 1), resolve, function(image2) {
  7533. if (image2) {
  7534. c2d.drawImage.apply(
  7535. c2d,
  7536. // @ts-ignore
  7537. [image2].concat(
  7538. // @ts-ignore
  7539. [...otherData.slice(4, 8)],
  7540. [...otherData.slice(0, 4)]
  7541. )
  7542. );
  7543. }
  7544. }))
  7545. return "break";
  7546. }();
  7547. if (drawImage === "break") {
  7548. break;
  7549. }
  7550. } else {
  7551. if (method === "clip") {
  7552. data.forEach(function(data_) {
  7553. c2d[data_.method].apply(c2d, data_.data);
  7554. });
  7555. c2d.clip();
  7556. } else {
  7557. c2d[method].apply(c2d, data);
  7558. }
  7559. }
  7560. }
  7561. if (!actionsWaiting.value) {
  7562. resolve({
  7563. errMsg: "drawCanvas:ok"
  7564. });
  7565. }
  7566. }
  7567. function preloadImage(actions) {
  7568. actions.forEach(function(action) {
  7569. let method = action.method;
  7570. let data = action.data;
  7571. let src = "";
  7572. if (method === "drawImage") {
  7573. src = data[0];
  7574. src = $getRealPath(src);
  7575. data[0] = src;
  7576. } else if (method === "setFillStyle" && data[0] === "pattern") {
  7577. src = data[1];
  7578. src = $getRealPath(src);
  7579. data[1] = src;
  7580. }
  7581. if (src && !_images[src]) {
  7582. loadImage();
  7583. }
  7584. function loadImage() {
  7585. const image2 = _images[src] = new Image();
  7586. image2.onload = function() {
  7587. image2.ready = true;
  7588. };
  7589. getSameOriginUrl(src).then((src2) => {
  7590. image2.src = src2;
  7591. }).catch(() => {
  7592. image2.src = src;
  7593. });
  7594. }
  7595. });
  7596. }
  7597. function checkImageLoaded(src, actions, resolve, fn) {
  7598. let image2 = _images[src];
  7599. if (image2.ready) {
  7600. fn(image2);
  7601. return true;
  7602. } else {
  7603. _actionsDefer.unshift([actions, true]);
  7604. actionsWaiting.value = true;
  7605. image2.onload = function() {
  7606. image2.ready = true;
  7607. fn(image2);
  7608. actionsWaiting.value = false;
  7609. let actions2 = _actionsDefer.slice(0);
  7610. _actionsDefer = [];
  7611. for (let action = actions2.shift(); action; ) {
  7612. actionsChanged({
  7613. actions: action[0],
  7614. reserve: action[1]
  7615. }, resolve);
  7616. action = actions2.shift();
  7617. }
  7618. };
  7619. return false;
  7620. }
  7621. }
  7622. function getImageData({
  7623. x = 0,
  7624. y = 0,
  7625. width,
  7626. height,
  7627. destWidth,
  7628. destHeight,
  7629. hidpi = true,
  7630. dataType: dataType2,
  7631. quality = 1,
  7632. type = "png"
  7633. }, resolve) {
  7634. const canvas = canvasRef.value;
  7635. let data;
  7636. const maxWidth2 = canvas.offsetWidth - x;
  7637. width = width ? Math.min(width, maxWidth2) : maxWidth2;
  7638. const maxHeight = canvas.offsetHeight - y;
  7639. height = height ? Math.min(height, maxHeight) : maxHeight;
  7640. if (!hidpi) {
  7641. if (!destWidth && !destHeight) {
  7642. destWidth = Math.round(width * _pixelRatio.value);
  7643. destHeight = Math.round(height * _pixelRatio.value);
  7644. } else if (!destWidth) {
  7645. destWidth = Math.round(width / height * destHeight);
  7646. } else if (!destHeight) {
  7647. destHeight = Math.round(height / width * destWidth);
  7648. }
  7649. } else {
  7650. destWidth = width;
  7651. destHeight = height;
  7652. }
  7653. const newCanvas = getTempCanvas(destWidth, destHeight);
  7654. const context = newCanvas.getContext("2d");
  7655. if (type === "jpeg" || type === "jpg") {
  7656. type = "jpeg";
  7657. context.fillStyle = "#fff";
  7658. context.fillRect(0, 0, destWidth, destHeight);
  7659. }
  7660. context.__hidpi__ = true;
  7661. context.drawImageByCanvas(canvas, x, y, width, height, 0, 0, destWidth, destHeight, false);
  7662. let result;
  7663. try {
  7664. let compressed;
  7665. if (dataType2 === "base64") {
  7666. data = newCanvas.toDataURL(`image/${type}`, quality);
  7667. } else {
  7668. const imgData = context.getImageData(0, 0, destWidth, destHeight);
  7669. if (false)
  7670. ;
  7671. else {
  7672. data = Array.prototype.slice.call(imgData.data);
  7673. }
  7674. }
  7675. result = {
  7676. data,
  7677. compressed,
  7678. width: destWidth,
  7679. height: destHeight
  7680. };
  7681. } catch (error) {
  7682. result = {
  7683. errMsg: `canvasGetImageData:fail ${error}`
  7684. };
  7685. }
  7686. newCanvas.height = newCanvas.width = 0;
  7687. context.__hidpi__ = false;
  7688. if (!resolve) {
  7689. return result;
  7690. } else {
  7691. resolve(result);
  7692. }
  7693. }
  7694. function putImageData({
  7695. data,
  7696. x,
  7697. y,
  7698. width,
  7699. height,
  7700. compressed
  7701. }, resolve) {
  7702. try {
  7703. if (false)
  7704. ;
  7705. if (!height) {
  7706. height = Math.round(data.length / 4 / width);
  7707. }
  7708. const canvas = getTempCanvas(width, height);
  7709. const context = canvas.getContext("2d");
  7710. context.putImageData(new ImageData(new Uint8ClampedArray(data), width, height), 0, 0);
  7711. canvasRef.value.getContext("2d").drawImage(canvas, x, y, width, height);
  7712. canvas.height = canvas.width = 0;
  7713. } catch (error) {
  7714. resolve({
  7715. errMsg: "canvasPutImageData:fail"
  7716. });
  7717. return;
  7718. }
  7719. resolve({
  7720. errMsg: "canvasPutImageData:ok"
  7721. });
  7722. }
  7723. function toTempFilePath({
  7724. x = 0,
  7725. y = 0,
  7726. width,
  7727. height,
  7728. destWidth,
  7729. destHeight,
  7730. fileType,
  7731. quality,
  7732. dirname
  7733. }, resolve) {
  7734. const res = getImageData({
  7735. x,
  7736. y,
  7737. width,
  7738. height,
  7739. destWidth,
  7740. destHeight,
  7741. hidpi: false,
  7742. dataType: "base64",
  7743. type: fileType,
  7744. quality
  7745. });
  7746. if (!res.data || !res.data.length) {
  7747. resolve({
  7748. errMsg: res.errMsg.replace("canvasPutImageData", "toTempFilePath")
  7749. });
  7750. return;
  7751. }
  7752. saveImage(res.data, dirname, (error, tempFilePath) => {
  7753. let errMsg = `toTempFilePath:${error ? "fail" : "ok"}`;
  7754. if (error) {
  7755. errMsg += ` ${error.message}`;
  7756. }
  7757. resolve({
  7758. errMsg,
  7759. tempFilePath
  7760. });
  7761. });
  7762. }
  7763. const methods = {
  7764. actionsChanged,
  7765. getImageData,
  7766. putImageData,
  7767. toTempFilePath
  7768. };
  7769. function _handleSubscribe(type, data, resolve) {
  7770. let method = methods[type];
  7771. if (type.indexOf("_") !== 0 && isFunction(method)) {
  7772. method(data, resolve);
  7773. }
  7774. }
  7775. return extend(methods, {
  7776. _resize,
  7777. _handleSubscribe
  7778. });
  7779. }
  7780. const uniCheckGroupKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniCheckGroup" : "ucg");
  7781. const props$w = {
  7782. name: {
  7783. type: String,
  7784. default: ""
  7785. }
  7786. };
  7787. const index$u = /* @__PURE__ */ defineBuiltInComponent({
  7788. name: "CheckboxGroup",
  7789. props: props$w,
  7790. emits: ["change"],
  7791. setup(props2, {
  7792. emit: emit2,
  7793. slots
  7794. }) {
  7795. const rootRef = ref(null);
  7796. const trigger = useCustomEvent(rootRef, emit2);
  7797. useProvideCheckGroup(props2, trigger);
  7798. return () => {
  7799. return createVNode("uni-checkbox-group", {
  7800. "ref": rootRef
  7801. }, [slots.default && slots.default()], 512);
  7802. };
  7803. }
  7804. });
  7805. function useProvideCheckGroup(props2, trigger) {
  7806. const fields2 = [];
  7807. const getFieldsValue = () => fields2.reduce((res, field) => {
  7808. if (field.value.checkboxChecked) {
  7809. res.push(field.value.value);
  7810. }
  7811. return res;
  7812. }, new Array());
  7813. provide(uniCheckGroupKey, {
  7814. addField(field) {
  7815. fields2.push(field);
  7816. },
  7817. removeField(field) {
  7818. fields2.splice(fields2.indexOf(field), 1);
  7819. },
  7820. checkboxChange($event) {
  7821. trigger("change", $event, {
  7822. value: getFieldsValue()
  7823. });
  7824. }
  7825. });
  7826. const uniForm = inject(uniFormKey, false);
  7827. if (uniForm) {
  7828. uniForm.addField({
  7829. submit: () => {
  7830. let data = ["", null];
  7831. if (props2.name !== "") {
  7832. data[0] = props2.name;
  7833. data[1] = getFieldsValue();
  7834. }
  7835. return data;
  7836. }
  7837. });
  7838. }
  7839. return getFieldsValue;
  7840. }
  7841. const props$v = {
  7842. checked: {
  7843. type: [Boolean, String],
  7844. default: false
  7845. },
  7846. id: {
  7847. type: String,
  7848. default: ""
  7849. },
  7850. disabled: {
  7851. type: [Boolean, String],
  7852. default: false
  7853. },
  7854. value: {
  7855. type: String,
  7856. default: ""
  7857. },
  7858. color: {
  7859. type: String,
  7860. default: "#007aff"
  7861. },
  7862. backgroundColor: {
  7863. type: String,
  7864. default: ""
  7865. },
  7866. borderColor: {
  7867. type: String,
  7868. default: ""
  7869. },
  7870. activeBackgroundColor: {
  7871. type: String,
  7872. default: ""
  7873. },
  7874. activeBorderColor: {
  7875. type: String,
  7876. default: ""
  7877. },
  7878. iconColor: {
  7879. type: String,
  7880. default: ""
  7881. }
  7882. };
  7883. const index$t = /* @__PURE__ */ defineBuiltInComponent({
  7884. name: "Checkbox",
  7885. props: props$v,
  7886. setup(props2, {
  7887. slots
  7888. }) {
  7889. const rootRef = ref(null);
  7890. const checkboxChecked = ref(props2.checked);
  7891. const checkboxCheckedBool = computed(() => {
  7892. return checkboxChecked.value === "true" || checkboxChecked.value === true;
  7893. });
  7894. const checkboxValue = ref(props2.value);
  7895. function getCheckBoxStyle(checked) {
  7896. if (props2.disabled) {
  7897. return {
  7898. backgroundColor: "#E1E1E1",
  7899. borderColor: "#D1D1D1"
  7900. };
  7901. }
  7902. const style = {};
  7903. if (checked) {
  7904. if (props2.activeBorderColor)
  7905. style.borderColor = props2.activeBorderColor;
  7906. if (props2.activeBackgroundColor)
  7907. style.backgroundColor = props2.activeBackgroundColor;
  7908. } else {
  7909. if (props2.borderColor)
  7910. style.borderColor = props2.borderColor;
  7911. if (props2.backgroundColor)
  7912. style.backgroundColor = props2.backgroundColor;
  7913. }
  7914. return style;
  7915. }
  7916. const checkboxStyle = computed(() => {
  7917. return getCheckBoxStyle(checkboxCheckedBool.value);
  7918. });
  7919. watch([() => props2.checked, () => props2.value], ([newChecked, newModelValue]) => {
  7920. checkboxChecked.value = newChecked;
  7921. checkboxValue.value = newModelValue;
  7922. });
  7923. const reset = () => {
  7924. checkboxChecked.value = false;
  7925. };
  7926. const {
  7927. uniCheckGroup,
  7928. uniLabel
  7929. } = useCheckboxInject(checkboxChecked, checkboxValue, reset);
  7930. const _onClick = ($event) => {
  7931. if (props2.disabled) {
  7932. return;
  7933. }
  7934. checkboxChecked.value = !checkboxChecked.value;
  7935. uniCheckGroup && uniCheckGroup.checkboxChange($event);
  7936. $event.stopPropagation();
  7937. };
  7938. if (!!uniLabel) {
  7939. uniLabel.addHandler(_onClick);
  7940. onBeforeUnmount(() => {
  7941. uniLabel.removeHandler(_onClick);
  7942. });
  7943. }
  7944. useListeners$1(props2, {
  7945. "label-click": _onClick
  7946. });
  7947. return () => {
  7948. const booleanAttrs = useBooleanAttr(props2, "disabled");
  7949. let realCheckValue;
  7950. realCheckValue = checkboxChecked.value;
  7951. return createVNode("uni-checkbox", mergeProps(booleanAttrs, {
  7952. "id": props2.id,
  7953. "onClick": _onClick,
  7954. "ref": rootRef
  7955. }), [createVNode("div", {
  7956. "class": "uni-checkbox-wrapper",
  7957. "style": {
  7958. "--HOVER-BD-COLOR": props2.activeBorderColor
  7959. }
  7960. }, [createVNode("div", {
  7961. "class": ["uni-checkbox-input", {
  7962. "uni-checkbox-input-disabled": props2.disabled
  7963. }],
  7964. "style": checkboxStyle.value
  7965. }, [realCheckValue ? createSvgIconVNode(ICON_PATH_SUCCESS_NO_CIRCLE, props2.disabled ? "#ADADAD" : props2.iconColor || props2.color, 22) : ""], 6), slots.default && slots.default()], 4)], 16, ["id", "onClick"]);
  7966. };
  7967. }
  7968. });
  7969. function useCheckboxInject(checkboxChecked, checkboxValue, reset) {
  7970. const field = computed(() => ({
  7971. checkboxChecked: Boolean(checkboxChecked.value),
  7972. value: checkboxValue.value
  7973. }));
  7974. const formField = {
  7975. reset
  7976. };
  7977. const uniCheckGroup = inject(uniCheckGroupKey, false);
  7978. if (!!uniCheckGroup) {
  7979. uniCheckGroup.addField(field);
  7980. }
  7981. const uniForm = inject(uniFormKey, false);
  7982. if (!!uniForm) {
  7983. uniForm.addField(formField);
  7984. }
  7985. const uniLabel = inject(uniLabelKey, false);
  7986. onBeforeUnmount(() => {
  7987. uniCheckGroup && uniCheckGroup.removeField(field);
  7988. uniForm && uniForm.removeField(formField);
  7989. });
  7990. return {
  7991. uniCheckGroup,
  7992. uniForm,
  7993. uniLabel
  7994. };
  7995. }
  7996. let resetTimer;
  7997. function iosHideKeyboard() {
  7998. }
  7999. const props$u = {
  8000. cursorSpacing: {
  8001. type: [Number, String],
  8002. default: 0
  8003. },
  8004. showConfirmBar: {
  8005. type: [Boolean, String],
  8006. default: "auto"
  8007. },
  8008. adjustPosition: {
  8009. type: [Boolean, String],
  8010. default: true
  8011. },
  8012. autoBlur: {
  8013. type: [Boolean, String],
  8014. default: false
  8015. }
  8016. };
  8017. const emit$1 = ["keyboardheightchange"];
  8018. function useKeyboard$1(props2, elRef, trigger) {
  8019. function initKeyboard(el) {
  8020. const isApple = computed(
  8021. () => String(navigator.vendor).indexOf("Apple") === 0
  8022. );
  8023. el.addEventListener("focus", () => {
  8024. clearTimeout(resetTimer);
  8025. document.addEventListener("click", iosHideKeyboard, false);
  8026. });
  8027. const onKeyboardHide = () => {
  8028. document.removeEventListener("click", iosHideKeyboard, false);
  8029. if (isApple.value) {
  8030. document.documentElement.scrollTo(
  8031. document.documentElement.scrollLeft,
  8032. document.documentElement.scrollTop
  8033. );
  8034. }
  8035. };
  8036. el.addEventListener("blur", () => {
  8037. if (isApple.value) {
  8038. el.blur();
  8039. }
  8040. onKeyboardHide();
  8041. });
  8042. }
  8043. watch(
  8044. () => elRef.value,
  8045. (el) => el && initKeyboard(el)
  8046. );
  8047. }
  8048. var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/;
  8049. var endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/;
  8050. var attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
  8051. var empty = /* @__PURE__ */ makeMap(
  8052. "area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr"
  8053. );
  8054. var block = /* @__PURE__ */ makeMap(
  8055. "a,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video"
  8056. );
  8057. var inline = /* @__PURE__ */ makeMap(
  8058. "abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var"
  8059. );
  8060. var closeSelf = /* @__PURE__ */ makeMap(
  8061. "colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"
  8062. );
  8063. var fillAttrs = /* @__PURE__ */ makeMap(
  8064. "checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"
  8065. );
  8066. var special = /* @__PURE__ */ makeMap("script,style");
  8067. function HTMLParser(html, handler) {
  8068. var index2;
  8069. var chars2;
  8070. var match;
  8071. var stack = [];
  8072. var last = html;
  8073. stack.last = function() {
  8074. return this[this.length - 1];
  8075. };
  8076. while (html) {
  8077. chars2 = true;
  8078. if (!stack.last() || !special[stack.last()]) {
  8079. if (html.indexOf("<!--") == 0) {
  8080. index2 = html.indexOf("-->");
  8081. if (index2 >= 0) {
  8082. if (handler.comment) {
  8083. handler.comment(html.substring(4, index2));
  8084. }
  8085. html = html.substring(index2 + 3);
  8086. chars2 = false;
  8087. }
  8088. } else if (html.indexOf("</") == 0) {
  8089. match = html.match(endTag);
  8090. if (match) {
  8091. html = html.substring(match[0].length);
  8092. match[0].replace(endTag, parseEndTag);
  8093. chars2 = false;
  8094. }
  8095. } else if (html.indexOf("<") == 0) {
  8096. match = html.match(startTag);
  8097. if (match) {
  8098. html = html.substring(match[0].length);
  8099. match[0].replace(startTag, parseStartTag);
  8100. chars2 = false;
  8101. }
  8102. }
  8103. if (chars2) {
  8104. index2 = html.indexOf("<");
  8105. var text2 = index2 < 0 ? html : html.substring(0, index2);
  8106. html = index2 < 0 ? "" : html.substring(index2);
  8107. if (handler.chars) {
  8108. handler.chars(text2);
  8109. }
  8110. }
  8111. } else {
  8112. html = html.replace(
  8113. new RegExp("([\\s\\S]*?)</" + stack.last() + "[^>]*>"),
  8114. function(all, text3) {
  8115. text3 = text3.replace(
  8116. /<!--([\s\S]*?)-->|<!\[CDATA\[([\s\S]*?)]]>/g,
  8117. "$1$2"
  8118. );
  8119. if (handler.chars) {
  8120. handler.chars(text3);
  8121. }
  8122. return "";
  8123. }
  8124. );
  8125. parseEndTag("", stack.last());
  8126. }
  8127. if (html == last) {
  8128. throw "Parse Error: " + html;
  8129. }
  8130. last = html;
  8131. }
  8132. parseEndTag();
  8133. function parseStartTag(tag, tagName, rest, unary) {
  8134. tagName = tagName.toLowerCase();
  8135. if (block[tagName]) {
  8136. while (stack.last() && inline[stack.last()]) {
  8137. parseEndTag("", stack.last());
  8138. }
  8139. }
  8140. if (closeSelf[tagName] && stack.last() == tagName) {
  8141. parseEndTag("", tagName);
  8142. }
  8143. unary = empty[tagName] || !!unary;
  8144. if (!unary) {
  8145. stack.push(tagName);
  8146. }
  8147. if (handler.start) {
  8148. var attrs2 = [];
  8149. rest.replace(attr, function(match2, name) {
  8150. var value = arguments[2] ? arguments[2] : arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : fillAttrs[name] ? name : "";
  8151. attrs2.push({
  8152. name,
  8153. value,
  8154. escaped: value.replace(/(^|[^\\])"/g, '$1\\"')
  8155. // "
  8156. });
  8157. });
  8158. if (handler.start) {
  8159. handler.start(tagName, attrs2, unary);
  8160. }
  8161. }
  8162. }
  8163. function parseEndTag(tag, tagName) {
  8164. if (!tagName) {
  8165. var pos = 0;
  8166. } else {
  8167. for (var pos = stack.length - 1; pos >= 0; pos--) {
  8168. if (stack[pos] == tagName) {
  8169. break;
  8170. }
  8171. }
  8172. }
  8173. if (pos >= 0) {
  8174. for (var i = stack.length - 1; i >= pos; i--) {
  8175. if (handler.end) {
  8176. handler.end(stack[i]);
  8177. }
  8178. }
  8179. stack.length = pos;
  8180. }
  8181. }
  8182. }
  8183. function makeMap(str) {
  8184. var obj = {};
  8185. var items = str.split(",");
  8186. for (var i = 0; i < items.length; i++) {
  8187. obj[items[i]] = true;
  8188. }
  8189. return obj;
  8190. }
  8191. const scripts = {};
  8192. function loadScript(globalName, src, callback) {
  8193. const globalObject = isString(globalName) ? window[globalName] : globalName;
  8194. if (globalObject) {
  8195. callback();
  8196. return;
  8197. }
  8198. let callbacks2 = scripts[src];
  8199. if (!callbacks2) {
  8200. callbacks2 = scripts[src] = [];
  8201. const script = document.createElement("script");
  8202. script.src = src;
  8203. document.body.appendChild(script);
  8204. script.onload = function() {
  8205. callbacks2.forEach((callback2) => callback2());
  8206. delete scripts[src];
  8207. };
  8208. }
  8209. callbacks2.push(callback);
  8210. }
  8211. function divider(Quill) {
  8212. const BlockEmbed = Quill.import("blots/block/embed");
  8213. class Divider extends BlockEmbed {
  8214. }
  8215. Divider.blotName = "divider";
  8216. Divider.tagName = "HR";
  8217. return {
  8218. "formats/divider": Divider
  8219. };
  8220. }
  8221. function ins(Quill) {
  8222. const Inline = Quill.import("blots/inline");
  8223. class Ins extends Inline {
  8224. }
  8225. Ins.blotName = "ins";
  8226. Ins.tagName = "INS";
  8227. return {
  8228. "formats/ins": Ins
  8229. };
  8230. }
  8231. function align(Quill) {
  8232. const { Scope, Attributor } = Quill.import("parchment");
  8233. const config = {
  8234. scope: Scope.BLOCK,
  8235. whitelist: ["left", "right", "center", "justify"]
  8236. };
  8237. const AlignStyle = new Attributor.Style("align", "text-align", config);
  8238. return {
  8239. "formats/align": AlignStyle
  8240. };
  8241. }
  8242. function direction(Quill) {
  8243. const { Scope, Attributor } = Quill.import("parchment");
  8244. const config = {
  8245. scope: Scope.BLOCK,
  8246. whitelist: ["rtl"]
  8247. };
  8248. const DirectionStyle = new Attributor.Style("direction", "direction", config);
  8249. return {
  8250. "formats/direction": DirectionStyle
  8251. };
  8252. }
  8253. function list(Quill) {
  8254. const Parchment = Quill.import("parchment");
  8255. const Container = Quill.import("blots/container");
  8256. const ListItem = Quill.import("formats/list/item");
  8257. class List extends Container {
  8258. static create(value) {
  8259. const tagName = value === "ordered" ? "OL" : "UL";
  8260. const node = super.create(tagName);
  8261. if (value === "checked" || value === "unchecked") {
  8262. node.setAttribute("data-checked", value === "checked");
  8263. }
  8264. return node;
  8265. }
  8266. static formats(domNode) {
  8267. if (domNode.tagName === "OL")
  8268. return "ordered";
  8269. if (domNode.tagName === "UL") {
  8270. if (domNode.hasAttribute("data-checked")) {
  8271. return domNode.getAttribute("data-checked") === "true" ? "checked" : "unchecked";
  8272. } else {
  8273. return "bullet";
  8274. }
  8275. }
  8276. return void 0;
  8277. }
  8278. constructor(domNode) {
  8279. super(domNode);
  8280. const listEventHandler = (e2) => {
  8281. if (e2.target.parentNode !== domNode)
  8282. return;
  8283. const format = this.statics.formats(domNode);
  8284. const blot = Parchment.find(e2.target);
  8285. if (format === "checked") {
  8286. blot.format("list", "unchecked");
  8287. } else if (format === "unchecked") {
  8288. blot.format("list", "checked");
  8289. }
  8290. };
  8291. domNode.addEventListener("click", listEventHandler);
  8292. }
  8293. format(name, value) {
  8294. if (this.children.length > 0) {
  8295. this.children.tail.format(name, value);
  8296. }
  8297. }
  8298. formats() {
  8299. return { [this.statics.blotName]: this.statics.formats(this.domNode) };
  8300. }
  8301. insertBefore(blot, ref2) {
  8302. if (blot instanceof ListItem) {
  8303. super.insertBefore(blot, ref2);
  8304. } else {
  8305. const index2 = ref2 == null ? this.length() : ref2.offset(this);
  8306. const after = this.split(index2);
  8307. after.parent.insertBefore(blot, after);
  8308. }
  8309. }
  8310. optimize(context) {
  8311. super.optimize(context);
  8312. const next = this.next;
  8313. if (next != null && next.prev === this && next.statics.blotName === this.statics.blotName && next.domNode.tagName === this.domNode.tagName && next.domNode.getAttribute("data-checked") === this.domNode.getAttribute("data-checked")) {
  8314. next.moveChildren(this);
  8315. next.remove();
  8316. }
  8317. }
  8318. replace(target) {
  8319. if (target.statics.blotName !== this.statics.blotName) {
  8320. const item = Parchment.create(this.statics.defaultChild);
  8321. target.moveChildren(item);
  8322. this.appendChild(item);
  8323. }
  8324. super.replace(target);
  8325. }
  8326. }
  8327. List.blotName = "list";
  8328. List.scope = Parchment.Scope.BLOCK_BLOT;
  8329. List.tagName = ["OL", "UL"];
  8330. List.defaultChild = "list-item";
  8331. List.allowedChildren = [ListItem];
  8332. return {
  8333. "formats/list": List
  8334. };
  8335. }
  8336. function background(Quill) {
  8337. const { Scope } = Quill.import("parchment");
  8338. const BackgroundStyle = Quill.import("formats/background");
  8339. const BackgroundColorStyle = new BackgroundStyle.constructor(
  8340. "backgroundColor",
  8341. "background-color",
  8342. {
  8343. scope: Scope.INLINE
  8344. }
  8345. );
  8346. return {
  8347. "formats/backgroundColor": BackgroundColorStyle
  8348. };
  8349. }
  8350. function box(Quill) {
  8351. const { Scope, Attributor } = Quill.import("parchment");
  8352. const config = {
  8353. scope: Scope.BLOCK
  8354. };
  8355. const margin = [
  8356. "margin",
  8357. "marginTop",
  8358. "marginBottom",
  8359. "marginLeft",
  8360. "marginRight"
  8361. ];
  8362. const padding = [
  8363. "padding",
  8364. "paddingTop",
  8365. "paddingBottom",
  8366. "paddingLeft",
  8367. "paddingRight"
  8368. ];
  8369. const result = {};
  8370. margin.concat(padding).forEach((name) => {
  8371. result[`formats/${name}`] = new Attributor.Style(
  8372. name,
  8373. hyphenate(name),
  8374. config
  8375. );
  8376. });
  8377. return result;
  8378. }
  8379. function font(Quill) {
  8380. const { Scope, Attributor } = Quill.import("parchment");
  8381. const config = {
  8382. scope: Scope.INLINE
  8383. };
  8384. const font2 = [
  8385. "font",
  8386. "fontSize",
  8387. "fontStyle",
  8388. "fontVariant",
  8389. "fontWeight",
  8390. "fontFamily"
  8391. ];
  8392. const result = {};
  8393. font2.forEach((name) => {
  8394. result[`formats/${name}`] = new Attributor.Style(
  8395. name,
  8396. hyphenate(name),
  8397. config
  8398. );
  8399. });
  8400. return result;
  8401. }
  8402. function text(Quill) {
  8403. const { Scope, Attributor } = Quill.import("parchment");
  8404. const text2 = [
  8405. {
  8406. name: "lineHeight",
  8407. scope: Scope.BLOCK
  8408. },
  8409. {
  8410. name: "letterSpacing",
  8411. scope: Scope.INLINE
  8412. },
  8413. {
  8414. name: "textDecoration",
  8415. scope: Scope.INLINE
  8416. },
  8417. {
  8418. name: "textIndent",
  8419. scope: Scope.BLOCK
  8420. }
  8421. ];
  8422. const result = {};
  8423. text2.forEach(({ name, scope: scope2 }) => {
  8424. result[`formats/${name}`] = new Attributor.Style(name, hyphenate(name), {
  8425. scope: scope2
  8426. });
  8427. });
  8428. return result;
  8429. }
  8430. function image(Quill) {
  8431. const Image2 = Quill.import("formats/image");
  8432. const ATTRIBUTES = [
  8433. "alt",
  8434. "height",
  8435. "width",
  8436. "data-custom",
  8437. "class",
  8438. "data-local"
  8439. ];
  8440. Image2.sanitize = (url) => url ? getRealPath(url) : url;
  8441. Image2.formats = function formats(domNode) {
  8442. return ATTRIBUTES.reduce(
  8443. function(formats2, attribute) {
  8444. if (domNode.hasAttribute(attribute)) {
  8445. formats2[attribute] = domNode.getAttribute(attribute);
  8446. }
  8447. return formats2;
  8448. },
  8449. {}
  8450. );
  8451. };
  8452. const format = Image2.prototype.format;
  8453. Image2.prototype.format = function(name, value) {
  8454. if (ATTRIBUTES.indexOf(name) > -1) {
  8455. if (value) {
  8456. this.domNode.setAttribute(name, value);
  8457. } else {
  8458. this.domNode.removeAttribute(name);
  8459. }
  8460. } else {
  8461. format.call(this, name, value);
  8462. }
  8463. };
  8464. }
  8465. function link(Quill) {
  8466. const Link = Quill.import("formats/link");
  8467. Link.sanitize = (url) => {
  8468. const anchor = document.createElement("a");
  8469. anchor.href = url;
  8470. const protocol = anchor.href.slice(0, anchor.href.indexOf(":"));
  8471. return Link.PROTOCOL_WHITELIST.concat("file").indexOf(protocol) > -1 ? url : Link.SANITIZED_URL;
  8472. };
  8473. }
  8474. function register(Quill) {
  8475. const formats = {
  8476. divider,
  8477. ins,
  8478. align,
  8479. direction,
  8480. list,
  8481. background,
  8482. box,
  8483. font,
  8484. text,
  8485. image,
  8486. link
  8487. };
  8488. const options = {};
  8489. Object.values(formats).forEach((value) => extend(options, value(Quill)));
  8490. Quill.register(options, true);
  8491. }
  8492. function useQuill(props2, rootRef, trigger) {
  8493. let quillReady;
  8494. let skipMatcher;
  8495. let quill;
  8496. watch(
  8497. () => props2.readOnly,
  8498. (value) => {
  8499. if (quillReady) {
  8500. quill.enable(!value);
  8501. if (!value) {
  8502. quill.blur();
  8503. }
  8504. }
  8505. }
  8506. );
  8507. watch(
  8508. () => props2.placeholder,
  8509. (value) => {
  8510. if (quillReady) {
  8511. setPlaceHolder(value);
  8512. }
  8513. }
  8514. );
  8515. function html2delta(html) {
  8516. const tags = [
  8517. "span",
  8518. "strong",
  8519. "b",
  8520. "ins",
  8521. "em",
  8522. "i",
  8523. "u",
  8524. "a",
  8525. "del",
  8526. "s",
  8527. "sub",
  8528. "sup",
  8529. "img",
  8530. "div",
  8531. "p",
  8532. "h1",
  8533. "h2",
  8534. "h3",
  8535. "h4",
  8536. "h5",
  8537. "h6",
  8538. "hr",
  8539. "ol",
  8540. "ul",
  8541. "li",
  8542. "br"
  8543. ];
  8544. let content = "";
  8545. let disable;
  8546. HTMLParser(html, {
  8547. start: function(tag, attrs2, unary) {
  8548. if (!tags.includes(tag)) {
  8549. disable = !unary;
  8550. return;
  8551. }
  8552. disable = false;
  8553. const arrts = attrs2.map(({ name, value }) => `${name}="${value}"`).join(" ");
  8554. const start = `<${tag} ${arrts} ${unary ? "/" : ""}>`;
  8555. content += start;
  8556. },
  8557. end: function(tag) {
  8558. if (!disable) {
  8559. content += `</${tag}>`;
  8560. }
  8561. },
  8562. chars: function(text2) {
  8563. if (!disable) {
  8564. content += text2;
  8565. }
  8566. }
  8567. });
  8568. skipMatcher = true;
  8569. const delta = quill.clipboard.convert(content);
  8570. skipMatcher = false;
  8571. return delta;
  8572. }
  8573. function getContents() {
  8574. const html = quill.root.innerHTML;
  8575. const text2 = quill.getText();
  8576. const delta = quill.getContents();
  8577. return {
  8578. html,
  8579. text: text2,
  8580. delta
  8581. };
  8582. }
  8583. function setPlaceHolder(placeholder) {
  8584. const placeHolderAttrName = "data-placeholder";
  8585. const QuillRoot = quill.root;
  8586. QuillRoot.getAttribute(placeHolderAttrName) !== placeholder && QuillRoot.setAttribute(placeHolderAttrName, placeholder);
  8587. }
  8588. let oldStatus = {};
  8589. function updateStatus(range) {
  8590. const status = range ? quill.getFormat(range) : {};
  8591. const keys = Object.keys(status);
  8592. if (keys.length !== Object.keys(oldStatus).length || keys.find((key) => status[key] !== oldStatus[key])) {
  8593. oldStatus = status;
  8594. trigger("statuschange", {}, status);
  8595. }
  8596. }
  8597. function textChangeHandler() {
  8598. trigger("input", {}, getContents());
  8599. }
  8600. function initQuill(imageResizeModules) {
  8601. const Quill = window.Quill;
  8602. register(Quill);
  8603. const options = {
  8604. toolbar: false,
  8605. readOnly: props2.readOnly,
  8606. placeholder: props2.placeholder
  8607. };
  8608. if (imageResizeModules.length) {
  8609. Quill.register(
  8610. "modules/ImageResize",
  8611. window.ImageResize.default
  8612. );
  8613. options.modules = {
  8614. ImageResize: {
  8615. modules: imageResizeModules
  8616. }
  8617. };
  8618. }
  8619. const rootEl = rootRef.value;
  8620. quill = new Quill(rootEl, options);
  8621. const $el = quill.root;
  8622. const events = ["focus", "blur", "input"];
  8623. events.forEach((name) => {
  8624. $el.addEventListener(name, ($event) => {
  8625. const contents = getContents();
  8626. if (name === "input") {
  8627. if (getBaseSystemInfo().platform === "ios") {
  8628. const regExpContent = (contents.html.match(
  8629. /<span [\s\S]*>([\s\S]*)<\/span>/
  8630. ) || [])[1];
  8631. const placeholder = regExpContent && regExpContent.replace(/\s/g, "") ? "" : props2.placeholder;
  8632. setPlaceHolder(placeholder);
  8633. }
  8634. $event.stopPropagation();
  8635. } else {
  8636. trigger(name, $event, contents);
  8637. }
  8638. });
  8639. });
  8640. quill.on("text-change", textChangeHandler);
  8641. quill.on("selection-change", updateStatus);
  8642. quill.on("scroll-optimize", () => {
  8643. const range = quill.selection.getRange()[0];
  8644. updateStatus(range);
  8645. });
  8646. quill.clipboard.addMatcher(Node.ELEMENT_NODE, (node, delta) => {
  8647. if (skipMatcher) {
  8648. return delta;
  8649. }
  8650. if (delta.ops) {
  8651. delta.ops = delta.ops.filter(({ insert }) => isString(insert)).map(({ insert }) => ({ insert }));
  8652. }
  8653. return delta;
  8654. });
  8655. quillReady = true;
  8656. trigger("ready", {}, {});
  8657. }
  8658. const id2 = useContextInfo();
  8659. useSubscribe(
  8660. (type, data, resolve) => {
  8661. const { options, callbackId } = data;
  8662. let res;
  8663. let range;
  8664. let errMsg;
  8665. if (quillReady) {
  8666. const Quill = window.Quill;
  8667. switch (type) {
  8668. case "format":
  8669. {
  8670. let { name = "", value = false } = options;
  8671. range = quill.getSelection(true);
  8672. let format = quill.getFormat(range)[name] || false;
  8673. if (["bold", "italic", "underline", "strike", "ins"].includes(name)) {
  8674. value = !format;
  8675. } else if (name === "direction") {
  8676. value = value === "rtl" && format ? false : value;
  8677. const align2 = quill.getFormat(range).align;
  8678. if (value === "rtl" && !align2) {
  8679. quill.format("align", "right", "user");
  8680. } else if (!value && align2 === "right") {
  8681. quill.format("align", false, "user");
  8682. }
  8683. } else if (name === "indent") {
  8684. const rtl = quill.getFormat(range).direction === "rtl";
  8685. value = value === "+1";
  8686. if (rtl) {
  8687. value = !value;
  8688. }
  8689. value = value ? "+1" : "-1";
  8690. } else {
  8691. if (name === "list") {
  8692. value = value === "check" ? "unchecked" : value;
  8693. format = format === "checked" ? "unchecked" : format;
  8694. }
  8695. value = format && format !== (value || false) || !format && value ? value : !format;
  8696. }
  8697. quill.format(name, value, "user");
  8698. }
  8699. break;
  8700. case "insertDivider":
  8701. range = quill.getSelection(true);
  8702. quill.insertText(range.index, LINEFEED, "user");
  8703. quill.insertEmbed(range.index + 1, "divider", true, "user");
  8704. quill.setSelection(range.index + 2, 0, "silent");
  8705. break;
  8706. case "insertImage":
  8707. {
  8708. range = quill.getSelection(true);
  8709. const {
  8710. src = "",
  8711. alt = "",
  8712. width = "",
  8713. height = "",
  8714. extClass = "",
  8715. data: data2 = {}
  8716. } = options;
  8717. const path = getRealPath(src);
  8718. quill.insertEmbed(range.index, "image", path, "silent");
  8719. const local = /^(file|blob):/.test(path) ? path : false;
  8720. quill.formatText(range.index, 1, "data-local", local, "silent");
  8721. quill.formatText(range.index, 1, "alt", alt, "silent");
  8722. quill.formatText(range.index, 1, "width", width, "silent");
  8723. quill.formatText(range.index, 1, "height", height, "silent");
  8724. quill.formatText(range.index, 1, "class", extClass, "silent");
  8725. quill.formatText(
  8726. range.index,
  8727. 1,
  8728. "data-custom",
  8729. Object.keys(data2).map((key) => `${key}=${data2[key]}`).join("&"),
  8730. "silent"
  8731. );
  8732. quill.setSelection(range.index + 1, 0, "silent");
  8733. quill.scrollIntoView();
  8734. setTimeout(() => {
  8735. textChangeHandler();
  8736. }, 1e3);
  8737. }
  8738. break;
  8739. case "insertText":
  8740. {
  8741. range = quill.getSelection(true);
  8742. const { text: text2 = "" } = options;
  8743. quill.insertText(range.index, text2, "user");
  8744. quill.setSelection(range.index + text2.length, 0, "silent");
  8745. }
  8746. break;
  8747. case "setContents":
  8748. {
  8749. const { delta, html } = options;
  8750. if (typeof delta === "object") {
  8751. quill.setContents(delta, "silent");
  8752. } else if (isString(html)) {
  8753. quill.setContents(html2delta(html), "silent");
  8754. } else {
  8755. errMsg = "contents is missing";
  8756. }
  8757. }
  8758. break;
  8759. case "getContents":
  8760. res = getContents();
  8761. break;
  8762. case "clear":
  8763. quill.setText("");
  8764. break;
  8765. case "removeFormat":
  8766. {
  8767. range = quill.getSelection(true);
  8768. const parchment = Quill.import("parchment");
  8769. if (range.length) {
  8770. quill.removeFormat(range.index, range.length, "user");
  8771. } else {
  8772. Object.keys(quill.getFormat(range)).forEach((key) => {
  8773. if (parchment.query(key, parchment.Scope.INLINE)) {
  8774. quill.format(key, false);
  8775. }
  8776. });
  8777. }
  8778. }
  8779. break;
  8780. case "undo":
  8781. quill.history.undo();
  8782. break;
  8783. case "redo":
  8784. quill.history.redo();
  8785. break;
  8786. case "blur":
  8787. quill.blur();
  8788. break;
  8789. case "getSelectionText":
  8790. range = quill.selection.savedRange;
  8791. res = { text: "" };
  8792. if (range && range.length !== 0) {
  8793. res.text = quill.getText(range.index, range.length);
  8794. }
  8795. break;
  8796. case "scrollIntoView":
  8797. quill.scrollIntoView();
  8798. break;
  8799. }
  8800. updateStatus(range);
  8801. } else {
  8802. errMsg = "not ready";
  8803. }
  8804. if (callbackId) {
  8805. resolve({
  8806. callbackId,
  8807. data: extend({}, res, {
  8808. errMsg: `${type}:${errMsg ? "fail " + errMsg : "ok"}`
  8809. })
  8810. });
  8811. }
  8812. },
  8813. id2,
  8814. true
  8815. );
  8816. onMounted(() => {
  8817. const imageResizeModules = [];
  8818. if (props2.showImgSize) {
  8819. imageResizeModules.push("DisplaySize");
  8820. }
  8821. if (props2.showImgToolbar) {
  8822. imageResizeModules.push("Toolbar");
  8823. }
  8824. if (props2.showImgResize) {
  8825. imageResizeModules.push("Resize");
  8826. }
  8827. const quillSrc = "https://unpkg.com/quill@1.3.7/dist/quill.min.js";
  8828. loadScript(window.Quill, quillSrc, () => {
  8829. if (imageResizeModules.length) {
  8830. const imageResizeSrc = "https://unpkg.com/quill-image-resize-mp@3.0.1/image-resize.min.js";
  8831. loadScript(window.ImageResize, imageResizeSrc, () => {
  8832. initQuill(imageResizeModules);
  8833. });
  8834. } else {
  8835. initQuill(imageResizeModules);
  8836. }
  8837. });
  8838. });
  8839. }
  8840. const props$t = /* @__PURE__ */ extend({}, props$u, {
  8841. id: {
  8842. type: String,
  8843. default: ""
  8844. },
  8845. readOnly: {
  8846. type: [Boolean, String],
  8847. default: false
  8848. },
  8849. placeholder: {
  8850. type: String,
  8851. default: ""
  8852. },
  8853. showImgSize: {
  8854. type: [Boolean, String],
  8855. default: false
  8856. },
  8857. showImgToolbar: {
  8858. type: [Boolean, String],
  8859. default: false
  8860. },
  8861. showImgResize: {
  8862. type: [Boolean, String],
  8863. default: false
  8864. }
  8865. });
  8866. const index$s = /* @__PURE__ */ defineBuiltInComponent({
  8867. name: "Editor",
  8868. props: props$t,
  8869. emit: ["ready", "focus", "blur", "input", "statuschange", ...emit$1],
  8870. setup(props2, {
  8871. emit: emit2
  8872. }) {
  8873. const rootRef = ref(null);
  8874. const trigger = useCustomEvent(rootRef, emit2);
  8875. useQuill(props2, rootRef, trigger);
  8876. useKeyboard$1(props2, rootRef);
  8877. return () => {
  8878. return createVNode("uni-editor", {
  8879. "ref": rootRef,
  8880. "id": props2.id,
  8881. "class": "ql-container"
  8882. }, null, 8, ["id"]);
  8883. };
  8884. }
  8885. });
  8886. const INFO_COLOR = "#10aeff";
  8887. const WARN_COLOR = "#f76260";
  8888. const GREY_COLOR = "#b2b2b2";
  8889. const CANCEL_COLOR = "#f43530";
  8890. const ICONS = {
  8891. success: {
  8892. d: ICON_PATH_SUCCESS,
  8893. c: PRIMARY_COLOR
  8894. },
  8895. success_no_circle: {
  8896. d: ICON_PATH_SUCCESS_NO_CIRCLE,
  8897. c: PRIMARY_COLOR
  8898. },
  8899. info: {
  8900. d: ICON_PATH_INFO,
  8901. c: INFO_COLOR
  8902. },
  8903. warn: {
  8904. d: ICON_PATH_WARN,
  8905. c: WARN_COLOR
  8906. },
  8907. waiting: {
  8908. d: ICON_PATH_WAITING,
  8909. c: INFO_COLOR
  8910. },
  8911. cancel: {
  8912. d: ICON_PATH_CANCEL,
  8913. c: CANCEL_COLOR
  8914. },
  8915. download: {
  8916. d: ICON_PATH_DOWNLOAD,
  8917. c: PRIMARY_COLOR
  8918. },
  8919. search: {
  8920. d: ICON_PATH_SEARCH,
  8921. c: GREY_COLOR
  8922. },
  8923. clear: {
  8924. d: ICON_PATH_CLEAR,
  8925. c: GREY_COLOR
  8926. }
  8927. };
  8928. const index$r = /* @__PURE__ */ defineBuiltInComponent({
  8929. name: "Icon",
  8930. props: {
  8931. type: {
  8932. type: String,
  8933. required: true,
  8934. default: ""
  8935. },
  8936. size: {
  8937. type: [String, Number],
  8938. default: 23
  8939. },
  8940. color: {
  8941. type: String,
  8942. default: ""
  8943. }
  8944. },
  8945. setup(props2) {
  8946. const rootRef = ref(null);
  8947. const path = computed(() => ICONS[props2.type]);
  8948. return () => {
  8949. const {
  8950. value
  8951. } = path;
  8952. return createVNode("uni-icon", {
  8953. "ref": rootRef
  8954. }, [value && value.d && createSvgIconVNode(value.d, props2.color || value.c, rpx2px(props2.size))], 512);
  8955. };
  8956. }
  8957. });
  8958. const props$s = {
  8959. src: {
  8960. type: String,
  8961. default: ""
  8962. },
  8963. mode: {
  8964. type: String,
  8965. default: "scaleToFill"
  8966. },
  8967. lazyLoad: {
  8968. type: [Boolean, String],
  8969. default: false
  8970. },
  8971. draggable: {
  8972. type: Boolean,
  8973. default: false
  8974. }
  8975. };
  8976. const FIX_MODES = {
  8977. widthFix: ["offsetWidth", "height", (value, ratio) => value / ratio],
  8978. heightFix: ["offsetHeight", "width", (value, ratio) => value * ratio]
  8979. };
  8980. const IMAGE_MODES = {
  8981. aspectFit: ["center center", "contain"],
  8982. aspectFill: ["center center", "cover"],
  8983. widthFix: [, "100% 100%"],
  8984. heightFix: [, "100% 100%"],
  8985. top: ["center top"],
  8986. bottom: ["center bottom"],
  8987. center: ["center center"],
  8988. left: ["left center"],
  8989. right: ["right center"],
  8990. "top left": ["left top"],
  8991. "top right": ["right top"],
  8992. "bottom left": ["left bottom"],
  8993. "bottom right": ["right bottom"]
  8994. };
  8995. const index$q = /* @__PURE__ */ defineBuiltInComponent({
  8996. name: "Image",
  8997. props: props$s,
  8998. setup(props2, {
  8999. emit: emit2
  9000. }) {
  9001. const rootRef = ref(null);
  9002. const state2 = useImageState(rootRef, props2);
  9003. const trigger = useCustomEvent(rootRef, emit2);
  9004. const {
  9005. fixSize
  9006. } = useImageSize(rootRef, props2, state2);
  9007. useImageLoader(state2, props2, rootRef, fixSize, trigger);
  9008. return () => {
  9009. return createVNode("uni-image", {
  9010. "ref": rootRef
  9011. }, [createVNode("div", {
  9012. "style": state2.modeStyle
  9013. }, null, 4), FIX_MODES[props2.mode] ? (
  9014. // @ts-ignore
  9015. createVNode(ResizeSensor, {
  9016. "onResize": fixSize
  9017. }, null, 8, ["onResize"])
  9018. ) : createVNode("span", null, null)], 512);
  9019. };
  9020. }
  9021. });
  9022. function useImageState(rootRef, props2) {
  9023. const imgSrc = ref("");
  9024. const modeStyleRef = computed(() => {
  9025. let size = "auto";
  9026. let position = "";
  9027. const opts = IMAGE_MODES[props2.mode];
  9028. if (!opts) {
  9029. position = "0% 0%";
  9030. size = "100% 100%";
  9031. } else {
  9032. opts[0] && (position = opts[0]);
  9033. opts[1] && (size = opts[1]);
  9034. }
  9035. return `background-image:${imgSrc.value ? 'url("' + imgSrc.value + '")' : "none"};background-position:${position};background-size:${size};`;
  9036. });
  9037. const state2 = reactive({
  9038. rootEl: rootRef,
  9039. src: computed(() => props2.src ? getRealPath(props2.src) : ""),
  9040. origWidth: 0,
  9041. origHeight: 0,
  9042. origStyle: {
  9043. width: "",
  9044. height: ""
  9045. },
  9046. modeStyle: modeStyleRef,
  9047. imgSrc
  9048. });
  9049. onMounted(() => {
  9050. const rootEl = rootRef.value;
  9051. const style = rootEl.style;
  9052. state2.origWidth = Number(style.width) || 0;
  9053. state2.origHeight = Number(style.height) || 0;
  9054. });
  9055. return state2;
  9056. }
  9057. function useImageLoader(state2, props2, rootRef, fixSize, trigger) {
  9058. let img;
  9059. let draggableImg;
  9060. const setState = (width = 0, height = 0, imgSrc = "") => {
  9061. state2.origWidth = width;
  9062. state2.origHeight = height;
  9063. state2.imgSrc = imgSrc;
  9064. };
  9065. const loadImage = (src) => {
  9066. if (!src) {
  9067. resetImage();
  9068. setState();
  9069. return;
  9070. }
  9071. img = img || new Image();
  9072. img.onload = (evt) => {
  9073. const {
  9074. width,
  9075. height
  9076. } = img;
  9077. setState(width, height, src);
  9078. fixSize();
  9079. img.draggable = props2.draggable;
  9080. if (draggableImg) {
  9081. draggableImg.remove();
  9082. }
  9083. draggableImg = img;
  9084. rootRef.value.appendChild(img);
  9085. resetImage();
  9086. trigger("load", evt, {
  9087. width,
  9088. height
  9089. });
  9090. };
  9091. img.onerror = (evt) => {
  9092. setState();
  9093. resetImage();
  9094. trigger("error", evt, {
  9095. errMsg: `GET ${state2.src} 404 (Not Found)`
  9096. });
  9097. };
  9098. img.src = src;
  9099. };
  9100. const resetImage = () => {
  9101. if (img) {
  9102. img.onload = null;
  9103. img.onerror = null;
  9104. img = null;
  9105. }
  9106. };
  9107. watch(() => state2.src, (value) => loadImage(value));
  9108. watch(() => state2.imgSrc, (value) => {
  9109. if (!value && draggableImg) {
  9110. draggableImg.remove();
  9111. draggableImg = null;
  9112. }
  9113. });
  9114. onMounted(() => loadImage(state2.src));
  9115. onBeforeUnmount(() => resetImage());
  9116. }
  9117. const isChrome = navigator.vendor === "Google Inc.";
  9118. function fixNumber(num) {
  9119. if (isChrome && num > 10) {
  9120. num = Math.round(num / 2) * 2;
  9121. }
  9122. return num;
  9123. }
  9124. function useImageSize(rootRef, props2, state2) {
  9125. const fixSize = () => {
  9126. const {
  9127. mode: mode2
  9128. } = props2;
  9129. const names = FIX_MODES[mode2];
  9130. if (!names) {
  9131. return;
  9132. }
  9133. const {
  9134. origWidth,
  9135. origHeight
  9136. } = state2;
  9137. const ratio = origWidth && origHeight ? origWidth / origHeight : 0;
  9138. if (!ratio) {
  9139. return;
  9140. }
  9141. const rootEl = rootRef.value;
  9142. const value = rootEl[names[0]];
  9143. if (value) {
  9144. rootEl.style[names[1]] = fixNumber(names[2](value, ratio)) + "px";
  9145. }
  9146. };
  9147. const resetSize = () => {
  9148. const {
  9149. style
  9150. } = rootRef.value;
  9151. const {
  9152. origStyle: {
  9153. width,
  9154. height
  9155. }
  9156. } = state2;
  9157. style.width = width;
  9158. style.height = height;
  9159. };
  9160. watch(() => props2.mode, (value, oldValue) => {
  9161. if (FIX_MODES[oldValue]) {
  9162. resetSize();
  9163. }
  9164. if (FIX_MODES[value]) {
  9165. fixSize();
  9166. }
  9167. });
  9168. return {
  9169. fixSize,
  9170. resetSize
  9171. };
  9172. }
  9173. function throttle(fn, wait) {
  9174. let last = 0;
  9175. let timeout;
  9176. let waitCallback;
  9177. const newFn = function(...arg) {
  9178. const now = Date.now();
  9179. clearTimeout(timeout);
  9180. waitCallback = () => {
  9181. waitCallback = null;
  9182. last = now;
  9183. fn.apply(this, arg);
  9184. };
  9185. if (now - last < wait) {
  9186. timeout = setTimeout(waitCallback, wait - (now - last));
  9187. return;
  9188. }
  9189. waitCallback();
  9190. };
  9191. newFn.cancel = function() {
  9192. clearTimeout(timeout);
  9193. waitCallback = null;
  9194. };
  9195. newFn.flush = function() {
  9196. clearTimeout(timeout);
  9197. waitCallback && waitCallback();
  9198. };
  9199. return newFn;
  9200. }
  9201. const passiveOptions$1 = /* @__PURE__ */ passive(true);
  9202. const states = [];
  9203. let userInteract = 0;
  9204. let inited;
  9205. const setUserAction = (userAction) => states.forEach((vm) => vm.userAction = userAction);
  9206. function addInteractListener(vm = { userAction: false }) {
  9207. if (!inited) {
  9208. const eventNames = [
  9209. "touchstart",
  9210. "touchmove",
  9211. "touchend",
  9212. "mousedown",
  9213. "mouseup"
  9214. ];
  9215. eventNames.forEach((eventName) => {
  9216. document.addEventListener(
  9217. eventName,
  9218. function() {
  9219. !userInteract && setUserAction(true);
  9220. userInteract++;
  9221. setTimeout(() => {
  9222. !--userInteract && setUserAction(false);
  9223. }, 0);
  9224. },
  9225. passiveOptions$1
  9226. );
  9227. });
  9228. inited = true;
  9229. }
  9230. states.push(vm);
  9231. }
  9232. function removeInteractListener(vm) {
  9233. const index2 = states.indexOf(vm);
  9234. if (index2 >= 0) {
  9235. states.splice(index2, 1);
  9236. }
  9237. }
  9238. const getInteractStatus = () => !!userInteract;
  9239. function useUserAction() {
  9240. const state2 = reactive({
  9241. /**
  9242. * 是否用户激活
  9243. */
  9244. userAction: false
  9245. });
  9246. onMounted(() => {
  9247. addInteractListener(state2);
  9248. });
  9249. onBeforeUnmount(() => {
  9250. removeInteractListener(state2);
  9251. });
  9252. return {
  9253. state: state2
  9254. };
  9255. }
  9256. function useScopedAttrs() {
  9257. const state2 = reactive({
  9258. attrs: {}
  9259. });
  9260. onMounted(() => {
  9261. let instance2 = getCurrentInstance();
  9262. while (instance2) {
  9263. const scopeId = instance2.type.__scopeId;
  9264. if (scopeId) {
  9265. state2.attrs[scopeId] = "";
  9266. }
  9267. instance2 = instance2.proxy && instance2.proxy.$mpType === "page" ? null : instance2.parent;
  9268. }
  9269. });
  9270. return {
  9271. state: state2
  9272. };
  9273. }
  9274. function useFormField(nameKey, value) {
  9275. const uniForm = inject(
  9276. uniFormKey,
  9277. false
  9278. // remove warning
  9279. );
  9280. if (!uniForm) {
  9281. return;
  9282. }
  9283. const instance2 = getCurrentInstance();
  9284. const ctx = {
  9285. submit() {
  9286. const proxy = instance2.proxy;
  9287. return [
  9288. proxy[nameKey],
  9289. isString(value) ? proxy[value] : value.value
  9290. ];
  9291. },
  9292. reset() {
  9293. if (isString(value)) {
  9294. instance2.proxy[value] = "";
  9295. } else {
  9296. value.value = "";
  9297. }
  9298. }
  9299. };
  9300. uniForm.addField(ctx);
  9301. onBeforeUnmount(() => {
  9302. uniForm.removeField(ctx);
  9303. });
  9304. }
  9305. function getSelectedTextRange(_, resolve) {
  9306. const activeElement = document.activeElement;
  9307. if (!activeElement) {
  9308. return resolve({});
  9309. }
  9310. const data = {};
  9311. if (["input", "textarea"].includes(activeElement.tagName.toLowerCase())) {
  9312. data.start = activeElement.selectionStart;
  9313. data.end = activeElement.selectionEnd;
  9314. }
  9315. resolve(data);
  9316. }
  9317. const UniViewJSBridgeSubscribe = function() {
  9318. registerViewMethod(
  9319. getCurrentPageId(),
  9320. "getSelectedTextRange",
  9321. getSelectedTextRange
  9322. );
  9323. };
  9324. function getValueString(value, type) {
  9325. if (type === "number" && isNaN(Number(value))) {
  9326. value = "";
  9327. }
  9328. return value === null ? "" : String(value);
  9329. }
  9330. const INPUT_MODES = [
  9331. "none",
  9332. "text",
  9333. "decimal",
  9334. "numeric",
  9335. "tel",
  9336. "search",
  9337. "email",
  9338. "url"
  9339. ];
  9340. const props$r = /* @__PURE__ */ extend(
  9341. {},
  9342. {
  9343. name: {
  9344. type: String,
  9345. default: ""
  9346. },
  9347. modelValue: {
  9348. type: [String, Number],
  9349. default: ""
  9350. },
  9351. value: {
  9352. type: [String, Number],
  9353. default: ""
  9354. },
  9355. disabled: {
  9356. type: [Boolean, String],
  9357. default: false
  9358. },
  9359. /**
  9360. * 已废弃属性,用于历史兼容
  9361. */
  9362. autoFocus: {
  9363. type: [Boolean, String],
  9364. default: false
  9365. },
  9366. focus: {
  9367. type: [Boolean, String],
  9368. default: false
  9369. },
  9370. cursor: {
  9371. type: [Number, String],
  9372. default: -1
  9373. },
  9374. selectionStart: {
  9375. type: [Number, String],
  9376. default: -1
  9377. },
  9378. selectionEnd: {
  9379. type: [Number, String],
  9380. default: -1
  9381. },
  9382. type: {
  9383. type: String,
  9384. default: "text"
  9385. },
  9386. password: {
  9387. type: [Boolean, String],
  9388. default: false
  9389. },
  9390. placeholder: {
  9391. type: String,
  9392. default: ""
  9393. },
  9394. placeholderStyle: {
  9395. type: String,
  9396. default: ""
  9397. },
  9398. placeholderClass: {
  9399. type: String,
  9400. default: ""
  9401. },
  9402. maxlength: {
  9403. type: [Number, String],
  9404. default: 140
  9405. },
  9406. confirmType: {
  9407. type: String,
  9408. default: "done"
  9409. },
  9410. confirmHold: {
  9411. type: Boolean,
  9412. default: false
  9413. },
  9414. ignoreCompositionEvent: {
  9415. type: Boolean,
  9416. default: true
  9417. },
  9418. step: {
  9419. type: String,
  9420. default: "0.000000000000000001"
  9421. },
  9422. inputmode: {
  9423. type: String,
  9424. default: void 0,
  9425. validator: (value) => !!~INPUT_MODES.indexOf(value)
  9426. },
  9427. cursorColor: {
  9428. type: String,
  9429. default: ""
  9430. }
  9431. },
  9432. props$u
  9433. );
  9434. const emit = [
  9435. "input",
  9436. "focus",
  9437. "blur",
  9438. "update:value",
  9439. "update:modelValue",
  9440. "update:focus",
  9441. "compositionstart",
  9442. "compositionupdate",
  9443. "compositionend",
  9444. ...emit$1
  9445. ];
  9446. function useBase(props2, rootRef, emit2) {
  9447. const fieldRef = ref(null);
  9448. const trigger = useCustomEvent(rootRef, emit2);
  9449. const selectionStart = computed(() => {
  9450. const selectionStart2 = Number(props2.selectionStart);
  9451. return isNaN(selectionStart2) ? -1 : selectionStart2;
  9452. });
  9453. const selectionEnd = computed(() => {
  9454. const selectionEnd2 = Number(props2.selectionEnd);
  9455. return isNaN(selectionEnd2) ? -1 : selectionEnd2;
  9456. });
  9457. const cursor = computed(() => {
  9458. const cursor2 = Number(props2.cursor);
  9459. return isNaN(cursor2) ? -1 : cursor2;
  9460. });
  9461. const maxlength = computed(() => {
  9462. var maxlength2 = Number(props2.maxlength);
  9463. return isNaN(maxlength2) ? 140 : maxlength2;
  9464. });
  9465. const value = getValueString(props2.modelValue, props2.type) || getValueString(props2.value, props2.type);
  9466. const state2 = reactive({
  9467. value,
  9468. valueOrigin: value,
  9469. maxlength,
  9470. focus: props2.focus,
  9471. composing: false,
  9472. selectionStart,
  9473. selectionEnd,
  9474. cursor
  9475. });
  9476. watch(
  9477. () => state2.focus,
  9478. (val) => emit2("update:focus", val)
  9479. );
  9480. watch(
  9481. () => state2.maxlength,
  9482. (val) => state2.value = state2.value.slice(0, val)
  9483. );
  9484. return {
  9485. fieldRef,
  9486. state: state2,
  9487. trigger
  9488. };
  9489. }
  9490. function useValueSync(props2, state2, emit2, trigger) {
  9491. const valueChangeFn = debounce(
  9492. (val) => {
  9493. state2.value = getValueString(val, props2.type);
  9494. },
  9495. 100,
  9496. { setTimeout, clearTimeout }
  9497. );
  9498. watch(() => props2.modelValue, valueChangeFn);
  9499. watch(() => props2.value, valueChangeFn);
  9500. const triggerInputFn = throttle((event, detail) => {
  9501. valueChangeFn.cancel();
  9502. emit2("update:modelValue", detail.value);
  9503. emit2("update:value", detail.value);
  9504. trigger("input", event, detail);
  9505. }, 100);
  9506. const triggerInput = (event, detail, force) => {
  9507. valueChangeFn.cancel();
  9508. triggerInputFn(event, detail);
  9509. if (force) {
  9510. triggerInputFn.flush();
  9511. }
  9512. };
  9513. onBeforeMount(() => {
  9514. valueChangeFn.cancel();
  9515. triggerInputFn.cancel();
  9516. });
  9517. return {
  9518. trigger,
  9519. triggerInput
  9520. };
  9521. }
  9522. function useAutoFocus(props2, fieldRef) {
  9523. useUserAction();
  9524. const needFocus = computed(() => props2.autoFocus || props2.focus);
  9525. function focus() {
  9526. if (!needFocus.value) {
  9527. return;
  9528. }
  9529. const field = fieldRef.value;
  9530. if (!field || false) {
  9531. setTimeout(focus, 100);
  9532. return;
  9533. }
  9534. {
  9535. field.focus();
  9536. }
  9537. }
  9538. function blur() {
  9539. const field = fieldRef.value;
  9540. if (field) {
  9541. field.blur();
  9542. }
  9543. }
  9544. watch(
  9545. () => props2.focus,
  9546. (value) => {
  9547. if (value) {
  9548. focus();
  9549. } else {
  9550. blur();
  9551. }
  9552. }
  9553. );
  9554. onMounted(() => {
  9555. if (needFocus.value) {
  9556. nextTick(focus);
  9557. }
  9558. });
  9559. }
  9560. function useEvent(fieldRef, state2, props2, trigger, triggerInput, beforeInput) {
  9561. function checkSelection() {
  9562. const field = fieldRef.value;
  9563. if (field && state2.focus && state2.selectionStart > -1 && state2.selectionEnd > -1 && field.type !== "number") {
  9564. field.selectionStart = state2.selectionStart;
  9565. field.selectionEnd = state2.selectionEnd;
  9566. }
  9567. }
  9568. function checkCursor() {
  9569. const field = fieldRef.value;
  9570. if (field && state2.focus && state2.selectionStart < 0 && state2.selectionEnd < 0 && state2.cursor > -1 && field.type !== "number") {
  9571. field.selectionEnd = field.selectionStart = state2.cursor;
  9572. }
  9573. }
  9574. function getFieldSelectionEnd(field) {
  9575. if (field.type === "number") {
  9576. return null;
  9577. } else {
  9578. return field.selectionEnd;
  9579. }
  9580. }
  9581. function initField() {
  9582. const field = fieldRef.value;
  9583. if (!field)
  9584. return;
  9585. const onFocus = function(event) {
  9586. state2.focus = true;
  9587. trigger("focus", event, {
  9588. value: state2.value
  9589. });
  9590. checkSelection();
  9591. checkCursor();
  9592. };
  9593. const onInput = function(event, force) {
  9594. event.stopPropagation();
  9595. if (isFunction(beforeInput) && beforeInput(event, state2) === false) {
  9596. return;
  9597. }
  9598. state2.value = field.value;
  9599. if (!state2.composing || !props2.ignoreCompositionEvent) {
  9600. triggerInput(
  9601. event,
  9602. {
  9603. value: field.value,
  9604. cursor: getFieldSelectionEnd(field)
  9605. },
  9606. force
  9607. );
  9608. }
  9609. };
  9610. const onBlur = function(event) {
  9611. if (state2.composing) {
  9612. state2.composing = false;
  9613. onInput(event, true);
  9614. }
  9615. state2.focus = false;
  9616. trigger("blur", event, {
  9617. value: state2.value,
  9618. cursor: getFieldSelectionEnd(event.target)
  9619. });
  9620. };
  9621. field.addEventListener("change", (event) => event.stopPropagation());
  9622. field.addEventListener("focus", onFocus);
  9623. field.addEventListener("blur", onBlur);
  9624. field.addEventListener("input", onInput);
  9625. field.addEventListener("compositionstart", (event) => {
  9626. event.stopPropagation();
  9627. state2.composing = true;
  9628. _onComposition(event);
  9629. });
  9630. field.addEventListener("compositionend", (event) => {
  9631. event.stopPropagation();
  9632. if (state2.composing) {
  9633. state2.composing = false;
  9634. onInput(event);
  9635. }
  9636. _onComposition(event);
  9637. });
  9638. field.addEventListener("compositionupdate", _onComposition);
  9639. function _onComposition(event) {
  9640. if (!props2.ignoreCompositionEvent) {
  9641. trigger(event.type, event, {
  9642. value: event.data
  9643. });
  9644. }
  9645. }
  9646. }
  9647. watch([() => state2.selectionStart, () => state2.selectionEnd], checkSelection);
  9648. watch(() => state2.cursor, checkCursor);
  9649. watch(() => fieldRef.value, initField);
  9650. }
  9651. function useField(props2, rootRef, emit2, beforeInput) {
  9652. UniViewJSBridgeSubscribe();
  9653. const { fieldRef, state: state2, trigger } = useBase(props2, rootRef, emit2);
  9654. const { triggerInput } = useValueSync(props2, state2, emit2, trigger);
  9655. useAutoFocus(props2, fieldRef);
  9656. useKeyboard$1(props2, fieldRef);
  9657. const { state: scopedAttrsState } = useScopedAttrs();
  9658. useFormField("name", state2);
  9659. useEvent(fieldRef, state2, props2, trigger, triggerInput, beforeInput);
  9660. const fixDisabledColor = String(navigator.vendor).indexOf("Apple") === 0 && CSS.supports("image-orientation:from-image");
  9661. return {
  9662. fieldRef,
  9663. state: state2,
  9664. scopedAttrsState,
  9665. fixDisabledColor,
  9666. trigger
  9667. };
  9668. }
  9669. const props$q = /* @__PURE__ */ extend({}, props$r, {
  9670. placeholderClass: {
  9671. type: String,
  9672. default: "input-placeholder"
  9673. },
  9674. textContentType: {
  9675. type: String,
  9676. default: ""
  9677. }
  9678. });
  9679. const Input = /* @__PURE__ */ defineBuiltInComponent({
  9680. name: "Input",
  9681. props: props$q,
  9682. emits: ["confirm", ...emit],
  9683. setup(props2, {
  9684. emit: emit2,
  9685. expose
  9686. }) {
  9687. const INPUT_TYPES = ["text", "number", "idcard", "digit", "password", "tel"];
  9688. const AUTOCOMPLETES = ["off", "one-time-code"];
  9689. const type = computed(() => {
  9690. let type2 = "";
  9691. switch (props2.type) {
  9692. case "text":
  9693. if (props2.confirmType === "search") {
  9694. type2 = "search";
  9695. }
  9696. break;
  9697. case "idcard":
  9698. type2 = "text";
  9699. break;
  9700. case "digit":
  9701. type2 = "number";
  9702. break;
  9703. default:
  9704. type2 = ~INPUT_TYPES.includes(props2.type) ? props2.type : "text";
  9705. break;
  9706. }
  9707. return props2.password ? "password" : type2;
  9708. });
  9709. const autocomplete = computed(() => {
  9710. const camelizeIndex = AUTOCOMPLETES.indexOf(props2.textContentType);
  9711. const kebabCaseIndex = AUTOCOMPLETES.indexOf(hyphenate(props2.textContentType));
  9712. const index2 = camelizeIndex !== -1 ? camelizeIndex : kebabCaseIndex !== -1 ? kebabCaseIndex : 0;
  9713. return AUTOCOMPLETES[index2];
  9714. });
  9715. let cache = ref("");
  9716. let resetCache;
  9717. const rootRef = ref(null);
  9718. const {
  9719. fieldRef,
  9720. state: state2,
  9721. scopedAttrsState,
  9722. fixDisabledColor,
  9723. trigger
  9724. } = useField(props2, rootRef, emit2, (event, state3) => {
  9725. const input = event.target;
  9726. if (type.value === "number") {
  9727. if (resetCache) {
  9728. input.removeEventListener("blur", resetCache);
  9729. resetCache = null;
  9730. }
  9731. if (input.validity && !input.validity.valid) {
  9732. if ((!cache.value || !input.value) && event.data === "-" || cache.value[0] === "-" && event.inputType === "deleteContentBackward") {
  9733. cache.value = "-";
  9734. state3.value = "";
  9735. resetCache = () => {
  9736. cache.value = input.value = "";
  9737. };
  9738. input.addEventListener("blur", resetCache);
  9739. return false;
  9740. }
  9741. if (cache.value) {
  9742. if (cache.value.indexOf(".") !== -1) {
  9743. if (event.data !== "." && event.inputType === "deleteContentBackward") {
  9744. const dotIndex = cache.value.indexOf(".");
  9745. cache.value = input.value = state3.value = cache.value.slice(0, dotIndex);
  9746. return true;
  9747. }
  9748. } else if (event.data === ".") {
  9749. cache.value += ".";
  9750. resetCache = () => {
  9751. cache.value = input.value = cache.value.slice(0, -1);
  9752. };
  9753. input.addEventListener("blur", resetCache);
  9754. return false;
  9755. }
  9756. }
  9757. cache.value = state3.value = input.value = cache.value === "-" ? "" : cache.value;
  9758. return false;
  9759. } else {
  9760. cache.value = input.value;
  9761. }
  9762. const maxlength = state3.maxlength;
  9763. if (maxlength > 0 && input.value.length > maxlength) {
  9764. input.value = input.value.slice(0, maxlength);
  9765. state3.value = input.value;
  9766. return false;
  9767. }
  9768. }
  9769. });
  9770. watch(() => state2.value, (value) => {
  9771. if (props2.type === "number" && !(cache.value === "-" && value === "")) {
  9772. cache.value = value;
  9773. }
  9774. });
  9775. const NUMBER_TYPES = ["number", "digit"];
  9776. const step = computed(() => NUMBER_TYPES.includes(props2.type) ? props2.step : "");
  9777. function onKeyUpEnter(event) {
  9778. if (event.key !== "Enter") {
  9779. return;
  9780. }
  9781. const input = event.target;
  9782. event.stopPropagation();
  9783. trigger("confirm", event, {
  9784. value: input.value
  9785. });
  9786. !props2.confirmHold && input.blur();
  9787. }
  9788. expose({
  9789. $triggerInput: (detail) => {
  9790. emit2("update:modelValue", detail.value);
  9791. emit2("update:value", detail.value);
  9792. state2.value = detail.value;
  9793. }
  9794. });
  9795. return () => {
  9796. let inputNode = props2.disabled && fixDisabledColor ? createVNode("input", {
  9797. "key": "disabled-input",
  9798. "ref": fieldRef,
  9799. "value": state2.value,
  9800. "tabindex": "-1",
  9801. "readonly": !!props2.disabled,
  9802. "type": type.value,
  9803. "maxlength": state2.maxlength,
  9804. "step": step.value,
  9805. "class": "uni-input-input",
  9806. "style": props2.cursorColor ? {
  9807. caretColor: props2.cursorColor
  9808. } : {},
  9809. "onFocus": (event) => event.target.blur()
  9810. }, null, 44, ["value", "readonly", "type", "maxlength", "step", "onFocus"]) : withDirectives(createVNode("input", {
  9811. "key": "input",
  9812. "ref": fieldRef,
  9813. "onUpdate:modelValue": ($event) => state2.value = $event,
  9814. "disabled": !!props2.disabled,
  9815. "type": type.value,
  9816. "maxlength": state2.maxlength,
  9817. "step": step.value,
  9818. "enterkeyhint": props2.confirmType,
  9819. "pattern": props2.type === "number" ? "[0-9]*" : void 0,
  9820. "class": "uni-input-input",
  9821. "style": props2.cursorColor ? {
  9822. caretColor: props2.cursorColor
  9823. } : {},
  9824. "autocomplete": autocomplete.value,
  9825. "onKeyup": onKeyUpEnter,
  9826. "inputmode": props2.inputmode
  9827. }, null, 44, ["onUpdate:modelValue", "disabled", "type", "maxlength", "step", "enterkeyhint", "pattern", "autocomplete", "onKeyup", "inputmode"]), [[vModelDynamic, state2.value]]);
  9828. return createVNode("uni-input", {
  9829. "ref": rootRef
  9830. }, [createVNode("div", {
  9831. "class": "uni-input-wrapper"
  9832. }, [withDirectives(createVNode("div", mergeProps(scopedAttrsState.attrs, {
  9833. "style": props2.placeholderStyle,
  9834. "class": ["uni-input-placeholder", props2.placeholderClass]
  9835. }), [props2.placeholder], 16), [[vShow, !(state2.value.length || cache.value === "-")]]), props2.confirmType === "search" ? createVNode("form", {
  9836. "action": "",
  9837. "onSubmit": (event) => event.preventDefault(),
  9838. "class": "uni-input-form"
  9839. }, [inputNode], 40, ["onSubmit"]) : inputNode])], 512);
  9840. };
  9841. }
  9842. });
  9843. function entries(obj) {
  9844. return Object.keys(obj).map((key) => [key, obj[key]]);
  9845. }
  9846. const DEFAULT_EXCLUDE_KEYS = ["class", "style"];
  9847. const LISTENER_PREFIX = /^on[A-Z]+/;
  9848. const useAttrs = (params = {}) => {
  9849. const { excludeListeners = false, excludeKeys = [] } = params;
  9850. const instance2 = getCurrentInstance();
  9851. const attrs2 = shallowRef({});
  9852. const listeners2 = shallowRef({});
  9853. const excludeAttrs = shallowRef({});
  9854. const allExcludeKeys = excludeKeys.concat(DEFAULT_EXCLUDE_KEYS);
  9855. instance2.attrs = reactive(instance2.attrs);
  9856. watchEffect(() => {
  9857. const res = entries(instance2.attrs).reduce(
  9858. (acc, [key, val]) => {
  9859. if (allExcludeKeys.includes(key)) {
  9860. acc.exclude[key] = val;
  9861. } else if (LISTENER_PREFIX.test(key)) {
  9862. if (!excludeListeners) {
  9863. acc.attrs[key] = val;
  9864. }
  9865. acc.listeners[key] = val;
  9866. } else {
  9867. acc.attrs[key] = val;
  9868. }
  9869. return acc;
  9870. },
  9871. {
  9872. exclude: {},
  9873. attrs: {},
  9874. listeners: {}
  9875. }
  9876. );
  9877. attrs2.value = res.attrs;
  9878. listeners2.value = res.listeners;
  9879. excludeAttrs.value = res.exclude;
  9880. });
  9881. return { $attrs: attrs2, $listeners: listeners2, $excludeAttrs: excludeAttrs };
  9882. };
  9883. function flatVNode(nodes) {
  9884. const array = [];
  9885. if (isArray(nodes)) {
  9886. nodes.forEach((vnode) => {
  9887. if (isVNode(vnode)) {
  9888. if (vnode.type === Fragment) {
  9889. array.push(...flatVNode(vnode.children));
  9890. } else {
  9891. array.push(vnode);
  9892. }
  9893. } else if (isArray(vnode)) {
  9894. array.push(...flatVNode(vnode));
  9895. }
  9896. });
  9897. }
  9898. return array;
  9899. }
  9900. const movableAreaProps = {
  9901. scaleArea: {
  9902. type: Boolean,
  9903. default: false
  9904. }
  9905. };
  9906. const MovableArea = /* @__PURE__ */ defineBuiltInComponent({
  9907. inheritAttrs: false,
  9908. name: "MovableArea",
  9909. props: movableAreaProps,
  9910. setup(props2, {
  9911. slots
  9912. }) {
  9913. const rootRef = ref(null);
  9914. const _isMounted = ref(false);
  9915. let {
  9916. setContexts,
  9917. events: movableAreaEvents
  9918. } = useMovableAreaState(props2, rootRef);
  9919. const {
  9920. $listeners,
  9921. $attrs,
  9922. $excludeAttrs
  9923. } = useAttrs();
  9924. const _listeners = $listeners.value;
  9925. let events = ["onTouchstart", "onTouchmove", "onTouchend"];
  9926. events.forEach((event) => {
  9927. let existing = _listeners[event];
  9928. let ours = movableAreaEvents[`_${event}`];
  9929. _listeners[event] = existing ? [].concat(existing, ours) : ours;
  9930. });
  9931. onMounted(() => {
  9932. movableAreaEvents._resize();
  9933. _isMounted.value = true;
  9934. });
  9935. let movableViewItems = [];
  9936. const originMovableViewContexts = [];
  9937. function updateMovableViewContexts() {
  9938. const contexts = [];
  9939. for (let index2 = 0; index2 < movableViewItems.length; index2++) {
  9940. let movableViewItem = movableViewItems[index2];
  9941. {
  9942. movableViewItem = movableViewItem.el;
  9943. }
  9944. const movableViewContext = originMovableViewContexts.find((context) => movableViewItem === context.rootRef.value);
  9945. if (movableViewContext) {
  9946. contexts.push(markRaw(movableViewContext));
  9947. }
  9948. }
  9949. setContexts(contexts);
  9950. }
  9951. const addMovableViewContext = (movableViewContext) => {
  9952. originMovableViewContexts.push(movableViewContext);
  9953. updateMovableViewContexts();
  9954. };
  9955. const removeMovableViewContext = (movableViewContext) => {
  9956. const index2 = originMovableViewContexts.indexOf(movableViewContext);
  9957. if (index2 >= 0) {
  9958. originMovableViewContexts.splice(index2, 1);
  9959. updateMovableViewContexts();
  9960. }
  9961. };
  9962. provide("_isMounted", _isMounted);
  9963. provide("movableAreaRootRef", rootRef);
  9964. provide("addMovableViewContext", addMovableViewContext);
  9965. provide("removeMovableViewContext", removeMovableViewContext);
  9966. return () => {
  9967. const defaultSlots = slots.default && slots.default();
  9968. {
  9969. movableViewItems = flatVNode(defaultSlots);
  9970. }
  9971. return createVNode("uni-movable-area", mergeProps({
  9972. "ref": rootRef
  9973. }, $attrs.value, $excludeAttrs.value, _listeners), [createVNode(ResizeSensor, {
  9974. "onResize": movableAreaEvents._resize
  9975. }, null, 8, ["onResize"]), movableViewItems], 16);
  9976. };
  9977. }
  9978. });
  9979. function calc(e2) {
  9980. return Math.sqrt(e2.x * e2.x + e2.y * e2.y);
  9981. }
  9982. function useMovableAreaState(props2, rootRef) {
  9983. const width = ref(0);
  9984. const height = ref(0);
  9985. const gapV = reactive({
  9986. x: null,
  9987. y: null
  9988. });
  9989. const pinchStartLen = ref(null);
  9990. let _scaleMovableView = null;
  9991. let movableViewContexts = [];
  9992. function _updateScale(e2) {
  9993. if (e2 && e2 !== 1) {
  9994. if (props2.scaleArea) {
  9995. movableViewContexts.forEach(function(item) {
  9996. item._setScale(e2);
  9997. });
  9998. } else {
  9999. if (_scaleMovableView) {
  10000. _scaleMovableView._setScale(e2);
  10001. }
  10002. }
  10003. }
  10004. }
  10005. function _find(target, items = movableViewContexts) {
  10006. let root = rootRef.value;
  10007. function get(node) {
  10008. for (let i = 0; i < items.length; i++) {
  10009. const item = items[i];
  10010. if (node === item.rootRef.value) {
  10011. return item;
  10012. }
  10013. }
  10014. if (node === root || node === document.body || node === document) {
  10015. return null;
  10016. }
  10017. return get(node.parentNode);
  10018. }
  10019. return get(target);
  10020. }
  10021. const _onTouchstart = withWebEvent((t2) => {
  10022. let i = t2.touches;
  10023. if (i) {
  10024. if (i.length > 1) {
  10025. let r = {
  10026. x: i[1].pageX - i[0].pageX,
  10027. y: i[1].pageY - i[0].pageY
  10028. };
  10029. pinchStartLen.value = calc(r);
  10030. gapV.x = r.x;
  10031. gapV.y = r.y;
  10032. if (!props2.scaleArea) {
  10033. let touch0 = _find(i[0].target);
  10034. let touch1 = _find(i[1].target);
  10035. _scaleMovableView = touch0 && touch0 === touch1 ? touch0 : null;
  10036. }
  10037. }
  10038. }
  10039. });
  10040. const _onTouchmove = withWebEvent((t2) => {
  10041. let n = t2.touches;
  10042. if (n) {
  10043. if (n.length > 1) {
  10044. t2.preventDefault();
  10045. let i = {
  10046. x: n[1].pageX - n[0].pageX,
  10047. y: n[1].pageY - n[0].pageY
  10048. };
  10049. if (gapV.x !== null && pinchStartLen.value && pinchStartLen.value > 0) {
  10050. let r = calc(i) / pinchStartLen.value;
  10051. _updateScale(r);
  10052. }
  10053. gapV.x = i.x;
  10054. gapV.y = i.y;
  10055. }
  10056. }
  10057. });
  10058. const _onTouchend = withWebEvent((e2) => {
  10059. let t2 = e2.touches;
  10060. if (!(t2 && t2.length)) {
  10061. if (e2.changedTouches) {
  10062. gapV.x = 0;
  10063. gapV.y = 0;
  10064. pinchStartLen.value = null;
  10065. if (props2.scaleArea) {
  10066. movableViewContexts.forEach(function(item) {
  10067. item._endScale();
  10068. });
  10069. } else {
  10070. if (_scaleMovableView) {
  10071. _scaleMovableView._endScale();
  10072. }
  10073. }
  10074. }
  10075. }
  10076. });
  10077. function _resize() {
  10078. _getWH();
  10079. movableViewContexts.forEach(function(item, index2) {
  10080. item.setParent();
  10081. });
  10082. }
  10083. function _getWH() {
  10084. let style = window.getComputedStyle(rootRef.value);
  10085. let rect = rootRef.value.getBoundingClientRect();
  10086. width.value = rect.width - ["Left", "Right"].reduce(function(all, item) {
  10087. const LEFT = "border" + item + "Width";
  10088. const RIGHT = "padding" + item;
  10089. return all + parseFloat(style[LEFT]) + parseFloat(style[RIGHT]);
  10090. }, 0);
  10091. height.value = rect.height - ["Top", "Bottom"].reduce(function(all, item) {
  10092. const TOP = "border" + item + "Width";
  10093. const BOTTOM = "padding" + item;
  10094. return all + parseFloat(style[TOP]) + parseFloat(style[BOTTOM]);
  10095. }, 0);
  10096. }
  10097. provide("movableAreaWidth", width);
  10098. provide("movableAreaHeight", height);
  10099. return {
  10100. setContexts(contexts) {
  10101. movableViewContexts = contexts;
  10102. },
  10103. events: {
  10104. _onTouchstart,
  10105. _onTouchmove,
  10106. _onTouchend,
  10107. _resize
  10108. }
  10109. };
  10110. }
  10111. const addListenerToElement = function(element, type, callback, capture) {
  10112. element.addEventListener(
  10113. type,
  10114. ($event) => {
  10115. if (isFunction(callback)) {
  10116. if (callback($event) === false) {
  10117. if (typeof $event.cancelable !== "undefined" ? $event.cancelable : true) {
  10118. $event.preventDefault();
  10119. }
  10120. $event.stopPropagation();
  10121. }
  10122. }
  10123. },
  10124. {
  10125. passive: false
  10126. }
  10127. );
  10128. };
  10129. let __mouseMoveEventListener;
  10130. let __mouseUpEventListener;
  10131. function useTouchtrack(element, method, useCancel) {
  10132. onBeforeUnmount(() => {
  10133. document.removeEventListener("mousemove", __mouseMoveEventListener);
  10134. document.removeEventListener("mouseup", __mouseUpEventListener);
  10135. });
  10136. let x0 = 0;
  10137. let y0 = 0;
  10138. let x1 = 0;
  10139. let y1 = 0;
  10140. const fn = function($event, state2, x, y) {
  10141. if (method({
  10142. // @ts-expect-error
  10143. cancelable: $event.cancelable,
  10144. target: $event.target,
  10145. currentTarget: $event.currentTarget,
  10146. preventDefault: $event.preventDefault.bind($event),
  10147. stopPropagation: $event.stopPropagation.bind($event),
  10148. touches: $event.touches,
  10149. changedTouches: $event.changedTouches,
  10150. detail: {
  10151. state: state2,
  10152. x,
  10153. y,
  10154. dx: x - x0,
  10155. dy: y - y0,
  10156. ddx: x - x1,
  10157. ddy: y - y1,
  10158. timeStamp: $event.timeStamp
  10159. }
  10160. }) === false) {
  10161. return false;
  10162. }
  10163. };
  10164. let $eventOld = null;
  10165. let hasTouchStart;
  10166. let hasMouseDown;
  10167. addListenerToElement(element, "touchstart", function($event) {
  10168. hasTouchStart = true;
  10169. if ($event.touches.length === 1 && !$eventOld) {
  10170. $eventOld = $event;
  10171. x0 = x1 = $event.touches[0].pageX;
  10172. y0 = y1 = $event.touches[0].pageY;
  10173. return fn($event, "start", x0, y0);
  10174. }
  10175. });
  10176. addListenerToElement(element, "mousedown", function($event) {
  10177. hasMouseDown = true;
  10178. if (!hasTouchStart && !$eventOld) {
  10179. $eventOld = $event;
  10180. x0 = x1 = $event.pageX;
  10181. y0 = y1 = $event.pageY;
  10182. return fn($event, "start", x0, y0);
  10183. }
  10184. });
  10185. addListenerToElement(element, "touchmove", function($event) {
  10186. if ($event.touches.length === 1 && $eventOld) {
  10187. const res = fn(
  10188. $event,
  10189. "move",
  10190. $event.touches[0].pageX,
  10191. $event.touches[0].pageY
  10192. );
  10193. x1 = $event.touches[0].pageX;
  10194. y1 = $event.touches[0].pageY;
  10195. return res;
  10196. }
  10197. });
  10198. const mouseMoveEventListener = __mouseMoveEventListener = function($event) {
  10199. if (!hasTouchStart && hasMouseDown && $eventOld) {
  10200. const res = fn($event, "move", $event.pageX, $event.pageY);
  10201. x1 = $event.pageX;
  10202. y1 = $event.pageY;
  10203. return res;
  10204. }
  10205. };
  10206. document.addEventListener("mousemove", mouseMoveEventListener);
  10207. addListenerToElement(element, "touchend", function($event) {
  10208. if ($event.touches.length === 0 && $eventOld) {
  10209. hasTouchStart = false;
  10210. $eventOld = null;
  10211. return fn(
  10212. $event,
  10213. "end",
  10214. $event.changedTouches[0].pageX,
  10215. $event.changedTouches[0].pageY
  10216. );
  10217. }
  10218. });
  10219. const mouseUpEventListener = __mouseUpEventListener = function($event) {
  10220. hasMouseDown = false;
  10221. if (!hasTouchStart && $eventOld) {
  10222. $eventOld = null;
  10223. return fn($event, "end", $event.pageX, $event.pageY);
  10224. }
  10225. };
  10226. document.addEventListener("mouseup", mouseUpEventListener);
  10227. addListenerToElement(element, "touchcancel", function($event) {
  10228. if ($eventOld) {
  10229. hasTouchStart = false;
  10230. const $eventTemp = $eventOld;
  10231. $eventOld = null;
  10232. return fn(
  10233. $event,
  10234. useCancel ? "cancel" : "end",
  10235. $eventTemp.touches[0].pageX,
  10236. $eventTemp.touches[0].pageY
  10237. );
  10238. }
  10239. });
  10240. }
  10241. function e(e2, t2, n) {
  10242. return e2 > t2 - n && e2 < t2 + n;
  10243. }
  10244. function t(t2, n) {
  10245. return e(t2, 0, n);
  10246. }
  10247. function Decline() {
  10248. }
  10249. Decline.prototype.x = function(e2) {
  10250. return Math.sqrt(e2);
  10251. };
  10252. function Friction$1(e2, t2) {
  10253. this._m = e2;
  10254. this._f = 1e3 * t2;
  10255. this._startTime = 0;
  10256. this._v = 0;
  10257. }
  10258. Friction$1.prototype.setV = function(x, y) {
  10259. const n = Math.pow(Math.pow(x, 2) + Math.pow(y, 2), 0.5);
  10260. this._x_v = x;
  10261. this._y_v = y;
  10262. this._x_a = -this._f * this._x_v / n;
  10263. this._y_a = -this._f * this._y_v / n;
  10264. this._t = Math.abs(x / this._x_a) || Math.abs(y / this._y_a);
  10265. this._lastDt = null;
  10266. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  10267. };
  10268. Friction$1.prototype.setS = function(x, y) {
  10269. this._x_s = x;
  10270. this._y_s = y;
  10271. };
  10272. Friction$1.prototype.s = function(t2) {
  10273. if (void 0 === t2) {
  10274. t2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  10275. }
  10276. if (t2 > this._t) {
  10277. t2 = this._t;
  10278. this._lastDt = t2;
  10279. }
  10280. let x = this._x_v * t2 + 0.5 * this._x_a * Math.pow(t2, 2) + this._x_s;
  10281. let y = this._y_v * t2 + 0.5 * this._y_a * Math.pow(t2, 2) + this._y_s;
  10282. if (this._x_a > 0 && x < this._endPositionX || this._x_a < 0 && x > this._endPositionX) {
  10283. x = this._endPositionX;
  10284. }
  10285. if (this._y_a > 0 && y < this._endPositionY || this._y_a < 0 && y > this._endPositionY) {
  10286. y = this._endPositionY;
  10287. }
  10288. return {
  10289. x,
  10290. y
  10291. };
  10292. };
  10293. Friction$1.prototype.ds = function(t2) {
  10294. if (void 0 === t2) {
  10295. t2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  10296. }
  10297. if (t2 > this._t) {
  10298. t2 = this._t;
  10299. }
  10300. return {
  10301. dx: this._x_v + this._x_a * t2,
  10302. dy: this._y_v + this._y_a * t2
  10303. };
  10304. };
  10305. Friction$1.prototype.delta = function() {
  10306. return {
  10307. x: -1.5 * Math.pow(this._x_v, 2) / this._x_a || 0,
  10308. y: -1.5 * Math.pow(this._y_v, 2) / this._y_a || 0
  10309. };
  10310. };
  10311. Friction$1.prototype.dt = function() {
  10312. return -this._x_v / this._x_a;
  10313. };
  10314. Friction$1.prototype.done = function() {
  10315. const t2 = e(this.s().x, this._endPositionX) || e(this.s().y, this._endPositionY) || this._lastDt === this._t;
  10316. this._lastDt = null;
  10317. return t2;
  10318. };
  10319. Friction$1.prototype.setEnd = function(x, y) {
  10320. this._endPositionX = x;
  10321. this._endPositionY = y;
  10322. };
  10323. Friction$1.prototype.reconfigure = function(m, f2) {
  10324. this._m = m;
  10325. this._f = 1e3 * f2;
  10326. };
  10327. function Spring$1(m, k, c) {
  10328. this._m = m;
  10329. this._k = k;
  10330. this._c = c;
  10331. this._solution = null;
  10332. this._endPosition = 0;
  10333. this._startTime = 0;
  10334. }
  10335. Spring$1.prototype._solve = function(e2, t2) {
  10336. const n = this._c;
  10337. const i = this._m;
  10338. const r = this._k;
  10339. const o2 = n * n - 4 * i * r;
  10340. if (o2 === 0) {
  10341. const a2 = -n / (2 * i);
  10342. const s = e2;
  10343. const l = t2 / (a2 * e2);
  10344. return {
  10345. x: function(e3) {
  10346. return (s + l * e3) * Math.pow(Math.E, a2 * e3);
  10347. },
  10348. dx: function(e3) {
  10349. const t3 = Math.pow(Math.E, a2 * e3);
  10350. return a2 * (s + l * e3) * t3 + l * t3;
  10351. }
  10352. };
  10353. }
  10354. if (o2 > 0) {
  10355. const c = (-n - Math.sqrt(o2)) / (2 * i);
  10356. const u = (-n + Math.sqrt(o2)) / (2 * i);
  10357. const d = (t2 - c * e2) / (u - c);
  10358. const h2 = e2 - d;
  10359. return {
  10360. x: function(e3) {
  10361. let t3;
  10362. let n2;
  10363. if (e3 === this._t) {
  10364. t3 = this._powER1T;
  10365. n2 = this._powER2T;
  10366. }
  10367. this._t = e3;
  10368. if (!t3) {
  10369. t3 = this._powER1T = Math.pow(Math.E, c * e3);
  10370. }
  10371. if (!n2) {
  10372. n2 = this._powER2T = Math.pow(Math.E, u * e3);
  10373. }
  10374. return h2 * t3 + d * n2;
  10375. },
  10376. dx: function(e3) {
  10377. let t3;
  10378. let n2;
  10379. if (e3 === this._t) {
  10380. t3 = this._powER1T;
  10381. n2 = this._powER2T;
  10382. }
  10383. this._t = e3;
  10384. if (!t3) {
  10385. t3 = this._powER1T = Math.pow(Math.E, c * e3);
  10386. }
  10387. if (!n2) {
  10388. n2 = this._powER2T = Math.pow(Math.E, u * e3);
  10389. }
  10390. return h2 * c * t3 + d * u * n2;
  10391. }
  10392. };
  10393. }
  10394. const p2 = Math.sqrt(4 * i * r - n * n) / (2 * i);
  10395. const f2 = -n / 2 * i;
  10396. const v2 = e2;
  10397. const g2 = (t2 - f2 * e2) / p2;
  10398. return {
  10399. x: function(e3) {
  10400. return Math.pow(Math.E, f2 * e3) * (v2 * Math.cos(p2 * e3) + g2 * Math.sin(p2 * e3));
  10401. },
  10402. dx: function(e3) {
  10403. const t3 = Math.pow(Math.E, f2 * e3);
  10404. const n2 = Math.cos(p2 * e3);
  10405. const i2 = Math.sin(p2 * e3);
  10406. return t3 * (g2 * p2 * n2 - v2 * p2 * i2) + f2 * t3 * (g2 * i2 + v2 * n2);
  10407. }
  10408. };
  10409. };
  10410. Spring$1.prototype.x = function(e2) {
  10411. if (void 0 === e2) {
  10412. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  10413. }
  10414. return this._solution ? this._endPosition + this._solution.x(e2) : 0;
  10415. };
  10416. Spring$1.prototype.dx = function(e2) {
  10417. if (void 0 === e2) {
  10418. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  10419. }
  10420. return this._solution ? this._solution.dx(e2) : 0;
  10421. };
  10422. Spring$1.prototype.setEnd = function(e2, n, i) {
  10423. if (!i) {
  10424. i = (/* @__PURE__ */ new Date()).getTime();
  10425. }
  10426. if (e2 !== this._endPosition || !t(n, 0.1)) {
  10427. n = n || 0;
  10428. let r = this._endPosition;
  10429. if (this._solution) {
  10430. if (t(n, 0.1)) {
  10431. n = this._solution.dx((i - this._startTime) / 1e3);
  10432. }
  10433. r = this._solution.x((i - this._startTime) / 1e3);
  10434. if (t(n, 0.1)) {
  10435. n = 0;
  10436. }
  10437. if (t(r, 0.1)) {
  10438. r = 0;
  10439. }
  10440. r += this._endPosition;
  10441. }
  10442. if (!(this._solution && t(r - e2, 0.1) && t(n, 0.1))) {
  10443. this._endPosition = e2;
  10444. this._solution = this._solve(r - this._endPosition, n);
  10445. this._startTime = i;
  10446. }
  10447. }
  10448. };
  10449. Spring$1.prototype.snap = function(e2) {
  10450. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  10451. this._endPosition = e2;
  10452. this._solution = {
  10453. x: function() {
  10454. return 0;
  10455. },
  10456. dx: function() {
  10457. return 0;
  10458. }
  10459. };
  10460. };
  10461. Spring$1.prototype.done = function(n) {
  10462. if (!n) {
  10463. n = (/* @__PURE__ */ new Date()).getTime();
  10464. }
  10465. return e(this.x(), this._endPosition, 0.1) && t(this.dx(), 0.1);
  10466. };
  10467. Spring$1.prototype.reconfigure = function(m, t2, c) {
  10468. this._m = m;
  10469. this._k = t2;
  10470. this._c = c;
  10471. if (!this.done()) {
  10472. this._solution = this._solve(this.x() - this._endPosition, this.dx());
  10473. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  10474. }
  10475. };
  10476. Spring$1.prototype.springConstant = function() {
  10477. return this._k;
  10478. };
  10479. Spring$1.prototype.damping = function() {
  10480. return this._c;
  10481. };
  10482. Spring$1.prototype.configuration = function() {
  10483. function e2(e3, t3) {
  10484. e3.reconfigure(1, t3, e3.damping());
  10485. }
  10486. function t2(e3, t3) {
  10487. e3.reconfigure(1, e3.springConstant(), t3);
  10488. }
  10489. return [
  10490. {
  10491. label: "Spring Constant",
  10492. read: this.springConstant.bind(this),
  10493. write: e2.bind(this, this),
  10494. min: 100,
  10495. max: 1e3
  10496. },
  10497. {
  10498. label: "Damping",
  10499. read: this.damping.bind(this),
  10500. write: t2.bind(this, this),
  10501. min: 1,
  10502. max: 500
  10503. }
  10504. ];
  10505. };
  10506. function STD(e2, t2, n) {
  10507. this._springX = new Spring$1(e2, t2, n);
  10508. this._springY = new Spring$1(e2, t2, n);
  10509. this._springScale = new Spring$1(e2, t2, n);
  10510. this._startTime = 0;
  10511. }
  10512. STD.prototype.setEnd = function(e2, t2, n, i) {
  10513. const r = (/* @__PURE__ */ new Date()).getTime();
  10514. this._springX.setEnd(e2, i, r);
  10515. this._springY.setEnd(t2, i, r);
  10516. this._springScale.setEnd(n, i, r);
  10517. this._startTime = r;
  10518. };
  10519. STD.prototype.x = function() {
  10520. const e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  10521. return {
  10522. x: this._springX.x(e2),
  10523. y: this._springY.x(e2),
  10524. scale: this._springScale.x(e2)
  10525. };
  10526. };
  10527. STD.prototype.done = function() {
  10528. const e2 = (/* @__PURE__ */ new Date()).getTime();
  10529. return this._springX.done(e2) && this._springY.done(e2) && this._springScale.done(e2);
  10530. };
  10531. STD.prototype.reconfigure = function(e2, t2, n) {
  10532. this._springX.reconfigure(e2, t2, n);
  10533. this._springY.reconfigure(e2, t2, n);
  10534. this._springScale.reconfigure(e2, t2, n);
  10535. };
  10536. const movableViewProps = {
  10537. direction: {
  10538. type: String,
  10539. default: "none"
  10540. },
  10541. inertia: {
  10542. type: [Boolean, String],
  10543. default: false
  10544. },
  10545. outOfBounds: {
  10546. type: [Boolean, String],
  10547. default: false
  10548. },
  10549. x: {
  10550. type: [Number, String],
  10551. default: 0
  10552. },
  10553. y: {
  10554. type: [Number, String],
  10555. default: 0
  10556. },
  10557. damping: {
  10558. type: [Number, String],
  10559. default: 20
  10560. },
  10561. friction: {
  10562. type: [Number, String],
  10563. default: 2
  10564. },
  10565. disabled: {
  10566. type: [Boolean, String],
  10567. default: false
  10568. },
  10569. scale: {
  10570. type: [Boolean, String],
  10571. default: false
  10572. },
  10573. scaleMin: {
  10574. type: [Number, String],
  10575. default: 0.5
  10576. },
  10577. scaleMax: {
  10578. type: [Number, String],
  10579. default: 10
  10580. },
  10581. scaleValue: {
  10582. type: [Number, String],
  10583. default: 1
  10584. },
  10585. animation: {
  10586. type: [Boolean, String],
  10587. default: true
  10588. }
  10589. };
  10590. function v(a2, b) {
  10591. return +((1e3 * a2 - 1e3 * b) / 1e3).toFixed(1);
  10592. }
  10593. const MovableView = /* @__PURE__ */ defineBuiltInComponent({
  10594. name: "MovableView",
  10595. props: movableViewProps,
  10596. emits: ["change", "scale"],
  10597. setup(props2, {
  10598. slots,
  10599. emit: emit2
  10600. }) {
  10601. const rootRef = ref(null);
  10602. const trigger = useCustomEvent(rootRef, emit2);
  10603. const {
  10604. setParent
  10605. } = useMovableViewState(props2, trigger, rootRef);
  10606. return () => {
  10607. return createVNode("uni-movable-view", {
  10608. "ref": rootRef
  10609. }, [createVNode(ResizeSensor, {
  10610. "onResize": setParent
  10611. }, null, 8, ["onResize"]), slots.default && slots.default()], 512);
  10612. };
  10613. }
  10614. });
  10615. let requesting = false;
  10616. function _requestAnimationFrame(e2) {
  10617. if (!requesting) {
  10618. requesting = true;
  10619. requestAnimationFrame(function() {
  10620. e2();
  10621. requesting = false;
  10622. });
  10623. }
  10624. }
  10625. function p(t2, n) {
  10626. if (t2 === n) {
  10627. return 0;
  10628. }
  10629. let i = t2.offsetLeft;
  10630. return t2.offsetParent ? i += p(t2.offsetParent, n) : 0;
  10631. }
  10632. function f(t2, n) {
  10633. if (t2 === n) {
  10634. return 0;
  10635. }
  10636. let i = t2.offsetTop;
  10637. return t2.offsetParent ? i += f(t2.offsetParent, n) : 0;
  10638. }
  10639. function g(friction, execute, endCallback) {
  10640. let record = {
  10641. id: 0,
  10642. cancelled: false
  10643. };
  10644. let cancel = function(record2) {
  10645. if (record2 && record2.id) {
  10646. cancelAnimationFrame(record2.id);
  10647. }
  10648. if (record2) {
  10649. record2.cancelled = true;
  10650. }
  10651. };
  10652. function fn(record2, friction2, execute2, endCallback2) {
  10653. if (!record2 || !record2.cancelled) {
  10654. execute2(friction2);
  10655. let isDone = friction2.done();
  10656. if (!isDone) {
  10657. if (!record2.cancelled) {
  10658. record2.id = requestAnimationFrame(fn.bind(null, record2, friction2, execute2, endCallback2));
  10659. }
  10660. }
  10661. if (isDone && endCallback2) {
  10662. endCallback2(friction2);
  10663. }
  10664. }
  10665. }
  10666. fn(record, friction, execute, endCallback);
  10667. return {
  10668. cancel: cancel.bind(null, record),
  10669. model: friction
  10670. };
  10671. }
  10672. function _getPx(val) {
  10673. if (/\d+[ur]px$/i.test(val)) {
  10674. return uni.upx2px(parseFloat(val));
  10675. }
  10676. return Number(val) || 0;
  10677. }
  10678. function useMovableViewLayout(rootRef, _scale, _adjustScale) {
  10679. const movableAreaWidth = inject("movableAreaWidth", ref(0));
  10680. const movableAreaHeight = inject("movableAreaHeight", ref(0));
  10681. const movableAreaRootRef = inject("movableAreaRootRef");
  10682. const _offset = {
  10683. x: 0,
  10684. y: 0
  10685. };
  10686. const _scaleOffset = {
  10687. x: 0,
  10688. y: 0
  10689. };
  10690. const width = ref(0);
  10691. const height = ref(0);
  10692. const minX = ref(0);
  10693. const minY = ref(0);
  10694. const maxX = ref(0);
  10695. const maxY = ref(0);
  10696. function _updateBoundary() {
  10697. let x = 0 - _offset.x + _scaleOffset.x;
  10698. let _width = movableAreaWidth.value - width.value - _offset.x - _scaleOffset.x;
  10699. minX.value = Math.min(x, _width);
  10700. maxX.value = Math.max(x, _width);
  10701. let y = 0 - _offset.y + _scaleOffset.y;
  10702. let _height = movableAreaHeight.value - height.value - _offset.y - _scaleOffset.y;
  10703. minY.value = Math.min(y, _height);
  10704. maxY.value = Math.max(y, _height);
  10705. }
  10706. function _updateOffset() {
  10707. _offset.x = p(rootRef.value, movableAreaRootRef.value);
  10708. _offset.y = f(rootRef.value, movableAreaRootRef.value);
  10709. }
  10710. function _updateWH(scale) {
  10711. scale = scale || _scale.value;
  10712. scale = _adjustScale(scale);
  10713. let rect = rootRef.value.getBoundingClientRect();
  10714. height.value = rect.height / _scale.value;
  10715. width.value = rect.width / _scale.value;
  10716. let _height = height.value * scale;
  10717. let _width = width.value * scale;
  10718. _scaleOffset.x = (_width - width.value) / 2;
  10719. _scaleOffset.y = (_height - height.value) / 2;
  10720. }
  10721. return {
  10722. _updateBoundary,
  10723. _updateOffset,
  10724. _updateWH,
  10725. _scaleOffset,
  10726. minX,
  10727. minY,
  10728. maxX,
  10729. maxY
  10730. };
  10731. }
  10732. function useMovableViewTransform(rootRef, props2, _scaleOffset, _scale, maxX, maxY, minX, minY, _translateX, _translateY, _SFA, _FA, _adjustScale, trigger) {
  10733. const dampingNumber = computed(() => {
  10734. let val = Number(props2.damping);
  10735. return isNaN(val) ? 20 : val;
  10736. });
  10737. const xMove = computed(() => props2.direction === "all" || props2.direction === "horizontal");
  10738. const yMove = computed(() => props2.direction === "all" || props2.direction === "vertical");
  10739. const xSync = ref(_getPx(props2.x));
  10740. const ySync = ref(_getPx(props2.y));
  10741. watch(() => props2.x, (val) => {
  10742. xSync.value = _getPx(val);
  10743. });
  10744. watch(() => props2.y, (val) => {
  10745. ySync.value = _getPx(val);
  10746. });
  10747. watch(xSync, (val) => {
  10748. _setX(val);
  10749. });
  10750. watch(ySync, (val) => {
  10751. _setY(val);
  10752. });
  10753. const _STD = new STD(1, 9 * Math.pow(dampingNumber.value, 2) / 40, dampingNumber.value);
  10754. function _getLimitXY(x, y) {
  10755. let outOfBounds = false;
  10756. if (x > maxX.value) {
  10757. x = maxX.value;
  10758. outOfBounds = true;
  10759. } else {
  10760. if (x < minX.value) {
  10761. x = minX.value;
  10762. outOfBounds = true;
  10763. }
  10764. }
  10765. if (y > maxY.value) {
  10766. y = maxY.value;
  10767. outOfBounds = true;
  10768. } else {
  10769. if (y < minY.value) {
  10770. y = minY.value;
  10771. outOfBounds = true;
  10772. }
  10773. }
  10774. return {
  10775. x,
  10776. y,
  10777. outOfBounds
  10778. };
  10779. }
  10780. function FAandSFACancel() {
  10781. if (_FA) {
  10782. _FA.cancel();
  10783. }
  10784. if (_SFA) {
  10785. _SFA.cancel();
  10786. }
  10787. }
  10788. function _animationTo(x, y, scale, source, r, o2) {
  10789. FAandSFACancel();
  10790. if (!xMove.value) {
  10791. x = _translateX.value;
  10792. }
  10793. if (!yMove.value) {
  10794. y = _translateY.value;
  10795. }
  10796. if (!props2.scale) {
  10797. scale = _scale.value;
  10798. }
  10799. let limitXY = _getLimitXY(x, y);
  10800. x = limitXY.x;
  10801. y = limitXY.y;
  10802. if (!props2.animation) {
  10803. _setTransform(x, y, scale, source, r, o2);
  10804. return;
  10805. }
  10806. _STD._springX._solution = null;
  10807. _STD._springY._solution = null;
  10808. _STD._springScale._solution = null;
  10809. _STD._springX._endPosition = _translateX.value;
  10810. _STD._springY._endPosition = _translateY.value;
  10811. _STD._springScale._endPosition = _scale.value;
  10812. _STD.setEnd(x, y, scale, 1);
  10813. _SFA = g(_STD, function() {
  10814. let data = _STD.x();
  10815. let x2 = data.x;
  10816. let y2 = data.y;
  10817. let scale2 = data.scale;
  10818. _setTransform(x2, y2, scale2, source, r, o2);
  10819. }, function() {
  10820. _SFA.cancel();
  10821. });
  10822. }
  10823. function _setTransform(x, y, scale, source = "", r, o2) {
  10824. if (!(x !== null && x.toString() !== "NaN" && typeof x === "number")) {
  10825. x = _translateX.value || 0;
  10826. }
  10827. if (!(y !== null && y.toString() !== "NaN" && typeof y === "number")) {
  10828. y = _translateY.value || 0;
  10829. }
  10830. x = Number(x.toFixed(1));
  10831. y = Number(y.toFixed(1));
  10832. scale = Number(scale.toFixed(1));
  10833. if (!(_translateX.value === x && _translateY.value === y)) {
  10834. if (!r) {
  10835. trigger("change", {}, {
  10836. x: v(x, _scaleOffset.x),
  10837. y: v(y, _scaleOffset.y),
  10838. source
  10839. });
  10840. }
  10841. }
  10842. if (!props2.scale) {
  10843. scale = _scale.value;
  10844. }
  10845. scale = _adjustScale(scale);
  10846. scale = +scale.toFixed(3);
  10847. if (o2 && scale !== _scale.value) {
  10848. trigger("scale", {}, {
  10849. x,
  10850. y,
  10851. scale
  10852. });
  10853. }
  10854. let transform = "translateX(" + x + "px) translateY(" + y + "px) translateZ(0px) scale(" + scale + ")";
  10855. if (rootRef.value) {
  10856. rootRef.value.style.transform = transform;
  10857. rootRef.value.style.webkitTransform = transform;
  10858. _translateX.value = x;
  10859. _translateY.value = y;
  10860. _scale.value = scale;
  10861. }
  10862. }
  10863. function _revise(source) {
  10864. let limitXY = _getLimitXY(_translateX.value, _translateY.value);
  10865. let x = limitXY.x;
  10866. let y = limitXY.y;
  10867. let outOfBounds = limitXY.outOfBounds;
  10868. if (outOfBounds) {
  10869. _animationTo(x, y, _scale.value, source);
  10870. }
  10871. return outOfBounds;
  10872. }
  10873. function _setX(val) {
  10874. if (xMove.value) {
  10875. if (val + _scaleOffset.x === _translateX.value) {
  10876. return _translateX;
  10877. } else {
  10878. if (_SFA) {
  10879. _SFA.cancel();
  10880. }
  10881. _animationTo(val + _scaleOffset.x, ySync.value + _scaleOffset.y, _scale.value);
  10882. }
  10883. }
  10884. return val;
  10885. }
  10886. function _setY(val) {
  10887. if (yMove.value) {
  10888. if (val + _scaleOffset.y === _translateY.value) {
  10889. return _translateY;
  10890. } else {
  10891. if (_SFA) {
  10892. _SFA.cancel();
  10893. }
  10894. _animationTo(xSync.value + _scaleOffset.x, val + _scaleOffset.y, _scale.value);
  10895. }
  10896. }
  10897. return val;
  10898. }
  10899. return {
  10900. FAandSFACancel,
  10901. _getLimitXY,
  10902. _animationTo,
  10903. _setTransform,
  10904. _revise,
  10905. dampingNumber,
  10906. xMove,
  10907. yMove,
  10908. xSync,
  10909. ySync,
  10910. _STD
  10911. };
  10912. }
  10913. function useMovableViewInit(props2, rootRef, trigger, _scale, _oldScale, _isScaling, _translateX, _translateY, _SFA, _FA) {
  10914. const scaleMinNumber = computed(() => {
  10915. let val = Number(props2.scaleMin);
  10916. return isNaN(val) ? 0.5 : val;
  10917. });
  10918. const scaleMaxNumber = computed(() => {
  10919. let val = Number(props2.scaleMax);
  10920. return isNaN(val) ? 10 : val;
  10921. });
  10922. const scaleValueSync = ref(Number(props2.scaleValue) || 1);
  10923. watch(scaleValueSync, (val) => {
  10924. _setScaleValue(val);
  10925. });
  10926. watch(scaleMinNumber, () => {
  10927. _setScaleMinOrMax();
  10928. });
  10929. watch(scaleMaxNumber, () => {
  10930. _setScaleMinOrMax();
  10931. });
  10932. watch(() => props2.scaleValue, (val) => {
  10933. scaleValueSync.value = Number(val) || 0;
  10934. });
  10935. const {
  10936. _updateBoundary,
  10937. _updateOffset,
  10938. _updateWH,
  10939. _scaleOffset,
  10940. minX,
  10941. minY,
  10942. maxX,
  10943. maxY
  10944. } = useMovableViewLayout(rootRef, _scale, _adjustScale);
  10945. const {
  10946. FAandSFACancel,
  10947. _getLimitXY,
  10948. _animationTo,
  10949. _setTransform,
  10950. _revise,
  10951. dampingNumber,
  10952. xMove,
  10953. yMove,
  10954. xSync,
  10955. ySync,
  10956. _STD
  10957. } = useMovableViewTransform(rootRef, props2, _scaleOffset, _scale, maxX, maxY, minX, minY, _translateX, _translateY, _SFA, _FA, _adjustScale, trigger);
  10958. function _updateScale(scale, animat) {
  10959. if (props2.scale) {
  10960. scale = _adjustScale(scale);
  10961. _updateWH(scale);
  10962. _updateBoundary();
  10963. const limitXY = _getLimitXY(_translateX.value, _translateY.value);
  10964. const x = limitXY.x;
  10965. const y = limitXY.y;
  10966. if (animat) {
  10967. _animationTo(x, y, scale, "", true, true);
  10968. } else {
  10969. _requestAnimationFrame(function() {
  10970. _setTransform(x, y, scale, "", true, true);
  10971. });
  10972. }
  10973. }
  10974. }
  10975. function _beginScale() {
  10976. _isScaling.value = true;
  10977. }
  10978. function _updateOldScale(scale) {
  10979. _oldScale.value = scale;
  10980. }
  10981. function _adjustScale(scale) {
  10982. scale = Math.max(0.5, scaleMinNumber.value, scale);
  10983. scale = Math.min(10, scaleMaxNumber.value, scale);
  10984. return scale;
  10985. }
  10986. function _setScaleMinOrMax() {
  10987. if (!props2.scale) {
  10988. return false;
  10989. }
  10990. _updateScale(_scale.value, true);
  10991. _updateOldScale(_scale.value);
  10992. }
  10993. function _setScaleValue(scale) {
  10994. if (!props2.scale) {
  10995. return false;
  10996. }
  10997. scale = _adjustScale(scale);
  10998. _updateScale(scale, true);
  10999. _updateOldScale(scale);
  11000. return scale;
  11001. }
  11002. function _endScale() {
  11003. _isScaling.value = false;
  11004. _updateOldScale(_scale.value);
  11005. }
  11006. function _setScale(scale) {
  11007. if (scale) {
  11008. scale = _oldScale.value * scale;
  11009. _beginScale();
  11010. _updateScale(scale);
  11011. }
  11012. }
  11013. return {
  11014. // scale
  11015. _updateOldScale,
  11016. _endScale,
  11017. _setScale,
  11018. scaleValueSync,
  11019. // layout
  11020. _updateBoundary,
  11021. _updateOffset,
  11022. _updateWH,
  11023. _scaleOffset,
  11024. minX,
  11025. minY,
  11026. maxX,
  11027. maxY,
  11028. // transform
  11029. FAandSFACancel,
  11030. _getLimitXY,
  11031. _animationTo,
  11032. _setTransform,
  11033. _revise,
  11034. dampingNumber,
  11035. xMove,
  11036. yMove,
  11037. xSync,
  11038. ySync,
  11039. _STD
  11040. };
  11041. }
  11042. function useMovableViewState(props2, trigger, rootRef) {
  11043. const _isMounted = inject("_isMounted", ref(false));
  11044. const addMovableViewContext = inject("addMovableViewContext", () => {
  11045. });
  11046. const removeMovableViewContext = inject("removeMovableViewContext", () => {
  11047. });
  11048. let _scale = ref(1);
  11049. let _oldScale = ref(1);
  11050. let _isScaling = ref(false);
  11051. let _translateX = ref(0);
  11052. let _translateY = ref(0);
  11053. let _SFA = null;
  11054. let _FA = null;
  11055. let _isTouching = false;
  11056. let __baseX;
  11057. let __baseY;
  11058. let _checkCanMove = null;
  11059. let _firstMoveDirection = null;
  11060. const _declineX = new Decline();
  11061. const _declineY = new Decline();
  11062. const __touchInfo = {
  11063. historyX: [0, 0],
  11064. historyY: [0, 0],
  11065. historyT: [0, 0]
  11066. };
  11067. const frictionNumber = computed(() => {
  11068. let val = Number(props2.friction);
  11069. return isNaN(val) || val <= 0 ? 2 : val;
  11070. });
  11071. const _friction = new Friction$1(1, frictionNumber.value);
  11072. watch(() => props2.disabled, () => {
  11073. __handleTouchStart();
  11074. });
  11075. const {
  11076. // scale
  11077. _updateOldScale,
  11078. _endScale,
  11079. _setScale,
  11080. scaleValueSync,
  11081. // layout
  11082. _updateBoundary,
  11083. _updateOffset,
  11084. _updateWH,
  11085. _scaleOffset,
  11086. minX,
  11087. minY,
  11088. maxX,
  11089. maxY,
  11090. // transform
  11091. FAandSFACancel,
  11092. _getLimitXY,
  11093. _setTransform,
  11094. _revise,
  11095. dampingNumber,
  11096. xMove,
  11097. yMove,
  11098. xSync,
  11099. ySync,
  11100. _STD
  11101. } = useMovableViewInit(props2, rootRef, trigger, _scale, _oldScale, _isScaling, _translateX, _translateY, _SFA, _FA);
  11102. function __handleTouchStart() {
  11103. if (!_isScaling.value) {
  11104. if (!props2.disabled) {
  11105. FAandSFACancel();
  11106. __touchInfo.historyX = [0, 0];
  11107. __touchInfo.historyY = [0, 0];
  11108. __touchInfo.historyT = [0, 0];
  11109. if (xMove.value) {
  11110. __baseX = _translateX.value;
  11111. }
  11112. if (yMove.value) {
  11113. __baseY = _translateY.value;
  11114. }
  11115. rootRef.value.style.willChange = "transform";
  11116. _checkCanMove = null;
  11117. _firstMoveDirection = null;
  11118. _isTouching = true;
  11119. }
  11120. }
  11121. }
  11122. function __handleTouchMove(event) {
  11123. if (!_isScaling.value && !props2.disabled && _isTouching) {
  11124. let x = _translateX.value;
  11125. let y = _translateY.value;
  11126. if (_firstMoveDirection === null) {
  11127. _firstMoveDirection = Math.abs(event.detail.dx / event.detail.dy) > 1 ? "htouchmove" : "vtouchmove";
  11128. }
  11129. if (xMove.value) {
  11130. x = event.detail.dx + __baseX;
  11131. __touchInfo.historyX.shift();
  11132. __touchInfo.historyX.push(x);
  11133. if (!yMove.value && _checkCanMove === null) {
  11134. _checkCanMove = Math.abs(event.detail.dx / event.detail.dy) < 1;
  11135. }
  11136. }
  11137. if (yMove.value) {
  11138. y = event.detail.dy + __baseY;
  11139. __touchInfo.historyY.shift();
  11140. __touchInfo.historyY.push(y);
  11141. if (!xMove.value && _checkCanMove === null) {
  11142. _checkCanMove = Math.abs(event.detail.dy / event.detail.dx) < 1;
  11143. }
  11144. }
  11145. __touchInfo.historyT.shift();
  11146. __touchInfo.historyT.push(event.detail.timeStamp);
  11147. if (!_checkCanMove) {
  11148. event.preventDefault();
  11149. let source = "touch";
  11150. if (x < minX.value) {
  11151. if (props2.outOfBounds) {
  11152. source = "touch-out-of-bounds";
  11153. x = minX.value - _declineX.x(minX.value - x);
  11154. } else {
  11155. x = minX.value;
  11156. }
  11157. } else if (x > maxX.value) {
  11158. if (props2.outOfBounds) {
  11159. source = "touch-out-of-bounds";
  11160. x = maxX.value + _declineX.x(x - maxX.value);
  11161. } else {
  11162. x = maxX.value;
  11163. }
  11164. }
  11165. if (y < minY.value) {
  11166. if (props2.outOfBounds) {
  11167. source = "touch-out-of-bounds";
  11168. y = minY.value - _declineY.x(minY.value - y);
  11169. } else {
  11170. y = minY.value;
  11171. }
  11172. } else {
  11173. if (y > maxY.value) {
  11174. if (props2.outOfBounds) {
  11175. source = "touch-out-of-bounds";
  11176. y = maxY.value + _declineY.x(y - maxY.value);
  11177. } else {
  11178. y = maxY.value;
  11179. }
  11180. }
  11181. }
  11182. _requestAnimationFrame(function() {
  11183. _setTransform(x, y, _scale.value, source);
  11184. });
  11185. }
  11186. }
  11187. }
  11188. function __handleTouchEnd() {
  11189. if (!_isScaling.value && !props2.disabled && _isTouching) {
  11190. rootRef.value.style.willChange = "auto";
  11191. _isTouching = false;
  11192. if (!_checkCanMove && !_revise("out-of-bounds") && props2.inertia) {
  11193. const xv = 1e3 * (__touchInfo.historyX[1] - __touchInfo.historyX[0]) / (__touchInfo.historyT[1] - __touchInfo.historyT[0]);
  11194. const yv = 1e3 * (__touchInfo.historyY[1] - __touchInfo.historyY[0]) / (__touchInfo.historyT[1] - __touchInfo.historyT[0]);
  11195. const __translateX = _translateX.value;
  11196. const __translateY = _translateY.value;
  11197. _friction.setV(xv, yv);
  11198. _friction.setS(__translateX, __translateY);
  11199. const x0 = _friction.delta().x;
  11200. const y0 = _friction.delta().y;
  11201. let x = x0 + __translateX;
  11202. let y = y0 + __translateY;
  11203. if (x < minX.value) {
  11204. x = minX.value;
  11205. y = __translateY + (minX.value - __translateX) * y0 / x0;
  11206. } else {
  11207. if (x > maxX.value) {
  11208. x = maxX.value;
  11209. y = __translateY + (maxX.value - __translateX) * y0 / x0;
  11210. }
  11211. }
  11212. if (y < minY.value) {
  11213. y = minY.value;
  11214. x = __translateX + (minY.value - __translateY) * x0 / y0;
  11215. } else {
  11216. if (y > maxY.value) {
  11217. y = maxY.value;
  11218. x = __translateX + (maxY.value - __translateY) * x0 / y0;
  11219. }
  11220. }
  11221. _friction.setEnd(x, y);
  11222. _FA = g(_friction, function() {
  11223. let t2 = _friction.s();
  11224. let x2 = t2.x;
  11225. let y2 = t2.y;
  11226. _setTransform(x2, y2, _scale.value, "friction");
  11227. }, function() {
  11228. _FA.cancel();
  11229. });
  11230. }
  11231. }
  11232. if (!props2.outOfBounds && !props2.inertia) {
  11233. FAandSFACancel();
  11234. }
  11235. }
  11236. function setParent() {
  11237. if (!_isMounted.value) {
  11238. return;
  11239. }
  11240. FAandSFACancel();
  11241. let scale = props2.scale ? scaleValueSync.value : 1;
  11242. _updateOffset();
  11243. _updateWH(scale);
  11244. _updateBoundary();
  11245. let limitXY = _getLimitXY(xSync.value + _scaleOffset.x, ySync.value + _scaleOffset.y);
  11246. let x = limitXY.x;
  11247. let y = limitXY.y;
  11248. _setTransform(x, y, scale, "", true);
  11249. _updateOldScale(scale);
  11250. }
  11251. onMounted(() => {
  11252. useTouchtrack(rootRef.value, (event) => {
  11253. switch (event.detail.state) {
  11254. case "start":
  11255. __handleTouchStart();
  11256. break;
  11257. case "move":
  11258. __handleTouchMove(event);
  11259. break;
  11260. case "end":
  11261. __handleTouchEnd();
  11262. }
  11263. });
  11264. setParent();
  11265. _friction.reconfigure(1, frictionNumber.value);
  11266. _STD.reconfigure(1, 9 * Math.pow(dampingNumber.value, 2) / 40, dampingNumber.value);
  11267. rootRef.value.style.transformOrigin = "center";
  11268. const context = {
  11269. rootRef,
  11270. setParent,
  11271. _endScale,
  11272. _setScale
  11273. };
  11274. addMovableViewContext(context);
  11275. onUnmounted(() => {
  11276. removeMovableViewContext(context);
  11277. });
  11278. });
  11279. onUnmounted(() => {
  11280. FAandSFACancel();
  11281. });
  11282. return {
  11283. setParent
  11284. };
  11285. }
  11286. const OPEN_TYPES = [
  11287. "navigate",
  11288. "redirect",
  11289. "switchTab",
  11290. "reLaunch",
  11291. "navigateBack"
  11292. ];
  11293. const ANIMATION_IN = [
  11294. "slide-in-right",
  11295. "slide-in-left",
  11296. "slide-in-top",
  11297. "slide-in-bottom",
  11298. "fade-in",
  11299. "zoom-out",
  11300. "zoom-fade-out",
  11301. "pop-in",
  11302. "none"
  11303. ];
  11304. const ANIMATION_OUT = [
  11305. "slide-out-right",
  11306. "slide-out-left",
  11307. "slide-out-top",
  11308. "slide-out-bottom",
  11309. "fade-out",
  11310. "zoom-in",
  11311. "zoom-fade-in",
  11312. "pop-out",
  11313. "none"
  11314. ];
  11315. const navigatorProps = {
  11316. hoverClass: {
  11317. type: String,
  11318. default: "navigator-hover"
  11319. },
  11320. url: {
  11321. type: String,
  11322. default: ""
  11323. },
  11324. openType: {
  11325. type: String,
  11326. default: "navigate",
  11327. validator(value) {
  11328. return Boolean(~OPEN_TYPES.indexOf(value));
  11329. }
  11330. },
  11331. delta: {
  11332. type: Number,
  11333. default: 1
  11334. },
  11335. hoverStartTime: {
  11336. type: [Number, String],
  11337. default: 50
  11338. },
  11339. hoverStayTime: {
  11340. type: [Number, String],
  11341. default: 600
  11342. },
  11343. exists: {
  11344. type: String,
  11345. default: ""
  11346. },
  11347. hoverStopPropagation: {
  11348. type: Boolean,
  11349. default: false
  11350. },
  11351. animationType: {
  11352. type: String,
  11353. default: "",
  11354. validator(value) {
  11355. return !value || ANIMATION_IN.concat(ANIMATION_OUT).includes(value);
  11356. }
  11357. },
  11358. animationDuration: {
  11359. type: [String, Number],
  11360. default: 300
  11361. }
  11362. };
  11363. function createNavigatorOnClick(props2) {
  11364. return () => {
  11365. if (props2.openType !== "navigateBack" && !props2.url) {
  11366. console.error(
  11367. "<navigator/> should have url attribute when using navigateTo, redirectTo, reLaunch or switchTab"
  11368. );
  11369. return;
  11370. }
  11371. const animationDuration = parseInt(props2.animationDuration);
  11372. switch (props2.openType) {
  11373. case "navigate":
  11374. uni.navigateTo({
  11375. url: props2.url,
  11376. animationType: props2.animationType || "pop-in",
  11377. animationDuration
  11378. });
  11379. break;
  11380. case "redirect":
  11381. uni.redirectTo({
  11382. url: props2.url,
  11383. // @ts-ignore
  11384. exists: props2.exists
  11385. });
  11386. break;
  11387. case "switchTab":
  11388. uni.switchTab({
  11389. url: props2.url
  11390. });
  11391. break;
  11392. case "reLaunch":
  11393. uni.reLaunch({
  11394. url: props2.url
  11395. });
  11396. break;
  11397. case "navigateBack":
  11398. uni.navigateBack({
  11399. delta: props2.delta,
  11400. animationType: props2.animationType || "pop-out",
  11401. animationDuration
  11402. });
  11403. break;
  11404. }
  11405. };
  11406. }
  11407. const index$p = /* @__PURE__ */ defineBuiltInComponent({
  11408. name: "Navigator",
  11409. inheritAttrs: false,
  11410. compatConfig: {
  11411. MODE: 3
  11412. },
  11413. props: extend({}, navigatorProps, {
  11414. renderLink: {
  11415. type: Boolean,
  11416. default: true
  11417. }
  11418. }),
  11419. setup(props2, {
  11420. slots
  11421. }) {
  11422. const rootRef = ref(null);
  11423. const vm = getCurrentInstance();
  11424. const __scopeId = vm && vm.vnode.scopeId || "";
  11425. const {
  11426. hovering,
  11427. binding
  11428. } = useHover(props2);
  11429. const onClick = createNavigatorOnClick(props2);
  11430. return () => {
  11431. const {
  11432. hoverClass,
  11433. url
  11434. } = props2;
  11435. const hasHoverClass = props2.hoverClass && props2.hoverClass !== "none";
  11436. const innerNode = props2.renderLink ? createVNode("a", {
  11437. "class": "navigator-wrap",
  11438. "href": url,
  11439. "onClick": onEventPrevent,
  11440. "onMousedown": onEventPrevent
  11441. }, [slots.default && slots.default()], 40, ["href", "onClick", "onMousedown"]) : slots.default && slots.default();
  11442. return createVNode("uni-navigator", mergeProps({
  11443. "class": hasHoverClass && hovering.value ? hoverClass : "",
  11444. "ref": rootRef
  11445. }, hasHoverClass && binding, vm ? vm.attrs : {}, {
  11446. [__scopeId]: ""
  11447. }, {
  11448. "onClick": onClick
  11449. }), [innerNode], 16, ["onClick"]);
  11450. };
  11451. }
  11452. });
  11453. const pickerViewProps = {
  11454. value: {
  11455. type: Array,
  11456. default() {
  11457. return [];
  11458. },
  11459. validator: function(val) {
  11460. return isArray(val) && val.filter((val2) => typeof val2 === "number").length === val.length;
  11461. }
  11462. },
  11463. indicatorStyle: {
  11464. type: String,
  11465. default: ""
  11466. },
  11467. indicatorClass: {
  11468. type: String,
  11469. default: ""
  11470. },
  11471. maskStyle: {
  11472. type: String,
  11473. default: ""
  11474. },
  11475. maskClass: {
  11476. type: String,
  11477. default: ""
  11478. }
  11479. };
  11480. function useState$4(props2) {
  11481. const value = reactive([...props2.value]);
  11482. const state2 = reactive({
  11483. value,
  11484. height: 34
  11485. });
  11486. watch(() => props2.value, (val, oldVal) => {
  11487. {
  11488. state2.value.length = val.length;
  11489. val.forEach((val2, index2) => {
  11490. if (val2 !== state2.value[index2]) {
  11491. state2.value.splice(index2, 1, val2);
  11492. }
  11493. });
  11494. }
  11495. });
  11496. return state2;
  11497. }
  11498. const PickerView = /* @__PURE__ */ defineBuiltInComponent({
  11499. name: "PickerView",
  11500. props: pickerViewProps,
  11501. emits: ["change", "pickstart", "pickend", "update:value"],
  11502. setup(props2, {
  11503. slots,
  11504. emit: emit2
  11505. }) {
  11506. const rootRef = ref(null);
  11507. const wrapperRef = ref(null);
  11508. const trigger = useCustomEvent(rootRef, emit2);
  11509. const state2 = useState$4(props2);
  11510. const resizeSensorRef = ref(null);
  11511. const onMountedCallback = () => {
  11512. const resizeSensor = resizeSensorRef.value;
  11513. resizeSensor && (state2.height = resizeSensor.$el.offsetHeight);
  11514. };
  11515. {
  11516. onMounted(onMountedCallback);
  11517. }
  11518. let ColumnsPreRef = ref([]);
  11519. let columnsRef = ref([]);
  11520. function getItemIndex(vnode) {
  11521. let columnVNodes = columnsRef.value;
  11522. {
  11523. columnVNodes = columnVNodes.filter((vnode2) => vnode2.type !== Comment);
  11524. }
  11525. let index2 = columnVNodes.indexOf(vnode);
  11526. return index2 !== -1 ? index2 : ColumnsPreRef.value.indexOf(vnode);
  11527. }
  11528. const getPickerViewColumn = function(columnInstance) {
  11529. const ref2 = computed({
  11530. get() {
  11531. const index2 = getItemIndex(columnInstance.vnode);
  11532. return state2.value[index2] || 0;
  11533. },
  11534. set(current) {
  11535. const index2 = getItemIndex(columnInstance.vnode);
  11536. if (index2 < 0) {
  11537. return;
  11538. }
  11539. const oldCurrent = state2.value[index2];
  11540. if (oldCurrent !== current) {
  11541. state2.value[index2] = current;
  11542. const value = state2.value.map((val) => val);
  11543. emit2("update:value", value);
  11544. trigger("change", {}, {
  11545. value
  11546. });
  11547. }
  11548. }
  11549. });
  11550. return ref2;
  11551. };
  11552. provide("getPickerViewColumn", getPickerViewColumn);
  11553. provide("pickerViewProps", props2);
  11554. provide("pickerViewState", state2);
  11555. return () => {
  11556. const defaultSlots = slots.default && slots.default();
  11557. {
  11558. const vnode = flatVNode(defaultSlots);
  11559. ColumnsPreRef.value = vnode;
  11560. nextTick(() => {
  11561. columnsRef.value = vnode;
  11562. });
  11563. }
  11564. return createVNode("uni-picker-view", {
  11565. "ref": rootRef
  11566. }, [createVNode(ResizeSensor, {
  11567. "ref": resizeSensorRef,
  11568. "onResize": ({
  11569. height
  11570. }) => state2.height = height
  11571. }, null, 8, ["onResize"]), createVNode("div", {
  11572. "ref": wrapperRef,
  11573. "class": "uni-picker-view-wrapper"
  11574. }, [defaultSlots], 512)], 512);
  11575. };
  11576. }
  11577. });
  11578. class Friction {
  11579. constructor(drag) {
  11580. this._drag = drag;
  11581. this._dragLog = Math.log(drag);
  11582. this._x = 0;
  11583. this._v = 0;
  11584. this._startTime = 0;
  11585. }
  11586. set(x, v2) {
  11587. this._x = x;
  11588. this._v = v2;
  11589. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  11590. }
  11591. setVelocityByEnd(e2) {
  11592. this._v = (e2 - this._x) * this._dragLog / (Math.pow(this._drag, 100) - 1);
  11593. }
  11594. x(e2) {
  11595. if (e2 === void 0) {
  11596. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  11597. }
  11598. const t2 = e2 === this._dt && this._powDragDt ? this._powDragDt : this._powDragDt = Math.pow(this._drag, e2);
  11599. this._dt = e2;
  11600. return this._x + this._v * t2 / this._dragLog - this._v / this._dragLog;
  11601. }
  11602. dx(e2) {
  11603. if (e2 === void 0) {
  11604. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  11605. }
  11606. const t2 = e2 === this._dt && this._powDragDt ? this._powDragDt : this._powDragDt = Math.pow(this._drag, e2);
  11607. this._dt = e2;
  11608. return this._v * t2;
  11609. }
  11610. done() {
  11611. return Math.abs(this.dx()) < 3;
  11612. }
  11613. reconfigure(e2) {
  11614. const t2 = this.x();
  11615. const n = this.dx();
  11616. this._drag = e2;
  11617. this._dragLog = Math.log(e2);
  11618. this.set(t2, n);
  11619. }
  11620. configuration() {
  11621. const e2 = this;
  11622. return [
  11623. {
  11624. label: "Friction",
  11625. read: function() {
  11626. return e2._drag;
  11627. },
  11628. write: function(t2) {
  11629. e2.reconfigure(t2);
  11630. },
  11631. min: 1e-3,
  11632. max: 0.1,
  11633. step: 1e-3
  11634. }
  11635. ];
  11636. }
  11637. }
  11638. function o(e2, t2, n) {
  11639. return e2 > t2 - n && e2 < t2 + n;
  11640. }
  11641. function a(e2, t2) {
  11642. return o(e2, 0, t2);
  11643. }
  11644. class Spring {
  11645. constructor(m, k, c) {
  11646. this._m = m;
  11647. this._k = k;
  11648. this._c = c;
  11649. this._solution = null;
  11650. this._endPosition = 0;
  11651. this._startTime = 0;
  11652. }
  11653. _solve(e2, t2) {
  11654. const n = this._c;
  11655. const i = this._m;
  11656. const r = this._k;
  11657. const o2 = n * n - 4 * i * r;
  11658. if (o2 === 0) {
  11659. const a3 = -n / (2 * i);
  11660. const s2 = e2;
  11661. const l2 = t2 / (a3 * e2);
  11662. return {
  11663. x: function(e22) {
  11664. return (s2 + l2 * e22) * Math.pow(Math.E, a3 * e22);
  11665. },
  11666. dx: function(e22) {
  11667. const t22 = Math.pow(Math.E, a3 * e22);
  11668. return a3 * (s2 + l2 * e22) * t22 + l2 * t22;
  11669. }
  11670. };
  11671. }
  11672. if (o2 > 0) {
  11673. const c = (-n - Math.sqrt(o2)) / (2 * i);
  11674. const u = (-n + Math.sqrt(o2)) / (2 * i);
  11675. const l2 = (t2 - c * e2) / (u - c);
  11676. const s2 = e2 - l2;
  11677. return {
  11678. x: function(e22) {
  11679. let t22;
  11680. let n2;
  11681. if (e22 === this._t) {
  11682. t22 = this._powER1T;
  11683. n2 = this._powER2T;
  11684. }
  11685. this._t = e22;
  11686. if (!t22) {
  11687. t22 = this._powER1T = Math.pow(Math.E, c * e22);
  11688. }
  11689. if (!n2) {
  11690. n2 = this._powER2T = Math.pow(Math.E, u * e22);
  11691. }
  11692. return s2 * t22 + l2 * n2;
  11693. },
  11694. dx: function(e22) {
  11695. let t22;
  11696. let n2;
  11697. if (e22 === this._t) {
  11698. t22 = this._powER1T;
  11699. n2 = this._powER2T;
  11700. }
  11701. this._t = e22;
  11702. if (!t22) {
  11703. t22 = this._powER1T = Math.pow(Math.E, c * e22);
  11704. }
  11705. if (!n2) {
  11706. n2 = this._powER2T = Math.pow(Math.E, u * e22);
  11707. }
  11708. return s2 * c * t22 + l2 * u * n2;
  11709. }
  11710. };
  11711. }
  11712. const d = Math.sqrt(4 * i * r - n * n) / (2 * i);
  11713. const a2 = -n / 2 * i;
  11714. const s = e2;
  11715. const l = (t2 - a2 * e2) / d;
  11716. return {
  11717. x: function(e22) {
  11718. return Math.pow(Math.E, a2 * e22) * (s * Math.cos(d * e22) + l * Math.sin(d * e22));
  11719. },
  11720. dx: function(e22) {
  11721. const t22 = Math.pow(Math.E, a2 * e22);
  11722. const n2 = Math.cos(d * e22);
  11723. const i2 = Math.sin(d * e22);
  11724. return t22 * (l * d * n2 - s * d * i2) + a2 * t22 * (l * i2 + s * n2);
  11725. }
  11726. };
  11727. }
  11728. x(e2) {
  11729. if (e2 === void 0) {
  11730. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  11731. }
  11732. return this._solution ? this._endPosition + this._solution.x(e2) : 0;
  11733. }
  11734. dx(e2) {
  11735. if (e2 === void 0) {
  11736. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  11737. }
  11738. return this._solution ? this._solution.dx(e2) : 0;
  11739. }
  11740. setEnd(e2, t2, n) {
  11741. if (!n) {
  11742. n = (/* @__PURE__ */ new Date()).getTime();
  11743. }
  11744. if (e2 !== this._endPosition || !a(t2, 0.4)) {
  11745. t2 = t2 || 0;
  11746. let i = this._endPosition;
  11747. if (this._solution) {
  11748. if (a(t2, 0.4)) {
  11749. t2 = this._solution.dx((n - this._startTime) / 1e3);
  11750. }
  11751. i = this._solution.x((n - this._startTime) / 1e3);
  11752. if (a(t2, 0.4)) {
  11753. t2 = 0;
  11754. }
  11755. if (a(i, 0.4)) {
  11756. i = 0;
  11757. }
  11758. i += this._endPosition;
  11759. }
  11760. if (!(this._solution && a(i - e2, 0.4) && a(t2, 0.4))) {
  11761. this._endPosition = e2;
  11762. this._solution = this._solve(i - this._endPosition, t2);
  11763. this._startTime = n;
  11764. }
  11765. }
  11766. }
  11767. snap(e2) {
  11768. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  11769. this._endPosition = e2;
  11770. this._solution = {
  11771. x: function() {
  11772. return 0;
  11773. },
  11774. dx: function() {
  11775. return 0;
  11776. }
  11777. };
  11778. }
  11779. done(e2) {
  11780. if (!e2) {
  11781. e2 = (/* @__PURE__ */ new Date()).getTime();
  11782. }
  11783. return o(this.x(), this._endPosition, 0.4) && a(this.dx(), 0.4);
  11784. }
  11785. reconfigure(e2, t2, n) {
  11786. this._m = e2;
  11787. this._k = t2;
  11788. this._c = n;
  11789. if (!this.done()) {
  11790. this._solution = this._solve(this.x() - this._endPosition, this.dx());
  11791. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  11792. }
  11793. }
  11794. springConstant() {
  11795. return this._k;
  11796. }
  11797. damping() {
  11798. return this._c;
  11799. }
  11800. configuration() {
  11801. function e2(e22, t22) {
  11802. e22.reconfigure(1, t22, e22.damping());
  11803. }
  11804. function t2(e22, t22) {
  11805. e22.reconfigure(1, e22.springConstant(), t22);
  11806. }
  11807. return [
  11808. {
  11809. label: "Spring Constant",
  11810. read: this.springConstant.bind(this),
  11811. write: e2.bind(this, this),
  11812. min: 100,
  11813. max: 1e3
  11814. },
  11815. {
  11816. label: "Damping",
  11817. read: this.damping.bind(this),
  11818. write: t2.bind(this, this),
  11819. min: 1,
  11820. max: 500
  11821. }
  11822. ];
  11823. }
  11824. }
  11825. class Scroll {
  11826. constructor(extent, friction, spring) {
  11827. this._extent = extent;
  11828. this._friction = friction || new Friction(0.01);
  11829. this._spring = spring || new Spring(1, 90, 20);
  11830. this._startTime = 0;
  11831. this._springing = false;
  11832. this._springOffset = 0;
  11833. }
  11834. snap(e2, t2) {
  11835. this._springOffset = 0;
  11836. this._springing = true;
  11837. this._spring.snap(e2);
  11838. this._spring.setEnd(t2);
  11839. }
  11840. set(e2, t2) {
  11841. this._friction.set(e2, t2);
  11842. if (e2 > 0 && t2 >= 0) {
  11843. this._springOffset = 0;
  11844. this._springing = true;
  11845. this._spring.snap(e2);
  11846. this._spring.setEnd(0);
  11847. } else {
  11848. if (e2 < -this._extent && t2 <= 0) {
  11849. this._springOffset = 0;
  11850. this._springing = true;
  11851. this._spring.snap(e2);
  11852. this._spring.setEnd(-this._extent);
  11853. } else {
  11854. this._springing = false;
  11855. }
  11856. }
  11857. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  11858. }
  11859. x(e2) {
  11860. if (!this._startTime) {
  11861. return 0;
  11862. }
  11863. if (!e2) {
  11864. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  11865. }
  11866. if (this._springing) {
  11867. return this._spring.x() + this._springOffset;
  11868. }
  11869. let t2 = this._friction.x(e2);
  11870. let n = this.dx(e2);
  11871. if (t2 > 0 && n >= 0 || t2 < -this._extent && n <= 0) {
  11872. this._springing = true;
  11873. this._spring.setEnd(0, n);
  11874. if (t2 < -this._extent) {
  11875. this._springOffset = -this._extent;
  11876. } else {
  11877. this._springOffset = 0;
  11878. }
  11879. t2 = this._spring.x() + this._springOffset;
  11880. }
  11881. return t2;
  11882. }
  11883. dx(e2) {
  11884. let t2;
  11885. if (this._lastTime === e2) {
  11886. t2 = this._lastDx;
  11887. } else {
  11888. t2 = this._springing ? this._spring.dx(e2) : this._friction.dx(e2);
  11889. }
  11890. this._lastTime = e2;
  11891. this._lastDx = t2;
  11892. return t2;
  11893. }
  11894. done() {
  11895. return this._springing ? this._spring.done() : this._friction.done();
  11896. }
  11897. setVelocityByEnd(e2) {
  11898. this._friction.setVelocityByEnd(e2);
  11899. }
  11900. configuration() {
  11901. const e2 = this._friction.configuration();
  11902. e2.push.apply(e2, this._spring.configuration());
  11903. return e2;
  11904. }
  11905. }
  11906. function createAnimation(scroll, onScroll, onEnd) {
  11907. const state2 = {
  11908. id: 0,
  11909. cancelled: false
  11910. };
  11911. function startAnimation2(state22, scroll2, onScroll2, onEnd2) {
  11912. if (!state22 || !state22.cancelled) {
  11913. onScroll2(scroll2);
  11914. const isDone = scroll2.done();
  11915. if (!isDone) {
  11916. if (!state22.cancelled) {
  11917. state22.id = requestAnimationFrame(
  11918. startAnimation2.bind(null, state22, scroll2, onScroll2, onEnd2)
  11919. );
  11920. }
  11921. }
  11922. if (isDone && onEnd2) {
  11923. onEnd2(scroll2);
  11924. }
  11925. }
  11926. }
  11927. function cancel(state22) {
  11928. if (state22 && state22.id) {
  11929. cancelAnimationFrame(state22.id);
  11930. }
  11931. if (state22) {
  11932. state22.cancelled = true;
  11933. }
  11934. }
  11935. startAnimation2(state2, scroll, onScroll, onEnd);
  11936. return {
  11937. cancel: cancel.bind(null, state2),
  11938. model: scroll
  11939. };
  11940. }
  11941. class Scroller {
  11942. constructor(element, options) {
  11943. options = options || {};
  11944. this._element = element;
  11945. this._options = options;
  11946. this._enableSnap = options.enableSnap || false;
  11947. this._itemSize = options.itemSize || 0;
  11948. this._enableX = options.enableX || false;
  11949. this._enableY = options.enableY || false;
  11950. this._shouldDispatchScrollEvent = !!options.onScroll;
  11951. if (this._enableX) {
  11952. this._extent = (options.scrollWidth || this._element.offsetWidth) - this._element.parentElement.offsetWidth;
  11953. this._scrollWidth = options.scrollWidth;
  11954. } else {
  11955. this._extent = (options.scrollHeight || this._element.offsetHeight) - this._element.parentElement.offsetHeight;
  11956. this._scrollHeight = options.scrollHeight;
  11957. }
  11958. this._position = 0;
  11959. this._scroll = new Scroll(this._extent, options.friction, options.spring);
  11960. this._onTransitionEnd = this.onTransitionEnd.bind(this);
  11961. this.updatePosition();
  11962. }
  11963. onTouchStart() {
  11964. this._startPosition = this._position;
  11965. this._lastChangePos = this._startPosition;
  11966. if (this._startPosition > 0) {
  11967. this._startPosition /= 0.5;
  11968. } else {
  11969. if (this._startPosition < -this._extent) {
  11970. this._startPosition = (this._startPosition + this._extent) / 0.5 - this._extent;
  11971. }
  11972. }
  11973. if (this._animation) {
  11974. this._animation.cancel();
  11975. this._scrolling = false;
  11976. }
  11977. this.updatePosition();
  11978. }
  11979. onTouchMove(x, y) {
  11980. let startPosition = this._startPosition;
  11981. if (this._enableX) {
  11982. startPosition += x;
  11983. } else if (this._enableY) {
  11984. startPosition += y;
  11985. }
  11986. if (startPosition > 0) {
  11987. startPosition *= 0.5;
  11988. } else if (startPosition < -this._extent) {
  11989. startPosition = 0.5 * (startPosition + this._extent) - this._extent;
  11990. }
  11991. this._position = startPosition;
  11992. this.updatePosition();
  11993. this.dispatchScroll();
  11994. }
  11995. onTouchEnd(x, y, o2) {
  11996. if (this._enableSnap && this._position > -this._extent && this._position < 0) {
  11997. if (this._enableY && (Math.abs(y) < this._itemSize && Math.abs(o2.y) < 300 || Math.abs(o2.y) < 150)) {
  11998. this.snap();
  11999. return;
  12000. }
  12001. if (this._enableX && (Math.abs(x) < this._itemSize && Math.abs(o2.x) < 300 || Math.abs(o2.x) < 150)) {
  12002. this.snap();
  12003. return;
  12004. }
  12005. }
  12006. if (this._enableX) {
  12007. this._scroll.set(this._position, o2.x);
  12008. } else if (this._enableY) {
  12009. this._scroll.set(this._position, o2.y);
  12010. }
  12011. let c;
  12012. if (this._enableSnap) {
  12013. const s = this._scroll._friction.x(100);
  12014. const l = s % this._itemSize;
  12015. c = Math.abs(l) > this._itemSize / 2 ? s - (this._itemSize - Math.abs(l)) : s - l;
  12016. if (c <= 0 && c >= -this._extent) {
  12017. this._scroll.setVelocityByEnd(c);
  12018. }
  12019. }
  12020. this._lastTime = Date.now();
  12021. this._lastDelay = 0;
  12022. this._scrolling = true;
  12023. this._lastChangePos = this._position;
  12024. this._lastIdx = Math.floor(Math.abs(this._position / this._itemSize));
  12025. this._animation = createAnimation(
  12026. this._scroll,
  12027. () => {
  12028. const e2 = Date.now();
  12029. const i = (e2 - this._scroll._startTime) / 1e3;
  12030. const r = this._scroll.x(i);
  12031. this._position = r;
  12032. this.updatePosition();
  12033. const o22 = this._scroll.dx(i);
  12034. if (this._shouldDispatchScrollEvent && e2 - this._lastTime > this._lastDelay) {
  12035. this.dispatchScroll();
  12036. this._lastDelay = Math.abs(2e3 / o22);
  12037. this._lastTime = e2;
  12038. }
  12039. },
  12040. () => {
  12041. if (this._enableSnap) {
  12042. if (c <= 0 && c >= -this._extent) {
  12043. this._position = c;
  12044. this.updatePosition();
  12045. }
  12046. if (isFunction(this._options.onSnap)) {
  12047. this._options.onSnap(
  12048. Math.floor(Math.abs(this._position) / this._itemSize)
  12049. );
  12050. }
  12051. }
  12052. if (this._shouldDispatchScrollEvent) {
  12053. this.dispatchScroll();
  12054. }
  12055. this._scrolling = false;
  12056. }
  12057. );
  12058. }
  12059. onTransitionEnd() {
  12060. this._element.style.webkitTransition = "";
  12061. this._element.style.transition = "";
  12062. this._element.removeEventListener("transitionend", this._onTransitionEnd);
  12063. if (this._snapping) {
  12064. this._snapping = false;
  12065. }
  12066. this.dispatchScroll();
  12067. }
  12068. snap() {
  12069. const itemSize = this._itemSize;
  12070. const position = this._position % itemSize;
  12071. const i = Math.abs(position) > this._itemSize / 2 ? this._position - (itemSize - Math.abs(position)) : this._position - position;
  12072. if (this._position !== i) {
  12073. this._snapping = true;
  12074. this.scrollTo(-i);
  12075. if (isFunction(this._options.onSnap)) {
  12076. this._options.onSnap(
  12077. Math.floor(Math.abs(this._position) / this._itemSize)
  12078. );
  12079. }
  12080. }
  12081. }
  12082. scrollTo(position, time) {
  12083. if (this._animation) {
  12084. this._animation.cancel();
  12085. this._scrolling = false;
  12086. }
  12087. if (typeof position === "number") {
  12088. this._position = -position;
  12089. }
  12090. if (this._position < -this._extent) {
  12091. this._position = -this._extent;
  12092. } else {
  12093. if (this._position > 0) {
  12094. this._position = 0;
  12095. }
  12096. }
  12097. const transition = "transform " + (time || 0.2) + "s ease-out";
  12098. this._element.style.webkitTransition = "-webkit-" + transition;
  12099. this._element.style.transition = transition;
  12100. this.updatePosition();
  12101. this._element.addEventListener("transitionend", this._onTransitionEnd);
  12102. }
  12103. dispatchScroll() {
  12104. if (isFunction(this._options.onScroll) && Math.round(Number(this._lastPos)) !== Math.round(this._position)) {
  12105. this._lastPos = this._position;
  12106. const event = {
  12107. target: {
  12108. scrollLeft: this._enableX ? -this._position : 0,
  12109. scrollTop: this._enableY ? -this._position : 0,
  12110. scrollHeight: this._scrollHeight || this._element.offsetHeight,
  12111. scrollWidth: this._scrollWidth || this._element.offsetWidth,
  12112. offsetHeight: this._element.parentElement.offsetHeight,
  12113. offsetWidth: this._element.parentElement.offsetWidth
  12114. }
  12115. };
  12116. this._options.onScroll(event);
  12117. }
  12118. }
  12119. update(height, scrollHeight, itemSize) {
  12120. let extent = 0;
  12121. const position = this._position;
  12122. if (this._enableX) {
  12123. extent = this._element.childNodes.length ? (scrollHeight || this._element.offsetWidth) - this._element.parentElement.offsetWidth : 0;
  12124. this._scrollWidth = scrollHeight;
  12125. } else {
  12126. extent = this._element.childNodes.length ? (scrollHeight || this._element.offsetHeight) - this._element.parentElement.offsetHeight : 0;
  12127. this._scrollHeight = scrollHeight;
  12128. }
  12129. if (typeof height === "number") {
  12130. this._position = -height;
  12131. }
  12132. if (this._position < -extent) {
  12133. this._position = -extent;
  12134. } else {
  12135. if (this._position > 0) {
  12136. this._position = 0;
  12137. }
  12138. }
  12139. this._itemSize = itemSize || this._itemSize;
  12140. this.updatePosition();
  12141. if (position !== this._position) {
  12142. this.dispatchScroll();
  12143. if (isFunction(this._options.onSnap)) {
  12144. this._options.onSnap(
  12145. Math.floor(Math.abs(this._position) / this._itemSize)
  12146. );
  12147. }
  12148. }
  12149. this._extent = extent;
  12150. this._scroll._extent = extent;
  12151. }
  12152. updatePosition() {
  12153. let transform = "";
  12154. if (this._enableX) {
  12155. transform = "translateX(" + this._position + "px) translateZ(0)";
  12156. } else {
  12157. if (this._enableY) {
  12158. transform = "translateY(" + this._position + "px) translateZ(0)";
  12159. }
  12160. }
  12161. this._element.style.webkitTransform = transform;
  12162. this._element.style.transform = transform;
  12163. }
  12164. isScrolling() {
  12165. return this._scrolling || this._snapping;
  12166. }
  12167. }
  12168. function useScroller(element, options) {
  12169. const touchInfo = {
  12170. trackingID: -1,
  12171. maxDy: 0,
  12172. maxDx: 0
  12173. };
  12174. const scroller = new Scroller(element, options);
  12175. function findDelta(event) {
  12176. const touchtrackEvent = event;
  12177. const mouseEvent = event;
  12178. return touchtrackEvent.detail.state === "move" || touchtrackEvent.detail.state === "end" ? {
  12179. x: touchtrackEvent.detail.dx,
  12180. y: touchtrackEvent.detail.dy
  12181. } : {
  12182. x: mouseEvent.screenX - touchInfo.x,
  12183. y: mouseEvent.screenY - touchInfo.y
  12184. };
  12185. }
  12186. function handleTouchStart(event) {
  12187. const touchtrackEvent = event;
  12188. const mouseEvent = event;
  12189. if (touchtrackEvent.detail.state === "start") {
  12190. touchInfo.trackingID = "touch";
  12191. touchInfo.x = touchtrackEvent.detail.x;
  12192. touchInfo.y = touchtrackEvent.detail.y;
  12193. } else {
  12194. touchInfo.trackingID = "mouse";
  12195. touchInfo.x = mouseEvent.screenX;
  12196. touchInfo.y = mouseEvent.screenY;
  12197. }
  12198. touchInfo.maxDx = 0;
  12199. touchInfo.maxDy = 0;
  12200. touchInfo.historyX = [0];
  12201. touchInfo.historyY = [0];
  12202. touchInfo.historyTime = [
  12203. touchtrackEvent.detail.timeStamp || mouseEvent.timeStamp
  12204. ];
  12205. touchInfo.listener = scroller;
  12206. if (scroller.onTouchStart) {
  12207. scroller.onTouchStart();
  12208. }
  12209. if (typeof event.cancelable !== "boolean" || event.cancelable)
  12210. event.preventDefault();
  12211. }
  12212. function handleTouchMove(event) {
  12213. const touchtrackEvent = event;
  12214. const mouseEvent = event;
  12215. if (touchInfo.trackingID !== -1) {
  12216. if (typeof event.cancelable !== "boolean" || event.cancelable)
  12217. event.preventDefault();
  12218. const delta = findDelta(event);
  12219. if (delta) {
  12220. for (touchInfo.maxDy = Math.max(touchInfo.maxDy, Math.abs(delta.y)), touchInfo.maxDx = Math.max(touchInfo.maxDx, Math.abs(delta.x)), touchInfo.historyX.push(delta.x), touchInfo.historyY.push(delta.y), touchInfo.historyTime.push(
  12221. touchtrackEvent.detail.timeStamp || mouseEvent.timeStamp
  12222. ); touchInfo.historyTime.length > 10; ) {
  12223. touchInfo.historyTime.shift();
  12224. touchInfo.historyX.shift();
  12225. touchInfo.historyY.shift();
  12226. }
  12227. if (touchInfo.listener && touchInfo.listener.onTouchMove) {
  12228. touchInfo.listener.onTouchMove(delta.x, delta.y);
  12229. }
  12230. }
  12231. }
  12232. }
  12233. function handleTouchEnd(event) {
  12234. if (touchInfo.trackingID !== -1) {
  12235. event.preventDefault();
  12236. const delta = findDelta(event);
  12237. if (delta) {
  12238. const listener2 = touchInfo.listener;
  12239. touchInfo.trackingID = -1;
  12240. touchInfo.listener = null;
  12241. const length = touchInfo.historyTime.length;
  12242. const o2 = {
  12243. x: 0,
  12244. y: 0
  12245. };
  12246. if (length > 2) {
  12247. for (let i = touchInfo.historyTime.length - 1, time1 = touchInfo.historyTime[i], x = touchInfo.historyX[i], y = touchInfo.historyY[i]; i > 0; ) {
  12248. i--;
  12249. const time0 = touchInfo.historyTime[i];
  12250. const time = time1 - time0;
  12251. if (time > 30 && time < 50) {
  12252. o2.x = (x - touchInfo.historyX[i]) / (time / 1e3);
  12253. o2.y = (y - touchInfo.historyY[i]) / (time / 1e3);
  12254. break;
  12255. }
  12256. }
  12257. }
  12258. touchInfo.historyTime = [];
  12259. touchInfo.historyX = [];
  12260. touchInfo.historyY = [];
  12261. if (listener2 && listener2.onTouchEnd) {
  12262. listener2.onTouchEnd(delta.x, delta.y, o2);
  12263. }
  12264. }
  12265. }
  12266. }
  12267. return {
  12268. scroller,
  12269. handleTouchStart,
  12270. handleTouchMove,
  12271. handleTouchEnd
  12272. };
  12273. }
  12274. let scopedIndex = 0;
  12275. function useScopedClass(indicatorHeightRef) {
  12276. const className = `uni-picker-view-content-${scopedIndex++}`;
  12277. function updateStyle2() {
  12278. const style = document.createElement("style");
  12279. style.innerText = `.uni-picker-view-content.${className}>*{height: ${indicatorHeightRef.value}px;overflow: hidden;}`;
  12280. document.head.appendChild(style);
  12281. }
  12282. watch(() => indicatorHeightRef.value, updateStyle2);
  12283. return className;
  12284. }
  12285. function useCustomClick(dom) {
  12286. const MAX_MOVE = 20;
  12287. let x = 0;
  12288. let y = 0;
  12289. dom.addEventListener("touchstart", (event) => {
  12290. const info = event.changedTouches[0];
  12291. x = info.clientX;
  12292. y = info.clientY;
  12293. });
  12294. dom.addEventListener("touchend", (event) => {
  12295. const info = event.changedTouches[0];
  12296. if (Math.abs(info.clientX - x) < MAX_MOVE && Math.abs(info.clientY - y) < MAX_MOVE) {
  12297. const options = {
  12298. bubbles: true,
  12299. cancelable: true,
  12300. target: event.target,
  12301. currentTarget: event.currentTarget
  12302. };
  12303. const customClick = new CustomEvent("click", options);
  12304. const props2 = ["screenX", "screenY", "clientX", "clientY", "pageX", "pageY"];
  12305. props2.forEach((key) => {
  12306. customClick[key] = info[key];
  12307. });
  12308. event.target.dispatchEvent(customClick);
  12309. }
  12310. });
  12311. }
  12312. const PickerViewColumn = /* @__PURE__ */ defineBuiltInComponent({
  12313. name: "PickerViewColumn",
  12314. setup(props2, {
  12315. slots,
  12316. emit: emit2
  12317. }) {
  12318. const rootRef = ref(null);
  12319. const contentRef = ref(null);
  12320. const getPickerViewColumn = inject("getPickerViewColumn");
  12321. const instance2 = getCurrentInstance();
  12322. const currentRef = getPickerViewColumn ? getPickerViewColumn(instance2) : ref(0);
  12323. const pickerViewProps2 = inject("pickerViewProps");
  12324. const pickerViewState = inject("pickerViewState");
  12325. const indicatorHeight = ref(34);
  12326. const resizeSensorRef = ref(null);
  12327. const initIndicatorHeight = () => {
  12328. const resizeSensor = resizeSensorRef.value;
  12329. indicatorHeight.value = resizeSensor.$el.offsetHeight;
  12330. };
  12331. {
  12332. onMounted(initIndicatorHeight);
  12333. }
  12334. const maskSize = computed(() => (pickerViewState.height - indicatorHeight.value) / 2);
  12335. const {
  12336. state: scopedAttrsState
  12337. } = useScopedAttrs();
  12338. const className = useScopedClass(indicatorHeight);
  12339. let scroller;
  12340. const state2 = reactive({
  12341. current: currentRef.value,
  12342. length: 0
  12343. });
  12344. let updatesScrollerRequest;
  12345. function updatesScroller() {
  12346. if (scroller && !updatesScrollerRequest) {
  12347. updatesScrollerRequest = true;
  12348. nextTick(() => {
  12349. updatesScrollerRequest = false;
  12350. let current = Math.min(state2.current, state2.length - 1);
  12351. current = Math.max(current, 0);
  12352. scroller.update(current * indicatorHeight.value, void 0, indicatorHeight.value);
  12353. });
  12354. }
  12355. }
  12356. watch(() => currentRef.value, (current) => {
  12357. if (current !== state2.current) {
  12358. state2.current = current;
  12359. updatesScroller();
  12360. }
  12361. });
  12362. watch(() => state2.current, (current) => currentRef.value = current);
  12363. watch([() => indicatorHeight.value, () => state2.length, () => pickerViewState.height], updatesScroller);
  12364. let oldDeltaY = 0;
  12365. function handleWheel(event) {
  12366. const deltaY = oldDeltaY + event.deltaY;
  12367. if (Math.abs(deltaY) > 10) {
  12368. oldDeltaY = 0;
  12369. let current = Math.min(state2.current + (deltaY < 0 ? -1 : 1), state2.length - 1);
  12370. state2.current = current = Math.max(current, 0);
  12371. scroller.scrollTo(current * indicatorHeight.value);
  12372. } else {
  12373. oldDeltaY = deltaY;
  12374. }
  12375. event.preventDefault();
  12376. }
  12377. function handleTap({
  12378. clientY
  12379. }) {
  12380. const el = rootRef.value;
  12381. if (!scroller.isScrolling()) {
  12382. const rect = el.getBoundingClientRect();
  12383. const r = clientY - rect.top - pickerViewState.height / 2;
  12384. const o2 = indicatorHeight.value / 2;
  12385. if (!(Math.abs(r) <= o2)) {
  12386. const a2 = Math.ceil((Math.abs(r) - o2) / indicatorHeight.value);
  12387. const s = r < 0 ? -a2 : a2;
  12388. let current = Math.min(state2.current + s, state2.length - 1);
  12389. state2.current = current = Math.max(current, 0);
  12390. scroller.scrollTo(current * indicatorHeight.value);
  12391. }
  12392. }
  12393. }
  12394. const initScroller = () => {
  12395. const el = rootRef.value;
  12396. const content = contentRef.value;
  12397. const {
  12398. scroller: scrollerOrigin,
  12399. handleTouchStart,
  12400. handleTouchMove,
  12401. handleTouchEnd
  12402. } = useScroller(content, {
  12403. enableY: true,
  12404. enableX: false,
  12405. enableSnap: true,
  12406. itemSize: indicatorHeight.value,
  12407. friction: new Friction(1e-4),
  12408. spring: new Spring(2, 90, 20),
  12409. onSnap: (index2) => {
  12410. if (!isNaN(index2) && index2 !== state2.current) {
  12411. state2.current = index2;
  12412. }
  12413. }
  12414. });
  12415. scroller = scrollerOrigin;
  12416. useTouchtrack(el, (e2) => {
  12417. switch (e2.detail.state) {
  12418. case "start":
  12419. handleTouchStart(e2);
  12420. break;
  12421. case "move":
  12422. handleTouchMove(e2);
  12423. e2.stopPropagation();
  12424. break;
  12425. case "end":
  12426. case "cancel":
  12427. handleTouchEnd(e2);
  12428. }
  12429. }, true);
  12430. useCustomClick(el);
  12431. updatesScroller();
  12432. };
  12433. {
  12434. onMounted(initScroller);
  12435. }
  12436. return () => {
  12437. const defaultSlots = slots.default && slots.default();
  12438. {
  12439. state2.length = flatVNode(defaultSlots).length;
  12440. }
  12441. const padding = `${maskSize.value}px 0`;
  12442. return createVNode("uni-picker-view-column", {
  12443. "ref": rootRef
  12444. }, [createVNode("div", {
  12445. "onWheel": handleWheel,
  12446. "onClick": handleTap,
  12447. "class": "uni-picker-view-group"
  12448. }, [createVNode("div", mergeProps(scopedAttrsState.attrs, {
  12449. "class": ["uni-picker-view-mask", pickerViewProps2.maskClass],
  12450. "style": `background-size: 100% ${maskSize.value}px;${pickerViewProps2.maskStyle}`
  12451. }), null, 16), createVNode("div", mergeProps(scopedAttrsState.attrs, {
  12452. "class": ["uni-picker-view-indicator", pickerViewProps2.indicatorClass],
  12453. "style": pickerViewProps2.indicatorStyle
  12454. }), [createVNode(ResizeSensor, {
  12455. "ref": resizeSensorRef,
  12456. "onResize": ({
  12457. height
  12458. }) => indicatorHeight.value = height
  12459. }, null, 8, ["onResize"])], 16), createVNode("div", {
  12460. "ref": contentRef,
  12461. "class": ["uni-picker-view-content", className],
  12462. "style": {
  12463. padding
  12464. }
  12465. }, [defaultSlots], 6)], 40, ["onWheel", "onClick"])], 512);
  12466. };
  12467. }
  12468. });
  12469. const FONT_SIZE = 16;
  12470. const PROGRESS_VALUES = {
  12471. activeColor: PRIMARY_COLOR,
  12472. backgroundColor: "#EBEBEB",
  12473. activeMode: "backwards"
  12474. };
  12475. const progressProps = {
  12476. percent: {
  12477. type: [Number, String],
  12478. default: 0,
  12479. validator(value) {
  12480. return !isNaN(parseFloat(value));
  12481. }
  12482. },
  12483. fontSize: {
  12484. type: [String, Number],
  12485. default: FONT_SIZE
  12486. },
  12487. showInfo: {
  12488. type: [Boolean, String],
  12489. default: false
  12490. },
  12491. strokeWidth: {
  12492. type: [Number, String],
  12493. default: 6,
  12494. validator(value) {
  12495. return !isNaN(parseFloat(value));
  12496. }
  12497. },
  12498. color: {
  12499. type: String,
  12500. default: PROGRESS_VALUES.activeColor
  12501. },
  12502. activeColor: {
  12503. type: String,
  12504. default: PROGRESS_VALUES.activeColor
  12505. },
  12506. backgroundColor: {
  12507. type: String,
  12508. default: PROGRESS_VALUES.backgroundColor
  12509. },
  12510. active: {
  12511. type: [Boolean, String],
  12512. default: false
  12513. },
  12514. activeMode: {
  12515. type: String,
  12516. default: PROGRESS_VALUES.activeMode
  12517. },
  12518. duration: {
  12519. type: [Number, String],
  12520. default: 30,
  12521. validator(value) {
  12522. return !isNaN(parseFloat(value));
  12523. }
  12524. },
  12525. borderRadius: {
  12526. type: [Number, String],
  12527. default: 0
  12528. }
  12529. };
  12530. const index$o = /* @__PURE__ */ defineBuiltInComponent({
  12531. name: "Progress",
  12532. props: progressProps,
  12533. setup(props2) {
  12534. const rootRef = ref(null);
  12535. const state2 = useProgressState(props2);
  12536. _activeAnimation(state2, props2);
  12537. watch(() => state2.realPercent, (newValue, oldValue) => {
  12538. state2.strokeTimer && clearInterval(state2.strokeTimer);
  12539. state2.lastPercent = oldValue || 0;
  12540. _activeAnimation(state2, props2);
  12541. });
  12542. return () => {
  12543. const {
  12544. showInfo
  12545. } = props2;
  12546. const {
  12547. outerBarStyle,
  12548. innerBarStyle,
  12549. currentPercent
  12550. } = state2;
  12551. return createVNode("uni-progress", {
  12552. "class": "uni-progress",
  12553. "ref": rootRef
  12554. }, [createVNode("div", {
  12555. "style": outerBarStyle,
  12556. "class": "uni-progress-bar"
  12557. }, [createVNode("div", {
  12558. "style": innerBarStyle,
  12559. "class": "uni-progress-inner-bar"
  12560. }, null, 4)], 4), showInfo ? (
  12561. // {currentPercent}% 的写法会影响 SSR Hydration (tsx插件的问题)
  12562. createVNode("p", {
  12563. "class": "uni-progress-info"
  12564. }, [currentPercent + "%"])
  12565. ) : ""], 512);
  12566. };
  12567. }
  12568. });
  12569. function useProgressState(props2) {
  12570. const currentPercent = ref(0);
  12571. const outerBarStyle = computed(() => `background-color: ${props2.backgroundColor}; height: ${props2.strokeWidth}px;`);
  12572. const innerBarStyle = computed(() => {
  12573. const backgroundColor = props2.color !== PROGRESS_VALUES.activeColor && props2.activeColor === PROGRESS_VALUES.activeColor ? props2.color : props2.activeColor;
  12574. return `width: ${currentPercent.value}%;background-color: ${backgroundColor}`;
  12575. });
  12576. const realPercent = computed(() => {
  12577. let realValue = parseFloat(props2.percent);
  12578. realValue < 0 && (realValue = 0);
  12579. realValue > 100 && (realValue = 100);
  12580. return realValue;
  12581. });
  12582. const state2 = reactive({
  12583. outerBarStyle,
  12584. innerBarStyle,
  12585. realPercent,
  12586. currentPercent,
  12587. strokeTimer: 0,
  12588. lastPercent: 0
  12589. });
  12590. return state2;
  12591. }
  12592. function _activeAnimation(state2, props2) {
  12593. if (props2.active) {
  12594. state2.currentPercent = props2.activeMode === PROGRESS_VALUES.activeMode ? 0 : state2.lastPercent;
  12595. state2.strokeTimer = setInterval(() => {
  12596. if (state2.currentPercent + 1 > state2.realPercent) {
  12597. state2.currentPercent = state2.realPercent;
  12598. state2.strokeTimer && clearInterval(state2.strokeTimer);
  12599. } else {
  12600. state2.currentPercent += 1;
  12601. }
  12602. }, parseFloat(props2.duration));
  12603. } else {
  12604. state2.currentPercent = state2.realPercent;
  12605. }
  12606. }
  12607. const uniRadioGroupKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniCheckGroup" : "ucg");
  12608. const props$p = {
  12609. name: {
  12610. type: String,
  12611. default: ""
  12612. }
  12613. };
  12614. const index$n = /* @__PURE__ */ defineBuiltInComponent({
  12615. name: "RadioGroup",
  12616. props: props$p,
  12617. // emits: ['change'],
  12618. setup(props2, {
  12619. emit: emit2,
  12620. slots
  12621. }) {
  12622. const rootRef = ref(null);
  12623. const trigger = useCustomEvent(rootRef, emit2);
  12624. useProvideRadioGroup(props2, trigger);
  12625. return () => {
  12626. return createVNode("uni-radio-group", {
  12627. "ref": rootRef
  12628. }, [slots.default && slots.default()], 512);
  12629. };
  12630. }
  12631. });
  12632. function useProvideRadioGroup(props2, trigger) {
  12633. const fields2 = [];
  12634. onMounted(() => {
  12635. _resetRadioGroupValue(fields2.length - 1);
  12636. });
  12637. const getFieldsValue = () => {
  12638. var _a;
  12639. return (_a = fields2.find((field) => field.value.radioChecked)) == null ? void 0 : _a.value.value;
  12640. };
  12641. provide(uniRadioGroupKey, {
  12642. addField(field) {
  12643. fields2.push(field);
  12644. },
  12645. removeField(field) {
  12646. fields2.splice(fields2.indexOf(field), 1);
  12647. },
  12648. radioChange($event, field) {
  12649. const index2 = fields2.indexOf(field);
  12650. _resetRadioGroupValue(index2, true);
  12651. trigger("change", $event, {
  12652. value: getFieldsValue()
  12653. });
  12654. }
  12655. });
  12656. const uniForm = inject(uniFormKey, false);
  12657. const formField = {
  12658. submit: () => {
  12659. let data = ["", null];
  12660. if (props2.name !== "") {
  12661. data[0] = props2.name;
  12662. data[1] = getFieldsValue();
  12663. }
  12664. return data;
  12665. }
  12666. };
  12667. if (uniForm) {
  12668. uniForm.addField(formField);
  12669. onBeforeUnmount(() => {
  12670. uniForm.removeField(formField);
  12671. });
  12672. }
  12673. function setFieldChecked(field, radioChecked) {
  12674. field.value = {
  12675. radioChecked,
  12676. value: field.value.value
  12677. };
  12678. }
  12679. function _resetRadioGroupValue(key, change) {
  12680. fields2.forEach((value, index2) => {
  12681. if (index2 === key) {
  12682. return;
  12683. }
  12684. if (change) {
  12685. setFieldChecked(fields2[index2], false);
  12686. } else {
  12687. fields2.forEach((v2, i) => {
  12688. if (index2 >= i) {
  12689. return;
  12690. }
  12691. if (fields2[i].value.radioChecked) {
  12692. setFieldChecked(fields2[index2], false);
  12693. }
  12694. });
  12695. }
  12696. });
  12697. }
  12698. return fields2;
  12699. }
  12700. const props$o = {
  12701. checked: {
  12702. type: [Boolean, String],
  12703. default: false
  12704. },
  12705. id: {
  12706. type: String,
  12707. default: ""
  12708. },
  12709. disabled: {
  12710. type: [Boolean, String],
  12711. default: false
  12712. },
  12713. value: {
  12714. type: String,
  12715. default: ""
  12716. },
  12717. color: {
  12718. type: String,
  12719. default: "#007aff"
  12720. },
  12721. backgroundColor: {
  12722. type: String,
  12723. default: ""
  12724. },
  12725. borderColor: {
  12726. type: String,
  12727. default: ""
  12728. },
  12729. activeBackgroundColor: {
  12730. type: String,
  12731. default: ""
  12732. },
  12733. activeBorderColor: {
  12734. type: String,
  12735. default: ""
  12736. },
  12737. iconColor: {
  12738. type: String,
  12739. default: "#ffffff"
  12740. }
  12741. };
  12742. const index$m = /* @__PURE__ */ defineBuiltInComponent({
  12743. name: "Radio",
  12744. props: props$o,
  12745. setup(props2, {
  12746. slots
  12747. }) {
  12748. const rootRef = ref(null);
  12749. const radioChecked = ref(props2.checked);
  12750. const radioValue = ref(props2.value);
  12751. function getRadioStyle(checked) {
  12752. if (props2.disabled) {
  12753. return {
  12754. backgroundColor: "#E1E1E1",
  12755. borderColor: "#D1D1D1"
  12756. };
  12757. }
  12758. const style = {};
  12759. if (radioChecked.value) {
  12760. style.backgroundColor = props2.activeBackgroundColor || props2.color;
  12761. style.borderColor = props2.activeBorderColor || style.backgroundColor;
  12762. } else {
  12763. if (props2.borderColor)
  12764. style.borderColor = props2.borderColor;
  12765. if (props2.backgroundColor)
  12766. style.backgroundColor = props2.backgroundColor;
  12767. }
  12768. return style;
  12769. }
  12770. const radioStyle = computed(() => {
  12771. return getRadioStyle(radioChecked.value);
  12772. });
  12773. watch([() => props2.checked, () => props2.value], ([newChecked, newModelValue]) => {
  12774. radioChecked.value = newChecked;
  12775. radioValue.value = newModelValue;
  12776. });
  12777. const reset = () => {
  12778. radioChecked.value = false;
  12779. };
  12780. const {
  12781. uniCheckGroup,
  12782. uniLabel,
  12783. field
  12784. } = useRadioInject(radioChecked, radioValue, reset);
  12785. const _onClick = ($event) => {
  12786. if (props2.disabled || radioChecked.value) {
  12787. return;
  12788. }
  12789. radioChecked.value = true;
  12790. uniCheckGroup && uniCheckGroup.radioChange($event, field);
  12791. $event.stopPropagation();
  12792. };
  12793. if (!!uniLabel) {
  12794. uniLabel.addHandler(_onClick);
  12795. onBeforeUnmount(() => {
  12796. uniLabel.removeHandler(_onClick);
  12797. });
  12798. }
  12799. useListeners$1(props2, {
  12800. "label-click": _onClick
  12801. });
  12802. return () => {
  12803. const booleanAttrs = useBooleanAttr(props2, "disabled");
  12804. let realCheckValue;
  12805. realCheckValue = radioChecked.value;
  12806. return createVNode("uni-radio", mergeProps(booleanAttrs, {
  12807. "id": props2.id,
  12808. "onClick": _onClick,
  12809. "ref": rootRef
  12810. }), [createVNode("div", {
  12811. "class": "uni-radio-wrapper",
  12812. "style": {
  12813. "--HOVER-BD-COLOR": !radioChecked.value ? props2.activeBorderColor : radioStyle.value.borderColor
  12814. }
  12815. }, [createVNode("div", {
  12816. "class": ["uni-radio-input", {
  12817. "uni-radio-input-disabled": props2.disabled
  12818. }],
  12819. "style": radioStyle.value
  12820. }, [realCheckValue ? createSvgIconVNode(ICON_PATH_SUCCESS_NO_CIRCLE, props2.disabled ? "#ADADAD" : props2.iconColor, 18) : ""], 6), slots.default && slots.default()], 4)], 16, ["id", "onClick"]);
  12821. };
  12822. }
  12823. });
  12824. function useRadioInject(radioChecked, radioValue, reset) {
  12825. const field = computed({
  12826. get: () => ({
  12827. radioChecked: Boolean(radioChecked.value),
  12828. value: radioValue.value
  12829. }),
  12830. set: ({
  12831. radioChecked: checked
  12832. }) => {
  12833. radioChecked.value = checked;
  12834. }
  12835. });
  12836. const formField = {
  12837. reset
  12838. };
  12839. const uniCheckGroup = inject(uniRadioGroupKey, false);
  12840. if (!!uniCheckGroup) {
  12841. uniCheckGroup.addField(field);
  12842. }
  12843. const uniForm = inject(uniFormKey, false);
  12844. if (!!uniForm) {
  12845. uniForm.addField(formField);
  12846. }
  12847. const uniLabel = inject(uniLabelKey, false);
  12848. onBeforeUnmount(() => {
  12849. uniCheckGroup && uniCheckGroup.removeField(field);
  12850. uniForm && uniForm.removeField(formField);
  12851. });
  12852. return {
  12853. uniCheckGroup,
  12854. uniForm,
  12855. uniLabel,
  12856. field
  12857. };
  12858. }
  12859. const TAGS = {
  12860. a: "",
  12861. abbr: "",
  12862. address: "",
  12863. article: "",
  12864. aside: "",
  12865. b: "",
  12866. bdi: "",
  12867. bdo: ["dir"],
  12868. big: "",
  12869. blockquote: "",
  12870. br: "",
  12871. caption: "",
  12872. center: "",
  12873. cite: "",
  12874. code: "",
  12875. col: ["span", "width"],
  12876. colgroup: ["span", "width"],
  12877. dd: "",
  12878. del: "",
  12879. div: "",
  12880. dl: "",
  12881. dt: "",
  12882. em: "",
  12883. fieldset: "",
  12884. font: "",
  12885. footer: "",
  12886. h1: "",
  12887. h2: "",
  12888. h3: "",
  12889. h4: "",
  12890. h5: "",
  12891. h6: "",
  12892. header: "",
  12893. hr: "",
  12894. i: "",
  12895. img: ["alt", "src", "height", "width"],
  12896. ins: "",
  12897. label: "",
  12898. legend: "",
  12899. li: "",
  12900. mark: "",
  12901. nav: "",
  12902. ol: ["start", "type"],
  12903. p: "",
  12904. pre: "",
  12905. q: "",
  12906. rt: "",
  12907. ruby: "",
  12908. s: "",
  12909. section: "",
  12910. small: "",
  12911. span: "",
  12912. strong: "",
  12913. sub: "",
  12914. sup: "",
  12915. table: ["width"],
  12916. tbody: "",
  12917. td: ["colspan", "height", "rowspan", "width"],
  12918. tfoot: "",
  12919. th: ["colspan", "height", "rowspan", "width"],
  12920. thead: "",
  12921. tr: ["colspan", "height", "rowspan", "width"],
  12922. tt: "",
  12923. u: "",
  12924. ul: ""
  12925. };
  12926. const CHARS = {
  12927. amp: "&",
  12928. gt: ">",
  12929. lt: "<",
  12930. nbsp: " ",
  12931. quot: '"',
  12932. apos: "'",
  12933. ldquo: "“",
  12934. rdquo: "”",
  12935. yen: "¥",
  12936. radic: "√",
  12937. lceil: "⌈",
  12938. rceil: "⌉",
  12939. lfloor: "⌊",
  12940. rfloor: "⌋",
  12941. hellip: "…"
  12942. };
  12943. function decodeEntities(htmlString) {
  12944. return htmlString.replace(
  12945. /&(([a-zA-Z]+)|(#x{0,1}[\da-zA-Z]+));/gi,
  12946. function(match, stage) {
  12947. if (hasOwn(CHARS, stage) && CHARS[stage]) {
  12948. return CHARS[stage];
  12949. }
  12950. if (/^#[0-9]{1,4}$/.test(stage)) {
  12951. return String.fromCharCode(stage.slice(1));
  12952. }
  12953. if (/^#x[0-9a-f]{1,4}$/i.test(stage)) {
  12954. return String.fromCharCode(0 + stage.slice(1));
  12955. }
  12956. return match;
  12957. }
  12958. );
  12959. }
  12960. function processClickEvent(node, triggerItemClick) {
  12961. if (["a", "img"].includes(node.name) && triggerItemClick) {
  12962. return {
  12963. onClick: (e2) => {
  12964. triggerItemClick(e2, { node });
  12965. e2.stopPropagation();
  12966. e2.preventDefault();
  12967. e2.returnValue = false;
  12968. }
  12969. };
  12970. }
  12971. }
  12972. function normalizeAttrs(tagName, attrs2) {
  12973. if (!isPlainObject(attrs2))
  12974. return;
  12975. for (const key in attrs2) {
  12976. if (hasOwn(attrs2, key)) {
  12977. const value = attrs2[key];
  12978. if (tagName === "img" && key === "src")
  12979. attrs2[key] = getRealPath(value);
  12980. }
  12981. }
  12982. }
  12983. const nodeList2VNode = (scopeId, triggerItemClick, nodeList) => {
  12984. if (!nodeList || isArray(nodeList) && !nodeList.length)
  12985. return [];
  12986. return nodeList.map((node) => {
  12987. if (!isPlainObject(node)) {
  12988. return;
  12989. }
  12990. if (!hasOwn(node, "type") || node.type === "node") {
  12991. let nodeProps = { [scopeId]: "" };
  12992. const tagName = node.name.toLowerCase();
  12993. if (!hasOwn(TAGS, tagName)) {
  12994. return;
  12995. }
  12996. normalizeAttrs(tagName, node.attrs);
  12997. nodeProps = extend(
  12998. nodeProps,
  12999. processClickEvent(node, triggerItemClick),
  13000. node.attrs
  13001. );
  13002. return h(
  13003. node.name,
  13004. nodeProps,
  13005. nodeList2VNode(scopeId, triggerItemClick, node.children)
  13006. );
  13007. }
  13008. if (node.type === "text" && isString(node.text) && node.text !== "")
  13009. return createTextVNode(decodeEntities(node.text || ""));
  13010. });
  13011. };
  13012. function removeDOCTYPE(html) {
  13013. return html.replace(/<\?xml.*\?>\n/, "").replace(/<!doctype.*>\n/, "").replace(/<!DOCTYPE.*>\n/, "");
  13014. }
  13015. function parseAttrs(attrs2) {
  13016. return attrs2.reduce(function(pre, attr2) {
  13017. let value = attr2.value;
  13018. const name = attr2.name;
  13019. if (value.match(/ /) && ["style", "src"].indexOf(name) === -1) {
  13020. value = value.split(" ");
  13021. }
  13022. if (pre[name]) {
  13023. if (Array.isArray(pre[name])) {
  13024. pre[name].push(value);
  13025. } else {
  13026. pre[name] = [pre[name], value];
  13027. }
  13028. } else {
  13029. pre[name] = value;
  13030. }
  13031. return pre;
  13032. }, {});
  13033. }
  13034. function parseHtml(html) {
  13035. html = removeDOCTYPE(html);
  13036. const stacks = [];
  13037. const results = {
  13038. node: "root",
  13039. children: []
  13040. };
  13041. HTMLParser(html, {
  13042. start: function(tag, attrs2, unary) {
  13043. const node = {
  13044. name: tag
  13045. };
  13046. if (attrs2.length !== 0) {
  13047. node.attrs = parseAttrs(attrs2);
  13048. }
  13049. if (unary) {
  13050. const parent = stacks[0] || results;
  13051. if (!parent.children) {
  13052. parent.children = [];
  13053. }
  13054. parent.children.push(node);
  13055. } else {
  13056. stacks.unshift(node);
  13057. }
  13058. },
  13059. end: function(tag) {
  13060. const node = stacks.shift();
  13061. if (node.name !== tag)
  13062. console.error("invalid state: mismatch end tag");
  13063. if (stacks.length === 0) {
  13064. results.children.push(node);
  13065. } else {
  13066. const parent = stacks[0];
  13067. if (!parent.children) {
  13068. parent.children = [];
  13069. }
  13070. parent.children.push(node);
  13071. }
  13072. },
  13073. chars: function(text2) {
  13074. const node = {
  13075. type: "text",
  13076. text: text2
  13077. };
  13078. if (stacks.length === 0) {
  13079. results.children.push(node);
  13080. } else {
  13081. const parent = stacks[0];
  13082. if (!parent.children) {
  13083. parent.children = [];
  13084. }
  13085. parent.children.push(node);
  13086. }
  13087. },
  13088. comment: function(text2) {
  13089. const node = {
  13090. node: "comment",
  13091. text: text2
  13092. };
  13093. const parent = stacks[0];
  13094. if (!parent.children) {
  13095. parent.children = [];
  13096. }
  13097. parent.children.push(node);
  13098. }
  13099. });
  13100. return results.children;
  13101. }
  13102. const props$n = {
  13103. nodes: {
  13104. type: [Array, String],
  13105. default: function() {
  13106. return [];
  13107. }
  13108. }
  13109. };
  13110. const index$l = /* @__PURE__ */ defineBuiltInComponent({
  13111. name: "RichText",
  13112. compatConfig: {
  13113. MODE: 3
  13114. },
  13115. props: props$n,
  13116. emits: ["click", "touchstart", "touchmove", "touchcancel", "touchend", "longpress", "itemclick"],
  13117. setup(props2, {
  13118. emit: emit2
  13119. }) {
  13120. const vm = getCurrentInstance();
  13121. const scopeId = vm && vm.vnode.scopeId || "";
  13122. const rootRef = ref(null);
  13123. const _vnode = ref([]);
  13124. const trigger = useCustomEvent(rootRef, emit2);
  13125. function triggerItemClick(e2, detail = {}) {
  13126. trigger("itemclick", e2, detail);
  13127. }
  13128. function renderVNode() {
  13129. let nodeList = props2.nodes;
  13130. if (isString(nodeList)) {
  13131. nodeList = parseHtml(props2.nodes);
  13132. }
  13133. _vnode.value = nodeList2VNode(scopeId, triggerItemClick, nodeList);
  13134. }
  13135. watch(() => props2.nodes, renderVNode, {
  13136. immediate: true
  13137. });
  13138. return () => h("uni-rich-text", {
  13139. ref: rootRef
  13140. }, h("div", {}, _vnode.value));
  13141. }
  13142. });
  13143. const passiveOptions = /* @__PURE__ */ passive(true);
  13144. const props$m = {
  13145. direction: {
  13146. type: [String],
  13147. default: "vertical"
  13148. },
  13149. scrollX: {
  13150. type: [Boolean, String],
  13151. default: false
  13152. },
  13153. scrollY: {
  13154. type: [Boolean, String],
  13155. default: false
  13156. },
  13157. showScrollbar: {
  13158. type: [Boolean, String],
  13159. default: true
  13160. },
  13161. upperThreshold: {
  13162. type: [Number, String],
  13163. default: 50
  13164. },
  13165. lowerThreshold: {
  13166. type: [Number, String],
  13167. default: 50
  13168. },
  13169. scrollTop: {
  13170. type: [Number, String],
  13171. default: 0
  13172. },
  13173. scrollLeft: {
  13174. type: [Number, String],
  13175. default: 0
  13176. },
  13177. scrollIntoView: {
  13178. type: String,
  13179. default: ""
  13180. },
  13181. scrollWithAnimation: {
  13182. type: [Boolean, String],
  13183. default: false
  13184. },
  13185. enableBackToTop: {
  13186. type: [Boolean, String],
  13187. default: false
  13188. },
  13189. refresherEnabled: {
  13190. type: [Boolean, String],
  13191. default: false
  13192. },
  13193. refresherThreshold: {
  13194. type: Number,
  13195. default: 45
  13196. },
  13197. refresherDefaultStyle: {
  13198. type: String,
  13199. default: "back"
  13200. },
  13201. refresherBackground: {
  13202. type: String,
  13203. default: "#fff"
  13204. },
  13205. refresherTriggered: {
  13206. type: [Boolean, String],
  13207. default: false
  13208. }
  13209. };
  13210. const ScrollView = /* @__PURE__ */ defineBuiltInComponent({
  13211. name: "ScrollView",
  13212. compatConfig: {
  13213. MODE: 3
  13214. },
  13215. props: props$m,
  13216. emits: ["scroll", "scrolltoupper", "scrolltolower", "refresherrefresh", "refresherrestore", "refresherpulling", "refresherabort", "update:refresherTriggered"],
  13217. setup(props2, {
  13218. emit: emit2,
  13219. slots
  13220. }) {
  13221. const rootRef = ref(null);
  13222. const main = ref(null);
  13223. const wrap = ref(null);
  13224. const content = ref(null);
  13225. const refresherinner = ref(null);
  13226. const trigger = useCustomEvent(rootRef, emit2);
  13227. const {
  13228. state: state2,
  13229. scrollTopNumber,
  13230. scrollLeftNumber
  13231. } = useScrollViewState(props2);
  13232. const {
  13233. realScrollX,
  13234. realScrollY
  13235. } = useScrollViewLoader(props2, state2, scrollTopNumber, scrollLeftNumber, trigger, rootRef, main, content, emit2);
  13236. const mainStyle = computed(() => {
  13237. let style = "";
  13238. realScrollX.value ? style += "overflow-x:auto;" : style += "overflow-x:hidden;";
  13239. realScrollY.value ? style += "overflow-y:auto;" : style += "overflow-y:hidden;";
  13240. return style;
  13241. });
  13242. const scrollBarClassName = computed(() => {
  13243. let className = "uni-scroll-view";
  13244. if (props2.showScrollbar === false) {
  13245. className += " uni-scroll-view-scrollbar-hidden";
  13246. }
  13247. return className;
  13248. });
  13249. return () => {
  13250. const {
  13251. refresherEnabled,
  13252. refresherBackground,
  13253. refresherDefaultStyle
  13254. } = props2;
  13255. const {
  13256. refresherHeight,
  13257. refreshState,
  13258. refreshRotate
  13259. } = state2;
  13260. return createVNode("uni-scroll-view", {
  13261. "ref": rootRef
  13262. }, [createVNode("div", {
  13263. "ref": wrap,
  13264. "class": "uni-scroll-view"
  13265. }, [createVNode("div", {
  13266. "ref": main,
  13267. "style": mainStyle.value,
  13268. "class": scrollBarClassName.value
  13269. }, [createVNode("div", {
  13270. "ref": content,
  13271. "class": "uni-scroll-view-content"
  13272. }, [refresherEnabled ? createVNode("div", {
  13273. "ref": refresherinner,
  13274. "style": {
  13275. backgroundColor: refresherBackground,
  13276. height: refresherHeight + "px"
  13277. },
  13278. "class": "uni-scroll-view-refresher"
  13279. }, [refresherDefaultStyle !== "none" ? createVNode("div", {
  13280. "class": "uni-scroll-view-refresh"
  13281. }, [createVNode("div", {
  13282. "class": "uni-scroll-view-refresh-inner"
  13283. }, [refreshState == "pulling" ? createVNode("svg", {
  13284. "key": "refresh__icon",
  13285. "style": {
  13286. transform: "rotate(" + refreshRotate + "deg)"
  13287. },
  13288. "fill": "#2BD009",
  13289. "class": "uni-scroll-view-refresh__icon",
  13290. "width": "24",
  13291. "height": "24",
  13292. "viewBox": "0 0 24 24"
  13293. }, [createVNode("path", {
  13294. "d": "M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z"
  13295. }, null), createVNode("path", {
  13296. "d": "M0 0h24v24H0z",
  13297. "fill": "none"
  13298. }, null)], 4) : null, refreshState == "refreshing" ? createVNode("svg", {
  13299. "key": "refresh__spinner",
  13300. "class": "uni-scroll-view-refresh__spinner",
  13301. "width": "24",
  13302. "height": "24",
  13303. "viewBox": "25 25 50 50"
  13304. }, [createVNode("circle", {
  13305. "cx": "50",
  13306. "cy": "50",
  13307. "r": "20",
  13308. "fill": "none",
  13309. "style": "color: #2bd009",
  13310. "stroke-width": "3"
  13311. }, null)]) : null])]) : null, refresherDefaultStyle == "none" ? slots.refresher && slots.refresher() : null], 4) : null, slots.default && slots.default()], 512)], 6)], 512)], 512);
  13312. };
  13313. }
  13314. });
  13315. function useScrollViewState(props2) {
  13316. const scrollTopNumber = computed(() => {
  13317. return Number(props2.scrollTop) || 0;
  13318. });
  13319. const scrollLeftNumber = computed(() => {
  13320. return Number(props2.scrollLeft) || 0;
  13321. });
  13322. const state2 = reactive({
  13323. lastScrollTop: scrollTopNumber.value,
  13324. lastScrollLeft: scrollLeftNumber.value,
  13325. lastScrollToUpperTime: 0,
  13326. lastScrollToLowerTime: 0,
  13327. refresherHeight: 0,
  13328. refreshRotate: 0,
  13329. refreshState: ""
  13330. });
  13331. return {
  13332. state: state2,
  13333. scrollTopNumber,
  13334. scrollLeftNumber
  13335. };
  13336. }
  13337. function useScrollViewLoader(props2, state2, scrollTopNumber, scrollLeftNumber, trigger, rootRef, main, content, emit2) {
  13338. let beforeRefreshing = false;
  13339. let toUpperNumber = 0;
  13340. let triggerAbort = false;
  13341. let __transitionEnd = () => {
  13342. };
  13343. const realScrollX = computed(() => {
  13344. return props2.scrollX;
  13345. });
  13346. const realScrollY = computed(() => {
  13347. return props2.scrollY;
  13348. });
  13349. const upperThresholdNumber = computed(() => {
  13350. let val = Number(props2.upperThreshold);
  13351. return isNaN(val) ? 50 : val;
  13352. });
  13353. const lowerThresholdNumber = computed(() => {
  13354. let val = Number(props2.lowerThreshold);
  13355. return isNaN(val) ? 50 : val;
  13356. });
  13357. function scrollTo2(scrollToValue, direction2) {
  13358. const container = main.value;
  13359. let transformValue = 0;
  13360. let transform = "";
  13361. scrollToValue < 0 ? scrollToValue = 0 : direction2 === "x" && scrollToValue > container.scrollWidth - container.offsetWidth ? scrollToValue = container.scrollWidth - container.offsetWidth : direction2 === "y" && scrollToValue > container.scrollHeight - container.offsetHeight && (scrollToValue = container.scrollHeight - container.offsetHeight);
  13362. direction2 === "x" ? transformValue = container.scrollLeft - scrollToValue : direction2 === "y" && (transformValue = container.scrollTop - scrollToValue);
  13363. if (transformValue === 0)
  13364. return;
  13365. let _content = content.value;
  13366. _content.style.transition = "transform .3s ease-out";
  13367. _content.style.webkitTransition = "-webkit-transform .3s ease-out";
  13368. if (direction2 === "x") {
  13369. transform = "translateX(" + transformValue + "px) translateZ(0)";
  13370. } else {
  13371. direction2 === "y" && (transform = "translateY(" + transformValue + "px) translateZ(0)");
  13372. }
  13373. _content.removeEventListener("transitionend", __transitionEnd);
  13374. _content.removeEventListener("webkitTransitionEnd", __transitionEnd);
  13375. __transitionEnd = () => _transitionEnd(scrollToValue, direction2);
  13376. _content.addEventListener("transitionend", __transitionEnd);
  13377. _content.addEventListener("webkitTransitionEnd", __transitionEnd);
  13378. if (direction2 === "x") {
  13379. container.style.overflowX = "hidden";
  13380. } else if (direction2 === "y") {
  13381. container.style.overflowY = "hidden";
  13382. }
  13383. _content.style.transform = transform;
  13384. _content.style.webkitTransform = transform;
  13385. }
  13386. function _handleScroll($event) {
  13387. const target = $event.target;
  13388. trigger("scroll", $event, {
  13389. scrollLeft: target.scrollLeft,
  13390. scrollTop: target.scrollTop,
  13391. scrollHeight: target.scrollHeight,
  13392. scrollWidth: target.scrollWidth,
  13393. deltaX: state2.lastScrollLeft - target.scrollLeft,
  13394. deltaY: state2.lastScrollTop - target.scrollTop
  13395. });
  13396. if (realScrollY.value) {
  13397. if (target.scrollTop <= upperThresholdNumber.value && state2.lastScrollTop - target.scrollTop > 0 && $event.timeStamp - state2.lastScrollToUpperTime > 200) {
  13398. trigger("scrolltoupper", $event, {
  13399. direction: "top"
  13400. });
  13401. state2.lastScrollToUpperTime = $event.timeStamp;
  13402. }
  13403. if (target.scrollTop + target.offsetHeight + lowerThresholdNumber.value >= target.scrollHeight && state2.lastScrollTop - target.scrollTop < 0 && $event.timeStamp - state2.lastScrollToLowerTime > 200) {
  13404. trigger("scrolltolower", $event, {
  13405. direction: "bottom"
  13406. });
  13407. state2.lastScrollToLowerTime = $event.timeStamp;
  13408. }
  13409. }
  13410. if (realScrollX.value) {
  13411. if (target.scrollLeft <= upperThresholdNumber.value && state2.lastScrollLeft - target.scrollLeft > 0 && $event.timeStamp - state2.lastScrollToUpperTime > 200) {
  13412. trigger("scrolltoupper", $event, {
  13413. direction: "left"
  13414. });
  13415. state2.lastScrollToUpperTime = $event.timeStamp;
  13416. }
  13417. if (target.scrollLeft + target.offsetWidth + lowerThresholdNumber.value >= target.scrollWidth && state2.lastScrollLeft - target.scrollLeft < 0 && $event.timeStamp - state2.lastScrollToLowerTime > 200) {
  13418. trigger("scrolltolower", $event, {
  13419. direction: "right"
  13420. });
  13421. state2.lastScrollToLowerTime = $event.timeStamp;
  13422. }
  13423. }
  13424. state2.lastScrollTop = target.scrollTop;
  13425. state2.lastScrollLeft = target.scrollLeft;
  13426. }
  13427. function _scrollTopChanged(val) {
  13428. if (realScrollY.value) {
  13429. {
  13430. if (props2.scrollWithAnimation) {
  13431. scrollTo2(val, "y");
  13432. } else {
  13433. main.value.scrollTop = val;
  13434. }
  13435. }
  13436. }
  13437. }
  13438. function _scrollLeftChanged(val) {
  13439. if (realScrollX.value) {
  13440. {
  13441. if (props2.scrollWithAnimation) {
  13442. scrollTo2(val, "x");
  13443. } else {
  13444. main.value.scrollLeft = val;
  13445. }
  13446. }
  13447. }
  13448. }
  13449. function _scrollIntoViewChanged(val) {
  13450. if (val) {
  13451. if (!/^[_a-zA-Z][-_a-zA-Z0-9:]*$/.test(val)) {
  13452. console.error(`id error: scroll-into-view=${val}`);
  13453. return;
  13454. }
  13455. let element = rootRef.value.querySelector("#" + val);
  13456. if (element) {
  13457. let mainRect = main.value.getBoundingClientRect();
  13458. let elRect = element.getBoundingClientRect();
  13459. if (realScrollX.value) {
  13460. let left = elRect.left - mainRect.left;
  13461. let scrollLeft = main.value.scrollLeft;
  13462. let x = scrollLeft + left;
  13463. if (props2.scrollWithAnimation) {
  13464. scrollTo2(x, "x");
  13465. } else {
  13466. main.value.scrollLeft = x;
  13467. }
  13468. }
  13469. if (realScrollY.value) {
  13470. let top = elRect.top - mainRect.top;
  13471. let scrollTop = main.value.scrollTop;
  13472. let y = scrollTop + top;
  13473. if (props2.scrollWithAnimation) {
  13474. scrollTo2(y, "y");
  13475. } else {
  13476. main.value.scrollTop = y;
  13477. }
  13478. }
  13479. }
  13480. }
  13481. }
  13482. function _transitionEnd(val, direction2) {
  13483. content.value.style.transition = "";
  13484. content.value.style.webkitTransition = "";
  13485. content.value.style.transform = "";
  13486. content.value.style.webkitTransform = "";
  13487. let _main = main.value;
  13488. if (direction2 === "x") {
  13489. _main.style.overflowX = realScrollX.value ? "auto" : "hidden";
  13490. _main.scrollLeft = val;
  13491. } else if (direction2 === "y") {
  13492. _main.style.overflowY = realScrollY.value ? "auto" : "hidden";
  13493. _main.scrollTop = val;
  13494. }
  13495. content.value.removeEventListener("transitionend", __transitionEnd);
  13496. content.value.removeEventListener("webkitTransitionEnd", __transitionEnd);
  13497. }
  13498. function _setRefreshState(_state) {
  13499. if (!props2.refresherEnabled)
  13500. return;
  13501. switch (_state) {
  13502. case "refreshing":
  13503. state2.refresherHeight = props2.refresherThreshold;
  13504. if (!beforeRefreshing) {
  13505. beforeRefreshing = true;
  13506. trigger("refresherrefresh", {}, {});
  13507. emit2("update:refresherTriggered", true);
  13508. }
  13509. break;
  13510. case "restore":
  13511. case "refresherabort":
  13512. beforeRefreshing = false;
  13513. state2.refresherHeight = toUpperNumber = 0;
  13514. if (_state === "restore") {
  13515. triggerAbort = false;
  13516. trigger("refresherrestore", {}, {});
  13517. }
  13518. if (_state === "refresherabort" && triggerAbort) {
  13519. triggerAbort = false;
  13520. trigger("refresherabort", {}, {});
  13521. }
  13522. break;
  13523. }
  13524. state2.refreshState = _state;
  13525. }
  13526. onMounted(() => {
  13527. nextTick(() => {
  13528. _scrollTopChanged(scrollTopNumber.value);
  13529. _scrollLeftChanged(scrollLeftNumber.value);
  13530. });
  13531. _scrollIntoViewChanged(props2.scrollIntoView);
  13532. let __handleScroll = function(event) {
  13533. event.preventDefault();
  13534. event.stopPropagation();
  13535. _handleScroll(event);
  13536. };
  13537. let touchStart = {
  13538. x: 0,
  13539. y: 0
  13540. };
  13541. let needStop = null;
  13542. let __handleTouchMove = function(event) {
  13543. if (touchStart === null)
  13544. return;
  13545. let x = event.touches[0].pageX;
  13546. let y = event.touches[0].pageY;
  13547. let _main = main.value;
  13548. if (Math.abs(x - touchStart.x) > Math.abs(y - touchStart.y)) {
  13549. if (realScrollX.value) {
  13550. if (_main.scrollLeft === 0 && x > touchStart.x) {
  13551. needStop = false;
  13552. return;
  13553. } else if (_main.scrollWidth === _main.offsetWidth + _main.scrollLeft && x < touchStart.x) {
  13554. needStop = false;
  13555. return;
  13556. }
  13557. needStop = true;
  13558. } else {
  13559. needStop = false;
  13560. }
  13561. } else {
  13562. if (realScrollY.value) {
  13563. if (_main.scrollTop === 0 && y > touchStart.y) {
  13564. needStop = false;
  13565. if (props2.refresherEnabled && event.cancelable !== false)
  13566. event.preventDefault();
  13567. } else if (_main.scrollHeight === _main.offsetHeight + _main.scrollTop && y < touchStart.y) {
  13568. needStop = false;
  13569. return;
  13570. } else {
  13571. needStop = true;
  13572. }
  13573. } else {
  13574. needStop = false;
  13575. }
  13576. }
  13577. if (needStop) {
  13578. event.stopPropagation();
  13579. }
  13580. if (_main.scrollTop === 0 && event.touches.length === 1) {
  13581. _setRefreshState("pulling");
  13582. }
  13583. if (props2.refresherEnabled && state2.refreshState === "pulling") {
  13584. const dy = y - touchStart.y;
  13585. if (toUpperNumber === 0) {
  13586. toUpperNumber = y;
  13587. }
  13588. if (!beforeRefreshing) {
  13589. state2.refresherHeight = y - toUpperNumber;
  13590. if (state2.refresherHeight > 0) {
  13591. triggerAbort = true;
  13592. trigger("refresherpulling", event, {
  13593. deltaY: dy
  13594. });
  13595. }
  13596. } else {
  13597. state2.refresherHeight = dy + props2.refresherThreshold;
  13598. triggerAbort = false;
  13599. }
  13600. const route = state2.refresherHeight / props2.refresherThreshold;
  13601. state2.refreshRotate = (route > 1 ? 1 : route) * 360;
  13602. }
  13603. };
  13604. let __handleTouchStart = function(event) {
  13605. if (event.touches.length === 1) {
  13606. touchStart = {
  13607. x: event.touches[0].pageX,
  13608. y: event.touches[0].pageY
  13609. };
  13610. }
  13611. };
  13612. let __handleTouchEnd = function(event) {
  13613. touchStart = null;
  13614. if (state2.refresherHeight >= props2.refresherThreshold) {
  13615. _setRefreshState("refreshing");
  13616. } else {
  13617. _setRefreshState("refresherabort");
  13618. }
  13619. };
  13620. main.value.addEventListener("touchstart", __handleTouchStart, passiveOptions);
  13621. main.value.addEventListener("touchmove", __handleTouchMove, passive(false));
  13622. main.value.addEventListener("scroll", __handleScroll, passive(false));
  13623. main.value.addEventListener("touchend", __handleTouchEnd, passiveOptions);
  13624. onBeforeUnmount(() => {
  13625. main.value.removeEventListener("touchstart", __handleTouchStart);
  13626. main.value.removeEventListener("touchmove", __handleTouchMove);
  13627. main.value.removeEventListener("scroll", __handleScroll);
  13628. main.value.removeEventListener("touchend", __handleTouchEnd);
  13629. });
  13630. });
  13631. onActivated(() => {
  13632. realScrollY.value && (main.value.scrollTop = state2.lastScrollTop);
  13633. realScrollX.value && (main.value.scrollLeft = state2.lastScrollLeft);
  13634. });
  13635. watch(scrollTopNumber, (val) => {
  13636. _scrollTopChanged(val);
  13637. });
  13638. watch(scrollLeftNumber, (val) => {
  13639. _scrollLeftChanged(val);
  13640. });
  13641. watch(() => props2.scrollIntoView, (val) => {
  13642. _scrollIntoViewChanged(val);
  13643. });
  13644. watch(() => props2.refresherTriggered, (val) => {
  13645. if (val === true) {
  13646. _setRefreshState("refreshing");
  13647. } else if (val === false) {
  13648. _setRefreshState("restore");
  13649. }
  13650. });
  13651. return {
  13652. realScrollX,
  13653. realScrollY
  13654. };
  13655. }
  13656. const props$l = {
  13657. name: {
  13658. type: String,
  13659. default: ""
  13660. },
  13661. min: {
  13662. type: [Number, String],
  13663. default: 0
  13664. },
  13665. max: {
  13666. type: [Number, String],
  13667. default: 100
  13668. },
  13669. value: {
  13670. type: [Number, String],
  13671. default: 0
  13672. },
  13673. step: {
  13674. type: [Number, String],
  13675. default: 1
  13676. },
  13677. disabled: {
  13678. type: [Boolean, String],
  13679. default: false
  13680. },
  13681. color: {
  13682. type: String,
  13683. default: "#e9e9e9"
  13684. },
  13685. backgroundColor: {
  13686. type: String,
  13687. default: "#e9e9e9"
  13688. },
  13689. activeColor: {
  13690. type: String,
  13691. default: "#007aff"
  13692. },
  13693. selectedColor: {
  13694. type: String,
  13695. default: "#007aff"
  13696. },
  13697. blockColor: {
  13698. type: String,
  13699. default: "#ffffff"
  13700. },
  13701. blockSize: {
  13702. type: [Number, String],
  13703. default: 28
  13704. },
  13705. showValue: {
  13706. type: [Boolean, String],
  13707. default: false
  13708. }
  13709. };
  13710. const index$k = /* @__PURE__ */ defineBuiltInComponent({
  13711. name: "Slider",
  13712. props: props$l,
  13713. emits: ["changing", "change"],
  13714. setup(props2, {
  13715. emit: emit2
  13716. }) {
  13717. const sliderRef = ref(null);
  13718. const sliderValueRef = ref(null);
  13719. const sliderHandleRef = ref(null);
  13720. const sliderValue = ref(Number(props2.value));
  13721. watch(() => props2.value, (val) => {
  13722. sliderValue.value = Number(val);
  13723. });
  13724. const trigger = useCustomEvent(sliderRef, emit2);
  13725. const state2 = useSliderState(props2, sliderValue);
  13726. const {
  13727. _onClick,
  13728. _onTrack
  13729. } = useSliderLoader(props2, sliderValue, sliderRef, sliderValueRef, trigger);
  13730. onMounted(() => {
  13731. useTouchtrack(sliderHandleRef.value, _onTrack);
  13732. });
  13733. return () => {
  13734. const {
  13735. setBgColor,
  13736. setBlockBg,
  13737. setActiveColor,
  13738. setBlockStyle
  13739. } = state2;
  13740. return createVNode("uni-slider", {
  13741. "ref": sliderRef,
  13742. "onClick": withWebEvent(_onClick)
  13743. }, [createVNode("div", {
  13744. "class": "uni-slider-wrapper"
  13745. }, [createVNode("div", {
  13746. "class": "uni-slider-tap-area"
  13747. }, [createVNode("div", {
  13748. "style": setBgColor.value,
  13749. "class": "uni-slider-handle-wrapper"
  13750. }, [createVNode("div", {
  13751. "ref": sliderHandleRef,
  13752. "style": setBlockBg.value,
  13753. "class": "uni-slider-handle"
  13754. }, null, 4), createVNode("div", {
  13755. "style": setBlockStyle.value,
  13756. "class": "uni-slider-thumb"
  13757. }, null, 4), createVNode("div", {
  13758. "style": setActiveColor.value,
  13759. "class": "uni-slider-track"
  13760. }, null, 4)], 4)]), withDirectives(createVNode("span", {
  13761. "ref": sliderValueRef,
  13762. "class": "uni-slider-value"
  13763. }, [sliderValue.value], 512), [[vShow, props2.showValue]])]), createVNode("slot", null, null)], 8, ["onClick"]);
  13764. };
  13765. }
  13766. });
  13767. const getValueWidth = (value, min, max) => {
  13768. max = Number(max);
  13769. min = Number(min);
  13770. return 100 * (value - min) / (max - min) + "%";
  13771. };
  13772. function useSliderState(props2, sliderValue) {
  13773. const _getValueWidth = () => {
  13774. return getValueWidth(sliderValue.value, props2.min, props2.max);
  13775. };
  13776. const _getBgColor = () => {
  13777. return props2.backgroundColor !== "#e9e9e9" ? props2.backgroundColor : props2.color !== "#007aff" ? props2.color : "#007aff";
  13778. };
  13779. const _getActiveColor = () => {
  13780. return props2.activeColor !== "#007aff" ? props2.activeColor : props2.selectedColor !== "#e9e9e9" ? props2.selectedColor : "#e9e9e9";
  13781. };
  13782. const state2 = {
  13783. setBgColor: computed(() => ({
  13784. backgroundColor: _getBgColor()
  13785. })),
  13786. setBlockBg: computed(() => ({
  13787. left: _getValueWidth()
  13788. })),
  13789. setActiveColor: computed(() => ({
  13790. backgroundColor: _getActiveColor(),
  13791. width: _getValueWidth()
  13792. })),
  13793. setBlockStyle: computed(() => ({
  13794. width: props2.blockSize + "px",
  13795. height: props2.blockSize + "px",
  13796. marginLeft: -props2.blockSize / 2 + "px",
  13797. marginTop: -props2.blockSize / 2 + "px",
  13798. left: _getValueWidth(),
  13799. backgroundColor: props2.blockColor
  13800. }))
  13801. };
  13802. return state2;
  13803. }
  13804. function useSliderLoader(props2, sliderValue, sliderRef, sliderValueRef, trigger) {
  13805. const _onClick = ($event) => {
  13806. if (props2.disabled) {
  13807. return;
  13808. }
  13809. _onUserChangedValue($event);
  13810. trigger("change", $event, {
  13811. value: sliderValue.value
  13812. });
  13813. };
  13814. const _filterValue = (e2) => {
  13815. const max = Number(props2.max);
  13816. const min = Number(props2.min);
  13817. const step = Number(props2.step);
  13818. return e2 < min ? min : e2 > max ? max : computeController.mul.call(Math.round((e2 - min) / step), step) + min;
  13819. };
  13820. const _onUserChangedValue = (e2) => {
  13821. const max = Number(props2.max);
  13822. const min = Number(props2.min);
  13823. const sliderRightBox = sliderValueRef.value;
  13824. const sliderRightBoxLeft = getComputedStyle(sliderRightBox, null).marginLeft;
  13825. let sliderRightBoxWidth = sliderRightBox.offsetWidth;
  13826. sliderRightBoxWidth = sliderRightBoxWidth + parseInt(sliderRightBoxLeft);
  13827. const slider = sliderRef.value;
  13828. const offsetWidth = slider.offsetWidth - (props2.showValue ? sliderRightBoxWidth : 0);
  13829. const boxLeft = slider.getBoundingClientRect().left;
  13830. const value = (e2.x - boxLeft) * (max - min) / offsetWidth + min;
  13831. sliderValue.value = _filterValue(value);
  13832. };
  13833. const _onTrack = (e2) => {
  13834. if (!props2.disabled) {
  13835. return e2.detail.state === "move" ? (_onUserChangedValue({
  13836. x: e2.detail.x
  13837. }), trigger("changing", e2, {
  13838. value: sliderValue.value
  13839. }), false) : e2.detail.state === "end" && trigger("change", e2, {
  13840. value: sliderValue.value
  13841. });
  13842. }
  13843. };
  13844. const uniForm = inject(uniFormKey, false);
  13845. if (!!uniForm) {
  13846. const field = {
  13847. reset: () => sliderValue.value = Number(props2.min),
  13848. submit: () => {
  13849. const data = ["", null];
  13850. if (props2.name !== "") {
  13851. data[0] = props2.name;
  13852. data[1] = sliderValue.value;
  13853. }
  13854. return data;
  13855. }
  13856. };
  13857. uniForm.addField(field);
  13858. onBeforeUnmount(() => {
  13859. uniForm.removeField(field);
  13860. });
  13861. }
  13862. return {
  13863. _onClick,
  13864. _onTrack
  13865. };
  13866. }
  13867. var computeController = {
  13868. mul: function(arg) {
  13869. let m = 0;
  13870. let s1 = this.toString();
  13871. let s2 = arg.toString();
  13872. try {
  13873. m += s1.split(".")[1].length;
  13874. } catch (e2) {
  13875. }
  13876. try {
  13877. m += s2.split(".")[1].length;
  13878. } catch (e2) {
  13879. }
  13880. return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
  13881. }
  13882. };
  13883. const props$k = {
  13884. indicatorDots: {
  13885. type: [Boolean, String],
  13886. default: false
  13887. },
  13888. vertical: {
  13889. type: [Boolean, String],
  13890. default: false
  13891. },
  13892. autoplay: {
  13893. type: [Boolean, String],
  13894. default: false
  13895. },
  13896. circular: {
  13897. type: [Boolean, String],
  13898. default: false
  13899. },
  13900. interval: {
  13901. type: [Number, String],
  13902. default: 5e3
  13903. },
  13904. duration: {
  13905. type: [Number, String],
  13906. default: 500
  13907. },
  13908. current: {
  13909. type: [Number, String],
  13910. default: 0
  13911. },
  13912. indicatorColor: {
  13913. type: String,
  13914. default: ""
  13915. },
  13916. indicatorActiveColor: {
  13917. type: String,
  13918. default: ""
  13919. },
  13920. previousMargin: {
  13921. type: String,
  13922. default: ""
  13923. },
  13924. nextMargin: {
  13925. type: String,
  13926. default: ""
  13927. },
  13928. currentItemId: {
  13929. type: String,
  13930. default: ""
  13931. },
  13932. skipHiddenItemLayout: {
  13933. type: [Boolean, String],
  13934. default: false
  13935. },
  13936. displayMultipleItems: {
  13937. type: [Number, String],
  13938. default: 1
  13939. },
  13940. disableTouch: {
  13941. type: [Boolean, String],
  13942. default: false
  13943. },
  13944. navigation: {
  13945. type: [Boolean, String],
  13946. default: false
  13947. },
  13948. navigationColor: {
  13949. type: String,
  13950. default: "#fff"
  13951. },
  13952. navigationActiveColor: {
  13953. type: String,
  13954. default: "rgba(53, 53, 53, 0.6)"
  13955. }
  13956. };
  13957. function useState$3(props2) {
  13958. const interval = computed(() => {
  13959. const interval2 = Number(props2.interval);
  13960. return isNaN(interval2) ? 5e3 : interval2;
  13961. });
  13962. const duration = computed(() => {
  13963. const duration2 = Number(props2.duration);
  13964. return isNaN(duration2) ? 500 : duration2;
  13965. });
  13966. const displayMultipleItems = computed(() => {
  13967. const displayMultipleItems2 = Math.round(props2.displayMultipleItems);
  13968. return isNaN(displayMultipleItems2) ? 1 : displayMultipleItems2;
  13969. });
  13970. const state2 = reactive({
  13971. interval,
  13972. duration,
  13973. displayMultipleItems,
  13974. current: Math.round(props2.current) || 0,
  13975. currentItemId: props2.currentItemId,
  13976. userTracking: false
  13977. });
  13978. return state2;
  13979. }
  13980. function useLayout(props2, state2, swiperContexts, slideFrameRef, emit2, trigger) {
  13981. function cancelSchedule() {
  13982. if (timer) {
  13983. clearTimeout(timer);
  13984. timer = null;
  13985. }
  13986. }
  13987. let timer = null;
  13988. let invalid = true;
  13989. let viewportPosition = 0;
  13990. let viewportMoveRatio = 1;
  13991. let animating = null;
  13992. let requestedAnimation = false;
  13993. let contentTrackViewport = 0;
  13994. let transitionStart;
  13995. let currentChangeSource = "";
  13996. let animationFrame;
  13997. const swiperEnabled = computed(() => swiperContexts.value.length > state2.displayMultipleItems);
  13998. const circularEnabled = computed(() => props2.circular && swiperEnabled.value);
  13999. function checkCircularLayout(index2) {
  14000. if (!invalid) {
  14001. for (let items = swiperContexts.value, n = items.length, i = index2 + state2.displayMultipleItems, r = 0; r < n; r++) {
  14002. const item = items[r];
  14003. const s = Math.floor(index2 / n) * n + r;
  14004. const l = s + n;
  14005. const c = s - n;
  14006. const u = Math.max(index2 - (s + 1), s - i, 0);
  14007. const d = Math.max(index2 - (l + 1), l - i, 0);
  14008. const h2 = Math.max(index2 - (c + 1), c - i, 0);
  14009. const p2 = Math.min(u, d, h2);
  14010. const position = [s, l, c][[u, d, h2].indexOf(p2)];
  14011. item.updatePosition(position, props2.vertical);
  14012. }
  14013. }
  14014. }
  14015. function updateViewport(index2) {
  14016. if (!(Math.floor(2 * viewportPosition) === Math.floor(2 * index2) && Math.ceil(2 * viewportPosition) === Math.ceil(2 * index2))) {
  14017. if (circularEnabled.value) {
  14018. checkCircularLayout(index2);
  14019. }
  14020. }
  14021. const x = props2.vertical ? "0" : 100 * -index2 * viewportMoveRatio + "%";
  14022. const y = props2.vertical ? 100 * -index2 * viewportMoveRatio + "%" : "0";
  14023. const transform = "translate(" + x + ", " + y + ") translateZ(0)";
  14024. const slideFrame = slideFrameRef.value;
  14025. if (slideFrame) {
  14026. slideFrame.style.webkitTransform = transform;
  14027. slideFrame.style.transform = transform;
  14028. }
  14029. viewportPosition = index2;
  14030. if (!transitionStart) {
  14031. if (index2 % 1 === 0) {
  14032. return;
  14033. }
  14034. transitionStart = index2;
  14035. }
  14036. index2 -= Math.floor(transitionStart);
  14037. const items = swiperContexts.value;
  14038. if (index2 <= -(items.length - 1)) {
  14039. index2 += items.length;
  14040. } else if (index2 >= items.length) {
  14041. index2 -= items.length;
  14042. }
  14043. index2 = transitionStart % 1 > 0.5 || transitionStart < 0 ? index2 - 1 : index2;
  14044. trigger("transition", {}, {
  14045. dx: props2.vertical ? 0 : index2 * slideFrame.offsetWidth,
  14046. dy: props2.vertical ? index2 * slideFrame.offsetHeight : 0
  14047. });
  14048. }
  14049. function endViewportAnimation() {
  14050. if (animating) {
  14051. updateViewport(animating.toPos);
  14052. animating = null;
  14053. }
  14054. }
  14055. function normalizeCurrentValue(current) {
  14056. const length = swiperContexts.value.length;
  14057. if (!length) {
  14058. return -1;
  14059. }
  14060. const index2 = (Math.round(current) % length + length) % length;
  14061. if (circularEnabled.value) {
  14062. if (length <= state2.displayMultipleItems) {
  14063. return 0;
  14064. }
  14065. } else if (index2 > length - state2.displayMultipleItems) {
  14066. return length - state2.displayMultipleItems;
  14067. }
  14068. return index2;
  14069. }
  14070. function cancelViewportAnimation() {
  14071. animating = null;
  14072. }
  14073. function animateFrameFuncProto() {
  14074. if (!animating) {
  14075. requestedAnimation = false;
  14076. return;
  14077. }
  14078. const _animating = animating;
  14079. const toPos = _animating.toPos;
  14080. const acc = _animating.acc;
  14081. const endTime = _animating.endTime;
  14082. const source = _animating.source;
  14083. const time = endTime - Date.now();
  14084. if (time <= 0) {
  14085. updateViewport(toPos);
  14086. animating = null;
  14087. requestedAnimation = false;
  14088. transitionStart = null;
  14089. const item = swiperContexts.value[state2.current];
  14090. if (item) {
  14091. const currentItemId = item.getItemId();
  14092. trigger("animationfinish", {}, {
  14093. current: state2.current,
  14094. currentItemId,
  14095. source
  14096. });
  14097. }
  14098. return;
  14099. }
  14100. const s = acc * time * time / 2;
  14101. const l = toPos + s;
  14102. updateViewport(l);
  14103. animationFrame = requestAnimationFrame(animateFrameFuncProto);
  14104. }
  14105. function animateViewport(current, source, n) {
  14106. cancelViewportAnimation();
  14107. const duration = state2.duration;
  14108. const length = swiperContexts.value.length;
  14109. let position = viewportPosition;
  14110. if (circularEnabled.value) {
  14111. if (n < 0) {
  14112. for (; position < current; ) {
  14113. position += length;
  14114. }
  14115. for (; position - length > current; ) {
  14116. position -= length;
  14117. }
  14118. } else if (n > 0) {
  14119. for (; position > current; ) {
  14120. position -= length;
  14121. }
  14122. for (; position + length < current; ) {
  14123. position += length;
  14124. }
  14125. if (position + length - current < current - position) {
  14126. position += length;
  14127. }
  14128. } else {
  14129. for (; position + length < current; ) {
  14130. position += length;
  14131. }
  14132. for (; position - length > current; ) {
  14133. position -= length;
  14134. }
  14135. if (position + length - current < current - position) {
  14136. position += length;
  14137. }
  14138. }
  14139. } else if (source === "click") {
  14140. current = current + state2.displayMultipleItems - 1 < length ? current : 0;
  14141. }
  14142. animating = {
  14143. toPos: current,
  14144. acc: 2 * (position - current) / (duration * duration),
  14145. endTime: Date.now() + duration,
  14146. source
  14147. };
  14148. if (!requestedAnimation) {
  14149. requestedAnimation = true;
  14150. animationFrame = requestAnimationFrame(animateFrameFuncProto);
  14151. }
  14152. }
  14153. function scheduleAutoplay() {
  14154. cancelSchedule();
  14155. const items = swiperContexts.value;
  14156. const callback = function() {
  14157. timer = null;
  14158. currentChangeSource = "autoplay";
  14159. if (circularEnabled.value) {
  14160. state2.current = normalizeCurrentValue(state2.current + 1);
  14161. } else {
  14162. state2.current = state2.current + state2.displayMultipleItems < items.length ? state2.current + 1 : 0;
  14163. }
  14164. animateViewport(state2.current, "autoplay", circularEnabled.value ? 1 : 0);
  14165. timer = setTimeout(callback, state2.interval);
  14166. };
  14167. if (!(invalid || items.length <= state2.displayMultipleItems)) {
  14168. timer = setTimeout(callback, state2.interval);
  14169. }
  14170. }
  14171. function resetLayout() {
  14172. cancelSchedule();
  14173. endViewportAnimation();
  14174. const items = swiperContexts.value;
  14175. for (let i = 0; i < items.length; i++) {
  14176. items[i].updatePosition(i, props2.vertical);
  14177. }
  14178. viewportMoveRatio = 1;
  14179. const slideFrameEl = slideFrameRef.value;
  14180. if (state2.displayMultipleItems === 1 && items.length) {
  14181. const itemRect = items[0].getBoundingClientRect();
  14182. const slideFrameRect = slideFrameEl.getBoundingClientRect();
  14183. viewportMoveRatio = itemRect.width / slideFrameRect.width;
  14184. if (!(viewportMoveRatio > 0 && viewportMoveRatio < 1)) {
  14185. viewportMoveRatio = 1;
  14186. }
  14187. }
  14188. const position = viewportPosition;
  14189. viewportPosition = -2;
  14190. const current = state2.current;
  14191. if (current >= 0) {
  14192. invalid = false;
  14193. if (state2.userTracking) {
  14194. updateViewport(position + current - contentTrackViewport);
  14195. contentTrackViewport = current;
  14196. } else {
  14197. updateViewport(current);
  14198. if (props2.autoplay) {
  14199. scheduleAutoplay();
  14200. }
  14201. }
  14202. } else {
  14203. invalid = true;
  14204. updateViewport(-state2.displayMultipleItems - 1);
  14205. }
  14206. }
  14207. watch([() => props2.current, () => props2.currentItemId, () => [...swiperContexts.value]], () => {
  14208. let current = -1;
  14209. if (props2.currentItemId) {
  14210. for (let i = 0, items = swiperContexts.value; i < items.length; i++) {
  14211. const itemId = items[i].getItemId();
  14212. if (itemId === props2.currentItemId) {
  14213. current = i;
  14214. break;
  14215. }
  14216. }
  14217. }
  14218. if (current < 0) {
  14219. current = Math.round(props2.current) || 0;
  14220. }
  14221. current = current < 0 ? 0 : current;
  14222. if (state2.current !== current) {
  14223. currentChangeSource = "";
  14224. state2.current = current;
  14225. }
  14226. });
  14227. watch([() => props2.vertical, () => circularEnabled.value, () => state2.displayMultipleItems, () => [...swiperContexts.value]], resetLayout);
  14228. watch(() => state2.interval, () => {
  14229. if (timer) {
  14230. cancelSchedule();
  14231. scheduleAutoplay();
  14232. }
  14233. });
  14234. function currentChanged(current, history2) {
  14235. const source = currentChangeSource;
  14236. currentChangeSource = "";
  14237. const items = swiperContexts.value;
  14238. if (!source) {
  14239. const length = items.length;
  14240. animateViewport(current, "", circularEnabled.value && history2 + (length - current) % length > length / 2 ? 1 : 0);
  14241. }
  14242. const item = items[current];
  14243. if (item) {
  14244. const currentItemId = state2.currentItemId = item.getItemId();
  14245. trigger("change", {}, {
  14246. current: state2.current,
  14247. currentItemId,
  14248. source
  14249. });
  14250. }
  14251. }
  14252. watch(() => state2.current, (val, oldVal) => {
  14253. currentChanged(val, oldVal);
  14254. emit2("update:current", val);
  14255. });
  14256. watch(() => state2.currentItemId, (val) => {
  14257. emit2("update:currentItemId", val);
  14258. });
  14259. function inintAutoplay(enable) {
  14260. if (enable) {
  14261. scheduleAutoplay();
  14262. } else {
  14263. cancelSchedule();
  14264. }
  14265. }
  14266. watch(() => props2.autoplay && !state2.userTracking, inintAutoplay);
  14267. inintAutoplay(props2.autoplay && !state2.userTracking);
  14268. onMounted(() => {
  14269. let userDirectionChecked = false;
  14270. let contentTrackSpeed = 0;
  14271. let contentTrackT = 0;
  14272. function handleTrackStart() {
  14273. cancelSchedule();
  14274. contentTrackViewport = viewportPosition;
  14275. contentTrackSpeed = 0;
  14276. contentTrackT = Date.now();
  14277. cancelViewportAnimation();
  14278. }
  14279. function handleTrackMove(data) {
  14280. const oldContentTrackT = contentTrackT;
  14281. contentTrackT = Date.now();
  14282. const length = swiperContexts.value.length;
  14283. const other = length - state2.displayMultipleItems;
  14284. function calc2(val) {
  14285. return 0.5 - 0.25 / (val + 0.5);
  14286. }
  14287. function move(oldVal, newVal) {
  14288. let val = contentTrackViewport + oldVal;
  14289. contentTrackSpeed = 0.6 * contentTrackSpeed + 0.4 * newVal;
  14290. if (!circularEnabled.value) {
  14291. if (val < 0 || val > other) {
  14292. if (val < 0) {
  14293. val = -calc2(-val);
  14294. } else {
  14295. if (val > other) {
  14296. val = other + calc2(val - other);
  14297. }
  14298. }
  14299. contentTrackSpeed = 0;
  14300. }
  14301. }
  14302. updateViewport(val);
  14303. }
  14304. const time = contentTrackT - oldContentTrackT || 1;
  14305. const slideFrameEl = slideFrameRef.value;
  14306. if (props2.vertical) {
  14307. move(-data.dy / slideFrameEl.offsetHeight, -data.ddy / time);
  14308. } else {
  14309. move(-data.dx / slideFrameEl.offsetWidth, -data.ddx / time);
  14310. }
  14311. }
  14312. function handleTrackEnd(isCancel) {
  14313. state2.userTracking = false;
  14314. const t2 = contentTrackSpeed / Math.abs(contentTrackSpeed);
  14315. let n = 0;
  14316. if (!isCancel && Math.abs(contentTrackSpeed) > 0.2) {
  14317. n = 0.5 * t2;
  14318. }
  14319. const current = normalizeCurrentValue(viewportPosition + n);
  14320. if (isCancel) {
  14321. updateViewport(contentTrackViewport);
  14322. } else {
  14323. currentChangeSource = "touch";
  14324. state2.current = current;
  14325. animateViewport(current, "touch", n !== 0 ? n : current === 0 && circularEnabled.value && viewportPosition >= 1 ? 1 : 0);
  14326. }
  14327. }
  14328. useTouchtrack(slideFrameRef.value, (event) => {
  14329. if (props2.disableTouch) {
  14330. return;
  14331. }
  14332. if (!invalid) {
  14333. if (event.detail.state === "start") {
  14334. state2.userTracking = true;
  14335. userDirectionChecked = false;
  14336. return handleTrackStart();
  14337. }
  14338. if (event.detail.state === "end") {
  14339. return handleTrackEnd(false);
  14340. }
  14341. if (event.detail.state === "cancel") {
  14342. return handleTrackEnd(true);
  14343. }
  14344. if (state2.userTracking) {
  14345. if (!userDirectionChecked) {
  14346. userDirectionChecked = true;
  14347. const t2 = Math.abs(event.detail.dx);
  14348. const n = Math.abs(event.detail.dy);
  14349. if (t2 >= n && props2.vertical) {
  14350. state2.userTracking = false;
  14351. } else {
  14352. if (t2 <= n && !props2.vertical) {
  14353. state2.userTracking = false;
  14354. }
  14355. }
  14356. if (!state2.userTracking) {
  14357. if (props2.autoplay) {
  14358. scheduleAutoplay();
  14359. }
  14360. return;
  14361. }
  14362. }
  14363. handleTrackMove(event.detail);
  14364. return false;
  14365. }
  14366. }
  14367. });
  14368. });
  14369. onUnmounted(() => {
  14370. cancelSchedule();
  14371. cancelAnimationFrame(animationFrame);
  14372. });
  14373. function onSwiperDotClick(index2) {
  14374. animateViewport(state2.current = index2, currentChangeSource = "click", circularEnabled.value ? 1 : 0);
  14375. }
  14376. return {
  14377. onSwiperDotClick,
  14378. circularEnabled,
  14379. swiperEnabled
  14380. };
  14381. }
  14382. const Swiper = /* @__PURE__ */ defineBuiltInComponent({
  14383. name: "Swiper",
  14384. props: props$k,
  14385. emits: ["change", "transition", "animationfinish", "update:current", "update:currentItemId"],
  14386. setup(props2, {
  14387. slots,
  14388. emit: emit2
  14389. }) {
  14390. const rootRef = ref(null);
  14391. const trigger = useCustomEvent(rootRef, emit2);
  14392. const slidesWrapperRef = ref(null);
  14393. const slideFrameRef = ref(null);
  14394. const state2 = useState$3(props2);
  14395. const slidesStyle = computed(() => {
  14396. let style = {};
  14397. if (props2.nextMargin || props2.previousMargin) {
  14398. style = props2.vertical ? {
  14399. left: 0,
  14400. right: 0,
  14401. top: rpx2px(props2.previousMargin, true),
  14402. bottom: rpx2px(props2.nextMargin, true)
  14403. } : {
  14404. top: 0,
  14405. bottom: 0,
  14406. left: rpx2px(props2.previousMargin, true),
  14407. right: rpx2px(props2.nextMargin, true)
  14408. };
  14409. }
  14410. return style;
  14411. });
  14412. const slideFrameStyle = computed(() => {
  14413. const value = Math.abs(100 / state2.displayMultipleItems) + "%";
  14414. return {
  14415. width: props2.vertical ? "100%" : value,
  14416. height: !props2.vertical ? "100%" : value
  14417. };
  14418. });
  14419. let swiperItems = [];
  14420. const originSwiperContexts = [];
  14421. const swiperContexts = ref([]);
  14422. function updateSwiperContexts() {
  14423. const contexts = [];
  14424. for (let index2 = 0; index2 < swiperItems.length; index2++) {
  14425. let swiperItem = swiperItems[index2];
  14426. if (!(swiperItem instanceof Element)) {
  14427. swiperItem = swiperItem.el;
  14428. }
  14429. const swiperContext = originSwiperContexts.find((context) => swiperItem === context.rootRef.value);
  14430. if (swiperContext) {
  14431. contexts.push(markRaw(swiperContext));
  14432. }
  14433. }
  14434. swiperContexts.value = contexts;
  14435. }
  14436. const addSwiperContext = function(swiperContext) {
  14437. originSwiperContexts.push(swiperContext);
  14438. updateSwiperContexts();
  14439. };
  14440. provide("addSwiperContext", addSwiperContext);
  14441. const removeSwiperContext = function(swiperContext) {
  14442. const index2 = originSwiperContexts.indexOf(swiperContext);
  14443. if (index2 >= 0) {
  14444. originSwiperContexts.splice(index2, 1);
  14445. updateSwiperContexts();
  14446. }
  14447. };
  14448. provide("removeSwiperContext", removeSwiperContext);
  14449. const {
  14450. onSwiperDotClick,
  14451. circularEnabled,
  14452. swiperEnabled
  14453. } = useLayout(props2, state2, swiperContexts, slideFrameRef, emit2, trigger);
  14454. let createNavigationTsx = () => null;
  14455. {
  14456. createNavigationTsx = useSwiperNavigation(rootRef, props2, state2, onSwiperDotClick, swiperContexts, circularEnabled, swiperEnabled);
  14457. }
  14458. return () => {
  14459. const defaultSlots = slots.default && slots.default();
  14460. swiperItems = flatVNode(defaultSlots);
  14461. return createVNode("uni-swiper", {
  14462. "ref": rootRef
  14463. }, [createVNode("div", {
  14464. "ref": slidesWrapperRef,
  14465. "class": "uni-swiper-wrapper"
  14466. }, [createVNode("div", {
  14467. "class": "uni-swiper-slides",
  14468. "style": slidesStyle.value
  14469. }, [createVNode("div", {
  14470. "ref": slideFrameRef,
  14471. "class": "uni-swiper-slide-frame",
  14472. "style": slideFrameStyle.value
  14473. }, [defaultSlots], 4)], 4), props2.indicatorDots && createVNode("div", {
  14474. "class": ["uni-swiper-dots", props2.vertical ? "uni-swiper-dots-vertical" : "uni-swiper-dots-horizontal"]
  14475. }, [swiperContexts.value.map((_, index2, array) => createVNode("div", {
  14476. "onClick": () => onSwiperDotClick(index2),
  14477. "class": {
  14478. "uni-swiper-dot": true,
  14479. "uni-swiper-dot-active": index2 < state2.current + state2.displayMultipleItems && index2 >= state2.current || index2 < state2.current + state2.displayMultipleItems - array.length
  14480. },
  14481. "style": {
  14482. background: index2 === state2.current ? props2.indicatorActiveColor : props2.indicatorColor
  14483. }
  14484. }, null, 14, ["onClick"]))], 2), createNavigationTsx()], 512)], 512);
  14485. };
  14486. }
  14487. });
  14488. const useSwiperNavigation = (rootRef, props2, state2, onSwiperDotClick, swiperContext, circularEnabled, swiperEnabled) => {
  14489. let isNavigationAuto = false;
  14490. let prevDisabled = false;
  14491. let nextDisabled = false;
  14492. let hideNavigation = ref(false);
  14493. watchEffect(() => {
  14494. isNavigationAuto = props2.navigation === "auto";
  14495. hideNavigation.value = props2.navigation !== true || isNavigationAuto;
  14496. swiperAddMouseEvent();
  14497. });
  14498. watchEffect(() => {
  14499. const swiperItemLength = swiperContext.value.length;
  14500. const notCircular = !circularEnabled.value;
  14501. prevDisabled = state2.current === 0 && notCircular;
  14502. nextDisabled = state2.current === swiperItemLength - 1 && notCircular || notCircular && state2.current + state2.displayMultipleItems >= swiperItemLength;
  14503. if (!swiperEnabled.value) {
  14504. prevDisabled = true;
  14505. nextDisabled = true;
  14506. isNavigationAuto && (hideNavigation.value = true);
  14507. }
  14508. });
  14509. function navigationHover(event, type) {
  14510. const target = event.currentTarget;
  14511. if (!target)
  14512. return;
  14513. target.style.backgroundColor = type === "over" ? props2.navigationActiveColor : "";
  14514. }
  14515. const navigationAttr = {
  14516. onMouseover: (event) => navigationHover(event, "over"),
  14517. onMouseout: (event) => navigationHover(event, "out")
  14518. };
  14519. function navigationClick($event, type, disabled) {
  14520. $event.stopPropagation();
  14521. if (disabled)
  14522. return;
  14523. const swiperItemLength = swiperContext.value.length;
  14524. let _current = state2.current;
  14525. switch (type) {
  14526. case "prev":
  14527. _current--;
  14528. if (_current < 0 && circularEnabled.value) {
  14529. _current = swiperItemLength - 1;
  14530. }
  14531. break;
  14532. case "next":
  14533. _current++;
  14534. if (_current >= swiperItemLength && circularEnabled.value) {
  14535. _current = 0;
  14536. }
  14537. break;
  14538. }
  14539. onSwiperDotClick(_current);
  14540. }
  14541. const createNavigationSVG = () => createSvgIconVNode(ICON_PATH_BACK, props2.navigationColor, 26);
  14542. let setHideNavigationTimer;
  14543. const _mousemove = (e2) => {
  14544. clearTimeout(setHideNavigationTimer);
  14545. const {
  14546. clientX,
  14547. clientY
  14548. } = e2;
  14549. const {
  14550. left,
  14551. right,
  14552. top,
  14553. bottom,
  14554. width,
  14555. height
  14556. } = rootRef.value.getBoundingClientRect();
  14557. let hide = false;
  14558. if (props2.vertical) {
  14559. hide = !(clientY - top < height / 3 || bottom - clientY < height / 3);
  14560. } else {
  14561. hide = !(clientX - left < width / 3 || right - clientX < width / 3);
  14562. }
  14563. if (hide) {
  14564. return setHideNavigationTimer = setTimeout(() => {
  14565. hideNavigation.value = hide;
  14566. }, 300);
  14567. }
  14568. hideNavigation.value = hide;
  14569. };
  14570. const _mouseleave = () => {
  14571. hideNavigation.value = true;
  14572. };
  14573. function swiperAddMouseEvent() {
  14574. if (rootRef.value) {
  14575. rootRef.value.removeEventListener("mousemove", _mousemove);
  14576. rootRef.value.removeEventListener("mouseleave", _mouseleave);
  14577. if (isNavigationAuto) {
  14578. rootRef.value.addEventListener("mousemove", _mousemove);
  14579. rootRef.value.addEventListener("mouseleave", _mouseleave);
  14580. }
  14581. }
  14582. }
  14583. onMounted(swiperAddMouseEvent);
  14584. function createNavigationTsx() {
  14585. const navigationClass = {
  14586. "uni-swiper-navigation-hide": hideNavigation.value,
  14587. "uni-swiper-navigation-vertical": props2.vertical
  14588. };
  14589. if (props2.navigation) {
  14590. return createVNode(Fragment, null, [createVNode("div", mergeProps({
  14591. "class": ["uni-swiper-navigation uni-swiper-navigation-prev", extend({
  14592. "uni-swiper-navigation-disabled": prevDisabled
  14593. }, navigationClass)],
  14594. "onClick": (e2) => navigationClick(e2, "prev", prevDisabled)
  14595. }, navigationAttr), [createNavigationSVG()], 16, ["onClick"]), createVNode("div", mergeProps({
  14596. "class": ["uni-swiper-navigation uni-swiper-navigation-next", extend({
  14597. "uni-swiper-navigation-disabled": nextDisabled
  14598. }, navigationClass)],
  14599. "onClick": (e2) => navigationClick(e2, "next", nextDisabled)
  14600. }, navigationAttr), [createNavigationSVG()], 16, ["onClick"])]);
  14601. }
  14602. return null;
  14603. }
  14604. return createNavigationTsx;
  14605. };
  14606. const props$j = {
  14607. itemId: {
  14608. type: String,
  14609. default: ""
  14610. }
  14611. };
  14612. const SwiperItem = /* @__PURE__ */ defineBuiltInComponent({
  14613. name: "SwiperItem",
  14614. props: props$j,
  14615. setup(props2, {
  14616. slots
  14617. }) {
  14618. const rootRef = ref(null);
  14619. const context = {
  14620. rootRef,
  14621. getItemId() {
  14622. return props2.itemId;
  14623. },
  14624. getBoundingClientRect() {
  14625. const el = rootRef.value;
  14626. return el.getBoundingClientRect();
  14627. },
  14628. updatePosition(position, vertical) {
  14629. const x = vertical ? "0" : 100 * position + "%";
  14630. const y = vertical ? 100 * position + "%" : "0";
  14631. const rootEl = rootRef.value;
  14632. const value = `translate(${x},${y}) translateZ(0)`;
  14633. if (rootEl) {
  14634. rootEl.style.webkitTransform = value;
  14635. rootEl.style.transform = value;
  14636. }
  14637. }
  14638. };
  14639. onMounted(() => {
  14640. const addSwiperContext = inject("addSwiperContext");
  14641. if (addSwiperContext) {
  14642. addSwiperContext(context);
  14643. }
  14644. });
  14645. onUnmounted(() => {
  14646. const removeSwiperContext = inject("removeSwiperContext");
  14647. if (removeSwiperContext) {
  14648. removeSwiperContext(context);
  14649. }
  14650. });
  14651. return () => {
  14652. return createVNode("uni-swiper-item", {
  14653. "ref": rootRef,
  14654. "style": {
  14655. position: "absolute",
  14656. width: "100%",
  14657. height: "100%"
  14658. }
  14659. }, [slots.default && slots.default()], 512);
  14660. };
  14661. }
  14662. });
  14663. const props$i = {
  14664. name: {
  14665. type: String,
  14666. default: ""
  14667. },
  14668. checked: {
  14669. type: [Boolean, String],
  14670. default: false
  14671. },
  14672. type: {
  14673. type: String,
  14674. default: "switch"
  14675. },
  14676. id: {
  14677. type: String,
  14678. default: ""
  14679. },
  14680. disabled: {
  14681. type: [Boolean, String],
  14682. default: false
  14683. },
  14684. color: {
  14685. type: String,
  14686. default: ""
  14687. }
  14688. };
  14689. const index$j = /* @__PURE__ */ defineBuiltInComponent({
  14690. name: "Switch",
  14691. props: props$i,
  14692. emits: ["change"],
  14693. setup(props2, {
  14694. emit: emit2
  14695. }) {
  14696. const rootRef = ref(null);
  14697. const switchChecked = ref(props2.checked);
  14698. const uniLabel = useSwitchInject(props2, switchChecked);
  14699. const trigger = useCustomEvent(rootRef, emit2);
  14700. watch(() => props2.checked, (val) => {
  14701. switchChecked.value = val;
  14702. });
  14703. const _onClick = ($event) => {
  14704. if (props2.disabled) {
  14705. return;
  14706. }
  14707. switchChecked.value = !switchChecked.value;
  14708. trigger("change", $event, {
  14709. value: switchChecked.value
  14710. });
  14711. };
  14712. if (!!uniLabel) {
  14713. uniLabel.addHandler(_onClick);
  14714. onBeforeUnmount(() => {
  14715. uniLabel.removeHandler(_onClick);
  14716. });
  14717. }
  14718. useListeners$1(props2, {
  14719. "label-click": _onClick
  14720. });
  14721. return () => {
  14722. const {
  14723. color,
  14724. type
  14725. } = props2;
  14726. const booleanAttrs = useBooleanAttr(props2, "disabled");
  14727. const switchInputStyle = {};
  14728. if (color && switchChecked.value) {
  14729. switchInputStyle["backgroundColor"] = color;
  14730. switchInputStyle["borderColor"] = color;
  14731. }
  14732. let realCheckValue;
  14733. realCheckValue = switchChecked.value;
  14734. return createVNode("uni-switch", mergeProps({
  14735. "id": props2.id,
  14736. "ref": rootRef
  14737. }, booleanAttrs, {
  14738. "onClick": _onClick
  14739. }), [createVNode("div", {
  14740. "class": "uni-switch-wrapper"
  14741. }, [withDirectives(createVNode("div", {
  14742. "class": ["uni-switch-input", [switchChecked.value ? "uni-switch-input-checked" : ""]],
  14743. "style": switchInputStyle
  14744. }, null, 6), [[vShow, type === "switch"]]), withDirectives(createVNode("div", {
  14745. "class": "uni-checkbox-input"
  14746. }, [realCheckValue ? createSvgIconVNode(ICON_PATH_SUCCESS_NO_CIRCLE, props2.color, 22) : ""], 512), [[vShow, type === "checkbox"]])])], 16, ["id", "onClick"]);
  14747. };
  14748. }
  14749. });
  14750. function useSwitchInject(props2, switchChecked) {
  14751. const uniForm = inject(uniFormKey, false);
  14752. const uniLabel = inject(uniLabelKey, false);
  14753. const formField = {
  14754. submit: () => {
  14755. const data = ["", null];
  14756. if (props2.name) {
  14757. data[0] = props2.name;
  14758. data[1] = switchChecked.value;
  14759. }
  14760. return data;
  14761. },
  14762. reset: () => {
  14763. switchChecked.value = false;
  14764. }
  14765. };
  14766. if (!!uniForm) {
  14767. uniForm.addField(formField);
  14768. onUnmounted(() => {
  14769. uniForm.removeField(formField);
  14770. });
  14771. }
  14772. return uniLabel;
  14773. }
  14774. const SPACE_UNICODE = {
  14775. ensp: " ",
  14776. emsp: " ",
  14777. nbsp: " "
  14778. };
  14779. function normalizeText(text2, { space, decode: decode2 }) {
  14780. let result = "";
  14781. let isEscape = false;
  14782. for (let char of text2) {
  14783. if (space && SPACE_UNICODE[space] && char === " ") {
  14784. char = SPACE_UNICODE[space];
  14785. }
  14786. if (isEscape) {
  14787. if (char === "n") {
  14788. result += LINEFEED;
  14789. } else if (char === "\\") {
  14790. result += "\\";
  14791. } else {
  14792. result += "\\" + char;
  14793. }
  14794. isEscape = false;
  14795. } else {
  14796. if (char === "\\") {
  14797. isEscape = true;
  14798. } else {
  14799. result += char;
  14800. }
  14801. }
  14802. }
  14803. if (!decode2) {
  14804. return result;
  14805. }
  14806. return result.replace(/&nbsp;/g, SPACE_UNICODE.nbsp).replace(/&ensp;/g, SPACE_UNICODE.ensp).replace(/&emsp;/g, SPACE_UNICODE.emsp).replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'");
  14807. }
  14808. function parseText(text2, options) {
  14809. return normalizeText(text2, options).split(LINEFEED);
  14810. }
  14811. const index$i = /* @__PURE__ */ defineBuiltInComponent({
  14812. name: "Text",
  14813. props: {
  14814. selectable: {
  14815. type: [Boolean, String],
  14816. default: false
  14817. },
  14818. space: {
  14819. type: String,
  14820. default: ""
  14821. },
  14822. decode: {
  14823. type: [Boolean, String],
  14824. default: false
  14825. }
  14826. },
  14827. setup(props2, {
  14828. slots
  14829. }) {
  14830. const rootRef = ref(null);
  14831. return () => {
  14832. const children = [];
  14833. if (slots.default) {
  14834. slots.default().forEach((vnode) => {
  14835. if (vnode.shapeFlag & 8 && vnode.type !== Comment) {
  14836. const lines = parseText(vnode.children, {
  14837. space: props2.space,
  14838. decode: props2.decode
  14839. });
  14840. const len = lines.length - 1;
  14841. lines.forEach((line, index2) => {
  14842. if (index2 === 0 && !line)
  14843. ;
  14844. else {
  14845. children.push(createTextVNode(line));
  14846. }
  14847. if (index2 !== len) {
  14848. children.push(createVNode("br"));
  14849. }
  14850. });
  14851. } else {
  14852. if (process.env.NODE_ENV !== "production" && vnode.shapeFlag & 6 && vnode.type.name !== "Text") {
  14853. console.warn("Do not nest other components in the text component, as there may be display differences on different platforms.");
  14854. }
  14855. children.push(vnode);
  14856. }
  14857. });
  14858. }
  14859. return createVNode("uni-text", {
  14860. "ref": rootRef,
  14861. "selectable": props2.selectable ? true : null
  14862. }, [createVNode("span", null, children)], 8, ["selectable"]);
  14863. };
  14864. }
  14865. });
  14866. const props$h = /* @__PURE__ */ extend({}, props$r, {
  14867. placeholderClass: {
  14868. type: String,
  14869. default: "input-placeholder"
  14870. },
  14871. autoHeight: {
  14872. type: [Boolean, String],
  14873. default: false
  14874. },
  14875. confirmType: {
  14876. type: String,
  14877. default: "return",
  14878. validator(val) {
  14879. return ConfirmTypes.concat("return").includes(val);
  14880. }
  14881. }
  14882. });
  14883. let fixMargin = false;
  14884. const ConfirmTypes = ["done", "go", "next", "search", "send"];
  14885. function setFixMargin() {
  14886. const DARK_TEST_STRING = "(prefers-color-scheme: dark)";
  14887. fixMargin = String(navigator.platform).indexOf("iP") === 0 && String(navigator.vendor).indexOf("Apple") === 0 && window.matchMedia(DARK_TEST_STRING).media !== DARK_TEST_STRING;
  14888. }
  14889. const index$h = /* @__PURE__ */ defineBuiltInComponent({
  14890. name: "Textarea",
  14891. props: props$h,
  14892. emits: ["confirm", "linechange", ...emit],
  14893. setup(props2, {
  14894. emit: emit2,
  14895. expose
  14896. }) {
  14897. const rootRef = ref(null);
  14898. const wrapperRef = ref(null);
  14899. const {
  14900. fieldRef,
  14901. state: state2,
  14902. scopedAttrsState,
  14903. fixDisabledColor,
  14904. trigger
  14905. } = useField(props2, rootRef, emit2);
  14906. const valueCompute = computed(() => state2.value.split(LINEFEED));
  14907. const isDone = computed(() => ConfirmTypes.includes(props2.confirmType));
  14908. const heightRef = ref(0);
  14909. const lineRef = ref(null);
  14910. watch(() => heightRef.value, (height) => {
  14911. const el = rootRef.value;
  14912. const lineEl = lineRef.value;
  14913. const wrapper2 = wrapperRef.value;
  14914. let lineHeight = parseFloat(getComputedStyle(el).lineHeight);
  14915. if (isNaN(lineHeight)) {
  14916. lineHeight = lineEl.offsetHeight;
  14917. }
  14918. var lineCount = Math.round(height / lineHeight);
  14919. trigger("linechange", {}, {
  14920. height,
  14921. heightRpx: 750 / window.innerWidth * height,
  14922. lineCount
  14923. });
  14924. if (props2.autoHeight) {
  14925. el.style.height = "auto";
  14926. wrapper2.style.height = height + "px";
  14927. }
  14928. });
  14929. function onResize2({
  14930. height
  14931. }) {
  14932. heightRef.value = height;
  14933. }
  14934. function confirm(event) {
  14935. trigger("confirm", event, {
  14936. value: state2.value
  14937. });
  14938. }
  14939. function onKeyDownEnter(event) {
  14940. if (event.key !== "Enter") {
  14941. return;
  14942. }
  14943. if (isDone.value) {
  14944. event.preventDefault();
  14945. }
  14946. }
  14947. function onKeyUpEnter(event) {
  14948. if (event.key !== "Enter") {
  14949. return;
  14950. }
  14951. if (isDone.value) {
  14952. confirm(event);
  14953. const textarea = event.target;
  14954. !props2.confirmHold && textarea.blur();
  14955. }
  14956. }
  14957. {
  14958. setFixMargin();
  14959. }
  14960. expose({
  14961. $triggerInput: (detail) => {
  14962. emit2("update:modelValue", detail.value);
  14963. emit2("update:value", detail.value);
  14964. state2.value = detail.value;
  14965. }
  14966. });
  14967. return () => {
  14968. let textareaNode = props2.disabled && fixDisabledColor ? createVNode("textarea", {
  14969. "key": "disabled-textarea",
  14970. "ref": fieldRef,
  14971. "value": state2.value,
  14972. "tabindex": "-1",
  14973. "readonly": !!props2.disabled,
  14974. "maxlength": state2.maxlength,
  14975. "class": {
  14976. "uni-textarea-textarea": true,
  14977. "uni-textarea-textarea-fix-margin": fixMargin
  14978. },
  14979. "style": {
  14980. overflowY: props2.autoHeight ? "hidden" : "auto",
  14981. /* eslint-disable no-restricted-syntax */
  14982. ...props2.cursorColor && {
  14983. caretColor: props2.cursorColor
  14984. }
  14985. },
  14986. "onFocus": (event) => event.target.blur()
  14987. }, null, 46, ["value", "readonly", "maxlength", "onFocus"]) : createVNode("textarea", {
  14988. "key": "textarea",
  14989. "ref": fieldRef,
  14990. "value": state2.value,
  14991. "disabled": !!props2.disabled,
  14992. "maxlength": state2.maxlength,
  14993. "enterkeyhint": props2.confirmType,
  14994. "inputmode": props2.inputmode,
  14995. "class": {
  14996. "uni-textarea-textarea": true,
  14997. "uni-textarea-textarea-fix-margin": fixMargin
  14998. },
  14999. "style": {
  15000. overflowY: props2.autoHeight ? "hidden" : "auto",
  15001. /* eslint-disable no-restricted-syntax */
  15002. ...props2.cursorColor && {
  15003. caretColor: props2.cursorColor
  15004. }
  15005. },
  15006. "onKeydown": onKeyDownEnter,
  15007. "onKeyup": onKeyUpEnter
  15008. }, null, 46, ["value", "disabled", "maxlength", "enterkeyhint", "inputmode", "onKeydown", "onKeyup"]);
  15009. return createVNode("uni-textarea", {
  15010. "ref": rootRef
  15011. }, [createVNode("div", {
  15012. "ref": wrapperRef,
  15013. "class": "uni-textarea-wrapper"
  15014. }, [withDirectives(createVNode("div", mergeProps(scopedAttrsState.attrs, {
  15015. "style": props2.placeholderStyle,
  15016. "class": ["uni-textarea-placeholder", props2.placeholderClass]
  15017. }), [props2.placeholder], 16), [[vShow, !state2.value.length]]), createVNode("div", {
  15018. "ref": lineRef,
  15019. "class": "uni-textarea-line"
  15020. }, [" "], 512), createVNode("div", {
  15021. "class": "uni-textarea-compute"
  15022. }, [valueCompute.value.map((item) => createVNode("div", null, [item.trim() ? item : "."])), createVNode(ResizeSensor, {
  15023. "initial": true,
  15024. "onResize": onResize2
  15025. }, null, 8, ["initial", "onResize"])]), props2.confirmType === "search" ? createVNode("form", {
  15026. "action": "",
  15027. "onSubmit": () => false,
  15028. "class": "uni-input-form"
  15029. }, [textareaNode], 40, ["onSubmit"]) : textareaNode], 512)], 512);
  15030. };
  15031. }
  15032. });
  15033. const index$g = /* @__PURE__ */ defineBuiltInComponent({
  15034. name: "View",
  15035. props: extend({}, hoverProps),
  15036. setup(props2, {
  15037. slots
  15038. }) {
  15039. const rootRef = ref(null);
  15040. const {
  15041. hovering,
  15042. binding
  15043. } = useHover(props2);
  15044. return () => {
  15045. const hoverClass = props2.hoverClass;
  15046. if (hoverClass && hoverClass !== "none") {
  15047. return createVNode("uni-view", mergeProps({
  15048. "class": hovering.value ? hoverClass : "",
  15049. "ref": rootRef
  15050. }, binding), [slots.default && slots.default()], 16);
  15051. }
  15052. return createVNode("uni-view", {
  15053. "ref": rootRef
  15054. }, [slots.default && slots.default()], 512);
  15055. };
  15056. }
  15057. });
  15058. function normalizeEvent(vm, id2) {
  15059. if (!id2) {
  15060. id2 = vm.id;
  15061. }
  15062. if (!id2) {
  15063. return;
  15064. }
  15065. return vm.$options.name.toLowerCase() + "." + id2;
  15066. }
  15067. function addSubscribe(name, callback, pageId) {
  15068. if (!name) {
  15069. return;
  15070. }
  15071. registerViewMethod(
  15072. pageId || getCurrentPageId(),
  15073. name,
  15074. ({ type, data }, resolve) => {
  15075. callback(type, data, resolve);
  15076. }
  15077. );
  15078. }
  15079. function removeSubscribe(name, pageId) {
  15080. if (!name) {
  15081. return;
  15082. }
  15083. unregisterViewMethod(pageId || getCurrentPageId(), name);
  15084. }
  15085. function useSubscribe(callback, name, multiple, pageId) {
  15086. const instance2 = getCurrentInstance();
  15087. const vm = instance2.proxy;
  15088. onMounted(() => {
  15089. addSubscribe(name || normalizeEvent(vm), callback, pageId);
  15090. if (multiple || !name) {
  15091. watch(
  15092. () => vm.id,
  15093. (value, oldValue) => {
  15094. addSubscribe(normalizeEvent(vm, value), callback, pageId);
  15095. removeSubscribe(oldValue && normalizeEvent(vm, oldValue));
  15096. }
  15097. );
  15098. }
  15099. });
  15100. onBeforeUnmount(() => {
  15101. removeSubscribe(name || normalizeEvent(vm), pageId);
  15102. });
  15103. }
  15104. function useOn(name, callback) {
  15105. onMounted(() => UniViewJSBridge.on(name, callback));
  15106. onBeforeUnmount(() => UniViewJSBridge.off(name));
  15107. }
  15108. let index$f = 0;
  15109. function useContextInfo(_id) {
  15110. const page = useCurrentPageId();
  15111. const instance2 = getCurrentInstance();
  15112. const vm = instance2.proxy;
  15113. const type = vm.$options.name.toLowerCase();
  15114. const id2 = _id || vm.id || `context${index$f++}`;
  15115. onMounted(() => {
  15116. const el = vm.$el;
  15117. el.__uniContextInfo = {
  15118. id: id2,
  15119. type,
  15120. page
  15121. };
  15122. });
  15123. return `${type}.${id2}`;
  15124. }
  15125. function getContextInfo(el) {
  15126. return el.__uniContextInfo;
  15127. }
  15128. function injectLifecycleHook(name, hook, publicThis, instance2) {
  15129. if (isFunction(hook)) {
  15130. injectHook(name, hook.bind(publicThis), instance2);
  15131. }
  15132. }
  15133. function initHooks(options, instance2, publicThis) {
  15134. var _a;
  15135. const mpType = options.mpType || publicThis.$mpType;
  15136. if (!mpType || mpType === "component") {
  15137. return;
  15138. }
  15139. Object.keys(options).forEach((name) => {
  15140. if (isUniLifecycleHook(name, options[name], false)) {
  15141. const hooks = options[name];
  15142. if (isArray(hooks)) {
  15143. hooks.forEach(
  15144. (hook) => injectLifecycleHook(name, hook, publicThis, instance2)
  15145. );
  15146. } else {
  15147. injectLifecycleHook(name, hooks, publicThis, instance2);
  15148. }
  15149. }
  15150. });
  15151. if (mpType === "page") {
  15152. instance2.__isVisible = true;
  15153. try {
  15154. invokeHook(publicThis, ON_LOAD, instance2.attrs.__pageQuery);
  15155. delete instance2.attrs.__pageQuery;
  15156. if (((_a = publicThis.$page) == null ? void 0 : _a.openType) !== "preloadPage") {
  15157. invokeHook(publicThis, ON_SHOW);
  15158. }
  15159. } catch (e2) {
  15160. console.error(e2.message + LINEFEED + e2.stack);
  15161. }
  15162. }
  15163. }
  15164. function applyOptions(options, instance2, publicThis) {
  15165. initHooks(options, instance2, publicThis);
  15166. }
  15167. function set(target, key, val) {
  15168. return target[key] = val;
  15169. }
  15170. function $callMethod(method, ...args) {
  15171. const fn = this[method];
  15172. if (fn) {
  15173. return fn(...args);
  15174. }
  15175. console.error(`method ${method} not found`);
  15176. return null;
  15177. }
  15178. function createErrorHandler(app) {
  15179. return function errorHandler(err, instance2, _info) {
  15180. if (!instance2) {
  15181. throw err;
  15182. }
  15183. const appInstance = app._instance;
  15184. if (!appInstance || !appInstance.proxy) {
  15185. throw err;
  15186. }
  15187. {
  15188. invokeHook(appInstance.proxy, ON_ERROR, err);
  15189. }
  15190. };
  15191. }
  15192. function mergeAsArray(to, from) {
  15193. return to ? [...new Set([].concat(to, from))] : from;
  15194. }
  15195. function initOptionMergeStrategies(optionMergeStrategies) {
  15196. UniLifecycleHooks.forEach((name) => {
  15197. optionMergeStrategies[name] = mergeAsArray;
  15198. });
  15199. }
  15200. let realAtob;
  15201. const b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  15202. const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
  15203. if (typeof atob !== "function") {
  15204. realAtob = function(str) {
  15205. str = String(str).replace(/[\t\n\f\r ]+/g, "");
  15206. if (!b64re.test(str)) {
  15207. throw new Error(
  15208. "Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded."
  15209. );
  15210. }
  15211. str += "==".slice(2 - (str.length & 3));
  15212. var bitmap;
  15213. var result = "";
  15214. var r1;
  15215. var r2;
  15216. var i = 0;
  15217. for (; i < str.length; ) {
  15218. bitmap = b64.indexOf(str.charAt(i++)) << 18 | b64.indexOf(str.charAt(i++)) << 12 | (r1 = b64.indexOf(str.charAt(i++))) << 6 | (r2 = b64.indexOf(str.charAt(i++)));
  15219. result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255) : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255) : String.fromCharCode(
  15220. bitmap >> 16 & 255,
  15221. bitmap >> 8 & 255,
  15222. bitmap & 255
  15223. );
  15224. }
  15225. return result;
  15226. };
  15227. } else {
  15228. realAtob = atob;
  15229. }
  15230. function b64DecodeUnicode(str) {
  15231. return decodeURIComponent(
  15232. realAtob(str).split("").map(function(c) {
  15233. return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
  15234. }).join("")
  15235. );
  15236. }
  15237. function getCurrentUserInfo() {
  15238. const token = uni.getStorageSync("uni_id_token") || "";
  15239. const tokenArr = token.split(".");
  15240. if (!token || tokenArr.length !== 3) {
  15241. return {
  15242. uid: null,
  15243. role: [],
  15244. permission: [],
  15245. tokenExpired: 0
  15246. };
  15247. }
  15248. let userInfo;
  15249. try {
  15250. userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
  15251. } catch (error) {
  15252. throw new Error("获取当前用户信息出错,详细错误信息为:" + error.message);
  15253. }
  15254. userInfo.tokenExpired = userInfo.exp * 1e3;
  15255. delete userInfo.exp;
  15256. delete userInfo.iat;
  15257. return userInfo;
  15258. }
  15259. function uniIdMixin(globalProperties) {
  15260. globalProperties.uniIDHasRole = function(roleId) {
  15261. const { role } = getCurrentUserInfo();
  15262. return role.indexOf(roleId) > -1;
  15263. };
  15264. globalProperties.uniIDHasPermission = function(permissionId) {
  15265. const { permission } = getCurrentUserInfo();
  15266. return this.uniIDHasRole("admin") || permission.indexOf(permissionId) > -1;
  15267. };
  15268. globalProperties.uniIDTokenValid = function() {
  15269. const { tokenExpired } = getCurrentUserInfo();
  15270. return tokenExpired > Date.now();
  15271. };
  15272. }
  15273. function initApp$1(app) {
  15274. const appConfig = app._context.config;
  15275. appConfig.errorHandler = invokeCreateErrorHandler(app, createErrorHandler);
  15276. initOptionMergeStrategies(appConfig.optionMergeStrategies);
  15277. const globalProperties = appConfig.globalProperties;
  15278. {
  15279. if (__UNI_FEATURE_UNI_CLOUD__) {
  15280. uniIdMixin(globalProperties);
  15281. }
  15282. }
  15283. {
  15284. globalProperties.$set = set;
  15285. globalProperties.$applyOptions = applyOptions;
  15286. globalProperties.$callMethod = $callMethod;
  15287. }
  15288. {
  15289. invokeCreateVueAppHook(app);
  15290. }
  15291. }
  15292. const pageMetaKey = PolySymbol(process.env.NODE_ENV !== "production" ? "UniPageMeta" : "upm");
  15293. function usePageMeta() {
  15294. return inject(pageMetaKey);
  15295. }
  15296. function providePageMeta(id2) {
  15297. const pageMeta = initPageMeta(id2);
  15298. provide(pageMetaKey, pageMeta);
  15299. return pageMeta;
  15300. }
  15301. function usePageRoute() {
  15302. if (__UNI_FEATURE_PAGES__) {
  15303. return useRoute();
  15304. }
  15305. const url = location.href;
  15306. const searchPos = url.indexOf("?");
  15307. const hashPos = url.indexOf("#", searchPos > -1 ? searchPos : 0);
  15308. let query = {};
  15309. if (searchPos > -1) {
  15310. query = parseQuery(
  15311. url.slice(searchPos + 1, hashPos > -1 ? hashPos : url.length)
  15312. );
  15313. }
  15314. const { meta } = __uniRoutes[0];
  15315. const path = addLeadingSlash(meta.route);
  15316. return {
  15317. meta,
  15318. query,
  15319. path,
  15320. matched: [{ path }]
  15321. };
  15322. }
  15323. function initPageMeta(id2) {
  15324. if (__UNI_FEATURE_PAGES__) {
  15325. return reactive(
  15326. normalizePageMeta(
  15327. JSON.parse(
  15328. JSON.stringify(
  15329. initRouteMeta(
  15330. useRoute().meta,
  15331. id2
  15332. )
  15333. )
  15334. )
  15335. )
  15336. );
  15337. }
  15338. return reactive(
  15339. normalizePageMeta(
  15340. JSON.parse(JSON.stringify(initRouteMeta(__uniRoutes[0].meta, id2)))
  15341. )
  15342. );
  15343. }
  15344. function normalizePageMeta(pageMeta) {
  15345. if (__UNI_FEATURE_PULL_DOWN_REFRESH__) {
  15346. const { enablePullDownRefresh, navigationBar } = pageMeta;
  15347. if (enablePullDownRefresh) {
  15348. const pullToRefresh = normalizePullToRefreshRpx(
  15349. extend(
  15350. {
  15351. support: true,
  15352. color: "#2BD009",
  15353. style: "circle",
  15354. height: 70,
  15355. range: 150,
  15356. offset: 0
  15357. },
  15358. pageMeta.pullToRefresh
  15359. )
  15360. );
  15361. const { type, style } = navigationBar;
  15362. if (style !== "custom" && type !== "transparent") {
  15363. pullToRefresh.offset += NAVBAR_HEIGHT + safeAreaInsets$1.top;
  15364. }
  15365. pageMeta.pullToRefresh = pullToRefresh;
  15366. }
  15367. }
  15368. if (__UNI_FEATURE_NAVIGATIONBAR__) {
  15369. const { navigationBar } = pageMeta;
  15370. const { titleSize, titleColor, backgroundColor } = navigationBar;
  15371. navigationBar.titleText = navigationBar.titleText || "";
  15372. navigationBar.type = navigationBar.type || "default";
  15373. navigationBar.titleSize = titleSize || "16px";
  15374. navigationBar.titleColor = titleColor || "#000000";
  15375. navigationBar.backgroundColor = backgroundColor || "#F8F8F8";
  15376. __UNI_FEATURE_I18N_LOCALE__ && initNavigationBarI18n(navigationBar);
  15377. }
  15378. if (__UNI_FEATURE_PAGES__ && history.state) {
  15379. const type = history.state.__type__;
  15380. if ((type === "redirectTo" || type === "reLaunch") && getCurrentPages().length === 0) {
  15381. pageMeta.isEntry = true;
  15382. pageMeta.isQuit = true;
  15383. }
  15384. }
  15385. return pageMeta;
  15386. }
  15387. const screen$1 = window.screen;
  15388. const documentElement = document.documentElement;
  15389. function checkMinWidth(minWidth) {
  15390. const sizes = [
  15391. window.outerWidth,
  15392. window.outerHeight,
  15393. screen$1.width,
  15394. screen$1.height,
  15395. documentElement.clientWidth,
  15396. documentElement.clientHeight
  15397. ];
  15398. return Math.max.apply(null, sizes) > minWidth;
  15399. }
  15400. function getStateId() {
  15401. return history.state && history.state.__id__ || 1;
  15402. }
  15403. let tabBar;
  15404. function useTabBar() {
  15405. if (!tabBar) {
  15406. tabBar = __uniConfig.tabBar && reactive(initTabBarI18n(__uniConfig.tabBar));
  15407. }
  15408. return tabBar;
  15409. }
  15410. const supports = window.CSS && window.CSS.supports;
  15411. function cssSupports(css) {
  15412. return supports && (supports(css) || supports.apply(window.CSS, css.split(":")));
  15413. }
  15414. const cssVar = /* @__PURE__ */ cssSupports("--a:0");
  15415. const cssEnv = /* @__PURE__ */ cssSupports("top:env(a)");
  15416. const cssConstant = /* @__PURE__ */ cssSupports("top:constant(a)");
  15417. const cssBackdropFilter = /* @__PURE__ */ cssSupports("backdrop-filter:blur(10px)");
  15418. const SCHEMA_CSS = {
  15419. "css.var": cssVar,
  15420. "css.env": cssEnv,
  15421. "css.constant": cssConstant,
  15422. "css.backdrop-filter": cssBackdropFilter
  15423. };
  15424. const canIUse = /* @__PURE__ */ defineSyncApi(
  15425. API_CAN_I_USE,
  15426. (schema) => {
  15427. if (hasOwn(SCHEMA_CSS, schema)) {
  15428. return SCHEMA_CSS[schema];
  15429. }
  15430. return true;
  15431. },
  15432. CanIUseProtocol
  15433. );
  15434. const envMethod = /* @__PURE__ */ (() => cssEnv ? "env" : cssConstant ? "constant" : "")();
  15435. function updateCurPageCssVar(pageMeta) {
  15436. let windowTopValue = 0;
  15437. let windowBottomValue = 0;
  15438. if (__UNI_FEATURE_NAVIGATIONBAR__ && pageMeta.navigationBar.style !== "custom" && ["default", "float"].indexOf(pageMeta.navigationBar.type) > -1) {
  15439. windowTopValue = NAVBAR_HEIGHT;
  15440. }
  15441. if (__UNI_FEATURE_TABBAR__ && pageMeta.isTabBar) {
  15442. const tabBar2 = useTabBar();
  15443. tabBar2.shown && (windowBottomValue = parseInt(tabBar2.height));
  15444. }
  15445. updatePageCssVar({
  15446. "--window-top": normalizeWindowTop(windowTopValue),
  15447. "--window-bottom": normalizeWindowBottom(windowBottomValue)
  15448. });
  15449. }
  15450. function normalizeWindowTop(windowTop) {
  15451. return envMethod ? `calc(${windowTop}px + ${envMethod}(safe-area-inset-top))` : `${windowTop}px`;
  15452. }
  15453. function normalizeWindowBottom(windowBottom) {
  15454. return envMethod ? `calc(${windowBottom}px + ${envMethod}(safe-area-inset-bottom))` : `${windowBottom}px`;
  15455. }
  15456. const SEP = "$$";
  15457. const currentPagesMap = /* @__PURE__ */ new Map();
  15458. function pruneCurrentPages() {
  15459. currentPagesMap.forEach((page, id2) => {
  15460. if (page.$.isUnmounted) {
  15461. currentPagesMap.delete(id2);
  15462. }
  15463. });
  15464. }
  15465. function getCurrentPagesMap() {
  15466. return currentPagesMap;
  15467. }
  15468. function getCurrentPages$1() {
  15469. const curPages = [];
  15470. const pages = currentPagesMap.values();
  15471. for (const page of pages) {
  15472. if (page.$.__isTabBar) {
  15473. if (page.$.__isActive) {
  15474. curPages.push(page);
  15475. }
  15476. } else {
  15477. curPages.push(page);
  15478. }
  15479. }
  15480. return curPages;
  15481. }
  15482. function removeRouteCache(routeKey) {
  15483. const vnode = pageCacheMap.get(routeKey);
  15484. if (vnode) {
  15485. pageCacheMap.delete(routeKey);
  15486. routeCache.pruneCacheEntry(vnode);
  15487. }
  15488. }
  15489. function removePage(routeKey, removeRouteCaches = true) {
  15490. const pageVm = currentPagesMap.get(routeKey);
  15491. pageVm.$.__isUnload = true;
  15492. invokeHook(pageVm, ON_UNLOAD);
  15493. currentPagesMap.delete(routeKey);
  15494. removeRouteCaches && removeRouteCache(routeKey);
  15495. }
  15496. let id = /* @__PURE__ */ getStateId();
  15497. function createPageState(type, __id__) {
  15498. return {
  15499. __id__: __id__ || ++id,
  15500. __type__: type
  15501. };
  15502. }
  15503. function initPublicPage(route) {
  15504. const meta = usePageMeta();
  15505. if (!__UNI_FEATURE_PAGES__) {
  15506. return initPageInternalInstance("navigateTo", __uniRoutes[0].path, {}, meta);
  15507. }
  15508. let fullPath = route.fullPath;
  15509. if (route.meta.isEntry && fullPath.indexOf(route.meta.route) === -1) {
  15510. fullPath = "/" + route.meta.route + fullPath.replace("/", "");
  15511. }
  15512. return initPageInternalInstance("navigateTo", fullPath, {}, meta);
  15513. }
  15514. function initPage(vm) {
  15515. const route = vm.$route;
  15516. const page = initPublicPage(route);
  15517. initPageVm(vm, page);
  15518. currentPagesMap.set(normalizeRouteKey(page.path, page.id), vm);
  15519. }
  15520. function normalizeRouteKey(path, id2) {
  15521. return path + SEP + id2;
  15522. }
  15523. function useKeepAliveRoute() {
  15524. const route = useRoute();
  15525. const routeKey = computed(
  15526. () => normalizeRouteKey("/" + route.meta.route, getStateId())
  15527. );
  15528. const isTabBar = computed(() => route.meta.isTabBar);
  15529. return {
  15530. routeKey,
  15531. isTabBar,
  15532. routeCache
  15533. };
  15534. }
  15535. const pageCacheMap = /* @__PURE__ */ new Map();
  15536. const routeCache = {
  15537. get(key) {
  15538. return pageCacheMap.get(key);
  15539. },
  15540. set(key, value) {
  15541. pruneRouteCache(key);
  15542. pageCacheMap.set(key, value);
  15543. },
  15544. delete(key) {
  15545. const vnode = pageCacheMap.get(key);
  15546. if (!vnode) {
  15547. return;
  15548. }
  15549. pageCacheMap.delete(key);
  15550. },
  15551. forEach(fn) {
  15552. pageCacheMap.forEach(fn);
  15553. }
  15554. };
  15555. function isTabBarVNode(vnode) {
  15556. return vnode.props.type === "tabBar";
  15557. }
  15558. function pruneRouteCache(key) {
  15559. const pageId = parseInt(key.split(SEP)[1]);
  15560. if (!pageId) {
  15561. return;
  15562. }
  15563. routeCache.forEach((vnode, key2) => {
  15564. const cPageId = parseInt(key2.split(SEP)[1]);
  15565. if (cPageId && cPageId > pageId) {
  15566. if (__UNI_FEATURE_TABBAR__ && isTabBarVNode(vnode)) {
  15567. return;
  15568. }
  15569. routeCache.delete(key2);
  15570. routeCache.pruneCacheEntry(vnode);
  15571. nextTick(() => pruneCurrentPages());
  15572. }
  15573. });
  15574. }
  15575. function updateCurPageAttrs(pageMeta) {
  15576. {
  15577. const nvueDirKey = "nvue-dir-" + __uniConfig.nvue["flex-direction"];
  15578. if (pageMeta.isNVue) {
  15579. document.body.setAttribute("nvue", "");
  15580. document.body.setAttribute(nvueDirKey, "");
  15581. } else {
  15582. document.body.removeAttribute("nvue");
  15583. document.body.removeAttribute(nvueDirKey);
  15584. }
  15585. }
  15586. }
  15587. function onPageShow(instance2, pageMeta) {
  15588. updateBodyScopeId(instance2);
  15589. updateCurPageCssVar(pageMeta);
  15590. updateCurPageAttrs(pageMeta);
  15591. initPageScrollListener(instance2, pageMeta);
  15592. }
  15593. function onPageReady(instance2) {
  15594. const scopeId = getScopeId(instance2);
  15595. scopeId && updateCurPageBodyScopeId(scopeId);
  15596. }
  15597. function updateCurPageBodyScopeId(scopeId) {
  15598. const pageBodyEl = document.querySelector("uni-page-body");
  15599. if (pageBodyEl) {
  15600. pageBodyEl.setAttribute(scopeId, "");
  15601. } else if (process.env.NODE_ENV !== "production") {
  15602. console.warn("uni-page-body not found");
  15603. }
  15604. }
  15605. function getScopeId(instance2) {
  15606. return instance2.type.__scopeId;
  15607. }
  15608. let curScopeId;
  15609. function updateBodyScopeId(instance2) {
  15610. const scopeId = getScopeId(instance2);
  15611. const { body } = document;
  15612. curScopeId && body.removeAttribute(curScopeId);
  15613. scopeId && body.setAttribute(scopeId, "");
  15614. curScopeId = scopeId;
  15615. }
  15616. let curScrollListener;
  15617. function initPageScrollListener(instance2, pageMeta) {
  15618. document.removeEventListener("touchmove", disableScrollListener);
  15619. if (curScrollListener) {
  15620. document.removeEventListener("scroll", curScrollListener);
  15621. }
  15622. if (pageMeta.disableScroll) {
  15623. return document.addEventListener("touchmove", disableScrollListener);
  15624. }
  15625. const { onPageScroll, onReachBottom } = instance2;
  15626. const navigationBarTransparent = pageMeta.navigationBar.type === "transparent";
  15627. if (!onPageScroll && !onReachBottom && !navigationBarTransparent) {
  15628. return;
  15629. }
  15630. const opts = {};
  15631. const pageId = instance2.proxy.$page.id;
  15632. if (onPageScroll || navigationBarTransparent) {
  15633. opts.onPageScroll = createOnPageScroll(
  15634. pageId,
  15635. onPageScroll,
  15636. navigationBarTransparent
  15637. );
  15638. }
  15639. if (onReachBottom) {
  15640. opts.onReachBottomDistance = pageMeta.onReachBottomDistance || ON_REACH_BOTTOM_DISTANCE;
  15641. opts.onReachBottom = () => UniViewJSBridge.publishHandler(ON_REACH_BOTTOM, {}, pageId);
  15642. }
  15643. curScrollListener = createScrollListener(opts);
  15644. requestAnimationFrame(
  15645. () => document.addEventListener("scroll", curScrollListener)
  15646. );
  15647. }
  15648. function createOnPageScroll(pageId, onPageScroll, navigationBarTransparent) {
  15649. return (scrollTop) => {
  15650. if (onPageScroll) {
  15651. UniViewJSBridge.publishHandler(ON_PAGE_SCROLL, { scrollTop }, pageId);
  15652. }
  15653. if (navigationBarTransparent) {
  15654. UniViewJSBridge.emit(pageId + "." + ON_PAGE_SCROLL, {
  15655. scrollTop
  15656. });
  15657. }
  15658. };
  15659. }
  15660. function initRouter(app) {
  15661. const router = createRouter(createRouterOptions());
  15662. app.router = router;
  15663. app.use(router);
  15664. }
  15665. const scrollBehavior = (_to, _from, savedPosition) => {
  15666. if (savedPosition) {
  15667. return savedPosition;
  15668. }
  15669. };
  15670. function createRouterOptions() {
  15671. return {
  15672. history: initHistory(),
  15673. strict: !!__uniConfig.router.strict,
  15674. routes: __uniRoutes,
  15675. scrollBehavior
  15676. };
  15677. }
  15678. function removeCurrentPages(delta = 1) {
  15679. const keys = getCurrentPages$1();
  15680. const start = keys.length - 1;
  15681. const end = start - delta;
  15682. for (let i = start; i > end; i--) {
  15683. const page = keys[i].$page;
  15684. removePage(normalizeRouteKey(page.path, page.id), false);
  15685. }
  15686. }
  15687. function initHistory() {
  15688. let { routerBase } = __uniConfig.router;
  15689. if (routerBase === "/") {
  15690. routerBase = "";
  15691. }
  15692. const history2 = __UNI_FEATURE_ROUTER_MODE__ === "history" ? createWebHistory(routerBase) : createWebHashHistory(routerBase);
  15693. history2.listen((_to, _from, info) => {
  15694. if (info.direction === "back") {
  15695. removeCurrentPages(Math.abs(info.delta));
  15696. }
  15697. });
  15698. return history2;
  15699. }
  15700. const index$e = {
  15701. install(app) {
  15702. initApp$1(app);
  15703. initViewPlugin(app);
  15704. initServicePlugin(app);
  15705. if (!app.config.warnHandler) {
  15706. app.config.warnHandler = warnHandler;
  15707. }
  15708. if (__UNI_FEATURE_PAGES__) {
  15709. initRouter(app);
  15710. }
  15711. }
  15712. };
  15713. function warnHandler(msg, instance2, trace) {
  15714. if (instance2) {
  15715. const name = instance2.$.type.name;
  15716. if ("PageMetaHead" === name) {
  15717. return;
  15718. }
  15719. const parent = instance2.$.parent;
  15720. if (parent && parent.type.name === "PageMeta") {
  15721. return;
  15722. }
  15723. }
  15724. const warnArgs = [`[Vue warn]: ${msg}`];
  15725. if (trace.length) {
  15726. warnArgs.push(`
  15727. `, trace);
  15728. }
  15729. console.warn(...warnArgs);
  15730. }
  15731. const clazz = { class: "uni-async-loading" };
  15732. const loadingVNode = /* @__PURE__ */ createVNode(
  15733. "i",
  15734. { class: "uni-loading" },
  15735. null,
  15736. -1
  15737. /* HOISTED */
  15738. );
  15739. const AsyncLoadingComponent = /* @__PURE__ */ defineSystemComponent({
  15740. name: "AsyncLoading",
  15741. render() {
  15742. return openBlock(), createBlock("div", clazz, [loadingVNode]);
  15743. }
  15744. });
  15745. function reload() {
  15746. window.location.reload();
  15747. }
  15748. const AsyncErrorComponent = /* @__PURE__ */ defineSystemComponent({
  15749. name: "AsyncError",
  15750. setup() {
  15751. initI18nAsyncMsgsOnce();
  15752. const {
  15753. t: t2
  15754. } = useI18n();
  15755. return () => createVNode("div", {
  15756. "class": "uni-async-error",
  15757. "onClick": reload
  15758. }, [t2("uni.async.error")], 8, ["onClick"]);
  15759. }
  15760. });
  15761. let appVm;
  15762. function getApp$1() {
  15763. return appVm;
  15764. }
  15765. function initApp(vm) {
  15766. appVm = vm;
  15767. Object.defineProperty(appVm.$.ctx, "$children", {
  15768. get() {
  15769. return getCurrentPages().map((page) => page.$vm);
  15770. }
  15771. });
  15772. const app = appVm.$.appContext.app;
  15773. if (!app.component(AsyncLoadingComponent.name)) {
  15774. app.component(AsyncLoadingComponent.name, AsyncLoadingComponent);
  15775. }
  15776. if (!app.component(AsyncErrorComponent.name)) {
  15777. app.component(AsyncErrorComponent.name, AsyncErrorComponent);
  15778. }
  15779. initAppVm(appVm);
  15780. defineGlobalData(appVm);
  15781. initService();
  15782. initView();
  15783. }
  15784. function wrapperComponentSetup(comp, { clone, init: init2, setup, before }) {
  15785. if (clone) {
  15786. comp = extend({}, comp);
  15787. }
  15788. before && before(comp);
  15789. const oldSetup = comp.setup;
  15790. comp.setup = (props2, ctx) => {
  15791. const instance2 = getCurrentInstance();
  15792. init2(instance2.proxy);
  15793. const query = setup(instance2);
  15794. if (oldSetup) {
  15795. return oldSetup(query || props2, ctx);
  15796. }
  15797. };
  15798. return comp;
  15799. }
  15800. function setupComponent(comp, options) {
  15801. if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
  15802. return wrapperComponentSetup(comp.default, options);
  15803. }
  15804. return wrapperComponentSetup(comp, options);
  15805. }
  15806. function setupWindow(comp, id2) {
  15807. return setupComponent(comp, {
  15808. init: (vm) => {
  15809. vm.$page = {
  15810. id: id2
  15811. };
  15812. },
  15813. setup(instance2) {
  15814. instance2.$pageInstance = instance2;
  15815. }
  15816. });
  15817. }
  15818. function setupPage(comp) {
  15819. if (process.env.NODE_ENV !== "production") {
  15820. comp.__mpType = "page";
  15821. }
  15822. return setupComponent(comp, {
  15823. clone: true,
  15824. // 页面组件可能会被其他地方手动引用,比如 windows 等,需要 clone 一份新的作为页面组件
  15825. init: initPage,
  15826. setup(instance2) {
  15827. instance2.$pageInstance = instance2;
  15828. const route = usePageRoute();
  15829. const query = decodedQuery(route.query);
  15830. instance2.attrs.__pageQuery = query;
  15831. instance2.proxy.$page.options = query;
  15832. instance2.proxy.options = query;
  15833. const pageMeta = usePageMeta();
  15834. onBeforeMount(() => {
  15835. onPageShow(instance2, pageMeta);
  15836. });
  15837. onMounted(() => {
  15838. onPageReady(instance2);
  15839. const { onReady } = instance2;
  15840. onReady && invokeArrayFns$1(onReady);
  15841. invokeOnTabItemTap(route);
  15842. });
  15843. onBeforeActivate(() => {
  15844. if (!instance2.__isVisible) {
  15845. onPageShow(instance2, pageMeta);
  15846. instance2.__isVisible = true;
  15847. const { onShow } = instance2;
  15848. onShow && invokeArrayFns$1(onShow);
  15849. nextTick(() => {
  15850. invokeOnTabItemTap(route);
  15851. });
  15852. }
  15853. });
  15854. onBeforeDeactivate(() => {
  15855. if (instance2.__isVisible && !instance2.__isUnload) {
  15856. instance2.__isVisible = false;
  15857. const { onHide } = instance2;
  15858. onHide && invokeArrayFns$1(onHide);
  15859. }
  15860. });
  15861. subscribeViewMethod(pageMeta.id);
  15862. onBeforeUnmount(() => {
  15863. unsubscribeViewMethod(pageMeta.id);
  15864. });
  15865. return query;
  15866. }
  15867. });
  15868. }
  15869. function setupApp(comp) {
  15870. if (process.env.NODE_ENV !== "production") {
  15871. comp.__mpType = "app";
  15872. }
  15873. return setupComponent(comp, {
  15874. init: initApp,
  15875. setup(instance2) {
  15876. const route = usePageRoute();
  15877. const onLaunch = () => {
  15878. injectAppHooks(instance2);
  15879. const { onLaunch: onLaunch2, onShow, onPageNotFound: onPageNotFound2, onError: onError2 } = instance2;
  15880. const path = route.path.slice(1);
  15881. const launchOptions2 = initLaunchOptions({
  15882. path: path || __uniRoutes[0].meta.route,
  15883. query: decodedQuery(route.query)
  15884. });
  15885. onLaunch2 && invokeArrayFns$1(onLaunch2, launchOptions2);
  15886. onShow && invokeArrayFns$1(onShow, launchOptions2);
  15887. if (__UNI_FEATURE_PAGES__) {
  15888. if (!route.matched.length) {
  15889. const pageNotFoundOptions = {
  15890. notFound: true,
  15891. openType: "appLaunch",
  15892. path: route.path,
  15893. query: {},
  15894. scene: 1001
  15895. };
  15896. onPageNotFound2 && invokeArrayFns$1(onPageNotFound2, pageNotFoundOptions);
  15897. }
  15898. }
  15899. if (onError2) {
  15900. instance2.appContext.config.errorHandler = (err) => {
  15901. invokeArrayFns$1(onError2, err);
  15902. };
  15903. }
  15904. };
  15905. if (__UNI_FEATURE_PAGES__) {
  15906. useRouter().isReady().then(onLaunch);
  15907. } else {
  15908. onBeforeMount(onLaunch);
  15909. }
  15910. onMounted(() => {
  15911. window.addEventListener(
  15912. "resize",
  15913. debounce(onResize, 50, { setTimeout, clearTimeout })
  15914. );
  15915. window.addEventListener("message", onMessage);
  15916. document.addEventListener("visibilitychange", onVisibilityChange);
  15917. onThemeChange$2();
  15918. });
  15919. return route.query;
  15920. },
  15921. before(comp2) {
  15922. comp2.mpType = "app";
  15923. const { setup } = comp2;
  15924. const render = () => {
  15925. return openBlock(), createBlock(LayoutComponent);
  15926. };
  15927. comp2.setup = (props2, ctx) => {
  15928. const res = setup && setup(props2, ctx);
  15929. return isFunction(res) ? render : res;
  15930. };
  15931. comp2.render = render;
  15932. }
  15933. });
  15934. }
  15935. function onResize() {
  15936. const { windowWidth, windowHeight, screenWidth, screenHeight } = uni.getSystemInfoSync();
  15937. const landscape = Math.abs(Number(window.orientation)) === 90;
  15938. const deviceOrientation = landscape ? "landscape" : "portrait";
  15939. UniServiceJSBridge.emit(ON_RESIZE, {
  15940. deviceOrientation,
  15941. size: {
  15942. windowWidth,
  15943. windowHeight,
  15944. screenWidth,
  15945. screenHeight
  15946. }
  15947. });
  15948. }
  15949. function onMessage(evt) {
  15950. if (isPlainObject(evt.data) && evt.data.type === WEB_INVOKE_APPSERVICE) {
  15951. UniServiceJSBridge.emit(
  15952. ON_WEB_INVOKE_APP_SERVICE,
  15953. evt.data.data,
  15954. evt.data.pageId
  15955. );
  15956. }
  15957. }
  15958. function onVisibilityChange() {
  15959. const { emit: emit2 } = UniServiceJSBridge;
  15960. if (document.visibilityState === "visible") {
  15961. emit2(ON_APP_ENTER_FOREGROUND, getEnterOptions());
  15962. } else {
  15963. emit2(ON_APP_ENTER_BACKGROUND);
  15964. }
  15965. }
  15966. function onThemeChange$2() {
  15967. let mediaQueryList = null;
  15968. try {
  15969. mediaQueryList = window.matchMedia("(prefers-color-scheme: dark)");
  15970. } catch (error) {
  15971. }
  15972. if (mediaQueryList) {
  15973. let callback = (e2) => {
  15974. UniServiceJSBridge.emit(ON_THEME_CHANGE, {
  15975. theme: e2.matches ? "dark" : "light"
  15976. });
  15977. };
  15978. if (mediaQueryList.addEventListener) {
  15979. mediaQueryList.addEventListener("change", callback);
  15980. } else {
  15981. mediaQueryList.addListener(callback);
  15982. }
  15983. }
  15984. }
  15985. function invokeOnTabItemTap(route) {
  15986. const { tabBarText, tabBarIndex, route: pagePath } = route.meta;
  15987. if (tabBarText) {
  15988. invokeHook("onTabItemTap", {
  15989. index: tabBarIndex,
  15990. text: tabBarText,
  15991. pagePath
  15992. });
  15993. }
  15994. }
  15995. function formatTime(val) {
  15996. val = val > 0 && val < Infinity ? val : 0;
  15997. const h2 = Math.floor(val / 3600);
  15998. const m = Math.floor(val % 3600 / 60);
  15999. const s = Math.floor(val % 3600 % 60);
  16000. const hStr = (h2 < 10 ? "0" : "") + h2;
  16001. const mStr = (m < 10 ? "0" : "") + m;
  16002. const sStr = (s < 10 ? "0" : "") + s;
  16003. let str = mStr + ":" + sStr;
  16004. if (hStr !== "00") {
  16005. str = hStr + ":" + str;
  16006. }
  16007. return str;
  16008. }
  16009. function useGesture(props2, videoRef, fullscreenState) {
  16010. const state2 = reactive({
  16011. gestureType: "none",
  16012. volumeOld: 0,
  16013. volumeNew: 0,
  16014. currentTimeOld: 0,
  16015. currentTimeNew: 0
  16016. });
  16017. const touchStartOrigin = {
  16018. x: 0,
  16019. y: 0
  16020. };
  16021. function onTouchstart(event) {
  16022. const toucher = event.targetTouches[0];
  16023. touchStartOrigin.x = toucher.pageX;
  16024. touchStartOrigin.y = toucher.pageY;
  16025. state2.gestureType = "none";
  16026. state2.volumeOld = 0;
  16027. state2.currentTimeOld = state2.currentTimeNew = 0;
  16028. }
  16029. function onTouchmove(event) {
  16030. function stop() {
  16031. event.stopPropagation();
  16032. event.preventDefault();
  16033. }
  16034. if (fullscreenState.fullscreen) {
  16035. stop();
  16036. }
  16037. const gestureType = state2.gestureType;
  16038. if (gestureType === "stop") {
  16039. return;
  16040. }
  16041. const toucher = event.targetTouches[0];
  16042. const pageX = toucher.pageX;
  16043. const pageY = toucher.pageY;
  16044. const origin = touchStartOrigin;
  16045. const video = videoRef.value;
  16046. if (gestureType === "progress") {
  16047. changeProgress(pageX - origin.x);
  16048. } else if (gestureType === "volume") {
  16049. changeVolume(pageY - origin.y);
  16050. }
  16051. if (gestureType !== "none") {
  16052. return;
  16053. }
  16054. if (Math.abs(pageX - origin.x) > Math.abs(pageY - origin.y)) {
  16055. if (!props2.enableProgressGesture) {
  16056. state2.gestureType = "stop";
  16057. return;
  16058. }
  16059. state2.gestureType = "progress";
  16060. state2.currentTimeOld = state2.currentTimeNew = video.currentTime;
  16061. if (!fullscreenState.fullscreen) {
  16062. stop();
  16063. }
  16064. } else {
  16065. if (!props2.pageGesture) {
  16066. state2.gestureType = "stop";
  16067. return;
  16068. }
  16069. state2.gestureType = "volume";
  16070. state2.volumeOld = video.volume;
  16071. if (!fullscreenState.fullscreen) {
  16072. stop();
  16073. }
  16074. }
  16075. }
  16076. function onTouchend(event) {
  16077. const video = videoRef.value;
  16078. if (state2.gestureType !== "none" && state2.gestureType !== "stop") {
  16079. event.stopPropagation();
  16080. event.preventDefault();
  16081. }
  16082. if (state2.gestureType === "progress" && state2.currentTimeOld !== state2.currentTimeNew) {
  16083. video.currentTime = state2.currentTimeNew;
  16084. }
  16085. state2.gestureType = "none";
  16086. }
  16087. function changeProgress(x) {
  16088. const video = videoRef.value;
  16089. const duration = video.duration;
  16090. let currentTimeNew = x / 600 * duration + state2.currentTimeOld;
  16091. if (currentTimeNew < 0) {
  16092. currentTimeNew = 0;
  16093. } else if (currentTimeNew > duration) {
  16094. currentTimeNew = duration;
  16095. }
  16096. state2.currentTimeNew = currentTimeNew;
  16097. }
  16098. function changeVolume(y) {
  16099. const video = videoRef.value;
  16100. const valueOld = state2.volumeOld;
  16101. let value;
  16102. if (typeof valueOld === "number") {
  16103. value = valueOld - y / 200;
  16104. if (value < 0) {
  16105. value = 0;
  16106. } else if (value > 1) {
  16107. value = 1;
  16108. }
  16109. video.volume = value;
  16110. state2.volumeNew = value;
  16111. }
  16112. }
  16113. return {
  16114. state: state2,
  16115. onTouchstart,
  16116. onTouchmove,
  16117. onTouchend
  16118. };
  16119. }
  16120. function useFullscreen(trigger, containerRef, videoRef, userActionState, rootRef) {
  16121. const state2 = reactive({
  16122. fullscreen: false
  16123. });
  16124. const isSafari = /^Apple/.test(navigator.vendor);
  16125. function onFullscreenChange($event, webkit) {
  16126. if (webkit && document.fullscreenEnabled) {
  16127. return;
  16128. }
  16129. emitFullscreenChange(!!(document.fullscreenElement || document.webkitFullscreenElement));
  16130. }
  16131. function emitFullscreenChange(val) {
  16132. state2.fullscreen = val;
  16133. trigger("fullscreenchange", {}, {
  16134. fullScreen: val,
  16135. direction: "vertical"
  16136. });
  16137. }
  16138. function toggleFullscreen(val) {
  16139. const root = rootRef.value;
  16140. const container = containerRef.value;
  16141. const video = videoRef.value;
  16142. let mockFullScreen;
  16143. if (val) {
  16144. if ((document.fullscreenEnabled || document.webkitFullscreenEnabled) && (!isSafari || userActionState.userAction)) {
  16145. container[document.fullscreenEnabled ? "requestFullscreen" : "webkitRequestFullscreen"]();
  16146. } else if (video.webkitEnterFullScreen) {
  16147. video.webkitEnterFullScreen();
  16148. } else {
  16149. mockFullScreen = true;
  16150. container.remove();
  16151. container.classList.add("uni-video-type-fullscreen");
  16152. document.body.appendChild(container);
  16153. }
  16154. } else {
  16155. if (document.fullscreenEnabled || document.webkitFullscreenEnabled) {
  16156. if (document.fullscreenElement) {
  16157. document.exitFullscreen();
  16158. } else if (document.webkitFullscreenElement) {
  16159. document.webkitExitFullscreen();
  16160. }
  16161. } else if (video.webkitExitFullScreen) {
  16162. video.webkitExitFullScreen();
  16163. } else {
  16164. mockFullScreen = true;
  16165. container.remove();
  16166. container.classList.remove("uni-video-type-fullscreen");
  16167. root.appendChild(container);
  16168. }
  16169. }
  16170. if (mockFullScreen) {
  16171. emitFullscreenChange(val);
  16172. }
  16173. }
  16174. function requestFullScreen() {
  16175. toggleFullscreen(true);
  16176. }
  16177. function exitFullScreen() {
  16178. toggleFullscreen(false);
  16179. }
  16180. onBeforeUnmount(exitFullScreen);
  16181. return {
  16182. state: state2,
  16183. onFullscreenChange,
  16184. emitFullscreenChange,
  16185. toggleFullscreen,
  16186. requestFullScreen,
  16187. exitFullScreen
  16188. };
  16189. }
  16190. function useVideo(props2, attrs2, trigger) {
  16191. const videoRef = ref(null);
  16192. const src = computed(() => getRealPath(props2.src));
  16193. const muted = computed(() => props2.muted === "true" || props2.muted === true);
  16194. const state2 = reactive({
  16195. start: false,
  16196. src,
  16197. playing: false,
  16198. currentTime: 0,
  16199. duration: 0,
  16200. progress: 0,
  16201. buffered: 0,
  16202. muted
  16203. });
  16204. watch(() => src.value, () => {
  16205. state2.playing = false;
  16206. state2.currentTime = 0;
  16207. });
  16208. watch(() => state2.buffered, (buffered) => {
  16209. trigger("progress", {}, {
  16210. buffered
  16211. });
  16212. });
  16213. watch(() => muted.value, (muted2) => {
  16214. const video = videoRef.value;
  16215. video.muted = muted2;
  16216. });
  16217. function onDurationChange({
  16218. target
  16219. }) {
  16220. state2.duration = target.duration;
  16221. }
  16222. function onLoadedMetadata($event) {
  16223. const initialTime = Number(props2.initialTime) || 0;
  16224. const video = $event.target;
  16225. if (initialTime > 0) {
  16226. video.currentTime = initialTime;
  16227. }
  16228. trigger("loadedmetadata", $event, {
  16229. width: video.videoWidth,
  16230. height: video.videoHeight,
  16231. duration: video.duration
  16232. });
  16233. onProgress($event);
  16234. }
  16235. function onProgress($event) {
  16236. const video = $event.target;
  16237. const buffered = video.buffered;
  16238. if (buffered.length) {
  16239. state2.buffered = buffered.end(buffered.length - 1) / video.duration * 100;
  16240. }
  16241. }
  16242. function onWaiting($event) {
  16243. trigger("waiting", $event, {});
  16244. }
  16245. function onVideoError($event) {
  16246. state2.playing = false;
  16247. trigger("error", $event, {});
  16248. }
  16249. function onPlay($event) {
  16250. state2.start = true;
  16251. state2.playing = true;
  16252. trigger("play", $event, {});
  16253. }
  16254. function onPause($event) {
  16255. state2.playing = false;
  16256. trigger("pause", $event, {});
  16257. }
  16258. function onEnded($event) {
  16259. state2.playing = false;
  16260. trigger("ended", $event, {});
  16261. }
  16262. function onTimeUpdate($event) {
  16263. const video = $event.target;
  16264. const currentTime = state2.currentTime = video.currentTime;
  16265. trigger("timeupdate", $event, {
  16266. currentTime,
  16267. duration: video.duration
  16268. });
  16269. }
  16270. function toggle() {
  16271. const video = videoRef.value;
  16272. if (state2.playing) {
  16273. video.pause();
  16274. } else {
  16275. video.play();
  16276. }
  16277. }
  16278. function play() {
  16279. const video = videoRef.value;
  16280. state2.start = true;
  16281. video.play();
  16282. }
  16283. function pause() {
  16284. const video = videoRef.value;
  16285. video.pause();
  16286. }
  16287. function seek(position) {
  16288. const video = videoRef.value;
  16289. position = Number(position);
  16290. if (typeof position === "number" && !isNaN(position)) {
  16291. video.currentTime = position;
  16292. }
  16293. }
  16294. function stop() {
  16295. seek(0);
  16296. pause();
  16297. }
  16298. function playbackRate(rate) {
  16299. const video = videoRef.value;
  16300. video.playbackRate = rate;
  16301. }
  16302. return {
  16303. videoRef,
  16304. state: state2,
  16305. play,
  16306. pause,
  16307. stop,
  16308. seek,
  16309. playbackRate,
  16310. toggle,
  16311. onDurationChange,
  16312. onLoadedMetadata,
  16313. onProgress,
  16314. onWaiting,
  16315. onVideoError,
  16316. onPlay,
  16317. onPause,
  16318. onEnded,
  16319. onTimeUpdate
  16320. };
  16321. }
  16322. function useControls(props2, videoState, seek) {
  16323. const progressRef = ref(null);
  16324. const ballRef = ref(null);
  16325. const centerPlayBtnShow = computed(() => props2.showCenterPlayBtn && !videoState.start);
  16326. const controlsVisible = ref(true);
  16327. const controlsShow = computed(() => !centerPlayBtnShow.value && props2.controls && controlsVisible.value);
  16328. const state2 = reactive({
  16329. touching: false,
  16330. controlsTouching: false,
  16331. centerPlayBtnShow,
  16332. controlsShow,
  16333. controlsVisible
  16334. });
  16335. function clickProgress(event) {
  16336. const $progress = progressRef.value;
  16337. let element = event.target;
  16338. let x = event.offsetX;
  16339. while (element && element !== $progress) {
  16340. x += element.offsetLeft;
  16341. element = element.parentNode;
  16342. }
  16343. const w = $progress.offsetWidth;
  16344. let progress = 0;
  16345. if (x >= 0 && x <= w) {
  16346. progress = x / w;
  16347. seek(videoState.duration * progress);
  16348. }
  16349. }
  16350. function toggleControls() {
  16351. state2.controlsVisible = !state2.controlsVisible;
  16352. }
  16353. let hideTiming;
  16354. function autoHideStart() {
  16355. hideTiming = setTimeout(() => {
  16356. state2.controlsVisible = false;
  16357. }, 3e3);
  16358. }
  16359. function autoHideEnd() {
  16360. if (hideTiming) {
  16361. clearTimeout(hideTiming);
  16362. hideTiming = null;
  16363. }
  16364. }
  16365. onBeforeUnmount(() => {
  16366. if (hideTiming) {
  16367. clearTimeout(hideTiming);
  16368. }
  16369. });
  16370. watch(() => state2.controlsShow && videoState.playing && !state2.controlsTouching, (val) => {
  16371. if (val) {
  16372. autoHideStart();
  16373. } else {
  16374. autoHideEnd();
  16375. }
  16376. });
  16377. watch([() => videoState.currentTime, () => {
  16378. props2.duration;
  16379. }], function updateProgress() {
  16380. if (!state2.touching) {
  16381. videoState.progress = videoState.currentTime / videoState.duration * 100;
  16382. }
  16383. });
  16384. onMounted(() => {
  16385. const passiveOptions2 = passive(false);
  16386. let originX;
  16387. let originY;
  16388. let moveOnce = true;
  16389. let originProgress;
  16390. const ball = ballRef.value;
  16391. function touchmove2(event) {
  16392. const toucher = event.targetTouches[0];
  16393. const pageX = toucher.pageX;
  16394. const pageY = toucher.pageY;
  16395. if (moveOnce && Math.abs(pageX - originX) < Math.abs(pageY - originY)) {
  16396. touchend(event);
  16397. return;
  16398. }
  16399. moveOnce = false;
  16400. const progressEl = progressRef.value;
  16401. const w = progressEl.offsetWidth;
  16402. let progress = originProgress + (pageX - originX) / w * 100;
  16403. if (progress < 0) {
  16404. progress = 0;
  16405. } else if (progress > 100) {
  16406. progress = 100;
  16407. }
  16408. videoState.progress = progress;
  16409. event.preventDefault();
  16410. event.stopPropagation();
  16411. }
  16412. function touchend(event) {
  16413. state2.controlsTouching = false;
  16414. if (state2.touching) {
  16415. ball.removeEventListener("touchmove", touchmove2, passiveOptions2);
  16416. if (!moveOnce) {
  16417. event.preventDefault();
  16418. event.stopPropagation();
  16419. seek(videoState.duration * videoState.progress / 100);
  16420. }
  16421. state2.touching = false;
  16422. }
  16423. }
  16424. ball.addEventListener("touchstart", (event) => {
  16425. state2.controlsTouching = true;
  16426. const toucher = event.targetTouches[0];
  16427. originX = toucher.pageX;
  16428. originY = toucher.pageY;
  16429. originProgress = videoState.progress;
  16430. moveOnce = true;
  16431. state2.touching = true;
  16432. ball.addEventListener("touchmove", touchmove2, passiveOptions2);
  16433. });
  16434. ball.addEventListener("touchend", touchend);
  16435. ball.addEventListener("touchcancel", touchend);
  16436. });
  16437. return {
  16438. state: state2,
  16439. progressRef,
  16440. ballRef,
  16441. clickProgress,
  16442. toggleControls,
  16443. autoHideStart,
  16444. autoHideEnd
  16445. };
  16446. }
  16447. function useDanmu(props2, videoState) {
  16448. const danmuRef = ref(null);
  16449. const state2 = reactive({
  16450. enable: Boolean(props2.enableDanmu)
  16451. });
  16452. let danmuIndex = {
  16453. time: 0,
  16454. index: -1
  16455. };
  16456. const danmuList = isArray(props2.danmuList) ? JSON.parse(JSON.stringify(props2.danmuList)) : [];
  16457. danmuList.sort(function(a2, b) {
  16458. return (a2.time || 0) - (b.time || 0);
  16459. });
  16460. function toggleDanmu() {
  16461. state2.enable = !state2.enable;
  16462. }
  16463. function updateDanmu(event) {
  16464. const video = event.target;
  16465. const currentTime = video.currentTime;
  16466. const oldDanmuIndex = danmuIndex;
  16467. const newDanmuIndex = {
  16468. time: currentTime,
  16469. index: oldDanmuIndex.index
  16470. };
  16471. if (currentTime > oldDanmuIndex.time) {
  16472. for (let index2 = oldDanmuIndex.index + 1; index2 < danmuList.length; index2++) {
  16473. const element = danmuList[index2];
  16474. if (currentTime >= (element.time || 0)) {
  16475. newDanmuIndex.index = index2;
  16476. if (videoState.playing && state2.enable) {
  16477. playDanmu(element);
  16478. }
  16479. } else {
  16480. break;
  16481. }
  16482. }
  16483. } else if (currentTime < oldDanmuIndex.time) {
  16484. for (let index2 = oldDanmuIndex.index - 1; index2 > -1; index2--) {
  16485. const element = danmuList[index2];
  16486. if (currentTime <= (element.time || 0)) {
  16487. newDanmuIndex.index = index2 - 1;
  16488. } else {
  16489. break;
  16490. }
  16491. }
  16492. }
  16493. danmuIndex = newDanmuIndex;
  16494. }
  16495. function playDanmu(danmu) {
  16496. const p2 = document.createElement("p");
  16497. p2.className = "uni-video-danmu-item";
  16498. p2.innerText = danmu.text;
  16499. let style = `bottom: ${Math.random() * 100}%;color: ${danmu.color};`;
  16500. p2.setAttribute("style", style);
  16501. const danmuEl = danmuRef.value;
  16502. danmuEl.appendChild(p2);
  16503. setTimeout(function() {
  16504. style += "left: 0;-webkit-transform: translateX(-100%);transform: translateX(-100%);";
  16505. p2.setAttribute("style", style);
  16506. setTimeout(function() {
  16507. p2.remove();
  16508. }, 4e3);
  16509. }, 17);
  16510. }
  16511. function sendDanmu(danmu) {
  16512. danmuList.splice(danmuIndex.index + 1, 0, {
  16513. text: String(danmu.text),
  16514. color: danmu.color,
  16515. time: videoState.currentTime || 0
  16516. });
  16517. }
  16518. return {
  16519. state: state2,
  16520. danmuRef,
  16521. updateDanmu,
  16522. toggleDanmu,
  16523. sendDanmu
  16524. };
  16525. }
  16526. function useContext(play, pause, stop, seek, sendDanmu, playbackRate, requestFullScreen, exitFullScreen) {
  16527. const methods = {
  16528. play,
  16529. stop,
  16530. pause,
  16531. seek,
  16532. sendDanmu,
  16533. playbackRate,
  16534. requestFullScreen,
  16535. exitFullScreen
  16536. };
  16537. const id2 = useContextInfo();
  16538. useSubscribe((type, data) => {
  16539. let options;
  16540. switch (type) {
  16541. case "seek":
  16542. options = data.position;
  16543. break;
  16544. case "sendDanmu":
  16545. options = data;
  16546. break;
  16547. case "playbackRate":
  16548. options = data.rate;
  16549. break;
  16550. }
  16551. if (type in methods) {
  16552. methods[type](options);
  16553. }
  16554. }, id2, true);
  16555. }
  16556. const props$g = {
  16557. id: {
  16558. type: String,
  16559. default: ""
  16560. },
  16561. src: {
  16562. type: String,
  16563. default: ""
  16564. },
  16565. duration: {
  16566. type: [Number, String],
  16567. default: ""
  16568. },
  16569. controls: {
  16570. type: [Boolean, String],
  16571. default: true
  16572. },
  16573. danmuList: {
  16574. type: Array,
  16575. default() {
  16576. return [];
  16577. }
  16578. },
  16579. danmuBtn: {
  16580. type: [Boolean, String],
  16581. default: false
  16582. },
  16583. enableDanmu: {
  16584. type: [Boolean, String],
  16585. default: false
  16586. },
  16587. autoplay: {
  16588. type: [Boolean, String],
  16589. default: false
  16590. },
  16591. loop: {
  16592. type: [Boolean, String],
  16593. default: false
  16594. },
  16595. muted: {
  16596. type: [Boolean, String],
  16597. default: false
  16598. },
  16599. objectFit: {
  16600. type: String,
  16601. default: "contain"
  16602. },
  16603. poster: {
  16604. type: String,
  16605. default: ""
  16606. },
  16607. direction: {
  16608. type: [String, Number],
  16609. default: ""
  16610. },
  16611. showProgress: {
  16612. type: Boolean,
  16613. default: true
  16614. },
  16615. initialTime: {
  16616. type: [String, Number],
  16617. default: 0
  16618. },
  16619. showFullscreenBtn: {
  16620. type: [Boolean, String],
  16621. default: true
  16622. },
  16623. pageGesture: {
  16624. type: [Boolean, String],
  16625. default: false
  16626. },
  16627. enableProgressGesture: {
  16628. type: [Boolean, String],
  16629. default: true
  16630. },
  16631. showPlayBtn: {
  16632. type: [Boolean, String],
  16633. default: true
  16634. },
  16635. showCenterPlayBtn: {
  16636. type: [Boolean, String],
  16637. default: true
  16638. }
  16639. };
  16640. const index$d = /* @__PURE__ */ defineBuiltInComponent({
  16641. name: "Video",
  16642. props: props$g,
  16643. emits: ["fullscreenchange", "progress", "loadedmetadata", "waiting", "error", "play", "pause", "ended", "timeupdate"],
  16644. setup(props2, {
  16645. emit: emit2,
  16646. attrs: attrs2,
  16647. slots
  16648. }) {
  16649. const rootRef = ref(null);
  16650. const containerRef = ref(null);
  16651. const trigger = useCustomEvent(rootRef, emit2);
  16652. const {
  16653. state: userActionState
  16654. } = useUserAction();
  16655. const {
  16656. $attrs: videoAttrs
  16657. } = useAttrs({
  16658. excludeListeners: true
  16659. });
  16660. const {
  16661. t: t2
  16662. } = useI18n();
  16663. initI18nVideoMsgsOnce();
  16664. const {
  16665. videoRef,
  16666. state: videoState,
  16667. play,
  16668. pause,
  16669. stop,
  16670. seek,
  16671. playbackRate,
  16672. toggle,
  16673. onDurationChange,
  16674. onLoadedMetadata,
  16675. onProgress,
  16676. onWaiting,
  16677. onVideoError,
  16678. onPlay,
  16679. onPause,
  16680. onEnded,
  16681. onTimeUpdate
  16682. } = useVideo(props2, attrs2, trigger);
  16683. const {
  16684. state: danmuState,
  16685. danmuRef,
  16686. updateDanmu,
  16687. toggleDanmu,
  16688. sendDanmu
  16689. } = useDanmu(props2, videoState);
  16690. const {
  16691. state: fullscreenState,
  16692. onFullscreenChange,
  16693. emitFullscreenChange,
  16694. toggleFullscreen,
  16695. requestFullScreen,
  16696. exitFullScreen
  16697. } = useFullscreen(trigger, containerRef, videoRef, userActionState, rootRef);
  16698. const {
  16699. state: gestureState,
  16700. onTouchstart,
  16701. onTouchend,
  16702. onTouchmove
  16703. } = useGesture(props2, videoRef, fullscreenState);
  16704. const {
  16705. state: controlsState,
  16706. progressRef,
  16707. ballRef,
  16708. clickProgress,
  16709. toggleControls
  16710. } = useControls(props2, videoState, seek);
  16711. useContext(play, pause, stop, seek, sendDanmu, playbackRate, requestFullScreen, exitFullScreen);
  16712. return () => {
  16713. return createVNode("uni-video", {
  16714. "ref": rootRef,
  16715. "id": props2.id,
  16716. "onClick": toggleControls
  16717. }, [createVNode("div", {
  16718. "ref": containerRef,
  16719. "class": "uni-video-container",
  16720. "onTouchstart": onTouchstart,
  16721. "onTouchend": onTouchend,
  16722. "onTouchmove": onTouchmove,
  16723. "onFullscreenchange": withModifiers(onFullscreenChange, ["stop"]),
  16724. "onWebkitfullscreenchange": withModifiers(($event) => onFullscreenChange($event, true), ["stop"])
  16725. }, [createVNode("video", mergeProps({
  16726. "ref": videoRef,
  16727. "style": {
  16728. "object-fit": props2.objectFit
  16729. },
  16730. "muted": !!props2.muted,
  16731. "loop": !!props2.loop,
  16732. "src": videoState.src,
  16733. "poster": props2.poster,
  16734. "autoplay": !!props2.autoplay
  16735. }, videoAttrs.value, {
  16736. "class": "uni-video-video",
  16737. "webkit-playsinline": true,
  16738. "playsinline": true,
  16739. "onDurationchange": onDurationChange,
  16740. "onLoadedmetadata": onLoadedMetadata,
  16741. "onProgress": onProgress,
  16742. "onWaiting": onWaiting,
  16743. "onError": onVideoError,
  16744. "onPlay": onPlay,
  16745. "onPause": onPause,
  16746. "onEnded": onEnded,
  16747. "onTimeupdate": (event) => {
  16748. onTimeUpdate(event);
  16749. updateDanmu(event);
  16750. },
  16751. "onWebkitbeginfullscreen": () => emitFullscreenChange(true),
  16752. "onX5videoenterfullscreen": () => emitFullscreenChange(true),
  16753. "onWebkitendfullscreen": () => emitFullscreenChange(false),
  16754. "onX5videoexitfullscreen": () => emitFullscreenChange(false)
  16755. }), null, 16, ["muted", "loop", "src", "poster", "autoplay", "webkit-playsinline", "playsinline", "onDurationchange", "onLoadedmetadata", "onProgress", "onWaiting", "onError", "onPlay", "onPause", "onEnded", "onTimeupdate", "onWebkitbeginfullscreen", "onX5videoenterfullscreen", "onWebkitendfullscreen", "onX5videoexitfullscreen"]), withDirectives(createVNode("div", {
  16756. "class": "uni-video-bar uni-video-bar-full",
  16757. "onClick": withModifiers(() => {
  16758. }, ["stop"])
  16759. }, [createVNode("div", {
  16760. "class": "uni-video-controls"
  16761. }, [withDirectives(createVNode("div", {
  16762. "class": {
  16763. "uni-video-control-button": true,
  16764. "uni-video-control-button-play": !videoState.playing,
  16765. "uni-video-control-button-pause": videoState.playing
  16766. },
  16767. "onClick": withModifiers(toggle, ["stop"])
  16768. }, null, 10, ["onClick"]), [[vShow, props2.showPlayBtn]]), withDirectives(createVNode("div", {
  16769. "class": "uni-video-current-time"
  16770. }, [formatTime(videoState.currentTime)], 512), [[vShow, props2.showProgress]]), withDirectives(createVNode("div", {
  16771. "ref": progressRef,
  16772. "class": "uni-video-progress-container",
  16773. "onClick": withModifiers(clickProgress, ["stop"])
  16774. }, [createVNode("div", {
  16775. "class": "uni-video-progress"
  16776. }, [createVNode("div", {
  16777. "style": {
  16778. width: videoState.buffered + "%"
  16779. },
  16780. "class": "uni-video-progress-buffered"
  16781. }, null, 4), createVNode("div", {
  16782. "ref": ballRef,
  16783. "style": {
  16784. left: videoState.progress + "%"
  16785. },
  16786. "class": "uni-video-ball"
  16787. }, [createVNode("div", {
  16788. "class": "uni-video-inner"
  16789. }, null)], 4)])], 8, ["onClick"]), [[vShow, props2.showProgress]]), withDirectives(createVNode("div", {
  16790. "class": "uni-video-duration"
  16791. }, [formatTime(Number(props2.duration) || videoState.duration)], 512), [[vShow, props2.showProgress]])]), withDirectives(createVNode("div", {
  16792. "class": {
  16793. "uni-video-danmu-button": true,
  16794. "uni-video-danmu-button-active": danmuState.enable
  16795. },
  16796. "onClick": withModifiers(toggleDanmu, ["stop"])
  16797. }, [t2("uni.video.danmu")], 10, ["onClick"]), [[vShow, props2.danmuBtn]]), withDirectives(createVNode("div", {
  16798. "class": {
  16799. "uni-video-fullscreen": true,
  16800. "uni-video-type-fullscreen": fullscreenState.fullscreen
  16801. },
  16802. "onClick": withModifiers(() => toggleFullscreen(!fullscreenState.fullscreen), ["stop"])
  16803. }, null, 10, ["onClick"]), [[vShow, props2.showFullscreenBtn]])], 8, ["onClick"]), [[vShow, controlsState.controlsShow]]), withDirectives(createVNode("div", {
  16804. "ref": danmuRef,
  16805. "style": "z-index: 0;",
  16806. "class": "uni-video-danmu"
  16807. }, null, 512), [[vShow, videoState.start && danmuState.enable]]), controlsState.centerPlayBtnShow && createVNode("div", {
  16808. "class": "uni-video-cover",
  16809. "onClick": withModifiers(() => {
  16810. }, ["stop"])
  16811. }, [createVNode("div", {
  16812. "class": "uni-video-cover-play-button",
  16813. "onClick": withModifiers(play, ["stop"])
  16814. }, null, 8, ["onClick"]), createVNode("p", {
  16815. "class": "uni-video-cover-duration"
  16816. }, [formatTime(Number(props2.duration) || videoState.duration)])], 8, ["onClick"]), createVNode("div", {
  16817. "class": {
  16818. "uni-video-toast": true,
  16819. "uni-video-toast-volume": gestureState.gestureType === "volume"
  16820. }
  16821. }, [createVNode("div", {
  16822. "class": "uni-video-toast-title"
  16823. }, [t2("uni.video.volume")]), createVNode("svg", {
  16824. "class": "uni-video-toast-icon",
  16825. "width": "200px",
  16826. "height": "200px",
  16827. "viewBox": "0 0 1024 1024",
  16828. "version": "1.1",
  16829. "xmlns": "http://www.w3.org/2000/svg"
  16830. }, [createVNode("path", {
  16831. "d": "M475.400704 201.19552l0 621.674496q0 14.856192-10.856448 25.71264t-25.71264 10.856448-25.71264-10.856448l-190.273536-190.273536-149.704704 0q-14.856192 0-25.71264-10.856448t-10.856448-25.71264l0-219.414528q0-14.856192 10.856448-25.71264t25.71264-10.856448l149.704704 0 190.273536-190.273536q10.856448-10.856448 25.71264-10.856448t25.71264 10.856448 10.856448 25.71264zm219.414528 310.837248q0 43.425792-24.28416 80.851968t-64.2816 53.425152q-5.71392 2.85696-14.2848 2.85696-14.856192 0-25.71264-10.570752t-10.856448-25.998336q0-11.999232 6.856704-20.284416t16.570368-14.2848 19.427328-13.142016 16.570368-20.284416 6.856704-32.569344-6.856704-32.569344-16.570368-20.284416-19.427328-13.142016-16.570368-14.2848-6.856704-20.284416q0-15.427584 10.856448-25.998336t25.71264-10.570752q8.57088 0 14.2848 2.85696 39.99744 15.427584 64.2816 53.139456t24.28416 81.137664zm146.276352 0q0 87.422976-48.56832 161.41824t-128.5632 107.707392q-7.428096 2.85696-14.2848 2.85696-15.427584 0-26.284032-10.856448t-10.856448-25.71264q0-22.284288 22.284288-33.712128 31.997952-16.570368 43.425792-25.141248 42.283008-30.855168 65.995776-77.423616t23.712768-99.136512-23.712768-99.136512-65.995776-77.423616q-11.42784-8.57088-43.425792-25.141248-22.284288-11.42784-22.284288-33.712128 0-14.856192 10.856448-25.71264t25.71264-10.856448q7.428096 0 14.856192 2.85696 79.99488 33.712128 128.5632 107.707392t48.56832 161.41824zm146.276352 0q0 131.42016-72.566784 241.41312t-193.130496 161.989632q-7.428096 2.85696-14.856192 2.85696-14.856192 0-25.71264-10.856448t-10.856448-25.71264q0-20.570112 22.284288-33.712128 3.999744-2.285568 12.85632-5.999616t12.85632-5.999616q26.284032-14.2848 46.854144-29.140992 70.281216-51.996672 109.707264-129.705984t39.426048-165.132288-39.426048-165.132288-109.707264-129.705984q-20.570112-14.856192-46.854144-29.140992-3.999744-2.285568-12.85632-5.999616t-12.85632-5.999616q-22.284288-13.142016-22.284288-33.712128 0-14.856192 10.856448-25.71264t25.71264-10.856448q7.428096 0 14.856192 2.85696 120.563712 51.996672 193.130496 161.989632t72.566784 241.41312z"
  16832. }, null)]), createVNode("div", {
  16833. "class": "uni-video-toast-value"
  16834. }, [createVNode("div", {
  16835. "style": {
  16836. width: gestureState.volumeNew * 100 + "%"
  16837. },
  16838. "class": "uni-video-toast-value-content"
  16839. }, [createVNode("div", {
  16840. "class": "uni-video-toast-volume-grids"
  16841. }, [renderList(10, () => createVNode("div", {
  16842. "class": "uni-video-toast-volume-grids-item"
  16843. }, null))])], 4)])], 2), createVNode("div", {
  16844. "class": {
  16845. "uni-video-toast": true,
  16846. "uni-video-toast-progress": gestureState.gestureType === "progress"
  16847. }
  16848. }, [createVNode("div", {
  16849. "class": "uni-video-toast-title"
  16850. }, [formatTime(gestureState.currentTimeNew), " / ", formatTime(videoState.duration)])], 2), createVNode("div", {
  16851. "class": "uni-video-slots"
  16852. }, [slots.default && slots.default()])], 40, ["onTouchstart", "onTouchend", "onTouchmove", "onFullscreenchange", "onWebkitfullscreenchange"])], 8, ["id", "onClick"]);
  16853. };
  16854. }
  16855. });
  16856. const onWebInvokeAppService = ({ name, arg }) => {
  16857. if (name === "postMessage")
  16858. ;
  16859. else {
  16860. uni[name](arg);
  16861. }
  16862. };
  16863. const Invoke = /* @__PURE__ */ once(() => UniServiceJSBridge.on(ON_WEB_INVOKE_APP_SERVICE, onWebInvokeAppService));
  16864. const props$f = {
  16865. src: {
  16866. type: String,
  16867. default: ""
  16868. },
  16869. fullscreen: {
  16870. type: Boolean,
  16871. default: true
  16872. }
  16873. };
  16874. const index$c = /* @__PURE__ */ defineBuiltInComponent({
  16875. inheritAttrs: false,
  16876. name: "WebView",
  16877. props: props$f,
  16878. setup(props2) {
  16879. Invoke();
  16880. const rootRef = ref(null);
  16881. const iframeRef = ref(null);
  16882. const {
  16883. $attrs,
  16884. $excludeAttrs,
  16885. $listeners
  16886. } = useAttrs({
  16887. excludeListeners: true
  16888. });
  16889. let _resize;
  16890. const renderIframe = () => {
  16891. const iframe = document.createElement("iframe");
  16892. watchEffect(() => {
  16893. for (const key in $attrs.value) {
  16894. if (hasOwn($attrs.value, key)) {
  16895. const attr2 = $attrs.value[key];
  16896. iframe[key] = attr2;
  16897. }
  16898. }
  16899. });
  16900. watchEffect(() => {
  16901. iframe.src = getRealPath(props2.src);
  16902. });
  16903. iframeRef.value = iframe;
  16904. _resize = useWebViewSize(rootRef, iframeRef, props2.fullscreen);
  16905. if (props2.fullscreen) {
  16906. document.body.appendChild(iframe);
  16907. }
  16908. };
  16909. renderIframe();
  16910. onMounted(() => {
  16911. var _a;
  16912. _resize();
  16913. !props2.fullscreen && ((_a = rootRef.value) == null ? void 0 : _a.appendChild(iframeRef.value));
  16914. });
  16915. onActivated(() => {
  16916. props2.fullscreen && (iframeRef.value.style.display = "block");
  16917. });
  16918. onDeactivated(() => {
  16919. props2.fullscreen && (iframeRef.value.style.display = "none");
  16920. });
  16921. onBeforeUnmount(() => {
  16922. props2.fullscreen && document.body.removeChild(iframeRef.value);
  16923. });
  16924. return () => {
  16925. return createVNode(Fragment, null, [createVNode("uni-web-view", mergeProps({
  16926. "class": props2.fullscreen ? "uni-webview--fullscreen" : ""
  16927. }, $listeners.value, $excludeAttrs.value, {
  16928. "ref": rootRef
  16929. }), [createVNode(ResizeSensor, {
  16930. "onResize": _resize
  16931. }, null, 8, ["onResize"])], 16)]);
  16932. };
  16933. }
  16934. });
  16935. function useWebViewSize(rootRef, iframeRef, fullscreen) {
  16936. const _resize = () => {
  16937. var _a, _b;
  16938. if (fullscreen) {
  16939. const {
  16940. top,
  16941. left,
  16942. width,
  16943. height
  16944. } = rootRef.value.getBoundingClientRect();
  16945. updateElementStyle(iframeRef.value, {
  16946. position: "absolute",
  16947. display: "block",
  16948. border: "0",
  16949. top: top + "px",
  16950. left: left + "px",
  16951. width: width + "px",
  16952. height: height + "px"
  16953. });
  16954. } else {
  16955. updateElementStyle(iframeRef.value, {
  16956. width: ((_a = rootRef.value) == null ? void 0 : _a.style.width) || "300px",
  16957. height: ((_b = rootRef.value) == null ? void 0 : _b.style.height) || "150px"
  16958. });
  16959. }
  16960. };
  16961. return _resize;
  16962. }
  16963. let index$b = 0;
  16964. function getJSONP(url, options, success, error) {
  16965. var js = document.createElement("script");
  16966. var callbackKey = options.callback || "callback";
  16967. var callbackName = "__uni_jsonp_callback_" + index$b++;
  16968. var timeout = options.timeout || 3e4;
  16969. var timing;
  16970. function end() {
  16971. clearTimeout(timing);
  16972. delete window[callbackName];
  16973. js.remove();
  16974. }
  16975. window[callbackName] = (res) => {
  16976. if (isFunction(success)) {
  16977. success(res);
  16978. }
  16979. end();
  16980. };
  16981. js.onerror = () => {
  16982. if (isFunction(error)) {
  16983. error();
  16984. }
  16985. end();
  16986. };
  16987. timing = setTimeout(function() {
  16988. if (isFunction(error)) {
  16989. error();
  16990. }
  16991. end();
  16992. }, timeout);
  16993. js.src = url + (url.indexOf("?") >= 0 ? "&" : "?") + callbackKey + "=" + callbackName;
  16994. document.body.appendChild(js);
  16995. }
  16996. function createCallout(maps2) {
  16997. function onAdd() {
  16998. const div = this.div;
  16999. const panes = this.getPanes();
  17000. panes.floatPane.appendChild(div);
  17001. }
  17002. function onRemove() {
  17003. const parentNode = this.div.parentNode;
  17004. if (parentNode) {
  17005. parentNode.removeChild(this.div);
  17006. }
  17007. }
  17008. function createAMapText() {
  17009. const option = this.option;
  17010. this.Text = new maps2.Text({
  17011. text: option.content,
  17012. anchor: "bottom-center",
  17013. // 设置文本标记锚点
  17014. offset: new maps2.Pixel(0, option.offsetY - 16),
  17015. style: {
  17016. padding: (option.padding || 8) + "px",
  17017. "line-height": (option.fontSize || 14) + "px",
  17018. "border-radius": (option.borderRadius || 0) + "px",
  17019. "border-color": `${option.bgColor || "#fff"} transparent transparent`,
  17020. "background-color": option.bgColor || "#fff",
  17021. "box-shadow": "0 2px 6px 0 rgba(114, 124, 245, .5)",
  17022. "text-align": "center",
  17023. "font-size": (option.fontSize || 14) + "px",
  17024. color: option.color || "#000"
  17025. },
  17026. position: option.position
  17027. });
  17028. const event = maps2.event || maps2.Event;
  17029. event.addListener(this.Text, "click", () => {
  17030. this.callback();
  17031. });
  17032. this.Text.setMap(option.map);
  17033. }
  17034. function createBMapText() {
  17035. }
  17036. function removeAMapText() {
  17037. if (this.Text) {
  17038. this.option.map.remove(this.Text);
  17039. }
  17040. }
  17041. function removeBMapText() {
  17042. if (this.Text) {
  17043. this.option.map.remove(this.Text);
  17044. }
  17045. }
  17046. class Callout {
  17047. constructor(option = {}, callback) {
  17048. this.createAMapText = createAMapText;
  17049. this.removeAMapText = removeAMapText;
  17050. this.createBMapText = createBMapText;
  17051. this.removeBMapText = removeBMapText;
  17052. this.onAdd = onAdd;
  17053. this.construct = onAdd;
  17054. this.onRemove = onRemove;
  17055. this.destroy = onRemove;
  17056. this.option = option || {};
  17057. const visible = this.visible = this.alwaysVisible = option.display === "ALWAYS";
  17058. if (getIsAMap()) {
  17059. this.callback = callback;
  17060. if (this.visible) {
  17061. this.createAMapText();
  17062. }
  17063. } else if (getIsBMap()) {
  17064. if (this.visible) {
  17065. this.createBMapText();
  17066. }
  17067. } else {
  17068. const map = option.map;
  17069. this.position = option.position;
  17070. this.index = 1;
  17071. const div = this.div = document.createElement("div");
  17072. const divStyle = div.style;
  17073. divStyle.position = "absolute";
  17074. divStyle.whiteSpace = "nowrap";
  17075. divStyle.transform = "translateX(-50%) translateY(-100%)";
  17076. divStyle.zIndex = "1";
  17077. divStyle.boxShadow = option.boxShadow || "none";
  17078. divStyle.display = visible ? "block" : "none";
  17079. const triangle = this.triangle = document.createElement("div");
  17080. triangle.setAttribute(
  17081. "style",
  17082. "position: absolute;white-space: nowrap;border-width: 4px;border-style: solid;border-color: #fff transparent transparent;border-image: initial;font-size: 12px;padding: 0px;background-color: transparent;width: 0px;height: 0px;transform: translate(-50%, 100%);left: 50%;bottom: 0;"
  17083. );
  17084. this.setStyle(option);
  17085. div.appendChild(triangle);
  17086. if (map) {
  17087. this.setMap(map);
  17088. }
  17089. }
  17090. }
  17091. set onclick(callback) {
  17092. this.div.onclick = callback;
  17093. }
  17094. get onclick() {
  17095. return this.div.onclick;
  17096. }
  17097. setOption(option) {
  17098. this.option = option;
  17099. if (option.display === "ALWAYS") {
  17100. this.alwaysVisible = this.visible = true;
  17101. } else {
  17102. this.alwaysVisible = false;
  17103. }
  17104. if (getIsAMap()) {
  17105. if (this.visible) {
  17106. this.createAMapText();
  17107. }
  17108. } else if (getIsBMap()) {
  17109. if (this.visible) {
  17110. this.createBMapText();
  17111. }
  17112. } else {
  17113. this.setPosition(option.position);
  17114. this.setStyle(option);
  17115. }
  17116. }
  17117. setStyle(option) {
  17118. const div = this.div;
  17119. const divStyle = div.style;
  17120. div.innerText = option.content || "";
  17121. divStyle.lineHeight = (option.fontSize || 14) + "px";
  17122. divStyle.fontSize = (option.fontSize || 14) + "px";
  17123. divStyle.padding = (option.padding || 8) + "px";
  17124. divStyle.color = option.color || "#000";
  17125. divStyle.borderRadius = (option.borderRadius || 0) + "px";
  17126. divStyle.backgroundColor = option.bgColor || "#fff";
  17127. divStyle.marginTop = "-" + ((option.top || 0) + 5) + "px";
  17128. this.triangle.style.borderColor = `${option.bgColor || "#fff"} transparent transparent`;
  17129. }
  17130. setPosition(position) {
  17131. this.position = position;
  17132. this.draw();
  17133. }
  17134. draw() {
  17135. const overlayProjection = this.getProjection();
  17136. if (!this.position || !this.div || !overlayProjection) {
  17137. return;
  17138. }
  17139. const pixel = overlayProjection.fromLatLngToDivPixel(
  17140. this.position
  17141. );
  17142. const divStyle = this.div.style;
  17143. divStyle.left = pixel.x + "px";
  17144. divStyle.top = pixel.y + "px";
  17145. }
  17146. changed() {
  17147. const divStyle = this.div.style;
  17148. divStyle.display = this.visible ? "block" : "none";
  17149. }
  17150. }
  17151. if (!getIsAMap() && !getIsBMap()) {
  17152. const overlay = new (maps2.OverlayView || maps2.Overlay)();
  17153. Callout.prototype.setMap = overlay.setMap;
  17154. Callout.prototype.getMap = overlay.getMap;
  17155. Callout.prototype.getPanes = overlay.getPanes;
  17156. Callout.prototype.getProjection = overlay.getProjection;
  17157. Callout.prototype.map_changed = overlay.map_changed;
  17158. Callout.prototype.set = overlay.set;
  17159. Callout.prototype.get = overlay.get;
  17160. Callout.prototype.setOptions = overlay.setValues;
  17161. Callout.prototype.bindTo = overlay.bindTo;
  17162. Callout.prototype.bindsTo = overlay.bindsTo;
  17163. Callout.prototype.notify = overlay.notify;
  17164. Callout.prototype.setValues = overlay.setValues;
  17165. Callout.prototype.unbind = overlay.unbind;
  17166. Callout.prototype.unbindAll = overlay.unbindAll;
  17167. Callout.prototype.addListener = overlay.addListener;
  17168. }
  17169. return Callout;
  17170. }
  17171. let maps;
  17172. const callbacksMap = {};
  17173. const GOOGLE_MAP_CALLBACKNAME = "__map_callback__";
  17174. function loadMaps(libraries, callback) {
  17175. const mapInfo = getMapInfo();
  17176. if (!mapInfo.key) {
  17177. console.error("Map key not configured.");
  17178. return;
  17179. }
  17180. const callbacks2 = callbacksMap[mapInfo.type] = callbacksMap[mapInfo.type] || [];
  17181. if (maps) {
  17182. callback(maps);
  17183. } else if (window[mapInfo.type] && window[mapInfo.type].maps) {
  17184. maps = getIsAMap() || getIsBMap() ? window[mapInfo.type] : window[mapInfo.type].maps;
  17185. maps.Callout = maps.Callout || createCallout(maps);
  17186. callback(maps);
  17187. } else if (callbacks2.length) {
  17188. callbacks2.push(callback);
  17189. } else {
  17190. callbacks2.push(callback);
  17191. const globalExt = window;
  17192. const callbackName = GOOGLE_MAP_CALLBACKNAME + mapInfo.type;
  17193. globalExt[callbackName] = function() {
  17194. delete globalExt[callbackName];
  17195. maps = getIsAMap() || getIsBMap() ? window[mapInfo.type] : window[mapInfo.type].maps;
  17196. maps.Callout = createCallout(maps);
  17197. callbacks2.forEach((callback2) => callback2(maps));
  17198. callbacks2.length = 0;
  17199. };
  17200. if (getIsAMap()) {
  17201. handleAMapSecurityPolicy(mapInfo);
  17202. }
  17203. const script = document.createElement("script");
  17204. let src = getScriptBaseUrl(mapInfo.type);
  17205. if (mapInfo.type === MapType.QQ) {
  17206. libraries.push("geometry");
  17207. }
  17208. if (libraries.length) {
  17209. src += `libraries=${libraries.join("%2C")}&`;
  17210. }
  17211. if (mapInfo.type === MapType.BMAP) {
  17212. script.src = `${src}ak=${mapInfo.key}&callback=${callbackName}`;
  17213. } else {
  17214. script.src = `${src}key=${mapInfo.key}&callback=${callbackName}`;
  17215. }
  17216. script.onerror = function() {
  17217. console.error("Map load failed.");
  17218. };
  17219. document.body.appendChild(script);
  17220. }
  17221. }
  17222. const getScriptBaseUrl = (mapType) => {
  17223. const urlMap = {
  17224. qq: "https://map.qq.com/api/js?v=2.exp&",
  17225. google: "https://maps.googleapis.com/maps/api/js?",
  17226. AMap: "https://webapi.amap.com/maps?v=2.0&",
  17227. BMapGL: "https://api.map.baidu.com/api?type=webgl&v=1.0&"
  17228. };
  17229. return urlMap[mapType];
  17230. };
  17231. function handleAMapSecurityPolicy(mapInfo) {
  17232. window._AMapSecurityConfig = {
  17233. securityJsCode: mapInfo.securityJsCode || "",
  17234. serviceHost: mapInfo.serviceHost || ""
  17235. };
  17236. }
  17237. const ICON_PATH_LOCTAION = "M13.3334375 16 q0.033125 1.1334375 0.783125 1.8834375 q0.75 0.75 1.8834375 0.75 q1.1334375 0 1.8834375 -0.75 q0.75 -0.75 0.75 -1.8834375 q0 -1.1334375 -0.75 -1.8834375 q-0.75 -0.75 -1.8834375 -0.75 q-1.1334375 0 -1.8834375 0.75 q-0.75 0.75 -0.783125 1.8834375 ZM30.9334375 14.9334375 l-1.1334375 0 q-0.5 -5.2 -4.0165625 -8.716875 q-3.516875 -3.5165625 -8.716875 -4.0165625 l0 -1.1334375 q0 -0.4665625 -0.3 -0.7665625 q-0.3 -0.3 -0.7665625 -0.3 q-0.4665625 0 -0.7665625 0.3 q-0.3 0.3 -0.3 0.7665625 l0 1.1334375 q-5.2 0.5 -8.716875 4.0165625 q-3.5165625 3.516875 -4.0165625 8.716875 l-1.1334375 0 q-0.4665625 0 -0.7665625 0.3 q-0.3 0.3 -0.3 0.7665625 q0 0.4665625 0.3 0.7665625 q0.3 0.3 0.7665625 0.3 l1.1334375 0 q0.5 5.2 4.0165625 8.716875 q3.516875 3.5165625 8.716875 4.0165625 l0 1.1334375 q0 0.4665625 0.3 0.7665625 q0.3 0.3 0.7665625 0.3 q0.4665625 0 0.7665625 -0.3 q0.3 -0.3 0.3 -0.7665625 l0 -1.1334375 q5.2 -0.5 8.716875 -4.0165625 q3.5165625 -3.516875 4.0165625 -8.716875 l1.1334375 0 q0.4665625 0 0.7665625 -0.3 q0.3 -0.3 0.3 -0.7665625 q0 -0.4665625 -0.3 -0.7665625 q-0.3 -0.3 -0.7665625 -0.3 ZM17.0665625 27.6665625 l0 -2.0665625 q0 -0.4665625 -0.3 -0.7665625 q-0.3 -0.3 -0.7665625 -0.3 q-0.4665625 0 -0.7665625 0.3 q-0.3 0.3 -0.3 0.7665625 l0 2.0665625 q-4.3 -0.4665625 -7.216875 -3.383125 q-2.916875 -2.916875 -3.3834375 -7.216875 l2.0665625 0 q0.4665625 0 0.7665625 -0.3 q0.3 -0.3 0.3 -0.7665625 q0 -0.4665625 -0.3 -0.7665625 q-0.3 -0.3 -0.7665625 -0.3 l-2.0665625 0 q0.4665625 -4.3 3.3834375 -7.216875 q2.9165625 -2.916875 7.216875 -3.3834375 l0 2.0665625 q0 0.4665625 0.3 0.7665625 q0.3 0.3 0.7665625 0.3 q0.4665625 0 0.7665625 -0.3 q0.3 -0.3 0.3 -0.7665625 l0 -2.0665625 q4.3 0.4665625 7.216875 3.3834375 q2.9165625 2.9165625 3.383125 7.216875 l-2.0665625 0 q-0.4665625 0 -0.7665625 0.3 q-0.3 0.3 -0.3 0.7665625 q0 0.4665625 0.3 0.7665625 q0.3 0.3 0.7665625 0.3 l2.0665625 0 q-0.4665625 4.3 -3.383125 7.216875 q-2.916875 2.9165625 -7.216875 3.383125 Z";
  17238. const ICON_PATH_ORIGIN = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIQAAACECAMAAABmmnOVAAAC01BMVEUAAAAAef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef8Aef96quGStdqStdpbnujMzMzCyM7Gyc7Ky83MzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMwAef8GfP0yjfNWnOp0qOKKsdyYt9mju9aZt9mMstx1qeJYnekyjvIIfP0qivVmouaWttnMzMyat9lppOUujPQKffxhoOfNzc3Y2Njh4eHp6enu7u7y8vL19fXv7+/i4uLZ2dnOzs6auNgOf/sKff15quHR0dHx8fH9/f3////j4+N6quFdn+iywdPb29vw8PD+/v7c3NyywtLa2tr29vbS0tLd3d38/Pzf39/o6Ojc7f+q0v+HwP9rsf9dqv9Hnv9Vpv/q6urj8P+Vx/9Am/8Pgf8Iff/z8/OAvP95uf/n5+c5l//V6f+52v+y1//7+/vt7e0rkP/09PTQ0NDq9P8Whf+cy//W1tbe3t7A3v/m5ubs7OxOov/r6+vk5OQiaPjKAAAAknRSTlMACBZ9oB71/jiqywJBZATT6hBukRXv+zDCAVrkDIf4JbQsTb7eVeJLbwfa8Rh4G/OlPS/6/kxQ9/xdmZudoJxNVhng7B6wtWdzAtQOipcF1329wS44doK/BAkyP1pvgZOsrbnGXArAg34G2IsD1eMRe7bi7k5YnqFT9V0csyPedQyYD3p/Fje+hDpskq/MwpRBC6yKp2MAAAQdSURBVHja7Zn1exMxGIAPHbrhDsPdneHuNtzd3d3dIbjLh93o2o4i7TpgG1Jk0g0mMNwd/gTa5rq129reHnK5e/bk/TFNk/dJ7r5894XjGAwGg8GgTZasCpDIll1+hxw5vXLJLpEboTx5ZXbIhyzkl9fB28cqUaCgrBKFkI3CcjoUKYolihWXUSI7EihRUjaHXF52CVRKLoe8eZIdUOkyMknkRw6UlcehYAFHiXK+skgURk6Ul8OhQjFnCVRRBolKqRxQ5SzUHaqgNGSj7VCmalqJnDkoS5RF6ZCbroNvufQkUD6qEuXTdUA+3hQdqiEXVKfnUKOmK4latalJ1EEuoZZ6162HJ9x/4OChw0eOHj12/MTJU6dxG7XUu751tjNnz4ET5y9ctLZTSr0beKFLl89bpuUDrqgC1RqNWqsKuqqzNFw7e51S6u3tc+OmZUJ9kCHY6ECwOkRvab51iUrqXej2HYDQsHBjWgx3Ae7dppB6N2wEcF9jdMGDUIDGTaR2aNoM9FqjG7QmaN5CWgc/gIePjG559BigpZQOrYB/4jBfRGRUtDkmJjY6KjLCofkpD62lc2gDfMpWPIuLdwyV8XEpHgaddBZ+wBuSFcwJqSN2ovmZ/dfnOvCTxqGtwzq8SEjv4EhISn48eWgnhUP7DvDSvgzxrs6vV6+FLiro2EkCic4QKkzwJsH1KYreCp0eQhfyDl1B/w4P/xa5JVJ4U03QjbRD9x7wXlgH5IE3wmMBHXoSlugFAcI6f/AkkSi8q6HQm6xDn77wEQ8djTwSj3tqAMguRTe4ikeOQyJ4YV+KfkQl+oNW5GbY4gWOWgbwJ+kwAD6Fi90MK2ZsrIeBBCUGwRXbqJ+/iJMQliIEBhOU6AJhtlG/IpHE2bqrYQg5h6HA4yQiRqwEfkGCdTCMmMRw+IbPDCQaHCsCYAQxiZHw3TbmD/ESOHgHwShiEqPhp/gggYkSztIxxCRawy/bmEniJaJtfwiEscQkxkFgRqJESqQwwHhiEuMBp3Vm8RK/cZoHEzKXhCK2QxEPpiJe0YlKCFaKCNv/cYBNUsBRPlkJSc0U+dM7E9H0ThGJbgZT/iR7yj+VqMS06Qr4+OFm2JdCxIa8lugzkJs5K6MfxAaYPUcBpYG5khZJEkUUSb7DPCnKRfPBXj6M8FwuegoLpCgXcQszVjhbJFUJUee2hBhLoYTIcYtB57KY+opSMdVqwatSlZVj05aV//CwJLMX2DluaUcwhXm4ali2XOoLjxUrPV26zFtF4f5p0Gp310+z13BUWNvbehEXona6iAtX/zVZmtfN4WixfsNky4S6gCCVVq3RPLdfSfpv3MRRZfPoLc6Xs/5bt3EyMGzE9h07/Xft2t15z6i9+zgGg8FgMBgMBoPBYDAYDAYj8/APG67Rie8pUDsAAAAASUVORK5CYII=";
  17239. const ICON_PATH_TARGET = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAACcCAMAAAC3Fl5oAAAB3VBMVEVMaXH/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/EhL/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/Dw//AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/AAD/GRn/NTX/Dw//Fhb/AAD/AAD/AAD/GRn/GRn/Y2P/AAD/AAD/ExP/Ghr/AAD/AAD/MzP/GRn/AAD/Hh7/AAD/RUX/AAD/AAD/AAD/AAD/AAD/AAD/Dg7/AAD/HR3/Dw//FRX/SUn/AAD/////kJD/DQ3/Zmb/+/v/wMD/mJj/6en/vb3/1NT//Pz/ODj/+fn/3Nz/nJz/j4//9/f/7e3/9vb/7Oz/2Nj/x8f/Ozv/+Pj/3d3/nZ3/2dn//f3/6Oj/2tr/v7//09P/vr7/mZn/l5cdSvP3AAAAe3RSTlMAAhLiZgTb/vztB/JMRhlp6lQW86g8mQ4KFPs3UCH5U8huwlesWtTYGI7RsdVeJGfTW5rxnutLsvXWF8vQNdo6qQbuz7D4hgVIx2xtw8GC1TtZaIw0i84P98tU0/fsj7PKaAgiZZxeVfo8Z52eg1P0nESrENnjXVPUgw/uuSmDAAADsUlEQVR42u3aZ3cTRxgF4GtbYleSLdnGcsENG2ODjbExEHrvhAQCIb1Bem+QdkeuuFMNBBJIfmuOckzZI8/srHYmH3Lm+QNXK632LTvQ03Tu/IWeU/tTGTKT2n+q58L5c00wpXJd47DHEt5w47pKxLbhdLdPKb/7dBYxVLxw1GcI/2h1BcpzKNFHLX2JQ4gumaiitqpEEhEdOMJI9h5AFC3feYzI+7IF2tpSLEOqDXpObPRYFm/jCWho/4Ble7MdoT7fzhhq9yHEz28wltU1UPrJZ0wd66HwicfYvEFIfePTAP8tSLTupBHvtGJFH9bSkNrNWEHzERrT34xSH9Ogr1CijkbVAUH1KRqVqkdQAw07iIAaGlcTqI+/0LjeJJ5J0IIEnkpXMdzs4sTtW9dnZq7fuj2xOMtwVWk88RHDjBYejYvnjD8qjOpfQsUqhvj7oSjxcJIhVj3pyKqpNjYvVjQ/RrXq5YABKi3MCYm5BSrtWO5v11DlmlC4RpU1WRS9SJU7QukOVbpQ9JLu549+Dd0AUOlTbkGEuk85vxLAK5QbuytC3R2j3HoAjZSbFxrmKTcCoJdSk0LLJKV6gSaPMqNTQsvUKGW8JrxKqUWhaZFSeWyh1LTQNE2pHF6mzOy40DQ+S5mLimJcENoKlOnBWsr8KbRNUGYt5LXgd6HtD3lNQIoyN4S2G5RJIUOZm0LbTcqsBqVmhLYZSlkPsP4VWf+Rrd+m1v9o9h8Vv5p42C1R5qL1x7WRglOgVN52yfwNOBu76P+lLPoYidu23KPciIHGa07ZeIW1jvcNtI7q5vexCPGYCmf+m/Y9a3sAwQ5bI9T7ukPgPcn9GToEao+xk1OixJT+GIsvNAbx6eAgPq0xiF+KtkpYKhRXCQ8eFFcJhSWGu3rZ8jJkCM8kz9K4TUnrC6mAgzTsB9tLwQ2W15qfosQ2GrQNpZr7aczbzVjBZsvLcaC1g0bsbIVEnU8DOr6H1KDH2LwtUBi0/JII6Dxm9zUXkH+XMWzfh1Dte1i2Pe3QkC77Zel7aehpO8wyHG6Dtt0NjKxhN6I4uSli/TqJiJJDUQ4NDCURXTrXRy1XcumyD24M+AzhD1RXIIZsl/LoyZmurJHDM7s8lvB2FQ/PmPJ6PseAXP5HGMYAAC7ABbgAF+ACXIALcAEuwAW4ABfgAlyAC3ABLsAFuID/d8Cx4NEt8/byOf0wLnis8zjMq9/Kp7bWw4JOj8u8TlhRl+G/Mp2wpOX48GffvvZ1CyL4B53LAS6zb08EAAAAAElFTkSuQmCC";
  17240. var MapType = /* @__PURE__ */ ((MapType2) => {
  17241. MapType2["QQ"] = "qq";
  17242. MapType2["GOOGLE"] = "google";
  17243. MapType2["AMAP"] = "AMap";
  17244. MapType2["BMAP"] = "BMapGL";
  17245. MapType2["UNKNOWN"] = "";
  17246. return MapType2;
  17247. })(MapType || {});
  17248. function getMapInfo() {
  17249. if (__uniConfig.bMapKey) {
  17250. return {
  17251. type: "BMapGL",
  17252. key: __uniConfig.bMapKey
  17253. };
  17254. }
  17255. if (__uniConfig.qqMapKey) {
  17256. return {
  17257. type: "qq",
  17258. key: __uniConfig.qqMapKey
  17259. };
  17260. }
  17261. if (__uniConfig.googleMapKey) {
  17262. return {
  17263. type: "google",
  17264. key: __uniConfig.googleMapKey
  17265. };
  17266. }
  17267. if (__uniConfig.aMapKey) {
  17268. return {
  17269. type: "AMap",
  17270. key: __uniConfig.aMapKey,
  17271. securityJsCode: __uniConfig.aMapSecurityJsCode,
  17272. serviceHost: __uniConfig.aMapServiceHost
  17273. };
  17274. }
  17275. return {
  17276. type: "",
  17277. key: ""
  17278. };
  17279. }
  17280. let IS_AMAP = false;
  17281. let hasGetIsAMap = false;
  17282. const getIsAMap = () => {
  17283. if (hasGetIsAMap) {
  17284. return IS_AMAP;
  17285. } else {
  17286. hasGetIsAMap = true;
  17287. return IS_AMAP = getMapInfo().type === "AMap";
  17288. }
  17289. };
  17290. const getIsBMap = () => {
  17291. return getMapInfo().type === "BMapGL";
  17292. };
  17293. function translateCoordinateSystem(type, coords, skip) {
  17294. const mapInfo = getMapInfo();
  17295. const wgs84Map = [
  17296. "google"
  17297. /* GOOGLE */
  17298. ];
  17299. if (type && type.toUpperCase() === "WGS84" || wgs84Map.includes(mapInfo.type) || skip) {
  17300. return Promise.resolve(coords);
  17301. }
  17302. if (mapInfo.type === "qq") {
  17303. return new Promise((resolve) => {
  17304. getJSONP(
  17305. `https://apis.map.qq.com/jsapi?qt=translate&type=1&points=${coords.longitude},${coords.latitude}&key=${mapInfo.key}&output=jsonp&pf=jsapi&ref=jsapi`,
  17306. {
  17307. callback: "cb"
  17308. },
  17309. (res) => {
  17310. if ("detail" in res && "points" in res.detail && res.detail.points.length) {
  17311. const { lng, lat } = res.detail.points[0];
  17312. resolve({
  17313. longitude: lng,
  17314. latitude: lat,
  17315. altitude: coords.altitude,
  17316. accuracy: coords.accuracy,
  17317. altitudeAccuracy: coords.altitudeAccuracy,
  17318. heading: coords.heading,
  17319. speed: coords.speed
  17320. });
  17321. } else {
  17322. resolve(coords);
  17323. }
  17324. },
  17325. () => resolve(coords)
  17326. );
  17327. });
  17328. }
  17329. if (mapInfo.type === "AMap") {
  17330. return new Promise((resolve) => {
  17331. loadMaps([], () => {
  17332. window.AMap.convertFrom(
  17333. [coords.longitude, coords.latitude],
  17334. "gps",
  17335. (_, res) => {
  17336. if (res.info === "ok" && res.locations.length) {
  17337. const { lat, lng } = res.locations[0];
  17338. resolve({
  17339. longitude: lng,
  17340. latitude: lat,
  17341. altitude: coords.altitude,
  17342. accuracy: coords.accuracy,
  17343. altitudeAccuracy: coords.altitudeAccuracy,
  17344. heading: coords.heading,
  17345. speed: coords.speed
  17346. });
  17347. } else {
  17348. resolve(coords);
  17349. }
  17350. }
  17351. );
  17352. });
  17353. });
  17354. }
  17355. return Promise.reject(new Error("translate coordinate system faild"));
  17356. }
  17357. const props$e = {
  17358. id: {
  17359. type: [Number, String],
  17360. default: ""
  17361. },
  17362. latitude: {
  17363. type: [Number, String],
  17364. require: true
  17365. },
  17366. longitude: {
  17367. type: [Number, String],
  17368. require: true
  17369. },
  17370. title: {
  17371. type: String,
  17372. default: ""
  17373. },
  17374. iconPath: {
  17375. type: String,
  17376. require: true
  17377. },
  17378. rotate: {
  17379. type: [Number, String],
  17380. default: 0
  17381. },
  17382. alpha: {
  17383. type: [Number, String],
  17384. default: 1
  17385. },
  17386. width: {
  17387. type: [Number, String],
  17388. default: ""
  17389. },
  17390. height: {
  17391. type: [Number, String],
  17392. default: ""
  17393. },
  17394. callout: {
  17395. type: Object,
  17396. default: null
  17397. },
  17398. label: {
  17399. type: Object,
  17400. default: null
  17401. },
  17402. anchor: {
  17403. type: Object,
  17404. default: null
  17405. },
  17406. clusterId: {
  17407. type: [Number, String],
  17408. default: ""
  17409. },
  17410. customCallout: {
  17411. type: Object,
  17412. default: null
  17413. },
  17414. ariaLabel: {
  17415. type: String,
  17416. default: ""
  17417. }
  17418. };
  17419. function useMarkerLabelStyle(id2) {
  17420. const className = "uni-map-marker-label-" + id2;
  17421. const styleEl = document.createElement("style");
  17422. styleEl.id = className;
  17423. document.head.appendChild(styleEl);
  17424. onUnmounted(() => {
  17425. styleEl.remove();
  17426. });
  17427. return function updateMarkerLabelStyle(style) {
  17428. const newStyle = Object.assign({}, style, {
  17429. position: "absolute",
  17430. top: "70px",
  17431. borderStyle: "solid"
  17432. });
  17433. const div = document.createElement("div");
  17434. Object.keys(newStyle).forEach((key) => {
  17435. div.style[key] = newStyle[key] || "";
  17436. });
  17437. styleEl.innerText = `.${className}{${div.getAttribute("style")}}`;
  17438. return className;
  17439. };
  17440. }
  17441. const MapMarker = /* @__PURE__ */ defineSystemComponent({
  17442. name: "MapMarker",
  17443. props: props$e,
  17444. setup(props2) {
  17445. const id2 = String(!isNaN(Number(props2.id)) ? props2.id : "");
  17446. const onMapReady = inject("onMapReady");
  17447. const updateMarkerLabelStyle = useMarkerLabelStyle(id2);
  17448. let marker;
  17449. function removeMarker() {
  17450. if (marker) {
  17451. if (marker.label && "setMap" in marker.label) {
  17452. marker.label.setMap(null);
  17453. }
  17454. if (marker.callout) {
  17455. removeMarkerCallout(marker.callout);
  17456. }
  17457. marker.setMap(null);
  17458. }
  17459. }
  17460. function removeMarkerCallout(callout) {
  17461. if (getIsAMap()) {
  17462. callout.removeAMapText();
  17463. } else {
  17464. callout.setMap(null);
  17465. }
  17466. }
  17467. onMapReady((map, maps2, trigger) => {
  17468. function updateMarker(option) {
  17469. const title = option.title;
  17470. let position;
  17471. if (getIsAMap()) {
  17472. position = new maps2.LngLat(option.longitude, option.latitude);
  17473. } else if (getIsBMap()) {
  17474. position = new maps2.Point(option.longitude, option.latitude);
  17475. } else {
  17476. position = new maps2.LatLng(option.latitude, option.longitude);
  17477. }
  17478. const img = new Image();
  17479. let imgHeight = 0;
  17480. img.onload = () => {
  17481. const anchor = option.anchor || {};
  17482. let icon;
  17483. let w;
  17484. let h2;
  17485. let top;
  17486. let x = typeof anchor.x === "number" ? anchor.x : 0.5;
  17487. let y = typeof anchor.y === "number" ? anchor.y : 1;
  17488. if (option.iconPath && (option.width || option.height)) {
  17489. w = option.width || img.width / img.height * option.height;
  17490. h2 = option.height || img.height / img.width * option.width;
  17491. } else {
  17492. w = img.width / 2;
  17493. h2 = img.height / 2;
  17494. }
  17495. imgHeight = h2;
  17496. top = h2 - (h2 - y * h2);
  17497. if ("MarkerImage" in maps2) {
  17498. icon = new maps2.MarkerImage(img.src, null, null, new maps2.Point(x * w, y * h2), new maps2.Size(w, h2));
  17499. } else if ("Icon" in maps2) {
  17500. icon = new maps2.Icon({
  17501. image: img.src,
  17502. size: new maps2.Size(w, h2),
  17503. imageSize: new maps2.Size(w, h2),
  17504. imageOffset: new maps2.Pixel(x * w, y * h2)
  17505. });
  17506. } else {
  17507. icon = {
  17508. url: img.src,
  17509. anchor: new maps2.Point(x, y),
  17510. size: new maps2.Size(w, h2)
  17511. };
  17512. }
  17513. if (getIsBMap()) {
  17514. marker = new maps2.Marker(new maps2.Point(position.lng, position.lat));
  17515. map.addOverlay(marker);
  17516. } else {
  17517. marker.setPosition(position);
  17518. marker.setIcon(icon);
  17519. }
  17520. if ("setRotation" in marker) {
  17521. marker.setRotation(option.rotate || 0);
  17522. }
  17523. const labelOpt = option.label || {};
  17524. if ("label" in marker) {
  17525. marker.label.setMap(null);
  17526. delete marker.label;
  17527. }
  17528. let label;
  17529. if (labelOpt.content) {
  17530. const labelStyle = {
  17531. borderColor: labelOpt.borderColor,
  17532. borderWidth: (Number(labelOpt.borderWidth) || 0) + "px",
  17533. padding: (Number(labelOpt.padding) || 0) + "px",
  17534. borderRadius: (Number(labelOpt.borderRadius) || 0) + "px",
  17535. backgroundColor: labelOpt.bgColor,
  17536. color: labelOpt.color,
  17537. fontSize: (labelOpt.fontSize || 14) + "px",
  17538. lineHeight: (labelOpt.fontSize || 14) + "px",
  17539. marginLeft: (Number(labelOpt.anchorX || labelOpt.x) || 0) + "px",
  17540. marginTop: (Number(labelOpt.anchorY || labelOpt.y) || 0) + "px"
  17541. };
  17542. if ("Label" in maps2) {
  17543. label = new maps2.Label({
  17544. position,
  17545. map,
  17546. clickable: false,
  17547. content: labelOpt.content,
  17548. style: labelStyle
  17549. });
  17550. marker.label = label;
  17551. } else if ("setLabel" in marker) {
  17552. if (getIsAMap()) {
  17553. const content = `<div style="
  17554. margin-left:${labelStyle.marginLeft};
  17555. margin-top:${labelStyle.marginTop};
  17556. padding:${labelStyle.padding};
  17557. background-color:${labelStyle.backgroundColor};
  17558. border-radius:${labelStyle.borderRadius};
  17559. line-height:${labelStyle.lineHeight};
  17560. color:${labelStyle.color};
  17561. font-size:${labelStyle.fontSize};
  17562. ">
  17563. ${labelOpt.content}
  17564. <div>`;
  17565. marker.setLabel({
  17566. content,
  17567. direction: "bottom-right"
  17568. });
  17569. } else {
  17570. const className = updateMarkerLabelStyle(labelStyle);
  17571. marker.setLabel({
  17572. text: labelOpt.content,
  17573. color: labelStyle.color,
  17574. fontSize: labelStyle.fontSize,
  17575. className
  17576. });
  17577. }
  17578. }
  17579. }
  17580. const calloutOpt = option.callout || {};
  17581. let callout = marker.callout;
  17582. let calloutStyle;
  17583. if (calloutOpt.content || title) {
  17584. if (getIsAMap() && calloutOpt.content) {
  17585. calloutOpt.content = calloutOpt.content.replaceAll("\n", "<br/>");
  17586. }
  17587. const boxShadow = "0px 0px 3px 1px rgba(0,0,0,0.5)";
  17588. let offsetY = -imgHeight / 2;
  17589. if (option.width || option.height) {
  17590. offsetY += 14 - imgHeight / 2;
  17591. }
  17592. calloutStyle = calloutOpt.content ? {
  17593. position,
  17594. map,
  17595. top,
  17596. // handle AMap callout offset
  17597. offsetY,
  17598. content: calloutOpt.content,
  17599. color: calloutOpt.color,
  17600. fontSize: calloutOpt.fontSize,
  17601. borderRadius: calloutOpt.borderRadius,
  17602. bgColor: calloutOpt.bgColor,
  17603. padding: calloutOpt.padding,
  17604. boxShadow: calloutOpt.boxShadow || boxShadow,
  17605. display: calloutOpt.display
  17606. } : {
  17607. position,
  17608. map,
  17609. top,
  17610. // handle AMap callout offset
  17611. offsetY,
  17612. content: title,
  17613. boxShadow
  17614. };
  17615. if (callout) {
  17616. callout.setOption(calloutStyle);
  17617. } else {
  17618. if (getIsAMap()) {
  17619. const callback = (id3) => {
  17620. if (id3 !== "") {
  17621. trigger("callouttap", {}, {
  17622. markerId: Number(id3)
  17623. });
  17624. }
  17625. };
  17626. callout = marker.callout = new maps2.Callout(calloutStyle, callback);
  17627. } else {
  17628. callout = marker.callout = new maps2.Callout(calloutStyle);
  17629. callout.div.onclick = function($event) {
  17630. if (id2 !== "") {
  17631. trigger("callouttap", $event, {
  17632. markerId: Number(id2)
  17633. });
  17634. }
  17635. $event.stopPropagation();
  17636. $event.preventDefault();
  17637. };
  17638. if (getMapInfo().type === MapType.GOOGLE) {
  17639. callout.div.ontouchstart = function($event) {
  17640. $event.stopPropagation();
  17641. };
  17642. callout.div.onpointerdown = function($event) {
  17643. $event.stopPropagation();
  17644. };
  17645. }
  17646. }
  17647. }
  17648. } else {
  17649. if (callout) {
  17650. removeMarkerCallout(callout);
  17651. delete marker.callout;
  17652. }
  17653. }
  17654. };
  17655. if (option.iconPath) {
  17656. img.src = getRealPath(option.iconPath);
  17657. } else {
  17658. console.error("Marker.iconPath is required.");
  17659. }
  17660. }
  17661. function addMarker(props3) {
  17662. if (!getIsBMap()) {
  17663. marker = new maps2.Marker({
  17664. map,
  17665. flat: true,
  17666. autoRotation: false
  17667. });
  17668. }
  17669. updateMarker(props3);
  17670. const MapsEvent = maps2.event || maps2.Event;
  17671. if (getIsBMap())
  17672. ;
  17673. else {
  17674. MapsEvent.addListener(marker, "click", () => {
  17675. const callout = marker.callout;
  17676. if (callout && !callout.alwaysVisible) {
  17677. if (getIsAMap()) {
  17678. callout.visible = !callout.visible;
  17679. if (callout.visible) {
  17680. marker.callout.createAMapText();
  17681. } else {
  17682. marker.callout.removeAMapText();
  17683. }
  17684. } else {
  17685. callout.set("visible", !callout.visible);
  17686. if (callout.visible) {
  17687. const div = callout.div;
  17688. const parent = div.parentNode;
  17689. parent.removeChild(div);
  17690. parent.appendChild(div);
  17691. }
  17692. }
  17693. }
  17694. if (id2) {
  17695. trigger("markertap", {}, {
  17696. markerId: Number(id2),
  17697. latitude: props3.latitude,
  17698. longitude: props3.longitude
  17699. });
  17700. }
  17701. });
  17702. }
  17703. }
  17704. addMarker(props2);
  17705. watch(props2, updateMarker);
  17706. });
  17707. if (id2) {
  17708. const addMapChidlContext = inject("addMapChidlContext");
  17709. const removeMapChidlContext = inject("removeMapChidlContext");
  17710. const context = {
  17711. id: id2,
  17712. translate(data) {
  17713. onMapReady((map, maps2, trigger) => {
  17714. const destination = data.destination;
  17715. const duration = data.duration;
  17716. const autoRotate = !!data.autoRotate;
  17717. let rotate = Number(data.rotate) || 0;
  17718. let rotation = 0;
  17719. if ("getRotation" in marker) {
  17720. rotation = marker.getRotation();
  17721. }
  17722. const a2 = marker.getPosition();
  17723. const b = new maps2.LatLng(destination.latitude, destination.longitude);
  17724. const distance2 = maps2.geometry.spherical.computeDistanceBetween(a2, b) / 1e3;
  17725. const time = (typeof duration === "number" ? duration : 1e3) / (1e3 * 60 * 60);
  17726. const speed = distance2 / time;
  17727. const MapsEvent = maps2.event || maps2.Event;
  17728. const movingEvent = MapsEvent.addListener(marker, "moving", (e2) => {
  17729. const latLng = e2.latLng;
  17730. const label = marker.label;
  17731. if (label) {
  17732. label.setPosition(latLng);
  17733. }
  17734. const callout = marker.callout;
  17735. if (callout) {
  17736. callout.setPosition(latLng);
  17737. }
  17738. });
  17739. const event = MapsEvent.addListener(marker, "moveend", () => {
  17740. event.remove();
  17741. movingEvent.remove();
  17742. marker.lastPosition = a2;
  17743. marker.setPosition(b);
  17744. const label = marker.label;
  17745. if (label) {
  17746. label.setPosition(b);
  17747. }
  17748. const callout = marker.callout;
  17749. if (callout) {
  17750. callout.setPosition(b);
  17751. }
  17752. const cb = data.animationEnd;
  17753. if (isFunction(cb)) {
  17754. cb();
  17755. }
  17756. });
  17757. let lastRtate = 0;
  17758. if (autoRotate) {
  17759. if (marker.lastPosition) {
  17760. lastRtate = maps2.geometry.spherical.computeHeading(marker.lastPosition, a2);
  17761. }
  17762. rotate = maps2.geometry.spherical.computeHeading(a2, b) - lastRtate;
  17763. }
  17764. if ("setRotation" in marker) {
  17765. marker.setRotation(rotation + rotate);
  17766. }
  17767. if ("moveTo" in marker) {
  17768. marker.moveTo(b, speed);
  17769. } else {
  17770. marker.setPosition(b);
  17771. MapsEvent.trigger(marker, "moveend", {});
  17772. }
  17773. });
  17774. }
  17775. };
  17776. addMapChidlContext(context);
  17777. onUnmounted(() => removeMapChidlContext(context));
  17778. }
  17779. onUnmounted(removeMarker);
  17780. return () => {
  17781. return null;
  17782. };
  17783. }
  17784. });
  17785. function hexToRgba(hex) {
  17786. if (!hex) {
  17787. return {
  17788. r: 0,
  17789. g: 0,
  17790. b: 0,
  17791. a: 0
  17792. };
  17793. }
  17794. let tmpHex = hex.slice(1);
  17795. const tmpHexLen = tmpHex.length;
  17796. if (![3, 4, 6, 8].includes(tmpHexLen)) {
  17797. return {
  17798. r: 0,
  17799. g: 0,
  17800. b: 0,
  17801. a: 0
  17802. };
  17803. }
  17804. if (tmpHexLen === 3 || tmpHexLen === 4) {
  17805. tmpHex = tmpHex.replace(/(\w{1})/g, "$1$1");
  17806. }
  17807. let [sr, sg, sb, sa] = tmpHex.match(/(\w{2})/g);
  17808. const r = parseInt(sr, 16), g2 = parseInt(sg, 16), b = parseInt(sb, 16);
  17809. if (!sa) {
  17810. return { r, g: g2, b, a: 1 };
  17811. }
  17812. return {
  17813. r,
  17814. g: g2,
  17815. b,
  17816. a: (`0x100${sa}` - 65536) / 255
  17817. };
  17818. }
  17819. const props$d = {
  17820. points: {
  17821. type: Array,
  17822. require: true
  17823. },
  17824. color: {
  17825. type: String,
  17826. default: "#000000"
  17827. },
  17828. width: {
  17829. type: [Number, String],
  17830. default: ""
  17831. },
  17832. dottedLine: {
  17833. type: [Boolean, String],
  17834. default: false
  17835. },
  17836. arrowLine: {
  17837. type: [Boolean, String],
  17838. default: false
  17839. },
  17840. arrowIconPath: {
  17841. type: String,
  17842. default: ""
  17843. },
  17844. borderColor: {
  17845. type: String,
  17846. default: "#000000"
  17847. },
  17848. borderWidth: {
  17849. type: [Number, String],
  17850. default: ""
  17851. },
  17852. colorList: {
  17853. type: Array,
  17854. default() {
  17855. return [];
  17856. }
  17857. },
  17858. level: {
  17859. type: String,
  17860. default: ""
  17861. }
  17862. };
  17863. const MapPolyline = /* @__PURE__ */ defineSystemComponent({
  17864. name: "MapPolyline",
  17865. props: props$d,
  17866. setup(props2) {
  17867. const onMapReady = inject("onMapReady");
  17868. let polyline;
  17869. let polylineBorder;
  17870. function removePolyline() {
  17871. if (polyline) {
  17872. polyline.setMap(null);
  17873. }
  17874. if (polylineBorder) {
  17875. polylineBorder.setMap(null);
  17876. }
  17877. }
  17878. onMapReady((map, maps2) => {
  17879. function updatePolyline(option) {
  17880. removePolyline();
  17881. addPolyline(option);
  17882. }
  17883. function addPolyline(option) {
  17884. const path = [];
  17885. option.points.forEach((point) => {
  17886. let pointPosition;
  17887. if (getIsAMap()) {
  17888. pointPosition = [point.longitude, point.latitude];
  17889. } else if (getIsBMap()) {
  17890. pointPosition = new maps2.Point(point.longitude, point.latitude);
  17891. } else {
  17892. pointPosition = new maps2.LatLng(point.latitude, point.longitude);
  17893. }
  17894. path.push(pointPosition);
  17895. });
  17896. const strokeWeight = Number(option.width) || 1;
  17897. const {
  17898. r: sr,
  17899. g: sg,
  17900. b: sb,
  17901. a: sa
  17902. } = hexToRgba(option.color);
  17903. const {
  17904. r: br,
  17905. g: bg,
  17906. b: bb,
  17907. a: ba
  17908. } = hexToRgba(option.borderColor);
  17909. const polylineOptions = {
  17910. map,
  17911. clickable: false,
  17912. path,
  17913. strokeWeight,
  17914. strokeColor: option.color || void 0,
  17915. strokeDashStyle: option.dottedLine ? "dash" : "solid"
  17916. };
  17917. const borderWidth = Number(option.borderWidth) || 0;
  17918. const polylineBorderOptions = {
  17919. map,
  17920. clickable: false,
  17921. path,
  17922. strokeWeight: strokeWeight + borderWidth * 2,
  17923. strokeColor: option.borderColor || void 0,
  17924. strokeDashStyle: option.dottedLine ? "dash" : "solid"
  17925. };
  17926. if ("Color" in maps2) {
  17927. polylineOptions.strokeColor = new maps2.Color(sr, sg, sb, sa);
  17928. polylineBorderOptions.strokeColor = new maps2.Color(br, bg, bb, ba);
  17929. } else {
  17930. polylineOptions.strokeColor = `rgb(${sr}, ${sg}, ${sb})`;
  17931. polylineOptions.strokeOpacity = sa;
  17932. polylineBorderOptions.strokeColor = `rgb(${br}, ${bg}, ${bb})`;
  17933. polylineBorderOptions.strokeOpacity = ba;
  17934. }
  17935. if (borderWidth) {
  17936. polylineBorder = new maps2.Polyline(polylineBorderOptions);
  17937. }
  17938. if (getIsBMap()) {
  17939. polyline = new maps2.Polyline(polylineOptions.path, polylineOptions);
  17940. map.addOverlay(polyline);
  17941. } else {
  17942. polyline = new maps2.Polyline(polylineOptions);
  17943. }
  17944. }
  17945. addPolyline(props2);
  17946. watch(props2, updatePolyline);
  17947. });
  17948. onUnmounted(removePolyline);
  17949. return () => {
  17950. return null;
  17951. };
  17952. }
  17953. });
  17954. const props$c = {
  17955. latitude: {
  17956. type: [Number, String],
  17957. require: true
  17958. },
  17959. longitude: {
  17960. type: [Number, String],
  17961. require: true
  17962. },
  17963. color: {
  17964. type: String,
  17965. default: "#000000"
  17966. },
  17967. fillColor: {
  17968. type: String,
  17969. default: "#00000000"
  17970. },
  17971. radius: {
  17972. type: [Number, String],
  17973. require: true
  17974. },
  17975. strokeWidth: {
  17976. type: [Number, String],
  17977. default: ""
  17978. },
  17979. level: {
  17980. type: String,
  17981. default: ""
  17982. }
  17983. };
  17984. const MapCircle = /* @__PURE__ */ defineSystemComponent({
  17985. name: "MapCircle",
  17986. props: props$c,
  17987. setup(props2) {
  17988. const onMapReady = inject("onMapReady");
  17989. let circle;
  17990. function removeCircle() {
  17991. if (circle) {
  17992. circle.setMap(null);
  17993. }
  17994. }
  17995. onMapReady((map, maps2) => {
  17996. function updateCircle(option) {
  17997. removeCircle();
  17998. addCircle(option);
  17999. }
  18000. function addCircle(option) {
  18001. const center = getIsAMap() || getIsBMap() ? [option.longitude, option.latitude] : new maps2.LatLng(option.latitude, option.longitude);
  18002. const circleOptions = {
  18003. map,
  18004. center,
  18005. clickable: false,
  18006. radius: option.radius,
  18007. strokeWeight: Number(option.strokeWidth) || 1,
  18008. strokeDashStyle: "solid"
  18009. };
  18010. if (getIsBMap()) {
  18011. circleOptions.strokeColor = option.color;
  18012. circleOptions.fillColor = option.fillColor || "#000";
  18013. circleOptions.fillOpacity = 1;
  18014. } else {
  18015. const {
  18016. r: fr,
  18017. g: fg,
  18018. b: fb,
  18019. a: fa
  18020. } = hexToRgba(option.fillColor);
  18021. const {
  18022. r: sr,
  18023. g: sg,
  18024. b: sb,
  18025. a: sa
  18026. } = hexToRgba(option.color);
  18027. if ("Color" in maps2) {
  18028. circleOptions.fillColor = new maps2.Color(fr, fg, fb, fa);
  18029. circleOptions.strokeColor = new maps2.Color(sr, sg, sb, sa);
  18030. } else {
  18031. circleOptions.fillColor = `rgb(${fr}, ${fg}, ${fb})`;
  18032. circleOptions.fillOpacity = fa;
  18033. circleOptions.strokeColor = `rgb(${sr}, ${sg}, ${sb})`;
  18034. circleOptions.strokeOpacity = sa;
  18035. }
  18036. }
  18037. if (getIsBMap()) {
  18038. let pt = new maps2.Point(
  18039. // @ts-ignore
  18040. circleOptions.center[0],
  18041. // @ts-ignore
  18042. circleOptions.center[1]
  18043. );
  18044. circle = new maps2.Circle(pt, circleOptions.radius, circleOptions);
  18045. map.addOverlay(circle);
  18046. } else {
  18047. circle = new maps2.Circle(circleOptions);
  18048. if (getIsAMap()) {
  18049. map.add(circle);
  18050. }
  18051. }
  18052. }
  18053. addCircle(props2);
  18054. watch(props2, updateCircle);
  18055. });
  18056. onUnmounted(removeCircle);
  18057. return () => {
  18058. return null;
  18059. };
  18060. }
  18061. });
  18062. const props$b = {
  18063. id: {
  18064. type: [Number, String],
  18065. default: ""
  18066. },
  18067. position: {
  18068. type: Object,
  18069. required: true
  18070. },
  18071. iconPath: {
  18072. type: String,
  18073. required: true
  18074. },
  18075. clickable: {
  18076. type: [Boolean, String],
  18077. default: ""
  18078. },
  18079. trigger: {
  18080. type: Function,
  18081. required: true
  18082. }
  18083. };
  18084. const MapControl = /* @__PURE__ */ defineSystemComponent({
  18085. name: "MapControl",
  18086. props: props$b,
  18087. setup(props2) {
  18088. const imgPath = computed(() => getRealPath(props2.iconPath));
  18089. const positionStyle = computed(() => {
  18090. let positionStyle2 = `top:${props2.position.top || 0}px;left:${props2.position.left || 0}px;`;
  18091. if (props2.position.width) {
  18092. positionStyle2 += `width:${props2.position.width}px;`;
  18093. }
  18094. if (props2.position.height) {
  18095. positionStyle2 += `height:${props2.position.height}px;`;
  18096. }
  18097. return positionStyle2;
  18098. });
  18099. const handleClick = ($event) => {
  18100. if (props2.clickable) {
  18101. props2.trigger("controltap", $event, {
  18102. controlId: props2.id
  18103. });
  18104. }
  18105. };
  18106. return () => {
  18107. return createVNode("div", {
  18108. "class": "uni-map-control"
  18109. }, [createVNode("img", {
  18110. "src": imgPath.value,
  18111. "style": positionStyle.value,
  18112. "class": "uni-map-control-icon",
  18113. "onClick": handleClick
  18114. }, null, 12, ["src", "onClick"])]);
  18115. };
  18116. }
  18117. });
  18118. const initInnerAudioContextEventOnce = /* @__PURE__ */ once(() => {
  18119. innerAudioContextEventNames.forEach((eventName) => {
  18120. InnerAudioContext.prototype[eventName] = function(callback) {
  18121. if (isFunction(callback)) {
  18122. this._events[eventName].push(callback);
  18123. }
  18124. };
  18125. });
  18126. innerAudioContextOffEventNames.forEach((eventName) => {
  18127. InnerAudioContext.prototype[eventName] = function(callback) {
  18128. var handle = this._events[eventName.replace("off", "on")];
  18129. var index2 = handle.indexOf(callback);
  18130. if (index2 >= 0) {
  18131. handle.splice(index2, 1);
  18132. }
  18133. };
  18134. });
  18135. });
  18136. class InnerAudioContext {
  18137. /**
  18138. * 音频上下文初始化
  18139. */
  18140. constructor() {
  18141. this._src = "";
  18142. var audio = this._audio = new Audio();
  18143. this._stoping = false;
  18144. const propertys = [
  18145. "src",
  18146. "autoplay",
  18147. "loop",
  18148. "duration",
  18149. "currentTime",
  18150. "paused",
  18151. "volume"
  18152. ];
  18153. propertys.forEach((property) => {
  18154. Object.defineProperty(this, property, {
  18155. set: property === "src" ? (src) => {
  18156. audio.src = getRealPath(src);
  18157. this._src = src;
  18158. return src;
  18159. } : (val) => {
  18160. audio[property] = val;
  18161. return val;
  18162. },
  18163. get: property === "src" ? () => {
  18164. return this._src;
  18165. } : () => {
  18166. return audio[property];
  18167. }
  18168. });
  18169. });
  18170. this.startTime = 0;
  18171. Object.defineProperty(this, "obeyMuteSwitch", {
  18172. set: () => false,
  18173. get: () => false
  18174. });
  18175. Object.defineProperty(this, "buffered", {
  18176. get() {
  18177. var buffered = audio.buffered;
  18178. if (buffered.length) {
  18179. return buffered.end(buffered.length - 1);
  18180. } else {
  18181. return 0;
  18182. }
  18183. }
  18184. });
  18185. this._events = {};
  18186. innerAudioContextEventNames.forEach((eventName) => {
  18187. this._events[eventName] = [];
  18188. });
  18189. audio.addEventListener("loadedmetadata", () => {
  18190. var startTime = Number(this.startTime) || 0;
  18191. if (startTime > 0) {
  18192. audio.currentTime = startTime;
  18193. }
  18194. });
  18195. var stopEventNames = ["canplay", "pause", "seeking", "seeked", "timeUpdate"];
  18196. var eventNames = stopEventNames.concat([
  18197. "play",
  18198. "ended",
  18199. "error",
  18200. "waiting"
  18201. ]);
  18202. eventNames.forEach((eventName) => {
  18203. audio.addEventListener(
  18204. eventName.toLowerCase(),
  18205. () => {
  18206. if (this._stoping && stopEventNames.indexOf(eventName) >= 0) {
  18207. return;
  18208. }
  18209. const EventName = `on${eventName.slice(0, 1).toUpperCase()}${eventName.slice(1)}`;
  18210. this._events[EventName].forEach((callback) => {
  18211. callback();
  18212. });
  18213. },
  18214. false
  18215. );
  18216. });
  18217. initInnerAudioContextEventOnce();
  18218. }
  18219. /**
  18220. * 播放
  18221. */
  18222. play() {
  18223. this._stoping = false;
  18224. this._audio.play();
  18225. }
  18226. /**
  18227. * 暂停
  18228. */
  18229. pause() {
  18230. this._audio.pause();
  18231. }
  18232. /**
  18233. * 停止
  18234. */
  18235. stop() {
  18236. this._stoping = true;
  18237. this._audio.pause();
  18238. this._audio.currentTime = 0;
  18239. this._events.onStop.forEach((callback) => {
  18240. callback();
  18241. });
  18242. }
  18243. /**
  18244. * 跳转到
  18245. * @param {number} position
  18246. */
  18247. seek(position) {
  18248. this._stoping = false;
  18249. position = Number(position);
  18250. if (typeof position === "number" && !isNaN(position)) {
  18251. this._audio.currentTime = position;
  18252. }
  18253. }
  18254. /**
  18255. * 销毁
  18256. */
  18257. destroy() {
  18258. this.stop();
  18259. }
  18260. }
  18261. const createInnerAudioContext = /* @__PURE__ */ defineSyncApi(
  18262. API_CREATE_INNER_AUDIO_CONTEXT,
  18263. () => {
  18264. return new InnerAudioContext();
  18265. }
  18266. );
  18267. const makePhoneCall = /* @__PURE__ */ defineAsyncApi(
  18268. API_MAKE_PHONE_CALL,
  18269. ({ phoneNumber }, { resolve }) => {
  18270. window.location.href = `tel:${phoneNumber}`;
  18271. return resolve();
  18272. },
  18273. MakePhoneCallProtocol
  18274. );
  18275. const UUID_KEY = "__DC_STAT_UUID";
  18276. const storage = navigator.cookieEnabled && (window.localStorage || window.sessionStorage) || {};
  18277. let deviceId;
  18278. function deviceId$1() {
  18279. deviceId = deviceId || storage[UUID_KEY];
  18280. if (!deviceId) {
  18281. deviceId = Date.now() + "" + Math.floor(Math.random() * 1e7);
  18282. try {
  18283. storage[UUID_KEY] = deviceId;
  18284. } catch (error) {
  18285. }
  18286. }
  18287. return deviceId;
  18288. }
  18289. function IEVersion() {
  18290. const userAgent = navigator.userAgent;
  18291. const isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1;
  18292. const isEdge = userAgent.indexOf("Edge") > -1 && !isIE;
  18293. const isIE11 = userAgent.indexOf("Trident") > -1 && userAgent.indexOf("rv:11.0") > -1;
  18294. if (isIE) {
  18295. const reIE = new RegExp("MSIE (\\d+\\.\\d+);");
  18296. reIE.test(userAgent);
  18297. const fIEVersion = parseFloat(RegExp.$1);
  18298. if (fIEVersion > 6) {
  18299. return fIEVersion;
  18300. } else {
  18301. return 6;
  18302. }
  18303. } else if (isEdge) {
  18304. return -1;
  18305. } else if (isIE11) {
  18306. return 11;
  18307. } else {
  18308. return -1;
  18309. }
  18310. }
  18311. function getTheme() {
  18312. if (__uniConfig.darkmode !== true)
  18313. return isString(__uniConfig.darkmode) ? __uniConfig.darkmode : "light";
  18314. try {
  18315. return window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
  18316. } catch (error) {
  18317. return "light";
  18318. }
  18319. }
  18320. function getBrowserInfo() {
  18321. let osname;
  18322. let osversion = "0";
  18323. let model = "";
  18324. let deviceType = "phone";
  18325. const language = navigator.language;
  18326. if (isIOS$1) {
  18327. osname = "iOS";
  18328. const osversionFind = ua.match(/OS\s([\w_]+)\slike/);
  18329. if (osversionFind) {
  18330. osversion = osversionFind[1].replace(/_/g, ".");
  18331. }
  18332. const modelFind = ua.match(/\(([a-zA-Z]+);/);
  18333. if (modelFind) {
  18334. model = modelFind[1];
  18335. }
  18336. } else if (isAndroid) {
  18337. osname = "Android";
  18338. const osversionFind = ua.match(/Android[\s/]([\w\.]+)[;\s]/);
  18339. if (osversionFind) {
  18340. osversion = osversionFind[1];
  18341. }
  18342. const infoFind = ua.match(/\((.+?)\)/);
  18343. const infos = infoFind ? infoFind[1].split(";") : ua.split(" ");
  18344. const otherInfo = [
  18345. /\bAndroid\b/i,
  18346. /\bLinux\b/i,
  18347. /\bU\b/i,
  18348. /^\s?[a-z][a-z]$/i,
  18349. /^\s?[a-z][a-z]-[a-z][a-z]$/i,
  18350. /\bwv\b/i,
  18351. /\/[\d\.,]+$/,
  18352. /^\s?[\d\.,]+$/,
  18353. /\bBrowser\b/i,
  18354. /\bMobile\b/i
  18355. ];
  18356. for (let i = 0; i < infos.length; i++) {
  18357. const info = infos[i];
  18358. if (info.indexOf("Build") > 0) {
  18359. model = info.split("Build")[0].trim();
  18360. break;
  18361. }
  18362. let other;
  18363. for (let o2 = 0; o2 < otherInfo.length; o2++) {
  18364. if (otherInfo[o2].test(info)) {
  18365. other = true;
  18366. break;
  18367. }
  18368. }
  18369. if (!other) {
  18370. model = info.trim();
  18371. break;
  18372. }
  18373. }
  18374. } else if (isIPadOS) {
  18375. model = "iPad";
  18376. osname = "iOS";
  18377. deviceType = "pad";
  18378. osversion = isFunction(window.BigInt) ? "14.0" : "13.0";
  18379. } else if (isWindows || isMac || isLinux) {
  18380. model = "PC";
  18381. osname = "PC";
  18382. deviceType = "pc";
  18383. osversion = "0";
  18384. let osversionFind = ua.match(/\((.+?)\)/)[1];
  18385. if (isWindows) {
  18386. osname = "Windows";
  18387. switch (isWindows[1]) {
  18388. case "5.1":
  18389. osversion = "XP";
  18390. break;
  18391. case "6.0":
  18392. osversion = "Vista";
  18393. break;
  18394. case "6.1":
  18395. osversion = "7";
  18396. break;
  18397. case "6.2":
  18398. osversion = "8";
  18399. break;
  18400. case "6.3":
  18401. osversion = "8.1";
  18402. break;
  18403. case "10.0":
  18404. osversion = "10";
  18405. break;
  18406. }
  18407. const framework = osversionFind && osversionFind.match(/[Win|WOW]([\d]+)/);
  18408. if (framework) {
  18409. osversion += ` x${framework[1]}`;
  18410. }
  18411. } else if (isMac) {
  18412. osname = "macOS";
  18413. const _osversion = osversionFind && osversionFind.match(/Mac OS X (.+)/) || "";
  18414. if (osversion) {
  18415. osversion = _osversion[1].replace(/_/g, ".");
  18416. if (osversion.indexOf(";") !== -1) {
  18417. osversion = osversion.split(";")[0];
  18418. }
  18419. }
  18420. } else if (isLinux) {
  18421. osname = "Linux";
  18422. const _osversion = osversionFind && osversionFind.match(/Linux (.*)/) || "";
  18423. if (_osversion) {
  18424. osversion = _osversion[1];
  18425. if (osversion.indexOf(";") !== -1) {
  18426. osversion = osversion.split(";")[0];
  18427. }
  18428. }
  18429. }
  18430. } else {
  18431. osname = "Other";
  18432. osversion = "0";
  18433. deviceType = "unknown";
  18434. }
  18435. const system = `${osname} ${osversion}`;
  18436. const platform = osname.toLocaleLowerCase();
  18437. let browserName = "";
  18438. let browserVersion = String(IEVersion());
  18439. if (browserVersion !== "-1") {
  18440. browserName = "IE";
  18441. } else {
  18442. const browseVendors = ["Version", "Firefox", "Chrome", "Edge{0,1}"];
  18443. const vendors = ["Safari", "Firefox", "Chrome", "Edge"];
  18444. for (let index2 = 0; index2 < browseVendors.length; index2++) {
  18445. const vendor = browseVendors[index2];
  18446. const reg = new RegExp(`(${vendor})/(\\S*)\\b`);
  18447. if (reg.test(ua)) {
  18448. browserName = vendors[index2];
  18449. browserVersion = ua.match(reg)[2];
  18450. }
  18451. }
  18452. }
  18453. let deviceOrientation = "portrait";
  18454. const orientation = typeof window.screen.orientation === "undefined" ? window.orientation : window.screen.orientation.angle;
  18455. deviceOrientation = Math.abs(orientation) === 90 ? "landscape" : "portrait";
  18456. return {
  18457. deviceBrand: void 0,
  18458. brand: void 0,
  18459. deviceModel: model,
  18460. deviceOrientation,
  18461. model,
  18462. system,
  18463. platform,
  18464. browserName: browserName.toLocaleLowerCase(),
  18465. browserVersion,
  18466. language,
  18467. deviceType,
  18468. ua,
  18469. osname,
  18470. osversion,
  18471. theme: getTheme()
  18472. };
  18473. }
  18474. const getWindowInfo = /* @__PURE__ */ defineSyncApi(
  18475. "getWindowInfo",
  18476. () => {
  18477. const pixelRatio2 = window.devicePixelRatio;
  18478. const screenFix = getScreenFix();
  18479. const landscape = isLandscape(screenFix);
  18480. const screenWidth = getScreenWidth(screenFix, landscape);
  18481. const screenHeight = getScreenHeight(screenFix, landscape);
  18482. const windowWidth = getWindowWidth(screenWidth);
  18483. let windowHeight = window.innerHeight;
  18484. const statusBarHeight = safeAreaInsets$1.top;
  18485. const safeArea = {
  18486. left: safeAreaInsets$1.left,
  18487. right: windowWidth - safeAreaInsets$1.right,
  18488. top: safeAreaInsets$1.top,
  18489. bottom: windowHeight - safeAreaInsets$1.bottom,
  18490. width: windowWidth - safeAreaInsets$1.left - safeAreaInsets$1.right,
  18491. height: windowHeight - safeAreaInsets$1.top - safeAreaInsets$1.bottom
  18492. };
  18493. const { top: windowTop, bottom: windowBottom } = getWindowOffset();
  18494. windowHeight -= windowTop;
  18495. windowHeight -= windowBottom;
  18496. return {
  18497. windowTop,
  18498. windowBottom,
  18499. windowWidth,
  18500. windowHeight,
  18501. pixelRatio: pixelRatio2,
  18502. screenWidth,
  18503. screenHeight,
  18504. statusBarHeight,
  18505. safeArea,
  18506. safeAreaInsets: {
  18507. top: safeAreaInsets$1.top,
  18508. right: safeAreaInsets$1.right,
  18509. bottom: safeAreaInsets$1.bottom,
  18510. left: safeAreaInsets$1.left
  18511. },
  18512. screenTop: screenHeight - windowHeight
  18513. };
  18514. }
  18515. );
  18516. let browserInfo;
  18517. let _initBrowserInfo = true;
  18518. function initBrowserInfo() {
  18519. if (!_initBrowserInfo)
  18520. return;
  18521. browserInfo = getBrowserInfo();
  18522. }
  18523. const getDeviceInfo = /* @__PURE__ */ defineSyncApi(
  18524. "getDeviceInfo",
  18525. () => {
  18526. initBrowserInfo();
  18527. const {
  18528. deviceBrand,
  18529. deviceModel,
  18530. brand,
  18531. model,
  18532. platform,
  18533. system,
  18534. deviceOrientation,
  18535. deviceType
  18536. } = browserInfo;
  18537. return {
  18538. brand,
  18539. deviceBrand,
  18540. deviceModel,
  18541. devicePixelRatio: window.devicePixelRatio,
  18542. deviceId: deviceId$1(),
  18543. deviceOrientation,
  18544. deviceType,
  18545. model,
  18546. platform,
  18547. system
  18548. };
  18549. }
  18550. );
  18551. const getAppBaseInfo = /* @__PURE__ */ defineSyncApi(
  18552. "getAppBaseInfo",
  18553. () => {
  18554. initBrowserInfo();
  18555. const { theme, language, browserName, browserVersion } = browserInfo;
  18556. return {
  18557. appId: __uniConfig.appId,
  18558. appName: __uniConfig.appName,
  18559. appVersion: __uniConfig.appVersion,
  18560. appVersionCode: __uniConfig.appVersionCode,
  18561. appLanguage: getLocale ? getLocale() : language,
  18562. enableDebug: false,
  18563. hostSDKVersion: void 0,
  18564. hostPackageName: void 0,
  18565. hostFontSizeSetting: void 0,
  18566. hostName: browserName,
  18567. hostVersion: browserVersion,
  18568. hostTheme: theme,
  18569. hostLanguage: language,
  18570. language,
  18571. SDKVersion: "",
  18572. theme,
  18573. version: ""
  18574. };
  18575. }
  18576. );
  18577. const getSystemInfoSync = /* @__PURE__ */ defineSyncApi(
  18578. "getSystemInfoSync",
  18579. () => {
  18580. _initBrowserInfo = true;
  18581. initBrowserInfo();
  18582. _initBrowserInfo = false;
  18583. const windowInfo = getWindowInfo();
  18584. const deviceInfo = getDeviceInfo();
  18585. const appBaseInfo = getAppBaseInfo();
  18586. _initBrowserInfo = true;
  18587. const { ua: ua2, browserName, browserVersion, osname, osversion } = browserInfo;
  18588. const systemInfo = extend(
  18589. windowInfo,
  18590. deviceInfo,
  18591. appBaseInfo,
  18592. {
  18593. ua: ua2,
  18594. browserName,
  18595. browserVersion,
  18596. uniPlatform: "web",
  18597. uniCompileVersion: __uniConfig.compilerVersion,
  18598. uniRuntimeVersion: __uniConfig.compilerVersion,
  18599. fontSizeSetting: void 0,
  18600. osName: osname.toLocaleLowerCase(),
  18601. osVersion: osversion,
  18602. osLanguage: void 0,
  18603. osTheme: void 0
  18604. }
  18605. );
  18606. delete systemInfo.screenTop;
  18607. delete systemInfo.enableDebug;
  18608. if (!__uniConfig.darkmode)
  18609. delete systemInfo.theme;
  18610. return sortObject(systemInfo);
  18611. }
  18612. );
  18613. const getSystemInfo = /* @__PURE__ */ defineAsyncApi(
  18614. "getSystemInfo",
  18615. (_args, { resolve }) => {
  18616. return resolve(getSystemInfoSync());
  18617. }
  18618. );
  18619. const API_ON_NETWORK_STATUS_CHANGE = "onNetworkStatusChange";
  18620. function networkListener() {
  18621. getNetworkType().then(({ networkType }) => {
  18622. UniServiceJSBridge.invokeOnCallback(
  18623. API_ON_NETWORK_STATUS_CHANGE,
  18624. {
  18625. isConnected: networkType !== "none",
  18626. networkType
  18627. }
  18628. );
  18629. });
  18630. }
  18631. function getConnection() {
  18632. return navigator.connection || navigator.webkitConnection || navigator.mozConnection;
  18633. }
  18634. const onNetworkStatusChange = /* @__PURE__ */ defineOnApi(
  18635. API_ON_NETWORK_STATUS_CHANGE,
  18636. () => {
  18637. const connection = getConnection();
  18638. if (connection) {
  18639. connection.addEventListener("change", networkListener);
  18640. } else {
  18641. window.addEventListener("offline", networkListener);
  18642. window.addEventListener("online", networkListener);
  18643. }
  18644. }
  18645. );
  18646. const offNetworkStatusChange = /* @__PURE__ */ defineOffApi("offNetworkStatusChange", () => {
  18647. const connection = getConnection();
  18648. if (connection) {
  18649. connection.removeEventListener("change", networkListener);
  18650. } else {
  18651. window.removeEventListener("offline", networkListener);
  18652. window.removeEventListener("online", networkListener);
  18653. }
  18654. });
  18655. const getNetworkType = /* @__PURE__ */ defineAsyncApi(
  18656. "getNetworkType",
  18657. (_args, { resolve }) => {
  18658. const connection = getConnection();
  18659. let networkType = "unknown";
  18660. if (connection) {
  18661. networkType = connection.type;
  18662. if (networkType === "cellular" && connection.effectiveType) {
  18663. networkType = connection.effectiveType.replace("slow-", "");
  18664. } else if (!networkType && connection.effectiveType) {
  18665. networkType = connection.effectiveType;
  18666. } else if (!["none", "wifi"].includes(networkType)) {
  18667. networkType = "unknown";
  18668. }
  18669. } else if (navigator.onLine === false) {
  18670. networkType = "none";
  18671. }
  18672. return resolve({ networkType });
  18673. }
  18674. );
  18675. let listener$1 = null;
  18676. const onAccelerometerChange = /* @__PURE__ */ defineOnApi(API_ON_ACCELEROMETER, () => {
  18677. startAccelerometer();
  18678. });
  18679. const offAccelerometerChange = /* @__PURE__ */ defineOffApi(API_OFF_ACCELEROMETER, () => {
  18680. stopAccelerometer();
  18681. });
  18682. const startAccelerometer = /* @__PURE__ */ defineAsyncApi(
  18683. API_START_ACCELEROMETER,
  18684. (_, { resolve, reject }) => {
  18685. if (!window.DeviceMotionEvent) {
  18686. reject();
  18687. return;
  18688. }
  18689. function addEventListener() {
  18690. listener$1 = function(event) {
  18691. const acceleration = event.acceleration || event.accelerationIncludingGravity;
  18692. UniServiceJSBridge.invokeOnCallback(API_ON_ACCELEROMETER, {
  18693. x: acceleration && acceleration.x || 0,
  18694. y: acceleration && acceleration.y || 0,
  18695. z: acceleration && acceleration.z || 0
  18696. });
  18697. };
  18698. window.addEventListener("devicemotion", listener$1, false);
  18699. }
  18700. if (!listener$1) {
  18701. if (DeviceMotionEvent.requestPermission) {
  18702. DeviceMotionEvent.requestPermission().then((res) => {
  18703. if (res === "granted") {
  18704. addEventListener();
  18705. resolve();
  18706. } else {
  18707. reject(`${res}`);
  18708. }
  18709. }).catch((error) => {
  18710. reject(`${error}`);
  18711. });
  18712. return;
  18713. }
  18714. addEventListener();
  18715. }
  18716. resolve();
  18717. }
  18718. );
  18719. const stopAccelerometer = /* @__PURE__ */ defineAsyncApi(
  18720. API_STOP_ACCELEROMETER,
  18721. (_, { resolve }) => {
  18722. if (listener$1) {
  18723. window.removeEventListener("devicemotion", listener$1, false);
  18724. listener$1 = null;
  18725. }
  18726. resolve();
  18727. }
  18728. );
  18729. let listener = null;
  18730. const onCompassChange = /* @__PURE__ */ defineOnApi(
  18731. API_ON_COMPASS,
  18732. () => {
  18733. startCompass();
  18734. }
  18735. );
  18736. const offCompassChange = /* @__PURE__ */ defineOffApi(
  18737. API_OFF_COMPASS,
  18738. () => {
  18739. stopCompass();
  18740. }
  18741. );
  18742. const startCompass = /* @__PURE__ */ defineAsyncApi(
  18743. API_START_COMPASS,
  18744. (_, { resolve, reject }) => {
  18745. if (!window.DeviceOrientationEvent) {
  18746. reject();
  18747. return;
  18748. }
  18749. function addEventListener() {
  18750. listener = function(event) {
  18751. const direction2 = 360 - (event.alpha !== null ? event.alpha : 360);
  18752. UniServiceJSBridge.invokeOnCallback(API_ON_COMPASS, {
  18753. direction: direction2
  18754. });
  18755. };
  18756. window.addEventListener("deviceorientation", listener, false);
  18757. }
  18758. if (!listener) {
  18759. if (DeviceOrientationEvent.requestPermission) {
  18760. DeviceOrientationEvent.requestPermission().then((res) => {
  18761. if (res === "granted") {
  18762. addEventListener();
  18763. resolve();
  18764. } else {
  18765. reject(`${res}`);
  18766. }
  18767. }).catch((error) => {
  18768. reject(`${error}`);
  18769. });
  18770. return;
  18771. }
  18772. addEventListener();
  18773. }
  18774. resolve();
  18775. }
  18776. );
  18777. const stopCompass = /* @__PURE__ */ defineAsyncApi(
  18778. API_STOP_COMPASS,
  18779. (_, { resolve }) => {
  18780. if (listener) {
  18781. window.removeEventListener("deviceorientation", listener, false);
  18782. listener = null;
  18783. }
  18784. resolve();
  18785. }
  18786. );
  18787. const _isSupport = !!window.navigator.vibrate;
  18788. const vibrateShort = /* @__PURE__ */ defineAsyncApi(
  18789. API_VIBRATE_SHORT,
  18790. (args, { resolve, reject }) => {
  18791. if (_isSupport && window.navigator.vibrate(15)) {
  18792. resolve();
  18793. } else {
  18794. reject("vibrateLong:fail");
  18795. }
  18796. }
  18797. );
  18798. const vibrateLong = /* @__PURE__ */ defineAsyncApi(
  18799. API_VIBRATE_LONG,
  18800. (args, { resolve, reject }) => {
  18801. if (_isSupport && window.navigator.vibrate(400)) {
  18802. resolve();
  18803. } else {
  18804. reject("vibrateLong:fail");
  18805. }
  18806. }
  18807. );
  18808. var __async = (__this, __arguments, generator) => {
  18809. return new Promise((resolve, reject) => {
  18810. var fulfilled = (value) => {
  18811. try {
  18812. step(generator.next(value));
  18813. } catch (e2) {
  18814. reject(e2);
  18815. }
  18816. };
  18817. var rejected = (value) => {
  18818. try {
  18819. step(generator.throw(value));
  18820. } catch (e2) {
  18821. reject(e2);
  18822. }
  18823. };
  18824. var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
  18825. step((generator = generator.apply(__this, __arguments)).next());
  18826. });
  18827. };
  18828. const getClipboardData = /* @__PURE__ */ defineAsyncApi(
  18829. API_GET_CLIPBOARD_DATA,
  18830. (_0, _1) => __async(void 0, [_0, _1], function* (_, { resolve, reject }) {
  18831. initI18nGetClipboardDataMsgsOnce();
  18832. const { t: t2 } = useI18n();
  18833. try {
  18834. const data = yield navigator.clipboard.readText();
  18835. resolve({ data });
  18836. } catch (error) {
  18837. _getClipboardData(resolve, () => {
  18838. reject(`${error} ${t2("uni.getClipboardData.fail")}`);
  18839. });
  18840. }
  18841. })
  18842. );
  18843. const setClipboardData = /* @__PURE__ */ defineAsyncApi(
  18844. API_SET_CLIPBOARD_DATA,
  18845. (_0, _1) => __async(void 0, [_0, _1], function* ({ data }, { resolve, reject }) {
  18846. try {
  18847. yield navigator.clipboard.writeText(data);
  18848. resolve();
  18849. } catch (error) {
  18850. _setClipboardData(data, resolve, reject);
  18851. }
  18852. }),
  18853. SetClipboardDataProtocol,
  18854. SetClipboardDataOptions
  18855. );
  18856. function _getClipboardData(resolve, reject) {
  18857. const pasteText = document.getElementById("#clipboard");
  18858. const data = pasteText ? pasteText.value : void 0;
  18859. if (data) {
  18860. resolve({ data });
  18861. } else {
  18862. reject();
  18863. }
  18864. }
  18865. function _setClipboardData(data, resolve, reject) {
  18866. const pasteText = document.getElementById("#clipboard");
  18867. pasteText && pasteText.remove();
  18868. const textarea = document.createElement("textarea");
  18869. textarea.id = "#clipboard";
  18870. textarea.style.position = "fixed";
  18871. textarea.style.top = "-9999px";
  18872. textarea.style.zIndex = "-9999";
  18873. document.body.appendChild(textarea);
  18874. textarea.value = data;
  18875. textarea.select();
  18876. textarea.setSelectionRange(0, textarea.value.length);
  18877. const result = document.execCommand("Copy", false);
  18878. textarea.blur();
  18879. if (result) {
  18880. resolve();
  18881. } else {
  18882. reject();
  18883. }
  18884. }
  18885. const themeChangeCallBack = (res) => {
  18886. UniServiceJSBridge.invokeOnCallback(ON_THEME_CHANGE, res);
  18887. };
  18888. const onThemeChange$1 = /* @__PURE__ */ defineOnApi(
  18889. ON_THEME_CHANGE,
  18890. () => {
  18891. UniServiceJSBridge.on(ON_THEME_CHANGE, themeChangeCallBack);
  18892. }
  18893. );
  18894. const offThemeChange$1 = /* @__PURE__ */ defineOffApi(
  18895. OFF_THEME_CHANGE,
  18896. () => {
  18897. UniServiceJSBridge.off(ON_THEME_CHANGE, themeChangeCallBack);
  18898. }
  18899. );
  18900. const STORAGE_KEYS = "uni-storage-keys";
  18901. function parseValue(value) {
  18902. const types = ["object", "string", "number", "boolean", "undefined"];
  18903. try {
  18904. const object = isString(value) ? JSON.parse(value) : value;
  18905. const type = object.type;
  18906. if (types.indexOf(type) >= 0) {
  18907. const keys = Object.keys(object);
  18908. if (keys.length === 2 && "data" in object) {
  18909. if (typeof object.data === type) {
  18910. return object.data;
  18911. }
  18912. if (type === "object" && /^\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}\.\d{3}Z$/.test(object.data)) {
  18913. return new Date(object.data);
  18914. }
  18915. } else if (keys.length === 1) {
  18916. return "";
  18917. }
  18918. }
  18919. } catch (error) {
  18920. }
  18921. }
  18922. const setStorageSync = /* @__PURE__ */ defineSyncApi(
  18923. API_SET_STORAGE_SYNC,
  18924. (key, data) => {
  18925. const type = typeof data;
  18926. const value = type === "string" ? data : JSON.stringify({
  18927. type,
  18928. data
  18929. });
  18930. localStorage.setItem(key, value);
  18931. },
  18932. SetStorageSyncProtocol
  18933. );
  18934. const setStorage = /* @__PURE__ */ defineAsyncApi(
  18935. API_SET_STORAGE,
  18936. ({ key, data }, { resolve, reject }) => {
  18937. try {
  18938. setStorageSync(key, data);
  18939. resolve();
  18940. } catch (error) {
  18941. reject(error.message);
  18942. }
  18943. },
  18944. SetStorageProtocol
  18945. );
  18946. function getStorageOrigin(key) {
  18947. const value = localStorage && localStorage.getItem(key);
  18948. if (!isString(value)) {
  18949. throw new Error("data not found");
  18950. }
  18951. let data = value;
  18952. try {
  18953. const object = JSON.parse(value);
  18954. const result = parseValue(object);
  18955. if (result !== void 0) {
  18956. data = result;
  18957. }
  18958. } catch (error) {
  18959. }
  18960. return data;
  18961. }
  18962. const getStorageSync = /* @__PURE__ */ defineSyncApi(
  18963. API_GET_STORAGE_SYNC,
  18964. (key) => {
  18965. try {
  18966. return getStorageOrigin(key);
  18967. } catch (error) {
  18968. return "";
  18969. }
  18970. },
  18971. GetStorageSyncProtocol
  18972. );
  18973. const getStorage = /* @__PURE__ */ defineAsyncApi(
  18974. API_GET_STORAGE,
  18975. ({ key }, { resolve, reject }) => {
  18976. try {
  18977. const data = getStorageOrigin(key);
  18978. resolve({
  18979. data
  18980. });
  18981. } catch (error) {
  18982. reject(error.message);
  18983. }
  18984. },
  18985. GetStorageProtocol
  18986. );
  18987. const removeStorageSync = /* @__PURE__ */ defineSyncApi(
  18988. API_REMOVE_STORAGE,
  18989. (key) => {
  18990. if (localStorage) {
  18991. localStorage.removeItem(key);
  18992. }
  18993. },
  18994. RemoveStorageSyncProtocol
  18995. );
  18996. const removeStorage = /* @__PURE__ */ defineAsyncApi(
  18997. API_REMOVE_STORAGE,
  18998. ({ key }, { resolve }) => {
  18999. removeStorageSync(key);
  19000. resolve();
  19001. },
  19002. RemoveStorageProtocol
  19003. );
  19004. const clearStorageSync = /* @__PURE__ */ defineSyncApi(
  19005. "clearStorageSync",
  19006. () => {
  19007. if (localStorage) {
  19008. localStorage.clear();
  19009. }
  19010. }
  19011. );
  19012. const clearStorage = /* @__PURE__ */ defineAsyncApi(
  19013. "clearStorage",
  19014. (_, { resolve }) => {
  19015. clearStorageSync();
  19016. resolve();
  19017. }
  19018. );
  19019. const getStorageInfoSync = /* @__PURE__ */ defineSyncApi(
  19020. "getStorageInfoSync",
  19021. () => {
  19022. const length = localStorage && localStorage.length || 0;
  19023. const keys = [];
  19024. let currentSize = 0;
  19025. for (let index2 = 0; index2 < length; index2++) {
  19026. const key = localStorage.key(index2);
  19027. const value = localStorage.getItem(key) || "";
  19028. currentSize += key.length + value.length;
  19029. if (key !== STORAGE_KEYS) {
  19030. keys.push(key);
  19031. }
  19032. }
  19033. return {
  19034. keys,
  19035. currentSize: Math.ceil(currentSize * 2 / 1024),
  19036. limitSize: Number.MAX_VALUE
  19037. };
  19038. }
  19039. );
  19040. const getStorageInfo = /* @__PURE__ */ defineAsyncApi(
  19041. "getStorageInfo",
  19042. (_, { resolve }) => {
  19043. resolve(getStorageInfoSync());
  19044. }
  19045. );
  19046. const getFileInfo = /* @__PURE__ */ defineAsyncApi(
  19047. API_GET_FILE_INFO,
  19048. ({ filePath }, { resolve, reject }) => {
  19049. urlToFile(filePath).then((res) => {
  19050. resolve({
  19051. size: res.size
  19052. });
  19053. }).catch((err) => {
  19054. reject(String(err));
  19055. });
  19056. },
  19057. GetFileInfoProtocol,
  19058. GetFileInfoOptions
  19059. );
  19060. const openDocument = /* @__PURE__ */ defineAsyncApi(
  19061. API_OPEN_DOCUMENT,
  19062. ({ filePath }, { resolve }) => {
  19063. window.open(filePath);
  19064. return resolve();
  19065. },
  19066. OpenDocumentProtocol,
  19067. OpenDocumentOptions
  19068. );
  19069. const hideKeyboard = /* @__PURE__ */ defineAsyncApi(
  19070. API_HIDE_KEYBOARD,
  19071. (args, { resolve, reject }) => {
  19072. const activeElement = document.activeElement;
  19073. if (activeElement && (activeElement.tagName === "TEXTAREA" || activeElement.tagName === "INPUT")) {
  19074. activeElement.blur();
  19075. resolve();
  19076. }
  19077. }
  19078. );
  19079. function getServiceAddress() {
  19080. return window.location.protocol + "//" + window.location.host;
  19081. }
  19082. const getImageInfo = /* @__PURE__ */ defineAsyncApi(
  19083. API_GET_IMAGE_INFO,
  19084. ({ src }, { resolve, reject }) => {
  19085. const img = new Image();
  19086. img.onload = function() {
  19087. resolve({
  19088. width: img.naturalWidth,
  19089. height: img.naturalHeight,
  19090. path: src.indexOf("/") === 0 ? getServiceAddress() + src : src
  19091. });
  19092. };
  19093. img.onerror = function() {
  19094. reject();
  19095. };
  19096. img.src = src;
  19097. },
  19098. GetImageInfoProtocol,
  19099. GetImageInfoOptions
  19100. );
  19101. const getVideoInfo = /* @__PURE__ */ defineAsyncApi(
  19102. API_GET_VIDEO_INFO,
  19103. ({ src }, { resolve, reject }) => {
  19104. urlToFile(src, true).then((file) => {
  19105. return file;
  19106. }).catch(() => {
  19107. return null;
  19108. }).then((file) => {
  19109. const video = document.createElement("video");
  19110. if (video.onloadedmetadata !== void 0) {
  19111. const handle = setTimeout(
  19112. () => {
  19113. video.onloadedmetadata = null;
  19114. video.onerror = null;
  19115. reject();
  19116. },
  19117. src.startsWith("data:") || src.startsWith("blob:") ? 300 : 3e3
  19118. );
  19119. video.onloadedmetadata = function() {
  19120. clearTimeout(handle);
  19121. video.onerror = null;
  19122. resolve({
  19123. size: file ? file.size : 0,
  19124. duration: video.duration || 0,
  19125. width: video.videoWidth || 0,
  19126. height: video.videoHeight || 0
  19127. });
  19128. };
  19129. video.onerror = function() {
  19130. clearTimeout(handle);
  19131. video.onloadedmetadata = null;
  19132. reject();
  19133. };
  19134. video.src = src;
  19135. } else {
  19136. reject();
  19137. }
  19138. });
  19139. },
  19140. GetVideoInfoProtocol,
  19141. GetVideoInfoOptions
  19142. );
  19143. const MIMEType = {
  19144. /**
  19145. * 关于图片常见的MIME类型
  19146. */
  19147. image: {
  19148. jpg: "jpeg",
  19149. jpe: "jpeg",
  19150. pbm: "x-portable-bitmap",
  19151. pgm: "x-portable-graymap",
  19152. pnm: "x-portable-anymap",
  19153. ppm: "x-portable-pixmap",
  19154. psd: "vnd.adobe.photoshop",
  19155. pic: "x-pict",
  19156. rgb: "x-rgb",
  19157. svg: "svg+xml",
  19158. svgz: "svg+xml",
  19159. tif: "tiff",
  19160. xif: "vnd.xiff",
  19161. wbmp: "vnd.wap.wbmp",
  19162. wdp: "vnd.ms-photo",
  19163. xbm: "x-xbitmap",
  19164. ico: "x-icon"
  19165. },
  19166. /**
  19167. * 关于视频常见的MIME类型
  19168. */
  19169. video: {
  19170. "3g2": "3gpp2",
  19171. "3gp": "3gpp",
  19172. avi: "x-msvideo",
  19173. f4v: "x-f4v",
  19174. flv: "x-flv",
  19175. jpgm: "jpm",
  19176. jpgv: "jpeg",
  19177. m1v: "mpeg",
  19178. m2v: "mpeg",
  19179. mpe: "mpeg",
  19180. mpg: "mpeg",
  19181. mpg4: "mpeg",
  19182. m4v: "x-m4v",
  19183. mkv: "x-matroska",
  19184. mov: "quicktime",
  19185. qt: "quicktime",
  19186. movie: "x-sgi-movie",
  19187. mp4v: "mp4",
  19188. ogv: "ogg",
  19189. smv: "x-smv",
  19190. wm: "x-ms-wm",
  19191. wmv: "x-ms-wmv",
  19192. wmx: "x-ms-wmx",
  19193. wvx: "x-ms-wvx"
  19194. }
  19195. };
  19196. const MIMEType$1 = MIMEType;
  19197. const ALL = "all";
  19198. addInteractListener();
  19199. function isWXEnv() {
  19200. const ua2 = window.navigator.userAgent.toLowerCase();
  19201. const matchUA = ua2.match(/MicroMessenger/i);
  19202. return !!(matchUA && matchUA[0] === "micromessenger");
  19203. }
  19204. function _createInput({
  19205. count,
  19206. sourceType,
  19207. type,
  19208. extension
  19209. }) {
  19210. const inputEl = document.createElement("input");
  19211. inputEl.type = "file";
  19212. updateElementStyle(inputEl, {
  19213. position: "absolute",
  19214. visibility: "hidden",
  19215. zIndex: "-999",
  19216. width: "0",
  19217. height: "0",
  19218. top: "0",
  19219. left: "0"
  19220. });
  19221. inputEl.accept = extension.map((item) => {
  19222. if (type !== ALL) {
  19223. const MIMEKey = item.replace(".", "");
  19224. return `${type}/${MIMEType$1[type][MIMEKey] || MIMEKey}`;
  19225. } else {
  19226. if (isWXEnv()) {
  19227. return ".";
  19228. }
  19229. return item.indexOf(".") === 0 ? item : `.${item}`;
  19230. }
  19231. }).join(",");
  19232. if (count && count > 1) {
  19233. inputEl.multiple = true;
  19234. }
  19235. if (type !== ALL && sourceType instanceof Array && sourceType.length === 1 && sourceType[0] === "camera") {
  19236. inputEl.setAttribute("capture", "camera");
  19237. }
  19238. return inputEl;
  19239. }
  19240. let fileInput = null;
  19241. const chooseFile = /* @__PURE__ */ defineAsyncApi(
  19242. API_CHOOSE_FILE,
  19243. ({
  19244. // sizeType,
  19245. count,
  19246. sourceType,
  19247. type,
  19248. extension
  19249. }, { resolve, reject }) => {
  19250. initI18nChooseFileMsgsOnce();
  19251. const { t: t2 } = useI18n();
  19252. if (fileInput) {
  19253. document.body.removeChild(fileInput);
  19254. fileInput = null;
  19255. }
  19256. fileInput = _createInput({
  19257. count,
  19258. sourceType,
  19259. type,
  19260. extension
  19261. });
  19262. document.body.appendChild(fileInput);
  19263. fileInput.addEventListener("change", function(event) {
  19264. const eventTarget = event.target;
  19265. const tempFiles = [];
  19266. if (eventTarget && eventTarget.files) {
  19267. const fileCount = eventTarget.files.length;
  19268. for (let i = 0; i < fileCount; i++) {
  19269. const file = eventTarget.files[i];
  19270. let filePath;
  19271. Object.defineProperty(file, "path", {
  19272. get() {
  19273. filePath = filePath || fileToUrl(file);
  19274. return filePath;
  19275. }
  19276. });
  19277. if (i < count)
  19278. tempFiles.push(file);
  19279. }
  19280. }
  19281. const res = {
  19282. get tempFilePaths() {
  19283. return tempFiles.map(({ path }) => path);
  19284. },
  19285. tempFiles
  19286. };
  19287. resolve(res);
  19288. });
  19289. fileInput.click();
  19290. if (!getInteractStatus()) {
  19291. console.warn(t2("uni.chooseFile.notUserActivation"));
  19292. }
  19293. },
  19294. ChooseFileProtocol,
  19295. ChooseFileOptions
  19296. );
  19297. let imageInput = null;
  19298. const chooseImage = /* @__PURE__ */ defineAsyncApi(
  19299. API_CHOOSE_IMAGE,
  19300. ({
  19301. count,
  19302. // sizeType,
  19303. sourceType,
  19304. extension
  19305. }, { resolve, reject }) => {
  19306. initI18nChooseFileMsgsOnce();
  19307. const { t: t2 } = useI18n();
  19308. if (imageInput) {
  19309. document.body.removeChild(imageInput);
  19310. imageInput = null;
  19311. }
  19312. imageInput = _createInput({
  19313. count,
  19314. sourceType,
  19315. extension,
  19316. type: "image"
  19317. });
  19318. document.body.appendChild(imageInput);
  19319. imageInput.addEventListener("change", function(event) {
  19320. const eventTarget = event.target;
  19321. const tempFiles = [];
  19322. if (eventTarget && eventTarget.files) {
  19323. const fileCount = eventTarget.files.length;
  19324. for (let i = 0; i < fileCount; i++) {
  19325. const file = eventTarget.files[i];
  19326. let filePath;
  19327. Object.defineProperty(file, "path", {
  19328. get() {
  19329. filePath = filePath || fileToUrl(file);
  19330. return filePath;
  19331. }
  19332. });
  19333. if (i < count)
  19334. tempFiles.push(file);
  19335. }
  19336. }
  19337. const res = {
  19338. get tempFilePaths() {
  19339. return tempFiles.map(({ path }) => path);
  19340. },
  19341. tempFiles
  19342. };
  19343. resolve(res);
  19344. });
  19345. imageInput.click();
  19346. if (!getInteractStatus()) {
  19347. console.warn(t2("uni.chooseFile.notUserActivation"));
  19348. }
  19349. },
  19350. ChooseImageProtocol,
  19351. ChooseImageOptions
  19352. );
  19353. const KEY_MAPS = {
  19354. esc: ["Esc", "Escape"],
  19355. // tab: ['Tab'],
  19356. enter: ["Enter"]
  19357. // space: [' ', 'Spacebar'],
  19358. // up: ['Up', 'ArrowUp'],
  19359. // left: ['Left', 'ArrowLeft'],
  19360. // right: ['Right', 'ArrowRight'],
  19361. // down: ['Down', 'ArrowDown'],
  19362. // delete: ['Backspace', 'Delete', 'Del'],
  19363. };
  19364. const KEYS = Object.keys(KEY_MAPS);
  19365. function useKeyboard() {
  19366. const key = ref("");
  19367. const disable = ref(false);
  19368. const onKeyup = (evt) => {
  19369. if (disable.value) {
  19370. return;
  19371. }
  19372. const res = KEYS.find(
  19373. (key2) => KEY_MAPS[key2].indexOf(evt.key) !== -1
  19374. );
  19375. if (res) {
  19376. key.value = res;
  19377. }
  19378. nextTick(() => key.value = "");
  19379. };
  19380. onMounted(() => {
  19381. document.addEventListener("keyup", onKeyup);
  19382. });
  19383. onBeforeUnmount(() => {
  19384. document.removeEventListener("keyup", onKeyup);
  19385. });
  19386. return {
  19387. key,
  19388. disable
  19389. };
  19390. }
  19391. const VNODE_MASK = /* @__PURE__ */ createVNode(
  19392. "div",
  19393. { class: "uni-mask" },
  19394. null,
  19395. -1
  19396. /* HOISTED */
  19397. );
  19398. function createRootApp(component, rootState, callback) {
  19399. rootState.onClose = (...args) => (rootState.visible = false, callback.apply(null, args));
  19400. return createApp(
  19401. defineComponent({
  19402. setup() {
  19403. return () => (openBlock(), createBlock(
  19404. component,
  19405. rootState,
  19406. null,
  19407. 16
  19408. /* FULL_PROPS */
  19409. ));
  19410. }
  19411. })
  19412. );
  19413. }
  19414. function ensureRoot(id2) {
  19415. let rootEl = document.getElementById(id2);
  19416. if (!rootEl) {
  19417. rootEl = document.createElement("div");
  19418. rootEl.id = id2;
  19419. document.body.append(rootEl);
  19420. }
  19421. return rootEl;
  19422. }
  19423. function usePopup(props2, {
  19424. onEsc,
  19425. onEnter
  19426. }) {
  19427. const visible = ref(props2.visible);
  19428. const { key, disable } = useKeyboard();
  19429. watch(
  19430. () => props2.visible,
  19431. (value) => visible.value = value
  19432. );
  19433. watch(
  19434. () => visible.value,
  19435. (value) => disable.value = !value
  19436. );
  19437. watchEffect(() => {
  19438. const { value } = key;
  19439. if (value === "esc") {
  19440. onEsc && onEsc();
  19441. } else if (value === "enter") {
  19442. onEnter && onEnter();
  19443. }
  19444. });
  19445. return visible;
  19446. }
  19447. let index$a = 0;
  19448. let overflow = "";
  19449. function preventScroll(prevent) {
  19450. let before = index$a;
  19451. index$a += prevent ? 1 : -1;
  19452. index$a = Math.max(0, index$a);
  19453. if (index$a > 0) {
  19454. if (before === 0) {
  19455. overflow = document.body.style.overflow;
  19456. document.body.style.overflow = "hidden";
  19457. }
  19458. } else {
  19459. document.body.style.overflow = overflow;
  19460. overflow = "";
  19461. }
  19462. }
  19463. function usePreventScroll() {
  19464. onMounted(() => preventScroll(true));
  19465. onUnmounted(() => preventScroll(false));
  19466. }
  19467. const props$a = {
  19468. src: {
  19469. type: String,
  19470. default: ""
  19471. }
  19472. };
  19473. const ImageView = /* @__PURE__ */ defineSystemComponent({
  19474. name: "ImageView",
  19475. props: props$a,
  19476. setup(props2) {
  19477. const state2 = reactive({
  19478. direction: "none"
  19479. });
  19480. let scale = 1;
  19481. let imgWidth = 0;
  19482. let imgHeight = 0;
  19483. let width = 0;
  19484. let height = 0;
  19485. function onScale({
  19486. detail
  19487. }) {
  19488. scale = detail.scale;
  19489. }
  19490. function onImgLoad(event) {
  19491. const target = event.target;
  19492. const rect = target.getBoundingClientRect();
  19493. imgWidth = rect.width;
  19494. imgHeight = rect.height;
  19495. }
  19496. function onTouchStart(event) {
  19497. const target = event.target;
  19498. const rect = target.getBoundingClientRect();
  19499. width = rect.width;
  19500. height = rect.height;
  19501. checkDirection(event);
  19502. }
  19503. function onTouchEnd(event) {
  19504. const horizontal = scale * imgWidth > width;
  19505. const vertical = scale * imgHeight > height;
  19506. if (horizontal && vertical) {
  19507. state2.direction = "all";
  19508. } else if (horizontal) {
  19509. state2.direction = "horizontal";
  19510. } else if (vertical) {
  19511. state2.direction = "vertical";
  19512. } else {
  19513. state2.direction = "none";
  19514. }
  19515. checkDirection(event);
  19516. }
  19517. function checkDirection(event) {
  19518. if (state2.direction === "all" || state2.direction === "horizontal") {
  19519. event.stopPropagation();
  19520. }
  19521. }
  19522. return () => {
  19523. const viewStyle = {
  19524. position: "absolute",
  19525. left: "0",
  19526. top: "0",
  19527. width: "100%",
  19528. height: "100%"
  19529. };
  19530. return createVNode(MovableArea, {
  19531. "style": viewStyle,
  19532. "onTouchstart": withWebEvent(onTouchStart),
  19533. "onTouchmove": withWebEvent(checkDirection),
  19534. "onTouchend": withWebEvent(onTouchEnd)
  19535. }, {
  19536. default: () => [createVNode(MovableView, {
  19537. "style": viewStyle,
  19538. "direction": state2.direction,
  19539. "inertia": true,
  19540. "scale": true,
  19541. "scale-min": "1",
  19542. "scale-max": "4",
  19543. "onScale": onScale
  19544. }, {
  19545. default: () => [createVNode("img", {
  19546. "src": props2.src,
  19547. "style": {
  19548. position: "absolute",
  19549. left: "50%",
  19550. top: "50%",
  19551. transform: "translate(-50%, -50%)",
  19552. maxHeight: "100%",
  19553. maxWidth: "100%"
  19554. },
  19555. "onLoad": onImgLoad
  19556. }, null, 40, ["src", "onLoad"])]
  19557. }, 8, ["style", "direction", "inertia", "scale", "onScale"])]
  19558. }, 8, ["style", "onTouchstart", "onTouchmove", "onTouchend"]);
  19559. };
  19560. }
  19561. });
  19562. function _isSlot$2(s) {
  19563. return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
  19564. }
  19565. const props$9 = {
  19566. urls: {
  19567. type: Array,
  19568. default() {
  19569. return [];
  19570. }
  19571. },
  19572. current: {
  19573. type: [Number, String],
  19574. default: 0
  19575. }
  19576. };
  19577. function getIndex(props2) {
  19578. let index2 = typeof props2.current === "number" ? props2.current : props2.urls.indexOf(props2.current);
  19579. index2 = index2 < 0 ? 0 : index2;
  19580. return index2;
  19581. }
  19582. const ImagePreview = /* @__PURE__ */ defineSystemComponent({
  19583. name: "ImagePreview",
  19584. props: props$9,
  19585. emits: ["close"],
  19586. setup(props2, {
  19587. emit: emit2
  19588. }) {
  19589. usePreventScroll();
  19590. const rootRef = ref(null);
  19591. const indexRef = ref(getIndex(props2));
  19592. watch(() => props2.current, () => indexRef.value = getIndex(props2));
  19593. let preventDefault;
  19594. onMounted(() => {
  19595. const el = rootRef.value;
  19596. const MAX_MOVE = 20;
  19597. let x = 0;
  19598. let y = 0;
  19599. el.addEventListener("mousedown", (event) => {
  19600. preventDefault = false;
  19601. x = event.clientX;
  19602. y = event.clientY;
  19603. });
  19604. el.addEventListener("mouseup", (event) => {
  19605. if (Math.abs(event.clientX - x) > MAX_MOVE || Math.abs(event.clientY - y) > MAX_MOVE) {
  19606. preventDefault = true;
  19607. }
  19608. });
  19609. });
  19610. function onClick() {
  19611. if (!preventDefault) {
  19612. nextTick(() => {
  19613. emit2("close");
  19614. });
  19615. }
  19616. }
  19617. function onChange2(event) {
  19618. indexRef.value = event.detail.current;
  19619. }
  19620. const closeBtnStyle = {
  19621. position: "absolute",
  19622. "box-sizing": "border-box",
  19623. top: "0",
  19624. right: "0",
  19625. width: "60px",
  19626. height: "44px",
  19627. padding: "6px",
  19628. "line-height": "32px",
  19629. "font-size": "26px",
  19630. color: "white",
  19631. "text-align": "center",
  19632. cursor: "pointer"
  19633. };
  19634. return () => {
  19635. let _slot;
  19636. return createVNode("div", {
  19637. "ref": rootRef,
  19638. "style": {
  19639. display: "block",
  19640. position: "fixed",
  19641. left: "0",
  19642. top: "0",
  19643. width: "100%",
  19644. height: "100%",
  19645. zIndex: 999,
  19646. background: "rgba(0,0,0,0.8)"
  19647. },
  19648. "onClick": onClick
  19649. }, [createVNode(Swiper, {
  19650. "navigation": "auto",
  19651. "current": indexRef.value,
  19652. "onChange": onChange2,
  19653. "indicator-dots": false,
  19654. "autoplay": false,
  19655. "style": {
  19656. position: "absolute",
  19657. left: "0",
  19658. top: "0",
  19659. width: "100%",
  19660. height: "100%"
  19661. }
  19662. }, _isSlot$2(_slot = props2.urls.map((src) => createVNode(SwiperItem, null, {
  19663. default: () => [createVNode(ImageView, {
  19664. "src": src
  19665. }, null, 8, ["src"])]
  19666. }))) ? _slot : {
  19667. default: () => [_slot],
  19668. _: 1
  19669. }, 8, ["current", "onChange"]), createVNode("div", {
  19670. "style": closeBtnStyle
  19671. }, [createSvgIconVNode(ICON_PATH_CLOSE, "#ffffff", 26)], 4)], 8, ["onClick"]);
  19672. };
  19673. }
  19674. });
  19675. let state$2 = null;
  19676. let imagePreviewInstance;
  19677. const closePreviewImageView = () => {
  19678. state$2 = null;
  19679. nextTick(() => {
  19680. imagePreviewInstance == null ? void 0 : imagePreviewInstance.unmount();
  19681. imagePreviewInstance = null;
  19682. });
  19683. };
  19684. const previewImage = /* @__PURE__ */ defineAsyncApi(
  19685. API_PREVIEW_IMAGE,
  19686. (args, { resolve }) => {
  19687. if (!state$2) {
  19688. state$2 = reactive(args);
  19689. nextTick(() => {
  19690. imagePreviewInstance = createRootApp(
  19691. ImagePreview,
  19692. state$2,
  19693. closePreviewImageView
  19694. );
  19695. imagePreviewInstance.mount(ensureRoot("u-a-p"));
  19696. });
  19697. } else {
  19698. extend(state$2, args);
  19699. }
  19700. resolve();
  19701. },
  19702. PreviewImageProtocol,
  19703. PreviewImageOptions
  19704. );
  19705. const closePreviewImage = /* @__PURE__ */ defineAsyncApi(
  19706. API_CLOSE_PREVIEW_IMAGE,
  19707. (_, { resolve, reject }) => {
  19708. if (imagePreviewInstance) {
  19709. closePreviewImageView();
  19710. resolve();
  19711. } else {
  19712. reject();
  19713. }
  19714. }
  19715. );
  19716. let videoInput = null;
  19717. const chooseVideo = /* @__PURE__ */ defineAsyncApi(
  19718. API_CHOOSE_VIDEO,
  19719. ({ sourceType, extension }, { resolve, reject }) => {
  19720. initI18nChooseFileMsgsOnce();
  19721. const { t: t2 } = useI18n();
  19722. if (videoInput) {
  19723. document.body.removeChild(videoInput);
  19724. videoInput = null;
  19725. }
  19726. videoInput = _createInput({
  19727. sourceType,
  19728. extension,
  19729. type: "video"
  19730. });
  19731. document.body.appendChild(videoInput);
  19732. videoInput.addEventListener("change", function(event) {
  19733. const eventTarget = event.target;
  19734. const file = eventTarget.files[0];
  19735. let filePath = "";
  19736. const callbackResult = {
  19737. tempFilePath: filePath,
  19738. tempFile: file,
  19739. size: file.size,
  19740. duration: 0,
  19741. width: 0,
  19742. height: 0,
  19743. name: file.name
  19744. };
  19745. Object.defineProperty(callbackResult, "tempFilePath", {
  19746. get() {
  19747. filePath = filePath || fileToUrl(this.tempFile);
  19748. return filePath;
  19749. }
  19750. });
  19751. const video = document.createElement("video");
  19752. if (video.onloadedmetadata !== void 0) {
  19753. const filePath2 = fileToUrl(file);
  19754. video.onloadedmetadata = function() {
  19755. revokeObjectURL(filePath2);
  19756. resolve(
  19757. extend(callbackResult, {
  19758. duration: video.duration || 0,
  19759. width: video.videoWidth || 0,
  19760. height: video.videoHeight || 0
  19761. })
  19762. );
  19763. };
  19764. setTimeout(() => {
  19765. video.onloadedmetadata = null;
  19766. revokeObjectURL(filePath2);
  19767. resolve(callbackResult);
  19768. }, 300);
  19769. video.src = filePath2;
  19770. } else {
  19771. resolve(callbackResult);
  19772. }
  19773. });
  19774. videoInput.click();
  19775. if (!getInteractStatus()) {
  19776. console.warn(t2("uni.chooseFile.notUserActivation"));
  19777. }
  19778. },
  19779. ChooseVideoProtocol,
  19780. ChooseVideoOptions
  19781. );
  19782. const request = /* @__PURE__ */ defineTaskApi(
  19783. API_REQUEST,
  19784. ({
  19785. url,
  19786. data,
  19787. header = {},
  19788. method,
  19789. dataType: dataType2,
  19790. responseType,
  19791. withCredentials,
  19792. timeout = __uniConfig.networkTimeout.request
  19793. }, { resolve, reject }) => {
  19794. let body = null;
  19795. const contentType = normalizeContentType(header);
  19796. if (method !== "GET") {
  19797. if (isString(data) || data instanceof ArrayBuffer) {
  19798. body = data;
  19799. } else {
  19800. if (contentType === "json") {
  19801. try {
  19802. body = JSON.stringify(data);
  19803. } catch (error) {
  19804. body = data.toString();
  19805. }
  19806. } else if (contentType === "urlencoded") {
  19807. const bodyArray = [];
  19808. for (const key in data) {
  19809. if (hasOwn(data, key)) {
  19810. bodyArray.push(
  19811. encodeURIComponent(key) + "=" + encodeURIComponent(data[key])
  19812. );
  19813. }
  19814. }
  19815. body = bodyArray.join("&");
  19816. } else {
  19817. body = data.toString();
  19818. }
  19819. }
  19820. }
  19821. const xhr = new XMLHttpRequest();
  19822. const requestTask = new RequestTask(xhr);
  19823. xhr.open(method, url);
  19824. for (const key in header) {
  19825. if (hasOwn(header, key)) {
  19826. xhr.setRequestHeader(key, header[key]);
  19827. }
  19828. }
  19829. const timer = setTimeout(function() {
  19830. xhr.onload = xhr.onabort = xhr.onerror = null;
  19831. requestTask.abort();
  19832. reject("timeout", { errCode: 5 });
  19833. }, timeout);
  19834. xhr.responseType = responseType;
  19835. xhr.onload = function() {
  19836. clearTimeout(timer);
  19837. const statusCode = xhr.status;
  19838. let res = responseType === "text" ? xhr.responseText : xhr.response;
  19839. if (responseType === "text" && dataType2 === "json") {
  19840. try {
  19841. res = JSON.parse(res);
  19842. } catch (error) {
  19843. }
  19844. }
  19845. resolve({
  19846. data: res,
  19847. statusCode,
  19848. header: parseHeaders(xhr.getAllResponseHeaders()),
  19849. cookies: []
  19850. });
  19851. };
  19852. xhr.onabort = function() {
  19853. clearTimeout(timer);
  19854. reject("abort", { errCode: 600003 });
  19855. };
  19856. xhr.onerror = function() {
  19857. clearTimeout(timer);
  19858. reject(void 0, { errCode: 5 });
  19859. };
  19860. xhr.withCredentials = withCredentials;
  19861. xhr.send(body);
  19862. return requestTask;
  19863. },
  19864. RequestProtocol,
  19865. RequestOptions
  19866. );
  19867. function normalizeContentType(header) {
  19868. const name = Object.keys(header).find(
  19869. (name2) => name2.toLowerCase() === "content-type"
  19870. );
  19871. if (!name) {
  19872. return;
  19873. }
  19874. const contentType = header[name];
  19875. if (contentType.indexOf("application/json") === 0) {
  19876. return "json";
  19877. } else if (contentType.indexOf("application/x-www-form-urlencoded") === 0) {
  19878. return "urlencoded";
  19879. }
  19880. return "string";
  19881. }
  19882. class RequestTask {
  19883. constructor(xhr) {
  19884. this._xhr = xhr;
  19885. }
  19886. abort() {
  19887. if (this._xhr) {
  19888. this._xhr.abort();
  19889. delete this._xhr;
  19890. }
  19891. }
  19892. onHeadersReceived(callback) {
  19893. throw new Error("Method not implemented.");
  19894. }
  19895. offHeadersReceived(callback) {
  19896. throw new Error("Method not implemented.");
  19897. }
  19898. }
  19899. function parseHeaders(headers) {
  19900. const headersObject = {};
  19901. headers.split(LINEFEED).forEach((header) => {
  19902. const find = header.match(/(\S+\s*):\s*(.*)/);
  19903. if (!find || find.length !== 3) {
  19904. return;
  19905. }
  19906. headersObject[find[1]] = find[2];
  19907. });
  19908. return headersObject;
  19909. }
  19910. class DownloadTask {
  19911. constructor(xhr) {
  19912. this._callbacks = [];
  19913. this._xhr = xhr;
  19914. }
  19915. /**
  19916. * 监听下载进度
  19917. * @param {Function} callback 回调
  19918. */
  19919. onProgressUpdate(callback) {
  19920. if (!isFunction(callback)) {
  19921. return;
  19922. }
  19923. this._callbacks.push(callback);
  19924. }
  19925. offProgressUpdate(callback) {
  19926. const index2 = this._callbacks.indexOf(callback);
  19927. if (index2 >= 0) {
  19928. this._callbacks.splice(index2, 1);
  19929. }
  19930. }
  19931. /**
  19932. * 停止任务
  19933. */
  19934. abort() {
  19935. if (this._xhr) {
  19936. this._xhr.abort();
  19937. delete this._xhr;
  19938. }
  19939. }
  19940. onHeadersReceived(callback) {
  19941. throw new Error("Method not implemented.");
  19942. }
  19943. offHeadersReceived(callback) {
  19944. throw new Error("Method not implemented.");
  19945. }
  19946. }
  19947. const downloadFile = /* @__PURE__ */ defineTaskApi(
  19948. API_DOWNLOAD_FILE,
  19949. ({ url, header = {}, timeout = __uniConfig.networkTimeout.downloadFile }, { resolve, reject }) => {
  19950. var timer;
  19951. var xhr = new XMLHttpRequest();
  19952. var downloadTask = new DownloadTask(xhr);
  19953. xhr.open("GET", url, true);
  19954. Object.keys(header).forEach((key) => {
  19955. xhr.setRequestHeader(key, header[key]);
  19956. });
  19957. xhr.responseType = "blob";
  19958. xhr.onload = function() {
  19959. clearTimeout(timer);
  19960. const statusCode = xhr.status;
  19961. const blob = this.response;
  19962. let filename;
  19963. const contentDisposition = xhr.getResponseHeader("content-disposition");
  19964. if (contentDisposition) {
  19965. const res = contentDisposition.match(/filename="?(\S+)"?\b/);
  19966. if (res) {
  19967. filename = res[1];
  19968. }
  19969. }
  19970. blob.name = filename || getFileName(url);
  19971. resolve({
  19972. statusCode,
  19973. tempFilePath: fileToUrl(blob)
  19974. });
  19975. };
  19976. xhr.onabort = function() {
  19977. clearTimeout(timer);
  19978. reject("abort", { errCode: 600003 });
  19979. };
  19980. xhr.onerror = function() {
  19981. clearTimeout(timer);
  19982. reject("", { errCode: 602001 });
  19983. };
  19984. xhr.onprogress = function(event) {
  19985. downloadTask._callbacks.forEach((callback) => {
  19986. var totalBytesWritten = event.loaded;
  19987. var totalBytesExpectedToWrite = event.total;
  19988. var progress = Math.round(
  19989. totalBytesWritten / totalBytesExpectedToWrite * 100
  19990. );
  19991. callback({
  19992. progress,
  19993. totalBytesWritten,
  19994. totalBytesExpectedToWrite
  19995. });
  19996. });
  19997. };
  19998. xhr.send();
  19999. timer = setTimeout(function() {
  20000. xhr.onprogress = xhr.onload = xhr.onabort = xhr.onerror = null;
  20001. downloadTask.abort();
  20002. reject("timeout", { errCode: 5 });
  20003. }, timeout);
  20004. return downloadTask;
  20005. },
  20006. DownloadFileProtocol,
  20007. DownloadFileOptions
  20008. );
  20009. class UploadTask {
  20010. constructor(xhr) {
  20011. this._callbacks = [];
  20012. this._xhr = xhr;
  20013. }
  20014. /**
  20015. * 监听上传进度
  20016. * @param callback 回调
  20017. */
  20018. onProgressUpdate(callback) {
  20019. if (!isFunction(callback)) {
  20020. return;
  20021. }
  20022. this._callbacks.push(callback);
  20023. }
  20024. offProgressUpdate(callback) {
  20025. const index2 = this._callbacks.indexOf(callback);
  20026. if (index2 >= 0) {
  20027. this._callbacks.splice(index2, 1);
  20028. }
  20029. }
  20030. /**
  20031. * 中断上传任务
  20032. */
  20033. abort() {
  20034. this._isAbort = true;
  20035. if (this._xhr) {
  20036. this._xhr.abort();
  20037. delete this._xhr;
  20038. }
  20039. }
  20040. onHeadersReceived(callback) {
  20041. throw new Error("Method not implemented.");
  20042. }
  20043. offHeadersReceived(callback) {
  20044. throw new Error("Method not implemented.");
  20045. }
  20046. }
  20047. const uploadFile = /* @__PURE__ */ defineTaskApi(
  20048. API_UPLOAD_FILE,
  20049. ({
  20050. url,
  20051. file,
  20052. filePath,
  20053. name,
  20054. files: files2,
  20055. header = {},
  20056. formData = {},
  20057. timeout = __uniConfig.networkTimeout.uploadFile
  20058. }, { resolve, reject }) => {
  20059. var uploadTask = new UploadTask();
  20060. if (!isArray(files2) || !files2.length) {
  20061. files2 = [
  20062. {
  20063. name,
  20064. file,
  20065. uri: filePath
  20066. }
  20067. ];
  20068. }
  20069. function upload(realFiles) {
  20070. var xhr = new XMLHttpRequest();
  20071. var form = new FormData();
  20072. var timer;
  20073. Object.keys(formData).forEach((key) => {
  20074. form.append(key, formData[key]);
  20075. });
  20076. Object.values(files2).forEach(({ name: name2 }, index2) => {
  20077. const file2 = realFiles[index2];
  20078. form.append(name2 || "file", file2, file2.name || `file-${Date.now()}`);
  20079. });
  20080. xhr.open("POST", url);
  20081. Object.keys(header).forEach((key) => {
  20082. xhr.setRequestHeader(key, header[key]);
  20083. });
  20084. xhr.upload.onprogress = function(event) {
  20085. uploadTask._callbacks.forEach((callback) => {
  20086. var totalBytesSent = event.loaded;
  20087. var totalBytesExpectedToSend = event.total;
  20088. var progress = Math.round(
  20089. totalBytesSent / totalBytesExpectedToSend * 100
  20090. );
  20091. callback({
  20092. progress,
  20093. totalBytesSent,
  20094. totalBytesExpectedToSend
  20095. });
  20096. });
  20097. };
  20098. xhr.onerror = function() {
  20099. clearTimeout(timer);
  20100. reject("", { errCode: 602001 });
  20101. };
  20102. xhr.onabort = function() {
  20103. clearTimeout(timer);
  20104. reject("abort", { errCode: 600003 });
  20105. };
  20106. xhr.onload = function() {
  20107. clearTimeout(timer);
  20108. const statusCode = xhr.status;
  20109. resolve({
  20110. statusCode,
  20111. data: xhr.responseText || xhr.response
  20112. });
  20113. };
  20114. if (!uploadTask._isAbort) {
  20115. timer = setTimeout(function() {
  20116. xhr.upload.onprogress = xhr.onload = xhr.onabort = xhr.onerror = null;
  20117. uploadTask.abort();
  20118. reject("timeout", { errCode: 5 });
  20119. }, timeout);
  20120. xhr.send(form);
  20121. uploadTask._xhr = xhr;
  20122. } else {
  20123. reject("abort", { errCode: 600003 });
  20124. }
  20125. }
  20126. Promise.all(
  20127. files2.map(
  20128. ({ file: file2, uri }) => file2 instanceof Blob ? Promise.resolve(blobToFile(file2)) : urlToFile(uri)
  20129. )
  20130. ).then(upload).catch(() => {
  20131. setTimeout(() => {
  20132. reject("file error");
  20133. }, 0);
  20134. });
  20135. return uploadTask;
  20136. },
  20137. UploadFileProtocol,
  20138. UploadFileOptions
  20139. );
  20140. const socketTasks = [];
  20141. const globalEvent = {
  20142. open: "",
  20143. close: "",
  20144. error: "",
  20145. message: ""
  20146. };
  20147. class SocketTask {
  20148. /**
  20149. * 构造函数
  20150. * @param {string} url
  20151. * @param {Array} protocols
  20152. */
  20153. constructor(url, protocols, callback) {
  20154. this._callbacks = {
  20155. open: [],
  20156. close: [],
  20157. error: [],
  20158. message: []
  20159. };
  20160. let error;
  20161. try {
  20162. const webSocket = this._webSocket = new WebSocket(url, protocols);
  20163. webSocket.binaryType = "arraybuffer";
  20164. const eventNames = ["open", "close", "error", "message"];
  20165. eventNames.forEach((name) => {
  20166. this._callbacks[name] = [];
  20167. webSocket.addEventListener(name, (event) => {
  20168. const { data, code, reason } = event;
  20169. const res = name === "message" ? { data } : name === "close" ? { code, reason } : {};
  20170. this._callbacks[name].forEach((callback2) => {
  20171. try {
  20172. callback2(res);
  20173. } catch (e2) {
  20174. console.error(
  20175. `thirdScriptError
  20176. ${e2};at socketTask.on${capitalize(
  20177. name
  20178. )} callback function
  20179. `,
  20180. e2
  20181. );
  20182. }
  20183. });
  20184. if (this === socketTasks[0] && globalEvent[name]) {
  20185. UniServiceJSBridge.invokeOnCallback(globalEvent[name], res);
  20186. }
  20187. if (name === "error" || name === "close") {
  20188. const index2 = socketTasks.indexOf(this);
  20189. if (index2 >= 0) {
  20190. socketTasks.splice(index2, 1);
  20191. }
  20192. }
  20193. });
  20194. });
  20195. const propertys = [
  20196. "CLOSED",
  20197. "CLOSING",
  20198. "CONNECTING",
  20199. "OPEN",
  20200. "readyState"
  20201. ];
  20202. propertys.forEach((property) => {
  20203. Object.defineProperty(this, property, {
  20204. get() {
  20205. return webSocket[property];
  20206. }
  20207. });
  20208. });
  20209. } catch (e2) {
  20210. error = e2;
  20211. }
  20212. callback && callback(error, this);
  20213. }
  20214. /**
  20215. * 发送
  20216. * @param {any} data
  20217. */
  20218. send(options) {
  20219. const data = (options || {}).data;
  20220. const ws = this._webSocket;
  20221. try {
  20222. if (ws.readyState !== ws.OPEN) {
  20223. callOptions(options, {
  20224. errMsg: `sendSocketMessage:fail SocketTask.readyState is not OPEN`,
  20225. errCode: 10002
  20226. });
  20227. throw new Error("SocketTask.readyState is not OPEN");
  20228. }
  20229. ws.send(data);
  20230. callOptions(options, "sendSocketMessage:ok");
  20231. } catch (error) {
  20232. callOptions(options, {
  20233. errMsg: `sendSocketMessage:fail ${error}`,
  20234. errCode: 602001
  20235. });
  20236. }
  20237. }
  20238. /**
  20239. * 关闭
  20240. * @param {number} code
  20241. * @param {string} reason
  20242. */
  20243. close(options = {}) {
  20244. const ws = this._webSocket;
  20245. try {
  20246. const code = options.code || 1e3;
  20247. const reason = options.reason;
  20248. if (isString(reason)) {
  20249. ws.close(code, reason);
  20250. } else {
  20251. ws.close(code);
  20252. }
  20253. callOptions(options, "closeSocket:ok");
  20254. } catch (error) {
  20255. callOptions(options, `closeSocket:fail ${error}`);
  20256. }
  20257. }
  20258. onOpen(callback) {
  20259. this._callbacks.open.push(callback);
  20260. }
  20261. onMessage(callback) {
  20262. this._callbacks.message.push(callback);
  20263. }
  20264. onError(callback) {
  20265. this._callbacks.error.push(callback);
  20266. }
  20267. onClose(callback) {
  20268. this._callbacks.close.push(callback);
  20269. }
  20270. }
  20271. const connectSocket = /* @__PURE__ */ defineTaskApi(
  20272. API_CONNECT_SOCKET,
  20273. ({ url, protocols }, { resolve, reject }) => {
  20274. return new SocketTask(
  20275. url,
  20276. protocols,
  20277. (error, socketTask) => {
  20278. if (error) {
  20279. reject(error.toString(), {
  20280. errCode: 600009
  20281. });
  20282. return;
  20283. }
  20284. socketTasks.push(socketTask);
  20285. resolve();
  20286. }
  20287. );
  20288. },
  20289. ConnectSocketProtocol,
  20290. ConnectSocketOptions
  20291. );
  20292. function callSocketTask(socketTask, method, option, resolve, reject) {
  20293. const fn = socketTask[method];
  20294. if (isFunction(fn)) {
  20295. fn.call(
  20296. socketTask,
  20297. extend({}, option, {
  20298. success() {
  20299. resolve();
  20300. },
  20301. fail({ errMsg }) {
  20302. reject(errMsg.replace("sendSocketMessage:fail ", ""));
  20303. },
  20304. complete: void 0
  20305. })
  20306. );
  20307. }
  20308. }
  20309. const sendSocketMessage = /* @__PURE__ */ defineAsyncApi(
  20310. API_SEND_SOCKET_MESSAGE,
  20311. (options, { resolve, reject }) => {
  20312. const socketTask = socketTasks[0];
  20313. if (socketTask && socketTask.readyState === socketTask.OPEN) {
  20314. callSocketTask(socketTask, "send", options, resolve, reject);
  20315. } else {
  20316. reject("WebSocket is not connected");
  20317. }
  20318. },
  20319. SendSocketMessageProtocol
  20320. );
  20321. const closeSocket = /* @__PURE__ */ defineAsyncApi(
  20322. API_CLOSE_SOCKET,
  20323. (options, { resolve, reject }) => {
  20324. const socketTask = socketTasks[0];
  20325. if (socketTask) {
  20326. callSocketTask(socketTask, "close", options, resolve, reject);
  20327. } else {
  20328. reject("WebSocket is not connected");
  20329. }
  20330. },
  20331. CloseSocketProtocol
  20332. );
  20333. function on(event) {
  20334. const api2 = `onSocket${capitalize(event)}`;
  20335. return /* @__PURE__ */ defineOnApi(api2, () => {
  20336. globalEvent[event] = api2;
  20337. });
  20338. }
  20339. const onSocketOpen = /* @__PURE__ */ on("open");
  20340. const onSocketError = /* @__PURE__ */ on("error");
  20341. const onSocketMessage = /* @__PURE__ */ on("message");
  20342. const onSocketClose = /* @__PURE__ */ on("close");
  20343. const getLocation = /* @__PURE__ */ defineAsyncApi(
  20344. API_GET_LOCATION,
  20345. ({ type, altitude, highAccuracyExpireTime, isHighAccuracy }, { resolve, reject }) => {
  20346. const mapInfo = getMapInfo();
  20347. new Promise((resolve2, reject2) => {
  20348. if (navigator.geolocation) {
  20349. navigator.geolocation.getCurrentPosition(
  20350. (res) => resolve2({ coords: res.coords }),
  20351. reject2,
  20352. {
  20353. enableHighAccuracy: isHighAccuracy || altitude,
  20354. timeout: highAccuracyExpireTime || 1e3 * 100
  20355. }
  20356. );
  20357. } else {
  20358. reject2(new Error("device nonsupport geolocation"));
  20359. }
  20360. }).catch((error) => {
  20361. return new Promise(
  20362. (resolve2, reject2) => {
  20363. if (mapInfo.type === MapType.QQ) {
  20364. getJSONP(
  20365. `https://apis.map.qq.com/ws/location/v1/ip?output=jsonp&key=${mapInfo.key}`,
  20366. {
  20367. callback: "callback"
  20368. },
  20369. (res) => {
  20370. if ("result" in res && res.result.location) {
  20371. const location2 = res.result.location;
  20372. resolve2({
  20373. coords: {
  20374. latitude: location2.lat,
  20375. longitude: location2.lng
  20376. },
  20377. skip: true
  20378. });
  20379. } else {
  20380. reject2(new Error(res.message || JSON.stringify(res)));
  20381. }
  20382. },
  20383. () => reject2(new Error("network error"))
  20384. );
  20385. } else if (mapInfo.type === MapType.GOOGLE) {
  20386. request({
  20387. method: "POST",
  20388. url: `https://www.googleapis.com/geolocation/v1/geolocate?key=${mapInfo.key}`,
  20389. success(res) {
  20390. const data = res.data;
  20391. if ("location" in data) {
  20392. resolve2({
  20393. coords: {
  20394. latitude: data.location.lat,
  20395. longitude: data.location.lng,
  20396. accuracy: data.accuracy
  20397. },
  20398. skip: true
  20399. });
  20400. } else {
  20401. reject2(
  20402. new Error(
  20403. data.error && data.error.message || JSON.stringify(res)
  20404. )
  20405. );
  20406. }
  20407. },
  20408. fail() {
  20409. reject2(new Error("network error"));
  20410. }
  20411. });
  20412. } else if (mapInfo.type === MapType.AMAP) {
  20413. loadMaps([], () => {
  20414. window.AMap.plugin("AMap.Geolocation", () => {
  20415. const geolocation = new window.AMap.Geolocation({
  20416. enableHighAccuracy: true,
  20417. timeout: 1e4
  20418. });
  20419. geolocation.getCurrentPosition(
  20420. (status, data) => {
  20421. if (status === "complete") {
  20422. resolve2({
  20423. coords: {
  20424. latitude: data.position.lat,
  20425. longitude: data.position.lng,
  20426. accuracy: data.accuracy
  20427. },
  20428. skip: true
  20429. });
  20430. } else {
  20431. reject2(new Error(data.message));
  20432. }
  20433. }
  20434. );
  20435. });
  20436. });
  20437. } else {
  20438. reject2(error);
  20439. }
  20440. }
  20441. );
  20442. }).then(({ coords, skip }) => {
  20443. translateCoordinateSystem(type, coords, skip).then((coords2) => {
  20444. resolve({
  20445. latitude: coords2.latitude,
  20446. longitude: coords2.longitude,
  20447. accuracy: coords2.accuracy,
  20448. speed: coords2.altitude || 0,
  20449. altitude: coords2.altitude || 0,
  20450. verticalAccuracy: coords2.altitudeAccuracy || 0,
  20451. // 无专门水平精度,使用位置精度替代
  20452. horizontalAccuracy: coords2.accuracy || 0
  20453. });
  20454. }).catch((error) => {
  20455. reject(error.message);
  20456. });
  20457. }).catch((error) => {
  20458. reject(error.message || JSON.stringify(error));
  20459. });
  20460. },
  20461. GetLocationProtocol,
  20462. GetLocationOptions
  20463. );
  20464. const ICON_PATH_NAV = "M28 17c-6.49396875 0-12.13721875 2.57040625-15 6.34840625V5.4105l6.29859375 6.29859375c0.387875 0.387875 1.02259375 0.387875 1.4105 0 0.387875-0.387875 0.387875-1.02259375 0-1.4105L12.77853125 2.36803125a0.9978125 0.9978125 0 0 0-0.0694375-0.077125c-0.1944375-0.1944375-0.45090625-0.291375-0.70721875-0.290875l-0.00184375-0.0000625-0.00184375 0.0000625c-0.2563125-0.0005-0.51278125 0.09640625-0.70721875 0.290875a0.9978125 0.9978125 0 0 0-0.0694375 0.077125l-7.930625 7.9305625c-0.387875 0.387875-0.387875 1.02259375 0 1.4105 0.387875 0.387875 1.02259375 0.387875 1.4105 0L11 5.4105V29c0 0.55 0.45 1 1 1s1-0.45 1-1c0-5.52284375 6.71571875-10 15-10 0.55228125 0 1-0.44771875 1-1 0-0.55228125-0.44771875-1-1-1z";
  20465. const props$8 = {
  20466. latitude: {
  20467. type: Number
  20468. },
  20469. longitude: {
  20470. type: Number
  20471. },
  20472. scale: {
  20473. type: Number,
  20474. default: 18
  20475. },
  20476. name: {
  20477. type: String,
  20478. default: ""
  20479. },
  20480. address: {
  20481. type: String,
  20482. default: ""
  20483. }
  20484. };
  20485. function useState$2(props2) {
  20486. const state2 = reactive({
  20487. center: {
  20488. latitude: 0,
  20489. longitude: 0
  20490. },
  20491. marker: {
  20492. id: 1,
  20493. latitude: 0,
  20494. longitude: 0,
  20495. iconPath: ICON_PATH_TARGET,
  20496. width: 32,
  20497. height: 52
  20498. },
  20499. location: {
  20500. id: 2,
  20501. latitude: 0,
  20502. longitude: 0,
  20503. iconPath: ICON_PATH_ORIGIN,
  20504. width: 44,
  20505. height: 44
  20506. }
  20507. });
  20508. function updatePosition() {
  20509. if (props2.latitude && props2.longitude) {
  20510. state2.center.latitude = props2.latitude;
  20511. state2.center.longitude = props2.longitude;
  20512. state2.marker.latitude = props2.latitude;
  20513. state2.marker.longitude = props2.longitude;
  20514. }
  20515. }
  20516. watch([() => props2.latitude, () => props2.longitude], updatePosition);
  20517. updatePosition();
  20518. return state2;
  20519. }
  20520. const LocationView = /* @__PURE__ */ defineSystemComponent({
  20521. name: "LocationView",
  20522. props: props$8,
  20523. emits: ["close"],
  20524. setup(props2, {
  20525. emit: emit2
  20526. }) {
  20527. const state2 = useState$2(props2);
  20528. usePreventScroll();
  20529. getLocation({
  20530. type: "gcj02",
  20531. success: ({
  20532. latitude,
  20533. longitude
  20534. }) => {
  20535. state2.location.latitude = latitude;
  20536. state2.location.longitude = longitude;
  20537. }
  20538. });
  20539. function onRegionChange(event) {
  20540. const centerLocation = event.detail.centerLocation;
  20541. if (centerLocation) {
  20542. state2.center.latitude = centerLocation.latitude;
  20543. state2.center.longitude = centerLocation.longitude;
  20544. }
  20545. }
  20546. function nav() {
  20547. const mapInfo = getMapInfo();
  20548. let url = "";
  20549. if (mapInfo.type === MapType.GOOGLE) {
  20550. const origin = state2.location.latitude ? `&origin=${state2.location.latitude}%2C${state2.location.longitude}` : "";
  20551. url = `https://www.google.com/maps/dir/?api=1${origin}&destination=${props2.latitude}%2C${props2.longitude}`;
  20552. } else if (mapInfo.type === MapType.QQ) {
  20553. const fromcoord = state2.location.latitude ? `&fromcoord=${state2.location.latitude}%2C${state2.location.longitude}&from=${encodeURIComponent("我的位置")}` : "";
  20554. url = `https://apis.map.qq.com/uri/v1/routeplan?type=drive${fromcoord}&tocoord=${props2.latitude}%2C${props2.longitude}&to=${encodeURIComponent(props2.name || "目的地")}&ref=${mapInfo.key}`;
  20555. } else if (mapInfo.type === MapType.AMAP) {
  20556. const from = state2.location.latitude ? `from=${state2.location.longitude},${state2.location.latitude},${encodeURIComponent("我的位置")}&` : "";
  20557. url = `https://uri.amap.com/navigation?${from}to=${props2.longitude},${props2.latitude},${encodeURIComponent(props2.name || "目的地")}`;
  20558. }
  20559. window.open(url);
  20560. }
  20561. function back() {
  20562. emit2("close");
  20563. }
  20564. function setCenter({
  20565. latitude,
  20566. longitude
  20567. }) {
  20568. state2.center.latitude = latitude;
  20569. state2.center.longitude = longitude;
  20570. }
  20571. return () => {
  20572. return createVNode("div", {
  20573. "class": "uni-system-open-location"
  20574. }, [createVNode(Map$1, {
  20575. "latitude": state2.center.latitude,
  20576. "longitude": state2.center.longitude,
  20577. "class": "map",
  20578. "markers": [state2.marker, state2.location],
  20579. "onRegionchange": onRegionChange
  20580. }, {
  20581. default: () => [createVNode("div", {
  20582. "class": "map-move",
  20583. "onClick": () => setCenter(state2.location)
  20584. }, [createSvgIconVNode(ICON_PATH_LOCTAION, "#000000", 24)], 8, ["onClick"])]
  20585. }, 8, ["latitude", "longitude", "markers", "onRegionchange"]), createVNode("div", {
  20586. "class": "info"
  20587. }, [createVNode("div", {
  20588. "class": "name",
  20589. "onClick": () => setCenter(state2.marker)
  20590. }, [props2.name], 8, ["onClick"]), createVNode("div", {
  20591. "class": "address",
  20592. "onClick": () => setCenter(state2.marker)
  20593. }, [props2.address], 8, ["onClick"]), createVNode("div", {
  20594. "class": "nav",
  20595. "onClick": nav
  20596. }, [createSvgIconVNode(ICON_PATH_NAV, "#ffffff", 26)], 8, ["onClick"])]), createVNode("div", {
  20597. "class": "nav-btn-back",
  20598. "onClick": back
  20599. }, [createSvgIconVNode(ICON_PATH_BACK, "#ffffff", 26)], 8, ["onClick"])]);
  20600. };
  20601. }
  20602. });
  20603. let state$1 = null;
  20604. const openLocation = /* @__PURE__ */ defineAsyncApi(
  20605. API_OPEN_LOCATION,
  20606. (args, { resolve }) => {
  20607. if (!state$1) {
  20608. state$1 = reactive(args);
  20609. nextTick(() => {
  20610. const app = createRootApp(LocationView, state$1, () => {
  20611. state$1 = null;
  20612. nextTick(() => {
  20613. app.unmount();
  20614. });
  20615. });
  20616. app.mount(ensureRoot("u-a-o"));
  20617. });
  20618. } else {
  20619. extend(state$1, args);
  20620. }
  20621. resolve();
  20622. },
  20623. OpenLocationProtocol,
  20624. OpenLocationOptions
  20625. );
  20626. function _isSlot$1(s) {
  20627. return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
  20628. }
  20629. const props$7 = {
  20630. latitude: {
  20631. type: Number
  20632. },
  20633. longitude: {
  20634. type: Number
  20635. }
  20636. };
  20637. function distance(distance2) {
  20638. if (distance2 > 100) {
  20639. return `${distance2 > 1e3 ? (distance2 / 1e3).toFixed(1) + "k" : distance2.toFixed(0)}m | `;
  20640. } else if (distance2 > 0) {
  20641. return "<100m | ";
  20642. } else {
  20643. return "";
  20644. }
  20645. }
  20646. function useState$1(props2) {
  20647. const state2 = reactive({
  20648. latitude: 0,
  20649. longitude: 0,
  20650. keyword: "",
  20651. searching: false
  20652. });
  20653. function updatePosition() {
  20654. if (props2.latitude && props2.longitude) {
  20655. state2.latitude = props2.latitude;
  20656. state2.longitude = props2.longitude;
  20657. }
  20658. }
  20659. watch([() => props2.latitude, () => props2.longitude], updatePosition);
  20660. updatePosition();
  20661. return state2;
  20662. }
  20663. function useList(state2) {
  20664. const key = __uniConfig.qqMapKey;
  20665. const list2 = reactive([]);
  20666. const selectedIndexRef = ref(-1);
  20667. const selectedRef = computed(() => list2[selectedIndexRef.value]);
  20668. const listState = reactive({
  20669. loading: true,
  20670. // google map default
  20671. pageSize: 20,
  20672. pageIndex: 1,
  20673. hasNextPage: true,
  20674. nextPage: null,
  20675. selectedIndex: selectedIndexRef,
  20676. selected: selectedRef
  20677. });
  20678. const adcodeRef = ref("");
  20679. const boundaryRef = computed(() => adcodeRef.value ? `region(${adcodeRef.value},1,${state2.latitude},${state2.longitude})` : `nearby(${state2.latitude},${state2.longitude},5000)`);
  20680. function pushData(array) {
  20681. array.forEach((item) => {
  20682. list2.push({
  20683. name: item.title || item.name,
  20684. address: item.address,
  20685. distance: item._distance || item.distance,
  20686. latitude: item.location.lat,
  20687. longitude: item.location.lng
  20688. });
  20689. });
  20690. }
  20691. function getList() {
  20692. listState.loading = true;
  20693. const mapInfo = getMapInfo();
  20694. if (mapInfo.type === MapType.GOOGLE) {
  20695. if (listState.pageIndex > 1 && listState.nextPage) {
  20696. listState.nextPage();
  20697. return;
  20698. }
  20699. const service = new google.maps.places.PlacesService(document.createElement("div"));
  20700. service[state2.searching ? "textSearch" : "nearbySearch"]({
  20701. location: {
  20702. lat: state2.latitude,
  20703. lng: state2.longitude
  20704. },
  20705. query: state2.keyword,
  20706. radius: 5e3
  20707. }, (results, state3, page) => {
  20708. listState.loading = false;
  20709. if (results && results.length) {
  20710. results.forEach((item) => {
  20711. list2.push({
  20712. name: item.name || "",
  20713. address: item.vicinity || item.formatted_address || "",
  20714. distance: 0,
  20715. latitude: item.geometry.location.lat(),
  20716. longitude: item.geometry.location.lng()
  20717. });
  20718. });
  20719. }
  20720. if (page) {
  20721. if (!page.hasNextPage) {
  20722. listState.hasNextPage = false;
  20723. } else {
  20724. listState.nextPage = () => {
  20725. page.nextPage();
  20726. };
  20727. }
  20728. }
  20729. });
  20730. } else if (mapInfo.type === MapType.QQ) {
  20731. const url = state2.searching ? `https://apis.map.qq.com/ws/place/v1/search?output=jsonp&key=${key}&boundary=${boundaryRef.value}&keyword=${state2.keyword}&page_size=${listState.pageSize}&page_index=${listState.pageIndex}` : `https://apis.map.qq.com/ws/geocoder/v1/?output=jsonp&key=${key}&location=${state2.latitude},${state2.longitude}&get_poi=1&poi_options=page_size=${listState.pageSize};page_index=${listState.pageIndex}`;
  20732. getJSONP(url, {
  20733. callback: "callback"
  20734. }, (res) => {
  20735. listState.loading = false;
  20736. if (state2.searching && "data" in res && res.data.length) {
  20737. pushData(res.data);
  20738. } else if ("result" in res) {
  20739. const result = res.result;
  20740. adcodeRef.value = result.ad_info ? result.ad_info.adcode : "";
  20741. if (result.pois) {
  20742. pushData(result.pois);
  20743. }
  20744. }
  20745. if (list2.length === listState.pageSize * listState.pageIndex) {
  20746. listState.hasNextPage = false;
  20747. }
  20748. }, () => {
  20749. listState.loading = false;
  20750. });
  20751. } else if (mapInfo.type === MapType.AMAP) {
  20752. window.AMap.plugin("AMap.PlaceSearch", function() {
  20753. const placeSearch = new window.AMap.PlaceSearch({
  20754. city: "全国",
  20755. pageSize: 10,
  20756. pageIndex: listState.pageIndex
  20757. });
  20758. const keyword = state2.searching ? state2.keyword : "";
  20759. const radius = state2.searching ? 5e4 : 5e3;
  20760. placeSearch.searchNearBy(keyword, [state2.longitude, state2.latitude], radius, function(status, result) {
  20761. if (status === "error") {
  20762. console.error(result);
  20763. } else if (status === "no_data") {
  20764. listState.hasNextPage = false;
  20765. } else {
  20766. pushData(result.poiList.pois);
  20767. }
  20768. });
  20769. listState.loading = false;
  20770. });
  20771. }
  20772. }
  20773. function loadMore() {
  20774. if (!listState.loading && listState.hasNextPage) {
  20775. listState.pageIndex++;
  20776. getList();
  20777. }
  20778. }
  20779. function reset() {
  20780. listState.selectedIndex = -1;
  20781. listState.pageIndex = 1;
  20782. listState.hasNextPage = true;
  20783. listState.nextPage = null;
  20784. list2.splice(0, list2.length);
  20785. }
  20786. return {
  20787. listState,
  20788. list: list2,
  20789. loadMore,
  20790. reset,
  20791. getList
  20792. };
  20793. }
  20794. const LoctaionPicker = /* @__PURE__ */ defineSystemComponent({
  20795. name: "LoctaionPicker",
  20796. props: props$7,
  20797. emits: ["close"],
  20798. setup(props2, {
  20799. emit: emit2
  20800. }) {
  20801. usePreventScroll();
  20802. initI18nChooseLocationMsgsOnce();
  20803. const {
  20804. t: t2
  20805. } = useI18n();
  20806. const state2 = useState$1(props2);
  20807. const {
  20808. list: list2,
  20809. listState,
  20810. loadMore,
  20811. reset,
  20812. getList
  20813. } = useList(state2);
  20814. const search = debounce(() => {
  20815. reset();
  20816. if (state2.keyword) {
  20817. getList();
  20818. }
  20819. }, 1e3, {
  20820. setTimeout,
  20821. clearTimeout
  20822. });
  20823. watch(() => state2.searching, (val) => {
  20824. reset();
  20825. if (!val) {
  20826. getList();
  20827. }
  20828. });
  20829. function onInput(event) {
  20830. state2.keyword = event.detail.value;
  20831. search();
  20832. }
  20833. function onChoose() {
  20834. emit2("close", extend({}, listState.selected));
  20835. }
  20836. function onBack() {
  20837. emit2("close");
  20838. }
  20839. function onRegionChange(event) {
  20840. const centerLocation = event.detail.centerLocation;
  20841. if (centerLocation) {
  20842. move(centerLocation);
  20843. }
  20844. }
  20845. function moveToLocation() {
  20846. getLocation({
  20847. type: "gcj02",
  20848. success: move,
  20849. fail: () => {
  20850. }
  20851. });
  20852. }
  20853. function move({
  20854. latitude,
  20855. longitude
  20856. }) {
  20857. state2.latitude = latitude;
  20858. state2.longitude = longitude;
  20859. if (!state2.searching) {
  20860. reset();
  20861. getList();
  20862. }
  20863. }
  20864. if (!state2.latitude || !state2.longitude) {
  20865. moveToLocation();
  20866. }
  20867. return () => {
  20868. const content = list2.map((item, index2) => {
  20869. return createVNode("div", {
  20870. "key": index2,
  20871. "class": {
  20872. "list-item": true,
  20873. selected: listState.selectedIndex === index2
  20874. },
  20875. "onClick": () => {
  20876. listState.selectedIndex = index2;
  20877. state2.latitude = item.latitude;
  20878. state2.longitude = item.longitude;
  20879. }
  20880. }, [createSvgIconVNode(ICON_PATH_CONFIRM, "#007aff", 24), createVNode("div", {
  20881. "class": "list-item-title"
  20882. }, [item.name]), createVNode("div", {
  20883. "class": "list-item-detail"
  20884. }, [distance(item.distance), item.address])], 10, ["onClick"]);
  20885. });
  20886. if (listState.loading) {
  20887. content.unshift(createVNode("div", {
  20888. "class": "list-loading"
  20889. }, [createVNode("i", {
  20890. "class": "uni-loading"
  20891. }, null)]));
  20892. }
  20893. return createVNode("div", {
  20894. "class": "uni-system-choose-location"
  20895. }, [createVNode(Map$1, {
  20896. "latitude": state2.latitude,
  20897. "longitude": state2.longitude,
  20898. "class": "map",
  20899. "show-location": true,
  20900. "libraries": ["places"],
  20901. "onUpdated": getList,
  20902. "onRegionchange": onRegionChange
  20903. }, {
  20904. default: () => [createVNode("div", {
  20905. "class": "map-location",
  20906. "style": `background-image: url("${ICON_PATH_TARGET}")`
  20907. }, null), createVNode("div", {
  20908. "class": "map-move",
  20909. "onClick": moveToLocation
  20910. }, [createSvgIconVNode(ICON_PATH_LOCTAION, "#000000", 24)], 8, ["onClick"])],
  20911. _: 1
  20912. }, 8, ["latitude", "longitude", "show-location", "onUpdated", "onRegionchange"]), createVNode("div", {
  20913. "class": "nav"
  20914. }, [createVNode("div", {
  20915. "class": "nav-btn back",
  20916. "onClick": onBack
  20917. }, [createSvgIconVNode(ICON_PATH_CLOSE, "#ffffff", 26)], 8, ["onClick"]), createVNode("div", {
  20918. "class": {
  20919. "nav-btn": true,
  20920. confirm: true,
  20921. disable: !listState.selected
  20922. },
  20923. "onClick": onChoose
  20924. }, [createSvgIconVNode(ICON_PATH_CONFIRM, "#ffffff", 26)], 10, ["onClick"])]), createVNode("div", {
  20925. "class": "menu"
  20926. }, [createVNode("div", {
  20927. "class": "search"
  20928. }, [createVNode(Input, {
  20929. "value": state2.keyword,
  20930. "class": "search-input",
  20931. "placeholder": t2("uni.chooseLocation.search"),
  20932. "onFocus": () => state2.searching = true,
  20933. "onInput": onInput
  20934. }, null, 8, ["value", "placeholder", "onFocus", "onInput"]), state2.searching && createVNode("div", {
  20935. "class": "search-btn",
  20936. "onClick": () => {
  20937. state2.searching = false;
  20938. state2.keyword = "";
  20939. }
  20940. }, [t2("uni.chooseLocation.cancel")], 8, ["onClick"])]), createVNode(ScrollView, {
  20941. "scroll-y": true,
  20942. "class": "list",
  20943. "onScrolltolower": loadMore
  20944. }, _isSlot$1(content) ? content : {
  20945. default: () => [content],
  20946. _: 2
  20947. }, 8, ["scroll-y", "onScrolltolower"])])]);
  20948. };
  20949. }
  20950. });
  20951. let state = null;
  20952. const chooseLocation = /* @__PURE__ */ defineAsyncApi(
  20953. API_CHOOSE_LOCATION,
  20954. (args, { resolve, reject }) => {
  20955. if (!state) {
  20956. state = reactive(args);
  20957. nextTick(() => {
  20958. const app = createRootApp(
  20959. LoctaionPicker,
  20960. state,
  20961. (poi) => {
  20962. state = null;
  20963. nextTick(() => {
  20964. app.unmount();
  20965. });
  20966. poi ? resolve(poi) : reject("cancel");
  20967. }
  20968. );
  20969. app.mount(ensureRoot("u-a-c"));
  20970. });
  20971. } else {
  20972. reject("cancel");
  20973. }
  20974. },
  20975. ChooseLocationProtocol
  20976. );
  20977. let started = false;
  20978. let watchId = 0;
  20979. const startLocationUpdate = /* @__PURE__ */ defineAsyncApi(
  20980. API_START_LOCATION_UPDATE,
  20981. (options, { resolve, reject }) => {
  20982. if (!navigator.geolocation) {
  20983. reject();
  20984. return;
  20985. }
  20986. watchId = watchId || navigator.geolocation.watchPosition(
  20987. (res) => {
  20988. started = true;
  20989. translateCoordinateSystem(options == null ? void 0 : options.type, res.coords).then((coords) => {
  20990. UniServiceJSBridge.invokeOnCallback(
  20991. API_ON_LOCATION_CHANGE,
  20992. coords
  20993. );
  20994. resolve();
  20995. }).catch((error) => {
  20996. UniServiceJSBridge.invokeOnCallback(
  20997. API_ON_LOCATION_CHANGE_ERROR,
  20998. { errMsg: `onLocationChange:fail ${error.message}` }
  20999. );
  21000. });
  21001. },
  21002. (error) => {
  21003. if (!started) {
  21004. reject(error.message);
  21005. started = true;
  21006. }
  21007. UniServiceJSBridge.invokeOnCallback(API_ON_LOCATION_CHANGE_ERROR, {
  21008. errMsg: `onLocationChange:fail ${error.message}`
  21009. });
  21010. }
  21011. );
  21012. setTimeout(resolve, 100);
  21013. },
  21014. StartLocationUpdateProtocol,
  21015. StartLocationUpdateOptions
  21016. );
  21017. const stopLocationUpdate = /* @__PURE__ */ defineAsyncApi(
  21018. API_STOP_LOCATION_UPDATE,
  21019. (_, { resolve }) => {
  21020. if (watchId) {
  21021. navigator.geolocation.clearWatch(watchId);
  21022. started = false;
  21023. watchId = 0;
  21024. }
  21025. resolve();
  21026. }
  21027. );
  21028. const onLocationChange = /* @__PURE__ */ defineOnApi(
  21029. API_ON_LOCATION_CHANGE,
  21030. () => {
  21031. }
  21032. );
  21033. const offLocationChange = /* @__PURE__ */ defineOffApi(
  21034. API_OFF_LOCATION_CHANGE,
  21035. () => {
  21036. }
  21037. );
  21038. const onLocationChangeError = /* @__PURE__ */ defineOnApi(
  21039. API_ON_LOCATION_CHANGE_ERROR,
  21040. () => {
  21041. }
  21042. );
  21043. const offLocationChangeError = /* @__PURE__ */ defineOffApi(
  21044. API_OFF_LOCATION_CHANGE_ERROR,
  21045. () => {
  21046. }
  21047. );
  21048. const navigateBack = /* @__PURE__ */ defineAsyncApi(
  21049. API_NAVIGATE_BACK,
  21050. (args, { resolve, reject }) => {
  21051. let canBack = true;
  21052. if (invokeHook(ON_BACK_PRESS, {
  21053. from: args.from || "navigateBack"
  21054. }) === true) {
  21055. canBack = false;
  21056. }
  21057. if (!canBack) {
  21058. return reject(ON_BACK_PRESS);
  21059. }
  21060. getApp().$router.go(-args.delta);
  21061. return resolve();
  21062. },
  21063. NavigateBackProtocol,
  21064. NavigateBackOptions
  21065. );
  21066. function navigate({ type, url, tabBarText, events, isAutomatedTesting }, __id__) {
  21067. const router = getApp().$router;
  21068. const { path, query } = parseUrl(url);
  21069. return new Promise((resolve, reject) => {
  21070. const state2 = createPageState(type, __id__);
  21071. router[type === "navigateTo" ? "push" : "replace"]({
  21072. path,
  21073. query,
  21074. state: state2,
  21075. force: true
  21076. }).then((failure) => {
  21077. if (isNavigationFailure(failure)) {
  21078. return reject(failure.message);
  21079. }
  21080. if (type === "switchTab") {
  21081. router.currentRoute.value.meta.tabBarText = tabBarText;
  21082. }
  21083. if (type === "navigateTo") {
  21084. const meta = router.currentRoute.value.meta;
  21085. if (!meta.eventChannel) {
  21086. meta.eventChannel = new EventChannel(state2.__id__, events);
  21087. } else if (events) {
  21088. Object.keys(events).forEach((eventName) => {
  21089. meta.eventChannel._addListener(
  21090. eventName,
  21091. "on",
  21092. events[eventName]
  21093. );
  21094. });
  21095. meta.eventChannel._clearCache();
  21096. }
  21097. return isAutomatedTesting ? resolve({
  21098. __id__: state2.__id__
  21099. }) : resolve({
  21100. eventChannel: meta.eventChannel
  21101. });
  21102. }
  21103. return isAutomatedTesting ? resolve({ __id__: state2.__id__ }) : resolve();
  21104. });
  21105. });
  21106. }
  21107. const navigateTo = /* @__PURE__ */ defineAsyncApi(
  21108. API_NAVIGATE_TO,
  21109. // @ts-ignore
  21110. ({ url, events, isAutomatedTesting }, { resolve, reject }) => navigate({ type: API_NAVIGATE_TO, url, events, isAutomatedTesting }).then(resolve).catch(reject),
  21111. NavigateToProtocol,
  21112. NavigateToOptions
  21113. );
  21114. function removeLastPage() {
  21115. const page = getCurrentPage();
  21116. if (!page) {
  21117. return;
  21118. }
  21119. const $page = page.$page;
  21120. removePage(normalizeRouteKey($page.path, $page.id));
  21121. }
  21122. const redirectTo = /* @__PURE__ */ defineAsyncApi(
  21123. API_REDIRECT_TO,
  21124. // @ts-ignore
  21125. ({ url, isAutomatedTesting }, { resolve, reject }) => {
  21126. return (
  21127. // TODO exists 属性未实现
  21128. removeLastPage(), navigate({ type: API_REDIRECT_TO, url, isAutomatedTesting }).then(resolve).catch(reject)
  21129. );
  21130. },
  21131. RedirectToProtocol,
  21132. RedirectToOptions
  21133. );
  21134. function removeAllPages() {
  21135. const keys = getCurrentPagesMap().keys();
  21136. for (const routeKey of keys) {
  21137. removePage(routeKey);
  21138. }
  21139. }
  21140. const reLaunch = /* @__PURE__ */ defineAsyncApi(
  21141. API_RE_LAUNCH,
  21142. // @ts-ignore
  21143. ({ url, isAutomatedTesting }, { resolve, reject }) => {
  21144. return removeAllPages(), navigate({ type: API_RE_LAUNCH, url, isAutomatedTesting }).then(resolve).catch(reject);
  21145. },
  21146. ReLaunchProtocol,
  21147. ReLaunchOptions
  21148. );
  21149. function removeNonTabBarPages() {
  21150. const curTabBarPageVm = getCurrentPageVm();
  21151. if (!curTabBarPageVm) {
  21152. return;
  21153. }
  21154. const pagesMap = getCurrentPagesMap();
  21155. const keys = pagesMap.keys();
  21156. for (const routeKey of keys) {
  21157. const page = pagesMap.get(routeKey);
  21158. if (!page.$.__isTabBar) {
  21159. removePage(routeKey);
  21160. } else {
  21161. page.$.__isActive = false;
  21162. }
  21163. }
  21164. if (curTabBarPageVm.$.__isTabBar) {
  21165. curTabBarPageVm.$.__isVisible = false;
  21166. invokeHook(curTabBarPageVm, ON_HIDE);
  21167. }
  21168. }
  21169. function isSamePage(url, $page) {
  21170. return url === $page.fullPath || url === "/" && $page.meta.isEntry;
  21171. }
  21172. function getTabBarPageId(url) {
  21173. const pages = getCurrentPagesMap().values();
  21174. for (const page of pages) {
  21175. const $page = page.$page;
  21176. if (isSamePage(url, $page)) {
  21177. page.$.__isActive = true;
  21178. return $page.id;
  21179. }
  21180. }
  21181. }
  21182. const switchTab = /* @__PURE__ */ defineAsyncApi(
  21183. API_SWITCH_TAB,
  21184. // @ts-ignore
  21185. ({ url, tabBarText, isAutomatedTesting }, { resolve, reject }) => {
  21186. return removeNonTabBarPages(), navigate(
  21187. { type: API_SWITCH_TAB, url, tabBarText, isAutomatedTesting },
  21188. getTabBarPageId(url)
  21189. ).then(resolve).catch(reject);
  21190. },
  21191. SwitchTabProtocol,
  21192. SwitchTabOptions
  21193. );
  21194. const preloadPage = /* @__PURE__ */ defineAsyncApi(
  21195. API_PRELOAD_PAGE,
  21196. ({ url }, { resolve, reject }) => {
  21197. const path = url.split("?")[0];
  21198. const route = getRouteOptions(path);
  21199. if (!route) {
  21200. reject(`${url}}`);
  21201. return;
  21202. }
  21203. route.loader && route.loader().then(() => {
  21204. resolve({
  21205. url,
  21206. errMsg: "preloadPage:ok"
  21207. });
  21208. }).catch((err) => {
  21209. reject(`${url} ${String(err)}`);
  21210. });
  21211. },
  21212. PreloadPageProtocol
  21213. );
  21214. function onThemeChange(callback) {
  21215. if (__uniConfig.darkmode) {
  21216. UniServiceJSBridge.on(ON_THEME_CHANGE, callback);
  21217. }
  21218. }
  21219. function offThemeChange(callback) {
  21220. UniServiceJSBridge.off(ON_THEME_CHANGE, callback);
  21221. }
  21222. function parseTheme(pageStyle) {
  21223. let parsedStyle = {};
  21224. if (__uniConfig.darkmode) {
  21225. parsedStyle = normalizeStyles(
  21226. pageStyle,
  21227. __uniConfig.themeConfig,
  21228. getTheme()
  21229. );
  21230. }
  21231. return __uniConfig.darkmode ? parsedStyle : pageStyle;
  21232. }
  21233. function useTheme(pageStyle, onThemeChangeCallback) {
  21234. const isReactived = isReactive(pageStyle);
  21235. const reactivePageStyle = isReactived ? reactive(parseTheme(pageStyle)) : parseTheme(pageStyle);
  21236. if (__uniConfig.darkmode && isReactived) {
  21237. watch(pageStyle, (value) => {
  21238. const _pageStyle = parseTheme(value);
  21239. for (const key in _pageStyle) {
  21240. reactivePageStyle[key] = _pageStyle[key];
  21241. }
  21242. });
  21243. }
  21244. onThemeChangeCallback && onThemeChange(onThemeChangeCallback);
  21245. return reactivePageStyle;
  21246. }
  21247. const ModalTheme = {
  21248. light: {
  21249. cancelColor: "#000000"
  21250. },
  21251. dark: {
  21252. cancelColor: "rgb(170, 170, 170)"
  21253. }
  21254. };
  21255. const setCancelColor = (theme, cancelColor) => cancelColor.value = ModalTheme[theme].cancelColor;
  21256. const props$6 = {
  21257. title: {
  21258. type: String,
  21259. default: ""
  21260. },
  21261. content: {
  21262. type: String,
  21263. default: ""
  21264. },
  21265. showCancel: {
  21266. type: Boolean,
  21267. default: true
  21268. },
  21269. cancelText: {
  21270. type: String,
  21271. default: "Cancel"
  21272. },
  21273. cancelColor: {
  21274. type: String,
  21275. default: "#000000"
  21276. },
  21277. confirmText: {
  21278. type: String,
  21279. default: "OK"
  21280. },
  21281. confirmColor: {
  21282. type: String,
  21283. default: "#007aff"
  21284. },
  21285. visible: {
  21286. type: Boolean
  21287. },
  21288. editable: {
  21289. type: Boolean,
  21290. default: false
  21291. },
  21292. placeholderText: {
  21293. type: String,
  21294. default: ""
  21295. }
  21296. };
  21297. const modal = /* @__PURE__ */ defineComponent({
  21298. props: props$6,
  21299. setup(props2, {
  21300. emit: emit2
  21301. }) {
  21302. const editContent = ref("");
  21303. const close = () => visible.value = false;
  21304. const cancel = () => (close(), emit2("close", "cancel"));
  21305. const confirm = () => (close(), emit2("close", "confirm", editContent.value));
  21306. const visible = usePopup(props2, {
  21307. onEsc: cancel,
  21308. onEnter: () => {
  21309. !props2.editable && confirm();
  21310. }
  21311. });
  21312. const cancelColor = useOnThemeChange$1(props2);
  21313. return () => {
  21314. const {
  21315. title,
  21316. content,
  21317. showCancel,
  21318. confirmText,
  21319. confirmColor,
  21320. editable,
  21321. placeholderText
  21322. } = props2;
  21323. editContent.value = content;
  21324. return createVNode(Transition, {
  21325. "name": "uni-fade"
  21326. }, {
  21327. default: () => [withDirectives(createVNode("uni-modal", {
  21328. "onTouchmove": onEventPrevent
  21329. }, [VNODE_MASK, createVNode("div", {
  21330. "class": "uni-modal"
  21331. }, [title && createVNode("div", {
  21332. "class": "uni-modal__hd"
  21333. }, [createVNode("strong", {
  21334. "class": "uni-modal__title",
  21335. "textContent": title
  21336. }, null, 8, ["textContent"])]), editable ? createVNode("textarea", {
  21337. "class": "uni-modal__textarea",
  21338. "rows": "1",
  21339. "placeholder": placeholderText,
  21340. "value": content,
  21341. "onInput": (e2) => editContent.value = e2.target.value
  21342. }, null, 40, ["placeholder", "value", "onInput"]) : createVNode("div", {
  21343. "class": "uni-modal__bd",
  21344. "onTouchmovePassive": onEventStop,
  21345. "textContent": content
  21346. }, null, 40, ["onTouchmovePassive", "textContent"]), createVNode("div", {
  21347. "class": "uni-modal__ft"
  21348. }, [showCancel && createVNode("div", {
  21349. "style": {
  21350. color: cancelColor.value
  21351. },
  21352. "class": "uni-modal__btn uni-modal__btn_default",
  21353. "onClick": cancel
  21354. }, [props2.cancelText], 12, ["onClick"]), createVNode("div", {
  21355. "style": {
  21356. color: confirmColor
  21357. },
  21358. "class": "uni-modal__btn uni-modal__btn_primary",
  21359. "onClick": confirm
  21360. }, [confirmText], 12, ["onClick"])])])], 40, ["onTouchmove"]), [[vShow, visible.value]])]
  21361. });
  21362. };
  21363. }
  21364. });
  21365. function useOnThemeChange$1(props2) {
  21366. const cancelColor = ref(props2.cancelColor);
  21367. const _onThemeChange = ({
  21368. theme
  21369. }) => {
  21370. setCancelColor(theme, cancelColor);
  21371. };
  21372. watchEffect(() => {
  21373. if (props2.visible) {
  21374. cancelColor.value = props2.cancelColor;
  21375. if (props2.cancelColor === "#000") {
  21376. if (getTheme() === "dark")
  21377. _onThemeChange({
  21378. theme: "dark"
  21379. });
  21380. onThemeChange(_onThemeChange);
  21381. }
  21382. } else {
  21383. offThemeChange(_onThemeChange);
  21384. }
  21385. });
  21386. return cancelColor;
  21387. }
  21388. let showModalState;
  21389. const onHidePopupOnce$1 = /* @__PURE__ */ once(() => {
  21390. UniServiceJSBridge.on("onHidePopup", () => showModalState.visible = false);
  21391. });
  21392. let currentShowModalResolve;
  21393. function onModalClose(type, content) {
  21394. const isConfirm = type === "confirm";
  21395. const res = {
  21396. confirm: isConfirm,
  21397. cancel: type === "cancel"
  21398. };
  21399. isConfirm && showModalState.editable && (res.content = content);
  21400. currentShowModalResolve && currentShowModalResolve(res);
  21401. }
  21402. const hideModal = () => {
  21403. if (showModalState) {
  21404. showModalState.visible = false;
  21405. }
  21406. };
  21407. const showModal = /* @__PURE__ */ defineAsyncApi(
  21408. API_SHOW_MODAL,
  21409. (args, { resolve }) => {
  21410. onHidePopupOnce$1();
  21411. currentShowModalResolve = resolve;
  21412. if (!showModalState) {
  21413. showModalState = reactive(args);
  21414. nextTick(
  21415. () => (createRootApp(modal, showModalState, onModalClose).mount(
  21416. ensureRoot("u-a-m")
  21417. ), //下一帧执行,确保首次显示时有动画效果
  21418. nextTick(() => showModalState.visible = true))
  21419. );
  21420. } else {
  21421. extend(showModalState, args);
  21422. showModalState.visible = true;
  21423. }
  21424. },
  21425. ShowModalProtocol,
  21426. ShowModalOptions
  21427. );
  21428. const props$5 = {
  21429. title: {
  21430. type: String,
  21431. default: ""
  21432. },
  21433. icon: {
  21434. default: "success",
  21435. validator(value) {
  21436. return SHOW_TOAST_ICON.indexOf(value) !== -1;
  21437. }
  21438. },
  21439. image: {
  21440. type: String,
  21441. default: ""
  21442. },
  21443. duration: {
  21444. type: Number,
  21445. default: 1500
  21446. },
  21447. mask: {
  21448. type: Boolean,
  21449. default: false
  21450. },
  21451. visible: {
  21452. type: Boolean
  21453. }
  21454. };
  21455. const ToastIconClassName = "uni-toast__icon";
  21456. const ICONCOLOR = {
  21457. light: "#fff",
  21458. dark: "rgba(255,255,255,0.9)"
  21459. };
  21460. const getIconColor = (theme) => ICONCOLOR[theme];
  21461. const Toast = /* @__PURE__ */ defineComponent({
  21462. name: "Toast",
  21463. props: props$5,
  21464. setup(props2) {
  21465. initI18nShowToastMsgsOnce();
  21466. initI18nShowLoadingMsgsOnce();
  21467. const {
  21468. Icon
  21469. } = useToastIcon(props2);
  21470. const visible = usePopup(props2, {});
  21471. return () => {
  21472. const {
  21473. mask,
  21474. duration,
  21475. title,
  21476. image: image2
  21477. } = props2;
  21478. return createVNode(Transition, {
  21479. "name": "uni-fade"
  21480. }, {
  21481. default: () => [withDirectives(createVNode("uni-toast", {
  21482. "data-duration": duration
  21483. }, [mask ? createVNode("div", {
  21484. "class": "uni-mask",
  21485. "style": "background: transparent;",
  21486. "onTouchmove": onEventPrevent
  21487. }, null, 40, ["onTouchmove"]) : "", !image2 && !Icon.value ? createVNode("div", {
  21488. "class": "uni-sample-toast"
  21489. }, [createVNode("p", {
  21490. "class": "uni-simple-toast__text"
  21491. }, [title])]) : createVNode("div", {
  21492. "class": "uni-toast"
  21493. }, [image2 ? createVNode("img", {
  21494. "src": image2,
  21495. "class": ToastIconClassName
  21496. }, null, 10, ["src"]) : Icon.value, createVNode("p", {
  21497. "class": "uni-toast__content"
  21498. }, [title])])], 8, ["data-duration"]), [[vShow, visible.value]])]
  21499. });
  21500. };
  21501. }
  21502. });
  21503. function useToastIcon(props2) {
  21504. const iconColor = ref(getIconColor(getTheme()));
  21505. const _onThemeChange = ({
  21506. theme
  21507. }) => iconColor.value = getIconColor(theme);
  21508. watchEffect(() => {
  21509. if (props2.visible) {
  21510. onThemeChange(_onThemeChange);
  21511. } else {
  21512. offThemeChange(_onThemeChange);
  21513. }
  21514. });
  21515. const Icon = computed(() => {
  21516. switch (props2.icon) {
  21517. case "success":
  21518. return createVNode(createSvgIconVNode(ICON_PATH_SUCCESS_NO_CIRCLE, iconColor.value, 38), {
  21519. class: ToastIconClassName
  21520. });
  21521. case "error":
  21522. return createVNode(createSvgIconVNode(ICON_PATH_WARN, iconColor.value, 38), {
  21523. class: ToastIconClassName
  21524. });
  21525. case "loading":
  21526. return createVNode("i", {
  21527. "class": [ToastIconClassName, "uni-loading"]
  21528. }, null, 2);
  21529. default:
  21530. return null;
  21531. }
  21532. });
  21533. return {
  21534. Icon
  21535. };
  21536. }
  21537. let showToastState;
  21538. let showType = "";
  21539. let timeoutId;
  21540. const scope = /* @__PURE__ */ effectScope();
  21541. function watchVisible() {
  21542. scope.run(() => {
  21543. watch(
  21544. [() => showToastState.visible, () => showToastState.duration],
  21545. ([visible, duration]) => {
  21546. if (visible) {
  21547. timeoutId && clearTimeout(timeoutId);
  21548. if (showType === "onShowLoading")
  21549. return;
  21550. timeoutId = setTimeout(() => {
  21551. hidePopup("onHideToast");
  21552. }, duration);
  21553. } else {
  21554. timeoutId && clearTimeout(timeoutId);
  21555. }
  21556. }
  21557. );
  21558. });
  21559. }
  21560. function createToast(args) {
  21561. if (!showToastState) {
  21562. showToastState = reactive(extend(args, { visible: false }));
  21563. nextTick(() => {
  21564. watchVisible();
  21565. UniServiceJSBridge.on("onHidePopup", () => hidePopup("onHidePopup"));
  21566. createRootApp(Toast, showToastState, () => {
  21567. }).mount(ensureRoot("u-a-t"));
  21568. });
  21569. } else {
  21570. extend(showToastState, args);
  21571. }
  21572. setTimeout(() => {
  21573. showToastState.visible = true;
  21574. }, 10);
  21575. }
  21576. const showToast = /* @__PURE__ */ defineAsyncApi(
  21577. API_SHOW_TOAST,
  21578. (args, { resolve, reject }) => {
  21579. createToast(args);
  21580. showType = "onShowToast";
  21581. resolve();
  21582. },
  21583. ShowToastProtocol,
  21584. ShowToastOptions
  21585. );
  21586. const showLoadingDefaultState = {
  21587. icon: "loading",
  21588. duration: 1e8,
  21589. image: ""
  21590. };
  21591. const showLoading = /* @__PURE__ */ defineAsyncApi(
  21592. API_SHOW_LOADING,
  21593. (args, { resolve, reject }) => {
  21594. extend(args, showLoadingDefaultState);
  21595. createToast(args);
  21596. showType = "onShowLoading";
  21597. resolve();
  21598. },
  21599. ShowLoadingProtocol,
  21600. ShowLoadingOptions
  21601. );
  21602. const hideToast = /* @__PURE__ */ defineAsyncApi(
  21603. API_HIDE_TOAST,
  21604. (args, { resolve, reject }) => {
  21605. hidePopup("onHideToast");
  21606. resolve();
  21607. }
  21608. );
  21609. const hideLoading = /* @__PURE__ */ defineAsyncApi(
  21610. API_HIDE_LOADING,
  21611. (args, { resolve, reject }) => {
  21612. hidePopup("onHideLoading");
  21613. resolve();
  21614. }
  21615. );
  21616. function hidePopup(type) {
  21617. const { t: t2 } = useI18n();
  21618. if (!showType) {
  21619. return;
  21620. }
  21621. let warnMsg = "";
  21622. if (type === "onHideToast" && showType !== "onShowToast") {
  21623. warnMsg = t2("uni.showToast.unpaired");
  21624. } else if (type === "onHideLoading" && showType !== "onShowLoading") {
  21625. warnMsg = t2("uni.showLoading.unpaired");
  21626. }
  21627. if (warnMsg) {
  21628. return console.warn(warnMsg);
  21629. }
  21630. showType = "";
  21631. setTimeout(() => {
  21632. showToastState.visible = false;
  21633. }, 10);
  21634. }
  21635. function usePopupStyle(props2) {
  21636. const popupWidth = ref(0);
  21637. const popupHeight = ref(0);
  21638. const isDesktop = computed(
  21639. () => popupWidth.value >= 500 && popupHeight.value >= 500
  21640. );
  21641. const popupStyle = computed(() => {
  21642. const style = {
  21643. content: {
  21644. transform: "",
  21645. left: "",
  21646. top: "",
  21647. bottom: ""
  21648. },
  21649. triangle: {
  21650. left: "",
  21651. top: "",
  21652. bottom: "",
  21653. "border-width": "",
  21654. "border-color": ""
  21655. }
  21656. };
  21657. const contentStyle = style.content;
  21658. const triangleStyle = style.triangle;
  21659. const popover = props2.popover;
  21660. function getNumber(value) {
  21661. return Number(value) || 0;
  21662. }
  21663. if (isDesktop.value && popover) {
  21664. extend(triangleStyle, {
  21665. position: "absolute",
  21666. width: "0",
  21667. height: "0",
  21668. "margin-left": "-6px",
  21669. "border-style": "solid"
  21670. });
  21671. const popoverLeft = getNumber(popover.left);
  21672. const popoverWidth = getNumber(popover.width);
  21673. const popoverTop = getNumber(popover.top);
  21674. const popoverHeight = getNumber(popover.height);
  21675. const center = popoverLeft + popoverWidth / 2;
  21676. contentStyle.transform = "none !important";
  21677. const contentLeft = Math.max(0, center - 300 / 2);
  21678. contentStyle.left = `${contentLeft}px`;
  21679. let triangleLeft = Math.max(12, center - contentLeft);
  21680. triangleLeft = Math.min(300 - 12, triangleLeft);
  21681. triangleStyle.left = `${triangleLeft}px`;
  21682. const vcl = popupHeight.value / 2;
  21683. if (popoverTop + popoverHeight - vcl > vcl - popoverTop) {
  21684. contentStyle.top = "auto";
  21685. contentStyle.bottom = `${popupHeight.value - popoverTop + 6}px`;
  21686. triangleStyle.bottom = "-6px";
  21687. triangleStyle["border-width"] = "6px 6px 0 6px";
  21688. triangleStyle["border-color"] = "#fcfcfd transparent transparent transparent";
  21689. } else {
  21690. contentStyle.top = `${popoverTop + popoverHeight + 6}px`;
  21691. triangleStyle.top = "-6px";
  21692. triangleStyle["border-width"] = "0 6px 6px 6px";
  21693. triangleStyle["border-color"] = "transparent transparent #fcfcfd transparent";
  21694. }
  21695. }
  21696. return style;
  21697. });
  21698. onMounted(() => {
  21699. const fixSize = () => {
  21700. const { windowWidth, windowHeight, windowTop } = uni.getSystemInfoSync();
  21701. popupWidth.value = windowWidth;
  21702. popupHeight.value = windowHeight + (windowTop || 0);
  21703. };
  21704. window.addEventListener("resize", fixSize);
  21705. fixSize();
  21706. onUnmounted(() => {
  21707. window.removeEventListener("resize", fixSize);
  21708. });
  21709. });
  21710. return {
  21711. isDesktop,
  21712. popupStyle
  21713. };
  21714. }
  21715. const ACTION_SHEET_THEME = {
  21716. light: {
  21717. listItemColor: "#000000",
  21718. cancelItemColor: "#000000"
  21719. },
  21720. dark: {
  21721. listItemColor: "rgba(255, 255, 255, 0.8)",
  21722. cancelItemColor: "rgba(255, 255, 255)"
  21723. }
  21724. };
  21725. function setActionSheetTheme(theme, actionSheetTheme) {
  21726. const ActionSheetThemeKey = ["listItemColor", "cancelItemColor"];
  21727. ActionSheetThemeKey.forEach((key) => {
  21728. actionSheetTheme[key] = ACTION_SHEET_THEME[theme][key];
  21729. });
  21730. }
  21731. const props$4 = {
  21732. title: {
  21733. type: String,
  21734. default: ""
  21735. },
  21736. itemList: {
  21737. type: Array,
  21738. default() {
  21739. return [];
  21740. }
  21741. },
  21742. itemColor: {
  21743. type: String,
  21744. default: "#000000"
  21745. },
  21746. popover: {
  21747. type: Object,
  21748. default: null
  21749. },
  21750. visible: {
  21751. type: Boolean,
  21752. default: false
  21753. }
  21754. };
  21755. const actionSheet = /* @__PURE__ */ defineComponent({
  21756. name: "ActionSheet",
  21757. props: props$4,
  21758. emits: ["close"],
  21759. setup(props2, {
  21760. emit: emit2
  21761. }) {
  21762. initI18nShowActionSheetMsgsOnce();
  21763. const HEIGHT = ref(260);
  21764. const contentHeight = ref(0);
  21765. const titleHeight = ref(0);
  21766. const deltaY = ref(0);
  21767. const scrollTop = ref(0);
  21768. const content = ref(null);
  21769. const main = ref(null);
  21770. const {
  21771. t: t2
  21772. } = useI18n();
  21773. const {
  21774. _close
  21775. } = useActionSheetLoader(props2, emit2);
  21776. const {
  21777. popupStyle
  21778. } = usePopupStyle(props2);
  21779. let scroller;
  21780. onMounted(() => {
  21781. const {
  21782. scroller: _scroller,
  21783. handleTouchStart,
  21784. handleTouchMove,
  21785. handleTouchEnd
  21786. } = useScroller(content.value, {
  21787. enableY: true,
  21788. friction: new Friction(1e-4),
  21789. spring: new Spring(2, 90, 20),
  21790. onScroll: (e2) => {
  21791. scrollTop.value = e2.target.scrollTop;
  21792. }
  21793. });
  21794. scroller = _scroller;
  21795. useTouchtrack(content.value, (e2) => {
  21796. if (_scroller) {
  21797. switch (e2.detail.state) {
  21798. case "start":
  21799. handleTouchStart(e2);
  21800. break;
  21801. case "move":
  21802. handleTouchMove(e2);
  21803. break;
  21804. case "end":
  21805. case "cancel":
  21806. handleTouchEnd(e2);
  21807. }
  21808. }
  21809. }, true);
  21810. });
  21811. function _handleWheel($event) {
  21812. const _deltaY = deltaY.value + $event.deltaY;
  21813. if (Math.abs(_deltaY) > 10) {
  21814. scrollTop.value += _deltaY / 3;
  21815. scrollTop.value = scrollTop.value >= contentHeight.value ? contentHeight.value : scrollTop.value <= 0 ? 0 : scrollTop.value;
  21816. scroller.scrollTo(scrollTop.value);
  21817. } else {
  21818. deltaY.value = _deltaY;
  21819. }
  21820. $event.preventDefault();
  21821. }
  21822. watch(() => props2.visible, () => {
  21823. nextTick(() => {
  21824. if (props2.title) {
  21825. titleHeight.value = document.querySelector(".uni-actionsheet__title").offsetHeight;
  21826. }
  21827. scroller.update();
  21828. if (content.value)
  21829. contentHeight.value = content.value.clientHeight - HEIGHT.value;
  21830. document.querySelectorAll(".uni-actionsheet__cell").forEach((item) => {
  21831. initClick(item);
  21832. });
  21833. });
  21834. });
  21835. const actionSheetTheme = useOnThemeChange(props2);
  21836. return () => {
  21837. return createVNode("uni-actionsheet", {
  21838. "onTouchmove": onEventPrevent
  21839. }, [createVNode(Transition, {
  21840. "name": "uni-fade"
  21841. }, {
  21842. default: () => [withDirectives(createVNode("div", {
  21843. "class": "uni-mask uni-actionsheet__mask",
  21844. "onClick": () => _close(-1)
  21845. }, null, 8, ["onClick"]), [[vShow, props2.visible]])]
  21846. }), createVNode("div", {
  21847. "class": ["uni-actionsheet", {
  21848. "uni-actionsheet_toggle": props2.visible
  21849. }],
  21850. "style": popupStyle.value.content
  21851. }, [createVNode("div", {
  21852. "ref": main,
  21853. "class": "uni-actionsheet__menu",
  21854. "onWheel": _handleWheel
  21855. }, [props2.title ? createVNode(Fragment, null, [createVNode("div", {
  21856. "class": "uni-actionsheet__cell",
  21857. "style": {
  21858. height: `${titleHeight.value}px`
  21859. }
  21860. }, null), createVNode("div", {
  21861. "class": "uni-actionsheet__title"
  21862. }, [props2.title])]) : "", createVNode("div", {
  21863. "style": {
  21864. maxHeight: `${HEIGHT.value}px`,
  21865. overflow: "hidden"
  21866. }
  21867. }, [createVNode("div", {
  21868. "ref": content
  21869. }, [props2.itemList.map((itemTitle, index2) => createVNode("div", {
  21870. "key": index2,
  21871. "style": {
  21872. color: actionSheetTheme.listItemColor
  21873. },
  21874. "class": "uni-actionsheet__cell",
  21875. "onClick": () => _close(index2)
  21876. }, [itemTitle], 12, ["onClick"]))], 512)])], 40, ["onWheel"]), createVNode("div", {
  21877. "class": "uni-actionsheet__action"
  21878. }, [createVNode("div", {
  21879. "style": {
  21880. color: actionSheetTheme.cancelItemColor
  21881. },
  21882. "class": "uni-actionsheet__cell",
  21883. "onClick": () => _close(-1)
  21884. }, [t2("uni.showActionSheet.cancel")], 12, ["onClick"])]), createVNode("div", {
  21885. "style": popupStyle.value.triangle
  21886. }, null, 4)], 6)], 40, ["onTouchmove"]);
  21887. };
  21888. }
  21889. });
  21890. function useActionSheetLoader(props2, emit2) {
  21891. function _close(tapIndex) {
  21892. emit2("close", tapIndex);
  21893. }
  21894. const {
  21895. key,
  21896. disable
  21897. } = useKeyboard();
  21898. watch(() => props2.visible, (value) => disable.value = !value);
  21899. watchEffect(() => {
  21900. const {
  21901. value
  21902. } = key;
  21903. if (value === "esc") {
  21904. _close && _close(-1);
  21905. }
  21906. });
  21907. return {
  21908. _close
  21909. };
  21910. }
  21911. function initClick(dom) {
  21912. const MAX_MOVE = 20;
  21913. let x = 0;
  21914. let y = 0;
  21915. dom.addEventListener("touchstart", (event) => {
  21916. const info = event.changedTouches[0];
  21917. x = info.clientX;
  21918. y = info.clientY;
  21919. });
  21920. dom.addEventListener("touchend", (event) => {
  21921. const info = event.changedTouches[0];
  21922. if (Math.abs(info.clientX - x) < MAX_MOVE && Math.abs(info.clientY - y) < MAX_MOVE) {
  21923. const target = event.target;
  21924. const currentTarget = event.currentTarget;
  21925. const customEvent = new CustomEvent("click", {
  21926. bubbles: true,
  21927. cancelable: true,
  21928. target,
  21929. currentTarget
  21930. });
  21931. ["screenX", "screenY", "clientX", "clientY", "pageX", "pageY"].forEach((key) => {
  21932. customEvent[key] = info[key];
  21933. });
  21934. event.target.dispatchEvent(customEvent);
  21935. }
  21936. });
  21937. }
  21938. function useOnThemeChange(props2) {
  21939. const actionSheetTheme = reactive({
  21940. listItemColor: "#000",
  21941. cancelItemColor: "#000"
  21942. });
  21943. const _onThemeChange = ({
  21944. theme
  21945. }) => {
  21946. setActionSheetTheme(theme, actionSheetTheme);
  21947. };
  21948. watchEffect(() => {
  21949. if (props2.visible) {
  21950. actionSheetTheme.listItemColor = actionSheetTheme.cancelItemColor = props2.itemColor;
  21951. if (props2.itemColor === "#000") {
  21952. _onThemeChange({
  21953. theme: getTheme()
  21954. });
  21955. onThemeChange(_onThemeChange);
  21956. }
  21957. } else {
  21958. offThemeChange(_onThemeChange);
  21959. }
  21960. });
  21961. return actionSheetTheme;
  21962. }
  21963. let resolveAction;
  21964. let rejectAction;
  21965. let showActionSheetState;
  21966. const onHidePopupOnce = /* @__PURE__ */ once(() => {
  21967. UniServiceJSBridge.on(
  21968. "onHidePopup",
  21969. () => showActionSheetState.visible = false
  21970. );
  21971. });
  21972. function onActionSheetClose(tapIndex) {
  21973. if (tapIndex === -1) {
  21974. rejectAction && rejectAction("cancel");
  21975. } else {
  21976. resolveAction && resolveAction({ tapIndex });
  21977. }
  21978. }
  21979. const hideActionSheet = () => {
  21980. if (showActionSheetState) {
  21981. showActionSheetState.visible = false;
  21982. }
  21983. };
  21984. const showActionSheet = /* @__PURE__ */ defineAsyncApi(
  21985. API_SHOW_ACTION_SHEET,
  21986. (args, { resolve, reject }) => {
  21987. onHidePopupOnce();
  21988. resolveAction = resolve;
  21989. rejectAction = reject;
  21990. if (!showActionSheetState) {
  21991. showActionSheetState = reactive(args);
  21992. nextTick(
  21993. () => (createRootApp(
  21994. actionSheet,
  21995. showActionSheetState,
  21996. onActionSheetClose
  21997. ).mount(ensureRoot("u-s-a-s")), //下一帧执行,确保首次显示时有动画效果
  21998. nextTick(() => showActionSheetState.visible = true))
  21999. );
  22000. } else {
  22001. extend(showActionSheetState, args);
  22002. showActionSheetState.visible = true;
  22003. }
  22004. },
  22005. ShowActionSheetProtocol,
  22006. ShowActionSheetOptions
  22007. );
  22008. const loadFontFace = /* @__PURE__ */ defineAsyncApi(
  22009. API_LOAD_FONT_FACE,
  22010. ({ family, source, desc }, { resolve, reject }) => {
  22011. if (source.startsWith(`url("`) || source.startsWith(`url('`)) {
  22012. source = `url('${getRealPath(source.substring(5, source.length - 2))}')`;
  22013. } else if (source.startsWith("url(")) {
  22014. source = `url('${getRealPath(source.substring(4, source.length - 1))}')`;
  22015. } else {
  22016. source = getRealPath(source);
  22017. }
  22018. addFont(family, source, desc).then(() => {
  22019. resolve();
  22020. }).catch((err) => {
  22021. reject(`loadFontFace:fail ${err}`);
  22022. });
  22023. },
  22024. LoadFontFaceProtocol
  22025. );
  22026. function updateDocumentTitle(title) {
  22027. {
  22028. document.title = title;
  22029. }
  22030. UniServiceJSBridge.emit(ON_NAVIGATION_BAR_CHANGE, { titleText: title });
  22031. }
  22032. function useDocumentTitle(pageMeta) {
  22033. function update() {
  22034. updateDocumentTitle(pageMeta.navigationBar.titleText);
  22035. }
  22036. watchEffect(update);
  22037. onActivated(update);
  22038. }
  22039. function setNavigationBar(pageMeta, type, args, resolve, reject) {
  22040. if (!pageMeta) {
  22041. return reject("page not found");
  22042. }
  22043. const { navigationBar } = pageMeta;
  22044. switch (type) {
  22045. case API_SET_NAVIGATION_BAR_COLOR:
  22046. const { frontColor, backgroundColor, animation: animation2 } = args;
  22047. const { duration, timingFunc } = animation2;
  22048. if (frontColor) {
  22049. navigationBar.titleColor = frontColor === "#000000" ? "#000000" : "#ffffff";
  22050. }
  22051. if (backgroundColor) {
  22052. navigationBar.backgroundColor = backgroundColor;
  22053. }
  22054. navigationBar.duration = duration + "ms";
  22055. navigationBar.timingFunc = timingFunc;
  22056. break;
  22057. case API_SHOW_NAVIGATION_BAR_LOADING:
  22058. navigationBar.loading = true;
  22059. break;
  22060. case API_HIDE_NAVIGATION_BAR_LOADING:
  22061. navigationBar.loading = false;
  22062. break;
  22063. case API_SET_NAVIGATION_BAR_TITLE:
  22064. const { title } = args;
  22065. navigationBar.titleText = title;
  22066. break;
  22067. }
  22068. resolve();
  22069. }
  22070. const setNavigationBarColor = /* @__PURE__ */ defineAsyncApi(
  22071. API_SET_NAVIGATION_BAR_COLOR,
  22072. (args, { resolve, reject }) => {
  22073. setNavigationBar(
  22074. getCurrentPageMeta(),
  22075. API_SET_NAVIGATION_BAR_COLOR,
  22076. args,
  22077. resolve,
  22078. reject
  22079. );
  22080. },
  22081. SetNavigationBarColorProtocol,
  22082. SetNavigationBarColorOptions
  22083. );
  22084. const showNavigationBarLoading = /* @__PURE__ */ defineAsyncApi(
  22085. API_SHOW_NAVIGATION_BAR_LOADING,
  22086. (args, { resolve, reject }) => {
  22087. setNavigationBar(
  22088. getCurrentPageMeta(),
  22089. API_SHOW_NAVIGATION_BAR_LOADING,
  22090. args || {},
  22091. resolve,
  22092. reject
  22093. );
  22094. }
  22095. );
  22096. const hideNavigationBarLoading = /* @__PURE__ */ defineAsyncApi(
  22097. API_HIDE_NAVIGATION_BAR_LOADING,
  22098. (args, { resolve, reject }) => {
  22099. setNavigationBar(
  22100. getCurrentPageMeta(),
  22101. API_HIDE_NAVIGATION_BAR_LOADING,
  22102. args || {},
  22103. resolve,
  22104. reject
  22105. );
  22106. }
  22107. );
  22108. const setNavigationBarTitle = /* @__PURE__ */ defineAsyncApi(
  22109. API_SET_NAVIGATION_BAR_TITLE,
  22110. (args, { resolve, reject }) => {
  22111. setNavigationBar(
  22112. getCurrentPageMeta(),
  22113. API_SET_NAVIGATION_BAR_TITLE,
  22114. args,
  22115. resolve,
  22116. reject
  22117. );
  22118. },
  22119. SetNavigationBarTitleProtocol
  22120. );
  22121. const pageScrollTo = /* @__PURE__ */ defineAsyncApi(
  22122. API_PAGE_SCROLL_TO,
  22123. ({ scrollTop, selector, duration }, { resolve }) => {
  22124. scrollTo(selector || scrollTop || 0, duration, true);
  22125. resolve();
  22126. },
  22127. PageScrollToProtocol,
  22128. PageScrollToOptions
  22129. );
  22130. const startPullDownRefresh = /* @__PURE__ */ defineAsyncApi(
  22131. API_START_PULL_DOWN_REFRESH,
  22132. (_args, { resolve }) => {
  22133. UniServiceJSBridge.invokeViewMethod(
  22134. API_START_PULL_DOWN_REFRESH,
  22135. {},
  22136. getCurrentPageId()
  22137. );
  22138. resolve();
  22139. }
  22140. );
  22141. const stopPullDownRefresh = /* @__PURE__ */ defineAsyncApi(
  22142. API_STOP_PULL_DOWN_REFRESH,
  22143. (_args, { resolve }) => {
  22144. UniServiceJSBridge.invokeViewMethod(
  22145. API_STOP_PULL_DOWN_REFRESH,
  22146. {},
  22147. getCurrentPageId()
  22148. );
  22149. resolve();
  22150. }
  22151. );
  22152. const setTabBarItemProps = [
  22153. "text",
  22154. "iconPath",
  22155. "iconfont",
  22156. "selectedIconPath",
  22157. "visible"
  22158. ];
  22159. const setTabBarStyleProps = [
  22160. "color",
  22161. "selectedColor",
  22162. "backgroundColor",
  22163. "borderStyle",
  22164. "midButton"
  22165. ];
  22166. const setTabBarBadgeProps = ["badge", "redDot"];
  22167. function setProperties(item, props2, propsData) {
  22168. props2.forEach(function(name) {
  22169. if (hasOwn(propsData, name)) {
  22170. item[name] = propsData[name];
  22171. }
  22172. });
  22173. }
  22174. function setTabBar(type, args, resolve) {
  22175. const tabBar2 = useTabBar();
  22176. switch (type) {
  22177. case API_SHOW_TAB_BAR:
  22178. tabBar2.shown = true;
  22179. break;
  22180. case API_HIDE_TAB_BAR:
  22181. tabBar2.shown = false;
  22182. break;
  22183. case API_SET_TAB_BAR_ITEM:
  22184. const { index: index2 } = args;
  22185. const tabBarItem = tabBar2.list[index2];
  22186. const oldPagePath = tabBarItem.pagePath;
  22187. setProperties(tabBarItem, setTabBarItemProps, args);
  22188. const { pagePath } = args;
  22189. if (pagePath) {
  22190. const newPagePath = addLeadingSlash(pagePath);
  22191. if (newPagePath !== oldPagePath) {
  22192. normalizeTabBarRoute(index2, oldPagePath, newPagePath);
  22193. }
  22194. }
  22195. break;
  22196. case API_SET_TAB_BAR_STYLE:
  22197. setProperties(tabBar2, setTabBarStyleProps, args);
  22198. break;
  22199. case API_SHOW_TAB_BAR_RED_DOT:
  22200. setProperties(tabBar2.list[args.index], setTabBarBadgeProps, {
  22201. badge: "",
  22202. redDot: true
  22203. });
  22204. break;
  22205. case API_SET_TAB_BAR_BADGE:
  22206. setProperties(tabBar2.list[args.index], setTabBarBadgeProps, {
  22207. badge: args.text,
  22208. redDot: true
  22209. });
  22210. break;
  22211. case API_HIDE_TAB_BAR_RED_DOT:
  22212. case API_REMOVE_TAB_BAR_BADGE:
  22213. setProperties(tabBar2.list[args.index], setTabBarBadgeProps, {
  22214. badge: "",
  22215. redDot: false
  22216. });
  22217. break;
  22218. }
  22219. resolve();
  22220. }
  22221. const setTabBarItem = /* @__PURE__ */ defineAsyncApi(
  22222. API_SET_TAB_BAR_ITEM,
  22223. (args, { resolve }) => {
  22224. setTabBar(API_SET_TAB_BAR_ITEM, args, resolve);
  22225. },
  22226. SetTabBarItemProtocol,
  22227. SetTabBarItemOptions
  22228. );
  22229. const setTabBarStyle = /* @__PURE__ */ defineAsyncApi(
  22230. API_SET_TAB_BAR_STYLE,
  22231. (args, { resolve }) => {
  22232. setTabBar(API_SET_TAB_BAR_STYLE, args, resolve);
  22233. },
  22234. SetTabBarStyleProtocol,
  22235. SetTabBarStyleOptions
  22236. );
  22237. const hideTabBar = /* @__PURE__ */ defineAsyncApi(
  22238. API_HIDE_TAB_BAR,
  22239. (args, { resolve }) => {
  22240. setTabBar(API_HIDE_TAB_BAR, args ? args : {}, resolve);
  22241. },
  22242. HideTabBarProtocol
  22243. );
  22244. const showTabBar = /* @__PURE__ */ defineAsyncApi(
  22245. API_SHOW_TAB_BAR,
  22246. (args, { resolve }) => {
  22247. setTabBar(API_SHOW_TAB_BAR, args ? args : {}, resolve);
  22248. },
  22249. ShowTabBarProtocol
  22250. );
  22251. const hideTabBarRedDot = /* @__PURE__ */ defineAsyncApi(
  22252. API_HIDE_TAB_BAR_RED_DOT,
  22253. (args, { resolve }) => {
  22254. setTabBar(API_HIDE_TAB_BAR_RED_DOT, args, resolve);
  22255. },
  22256. HideTabBarRedDotProtocol,
  22257. HideTabBarRedDotOptions
  22258. );
  22259. const showTabBarRedDot = /* @__PURE__ */ defineAsyncApi(
  22260. API_SHOW_TAB_BAR_RED_DOT,
  22261. (args, { resolve }) => {
  22262. setTabBar(API_SHOW_TAB_BAR_RED_DOT, args, resolve);
  22263. },
  22264. ShowTabBarRedDotProtocol,
  22265. ShowTabBarRedDotOptions
  22266. );
  22267. const removeTabBarBadge = /* @__PURE__ */ defineAsyncApi(
  22268. API_REMOVE_TAB_BAR_BADGE,
  22269. (args, { resolve }) => {
  22270. setTabBar(API_REMOVE_TAB_BAR_BADGE, args, resolve);
  22271. },
  22272. RemoveTabBarBadgeProtocol,
  22273. RemoveTabBarBadgeOptions
  22274. );
  22275. const setTabBarBadge = /* @__PURE__ */ defineAsyncApi(
  22276. API_SET_TAB_BAR_BADGE,
  22277. (args, { resolve }) => {
  22278. setTabBar(API_SET_TAB_BAR_BADGE, args, resolve);
  22279. },
  22280. SetTabBarBadgeProtocol,
  22281. SetTabBarBadgeOptions
  22282. );
  22283. const UNI_TABBAR_ICON_FONT = "UniTabbarIconFont";
  22284. const _middleButton = {
  22285. width: "50px",
  22286. height: "50px",
  22287. iconWidth: "24px"
  22288. };
  22289. const TabBar = /* @__PURE__ */ defineSystemComponent({
  22290. name: "TabBar",
  22291. setup() {
  22292. const visibleList = ref([]);
  22293. const _tabBar = useTabBar();
  22294. const tabBar2 = useTheme(_tabBar, () => {
  22295. const tabBarStyle = parseTheme(_tabBar);
  22296. tabBar2.backgroundColor = tabBarStyle.backgroundColor;
  22297. tabBar2.borderStyle = tabBarStyle.borderStyle;
  22298. tabBar2.color = tabBarStyle.color;
  22299. tabBar2.selectedColor = tabBarStyle.selectedColor;
  22300. tabBar2.blurEffect = tabBarStyle.blurEffect;
  22301. if (tabBarStyle.list && tabBarStyle.list.length) {
  22302. tabBarStyle.list.forEach((item, index2) => {
  22303. tabBar2.list[index2].iconPath = item.iconPath;
  22304. tabBar2.list[index2].selectedIconPath = item.selectedIconPath;
  22305. });
  22306. }
  22307. });
  22308. useVisibleList(tabBar2, visibleList);
  22309. useTabBarCssVar(tabBar2);
  22310. const onSwitchTab = useSwitchTab(useRoute(), tabBar2, visibleList);
  22311. const {
  22312. style,
  22313. borderStyle,
  22314. placeholderStyle
  22315. } = useTabBarStyle(tabBar2);
  22316. onMounted(() => {
  22317. if (tabBar2.iconfontSrc) {
  22318. loadFontFace({
  22319. family: UNI_TABBAR_ICON_FONT,
  22320. source: `url("${tabBar2.iconfontSrc}")`
  22321. });
  22322. }
  22323. });
  22324. return () => {
  22325. const tabBarItemsTsx = createTabBarItemsTsx(tabBar2, onSwitchTab, visibleList);
  22326. return createVNode("uni-tabbar", {
  22327. "class": "uni-tabbar-" + tabBar2.position
  22328. }, [createVNode("div", {
  22329. "class": "uni-tabbar",
  22330. "style": style.value
  22331. }, [createVNode("div", {
  22332. "class": "uni-tabbar-border",
  22333. "style": borderStyle.value
  22334. }, null, 4), tabBarItemsTsx], 4), createVNode("div", {
  22335. "class": "uni-placeholder",
  22336. "style": placeholderStyle.value
  22337. }, null, 4)], 2);
  22338. };
  22339. }
  22340. });
  22341. function useTabBarCssVar(tabBar2) {
  22342. watch(() => tabBar2.shown, (value) => {
  22343. updatePageCssVar({
  22344. "--window-bottom": normalizeWindowBottom(value ? parseInt(tabBar2.height) : 0)
  22345. });
  22346. });
  22347. }
  22348. function useVisibleList(tabBar2, visibleList) {
  22349. const internalMidButton = ref(extend({
  22350. type: "midButton"
  22351. }, tabBar2.midButton));
  22352. function setVisibleList() {
  22353. let tempList = [];
  22354. tempList = tabBar2.list.filter((item) => item.visible !== false);
  22355. if (__UNI_FEATURE_TABBAR_MIDBUTTON__ && tabBar2.midButton) {
  22356. internalMidButton.value = extend({}, _middleButton, internalMidButton.value, tabBar2.midButton);
  22357. tempList = tempList.filter((item) => !isMidButton(item));
  22358. if (tempList.length % 2 === 0) {
  22359. tempList.splice(Math.floor(tempList.length / 2), 0, internalMidButton.value);
  22360. }
  22361. }
  22362. visibleList.value = tempList;
  22363. }
  22364. watchEffect(setVisibleList);
  22365. }
  22366. function useSwitchTab(route, tabBar2, visibleList) {
  22367. watchEffect(() => {
  22368. const meta = route.meta;
  22369. if (meta.isTabBar) {
  22370. const pagePath = meta.route;
  22371. const index2 = visibleList.value.findIndex((item) => item.pagePath === pagePath);
  22372. tabBar2.selectedIndex = index2;
  22373. }
  22374. });
  22375. return (tabBarItem, index2) => {
  22376. const {
  22377. type
  22378. } = tabBarItem;
  22379. return () => {
  22380. if (__UNI_FEATURE_TABBAR_MIDBUTTON__ && type === "midButton") {
  22381. return UniServiceJSBridge.invokeOnCallback(API_ON_TAB_BAR_MID_BUTTON_TAP);
  22382. }
  22383. const {
  22384. pagePath,
  22385. text: text2
  22386. } = tabBarItem;
  22387. let url = addLeadingSlash(pagePath);
  22388. if (url === __uniRoutes[0].alias) {
  22389. url = "/";
  22390. }
  22391. if (route.path !== url) {
  22392. uni.switchTab({
  22393. from: "tabBar",
  22394. url,
  22395. tabBarText: text2
  22396. });
  22397. } else {
  22398. invokeHook("onTabItemTap", {
  22399. index: index2,
  22400. text: text2,
  22401. pagePath
  22402. });
  22403. }
  22404. };
  22405. };
  22406. }
  22407. const DEFAULT_BG_COLOR = "#f7f7fa";
  22408. const BLUR_EFFECT_COLOR_DARK = "rgb(0, 0, 0, 0.8)";
  22409. const BLUR_EFFECT_COLOR_LIGHT = "rgb(250, 250, 250, 0.8)";
  22410. const BLUR_EFFECT_COLORS = {
  22411. dark: BLUR_EFFECT_COLOR_DARK,
  22412. light: BLUR_EFFECT_COLOR_LIGHT,
  22413. extralight: BLUR_EFFECT_COLOR_LIGHT
  22414. };
  22415. const BORDER_COLORS = {
  22416. white: "rgba(255, 255, 255, 0.33)",
  22417. black: "rgba(0, 0, 0, 0.33)"
  22418. };
  22419. function useTabBarStyle(tabBar2) {
  22420. const style = computed(() => {
  22421. let backgroundColor = tabBar2.backgroundColor;
  22422. const blurEffect = tabBar2.blurEffect;
  22423. if (!backgroundColor) {
  22424. if (cssBackdropFilter && blurEffect && blurEffect !== "none") {
  22425. backgroundColor = BLUR_EFFECT_COLORS[blurEffect];
  22426. }
  22427. }
  22428. return {
  22429. backgroundColor: backgroundColor || DEFAULT_BG_COLOR,
  22430. backdropFilter: blurEffect !== "none" ? "blur(10px)" : blurEffect
  22431. };
  22432. });
  22433. const borderStyle = computed(() => {
  22434. const {
  22435. borderStyle: borderStyle2
  22436. } = tabBar2;
  22437. return {
  22438. backgroundColor: BORDER_COLORS[borderStyle2] || borderStyle2
  22439. };
  22440. });
  22441. const placeholderStyle = computed(() => {
  22442. return {
  22443. height: tabBar2.height
  22444. };
  22445. });
  22446. return {
  22447. style,
  22448. borderStyle,
  22449. placeholderStyle
  22450. };
  22451. }
  22452. function isMidButton(item) {
  22453. return item.type === "midButton";
  22454. }
  22455. function createTabBarItemsTsx(tabBar2, onSwitchTab, visibleList) {
  22456. const {
  22457. selectedIndex,
  22458. selectedColor,
  22459. color
  22460. } = tabBar2;
  22461. return visibleList.value.map((item, index2) => {
  22462. const selected = selectedIndex === index2;
  22463. const textColor = selected ? selectedColor : color;
  22464. const iconPath = (selected ? item.selectedIconPath || item.iconPath : item.iconPath) || "";
  22465. const iconfontText = item.iconfont ? selected ? item.iconfont.selectedText || item.iconfont.text : item.iconfont.text : void 0;
  22466. const iconfontColor = item.iconfont ? selected ? item.iconfont.selectedColor || item.iconfont.color : item.iconfont.color : void 0;
  22467. if (!__UNI_FEATURE_TABBAR_MIDBUTTON__) {
  22468. return createTabBarItemTsx(textColor, iconPath, iconfontText, iconfontColor, item, tabBar2, index2, onSwitchTab);
  22469. }
  22470. return isMidButton(item) ? createTabBarMidButtonTsx(textColor, iconPath, iconfontText, iconfontColor, item, tabBar2, index2, onSwitchTab) : createTabBarItemTsx(textColor, iconPath, iconfontText, iconfontColor, item, tabBar2, index2, onSwitchTab);
  22471. });
  22472. }
  22473. function createTabBarItemTsx(color, iconPath, iconfontText, iconfontColor, tabBarItem, tabBar2, index2, onSwitchTab) {
  22474. return createVNode("div", {
  22475. "key": index2,
  22476. "class": "uni-tabbar__item",
  22477. "onClick": onSwitchTab(tabBarItem, index2)
  22478. }, [createTabBarItemBdTsx(color, iconPath || "", iconfontText, iconfontColor, tabBarItem, tabBar2)], 8, ["onClick"]);
  22479. }
  22480. function createTabBarItemBdTsx(color, iconPath, iconfontText, iconfontColor, tabBarItem, tabBar2) {
  22481. const {
  22482. height
  22483. } = tabBar2;
  22484. return createVNode("div", {
  22485. "class": "uni-tabbar__bd",
  22486. "style": {
  22487. height
  22488. }
  22489. }, [iconfontText ? createTabBarItemIconfontTsx(iconfontText, iconfontColor || BLUR_EFFECT_COLOR_DARK, tabBarItem, tabBar2) : iconPath && createTabBarItemIconTsx(iconPath, tabBarItem, tabBar2), tabBarItem.text && createTabBarItemTextTsx(color, tabBarItem, tabBar2), tabBarItem.redDot && createTabBarItemRedDotTsx(tabBarItem.badge)], 4);
  22490. }
  22491. function createTabBarItemIconTsx(iconPath, tabBarItem, tabBar2) {
  22492. const {
  22493. type,
  22494. text: text2
  22495. } = tabBarItem;
  22496. const {
  22497. iconWidth
  22498. } = tabBar2;
  22499. const clazz2 = "uni-tabbar__icon" + (text2 ? " uni-tabbar__icon__diff" : "");
  22500. const style = {
  22501. width: iconWidth,
  22502. height: iconWidth
  22503. };
  22504. return createVNode("div", {
  22505. "class": clazz2,
  22506. "style": style
  22507. }, [type !== "midButton" && createVNode("img", {
  22508. "src": getRealPath(iconPath)
  22509. }, null, 8, ["src"])], 6);
  22510. }
  22511. function createTabBarItemIconfontTsx(iconfontText, iconfontColor, tabBarItem, tabBar2) {
  22512. var _a;
  22513. const {
  22514. type,
  22515. text: text2
  22516. } = tabBarItem;
  22517. const {
  22518. iconWidth
  22519. } = tabBar2;
  22520. const clazz2 = "uni-tabbar__icon" + (text2 ? " uni-tabbar__icon__diff" : "");
  22521. const style = {
  22522. width: iconWidth,
  22523. height: iconWidth
  22524. };
  22525. const iconfontStyle = {
  22526. fontSize: ((_a = tabBarItem.iconfont) == null ? void 0 : _a.fontSize) || iconWidth,
  22527. color: iconfontColor
  22528. };
  22529. return createVNode("div", {
  22530. "class": clazz2,
  22531. "style": style
  22532. }, [type !== "midButton" && createVNode("div", {
  22533. "class": "uni-tabbar__iconfont",
  22534. "style": iconfontStyle
  22535. }, [iconfontText], 4)], 6);
  22536. }
  22537. function createTabBarItemTextTsx(color, tabBarItem, tabBar2) {
  22538. const {
  22539. iconPath,
  22540. text: text2
  22541. } = tabBarItem;
  22542. const {
  22543. fontSize,
  22544. spacing
  22545. } = tabBar2;
  22546. const style = {
  22547. color,
  22548. fontSize,
  22549. lineHeight: !iconPath ? 1.8 : "normal",
  22550. marginTop: !iconPath ? "inherit" : spacing
  22551. };
  22552. return createVNode("div", {
  22553. "class": "uni-tabbar__label",
  22554. "style": style
  22555. }, [text2], 4);
  22556. }
  22557. function createTabBarItemRedDotTsx(badge) {
  22558. const clazz2 = "uni-tabbar__reddot" + (badge ? " uni-tabbar__badge" : "");
  22559. return createVNode("div", {
  22560. "class": clazz2
  22561. }, [badge], 2);
  22562. }
  22563. function createTabBarMidButtonTsx(color, iconPath, iconfontText, iconfontColor, midButton, tabBar2, index2, onSwitchTab) {
  22564. const {
  22565. width,
  22566. height,
  22567. backgroundImage,
  22568. iconWidth
  22569. } = midButton;
  22570. return createVNode("div", {
  22571. "key": "midButton",
  22572. "class": "uni-tabbar__item",
  22573. "style": {
  22574. flex: "0 0 " + width,
  22575. position: "relative"
  22576. },
  22577. "onClick": onSwitchTab(midButton, index2)
  22578. }, [createVNode("div", {
  22579. "class": "uni-tabbar__mid",
  22580. "style": {
  22581. width,
  22582. height,
  22583. backgroundImage: backgroundImage ? "url('" + getRealPath(backgroundImage) + "')" : "none"
  22584. }
  22585. }, [iconPath && createVNode("img", {
  22586. "style": {
  22587. width: iconWidth,
  22588. height: iconWidth
  22589. },
  22590. "src": getRealPath(iconPath)
  22591. }, null, 12, ["src"])], 4), createTabBarItemBdTsx(color, iconPath, iconfontText, iconfontColor, midButton, tabBar2)], 12, ["onClick"]);
  22592. }
  22593. const DEFAULT_CSS_VAR_VALUE = "0px";
  22594. let globalLayoutState = void 0;
  22595. function getLayoutState() {
  22596. return globalLayoutState;
  22597. }
  22598. const LayoutComponent = /* @__PURE__ */ defineSystemComponent({
  22599. name: "Layout",
  22600. setup(_props, {
  22601. emit: emit2
  22602. }) {
  22603. const rootRef = ref(null);
  22604. initCssVar();
  22605. const keepAliveRoute = __UNI_FEATURE_PAGES__ && useKeepAliveRoute();
  22606. const {
  22607. layoutState,
  22608. windowState
  22609. } = useState();
  22610. useMaxWidth(layoutState, rootRef);
  22611. const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState);
  22612. const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState);
  22613. const rightWindow = __UNI_FEATURE_RIGHTWINDOW__ && useRightWindow(layoutState);
  22614. const showTabBar2 = __UNI_FEATURE_TABBAR__ && useShowTabBar();
  22615. const clazz2 = useAppClass(showTabBar2);
  22616. globalLayoutState = layoutState;
  22617. return () => {
  22618. const layoutTsx = createLayoutTsx(keepAliveRoute, layoutState, windowState, topWindow, leftWindow, rightWindow);
  22619. const tabBarTsx = __UNI_FEATURE_TABBAR__ && createTabBarTsx(showTabBar2);
  22620. return createVNode("uni-app", {
  22621. "ref": rootRef,
  22622. "class": clazz2.value
  22623. }, [layoutTsx, tabBarTsx], 2);
  22624. };
  22625. }
  22626. });
  22627. function useAppClass(showTabBar2) {
  22628. const showMaxWidth = ref(false);
  22629. return computed(() => {
  22630. return {
  22631. "uni-app--showtabbar": showTabBar2 && showTabBar2.value,
  22632. "uni-app--maxwidth": showMaxWidth.value
  22633. };
  22634. });
  22635. }
  22636. function initCssVar() {
  22637. updateCssVar({
  22638. "--status-bar-height": DEFAULT_CSS_VAR_VALUE,
  22639. "--top-window-height": DEFAULT_CSS_VAR_VALUE,
  22640. "--window-left": DEFAULT_CSS_VAR_VALUE,
  22641. "--window-right": DEFAULT_CSS_VAR_VALUE,
  22642. "--window-margin": DEFAULT_CSS_VAR_VALUE,
  22643. "--tab-bar-height": DEFAULT_CSS_VAR_VALUE
  22644. });
  22645. }
  22646. function initMediaQuery(minWidth, callback) {
  22647. const mediaQueryList = window.matchMedia("(min-width: " + minWidth + "px)");
  22648. if (mediaQueryList.addEventListener) {
  22649. mediaQueryList.addEventListener("change", callback);
  22650. } else {
  22651. mediaQueryList.addListener(callback);
  22652. }
  22653. return mediaQueryList.matches;
  22654. }
  22655. function useMaxWidth(layoutState, rootRef) {
  22656. const route = usePageRoute();
  22657. function checkMaxWidth2() {
  22658. const windowWidth = document.body.clientWidth;
  22659. const pages = getCurrentPages();
  22660. let meta = {};
  22661. if (pages.length > 0) {
  22662. const curPage = pages[pages.length - 1];
  22663. meta = curPage.$page.meta;
  22664. } else {
  22665. const routeOptions = getRouteOptions(route.path, true);
  22666. if (routeOptions) {
  22667. meta = routeOptions.meta;
  22668. }
  22669. }
  22670. const maxWidth2 = parseInt(String((hasOwn(meta, "maxWidth") ? meta.maxWidth : __uniConfig.globalStyle.maxWidth) || Number.MAX_SAFE_INTEGER));
  22671. let showMaxWidth = false;
  22672. if (windowWidth > maxWidth2) {
  22673. showMaxWidth = true;
  22674. } else {
  22675. showMaxWidth = false;
  22676. }
  22677. if (showMaxWidth && maxWidth2) {
  22678. layoutState.marginWidth = (windowWidth - maxWidth2) / 2;
  22679. nextTick(() => {
  22680. const rootEl = rootRef.value;
  22681. if (rootEl) {
  22682. rootEl.setAttribute("style", "max-width:" + maxWidth2 + "px;margin:0 auto;");
  22683. }
  22684. });
  22685. } else {
  22686. layoutState.marginWidth = 0;
  22687. nextTick(() => {
  22688. const rootEl = rootRef.value;
  22689. if (rootEl) {
  22690. rootEl.removeAttribute("style");
  22691. }
  22692. });
  22693. }
  22694. }
  22695. watch([() => route.path], checkMaxWidth2);
  22696. onMounted(() => {
  22697. checkMaxWidth2();
  22698. window.addEventListener("resize", checkMaxWidth2);
  22699. });
  22700. }
  22701. function useState() {
  22702. const route = usePageRoute();
  22703. if (!__UNI_FEATURE_RESPONSIVE__) {
  22704. const layoutState2 = reactive({
  22705. marginWidth: 0,
  22706. leftWindowWidth: 0,
  22707. rightWindowWidth: 0
  22708. });
  22709. watch(() => layoutState2.marginWidth, (value) => updateCssVar({
  22710. "--window-margin": value + "px"
  22711. }));
  22712. watch(() => layoutState2.leftWindowWidth + layoutState2.marginWidth, (value) => {
  22713. updateCssVar({
  22714. "--window-left": value + "px"
  22715. });
  22716. });
  22717. watch(() => layoutState2.rightWindowWidth + layoutState2.marginWidth, (value) => {
  22718. updateCssVar({
  22719. "--window-right": value + "px"
  22720. });
  22721. });
  22722. return {
  22723. layoutState: layoutState2,
  22724. windowState: computed(() => ({}))
  22725. };
  22726. }
  22727. const topWindowMediaQuery = ref(false);
  22728. const leftWindowMediaQuery = ref(false);
  22729. const rightWindowMediaQuery = ref(false);
  22730. const showTopWindow2 = computed(() => __UNI_FEATURE_TOPWINDOW__ && route.meta.topWindow !== false && topWindowMediaQuery.value);
  22731. const showLeftWindow2 = computed(() => __UNI_FEATURE_LEFTWINDOW__ && route.meta.leftWindow !== false && leftWindowMediaQuery.value);
  22732. const showRightWindow2 = computed(() => __UNI_FEATURE_RIGHTWINDOW__ && route.meta.rightWindow !== false && rightWindowMediaQuery.value);
  22733. const layoutState = reactive({
  22734. topWindowMediaQuery,
  22735. showTopWindow: showTopWindow2,
  22736. apiShowTopWindow: false,
  22737. leftWindowMediaQuery,
  22738. showLeftWindow: showLeftWindow2,
  22739. apiShowLeftWindow: false,
  22740. rightWindowMediaQuery,
  22741. showRightWindow: showRightWindow2,
  22742. apiShowRightWindow: false,
  22743. topWindowHeight: 0,
  22744. marginWidth: 0,
  22745. leftWindowWidth: 0,
  22746. rightWindowWidth: 0,
  22747. navigationBarTitleText: "",
  22748. topWindowStyle: {},
  22749. leftWindowStyle: {},
  22750. rightWindowStyle: {}
  22751. });
  22752. const props2 = ["topWindow", "leftWindow", "rightWindow"];
  22753. props2.forEach((prop) => {
  22754. var _a;
  22755. const matchMedia = (_a = __uniConfig[prop]) == null ? void 0 : _a.matchMedia;
  22756. let topWindowMinWidth = RESPONSIVE_MIN_WIDTH;
  22757. if (matchMedia && hasOwn(matchMedia, "minWidth")) {
  22758. const minWidth = matchMedia.minWidth;
  22759. topWindowMinWidth = checkMinWidth(minWidth) ? minWidth : topWindowMinWidth;
  22760. }
  22761. const matches2 = initMediaQuery(topWindowMinWidth, (ev) => {
  22762. layoutState[`${prop}MediaQuery`] = ev.matches;
  22763. });
  22764. layoutState[`${prop}MediaQuery`] = matches2;
  22765. });
  22766. watch(() => layoutState.topWindowHeight, (value) => updateCssVar({
  22767. "--top-window-height": value + "px"
  22768. }));
  22769. watch(() => layoutState.marginWidth, (value) => updateCssVar({
  22770. "--window-margin": value + "px"
  22771. }));
  22772. watch(() => layoutState.leftWindowWidth + layoutState.marginWidth, (value) => {
  22773. updateCssVar({
  22774. "--window-left": value + "px"
  22775. });
  22776. });
  22777. watch(() => layoutState.rightWindowWidth + layoutState.marginWidth, (value) => {
  22778. updateCssVar({
  22779. "--window-right": value + "px"
  22780. });
  22781. });
  22782. UniServiceJSBridge.on(ON_NAVIGATION_BAR_CHANGE, (navigationBar) => {
  22783. layoutState.navigationBarTitleText = navigationBar.titleText;
  22784. });
  22785. const windowState = computed(() => ({
  22786. matchTopWindow: layoutState.topWindowMediaQuery,
  22787. showTopWindow: layoutState.showTopWindow || layoutState.apiShowTopWindow,
  22788. matchLeftWindow: layoutState.leftWindowMediaQuery,
  22789. showLeftWindow: layoutState.showLeftWindow || layoutState.apiShowLeftWindow,
  22790. matchRightWindow: layoutState.rightWindowMediaQuery,
  22791. showRightWindow: layoutState.showRightWindow || layoutState.apiShowRightWindow
  22792. }));
  22793. return {
  22794. layoutState,
  22795. windowState
  22796. };
  22797. }
  22798. function createLayoutTsx(keepAliveRoute, layoutState, windowState, topWindow, leftWindow, rightWindow) {
  22799. const routerVNode = __UNI_FEATURE_PAGES__ ? createRouterViewVNode(keepAliveRoute) : createPageVNode();
  22800. if (!__UNI_FEATURE_RESPONSIVE__) {
  22801. return routerVNode;
  22802. }
  22803. const topWindowTsx = __UNI_FEATURE_TOPWINDOW__ ? createTopWindowTsx(topWindow, layoutState, windowState.value) : null;
  22804. const leftWindowTsx = __UNI_FEATURE_LEFTWINDOW__ ? createLeftWindowTsx(leftWindow, layoutState, windowState.value) : null;
  22805. const rightWindowTsx = __UNI_FEATURE_RIGHTWINDOW__ ? createRightWindowTsx(rightWindow, layoutState, windowState.value) : null;
  22806. return createVNode("uni-layout", {
  22807. "class": {
  22808. "uni-app--showtopwindow": __UNI_FEATURE_TOPWINDOW__ && layoutState.showTopWindow,
  22809. "uni-app--showleftwindow": __UNI_FEATURE_LEFTWINDOW__ && layoutState.showLeftWindow,
  22810. "uni-app--showrightwindow": __UNI_FEATURE_RIGHTWINDOW__ && layoutState.showRightWindow
  22811. }
  22812. }, [topWindowTsx, createVNode("uni-content", null, [createVNode("uni-main", null, [routerVNode]), leftWindowTsx, rightWindowTsx])], 2);
  22813. }
  22814. function useShowTabBar(emit2) {
  22815. const route = usePageRoute();
  22816. const tabBar2 = useTabBar();
  22817. const showTabBar2 = computed(() => route.meta.isTabBar && tabBar2.shown);
  22818. updateCssVar({
  22819. "--tab-bar-height": tabBar2.height
  22820. });
  22821. return showTabBar2;
  22822. }
  22823. function createTabBarTsx(showTabBar2) {
  22824. return withDirectives(createVNode(TabBar, null, null, 512), [[vShow, showTabBar2.value]]);
  22825. }
  22826. function createPageVNode() {
  22827. return createVNode(__uniRoutes[0].component);
  22828. }
  22829. function createRouterViewVNode({
  22830. routeKey,
  22831. isTabBar,
  22832. routeCache: routeCache2
  22833. }) {
  22834. return createVNode(RouterView, null, {
  22835. default: withCtx(({
  22836. Component
  22837. }) => [(openBlock(), createBlock(KeepAlive, {
  22838. matchBy: "key",
  22839. cache: routeCache2
  22840. }, [(openBlock(), createBlock(resolveDynamicComponent(Component), {
  22841. type: isTabBar.value ? "tabBar" : "",
  22842. key: routeKey.value
  22843. }))], 1032, ["cache"]))]),
  22844. _: 1
  22845. /* STABLE */
  22846. });
  22847. }
  22848. function useTopWindow(layoutState) {
  22849. const {
  22850. component,
  22851. style
  22852. } = __uniConfig.topWindow;
  22853. const windowRef = ref(null);
  22854. function updateWindow() {
  22855. const instance2 = windowRef.value;
  22856. const el = resolveOwnerEl(instance2.$);
  22857. const height = el.getBoundingClientRect().height;
  22858. layoutState.topWindowHeight = height;
  22859. }
  22860. onMounted(updateWindow);
  22861. watch(() => layoutState.showTopWindow || layoutState.apiShowTopWindow, () => nextTick(updateWindow));
  22862. layoutState.topWindowStyle = style;
  22863. return {
  22864. component,
  22865. windowRef
  22866. };
  22867. }
  22868. function useLeftWindow(layoutState) {
  22869. const {
  22870. component,
  22871. style
  22872. } = __uniConfig.leftWindow;
  22873. const windowRef = ref(null);
  22874. function updateWindow() {
  22875. const instance2 = windowRef.value;
  22876. const el = resolveOwnerEl(instance2.$);
  22877. const width = el.getBoundingClientRect().width;
  22878. layoutState.leftWindowWidth = width;
  22879. }
  22880. onMounted(updateWindow);
  22881. watch(() => layoutState.showLeftWindow || layoutState.apiShowLeftWindow, () => nextTick(updateWindow));
  22882. layoutState.leftWindowStyle = style;
  22883. return {
  22884. component,
  22885. windowRef
  22886. };
  22887. }
  22888. function useRightWindow(layoutState) {
  22889. const {
  22890. component,
  22891. style
  22892. } = __uniConfig.rightWindow;
  22893. const windowRef = ref(null);
  22894. function updateWindow() {
  22895. const instance2 = windowRef.value;
  22896. const el = resolveOwnerEl(instance2.$);
  22897. const width = el.getBoundingClientRect().width;
  22898. layoutState.rightWindowWidth = width;
  22899. }
  22900. onMounted(updateWindow);
  22901. watch(() => layoutState.showRightWindow || layoutState.apiShowRightWindow, () => nextTick(updateWindow));
  22902. layoutState.rightWindowStyle = style;
  22903. return {
  22904. component,
  22905. windowRef
  22906. };
  22907. }
  22908. function createTopWindowTsx(topWindow, layoutState, windowState) {
  22909. if (topWindow) {
  22910. const {
  22911. component: TopWindow,
  22912. windowRef
  22913. } = topWindow;
  22914. return withDirectives(createVNode("uni-top-window", null, [createVNode("div", {
  22915. "class": "uni-top-window",
  22916. "style": layoutState.topWindowStyle
  22917. }, [createVNode(TopWindow, mergeProps({
  22918. "ref": windowRef,
  22919. "navigation-bar-title-text": layoutState.navigationBarTitleText
  22920. }, windowState), null, 16, ["navigation-bar-title-text"])], 4), createVNode("div", {
  22921. "class": "uni-top-window--placeholder",
  22922. "style": {
  22923. height: layoutState.topWindowHeight + "px"
  22924. }
  22925. }, null, 4)], 512), [[vShow, layoutState.showTopWindow || layoutState.apiShowTopWindow]]);
  22926. }
  22927. }
  22928. function createLeftWindowTsx(leftWindow, layoutState, windowState) {
  22929. if (leftWindow) {
  22930. const {
  22931. component: LeftWindow,
  22932. windowRef
  22933. } = leftWindow;
  22934. return withDirectives(createVNode("uni-left-window", {
  22935. "data-show": layoutState.apiShowLeftWindow || void 0,
  22936. "style": layoutState.leftWindowStyle
  22937. }, [layoutState.apiShowLeftWindow ? createVNode("div", {
  22938. "class": "uni-mask",
  22939. "onClick": () => layoutState.apiShowLeftWindow = false
  22940. }, null, 8, ["onClick"]) : null, createVNode("div", {
  22941. "class": "uni-left-window"
  22942. }, [createVNode(LeftWindow, mergeProps({
  22943. "ref": windowRef
  22944. }, windowState), null, 16)])], 12, ["data-show"]), [[vShow, layoutState.showLeftWindow || layoutState.apiShowLeftWindow]]);
  22945. }
  22946. }
  22947. function createRightWindowTsx(rightWindow, layoutState, windowState) {
  22948. if (rightWindow) {
  22949. const {
  22950. component: RightWindow,
  22951. windowRef
  22952. } = rightWindow;
  22953. return withDirectives(createVNode("uni-right-window", {
  22954. "data-show": layoutState.apiShowRightWindow || void 0,
  22955. "style": layoutState.rightWindowStyle
  22956. }, [layoutState.apiShowRightWindow ? createVNode("div", {
  22957. "class": "uni-mask",
  22958. "onClick": () => layoutState.apiShowRightWindow = false
  22959. }, null, 8, ["onClick"]) : null, createVNode("div", {
  22960. "class": "uni-right-window"
  22961. }, [createVNode(RightWindow, mergeProps({
  22962. "ref": windowRef
  22963. }, windowState), null, 16)])], 12, ["data-show"]), [[vShow, layoutState.showRightWindow || layoutState.apiShowRightWindow]]);
  22964. }
  22965. }
  22966. const showTopWindow = /* @__PURE__ */ defineAsyncApi(
  22967. "showTopWindow",
  22968. (_, { resolve, reject }) => {
  22969. const state2 = getLayoutState();
  22970. if (!state2) {
  22971. reject();
  22972. return;
  22973. }
  22974. state2.apiShowTopWindow = true;
  22975. nextTick(resolve);
  22976. }
  22977. );
  22978. const hideTopWindow = /* @__PURE__ */ defineAsyncApi(
  22979. "hideTopWindow",
  22980. (_, { resolve, reject }) => {
  22981. const state2 = getLayoutState();
  22982. if (!state2) {
  22983. reject();
  22984. return;
  22985. }
  22986. state2.apiShowTopWindow = false;
  22987. nextTick(resolve);
  22988. }
  22989. );
  22990. const showLeftWindow = /* @__PURE__ */ defineAsyncApi(
  22991. "showLeftWindow",
  22992. (_, { resolve, reject }) => {
  22993. const state2 = getLayoutState();
  22994. if (!state2) {
  22995. reject();
  22996. return;
  22997. }
  22998. state2.apiShowLeftWindow = true;
  22999. nextTick(resolve);
  23000. }
  23001. );
  23002. const hideLeftWindow = /* @__PURE__ */ defineAsyncApi(
  23003. "hideLeftWindow",
  23004. (_, { resolve, reject }) => {
  23005. const state2 = getLayoutState();
  23006. if (!state2) {
  23007. reject();
  23008. return;
  23009. }
  23010. state2.apiShowLeftWindow = false;
  23011. nextTick(resolve);
  23012. }
  23013. );
  23014. const showRightWindow = /* @__PURE__ */ defineAsyncApi(
  23015. "showRightWindow",
  23016. (_, { resolve, reject }) => {
  23017. const state2 = getLayoutState();
  23018. if (!state2) {
  23019. reject();
  23020. return;
  23021. }
  23022. state2.apiShowRightWindow = true;
  23023. nextTick(resolve);
  23024. }
  23025. );
  23026. const hideRightWindow = /* @__PURE__ */ defineAsyncApi(
  23027. "hideRightWindow",
  23028. (_, { resolve, reject }) => {
  23029. const state2 = getLayoutState();
  23030. if (!state2) {
  23031. reject();
  23032. return;
  23033. }
  23034. state2.apiShowRightWindow = false;
  23035. nextTick(resolve);
  23036. }
  23037. );
  23038. const getTopWindowStyle = /* @__PURE__ */ defineSyncApi(
  23039. "getTopWindowStyle",
  23040. () => {
  23041. const state2 = getLayoutState();
  23042. return extend({}, state2 && state2.topWindowStyle);
  23043. }
  23044. );
  23045. const setTopWindowStyle = /* @__PURE__ */ defineSyncApi(
  23046. "setTopWindowStyle",
  23047. (style) => {
  23048. const state2 = getLayoutState();
  23049. if (state2) {
  23050. state2.topWindowStyle = style;
  23051. }
  23052. }
  23053. );
  23054. const getLeftWindowStyle = /* @__PURE__ */ defineSyncApi(
  23055. "getLeftWindowStyle",
  23056. () => {
  23057. const state2 = getLayoutState();
  23058. return extend({}, state2 && state2.leftWindowStyle);
  23059. }
  23060. );
  23061. const setLeftWindowStyle = /* @__PURE__ */ defineSyncApi(
  23062. "setLeftWindowStyle",
  23063. (style) => {
  23064. const state2 = getLayoutState();
  23065. if (state2) {
  23066. state2.leftWindowStyle = style;
  23067. }
  23068. }
  23069. );
  23070. const getRightWindowStyle = /* @__PURE__ */ defineSyncApi("getRightWindowStyle", () => {
  23071. const state2 = getLayoutState();
  23072. return extend({}, state2 && state2.rightWindowStyle);
  23073. });
  23074. const setRightWindowStyle = /* @__PURE__ */ defineSyncApi("setRightWindowStyle", (style) => {
  23075. const state2 = getLayoutState();
  23076. if (state2) {
  23077. state2.rightWindowStyle = style;
  23078. }
  23079. });
  23080. const getElementById = /* @__PURE__ */ defineSyncApi(
  23081. "getElementById",
  23082. (id2) => {
  23083. const uniPageBody = document.querySelector("uni-page-body");
  23084. return uniPageBody ? uniPageBody.querySelector(`#${id2}`) : null;
  23085. }
  23086. );
  23087. const saveImageToPhotosAlbum = /* @__PURE__ */ defineAsyncApi(
  23088. API_SAVE_IMAGE_TO_PHOTOS_ALBUM,
  23089. createUnsupportedAsyncApi(API_SAVE_IMAGE_TO_PHOTOS_ALBUM)
  23090. );
  23091. const API_GET_RECORDER_MANAGER = "getRecorderManager";
  23092. const getRecorderManager = /* @__PURE__ */ defineSyncApi(
  23093. API_GET_RECORDER_MANAGER,
  23094. createUnsupportedSyncApi(API_GET_RECORDER_MANAGER)
  23095. );
  23096. const saveVideoToPhotosAlbum = /* @__PURE__ */ defineAsyncApi(
  23097. API_SAVE_VIDEO_TO_PHOTOS_ALBUM,
  23098. createUnsupportedAsyncApi(API_SAVE_VIDEO_TO_PHOTOS_ALBUM)
  23099. );
  23100. const API_CREATE_CAMERA_CONTEXT = "createCameraContext";
  23101. const createCameraContext = /* @__PURE__ */ defineSyncApi(
  23102. API_CREATE_CAMERA_CONTEXT,
  23103. createUnsupportedSyncApi(API_CREATE_CAMERA_CONTEXT)
  23104. );
  23105. const API_CREATE_LIVE_PLAYER_CONTEXT = "createLivePlayerContext";
  23106. const createLivePlayerContext = /* @__PURE__ */ defineSyncApi(
  23107. API_CREATE_LIVE_PLAYER_CONTEXT,
  23108. createUnsupportedSyncApi(API_CREATE_LIVE_PLAYER_CONTEXT)
  23109. );
  23110. const API_SAVE_FILE = "saveFile";
  23111. const saveFile = /* @__PURE__ */ defineAsyncApi(
  23112. API_SAVE_FILE,
  23113. createUnsupportedAsyncApi(API_SAVE_FILE)
  23114. );
  23115. const API_GET_SAVED_FILE_LIST = "getSavedFileList";
  23116. const getSavedFileList = /* @__PURE__ */ defineAsyncApi(
  23117. API_GET_SAVED_FILE_LIST,
  23118. createUnsupportedAsyncApi(API_GET_SAVED_FILE_LIST)
  23119. );
  23120. const API_GET_SAVED_FILE_INFO = "getSavedFileInfo";
  23121. const getSavedFileInfo = /* @__PURE__ */ defineAsyncApi(
  23122. API_GET_SAVED_FILE_INFO,
  23123. createUnsupportedAsyncApi(API_GET_SAVED_FILE_INFO)
  23124. );
  23125. const API_REMOVE_SAVED_FILE = "removeSavedFile";
  23126. const removeSavedFile = /* @__PURE__ */ defineAsyncApi(
  23127. API_REMOVE_SAVED_FILE,
  23128. createUnsupportedAsyncApi(API_REMOVE_SAVED_FILE)
  23129. );
  23130. const API_ON_MEMORY_WARNING = "onMemoryWarning";
  23131. const onMemoryWarning = /* @__PURE__ */ defineOnApi(
  23132. API_ON_MEMORY_WARNING,
  23133. createUnsupportedOnApi(API_ON_MEMORY_WARNING)
  23134. );
  23135. const API_ON_GYROSCOPE_CHANGE = "onGyroscopeChange";
  23136. const onGyroscopeChange = /* @__PURE__ */ defineOnApi(
  23137. API_ON_GYROSCOPE_CHANGE,
  23138. createUnsupportedOnApi(API_ON_GYROSCOPE_CHANGE)
  23139. );
  23140. const API_START_GYROSCOPE = "startGyroscope";
  23141. const startGyroscope = /* @__PURE__ */ defineAsyncApi(
  23142. API_START_GYROSCOPE,
  23143. createUnsupportedAsyncApi(API_START_GYROSCOPE)
  23144. );
  23145. const API_STOP_GYROSCOPE = "stopGyroscope";
  23146. const stopGyroscope = /* @__PURE__ */ defineAsyncApi(
  23147. API_STOP_GYROSCOPE,
  23148. createUnsupportedAsyncApi(API_STOP_GYROSCOPE)
  23149. );
  23150. const API_SCAN_CODE = "scanCode";
  23151. const scanCode = /* @__PURE__ */ defineAsyncApi(
  23152. API_SCAN_CODE,
  23153. createUnsupportedAsyncApi(API_SCAN_CODE)
  23154. );
  23155. const API_SET_SCREEN_BRIGHTNESS = "setScreenBrightness";
  23156. const setScreenBrightness = /* @__PURE__ */ defineAsyncApi(
  23157. API_SET_SCREEN_BRIGHTNESS,
  23158. createUnsupportedAsyncApi(API_SET_SCREEN_BRIGHTNESS)
  23159. );
  23160. const API_GET_SCREEN_BRIGHTNESS = "getScreenBrightness";
  23161. const getScreenBrightness = /* @__PURE__ */ defineAsyncApi(
  23162. API_GET_SCREEN_BRIGHTNESS,
  23163. createUnsupportedAsyncApi(API_GET_SCREEN_BRIGHTNESS)
  23164. );
  23165. const API_SET_KEEP_SCREEN_ON = "setKeepScreenOn";
  23166. const setKeepScreenOn = /* @__PURE__ */ defineAsyncApi(
  23167. API_SET_KEEP_SCREEN_ON,
  23168. createUnsupportedAsyncApi(API_SET_KEEP_SCREEN_ON)
  23169. );
  23170. const API_ON_USER_CAPTURE_SCREEN = "onUserCaptureScreen";
  23171. const onUserCaptureScreen = /* @__PURE__ */ defineOnApi(
  23172. API_ON_USER_CAPTURE_SCREEN,
  23173. createUnsupportedOnApi(API_ON_USER_CAPTURE_SCREEN)
  23174. );
  23175. const API_ADD_PHONE_CONTACT = "addPhoneContact";
  23176. const addPhoneContact = /* @__PURE__ */ defineAsyncApi(
  23177. API_ADD_PHONE_CONTACT,
  23178. createUnsupportedAsyncApi(API_ADD_PHONE_CONTACT)
  23179. );
  23180. const API_LOGIN = "login";
  23181. const login = /* @__PURE__ */ defineAsyncApi(
  23182. API_LOGIN,
  23183. createUnsupportedAsyncApi(API_LOGIN)
  23184. );
  23185. const API_GET_PROVIDER = "getProvider";
  23186. const getProvider = /* @__PURE__ */ defineAsyncApi(
  23187. API_GET_PROVIDER,
  23188. createUnsupportedAsyncApi(API_GET_PROVIDER)
  23189. );
  23190. const api = /* @__PURE__ */ Object.defineProperty({
  23191. __proto__: null,
  23192. $emit,
  23193. $off,
  23194. $on,
  23195. $once,
  23196. addInterceptor,
  23197. addPhoneContact,
  23198. arrayBufferToBase64,
  23199. base64ToArrayBuffer,
  23200. canIUse,
  23201. canvasGetImageData,
  23202. canvasPutImageData,
  23203. canvasToTempFilePath,
  23204. chooseFile,
  23205. chooseImage,
  23206. chooseLocation,
  23207. chooseVideo,
  23208. clearStorage,
  23209. clearStorageSync,
  23210. closePreviewImage,
  23211. closeSocket,
  23212. connectSocket,
  23213. createAnimation: createAnimation$1,
  23214. createCameraContext,
  23215. createCanvasContext,
  23216. createInnerAudioContext,
  23217. createIntersectionObserver,
  23218. createLivePlayerContext,
  23219. createMapContext,
  23220. createMediaQueryObserver,
  23221. createSelectorQuery,
  23222. createVideoContext,
  23223. cssBackdropFilter,
  23224. cssConstant,
  23225. cssEnv,
  23226. cssVar,
  23227. downloadFile,
  23228. getAppBaseInfo,
  23229. getClipboardData,
  23230. getDeviceInfo,
  23231. getElementById,
  23232. getEnterOptionsSync,
  23233. getFileInfo,
  23234. getImageInfo,
  23235. getLaunchOptionsSync,
  23236. getLeftWindowStyle,
  23237. getLocale,
  23238. getLocation,
  23239. getNetworkType,
  23240. getProvider,
  23241. getPushClientId,
  23242. getRecorderManager,
  23243. getRightWindowStyle,
  23244. getSavedFileInfo,
  23245. getSavedFileList,
  23246. getScreenBrightness,
  23247. getSelectedTextRange: getSelectedTextRange$1,
  23248. getStorage,
  23249. getStorageInfo,
  23250. getStorageInfoSync,
  23251. getStorageSync,
  23252. getSystemInfo,
  23253. getSystemInfoSync,
  23254. getTopWindowStyle,
  23255. getVideoInfo,
  23256. getWindowInfo,
  23257. hideActionSheet,
  23258. hideKeyboard,
  23259. hideLeftWindow,
  23260. hideLoading,
  23261. hideModal,
  23262. hideNavigationBarLoading,
  23263. hideRightWindow,
  23264. hideTabBar,
  23265. hideTabBarRedDot,
  23266. hideToast,
  23267. hideTopWindow,
  23268. interceptors,
  23269. invokePushCallback,
  23270. loadFontFace,
  23271. login,
  23272. makePhoneCall,
  23273. navigateBack,
  23274. navigateTo,
  23275. offAccelerometerChange,
  23276. offAppHide,
  23277. offAppShow,
  23278. offCompassChange,
  23279. offError,
  23280. offLocationChange,
  23281. offLocationChangeError,
  23282. offNetworkStatusChange,
  23283. offPageNotFound,
  23284. offPushMessage,
  23285. offThemeChange: offThemeChange$1,
  23286. offUnhandledRejection,
  23287. offWindowResize,
  23288. onAccelerometerChange,
  23289. onAppHide,
  23290. onAppShow,
  23291. onCompassChange,
  23292. onCreateVueApp,
  23293. onError,
  23294. onGyroscopeChange,
  23295. onLocaleChange,
  23296. onLocationChange,
  23297. onLocationChangeError,
  23298. onMemoryWarning,
  23299. onNetworkStatusChange,
  23300. onPageNotFound,
  23301. onPushMessage,
  23302. onSocketClose,
  23303. onSocketError,
  23304. onSocketMessage,
  23305. onSocketOpen,
  23306. onTabBarMidButtonTap,
  23307. onThemeChange: onThemeChange$1,
  23308. onUnhandledRejection,
  23309. onUserCaptureScreen,
  23310. onWindowResize,
  23311. openDocument,
  23312. openLocation,
  23313. pageScrollTo,
  23314. preloadPage,
  23315. previewImage,
  23316. reLaunch,
  23317. redirectTo,
  23318. removeInterceptor,
  23319. removeSavedFile,
  23320. removeStorage,
  23321. removeStorageSync,
  23322. removeTabBarBadge,
  23323. request,
  23324. saveFile,
  23325. saveImageToPhotosAlbum,
  23326. saveVideoToPhotosAlbum,
  23327. scanCode,
  23328. sendSocketMessage,
  23329. setClipboardData,
  23330. setKeepScreenOn,
  23331. setLeftWindowStyle,
  23332. setLocale,
  23333. setNavigationBarColor,
  23334. setNavigationBarTitle,
  23335. setPageMeta,
  23336. setRightWindowStyle,
  23337. setScreenBrightness,
  23338. setStorage,
  23339. setStorageSync,
  23340. setTabBarBadge,
  23341. setTabBarItem,
  23342. setTabBarStyle,
  23343. setTopWindowStyle,
  23344. showActionSheet,
  23345. showLeftWindow,
  23346. showLoading,
  23347. showModal,
  23348. showNavigationBarLoading,
  23349. showRightWindow,
  23350. showTabBar,
  23351. showTabBarRedDot,
  23352. showToast,
  23353. showTopWindow,
  23354. startAccelerometer,
  23355. startCompass,
  23356. startGyroscope,
  23357. startLocationUpdate,
  23358. startPullDownRefresh,
  23359. stopAccelerometer,
  23360. stopCompass,
  23361. stopGyroscope,
  23362. stopLocationUpdate,
  23363. stopPullDownRefresh,
  23364. switchTab,
  23365. uploadFile,
  23366. upx2px,
  23367. vibrateLong,
  23368. vibrateShort
  23369. }, Symbol.toStringTag, { value: "Module" });
  23370. const CONTEXT_ID = "MAP_LOCATION";
  23371. const MapLocation = /* @__PURE__ */ defineSystemComponent({
  23372. name: "MapLocation",
  23373. setup() {
  23374. const state2 = reactive({
  23375. latitude: 0,
  23376. longitude: 0,
  23377. rotate: 0
  23378. });
  23379. {
  23380. let compassChangeHandler = function(res) {
  23381. state2.rotate = res.direction;
  23382. }, updateLocation = function() {
  23383. getLocation({
  23384. type: "gcj02",
  23385. success: (res) => {
  23386. state2.latitude = res.latitude;
  23387. state2.longitude = res.longitude;
  23388. },
  23389. complete: () => {
  23390. timer = setTimeout(updateLocation, 3e4);
  23391. }
  23392. });
  23393. }, removeLocation = function() {
  23394. if (timer) {
  23395. clearTimeout(timer);
  23396. }
  23397. offCompassChange(compassChangeHandler);
  23398. };
  23399. const onMapReady = inject("onMapReady");
  23400. let timer;
  23401. onCompassChange(compassChangeHandler);
  23402. onMapReady(updateLocation);
  23403. onUnmounted(removeLocation);
  23404. const addMapChidlContext = inject("addMapChidlContext");
  23405. const removeMapChidlContext = inject("removeMapChidlContext");
  23406. const context = {
  23407. id: CONTEXT_ID,
  23408. state: state2
  23409. };
  23410. addMapChidlContext(context);
  23411. onUnmounted(() => removeMapChidlContext(context));
  23412. }
  23413. return () => {
  23414. return state2.latitude ? createVNode(MapMarker, mergeProps({
  23415. "anchor": {
  23416. x: 0.5,
  23417. y: 0.5
  23418. },
  23419. "width": "44",
  23420. "height": "44",
  23421. "iconPath": ICON_PATH_ORIGIN
  23422. }, state2), null, 16, ["iconPath"]) : null;
  23423. };
  23424. }
  23425. });
  23426. const props$3 = {
  23427. // 边框虚线,腾讯地图支持,google 高德 地图不支持,默认值为[0, 0] 为实线,非 [0, 0] 为虚线,H5 端无法像微信小程序一样控制虚线的间隔像素大小
  23428. dashArray: {
  23429. type: Array,
  23430. default: () => [0, 0]
  23431. },
  23432. // 经纬度数组,[{latitude: 0, longitude: 0}]
  23433. points: {
  23434. type: Array,
  23435. required: true
  23436. },
  23437. // 描边的宽度
  23438. strokeWidth: {
  23439. type: Number,
  23440. default: 1
  23441. },
  23442. // 描边的颜色,十六进制
  23443. strokeColor: {
  23444. type: String,
  23445. default: "#000000"
  23446. },
  23447. // 填充颜色,十六进制
  23448. fillColor: {
  23449. type: String,
  23450. default: "#00000000"
  23451. },
  23452. // 设置多边形 Z 轴数值
  23453. zIndex: {
  23454. type: Number,
  23455. default: 0
  23456. }
  23457. };
  23458. const MapPolygon = /* @__PURE__ */ defineSystemComponent({
  23459. name: "MapPolygon",
  23460. props: props$3,
  23461. setup(props2) {
  23462. let polygonIns;
  23463. const onMapReady = inject("onMapReady");
  23464. onMapReady((map, maps2, trigger) => {
  23465. function drawPolygon() {
  23466. const {
  23467. points,
  23468. strokeWidth,
  23469. strokeColor,
  23470. dashArray,
  23471. fillColor,
  23472. zIndex
  23473. } = props2;
  23474. const path = points.map((item) => {
  23475. const {
  23476. latitude,
  23477. longitude
  23478. } = item;
  23479. if (getIsAMap()) {
  23480. return [longitude, latitude];
  23481. } else if (getIsBMap()) {
  23482. return new maps2.Point(longitude, latitude);
  23483. } else {
  23484. return new maps2.LatLng(latitude, longitude);
  23485. }
  23486. });
  23487. const {
  23488. r: fcR,
  23489. g: fcG,
  23490. b: fcB,
  23491. a: fcA
  23492. } = hexToRgba(fillColor);
  23493. const {
  23494. r: scR,
  23495. g: scG,
  23496. b: scB,
  23497. a: scA
  23498. } = hexToRgba(strokeColor);
  23499. const polygonOptions = {
  23500. //多边形是否可点击。
  23501. clickable: true,
  23502. //鼠标在多边形内的光标样式。
  23503. cursor: "crosshair",
  23504. //多边形是否可编辑。
  23505. editable: false,
  23506. // 地图实例,即要显示多边形的地图
  23507. // @ts-ignore
  23508. map,
  23509. // 区域填充色
  23510. fillColor: "",
  23511. //多边形的路径,以经纬度坐标数组构成。
  23512. path,
  23513. // 区域边框
  23514. strokeColor: "",
  23515. //多边形的边框样式。实线是solid,虚线是dash。
  23516. strokeDashStyle: dashArray.some((item) => item > 0) ? "dash" : "solid",
  23517. //多边形的边框线宽。
  23518. strokeWeight: strokeWidth,
  23519. //多边形是否可见。
  23520. visible: true,
  23521. //多边形的zIndex值。
  23522. zIndex
  23523. };
  23524. if (maps2.Color) {
  23525. polygonOptions.fillColor = new maps2.Color(fcR, fcG, fcB, fcA);
  23526. polygonOptions.strokeColor = new maps2.Color(scR, scG, scB, scA);
  23527. } else {
  23528. polygonOptions.fillColor = `rgb(${fcR}, ${fcG}, ${fcB})`;
  23529. polygonOptions.fillOpacity = fcA;
  23530. polygonOptions.strokeColor = `rgb(${scR}, ${scG}, ${scB})`;
  23531. polygonOptions.strokeOpacity = scA;
  23532. }
  23533. if (polygonIns) {
  23534. polygonIns.setOptions(polygonOptions);
  23535. return;
  23536. }
  23537. if (getIsBMap()) {
  23538. polygonIns = new maps2.Polygon(polygonOptions.path, polygonOptions);
  23539. map.addOverlay(polygonIns);
  23540. } else {
  23541. polygonIns = new maps2.Polygon(polygonOptions);
  23542. }
  23543. }
  23544. drawPolygon();
  23545. watch(props2, drawPolygon);
  23546. });
  23547. onUnmounted(() => {
  23548. polygonIns.setMap(null);
  23549. });
  23550. return () => null;
  23551. }
  23552. });
  23553. const props$2 = {
  23554. id: {
  23555. type: String,
  23556. default: ""
  23557. },
  23558. latitude: {
  23559. type: [String, Number],
  23560. default: 0
  23561. },
  23562. longitude: {
  23563. type: [String, Number],
  23564. default: 0
  23565. },
  23566. scale: {
  23567. type: [String, Number],
  23568. default: 16
  23569. },
  23570. markers: {
  23571. type: Array,
  23572. default() {
  23573. return [];
  23574. }
  23575. },
  23576. includePoints: {
  23577. type: Array,
  23578. default() {
  23579. return [];
  23580. }
  23581. },
  23582. polyline: {
  23583. type: Array,
  23584. default() {
  23585. return [];
  23586. }
  23587. },
  23588. circles: {
  23589. type: Array,
  23590. default() {
  23591. return [];
  23592. }
  23593. },
  23594. controls: {
  23595. type: Array,
  23596. default() {
  23597. return [];
  23598. }
  23599. },
  23600. showLocation: {
  23601. type: [Boolean, String],
  23602. default: false
  23603. },
  23604. libraries: {
  23605. type: Array,
  23606. default() {
  23607. return [];
  23608. }
  23609. },
  23610. polygons: {
  23611. type: Array,
  23612. default: () => []
  23613. }
  23614. };
  23615. function getPoints(points) {
  23616. const newPoints = [];
  23617. if (isArray(points)) {
  23618. points.forEach((point) => {
  23619. if (point && point.latitude && point.longitude) {
  23620. newPoints.push({
  23621. latitude: point.latitude,
  23622. longitude: point.longitude
  23623. });
  23624. }
  23625. });
  23626. }
  23627. return newPoints;
  23628. }
  23629. function getAMapPosition(maps2, latitude, longitude) {
  23630. return new maps2.LngLat(longitude, latitude);
  23631. }
  23632. function getBMapPosition(maps2, latitude, longitude) {
  23633. return new maps2.Point(longitude, latitude);
  23634. }
  23635. function getGoogleOrQQMapPosition(maps2, latitude, longitude) {
  23636. return new maps2.LatLng(latitude, longitude);
  23637. }
  23638. function getMapPosition(maps2, latitude, longitude) {
  23639. if (getIsBMap()) {
  23640. return getBMapPosition(maps2, latitude, longitude);
  23641. } else if (getIsAMap()) {
  23642. return getAMapPosition(maps2, latitude, longitude);
  23643. } else {
  23644. return getGoogleOrQQMapPosition(maps2, latitude, longitude);
  23645. }
  23646. }
  23647. function getLat(latLng) {
  23648. if ("getLat" in latLng) {
  23649. return latLng.getLat();
  23650. } else {
  23651. if (getIsBMap()) {
  23652. return latLng.lat;
  23653. }
  23654. return latLng.lat();
  23655. }
  23656. }
  23657. function getLng(latLng) {
  23658. if ("getLng" in latLng) {
  23659. return latLng.getLng();
  23660. } else {
  23661. if (getIsBMap()) {
  23662. return latLng.lng;
  23663. }
  23664. return latLng.lng();
  23665. }
  23666. }
  23667. function useMap(props2, rootRef, emit2) {
  23668. const trigger = useCustomEvent(rootRef, emit2);
  23669. const mapRef = ref(null);
  23670. let maps2;
  23671. let map;
  23672. const state2 = reactive({
  23673. latitude: Number(props2.latitude),
  23674. longitude: Number(props2.longitude),
  23675. includePoints: getPoints(props2.includePoints)
  23676. });
  23677. const onMapReadyCallbacks = [];
  23678. let isMapReady;
  23679. function onMapReady(callback) {
  23680. if (isMapReady) {
  23681. callback(map, maps2, trigger);
  23682. } else {
  23683. onMapReadyCallbacks.push(callback);
  23684. }
  23685. }
  23686. function emitMapReady() {
  23687. isMapReady = true;
  23688. onMapReadyCallbacks.forEach((callback) => callback(map, maps2, trigger));
  23689. onMapReadyCallbacks.length = 0;
  23690. }
  23691. let isBoundsReady;
  23692. const onBoundsReadyCallbacks = [];
  23693. function onBoundsReady(callback) {
  23694. if (isBoundsReady) {
  23695. callback();
  23696. } else {
  23697. onMapReadyCallbacks.push(callback);
  23698. }
  23699. }
  23700. const contexts = {};
  23701. function addMapChidlContext(context) {
  23702. contexts[context.id] = context;
  23703. }
  23704. function removeMapChidlContext(context) {
  23705. delete contexts[context.id];
  23706. }
  23707. watch([() => props2.latitude, () => props2.longitude], ([latitudeVlaue, longitudeVlaue]) => {
  23708. const latitude = Number(latitudeVlaue);
  23709. const longitude = Number(longitudeVlaue);
  23710. if (latitude !== state2.latitude || longitude !== state2.longitude) {
  23711. state2.latitude = latitude;
  23712. state2.longitude = longitude;
  23713. if (map) {
  23714. const centerPosition = getMapPosition(maps2, state2.latitude, state2.longitude);
  23715. map.setCenter(centerPosition);
  23716. }
  23717. }
  23718. });
  23719. watch(() => props2.includePoints, (points) => {
  23720. state2.includePoints = getPoints(points);
  23721. if (isBoundsReady) {
  23722. updateBounds();
  23723. }
  23724. }, {
  23725. deep: true
  23726. });
  23727. function emitBoundsReady() {
  23728. isBoundsReady = true;
  23729. onBoundsReadyCallbacks.forEach((callback) => callback());
  23730. onBoundsReadyCallbacks.length = 0;
  23731. }
  23732. function getMapInfo2() {
  23733. const center = map.getCenter();
  23734. return {
  23735. scale: map.getZoom(),
  23736. centerLocation: {
  23737. latitude: getLat(center),
  23738. longitude: getLng(center)
  23739. }
  23740. };
  23741. }
  23742. function updateCenter() {
  23743. const centerPosition = getMapPosition(maps2, state2.latitude, state2.longitude);
  23744. map.setCenter(centerPosition);
  23745. }
  23746. function updateBounds() {
  23747. if (getIsAMap()) {
  23748. const points = [];
  23749. state2.includePoints.forEach((point) => {
  23750. points.push([point.longitude, point.latitude]);
  23751. });
  23752. const bounds = new maps2.Bounds(...points);
  23753. map.setBounds(bounds);
  23754. } else if (getIsBMap())
  23755. ;
  23756. else {
  23757. const bounds = new maps2.LatLngBounds();
  23758. state2.includePoints.forEach(({
  23759. latitude,
  23760. longitude
  23761. }) => {
  23762. const latLng = new maps2.LatLng(latitude, longitude);
  23763. bounds.extend(latLng);
  23764. });
  23765. map.fitBounds(bounds);
  23766. }
  23767. }
  23768. function initMap() {
  23769. const mapEl = mapRef.value;
  23770. const center = getMapPosition(maps2, state2.latitude, state2.longitude);
  23771. const event = maps2.event || maps2.Event;
  23772. const map2 = new maps2.Map(mapEl, {
  23773. center,
  23774. zoom: Number(props2.scale),
  23775. // scrollwheel: false,
  23776. disableDoubleClickZoom: true,
  23777. mapTypeControl: false,
  23778. zoomControl: false,
  23779. scaleControl: false,
  23780. panControl: false,
  23781. fullscreenControl: false,
  23782. streetViewControl: false,
  23783. keyboardShortcuts: false,
  23784. minZoom: 5,
  23785. maxZoom: 18,
  23786. draggable: true
  23787. });
  23788. if (getIsBMap()) {
  23789. map2.centerAndZoom(center, Number(props2.scale));
  23790. map2.enableScrollWheelZoom();
  23791. map2._printLog && map2._printLog("uniapp");
  23792. }
  23793. watch(() => props2.scale, (scale) => {
  23794. map2.setZoom(Number(scale) || 16);
  23795. });
  23796. onBoundsReady(() => {
  23797. if (state2.includePoints.length) {
  23798. updateBounds();
  23799. updateCenter();
  23800. }
  23801. });
  23802. if (getIsBMap()) {
  23803. map2.addEventListener("click", () => {
  23804. trigger("tap", {}, {});
  23805. trigger("click", {}, {});
  23806. });
  23807. map2.addEventListener("dragstart", () => {
  23808. trigger("regionchange", {}, {
  23809. type: "begin",
  23810. causedBy: "gesture"
  23811. });
  23812. });
  23813. map2.addEventListener("dragend", () => {
  23814. trigger("regionchange", {}, extend({
  23815. type: "end",
  23816. causedBy: "drag"
  23817. }, getMapInfo2()));
  23818. });
  23819. } else {
  23820. const boundsChangedEvent = event.addListener(map2, "bounds_changed", () => {
  23821. boundsChangedEvent.remove();
  23822. emitBoundsReady();
  23823. });
  23824. event.addListener(map2, "click", () => {
  23825. trigger("tap", {}, {});
  23826. trigger("click", {}, {});
  23827. });
  23828. event.addListener(map2, "dragstart", () => {
  23829. trigger("regionchange", {}, {
  23830. type: "begin",
  23831. causedBy: "gesture"
  23832. });
  23833. });
  23834. event.addListener(map2, "dragend", () => {
  23835. trigger("regionchange", {}, extend({
  23836. type: "end",
  23837. causedBy: "drag"
  23838. }, getMapInfo2()));
  23839. });
  23840. const zoomChangedCallback = () => {
  23841. emit2("update:scale", map2.getZoom());
  23842. trigger("regionchange", {}, extend({
  23843. type: "end",
  23844. causedBy: "scale"
  23845. }, getMapInfo2()));
  23846. };
  23847. event.addListener(map2, "zoom_changed", zoomChangedCallback);
  23848. event.addListener(map2, "zoomend", zoomChangedCallback);
  23849. event.addListener(map2, "center_changed", () => {
  23850. const center2 = map2.getCenter();
  23851. const latitude = getLat(center2);
  23852. const longitude = getLng(center2);
  23853. emit2("update:latitude", latitude);
  23854. emit2("update:longitude", longitude);
  23855. });
  23856. }
  23857. return map2;
  23858. }
  23859. try {
  23860. const id2 = useContextInfo();
  23861. useSubscribe((type, data = {}) => {
  23862. switch (type) {
  23863. case "getCenterLocation":
  23864. onMapReady(() => {
  23865. const center = map.getCenter();
  23866. callOptions(data, {
  23867. latitude: getLat(center),
  23868. longitude: getLng(center),
  23869. errMsg: `${type}:ok`
  23870. });
  23871. });
  23872. break;
  23873. case "moveToLocation":
  23874. {
  23875. let latitude = Number(data.latitude);
  23876. let longitude = Number(data.longitude);
  23877. if (!latitude || !longitude) {
  23878. const context = contexts[CONTEXT_ID];
  23879. if (context) {
  23880. latitude = context.state.latitude;
  23881. longitude = context.state.longitude;
  23882. }
  23883. }
  23884. if (latitude && longitude) {
  23885. state2.latitude = latitude;
  23886. state2.longitude = longitude;
  23887. if (map) {
  23888. const centerPosition = getMapPosition(maps2, latitude, longitude);
  23889. map.setCenter(centerPosition);
  23890. }
  23891. onMapReady(() => {
  23892. callOptions(data, `${type}:ok`);
  23893. });
  23894. } else {
  23895. callOptions(data, `${type}:fail`);
  23896. }
  23897. }
  23898. break;
  23899. case "translateMarker":
  23900. onMapReady(() => {
  23901. const context = contexts[data.markerId];
  23902. if (context) {
  23903. try {
  23904. context.translate(data);
  23905. } catch (error) {
  23906. callOptions(data, `${type}:fail ${error.message}`);
  23907. }
  23908. callOptions(data, `${type}:ok`);
  23909. } else {
  23910. callOptions(data, `${type}:fail not found`);
  23911. }
  23912. });
  23913. break;
  23914. case "includePoints":
  23915. state2.includePoints = getPoints(data.includePoints);
  23916. if (isBoundsReady || getIsAMap()) {
  23917. updateBounds();
  23918. }
  23919. onBoundsReady(() => {
  23920. callOptions(data, `${type}:ok`);
  23921. });
  23922. break;
  23923. case "getRegion":
  23924. onBoundsReady(() => {
  23925. const latLngBounds = map.getBounds();
  23926. const southwest = latLngBounds.getSouthWest();
  23927. const northeast = latLngBounds.getNorthEast();
  23928. callOptions(data, {
  23929. southwest: {
  23930. latitude: getLat(southwest),
  23931. longitude: getLng(southwest)
  23932. },
  23933. northeast: {
  23934. latitude: getLat(northeast),
  23935. longitude: getLng(northeast)
  23936. },
  23937. errMsg: `${type}:ok`
  23938. });
  23939. });
  23940. break;
  23941. case "getScale":
  23942. onMapReady(() => {
  23943. callOptions(data, {
  23944. scale: map.getZoom(),
  23945. errMsg: `${type}:ok`
  23946. });
  23947. });
  23948. break;
  23949. }
  23950. }, id2, true);
  23951. } catch (error) {
  23952. }
  23953. onMounted(() => {
  23954. loadMaps(props2.libraries, (result) => {
  23955. maps2 = result;
  23956. map = initMap();
  23957. emitMapReady();
  23958. trigger("updated", {}, {});
  23959. });
  23960. });
  23961. provide("onMapReady", onMapReady);
  23962. provide("addMapChidlContext", addMapChidlContext);
  23963. provide("removeMapChidlContext", removeMapChidlContext);
  23964. return {
  23965. state: state2,
  23966. mapRef,
  23967. trigger
  23968. };
  23969. }
  23970. const Map$1 = /* @__PURE__ */ defineBuiltInComponent({
  23971. name: "Map",
  23972. props: props$2,
  23973. emits: ["markertap", "labeltap", "callouttap", "controltap", "regionchange", "tap", "click", "updated", "update:scale", "update:latitude", "update:longitude"],
  23974. setup(props2, {
  23975. emit: emit2,
  23976. slots
  23977. }) {
  23978. const rootRef = ref(null);
  23979. const {
  23980. mapRef,
  23981. trigger
  23982. } = useMap(props2, rootRef, emit2);
  23983. return () => {
  23984. return createVNode("uni-map", {
  23985. "ref": rootRef,
  23986. "id": props2.id
  23987. }, [createVNode("div", {
  23988. "ref": mapRef,
  23989. "style": "width: 100%; height: 100%; position: relative; overflow: hidden"
  23990. }, null, 512), props2.markers.map((item) => createVNode(MapMarker, mergeProps({
  23991. "key": item.id
  23992. }, item), null, 16)), props2.polyline.map((item) => createVNode(MapPolyline, item, null, 16)), props2.circles.map((item) => createVNode(MapCircle, item, null, 16)), props2.controls.map((item) => createVNode(MapControl, mergeProps(item, {
  23993. "trigger": trigger
  23994. }), null, 16, ["trigger"])), props2.showLocation && createVNode(MapLocation, null, null), props2.polygons.map((item) => createVNode(MapPolygon, item, null, 16)), createVNode("div", {
  23995. "style": "position: absolute;top: 0;width: 100%;height: 100%;overflow: hidden;pointer-events: none;"
  23996. }, [slots.default && slots.default()])], 8, ["id"]);
  23997. };
  23998. }
  23999. });
  24000. const props$1 = {
  24001. scrollTop: {
  24002. type: [String, Number],
  24003. default: 0
  24004. }
  24005. };
  24006. const index$9 = /* @__PURE__ */ defineBuiltInComponent({
  24007. name: "CoverView",
  24008. compatConfig: {
  24009. MODE: 3
  24010. },
  24011. props: props$1,
  24012. setup(props2, {
  24013. slots
  24014. }) {
  24015. const root = ref(null);
  24016. const content = ref(null);
  24017. watch(() => props2.scrollTop, (val) => {
  24018. setScrollTop(val);
  24019. });
  24020. function setScrollTop(val) {
  24021. let _content = content.value;
  24022. if (getComputedStyle(_content).overflowY === "scroll") {
  24023. _content.scrollTop = _upx2pxNum(val);
  24024. }
  24025. }
  24026. function _upx2pxNum(val) {
  24027. let _val = String(val);
  24028. if (/\d+[ur]px$/i.test(_val)) {
  24029. _val.replace(/\d+[ur]px$/i, (text2) => {
  24030. return String(uni.upx2px(parseFloat(text2)));
  24031. });
  24032. }
  24033. return parseFloat(_val) || 0;
  24034. }
  24035. onMounted(() => {
  24036. setScrollTop(props2.scrollTop);
  24037. });
  24038. return () => {
  24039. return createVNode("uni-cover-view", {
  24040. "scroll-top": props2.scrollTop,
  24041. "ref": root
  24042. }, [createVNode("div", {
  24043. "ref": content,
  24044. "class": "uni-cover-view"
  24045. }, [slots.default && slots.default()], 512)], 8, ["scroll-top"]);
  24046. };
  24047. }
  24048. });
  24049. const index$8 = /* @__PURE__ */ defineBuiltInComponent({
  24050. name: "CoverImage",
  24051. compatConfig: {
  24052. MODE: 3
  24053. },
  24054. props: {
  24055. src: {
  24056. type: String,
  24057. default: ""
  24058. }
  24059. },
  24060. emits: ["load", "error"],
  24061. setup(props2, {
  24062. emit: emit2
  24063. }) {
  24064. const root = ref(null);
  24065. const trigger = useCustomEvent(root, emit2);
  24066. function load($event) {
  24067. trigger("load", $event);
  24068. }
  24069. function error($event) {
  24070. trigger("error", $event);
  24071. }
  24072. return () => {
  24073. const {
  24074. src
  24075. } = props2;
  24076. return createVNode("uni-cover-image", {
  24077. "ref": root,
  24078. "src": src
  24079. }, [createVNode("div", {
  24080. "class": "uni-cover-image"
  24081. }, [src ? createVNode("img", {
  24082. "src": getRealPath(src),
  24083. "onLoad": load,
  24084. "onError": error
  24085. }, null, 40, ["src", "onLoad", "onError"]) : null])], 8, ["src"]);
  24086. };
  24087. }
  24088. });
  24089. function _isSlot(s) {
  24090. return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
  24091. }
  24092. function getDefaultStartValue(props2) {
  24093. if (props2.mode === mode.TIME) {
  24094. return "00:00";
  24095. }
  24096. if (props2.mode === mode.DATE) {
  24097. const year = (/* @__PURE__ */ new Date()).getFullYear() - 150;
  24098. switch (props2.fields) {
  24099. case fields.YEAR:
  24100. return year.toString();
  24101. case fields.MONTH:
  24102. return year + "-01";
  24103. default:
  24104. return year + "-01-01";
  24105. }
  24106. }
  24107. return "";
  24108. }
  24109. function getDefaultEndValue(props2) {
  24110. if (props2.mode === mode.TIME) {
  24111. return "23:59";
  24112. }
  24113. if (props2.mode === mode.DATE) {
  24114. const year = (/* @__PURE__ */ new Date()).getFullYear() + 150;
  24115. switch (props2.fields) {
  24116. case fields.YEAR:
  24117. return year.toString();
  24118. case fields.MONTH:
  24119. return year + "-12";
  24120. default:
  24121. return year + "-12-31";
  24122. }
  24123. }
  24124. return "";
  24125. }
  24126. function getDateValueArray(props2, state2, valueStr, defaultValue) {
  24127. const splitStr = props2.mode === mode.DATE ? "-" : ":";
  24128. const array = props2.mode === mode.DATE ? state2.dateArray : state2.timeArray;
  24129. let max;
  24130. if (props2.mode === mode.TIME) {
  24131. max = 2;
  24132. } else {
  24133. switch (props2.fields) {
  24134. case fields.YEAR:
  24135. max = 1;
  24136. break;
  24137. case fields.MONTH:
  24138. max = 2;
  24139. break;
  24140. default:
  24141. max = 3;
  24142. break;
  24143. }
  24144. }
  24145. const inputArray = String(valueStr).split(splitStr);
  24146. let value = [];
  24147. for (let i = 0; i < max; i++) {
  24148. const val = inputArray[i];
  24149. value.push(array[i].indexOf(val));
  24150. }
  24151. if (value.indexOf(-1) >= 0) {
  24152. value = defaultValue ? getDateValueArray(props2, state2, defaultValue) : value.map(() => 0);
  24153. }
  24154. return value;
  24155. }
  24156. const mode = {
  24157. SELECTOR: "selector",
  24158. MULTISELECTOR: "multiSelector",
  24159. TIME: "time",
  24160. DATE: "date"
  24161. // 暂不支持城市选择
  24162. // REGION: 'region'
  24163. };
  24164. const fields = {
  24165. YEAR: "year",
  24166. MONTH: "month",
  24167. DAY: "day"
  24168. };
  24169. const selectorType = {
  24170. PICKER: "picker",
  24171. SELECT: "select"
  24172. };
  24173. const props = {
  24174. name: {
  24175. type: String,
  24176. default: ""
  24177. },
  24178. range: {
  24179. type: Array,
  24180. default() {
  24181. return [];
  24182. }
  24183. },
  24184. rangeKey: {
  24185. type: String,
  24186. default: ""
  24187. },
  24188. value: {
  24189. type: [Number, String, Array],
  24190. default: 0
  24191. },
  24192. mode: {
  24193. type: String,
  24194. default: mode.SELECTOR,
  24195. validator(val) {
  24196. return Object.values(mode).includes(val);
  24197. }
  24198. },
  24199. fields: {
  24200. type: String,
  24201. default: ""
  24202. },
  24203. start: {
  24204. type: String,
  24205. default: (props2) => {
  24206. return getDefaultStartValue(props2);
  24207. }
  24208. },
  24209. end: {
  24210. type: String,
  24211. default: (props2) => {
  24212. return getDefaultEndValue(props2);
  24213. }
  24214. },
  24215. disabled: {
  24216. type: [Boolean, String],
  24217. default: false
  24218. },
  24219. selectorType: {
  24220. type: String,
  24221. default: ""
  24222. }
  24223. };
  24224. const index$7 = /* @__PURE__ */ defineBuiltInComponent({
  24225. name: "Picker",
  24226. compatConfig: {
  24227. MODE: 3
  24228. },
  24229. props,
  24230. emits: ["change", "cancel", "columnchange"],
  24231. setup(props2, {
  24232. emit: emit2,
  24233. slots
  24234. }) {
  24235. initI18nPickerMsgsOnce();
  24236. const {
  24237. t: t2
  24238. } = useI18n();
  24239. const rootRef = ref(null);
  24240. const pickerRef = ref(null);
  24241. const selectRef = ref(null);
  24242. const inputRef = ref(null);
  24243. const pickerRender = ref(false);
  24244. const {
  24245. state: state2,
  24246. rangeArray
  24247. } = usePickerState(props2);
  24248. const trigger = useCustomEvent(rootRef, emit2);
  24249. const {
  24250. system,
  24251. selectorTypeComputed,
  24252. _show,
  24253. _l10nColumn,
  24254. _l10nItem,
  24255. _input,
  24256. _fixInputPosition,
  24257. _pickerViewChange,
  24258. _cancel,
  24259. _change,
  24260. _resetFormData,
  24261. _getFormData,
  24262. _createTime,
  24263. _createDate,
  24264. _setValueSync
  24265. } = usePickerMethods(props2, state2, trigger, rootRef, pickerRef, selectRef, inputRef);
  24266. usePickerWatch(state2, _cancel, _change);
  24267. usePickerForm(_resetFormData, _getFormData);
  24268. _createTime();
  24269. _createDate();
  24270. _setValueSync();
  24271. const popup = usePopupStyle(state2);
  24272. watchEffect(() => {
  24273. state2.isDesktop = popup.isDesktop.value;
  24274. state2.popupStyle = popup.popupStyle.value;
  24275. });
  24276. onBeforeUnmount(() => {
  24277. pickerRef.value && pickerRef.value.remove();
  24278. });
  24279. onMounted(() => {
  24280. pickerRender.value = true;
  24281. });
  24282. return () => {
  24283. let _slot2;
  24284. const {
  24285. visible,
  24286. contentVisible,
  24287. valueArray,
  24288. popupStyle,
  24289. valueSync
  24290. } = state2;
  24291. const {
  24292. rangeKey,
  24293. mode: mode2,
  24294. start,
  24295. end
  24296. } = props2;
  24297. const booleanAttrs = useBooleanAttr(props2, "disabled");
  24298. return createVNode("uni-picker", mergeProps({
  24299. "ref": rootRef
  24300. }, booleanAttrs, {
  24301. "onClick": withWebEvent(_show)
  24302. }), [pickerRender.value ? createVNode("div", {
  24303. "ref": pickerRef,
  24304. "class": ["uni-picker-container", `uni-${mode2}-${selectorTypeComputed.value}`],
  24305. "onWheel": onEventPrevent,
  24306. "onTouchmove": onEventPrevent
  24307. }, [createVNode(Transition, {
  24308. "name": "uni-fade"
  24309. }, {
  24310. default: () => [withDirectives(createVNode("div", {
  24311. "class": "uni-mask uni-picker-mask",
  24312. "onClick": withWebEvent(_cancel),
  24313. "onMousemove": _fixInputPosition
  24314. }, null, 40, ["onClick", "onMousemove"]), [[vShow, visible]])]
  24315. }), !system.value ? createVNode("div", {
  24316. "class": [{
  24317. "uni-picker-toggle": visible
  24318. }, "uni-picker-custom"],
  24319. "style": popupStyle.content
  24320. }, [createVNode("div", {
  24321. "class": "uni-picker-header",
  24322. "onClick": onEventStop
  24323. }, [createVNode("div", {
  24324. "class": "uni-picker-action uni-picker-action-cancel",
  24325. "onClick": withWebEvent(_cancel)
  24326. }, [t2("uni.picker.cancel")], 8, ["onClick"]), createVNode("div", {
  24327. "class": "uni-picker-action uni-picker-action-confirm",
  24328. "onClick": _change
  24329. }, [t2("uni.picker.done")], 8, ["onClick"])], 8, ["onClick"]), contentVisible ? createVNode(PickerView, {
  24330. "value": _l10nColumn(valueArray),
  24331. "class": "uni-picker-content",
  24332. "onChange": _pickerViewChange
  24333. }, _isSlot(_slot2 = renderList(_l10nColumn(rangeArray.value), (rangeItem, index0) => {
  24334. let _slot;
  24335. return createVNode(PickerViewColumn, {
  24336. "key": index0
  24337. }, _isSlot(_slot = renderList(rangeItem, (item, index2) => createVNode("div", {
  24338. "key": index2,
  24339. "class": "uni-picker-item"
  24340. }, [typeof item === "object" ? item[rangeKey] || "" : _l10nItem(item, index0)]))) ? _slot : {
  24341. default: () => [_slot],
  24342. _: 1
  24343. });
  24344. })) ? _slot2 : {
  24345. default: () => [_slot2],
  24346. _: 1
  24347. }, 8, ["value", "onChange"]) : null, createVNode("div", {
  24348. "ref": selectRef,
  24349. "class": "uni-picker-select",
  24350. "onWheel": onEventStop,
  24351. "onTouchmove": onEventStop
  24352. }, [renderList(rangeArray.value[0], (item, index2) => createVNode("div", {
  24353. "key": index2,
  24354. "class": ["uni-picker-item", {
  24355. selected: valueArray[0] === index2
  24356. }],
  24357. "onClick": () => {
  24358. valueArray[0] = index2;
  24359. _change();
  24360. }
  24361. }, [typeof item === "object" ? item[rangeKey] || "" : item], 10, ["onClick"]))], 40, ["onWheel", "onTouchmove"]), createVNode("div", {
  24362. "style": popupStyle.triangle
  24363. }, null, 4)], 6) : null], 40, ["onWheel", "onTouchmove"]) : null, createVNode("div", null, [slots.default && slots.default()]), system.value ? createVNode("div", {
  24364. "class": "uni-picker-system",
  24365. "onMousemove": withWebEvent(_fixInputPosition)
  24366. }, [createVNode("input", {
  24367. "class": ["uni-picker-system_input", system.value],
  24368. "ref": inputRef,
  24369. "value": valueSync,
  24370. "type": mode2,
  24371. "tabindex": "-1",
  24372. "min": start,
  24373. "max": end,
  24374. "onChange": ($event) => {
  24375. _input($event);
  24376. onEventStop($event);
  24377. }
  24378. }, null, 42, ["value", "type", "min", "max", "onChange"])], 40, ["onMousemove"]) : null], 16, ["onClick"]);
  24379. };
  24380. }
  24381. });
  24382. function usePickerState(props2) {
  24383. const state2 = reactive({
  24384. valueSync: void 0,
  24385. visible: false,
  24386. contentVisible: false,
  24387. popover: null,
  24388. valueChangeSource: "",
  24389. timeArray: [],
  24390. dateArray: [],
  24391. valueArray: [],
  24392. oldValueArray: [],
  24393. isDesktop: false,
  24394. popupStyle: {
  24395. content: {},
  24396. triangle: {}
  24397. }
  24398. });
  24399. const rangeArray = computed(() => {
  24400. let val = props2.range;
  24401. switch (props2.mode) {
  24402. case mode.SELECTOR:
  24403. return [val];
  24404. case mode.MULTISELECTOR:
  24405. return val;
  24406. case mode.TIME:
  24407. return state2.timeArray;
  24408. case mode.DATE: {
  24409. const dateArray = state2.dateArray;
  24410. switch (props2.fields) {
  24411. case fields.YEAR:
  24412. return [dateArray[0]];
  24413. case fields.MONTH:
  24414. return [dateArray[0], dateArray[1]];
  24415. default:
  24416. return [dateArray[0], dateArray[1], dateArray[2]];
  24417. }
  24418. }
  24419. }
  24420. return [];
  24421. });
  24422. return {
  24423. state: state2,
  24424. rangeArray
  24425. };
  24426. }
  24427. const getiPadFlag = () => String(navigator.vendor).indexOf("Apple") === 0 && navigator.maxTouchPoints > 0;
  24428. function useIsiPad() {
  24429. const isiPad = ref(false);
  24430. {
  24431. isiPad.value = getiPadFlag();
  24432. }
  24433. return isiPad;
  24434. }
  24435. const getSystem = () => {
  24436. if (/win|mac/i.test(navigator.platform)) {
  24437. if (navigator.vendor === "Google Inc.") {
  24438. return "chrome";
  24439. } else if (/Firefox/.test(navigator.userAgent)) {
  24440. return "firefox";
  24441. }
  24442. }
  24443. return "";
  24444. };
  24445. function useSystem() {
  24446. const _system = ref("");
  24447. {
  24448. _system.value = getSystem();
  24449. }
  24450. return _system;
  24451. }
  24452. let __contentVisibleDelay;
  24453. function usePickerMethods(props2, state2, trigger, rootRef, pickerRef, selectRef, inputRef) {
  24454. const isiPad = useIsiPad();
  24455. const _system = useSystem();
  24456. const selectorTypeComputed = computed(() => {
  24457. const type = props2.selectorType;
  24458. if (Object.values(selectorType).includes(type)) {
  24459. return type;
  24460. }
  24461. return isiPad.value ? selectorType.PICKER : selectorType.SELECT;
  24462. });
  24463. const system = computed(() => {
  24464. if (props2.mode === mode.DATE && !Object.values(fields).includes(props2.fields) && state2.isDesktop) {
  24465. return _system.value;
  24466. }
  24467. return "";
  24468. });
  24469. const startArray = computed(() => {
  24470. return getDateValueArray(props2, state2, props2.start, getDefaultStartValue(props2));
  24471. });
  24472. const endArray = computed(() => {
  24473. return getDateValueArray(props2, state2, props2.end, getDefaultEndValue(props2));
  24474. });
  24475. function _show(event) {
  24476. if (props2.disabled) {
  24477. return;
  24478. }
  24479. state2.valueChangeSource = "";
  24480. let $picker = pickerRef.value;
  24481. let _currentTarget = event.currentTarget;
  24482. $picker.remove();
  24483. (document.querySelector("uni-app") || document.body).appendChild($picker);
  24484. $picker.style.display = "block";
  24485. const rect = _currentTarget.getBoundingClientRect();
  24486. state2.popover = {
  24487. top: rect.top,
  24488. left: rect.left,
  24489. width: rect.width,
  24490. height: rect.height
  24491. };
  24492. setTimeout(() => {
  24493. state2.visible = true;
  24494. }, 20);
  24495. }
  24496. function _getFormData() {
  24497. return {
  24498. value: state2.valueSync,
  24499. key: props2.name
  24500. };
  24501. }
  24502. function _resetFormData() {
  24503. switch (props2.mode) {
  24504. case mode.SELECTOR:
  24505. state2.valueSync = 0;
  24506. break;
  24507. case mode.MULTISELECTOR:
  24508. state2.valueSync = props2.value.map((val) => 0);
  24509. break;
  24510. case mode.DATE:
  24511. case mode.TIME:
  24512. state2.valueSync = "";
  24513. break;
  24514. }
  24515. }
  24516. function _createTime() {
  24517. let hours = [];
  24518. let minutes = [];
  24519. for (let i = 0; i < 24; i++) {
  24520. hours.push((i < 10 ? "0" : "") + i);
  24521. }
  24522. for (let i = 0; i < 60; i++) {
  24523. minutes.push((i < 10 ? "0" : "") + i);
  24524. }
  24525. state2.timeArray.push(hours, minutes);
  24526. }
  24527. function getYearStartEnd() {
  24528. let year = (/* @__PURE__ */ new Date()).getFullYear();
  24529. let start = year - 150;
  24530. let end = year + 150;
  24531. if (props2.start) {
  24532. const _year = new Date(props2.start).getFullYear();
  24533. if (!isNaN(_year) && _year < start) {
  24534. start = _year;
  24535. }
  24536. }
  24537. if (props2.end) {
  24538. const _year = new Date(props2.end).getFullYear();
  24539. if (!isNaN(_year) && _year > end) {
  24540. end = _year;
  24541. }
  24542. }
  24543. return {
  24544. start,
  24545. end
  24546. };
  24547. }
  24548. function _createDate() {
  24549. let years = [];
  24550. const year = getYearStartEnd();
  24551. for (let i = year.start, end = year.end; i <= end; i++) {
  24552. years.push(String(i));
  24553. }
  24554. let months = [];
  24555. for (let i = 1; i <= 12; i++) {
  24556. months.push((i < 10 ? "0" : "") + i);
  24557. }
  24558. let days = [];
  24559. for (let i = 1; i <= 31; i++) {
  24560. days.push((i < 10 ? "0" : "") + i);
  24561. }
  24562. state2.dateArray.push(years, months, days);
  24563. }
  24564. function _getTimeValue(val) {
  24565. return val[0] * 60 + val[1];
  24566. }
  24567. function _getDateValue(val) {
  24568. const DAY = 31;
  24569. return val[0] * DAY * 12 + (val[1] || 0) * DAY + (val[2] || 0);
  24570. }
  24571. function _cloneArray(val1, val2) {
  24572. for (let i = 0; i < val1.length && i < val2.length; i++) {
  24573. val1[i] = val2[i];
  24574. }
  24575. }
  24576. function _setValueSync() {
  24577. let val = props2.value;
  24578. switch (props2.mode) {
  24579. case mode.MULTISELECTOR:
  24580. {
  24581. if (!isArray(val)) {
  24582. val = state2.valueArray;
  24583. }
  24584. if (!isArray(state2.valueSync)) {
  24585. state2.valueSync = [];
  24586. }
  24587. const length = state2.valueSync.length = Math.max(val.length, props2.range.length);
  24588. for (let index2 = 0; index2 < length; index2++) {
  24589. const val0 = Number(val[index2]);
  24590. const val1 = Number(state2.valueSync[index2]);
  24591. const val2 = isNaN(val0) ? isNaN(val1) ? 0 : val1 : val0;
  24592. const maxVal = props2.range[index2] ? props2.range[index2].length - 1 : 0;
  24593. state2.valueSync.splice(index2, 1, val2 < 0 || val2 > maxVal ? 0 : val2);
  24594. }
  24595. }
  24596. break;
  24597. case mode.TIME:
  24598. case mode.DATE:
  24599. state2.valueSync = String(val);
  24600. break;
  24601. default: {
  24602. const valueSync = Number(val);
  24603. state2.valueSync = valueSync < 0 ? 0 : valueSync;
  24604. break;
  24605. }
  24606. }
  24607. }
  24608. function _setValueArray() {
  24609. let val = state2.valueSync;
  24610. let valueArray;
  24611. switch (props2.mode) {
  24612. case mode.MULTISELECTOR:
  24613. valueArray = [...val];
  24614. break;
  24615. case mode.TIME:
  24616. valueArray = getDateValueArray(props2, state2, val, formatDateTime({
  24617. mode: mode.TIME
  24618. }));
  24619. break;
  24620. case mode.DATE:
  24621. valueArray = getDateValueArray(props2, state2, val, formatDateTime({
  24622. mode: mode.DATE
  24623. }));
  24624. break;
  24625. default:
  24626. valueArray = [val];
  24627. break;
  24628. }
  24629. state2.oldValueArray = [...valueArray];
  24630. state2.valueArray = [...valueArray];
  24631. }
  24632. function _getValue() {
  24633. let val = state2.valueArray;
  24634. switch (props2.mode) {
  24635. case mode.SELECTOR:
  24636. return val[0];
  24637. case mode.MULTISELECTOR:
  24638. return val.map((val2) => val2);
  24639. case mode.TIME:
  24640. return state2.valueArray.map((val2, i) => state2.timeArray[i][val2]).join(":");
  24641. case mode.DATE:
  24642. return state2.valueArray.map((val2, i) => state2.dateArray[i][val2]).join("-");
  24643. }
  24644. }
  24645. function _change() {
  24646. _close();
  24647. state2.valueChangeSource = "click";
  24648. const value = _getValue();
  24649. state2.valueSync = isArray(value) ? value.map((val) => val) : value;
  24650. trigger("change", {}, {
  24651. value
  24652. });
  24653. }
  24654. function _cancel($event) {
  24655. if (system.value === "firefox" && $event) {
  24656. const {
  24657. top,
  24658. left,
  24659. width,
  24660. height
  24661. } = state2.popover;
  24662. const {
  24663. pageX,
  24664. pageY
  24665. } = $event;
  24666. if (pageX > left && pageX < left + width && pageY > top && pageY < top + height) {
  24667. return;
  24668. }
  24669. }
  24670. _close();
  24671. trigger("cancel", {}, {});
  24672. }
  24673. function _close() {
  24674. state2.visible = false;
  24675. setTimeout(() => {
  24676. let $picker = pickerRef.value;
  24677. $picker.remove();
  24678. rootRef.value.prepend($picker);
  24679. $picker.style.display = "none";
  24680. }, 260);
  24681. }
  24682. function _select() {
  24683. if (props2.mode === mode.SELECTOR && selectorTypeComputed.value === selectorType.SELECT) {
  24684. selectRef.value.scrollTop = state2.valueArray[0] * 34;
  24685. }
  24686. }
  24687. function _input($event) {
  24688. const EventTarget = $event.target;
  24689. state2.valueSync = EventTarget.value;
  24690. nextTick(() => {
  24691. _change();
  24692. });
  24693. }
  24694. function _fixInputPosition($event) {
  24695. if (system.value === "chrome") {
  24696. const rect = rootRef.value.getBoundingClientRect();
  24697. const fontSize = 32;
  24698. inputRef.value.style.left = `${$event.clientX - rect.left - fontSize * 1.5}px`;
  24699. inputRef.value.style.top = `${$event.clientY - rect.top - fontSize * 0.5}px`;
  24700. }
  24701. }
  24702. function _pickerViewChange(event) {
  24703. state2.valueArray = _l10nColumn(event.detail.value, true);
  24704. }
  24705. function _l10nColumn(array, normalize) {
  24706. const {
  24707. getLocale: getLocale2
  24708. } = useI18n();
  24709. if (props2.mode === mode.DATE) {
  24710. const locale = getLocale2();
  24711. if (!locale.startsWith("zh")) {
  24712. switch (props2.fields) {
  24713. case fields.YEAR:
  24714. return array;
  24715. case fields.MONTH:
  24716. return [array[1], array[0]];
  24717. default:
  24718. switch (locale) {
  24719. case "es":
  24720. case "fr":
  24721. return [array[2], array[1], array[0]];
  24722. default:
  24723. return normalize ? [array[2], array[0], array[1]] : [array[1], array[2], array[0]];
  24724. }
  24725. }
  24726. }
  24727. }
  24728. return array;
  24729. }
  24730. function _l10nItem(item, index2) {
  24731. const {
  24732. getLocale: getLocale2
  24733. } = useI18n();
  24734. if (props2.mode === mode.DATE) {
  24735. const locale = getLocale2();
  24736. if (locale.startsWith("zh")) {
  24737. const array = ["年", "月", "日"];
  24738. return item + array[index2];
  24739. } else if (props2.fields !== fields.YEAR && index2 === (props2.fields !== fields.MONTH && (locale === "es" || locale === "fr") ? 1 : 0)) {
  24740. let array;
  24741. switch (locale) {
  24742. case "es":
  24743. array = ["enero", "febrero", "marzo", "abril", "mayo", "junio", "​​julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"];
  24744. break;
  24745. case "fr":
  24746. array = ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"];
  24747. break;
  24748. default:
  24749. array = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
  24750. break;
  24751. }
  24752. return array[Number(item) - 1];
  24753. }
  24754. }
  24755. return item;
  24756. }
  24757. watch(() => state2.visible, (val) => {
  24758. if (val) {
  24759. clearTimeout(__contentVisibleDelay);
  24760. state2.contentVisible = val;
  24761. _select();
  24762. } else {
  24763. __contentVisibleDelay = setTimeout(() => {
  24764. state2.contentVisible = val;
  24765. }, 300);
  24766. }
  24767. });
  24768. watch([() => props2.mode, () => props2.value, () => props2.range], _setValueSync, {
  24769. deep: true
  24770. });
  24771. watch(() => state2.valueSync, _setValueArray, {
  24772. deep: true
  24773. });
  24774. watch(() => state2.valueArray, (val) => {
  24775. if (props2.mode === mode.TIME || props2.mode === mode.DATE) {
  24776. const getValue = props2.mode === mode.TIME ? _getTimeValue : _getDateValue;
  24777. const valueArray = state2.valueArray;
  24778. const _startArray = startArray.value;
  24779. const _endArray = endArray.value;
  24780. if (props2.mode === mode.DATE) {
  24781. const dateArray = state2.dateArray;
  24782. const max = dateArray[2].length;
  24783. const day = Number(dateArray[2][valueArray[2]]) || 1;
  24784. const realDay = (/* @__PURE__ */ new Date(`${dateArray[0][valueArray[0]]}/${dateArray[1][valueArray[1]]}/${day}`)).getDate();
  24785. if (realDay < day) {
  24786. valueArray[2] -= realDay + max - day;
  24787. }
  24788. }
  24789. if (getValue(valueArray) < getValue(_startArray)) {
  24790. _cloneArray(valueArray, _startArray);
  24791. } else if (getValue(valueArray) > getValue(_endArray)) {
  24792. _cloneArray(valueArray, _endArray);
  24793. }
  24794. }
  24795. val.forEach((value, column) => {
  24796. if (value !== state2.oldValueArray[column]) {
  24797. state2.oldValueArray[column] = value;
  24798. if (props2.mode === mode.MULTISELECTOR) {
  24799. trigger("columnchange", {}, {
  24800. column,
  24801. value
  24802. });
  24803. }
  24804. }
  24805. });
  24806. });
  24807. return {
  24808. selectorTypeComputed,
  24809. system,
  24810. _show,
  24811. _cancel,
  24812. _change,
  24813. _l10nColumn,
  24814. _l10nItem,
  24815. _input,
  24816. _resetFormData,
  24817. _getFormData,
  24818. _createTime,
  24819. _createDate,
  24820. _setValueSync,
  24821. _fixInputPosition,
  24822. _pickerViewChange
  24823. };
  24824. }
  24825. function usePickerWatch(state2, _cancel, _change) {
  24826. const {
  24827. key,
  24828. disable
  24829. } = useKeyboard();
  24830. watchEffect(() => {
  24831. disable.value = !state2.visible;
  24832. });
  24833. watch(key, (value) => {
  24834. if (value === "esc") {
  24835. _cancel();
  24836. } else if (value === "enter") {
  24837. _change();
  24838. }
  24839. });
  24840. }
  24841. function usePickerForm(_resetFormData, _getFormData) {
  24842. const uniForm = inject(uniFormKey, false);
  24843. if (uniForm) {
  24844. const field = {
  24845. reset: _resetFormData,
  24846. submit: () => {
  24847. const data = ["", null];
  24848. const {
  24849. key,
  24850. value
  24851. } = _getFormData();
  24852. if (key !== "") {
  24853. data[0] = key;
  24854. data[1] = value;
  24855. }
  24856. return data;
  24857. }
  24858. };
  24859. uniForm.addField(field);
  24860. onBeforeUnmount(() => {
  24861. uniForm.removeField(field);
  24862. });
  24863. }
  24864. }
  24865. const index$6 = /* @__PURE__ */ defineUnsupportedComponent("ad");
  24866. const index$5 = /* @__PURE__ */ defineUnsupportedComponent("ad-content-page");
  24867. const index$4 = /* @__PURE__ */ defineUnsupportedComponent("ad-draw");
  24868. const index$3 = /* @__PURE__ */ defineUnsupportedComponent("camera");
  24869. const index$2 = /* @__PURE__ */ defineUnsupportedComponent("live-player");
  24870. const index$1 = /* @__PURE__ */ defineUnsupportedComponent("live-pusher");
  24871. const UniViewJSBridge$1 = /* @__PURE__ */ extend(ViewJSBridge, {
  24872. publishHandler(event, args, pageId) {
  24873. UniServiceJSBridge.subscribeHandler(event, args, pageId);
  24874. }
  24875. });
  24876. const uni$1 = api;
  24877. const UniServiceJSBridge$1 = /* @__PURE__ */ extend(ServiceJSBridge, {
  24878. publishHandler(event, args, pageId) {
  24879. UniViewJSBridge.subscribeHandler(event, args, pageId);
  24880. }
  24881. });
  24882. function usePageHeadTransparentBackgroundColor(backgroundColor) {
  24883. const { r, g: g2, b } = hexToRgba(backgroundColor);
  24884. return `rgba(${r},${g2},${b},0)`;
  24885. }
  24886. function usePageHeadTransparent(headRef, {
  24887. id: id2,
  24888. navigationBar: { titleColor, coverage, backgroundColor }
  24889. }) {
  24890. let A = 0;
  24891. const rgb = computed(() => hexToRgba(backgroundColor));
  24892. const offset = parseInt(coverage);
  24893. let titleElem;
  24894. let transparentElemStyle;
  24895. const iconElemsPaths = [];
  24896. const borderRadiusElemsStyles = [];
  24897. const oldColors = [];
  24898. onMounted(() => {
  24899. const $el = headRef.value;
  24900. transparentElemStyle = $el.style;
  24901. titleElem = $el.querySelector(".uni-page-head__title");
  24902. const borderRadiusElems = $el.querySelectorAll(
  24903. ".uni-page-head-btn"
  24904. );
  24905. const iconSvgElems = $el.querySelectorAll(
  24906. "svg path"
  24907. );
  24908. for (let i = 0; i < iconSvgElems.length; i++) {
  24909. iconElemsPaths.push(iconSvgElems[i]);
  24910. }
  24911. for (let i = 0; i < borderRadiusElems.length; i++) {
  24912. const borderRadiusElem = borderRadiusElems[i];
  24913. oldColors.push(getComputedStyle(borderRadiusElem).backgroundColor);
  24914. borderRadiusElemsStyles.push(borderRadiusElem.style);
  24915. }
  24916. });
  24917. useOn(id2 + ".onPageScroll", ({ scrollTop }) => {
  24918. const alpha = Math.min(scrollTop / offset, 1);
  24919. if (alpha === 1 && A === 1) {
  24920. return;
  24921. }
  24922. if (alpha > 0.5 && A <= 0.5) {
  24923. iconElemsPaths.forEach(function(iconElemPath) {
  24924. iconElemPath.setAttribute("fill", titleColor);
  24925. });
  24926. } else if (alpha <= 0.5 && A > 0.5) {
  24927. iconElemsPaths.forEach(function(iconElemPath) {
  24928. iconElemPath.setAttribute("fill", "#fff");
  24929. });
  24930. }
  24931. A = alpha;
  24932. if (titleElem) {
  24933. titleElem.style.opacity = alpha;
  24934. }
  24935. const bg = rgb.value;
  24936. transparentElemStyle.backgroundColor = `rgba(${bg.r},${bg.g},${bg.b},${alpha})`;
  24937. borderRadiusElemsStyles.forEach(function(borderRadiusElemStyle, index2) {
  24938. const oldColor = oldColors[index2];
  24939. const rgba = oldColor.match(/[\d+\.]+/g);
  24940. rgba[3] = (1 - alpha) * (rgba.length === 4 ? rgba[3] : 1);
  24941. borderRadiusElemStyle.backgroundColor = `rgba(${rgba})`;
  24942. });
  24943. });
  24944. }
  24945. const ICON_PATHS = {
  24946. none: "",
  24947. forward: "M11 7.844q-0.25-0.219-0.25-0.578t0.25-0.578q0.219-0.25 0.563-0.25t0.563 0.25l9.656 9.125q0.125 0.125 0.188 0.297t0.063 0.328q0 0.188-0.063 0.359t-0.188 0.297l-9.656 9.125q-0.219 0.25-0.563 0.25t-0.563-0.25q-0.25-0.219-0.25-0.578t0.25-0.609l9.063-8.594-9.063-8.594z",
  24948. back: ICON_PATH_BACK,
  24949. select: ICON_PATH_BACK,
  24950. share: "M26.563 24.844q0 0.125-0.109 0.234t-0.234 0.109h-17.938q-0.125 0-0.219-0.109t-0.094-0.234v-13.25q0-0.156 0.094-0.25t0.219-0.094h5.5v-1.531h-6q-0.531 0-0.906 0.391t-0.375 0.922v14.375q0 0.531 0.375 0.922t0.906 0.391h18.969q0.531 0 0.891-0.391t0.359-0.953v-5.156h-1.438v4.625zM29.813 10.969l-5.125-5.375-1.031 1.094 3.438 3.594-3.719 0.031q-2.313 0.188-4.344 1.125t-3.578 2.422-2.5 3.453-1.109 4.188l-0.031 0.25h1.469v-0.219q0.156-1.875 1-3.594t2.25-3.063 3.234-2.125 3.828-0.906l0.188-0.031 3.313-0.031-3.438 3.625 1.031 1.063 5.125-5.375-0.031-0.063 0.031-0.063z",
  24951. favorite: "M27.594 13.375q-0.063-0.188-0.219-0.313t-0.344-0.156l-7.094-0.969-3.219-6.406q-0.094-0.188-0.25-0.281t-0.375-0.094q-0.188 0-0.344 0.094t-0.25 0.281l-3.125 6.438-7.094 1.094q-0.188 0.031-0.344 0.156t-0.219 0.313q-0.031 0.188 0.016 0.375t0.172 0.313l5.156 4.969-1.156 7.063q-0.031 0.188 0.047 0.375t0.234 0.313q0.094 0.063 0.188 0.094t0.219 0.031q0.063 0 0.141-0.031t0.172-0.063l6.313-3.375 6.375 3.313q0.063 0.031 0.141 0.047t0.172 0.016q0.188 0 0.344-0.094t0.25-0.281q0.063-0.094 0.078-0.234t-0.016-0.234q0-0.031 0-0.063l-1.25-6.938 5.094-5.031q0.156-0.156 0.203-0.344t-0.016-0.375zM11.469 19.063q0.031-0.188-0.016-0.344t-0.172-0.281l-4.406-4.25 6.063-0.906q0.156-0.031 0.297-0.125t0.203-0.25l2.688-5.531 2.75 5.5q0.063 0.156 0.203 0.25t0.297 0.125l6.094 0.844-4.375 4.281q-0.125 0.125-0.172 0.297t-0.016 0.328l1.063 6.031-5.438-2.813q-0.156-0.094-0.328-0.078t-0.297 0.078l-5.438 2.875 1-6.031z",
  24952. home: "M23.719 16.5q-0.313 0-0.531 0.219t-0.219 0.5v7.063q0 0.219-0.172 0.391t-0.391 0.172h-12.344q-0.25 0-0.422-0.172t-0.172-0.391v-7.063q0-0.281-0.219-0.5t-0.531-0.219q-0.281 0-0.516 0.219t-0.234 0.5v7.063q0.031 0.844 0.625 1.453t1.438 0.609h12.375q0.844 0 1.453-0.609t0.609-1.453v-7.063q0-0.125-0.063-0.266t-0.156-0.234q-0.094-0.125-0.234-0.172t-0.297-0.047zM26.5 14.875l-8.813-8.813q-0.313-0.313-0.688-0.453t-0.781-0.141-0.781 0.141-0.656 0.422l-8.813 8.844q-0.188 0.219-0.188 0.516t0.219 0.484q0.094 0.125 0.234 0.172t0.297 0.047q0.125 0 0.25-0.047t0.25-0.141l8.781-8.781q0.156-0.156 0.406-0.156t0.406 0.156l8.813 8.781q0.219 0.188 0.516 0.188t0.516-0.219q0.188-0.188 0.203-0.484t-0.172-0.516z",
  24953. menu: "M8.938 18.313q0.875 0 1.484-0.609t0.609-1.453-0.609-1.453-1.484-0.609q-0.844 0-1.453 0.609t-0.609 1.453 0.609 1.453 1.453 0.609zM16.188 18.313q0.875 0 1.484-0.609t0.609-1.453-0.609-1.453-1.484-0.609q-0.844 0-1.453 0.609t-0.609 1.453 0.609 1.453 1.453 0.609zM23.469 18.313q0.844 0 1.453-0.609t0.609-1.453-0.609-1.453-1.453-0.609q-0.875 0-1.484 0.609t-0.609 1.453 0.609 1.453 1.484 0.609z",
  24954. close: ICON_PATH_CLOSE
  24955. };
  24956. const PageHead = /* @__PURE__ */ defineSystemComponent({
  24957. name: "PageHead",
  24958. setup() {
  24959. const headRef = ref(null);
  24960. const pageMeta = usePageMeta();
  24961. const navigationBar = useTheme(pageMeta.navigationBar, () => {
  24962. const _navigationBar = parseTheme(pageMeta.navigationBar);
  24963. navigationBar.backgroundColor = _navigationBar.backgroundColor;
  24964. navigationBar.titleColor = _navigationBar.titleColor;
  24965. });
  24966. const {
  24967. clazz: clazz2,
  24968. style
  24969. } = usePageHead(navigationBar);
  24970. const buttons = __UNI_FEATURE_NAVIGATIONBAR_BUTTONS__ && usePageHeadButtons(pageMeta);
  24971. const searchInput = __UNI_FEATURE_NAVIGATIONBAR_SEARCHINPUT__ && navigationBar.searchInput && usePageHeadSearchInput(pageMeta);
  24972. __UNI_FEATURE_NAVIGATIONBAR_TRANSPARENT__ && navigationBar.type === "transparent" && usePageHeadTransparent(headRef, pageMeta);
  24973. return () => {
  24974. const backButtonTsx = __UNI_FEATURE_PAGES__ ? createBackButtonTsx(navigationBar, pageMeta.isQuit) : null;
  24975. const leftButtonsTsx = __UNI_FEATURE_NAVIGATIONBAR_BUTTONS__ ? createButtonsTsx(buttons.left) : [];
  24976. const rightButtonsTsx = __UNI_FEATURE_NAVIGATIONBAR_BUTTONS__ ? createButtonsTsx(buttons.right) : [];
  24977. const type = navigationBar.type || "default";
  24978. const placeholderTsx = type !== "transparent" && type !== "float" && createVNode("div", {
  24979. "class": {
  24980. "uni-placeholder": true,
  24981. "uni-placeholder-titlePenetrate": navigationBar.titlePenetrate
  24982. }
  24983. }, null, 2);
  24984. return createVNode("uni-page-head", {
  24985. "uni-page-head-type": type
  24986. }, [createVNode("div", {
  24987. "ref": headRef,
  24988. "class": clazz2.value,
  24989. "style": style.value
  24990. }, [createVNode("div", {
  24991. "class": "uni-page-head-hd"
  24992. }, [backButtonTsx, ...leftButtonsTsx]), createPageHeadBdTsx(navigationBar, searchInput), createVNode("div", {
  24993. "class": "uni-page-head-ft"
  24994. }, [...rightButtonsTsx])], 6), placeholderTsx], 8, ["uni-page-head-type"]);
  24995. };
  24996. }
  24997. });
  24998. function createBackButtonTsx(navigationBar, isQuit) {
  24999. if (!isQuit) {
  25000. return createVNode("div", {
  25001. "class": "uni-page-head-btn",
  25002. "onClick": onPageHeadBackButton
  25003. }, [createSvgIconVNode(ICON_PATH_BACK, navigationBar.type === "transparent" ? "#fff" : navigationBar.titleColor, 26)], 8, ["onClick"]);
  25004. }
  25005. }
  25006. function createButtonsTsx(btns) {
  25007. return btns.map(({
  25008. onClick,
  25009. btnClass,
  25010. btnStyle,
  25011. btnText,
  25012. btnIconPath,
  25013. badgeText,
  25014. iconStyle,
  25015. btnSelect
  25016. }, index2) => {
  25017. return createVNode("div", {
  25018. "key": index2,
  25019. "class": btnClass,
  25020. "style": btnStyle,
  25021. "onClick": onClick,
  25022. "badge-text": badgeText
  25023. }, [btnIconPath ? createSvgIconVNode(btnIconPath, iconStyle.color, iconStyle.fontSize) : btnSelect ? createVNode("span", {
  25024. "style": iconStyle
  25025. }, [createVNode("i", {
  25026. "class": "uni-btn-icon",
  25027. "innerHTML": btnText
  25028. }, null, 8, ["innerHTML"]), createSvgIconVNode(ICON_PATHS["select"], "#000", 14)], 4) : createVNode("i", {
  25029. "class": "uni-btn-icon",
  25030. "style": iconStyle,
  25031. "innerHTML": btnText
  25032. }, null, 12, ["innerHTML"])], 14, ["onClick", "badge-text"]);
  25033. });
  25034. }
  25035. function createPageHeadBdTsx(navigationBar, searchInput) {
  25036. if (!__UNI_FEATURE_NAVIGATIONBAR_SEARCHINPUT__ || !navigationBar.searchInput) {
  25037. return createPageHeadTitleTextTsx(navigationBar);
  25038. }
  25039. return createPageHeadSearchInputTsx(navigationBar, searchInput);
  25040. }
  25041. function createPageHeadTitleTextTsx({
  25042. type,
  25043. loading,
  25044. titleSize,
  25045. titleText,
  25046. titleImage
  25047. }) {
  25048. return createVNode("div", {
  25049. "class": "uni-page-head-bd"
  25050. }, [createVNode("div", {
  25051. "style": {
  25052. fontSize: titleSize,
  25053. opacity: type === "transparent" ? 0 : 1
  25054. },
  25055. "class": "uni-page-head__title"
  25056. }, [loading ? createVNode("i", {
  25057. "class": "uni-loading"
  25058. }, null) : titleImage ? createVNode("img", {
  25059. "src": titleImage,
  25060. "class": "uni-page-head__title_image"
  25061. }, null, 8, ["src"]) : titleText], 4)]);
  25062. }
  25063. function createPageHeadSearchInputTsx(navigationBar, {
  25064. text: text2,
  25065. focus,
  25066. composing,
  25067. onBlur,
  25068. onFocus,
  25069. onInput,
  25070. onConfirm,
  25071. onClick
  25072. }) {
  25073. const {
  25074. color,
  25075. align: align2,
  25076. autoFocus,
  25077. disabled,
  25078. borderRadius,
  25079. backgroundColor,
  25080. placeholder,
  25081. placeholderColor
  25082. } = navigationBar.searchInput;
  25083. const searchStyle = {
  25084. borderRadius,
  25085. backgroundColor
  25086. };
  25087. const placeholderClass = ["uni-page-head-search-placeholder", `uni-page-head-search-placeholder-${focus.value || text2.value ? "left" : align2}`];
  25088. return createVNode("div", {
  25089. "class": "uni-page-head-search",
  25090. "style": searchStyle
  25091. }, [createVNode("div", {
  25092. "style": {
  25093. color: placeholderColor
  25094. },
  25095. "class": placeholderClass
  25096. }, [createVNode("div", {
  25097. "class": "uni-page-head-search-icon"
  25098. }, [createSvgIconVNode(ICON_PATH_SEARCH, placeholderColor, 20)]), text2.value || composing.value ? "" : placeholder], 6), disabled ? createVNode(Input, {
  25099. "disabled": true,
  25100. "style": {
  25101. color
  25102. },
  25103. "placeholder-style": "color: " + placeholderColor,
  25104. "class": "uni-page-head-search-input",
  25105. "confirm-type": "search",
  25106. "onClick": onClick
  25107. }, null, 8, ["style", "placeholder-style", "onClick"]) : createVNode(Input, {
  25108. "focus": autoFocus,
  25109. "style": {
  25110. color
  25111. },
  25112. "placeholder-style": "color: " + placeholderColor,
  25113. "class": "uni-page-head-search-input",
  25114. "confirm-type": "search",
  25115. "onFocus": onFocus,
  25116. "onBlur": onBlur,
  25117. "onInput": onInput,
  25118. "onConfirm": onConfirm
  25119. }, null, 8, ["focus", "style", "placeholder-style", "onFocus", "onBlur", "onInput", "onConfirm"])], 4);
  25120. }
  25121. function onPageHeadBackButton() {
  25122. if (getCurrentPages().length === 1) {
  25123. uni.reLaunch({
  25124. url: "/"
  25125. });
  25126. } else {
  25127. uni.navigateBack({
  25128. from: "backbutton",
  25129. success() {
  25130. }
  25131. // 传入空方法,避免返回Promise,因为onBackPress可能导致fail
  25132. });
  25133. }
  25134. }
  25135. function usePageHead(navigationBar) {
  25136. const clazz2 = computed(() => {
  25137. const {
  25138. type,
  25139. titlePenetrate,
  25140. shadowColorType
  25141. } = navigationBar;
  25142. const clazz3 = {
  25143. "uni-page-head": true,
  25144. "uni-page-head-transparent": type === "transparent",
  25145. "uni-page-head-titlePenetrate": titlePenetrate === "YES",
  25146. "uni-page-head-shadow": !!shadowColorType
  25147. };
  25148. if (shadowColorType) {
  25149. clazz3[`uni-page-head-shadow-${shadowColorType}`] = true;
  25150. }
  25151. return clazz3;
  25152. });
  25153. const style = computed(() => {
  25154. const backgroundColor = __UNI_FEATURE_NAVIGATIONBAR_TRANSPARENT__ && navigationBar.type === "transparent" ? usePageHeadTransparentBackgroundColor(navigationBar.backgroundColor) : navigationBar.backgroundColor;
  25155. return {
  25156. backgroundColor,
  25157. color: navigationBar.titleColor,
  25158. transitionDuration: navigationBar.duration,
  25159. transitionTimingFunction: navigationBar.timingFunc
  25160. };
  25161. });
  25162. return {
  25163. clazz: clazz2,
  25164. style
  25165. };
  25166. }
  25167. function usePageHeadButtons({
  25168. id: id2,
  25169. navigationBar
  25170. }) {
  25171. const left = [];
  25172. const right = [];
  25173. const {
  25174. buttons
  25175. } = navigationBar;
  25176. if (isArray(buttons)) {
  25177. const {
  25178. type
  25179. } = navigationBar;
  25180. const isTransparent = type === "transparent";
  25181. const fonts = /* @__PURE__ */ Object.create(null);
  25182. buttons.forEach((btn, index2) => {
  25183. if (btn.fontSrc && !btn.fontFamily) {
  25184. const fontSrc = getRealPath(btn.fontSrc);
  25185. let fontFamily = fonts[fontSrc];
  25186. if (!fontFamily) {
  25187. fontFamily = `font${Date.now()}`;
  25188. fonts[fontSrc] = fontFamily;
  25189. onBeforeMount(() => updateStyle("uni-btn-" + fontFamily, `@font-face{font-family: "${fontFamily}";src: url("${fontSrc}") format("truetype")}`));
  25190. }
  25191. btn.fontFamily = fontFamily;
  25192. }
  25193. const pageHeadBtn = usePageHeadButton(id2, index2, btn, isTransparent);
  25194. if (btn.float === "left") {
  25195. left.push(pageHeadBtn);
  25196. } else {
  25197. right.push(pageHeadBtn);
  25198. }
  25199. });
  25200. }
  25201. return {
  25202. left,
  25203. right
  25204. };
  25205. }
  25206. function usePageHeadButton(pageId, index2, btn, isTransparent) {
  25207. const iconStyle = {
  25208. color: btn.color,
  25209. fontSize: btn.fontSize,
  25210. fontWeight: btn.fontWeight
  25211. };
  25212. if (btn.fontFamily) {
  25213. iconStyle.fontFamily = btn.fontFamily;
  25214. }
  25215. return new Proxy({
  25216. btnClass: {
  25217. // 类似这样的大量重复的字符串,会在gzip时压缩大小,无需在代码层考虑优化相同字符串
  25218. "uni-page-head-btn": true,
  25219. "uni-page-head-btn-red-dot": !!(btn.redDot || btn.badgeText),
  25220. "uni-page-head-btn-select": !!btn.select
  25221. },
  25222. btnStyle: {
  25223. backgroundColor: isTransparent ? btn.background : "transparent",
  25224. width: btn.width
  25225. },
  25226. btnText: "",
  25227. btnIconPath: ICON_PATHS[btn.type],
  25228. badgeText: btn.badgeText,
  25229. iconStyle,
  25230. onClick() {
  25231. invokeHook(pageId, ON_NAVIGATION_BAR_BUTTON_TAP, extend({
  25232. index: index2
  25233. }, btn));
  25234. },
  25235. btnSelect: btn.select
  25236. }, {
  25237. get(target, key, receiver) {
  25238. if (["btnText"].includes(key)) {
  25239. return btn.fontSrc && btn.fontFamily ? btn.text.replace("\\u", "&#x") : btn.text;
  25240. } else {
  25241. return Reflect.get(target, key, receiver);
  25242. }
  25243. }
  25244. });
  25245. }
  25246. function usePageHeadSearchInput({
  25247. id: id2,
  25248. navigationBar: {
  25249. searchInput
  25250. }
  25251. }) {
  25252. const focus = ref(false);
  25253. const text2 = ref("");
  25254. const composing = ref(false);
  25255. const {
  25256. disabled
  25257. } = searchInput;
  25258. if (disabled) {
  25259. const onClick = () => {
  25260. invokeHook(id2, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED);
  25261. };
  25262. return {
  25263. focus,
  25264. text: text2,
  25265. composing,
  25266. onClick
  25267. };
  25268. }
  25269. const onFocus = () => {
  25270. focus.value = true;
  25271. invokeHook(id2, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, {
  25272. focus: true
  25273. });
  25274. };
  25275. const onBlur = () => {
  25276. focus.value = false;
  25277. invokeHook(id2, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, {
  25278. focus: false
  25279. });
  25280. };
  25281. const onInput = (evt) => {
  25282. text2.value = evt.detail.value;
  25283. invokeHook(id2, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, {
  25284. text: text2.value
  25285. });
  25286. };
  25287. const onConfirm = (evt) => {
  25288. invokeHook(id2, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, {
  25289. text: text2.value
  25290. });
  25291. };
  25292. return {
  25293. focus,
  25294. text: text2,
  25295. composing,
  25296. onFocus,
  25297. onBlur,
  25298. onInput,
  25299. onConfirm
  25300. };
  25301. }
  25302. const _sfc_main = {
  25303. name: "PageRefresh",
  25304. setup() {
  25305. const { pullToRefresh } = usePageMeta();
  25306. return {
  25307. offset: pullToRefresh.offset,
  25308. color: pullToRefresh.color
  25309. };
  25310. }
  25311. };
  25312. const _export_sfc = (sfc, props2) => {
  25313. const target = sfc.__vccOpts || sfc;
  25314. for (const [key, val] of props2) {
  25315. target[key] = val;
  25316. }
  25317. return target;
  25318. };
  25319. const _hoisted_1 = { class: "uni-page-refresh-inner" };
  25320. const _hoisted_2 = ["fill"];
  25321. const _hoisted_3 = /* @__PURE__ */ createElementVNode("path", { d: "M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z" }, null, -1);
  25322. const _hoisted_4 = /* @__PURE__ */ createElementVNode("path", {
  25323. d: "M0 0h24v24H0z",
  25324. fill: "none"
  25325. }, null, -1);
  25326. const _hoisted_5 = [
  25327. _hoisted_3,
  25328. _hoisted_4
  25329. ];
  25330. const _hoisted_6 = {
  25331. class: "uni-page-refresh__spinner",
  25332. width: "24",
  25333. height: "24",
  25334. viewBox: "25 25 50 50"
  25335. };
  25336. const _hoisted_7 = ["stroke"];
  25337. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  25338. return openBlock(), createElementBlock("uni-page-refresh", null, [
  25339. createElementVNode("div", {
  25340. style: normalizeStyle({ "margin-top": $setup.offset + "px" }),
  25341. class: "uni-page-refresh"
  25342. }, [
  25343. createElementVNode("div", _hoisted_1, [
  25344. (openBlock(), createElementBlock("svg", {
  25345. fill: $setup.color,
  25346. class: "uni-page-refresh__icon",
  25347. width: "24",
  25348. height: "24",
  25349. viewBox: "0 0 24 24"
  25350. }, _hoisted_5, 8, _hoisted_2)),
  25351. (openBlock(), createElementBlock("svg", _hoisted_6, [
  25352. createElementVNode("circle", {
  25353. stroke: $setup.color,
  25354. class: "uni-page-refresh__path",
  25355. cx: "50",
  25356. cy: "50",
  25357. r: "20",
  25358. fill: "none",
  25359. "stroke-width": "4",
  25360. "stroke-miterlimit": "10"
  25361. }, null, 8, _hoisted_7)
  25362. ]))
  25363. ])
  25364. ], 4)
  25365. ]);
  25366. }
  25367. const PageRefresh = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
  25368. function processDeltaY(ev, identifier, startY) {
  25369. const touch = Array.prototype.slice.call(ev.changedTouches).filter((touch2) => touch2.identifier === identifier)[0];
  25370. if (!touch) {
  25371. return false;
  25372. }
  25373. ev.deltaY = touch.pageY - startY;
  25374. return true;
  25375. }
  25376. const PULLING = "pulling";
  25377. const REACHED = "reached";
  25378. const ABORTING = "aborting";
  25379. const REFRESHING = "refreshing";
  25380. const RESTORING = "restoring";
  25381. function usePageRefresh(refreshRef) {
  25382. const { id: id2, pullToRefresh } = usePageMeta();
  25383. const { range, height } = pullToRefresh;
  25384. let refreshContainerElem;
  25385. let refreshControllerElem;
  25386. let refreshControllerElemStyle;
  25387. let refreshInnerElemStyle;
  25388. useSubscribe(
  25389. () => {
  25390. if (!state2) {
  25391. state2 = REFRESHING;
  25392. addClass();
  25393. setTimeout(() => {
  25394. refreshing();
  25395. }, 50);
  25396. }
  25397. },
  25398. API_START_PULL_DOWN_REFRESH,
  25399. false,
  25400. id2
  25401. );
  25402. useSubscribe(
  25403. () => {
  25404. if (state2 === REFRESHING) {
  25405. removeClass();
  25406. state2 = RESTORING;
  25407. addClass();
  25408. restoring(() => {
  25409. removeClass();
  25410. state2 = distance2 = offset = null;
  25411. });
  25412. }
  25413. },
  25414. API_STOP_PULL_DOWN_REFRESH,
  25415. false,
  25416. id2
  25417. );
  25418. onMounted(() => {
  25419. refreshContainerElem = refreshRef.value.$el;
  25420. refreshControllerElem = refreshContainerElem.querySelector(".uni-page-refresh");
  25421. refreshControllerElemStyle = refreshControllerElem.style;
  25422. refreshInnerElemStyle = refreshControllerElem.querySelector(
  25423. ".uni-page-refresh-inner"
  25424. ).style;
  25425. });
  25426. let touchId;
  25427. let startY;
  25428. let canRefresh;
  25429. let state2;
  25430. let distance2 = null;
  25431. let offset = null;
  25432. function toggleClass(type) {
  25433. if (!state2) {
  25434. return;
  25435. }
  25436. if (refreshContainerElem) {
  25437. refreshContainerElem.classList[type]("uni-page-refresh--" + state2);
  25438. }
  25439. }
  25440. function addClass() {
  25441. toggleClass("add");
  25442. }
  25443. function removeClass() {
  25444. toggleClass("remove");
  25445. }
  25446. function pulling(deltaY) {
  25447. if (!refreshControllerElem) {
  25448. return;
  25449. }
  25450. let rotate = deltaY / range;
  25451. if (rotate > 1) {
  25452. rotate = 1;
  25453. } else {
  25454. rotate = rotate * rotate * rotate;
  25455. }
  25456. const y = Math.round(deltaY / (range / height)) || 0;
  25457. refreshInnerElemStyle.transform = "rotate(" + 360 * rotate + "deg)";
  25458. refreshControllerElemStyle.clip = "rect(" + (45 - y) + "px,45px,45px,-5px)";
  25459. refreshControllerElemStyle.transform = "translate3d(-50%, " + y + "px, 0)";
  25460. }
  25461. const onTouchstartPassive = withWebEvent((ev) => {
  25462. const touch = ev.changedTouches[0];
  25463. touchId = touch.identifier;
  25464. startY = touch.pageY;
  25465. if ([ABORTING, REFRESHING, RESTORING].indexOf(state2) >= 0) {
  25466. canRefresh = false;
  25467. } else {
  25468. canRefresh = true;
  25469. }
  25470. });
  25471. const onTouchmove = withWebEvent((ev) => {
  25472. if (!canRefresh) {
  25473. return;
  25474. }
  25475. if (!processDeltaY(ev, touchId, startY)) {
  25476. return;
  25477. }
  25478. let { deltaY } = ev;
  25479. if ((document.documentElement.scrollTop || document.body.scrollTop) !== 0) {
  25480. touchId = null;
  25481. return;
  25482. }
  25483. if (deltaY < 0 && !state2) {
  25484. return;
  25485. }
  25486. ev.preventDefault();
  25487. if (distance2 === null) {
  25488. offset = deltaY;
  25489. state2 = PULLING;
  25490. addClass();
  25491. }
  25492. deltaY = deltaY - offset;
  25493. if (deltaY < 0) {
  25494. deltaY = 0;
  25495. }
  25496. distance2 = deltaY;
  25497. const isReached = deltaY >= range && state2 !== REACHED;
  25498. const isPulling = deltaY < range && state2 !== PULLING;
  25499. if (isReached || isPulling) {
  25500. removeClass();
  25501. state2 = state2 === REACHED ? PULLING : REACHED;
  25502. addClass();
  25503. }
  25504. pulling(deltaY);
  25505. });
  25506. const onTouchend = withWebEvent((ev) => {
  25507. if (!processDeltaY(ev, touchId, startY)) {
  25508. return;
  25509. }
  25510. if (state2 === null) {
  25511. return;
  25512. }
  25513. if (state2 === PULLING) {
  25514. removeClass();
  25515. state2 = ABORTING;
  25516. addClass();
  25517. aborting(() => {
  25518. removeClass();
  25519. state2 = distance2 = offset = null;
  25520. });
  25521. } else if (state2 === REACHED) {
  25522. removeClass();
  25523. state2 = REFRESHING;
  25524. addClass();
  25525. refreshing();
  25526. }
  25527. });
  25528. function aborting(callback) {
  25529. if (!refreshControllerElem) {
  25530. return;
  25531. }
  25532. if (refreshControllerElemStyle.transform) {
  25533. refreshControllerElemStyle.transition = "-webkit-transform 0.3s";
  25534. refreshControllerElemStyle.transform = "translate3d(-50%, 0, 0)";
  25535. const abortTransitionEnd = function() {
  25536. timeout && clearTimeout(timeout);
  25537. refreshControllerElem.removeEventListener(
  25538. "webkitTransitionEnd",
  25539. abortTransitionEnd
  25540. );
  25541. refreshControllerElemStyle.transition = "";
  25542. callback();
  25543. };
  25544. refreshControllerElem.addEventListener(
  25545. "webkitTransitionEnd",
  25546. abortTransitionEnd
  25547. );
  25548. const timeout = setTimeout(abortTransitionEnd, 350);
  25549. } else {
  25550. callback();
  25551. }
  25552. }
  25553. function refreshing() {
  25554. if (!refreshControllerElem) {
  25555. return;
  25556. }
  25557. refreshControllerElemStyle.transition = "-webkit-transform 0.2s";
  25558. refreshControllerElemStyle.transform = "translate3d(-50%, " + height + "px, 0)";
  25559. invokeHook(id2, ON_PULL_DOWN_REFRESH);
  25560. }
  25561. function restoring(callback) {
  25562. if (!refreshControllerElem) {
  25563. return;
  25564. }
  25565. refreshControllerElemStyle.transition = "-webkit-transform 0.3s";
  25566. refreshControllerElemStyle.transform += " scale(0.01)";
  25567. const restoreTransitionEnd = function() {
  25568. timeout && clearTimeout(timeout);
  25569. refreshControllerElem.removeEventListener(
  25570. "webkitTransitionEnd",
  25571. restoreTransitionEnd
  25572. );
  25573. refreshControllerElemStyle.transition = "";
  25574. refreshControllerElemStyle.transform = "translate3d(-50%, 0, 0)";
  25575. callback();
  25576. };
  25577. refreshControllerElem.addEventListener(
  25578. "webkitTransitionEnd",
  25579. restoreTransitionEnd
  25580. );
  25581. const timeout = setTimeout(restoreTransitionEnd, 350);
  25582. }
  25583. return {
  25584. onTouchstartPassive,
  25585. onTouchmove,
  25586. onTouchend,
  25587. onTouchcancel: onTouchend
  25588. };
  25589. }
  25590. const PageBody = defineSystemComponent({
  25591. name: "PageBody",
  25592. setup(props2, ctx) {
  25593. const pageMeta = __UNI_FEATURE_PULL_DOWN_REFRESH__ && usePageMeta();
  25594. const refreshRef = __UNI_FEATURE_PULL_DOWN_REFRESH__ && ref(null);
  25595. const pageRefresh = __UNI_FEATURE_PULL_DOWN_REFRESH__ && pageMeta.enablePullDownRefresh ? usePageRefresh(refreshRef) : null;
  25596. return () => {
  25597. const pageRefreshTsx = __UNI_FEATURE_PULL_DOWN_REFRESH__ && createPageRefreshTsx(refreshRef, pageMeta);
  25598. return createVNode(Fragment, null, [pageRefreshTsx, createVNode("uni-page-wrapper", pageRefresh, [createVNode("uni-page-body", null, [renderSlot(ctx.slots, "default")])], 16)]);
  25599. };
  25600. }
  25601. });
  25602. function createPageRefreshTsx(refreshRef, pageMeta) {
  25603. if (!__UNI_FEATURE_PULL_DOWN_REFRESH__ || !pageMeta.enablePullDownRefresh) {
  25604. return null;
  25605. }
  25606. return createVNode(PageRefresh, {
  25607. "ref": refreshRef
  25608. }, null, 512);
  25609. }
  25610. const index = defineSystemComponent({
  25611. name: "Page",
  25612. setup(_props, ctx) {
  25613. const pageMeta = providePageMeta(getStateId());
  25614. const navigationBar = pageMeta.navigationBar;
  25615. useDocumentTitle(pageMeta);
  25616. return () => createVNode(
  25617. "uni-page",
  25618. { "data-page": pageMeta.route },
  25619. __UNI_FEATURE_NAVIGATIONBAR__ && navigationBar.style !== "custom" ? [createVNode(PageHead), createPageBodyVNode(ctx)] : [createPageBodyVNode(ctx)]
  25620. );
  25621. }
  25622. });
  25623. function createPageBodyVNode(ctx) {
  25624. return openBlock(), createBlock(
  25625. PageBody,
  25626. { key: 0 },
  25627. {
  25628. default: withCtx(() => [renderSlot(ctx.slots, "page")]),
  25629. _: 3
  25630. }
  25631. );
  25632. }
  25633. export {
  25634. $emit,
  25635. $off,
  25636. $on,
  25637. $once,
  25638. index$6 as Ad,
  25639. index$5 as AdContentPage,
  25640. index$4 as AdDraw,
  25641. AsyncErrorComponent,
  25642. AsyncLoadingComponent,
  25643. index$x as Button,
  25644. index$3 as Camera,
  25645. index$v as Canvas,
  25646. index$t as Checkbox,
  25647. index$u as CheckboxGroup,
  25648. index$8 as CoverImage,
  25649. index$9 as CoverView,
  25650. index$s as Editor,
  25651. index$z as Form,
  25652. index$r as Icon,
  25653. index$q as Image,
  25654. Input,
  25655. index$y as Label,
  25656. LayoutComponent,
  25657. index$2 as LivePlayer,
  25658. index$1 as LivePusher,
  25659. Map$1 as Map,
  25660. MovableArea,
  25661. MovableView,
  25662. index$p as Navigator,
  25663. index as PageComponent,
  25664. index$7 as Picker,
  25665. PickerView,
  25666. PickerViewColumn,
  25667. index$o as Progress,
  25668. index$m as Radio,
  25669. index$n as RadioGroup,
  25670. ResizeSensor,
  25671. index$l as RichText,
  25672. ScrollView,
  25673. index$k as Slider,
  25674. Swiper,
  25675. SwiperItem,
  25676. index$j as Switch,
  25677. index$i as Text,
  25678. index$h as Textarea,
  25679. UniServiceJSBridge$1 as UniServiceJSBridge,
  25680. UniViewJSBridge$1 as UniViewJSBridge,
  25681. index$d as Video,
  25682. index$g as View,
  25683. index$c as WebView,
  25684. addInterceptor,
  25685. addPhoneContact,
  25686. arrayBufferToBase64,
  25687. base64ToArrayBuffer,
  25688. canIUse,
  25689. canvasGetImageData,
  25690. canvasPutImageData,
  25691. canvasToTempFilePath,
  25692. chooseFile,
  25693. chooseImage,
  25694. chooseLocation,
  25695. chooseVideo,
  25696. clearStorage,
  25697. clearStorageSync,
  25698. closePreviewImage,
  25699. closeSocket,
  25700. connectSocket,
  25701. createAnimation$1 as createAnimation,
  25702. createCameraContext,
  25703. createCanvasContext,
  25704. createInnerAudioContext,
  25705. createIntersectionObserver,
  25706. createLivePlayerContext,
  25707. createMapContext,
  25708. createMediaQueryObserver,
  25709. createSelectorQuery,
  25710. createVideoContext,
  25711. cssBackdropFilter,
  25712. cssConstant,
  25713. cssEnv,
  25714. cssVar,
  25715. downloadFile,
  25716. getApp$1 as getApp,
  25717. getAppBaseInfo,
  25718. getClipboardData,
  25719. getCurrentPages$1 as getCurrentPages,
  25720. getDeviceInfo,
  25721. getElementById,
  25722. getEnterOptionsSync,
  25723. getFileInfo,
  25724. getImageInfo,
  25725. getLaunchOptionsSync,
  25726. getLeftWindowStyle,
  25727. getLocale,
  25728. getLocation,
  25729. getNetworkType,
  25730. getProvider,
  25731. getPushClientId,
  25732. getRealPath,
  25733. getRecorderManager,
  25734. getRightWindowStyle,
  25735. getSavedFileInfo,
  25736. getSavedFileList,
  25737. getScreenBrightness,
  25738. getSelectedTextRange$1 as getSelectedTextRange,
  25739. getStorage,
  25740. getStorageInfo,
  25741. getStorageInfoSync,
  25742. getStorageSync,
  25743. getSystemInfo,
  25744. getSystemInfoSync,
  25745. getTopWindowStyle,
  25746. getVideoInfo,
  25747. getWindowInfo,
  25748. hideActionSheet,
  25749. hideKeyboard,
  25750. hideLeftWindow,
  25751. hideLoading,
  25752. hideModal,
  25753. hideNavigationBarLoading,
  25754. hideRightWindow,
  25755. hideTabBar,
  25756. hideTabBarRedDot,
  25757. hideToast,
  25758. hideTopWindow,
  25759. interceptors,
  25760. invokePushCallback,
  25761. loadFontFace,
  25762. login,
  25763. makePhoneCall,
  25764. navigateBack,
  25765. navigateTo,
  25766. offAccelerometerChange,
  25767. offAppHide,
  25768. offAppShow,
  25769. offCompassChange,
  25770. offError,
  25771. offLocationChange,
  25772. offLocationChangeError,
  25773. offNetworkStatusChange,
  25774. offPageNotFound,
  25775. offPushMessage,
  25776. offThemeChange$1 as offThemeChange,
  25777. offUnhandledRejection,
  25778. offWindowResize,
  25779. onAccelerometerChange,
  25780. onAppHide,
  25781. onAppShow,
  25782. onCompassChange,
  25783. onCreateVueApp2 as onCreateVueApp,
  25784. onError,
  25785. onGyroscopeChange,
  25786. onLocaleChange,
  25787. onLocationChange,
  25788. onLocationChangeError,
  25789. onMemoryWarning,
  25790. onNetworkStatusChange,
  25791. onPageNotFound,
  25792. onPushMessage,
  25793. onSocketClose,
  25794. onSocketError,
  25795. onSocketMessage,
  25796. onSocketOpen,
  25797. onTabBarMidButtonTap,
  25798. onThemeChange$1 as onThemeChange,
  25799. onUnhandledRejection,
  25800. onUserCaptureScreen,
  25801. onWindowResize,
  25802. openDocument,
  25803. openLocation,
  25804. pageScrollTo,
  25805. index$e as plugin,
  25806. preloadPage,
  25807. previewImage,
  25808. reLaunch,
  25809. redirectTo,
  25810. removeInterceptor,
  25811. removeSavedFile,
  25812. removeStorage,
  25813. removeStorageSync,
  25814. removeTabBarBadge,
  25815. request,
  25816. saveFile,
  25817. saveImageToPhotosAlbum,
  25818. saveVideoToPhotosAlbum,
  25819. scanCode,
  25820. sendSocketMessage,
  25821. setClipboardData,
  25822. setKeepScreenOn,
  25823. setLeftWindowStyle,
  25824. setLocale,
  25825. setNavigationBarColor,
  25826. setNavigationBarTitle,
  25827. setPageMeta,
  25828. setRightWindowStyle,
  25829. setScreenBrightness,
  25830. setStorage,
  25831. setStorageSync,
  25832. setTabBarBadge,
  25833. setTabBarItem,
  25834. setTabBarStyle,
  25835. setTopWindowStyle,
  25836. setupApp,
  25837. setupPage,
  25838. setupWindow,
  25839. showActionSheet,
  25840. showLeftWindow,
  25841. showLoading,
  25842. showModal,
  25843. showNavigationBarLoading,
  25844. showRightWindow,
  25845. showTabBar,
  25846. showTabBarRedDot,
  25847. showToast,
  25848. showTopWindow,
  25849. startAccelerometer,
  25850. startCompass,
  25851. startGyroscope,
  25852. startLocationUpdate,
  25853. startPullDownRefresh,
  25854. stopAccelerometer,
  25855. stopCompass,
  25856. stopGyroscope,
  25857. stopLocationUpdate,
  25858. stopPullDownRefresh,
  25859. switchTab,
  25860. uni$1 as uni,
  25861. uploadFile,
  25862. upx2px,
  25863. useI18n,
  25864. useTabBar,
  25865. vibrateLong,
  25866. vibrateShort
  25867. };