uni-h5.es.js 778 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976
  1. var __defProp = Object.defineProperty;
  2. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  3. var __publicField = (obj, key, value) => {
  4. __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  5. return value;
  6. };
  7. import { withModifiers, createVNode, getCurrentInstance, ref, defineComponent, openBlock, createElementBlock, onMounted, provide, computed, watch, onUnmounted, inject, onBeforeUnmount, mergeProps, injectHook, reactive, onActivated, nextTick, onBeforeMount, withDirectives, vShow, shallowRef, watchEffect, isVNode, Fragment, markRaw, Comment, h, createTextVNode, isReactive, Transition, createApp, createBlock, onBeforeActivate, onBeforeDeactivate, renderList, effectScope, withCtx, KeepAlive, resolveDynamicComponent, createElementVNode, normalizeStyle, renderSlot } from "vue";
  8. import { isArray, isString, extend, remove, stringifyStyle, parseStringStyle, isPlainObject as isPlainObject$1, isFunction, capitalize, camelize, hasOwn, isObject, toRawType, makeMap as makeMap$1, isPromise, hyphenate, invokeArrayFns as invokeArrayFns$1 } from "@vue/shared";
  9. import { once, UNI_STORAGE_LOCALE, I18N_JSON_DELIMITERS, Emitter, passive, initCustomDatasetOnce, resolveComponentInstance, normalizeStyles, addLeadingSlash, invokeArrayFns, removeLeadingSlash, resolveOwnerVm, resolveOwnerEl, ON_WXS_INVOKE_CALL_METHOD, 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, ON_ERROR, callOptions, ON_UNHANDLE_REJECTION, ON_PAGE_NOT_FOUND, getLen, LINEFEED, PRIMARY_COLOR, debounce, isUniLifecycleHook, decodedQuery, ON_LOAD, UniLifecycleHooks, invokeCreateErrorHandler, invokeCreateVueAppHook, parseQuery, NAVBAR_HEIGHT, parseUrl, ON_UNLOAD, normalizeTitleColor, ON_REACH_BOTTOM_DISTANCE, ON_THEME_CHANGE, WEB_INVOKE_APPSERVICE, ON_WEB_INVOKE_APP_SERVICE, sortObject, OFF_THEME_CHANGE, updateElementStyle, ON_BACK_PRESS, 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";
  10. import { onCreateVueApp as onCreateVueApp2 } from "@dcloudio/uni-shared";
  11. import { useRoute, isNavigationFailure, createRouter, createWebHistory, createWebHashHistory, useRouter, RouterView } from "vue-router";
  12. import { initVueI18n, isI18nStr, LOCALE_EN, LOCALE_ES, LOCALE_FR, LOCALE_ZH_HANS, LOCALE_ZH_HANT } from "@dcloudio/uni-i18n";
  13. function arrayPop(array) {
  14. if (array.length === 0) {
  15. return null;
  16. }
  17. return array.pop();
  18. }
  19. function arrayShift(array) {
  20. if (array.length === 0) {
  21. return null;
  22. }
  23. return array.shift();
  24. }
  25. function arrayFind(array, predicate) {
  26. const index2 = array.findIndex(predicate);
  27. if (index2 < 0) {
  28. return null;
  29. }
  30. return array[index2];
  31. }
  32. function arrayFindLast(array, predicate) {
  33. const index2 = array.findLastIndex(predicate);
  34. if (index2 < 0) {
  35. return null;
  36. }
  37. return array[index2];
  38. }
  39. function arrayAt(array, index2) {
  40. if (index2 < -array.length || index2 >= array.length) {
  41. return null;
  42. }
  43. return array.at(index2);
  44. }
  45. var IDENTIFIER;
  46. (function(IDENTIFIER2) {
  47. IDENTIFIER2["UTSJSONObject"] = "UTSJSONObject";
  48. IDENTIFIER2["JSON"] = "JSON";
  49. IDENTIFIER2["UTS"] = "UTS";
  50. IDENTIFIER2["DEFINE_COMPONENT"] = "defineComponent";
  51. IDENTIFIER2["VUE"] = "vue";
  52. IDENTIFIER2["GLOBAL_THIS"] = "globalThis";
  53. IDENTIFIER2["UTS_TYPE"] = "UTSType";
  54. IDENTIFIER2["UTS_METADATA"] = "$UTSMetadata$";
  55. IDENTIFIER2["TEMP_UTS_METADATA"] = "$TempUTSMetadata$";
  56. IDENTIFIER2["JSON_FIELD"] = "JSON_FIELD";
  57. })(IDENTIFIER || (IDENTIFIER = {}));
  58. var UTS_CLASS_METADATA_KIND;
  59. (function(UTS_CLASS_METADATA_KIND2) {
  60. UTS_CLASS_METADATA_KIND2[UTS_CLASS_METADATA_KIND2["CLASS"] = 0] = "CLASS";
  61. UTS_CLASS_METADATA_KIND2[UTS_CLASS_METADATA_KIND2["INTERFACE"] = 1] = "INTERFACE";
  62. UTS_CLASS_METADATA_KIND2[UTS_CLASS_METADATA_KIND2["TYPE"] = 2] = "TYPE";
  63. })(UTS_CLASS_METADATA_KIND || (UTS_CLASS_METADATA_KIND = {}));
  64. function getType$1(val) {
  65. return Object.prototype.toString.call(val).slice(8, -1).toLowerCase();
  66. }
  67. function isPlainObject(val) {
  68. if (val == null || typeof val !== "object") {
  69. return false;
  70. }
  71. const proto = Object.getPrototypeOf(val);
  72. return proto === Object.prototype || proto === null;
  73. }
  74. class UTSError extends Error {
  75. constructor(message) {
  76. super(message);
  77. }
  78. }
  79. function isUTSMetadata(metadata) {
  80. return !!(metadata && metadata.kind in UTS_CLASS_METADATA_KIND && metadata.interfaces);
  81. }
  82. function isNativeType(proto) {
  83. return !proto || proto === Object.prototype;
  84. }
  85. const utsMetadataKey = IDENTIFIER.UTS_METADATA;
  86. function getParentTypeList(type) {
  87. const metadata = utsMetadataKey in type ? type[utsMetadataKey] : {};
  88. let interfaces = [];
  89. if (!isUTSMetadata(metadata)) {
  90. interfaces = [];
  91. } else {
  92. interfaces = metadata.interfaces || [];
  93. }
  94. const proto = Object.getPrototypeOf(type);
  95. if (!isNativeType(proto)) {
  96. interfaces.push(proto.constructor);
  97. }
  98. return interfaces;
  99. }
  100. function isImplementationOf(leftType, rightType, visited = []) {
  101. if (isNativeType(leftType)) {
  102. return false;
  103. }
  104. if (leftType === rightType) {
  105. return true;
  106. }
  107. visited.push(leftType);
  108. const parentTypeList = getParentTypeList(leftType);
  109. return parentTypeList.some((parentType) => {
  110. if (visited.includes(parentType)) {
  111. return false;
  112. }
  113. return isImplementationOf(parentType, rightType, visited);
  114. });
  115. }
  116. function isInstanceOf(value, type) {
  117. const isNativeInstanceofType = value instanceof type;
  118. if (isNativeInstanceofType || typeof value !== "object") {
  119. return isNativeInstanceofType;
  120. }
  121. const proto = Object.getPrototypeOf(value).constructor;
  122. return isImplementationOf(proto, type);
  123. }
  124. function isBaseType(type) {
  125. return type === Number || type === String || type === Boolean;
  126. }
  127. function isUnknownType(type) {
  128. return type === "Unknown";
  129. }
  130. function isAnyType(type) {
  131. return type === "Any";
  132. }
  133. function isUTSType(type) {
  134. return type && type.prototype && type.prototype instanceof UTSType;
  135. }
  136. function normalizeGenericValue(value, genericType, isJSONParse = false) {
  137. return value == null ? null : isBaseType(genericType) || isUnknownType(genericType) || isAnyType(genericType) ? value : genericType === Array ? new Array(...value) : new genericType(value, void 0, isJSONParse);
  138. }
  139. class UTSType {
  140. static get$UTSMetadata$(...args) {
  141. return {
  142. kind: UTS_CLASS_METADATA_KIND.TYPE,
  143. interfaces: [],
  144. fields: {}
  145. };
  146. }
  147. get $UTSMetadata$() {
  148. return UTSType.get$UTSMetadata$();
  149. }
  150. // TODO 缓存withGenerics结果
  151. static withGenerics(parent, generics, isJSONParse = false) {
  152. if (isJSONParse) {
  153. const illegalGeneric = generics.find((item) => !(item === Array || isBaseType(item) || isUnknownType(item) || isAnyType(item) || item === UTSJSONObject || item.prototype && item.prototype instanceof UTSType));
  154. if (illegalGeneric) {
  155. throw new Error("Generic is not UTSType or Array or UTSJSONObject or base type, generic: " + illegalGeneric);
  156. }
  157. }
  158. if (parent === Array) {
  159. return class UTSArray extends UTSType {
  160. constructor(options, isJSONParse2 = false) {
  161. if (!Array.isArray(options)) {
  162. throw new UTSError(`Failed to contruct type, ${options} is not an array`);
  163. }
  164. super();
  165. return options.map((item) => {
  166. return normalizeGenericValue(item, generics[0], isJSONParse2);
  167. });
  168. }
  169. };
  170. } else if (parent === Map || parent === WeakMap) {
  171. return class UTSMap extends UTSType {
  172. constructor(options, isJSONParse2 = false) {
  173. if (options == null || typeof options !== "object") {
  174. throw new UTSError(`Failed to contruct type, ${options} is not an object`);
  175. }
  176. super();
  177. const obj = new parent();
  178. for (const key in options) {
  179. obj.set(normalizeGenericValue(key, generics[0], isJSONParse2), normalizeGenericValue(options[key], generics[1], isJSONParse2));
  180. }
  181. return obj;
  182. }
  183. };
  184. } else if (isUTSType(parent)) {
  185. return class VirtualClassWithGenerics extends parent {
  186. static get$UTSMetadata$() {
  187. return parent.get$UTSMetadata$(...generics);
  188. }
  189. constructor(options, metadata = VirtualClassWithGenerics.get$UTSMetadata$(), isJSONParse2 = false) {
  190. super(options, metadata, isJSONParse2);
  191. }
  192. };
  193. } else {
  194. return parent;
  195. }
  196. }
  197. constructor() {
  198. }
  199. static initProps(options, metadata, isJSONParse = false) {
  200. const obj = {};
  201. if (!metadata.fields) {
  202. return obj;
  203. }
  204. for (const key in metadata.fields) {
  205. const { type, optional, jsonField } = metadata.fields[key];
  206. const realKey = isJSONParse ? jsonField || key : key;
  207. if (options[realKey] == null) {
  208. if (optional) {
  209. obj[key] = null;
  210. continue;
  211. } else {
  212. throw new UTSError(`Failed to contruct type, missing required property: ${key}`);
  213. }
  214. }
  215. if (isUTSType(type)) {
  216. obj[key] = new type(options[realKey], void 0, isJSONParse);
  217. } else if (type === Array) {
  218. if (!Array.isArray(options[realKey])) {
  219. throw new UTSError(`Failed to contruct type, property ${key} is not an array`);
  220. }
  221. obj[key] = options[realKey].map((item) => {
  222. return item == null ? null : item;
  223. });
  224. } else {
  225. obj[key] = options[realKey];
  226. }
  227. }
  228. return obj;
  229. }
  230. }
  231. const OriginalJSON = JSON;
  232. function parseObjectOrArray(object, utsType) {
  233. const objectType = getType$1(object);
  234. if (object === null || objectType !== "object" && objectType !== "array") {
  235. return object;
  236. }
  237. if (utsType || utsType === UTSJSONObject) {
  238. try {
  239. return new utsType(object, void 0, true);
  240. } catch (error) {
  241. console.error(error);
  242. return null;
  243. }
  244. }
  245. if (objectType === "array") {
  246. return object.map((value) => {
  247. return parseObjectOrArray(value);
  248. });
  249. } else if (objectType === "object") {
  250. return new UTSJSONObject(object);
  251. }
  252. return object;
  253. }
  254. const UTSJSON = {
  255. parse: (text2, reviver, utsType) => {
  256. if (reviver && (isUTSType(reviver) || reviver === UTSJSONObject)) {
  257. utsType = reviver;
  258. reviver = void 0;
  259. }
  260. try {
  261. const parseResult = OriginalJSON.parse(text2, reviver);
  262. return parseObjectOrArray(parseResult, utsType);
  263. } catch (error) {
  264. console.error(error);
  265. return null;
  266. }
  267. },
  268. parseArray(text2, utsType) {
  269. try {
  270. const parseResult = OriginalJSON.parse(text2);
  271. if (Array.isArray(parseResult)) {
  272. return parseObjectOrArray(parseResult, utsType ? UTSType.withGenerics(Array, [utsType], true) : void 0);
  273. }
  274. return null;
  275. } catch (error) {
  276. console.error(error);
  277. return null;
  278. }
  279. },
  280. parseObject(text2, utsType) {
  281. try {
  282. const parseResult = OriginalJSON.parse(text2);
  283. if (Array.isArray(parseResult)) {
  284. return null;
  285. }
  286. return parseObjectOrArray(parseResult, utsType);
  287. } catch (error) {
  288. console.error(error);
  289. return null;
  290. }
  291. },
  292. stringify: (value) => {
  293. return OriginalJSON.stringify(value);
  294. }
  295. };
  296. function mapGet(map, key) {
  297. if (!map.has(key)) {
  298. return null;
  299. }
  300. return map.get(key);
  301. }
  302. function stringCodePointAt(str, pos) {
  303. if (pos < 0 || pos >= str.length) {
  304. return null;
  305. }
  306. return str.codePointAt(pos);
  307. }
  308. function stringAt(str, pos) {
  309. if (pos < -str.length || pos >= str.length) {
  310. return null;
  311. }
  312. return str.at(pos);
  313. }
  314. function weakMapGet(map, key) {
  315. if (!map.has(key)) {
  316. return null;
  317. }
  318. return map.get(key);
  319. }
  320. const UTS$1 = {
  321. arrayAt,
  322. arrayFind,
  323. arrayFindLast,
  324. arrayPop,
  325. arrayShift,
  326. isInstanceOf,
  327. UTSType,
  328. mapGet,
  329. stringAt,
  330. stringCodePointAt,
  331. weakMapGet,
  332. JSON: UTSJSON
  333. };
  334. let UniError$1 = class UniError2 extends Error {
  335. constructor(errSubject, errCode, errMsg) {
  336. let options = {};
  337. const argsLength = Array.from(arguments).length;
  338. switch (argsLength) {
  339. case 0:
  340. errSubject = "";
  341. errMsg = "";
  342. errCode = 0;
  343. break;
  344. case 1:
  345. errMsg = errSubject;
  346. errSubject = "";
  347. errCode = 0;
  348. break;
  349. case 2:
  350. errMsg = errSubject;
  351. options = errCode;
  352. errCode = options.errCode || 0;
  353. errSubject = options.errSubject || "";
  354. break;
  355. }
  356. super(errMsg);
  357. this.name = "UniError";
  358. this.errSubject = errSubject;
  359. this.errCode = errCode;
  360. this.errMsg = errMsg;
  361. if (options.data) {
  362. this.data = options.data;
  363. }
  364. if (options.cause) {
  365. this.cause = options.cause;
  366. }
  367. }
  368. set errMsg(msg) {
  369. this.message = msg;
  370. }
  371. get errMsg() {
  372. return this.message;
  373. }
  374. toString() {
  375. return this.errMsg;
  376. }
  377. toJSON() {
  378. return {
  379. errSubject: this.errSubject,
  380. errCode: this.errCode,
  381. errMsg: this.errMsg,
  382. data: this.data,
  383. cause: this.cause && typeof this.cause.toJSON === "function" ? this.cause.toJSON() : this.cause
  384. };
  385. }
  386. };
  387. function initUTSJSONObjectProperties(obj) {
  388. const propertyList = [
  389. "_resolveKeyPath",
  390. "_getValue",
  391. "toJSON",
  392. "get",
  393. "set",
  394. "getAny",
  395. "getString",
  396. "getNumber",
  397. "getBoolean",
  398. "getJSON",
  399. "getArray",
  400. "toMap",
  401. "forEach"
  402. ];
  403. const propertyDescriptorMap = {};
  404. for (let i = 0; i < propertyList.length; i++) {
  405. const property = propertyList[i];
  406. propertyDescriptorMap[property] = {
  407. enumerable: false,
  408. value: obj[property]
  409. };
  410. }
  411. Object.defineProperties(obj, propertyDescriptorMap);
  412. }
  413. function setUTSJSONObjectValue(obj, key, value) {
  414. if (isPlainObject(value)) {
  415. obj[key] = new UTSJSONObject$1(value);
  416. } else if (getType$1(value) === "array") {
  417. obj[key] = value.map((item) => {
  418. if (isPlainObject(item)) {
  419. return new UTSJSONObject$1(item);
  420. } else {
  421. return item;
  422. }
  423. });
  424. } else {
  425. obj[key] = value;
  426. }
  427. }
  428. let UTSJSONObject$1 = class UTSJSONObject2 {
  429. static keys(obj) {
  430. return Object.keys(obj);
  431. }
  432. static assign(target, ...sources) {
  433. for (let i = 0; i < sources.length; i++) {
  434. const source = sources[i];
  435. for (let key in source) {
  436. target[key] = source[key];
  437. }
  438. }
  439. return target;
  440. }
  441. constructor(content = {}) {
  442. if (content instanceof Map) {
  443. content.forEach((value, key) => {
  444. setUTSJSONObjectValue(this, key, value);
  445. });
  446. } else {
  447. for (const key in content) {
  448. if (Object.prototype.hasOwnProperty.call(content, key)) {
  449. const value = content[key];
  450. setUTSJSONObjectValue(this, key, value);
  451. }
  452. }
  453. }
  454. initUTSJSONObjectProperties(this);
  455. }
  456. _resolveKeyPath(keyPath) {
  457. let token = "";
  458. const keyPathArr = [];
  459. let inOpenParentheses = false;
  460. for (let i = 0; i < keyPath.length; i++) {
  461. const word = keyPath[i];
  462. switch (word) {
  463. case ".":
  464. if (token.length > 0) {
  465. keyPathArr.push(token);
  466. token = "";
  467. }
  468. break;
  469. case "[": {
  470. inOpenParentheses = true;
  471. if (token.length > 0) {
  472. keyPathArr.push(token);
  473. token = "";
  474. }
  475. break;
  476. }
  477. case "]":
  478. if (inOpenParentheses) {
  479. if (token.length > 0) {
  480. const tokenFirstChar = token[0];
  481. const tokenLastChar = token[token.length - 1];
  482. if (tokenFirstChar === '"' && tokenLastChar === '"' || tokenFirstChar === "'" && tokenLastChar === "'" || tokenFirstChar === "`" && tokenLastChar === "`") {
  483. if (token.length > 2) {
  484. token = token.slice(1, -1);
  485. } else {
  486. return [];
  487. }
  488. } else if (!/^\d+$/.test(token)) {
  489. return [];
  490. }
  491. keyPathArr.push(token);
  492. token = "";
  493. } else {
  494. return [];
  495. }
  496. inOpenParentheses = false;
  497. } else {
  498. return [];
  499. }
  500. break;
  501. default:
  502. token += word;
  503. break;
  504. }
  505. if (i === keyPath.length - 1) {
  506. if (token.length > 0) {
  507. keyPathArr.push(token);
  508. token = "";
  509. }
  510. }
  511. }
  512. return keyPathArr;
  513. }
  514. _getValue(keyPath) {
  515. const keyPathArr = this._resolveKeyPath(keyPath);
  516. if (keyPathArr.length === 0) {
  517. return null;
  518. }
  519. let value = this;
  520. for (let i = 0; i < keyPathArr.length; i++) {
  521. const key = keyPathArr[i];
  522. if (value instanceof Object) {
  523. value = value[key];
  524. } else {
  525. return null;
  526. }
  527. }
  528. return value;
  529. }
  530. get(key) {
  531. return this._getValue(key);
  532. }
  533. set(key, value) {
  534. this[key] = value;
  535. }
  536. getAny(key) {
  537. return this._getValue(key);
  538. }
  539. getString(key) {
  540. const value = this._getValue(key);
  541. if (typeof value === "string") {
  542. return value;
  543. } else {
  544. return null;
  545. }
  546. }
  547. getNumber(key) {
  548. const value = this._getValue(key);
  549. if (typeof value === "number") {
  550. return value;
  551. } else {
  552. return null;
  553. }
  554. }
  555. getBoolean(key) {
  556. const boolean = this._getValue(key);
  557. if (typeof boolean === "boolean") {
  558. return boolean;
  559. } else {
  560. return null;
  561. }
  562. }
  563. getJSON(key) {
  564. let value = this._getValue(key);
  565. if (value instanceof Object) {
  566. return new UTSJSONObject2(value);
  567. } else {
  568. return null;
  569. }
  570. }
  571. getArray(key) {
  572. let value = this._getValue(key);
  573. if (value instanceof Array) {
  574. return value;
  575. } else {
  576. return null;
  577. }
  578. }
  579. toMap() {
  580. let map = /* @__PURE__ */ new Map();
  581. for (let key in this) {
  582. map.set(key, this[key]);
  583. }
  584. return map;
  585. }
  586. forEach(callback) {
  587. for (let key in this) {
  588. callback(this[key], key);
  589. }
  590. }
  591. };
  592. function getGlobal() {
  593. if (typeof globalThis !== "undefined") {
  594. return globalThis;
  595. }
  596. if (typeof self !== "undefined") {
  597. return self;
  598. }
  599. if (typeof window !== "undefined") {
  600. return window;
  601. }
  602. if (typeof window !== "undefined") {
  603. return window;
  604. }
  605. function g2() {
  606. return this;
  607. }
  608. if (typeof g2() !== "undefined") {
  609. return g2();
  610. }
  611. return function() {
  612. return new Function("return this")();
  613. }();
  614. }
  615. const realGlobal = getGlobal();
  616. realGlobal.UTSJSONObject = UTSJSONObject$1;
  617. realGlobal.UniError = UniError$1;
  618. realGlobal.UTS = UTS$1;
  619. const isEnableLocale = /* @__PURE__ */ once(
  620. () => typeof __uniConfig !== "undefined" && __uniConfig.locales && !!Object.keys(__uniConfig.locales).length
  621. );
  622. let i18n;
  623. function getLocaleMessage() {
  624. const locale = uni.getLocale();
  625. const locales = __uniConfig.locales;
  626. return locales[locale] || locales[__uniConfig.fallbackLocale] || locales.en || {};
  627. }
  628. function formatI18n(message) {
  629. if (isI18nStr(message, I18N_JSON_DELIMITERS)) {
  630. return useI18n().f(message, getLocaleMessage(), I18N_JSON_DELIMITERS);
  631. }
  632. return message;
  633. }
  634. function resolveJsonObj(jsonObj, names) {
  635. if (names.length === 1) {
  636. if (jsonObj) {
  637. const _isI18nStr = (value2) => isString(value2) && isI18nStr(value2, I18N_JSON_DELIMITERS);
  638. const _name = names[0];
  639. let filterJsonObj = [];
  640. if (isArray(jsonObj) && (filterJsonObj = jsonObj.filter((item) => _isI18nStr(item[_name]))).length) {
  641. return filterJsonObj;
  642. }
  643. const value = jsonObj[names[0]];
  644. if (_isI18nStr(value)) {
  645. return jsonObj;
  646. }
  647. }
  648. return;
  649. }
  650. const name = names.shift();
  651. return resolveJsonObj(jsonObj && jsonObj[name], names);
  652. }
  653. function defineI18nProperties(obj, names) {
  654. return names.map((name) => defineI18nProperty(obj, name));
  655. }
  656. function defineI18nProperty(obj, names) {
  657. const jsonObj = resolveJsonObj(obj, names);
  658. if (!jsonObj) {
  659. return false;
  660. }
  661. const prop = names[names.length - 1];
  662. if (isArray(jsonObj)) {
  663. jsonObj.forEach((item) => defineI18nProperty(item, [prop]));
  664. } else {
  665. let value = jsonObj[prop];
  666. Object.defineProperty(jsonObj, prop, {
  667. get() {
  668. return formatI18n(value);
  669. },
  670. set(v2) {
  671. value = v2;
  672. }
  673. });
  674. }
  675. return true;
  676. }
  677. function useI18n() {
  678. if (!i18n) {
  679. let locale;
  680. {
  681. {
  682. locale = navigator.cookieEnabled && window.localStorage && localStorage[UNI_STORAGE_LOCALE] || __uniConfig.locale || navigator.language;
  683. }
  684. }
  685. i18n = initVueI18n(locale);
  686. if (isEnableLocale()) {
  687. const localeKeys = Object.keys(__uniConfig.locales || {});
  688. if (localeKeys.length) {
  689. localeKeys.forEach(
  690. (locale2) => i18n.add(locale2, __uniConfig.locales[locale2])
  691. );
  692. }
  693. i18n.setLocale(locale);
  694. }
  695. }
  696. return i18n;
  697. }
  698. function normalizeMessages(module, keys, values) {
  699. return keys.reduce((res, name, index2) => {
  700. res[module + name] = values[index2];
  701. return res;
  702. }, {});
  703. }
  704. const initI18nAsyncMsgsOnce = /* @__PURE__ */ once(() => {
  705. const name = "uni.async.";
  706. const keys = ["error"];
  707. if (__UNI_FEATURE_I18N_EN__) {
  708. useI18n().add(
  709. LOCALE_EN,
  710. normalizeMessages(name, keys, [
  711. "The connection timed out, click the screen to try again."
  712. ]),
  713. false
  714. );
  715. }
  716. if (__UNI_FEATURE_I18N_ES__) {
  717. useI18n().add(
  718. LOCALE_ES,
  719. normalizeMessages(name, keys, [
  720. "Se agotó el tiempo de conexión, haga clic en la pantalla para volver a intentarlo."
  721. ]),
  722. false
  723. );
  724. }
  725. if (__UNI_FEATURE_I18N_FR__) {
  726. useI18n().add(
  727. LOCALE_FR,
  728. normalizeMessages(name, keys, [
  729. "La connexion a expiré, cliquez sur l'écran pour réessayer."
  730. ]),
  731. false
  732. );
  733. }
  734. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  735. useI18n().add(
  736. LOCALE_ZH_HANS,
  737. normalizeMessages(name, keys, ["连接服务器超时,点击屏幕重试"]),
  738. false
  739. );
  740. }
  741. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  742. useI18n().add(
  743. LOCALE_ZH_HANT,
  744. normalizeMessages(name, keys, ["連接服務器超時,點擊屏幕重試"]),
  745. false
  746. );
  747. }
  748. });
  749. const initI18nShowActionSheetMsgsOnce = /* @__PURE__ */ once(() => {
  750. const name = "uni.showActionSheet.";
  751. const keys = ["cancel"];
  752. if (__UNI_FEATURE_I18N_EN__) {
  753. useI18n().add(LOCALE_EN, normalizeMessages(name, keys, ["Cancel"]), false);
  754. }
  755. if (__UNI_FEATURE_I18N_ES__) {
  756. useI18n().add(LOCALE_ES, normalizeMessages(name, keys, ["Cancelar"]), false);
  757. }
  758. if (__UNI_FEATURE_I18N_FR__) {
  759. useI18n().add(LOCALE_FR, normalizeMessages(name, keys, ["Annuler"]), false);
  760. }
  761. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  762. useI18n().add(
  763. LOCALE_ZH_HANS,
  764. normalizeMessages(name, keys, ["取消"]),
  765. false
  766. );
  767. }
  768. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  769. useI18n().add(
  770. LOCALE_ZH_HANT,
  771. normalizeMessages(name, keys, ["取消"]),
  772. false
  773. );
  774. }
  775. });
  776. const initI18nShowToastMsgsOnce = /* @__PURE__ */ once(() => {
  777. const name = "uni.showToast.";
  778. const keys = ["unpaired"];
  779. if (__UNI_FEATURE_I18N_EN__) {
  780. useI18n().add(
  781. LOCALE_EN,
  782. normalizeMessages(name, keys, [
  783. "Please note showToast must be paired with hideToast"
  784. ]),
  785. false
  786. );
  787. }
  788. if (__UNI_FEATURE_I18N_ES__) {
  789. useI18n().add(
  790. LOCALE_ES,
  791. normalizeMessages(name, keys, [
  792. "Tenga en cuenta que showToast debe estar emparejado con hideToast"
  793. ]),
  794. false
  795. );
  796. }
  797. if (__UNI_FEATURE_I18N_FR__) {
  798. useI18n().add(
  799. LOCALE_FR,
  800. normalizeMessages(name, keys, [
  801. "Veuillez noter que showToast doit être associé à hideToast"
  802. ]),
  803. false
  804. );
  805. }
  806. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  807. useI18n().add(
  808. LOCALE_ZH_HANS,
  809. normalizeMessages(name, keys, [
  810. "请注意 showToast 与 hideToast 必须配对使用"
  811. ]),
  812. false
  813. );
  814. }
  815. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  816. useI18n().add(
  817. LOCALE_ZH_HANT,
  818. normalizeMessages(name, keys, [
  819. "請注意 showToast 與 hideToast 必須配對使用"
  820. ]),
  821. false
  822. );
  823. }
  824. });
  825. const initI18nShowLoadingMsgsOnce = /* @__PURE__ */ once(() => {
  826. const name = "uni.showLoading.";
  827. const keys = ["unpaired"];
  828. if (__UNI_FEATURE_I18N_EN__) {
  829. useI18n().add(
  830. LOCALE_EN,
  831. normalizeMessages(name, keys, [
  832. "Please note showLoading must be paired with hideLoading"
  833. ]),
  834. false
  835. );
  836. }
  837. if (__UNI_FEATURE_I18N_ES__) {
  838. useI18n().add(
  839. LOCALE_ES,
  840. normalizeMessages(name, keys, [
  841. "Tenga en cuenta que showLoading debe estar emparejado con hideLoading"
  842. ]),
  843. false
  844. );
  845. }
  846. if (__UNI_FEATURE_I18N_FR__) {
  847. useI18n().add(
  848. LOCALE_FR,
  849. normalizeMessages(name, keys, [
  850. "Veuillez noter que showLoading doit être associé à hideLoading"
  851. ]),
  852. false
  853. );
  854. }
  855. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  856. useI18n().add(
  857. LOCALE_ZH_HANS,
  858. normalizeMessages(name, keys, [
  859. "请注意 showLoading 与 hideLoading 必须配对使用"
  860. ]),
  861. false
  862. );
  863. }
  864. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  865. useI18n().add(
  866. LOCALE_ZH_HANT,
  867. normalizeMessages(name, keys, [
  868. "請注意 showLoading 與 hideLoading 必須配對使用"
  869. ]),
  870. false
  871. );
  872. }
  873. });
  874. const initI18nShowModalMsgsOnce = /* @__PURE__ */ once(() => {
  875. const name = "uni.showModal.";
  876. const keys = ["cancel", "confirm"];
  877. if (__UNI_FEATURE_I18N_EN__) {
  878. useI18n().add(
  879. LOCALE_EN,
  880. normalizeMessages(name, keys, ["Cancel", "OK"]),
  881. false
  882. );
  883. }
  884. if (__UNI_FEATURE_I18N_ES__) {
  885. useI18n().add(
  886. LOCALE_ES,
  887. normalizeMessages(name, keys, ["Cancelar", "OK"]),
  888. false
  889. );
  890. }
  891. if (__UNI_FEATURE_I18N_FR__) {
  892. useI18n().add(
  893. LOCALE_FR,
  894. normalizeMessages(name, keys, ["Annuler", "OK"]),
  895. false
  896. );
  897. }
  898. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  899. useI18n().add(
  900. LOCALE_ZH_HANS,
  901. normalizeMessages(name, keys, ["取消", "确定"]),
  902. false
  903. );
  904. }
  905. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  906. useI18n().add(
  907. LOCALE_ZH_HANT,
  908. normalizeMessages(name, keys, ["取消", "確定"]),
  909. false
  910. );
  911. }
  912. });
  913. const initI18nChooseFileMsgsOnce = /* @__PURE__ */ once(() => {
  914. const name = "uni.chooseFile.";
  915. const keys = ["notUserActivation"];
  916. if (__UNI_FEATURE_I18N_EN__) {
  917. useI18n().add(
  918. LOCALE_EN,
  919. normalizeMessages(name, keys, [
  920. "File chooser dialog can only be shown with a user activation"
  921. ]),
  922. false
  923. );
  924. }
  925. if (__UNI_FEATURE_I18N_ES__) {
  926. useI18n().add(
  927. LOCALE_ES,
  928. normalizeMessages(name, keys, [
  929. "El cuadro de diálogo del selector de archivos solo se puede mostrar con la activación del usuario"
  930. ]),
  931. false
  932. );
  933. }
  934. if (__UNI_FEATURE_I18N_FR__) {
  935. useI18n().add(
  936. LOCALE_FR,
  937. normalizeMessages(name, keys, [
  938. "La boîte de dialogue du sélecteur de fichier ne peut être affichée qu'avec une activation par l'utilisateur"
  939. ]),
  940. false
  941. );
  942. }
  943. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  944. useI18n().add(
  945. LOCALE_ZH_HANS,
  946. normalizeMessages(name, keys, ["文件选择器对话框只能在由用户激活时显示"]),
  947. false
  948. );
  949. }
  950. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  951. useI18n().add(
  952. LOCALE_ZH_HANT,
  953. normalizeMessages(name, keys, ["文件選擇器對話框只能在由用戶激活時顯示"]),
  954. false
  955. );
  956. }
  957. });
  958. const initI18nSetClipboardDataMsgsOnce = /* @__PURE__ */ once(() => {
  959. const name = "uni.setClipboardData.";
  960. const keys = ["success", "fail"];
  961. if (__UNI_FEATURE_I18N_EN__) {
  962. useI18n().add(
  963. LOCALE_EN,
  964. normalizeMessages(name, keys, [
  965. "Content copied",
  966. "Copy failed, please copy manually"
  967. ]),
  968. false
  969. );
  970. }
  971. if (__UNI_FEATURE_I18N_ES__) {
  972. useI18n().add(
  973. LOCALE_ES,
  974. normalizeMessages(name, keys, [
  975. "Contenido copiado",
  976. "Error al copiar, copie manualmente"
  977. ]),
  978. false
  979. );
  980. }
  981. if (__UNI_FEATURE_I18N_FR__) {
  982. useI18n().add(
  983. LOCALE_FR,
  984. normalizeMessages(name, keys, [
  985. "Contenu copié",
  986. "Échec de la copie, copiez manuellement"
  987. ]),
  988. false
  989. );
  990. }
  991. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  992. useI18n().add(
  993. LOCALE_ZH_HANS,
  994. normalizeMessages(name, keys, ["内容已复制", "复制失败,请手动复制"]),
  995. false
  996. );
  997. }
  998. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  999. useI18n().add(
  1000. LOCALE_ZH_HANT,
  1001. normalizeMessages(name, keys, ["內容已復制", "復制失敗,請手動復製"]),
  1002. false
  1003. );
  1004. }
  1005. });
  1006. const initI18nGetClipboardDataMsgsOnce = /* @__PURE__ */ once(() => {
  1007. const name = "uni.getClipboardData.";
  1008. const keys = ["fail"];
  1009. if (__UNI_FEATURE_I18N_EN__) {
  1010. useI18n().add(
  1011. LOCALE_EN,
  1012. normalizeMessages(name, keys, ["Reading failed, please paste manually"]),
  1013. false
  1014. );
  1015. }
  1016. if (__UNI_FEATURE_I18N_ES__) {
  1017. useI18n().add(
  1018. LOCALE_ES,
  1019. normalizeMessages(name, keys, ["Error de lectura, pegue manualmente"]),
  1020. false
  1021. );
  1022. }
  1023. if (__UNI_FEATURE_I18N_FR__) {
  1024. useI18n().add(
  1025. LOCALE_FR,
  1026. normalizeMessages(name, keys, [
  1027. "Échec de la lecture, veuillez coller manuellement"
  1028. ]),
  1029. false
  1030. );
  1031. }
  1032. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  1033. useI18n().add(
  1034. LOCALE_ZH_HANS,
  1035. normalizeMessages(name, keys, ["读取失败,请手动粘贴"]),
  1036. false
  1037. );
  1038. }
  1039. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  1040. useI18n().add(
  1041. LOCALE_ZH_HANT,
  1042. normalizeMessages(name, keys, ["讀取失敗,請手動粘貼"]),
  1043. false
  1044. );
  1045. }
  1046. });
  1047. const initI18nPickerMsgsOnce = /* @__PURE__ */ once(() => {
  1048. const name = "uni.picker.";
  1049. const keys = ["done", "cancel"];
  1050. if (__UNI_FEATURE_I18N_EN__) {
  1051. useI18n().add(
  1052. LOCALE_EN,
  1053. normalizeMessages(name, keys, ["Done", "Cancel"]),
  1054. false
  1055. );
  1056. }
  1057. if (__UNI_FEATURE_I18N_ES__) {
  1058. useI18n().add(
  1059. LOCALE_ES,
  1060. normalizeMessages(name, keys, ["OK", "Cancelar"]),
  1061. false
  1062. );
  1063. }
  1064. if (__UNI_FEATURE_I18N_FR__) {
  1065. useI18n().add(
  1066. LOCALE_FR,
  1067. normalizeMessages(name, keys, ["OK", "Annuler"]),
  1068. false
  1069. );
  1070. }
  1071. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  1072. useI18n().add(
  1073. LOCALE_ZH_HANS,
  1074. normalizeMessages(name, keys, ["完成", "取消"]),
  1075. false
  1076. );
  1077. }
  1078. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  1079. useI18n().add(
  1080. LOCALE_ZH_HANT,
  1081. normalizeMessages(name, keys, ["完成", "取消"]),
  1082. false
  1083. );
  1084. }
  1085. });
  1086. const initI18nVideoMsgsOnce = /* @__PURE__ */ once(() => {
  1087. const name = "uni.video.";
  1088. const keys = ["danmu", "volume"];
  1089. if (__UNI_FEATURE_I18N_EN__) {
  1090. useI18n().add(
  1091. LOCALE_EN,
  1092. normalizeMessages(name, keys, ["Danmu", "Volume"]),
  1093. false
  1094. );
  1095. }
  1096. if (__UNI_FEATURE_I18N_ES__) {
  1097. useI18n().add(
  1098. LOCALE_ES,
  1099. normalizeMessages(name, keys, ["Danmu", "Volumen"]),
  1100. false
  1101. );
  1102. }
  1103. if (__UNI_FEATURE_I18N_FR__) {
  1104. useI18n().add(
  1105. LOCALE_FR,
  1106. normalizeMessages(name, keys, ["Danmu", "Le Volume"]),
  1107. false
  1108. );
  1109. }
  1110. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  1111. useI18n().add(
  1112. LOCALE_ZH_HANS,
  1113. normalizeMessages(name, keys, ["弹幕", "音量"]),
  1114. false
  1115. );
  1116. }
  1117. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  1118. useI18n().add(
  1119. LOCALE_ZH_HANT,
  1120. normalizeMessages(name, keys, ["彈幕", "音量"]),
  1121. false
  1122. );
  1123. }
  1124. });
  1125. const initI18nChooseLocationMsgsOnce = /* @__PURE__ */ once(() => {
  1126. const name = "uni.chooseLocation.";
  1127. const keys = ["search", "cancel"];
  1128. if (__UNI_FEATURE_I18N_EN__) {
  1129. useI18n().add(
  1130. LOCALE_EN,
  1131. normalizeMessages(name, keys, ["Find Place", "Cancel"]),
  1132. false
  1133. );
  1134. }
  1135. if (__UNI_FEATURE_I18N_ES__) {
  1136. useI18n().add(
  1137. LOCALE_ES,
  1138. normalizeMessages(name, keys, ["Encontrar", "Cancelar"]),
  1139. false
  1140. );
  1141. }
  1142. if (__UNI_FEATURE_I18N_FR__) {
  1143. useI18n().add(
  1144. LOCALE_FR,
  1145. normalizeMessages(name, keys, ["Trouve", "Annuler"]),
  1146. false
  1147. );
  1148. }
  1149. if (__UNI_FEATURE_I18N_ZH_HANS__) {
  1150. useI18n().add(
  1151. LOCALE_ZH_HANS,
  1152. normalizeMessages(name, keys, ["搜索地点", "取消"]),
  1153. false
  1154. );
  1155. }
  1156. if (__UNI_FEATURE_I18N_ZH_HANT__) {
  1157. useI18n().add(
  1158. LOCALE_ZH_HANT,
  1159. normalizeMessages(name, keys, ["搜索地點", "取消"]),
  1160. false
  1161. );
  1162. }
  1163. });
  1164. function initNavigationBarI18n(navigationBar) {
  1165. if (isEnableLocale()) {
  1166. return defineI18nProperties(navigationBar, [
  1167. ["titleText"],
  1168. ["searchInput", "placeholder"],
  1169. ["buttons", "text"]
  1170. ]);
  1171. }
  1172. }
  1173. function initTabBarI18n(tabBar2) {
  1174. if (isEnableLocale() && tabBar2.list) {
  1175. tabBar2.list.forEach((item) => {
  1176. defineI18nProperty(item, ["text"]);
  1177. });
  1178. }
  1179. return tabBar2;
  1180. }
  1181. function initBridge(subscribeNamespace) {
  1182. const emitter2 = new Emitter();
  1183. return {
  1184. on(event, callback) {
  1185. return emitter2.on(event, callback);
  1186. },
  1187. once(event, callback) {
  1188. return emitter2.once(event, callback);
  1189. },
  1190. off(event, callback) {
  1191. return emitter2.off(event, callback);
  1192. },
  1193. emit(event, ...args) {
  1194. return emitter2.emit(event, ...args);
  1195. },
  1196. subscribe(event, callback, once2 = false) {
  1197. emitter2[once2 ? "once" : "on"](`${subscribeNamespace}.${event}`, callback);
  1198. },
  1199. unsubscribe(event, callback) {
  1200. emitter2.off(`${subscribeNamespace}.${event}`, callback);
  1201. },
  1202. subscribeHandler(event, args, pageId) {
  1203. emitter2.emit(`${subscribeNamespace}.${event}`, args, pageId);
  1204. }
  1205. };
  1206. }
  1207. const INVOKE_VIEW_API = "invokeViewApi";
  1208. const INVOKE_SERVICE_API = "invokeServiceApi";
  1209. let invokeServiceMethodId = 1;
  1210. const invokeServiceMethod = (name, args, callback) => {
  1211. const { subscribe, publishHandler } = UniViewJSBridge;
  1212. const id2 = callback ? invokeServiceMethodId++ : 0;
  1213. callback && subscribe(INVOKE_SERVICE_API + "." + id2, callback, true);
  1214. publishHandler(INVOKE_SERVICE_API, { id: id2, name, args });
  1215. };
  1216. const viewMethods = /* @__PURE__ */ Object.create(null);
  1217. function normalizeViewMethodName(pageId, name) {
  1218. return pageId + "." + name;
  1219. }
  1220. function subscribeViewMethod(pageId, wrapper) {
  1221. UniViewJSBridge.subscribe(
  1222. normalizeViewMethodName(pageId, INVOKE_VIEW_API),
  1223. wrapper ? wrapper(onInvokeViewMethod) : onInvokeViewMethod
  1224. );
  1225. }
  1226. function unsubscribeViewMethod(pageId) {
  1227. UniViewJSBridge.unsubscribe(normalizeViewMethodName(pageId, INVOKE_VIEW_API));
  1228. Object.keys(viewMethods).forEach((name) => {
  1229. if (name.indexOf(pageId + ".") === 0) {
  1230. delete viewMethods[name];
  1231. }
  1232. });
  1233. }
  1234. function registerViewMethod(pageId, name, fn) {
  1235. name = normalizeViewMethodName(pageId, name);
  1236. if (!viewMethods[name]) {
  1237. viewMethods[name] = fn;
  1238. }
  1239. }
  1240. function unregisterViewMethod(pageId, name) {
  1241. name = normalizeViewMethodName(pageId, name);
  1242. delete viewMethods[name];
  1243. }
  1244. function onInvokeViewMethod({
  1245. id: id2,
  1246. name,
  1247. args
  1248. }, pageId) {
  1249. name = normalizeViewMethodName(pageId, name);
  1250. const publish = (res) => {
  1251. id2 && UniViewJSBridge.publishHandler(INVOKE_VIEW_API + "." + id2, res);
  1252. };
  1253. const handler = viewMethods[name];
  1254. if (handler) {
  1255. handler(args, publish);
  1256. } else {
  1257. publish({});
  1258. }
  1259. }
  1260. const ViewJSBridge = /* @__PURE__ */ extend(
  1261. /* @__PURE__ */ initBridge("service"),
  1262. {
  1263. invokeServiceMethod
  1264. }
  1265. );
  1266. const LONGPRESS_TIMEOUT = 350;
  1267. const LONGPRESS_THRESHOLD = 10;
  1268. const passiveOptions$2 = /* @__PURE__ */ passive(true);
  1269. let longPressTimer;
  1270. function clearLongPressTimer() {
  1271. if (longPressTimer) {
  1272. clearTimeout(longPressTimer);
  1273. longPressTimer = null;
  1274. }
  1275. }
  1276. let startPageX = 0;
  1277. let startPageY = 0;
  1278. function touchstart(evt) {
  1279. clearLongPressTimer();
  1280. if (evt.touches.length !== 1) {
  1281. return;
  1282. }
  1283. const { pageX, pageY } = evt.touches[0];
  1284. startPageX = pageX;
  1285. startPageY = pageY;
  1286. longPressTimer = setTimeout(function() {
  1287. const customEvent = new CustomEvent("longpress", {
  1288. bubbles: true,
  1289. cancelable: true,
  1290. // @ts-expect-error
  1291. target: evt.target,
  1292. currentTarget: evt.currentTarget
  1293. });
  1294. customEvent.touches = evt.touches;
  1295. customEvent.changedTouches = evt.changedTouches;
  1296. evt.target.dispatchEvent(customEvent);
  1297. }, LONGPRESS_TIMEOUT);
  1298. }
  1299. function touchmove(evt) {
  1300. if (!longPressTimer) {
  1301. return;
  1302. }
  1303. if (evt.touches.length !== 1) {
  1304. return clearLongPressTimer();
  1305. }
  1306. const { pageX, pageY } = evt.touches[0];
  1307. if (Math.abs(pageX - startPageX) > LONGPRESS_THRESHOLD || Math.abs(pageY - startPageY) > LONGPRESS_THRESHOLD) {
  1308. return clearLongPressTimer();
  1309. }
  1310. }
  1311. function initLongPress() {
  1312. window.addEventListener("touchstart", touchstart, passiveOptions$2);
  1313. window.addEventListener("touchmove", touchmove, passiveOptions$2);
  1314. window.addEventListener("touchend", clearLongPressTimer, passiveOptions$2);
  1315. window.addEventListener("touchcancel", clearLongPressTimer, passiveOptions$2);
  1316. }
  1317. function checkValue$1(value, defaultValue) {
  1318. const newValue = Number(value);
  1319. return isNaN(newValue) ? defaultValue : newValue;
  1320. }
  1321. function getWindowWidth$1() {
  1322. const screenFix = /^Apple/.test(navigator.vendor) && typeof window.orientation === "number";
  1323. const landscape = screenFix && Math.abs(window.orientation) === 90;
  1324. var screenWidth = screenFix ? Math[landscape ? "max" : "min"](screen.width, screen.height) : screen.width;
  1325. var windowWidth = Math.min(
  1326. window.innerWidth,
  1327. document.documentElement.clientWidth,
  1328. screenWidth
  1329. ) || screenWidth;
  1330. return windowWidth;
  1331. }
  1332. function useRem() {
  1333. const config = __uniConfig.globalStyle || {};
  1334. const maxWidth2 = checkValue$1(config.rpxCalcMaxDeviceWidth, 960);
  1335. const baseWidth2 = checkValue$1(config.rpxCalcBaseDeviceWidth, 375);
  1336. function updateRem() {
  1337. let width = getWindowWidth$1();
  1338. width = width <= maxWidth2 ? width : baseWidth2;
  1339. document.documentElement.style.fontSize = width / 23.4375 + "px";
  1340. }
  1341. updateRem();
  1342. document.addEventListener("DOMContentLoaded", updateRem);
  1343. window.addEventListener("load", updateRem);
  1344. window.addEventListener("resize", updateRem);
  1345. }
  1346. function initView() {
  1347. useRem();
  1348. initCustomDatasetOnce();
  1349. if (__UNI_FEATURE_LONGPRESS__) {
  1350. initLongPress();
  1351. }
  1352. }
  1353. function getDefaultExportFromCjs(x) {
  1354. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
  1355. }
  1356. var attrs = ["top", "left", "right", "bottom"];
  1357. var inited$1;
  1358. var elementComputedStyle = {};
  1359. var support;
  1360. function getSupport() {
  1361. if (!("CSS" in window) || typeof CSS.supports != "function") {
  1362. support = "";
  1363. } else if (CSS.supports("top: env(safe-area-inset-top)")) {
  1364. support = "env";
  1365. } else if (CSS.supports("top: constant(safe-area-inset-top)")) {
  1366. support = "constant";
  1367. } else {
  1368. support = "";
  1369. }
  1370. return support;
  1371. }
  1372. function init() {
  1373. support = typeof support === "string" ? support : getSupport();
  1374. if (!support) {
  1375. attrs.forEach(function(attr2) {
  1376. elementComputedStyle[attr2] = 0;
  1377. });
  1378. return;
  1379. }
  1380. function setStyle(el, style) {
  1381. var elStyle = el.style;
  1382. Object.keys(style).forEach(function(key) {
  1383. var val = style[key];
  1384. elStyle[key] = val;
  1385. });
  1386. }
  1387. var cbs = [];
  1388. function parentReady(callback) {
  1389. if (callback) {
  1390. cbs.push(callback);
  1391. } else {
  1392. cbs.forEach(function(cb) {
  1393. cb();
  1394. });
  1395. }
  1396. }
  1397. var passiveEvents = false;
  1398. try {
  1399. var opts = Object.defineProperty({}, "passive", {
  1400. get: function() {
  1401. passiveEvents = { passive: true };
  1402. }
  1403. });
  1404. window.addEventListener("test", null, opts);
  1405. } catch (e2) {
  1406. }
  1407. function addChild(parent, attr2) {
  1408. var a1 = document.createElement("div");
  1409. var a2 = document.createElement("div");
  1410. var a1Children = document.createElement("div");
  1411. var a2Children = document.createElement("div");
  1412. var W = 100;
  1413. var MAX = 1e4;
  1414. var aStyle = {
  1415. position: "absolute",
  1416. width: W + "px",
  1417. height: "200px",
  1418. boxSizing: "border-box",
  1419. overflow: "hidden",
  1420. paddingBottom: support + "(safe-area-inset-" + attr2 + ")"
  1421. };
  1422. setStyle(a1, aStyle);
  1423. setStyle(a2, aStyle);
  1424. setStyle(a1Children, {
  1425. transition: "0s",
  1426. animation: "none",
  1427. width: "400px",
  1428. height: "400px"
  1429. });
  1430. setStyle(a2Children, {
  1431. transition: "0s",
  1432. animation: "none",
  1433. width: "250%",
  1434. height: "250%"
  1435. });
  1436. a1.appendChild(a1Children);
  1437. a2.appendChild(a2Children);
  1438. parent.appendChild(a1);
  1439. parent.appendChild(a2);
  1440. parentReady(function() {
  1441. a1.scrollTop = a2.scrollTop = MAX;
  1442. var a1LastScrollTop = a1.scrollTop;
  1443. var a2LastScrollTop = a2.scrollTop;
  1444. function onScroll() {
  1445. if (this.scrollTop === (this === a1 ? a1LastScrollTop : a2LastScrollTop)) {
  1446. return;
  1447. }
  1448. a1.scrollTop = a2.scrollTop = MAX;
  1449. a1LastScrollTop = a1.scrollTop;
  1450. a2LastScrollTop = a2.scrollTop;
  1451. attrChange(attr2);
  1452. }
  1453. a1.addEventListener("scroll", onScroll, passiveEvents);
  1454. a2.addEventListener("scroll", onScroll, passiveEvents);
  1455. });
  1456. var computedStyle = getComputedStyle(a1);
  1457. Object.defineProperty(elementComputedStyle, attr2, {
  1458. configurable: true,
  1459. get: function() {
  1460. return parseFloat(computedStyle.paddingBottom);
  1461. }
  1462. });
  1463. }
  1464. var parentDiv = document.createElement("div");
  1465. setStyle(parentDiv, {
  1466. position: "absolute",
  1467. left: "0",
  1468. top: "0",
  1469. width: "0",
  1470. height: "0",
  1471. zIndex: "-1",
  1472. overflow: "hidden",
  1473. visibility: "hidden"
  1474. });
  1475. attrs.forEach(function(key) {
  1476. addChild(parentDiv, key);
  1477. });
  1478. document.body.appendChild(parentDiv);
  1479. parentReady();
  1480. inited$1 = true;
  1481. }
  1482. function getAttr(attr2) {
  1483. if (!inited$1) {
  1484. init();
  1485. }
  1486. return elementComputedStyle[attr2];
  1487. }
  1488. var changeAttrs = [];
  1489. function attrChange(attr2) {
  1490. if (!changeAttrs.length) {
  1491. setTimeout(function() {
  1492. var style = {};
  1493. changeAttrs.forEach(function(attr3) {
  1494. style[attr3] = elementComputedStyle[attr3];
  1495. });
  1496. changeAttrs.length = 0;
  1497. callbacks.forEach(function(callback) {
  1498. callback(style);
  1499. });
  1500. }, 0);
  1501. }
  1502. changeAttrs.push(attr2);
  1503. }
  1504. var callbacks = [];
  1505. function onChange(callback) {
  1506. if (!getSupport()) {
  1507. return;
  1508. }
  1509. if (!inited$1) {
  1510. init();
  1511. }
  1512. if (typeof callback === "function") {
  1513. callbacks.push(callback);
  1514. }
  1515. }
  1516. function offChange(callback) {
  1517. var index2 = callbacks.indexOf(callback);
  1518. if (index2 >= 0) {
  1519. callbacks.splice(index2, 1);
  1520. }
  1521. }
  1522. var safeAreaInsets = {
  1523. get support() {
  1524. return (typeof support === "string" ? support : getSupport()).length != 0;
  1525. },
  1526. get top() {
  1527. return getAttr("top");
  1528. },
  1529. get left() {
  1530. return getAttr("left");
  1531. },
  1532. get right() {
  1533. return getAttr("right");
  1534. },
  1535. get bottom() {
  1536. return getAttr("bottom");
  1537. },
  1538. onChange,
  1539. offChange
  1540. };
  1541. var out = safeAreaInsets;
  1542. const safeAreaInsets$1 = /* @__PURE__ */ getDefaultExportFromCjs(out);
  1543. const onEventPrevent = /* @__PURE__ */ withModifiers(() => {
  1544. }, ["prevent"]);
  1545. const onEventStop = /* @__PURE__ */ withModifiers(
  1546. (_event) => {
  1547. },
  1548. ["stop"]
  1549. );
  1550. function getWindowOffsetCssVar(style, name) {
  1551. return parseInt((style.getPropertyValue(name).match(/\d+/) || ["0"])[0]);
  1552. }
  1553. function getWindowTop() {
  1554. const style = document.documentElement.style;
  1555. const top = getWindowOffsetCssVar(style, "--window-top");
  1556. return top ? top + safeAreaInsets$1.top : 0;
  1557. }
  1558. function getWindowOffset() {
  1559. const style = document.documentElement.style;
  1560. const top = getWindowTop();
  1561. const bottom = getWindowOffsetCssVar(style, "--window-bottom");
  1562. const left = getWindowOffsetCssVar(style, "--window-left");
  1563. const right = getWindowOffsetCssVar(style, "--window-right");
  1564. const topWindowHeight = getWindowOffsetCssVar(style, "--top-window-height");
  1565. return {
  1566. top,
  1567. bottom: bottom ? bottom + safeAreaInsets$1.bottom : 0,
  1568. left: left ? left + safeAreaInsets$1.left : 0,
  1569. right: right ? right + safeAreaInsets$1.right : 0,
  1570. topWindowHeight: topWindowHeight || 0
  1571. };
  1572. }
  1573. function updateCssVar(cssVars) {
  1574. const style = document.documentElement.style;
  1575. Object.keys(cssVars).forEach((name) => {
  1576. style.setProperty(name, cssVars[name]);
  1577. });
  1578. }
  1579. function updatePageCssVar(cssVars) {
  1580. return updateCssVar(cssVars);
  1581. }
  1582. const sheetsMap = /* @__PURE__ */ new Map();
  1583. function updateStyle(id2, content) {
  1584. let style = sheetsMap.get(id2);
  1585. if (style && !(style instanceof HTMLStyleElement)) {
  1586. removeStyle(id2);
  1587. style = void 0;
  1588. }
  1589. if (!style) {
  1590. style = document.createElement("style");
  1591. style.setAttribute("type", "text/css");
  1592. style.innerHTML = content;
  1593. document.head.appendChild(style);
  1594. } else {
  1595. style.innerHTML = content;
  1596. }
  1597. sheetsMap.set(id2, style);
  1598. }
  1599. function removeStyle(id2) {
  1600. let style = sheetsMap.get(id2);
  1601. if (style) {
  1602. if (style instanceof CSSStyleSheet) {
  1603. document.adoptedStyleSheets = document.adoptedStyleSheets.filter(
  1604. (s) => s !== style
  1605. );
  1606. } else {
  1607. document.head.removeChild(style);
  1608. }
  1609. sheetsMap.delete(id2);
  1610. }
  1611. }
  1612. function PolySymbol(name) {
  1613. return Symbol(process.env.NODE_ENV !== "production" ? "[uni-app]: " + name : name);
  1614. }
  1615. function hasRpx(str) {
  1616. str = str + "";
  1617. return str.indexOf("rpx") !== -1 || str.indexOf("upx") !== -1;
  1618. }
  1619. function rpx2px(str, replace = false) {
  1620. if (replace) {
  1621. return rpx2pxWithReplace(str);
  1622. }
  1623. if (isString(str)) {
  1624. const res = parseInt(str) || 0;
  1625. if (hasRpx(str)) {
  1626. return uni.upx2px(res);
  1627. }
  1628. return res;
  1629. }
  1630. return str;
  1631. }
  1632. function rpx2pxWithReplace(str) {
  1633. if (!hasRpx(str)) {
  1634. return str;
  1635. }
  1636. return str.replace(/(\d+(\.\d+)?)[ru]px/g, (_a, b) => {
  1637. return uni.upx2px(parseFloat(b)) + "px";
  1638. });
  1639. }
  1640. 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";
  1641. 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";
  1642. 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";
  1643. 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";
  1644. 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";
  1645. 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";
  1646. 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";
  1647. 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";
  1648. 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";
  1649. 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";
  1650. 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";
  1651. 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";
  1652. function createSvgIconVNode(path, color = "#000", size = 27) {
  1653. return createVNode(
  1654. "svg",
  1655. {
  1656. width: size,
  1657. height: size,
  1658. viewBox: "0 0 32 32"
  1659. },
  1660. [
  1661. createVNode(
  1662. "path",
  1663. {
  1664. d: path,
  1665. fill: color
  1666. },
  1667. null,
  1668. 8,
  1669. ["d", "fill"]
  1670. )
  1671. ],
  1672. 8,
  1673. ["width", "height"]
  1674. );
  1675. }
  1676. function useCurrentPageId() {
  1677. {
  1678. const { $pageInstance } = getCurrentInstance();
  1679. return $pageInstance && $pageInstance.proxy.$page.id;
  1680. }
  1681. }
  1682. function getPageIdByVm(instance2) {
  1683. const vm = resolveComponentInstance(instance2);
  1684. if (vm.$page) {
  1685. return vm.$page.id;
  1686. }
  1687. if (!vm.$) {
  1688. return;
  1689. }
  1690. {
  1691. const { $pageInstance } = vm.$;
  1692. return $pageInstance && $pageInstance.proxy.$page.id;
  1693. }
  1694. }
  1695. function getCurrentPage() {
  1696. const pages = getCurrentPages();
  1697. const len = pages.length;
  1698. if (len) {
  1699. return pages[len - 1];
  1700. }
  1701. }
  1702. function getCurrentPageMeta() {
  1703. const page = getCurrentPage();
  1704. if (page) {
  1705. return page.$page.meta;
  1706. }
  1707. }
  1708. function getCurrentPageId() {
  1709. const meta = getCurrentPageMeta();
  1710. if (meta) {
  1711. return meta.id;
  1712. }
  1713. return -1;
  1714. }
  1715. function getCurrentPageVm() {
  1716. const page = getCurrentPage();
  1717. if (page) {
  1718. return page.$vm;
  1719. }
  1720. }
  1721. const PAGE_META_KEYS = ["navigationBar", "pullToRefresh"];
  1722. function initGlobalStyle() {
  1723. return JSON.parse(JSON.stringify(__uniConfig.globalStyle || {}));
  1724. }
  1725. function initRouteMeta(pageMeta, id2) {
  1726. const globalStyle = initGlobalStyle();
  1727. const res = extend({ id: id2 }, globalStyle, pageMeta);
  1728. PAGE_META_KEYS.forEach((name) => {
  1729. res[name] = extend({}, globalStyle[name], pageMeta[name]);
  1730. });
  1731. const { navigationBar } = res;
  1732. navigationBar.titleText && navigationBar.titleImage && (navigationBar.titleText = "");
  1733. return res;
  1734. }
  1735. function normalizePullToRefreshRpx(pullToRefresh) {
  1736. if (pullToRefresh.offset) {
  1737. pullToRefresh.offset = rpx2px(pullToRefresh.offset);
  1738. }
  1739. if (pullToRefresh.height) {
  1740. pullToRefresh.height = rpx2px(pullToRefresh.height);
  1741. }
  1742. if (pullToRefresh.range) {
  1743. pullToRefresh.range = rpx2px(pullToRefresh.range);
  1744. }
  1745. return pullToRefresh;
  1746. }
  1747. function initPageInternalInstance(openType, url, pageQuery, meta, eventChannel, themeMode) {
  1748. const { id: id2, route } = meta;
  1749. const titleColor = normalizeStyles(
  1750. meta.navigationBar,
  1751. __uniConfig.themeConfig,
  1752. themeMode
  1753. ).titleColor;
  1754. return {
  1755. id: id2,
  1756. path: addLeadingSlash(route),
  1757. route,
  1758. fullPath: url,
  1759. options: pageQuery,
  1760. meta,
  1761. openType,
  1762. eventChannel,
  1763. statusBarStyle: titleColor === "#ffffff" ? "light" : "dark"
  1764. };
  1765. }
  1766. function removeHook(vm, name, hook) {
  1767. const hooks = vm.$[name];
  1768. if (!isArray(hooks)) {
  1769. return;
  1770. }
  1771. if (hook.__weh) {
  1772. remove(hooks, hook.__weh);
  1773. }
  1774. }
  1775. function invokeHook(vm, name, args) {
  1776. if (isString(vm)) {
  1777. args = name;
  1778. name = vm;
  1779. vm = getCurrentPageVm();
  1780. } else if (typeof vm === "number") {
  1781. const page = getCurrentPages().find((page2) => page2.$page.id === vm);
  1782. if (page) {
  1783. vm = page.$vm;
  1784. } else {
  1785. vm = getCurrentPageVm();
  1786. }
  1787. }
  1788. if (!vm) {
  1789. return;
  1790. }
  1791. const hooks = vm.$[name];
  1792. return hooks && invokeArrayFns(hooks, args);
  1793. }
  1794. function disableScrollListener(evt) {
  1795. evt.preventDefault();
  1796. }
  1797. let testReachBottomTimer;
  1798. let lastScrollHeight = 0;
  1799. function createScrollListener({
  1800. onPageScroll,
  1801. onReachBottom,
  1802. onReachBottomDistance
  1803. }) {
  1804. let ticking = false;
  1805. let hasReachBottom = false;
  1806. let reachBottomLocking = true;
  1807. const isReachBottom = () => {
  1808. const { scrollHeight } = document.documentElement;
  1809. const windowHeight = window.innerHeight;
  1810. const scrollY = window.scrollY;
  1811. const isBottom = scrollY > 0 && scrollHeight > windowHeight && scrollY + windowHeight + onReachBottomDistance >= scrollHeight;
  1812. const heightChanged = Math.abs(scrollHeight - lastScrollHeight) > onReachBottomDistance;
  1813. if (isBottom && (!hasReachBottom || heightChanged)) {
  1814. lastScrollHeight = scrollHeight;
  1815. hasReachBottom = true;
  1816. return true;
  1817. }
  1818. if (!isBottom && hasReachBottom) {
  1819. hasReachBottom = false;
  1820. }
  1821. return false;
  1822. };
  1823. const trigger = () => {
  1824. onPageScroll && onPageScroll(window.pageYOffset);
  1825. function testReachBottom() {
  1826. if (isReachBottom()) {
  1827. onReachBottom && onReachBottom();
  1828. reachBottomLocking = false;
  1829. setTimeout(function() {
  1830. reachBottomLocking = true;
  1831. }, 350);
  1832. return true;
  1833. }
  1834. }
  1835. if (onReachBottom && reachBottomLocking) {
  1836. if (testReachBottom())
  1837. ;
  1838. else {
  1839. testReachBottomTimer = setTimeout(testReachBottom, 300);
  1840. }
  1841. }
  1842. ticking = false;
  1843. };
  1844. return function onScroll() {
  1845. clearTimeout(testReachBottomTimer);
  1846. if (!ticking) {
  1847. requestAnimationFrame(trigger);
  1848. }
  1849. ticking = true;
  1850. };
  1851. }
  1852. function normalizeRoute(toRoute) {
  1853. if (toRoute.indexOf("/") === 0) {
  1854. return toRoute;
  1855. }
  1856. let fromRoute = "";
  1857. const pages = getCurrentPages();
  1858. if (pages.length) {
  1859. fromRoute = pages[pages.length - 1].$page.route;
  1860. }
  1861. return getRealRoute(fromRoute, toRoute);
  1862. }
  1863. function getRealRoute(fromRoute, toRoute) {
  1864. if (toRoute.indexOf("/") === 0) {
  1865. return toRoute;
  1866. }
  1867. if (toRoute.indexOf("./") === 0) {
  1868. return getRealRoute(fromRoute, toRoute.slice(2));
  1869. }
  1870. const toRouteArray = toRoute.split("/");
  1871. const toRouteLength = toRouteArray.length;
  1872. let i = 0;
  1873. for (; i < toRouteLength && toRouteArray[i] === ".."; i++) {
  1874. }
  1875. toRouteArray.splice(0, i);
  1876. toRoute = toRouteArray.join("/");
  1877. const fromRouteArray = fromRoute.length > 0 ? fromRoute.split("/") : [];
  1878. fromRouteArray.splice(fromRouteArray.length - i - 1, i + 1);
  1879. return addLeadingSlash(fromRouteArray.concat(toRouteArray).join("/"));
  1880. }
  1881. function getRouteOptions(path, alias = false) {
  1882. if (alias) {
  1883. return __uniRoutes.find(
  1884. (route) => route.path === path || route.alias === path
  1885. );
  1886. }
  1887. return __uniRoutes.find((route) => route.path === path);
  1888. }
  1889. function normalizeTabBarRoute(index2, oldPagePath, newPagePath) {
  1890. const oldTabBarRoute = getRouteOptions(addLeadingSlash(oldPagePath));
  1891. if (oldTabBarRoute) {
  1892. const { meta } = oldTabBarRoute;
  1893. delete meta.tabBarIndex;
  1894. meta.isQuit = meta.isTabBar = false;
  1895. }
  1896. const newTabBarRoute = getRouteOptions(addLeadingSlash(newPagePath));
  1897. if (newTabBarRoute) {
  1898. const { meta } = newTabBarRoute;
  1899. meta.tabBarIndex = index2;
  1900. meta.isQuit = meta.isTabBar = true;
  1901. const tabBar2 = __uniConfig.tabBar;
  1902. if (tabBar2 && tabBar2.list && tabBar2.list[index2]) {
  1903. tabBar2.list[index2].pagePath = removeLeadingSlash(newPagePath);
  1904. }
  1905. }
  1906. }
  1907. class ComponentDescriptor {
  1908. constructor(vm) {
  1909. this.$bindClass = false;
  1910. this.$bindStyle = false;
  1911. this.$vm = vm;
  1912. {
  1913. this.$el = resolveOwnerEl(vm.$);
  1914. }
  1915. if (this.$el.getAttribute) {
  1916. this.$bindClass = !!this.$el.getAttribute("class");
  1917. this.$bindStyle = !!this.$el.getAttribute("style");
  1918. }
  1919. }
  1920. selectComponent(selector) {
  1921. if (!this.$el || !selector) {
  1922. return;
  1923. }
  1924. const wxsVm = getWxsVm(this.$el.querySelector(selector));
  1925. if (!wxsVm) {
  1926. return;
  1927. }
  1928. return createComponentDescriptor(wxsVm, false);
  1929. }
  1930. selectAllComponents(selector) {
  1931. if (!this.$el || !selector) {
  1932. return [];
  1933. }
  1934. const descriptors = [];
  1935. const els = this.$el.querySelectorAll(selector);
  1936. for (let i = 0; i < els.length; i++) {
  1937. const wxsVm = getWxsVm(els[i]);
  1938. if (wxsVm) {
  1939. descriptors.push(createComponentDescriptor(wxsVm, false));
  1940. }
  1941. }
  1942. return descriptors;
  1943. }
  1944. forceUpdate(type) {
  1945. if (type === "class") {
  1946. if (this.$bindClass) {
  1947. this.$el.__wxsClassChanged = true;
  1948. this.$vm.$forceUpdate();
  1949. } else {
  1950. this.updateWxsClass();
  1951. }
  1952. } else if (type === "style") {
  1953. if (this.$bindStyle) {
  1954. this.$el.__wxsStyleChanged = true;
  1955. this.$vm.$forceUpdate();
  1956. } else {
  1957. this.updateWxsStyle();
  1958. }
  1959. }
  1960. }
  1961. updateWxsClass() {
  1962. const { __wxsAddClass } = this.$el;
  1963. if (__wxsAddClass.length) {
  1964. this.$el.className = __wxsAddClass.join(" ");
  1965. }
  1966. }
  1967. updateWxsStyle() {
  1968. const { __wxsStyle } = this.$el;
  1969. if (__wxsStyle) {
  1970. this.$el.setAttribute("style", stringifyStyle(__wxsStyle));
  1971. }
  1972. }
  1973. setStyle(style) {
  1974. if (!this.$el || !style) {
  1975. return this;
  1976. }
  1977. if (isString(style)) {
  1978. style = parseStringStyle(style);
  1979. }
  1980. if (isPlainObject$1(style)) {
  1981. this.$el.__wxsStyle = style;
  1982. this.forceUpdate("style");
  1983. }
  1984. return this;
  1985. }
  1986. addClass(clazz2) {
  1987. if (!this.$el || !clazz2) {
  1988. return this;
  1989. }
  1990. const __wxsAddClass = this.$el.__wxsAddClass || (this.$el.__wxsAddClass = []);
  1991. if (__wxsAddClass.indexOf(clazz2) === -1) {
  1992. __wxsAddClass.push(clazz2);
  1993. this.forceUpdate("class");
  1994. }
  1995. return this;
  1996. }
  1997. removeClass(clazz2) {
  1998. if (!this.$el || !clazz2) {
  1999. return this;
  2000. }
  2001. const { __wxsAddClass } = this.$el;
  2002. if (__wxsAddClass) {
  2003. const index2 = __wxsAddClass.indexOf(clazz2);
  2004. if (index2 > -1) {
  2005. __wxsAddClass.splice(index2, 1);
  2006. }
  2007. }
  2008. const __wxsRemoveClass = this.$el.__wxsRemoveClass || (this.$el.__wxsRemoveClass = []);
  2009. if (__wxsRemoveClass.indexOf(clazz2) === -1) {
  2010. __wxsRemoveClass.push(clazz2);
  2011. this.forceUpdate("class");
  2012. }
  2013. return this;
  2014. }
  2015. hasClass(cls) {
  2016. return this.$el && this.$el.classList.contains(cls);
  2017. }
  2018. getDataset() {
  2019. return this.$el && this.$el.dataset;
  2020. }
  2021. callMethod(funcName, args = {}) {
  2022. const func = this.$vm[funcName];
  2023. if (isFunction(func)) {
  2024. func(JSON.parse(JSON.stringify(args)));
  2025. } else if (this.$vm.ownerId) {
  2026. UniViewJSBridge.publishHandler(ON_WXS_INVOKE_CALL_METHOD, {
  2027. nodeId: this.$el.__id,
  2028. ownerId: this.$vm.ownerId,
  2029. method: funcName,
  2030. args
  2031. });
  2032. }
  2033. }
  2034. requestAnimationFrame(callback) {
  2035. return window.requestAnimationFrame(callback);
  2036. }
  2037. getState() {
  2038. return this.$el && (this.$el.__wxsState || (this.$el.__wxsState = {}));
  2039. }
  2040. triggerEvent(eventName, detail = {}) {
  2041. return this.$vm.$emit(eventName, detail), this;
  2042. }
  2043. getComputedStyle(names) {
  2044. if (this.$el) {
  2045. const styles = window.getComputedStyle(this.$el);
  2046. if (names && names.length) {
  2047. return names.reduce((res, n) => {
  2048. res[n] = styles[n];
  2049. return res;
  2050. }, {});
  2051. }
  2052. return styles;
  2053. }
  2054. return {};
  2055. }
  2056. setTimeout(handler, timeout) {
  2057. return window.setTimeout(handler, timeout);
  2058. }
  2059. clearTimeout(handle) {
  2060. return window.clearTimeout(handle);
  2061. }
  2062. getBoundingClientRect() {
  2063. return this.$el.getBoundingClientRect();
  2064. }
  2065. }
  2066. function createComponentDescriptor(vm, isOwnerInstance = true) {
  2067. {
  2068. if (isOwnerInstance && vm) {
  2069. vm = resolveOwnerVm(vm.$);
  2070. }
  2071. }
  2072. if (vm && vm.$el) {
  2073. if (!vm.$el.__wxsComponentDescriptor) {
  2074. vm.$el.__wxsComponentDescriptor = new ComponentDescriptor(vm);
  2075. }
  2076. return vm.$el.__wxsComponentDescriptor;
  2077. }
  2078. }
  2079. function getComponentDescriptor(instance2, isOwnerInstance) {
  2080. return createComponentDescriptor(instance2, isOwnerInstance);
  2081. }
  2082. function resolveOwnerComponentPublicInstance(eventValue, instance2, checkArgsLength = true) {
  2083. if (!instance2) {
  2084. return false;
  2085. }
  2086. if (checkArgsLength && eventValue.length < 2) {
  2087. return false;
  2088. }
  2089. const ownerVm = resolveOwnerVm(instance2);
  2090. if (!ownerVm) {
  2091. return false;
  2092. }
  2093. const type = ownerVm.$.type;
  2094. if (!type.$wxs && !type.$renderjs) {
  2095. return false;
  2096. }
  2097. return ownerVm;
  2098. }
  2099. function wrapperH5WxsEvent(event, eventValue, instance2, checkArgsLength = true) {
  2100. if (eventValue) {
  2101. if (!event.__instance) {
  2102. event.__instance = true;
  2103. Object.defineProperty(event, "instance", {
  2104. get() {
  2105. return getComponentDescriptor(instance2.proxy, false);
  2106. }
  2107. });
  2108. }
  2109. const ownerVm = resolveOwnerComponentPublicInstance(
  2110. eventValue,
  2111. instance2,
  2112. checkArgsLength
  2113. );
  2114. if (ownerVm) {
  2115. return [event, getComponentDescriptor(ownerVm, false)];
  2116. }
  2117. }
  2118. }
  2119. function getWxsVm(el) {
  2120. if (!el) {
  2121. return;
  2122. }
  2123. {
  2124. return el.__vueParentComponent && el.__vueParentComponent.proxy;
  2125. }
  2126. }
  2127. const isKeyboardEvent = (val) => !val.type.indexOf("key") && val instanceof KeyboardEvent;
  2128. const isClickEvent = (val) => val.type === "click";
  2129. const isMouseEvent = (val) => val.type.indexOf("mouse") === 0 || ["contextmenu"].includes(val.type);
  2130. const isTouchEvent = (val) => typeof TouchEvent !== "undefined" && val instanceof TouchEvent || val.type.indexOf("touch") === 0 || ["longpress"].indexOf(val.type) >= 0;
  2131. function $nne(evt, eventValue, instance2) {
  2132. const { currentTarget } = evt;
  2133. if (!(evt instanceof Event) || !(currentTarget instanceof HTMLElement)) {
  2134. return [evt];
  2135. }
  2136. const isHTMLTarget = currentTarget.tagName.indexOf("UNI-") !== 0;
  2137. {
  2138. if (isHTMLTarget) {
  2139. return wrapperH5WxsEvent(
  2140. evt,
  2141. eventValue,
  2142. instance2,
  2143. false
  2144. // 原生标签事件可能被cache,参数长度不准确,故默认不校验
  2145. ) || [evt];
  2146. }
  2147. }
  2148. const res = createNativeEvent(evt, isHTMLTarget);
  2149. if (isClickEvent(evt)) {
  2150. normalizeClickEvent(res, evt);
  2151. } else if (isMouseEvent(evt)) {
  2152. normalizeMouseEvent(res, evt);
  2153. } else if (isTouchEvent(evt)) {
  2154. const top = getWindowTop();
  2155. res.touches = normalizeTouchEvent(evt.touches, top);
  2156. res.changedTouches = normalizeTouchEvent(evt.changedTouches, top);
  2157. } else if (isKeyboardEvent(evt)) {
  2158. const proxyKeys = ["key", "code"];
  2159. proxyKeys.forEach((key) => {
  2160. Object.defineProperty(res, key, {
  2161. get() {
  2162. return evt[key];
  2163. }
  2164. });
  2165. });
  2166. }
  2167. {
  2168. return wrapperH5WxsEvent(
  2169. res,
  2170. eventValue,
  2171. instance2
  2172. ) || [res];
  2173. }
  2174. }
  2175. function findUniTarget(target) {
  2176. while (target && target.tagName.indexOf("UNI-") !== 0) {
  2177. target = target.parentElement;
  2178. }
  2179. return target;
  2180. }
  2181. function createNativeEvent(evt, htmlElement = false) {
  2182. const { type, timeStamp, target, currentTarget } = evt;
  2183. let realTarget, realCurrentTarget;
  2184. realTarget = htmlElement ? target : findUniTarget(target);
  2185. realCurrentTarget = currentTarget;
  2186. const event = {
  2187. type,
  2188. timeStamp,
  2189. target: realTarget,
  2190. detail: {},
  2191. currentTarget: realCurrentTarget
  2192. };
  2193. if (evt._stopped) {
  2194. event._stopped = true;
  2195. }
  2196. if (evt.type.startsWith("touch")) {
  2197. event.touches = evt.touches;
  2198. event.changedTouches = evt.changedTouches;
  2199. }
  2200. {
  2201. wrapperEvent(event, evt);
  2202. }
  2203. return event;
  2204. }
  2205. function wrapperEvent(event, evt) {
  2206. extend(event, {
  2207. preventDefault() {
  2208. return evt.preventDefault();
  2209. },
  2210. stopPropagation() {
  2211. return evt.stopPropagation();
  2212. }
  2213. });
  2214. }
  2215. function normalizeClickEvent(evt, mouseEvt) {
  2216. const { x, y } = mouseEvt;
  2217. const top = getWindowTop();
  2218. evt.detail = { x, y: y - top };
  2219. evt.x = x;
  2220. evt.y = y - top;
  2221. evt.touches = evt.changedTouches = [createTouchEvent(mouseEvt, top)];
  2222. }
  2223. function normalizeMouseEvent(evt, mouseEvt) {
  2224. const top = getWindowTop();
  2225. evt.pageX = mouseEvt.pageX;
  2226. evt.pageY = mouseEvt.pageY - top;
  2227. evt.clientX = mouseEvt.clientX;
  2228. evt.clientY = mouseEvt.clientY - top;
  2229. evt.touches = evt.changedTouches = [createTouchEvent(mouseEvt, top)];
  2230. }
  2231. function createTouchEvent(evt, top) {
  2232. return {
  2233. force: 1,
  2234. identifier: 0,
  2235. clientX: evt.clientX,
  2236. clientY: evt.clientY - top,
  2237. pageX: evt.pageX,
  2238. pageY: evt.pageY - top
  2239. };
  2240. }
  2241. function normalizeTouchEvent(touches, top) {
  2242. const res = [];
  2243. for (let i = 0; i < touches.length; i++) {
  2244. const {
  2245. identifier,
  2246. pageX,
  2247. pageY,
  2248. clientX,
  2249. clientY,
  2250. force,
  2251. screenX,
  2252. screenY
  2253. } = touches[i];
  2254. res.push({
  2255. identifier,
  2256. pageX,
  2257. pageY: pageY - top,
  2258. clientX,
  2259. clientY: clientY - top,
  2260. screenX,
  2261. screenY,
  2262. force: force || 0
  2263. });
  2264. }
  2265. return res;
  2266. }
  2267. const instance = /* @__PURE__ */ Object.defineProperty({
  2268. __proto__: null,
  2269. $nne,
  2270. createNativeEvent
  2271. }, Symbol.toStringTag, { value: "Module" });
  2272. function initAppConfig$1(appConfig) {
  2273. const globalProperties = appConfig.globalProperties;
  2274. extend(globalProperties, instance);
  2275. if (__UNI_FEATURE_WXS__) {
  2276. globalProperties.$gcd = getComponentDescriptor;
  2277. }
  2278. }
  2279. function initViewPlugin(app) {
  2280. initAppConfig$1(app._context.config);
  2281. }
  2282. const invokeOnCallback = (name, res) => UniServiceJSBridge.emit("api." + name, res);
  2283. let invokeViewMethodId = 1;
  2284. function publishViewMethodName(pageId) {
  2285. return (pageId || getCurrentPageId()) + "." + INVOKE_VIEW_API;
  2286. }
  2287. const invokeViewMethod = (name, args, pageId, callback) => {
  2288. const { subscribe, publishHandler } = UniServiceJSBridge;
  2289. const id2 = callback ? invokeViewMethodId++ : 0;
  2290. callback && subscribe(INVOKE_VIEW_API + "." + id2, callback, true);
  2291. publishHandler(publishViewMethodName(pageId), { id: id2, name, args }, pageId);
  2292. };
  2293. const invokeViewMethodKeepAlive = (name, args, callback, pageId) => {
  2294. const { subscribe, unsubscribe, publishHandler } = UniServiceJSBridge;
  2295. const id2 = invokeViewMethodId++;
  2296. const subscribeName = INVOKE_VIEW_API + "." + id2;
  2297. subscribe(subscribeName, callback);
  2298. publishHandler(publishViewMethodName(pageId), { id: id2, name, args }, pageId);
  2299. return () => {
  2300. unsubscribe(subscribeName);
  2301. };
  2302. };
  2303. const ServiceJSBridge = /* @__PURE__ */ extend(
  2304. /* @__PURE__ */ initBridge(
  2305. "view"
  2306. /* view 指的是 service 层订阅的是 view 层事件 */
  2307. ),
  2308. {
  2309. invokeOnCallback,
  2310. invokeViewMethod,
  2311. invokeViewMethodKeepAlive
  2312. }
  2313. );
  2314. function initOn() {
  2315. const { on: on2 } = UniServiceJSBridge;
  2316. on2(ON_RESIZE, onResize$1);
  2317. on2(ON_APP_ENTER_FOREGROUND, onAppEnterForeground);
  2318. on2(ON_APP_ENTER_BACKGROUND, onAppEnterBackground);
  2319. }
  2320. function onResize$1(res) {
  2321. invokeHook(getCurrentPage(), ON_RESIZE, res);
  2322. UniServiceJSBridge.invokeOnCallback("onWindowResize", res);
  2323. }
  2324. function onAppEnterForeground(enterOptions2) {
  2325. const page = getCurrentPage();
  2326. invokeHook(getApp(), ON_SHOW, enterOptions2);
  2327. invokeHook(page, ON_SHOW);
  2328. }
  2329. function onAppEnterBackground() {
  2330. invokeHook(getApp(), ON_HIDE);
  2331. invokeHook(getCurrentPage(), ON_HIDE);
  2332. }
  2333. const SUBSCRIBE_LIFECYCLE_HOOKS = [ON_PAGE_SCROLL, ON_REACH_BOTTOM];
  2334. function initSubscribe() {
  2335. SUBSCRIBE_LIFECYCLE_HOOKS.forEach(
  2336. (name) => UniServiceJSBridge.subscribe(name, createPageEvent(name))
  2337. );
  2338. }
  2339. function createPageEvent(name) {
  2340. return (args, pageId) => {
  2341. invokeHook(parseInt(pageId), name, args);
  2342. };
  2343. }
  2344. function initService() {
  2345. {
  2346. initOn();
  2347. initSubscribe();
  2348. }
  2349. }
  2350. function initAppVm(appVm2) {
  2351. appVm2.$vm = appVm2;
  2352. appVm2.$mpType = "app";
  2353. const locale = ref(useI18n().getLocale());
  2354. Object.defineProperty(appVm2, "$locale", {
  2355. get() {
  2356. return locale.value;
  2357. },
  2358. set(v2) {
  2359. locale.value = v2;
  2360. }
  2361. });
  2362. }
  2363. function initPageVm(pageVm, page) {
  2364. pageVm.route = page.route;
  2365. pageVm.$vm = pageVm;
  2366. pageVm.$page = page;
  2367. pageVm.$mpType = "page";
  2368. pageVm.$fontFamilySet = /* @__PURE__ */ new Set();
  2369. if (page.meta.isTabBar) {
  2370. pageVm.$.__isTabBar = true;
  2371. pageVm.$.__isActive = true;
  2372. }
  2373. }
  2374. function querySelector(vm, selector) {
  2375. const el = vm.$el.querySelector(selector);
  2376. return el && el.__vue__;
  2377. }
  2378. function querySelectorAll(vm, selector) {
  2379. const nodeList = vm.$el.querySelectorAll(selector);
  2380. if (nodeList) {
  2381. return [...nodeList].map((node) => node.__vue__).filter(Boolean);
  2382. }
  2383. return [];
  2384. }
  2385. function createSelectorQuery$1() {
  2386. return uni.createSelectorQuery().in(this);
  2387. }
  2388. function createMediaQueryObserver$1() {
  2389. return uni.createMediaQueryObserver(this);
  2390. }
  2391. function createIntersectionObserver$1(options) {
  2392. return uni.createIntersectionObserver(this, options);
  2393. }
  2394. function selectComponent(selector) {
  2395. return querySelector(this, selector);
  2396. }
  2397. function selectAllComponents(selector) {
  2398. return querySelectorAll(this, selector);
  2399. }
  2400. const wxInstance = /* @__PURE__ */ Object.defineProperty({
  2401. __proto__: null,
  2402. createIntersectionObserver: createIntersectionObserver$1,
  2403. createMediaQueryObserver: createMediaQueryObserver$1,
  2404. createSelectorQuery: createSelectorQuery$1,
  2405. selectAllComponents,
  2406. selectComponent
  2407. }, Symbol.toStringTag, { value: "Module" });
  2408. function getOpenerEventChannel() {
  2409. {
  2410. if (this.$route) {
  2411. const meta = this.$route.meta;
  2412. if (!meta.eventChannel) {
  2413. meta.eventChannel = new EventChannel(this.$page.id);
  2414. }
  2415. return meta.eventChannel;
  2416. }
  2417. }
  2418. }
  2419. function initAppConfig(appConfig) {
  2420. const globalProperties = appConfig.globalProperties;
  2421. globalProperties.getOpenerEventChannel = getOpenerEventChannel;
  2422. if (__UNI_FEATURE_WX__) {
  2423. extend(globalProperties, wxInstance);
  2424. }
  2425. }
  2426. function initServicePlugin(app) {
  2427. initAppConfig(app._context.config);
  2428. }
  2429. function createLaunchOptions() {
  2430. return {
  2431. path: "",
  2432. query: {},
  2433. scene: 1001,
  2434. referrerInfo: {
  2435. appId: "",
  2436. extraData: {}
  2437. }
  2438. };
  2439. }
  2440. function defineGlobalData(app, defaultGlobalData) {
  2441. const options = app.$options || {};
  2442. options.globalData = extend(options.globalData || {}, defaultGlobalData);
  2443. Object.defineProperty(app, "globalData", {
  2444. get() {
  2445. return options.globalData;
  2446. },
  2447. set(newGlobalData) {
  2448. options.globalData = newGlobalData;
  2449. }
  2450. });
  2451. }
  2452. function converPx(value) {
  2453. if (/^-?\d+[ur]px$/i.test(value)) {
  2454. return value.replace(/(^-?\d+)[ur]px$/i, (text2, num) => {
  2455. return `${uni.upx2px(parseFloat(num))}px`;
  2456. });
  2457. } else if (/^-?[\d\.]+$/.test(value)) {
  2458. return `${value}px`;
  2459. }
  2460. return value || "";
  2461. }
  2462. function converType(type) {
  2463. return type.replace(/[A-Z]/g, (text2) => {
  2464. return `-${text2.toLowerCase()}`;
  2465. }).replace("webkit", "-webkit");
  2466. }
  2467. function getStyle(action) {
  2468. const animateTypes1 = [
  2469. "matrix",
  2470. "matrix3d",
  2471. "scale",
  2472. "scale3d",
  2473. "rotate3d",
  2474. "skew",
  2475. "translate",
  2476. "translate3d"
  2477. ];
  2478. const animateTypes2 = [
  2479. "scaleX",
  2480. "scaleY",
  2481. "scaleZ",
  2482. "rotate",
  2483. "rotateX",
  2484. "rotateY",
  2485. "rotateZ",
  2486. "skewX",
  2487. "skewY",
  2488. "translateX",
  2489. "translateY",
  2490. "translateZ"
  2491. ];
  2492. const animateTypes3 = ["opacity", "background-color"];
  2493. const animateTypes4 = ["width", "height", "left", "right", "top", "bottom"];
  2494. const animates = action.animates;
  2495. const option = action.option;
  2496. const transition = option.transition;
  2497. const style = {};
  2498. const transform = [];
  2499. animates.forEach((animate) => {
  2500. let type = animate.type;
  2501. let args = [...animate.args];
  2502. if (animateTypes1.concat(animateTypes2).includes(type)) {
  2503. if (type.startsWith("rotate") || type.startsWith("skew")) {
  2504. args = args.map((value) => parseFloat(value) + "deg");
  2505. } else if (type.startsWith("translate")) {
  2506. args = args.map(converPx);
  2507. }
  2508. if (animateTypes2.indexOf(type) >= 0) {
  2509. args.length = 1;
  2510. }
  2511. transform.push(`${type}(${args.join(",")})`);
  2512. } else if (animateTypes3.concat(animateTypes4).includes(args[0])) {
  2513. type = args[0];
  2514. const value = args[1];
  2515. style[type] = animateTypes4.includes(type) ? converPx(value) : value;
  2516. }
  2517. });
  2518. style.transform = style.webkitTransform = transform.join(" ");
  2519. style.transition = style.webkitTransition = Object.keys(style).map(
  2520. (type) => `${converType(type)} ${transition.duration}ms ${transition.timingFunction} ${transition.delay}ms`
  2521. ).join(",");
  2522. style.transformOrigin = style.webkitTransformOrigin = option.transformOrigin;
  2523. return style;
  2524. }
  2525. function startAnimation(context) {
  2526. const animation2 = context.animation;
  2527. if (!animation2 || !animation2.actions || !animation2.actions.length) {
  2528. return;
  2529. }
  2530. let index2 = 0;
  2531. const actions = animation2.actions;
  2532. const length = animation2.actions.length;
  2533. function animate() {
  2534. const action = actions[index2];
  2535. const transition = action.option.transition;
  2536. const style = getStyle(action);
  2537. Object.keys(style).forEach((key) => {
  2538. context.$el.style[key] = style[key];
  2539. });
  2540. index2 += 1;
  2541. if (index2 < length) {
  2542. setTimeout(animate, transition.duration + transition.delay);
  2543. }
  2544. }
  2545. setTimeout(() => {
  2546. animate();
  2547. }, 0);
  2548. }
  2549. const animation = {
  2550. props: ["animation"],
  2551. watch: {
  2552. animation: {
  2553. deep: true,
  2554. handler() {
  2555. startAnimation(this);
  2556. }
  2557. }
  2558. },
  2559. mounted() {
  2560. startAnimation(this);
  2561. }
  2562. };
  2563. const defineBuiltInComponent = (options) => {
  2564. options.__reserved = true;
  2565. const { props: props2, mixins } = options;
  2566. if (!props2 || !props2.animation) {
  2567. (mixins || (options.mixins = [])).push(animation);
  2568. }
  2569. {
  2570. const rootElement = options.rootElement;
  2571. if (rootElement) {
  2572. customElements.define(
  2573. rootElement.name,
  2574. rootElement.class,
  2575. rootElement.options
  2576. );
  2577. }
  2578. }
  2579. return defineSystemComponent(options);
  2580. };
  2581. const defineSystemComponent = (options) => {
  2582. options.__reserved = true;
  2583. options.compatConfig = {
  2584. MODE: 3
  2585. // 标记为vue3
  2586. };
  2587. return defineComponent(options);
  2588. };
  2589. const defineUnsupportedComponent = (name) => {
  2590. return defineBuiltInComponent({
  2591. name: capitalize(camelize(name)),
  2592. setup() {
  2593. return () => (openBlock(), createElementBlock("uni-" + name, null, name + " is unsupported"));
  2594. }
  2595. });
  2596. };
  2597. function withWebEvent(fn) {
  2598. return fn.__wwe = true, fn;
  2599. }
  2600. function useCustomEvent(ref2, emit2) {
  2601. return (name, evt, detail) => {
  2602. if (ref2.value) {
  2603. emit2(name, normalizeCustomEvent(name, evt, ref2.value, detail || {}));
  2604. }
  2605. };
  2606. }
  2607. function normalizeCustomEvent(name, domEvt, el, detail) {
  2608. let target;
  2609. target = el;
  2610. return {
  2611. type: detail.type || name,
  2612. timeStamp: domEvt.timeStamp || 0,
  2613. target,
  2614. currentTarget: target,
  2615. detail
  2616. };
  2617. }
  2618. const hoverProps = {
  2619. hoverClass: {
  2620. type: String,
  2621. default: "none"
  2622. },
  2623. hoverStopPropagation: {
  2624. type: Boolean,
  2625. default: false
  2626. },
  2627. hoverStartTime: {
  2628. type: [Number, String],
  2629. default: 50
  2630. },
  2631. hoverStayTime: {
  2632. type: [Number, String],
  2633. default: 400
  2634. }
  2635. };
  2636. function useHover(props2) {
  2637. const hovering = ref(false);
  2638. let hoverTouch = false;
  2639. let hoverStartTimer;
  2640. let hoverStayTimer;
  2641. function hoverReset() {
  2642. requestAnimationFrame(() => {
  2643. clearTimeout(hoverStayTimer);
  2644. hoverStayTimer = setTimeout(() => {
  2645. hovering.value = false;
  2646. }, parseInt(props2.hoverStayTime));
  2647. });
  2648. }
  2649. function onTouchstartPassive(evt) {
  2650. if (evt.touches.length > 1) {
  2651. return;
  2652. }
  2653. handleHoverStart(evt);
  2654. }
  2655. function onMousedown(evt) {
  2656. if (hoverTouch) {
  2657. return;
  2658. }
  2659. handleHoverStart(evt);
  2660. window.addEventListener("mouseup", handlePCHoverEnd);
  2661. }
  2662. function handleHoverStart(evt) {
  2663. if (evt._hoverPropagationStopped) {
  2664. return;
  2665. }
  2666. if (!props2.hoverClass || props2.hoverClass === "none" || props2.disabled) {
  2667. return;
  2668. }
  2669. if (props2.hoverStopPropagation) {
  2670. evt._hoverPropagationStopped = true;
  2671. }
  2672. hoverTouch = true;
  2673. hoverStartTimer = setTimeout(() => {
  2674. hovering.value = true;
  2675. if (!hoverTouch) {
  2676. hoverReset();
  2677. }
  2678. }, parseInt(props2.hoverStartTime));
  2679. }
  2680. function onTouchend() {
  2681. handleHoverEnd();
  2682. }
  2683. function onMouseup() {
  2684. if (!hoverTouch) {
  2685. return;
  2686. }
  2687. handlePCHoverEnd();
  2688. }
  2689. function handleHoverEnd() {
  2690. hoverTouch = false;
  2691. if (hovering.value) {
  2692. hoverReset();
  2693. }
  2694. }
  2695. function handlePCHoverEnd() {
  2696. handleHoverEnd();
  2697. window.removeEventListener("mouseup", handlePCHoverEnd);
  2698. }
  2699. function onTouchcancel() {
  2700. hoverTouch = false;
  2701. hovering.value = false;
  2702. clearTimeout(hoverStartTimer);
  2703. }
  2704. return {
  2705. hovering,
  2706. binding: {
  2707. onTouchstartPassive: withWebEvent(onTouchstartPassive),
  2708. onMousedown: withWebEvent(onMousedown),
  2709. onTouchend: withWebEvent(onTouchend),
  2710. onMouseup: withWebEvent(onMouseup),
  2711. onTouchcancel: withWebEvent(onTouchcancel)
  2712. }
  2713. };
  2714. }
  2715. function useBooleanAttr(props2, keys) {
  2716. if (isString(keys)) {
  2717. keys = [keys];
  2718. }
  2719. return keys.reduce((res, key) => {
  2720. if (props2[key]) {
  2721. res[key] = true;
  2722. }
  2723. return res;
  2724. }, /* @__PURE__ */ Object.create(null));
  2725. }
  2726. function transformRpx(value) {
  2727. if (/(-?(?:\d+\.)?\d+)[ur]px/gi.test(value)) {
  2728. return value.replace(/(-?(?:\d+\.)?\d+)[ur]px/gi, (text2, num) => {
  2729. return `${uni.upx2px(parseFloat(num))}px`;
  2730. });
  2731. }
  2732. return value;
  2733. }
  2734. class UniElement extends HTMLElement {
  2735. constructor() {
  2736. super();
  2737. this._props = {};
  2738. this.__isUniElement = true;
  2739. }
  2740. attachVmProps(props2) {
  2741. this._props = props2;
  2742. }
  2743. getAttribute(qualifiedName) {
  2744. const name = camelize(qualifiedName);
  2745. return name in this._props ? this._props[name] + "" : super.getAttribute(qualifiedName) || null;
  2746. }
  2747. get style() {
  2748. const originalStyle = super.style;
  2749. if (originalStyle.__patchRpx__) {
  2750. return originalStyle;
  2751. }
  2752. originalStyle.__patchRpx__ = true;
  2753. const originalSetProperty = originalStyle.setProperty.bind(originalStyle);
  2754. super.style.setProperty = function(property, value, priority) {
  2755. return originalSetProperty(
  2756. property,
  2757. value ? transformRpx(value + "") : value,
  2758. priority || void 0
  2759. );
  2760. };
  2761. return super.style;
  2762. }
  2763. get tagName() {
  2764. return super.tagName.replace(/^UNI-/, "");
  2765. }
  2766. get nodeName() {
  2767. return super.nodeName.replace(/^UNI-/, "");
  2768. }
  2769. }
  2770. const uniFormKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniForm" : "uf");
  2771. class UniFormElement extends UniElement {
  2772. }
  2773. const index$y = /* @__PURE__ */ defineBuiltInComponent({
  2774. name: "Form",
  2775. emits: ["submit", "reset"],
  2776. rootElement: {
  2777. name: "uni-form",
  2778. class: UniFormElement
  2779. },
  2780. setup(_props, {
  2781. slots,
  2782. emit: emit2
  2783. }) {
  2784. const rootRef = ref(null);
  2785. provideForm(useCustomEvent(rootRef, emit2));
  2786. onMounted(() => {
  2787. const rootElement = rootRef.value;
  2788. rootElement.attachVmProps(_props);
  2789. });
  2790. return () => createVNode("uni-form", {
  2791. "ref": rootRef
  2792. }, [createVNode("span", null, [slots.default && slots.default()])], 512);
  2793. }
  2794. });
  2795. function provideForm(trigger) {
  2796. const fields2 = [];
  2797. provide(uniFormKey, {
  2798. addField(field) {
  2799. fields2.push(field);
  2800. },
  2801. removeField(field) {
  2802. fields2.splice(fields2.indexOf(field), 1);
  2803. },
  2804. submit(evt) {
  2805. trigger("submit", evt, {
  2806. value: fields2.reduce((res, field) => {
  2807. if (field.submit) {
  2808. const [name, value] = field.submit();
  2809. name && (res[name] = value);
  2810. }
  2811. return res;
  2812. }, /* @__PURE__ */ Object.create(null))
  2813. });
  2814. },
  2815. reset(evt) {
  2816. fields2.forEach((field) => field.reset && field.reset());
  2817. trigger("reset", evt);
  2818. }
  2819. });
  2820. return fields2;
  2821. }
  2822. const labelProps = {
  2823. for: {
  2824. type: String,
  2825. default: ""
  2826. }
  2827. };
  2828. const uniLabelKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniLabel" : "ul");
  2829. function useProvideLabel() {
  2830. const handlers = [];
  2831. provide(uniLabelKey, {
  2832. addHandler(handler) {
  2833. handlers.push(handler);
  2834. },
  2835. removeHandler(handler) {
  2836. handlers.splice(handlers.indexOf(handler), 1);
  2837. }
  2838. });
  2839. return handlers;
  2840. }
  2841. class UniLabelElement extends UniElement {
  2842. }
  2843. const index$x = /* @__PURE__ */ defineBuiltInComponent({
  2844. name: "Label",
  2845. props: labelProps,
  2846. rootElement: {
  2847. name: "uni-label",
  2848. class: UniLabelElement
  2849. },
  2850. setup(props2, {
  2851. slots
  2852. }) {
  2853. const rootRef = ref(null);
  2854. const pageId = useCurrentPageId();
  2855. const handlers = useProvideLabel();
  2856. const pointer = computed(() => props2.for || slots.default && slots.default.length);
  2857. const _onClick = withWebEvent(($event) => {
  2858. const EventTarget = $event.target;
  2859. let stopPropagation = /^uni-(checkbox|radio|switch)-/.test(EventTarget.className);
  2860. if (!stopPropagation) {
  2861. stopPropagation = /^uni-(checkbox|radio|switch|button)$|^(svg|path)$/i.test(EventTarget.tagName);
  2862. }
  2863. if (stopPropagation) {
  2864. return;
  2865. }
  2866. if (props2.for) {
  2867. UniViewJSBridge.emit("uni-label-click-" + pageId + "-" + props2.for, $event, true);
  2868. } else {
  2869. handlers.length && handlers[0]($event, true);
  2870. }
  2871. });
  2872. onMounted(() => {
  2873. const rootElement = rootRef.value;
  2874. rootElement.attachVmProps(props2);
  2875. });
  2876. return () => createVNode("uni-label", {
  2877. "ref": rootRef,
  2878. "class": {
  2879. "uni-label-pointer": pointer
  2880. },
  2881. "onClick": _onClick
  2882. }, [slots.default && slots.default()], 10, ["onClick"]);
  2883. }
  2884. });
  2885. function useListeners(props2, listeners2) {
  2886. _addListeners(props2.id, listeners2);
  2887. watch(
  2888. () => props2.id,
  2889. (newId, oldId) => {
  2890. _removeListeners(oldId, listeners2, true);
  2891. _addListeners(newId, listeners2, true);
  2892. }
  2893. );
  2894. onUnmounted(() => {
  2895. _removeListeners(props2.id, listeners2);
  2896. });
  2897. }
  2898. function _addListeners(id2, listeners2, watch2) {
  2899. const pageId = useCurrentPageId();
  2900. if (watch2 && !id2) {
  2901. return;
  2902. }
  2903. if (!isPlainObject$1(listeners2)) {
  2904. return;
  2905. }
  2906. Object.keys(listeners2).forEach((name) => {
  2907. if (watch2) {
  2908. if (name.indexOf("@") !== 0 && name.indexOf("uni-") !== 0) {
  2909. UniViewJSBridge.on(`uni-${name}-${pageId}-${id2}`, listeners2[name]);
  2910. }
  2911. } else {
  2912. if (name.indexOf("uni-") === 0) {
  2913. UniViewJSBridge.on(name, listeners2[name]);
  2914. } else if (id2) {
  2915. UniViewJSBridge.on(`uni-${name}-${pageId}-${id2}`, listeners2[name]);
  2916. }
  2917. }
  2918. });
  2919. }
  2920. function _removeListeners(id2, listeners2, watch2) {
  2921. const pageId = useCurrentPageId();
  2922. if (watch2 && !id2) {
  2923. return;
  2924. }
  2925. if (!isPlainObject$1(listeners2)) {
  2926. return;
  2927. }
  2928. Object.keys(listeners2).forEach((name) => {
  2929. if (watch2) {
  2930. if (name.indexOf("@") !== 0 && name.indexOf("uni-") !== 0) {
  2931. UniViewJSBridge.off(`uni-${name}-${pageId}-${id2}`, listeners2[name]);
  2932. }
  2933. } else {
  2934. if (name.indexOf("uni-") === 0) {
  2935. UniViewJSBridge.off(name, listeners2[name]);
  2936. } else if (id2) {
  2937. UniViewJSBridge.off(`uni-${name}-${pageId}-${id2}`, listeners2[name]);
  2938. }
  2939. }
  2940. });
  2941. }
  2942. const buttonProps = {
  2943. id: {
  2944. type: String,
  2945. default: ""
  2946. },
  2947. hoverClass: {
  2948. type: String,
  2949. default: "button-hover"
  2950. },
  2951. hoverStartTime: {
  2952. type: [Number, String],
  2953. default: 20
  2954. },
  2955. hoverStayTime: {
  2956. type: [Number, String],
  2957. default: 70
  2958. },
  2959. hoverStopPropagation: {
  2960. type: Boolean,
  2961. default: false
  2962. },
  2963. disabled: {
  2964. type: [Boolean, String],
  2965. default: false
  2966. },
  2967. formType: {
  2968. type: String,
  2969. default: ""
  2970. },
  2971. openType: {
  2972. type: String,
  2973. default: ""
  2974. },
  2975. loading: {
  2976. type: [Boolean, String],
  2977. default: false
  2978. },
  2979. plain: {
  2980. type: [Boolean, String],
  2981. default: false
  2982. }
  2983. };
  2984. class UniButtonElement extends UniElement {
  2985. }
  2986. const index$w = /* @__PURE__ */ defineBuiltInComponent({
  2987. name: "Button",
  2988. props: buttonProps,
  2989. rootElement: {
  2990. name: "uni-button",
  2991. class: UniButtonElement
  2992. },
  2993. setup(props2, {
  2994. slots
  2995. }) {
  2996. const rootRef = ref(null);
  2997. const uniForm = inject(uniFormKey, false);
  2998. const {
  2999. hovering,
  3000. binding
  3001. } = useHover(props2);
  3002. const onClick = withWebEvent((e2, isLabelClick) => {
  3003. if (props2.disabled) {
  3004. return e2.stopImmediatePropagation();
  3005. }
  3006. if (isLabelClick) {
  3007. rootRef.value.click();
  3008. }
  3009. const formType = props2.formType;
  3010. if (formType) {
  3011. if (!uniForm) {
  3012. return;
  3013. }
  3014. if (formType === "submit") {
  3015. uniForm.submit(e2);
  3016. } else if (formType === "reset") {
  3017. uniForm.reset(e2);
  3018. }
  3019. return;
  3020. }
  3021. });
  3022. const uniLabel = inject(uniLabelKey, false);
  3023. if (uniLabel) {
  3024. uniLabel.addHandler(onClick);
  3025. onBeforeUnmount(() => {
  3026. uniLabel.removeHandler(onClick);
  3027. });
  3028. }
  3029. useListeners(props2, {
  3030. "label-click": onClick
  3031. });
  3032. onMounted(() => {
  3033. const rootElement = rootRef.value;
  3034. rootElement.attachVmProps(props2);
  3035. });
  3036. return () => {
  3037. const hoverClass = props2.hoverClass;
  3038. const booleanAttrs = useBooleanAttr(props2, "disabled");
  3039. const loadingAttrs = useBooleanAttr(props2, "loading");
  3040. const plainAttrs = useBooleanAttr(props2, "plain");
  3041. const hasHoverClass = hoverClass && hoverClass !== "none";
  3042. return createVNode("uni-button", mergeProps({
  3043. "ref": rootRef,
  3044. "onClick": onClick,
  3045. "id": props2.id,
  3046. "class": hasHoverClass && hovering.value ? hoverClass : ""
  3047. }, hasHoverClass && binding, booleanAttrs, loadingAttrs, plainAttrs), [slots.default && slots.default()], 16, ["onClick", "id"]);
  3048. };
  3049. }
  3050. });
  3051. const props$y = {
  3052. disableScroll: {
  3053. type: [Boolean, String],
  3054. default: false
  3055. }
  3056. };
  3057. class UniCanvasElement extends UniElement {
  3058. get width() {
  3059. return this.querySelector("canvas").width;
  3060. }
  3061. set width(value) {
  3062. this.querySelector("canvas").width = value;
  3063. }
  3064. get height() {
  3065. return this.querySelector("canvas").height;
  3066. }
  3067. set height(value) {
  3068. this.querySelector("canvas").height = value;
  3069. }
  3070. getContext(contextId, options) {
  3071. return this.querySelector("canvas").getContext(contextId, options);
  3072. }
  3073. toBlob(...args) {
  3074. const c = this.querySelector("canvas");
  3075. return c.toBlob.apply(c, args);
  3076. }
  3077. toDataURL(type, encoderOptions) {
  3078. return this.querySelector("canvas").toDataURL(type, encoderOptions);
  3079. }
  3080. }
  3081. const indexX$4 = /* @__PURE__ */ defineBuiltInComponent({
  3082. inheritAttrs: true,
  3083. name: "Canvas",
  3084. compatConfig: {
  3085. MODE: 3
  3086. },
  3087. props: props$y,
  3088. rootElement: {
  3089. name: "uni-canvas",
  3090. class: UniCanvasElement
  3091. },
  3092. setup(props2, {}) {
  3093. const rootRef = ref(null);
  3094. const canvas = ref(null);
  3095. onMounted(() => {
  3096. const rootElement = rootRef.value;
  3097. rootElement.attachVmProps(props2);
  3098. });
  3099. return () => {
  3100. return createVNode("uni-canvas", {
  3101. "ref": rootRef
  3102. }, [createVNode("canvas", {
  3103. "ref": canvas,
  3104. "class": "uni-canvas-canvas"
  3105. }, null, 512)], 512);
  3106. };
  3107. }
  3108. });
  3109. const uniCheckGroupKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniCheckGroup" : "ucg");
  3110. const props$x = {
  3111. name: {
  3112. type: String,
  3113. default: ""
  3114. }
  3115. };
  3116. class UniCheckboxGroupElement extends UniElement {
  3117. }
  3118. const index$v = /* @__PURE__ */ defineBuiltInComponent({
  3119. name: "CheckboxGroup",
  3120. props: props$x,
  3121. emits: ["change"],
  3122. rootElement: {
  3123. name: "uni-checkbox-group",
  3124. class: UniCheckboxGroupElement
  3125. },
  3126. setup(props2, {
  3127. emit: emit2,
  3128. slots
  3129. }) {
  3130. const rootRef = ref(null);
  3131. const trigger = useCustomEvent(rootRef, emit2);
  3132. useProvideCheckGroup(props2, trigger);
  3133. onMounted(() => {
  3134. const rootElement = rootRef.value;
  3135. rootElement.attachVmProps(props2);
  3136. });
  3137. return () => {
  3138. return createVNode("uni-checkbox-group", {
  3139. "ref": rootRef
  3140. }, [slots.default && slots.default()], 512);
  3141. };
  3142. }
  3143. });
  3144. function useProvideCheckGroup(props2, trigger) {
  3145. const fields2 = [];
  3146. const getFieldsValue = () => fields2.reduce((res, field) => {
  3147. if (field.value.checkboxChecked) {
  3148. res.push(field.value.value + "");
  3149. }
  3150. return res;
  3151. }, new Array());
  3152. provide(uniCheckGroupKey, {
  3153. addField(field) {
  3154. fields2.push(field);
  3155. },
  3156. removeField(field) {
  3157. fields2.splice(fields2.indexOf(field), 1);
  3158. },
  3159. checkboxChange($event) {
  3160. trigger("change", $event, {
  3161. value: getFieldsValue()
  3162. });
  3163. }
  3164. });
  3165. const uniForm = inject(uniFormKey, false);
  3166. if (uniForm) {
  3167. uniForm.addField({
  3168. submit: () => {
  3169. let data = ["", null];
  3170. if (props2.name !== "") {
  3171. data[0] = props2.name;
  3172. data[1] = getFieldsValue();
  3173. }
  3174. return data;
  3175. }
  3176. });
  3177. }
  3178. return getFieldsValue;
  3179. }
  3180. const props$w = {
  3181. checked: {
  3182. type: [Boolean, String],
  3183. default: false
  3184. },
  3185. id: {
  3186. type: String,
  3187. default: ""
  3188. },
  3189. disabled: {
  3190. type: [Boolean, String],
  3191. default: false
  3192. },
  3193. value: {
  3194. type: String,
  3195. default: ""
  3196. },
  3197. color: {
  3198. type: String,
  3199. default: "#007aff"
  3200. },
  3201. backgroundColor: {
  3202. type: String,
  3203. default: ""
  3204. },
  3205. borderColor: {
  3206. type: String,
  3207. default: ""
  3208. },
  3209. activeBackgroundColor: {
  3210. type: String,
  3211. default: ""
  3212. },
  3213. activeBorderColor: {
  3214. type: String,
  3215. default: ""
  3216. },
  3217. iconColor: {
  3218. type: String,
  3219. default: ""
  3220. },
  3221. // 图标颜色,同color,优先级大于iconColor
  3222. foreColor: {
  3223. type: String,
  3224. default: ""
  3225. }
  3226. };
  3227. class UniCheckboxElement extends UniElement {
  3228. }
  3229. const index$u = /* @__PURE__ */ defineBuiltInComponent({
  3230. name: "Checkbox",
  3231. props: props$w,
  3232. rootElement: {
  3233. name: "uni-checkbox",
  3234. class: UniCheckboxElement
  3235. },
  3236. setup(props2, {
  3237. slots
  3238. }) {
  3239. const rootRef = ref(null);
  3240. const checkboxChecked = ref(props2.checked);
  3241. const checkboxCheckedBool = computed(() => {
  3242. return checkboxChecked.value === "true" || checkboxChecked.value === true;
  3243. });
  3244. const checkboxValue = ref(props2.value);
  3245. const initialCheckedValue = props2.checked;
  3246. function getCheckBoxStyle(checked) {
  3247. if (props2.disabled) {
  3248. return {
  3249. backgroundColor: "#E1E1E1",
  3250. borderColor: "#D1D1D1"
  3251. };
  3252. }
  3253. const style = {};
  3254. if (checked) {
  3255. if (props2.activeBorderColor)
  3256. style.borderColor = props2.activeBorderColor;
  3257. if (props2.activeBackgroundColor)
  3258. style.backgroundColor = props2.activeBackgroundColor;
  3259. } else {
  3260. if (props2.borderColor)
  3261. style.borderColor = props2.borderColor;
  3262. if (props2.backgroundColor)
  3263. style.backgroundColor = props2.backgroundColor;
  3264. }
  3265. return style;
  3266. }
  3267. const checkboxStyle = computed(() => {
  3268. return getCheckBoxStyle(checkboxCheckedBool.value);
  3269. });
  3270. watch([() => props2.checked, () => props2.value], ([newChecked, newModelValue]) => {
  3271. checkboxChecked.value = newChecked;
  3272. checkboxValue.value = newModelValue;
  3273. });
  3274. const reset = () => {
  3275. checkboxChecked.value = initialCheckedValue;
  3276. };
  3277. const {
  3278. uniCheckGroup,
  3279. uniLabel
  3280. } = useCheckboxInject(checkboxChecked, checkboxValue, reset);
  3281. const _onClick = ($event) => {
  3282. if (props2.disabled) {
  3283. return;
  3284. }
  3285. checkboxChecked.value = !checkboxChecked.value;
  3286. uniCheckGroup && uniCheckGroup.checkboxChange($event);
  3287. $event.stopPropagation();
  3288. };
  3289. if (!!uniLabel) {
  3290. uniLabel.addHandler(_onClick);
  3291. onBeforeUnmount(() => {
  3292. uniLabel.removeHandler(_onClick);
  3293. });
  3294. }
  3295. useListeners(props2, {
  3296. "label-click": _onClick
  3297. });
  3298. let checkedCache = ref(checkboxCheckedBool.value);
  3299. watch(() => checkboxCheckedBool.value, (newChecked) => {
  3300. checkedCache.value = newChecked;
  3301. });
  3302. onMounted(() => {
  3303. const rootElement = rootRef.value;
  3304. Object.defineProperty(rootElement, "checked", {
  3305. get() {
  3306. return checkedCache.value;
  3307. },
  3308. set(val) {
  3309. checkedCache.value = val;
  3310. const style = getCheckBoxStyle(val);
  3311. const checkboxInputElement = rootElement.querySelector(".uni-checkbox-input");
  3312. for (const key in style) {
  3313. const value = style[key];
  3314. value && checkboxInputElement.style.setProperty(key, value);
  3315. }
  3316. }
  3317. });
  3318. rootElement.attachVmProps(props2);
  3319. });
  3320. return () => {
  3321. const booleanAttrs = useBooleanAttr(props2, "disabled");
  3322. let realCheckValue;
  3323. realCheckValue = checkedCache.value;
  3324. return createVNode("uni-checkbox", mergeProps(booleanAttrs, {
  3325. "id": props2.id,
  3326. "onClick": _onClick,
  3327. "ref": rootRef
  3328. }), [createVNode("div", {
  3329. "class": "uni-checkbox-wrapper",
  3330. "style": {
  3331. "--HOVER-BD-COLOR": props2.activeBorderColor
  3332. }
  3333. }, [createVNode("div", {
  3334. "class": ["uni-checkbox-input", {
  3335. "uni-checkbox-input-disabled": props2.disabled
  3336. }],
  3337. "style": checkboxStyle.value
  3338. }, [realCheckValue ? createSvgIconVNode(ICON_PATH_SUCCESS_NO_CIRCLE, props2.disabled ? "#ADADAD" : props2.foreColor || props2.iconColor || props2.color, 22) : ""], 6), slots.default && slots.default()], 4)], 16, ["id", "onClick"]);
  3339. };
  3340. }
  3341. });
  3342. function useCheckboxInject(checkboxChecked, checkboxValue, reset) {
  3343. const field = computed(() => ({
  3344. checkboxChecked: Boolean(checkboxChecked.value),
  3345. value: checkboxValue.value
  3346. }));
  3347. const formField = {
  3348. reset
  3349. };
  3350. const uniCheckGroup = inject(uniCheckGroupKey, false);
  3351. if (!!uniCheckGroup) {
  3352. uniCheckGroup.addField(field);
  3353. }
  3354. const uniForm = inject(uniFormKey, false);
  3355. if (!!uniForm) {
  3356. uniForm.addField(formField);
  3357. }
  3358. const uniLabel = inject(uniLabelKey, false);
  3359. onBeforeUnmount(() => {
  3360. uniCheckGroup && uniCheckGroup.removeField(field);
  3361. uniForm && uniForm.removeField(formField);
  3362. });
  3363. return {
  3364. uniCheckGroup,
  3365. uniForm,
  3366. uniLabel
  3367. };
  3368. }
  3369. let resetTimer;
  3370. function iosHideKeyboard() {
  3371. }
  3372. const props$v = {
  3373. cursorSpacing: {
  3374. type: [Number, String],
  3375. default: 0
  3376. },
  3377. showConfirmBar: {
  3378. type: [Boolean, String],
  3379. default: "auto"
  3380. },
  3381. adjustPosition: {
  3382. type: [Boolean, String],
  3383. default: true
  3384. },
  3385. autoBlur: {
  3386. type: [Boolean, String],
  3387. default: false
  3388. }
  3389. };
  3390. const emit$1 = ["keyboardheightchange"];
  3391. function useKeyboard$1(props2, elRef, trigger) {
  3392. function initKeyboard(el) {
  3393. const isApple = computed(
  3394. () => String(navigator.vendor).indexOf("Apple") === 0
  3395. );
  3396. el.addEventListener("focus", () => {
  3397. clearTimeout(resetTimer);
  3398. document.addEventListener("click", iosHideKeyboard, false);
  3399. });
  3400. const onKeyboardHide = () => {
  3401. document.removeEventListener("click", iosHideKeyboard, false);
  3402. if (isApple.value) {
  3403. document.documentElement.scrollTo(
  3404. document.documentElement.scrollLeft,
  3405. document.documentElement.scrollTop
  3406. );
  3407. }
  3408. };
  3409. el.addEventListener("blur", () => {
  3410. if (isApple.value) {
  3411. el.blur();
  3412. }
  3413. onKeyboardHide();
  3414. });
  3415. }
  3416. watch(
  3417. () => elRef.value,
  3418. (el) => el && initKeyboard(el)
  3419. );
  3420. }
  3421. const TEMP_PATH = "";
  3422. function findElem(vm) {
  3423. return vm.$el;
  3424. }
  3425. function addBase(filePath) {
  3426. const { base: baseUrl } = __uniConfig.router;
  3427. if (addLeadingSlash(filePath).indexOf(baseUrl) === 0) {
  3428. return addLeadingSlash(filePath);
  3429. }
  3430. return baseUrl + filePath;
  3431. }
  3432. function getRealPath(filePath) {
  3433. const { base, assets } = __uniConfig.router;
  3434. if (base === "./") {
  3435. if (filePath.indexOf("./") === 0 && (filePath.includes("/static/") || filePath.indexOf("./" + (assets || "assets") + "/") === 0)) {
  3436. filePath = filePath.slice(1);
  3437. }
  3438. }
  3439. if (filePath.indexOf("/") === 0) {
  3440. if (filePath.indexOf("//") === 0) {
  3441. filePath = "https:" + filePath;
  3442. } else {
  3443. return addBase(filePath.slice(1));
  3444. }
  3445. }
  3446. if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath) || filePath.indexOf("blob:") === 0) {
  3447. return filePath;
  3448. }
  3449. {
  3450. if (process.env.NODE_ENV !== "production") {
  3451. if (!filePath.includes("/static/")) {
  3452. return filePath;
  3453. }
  3454. }
  3455. }
  3456. const pages = getCurrentPages();
  3457. if (pages.length) {
  3458. return addBase(
  3459. getRealRoute(pages[pages.length - 1].$page.route, filePath).slice(1)
  3460. );
  3461. }
  3462. return filePath;
  3463. }
  3464. const ua = navigator.userAgent;
  3465. const isAndroid = /* @__PURE__ */ /android/i.test(ua);
  3466. const isIOS$1 = /* @__PURE__ */ /iphone|ipad|ipod/i.test(ua);
  3467. const isWindows = /* @__PURE__ */ ua.match(/Windows NT ([\d|\d.\d]*)/i);
  3468. const isMac = /* @__PURE__ */ /Macintosh|Mac/i.test(ua);
  3469. const isLinux = /* @__PURE__ */ /Linux|X11/i.test(ua);
  3470. const isIPadOS = isMac && navigator.maxTouchPoints > 0;
  3471. function getScreenFix() {
  3472. return /^Apple/.test(navigator.vendor) && typeof window.orientation === "number";
  3473. }
  3474. function isLandscape(screenFix) {
  3475. return screenFix && Math.abs(window.orientation) === 90;
  3476. }
  3477. function getScreenWidth(screenFix, landscape) {
  3478. return screenFix ? Math[landscape ? "max" : "min"](screen.width, screen.height) : screen.width;
  3479. }
  3480. function getScreenHeight(screenFix, landscape) {
  3481. return screenFix ? Math[landscape ? "min" : "max"](screen.height, screen.width) : screen.height;
  3482. }
  3483. function getWindowWidth(screenWidth) {
  3484. return Math.min(
  3485. window.innerWidth,
  3486. document.documentElement.clientWidth,
  3487. screenWidth
  3488. ) || screenWidth;
  3489. }
  3490. function getBaseSystemInfo() {
  3491. const screenFix = getScreenFix();
  3492. const windowWidth = getWindowWidth(
  3493. getScreenWidth(screenFix, isLandscape(screenFix))
  3494. );
  3495. return {
  3496. platform: isIOS$1 ? "ios" : "other",
  3497. pixelRatio: window.devicePixelRatio,
  3498. windowWidth
  3499. };
  3500. }
  3501. function operateVideoPlayer(videoId, pageId, type, data) {
  3502. UniServiceJSBridge.invokeViewMethod(
  3503. "video." + videoId,
  3504. {
  3505. videoId,
  3506. type,
  3507. data
  3508. },
  3509. pageId
  3510. );
  3511. }
  3512. function operateMap(id2, pageId, type, data, operateMapCallback2) {
  3513. UniServiceJSBridge.invokeViewMethod(
  3514. "map." + id2,
  3515. {
  3516. type,
  3517. data
  3518. },
  3519. pageId,
  3520. operateMapCallback2
  3521. );
  3522. }
  3523. function getRootInfo(fields2) {
  3524. const info = {};
  3525. if (fields2.id) {
  3526. info.id = "";
  3527. }
  3528. if (fields2.dataset) {
  3529. info.dataset = {};
  3530. }
  3531. if (fields2.rect) {
  3532. info.left = 0;
  3533. info.right = 0;
  3534. info.top = 0;
  3535. info.bottom = 0;
  3536. }
  3537. if (fields2.size) {
  3538. info.width = document.documentElement.clientWidth;
  3539. info.height = document.documentElement.clientHeight;
  3540. }
  3541. if (fields2.scrollOffset) {
  3542. const documentElement2 = document.documentElement;
  3543. const body = document.body;
  3544. info.scrollLeft = documentElement2.scrollLeft || body.scrollLeft || 0;
  3545. info.scrollTop = documentElement2.scrollTop || body.scrollTop || 0;
  3546. info.scrollHeight = documentElement2.scrollHeight || body.scrollHeight || 0;
  3547. info.scrollWidth = documentElement2.scrollWidth || body.scrollWidth || 0;
  3548. }
  3549. return info;
  3550. }
  3551. function getNodeInfo(el, fields2) {
  3552. const info = {};
  3553. const { top, topWindowHeight } = getWindowOffset();
  3554. if (fields2.node) {
  3555. const tagName = el.tagName.replace("uni-", "");
  3556. if (tagName) {
  3557. info.node = el.querySelector(tagName);
  3558. }
  3559. }
  3560. if (fields2.id) {
  3561. info.id = el.id;
  3562. }
  3563. if (fields2.dataset) {
  3564. info.dataset = getCustomDataset(el);
  3565. }
  3566. if (fields2.rect || fields2.size) {
  3567. const rect = el.getBoundingClientRect();
  3568. if (fields2.rect) {
  3569. info.left = rect.left;
  3570. info.right = rect.right;
  3571. info.top = rect.top - top - topWindowHeight;
  3572. info.bottom = rect.bottom - top - topWindowHeight;
  3573. }
  3574. if (fields2.size) {
  3575. info.width = rect.width;
  3576. info.height = rect.height;
  3577. }
  3578. }
  3579. if (isArray(fields2.properties)) {
  3580. fields2.properties.forEach((prop) => {
  3581. prop = prop.replace(/-([a-z])/g, function(e2, t2) {
  3582. return t2.toUpperCase();
  3583. });
  3584. });
  3585. }
  3586. if (fields2.scrollOffset) {
  3587. if (el.tagName === "UNI-SCROLL-VIEW") {
  3588. const scroll = el.children[0].children[0];
  3589. info.scrollLeft = scroll.scrollLeft;
  3590. info.scrollTop = scroll.scrollTop;
  3591. info.scrollHeight = scroll.scrollHeight;
  3592. info.scrollWidth = scroll.scrollWidth;
  3593. } else {
  3594. info.scrollLeft = 0;
  3595. info.scrollTop = 0;
  3596. info.scrollHeight = 0;
  3597. info.scrollWidth = 0;
  3598. }
  3599. }
  3600. if (isArray(fields2.computedStyle)) {
  3601. const sytle = getComputedStyle(el);
  3602. fields2.computedStyle.forEach((name) => {
  3603. info[name] = sytle[name];
  3604. });
  3605. }
  3606. if (fields2.context) {
  3607. info.contextInfo = getContextInfo(el);
  3608. }
  3609. return info;
  3610. }
  3611. function findElm(component, pageVm) {
  3612. if (!component) {
  3613. return pageVm.$el;
  3614. }
  3615. return component.$el;
  3616. }
  3617. function matches(element, selectors) {
  3618. const matches2 = element.matches || element.matchesSelector || element.mozMatchesSelector || element.msMatchesSelector || element.oMatchesSelector || element.webkitMatchesSelector || function(selectors2) {
  3619. const matches3 = this.parentElement.querySelectorAll(
  3620. selectors2
  3621. );
  3622. let i = matches3.length;
  3623. while (--i >= 0 && matches3.item(i) !== this) {
  3624. }
  3625. return i > -1;
  3626. };
  3627. return matches2.call(element, selectors);
  3628. }
  3629. class QuerySelectorHelper {
  3630. constructor(element, vnode) {
  3631. this._element = element;
  3632. this._commentStartVNode = vnode;
  3633. }
  3634. static queryElement(element, selector, all, vnode) {
  3635. return new QuerySelectorHelper(element, vnode).query(selector, all);
  3636. }
  3637. query(selector, all) {
  3638. const isFragment = (
  3639. // @ts-expect-error
  3640. this._element.nodeType === 3 || this._element.nodeType === 8
  3641. );
  3642. if (isFragment) {
  3643. return this.queryFragment(this._element, selector, all);
  3644. } else {
  3645. return all ? this.querySelectorAll(this._element, selector) : this.querySelector(this._element, selector);
  3646. }
  3647. }
  3648. queryFragment(el, selector, all) {
  3649. let current = el.nextSibling;
  3650. if (current == null) {
  3651. return null;
  3652. }
  3653. let depth = 65535;
  3654. if (all) {
  3655. const result1 = [];
  3656. while (depth > 0) {
  3657. depth--;
  3658. if (current.nodeName && current.nodeName == "#comment") {
  3659. current = current.nextSibling;
  3660. continue;
  3661. }
  3662. const queryResult = this.querySelectorAll(current, selector);
  3663. if (queryResult != null) {
  3664. result1.push(...queryResult);
  3665. }
  3666. current = current.nextSibling;
  3667. if (current == null || this._commentStartVNode.anchor == current) {
  3668. break;
  3669. }
  3670. }
  3671. return result1;
  3672. } else {
  3673. let result2 = null;
  3674. while (depth > 0) {
  3675. depth--;
  3676. if (current.nodeName && current.nodeName == "#comment") {
  3677. current = current.nextSibling;
  3678. continue;
  3679. }
  3680. result2 = this.querySelector(current, selector);
  3681. current = current.nextSibling;
  3682. if (result2 != null || current == null || this._commentStartVNode.anchor == current) {
  3683. break;
  3684. }
  3685. }
  3686. return result2;
  3687. }
  3688. }
  3689. querySelector(element, selector) {
  3690. let element2 = this.querySelf(element, selector);
  3691. if (element2 == null) {
  3692. element2 = element.querySelector(selector);
  3693. }
  3694. if (element2 != null) {
  3695. return this.getNodeInfo(element2);
  3696. }
  3697. return null;
  3698. }
  3699. querySelectorAll(element, selector) {
  3700. const nodesInfoArray = [];
  3701. const element2 = this.querySelf(element, selector);
  3702. if (element2 != null) {
  3703. nodesInfoArray.push(this.getNodeInfo(element));
  3704. }
  3705. const findNodes = element.querySelectorAll(selector);
  3706. findNodes == null ? void 0 : findNodes.forEach((el) => {
  3707. nodesInfoArray.push(this.getNodeInfo(el));
  3708. });
  3709. return nodesInfoArray;
  3710. }
  3711. querySelf(element, selector) {
  3712. if (element == null || selector.length < 2) {
  3713. return null;
  3714. }
  3715. const selectorType2 = selector.charAt(0);
  3716. const selectorName = selector.slice(1);
  3717. if (selectorType2 == "." && element.classList.contains(selectorName)) {
  3718. return element;
  3719. }
  3720. if (selectorType2 == "#" && element.getAttribute("id") == selectorName) {
  3721. return element;
  3722. }
  3723. if (selector.toUpperCase() == element.nodeName.toUpperCase()) {
  3724. return element;
  3725. }
  3726. return null;
  3727. }
  3728. getNodeInfo(element) {
  3729. var _a;
  3730. const rect = element.getBoundingClientRect();
  3731. const nodeInfo = {
  3732. id: (_a = element.getAttribute("id")) == null ? void 0 : _a.toString(),
  3733. dataset: null,
  3734. left: rect.left,
  3735. top: rect.top,
  3736. right: rect.right,
  3737. bottom: rect.bottom,
  3738. width: rect.width,
  3739. height: rect.height
  3740. };
  3741. return nodeInfo;
  3742. }
  3743. }
  3744. function getNodesInfo(pageVm, component, selector, single, fields2) {
  3745. const selfElement = findElm(component, pageVm);
  3746. const parentElement = selfElement.parentElement;
  3747. if (!parentElement) {
  3748. return single ? null : [];
  3749. }
  3750. const { nodeType } = selfElement;
  3751. const maybeFragment = nodeType === 3 || nodeType === 8;
  3752. if (maybeFragment)
  3753. return QuerySelectorHelper.queryElement(
  3754. selfElement,
  3755. selector,
  3756. !single,
  3757. component == null ? void 0 : component.$.subTree
  3758. );
  3759. if (single) {
  3760. const node = maybeFragment ? parentElement.querySelector(selector) : matches(selfElement, selector) ? selfElement : selfElement.querySelector(selector);
  3761. if (node) {
  3762. return getNodeInfo(node, fields2);
  3763. }
  3764. return null;
  3765. } else {
  3766. let infos = [];
  3767. const nodeList = (maybeFragment ? parentElement : selfElement).querySelectorAll(selector);
  3768. if (nodeList && nodeList.length) {
  3769. [].forEach.call(nodeList, (node) => {
  3770. infos.push(getNodeInfo(node, fields2));
  3771. });
  3772. }
  3773. if (!maybeFragment && matches(selfElement, selector)) {
  3774. infos.unshift(getNodeInfo(selfElement, fields2));
  3775. }
  3776. return infos;
  3777. }
  3778. }
  3779. function requestComponentInfo(page, reqs, callback) {
  3780. const result = [];
  3781. reqs.forEach(({ component, selector, single, fields: fields2 }) => {
  3782. if (component === null) {
  3783. result.push(getRootInfo(fields2));
  3784. } else {
  3785. result.push(getNodesInfo(page, component, selector, single, fields2));
  3786. }
  3787. });
  3788. callback(result);
  3789. }
  3790. function setCurrentPageMeta(_page, { pageStyle, rootFontSize }) {
  3791. if (pageStyle) {
  3792. const pageElm = document.querySelector("uni-page-body") || document.body;
  3793. pageElm.setAttribute("style", pageStyle);
  3794. }
  3795. if (rootFontSize && document.documentElement.style.fontSize !== rootFontSize) {
  3796. document.documentElement.style.fontSize = rootFontSize;
  3797. }
  3798. }
  3799. var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  3800. var lookup = /* @__PURE__ */ function() {
  3801. const lookup2 = new Uint8Array(256);
  3802. for (var i = 0; i < chars.length; i++) {
  3803. lookup2[chars.charCodeAt(i)] = i;
  3804. }
  3805. return lookup2;
  3806. }();
  3807. function encode$1(arraybuffer) {
  3808. var bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = "";
  3809. for (i = 0; i < len; i += 3) {
  3810. base64 += chars[bytes[i] >> 2];
  3811. base64 += chars[(bytes[i] & 3) << 4 | bytes[i + 1] >> 4];
  3812. base64 += chars[(bytes[i + 1] & 15) << 2 | bytes[i + 2] >> 6];
  3813. base64 += chars[bytes[i + 2] & 63];
  3814. }
  3815. if (len % 3 === 2) {
  3816. base64 = base64.substring(0, base64.length - 1) + "=";
  3817. } else if (len % 3 === 1) {
  3818. base64 = base64.substring(0, base64.length - 2) + "==";
  3819. }
  3820. return base64;
  3821. }
  3822. function decode(base64) {
  3823. var bufferLength = base64.length * 0.75, len = base64.length, i, p2 = 0, encoded1, encoded2, encoded3, encoded4;
  3824. if (base64[base64.length - 1] === "=") {
  3825. bufferLength--;
  3826. if (base64[base64.length - 2] === "=") {
  3827. bufferLength--;
  3828. }
  3829. }
  3830. var arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);
  3831. for (i = 0; i < len; i += 4) {
  3832. encoded1 = lookup[base64.charCodeAt(i)];
  3833. encoded2 = lookup[base64.charCodeAt(i + 1)];
  3834. encoded3 = lookup[base64.charCodeAt(i + 2)];
  3835. encoded4 = lookup[base64.charCodeAt(i + 3)];
  3836. bytes[p2++] = encoded1 << 2 | encoded2 >> 4;
  3837. bytes[p2++] = (encoded2 & 15) << 4 | encoded3 >> 2;
  3838. bytes[p2++] = (encoded3 & 3) << 6 | encoded4 & 63;
  3839. }
  3840. return arraybuffer;
  3841. }
  3842. const CHOOSE_SIZE_TYPES = ["original", "compressed"];
  3843. const CHOOSE_SOURCE_TYPES = ["album", "camera"];
  3844. const HTTP_METHODS = [
  3845. "GET",
  3846. "OPTIONS",
  3847. "HEAD",
  3848. "POST",
  3849. "PUT",
  3850. "DELETE",
  3851. "TRACE",
  3852. "CONNECT",
  3853. "PATCH"
  3854. ];
  3855. function elemInArray(str, arr) {
  3856. if (!str || arr.indexOf(str) === -1) {
  3857. return arr[0];
  3858. }
  3859. return str;
  3860. }
  3861. function elemsInArray(strArr, optionalVal) {
  3862. if (!isArray(strArr) || strArr.length === 0 || strArr.find((val) => optionalVal.indexOf(val) === -1)) {
  3863. return optionalVal;
  3864. }
  3865. return strArr;
  3866. }
  3867. function validateProtocolFail(name, msg) {
  3868. console.warn(`${name}: ${msg}`);
  3869. }
  3870. function validateProtocol(name, data, protocol, onFail) {
  3871. if (!onFail) {
  3872. onFail = validateProtocolFail;
  3873. }
  3874. for (const key in protocol) {
  3875. const errMsg = validateProp(
  3876. key,
  3877. data[key],
  3878. protocol[key],
  3879. !hasOwn(data, key)
  3880. );
  3881. if (isString(errMsg)) {
  3882. onFail(name, errMsg);
  3883. }
  3884. }
  3885. }
  3886. function validateProtocols(name, args, protocol, onFail) {
  3887. if (!protocol) {
  3888. return;
  3889. }
  3890. if (!isArray(protocol)) {
  3891. return validateProtocol(
  3892. name,
  3893. args[0] || /* @__PURE__ */ Object.create(null),
  3894. protocol,
  3895. onFail
  3896. );
  3897. }
  3898. const len = protocol.length;
  3899. const argsLen = args.length;
  3900. for (let i = 0; i < len; i++) {
  3901. const opts = protocol[i];
  3902. const data = /* @__PURE__ */ Object.create(null);
  3903. if (argsLen > i) {
  3904. data[opts.name] = args[i];
  3905. }
  3906. validateProtocol(name, data, { [opts.name]: opts }, onFail);
  3907. }
  3908. }
  3909. function validateProp(name, value, prop, isAbsent) {
  3910. if (!isPlainObject$1(prop)) {
  3911. prop = { type: prop };
  3912. }
  3913. const { type, required, validator: validator2 } = prop;
  3914. if (required && isAbsent) {
  3915. return 'Missing required args: "' + name + '"';
  3916. }
  3917. if (value == null && !required) {
  3918. return;
  3919. }
  3920. if (type != null) {
  3921. let isValid = false;
  3922. const types = isArray(type) ? type : [type];
  3923. const expectedTypes = [];
  3924. for (let i = 0; i < types.length && !isValid; i++) {
  3925. const { valid, expectedType } = assertType(value, types[i]);
  3926. expectedTypes.push(expectedType || "");
  3927. isValid = valid;
  3928. }
  3929. if (!isValid) {
  3930. return getInvalidTypeMessage(name, value, expectedTypes);
  3931. }
  3932. }
  3933. if (validator2) {
  3934. return validator2(value);
  3935. }
  3936. }
  3937. const isSimpleType = /* @__PURE__ */ makeMap$1(
  3938. "String,Number,Boolean,Function,Symbol"
  3939. );
  3940. function assertType(value, type) {
  3941. let valid;
  3942. const expectedType = getType(type);
  3943. if (isSimpleType(expectedType)) {
  3944. const t2 = typeof value;
  3945. valid = t2 === expectedType.toLowerCase();
  3946. if (!valid && t2 === "object") {
  3947. valid = value instanceof type;
  3948. }
  3949. } else if (expectedType === "Object") {
  3950. valid = isObject(value);
  3951. } else if (expectedType === "Array") {
  3952. valid = isArray(value);
  3953. } else {
  3954. {
  3955. valid = value instanceof type;
  3956. }
  3957. }
  3958. return {
  3959. valid,
  3960. expectedType
  3961. };
  3962. }
  3963. function getInvalidTypeMessage(name, value, expectedTypes) {
  3964. let message = `Invalid args: type check failed for args "${name}". Expected ${expectedTypes.map(capitalize).join(", ")}`;
  3965. const expectedType = expectedTypes[0];
  3966. const receivedType = toRawType(value);
  3967. const expectedValue = styleValue(value, expectedType);
  3968. const receivedValue = styleValue(value, receivedType);
  3969. if (expectedTypes.length === 1 && isExplicable(expectedType) && !isBoolean(expectedType, receivedType)) {
  3970. message += ` with value ${expectedValue}`;
  3971. }
  3972. message += `, got ${receivedType} `;
  3973. if (isExplicable(receivedType)) {
  3974. message += `with value ${receivedValue}.`;
  3975. }
  3976. return message;
  3977. }
  3978. function getType(ctor) {
  3979. const match = ctor && ctor.toString().match(/^\s*function (\w+)/);
  3980. return match ? match[1] : "";
  3981. }
  3982. function styleValue(value, type) {
  3983. if (type === "String") {
  3984. return `"${value}"`;
  3985. } else if (type === "Number") {
  3986. return `${Number(value)}`;
  3987. } else {
  3988. return `${value}`;
  3989. }
  3990. }
  3991. function isExplicable(type) {
  3992. const explicitTypes = ["string", "number", "boolean"];
  3993. return explicitTypes.some((elem) => type.toLowerCase() === elem);
  3994. }
  3995. function isBoolean(...args) {
  3996. return args.some((elem) => elem.toLowerCase() === "boolean");
  3997. }
  3998. function tryCatch(fn) {
  3999. return function() {
  4000. try {
  4001. return fn.apply(fn, arguments);
  4002. } catch (e2) {
  4003. console.error(e2);
  4004. }
  4005. };
  4006. }
  4007. let invokeCallbackId = 1;
  4008. const invokeCallbacks = {};
  4009. function addInvokeCallback(id2, name, callback, keepAlive = false) {
  4010. invokeCallbacks[id2] = {
  4011. name,
  4012. keepAlive,
  4013. callback
  4014. };
  4015. return id2;
  4016. }
  4017. function invokeCallback(id2, res, extras) {
  4018. if (typeof id2 === "number") {
  4019. const opts = invokeCallbacks[id2];
  4020. if (opts) {
  4021. if (!opts.keepAlive) {
  4022. delete invokeCallbacks[id2];
  4023. }
  4024. return opts.callback(res, extras);
  4025. }
  4026. }
  4027. return res;
  4028. }
  4029. function findInvokeCallbackByName(name) {
  4030. for (const key in invokeCallbacks) {
  4031. if (invokeCallbacks[key].name === name) {
  4032. return true;
  4033. }
  4034. }
  4035. return false;
  4036. }
  4037. function removeKeepAliveApiCallback(name, callback) {
  4038. for (const key in invokeCallbacks) {
  4039. const item = invokeCallbacks[key];
  4040. if (item.callback === callback && item.name === name) {
  4041. delete invokeCallbacks[key];
  4042. }
  4043. }
  4044. }
  4045. function offKeepAliveApiCallback(name) {
  4046. UniServiceJSBridge.off("api." + name);
  4047. }
  4048. function onKeepAliveApiCallback(name) {
  4049. UniServiceJSBridge.on("api." + name, (res) => {
  4050. for (const key in invokeCallbacks) {
  4051. const opts = invokeCallbacks[key];
  4052. if (opts.name === name) {
  4053. opts.callback(res);
  4054. }
  4055. }
  4056. });
  4057. }
  4058. function createKeepAliveApiCallback(name, callback) {
  4059. return addInvokeCallback(invokeCallbackId++, name, callback, true);
  4060. }
  4061. const API_SUCCESS = "success";
  4062. const API_FAIL = "fail";
  4063. const API_COMPLETE = "complete";
  4064. function getApiCallbacks(args) {
  4065. const apiCallbacks = {};
  4066. for (const name in args) {
  4067. const fn = args[name];
  4068. if (isFunction(fn)) {
  4069. apiCallbacks[name] = tryCatch(fn);
  4070. delete args[name];
  4071. }
  4072. }
  4073. return apiCallbacks;
  4074. }
  4075. function normalizeErrMsg(errMsg, name) {
  4076. if (!errMsg || errMsg.indexOf(":fail") === -1) {
  4077. return name + ":ok";
  4078. }
  4079. return name + errMsg.substring(errMsg.indexOf(":fail"));
  4080. }
  4081. function createAsyncApiCallback(name, args = {}, { beforeAll, beforeSuccess } = {}) {
  4082. if (!isPlainObject$1(args)) {
  4083. args = {};
  4084. }
  4085. const { success, fail, complete } = getApiCallbacks(args);
  4086. const hasSuccess = isFunction(success);
  4087. const hasFail = isFunction(fail);
  4088. const hasComplete = isFunction(complete);
  4089. const callbackId = invokeCallbackId++;
  4090. addInvokeCallback(callbackId, name, (res) => {
  4091. res = res || {};
  4092. res.errMsg = normalizeErrMsg(res.errMsg, name);
  4093. isFunction(beforeAll) && beforeAll(res);
  4094. if (res.errMsg === name + ":ok") {
  4095. isFunction(beforeSuccess) && beforeSuccess(res, args);
  4096. hasSuccess && success(res);
  4097. } else {
  4098. hasFail && fail(res);
  4099. }
  4100. hasComplete && complete(res);
  4101. });
  4102. return callbackId;
  4103. }
  4104. const HOOK_SUCCESS = "success";
  4105. const HOOK_FAIL = "fail";
  4106. const HOOK_COMPLETE = "complete";
  4107. const globalInterceptors = {};
  4108. const scopedInterceptors = {};
  4109. function wrapperHook(hook, params) {
  4110. return function(data) {
  4111. return hook(data, params) || data;
  4112. };
  4113. }
  4114. function queue(hooks, data, params) {
  4115. let promise = false;
  4116. for (let i = 0; i < hooks.length; i++) {
  4117. const hook = hooks[i];
  4118. if (promise) {
  4119. promise = Promise.resolve(wrapperHook(hook, params));
  4120. } else {
  4121. const res = hook(data, params);
  4122. if (isPromise(res)) {
  4123. promise = Promise.resolve(res);
  4124. }
  4125. if (res === false) {
  4126. return {
  4127. then() {
  4128. },
  4129. catch() {
  4130. }
  4131. };
  4132. }
  4133. }
  4134. }
  4135. return promise || {
  4136. then(callback) {
  4137. return callback(data);
  4138. },
  4139. catch() {
  4140. }
  4141. };
  4142. }
  4143. function wrapperOptions(interceptors2, options = {}) {
  4144. [HOOK_SUCCESS, HOOK_FAIL, HOOK_COMPLETE].forEach((name) => {
  4145. const hooks = interceptors2[name];
  4146. if (!isArray(hooks)) {
  4147. return;
  4148. }
  4149. const oldCallback = options[name];
  4150. options[name] = function callbackInterceptor(res) {
  4151. queue(hooks, res, options).then((res2) => {
  4152. return isFunction(oldCallback) && oldCallback(res2) || res2;
  4153. });
  4154. };
  4155. });
  4156. return options;
  4157. }
  4158. function wrapperReturnValue(method, returnValue) {
  4159. const returnValueHooks = [];
  4160. if (isArray(globalInterceptors.returnValue)) {
  4161. returnValueHooks.push(...globalInterceptors.returnValue);
  4162. }
  4163. const interceptor = scopedInterceptors[method];
  4164. if (interceptor && isArray(interceptor.returnValue)) {
  4165. returnValueHooks.push(...interceptor.returnValue);
  4166. }
  4167. returnValueHooks.forEach((hook) => {
  4168. returnValue = hook(returnValue) || returnValue;
  4169. });
  4170. return returnValue;
  4171. }
  4172. function getApiInterceptorHooks(method) {
  4173. const interceptor = /* @__PURE__ */ Object.create(null);
  4174. Object.keys(globalInterceptors).forEach((hook) => {
  4175. if (hook !== "returnValue") {
  4176. interceptor[hook] = globalInterceptors[hook].slice();
  4177. }
  4178. });
  4179. const scopedInterceptor = scopedInterceptors[method];
  4180. if (scopedInterceptor) {
  4181. Object.keys(scopedInterceptor).forEach((hook) => {
  4182. if (hook !== "returnValue") {
  4183. interceptor[hook] = (interceptor[hook] || []).concat(
  4184. scopedInterceptor[hook]
  4185. );
  4186. }
  4187. });
  4188. }
  4189. return interceptor;
  4190. }
  4191. function invokeApi(method, api2, options, params) {
  4192. const interceptor = getApiInterceptorHooks(method);
  4193. if (interceptor && Object.keys(interceptor).length) {
  4194. if (isArray(interceptor.invoke)) {
  4195. const res = queue(interceptor.invoke, options);
  4196. return res.then((options2) => {
  4197. return api2(
  4198. wrapperOptions(getApiInterceptorHooks(method), options2),
  4199. ...params
  4200. );
  4201. });
  4202. } else {
  4203. return api2(wrapperOptions(interceptor, options), ...params);
  4204. }
  4205. }
  4206. return api2(options, ...params);
  4207. }
  4208. function hasCallback(args) {
  4209. if (isPlainObject$1(args) && [API_SUCCESS, API_FAIL, API_COMPLETE].find(
  4210. (cb) => isFunction(args[cb])
  4211. )) {
  4212. return true;
  4213. }
  4214. return false;
  4215. }
  4216. function handlePromise(promise) {
  4217. return promise;
  4218. }
  4219. function promisify(name, fn) {
  4220. return (args = {}, ...rest) => {
  4221. if (hasCallback(args)) {
  4222. return wrapperReturnValue(name, invokeApi(name, fn, args, rest));
  4223. }
  4224. return wrapperReturnValue(
  4225. name,
  4226. handlePromise(
  4227. new Promise((resolve, reject) => {
  4228. invokeApi(
  4229. name,
  4230. fn,
  4231. extend(args, { success: resolve, fail: reject }),
  4232. rest
  4233. );
  4234. })
  4235. )
  4236. );
  4237. };
  4238. }
  4239. function formatApiArgs(args, options) {
  4240. const params = args[0];
  4241. if (!options || !options.formatArgs || !isPlainObject$1(options.formatArgs) && isPlainObject$1(params)) {
  4242. return;
  4243. }
  4244. const formatArgs = options.formatArgs;
  4245. const keys = Object.keys(formatArgs);
  4246. for (let i = 0; i < keys.length; i++) {
  4247. const name = keys[i];
  4248. const formatterOrDefaultValue = formatArgs[name];
  4249. if (isFunction(formatterOrDefaultValue)) {
  4250. const errMsg = formatterOrDefaultValue(args[0][name], params);
  4251. if (isString(errMsg)) {
  4252. return errMsg;
  4253. }
  4254. } else {
  4255. if (!hasOwn(params, name)) {
  4256. params[name] = formatterOrDefaultValue;
  4257. }
  4258. }
  4259. }
  4260. }
  4261. function invokeSuccess(id2, name, res) {
  4262. const result = {
  4263. errMsg: name + ":ok"
  4264. };
  4265. result.errSubject = name;
  4266. return invokeCallback(id2, extend(res || {}, result));
  4267. }
  4268. function invokeFail(id2, name, errMsg, errRes = {}) {
  4269. const apiErrMsg = name + ":fail" + (errMsg ? " " + errMsg : "");
  4270. let res = extend({ errMsg: apiErrMsg }, errRes);
  4271. if (typeof UniError !== "undefined") {
  4272. res = typeof errRes.errCode !== "undefined" ? new UniError(name, errRes.errCode, apiErrMsg) : new UniError(apiErrMsg, errRes);
  4273. }
  4274. return invokeCallback(id2, res);
  4275. }
  4276. function beforeInvokeApi(name, args, protocol, options) {
  4277. if (process.env.NODE_ENV !== "production") {
  4278. validateProtocols(name, args, protocol);
  4279. }
  4280. if (options && options.beforeInvoke) {
  4281. const errMsg2 = options.beforeInvoke(args);
  4282. if (isString(errMsg2)) {
  4283. return errMsg2;
  4284. }
  4285. }
  4286. const errMsg = formatApiArgs(args, options);
  4287. if (errMsg) {
  4288. return errMsg;
  4289. }
  4290. }
  4291. function checkCallback(callback) {
  4292. if (!isFunction(callback)) {
  4293. throw new Error(
  4294. 'Invalid args: type check failed for args "callback". Expected Function'
  4295. );
  4296. }
  4297. }
  4298. function wrapperOnApi(name, fn, options) {
  4299. return (callback) => {
  4300. checkCallback(callback);
  4301. const errMsg = beforeInvokeApi(name, [callback], void 0, options);
  4302. if (errMsg) {
  4303. throw new Error(errMsg);
  4304. }
  4305. const isFirstInvokeOnApi = !findInvokeCallbackByName(name);
  4306. createKeepAliveApiCallback(name, callback);
  4307. if (isFirstInvokeOnApi) {
  4308. onKeepAliveApiCallback(name);
  4309. fn();
  4310. }
  4311. };
  4312. }
  4313. function wrapperOffApi(name, fn, options) {
  4314. return (callback) => {
  4315. checkCallback(callback);
  4316. const errMsg = beforeInvokeApi(name, [callback], void 0, options);
  4317. if (errMsg) {
  4318. throw new Error(errMsg);
  4319. }
  4320. name = name.replace("off", "on");
  4321. removeKeepAliveApiCallback(name, callback);
  4322. const hasInvokeOnApi = findInvokeCallbackByName(name);
  4323. if (!hasInvokeOnApi) {
  4324. offKeepAliveApiCallback(name);
  4325. fn();
  4326. }
  4327. };
  4328. }
  4329. function parseErrMsg(errMsg) {
  4330. if (!errMsg || isString(errMsg)) {
  4331. return errMsg;
  4332. }
  4333. if (errMsg.stack) {
  4334. console.error(errMsg.message + "\n" + errMsg.stack);
  4335. return errMsg.message;
  4336. }
  4337. return errMsg;
  4338. }
  4339. function wrapperTaskApi(name, fn, protocol, options) {
  4340. return (args) => {
  4341. const id2 = createAsyncApiCallback(name, args, options);
  4342. const errMsg = beforeInvokeApi(name, [args], protocol, options);
  4343. if (errMsg) {
  4344. return invokeFail(id2, name, errMsg);
  4345. }
  4346. return fn(args, {
  4347. resolve: (res) => invokeSuccess(id2, name, res),
  4348. reject: (errMsg2, errRes) => invokeFail(id2, name, parseErrMsg(errMsg2), errRes)
  4349. });
  4350. };
  4351. }
  4352. function wrapperSyncApi(name, fn, protocol, options) {
  4353. return (...args) => {
  4354. const errMsg = beforeInvokeApi(name, args, protocol, options);
  4355. if (errMsg) {
  4356. throw new Error(errMsg);
  4357. }
  4358. return fn.apply(null, args);
  4359. };
  4360. }
  4361. function wrapperAsyncApi(name, fn, protocol, options) {
  4362. return wrapperTaskApi(name, fn, protocol, options);
  4363. }
  4364. function defineOnApi(name, fn, options) {
  4365. return wrapperOnApi(name, fn, options);
  4366. }
  4367. function defineOffApi(name, fn, options) {
  4368. return wrapperOffApi(name, fn, options);
  4369. }
  4370. function defineTaskApi(name, fn, protocol, options) {
  4371. return promisify(
  4372. name,
  4373. wrapperTaskApi(name, fn, process.env.NODE_ENV !== "production" ? protocol : void 0, options)
  4374. );
  4375. }
  4376. function defineSyncApi(name, fn, protocol, options) {
  4377. return wrapperSyncApi(
  4378. name,
  4379. fn,
  4380. process.env.NODE_ENV !== "production" ? protocol : void 0,
  4381. options
  4382. );
  4383. }
  4384. function defineAsyncApi(name, fn, protocol, options) {
  4385. return promisify(
  4386. name,
  4387. wrapperAsyncApi(name, fn, process.env.NODE_ENV !== "production" ? protocol : void 0, options)
  4388. );
  4389. }
  4390. function createUnsupportedMsg(name) {
  4391. return `method 'uni.${name}' not supported`;
  4392. }
  4393. function createUnsupportedSyncApi(name) {
  4394. return () => {
  4395. console.error(createUnsupportedMsg(name));
  4396. };
  4397. }
  4398. const createUnsupportedOnApi = createUnsupportedSyncApi;
  4399. function createUnsupportedAsyncApi(name) {
  4400. return (_args, { reject }) => {
  4401. return reject(createUnsupportedMsg(name));
  4402. };
  4403. }
  4404. const API_BASE64_TO_ARRAY_BUFFER = "base64ToArrayBuffer";
  4405. const Base64ToArrayBufferProtocol = [
  4406. {
  4407. name: "base64",
  4408. type: String,
  4409. required: true
  4410. }
  4411. ];
  4412. const API_ARRAY_BUFFER_TO_BASE64 = "arrayBufferToBase64";
  4413. const ArrayBufferToBase64Protocol = [
  4414. {
  4415. name: "arrayBuffer",
  4416. type: [ArrayBuffer, Uint8Array],
  4417. required: true
  4418. }
  4419. ];
  4420. const base64ToArrayBuffer = /* @__PURE__ */ defineSyncApi(
  4421. API_BASE64_TO_ARRAY_BUFFER,
  4422. (base64) => {
  4423. return decode(base64);
  4424. },
  4425. Base64ToArrayBufferProtocol
  4426. );
  4427. const arrayBufferToBase64 = /* @__PURE__ */ defineSyncApi(
  4428. API_ARRAY_BUFFER_TO_BASE64,
  4429. (arrayBuffer) => {
  4430. return encode$1(arrayBuffer);
  4431. },
  4432. ArrayBufferToBase64Protocol
  4433. );
  4434. const API_UPX2PX = "upx2px";
  4435. const Upx2pxProtocol = [
  4436. {
  4437. name: "upx",
  4438. type: [Number, String],
  4439. required: true
  4440. }
  4441. ];
  4442. const EPS = 1e-4;
  4443. const BASE_DEVICE_WIDTH = 750;
  4444. let isIOS = false;
  4445. let deviceWidth = 0;
  4446. let deviceDPR = 0;
  4447. let maxWidth = 960;
  4448. let baseWidth = 375;
  4449. let includeWidth = 750;
  4450. function checkDeviceWidth() {
  4451. const { platform, pixelRatio, windowWidth } = getBaseSystemInfo();
  4452. deviceWidth = windowWidth;
  4453. deviceDPR = pixelRatio;
  4454. isIOS = platform === "ios";
  4455. }
  4456. function checkValue(value, defaultValue) {
  4457. const newValue = Number(value);
  4458. return isNaN(newValue) ? defaultValue : newValue;
  4459. }
  4460. function checkMaxWidth() {
  4461. const config = __uniConfig.globalStyle || {};
  4462. maxWidth = checkValue(config.rpxCalcMaxDeviceWidth, 960);
  4463. baseWidth = checkValue(config.rpxCalcBaseDeviceWidth, 375);
  4464. includeWidth = checkValue(config.rpxCalcBaseDeviceWidth, 750);
  4465. }
  4466. const upx2px = /* @__PURE__ */ defineSyncApi(
  4467. API_UPX2PX,
  4468. (number, newDeviceWidth) => {
  4469. if (deviceWidth === 0) {
  4470. checkDeviceWidth();
  4471. {
  4472. checkMaxWidth();
  4473. }
  4474. }
  4475. number = Number(number);
  4476. if (number === 0) {
  4477. return 0;
  4478. }
  4479. let width = newDeviceWidth || deviceWidth;
  4480. {
  4481. width = number === includeWidth || width <= maxWidth ? width : baseWidth;
  4482. }
  4483. let result = number / BASE_DEVICE_WIDTH * width;
  4484. if (result < 0) {
  4485. result = -result;
  4486. }
  4487. result = Math.floor(result + EPS);
  4488. if (result === 0) {
  4489. if (deviceDPR === 1 || !isIOS) {
  4490. result = 1;
  4491. } else {
  4492. result = 0.5;
  4493. }
  4494. }
  4495. return number < 0 ? -result : result;
  4496. },
  4497. Upx2pxProtocol
  4498. );
  4499. const API_ADD_INTERCEPTOR = "addInterceptor";
  4500. const API_REMOVE_INTERCEPTOR = "removeInterceptor";
  4501. const AddInterceptorProtocol = [
  4502. {
  4503. name: "method",
  4504. type: [String, Object],
  4505. required: true
  4506. }
  4507. ];
  4508. const RemoveInterceptorProtocol = AddInterceptorProtocol;
  4509. function mergeInterceptorHook(interceptors2, interceptor) {
  4510. Object.keys(interceptor).forEach((hook) => {
  4511. if (isFunction(interceptor[hook])) {
  4512. interceptors2[hook] = mergeHook(
  4513. interceptors2[hook],
  4514. interceptor[hook]
  4515. );
  4516. }
  4517. });
  4518. }
  4519. function removeInterceptorHook(interceptors2, interceptor) {
  4520. if (!interceptors2 || !interceptor) {
  4521. return;
  4522. }
  4523. Object.keys(interceptor).forEach((name) => {
  4524. const hooks = interceptors2[name];
  4525. const hook = interceptor[name];
  4526. if (isArray(hooks) && isFunction(hook)) {
  4527. remove(hooks, hook);
  4528. }
  4529. });
  4530. }
  4531. function mergeHook(parentVal, childVal) {
  4532. const res = childVal ? parentVal ? parentVal.concat(childVal) : isArray(childVal) ? childVal : [childVal] : parentVal;
  4533. return res ? dedupeHooks(res) : res;
  4534. }
  4535. function dedupeHooks(hooks) {
  4536. const res = [];
  4537. for (let i = 0; i < hooks.length; i++) {
  4538. if (res.indexOf(hooks[i]) === -1) {
  4539. res.push(hooks[i]);
  4540. }
  4541. }
  4542. return res;
  4543. }
  4544. const addInterceptor = /* @__PURE__ */ defineSyncApi(
  4545. API_ADD_INTERCEPTOR,
  4546. (method, interceptor) => {
  4547. if (isString(method) && isPlainObject$1(interceptor)) {
  4548. mergeInterceptorHook(
  4549. scopedInterceptors[method] || (scopedInterceptors[method] = {}),
  4550. interceptor
  4551. );
  4552. } else if (isPlainObject$1(method)) {
  4553. mergeInterceptorHook(globalInterceptors, method);
  4554. }
  4555. },
  4556. AddInterceptorProtocol
  4557. );
  4558. const removeInterceptor = /* @__PURE__ */ defineSyncApi(
  4559. API_REMOVE_INTERCEPTOR,
  4560. (method, interceptor) => {
  4561. if (isString(method)) {
  4562. if (isPlainObject$1(interceptor)) {
  4563. removeInterceptorHook(scopedInterceptors[method], interceptor);
  4564. } else {
  4565. delete scopedInterceptors[method];
  4566. }
  4567. } else if (isPlainObject$1(method)) {
  4568. removeInterceptorHook(globalInterceptors, method);
  4569. }
  4570. },
  4571. RemoveInterceptorProtocol
  4572. );
  4573. const interceptors = {};
  4574. const API_ON = "$on";
  4575. const OnProtocol = [
  4576. {
  4577. name: "event",
  4578. type: String,
  4579. required: true
  4580. },
  4581. {
  4582. name: "callback",
  4583. type: Function,
  4584. required: true
  4585. }
  4586. ];
  4587. const API_ONCE = "$once";
  4588. const OnceProtocol = OnProtocol;
  4589. const API_OFF = "$off";
  4590. const OffProtocol = [
  4591. {
  4592. name: "event",
  4593. type: [String, Array]
  4594. },
  4595. {
  4596. name: "callback",
  4597. type: Function
  4598. }
  4599. ];
  4600. const API_EMIT = "$emit";
  4601. const EmitProtocol = [
  4602. {
  4603. name: "event",
  4604. type: String,
  4605. required: true
  4606. }
  4607. ];
  4608. const emitter = new Emitter();
  4609. const $on = /* @__PURE__ */ defineSyncApi(
  4610. API_ON,
  4611. (name, callback) => {
  4612. emitter.on(name, callback);
  4613. return () => emitter.off(name, callback);
  4614. },
  4615. OnProtocol
  4616. );
  4617. const $once = /* @__PURE__ */ defineSyncApi(
  4618. API_ONCE,
  4619. (name, callback) => {
  4620. emitter.once(name, callback);
  4621. return () => emitter.off(name, callback);
  4622. },
  4623. OnceProtocol
  4624. );
  4625. const $off = /* @__PURE__ */ defineSyncApi(
  4626. API_OFF,
  4627. (name, callback) => {
  4628. if (!name) {
  4629. emitter.e = {};
  4630. return;
  4631. }
  4632. if (!isArray(name))
  4633. name = [name];
  4634. name.forEach((n) => emitter.off(n, callback));
  4635. },
  4636. OffProtocol
  4637. );
  4638. const $emit = /* @__PURE__ */ defineSyncApi(
  4639. API_EMIT,
  4640. (name, ...args) => {
  4641. emitter.emit(name, ...args);
  4642. },
  4643. EmitProtocol
  4644. );
  4645. const validator = [
  4646. {
  4647. name: "id",
  4648. type: String,
  4649. required: true
  4650. }
  4651. ];
  4652. const API_CREATE_VIDEO_CONTEXT = "createVideoContext";
  4653. const API_CREATE_MAP_CONTEXT = "createMapContext";
  4654. const CreateMapContextProtocol = validator;
  4655. const API_CREATE_CANVAS_CONTEXT = "createCanvasContext";
  4656. const CreateCanvasContextProtocol = [
  4657. {
  4658. name: "canvasId",
  4659. type: String,
  4660. required: true
  4661. },
  4662. {
  4663. name: "componentInstance",
  4664. type: Object
  4665. }
  4666. ];
  4667. const API_CREATE_INNER_AUDIO_CONTEXT = "createInnerAudioContext";
  4668. validator.concat({
  4669. name: "componentInstance",
  4670. type: Object
  4671. });
  4672. const RATES = [0.5, 0.8, 1, 1.25, 1.5, 2];
  4673. class VideoContext {
  4674. constructor(id2, pageId) {
  4675. this.id = id2;
  4676. this.pageId = pageId;
  4677. }
  4678. play() {
  4679. operateVideoPlayer(this.id, this.pageId, "play");
  4680. }
  4681. pause() {
  4682. operateVideoPlayer(this.id, this.pageId, "pause");
  4683. }
  4684. stop() {
  4685. operateVideoPlayer(this.id, this.pageId, "stop");
  4686. }
  4687. seek(position) {
  4688. operateVideoPlayer(this.id, this.pageId, "seek", {
  4689. position
  4690. });
  4691. }
  4692. sendDanmu(args) {
  4693. operateVideoPlayer(this.id, this.pageId, "sendDanmu", args);
  4694. }
  4695. playbackRate(rate) {
  4696. if (!~RATES.indexOf(rate)) {
  4697. rate = 1;
  4698. }
  4699. operateVideoPlayer(this.id, this.pageId, "playbackRate", {
  4700. rate
  4701. });
  4702. }
  4703. requestFullScreen(args = {}) {
  4704. operateVideoPlayer(this.id, this.pageId, "requestFullScreen", args);
  4705. }
  4706. exitFullScreen() {
  4707. operateVideoPlayer(this.id, this.pageId, "exitFullScreen");
  4708. }
  4709. showStatusBar() {
  4710. operateVideoPlayer(this.id, this.pageId, "showStatusBar");
  4711. }
  4712. hideStatusBar() {
  4713. operateVideoPlayer(this.id, this.pageId, "hideStatusBar");
  4714. }
  4715. }
  4716. const createVideoContext = /* @__PURE__ */ defineSyncApi(
  4717. API_CREATE_VIDEO_CONTEXT,
  4718. (id2, context) => {
  4719. if (context) {
  4720. return new VideoContext(id2, getPageIdByVm(context));
  4721. }
  4722. return new VideoContext(id2, getPageIdByVm(getCurrentPageVm()));
  4723. }
  4724. );
  4725. const operateMapCallback = (options, res) => {
  4726. const errMsg = res.errMsg || "";
  4727. if (new RegExp("\\:\\s*fail").test(errMsg)) {
  4728. options.fail && options.fail(res);
  4729. } else {
  4730. options.success && options.success(res);
  4731. }
  4732. options.complete && options.complete(res);
  4733. };
  4734. const operateMapWrap = (id2, pageId, type, options) => {
  4735. operateMap(id2, pageId, type, options, (res) => {
  4736. options && operateMapCallback(options, res);
  4737. });
  4738. };
  4739. class MapContext {
  4740. constructor(id2, pageId) {
  4741. this.id = id2;
  4742. this.pageId = pageId;
  4743. }
  4744. getCenterLocation(options) {
  4745. operateMapWrap(this.id, this.pageId, "getCenterLocation", options);
  4746. }
  4747. moveToLocation(options) {
  4748. operateMapWrap(this.id, this.pageId, "moveToLocation", options);
  4749. }
  4750. getScale(options) {
  4751. operateMapWrap(this.id, this.pageId, "getScale", options);
  4752. }
  4753. getRegion(options) {
  4754. operateMapWrap(this.id, this.pageId, "getRegion", options);
  4755. }
  4756. includePoints(options) {
  4757. operateMapWrap(this.id, this.pageId, "includePoints", options);
  4758. }
  4759. translateMarker(options) {
  4760. operateMapWrap(this.id, this.pageId, "translateMarker", options);
  4761. }
  4762. $getAppMap() {
  4763. }
  4764. addCustomLayer(options) {
  4765. operateMapWrap(this.id, this.pageId, "addCustomLayer", options);
  4766. }
  4767. removeCustomLayer(options) {
  4768. operateMapWrap(this.id, this.pageId, "removeCustomLayer", options);
  4769. }
  4770. addGroundOverlay(options) {
  4771. operateMapWrap(this.id, this.pageId, "addGroundOverlay", options);
  4772. }
  4773. removeGroundOverlay(options) {
  4774. operateMapWrap(this.id, this.pageId, "removeGroundOverlay", options);
  4775. }
  4776. updateGroundOverlay(options) {
  4777. operateMapWrap(this.id, this.pageId, "updateGroundOverlay", options);
  4778. }
  4779. initMarkerCluster(options) {
  4780. operateMapWrap(this.id, this.pageId, "initMarkerCluster", options);
  4781. }
  4782. addMarkers(options) {
  4783. operateMapWrap(this.id, this.pageId, "addMarkers", options);
  4784. }
  4785. removeMarkers(options) {
  4786. operateMapWrap(this.id, this.pageId, "removeMarkers", options);
  4787. }
  4788. moveAlong(options) {
  4789. operateMapWrap(this.id, this.pageId, "moveAlong", options);
  4790. }
  4791. setLocMarkerIcon(options) {
  4792. operateMapWrap(this.id, this.pageId, "setLocMarkerIcon", options);
  4793. }
  4794. openMapApp(options) {
  4795. operateMapWrap(this.id, this.pageId, "openMapApp", options);
  4796. }
  4797. on(name, callback) {
  4798. operateMapWrap(this.id, this.pageId, "on", { name, callback });
  4799. }
  4800. }
  4801. const createMapContext = /* @__PURE__ */ defineSyncApi(
  4802. API_CREATE_MAP_CONTEXT,
  4803. (id2, context) => {
  4804. if (context) {
  4805. return new MapContext(id2, getPageIdByVm(context));
  4806. }
  4807. return new MapContext(id2, getPageIdByVm(getCurrentPageVm()));
  4808. },
  4809. CreateMapContextProtocol
  4810. );
  4811. function getInt(name, defaultValue) {
  4812. return function(value, params) {
  4813. if (value) {
  4814. params[name] = Math.round(value);
  4815. } else if (typeof defaultValue !== "undefined") {
  4816. params[name] = defaultValue;
  4817. }
  4818. };
  4819. }
  4820. const formatWidth = getInt("width");
  4821. const formatHeight = getInt("height");
  4822. const API_CANVAS_GET_IMAGE_DATA = "canvasGetImageData";
  4823. const CanvasGetImageDataOptions = {
  4824. formatArgs: {
  4825. x: getInt("x"),
  4826. y: getInt("y"),
  4827. width: formatWidth,
  4828. height: formatHeight
  4829. }
  4830. };
  4831. const CanvasGetImageDataProtocol = {
  4832. canvasId: {
  4833. type: String,
  4834. required: true
  4835. },
  4836. x: {
  4837. type: Number,
  4838. required: true
  4839. },
  4840. y: {
  4841. type: Number,
  4842. required: true
  4843. },
  4844. width: {
  4845. type: Number,
  4846. required: true
  4847. },
  4848. height: {
  4849. type: Number,
  4850. required: true
  4851. }
  4852. };
  4853. const API_CANVAS_PUT_IMAGE_DATA = "canvasPutImageData";
  4854. const CanvasPutImageDataOptions = CanvasGetImageDataOptions;
  4855. const CanvasPutImageDataProtocol = /* @__PURE__ */ extend(
  4856. {
  4857. data: {
  4858. type: Uint8ClampedArray,
  4859. required: true
  4860. }
  4861. },
  4862. CanvasGetImageDataProtocol,
  4863. {
  4864. height: {
  4865. type: Number
  4866. }
  4867. }
  4868. );
  4869. const fileTypes = {
  4870. PNG: "png",
  4871. JPG: "jpg",
  4872. JPEG: "jpg"
  4873. };
  4874. const API_CANVAS_TO_TEMP_FILE_PATH = "canvasToTempFilePath";
  4875. const CanvasToTempFilePathOptions = {
  4876. formatArgs: {
  4877. x: getInt("x", 0),
  4878. y: getInt("y", 0),
  4879. width: formatWidth,
  4880. height: formatHeight,
  4881. destWidth: getInt("destWidth"),
  4882. destHeight: getInt("destHeight"),
  4883. fileType(value, params) {
  4884. value = (value || "").toUpperCase();
  4885. let type = fileTypes[value];
  4886. if (!type) {
  4887. type = fileTypes.PNG;
  4888. }
  4889. params.fileType = type;
  4890. },
  4891. quality(value, params) {
  4892. params.quality = value && value > 0 && value < 1 ? value : 1;
  4893. }
  4894. }
  4895. };
  4896. const CanvasToTempFilePathProtocol = {
  4897. x: Number,
  4898. y: Number,
  4899. width: Number,
  4900. height: Number,
  4901. destWidth: Number,
  4902. destHeight: Number,
  4903. canvasId: {
  4904. type: String,
  4905. required: true
  4906. },
  4907. fileType: String,
  4908. quality: Number
  4909. };
  4910. function operateCanvas(canvasId, pageId, type, data, callback) {
  4911. UniServiceJSBridge.invokeViewMethod(
  4912. `canvas.${canvasId}`,
  4913. {
  4914. type,
  4915. data
  4916. },
  4917. pageId,
  4918. (data2) => {
  4919. if (callback)
  4920. callback(data2);
  4921. }
  4922. );
  4923. }
  4924. var methods1 = ["scale", "rotate", "translate", "setTransform", "transform"];
  4925. var methods2 = [
  4926. "drawImage",
  4927. "fillText",
  4928. "fill",
  4929. "stroke",
  4930. "fillRect",
  4931. "strokeRect",
  4932. "clearRect",
  4933. "strokeText"
  4934. ];
  4935. var methods3 = [
  4936. "setFillStyle",
  4937. "setTextAlign",
  4938. "setStrokeStyle",
  4939. "setGlobalAlpha",
  4940. "setShadow",
  4941. "setFontSize",
  4942. "setLineCap",
  4943. "setLineJoin",
  4944. "setLineWidth",
  4945. "setMiterLimit",
  4946. "setTextBaseline",
  4947. "setLineDash"
  4948. ];
  4949. function measureText(text2, font2) {
  4950. const canvas = document.createElement("canvas");
  4951. const c2d = canvas.getContext("2d");
  4952. c2d.font = font2;
  4953. return c2d.measureText(text2).width || 0;
  4954. }
  4955. const predefinedColor = {
  4956. aliceblue: "#f0f8ff",
  4957. antiquewhite: "#faebd7",
  4958. aqua: "#00ffff",
  4959. aquamarine: "#7fffd4",
  4960. azure: "#f0ffff",
  4961. beige: "#f5f5dc",
  4962. bisque: "#ffe4c4",
  4963. black: "#000000",
  4964. blanchedalmond: "#ffebcd",
  4965. blue: "#0000ff",
  4966. blueviolet: "#8a2be2",
  4967. brown: "#a52a2a",
  4968. burlywood: "#deb887",
  4969. cadetblue: "#5f9ea0",
  4970. chartreuse: "#7fff00",
  4971. chocolate: "#d2691e",
  4972. coral: "#ff7f50",
  4973. cornflowerblue: "#6495ed",
  4974. cornsilk: "#fff8dc",
  4975. crimson: "#dc143c",
  4976. cyan: "#00ffff",
  4977. darkblue: "#00008b",
  4978. darkcyan: "#008b8b",
  4979. darkgoldenrod: "#b8860b",
  4980. darkgray: "#a9a9a9",
  4981. darkgrey: "#a9a9a9",
  4982. darkgreen: "#006400",
  4983. darkkhaki: "#bdb76b",
  4984. darkmagenta: "#8b008b",
  4985. darkolivegreen: "#556b2f",
  4986. darkorange: "#ff8c00",
  4987. darkorchid: "#9932cc",
  4988. darkred: "#8b0000",
  4989. darksalmon: "#e9967a",
  4990. darkseagreen: "#8fbc8f",
  4991. darkslateblue: "#483d8b",
  4992. darkslategray: "#2f4f4f",
  4993. darkslategrey: "#2f4f4f",
  4994. darkturquoise: "#00ced1",
  4995. darkviolet: "#9400d3",
  4996. deeppink: "#ff1493",
  4997. deepskyblue: "#00bfff",
  4998. dimgray: "#696969",
  4999. dimgrey: "#696969",
  5000. dodgerblue: "#1e90ff",
  5001. firebrick: "#b22222",
  5002. floralwhite: "#fffaf0",
  5003. forestgreen: "#228b22",
  5004. fuchsia: "#ff00ff",
  5005. gainsboro: "#dcdcdc",
  5006. ghostwhite: "#f8f8ff",
  5007. gold: "#ffd700",
  5008. goldenrod: "#daa520",
  5009. gray: "#808080",
  5010. grey: "#808080",
  5011. green: "#008000",
  5012. greenyellow: "#adff2f",
  5013. honeydew: "#f0fff0",
  5014. hotpink: "#ff69b4",
  5015. indianred: "#cd5c5c",
  5016. indigo: "#4b0082",
  5017. ivory: "#fffff0",
  5018. khaki: "#f0e68c",
  5019. lavender: "#e6e6fa",
  5020. lavenderblush: "#fff0f5",
  5021. lawngreen: "#7cfc00",
  5022. lemonchiffon: "#fffacd",
  5023. lightblue: "#add8e6",
  5024. lightcoral: "#f08080",
  5025. lightcyan: "#e0ffff",
  5026. lightgoldenrodyellow: "#fafad2",
  5027. lightgray: "#d3d3d3",
  5028. lightgrey: "#d3d3d3",
  5029. lightgreen: "#90ee90",
  5030. lightpink: "#ffb6c1",
  5031. lightsalmon: "#ffa07a",
  5032. lightseagreen: "#20b2aa",
  5033. lightskyblue: "#87cefa",
  5034. lightslategray: "#778899",
  5035. lightslategrey: "#778899",
  5036. lightsteelblue: "#b0c4de",
  5037. lightyellow: "#ffffe0",
  5038. lime: "#00ff00",
  5039. limegreen: "#32cd32",
  5040. linen: "#faf0e6",
  5041. magenta: "#ff00ff",
  5042. maroon: "#800000",
  5043. mediumaquamarine: "#66cdaa",
  5044. mediumblue: "#0000cd",
  5045. mediumorchid: "#ba55d3",
  5046. mediumpurple: "#9370db",
  5047. mediumseagreen: "#3cb371",
  5048. mediumslateblue: "#7b68ee",
  5049. mediumspringgreen: "#00fa9a",
  5050. mediumturquoise: "#48d1cc",
  5051. mediumvioletred: "#c71585",
  5052. midnightblue: "#191970",
  5053. mintcream: "#f5fffa",
  5054. mistyrose: "#ffe4e1",
  5055. moccasin: "#ffe4b5",
  5056. navajowhite: "#ffdead",
  5057. navy: "#000080",
  5058. oldlace: "#fdf5e6",
  5059. olive: "#808000",
  5060. olivedrab: "#6b8e23",
  5061. orange: "#ffa500",
  5062. orangered: "#ff4500",
  5063. orchid: "#da70d6",
  5064. palegoldenrod: "#eee8aa",
  5065. palegreen: "#98fb98",
  5066. paleturquoise: "#afeeee",
  5067. palevioletred: "#db7093",
  5068. papayawhip: "#ffefd5",
  5069. peachpuff: "#ffdab9",
  5070. peru: "#cd853f",
  5071. pink: "#ffc0cb",
  5072. plum: "#dda0dd",
  5073. powderblue: "#b0e0e6",
  5074. purple: "#800080",
  5075. rebeccapurple: "#663399",
  5076. red: "#ff0000",
  5077. rosybrown: "#bc8f8f",
  5078. royalblue: "#4169e1",
  5079. saddlebrown: "#8b4513",
  5080. salmon: "#fa8072",
  5081. sandybrown: "#f4a460",
  5082. seagreen: "#2e8b57",
  5083. seashell: "#fff5ee",
  5084. sienna: "#a0522d",
  5085. silver: "#c0c0c0",
  5086. skyblue: "#87ceeb",
  5087. slateblue: "#6a5acd",
  5088. slategray: "#708090",
  5089. slategrey: "#708090",
  5090. snow: "#fffafa",
  5091. springgreen: "#00ff7f",
  5092. steelblue: "#4682b4",
  5093. tan: "#d2b48c",
  5094. teal: "#008080",
  5095. thistle: "#d8bfd8",
  5096. tomato: "#ff6347",
  5097. turquoise: "#40e0d0",
  5098. violet: "#ee82ee",
  5099. wheat: "#f5deb3",
  5100. white: "#ffffff",
  5101. whitesmoke: "#f5f5f5",
  5102. yellow: "#ffff00",
  5103. yellowgreen: "#9acd32",
  5104. transparent: "#00000000"
  5105. };
  5106. function checkColor(e2) {
  5107. e2 = e2 || "#000000";
  5108. let t2 = null;
  5109. if ((t2 = /^#([0-9|A-F|a-f]{6})$/.exec(e2)) != null) {
  5110. const n = parseInt(t2[1].slice(0, 2), 16);
  5111. const o2 = parseInt(t2[1].slice(2, 4), 16);
  5112. const r = parseInt(t2[1].slice(4), 16);
  5113. return [n, o2, r, 255];
  5114. }
  5115. if ((t2 = /^#([0-9|A-F|a-f]{3})$/.exec(e2)) != null) {
  5116. let n = t2[1].slice(0, 1);
  5117. let o2 = t2[1].slice(1, 2);
  5118. let r = t2[1].slice(2, 3);
  5119. n = parseInt(n + n, 16);
  5120. o2 = parseInt(o2 + o2, 16);
  5121. r = parseInt(r + r, 16);
  5122. return [n, o2, r, 255];
  5123. }
  5124. if ((t2 = /^rgb\((.+)\)$/.exec(e2)) != null) {
  5125. return t2[1].split(",").map(function(e22) {
  5126. return Math.min(255, parseInt(e22.trim()));
  5127. }).concat(255);
  5128. }
  5129. if ((t2 = /^rgba\((.+)\)$/.exec(e2)) != null) {
  5130. return t2[1].split(",").map(function(e22, t22) {
  5131. return t22 === 3 ? Math.floor(255 * parseFloat(e22.trim())) : Math.min(255, parseInt(e22.trim()));
  5132. });
  5133. }
  5134. var i = e2.toLowerCase();
  5135. if (hasOwn(predefinedColor, i)) {
  5136. t2 = /^#([0-9|A-F|a-f]{6,8})$/.exec(predefinedColor[i]);
  5137. const n = parseInt(t2[1].slice(0, 2), 16);
  5138. const o2 = parseInt(t2[1].slice(2, 4), 16);
  5139. const r = parseInt(t2[1].slice(4, 6), 16);
  5140. let a2 = parseInt(t2[1].slice(6, 8), 16);
  5141. a2 = a2 >= 0 ? a2 : 255;
  5142. return [n, o2, r, a2];
  5143. }
  5144. console.error("unsupported color:" + e2);
  5145. return [0, 0, 0, 255];
  5146. }
  5147. class CanvasGradient {
  5148. constructor(type, data) {
  5149. this.type = type;
  5150. this.data = data;
  5151. this.colorStop = [];
  5152. }
  5153. addColorStop(position, color) {
  5154. this.colorStop.push([position, checkColor(color)]);
  5155. }
  5156. }
  5157. class Pattern {
  5158. constructor(image2, repetition) {
  5159. this.type = "pattern";
  5160. this.data = image2;
  5161. this.colorStop = repetition;
  5162. }
  5163. }
  5164. class TextMetrics {
  5165. constructor(width) {
  5166. this.width = width;
  5167. }
  5168. }
  5169. const getTempPath = () => {
  5170. let _TEMP_PATH = TEMP_PATH;
  5171. return _TEMP_PATH;
  5172. };
  5173. class CanvasContext {
  5174. constructor(id2, pageId) {
  5175. this.id = id2;
  5176. this.pageId = pageId;
  5177. this.actions = [];
  5178. this.path = [];
  5179. this.subpath = [];
  5180. this.drawingState = [];
  5181. this.state = {
  5182. lineDash: [0, 0],
  5183. shadowOffsetX: 0,
  5184. shadowOffsetY: 0,
  5185. shadowBlur: 0,
  5186. shadowColor: [0, 0, 0, 0],
  5187. font: "10px sans-serif",
  5188. fontSize: 10,
  5189. fontWeight: "normal",
  5190. fontStyle: "normal",
  5191. fontFamily: "sans-serif"
  5192. };
  5193. }
  5194. setFillStyle(color) {
  5195. console.log("initCanvasContextProperty implemented.");
  5196. }
  5197. setStrokeStyle(color) {
  5198. console.log("initCanvasContextProperty implemented.");
  5199. }
  5200. setShadow(offsetX, offsetY, blur, color) {
  5201. console.log("initCanvasContextProperty implemented.");
  5202. }
  5203. addColorStop(stop, color) {
  5204. console.log("initCanvasContextProperty implemented.");
  5205. }
  5206. setLineWidth(lineWidth) {
  5207. console.log("initCanvasContextProperty implemented.");
  5208. }
  5209. setLineCap(lineCap) {
  5210. console.log("initCanvasContextProperty implemented.");
  5211. }
  5212. setLineJoin(lineJoin) {
  5213. console.log("initCanvasContextProperty implemented.");
  5214. }
  5215. setLineDash(pattern, offset) {
  5216. console.log("initCanvasContextProperty implemented.");
  5217. }
  5218. setMiterLimit(miterLimit) {
  5219. console.log("initCanvasContextProperty implemented.");
  5220. }
  5221. fillRect(x, y, width, height) {
  5222. console.log("initCanvasContextProperty implemented.");
  5223. }
  5224. strokeRect(x, y, width, height) {
  5225. console.log("initCanvasContextProperty implemented.");
  5226. }
  5227. clearRect(x, y, width, height) {
  5228. console.log("initCanvasContextProperty implemented.");
  5229. }
  5230. fill() {
  5231. console.log("initCanvasContextProperty implemented.");
  5232. }
  5233. stroke() {
  5234. console.log("initCanvasContextProperty implemented.");
  5235. }
  5236. scale(scaleWidth, scaleHeight) {
  5237. console.log("initCanvasContextProperty implemented.");
  5238. }
  5239. rotate(rotate) {
  5240. console.log("initCanvasContextProperty implemented.");
  5241. }
  5242. translate(x, y) {
  5243. console.log("initCanvasContextProperty implemented.");
  5244. }
  5245. setFontSize(fontSize) {
  5246. console.log("initCanvasContextProperty implemented.");
  5247. }
  5248. fillText(text2, x, y, maxWidth2) {
  5249. console.log("initCanvasContextProperty implemented.");
  5250. }
  5251. setTextAlign(align2) {
  5252. console.log("initCanvasContextProperty implemented.");
  5253. }
  5254. setTextBaseline(textBaseline) {
  5255. console.log("initCanvasContextProperty implemented.");
  5256. }
  5257. drawImage(imageResource, dx, dy, dWidth, dHeigt, sx, sy, sWidth, sHeight) {
  5258. console.log("initCanvasContextProperty implemented.");
  5259. }
  5260. setGlobalAlpha(alpha) {
  5261. console.log("initCanvasContextProperty implemented.");
  5262. }
  5263. strokeText(text2, x, y, maxWidth2) {
  5264. console.log("initCanvasContextProperty implemented.");
  5265. }
  5266. setTransform(scaleX, skewX, skewY, scaleY, translateX, translateY) {
  5267. console.log("initCanvasContextProperty implemented.");
  5268. }
  5269. draw(reserve = false, callback) {
  5270. var actions = [...this.actions];
  5271. this.actions = [];
  5272. this.path = [];
  5273. operateCanvas(
  5274. this.id,
  5275. this.pageId,
  5276. "actionsChanged",
  5277. {
  5278. actions,
  5279. reserve
  5280. },
  5281. callback
  5282. );
  5283. }
  5284. createLinearGradient(x0, y0, x1, y1) {
  5285. return new CanvasGradient("linear", [x0, y0, x1, y1]);
  5286. }
  5287. createCircularGradient(x, y, r) {
  5288. return new CanvasGradient("radial", [x, y, r]);
  5289. }
  5290. createPattern(image2, repetition) {
  5291. if (void 0 === repetition) {
  5292. console.error(
  5293. "Failed to execute 'createPattern' on 'CanvasContext': 2 arguments required, but only 1 present."
  5294. );
  5295. } else if (["repeat", "repeat-x", "repeat-y", "no-repeat"].indexOf(repetition) < 0) {
  5296. console.error(
  5297. "Failed to execute 'createPattern' on 'CanvasContext': The provided type ('" + repetition + "') is not one of 'repeat', 'no-repeat', 'repeat-x', or 'repeat-y'."
  5298. );
  5299. } else {
  5300. return new Pattern(image2, repetition);
  5301. }
  5302. }
  5303. measureText(text2, callback) {
  5304. const font2 = this.state.font;
  5305. let width = 0;
  5306. {
  5307. width = measureText(text2, font2);
  5308. }
  5309. return new TextMetrics(width);
  5310. }
  5311. save() {
  5312. this.actions.push({
  5313. method: "save",
  5314. data: []
  5315. });
  5316. this.drawingState.push(this.state);
  5317. }
  5318. restore() {
  5319. this.actions.push({
  5320. method: "restore",
  5321. data: []
  5322. });
  5323. this.state = this.drawingState.pop() || {
  5324. lineDash: [0, 0],
  5325. shadowOffsetX: 0,
  5326. shadowOffsetY: 0,
  5327. shadowBlur: 0,
  5328. shadowColor: [0, 0, 0, 0],
  5329. font: "10px sans-serif",
  5330. fontSize: 10,
  5331. fontWeight: "normal",
  5332. fontStyle: "normal",
  5333. fontFamily: "sans-serif"
  5334. };
  5335. }
  5336. beginPath() {
  5337. this.path = [];
  5338. this.subpath = [];
  5339. this.path.push({
  5340. method: "beginPath",
  5341. data: []
  5342. });
  5343. }
  5344. moveTo(x, y) {
  5345. this.path.push({
  5346. method: "moveTo",
  5347. data: [x, y]
  5348. });
  5349. this.subpath = [[x, y]];
  5350. }
  5351. lineTo(x, y) {
  5352. if (this.path.length === 0 && this.subpath.length === 0) {
  5353. this.path.push({
  5354. method: "moveTo",
  5355. data: [x, y]
  5356. });
  5357. } else {
  5358. this.path.push({
  5359. method: "lineTo",
  5360. data: [x, y]
  5361. });
  5362. }
  5363. this.subpath.push([x, y]);
  5364. }
  5365. quadraticCurveTo(cpx, cpy, x, y) {
  5366. this.path.push({
  5367. method: "quadraticCurveTo",
  5368. data: [cpx, cpy, x, y]
  5369. });
  5370. this.subpath.push([x, y]);
  5371. }
  5372. bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
  5373. this.path.push({
  5374. method: "bezierCurveTo",
  5375. data: [cp1x, cp1y, cp2x, cp2y, x, y]
  5376. });
  5377. this.subpath.push([x, y]);
  5378. }
  5379. arc(x, y, r, sAngle, eAngle, counterclockwise = false) {
  5380. this.path.push({
  5381. method: "arc",
  5382. data: [x, y, r, sAngle, eAngle, counterclockwise]
  5383. });
  5384. this.subpath.push([x, y]);
  5385. }
  5386. rect(x, y, width, height) {
  5387. this.path.push({
  5388. method: "rect",
  5389. data: [x, y, width, height]
  5390. });
  5391. this.subpath = [[x, y]];
  5392. }
  5393. arcTo(x1, y1, x2, y2, radius) {
  5394. this.path.push({
  5395. method: "arcTo",
  5396. data: [x1, y1, x2, y2, radius]
  5397. });
  5398. this.subpath.push([x2, y2]);
  5399. }
  5400. clip() {
  5401. this.actions.push({
  5402. method: "clip",
  5403. data: [...this.path]
  5404. });
  5405. }
  5406. closePath() {
  5407. this.path.push({
  5408. method: "closePath",
  5409. data: []
  5410. });
  5411. if (this.subpath.length) {
  5412. this.subpath = [this.subpath.shift()];
  5413. }
  5414. }
  5415. clearActions() {
  5416. this.actions = [];
  5417. this.path = [];
  5418. this.subpath = [];
  5419. }
  5420. getActions() {
  5421. var actions = [...this.actions];
  5422. this.clearActions();
  5423. return actions;
  5424. }
  5425. set lineDashOffset(value) {
  5426. this.actions.push({
  5427. method: "setLineDashOffset",
  5428. data: [value]
  5429. });
  5430. }
  5431. set globalCompositeOperation(type) {
  5432. this.actions.push({
  5433. method: "setGlobalCompositeOperation",
  5434. data: [type]
  5435. });
  5436. }
  5437. set shadowBlur(level) {
  5438. this.actions.push({
  5439. method: "setShadowBlur",
  5440. data: [level]
  5441. });
  5442. }
  5443. set shadowColor(color) {
  5444. this.actions.push({
  5445. method: "setShadowColor",
  5446. data: [color]
  5447. });
  5448. }
  5449. set shadowOffsetX(x) {
  5450. this.actions.push({
  5451. method: "setShadowOffsetX",
  5452. data: [x]
  5453. });
  5454. }
  5455. set shadowOffsetY(y) {
  5456. this.actions.push({
  5457. method: "setShadowOffsetY",
  5458. data: [y]
  5459. });
  5460. }
  5461. set font(value) {
  5462. var self2 = this;
  5463. this.state.font = value;
  5464. var fontFormat = value.match(
  5465. /^(([\w\-]+\s)*)(\d+r?px)(\/(\d+\.?\d*(r?px)?))?\s+(.*)/
  5466. );
  5467. if (fontFormat) {
  5468. var style = fontFormat[1].trim().split(/\s/);
  5469. var fontSize = parseFloat(fontFormat[3]);
  5470. var fontFamily = fontFormat[7];
  5471. var actions = [];
  5472. style.forEach(function(value2, index2) {
  5473. if (["italic", "oblique", "normal"].indexOf(value2) > -1) {
  5474. actions.push({
  5475. method: "setFontStyle",
  5476. data: [value2]
  5477. });
  5478. self2.state.fontStyle = value2;
  5479. } else if (["bold", "normal"].indexOf(value2) > -1) {
  5480. actions.push({
  5481. method: "setFontWeight",
  5482. data: [value2]
  5483. });
  5484. self2.state.fontWeight = value2;
  5485. } else if (index2 === 0) {
  5486. actions.push({
  5487. method: "setFontStyle",
  5488. data: ["normal"]
  5489. });
  5490. self2.state.fontStyle = "normal";
  5491. } else if (index2 === 1) {
  5492. pushAction();
  5493. }
  5494. });
  5495. if (style.length === 1) {
  5496. pushAction();
  5497. }
  5498. style = actions.map(function(action) {
  5499. return action.data[0];
  5500. }).join(" ");
  5501. this.state.fontSize = fontSize;
  5502. this.state.fontFamily = fontFamily;
  5503. this.actions.push({
  5504. method: "setFont",
  5505. data: [`${style} ${fontSize}px ${fontFamily}`]
  5506. });
  5507. } else {
  5508. console.warn("Failed to set 'font' on 'CanvasContext': invalid format.");
  5509. }
  5510. function pushAction() {
  5511. actions.push({
  5512. method: "setFontWeight",
  5513. data: ["normal"]
  5514. });
  5515. self2.state.fontWeight = "normal";
  5516. }
  5517. }
  5518. get font() {
  5519. return this.state.font;
  5520. }
  5521. set fillStyle(color) {
  5522. this.setFillStyle(color);
  5523. }
  5524. set strokeStyle(color) {
  5525. this.setStrokeStyle(color);
  5526. }
  5527. set globalAlpha(value) {
  5528. value = Math.floor(255 * parseFloat(value));
  5529. this.actions.push({
  5530. method: "setGlobalAlpha",
  5531. data: [value]
  5532. });
  5533. }
  5534. set textAlign(align2) {
  5535. this.actions.push({
  5536. method: "setTextAlign",
  5537. data: [align2]
  5538. });
  5539. }
  5540. set lineCap(type) {
  5541. this.actions.push({
  5542. method: "setLineCap",
  5543. data: [type]
  5544. });
  5545. }
  5546. set lineJoin(type) {
  5547. this.actions.push({
  5548. method: "setLineJoin",
  5549. data: [type]
  5550. });
  5551. }
  5552. set lineWidth(value) {
  5553. this.actions.push({
  5554. method: "setLineWidth",
  5555. data: [value]
  5556. });
  5557. }
  5558. set miterLimit(value) {
  5559. this.actions.push({
  5560. method: "setMiterLimit",
  5561. data: [value]
  5562. });
  5563. }
  5564. set textBaseline(type) {
  5565. this.actions.push({
  5566. method: "setTextBaseline",
  5567. data: [type]
  5568. });
  5569. }
  5570. }
  5571. const initCanvasContextProperty = /* @__PURE__ */ once(() => {
  5572. [...methods1, ...methods2].forEach(function(method) {
  5573. function get(method2) {
  5574. switch (method2) {
  5575. case "fill":
  5576. case "stroke":
  5577. return function() {
  5578. this.actions.push({
  5579. method: method2 + "Path",
  5580. // @ts-expect-error
  5581. data: [...this.path]
  5582. });
  5583. };
  5584. case "fillRect":
  5585. return function(x, y, width, height) {
  5586. this.actions.push({
  5587. method: "fillPath",
  5588. data: [
  5589. {
  5590. method: "rect",
  5591. data: [x, y, width, height]
  5592. }
  5593. ]
  5594. });
  5595. };
  5596. case "strokeRect":
  5597. return function(x, y, width, height) {
  5598. this.actions.push({
  5599. method: "strokePath",
  5600. data: [
  5601. {
  5602. method: "rect",
  5603. data: [x, y, width, height]
  5604. }
  5605. ]
  5606. });
  5607. };
  5608. case "fillText":
  5609. case "strokeText":
  5610. return function(text2, x, y, maxWidth2) {
  5611. var data = [text2.toString(), x, y];
  5612. if (typeof maxWidth2 === "number") {
  5613. data.push(maxWidth2);
  5614. }
  5615. this.actions.push({
  5616. method: method2,
  5617. data
  5618. });
  5619. };
  5620. case "drawImage":
  5621. return function(imageResource, dx, dy, dWidth, dHeight, sx, sy, sWidth, sHeight) {
  5622. if (sHeight === void 0) {
  5623. sx = dx;
  5624. sy = dy;
  5625. sWidth = dWidth;
  5626. sHeight = dHeight;
  5627. dx = void 0;
  5628. dy = void 0;
  5629. dWidth = void 0;
  5630. dHeight = void 0;
  5631. }
  5632. var data;
  5633. function isNumber(e2) {
  5634. return typeof e2 === "number";
  5635. }
  5636. data = isNumber(dx) && isNumber(dy) && isNumber(dWidth) && isNumber(dHeight) ? [
  5637. imageResource,
  5638. sx,
  5639. sy,
  5640. sWidth,
  5641. sHeight,
  5642. dx,
  5643. dy,
  5644. dWidth,
  5645. dHeight
  5646. ] : isNumber(sWidth) && isNumber(sHeight) ? [imageResource, sx, sy, sWidth, sHeight] : [imageResource, sx, sy];
  5647. this.actions.push({
  5648. method: method2,
  5649. data
  5650. });
  5651. };
  5652. default:
  5653. return function(...data) {
  5654. this.actions.push({
  5655. method: method2,
  5656. data
  5657. });
  5658. };
  5659. }
  5660. }
  5661. CanvasContext.prototype[method] = get(method);
  5662. });
  5663. methods3.forEach(function(method) {
  5664. function get(method2) {
  5665. switch (method2) {
  5666. case "setFillStyle":
  5667. case "setStrokeStyle":
  5668. return function(color) {
  5669. if (typeof color !== "object") {
  5670. this.actions.push({
  5671. method: method2,
  5672. data: ["normal", checkColor(color)]
  5673. });
  5674. } else {
  5675. this.actions.push({
  5676. method: method2,
  5677. data: [color.type, color.data, color.colorStop]
  5678. });
  5679. }
  5680. };
  5681. case "setGlobalAlpha":
  5682. return function(alpha) {
  5683. alpha = Math.floor(255 * parseFloat(alpha));
  5684. this.actions.push({
  5685. method: method2,
  5686. data: [alpha]
  5687. });
  5688. };
  5689. case "setShadow":
  5690. return function(offsetX, offsetY, blur, color) {
  5691. color = checkColor(color);
  5692. this.actions.push({
  5693. method: method2,
  5694. data: [offsetX, offsetY, blur, color]
  5695. });
  5696. this.state.shadowBlur = blur;
  5697. this.state.shadowColor = color;
  5698. this.state.shadowOffsetX = offsetX;
  5699. this.state.shadowOffsetY = offsetY;
  5700. };
  5701. case "setLineDash":
  5702. return function(pattern, offset) {
  5703. pattern = pattern || [0, 0];
  5704. offset = offset || 0;
  5705. this.actions.push({
  5706. method: method2,
  5707. data: [pattern, offset]
  5708. });
  5709. this.state.lineDash = pattern;
  5710. };
  5711. case "setFontSize":
  5712. return function(fontSize) {
  5713. this.state.font = this.state.font.replace(
  5714. /\d+\.?\d*px/,
  5715. fontSize + "px"
  5716. );
  5717. this.state.fontSize = fontSize;
  5718. this.actions.push({
  5719. method: method2,
  5720. data: [fontSize]
  5721. });
  5722. };
  5723. default:
  5724. return function(...data) {
  5725. this.actions.push({
  5726. method: method2,
  5727. data
  5728. });
  5729. };
  5730. }
  5731. }
  5732. CanvasContext.prototype[method] = get(method);
  5733. });
  5734. });
  5735. const createCanvasContext = /* @__PURE__ */ defineSyncApi(
  5736. API_CREATE_CANVAS_CONTEXT,
  5737. (canvasId, componentInstance) => {
  5738. initCanvasContextProperty();
  5739. if (componentInstance) {
  5740. return new CanvasContext(canvasId, getPageIdByVm(componentInstance));
  5741. }
  5742. const pageId = getPageIdByVm(getCurrentPageVm());
  5743. if (pageId) {
  5744. return new CanvasContext(canvasId, pageId);
  5745. } else {
  5746. UniServiceJSBridge.emit(ON_ERROR, "createCanvasContext:fail");
  5747. }
  5748. },
  5749. CreateCanvasContextProtocol
  5750. );
  5751. const canvasGetImageData = /* @__PURE__ */ defineAsyncApi(
  5752. API_CANVAS_GET_IMAGE_DATA,
  5753. ({ canvasId, x, y, width, height }, { resolve, reject }) => {
  5754. const pageId = getPageIdByVm(getCurrentPageVm());
  5755. if (!pageId) {
  5756. reject();
  5757. return;
  5758. }
  5759. function callback(data) {
  5760. if (data.errMsg && data.errMsg.indexOf("fail") !== -1) {
  5761. reject("", data);
  5762. return;
  5763. }
  5764. let imgData = data.data;
  5765. if (imgData && imgData.length) {
  5766. data.data = new Uint8ClampedArray(imgData);
  5767. }
  5768. delete data.compressed;
  5769. resolve(data);
  5770. }
  5771. operateCanvas(
  5772. canvasId,
  5773. pageId,
  5774. "getImageData",
  5775. {
  5776. x,
  5777. y,
  5778. width,
  5779. height
  5780. },
  5781. callback
  5782. );
  5783. },
  5784. CanvasGetImageDataProtocol,
  5785. CanvasGetImageDataOptions
  5786. );
  5787. const canvasPutImageData = /* @__PURE__ */ defineAsyncApi(
  5788. API_CANVAS_PUT_IMAGE_DATA,
  5789. ({ canvasId, data, x, y, width, height }, { resolve, reject }) => {
  5790. var pageId = getPageIdByVm(getCurrentPageVm());
  5791. if (!pageId) {
  5792. reject();
  5793. return;
  5794. }
  5795. let compressed;
  5796. const operate = () => {
  5797. operateCanvas(
  5798. canvasId,
  5799. pageId,
  5800. "putImageData",
  5801. {
  5802. data,
  5803. x,
  5804. y,
  5805. width,
  5806. height,
  5807. compressed
  5808. },
  5809. (data2) => {
  5810. if (data2.errMsg && data2.errMsg.indexOf("fail") !== -1) {
  5811. reject();
  5812. return;
  5813. }
  5814. resolve(data2);
  5815. }
  5816. );
  5817. };
  5818. {
  5819. data = Array.prototype.slice.call(data);
  5820. }
  5821. operate();
  5822. },
  5823. CanvasPutImageDataProtocol,
  5824. CanvasPutImageDataOptions
  5825. );
  5826. const canvasToTempFilePath = /* @__PURE__ */ defineAsyncApi(
  5827. API_CANVAS_TO_TEMP_FILE_PATH,
  5828. ({
  5829. x = 0,
  5830. y = 0,
  5831. width,
  5832. height,
  5833. destWidth,
  5834. destHeight,
  5835. canvasId,
  5836. fileType,
  5837. quality
  5838. }, { resolve, reject }) => {
  5839. var pageId = getPageIdByVm(getCurrentPageVm());
  5840. if (!pageId) {
  5841. reject();
  5842. return;
  5843. }
  5844. let dirname = `${getTempPath()}/canvas`;
  5845. operateCanvas(
  5846. canvasId,
  5847. pageId,
  5848. "toTempFilePath",
  5849. {
  5850. x,
  5851. y,
  5852. width,
  5853. height,
  5854. destWidth,
  5855. destHeight,
  5856. fileType,
  5857. quality,
  5858. dirname
  5859. },
  5860. (res) => {
  5861. if (res.errMsg && res.errMsg.indexOf("fail") !== -1) {
  5862. reject("", res);
  5863. return;
  5864. }
  5865. resolve(res);
  5866. }
  5867. );
  5868. },
  5869. CanvasToTempFilePathProtocol,
  5870. CanvasToTempFilePathOptions
  5871. );
  5872. const innerAudioContextEventNames = [
  5873. "onCanplay",
  5874. "onPlay",
  5875. "onPause",
  5876. "onStop",
  5877. "onEnded",
  5878. "onTimeUpdate",
  5879. "onError",
  5880. "onWaiting",
  5881. "onSeeking",
  5882. "onSeeked"
  5883. ];
  5884. const innerAudioContextOffEventNames = [
  5885. "offCanplay",
  5886. "offPlay",
  5887. "offPause",
  5888. "offStop",
  5889. "offEnded",
  5890. "offTimeUpdate",
  5891. "offError",
  5892. "offWaiting",
  5893. "offSeeking",
  5894. "offSeeked"
  5895. ];
  5896. const defaultOptions = {
  5897. thresholds: [0],
  5898. initialRatio: 0,
  5899. observeAll: false
  5900. };
  5901. const MARGINS = ["top", "right", "bottom", "left"];
  5902. let reqComponentObserverId$1 = 1;
  5903. function normalizeRootMargin(margins = {}) {
  5904. return MARGINS.map(
  5905. (name) => `${Number(margins[name]) || 0}px`
  5906. ).join(" ");
  5907. }
  5908. class ServiceIntersectionObserver {
  5909. constructor(component, options) {
  5910. this._pageId = getPageIdByVm(component);
  5911. this._component = component;
  5912. this._options = extend({}, defaultOptions, options);
  5913. }
  5914. relativeTo(selector, margins) {
  5915. this._options.relativeToSelector = selector;
  5916. this._options.rootMargin = normalizeRootMargin(margins);
  5917. return this;
  5918. }
  5919. relativeToViewport(margins) {
  5920. this._options.relativeToSelector = void 0;
  5921. this._options.rootMargin = normalizeRootMargin(margins);
  5922. return this;
  5923. }
  5924. observe(selector, callback) {
  5925. if (!isFunction(callback)) {
  5926. return;
  5927. }
  5928. this._options.selector = selector;
  5929. this._reqId = reqComponentObserverId$1++;
  5930. addIntersectionObserver(
  5931. {
  5932. reqId: this._reqId,
  5933. component: this._component,
  5934. options: this._options,
  5935. callback
  5936. },
  5937. this._pageId
  5938. );
  5939. }
  5940. disconnect() {
  5941. this._reqId && removeIntersectionObserver(
  5942. { reqId: this._reqId, component: this._component },
  5943. this._pageId
  5944. );
  5945. }
  5946. }
  5947. const createIntersectionObserver = /* @__PURE__ */ defineSyncApi("createIntersectionObserver", (context, options) => {
  5948. context = resolveComponentInstance(context);
  5949. if (context && !getPageIdByVm(context)) {
  5950. options = context;
  5951. context = null;
  5952. }
  5953. if (context) {
  5954. return new ServiceIntersectionObserver(context, options);
  5955. }
  5956. return new ServiceIntersectionObserver(getCurrentPageVm(), options);
  5957. });
  5958. let reqComponentObserverId = 1;
  5959. class ServiceMediaQueryObserver {
  5960. constructor(component) {
  5961. this._pageId = component.$page && component.$page.id;
  5962. this._component = component;
  5963. }
  5964. observe(options, callback) {
  5965. if (!isFunction(callback)) {
  5966. return;
  5967. }
  5968. this._reqId = reqComponentObserverId++;
  5969. addMediaQueryObserver(
  5970. {
  5971. reqId: this._reqId,
  5972. component: this._component,
  5973. options,
  5974. callback
  5975. },
  5976. this._pageId
  5977. );
  5978. }
  5979. disconnect() {
  5980. this._reqId && removeMediaQueryObserver(
  5981. {
  5982. reqId: this._reqId,
  5983. component: this._component
  5984. },
  5985. this._pageId
  5986. );
  5987. }
  5988. }
  5989. const createMediaQueryObserver = /* @__PURE__ */ defineSyncApi("createMediaQueryObserver", (context) => {
  5990. context = resolveComponentInstance(context);
  5991. if (context && !getPageIdByVm(context)) {
  5992. context = null;
  5993. }
  5994. if (context) {
  5995. return new ServiceMediaQueryObserver(context);
  5996. }
  5997. return new ServiceMediaQueryObserver(getCurrentPageVm());
  5998. });
  5999. let index$t = 0;
  6000. let optionsCache = {};
  6001. function operateEditor(componentId, pageId, type, options) {
  6002. const data = { options };
  6003. const needCallOptions = options && ("success" in options || "fail" in options || "complete" in options);
  6004. if (needCallOptions) {
  6005. const callbackId = String(index$t++);
  6006. data.callbackId = callbackId;
  6007. optionsCache[callbackId] = options;
  6008. }
  6009. UniServiceJSBridge.invokeViewMethod(
  6010. `editor.${componentId}`,
  6011. {
  6012. type,
  6013. data
  6014. },
  6015. pageId,
  6016. ({ callbackId, data: data2 }) => {
  6017. if (needCallOptions) {
  6018. callOptions(optionsCache[callbackId], data2);
  6019. delete optionsCache[callbackId];
  6020. }
  6021. }
  6022. );
  6023. }
  6024. class EditorContext {
  6025. constructor(id2, pageId) {
  6026. this.id = id2;
  6027. this.pageId = pageId;
  6028. }
  6029. format(name, value) {
  6030. this._exec("format", {
  6031. name,
  6032. value
  6033. });
  6034. }
  6035. insertDivider() {
  6036. this._exec("insertDivider");
  6037. }
  6038. insertImage(options) {
  6039. this._exec("insertImage", options);
  6040. }
  6041. insertText(options) {
  6042. this._exec("insertText", options);
  6043. }
  6044. setContents(options) {
  6045. this._exec("setContents", options);
  6046. }
  6047. getContents(options) {
  6048. this._exec("getContents", options);
  6049. }
  6050. clear(options) {
  6051. this._exec("clear", options);
  6052. }
  6053. removeFormat(options) {
  6054. this._exec("removeFormat", options);
  6055. }
  6056. undo(options) {
  6057. this._exec("undo", options);
  6058. }
  6059. redo(options) {
  6060. this._exec("redo", options);
  6061. }
  6062. blur(options) {
  6063. this._exec("blur", options);
  6064. }
  6065. getSelectionText(options) {
  6066. this._exec("getSelectionText", options);
  6067. }
  6068. scrollIntoView(options) {
  6069. this._exec("scrollIntoView", options);
  6070. }
  6071. _exec(method, options) {
  6072. operateEditor(this.id, this.pageId, method, options);
  6073. }
  6074. }
  6075. const ContextClasss = {
  6076. canvas: CanvasContext,
  6077. map: MapContext,
  6078. video: VideoContext,
  6079. editor: EditorContext
  6080. };
  6081. function convertContext(result) {
  6082. if (result && result.contextInfo) {
  6083. const { id: id2, type, page } = result.contextInfo;
  6084. const ContextClass = ContextClasss[type];
  6085. result.context = new ContextClass(id2, page);
  6086. delete result.contextInfo;
  6087. }
  6088. }
  6089. class NodesRef {
  6090. constructor(selectorQuery, component, selector, single) {
  6091. this._selectorQuery = selectorQuery;
  6092. this._component = component;
  6093. this._selector = selector;
  6094. this._single = single;
  6095. }
  6096. boundingClientRect(callback) {
  6097. this._selectorQuery._push(
  6098. this._selector,
  6099. this._component,
  6100. this._single,
  6101. {
  6102. id: true,
  6103. dataset: true,
  6104. rect: true,
  6105. size: true
  6106. },
  6107. callback
  6108. );
  6109. return this._selectorQuery;
  6110. }
  6111. fields(fields2, callback) {
  6112. this._selectorQuery._push(
  6113. this._selector,
  6114. this._component,
  6115. this._single,
  6116. fields2,
  6117. callback
  6118. );
  6119. return this._selectorQuery;
  6120. }
  6121. scrollOffset(callback) {
  6122. this._selectorQuery._push(
  6123. this._selector,
  6124. this._component,
  6125. this._single,
  6126. {
  6127. id: true,
  6128. dataset: true,
  6129. scrollOffset: true
  6130. },
  6131. callback
  6132. );
  6133. return this._selectorQuery;
  6134. }
  6135. context(callback) {
  6136. this._selectorQuery._push(
  6137. this._selector,
  6138. this._component,
  6139. this._single,
  6140. {
  6141. context: true
  6142. },
  6143. callback
  6144. );
  6145. return this._selectorQuery;
  6146. }
  6147. node(callback) {
  6148. this._selectorQuery._push(
  6149. this._selector,
  6150. this._component,
  6151. this._single,
  6152. {
  6153. node: true
  6154. },
  6155. callback
  6156. );
  6157. return this._selectorQuery;
  6158. }
  6159. }
  6160. class SelectorQuery {
  6161. constructor(page) {
  6162. this._component = void 0;
  6163. this._page = page;
  6164. this._queue = [];
  6165. this._queueCb = [];
  6166. }
  6167. exec(callback) {
  6168. requestComponentInfo(
  6169. this._page,
  6170. this._queue,
  6171. (res) => {
  6172. const queueCbs = this._queueCb;
  6173. res.forEach((result, index2) => {
  6174. if (isArray(result)) {
  6175. result.forEach(convertContext);
  6176. } else {
  6177. convertContext(result);
  6178. }
  6179. const queueCb = queueCbs[index2];
  6180. if (isFunction(queueCb)) {
  6181. queueCb.call(this, result);
  6182. }
  6183. });
  6184. if (isFunction(callback)) {
  6185. callback.call(this, res);
  6186. }
  6187. }
  6188. );
  6189. return this._nodesRef;
  6190. }
  6191. in(component) {
  6192. this._component = resolveComponentInstance(component);
  6193. return this;
  6194. }
  6195. select(selector) {
  6196. return this._nodesRef = new NodesRef(
  6197. this,
  6198. this._component,
  6199. selector,
  6200. true
  6201. );
  6202. }
  6203. selectAll(selector) {
  6204. return this._nodesRef = new NodesRef(
  6205. this,
  6206. this._component,
  6207. selector,
  6208. false
  6209. );
  6210. }
  6211. selectViewport() {
  6212. return this._nodesRef = new NodesRef(this, null, "", true);
  6213. }
  6214. _push(selector, component, single, fields2, callback) {
  6215. this._queue.push({
  6216. component,
  6217. selector,
  6218. single,
  6219. fields: fields2
  6220. });
  6221. this._queueCb.push(callback);
  6222. }
  6223. }
  6224. const createSelectorQuery = /* @__PURE__ */ defineSyncApi("createSelectorQuery", (context) => {
  6225. context = resolveComponentInstance(context);
  6226. if (context && !getPageIdByVm(context)) {
  6227. context = null;
  6228. }
  6229. return new SelectorQuery(context || getCurrentPageVm());
  6230. });
  6231. const API_CREATE_ANIMATION = "createAnimation";
  6232. const CreateAnimationOptions = {
  6233. // 目前参数校验不支持此api校验
  6234. formatArgs: {
  6235. /* duration: 400,
  6236. timingFunction(timingFunction, params) {
  6237. params.timingFunction = elemInArray(timingFunction, timingFunctions)
  6238. },
  6239. delay: 0,
  6240. transformOrigin: '50% 50% 0', */
  6241. }
  6242. };
  6243. const CreateAnimationProtocol = {
  6244. duration: Number,
  6245. timingFunction: String,
  6246. delay: Number,
  6247. transformOrigin: String
  6248. };
  6249. const defaultOption = {
  6250. duration: 400,
  6251. timingFunction: "linear",
  6252. delay: 0,
  6253. transformOrigin: "50% 50% 0"
  6254. };
  6255. class MPAnimation {
  6256. constructor(option) {
  6257. this.actions = [];
  6258. this.currentTransform = {};
  6259. this.currentStepAnimates = [];
  6260. this.option = extend({}, defaultOption, option);
  6261. }
  6262. _getOption(option) {
  6263. const _option = {
  6264. transition: extend({}, this.option, option),
  6265. transformOrigin: ""
  6266. };
  6267. _option.transformOrigin = _option.transition.transformOrigin;
  6268. delete _option.transition.transformOrigin;
  6269. return _option;
  6270. }
  6271. _pushAnimates(type, args) {
  6272. this.currentStepAnimates.push({
  6273. type,
  6274. args
  6275. });
  6276. }
  6277. _converType(type) {
  6278. return type.replace(/[A-Z]/g, (text2) => {
  6279. return `-${text2.toLowerCase()}`;
  6280. });
  6281. }
  6282. _getValue(value) {
  6283. return typeof value === "number" ? `${value}px` : value;
  6284. }
  6285. export() {
  6286. const actions = this.actions;
  6287. this.actions = [];
  6288. return {
  6289. actions
  6290. };
  6291. }
  6292. step(option) {
  6293. this.currentStepAnimates.forEach((animate) => {
  6294. if (animate.type !== "style") {
  6295. this.currentTransform[animate.type] = animate;
  6296. } else {
  6297. this.currentTransform[`${animate.type}.${animate.args[0]}`] = animate;
  6298. }
  6299. });
  6300. this.actions.push({
  6301. animates: Object.values(
  6302. this.currentTransform
  6303. ),
  6304. option: this._getOption(option)
  6305. });
  6306. this.currentStepAnimates = [];
  6307. return this;
  6308. }
  6309. }
  6310. const initAnimationProperty = /* @__PURE__ */ once(() => {
  6311. const animateTypes1 = [
  6312. "matrix",
  6313. "matrix3d",
  6314. "rotate",
  6315. "rotate3d",
  6316. "rotateX",
  6317. "rotateY",
  6318. "rotateZ",
  6319. "scale",
  6320. "scale3d",
  6321. "scaleX",
  6322. "scaleY",
  6323. "scaleZ",
  6324. "skew",
  6325. "skewX",
  6326. "skewY",
  6327. "translate",
  6328. "translate3d",
  6329. "translateX",
  6330. "translateY",
  6331. "translateZ"
  6332. ];
  6333. const animateTypes2 = ["opacity", "backgroundColor"];
  6334. const animateTypes3 = ["width", "height", "left", "right", "top", "bottom"];
  6335. animateTypes1.concat(animateTypes2, animateTypes3).forEach((type) => {
  6336. MPAnimation.prototype[type] = function(...args) {
  6337. if (animateTypes2.concat(animateTypes3).includes(type)) {
  6338. this._pushAnimates("style", [
  6339. this._converType(type),
  6340. animateTypes3.includes(type) ? this._getValue(args[0]) : args[0]
  6341. ]);
  6342. } else {
  6343. this._pushAnimates(type, args);
  6344. }
  6345. return this;
  6346. };
  6347. });
  6348. });
  6349. const createAnimation$1 = /* @__PURE__ */ defineSyncApi(
  6350. API_CREATE_ANIMATION,
  6351. (option) => {
  6352. initAnimationProperty();
  6353. return new MPAnimation(option);
  6354. },
  6355. CreateAnimationProtocol,
  6356. CreateAnimationOptions
  6357. );
  6358. const API_ON_TAB_BAR_MID_BUTTON_TAP = "onTabBarMidButtonTap";
  6359. const onTabBarMidButtonTap = /* @__PURE__ */ defineOnApi(
  6360. API_ON_TAB_BAR_MID_BUTTON_TAP,
  6361. () => {
  6362. }
  6363. );
  6364. const API_ON_WINDOW_RESIZE = "onWindowResize";
  6365. const API_OFF_WINDOW_RESIZE = "offWindowResize";
  6366. const onWindowResize = /* @__PURE__ */ defineOnApi(
  6367. API_ON_WINDOW_RESIZE,
  6368. () => {
  6369. }
  6370. );
  6371. const offWindowResize = /* @__PURE__ */ defineOffApi(
  6372. API_OFF_WINDOW_RESIZE,
  6373. () => {
  6374. }
  6375. );
  6376. const API_SET_LOCALE = "setLocale";
  6377. const API_GET_LOCALE = "getLocale";
  6378. const API_ON_LOCALE_CHANGE = "onLocaleChange";
  6379. const getLocale = /* @__PURE__ */ defineSyncApi(
  6380. API_GET_LOCALE,
  6381. () => {
  6382. const app = getApp({ allowDefault: true });
  6383. if (app && app.$vm) {
  6384. return app.$vm.$locale;
  6385. }
  6386. return useI18n().getLocale();
  6387. }
  6388. );
  6389. const onLocaleChange = /* @__PURE__ */ defineOnApi(
  6390. API_ON_LOCALE_CHANGE,
  6391. () => {
  6392. }
  6393. );
  6394. const setLocale = /* @__PURE__ */ defineSyncApi(
  6395. API_SET_LOCALE,
  6396. (locale) => {
  6397. const app = getApp();
  6398. if (!app) {
  6399. return false;
  6400. }
  6401. const oldLocale = app.$vm.$locale;
  6402. if (oldLocale !== locale) {
  6403. app.$vm.$locale = locale;
  6404. {
  6405. navigator.cookieEnabled && window.localStorage && (localStorage[UNI_STORAGE_LOCALE] = locale);
  6406. }
  6407. UniServiceJSBridge.invokeOnCallback(API_ON_LOCALE_CHANGE, { locale });
  6408. return true;
  6409. }
  6410. return false;
  6411. }
  6412. );
  6413. const API_SET_PAGE_META = "setPageMeta";
  6414. const setPageMeta = /* @__PURE__ */ defineAsyncApi(
  6415. API_SET_PAGE_META,
  6416. (options, { resolve }) => {
  6417. resolve(setCurrentPageMeta(getCurrentPageVm(), options));
  6418. }
  6419. );
  6420. const API_GET_SELECTED_TEXT_RANGE = "getSelectedTextRange";
  6421. const getSelectedTextRange$1 = /* @__PURE__ */ defineAsyncApi(
  6422. API_GET_SELECTED_TEXT_RANGE,
  6423. (_, { resolve, reject }) => {
  6424. UniServiceJSBridge.invokeViewMethod(API_GET_SELECTED_TEXT_RANGE, {}, getCurrentPageId(), (res) => {
  6425. if (typeof res.end === "undefined" && typeof res.start === "undefined") {
  6426. reject("no focused");
  6427. } else {
  6428. resolve(res);
  6429. }
  6430. });
  6431. }
  6432. );
  6433. const appHooks = {
  6434. [ON_UNHANDLE_REJECTION]: [],
  6435. [ON_PAGE_NOT_FOUND]: [],
  6436. [ON_ERROR]: [],
  6437. [ON_SHOW]: [],
  6438. [ON_HIDE]: []
  6439. };
  6440. function onAppHook(type, hook) {
  6441. const app = getApp({ allowDefault: true });
  6442. if (app && app.$vm) {
  6443. return injectHook(type, hook, app.$vm.$);
  6444. }
  6445. appHooks[type].push(hook);
  6446. }
  6447. function injectAppHooks(appInstance) {
  6448. Object.keys(appHooks).forEach((type) => {
  6449. appHooks[type].forEach((hook) => {
  6450. injectHook(type, hook, appInstance);
  6451. });
  6452. });
  6453. }
  6454. function offAppHook(type, hook) {
  6455. const app = getApp({ allowDefault: true });
  6456. if (app && app.$vm) {
  6457. return removeHook(app.$vm, type, hook);
  6458. }
  6459. remove(appHooks[type], hook);
  6460. }
  6461. function onUnhandledRejection(hook) {
  6462. onAppHook(ON_UNHANDLE_REJECTION, hook);
  6463. }
  6464. function offUnhandledRejection(hook) {
  6465. offAppHook(ON_UNHANDLE_REJECTION, hook);
  6466. }
  6467. function onPageNotFound(hook) {
  6468. onAppHook(ON_PAGE_NOT_FOUND, hook);
  6469. }
  6470. function offPageNotFound(hook) {
  6471. offAppHook(ON_PAGE_NOT_FOUND, hook);
  6472. }
  6473. function onError(hook) {
  6474. onAppHook(ON_ERROR, hook);
  6475. }
  6476. function offError(hook) {
  6477. offAppHook(ON_ERROR, hook);
  6478. }
  6479. function onAppShow(hook) {
  6480. onAppHook(ON_SHOW, hook);
  6481. }
  6482. function offAppShow(hook) {
  6483. offAppHook(ON_SHOW, hook);
  6484. }
  6485. function onAppHide(hook) {
  6486. onAppHook(ON_HIDE, hook);
  6487. }
  6488. function offAppHide(hook) {
  6489. offAppHook(ON_HIDE, hook);
  6490. }
  6491. const API_GET_ENTER_OPTIONS_SYNC = "getEnterOptionsSync";
  6492. const getEnterOptionsSync = /* @__PURE__ */ defineSyncApi(
  6493. API_GET_ENTER_OPTIONS_SYNC,
  6494. () => {
  6495. return getEnterOptions();
  6496. }
  6497. );
  6498. const API_GET_LAUNCH_OPTIONS_SYNC = "getLaunchOptionsSync";
  6499. const getLaunchOptionsSync = /* @__PURE__ */ defineSyncApi(
  6500. API_GET_LAUNCH_OPTIONS_SYNC,
  6501. () => {
  6502. return getLaunchOptions();
  6503. }
  6504. );
  6505. let cid;
  6506. let cidErrMsg;
  6507. let enabled;
  6508. function normalizePushMessage(message) {
  6509. try {
  6510. return JSON.parse(message);
  6511. } catch (e2) {
  6512. }
  6513. return message;
  6514. }
  6515. function invokePushCallback(args) {
  6516. if (args.type === "enabled") {
  6517. enabled = true;
  6518. } else if (args.type === "clientId") {
  6519. cid = args.cid;
  6520. cidErrMsg = args.errMsg;
  6521. invokeGetPushCidCallbacks(cid, args.errMsg);
  6522. } else if (args.type === "pushMsg") {
  6523. const message = {
  6524. type: "receive",
  6525. data: normalizePushMessage(args.message)
  6526. };
  6527. for (let i = 0; i < onPushMessageCallbacks.length; i++) {
  6528. const callback = onPushMessageCallbacks[i];
  6529. callback(message);
  6530. if (message.stopped) {
  6531. break;
  6532. }
  6533. }
  6534. } else if (args.type === "click") {
  6535. onPushMessageCallbacks.forEach((callback) => {
  6536. callback({
  6537. type: "click",
  6538. data: normalizePushMessage(args.message)
  6539. });
  6540. });
  6541. }
  6542. }
  6543. const getPushCidCallbacks = [];
  6544. function invokeGetPushCidCallbacks(cid2, errMsg) {
  6545. getPushCidCallbacks.forEach((callback) => {
  6546. callback(cid2, errMsg);
  6547. });
  6548. getPushCidCallbacks.length = 0;
  6549. }
  6550. const API_GET_PUSH_CLIENT_ID = "getPushClientId";
  6551. const getPushClientId = /* @__PURE__ */ defineAsyncApi(
  6552. API_GET_PUSH_CLIENT_ID,
  6553. (_, { resolve, reject }) => {
  6554. Promise.resolve().then(() => {
  6555. if (typeof enabled === "undefined") {
  6556. enabled = false;
  6557. cid = "";
  6558. cidErrMsg = "uniPush is not enabled";
  6559. }
  6560. getPushCidCallbacks.push((cid2, errMsg) => {
  6561. if (cid2) {
  6562. resolve({ cid: cid2 });
  6563. } else {
  6564. reject(errMsg);
  6565. }
  6566. });
  6567. if (typeof cid !== "undefined") {
  6568. invokeGetPushCidCallbacks(cid, cidErrMsg);
  6569. }
  6570. });
  6571. }
  6572. );
  6573. const onPushMessageCallbacks = [];
  6574. const onPushMessage = (fn) => {
  6575. if (onPushMessageCallbacks.indexOf(fn) === -1) {
  6576. onPushMessageCallbacks.push(fn);
  6577. }
  6578. };
  6579. const offPushMessage = (fn) => {
  6580. if (!fn) {
  6581. onPushMessageCallbacks.length = 0;
  6582. } else {
  6583. const index2 = onPushMessageCallbacks.indexOf(fn);
  6584. if (index2 > -1) {
  6585. onPushMessageCallbacks.splice(index2, 1);
  6586. }
  6587. }
  6588. };
  6589. const API_CAN_I_USE = "canIUse";
  6590. const CanIUseProtocol = [
  6591. {
  6592. name: "schema",
  6593. type: String,
  6594. required: true
  6595. }
  6596. ];
  6597. const API_MAKE_PHONE_CALL = "makePhoneCall";
  6598. const MakePhoneCallProtocol = {
  6599. phoneNumber: String
  6600. };
  6601. const API_GET_CLIPBOARD_DATA = "getClipboardData";
  6602. const API_SET_CLIPBOARD_DATA = "setClipboardData";
  6603. const SetClipboardDataOptions = {
  6604. formatArgs: {
  6605. showToast: true
  6606. },
  6607. beforeInvoke() {
  6608. initI18nSetClipboardDataMsgsOnce();
  6609. },
  6610. beforeSuccess(res, params) {
  6611. if (!params.showToast)
  6612. return;
  6613. const { t: t2 } = useI18n();
  6614. const title = t2("uni.setClipboardData.success");
  6615. if (title) {
  6616. uni.showToast({
  6617. title,
  6618. icon: "success",
  6619. mask: false
  6620. });
  6621. }
  6622. }
  6623. };
  6624. const SetClipboardDataProtocol = {
  6625. data: {
  6626. type: String,
  6627. required: true
  6628. },
  6629. showToast: {
  6630. type: Boolean
  6631. }
  6632. };
  6633. const API_ON_ACCELEROMETER = "onAccelerometer";
  6634. const API_OFF_ACCELEROMETER = "offAccelerometer";
  6635. const API_START_ACCELEROMETER = "startAccelerometer";
  6636. const API_STOP_ACCELEROMETER = "stopAccelerometer";
  6637. const API_ON_COMPASS = "onCompass";
  6638. const API_OFF_COMPASS = "offCompass";
  6639. const API_START_COMPASS = "startCompass";
  6640. const API_STOP_COMPASS = "stopCompass";
  6641. const API_VIBRATE_SHORT = "vibrateShort";
  6642. const API_VIBRATE_LONG = "vibrateLong";
  6643. const API_GET_STORAGE = "getStorage";
  6644. const GetStorageProtocol = {
  6645. key: {
  6646. type: String,
  6647. required: true
  6648. }
  6649. };
  6650. const API_GET_STORAGE_SYNC = "getStorageSync";
  6651. const GetStorageSyncProtocol = [
  6652. {
  6653. name: "key",
  6654. type: String,
  6655. required: true
  6656. }
  6657. ];
  6658. const API_SET_STORAGE = "setStorage";
  6659. const SetStorageProtocol = {
  6660. key: {
  6661. type: String,
  6662. required: true
  6663. },
  6664. data: {
  6665. required: true
  6666. }
  6667. };
  6668. const API_SET_STORAGE_SYNC = "setStorageSync";
  6669. const SetStorageSyncProtocol = [
  6670. {
  6671. name: "key",
  6672. type: String,
  6673. required: true
  6674. },
  6675. {
  6676. name: "data",
  6677. required: true
  6678. }
  6679. ];
  6680. const API_REMOVE_STORAGE = "removeStorage";
  6681. const RemoveStorageProtocol = GetStorageProtocol;
  6682. const RemoveStorageSyncProtocol = GetStorageSyncProtocol;
  6683. const API_GET_FILE_INFO = "getFileInfo";
  6684. const GetFileInfoOptions = {
  6685. formatArgs: {
  6686. filePath(filePath, params) {
  6687. params.filePath = getRealPath(filePath);
  6688. }
  6689. }
  6690. };
  6691. const GetFileInfoProtocol = {
  6692. filePath: {
  6693. type: String,
  6694. required: true
  6695. }
  6696. };
  6697. const API_OPEN_DOCUMENT = "openDocument";
  6698. const OpenDocumentOptions = {
  6699. formatArgs: {
  6700. filePath(filePath, params) {
  6701. params.filePath = getRealPath(filePath);
  6702. }
  6703. }
  6704. };
  6705. const OpenDocumentProtocol = {
  6706. filePath: {
  6707. type: String,
  6708. required: true
  6709. },
  6710. fileType: String
  6711. };
  6712. const API_HIDE_KEYBOARD = "hideKeyboard";
  6713. const API_CHOOSE_LOCATION = "chooseLocation";
  6714. const ChooseLocationProtocol = {
  6715. keyword: String,
  6716. latitude: Number,
  6717. longitude: Number
  6718. };
  6719. const API_GET_LOCATION = "getLocation";
  6720. const coordTypes$1 = ["wgs84", "gcj02"];
  6721. const GetLocationOptions = {
  6722. formatArgs: {
  6723. type(value, params) {
  6724. value = (value || "").toLowerCase();
  6725. if (coordTypes$1.indexOf(value) === -1) {
  6726. params.type = coordTypes$1[0];
  6727. } else {
  6728. params.type = value;
  6729. }
  6730. },
  6731. altitude(value, params) {
  6732. params.altitude = value ? value : false;
  6733. }
  6734. }
  6735. };
  6736. const GetLocationProtocol = {
  6737. type: String,
  6738. altitude: Boolean
  6739. };
  6740. const API_OPEN_LOCATION = "openLocation";
  6741. const checkProps = (key, value) => {
  6742. if (value === void 0) {
  6743. return `${key} should not be empty.`;
  6744. }
  6745. if (typeof value !== "number") {
  6746. let receivedType = typeof value;
  6747. receivedType = receivedType[0].toUpperCase() + receivedType.substring(1);
  6748. return `Expected Number, got ${receivedType} with value ${JSON.stringify(
  6749. value
  6750. )}.`;
  6751. }
  6752. };
  6753. const OpenLocationOptions = {
  6754. formatArgs: {
  6755. latitude(value, params) {
  6756. const checkedInfo = checkProps("latitude", value);
  6757. if (checkedInfo) {
  6758. return checkedInfo;
  6759. }
  6760. params.latitude = value;
  6761. },
  6762. longitude(value, params) {
  6763. const checkedInfo = checkProps("longitude", value);
  6764. if (checkedInfo) {
  6765. return checkedInfo;
  6766. }
  6767. params.longitude = value;
  6768. },
  6769. scale(value, params) {
  6770. value = Math.floor(value);
  6771. params.scale = value >= 5 && value <= 18 ? value : 18;
  6772. }
  6773. }
  6774. };
  6775. const OpenLocationProtocol = {
  6776. latitude: Number,
  6777. longitude: Number,
  6778. scale: Number,
  6779. name: String,
  6780. address: String
  6781. };
  6782. const API_CHOOSE_IMAGE = "chooseImage";
  6783. const ChooseImageOptions = {
  6784. formatArgs: {
  6785. count(value, params) {
  6786. if (!value || value <= 0) {
  6787. params.count = 9;
  6788. }
  6789. },
  6790. sizeType(sizeType, params) {
  6791. params.sizeType = elemsInArray(sizeType, CHOOSE_SIZE_TYPES);
  6792. },
  6793. sourceType(sourceType, params) {
  6794. params.sourceType = elemsInArray(sourceType, CHOOSE_SOURCE_TYPES);
  6795. },
  6796. extension(extension, params) {
  6797. if (extension instanceof Array && extension.length === 0) {
  6798. return "param extension should not be empty.";
  6799. }
  6800. if (!extension)
  6801. params.extension = ["*"];
  6802. }
  6803. }
  6804. };
  6805. const ChooseImageProtocol = {
  6806. count: Number,
  6807. sizeType: [Array, String],
  6808. sourceType: Array,
  6809. extension: Array
  6810. };
  6811. const API_CHOOSE_VIDEO = "chooseVideo";
  6812. const ChooseVideoOptions = {
  6813. formatArgs: {
  6814. sourceType(sourceType, params) {
  6815. params.sourceType = elemsInArray(sourceType, CHOOSE_SOURCE_TYPES);
  6816. },
  6817. compressed: true,
  6818. maxDuration: 60,
  6819. camera: "back",
  6820. extension(extension, params) {
  6821. if (extension instanceof Array && extension.length === 0) {
  6822. return "param extension should not be empty.";
  6823. }
  6824. if (!extension)
  6825. params.extension = ["*"];
  6826. }
  6827. }
  6828. };
  6829. const ChooseVideoProtocol = {
  6830. sourceType: Array,
  6831. compressed: Boolean,
  6832. maxDuration: Number,
  6833. camera: String,
  6834. extension: Array
  6835. };
  6836. const API_CHOOSE_FILE = "chooseFile";
  6837. const CHOOSE_MEDIA_TYPE = [
  6838. "all",
  6839. "image",
  6840. "video"
  6841. ];
  6842. const ChooseFileOptions = {
  6843. formatArgs: {
  6844. count(count, params) {
  6845. if (!count || count <= 0) {
  6846. params.count = 100;
  6847. }
  6848. },
  6849. sourceType(sourceType, params) {
  6850. params.sourceType = elemsInArray(sourceType, CHOOSE_SOURCE_TYPES);
  6851. },
  6852. type(type, params) {
  6853. params.type = elemInArray(type, CHOOSE_MEDIA_TYPE);
  6854. },
  6855. extension(extension, params) {
  6856. if (extension instanceof Array && extension.length === 0) {
  6857. return "param extension should not be empty.";
  6858. }
  6859. if (!extension)
  6860. params.extension = [""];
  6861. }
  6862. }
  6863. };
  6864. const ChooseFileProtocol = {
  6865. count: Number,
  6866. sourceType: Array,
  6867. type: String,
  6868. extension: Array
  6869. };
  6870. const API_GET_IMAGE_INFO = "getImageInfo";
  6871. const GetImageInfoOptions = {
  6872. formatArgs: {
  6873. src(src, params) {
  6874. params.src = getRealPath(src);
  6875. }
  6876. }
  6877. };
  6878. const GetImageInfoProtocol = {
  6879. src: {
  6880. type: String,
  6881. required: true
  6882. }
  6883. };
  6884. const API_PREVIEW_IMAGE = "previewImage";
  6885. const PreviewImageOptions = {
  6886. formatArgs: {
  6887. urls(urls, params) {
  6888. params.urls = urls.map(
  6889. (url) => isString(url) && url ? getRealPath(url) : ""
  6890. );
  6891. },
  6892. current(current, params) {
  6893. if (typeof current === "number") {
  6894. params.current = current > 0 && current < params.urls.length ? current : 0;
  6895. } else if (isString(current) && current) {
  6896. params.current = getRealPath(current);
  6897. }
  6898. }
  6899. }
  6900. };
  6901. const PreviewImageProtocol = {
  6902. urls: {
  6903. type: Array,
  6904. required: true
  6905. },
  6906. current: {
  6907. type: [Number, String]
  6908. }
  6909. };
  6910. const API_CLOSE_PREVIEW_IMAGE = "closePreviewImage";
  6911. const API_GET_VIDEO_INFO = "getVideoInfo";
  6912. const GetVideoInfoOptions = {
  6913. formatArgs: {
  6914. src(src, params) {
  6915. params.src = getRealPath(src);
  6916. }
  6917. }
  6918. };
  6919. const GetVideoInfoProtocol = {
  6920. src: {
  6921. type: String,
  6922. required: true
  6923. }
  6924. };
  6925. const API_SAVE_IMAGE_TO_PHOTOS_ALBUM = "saveImageToPhotosAlbum";
  6926. const API_SAVE_VIDEO_TO_PHOTOS_ALBUM = "saveVideoToPhotosAlbum";
  6927. const API_REQUEST = "request";
  6928. const dataType = {
  6929. JSON: "json"
  6930. };
  6931. const RESPONSE_TYPE = ["text", "arraybuffer"];
  6932. const DEFAULT_RESPONSE_TYPE = "text";
  6933. const encode = encodeURIComponent;
  6934. function stringifyQuery(url, data) {
  6935. let str = url.split("#");
  6936. const hash = str[1] || "";
  6937. str = str[0].split("?");
  6938. let query = str[1] || "";
  6939. url = str[0];
  6940. const search = query.split("&").filter((item) => item);
  6941. const params = {};
  6942. search.forEach((item) => {
  6943. const part = item.split("=");
  6944. params[part[0]] = part[1];
  6945. });
  6946. for (const key in data) {
  6947. if (hasOwn(data, key)) {
  6948. let v2 = data[key];
  6949. if (typeof v2 === "undefined" || v2 === null) {
  6950. v2 = "";
  6951. } else if (isPlainObject$1(v2)) {
  6952. v2 = JSON.stringify(v2);
  6953. }
  6954. params[encode(key)] = encode(v2);
  6955. }
  6956. }
  6957. query = Object.keys(params).map((item) => `${item}=${params[item]}`).join("&");
  6958. return url + (query ? "?" + query : "") + (hash ? "#" + hash : "");
  6959. }
  6960. const RequestProtocol = {
  6961. method: String,
  6962. data: [Object, String, Array, ArrayBuffer],
  6963. url: {
  6964. type: String,
  6965. required: true
  6966. },
  6967. header: Object,
  6968. dataType: String,
  6969. responseType: String,
  6970. withCredentials: Boolean
  6971. };
  6972. const RequestOptions = {
  6973. formatArgs: {
  6974. method(value, params) {
  6975. params.method = elemInArray(
  6976. (value || "").toUpperCase(),
  6977. HTTP_METHODS
  6978. );
  6979. },
  6980. data(value, params) {
  6981. params.data = value || "";
  6982. },
  6983. url(value, params) {
  6984. if (params.method === HTTP_METHODS[0] && isPlainObject$1(params.data) && Object.keys(params.data).length) {
  6985. params.url = stringifyQuery(value, params.data);
  6986. }
  6987. },
  6988. header(value, params) {
  6989. const header = params.header = value || {};
  6990. if (params.method !== HTTP_METHODS[0]) {
  6991. if (!Object.keys(header).find(
  6992. (key) => key.toLowerCase() === "content-type"
  6993. )) {
  6994. header["Content-Type"] = "application/json";
  6995. }
  6996. }
  6997. },
  6998. dataType(value, params) {
  6999. params.dataType = (value || dataType.JSON).toLowerCase();
  7000. },
  7001. responseType(value, params) {
  7002. params.responseType = (value || "").toLowerCase();
  7003. if (RESPONSE_TYPE.indexOf(params.responseType) === -1) {
  7004. params.responseType = DEFAULT_RESPONSE_TYPE;
  7005. }
  7006. }
  7007. }
  7008. };
  7009. const API_DOWNLOAD_FILE = "downloadFile";
  7010. const DownloadFileOptions = {
  7011. formatArgs: {
  7012. header(value, params) {
  7013. params.header = value || {};
  7014. }
  7015. }
  7016. };
  7017. const DownloadFileProtocol = {
  7018. url: {
  7019. type: String,
  7020. required: true
  7021. },
  7022. header: Object,
  7023. timeout: Number
  7024. };
  7025. const API_UPLOAD_FILE = "uploadFile";
  7026. const UploadFileOptions = {
  7027. formatArgs: {
  7028. filePath(filePath, params) {
  7029. if (filePath) {
  7030. params.filePath = getRealPath(filePath);
  7031. }
  7032. },
  7033. header(value, params) {
  7034. params.header = value || {};
  7035. },
  7036. formData(value, params) {
  7037. params.formData = value || {};
  7038. }
  7039. }
  7040. };
  7041. const UploadFileProtocol = {
  7042. url: {
  7043. type: String,
  7044. required: true
  7045. },
  7046. files: Array,
  7047. filePath: String,
  7048. name: String,
  7049. header: Object,
  7050. formData: Object,
  7051. timeout: Number
  7052. };
  7053. const API_CONNECT_SOCKET = "connectSocket";
  7054. const ConnectSocketOptions = {
  7055. formatArgs: {
  7056. header(value, params) {
  7057. params.header = value || {};
  7058. },
  7059. method(value, params) {
  7060. params.method = elemInArray(
  7061. (value || "").toUpperCase(),
  7062. HTTP_METHODS
  7063. );
  7064. },
  7065. protocols(protocols, params) {
  7066. if (isString(protocols)) {
  7067. params.protocols = [protocols];
  7068. }
  7069. }
  7070. }
  7071. };
  7072. const ConnectSocketProtocol = {
  7073. url: {
  7074. type: String,
  7075. required: true
  7076. },
  7077. header: {
  7078. type: Object
  7079. },
  7080. method: String,
  7081. protocols: [Array, String]
  7082. };
  7083. const API_SEND_SOCKET_MESSAGE = "sendSocketMessage";
  7084. const SendSocketMessageProtocol = {
  7085. data: [String, ArrayBuffer]
  7086. };
  7087. const API_CLOSE_SOCKET = "closeSocket";
  7088. const CloseSocketProtocol = {
  7089. code: Number,
  7090. reason: String
  7091. };
  7092. const API_START_LOCATION_UPDATE = "startLocationUpdate";
  7093. const API_ON_LOCATION_CHANGE = "onLocationChange";
  7094. const API_STOP_LOCATION_UPDATE = "stopLocationUpdate";
  7095. const API_OFF_LOCATION_CHANGE = "offLocationChange";
  7096. const API_OFF_LOCATION_CHANGE_ERROR = "offLocationChangeError";
  7097. const API_ON_LOCATION_CHANGE_ERROR = "onLocationChangeError";
  7098. const coordTypes = ["wgs84", "gcj02"];
  7099. const StartLocationUpdateProtocol = {
  7100. type: String
  7101. };
  7102. const StartLocationUpdateOptions = {
  7103. formatArgs: {
  7104. type(value, params) {
  7105. value = (value || "").toLowerCase();
  7106. if (coordTypes.indexOf(value) === -1) {
  7107. params.type = coordTypes[1];
  7108. } else {
  7109. params.type = value;
  7110. }
  7111. }
  7112. }
  7113. };
  7114. function encodeQueryString(url) {
  7115. if (!isString(url)) {
  7116. return url;
  7117. }
  7118. const index2 = url.indexOf("?");
  7119. if (index2 === -1) {
  7120. return url;
  7121. }
  7122. const query = url.slice(index2 + 1).trim().replace(/^(\?|#|&)/, "");
  7123. if (!query) {
  7124. return url;
  7125. }
  7126. url = url.slice(0, index2);
  7127. const params = [];
  7128. query.split("&").forEach((param) => {
  7129. const parts = param.replace(/\+/g, " ").split("=");
  7130. const key = parts.shift();
  7131. const val = parts.length > 0 ? parts.join("=") : "";
  7132. params.push(key + "=" + encodeURIComponent(val));
  7133. });
  7134. return params.length ? url + "?" + params.join("&") : url;
  7135. }
  7136. const ANIMATION_IN$1 = [
  7137. "slide-in-right",
  7138. "slide-in-left",
  7139. "slide-in-top",
  7140. "slide-in-bottom",
  7141. "fade-in",
  7142. "zoom-out",
  7143. "zoom-fade-out",
  7144. "pop-in",
  7145. "none"
  7146. ];
  7147. const ANIMATION_OUT$1 = [
  7148. "slide-out-right",
  7149. "slide-out-left",
  7150. "slide-out-top",
  7151. "slide-out-bottom",
  7152. "fade-out",
  7153. "zoom-in",
  7154. "zoom-fade-in",
  7155. "pop-out",
  7156. "none"
  7157. ];
  7158. const BaseRouteProtocol = {
  7159. url: {
  7160. type: String,
  7161. required: true
  7162. }
  7163. };
  7164. const API_NAVIGATE_TO = "navigateTo";
  7165. const API_REDIRECT_TO = "redirectTo";
  7166. const API_RE_LAUNCH = "reLaunch";
  7167. const API_SWITCH_TAB = "switchTab";
  7168. const API_NAVIGATE_BACK = "navigateBack";
  7169. const API_PRELOAD_PAGE = "preloadPage";
  7170. const API_UN_PRELOAD_PAGE = "unPreloadPage";
  7171. const NavigateToProtocol = /* @__PURE__ */ extend(
  7172. {},
  7173. BaseRouteProtocol,
  7174. createAnimationProtocol(ANIMATION_IN$1)
  7175. );
  7176. const NavigateBackProtocol = /* @__PURE__ */ extend(
  7177. {
  7178. delta: {
  7179. type: Number
  7180. }
  7181. },
  7182. createAnimationProtocol(ANIMATION_OUT$1)
  7183. );
  7184. const RedirectToProtocol = BaseRouteProtocol;
  7185. const ReLaunchProtocol = BaseRouteProtocol;
  7186. const SwitchTabProtocol = BaseRouteProtocol;
  7187. const PreloadPageProtocol = BaseRouteProtocol;
  7188. const NavigateToOptions = /* @__PURE__ */ createRouteOptions(API_NAVIGATE_TO);
  7189. const RedirectToOptions = /* @__PURE__ */ createRouteOptions(API_REDIRECT_TO);
  7190. const ReLaunchOptions = /* @__PURE__ */ createRouteOptions(API_RE_LAUNCH);
  7191. const SwitchTabOptions = /* @__PURE__ */ createRouteOptions(API_SWITCH_TAB);
  7192. const NavigateBackOptions = {
  7193. formatArgs: {
  7194. delta(value, params) {
  7195. value = parseInt(value + "") || 1;
  7196. params.delta = Math.min(getCurrentPages().length - 1, value);
  7197. }
  7198. }
  7199. };
  7200. function createAnimationProtocol(animationTypes) {
  7201. return {
  7202. animationType: {
  7203. type: String,
  7204. validator(type) {
  7205. if (type && animationTypes.indexOf(type) === -1) {
  7206. return "`" + type + "` is not supported for `animationType` (supported values are: `" + animationTypes.join("`|`") + "`)";
  7207. }
  7208. }
  7209. },
  7210. animationDuration: {
  7211. type: Number
  7212. }
  7213. };
  7214. }
  7215. let navigatorLock;
  7216. function beforeRoute() {
  7217. navigatorLock = "";
  7218. }
  7219. function createRouteOptions(type) {
  7220. return {
  7221. formatArgs: {
  7222. url: createNormalizeUrl(type)
  7223. },
  7224. beforeAll: beforeRoute
  7225. };
  7226. }
  7227. function createNormalizeUrl(type) {
  7228. return function normalizeUrl(url, params) {
  7229. if (!url) {
  7230. return `Missing required args: "url"`;
  7231. }
  7232. url = normalizeRoute(url);
  7233. const pagePath = url.split("?")[0];
  7234. const routeOptions = getRouteOptions(pagePath, true);
  7235. if (!routeOptions) {
  7236. return "page `" + url + "` is not found";
  7237. }
  7238. if (type === API_NAVIGATE_TO || type === API_REDIRECT_TO) {
  7239. if (routeOptions.meta.isTabBar) {
  7240. return `can not ${type} a tabbar page`;
  7241. }
  7242. } else if (type === API_SWITCH_TAB) {
  7243. if (!routeOptions.meta.isTabBar) {
  7244. return "can not switch to no-tabBar page";
  7245. }
  7246. }
  7247. if ((type === API_SWITCH_TAB || type === API_PRELOAD_PAGE) && routeOptions.meta.isTabBar && params.openType !== "appLaunch") {
  7248. url = pagePath;
  7249. }
  7250. if (routeOptions.meta.isEntry) {
  7251. url = url.replace(routeOptions.alias, "/");
  7252. }
  7253. params.url = encodeQueryString(url);
  7254. if (type === API_UN_PRELOAD_PAGE) {
  7255. return;
  7256. } else if (type === API_PRELOAD_PAGE) {
  7257. if (routeOptions.meta.isTabBar) {
  7258. const pages = getCurrentPages();
  7259. const tabBarPagePath = routeOptions.path.slice(1);
  7260. if (pages.find((page) => page.route === tabBarPagePath)) {
  7261. return "tabBar page `" + tabBarPagePath + "` already exists";
  7262. }
  7263. }
  7264. return;
  7265. }
  7266. if (navigatorLock === url && params.openType !== "appLaunch") {
  7267. return `${navigatorLock} locked`;
  7268. }
  7269. if (__uniConfig.ready) {
  7270. navigatorLock = url;
  7271. }
  7272. };
  7273. }
  7274. const API_HIDE_LOADING = "hideLoading";
  7275. const API_HIDE_TOAST = "hideToast";
  7276. const API_LOAD_FONT_FACE = "loadFontFace";
  7277. const LoadFontFaceProtocol = {
  7278. family: {
  7279. type: String,
  7280. required: true
  7281. },
  7282. source: {
  7283. type: String,
  7284. required: true
  7285. },
  7286. desc: Object
  7287. };
  7288. const FRONT_COLORS = ["#ffffff", "#000000"];
  7289. const API_SET_NAVIGATION_BAR_COLOR = "setNavigationBarColor";
  7290. const SetNavigationBarColorOptions = {
  7291. formatArgs: {
  7292. animation(animation2, params) {
  7293. if (!animation2) {
  7294. animation2 = { duration: 0, timingFunc: "linear" };
  7295. }
  7296. params.animation = {
  7297. duration: animation2.duration || 0,
  7298. timingFunc: animation2.timingFunc || "linear"
  7299. };
  7300. }
  7301. }
  7302. };
  7303. const SetNavigationBarColorProtocol = {
  7304. frontColor: {
  7305. type: String,
  7306. required: true,
  7307. validator(frontColor) {
  7308. if (FRONT_COLORS.indexOf(frontColor) === -1) {
  7309. return `invalid frontColor "${frontColor}"`;
  7310. }
  7311. }
  7312. },
  7313. backgroundColor: {
  7314. type: String,
  7315. required: true
  7316. },
  7317. animation: Object
  7318. };
  7319. const API_SET_NAVIGATION_BAR_TITLE = "setNavigationBarTitle";
  7320. const SetNavigationBarTitleProtocol = {
  7321. title: {
  7322. type: String,
  7323. required: true
  7324. }
  7325. };
  7326. const API_SHOW_NAVIGATION_BAR_LOADING = "showNavigationBarLoading";
  7327. const API_HIDE_NAVIGATION_BAR_LOADING = "hideNavigationBarLoading";
  7328. const API_PAGE_SCROLL_TO = "pageScrollTo";
  7329. const PageScrollToProtocol = {
  7330. scrollTop: Number,
  7331. selector: String,
  7332. duration: Number
  7333. };
  7334. const PageScrollToOptions = {
  7335. formatArgs: {
  7336. duration: 300
  7337. }
  7338. };
  7339. const API_SHOW_ACTION_SHEET = "showActionSheet";
  7340. const ShowActionSheetProtocol = {
  7341. itemList: {
  7342. type: Array,
  7343. required: true
  7344. },
  7345. title: String,
  7346. itemColor: String,
  7347. popover: Object
  7348. };
  7349. const ShowActionSheetOptions = {
  7350. formatArgs: {
  7351. itemColor: "#000"
  7352. }
  7353. };
  7354. const API_SHOW_LOADING = "showLoading";
  7355. const ShowLoadingProtocol = {
  7356. title: String,
  7357. mask: Boolean
  7358. };
  7359. const ShowLoadingOptions = {
  7360. formatArgs: {
  7361. title: "",
  7362. mask: false
  7363. }
  7364. };
  7365. const API_SHOW_MODAL = "showModal";
  7366. const ShowModalProtocol = {
  7367. title: String,
  7368. content: String,
  7369. showCancel: Boolean,
  7370. cancelText: String,
  7371. cancelColor: String,
  7372. confirmText: String,
  7373. confirmColor: String
  7374. };
  7375. const ShowModalOptions = {
  7376. beforeInvoke() {
  7377. initI18nShowModalMsgsOnce();
  7378. },
  7379. formatArgs: {
  7380. title: "",
  7381. content: "",
  7382. placeholderText: "",
  7383. showCancel: true,
  7384. editable: false,
  7385. cancelText(_value, params) {
  7386. if (!hasOwn(params, "cancelText")) {
  7387. const { t: t2 } = useI18n();
  7388. params.cancelText = t2("uni.showModal.cancel");
  7389. }
  7390. },
  7391. cancelColor: "#000",
  7392. confirmText(_value, params) {
  7393. if (!hasOwn(params, "confirmText")) {
  7394. const { t: t2 } = useI18n();
  7395. params.confirmText = t2("uni.showModal.confirm");
  7396. }
  7397. },
  7398. //@ts-expect-error
  7399. confirmColor: "#576b95"
  7400. }
  7401. };
  7402. const API_SHOW_TOAST = "showToast";
  7403. const SHOW_TOAST_ICON = [
  7404. "success",
  7405. "loading",
  7406. "none",
  7407. "error"
  7408. ];
  7409. const ShowToastProtocol = {
  7410. title: String,
  7411. icon: String,
  7412. image: String,
  7413. duration: Number,
  7414. mask: Boolean
  7415. };
  7416. const ShowToastOptions = {
  7417. formatArgs: {
  7418. title: "",
  7419. icon(type, params) {
  7420. params.icon = elemInArray(type, SHOW_TOAST_ICON);
  7421. },
  7422. image(value, params) {
  7423. if (value) {
  7424. params.image = getRealPath(value);
  7425. } else {
  7426. params.image = "";
  7427. }
  7428. },
  7429. duration: 1500,
  7430. mask: false
  7431. }
  7432. };
  7433. const API_START_PULL_DOWN_REFRESH = "startPullDownRefresh";
  7434. const API_STOP_PULL_DOWN_REFRESH = "stopPullDownRefresh";
  7435. const IndexProtocol = {
  7436. index: {
  7437. type: Number,
  7438. required: true
  7439. }
  7440. };
  7441. const IndexOptions = {
  7442. beforeInvoke() {
  7443. const pageMeta = getCurrentPageMeta();
  7444. if (pageMeta && !pageMeta.isTabBar) {
  7445. return "not TabBar page";
  7446. }
  7447. },
  7448. formatArgs: {
  7449. index(value) {
  7450. if (!__uniConfig.tabBar.list[value]) {
  7451. return "tabbar item not found";
  7452. }
  7453. }
  7454. }
  7455. };
  7456. const API_SET_TAB_BAR_ITEM = "setTabBarItem";
  7457. const SetTabBarItemProtocol = /* @__PURE__ */ extend(
  7458. {
  7459. text: String,
  7460. iconPath: String,
  7461. selectedIconPath: String,
  7462. pagePath: String
  7463. },
  7464. IndexProtocol
  7465. );
  7466. const SetTabBarItemOptions = {
  7467. beforeInvoke: IndexOptions.beforeInvoke,
  7468. formatArgs: /* @__PURE__ */ extend(
  7469. {
  7470. pagePath(value, params) {
  7471. if (value) {
  7472. params.pagePath = removeLeadingSlash(value);
  7473. }
  7474. }
  7475. },
  7476. IndexOptions.formatArgs
  7477. )
  7478. };
  7479. const API_SET_TAB_BAR_STYLE = "setTabBarStyle";
  7480. const SetTabBarStyleProtocol = {
  7481. color: String,
  7482. selectedColor: String,
  7483. backgroundColor: String,
  7484. backgroundImage: String,
  7485. backgroundRepeat: String,
  7486. borderStyle: String
  7487. };
  7488. const GRADIENT_RE = /^(linear|radial)-gradient\(.+?\);?$/;
  7489. const SetTabBarStyleOptions = {
  7490. beforeInvoke: IndexOptions.beforeInvoke,
  7491. formatArgs: {
  7492. backgroundImage(value, params) {
  7493. if (value && !GRADIENT_RE.test(value)) {
  7494. params.backgroundImage = getRealPath(value);
  7495. }
  7496. },
  7497. borderStyle(value, params) {
  7498. if (value) {
  7499. params.borderStyle = value === "white" ? "white" : "black";
  7500. }
  7501. }
  7502. }
  7503. };
  7504. const API_HIDE_TAB_BAR = "hideTabBar";
  7505. const HideTabBarProtocol = {
  7506. animation: Boolean
  7507. };
  7508. const API_SHOW_TAB_BAR = "showTabBar";
  7509. const ShowTabBarProtocol = HideTabBarProtocol;
  7510. const API_HIDE_TAB_BAR_RED_DOT = "hideTabBarRedDot";
  7511. const HideTabBarRedDotProtocol = IndexProtocol;
  7512. const HideTabBarRedDotOptions = IndexOptions;
  7513. const API_SHOW_TAB_BAR_RED_DOT = "showTabBarRedDot";
  7514. const ShowTabBarRedDotProtocol = IndexProtocol;
  7515. const ShowTabBarRedDotOptions = IndexOptions;
  7516. const API_REMOVE_TAB_BAR_BADGE = "removeTabBarBadge";
  7517. const RemoveTabBarBadgeProtocol = IndexProtocol;
  7518. const RemoveTabBarBadgeOptions = IndexOptions;
  7519. const API_SET_TAB_BAR_BADGE = "setTabBarBadge";
  7520. const SetTabBarBadgeProtocol = /* @__PURE__ */ extend(
  7521. {
  7522. text: {
  7523. type: String,
  7524. required: true
  7525. }
  7526. },
  7527. IndexProtocol
  7528. );
  7529. const SetTabBarBadgeOptions = {
  7530. beforeInvoke: IndexOptions.beforeInvoke,
  7531. formatArgs: /* @__PURE__ */ extend(
  7532. {
  7533. text(value, params) {
  7534. if (getLen(value) >= 4) {
  7535. params.text = "...";
  7536. }
  7537. }
  7538. },
  7539. IndexOptions.formatArgs
  7540. )
  7541. };
  7542. const initIntersectionObserverPolyfill = function() {
  7543. if (typeof window !== "object") {
  7544. return;
  7545. }
  7546. if ("IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
  7547. if (!("isIntersecting" in window.IntersectionObserverEntry.prototype)) {
  7548. Object.defineProperty(
  7549. window.IntersectionObserverEntry.prototype,
  7550. "isIntersecting",
  7551. {
  7552. get: function() {
  7553. return this.intersectionRatio > 0;
  7554. }
  7555. }
  7556. );
  7557. }
  7558. return;
  7559. }
  7560. function getFrameElement(doc) {
  7561. try {
  7562. return doc.defaultView && doc.defaultView.frameElement || null;
  7563. } catch (e2) {
  7564. return null;
  7565. }
  7566. }
  7567. var document2 = function(startDoc) {
  7568. var doc = startDoc;
  7569. var frame = getFrameElement(doc);
  7570. while (frame) {
  7571. doc = frame.ownerDocument;
  7572. frame = getFrameElement(doc);
  7573. }
  7574. return doc;
  7575. }(window.document);
  7576. var registry = [];
  7577. var crossOriginUpdater = null;
  7578. var crossOriginRect = null;
  7579. function IntersectionObserverEntry(entry) {
  7580. this.time = entry.time;
  7581. this.target = entry.target;
  7582. this.rootBounds = ensureDOMRect(entry.rootBounds);
  7583. this.boundingClientRect = ensureDOMRect(entry.boundingClientRect);
  7584. this.intersectionRect = ensureDOMRect(
  7585. entry.intersectionRect || getEmptyRect()
  7586. );
  7587. this.isIntersecting = !!entry.intersectionRect;
  7588. var targetRect = this.boundingClientRect;
  7589. var targetArea = targetRect.width * targetRect.height;
  7590. var intersectionRect = this.intersectionRect;
  7591. var intersectionArea = intersectionRect.width * intersectionRect.height;
  7592. if (targetArea) {
  7593. this.intersectionRatio = Number(
  7594. (intersectionArea / targetArea).toFixed(4)
  7595. );
  7596. } else {
  7597. this.intersectionRatio = this.isIntersecting ? 1 : 0;
  7598. }
  7599. }
  7600. function IntersectionObserver2(callback, opt_options) {
  7601. var options = opt_options || {};
  7602. if (typeof callback != "function") {
  7603. throw new Error("callback must be a function");
  7604. }
  7605. if (options.root && options.root.nodeType != 1 && options.root.nodeType != 9) {
  7606. throw new Error("root must be a Document or Element");
  7607. }
  7608. this._checkForIntersections = throttle2(
  7609. this._checkForIntersections.bind(this),
  7610. this.THROTTLE_TIMEOUT
  7611. );
  7612. this._callback = callback;
  7613. this._observationTargets = [];
  7614. this._queuedEntries = [];
  7615. this._rootMarginValues = this._parseRootMargin(options.rootMargin);
  7616. this.thresholds = this._initThresholds(options.threshold);
  7617. this.root = options.root || null;
  7618. this.rootMargin = this._rootMarginValues.map(function(margin) {
  7619. return margin.value + margin.unit;
  7620. }).join(" ");
  7621. this._monitoringDocuments = [];
  7622. this._monitoringUnsubscribes = [];
  7623. }
  7624. IntersectionObserver2.prototype.THROTTLE_TIMEOUT = 100;
  7625. IntersectionObserver2.prototype.POLL_INTERVAL = null;
  7626. IntersectionObserver2.prototype.USE_MUTATION_OBSERVER = true;
  7627. IntersectionObserver2._setupCrossOriginUpdater = function() {
  7628. if (!crossOriginUpdater) {
  7629. crossOriginUpdater = function(boundingClientRect, intersectionRect) {
  7630. if (!boundingClientRect || !intersectionRect) {
  7631. crossOriginRect = getEmptyRect();
  7632. } else {
  7633. crossOriginRect = convertFromParentRect(
  7634. boundingClientRect,
  7635. intersectionRect
  7636. );
  7637. }
  7638. registry.forEach(function(observer) {
  7639. observer._checkForIntersections();
  7640. });
  7641. };
  7642. }
  7643. return crossOriginUpdater;
  7644. };
  7645. IntersectionObserver2._resetCrossOriginUpdater = function() {
  7646. crossOriginUpdater = null;
  7647. crossOriginRect = null;
  7648. };
  7649. IntersectionObserver2.prototype.observe = function(target) {
  7650. var isTargetAlreadyObserved = this._observationTargets.some(function(item) {
  7651. return item.element == target;
  7652. });
  7653. if (isTargetAlreadyObserved) {
  7654. return;
  7655. }
  7656. if (!(target && target.nodeType == 1)) {
  7657. throw new Error("target must be an Element");
  7658. }
  7659. this._registerInstance();
  7660. this._observationTargets.push({ element: target, entry: null });
  7661. this._monitorIntersections(target.ownerDocument);
  7662. this._checkForIntersections();
  7663. };
  7664. IntersectionObserver2.prototype.unobserve = function(target) {
  7665. this._observationTargets = this._observationTargets.filter(function(item) {
  7666. return item.element != target;
  7667. });
  7668. this._unmonitorIntersections(target.ownerDocument);
  7669. if (this._observationTargets.length == 0) {
  7670. this._unregisterInstance();
  7671. }
  7672. };
  7673. IntersectionObserver2.prototype.disconnect = function() {
  7674. this._observationTargets = [];
  7675. this._unmonitorAllIntersections();
  7676. this._unregisterInstance();
  7677. };
  7678. IntersectionObserver2.prototype.takeRecords = function() {
  7679. var records = this._queuedEntries.slice();
  7680. this._queuedEntries = [];
  7681. return records;
  7682. };
  7683. IntersectionObserver2.prototype._initThresholds = function(opt_threshold) {
  7684. var threshold = opt_threshold || [0];
  7685. if (!Array.isArray(threshold))
  7686. threshold = [threshold];
  7687. return threshold.sort().filter(function(t2, i, a2) {
  7688. if (typeof t2 != "number" || isNaN(t2) || t2 < 0 || t2 > 1) {
  7689. throw new Error(
  7690. "threshold must be a number between 0 and 1 inclusively"
  7691. );
  7692. }
  7693. return t2 !== a2[i - 1];
  7694. });
  7695. };
  7696. IntersectionObserver2.prototype._parseRootMargin = function(opt_rootMargin) {
  7697. var marginString = opt_rootMargin || "0px";
  7698. var margins = marginString.split(/\s+/).map(function(margin) {
  7699. var parts = /^(-?\d*\.?\d+)(px|%)$/.exec(margin);
  7700. if (!parts) {
  7701. throw new Error("rootMargin must be specified in pixels or percent");
  7702. }
  7703. return { value: parseFloat(parts[1]), unit: parts[2] };
  7704. });
  7705. margins[1] = margins[1] || margins[0];
  7706. margins[2] = margins[2] || margins[0];
  7707. margins[3] = margins[3] || margins[1];
  7708. return margins;
  7709. };
  7710. IntersectionObserver2.prototype._monitorIntersections = function(doc) {
  7711. var win = doc.defaultView;
  7712. if (!win) {
  7713. return;
  7714. }
  7715. if (this._monitoringDocuments.indexOf(doc) != -1) {
  7716. return;
  7717. }
  7718. var callback = this._checkForIntersections;
  7719. var monitoringInterval = null;
  7720. var domObserver = null;
  7721. if (this.POLL_INTERVAL) {
  7722. monitoringInterval = win.setInterval(callback, this.POLL_INTERVAL);
  7723. } else {
  7724. addEvent(win, "resize", callback, true);
  7725. addEvent(doc, "scroll", callback, true);
  7726. if (this.USE_MUTATION_OBSERVER && "MutationObserver" in win) {
  7727. domObserver = new win.MutationObserver(callback);
  7728. domObserver.observe(doc, {
  7729. attributes: true,
  7730. childList: true,
  7731. characterData: true,
  7732. subtree: true
  7733. });
  7734. }
  7735. }
  7736. this._monitoringDocuments.push(doc);
  7737. this._monitoringUnsubscribes.push(function() {
  7738. var win2 = doc.defaultView;
  7739. if (win2) {
  7740. if (monitoringInterval) {
  7741. win2.clearInterval(monitoringInterval);
  7742. }
  7743. removeEvent(win2, "resize", callback, true);
  7744. }
  7745. removeEvent(doc, "scroll", callback, true);
  7746. if (domObserver) {
  7747. domObserver.disconnect();
  7748. }
  7749. });
  7750. var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2;
  7751. if (doc != rootDoc) {
  7752. var frame = getFrameElement(doc);
  7753. if (frame) {
  7754. this._monitorIntersections(frame.ownerDocument);
  7755. }
  7756. }
  7757. };
  7758. IntersectionObserver2.prototype._unmonitorIntersections = function(doc) {
  7759. var index2 = this._monitoringDocuments.indexOf(doc);
  7760. if (index2 == -1) {
  7761. return;
  7762. }
  7763. var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2;
  7764. var hasDependentTargets = this._observationTargets.some(function(item) {
  7765. var itemDoc = item.element.ownerDocument;
  7766. if (itemDoc == doc) {
  7767. return true;
  7768. }
  7769. while (itemDoc && itemDoc != rootDoc) {
  7770. var frame2 = getFrameElement(itemDoc);
  7771. itemDoc = frame2 && frame2.ownerDocument;
  7772. if (itemDoc == doc) {
  7773. return true;
  7774. }
  7775. }
  7776. return false;
  7777. });
  7778. if (hasDependentTargets) {
  7779. return;
  7780. }
  7781. var unsubscribe = this._monitoringUnsubscribes[index2];
  7782. this._monitoringDocuments.splice(index2, 1);
  7783. this._monitoringUnsubscribes.splice(index2, 1);
  7784. unsubscribe();
  7785. if (doc != rootDoc) {
  7786. var frame = getFrameElement(doc);
  7787. if (frame) {
  7788. this._unmonitorIntersections(frame.ownerDocument);
  7789. }
  7790. }
  7791. };
  7792. IntersectionObserver2.prototype._unmonitorAllIntersections = function() {
  7793. var unsubscribes = this._monitoringUnsubscribes.slice(0);
  7794. this._monitoringDocuments.length = 0;
  7795. this._monitoringUnsubscribes.length = 0;
  7796. for (var i = 0; i < unsubscribes.length; i++) {
  7797. unsubscribes[i]();
  7798. }
  7799. };
  7800. IntersectionObserver2.prototype._checkForIntersections = function() {
  7801. if (!this.root && crossOriginUpdater && !crossOriginRect) {
  7802. return;
  7803. }
  7804. var rootIsInDom = this._rootIsInDom();
  7805. var rootRect = rootIsInDom ? this._getRootRect() : getEmptyRect();
  7806. this._observationTargets.forEach(function(item) {
  7807. var target = item.element;
  7808. var targetRect = getBoundingClientRect(target);
  7809. var rootContainsTarget = this._rootContainsTarget(target);
  7810. var oldEntry = item.entry;
  7811. var intersectionRect = rootIsInDom && rootContainsTarget && this._computeTargetAndRootIntersection(target, targetRect, rootRect);
  7812. var rootBounds = null;
  7813. if (!this._rootContainsTarget(target)) {
  7814. rootBounds = getEmptyRect();
  7815. } else if (!crossOriginUpdater || this.root) {
  7816. rootBounds = rootRect;
  7817. }
  7818. var newEntry = item.entry = new IntersectionObserverEntry({
  7819. time: now(),
  7820. target,
  7821. boundingClientRect: targetRect,
  7822. rootBounds,
  7823. intersectionRect
  7824. });
  7825. if (!oldEntry) {
  7826. this._queuedEntries.push(newEntry);
  7827. } else if (rootIsInDom && rootContainsTarget) {
  7828. if (this._hasCrossedThreshold(oldEntry, newEntry)) {
  7829. this._queuedEntries.push(newEntry);
  7830. }
  7831. } else {
  7832. if (oldEntry && oldEntry.isIntersecting) {
  7833. this._queuedEntries.push(newEntry);
  7834. }
  7835. }
  7836. }, this);
  7837. if (this._queuedEntries.length) {
  7838. this._callback(this.takeRecords(), this);
  7839. }
  7840. };
  7841. IntersectionObserver2.prototype._computeTargetAndRootIntersection = function(target, targetRect, rootRect) {
  7842. if (window.getComputedStyle(target).display == "none")
  7843. return;
  7844. var intersectionRect = targetRect;
  7845. var parent = getParentNode(target);
  7846. var atRoot = false;
  7847. while (!atRoot && parent) {
  7848. var parentRect = null;
  7849. var parentComputedStyle = parent.nodeType == 1 ? window.getComputedStyle(parent) : {};
  7850. if (parentComputedStyle.display == "none")
  7851. return null;
  7852. if (parent == this.root || parent.nodeType == /* DOCUMENT */
  7853. 9) {
  7854. atRoot = true;
  7855. if (parent == this.root || parent == document2) {
  7856. if (crossOriginUpdater && !this.root) {
  7857. if (!crossOriginRect || crossOriginRect.width == 0 && crossOriginRect.height == 0) {
  7858. parent = null;
  7859. parentRect = null;
  7860. intersectionRect = null;
  7861. } else {
  7862. parentRect = crossOriginRect;
  7863. }
  7864. } else {
  7865. parentRect = rootRect;
  7866. }
  7867. } else {
  7868. var frame = getParentNode(parent);
  7869. var frameRect = frame && getBoundingClientRect(frame);
  7870. var frameIntersect = frame && this._computeTargetAndRootIntersection(frame, frameRect, rootRect);
  7871. if (frameRect && frameIntersect) {
  7872. parent = frame;
  7873. parentRect = convertFromParentRect(frameRect, frameIntersect);
  7874. } else {
  7875. parent = null;
  7876. intersectionRect = null;
  7877. }
  7878. }
  7879. } else {
  7880. var doc = parent.ownerDocument;
  7881. if (parent != doc.body && parent != doc.documentElement && parentComputedStyle.overflow != "visible") {
  7882. parentRect = getBoundingClientRect(parent);
  7883. }
  7884. }
  7885. if (parentRect) {
  7886. intersectionRect = computeRectIntersection(parentRect, intersectionRect);
  7887. }
  7888. if (!intersectionRect)
  7889. break;
  7890. parent = parent && getParentNode(parent);
  7891. }
  7892. return intersectionRect;
  7893. };
  7894. IntersectionObserver2.prototype._getRootRect = function() {
  7895. var rootRect;
  7896. if (this.root && !isDoc(this.root)) {
  7897. rootRect = getBoundingClientRect(this.root);
  7898. } else {
  7899. var doc = isDoc(this.root) ? this.root : document2;
  7900. var html = doc.documentElement;
  7901. var body = doc.body;
  7902. rootRect = {
  7903. top: 0,
  7904. left: 0,
  7905. right: html.clientWidth || body.clientWidth,
  7906. width: html.clientWidth || body.clientWidth,
  7907. bottom: html.clientHeight || body.clientHeight,
  7908. height: html.clientHeight || body.clientHeight
  7909. };
  7910. }
  7911. return this._expandRectByRootMargin(rootRect);
  7912. };
  7913. IntersectionObserver2.prototype._expandRectByRootMargin = function(rect) {
  7914. var margins = this._rootMarginValues.map(function(margin, i) {
  7915. return margin.unit == "px" ? margin.value : margin.value * (i % 2 ? rect.width : rect.height) / 100;
  7916. });
  7917. var newRect = {
  7918. top: rect.top - margins[0],
  7919. right: rect.right + margins[1],
  7920. bottom: rect.bottom + margins[2],
  7921. left: rect.left - margins[3]
  7922. };
  7923. newRect.width = newRect.right - newRect.left;
  7924. newRect.height = newRect.bottom - newRect.top;
  7925. return newRect;
  7926. };
  7927. IntersectionObserver2.prototype._hasCrossedThreshold = function(oldEntry, newEntry) {
  7928. var oldRatio = oldEntry && oldEntry.isIntersecting ? oldEntry.intersectionRatio || 0 : -1;
  7929. var newRatio = newEntry.isIntersecting ? newEntry.intersectionRatio || 0 : -1;
  7930. if (oldRatio === newRatio)
  7931. return;
  7932. for (var i = 0; i < this.thresholds.length; i++) {
  7933. var threshold = this.thresholds[i];
  7934. if (threshold == oldRatio || threshold == newRatio || threshold < oldRatio !== threshold < newRatio) {
  7935. return true;
  7936. }
  7937. }
  7938. };
  7939. IntersectionObserver2.prototype._rootIsInDom = function() {
  7940. return !this.root || containsDeep(document2, this.root);
  7941. };
  7942. IntersectionObserver2.prototype._rootContainsTarget = function(target) {
  7943. var rootDoc = this.root && (this.root.ownerDocument || this.root) || document2;
  7944. return containsDeep(rootDoc, target) && (!this.root || rootDoc == target.ownerDocument);
  7945. };
  7946. IntersectionObserver2.prototype._registerInstance = function() {
  7947. if (registry.indexOf(this) < 0) {
  7948. registry.push(this);
  7949. }
  7950. };
  7951. IntersectionObserver2.prototype._unregisterInstance = function() {
  7952. var index2 = registry.indexOf(this);
  7953. if (index2 != -1)
  7954. registry.splice(index2, 1);
  7955. };
  7956. function now() {
  7957. return window.performance && performance.now && performance.now();
  7958. }
  7959. function throttle2(fn, timeout) {
  7960. var timer = null;
  7961. return function() {
  7962. if (!timer) {
  7963. timer = setTimeout(function() {
  7964. fn();
  7965. timer = null;
  7966. }, timeout);
  7967. }
  7968. };
  7969. }
  7970. function addEvent(node, event, fn, opt_useCapture) {
  7971. if (typeof node.addEventListener == "function") {
  7972. node.addEventListener(event, fn, opt_useCapture || false);
  7973. } else if (typeof node.attachEvent == "function") {
  7974. node.attachEvent("on" + event, fn);
  7975. }
  7976. }
  7977. function removeEvent(node, event, fn, opt_useCapture) {
  7978. if (typeof node.removeEventListener == "function") {
  7979. node.removeEventListener(event, fn, opt_useCapture || false);
  7980. } else if (typeof node.detatchEvent == "function") {
  7981. node.detatchEvent("on" + event, fn);
  7982. }
  7983. }
  7984. function computeRectIntersection(rect1, rect2) {
  7985. var top = Math.max(rect1.top, rect2.top);
  7986. var bottom = Math.min(rect1.bottom, rect2.bottom);
  7987. var left = Math.max(rect1.left, rect2.left);
  7988. var right = Math.min(rect1.right, rect2.right);
  7989. var width = right - left;
  7990. var height = bottom - top;
  7991. return width >= 0 && height >= 0 && {
  7992. top,
  7993. bottom,
  7994. left,
  7995. right,
  7996. width,
  7997. height
  7998. } || null;
  7999. }
  8000. function getBoundingClientRect(el) {
  8001. var rect;
  8002. try {
  8003. rect = el.getBoundingClientRect();
  8004. } catch (err) {
  8005. }
  8006. if (!rect)
  8007. return getEmptyRect();
  8008. if (!(rect.width && rect.height)) {
  8009. rect = {
  8010. top: rect.top,
  8011. right: rect.right,
  8012. bottom: rect.bottom,
  8013. left: rect.left,
  8014. width: rect.right - rect.left,
  8015. height: rect.bottom - rect.top
  8016. };
  8017. }
  8018. return rect;
  8019. }
  8020. function getEmptyRect() {
  8021. return {
  8022. top: 0,
  8023. bottom: 0,
  8024. left: 0,
  8025. right: 0,
  8026. width: 0,
  8027. height: 0
  8028. };
  8029. }
  8030. function ensureDOMRect(rect) {
  8031. if (!rect || "x" in rect) {
  8032. return rect;
  8033. }
  8034. return {
  8035. top: rect.top,
  8036. y: rect.top,
  8037. bottom: rect.bottom,
  8038. left: rect.left,
  8039. x: rect.left,
  8040. right: rect.right,
  8041. width: rect.width,
  8042. height: rect.height
  8043. };
  8044. }
  8045. function convertFromParentRect(parentBoundingRect, parentIntersectionRect) {
  8046. var top = parentIntersectionRect.top - parentBoundingRect.top;
  8047. var left = parentIntersectionRect.left - parentBoundingRect.left;
  8048. return {
  8049. top,
  8050. left,
  8051. height: parentIntersectionRect.height,
  8052. width: parentIntersectionRect.width,
  8053. bottom: top + parentIntersectionRect.height,
  8054. right: left + parentIntersectionRect.width
  8055. };
  8056. }
  8057. function containsDeep(parent, child) {
  8058. var node = child;
  8059. while (node) {
  8060. if (node == parent)
  8061. return true;
  8062. node = getParentNode(node);
  8063. }
  8064. return false;
  8065. }
  8066. function getParentNode(node) {
  8067. var parent = node.parentNode;
  8068. if (node.nodeType == /* DOCUMENT */
  8069. 9 && node != document2) {
  8070. return getFrameElement(node);
  8071. }
  8072. if (parent && parent.assignedSlot) {
  8073. parent = parent.assignedSlot.parentNode;
  8074. }
  8075. if (parent && parent.nodeType == 11 && parent.host) {
  8076. return parent.host;
  8077. }
  8078. return parent;
  8079. }
  8080. function isDoc(node) {
  8081. return node && node.nodeType === 9;
  8082. }
  8083. window.IntersectionObserver = IntersectionObserver2;
  8084. window.IntersectionObserverEntry = IntersectionObserverEntry;
  8085. };
  8086. function normalizeRect(rect) {
  8087. const { bottom, height, left, right, top, width } = rect || {};
  8088. return {
  8089. bottom,
  8090. height,
  8091. left,
  8092. right,
  8093. top,
  8094. width
  8095. };
  8096. }
  8097. function rectifyIntersectionRatio(entrie) {
  8098. const {
  8099. intersectionRatio,
  8100. boundingClientRect: { height: overAllHeight, width: overAllWidth },
  8101. intersectionRect: { height: intersectionHeight, width: intersectionWidth }
  8102. } = entrie;
  8103. if (intersectionRatio !== 0)
  8104. return intersectionRatio;
  8105. return intersectionHeight === overAllHeight ? intersectionWidth / overAllWidth : intersectionHeight / overAllHeight;
  8106. }
  8107. function requestComponentObserver($el, options, callback) {
  8108. initIntersectionObserverPolyfill();
  8109. const root = options.relativeToSelector ? $el.querySelector(options.relativeToSelector) : null;
  8110. const intersectionObserver = new IntersectionObserver(
  8111. (entries2) => {
  8112. entries2.forEach((entrie) => {
  8113. callback({
  8114. intersectionRatio: rectifyIntersectionRatio(entrie),
  8115. intersectionRect: normalizeRect(entrie.intersectionRect),
  8116. boundingClientRect: normalizeRect(entrie.boundingClientRect),
  8117. relativeRect: normalizeRect(entrie.rootBounds),
  8118. time: Date.now(),
  8119. dataset: getCustomDataset(entrie.target),
  8120. id: entrie.target.id
  8121. });
  8122. });
  8123. },
  8124. {
  8125. root,
  8126. rootMargin: options.rootMargin,
  8127. threshold: options.thresholds
  8128. }
  8129. );
  8130. if (options.observeAll) {
  8131. intersectionObserver.USE_MUTATION_OBSERVER = true;
  8132. const nodeList = $el.querySelectorAll(options.selector);
  8133. for (let i = 0; i < nodeList.length; i++) {
  8134. intersectionObserver.observe(nodeList[i]);
  8135. }
  8136. } else {
  8137. intersectionObserver.USE_MUTATION_OBSERVER = false;
  8138. const el = $el.querySelector(options.selector);
  8139. if (!el) {
  8140. console.warn(
  8141. `Node ${options.selector} is not found. Intersection observer will not trigger.`
  8142. );
  8143. } else {
  8144. intersectionObserver.observe(el);
  8145. }
  8146. }
  8147. return intersectionObserver;
  8148. }
  8149. function addIntersectionObserver({ reqId, component, options, callback }, _pageId) {
  8150. const $el = findElem(component);
  8151. ($el.__io || ($el.__io = {}))[reqId] = requestComponentObserver(
  8152. $el,
  8153. options,
  8154. callback
  8155. );
  8156. }
  8157. function removeIntersectionObserver({ reqId, component }, _pageId) {
  8158. const $el = findElem(component);
  8159. const intersectionObserver = $el.__io && $el.__io[reqId];
  8160. if (intersectionObserver) {
  8161. intersectionObserver.disconnect();
  8162. delete $el.__io[reqId];
  8163. }
  8164. }
  8165. let mediaQueryObservers = {};
  8166. let listeners = {};
  8167. function handleMediaQueryStr($props) {
  8168. const mediaQueryArr = [];
  8169. const propsMenu = [
  8170. "width",
  8171. "minWidth",
  8172. "maxWidth",
  8173. "height",
  8174. "minHeight",
  8175. "maxHeight",
  8176. "orientation"
  8177. ];
  8178. for (const item of propsMenu) {
  8179. if (item !== "orientation" && $props[item] && Number($props[item] >= 0)) {
  8180. mediaQueryArr.push(
  8181. `(${humpToLine(item)}: ${Number(
  8182. $props[item]
  8183. )}px)`
  8184. );
  8185. }
  8186. if (item === "orientation" && $props[item]) {
  8187. mediaQueryArr.push(`(${humpToLine(item)}: ${$props[item]})`);
  8188. }
  8189. }
  8190. const mediaQueryStr = mediaQueryArr.join(" and ");
  8191. return mediaQueryStr;
  8192. }
  8193. function humpToLine(name) {
  8194. return name.replace(/([A-Z])/g, "-$1").toLowerCase();
  8195. }
  8196. function addMediaQueryObserver({ reqId, component, options, callback }, _pageId) {
  8197. const mediaQueryObserver = mediaQueryObservers[reqId] = window.matchMedia(
  8198. handleMediaQueryStr(options)
  8199. );
  8200. const listener2 = listeners[reqId] = (observer) => callback(observer.matches);
  8201. listener2(mediaQueryObserver);
  8202. mediaQueryObserver.addListener(listener2);
  8203. }
  8204. function removeMediaQueryObserver({ reqId, component }, _pageId) {
  8205. const listener2 = listeners[reqId];
  8206. const mediaQueryObserver = mediaQueryObservers[reqId];
  8207. if (mediaQueryObserver) {
  8208. mediaQueryObserver.removeListener(listener2);
  8209. delete listeners[reqId];
  8210. delete mediaQueryObservers[reqId];
  8211. }
  8212. }
  8213. const files = {};
  8214. function urlToFile(url, local) {
  8215. const file = files[url];
  8216. if (file) {
  8217. return Promise.resolve(file);
  8218. }
  8219. if (/^data:[a-z-]+\/[a-z-]+;base64,/.test(url)) {
  8220. return Promise.resolve(base64ToFile(url));
  8221. }
  8222. if (local) {
  8223. return Promise.reject(new Error("not find"));
  8224. }
  8225. return new Promise((resolve, reject) => {
  8226. const xhr = new XMLHttpRequest();
  8227. xhr.open("GET", url, true);
  8228. xhr.responseType = "blob";
  8229. xhr.onload = function() {
  8230. resolve(this.response);
  8231. };
  8232. xhr.onerror = reject;
  8233. xhr.send();
  8234. });
  8235. }
  8236. function base64ToFile(base64) {
  8237. const base64Array = base64.split(",");
  8238. const res = base64Array[0].match(/:(.*?);/);
  8239. const type = res ? res[1] : "";
  8240. const str = atob(base64Array[1]);
  8241. let n = str.length;
  8242. const array = new Uint8Array(n);
  8243. while (n--) {
  8244. array[n] = str.charCodeAt(n);
  8245. }
  8246. return blobToFile(array, type);
  8247. }
  8248. function getExtname(type) {
  8249. const extname = type.split("/")[1];
  8250. return extname ? `.${extname}` : "";
  8251. }
  8252. function getFileName(url) {
  8253. url = url.split("#")[0].split("?")[0];
  8254. const array = url.split("/");
  8255. return array[array.length - 1];
  8256. }
  8257. function blobToFile(blob, type) {
  8258. let file;
  8259. if (blob instanceof File) {
  8260. file = blob;
  8261. } else {
  8262. type = type || blob.type || "";
  8263. const filename = `${Date.now()}${getExtname(type)}`;
  8264. try {
  8265. file = new File([blob], filename, { type });
  8266. } catch (error) {
  8267. blob = blob instanceof Blob ? blob : new Blob([blob], { type });
  8268. file = blob;
  8269. file.name = file.name || filename;
  8270. }
  8271. }
  8272. return file;
  8273. }
  8274. function fileToUrl(file) {
  8275. for (const key in files) {
  8276. if (hasOwn(files, key)) {
  8277. const oldFile = files[key];
  8278. if (oldFile === file) {
  8279. return key;
  8280. }
  8281. }
  8282. }
  8283. var url = (window.URL || window.webkitURL).createObjectURL(file);
  8284. files[url] = file;
  8285. return url;
  8286. }
  8287. function revokeObjectURL(url) {
  8288. const URL = window.URL || window.webkitURL;
  8289. URL.revokeObjectURL(url);
  8290. delete files[url];
  8291. }
  8292. const launchOptions = /* @__PURE__ */ createLaunchOptions();
  8293. const enterOptions = /* @__PURE__ */ createLaunchOptions();
  8294. function getEnterOptions() {
  8295. return extend({}, enterOptions);
  8296. }
  8297. function getLaunchOptions() {
  8298. return extend({}, launchOptions);
  8299. }
  8300. function initLaunchOptions({
  8301. path,
  8302. query
  8303. }) {
  8304. extend(launchOptions, {
  8305. path,
  8306. query
  8307. });
  8308. extend(enterOptions, launchOptions);
  8309. return extend({}, launchOptions);
  8310. }
  8311. var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/;
  8312. var endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/;
  8313. var attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
  8314. var empty = /* @__PURE__ */ makeMap(
  8315. "area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr"
  8316. );
  8317. var block = /* @__PURE__ */ makeMap(
  8318. "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"
  8319. );
  8320. var inline = /* @__PURE__ */ makeMap(
  8321. "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"
  8322. );
  8323. var closeSelf = /* @__PURE__ */ makeMap(
  8324. "colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr"
  8325. );
  8326. var fillAttrs = /* @__PURE__ */ makeMap(
  8327. "checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected"
  8328. );
  8329. var special = /* @__PURE__ */ makeMap("script,style");
  8330. function HTMLParser(html, handler) {
  8331. var index2;
  8332. var chars2;
  8333. var match;
  8334. var stack = [];
  8335. var last = html;
  8336. stack.last = function() {
  8337. return this[this.length - 1];
  8338. };
  8339. while (html) {
  8340. chars2 = true;
  8341. if (!stack.last() || !special[stack.last()]) {
  8342. if (html.indexOf("<!--") == 0) {
  8343. index2 = html.indexOf("-->");
  8344. if (index2 >= 0) {
  8345. if (handler.comment) {
  8346. handler.comment(html.substring(4, index2));
  8347. }
  8348. html = html.substring(index2 + 3);
  8349. chars2 = false;
  8350. }
  8351. } else if (html.indexOf("</") == 0) {
  8352. match = html.match(endTag);
  8353. if (match) {
  8354. html = html.substring(match[0].length);
  8355. match[0].replace(endTag, parseEndTag);
  8356. chars2 = false;
  8357. }
  8358. } else if (html.indexOf("<") == 0) {
  8359. match = html.match(startTag);
  8360. if (match) {
  8361. html = html.substring(match[0].length);
  8362. match[0].replace(startTag, parseStartTag);
  8363. chars2 = false;
  8364. }
  8365. }
  8366. if (chars2) {
  8367. index2 = html.indexOf("<");
  8368. var text2 = index2 < 0 ? html : html.substring(0, index2);
  8369. html = index2 < 0 ? "" : html.substring(index2);
  8370. if (handler.chars) {
  8371. handler.chars(text2);
  8372. }
  8373. }
  8374. } else {
  8375. html = html.replace(
  8376. new RegExp("([\\s\\S]*?)</" + stack.last() + "[^>]*>"),
  8377. function(all, text3) {
  8378. text3 = text3.replace(
  8379. /<!--([\s\S]*?)-->|<!\[CDATA\[([\s\S]*?)]]>/g,
  8380. "$1$2"
  8381. );
  8382. if (handler.chars) {
  8383. handler.chars(text3);
  8384. }
  8385. return "";
  8386. }
  8387. );
  8388. parseEndTag("", stack.last());
  8389. }
  8390. if (html == last) {
  8391. throw "Parse Error: " + html;
  8392. }
  8393. last = html;
  8394. }
  8395. parseEndTag();
  8396. function parseStartTag(tag, tagName, rest, unary) {
  8397. tagName = tagName.toLowerCase();
  8398. if (block[tagName]) {
  8399. while (stack.last() && inline[stack.last()]) {
  8400. parseEndTag("", stack.last());
  8401. }
  8402. }
  8403. if (closeSelf[tagName] && stack.last() == tagName) {
  8404. parseEndTag("", tagName);
  8405. }
  8406. unary = empty[tagName] || !!unary;
  8407. if (!unary) {
  8408. stack.push(tagName);
  8409. }
  8410. if (handler.start) {
  8411. var attrs2 = [];
  8412. rest.replace(attr, function(match2, name) {
  8413. var value = arguments[2] ? arguments[2] : arguments[3] ? arguments[3] : arguments[4] ? arguments[4] : fillAttrs[name] ? name : "";
  8414. attrs2.push({
  8415. name,
  8416. value,
  8417. escaped: value.replace(/(^|[^\\])"/g, '$1\\"')
  8418. // "
  8419. });
  8420. });
  8421. if (handler.start) {
  8422. handler.start(tagName, attrs2, unary);
  8423. }
  8424. }
  8425. }
  8426. function parseEndTag(tag, tagName) {
  8427. if (!tagName) {
  8428. var pos = 0;
  8429. } else {
  8430. for (var pos = stack.length - 1; pos >= 0; pos--) {
  8431. if (stack[pos] == tagName) {
  8432. break;
  8433. }
  8434. }
  8435. }
  8436. if (pos >= 0) {
  8437. for (var i = stack.length - 1; i >= pos; i--) {
  8438. if (handler.end) {
  8439. handler.end(stack[i]);
  8440. }
  8441. }
  8442. stack.length = pos;
  8443. }
  8444. }
  8445. }
  8446. function makeMap(str) {
  8447. var obj = {};
  8448. var items = str.split(",");
  8449. for (var i = 0; i < items.length; i++) {
  8450. obj[items[i]] = true;
  8451. }
  8452. return obj;
  8453. }
  8454. const scripts = {};
  8455. function loadScript(globalName, src, callback) {
  8456. const globalObject = isString(globalName) ? window[globalName] : globalName;
  8457. if (globalObject) {
  8458. callback();
  8459. return;
  8460. }
  8461. let callbacks2 = scripts[src];
  8462. if (!callbacks2) {
  8463. callbacks2 = scripts[src] = [];
  8464. const script = document.createElement("script");
  8465. script.src = src;
  8466. document.body.appendChild(script);
  8467. script.onload = function() {
  8468. callbacks2.forEach((callback2) => callback2());
  8469. delete scripts[src];
  8470. };
  8471. }
  8472. callbacks2.push(callback);
  8473. }
  8474. function divider(Quill) {
  8475. const BlockEmbed = Quill.import("blots/block/embed");
  8476. class Divider extends BlockEmbed {
  8477. }
  8478. Divider.blotName = "divider";
  8479. Divider.tagName = "HR";
  8480. return {
  8481. "formats/divider": Divider
  8482. };
  8483. }
  8484. function ins(Quill) {
  8485. const Inline = Quill.import("blots/inline");
  8486. class Ins extends Inline {
  8487. }
  8488. Ins.blotName = "ins";
  8489. Ins.tagName = "INS";
  8490. return {
  8491. "formats/ins": Ins
  8492. };
  8493. }
  8494. function align(Quill) {
  8495. const { Scope, Attributor } = Quill.import("parchment");
  8496. const config = {
  8497. scope: Scope.BLOCK,
  8498. whitelist: ["left", "right", "center", "justify"]
  8499. };
  8500. const AlignStyle = new Attributor.Style("align", "text-align", config);
  8501. return {
  8502. "formats/align": AlignStyle
  8503. };
  8504. }
  8505. function direction(Quill) {
  8506. const { Scope, Attributor } = Quill.import("parchment");
  8507. const config = {
  8508. scope: Scope.BLOCK,
  8509. whitelist: ["rtl"]
  8510. };
  8511. const DirectionStyle = new Attributor.Style("direction", "direction", config);
  8512. return {
  8513. "formats/direction": DirectionStyle
  8514. };
  8515. }
  8516. function list(Quill) {
  8517. const Parchment = Quill.import("parchment");
  8518. const Container = Quill.import("blots/container");
  8519. const ListItem = Quill.import("formats/list/item");
  8520. class List extends Container {
  8521. static create(value) {
  8522. const tagName = value === "ordered" ? "OL" : "UL";
  8523. const node = super.create(tagName);
  8524. if (value === "checked" || value === "unchecked") {
  8525. node.setAttribute("data-checked", value === "checked");
  8526. }
  8527. return node;
  8528. }
  8529. static formats(domNode) {
  8530. if (domNode.tagName === "OL")
  8531. return "ordered";
  8532. if (domNode.tagName === "UL") {
  8533. if (domNode.hasAttribute("data-checked")) {
  8534. return domNode.getAttribute("data-checked") === "true" ? "checked" : "unchecked";
  8535. } else {
  8536. return "bullet";
  8537. }
  8538. }
  8539. return void 0;
  8540. }
  8541. constructor(domNode) {
  8542. super(domNode);
  8543. const listEventHandler = (e2) => {
  8544. if (e2.target.parentNode !== domNode)
  8545. return;
  8546. const format = this.statics.formats(domNode);
  8547. const blot = Parchment.find(e2.target);
  8548. if (format === "checked") {
  8549. blot.format("list", "unchecked");
  8550. } else if (format === "unchecked") {
  8551. blot.format("list", "checked");
  8552. }
  8553. };
  8554. domNode.addEventListener("click", listEventHandler);
  8555. }
  8556. format(name, value) {
  8557. if (this.children.length > 0) {
  8558. this.children.tail.format(name, value);
  8559. }
  8560. }
  8561. formats() {
  8562. return { [this.statics.blotName]: this.statics.formats(this.domNode) };
  8563. }
  8564. insertBefore(blot, ref2) {
  8565. if (blot instanceof ListItem) {
  8566. super.insertBefore(blot, ref2);
  8567. } else {
  8568. const index2 = ref2 == null ? this.length() : ref2.offset(this);
  8569. const after = this.split(index2);
  8570. after.parent.insertBefore(blot, after);
  8571. }
  8572. }
  8573. optimize(context) {
  8574. super.optimize(context);
  8575. const next = this.next;
  8576. 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")) {
  8577. next.moveChildren(this);
  8578. next.remove();
  8579. }
  8580. }
  8581. replace(target) {
  8582. if (target.statics.blotName !== this.statics.blotName) {
  8583. const item = Parchment.create(this.statics.defaultChild);
  8584. target.moveChildren(item);
  8585. this.appendChild(item);
  8586. }
  8587. super.replace(target);
  8588. }
  8589. }
  8590. List.blotName = "list";
  8591. List.scope = Parchment.Scope.BLOCK_BLOT;
  8592. List.tagName = ["OL", "UL"];
  8593. List.defaultChild = "list-item";
  8594. List.allowedChildren = [ListItem];
  8595. return {
  8596. "formats/list": List
  8597. };
  8598. }
  8599. function background(Quill) {
  8600. const { Scope } = Quill.import("parchment");
  8601. const BackgroundStyle = Quill.import("formats/background");
  8602. const BackgroundColorStyle = new BackgroundStyle.constructor(
  8603. "backgroundColor",
  8604. "background-color",
  8605. {
  8606. scope: Scope.INLINE
  8607. }
  8608. );
  8609. return {
  8610. "formats/backgroundColor": BackgroundColorStyle
  8611. };
  8612. }
  8613. function box(Quill) {
  8614. const { Scope, Attributor } = Quill.import("parchment");
  8615. const config = {
  8616. scope: Scope.BLOCK
  8617. };
  8618. const margin = [
  8619. "margin",
  8620. "marginTop",
  8621. "marginBottom",
  8622. "marginLeft",
  8623. "marginRight"
  8624. ];
  8625. const padding = [
  8626. "padding",
  8627. "paddingTop",
  8628. "paddingBottom",
  8629. "paddingLeft",
  8630. "paddingRight"
  8631. ];
  8632. const result = {};
  8633. margin.concat(padding).forEach((name) => {
  8634. result[`formats/${name}`] = new Attributor.Style(
  8635. name,
  8636. hyphenate(name),
  8637. config
  8638. );
  8639. });
  8640. return result;
  8641. }
  8642. function font(Quill) {
  8643. const { Scope, Attributor } = Quill.import("parchment");
  8644. const config = {
  8645. scope: Scope.INLINE
  8646. };
  8647. const font2 = [
  8648. "font",
  8649. "fontSize",
  8650. "fontStyle",
  8651. "fontVariant",
  8652. "fontWeight",
  8653. "fontFamily"
  8654. ];
  8655. const result = {};
  8656. font2.forEach((name) => {
  8657. result[`formats/${name}`] = new Attributor.Style(
  8658. name,
  8659. hyphenate(name),
  8660. config
  8661. );
  8662. });
  8663. return result;
  8664. }
  8665. function text(Quill) {
  8666. const { Scope, Attributor } = Quill.import("parchment");
  8667. const text2 = [
  8668. {
  8669. name: "lineHeight",
  8670. scope: Scope.BLOCK
  8671. },
  8672. {
  8673. name: "letterSpacing",
  8674. scope: Scope.INLINE
  8675. },
  8676. {
  8677. name: "textDecoration",
  8678. scope: Scope.INLINE
  8679. },
  8680. {
  8681. name: "textIndent",
  8682. scope: Scope.BLOCK
  8683. }
  8684. ];
  8685. const result = {};
  8686. text2.forEach(({ name, scope: scope2 }) => {
  8687. result[`formats/${name}`] = new Attributor.Style(name, hyphenate(name), {
  8688. scope: scope2
  8689. });
  8690. });
  8691. return result;
  8692. }
  8693. function image(Quill) {
  8694. const Image2 = Quill.import("formats/image");
  8695. const ATTRIBUTES = [
  8696. "alt",
  8697. "height",
  8698. "width",
  8699. "data-custom",
  8700. "class",
  8701. "data-local"
  8702. ];
  8703. Image2.sanitize = (url) => url ? getRealPath(url) : url;
  8704. Image2.formats = function formats(domNode) {
  8705. return ATTRIBUTES.reduce(
  8706. function(formats2, attribute) {
  8707. if (domNode.hasAttribute(attribute)) {
  8708. formats2[attribute] = domNode.getAttribute(attribute);
  8709. }
  8710. return formats2;
  8711. },
  8712. {}
  8713. );
  8714. };
  8715. const format = Image2.prototype.format;
  8716. Image2.prototype.format = function(name, value) {
  8717. if (ATTRIBUTES.indexOf(name) > -1) {
  8718. if (value) {
  8719. this.domNode.setAttribute(name, value);
  8720. } else {
  8721. this.domNode.removeAttribute(name);
  8722. }
  8723. } else {
  8724. format.call(this, name, value);
  8725. }
  8726. };
  8727. }
  8728. function link(Quill) {
  8729. const Link = Quill.import("formats/link");
  8730. Link.sanitize = (url) => {
  8731. const anchor = document.createElement("a");
  8732. anchor.href = url;
  8733. const protocol = anchor.href.slice(0, anchor.href.indexOf(":"));
  8734. return Link.PROTOCOL_WHITELIST.concat("file").indexOf(protocol) > -1 ? url : Link.SANITIZED_URL;
  8735. };
  8736. }
  8737. function register(Quill) {
  8738. const formats = {
  8739. divider,
  8740. ins,
  8741. align,
  8742. direction,
  8743. list,
  8744. background,
  8745. box,
  8746. font,
  8747. text,
  8748. image,
  8749. link
  8750. };
  8751. const options = {};
  8752. Object.values(formats).forEach((value) => extend(options, value(Quill)));
  8753. Quill.register(options, true);
  8754. }
  8755. function useQuill(props2, rootRef, trigger) {
  8756. let quillReady;
  8757. let skipMatcher;
  8758. let quill;
  8759. watch(
  8760. () => props2.readOnly,
  8761. (value) => {
  8762. if (quillReady) {
  8763. quill.enable(!value);
  8764. if (!value) {
  8765. quill.blur();
  8766. }
  8767. }
  8768. }
  8769. );
  8770. watch(
  8771. () => props2.placeholder,
  8772. (value) => {
  8773. if (quillReady) {
  8774. setPlaceHolder(value);
  8775. }
  8776. }
  8777. );
  8778. function html2delta(html) {
  8779. const tags = [
  8780. "span",
  8781. "strong",
  8782. "b",
  8783. "ins",
  8784. "em",
  8785. "i",
  8786. "u",
  8787. "a",
  8788. "del",
  8789. "s",
  8790. "sub",
  8791. "sup",
  8792. "img",
  8793. "div",
  8794. "p",
  8795. "h1",
  8796. "h2",
  8797. "h3",
  8798. "h4",
  8799. "h5",
  8800. "h6",
  8801. "hr",
  8802. "ol",
  8803. "ul",
  8804. "li",
  8805. "br"
  8806. ];
  8807. let content = "";
  8808. let disable;
  8809. HTMLParser(html, {
  8810. start: function(tag, attrs2, unary) {
  8811. if (!tags.includes(tag)) {
  8812. disable = !unary;
  8813. return;
  8814. }
  8815. disable = false;
  8816. const arrts = attrs2.map(({ name, value }) => `${name}="${value}"`).join(" ");
  8817. const start = `<${tag} ${arrts} ${unary ? "/" : ""}>`;
  8818. content += start;
  8819. },
  8820. end: function(tag) {
  8821. if (!disable) {
  8822. content += `</${tag}>`;
  8823. }
  8824. },
  8825. chars: function(text2) {
  8826. if (!disable) {
  8827. content += text2;
  8828. }
  8829. }
  8830. });
  8831. skipMatcher = true;
  8832. const delta = quill.clipboard.convert(content);
  8833. skipMatcher = false;
  8834. return delta;
  8835. }
  8836. function getContents() {
  8837. const html = quill.root.innerHTML;
  8838. const text2 = quill.getText();
  8839. const delta = quill.getContents();
  8840. return {
  8841. html,
  8842. text: text2,
  8843. delta
  8844. };
  8845. }
  8846. function setPlaceHolder(placeholder) {
  8847. const placeHolderAttrName = "data-placeholder";
  8848. const QuillRoot = quill.root;
  8849. QuillRoot.getAttribute(placeHolderAttrName) !== placeholder && QuillRoot.setAttribute(placeHolderAttrName, placeholder);
  8850. }
  8851. let oldStatus = {};
  8852. function updateStatus(range) {
  8853. const status = range ? quill.getFormat(range) : {};
  8854. const keys = Object.keys(status);
  8855. if (keys.length !== Object.keys(oldStatus).length || keys.find((key) => status[key] !== oldStatus[key])) {
  8856. oldStatus = status;
  8857. trigger("statuschange", {}, status);
  8858. }
  8859. }
  8860. function textChangeHandler() {
  8861. trigger("input", {}, getContents());
  8862. }
  8863. function initQuill(imageResizeModules) {
  8864. const Quill = window.Quill;
  8865. register(Quill);
  8866. const options = {
  8867. toolbar: false,
  8868. readOnly: props2.readOnly,
  8869. placeholder: props2.placeholder
  8870. };
  8871. if (imageResizeModules.length) {
  8872. Quill.register(
  8873. "modules/ImageResize",
  8874. window.ImageResize.default
  8875. );
  8876. options.modules = {
  8877. ImageResize: {
  8878. modules: imageResizeModules
  8879. }
  8880. };
  8881. }
  8882. const rootEl = rootRef.value;
  8883. quill = new Quill(rootEl, options);
  8884. const $el = quill.root;
  8885. const events = ["focus", "blur", "input"];
  8886. events.forEach((name) => {
  8887. $el.addEventListener(name, ($event) => {
  8888. const contents = getContents();
  8889. if (name === "input") {
  8890. if (getBaseSystemInfo().platform === "ios") {
  8891. const regExpContent = (contents.html.match(
  8892. /<span [\s\S]*>([\s\S]*)<\/span>/
  8893. ) || [])[1];
  8894. const placeholder = regExpContent && regExpContent.replace(/\s/g, "") ? "" : props2.placeholder;
  8895. setPlaceHolder(placeholder);
  8896. }
  8897. $event.stopPropagation();
  8898. } else {
  8899. trigger(name, $event, contents);
  8900. }
  8901. });
  8902. });
  8903. quill.on("text-change", textChangeHandler);
  8904. quill.on("selection-change", updateStatus);
  8905. quill.on("scroll-optimize", () => {
  8906. const range = quill.selection.getRange()[0];
  8907. updateStatus(range);
  8908. });
  8909. quill.clipboard.addMatcher(Node.ELEMENT_NODE, (node, delta) => {
  8910. if (skipMatcher) {
  8911. return delta;
  8912. }
  8913. if (delta.ops) {
  8914. delta.ops = delta.ops.filter(({ insert }) => isString(insert)).map(({ insert }) => ({ insert }));
  8915. }
  8916. return delta;
  8917. });
  8918. quillReady = true;
  8919. trigger("ready", {}, {});
  8920. }
  8921. const id2 = useContextInfo();
  8922. useSubscribe(
  8923. (type, data, resolve) => {
  8924. const { options, callbackId } = data;
  8925. let res;
  8926. let range;
  8927. let errMsg;
  8928. if (quillReady) {
  8929. const Quill = window.Quill;
  8930. switch (type) {
  8931. case "format":
  8932. {
  8933. let { name = "", value = false } = options;
  8934. range = quill.getSelection(true);
  8935. let format = quill.getFormat(range)[name] || false;
  8936. if (["bold", "italic", "underline", "strike", "ins"].includes(name)) {
  8937. value = !format;
  8938. } else if (name === "direction") {
  8939. value = value === "rtl" && format ? false : value;
  8940. const align2 = quill.getFormat(range).align;
  8941. if (value === "rtl" && !align2) {
  8942. quill.format("align", "right", "user");
  8943. } else if (!value && align2 === "right") {
  8944. quill.format("align", false, "user");
  8945. }
  8946. } else if (name === "indent") {
  8947. const rtl = quill.getFormat(range).direction === "rtl";
  8948. value = value === "+1";
  8949. if (rtl) {
  8950. value = !value;
  8951. }
  8952. value = value ? "+1" : "-1";
  8953. } else {
  8954. if (name === "list") {
  8955. value = value === "check" ? "unchecked" : value;
  8956. format = format === "checked" ? "unchecked" : format;
  8957. }
  8958. value = format && format !== (value || false) || !format && value ? value : !format;
  8959. }
  8960. quill.format(name, value, "user");
  8961. }
  8962. break;
  8963. case "insertDivider":
  8964. range = quill.getSelection(true);
  8965. quill.insertText(range.index, LINEFEED, "user");
  8966. quill.insertEmbed(range.index + 1, "divider", true, "user");
  8967. quill.setSelection(range.index + 2, 0, "silent");
  8968. break;
  8969. case "insertImage":
  8970. {
  8971. range = quill.getSelection(true);
  8972. const {
  8973. src = "",
  8974. alt = "",
  8975. width = "",
  8976. height = "",
  8977. extClass = "",
  8978. data: data2 = {}
  8979. } = options;
  8980. const path = getRealPath(src);
  8981. quill.insertEmbed(range.index, "image", path, "silent");
  8982. const local = /^(file|blob):/.test(path) ? path : false;
  8983. quill.formatText(range.index, 1, "data-local", local, "silent");
  8984. quill.formatText(range.index, 1, "alt", alt, "silent");
  8985. quill.formatText(range.index, 1, "width", width, "silent");
  8986. quill.formatText(range.index, 1, "height", height, "silent");
  8987. quill.formatText(range.index, 1, "class", extClass, "silent");
  8988. quill.formatText(
  8989. range.index,
  8990. 1,
  8991. "data-custom",
  8992. Object.keys(data2).map((key) => `${key}=${data2[key]}`).join("&"),
  8993. "silent"
  8994. );
  8995. quill.setSelection(range.index + 1, 0, "silent");
  8996. quill.scrollIntoView();
  8997. setTimeout(() => {
  8998. textChangeHandler();
  8999. }, 1e3);
  9000. }
  9001. break;
  9002. case "insertText":
  9003. {
  9004. range = quill.getSelection(true);
  9005. const { text: text2 = "" } = options;
  9006. quill.insertText(range.index, text2, "user");
  9007. quill.setSelection(range.index + text2.length, 0, "silent");
  9008. }
  9009. break;
  9010. case "setContents":
  9011. {
  9012. const { delta, html } = options;
  9013. if (typeof delta === "object") {
  9014. quill.setContents(delta, "silent");
  9015. } else if (isString(html)) {
  9016. quill.setContents(html2delta(html), "silent");
  9017. } else {
  9018. errMsg = "contents is missing";
  9019. }
  9020. }
  9021. break;
  9022. case "getContents":
  9023. res = getContents();
  9024. break;
  9025. case "clear":
  9026. quill.setText("");
  9027. break;
  9028. case "removeFormat":
  9029. {
  9030. range = quill.getSelection(true);
  9031. const parchment = Quill.import("parchment");
  9032. if (range.length) {
  9033. quill.removeFormat(range.index, range.length, "user");
  9034. } else {
  9035. Object.keys(quill.getFormat(range)).forEach((key) => {
  9036. if (parchment.query(key, parchment.Scope.INLINE)) {
  9037. quill.format(key, false);
  9038. }
  9039. });
  9040. }
  9041. }
  9042. break;
  9043. case "undo":
  9044. quill.history.undo();
  9045. break;
  9046. case "redo":
  9047. quill.history.redo();
  9048. break;
  9049. case "blur":
  9050. quill.blur();
  9051. break;
  9052. case "getSelectionText":
  9053. range = quill.selection.savedRange;
  9054. res = { text: "" };
  9055. if (range && range.length !== 0) {
  9056. res.text = quill.getText(range.index, range.length);
  9057. }
  9058. break;
  9059. case "scrollIntoView":
  9060. quill.scrollIntoView();
  9061. break;
  9062. }
  9063. updateStatus(range);
  9064. } else {
  9065. errMsg = "not ready";
  9066. }
  9067. if (callbackId) {
  9068. resolve({
  9069. callbackId,
  9070. data: extend({}, res, {
  9071. errMsg: `${type}:${errMsg ? "fail " + errMsg : "ok"}`
  9072. })
  9073. });
  9074. }
  9075. },
  9076. id2,
  9077. true
  9078. );
  9079. onMounted(() => {
  9080. const imageResizeModules = [];
  9081. if (props2.showImgSize) {
  9082. imageResizeModules.push("DisplaySize");
  9083. }
  9084. if (props2.showImgToolbar) {
  9085. imageResizeModules.push("Toolbar");
  9086. }
  9087. if (props2.showImgResize) {
  9088. imageResizeModules.push("Resize");
  9089. }
  9090. const quillSrc = "https://unpkg.com/quill@1.3.7/dist/quill.min.js";
  9091. loadScript(window.Quill, quillSrc, () => {
  9092. if (imageResizeModules.length) {
  9093. const imageResizeSrc = "https://unpkg.com/quill-image-resize-mp@3.0.1/image-resize.min.js";
  9094. loadScript(window.ImageResize, imageResizeSrc, () => {
  9095. initQuill(imageResizeModules);
  9096. });
  9097. } else {
  9098. initQuill(imageResizeModules);
  9099. }
  9100. });
  9101. });
  9102. }
  9103. const props$u = /* @__PURE__ */ extend({}, props$v, {
  9104. id: {
  9105. type: String,
  9106. default: ""
  9107. },
  9108. readOnly: {
  9109. type: [Boolean, String],
  9110. default: false
  9111. },
  9112. placeholder: {
  9113. type: String,
  9114. default: ""
  9115. },
  9116. showImgSize: {
  9117. type: [Boolean, String],
  9118. default: false
  9119. },
  9120. showImgToolbar: {
  9121. type: [Boolean, String],
  9122. default: false
  9123. },
  9124. showImgResize: {
  9125. type: [Boolean, String],
  9126. default: false
  9127. }
  9128. });
  9129. class UniEditorElement extends UniElement {
  9130. }
  9131. const index$s = /* @__PURE__ */ defineBuiltInComponent({
  9132. name: "Editor",
  9133. props: props$u,
  9134. emit: ["ready", "focus", "blur", "input", "statuschange", ...emit$1],
  9135. rootElement: {
  9136. name: "uni-editor",
  9137. class: UniEditorElement
  9138. },
  9139. setup(props2, {
  9140. emit: emit2
  9141. }) {
  9142. const rootRef = ref(null);
  9143. const trigger = useCustomEvent(rootRef, emit2);
  9144. useQuill(props2, rootRef, trigger);
  9145. useKeyboard$1(props2, rootRef);
  9146. onMounted(() => {
  9147. const rootElement = rootRef.value;
  9148. rootElement.attachVmProps(props2);
  9149. });
  9150. return () => {
  9151. return createVNode("uni-editor", {
  9152. "ref": rootRef,
  9153. "id": props2.id,
  9154. "class": "ql-container"
  9155. }, null, 8, ["id"]);
  9156. };
  9157. }
  9158. });
  9159. const INFO_COLOR = "#10aeff";
  9160. const WARN_COLOR = "#f76260";
  9161. const GREY_COLOR = "#b2b2b2";
  9162. const CANCEL_COLOR = "#f43530";
  9163. const ICONS = {
  9164. success: {
  9165. d: ICON_PATH_SUCCESS,
  9166. c: PRIMARY_COLOR
  9167. },
  9168. success_no_circle: {
  9169. d: ICON_PATH_SUCCESS_NO_CIRCLE,
  9170. c: PRIMARY_COLOR
  9171. },
  9172. info: {
  9173. d: ICON_PATH_INFO,
  9174. c: INFO_COLOR
  9175. },
  9176. warn: {
  9177. d: ICON_PATH_WARN,
  9178. c: WARN_COLOR
  9179. },
  9180. waiting: {
  9181. d: ICON_PATH_WAITING,
  9182. c: INFO_COLOR
  9183. },
  9184. cancel: {
  9185. d: ICON_PATH_CANCEL,
  9186. c: CANCEL_COLOR
  9187. },
  9188. download: {
  9189. d: ICON_PATH_DOWNLOAD,
  9190. c: PRIMARY_COLOR
  9191. },
  9192. search: {
  9193. d: ICON_PATH_SEARCH,
  9194. c: GREY_COLOR
  9195. },
  9196. clear: {
  9197. d: ICON_PATH_CLEAR,
  9198. c: GREY_COLOR
  9199. }
  9200. };
  9201. class UniIconElement extends UniElement {
  9202. }
  9203. const index$r = /* @__PURE__ */ defineBuiltInComponent({
  9204. name: "Icon",
  9205. props: {
  9206. type: {
  9207. type: String,
  9208. required: true,
  9209. default: ""
  9210. },
  9211. size: {
  9212. type: [String, Number],
  9213. default: 23
  9214. },
  9215. color: {
  9216. type: String,
  9217. default: ""
  9218. }
  9219. },
  9220. rootElement: {
  9221. name: "uni-icon",
  9222. class: UniIconElement
  9223. },
  9224. setup(props2) {
  9225. const rootRef = ref(null);
  9226. const path = computed(() => ICONS[props2.type]);
  9227. return () => {
  9228. const {
  9229. value
  9230. } = path;
  9231. onMounted(() => {
  9232. const rootElement = rootRef.value;
  9233. rootElement.attachVmProps(props2);
  9234. });
  9235. return createVNode("uni-icon", {
  9236. "ref": rootRef
  9237. }, [value && value.d && createSvgIconVNode(value.d, props2.color || value.c, rpx2px(props2.size))], 512);
  9238. };
  9239. }
  9240. });
  9241. const ResizeSensor = /* @__PURE__ */ defineBuiltInComponent({
  9242. name: "ResizeSensor",
  9243. props: {
  9244. initial: {
  9245. type: Boolean,
  9246. default: false
  9247. }
  9248. },
  9249. emits: ["resize"],
  9250. setup(props2, {
  9251. emit: emit2
  9252. }) {
  9253. const rootRef = ref(null);
  9254. const reset = useResizeSensorReset(rootRef);
  9255. const update = useResizeSensorUpdate(rootRef, emit2, reset);
  9256. useResizeSensorLifecycle(rootRef, props2, update, reset);
  9257. return () => createVNode("uni-resize-sensor", {
  9258. "ref": rootRef,
  9259. "onAnimationstartOnce": update
  9260. }, [createVNode("div", {
  9261. "onScroll": update
  9262. }, [createVNode("div", null, null)], 40, ["onScroll"]), createVNode("div", {
  9263. "onScroll": update
  9264. }, [createVNode("div", null, null)], 40, ["onScroll"])], 40, ["onAnimationstartOnce"]);
  9265. }
  9266. });
  9267. function useResizeSensorUpdate(rootRef, emit2, reset) {
  9268. const size = reactive({
  9269. width: -1,
  9270. height: -1
  9271. });
  9272. watch(() => extend({}, size), (value) => emit2("resize", value));
  9273. return () => {
  9274. const rootEl = rootRef.value;
  9275. if (!rootEl)
  9276. return;
  9277. size.width = rootEl.offsetWidth;
  9278. size.height = rootEl.offsetHeight;
  9279. reset();
  9280. };
  9281. }
  9282. function useResizeSensorReset(rootRef) {
  9283. return () => {
  9284. const {
  9285. firstElementChild,
  9286. lastElementChild
  9287. } = rootRef.value;
  9288. firstElementChild.scrollLeft = 1e5;
  9289. firstElementChild.scrollTop = 1e5;
  9290. lastElementChild.scrollLeft = 1e5;
  9291. lastElementChild.scrollTop = 1e5;
  9292. };
  9293. }
  9294. function useResizeSensorLifecycle(rootRef, props2, update, reset) {
  9295. onActivated(reset);
  9296. onMounted(() => {
  9297. if (props2.initial) {
  9298. nextTick(update);
  9299. }
  9300. const rootEl = rootRef.value;
  9301. if (rootEl.offsetParent !== rootEl.parentElement) {
  9302. rootEl.parentElement.style.position = "relative";
  9303. }
  9304. if (!("AnimationEvent" in window)) {
  9305. reset();
  9306. }
  9307. });
  9308. }
  9309. const props$t = {
  9310. src: {
  9311. type: String,
  9312. default: ""
  9313. },
  9314. mode: {
  9315. type: String,
  9316. default: "scaleToFill"
  9317. },
  9318. lazyLoad: {
  9319. type: [Boolean, String],
  9320. default: false
  9321. },
  9322. draggable: {
  9323. type: Boolean,
  9324. default: false
  9325. }
  9326. };
  9327. const FIX_MODES = {
  9328. widthFix: ["offsetWidth", "height", (value, ratio) => value / ratio],
  9329. heightFix: ["offsetHeight", "width", (value, ratio) => value * ratio]
  9330. };
  9331. const IMAGE_MODES = {
  9332. aspectFit: ["center center", "contain"],
  9333. aspectFill: ["center center", "cover"],
  9334. widthFix: [, "100% 100%"],
  9335. heightFix: [, "100% 100%"],
  9336. top: ["center top"],
  9337. bottom: ["center bottom"],
  9338. center: ["center center"],
  9339. left: ["left center"],
  9340. right: ["right center"],
  9341. "top left": ["left top"],
  9342. "top right": ["right top"],
  9343. "bottom left": ["left bottom"],
  9344. "bottom right": ["right bottom"]
  9345. };
  9346. class UniImageElement extends UniElement {
  9347. }
  9348. const index$q = /* @__PURE__ */ defineBuiltInComponent({
  9349. name: "Image",
  9350. props: props$t,
  9351. rootElement: {
  9352. name: "uni-image",
  9353. class: UniImageElement
  9354. },
  9355. setup(props2, {
  9356. emit: emit2
  9357. }) {
  9358. const rootRef = ref(null);
  9359. const state2 = useImageState(rootRef, props2);
  9360. const trigger = useCustomEvent(rootRef, emit2);
  9361. const {
  9362. fixSize
  9363. } = useImageSize(rootRef, props2, state2);
  9364. useImageLoader(state2, props2, rootRef, fixSize, trigger);
  9365. onMounted(() => {
  9366. const rootElement = rootRef.value;
  9367. Object.defineProperty(rootElement, "src", {
  9368. get() {
  9369. return rootElement.querySelector("img").src;
  9370. },
  9371. set(value) {
  9372. rootElement.querySelector("div").style.backgroundImage = `url("${value}")`;
  9373. rootElement.querySelector("img").src = value;
  9374. }
  9375. });
  9376. rootElement.attachVmProps(props2);
  9377. });
  9378. return () => {
  9379. return createVNode("uni-image", {
  9380. "ref": rootRef
  9381. }, [createVNode("div", {
  9382. "style": state2.modeStyle
  9383. }, null, 4), FIX_MODES[props2.mode] ? createVNode(ResizeSensor, {
  9384. "onResize": fixSize
  9385. }, null, 8, ["onResize"]) : createVNode("span", null, null)], 512);
  9386. };
  9387. }
  9388. });
  9389. function useImageState(rootRef, props2) {
  9390. const imgSrc = ref("");
  9391. const modeStyleRef = computed(() => {
  9392. let size = "auto";
  9393. let position = "";
  9394. const opts = IMAGE_MODES[props2.mode];
  9395. if (!opts) {
  9396. position = "0% 0%";
  9397. size = "100% 100%";
  9398. } else {
  9399. opts[0] && (position = opts[0]);
  9400. opts[1] && (size = opts[1]);
  9401. }
  9402. return `background-image:${imgSrc.value ? 'url("' + imgSrc.value + '")' : "none"};background-position:${position};background-size:${size};`;
  9403. });
  9404. const state2 = reactive({
  9405. rootEl: rootRef,
  9406. src: computed(() => props2.src ? getRealPath(props2.src) : ""),
  9407. origWidth: 0,
  9408. origHeight: 0,
  9409. origStyle: {
  9410. width: "",
  9411. height: ""
  9412. },
  9413. modeStyle: modeStyleRef,
  9414. imgSrc
  9415. });
  9416. onMounted(() => {
  9417. const rootEl = rootRef.value;
  9418. state2.origWidth = rootEl.clientWidth || 0;
  9419. state2.origHeight = rootEl.clientHeight || 0;
  9420. });
  9421. return state2;
  9422. }
  9423. function useImageLoader(state2, props2, rootRef, fixSize, trigger) {
  9424. let img;
  9425. let draggableImg;
  9426. const setState = (width = 0, height = 0, imgSrc = "") => {
  9427. state2.origWidth = width;
  9428. state2.origHeight = height;
  9429. state2.imgSrc = imgSrc;
  9430. };
  9431. const loadImage = (src) => {
  9432. if (!src) {
  9433. resetImage();
  9434. setState();
  9435. return;
  9436. }
  9437. img = img || new Image();
  9438. img.onload = (evt) => {
  9439. const {
  9440. width,
  9441. height
  9442. } = img;
  9443. setState(width, height, src);
  9444. nextTick(() => {
  9445. fixSize();
  9446. });
  9447. img.draggable = props2.draggable;
  9448. if (draggableImg) {
  9449. draggableImg.remove();
  9450. }
  9451. draggableImg = img;
  9452. rootRef.value.appendChild(img);
  9453. resetImage();
  9454. trigger("load", evt, {
  9455. width,
  9456. height
  9457. });
  9458. };
  9459. img.onerror = (evt) => {
  9460. setState();
  9461. resetImage();
  9462. trigger("error", evt, {
  9463. errMsg: `GET ${state2.src} 404 (Not Found)`
  9464. });
  9465. };
  9466. img.src = src;
  9467. };
  9468. const resetImage = () => {
  9469. if (img) {
  9470. img.onload = null;
  9471. img.onerror = null;
  9472. img = null;
  9473. }
  9474. };
  9475. watch(() => state2.src, (value) => loadImage(value));
  9476. watch(() => state2.imgSrc, (value) => {
  9477. if (!value && draggableImg) {
  9478. draggableImg.remove();
  9479. draggableImg = null;
  9480. }
  9481. });
  9482. onMounted(() => loadImage(state2.src));
  9483. onBeforeUnmount(() => resetImage());
  9484. }
  9485. const isChrome = navigator.vendor === "Google Inc.";
  9486. function fixNumber(num) {
  9487. if (isChrome && num > 10) {
  9488. num = Math.round(num / 2) * 2;
  9489. }
  9490. return num;
  9491. }
  9492. function useImageSize(rootRef, props2, state2) {
  9493. const fixSize = () => {
  9494. const {
  9495. mode: mode2
  9496. } = props2;
  9497. const names = FIX_MODES[mode2];
  9498. if (!names) {
  9499. return;
  9500. }
  9501. const {
  9502. origWidth,
  9503. origHeight
  9504. } = state2;
  9505. const ratio = origWidth && origHeight ? origWidth / origHeight : 0;
  9506. if (!ratio) {
  9507. return;
  9508. }
  9509. const rootEl = rootRef.value;
  9510. const value = rootEl[names[0]];
  9511. if (value) {
  9512. rootEl.style[names[1]] = fixNumber(names[2](value, ratio)) + "px";
  9513. }
  9514. };
  9515. const resetSize = () => {
  9516. const {
  9517. style
  9518. } = rootRef.value;
  9519. const {
  9520. origStyle: {
  9521. width,
  9522. height
  9523. }
  9524. } = state2;
  9525. style.width = width;
  9526. style.height = height;
  9527. };
  9528. watch(() => props2.mode, (value, oldValue) => {
  9529. if (FIX_MODES[oldValue]) {
  9530. resetSize();
  9531. }
  9532. if (FIX_MODES[value]) {
  9533. fixSize();
  9534. }
  9535. });
  9536. return {
  9537. fixSize,
  9538. resetSize
  9539. };
  9540. }
  9541. function throttle(fn, wait) {
  9542. let last = 0;
  9543. let timeout;
  9544. let waitCallback;
  9545. const newFn = function(...arg) {
  9546. const now = Date.now();
  9547. clearTimeout(timeout);
  9548. waitCallback = () => {
  9549. waitCallback = null;
  9550. last = now;
  9551. fn.apply(this, arg);
  9552. };
  9553. if (now - last < wait) {
  9554. timeout = setTimeout(waitCallback, wait - (now - last));
  9555. return;
  9556. }
  9557. waitCallback();
  9558. };
  9559. newFn.cancel = function() {
  9560. clearTimeout(timeout);
  9561. waitCallback = null;
  9562. };
  9563. newFn.flush = function() {
  9564. clearTimeout(timeout);
  9565. waitCallback && waitCallback();
  9566. };
  9567. return newFn;
  9568. }
  9569. const passiveOptions$1 = /* @__PURE__ */ passive(true);
  9570. const states = [];
  9571. let userInteract = 0;
  9572. let inited = false;
  9573. const setUserAction = (userAction) => states.forEach((vm) => vm.userAction = userAction);
  9574. function addInteractListener(vm = { userAction: false }) {
  9575. if (!inited) {
  9576. const eventNames = [
  9577. "touchstart",
  9578. "touchmove",
  9579. "touchend",
  9580. "mousedown",
  9581. "mouseup"
  9582. ];
  9583. eventNames.forEach((eventName) => {
  9584. document.addEventListener(
  9585. eventName,
  9586. function() {
  9587. !userInteract && setUserAction(true);
  9588. userInteract++;
  9589. setTimeout(() => {
  9590. !--userInteract && setUserAction(false);
  9591. }, 0);
  9592. },
  9593. passiveOptions$1
  9594. );
  9595. });
  9596. inited = true;
  9597. }
  9598. states.push(vm);
  9599. }
  9600. function removeInteractListener(vm) {
  9601. const index2 = states.indexOf(vm);
  9602. if (index2 >= 0) {
  9603. states.splice(index2, 1);
  9604. }
  9605. }
  9606. const getInteractStatus = () => !!userInteract;
  9607. function useUserAction() {
  9608. const state2 = reactive({
  9609. /**
  9610. * 是否用户激活
  9611. */
  9612. userAction: false
  9613. });
  9614. onMounted(() => {
  9615. addInteractListener(state2);
  9616. });
  9617. onBeforeUnmount(() => {
  9618. removeInteractListener(state2);
  9619. });
  9620. return {
  9621. state: state2
  9622. };
  9623. }
  9624. function useScopedAttrs() {
  9625. const state2 = reactive({
  9626. attrs: {}
  9627. });
  9628. onMounted(() => {
  9629. let instance2 = getCurrentInstance();
  9630. while (instance2) {
  9631. const scopeId = instance2.type.__scopeId;
  9632. if (scopeId) {
  9633. state2.attrs[scopeId] = "";
  9634. }
  9635. instance2 = instance2.proxy && instance2.proxy.$mpType === "page" ? null : instance2.parent;
  9636. }
  9637. });
  9638. return {
  9639. state: state2
  9640. };
  9641. }
  9642. function useFormField(nameKey, value) {
  9643. const uniForm = inject(
  9644. uniFormKey,
  9645. false
  9646. // remove warning
  9647. );
  9648. if (!uniForm) {
  9649. return;
  9650. }
  9651. const instance2 = getCurrentInstance();
  9652. const initialValue = isString(value) ? instance2.proxy[value] : value.value;
  9653. const ctx = {
  9654. submit() {
  9655. const proxy = instance2.proxy;
  9656. return [
  9657. proxy[nameKey],
  9658. isString(value) ? proxy[value] : value.value
  9659. ];
  9660. },
  9661. reset() {
  9662. if (isString(value)) {
  9663. instance2.proxy[value] = initialValue;
  9664. } else {
  9665. value.value = initialValue;
  9666. }
  9667. }
  9668. };
  9669. uniForm.addField(ctx);
  9670. onBeforeUnmount(() => {
  9671. uniForm.removeField(ctx);
  9672. });
  9673. }
  9674. function getSelectedTextRange(_, resolve) {
  9675. const activeElement = document.activeElement;
  9676. if (!activeElement) {
  9677. return resolve({});
  9678. }
  9679. const data = {};
  9680. if (["input", "textarea"].includes(activeElement.tagName.toLowerCase())) {
  9681. data.start = activeElement.selectionStart;
  9682. data.end = activeElement.selectionEnd;
  9683. }
  9684. resolve(data);
  9685. }
  9686. const UniViewJSBridgeSubscribe = function() {
  9687. registerViewMethod(
  9688. getCurrentPageId(),
  9689. "getSelectedTextRange",
  9690. getSelectedTextRange
  9691. );
  9692. };
  9693. function getValueString(value, type, maxlength) {
  9694. if (type === "number" && isNaN(Number(value))) {
  9695. value = "";
  9696. }
  9697. const valueStr = value === null || value === void 0 ? "" : String(value);
  9698. if (maxlength == void 0) {
  9699. return valueStr;
  9700. }
  9701. return valueStr.slice(0, maxlength);
  9702. }
  9703. const INPUT_MODES = [
  9704. "none",
  9705. "text",
  9706. "decimal",
  9707. "numeric",
  9708. "tel",
  9709. "search",
  9710. "email",
  9711. "url"
  9712. ];
  9713. const props$s = /* @__PURE__ */ extend(
  9714. {},
  9715. {
  9716. name: {
  9717. type: String,
  9718. default: ""
  9719. },
  9720. modelValue: {
  9721. type: [String, Number]
  9722. },
  9723. value: {
  9724. type: [String, Number]
  9725. },
  9726. disabled: {
  9727. type: [Boolean, String],
  9728. default: false
  9729. },
  9730. /**
  9731. * 已废弃属性,用于历史兼容
  9732. */
  9733. autoFocus: {
  9734. type: [Boolean, String],
  9735. default: false
  9736. },
  9737. focus: {
  9738. type: [Boolean, String],
  9739. default: false
  9740. },
  9741. cursor: {
  9742. type: [Number, String],
  9743. default: -1
  9744. },
  9745. selectionStart: {
  9746. type: [Number, String],
  9747. default: -1
  9748. },
  9749. selectionEnd: {
  9750. type: [Number, String],
  9751. default: -1
  9752. },
  9753. type: {
  9754. type: String,
  9755. default: "text"
  9756. },
  9757. password: {
  9758. type: [Boolean, String],
  9759. default: false
  9760. },
  9761. placeholder: {
  9762. type: String,
  9763. default: ""
  9764. },
  9765. placeholderStyle: {
  9766. type: String,
  9767. default: ""
  9768. },
  9769. placeholderClass: {
  9770. type: String,
  9771. default: ""
  9772. },
  9773. maxlength: {
  9774. type: [Number, String],
  9775. default: Infinity
  9776. },
  9777. confirmType: {
  9778. type: String,
  9779. default: "done"
  9780. },
  9781. confirmHold: {
  9782. type: Boolean,
  9783. default: false
  9784. },
  9785. ignoreCompositionEvent: {
  9786. type: Boolean,
  9787. default: true
  9788. },
  9789. step: {
  9790. type: String,
  9791. default: "0.000000000000000001"
  9792. },
  9793. inputmode: {
  9794. type: String,
  9795. default: void 0,
  9796. validator: (value) => !!~INPUT_MODES.indexOf(value)
  9797. },
  9798. cursorColor: {
  9799. type: String,
  9800. default: ""
  9801. }
  9802. },
  9803. props$v
  9804. );
  9805. const emit = [
  9806. "input",
  9807. "focus",
  9808. "blur",
  9809. "update:value",
  9810. "update:modelValue",
  9811. "update:focus",
  9812. "compositionstart",
  9813. "compositionupdate",
  9814. "compositionend",
  9815. ...emit$1
  9816. ];
  9817. function useBase(props2, rootRef, emit2) {
  9818. const fieldRef = ref(null);
  9819. const trigger = useCustomEvent(rootRef, emit2);
  9820. const selectionStart = computed(() => {
  9821. const selectionStart2 = Number(props2.selectionStart);
  9822. return isNaN(selectionStart2) ? -1 : selectionStart2;
  9823. });
  9824. const selectionEnd = computed(() => {
  9825. const selectionEnd2 = Number(props2.selectionEnd);
  9826. return isNaN(selectionEnd2) ? -1 : selectionEnd2;
  9827. });
  9828. const cursor = computed(() => {
  9829. const cursor2 = Number(props2.cursor);
  9830. return isNaN(cursor2) ? -1 : cursor2;
  9831. });
  9832. const maxlength = computed(() => {
  9833. var maxlength2 = Number(props2.maxlength);
  9834. {
  9835. return isNaN(maxlength2) || maxlength2 < 0 ? Infinity : Math.floor(maxlength2);
  9836. }
  9837. });
  9838. let value = "";
  9839. {
  9840. const modelValueString = getValueString(
  9841. props2.modelValue,
  9842. props2.type,
  9843. maxlength.value
  9844. );
  9845. const valueString = getValueString(props2.value, props2.type, maxlength.value);
  9846. value = props2.modelValue !== void 0 ? modelValueString !== null && modelValueString !== void 0 ? modelValueString : valueString : valueString;
  9847. }
  9848. const state2 = reactive({
  9849. value,
  9850. valueOrigin: value,
  9851. maxlength,
  9852. focus: props2.focus,
  9853. composing: false,
  9854. selectionStart,
  9855. selectionEnd,
  9856. cursor
  9857. });
  9858. watch(
  9859. () => state2.focus,
  9860. (val) => emit2("update:focus", val)
  9861. );
  9862. watch(
  9863. () => state2.maxlength,
  9864. (val) => state2.value = state2.value.slice(0, val),
  9865. {
  9866. immediate: true
  9867. }
  9868. );
  9869. return {
  9870. fieldRef,
  9871. state: state2,
  9872. trigger
  9873. };
  9874. }
  9875. function useValueSync(props2, state2, emit2, trigger) {
  9876. let valueChangeFn = null;
  9877. {
  9878. valueChangeFn = throttle((val) => {
  9879. state2.value = getValueString(val, props2.type, state2.maxlength);
  9880. }, 100);
  9881. }
  9882. watch(() => props2.modelValue, valueChangeFn);
  9883. watch(() => props2.value, valueChangeFn);
  9884. const triggerInputFn = throttle((event, detail) => {
  9885. valueChangeFn.cancel();
  9886. emit2("update:modelValue", detail.value);
  9887. emit2("update:value", detail.value);
  9888. trigger("input", event, detail);
  9889. }, 100);
  9890. const triggerInput = (event, detail, force) => {
  9891. valueChangeFn.cancel();
  9892. triggerInputFn(event, detail);
  9893. if (force) {
  9894. triggerInputFn.flush();
  9895. }
  9896. };
  9897. onBeforeMount(() => {
  9898. valueChangeFn.cancel();
  9899. triggerInputFn.cancel();
  9900. });
  9901. return {
  9902. trigger,
  9903. triggerInput
  9904. };
  9905. }
  9906. function useAutoFocus(props2, fieldRef) {
  9907. useUserAction();
  9908. const needFocus = computed(() => props2.autoFocus || props2.focus);
  9909. function focus() {
  9910. if (!needFocus.value) {
  9911. return;
  9912. }
  9913. const field = fieldRef.value;
  9914. if (!field || false) {
  9915. setTimeout(focus, 100);
  9916. return;
  9917. }
  9918. {
  9919. field.focus();
  9920. }
  9921. }
  9922. function blur() {
  9923. const field = fieldRef.value;
  9924. if (field) {
  9925. field.blur();
  9926. }
  9927. }
  9928. watch(
  9929. () => props2.focus,
  9930. (value) => {
  9931. if (value) {
  9932. focus();
  9933. } else {
  9934. blur();
  9935. }
  9936. }
  9937. );
  9938. onMounted(() => {
  9939. if (needFocus.value) {
  9940. nextTick(focus);
  9941. }
  9942. });
  9943. }
  9944. function useEvent(fieldRef, state2, props2, trigger, triggerInput, beforeInput) {
  9945. function checkSelection() {
  9946. const field = fieldRef.value;
  9947. if (field && state2.focus && state2.selectionStart > -1 && state2.selectionEnd > -1 && field.type !== "number") {
  9948. field.selectionStart = state2.selectionStart;
  9949. field.selectionEnd = state2.selectionEnd;
  9950. }
  9951. }
  9952. function checkCursor() {
  9953. const field = fieldRef.value;
  9954. if (field && state2.focus && state2.selectionStart < 0 && state2.selectionEnd < 0 && state2.cursor > -1 && field.type !== "number") {
  9955. field.selectionEnd = field.selectionStart = state2.cursor;
  9956. }
  9957. }
  9958. function getFieldSelectionEnd(field) {
  9959. if (field.type === "number") {
  9960. return null;
  9961. } else {
  9962. return field.selectionEnd;
  9963. }
  9964. }
  9965. function initField() {
  9966. const field = fieldRef.value;
  9967. if (!field)
  9968. return;
  9969. const onFocus = function(event) {
  9970. state2.focus = true;
  9971. trigger("focus", event, {
  9972. value: state2.value
  9973. });
  9974. checkSelection();
  9975. checkCursor();
  9976. };
  9977. const onInput = function(event, force) {
  9978. event.stopPropagation();
  9979. if (isFunction(beforeInput) && beforeInput(event, state2) === false) {
  9980. return;
  9981. }
  9982. state2.value = field.value;
  9983. if (!state2.composing || !props2.ignoreCompositionEvent) {
  9984. triggerInput(
  9985. event,
  9986. {
  9987. value: field.value,
  9988. cursor: getFieldSelectionEnd(field)
  9989. },
  9990. force
  9991. );
  9992. }
  9993. };
  9994. const onBlur = function(event) {
  9995. if (state2.composing) {
  9996. state2.composing = false;
  9997. onInput(event, true);
  9998. }
  9999. state2.focus = false;
  10000. trigger("blur", event, {
  10001. value: state2.value,
  10002. cursor: getFieldSelectionEnd(event.target)
  10003. });
  10004. };
  10005. field.addEventListener("change", (event) => event.stopPropagation());
  10006. field.addEventListener("focus", onFocus);
  10007. field.addEventListener("blur", onBlur);
  10008. field.addEventListener("input", onInput);
  10009. field.addEventListener("compositionstart", (event) => {
  10010. event.stopPropagation();
  10011. state2.composing = true;
  10012. _onComposition(event);
  10013. });
  10014. field.addEventListener("compositionend", (event) => {
  10015. event.stopPropagation();
  10016. if (state2.composing) {
  10017. state2.composing = false;
  10018. onInput(event);
  10019. }
  10020. _onComposition(event);
  10021. });
  10022. field.addEventListener("compositionupdate", _onComposition);
  10023. function _onComposition(event) {
  10024. if (!props2.ignoreCompositionEvent) {
  10025. trigger(event.type, event, {
  10026. value: event.data
  10027. });
  10028. }
  10029. }
  10030. }
  10031. watch([() => state2.selectionStart, () => state2.selectionEnd], checkSelection);
  10032. watch(() => state2.cursor, checkCursor);
  10033. watch(() => fieldRef.value, initField);
  10034. }
  10035. function useField(props2, rootRef, emit2, beforeInput) {
  10036. UniViewJSBridgeSubscribe();
  10037. const { fieldRef, state: state2, trigger } = useBase(props2, rootRef, emit2);
  10038. const { triggerInput } = useValueSync(props2, state2, emit2, trigger);
  10039. useAutoFocus(props2, fieldRef);
  10040. useKeyboard$1(props2, fieldRef);
  10041. const { state: scopedAttrsState } = useScopedAttrs();
  10042. useFormField("name", state2);
  10043. useEvent(fieldRef, state2, props2, trigger, triggerInput, beforeInput);
  10044. const fixDisabledColor = String(navigator.vendor).indexOf("Apple") === 0 && CSS.supports("image-orientation:from-image");
  10045. return {
  10046. fieldRef,
  10047. state: state2,
  10048. scopedAttrsState,
  10049. fixDisabledColor,
  10050. trigger
  10051. };
  10052. }
  10053. const props$r = /* @__PURE__ */ extend({}, props$s, {
  10054. placeholderClass: {
  10055. type: String,
  10056. default: "input-placeholder"
  10057. },
  10058. textContentType: {
  10059. type: String,
  10060. default: ""
  10061. }
  10062. });
  10063. function resolveDigitDecimalPoint(event, cache, state2, input, resetCache) {
  10064. if (cache.value) {
  10065. if (event.data === ".") {
  10066. if (cache.value.slice(-1) === ".") {
  10067. state2.value = input.value = cache.value = cache.value.slice(0, -1);
  10068. return false;
  10069. }
  10070. if (cache.value && !cache.value.includes(".")) {
  10071. cache.value += ".";
  10072. if (resetCache) {
  10073. resetCache.fn = () => {
  10074. state2.value = input.value = cache.value = cache.value.slice(0, -1);
  10075. input.removeEventListener("blur", resetCache.fn);
  10076. };
  10077. input.addEventListener("blur", resetCache.fn);
  10078. }
  10079. return false;
  10080. }
  10081. } else if (event.inputType === "deleteContentBackward") {
  10082. if (navigator.userAgent.includes("iPhone OS 16")) {
  10083. if (cache.value.slice(-2, -1) === ".") {
  10084. cache.value = state2.value = input.value = cache.value.slice(0, -2);
  10085. return true;
  10086. }
  10087. }
  10088. }
  10089. }
  10090. }
  10091. function useCache(props2, type) {
  10092. if (type.value === "number") {
  10093. const value = typeof props2.modelValue === "undefined" ? props2.value : props2.modelValue;
  10094. const cache = ref(typeof value !== "undefined" && value !== null ? value.toLocaleString() : "");
  10095. watch(() => props2.modelValue, (value2) => {
  10096. cache.value = typeof value2 !== "undefined" && value2 !== null ? value2.toLocaleString() : "";
  10097. });
  10098. watch(() => props2.value, (value2) => {
  10099. cache.value = typeof value2 !== "undefined" && value2 !== null ? value2.toLocaleString() : "";
  10100. });
  10101. return cache;
  10102. } else {
  10103. return ref("");
  10104. }
  10105. }
  10106. class UniInputElement extends UniElement {
  10107. focus(options) {
  10108. var _a;
  10109. (_a = this.querySelector("input")) == null ? void 0 : _a.focus(options);
  10110. }
  10111. }
  10112. const Input = /* @__PURE__ */ defineBuiltInComponent({
  10113. name: "Input",
  10114. props: props$r,
  10115. emits: ["confirm", ...emit],
  10116. rootElement: {
  10117. name: "uni-input",
  10118. class: UniInputElement
  10119. },
  10120. setup(props2, {
  10121. emit: emit2,
  10122. expose
  10123. }) {
  10124. const INPUT_TYPES = ["text", "number", "idcard", "digit", "password", "tel"];
  10125. const AUTOCOMPLETES = ["off", "one-time-code"];
  10126. const type = computed(() => {
  10127. let type2 = "";
  10128. switch (props2.type) {
  10129. case "text":
  10130. type2 = "text";
  10131. if (props2.confirmType === "search") {
  10132. type2 = "search";
  10133. }
  10134. break;
  10135. case "idcard":
  10136. type2 = "text";
  10137. break;
  10138. case "digit":
  10139. type2 = "number";
  10140. break;
  10141. default:
  10142. type2 = ~INPUT_TYPES.includes(props2.type) ? props2.type : "text";
  10143. break;
  10144. }
  10145. return props2.password ? "password" : type2;
  10146. });
  10147. const autocomplete = computed(() => {
  10148. const camelizeIndex = AUTOCOMPLETES.indexOf(props2.textContentType);
  10149. const kebabCaseIndex = AUTOCOMPLETES.indexOf(hyphenate(props2.textContentType));
  10150. const index2 = camelizeIndex !== -1 ? camelizeIndex : kebabCaseIndex !== -1 ? kebabCaseIndex : 0;
  10151. return AUTOCOMPLETES[index2];
  10152. });
  10153. let cache = useCache(props2, type);
  10154. let resetCache = {
  10155. fn: null
  10156. };
  10157. const rootRef = ref(null);
  10158. const {
  10159. fieldRef,
  10160. state: state2,
  10161. scopedAttrsState,
  10162. fixDisabledColor,
  10163. trigger
  10164. } = useField(props2, rootRef, emit2, (event, state22) => {
  10165. const input = event.target;
  10166. if (type.value === "number") {
  10167. if (resetCache.fn) {
  10168. input.removeEventListener("blur", resetCache.fn);
  10169. resetCache.fn = null;
  10170. }
  10171. if (input.validity && !input.validity.valid) {
  10172. if ((!cache.value || !input.value) && event.data === "-" || cache.value[0] === "-" && event.inputType === "deleteContentBackward") {
  10173. cache.value = "-";
  10174. state22.value = "";
  10175. resetCache.fn = () => {
  10176. cache.value = input.value = "";
  10177. };
  10178. input.addEventListener("blur", resetCache.fn);
  10179. return false;
  10180. }
  10181. const res = resolveDigitDecimalPoint(event, cache, state22, input, resetCache);
  10182. if (typeof res === "boolean")
  10183. return res;
  10184. cache.value = state22.value = input.value = cache.value === "-" ? "" : cache.value;
  10185. return false;
  10186. } else {
  10187. const res = resolveDigitDecimalPoint(event, cache, state22, input, resetCache);
  10188. if (typeof res === "boolean")
  10189. return res;
  10190. cache.value = input.value;
  10191. }
  10192. const maxlength = state22.maxlength;
  10193. if (maxlength > 0 && input.value.length > maxlength) {
  10194. input.value = input.value.slice(0, maxlength);
  10195. state22.value = input.value;
  10196. return false;
  10197. }
  10198. }
  10199. });
  10200. watch(() => state2.value, (value) => {
  10201. if (props2.type === "number" && !(cache.value === "-" && value === "")) {
  10202. cache.value = value.toString();
  10203. }
  10204. });
  10205. const NUMBER_TYPES = ["number", "digit"];
  10206. const step = computed(() => NUMBER_TYPES.includes(props2.type) ? props2.step : "");
  10207. function onKeyUpEnter(event) {
  10208. if (event.key !== "Enter") {
  10209. return;
  10210. }
  10211. const input = event.target;
  10212. event.stopPropagation();
  10213. trigger("confirm", event, {
  10214. value: input.value
  10215. });
  10216. !props2.confirmHold && input.blur();
  10217. }
  10218. expose({
  10219. $triggerInput: (detail) => {
  10220. emit2("update:modelValue", detail.value);
  10221. emit2("update:value", detail.value);
  10222. state2.value = detail.value;
  10223. }
  10224. });
  10225. onMounted(() => {
  10226. const rootElement = rootRef.value;
  10227. Object.defineProperty(rootElement, "value", {
  10228. get() {
  10229. return rootElement.querySelector("input").value;
  10230. },
  10231. set(value) {
  10232. rootElement.querySelector("input").value = value;
  10233. }
  10234. });
  10235. rootElement.attachVmProps(props2);
  10236. });
  10237. return () => {
  10238. let inputNode = props2.disabled && fixDisabledColor ? createVNode("input", {
  10239. "key": "disabled-input",
  10240. "ref": fieldRef,
  10241. "value": state2.value,
  10242. "tabindex": "-1",
  10243. "readonly": !!props2.disabled,
  10244. "type": type.value,
  10245. "maxlength": state2.maxlength,
  10246. "step": step.value,
  10247. "class": "uni-input-input",
  10248. "style": props2.cursorColor ? {
  10249. caretColor: props2.cursorColor
  10250. } : {},
  10251. "onFocus": (event) => event.target.blur()
  10252. }, null, 44, ["value", "readonly", "type", "maxlength", "step", "onFocus"]) : createVNode("input", {
  10253. "key": "input",
  10254. "ref": fieldRef,
  10255. "value": state2.value,
  10256. "onInput": (event) => {
  10257. state2.value = event.target.value.toString();
  10258. },
  10259. "disabled": !!props2.disabled,
  10260. "type": type.value,
  10261. "maxlength": state2.maxlength,
  10262. "step": step.value,
  10263. "enterkeyhint": props2.confirmType,
  10264. "pattern": props2.type === "number" ? "[0-9]*" : void 0,
  10265. "class": "uni-input-input",
  10266. "style": props2.cursorColor ? {
  10267. caretColor: props2.cursorColor
  10268. } : {},
  10269. "autocomplete": autocomplete.value,
  10270. "onKeyup": onKeyUpEnter,
  10271. "inputmode": props2.inputmode
  10272. }, null, 44, ["value", "onInput", "disabled", "type", "maxlength", "step", "enterkeyhint", "pattern", "autocomplete", "onKeyup", "inputmode"]);
  10273. return createVNode("uni-input", {
  10274. "ref": rootRef
  10275. }, [createVNode("div", {
  10276. "class": "uni-input-wrapper"
  10277. }, [withDirectives(createVNode("div", mergeProps(scopedAttrsState.attrs, {
  10278. "style": props2.placeholderStyle,
  10279. "class": ["uni-input-placeholder", props2.placeholderClass]
  10280. }), [props2.placeholder], 16), [[vShow, !(state2.value.length || cache.value === "-" || cache.value.includes("."))]]), props2.confirmType === "search" ? createVNode("form", {
  10281. "action": "",
  10282. "onSubmit": (event) => event.preventDefault(),
  10283. "class": "uni-input-form"
  10284. }, [inputNode], 40, ["onSubmit"]) : inputNode])], 512);
  10285. };
  10286. }
  10287. });
  10288. function entries(obj) {
  10289. return Object.keys(obj).map((key) => [key, obj[key]]);
  10290. }
  10291. const DEFAULT_EXCLUDE_KEYS = ["class", "style"];
  10292. const LISTENER_PREFIX = /^on[A-Z]+/;
  10293. const useAttrs = (params = {}) => {
  10294. const { excludeListeners = false, excludeKeys = [] } = params;
  10295. const instance2 = getCurrentInstance();
  10296. const attrs2 = shallowRef({});
  10297. const listeners2 = shallowRef({});
  10298. const excludeAttrs = shallowRef({});
  10299. const allExcludeKeys = excludeKeys.concat(DEFAULT_EXCLUDE_KEYS);
  10300. instance2.attrs = reactive(instance2.attrs);
  10301. watchEffect(() => {
  10302. const res = entries(instance2.attrs).reduce(
  10303. (acc, [key, val]) => {
  10304. if (allExcludeKeys.includes(key)) {
  10305. acc.exclude[key] = val;
  10306. } else if (LISTENER_PREFIX.test(key)) {
  10307. if (!excludeListeners) {
  10308. acc.attrs[key] = val;
  10309. }
  10310. acc.listeners[key] = val;
  10311. } else {
  10312. acc.attrs[key] = val;
  10313. }
  10314. return acc;
  10315. },
  10316. {
  10317. exclude: {},
  10318. attrs: {},
  10319. listeners: {}
  10320. }
  10321. );
  10322. attrs2.value = res.attrs;
  10323. listeners2.value = res.listeners;
  10324. excludeAttrs.value = res.exclude;
  10325. });
  10326. return { $attrs: attrs2, $listeners: listeners2, $excludeAttrs: excludeAttrs };
  10327. };
  10328. function flatVNode(nodes) {
  10329. const array = [];
  10330. if (isArray(nodes)) {
  10331. nodes.forEach((vnode) => {
  10332. if (isVNode(vnode)) {
  10333. if (vnode.type === Fragment) {
  10334. array.push(...flatVNode(vnode.children));
  10335. } else {
  10336. array.push(vnode);
  10337. }
  10338. } else if (isArray(vnode)) {
  10339. array.push(...flatVNode(vnode));
  10340. }
  10341. });
  10342. }
  10343. return array;
  10344. }
  10345. const movableAreaProps = {
  10346. scaleArea: {
  10347. type: Boolean,
  10348. default: false
  10349. }
  10350. };
  10351. class UniMovableAreaElement extends UniElement {
  10352. }
  10353. const MovableArea = /* @__PURE__ */ defineBuiltInComponent({
  10354. inheritAttrs: false,
  10355. name: "MovableArea",
  10356. props: movableAreaProps,
  10357. rootElement: {
  10358. name: "uni-movable-area",
  10359. class: UniMovableAreaElement
  10360. },
  10361. setup(props2, {
  10362. slots
  10363. }) {
  10364. const rootRef = ref(null);
  10365. const _isMounted = ref(false);
  10366. let {
  10367. setContexts,
  10368. events: movableAreaEvents
  10369. } = useMovableAreaState(props2, rootRef);
  10370. const {
  10371. $listeners,
  10372. $attrs,
  10373. $excludeAttrs
  10374. } = useAttrs();
  10375. const _listeners = $listeners.value;
  10376. let events = ["onTouchstart", "onTouchmove", "onTouchend"];
  10377. events.forEach((event) => {
  10378. let existing = _listeners[event];
  10379. let ours = movableAreaEvents[`_${event}`];
  10380. _listeners[event] = existing ? [].concat(existing, ours) : ours;
  10381. });
  10382. onMounted(() => {
  10383. movableAreaEvents._resize();
  10384. _isMounted.value = true;
  10385. });
  10386. let movableViewItems = [];
  10387. const originMovableViewContexts = [];
  10388. function updateMovableViewContexts() {
  10389. const contexts = [];
  10390. for (let index2 = 0; index2 < movableViewItems.length; index2++) {
  10391. let movableViewItem = movableViewItems[index2];
  10392. {
  10393. movableViewItem = movableViewItem.el;
  10394. }
  10395. const movableViewContext = originMovableViewContexts.find((context) => movableViewItem === context.rootRef.value);
  10396. if (movableViewContext) {
  10397. contexts.push(markRaw(movableViewContext));
  10398. }
  10399. }
  10400. setContexts(contexts);
  10401. }
  10402. const addMovableViewContext = (movableViewContext) => {
  10403. originMovableViewContexts.push(movableViewContext);
  10404. updateMovableViewContexts();
  10405. };
  10406. const removeMovableViewContext = (movableViewContext) => {
  10407. const index2 = originMovableViewContexts.indexOf(movableViewContext);
  10408. if (index2 >= 0) {
  10409. originMovableViewContexts.splice(index2, 1);
  10410. updateMovableViewContexts();
  10411. }
  10412. };
  10413. provide("_isMounted", _isMounted);
  10414. provide("movableAreaRootRef", rootRef);
  10415. provide("addMovableViewContext", addMovableViewContext);
  10416. provide("removeMovableViewContext", removeMovableViewContext);
  10417. onMounted(() => {
  10418. const rootElement = rootRef.value;
  10419. rootElement.attachVmProps(props2);
  10420. });
  10421. return () => {
  10422. const defaultSlots = slots.default && slots.default();
  10423. {
  10424. movableViewItems = flatVNode(defaultSlots);
  10425. }
  10426. return createVNode("uni-movable-area", mergeProps({
  10427. "ref": rootRef
  10428. }, $attrs.value, $excludeAttrs.value, _listeners), [createVNode(ResizeSensor, {
  10429. "onResize": movableAreaEvents._resize
  10430. }, null, 8, ["onResize"]), movableViewItems], 16);
  10431. };
  10432. }
  10433. });
  10434. function calc(e2) {
  10435. return Math.sqrt(e2.x * e2.x + e2.y * e2.y);
  10436. }
  10437. function useMovableAreaState(props2, rootRef) {
  10438. const width = ref(0);
  10439. const height = ref(0);
  10440. const gapV = reactive({
  10441. x: null,
  10442. y: null
  10443. });
  10444. const pinchStartLen = ref(null);
  10445. let _scaleMovableView = null;
  10446. let movableViewContexts = [];
  10447. function _updateScale(e2) {
  10448. if (e2 && e2 !== 1) {
  10449. if (props2.scaleArea) {
  10450. movableViewContexts.forEach(function(item) {
  10451. item._setScale(e2);
  10452. });
  10453. } else {
  10454. if (_scaleMovableView) {
  10455. _scaleMovableView._setScale(e2);
  10456. }
  10457. }
  10458. }
  10459. }
  10460. function _find(target, items = movableViewContexts) {
  10461. let root = rootRef.value;
  10462. function get(node) {
  10463. for (let i = 0; i < items.length; i++) {
  10464. const item = items[i];
  10465. if (node === item.rootRef.value) {
  10466. return item;
  10467. }
  10468. }
  10469. if (node === root || node === document.body || node === document) {
  10470. return null;
  10471. }
  10472. return get(node.parentNode);
  10473. }
  10474. return get(target);
  10475. }
  10476. const _onTouchstart = withWebEvent((t2) => {
  10477. let i = t2.touches;
  10478. if (i) {
  10479. if (i.length > 1) {
  10480. let r = {
  10481. x: i[1].pageX - i[0].pageX,
  10482. y: i[1].pageY - i[0].pageY
  10483. };
  10484. pinchStartLen.value = calc(r);
  10485. gapV.x = r.x;
  10486. gapV.y = r.y;
  10487. if (!props2.scaleArea) {
  10488. let touch0 = _find(i[0].target);
  10489. let touch1 = _find(i[1].target);
  10490. _scaleMovableView = touch0 && touch0 === touch1 ? touch0 : null;
  10491. }
  10492. }
  10493. }
  10494. });
  10495. const _onTouchmove = withWebEvent((t2) => {
  10496. let n = t2.touches;
  10497. if (n) {
  10498. if (n.length > 1) {
  10499. t2.preventDefault();
  10500. let i = {
  10501. x: n[1].pageX - n[0].pageX,
  10502. y: n[1].pageY - n[0].pageY
  10503. };
  10504. if (gapV.x !== null && pinchStartLen.value && pinchStartLen.value > 0) {
  10505. let r = calc(i) / pinchStartLen.value;
  10506. _updateScale(r);
  10507. }
  10508. gapV.x = i.x;
  10509. gapV.y = i.y;
  10510. }
  10511. }
  10512. });
  10513. const _onTouchend = withWebEvent((e2) => {
  10514. let t2 = e2.touches;
  10515. if (!(t2 && t2.length)) {
  10516. if (e2.changedTouches) {
  10517. gapV.x = 0;
  10518. gapV.y = 0;
  10519. pinchStartLen.value = null;
  10520. if (props2.scaleArea) {
  10521. movableViewContexts.forEach(function(item) {
  10522. item._endScale();
  10523. });
  10524. } else {
  10525. if (_scaleMovableView) {
  10526. _scaleMovableView._endScale();
  10527. }
  10528. }
  10529. }
  10530. }
  10531. });
  10532. function _resize() {
  10533. _getWH();
  10534. movableViewContexts.forEach(function(item, index2) {
  10535. item.setParent();
  10536. });
  10537. }
  10538. function _getWH() {
  10539. let style = window.getComputedStyle(rootRef.value);
  10540. let rect = rootRef.value.getBoundingClientRect();
  10541. width.value = rect.width - ["Left", "Right"].reduce(function(all, item) {
  10542. const LEFT = "border" + item + "Width";
  10543. const RIGHT = "padding" + item;
  10544. return all + parseFloat(style[LEFT]) + parseFloat(style[RIGHT]);
  10545. }, 0);
  10546. height.value = rect.height - ["Top", "Bottom"].reduce(function(all, item) {
  10547. const TOP = "border" + item + "Width";
  10548. const BOTTOM = "padding" + item;
  10549. return all + parseFloat(style[TOP]) + parseFloat(style[BOTTOM]);
  10550. }, 0);
  10551. }
  10552. provide("movableAreaWidth", width);
  10553. provide("movableAreaHeight", height);
  10554. return {
  10555. setContexts(contexts) {
  10556. movableViewContexts = contexts;
  10557. },
  10558. events: {
  10559. _onTouchstart,
  10560. _onTouchmove,
  10561. _onTouchend,
  10562. _resize
  10563. }
  10564. };
  10565. }
  10566. const addListenerToElement = function(element, type, callback, capture) {
  10567. element.addEventListener(
  10568. type,
  10569. ($event) => {
  10570. if (isFunction(callback)) {
  10571. if (callback($event) === false) {
  10572. if (typeof $event.cancelable !== "undefined" ? $event.cancelable : true) {
  10573. $event.preventDefault();
  10574. }
  10575. $event.stopPropagation();
  10576. }
  10577. }
  10578. },
  10579. {
  10580. passive: false
  10581. }
  10582. );
  10583. };
  10584. let __mouseMoveEventListener;
  10585. let __mouseUpEventListener;
  10586. function useTouchtrack(element, method, useCancel) {
  10587. onBeforeUnmount(() => {
  10588. document.removeEventListener("mousemove", __mouseMoveEventListener);
  10589. document.removeEventListener("mouseup", __mouseUpEventListener);
  10590. });
  10591. let x0 = 0;
  10592. let y0 = 0;
  10593. let x1 = 0;
  10594. let y1 = 0;
  10595. const fn = function($event, state2, x, y) {
  10596. if (method({
  10597. // @ts-expect-error
  10598. cancelable: $event.cancelable,
  10599. target: $event.target,
  10600. currentTarget: $event.currentTarget,
  10601. preventDefault: $event.preventDefault.bind($event),
  10602. stopPropagation: $event.stopPropagation.bind($event),
  10603. touches: $event.touches,
  10604. changedTouches: $event.changedTouches,
  10605. detail: {
  10606. state: state2,
  10607. x,
  10608. y,
  10609. dx: x - x0,
  10610. dy: y - y0,
  10611. ddx: x - x1,
  10612. ddy: y - y1,
  10613. timeStamp: $event.timeStamp
  10614. }
  10615. }) === false) {
  10616. return false;
  10617. }
  10618. };
  10619. let $eventOld = null;
  10620. let hasTouchStart;
  10621. let hasMouseDown;
  10622. addListenerToElement(element, "touchstart", function($event) {
  10623. hasTouchStart = true;
  10624. if ($event.touches.length === 1 && !$eventOld) {
  10625. $eventOld = $event;
  10626. x0 = x1 = $event.touches[0].pageX;
  10627. y0 = y1 = $event.touches[0].pageY;
  10628. return fn($event, "start", x0, y0);
  10629. }
  10630. });
  10631. addListenerToElement(element, "mousedown", function($event) {
  10632. hasMouseDown = true;
  10633. if (!hasTouchStart && !$eventOld) {
  10634. $eventOld = $event;
  10635. x0 = x1 = $event.pageX;
  10636. y0 = y1 = $event.pageY;
  10637. return fn($event, "start", x0, y0);
  10638. }
  10639. });
  10640. addListenerToElement(element, "touchmove", function($event) {
  10641. if ($event.touches.length === 1 && $eventOld) {
  10642. const res = fn(
  10643. $event,
  10644. "move",
  10645. $event.touches[0].pageX,
  10646. $event.touches[0].pageY
  10647. );
  10648. x1 = $event.touches[0].pageX;
  10649. y1 = $event.touches[0].pageY;
  10650. return res;
  10651. }
  10652. });
  10653. const mouseMoveEventListener = __mouseMoveEventListener = function($event) {
  10654. if (!hasTouchStart && hasMouseDown && $eventOld) {
  10655. const res = fn($event, "move", $event.pageX, $event.pageY);
  10656. x1 = $event.pageX;
  10657. y1 = $event.pageY;
  10658. return res;
  10659. }
  10660. };
  10661. document.addEventListener("mousemove", mouseMoveEventListener);
  10662. addListenerToElement(element, "touchend", function($event) {
  10663. if ($event.touches.length === 0 && $eventOld) {
  10664. hasTouchStart = false;
  10665. $eventOld = null;
  10666. return fn(
  10667. $event,
  10668. "end",
  10669. $event.changedTouches[0].pageX,
  10670. $event.changedTouches[0].pageY
  10671. );
  10672. }
  10673. });
  10674. const mouseUpEventListener = __mouseUpEventListener = function($event) {
  10675. hasMouseDown = false;
  10676. if (!hasTouchStart && $eventOld) {
  10677. $eventOld = null;
  10678. return fn($event, "end", $event.pageX, $event.pageY);
  10679. }
  10680. };
  10681. document.addEventListener("mouseup", mouseUpEventListener);
  10682. addListenerToElement(element, "touchcancel", function($event) {
  10683. if ($eventOld) {
  10684. hasTouchStart = false;
  10685. const $eventTemp = $eventOld;
  10686. $eventOld = null;
  10687. return fn(
  10688. $event,
  10689. useCancel ? "cancel" : "end",
  10690. $eventTemp.touches[0].pageX,
  10691. $eventTemp.touches[0].pageY
  10692. );
  10693. }
  10694. });
  10695. }
  10696. function e(e2, t2, n) {
  10697. return e2 > t2 - n && e2 < t2 + n;
  10698. }
  10699. function t(t2, n) {
  10700. return e(t2, 0, n);
  10701. }
  10702. function Decline() {
  10703. }
  10704. Decline.prototype.x = function(e2) {
  10705. return Math.sqrt(e2);
  10706. };
  10707. function Friction$1(e2, t2) {
  10708. this._m = e2;
  10709. this._f = 1e3 * t2;
  10710. this._startTime = 0;
  10711. this._v = 0;
  10712. }
  10713. Friction$1.prototype.setV = function(x, y) {
  10714. const n = Math.pow(Math.pow(x, 2) + Math.pow(y, 2), 0.5);
  10715. this._x_v = x;
  10716. this._y_v = y;
  10717. this._x_a = -this._f * this._x_v / n;
  10718. this._y_a = -this._f * this._y_v / n;
  10719. this._t = Math.abs(x / this._x_a) || Math.abs(y / this._y_a);
  10720. this._lastDt = null;
  10721. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  10722. };
  10723. Friction$1.prototype.setS = function(x, y) {
  10724. this._x_s = x;
  10725. this._y_s = y;
  10726. };
  10727. Friction$1.prototype.s = function(t2) {
  10728. if (void 0 === t2) {
  10729. t2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  10730. }
  10731. if (t2 > this._t) {
  10732. t2 = this._t;
  10733. this._lastDt = t2;
  10734. }
  10735. let x = this._x_v * t2 + 0.5 * this._x_a * Math.pow(t2, 2) + this._x_s;
  10736. let y = this._y_v * t2 + 0.5 * this._y_a * Math.pow(t2, 2) + this._y_s;
  10737. if (this._x_a > 0 && x < this._endPositionX || this._x_a < 0 && x > this._endPositionX) {
  10738. x = this._endPositionX;
  10739. }
  10740. if (this._y_a > 0 && y < this._endPositionY || this._y_a < 0 && y > this._endPositionY) {
  10741. y = this._endPositionY;
  10742. }
  10743. return {
  10744. x,
  10745. y
  10746. };
  10747. };
  10748. Friction$1.prototype.ds = function(t2) {
  10749. if (void 0 === t2) {
  10750. t2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  10751. }
  10752. if (t2 > this._t) {
  10753. t2 = this._t;
  10754. }
  10755. return {
  10756. dx: this._x_v + this._x_a * t2,
  10757. dy: this._y_v + this._y_a * t2
  10758. };
  10759. };
  10760. Friction$1.prototype.delta = function() {
  10761. return {
  10762. x: -1.5 * Math.pow(this._x_v, 2) / this._x_a || 0,
  10763. y: -1.5 * Math.pow(this._y_v, 2) / this._y_a || 0
  10764. };
  10765. };
  10766. Friction$1.prototype.dt = function() {
  10767. return -this._x_v / this._x_a;
  10768. };
  10769. Friction$1.prototype.done = function() {
  10770. const t2 = e(this.s().x, this._endPositionX) || e(this.s().y, this._endPositionY) || this._lastDt === this._t;
  10771. this._lastDt = null;
  10772. return t2;
  10773. };
  10774. Friction$1.prototype.setEnd = function(x, y) {
  10775. this._endPositionX = x;
  10776. this._endPositionY = y;
  10777. };
  10778. Friction$1.prototype.reconfigure = function(m, f2) {
  10779. this._m = m;
  10780. this._f = 1e3 * f2;
  10781. };
  10782. function Spring$1(m, k, c) {
  10783. this._m = m;
  10784. this._k = k;
  10785. this._c = c;
  10786. this._solution = null;
  10787. this._endPosition = 0;
  10788. this._startTime = 0;
  10789. }
  10790. Spring$1.prototype._solve = function(e2, t2) {
  10791. const n = this._c;
  10792. const i = this._m;
  10793. const r = this._k;
  10794. const o2 = n * n - 4 * i * r;
  10795. if (o2 === 0) {
  10796. const a2 = -n / (2 * i);
  10797. const s = e2;
  10798. const l = t2 / (a2 * e2);
  10799. return {
  10800. x: function(e3) {
  10801. return (s + l * e3) * Math.pow(Math.E, a2 * e3);
  10802. },
  10803. dx: function(e3) {
  10804. const t3 = Math.pow(Math.E, a2 * e3);
  10805. return a2 * (s + l * e3) * t3 + l * t3;
  10806. }
  10807. };
  10808. }
  10809. if (o2 > 0) {
  10810. const c = (-n - Math.sqrt(o2)) / (2 * i);
  10811. const u = (-n + Math.sqrt(o2)) / (2 * i);
  10812. const d = (t2 - c * e2) / (u - c);
  10813. const h2 = e2 - d;
  10814. return {
  10815. x: function(e3) {
  10816. let t3;
  10817. let n2;
  10818. if (e3 === this._t) {
  10819. t3 = this._powER1T;
  10820. n2 = this._powER2T;
  10821. }
  10822. this._t = e3;
  10823. if (!t3) {
  10824. t3 = this._powER1T = Math.pow(Math.E, c * e3);
  10825. }
  10826. if (!n2) {
  10827. n2 = this._powER2T = Math.pow(Math.E, u * e3);
  10828. }
  10829. return h2 * t3 + d * n2;
  10830. },
  10831. dx: function(e3) {
  10832. let t3;
  10833. let n2;
  10834. if (e3 === this._t) {
  10835. t3 = this._powER1T;
  10836. n2 = this._powER2T;
  10837. }
  10838. this._t = e3;
  10839. if (!t3) {
  10840. t3 = this._powER1T = Math.pow(Math.E, c * e3);
  10841. }
  10842. if (!n2) {
  10843. n2 = this._powER2T = Math.pow(Math.E, u * e3);
  10844. }
  10845. return h2 * c * t3 + d * u * n2;
  10846. }
  10847. };
  10848. }
  10849. const p2 = Math.sqrt(4 * i * r - n * n) / (2 * i);
  10850. const f2 = -n / 2 * i;
  10851. const v2 = e2;
  10852. const g2 = (t2 - f2 * e2) / p2;
  10853. return {
  10854. x: function(e3) {
  10855. return Math.pow(Math.E, f2 * e3) * (v2 * Math.cos(p2 * e3) + g2 * Math.sin(p2 * e3));
  10856. },
  10857. dx: function(e3) {
  10858. const t3 = Math.pow(Math.E, f2 * e3);
  10859. const n2 = Math.cos(p2 * e3);
  10860. const i2 = Math.sin(p2 * e3);
  10861. return t3 * (g2 * p2 * n2 - v2 * p2 * i2) + f2 * t3 * (g2 * i2 + v2 * n2);
  10862. }
  10863. };
  10864. };
  10865. Spring$1.prototype.x = function(e2) {
  10866. if (void 0 === e2) {
  10867. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  10868. }
  10869. return this._solution ? this._endPosition + this._solution.x(e2) : 0;
  10870. };
  10871. Spring$1.prototype.dx = function(e2) {
  10872. if (void 0 === e2) {
  10873. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  10874. }
  10875. return this._solution ? this._solution.dx(e2) : 0;
  10876. };
  10877. Spring$1.prototype.setEnd = function(e2, n, i) {
  10878. if (!i) {
  10879. i = (/* @__PURE__ */ new Date()).getTime();
  10880. }
  10881. if (e2 !== this._endPosition || !t(n, 0.1)) {
  10882. n = n || 0;
  10883. let r = this._endPosition;
  10884. if (this._solution) {
  10885. if (t(n, 0.1)) {
  10886. n = this._solution.dx((i - this._startTime) / 1e3);
  10887. }
  10888. r = this._solution.x((i - this._startTime) / 1e3);
  10889. if (t(n, 0.1)) {
  10890. n = 0;
  10891. }
  10892. if (t(r, 0.1)) {
  10893. r = 0;
  10894. }
  10895. r += this._endPosition;
  10896. }
  10897. if (!(this._solution && t(r - e2, 0.1) && t(n, 0.1))) {
  10898. this._endPosition = e2;
  10899. this._solution = this._solve(r - this._endPosition, n);
  10900. this._startTime = i;
  10901. }
  10902. }
  10903. };
  10904. Spring$1.prototype.snap = function(e2) {
  10905. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  10906. this._endPosition = e2;
  10907. this._solution = {
  10908. x: function() {
  10909. return 0;
  10910. },
  10911. dx: function() {
  10912. return 0;
  10913. }
  10914. };
  10915. };
  10916. Spring$1.prototype.done = function(n) {
  10917. if (!n) {
  10918. n = (/* @__PURE__ */ new Date()).getTime();
  10919. }
  10920. return e(this.x(), this._endPosition, 0.1) && t(this.dx(), 0.1);
  10921. };
  10922. Spring$1.prototype.reconfigure = function(m, t2, c) {
  10923. this._m = m;
  10924. this._k = t2;
  10925. this._c = c;
  10926. if (!this.done()) {
  10927. this._solution = this._solve(this.x() - this._endPosition, this.dx());
  10928. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  10929. }
  10930. };
  10931. Spring$1.prototype.springConstant = function() {
  10932. return this._k;
  10933. };
  10934. Spring$1.prototype.damping = function() {
  10935. return this._c;
  10936. };
  10937. Spring$1.prototype.configuration = function() {
  10938. function e2(e3, t3) {
  10939. e3.reconfigure(1, t3, e3.damping());
  10940. }
  10941. function t2(e3, t3) {
  10942. e3.reconfigure(1, e3.springConstant(), t3);
  10943. }
  10944. return [
  10945. {
  10946. label: "Spring Constant",
  10947. read: this.springConstant.bind(this),
  10948. write: e2.bind(this, this),
  10949. min: 100,
  10950. max: 1e3
  10951. },
  10952. {
  10953. label: "Damping",
  10954. read: this.damping.bind(this),
  10955. write: t2.bind(this, this),
  10956. min: 1,
  10957. max: 500
  10958. }
  10959. ];
  10960. };
  10961. function STD(e2, t2, n) {
  10962. this._springX = new Spring$1(e2, t2, n);
  10963. this._springY = new Spring$1(e2, t2, n);
  10964. this._springScale = new Spring$1(e2, t2, n);
  10965. this._startTime = 0;
  10966. }
  10967. STD.prototype.setEnd = function(e2, t2, n, i) {
  10968. const r = (/* @__PURE__ */ new Date()).getTime();
  10969. this._springX.setEnd(e2, i, r);
  10970. this._springY.setEnd(t2, i, r);
  10971. this._springScale.setEnd(n, i, r);
  10972. this._startTime = r;
  10973. };
  10974. STD.prototype.x = function() {
  10975. const e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  10976. return {
  10977. x: this._springX.x(e2),
  10978. y: this._springY.x(e2),
  10979. scale: this._springScale.x(e2)
  10980. };
  10981. };
  10982. STD.prototype.done = function() {
  10983. const e2 = (/* @__PURE__ */ new Date()).getTime();
  10984. return this._springX.done(e2) && this._springY.done(e2) && this._springScale.done(e2);
  10985. };
  10986. STD.prototype.reconfigure = function(e2, t2, n) {
  10987. this._springX.reconfigure(e2, t2, n);
  10988. this._springY.reconfigure(e2, t2, n);
  10989. this._springScale.reconfigure(e2, t2, n);
  10990. };
  10991. const movableViewProps = {
  10992. direction: {
  10993. type: String,
  10994. default: "none"
  10995. },
  10996. inertia: {
  10997. type: [Boolean, String],
  10998. default: false
  10999. },
  11000. outOfBounds: {
  11001. type: [Boolean, String],
  11002. default: false
  11003. },
  11004. x: {
  11005. type: [Number, String],
  11006. default: 0
  11007. },
  11008. y: {
  11009. type: [Number, String],
  11010. default: 0
  11011. },
  11012. damping: {
  11013. type: [Number, String],
  11014. default: 20
  11015. },
  11016. friction: {
  11017. type: [Number, String],
  11018. default: 2
  11019. },
  11020. disabled: {
  11021. type: [Boolean, String],
  11022. default: false
  11023. },
  11024. scale: {
  11025. type: [Boolean, String],
  11026. default: false
  11027. },
  11028. scaleMin: {
  11029. type: [Number, String],
  11030. default: 0.5
  11031. },
  11032. scaleMax: {
  11033. type: [Number, String],
  11034. default: 10
  11035. },
  11036. scaleValue: {
  11037. type: [Number, String],
  11038. default: 1
  11039. },
  11040. animation: {
  11041. type: [Boolean, String],
  11042. default: true
  11043. }
  11044. };
  11045. function v(a2, b) {
  11046. return +((1e3 * a2 - 1e3 * b) / 1e3).toFixed(1);
  11047. }
  11048. class UniMovableViewElement extends UniElement {
  11049. }
  11050. const MovableView = /* @__PURE__ */ defineBuiltInComponent({
  11051. name: "MovableView",
  11052. props: movableViewProps,
  11053. emits: ["change", "scale"],
  11054. rootElement: {
  11055. name: "uni-movable-view",
  11056. class: UniMovableViewElement
  11057. },
  11058. setup(props2, {
  11059. slots,
  11060. emit: emit2
  11061. }) {
  11062. const rootRef = ref(null);
  11063. const trigger = useCustomEvent(rootRef, emit2);
  11064. const {
  11065. setParent
  11066. } = useMovableViewState(props2, trigger, rootRef);
  11067. onMounted(() => {
  11068. const rootElement = rootRef.value;
  11069. rootElement.attachVmProps(props2);
  11070. });
  11071. return () => {
  11072. return createVNode("uni-movable-view", {
  11073. "ref": rootRef
  11074. }, [createVNode(ResizeSensor, {
  11075. "onResize": setParent
  11076. }, null, 8, ["onResize"]), slots.default && slots.default()], 512);
  11077. };
  11078. }
  11079. });
  11080. let requesting = false;
  11081. function _requestAnimationFrame(e2) {
  11082. if (!requesting) {
  11083. requesting = true;
  11084. requestAnimationFrame(function() {
  11085. e2();
  11086. requesting = false;
  11087. });
  11088. }
  11089. }
  11090. function p(t2, n) {
  11091. if (t2 === n) {
  11092. return 0;
  11093. }
  11094. let i = t2.offsetLeft;
  11095. return t2.offsetParent ? i += p(t2.offsetParent, n) : 0;
  11096. }
  11097. function f(t2, n) {
  11098. if (t2 === n) {
  11099. return 0;
  11100. }
  11101. let i = t2.offsetTop;
  11102. return t2.offsetParent ? i += f(t2.offsetParent, n) : 0;
  11103. }
  11104. function g(friction, execute, endCallback) {
  11105. let record = {
  11106. id: 0,
  11107. cancelled: false
  11108. };
  11109. let cancel = function(record2) {
  11110. if (record2 && record2.id) {
  11111. cancelAnimationFrame(record2.id);
  11112. }
  11113. if (record2) {
  11114. record2.cancelled = true;
  11115. }
  11116. };
  11117. function fn(record2, friction2, execute2, endCallback2) {
  11118. if (!record2 || !record2.cancelled) {
  11119. execute2(friction2);
  11120. let isDone = friction2.done();
  11121. if (!isDone) {
  11122. if (!record2.cancelled) {
  11123. record2.id = requestAnimationFrame(fn.bind(null, record2, friction2, execute2, endCallback2));
  11124. }
  11125. }
  11126. if (isDone && endCallback2) {
  11127. endCallback2(friction2);
  11128. }
  11129. }
  11130. }
  11131. fn(record, friction, execute, endCallback);
  11132. return {
  11133. cancel: cancel.bind(null, record),
  11134. model: friction
  11135. };
  11136. }
  11137. function _getPx(val) {
  11138. if (/\d+[ur]px$/i.test(val)) {
  11139. return uni.upx2px(parseFloat(val));
  11140. }
  11141. return Number(val) || 0;
  11142. }
  11143. function useMovableViewLayout(rootRef, _scale, _adjustScale) {
  11144. const movableAreaWidth = inject("movableAreaWidth", ref(0));
  11145. const movableAreaHeight = inject("movableAreaHeight", ref(0));
  11146. const movableAreaRootRef = inject("movableAreaRootRef");
  11147. const _offset = {
  11148. x: 0,
  11149. y: 0
  11150. };
  11151. const _scaleOffset = {
  11152. x: 0,
  11153. y: 0
  11154. };
  11155. const width = ref(0);
  11156. const height = ref(0);
  11157. const minX = ref(0);
  11158. const minY = ref(0);
  11159. const maxX = ref(0);
  11160. const maxY = ref(0);
  11161. function _updateBoundary() {
  11162. let x = 0 - _offset.x + _scaleOffset.x;
  11163. let _width = movableAreaWidth.value - width.value - _offset.x - _scaleOffset.x;
  11164. minX.value = Math.min(x, _width);
  11165. maxX.value = Math.max(x, _width);
  11166. let y = 0 - _offset.y + _scaleOffset.y;
  11167. let _height = movableAreaHeight.value - height.value - _offset.y - _scaleOffset.y;
  11168. minY.value = Math.min(y, _height);
  11169. maxY.value = Math.max(y, _height);
  11170. }
  11171. function _updateOffset() {
  11172. _offset.x = p(rootRef.value, movableAreaRootRef.value);
  11173. _offset.y = f(rootRef.value, movableAreaRootRef.value);
  11174. }
  11175. function _updateWH(scale) {
  11176. scale = scale || _scale.value;
  11177. scale = _adjustScale(scale);
  11178. let rect = rootRef.value.getBoundingClientRect();
  11179. height.value = rect.height / _scale.value;
  11180. width.value = rect.width / _scale.value;
  11181. let _height = height.value * scale;
  11182. let _width = width.value * scale;
  11183. _scaleOffset.x = (_width - width.value) / 2;
  11184. _scaleOffset.y = (_height - height.value) / 2;
  11185. }
  11186. return {
  11187. _updateBoundary,
  11188. _updateOffset,
  11189. _updateWH,
  11190. _scaleOffset,
  11191. minX,
  11192. minY,
  11193. maxX,
  11194. maxY
  11195. };
  11196. }
  11197. function useMovableViewTransform(rootRef, props2, _scaleOffset, _scale, maxX, maxY, minX, minY, _translateX, _translateY, _SFA, _FA, _adjustScale, trigger) {
  11198. const dampingNumber = computed(() => {
  11199. let val = Number(props2.damping);
  11200. return isNaN(val) ? 20 : val;
  11201. });
  11202. const xMove = computed(() => props2.direction === "all" || props2.direction === "horizontal");
  11203. const yMove = computed(() => props2.direction === "all" || props2.direction === "vertical");
  11204. const xSync = ref(_getPx(props2.x));
  11205. const ySync = ref(_getPx(props2.y));
  11206. watch(() => props2.x, (val) => {
  11207. xSync.value = _getPx(val);
  11208. });
  11209. watch(() => props2.y, (val) => {
  11210. ySync.value = _getPx(val);
  11211. });
  11212. watch(xSync, (val) => {
  11213. _setX(val);
  11214. });
  11215. watch(ySync, (val) => {
  11216. _setY(val);
  11217. });
  11218. const _STD = new STD(1, 9 * Math.pow(dampingNumber.value, 2) / 40, dampingNumber.value);
  11219. function _getLimitXY(x, y) {
  11220. let outOfBounds = false;
  11221. if (x > maxX.value) {
  11222. x = maxX.value;
  11223. outOfBounds = true;
  11224. } else {
  11225. if (x < minX.value) {
  11226. x = minX.value;
  11227. outOfBounds = true;
  11228. }
  11229. }
  11230. if (y > maxY.value) {
  11231. y = maxY.value;
  11232. outOfBounds = true;
  11233. } else {
  11234. if (y < minY.value) {
  11235. y = minY.value;
  11236. outOfBounds = true;
  11237. }
  11238. }
  11239. return {
  11240. x,
  11241. y,
  11242. outOfBounds
  11243. };
  11244. }
  11245. function FAandSFACancel() {
  11246. if (_FA) {
  11247. _FA.cancel();
  11248. }
  11249. if (_SFA) {
  11250. _SFA.cancel();
  11251. }
  11252. }
  11253. function _animationTo(x, y, scale, source, r, o2) {
  11254. FAandSFACancel();
  11255. if (!xMove.value) {
  11256. x = _translateX.value;
  11257. }
  11258. if (!yMove.value) {
  11259. y = _translateY.value;
  11260. }
  11261. if (!props2.scale) {
  11262. scale = _scale.value;
  11263. }
  11264. let limitXY = _getLimitXY(x, y);
  11265. x = limitXY.x;
  11266. y = limitXY.y;
  11267. if (!props2.animation) {
  11268. _setTransform(x, y, scale, source, r, o2);
  11269. return;
  11270. }
  11271. _STD._springX._solution = null;
  11272. _STD._springY._solution = null;
  11273. _STD._springScale._solution = null;
  11274. _STD._springX._endPosition = _translateX.value;
  11275. _STD._springY._endPosition = _translateY.value;
  11276. _STD._springScale._endPosition = _scale.value;
  11277. _STD.setEnd(x, y, scale, 1);
  11278. _SFA = g(_STD, function() {
  11279. let data = _STD.x();
  11280. let x2 = data.x;
  11281. let y2 = data.y;
  11282. let scale2 = data.scale;
  11283. _setTransform(x2, y2, scale2, source, r, o2);
  11284. }, function() {
  11285. _SFA.cancel();
  11286. });
  11287. }
  11288. function _setTransform(x, y, scale, source = "", r, o2) {
  11289. if (!(x !== null && x.toString() !== "NaN" && typeof x === "number")) {
  11290. x = _translateX.value || 0;
  11291. }
  11292. if (!(y !== null && y.toString() !== "NaN" && typeof y === "number")) {
  11293. y = _translateY.value || 0;
  11294. }
  11295. x = Number(x.toFixed(1));
  11296. y = Number(y.toFixed(1));
  11297. scale = Number(scale.toFixed(1));
  11298. if (!(_translateX.value === x && _translateY.value === y)) {
  11299. if (!r) {
  11300. trigger("change", {}, {
  11301. x: v(x, _scaleOffset.x),
  11302. y: v(y, _scaleOffset.y),
  11303. source
  11304. });
  11305. }
  11306. }
  11307. if (!props2.scale) {
  11308. scale = _scale.value;
  11309. }
  11310. scale = _adjustScale(scale);
  11311. scale = +scale.toFixed(3);
  11312. if (o2 && scale !== _scale.value) {
  11313. trigger("scale", {}, {
  11314. x,
  11315. y,
  11316. scale
  11317. });
  11318. }
  11319. let transform = "translateX(" + x + "px) translateY(" + y + "px) translateZ(0px) scale(" + scale + ")";
  11320. if (rootRef.value) {
  11321. rootRef.value.style.transform = transform;
  11322. rootRef.value.style.webkitTransform = transform;
  11323. _translateX.value = x;
  11324. _translateY.value = y;
  11325. _scale.value = scale;
  11326. }
  11327. }
  11328. function _revise(source) {
  11329. let limitXY = _getLimitXY(_translateX.value, _translateY.value);
  11330. let x = limitXY.x;
  11331. let y = limitXY.y;
  11332. let outOfBounds = limitXY.outOfBounds;
  11333. if (outOfBounds) {
  11334. _animationTo(x, y, _scale.value, source);
  11335. }
  11336. return outOfBounds;
  11337. }
  11338. function _setX(val) {
  11339. if (xMove.value) {
  11340. if (val + _scaleOffset.x === _translateX.value) {
  11341. return _translateX;
  11342. } else {
  11343. if (_SFA) {
  11344. _SFA.cancel();
  11345. }
  11346. _animationTo(val + _scaleOffset.x, ySync.value + _scaleOffset.y, _scale.value);
  11347. }
  11348. }
  11349. return val;
  11350. }
  11351. function _setY(val) {
  11352. if (yMove.value) {
  11353. if (val + _scaleOffset.y === _translateY.value) {
  11354. return _translateY;
  11355. } else {
  11356. if (_SFA) {
  11357. _SFA.cancel();
  11358. }
  11359. _animationTo(xSync.value + _scaleOffset.x, val + _scaleOffset.y, _scale.value);
  11360. }
  11361. }
  11362. return val;
  11363. }
  11364. return {
  11365. FAandSFACancel,
  11366. _getLimitXY,
  11367. _animationTo,
  11368. _setTransform,
  11369. _revise,
  11370. dampingNumber,
  11371. xMove,
  11372. yMove,
  11373. xSync,
  11374. ySync,
  11375. _STD
  11376. };
  11377. }
  11378. function useMovableViewInit(props2, rootRef, trigger, _scale, _oldScale, _isScaling, _translateX, _translateY, _SFA, _FA) {
  11379. const scaleMinNumber = computed(() => {
  11380. let val = Number(props2.scaleMin);
  11381. return isNaN(val) ? 0.5 : val;
  11382. });
  11383. const scaleMaxNumber = computed(() => {
  11384. let val = Number(props2.scaleMax);
  11385. return isNaN(val) ? 10 : val;
  11386. });
  11387. const scaleValueSync = ref(Number(props2.scaleValue) || 1);
  11388. watch(scaleValueSync, (val) => {
  11389. _setScaleValue(val);
  11390. });
  11391. watch(scaleMinNumber, () => {
  11392. _setScaleMinOrMax();
  11393. });
  11394. watch(scaleMaxNumber, () => {
  11395. _setScaleMinOrMax();
  11396. });
  11397. watch(() => props2.scaleValue, (val) => {
  11398. scaleValueSync.value = Number(val) || 0;
  11399. });
  11400. const {
  11401. _updateBoundary,
  11402. _updateOffset,
  11403. _updateWH,
  11404. _scaleOffset,
  11405. minX,
  11406. minY,
  11407. maxX,
  11408. maxY
  11409. } = useMovableViewLayout(rootRef, _scale, _adjustScale);
  11410. const {
  11411. FAandSFACancel,
  11412. _getLimitXY,
  11413. _animationTo,
  11414. _setTransform,
  11415. _revise,
  11416. dampingNumber,
  11417. xMove,
  11418. yMove,
  11419. xSync,
  11420. ySync,
  11421. _STD
  11422. } = useMovableViewTransform(rootRef, props2, _scaleOffset, _scale, maxX, maxY, minX, minY, _translateX, _translateY, _SFA, _FA, _adjustScale, trigger);
  11423. function _updateScale(scale, animat) {
  11424. if (props2.scale) {
  11425. scale = _adjustScale(scale);
  11426. _updateWH(scale);
  11427. _updateBoundary();
  11428. const limitXY = _getLimitXY(_translateX.value, _translateY.value);
  11429. const x = limitXY.x;
  11430. const y = limitXY.y;
  11431. if (animat) {
  11432. _animationTo(x, y, scale, "", true, true);
  11433. } else {
  11434. _requestAnimationFrame(function() {
  11435. _setTransform(x, y, scale, "", true, true);
  11436. });
  11437. }
  11438. }
  11439. }
  11440. function _beginScale() {
  11441. _isScaling.value = true;
  11442. }
  11443. function _updateOldScale(scale) {
  11444. _oldScale.value = scale;
  11445. }
  11446. function _adjustScale(scale) {
  11447. scale = Math.max(0.5, scaleMinNumber.value, scale);
  11448. scale = Math.min(10, scaleMaxNumber.value, scale);
  11449. return scale;
  11450. }
  11451. function _setScaleMinOrMax() {
  11452. if (!props2.scale) {
  11453. return false;
  11454. }
  11455. _updateScale(_scale.value, true);
  11456. _updateOldScale(_scale.value);
  11457. }
  11458. function _setScaleValue(scale) {
  11459. if (!props2.scale) {
  11460. return false;
  11461. }
  11462. scale = _adjustScale(scale);
  11463. _updateScale(scale, true);
  11464. _updateOldScale(scale);
  11465. return scale;
  11466. }
  11467. function _endScale() {
  11468. _isScaling.value = false;
  11469. _updateOldScale(_scale.value);
  11470. }
  11471. function _setScale(scale) {
  11472. if (scale) {
  11473. scale = _oldScale.value * scale;
  11474. _beginScale();
  11475. _updateScale(scale);
  11476. }
  11477. }
  11478. return {
  11479. // scale
  11480. _updateOldScale,
  11481. _endScale,
  11482. _setScale,
  11483. scaleValueSync,
  11484. // layout
  11485. _updateBoundary,
  11486. _updateOffset,
  11487. _updateWH,
  11488. _scaleOffset,
  11489. minX,
  11490. minY,
  11491. maxX,
  11492. maxY,
  11493. // transform
  11494. FAandSFACancel,
  11495. _getLimitXY,
  11496. _animationTo,
  11497. _setTransform,
  11498. _revise,
  11499. dampingNumber,
  11500. xMove,
  11501. yMove,
  11502. xSync,
  11503. ySync,
  11504. _STD
  11505. };
  11506. }
  11507. function useMovableViewState(props2, trigger, rootRef) {
  11508. const _isMounted = inject("_isMounted", ref(false));
  11509. const addMovableViewContext = inject("addMovableViewContext", () => {
  11510. });
  11511. const removeMovableViewContext = inject("removeMovableViewContext", () => {
  11512. });
  11513. let _scale = ref(1);
  11514. let _oldScale = ref(1);
  11515. let _isScaling = ref(false);
  11516. let _translateX = ref(0);
  11517. let _translateY = ref(0);
  11518. let _SFA = null;
  11519. let _FA = null;
  11520. let _isTouching = false;
  11521. let __baseX;
  11522. let __baseY;
  11523. let _checkCanMove = null;
  11524. let _firstMoveDirection = null;
  11525. const _declineX = new Decline();
  11526. const _declineY = new Decline();
  11527. const __touchInfo = {
  11528. historyX: [0, 0],
  11529. historyY: [0, 0],
  11530. historyT: [0, 0]
  11531. };
  11532. const frictionNumber = computed(() => {
  11533. let val = Number(props2.friction);
  11534. return isNaN(val) || val <= 0 ? 2 : val;
  11535. });
  11536. const _friction = new Friction$1(1, frictionNumber.value);
  11537. watch(() => props2.disabled, () => {
  11538. __handleTouchStart();
  11539. });
  11540. const {
  11541. // scale
  11542. _updateOldScale,
  11543. _endScale,
  11544. _setScale,
  11545. scaleValueSync,
  11546. // layout
  11547. _updateBoundary,
  11548. _updateOffset,
  11549. _updateWH,
  11550. _scaleOffset,
  11551. minX,
  11552. minY,
  11553. maxX,
  11554. maxY,
  11555. // transform
  11556. FAandSFACancel,
  11557. _getLimitXY,
  11558. _setTransform,
  11559. _revise,
  11560. dampingNumber,
  11561. xMove,
  11562. yMove,
  11563. xSync,
  11564. ySync,
  11565. _STD
  11566. } = useMovableViewInit(props2, rootRef, trigger, _scale, _oldScale, _isScaling, _translateX, _translateY, _SFA, _FA);
  11567. function __handleTouchStart() {
  11568. if (!_isScaling.value) {
  11569. if (!props2.disabled) {
  11570. FAandSFACancel();
  11571. __touchInfo.historyX = [0, 0];
  11572. __touchInfo.historyY = [0, 0];
  11573. __touchInfo.historyT = [0, 0];
  11574. if (xMove.value) {
  11575. __baseX = _translateX.value;
  11576. }
  11577. if (yMove.value) {
  11578. __baseY = _translateY.value;
  11579. }
  11580. rootRef.value.style.willChange = "transform";
  11581. _checkCanMove = null;
  11582. _firstMoveDirection = null;
  11583. _isTouching = true;
  11584. }
  11585. }
  11586. }
  11587. function __handleTouchMove(event) {
  11588. if (!_isScaling.value && !props2.disabled && _isTouching) {
  11589. let x = _translateX.value;
  11590. let y = _translateY.value;
  11591. if (_firstMoveDirection === null) {
  11592. _firstMoveDirection = Math.abs(event.detail.dx / event.detail.dy) > 1 ? "htouchmove" : "vtouchmove";
  11593. }
  11594. if (xMove.value) {
  11595. x = event.detail.dx + __baseX;
  11596. __touchInfo.historyX.shift();
  11597. __touchInfo.historyX.push(x);
  11598. if (!yMove.value && _checkCanMove === null) {
  11599. _checkCanMove = Math.abs(event.detail.dx / event.detail.dy) < 1;
  11600. }
  11601. }
  11602. if (yMove.value) {
  11603. y = event.detail.dy + __baseY;
  11604. __touchInfo.historyY.shift();
  11605. __touchInfo.historyY.push(y);
  11606. if (!xMove.value && _checkCanMove === null) {
  11607. _checkCanMove = Math.abs(event.detail.dy / event.detail.dx) < 1;
  11608. }
  11609. }
  11610. __touchInfo.historyT.shift();
  11611. __touchInfo.historyT.push(event.detail.timeStamp);
  11612. if (!_checkCanMove) {
  11613. event.preventDefault();
  11614. let source = "touch";
  11615. if (x < minX.value) {
  11616. if (props2.outOfBounds) {
  11617. source = "touch-out-of-bounds";
  11618. x = minX.value - _declineX.x(minX.value - x);
  11619. } else {
  11620. x = minX.value;
  11621. }
  11622. } else if (x > maxX.value) {
  11623. if (props2.outOfBounds) {
  11624. source = "touch-out-of-bounds";
  11625. x = maxX.value + _declineX.x(x - maxX.value);
  11626. } else {
  11627. x = maxX.value;
  11628. }
  11629. }
  11630. if (y < minY.value) {
  11631. if (props2.outOfBounds) {
  11632. source = "touch-out-of-bounds";
  11633. y = minY.value - _declineY.x(minY.value - y);
  11634. } else {
  11635. y = minY.value;
  11636. }
  11637. } else {
  11638. if (y > maxY.value) {
  11639. if (props2.outOfBounds) {
  11640. source = "touch-out-of-bounds";
  11641. y = maxY.value + _declineY.x(y - maxY.value);
  11642. } else {
  11643. y = maxY.value;
  11644. }
  11645. }
  11646. }
  11647. _requestAnimationFrame(function() {
  11648. _setTransform(x, y, _scale.value, source);
  11649. });
  11650. }
  11651. }
  11652. }
  11653. function __handleTouchEnd() {
  11654. if (!_isScaling.value && !props2.disabled && _isTouching) {
  11655. rootRef.value.style.willChange = "auto";
  11656. _isTouching = false;
  11657. if (!_checkCanMove && !_revise("out-of-bounds") && props2.inertia) {
  11658. const xv = 1e3 * (__touchInfo.historyX[1] - __touchInfo.historyX[0]) / (__touchInfo.historyT[1] - __touchInfo.historyT[0]);
  11659. const yv = 1e3 * (__touchInfo.historyY[1] - __touchInfo.historyY[0]) / (__touchInfo.historyT[1] - __touchInfo.historyT[0]);
  11660. const __translateX = _translateX.value;
  11661. const __translateY = _translateY.value;
  11662. _friction.setV(xv, yv);
  11663. _friction.setS(__translateX, __translateY);
  11664. const x0 = _friction.delta().x;
  11665. const y0 = _friction.delta().y;
  11666. let x = x0 + __translateX;
  11667. let y = y0 + __translateY;
  11668. if (x < minX.value) {
  11669. x = minX.value;
  11670. y = __translateY + (minX.value - __translateX) * y0 / x0;
  11671. } else {
  11672. if (x > maxX.value) {
  11673. x = maxX.value;
  11674. y = __translateY + (maxX.value - __translateX) * y0 / x0;
  11675. }
  11676. }
  11677. if (y < minY.value) {
  11678. y = minY.value;
  11679. x = __translateX + (minY.value - __translateY) * x0 / y0;
  11680. } else {
  11681. if (y > maxY.value) {
  11682. y = maxY.value;
  11683. x = __translateX + (maxY.value - __translateY) * x0 / y0;
  11684. }
  11685. }
  11686. _friction.setEnd(x, y);
  11687. _FA = g(_friction, function() {
  11688. let t2 = _friction.s();
  11689. let x2 = t2.x;
  11690. let y2 = t2.y;
  11691. _setTransform(x2, y2, _scale.value, "friction");
  11692. }, function() {
  11693. _FA.cancel();
  11694. });
  11695. }
  11696. }
  11697. if (!props2.outOfBounds && !props2.inertia) {
  11698. FAandSFACancel();
  11699. }
  11700. }
  11701. function setParent() {
  11702. if (!_isMounted.value) {
  11703. return;
  11704. }
  11705. FAandSFACancel();
  11706. let scale = props2.scale ? scaleValueSync.value : 1;
  11707. _updateOffset();
  11708. _updateWH(scale);
  11709. _updateBoundary();
  11710. let limitXY = _getLimitXY(xSync.value + _scaleOffset.x, ySync.value + _scaleOffset.y);
  11711. let x = limitXY.x;
  11712. let y = limitXY.y;
  11713. _setTransform(x, y, scale, "", true);
  11714. _updateOldScale(scale);
  11715. }
  11716. onMounted(() => {
  11717. useTouchtrack(rootRef.value, (event) => {
  11718. switch (event.detail.state) {
  11719. case "start":
  11720. __handleTouchStart();
  11721. break;
  11722. case "move":
  11723. __handleTouchMove(event);
  11724. break;
  11725. case "end":
  11726. __handleTouchEnd();
  11727. }
  11728. });
  11729. setParent();
  11730. _friction.reconfigure(1, frictionNumber.value);
  11731. _STD.reconfigure(1, 9 * Math.pow(dampingNumber.value, 2) / 40, dampingNumber.value);
  11732. rootRef.value.style.transformOrigin = "center";
  11733. const context = {
  11734. rootRef,
  11735. setParent,
  11736. _endScale,
  11737. _setScale
  11738. };
  11739. addMovableViewContext(context);
  11740. onUnmounted(() => {
  11741. removeMovableViewContext(context);
  11742. });
  11743. });
  11744. onUnmounted(() => {
  11745. FAandSFACancel();
  11746. });
  11747. return {
  11748. setParent
  11749. };
  11750. }
  11751. const OPEN_TYPES = [
  11752. "navigate",
  11753. "redirect",
  11754. "switchTab",
  11755. "reLaunch",
  11756. "navigateBack"
  11757. ];
  11758. const ANIMATION_IN = [
  11759. "slide-in-right",
  11760. "slide-in-left",
  11761. "slide-in-top",
  11762. "slide-in-bottom",
  11763. "fade-in",
  11764. "zoom-out",
  11765. "zoom-fade-out",
  11766. "pop-in",
  11767. "none"
  11768. ];
  11769. const ANIMATION_OUT = [
  11770. "slide-out-right",
  11771. "slide-out-left",
  11772. "slide-out-top",
  11773. "slide-out-bottom",
  11774. "fade-out",
  11775. "zoom-in",
  11776. "zoom-fade-in",
  11777. "pop-out",
  11778. "none"
  11779. ];
  11780. const navigatorProps = {
  11781. hoverClass: {
  11782. type: String,
  11783. default: "navigator-hover"
  11784. },
  11785. url: {
  11786. type: String,
  11787. default: ""
  11788. },
  11789. openType: {
  11790. type: String,
  11791. default: "navigate",
  11792. validator(value) {
  11793. return Boolean(~OPEN_TYPES.indexOf(value));
  11794. }
  11795. },
  11796. delta: {
  11797. type: Number,
  11798. default: 1
  11799. },
  11800. hoverStartTime: {
  11801. type: [Number, String],
  11802. default: 50
  11803. },
  11804. hoverStayTime: {
  11805. type: [Number, String],
  11806. default: 600
  11807. },
  11808. exists: {
  11809. type: String,
  11810. default: ""
  11811. },
  11812. hoverStopPropagation: {
  11813. type: Boolean,
  11814. default: false
  11815. },
  11816. animationType: {
  11817. type: String,
  11818. default: "",
  11819. validator(value) {
  11820. return !value || ANIMATION_IN.concat(ANIMATION_OUT).includes(value);
  11821. }
  11822. },
  11823. animationDuration: {
  11824. type: [String, Number],
  11825. default: 300
  11826. }
  11827. };
  11828. function createNavigatorOnClick(props2) {
  11829. return () => {
  11830. if (props2.openType !== "navigateBack" && !props2.url) {
  11831. console.error(
  11832. "<navigator/> should have url attribute when using navigateTo, redirectTo, reLaunch or switchTab"
  11833. );
  11834. return;
  11835. }
  11836. const animationDuration = parseInt(props2.animationDuration);
  11837. switch (props2.openType) {
  11838. case "navigate":
  11839. uni.navigateTo({
  11840. url: props2.url,
  11841. animationType: props2.animationType || "pop-in",
  11842. animationDuration
  11843. });
  11844. break;
  11845. case "redirect":
  11846. uni.redirectTo({
  11847. url: props2.url,
  11848. exists: props2.exists
  11849. });
  11850. break;
  11851. case "switchTab":
  11852. uni.switchTab({
  11853. url: props2.url
  11854. });
  11855. break;
  11856. case "reLaunch":
  11857. uni.reLaunch({
  11858. url: props2.url
  11859. });
  11860. break;
  11861. case "navigateBack":
  11862. uni.navigateBack({
  11863. delta: props2.delta,
  11864. animationType: props2.animationType || "pop-out",
  11865. animationDuration
  11866. });
  11867. break;
  11868. }
  11869. };
  11870. }
  11871. class UniNavigatorElement extends UniElement {
  11872. }
  11873. const index$p = /* @__PURE__ */ defineBuiltInComponent({
  11874. name: "Navigator",
  11875. inheritAttrs: false,
  11876. compatConfig: {
  11877. MODE: 3
  11878. },
  11879. props: /* @__PURE__ */ extend({}, navigatorProps, {
  11880. renderLink: {
  11881. type: Boolean,
  11882. default: true
  11883. }
  11884. }),
  11885. rootElement: {
  11886. name: "uni-navigator",
  11887. class: UniNavigatorElement
  11888. },
  11889. setup(props2, {
  11890. slots
  11891. }) {
  11892. const rootRef = ref(null);
  11893. const vm = getCurrentInstance();
  11894. const __scopeId = vm && vm.vnode.scopeId || "";
  11895. const {
  11896. hovering,
  11897. binding
  11898. } = useHover(props2);
  11899. const onClick = createNavigatorOnClick(props2);
  11900. onMounted(() => {
  11901. const rootElement = rootRef.value;
  11902. rootElement.attachVmProps(props2);
  11903. });
  11904. return () => {
  11905. const {
  11906. hoverClass,
  11907. url
  11908. } = props2;
  11909. const hasHoverClass = props2.hoverClass && props2.hoverClass !== "none";
  11910. const innerNode = props2.renderLink ? createVNode("a", {
  11911. "class": "navigator-wrap",
  11912. "href": url,
  11913. "onClick": onEventPrevent,
  11914. "onMousedown": onEventPrevent
  11915. }, [slots.default && slots.default()], 40, ["href", "onClick", "onMousedown"]) : slots.default && slots.default();
  11916. return createVNode("uni-navigator", mergeProps({
  11917. "class": hasHoverClass && hovering.value ? hoverClass : "",
  11918. "ref": rootRef
  11919. }, hasHoverClass && binding, vm ? vm.attrs : {}, {
  11920. [__scopeId]: ""
  11921. }, {
  11922. "onClick": onClick
  11923. }), [innerNode], 16, ["onClick"]);
  11924. };
  11925. }
  11926. });
  11927. const pickerViewProps = {
  11928. value: {
  11929. type: Array,
  11930. default() {
  11931. return [];
  11932. },
  11933. validator: function(val) {
  11934. return isArray(val) && val.filter((val2) => typeof val2 === "number").length === val.length;
  11935. }
  11936. },
  11937. indicatorStyle: {
  11938. type: String,
  11939. default: ""
  11940. },
  11941. indicatorClass: {
  11942. type: String,
  11943. default: ""
  11944. },
  11945. maskStyle: {
  11946. type: String,
  11947. default: ""
  11948. },
  11949. maskClass: {
  11950. type: String,
  11951. default: ""
  11952. }
  11953. };
  11954. function useState$4(props2) {
  11955. const value = reactive([...props2.value]);
  11956. const state2 = reactive({
  11957. value,
  11958. height: 34
  11959. });
  11960. watch(() => props2.value, (val, oldVal) => {
  11961. {
  11962. state2.value.length = val.length;
  11963. val.forEach((val2, index2) => {
  11964. if (val2 !== state2.value[index2]) {
  11965. state2.value.splice(index2, 1, val2);
  11966. }
  11967. });
  11968. }
  11969. });
  11970. return state2;
  11971. }
  11972. class UniPickerViewElement extends UniElement {
  11973. }
  11974. const PickerView = /* @__PURE__ */ defineBuiltInComponent({
  11975. name: "PickerView",
  11976. props: pickerViewProps,
  11977. emits: ["change", "pickstart", "pickend", "update:value"],
  11978. rootElement: {
  11979. name: "uni-picker-view",
  11980. class: UniPickerViewElement
  11981. },
  11982. setup(props2, {
  11983. slots,
  11984. emit: emit2
  11985. }) {
  11986. const rootRef = ref(null);
  11987. const wrapperRef = ref(null);
  11988. const trigger = useCustomEvent(rootRef, emit2);
  11989. const state2 = useState$4(props2);
  11990. const resizeSensorRef = ref(null);
  11991. const onMountedCallback = () => {
  11992. const resizeSensor = resizeSensorRef.value;
  11993. resizeSensor && (state2.height = resizeSensor.$el.offsetHeight);
  11994. };
  11995. {
  11996. onMounted(onMountedCallback);
  11997. }
  11998. let ColumnsPreRef = ref([]);
  11999. let columnsRef = ref([]);
  12000. function getItemIndex(vnode) {
  12001. let columnVNodes = columnsRef.value;
  12002. {
  12003. columnVNodes = columnVNodes.filter((vnode2) => vnode2.type !== Comment);
  12004. }
  12005. let index2 = columnVNodes.indexOf(vnode);
  12006. return index2 !== -1 ? index2 : ColumnsPreRef.value.indexOf(vnode);
  12007. }
  12008. const getPickerViewColumn = function(columnInstance) {
  12009. const ref2 = computed({
  12010. get() {
  12011. const index2 = getItemIndex(columnInstance.vnode);
  12012. return state2.value[index2] || 0;
  12013. },
  12014. set(current) {
  12015. const index2 = getItemIndex(columnInstance.vnode);
  12016. if (index2 < 0) {
  12017. return;
  12018. }
  12019. const oldCurrent = state2.value[index2];
  12020. if (oldCurrent !== current) {
  12021. state2.value[index2] = current;
  12022. const value = state2.value.map((val) => val);
  12023. emit2("update:value", value);
  12024. trigger("change", {}, {
  12025. value
  12026. });
  12027. }
  12028. }
  12029. });
  12030. return ref2;
  12031. };
  12032. provide("getPickerViewColumn", getPickerViewColumn);
  12033. provide("pickerViewProps", props2);
  12034. provide("pickerViewState", state2);
  12035. onMounted(() => {
  12036. const rootElement = rootRef.value;
  12037. Object.defineProperty(rootElement, "value", {
  12038. get() {
  12039. const columns = rootElement.querySelectorAll("uni-picker-view-column");
  12040. return Array.from(columns).map((item) => item.current);
  12041. },
  12042. set(value) {
  12043. const columns = rootElement.querySelectorAll("uni-picker-view-column");
  12044. Array.from(columns).forEach((item, index2) => {
  12045. item.current = value[index2] || 0;
  12046. });
  12047. }
  12048. });
  12049. rootElement.attachVmProps(props2);
  12050. });
  12051. return () => {
  12052. const defaultSlots = slots.default && slots.default();
  12053. {
  12054. const vnode = flatVNode(defaultSlots);
  12055. ColumnsPreRef.value = vnode;
  12056. nextTick(() => {
  12057. columnsRef.value = vnode;
  12058. });
  12059. }
  12060. return createVNode("uni-picker-view", {
  12061. "ref": rootRef
  12062. }, [createVNode(ResizeSensor, {
  12063. "ref": resizeSensorRef,
  12064. "onResize": ({
  12065. height
  12066. }) => state2.height = height
  12067. }, null, 8, ["onResize"]), createVNode("div", {
  12068. "ref": wrapperRef,
  12069. "class": "uni-picker-view-wrapper"
  12070. }, [defaultSlots], 512)], 512);
  12071. };
  12072. }
  12073. });
  12074. class Friction {
  12075. constructor(drag) {
  12076. this._drag = drag;
  12077. this._dragLog = Math.log(drag);
  12078. this._x = 0;
  12079. this._v = 0;
  12080. this._startTime = 0;
  12081. }
  12082. set(x, v2) {
  12083. this._x = x;
  12084. this._v = v2;
  12085. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  12086. }
  12087. setVelocityByEnd(e2) {
  12088. this._v = (e2 - this._x) * this._dragLog / (Math.pow(this._drag, 100) - 1);
  12089. }
  12090. x(e2) {
  12091. if (e2 === void 0) {
  12092. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  12093. }
  12094. const t2 = e2 === this._dt && this._powDragDt ? this._powDragDt : this._powDragDt = Math.pow(this._drag, e2);
  12095. this._dt = e2;
  12096. return this._x + this._v * t2 / this._dragLog - this._v / this._dragLog;
  12097. }
  12098. dx(e2) {
  12099. if (e2 === void 0) {
  12100. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  12101. }
  12102. const t2 = e2 === this._dt && this._powDragDt ? this._powDragDt : this._powDragDt = Math.pow(this._drag, e2);
  12103. this._dt = e2;
  12104. return this._v * t2;
  12105. }
  12106. done() {
  12107. return Math.abs(this.dx()) < 3;
  12108. }
  12109. reconfigure(e2) {
  12110. const t2 = this.x();
  12111. const n = this.dx();
  12112. this._drag = e2;
  12113. this._dragLog = Math.log(e2);
  12114. this.set(t2, n);
  12115. }
  12116. configuration() {
  12117. const e2 = this;
  12118. return [
  12119. {
  12120. label: "Friction",
  12121. read: function() {
  12122. return e2._drag;
  12123. },
  12124. write: function(t2) {
  12125. e2.reconfigure(t2);
  12126. },
  12127. min: 1e-3,
  12128. max: 0.1,
  12129. step: 1e-3
  12130. }
  12131. ];
  12132. }
  12133. }
  12134. function o(e2, t2, n) {
  12135. return e2 > t2 - n && e2 < t2 + n;
  12136. }
  12137. function a(e2, t2) {
  12138. return o(e2, 0, t2);
  12139. }
  12140. class Spring {
  12141. constructor(m, k, c) {
  12142. this._m = m;
  12143. this._k = k;
  12144. this._c = c;
  12145. this._solution = null;
  12146. this._endPosition = 0;
  12147. this._startTime = 0;
  12148. }
  12149. _solve(e2, t2) {
  12150. const n = this._c;
  12151. const i = this._m;
  12152. const r = this._k;
  12153. const o2 = n * n - 4 * i * r;
  12154. if (o2 === 0) {
  12155. const a3 = -n / (2 * i);
  12156. const s2 = e2;
  12157. const l2 = t2 / (a3 * e2);
  12158. return {
  12159. x: function(e22) {
  12160. return (s2 + l2 * e22) * Math.pow(Math.E, a3 * e22);
  12161. },
  12162. dx: function(e22) {
  12163. const t22 = Math.pow(Math.E, a3 * e22);
  12164. return a3 * (s2 + l2 * e22) * t22 + l2 * t22;
  12165. }
  12166. };
  12167. }
  12168. if (o2 > 0) {
  12169. const c = (-n - Math.sqrt(o2)) / (2 * i);
  12170. const u = (-n + Math.sqrt(o2)) / (2 * i);
  12171. const l2 = (t2 - c * e2) / (u - c);
  12172. const s2 = e2 - l2;
  12173. return {
  12174. x: function(e22) {
  12175. let t22;
  12176. let n2;
  12177. if (e22 === this._t) {
  12178. t22 = this._powER1T;
  12179. n2 = this._powER2T;
  12180. }
  12181. this._t = e22;
  12182. if (!t22) {
  12183. t22 = this._powER1T = Math.pow(Math.E, c * e22);
  12184. }
  12185. if (!n2) {
  12186. n2 = this._powER2T = Math.pow(Math.E, u * e22);
  12187. }
  12188. return s2 * t22 + l2 * n2;
  12189. },
  12190. dx: function(e22) {
  12191. let t22;
  12192. let n2;
  12193. if (e22 === this._t) {
  12194. t22 = this._powER1T;
  12195. n2 = this._powER2T;
  12196. }
  12197. this._t = e22;
  12198. if (!t22) {
  12199. t22 = this._powER1T = Math.pow(Math.E, c * e22);
  12200. }
  12201. if (!n2) {
  12202. n2 = this._powER2T = Math.pow(Math.E, u * e22);
  12203. }
  12204. return s2 * c * t22 + l2 * u * n2;
  12205. }
  12206. };
  12207. }
  12208. const d = Math.sqrt(4 * i * r - n * n) / (2 * i);
  12209. const a2 = -n / 2 * i;
  12210. const s = e2;
  12211. const l = (t2 - a2 * e2) / d;
  12212. return {
  12213. x: function(e22) {
  12214. return Math.pow(Math.E, a2 * e22) * (s * Math.cos(d * e22) + l * Math.sin(d * e22));
  12215. },
  12216. dx: function(e22) {
  12217. const t22 = Math.pow(Math.E, a2 * e22);
  12218. const n2 = Math.cos(d * e22);
  12219. const i2 = Math.sin(d * e22);
  12220. return t22 * (l * d * n2 - s * d * i2) + a2 * t22 * (l * i2 + s * n2);
  12221. }
  12222. };
  12223. }
  12224. x(e2) {
  12225. if (e2 === void 0) {
  12226. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  12227. }
  12228. return this._solution ? this._endPosition + this._solution.x(e2) : 0;
  12229. }
  12230. dx(e2) {
  12231. if (e2 === void 0) {
  12232. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  12233. }
  12234. return this._solution ? this._solution.dx(e2) : 0;
  12235. }
  12236. setEnd(e2, t2, n) {
  12237. if (!n) {
  12238. n = (/* @__PURE__ */ new Date()).getTime();
  12239. }
  12240. if (e2 !== this._endPosition || !a(t2, 0.4)) {
  12241. t2 = t2 || 0;
  12242. let i = this._endPosition;
  12243. if (this._solution) {
  12244. if (a(t2, 0.4)) {
  12245. t2 = this._solution.dx((n - this._startTime) / 1e3);
  12246. }
  12247. i = this._solution.x((n - this._startTime) / 1e3);
  12248. if (a(t2, 0.4)) {
  12249. t2 = 0;
  12250. }
  12251. if (a(i, 0.4)) {
  12252. i = 0;
  12253. }
  12254. i += this._endPosition;
  12255. }
  12256. if (!(this._solution && a(i - e2, 0.4) && a(t2, 0.4))) {
  12257. this._endPosition = e2;
  12258. this._solution = this._solve(i - this._endPosition, t2);
  12259. this._startTime = n;
  12260. }
  12261. }
  12262. }
  12263. snap(e2) {
  12264. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  12265. this._endPosition = e2;
  12266. this._solution = {
  12267. x: function() {
  12268. return 0;
  12269. },
  12270. dx: function() {
  12271. return 0;
  12272. }
  12273. };
  12274. }
  12275. done(e2) {
  12276. if (!e2) {
  12277. e2 = (/* @__PURE__ */ new Date()).getTime();
  12278. }
  12279. return o(this.x(), this._endPosition, 0.4) && a(this.dx(), 0.4);
  12280. }
  12281. reconfigure(e2, t2, n) {
  12282. this._m = e2;
  12283. this._k = t2;
  12284. this._c = n;
  12285. if (!this.done()) {
  12286. this._solution = this._solve(this.x() - this._endPosition, this.dx());
  12287. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  12288. }
  12289. }
  12290. springConstant() {
  12291. return this._k;
  12292. }
  12293. damping() {
  12294. return this._c;
  12295. }
  12296. configuration() {
  12297. function e2(e22, t22) {
  12298. e22.reconfigure(1, t22, e22.damping());
  12299. }
  12300. function t2(e22, t22) {
  12301. e22.reconfigure(1, e22.springConstant(), t22);
  12302. }
  12303. return [
  12304. {
  12305. label: "Spring Constant",
  12306. read: this.springConstant.bind(this),
  12307. write: e2.bind(this, this),
  12308. min: 100,
  12309. max: 1e3
  12310. },
  12311. {
  12312. label: "Damping",
  12313. read: this.damping.bind(this),
  12314. write: t2.bind(this, this),
  12315. min: 1,
  12316. max: 500
  12317. }
  12318. ];
  12319. }
  12320. }
  12321. class Scroll {
  12322. constructor(extent, friction, spring) {
  12323. this._extent = extent;
  12324. this._friction = friction || new Friction(0.01);
  12325. this._spring = spring || new Spring(1, 90, 20);
  12326. this._startTime = 0;
  12327. this._springing = false;
  12328. this._springOffset = 0;
  12329. }
  12330. snap(e2, t2) {
  12331. this._springOffset = 0;
  12332. this._springing = true;
  12333. this._spring.snap(e2);
  12334. this._spring.setEnd(t2);
  12335. }
  12336. set(e2, t2) {
  12337. this._friction.set(e2, t2);
  12338. if (e2 > 0 && t2 >= 0) {
  12339. this._springOffset = 0;
  12340. this._springing = true;
  12341. this._spring.snap(e2);
  12342. this._spring.setEnd(0);
  12343. } else {
  12344. if (e2 < -this._extent && t2 <= 0) {
  12345. this._springOffset = 0;
  12346. this._springing = true;
  12347. this._spring.snap(e2);
  12348. this._spring.setEnd(-this._extent);
  12349. } else {
  12350. this._springing = false;
  12351. }
  12352. }
  12353. this._startTime = (/* @__PURE__ */ new Date()).getTime();
  12354. }
  12355. x(e2) {
  12356. if (!this._startTime) {
  12357. return 0;
  12358. }
  12359. if (!e2) {
  12360. e2 = ((/* @__PURE__ */ new Date()).getTime() - this._startTime) / 1e3;
  12361. }
  12362. if (this._springing) {
  12363. return this._spring.x() + this._springOffset;
  12364. }
  12365. let t2 = this._friction.x(e2);
  12366. let n = this.dx(e2);
  12367. if (t2 > 0 && n >= 0 || t2 < -this._extent && n <= 0) {
  12368. this._springing = true;
  12369. this._spring.setEnd(0, n);
  12370. if (t2 < -this._extent) {
  12371. this._springOffset = -this._extent;
  12372. } else {
  12373. this._springOffset = 0;
  12374. }
  12375. t2 = this._spring.x() + this._springOffset;
  12376. }
  12377. return t2;
  12378. }
  12379. dx(e2) {
  12380. let t2;
  12381. if (this._lastTime === e2) {
  12382. t2 = this._lastDx;
  12383. } else {
  12384. t2 = this._springing ? this._spring.dx(e2) : this._friction.dx(e2);
  12385. }
  12386. this._lastTime = e2;
  12387. this._lastDx = t2;
  12388. return t2;
  12389. }
  12390. done() {
  12391. return this._springing ? this._spring.done() : this._friction.done();
  12392. }
  12393. setVelocityByEnd(e2) {
  12394. this._friction.setVelocityByEnd(e2);
  12395. }
  12396. configuration() {
  12397. const e2 = this._friction.configuration();
  12398. e2.push.apply(e2, this._spring.configuration());
  12399. return e2;
  12400. }
  12401. }
  12402. function createAnimation(scroll, onScroll, onEnd) {
  12403. const state2 = {
  12404. id: 0,
  12405. cancelled: false
  12406. };
  12407. function startAnimation2(state22, scroll2, onScroll2, onEnd2) {
  12408. if (!state22 || !state22.cancelled) {
  12409. onScroll2(scroll2);
  12410. const isDone = scroll2.done();
  12411. if (!isDone) {
  12412. if (!state22.cancelled) {
  12413. state22.id = requestAnimationFrame(
  12414. startAnimation2.bind(null, state22, scroll2, onScroll2, onEnd2)
  12415. );
  12416. }
  12417. }
  12418. if (isDone && onEnd2) {
  12419. onEnd2(scroll2);
  12420. }
  12421. }
  12422. }
  12423. function cancel(state22) {
  12424. if (state22 && state22.id) {
  12425. cancelAnimationFrame(state22.id);
  12426. }
  12427. if (state22) {
  12428. state22.cancelled = true;
  12429. }
  12430. }
  12431. startAnimation2(state2, scroll, onScroll, onEnd);
  12432. return {
  12433. cancel: cancel.bind(null, state2),
  12434. model: scroll
  12435. };
  12436. }
  12437. class Scroller {
  12438. constructor(element, options) {
  12439. options = options || {};
  12440. this._element = element;
  12441. this._options = options;
  12442. this._enableSnap = options.enableSnap || false;
  12443. this._itemSize = options.itemSize || 0;
  12444. this._enableX = options.enableX || false;
  12445. this._enableY = options.enableY || false;
  12446. this._shouldDispatchScrollEvent = !!options.onScroll;
  12447. if (this._enableX) {
  12448. this._extent = (options.scrollWidth || this._element.offsetWidth) - this._element.parentElement.offsetWidth;
  12449. this._scrollWidth = options.scrollWidth;
  12450. } else {
  12451. this._extent = (options.scrollHeight || this._element.offsetHeight) - this._element.parentElement.offsetHeight;
  12452. this._scrollHeight = options.scrollHeight;
  12453. }
  12454. this._position = 0;
  12455. this._scroll = new Scroll(this._extent, options.friction, options.spring);
  12456. this._onTransitionEnd = this.onTransitionEnd.bind(this);
  12457. this.updatePosition();
  12458. }
  12459. onTouchStart() {
  12460. this._startPosition = this._position;
  12461. this._lastChangePos = this._startPosition;
  12462. if (this._startPosition > 0) {
  12463. this._startPosition /= 0.5;
  12464. } else {
  12465. if (this._startPosition < -this._extent) {
  12466. this._startPosition = (this._startPosition + this._extent) / 0.5 - this._extent;
  12467. }
  12468. }
  12469. if (this._animation) {
  12470. this._animation.cancel();
  12471. this._scrolling = false;
  12472. }
  12473. this.updatePosition();
  12474. }
  12475. onTouchMove(x, y) {
  12476. let startPosition = this._startPosition;
  12477. if (this._enableX) {
  12478. startPosition += x;
  12479. } else if (this._enableY) {
  12480. startPosition += y;
  12481. }
  12482. if (startPosition > 0) {
  12483. startPosition *= 0.5;
  12484. } else if (startPosition < -this._extent) {
  12485. startPosition = 0.5 * (startPosition + this._extent) - this._extent;
  12486. }
  12487. this._position = startPosition;
  12488. this.updatePosition();
  12489. this.dispatchScroll();
  12490. }
  12491. onTouchEnd(x, y, o2) {
  12492. if (this._enableSnap && this._position > -this._extent && this._position < 0) {
  12493. if (this._enableY && (Math.abs(y) < this._itemSize && Math.abs(o2.y) < 300 || Math.abs(o2.y) < 150)) {
  12494. this.snap();
  12495. return;
  12496. }
  12497. if (this._enableX && (Math.abs(x) < this._itemSize && Math.abs(o2.x) < 300 || Math.abs(o2.x) < 150)) {
  12498. this.snap();
  12499. return;
  12500. }
  12501. }
  12502. if (this._enableX) {
  12503. this._scroll.set(this._position, o2.x);
  12504. } else if (this._enableY) {
  12505. this._scroll.set(this._position, o2.y);
  12506. }
  12507. let c;
  12508. if (this._enableSnap) {
  12509. const s = this._scroll._friction.x(100);
  12510. const l = s % this._itemSize;
  12511. c = Math.abs(l) > this._itemSize / 2 ? s - (this._itemSize - Math.abs(l)) : s - l;
  12512. if (c <= 0 && c >= -this._extent) {
  12513. this._scroll.setVelocityByEnd(c);
  12514. }
  12515. }
  12516. this._lastTime = Date.now();
  12517. this._lastDelay = 0;
  12518. this._scrolling = true;
  12519. this._lastChangePos = this._position;
  12520. this._lastIdx = Math.floor(Math.abs(this._position / this._itemSize));
  12521. this._animation = createAnimation(
  12522. this._scroll,
  12523. () => {
  12524. const e2 = Date.now();
  12525. const i = (e2 - this._scroll._startTime) / 1e3;
  12526. const r = this._scroll.x(i);
  12527. this._position = r;
  12528. this.updatePosition();
  12529. const o22 = this._scroll.dx(i);
  12530. if (this._shouldDispatchScrollEvent && e2 - this._lastTime > this._lastDelay) {
  12531. this.dispatchScroll();
  12532. this._lastDelay = Math.abs(2e3 / o22);
  12533. this._lastTime = e2;
  12534. }
  12535. },
  12536. () => {
  12537. if (this._enableSnap) {
  12538. if (c <= 0 && c >= -this._extent) {
  12539. this._position = c;
  12540. this.updatePosition();
  12541. }
  12542. if (isFunction(this._options.onSnap)) {
  12543. this._options.onSnap(
  12544. Math.floor(Math.abs(this._position) / this._itemSize)
  12545. );
  12546. }
  12547. }
  12548. if (this._shouldDispatchScrollEvent) {
  12549. this.dispatchScroll();
  12550. }
  12551. this._scrolling = false;
  12552. }
  12553. );
  12554. }
  12555. onTransitionEnd() {
  12556. this._element.style.webkitTransition = "";
  12557. this._element.style.transition = "";
  12558. this._element.removeEventListener("transitionend", this._onTransitionEnd);
  12559. if (this._snapping) {
  12560. this._snapping = false;
  12561. }
  12562. this.dispatchScroll();
  12563. }
  12564. snap() {
  12565. const itemSize = this._itemSize;
  12566. const position = this._position % itemSize;
  12567. const i = Math.abs(position) > this._itemSize / 2 ? this._position - (itemSize - Math.abs(position)) : this._position - position;
  12568. if (this._position !== i) {
  12569. this._snapping = true;
  12570. this.scrollTo(-i);
  12571. if (isFunction(this._options.onSnap)) {
  12572. this._options.onSnap(
  12573. Math.floor(Math.abs(this._position) / this._itemSize)
  12574. );
  12575. }
  12576. }
  12577. }
  12578. scrollTo(position, time) {
  12579. if (this._animation) {
  12580. this._animation.cancel();
  12581. this._scrolling = false;
  12582. }
  12583. if (typeof position === "number") {
  12584. this._position = -position;
  12585. }
  12586. if (this._position < -this._extent) {
  12587. this._position = -this._extent;
  12588. } else {
  12589. if (this._position > 0) {
  12590. this._position = 0;
  12591. }
  12592. }
  12593. const transition = "transform " + (time || 0.2) + "s ease-out";
  12594. this._element.style.webkitTransition = "-webkit-" + transition;
  12595. this._element.style.transition = transition;
  12596. this.updatePosition();
  12597. this._element.addEventListener("transitionend", this._onTransitionEnd);
  12598. }
  12599. dispatchScroll() {
  12600. if (isFunction(this._options.onScroll) && Math.round(Number(this._lastPos)) !== Math.round(this._position)) {
  12601. this._lastPos = this._position;
  12602. const event = {
  12603. target: {
  12604. scrollLeft: this._enableX ? -this._position : 0,
  12605. scrollTop: this._enableY ? -this._position : 0,
  12606. scrollHeight: this._scrollHeight || this._element.offsetHeight,
  12607. scrollWidth: this._scrollWidth || this._element.offsetWidth,
  12608. offsetHeight: this._element.parentElement.offsetHeight,
  12609. offsetWidth: this._element.parentElement.offsetWidth
  12610. }
  12611. };
  12612. this._options.onScroll(event);
  12613. }
  12614. }
  12615. update(height, scrollHeight, itemSize) {
  12616. let extent = 0;
  12617. const position = this._position;
  12618. if (this._enableX) {
  12619. extent = this._element.childNodes.length ? (scrollHeight || this._element.offsetWidth) - this._element.parentElement.offsetWidth : 0;
  12620. this._scrollWidth = scrollHeight;
  12621. } else {
  12622. extent = this._element.childNodes.length ? (scrollHeight || this._element.offsetHeight) - this._element.parentElement.offsetHeight : 0;
  12623. this._scrollHeight = scrollHeight;
  12624. }
  12625. if (typeof height === "number") {
  12626. this._position = -height;
  12627. }
  12628. if (this._position < -extent) {
  12629. this._position = -extent;
  12630. } else {
  12631. if (this._position > 0) {
  12632. this._position = 0;
  12633. }
  12634. }
  12635. this._itemSize = itemSize || this._itemSize;
  12636. this.updatePosition();
  12637. if (position !== this._position) {
  12638. this.dispatchScroll();
  12639. if (isFunction(this._options.onSnap)) {
  12640. this._options.onSnap(
  12641. Math.floor(Math.abs(this._position) / this._itemSize)
  12642. );
  12643. }
  12644. }
  12645. this._extent = extent;
  12646. this._scroll._extent = extent;
  12647. }
  12648. updatePosition() {
  12649. let transform = "";
  12650. if (this._enableX) {
  12651. transform = "translateX(" + this._position + "px) translateZ(0)";
  12652. } else {
  12653. if (this._enableY) {
  12654. transform = "translateY(" + this._position + "px) translateZ(0)";
  12655. }
  12656. }
  12657. this._element.style.webkitTransform = transform;
  12658. this._element.style.transform = transform;
  12659. }
  12660. isScrolling() {
  12661. return this._scrolling || this._snapping;
  12662. }
  12663. }
  12664. function useScroller(element, options) {
  12665. const touchInfo = {
  12666. trackingID: -1,
  12667. maxDy: 0,
  12668. maxDx: 0
  12669. };
  12670. const scroller = new Scroller(element, options);
  12671. function findDelta(event) {
  12672. const touchtrackEvent = event;
  12673. const mouseEvent = event;
  12674. return touchtrackEvent.detail.state === "move" || touchtrackEvent.detail.state === "end" ? {
  12675. x: touchtrackEvent.detail.dx,
  12676. y: touchtrackEvent.detail.dy
  12677. } : {
  12678. x: mouseEvent.screenX - touchInfo.x,
  12679. y: mouseEvent.screenY - touchInfo.y
  12680. };
  12681. }
  12682. function handleTouchStart(event) {
  12683. const touchtrackEvent = event;
  12684. const mouseEvent = event;
  12685. if (touchtrackEvent.detail.state === "start") {
  12686. touchInfo.trackingID = "touch";
  12687. touchInfo.x = touchtrackEvent.detail.x;
  12688. touchInfo.y = touchtrackEvent.detail.y;
  12689. } else {
  12690. touchInfo.trackingID = "mouse";
  12691. touchInfo.x = mouseEvent.screenX;
  12692. touchInfo.y = mouseEvent.screenY;
  12693. }
  12694. touchInfo.maxDx = 0;
  12695. touchInfo.maxDy = 0;
  12696. touchInfo.historyX = [0];
  12697. touchInfo.historyY = [0];
  12698. touchInfo.historyTime = [
  12699. touchtrackEvent.detail.timeStamp || mouseEvent.timeStamp
  12700. ];
  12701. touchInfo.listener = scroller;
  12702. if (scroller.onTouchStart) {
  12703. scroller.onTouchStart();
  12704. }
  12705. if (typeof event.cancelable !== "boolean" || event.cancelable)
  12706. event.preventDefault();
  12707. }
  12708. function handleTouchMove(event) {
  12709. const touchtrackEvent = event;
  12710. const mouseEvent = event;
  12711. if (touchInfo.trackingID !== -1) {
  12712. if (typeof event.cancelable !== "boolean" || event.cancelable)
  12713. event.preventDefault();
  12714. const delta = findDelta(event);
  12715. if (delta) {
  12716. 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(
  12717. touchtrackEvent.detail.timeStamp || mouseEvent.timeStamp
  12718. ); touchInfo.historyTime.length > 10; ) {
  12719. touchInfo.historyTime.shift();
  12720. touchInfo.historyX.shift();
  12721. touchInfo.historyY.shift();
  12722. }
  12723. if (touchInfo.listener && touchInfo.listener.onTouchMove) {
  12724. touchInfo.listener.onTouchMove(delta.x, delta.y);
  12725. }
  12726. }
  12727. }
  12728. }
  12729. function handleTouchEnd(event) {
  12730. if (touchInfo.trackingID !== -1) {
  12731. event.preventDefault();
  12732. const delta = findDelta(event);
  12733. if (delta) {
  12734. const listener2 = touchInfo.listener;
  12735. touchInfo.trackingID = -1;
  12736. touchInfo.listener = null;
  12737. const length = touchInfo.historyTime.length;
  12738. const o2 = {
  12739. x: 0,
  12740. y: 0
  12741. };
  12742. if (length > 2) {
  12743. for (let i = touchInfo.historyTime.length - 1, time1 = touchInfo.historyTime[i], x = touchInfo.historyX[i], y = touchInfo.historyY[i]; i > 0; ) {
  12744. i--;
  12745. const time0 = touchInfo.historyTime[i];
  12746. const time = time1 - time0;
  12747. if (time > 30 && time < 50) {
  12748. o2.x = (x - touchInfo.historyX[i]) / (time / 1e3);
  12749. o2.y = (y - touchInfo.historyY[i]) / (time / 1e3);
  12750. break;
  12751. }
  12752. }
  12753. }
  12754. touchInfo.historyTime = [];
  12755. touchInfo.historyX = [];
  12756. touchInfo.historyY = [];
  12757. if (listener2 && listener2.onTouchEnd) {
  12758. listener2.onTouchEnd(delta.x, delta.y, o2);
  12759. }
  12760. }
  12761. }
  12762. }
  12763. return {
  12764. scroller,
  12765. handleTouchStart,
  12766. handleTouchMove,
  12767. handleTouchEnd
  12768. };
  12769. }
  12770. function useCustomClick(dom) {
  12771. const MAX_MOVE = 20;
  12772. let x = 0;
  12773. let y = 0;
  12774. dom.addEventListener("touchstart", (event) => {
  12775. const info = event.changedTouches[0];
  12776. x = info.clientX;
  12777. y = info.clientY;
  12778. });
  12779. dom.addEventListener("touchend", (event) => {
  12780. const info = event.changedTouches[0];
  12781. if (Math.abs(info.clientX - x) < MAX_MOVE && Math.abs(info.clientY - y) < MAX_MOVE) {
  12782. const options = {
  12783. bubbles: true,
  12784. cancelable: true,
  12785. target: event.target,
  12786. currentTarget: event.currentTarget
  12787. };
  12788. const customClick = new CustomEvent("click", options);
  12789. const props2 = ["screenX", "screenY", "clientX", "clientY", "pageX", "pageY"];
  12790. props2.forEach((key) => {
  12791. customClick[key] = info[key];
  12792. });
  12793. event.target.dispatchEvent(customClick);
  12794. }
  12795. });
  12796. }
  12797. class UniPickerViewColumnElement extends UniElement {
  12798. }
  12799. const PickerViewColumn = /* @__PURE__ */ defineBuiltInComponent({
  12800. name: "PickerViewColumn",
  12801. rootElement: {
  12802. name: "uni-picker-view-column",
  12803. class: UniPickerViewColumnElement
  12804. },
  12805. setup(props2, {
  12806. slots,
  12807. emit: emit2
  12808. }) {
  12809. const rootRef = ref(null);
  12810. const contentRef = ref(null);
  12811. const getPickerViewColumn = inject("getPickerViewColumn");
  12812. const instance2 = getCurrentInstance();
  12813. const currentRef = getPickerViewColumn ? getPickerViewColumn(instance2) : ref(0);
  12814. const pickerViewProps2 = inject("pickerViewProps");
  12815. const pickerViewState = inject("pickerViewState");
  12816. const indicatorHeight = ref(34);
  12817. const resizeSensorRef = ref(null);
  12818. const initIndicatorHeight = () => {
  12819. const resizeSensor = resizeSensorRef.value;
  12820. indicatorHeight.value = resizeSensor.$el.offsetHeight;
  12821. };
  12822. {
  12823. onMounted(initIndicatorHeight);
  12824. }
  12825. const maskSize = computed(() => (pickerViewState.height - indicatorHeight.value) / 2);
  12826. const {
  12827. state: scopedAttrsState
  12828. } = useScopedAttrs();
  12829. let scroller;
  12830. const state2 = reactive({
  12831. current: currentRef.value,
  12832. length: 0
  12833. });
  12834. let updatesScrollerRequest;
  12835. function updatesScroller() {
  12836. if (scroller && !updatesScrollerRequest) {
  12837. updatesScrollerRequest = true;
  12838. nextTick(() => {
  12839. updatesScrollerRequest = false;
  12840. let current = Math.min(state2.current, state2.length - 1);
  12841. current = Math.max(current, 0);
  12842. scroller.update(current * indicatorHeight.value, void 0, indicatorHeight.value);
  12843. });
  12844. }
  12845. }
  12846. watch(() => currentRef.value, (current) => {
  12847. if (current !== state2.current) {
  12848. state2.current = current;
  12849. updatesScroller();
  12850. }
  12851. });
  12852. watch(() => state2.current, (current) => currentRef.value = current);
  12853. watch([() => indicatorHeight.value, () => state2.length, () => pickerViewState.height], updatesScroller);
  12854. let oldDeltaY = 0;
  12855. function handleWheel(event) {
  12856. const deltaY = oldDeltaY + event.deltaY;
  12857. if (Math.abs(deltaY) > 10) {
  12858. oldDeltaY = 0;
  12859. let current = Math.min(state2.current + (deltaY < 0 ? -1 : 1), state2.length - 1);
  12860. state2.current = current = Math.max(current, 0);
  12861. scroller.scrollTo(current * indicatorHeight.value);
  12862. } else {
  12863. oldDeltaY = deltaY;
  12864. }
  12865. event.preventDefault();
  12866. }
  12867. function handleTap({
  12868. clientY
  12869. }) {
  12870. const el = rootRef.value;
  12871. if (!scroller.isScrolling()) {
  12872. const rect = el.getBoundingClientRect();
  12873. const r = clientY - rect.top - pickerViewState.height / 2;
  12874. const o2 = indicatorHeight.value / 2;
  12875. if (!(Math.abs(r) <= o2)) {
  12876. const a2 = Math.ceil((Math.abs(r) - o2) / indicatorHeight.value);
  12877. const s = r < 0 ? -a2 : a2;
  12878. let current = Math.min(state2.current + s, state2.length - 1);
  12879. state2.current = current = Math.max(current, 0);
  12880. scroller.scrollTo(current * indicatorHeight.value);
  12881. }
  12882. }
  12883. }
  12884. const initScroller = () => {
  12885. const el = rootRef.value;
  12886. const content = contentRef.value;
  12887. const {
  12888. scroller: scrollerOrigin,
  12889. handleTouchStart,
  12890. handleTouchMove,
  12891. handleTouchEnd
  12892. } = useScroller(content, {
  12893. enableY: true,
  12894. enableX: false,
  12895. enableSnap: true,
  12896. itemSize: indicatorHeight.value,
  12897. friction: new Friction(1e-4),
  12898. spring: new Spring(2, 90, 20),
  12899. onSnap: (index2) => {
  12900. if (!isNaN(index2) && index2 !== state2.current) {
  12901. state2.current = index2;
  12902. }
  12903. }
  12904. });
  12905. scroller = scrollerOrigin;
  12906. useTouchtrack(el, (e2) => {
  12907. switch (e2.detail.state) {
  12908. case "start":
  12909. handleTouchStart(e2);
  12910. break;
  12911. case "move":
  12912. handleTouchMove(e2);
  12913. e2.stopPropagation();
  12914. break;
  12915. case "end":
  12916. case "cancel":
  12917. handleTouchEnd(e2);
  12918. }
  12919. }, true);
  12920. useCustomClick(el);
  12921. updatesScroller();
  12922. };
  12923. {
  12924. onMounted(initScroller);
  12925. }
  12926. let currentCache = state2.current;
  12927. watch(() => state2.current, (newCurrent) => {
  12928. currentCache = newCurrent;
  12929. });
  12930. onMounted(() => {
  12931. const rootElement = rootRef.value;
  12932. Object.defineProperty(rootElement, "current", {
  12933. get() {
  12934. return currentCache;
  12935. },
  12936. set(current) {
  12937. currentCache = current;
  12938. scroller.scrollTo(current * indicatorHeight.value);
  12939. }
  12940. });
  12941. rootElement.attachVmProps(props2);
  12942. });
  12943. return () => {
  12944. const defaultSlots = slots.default && slots.default();
  12945. {
  12946. state2.length = flatVNode(defaultSlots).length;
  12947. }
  12948. const padding = `${maskSize.value}px 0`;
  12949. return createVNode("uni-picker-view-column", {
  12950. "ref": rootRef
  12951. }, [createVNode("div", {
  12952. "onWheel": handleWheel,
  12953. "onClick": handleTap,
  12954. "class": "uni-picker-view-group"
  12955. }, [createVNode("div", mergeProps(scopedAttrsState.attrs, {
  12956. "class": ["uni-picker-view-mask", pickerViewProps2.maskClass],
  12957. "style": `background-size: 100% ${maskSize.value}px;${pickerViewProps2.maskStyle}`
  12958. }), null, 16), createVNode("div", mergeProps(scopedAttrsState.attrs, {
  12959. "class": ["uni-picker-view-indicator", pickerViewProps2.indicatorClass],
  12960. "style": pickerViewProps2.indicatorStyle
  12961. }), [createVNode(ResizeSensor, {
  12962. "ref": resizeSensorRef,
  12963. "onResize": ({
  12964. height
  12965. }) => indicatorHeight.value = height
  12966. }, null, 8, ["onResize"])], 16), createVNode("div", {
  12967. "ref": contentRef,
  12968. "class": ["uni-picker-view-content"],
  12969. "style": {
  12970. padding,
  12971. "--picker-view-column-indicator-height": `${indicatorHeight.value}px`
  12972. }
  12973. }, [defaultSlots], 4)], 40, ["onWheel", "onClick"])], 512);
  12974. };
  12975. }
  12976. });
  12977. const FONT_SIZE = 16;
  12978. const PROGRESS_VALUES = {
  12979. activeColor: PRIMARY_COLOR,
  12980. backgroundColor: "#EBEBEB",
  12981. activeMode: "backwards"
  12982. };
  12983. const progressProps = {
  12984. percent: {
  12985. type: [Number, String],
  12986. default: 0,
  12987. validator(value) {
  12988. return !isNaN(parseFloat(value));
  12989. }
  12990. },
  12991. fontSize: {
  12992. type: [String, Number],
  12993. default: FONT_SIZE
  12994. },
  12995. showInfo: {
  12996. type: [Boolean, String],
  12997. default: false
  12998. },
  12999. strokeWidth: {
  13000. type: [Number, String],
  13001. default: 6,
  13002. validator(value) {
  13003. return !isNaN(parseFloat(value));
  13004. }
  13005. },
  13006. color: {
  13007. type: String,
  13008. default: PROGRESS_VALUES.activeColor
  13009. },
  13010. activeColor: {
  13011. type: String,
  13012. default: PROGRESS_VALUES.activeColor
  13013. },
  13014. backgroundColor: {
  13015. type: String,
  13016. default: PROGRESS_VALUES.backgroundColor
  13017. },
  13018. active: {
  13019. type: [Boolean, String],
  13020. default: false
  13021. },
  13022. activeMode: {
  13023. type: String,
  13024. default: PROGRESS_VALUES.activeMode
  13025. },
  13026. duration: {
  13027. type: [Number, String],
  13028. default: 30,
  13029. validator(value) {
  13030. return !isNaN(parseFloat(value));
  13031. }
  13032. },
  13033. borderRadius: {
  13034. type: [Number, String],
  13035. default: 0
  13036. }
  13037. };
  13038. class UniProgressElement extends UniElement {
  13039. }
  13040. const index$o = /* @__PURE__ */ defineBuiltInComponent({
  13041. name: "Progress",
  13042. props: progressProps,
  13043. rootElement: {
  13044. name: "uni-progress",
  13045. class: UniProgressElement
  13046. },
  13047. setup(props2) {
  13048. const rootRef = ref(null);
  13049. const state2 = useProgressState(props2);
  13050. _activeAnimation(state2, props2);
  13051. watch(() => state2.realPercent, (newValue, oldValue) => {
  13052. state2.strokeTimer && clearInterval(state2.strokeTimer);
  13053. state2.lastPercent = oldValue || 0;
  13054. _activeAnimation(state2, props2);
  13055. });
  13056. let percentCache = state2.currentPercent;
  13057. watch(() => state2.currentPercent, (newPercent) => {
  13058. percentCache = newPercent;
  13059. });
  13060. onMounted(() => {
  13061. const rootElement = rootRef.value;
  13062. Object.defineProperty(rootElement, "percent", {
  13063. get() {
  13064. return percentCache;
  13065. },
  13066. set(value) {
  13067. percentCache = value;
  13068. rootElement.querySelector(".uni-progress-inner-bar").style.width = `${value}%`;
  13069. if (props2.showInfo) {
  13070. rootElement.querySelector(".uni-progress-info").innerText = `${value}%`;
  13071. }
  13072. }
  13073. });
  13074. rootElement.attachVmProps(props2);
  13075. });
  13076. return () => {
  13077. const {
  13078. showInfo
  13079. } = props2;
  13080. const {
  13081. outerBarStyle,
  13082. innerBarStyle,
  13083. currentPercent
  13084. } = state2;
  13085. return createVNode("uni-progress", {
  13086. "class": "uni-progress",
  13087. "ref": rootRef
  13088. }, [createVNode("div", {
  13089. "style": outerBarStyle,
  13090. "class": "uni-progress-bar"
  13091. }, [createVNode("div", {
  13092. "style": innerBarStyle,
  13093. "class": "uni-progress-inner-bar"
  13094. }, null, 4)], 4), showInfo ? (
  13095. // {currentPercent}% 的写法会影响 SSR Hydration (tsx插件的问题)
  13096. createVNode("p", {
  13097. "class": "uni-progress-info"
  13098. }, [currentPercent + "%"])
  13099. ) : ""], 512);
  13100. };
  13101. }
  13102. });
  13103. function useProgressState(props2) {
  13104. const currentPercent = ref(0);
  13105. const outerBarStyle = computed(() => `background-color: ${props2.backgroundColor}; height: ${props2.strokeWidth}px;`);
  13106. const innerBarStyle = computed(() => {
  13107. const backgroundColor = props2.color !== PROGRESS_VALUES.activeColor && props2.activeColor === PROGRESS_VALUES.activeColor ? props2.color : props2.activeColor;
  13108. return `width: ${currentPercent.value}%;background-color: ${backgroundColor}`;
  13109. });
  13110. const realPercent = computed(() => {
  13111. if (typeof props2.percent === "string" && !/^-?\d*\.?\d*$/.test(props2.percent)) {
  13112. return 0;
  13113. }
  13114. let realValue = parseFloat(props2.percent);
  13115. if (Number.isNaN(realValue) || realValue < 0) {
  13116. realValue = 0;
  13117. } else if (realValue > 100) {
  13118. realValue = 100;
  13119. }
  13120. return realValue;
  13121. });
  13122. const state2 = reactive({
  13123. outerBarStyle,
  13124. innerBarStyle,
  13125. realPercent,
  13126. currentPercent,
  13127. strokeTimer: 0,
  13128. lastPercent: 0
  13129. });
  13130. return state2;
  13131. }
  13132. function _activeAnimation(state2, props2) {
  13133. if (props2.active) {
  13134. state2.currentPercent = props2.activeMode === PROGRESS_VALUES.activeMode ? 0 : state2.lastPercent;
  13135. state2.strokeTimer = setInterval(() => {
  13136. if (state2.currentPercent + 1 > state2.realPercent) {
  13137. state2.currentPercent = state2.realPercent;
  13138. state2.strokeTimer && clearInterval(state2.strokeTimer);
  13139. } else {
  13140. state2.currentPercent += 1;
  13141. }
  13142. }, parseFloat(props2.duration));
  13143. } else {
  13144. state2.currentPercent = state2.realPercent;
  13145. }
  13146. }
  13147. const uniRadioGroupKey = PolySymbol(process.env.NODE_ENV !== "production" ? "uniCheckGroup" : "ucg");
  13148. const props$q = {
  13149. name: {
  13150. type: String,
  13151. default: ""
  13152. }
  13153. };
  13154. class UniRadioGroupElement extends UniElement {
  13155. }
  13156. const index$n = /* @__PURE__ */ defineBuiltInComponent({
  13157. name: "RadioGroup",
  13158. props: props$q,
  13159. // emits: ['change'],
  13160. rootElement: {
  13161. name: "uni-radio-group",
  13162. class: UniRadioGroupElement
  13163. },
  13164. setup(props2, {
  13165. emit: emit2,
  13166. slots
  13167. }) {
  13168. const rootRef = ref(null);
  13169. const trigger = useCustomEvent(rootRef, emit2);
  13170. useProvideRadioGroup(props2, trigger);
  13171. onMounted(() => {
  13172. const rootElement = rootRef.value;
  13173. rootElement.attachVmProps(props2);
  13174. });
  13175. return () => {
  13176. return createVNode("uni-radio-group", {
  13177. "ref": rootRef
  13178. }, [slots.default && slots.default()], 512);
  13179. };
  13180. }
  13181. });
  13182. function useProvideRadioGroup(props2, trigger) {
  13183. const fields2 = [];
  13184. onMounted(() => {
  13185. _resetRadioGroupValue(fields2.length - 1);
  13186. });
  13187. const getFieldsValue = () => {
  13188. var _a;
  13189. return ((_a = fields2.find((field) => field.value.radioChecked)) == null ? void 0 : _a.value.value) + "";
  13190. };
  13191. provide(uniRadioGroupKey, {
  13192. addField(field) {
  13193. fields2.push(field);
  13194. },
  13195. removeField(field) {
  13196. fields2.splice(fields2.indexOf(field), 1);
  13197. },
  13198. radioChange($event, field) {
  13199. const index2 = fields2.indexOf(field);
  13200. _resetRadioGroupValue(index2, true);
  13201. trigger("change", $event, {
  13202. value: getFieldsValue()
  13203. });
  13204. }
  13205. });
  13206. const uniForm = inject(uniFormKey, false);
  13207. const formField = {
  13208. submit: () => {
  13209. let data = ["", null];
  13210. if (props2.name !== "") {
  13211. data[0] = props2.name;
  13212. data[1] = getFieldsValue();
  13213. }
  13214. return data;
  13215. }
  13216. };
  13217. if (uniForm) {
  13218. uniForm.addField(formField);
  13219. onBeforeUnmount(() => {
  13220. uniForm.removeField(formField);
  13221. });
  13222. }
  13223. function setFieldChecked(field, radioChecked) {
  13224. field.value = {
  13225. radioChecked,
  13226. value: field.value.value
  13227. };
  13228. }
  13229. function _resetRadioGroupValue(key, change) {
  13230. fields2.forEach((value, index2) => {
  13231. if (index2 === key) {
  13232. return;
  13233. }
  13234. if (change) {
  13235. setFieldChecked(fields2[index2], false);
  13236. } else {
  13237. fields2.forEach((v2, i) => {
  13238. if (index2 >= i) {
  13239. return;
  13240. }
  13241. if (fields2[i].value.radioChecked) {
  13242. setFieldChecked(fields2[index2], false);
  13243. }
  13244. });
  13245. }
  13246. });
  13247. }
  13248. return fields2;
  13249. }
  13250. const props$p = {
  13251. checked: {
  13252. type: [Boolean, String],
  13253. default: false
  13254. },
  13255. id: {
  13256. type: String,
  13257. default: ""
  13258. },
  13259. disabled: {
  13260. type: [Boolean, String],
  13261. default: false
  13262. },
  13263. value: {
  13264. type: String,
  13265. default: ""
  13266. },
  13267. color: {
  13268. type: String,
  13269. default: "#007aff"
  13270. },
  13271. backgroundColor: {
  13272. type: String,
  13273. default: ""
  13274. },
  13275. borderColor: {
  13276. type: String,
  13277. default: ""
  13278. },
  13279. activeBackgroundColor: {
  13280. type: String,
  13281. default: ""
  13282. },
  13283. activeBorderColor: {
  13284. type: String,
  13285. default: ""
  13286. },
  13287. iconColor: {
  13288. type: String,
  13289. default: "#ffffff"
  13290. },
  13291. // 图标颜色,同color,优先级大于iconColor
  13292. foreColor: {
  13293. type: String,
  13294. default: ""
  13295. }
  13296. };
  13297. class UniRadioElement extends UniElement {
  13298. }
  13299. const indexX$3 = /* @__PURE__ */ defineBuiltInComponent({
  13300. name: "Radio",
  13301. props: props$p,
  13302. rootElement: {
  13303. name: "uni-radio",
  13304. class: UniRadioElement
  13305. },
  13306. setup(props2, {
  13307. slots
  13308. }) {
  13309. const rootRef = ref(null);
  13310. const radioChecked = ref(props2.checked);
  13311. const radioValue = ref(props2.value);
  13312. const initialCheckedValue = props2.checked;
  13313. function getRadioStyle(checked) {
  13314. if (props2.disabled) {
  13315. return {
  13316. backgroundColor: "#E1E1E1",
  13317. borderColor: "#D1D1D1"
  13318. };
  13319. }
  13320. const style = {};
  13321. if (radioChecked.value) {
  13322. style.backgroundColor = props2.activeBackgroundColor || props2.color;
  13323. style.borderColor = props2.activeBorderColor || style.backgroundColor;
  13324. } else {
  13325. if (props2.borderColor)
  13326. style.borderColor = props2.borderColor;
  13327. if (props2.backgroundColor)
  13328. style.backgroundColor = props2.backgroundColor;
  13329. }
  13330. return style;
  13331. }
  13332. const radioStyle = computed(() => {
  13333. return getRadioStyle(radioChecked.value);
  13334. });
  13335. watch([() => props2.checked, () => props2.value], ([newChecked, newModelValue]) => {
  13336. radioChecked.value = newChecked;
  13337. radioValue.value = newModelValue;
  13338. });
  13339. const reset = () => {
  13340. radioChecked.value = initialCheckedValue;
  13341. };
  13342. const {
  13343. uniCheckGroup,
  13344. uniLabel,
  13345. field
  13346. } = useRadioInject(radioChecked, radioValue, reset);
  13347. const _onClick = ($event) => {
  13348. if (props2.disabled || radioChecked.value) {
  13349. return;
  13350. }
  13351. radioChecked.value = true;
  13352. uniCheckGroup && uniCheckGroup.radioChange($event, field);
  13353. $event.stopPropagation();
  13354. };
  13355. if (!!uniLabel) {
  13356. uniLabel.addHandler(_onClick);
  13357. onBeforeUnmount(() => {
  13358. uniLabel.removeHandler(_onClick);
  13359. });
  13360. }
  13361. useListeners(props2, {
  13362. "label-click": _onClick
  13363. });
  13364. const checkedCache = ref(radioChecked.value);
  13365. watch(() => radioChecked.value, (value) => {
  13366. checkedCache.value = value;
  13367. });
  13368. onMounted(() => {
  13369. const rootElement = rootRef.value;
  13370. Object.defineProperty(rootElement, "checked", {
  13371. get() {
  13372. return checkedCache.value;
  13373. },
  13374. set(value) {
  13375. checkedCache.value = value;
  13376. const style = getRadioStyle();
  13377. const checkboxInputElement = rootElement.querySelector(".uni-checkbox-input");
  13378. for (const key in style) {
  13379. const value2 = style[key];
  13380. value2 && checkboxInputElement.style.setProperty(key, value2);
  13381. }
  13382. }
  13383. });
  13384. rootElement.attachVmProps(props2);
  13385. });
  13386. return () => {
  13387. const booleanAttrs = useBooleanAttr(props2, "disabled");
  13388. let realCheckValue;
  13389. realCheckValue = checkedCache.value;
  13390. return createVNode("uni-radio", mergeProps(booleanAttrs, {
  13391. "onClick": _onClick,
  13392. "ref": rootRef,
  13393. "id": props2.id,
  13394. "class": "uni-radio-wrapper",
  13395. "style": {
  13396. "--HOVER-BD-COLOR": !radioChecked.value ? props2.activeBorderColor : radioStyle.value.borderColor
  13397. }
  13398. }), [createVNode("div", {
  13399. "class": ["uni-radio-input", {
  13400. "uni-radio-input-disabled": props2.disabled
  13401. }],
  13402. "style": radioStyle.value
  13403. }, [realCheckValue ? createSvgIconVNode(ICON_PATH_SUCCESS_NO_CIRCLE, props2.disabled ? "#ADADAD" : props2.foreColor || props2.iconColor, 18) : ""], 6), slots.default && slots.default()], 16, ["onClick", "id"]);
  13404. };
  13405. }
  13406. });
  13407. function useRadioInject(radioChecked, radioValue, reset) {
  13408. const field = computed({
  13409. get: () => ({
  13410. radioChecked: Boolean(radioChecked.value),
  13411. value: radioValue.value
  13412. }),
  13413. set: ({
  13414. radioChecked: checked
  13415. }) => {
  13416. radioChecked.value = checked;
  13417. }
  13418. });
  13419. const formField = {
  13420. reset
  13421. };
  13422. const uniCheckGroup = inject(uniRadioGroupKey, false);
  13423. if (!!uniCheckGroup) {
  13424. uniCheckGroup.addField(field);
  13425. }
  13426. const uniForm = inject(uniFormKey, false);
  13427. if (!!uniForm) {
  13428. uniForm.addField(formField);
  13429. }
  13430. const uniLabel = inject(uniLabelKey, false);
  13431. onBeforeUnmount(() => {
  13432. uniCheckGroup && uniCheckGroup.removeField(field);
  13433. uniForm && uniForm.removeField(formField);
  13434. });
  13435. return {
  13436. uniCheckGroup,
  13437. uniForm,
  13438. uniLabel,
  13439. field
  13440. };
  13441. }
  13442. const TAGS = {
  13443. a: "",
  13444. abbr: "",
  13445. address: "",
  13446. article: "",
  13447. aside: "",
  13448. b: "",
  13449. bdi: "",
  13450. bdo: ["dir"],
  13451. big: "",
  13452. blockquote: "",
  13453. br: "",
  13454. caption: "",
  13455. center: "",
  13456. cite: "",
  13457. code: "",
  13458. col: ["span", "width"],
  13459. colgroup: ["span", "width"],
  13460. dd: "",
  13461. del: "",
  13462. div: "",
  13463. dl: "",
  13464. dt: "",
  13465. em: "",
  13466. fieldset: "",
  13467. font: "",
  13468. footer: "",
  13469. h1: "",
  13470. h2: "",
  13471. h3: "",
  13472. h4: "",
  13473. h5: "",
  13474. h6: "",
  13475. header: "",
  13476. hr: "",
  13477. i: "",
  13478. img: ["alt", "src", "height", "width"],
  13479. ins: "",
  13480. label: "",
  13481. legend: "",
  13482. li: "",
  13483. mark: "",
  13484. nav: "",
  13485. ol: ["start", "type"],
  13486. p: "",
  13487. pre: "",
  13488. q: "",
  13489. rt: "",
  13490. ruby: "",
  13491. s: "",
  13492. section: "",
  13493. small: "",
  13494. span: "",
  13495. strong: "",
  13496. sub: "",
  13497. sup: "",
  13498. table: ["width"],
  13499. tbody: "",
  13500. td: ["colspan", "height", "rowspan", "width"],
  13501. tfoot: "",
  13502. th: ["colspan", "height", "rowspan", "width"],
  13503. thead: "",
  13504. tr: ["colspan", "height", "rowspan", "width"],
  13505. tt: "",
  13506. u: "",
  13507. ul: ""
  13508. };
  13509. const CHARS = {
  13510. amp: "&",
  13511. gt: ">",
  13512. lt: "<",
  13513. nbsp: " ",
  13514. quot: '"',
  13515. apos: "'",
  13516. ldquo: "“",
  13517. rdquo: "”",
  13518. yen: "¥",
  13519. radic: "√",
  13520. lceil: "⌈",
  13521. rceil: "⌉",
  13522. lfloor: "⌊",
  13523. rfloor: "⌋",
  13524. hellip: "…"
  13525. };
  13526. function decodeEntities(htmlString) {
  13527. return htmlString.replace(
  13528. /&(([a-zA-Z]+)|(#x{0,1}[\da-zA-Z]+));/gi,
  13529. function(match, stage) {
  13530. if (hasOwn(CHARS, stage) && CHARS[stage]) {
  13531. return CHARS[stage];
  13532. }
  13533. if (/^#[0-9]{1,4}$/.test(stage)) {
  13534. return String.fromCharCode(stage.slice(1));
  13535. }
  13536. if (/^#x[0-9a-f]{1,4}$/i.test(stage)) {
  13537. return String.fromCharCode(0 + stage.slice(1));
  13538. }
  13539. return match;
  13540. }
  13541. );
  13542. }
  13543. function processClickEvent(node, triggerItemClick) {
  13544. if (["a", "img"].includes(node.name) && triggerItemClick) {
  13545. return {
  13546. onClick: (e2) => {
  13547. triggerItemClick(e2, { node });
  13548. e2.stopPropagation();
  13549. e2.preventDefault();
  13550. e2.returnValue = false;
  13551. }
  13552. };
  13553. }
  13554. }
  13555. function normalizeAttrs(tagName, attrs2) {
  13556. if (!isPlainObject$1(attrs2))
  13557. return;
  13558. for (const key in attrs2) {
  13559. if (hasOwn(attrs2, key)) {
  13560. const value = attrs2[key];
  13561. if (tagName === "img" && key === "src")
  13562. attrs2[key] = getRealPath(value);
  13563. }
  13564. }
  13565. }
  13566. const nodeList2VNode = (scopeId, triggerItemClick, nodeList) => {
  13567. if (!nodeList || isArray(nodeList) && !nodeList.length)
  13568. return [];
  13569. return nodeList.map((node) => {
  13570. var _a;
  13571. if (!isPlainObject$1(node)) {
  13572. return;
  13573. }
  13574. if (!hasOwn(node, "type") || node.type === "node") {
  13575. let nodeProps = { [scopeId]: "" };
  13576. const tagName = (_a = node.name) == null ? void 0 : _a.toLowerCase();
  13577. if (!hasOwn(TAGS, tagName)) {
  13578. return;
  13579. }
  13580. normalizeAttrs(tagName, node.attrs);
  13581. nodeProps = extend(
  13582. nodeProps,
  13583. processClickEvent(node, triggerItemClick),
  13584. node.attrs
  13585. );
  13586. return h(
  13587. node.name,
  13588. nodeProps,
  13589. nodeList2VNode(scopeId, triggerItemClick, node.children)
  13590. );
  13591. }
  13592. if (node.type === "text" && isString(node.text) && node.text !== "")
  13593. return createTextVNode(decodeEntities(node.text || ""));
  13594. });
  13595. };
  13596. function removeDOCTYPE(html) {
  13597. return html.replace(/<\?xml.*\?>\n/, "").replace(/<!doctype.*>\n/, "").replace(/<!DOCTYPE.*>\n/, "");
  13598. }
  13599. function parseAttrs(attrs2) {
  13600. return attrs2.reduce(function(pre, attr2) {
  13601. let value = attr2.value;
  13602. const name = attr2.name;
  13603. if (value.match(/ /) && ["style", "src"].indexOf(name) === -1) {
  13604. value = value.split(" ");
  13605. }
  13606. if (pre[name]) {
  13607. if (Array.isArray(pre[name])) {
  13608. pre[name].push(value);
  13609. } else {
  13610. pre[name] = [pre[name], value];
  13611. }
  13612. } else {
  13613. pre[name] = value;
  13614. }
  13615. return pre;
  13616. }, {});
  13617. }
  13618. function parseHtml(html) {
  13619. html = removeDOCTYPE(html);
  13620. const stacks = [];
  13621. const results = {
  13622. node: "root",
  13623. children: []
  13624. };
  13625. HTMLParser(html, {
  13626. start: function(tag, attrs2, unary) {
  13627. const node = {
  13628. name: tag
  13629. };
  13630. if (attrs2.length !== 0) {
  13631. node.attrs = parseAttrs(attrs2);
  13632. }
  13633. if (unary) {
  13634. const parent = stacks[0] || results;
  13635. if (!parent.children) {
  13636. parent.children = [];
  13637. }
  13638. parent.children.push(node);
  13639. } else {
  13640. stacks.unshift(node);
  13641. }
  13642. },
  13643. end: function(tag) {
  13644. const node = stacks.shift();
  13645. if (node.name !== tag)
  13646. console.error("invalid state: mismatch end tag");
  13647. if (stacks.length === 0) {
  13648. results.children.push(node);
  13649. } else {
  13650. const parent = stacks[0];
  13651. if (!parent.children) {
  13652. parent.children = [];
  13653. }
  13654. parent.children.push(node);
  13655. }
  13656. },
  13657. chars: function(text2) {
  13658. const node = {
  13659. type: "text",
  13660. text: text2
  13661. };
  13662. if (stacks.length === 0) {
  13663. results.children.push(node);
  13664. } else {
  13665. const parent = stacks[0];
  13666. if (!parent.children) {
  13667. parent.children = [];
  13668. }
  13669. parent.children.push(node);
  13670. }
  13671. },
  13672. comment: function(text2) {
  13673. const node = {
  13674. node: "comment",
  13675. text: text2
  13676. };
  13677. const parent = stacks[0];
  13678. if (parent) {
  13679. if (!parent.children) {
  13680. parent.children = [];
  13681. }
  13682. parent.children.push(node);
  13683. }
  13684. }
  13685. });
  13686. return results.children;
  13687. }
  13688. const props$o = {
  13689. nodes: {
  13690. type: [Array, String],
  13691. default: function() {
  13692. return [];
  13693. }
  13694. }
  13695. };
  13696. class UniRichTextElement extends UniElement {
  13697. }
  13698. const index$m = /* @__PURE__ */ defineBuiltInComponent({
  13699. name: "RichText",
  13700. compatConfig: {
  13701. MODE: 3
  13702. },
  13703. props: props$o,
  13704. emits: ["click", "touchstart", "touchmove", "touchcancel", "touchend", "longpress", "itemclick"],
  13705. rootElement: {
  13706. name: "uni-rich-text",
  13707. class: UniRichTextElement
  13708. },
  13709. setup(props2, {
  13710. emit: emit2
  13711. }) {
  13712. const vm = getCurrentInstance();
  13713. const scopeId = vm && vm.vnode.scopeId || "";
  13714. const rootRef = ref(null);
  13715. const _vnode = ref([]);
  13716. const trigger = useCustomEvent(rootRef, emit2);
  13717. function triggerItemClick(e2, detail = {}) {
  13718. trigger("itemclick", e2, detail);
  13719. }
  13720. function renderVNode() {
  13721. let nodeList = props2.nodes;
  13722. if (isString(nodeList)) {
  13723. nodeList = parseHtml(props2.nodes);
  13724. }
  13725. _vnode.value = nodeList2VNode(scopeId, triggerItemClick, nodeList);
  13726. }
  13727. watch(() => props2.nodes, renderVNode, {
  13728. immediate: true
  13729. });
  13730. onMounted(() => {
  13731. const rootElement = rootRef.value;
  13732. rootElement.attachVmProps(props2);
  13733. });
  13734. return () => h("uni-rich-text", {
  13735. ref: rootRef
  13736. }, h("div", {}, _vnode.value));
  13737. }
  13738. });
  13739. const Refresher = /* @__PURE__ */ defineBuiltInComponent({
  13740. name: "Refresher",
  13741. props: {
  13742. refreshState: {
  13743. type: String,
  13744. default: ""
  13745. },
  13746. refresherHeight: {
  13747. type: Number,
  13748. default: 0
  13749. },
  13750. refresherThreshold: {
  13751. type: Number,
  13752. default: 45
  13753. },
  13754. refresherDefaultStyle: {
  13755. type: String,
  13756. default: "black"
  13757. },
  13758. refresherBackground: {
  13759. type: String,
  13760. default: "transparent"
  13761. }
  13762. },
  13763. setup(props2, {
  13764. slots
  13765. }) {
  13766. const rootRef = ref(null);
  13767. const rootStyle = computed(() => {
  13768. const style = {
  13769. backgroundColor: props2.refresherBackground
  13770. };
  13771. switch (props2.refreshState) {
  13772. case "pulling":
  13773. style.height = props2.refresherHeight + "px";
  13774. break;
  13775. case "refreshing":
  13776. style.height = props2.refresherThreshold + "px";
  13777. style.transition = "height 0.3s";
  13778. break;
  13779. case "":
  13780. case "refresherabort":
  13781. case "restore":
  13782. style.height = "0px";
  13783. style.transition = "height 0.3s";
  13784. break;
  13785. }
  13786. return style;
  13787. });
  13788. const refreshRotate = computed(() => {
  13789. const route = props2.refresherHeight / props2.refresherThreshold;
  13790. return (route > 1 ? 1 : route) * 360;
  13791. });
  13792. return () => {
  13793. const {
  13794. refreshState,
  13795. refresherDefaultStyle,
  13796. refresherThreshold
  13797. } = props2;
  13798. return createVNode("div", {
  13799. "ref": rootRef,
  13800. "style": rootStyle.value,
  13801. "class": "uni-scroll-view-refresher"
  13802. }, [refresherDefaultStyle !== "none" ? createVNode("div", {
  13803. "class": "uni-scroll-view-refresh"
  13804. }, [createVNode("div", {
  13805. "class": "uni-scroll-view-refresh-inner"
  13806. }, [refreshState == "pulling" ? createVNode("svg", {
  13807. "key": "refresh__icon",
  13808. "style": {
  13809. transform: "rotate(" + refreshRotate.value + "deg)"
  13810. },
  13811. "fill": "#2BD009",
  13812. "class": "uni-scroll-view-refresh__icon",
  13813. "width": "24",
  13814. "height": "24",
  13815. "viewBox": "0 0 24 24"
  13816. }, [createVNode("path", {
  13817. "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"
  13818. }, null), createVNode("path", {
  13819. "d": "M0 0h24v24H0z",
  13820. "fill": "none"
  13821. }, null)], 4) : null, refreshState == "refreshing" ? createVNode("svg", {
  13822. "key": "refresh__spinner",
  13823. "class": "uni-scroll-view-refresh__spinner",
  13824. "width": "24",
  13825. "height": "24",
  13826. "viewBox": "25 25 50 50"
  13827. }, [createVNode("circle", {
  13828. "cx": "50",
  13829. "cy": "50",
  13830. "r": "20",
  13831. "fill": "none",
  13832. "style": "color: #2bd009",
  13833. "stroke-width": "3"
  13834. }, null)]) : null])]) : null, refresherDefaultStyle === "none" ? createVNode("div", {
  13835. "class": "uni-scroll-view-refresher-container",
  13836. "style": {
  13837. height: `${refresherThreshold}px`
  13838. }
  13839. }, [slots.default && slots.default()]) : null], 4);
  13840. };
  13841. }
  13842. });
  13843. const passiveOptions = /* @__PURE__ */ passive(true);
  13844. const props$n = {
  13845. direction: {
  13846. type: [String],
  13847. default: "vertical"
  13848. },
  13849. scrollX: {
  13850. type: [Boolean, String],
  13851. default: false
  13852. },
  13853. scrollY: {
  13854. type: [Boolean, String],
  13855. default: false
  13856. },
  13857. showScrollbar: {
  13858. type: [Boolean, String],
  13859. default: true
  13860. },
  13861. upperThreshold: {
  13862. type: [Number, String],
  13863. default: 50
  13864. },
  13865. lowerThreshold: {
  13866. type: [Number, String],
  13867. default: 50
  13868. },
  13869. scrollTop: {
  13870. type: [Number, String],
  13871. default: 0
  13872. },
  13873. scrollLeft: {
  13874. type: [Number, String],
  13875. default: 0
  13876. },
  13877. scrollIntoView: {
  13878. type: String,
  13879. default: ""
  13880. },
  13881. scrollWithAnimation: {
  13882. type: [Boolean, String],
  13883. default: false
  13884. },
  13885. enableBackToTop: {
  13886. type: [Boolean, String],
  13887. default: false
  13888. },
  13889. refresherEnabled: {
  13890. type: [Boolean, String],
  13891. default: false
  13892. },
  13893. refresherThreshold: {
  13894. type: Number,
  13895. default: 45
  13896. },
  13897. refresherDefaultStyle: {
  13898. type: String,
  13899. default: "black"
  13900. },
  13901. refresherBackground: {
  13902. type: String,
  13903. default: "transparent"
  13904. },
  13905. refresherTriggered: {
  13906. type: [Boolean, String],
  13907. default: false
  13908. }
  13909. };
  13910. class UniScrollViewElement extends UniElement {
  13911. }
  13912. const ScrollView = /* @__PURE__ */ defineBuiltInComponent({
  13913. name: "ScrollView",
  13914. compatConfig: {
  13915. MODE: 3
  13916. },
  13917. props: props$n,
  13918. emits: ["scroll", "scrolltoupper", "scrolltolower", "refresherrefresh", "refresherrestore", "refresherpulling", "refresherabort", "update:refresherTriggered"],
  13919. rootElement: {
  13920. name: "uni-scroll-view",
  13921. class: UniScrollViewElement
  13922. },
  13923. setup(props2, {
  13924. emit: emit2,
  13925. slots,
  13926. expose
  13927. }) {
  13928. const rootRef = ref(null);
  13929. const main = ref(null);
  13930. const wrap = ref(null);
  13931. const content = ref(null);
  13932. const trigger = useCustomEvent(rootRef, emit2);
  13933. const {
  13934. state: state2,
  13935. scrollTopNumber,
  13936. scrollLeftNumber
  13937. } = useScrollViewState(props2);
  13938. const {
  13939. realScrollX,
  13940. realScrollY,
  13941. _scrollLeftChanged,
  13942. _scrollTopChanged
  13943. } = useScrollViewLoader(props2, state2, scrollTopNumber, scrollLeftNumber, trigger, rootRef, main, content, emit2);
  13944. const mainStyle = computed(() => {
  13945. let style = "";
  13946. realScrollX.value ? style += "overflow-x:auto;" : style += "overflow-x:hidden;";
  13947. realScrollY.value ? style += "overflow-y:auto;" : style += "overflow-y:hidden;";
  13948. return style;
  13949. });
  13950. const scrollBarClassName = computed(() => {
  13951. let className = "uni-scroll-view";
  13952. if (props2.showScrollbar === false) {
  13953. className += " uni-scroll-view-scrollbar-hidden";
  13954. }
  13955. return className;
  13956. });
  13957. onMounted(() => {
  13958. const rootElement = rootRef.value;
  13959. Object.defineProperties(rootElement, {
  13960. scrollHeight: {
  13961. get() {
  13962. return main.value.scrollHeight;
  13963. }
  13964. },
  13965. scrollWidth: {
  13966. get() {
  13967. return main.value.scrollWidth;
  13968. }
  13969. },
  13970. scrollLeft: {
  13971. get() {
  13972. return main.value.scrollLeft;
  13973. },
  13974. set(val) {
  13975. _scrollLeftChanged(val);
  13976. }
  13977. },
  13978. scrollTop: {
  13979. get() {
  13980. return main.value.scrollTop;
  13981. },
  13982. set(val) {
  13983. _scrollTopChanged(val);
  13984. }
  13985. },
  13986. scrollBy: {
  13987. get() {
  13988. return main.value.scrollBy.bind(main.value);
  13989. }
  13990. }
  13991. });
  13992. rootElement.attachVmProps(props2);
  13993. });
  13994. expose({
  13995. // 自动化测试需要暴露main从而获取scrollLeft
  13996. $getMain() {
  13997. return main.value;
  13998. }
  13999. });
  14000. return () => {
  14001. const {
  14002. refresherEnabled,
  14003. refresherBackground,
  14004. refresherDefaultStyle,
  14005. refresherThreshold
  14006. } = props2;
  14007. const {
  14008. refresherHeight,
  14009. refreshState
  14010. } = state2;
  14011. return createVNode("uni-scroll-view", {
  14012. "ref": rootRef
  14013. }, [createVNode("div", {
  14014. "ref": wrap,
  14015. "class": "uni-scroll-view"
  14016. }, [createVNode("div", {
  14017. "ref": main,
  14018. "style": mainStyle.value,
  14019. "class": scrollBarClassName.value
  14020. }, [refresherEnabled ? createVNode(Refresher, {
  14021. "refreshState": refreshState,
  14022. "refresherHeight": refresherHeight,
  14023. "refresherThreshold": refresherThreshold,
  14024. "refresherDefaultStyle": refresherDefaultStyle,
  14025. "refresherBackground": refresherBackground
  14026. }, {
  14027. default: () => [refresherDefaultStyle == "none" ? slots.refresher && slots.refresher() : null]
  14028. }, 8, ["refreshState", "refresherHeight", "refresherThreshold", "refresherDefaultStyle", "refresherBackground"]) : null, createVNode("div", {
  14029. "ref": content,
  14030. "class": "uni-scroll-view-content"
  14031. }, [slots.default && slots.default()], 512)], 6)], 512)], 512);
  14032. };
  14033. }
  14034. });
  14035. function useScrollViewState(props2) {
  14036. const scrollTopNumber = computed(() => {
  14037. return Number(props2.scrollTop) || 0;
  14038. });
  14039. const scrollLeftNumber = computed(() => {
  14040. return Number(props2.scrollLeft) || 0;
  14041. });
  14042. const state2 = reactive({
  14043. lastScrollTop: scrollTopNumber.value,
  14044. lastScrollLeft: scrollLeftNumber.value,
  14045. lastScrollToUpperTime: 0,
  14046. lastScrollToLowerTime: 0,
  14047. refresherHeight: 0,
  14048. refreshState: ""
  14049. });
  14050. return {
  14051. state: state2,
  14052. scrollTopNumber,
  14053. scrollLeftNumber
  14054. };
  14055. }
  14056. function useScrollViewLoader(props2, state2, scrollTopNumber, scrollLeftNumber, trigger, rootRef, main, content, emit2) {
  14057. let beforeRefreshing = false;
  14058. let toUpperNumber = 0;
  14059. let triggerAbort = false;
  14060. let __transitionEnd = () => {
  14061. };
  14062. const realScrollX = computed(() => {
  14063. if (props2.direction === "horizontal" || props2.direction === "all") {
  14064. return true;
  14065. }
  14066. return false;
  14067. });
  14068. const realScrollY = computed(() => {
  14069. if (props2.direction === "vertical" || props2.direction === "all") {
  14070. return true;
  14071. }
  14072. return false;
  14073. });
  14074. const upperThresholdNumber = computed(() => {
  14075. let val = Number(props2.upperThreshold);
  14076. return isNaN(val) ? 50 : val;
  14077. });
  14078. const lowerThresholdNumber = computed(() => {
  14079. let val = Number(props2.lowerThreshold);
  14080. return isNaN(val) ? 50 : val;
  14081. });
  14082. function scrollTo2(scrollToValue, direction2) {
  14083. const container = main.value;
  14084. let transformValue = 0;
  14085. let transform = "";
  14086. 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);
  14087. direction2 === "x" ? transformValue = container.scrollLeft - scrollToValue : direction2 === "y" && (transformValue = container.scrollTop - scrollToValue);
  14088. if (transformValue === 0)
  14089. return;
  14090. let _content = content.value;
  14091. _content.style.transition = "transform .3s ease-out";
  14092. _content.style.webkitTransition = "-webkit-transform .3s ease-out";
  14093. if (direction2 === "x") {
  14094. transform = "translateX(" + transformValue + "px) translateZ(0)";
  14095. } else {
  14096. direction2 === "y" && (transform = "translateY(" + transformValue + "px) translateZ(0)");
  14097. }
  14098. _content.removeEventListener("transitionend", __transitionEnd);
  14099. _content.removeEventListener("webkitTransitionEnd", __transitionEnd);
  14100. __transitionEnd = () => _transitionEnd(scrollToValue, direction2);
  14101. _content.addEventListener("transitionend", __transitionEnd);
  14102. _content.addEventListener("webkitTransitionEnd", __transitionEnd);
  14103. if (direction2 === "x") {
  14104. container.style.overflowX = "hidden";
  14105. } else if (direction2 === "y") {
  14106. container.style.overflowY = "hidden";
  14107. }
  14108. _content.style.transform = transform;
  14109. _content.style.webkitTransform = transform;
  14110. }
  14111. function _handleScroll($event) {
  14112. const target = $event.target;
  14113. trigger("scroll", $event, {
  14114. scrollLeft: target.scrollLeft,
  14115. scrollTop: target.scrollTop,
  14116. scrollHeight: target.scrollHeight,
  14117. scrollWidth: target.scrollWidth,
  14118. deltaX: state2.lastScrollLeft - target.scrollLeft,
  14119. deltaY: state2.lastScrollTop - target.scrollTop
  14120. });
  14121. if (realScrollY.value) {
  14122. if (target.scrollTop <= upperThresholdNumber.value && state2.lastScrollTop - target.scrollTop > 0 && $event.timeStamp - state2.lastScrollToUpperTime > 200) {
  14123. trigger("scrolltoupper", $event, {
  14124. direction: "top"
  14125. });
  14126. state2.lastScrollToUpperTime = $event.timeStamp;
  14127. }
  14128. if (target.scrollTop + target.offsetHeight + lowerThresholdNumber.value >= target.scrollHeight && state2.lastScrollTop - target.scrollTop < 0 && $event.timeStamp - state2.lastScrollToLowerTime > 200) {
  14129. trigger("scrolltolower", $event, {
  14130. direction: "bottom"
  14131. });
  14132. state2.lastScrollToLowerTime = $event.timeStamp;
  14133. }
  14134. }
  14135. if (realScrollX.value) {
  14136. if (target.scrollLeft <= upperThresholdNumber.value && state2.lastScrollLeft - target.scrollLeft > 0 && $event.timeStamp - state2.lastScrollToUpperTime > 200) {
  14137. trigger("scrolltoupper", $event, {
  14138. direction: "left"
  14139. });
  14140. state2.lastScrollToUpperTime = $event.timeStamp;
  14141. }
  14142. if (target.scrollLeft + target.offsetWidth + lowerThresholdNumber.value >= target.scrollWidth && state2.lastScrollLeft - target.scrollLeft < 0 && $event.timeStamp - state2.lastScrollToLowerTime > 200) {
  14143. trigger("scrolltolower", $event, {
  14144. direction: "right"
  14145. });
  14146. state2.lastScrollToLowerTime = $event.timeStamp;
  14147. }
  14148. }
  14149. state2.lastScrollTop = target.scrollTop;
  14150. state2.lastScrollLeft = target.scrollLeft;
  14151. }
  14152. function _scrollTopChanged(val) {
  14153. if (realScrollY.value) {
  14154. {
  14155. if (props2.scrollWithAnimation) {
  14156. scrollTo2(val, "y");
  14157. } else {
  14158. main.value.scrollTop = val;
  14159. }
  14160. }
  14161. }
  14162. }
  14163. function _scrollLeftChanged(val) {
  14164. if (realScrollX.value) {
  14165. {
  14166. if (props2.scrollWithAnimation) {
  14167. scrollTo2(val, "x");
  14168. } else {
  14169. main.value.scrollLeft = val;
  14170. }
  14171. }
  14172. }
  14173. }
  14174. function _scrollIntoViewChanged(val) {
  14175. if (val) {
  14176. if (!/^[_a-zA-Z][-_a-zA-Z0-9:]*$/.test(val)) {
  14177. console.error(`id error: scroll-into-view=${val}`);
  14178. return;
  14179. }
  14180. let element = rootRef.value.querySelector("#" + val);
  14181. if (element) {
  14182. let mainRect = main.value.getBoundingClientRect();
  14183. let elRect = element.getBoundingClientRect();
  14184. if (realScrollX.value) {
  14185. let left = elRect.left - mainRect.left;
  14186. let scrollLeft = main.value.scrollLeft;
  14187. let x = scrollLeft + left;
  14188. if (props2.scrollWithAnimation) {
  14189. scrollTo2(x, "x");
  14190. } else {
  14191. main.value.scrollLeft = x;
  14192. }
  14193. }
  14194. if (realScrollY.value) {
  14195. let top = elRect.top - mainRect.top;
  14196. let scrollTop = main.value.scrollTop;
  14197. let y = scrollTop + top;
  14198. if (props2.scrollWithAnimation) {
  14199. scrollTo2(y, "y");
  14200. } else {
  14201. main.value.scrollTop = y;
  14202. }
  14203. }
  14204. }
  14205. }
  14206. }
  14207. function _transitionEnd(val, direction2) {
  14208. content.value.style.transition = "";
  14209. content.value.style.webkitTransition = "";
  14210. content.value.style.transform = "";
  14211. content.value.style.webkitTransform = "";
  14212. let _main = main.value;
  14213. if (direction2 === "x") {
  14214. _main.style.overflowX = realScrollX.value ? "auto" : "hidden";
  14215. _main.scrollLeft = val;
  14216. } else if (direction2 === "y") {
  14217. _main.style.overflowY = realScrollY.value ? "auto" : "hidden";
  14218. _main.scrollTop = val;
  14219. }
  14220. content.value.removeEventListener("transitionend", __transitionEnd);
  14221. content.value.removeEventListener("webkitTransitionEnd", __transitionEnd);
  14222. }
  14223. function _setRefreshState(_state) {
  14224. if (!props2.refresherEnabled)
  14225. return;
  14226. switch (_state) {
  14227. case "refreshing":
  14228. state2.refresherHeight = props2.refresherThreshold;
  14229. if (!beforeRefreshing) {
  14230. beforeRefreshing = true;
  14231. trigger("refresherpulling", {}, {
  14232. deltaY: state2.refresherHeight,
  14233. dy: state2.refresherHeight
  14234. });
  14235. trigger("refresherrefresh", {}, {
  14236. dy: touchEnd.y - touchStart.y
  14237. });
  14238. emit2("update:refresherTriggered", true);
  14239. }
  14240. break;
  14241. case "restore":
  14242. case "refresherabort":
  14243. beforeRefreshing = false;
  14244. state2.refresherHeight = toUpperNumber = 0;
  14245. if (_state === "restore") {
  14246. triggerAbort = false;
  14247. trigger("refresherrestore", {}, {
  14248. dy: touchEnd.y - touchStart.y
  14249. });
  14250. }
  14251. if (_state === "refresherabort" && triggerAbort) {
  14252. triggerAbort = false;
  14253. trigger("refresherabort", {}, {
  14254. dy: touchEnd.y - touchStart.y
  14255. });
  14256. }
  14257. break;
  14258. }
  14259. state2.refreshState = _state;
  14260. }
  14261. let touchStart = {
  14262. x: 0,
  14263. y: 0
  14264. };
  14265. let touchEnd = {
  14266. x: 0,
  14267. y: props2.refresherThreshold
  14268. };
  14269. onMounted(() => {
  14270. nextTick(() => {
  14271. _scrollTopChanged(scrollTopNumber.value);
  14272. _scrollLeftChanged(scrollLeftNumber.value);
  14273. });
  14274. _scrollIntoViewChanged(props2.scrollIntoView);
  14275. let __handleScroll = function(event) {
  14276. event.preventDefault();
  14277. event.stopPropagation();
  14278. _handleScroll(event);
  14279. };
  14280. let needStop = null;
  14281. let __handleTouchMove = function(event) {
  14282. if (touchStart === null)
  14283. return;
  14284. let x = event.touches[0].pageX;
  14285. let y = event.touches[0].pageY;
  14286. let _main = main.value;
  14287. if (Math.abs(x - touchStart.x) > Math.abs(y - touchStart.y)) {
  14288. if (realScrollX.value) {
  14289. if (_main.scrollLeft === 0 && x > touchStart.x) {
  14290. needStop = false;
  14291. return;
  14292. } else if (_main.scrollWidth === _main.offsetWidth + _main.scrollLeft && x < touchStart.x) {
  14293. needStop = false;
  14294. return;
  14295. }
  14296. needStop = true;
  14297. } else {
  14298. needStop = false;
  14299. }
  14300. } else {
  14301. if (realScrollY.value) {
  14302. if (_main.scrollTop === 0 && y > touchStart.y) {
  14303. needStop = false;
  14304. if (props2.refresherEnabled && event.cancelable !== false)
  14305. event.preventDefault();
  14306. } else if (_main.scrollHeight === _main.offsetHeight + _main.scrollTop && y < touchStart.y) {
  14307. needStop = false;
  14308. return;
  14309. } else {
  14310. needStop = true;
  14311. }
  14312. } else {
  14313. needStop = false;
  14314. }
  14315. }
  14316. if (needStop) {
  14317. event.stopPropagation();
  14318. }
  14319. if (_main.scrollTop === 0 && event.touches.length === 1) {
  14320. _setRefreshState("pulling");
  14321. }
  14322. if (props2.refresherEnabled && state2.refreshState === "pulling") {
  14323. const dy = y - touchStart.y;
  14324. if (toUpperNumber === 0) {
  14325. toUpperNumber = y;
  14326. }
  14327. if (!beforeRefreshing) {
  14328. state2.refresherHeight = y - toUpperNumber;
  14329. if (state2.refresherHeight > 0) {
  14330. triggerAbort = true;
  14331. trigger("refresherpulling", event, {
  14332. deltaY: dy,
  14333. dy
  14334. });
  14335. }
  14336. } else {
  14337. state2.refresherHeight = dy + props2.refresherThreshold;
  14338. triggerAbort = false;
  14339. }
  14340. }
  14341. };
  14342. let __handleTouchStart = function(event) {
  14343. if (event.touches.length === 1) {
  14344. touchStart = {
  14345. x: event.touches[0].pageX,
  14346. y: event.touches[0].pageY
  14347. };
  14348. }
  14349. };
  14350. let __handleTouchEnd = function(event) {
  14351. touchEnd = {
  14352. x: event.changedTouches[0].pageX,
  14353. y: event.changedTouches[0].pageY
  14354. };
  14355. if (state2.refresherHeight >= props2.refresherThreshold) {
  14356. _setRefreshState("refreshing");
  14357. } else {
  14358. _setRefreshState("refresherabort");
  14359. }
  14360. touchStart = {
  14361. x: 0,
  14362. y: 0
  14363. };
  14364. touchEnd = {
  14365. x: 0,
  14366. y: props2.refresherThreshold
  14367. };
  14368. };
  14369. main.value.addEventListener("touchstart", __handleTouchStart, passiveOptions);
  14370. main.value.addEventListener("touchmove", __handleTouchMove, passive(false));
  14371. main.value.addEventListener("scroll", __handleScroll, passive(false));
  14372. main.value.addEventListener("touchend", __handleTouchEnd, passiveOptions);
  14373. onBeforeUnmount(() => {
  14374. main.value.removeEventListener("touchstart", __handleTouchStart);
  14375. main.value.removeEventListener("touchmove", __handleTouchMove);
  14376. main.value.removeEventListener("scroll", __handleScroll);
  14377. main.value.removeEventListener("touchend", __handleTouchEnd);
  14378. });
  14379. });
  14380. onActivated(() => {
  14381. realScrollY.value && (main.value.scrollTop = state2.lastScrollTop);
  14382. realScrollX.value && (main.value.scrollLeft = state2.lastScrollLeft);
  14383. });
  14384. watch(scrollTopNumber, (val) => {
  14385. _scrollTopChanged(val);
  14386. });
  14387. watch(scrollLeftNumber, (val) => {
  14388. _scrollLeftChanged(val);
  14389. });
  14390. watch(() => props2.scrollIntoView, (val) => {
  14391. _scrollIntoViewChanged(val);
  14392. });
  14393. watch(() => props2.refresherTriggered, (val) => {
  14394. if (val === true) {
  14395. _setRefreshState("refreshing");
  14396. } else if (val === false) {
  14397. _setRefreshState("restore");
  14398. }
  14399. });
  14400. return {
  14401. realScrollX,
  14402. realScrollY,
  14403. _scrollTopChanged,
  14404. _scrollLeftChanged
  14405. };
  14406. }
  14407. const SLIDER_BLOCK_SIZE_MIN_VALUE = 12;
  14408. const SLIDER_BLOCK_SIZE_MAX_VALUE = 28;
  14409. const props$m = {
  14410. name: {
  14411. type: String,
  14412. default: ""
  14413. },
  14414. min: {
  14415. type: [Number, String],
  14416. default: 0
  14417. },
  14418. max: {
  14419. type: [Number, String],
  14420. default: 100
  14421. },
  14422. value: {
  14423. type: [Number, String],
  14424. default: 0
  14425. },
  14426. step: {
  14427. type: [Number, String],
  14428. default: 1
  14429. },
  14430. disabled: {
  14431. type: [Boolean, String],
  14432. default: false
  14433. },
  14434. color: {
  14435. type: String,
  14436. default: "#e9e9e9"
  14437. },
  14438. backgroundColor: {
  14439. type: String,
  14440. default: "#e9e9e9"
  14441. },
  14442. // 优先级高于 activeColor
  14443. activeBackgroundColor: {
  14444. type: String,
  14445. default: ""
  14446. },
  14447. activeColor: {
  14448. type: String,
  14449. default: "#007aff"
  14450. },
  14451. selectedColor: {
  14452. type: String,
  14453. default: "#007aff"
  14454. },
  14455. blockColor: {
  14456. type: String,
  14457. default: "#ffffff"
  14458. },
  14459. // 优先级高于blockColor
  14460. foreColor: {
  14461. type: String,
  14462. default: ""
  14463. },
  14464. valueColor: {
  14465. type: String,
  14466. default: "#888888"
  14467. },
  14468. blockSize: {
  14469. type: [Number, String],
  14470. default: 28
  14471. },
  14472. showValue: {
  14473. type: [Boolean, String],
  14474. default: false
  14475. }
  14476. };
  14477. const getValuePercentage = (value, min, max) => {
  14478. return 100 * (value - min) / (max - min) + "%";
  14479. };
  14480. class UniSliderElement extends UniElement {
  14481. constructor() {
  14482. super(...arguments);
  14483. __publicField(this, "_initialValue", 0);
  14484. }
  14485. init() {
  14486. this.htmlSlider = this.querySelector(".uni-slider-browser-input-range");
  14487. this.trackValue = this.querySelector(".uni-slider-track-value");
  14488. this.thumbValue = this.querySelector(".uni-slider-thumb-value");
  14489. this.inputValue = this.querySelector(".uni-slider-value");
  14490. this.updateValue(this.value);
  14491. }
  14492. get value() {
  14493. return Number(this.htmlSlider.value);
  14494. }
  14495. set value(value) {
  14496. this.htmlSlider.value = value.toString();
  14497. this.updateValue(value);
  14498. }
  14499. reset() {
  14500. this.value = this._initialValue;
  14501. }
  14502. updateValue(value) {
  14503. const min = Number(this.htmlSlider.getAttribute("min"));
  14504. const max = Number(this.htmlSlider.getAttribute("max"));
  14505. if (value < min) {
  14506. value = min;
  14507. } else if (value > max) {
  14508. value = max;
  14509. }
  14510. const percentage = getValuePercentage(value, min, max);
  14511. this.trackValue.style.width = percentage;
  14512. this.thumbValue.style.left = percentage;
  14513. this.inputValue.innerText = value.toString();
  14514. }
  14515. }
  14516. const indexX$2 = /* @__PURE__ */ defineBuiltInComponent({
  14517. name: "Slider",
  14518. props: props$m,
  14519. emits: ["changing", "change"],
  14520. rootElement: {
  14521. name: "uni-slider",
  14522. class: UniSliderElement
  14523. },
  14524. setup(props2, {
  14525. emit: emit2
  14526. }) {
  14527. const sliderRef = ref(null);
  14528. const sliderValueRef = ref(null);
  14529. let uniSliderElement;
  14530. watch(() => props2.value, (val) => {
  14531. uniSliderElement.value = Number(val);
  14532. });
  14533. const trigger = useCustomEvent(sliderRef, emit2);
  14534. const state2 = useSliderState(props2);
  14535. const {
  14536. _onInput,
  14537. _onChange
  14538. } = useSliderLoader(props2, sliderRef, trigger);
  14539. onMounted(() => {
  14540. uniSliderElement = sliderRef.value;
  14541. uniSliderElement._initialValue = props2.value;
  14542. uniSliderElement.init();
  14543. uniSliderElement.attachVmProps(props2);
  14544. });
  14545. return () => {
  14546. const {
  14547. setTrackBgColor,
  14548. setActiveColor,
  14549. setThumbStyle,
  14550. thumbTrackStyle,
  14551. setValueStyle
  14552. } = state2;
  14553. return createVNode("uni-slider", {
  14554. "ref": sliderRef
  14555. }, [createVNode("div", {
  14556. "class": "uni-slider-wrapper"
  14557. }, [createVNode("div", {
  14558. "class": "uni-slider-input"
  14559. }, [createVNode("div", {
  14560. "style": setTrackBgColor.value,
  14561. "class": "uni-slider-track"
  14562. }, [createVNode("div", {
  14563. "style": setActiveColor.value,
  14564. "class": "uni-slider-track-value"
  14565. }, null, 4)], 4), createVNode("div", {
  14566. "style": thumbTrackStyle.value,
  14567. "class": "uni-slider-thumb-track"
  14568. }, [createVNode("div", {
  14569. "style": setThumbStyle.value,
  14570. "class": "uni-slider-thumb-value"
  14571. }, null, 4)], 4), createVNode("input", {
  14572. "class": "uni-slider-browser-input-range",
  14573. "type": "range",
  14574. "min": props2.min,
  14575. "max": props2.max,
  14576. "step": props2.step,
  14577. "value": props2.value,
  14578. "onInput": withWebEvent(_onInput),
  14579. "onChange": withWebEvent(_onChange)
  14580. }, null, 40, ["min", "max", "step", "value", "onInput", "onChange"])]), withDirectives(createVNode("span", {
  14581. "ref": sliderValueRef,
  14582. "style": setValueStyle.value,
  14583. "class": "uni-slider-value"
  14584. }, null, 4), [[vShow, props2.showValue]])]), createVNode("slot", null, null)], 512);
  14585. };
  14586. }
  14587. });
  14588. function useSliderState(props2) {
  14589. const _getBgColor = () => {
  14590. return props2.backgroundColor !== "#e9e9e9" ? props2.backgroundColor : props2.color !== "#007aff" ? props2.color : "#007aff";
  14591. };
  14592. const _getActiveColor = () => {
  14593. const activeColor = props2.activeBackgroundColor || props2.activeColor;
  14594. return activeColor !== "#007aff" ? activeColor : props2.selectedColor !== "#e9e9e9" ? props2.selectedColor : "#e9e9e9";
  14595. };
  14596. const _getBlockSizeString = () => {
  14597. const blockSize = Math.min(Math.max(Number(props2.blockSize), SLIDER_BLOCK_SIZE_MIN_VALUE), SLIDER_BLOCK_SIZE_MAX_VALUE);
  14598. return blockSize + "px";
  14599. };
  14600. const state2 = {
  14601. setTrackBgColor: computed(() => ({
  14602. backgroundColor: _getBgColor()
  14603. })),
  14604. setActiveColor: computed(() => ({
  14605. backgroundColor: _getActiveColor()
  14606. })),
  14607. thumbTrackStyle: computed(() => ({
  14608. marginRight: _getBlockSizeString()
  14609. })),
  14610. setThumbStyle: computed(() => ({
  14611. width: _getBlockSizeString(),
  14612. height: _getBlockSizeString(),
  14613. backgroundColor: props2.foreColor || props2.blockColor
  14614. })),
  14615. setValueStyle: computed(() => ({
  14616. color: props2.valueColor
  14617. }))
  14618. };
  14619. return state2;
  14620. }
  14621. function useSliderLoader(props2, sliderRef, trigger) {
  14622. const _onInput = (event) => {
  14623. if (props2.disabled) {
  14624. return;
  14625. }
  14626. const valueNumber = Number(event.target.value);
  14627. sliderRef.value.updateValue(valueNumber);
  14628. trigger("changing", event, {
  14629. value: valueNumber
  14630. });
  14631. };
  14632. const _onChange = (event) => {
  14633. if (props2.disabled) {
  14634. return;
  14635. }
  14636. const valueNumber = Number(event.target.value);
  14637. sliderRef.value.updateValue(valueNumber);
  14638. trigger("change", event, {
  14639. value: valueNumber
  14640. });
  14641. };
  14642. const uniForm = inject(uniFormKey, false);
  14643. if (!!uniForm) {
  14644. const field = {
  14645. reset: () => {
  14646. sliderRef.value.reset();
  14647. },
  14648. submit: () => {
  14649. const data = ["", null];
  14650. const value = sliderRef.value.value;
  14651. if (props2.name !== "") {
  14652. data[0] = props2.name;
  14653. data[1] = value;
  14654. }
  14655. return data;
  14656. }
  14657. };
  14658. uniForm.addField(field);
  14659. onBeforeUnmount(() => {
  14660. uniForm.removeField(field);
  14661. });
  14662. }
  14663. return {
  14664. _onInput,
  14665. _onChange
  14666. };
  14667. }
  14668. const props$l = {
  14669. indicatorDots: {
  14670. type: [Boolean, String],
  14671. default: false
  14672. },
  14673. vertical: {
  14674. type: [Boolean, String],
  14675. default: false
  14676. },
  14677. autoplay: {
  14678. type: [Boolean, String],
  14679. default: false
  14680. },
  14681. circular: {
  14682. type: [Boolean, String],
  14683. default: false
  14684. },
  14685. interval: {
  14686. type: [Number, String],
  14687. default: 5e3
  14688. },
  14689. duration: {
  14690. type: [Number, String],
  14691. default: 500
  14692. },
  14693. current: {
  14694. type: [Number, String],
  14695. default: 0
  14696. },
  14697. indicatorColor: {
  14698. type: String,
  14699. default: ""
  14700. },
  14701. indicatorActiveColor: {
  14702. type: String,
  14703. default: ""
  14704. },
  14705. previousMargin: {
  14706. type: String,
  14707. default: ""
  14708. },
  14709. nextMargin: {
  14710. type: String,
  14711. default: ""
  14712. },
  14713. currentItemId: {
  14714. type: String,
  14715. default: ""
  14716. },
  14717. skipHiddenItemLayout: {
  14718. type: [Boolean, String],
  14719. default: false
  14720. },
  14721. displayMultipleItems: {
  14722. type: [Number, String],
  14723. default: 1
  14724. },
  14725. disableTouch: {
  14726. type: [Boolean, String],
  14727. default: false
  14728. },
  14729. navigation: {
  14730. type: [Boolean, String],
  14731. default: false
  14732. },
  14733. navigationColor: {
  14734. type: String,
  14735. default: "#fff"
  14736. },
  14737. navigationActiveColor: {
  14738. type: String,
  14739. default: "rgba(53, 53, 53, 0.6)"
  14740. }
  14741. };
  14742. function useState$3(props2) {
  14743. const interval = computed(() => {
  14744. const interval2 = Number(props2.interval);
  14745. return isNaN(interval2) ? 5e3 : interval2;
  14746. });
  14747. const duration = computed(() => {
  14748. const duration2 = Number(props2.duration);
  14749. return isNaN(duration2) ? 500 : duration2;
  14750. });
  14751. const displayMultipleItems = computed(() => {
  14752. const displayMultipleItems2 = Math.round(props2.displayMultipleItems);
  14753. return isNaN(displayMultipleItems2) ? 1 : displayMultipleItems2;
  14754. });
  14755. const state2 = reactive({
  14756. interval,
  14757. duration,
  14758. displayMultipleItems,
  14759. current: Math.round(props2.current) || 0,
  14760. currentItemId: props2.currentItemId,
  14761. userTracking: false
  14762. });
  14763. return state2;
  14764. }
  14765. function useLayout(props2, state2, swiperContexts, slideFrameRef, emit2, trigger) {
  14766. function cancelSchedule() {
  14767. if (timer) {
  14768. clearTimeout(timer);
  14769. timer = null;
  14770. }
  14771. }
  14772. let timer = null;
  14773. let invalid = true;
  14774. let viewportPosition = 0;
  14775. let viewportMoveRatio = 1;
  14776. let animating = null;
  14777. let requestedAnimation = false;
  14778. let contentTrackViewport = 0;
  14779. let transitionStart;
  14780. let currentChangeSource = "";
  14781. let animationFrame;
  14782. const swiperEnabled = computed(() => swiperContexts.value.length > state2.displayMultipleItems);
  14783. const circularEnabled = computed(() => props2.circular && swiperEnabled.value);
  14784. function checkCircularLayout(index2) {
  14785. if (!invalid) {
  14786. for (let items = swiperContexts.value, n = items.length, i = index2 + state2.displayMultipleItems, r = 0; r < n; r++) {
  14787. const item = items[r];
  14788. const s = Math.floor(index2 / n) * n + r;
  14789. const l = s + n;
  14790. const c = s - n;
  14791. const u = Math.max(index2 - (s + 1), s - i, 0);
  14792. const d = Math.max(index2 - (l + 1), l - i, 0);
  14793. const h2 = Math.max(index2 - (c + 1), c - i, 0);
  14794. const p2 = Math.min(u, d, h2);
  14795. const position = [s, l, c][[u, d, h2].indexOf(p2)];
  14796. item.updatePosition(position, props2.vertical);
  14797. }
  14798. }
  14799. }
  14800. function updateViewport(index2) {
  14801. if (!(Math.floor(2 * viewportPosition) === Math.floor(2 * index2) && Math.ceil(2 * viewportPosition) === Math.ceil(2 * index2))) {
  14802. if (circularEnabled.value) {
  14803. checkCircularLayout(index2);
  14804. }
  14805. }
  14806. const x = props2.vertical ? "0" : 100 * -index2 * viewportMoveRatio + "%";
  14807. const y = props2.vertical ? 100 * -index2 * viewportMoveRatio + "%" : "0";
  14808. const transform = "translate(" + x + ", " + y + ") translateZ(0)";
  14809. const slideFrame = slideFrameRef.value;
  14810. if (slideFrame) {
  14811. slideFrame.style.webkitTransform = transform;
  14812. slideFrame.style.transform = transform;
  14813. }
  14814. viewportPosition = index2;
  14815. if (!transitionStart) {
  14816. if (index2 % 1 === 0) {
  14817. return;
  14818. }
  14819. transitionStart = index2;
  14820. }
  14821. index2 -= Math.floor(transitionStart);
  14822. const items = swiperContexts.value;
  14823. if (index2 <= -(items.length - 1)) {
  14824. index2 += items.length;
  14825. } else if (index2 >= items.length) {
  14826. index2 -= items.length;
  14827. }
  14828. index2 = transitionStart % 1 > 0.5 || transitionStart < 0 ? index2 - 1 : index2;
  14829. trigger("transition", {}, {
  14830. dx: props2.vertical ? 0 : index2 * slideFrame.offsetWidth,
  14831. dy: props2.vertical ? index2 * slideFrame.offsetHeight : 0
  14832. });
  14833. }
  14834. function endViewportAnimation() {
  14835. if (animating) {
  14836. updateViewport(animating.toPos);
  14837. animating = null;
  14838. }
  14839. }
  14840. function normalizeCurrentValue(current) {
  14841. const length = swiperContexts.value.length;
  14842. if (!length) {
  14843. return -1;
  14844. }
  14845. const index2 = (Math.round(current) % length + length) % length;
  14846. if (circularEnabled.value) {
  14847. if (length <= state2.displayMultipleItems) {
  14848. return 0;
  14849. }
  14850. } else if (index2 > length - state2.displayMultipleItems) {
  14851. return length - state2.displayMultipleItems;
  14852. }
  14853. return index2;
  14854. }
  14855. function cancelViewportAnimation() {
  14856. animating = null;
  14857. }
  14858. function animateFrameFuncProto() {
  14859. if (!animating) {
  14860. requestedAnimation = false;
  14861. return;
  14862. }
  14863. const _animating = animating;
  14864. const toPos = _animating.toPos;
  14865. const acc = _animating.acc;
  14866. const endTime = _animating.endTime;
  14867. const source = _animating.source;
  14868. const time = endTime - Date.now();
  14869. if (time <= 0) {
  14870. updateViewport(toPos);
  14871. animating = null;
  14872. requestedAnimation = false;
  14873. transitionStart = null;
  14874. const item = swiperContexts.value[state2.current];
  14875. if (item) {
  14876. const currentItemId = item.getItemId();
  14877. trigger("animationfinish", {}, {
  14878. current: state2.current,
  14879. currentItemId,
  14880. source
  14881. });
  14882. }
  14883. return;
  14884. }
  14885. const s = acc * time * time / 2;
  14886. const l = toPos + s;
  14887. updateViewport(l);
  14888. animationFrame = requestAnimationFrame(animateFrameFuncProto);
  14889. }
  14890. function animateViewport(current, source, n) {
  14891. cancelViewportAnimation();
  14892. const duration = state2.duration;
  14893. const length = swiperContexts.value.length;
  14894. let position = viewportPosition;
  14895. if (circularEnabled.value) {
  14896. if (n < 0) {
  14897. for (; position < current; ) {
  14898. position += length;
  14899. }
  14900. for (; position - length > current; ) {
  14901. position -= length;
  14902. }
  14903. } else if (n > 0) {
  14904. for (; position > current; ) {
  14905. position -= length;
  14906. }
  14907. for (; position + length < current; ) {
  14908. position += length;
  14909. }
  14910. if (position + length - current < current - position) {
  14911. position += length;
  14912. }
  14913. } else {
  14914. for (; position + length < current; ) {
  14915. position += length;
  14916. }
  14917. for (; position - length > current; ) {
  14918. position -= length;
  14919. }
  14920. if (position + length - current < current - position) {
  14921. position += length;
  14922. }
  14923. }
  14924. } else if (source === "click") {
  14925. current = current + state2.displayMultipleItems - 1 < length ? current : 0;
  14926. }
  14927. animating = {
  14928. toPos: current,
  14929. acc: 2 * (position - current) / (duration * duration),
  14930. endTime: Date.now() + duration,
  14931. source
  14932. };
  14933. if (!requestedAnimation) {
  14934. requestedAnimation = true;
  14935. animationFrame = requestAnimationFrame(animateFrameFuncProto);
  14936. }
  14937. }
  14938. function scheduleAutoplay() {
  14939. cancelSchedule();
  14940. const items = swiperContexts.value;
  14941. const callback = function() {
  14942. timer = null;
  14943. currentChangeSource = "autoplay";
  14944. if (circularEnabled.value) {
  14945. state2.current = normalizeCurrentValue(state2.current + 1);
  14946. } else {
  14947. state2.current = state2.current + state2.displayMultipleItems < items.length ? state2.current + 1 : 0;
  14948. }
  14949. animateViewport(state2.current, "autoplay", circularEnabled.value ? 1 : 0);
  14950. timer = setTimeout(callback, state2.interval);
  14951. };
  14952. if (!(invalid || items.length <= state2.displayMultipleItems)) {
  14953. timer = setTimeout(callback, state2.interval);
  14954. }
  14955. }
  14956. function resetLayout() {
  14957. cancelSchedule();
  14958. endViewportAnimation();
  14959. const items = swiperContexts.value;
  14960. for (let i = 0; i < items.length; i++) {
  14961. items[i].updatePosition(i, props2.vertical);
  14962. }
  14963. viewportMoveRatio = 1;
  14964. const slideFrameEl = slideFrameRef.value;
  14965. if (state2.displayMultipleItems === 1 && items.length) {
  14966. const itemRect = items[0].getBoundingClientRect();
  14967. const slideFrameRect = slideFrameEl.getBoundingClientRect();
  14968. viewportMoveRatio = itemRect.width / slideFrameRect.width;
  14969. if (!(viewportMoveRatio > 0 && viewportMoveRatio < 1)) {
  14970. viewportMoveRatio = 1;
  14971. }
  14972. }
  14973. const position = viewportPosition;
  14974. viewportPosition = -2;
  14975. const current = state2.current;
  14976. if (current >= 0) {
  14977. invalid = false;
  14978. if (state2.userTracking) {
  14979. updateViewport(position + current - contentTrackViewport);
  14980. contentTrackViewport = current;
  14981. } else {
  14982. updateViewport(current);
  14983. if (props2.autoplay) {
  14984. scheduleAutoplay();
  14985. }
  14986. }
  14987. } else {
  14988. invalid = true;
  14989. updateViewport(-state2.displayMultipleItems - 1);
  14990. }
  14991. }
  14992. watch([() => props2.current, () => props2.currentItemId, () => [...swiperContexts.value]], () => {
  14993. let current = -1;
  14994. if (props2.currentItemId) {
  14995. for (let i = 0, items = swiperContexts.value; i < items.length; i++) {
  14996. const itemId = items[i].getItemId();
  14997. if (itemId === props2.currentItemId) {
  14998. current = i;
  14999. break;
  15000. }
  15001. }
  15002. }
  15003. if (current < 0) {
  15004. current = Math.round(props2.current) || 0;
  15005. }
  15006. current = current < 0 ? 0 : current;
  15007. if (state2.current !== current) {
  15008. currentChangeSource = "";
  15009. state2.current = current;
  15010. }
  15011. });
  15012. watch([() => props2.vertical, () => circularEnabled.value, () => state2.displayMultipleItems, () => [...swiperContexts.value]], resetLayout);
  15013. watch(() => state2.interval, () => {
  15014. if (timer) {
  15015. cancelSchedule();
  15016. scheduleAutoplay();
  15017. }
  15018. });
  15019. function currentChanged(current, history2) {
  15020. const source = currentChangeSource;
  15021. currentChangeSource = "";
  15022. const items = swiperContexts.value;
  15023. if (!source) {
  15024. const length = items.length;
  15025. animateViewport(current, "", circularEnabled.value && history2 + (length - current) % length > length / 2 ? 1 : 0);
  15026. }
  15027. const item = items[current];
  15028. if (item) {
  15029. const currentItemId = state2.currentItemId = item.getItemId();
  15030. trigger("change", {}, {
  15031. current: state2.current,
  15032. currentItemId,
  15033. source
  15034. });
  15035. }
  15036. }
  15037. watch(() => state2.current, (val, oldVal) => {
  15038. currentChanged(val, oldVal);
  15039. emit2("update:current", val);
  15040. });
  15041. watch(() => state2.currentItemId, (val) => {
  15042. emit2("update:currentItemId", val);
  15043. });
  15044. function inintAutoplay(enable) {
  15045. if (enable) {
  15046. scheduleAutoplay();
  15047. } else {
  15048. cancelSchedule();
  15049. }
  15050. }
  15051. watch(() => props2.autoplay && !state2.userTracking, inintAutoplay);
  15052. inintAutoplay(props2.autoplay && !state2.userTracking);
  15053. onMounted(() => {
  15054. let userDirectionChecked = false;
  15055. let contentTrackSpeed = 0;
  15056. let contentTrackT = 0;
  15057. function handleTrackStart() {
  15058. cancelSchedule();
  15059. contentTrackViewport = viewportPosition;
  15060. contentTrackSpeed = 0;
  15061. contentTrackT = Date.now();
  15062. cancelViewportAnimation();
  15063. }
  15064. function handleTrackMove(data) {
  15065. const oldContentTrackT = contentTrackT;
  15066. contentTrackT = Date.now();
  15067. const length = swiperContexts.value.length;
  15068. const other = length - state2.displayMultipleItems;
  15069. function calc2(val) {
  15070. return 0.5 - 0.25 / (val + 0.5);
  15071. }
  15072. function move(oldVal, newVal) {
  15073. let val = contentTrackViewport + oldVal;
  15074. contentTrackSpeed = 0.6 * contentTrackSpeed + 0.4 * newVal;
  15075. if (!circularEnabled.value) {
  15076. if (val < 0 || val > other) {
  15077. if (val < 0) {
  15078. val = -calc2(-val);
  15079. } else {
  15080. if (val > other) {
  15081. val = other + calc2(val - other);
  15082. }
  15083. }
  15084. contentTrackSpeed = 0;
  15085. }
  15086. }
  15087. updateViewport(val);
  15088. }
  15089. const time = contentTrackT - oldContentTrackT || 1;
  15090. const slideFrameEl = slideFrameRef.value;
  15091. if (props2.vertical) {
  15092. move(-data.dy / slideFrameEl.offsetHeight, -data.ddy / time);
  15093. } else {
  15094. move(-data.dx / slideFrameEl.offsetWidth, -data.ddx / time);
  15095. }
  15096. }
  15097. function handleTrackEnd(isCancel) {
  15098. state2.userTracking = false;
  15099. const t2 = contentTrackSpeed / Math.abs(contentTrackSpeed);
  15100. let n = 0;
  15101. if (!isCancel && Math.abs(contentTrackSpeed) > 0.2) {
  15102. n = 0.5 * t2;
  15103. }
  15104. const current = normalizeCurrentValue(viewportPosition + n);
  15105. if (isCancel) {
  15106. updateViewport(contentTrackViewport);
  15107. } else {
  15108. currentChangeSource = "touch";
  15109. state2.current = current;
  15110. animateViewport(current, "touch", n !== 0 ? n : current === 0 && circularEnabled.value && viewportPosition >= 1 ? 1 : 0);
  15111. }
  15112. }
  15113. useTouchtrack(slideFrameRef.value, (event) => {
  15114. if (props2.disableTouch) {
  15115. return;
  15116. }
  15117. if (!invalid) {
  15118. if (event.detail.state === "start") {
  15119. state2.userTracking = true;
  15120. userDirectionChecked = false;
  15121. return handleTrackStart();
  15122. }
  15123. if (event.detail.state === "end") {
  15124. return handleTrackEnd(false);
  15125. }
  15126. if (event.detail.state === "cancel") {
  15127. return handleTrackEnd(true);
  15128. }
  15129. if (state2.userTracking) {
  15130. if (!userDirectionChecked) {
  15131. userDirectionChecked = true;
  15132. const t2 = Math.abs(event.detail.dx);
  15133. const n = Math.abs(event.detail.dy);
  15134. if (t2 >= n && props2.vertical) {
  15135. state2.userTracking = false;
  15136. } else {
  15137. if (t2 <= n && !props2.vertical) {
  15138. state2.userTracking = false;
  15139. }
  15140. }
  15141. if (!state2.userTracking) {
  15142. if (props2.autoplay) {
  15143. scheduleAutoplay();
  15144. }
  15145. return;
  15146. }
  15147. }
  15148. handleTrackMove(event.detail);
  15149. return false;
  15150. }
  15151. }
  15152. });
  15153. });
  15154. onUnmounted(() => {
  15155. cancelSchedule();
  15156. cancelAnimationFrame(animationFrame);
  15157. });
  15158. function onSwiperDotClick(index2) {
  15159. animateViewport(state2.current = index2, currentChangeSource = "click", circularEnabled.value ? 1 : 0);
  15160. }
  15161. return {
  15162. onSwiperDotClick,
  15163. circularEnabled,
  15164. swiperEnabled
  15165. };
  15166. }
  15167. class UniSwiperElement extends UniElement {
  15168. }
  15169. const Swiper = /* @__PURE__ */ defineBuiltInComponent({
  15170. name: "Swiper",
  15171. props: props$l,
  15172. emits: ["change", "transition", "animationfinish", "update:current", "update:currentItemId"],
  15173. rootElement: {
  15174. name: "uni-swiper",
  15175. class: UniSwiperElement
  15176. },
  15177. setup(props2, {
  15178. slots,
  15179. emit: emit2
  15180. }) {
  15181. const rootRef = ref(null);
  15182. const trigger = useCustomEvent(rootRef, emit2);
  15183. const slidesWrapperRef = ref(null);
  15184. const slideFrameRef = ref(null);
  15185. const state2 = useState$3(props2);
  15186. const slidesStyle = computed(() => {
  15187. let style = {};
  15188. if (props2.nextMargin || props2.previousMargin) {
  15189. style = props2.vertical ? {
  15190. left: 0,
  15191. right: 0,
  15192. top: rpx2px(props2.previousMargin, true),
  15193. bottom: rpx2px(props2.nextMargin, true)
  15194. } : {
  15195. top: 0,
  15196. bottom: 0,
  15197. left: rpx2px(props2.previousMargin, true),
  15198. right: rpx2px(props2.nextMargin, true)
  15199. };
  15200. }
  15201. return style;
  15202. });
  15203. const slideFrameStyle = computed(() => {
  15204. const value = Math.abs(100 / state2.displayMultipleItems) + "%";
  15205. return {
  15206. width: props2.vertical ? "100%" : value,
  15207. height: !props2.vertical ? "100%" : value
  15208. };
  15209. });
  15210. let swiperItems = [];
  15211. const originSwiperContexts = [];
  15212. const swiperContexts = ref([]);
  15213. function updateSwiperContexts() {
  15214. const contexts = [];
  15215. for (let index2 = 0; index2 < swiperItems.length; index2++) {
  15216. let swiperItem = swiperItems[index2];
  15217. if (!(swiperItem instanceof Element)) {
  15218. swiperItem = swiperItem.el;
  15219. }
  15220. const swiperContext = originSwiperContexts.find((context) => swiperItem === context.rootRef.value);
  15221. if (swiperContext) {
  15222. contexts.push(markRaw(swiperContext));
  15223. }
  15224. }
  15225. swiperContexts.value = contexts;
  15226. }
  15227. const addSwiperContext = function(swiperContext) {
  15228. originSwiperContexts.push(swiperContext);
  15229. updateSwiperContexts();
  15230. };
  15231. provide("addSwiperContext", addSwiperContext);
  15232. const removeSwiperContext = function(swiperContext) {
  15233. const index2 = originSwiperContexts.indexOf(swiperContext);
  15234. if (index2 >= 0) {
  15235. originSwiperContexts.splice(index2, 1);
  15236. updateSwiperContexts();
  15237. }
  15238. };
  15239. provide("removeSwiperContext", removeSwiperContext);
  15240. const {
  15241. onSwiperDotClick,
  15242. circularEnabled,
  15243. swiperEnabled
  15244. } = useLayout(props2, state2, swiperContexts, slideFrameRef, emit2, trigger);
  15245. let createNavigationTsx = () => null;
  15246. {
  15247. createNavigationTsx = useSwiperNavigation(rootRef, props2, state2, onSwiperDotClick, swiperContexts, circularEnabled, swiperEnabled);
  15248. }
  15249. onMounted(() => {
  15250. const rootElement = rootRef.value;
  15251. rootElement.attachVmProps(props2);
  15252. });
  15253. return () => {
  15254. const defaultSlots = slots.default && slots.default();
  15255. swiperItems = flatVNode(defaultSlots);
  15256. return createVNode("uni-swiper", {
  15257. "ref": rootRef
  15258. }, [createVNode("div", {
  15259. "ref": slidesWrapperRef,
  15260. "class": "uni-swiper-wrapper"
  15261. }, [createVNode("div", {
  15262. "class": "uni-swiper-slides",
  15263. "style": slidesStyle.value
  15264. }, [createVNode("div", {
  15265. "ref": slideFrameRef,
  15266. "class": "uni-swiper-slide-frame",
  15267. "style": slideFrameStyle.value
  15268. }, [defaultSlots], 4)], 4), props2.indicatorDots && createVNode("div", {
  15269. "class": ["uni-swiper-dots", props2.vertical ? "uni-swiper-dots-vertical" : "uni-swiper-dots-horizontal"]
  15270. }, [swiperContexts.value.map((_, index2, array) => createVNode("div", {
  15271. "onClick": () => onSwiperDotClick(index2),
  15272. "class": {
  15273. "uni-swiper-dot": true,
  15274. "uni-swiper-dot-active": index2 < state2.current + state2.displayMultipleItems && index2 >= state2.current || index2 < state2.current + state2.displayMultipleItems - array.length
  15275. },
  15276. "style": {
  15277. background: index2 === state2.current ? props2.indicatorActiveColor : props2.indicatorColor
  15278. }
  15279. }, null, 14, ["onClick"]))], 2), createNavigationTsx()], 512)], 512);
  15280. };
  15281. }
  15282. });
  15283. const useSwiperNavigation = (rootRef, props2, state2, onSwiperDotClick, swiperContext, circularEnabled, swiperEnabled) => {
  15284. let isNavigationAuto = false;
  15285. let prevDisabled = false;
  15286. let nextDisabled = false;
  15287. let hideNavigation = ref(false);
  15288. watchEffect(() => {
  15289. isNavigationAuto = props2.navigation === "auto";
  15290. hideNavigation.value = props2.navigation !== true || isNavigationAuto;
  15291. swiperAddMouseEvent();
  15292. });
  15293. watchEffect(() => {
  15294. const swiperItemLength = swiperContext.value.length;
  15295. const notCircular = !circularEnabled.value;
  15296. prevDisabled = state2.current === 0 && notCircular;
  15297. nextDisabled = state2.current === swiperItemLength - 1 && notCircular || notCircular && state2.current + state2.displayMultipleItems >= swiperItemLength;
  15298. if (!swiperEnabled.value) {
  15299. prevDisabled = true;
  15300. nextDisabled = true;
  15301. isNavigationAuto && (hideNavigation.value = true);
  15302. }
  15303. });
  15304. function navigationHover(event, type) {
  15305. const target = event.currentTarget;
  15306. if (!target)
  15307. return;
  15308. target.style.backgroundColor = type === "over" ? props2.navigationActiveColor : "";
  15309. }
  15310. const navigationAttr = {
  15311. onMouseover: (event) => navigationHover(event, "over"),
  15312. onMouseout: (event) => navigationHover(event, "out")
  15313. };
  15314. function navigationClick($event, type, disabled) {
  15315. $event.stopPropagation();
  15316. if (disabled)
  15317. return;
  15318. const swiperItemLength = swiperContext.value.length;
  15319. let _current = state2.current;
  15320. switch (type) {
  15321. case "prev":
  15322. _current--;
  15323. if (_current < 0 && circularEnabled.value) {
  15324. _current = swiperItemLength - 1;
  15325. }
  15326. break;
  15327. case "next":
  15328. _current++;
  15329. if (_current >= swiperItemLength && circularEnabled.value) {
  15330. _current = 0;
  15331. }
  15332. break;
  15333. }
  15334. onSwiperDotClick(_current);
  15335. }
  15336. const createNavigationSVG = () => createSvgIconVNode(ICON_PATH_BACK, props2.navigationColor, 26);
  15337. let setHideNavigationTimer;
  15338. const _mousemove = (e2) => {
  15339. clearTimeout(setHideNavigationTimer);
  15340. const {
  15341. clientX,
  15342. clientY
  15343. } = e2;
  15344. const {
  15345. left,
  15346. right,
  15347. top,
  15348. bottom,
  15349. width,
  15350. height
  15351. } = rootRef.value.getBoundingClientRect();
  15352. let hide = false;
  15353. if (props2.vertical) {
  15354. hide = !(clientY - top < height / 3 || bottom - clientY < height / 3);
  15355. } else {
  15356. hide = !(clientX - left < width / 3 || right - clientX < width / 3);
  15357. }
  15358. if (hide) {
  15359. return setHideNavigationTimer = setTimeout(() => {
  15360. hideNavigation.value = hide;
  15361. }, 300);
  15362. }
  15363. hideNavigation.value = hide;
  15364. };
  15365. const _mouseleave = () => {
  15366. hideNavigation.value = true;
  15367. };
  15368. function swiperAddMouseEvent() {
  15369. if (rootRef.value) {
  15370. rootRef.value.removeEventListener("mousemove", _mousemove);
  15371. rootRef.value.removeEventListener("mouseleave", _mouseleave);
  15372. if (isNavigationAuto) {
  15373. rootRef.value.addEventListener("mousemove", _mousemove);
  15374. rootRef.value.addEventListener("mouseleave", _mouseleave);
  15375. }
  15376. }
  15377. }
  15378. onMounted(swiperAddMouseEvent);
  15379. function createNavigationTsx() {
  15380. const navigationClass = {
  15381. "uni-swiper-navigation-hide": hideNavigation.value,
  15382. "uni-swiper-navigation-vertical": props2.vertical
  15383. };
  15384. if (props2.navigation) {
  15385. return createVNode(Fragment, null, [createVNode("div", mergeProps({
  15386. "class": ["uni-swiper-navigation uni-swiper-navigation-prev", extend({
  15387. "uni-swiper-navigation-disabled": prevDisabled
  15388. }, navigationClass)],
  15389. "onClick": (e2) => navigationClick(e2, "prev", prevDisabled)
  15390. }, navigationAttr), [createNavigationSVG()], 16, ["onClick"]), createVNode("div", mergeProps({
  15391. "class": ["uni-swiper-navigation uni-swiper-navigation-next", extend({
  15392. "uni-swiper-navigation-disabled": nextDisabled
  15393. }, navigationClass)],
  15394. "onClick": (e2) => navigationClick(e2, "next", nextDisabled)
  15395. }, navigationAttr), [createNavigationSVG()], 16, ["onClick"])]);
  15396. }
  15397. return null;
  15398. }
  15399. return createNavigationTsx;
  15400. };
  15401. const props$k = {
  15402. itemId: {
  15403. type: String,
  15404. default: ""
  15405. }
  15406. };
  15407. class UniSwiperItemElement extends UniElement {
  15408. }
  15409. const SwiperItem = /* @__PURE__ */ defineBuiltInComponent({
  15410. name: "SwiperItem",
  15411. props: props$k,
  15412. rootElement: {
  15413. name: "uni-swiper-item",
  15414. class: UniSwiperItemElement
  15415. },
  15416. setup(props2, {
  15417. slots
  15418. }) {
  15419. const rootRef = ref(null);
  15420. const context = {
  15421. rootRef,
  15422. getItemId() {
  15423. return props2.itemId;
  15424. },
  15425. getBoundingClientRect() {
  15426. const el = rootRef.value;
  15427. return el.getBoundingClientRect();
  15428. },
  15429. updatePosition(position, vertical) {
  15430. const x = vertical ? "0" : 100 * position + "%";
  15431. const y = vertical ? 100 * position + "%" : "0";
  15432. const rootEl = rootRef.value;
  15433. const value = `translate(${x},${y}) translateZ(0)`;
  15434. if (rootEl) {
  15435. rootEl.style.webkitTransform = value;
  15436. rootEl.style.transform = value;
  15437. }
  15438. }
  15439. };
  15440. onMounted(() => {
  15441. const addSwiperContext = inject("addSwiperContext");
  15442. if (addSwiperContext) {
  15443. addSwiperContext(context);
  15444. }
  15445. });
  15446. onUnmounted(() => {
  15447. const removeSwiperContext = inject("removeSwiperContext");
  15448. if (removeSwiperContext) {
  15449. removeSwiperContext(context);
  15450. }
  15451. });
  15452. onMounted(() => {
  15453. const rootElement = rootRef.value;
  15454. rootElement.attachVmProps(props2);
  15455. });
  15456. return () => {
  15457. return createVNode("uni-swiper-item", {
  15458. "ref": rootRef,
  15459. "style": {
  15460. position: "absolute",
  15461. width: "100%",
  15462. height: "100%"
  15463. }
  15464. }, [slots.default && slots.default()], 512);
  15465. };
  15466. }
  15467. });
  15468. const props$j = {
  15469. name: {
  15470. type: String,
  15471. default: ""
  15472. },
  15473. checked: {
  15474. type: [Boolean, String],
  15475. default: false
  15476. },
  15477. type: {
  15478. type: String,
  15479. default: "switch"
  15480. },
  15481. id: {
  15482. type: String,
  15483. default: ""
  15484. },
  15485. disabled: {
  15486. type: [Boolean, String],
  15487. default: false
  15488. },
  15489. color: {
  15490. type: String,
  15491. default: ""
  15492. },
  15493. backgroundColor: {
  15494. type: String,
  15495. default: "#e9e9ea"
  15496. },
  15497. activeBackgroundColor: {
  15498. type: String,
  15499. default: ""
  15500. },
  15501. foreColor: {
  15502. type: String,
  15503. default: ""
  15504. },
  15505. activeForeColor: {
  15506. type: String,
  15507. default: ""
  15508. }
  15509. };
  15510. class UniSwitchElement extends UniElement {
  15511. }
  15512. const indexX$1 = /* @__PURE__ */ defineBuiltInComponent({
  15513. name: "Switch",
  15514. props: props$j,
  15515. emits: ["change"],
  15516. rootElement: {
  15517. name: "uni-switch",
  15518. class: UniSwitchElement
  15519. },
  15520. setup(props2, {
  15521. emit: emit2
  15522. }) {
  15523. const rootRef = ref(null);
  15524. const switchChecked = ref(props2.checked);
  15525. const uniLabel = useSwitchInject(rootRef, props2, switchChecked);
  15526. const trigger = useCustomEvent(rootRef, emit2);
  15527. watch(() => props2.checked, (val) => {
  15528. switchChecked.value = val;
  15529. });
  15530. const _onClick = ($event) => {
  15531. if (props2.disabled) {
  15532. return;
  15533. }
  15534. switchChecked.value = !switchChecked.value;
  15535. trigger("change", $event, {
  15536. value: switchChecked.value
  15537. });
  15538. };
  15539. if (!!uniLabel) {
  15540. uniLabel.addHandler(_onClick);
  15541. onBeforeUnmount(() => {
  15542. uniLabel.removeHandler(_onClick);
  15543. });
  15544. }
  15545. useListeners(props2, {
  15546. "label-click": _onClick
  15547. });
  15548. let checkedCache = ref(switchChecked.value);
  15549. watch(() => switchChecked.value, (val) => {
  15550. checkedCache.value = val;
  15551. });
  15552. onMounted(() => {
  15553. const rootElement = rootRef.value;
  15554. Object.defineProperty(rootElement, "checked", {
  15555. get() {
  15556. return checkedCache.value;
  15557. },
  15558. set(val) {
  15559. checkedCache.value = val;
  15560. }
  15561. });
  15562. rootElement.attachVmProps(props2);
  15563. });
  15564. return () => {
  15565. const {
  15566. activeBackgroundColor,
  15567. activeForeColor,
  15568. backgroundColor,
  15569. color,
  15570. foreColor,
  15571. type
  15572. } = props2;
  15573. const booleanAttrs = useBooleanAttr(props2, "disabled");
  15574. const switchInputStyle = {};
  15575. const fixColor = activeBackgroundColor || color;
  15576. const bgColor = switchChecked.value ? fixColor : backgroundColor;
  15577. if (bgColor) {
  15578. switchInputStyle["backgroundColor"] = bgColor;
  15579. switchInputStyle["borderColor"] = bgColor;
  15580. }
  15581. const thumbStyle = {};
  15582. const fgColor = switchChecked.value ? activeForeColor : foreColor;
  15583. if (fgColor) {
  15584. thumbStyle["backgroundColor"] = fgColor;
  15585. }
  15586. let realCheckValue;
  15587. realCheckValue = checkedCache.value;
  15588. return createVNode("uni-switch", mergeProps({
  15589. "id": props2.id,
  15590. "ref": rootRef
  15591. }, booleanAttrs, {
  15592. "onClick": _onClick
  15593. }), [createVNode("div", {
  15594. "class": "uni-switch-wrapper"
  15595. }, [withDirectives(createVNode("div", {
  15596. "class": ["uni-switch-input", [switchChecked.value ? "uni-switch-input-checked" : ""]],
  15597. "style": switchInputStyle
  15598. }, [createVNode("div", {
  15599. "class": ["uni-switch-thumb", [switchChecked.value ? "uni-switch-thumb-checked" : ""]],
  15600. "style": thumbStyle
  15601. }, null, 6)], 6), [[vShow, type === "switch"]]), withDirectives(createVNode("div", {
  15602. "class": "uni-checkbox-input"
  15603. }, [realCheckValue ? createSvgIconVNode(ICON_PATH_SUCCESS_NO_CIRCLE, props2.color, 22) : ""], 512), [[vShow, type === "checkbox"]])])], 16, ["id", "onClick"]);
  15604. };
  15605. }
  15606. });
  15607. function useSwitchInject(rootRef, props2, switchChecked) {
  15608. const initialCheckedValue = props2.checked;
  15609. const uniForm = inject(uniFormKey, false);
  15610. const uniLabel = inject(uniLabelKey, false);
  15611. const formField = {
  15612. submit: () => {
  15613. const data = ["", null];
  15614. if (props2.name) {
  15615. data[0] = props2.name;
  15616. data[1] = rootRef.value.checked;
  15617. }
  15618. return data;
  15619. },
  15620. reset: () => {
  15621. switchChecked.value = initialCheckedValue;
  15622. }
  15623. };
  15624. if (!!uniForm) {
  15625. uniForm.addField(formField);
  15626. onUnmounted(() => {
  15627. uniForm.removeField(formField);
  15628. });
  15629. }
  15630. return uniLabel;
  15631. }
  15632. const SPACE_UNICODE = {
  15633. ensp: " ",
  15634. emsp: " ",
  15635. nbsp: " "
  15636. };
  15637. function normalizeText(text2, { space, decode: decode2 }) {
  15638. let result = "";
  15639. let isEscape = false;
  15640. for (let char of text2) {
  15641. if (space && SPACE_UNICODE[space] && char === " ") {
  15642. char = SPACE_UNICODE[space];
  15643. }
  15644. if (isEscape) {
  15645. if (char === "n") {
  15646. result += LINEFEED;
  15647. } else if (char === "\\") {
  15648. result += "\\";
  15649. } else {
  15650. result += "\\" + char;
  15651. }
  15652. isEscape = false;
  15653. } else {
  15654. if (char === "\\") {
  15655. isEscape = true;
  15656. } else {
  15657. result += char;
  15658. }
  15659. }
  15660. }
  15661. if (!decode2) {
  15662. return result;
  15663. }
  15664. 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, "'");
  15665. }
  15666. function parseText(text2, options) {
  15667. return normalizeText(text2, options).split(LINEFEED);
  15668. }
  15669. class UniTextElement extends UniElement {
  15670. }
  15671. const index$l = /* @__PURE__ */ defineBuiltInComponent({
  15672. name: "Text",
  15673. rootElement: {
  15674. name: "uni-text",
  15675. class: UniTextElement
  15676. },
  15677. props: {
  15678. selectable: {
  15679. type: [Boolean, String],
  15680. default: false
  15681. },
  15682. space: {
  15683. type: String,
  15684. default: ""
  15685. },
  15686. decode: {
  15687. type: [Boolean, String],
  15688. default: false
  15689. }
  15690. },
  15691. setup(props2, {
  15692. slots
  15693. }) {
  15694. const rootRef = ref(null);
  15695. onMounted(() => {
  15696. const rootElement = rootRef.value;
  15697. rootElement.attachVmProps(props2);
  15698. });
  15699. return () => {
  15700. const children = [];
  15701. if (slots.default) {
  15702. slots.default().forEach((vnode) => {
  15703. if (vnode.shapeFlag & 8 && vnode.type !== Comment) {
  15704. const lines = parseText(vnode.children, {
  15705. space: props2.space,
  15706. decode: props2.decode
  15707. });
  15708. const len = lines.length - 1;
  15709. lines.forEach((line, index2) => {
  15710. if (index2 === 0 && !line)
  15711. ;
  15712. else {
  15713. children.push(createTextVNode(line));
  15714. }
  15715. if (index2 !== len) {
  15716. children.push(createVNode("br"));
  15717. }
  15718. });
  15719. } else {
  15720. if (process.env.NODE_ENV !== "production" && vnode.shapeFlag & 6 && vnode.type.name !== "Text") {
  15721. console.warn("Do not nest other components in the text component, as there may be display differences on different platforms.");
  15722. }
  15723. children.push(vnode);
  15724. }
  15725. });
  15726. }
  15727. return createVNode("uni-text", {
  15728. "ref": rootRef,
  15729. "selectable": props2.selectable ? true : null
  15730. }, [createVNode("span", null, children)], 8, ["selectable"]);
  15731. };
  15732. }
  15733. });
  15734. const props$i = /* @__PURE__ */ extend({}, props$s, {
  15735. placeholderClass: {
  15736. type: String,
  15737. default: "input-placeholder"
  15738. },
  15739. autoHeight: {
  15740. type: [Boolean, String],
  15741. default: false
  15742. },
  15743. confirmType: {
  15744. type: String,
  15745. default: "return",
  15746. validator(val) {
  15747. return ConfirmTypes.concat("return").includes(val);
  15748. }
  15749. }
  15750. });
  15751. let fixMargin = false;
  15752. const ConfirmTypes = ["done", "go", "next", "search", "send"];
  15753. function setFixMargin() {
  15754. const DARK_TEST_STRING = "(prefers-color-scheme: dark)";
  15755. fixMargin = String(navigator.platform).indexOf("iP") === 0 && String(navigator.vendor).indexOf("Apple") === 0 && window.matchMedia(DARK_TEST_STRING).media !== DARK_TEST_STRING;
  15756. }
  15757. class UniTextareaElement extends UniElement {
  15758. focus(options) {
  15759. var _a;
  15760. (_a = this.querySelector("textarea")) == null ? void 0 : _a.focus(options);
  15761. }
  15762. }
  15763. const index$k = /* @__PURE__ */ defineBuiltInComponent({
  15764. name: "Textarea",
  15765. props: props$i,
  15766. emits: ["confirm", "linechange", ...emit],
  15767. rootElement: {
  15768. name: "uni-textarea",
  15769. class: UniTextareaElement
  15770. },
  15771. setup(props2, {
  15772. emit: emit2,
  15773. expose
  15774. }) {
  15775. const rootRef = ref(null);
  15776. const wrapperRef = ref(null);
  15777. const {
  15778. fieldRef,
  15779. state: state2,
  15780. scopedAttrsState,
  15781. fixDisabledColor,
  15782. trigger
  15783. } = useField(props2, rootRef, emit2);
  15784. const valueCompute = computed(() => state2.value.split(LINEFEED));
  15785. const isDone = computed(() => ConfirmTypes.includes(props2.confirmType));
  15786. const heightRef = ref(0);
  15787. const lineRef = ref(null);
  15788. watch(() => heightRef.value, (height) => {
  15789. const el = rootRef.value;
  15790. const lineEl = lineRef.value;
  15791. const wrapper = wrapperRef.value;
  15792. let lineHeight = parseFloat(getComputedStyle(el).lineHeight);
  15793. if (isNaN(lineHeight)) {
  15794. lineHeight = lineEl.offsetHeight;
  15795. }
  15796. var lineCount = Math.round(height / lineHeight);
  15797. trigger("linechange", {}, {
  15798. height,
  15799. heightRpx: 750 / window.innerWidth * height,
  15800. lineCount
  15801. });
  15802. if (props2.autoHeight) {
  15803. el.style.height = "auto";
  15804. wrapper.style.height = height + "px";
  15805. }
  15806. });
  15807. watch(() => props2.autoHeight, (autoHeight) => {
  15808. const el = rootRef.value;
  15809. const wrapper = wrapperRef.value;
  15810. if (autoHeight) {
  15811. el.style.height = "auto";
  15812. wrapper.style.height = heightRef.value + "px";
  15813. } else {
  15814. el.style.height = "";
  15815. wrapper.style.height = "";
  15816. }
  15817. });
  15818. function onResize2({
  15819. height
  15820. }) {
  15821. heightRef.value = height;
  15822. }
  15823. function confirm(event) {
  15824. trigger("confirm", event, {
  15825. value: state2.value
  15826. });
  15827. }
  15828. function onKeyDownEnter(event) {
  15829. if (event.key !== "Enter") {
  15830. return;
  15831. }
  15832. if (isDone.value) {
  15833. event.preventDefault();
  15834. }
  15835. }
  15836. function onKeyUpEnter(event) {
  15837. if (event.key !== "Enter") {
  15838. return;
  15839. }
  15840. if (isDone.value) {
  15841. confirm(event);
  15842. const textarea = event.target;
  15843. !props2.confirmHold && textarea.blur();
  15844. }
  15845. }
  15846. {
  15847. setFixMargin();
  15848. }
  15849. expose({
  15850. $triggerInput: (detail) => {
  15851. emit2("update:modelValue", detail.value);
  15852. emit2("update:value", detail.value);
  15853. state2.value = detail.value;
  15854. }
  15855. });
  15856. onMounted(() => {
  15857. const rootElement = rootRef.value;
  15858. Object.defineProperty(rootElement, "value", {
  15859. get() {
  15860. return state2.value;
  15861. },
  15862. set(value) {
  15863. rootElement.querySelector("textarea").value = value;
  15864. }
  15865. });
  15866. rootElement.attachVmProps(props2);
  15867. });
  15868. return () => {
  15869. let textareaNode = props2.disabled && fixDisabledColor ? createVNode("textarea", {
  15870. "key": "disabled-textarea",
  15871. "ref": fieldRef,
  15872. "value": state2.value,
  15873. "tabindex": "-1",
  15874. "readonly": !!props2.disabled,
  15875. "maxlength": state2.maxlength,
  15876. "class": {
  15877. "uni-textarea-textarea": true,
  15878. "uni-textarea-textarea-fix-margin": fixMargin
  15879. },
  15880. "style": {
  15881. overflowY: props2.autoHeight ? "hidden" : "auto",
  15882. /* eslint-disable no-restricted-syntax */
  15883. ...props2.cursorColor && {
  15884. caretColor: props2.cursorColor
  15885. }
  15886. },
  15887. "onFocus": (event) => event.target.blur()
  15888. }, null, 46, ["value", "readonly", "maxlength", "onFocus"]) : createVNode("textarea", {
  15889. "key": "textarea",
  15890. "ref": fieldRef,
  15891. "value": state2.value,
  15892. "disabled": !!props2.disabled,
  15893. "maxlength": state2.maxlength,
  15894. "enterkeyhint": props2.confirmType,
  15895. "inputmode": props2.inputmode,
  15896. "class": {
  15897. "uni-textarea-textarea": true,
  15898. "uni-textarea-textarea-fix-margin": fixMargin
  15899. },
  15900. "style": {
  15901. overflowY: props2.autoHeight ? "hidden" : "auto",
  15902. /* eslint-disable no-restricted-syntax */
  15903. ...props2.cursorColor && {
  15904. caretColor: props2.cursorColor
  15905. }
  15906. },
  15907. "onKeydown": onKeyDownEnter,
  15908. "onKeyup": onKeyUpEnter
  15909. }, null, 46, ["value", "disabled", "maxlength", "enterkeyhint", "inputmode", "onKeydown", "onKeyup"]);
  15910. return createVNode("uni-textarea", {
  15911. "ref": rootRef
  15912. }, [createVNode("div", {
  15913. "ref": wrapperRef,
  15914. "class": "uni-textarea-wrapper"
  15915. }, [withDirectives(createVNode("div", mergeProps(scopedAttrsState.attrs, {
  15916. "style": props2.placeholderStyle,
  15917. "class": ["uni-textarea-placeholder", props2.placeholderClass]
  15918. }), [props2.placeholder], 16), [[vShow, !state2.value.length]]), createVNode("div", {
  15919. "ref": lineRef,
  15920. "class": "uni-textarea-line"
  15921. }, [" "], 512), createVNode("div", {
  15922. "class": "uni-textarea-compute"
  15923. }, [valueCompute.value.map((item) => createVNode("div", null, [item.trim() ? item : "."])), createVNode(ResizeSensor, {
  15924. "initial": true,
  15925. "onResize": onResize2
  15926. }, null, 8, ["initial", "onResize"])]), props2.confirmType === "search" ? createVNode("form", {
  15927. "action": "",
  15928. "onSubmit": () => false,
  15929. "class": "uni-input-form"
  15930. }, [textareaNode], 40, ["onSubmit"]) : textareaNode], 512)], 512);
  15931. };
  15932. }
  15933. });
  15934. class UniViewElement extends UniElement {
  15935. }
  15936. const index$j = /* @__PURE__ */ defineBuiltInComponent({
  15937. name: "View",
  15938. props: /* @__PURE__ */ extend({}, hoverProps),
  15939. rootElement: {
  15940. name: "uni-view",
  15941. class: UniViewElement
  15942. },
  15943. setup(props2, {
  15944. slots
  15945. }) {
  15946. const rootRef = ref(null);
  15947. const {
  15948. hovering,
  15949. binding
  15950. } = useHover(props2);
  15951. onMounted(() => {
  15952. const rootElement = rootRef.value;
  15953. rootElement.attachVmProps(props2);
  15954. });
  15955. return () => {
  15956. const hoverClass = props2.hoverClass;
  15957. if (hoverClass && hoverClass !== "none") {
  15958. return createVNode("uni-view", mergeProps({
  15959. "class": hovering.value ? hoverClass : "",
  15960. "ref": rootRef
  15961. }, binding), [slots.default && slots.default()], 16);
  15962. }
  15963. return createVNode("uni-view", {
  15964. "ref": rootRef
  15965. }, [slots.default && slots.default()], 512);
  15966. };
  15967. }
  15968. });
  15969. function isHTMlElement(node) {
  15970. return !!(node && node.nodeType === 1);
  15971. }
  15972. function getChildren(root) {
  15973. const children = [];
  15974. if (root) {
  15975. walk(root, children);
  15976. }
  15977. return children;
  15978. }
  15979. const ChildType = ["ListItem", "StickySection", "StickyHeader"];
  15980. function walk(vnode, children) {
  15981. if (vnode.component && vnode.component.type && vnode.component.type.name && ChildType.includes(vnode.component.type.name)) {
  15982. children.push(vnode);
  15983. } else if (vnode.component) {
  15984. walk(vnode.component.subTree, children);
  15985. } else if (vnode.shapeFlag & 16) {
  15986. const vnodes = vnode.children;
  15987. for (let i = 0; i < vnodes.length; i++) {
  15988. walk(vnodes[i], children);
  15989. }
  15990. }
  15991. }
  15992. function traverseListView(visibleVNode, callback) {
  15993. const children = getChildren(visibleVNode);
  15994. for (let i = 0; i < children.length; i++) {
  15995. const child = children[i];
  15996. callback(child);
  15997. }
  15998. }
  15999. function traverseStickySection(stickySectionVNode, callback) {
  16000. const children = getChildren(stickySectionVNode.component.subTree);
  16001. for (let i = 0; i < children.length; i++) {
  16002. const child = children[i];
  16003. callback(child);
  16004. }
  16005. }
  16006. const props$h = {
  16007. direction: {
  16008. type: String,
  16009. default: "vertical",
  16010. validator: (val) => {
  16011. return ["none", "vertical", "horizontal"].includes(val);
  16012. }
  16013. },
  16014. showScrollbar: {
  16015. type: [Boolean, String],
  16016. default: true
  16017. },
  16018. upperThreshold: {
  16019. type: [Number, String],
  16020. default: 50
  16021. },
  16022. lowerThreshold: {
  16023. type: [Number, String],
  16024. default: 50
  16025. },
  16026. scrollTop: {
  16027. type: [Number, String],
  16028. default: 0
  16029. },
  16030. scrollLeft: {
  16031. type: [Number, String],
  16032. default: 0
  16033. },
  16034. // 暂不支持
  16035. // scrollIntoView: {
  16036. // type: String,
  16037. // default: '',
  16038. // },
  16039. scrollWithAnimation: {
  16040. type: [Boolean, String],
  16041. default: false
  16042. },
  16043. refresherEnabled: {
  16044. type: [Boolean, String],
  16045. default: false
  16046. },
  16047. refresherThreshold: {
  16048. type: Number,
  16049. default: 45
  16050. },
  16051. refresherDefaultStyle: {
  16052. type: String,
  16053. default: "black"
  16054. },
  16055. refresherBackground: {
  16056. type: String,
  16057. default: "transparent"
  16058. },
  16059. refresherTriggered: {
  16060. type: [Boolean, String],
  16061. default: false
  16062. }
  16063. };
  16064. class UniListViewElement extends UniElement {
  16065. }
  16066. const index$i = /* @__PURE__ */ defineBuiltInComponent({
  16067. name: "ListView",
  16068. props: props$h,
  16069. emits: [
  16070. "scroll",
  16071. "scrolltoupper",
  16072. "scrolltolower",
  16073. // 有触发时机,但是由于没有原生事件暂不支持
  16074. // 'scrollend',
  16075. "refresherrefresh",
  16076. "refresherrestore",
  16077. "refresherpulling",
  16078. "refresherabort",
  16079. "update:refresherTriggered"
  16080. ],
  16081. rootElement: {
  16082. name: "uni-list-view",
  16083. class: UniListViewElement
  16084. },
  16085. setup(props2, {
  16086. slots,
  16087. emit: emit2
  16088. }) {
  16089. const rootRef = ref(null);
  16090. const containerRef = ref(null);
  16091. const visibleRef = ref(null);
  16092. const {
  16093. isVertical,
  16094. state: state2
  16095. } = useListViewState(props2);
  16096. provide("__listViewIsVertical", isVertical);
  16097. provide("__listViewDefaultItemSize", state2.defaultItemSize);
  16098. const onItemChange = debounce(() => {
  16099. nextTick(() => {
  16100. _rearrange();
  16101. });
  16102. }, 10, {
  16103. clearTimeout,
  16104. setTimeout
  16105. });
  16106. provide("__listViewRegisterItem", (status) => {
  16107. onItemChange();
  16108. });
  16109. provide("__listViewUnregisterItem", (status) => {
  16110. onItemChange();
  16111. });
  16112. const trigger = useCustomEvent(rootRef, emit2);
  16113. handleTouchEvent(isVertical, containerRef, props2, state2, trigger, emit2);
  16114. function getOffset() {
  16115. return isVertical.value ? containerRef.value.scrollTop : containerRef.value.scrollLeft;
  16116. }
  16117. function resetContainerSize() {
  16118. const containerEl = containerRef.value;
  16119. state2.containerSize = isVertical.value ? containerEl.clientHeight : containerEl.clientWidth;
  16120. }
  16121. watch(isVertical, () => {
  16122. resetContainerSize();
  16123. });
  16124. const upperThresholdNumber = computed(() => {
  16125. const val = Number(props2.upperThreshold);
  16126. return isNaN(val) ? 50 : val;
  16127. });
  16128. const lowerThresholdNumber = computed(() => {
  16129. const val = Number(props2.lowerThreshold);
  16130. return isNaN(val) ? 50 : val;
  16131. });
  16132. const scrollTopNumber = computed(() => {
  16133. return Number(props2.scrollTop) || 0;
  16134. });
  16135. const scrollLeftNumber = computed(() => {
  16136. return Number(props2.scrollLeft) || 0;
  16137. });
  16138. watch(scrollTopNumber, (val) => {
  16139. if (containerRef.value) {
  16140. containerRef.value.scrollTop = val;
  16141. }
  16142. });
  16143. watch(scrollLeftNumber, (val) => {
  16144. if (containerRef.value) {
  16145. containerRef.value.scrollLeft = val;
  16146. }
  16147. });
  16148. onMounted(() => {
  16149. resetContainerSize();
  16150. let lastScrollOffset = 0;
  16151. containerRef.value.addEventListener("scroll", function($event) {
  16152. const target = $event.target;
  16153. trigger("scroll", $event, {
  16154. scrollLeft: target.scrollLeft,
  16155. scrollTop: target.scrollTop,
  16156. scrollHeight: target.scrollHeight,
  16157. scrollWidth: target.scrollWidth,
  16158. deltaX: isVertical.value ? 0 : lastScrollOffset - target.scrollLeft,
  16159. deltaY: isVertical.value ? lastScrollOffset - target.scrollTop : 0
  16160. });
  16161. const currentOffset = getOffset();
  16162. const upperOffset = upperThresholdNumber.value;
  16163. if (currentOffset <= upperOffset && lastScrollOffset > upperOffset) {
  16164. trigger("scrolltoupper", $event, {
  16165. direction: isVertical.value ? "top" : "left"
  16166. });
  16167. }
  16168. const realTotalSize = isVertical.value ? target.scrollHeight : target.scrollWidth;
  16169. const realRootSize = isVertical.value ? target.clientHeight : target.clientWidth;
  16170. const lowerOffset = realTotalSize - realRootSize - lowerThresholdNumber.value;
  16171. if (currentOffset >= lowerOffset && lastScrollOffset < lowerOffset) {
  16172. trigger("scrolltolower", $event, {
  16173. direction: isVertical.value ? "bottom" : "right"
  16174. });
  16175. }
  16176. lastScrollOffset = currentOffset;
  16177. if (_shouldRearrange()) {
  16178. _rearrange();
  16179. }
  16180. });
  16181. const rootElement = rootRef.value;
  16182. const containerElement = containerRef.value;
  16183. Object.defineProperties(rootElement, {
  16184. scrollHeight: {
  16185. get() {
  16186. return containerElement.scrollHeight;
  16187. }
  16188. },
  16189. scrollWidth: {
  16190. get() {
  16191. return containerElement.scrollWidth;
  16192. }
  16193. },
  16194. scrollLeft: {
  16195. get() {
  16196. return containerElement.scrollLeft;
  16197. },
  16198. set(val) {
  16199. containerElement.scrollLeft = val;
  16200. }
  16201. },
  16202. scrollTop: {
  16203. get() {
  16204. return containerElement.scrollTop;
  16205. },
  16206. set(val) {
  16207. containerElement.scrollTop = val;
  16208. }
  16209. },
  16210. scrollBy: {
  16211. get() {
  16212. return containerElement.scrollBy.bind(containerElement);
  16213. }
  16214. }
  16215. });
  16216. rootElement.attachVmProps(props2);
  16217. });
  16218. function forceRearrange() {
  16219. traverseAllItems(visibleVNode, (child) => {
  16220. const exposed = child.component.exposed;
  16221. if (exposed == null ? void 0 : exposed.__listViewChildStatus.seen.value) {
  16222. exposed.__listViewChildStatus.seen.value = false;
  16223. }
  16224. });
  16225. nextTick(() => {
  16226. nextTick(() => {
  16227. _rearrange();
  16228. });
  16229. });
  16230. }
  16231. function onResize2() {
  16232. resetContainerSize();
  16233. forceRearrange();
  16234. }
  16235. function traverseAllItems(visibleVNode2, callback) {
  16236. traverseListView(visibleVNode2, (child) => {
  16237. var _a;
  16238. const childType = (_a = child.component) == null ? void 0 : _a.type.name;
  16239. if (childType === "StickySection") {
  16240. traverseStickySection(child, function() {
  16241. var _a2;
  16242. const childType2 = (_a2 = child.component) == null ? void 0 : _a2.type.name;
  16243. if (childType2 === "ListItem") {
  16244. callback(child);
  16245. }
  16246. });
  16247. } else if (childType === "ListItem") {
  16248. callback(child);
  16249. } else if (childType === "StickyHeader")
  16250. ;
  16251. else if (child.component && child.component.subTree) {
  16252. traverseAllItems(child.component.subTree, callback);
  16253. }
  16254. });
  16255. }
  16256. function _rearrange() {
  16257. rearrange(visibleVNode, containerRef, isVertical, state2);
  16258. }
  16259. function _shouldRearrange() {
  16260. return shouldRearrange(containerRef, isVertical, state2);
  16261. }
  16262. const containerStyle = computed(() => {
  16263. return `${props2.direction === "none" ? "overflow: hidden;" : isVertical.value ? "overflow-y: auto;" : "overflow-x: auto;"}scroll-behavior: ${props2.scrollWithAnimation ? "smooth" : "auto"};`;
  16264. });
  16265. const contentStyle = computed(() => {
  16266. return `position: relative; ${isVertical.value ? "height" : "width"}: ${state2.totalSize}px;`;
  16267. });
  16268. const visibleStyle = computed(() => {
  16269. return `position: absolute; ${isVertical.value ? "width" : "height"}: 100%; ${isVertical.value ? "top" : "left"}: ${state2.placehoderSize}px;`;
  16270. });
  16271. let visibleVNode = null;
  16272. return () => {
  16273. const {
  16274. refresherEnabled,
  16275. refresherBackground,
  16276. refresherDefaultStyle,
  16277. refresherThreshold
  16278. } = props2;
  16279. const {
  16280. refresherHeight,
  16281. refreshState
  16282. } = state2;
  16283. const defaultSlot = slots.default && slots.default();
  16284. visibleVNode = createVNode("div", {
  16285. "ref": visibleRef,
  16286. "class": "uni-list-view-visible",
  16287. "style": visibleStyle.value
  16288. }, [defaultSlot], 4);
  16289. return createVNode("uni-list-view", {
  16290. "ref": rootRef,
  16291. "class": "uni-list-view"
  16292. }, [createVNode("div", {
  16293. "ref": containerRef,
  16294. "class": `uni-list-view-container ${props2.showScrollbar === false ? "uni-list-view-scrollbar-hidden" : ""}`,
  16295. "style": containerStyle.value
  16296. }, [refresherEnabled ? createVNode(Refresher, {
  16297. "refreshState": refreshState,
  16298. "refresherHeight": refresherHeight,
  16299. "refresherThreshold": refresherThreshold,
  16300. "refresherDefaultStyle": refresherDefaultStyle,
  16301. "refresherBackground": refresherBackground
  16302. }, {
  16303. default: () => [refresherDefaultStyle == "none" ? slots.refresher && slots.refresher() : null]
  16304. }, 8, ["refreshState", "refresherHeight", "refresherThreshold", "refresherDefaultStyle", "refresherBackground"]) : null, createVNode("div", {
  16305. "class": "uni-list-view-content",
  16306. "style": contentStyle.value
  16307. }, [visibleVNode], 4)], 4), createVNode(ResizeSensor, {
  16308. "onResize": onResize2
  16309. }, null, 8, ["onResize"])], 512);
  16310. };
  16311. }
  16312. });
  16313. function useListViewState(props2) {
  16314. const isVertical = computed(() => {
  16315. return props2.direction !== "horizontal";
  16316. });
  16317. const state2 = reactive({
  16318. defaultItemSize: 40,
  16319. totalSize: 0,
  16320. placehoderSize: 0,
  16321. visibleSize: 0,
  16322. containerSize: 0,
  16323. cacheScreenCount: 5,
  16324. loadScreenThreshold: 3,
  16325. refresherHeight: 0,
  16326. refreshState: ""
  16327. });
  16328. return {
  16329. state: state2,
  16330. isVertical
  16331. };
  16332. }
  16333. function shouldRearrange(containerRef, isVertical, state2) {
  16334. const offset = isVertical.value ? containerRef.value.scrollTop : containerRef.value.scrollLeft;
  16335. const loadScreenThresholdSize = state2.containerSize * state2.loadScreenThreshold;
  16336. const rearrangeOffsetMin = state2.placehoderSize + loadScreenThresholdSize;
  16337. const rearrangeOffsetMax = state2.placehoderSize + state2.visibleSize - loadScreenThresholdSize;
  16338. return offset < rearrangeOffsetMin && state2.placehoderSize > 0 || offset > rearrangeOffsetMax && state2.placehoderSize + state2.visibleSize < state2.totalSize;
  16339. }
  16340. function rearrange(visibleVNode, containerRef, isVertical, state2) {
  16341. if (!visibleVNode) {
  16342. return;
  16343. }
  16344. const containerEl = containerRef.value;
  16345. if (!containerEl) {
  16346. return;
  16347. }
  16348. const offset = isVertical.value ? containerEl.scrollTop : containerEl.scrollLeft;
  16349. const offsetMin = Math.max(offset - state2.containerSize * state2.cacheScreenCount, 0);
  16350. const offsetMax = Math.max(offset + state2.containerSize * (state2.cacheScreenCount + 1), offsetMin + 1);
  16351. let tempTotalSize = 0;
  16352. let tempVisibleSize = 0;
  16353. let tempPlaceholderSize = 0;
  16354. let start = false, end = false;
  16355. function callback(child) {
  16356. var _a, _b, _c;
  16357. const childType = (_a = child.component) == null ? void 0 : _a.type.name;
  16358. const status = (_c = (_b = child.component) == null ? void 0 : _b.exposed) == null ? void 0 : _c.__listViewChildStatus;
  16359. if (childType === "StickySection") {
  16360. const {
  16361. headSize,
  16362. tailSize
  16363. } = status;
  16364. tempTotalSize += headSize.value;
  16365. traverseStickySection(child, callback);
  16366. tempTotalSize += tailSize.value;
  16367. } else if (childType === "ListItem") {
  16368. const {
  16369. cachedSize
  16370. } = status;
  16371. const itemSize = cachedSize;
  16372. tempTotalSize += itemSize;
  16373. if (!start && tempTotalSize > offsetMin) {
  16374. start = true;
  16375. }
  16376. if (!start) {
  16377. tempPlaceholderSize += itemSize;
  16378. }
  16379. if (start && !end) {
  16380. tempVisibleSize += itemSize;
  16381. status.visible.value = true;
  16382. } else {
  16383. status.visible.value = false;
  16384. }
  16385. if (!end && tempTotalSize >= offsetMax) {
  16386. end = true;
  16387. }
  16388. } else if (childType === "StickyHeader") {
  16389. const {
  16390. cachedSize
  16391. } = status;
  16392. tempTotalSize += cachedSize;
  16393. tempVisibleSize += cachedSize;
  16394. }
  16395. }
  16396. traverseListView(visibleVNode, callback);
  16397. state2.totalSize = tempTotalSize;
  16398. state2.visibleSize = tempVisibleSize;
  16399. state2.placehoderSize = tempPlaceholderSize;
  16400. }
  16401. function handleTouchEvent(isVertical, containerRef, props2, state2, trigger, emit2) {
  16402. let beforeRefreshing = false;
  16403. let triggerAbort = false;
  16404. let toUpperNumber = 0;
  16405. let touchStart = {
  16406. x: 0,
  16407. y: 0
  16408. };
  16409. let touchEnd = {
  16410. x: 0,
  16411. y: props2.refresherThreshold
  16412. };
  16413. function _setRefreshState(_state) {
  16414. if (!props2.refresherEnabled)
  16415. return;
  16416. switch (_state) {
  16417. case "refreshing":
  16418. state2.refresherHeight = props2.refresherThreshold;
  16419. if (!beforeRefreshing) {
  16420. beforeRefreshing = true;
  16421. trigger("refresherpulling", {}, {
  16422. deltaY: state2.refresherHeight,
  16423. dy: state2.refresherHeight
  16424. });
  16425. trigger("refresherrefresh", {}, {
  16426. dy: touchEnd.y - touchStart.y
  16427. });
  16428. emit2("update:refresherTriggered", true);
  16429. }
  16430. break;
  16431. case "restore":
  16432. case "refresherabort":
  16433. beforeRefreshing = false;
  16434. state2.refresherHeight = toUpperNumber = 0;
  16435. if (_state === "restore") {
  16436. triggerAbort = false;
  16437. trigger("refresherrestore", {}, {
  16438. dy: touchEnd.y - touchStart.y
  16439. });
  16440. }
  16441. if (_state === "refresherabort" && triggerAbort) {
  16442. triggerAbort = false;
  16443. trigger("refresherabort", {}, {
  16444. dy: touchEnd.y - touchStart.y
  16445. });
  16446. }
  16447. break;
  16448. }
  16449. state2.refreshState = _state;
  16450. }
  16451. watch(() => props2.refresherTriggered, (val) => {
  16452. if (val === true) {
  16453. _setRefreshState("refreshing");
  16454. } else if (val === false) {
  16455. _setRefreshState("restore");
  16456. }
  16457. });
  16458. function __handleTouchStart(event) {
  16459. if (event.touches.length === 1) {
  16460. touchStart = {
  16461. x: event.touches[0].pageX,
  16462. y: event.touches[0].pageY
  16463. };
  16464. }
  16465. }
  16466. function __handleTouchMove(event) {
  16467. const containerEl = containerRef.value;
  16468. if (touchStart === null)
  16469. return;
  16470. let x = event.touches[0].pageX;
  16471. let y = event.touches[0].pageY;
  16472. if (!isVertical.value) {
  16473. return;
  16474. }
  16475. let needStop = false;
  16476. if (Math.abs(touchStart.y - y) < Math.abs(touchStart.x - x)) {
  16477. needStop = false;
  16478. } else if (containerEl.scrollTop === 0 && y > touchStart.y) {
  16479. needStop = false;
  16480. if (props2.refresherEnabled && event.cancelable !== false)
  16481. event.preventDefault();
  16482. } else if (containerEl.scrollHeight === containerEl.offsetHeight + containerEl.scrollTop && y < touchStart.y) {
  16483. needStop = false;
  16484. return;
  16485. } else {
  16486. needStop = true;
  16487. }
  16488. if (needStop) {
  16489. event.stopPropagation();
  16490. }
  16491. if (!props2.refresherEnabled) {
  16492. return;
  16493. }
  16494. if (containerEl.scrollTop === 0 && event.touches.length === 1) {
  16495. _setRefreshState("pulling");
  16496. }
  16497. if (props2.refresherEnabled && state2.refreshState === "pulling") {
  16498. const dy = y - touchStart.y;
  16499. if (toUpperNumber === 0) {
  16500. toUpperNumber = y;
  16501. }
  16502. if (!beforeRefreshing) {
  16503. state2.refresherHeight = y - toUpperNumber;
  16504. if (state2.refresherHeight > 0) {
  16505. triggerAbort = true;
  16506. trigger("refresherpulling", event, {
  16507. deltaY: dy,
  16508. dy
  16509. });
  16510. }
  16511. } else {
  16512. state2.refresherHeight = dy + props2.refresherThreshold;
  16513. triggerAbort = false;
  16514. }
  16515. }
  16516. }
  16517. function __handleTouchEnd(event) {
  16518. touchEnd = {
  16519. x: event.changedTouches[0].pageX,
  16520. y: event.changedTouches[0].pageY
  16521. };
  16522. if (state2.refresherHeight >= props2.refresherThreshold) {
  16523. _setRefreshState("refreshing");
  16524. } else {
  16525. _setRefreshState("refresherabort");
  16526. }
  16527. touchStart = {
  16528. x: 0,
  16529. y: 0
  16530. };
  16531. touchEnd = {
  16532. x: 0,
  16533. y: props2.refresherThreshold
  16534. };
  16535. }
  16536. onMounted(() => {
  16537. const containerEl = containerRef.value;
  16538. containerEl.addEventListener("touchstart", __handleTouchStart);
  16539. containerEl.addEventListener("touchmove", __handleTouchMove, {
  16540. passive: false
  16541. });
  16542. containerEl.addEventListener("touchend", __handleTouchEnd);
  16543. });
  16544. onBeforeUnmount(() => {
  16545. const containerEl = containerRef.value;
  16546. containerEl.removeEventListener("touchstart", __handleTouchStart);
  16547. containerEl.removeEventListener("touchmove", __handleTouchMove);
  16548. containerEl.removeEventListener("touchend", __handleTouchEnd);
  16549. });
  16550. }
  16551. function getSize(isVertical, el) {
  16552. var style = window.getComputedStyle(el);
  16553. if (isVertical) {
  16554. return parseFloat(style.marginTop) + el.getBoundingClientRect().height + parseFloat(style.marginBottom);
  16555. } else {
  16556. return parseFloat(style.marginLeft) + el.getBoundingClientRect().width + parseFloat(style.marginRight);
  16557. }
  16558. }
  16559. class UniListItemElement extends UniElement {
  16560. }
  16561. const index$h = /* @__PURE__ */ defineBuiltInComponent({
  16562. name: "ListItem",
  16563. props: {},
  16564. rootElement: {
  16565. name: "uni-list-item",
  16566. class: UniListItemElement
  16567. },
  16568. setup(props2, {
  16569. slots,
  16570. expose
  16571. }) {
  16572. const rootRef = ref(null);
  16573. const isVertical = inject("__listViewIsVertical");
  16574. const visible = ref(false);
  16575. const seen = ref(false);
  16576. const status = {
  16577. type: "ListItem",
  16578. visible,
  16579. cachedSize: 0,
  16580. seen
  16581. };
  16582. expose({
  16583. __listViewChildStatus: status
  16584. });
  16585. const registerItem = inject("__listViewRegisterItem");
  16586. const unregisterItem = inject("__listViewUnregisterItem");
  16587. onMounted(() => {
  16588. registerItem(status);
  16589. });
  16590. onBeforeUnmount(() => {
  16591. unregisterItem(status);
  16592. });
  16593. const realVisible = computed(() => {
  16594. return visible.value || !status.seen.value;
  16595. });
  16596. return () => {
  16597. nextTick(() => {
  16598. const rootNode = rootRef.value;
  16599. if (realVisible.value && isHTMlElement(rootNode)) {
  16600. status.cachedSize = getSize(isVertical.value, rootNode);
  16601. seen.value = true;
  16602. }
  16603. });
  16604. if (!realVisible.value) {
  16605. return null;
  16606. }
  16607. return createVNode("uni-list-item", {
  16608. "ref": rootRef
  16609. }, [slots.default && slots.default()], 512);
  16610. };
  16611. }
  16612. });
  16613. class UniStickySectionElement extends UniElement {
  16614. }
  16615. const index$g = /* @__PURE__ */ defineBuiltInComponent({
  16616. name: "StickySection",
  16617. props: {
  16618. padding: {
  16619. type: Array,
  16620. default: [0, 0, 0, 0]
  16621. }
  16622. },
  16623. rootElement: {
  16624. name: "uni-sticky-section",
  16625. class: UniStickySectionElement
  16626. },
  16627. setup(props2, {
  16628. slots,
  16629. expose
  16630. }) {
  16631. const rootRef = ref(null);
  16632. const isVertical = inject("__listViewIsVertical");
  16633. const style = computed(() => {
  16634. return {
  16635. paddingTop: props2.padding[0] + "px",
  16636. paddingRight: props2.padding[1] + "px",
  16637. paddingBottom: props2.padding[2] + "px",
  16638. paddingLeft: props2.padding[3] + "px"
  16639. };
  16640. });
  16641. const headSize = computed(() => {
  16642. return isVertical ? props2.padding[0] : props2.padding[3];
  16643. });
  16644. const tailSize = computed(() => {
  16645. return isVertical ? props2.padding[2] : props2.padding[1];
  16646. });
  16647. const status = {
  16648. type: "StickySection",
  16649. headSize,
  16650. tailSize
  16651. };
  16652. expose({
  16653. __listViewChildStatus: status
  16654. });
  16655. onMounted(() => {
  16656. const rootElement = rootRef.value;
  16657. rootElement.attachVmProps(props2);
  16658. });
  16659. return () => {
  16660. var _a;
  16661. return createVNode("uni-sticky-section", {
  16662. "ref": rootRef,
  16663. "style": style.value
  16664. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)], 4);
  16665. };
  16666. }
  16667. });
  16668. class UniStickyHeaderElement extends UniElement {
  16669. }
  16670. const index$f = /* @__PURE__ */ defineBuiltInComponent({
  16671. name: "StickyHeader",
  16672. props: {
  16673. padding: {
  16674. type: Array,
  16675. default: [0, 0, 0, 0]
  16676. }
  16677. },
  16678. rootElement: {
  16679. name: "uni-sticky-header",
  16680. class: UniStickyHeaderElement
  16681. },
  16682. setup(props2, {
  16683. slots,
  16684. expose
  16685. }) {
  16686. const rootRef = ref(null);
  16687. const isVertical = inject("__listViewIsVertical");
  16688. const style = computed(() => {
  16689. return {
  16690. paddingTop: props2.padding[0] + "px",
  16691. paddingRight: props2.padding[1] + "px",
  16692. paddingBottom: props2.padding[2] + "px",
  16693. paddingLeft: props2.padding[3] + "px",
  16694. top: 0 - props2.padding[0] + "px"
  16695. };
  16696. });
  16697. const status = {
  16698. type: "StickyHeader",
  16699. cachedSize: 0
  16700. };
  16701. expose({
  16702. __listViewChildStatus: status
  16703. });
  16704. onMounted(() => {
  16705. const rootElement = rootRef.value;
  16706. rootElement.attachVmProps(props2);
  16707. });
  16708. return () => {
  16709. var _a;
  16710. nextTick(() => {
  16711. const rootEl = rootRef.value;
  16712. const rect = rootEl.getBoundingClientRect();
  16713. status.cachedSize = isVertical ? rect.height : rect.width;
  16714. });
  16715. return createVNode("uni-sticky-header", {
  16716. "ref": rootRef,
  16717. "style": style.value
  16718. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)], 4);
  16719. };
  16720. }
  16721. });
  16722. function normalizeEvent(vm, id2) {
  16723. if (!id2) {
  16724. id2 = vm.id;
  16725. }
  16726. if (!id2) {
  16727. return;
  16728. }
  16729. return vm.$options.name.toLowerCase() + "." + id2;
  16730. }
  16731. function addSubscribe(name, callback, pageId) {
  16732. if (!name) {
  16733. return;
  16734. }
  16735. registerViewMethod(
  16736. pageId || getCurrentPageId(),
  16737. name,
  16738. ({ type, data }, resolve) => {
  16739. callback(type, data, resolve);
  16740. }
  16741. );
  16742. }
  16743. function removeSubscribe(name, pageId) {
  16744. if (!name) {
  16745. return;
  16746. }
  16747. unregisterViewMethod(pageId || getCurrentPageId(), name);
  16748. }
  16749. function useSubscribe(callback, name, multiple, pageId) {
  16750. const instance2 = getCurrentInstance();
  16751. const vm = instance2.proxy;
  16752. onMounted(() => {
  16753. addSubscribe(name || normalizeEvent(vm), callback, pageId);
  16754. if (multiple || !name) {
  16755. watch(
  16756. () => vm.id,
  16757. (value, oldValue) => {
  16758. addSubscribe(normalizeEvent(vm, value), callback, pageId);
  16759. removeSubscribe(oldValue && normalizeEvent(vm, oldValue));
  16760. }
  16761. );
  16762. }
  16763. });
  16764. onBeforeUnmount(() => {
  16765. removeSubscribe(name || normalizeEvent(vm), pageId);
  16766. });
  16767. }
  16768. function useOn(name, callback) {
  16769. onMounted(() => UniViewJSBridge.on(name, callback));
  16770. onBeforeUnmount(() => UniViewJSBridge.off(name));
  16771. }
  16772. let index$e = 0;
  16773. function useContextInfo(_id) {
  16774. const page = useCurrentPageId();
  16775. const instance2 = getCurrentInstance();
  16776. const vm = instance2.proxy;
  16777. const type = vm.$options.name.toLowerCase();
  16778. const id2 = _id || vm.id || `context${index$e++}`;
  16779. onMounted(() => {
  16780. const el = vm.$el;
  16781. el.__uniContextInfo = {
  16782. id: id2,
  16783. type,
  16784. page
  16785. };
  16786. });
  16787. return `${type}.${id2}`;
  16788. }
  16789. function getContextInfo(el) {
  16790. return el.__uniContextInfo;
  16791. }
  16792. function injectLifecycleHook(name, hook, publicThis, instance2) {
  16793. if (isFunction(hook)) {
  16794. injectHook(name, hook.bind(publicThis), instance2);
  16795. }
  16796. }
  16797. function initHooks(options, instance2, publicThis) {
  16798. var _b;
  16799. const mpType = options.mpType || publicThis.$mpType;
  16800. if (!mpType || mpType === "component") {
  16801. return;
  16802. }
  16803. Object.keys(options).forEach((name) => {
  16804. if (isUniLifecycleHook(name, options[name], false)) {
  16805. const hooks = options[name];
  16806. if (isArray(hooks)) {
  16807. hooks.forEach(
  16808. (hook) => injectLifecycleHook(name, hook, publicThis, instance2)
  16809. );
  16810. } else {
  16811. injectLifecycleHook(name, hooks, publicThis, instance2);
  16812. }
  16813. }
  16814. });
  16815. if (mpType === "page") {
  16816. instance2.__isVisible = true;
  16817. try {
  16818. let query = instance2.attrs.__pageQuery;
  16819. if (true) {
  16820. query = decodedQuery(query);
  16821. }
  16822. if (false)
  16823. ;
  16824. invokeHook(publicThis, ON_LOAD, query);
  16825. delete instance2.attrs.__pageQuery;
  16826. if (true) {
  16827. if (((_b = publicThis.$page) == null ? void 0 : _b.openType) !== "preloadPage") {
  16828. invokeHook(publicThis, ON_SHOW);
  16829. }
  16830. }
  16831. } catch (e2) {
  16832. console.error(e2.message + LINEFEED + e2.stack);
  16833. }
  16834. }
  16835. }
  16836. function applyOptions(options, instance2, publicThis) {
  16837. initHooks(options, instance2, publicThis);
  16838. }
  16839. function set(target, key, val) {
  16840. return target[key] = val;
  16841. }
  16842. function $callMethod(method, ...args) {
  16843. const fn = this[method];
  16844. if (fn) {
  16845. return fn(...args);
  16846. }
  16847. console.error(`method ${method} not found`);
  16848. return null;
  16849. }
  16850. function createErrorHandler(app) {
  16851. return function errorHandler(err, instance2, _info) {
  16852. if (!instance2) {
  16853. throw err;
  16854. }
  16855. const appInstance = app._instance;
  16856. if (!appInstance || !appInstance.proxy) {
  16857. throw err;
  16858. }
  16859. {
  16860. invokeHook(appInstance.proxy, ON_ERROR, err);
  16861. }
  16862. };
  16863. }
  16864. function mergeAsArray(to, from) {
  16865. return to ? [...new Set([].concat(to, from))] : from;
  16866. }
  16867. function initOptionMergeStrategies(optionMergeStrategies) {
  16868. UniLifecycleHooks.forEach((name) => {
  16869. optionMergeStrategies[name] = mergeAsArray;
  16870. });
  16871. }
  16872. let realAtob;
  16873. const b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  16874. const b64re = /^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;
  16875. if (typeof atob !== "function") {
  16876. realAtob = function(str) {
  16877. str = String(str).replace(/[\t\n\f\r ]+/g, "");
  16878. if (!b64re.test(str)) {
  16879. throw new Error(
  16880. "Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded."
  16881. );
  16882. }
  16883. str += "==".slice(2 - (str.length & 3));
  16884. var bitmap;
  16885. var result = "";
  16886. var r1;
  16887. var r2;
  16888. var i = 0;
  16889. for (; i < str.length; ) {
  16890. 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++)));
  16891. result += r1 === 64 ? String.fromCharCode(bitmap >> 16 & 255) : r2 === 64 ? String.fromCharCode(bitmap >> 16 & 255, bitmap >> 8 & 255) : String.fromCharCode(
  16892. bitmap >> 16 & 255,
  16893. bitmap >> 8 & 255,
  16894. bitmap & 255
  16895. );
  16896. }
  16897. return result;
  16898. };
  16899. } else {
  16900. realAtob = atob;
  16901. }
  16902. function b64DecodeUnicode(str) {
  16903. return decodeURIComponent(
  16904. realAtob(str).split("").map(function(c) {
  16905. return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
  16906. }).join("")
  16907. );
  16908. }
  16909. function getCurrentUserInfo() {
  16910. const token = uni.getStorageSync("uni_id_token") || "";
  16911. const tokenArr = token.split(".");
  16912. if (!token || tokenArr.length !== 3) {
  16913. return {
  16914. uid: null,
  16915. role: [],
  16916. permission: [],
  16917. tokenExpired: 0
  16918. };
  16919. }
  16920. let userInfo;
  16921. try {
  16922. userInfo = JSON.parse(b64DecodeUnicode(tokenArr[1]));
  16923. } catch (error) {
  16924. throw new Error("获取当前用户信息出错,详细错误信息为:" + error.message);
  16925. }
  16926. userInfo.tokenExpired = userInfo.exp * 1e3;
  16927. delete userInfo.exp;
  16928. delete userInfo.iat;
  16929. return userInfo;
  16930. }
  16931. function uniIdMixin(globalProperties) {
  16932. globalProperties.uniIDHasRole = function(roleId) {
  16933. const { role } = getCurrentUserInfo();
  16934. return role.indexOf(roleId) > -1;
  16935. };
  16936. globalProperties.uniIDHasPermission = function(permissionId) {
  16937. const { permission } = getCurrentUserInfo();
  16938. return this.uniIDHasRole("admin") || permission.indexOf(permissionId) > -1;
  16939. };
  16940. globalProperties.uniIDTokenValid = function() {
  16941. const { tokenExpired } = getCurrentUserInfo();
  16942. return tokenExpired > Date.now();
  16943. };
  16944. }
  16945. function initApp$1(app) {
  16946. const appConfig = app._context.config;
  16947. appConfig.errorHandler = invokeCreateErrorHandler(app, createErrorHandler);
  16948. initOptionMergeStrategies(appConfig.optionMergeStrategies);
  16949. const globalProperties = appConfig.globalProperties;
  16950. {
  16951. if (__UNI_FEATURE_UNI_CLOUD__) {
  16952. uniIdMixin(globalProperties);
  16953. }
  16954. }
  16955. {
  16956. globalProperties.$set = set;
  16957. globalProperties.$applyOptions = applyOptions;
  16958. globalProperties.$callMethod = $callMethod;
  16959. }
  16960. {
  16961. invokeCreateVueAppHook(app);
  16962. }
  16963. }
  16964. const pageMetaKey = PolySymbol(process.env.NODE_ENV !== "production" ? "UniPageMeta" : "upm");
  16965. function usePageMeta() {
  16966. return inject(pageMetaKey);
  16967. }
  16968. function providePageMeta(id2) {
  16969. const pageMeta = initPageMeta(id2);
  16970. provide(pageMetaKey, pageMeta);
  16971. return pageMeta;
  16972. }
  16973. function usePageRoute() {
  16974. if (__UNI_FEATURE_PAGES__) {
  16975. return useRoute();
  16976. }
  16977. const url = location.href;
  16978. const searchPos = url.indexOf("?");
  16979. const hashPos = url.indexOf("#", searchPos > -1 ? searchPos : 0);
  16980. let query = {};
  16981. if (searchPos > -1) {
  16982. query = parseQuery(
  16983. url.slice(searchPos + 1, hashPos > -1 ? hashPos : url.length)
  16984. );
  16985. }
  16986. const { meta } = __uniRoutes[0];
  16987. const path = addLeadingSlash(meta.route);
  16988. return {
  16989. meta,
  16990. query,
  16991. path,
  16992. matched: [{ path }]
  16993. };
  16994. }
  16995. function initPageMeta(id2) {
  16996. if (__UNI_FEATURE_PAGES__) {
  16997. return reactive(
  16998. normalizePageMeta(
  16999. JSON.parse(
  17000. JSON.stringify(
  17001. initRouteMeta(
  17002. useRoute().meta,
  17003. id2
  17004. )
  17005. )
  17006. )
  17007. )
  17008. );
  17009. }
  17010. return reactive(
  17011. normalizePageMeta(
  17012. JSON.parse(JSON.stringify(initRouteMeta(__uniRoutes[0].meta, id2)))
  17013. )
  17014. );
  17015. }
  17016. function normalizePageMeta(pageMeta) {
  17017. if (__UNI_FEATURE_PULL_DOWN_REFRESH__) {
  17018. const { enablePullDownRefresh, navigationBar } = pageMeta;
  17019. {
  17020. const pullToRefresh = normalizePullToRefreshRpx(
  17021. extend(
  17022. {
  17023. support: true,
  17024. color: "#2BD009",
  17025. style: "circle",
  17026. height: 70,
  17027. range: 150,
  17028. offset: 0
  17029. },
  17030. pageMeta.pullToRefresh
  17031. )
  17032. );
  17033. const { type, style } = navigationBar;
  17034. if (style !== "custom" && type !== "transparent") {
  17035. pullToRefresh.offset += NAVBAR_HEIGHT + safeAreaInsets$1.top;
  17036. }
  17037. pageMeta.pullToRefresh = pullToRefresh;
  17038. }
  17039. }
  17040. if (__UNI_FEATURE_NAVIGATIONBAR__) {
  17041. const { navigationBar } = pageMeta;
  17042. const { titleSize, titleColor, backgroundColor } = navigationBar;
  17043. navigationBar.titleText = navigationBar.titleText || "";
  17044. navigationBar.type = navigationBar.type || "default";
  17045. navigationBar.titleSize = titleSize || "16px";
  17046. navigationBar.titleColor = titleColor || "#000000";
  17047. navigationBar.backgroundColor = backgroundColor || "#F8F8F8";
  17048. __UNI_FEATURE_I18N_LOCALE__ && initNavigationBarI18n(navigationBar);
  17049. }
  17050. if (__UNI_FEATURE_PAGES__ && history.state) {
  17051. const type = history.state.__type__;
  17052. if ((type === "redirectTo" || type === "reLaunch") && getCurrentPages().length === 0) {
  17053. pageMeta.isEntry = true;
  17054. pageMeta.isQuit = true;
  17055. }
  17056. }
  17057. return pageMeta;
  17058. }
  17059. const screen$1 = window.screen;
  17060. const documentElement = document.documentElement;
  17061. function checkMinWidth(minWidth) {
  17062. const sizes = [
  17063. window.outerWidth,
  17064. window.outerHeight,
  17065. screen$1.width,
  17066. screen$1.height,
  17067. documentElement.clientWidth,
  17068. documentElement.clientHeight
  17069. ];
  17070. return Math.max.apply(null, sizes) > minWidth;
  17071. }
  17072. function getStateId() {
  17073. return history.state && history.state.__id__ || 1;
  17074. }
  17075. function removeNonTabBarPages() {
  17076. const curTabBarPageVm = getCurrentPageVm();
  17077. if (!curTabBarPageVm) {
  17078. return;
  17079. }
  17080. const pagesMap = getCurrentPagesMap();
  17081. const keys = pagesMap.keys();
  17082. for (const routeKey of keys) {
  17083. const page = pagesMap.get(routeKey);
  17084. if (!page.$.__isTabBar) {
  17085. removePage(routeKey);
  17086. } else {
  17087. page.$.__isActive = false;
  17088. }
  17089. }
  17090. if (curTabBarPageVm.$.__isTabBar) {
  17091. curTabBarPageVm.$.__isVisible = false;
  17092. invokeHook(curTabBarPageVm, ON_HIDE);
  17093. }
  17094. }
  17095. function isSamePage(url, $page) {
  17096. return url === $page.fullPath || url === "/" && $page.meta.isEntry;
  17097. }
  17098. function getTabBarPageId(url) {
  17099. const pages = getCurrentPagesMap().values();
  17100. for (const page of pages) {
  17101. const $page = page.$page;
  17102. if (isSamePage(url, $page)) {
  17103. page.$.__isActive = true;
  17104. return $page.id;
  17105. }
  17106. }
  17107. }
  17108. const switchTab = /* @__PURE__ */ defineAsyncApi(
  17109. API_SWITCH_TAB,
  17110. // @ts-expect-error
  17111. ({ url, tabBarText, isAutomatedTesting }, { resolve, reject }) => {
  17112. if (!entryPageState.handledBeforeEntryPageRoutes) {
  17113. switchTabPagesBeforeEntryPages.push({
  17114. args: { type: API_SWITCH_TAB, url, tabBarText, isAutomatedTesting },
  17115. resolve,
  17116. reject
  17117. });
  17118. return;
  17119. }
  17120. return removeNonTabBarPages(), navigate(
  17121. { type: API_SWITCH_TAB, url, tabBarText, isAutomatedTesting },
  17122. getTabBarPageId(url)
  17123. ).then(resolve).catch(reject);
  17124. },
  17125. SwitchTabProtocol,
  17126. SwitchTabOptions
  17127. );
  17128. function removeLastPage() {
  17129. const page = getCurrentPage();
  17130. if (!page) {
  17131. return;
  17132. }
  17133. const $page = page.$page;
  17134. removePage(normalizeRouteKey($page.path, $page.id));
  17135. }
  17136. const redirectTo = /* @__PURE__ */ defineAsyncApi(
  17137. API_REDIRECT_TO,
  17138. // @ts-expect-error
  17139. ({ url, isAutomatedTesting }, { resolve, reject }) => {
  17140. if (!entryPageState.handledBeforeEntryPageRoutes) {
  17141. redirectToPagesBeforeEntryPages.push({
  17142. args: { type: API_REDIRECT_TO, url, isAutomatedTesting },
  17143. resolve,
  17144. reject
  17145. });
  17146. return;
  17147. }
  17148. return (
  17149. // TODO exists 属性未实现
  17150. removeLastPage(), navigate({ type: API_REDIRECT_TO, url, isAutomatedTesting }).then(resolve).catch(reject)
  17151. );
  17152. },
  17153. RedirectToProtocol,
  17154. RedirectToOptions
  17155. );
  17156. function removeAllPages() {
  17157. const keys = getCurrentPagesMap().keys();
  17158. for (const routeKey of keys) {
  17159. removePage(routeKey);
  17160. }
  17161. }
  17162. const reLaunch = /* @__PURE__ */ defineAsyncApi(
  17163. API_RE_LAUNCH,
  17164. // @ts-expect-error
  17165. ({ url, isAutomatedTesting }, { resolve, reject }) => {
  17166. if (!entryPageState.handledBeforeEntryPageRoutes) {
  17167. reLaunchPagesBeforeEntryPages.push({
  17168. args: { type: API_RE_LAUNCH, url, isAutomatedTesting },
  17169. resolve,
  17170. reject
  17171. });
  17172. return;
  17173. }
  17174. return removeAllPages(), navigate({ type: API_RE_LAUNCH, url, isAutomatedTesting }).then(resolve).catch(reject);
  17175. },
  17176. ReLaunchProtocol,
  17177. ReLaunchOptions
  17178. );
  17179. function navigate({ type, url, tabBarText, events, isAutomatedTesting }, __id__) {
  17180. const router = getApp().$router;
  17181. const { path, query } = parseUrl(url);
  17182. return new Promise((resolve, reject) => {
  17183. const state2 = createPageState(type, __id__);
  17184. router[type === "navigateTo" ? "push" : "replace"]({
  17185. path,
  17186. query,
  17187. state: state2,
  17188. force: true
  17189. }).then((failure) => {
  17190. if (isNavigationFailure(failure)) {
  17191. return reject(failure.message);
  17192. }
  17193. if (type === "switchTab") {
  17194. router.currentRoute.value.meta.tabBarText = tabBarText;
  17195. }
  17196. if (type === "navigateTo") {
  17197. const meta = router.currentRoute.value.meta;
  17198. if (!meta.eventChannel) {
  17199. meta.eventChannel = new EventChannel(state2.__id__, events);
  17200. } else if (events) {
  17201. Object.keys(events).forEach((eventName) => {
  17202. meta.eventChannel._addListener(
  17203. eventName,
  17204. "on",
  17205. events[eventName]
  17206. );
  17207. });
  17208. meta.eventChannel._clearCache();
  17209. }
  17210. return isAutomatedTesting ? resolve({
  17211. __id__: state2.__id__
  17212. }) : resolve({
  17213. eventChannel: meta.eventChannel
  17214. });
  17215. }
  17216. return isAutomatedTesting ? resolve({ __id__: state2.__id__ }) : resolve();
  17217. });
  17218. });
  17219. }
  17220. function handleBeforeEntryPageRoutes() {
  17221. if (entryPageState.handledBeforeEntryPageRoutes) {
  17222. return;
  17223. }
  17224. entryPageState.handledBeforeEntryPageRoutes = true;
  17225. const navigateToPages = [...navigateToPagesBeforeEntryPages];
  17226. navigateToPagesBeforeEntryPages.length = 0;
  17227. navigateToPages.forEach(
  17228. ({ args, resolve, reject }) => (
  17229. // @ts-expect-error
  17230. navigate(args).then(resolve).catch(reject)
  17231. )
  17232. );
  17233. const switchTabPages = [...switchTabPagesBeforeEntryPages];
  17234. switchTabPagesBeforeEntryPages.length = 0;
  17235. switchTabPages.forEach(
  17236. ({ args, resolve, reject }) => (removeNonTabBarPages(), navigate(args, getTabBarPageId(args.url)).then(resolve).catch(reject))
  17237. );
  17238. const redirectToPages = [...redirectToPagesBeforeEntryPages];
  17239. redirectToPagesBeforeEntryPages.length = 0;
  17240. redirectToPages.forEach(
  17241. ({ args, resolve, reject }) => (removeLastPage(), navigate(args).then(resolve).catch(reject))
  17242. );
  17243. const reLaunchPages = [...reLaunchPagesBeforeEntryPages];
  17244. reLaunchPagesBeforeEntryPages.length = 0;
  17245. reLaunchPages.forEach(
  17246. ({ args, resolve, reject }) => (removeAllPages(), navigate(args).then(resolve).catch(reject))
  17247. );
  17248. }
  17249. let tabBar;
  17250. function useTabBar() {
  17251. if (!tabBar) {
  17252. tabBar = __uniConfig.tabBar && reactive(initTabBarI18n(__uniConfig.tabBar));
  17253. }
  17254. return tabBar;
  17255. }
  17256. const supports = window.CSS && window.CSS.supports;
  17257. function cssSupports(css) {
  17258. return supports && (supports(css) || supports.apply(window.CSS, css.split(":")));
  17259. }
  17260. const cssVar = /* @__PURE__ */ cssSupports("--a:0");
  17261. const cssEnv = /* @__PURE__ */ cssSupports("top:env(a)");
  17262. const cssConstant = /* @__PURE__ */ cssSupports("top:constant(a)");
  17263. const cssBackdropFilter = /* @__PURE__ */ cssSupports("backdrop-filter:blur(10px)");
  17264. const SCHEMA_CSS = {
  17265. "css.var": cssVar,
  17266. "css.env": cssEnv,
  17267. "css.constant": cssConstant,
  17268. "css.backdrop-filter": cssBackdropFilter
  17269. };
  17270. const canIUse = /* @__PURE__ */ defineSyncApi(
  17271. API_CAN_I_USE,
  17272. (schema) => {
  17273. if (hasOwn(SCHEMA_CSS, schema)) {
  17274. return SCHEMA_CSS[schema];
  17275. }
  17276. return true;
  17277. },
  17278. CanIUseProtocol
  17279. );
  17280. const envMethod = /* @__PURE__ */ (() => cssEnv ? "env" : cssConstant ? "constant" : "")();
  17281. function updateCurPageCssVar(pageMeta) {
  17282. let windowTopValue = 0;
  17283. let windowBottomValue = 0;
  17284. if (__UNI_FEATURE_NAVIGATIONBAR__ && pageMeta.navigationBar.style !== "custom" && ["default", "float"].indexOf(pageMeta.navigationBar.type) > -1) {
  17285. windowTopValue = NAVBAR_HEIGHT;
  17286. }
  17287. if (__UNI_FEATURE_TABBAR__ && pageMeta.isTabBar) {
  17288. const tabBar2 = useTabBar();
  17289. tabBar2.shown && (windowBottomValue = parseInt(tabBar2.height));
  17290. }
  17291. updatePageCssVar({
  17292. "--window-top": normalizeWindowTop(windowTopValue),
  17293. "--window-bottom": normalizeWindowBottom(windowBottomValue)
  17294. });
  17295. }
  17296. function normalizeWindowTop(windowTop) {
  17297. return envMethod ? `calc(${windowTop}px + ${envMethod}(safe-area-inset-top))` : `${windowTop}px`;
  17298. }
  17299. function normalizeWindowBottom(windowBottom) {
  17300. return envMethod ? `calc(${windowBottom}px + ${envMethod}(safe-area-inset-bottom))` : `${windowBottom}px`;
  17301. }
  17302. const SEP = "$$";
  17303. const currentPagesMap = /* @__PURE__ */ new Map();
  17304. const entryPageState = {
  17305. handledBeforeEntryPageRoutes: false
  17306. };
  17307. const navigateToPagesBeforeEntryPages = [];
  17308. const switchTabPagesBeforeEntryPages = [];
  17309. const redirectToPagesBeforeEntryPages = [];
  17310. const reLaunchPagesBeforeEntryPages = [];
  17311. function pruneCurrentPages() {
  17312. currentPagesMap.forEach((page, id2) => {
  17313. if (page.$.isUnmounted) {
  17314. currentPagesMap.delete(id2);
  17315. }
  17316. });
  17317. }
  17318. function getCurrentPagesMap() {
  17319. return currentPagesMap;
  17320. }
  17321. function getCurrentPages$1() {
  17322. const curPages = [];
  17323. const pages = currentPagesMap.values();
  17324. for (const page of pages) {
  17325. if (page.$.__isTabBar) {
  17326. if (page.$.__isActive) {
  17327. curPages.push(page);
  17328. }
  17329. } else {
  17330. curPages.push(page);
  17331. }
  17332. }
  17333. return curPages;
  17334. }
  17335. function removeRouteCache(routeKey) {
  17336. const vnode = pageCacheMap.get(routeKey);
  17337. if (vnode) {
  17338. pageCacheMap.delete(routeKey);
  17339. routeCache.pruneCacheEntry(vnode);
  17340. }
  17341. }
  17342. function removePage(routeKey, removeRouteCaches = true) {
  17343. const pageVm = currentPagesMap.get(routeKey);
  17344. pageVm.$.__isUnload = true;
  17345. invokeHook(pageVm, ON_UNLOAD);
  17346. currentPagesMap.delete(routeKey);
  17347. removeRouteCaches && removeRouteCache(routeKey);
  17348. }
  17349. let id = /* @__PURE__ */ getStateId();
  17350. function createPageState(type, __id__) {
  17351. return {
  17352. __id__: __id__ || ++id,
  17353. __type__: type
  17354. };
  17355. }
  17356. function initPublicPage(route) {
  17357. const meta = usePageMeta();
  17358. if (!__UNI_FEATURE_PAGES__) {
  17359. return initPageInternalInstance("navigateTo", __uniRoutes[0].path, {}, meta);
  17360. }
  17361. let fullPath = route.fullPath;
  17362. if (route.meta.isEntry && fullPath.indexOf(route.meta.route) === -1) {
  17363. fullPath = "/" + route.meta.route + fullPath.replace("/", "");
  17364. }
  17365. return initPageInternalInstance("navigateTo", fullPath, {}, meta);
  17366. }
  17367. function initPage(vm) {
  17368. const route = vm.$route;
  17369. const page = initPublicPage(route);
  17370. initPageVm(vm, page);
  17371. {
  17372. const pageMeta = page.meta;
  17373. vm.$setPageStyle = (style) => {
  17374. for (const key in style) {
  17375. switch (key) {
  17376. case "navigationBarBackgroundColor":
  17377. pageMeta.navigationBar.backgroundColor = style[key];
  17378. break;
  17379. case "navigationBarTextStyle":
  17380. const textStyle = style[key];
  17381. if (textStyle == null) {
  17382. continue;
  17383. }
  17384. pageMeta.navigationBar.titleColor = ["black", "white"].includes(
  17385. textStyle
  17386. ) ? normalizeTitleColor(textStyle || "") : textStyle;
  17387. break;
  17388. case "navigationBarTitleText":
  17389. pageMeta.navigationBar.titleText = style[key];
  17390. break;
  17391. case "titleImage":
  17392. pageMeta.navigationBar.titleImage = style[key];
  17393. break;
  17394. case "navigationStyle":
  17395. pageMeta.navigationBar.style = style[key];
  17396. break;
  17397. default:
  17398. pageMeta[key] = style[key];
  17399. break;
  17400. }
  17401. }
  17402. };
  17403. vm.$getPageStyle = () => new UTSJSONObject({
  17404. navigationBarBackgroundColor: pageMeta.navigationBar.backgroundColor,
  17405. navigationBarTextStyle: pageMeta.navigationBar.titleColor,
  17406. navigationBarTitleText: pageMeta.navigationBar.titleText,
  17407. titleImage: pageMeta.navigationBar.titleImage || "",
  17408. navigationStyle: pageMeta.navigationBar.style || "default",
  17409. disableScroll: pageMeta.disableScroll || false,
  17410. enablePullDownRefresh: pageMeta.enablePullDownRefresh || false,
  17411. onReachBottomDistance: pageMeta.onReachBottomDistance || ON_REACH_BOTTOM_DISTANCE,
  17412. backgroundColorContent: pageMeta.backgroundColorContent
  17413. });
  17414. }
  17415. currentPagesMap.set(normalizeRouteKey(page.path, page.id), vm);
  17416. if (currentPagesMap.size === 1) {
  17417. setTimeout(() => {
  17418. handleBeforeEntryPageRoutes();
  17419. }, 0);
  17420. }
  17421. }
  17422. function normalizeRouteKey(path, id2) {
  17423. return path + SEP + id2;
  17424. }
  17425. function useKeepAliveRoute() {
  17426. const route = useRoute();
  17427. const routeKey = computed(
  17428. () => normalizeRouteKey("/" + route.meta.route, getStateId())
  17429. );
  17430. const isTabBar = computed(() => route.meta.isTabBar);
  17431. return {
  17432. routeKey,
  17433. isTabBar,
  17434. routeCache
  17435. };
  17436. }
  17437. const pageCacheMap = /* @__PURE__ */ new Map();
  17438. const routeCache = {
  17439. get(key) {
  17440. return pageCacheMap.get(key);
  17441. },
  17442. set(key, value) {
  17443. pruneRouteCache(key);
  17444. pageCacheMap.set(key, value);
  17445. },
  17446. delete(key) {
  17447. const vnode = pageCacheMap.get(key);
  17448. if (!vnode) {
  17449. return;
  17450. }
  17451. pageCacheMap.delete(key);
  17452. },
  17453. forEach(fn) {
  17454. pageCacheMap.forEach(fn);
  17455. }
  17456. };
  17457. function isTabBarVNode(vnode) {
  17458. return vnode.props.type === "tabBar";
  17459. }
  17460. function pruneRouteCache(key) {
  17461. const pageId = parseInt(key.split(SEP)[1]);
  17462. if (!pageId) {
  17463. return;
  17464. }
  17465. routeCache.forEach((vnode, key2) => {
  17466. const cPageId = parseInt(key2.split(SEP)[1]);
  17467. if (cPageId && cPageId > pageId) {
  17468. if (__UNI_FEATURE_TABBAR__ && isTabBarVNode(vnode)) {
  17469. return;
  17470. }
  17471. routeCache.delete(key2);
  17472. routeCache.pruneCacheEntry(vnode);
  17473. nextTick(() => pruneCurrentPages());
  17474. }
  17475. });
  17476. }
  17477. function updateCurPageAttrs(pageMeta) {
  17478. {
  17479. const uvueDirKey = "uvue-dir-" + __uniConfig.uvue["flex-direction"];
  17480. document.body.setAttribute("uvue", "");
  17481. document.body.setAttribute(uvueDirKey, "");
  17482. }
  17483. }
  17484. function onPageShow(instance2, pageMeta) {
  17485. updateBodyScopeId(instance2);
  17486. updateCurPageCssVar(pageMeta);
  17487. updateCurPageAttrs();
  17488. initPageScrollListener(instance2, pageMeta);
  17489. }
  17490. function onPageReady(instance2) {
  17491. const scopeId = getScopeId(instance2);
  17492. scopeId && updateCurPageBodyScopeId(scopeId);
  17493. }
  17494. function updateCurPageBodyScopeId(scopeId) {
  17495. const pageBodyEl = document.querySelector("uni-page-body");
  17496. if (pageBodyEl) {
  17497. pageBodyEl.setAttribute(scopeId, "");
  17498. } else if (process.env.NODE_ENV !== "production") {
  17499. console.warn("uni-page-body not found");
  17500. }
  17501. }
  17502. function getScopeId(instance2) {
  17503. return instance2.type.__scopeId;
  17504. }
  17505. let curScopeId;
  17506. function updateBodyScopeId(instance2) {
  17507. const scopeId = getScopeId(instance2);
  17508. const { body } = document;
  17509. curScopeId && body.removeAttribute(curScopeId);
  17510. scopeId && body.setAttribute(scopeId, "");
  17511. curScopeId = scopeId;
  17512. }
  17513. let curScrollListener;
  17514. function initPageScrollListener(instance2, pageMeta) {
  17515. document.removeEventListener("touchmove", disableScrollListener);
  17516. if (curScrollListener) {
  17517. document.removeEventListener("scroll", curScrollListener);
  17518. }
  17519. if (pageMeta.disableScroll) {
  17520. return document.addEventListener("touchmove", disableScrollListener);
  17521. }
  17522. const { onPageScroll, onReachBottom } = instance2;
  17523. const navigationBarTransparent = pageMeta.navigationBar.type === "transparent";
  17524. if (!(onPageScroll == null ? void 0 : onPageScroll.length) && !(onReachBottom == null ? void 0 : onReachBottom.length) && !navigationBarTransparent) {
  17525. return;
  17526. }
  17527. const opts = {};
  17528. const pageId = instance2.proxy.$page.id;
  17529. if (onPageScroll || navigationBarTransparent) {
  17530. opts.onPageScroll = createOnPageScroll(
  17531. pageId,
  17532. onPageScroll,
  17533. navigationBarTransparent
  17534. );
  17535. }
  17536. if (onReachBottom == null ? void 0 : onReachBottom.length) {
  17537. opts.onReachBottomDistance = pageMeta.onReachBottomDistance || ON_REACH_BOTTOM_DISTANCE;
  17538. opts.onReachBottom = () => UniViewJSBridge.publishHandler(ON_REACH_BOTTOM, {}, pageId);
  17539. }
  17540. curScrollListener = createScrollListener(opts);
  17541. requestAnimationFrame(
  17542. () => document.addEventListener("scroll", curScrollListener)
  17543. );
  17544. {
  17545. watch(
  17546. () => pageMeta.onReachBottomDistance,
  17547. (onReachBottomDistance) => {
  17548. if (!onReachBottom) {
  17549. return;
  17550. }
  17551. opts.onReachBottomDistance = onReachBottomDistance || ON_REACH_BOTTOM_DISTANCE;
  17552. document.removeEventListener("scroll", curScrollListener);
  17553. curScrollListener = createScrollListener(opts);
  17554. document.addEventListener("scroll", curScrollListener);
  17555. }
  17556. );
  17557. watch(
  17558. () => pageMeta.disableScroll,
  17559. (disableScroll) => {
  17560. document.removeEventListener("touchmove", disableScrollListener);
  17561. if (disableScroll) {
  17562. return document.addEventListener("touchmove", disableScrollListener);
  17563. }
  17564. }
  17565. );
  17566. }
  17567. }
  17568. function createOnPageScroll(pageId, onPageScroll, navigationBarTransparent) {
  17569. return (scrollTop) => {
  17570. if (onPageScroll) {
  17571. UniViewJSBridge.publishHandler(ON_PAGE_SCROLL, { scrollTop }, pageId);
  17572. }
  17573. if (navigationBarTransparent) {
  17574. UniViewJSBridge.emit(pageId + "." + ON_PAGE_SCROLL, {
  17575. scrollTop
  17576. });
  17577. }
  17578. };
  17579. }
  17580. function usePopupStyle(props2) {
  17581. const popupWidth = ref(0);
  17582. const popupHeight = ref(0);
  17583. const isDesktop = computed(
  17584. () => popupWidth.value >= 500 && popupHeight.value >= 500
  17585. );
  17586. const popupStyle = computed(() => {
  17587. const style = {
  17588. content: {
  17589. transform: "",
  17590. left: "",
  17591. top: "",
  17592. bottom: ""
  17593. },
  17594. triangle: {
  17595. left: "",
  17596. top: "",
  17597. bottom: "",
  17598. "border-width": "",
  17599. "border-color": ""
  17600. }
  17601. };
  17602. const contentStyle = style.content;
  17603. const triangleStyle = style.triangle;
  17604. const popover = props2.popover;
  17605. function getNumber(value) {
  17606. return Number(value) || 0;
  17607. }
  17608. if (isDesktop.value && popover) {
  17609. extend(triangleStyle, {
  17610. position: "absolute",
  17611. width: "0",
  17612. height: "0",
  17613. "margin-left": "-6px",
  17614. "border-style": "solid"
  17615. });
  17616. const popoverLeft = getNumber(popover.left);
  17617. const popoverWidth = getNumber(popover.width);
  17618. const popoverTop = getNumber(popover.top);
  17619. const popoverHeight = getNumber(popover.height);
  17620. const center = popoverLeft + popoverWidth / 2;
  17621. contentStyle.transform = "none !important";
  17622. const contentLeft = Math.max(0, center - 300 / 2);
  17623. contentStyle.left = `${contentLeft}px`;
  17624. let triangleLeft = Math.max(12, center - contentLeft);
  17625. triangleLeft = Math.min(300 - 12, triangleLeft);
  17626. triangleStyle.left = `${triangleLeft}px`;
  17627. const vcl = popupHeight.value / 2;
  17628. if (popoverTop + popoverHeight - vcl > vcl - popoverTop) {
  17629. contentStyle.top = "auto";
  17630. contentStyle.bottom = `${popupHeight.value - popoverTop + 6}px`;
  17631. triangleStyle.bottom = "-6px";
  17632. triangleStyle["border-width"] = "6px 6px 0 6px";
  17633. triangleStyle["border-color"] = "#fcfcfd transparent transparent transparent";
  17634. } else {
  17635. contentStyle.top = `${popoverTop + popoverHeight + 6}px`;
  17636. triangleStyle.top = "-6px";
  17637. triangleStyle["border-width"] = "0 6px 6px 6px";
  17638. triangleStyle["border-color"] = "transparent transparent #fcfcfd transparent";
  17639. }
  17640. }
  17641. return style;
  17642. });
  17643. onMounted(() => {
  17644. const fixSize = () => {
  17645. const { windowWidth, windowHeight, windowTop } = uni.getSystemInfoSync();
  17646. popupWidth.value = windowWidth;
  17647. popupHeight.value = windowHeight + (windowTop || 0);
  17648. };
  17649. window.addEventListener("resize", fixSize);
  17650. fixSize();
  17651. onUnmounted(() => {
  17652. window.removeEventListener("resize", fixSize);
  17653. });
  17654. });
  17655. return {
  17656. isDesktop,
  17657. popupStyle
  17658. };
  17659. }
  17660. const KEY_MAPS = {
  17661. esc: ["Esc", "Escape"],
  17662. // tab: ['Tab'],
  17663. enter: ["Enter"]
  17664. // space: [' ', 'Spacebar'],
  17665. // up: ['Up', 'ArrowUp'],
  17666. // left: ['Left', 'ArrowLeft'],
  17667. // right: ['Right', 'ArrowRight'],
  17668. // down: ['Down', 'ArrowDown'],
  17669. // delete: ['Backspace', 'Delete', 'Del'],
  17670. };
  17671. const KEYS = Object.keys(KEY_MAPS);
  17672. function useKeyboard() {
  17673. const key = ref("");
  17674. const disable = ref(false);
  17675. const onKeyup = (evt) => {
  17676. if (disable.value) {
  17677. return;
  17678. }
  17679. const res = KEYS.find(
  17680. (key2) => KEY_MAPS[key2].indexOf(evt.key) !== -1
  17681. );
  17682. if (res) {
  17683. key.value = res;
  17684. }
  17685. nextTick(() => key.value = "");
  17686. };
  17687. onMounted(() => {
  17688. document.addEventListener("keyup", onKeyup);
  17689. });
  17690. onBeforeUnmount(() => {
  17691. document.removeEventListener("keyup", onKeyup);
  17692. });
  17693. return {
  17694. key,
  17695. disable
  17696. };
  17697. }
  17698. function IEVersion() {
  17699. const userAgent = navigator.userAgent;
  17700. const isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1;
  17701. const isEdge = userAgent.indexOf("Edge") > -1 && !isIE;
  17702. const isIE11 = userAgent.indexOf("Trident") > -1 && userAgent.indexOf("rv:11.0") > -1;
  17703. if (isIE) {
  17704. const reIE = new RegExp("MSIE (\\d+\\.\\d+);");
  17705. reIE.test(userAgent);
  17706. const fIEVersion = parseFloat(RegExp.$1);
  17707. if (fIEVersion > 6) {
  17708. return fIEVersion;
  17709. } else {
  17710. return 6;
  17711. }
  17712. } else if (isEdge) {
  17713. return -1;
  17714. } else if (isIE11) {
  17715. return 11;
  17716. } else {
  17717. return -1;
  17718. }
  17719. }
  17720. function getTheme() {
  17721. if (__uniConfig.darkmode !== true)
  17722. return isString(__uniConfig.darkmode) ? __uniConfig.darkmode : "light";
  17723. try {
  17724. return window.matchMedia("(prefers-color-scheme: light)").matches ? "light" : "dark";
  17725. } catch (error) {
  17726. return "light";
  17727. }
  17728. }
  17729. function getBrowserInfo() {
  17730. let osname;
  17731. let osversion = "0";
  17732. let model = "";
  17733. let deviceType = "phone";
  17734. const language = navigator.language;
  17735. if (isIOS$1) {
  17736. osname = "iOS";
  17737. const osversionFind = ua.match(/OS\s([\w_]+)\slike/);
  17738. if (osversionFind) {
  17739. osversion = osversionFind[1].replace(/_/g, ".");
  17740. }
  17741. const modelFind = ua.match(/\(([a-zA-Z]+);/);
  17742. if (modelFind) {
  17743. model = modelFind[1];
  17744. }
  17745. } else if (isAndroid) {
  17746. osname = "Android";
  17747. const osversionFind = ua.match(/Android[\s/]([\w\.]+)[;\s]/);
  17748. if (osversionFind) {
  17749. osversion = osversionFind[1];
  17750. }
  17751. const infoFind = ua.match(/\((.+?)\)/);
  17752. const infos = infoFind ? infoFind[1].split(";") : ua.split(" ");
  17753. const otherInfo = [
  17754. /\bAndroid\b/i,
  17755. /\bLinux\b/i,
  17756. /\bU\b/i,
  17757. /^\s?[a-z][a-z]$/i,
  17758. /^\s?[a-z][a-z]-[a-z][a-z]$/i,
  17759. /\bwv\b/i,
  17760. /\/[\d\.,]+$/,
  17761. /^\s?[\d\.,]+$/,
  17762. /\bBrowser\b/i,
  17763. /\bMobile\b/i
  17764. ];
  17765. for (let i = 0; i < infos.length; i++) {
  17766. const info = infos[i];
  17767. if (info.indexOf("Build") > 0) {
  17768. model = info.split("Build")[0].trim();
  17769. break;
  17770. }
  17771. let other;
  17772. for (let o2 = 0; o2 < otherInfo.length; o2++) {
  17773. if (otherInfo[o2].test(info)) {
  17774. other = true;
  17775. break;
  17776. }
  17777. }
  17778. if (!other) {
  17779. model = info.trim();
  17780. break;
  17781. }
  17782. }
  17783. } else if (isIPadOS) {
  17784. model = "iPad";
  17785. osname = "iOS";
  17786. deviceType = "pad";
  17787. osversion = isFunction(window.BigInt) ? "14.0" : "13.0";
  17788. } else if (isWindows || isMac || isLinux) {
  17789. model = "PC";
  17790. osname = "PC";
  17791. deviceType = "pc";
  17792. osversion = "0";
  17793. let osversionFind = ua.match(/\((.+?)\)/)[1];
  17794. if (isWindows) {
  17795. osname = "Windows";
  17796. switch (isWindows[1]) {
  17797. case "5.1":
  17798. osversion = "XP";
  17799. break;
  17800. case "6.0":
  17801. osversion = "Vista";
  17802. break;
  17803. case "6.1":
  17804. osversion = "7";
  17805. break;
  17806. case "6.2":
  17807. osversion = "8";
  17808. break;
  17809. case "6.3":
  17810. osversion = "8.1";
  17811. break;
  17812. case "10.0":
  17813. osversion = "10";
  17814. break;
  17815. }
  17816. const framework = osversionFind && osversionFind.match(/[Win|WOW]([\d]+)/);
  17817. if (framework) {
  17818. osversion += ` x${framework[1]}`;
  17819. }
  17820. } else if (isMac) {
  17821. osname = "macOS";
  17822. const _osversion = osversionFind && osversionFind.match(/Mac OS X (.+)/) || "";
  17823. if (osversion) {
  17824. osversion = _osversion[1].replace(/_/g, ".");
  17825. if (osversion.indexOf(";") !== -1) {
  17826. osversion = osversion.split(";")[0];
  17827. }
  17828. }
  17829. } else if (isLinux) {
  17830. osname = "Linux";
  17831. const _osversion = osversionFind && osversionFind.match(/Linux (.*)/) || "";
  17832. if (_osversion) {
  17833. osversion = _osversion[1];
  17834. if (osversion.indexOf(";") !== -1) {
  17835. osversion = osversion.split(";")[0];
  17836. }
  17837. }
  17838. }
  17839. } else {
  17840. osname = "Other";
  17841. osversion = "0";
  17842. deviceType = "unknown";
  17843. }
  17844. const system = `${osname} ${osversion}`;
  17845. const platform = osname.toLocaleLowerCase();
  17846. let browserName = "";
  17847. let browserVersion = String(IEVersion());
  17848. if (browserVersion !== "-1") {
  17849. browserName = "IE";
  17850. } else {
  17851. const browseVendors = ["Version", "Firefox", "Chrome", "Edge{0,1}"];
  17852. const vendors = ["Safari", "Firefox", "Chrome", "Edge"];
  17853. for (let index2 = 0; index2 < browseVendors.length; index2++) {
  17854. const vendor = browseVendors[index2];
  17855. const reg = new RegExp(`(${vendor})/(\\S*)\\b`);
  17856. if (reg.test(ua)) {
  17857. browserName = vendors[index2];
  17858. browserVersion = ua.match(reg)[2];
  17859. }
  17860. }
  17861. }
  17862. let deviceOrientation = "portrait";
  17863. const orientation = typeof window.screen.orientation === "undefined" ? window.orientation : window.screen.orientation.angle;
  17864. deviceOrientation = Math.abs(orientation) === 90 ? "landscape" : "portrait";
  17865. return {
  17866. deviceBrand: void 0,
  17867. brand: void 0,
  17868. deviceModel: model,
  17869. deviceOrientation,
  17870. model,
  17871. system,
  17872. platform,
  17873. browserName: browserName.toLocaleLowerCase(),
  17874. browserVersion,
  17875. language,
  17876. deviceType,
  17877. ua,
  17878. osname,
  17879. osversion,
  17880. theme: getTheme()
  17881. };
  17882. }
  17883. function onThemeChange$2(callback) {
  17884. if (__uniConfig.darkmode) {
  17885. UniServiceJSBridge.on(ON_THEME_CHANGE, callback);
  17886. }
  17887. }
  17888. function offThemeChange$1(callback) {
  17889. UniServiceJSBridge.off(ON_THEME_CHANGE, callback);
  17890. }
  17891. function parseTheme(pageStyle) {
  17892. let parsedStyle = {};
  17893. if (__uniConfig.darkmode) {
  17894. parsedStyle = normalizeStyles(
  17895. pageStyle,
  17896. __uniConfig.themeConfig,
  17897. getTheme()
  17898. );
  17899. }
  17900. return __uniConfig.darkmode ? parsedStyle : pageStyle;
  17901. }
  17902. function useTheme(pageStyle, onThemeChangeCallback) {
  17903. const isReactivity = isReactive(pageStyle);
  17904. const reactivePageStyle = isReactivity ? reactive(parseTheme(pageStyle)) : parseTheme(pageStyle);
  17905. if (__uniConfig.darkmode && isReactivity) {
  17906. watch(pageStyle, (value) => {
  17907. const _pageStyle = parseTheme(value);
  17908. for (const key in _pageStyle) {
  17909. reactivePageStyle[key] = _pageStyle[key];
  17910. }
  17911. });
  17912. }
  17913. onThemeChangeCallback && onThemeChange$2(onThemeChangeCallback);
  17914. return reactivePageStyle;
  17915. }
  17916. const ACTION_SHEET_THEME = {
  17917. light: {
  17918. listItemColor: "#000000",
  17919. cancelItemColor: "#000000"
  17920. },
  17921. dark: {
  17922. listItemColor: "rgba(255, 255, 255, 0.8)",
  17923. cancelItemColor: "rgba(255, 255, 255)"
  17924. }
  17925. };
  17926. function setActionSheetTheme(theme, actionSheetTheme) {
  17927. const ActionSheetThemeKey = ["listItemColor", "cancelItemColor"];
  17928. ActionSheetThemeKey.forEach((key) => {
  17929. actionSheetTheme[key] = ACTION_SHEET_THEME[theme][key];
  17930. });
  17931. }
  17932. const props$g = {
  17933. title: {
  17934. type: String,
  17935. default: ""
  17936. },
  17937. itemList: {
  17938. type: Array,
  17939. default() {
  17940. return [];
  17941. }
  17942. },
  17943. itemColor: {
  17944. type: String,
  17945. default: "#000000"
  17946. },
  17947. popover: {
  17948. type: Object,
  17949. default: null
  17950. },
  17951. visible: {
  17952. type: Boolean,
  17953. default: false
  17954. }
  17955. };
  17956. const actionSheet = /* @__PURE__ */ defineComponent({
  17957. name: "ActionSheet",
  17958. props: props$g,
  17959. emits: ["close"],
  17960. setup(props2, {
  17961. emit: emit2
  17962. }) {
  17963. initI18nShowActionSheetMsgsOnce();
  17964. const HEIGHT = ref(336);
  17965. const contentHeight = ref(0);
  17966. const titleHeight = ref(0);
  17967. const deltaY = ref(0);
  17968. const scrollTop = ref(0);
  17969. const content = ref(null);
  17970. const main = ref(null);
  17971. const {
  17972. t: t2
  17973. } = useI18n();
  17974. const {
  17975. _close
  17976. } = useActionSheetLoader(props2, emit2);
  17977. const {
  17978. popupStyle
  17979. } = usePopupStyle(props2);
  17980. let scroller;
  17981. onMounted(() => {
  17982. const {
  17983. scroller: _scroller,
  17984. handleTouchStart,
  17985. handleTouchMove,
  17986. handleTouchEnd
  17987. } = useScroller(content.value, {
  17988. enableY: true,
  17989. friction: new Friction(1e-4),
  17990. spring: new Spring(2, 90, 20),
  17991. onScroll: (e2) => {
  17992. scrollTop.value = e2.target.scrollTop;
  17993. }
  17994. });
  17995. scroller = _scroller;
  17996. useTouchtrack(content.value, (e2) => {
  17997. if (_scroller) {
  17998. switch (e2.detail.state) {
  17999. case "start":
  18000. handleTouchStart(e2);
  18001. break;
  18002. case "move":
  18003. handleTouchMove(e2);
  18004. break;
  18005. case "end":
  18006. case "cancel":
  18007. handleTouchEnd(e2);
  18008. }
  18009. }
  18010. }, true);
  18011. });
  18012. function _handleWheel($event) {
  18013. const _deltaY = deltaY.value + $event.deltaY;
  18014. if (Math.abs(_deltaY) > 10) {
  18015. scrollTop.value += _deltaY / 3;
  18016. scrollTop.value = scrollTop.value >= contentHeight.value ? contentHeight.value : scrollTop.value <= 0 ? 0 : scrollTop.value;
  18017. scroller.scrollTo(scrollTop.value);
  18018. } else {
  18019. deltaY.value = _deltaY;
  18020. }
  18021. $event.preventDefault();
  18022. }
  18023. watch(() => props2.visible, () => {
  18024. nextTick(() => {
  18025. if (props2.title) {
  18026. titleHeight.value = document.querySelector(".uni-actionsheet__title").offsetHeight;
  18027. }
  18028. scroller.update();
  18029. if (content.value)
  18030. contentHeight.value = content.value.clientHeight - HEIGHT.value;
  18031. document.querySelectorAll(".uni-actionsheet__cell").forEach((item) => {
  18032. initClick(item);
  18033. });
  18034. });
  18035. });
  18036. const actionSheetTheme = useOnThemeChange$1(props2);
  18037. return () => {
  18038. return createVNode("uni-actionsheet", {
  18039. "onTouchmove": onEventPrevent
  18040. }, [createVNode(Transition, {
  18041. "name": "uni-fade"
  18042. }, {
  18043. default: () => [withDirectives(createVNode("div", {
  18044. "class": "uni-mask uni-actionsheet__mask",
  18045. "onClick": () => _close(-1)
  18046. }, null, 8, ["onClick"]), [[vShow, props2.visible]])]
  18047. }), createVNode("div", {
  18048. "class": ["uni-actionsheet", {
  18049. "uni-actionsheet_toggle": props2.visible
  18050. }],
  18051. "style": popupStyle.value.content
  18052. }, [createVNode("div", {
  18053. "ref": main,
  18054. "class": "uni-actionsheet__menu",
  18055. "onWheel": _handleWheel
  18056. }, [props2.title ? createVNode(Fragment, null, [createVNode("div", {
  18057. "class": "uni-actionsheet__cell",
  18058. "style": {
  18059. height: `${titleHeight.value}px`
  18060. }
  18061. }, null), createVNode("div", {
  18062. "class": "uni-actionsheet__title"
  18063. }, [props2.title])]) : "", createVNode("div", {
  18064. "style": {
  18065. maxHeight: `${HEIGHT.value}px`,
  18066. overflow: "hidden"
  18067. }
  18068. }, [createVNode("div", {
  18069. "ref": content
  18070. }, [props2.itemList.map((itemTitle, index2) => createVNode("div", {
  18071. "key": index2,
  18072. "style": {
  18073. color: actionSheetTheme.listItemColor
  18074. },
  18075. "class": "uni-actionsheet__cell",
  18076. "onClick": () => _close(index2)
  18077. }, [itemTitle], 12, ["onClick"]))], 512)])], 40, ["onWheel"]), createVNode("div", {
  18078. "class": "uni-actionsheet__action"
  18079. }, [createVNode("div", {
  18080. "style": {
  18081. color: actionSheetTheme.cancelItemColor
  18082. },
  18083. "class": "uni-actionsheet__cell",
  18084. "onClick": () => _close(-1)
  18085. }, [t2("uni.showActionSheet.cancel")], 12, ["onClick"])]), createVNode("div", {
  18086. "style": popupStyle.value.triangle
  18087. }, null, 4)], 6)], 40, ["onTouchmove"]);
  18088. };
  18089. }
  18090. });
  18091. function useActionSheetLoader(props2, emit2) {
  18092. function _close(tapIndex) {
  18093. emit2("close", tapIndex);
  18094. }
  18095. const {
  18096. key,
  18097. disable
  18098. } = useKeyboard();
  18099. watch(() => props2.visible, (value) => disable.value = !value);
  18100. watchEffect(() => {
  18101. const {
  18102. value
  18103. } = key;
  18104. if (value === "esc") {
  18105. _close && _close(-1);
  18106. }
  18107. });
  18108. return {
  18109. _close
  18110. };
  18111. }
  18112. function initClick(dom) {
  18113. const MAX_MOVE = 20;
  18114. let x = 0;
  18115. let y = 0;
  18116. dom.addEventListener("touchstart", (event) => {
  18117. const info = event.changedTouches[0];
  18118. x = info.clientX;
  18119. y = info.clientY;
  18120. });
  18121. dom.addEventListener("touchend", (event) => {
  18122. const info = event.changedTouches[0];
  18123. if (Math.abs(info.clientX - x) < MAX_MOVE && Math.abs(info.clientY - y) < MAX_MOVE) {
  18124. const target = event.target;
  18125. const currentTarget = event.currentTarget;
  18126. const customEvent = new CustomEvent("click", {
  18127. bubbles: true,
  18128. cancelable: true,
  18129. target,
  18130. currentTarget
  18131. });
  18132. ["screenX", "screenY", "clientX", "clientY", "pageX", "pageY"].forEach((key) => {
  18133. customEvent[key] = info[key];
  18134. });
  18135. event.target.dispatchEvent(customEvent);
  18136. }
  18137. });
  18138. }
  18139. function useOnThemeChange$1(props2) {
  18140. const actionSheetTheme = reactive({
  18141. listItemColor: "#000",
  18142. cancelItemColor: "#000"
  18143. });
  18144. const _onThemeChange = ({
  18145. theme
  18146. }) => {
  18147. setActionSheetTheme(theme, actionSheetTheme);
  18148. };
  18149. watchEffect(() => {
  18150. if (props2.visible) {
  18151. actionSheetTheme.listItemColor = actionSheetTheme.cancelItemColor = props2.itemColor;
  18152. if (props2.itemColor === "#000") {
  18153. _onThemeChange({
  18154. theme: getTheme()
  18155. });
  18156. onThemeChange$2(_onThemeChange);
  18157. }
  18158. } else {
  18159. offThemeChange$1(_onThemeChange);
  18160. }
  18161. });
  18162. return actionSheetTheme;
  18163. }
  18164. const VNODE_MASK = /* @__PURE__ */ createVNode(
  18165. "div",
  18166. { class: "uni-mask" },
  18167. null,
  18168. -1
  18169. /* HOISTED */
  18170. );
  18171. function createRootApp(component, rootState, callback) {
  18172. rootState.onClose = (...args) => (rootState.visible = false, callback.apply(null, args));
  18173. return createApp(
  18174. defineComponent({
  18175. setup() {
  18176. return () => (openBlock(), createBlock(
  18177. component,
  18178. rootState,
  18179. null,
  18180. 16
  18181. /* FULL_PROPS */
  18182. ));
  18183. }
  18184. })
  18185. );
  18186. }
  18187. function ensureRoot(id2) {
  18188. let rootEl = document.getElementById(id2);
  18189. if (!rootEl) {
  18190. rootEl = document.createElement("div");
  18191. rootEl.id = id2;
  18192. document.body.append(rootEl);
  18193. }
  18194. return rootEl;
  18195. }
  18196. function usePopup(props2, {
  18197. onEsc,
  18198. onEnter
  18199. }) {
  18200. const visible = ref(props2.visible);
  18201. const { key, disable } = useKeyboard();
  18202. watch(
  18203. () => props2.visible,
  18204. (value) => visible.value = value
  18205. );
  18206. watch(
  18207. () => visible.value,
  18208. (value) => disable.value = !value
  18209. );
  18210. watchEffect(() => {
  18211. const { value } = key;
  18212. if (value === "esc") {
  18213. onEsc && onEsc();
  18214. } else if (value === "enter") {
  18215. onEnter && onEnter();
  18216. }
  18217. });
  18218. return visible;
  18219. }
  18220. let resolveAction;
  18221. let rejectAction;
  18222. let showActionSheetState;
  18223. const onHidePopupOnce$1 = /* @__PURE__ */ once(() => {
  18224. UniServiceJSBridge.on(
  18225. "onHidePopup",
  18226. () => showActionSheetState.visible = false
  18227. );
  18228. });
  18229. function onActionSheetClose(tapIndex) {
  18230. if (tapIndex === -1) {
  18231. rejectAction && rejectAction("cancel");
  18232. } else {
  18233. resolveAction && resolveAction({ tapIndex });
  18234. }
  18235. }
  18236. const hideActionSheet = () => {
  18237. if (showActionSheetState) {
  18238. showActionSheetState.visible = false;
  18239. }
  18240. };
  18241. const showActionSheet = /* @__PURE__ */ defineAsyncApi(
  18242. API_SHOW_ACTION_SHEET,
  18243. (args, { resolve, reject }) => {
  18244. onHidePopupOnce$1();
  18245. resolveAction = resolve;
  18246. rejectAction = reject;
  18247. if (!showActionSheetState) {
  18248. showActionSheetState = reactive(args);
  18249. nextTick(
  18250. () => (createRootApp(
  18251. actionSheet,
  18252. showActionSheetState,
  18253. onActionSheetClose
  18254. ).mount(ensureRoot("u-s-a-s")), //下一帧执行,确保首次显示时有动画效果
  18255. nextTick(() => showActionSheetState.visible = true))
  18256. );
  18257. } else {
  18258. extend(showActionSheetState, args);
  18259. showActionSheetState.visible = true;
  18260. }
  18261. },
  18262. ShowActionSheetProtocol,
  18263. ShowActionSheetOptions
  18264. );
  18265. const ModalTheme = {
  18266. light: {
  18267. cancelColor: "#000000"
  18268. },
  18269. dark: {
  18270. cancelColor: "rgb(170, 170, 170)"
  18271. }
  18272. };
  18273. const setCancelColor = (theme, cancelColor) => cancelColor.value = ModalTheme[theme].cancelColor;
  18274. const props$f = {
  18275. title: {
  18276. type: String,
  18277. default: ""
  18278. },
  18279. content: {
  18280. type: String,
  18281. default: ""
  18282. },
  18283. showCancel: {
  18284. type: Boolean,
  18285. default: true
  18286. },
  18287. cancelText: {
  18288. type: String,
  18289. default: "Cancel"
  18290. },
  18291. cancelColor: {
  18292. type: String,
  18293. default: "#000000"
  18294. },
  18295. confirmText: {
  18296. type: String,
  18297. default: "OK"
  18298. },
  18299. confirmColor: {
  18300. type: String,
  18301. default: "#576b95"
  18302. },
  18303. visible: {
  18304. type: Boolean
  18305. },
  18306. editable: {
  18307. type: Boolean,
  18308. default: false
  18309. },
  18310. placeholderText: {
  18311. type: String,
  18312. default: ""
  18313. }
  18314. };
  18315. const modal = /* @__PURE__ */ defineComponent({
  18316. props: props$f,
  18317. setup(props2, {
  18318. emit: emit2
  18319. }) {
  18320. const editContent = ref("");
  18321. const close = () => visible.value = false;
  18322. const cancel = () => (close(), emit2("close", "cancel"));
  18323. const confirm = () => (close(), emit2("close", "confirm", editContent.value));
  18324. const visible = usePopup(props2, {
  18325. onEsc: cancel,
  18326. onEnter: () => {
  18327. !props2.editable && confirm();
  18328. }
  18329. });
  18330. const cancelColor = useOnThemeChange(props2);
  18331. return () => {
  18332. const {
  18333. title,
  18334. content,
  18335. showCancel,
  18336. confirmText,
  18337. confirmColor,
  18338. editable,
  18339. placeholderText
  18340. } = props2;
  18341. editContent.value = content;
  18342. return createVNode(Transition, {
  18343. "name": "uni-fade"
  18344. }, {
  18345. default: () => [withDirectives(createVNode("uni-modal", {
  18346. "onTouchmove": onEventPrevent
  18347. }, [VNODE_MASK, createVNode("div", {
  18348. "class": "uni-modal"
  18349. }, [title || true ? createVNode("div", {
  18350. "class": "uni-modal__hd"
  18351. }, [createVNode("strong", {
  18352. "class": "uni-modal__title",
  18353. "textContent": title || ""
  18354. }, null, 8, ["textContent"])]) : null, editable ? createVNode("div", {
  18355. "class": "uni-modal__bd",
  18356. "key": "uni-modal-bd-editable"
  18357. }, [createVNode("textarea", {
  18358. "class": "uni-modal__textarea",
  18359. "rows": "2",
  18360. "placeholder": placeholderText,
  18361. "value": content,
  18362. "onInput": (e2) => editContent.value = e2.target.value
  18363. }, null, 40, ["placeholder", "value", "onInput"])]) : createVNode("div", {
  18364. "class": "uni-modal__bd",
  18365. "onTouchmovePassive": onEventStop,
  18366. "textContent": content
  18367. }, null, 40, ["onTouchmovePassive", "textContent"]), createVNode("div", {
  18368. "class": "uni-modal__ft"
  18369. }, [showCancel && createVNode("div", {
  18370. "style": {
  18371. color: cancelColor.value
  18372. },
  18373. "class": "uni-modal__btn uni-modal__btn_default",
  18374. "onClick": cancel
  18375. }, [props2.cancelText], 12, ["onClick"]), createVNode("div", {
  18376. "style": {
  18377. color: confirmColor
  18378. },
  18379. "class": "uni-modal__btn uni-modal__btn_primary",
  18380. "onClick": confirm
  18381. }, [confirmText], 12, ["onClick"])])])], 40, ["onTouchmove"]), [[vShow, visible.value]])]
  18382. });
  18383. };
  18384. }
  18385. });
  18386. function useOnThemeChange(props2) {
  18387. const cancelColor = ref(props2.cancelColor);
  18388. const _onThemeChange = ({
  18389. theme
  18390. }) => {
  18391. setCancelColor(theme, cancelColor);
  18392. };
  18393. watchEffect(() => {
  18394. if (props2.visible) {
  18395. cancelColor.value = props2.cancelColor;
  18396. if (props2.cancelColor === "#000") {
  18397. if (getTheme() === "dark")
  18398. _onThemeChange({
  18399. theme: "dark"
  18400. });
  18401. onThemeChange$2(_onThemeChange);
  18402. }
  18403. } else {
  18404. offThemeChange$1(_onThemeChange);
  18405. }
  18406. });
  18407. return cancelColor;
  18408. }
  18409. let showModalState;
  18410. const onHidePopupOnce = /* @__PURE__ */ once(() => {
  18411. UniServiceJSBridge.on("onHidePopup", () => showModalState.visible = false);
  18412. });
  18413. let currentShowModalResolve;
  18414. function onModalClose(type, content) {
  18415. const isConfirm = type === "confirm";
  18416. const res = {
  18417. confirm: isConfirm,
  18418. cancel: type === "cancel"
  18419. };
  18420. isConfirm && showModalState.editable && (res.content = content);
  18421. currentShowModalResolve && currentShowModalResolve(res);
  18422. }
  18423. const hideModal = () => {
  18424. if (showModalState) {
  18425. showModalState.visible = false;
  18426. }
  18427. };
  18428. const showModal = /* @__PURE__ */ defineAsyncApi(
  18429. API_SHOW_MODAL,
  18430. (args, { resolve }) => {
  18431. onHidePopupOnce();
  18432. currentShowModalResolve = resolve;
  18433. if (!showModalState) {
  18434. showModalState = reactive(args);
  18435. nextTick(
  18436. () => (createRootApp(modal, showModalState, onModalClose).mount(
  18437. ensureRoot("u-a-m")
  18438. ), //下一帧执行,确保首次显示时有动画效果
  18439. nextTick(() => showModalState.visible = true))
  18440. );
  18441. } else {
  18442. extend(showModalState, args);
  18443. showModalState.visible = true;
  18444. }
  18445. },
  18446. ShowModalProtocol,
  18447. ShowModalOptions
  18448. );
  18449. function initRouter(app) {
  18450. const router = createRouter(createRouterOptions());
  18451. router.beforeEach((to, from) => {
  18452. hideActionSheet();
  18453. hideModal();
  18454. uni.hideToast();
  18455. uni.hideLoading();
  18456. });
  18457. router.beforeEach((to, from) => {
  18458. if (to && from && to.meta.isTabBar && from.meta.isTabBar) {
  18459. saveTabBarScrollPosition(from.meta.tabBarIndex);
  18460. }
  18461. });
  18462. app.router = router;
  18463. app.use(router);
  18464. }
  18465. let positionStore = /* @__PURE__ */ Object.create(null);
  18466. function getTabBarScrollPosition(id2) {
  18467. return positionStore[id2];
  18468. }
  18469. function saveTabBarScrollPosition(id2) {
  18470. if (typeof window !== "undefined") {
  18471. positionStore[id2] = {
  18472. left: window.pageXOffset,
  18473. top: window.pageYOffset
  18474. };
  18475. }
  18476. }
  18477. const scrollBehavior = (to, from, savedPosition) => {
  18478. if (savedPosition) {
  18479. return savedPosition;
  18480. } else {
  18481. if (to && from && to.meta.isTabBar && from.meta.isTabBar) {
  18482. const position = getTabBarScrollPosition(to.meta.tabBarIndex);
  18483. if (position) {
  18484. return position;
  18485. }
  18486. }
  18487. return {
  18488. left: 0,
  18489. top: 0
  18490. };
  18491. }
  18492. };
  18493. function createRouterOptions() {
  18494. return {
  18495. history: initHistory(),
  18496. strict: !!__uniConfig.router.strict,
  18497. routes: __uniRoutes,
  18498. scrollBehavior
  18499. };
  18500. }
  18501. function removeCurrentPages(delta = 1) {
  18502. const keys = getCurrentPages$1();
  18503. const start = keys.length - 1;
  18504. const end = start - delta;
  18505. for (let i = start; i > end; i--) {
  18506. const page = keys[i].$page;
  18507. removePage(normalizeRouteKey(page.path, page.id), false);
  18508. }
  18509. }
  18510. function initHistory() {
  18511. let { routerBase } = __uniConfig.router;
  18512. if (routerBase === "/") {
  18513. routerBase = "";
  18514. }
  18515. const history2 = __UNI_FEATURE_ROUTER_MODE__ === "history" ? createWebHistory(routerBase) : createWebHashHistory(routerBase);
  18516. history2.listen((_to, _from, info) => {
  18517. if (info.direction === "back") {
  18518. removeCurrentPages(Math.abs(info.delta));
  18519. }
  18520. });
  18521. return history2;
  18522. }
  18523. const index$d = {
  18524. install(app) {
  18525. initApp$1(app);
  18526. initViewPlugin(app);
  18527. initServicePlugin(app);
  18528. if (!app.config.warnHandler) {
  18529. app.config.warnHandler = warnHandler;
  18530. }
  18531. if (__UNI_FEATURE_PAGES__) {
  18532. initRouter(app);
  18533. }
  18534. }
  18535. };
  18536. function warnHandler(msg, instance2, trace) {
  18537. if (instance2) {
  18538. const name = instance2.$.type.name;
  18539. if ("PageMetaHead" === name) {
  18540. return;
  18541. }
  18542. const parent = instance2.$.parent;
  18543. if (parent && parent.type.name === "PageMeta") {
  18544. return;
  18545. }
  18546. }
  18547. const warnArgs = [`[Vue warn]: ${msg}`];
  18548. if (trace.length) {
  18549. warnArgs.push(`
  18550. `, trace);
  18551. }
  18552. console.warn(...warnArgs);
  18553. }
  18554. const clazz = { class: "uni-async-loading" };
  18555. const loadingVNode = /* @__PURE__ */ createVNode(
  18556. "i",
  18557. { class: "uni-loading" },
  18558. null,
  18559. -1
  18560. /* HOISTED */
  18561. );
  18562. const AsyncLoadingComponent = /* @__PURE__ */ defineSystemComponent({
  18563. name: "AsyncLoading",
  18564. render() {
  18565. return openBlock(), createBlock("div", clazz, [loadingVNode]);
  18566. }
  18567. });
  18568. function reload() {
  18569. window.location.reload();
  18570. }
  18571. const AsyncErrorComponent = /* @__PURE__ */ defineSystemComponent({
  18572. name: "AsyncError",
  18573. setup() {
  18574. initI18nAsyncMsgsOnce();
  18575. const {
  18576. t: t2
  18577. } = useI18n();
  18578. return () => createVNode("div", {
  18579. "class": "uni-async-error",
  18580. "onClick": reload
  18581. }, [t2("uni.async.error")], 8, ["onClick"]);
  18582. }
  18583. });
  18584. let appVm;
  18585. function getApp$1() {
  18586. return appVm;
  18587. }
  18588. function initApp(vm) {
  18589. appVm = vm;
  18590. Object.defineProperty(appVm.$.ctx, "$children", {
  18591. get() {
  18592. return getCurrentPages().map((page) => page.$vm);
  18593. }
  18594. });
  18595. const app = appVm.$.appContext.app;
  18596. if (!app.component(AsyncLoadingComponent.name)) {
  18597. app.component(AsyncLoadingComponent.name, AsyncLoadingComponent);
  18598. }
  18599. if (!app.component(AsyncErrorComponent.name)) {
  18600. app.component(AsyncErrorComponent.name, AsyncErrorComponent);
  18601. }
  18602. initAppVm(appVm);
  18603. defineGlobalData(appVm);
  18604. initService();
  18605. initView();
  18606. }
  18607. function wrapperComponentSetup(comp, { clone, init: init2, setup, before }) {
  18608. if (clone) {
  18609. comp = extend({}, comp);
  18610. }
  18611. before && before(comp);
  18612. const oldSetup = comp.setup;
  18613. comp.setup = (props2, ctx) => {
  18614. const instance2 = getCurrentInstance();
  18615. init2(instance2.proxy);
  18616. const query = setup(instance2);
  18617. if (oldSetup) {
  18618. return oldSetup(query || props2, ctx);
  18619. }
  18620. };
  18621. return comp;
  18622. }
  18623. function setupComponent(comp, options) {
  18624. if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
  18625. return wrapperComponentSetup(comp.default, options);
  18626. }
  18627. return wrapperComponentSetup(comp, options);
  18628. }
  18629. function setupWindow(comp, id2) {
  18630. return setupComponent(comp, {
  18631. init: (vm) => {
  18632. vm.$page = {
  18633. id: id2
  18634. };
  18635. },
  18636. setup(instance2) {
  18637. instance2.$pageInstance = instance2;
  18638. }
  18639. });
  18640. }
  18641. function setupPage(comp) {
  18642. if (process.env.NODE_ENV !== "production") {
  18643. comp.__mpType = "page";
  18644. }
  18645. return setupComponent(comp, {
  18646. clone: true,
  18647. // 页面组件可能会被其他地方手动引用,比如 windows 等,需要 clone 一份新的作为页面组件
  18648. init: initPage,
  18649. setup(instance2) {
  18650. instance2.$pageInstance = instance2;
  18651. const route = usePageRoute();
  18652. const query = decodedQuery(route.query);
  18653. instance2.attrs.__pageQuery = query;
  18654. instance2.proxy.$page.options = query;
  18655. instance2.proxy.options = query;
  18656. const pageMeta = usePageMeta();
  18657. instance2.onReachBottom = reactive([]);
  18658. instance2.onPageScroll = reactive([]);
  18659. watch(
  18660. [instance2.onReachBottom, instance2.onPageScroll],
  18661. () => {
  18662. if (instance2.proxy === getCurrentPage()) {
  18663. initPageScrollListener(instance2, pageMeta);
  18664. }
  18665. },
  18666. { once: true }
  18667. );
  18668. onBeforeMount(() => {
  18669. onPageShow(instance2, pageMeta);
  18670. });
  18671. onMounted(() => {
  18672. onPageReady(instance2);
  18673. const { onReady } = instance2;
  18674. onReady && invokeArrayFns$1(onReady);
  18675. invokeOnTabItemTap(route);
  18676. });
  18677. onBeforeActivate(() => {
  18678. if (!instance2.__isVisible) {
  18679. onPageShow(instance2, pageMeta);
  18680. instance2.__isVisible = true;
  18681. const { onShow } = instance2;
  18682. onShow && invokeArrayFns$1(onShow);
  18683. nextTick(() => {
  18684. invokeOnTabItemTap(route);
  18685. });
  18686. }
  18687. });
  18688. onBeforeDeactivate(() => {
  18689. if (instance2.__isVisible && !instance2.__isUnload) {
  18690. instance2.__isVisible = false;
  18691. const { onHide } = instance2;
  18692. onHide && invokeArrayFns$1(onHide);
  18693. }
  18694. });
  18695. subscribeViewMethod(pageMeta.id);
  18696. onBeforeUnmount(() => {
  18697. unsubscribeViewMethod(pageMeta.id);
  18698. });
  18699. return query;
  18700. }
  18701. });
  18702. }
  18703. function setupApp(comp) {
  18704. if (process.env.NODE_ENV !== "production") {
  18705. comp.__mpType = "app";
  18706. }
  18707. return setupComponent(comp, {
  18708. init: initApp,
  18709. setup(instance2) {
  18710. const route = usePageRoute();
  18711. const onLaunch = () => {
  18712. injectAppHooks(instance2);
  18713. const { onLaunch: onLaunch2, onShow, onPageNotFound: onPageNotFound2, onError: onError2 } = instance2;
  18714. const path = route.path.slice(1);
  18715. const launchOptions2 = initLaunchOptions({
  18716. path: path || __uniRoutes[0].meta.route,
  18717. query: decodedQuery(route.query)
  18718. });
  18719. onLaunch2 && invokeArrayFns$1(onLaunch2, launchOptions2);
  18720. onShow && invokeArrayFns$1(onShow, launchOptions2);
  18721. if (__UNI_FEATURE_PAGES__) {
  18722. if (!route.matched.length) {
  18723. const pageNotFoundOptions = {
  18724. notFound: true,
  18725. openType: "appLaunch",
  18726. path: route.path,
  18727. query: {},
  18728. scene: 1001
  18729. };
  18730. onPageNotFound2 && invokeArrayFns$1(onPageNotFound2, pageNotFoundOptions);
  18731. }
  18732. }
  18733. if (onError2) {
  18734. instance2.appContext.config.errorHandler = (err) => {
  18735. invokeArrayFns$1(onError2, err);
  18736. };
  18737. }
  18738. };
  18739. if (__UNI_FEATURE_PAGES__) {
  18740. useRouter().isReady().then(onLaunch);
  18741. } else {
  18742. onBeforeMount(onLaunch);
  18743. }
  18744. onMounted(() => {
  18745. window.addEventListener(
  18746. "resize",
  18747. debounce(onResize, 50, { setTimeout, clearTimeout })
  18748. );
  18749. window.addEventListener("message", onMessage);
  18750. document.addEventListener("visibilitychange", onVisibilityChange);
  18751. onThemeChange$1();
  18752. });
  18753. return route.query;
  18754. },
  18755. before(comp2) {
  18756. comp2.mpType = "app";
  18757. const { setup } = comp2;
  18758. const render = () => {
  18759. return openBlock(), createBlock(LayoutComponent);
  18760. };
  18761. comp2.setup = (props2, ctx) => {
  18762. const res = setup && setup(props2, ctx);
  18763. return isFunction(res) ? render : res;
  18764. };
  18765. comp2.render = render;
  18766. }
  18767. });
  18768. }
  18769. function onResize() {
  18770. const { windowWidth, windowHeight, screenWidth, screenHeight } = uni.getSystemInfoSync();
  18771. const landscape = Math.abs(Number(window.orientation)) === 90;
  18772. const deviceOrientation = landscape ? "landscape" : "portrait";
  18773. UniServiceJSBridge.emit(ON_RESIZE, {
  18774. deviceOrientation,
  18775. size: {
  18776. windowWidth,
  18777. windowHeight,
  18778. screenWidth,
  18779. screenHeight
  18780. }
  18781. });
  18782. }
  18783. function onMessage(evt) {
  18784. if (isPlainObject$1(evt.data) && evt.data.type === WEB_INVOKE_APPSERVICE) {
  18785. UniServiceJSBridge.emit(
  18786. ON_WEB_INVOKE_APP_SERVICE,
  18787. evt.data.data,
  18788. evt.data.pageId
  18789. );
  18790. }
  18791. }
  18792. function onVisibilityChange() {
  18793. const { emit: emit2 } = UniServiceJSBridge;
  18794. if (document.visibilityState === "visible") {
  18795. emit2(ON_APP_ENTER_FOREGROUND, getEnterOptions());
  18796. } else {
  18797. emit2(ON_APP_ENTER_BACKGROUND);
  18798. }
  18799. }
  18800. function onThemeChange$1() {
  18801. let mediaQueryList = null;
  18802. try {
  18803. mediaQueryList = window.matchMedia("(prefers-color-scheme: dark)");
  18804. } catch (error) {
  18805. }
  18806. if (mediaQueryList) {
  18807. let callback = (e2) => {
  18808. UniServiceJSBridge.emit(ON_THEME_CHANGE, {
  18809. theme: e2.matches ? "dark" : "light"
  18810. });
  18811. };
  18812. if (mediaQueryList.addEventListener) {
  18813. mediaQueryList.addEventListener("change", callback);
  18814. } else {
  18815. mediaQueryList.addListener(callback);
  18816. }
  18817. }
  18818. }
  18819. function invokeOnTabItemTap(route) {
  18820. const { tabBarText, tabBarIndex, route: pagePath } = route.meta;
  18821. if (tabBarText) {
  18822. invokeHook("onTabItemTap", {
  18823. index: tabBarIndex,
  18824. text: tabBarText,
  18825. pagePath
  18826. });
  18827. }
  18828. }
  18829. function formatTime(val) {
  18830. val = val > 0 && val < Infinity ? val : 0;
  18831. const h2 = Math.floor(val / 3600);
  18832. const m = Math.floor(val % 3600 / 60);
  18833. const s = Math.floor(val % 3600 % 60);
  18834. const hStr = (h2 < 10 ? "0" : "") + h2;
  18835. const mStr = (m < 10 ? "0" : "") + m;
  18836. const sStr = (s < 10 ? "0" : "") + s;
  18837. let str = mStr + ":" + sStr;
  18838. if (hStr !== "00") {
  18839. str = hStr + ":" + str;
  18840. }
  18841. return str;
  18842. }
  18843. function useGesture(props2, videoRef, fullscreenState) {
  18844. const state2 = reactive({
  18845. gestureType: "none",
  18846. volumeOld: 0,
  18847. volumeNew: 0,
  18848. currentTimeOld: 0,
  18849. currentTimeNew: 0
  18850. });
  18851. const touchStartOrigin = {
  18852. x: 0,
  18853. y: 0
  18854. };
  18855. function onTouchstart(event) {
  18856. const toucher = event.targetTouches[0];
  18857. touchStartOrigin.x = toucher.pageX;
  18858. touchStartOrigin.y = toucher.pageY;
  18859. state2.gestureType = "none";
  18860. state2.volumeOld = 0;
  18861. state2.currentTimeOld = state2.currentTimeNew = 0;
  18862. }
  18863. function onTouchmove(event) {
  18864. function stop() {
  18865. event.stopPropagation();
  18866. event.preventDefault();
  18867. }
  18868. if (fullscreenState.fullscreen) {
  18869. stop();
  18870. }
  18871. const gestureType = state2.gestureType;
  18872. if (gestureType === "stop") {
  18873. return;
  18874. }
  18875. const toucher = event.targetTouches[0];
  18876. const pageX = toucher.pageX;
  18877. const pageY = toucher.pageY;
  18878. const origin = touchStartOrigin;
  18879. const video = videoRef.value;
  18880. if (gestureType === "progress") {
  18881. changeProgress(pageX - origin.x);
  18882. } else if (gestureType === "volume") {
  18883. changeVolume(pageY - origin.y);
  18884. }
  18885. if (gestureType !== "none") {
  18886. return;
  18887. }
  18888. if (Math.abs(pageX - origin.x) > Math.abs(pageY - origin.y)) {
  18889. if (!props2.enableProgressGesture) {
  18890. state2.gestureType = "stop";
  18891. return;
  18892. }
  18893. state2.gestureType = "progress";
  18894. state2.currentTimeOld = state2.currentTimeNew = video.currentTime;
  18895. if (!fullscreenState.fullscreen) {
  18896. stop();
  18897. }
  18898. } else {
  18899. if (!props2.pageGesture) {
  18900. state2.gestureType = "stop";
  18901. return;
  18902. }
  18903. state2.gestureType = "volume";
  18904. state2.volumeOld = video.volume;
  18905. if (!fullscreenState.fullscreen) {
  18906. stop();
  18907. }
  18908. }
  18909. }
  18910. function onTouchend(event) {
  18911. const video = videoRef.value;
  18912. if (state2.gestureType !== "none" && state2.gestureType !== "stop") {
  18913. event.stopPropagation();
  18914. event.preventDefault();
  18915. }
  18916. if (state2.gestureType === "progress" && state2.currentTimeOld !== state2.currentTimeNew) {
  18917. video.currentTime = state2.currentTimeNew;
  18918. }
  18919. state2.gestureType = "none";
  18920. }
  18921. function changeProgress(x) {
  18922. const video = videoRef.value;
  18923. const duration = video.duration;
  18924. let currentTimeNew = x / 600 * duration + state2.currentTimeOld;
  18925. if (currentTimeNew < 0) {
  18926. currentTimeNew = 0;
  18927. } else if (currentTimeNew > duration) {
  18928. currentTimeNew = duration;
  18929. }
  18930. state2.currentTimeNew = currentTimeNew;
  18931. }
  18932. function changeVolume(y) {
  18933. const video = videoRef.value;
  18934. const valueOld = state2.volumeOld;
  18935. let value;
  18936. if (typeof valueOld === "number") {
  18937. value = valueOld - y / 200;
  18938. if (value < 0) {
  18939. value = 0;
  18940. } else if (value > 1) {
  18941. value = 1;
  18942. }
  18943. video.volume = value;
  18944. state2.volumeNew = value;
  18945. }
  18946. }
  18947. return {
  18948. state: state2,
  18949. onTouchstart,
  18950. onTouchmove,
  18951. onTouchend
  18952. };
  18953. }
  18954. function useFullscreen(trigger, containerRef, videoRef, userActionState, rootRef) {
  18955. const state2 = reactive({
  18956. fullscreen: false
  18957. });
  18958. const isSafari = /^Apple/.test(navigator.vendor);
  18959. function onFullscreenChange($event, webkit) {
  18960. if (webkit && document.fullscreenEnabled) {
  18961. return;
  18962. }
  18963. emitFullscreenChange(!!(document.fullscreenElement || document.webkitFullscreenElement));
  18964. }
  18965. function emitFullscreenChange(val) {
  18966. state2.fullscreen = val;
  18967. trigger("fullscreenchange", {}, {
  18968. fullScreen: val,
  18969. direction: "vertical"
  18970. });
  18971. }
  18972. function toggleFullscreen(val) {
  18973. const root = rootRef.value;
  18974. const container = containerRef.value;
  18975. const video = videoRef.value;
  18976. let mockFullScreen;
  18977. if (val) {
  18978. if ((document.fullscreenEnabled || document.webkitFullscreenEnabled) && (!isSafari || userActionState.userAction)) {
  18979. container[document.fullscreenEnabled ? "requestFullscreen" : "webkitRequestFullscreen"]();
  18980. } else if (video.webkitEnterFullScreen) {
  18981. video.webkitEnterFullScreen();
  18982. } else {
  18983. mockFullScreen = true;
  18984. container.remove();
  18985. container.classList.add("uni-video-type-fullscreen");
  18986. document.body.appendChild(container);
  18987. }
  18988. } else {
  18989. if (document.fullscreenEnabled || document.webkitFullscreenEnabled) {
  18990. if (document.fullscreenElement) {
  18991. document.exitFullscreen();
  18992. } else if (document.webkitFullscreenElement) {
  18993. document.webkitExitFullscreen();
  18994. }
  18995. } else if (video.webkitExitFullScreen) {
  18996. video.webkitExitFullScreen();
  18997. } else {
  18998. mockFullScreen = true;
  18999. container.remove();
  19000. container.classList.remove("uni-video-type-fullscreen");
  19001. root.appendChild(container);
  19002. }
  19003. }
  19004. if (mockFullScreen) {
  19005. emitFullscreenChange(val);
  19006. }
  19007. }
  19008. function requestFullScreen() {
  19009. toggleFullscreen(true);
  19010. }
  19011. function exitFullScreen() {
  19012. toggleFullscreen(false);
  19013. }
  19014. onBeforeUnmount(exitFullScreen);
  19015. return {
  19016. state: state2,
  19017. onFullscreenChange,
  19018. emitFullscreenChange,
  19019. toggleFullscreen,
  19020. requestFullScreen,
  19021. exitFullScreen
  19022. };
  19023. }
  19024. function useVideo(props2, attrs2, trigger) {
  19025. const videoRef = ref(null);
  19026. const src = computed(() => getRealPath(props2.src));
  19027. const muted = computed(() => props2.muted === "true" || props2.muted === true);
  19028. const state2 = reactive({
  19029. start: false,
  19030. src,
  19031. playing: false,
  19032. currentTime: 0,
  19033. duration: 0,
  19034. progress: 0,
  19035. buffered: 0,
  19036. muted
  19037. });
  19038. watch(() => src.value, () => {
  19039. state2.playing = false;
  19040. state2.currentTime = 0;
  19041. });
  19042. watch(() => state2.buffered, (buffered) => {
  19043. trigger("progress", {}, {
  19044. buffered
  19045. });
  19046. });
  19047. watch(() => muted.value, (muted2) => {
  19048. const video = videoRef.value;
  19049. video.muted = muted2;
  19050. });
  19051. function onDurationChange({
  19052. target
  19053. }) {
  19054. state2.duration = target.duration;
  19055. }
  19056. function onLoadedMetadata($event) {
  19057. const initialTime = Number(props2.initialTime) || 0;
  19058. const video = $event.target;
  19059. if (initialTime > 0) {
  19060. video.currentTime = initialTime;
  19061. }
  19062. trigger("loadedmetadata", $event, {
  19063. width: video.videoWidth,
  19064. height: video.videoHeight,
  19065. duration: video.duration
  19066. });
  19067. onProgress($event);
  19068. }
  19069. function onProgress($event) {
  19070. const video = $event.target;
  19071. const buffered = video.buffered;
  19072. if (buffered.length) {
  19073. state2.buffered = buffered.end(buffered.length - 1) / video.duration * 100;
  19074. }
  19075. }
  19076. function onWaiting($event) {
  19077. trigger("waiting", $event, {});
  19078. }
  19079. function onVideoError($event) {
  19080. state2.playing = false;
  19081. trigger("error", $event, {});
  19082. }
  19083. function onPlay($event) {
  19084. state2.start = true;
  19085. state2.playing = true;
  19086. trigger("play", $event, {});
  19087. }
  19088. function onPause($event) {
  19089. state2.playing = false;
  19090. trigger("pause", $event, {});
  19091. }
  19092. function onEnded($event) {
  19093. state2.playing = false;
  19094. trigger("ended", $event, {});
  19095. }
  19096. function onTimeUpdate($event) {
  19097. const video = $event.target;
  19098. const currentTime = state2.currentTime = video.currentTime;
  19099. trigger("timeupdate", $event, {
  19100. currentTime,
  19101. duration: video.duration
  19102. });
  19103. }
  19104. function toggle() {
  19105. const video = videoRef.value;
  19106. if (state2.playing) {
  19107. video.pause();
  19108. } else {
  19109. video.play();
  19110. }
  19111. }
  19112. function play() {
  19113. const video = videoRef.value;
  19114. state2.start = true;
  19115. video.play();
  19116. }
  19117. function pause() {
  19118. const video = videoRef.value;
  19119. video.pause();
  19120. }
  19121. function seek(position) {
  19122. const video = videoRef.value;
  19123. position = Number(position);
  19124. if (typeof position === "number" && !isNaN(position)) {
  19125. video.currentTime = position;
  19126. }
  19127. }
  19128. function stop() {
  19129. seek(0);
  19130. pause();
  19131. }
  19132. function playbackRate(rate) {
  19133. const video = videoRef.value;
  19134. video.playbackRate = rate;
  19135. }
  19136. return {
  19137. videoRef,
  19138. state: state2,
  19139. play,
  19140. pause,
  19141. stop,
  19142. seek,
  19143. playbackRate,
  19144. toggle,
  19145. onDurationChange,
  19146. onLoadedMetadata,
  19147. onProgress,
  19148. onWaiting,
  19149. onVideoError,
  19150. onPlay,
  19151. onPause,
  19152. onEnded,
  19153. onTimeUpdate
  19154. };
  19155. }
  19156. function useControls(props2, videoState, seek) {
  19157. const progressRef = ref(null);
  19158. const ballRef = ref(null);
  19159. const centerPlayBtnShow = computed(() => props2.showCenterPlayBtn && !videoState.start);
  19160. const controlsVisible = ref(true);
  19161. const controlsShow = computed(() => !centerPlayBtnShow.value && props2.controls && controlsVisible.value);
  19162. const state2 = reactive({
  19163. touching: false,
  19164. controlsTouching: false,
  19165. centerPlayBtnShow,
  19166. controlsShow,
  19167. controlsVisible
  19168. });
  19169. function clickProgress(event) {
  19170. const $progress = progressRef.value;
  19171. let element = event.target;
  19172. let x = event.offsetX;
  19173. while (element && element !== $progress) {
  19174. x += element.offsetLeft;
  19175. element = element.parentNode;
  19176. }
  19177. const w = $progress.offsetWidth;
  19178. let progress = 0;
  19179. if (x >= 0 && x <= w) {
  19180. progress = x / w;
  19181. seek(videoState.duration * progress);
  19182. }
  19183. }
  19184. function toggleControls() {
  19185. state2.controlsVisible = !state2.controlsVisible;
  19186. }
  19187. let hideTiming;
  19188. function autoHideStart() {
  19189. hideTiming = setTimeout(() => {
  19190. state2.controlsVisible = false;
  19191. }, 3e3);
  19192. }
  19193. function autoHideEnd() {
  19194. if (hideTiming) {
  19195. clearTimeout(hideTiming);
  19196. hideTiming = null;
  19197. }
  19198. }
  19199. onBeforeUnmount(() => {
  19200. if (hideTiming) {
  19201. clearTimeout(hideTiming);
  19202. }
  19203. });
  19204. watch(() => state2.controlsShow && videoState.playing && !state2.controlsTouching, (val) => {
  19205. if (val) {
  19206. autoHideStart();
  19207. } else {
  19208. autoHideEnd();
  19209. }
  19210. });
  19211. watch([() => videoState.currentTime, () => {
  19212. props2.duration;
  19213. }], function updateProgress() {
  19214. if (!state2.touching) {
  19215. videoState.progress = videoState.currentTime / videoState.duration * 100;
  19216. }
  19217. });
  19218. onMounted(() => {
  19219. const passiveOptions2 = passive(false);
  19220. let originX;
  19221. let originY;
  19222. let moveOnce = true;
  19223. let originProgress;
  19224. const ball = ballRef.value;
  19225. function touchmove2(event) {
  19226. const toucher = event.targetTouches[0];
  19227. const pageX = toucher.pageX;
  19228. const pageY = toucher.pageY;
  19229. if (moveOnce && Math.abs(pageX - originX) < Math.abs(pageY - originY)) {
  19230. touchend(event);
  19231. return;
  19232. }
  19233. moveOnce = false;
  19234. const progressEl = progressRef.value;
  19235. const w = progressEl.offsetWidth;
  19236. let progress = originProgress + (pageX - originX) / w * 100;
  19237. if (progress < 0) {
  19238. progress = 0;
  19239. } else if (progress > 100) {
  19240. progress = 100;
  19241. }
  19242. videoState.progress = progress;
  19243. event.preventDefault();
  19244. event.stopPropagation();
  19245. }
  19246. function touchend(event) {
  19247. state2.controlsTouching = false;
  19248. if (state2.touching) {
  19249. ball.removeEventListener("touchmove", touchmove2, passiveOptions2);
  19250. if (!moveOnce) {
  19251. event.preventDefault();
  19252. event.stopPropagation();
  19253. seek(videoState.duration * videoState.progress / 100);
  19254. }
  19255. state2.touching = false;
  19256. }
  19257. }
  19258. ball.addEventListener("touchstart", (event) => {
  19259. state2.controlsTouching = true;
  19260. const toucher = event.targetTouches[0];
  19261. originX = toucher.pageX;
  19262. originY = toucher.pageY;
  19263. originProgress = videoState.progress;
  19264. moveOnce = true;
  19265. state2.touching = true;
  19266. ball.addEventListener("touchmove", touchmove2, passiveOptions2);
  19267. });
  19268. ball.addEventListener("touchend", touchend);
  19269. ball.addEventListener("touchcancel", touchend);
  19270. });
  19271. return {
  19272. state: state2,
  19273. progressRef,
  19274. ballRef,
  19275. clickProgress,
  19276. toggleControls,
  19277. autoHideStart,
  19278. autoHideEnd
  19279. };
  19280. }
  19281. function useDanmu(props2, videoState) {
  19282. const danmuRef = ref(null);
  19283. const state2 = reactive({
  19284. enable: Boolean(props2.enableDanmu)
  19285. });
  19286. let danmuIndex = {
  19287. time: 0,
  19288. index: -1
  19289. };
  19290. const danmuList = isArray(props2.danmuList) ? JSON.parse(JSON.stringify(props2.danmuList)) : [];
  19291. danmuList.sort(function(a2, b) {
  19292. return (a2.time || 0) - (b.time || 0);
  19293. });
  19294. function toggleDanmu() {
  19295. state2.enable = !state2.enable;
  19296. }
  19297. function updateDanmu(event) {
  19298. const video = event.target;
  19299. const currentTime = video.currentTime;
  19300. const oldDanmuIndex = danmuIndex;
  19301. const newDanmuIndex = {
  19302. time: currentTime,
  19303. index: oldDanmuIndex.index
  19304. };
  19305. if (currentTime > oldDanmuIndex.time) {
  19306. for (let index2 = oldDanmuIndex.index + 1; index2 < danmuList.length; index2++) {
  19307. const element = danmuList[index2];
  19308. if (currentTime >= (element.time || 0)) {
  19309. newDanmuIndex.index = index2;
  19310. if (videoState.playing && state2.enable) {
  19311. playDanmu(element);
  19312. }
  19313. } else {
  19314. break;
  19315. }
  19316. }
  19317. } else if (currentTime < oldDanmuIndex.time) {
  19318. for (let index2 = oldDanmuIndex.index - 1; index2 > -1; index2--) {
  19319. const element = danmuList[index2];
  19320. if (currentTime <= (element.time || 0)) {
  19321. newDanmuIndex.index = index2 - 1;
  19322. } else {
  19323. break;
  19324. }
  19325. }
  19326. }
  19327. danmuIndex = newDanmuIndex;
  19328. }
  19329. function playDanmu(danmu) {
  19330. const p2 = document.createElement("p");
  19331. p2.className = "uni-video-danmu-item";
  19332. p2.innerText = danmu.text;
  19333. let style = `bottom: ${Math.random() * 100}%;color: ${danmu.color};`;
  19334. p2.setAttribute("style", style);
  19335. const danmuEl = danmuRef.value;
  19336. danmuEl.appendChild(p2);
  19337. setTimeout(function() {
  19338. style += "left: 0;-webkit-transform: translateX(-100%);transform: translateX(-100%);";
  19339. p2.setAttribute("style", style);
  19340. setTimeout(function() {
  19341. p2.remove();
  19342. }, 4e3);
  19343. }, 17);
  19344. }
  19345. function sendDanmu(danmu) {
  19346. danmuList.splice(danmuIndex.index + 1, 0, {
  19347. text: String(danmu.text),
  19348. color: danmu.color,
  19349. time: videoState.currentTime || 0
  19350. });
  19351. }
  19352. return {
  19353. state: state2,
  19354. danmuRef,
  19355. updateDanmu,
  19356. toggleDanmu,
  19357. sendDanmu
  19358. };
  19359. }
  19360. function useContext(play, pause, stop, seek, sendDanmu, playbackRate, requestFullScreen, exitFullScreen) {
  19361. const methods = {
  19362. play,
  19363. stop,
  19364. pause,
  19365. seek,
  19366. sendDanmu,
  19367. playbackRate,
  19368. requestFullScreen,
  19369. exitFullScreen
  19370. };
  19371. const id2 = useContextInfo();
  19372. useSubscribe((type, data) => {
  19373. let options;
  19374. switch (type) {
  19375. case "seek":
  19376. options = data.position;
  19377. break;
  19378. case "sendDanmu":
  19379. options = data;
  19380. break;
  19381. case "playbackRate":
  19382. options = data.rate;
  19383. break;
  19384. }
  19385. if (type in methods) {
  19386. methods[type](options);
  19387. }
  19388. }, id2, true);
  19389. }
  19390. const props$e = {
  19391. id: {
  19392. type: String,
  19393. default: ""
  19394. },
  19395. src: {
  19396. type: String,
  19397. default: ""
  19398. },
  19399. duration: {
  19400. type: [Number, String],
  19401. default: ""
  19402. },
  19403. controls: {
  19404. type: [Boolean, String],
  19405. default: true
  19406. },
  19407. danmuList: {
  19408. type: Array,
  19409. default() {
  19410. return [];
  19411. }
  19412. },
  19413. danmuBtn: {
  19414. type: [Boolean, String],
  19415. default: false
  19416. },
  19417. enableDanmu: {
  19418. type: [Boolean, String],
  19419. default: false
  19420. },
  19421. autoplay: {
  19422. type: [Boolean, String],
  19423. default: false
  19424. },
  19425. loop: {
  19426. type: [Boolean, String],
  19427. default: false
  19428. },
  19429. muted: {
  19430. type: [Boolean, String],
  19431. default: false
  19432. },
  19433. objectFit: {
  19434. type: String,
  19435. default: "contain"
  19436. },
  19437. poster: {
  19438. type: String,
  19439. default: ""
  19440. },
  19441. direction: {
  19442. type: [String, Number],
  19443. default: ""
  19444. },
  19445. showProgress: {
  19446. type: Boolean,
  19447. default: true
  19448. },
  19449. initialTime: {
  19450. type: [String, Number],
  19451. default: 0
  19452. },
  19453. showFullscreenBtn: {
  19454. type: [Boolean, String],
  19455. default: true
  19456. },
  19457. pageGesture: {
  19458. type: [Boolean, String],
  19459. default: false
  19460. },
  19461. enableProgressGesture: {
  19462. type: [Boolean, String],
  19463. default: true
  19464. },
  19465. showPlayBtn: {
  19466. type: [Boolean, String],
  19467. default: true
  19468. },
  19469. showCenterPlayBtn: {
  19470. type: [Boolean, String],
  19471. default: true
  19472. }
  19473. };
  19474. class UniVideoElement extends UniElement {
  19475. }
  19476. const index$c = /* @__PURE__ */ defineBuiltInComponent({
  19477. name: "Video",
  19478. props: props$e,
  19479. emits: ["fullscreenchange", "progress", "loadedmetadata", "waiting", "error", "play", "pause", "ended", "timeupdate"],
  19480. rootElement: {
  19481. name: "uni-video",
  19482. class: UniVideoElement
  19483. },
  19484. setup(props2, {
  19485. emit: emit2,
  19486. attrs: attrs2,
  19487. slots
  19488. }) {
  19489. const rootRef = ref(null);
  19490. const containerRef = ref(null);
  19491. const trigger = useCustomEvent(rootRef, emit2);
  19492. const {
  19493. state: userActionState
  19494. } = useUserAction();
  19495. const {
  19496. $attrs: videoAttrs
  19497. } = useAttrs({
  19498. excludeListeners: true
  19499. });
  19500. const {
  19501. t: t2
  19502. } = useI18n();
  19503. initI18nVideoMsgsOnce();
  19504. const {
  19505. videoRef,
  19506. state: videoState,
  19507. play,
  19508. pause,
  19509. stop,
  19510. seek,
  19511. playbackRate,
  19512. toggle,
  19513. onDurationChange,
  19514. onLoadedMetadata,
  19515. onProgress,
  19516. onWaiting,
  19517. onVideoError,
  19518. onPlay,
  19519. onPause,
  19520. onEnded,
  19521. onTimeUpdate
  19522. } = useVideo(props2, attrs2, trigger);
  19523. const {
  19524. state: danmuState,
  19525. danmuRef,
  19526. updateDanmu,
  19527. toggleDanmu,
  19528. sendDanmu
  19529. } = useDanmu(props2, videoState);
  19530. const {
  19531. state: fullscreenState,
  19532. onFullscreenChange,
  19533. emitFullscreenChange,
  19534. toggleFullscreen,
  19535. requestFullScreen,
  19536. exitFullScreen
  19537. } = useFullscreen(trigger, containerRef, videoRef, userActionState, rootRef);
  19538. const {
  19539. state: gestureState,
  19540. onTouchstart,
  19541. onTouchend,
  19542. onTouchmove
  19543. } = useGesture(props2, videoRef, fullscreenState);
  19544. const {
  19545. state: controlsState,
  19546. progressRef,
  19547. ballRef,
  19548. clickProgress,
  19549. toggleControls
  19550. } = useControls(props2, videoState, seek);
  19551. useContext(play, pause, stop, seek, sendDanmu, playbackRate, requestFullScreen, exitFullScreen);
  19552. onMounted(() => {
  19553. const rootElement = rootRef.value;
  19554. Object.assign(rootElement, {
  19555. play,
  19556. pause,
  19557. stop,
  19558. seek,
  19559. sendDanmu,
  19560. playbackRate,
  19561. requestFullScreen,
  19562. exitFullScreen
  19563. });
  19564. rootElement.attachVmProps(props2);
  19565. });
  19566. return () => {
  19567. return createVNode("uni-video", {
  19568. "ref": rootRef,
  19569. "id": props2.id,
  19570. "onClick": toggleControls
  19571. }, [createVNode("div", {
  19572. "ref": containerRef,
  19573. "class": "uni-video-container",
  19574. "onTouchstart": onTouchstart,
  19575. "onTouchend": onTouchend,
  19576. "onTouchmove": onTouchmove,
  19577. "onFullscreenchange": withModifiers(onFullscreenChange, ["stop"]),
  19578. "onWebkitfullscreenchange": withModifiers(($event) => onFullscreenChange($event, true), ["stop"])
  19579. }, [createVNode("video", mergeProps({
  19580. "ref": videoRef,
  19581. "style": {
  19582. "object-fit": props2.objectFit
  19583. },
  19584. "muted": !!props2.muted,
  19585. "loop": !!props2.loop,
  19586. "src": videoState.src,
  19587. "poster": props2.poster,
  19588. "autoplay": !!props2.autoplay
  19589. }, videoAttrs.value, {
  19590. "class": "uni-video-video",
  19591. "webkit-playsinline": true,
  19592. "playsinline": true,
  19593. "onDurationchange": onDurationChange,
  19594. "onLoadedmetadata": onLoadedMetadata,
  19595. "onProgress": onProgress,
  19596. "onWaiting": onWaiting,
  19597. "onError": onVideoError,
  19598. "onPlay": onPlay,
  19599. "onPause": onPause,
  19600. "onEnded": onEnded,
  19601. "onTimeupdate": (event) => {
  19602. onTimeUpdate(event);
  19603. updateDanmu(event);
  19604. },
  19605. "onWebkitbeginfullscreen": () => emitFullscreenChange(true),
  19606. "onX5videoenterfullscreen": () => emitFullscreenChange(true),
  19607. "onWebkitendfullscreen": () => emitFullscreenChange(false),
  19608. "onX5videoexitfullscreen": () => emitFullscreenChange(false)
  19609. }), 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", {
  19610. "class": "uni-video-bar uni-video-bar-full",
  19611. "onClick": withModifiers(() => {
  19612. }, ["stop"])
  19613. }, [createVNode("div", {
  19614. "class": "uni-video-controls"
  19615. }, [withDirectives(createVNode("div", {
  19616. "class": {
  19617. "uni-video-control-button": true,
  19618. "uni-video-control-button-play": !videoState.playing,
  19619. "uni-video-control-button-pause": videoState.playing
  19620. },
  19621. "onClick": withModifiers(toggle, ["stop"])
  19622. }, null, 10, ["onClick"]), [[vShow, props2.showPlayBtn]]), withDirectives(createVNode("div", {
  19623. "class": "uni-video-current-time"
  19624. }, [formatTime(videoState.currentTime)], 512), [[vShow, props2.showProgress]]), withDirectives(createVNode("div", {
  19625. "ref": progressRef,
  19626. "class": "uni-video-progress-container",
  19627. "onClick": withModifiers(clickProgress, ["stop"])
  19628. }, [createVNode("div", {
  19629. "class": "uni-video-progress"
  19630. }, [createVNode("div", {
  19631. "style": {
  19632. width: videoState.buffered + "%"
  19633. },
  19634. "class": "uni-video-progress-buffered"
  19635. }, null, 4), createVNode("div", {
  19636. "ref": ballRef,
  19637. "style": {
  19638. left: videoState.progress + "%"
  19639. },
  19640. "class": "uni-video-ball"
  19641. }, [createVNode("div", {
  19642. "class": "uni-video-inner"
  19643. }, null)], 4)])], 8, ["onClick"]), [[vShow, props2.showProgress]]), withDirectives(createVNode("div", {
  19644. "class": "uni-video-duration"
  19645. }, [formatTime(Number(props2.duration) || videoState.duration)], 512), [[vShow, props2.showProgress]])]), withDirectives(createVNode("div", {
  19646. "class": {
  19647. "uni-video-danmu-button": true,
  19648. "uni-video-danmu-button-active": danmuState.enable
  19649. },
  19650. "onClick": withModifiers(toggleDanmu, ["stop"])
  19651. }, [t2("uni.video.danmu")], 10, ["onClick"]), [[vShow, props2.danmuBtn]]), withDirectives(createVNode("div", {
  19652. "class": {
  19653. "uni-video-fullscreen": true,
  19654. "uni-video-type-fullscreen": fullscreenState.fullscreen
  19655. },
  19656. "onClick": withModifiers(() => toggleFullscreen(!fullscreenState.fullscreen), ["stop"])
  19657. }, null, 10, ["onClick"]), [[vShow, props2.showFullscreenBtn]])], 8, ["onClick"]), [[vShow, controlsState.controlsShow]]), withDirectives(createVNode("div", {
  19658. "ref": danmuRef,
  19659. "style": "z-index: 0;",
  19660. "class": "uni-video-danmu"
  19661. }, null, 512), [[vShow, videoState.start && danmuState.enable]]), controlsState.centerPlayBtnShow && createVNode("div", {
  19662. "class": "uni-video-cover",
  19663. "onClick": withModifiers(() => {
  19664. }, ["stop"])
  19665. }, [createVNode("div", {
  19666. "class": "uni-video-cover-play-button",
  19667. "onClick": withModifiers(play, ["stop"])
  19668. }, null, 8, ["onClick"]), createVNode("p", {
  19669. "class": "uni-video-cover-duration"
  19670. }, [formatTime(Number(props2.duration) || videoState.duration)])], 8, ["onClick"]), createVNode("div", {
  19671. "class": {
  19672. "uni-video-toast": true,
  19673. "uni-video-toast-volume": gestureState.gestureType === "volume"
  19674. }
  19675. }, [createVNode("div", {
  19676. "class": "uni-video-toast-title"
  19677. }, [t2("uni.video.volume")]), createVNode("svg", {
  19678. "class": "uni-video-toast-icon",
  19679. "width": "200px",
  19680. "height": "200px",
  19681. "viewBox": "0 0 1024 1024",
  19682. "version": "1.1",
  19683. "xmlns": "http://www.w3.org/2000/svg"
  19684. }, [createVNode("path", {
  19685. "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"
  19686. }, null)]), createVNode("div", {
  19687. "class": "uni-video-toast-value"
  19688. }, [createVNode("div", {
  19689. "style": {
  19690. width: gestureState.volumeNew * 100 + "%"
  19691. },
  19692. "class": "uni-video-toast-value-content"
  19693. }, [createVNode("div", {
  19694. "class": "uni-video-toast-volume-grids"
  19695. }, [renderList(10, () => createVNode("div", {
  19696. "class": "uni-video-toast-volume-grids-item"
  19697. }, null))])], 4)])], 2), createVNode("div", {
  19698. "class": {
  19699. "uni-video-toast": true,
  19700. "uni-video-toast-progress": gestureState.gestureType === "progress"
  19701. }
  19702. }, [createVNode("div", {
  19703. "class": "uni-video-toast-title"
  19704. }, [formatTime(gestureState.currentTimeNew), " / ", formatTime(videoState.duration)])], 2), createVNode("div", {
  19705. "class": "uni-video-slots"
  19706. }, [slots.default && slots.default()])], 40, ["onTouchstart", "onTouchend", "onTouchmove", "onFullscreenchange", "onWebkitfullscreenchange"])], 8, ["id", "onClick"]);
  19707. };
  19708. }
  19709. });
  19710. const onWebInvokeAppService = ({ name, arg }) => {
  19711. if (name === "postMessage")
  19712. ;
  19713. else {
  19714. uni[name](arg);
  19715. }
  19716. };
  19717. const Invoke = /* @__PURE__ */ once(() => UniServiceJSBridge.on(ON_WEB_INVOKE_APP_SERVICE, onWebInvokeAppService));
  19718. const props$d = {
  19719. src: {
  19720. type: String,
  19721. default: ""
  19722. }
  19723. };
  19724. class UniWebViewElement extends UniElement {
  19725. }
  19726. const indexX = /* @__PURE__ */ defineBuiltInComponent({
  19727. inheritAttrs: false,
  19728. name: "WebView",
  19729. props: props$d,
  19730. rootElement: {
  19731. name: "uni-web-view",
  19732. class: UniWebViewElement
  19733. },
  19734. setup(props2) {
  19735. Invoke();
  19736. const rootRef = ref(null);
  19737. const iframeRef = ref(null);
  19738. const {
  19739. $attrs,
  19740. $excludeAttrs,
  19741. $listeners
  19742. } = useAttrs({
  19743. excludeListeners: true
  19744. });
  19745. const renderIframe = () => {
  19746. const iframe = document.createElement("iframe");
  19747. watchEffect(() => {
  19748. for (const key in $attrs.value) {
  19749. if (hasOwn($attrs.value, key)) {
  19750. const attr2 = $attrs.value[key];
  19751. iframe[key] = attr2;
  19752. }
  19753. }
  19754. });
  19755. watchEffect(() => {
  19756. iframe.src = getRealPath(props2.src);
  19757. });
  19758. iframeRef.value = iframe;
  19759. };
  19760. renderIframe();
  19761. onMounted(() => {
  19762. var _a;
  19763. (_a = rootRef.value) == null ? void 0 : _a.appendChild(iframeRef.value);
  19764. });
  19765. onMounted(() => {
  19766. const rootElement = rootRef.value;
  19767. rootElement.attachVmProps(props2);
  19768. });
  19769. return () => {
  19770. return createVNode("uni-web-view", mergeProps({
  19771. "class": "uni-webview"
  19772. }, $listeners.value, $excludeAttrs.value, {
  19773. "ref": rootRef
  19774. }), null, 16);
  19775. };
  19776. }
  19777. });
  19778. let index$b = 0;
  19779. function getJSONP(url, options, success, error) {
  19780. var js = document.createElement("script");
  19781. var callbackKey = options.callback || "callback";
  19782. var callbackName = "__uni_jsonp_callback_" + index$b++;
  19783. var timeout = options.timeout || 3e4;
  19784. var timing;
  19785. function end() {
  19786. clearTimeout(timing);
  19787. delete window[callbackName];
  19788. js.remove();
  19789. }
  19790. window[callbackName] = (res) => {
  19791. if (isFunction(success)) {
  19792. success(res);
  19793. }
  19794. end();
  19795. };
  19796. js.onerror = () => {
  19797. if (isFunction(error)) {
  19798. error();
  19799. }
  19800. end();
  19801. };
  19802. timing = setTimeout(function() {
  19803. if (isFunction(error)) {
  19804. error();
  19805. }
  19806. end();
  19807. }, timeout);
  19808. js.src = url + (url.indexOf("?") >= 0 ? "&" : "?") + callbackKey + "=" + callbackName;
  19809. document.body.appendChild(js);
  19810. }
  19811. function createCallout(maps2) {
  19812. function onAdd() {
  19813. const div = this.div;
  19814. const panes = this.getPanes();
  19815. panes.floatPane.appendChild(div);
  19816. }
  19817. function onRemove() {
  19818. const parentNode = this.div.parentNode;
  19819. if (parentNode) {
  19820. parentNode.removeChild(this.div);
  19821. }
  19822. }
  19823. function createAMapText() {
  19824. const option = this.option;
  19825. this.Text = new maps2.Text({
  19826. text: option.content,
  19827. anchor: "bottom-center",
  19828. // 设置文本标记锚点
  19829. offset: new maps2.Pixel(0, option.offsetY - 16),
  19830. style: {
  19831. padding: (option.padding || 8) + "px",
  19832. "line-height": (option.fontSize || 14) + "px",
  19833. "border-radius": (option.borderRadius || 0) + "px",
  19834. "border-color": `${option.bgColor || "#fff"} transparent transparent`,
  19835. "background-color": option.bgColor || "#fff",
  19836. "box-shadow": "0 2px 6px 0 rgba(114, 124, 245, .5)",
  19837. "text-align": "center",
  19838. "font-size": (option.fontSize || 14) + "px",
  19839. color: option.color || "#000"
  19840. },
  19841. position: option.position
  19842. });
  19843. const event = maps2.event || maps2.Event;
  19844. event.addListener(this.Text, "click", () => {
  19845. this.callback();
  19846. });
  19847. this.Text.setMap(option.map);
  19848. }
  19849. function createBMapText() {
  19850. }
  19851. function removeAMapText() {
  19852. if (this.Text) {
  19853. this.option.map.remove(this.Text);
  19854. }
  19855. }
  19856. function removeBMapText() {
  19857. if (this.Text) {
  19858. this.option.map.remove(this.Text);
  19859. }
  19860. }
  19861. class Callout {
  19862. constructor(option = {}, callback) {
  19863. this.createAMapText = createAMapText;
  19864. this.removeAMapText = removeAMapText;
  19865. this.createBMapText = createBMapText;
  19866. this.removeBMapText = removeBMapText;
  19867. this.onAdd = onAdd;
  19868. this.construct = onAdd;
  19869. this.onRemove = onRemove;
  19870. this.destroy = onRemove;
  19871. this.option = option || {};
  19872. const visible = this.visible = this.alwaysVisible = option.display === "ALWAYS";
  19873. if (getIsAMap()) {
  19874. this.callback = callback;
  19875. if (this.visible) {
  19876. this.createAMapText();
  19877. }
  19878. } else if (getIsBMap()) {
  19879. if (this.visible) {
  19880. this.createBMapText();
  19881. }
  19882. } else {
  19883. const map = option.map;
  19884. this.position = option.position;
  19885. this.index = 1;
  19886. const div = this.div = document.createElement("div");
  19887. const divStyle = div.style;
  19888. divStyle.position = "absolute";
  19889. divStyle.whiteSpace = "nowrap";
  19890. divStyle.transform = "translateX(-50%) translateY(-100%)";
  19891. divStyle.zIndex = "1";
  19892. divStyle.boxShadow = option.boxShadow || "none";
  19893. divStyle.display = visible ? "block" : "none";
  19894. const triangle = this.triangle = document.createElement("div");
  19895. triangle.setAttribute(
  19896. "style",
  19897. "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;"
  19898. );
  19899. this.setStyle(option);
  19900. div.appendChild(triangle);
  19901. if (map) {
  19902. this.setMap(map);
  19903. }
  19904. }
  19905. }
  19906. set onclick(callback) {
  19907. this.div.onclick = callback;
  19908. }
  19909. get onclick() {
  19910. return this.div.onclick;
  19911. }
  19912. setOption(option) {
  19913. this.option = option;
  19914. if (option.display === "ALWAYS") {
  19915. this.alwaysVisible = this.visible = true;
  19916. } else {
  19917. this.alwaysVisible = false;
  19918. }
  19919. if (getIsAMap()) {
  19920. if (this.visible) {
  19921. this.createAMapText();
  19922. }
  19923. } else if (getIsBMap()) {
  19924. if (this.visible) {
  19925. this.createBMapText();
  19926. }
  19927. } else {
  19928. this.setPosition(option.position);
  19929. this.setStyle(option);
  19930. }
  19931. }
  19932. setStyle(option) {
  19933. const div = this.div;
  19934. const divStyle = div.style;
  19935. div.innerText = option.content || "";
  19936. divStyle.lineHeight = (option.fontSize || 14) + "px";
  19937. divStyle.fontSize = (option.fontSize || 14) + "px";
  19938. divStyle.padding = (option.padding || 8) + "px";
  19939. divStyle.color = option.color || "#000";
  19940. divStyle.borderRadius = (option.borderRadius || 0) + "px";
  19941. divStyle.backgroundColor = option.bgColor || "#fff";
  19942. divStyle.marginTop = "-" + ((option.top || 0) + 5) + "px";
  19943. this.triangle.style.borderColor = `${option.bgColor || "#fff"} transparent transparent`;
  19944. }
  19945. setPosition(position) {
  19946. this.position = position;
  19947. this.draw();
  19948. }
  19949. draw() {
  19950. const overlayProjection = this.getProjection();
  19951. if (!this.position || !this.div || !overlayProjection) {
  19952. return;
  19953. }
  19954. const pixel = overlayProjection.fromLatLngToDivPixel(
  19955. this.position
  19956. );
  19957. const divStyle = this.div.style;
  19958. divStyle.left = pixel.x + "px";
  19959. divStyle.top = pixel.y + "px";
  19960. }
  19961. changed() {
  19962. const divStyle = this.div.style;
  19963. divStyle.display = this.visible ? "block" : "none";
  19964. }
  19965. }
  19966. if (!getIsAMap() && !getIsBMap()) {
  19967. const overlay = new (maps2.OverlayView || maps2.Overlay)();
  19968. Callout.prototype.setMap = overlay.setMap;
  19969. Callout.prototype.getMap = overlay.getMap;
  19970. Callout.prototype.getPanes = overlay.getPanes;
  19971. Callout.prototype.getProjection = overlay.getProjection;
  19972. Callout.prototype.map_changed = overlay.map_changed;
  19973. Callout.prototype.set = overlay.set;
  19974. Callout.prototype.get = overlay.get;
  19975. Callout.prototype.setOptions = overlay.setValues;
  19976. Callout.prototype.bindTo = overlay.bindTo;
  19977. Callout.prototype.bindsTo = overlay.bindsTo;
  19978. Callout.prototype.notify = overlay.notify;
  19979. Callout.prototype.setValues = overlay.setValues;
  19980. Callout.prototype.unbind = overlay.unbind;
  19981. Callout.prototype.unbindAll = overlay.unbindAll;
  19982. Callout.prototype.addListener = overlay.addListener;
  19983. }
  19984. return Callout;
  19985. }
  19986. let maps;
  19987. const callbacksMap = {};
  19988. const GOOGLE_MAP_CALLBACKNAME = "__map_callback__";
  19989. function loadMaps(libraries, callback) {
  19990. const mapInfo = getMapInfo();
  19991. if (!mapInfo.key) {
  19992. console.error("Map key not configured.");
  19993. return;
  19994. }
  19995. const callbacks2 = callbacksMap[mapInfo.type] = callbacksMap[mapInfo.type] || [];
  19996. if (maps) {
  19997. callback(maps);
  19998. } else if (window[mapInfo.type] && window[mapInfo.type].maps) {
  19999. maps = getIsAMap() || getIsBMap() ? window[mapInfo.type] : window[mapInfo.type].maps;
  20000. maps.Callout = maps.Callout || createCallout(maps);
  20001. callback(maps);
  20002. } else if (callbacks2.length) {
  20003. callbacks2.push(callback);
  20004. } else {
  20005. callbacks2.push(callback);
  20006. const globalExt = window;
  20007. const callbackName = GOOGLE_MAP_CALLBACKNAME + mapInfo.type;
  20008. globalExt[callbackName] = function() {
  20009. delete globalExt[callbackName];
  20010. maps = getIsAMap() || getIsBMap() ? window[mapInfo.type] : window[mapInfo.type].maps;
  20011. maps.Callout = createCallout(maps);
  20012. callbacks2.forEach((callback2) => callback2(maps));
  20013. callbacks2.length = 0;
  20014. };
  20015. if (getIsAMap()) {
  20016. handleAMapSecurityPolicy(mapInfo);
  20017. }
  20018. const script = document.createElement("script");
  20019. let src = getScriptBaseUrl(mapInfo.type);
  20020. if (mapInfo.type === MapType.QQ) {
  20021. libraries.push("geometry");
  20022. }
  20023. if (libraries.length) {
  20024. src += `libraries=${libraries.join("%2C")}&`;
  20025. }
  20026. if (mapInfo.type === MapType.BMAP) {
  20027. script.src = `${src}ak=${mapInfo.key}&callback=${callbackName}`;
  20028. } else {
  20029. script.src = `${src}key=${mapInfo.key}&callback=${callbackName}`;
  20030. }
  20031. script.onerror = function() {
  20032. console.error("Map load failed.");
  20033. };
  20034. document.body.appendChild(script);
  20035. }
  20036. }
  20037. const getScriptBaseUrl = (mapType) => {
  20038. const urlMap = {
  20039. qq: "https://map.qq.com/api/js?v=2.exp&",
  20040. google: "https://maps.googleapis.com/maps/api/js?",
  20041. AMap: "https://webapi.amap.com/maps?v=2.0&",
  20042. BMapGL: "https://api.map.baidu.com/api?type=webgl&v=1.0&"
  20043. };
  20044. return urlMap[mapType];
  20045. };
  20046. function handleAMapSecurityPolicy(mapInfo) {
  20047. window._AMapSecurityConfig = {
  20048. securityJsCode: mapInfo.securityJsCode || "",
  20049. serviceHost: mapInfo.serviceHost || ""
  20050. };
  20051. }
  20052. 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";
  20053. 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=";
  20054. 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";
  20055. var MapType = /* @__PURE__ */ ((MapType2) => {
  20056. MapType2["QQ"] = "qq";
  20057. MapType2["GOOGLE"] = "google";
  20058. MapType2["AMAP"] = "AMap";
  20059. MapType2["BMAP"] = "BMapGL";
  20060. MapType2["UNKNOWN"] = "";
  20061. return MapType2;
  20062. })(MapType || {});
  20063. function getMapInfo() {
  20064. if (__uniConfig.bMapKey) {
  20065. return {
  20066. type: "BMapGL",
  20067. key: __uniConfig.bMapKey
  20068. };
  20069. }
  20070. if (__uniConfig.qqMapKey) {
  20071. return {
  20072. type: "qq",
  20073. key: __uniConfig.qqMapKey
  20074. };
  20075. }
  20076. if (__uniConfig.googleMapKey) {
  20077. return {
  20078. type: "google",
  20079. key: __uniConfig.googleMapKey
  20080. };
  20081. }
  20082. if (__uniConfig.aMapKey) {
  20083. return {
  20084. type: "AMap",
  20085. key: __uniConfig.aMapKey,
  20086. securityJsCode: __uniConfig.aMapSecurityJsCode,
  20087. serviceHost: __uniConfig.aMapServiceHost
  20088. };
  20089. }
  20090. return {
  20091. type: "",
  20092. key: ""
  20093. };
  20094. }
  20095. let IS_AMAP = false;
  20096. let hasGetIsAMap = false;
  20097. const getIsAMap = () => {
  20098. if (hasGetIsAMap) {
  20099. return IS_AMAP;
  20100. } else {
  20101. hasGetIsAMap = true;
  20102. return IS_AMAP = getMapInfo().type === "AMap";
  20103. }
  20104. };
  20105. const getIsBMap = () => {
  20106. return getMapInfo().type === "BMapGL";
  20107. };
  20108. function translateCoordinateSystem(type, coords, skip) {
  20109. const mapInfo = getMapInfo();
  20110. const wgs84Map = [
  20111. "google"
  20112. /* GOOGLE */
  20113. ];
  20114. if (type && type.toUpperCase() === "WGS84" || wgs84Map.includes(mapInfo.type) || skip) {
  20115. return Promise.resolve(coords);
  20116. }
  20117. if (mapInfo.type === "qq") {
  20118. return new Promise((resolve) => {
  20119. getJSONP(
  20120. `https://apis.map.qq.com/ws/coord/v1/translate?type=1&locations=${coords.latitude},${coords.longitude}&key=${mapInfo.key}&output=jsonp`,
  20121. {
  20122. callback: "callback"
  20123. },
  20124. (res) => {
  20125. if ("locations" in res && res.locations.length) {
  20126. const { lng, lat } = res.locations[0];
  20127. resolve({
  20128. longitude: lng,
  20129. latitude: lat,
  20130. altitude: coords.altitude,
  20131. accuracy: coords.accuracy,
  20132. altitudeAccuracy: coords.altitudeAccuracy,
  20133. heading: coords.heading,
  20134. speed: coords.speed
  20135. });
  20136. } else {
  20137. resolve(coords);
  20138. }
  20139. },
  20140. () => resolve(coords)
  20141. );
  20142. });
  20143. }
  20144. if (mapInfo.type === "AMap") {
  20145. return new Promise((resolve) => {
  20146. loadMaps([], () => {
  20147. window.AMap.convertFrom(
  20148. [coords.longitude, coords.latitude],
  20149. "gps",
  20150. (_, res) => {
  20151. if (res.info === "ok" && res.locations.length) {
  20152. const { lat, lng } = res.locations[0];
  20153. resolve({
  20154. longitude: lng,
  20155. latitude: lat,
  20156. altitude: coords.altitude,
  20157. accuracy: coords.accuracy,
  20158. altitudeAccuracy: coords.altitudeAccuracy,
  20159. heading: coords.heading,
  20160. speed: coords.speed
  20161. });
  20162. } else {
  20163. resolve(coords);
  20164. }
  20165. }
  20166. );
  20167. });
  20168. });
  20169. }
  20170. return Promise.reject(new Error("translate coordinate system faild"));
  20171. }
  20172. const props$c = {
  20173. id: {
  20174. type: [Number, String],
  20175. default: ""
  20176. },
  20177. latitude: {
  20178. type: [Number, String],
  20179. require: true
  20180. },
  20181. longitude: {
  20182. type: [Number, String],
  20183. require: true
  20184. },
  20185. title: {
  20186. type: String,
  20187. default: ""
  20188. },
  20189. iconPath: {
  20190. type: String,
  20191. require: true
  20192. },
  20193. rotate: {
  20194. type: [Number, String],
  20195. default: 0
  20196. },
  20197. alpha: {
  20198. type: [Number, String],
  20199. default: 1
  20200. },
  20201. width: {
  20202. type: [Number, String],
  20203. default: ""
  20204. },
  20205. height: {
  20206. type: [Number, String],
  20207. default: ""
  20208. },
  20209. callout: {
  20210. type: Object,
  20211. default: null
  20212. },
  20213. label: {
  20214. type: Object,
  20215. default: null
  20216. },
  20217. anchor: {
  20218. type: Object,
  20219. default: null
  20220. },
  20221. clusterId: {
  20222. type: [Number, String],
  20223. default: ""
  20224. },
  20225. customCallout: {
  20226. type: Object,
  20227. default: null
  20228. },
  20229. ariaLabel: {
  20230. type: String,
  20231. default: ""
  20232. }
  20233. };
  20234. function useMarkerLabelStyle(id2) {
  20235. const className = "uni-map-marker-label-" + id2;
  20236. const styleEl = document.createElement("style");
  20237. styleEl.id = className;
  20238. document.head.appendChild(styleEl);
  20239. onUnmounted(() => {
  20240. styleEl.remove();
  20241. });
  20242. return function updateMarkerLabelStyle(style) {
  20243. const newStyle = Object.assign({}, style, {
  20244. position: "absolute",
  20245. top: "70px",
  20246. borderStyle: "solid"
  20247. });
  20248. const div = document.createElement("div");
  20249. Object.keys(newStyle).forEach((key) => {
  20250. div.style[key] = newStyle[key] || "";
  20251. });
  20252. styleEl.innerText = `.${className}{${div.getAttribute("style")}}`;
  20253. return className;
  20254. };
  20255. }
  20256. const MapMarker = /* @__PURE__ */ defineSystemComponent({
  20257. name: "MapMarker",
  20258. props: props$c,
  20259. setup(props2) {
  20260. const id2 = String(!isNaN(Number(props2.id)) ? props2.id : "");
  20261. const onMapReady = inject("onMapReady");
  20262. const updateMarkerLabelStyle = useMarkerLabelStyle(id2);
  20263. let marker;
  20264. function removeMarker() {
  20265. if (marker) {
  20266. if (marker.label && "setMap" in marker.label) {
  20267. marker.label.setMap(null);
  20268. }
  20269. if (marker.callout) {
  20270. removeMarkerCallout(marker.callout);
  20271. }
  20272. marker.setMap(null);
  20273. }
  20274. }
  20275. function removeMarkerCallout(callout) {
  20276. if (getIsAMap()) {
  20277. callout.removeAMapText();
  20278. } else {
  20279. callout.setMap(null);
  20280. }
  20281. }
  20282. onMapReady((map, maps2, trigger) => {
  20283. function updateMarker(option) {
  20284. const title = option.title;
  20285. let position;
  20286. if (getIsAMap()) {
  20287. position = new maps2.LngLat(option.longitude, option.latitude);
  20288. } else if (getIsBMap()) {
  20289. position = new maps2.Point(option.longitude, option.latitude);
  20290. } else {
  20291. position = new maps2.LatLng(option.latitude, option.longitude);
  20292. }
  20293. const img = new Image();
  20294. let imgHeight = 0;
  20295. img.onload = () => {
  20296. const anchor = option.anchor || {};
  20297. let icon;
  20298. let w;
  20299. let h2;
  20300. let top;
  20301. let x = typeof anchor.x === "number" ? anchor.x : 0.5;
  20302. let y = typeof anchor.y === "number" ? anchor.y : 1;
  20303. if (option.iconPath && (option.width || option.height)) {
  20304. w = option.width || img.width / img.height * option.height;
  20305. h2 = option.height || img.height / img.width * option.width;
  20306. } else {
  20307. w = img.width / 2;
  20308. h2 = img.height / 2;
  20309. }
  20310. imgHeight = h2;
  20311. top = h2 - (h2 - y * h2);
  20312. if ("MarkerImage" in maps2) {
  20313. icon = new maps2.MarkerImage(img.src, null, null, new maps2.Point(x * w, y * h2), new maps2.Size(w, h2));
  20314. } else if ("Icon" in maps2) {
  20315. icon = new maps2.Icon({
  20316. image: img.src,
  20317. size: new maps2.Size(w, h2),
  20318. imageSize: new maps2.Size(w, h2),
  20319. imageOffset: new maps2.Pixel(x * w, y * h2)
  20320. });
  20321. } else {
  20322. icon = {
  20323. url: img.src,
  20324. anchor: new maps2.Point(x, y),
  20325. size: new maps2.Size(w, h2)
  20326. };
  20327. }
  20328. if (getIsBMap()) {
  20329. marker = new maps2.Marker(new maps2.Point(position.lng, position.lat));
  20330. map.addOverlay(marker);
  20331. } else {
  20332. marker.setPosition(position);
  20333. marker.setIcon(icon);
  20334. }
  20335. if ("setRotation" in marker) {
  20336. marker.setRotation(option.rotate || 0);
  20337. }
  20338. const labelOpt = option.label || {};
  20339. if ("label" in marker) {
  20340. marker.label.setMap(null);
  20341. delete marker.label;
  20342. }
  20343. let label;
  20344. if (labelOpt.content) {
  20345. const labelStyle = {
  20346. borderColor: labelOpt.borderColor,
  20347. borderWidth: (Number(labelOpt.borderWidth) || 0) + "px",
  20348. padding: (Number(labelOpt.padding) || 0) + "px",
  20349. borderRadius: (Number(labelOpt.borderRadius) || 0) + "px",
  20350. backgroundColor: labelOpt.bgColor,
  20351. color: labelOpt.color,
  20352. fontSize: (labelOpt.fontSize || 14) + "px",
  20353. lineHeight: (labelOpt.fontSize || 14) + "px",
  20354. marginLeft: (Number(labelOpt.anchorX || labelOpt.x) || 0) + "px",
  20355. marginTop: (Number(labelOpt.anchorY || labelOpt.y) || 0) + "px"
  20356. };
  20357. if ("Label" in maps2) {
  20358. label = new maps2.Label({
  20359. position,
  20360. map,
  20361. clickable: false,
  20362. content: labelOpt.content,
  20363. style: labelStyle
  20364. });
  20365. marker.label = label;
  20366. } else if ("setLabel" in marker) {
  20367. if (getIsAMap()) {
  20368. const content = `<div style="
  20369. margin-left:${labelStyle.marginLeft};
  20370. margin-top:${labelStyle.marginTop};
  20371. padding:${labelStyle.padding};
  20372. background-color:${labelStyle.backgroundColor};
  20373. border-radius:${labelStyle.borderRadius};
  20374. line-height:${labelStyle.lineHeight};
  20375. color:${labelStyle.color};
  20376. font-size:${labelStyle.fontSize};
  20377. ">
  20378. ${labelOpt.content}
  20379. <div>`;
  20380. marker.setLabel({
  20381. content,
  20382. direction: "bottom-right"
  20383. });
  20384. } else {
  20385. const className = updateMarkerLabelStyle(labelStyle);
  20386. marker.setLabel({
  20387. text: labelOpt.content,
  20388. color: labelStyle.color,
  20389. fontSize: labelStyle.fontSize,
  20390. className
  20391. });
  20392. }
  20393. }
  20394. }
  20395. const calloutOpt = option.callout || {};
  20396. let callout = marker.callout;
  20397. let calloutStyle;
  20398. if (calloutOpt.content || title) {
  20399. if (getIsAMap() && calloutOpt.content) {
  20400. calloutOpt.content = calloutOpt.content.replaceAll("\n", "<br/>");
  20401. }
  20402. const boxShadow = "0px 0px 3px 1px rgba(0,0,0,0.5)";
  20403. let offsetY = -imgHeight / 2;
  20404. if (option.width || option.height) {
  20405. offsetY += 14 - imgHeight / 2;
  20406. }
  20407. calloutStyle = calloutOpt.content ? {
  20408. position,
  20409. map,
  20410. top,
  20411. // handle AMap callout offset
  20412. offsetY,
  20413. content: calloutOpt.content,
  20414. color: calloutOpt.color,
  20415. fontSize: calloutOpt.fontSize,
  20416. borderRadius: calloutOpt.borderRadius,
  20417. bgColor: calloutOpt.bgColor,
  20418. padding: calloutOpt.padding,
  20419. boxShadow: calloutOpt.boxShadow || boxShadow,
  20420. display: calloutOpt.display
  20421. } : {
  20422. position,
  20423. map,
  20424. top,
  20425. // handle AMap callout offset
  20426. offsetY,
  20427. content: title,
  20428. boxShadow
  20429. };
  20430. if (callout) {
  20431. callout.setOption(calloutStyle);
  20432. } else {
  20433. if (getIsAMap()) {
  20434. const callback = () => {
  20435. if (id2 !== "") {
  20436. trigger("callouttap", {}, {
  20437. markerId: Number(id2)
  20438. });
  20439. }
  20440. };
  20441. callout = marker.callout = new maps2.Callout(calloutStyle, callback);
  20442. } else {
  20443. callout = marker.callout = new maps2.Callout(calloutStyle);
  20444. callout.div.onclick = function($event) {
  20445. if (id2 !== "") {
  20446. trigger("callouttap", $event, {
  20447. markerId: Number(id2)
  20448. });
  20449. }
  20450. $event.stopPropagation();
  20451. $event.preventDefault();
  20452. };
  20453. if (getMapInfo().type === MapType.GOOGLE) {
  20454. callout.div.ontouchstart = function($event) {
  20455. $event.stopPropagation();
  20456. };
  20457. callout.div.onpointerdown = function($event) {
  20458. $event.stopPropagation();
  20459. };
  20460. }
  20461. }
  20462. }
  20463. } else {
  20464. if (callout) {
  20465. removeMarkerCallout(callout);
  20466. delete marker.callout;
  20467. }
  20468. }
  20469. };
  20470. if (option.iconPath) {
  20471. img.src = getRealPath(option.iconPath);
  20472. } else {
  20473. console.error("Marker.iconPath is required.");
  20474. }
  20475. }
  20476. function addMarker(props3) {
  20477. if (!getIsBMap()) {
  20478. marker = new maps2.Marker({
  20479. map,
  20480. flat: true,
  20481. autoRotation: false
  20482. });
  20483. }
  20484. updateMarker(props3);
  20485. const MapsEvent = maps2.event || maps2.Event;
  20486. if (getIsBMap())
  20487. ;
  20488. else {
  20489. MapsEvent.addListener(marker, "click", () => {
  20490. const callout = marker.callout;
  20491. if (callout && !callout.alwaysVisible) {
  20492. if (getIsAMap()) {
  20493. callout.visible = !callout.visible;
  20494. if (callout.visible) {
  20495. marker.callout.createAMapText();
  20496. } else {
  20497. marker.callout.removeAMapText();
  20498. }
  20499. } else {
  20500. callout.set("visible", !callout.visible);
  20501. if (callout.visible) {
  20502. const div = callout.div;
  20503. const parent = div.parentNode;
  20504. parent.removeChild(div);
  20505. parent.appendChild(div);
  20506. }
  20507. }
  20508. }
  20509. if (id2) {
  20510. trigger("markertap", {}, {
  20511. markerId: Number(id2),
  20512. latitude: props3.latitude,
  20513. longitude: props3.longitude
  20514. });
  20515. }
  20516. });
  20517. }
  20518. }
  20519. addMarker(props2);
  20520. watch(props2, updateMarker);
  20521. });
  20522. if (id2) {
  20523. const addMapChidlContext = inject("addMapChidlContext");
  20524. const removeMapChidlContext = inject("removeMapChidlContext");
  20525. const context = {
  20526. id: id2,
  20527. translate(data) {
  20528. onMapReady((map, maps2, trigger) => {
  20529. const destination = data.destination;
  20530. const duration = data.duration;
  20531. const autoRotate = !!data.autoRotate;
  20532. let rotate = Number(data.rotate) || 0;
  20533. let rotation = 0;
  20534. if ("getRotation" in marker) {
  20535. rotation = marker.getRotation();
  20536. }
  20537. const a2 = marker.getPosition();
  20538. const b = new maps2.LatLng(destination.latitude, destination.longitude);
  20539. const distance2 = maps2.geometry.spherical.computeDistanceBetween(a2, b) / 1e3;
  20540. const time = (typeof duration === "number" ? duration : 1e3) / (1e3 * 60 * 60);
  20541. const speed = distance2 / time;
  20542. const MapsEvent = maps2.event || maps2.Event;
  20543. const movingEvent = MapsEvent.addListener(marker, "moving", (e2) => {
  20544. const latLng = e2.latLng;
  20545. const label = marker.label;
  20546. if (label) {
  20547. label.setPosition(latLng);
  20548. }
  20549. const callout = marker.callout;
  20550. if (callout) {
  20551. callout.setPosition(latLng);
  20552. }
  20553. });
  20554. const event = MapsEvent.addListener(marker, "moveend", () => {
  20555. event.remove();
  20556. movingEvent.remove();
  20557. marker.lastPosition = a2;
  20558. marker.setPosition(b);
  20559. const label = marker.label;
  20560. if (label) {
  20561. label.setPosition(b);
  20562. }
  20563. const callout = marker.callout;
  20564. if (callout) {
  20565. callout.setPosition(b);
  20566. }
  20567. const cb = data.animationEnd;
  20568. if (isFunction(cb)) {
  20569. cb();
  20570. }
  20571. });
  20572. let lastRtate = 0;
  20573. if (autoRotate) {
  20574. if (marker.lastPosition) {
  20575. lastRtate = maps2.geometry.spherical.computeHeading(marker.lastPosition, a2);
  20576. }
  20577. rotate = maps2.geometry.spherical.computeHeading(a2, b) - lastRtate;
  20578. }
  20579. if ("setRotation" in marker) {
  20580. marker.setRotation(rotation + rotate);
  20581. }
  20582. if ("moveTo" in marker) {
  20583. marker.moveTo(b, speed);
  20584. } else {
  20585. marker.setPosition(b);
  20586. MapsEvent.trigger(marker, "moveend", {});
  20587. }
  20588. });
  20589. }
  20590. };
  20591. addMapChidlContext(context);
  20592. onUnmounted(() => removeMapChidlContext(context));
  20593. }
  20594. onUnmounted(removeMarker);
  20595. return () => {
  20596. return null;
  20597. };
  20598. }
  20599. });
  20600. function hexToRgba(hex) {
  20601. if (!hex) {
  20602. return {
  20603. r: 0,
  20604. g: 0,
  20605. b: 0,
  20606. a: 0
  20607. };
  20608. }
  20609. let tmpHex = hex.slice(1);
  20610. const tmpHexLen = tmpHex.length;
  20611. if (![3, 4, 6, 8].includes(tmpHexLen)) {
  20612. return {
  20613. r: 0,
  20614. g: 0,
  20615. b: 0,
  20616. a: 0
  20617. };
  20618. }
  20619. if (tmpHexLen === 3 || tmpHexLen === 4) {
  20620. tmpHex = tmpHex.replace(/(\w{1})/g, "$1$1");
  20621. }
  20622. let [sr, sg, sb, sa] = tmpHex.match(/(\w{2})/g);
  20623. const r = parseInt(sr, 16), g2 = parseInt(sg, 16), b = parseInt(sb, 16);
  20624. if (!sa) {
  20625. return { r, g: g2, b, a: 1 };
  20626. }
  20627. return {
  20628. r,
  20629. g: g2,
  20630. b,
  20631. a: (`0x100${sa}` - 65536) / 255
  20632. };
  20633. }
  20634. const props$b = {
  20635. points: {
  20636. type: Array,
  20637. require: true
  20638. },
  20639. color: {
  20640. type: String,
  20641. default: "#000000"
  20642. },
  20643. width: {
  20644. type: [Number, String],
  20645. default: ""
  20646. },
  20647. dottedLine: {
  20648. type: [Boolean, String],
  20649. default: false
  20650. },
  20651. arrowLine: {
  20652. type: [Boolean, String],
  20653. default: false
  20654. },
  20655. arrowIconPath: {
  20656. type: String,
  20657. default: ""
  20658. },
  20659. borderColor: {
  20660. type: String,
  20661. default: "#000000"
  20662. },
  20663. borderWidth: {
  20664. type: [Number, String],
  20665. default: ""
  20666. },
  20667. colorList: {
  20668. type: Array,
  20669. default() {
  20670. return [];
  20671. }
  20672. },
  20673. level: {
  20674. type: String,
  20675. default: ""
  20676. }
  20677. };
  20678. const MapPolyline = /* @__PURE__ */ defineSystemComponent({
  20679. name: "MapPolyline",
  20680. props: props$b,
  20681. setup(props2) {
  20682. const onMapReady = inject("onMapReady");
  20683. let polyline;
  20684. let polylineBorder;
  20685. function removePolyline() {
  20686. if (polyline) {
  20687. polyline.setMap(null);
  20688. }
  20689. if (polylineBorder) {
  20690. polylineBorder.setMap(null);
  20691. }
  20692. }
  20693. onMapReady((map, maps2) => {
  20694. function updatePolyline(option) {
  20695. removePolyline();
  20696. addPolyline(option);
  20697. }
  20698. function addPolyline(option) {
  20699. const path = [];
  20700. option.points.forEach((point) => {
  20701. let pointPosition;
  20702. if (getIsAMap()) {
  20703. pointPosition = [point.longitude, point.latitude];
  20704. } else if (getIsBMap()) {
  20705. pointPosition = new maps2.Point(point.longitude, point.latitude);
  20706. } else {
  20707. pointPosition = new maps2.LatLng(point.latitude, point.longitude);
  20708. }
  20709. path.push(pointPosition);
  20710. });
  20711. const strokeWeight = Number(option.width) || 1;
  20712. const {
  20713. r: sr,
  20714. g: sg,
  20715. b: sb,
  20716. a: sa
  20717. } = hexToRgba(option.color);
  20718. const {
  20719. r: br,
  20720. g: bg,
  20721. b: bb,
  20722. a: ba
  20723. } = hexToRgba(option.borderColor);
  20724. const polylineOptions = {
  20725. map,
  20726. clickable: false,
  20727. path,
  20728. strokeWeight,
  20729. strokeColor: option.color || void 0,
  20730. strokeDashStyle: option.dottedLine ? "dash" : "solid"
  20731. };
  20732. const borderWidth = Number(option.borderWidth) || 0;
  20733. const polylineBorderOptions = {
  20734. map,
  20735. clickable: false,
  20736. path,
  20737. strokeWeight: strokeWeight + borderWidth * 2,
  20738. strokeColor: option.borderColor || void 0,
  20739. strokeDashStyle: option.dottedLine ? "dash" : "solid"
  20740. };
  20741. if ("Color" in maps2) {
  20742. polylineOptions.strokeColor = new maps2.Color(sr, sg, sb, sa);
  20743. polylineBorderOptions.strokeColor = new maps2.Color(br, bg, bb, ba);
  20744. } else {
  20745. polylineOptions.strokeColor = `rgb(${sr}, ${sg}, ${sb})`;
  20746. polylineOptions.strokeOpacity = sa;
  20747. polylineBorderOptions.strokeColor = `rgb(${br}, ${bg}, ${bb})`;
  20748. polylineBorderOptions.strokeOpacity = ba;
  20749. }
  20750. if (borderWidth) {
  20751. polylineBorder = new maps2.Polyline(polylineBorderOptions);
  20752. }
  20753. if (getIsBMap()) {
  20754. polyline = new maps2.Polyline(polylineOptions.path, polylineOptions);
  20755. map.addOverlay(polyline);
  20756. } else {
  20757. polyline = new maps2.Polyline(polylineOptions);
  20758. }
  20759. }
  20760. addPolyline(props2);
  20761. watch(props2, updatePolyline);
  20762. });
  20763. onUnmounted(removePolyline);
  20764. return () => {
  20765. return null;
  20766. };
  20767. }
  20768. });
  20769. const props$a = {
  20770. latitude: {
  20771. type: [Number, String],
  20772. require: true
  20773. },
  20774. longitude: {
  20775. type: [Number, String],
  20776. require: true
  20777. },
  20778. color: {
  20779. type: String,
  20780. default: "#000000"
  20781. },
  20782. fillColor: {
  20783. type: String,
  20784. default: "#00000000"
  20785. },
  20786. radius: {
  20787. type: [Number, String],
  20788. require: true
  20789. },
  20790. strokeWidth: {
  20791. type: [Number, String],
  20792. default: ""
  20793. },
  20794. level: {
  20795. type: String,
  20796. default: ""
  20797. }
  20798. };
  20799. const MapCircle = /* @__PURE__ */ defineSystemComponent({
  20800. name: "MapCircle",
  20801. props: props$a,
  20802. setup(props2) {
  20803. const onMapReady = inject("onMapReady");
  20804. let circle;
  20805. function removeCircle() {
  20806. if (circle) {
  20807. circle.setMap(null);
  20808. }
  20809. }
  20810. onMapReady((map, maps2) => {
  20811. function updateCircle(option) {
  20812. removeCircle();
  20813. addCircle(option);
  20814. }
  20815. function addCircle(option) {
  20816. const center = getIsAMap() || getIsBMap() ? [option.longitude, option.latitude] : new maps2.LatLng(option.latitude, option.longitude);
  20817. const circleOptions = {
  20818. map,
  20819. center,
  20820. clickable: false,
  20821. radius: option.radius,
  20822. strokeWeight: Number(option.strokeWidth) || 1,
  20823. strokeDashStyle: "solid"
  20824. };
  20825. if (getIsBMap()) {
  20826. circleOptions.strokeColor = option.color;
  20827. circleOptions.fillColor = option.fillColor || "#000";
  20828. circleOptions.fillOpacity = 1;
  20829. } else {
  20830. const {
  20831. r: fr,
  20832. g: fg,
  20833. b: fb,
  20834. a: fa
  20835. } = hexToRgba(option.fillColor);
  20836. const {
  20837. r: sr,
  20838. g: sg,
  20839. b: sb,
  20840. a: sa
  20841. } = hexToRgba(option.color);
  20842. if ("Color" in maps2) {
  20843. circleOptions.fillColor = new maps2.Color(fr, fg, fb, fa);
  20844. circleOptions.strokeColor = new maps2.Color(sr, sg, sb, sa);
  20845. } else {
  20846. circleOptions.fillColor = `rgb(${fr}, ${fg}, ${fb})`;
  20847. circleOptions.fillOpacity = fa;
  20848. circleOptions.strokeColor = `rgb(${sr}, ${sg}, ${sb})`;
  20849. circleOptions.strokeOpacity = sa;
  20850. }
  20851. }
  20852. if (getIsBMap()) {
  20853. let pt = new maps2.Point(
  20854. // @ts-ignore
  20855. circleOptions.center[0],
  20856. // @ts-ignore
  20857. circleOptions.center[1]
  20858. );
  20859. circle = new maps2.Circle(pt, circleOptions.radius, circleOptions);
  20860. map.addOverlay(circle);
  20861. } else {
  20862. circle = new maps2.Circle(circleOptions);
  20863. if (getIsAMap()) {
  20864. map.add(circle);
  20865. }
  20866. }
  20867. }
  20868. addCircle(props2);
  20869. watch(props2, updateCircle);
  20870. });
  20871. onUnmounted(removeCircle);
  20872. return () => {
  20873. return null;
  20874. };
  20875. }
  20876. });
  20877. const props$9 = {
  20878. id: {
  20879. type: [Number, String],
  20880. default: ""
  20881. },
  20882. position: {
  20883. type: Object,
  20884. required: true
  20885. },
  20886. iconPath: {
  20887. type: String,
  20888. required: true
  20889. },
  20890. clickable: {
  20891. type: [Boolean, String],
  20892. default: ""
  20893. },
  20894. trigger: {
  20895. type: Function,
  20896. required: true
  20897. }
  20898. };
  20899. const MapControl = /* @__PURE__ */ defineSystemComponent({
  20900. name: "MapControl",
  20901. props: props$9,
  20902. setup(props2) {
  20903. const imgPath = computed(() => getRealPath(props2.iconPath));
  20904. const positionStyle = computed(() => {
  20905. let positionStyle2 = `top:${props2.position.top || 0}px;left:${props2.position.left || 0}px;`;
  20906. if (props2.position.width) {
  20907. positionStyle2 += `width:${props2.position.width}px;`;
  20908. }
  20909. if (props2.position.height) {
  20910. positionStyle2 += `height:${props2.position.height}px;`;
  20911. }
  20912. return positionStyle2;
  20913. });
  20914. const handleClick = ($event) => {
  20915. if (props2.clickable) {
  20916. props2.trigger("controltap", $event, {
  20917. controlId: props2.id
  20918. });
  20919. }
  20920. };
  20921. return () => {
  20922. return createVNode("div", {
  20923. "class": "uni-map-control"
  20924. }, [createVNode("img", {
  20925. "src": imgPath.value,
  20926. "style": positionStyle.value,
  20927. "class": "uni-map-control-icon",
  20928. "onClick": handleClick
  20929. }, null, 12, ["src", "onClick"])]);
  20930. };
  20931. }
  20932. });
  20933. const initInnerAudioContextEventOnce = /* @__PURE__ */ once(() => {
  20934. innerAudioContextEventNames.forEach((eventName) => {
  20935. InnerAudioContext.prototype[eventName] = function(callback) {
  20936. if (isFunction(callback)) {
  20937. this._events[eventName].push(callback);
  20938. }
  20939. };
  20940. });
  20941. innerAudioContextOffEventNames.forEach((eventName) => {
  20942. InnerAudioContext.prototype[eventName] = function(callback) {
  20943. var handle = this._events[eventName.replace("off", "on")];
  20944. var index2 = handle.indexOf(callback);
  20945. if (index2 >= 0) {
  20946. handle.splice(index2, 1);
  20947. }
  20948. };
  20949. });
  20950. });
  20951. class InnerAudioContext {
  20952. /**
  20953. * 音频上下文初始化
  20954. */
  20955. constructor() {
  20956. this._src = "";
  20957. var audio = this._audio = new Audio();
  20958. this._stoping = false;
  20959. const propertys = [
  20960. "src",
  20961. "autoplay",
  20962. "loop",
  20963. "duration",
  20964. "currentTime",
  20965. "paused",
  20966. "volume"
  20967. ];
  20968. propertys.forEach((property) => {
  20969. Object.defineProperty(this, property, {
  20970. set: property === "src" ? (src) => {
  20971. audio.src = getRealPath(src);
  20972. this._src = src;
  20973. return src;
  20974. } : (val) => {
  20975. audio[property] = val;
  20976. return val;
  20977. },
  20978. get: property === "src" ? () => {
  20979. return this._src;
  20980. } : () => {
  20981. return audio[property];
  20982. }
  20983. });
  20984. });
  20985. this.startTime = 0;
  20986. Object.defineProperty(this, "obeyMuteSwitch", {
  20987. set: () => false,
  20988. get: () => false
  20989. });
  20990. Object.defineProperty(this, "buffered", {
  20991. get() {
  20992. var buffered = audio.buffered;
  20993. if (buffered.length) {
  20994. return buffered.end(buffered.length - 1);
  20995. } else {
  20996. return 0;
  20997. }
  20998. }
  20999. });
  21000. this._events = {};
  21001. innerAudioContextEventNames.forEach((eventName) => {
  21002. this._events[eventName] = [];
  21003. });
  21004. audio.addEventListener("loadedmetadata", () => {
  21005. var startTime = Number(this.startTime) || 0;
  21006. if (startTime > 0) {
  21007. audio.currentTime = startTime;
  21008. }
  21009. });
  21010. var stopEventNames = ["canplay", "pause", "seeking", "seeked", "timeUpdate"];
  21011. var eventNames = stopEventNames.concat([
  21012. "play",
  21013. "ended",
  21014. "error",
  21015. "waiting"
  21016. ]);
  21017. eventNames.forEach((eventName) => {
  21018. audio.addEventListener(
  21019. eventName.toLowerCase(),
  21020. () => {
  21021. if (this._stoping && stopEventNames.indexOf(eventName) >= 0) {
  21022. return;
  21023. }
  21024. const EventName = `on${eventName.slice(0, 1).toUpperCase()}${eventName.slice(1)}`;
  21025. this._events[EventName].forEach((callback) => {
  21026. callback();
  21027. });
  21028. },
  21029. false
  21030. );
  21031. });
  21032. initInnerAudioContextEventOnce();
  21033. }
  21034. /**
  21035. * 播放
  21036. */
  21037. play() {
  21038. this._stoping = false;
  21039. this._audio.play();
  21040. }
  21041. /**
  21042. * 暂停
  21043. */
  21044. pause() {
  21045. this._audio.pause();
  21046. }
  21047. /**
  21048. * 停止
  21049. */
  21050. stop() {
  21051. this._stoping = true;
  21052. this._audio.pause();
  21053. this._audio.currentTime = 0;
  21054. this._events.onStop.forEach((callback) => {
  21055. callback();
  21056. });
  21057. }
  21058. /**
  21059. * 跳转到
  21060. * @param {number} position
  21061. */
  21062. seek(position) {
  21063. this._stoping = false;
  21064. position = Number(position);
  21065. if (typeof position === "number" && !isNaN(position)) {
  21066. this._audio.currentTime = position;
  21067. }
  21068. }
  21069. /**
  21070. * 销毁
  21071. */
  21072. destroy() {
  21073. this.stop();
  21074. }
  21075. }
  21076. const createInnerAudioContext = /* @__PURE__ */ defineSyncApi(
  21077. API_CREATE_INNER_AUDIO_CONTEXT,
  21078. () => {
  21079. return new InnerAudioContext();
  21080. }
  21081. );
  21082. const makePhoneCall = /* @__PURE__ */ defineAsyncApi(
  21083. API_MAKE_PHONE_CALL,
  21084. ({ phoneNumber }, { resolve }) => {
  21085. window.location.href = `tel:${phoneNumber}`;
  21086. return resolve();
  21087. },
  21088. MakePhoneCallProtocol
  21089. );
  21090. const UUID_KEY = "__DC_STAT_UUID";
  21091. const storage = navigator.cookieEnabled && (window.localStorage || window.sessionStorage) || {};
  21092. let deviceId;
  21093. function deviceId$1() {
  21094. deviceId = deviceId || storage[UUID_KEY];
  21095. if (!deviceId) {
  21096. deviceId = Date.now() + "" + Math.floor(Math.random() * 1e7);
  21097. try {
  21098. storage[UUID_KEY] = deviceId;
  21099. } catch (error) {
  21100. }
  21101. }
  21102. return deviceId;
  21103. }
  21104. const getWindowInfo = /* @__PURE__ */ defineSyncApi(
  21105. "getWindowInfo",
  21106. () => {
  21107. const pixelRatio = window.devicePixelRatio;
  21108. const screenFix = getScreenFix();
  21109. const landscape = isLandscape(screenFix);
  21110. const screenWidth = getScreenWidth(screenFix, landscape);
  21111. const screenHeight = getScreenHeight(screenFix, landscape);
  21112. const windowWidth = getWindowWidth(screenWidth);
  21113. let windowHeight = window.innerHeight;
  21114. const statusBarHeight = safeAreaInsets$1.top;
  21115. const safeArea = {
  21116. left: safeAreaInsets$1.left,
  21117. right: windowWidth - safeAreaInsets$1.right,
  21118. top: safeAreaInsets$1.top,
  21119. bottom: windowHeight - safeAreaInsets$1.bottom,
  21120. width: windowWidth - safeAreaInsets$1.left - safeAreaInsets$1.right,
  21121. height: windowHeight - safeAreaInsets$1.top - safeAreaInsets$1.bottom
  21122. };
  21123. const { top: windowTop, bottom: windowBottom } = getWindowOffset();
  21124. windowHeight -= windowTop;
  21125. windowHeight -= windowBottom;
  21126. return {
  21127. windowTop,
  21128. windowBottom,
  21129. windowWidth,
  21130. windowHeight,
  21131. pixelRatio,
  21132. screenWidth,
  21133. screenHeight,
  21134. statusBarHeight,
  21135. safeArea,
  21136. safeAreaInsets: {
  21137. top: safeAreaInsets$1.top,
  21138. right: safeAreaInsets$1.right,
  21139. bottom: safeAreaInsets$1.bottom,
  21140. left: safeAreaInsets$1.left
  21141. },
  21142. screenTop: screenHeight - windowHeight
  21143. };
  21144. }
  21145. );
  21146. let browserInfo;
  21147. let _initBrowserInfo = true;
  21148. function initBrowserInfo() {
  21149. if (!_initBrowserInfo)
  21150. return;
  21151. browserInfo = getBrowserInfo();
  21152. }
  21153. const getDeviceInfo = /* @__PURE__ */ defineSyncApi(
  21154. "getDeviceInfo",
  21155. () => {
  21156. initBrowserInfo();
  21157. const {
  21158. deviceBrand,
  21159. deviceModel,
  21160. brand,
  21161. model,
  21162. platform,
  21163. system,
  21164. deviceOrientation,
  21165. deviceType,
  21166. osname,
  21167. osversion
  21168. } = browserInfo;
  21169. return extend(
  21170. {
  21171. brand,
  21172. deviceBrand,
  21173. deviceModel,
  21174. devicePixelRatio: window.devicePixelRatio,
  21175. deviceId: deviceId$1(),
  21176. deviceOrientation,
  21177. deviceType,
  21178. model,
  21179. platform,
  21180. system
  21181. },
  21182. {
  21183. osName: osname ? osname.toLocaleLowerCase() : void 0,
  21184. osVersion: osversion
  21185. }
  21186. );
  21187. }
  21188. );
  21189. const getAppBaseInfo = /* @__PURE__ */ defineSyncApi(
  21190. "getAppBaseInfo",
  21191. () => {
  21192. initBrowserInfo();
  21193. const { theme, language, browserName, browserVersion } = browserInfo;
  21194. return extend(
  21195. {
  21196. appId: __uniConfig.appId,
  21197. appName: __uniConfig.appName,
  21198. appVersion: __uniConfig.appVersion,
  21199. appVersionCode: __uniConfig.appVersionCode,
  21200. appLanguage: getLocale ? getLocale() : language,
  21201. enableDebug: false,
  21202. hostSDKVersion: void 0,
  21203. hostPackageName: void 0,
  21204. hostFontSizeSetting: void 0,
  21205. hostName: browserName,
  21206. hostVersion: browserVersion,
  21207. hostTheme: theme,
  21208. hostLanguage: language,
  21209. language,
  21210. SDKVersion: "",
  21211. theme,
  21212. version: ""
  21213. },
  21214. {
  21215. uniCompilerVersion: __uniConfig.compilerVersion,
  21216. uniRuntimeVersion: __uniConfig.compilerVersion,
  21217. uniCompilerVersionCode: parseFloat(__uniConfig.compilerVersion),
  21218. uniRuntimeVersionCode: parseFloat(__uniConfig.compilerVersion),
  21219. isUniAppX: true
  21220. }
  21221. );
  21222. }
  21223. );
  21224. const getSystemInfoSync = /* @__PURE__ */ defineSyncApi(
  21225. "getSystemInfoSync",
  21226. () => {
  21227. _initBrowserInfo = true;
  21228. initBrowserInfo();
  21229. _initBrowserInfo = false;
  21230. const windowInfo = getWindowInfo();
  21231. const deviceInfo = getDeviceInfo();
  21232. const appBaseInfo = getAppBaseInfo();
  21233. _initBrowserInfo = true;
  21234. const { ua: ua2, browserName, browserVersion, osname, osversion } = browserInfo;
  21235. const systemInfo = extend(
  21236. windowInfo,
  21237. deviceInfo,
  21238. appBaseInfo,
  21239. {
  21240. ua: ua2,
  21241. browserName,
  21242. browserVersion,
  21243. uniPlatform: "web",
  21244. uniCompileVersion: __uniConfig.compilerVersion,
  21245. uniRuntimeVersion: __uniConfig.compilerVersion,
  21246. fontSizeSetting: void 0,
  21247. osName: osname.toLocaleLowerCase(),
  21248. osVersion: osversion,
  21249. osLanguage: void 0,
  21250. osTheme: void 0
  21251. }
  21252. );
  21253. delete systemInfo.screenTop;
  21254. delete systemInfo.enableDebug;
  21255. if (!__uniConfig.darkmode)
  21256. delete systemInfo.theme;
  21257. return sortObject(systemInfo);
  21258. }
  21259. );
  21260. const getSystemInfo = /* @__PURE__ */ defineAsyncApi(
  21261. "getSystemInfo",
  21262. (_args, { resolve }) => {
  21263. return resolve(getSystemInfoSync());
  21264. }
  21265. );
  21266. const API_ON_NETWORK_STATUS_CHANGE = "onNetworkStatusChange";
  21267. function networkListener() {
  21268. getNetworkType().then(({ networkType }) => {
  21269. UniServiceJSBridge.invokeOnCallback(
  21270. API_ON_NETWORK_STATUS_CHANGE,
  21271. {
  21272. isConnected: networkType !== "none",
  21273. networkType
  21274. }
  21275. );
  21276. });
  21277. }
  21278. function getConnection() {
  21279. return navigator.connection || navigator.webkitConnection || navigator.mozConnection;
  21280. }
  21281. const onNetworkStatusChange = /* @__PURE__ */ defineOnApi(
  21282. API_ON_NETWORK_STATUS_CHANGE,
  21283. () => {
  21284. const connection = getConnection();
  21285. if (connection) {
  21286. connection.addEventListener("change", networkListener);
  21287. } else {
  21288. window.addEventListener("offline", networkListener);
  21289. window.addEventListener("online", networkListener);
  21290. }
  21291. }
  21292. );
  21293. const offNetworkStatusChange = /* @__PURE__ */ defineOffApi("offNetworkStatusChange", () => {
  21294. const connection = getConnection();
  21295. if (connection) {
  21296. connection.removeEventListener("change", networkListener);
  21297. } else {
  21298. window.removeEventListener("offline", networkListener);
  21299. window.removeEventListener("online", networkListener);
  21300. }
  21301. });
  21302. const getNetworkType = /* @__PURE__ */ defineAsyncApi(
  21303. "getNetworkType",
  21304. (_args, { resolve }) => {
  21305. const connection = getConnection();
  21306. let networkType = "unknown";
  21307. if (connection) {
  21308. networkType = connection.type;
  21309. if (networkType === "cellular" && connection.effectiveType) {
  21310. networkType = connection.effectiveType.replace("slow-", "");
  21311. } else if (!networkType && connection.effectiveType) {
  21312. networkType = connection.effectiveType;
  21313. } else if (!["none", "wifi"].includes(networkType)) {
  21314. networkType = "unknown";
  21315. }
  21316. } else if (navigator.onLine === false) {
  21317. networkType = "none";
  21318. }
  21319. return resolve({ networkType });
  21320. }
  21321. );
  21322. let listener$1 = null;
  21323. const onAccelerometerChange = /* @__PURE__ */ defineOnApi(API_ON_ACCELEROMETER, () => {
  21324. startAccelerometer();
  21325. });
  21326. const offAccelerometerChange = /* @__PURE__ */ defineOffApi(API_OFF_ACCELEROMETER, () => {
  21327. stopAccelerometer();
  21328. });
  21329. const startAccelerometer = /* @__PURE__ */ defineAsyncApi(
  21330. API_START_ACCELEROMETER,
  21331. (_, { resolve, reject }) => {
  21332. if (!window.DeviceMotionEvent) {
  21333. reject();
  21334. return;
  21335. }
  21336. function addEventListener() {
  21337. listener$1 = function(event) {
  21338. const acceleration = event.acceleration || event.accelerationIncludingGravity;
  21339. UniServiceJSBridge.invokeOnCallback(API_ON_ACCELEROMETER, {
  21340. x: acceleration && acceleration.x || 0,
  21341. y: acceleration && acceleration.y || 0,
  21342. z: acceleration && acceleration.z || 0
  21343. });
  21344. };
  21345. window.addEventListener("devicemotion", listener$1, false);
  21346. }
  21347. if (!listener$1) {
  21348. if (DeviceMotionEvent.requestPermission) {
  21349. DeviceMotionEvent.requestPermission().then((res) => {
  21350. if (res === "granted") {
  21351. addEventListener();
  21352. resolve();
  21353. } else {
  21354. reject(`${res}`);
  21355. }
  21356. }).catch((error) => {
  21357. reject(`${error}`);
  21358. });
  21359. return;
  21360. }
  21361. addEventListener();
  21362. }
  21363. resolve();
  21364. }
  21365. );
  21366. const stopAccelerometer = /* @__PURE__ */ defineAsyncApi(
  21367. API_STOP_ACCELEROMETER,
  21368. (_, { resolve }) => {
  21369. if (listener$1) {
  21370. window.removeEventListener("devicemotion", listener$1, false);
  21371. listener$1 = null;
  21372. }
  21373. resolve();
  21374. }
  21375. );
  21376. let listener = null;
  21377. const onCompassChange = /* @__PURE__ */ defineOnApi(
  21378. API_ON_COMPASS,
  21379. () => {
  21380. startCompass();
  21381. }
  21382. );
  21383. const offCompassChange = /* @__PURE__ */ defineOffApi(
  21384. API_OFF_COMPASS,
  21385. () => {
  21386. stopCompass();
  21387. }
  21388. );
  21389. const startCompass = /* @__PURE__ */ defineAsyncApi(
  21390. API_START_COMPASS,
  21391. (_, { resolve, reject }) => {
  21392. if (!window.DeviceOrientationEvent) {
  21393. reject();
  21394. return;
  21395. }
  21396. function addEventListener() {
  21397. listener = function(event) {
  21398. const direction2 = 360 - (event.alpha !== null ? event.alpha : 360);
  21399. UniServiceJSBridge.invokeOnCallback(API_ON_COMPASS, {
  21400. direction: direction2
  21401. });
  21402. };
  21403. window.addEventListener("deviceorientation", listener, false);
  21404. }
  21405. if (!listener) {
  21406. if (DeviceOrientationEvent.requestPermission) {
  21407. DeviceOrientationEvent.requestPermission().then((res) => {
  21408. if (res === "granted") {
  21409. addEventListener();
  21410. resolve();
  21411. } else {
  21412. reject(`${res}`);
  21413. }
  21414. }).catch((error) => {
  21415. reject(`${error}`);
  21416. });
  21417. return;
  21418. }
  21419. addEventListener();
  21420. }
  21421. resolve();
  21422. }
  21423. );
  21424. const stopCompass = /* @__PURE__ */ defineAsyncApi(
  21425. API_STOP_COMPASS,
  21426. (_, { resolve }) => {
  21427. if (listener) {
  21428. window.removeEventListener("deviceorientation", listener, false);
  21429. listener = null;
  21430. }
  21431. resolve();
  21432. }
  21433. );
  21434. const _isSupport = !!window.navigator.vibrate;
  21435. const vibrateShort = /* @__PURE__ */ defineAsyncApi(
  21436. API_VIBRATE_SHORT,
  21437. (args, { resolve, reject }) => {
  21438. if (_isSupport && window.navigator.vibrate(15)) {
  21439. resolve();
  21440. } else {
  21441. reject("vibrateLong:fail");
  21442. }
  21443. }
  21444. );
  21445. const vibrateLong = /* @__PURE__ */ defineAsyncApi(
  21446. API_VIBRATE_LONG,
  21447. (args, { resolve, reject }) => {
  21448. if (_isSupport && window.navigator.vibrate(400)) {
  21449. resolve();
  21450. } else {
  21451. reject("vibrateLong:fail");
  21452. }
  21453. }
  21454. );
  21455. var __async = (__this, __arguments, generator) => {
  21456. return new Promise((resolve, reject) => {
  21457. var fulfilled = (value) => {
  21458. try {
  21459. step(generator.next(value));
  21460. } catch (e2) {
  21461. reject(e2);
  21462. }
  21463. };
  21464. var rejected = (value) => {
  21465. try {
  21466. step(generator.throw(value));
  21467. } catch (e2) {
  21468. reject(e2);
  21469. }
  21470. };
  21471. var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
  21472. step((generator = generator.apply(__this, __arguments)).next());
  21473. });
  21474. };
  21475. const getClipboardData = /* @__PURE__ */ defineAsyncApi(
  21476. API_GET_CLIPBOARD_DATA,
  21477. (_0, _1) => __async(void 0, [_0, _1], function* (_, { resolve, reject }) {
  21478. initI18nGetClipboardDataMsgsOnce();
  21479. const { t: t2 } = useI18n();
  21480. try {
  21481. const data = yield navigator.clipboard.readText();
  21482. resolve({ data });
  21483. } catch (error) {
  21484. _getClipboardData(resolve, () => {
  21485. reject(`${error} ${t2("uni.getClipboardData.fail")}`);
  21486. });
  21487. }
  21488. })
  21489. );
  21490. const setClipboardData = /* @__PURE__ */ defineAsyncApi(
  21491. API_SET_CLIPBOARD_DATA,
  21492. (_0, _1) => __async(void 0, [_0, _1], function* ({ data }, { resolve, reject }) {
  21493. try {
  21494. yield navigator.clipboard.writeText(data);
  21495. resolve();
  21496. } catch (error) {
  21497. _setClipboardData(data, resolve, reject);
  21498. }
  21499. }),
  21500. SetClipboardDataProtocol,
  21501. SetClipboardDataOptions
  21502. );
  21503. function _getClipboardData(resolve, reject) {
  21504. const pasteText = document.getElementById("#clipboard");
  21505. const data = pasteText ? pasteText.value : void 0;
  21506. if (data) {
  21507. resolve({ data });
  21508. } else {
  21509. reject();
  21510. }
  21511. }
  21512. function _setClipboardData(data, resolve, reject) {
  21513. const pasteText = document.getElementById("#clipboard");
  21514. pasteText && pasteText.remove();
  21515. const textarea = document.createElement("textarea");
  21516. textarea.setAttribute("inputmode", "none");
  21517. textarea.id = "#clipboard";
  21518. textarea.style.position = "fixed";
  21519. textarea.style.top = "-9999px";
  21520. textarea.style.zIndex = "-9999";
  21521. document.body.appendChild(textarea);
  21522. textarea.value = data;
  21523. textarea.select();
  21524. textarea.setSelectionRange(0, textarea.value.length);
  21525. const result = document.execCommand("Copy", false);
  21526. textarea.blur();
  21527. if (result) {
  21528. resolve();
  21529. } else {
  21530. reject();
  21531. }
  21532. }
  21533. const themeChangeCallBack = (res) => {
  21534. UniServiceJSBridge.invokeOnCallback(ON_THEME_CHANGE, res);
  21535. };
  21536. const onThemeChange = /* @__PURE__ */ defineOnApi(
  21537. ON_THEME_CHANGE,
  21538. () => {
  21539. UniServiceJSBridge.on(ON_THEME_CHANGE, themeChangeCallBack);
  21540. }
  21541. );
  21542. const offThemeChange = /* @__PURE__ */ defineOffApi(
  21543. OFF_THEME_CHANGE,
  21544. () => {
  21545. UniServiceJSBridge.off(ON_THEME_CHANGE, themeChangeCallBack);
  21546. }
  21547. );
  21548. const STORAGE_KEYS = "uni-storage-keys";
  21549. function parseValue(value) {
  21550. const types = ["object", "string", "number", "boolean", "undefined"];
  21551. try {
  21552. const object = isString(value) ? JSON.parse(value) : value;
  21553. const type = object.type;
  21554. if (types.indexOf(type) >= 0) {
  21555. const keys = Object.keys(object);
  21556. if (keys.length === 2 && "data" in object) {
  21557. if (typeof object.data === type) {
  21558. if (type === "object" && !Array.isArray(object.data)) {
  21559. return new UTSJSONObject(object.data);
  21560. }
  21561. return object.data;
  21562. }
  21563. if (type === "object" && /^\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}\.\d{3}Z$/.test(object.data)) {
  21564. return new Date(object.data);
  21565. }
  21566. } else if (keys.length === 1) {
  21567. return "";
  21568. }
  21569. }
  21570. } catch (error) {
  21571. }
  21572. }
  21573. const setStorageSync = /* @__PURE__ */ defineSyncApi(
  21574. API_SET_STORAGE_SYNC,
  21575. (key, data) => {
  21576. const type = typeof data;
  21577. const value = type === "string" ? data : JSON.stringify({
  21578. type,
  21579. data
  21580. });
  21581. localStorage.setItem(key, value);
  21582. },
  21583. SetStorageSyncProtocol
  21584. );
  21585. const setStorage = /* @__PURE__ */ defineAsyncApi(
  21586. API_SET_STORAGE,
  21587. ({ key, data }, { resolve, reject }) => {
  21588. try {
  21589. setStorageSync(key, data);
  21590. resolve();
  21591. } catch (error) {
  21592. reject(error.message);
  21593. }
  21594. },
  21595. SetStorageProtocol
  21596. );
  21597. function getStorageOrigin(key) {
  21598. const value = localStorage && localStorage.getItem(key);
  21599. if (!isString(value)) {
  21600. throw new Error("data not found");
  21601. }
  21602. let data = value;
  21603. try {
  21604. const object = JSON.parse(value);
  21605. const result = parseValue(object);
  21606. if (result !== void 0) {
  21607. data = result;
  21608. }
  21609. } catch (error) {
  21610. }
  21611. return data;
  21612. }
  21613. const getStorageSync = /* @__PURE__ */ defineSyncApi(
  21614. API_GET_STORAGE_SYNC,
  21615. (key) => {
  21616. try {
  21617. return getStorageOrigin(key);
  21618. } catch (error) {
  21619. return "";
  21620. }
  21621. },
  21622. GetStorageSyncProtocol
  21623. );
  21624. const getStorage = /* @__PURE__ */ defineAsyncApi(
  21625. API_GET_STORAGE,
  21626. ({ key }, { resolve, reject }) => {
  21627. try {
  21628. const data = getStorageOrigin(key);
  21629. resolve({
  21630. data
  21631. });
  21632. } catch (error) {
  21633. reject(error.message);
  21634. }
  21635. },
  21636. GetStorageProtocol
  21637. );
  21638. const removeStorageSync = /* @__PURE__ */ defineSyncApi(
  21639. API_REMOVE_STORAGE,
  21640. (key) => {
  21641. if (localStorage) {
  21642. localStorage.removeItem(key);
  21643. }
  21644. },
  21645. RemoveStorageSyncProtocol
  21646. );
  21647. const removeStorage = /* @__PURE__ */ defineAsyncApi(
  21648. API_REMOVE_STORAGE,
  21649. ({ key }, { resolve }) => {
  21650. removeStorageSync(key);
  21651. resolve();
  21652. },
  21653. RemoveStorageProtocol
  21654. );
  21655. const clearStorageSync = /* @__PURE__ */ defineSyncApi(
  21656. "clearStorageSync",
  21657. () => {
  21658. if (localStorage) {
  21659. localStorage.clear();
  21660. }
  21661. }
  21662. );
  21663. const clearStorage = /* @__PURE__ */ defineAsyncApi(
  21664. "clearStorage",
  21665. (_, { resolve }) => {
  21666. clearStorageSync();
  21667. resolve();
  21668. }
  21669. );
  21670. const getStorageInfoSync = /* @__PURE__ */ defineSyncApi(
  21671. "getStorageInfoSync",
  21672. () => {
  21673. const length = localStorage && localStorage.length || 0;
  21674. const keys = [];
  21675. let currentSize = 0;
  21676. for (let index2 = 0; index2 < length; index2++) {
  21677. const key = localStorage.key(index2);
  21678. const value = localStorage.getItem(key) || "";
  21679. currentSize += key.length + value.length;
  21680. if (key !== STORAGE_KEYS) {
  21681. keys.push(key);
  21682. }
  21683. }
  21684. return {
  21685. keys,
  21686. currentSize: Math.ceil(currentSize * 2 / 1024),
  21687. limitSize: Number.MAX_VALUE
  21688. };
  21689. }
  21690. );
  21691. const getStorageInfo = /* @__PURE__ */ defineAsyncApi(
  21692. "getStorageInfo",
  21693. (_, { resolve }) => {
  21694. resolve(getStorageInfoSync());
  21695. }
  21696. );
  21697. const getFileInfo = /* @__PURE__ */ defineAsyncApi(
  21698. API_GET_FILE_INFO,
  21699. ({ filePath }, { resolve, reject }) => {
  21700. urlToFile(filePath).then((res) => {
  21701. resolve({
  21702. size: res.size
  21703. });
  21704. }).catch((err) => {
  21705. reject(String(err));
  21706. });
  21707. },
  21708. GetFileInfoProtocol,
  21709. GetFileInfoOptions
  21710. );
  21711. const openDocument = /* @__PURE__ */ defineAsyncApi(
  21712. API_OPEN_DOCUMENT,
  21713. ({ filePath }, { resolve }) => {
  21714. window.open(filePath);
  21715. return resolve();
  21716. },
  21717. OpenDocumentProtocol,
  21718. OpenDocumentOptions
  21719. );
  21720. const hideKeyboard = /* @__PURE__ */ defineAsyncApi(
  21721. API_HIDE_KEYBOARD,
  21722. (args, { resolve, reject }) => {
  21723. const activeElement = document.activeElement;
  21724. if (activeElement && (activeElement.tagName === "TEXTAREA" || activeElement.tagName === "INPUT")) {
  21725. activeElement.blur();
  21726. resolve();
  21727. }
  21728. }
  21729. );
  21730. function getServiceAddress() {
  21731. return window.location.protocol + "//" + window.location.host;
  21732. }
  21733. const getImageInfo = /* @__PURE__ */ defineAsyncApi(
  21734. API_GET_IMAGE_INFO,
  21735. ({ src }, { resolve, reject }) => {
  21736. const img = new Image();
  21737. img.onload = function() {
  21738. resolve({
  21739. width: img.naturalWidth,
  21740. height: img.naturalHeight,
  21741. path: src.indexOf("/") === 0 ? getServiceAddress() + src : src
  21742. });
  21743. };
  21744. img.onerror = function() {
  21745. reject();
  21746. };
  21747. img.src = src;
  21748. },
  21749. GetImageInfoProtocol,
  21750. GetImageInfoOptions
  21751. );
  21752. const getVideoInfo = /* @__PURE__ */ defineAsyncApi(
  21753. API_GET_VIDEO_INFO,
  21754. ({ src }, { resolve, reject }) => {
  21755. urlToFile(src, true).then((file) => {
  21756. return file;
  21757. }).catch(() => {
  21758. return null;
  21759. }).then((file) => {
  21760. const video = document.createElement("video");
  21761. if (video.onloadedmetadata !== void 0) {
  21762. const handle = setTimeout(
  21763. () => {
  21764. video.onloadedmetadata = null;
  21765. video.onerror = null;
  21766. reject();
  21767. },
  21768. src.startsWith("data:") || src.startsWith("blob:") ? 300 : 3e3
  21769. );
  21770. video.onloadedmetadata = function() {
  21771. clearTimeout(handle);
  21772. video.onerror = null;
  21773. resolve({
  21774. size: Math.ceil((file ? file.size : 0) / 1024),
  21775. duration: video.duration || 0,
  21776. width: video.videoWidth || 0,
  21777. height: video.videoHeight || 0
  21778. });
  21779. };
  21780. video.onerror = function() {
  21781. clearTimeout(handle);
  21782. video.onloadedmetadata = null;
  21783. reject();
  21784. };
  21785. video.src = src;
  21786. } else {
  21787. reject();
  21788. }
  21789. });
  21790. },
  21791. GetVideoInfoProtocol,
  21792. GetVideoInfoOptions
  21793. );
  21794. const MIMEType = {
  21795. /**
  21796. * 关于图片常见的MIME类型
  21797. */
  21798. image: {
  21799. jpg: "jpeg",
  21800. jpe: "jpeg",
  21801. pbm: "x-portable-bitmap",
  21802. pgm: "x-portable-graymap",
  21803. pnm: "x-portable-anymap",
  21804. ppm: "x-portable-pixmap",
  21805. psd: "vnd.adobe.photoshop",
  21806. pic: "x-pict",
  21807. rgb: "x-rgb",
  21808. svg: "svg+xml",
  21809. svgz: "svg+xml",
  21810. tif: "tiff",
  21811. xif: "vnd.xiff",
  21812. wbmp: "vnd.wap.wbmp",
  21813. wdp: "vnd.ms-photo",
  21814. xbm: "x-xbitmap",
  21815. ico: "x-icon"
  21816. },
  21817. /**
  21818. * 关于视频常见的MIME类型
  21819. */
  21820. video: {
  21821. "3g2": "3gpp2",
  21822. "3gp": "3gpp",
  21823. avi: "x-msvideo",
  21824. f4v: "x-f4v",
  21825. flv: "x-flv",
  21826. jpgm: "jpm",
  21827. jpgv: "jpeg",
  21828. m1v: "mpeg",
  21829. m2v: "mpeg",
  21830. mpe: "mpeg",
  21831. mpg: "mpeg",
  21832. mpg4: "mpeg",
  21833. m4v: "x-m4v",
  21834. mkv: "x-matroska",
  21835. mov: "quicktime",
  21836. qt: "quicktime",
  21837. movie: "x-sgi-movie",
  21838. mp4v: "mp4",
  21839. ogv: "ogg",
  21840. smv: "x-smv",
  21841. wm: "x-ms-wm",
  21842. wmv: "x-ms-wmv",
  21843. wmx: "x-ms-wmx",
  21844. wvx: "x-ms-wvx"
  21845. }
  21846. };
  21847. const ALL = "all";
  21848. function isWXEnv() {
  21849. const ua2 = window.navigator.userAgent.toLowerCase();
  21850. const matchUA = ua2.match(/MicroMessenger/i);
  21851. return !!(matchUA && matchUA[0] === "micromessenger");
  21852. }
  21853. function _createInput({
  21854. count,
  21855. sourceType,
  21856. type,
  21857. extension
  21858. }) {
  21859. addInteractListener();
  21860. const inputEl = document.createElement("input");
  21861. inputEl.type = "file";
  21862. updateElementStyle(inputEl, {
  21863. position: "absolute",
  21864. visibility: "hidden",
  21865. zIndex: "-999",
  21866. width: "0",
  21867. height: "0",
  21868. top: "0",
  21869. left: "0"
  21870. });
  21871. inputEl.accept = extension.map((item) => {
  21872. if (type !== ALL) {
  21873. const MIMEKey = item.replace(".", "");
  21874. return `${type}/${MIMEType[type][MIMEKey] || MIMEKey}`;
  21875. } else {
  21876. if (isWXEnv()) {
  21877. return ".";
  21878. }
  21879. return item.indexOf(".") === 0 ? item : `.${item}`;
  21880. }
  21881. }).join(",");
  21882. if (count && count > 1) {
  21883. inputEl.multiple = true;
  21884. }
  21885. if (type !== ALL && sourceType instanceof Array && sourceType.length === 1 && sourceType[0] === "camera") {
  21886. inputEl.setAttribute("capture", "camera");
  21887. }
  21888. return inputEl;
  21889. }
  21890. let fileInput = null;
  21891. const chooseFile = /* @__PURE__ */ defineAsyncApi(
  21892. API_CHOOSE_FILE,
  21893. ({
  21894. // sizeType,
  21895. count,
  21896. sourceType,
  21897. type,
  21898. extension
  21899. }, { resolve, reject }) => {
  21900. initI18nChooseFileMsgsOnce();
  21901. const { t: t2 } = useI18n();
  21902. if (fileInput) {
  21903. document.body.removeChild(fileInput);
  21904. fileInput = null;
  21905. }
  21906. fileInput = _createInput({
  21907. count,
  21908. sourceType,
  21909. type,
  21910. extension
  21911. });
  21912. document.body.appendChild(fileInput);
  21913. fileInput.addEventListener("change", function(event) {
  21914. const eventTarget = event.target;
  21915. const tempFiles = [];
  21916. if (eventTarget && eventTarget.files) {
  21917. const fileCount = eventTarget.files.length;
  21918. for (let i = 0; i < fileCount; i++) {
  21919. const file = eventTarget.files[i];
  21920. let filePath;
  21921. Object.defineProperty(file, "path", {
  21922. get() {
  21923. filePath = filePath || fileToUrl(file);
  21924. return filePath;
  21925. }
  21926. });
  21927. if (i < count)
  21928. tempFiles.push(file);
  21929. }
  21930. }
  21931. const res = {
  21932. get tempFilePaths() {
  21933. return tempFiles.map(({ path }) => path);
  21934. },
  21935. tempFiles
  21936. };
  21937. resolve(res);
  21938. });
  21939. fileInput.click();
  21940. if (!getInteractStatus()) {
  21941. console.warn(t2("uni.chooseFile.notUserActivation"));
  21942. }
  21943. },
  21944. ChooseFileProtocol,
  21945. ChooseFileOptions
  21946. );
  21947. let imageInput = null;
  21948. const chooseImage = /* @__PURE__ */ defineAsyncApi(
  21949. API_CHOOSE_IMAGE,
  21950. ({
  21951. count,
  21952. // sizeType,
  21953. sourceType,
  21954. extension
  21955. }, { resolve, reject }) => {
  21956. initI18nChooseFileMsgsOnce();
  21957. const { t: t2 } = useI18n();
  21958. if (imageInput) {
  21959. document.body.removeChild(imageInput);
  21960. imageInput = null;
  21961. }
  21962. imageInput = _createInput({
  21963. count,
  21964. sourceType,
  21965. extension,
  21966. type: "image"
  21967. });
  21968. document.body.appendChild(imageInput);
  21969. imageInput.addEventListener("change", function(event) {
  21970. const eventTarget = event.target;
  21971. const tempFiles = [];
  21972. if (eventTarget && eventTarget.files) {
  21973. const fileCount = eventTarget.files.length;
  21974. for (let i = 0; i < fileCount; i++) {
  21975. const file = eventTarget.files[i];
  21976. let filePath;
  21977. Object.defineProperty(file, "path", {
  21978. get() {
  21979. filePath = filePath || fileToUrl(file);
  21980. return filePath;
  21981. }
  21982. });
  21983. if (i < count)
  21984. tempFiles.push(file);
  21985. }
  21986. }
  21987. const res = {
  21988. get tempFilePaths() {
  21989. return tempFiles.map(({ path }) => path);
  21990. },
  21991. tempFiles
  21992. };
  21993. resolve(res);
  21994. });
  21995. imageInput.click();
  21996. if (!getInteractStatus()) {
  21997. console.warn(t2("uni.chooseFile.notUserActivation"));
  21998. }
  21999. },
  22000. ChooseImageProtocol,
  22001. ChooseImageOptions
  22002. );
  22003. let index$a = 0;
  22004. let overflow = "";
  22005. function preventScroll(prevent) {
  22006. let before = index$a;
  22007. index$a += prevent ? 1 : -1;
  22008. index$a = Math.max(0, index$a);
  22009. if (index$a > 0) {
  22010. if (before === 0) {
  22011. overflow = document.body.style.overflow;
  22012. document.body.style.overflow = "hidden";
  22013. }
  22014. } else {
  22015. document.body.style.overflow = overflow;
  22016. overflow = "";
  22017. }
  22018. }
  22019. function usePreventScroll() {
  22020. onMounted(() => preventScroll(true));
  22021. onUnmounted(() => preventScroll(false));
  22022. }
  22023. const props$8 = {
  22024. src: {
  22025. type: String,
  22026. default: ""
  22027. }
  22028. };
  22029. const ImageView = /* @__PURE__ */ defineSystemComponent({
  22030. name: "ImageView",
  22031. props: props$8,
  22032. setup(props2) {
  22033. const state2 = reactive({
  22034. direction: "none"
  22035. });
  22036. let scale = 1;
  22037. let imgWidth = 0;
  22038. let imgHeight = 0;
  22039. let width = 0;
  22040. let height = 0;
  22041. function onScale({
  22042. detail
  22043. }) {
  22044. scale = detail.scale;
  22045. }
  22046. function onImgLoad(event) {
  22047. const target = event.target;
  22048. const rect = target.getBoundingClientRect();
  22049. imgWidth = rect.width;
  22050. imgHeight = rect.height;
  22051. }
  22052. function onTouchStart(event) {
  22053. const target = event.target;
  22054. const rect = target.getBoundingClientRect();
  22055. width = rect.width;
  22056. height = rect.height;
  22057. checkDirection(event);
  22058. }
  22059. function onTouchEnd(event) {
  22060. const horizontal = scale * imgWidth > width;
  22061. const vertical = scale * imgHeight > height;
  22062. if (horizontal && vertical) {
  22063. state2.direction = "all";
  22064. } else if (horizontal) {
  22065. state2.direction = "horizontal";
  22066. } else if (vertical) {
  22067. state2.direction = "vertical";
  22068. } else {
  22069. state2.direction = "none";
  22070. }
  22071. checkDirection(event);
  22072. }
  22073. function checkDirection(event) {
  22074. if (state2.direction === "all" || state2.direction === "horizontal") {
  22075. event.stopPropagation();
  22076. }
  22077. }
  22078. return () => {
  22079. const viewStyle = {
  22080. position: "absolute",
  22081. left: "0",
  22082. top: "0",
  22083. width: "100%",
  22084. height: "100%"
  22085. };
  22086. return createVNode(MovableArea, {
  22087. "style": viewStyle,
  22088. "onTouchstart": withWebEvent(onTouchStart),
  22089. "onTouchmove": withWebEvent(checkDirection),
  22090. "onTouchend": withWebEvent(onTouchEnd)
  22091. }, {
  22092. default: () => [createVNode(MovableView, {
  22093. "style": viewStyle,
  22094. "direction": state2.direction,
  22095. "inertia": true,
  22096. "scale": true,
  22097. "scale-min": "1",
  22098. "scale-max": "4",
  22099. "onScale": onScale
  22100. }, {
  22101. default: () => [createVNode("img", {
  22102. "src": props2.src,
  22103. "style": {
  22104. position: "absolute",
  22105. left: "50%",
  22106. top: "50%",
  22107. transform: "translate(-50%, -50%)",
  22108. maxHeight: "100%",
  22109. maxWidth: "100%"
  22110. },
  22111. "onLoad": onImgLoad
  22112. }, null, 40, ["src", "onLoad"])]
  22113. }, 8, ["style", "direction", "inertia", "scale", "onScale"])]
  22114. }, 8, ["style", "onTouchstart", "onTouchmove", "onTouchend"]);
  22115. };
  22116. }
  22117. });
  22118. function _isSlot$2(s) {
  22119. return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
  22120. }
  22121. const props$7 = {
  22122. urls: {
  22123. type: Array,
  22124. default() {
  22125. return [];
  22126. }
  22127. },
  22128. current: {
  22129. type: [Number, String],
  22130. default: 0
  22131. }
  22132. };
  22133. function getIndex(props2) {
  22134. let index2 = typeof props2.current === "number" ? props2.current : props2.urls.indexOf(props2.current);
  22135. index2 = index2 < 0 ? 0 : index2;
  22136. return index2;
  22137. }
  22138. const ImagePreview = /* @__PURE__ */ defineSystemComponent({
  22139. name: "ImagePreview",
  22140. props: props$7,
  22141. emits: ["close"],
  22142. setup(props2, {
  22143. emit: emit2
  22144. }) {
  22145. usePreventScroll();
  22146. const rootRef = ref(null);
  22147. const indexRef = ref(getIndex(props2));
  22148. watch(() => props2.current, () => indexRef.value = getIndex(props2));
  22149. let preventDefault;
  22150. onMounted(() => {
  22151. const el = rootRef.value;
  22152. const MAX_MOVE = 20;
  22153. let x = 0;
  22154. let y = 0;
  22155. el.addEventListener("mousedown", (event) => {
  22156. preventDefault = false;
  22157. x = event.clientX;
  22158. y = event.clientY;
  22159. });
  22160. el.addEventListener("mouseup", (event) => {
  22161. if (Math.abs(event.clientX - x) > MAX_MOVE || Math.abs(event.clientY - y) > MAX_MOVE) {
  22162. preventDefault = true;
  22163. }
  22164. });
  22165. });
  22166. function onClick() {
  22167. if (!preventDefault) {
  22168. nextTick(() => {
  22169. emit2("close");
  22170. });
  22171. }
  22172. }
  22173. function onChange2(event) {
  22174. indexRef.value = event.detail.current;
  22175. }
  22176. const closeBtnStyle = {
  22177. position: "absolute",
  22178. "box-sizing": "border-box",
  22179. top: "0",
  22180. right: "0",
  22181. width: "60px",
  22182. height: "44px",
  22183. padding: "6px",
  22184. "line-height": "32px",
  22185. "font-size": "26px",
  22186. color: "white",
  22187. "text-align": "center",
  22188. cursor: "pointer"
  22189. };
  22190. return () => {
  22191. let _slot;
  22192. return createVNode("div", {
  22193. "ref": rootRef,
  22194. "style": {
  22195. display: "block",
  22196. position: "fixed",
  22197. left: "0",
  22198. top: "0",
  22199. width: "100%",
  22200. height: "100%",
  22201. zIndex: 999,
  22202. background: "rgba(0,0,0,0.8)"
  22203. },
  22204. "onClick": onClick
  22205. }, [createVNode(Swiper, {
  22206. "navigation": "auto",
  22207. "current": indexRef.value,
  22208. "onChange": onChange2,
  22209. "indicator-dots": false,
  22210. "autoplay": false,
  22211. "style": {
  22212. position: "absolute",
  22213. left: "0",
  22214. top: "0",
  22215. width: "100%",
  22216. height: "100%"
  22217. }
  22218. }, _isSlot$2(_slot = props2.urls.map((src) => createVNode(SwiperItem, null, {
  22219. default: () => [createVNode(ImageView, {
  22220. "src": src
  22221. }, null, 8, ["src"])]
  22222. }))) ? _slot : {
  22223. default: () => [_slot],
  22224. _: 1
  22225. }, 8, ["current", "onChange"]), createVNode("div", {
  22226. "style": closeBtnStyle
  22227. }, [createSvgIconVNode(ICON_PATH_CLOSE, "#ffffff", 26)], 4)], 8, ["onClick"]);
  22228. };
  22229. }
  22230. });
  22231. let state$2 = null;
  22232. let imagePreviewInstance;
  22233. const closePreviewImageView = () => {
  22234. state$2 = null;
  22235. nextTick(() => {
  22236. imagePreviewInstance == null ? void 0 : imagePreviewInstance.unmount();
  22237. imagePreviewInstance = null;
  22238. });
  22239. };
  22240. const previewImage = /* @__PURE__ */ defineAsyncApi(
  22241. API_PREVIEW_IMAGE,
  22242. (args, { resolve }) => {
  22243. if (!state$2) {
  22244. state$2 = reactive(args);
  22245. nextTick(() => {
  22246. imagePreviewInstance = createRootApp(
  22247. ImagePreview,
  22248. state$2,
  22249. closePreviewImageView
  22250. );
  22251. imagePreviewInstance.mount(ensureRoot("u-a-p"));
  22252. });
  22253. } else {
  22254. extend(state$2, args);
  22255. }
  22256. resolve();
  22257. },
  22258. PreviewImageProtocol,
  22259. PreviewImageOptions
  22260. );
  22261. const closePreviewImage = /* @__PURE__ */ defineAsyncApi(
  22262. API_CLOSE_PREVIEW_IMAGE,
  22263. (_, { resolve, reject }) => {
  22264. if (imagePreviewInstance) {
  22265. closePreviewImageView();
  22266. resolve();
  22267. } else {
  22268. reject();
  22269. }
  22270. }
  22271. );
  22272. let videoInput = null;
  22273. const chooseVideo = /* @__PURE__ */ defineAsyncApi(
  22274. API_CHOOSE_VIDEO,
  22275. ({ sourceType, extension }, { resolve, reject }) => {
  22276. initI18nChooseFileMsgsOnce();
  22277. const { t: t2 } = useI18n();
  22278. if (videoInput) {
  22279. document.body.removeChild(videoInput);
  22280. videoInput = null;
  22281. }
  22282. videoInput = _createInput({
  22283. sourceType,
  22284. extension,
  22285. type: "video"
  22286. });
  22287. document.body.appendChild(videoInput);
  22288. videoInput.addEventListener("change", function(event) {
  22289. const eventTarget = event.target;
  22290. const file = eventTarget.files[0];
  22291. let filePath = "";
  22292. const callbackResult = {
  22293. tempFilePath: filePath,
  22294. tempFile: file,
  22295. size: file.size,
  22296. duration: 0,
  22297. width: 0,
  22298. height: 0,
  22299. name: file.name
  22300. };
  22301. Object.defineProperty(callbackResult, "tempFilePath", {
  22302. get() {
  22303. filePath = filePath || fileToUrl(this.tempFile);
  22304. return filePath;
  22305. }
  22306. });
  22307. const video = document.createElement("video");
  22308. if (video.onloadedmetadata !== void 0) {
  22309. const filePath2 = fileToUrl(file);
  22310. video.onloadedmetadata = function() {
  22311. revokeObjectURL(filePath2);
  22312. resolve(
  22313. extend(callbackResult, {
  22314. duration: video.duration || 0,
  22315. width: video.videoWidth || 0,
  22316. height: video.videoHeight || 0
  22317. })
  22318. );
  22319. };
  22320. setTimeout(() => {
  22321. video.onloadedmetadata = null;
  22322. revokeObjectURL(filePath2);
  22323. resolve(callbackResult);
  22324. }, 300);
  22325. video.src = filePath2;
  22326. } else {
  22327. resolve(callbackResult);
  22328. }
  22329. });
  22330. videoInput.click();
  22331. if (!getInteractStatus()) {
  22332. console.warn(t2("uni.chooseFile.notUserActivation"));
  22333. }
  22334. },
  22335. ChooseVideoProtocol,
  22336. ChooseVideoOptions
  22337. );
  22338. const request = /* @__PURE__ */ defineTaskApi(
  22339. API_REQUEST,
  22340. ({
  22341. url,
  22342. data,
  22343. header = {},
  22344. method,
  22345. dataType: dataType2,
  22346. responseType,
  22347. withCredentials,
  22348. timeout = __uniConfig.networkTimeout.request
  22349. }, { resolve, reject }) => {
  22350. {
  22351. timeout = timeout == null ? __uniConfig.networkTimeout.request : timeout;
  22352. }
  22353. let body = null;
  22354. const contentType = normalizeContentType(header);
  22355. if (method !== "GET") {
  22356. if (isString(data) || data instanceof ArrayBuffer) {
  22357. body = data;
  22358. } else {
  22359. if (contentType === "json") {
  22360. try {
  22361. body = JSON.stringify(data);
  22362. } catch (error) {
  22363. body = data.toString();
  22364. }
  22365. } else if (contentType === "urlencoded") {
  22366. const bodyArray = [];
  22367. for (const key in data) {
  22368. if (hasOwn(data, key)) {
  22369. bodyArray.push(
  22370. encodeURIComponent(key) + "=" + encodeURIComponent(data[key])
  22371. );
  22372. }
  22373. }
  22374. body = bodyArray.join("&");
  22375. } else {
  22376. body = data.toString();
  22377. }
  22378. }
  22379. }
  22380. const xhr = new XMLHttpRequest();
  22381. const requestTask = new RequestTask(xhr);
  22382. xhr.open(method, url);
  22383. for (const key in header) {
  22384. if (hasOwn(header, key)) {
  22385. xhr.setRequestHeader(key, header[key]);
  22386. }
  22387. }
  22388. const timer = setTimeout(function() {
  22389. xhr.onload = xhr.onabort = xhr.onerror = null;
  22390. requestTask.abort();
  22391. reject("timeout", { errCode: 5 });
  22392. }, timeout);
  22393. xhr.responseType = responseType;
  22394. xhr.onload = function() {
  22395. clearTimeout(timer);
  22396. const statusCode = xhr.status;
  22397. let res = responseType === "text" ? xhr.responseText : xhr.response;
  22398. if (responseType === "text" && dataType2 === "json") {
  22399. try {
  22400. res = UTS.JSON.parse(res);
  22401. } catch (error) {
  22402. }
  22403. }
  22404. resolve({
  22405. data: res,
  22406. statusCode,
  22407. header: parseHeaders(xhr.getAllResponseHeaders()),
  22408. cookies: []
  22409. });
  22410. };
  22411. xhr.onabort = function() {
  22412. clearTimeout(timer);
  22413. reject("abort", { errCode: 600003 });
  22414. };
  22415. xhr.onerror = function() {
  22416. clearTimeout(timer);
  22417. reject(void 0, { errCode: 5 });
  22418. };
  22419. xhr.withCredentials = withCredentials;
  22420. xhr.send(body);
  22421. return requestTask;
  22422. },
  22423. RequestProtocol,
  22424. RequestOptions
  22425. );
  22426. function normalizeContentType(header) {
  22427. const name = Object.keys(header).find(
  22428. (name2) => name2.toLowerCase() === "content-type"
  22429. );
  22430. if (!name) {
  22431. return;
  22432. }
  22433. const contentType = header[name];
  22434. if (contentType.indexOf("application/json") === 0) {
  22435. return "json";
  22436. } else if (contentType.indexOf("application/x-www-form-urlencoded") === 0) {
  22437. return "urlencoded";
  22438. }
  22439. return "string";
  22440. }
  22441. class RequestTask {
  22442. constructor(xhr) {
  22443. this._xhr = xhr;
  22444. }
  22445. abort() {
  22446. if (this._xhr) {
  22447. this._xhr.abort();
  22448. delete this._xhr;
  22449. }
  22450. }
  22451. onHeadersReceived(callback) {
  22452. throw new Error("Method not implemented.");
  22453. }
  22454. offHeadersReceived(callback) {
  22455. throw new Error("Method not implemented.");
  22456. }
  22457. }
  22458. function parseHeaders(headers) {
  22459. const headersObject = {};
  22460. headers.split(LINEFEED).forEach((header) => {
  22461. const find = header.match(/(\S+\s*):\s*(.*)/);
  22462. if (!find || find.length !== 3) {
  22463. return;
  22464. }
  22465. headersObject[find[1]] = find[2];
  22466. });
  22467. return headersObject;
  22468. }
  22469. class DownloadTask {
  22470. constructor(xhr) {
  22471. this._callbacks = [];
  22472. this._xhr = xhr;
  22473. }
  22474. /**
  22475. * 监听下载进度
  22476. * @param {Function} callback 回调
  22477. */
  22478. onProgressUpdate(callback) {
  22479. if (!isFunction(callback)) {
  22480. return;
  22481. }
  22482. this._callbacks.push(callback);
  22483. }
  22484. offProgressUpdate(callback) {
  22485. const index2 = this._callbacks.indexOf(callback);
  22486. if (index2 >= 0) {
  22487. this._callbacks.splice(index2, 1);
  22488. }
  22489. }
  22490. /**
  22491. * 停止任务
  22492. */
  22493. abort() {
  22494. if (this._xhr) {
  22495. this._xhr.abort();
  22496. delete this._xhr;
  22497. }
  22498. }
  22499. onHeadersReceived(callback) {
  22500. throw new Error("Method not implemented.");
  22501. }
  22502. offHeadersReceived(callback) {
  22503. throw new Error("Method not implemented.");
  22504. }
  22505. }
  22506. const downloadFile = /* @__PURE__ */ defineTaskApi(
  22507. API_DOWNLOAD_FILE,
  22508. ({ url, header = {}, timeout = __uniConfig.networkTimeout.downloadFile }, { resolve, reject }) => {
  22509. {
  22510. timeout = timeout == null ? __uniConfig.networkTimeout.downloadFile : timeout;
  22511. }
  22512. var timer;
  22513. var xhr = new XMLHttpRequest();
  22514. var downloadTask = new DownloadTask(xhr);
  22515. xhr.open("GET", url, true);
  22516. Object.keys(header).forEach((key) => {
  22517. xhr.setRequestHeader(key, header[key]);
  22518. });
  22519. xhr.responseType = "blob";
  22520. xhr.onload = function() {
  22521. clearTimeout(timer);
  22522. const statusCode = xhr.status;
  22523. const blob = this.response;
  22524. let filename;
  22525. const contentDisposition = xhr.getResponseHeader("content-disposition");
  22526. if (contentDisposition) {
  22527. const res = contentDisposition.match(/filename="?(\S+)"?\b/);
  22528. if (res) {
  22529. filename = res[1];
  22530. }
  22531. }
  22532. blob.name = filename || getFileName(url);
  22533. resolve({
  22534. statusCode,
  22535. tempFilePath: fileToUrl(blob)
  22536. });
  22537. };
  22538. xhr.onabort = function() {
  22539. clearTimeout(timer);
  22540. reject("abort", { errCode: 600003 });
  22541. };
  22542. xhr.onerror = function() {
  22543. clearTimeout(timer);
  22544. reject("", { errCode: 602001 });
  22545. };
  22546. xhr.onprogress = function(event) {
  22547. downloadTask._callbacks.forEach((callback) => {
  22548. var totalBytesWritten = event.loaded;
  22549. var totalBytesExpectedToWrite = event.total;
  22550. var progress = Math.round(
  22551. totalBytesWritten / totalBytesExpectedToWrite * 100
  22552. );
  22553. callback({
  22554. progress,
  22555. totalBytesWritten,
  22556. totalBytesExpectedToWrite
  22557. });
  22558. });
  22559. };
  22560. xhr.send();
  22561. timer = setTimeout(function() {
  22562. xhr.onprogress = xhr.onload = xhr.onabort = xhr.onerror = null;
  22563. downloadTask.abort();
  22564. reject("timeout", { errCode: 5 });
  22565. }, timeout);
  22566. return downloadTask;
  22567. },
  22568. DownloadFileProtocol,
  22569. DownloadFileOptions
  22570. );
  22571. class UploadTask {
  22572. constructor(xhr) {
  22573. this._callbacks = [];
  22574. this._xhr = xhr;
  22575. }
  22576. /**
  22577. * 监听上传进度
  22578. * @param callback 回调
  22579. */
  22580. onProgressUpdate(callback) {
  22581. if (!isFunction(callback)) {
  22582. return;
  22583. }
  22584. this._callbacks.push(callback);
  22585. }
  22586. offProgressUpdate(callback) {
  22587. const index2 = this._callbacks.indexOf(callback);
  22588. if (index2 >= 0) {
  22589. this._callbacks.splice(index2, 1);
  22590. }
  22591. }
  22592. /**
  22593. * 中断上传任务
  22594. */
  22595. abort() {
  22596. this._isAbort = true;
  22597. if (this._xhr) {
  22598. this._xhr.abort();
  22599. delete this._xhr;
  22600. }
  22601. }
  22602. onHeadersReceived(callback) {
  22603. throw new Error("Method not implemented.");
  22604. }
  22605. offHeadersReceived(callback) {
  22606. throw new Error("Method not implemented.");
  22607. }
  22608. }
  22609. const uploadFile = /* @__PURE__ */ defineTaskApi(
  22610. API_UPLOAD_FILE,
  22611. ({
  22612. url,
  22613. file,
  22614. filePath,
  22615. name,
  22616. files: files2,
  22617. header = {},
  22618. formData = {},
  22619. timeout = __uniConfig.networkTimeout.uploadFile
  22620. }, { resolve, reject }) => {
  22621. {
  22622. timeout = timeout == null ? __uniConfig.networkTimeout.uploadFile : timeout;
  22623. }
  22624. var uploadTask = new UploadTask();
  22625. if (!isArray(files2) || !files2.length) {
  22626. files2 = [
  22627. {
  22628. name,
  22629. file,
  22630. uri: filePath
  22631. }
  22632. ];
  22633. }
  22634. function upload(realFiles) {
  22635. var xhr = new XMLHttpRequest();
  22636. var form = new FormData();
  22637. var timer;
  22638. Object.keys(formData).forEach((key) => {
  22639. form.append(key, formData[key]);
  22640. });
  22641. Object.values(files2).forEach(({ name: name2 }, index2) => {
  22642. const file2 = realFiles[index2];
  22643. form.append(name2 || "file", file2, file2.name || `file-${Date.now()}`);
  22644. });
  22645. xhr.open("POST", url);
  22646. Object.keys(header).forEach((key) => {
  22647. xhr.setRequestHeader(key, header[key]);
  22648. });
  22649. xhr.upload.onprogress = function(event) {
  22650. uploadTask._callbacks.forEach((callback) => {
  22651. var totalBytesSent = event.loaded;
  22652. var totalBytesExpectedToSend = event.total;
  22653. var progress = Math.round(
  22654. totalBytesSent / totalBytesExpectedToSend * 100
  22655. );
  22656. callback({
  22657. progress,
  22658. totalBytesSent,
  22659. totalBytesExpectedToSend
  22660. });
  22661. });
  22662. };
  22663. xhr.onerror = function() {
  22664. clearTimeout(timer);
  22665. reject("", { errCode: 602001 });
  22666. };
  22667. xhr.onabort = function() {
  22668. clearTimeout(timer);
  22669. reject("abort", { errCode: 600003 });
  22670. };
  22671. xhr.onload = function() {
  22672. clearTimeout(timer);
  22673. const statusCode = xhr.status;
  22674. resolve({
  22675. statusCode,
  22676. data: xhr.responseText || xhr.response
  22677. });
  22678. };
  22679. if (!uploadTask._isAbort) {
  22680. timer = setTimeout(function() {
  22681. xhr.upload.onprogress = xhr.onload = xhr.onabort = xhr.onerror = null;
  22682. uploadTask.abort();
  22683. reject("timeout", { errCode: 5 });
  22684. }, timeout);
  22685. xhr.send(form);
  22686. uploadTask._xhr = xhr;
  22687. } else {
  22688. reject("abort", { errCode: 600003 });
  22689. }
  22690. }
  22691. Promise.all(
  22692. files2.map(
  22693. ({ file: file2, uri }) => file2 instanceof Blob ? Promise.resolve(blobToFile(file2)) : urlToFile(uri)
  22694. )
  22695. ).then(upload).catch(() => {
  22696. setTimeout(() => {
  22697. reject("file error");
  22698. }, 0);
  22699. });
  22700. return uploadTask;
  22701. },
  22702. UploadFileProtocol,
  22703. UploadFileOptions
  22704. );
  22705. const socketTasks = [];
  22706. const globalEvent = {
  22707. open: "",
  22708. close: "",
  22709. error: "",
  22710. message: ""
  22711. };
  22712. class SocketTask {
  22713. /**
  22714. * 构造函数
  22715. * @param {string} url
  22716. * @param {Array} protocols
  22717. */
  22718. constructor(url, protocols, callback) {
  22719. this._callbacks = {
  22720. open: [],
  22721. close: [],
  22722. error: [],
  22723. message: []
  22724. };
  22725. let error;
  22726. try {
  22727. const webSocket = this._webSocket = new WebSocket(url, protocols);
  22728. webSocket.binaryType = "arraybuffer";
  22729. const eventNames = ["open", "close", "error", "message"];
  22730. eventNames.forEach((name) => {
  22731. this._callbacks[name] = [];
  22732. webSocket.addEventListener(name, (event) => {
  22733. const { data, code, reason } = event;
  22734. const res = name === "message" ? { data } : name === "close" ? { code, reason } : {};
  22735. this._callbacks[name].forEach((callback2) => {
  22736. try {
  22737. callback2(res);
  22738. } catch (e2) {
  22739. console.error(
  22740. `thirdScriptError
  22741. ${e2};at socketTask.on${capitalize(
  22742. name
  22743. )} callback function
  22744. `,
  22745. e2
  22746. );
  22747. }
  22748. });
  22749. if (this === socketTasks[0] && globalEvent[name]) {
  22750. UniServiceJSBridge.invokeOnCallback(globalEvent[name], res);
  22751. }
  22752. if (name === "error" || name === "close") {
  22753. const index2 = socketTasks.indexOf(this);
  22754. if (index2 >= 0) {
  22755. socketTasks.splice(index2, 1);
  22756. }
  22757. }
  22758. });
  22759. });
  22760. const propertys = [
  22761. "CLOSED",
  22762. "CLOSING",
  22763. "CONNECTING",
  22764. "OPEN",
  22765. "readyState"
  22766. ];
  22767. propertys.forEach((property) => {
  22768. Object.defineProperty(this, property, {
  22769. get() {
  22770. return webSocket[property];
  22771. }
  22772. });
  22773. });
  22774. } catch (e2) {
  22775. error = e2;
  22776. }
  22777. callback && callback(error, this);
  22778. }
  22779. /**
  22780. * 发送
  22781. * @param {any} data
  22782. */
  22783. send(options) {
  22784. const data = (options || {}).data;
  22785. const ws = this._webSocket;
  22786. try {
  22787. if (ws.readyState !== ws.OPEN) {
  22788. callOptions(options, {
  22789. errMsg: `sendSocketMessage:fail SocketTask.readyState is not OPEN`,
  22790. errCode: 10002
  22791. });
  22792. throw new Error("SocketTask.readyState is not OPEN");
  22793. }
  22794. ws.send(data);
  22795. callOptions(options, "sendSocketMessage:ok");
  22796. } catch (error) {
  22797. callOptions(options, {
  22798. errMsg: `sendSocketMessage:fail ${error}`,
  22799. errCode: 602001
  22800. });
  22801. }
  22802. }
  22803. /**
  22804. * 关闭
  22805. * @param {number} code
  22806. * @param {string} reason
  22807. */
  22808. close(options = {}) {
  22809. const ws = this._webSocket;
  22810. try {
  22811. const code = options.code || 1e3;
  22812. const reason = options.reason;
  22813. if (isString(reason)) {
  22814. ws.close(code, reason);
  22815. } else {
  22816. ws.close(code);
  22817. }
  22818. callOptions(options, "closeSocket:ok");
  22819. } catch (error) {
  22820. callOptions(options, `closeSocket:fail ${error}`);
  22821. }
  22822. }
  22823. onOpen(callback) {
  22824. this._callbacks.open.push(callback);
  22825. }
  22826. onMessage(callback) {
  22827. this._callbacks.message.push(callback);
  22828. }
  22829. onError(callback) {
  22830. this._callbacks.error.push(callback);
  22831. }
  22832. onClose(callback) {
  22833. this._callbacks.close.push(callback);
  22834. }
  22835. }
  22836. const connectSocket = /* @__PURE__ */ defineTaskApi(
  22837. API_CONNECT_SOCKET,
  22838. ({ url, protocols }, { resolve, reject }) => {
  22839. return new SocketTask(
  22840. url,
  22841. protocols,
  22842. (error, socketTask) => {
  22843. if (error) {
  22844. reject(error.toString(), {
  22845. errCode: 600009
  22846. });
  22847. return;
  22848. }
  22849. socketTasks.push(socketTask);
  22850. resolve();
  22851. }
  22852. );
  22853. },
  22854. ConnectSocketProtocol,
  22855. ConnectSocketOptions
  22856. );
  22857. function callSocketTask(socketTask, method, option, resolve, reject) {
  22858. const fn = socketTask[method];
  22859. if (isFunction(fn)) {
  22860. fn.call(
  22861. socketTask,
  22862. extend({}, option, {
  22863. success() {
  22864. resolve();
  22865. },
  22866. fail({ errMsg }) {
  22867. reject(errMsg.replace("sendSocketMessage:fail ", ""));
  22868. },
  22869. complete: void 0
  22870. })
  22871. );
  22872. }
  22873. }
  22874. const sendSocketMessage = /* @__PURE__ */ defineAsyncApi(
  22875. API_SEND_SOCKET_MESSAGE,
  22876. (options, { resolve, reject }) => {
  22877. const socketTask = socketTasks[0];
  22878. if (socketTask && socketTask.readyState === socketTask.OPEN) {
  22879. callSocketTask(socketTask, "send", options, resolve, reject);
  22880. } else {
  22881. reject("WebSocket is not connected");
  22882. }
  22883. },
  22884. SendSocketMessageProtocol
  22885. );
  22886. const closeSocket = /* @__PURE__ */ defineAsyncApi(
  22887. API_CLOSE_SOCKET,
  22888. (options, { resolve, reject }) => {
  22889. const socketTask = socketTasks[0];
  22890. if (socketTask) {
  22891. callSocketTask(socketTask, "close", options, resolve, reject);
  22892. } else {
  22893. reject("WebSocket is not connected");
  22894. }
  22895. },
  22896. CloseSocketProtocol
  22897. );
  22898. function on(event) {
  22899. const api2 = `onSocket${capitalize(event)}`;
  22900. return /* @__PURE__ */ defineOnApi(api2, () => {
  22901. globalEvent[event] = api2;
  22902. });
  22903. }
  22904. const onSocketOpen = /* @__PURE__ */ on("open");
  22905. const onSocketError = /* @__PURE__ */ on("error");
  22906. const onSocketMessage = /* @__PURE__ */ on("message");
  22907. const onSocketClose = /* @__PURE__ */ on("close");
  22908. const getLocation = /* @__PURE__ */ defineAsyncApi(
  22909. API_GET_LOCATION,
  22910. ({ type, altitude, highAccuracyExpireTime, isHighAccuracy }, { resolve, reject }) => {
  22911. const mapInfo = getMapInfo();
  22912. new Promise((resolve2, reject2) => {
  22913. if (navigator.geolocation) {
  22914. navigator.geolocation.getCurrentPosition(
  22915. (res) => resolve2({ coords: res.coords }),
  22916. reject2,
  22917. {
  22918. enableHighAccuracy: isHighAccuracy || altitude,
  22919. timeout: highAccuracyExpireTime || 1e3 * 100
  22920. }
  22921. );
  22922. } else {
  22923. reject2(new Error("device nonsupport geolocation"));
  22924. }
  22925. }).catch((error) => {
  22926. return new Promise(
  22927. (resolve2, reject2) => {
  22928. if (mapInfo.type === MapType.QQ) {
  22929. getJSONP(
  22930. `https://apis.map.qq.com/ws/location/v1/ip?output=jsonp&key=${mapInfo.key}`,
  22931. {
  22932. callback: "callback"
  22933. },
  22934. (res) => {
  22935. if ("result" in res && res.result.location) {
  22936. const location2 = res.result.location;
  22937. resolve2({
  22938. coords: {
  22939. latitude: location2.lat,
  22940. longitude: location2.lng
  22941. },
  22942. skip: true
  22943. });
  22944. } else {
  22945. reject2(new Error(res.message || JSON.stringify(res)));
  22946. }
  22947. },
  22948. () => reject2(new Error("network error"))
  22949. );
  22950. } else if (mapInfo.type === MapType.GOOGLE) {
  22951. request({
  22952. method: "POST",
  22953. url: `https://www.googleapis.com/geolocation/v1/geolocate?key=${mapInfo.key}`,
  22954. success(res) {
  22955. const data = res.data;
  22956. if ("location" in data) {
  22957. resolve2({
  22958. coords: {
  22959. latitude: data.location.lat,
  22960. longitude: data.location.lng,
  22961. accuracy: data.accuracy
  22962. },
  22963. skip: true
  22964. });
  22965. } else {
  22966. reject2(
  22967. new Error(
  22968. data.error && data.error.message || JSON.stringify(res)
  22969. )
  22970. );
  22971. }
  22972. },
  22973. fail() {
  22974. reject2(new Error("network error"));
  22975. }
  22976. });
  22977. } else if (mapInfo.type === MapType.AMAP) {
  22978. loadMaps([], () => {
  22979. window.AMap.plugin("AMap.Geolocation", () => {
  22980. const geolocation = new window.AMap.Geolocation({
  22981. enableHighAccuracy: true,
  22982. timeout: 1e4
  22983. });
  22984. geolocation.getCurrentPosition(
  22985. (status, data) => {
  22986. if (status === "complete") {
  22987. resolve2({
  22988. coords: {
  22989. latitude: data.position.lat,
  22990. longitude: data.position.lng,
  22991. accuracy: data.accuracy
  22992. },
  22993. skip: true
  22994. });
  22995. } else {
  22996. reject2(new Error(data.message));
  22997. }
  22998. }
  22999. );
  23000. });
  23001. });
  23002. } else {
  23003. reject2(error);
  23004. }
  23005. }
  23006. );
  23007. }).then(({ coords, skip }) => {
  23008. translateCoordinateSystem(type, coords, skip).then((coords2) => {
  23009. resolve({
  23010. latitude: coords2.latitude,
  23011. longitude: coords2.longitude,
  23012. accuracy: coords2.accuracy,
  23013. speed: coords2.altitude || 0,
  23014. altitude: coords2.altitude || 0,
  23015. verticalAccuracy: coords2.altitudeAccuracy || 0,
  23016. // 无专门水平精度,使用位置精度替代
  23017. horizontalAccuracy: coords2.accuracy || 0
  23018. });
  23019. }).catch((error) => {
  23020. reject(error.message);
  23021. });
  23022. }).catch((error) => {
  23023. reject(error.message || JSON.stringify(error));
  23024. });
  23025. },
  23026. GetLocationProtocol,
  23027. GetLocationOptions
  23028. );
  23029. 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";
  23030. const props$6 = {
  23031. latitude: {
  23032. type: Number
  23033. },
  23034. longitude: {
  23035. type: Number
  23036. },
  23037. scale: {
  23038. type: Number,
  23039. default: 18
  23040. },
  23041. name: {
  23042. type: String,
  23043. default: ""
  23044. },
  23045. address: {
  23046. type: String,
  23047. default: ""
  23048. }
  23049. };
  23050. function useState$2(props2) {
  23051. const state2 = reactive({
  23052. center: {
  23053. latitude: 0,
  23054. longitude: 0
  23055. },
  23056. marker: {
  23057. id: 1,
  23058. latitude: 0,
  23059. longitude: 0,
  23060. iconPath: ICON_PATH_TARGET,
  23061. width: 32,
  23062. height: 52
  23063. },
  23064. location: {
  23065. id: 2,
  23066. latitude: 0,
  23067. longitude: 0,
  23068. iconPath: ICON_PATH_ORIGIN,
  23069. width: 44,
  23070. height: 44
  23071. }
  23072. });
  23073. function updatePosition() {
  23074. if (props2.latitude && props2.longitude) {
  23075. state2.center.latitude = props2.latitude;
  23076. state2.center.longitude = props2.longitude;
  23077. state2.marker.latitude = props2.latitude;
  23078. state2.marker.longitude = props2.longitude;
  23079. }
  23080. }
  23081. watch([() => props2.latitude, () => props2.longitude], updatePosition);
  23082. updatePosition();
  23083. return state2;
  23084. }
  23085. const LocationView = /* @__PURE__ */ defineSystemComponent({
  23086. name: "LocationView",
  23087. props: props$6,
  23088. emits: ["close"],
  23089. setup(props2, {
  23090. emit: emit2
  23091. }) {
  23092. const state2 = useState$2(props2);
  23093. usePreventScroll();
  23094. getLocation({
  23095. type: "gcj02",
  23096. success: ({
  23097. latitude,
  23098. longitude
  23099. }) => {
  23100. state2.location.latitude = latitude;
  23101. state2.location.longitude = longitude;
  23102. }
  23103. });
  23104. function onRegionChange(event) {
  23105. const centerLocation = event.detail.centerLocation;
  23106. if (centerLocation) {
  23107. state2.center.latitude = centerLocation.latitude;
  23108. state2.center.longitude = centerLocation.longitude;
  23109. }
  23110. }
  23111. function nav() {
  23112. const mapInfo = getMapInfo();
  23113. let url = "";
  23114. if (mapInfo.type === MapType.GOOGLE) {
  23115. const origin = state2.location.latitude ? `&origin=${state2.location.latitude}%2C${state2.location.longitude}` : "";
  23116. url = `https://www.google.com/maps/dir/?api=1${origin}&destination=${props2.latitude}%2C${props2.longitude}`;
  23117. } else if (mapInfo.type === MapType.QQ) {
  23118. const fromcoord = state2.location.latitude ? `&fromcoord=${state2.location.latitude}%2C${state2.location.longitude}&from=${encodeURIComponent("我的位置")}` : "";
  23119. 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}`;
  23120. } else if (mapInfo.type === MapType.AMAP) {
  23121. const from = state2.location.latitude ? `from=${state2.location.longitude},${state2.location.latitude},${encodeURIComponent("我的位置")}&` : "";
  23122. url = `https://uri.amap.com/navigation?${from}to=${props2.longitude},${props2.latitude},${encodeURIComponent(props2.name || "目的地")}`;
  23123. }
  23124. window.open(url);
  23125. }
  23126. function back() {
  23127. emit2("close");
  23128. }
  23129. function setCenter({
  23130. latitude,
  23131. longitude
  23132. }) {
  23133. state2.center.latitude = latitude;
  23134. state2.center.longitude = longitude;
  23135. }
  23136. return () => {
  23137. return createVNode("div", {
  23138. "class": "uni-system-open-location"
  23139. }, [createVNode(Map$1, {
  23140. "latitude": state2.center.latitude,
  23141. "longitude": state2.center.longitude,
  23142. "class": "map",
  23143. "markers": [state2.marker, state2.location],
  23144. "onRegionchange": onRegionChange
  23145. }, {
  23146. default: () => [createVNode("div", {
  23147. "class": "map-move",
  23148. "onClick": () => setCenter(state2.location)
  23149. }, [createSvgIconVNode(ICON_PATH_LOCTAION, "#000000", 24)], 8, ["onClick"])]
  23150. }, 8, ["latitude", "longitude", "markers", "onRegionchange"]), createVNode("div", {
  23151. "class": "info"
  23152. }, [createVNode("div", {
  23153. "class": "name",
  23154. "onClick": () => setCenter(state2.marker)
  23155. }, [props2.name], 8, ["onClick"]), createVNode("div", {
  23156. "class": "address",
  23157. "onClick": () => setCenter(state2.marker)
  23158. }, [props2.address], 8, ["onClick"]), createVNode("div", {
  23159. "class": "nav",
  23160. "onClick": nav
  23161. }, [createSvgIconVNode(ICON_PATH_NAV, "#ffffff", 26)], 8, ["onClick"])]), createVNode("div", {
  23162. "class": "nav-btn-back",
  23163. "onClick": back
  23164. }, [createSvgIconVNode(ICON_PATH_BACK, "#ffffff", 26)], 8, ["onClick"])]);
  23165. };
  23166. }
  23167. });
  23168. let state$1 = null;
  23169. const openLocation = /* @__PURE__ */ defineAsyncApi(
  23170. API_OPEN_LOCATION,
  23171. (args, { resolve }) => {
  23172. if (!state$1) {
  23173. state$1 = reactive(args);
  23174. nextTick(() => {
  23175. const app = createRootApp(LocationView, state$1, () => {
  23176. state$1 = null;
  23177. nextTick(() => {
  23178. app.unmount();
  23179. });
  23180. });
  23181. app.mount(ensureRoot("u-a-o"));
  23182. });
  23183. } else {
  23184. extend(state$1, args);
  23185. }
  23186. resolve();
  23187. },
  23188. OpenLocationProtocol,
  23189. OpenLocationOptions
  23190. );
  23191. function _isSlot$1(s) {
  23192. return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
  23193. }
  23194. const props$5 = {
  23195. latitude: {
  23196. type: Number
  23197. },
  23198. longitude: {
  23199. type: Number
  23200. }
  23201. };
  23202. function distance(distance2) {
  23203. if (distance2 > 100) {
  23204. return `${distance2 > 1e3 ? (distance2 / 1e3).toFixed(1) + "k" : distance2.toFixed(0)}m | `;
  23205. } else if (distance2 > 0) {
  23206. return "<100m | ";
  23207. } else {
  23208. return "";
  23209. }
  23210. }
  23211. function useState$1(props2) {
  23212. const state2 = reactive({
  23213. latitude: 0,
  23214. longitude: 0,
  23215. keyword: "",
  23216. searching: false
  23217. });
  23218. function updatePosition() {
  23219. if (props2.latitude && props2.longitude) {
  23220. state2.latitude = props2.latitude;
  23221. state2.longitude = props2.longitude;
  23222. }
  23223. }
  23224. watch([() => props2.latitude, () => props2.longitude], updatePosition);
  23225. updatePosition();
  23226. return state2;
  23227. }
  23228. function useList(state2) {
  23229. const key = __uniConfig.qqMapKey;
  23230. const list2 = reactive([]);
  23231. const selectedIndexRef = ref(-1);
  23232. const selectedRef = computed(() => list2[selectedIndexRef.value]);
  23233. const listState = reactive({
  23234. loading: true,
  23235. // google map default
  23236. pageSize: 20,
  23237. pageIndex: 1,
  23238. hasNextPage: true,
  23239. nextPage: null,
  23240. selectedIndex: selectedIndexRef,
  23241. selected: selectedRef
  23242. });
  23243. const adcodeRef = ref("");
  23244. const boundaryRef = computed(() => adcodeRef.value ? `region(${adcodeRef.value},1,${state2.latitude},${state2.longitude})` : `nearby(${state2.latitude},${state2.longitude},5000)`);
  23245. function pushData(array) {
  23246. array.forEach((item) => {
  23247. list2.push({
  23248. name: item.title || item.name,
  23249. address: item.address,
  23250. distance: item._distance || item.distance,
  23251. latitude: item.location.lat,
  23252. longitude: item.location.lng
  23253. });
  23254. });
  23255. }
  23256. function getList() {
  23257. listState.loading = true;
  23258. const mapInfo = getMapInfo();
  23259. if (mapInfo.type === MapType.GOOGLE) {
  23260. if (listState.pageIndex > 1 && listState.nextPage) {
  23261. listState.nextPage();
  23262. return;
  23263. }
  23264. const service = new google.maps.places.PlacesService(document.createElement("div"));
  23265. service[state2.searching ? "textSearch" : "nearbySearch"]({
  23266. location: {
  23267. lat: state2.latitude,
  23268. lng: state2.longitude
  23269. },
  23270. query: state2.keyword,
  23271. radius: 5e3
  23272. }, (results, state3, page) => {
  23273. listState.loading = false;
  23274. if (results && results.length) {
  23275. results.forEach((item) => {
  23276. list2.push({
  23277. name: item.name || "",
  23278. address: item.vicinity || item.formatted_address || "",
  23279. distance: 0,
  23280. latitude: item.geometry.location.lat(),
  23281. longitude: item.geometry.location.lng()
  23282. });
  23283. });
  23284. }
  23285. if (page) {
  23286. if (!page.hasNextPage) {
  23287. listState.hasNextPage = false;
  23288. } else {
  23289. listState.nextPage = () => {
  23290. page.nextPage();
  23291. };
  23292. }
  23293. }
  23294. });
  23295. } else if (mapInfo.type === MapType.QQ) {
  23296. 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}`;
  23297. getJSONP(url, {
  23298. callback: "callback"
  23299. }, (res) => {
  23300. listState.loading = false;
  23301. if (state2.searching && "data" in res && res.data.length) {
  23302. pushData(res.data);
  23303. } else if ("result" in res) {
  23304. const result = res.result;
  23305. adcodeRef.value = result.ad_info ? result.ad_info.adcode : "";
  23306. if (result.pois) {
  23307. pushData(result.pois);
  23308. }
  23309. }
  23310. if (list2.length === listState.pageSize * listState.pageIndex) {
  23311. listState.hasNextPage = false;
  23312. }
  23313. }, () => {
  23314. listState.loading = false;
  23315. });
  23316. } else if (mapInfo.type === MapType.AMAP) {
  23317. window.AMap.plugin("AMap.PlaceSearch", function() {
  23318. const placeSearch = new window.AMap.PlaceSearch({
  23319. city: "全国",
  23320. pageSize: 10,
  23321. pageIndex: listState.pageIndex
  23322. });
  23323. const keyword = state2.searching ? state2.keyword : "";
  23324. const radius = state2.searching ? 5e4 : 5e3;
  23325. placeSearch.searchNearBy(keyword, [state2.longitude, state2.latitude], radius, function(status, result) {
  23326. if (status === "error") {
  23327. console.error(result);
  23328. } else if (status === "no_data") {
  23329. listState.hasNextPage = false;
  23330. } else {
  23331. pushData(result.poiList.pois);
  23332. }
  23333. });
  23334. listState.loading = false;
  23335. });
  23336. }
  23337. }
  23338. function loadMore() {
  23339. if (!listState.loading && listState.hasNextPage) {
  23340. listState.pageIndex++;
  23341. getList();
  23342. }
  23343. }
  23344. function reset() {
  23345. listState.selectedIndex = -1;
  23346. listState.pageIndex = 1;
  23347. listState.hasNextPage = true;
  23348. listState.nextPage = null;
  23349. list2.splice(0, list2.length);
  23350. }
  23351. return {
  23352. listState,
  23353. list: list2,
  23354. loadMore,
  23355. reset,
  23356. getList
  23357. };
  23358. }
  23359. const LoctaionPicker = /* @__PURE__ */ defineSystemComponent({
  23360. name: "LoctaionPicker",
  23361. props: props$5,
  23362. emits: ["close"],
  23363. setup(props2, {
  23364. emit: emit2
  23365. }) {
  23366. usePreventScroll();
  23367. initI18nChooseLocationMsgsOnce();
  23368. const {
  23369. t: t2
  23370. } = useI18n();
  23371. const state2 = useState$1(props2);
  23372. const {
  23373. list: list2,
  23374. listState,
  23375. loadMore,
  23376. reset,
  23377. getList
  23378. } = useList(state2);
  23379. const search = debounce(() => {
  23380. reset();
  23381. if (state2.keyword) {
  23382. getList();
  23383. }
  23384. }, 1e3, {
  23385. setTimeout,
  23386. clearTimeout
  23387. });
  23388. watch(() => state2.searching, (val) => {
  23389. reset();
  23390. if (!val) {
  23391. getList();
  23392. }
  23393. });
  23394. function onInput(event) {
  23395. state2.keyword = event.detail.value;
  23396. search();
  23397. }
  23398. function onChoose() {
  23399. emit2("close", extend({}, listState.selected));
  23400. }
  23401. function onBack() {
  23402. emit2("close");
  23403. }
  23404. function onRegionChange(event) {
  23405. const centerLocation = event.detail.centerLocation;
  23406. if (centerLocation) {
  23407. move(centerLocation);
  23408. }
  23409. }
  23410. function moveToLocation() {
  23411. getLocation({
  23412. type: "gcj02",
  23413. success: move,
  23414. fail: () => {
  23415. }
  23416. });
  23417. }
  23418. function move({
  23419. latitude,
  23420. longitude
  23421. }) {
  23422. state2.latitude = latitude;
  23423. state2.longitude = longitude;
  23424. if (!state2.searching) {
  23425. reset();
  23426. getList();
  23427. }
  23428. }
  23429. if (!state2.latitude || !state2.longitude) {
  23430. moveToLocation();
  23431. }
  23432. return () => {
  23433. const content = list2.map((item, index2) => {
  23434. return createVNode("div", {
  23435. "key": index2,
  23436. "class": {
  23437. "list-item": true,
  23438. selected: listState.selectedIndex === index2
  23439. },
  23440. "onClick": () => {
  23441. listState.selectedIndex = index2;
  23442. state2.latitude = item.latitude;
  23443. state2.longitude = item.longitude;
  23444. }
  23445. }, [createSvgIconVNode(ICON_PATH_CONFIRM, "#007aff", 24), createVNode("div", {
  23446. "class": "list-item-title"
  23447. }, [item.name]), createVNode("div", {
  23448. "class": "list-item-detail"
  23449. }, [distance(item.distance), item.address])], 10, ["onClick"]);
  23450. });
  23451. if (listState.loading) {
  23452. content.unshift(createVNode("div", {
  23453. "class": "list-loading"
  23454. }, [createVNode("i", {
  23455. "class": "uni-loading"
  23456. }, null)]));
  23457. }
  23458. return createVNode("div", {
  23459. "class": "uni-system-choose-location"
  23460. }, [createVNode(Map$1, {
  23461. "latitude": state2.latitude,
  23462. "longitude": state2.longitude,
  23463. "class": "map",
  23464. "show-location": true,
  23465. "libraries": ["places"],
  23466. "onUpdated": getList,
  23467. "onRegionchange": onRegionChange
  23468. }, {
  23469. default: () => [createVNode("div", {
  23470. "class": "map-location",
  23471. "style": `background-image: url("${ICON_PATH_TARGET}")`
  23472. }, null), createVNode("div", {
  23473. "class": "map-move",
  23474. "onClick": moveToLocation
  23475. }, [createSvgIconVNode(ICON_PATH_LOCTAION, "#000000", 24)], 8, ["onClick"])],
  23476. _: 1
  23477. }, 8, ["latitude", "longitude", "show-location", "onUpdated", "onRegionchange"]), createVNode("div", {
  23478. "class": "nav"
  23479. }, [createVNode("div", {
  23480. "class": "nav-btn back",
  23481. "onClick": onBack
  23482. }, [createSvgIconVNode(ICON_PATH_CLOSE, "#ffffff", 26)], 8, ["onClick"]), createVNode("div", {
  23483. "class": {
  23484. "nav-btn": true,
  23485. confirm: true,
  23486. disable: !listState.selected
  23487. },
  23488. "onClick": onChoose
  23489. }, [createSvgIconVNode(ICON_PATH_CONFIRM, "#ffffff", 26)], 10, ["onClick"])]), createVNode("div", {
  23490. "class": "menu"
  23491. }, [createVNode("div", {
  23492. "class": "search"
  23493. }, [createVNode(Input, {
  23494. "value": state2.keyword,
  23495. "class": "search-input",
  23496. "placeholder": t2("uni.chooseLocation.search"),
  23497. "onFocus": () => state2.searching = true,
  23498. "onInput": onInput
  23499. }, null, 8, ["value", "placeholder", "onFocus", "onInput"]), state2.searching && createVNode("div", {
  23500. "class": "search-btn",
  23501. "onClick": () => {
  23502. state2.searching = false;
  23503. state2.keyword = "";
  23504. }
  23505. }, [t2("uni.chooseLocation.cancel")], 8, ["onClick"])]), createVNode(ScrollView, {
  23506. "scroll-y": true,
  23507. "class": "list",
  23508. "onScrolltolower": loadMore
  23509. }, _isSlot$1(content) ? content : {
  23510. default: () => [content],
  23511. _: 2
  23512. }, 8, ["scroll-y", "onScrolltolower"])])]);
  23513. };
  23514. }
  23515. });
  23516. let state = null;
  23517. const chooseLocation = /* @__PURE__ */ defineAsyncApi(
  23518. API_CHOOSE_LOCATION,
  23519. (args, { resolve, reject }) => {
  23520. if (!state) {
  23521. state = reactive(args);
  23522. nextTick(() => {
  23523. const app = createRootApp(
  23524. LoctaionPicker,
  23525. state,
  23526. (poi) => {
  23527. state = null;
  23528. nextTick(() => {
  23529. app.unmount();
  23530. });
  23531. poi ? resolve(poi) : reject("cancel");
  23532. }
  23533. );
  23534. app.mount(ensureRoot("u-a-c"));
  23535. });
  23536. } else {
  23537. reject("cancel");
  23538. }
  23539. },
  23540. ChooseLocationProtocol
  23541. );
  23542. let started = false;
  23543. let watchId = 0;
  23544. const startLocationUpdate = /* @__PURE__ */ defineAsyncApi(
  23545. API_START_LOCATION_UPDATE,
  23546. (options, { resolve, reject }) => {
  23547. if (!navigator.geolocation) {
  23548. reject();
  23549. return;
  23550. }
  23551. watchId = watchId || navigator.geolocation.watchPosition(
  23552. (res) => {
  23553. started = true;
  23554. translateCoordinateSystem(options == null ? void 0 : options.type, res.coords).then((coords) => {
  23555. UniServiceJSBridge.invokeOnCallback(
  23556. API_ON_LOCATION_CHANGE,
  23557. coords
  23558. );
  23559. resolve();
  23560. }).catch((error) => {
  23561. UniServiceJSBridge.invokeOnCallback(
  23562. API_ON_LOCATION_CHANGE_ERROR,
  23563. { errMsg: `onLocationChange:fail ${error.message}` }
  23564. );
  23565. });
  23566. },
  23567. (error) => {
  23568. if (!started) {
  23569. reject(error.message);
  23570. started = true;
  23571. }
  23572. UniServiceJSBridge.invokeOnCallback(API_ON_LOCATION_CHANGE_ERROR, {
  23573. errMsg: `onLocationChange:fail ${error.message}`
  23574. });
  23575. }
  23576. );
  23577. setTimeout(resolve, 100);
  23578. },
  23579. StartLocationUpdateProtocol,
  23580. StartLocationUpdateOptions
  23581. );
  23582. const stopLocationUpdate = /* @__PURE__ */ defineAsyncApi(
  23583. API_STOP_LOCATION_UPDATE,
  23584. (_, { resolve }) => {
  23585. if (watchId) {
  23586. navigator.geolocation.clearWatch(watchId);
  23587. started = false;
  23588. watchId = 0;
  23589. }
  23590. resolve();
  23591. }
  23592. );
  23593. const onLocationChange = /* @__PURE__ */ defineOnApi(
  23594. API_ON_LOCATION_CHANGE,
  23595. () => {
  23596. }
  23597. );
  23598. const offLocationChange = /* @__PURE__ */ defineOffApi(
  23599. API_OFF_LOCATION_CHANGE,
  23600. () => {
  23601. }
  23602. );
  23603. const onLocationChangeError = /* @__PURE__ */ defineOnApi(
  23604. API_ON_LOCATION_CHANGE_ERROR,
  23605. () => {
  23606. }
  23607. );
  23608. const offLocationChangeError = /* @__PURE__ */ defineOffApi(
  23609. API_OFF_LOCATION_CHANGE_ERROR,
  23610. () => {
  23611. }
  23612. );
  23613. const navigateBack = /* @__PURE__ */ defineAsyncApi(
  23614. API_NAVIGATE_BACK,
  23615. (args, { resolve, reject }) => {
  23616. let canBack = true;
  23617. if (invokeHook(ON_BACK_PRESS, {
  23618. from: args.from || "navigateBack"
  23619. }) === true) {
  23620. canBack = false;
  23621. }
  23622. if (!canBack) {
  23623. return reject(ON_BACK_PRESS);
  23624. }
  23625. getApp().$router.go(-args.delta);
  23626. return resolve();
  23627. },
  23628. NavigateBackProtocol,
  23629. NavigateBackOptions
  23630. );
  23631. const navigateTo = /* @__PURE__ */ defineAsyncApi(
  23632. API_NAVIGATE_TO,
  23633. // @ts-expect-error
  23634. ({ url, events, isAutomatedTesting }, { resolve, reject }) => {
  23635. if (!entryPageState.handledBeforeEntryPageRoutes) {
  23636. navigateToPagesBeforeEntryPages.push({
  23637. args: { type: API_NAVIGATE_TO, url, events, isAutomatedTesting },
  23638. resolve,
  23639. reject
  23640. });
  23641. return;
  23642. }
  23643. return navigate({ type: API_NAVIGATE_TO, url, events, isAutomatedTesting }).then(resolve).catch(reject);
  23644. },
  23645. NavigateToProtocol,
  23646. NavigateToOptions
  23647. );
  23648. const preloadPage = /* @__PURE__ */ defineAsyncApi(
  23649. API_PRELOAD_PAGE,
  23650. ({ url }, { resolve, reject }) => {
  23651. const path = url.split("?")[0];
  23652. const route = getRouteOptions(path);
  23653. if (!route) {
  23654. reject(`${url}}`);
  23655. return;
  23656. }
  23657. route.loader && route.loader().then(() => {
  23658. resolve({
  23659. url,
  23660. errMsg: "preloadPage:ok"
  23661. });
  23662. }).catch((err) => {
  23663. reject(`${url} ${String(err)}`);
  23664. });
  23665. },
  23666. PreloadPageProtocol
  23667. );
  23668. const props$4 = {
  23669. title: {
  23670. type: String,
  23671. default: ""
  23672. },
  23673. icon: {
  23674. default: "success",
  23675. validator(value) {
  23676. return SHOW_TOAST_ICON.indexOf(value) !== -1;
  23677. }
  23678. },
  23679. image: {
  23680. type: String,
  23681. default: ""
  23682. },
  23683. duration: {
  23684. type: Number,
  23685. default: 1500
  23686. },
  23687. mask: {
  23688. type: Boolean,
  23689. default: false
  23690. },
  23691. visible: {
  23692. type: Boolean
  23693. }
  23694. };
  23695. const ToastIconClassName = "uni-toast__icon";
  23696. const ICONCOLOR = {
  23697. light: "#fff",
  23698. dark: "rgba(255,255,255,0.9)"
  23699. };
  23700. const getIconColor = (theme) => ICONCOLOR[theme];
  23701. const Toast = /* @__PURE__ */ defineComponent({
  23702. name: "Toast",
  23703. props: props$4,
  23704. setup(props2) {
  23705. initI18nShowToastMsgsOnce();
  23706. initI18nShowLoadingMsgsOnce();
  23707. const {
  23708. Icon
  23709. } = useToastIcon(props2);
  23710. const visible = usePopup(props2, {});
  23711. return () => {
  23712. const {
  23713. mask,
  23714. duration,
  23715. title,
  23716. image: image2
  23717. } = props2;
  23718. return createVNode(Transition, {
  23719. "name": "uni-fade"
  23720. }, {
  23721. default: () => [withDirectives(createVNode("uni-toast", {
  23722. "data-duration": duration
  23723. }, [mask ? createVNode("div", {
  23724. "class": "uni-mask",
  23725. "style": "background: transparent;",
  23726. "onTouchmove": onEventPrevent
  23727. }, null, 40, ["onTouchmove"]) : "", !image2 && !Icon.value ? createVNode("div", {
  23728. "class": "uni-sample-toast"
  23729. }, [createVNode("p", {
  23730. "class": "uni-simple-toast__text"
  23731. }, [title])]) : createVNode("div", {
  23732. "class": "uni-toast"
  23733. }, [image2 ? createVNode("img", {
  23734. "src": image2,
  23735. "class": ToastIconClassName
  23736. }, null, 10, ["src"]) : Icon.value, createVNode("p", {
  23737. "class": "uni-toast__content"
  23738. }, [title])])], 8, ["data-duration"]), [[vShow, visible.value]])]
  23739. });
  23740. };
  23741. }
  23742. });
  23743. function useToastIcon(props2) {
  23744. const iconColor = ref(getIconColor(getTheme()));
  23745. const _onThemeChange = ({
  23746. theme
  23747. }) => iconColor.value = getIconColor(theme);
  23748. watchEffect(() => {
  23749. if (props2.visible) {
  23750. onThemeChange$2(_onThemeChange);
  23751. } else {
  23752. offThemeChange$1(_onThemeChange);
  23753. }
  23754. });
  23755. const Icon = computed(() => {
  23756. switch (props2.icon) {
  23757. case "success":
  23758. return createVNode(createSvgIconVNode(ICON_PATH_SUCCESS_NO_CIRCLE, iconColor.value, 38), {
  23759. class: ToastIconClassName
  23760. });
  23761. case "error":
  23762. return createVNode(createSvgIconVNode(ICON_PATH_WARN, iconColor.value, 38), {
  23763. class: ToastIconClassName
  23764. });
  23765. case "loading":
  23766. return createVNode("i", {
  23767. "class": [ToastIconClassName, "uni-loading"]
  23768. }, null, 2);
  23769. default:
  23770. return null;
  23771. }
  23772. });
  23773. return {
  23774. Icon
  23775. };
  23776. }
  23777. let showToastState;
  23778. let showType = "";
  23779. let timeoutId;
  23780. const scope = /* @__PURE__ */ effectScope();
  23781. function watchVisible() {
  23782. scope.run(() => {
  23783. watch(
  23784. [() => showToastState.visible, () => showToastState.duration],
  23785. ([visible, duration]) => {
  23786. if (visible) {
  23787. timeoutId && clearTimeout(timeoutId);
  23788. if (showType === "onShowLoading")
  23789. return;
  23790. timeoutId = setTimeout(() => {
  23791. hidePopup("onHideToast");
  23792. }, duration);
  23793. } else {
  23794. timeoutId && clearTimeout(timeoutId);
  23795. }
  23796. }
  23797. );
  23798. });
  23799. }
  23800. function createToast(args) {
  23801. if (!showToastState) {
  23802. showToastState = reactive(extend(args, { visible: false }));
  23803. nextTick(() => {
  23804. watchVisible();
  23805. UniServiceJSBridge.on("onHidePopup", () => hidePopup("onHidePopup"));
  23806. createRootApp(Toast, showToastState, () => {
  23807. }).mount(ensureRoot("u-a-t"));
  23808. });
  23809. } else {
  23810. extend(showToastState, args);
  23811. }
  23812. setTimeout(() => {
  23813. showToastState.visible = true;
  23814. }, 10);
  23815. }
  23816. const showToast = /* @__PURE__ */ defineAsyncApi(
  23817. API_SHOW_TOAST,
  23818. (args, { resolve, reject }) => {
  23819. createToast(args);
  23820. showType = "onShowToast";
  23821. resolve();
  23822. },
  23823. ShowToastProtocol,
  23824. ShowToastOptions
  23825. );
  23826. const showLoadingDefaultState = {
  23827. icon: "loading",
  23828. duration: 1e8,
  23829. image: ""
  23830. };
  23831. const showLoading = /* @__PURE__ */ defineAsyncApi(
  23832. API_SHOW_LOADING,
  23833. (args, { resolve, reject }) => {
  23834. extend(args, showLoadingDefaultState);
  23835. createToast(args);
  23836. showType = "onShowLoading";
  23837. resolve();
  23838. },
  23839. ShowLoadingProtocol,
  23840. ShowLoadingOptions
  23841. );
  23842. const hideToast = /* @__PURE__ */ defineAsyncApi(
  23843. API_HIDE_TOAST,
  23844. (args, { resolve, reject }) => {
  23845. hidePopup("onHideToast");
  23846. resolve();
  23847. }
  23848. );
  23849. const hideLoading = /* @__PURE__ */ defineAsyncApi(
  23850. API_HIDE_LOADING,
  23851. (args, { resolve, reject }) => {
  23852. hidePopup("onHideLoading");
  23853. resolve();
  23854. }
  23855. );
  23856. function hidePopup(type) {
  23857. const { t: t2 } = useI18n();
  23858. if (!showType) {
  23859. return;
  23860. }
  23861. let warnMsg = "";
  23862. if (type === "onHideToast" && showType !== "onShowToast") {
  23863. warnMsg = t2("uni.showToast.unpaired");
  23864. } else if (type === "onHideLoading" && showType !== "onShowLoading") {
  23865. warnMsg = t2("uni.showLoading.unpaired");
  23866. }
  23867. if (warnMsg) {
  23868. return console.warn(warnMsg);
  23869. }
  23870. showType = "";
  23871. setTimeout(() => {
  23872. showToastState.visible = false;
  23873. }, 10);
  23874. }
  23875. const loadFontFace = /* @__PURE__ */ defineAsyncApi(
  23876. API_LOAD_FONT_FACE,
  23877. ({ family, source, desc }, { resolve, reject }) => {
  23878. if (source.startsWith(`url("`) || source.startsWith(`url('`)) {
  23879. source = `url('${getRealPath(source.substring(5, source.length - 2))}')`;
  23880. } else if (source.startsWith("url(")) {
  23881. source = `url('${getRealPath(source.substring(4, source.length - 1))}')`;
  23882. } else {
  23883. source = getRealPath(source);
  23884. }
  23885. addFont(family, source, desc).then(() => {
  23886. resolve();
  23887. }).catch((err) => {
  23888. reject(`loadFontFace:fail ${err}`);
  23889. });
  23890. },
  23891. LoadFontFaceProtocol
  23892. );
  23893. function updateDocumentTitle(title) {
  23894. {
  23895. document.title = title;
  23896. }
  23897. UniServiceJSBridge.emit(ON_NAVIGATION_BAR_CHANGE, { titleText: title });
  23898. }
  23899. function useDocumentTitle(pageMeta) {
  23900. function update() {
  23901. updateDocumentTitle(pageMeta.navigationBar.titleText);
  23902. }
  23903. watchEffect(update);
  23904. onActivated(update);
  23905. }
  23906. function setNavigationBar(pageMeta, type, args, resolve, reject) {
  23907. if (!pageMeta) {
  23908. return reject("page not found");
  23909. }
  23910. const { navigationBar } = pageMeta;
  23911. switch (type) {
  23912. case API_SET_NAVIGATION_BAR_COLOR:
  23913. const { frontColor, backgroundColor, animation: animation2 } = args;
  23914. const { duration, timingFunc } = animation2;
  23915. if (frontColor) {
  23916. navigationBar.titleColor = frontColor === "#000000" ? "#000000" : "#ffffff";
  23917. }
  23918. if (backgroundColor) {
  23919. navigationBar.backgroundColor = backgroundColor;
  23920. }
  23921. navigationBar.duration = duration + "ms";
  23922. navigationBar.timingFunc = timingFunc;
  23923. break;
  23924. case API_SHOW_NAVIGATION_BAR_LOADING:
  23925. navigationBar.loading = true;
  23926. break;
  23927. case API_HIDE_NAVIGATION_BAR_LOADING:
  23928. navigationBar.loading = false;
  23929. break;
  23930. case API_SET_NAVIGATION_BAR_TITLE:
  23931. const { title } = args;
  23932. navigationBar.titleText = title;
  23933. break;
  23934. }
  23935. resolve();
  23936. }
  23937. const setNavigationBarColor = /* @__PURE__ */ defineAsyncApi(
  23938. API_SET_NAVIGATION_BAR_COLOR,
  23939. (args, { resolve, reject }) => {
  23940. setNavigationBar(
  23941. getCurrentPageMeta(),
  23942. API_SET_NAVIGATION_BAR_COLOR,
  23943. args,
  23944. resolve,
  23945. reject
  23946. );
  23947. },
  23948. SetNavigationBarColorProtocol,
  23949. SetNavigationBarColorOptions
  23950. );
  23951. const showNavigationBarLoading = /* @__PURE__ */ defineAsyncApi(
  23952. API_SHOW_NAVIGATION_BAR_LOADING,
  23953. (args, { resolve, reject }) => {
  23954. setNavigationBar(
  23955. getCurrentPageMeta(),
  23956. API_SHOW_NAVIGATION_BAR_LOADING,
  23957. args || {},
  23958. resolve,
  23959. reject
  23960. );
  23961. }
  23962. );
  23963. const hideNavigationBarLoading = /* @__PURE__ */ defineAsyncApi(
  23964. API_HIDE_NAVIGATION_BAR_LOADING,
  23965. (args, { resolve, reject }) => {
  23966. setNavigationBar(
  23967. getCurrentPageMeta(),
  23968. API_HIDE_NAVIGATION_BAR_LOADING,
  23969. args || {},
  23970. resolve,
  23971. reject
  23972. );
  23973. }
  23974. );
  23975. const setNavigationBarTitle = /* @__PURE__ */ defineAsyncApi(
  23976. API_SET_NAVIGATION_BAR_TITLE,
  23977. (args, { resolve, reject }) => {
  23978. setNavigationBar(
  23979. getCurrentPageMeta(),
  23980. API_SET_NAVIGATION_BAR_TITLE,
  23981. args,
  23982. resolve,
  23983. reject
  23984. );
  23985. },
  23986. SetNavigationBarTitleProtocol
  23987. );
  23988. const pageScrollTo = /* @__PURE__ */ defineAsyncApi(
  23989. API_PAGE_SCROLL_TO,
  23990. ({ scrollTop, selector, duration }, { resolve }) => {
  23991. scrollTo(selector || scrollTop || 0, duration, true);
  23992. resolve();
  23993. },
  23994. PageScrollToProtocol,
  23995. PageScrollToOptions
  23996. );
  23997. const startPullDownRefresh = /* @__PURE__ */ defineAsyncApi(
  23998. API_START_PULL_DOWN_REFRESH,
  23999. (_args, { resolve }) => {
  24000. UniServiceJSBridge.invokeViewMethod(
  24001. API_START_PULL_DOWN_REFRESH,
  24002. {},
  24003. getCurrentPageId()
  24004. );
  24005. resolve();
  24006. }
  24007. );
  24008. const stopPullDownRefresh = /* @__PURE__ */ defineAsyncApi(
  24009. API_STOP_PULL_DOWN_REFRESH,
  24010. (_args, { resolve }) => {
  24011. UniServiceJSBridge.invokeViewMethod(
  24012. API_STOP_PULL_DOWN_REFRESH,
  24013. {},
  24014. getCurrentPageId()
  24015. );
  24016. resolve();
  24017. }
  24018. );
  24019. const setTabBarItemProps = [
  24020. "text",
  24021. "iconPath",
  24022. "iconfont",
  24023. "selectedIconPath",
  24024. "visible"
  24025. ];
  24026. const setTabBarStyleProps = [
  24027. "color",
  24028. "selectedColor",
  24029. "backgroundColor",
  24030. "borderStyle",
  24031. "borderColor",
  24032. "midButton"
  24033. ];
  24034. const setTabBarBadgeProps = ["badge", "redDot"];
  24035. function setProperties(item, props2, propsData) {
  24036. props2.forEach(function(name) {
  24037. if (hasOwn(propsData, name)) {
  24038. item[name] = propsData[name];
  24039. }
  24040. });
  24041. }
  24042. function setTabBar(type, args, resolve, reject) {
  24043. var _a;
  24044. let isTabBar = false;
  24045. const pages = getCurrentPages();
  24046. if (pages.length) {
  24047. if (pages[pages.length - 1].$page.meta.isTabBar) {
  24048. isTabBar = true;
  24049. }
  24050. }
  24051. if (!isTabBar) {
  24052. return reject(`not TabBar page`);
  24053. }
  24054. const { index: index2 } = args;
  24055. if (typeof index2 === "number") {
  24056. const tabBarListLength = (_a = __uniConfig == null ? void 0 : __uniConfig.tabBar) == null ? void 0 : _a.list.length;
  24057. if (!tabBarListLength || index2 >= tabBarListLength) {
  24058. return reject(`tabbar item not found`);
  24059. }
  24060. }
  24061. const tabBar2 = useTabBar();
  24062. switch (type) {
  24063. case API_SHOW_TAB_BAR:
  24064. tabBar2.shown = true;
  24065. break;
  24066. case API_HIDE_TAB_BAR:
  24067. tabBar2.shown = false;
  24068. break;
  24069. case API_SET_TAB_BAR_ITEM:
  24070. const tabBarItem = tabBar2.list[index2];
  24071. const oldPagePath = tabBarItem.pagePath;
  24072. setProperties(tabBarItem, setTabBarItemProps, args);
  24073. const { pagePath } = args;
  24074. if (pagePath) {
  24075. const newPagePath = addLeadingSlash(pagePath);
  24076. if (newPagePath !== oldPagePath) {
  24077. normalizeTabBarRoute(index2, oldPagePath, newPagePath);
  24078. }
  24079. }
  24080. break;
  24081. case API_SET_TAB_BAR_STYLE:
  24082. setProperties(tabBar2, setTabBarStyleProps, args);
  24083. break;
  24084. case API_SHOW_TAB_BAR_RED_DOT:
  24085. setProperties(tabBar2.list[index2], setTabBarBadgeProps, {
  24086. badge: "",
  24087. redDot: true
  24088. });
  24089. break;
  24090. case API_SET_TAB_BAR_BADGE:
  24091. setProperties(tabBar2.list[index2], setTabBarBadgeProps, {
  24092. badge: args.text,
  24093. redDot: true
  24094. });
  24095. break;
  24096. case API_HIDE_TAB_BAR_RED_DOT:
  24097. case API_REMOVE_TAB_BAR_BADGE:
  24098. setProperties(tabBar2.list[index2], setTabBarBadgeProps, {
  24099. badge: "",
  24100. redDot: false
  24101. });
  24102. break;
  24103. }
  24104. resolve();
  24105. }
  24106. const setTabBarItem = /* @__PURE__ */ defineAsyncApi(
  24107. API_SET_TAB_BAR_ITEM,
  24108. (args, { resolve, reject }) => {
  24109. setTabBar(API_SET_TAB_BAR_ITEM, args, resolve, reject);
  24110. },
  24111. SetTabBarItemProtocol,
  24112. SetTabBarItemOptions
  24113. );
  24114. const setTabBarStyle = /* @__PURE__ */ defineAsyncApi(
  24115. API_SET_TAB_BAR_STYLE,
  24116. (args, { resolve, reject }) => {
  24117. setTabBar(API_SET_TAB_BAR_STYLE, args, resolve, reject);
  24118. },
  24119. SetTabBarStyleProtocol,
  24120. SetTabBarStyleOptions
  24121. );
  24122. const hideTabBar = /* @__PURE__ */ defineAsyncApi(
  24123. API_HIDE_TAB_BAR,
  24124. (args, { resolve, reject }) => {
  24125. setTabBar(API_HIDE_TAB_BAR, args ? args : {}, resolve, reject);
  24126. },
  24127. HideTabBarProtocol
  24128. );
  24129. const showTabBar = /* @__PURE__ */ defineAsyncApi(
  24130. API_SHOW_TAB_BAR,
  24131. (args, { resolve, reject }) => {
  24132. setTabBar(API_SHOW_TAB_BAR, args ? args : {}, resolve, reject);
  24133. },
  24134. ShowTabBarProtocol
  24135. );
  24136. const hideTabBarRedDot = /* @__PURE__ */ defineAsyncApi(
  24137. API_HIDE_TAB_BAR_RED_DOT,
  24138. (args, { resolve, reject }) => {
  24139. setTabBar(API_HIDE_TAB_BAR_RED_DOT, args, resolve, reject);
  24140. },
  24141. HideTabBarRedDotProtocol,
  24142. HideTabBarRedDotOptions
  24143. );
  24144. const showTabBarRedDot = /* @__PURE__ */ defineAsyncApi(
  24145. API_SHOW_TAB_BAR_RED_DOT,
  24146. (args, { resolve, reject }) => {
  24147. setTabBar(API_SHOW_TAB_BAR_RED_DOT, args, resolve, reject);
  24148. },
  24149. ShowTabBarRedDotProtocol,
  24150. ShowTabBarRedDotOptions
  24151. );
  24152. const removeTabBarBadge = /* @__PURE__ */ defineAsyncApi(
  24153. API_REMOVE_TAB_BAR_BADGE,
  24154. (args, { resolve, reject }) => {
  24155. setTabBar(API_REMOVE_TAB_BAR_BADGE, args, resolve, reject);
  24156. },
  24157. RemoveTabBarBadgeProtocol,
  24158. RemoveTabBarBadgeOptions
  24159. );
  24160. const setTabBarBadge = /* @__PURE__ */ defineAsyncApi(
  24161. API_SET_TAB_BAR_BADGE,
  24162. (args, { resolve, reject }) => {
  24163. setTabBar(API_SET_TAB_BAR_BADGE, args, resolve, reject);
  24164. },
  24165. SetTabBarBadgeProtocol,
  24166. SetTabBarBadgeOptions
  24167. );
  24168. const UNI_TABBAR_ICON_FONT = "UniTabbarIconFont";
  24169. const _middleButton = {
  24170. width: "50px",
  24171. height: "50px",
  24172. iconWidth: "24px"
  24173. };
  24174. const TabBar = /* @__PURE__ */ defineSystemComponent({
  24175. name: "TabBar",
  24176. setup() {
  24177. const visibleList = ref([]);
  24178. const _tabBar = useTabBar();
  24179. const tabBar2 = useTheme(_tabBar, () => {
  24180. const tabBarStyle = parseTheme(_tabBar);
  24181. tabBar2.backgroundColor = tabBarStyle.backgroundColor;
  24182. tabBar2.borderStyle = tabBarStyle.borderStyle;
  24183. tabBar2.color = tabBarStyle.color;
  24184. tabBar2.selectedColor = tabBarStyle.selectedColor;
  24185. tabBar2.blurEffect = tabBarStyle.blurEffect;
  24186. tabBar2.midButton = tabBarStyle.midButton;
  24187. if (tabBarStyle.list && tabBarStyle.list.length) {
  24188. tabBarStyle.list.forEach((item, index2) => {
  24189. tabBar2.list[index2].iconPath = item.iconPath;
  24190. tabBar2.list[index2].selectedIconPath = item.selectedIconPath;
  24191. });
  24192. }
  24193. });
  24194. useVisibleList(tabBar2, visibleList);
  24195. useTabBarCssVar(tabBar2);
  24196. const onSwitchTab = useSwitchTab(useRoute(), tabBar2, visibleList);
  24197. const {
  24198. style,
  24199. borderStyle,
  24200. placeholderStyle
  24201. } = useTabBarStyle(tabBar2);
  24202. onMounted(() => {
  24203. if (tabBar2.iconfontSrc) {
  24204. loadFontFace({
  24205. family: UNI_TABBAR_ICON_FONT,
  24206. source: `url("${tabBar2.iconfontSrc}")`
  24207. });
  24208. }
  24209. });
  24210. return () => {
  24211. const tabBarItemsTsx = createTabBarItemsTsx(tabBar2, onSwitchTab, visibleList);
  24212. return createVNode("uni-tabbar", {
  24213. "class": "uni-tabbar-" + tabBar2.position
  24214. }, [createVNode("div", {
  24215. "class": "uni-tabbar",
  24216. "style": style.value
  24217. }, [createVNode("div", {
  24218. "class": "uni-tabbar-border",
  24219. "style": borderStyle.value
  24220. }, null, 4), tabBarItemsTsx], 4), createVNode("div", {
  24221. "class": "uni-placeholder",
  24222. "style": placeholderStyle.value
  24223. }, null, 4)], 2);
  24224. };
  24225. }
  24226. });
  24227. function useTabBarCssVar(tabBar2) {
  24228. watch(() => tabBar2.shown, (value) => {
  24229. updatePageCssVar({
  24230. "--window-bottom": normalizeWindowBottom(value ? parseInt(tabBar2.height) : 0)
  24231. });
  24232. });
  24233. }
  24234. function useVisibleList(tabBar2, visibleList) {
  24235. const internalMidButton = ref(extend({
  24236. type: "midButton"
  24237. }, tabBar2.midButton));
  24238. function setVisibleList() {
  24239. let tempList = [];
  24240. tempList = tabBar2.list.filter((item) => item.visible !== false);
  24241. if (__UNI_FEATURE_TABBAR_MIDBUTTON__ && tabBar2.midButton) {
  24242. internalMidButton.value = extend({}, _middleButton, internalMidButton.value, tabBar2.midButton);
  24243. tempList = tempList.filter((item) => !isMidButton(item));
  24244. if (tempList.length % 2 === 0) {
  24245. tempList.splice(Math.floor(tempList.length / 2), 0, internalMidButton.value);
  24246. }
  24247. }
  24248. visibleList.value = tempList;
  24249. }
  24250. watchEffect(setVisibleList);
  24251. }
  24252. function useSwitchTab(route, tabBar2, visibleList) {
  24253. watchEffect(() => {
  24254. const meta = route.meta;
  24255. if (meta.isTabBar) {
  24256. const pagePath = meta.route;
  24257. const index2 = visibleList.value.findIndex((item) => item.pagePath === pagePath);
  24258. tabBar2.selectedIndex = index2;
  24259. }
  24260. });
  24261. return (tabBarItem, index2) => {
  24262. const {
  24263. type
  24264. } = tabBarItem;
  24265. return () => {
  24266. if (__UNI_FEATURE_TABBAR_MIDBUTTON__ && type === "midButton") {
  24267. return UniServiceJSBridge.invokeOnCallback(API_ON_TAB_BAR_MID_BUTTON_TAP);
  24268. }
  24269. const {
  24270. pagePath,
  24271. text: text2
  24272. } = tabBarItem;
  24273. let url = addLeadingSlash(pagePath);
  24274. if (url === __uniRoutes[0].alias) {
  24275. url = "/";
  24276. }
  24277. if (route.path !== url) {
  24278. uni.switchTab({
  24279. from: "tabBar",
  24280. url,
  24281. tabBarText: text2
  24282. });
  24283. } else {
  24284. invokeHook("onTabItemTap", {
  24285. index: index2,
  24286. text: text2,
  24287. pagePath
  24288. });
  24289. }
  24290. };
  24291. };
  24292. }
  24293. const DEFAULT_BG_COLOR = "#f7f7fa";
  24294. const BLUR_EFFECT_COLOR_DARK = "rgb(0, 0, 0, 0.8)";
  24295. const BLUR_EFFECT_COLOR_LIGHT = "rgb(250, 250, 250, 0.8)";
  24296. const BLUR_EFFECT_COLORS = {
  24297. dark: BLUR_EFFECT_COLOR_DARK,
  24298. light: BLUR_EFFECT_COLOR_LIGHT,
  24299. extralight: BLUR_EFFECT_COLOR_LIGHT
  24300. };
  24301. const BORDER_COLORS = {
  24302. white: "rgba(255, 255, 255, 0.33)",
  24303. black: "rgba(0, 0, 0, 0.33)"
  24304. };
  24305. function useTabBarStyle(tabBar2) {
  24306. const style = computed(() => {
  24307. let backgroundColor = tabBar2.backgroundColor;
  24308. const blurEffect = tabBar2.blurEffect;
  24309. if (!backgroundColor) {
  24310. if (cssBackdropFilter && blurEffect && blurEffect !== "none") {
  24311. backgroundColor = BLUR_EFFECT_COLORS[blurEffect];
  24312. }
  24313. }
  24314. return {
  24315. backgroundColor: backgroundColor || DEFAULT_BG_COLOR,
  24316. backdropFilter: blurEffect !== "none" ? "blur(10px)" : blurEffect
  24317. };
  24318. });
  24319. const borderStyle = computed(() => {
  24320. const {
  24321. borderStyle: borderStyle2,
  24322. borderColor
  24323. } = tabBar2;
  24324. if (borderColor && isString(borderColor)) {
  24325. return {
  24326. backgroundColor: borderColor
  24327. };
  24328. }
  24329. return {
  24330. backgroundColor: BORDER_COLORS[borderStyle2] || BORDER_COLORS["black"]
  24331. };
  24332. });
  24333. const placeholderStyle = computed(() => {
  24334. return {
  24335. height: tabBar2.height
  24336. };
  24337. });
  24338. return {
  24339. style,
  24340. borderStyle,
  24341. placeholderStyle
  24342. };
  24343. }
  24344. function isMidButton(item) {
  24345. return item.type === "midButton";
  24346. }
  24347. function createTabBarItemsTsx(tabBar2, onSwitchTab, visibleList) {
  24348. const {
  24349. selectedIndex,
  24350. selectedColor,
  24351. color
  24352. } = tabBar2;
  24353. return visibleList.value.map((item, index2) => {
  24354. const selected = selectedIndex === index2;
  24355. const textColor = selected ? selectedColor : color;
  24356. const iconPath = (selected ? item.selectedIconPath || item.iconPath : item.iconPath) || "";
  24357. const iconfontText = item.iconfont ? selected ? item.iconfont.selectedText || item.iconfont.text : item.iconfont.text : void 0;
  24358. const iconfontColor = item.iconfont ? selected ? item.iconfont.selectedColor || item.iconfont.color : item.iconfont.color : void 0;
  24359. if (!__UNI_FEATURE_TABBAR_MIDBUTTON__) {
  24360. return createTabBarItemTsx(textColor, iconPath, iconfontText, iconfontColor, item, tabBar2, index2, onSwitchTab);
  24361. }
  24362. return isMidButton(item) ? createTabBarMidButtonTsx(textColor, iconPath, iconfontText, iconfontColor, item, tabBar2, index2, onSwitchTab) : createTabBarItemTsx(textColor, iconPath, iconfontText, iconfontColor, item, tabBar2, index2, onSwitchTab);
  24363. });
  24364. }
  24365. function createTabBarItemTsx(color, iconPath, iconfontText, iconfontColor, tabBarItem, tabBar2, index2, onSwitchTab) {
  24366. return createVNode("div", {
  24367. "key": index2,
  24368. "class": "uni-tabbar__item",
  24369. "onClick": onSwitchTab(tabBarItem, index2)
  24370. }, [createTabBarItemBdTsx(color, iconPath || "", iconfontText, iconfontColor, tabBarItem, tabBar2)], 8, ["onClick"]);
  24371. }
  24372. function createTabBarItemBdTsx(color, iconPath, iconfontText, iconfontColor, tabBarItem, tabBar2) {
  24373. const {
  24374. height
  24375. } = tabBar2;
  24376. return createVNode("div", {
  24377. "class": "uni-tabbar__bd",
  24378. "style": {
  24379. height
  24380. }
  24381. }, [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);
  24382. }
  24383. function createTabBarItemIconTsx(iconPath, tabBarItem, tabBar2) {
  24384. const {
  24385. type,
  24386. text: text2
  24387. } = tabBarItem;
  24388. const {
  24389. iconWidth
  24390. } = tabBar2;
  24391. const clazz2 = "uni-tabbar__icon" + (text2 ? " uni-tabbar__icon__diff" : "");
  24392. const style = {
  24393. width: iconWidth,
  24394. height: iconWidth
  24395. };
  24396. return createVNode("div", {
  24397. "class": clazz2,
  24398. "style": style
  24399. }, [type !== "midButton" && createVNode("img", {
  24400. "src": getRealPath(iconPath)
  24401. }, null, 8, ["src"])], 6);
  24402. }
  24403. function createTabBarItemIconfontTsx(iconfontText, iconfontColor, tabBarItem, tabBar2) {
  24404. var _a;
  24405. const {
  24406. type,
  24407. text: text2
  24408. } = tabBarItem;
  24409. const {
  24410. iconWidth
  24411. } = tabBar2;
  24412. const clazz2 = "uni-tabbar__icon" + (text2 ? " uni-tabbar__icon__diff" : "");
  24413. const style = {
  24414. width: iconWidth,
  24415. height: iconWidth
  24416. };
  24417. const iconfontStyle = {
  24418. fontSize: ((_a = tabBarItem.iconfont) == null ? void 0 : _a.fontSize) || iconWidth,
  24419. color: iconfontColor
  24420. };
  24421. return createVNode("div", {
  24422. "class": clazz2,
  24423. "style": style
  24424. }, [type !== "midButton" && createVNode("div", {
  24425. "class": "uni-tabbar__iconfont",
  24426. "style": iconfontStyle
  24427. }, [iconfontText], 4)], 6);
  24428. }
  24429. function createTabBarItemTextTsx(color, tabBarItem, tabBar2) {
  24430. const {
  24431. iconPath,
  24432. text: text2
  24433. } = tabBarItem;
  24434. const {
  24435. fontSize,
  24436. spacing
  24437. } = tabBar2;
  24438. const style = {
  24439. color,
  24440. fontSize,
  24441. lineHeight: !iconPath ? 1.8 : "normal",
  24442. marginTop: !iconPath ? "inherit" : spacing
  24443. };
  24444. return createVNode("div", {
  24445. "class": "uni-tabbar__label",
  24446. "style": style
  24447. }, [text2], 4);
  24448. }
  24449. function createTabBarItemRedDotTsx(badge) {
  24450. const clazz2 = "uni-tabbar__reddot" + (badge ? " uni-tabbar__badge" : "");
  24451. return createVNode("div", {
  24452. "class": clazz2
  24453. }, [badge], 2);
  24454. }
  24455. function createTabBarMidButtonTsx(color, iconPath, iconfontText, iconfontColor, midButton, tabBar2, index2, onSwitchTab) {
  24456. const {
  24457. width,
  24458. height,
  24459. backgroundImage,
  24460. iconWidth
  24461. } = midButton;
  24462. return createVNode("div", {
  24463. "key": "midButton",
  24464. "class": "uni-tabbar__item",
  24465. "style": {
  24466. flex: "0 0 " + width,
  24467. position: "relative"
  24468. },
  24469. "onClick": onSwitchTab(midButton, index2)
  24470. }, [createVNode("div", {
  24471. "class": "uni-tabbar__mid",
  24472. "style": {
  24473. width,
  24474. height,
  24475. backgroundImage: backgroundImage ? "url('" + getRealPath(backgroundImage) + "')" : "none"
  24476. }
  24477. }, [iconPath && createVNode("img", {
  24478. "style": {
  24479. width: iconWidth,
  24480. height: iconWidth
  24481. },
  24482. "src": getRealPath(iconPath)
  24483. }, null, 12, ["src"])], 4), createTabBarItemBdTsx(color, iconPath, iconfontText, iconfontColor, midButton, tabBar2)], 12, ["onClick"]);
  24484. }
  24485. const DEFAULT_CSS_VAR_VALUE = "0px";
  24486. let globalLayoutState = void 0;
  24487. function getLayoutState() {
  24488. return globalLayoutState;
  24489. }
  24490. const LayoutComponent = /* @__PURE__ */ defineSystemComponent({
  24491. name: "Layout",
  24492. setup(_props, {
  24493. emit: emit2
  24494. }) {
  24495. const rootRef = ref(null);
  24496. initCssVar();
  24497. const keepAliveRoute = __UNI_FEATURE_PAGES__ && useKeepAliveRoute();
  24498. const {
  24499. layoutState,
  24500. windowState
  24501. } = useState();
  24502. useMaxWidth(layoutState, rootRef);
  24503. const topWindow = __UNI_FEATURE_TOPWINDOW__ && useTopWindow(layoutState);
  24504. const leftWindow = __UNI_FEATURE_LEFTWINDOW__ && useLeftWindow(layoutState);
  24505. const rightWindow = __UNI_FEATURE_RIGHTWINDOW__ && useRightWindow(layoutState);
  24506. const showTabBar2 = __UNI_FEATURE_TABBAR__ && useShowTabBar();
  24507. const clazz2 = useAppClass(showTabBar2);
  24508. globalLayoutState = layoutState;
  24509. return () => {
  24510. const layoutTsx = createLayoutTsx(keepAliveRoute, layoutState, windowState, topWindow, leftWindow, rightWindow);
  24511. const tabBarTsx = __UNI_FEATURE_TABBAR__ && createTabBarTsx(showTabBar2);
  24512. return createVNode("uni-app", {
  24513. "ref": rootRef,
  24514. "class": clazz2.value
  24515. }, [layoutTsx, tabBarTsx], 2);
  24516. };
  24517. }
  24518. });
  24519. function useAppClass(showTabBar2) {
  24520. const showMaxWidth = ref(false);
  24521. return computed(() => {
  24522. return {
  24523. "uni-app--showtabbar": showTabBar2 && showTabBar2.value,
  24524. "uni-app--maxwidth": showMaxWidth.value
  24525. };
  24526. });
  24527. }
  24528. function initCssVar() {
  24529. updateCssVar({
  24530. "--status-bar-height": DEFAULT_CSS_VAR_VALUE,
  24531. "--top-window-height": DEFAULT_CSS_VAR_VALUE,
  24532. "--window-left": DEFAULT_CSS_VAR_VALUE,
  24533. "--window-right": DEFAULT_CSS_VAR_VALUE,
  24534. "--window-margin": DEFAULT_CSS_VAR_VALUE,
  24535. "--tab-bar-height": DEFAULT_CSS_VAR_VALUE
  24536. });
  24537. }
  24538. function initMediaQuery(minWidth, callback) {
  24539. const mediaQueryList = window.matchMedia("(min-width: " + minWidth + "px)");
  24540. if (mediaQueryList.addEventListener) {
  24541. mediaQueryList.addEventListener("change", callback);
  24542. } else {
  24543. mediaQueryList.addListener(callback);
  24544. }
  24545. return mediaQueryList.matches;
  24546. }
  24547. function useMaxWidth(layoutState, rootRef) {
  24548. const route = usePageRoute();
  24549. function checkMaxWidth2() {
  24550. const windowWidth = document.body.clientWidth;
  24551. const pages = getCurrentPages();
  24552. let meta = {};
  24553. if (pages.length > 0) {
  24554. const curPage = pages[pages.length - 1];
  24555. meta = curPage.$page.meta;
  24556. } else {
  24557. const routeOptions = getRouteOptions(route.path, true);
  24558. if (routeOptions) {
  24559. meta = routeOptions.meta;
  24560. }
  24561. }
  24562. const maxWidth2 = parseInt(String((hasOwn(meta, "maxWidth") ? meta.maxWidth : __uniConfig.globalStyle.maxWidth) || Number.MAX_SAFE_INTEGER));
  24563. let showMaxWidth = false;
  24564. if (windowWidth > maxWidth2) {
  24565. showMaxWidth = true;
  24566. } else {
  24567. showMaxWidth = false;
  24568. }
  24569. if (showMaxWidth && maxWidth2) {
  24570. layoutState.marginWidth = (windowWidth - maxWidth2) / 2;
  24571. nextTick(() => {
  24572. const rootEl = rootRef.value;
  24573. if (rootEl) {
  24574. rootEl.setAttribute("style", "max-width:" + maxWidth2 + "px;margin:0 auto;");
  24575. }
  24576. });
  24577. } else {
  24578. layoutState.marginWidth = 0;
  24579. nextTick(() => {
  24580. const rootEl = rootRef.value;
  24581. if (rootEl) {
  24582. rootEl.removeAttribute("style");
  24583. }
  24584. });
  24585. }
  24586. }
  24587. watch([() => route.path], checkMaxWidth2);
  24588. onMounted(() => {
  24589. checkMaxWidth2();
  24590. window.addEventListener("resize", checkMaxWidth2);
  24591. });
  24592. }
  24593. function useState() {
  24594. const route = usePageRoute();
  24595. if (!__UNI_FEATURE_RESPONSIVE__) {
  24596. const layoutState2 = reactive({
  24597. marginWidth: 0,
  24598. leftWindowWidth: 0,
  24599. rightWindowWidth: 0
  24600. });
  24601. watch(() => layoutState2.marginWidth, (value) => updateCssVar({
  24602. "--window-margin": value + "px"
  24603. }));
  24604. watch(() => layoutState2.leftWindowWidth + layoutState2.marginWidth, (value) => {
  24605. updateCssVar({
  24606. "--window-left": value + "px"
  24607. });
  24608. });
  24609. watch(() => layoutState2.rightWindowWidth + layoutState2.marginWidth, (value) => {
  24610. updateCssVar({
  24611. "--window-right": value + "px"
  24612. });
  24613. });
  24614. return {
  24615. layoutState: layoutState2,
  24616. windowState: computed(() => ({}))
  24617. };
  24618. }
  24619. const topWindowMediaQuery = ref(false);
  24620. const leftWindowMediaQuery = ref(false);
  24621. const rightWindowMediaQuery = ref(false);
  24622. const showTopWindow2 = computed(() => __UNI_FEATURE_TOPWINDOW__ && route.meta.topWindow !== false && topWindowMediaQuery.value);
  24623. const showLeftWindow2 = computed(() => __UNI_FEATURE_LEFTWINDOW__ && route.meta.leftWindow !== false && leftWindowMediaQuery.value);
  24624. const showRightWindow2 = computed(() => __UNI_FEATURE_RIGHTWINDOW__ && route.meta.rightWindow !== false && rightWindowMediaQuery.value);
  24625. const layoutState = reactive({
  24626. topWindowMediaQuery,
  24627. showTopWindow: showTopWindow2,
  24628. apiShowTopWindow: false,
  24629. leftWindowMediaQuery,
  24630. showLeftWindow: showLeftWindow2,
  24631. apiShowLeftWindow: false,
  24632. rightWindowMediaQuery,
  24633. showRightWindow: showRightWindow2,
  24634. apiShowRightWindow: false,
  24635. topWindowHeight: 0,
  24636. marginWidth: 0,
  24637. leftWindowWidth: 0,
  24638. rightWindowWidth: 0,
  24639. navigationBarTitleText: "",
  24640. topWindowStyle: {},
  24641. leftWindowStyle: {},
  24642. rightWindowStyle: {}
  24643. });
  24644. const props2 = ["topWindow", "leftWindow", "rightWindow"];
  24645. props2.forEach((prop) => {
  24646. var _a;
  24647. const matchMedia = (_a = __uniConfig[prop]) == null ? void 0 : _a.matchMedia;
  24648. let topWindowMinWidth = RESPONSIVE_MIN_WIDTH;
  24649. if (matchMedia && hasOwn(matchMedia, "minWidth")) {
  24650. const minWidth = matchMedia.minWidth;
  24651. topWindowMinWidth = checkMinWidth(minWidth) ? minWidth : topWindowMinWidth;
  24652. }
  24653. const matches2 = initMediaQuery(topWindowMinWidth, (ev) => {
  24654. layoutState[`${prop}MediaQuery`] = ev.matches;
  24655. });
  24656. layoutState[`${prop}MediaQuery`] = matches2;
  24657. });
  24658. watch(() => layoutState.topWindowHeight, (value) => updateCssVar({
  24659. "--top-window-height": value + "px"
  24660. }));
  24661. watch(() => layoutState.marginWidth, (value) => updateCssVar({
  24662. "--window-margin": value + "px"
  24663. }));
  24664. watch(() => layoutState.leftWindowWidth + layoutState.marginWidth, (value) => {
  24665. updateCssVar({
  24666. "--window-left": value + "px"
  24667. });
  24668. });
  24669. watch(() => layoutState.rightWindowWidth + layoutState.marginWidth, (value) => {
  24670. updateCssVar({
  24671. "--window-right": value + "px"
  24672. });
  24673. });
  24674. UniServiceJSBridge.on(ON_NAVIGATION_BAR_CHANGE, (navigationBar) => {
  24675. layoutState.navigationBarTitleText = navigationBar.titleText;
  24676. });
  24677. const windowState = computed(() => ({
  24678. matchTopWindow: layoutState.topWindowMediaQuery,
  24679. showTopWindow: layoutState.showTopWindow || layoutState.apiShowTopWindow,
  24680. matchLeftWindow: layoutState.leftWindowMediaQuery,
  24681. showLeftWindow: layoutState.showLeftWindow || layoutState.apiShowLeftWindow,
  24682. matchRightWindow: layoutState.rightWindowMediaQuery,
  24683. showRightWindow: layoutState.showRightWindow || layoutState.apiShowRightWindow
  24684. }));
  24685. return {
  24686. layoutState,
  24687. windowState
  24688. };
  24689. }
  24690. function createLayoutTsx(keepAliveRoute, layoutState, windowState, topWindow, leftWindow, rightWindow) {
  24691. const routerVNode = __UNI_FEATURE_PAGES__ ? createRouterViewVNode(keepAliveRoute) : createPageVNode();
  24692. if (!__UNI_FEATURE_RESPONSIVE__) {
  24693. return routerVNode;
  24694. }
  24695. const topWindowTsx = __UNI_FEATURE_TOPWINDOW__ ? createTopWindowTsx(topWindow, layoutState, windowState.value) : null;
  24696. const leftWindowTsx = __UNI_FEATURE_LEFTWINDOW__ ? createLeftWindowTsx(leftWindow, layoutState, windowState.value) : null;
  24697. const rightWindowTsx = __UNI_FEATURE_RIGHTWINDOW__ ? createRightWindowTsx(rightWindow, layoutState, windowState.value) : null;
  24698. return createVNode("uni-layout", {
  24699. "class": {
  24700. "uni-app--showtopwindow": __UNI_FEATURE_TOPWINDOW__ && layoutState.showTopWindow,
  24701. "uni-app--showleftwindow": __UNI_FEATURE_LEFTWINDOW__ && layoutState.showLeftWindow,
  24702. "uni-app--showrightwindow": __UNI_FEATURE_RIGHTWINDOW__ && layoutState.showRightWindow
  24703. }
  24704. }, [topWindowTsx, createVNode("uni-content", null, [createVNode("uni-main", null, [routerVNode]), leftWindowTsx, rightWindowTsx])], 2);
  24705. }
  24706. function useShowTabBar(emit2) {
  24707. const route = usePageRoute();
  24708. const tabBar2 = useTabBar();
  24709. const showTabBar2 = computed(() => route.meta.isTabBar && tabBar2.shown);
  24710. updateCssVar({
  24711. "--tab-bar-height": tabBar2.height
  24712. });
  24713. return showTabBar2;
  24714. }
  24715. function createTabBarTsx(showTabBar2) {
  24716. return withDirectives(createVNode(TabBar, null, null, 512), [[vShow, showTabBar2.value]]);
  24717. }
  24718. function createPageVNode() {
  24719. return createVNode(__uniRoutes[0].component);
  24720. }
  24721. function createRouterViewVNode({
  24722. routeKey,
  24723. isTabBar,
  24724. routeCache: routeCache2
  24725. }) {
  24726. return createVNode(RouterView, null, {
  24727. default: withCtx(({
  24728. Component
  24729. }) => [(openBlock(), createBlock(KeepAlive, {
  24730. matchBy: "key",
  24731. cache: routeCache2
  24732. }, [(openBlock(), createBlock(resolveDynamicComponent(Component), {
  24733. type: isTabBar.value ? "tabBar" : "",
  24734. key: routeKey.value
  24735. }))], 1032, ["cache"]))]),
  24736. _: 1
  24737. /* STABLE */
  24738. });
  24739. }
  24740. function useTopWindow(layoutState) {
  24741. const {
  24742. component,
  24743. style
  24744. } = __uniConfig.topWindow;
  24745. const windowRef = ref(null);
  24746. function updateWindow() {
  24747. const instance2 = windowRef.value;
  24748. const el = resolveOwnerEl(instance2.$);
  24749. const height = el.getBoundingClientRect().height;
  24750. layoutState.topWindowHeight = height;
  24751. }
  24752. onMounted(updateWindow);
  24753. watch(() => layoutState.showTopWindow || layoutState.apiShowTopWindow, () => nextTick(updateWindow));
  24754. layoutState.topWindowStyle = style;
  24755. return {
  24756. component,
  24757. windowRef
  24758. };
  24759. }
  24760. function useLeftWindow(layoutState) {
  24761. const {
  24762. component,
  24763. style
  24764. } = __uniConfig.leftWindow;
  24765. const windowRef = ref(null);
  24766. function updateWindow() {
  24767. const instance2 = windowRef.value;
  24768. const el = resolveOwnerEl(instance2.$);
  24769. const width = el.getBoundingClientRect().width;
  24770. layoutState.leftWindowWidth = width;
  24771. }
  24772. onMounted(updateWindow);
  24773. watch(() => layoutState.showLeftWindow || layoutState.apiShowLeftWindow, () => nextTick(updateWindow));
  24774. layoutState.leftWindowStyle = style;
  24775. return {
  24776. component,
  24777. windowRef
  24778. };
  24779. }
  24780. function useRightWindow(layoutState) {
  24781. const {
  24782. component,
  24783. style
  24784. } = __uniConfig.rightWindow;
  24785. const windowRef = ref(null);
  24786. function updateWindow() {
  24787. const instance2 = windowRef.value;
  24788. const el = resolveOwnerEl(instance2.$);
  24789. const width = el.getBoundingClientRect().width;
  24790. layoutState.rightWindowWidth = width;
  24791. }
  24792. onMounted(updateWindow);
  24793. watch(() => layoutState.showRightWindow || layoutState.apiShowRightWindow, () => nextTick(updateWindow));
  24794. layoutState.rightWindowStyle = style;
  24795. return {
  24796. component,
  24797. windowRef
  24798. };
  24799. }
  24800. function createTopWindowTsx(topWindow, layoutState, windowState) {
  24801. if (topWindow) {
  24802. const {
  24803. component: TopWindow,
  24804. windowRef
  24805. } = topWindow;
  24806. return withDirectives(createVNode("uni-top-window", null, [createVNode("div", {
  24807. "class": "uni-top-window",
  24808. "style": layoutState.topWindowStyle
  24809. }, [createVNode(TopWindow, mergeProps({
  24810. "ref": windowRef,
  24811. "navigation-bar-title-text": layoutState.navigationBarTitleText
  24812. }, windowState), null, 16, ["navigation-bar-title-text"])], 4), createVNode("div", {
  24813. "class": "uni-top-window--placeholder",
  24814. "style": {
  24815. height: layoutState.topWindowHeight + "px"
  24816. }
  24817. }, null, 4)], 512), [[vShow, layoutState.showTopWindow || layoutState.apiShowTopWindow]]);
  24818. }
  24819. }
  24820. function createLeftWindowTsx(leftWindow, layoutState, windowState) {
  24821. if (leftWindow) {
  24822. const {
  24823. component: LeftWindow,
  24824. windowRef
  24825. } = leftWindow;
  24826. return withDirectives(createVNode("uni-left-window", {
  24827. "data-show": layoutState.apiShowLeftWindow || void 0,
  24828. "style": layoutState.leftWindowStyle
  24829. }, [layoutState.apiShowLeftWindow ? createVNode("div", {
  24830. "class": "uni-mask",
  24831. "onClick": () => layoutState.apiShowLeftWindow = false
  24832. }, null, 8, ["onClick"]) : null, createVNode("div", {
  24833. "class": "uni-left-window"
  24834. }, [createVNode(LeftWindow, mergeProps({
  24835. "ref": windowRef
  24836. }, windowState), null, 16)])], 12, ["data-show"]), [[vShow, layoutState.showLeftWindow || layoutState.apiShowLeftWindow]]);
  24837. }
  24838. }
  24839. function createRightWindowTsx(rightWindow, layoutState, windowState) {
  24840. if (rightWindow) {
  24841. const {
  24842. component: RightWindow,
  24843. windowRef
  24844. } = rightWindow;
  24845. return withDirectives(createVNode("uni-right-window", {
  24846. "data-show": layoutState.apiShowRightWindow || void 0,
  24847. "style": layoutState.rightWindowStyle
  24848. }, [layoutState.apiShowRightWindow ? createVNode("div", {
  24849. "class": "uni-mask",
  24850. "onClick": () => layoutState.apiShowRightWindow = false
  24851. }, null, 8, ["onClick"]) : null, createVNode("div", {
  24852. "class": "uni-right-window"
  24853. }, [createVNode(RightWindow, mergeProps({
  24854. "ref": windowRef
  24855. }, windowState), null, 16)])], 12, ["data-show"]), [[vShow, layoutState.showRightWindow || layoutState.apiShowRightWindow]]);
  24856. }
  24857. }
  24858. const showTopWindow = /* @__PURE__ */ defineAsyncApi(
  24859. "showTopWindow",
  24860. (_, { resolve, reject }) => {
  24861. const state2 = getLayoutState();
  24862. if (!state2) {
  24863. reject();
  24864. return;
  24865. }
  24866. state2.apiShowTopWindow = true;
  24867. nextTick(resolve);
  24868. }
  24869. );
  24870. const hideTopWindow = /* @__PURE__ */ defineAsyncApi(
  24871. "hideTopWindow",
  24872. (_, { resolve, reject }) => {
  24873. const state2 = getLayoutState();
  24874. if (!state2) {
  24875. reject();
  24876. return;
  24877. }
  24878. state2.apiShowTopWindow = false;
  24879. nextTick(resolve);
  24880. }
  24881. );
  24882. const showLeftWindow = /* @__PURE__ */ defineAsyncApi(
  24883. "showLeftWindow",
  24884. (_, { resolve, reject }) => {
  24885. const state2 = getLayoutState();
  24886. if (!state2) {
  24887. reject();
  24888. return;
  24889. }
  24890. state2.apiShowLeftWindow = true;
  24891. nextTick(resolve);
  24892. }
  24893. );
  24894. const hideLeftWindow = /* @__PURE__ */ defineAsyncApi(
  24895. "hideLeftWindow",
  24896. (_, { resolve, reject }) => {
  24897. const state2 = getLayoutState();
  24898. if (!state2) {
  24899. reject();
  24900. return;
  24901. }
  24902. state2.apiShowLeftWindow = false;
  24903. nextTick(resolve);
  24904. }
  24905. );
  24906. const showRightWindow = /* @__PURE__ */ defineAsyncApi(
  24907. "showRightWindow",
  24908. (_, { resolve, reject }) => {
  24909. const state2 = getLayoutState();
  24910. if (!state2) {
  24911. reject();
  24912. return;
  24913. }
  24914. state2.apiShowRightWindow = true;
  24915. nextTick(resolve);
  24916. }
  24917. );
  24918. const hideRightWindow = /* @__PURE__ */ defineAsyncApi(
  24919. "hideRightWindow",
  24920. (_, { resolve, reject }) => {
  24921. const state2 = getLayoutState();
  24922. if (!state2) {
  24923. reject();
  24924. return;
  24925. }
  24926. state2.apiShowRightWindow = false;
  24927. nextTick(resolve);
  24928. }
  24929. );
  24930. const getTopWindowStyle = /* @__PURE__ */ defineSyncApi(
  24931. "getTopWindowStyle",
  24932. () => {
  24933. const state2 = getLayoutState();
  24934. return extend({}, state2 && state2.topWindowStyle);
  24935. }
  24936. );
  24937. const setTopWindowStyle = /* @__PURE__ */ defineSyncApi(
  24938. "setTopWindowStyle",
  24939. (style) => {
  24940. const state2 = getLayoutState();
  24941. if (state2) {
  24942. state2.topWindowStyle = style;
  24943. }
  24944. }
  24945. );
  24946. const getLeftWindowStyle = /* @__PURE__ */ defineSyncApi(
  24947. "getLeftWindowStyle",
  24948. () => {
  24949. const state2 = getLayoutState();
  24950. return extend({}, state2 && state2.leftWindowStyle);
  24951. }
  24952. );
  24953. const setLeftWindowStyle = /* @__PURE__ */ defineSyncApi(
  24954. "setLeftWindowStyle",
  24955. (style) => {
  24956. const state2 = getLayoutState();
  24957. if (state2) {
  24958. state2.leftWindowStyle = style;
  24959. }
  24960. }
  24961. );
  24962. const getRightWindowStyle = /* @__PURE__ */ defineSyncApi("getRightWindowStyle", () => {
  24963. const state2 = getLayoutState();
  24964. return extend({}, state2 && state2.rightWindowStyle);
  24965. });
  24966. const setRightWindowStyle = /* @__PURE__ */ defineSyncApi("setRightWindowStyle", (style) => {
  24967. const state2 = getLayoutState();
  24968. if (state2) {
  24969. state2.rightWindowStyle = style;
  24970. }
  24971. });
  24972. const getElementById = /* @__PURE__ */ defineSyncApi(
  24973. "getElementById",
  24974. (id2) => {
  24975. const uniPageBody = document.querySelector("uni-page-body");
  24976. return uniPageBody ? uniPageBody.querySelector(`#${id2}`) : null;
  24977. }
  24978. );
  24979. const saveImageToPhotosAlbum = /* @__PURE__ */ defineAsyncApi(
  24980. API_SAVE_IMAGE_TO_PHOTOS_ALBUM,
  24981. createUnsupportedAsyncApi(API_SAVE_IMAGE_TO_PHOTOS_ALBUM)
  24982. );
  24983. const API_GET_RECORDER_MANAGER = "getRecorderManager";
  24984. const getRecorderManager = /* @__PURE__ */ defineSyncApi(
  24985. API_GET_RECORDER_MANAGER,
  24986. createUnsupportedSyncApi(API_GET_RECORDER_MANAGER)
  24987. );
  24988. const saveVideoToPhotosAlbum = /* @__PURE__ */ defineAsyncApi(
  24989. API_SAVE_VIDEO_TO_PHOTOS_ALBUM,
  24990. createUnsupportedAsyncApi(API_SAVE_VIDEO_TO_PHOTOS_ALBUM)
  24991. );
  24992. const API_CREATE_CAMERA_CONTEXT = "createCameraContext";
  24993. const createCameraContext = /* @__PURE__ */ defineSyncApi(
  24994. API_CREATE_CAMERA_CONTEXT,
  24995. createUnsupportedSyncApi(API_CREATE_CAMERA_CONTEXT)
  24996. );
  24997. const API_CREATE_LIVE_PLAYER_CONTEXT = "createLivePlayerContext";
  24998. const createLivePlayerContext = /* @__PURE__ */ defineSyncApi(
  24999. API_CREATE_LIVE_PLAYER_CONTEXT,
  25000. createUnsupportedSyncApi(API_CREATE_LIVE_PLAYER_CONTEXT)
  25001. );
  25002. const API_SAVE_FILE = "saveFile";
  25003. const saveFile = /* @__PURE__ */ defineAsyncApi(
  25004. API_SAVE_FILE,
  25005. createUnsupportedAsyncApi(API_SAVE_FILE)
  25006. );
  25007. const API_GET_SAVED_FILE_LIST = "getSavedFileList";
  25008. const getSavedFileList = /* @__PURE__ */ defineAsyncApi(
  25009. API_GET_SAVED_FILE_LIST,
  25010. createUnsupportedAsyncApi(API_GET_SAVED_FILE_LIST)
  25011. );
  25012. const API_GET_SAVED_FILE_INFO = "getSavedFileInfo";
  25013. const getSavedFileInfo = /* @__PURE__ */ defineAsyncApi(
  25014. API_GET_SAVED_FILE_INFO,
  25015. createUnsupportedAsyncApi(API_GET_SAVED_FILE_INFO)
  25016. );
  25017. const API_REMOVE_SAVED_FILE = "removeSavedFile";
  25018. const removeSavedFile = /* @__PURE__ */ defineAsyncApi(
  25019. API_REMOVE_SAVED_FILE,
  25020. createUnsupportedAsyncApi(API_REMOVE_SAVED_FILE)
  25021. );
  25022. const API_ON_MEMORY_WARNING = "onMemoryWarning";
  25023. const onMemoryWarning = /* @__PURE__ */ defineOnApi(
  25024. API_ON_MEMORY_WARNING,
  25025. createUnsupportedOnApi(API_ON_MEMORY_WARNING)
  25026. );
  25027. const API_ON_GYROSCOPE_CHANGE = "onGyroscopeChange";
  25028. const onGyroscopeChange = /* @__PURE__ */ defineOnApi(
  25029. API_ON_GYROSCOPE_CHANGE,
  25030. createUnsupportedOnApi(API_ON_GYROSCOPE_CHANGE)
  25031. );
  25032. const API_START_GYROSCOPE = "startGyroscope";
  25033. const startGyroscope = /* @__PURE__ */ defineAsyncApi(
  25034. API_START_GYROSCOPE,
  25035. createUnsupportedAsyncApi(API_START_GYROSCOPE)
  25036. );
  25037. const API_STOP_GYROSCOPE = "stopGyroscope";
  25038. const stopGyroscope = /* @__PURE__ */ defineAsyncApi(
  25039. API_STOP_GYROSCOPE,
  25040. createUnsupportedAsyncApi(API_STOP_GYROSCOPE)
  25041. );
  25042. const API_SCAN_CODE = "scanCode";
  25043. const scanCode = /* @__PURE__ */ defineAsyncApi(
  25044. API_SCAN_CODE,
  25045. createUnsupportedAsyncApi(API_SCAN_CODE)
  25046. );
  25047. const API_SET_SCREEN_BRIGHTNESS = "setScreenBrightness";
  25048. const setScreenBrightness = /* @__PURE__ */ defineAsyncApi(
  25049. API_SET_SCREEN_BRIGHTNESS,
  25050. createUnsupportedAsyncApi(API_SET_SCREEN_BRIGHTNESS)
  25051. );
  25052. const API_GET_SCREEN_BRIGHTNESS = "getScreenBrightness";
  25053. const getScreenBrightness = /* @__PURE__ */ defineAsyncApi(
  25054. API_GET_SCREEN_BRIGHTNESS,
  25055. createUnsupportedAsyncApi(API_GET_SCREEN_BRIGHTNESS)
  25056. );
  25057. const API_SET_KEEP_SCREEN_ON = "setKeepScreenOn";
  25058. const setKeepScreenOn = /* @__PURE__ */ defineAsyncApi(
  25059. API_SET_KEEP_SCREEN_ON,
  25060. createUnsupportedAsyncApi(API_SET_KEEP_SCREEN_ON)
  25061. );
  25062. const API_ON_USER_CAPTURE_SCREEN = "onUserCaptureScreen";
  25063. const onUserCaptureScreen = /* @__PURE__ */ defineOnApi(
  25064. API_ON_USER_CAPTURE_SCREEN,
  25065. createUnsupportedOnApi(API_ON_USER_CAPTURE_SCREEN)
  25066. );
  25067. const API_ADD_PHONE_CONTACT = "addPhoneContact";
  25068. const addPhoneContact = /* @__PURE__ */ defineAsyncApi(
  25069. API_ADD_PHONE_CONTACT,
  25070. createUnsupportedAsyncApi(API_ADD_PHONE_CONTACT)
  25071. );
  25072. const API_LOGIN = "login";
  25073. const login = /* @__PURE__ */ defineAsyncApi(
  25074. API_LOGIN,
  25075. createUnsupportedAsyncApi(API_LOGIN)
  25076. );
  25077. const API_GET_PROVIDER = "getProvider";
  25078. const getProvider = /* @__PURE__ */ defineAsyncApi(
  25079. API_GET_PROVIDER,
  25080. createUnsupportedAsyncApi(API_GET_PROVIDER)
  25081. );
  25082. class CanvasContextImpl {
  25083. constructor(element) {
  25084. this._element = element;
  25085. }
  25086. getContext(type) {
  25087. return this._element.getContext(type);
  25088. }
  25089. toBlob(callback, type, quality) {
  25090. this._element.toBlob(callback, type, quality);
  25091. }
  25092. toDataURL(type, encoderOptions) {
  25093. return this._element.toDataURL(type, encoderOptions);
  25094. }
  25095. // @ts-expect-error TODO 类型不匹配?
  25096. createImage() {
  25097. return new Image();
  25098. }
  25099. createPath2D() {
  25100. return new Path2D();
  25101. }
  25102. requestAnimationFrame(callback) {
  25103. return window.requestAnimationFrame(callback);
  25104. }
  25105. cancelAnimationFrame(taskId) {
  25106. window.cancelAnimationFrame(taskId);
  25107. }
  25108. }
  25109. const createCanvasContextAsync = function(options) {
  25110. var _a, _b, _c, _d, _e, _f;
  25111. const currentPage = (_a = options.component) != null ? _a : getCurrentPages()[getCurrentPages().length - 1];
  25112. if (currentPage != null) {
  25113. const element = (_b = currentPage.$el) == null ? void 0 : _b.querySelector("#" + options.id);
  25114. if (element != null) {
  25115. const canvas = element;
  25116. (_c = options.success) == null ? void 0 : _c.call(options, new CanvasContextImpl(canvas));
  25117. } else {
  25118. const uniError = new UniError(
  25119. "uni-createCanvasContextAsync",
  25120. -1,
  25121. "canvas id invalid."
  25122. );
  25123. (_d = options.fail) == null ? void 0 : _d.call(options, uniError);
  25124. }
  25125. } else {
  25126. const uniError = new UniError(
  25127. "uni-createCanvasContextAsync",
  25128. -1,
  25129. "No found current page."
  25130. );
  25131. (_e = options.fail) == null ? void 0 : _e.call(options, uniError);
  25132. }
  25133. (_f = options.complete) == null ? void 0 : _f.call(options);
  25134. };
  25135. window.UniResizeObserver = window.ResizeObserver;
  25136. const api = /* @__PURE__ */ Object.defineProperty({
  25137. __proto__: null,
  25138. $emit,
  25139. $off,
  25140. $on,
  25141. $once,
  25142. addInterceptor,
  25143. addPhoneContact,
  25144. arrayBufferToBase64,
  25145. base64ToArrayBuffer,
  25146. canIUse,
  25147. canvasGetImageData,
  25148. canvasPutImageData,
  25149. canvasToTempFilePath,
  25150. chooseFile,
  25151. chooseImage,
  25152. chooseLocation,
  25153. chooseVideo,
  25154. clearStorage,
  25155. clearStorageSync,
  25156. closePreviewImage,
  25157. closeSocket,
  25158. connectSocket,
  25159. createAnimation: createAnimation$1,
  25160. createCameraContext,
  25161. createCanvasContext,
  25162. createCanvasContextAsync,
  25163. createInnerAudioContext,
  25164. createIntersectionObserver,
  25165. createLivePlayerContext,
  25166. createMapContext,
  25167. createMediaQueryObserver,
  25168. createSelectorQuery,
  25169. createVideoContext,
  25170. cssBackdropFilter,
  25171. cssConstant,
  25172. cssEnv,
  25173. cssVar,
  25174. downloadFile,
  25175. getAppBaseInfo,
  25176. getClipboardData,
  25177. getDeviceInfo,
  25178. getElementById,
  25179. getEnterOptionsSync,
  25180. getFileInfo,
  25181. getImageInfo,
  25182. getLaunchOptionsSync,
  25183. getLeftWindowStyle,
  25184. getLocale,
  25185. getLocation,
  25186. getNetworkType,
  25187. getProvider,
  25188. getPushClientId,
  25189. getRecorderManager,
  25190. getRightWindowStyle,
  25191. getSavedFileInfo,
  25192. getSavedFileList,
  25193. getScreenBrightness,
  25194. getSelectedTextRange: getSelectedTextRange$1,
  25195. getStorage,
  25196. getStorageInfo,
  25197. getStorageInfoSync,
  25198. getStorageSync,
  25199. getSystemInfo,
  25200. getSystemInfoSync,
  25201. getTabBarPageId,
  25202. getTopWindowStyle,
  25203. getVideoInfo,
  25204. getWindowInfo,
  25205. hideActionSheet,
  25206. hideKeyboard,
  25207. hideLeftWindow,
  25208. hideLoading,
  25209. hideModal,
  25210. hideNavigationBarLoading,
  25211. hideRightWindow,
  25212. hideTabBar,
  25213. hideTabBarRedDot,
  25214. hideToast,
  25215. hideTopWindow,
  25216. interceptors,
  25217. invokePushCallback,
  25218. loadFontFace,
  25219. login,
  25220. makePhoneCall,
  25221. navigateBack,
  25222. navigateTo,
  25223. offAccelerometerChange,
  25224. offAppHide,
  25225. offAppShow,
  25226. offCompassChange,
  25227. offError,
  25228. offLocationChange,
  25229. offLocationChangeError,
  25230. offNetworkStatusChange,
  25231. offPageNotFound,
  25232. offPushMessage,
  25233. offThemeChange,
  25234. offUnhandledRejection,
  25235. offWindowResize,
  25236. onAccelerometerChange,
  25237. onAppHide,
  25238. onAppShow,
  25239. onCompassChange,
  25240. onCreateVueApp,
  25241. onError,
  25242. onGyroscopeChange,
  25243. onLocaleChange,
  25244. onLocationChange,
  25245. onLocationChangeError,
  25246. onMemoryWarning,
  25247. onNetworkStatusChange,
  25248. onPageNotFound,
  25249. onPushMessage,
  25250. onSocketClose,
  25251. onSocketError,
  25252. onSocketMessage,
  25253. onSocketOpen,
  25254. onTabBarMidButtonTap,
  25255. onThemeChange,
  25256. onUnhandledRejection,
  25257. onUserCaptureScreen,
  25258. onWindowResize,
  25259. openDocument,
  25260. openLocation,
  25261. pageScrollTo,
  25262. preloadPage,
  25263. previewImage,
  25264. reLaunch,
  25265. redirectTo,
  25266. removeAllPages,
  25267. removeInterceptor,
  25268. removeLastPage,
  25269. removeNonTabBarPages,
  25270. removeSavedFile,
  25271. removeStorage,
  25272. removeStorageSync,
  25273. removeTabBarBadge,
  25274. request,
  25275. rpx2px: upx2px,
  25276. saveFile,
  25277. saveImageToPhotosAlbum,
  25278. saveVideoToPhotosAlbum,
  25279. scanCode,
  25280. sendSocketMessage,
  25281. setClipboardData,
  25282. setKeepScreenOn,
  25283. setLeftWindowStyle,
  25284. setLocale,
  25285. setNavigationBarColor,
  25286. setNavigationBarTitle,
  25287. setPageMeta,
  25288. setRightWindowStyle,
  25289. setScreenBrightness,
  25290. setStorage,
  25291. setStorageSync,
  25292. setTabBarBadge,
  25293. setTabBarItem,
  25294. setTabBarStyle,
  25295. setTopWindowStyle,
  25296. showActionSheet,
  25297. showLeftWindow,
  25298. showLoading,
  25299. showModal,
  25300. showNavigationBarLoading,
  25301. showRightWindow,
  25302. showTabBar,
  25303. showTabBarRedDot,
  25304. showToast,
  25305. showTopWindow,
  25306. startAccelerometer,
  25307. startCompass,
  25308. startGyroscope,
  25309. startLocationUpdate,
  25310. startPullDownRefresh,
  25311. stopAccelerometer,
  25312. stopCompass,
  25313. stopGyroscope,
  25314. stopLocationUpdate,
  25315. stopPullDownRefresh,
  25316. switchTab,
  25317. uploadFile,
  25318. upx2px,
  25319. vibrateLong,
  25320. vibrateShort
  25321. }, Symbol.toStringTag, { value: "Module" });
  25322. const CONTEXT_ID = "MAP_LOCATION";
  25323. const MapLocation = /* @__PURE__ */ defineSystemComponent({
  25324. name: "MapLocation",
  25325. setup() {
  25326. const state2 = reactive({
  25327. latitude: 0,
  25328. longitude: 0,
  25329. rotate: 0
  25330. });
  25331. {
  25332. let compassChangeHandler = function(res) {
  25333. state2.rotate = res.direction;
  25334. }, updateLocation = function() {
  25335. getLocation({
  25336. type: "gcj02",
  25337. success: (res) => {
  25338. state2.latitude = res.latitude;
  25339. state2.longitude = res.longitude;
  25340. },
  25341. complete: () => {
  25342. timer = setTimeout(updateLocation, 3e4);
  25343. }
  25344. });
  25345. }, removeLocation = function() {
  25346. if (timer) {
  25347. clearTimeout(timer);
  25348. }
  25349. offCompassChange(compassChangeHandler);
  25350. };
  25351. const onMapReady = inject("onMapReady");
  25352. let timer;
  25353. onCompassChange(compassChangeHandler);
  25354. onMapReady(updateLocation);
  25355. onUnmounted(removeLocation);
  25356. const addMapChidlContext = inject("addMapChidlContext");
  25357. const removeMapChidlContext = inject("removeMapChidlContext");
  25358. const context = {
  25359. id: CONTEXT_ID,
  25360. state: state2
  25361. };
  25362. addMapChidlContext(context);
  25363. onUnmounted(() => removeMapChidlContext(context));
  25364. }
  25365. return () => {
  25366. return state2.latitude ? createVNode(MapMarker, mergeProps({
  25367. "anchor": {
  25368. x: 0.5,
  25369. y: 0.5
  25370. },
  25371. "width": "44",
  25372. "height": "44",
  25373. "iconPath": ICON_PATH_ORIGIN
  25374. }, state2), null, 16, ["iconPath"]) : null;
  25375. };
  25376. }
  25377. });
  25378. const props$3 = {
  25379. // 边框虚线,腾讯地图支持,google 高德 地图不支持,默认值为[0, 0] 为实线,非 [0, 0] 为虚线,H5 端无法像微信小程序一样控制虚线的间隔像素大小
  25380. dashArray: {
  25381. type: Array,
  25382. default: () => [0, 0]
  25383. },
  25384. // 经纬度数组,[{latitude: 0, longitude: 0}]
  25385. points: {
  25386. type: Array,
  25387. required: true
  25388. },
  25389. // 描边的宽度
  25390. strokeWidth: {
  25391. type: Number,
  25392. default: 1
  25393. },
  25394. // 描边的颜色,十六进制
  25395. strokeColor: {
  25396. type: String,
  25397. default: "#000000"
  25398. },
  25399. // 填充颜色,十六进制
  25400. fillColor: {
  25401. type: String,
  25402. default: "#00000000"
  25403. },
  25404. // 设置多边形 Z 轴数值
  25405. zIndex: {
  25406. type: Number,
  25407. default: 0
  25408. }
  25409. };
  25410. const MapPolygon = /* @__PURE__ */ defineSystemComponent({
  25411. name: "MapPolygon",
  25412. props: props$3,
  25413. setup(props2) {
  25414. let polygonIns;
  25415. const onMapReady = inject("onMapReady");
  25416. onMapReady((map, maps2, trigger) => {
  25417. function drawPolygon() {
  25418. const {
  25419. points,
  25420. strokeWidth,
  25421. strokeColor,
  25422. dashArray,
  25423. fillColor,
  25424. zIndex
  25425. } = props2;
  25426. const path = points.map((item) => {
  25427. const {
  25428. latitude,
  25429. longitude
  25430. } = item;
  25431. if (getIsAMap()) {
  25432. return [longitude, latitude];
  25433. } else if (getIsBMap()) {
  25434. return new maps2.Point(longitude, latitude);
  25435. } else {
  25436. return new maps2.LatLng(latitude, longitude);
  25437. }
  25438. });
  25439. const {
  25440. r: fcR,
  25441. g: fcG,
  25442. b: fcB,
  25443. a: fcA
  25444. } = hexToRgba(fillColor);
  25445. const {
  25446. r: scR,
  25447. g: scG,
  25448. b: scB,
  25449. a: scA
  25450. } = hexToRgba(strokeColor);
  25451. const polygonOptions = {
  25452. //多边形是否可点击。
  25453. clickable: true,
  25454. //鼠标在多边形内的光标样式。
  25455. cursor: "crosshair",
  25456. //多边形是否可编辑。
  25457. editable: false,
  25458. // 地图实例,即要显示多边形的地图
  25459. // @ts-ignore
  25460. map,
  25461. // 区域填充色
  25462. fillColor: "",
  25463. //多边形的路径,以经纬度坐标数组构成。
  25464. path,
  25465. // 区域边框
  25466. strokeColor: "",
  25467. //多边形的边框样式。实线是solid,虚线是dash。
  25468. strokeDashStyle: dashArray.some((item) => item > 0) ? "dash" : "solid",
  25469. //多边形的边框线宽。
  25470. strokeWeight: strokeWidth,
  25471. //多边形是否可见。
  25472. visible: true,
  25473. //多边形的zIndex值。
  25474. zIndex
  25475. };
  25476. if (maps2.Color) {
  25477. polygonOptions.fillColor = new maps2.Color(fcR, fcG, fcB, fcA);
  25478. polygonOptions.strokeColor = new maps2.Color(scR, scG, scB, scA);
  25479. } else {
  25480. polygonOptions.fillColor = `rgb(${fcR}, ${fcG}, ${fcB})`;
  25481. polygonOptions.fillOpacity = fcA;
  25482. polygonOptions.strokeColor = `rgb(${scR}, ${scG}, ${scB})`;
  25483. polygonOptions.strokeOpacity = scA;
  25484. }
  25485. if (polygonIns) {
  25486. polygonIns.setOptions(polygonOptions);
  25487. return;
  25488. }
  25489. if (getIsBMap()) {
  25490. polygonIns = new maps2.Polygon(polygonOptions.path, polygonOptions);
  25491. map.addOverlay(polygonIns);
  25492. } else {
  25493. polygonIns = new maps2.Polygon(polygonOptions);
  25494. }
  25495. }
  25496. drawPolygon();
  25497. watch(props2, drawPolygon);
  25498. });
  25499. onUnmounted(() => {
  25500. polygonIns.setMap(null);
  25501. });
  25502. return () => null;
  25503. }
  25504. });
  25505. const props$2 = {
  25506. id: {
  25507. type: String,
  25508. default: ""
  25509. },
  25510. latitude: {
  25511. type: [String, Number],
  25512. default: 0
  25513. },
  25514. longitude: {
  25515. type: [String, Number],
  25516. default: 0
  25517. },
  25518. scale: {
  25519. type: [String, Number],
  25520. default: 16
  25521. },
  25522. markers: {
  25523. type: Array,
  25524. default() {
  25525. return [];
  25526. }
  25527. },
  25528. includePoints: {
  25529. type: Array,
  25530. default() {
  25531. return [];
  25532. }
  25533. },
  25534. polyline: {
  25535. type: Array,
  25536. default() {
  25537. return [];
  25538. }
  25539. },
  25540. circles: {
  25541. type: Array,
  25542. default() {
  25543. return [];
  25544. }
  25545. },
  25546. controls: {
  25547. type: Array,
  25548. default() {
  25549. return [];
  25550. }
  25551. },
  25552. showLocation: {
  25553. type: [Boolean, String],
  25554. default: false
  25555. },
  25556. libraries: {
  25557. type: Array,
  25558. default() {
  25559. return [];
  25560. }
  25561. },
  25562. polygons: {
  25563. type: Array,
  25564. default: () => []
  25565. }
  25566. };
  25567. function getPoints(points) {
  25568. const newPoints = [];
  25569. if (isArray(points)) {
  25570. points.forEach((point) => {
  25571. if (point && point.latitude && point.longitude) {
  25572. newPoints.push({
  25573. latitude: point.latitude,
  25574. longitude: point.longitude
  25575. });
  25576. }
  25577. });
  25578. }
  25579. return newPoints;
  25580. }
  25581. function getAMapPosition(maps2, latitude, longitude) {
  25582. return new maps2.LngLat(longitude, latitude);
  25583. }
  25584. function getBMapPosition(maps2, latitude, longitude) {
  25585. return new maps2.Point(longitude, latitude);
  25586. }
  25587. function getGoogleOrQQMapPosition(maps2, latitude, longitude) {
  25588. return new maps2.LatLng(latitude, longitude);
  25589. }
  25590. function getMapPosition(maps2, latitude, longitude) {
  25591. if (getIsBMap()) {
  25592. return getBMapPosition(maps2, latitude, longitude);
  25593. } else if (getIsAMap()) {
  25594. return getAMapPosition(maps2, latitude, longitude);
  25595. } else {
  25596. return getGoogleOrQQMapPosition(maps2, latitude, longitude);
  25597. }
  25598. }
  25599. function getLat(latLng) {
  25600. if ("getLat" in latLng) {
  25601. return latLng.getLat();
  25602. } else {
  25603. if (getIsBMap()) {
  25604. return latLng.lat;
  25605. }
  25606. return latLng.lat();
  25607. }
  25608. }
  25609. function getLng(latLng) {
  25610. if ("getLng" in latLng) {
  25611. return latLng.getLng();
  25612. } else {
  25613. if (getIsBMap()) {
  25614. return latLng.lng;
  25615. }
  25616. return latLng.lng();
  25617. }
  25618. }
  25619. function useMap(props2, rootRef, emit2) {
  25620. const trigger = useCustomEvent(rootRef, emit2);
  25621. const mapRef = ref(null);
  25622. let maps2;
  25623. let map;
  25624. const state2 = reactive({
  25625. latitude: Number(props2.latitude),
  25626. longitude: Number(props2.longitude),
  25627. includePoints: getPoints(props2.includePoints)
  25628. });
  25629. const onMapReadyCallbacks = [];
  25630. let isMapReady;
  25631. function onMapReady(callback) {
  25632. if (isMapReady) {
  25633. callback(map, maps2, trigger);
  25634. } else {
  25635. onMapReadyCallbacks.push(callback);
  25636. }
  25637. }
  25638. function emitMapReady() {
  25639. isMapReady = true;
  25640. onMapReadyCallbacks.forEach((callback) => callback(map, maps2, trigger));
  25641. onMapReadyCallbacks.length = 0;
  25642. }
  25643. let isBoundsReady;
  25644. const onBoundsReadyCallbacks = [];
  25645. function onBoundsReady(callback) {
  25646. if (isBoundsReady) {
  25647. callback();
  25648. } else {
  25649. onMapReadyCallbacks.push(callback);
  25650. }
  25651. }
  25652. const contexts = {};
  25653. function addMapChidlContext(context) {
  25654. contexts[context.id] = context;
  25655. }
  25656. function removeMapChidlContext(context) {
  25657. delete contexts[context.id];
  25658. }
  25659. watch([() => props2.latitude, () => props2.longitude], ([latitudeVlaue, longitudeVlaue]) => {
  25660. const latitude = Number(latitudeVlaue);
  25661. const longitude = Number(longitudeVlaue);
  25662. if (latitude !== state2.latitude || longitude !== state2.longitude) {
  25663. state2.latitude = latitude;
  25664. state2.longitude = longitude;
  25665. if (map) {
  25666. const centerPosition = getMapPosition(maps2, state2.latitude, state2.longitude);
  25667. map.setCenter(centerPosition);
  25668. }
  25669. }
  25670. });
  25671. watch(() => props2.includePoints, (points) => {
  25672. state2.includePoints = getPoints(points);
  25673. if (isBoundsReady) {
  25674. updateBounds();
  25675. }
  25676. }, {
  25677. deep: true
  25678. });
  25679. function emitBoundsReady() {
  25680. isBoundsReady = true;
  25681. onBoundsReadyCallbacks.forEach((callback) => callback());
  25682. onBoundsReadyCallbacks.length = 0;
  25683. }
  25684. function getMapInfo2() {
  25685. const center = map.getCenter();
  25686. return {
  25687. scale: map.getZoom(),
  25688. centerLocation: {
  25689. latitude: getLat(center),
  25690. longitude: getLng(center)
  25691. }
  25692. };
  25693. }
  25694. function updateCenter() {
  25695. const centerPosition = getMapPosition(maps2, state2.latitude, state2.longitude);
  25696. map.setCenter(centerPosition);
  25697. }
  25698. function updateBounds() {
  25699. if (getIsAMap()) {
  25700. const points = [];
  25701. state2.includePoints.forEach((point) => {
  25702. points.push([point.longitude, point.latitude]);
  25703. });
  25704. const bounds = new maps2.Bounds(...points);
  25705. map.setBounds(bounds);
  25706. } else if (getIsBMap())
  25707. ;
  25708. else {
  25709. const bounds = new maps2.LatLngBounds();
  25710. state2.includePoints.forEach(({
  25711. latitude,
  25712. longitude
  25713. }) => {
  25714. const latLng = new maps2.LatLng(latitude, longitude);
  25715. bounds.extend(latLng);
  25716. });
  25717. map.fitBounds(bounds);
  25718. }
  25719. }
  25720. function initMap() {
  25721. const mapEl = mapRef.value;
  25722. const center = getMapPosition(maps2, state2.latitude, state2.longitude);
  25723. const event = maps2.event || maps2.Event;
  25724. const map2 = new maps2.Map(mapEl, {
  25725. center,
  25726. zoom: Number(props2.scale),
  25727. // scrollwheel: false,
  25728. disableDoubleClickZoom: true,
  25729. mapTypeControl: false,
  25730. zoomControl: false,
  25731. scaleControl: false,
  25732. panControl: false,
  25733. fullscreenControl: false,
  25734. streetViewControl: false,
  25735. keyboardShortcuts: false,
  25736. minZoom: 5,
  25737. maxZoom: 18,
  25738. draggable: true
  25739. });
  25740. if (getIsBMap()) {
  25741. map2.centerAndZoom(center, Number(props2.scale));
  25742. map2.enableScrollWheelZoom();
  25743. map2._printLog && map2._printLog("uniapp");
  25744. }
  25745. watch(() => props2.scale, (scale) => {
  25746. map2.setZoom(Number(scale) || 16);
  25747. });
  25748. onBoundsReady(() => {
  25749. if (state2.includePoints.length) {
  25750. updateBounds();
  25751. updateCenter();
  25752. }
  25753. });
  25754. if (getIsBMap()) {
  25755. map2.addEventListener("click", () => {
  25756. trigger("tap", {}, {});
  25757. trigger("click", {}, {});
  25758. });
  25759. map2.addEventListener("dragstart", () => {
  25760. trigger("regionchange", {}, {
  25761. type: "begin",
  25762. causedBy: "gesture"
  25763. });
  25764. });
  25765. map2.addEventListener("dragend", () => {
  25766. trigger("regionchange", {}, extend({
  25767. type: "end",
  25768. causedBy: "drag"
  25769. }, getMapInfo2()));
  25770. });
  25771. } else {
  25772. const boundsChangedEvent = event.addListener(map2, "bounds_changed", () => {
  25773. boundsChangedEvent.remove();
  25774. emitBoundsReady();
  25775. });
  25776. event.addListener(map2, "click", () => {
  25777. trigger("tap", {}, {});
  25778. trigger("click", {}, {});
  25779. });
  25780. event.addListener(map2, "dragstart", () => {
  25781. trigger("regionchange", {}, {
  25782. type: "begin",
  25783. causedBy: "gesture"
  25784. });
  25785. });
  25786. event.addListener(map2, "dragend", () => {
  25787. trigger("regionchange", {}, extend({
  25788. type: "end",
  25789. causedBy: "drag"
  25790. }, getMapInfo2()));
  25791. });
  25792. const zoomChangedCallback = () => {
  25793. emit2("update:scale", map2.getZoom());
  25794. trigger("regionchange", {}, extend({
  25795. type: "end",
  25796. causedBy: "scale"
  25797. }, getMapInfo2()));
  25798. };
  25799. event.addListener(map2, "zoom_changed", zoomChangedCallback);
  25800. event.addListener(map2, "zoomend", zoomChangedCallback);
  25801. event.addListener(map2, "center_changed", () => {
  25802. const center2 = map2.getCenter();
  25803. const latitude = getLat(center2);
  25804. const longitude = getLng(center2);
  25805. emit2("update:latitude", latitude);
  25806. emit2("update:longitude", longitude);
  25807. });
  25808. }
  25809. return map2;
  25810. }
  25811. try {
  25812. const id2 = useContextInfo();
  25813. useSubscribe((type, data = {}) => {
  25814. switch (type) {
  25815. case "getCenterLocation":
  25816. onMapReady(() => {
  25817. const center = map.getCenter();
  25818. callOptions(data, {
  25819. latitude: getLat(center),
  25820. longitude: getLng(center),
  25821. errMsg: `${type}:ok`
  25822. });
  25823. });
  25824. break;
  25825. case "moveToLocation":
  25826. {
  25827. let latitude = Number(data.latitude);
  25828. let longitude = Number(data.longitude);
  25829. if (!latitude || !longitude) {
  25830. const context = contexts[CONTEXT_ID];
  25831. if (context) {
  25832. latitude = context.state.latitude;
  25833. longitude = context.state.longitude;
  25834. }
  25835. }
  25836. if (latitude && longitude) {
  25837. state2.latitude = latitude;
  25838. state2.longitude = longitude;
  25839. if (map) {
  25840. const centerPosition = getMapPosition(maps2, latitude, longitude);
  25841. map.setCenter(centerPosition);
  25842. }
  25843. onMapReady(() => {
  25844. callOptions(data, `${type}:ok`);
  25845. });
  25846. } else {
  25847. callOptions(data, `${type}:fail`);
  25848. }
  25849. }
  25850. break;
  25851. case "translateMarker":
  25852. onMapReady(() => {
  25853. const context = contexts[data.markerId];
  25854. if (context) {
  25855. try {
  25856. context.translate(data);
  25857. } catch (error) {
  25858. callOptions(data, `${type}:fail ${error.message}`);
  25859. }
  25860. callOptions(data, `${type}:ok`);
  25861. } else {
  25862. callOptions(data, `${type}:fail not found`);
  25863. }
  25864. });
  25865. break;
  25866. case "includePoints":
  25867. state2.includePoints = getPoints(data.includePoints);
  25868. if (isBoundsReady || getIsAMap()) {
  25869. updateBounds();
  25870. }
  25871. onBoundsReady(() => {
  25872. callOptions(data, `${type}:ok`);
  25873. });
  25874. break;
  25875. case "getRegion":
  25876. onBoundsReady(() => {
  25877. const latLngBounds = map.getBounds();
  25878. const southwest = latLngBounds.getSouthWest();
  25879. const northeast = latLngBounds.getNorthEast();
  25880. callOptions(data, {
  25881. southwest: {
  25882. latitude: getLat(southwest),
  25883. longitude: getLng(southwest)
  25884. },
  25885. northeast: {
  25886. latitude: getLat(northeast),
  25887. longitude: getLng(northeast)
  25888. },
  25889. errMsg: `${type}:ok`
  25890. });
  25891. });
  25892. break;
  25893. case "getScale":
  25894. onMapReady(() => {
  25895. callOptions(data, {
  25896. scale: map.getZoom(),
  25897. errMsg: `${type}:ok`
  25898. });
  25899. });
  25900. break;
  25901. }
  25902. }, id2, true);
  25903. } catch (error) {
  25904. }
  25905. onMounted(() => {
  25906. loadMaps(props2.libraries, (result) => {
  25907. maps2 = result;
  25908. map = initMap();
  25909. emitMapReady();
  25910. trigger("updated", {}, {});
  25911. });
  25912. });
  25913. provide("onMapReady", onMapReady);
  25914. provide("addMapChidlContext", addMapChidlContext);
  25915. provide("removeMapChidlContext", removeMapChidlContext);
  25916. return {
  25917. state: state2,
  25918. mapRef,
  25919. trigger
  25920. };
  25921. }
  25922. class UniMapElement extends UniElement {
  25923. }
  25924. const Map$1 = /* @__PURE__ */ defineBuiltInComponent({
  25925. name: "Map",
  25926. props: props$2,
  25927. emits: ["markertap", "labeltap", "callouttap", "controltap", "regionchange", "tap", "click", "updated", "update:scale", "update:latitude", "update:longitude"],
  25928. rootElement: {
  25929. name: "uni-map",
  25930. class: UniMapElement
  25931. },
  25932. setup(props2, {
  25933. emit: emit2,
  25934. slots
  25935. }) {
  25936. const rootRef = ref(null);
  25937. const {
  25938. mapRef,
  25939. trigger
  25940. } = useMap(props2, rootRef, emit2);
  25941. onMounted(() => {
  25942. const rootElement = rootRef.value;
  25943. rootElement.attachVmProps(props2);
  25944. });
  25945. return () => {
  25946. return createVNode("uni-map", {
  25947. "ref": rootRef,
  25948. "id": props2.id
  25949. }, [createVNode("div", {
  25950. "ref": mapRef,
  25951. "style": "width: 100%; height: 100%; position: relative; overflow: hidden"
  25952. }, null, 512), props2.markers.map((item) => createVNode(MapMarker, mergeProps({
  25953. "key": item.id
  25954. }, 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, {
  25955. "trigger": trigger
  25956. }), null, 16, ["trigger"])), props2.showLocation && createVNode(MapLocation, null, null), props2.polygons.map((item) => createVNode(MapPolygon, item, null, 16)), createVNode("div", {
  25957. "style": "position: absolute;top: 0;width: 100%;height: 100%;overflow: hidden;pointer-events: none;"
  25958. }, [slots.default && slots.default()])], 8, ["id"]);
  25959. };
  25960. }
  25961. });
  25962. const props$1 = {
  25963. scrollTop: {
  25964. type: [String, Number],
  25965. default: 0
  25966. }
  25967. };
  25968. class UniCoverViewElement extends UniElement {
  25969. }
  25970. const index$9 = /* @__PURE__ */ defineBuiltInComponent({
  25971. name: "CoverView",
  25972. compatConfig: {
  25973. MODE: 3
  25974. },
  25975. props: props$1,
  25976. rootElement: {
  25977. name: "uni-cover-view",
  25978. class: UniCoverViewElement
  25979. },
  25980. setup(props2, {
  25981. slots
  25982. }) {
  25983. const root = ref(null);
  25984. const content = ref(null);
  25985. watch(() => props2.scrollTop, (val) => {
  25986. setScrollTop(val);
  25987. });
  25988. function setScrollTop(val) {
  25989. let _content = content.value;
  25990. if (getComputedStyle(_content).overflowY === "scroll") {
  25991. _content.scrollTop = _upx2pxNum(val);
  25992. }
  25993. }
  25994. function _upx2pxNum(val) {
  25995. let _val = String(val);
  25996. if (/\d+[ur]px$/i.test(_val)) {
  25997. _val.replace(/\d+[ur]px$/i, (text2) => {
  25998. return String(uni.upx2px(parseFloat(text2)));
  25999. });
  26000. }
  26001. return parseFloat(_val) || 0;
  26002. }
  26003. onMounted(() => {
  26004. setScrollTop(props2.scrollTop);
  26005. });
  26006. onMounted(() => {
  26007. const rootElement = root.value;
  26008. rootElement.attachVmProps(props2);
  26009. });
  26010. return () => {
  26011. return createVNode("uni-cover-view", {
  26012. "scroll-top": props2.scrollTop,
  26013. "ref": root
  26014. }, [createVNode("div", {
  26015. "ref": content,
  26016. "class": "uni-cover-view"
  26017. }, [slots.default && slots.default()], 512)], 8, ["scroll-top"]);
  26018. };
  26019. }
  26020. });
  26021. class UniCoverImageElement extends UniElement {
  26022. }
  26023. const index$8 = /* @__PURE__ */ defineBuiltInComponent({
  26024. name: "CoverImage",
  26025. compatConfig: {
  26026. MODE: 3
  26027. },
  26028. props: {
  26029. src: {
  26030. type: String,
  26031. default: ""
  26032. }
  26033. },
  26034. rootElement: {
  26035. name: "uni-cover-image",
  26036. class: UniCoverImageElement
  26037. },
  26038. emits: ["load", "error"],
  26039. setup(props2, {
  26040. emit: emit2
  26041. }) {
  26042. const root = ref(null);
  26043. const trigger = useCustomEvent(root, emit2);
  26044. function load($event) {
  26045. trigger("load", $event);
  26046. }
  26047. function error($event) {
  26048. trigger("error", $event);
  26049. }
  26050. onMounted(() => {
  26051. const rootElement = root.value;
  26052. rootElement.attachVmProps(props2);
  26053. });
  26054. return () => {
  26055. const {
  26056. src
  26057. } = props2;
  26058. return createVNode("uni-cover-image", {
  26059. "ref": root,
  26060. "src": src
  26061. }, [createVNode("div", {
  26062. "class": "uni-cover-image"
  26063. }, [src ? createVNode("img", {
  26064. "src": getRealPath(src),
  26065. "onLoad": load,
  26066. "onError": error
  26067. }, null, 40, ["src", "onLoad", "onError"]) : null])], 8, ["src"]);
  26068. };
  26069. }
  26070. });
  26071. function _isSlot(s) {
  26072. return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
  26073. }
  26074. function getDefaultStartValue(props2) {
  26075. if (props2.mode === mode.TIME) {
  26076. return "00:00";
  26077. }
  26078. if (props2.mode === mode.DATE) {
  26079. const year = (/* @__PURE__ */ new Date()).getFullYear() - 150;
  26080. switch (props2.fields) {
  26081. case fields.YEAR:
  26082. return year.toString();
  26083. case fields.MONTH:
  26084. return year + "-01";
  26085. default:
  26086. return year + "-01-01";
  26087. }
  26088. }
  26089. return "";
  26090. }
  26091. function getDefaultEndValue(props2) {
  26092. if (props2.mode === mode.TIME) {
  26093. return "23:59";
  26094. }
  26095. if (props2.mode === mode.DATE) {
  26096. const year = (/* @__PURE__ */ new Date()).getFullYear() + 150;
  26097. switch (props2.fields) {
  26098. case fields.YEAR:
  26099. return year.toString();
  26100. case fields.MONTH:
  26101. return year + "-12";
  26102. default:
  26103. return year + "-12-31";
  26104. }
  26105. }
  26106. return "";
  26107. }
  26108. function getDateValueArray(props2, state2, valueStr, defaultValue) {
  26109. const splitStr = props2.mode === mode.DATE ? "-" : ":";
  26110. const array = props2.mode === mode.DATE ? state2.dateArray : state2.timeArray;
  26111. let max;
  26112. if (props2.mode === mode.TIME) {
  26113. max = 2;
  26114. } else {
  26115. switch (props2.fields) {
  26116. case fields.YEAR:
  26117. max = 1;
  26118. break;
  26119. case fields.MONTH:
  26120. max = 2;
  26121. break;
  26122. default:
  26123. max = 3;
  26124. break;
  26125. }
  26126. }
  26127. const inputArray = String(valueStr).split(splitStr);
  26128. let value = [];
  26129. for (let i = 0; i < max; i++) {
  26130. const val = inputArray[i];
  26131. value.push(array[i].indexOf(val));
  26132. }
  26133. if (value.indexOf(-1) >= 0) {
  26134. value = defaultValue ? getDateValueArray(props2, state2, defaultValue) : value.map(() => 0);
  26135. }
  26136. return value;
  26137. }
  26138. const mode = {
  26139. SELECTOR: "selector",
  26140. MULTISELECTOR: "multiSelector",
  26141. TIME: "time",
  26142. DATE: "date"
  26143. // 暂不支持城市选择
  26144. // REGION: 'region'
  26145. };
  26146. const fields = {
  26147. YEAR: "year",
  26148. MONTH: "month",
  26149. DAY: "day"
  26150. };
  26151. const selectorType = {
  26152. PICKER: "picker",
  26153. SELECT: "select"
  26154. };
  26155. const props = {
  26156. name: {
  26157. type: String,
  26158. default: ""
  26159. },
  26160. range: {
  26161. type: Array,
  26162. default() {
  26163. return [];
  26164. }
  26165. },
  26166. rangeKey: {
  26167. type: String,
  26168. default: ""
  26169. },
  26170. value: {
  26171. type: [Number, String, Array],
  26172. default: 0
  26173. },
  26174. mode: {
  26175. type: String,
  26176. default: mode.SELECTOR,
  26177. validator(val) {
  26178. return Object.values(mode).includes(val);
  26179. }
  26180. },
  26181. fields: {
  26182. type: String,
  26183. default: ""
  26184. },
  26185. start: {
  26186. type: String,
  26187. default: (props2) => {
  26188. return getDefaultStartValue(props2);
  26189. }
  26190. },
  26191. end: {
  26192. type: String,
  26193. default: (props2) => {
  26194. return getDefaultEndValue(props2);
  26195. }
  26196. },
  26197. disabled: {
  26198. type: [Boolean, String],
  26199. default: false
  26200. },
  26201. selectorType: {
  26202. type: String,
  26203. default: ""
  26204. }
  26205. };
  26206. class UniPickerElement extends UniElement {
  26207. }
  26208. const index$7 = /* @__PURE__ */ defineBuiltInComponent({
  26209. name: "Picker",
  26210. compatConfig: {
  26211. MODE: 3
  26212. },
  26213. props,
  26214. emits: ["change", "cancel", "columnchange"],
  26215. rootElement: {
  26216. name: "uni-picker",
  26217. class: UniPickerElement
  26218. },
  26219. setup(props2, {
  26220. emit: emit2,
  26221. slots
  26222. }) {
  26223. initI18nPickerMsgsOnce();
  26224. const {
  26225. t: t2
  26226. } = useI18n();
  26227. const rootRef = ref(null);
  26228. const pickerRef = ref(null);
  26229. const selectRef = ref(null);
  26230. const inputRef = ref(null);
  26231. const pickerRender = ref(false);
  26232. const {
  26233. state: state2,
  26234. rangeArray
  26235. } = usePickerState(props2);
  26236. const trigger = useCustomEvent(rootRef, emit2);
  26237. const {
  26238. system,
  26239. selectorTypeComputed,
  26240. _show,
  26241. _l10nColumn,
  26242. _l10nItem,
  26243. _input,
  26244. _fixInputPosition,
  26245. _pickerViewChange,
  26246. _cancel,
  26247. _change,
  26248. _resetFormData,
  26249. _getFormData,
  26250. _createTime,
  26251. _createDate,
  26252. _setValueSync
  26253. } = usePickerMethods(props2, state2, trigger, rootRef, pickerRef, selectRef, inputRef);
  26254. usePickerWatch(state2, _cancel, _change);
  26255. usePickerForm(_resetFormData, _getFormData);
  26256. _createTime();
  26257. _createDate();
  26258. _setValueSync();
  26259. const popup = usePopupStyle(state2);
  26260. watchEffect(() => {
  26261. state2.isDesktop = popup.isDesktop.value;
  26262. state2.popupStyle = popup.popupStyle.value;
  26263. });
  26264. onBeforeUnmount(() => {
  26265. pickerRef.value && pickerRef.value.remove();
  26266. });
  26267. onMounted(() => {
  26268. pickerRender.value = true;
  26269. });
  26270. onMounted(() => {
  26271. const rootElement = rootRef.value;
  26272. rootElement.attachVmProps(props2);
  26273. });
  26274. return () => {
  26275. let _slot2;
  26276. const {
  26277. visible,
  26278. contentVisible,
  26279. valueArray,
  26280. popupStyle,
  26281. valueSync
  26282. } = state2;
  26283. const {
  26284. rangeKey,
  26285. mode: mode2,
  26286. start,
  26287. end
  26288. } = props2;
  26289. const booleanAttrs = useBooleanAttr(props2, "disabled");
  26290. return createVNode("uni-picker", mergeProps({
  26291. "ref": rootRef
  26292. }, booleanAttrs, {
  26293. "onClick": withWebEvent(_show)
  26294. }), [pickerRender.value ? createVNode("div", {
  26295. "ref": pickerRef,
  26296. "class": ["uni-picker-container", `uni-${mode2}-${selectorTypeComputed.value}`],
  26297. "onWheel": onEventPrevent,
  26298. "onTouchmove": onEventPrevent
  26299. }, [createVNode(Transition, {
  26300. "name": "uni-fade"
  26301. }, {
  26302. default: () => [withDirectives(createVNode("div", {
  26303. "class": "uni-mask uni-picker-mask",
  26304. "onClick": withWebEvent(_cancel),
  26305. "onMousemove": _fixInputPosition
  26306. }, null, 40, ["onClick", "onMousemove"]), [[vShow, visible]])]
  26307. }), !system.value ? createVNode("div", {
  26308. "class": [{
  26309. "uni-picker-toggle": visible
  26310. }, "uni-picker-custom"],
  26311. "style": popupStyle.content
  26312. }, [createVNode("div", {
  26313. "class": "uni-picker-header",
  26314. "onClick": onEventStop
  26315. }, [createVNode("div", {
  26316. "class": "uni-picker-action uni-picker-action-cancel",
  26317. "onClick": withWebEvent(_cancel)
  26318. }, [t2("uni.picker.cancel")], 8, ["onClick"]), createVNode("div", {
  26319. "class": "uni-picker-action uni-picker-action-confirm",
  26320. "onClick": _change
  26321. }, [t2("uni.picker.done")], 8, ["onClick"])], 8, ["onClick"]), contentVisible ? createVNode(PickerView, {
  26322. "value": _l10nColumn(valueArray),
  26323. "class": "uni-picker-content",
  26324. "onChange": _pickerViewChange
  26325. }, _isSlot(_slot2 = renderList(_l10nColumn(rangeArray.value), (rangeItem, index0) => {
  26326. let _slot;
  26327. return createVNode(PickerViewColumn, {
  26328. "key": index0
  26329. }, _isSlot(_slot = renderList(rangeItem, (item, index2) => createVNode("div", {
  26330. "key": index2,
  26331. "class": "uni-picker-item"
  26332. }, [typeof item === "object" ? item[rangeKey] || "" : _l10nItem(item, index0)]))) ? _slot : {
  26333. default: () => [_slot],
  26334. _: 1
  26335. });
  26336. })) ? _slot2 : {
  26337. default: () => [_slot2],
  26338. _: 1
  26339. }, 8, ["value", "onChange"]) : null, createVNode("div", {
  26340. "ref": selectRef,
  26341. "class": "uni-picker-select",
  26342. "onWheel": onEventStop,
  26343. "onTouchmove": onEventStop
  26344. }, [renderList(rangeArray.value[0], (item, index2) => createVNode("div", {
  26345. "key": index2,
  26346. "class": ["uni-picker-item", {
  26347. selected: valueArray[0] === index2
  26348. }],
  26349. "onClick": () => {
  26350. valueArray[0] = index2;
  26351. _change();
  26352. }
  26353. }, [typeof item === "object" ? item[rangeKey] || "" : item], 10, ["onClick"]))], 40, ["onWheel", "onTouchmove"]), createVNode("div", {
  26354. "style": popupStyle.triangle
  26355. }, null, 4)], 6) : null], 40, ["onWheel", "onTouchmove"]) : null, createVNode("div", null, [slots.default && slots.default()]), system.value ? createVNode("div", {
  26356. "class": "uni-picker-system",
  26357. "onMousemove": withWebEvent(_fixInputPosition)
  26358. }, [createVNode("input", {
  26359. "class": ["uni-picker-system_input", system.value],
  26360. "ref": inputRef,
  26361. "value": valueSync,
  26362. "type": mode2,
  26363. "tabindex": "-1",
  26364. "min": start,
  26365. "max": end,
  26366. "onChange": ($event) => {
  26367. _input($event);
  26368. onEventStop($event);
  26369. }
  26370. }, null, 42, ["value", "type", "min", "max", "onChange"])], 40, ["onMousemove"]) : null], 16, ["onClick"]);
  26371. };
  26372. }
  26373. });
  26374. function usePickerState(props2) {
  26375. const state2 = reactive({
  26376. valueSync: void 0,
  26377. visible: false,
  26378. contentVisible: false,
  26379. popover: null,
  26380. valueChangeSource: "",
  26381. timeArray: [],
  26382. dateArray: [],
  26383. valueArray: [],
  26384. oldValueArray: [],
  26385. isDesktop: false,
  26386. popupStyle: {
  26387. content: {},
  26388. triangle: {}
  26389. }
  26390. });
  26391. const rangeArray = computed(() => {
  26392. let val = props2.range;
  26393. switch (props2.mode) {
  26394. case mode.SELECTOR:
  26395. return [val];
  26396. case mode.MULTISELECTOR:
  26397. return val;
  26398. case mode.TIME:
  26399. return state2.timeArray;
  26400. case mode.DATE: {
  26401. const dateArray = state2.dateArray;
  26402. switch (props2.fields) {
  26403. case fields.YEAR:
  26404. return [dateArray[0]];
  26405. case fields.MONTH:
  26406. return [dateArray[0], dateArray[1]];
  26407. default:
  26408. return [dateArray[0], dateArray[1], dateArray[2]];
  26409. }
  26410. }
  26411. }
  26412. return [];
  26413. });
  26414. return {
  26415. state: state2,
  26416. rangeArray
  26417. };
  26418. }
  26419. const getiPadFlag = () => String(navigator.vendor).indexOf("Apple") === 0 && navigator.maxTouchPoints > 0;
  26420. function useIsiPad() {
  26421. const isiPad = ref(false);
  26422. {
  26423. isiPad.value = getiPadFlag();
  26424. }
  26425. return isiPad;
  26426. }
  26427. const getSystem = () => {
  26428. if (/win|mac/i.test(navigator.platform)) {
  26429. if (navigator.vendor === "Google Inc.") {
  26430. return "chrome";
  26431. } else if (/Firefox/.test(navigator.userAgent)) {
  26432. return "firefox";
  26433. }
  26434. }
  26435. return "";
  26436. };
  26437. function useSystem() {
  26438. const _system = ref("");
  26439. {
  26440. _system.value = getSystem();
  26441. }
  26442. return _system;
  26443. }
  26444. let __contentVisibleDelay;
  26445. function usePickerMethods(props2, state2, trigger, rootRef, pickerRef, selectRef, inputRef) {
  26446. const isiPad = useIsiPad();
  26447. const _system = useSystem();
  26448. const selectorTypeComputed = computed(() => {
  26449. const type = props2.selectorType;
  26450. if (Object.values(selectorType).includes(type)) {
  26451. return type;
  26452. }
  26453. return isiPad.value ? selectorType.PICKER : selectorType.SELECT;
  26454. });
  26455. const system = computed(() => {
  26456. if (props2.mode === mode.DATE && !Object.values(fields).includes(props2.fields) && state2.isDesktop) {
  26457. return _system.value;
  26458. }
  26459. return "";
  26460. });
  26461. const startArray = computed(() => {
  26462. return getDateValueArray(props2, state2, props2.start, getDefaultStartValue(props2));
  26463. });
  26464. const endArray = computed(() => {
  26465. return getDateValueArray(props2, state2, props2.end, getDefaultEndValue(props2));
  26466. });
  26467. function _show(event) {
  26468. if (props2.disabled) {
  26469. return;
  26470. }
  26471. state2.valueChangeSource = "";
  26472. let $picker = pickerRef.value;
  26473. let _currentTarget = event.currentTarget;
  26474. $picker.remove();
  26475. (document.querySelector("uni-app") || document.body).appendChild($picker);
  26476. $picker.style.display = "block";
  26477. const rect = _currentTarget.getBoundingClientRect();
  26478. state2.popover = {
  26479. top: rect.top,
  26480. left: rect.left,
  26481. width: rect.width,
  26482. height: rect.height
  26483. };
  26484. setTimeout(() => {
  26485. state2.visible = true;
  26486. }, 20);
  26487. }
  26488. function _getFormData() {
  26489. return {
  26490. value: state2.valueSync,
  26491. key: props2.name
  26492. };
  26493. }
  26494. function _resetFormData() {
  26495. switch (props2.mode) {
  26496. case mode.SELECTOR:
  26497. state2.valueSync = 0;
  26498. break;
  26499. case mode.MULTISELECTOR:
  26500. state2.valueSync = props2.value.map((val) => 0);
  26501. break;
  26502. case mode.DATE:
  26503. case mode.TIME:
  26504. state2.valueSync = "";
  26505. break;
  26506. }
  26507. }
  26508. function _createTime() {
  26509. let hours = [];
  26510. let minutes = [];
  26511. for (let i = 0; i < 24; i++) {
  26512. hours.push((i < 10 ? "0" : "") + i);
  26513. }
  26514. for (let i = 0; i < 60; i++) {
  26515. minutes.push((i < 10 ? "0" : "") + i);
  26516. }
  26517. state2.timeArray.push(hours, minutes);
  26518. }
  26519. function getYearStartEnd() {
  26520. let year = (/* @__PURE__ */ new Date()).getFullYear();
  26521. let start = year - 150;
  26522. let end = year + 150;
  26523. if (props2.start) {
  26524. const _year = new Date(props2.start).getFullYear();
  26525. if (!isNaN(_year) && _year < start) {
  26526. start = _year;
  26527. }
  26528. }
  26529. if (props2.end) {
  26530. const _year = new Date(props2.end).getFullYear();
  26531. if (!isNaN(_year) && _year > end) {
  26532. end = _year;
  26533. }
  26534. }
  26535. return {
  26536. start,
  26537. end
  26538. };
  26539. }
  26540. function _createDate() {
  26541. let years = [];
  26542. const year = getYearStartEnd();
  26543. for (let i = year.start, end = year.end; i <= end; i++) {
  26544. years.push(String(i));
  26545. }
  26546. let months = [];
  26547. for (let i = 1; i <= 12; i++) {
  26548. months.push((i < 10 ? "0" : "") + i);
  26549. }
  26550. let days = [];
  26551. for (let i = 1; i <= 31; i++) {
  26552. days.push((i < 10 ? "0" : "") + i);
  26553. }
  26554. state2.dateArray.push(years, months, days);
  26555. }
  26556. function _getTimeValue(val) {
  26557. return val[0] * 60 + val[1];
  26558. }
  26559. function _getDateValue(val) {
  26560. const DAY = 31;
  26561. return val[0] * DAY * 12 + (val[1] || 0) * DAY + (val[2] || 0);
  26562. }
  26563. function _cloneArray(val1, val2) {
  26564. for (let i = 0; i < val1.length && i < val2.length; i++) {
  26565. val1[i] = val2[i];
  26566. }
  26567. }
  26568. function _setValueSync() {
  26569. let val = props2.value;
  26570. switch (props2.mode) {
  26571. case mode.MULTISELECTOR:
  26572. {
  26573. if (!isArray(val)) {
  26574. val = state2.valueArray;
  26575. }
  26576. if (!isArray(state2.valueSync)) {
  26577. state2.valueSync = [];
  26578. }
  26579. const length = state2.valueSync.length = Math.max(val.length, props2.range.length);
  26580. for (let index2 = 0; index2 < length; index2++) {
  26581. const val0 = Number(val[index2]);
  26582. const val1 = Number(state2.valueSync[index2]);
  26583. const val2 = isNaN(val0) ? isNaN(val1) ? 0 : val1 : val0;
  26584. const maxVal = props2.range[index2] ? props2.range[index2].length - 1 : 0;
  26585. state2.valueSync.splice(index2, 1, val2 < 0 || val2 > maxVal ? 0 : val2);
  26586. }
  26587. }
  26588. break;
  26589. case mode.TIME:
  26590. case mode.DATE:
  26591. state2.valueSync = String(val);
  26592. break;
  26593. default: {
  26594. const valueSync = Number(val);
  26595. state2.valueSync = valueSync < 0 ? 0 : valueSync;
  26596. break;
  26597. }
  26598. }
  26599. }
  26600. function _setValueArray() {
  26601. let val = state2.valueSync;
  26602. let valueArray;
  26603. switch (props2.mode) {
  26604. case mode.MULTISELECTOR:
  26605. valueArray = [...val];
  26606. break;
  26607. case mode.TIME:
  26608. valueArray = getDateValueArray(props2, state2, val, formatDateTime({
  26609. mode: mode.TIME
  26610. }));
  26611. break;
  26612. case mode.DATE:
  26613. valueArray = getDateValueArray(props2, state2, val, formatDateTime({
  26614. mode: mode.DATE
  26615. }));
  26616. break;
  26617. default:
  26618. valueArray = [val];
  26619. break;
  26620. }
  26621. state2.oldValueArray = [...valueArray];
  26622. state2.valueArray = [...valueArray];
  26623. }
  26624. function _getValue() {
  26625. let val = state2.valueArray;
  26626. switch (props2.mode) {
  26627. case mode.SELECTOR:
  26628. return val[0];
  26629. case mode.MULTISELECTOR:
  26630. return val.map((val2) => val2);
  26631. case mode.TIME:
  26632. return state2.valueArray.map((val2, i) => state2.timeArray[i][val2]).join(":");
  26633. case mode.DATE:
  26634. return state2.valueArray.map((val2, i) => state2.dateArray[i][val2]).join("-");
  26635. }
  26636. }
  26637. function _change() {
  26638. _close();
  26639. state2.valueChangeSource = "click";
  26640. const value = _getValue();
  26641. state2.valueSync = isArray(value) ? value.map((val) => val) : value;
  26642. trigger("change", {}, {
  26643. value
  26644. });
  26645. }
  26646. function _cancel($event) {
  26647. if (system.value === "firefox" && $event) {
  26648. const {
  26649. top,
  26650. left,
  26651. width,
  26652. height
  26653. } = state2.popover;
  26654. const {
  26655. pageX,
  26656. pageY
  26657. } = $event;
  26658. if (pageX > left && pageX < left + width && pageY > top && pageY < top + height) {
  26659. return;
  26660. }
  26661. }
  26662. _close();
  26663. trigger("cancel", {}, {});
  26664. }
  26665. function _close() {
  26666. state2.visible = false;
  26667. setTimeout(() => {
  26668. let $picker = pickerRef.value;
  26669. $picker.remove();
  26670. rootRef.value.prepend($picker);
  26671. $picker.style.display = "none";
  26672. }, 260);
  26673. }
  26674. function _select() {
  26675. if (props2.mode === mode.SELECTOR && selectorTypeComputed.value === selectorType.SELECT) {
  26676. selectRef.value.scrollTop = state2.valueArray[0] * 34;
  26677. }
  26678. }
  26679. function _input($event) {
  26680. const EventTarget = $event.target;
  26681. state2.valueSync = EventTarget.value;
  26682. nextTick(() => {
  26683. _change();
  26684. });
  26685. }
  26686. function _fixInputPosition($event) {
  26687. if (system.value === "chrome") {
  26688. const rect = rootRef.value.getBoundingClientRect();
  26689. const fontSize = 32;
  26690. inputRef.value.style.left = `${$event.clientX - rect.left - fontSize * 1.5}px`;
  26691. inputRef.value.style.top = `${$event.clientY - rect.top - fontSize * 0.5}px`;
  26692. }
  26693. }
  26694. function _pickerViewChange(event) {
  26695. state2.valueArray = _l10nColumn(event.detail.value, true);
  26696. }
  26697. function _l10nColumn(array, normalize) {
  26698. const {
  26699. getLocale: getLocale2
  26700. } = useI18n();
  26701. if (props2.mode === mode.DATE) {
  26702. const locale = getLocale2();
  26703. if (!locale.startsWith("zh")) {
  26704. switch (props2.fields) {
  26705. case fields.YEAR:
  26706. return array;
  26707. case fields.MONTH:
  26708. return [array[1], array[0]];
  26709. default:
  26710. switch (locale) {
  26711. case "es":
  26712. case "fr":
  26713. return [array[2], array[1], array[0]];
  26714. default:
  26715. return normalize ? [array[2], array[0], array[1]] : [array[1], array[2], array[0]];
  26716. }
  26717. }
  26718. }
  26719. }
  26720. return array;
  26721. }
  26722. function _l10nItem(item, index2) {
  26723. const {
  26724. getLocale: getLocale2
  26725. } = useI18n();
  26726. if (props2.mode === mode.DATE) {
  26727. const locale = getLocale2();
  26728. if (locale.startsWith("zh")) {
  26729. const array = ["年", "月", "日"];
  26730. return item + array[index2];
  26731. } else if (props2.fields !== fields.YEAR && index2 === (props2.fields !== fields.MONTH && (locale === "es" || locale === "fr") ? 1 : 0)) {
  26732. let array;
  26733. switch (locale) {
  26734. case "es":
  26735. array = ["enero", "febrero", "marzo", "abril", "mayo", "junio", "​​julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"];
  26736. break;
  26737. case "fr":
  26738. array = ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"];
  26739. break;
  26740. default:
  26741. array = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
  26742. break;
  26743. }
  26744. return array[Number(item) - 1];
  26745. }
  26746. }
  26747. return item;
  26748. }
  26749. watch(() => state2.visible, (val) => {
  26750. if (val) {
  26751. clearTimeout(__contentVisibleDelay);
  26752. state2.contentVisible = val;
  26753. _select();
  26754. } else {
  26755. __contentVisibleDelay = setTimeout(() => {
  26756. state2.contentVisible = val;
  26757. }, 300);
  26758. }
  26759. });
  26760. watch([() => props2.mode, () => props2.value, () => props2.range], _setValueSync, {
  26761. deep: true
  26762. });
  26763. watch(() => state2.valueSync, _setValueArray, {
  26764. deep: true
  26765. });
  26766. watch(() => state2.valueArray, (val) => {
  26767. if (props2.mode === mode.TIME || props2.mode === mode.DATE) {
  26768. const getValue = props2.mode === mode.TIME ? _getTimeValue : _getDateValue;
  26769. const valueArray = state2.valueArray;
  26770. const _startArray = startArray.value;
  26771. const _endArray = endArray.value;
  26772. if (props2.mode === mode.DATE) {
  26773. const dateArray = state2.dateArray;
  26774. const max = dateArray[2].length;
  26775. const day = Number(dateArray[2][valueArray[2]]) || 1;
  26776. const realDay = (/* @__PURE__ */ new Date(`${dateArray[0][valueArray[0]]}/${dateArray[1][valueArray[1]]}/${day}`)).getDate();
  26777. if (realDay < day) {
  26778. valueArray[2] -= realDay + max - day;
  26779. }
  26780. }
  26781. if (getValue(valueArray) < getValue(_startArray)) {
  26782. _cloneArray(valueArray, _startArray);
  26783. } else if (getValue(valueArray) > getValue(_endArray)) {
  26784. _cloneArray(valueArray, _endArray);
  26785. }
  26786. }
  26787. val.forEach((value, column) => {
  26788. if (value !== state2.oldValueArray[column]) {
  26789. state2.oldValueArray[column] = value;
  26790. if (props2.mode === mode.MULTISELECTOR) {
  26791. trigger("columnchange", {}, {
  26792. column,
  26793. value
  26794. });
  26795. }
  26796. }
  26797. });
  26798. });
  26799. return {
  26800. selectorTypeComputed,
  26801. system,
  26802. _show,
  26803. _cancel,
  26804. _change,
  26805. _l10nColumn,
  26806. _l10nItem,
  26807. _input,
  26808. _resetFormData,
  26809. _getFormData,
  26810. _createTime,
  26811. _createDate,
  26812. _setValueSync,
  26813. _fixInputPosition,
  26814. _pickerViewChange
  26815. };
  26816. }
  26817. function usePickerWatch(state2, _cancel, _change) {
  26818. const {
  26819. key,
  26820. disable
  26821. } = useKeyboard();
  26822. watchEffect(() => {
  26823. disable.value = !state2.visible;
  26824. });
  26825. watch(key, (value) => {
  26826. if (value === "esc") {
  26827. _cancel();
  26828. } else if (value === "enter") {
  26829. _change();
  26830. }
  26831. });
  26832. }
  26833. function usePickerForm(_resetFormData, _getFormData) {
  26834. const uniForm = inject(uniFormKey, false);
  26835. if (uniForm) {
  26836. const field = {
  26837. reset: _resetFormData,
  26838. submit: () => {
  26839. const data = ["", null];
  26840. const {
  26841. key,
  26842. value
  26843. } = _getFormData();
  26844. if (key !== "") {
  26845. data[0] = key;
  26846. data[1] = value;
  26847. }
  26848. return data;
  26849. }
  26850. };
  26851. uniForm.addField(field);
  26852. onBeforeUnmount(() => {
  26853. uniForm.removeField(field);
  26854. });
  26855. }
  26856. }
  26857. const index$6 = /* @__PURE__ */ defineUnsupportedComponent("ad");
  26858. const index$5 = /* @__PURE__ */ defineUnsupportedComponent("ad-content-page");
  26859. const index$4 = /* @__PURE__ */ defineUnsupportedComponent("ad-draw");
  26860. const index$3 = /* @__PURE__ */ defineUnsupportedComponent("camera");
  26861. const index$2 = /* @__PURE__ */ defineUnsupportedComponent("live-player");
  26862. const index$1 = /* @__PURE__ */ defineUnsupportedComponent("live-pusher");
  26863. const UniViewJSBridge$1 = /* @__PURE__ */ extend(ViewJSBridge, {
  26864. publishHandler(event, args, pageId) {
  26865. UniServiceJSBridge.subscribeHandler(event, args, pageId);
  26866. }
  26867. });
  26868. const uni$1 = api;
  26869. const UniServiceJSBridge$1 = /* @__PURE__ */ extend(ServiceJSBridge, {
  26870. publishHandler(event, args, pageId) {
  26871. UniViewJSBridge.subscribeHandler(event, args, pageId);
  26872. }
  26873. });
  26874. function updateBackgroundColorContent(backgroundColorContent) {
  26875. if (backgroundColorContent) {
  26876. document.body.style.setProperty(
  26877. "--background-color-content",
  26878. backgroundColorContent
  26879. );
  26880. } else {
  26881. document.body.style.removeProperty("--background-color-content");
  26882. }
  26883. }
  26884. function useBackgroundColorContent(pageMeta) {
  26885. function update() {
  26886. if (pageMeta.backgroundColorContent) {
  26887. updateBackgroundColorContent(
  26888. parseTheme({ backgroundColorContent: pageMeta.backgroundColorContent }).backgroundColorContent
  26889. );
  26890. }
  26891. }
  26892. onThemeChange$2(update);
  26893. watchEffect(update);
  26894. onActivated(update);
  26895. }
  26896. function usePageHeadTransparentBackgroundColor(backgroundColor) {
  26897. const { r, g: g2, b } = hexToRgba(backgroundColor);
  26898. return `rgba(${r},${g2},${b},0)`;
  26899. }
  26900. function usePageHeadTransparent(headRef, {
  26901. id: id2,
  26902. navigationBar: { titleColor, coverage, backgroundColor }
  26903. }) {
  26904. let A = 0;
  26905. const rgb = computed(() => hexToRgba(backgroundColor));
  26906. const offset = parseInt(coverage);
  26907. let titleElem;
  26908. let transparentElemStyle;
  26909. const iconElemsPaths = [];
  26910. const borderRadiusElemsStyles = [];
  26911. const oldColors = [];
  26912. onMounted(() => {
  26913. const $el = headRef.value;
  26914. transparentElemStyle = $el.style;
  26915. titleElem = $el.querySelector(".uni-page-head__title");
  26916. const borderRadiusElems = $el.querySelectorAll(
  26917. ".uni-page-head-btn"
  26918. );
  26919. const iconSvgElems = $el.querySelectorAll(
  26920. "svg path"
  26921. );
  26922. for (let i = 0; i < iconSvgElems.length; i++) {
  26923. iconElemsPaths.push(iconSvgElems[i]);
  26924. }
  26925. for (let i = 0; i < borderRadiusElems.length; i++) {
  26926. const borderRadiusElem = borderRadiusElems[i];
  26927. oldColors.push(getComputedStyle(borderRadiusElem).backgroundColor);
  26928. borderRadiusElemsStyles.push(borderRadiusElem.style);
  26929. }
  26930. });
  26931. useOn(id2 + ".onPageScroll", ({ scrollTop }) => {
  26932. const alpha = Math.min(scrollTop / offset, 1);
  26933. if (alpha === 1 && A === 1) {
  26934. return;
  26935. }
  26936. if (alpha > 0.5 && A <= 0.5) {
  26937. iconElemsPaths.forEach(function(iconElemPath) {
  26938. iconElemPath.setAttribute("fill", titleColor);
  26939. });
  26940. } else if (alpha <= 0.5 && A > 0.5) {
  26941. iconElemsPaths.forEach(function(iconElemPath) {
  26942. iconElemPath.setAttribute("fill", "#fff");
  26943. });
  26944. }
  26945. A = alpha;
  26946. if (titleElem) {
  26947. titleElem.style.opacity = alpha;
  26948. }
  26949. const bg = rgb.value;
  26950. transparentElemStyle.backgroundColor = `rgba(${bg.r},${bg.g},${bg.b},${alpha})`;
  26951. borderRadiusElemsStyles.forEach(function(borderRadiusElemStyle, index2) {
  26952. const oldColor = oldColors[index2];
  26953. const rgba = oldColor.match(/[\d+\.]+/g);
  26954. rgba[3] = (1 - alpha) * (rgba.length === 4 ? rgba[3] : 1);
  26955. borderRadiusElemStyle.backgroundColor = `rgba(${rgba})`;
  26956. });
  26957. });
  26958. }
  26959. const ICON_PATHS = {
  26960. none: "",
  26961. 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",
  26962. back: ICON_PATH_BACK,
  26963. select: ICON_PATH_BACK,
  26964. 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",
  26965. 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",
  26966. 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",
  26967. 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",
  26968. close: ICON_PATH_CLOSE
  26969. };
  26970. const PageHead = /* @__PURE__ */ defineSystemComponent({
  26971. name: "PageHead",
  26972. setup() {
  26973. const headRef = ref(null);
  26974. const pageMeta = usePageMeta();
  26975. const navigationBar = useTheme(pageMeta.navigationBar, () => {
  26976. const _navigationBar = parseTheme(pageMeta.navigationBar);
  26977. navigationBar.backgroundColor = _navigationBar.backgroundColor;
  26978. navigationBar.titleColor = _navigationBar.titleColor;
  26979. });
  26980. const {
  26981. clazz: clazz2,
  26982. style
  26983. } = usePageHead(navigationBar);
  26984. const buttons = __UNI_FEATURE_NAVIGATIONBAR_BUTTONS__ && usePageHeadButtons(pageMeta);
  26985. const searchInput = __UNI_FEATURE_NAVIGATIONBAR_SEARCHINPUT__ && navigationBar.searchInput && usePageHeadSearchInput(pageMeta);
  26986. __UNI_FEATURE_NAVIGATIONBAR_TRANSPARENT__ && navigationBar.type === "transparent" && usePageHeadTransparent(headRef, pageMeta);
  26987. return () => {
  26988. const backButtonTsx = __UNI_FEATURE_PAGES__ ? createBackButtonTsx(navigationBar, pageMeta.isQuit) : null;
  26989. const leftButtonsTsx = __UNI_FEATURE_NAVIGATIONBAR_BUTTONS__ ? createButtonsTsx(buttons.left) : [];
  26990. const rightButtonsTsx = __UNI_FEATURE_NAVIGATIONBAR_BUTTONS__ ? createButtonsTsx(buttons.right) : [];
  26991. const type = navigationBar.type || "default";
  26992. const placeholderTsx = type !== "transparent" && type !== "float" && createVNode("div", {
  26993. "class": {
  26994. "uni-placeholder": true,
  26995. "uni-placeholder-titlePenetrate": navigationBar.titlePenetrate
  26996. }
  26997. }, null, 2);
  26998. return createVNode("uni-page-head", {
  26999. "uni-page-head-type": type
  27000. }, [createVNode("div", {
  27001. "ref": headRef,
  27002. "class": clazz2.value,
  27003. "style": style.value
  27004. }, [createVNode("div", {
  27005. "class": "uni-page-head-hd"
  27006. }, [backButtonTsx, ...leftButtonsTsx]), createPageHeadBdTsx(navigationBar, searchInput), createVNode("div", {
  27007. "class": "uni-page-head-ft"
  27008. }, [...rightButtonsTsx])], 6), placeholderTsx], 8, ["uni-page-head-type"]);
  27009. };
  27010. }
  27011. });
  27012. function createBackButtonTsx(navigationBar, isQuit) {
  27013. if (!isQuit) {
  27014. return createVNode("div", {
  27015. "class": "uni-page-head-btn",
  27016. "onClick": onPageHeadBackButton
  27017. }, [createSvgIconVNode(ICON_PATH_BACK, navigationBar.type === "transparent" ? "#fff" : navigationBar.titleColor, 26)], 8, ["onClick"]);
  27018. }
  27019. }
  27020. function createButtonsTsx(btns) {
  27021. return btns.map(({
  27022. onClick,
  27023. btnClass,
  27024. btnStyle,
  27025. btnText,
  27026. btnIconPath,
  27027. badgeText,
  27028. iconStyle,
  27029. btnSelect
  27030. }, index2) => {
  27031. return createVNode("div", {
  27032. "key": index2,
  27033. "class": btnClass,
  27034. "style": btnStyle,
  27035. "onClick": onClick,
  27036. "badge-text": badgeText
  27037. }, [btnIconPath ? createSvgIconVNode(btnIconPath, iconStyle.color, iconStyle.fontSize) : btnSelect ? createVNode("span", {
  27038. "style": iconStyle
  27039. }, [createVNode("i", {
  27040. "class": "uni-btn-icon",
  27041. "innerHTML": btnText
  27042. }, null, 8, ["innerHTML"]), createSvgIconVNode(ICON_PATHS["select"], "#000", 14)], 4) : createVNode("i", {
  27043. "class": "uni-btn-icon",
  27044. "style": iconStyle,
  27045. "innerHTML": btnText
  27046. }, null, 12, ["innerHTML"])], 14, ["onClick", "badge-text"]);
  27047. });
  27048. }
  27049. function createPageHeadBdTsx(navigationBar, searchInput) {
  27050. if (!__UNI_FEATURE_NAVIGATIONBAR_SEARCHINPUT__ || !navigationBar.searchInput) {
  27051. return createPageHeadTitleTextTsx(navigationBar);
  27052. }
  27053. return createPageHeadSearchInputTsx(navigationBar, searchInput);
  27054. }
  27055. function createPageHeadTitleTextTsx({
  27056. type,
  27057. loading,
  27058. titleSize,
  27059. titleText,
  27060. titleImage
  27061. }) {
  27062. return createVNode("div", {
  27063. "class": "uni-page-head-bd"
  27064. }, [createVNode("div", {
  27065. "style": {
  27066. fontSize: titleSize,
  27067. opacity: type === "transparent" ? 0 : 1
  27068. },
  27069. "class": "uni-page-head__title"
  27070. }, [loading ? createVNode("i", {
  27071. "class": "uni-loading"
  27072. }, null) : titleImage ? createVNode("img", {
  27073. "src": titleImage,
  27074. "class": "uni-page-head__title_image"
  27075. }, null, 8, ["src"]) : titleText], 4)]);
  27076. }
  27077. function createPageHeadSearchInputTsx(navigationBar, {
  27078. text: text2,
  27079. focus,
  27080. composing,
  27081. onBlur,
  27082. onFocus,
  27083. onInput,
  27084. onConfirm,
  27085. onClick
  27086. }) {
  27087. const {
  27088. color,
  27089. align: align2,
  27090. autoFocus,
  27091. disabled,
  27092. borderRadius,
  27093. backgroundColor,
  27094. placeholder,
  27095. placeholderColor
  27096. } = navigationBar.searchInput;
  27097. const searchStyle = {
  27098. borderRadius,
  27099. backgroundColor
  27100. };
  27101. const placeholderClass = ["uni-page-head-search-placeholder", `uni-page-head-search-placeholder-${focus.value || text2.value ? "left" : align2}`];
  27102. return createVNode("div", {
  27103. "class": "uni-page-head-search",
  27104. "style": searchStyle
  27105. }, [createVNode("div", {
  27106. "style": {
  27107. color: placeholderColor
  27108. },
  27109. "class": placeholderClass
  27110. }, [createVNode("div", {
  27111. "class": "uni-page-head-search-icon"
  27112. }, [createSvgIconVNode(ICON_PATH_SEARCH, placeholderColor, 20)]), text2.value || composing.value ? "" : placeholder], 6), disabled ? createVNode(Input, {
  27113. "disabled": true,
  27114. "style": {
  27115. color
  27116. },
  27117. "placeholder-style": "color: " + placeholderColor,
  27118. "class": "uni-page-head-search-input",
  27119. "confirm-type": "search",
  27120. "onClick": onClick
  27121. }, null, 8, ["style", "placeholder-style", "onClick"]) : createVNode(Input, {
  27122. "focus": autoFocus,
  27123. "style": {
  27124. color
  27125. },
  27126. "placeholder-style": "color: " + placeholderColor,
  27127. "class": "uni-page-head-search-input",
  27128. "confirm-type": "search",
  27129. "onFocus": onFocus,
  27130. "onBlur": onBlur,
  27131. "onInput": onInput,
  27132. "onConfirm": onConfirm
  27133. }, null, 8, ["focus", "style", "placeholder-style", "onFocus", "onBlur", "onInput", "onConfirm"])], 4);
  27134. }
  27135. function onPageHeadBackButton() {
  27136. if (getCurrentPages().length === 1) {
  27137. uni.reLaunch({
  27138. url: "/"
  27139. });
  27140. } else {
  27141. uni.navigateBack({
  27142. from: "backbutton",
  27143. success() {
  27144. }
  27145. // 传入空方法,避免返回Promise,因为onBackPress可能导致fail
  27146. });
  27147. }
  27148. }
  27149. function usePageHead(navigationBar) {
  27150. const clazz2 = computed(() => {
  27151. const {
  27152. type,
  27153. titlePenetrate,
  27154. shadowColorType
  27155. } = navigationBar;
  27156. const clazz3 = {
  27157. "uni-page-head": true,
  27158. "uni-page-head-transparent": type === "transparent",
  27159. "uni-page-head-titlePenetrate": titlePenetrate === "YES",
  27160. "uni-page-head-shadow": !!shadowColorType
  27161. };
  27162. if (shadowColorType) {
  27163. clazz3[`uni-page-head-shadow-${shadowColorType}`] = true;
  27164. }
  27165. return clazz3;
  27166. });
  27167. const style = computed(() => {
  27168. const backgroundColor = __UNI_FEATURE_NAVIGATIONBAR_TRANSPARENT__ && navigationBar.type === "transparent" ? usePageHeadTransparentBackgroundColor(navigationBar.backgroundColor) : navigationBar.backgroundColor;
  27169. return {
  27170. backgroundColor,
  27171. color: navigationBar.titleColor,
  27172. transitionDuration: navigationBar.duration,
  27173. transitionTimingFunction: navigationBar.timingFunc
  27174. };
  27175. });
  27176. return {
  27177. clazz: clazz2,
  27178. style
  27179. };
  27180. }
  27181. function usePageHeadButtons({
  27182. id: id2,
  27183. navigationBar
  27184. }) {
  27185. const left = [];
  27186. const right = [];
  27187. const {
  27188. buttons
  27189. } = navigationBar;
  27190. if (isArray(buttons)) {
  27191. const {
  27192. type
  27193. } = navigationBar;
  27194. const isTransparent = type === "transparent";
  27195. const fonts = /* @__PURE__ */ Object.create(null);
  27196. buttons.forEach((btn, index2) => {
  27197. if (btn.fontSrc && !btn.fontFamily) {
  27198. const fontSrc = getRealPath(btn.fontSrc);
  27199. let fontFamily = fonts[fontSrc];
  27200. if (!fontFamily) {
  27201. fontFamily = `font${Date.now()}`;
  27202. fonts[fontSrc] = fontFamily;
  27203. onBeforeMount(() => updateStyle("uni-btn-" + fontFamily, `@font-face{font-family: "${fontFamily}";src: url("${fontSrc}") format("truetype")}`));
  27204. }
  27205. btn.fontFamily = fontFamily;
  27206. }
  27207. const pageHeadBtn = usePageHeadButton(id2, index2, btn, isTransparent);
  27208. if (btn.float === "left") {
  27209. left.push(pageHeadBtn);
  27210. } else {
  27211. right.push(pageHeadBtn);
  27212. }
  27213. });
  27214. }
  27215. return {
  27216. left,
  27217. right
  27218. };
  27219. }
  27220. function usePageHeadButton(pageId, index2, btn, isTransparent) {
  27221. const iconStyle = {
  27222. color: btn.color,
  27223. fontSize: btn.fontSize,
  27224. fontWeight: btn.fontWeight
  27225. };
  27226. if (btn.fontFamily) {
  27227. iconStyle.fontFamily = btn.fontFamily;
  27228. }
  27229. return new Proxy({
  27230. btnClass: {
  27231. // 类似这样的大量重复的字符串,会在gzip时压缩大小,无需在代码层考虑优化相同字符串
  27232. "uni-page-head-btn": true,
  27233. "uni-page-head-btn-red-dot": !!(btn.redDot || btn.badgeText),
  27234. "uni-page-head-btn-select": !!btn.select
  27235. },
  27236. btnStyle: {
  27237. backgroundColor: isTransparent ? btn.background : "transparent",
  27238. width: btn.width
  27239. },
  27240. btnText: "",
  27241. btnIconPath: ICON_PATHS[btn.type],
  27242. badgeText: btn.badgeText,
  27243. iconStyle,
  27244. onClick() {
  27245. invokeHook(pageId, ON_NAVIGATION_BAR_BUTTON_TAP, extend({
  27246. index: index2
  27247. }, btn));
  27248. },
  27249. btnSelect: btn.select
  27250. }, {
  27251. get(target, key, receiver) {
  27252. if (["btnText"].includes(key)) {
  27253. return btn.fontSrc && btn.fontFamily ? btn.text.replace("\\u", "&#x") : btn.text;
  27254. } else {
  27255. return Reflect.get(target, key, receiver);
  27256. }
  27257. }
  27258. });
  27259. }
  27260. function usePageHeadSearchInput({
  27261. id: id2,
  27262. navigationBar: {
  27263. searchInput
  27264. }
  27265. }) {
  27266. const focus = ref(false);
  27267. const text2 = ref("");
  27268. const composing = ref(false);
  27269. const {
  27270. disabled
  27271. } = searchInput;
  27272. if (disabled) {
  27273. const onClick = () => {
  27274. invokeHook(id2, ON_NAVIGATION_BAR_SEARCH_INPUT_CLICKED);
  27275. };
  27276. return {
  27277. focus,
  27278. text: text2,
  27279. composing,
  27280. onClick
  27281. };
  27282. }
  27283. const onFocus = () => {
  27284. focus.value = true;
  27285. invokeHook(id2, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, {
  27286. focus: true
  27287. });
  27288. };
  27289. const onBlur = () => {
  27290. focus.value = false;
  27291. invokeHook(id2, ON_NAVIGATION_BAR_SEARCH_INPUT_FOCUS_CHANGED, {
  27292. focus: false
  27293. });
  27294. };
  27295. const onInput = (evt) => {
  27296. text2.value = evt.detail.value;
  27297. invokeHook(id2, ON_NAVIGATION_BAR_SEARCH_INPUT_CHANGED, {
  27298. text: text2.value
  27299. });
  27300. };
  27301. const onConfirm = (evt) => {
  27302. invokeHook(id2, ON_NAVIGATION_BAR_SEARCH_INPUT_CONFIRMED, {
  27303. text: text2.value
  27304. });
  27305. };
  27306. return {
  27307. focus,
  27308. text: text2,
  27309. composing,
  27310. onFocus,
  27311. onBlur,
  27312. onInput,
  27313. onConfirm
  27314. };
  27315. }
  27316. const _sfc_main = {
  27317. name: "PageRefresh",
  27318. setup() {
  27319. const { pullToRefresh } = usePageMeta();
  27320. return {
  27321. offset: pullToRefresh.offset,
  27322. color: pullToRefresh.color
  27323. };
  27324. }
  27325. };
  27326. const _export_sfc = (sfc, props2) => {
  27327. const target = sfc.__vccOpts || sfc;
  27328. for (const [key, val] of props2) {
  27329. target[key] = val;
  27330. }
  27331. return target;
  27332. };
  27333. const _hoisted_1 = { class: "uni-page-refresh-inner" };
  27334. const _hoisted_2 = ["fill"];
  27335. 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);
  27336. const _hoisted_4 = /* @__PURE__ */ createElementVNode("path", {
  27337. d: "M0 0h24v24H0z",
  27338. fill: "none"
  27339. }, null, -1);
  27340. const _hoisted_5 = [
  27341. _hoisted_3,
  27342. _hoisted_4
  27343. ];
  27344. const _hoisted_6 = {
  27345. class: "uni-page-refresh__spinner",
  27346. width: "24",
  27347. height: "24",
  27348. viewBox: "25 25 50 50"
  27349. };
  27350. const _hoisted_7 = ["stroke"];
  27351. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  27352. return openBlock(), createElementBlock("uni-page-refresh", null, [
  27353. createElementVNode("div", {
  27354. style: normalizeStyle({ "margin-top": $setup.offset + "px" }),
  27355. class: "uni-page-refresh"
  27356. }, [
  27357. createElementVNode("div", _hoisted_1, [
  27358. (openBlock(), createElementBlock("svg", {
  27359. fill: $setup.color,
  27360. class: "uni-page-refresh__icon",
  27361. width: "24",
  27362. height: "24",
  27363. viewBox: "0 0 24 24"
  27364. }, _hoisted_5, 8, _hoisted_2)),
  27365. (openBlock(), createElementBlock("svg", _hoisted_6, [
  27366. createElementVNode("circle", {
  27367. stroke: $setup.color,
  27368. class: "uni-page-refresh__path",
  27369. cx: "50",
  27370. cy: "50",
  27371. r: "20",
  27372. fill: "none",
  27373. "stroke-width": "4",
  27374. "stroke-miterlimit": "10"
  27375. }, null, 8, _hoisted_7)
  27376. ]))
  27377. ])
  27378. ], 4)
  27379. ]);
  27380. }
  27381. const PageRefresh = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
  27382. function processDeltaY(ev, identifier, startY) {
  27383. const touch = Array.prototype.slice.call(ev.changedTouches).filter((touch2) => touch2.identifier === identifier)[0];
  27384. if (!touch) {
  27385. return false;
  27386. }
  27387. ev.deltaY = touch.pageY - startY;
  27388. return true;
  27389. }
  27390. const PULLING = "pulling";
  27391. const REACHED = "reached";
  27392. const ABORTING = "aborting";
  27393. const REFRESHING = "refreshing";
  27394. const RESTORING = "restoring";
  27395. function usePageRefresh(refreshRef) {
  27396. const pageMeta = usePageMeta();
  27397. const { id: id2, pullToRefresh } = pageMeta;
  27398. const { range, height } = pullToRefresh;
  27399. let refreshContainerElem;
  27400. let refreshControllerElem;
  27401. let refreshControllerElemStyle;
  27402. let refreshInnerElemStyle;
  27403. useSubscribe(
  27404. () => {
  27405. if (!pageMeta.enablePullDownRefresh) {
  27406. return;
  27407. }
  27408. if (!state2) {
  27409. state2 = REFRESHING;
  27410. addClass();
  27411. setTimeout(() => {
  27412. refreshing();
  27413. }, 50);
  27414. }
  27415. },
  27416. API_START_PULL_DOWN_REFRESH,
  27417. false,
  27418. id2
  27419. );
  27420. useSubscribe(
  27421. () => {
  27422. if (!pageMeta.enablePullDownRefresh) {
  27423. return;
  27424. }
  27425. if (state2 === REFRESHING) {
  27426. removeClass();
  27427. state2 = RESTORING;
  27428. addClass();
  27429. restoring(() => {
  27430. removeClass();
  27431. state2 = distance2 = offset = null;
  27432. });
  27433. }
  27434. },
  27435. API_STOP_PULL_DOWN_REFRESH,
  27436. false,
  27437. id2
  27438. );
  27439. function initElement() {
  27440. refreshContainerElem = refreshRef.value.$el;
  27441. refreshControllerElem = refreshContainerElem.querySelector(".uni-page-refresh");
  27442. refreshControllerElemStyle = refreshControllerElem.style;
  27443. refreshInnerElemStyle = refreshControllerElem.querySelector(
  27444. ".uni-page-refresh-inner"
  27445. ).style;
  27446. }
  27447. onMounted(() => {
  27448. initElement();
  27449. });
  27450. {
  27451. watch(
  27452. () => pageMeta.enablePullDownRefresh,
  27453. (enablePullDownRefresh) => {
  27454. if (enablePullDownRefresh) {
  27455. nextTick(() => {
  27456. initElement();
  27457. });
  27458. }
  27459. }
  27460. );
  27461. }
  27462. let touchId;
  27463. let startY;
  27464. let canRefresh;
  27465. let state2;
  27466. let distance2 = null;
  27467. let offset = null;
  27468. function toggleClass(type) {
  27469. if (!state2) {
  27470. return;
  27471. }
  27472. if (refreshContainerElem) {
  27473. refreshContainerElem.classList[type]("uni-page-refresh--" + state2);
  27474. }
  27475. }
  27476. function addClass() {
  27477. toggleClass("add");
  27478. }
  27479. function removeClass() {
  27480. toggleClass("remove");
  27481. }
  27482. function pulling(deltaY) {
  27483. if (!refreshControllerElem) {
  27484. return;
  27485. }
  27486. let rotate = deltaY / range;
  27487. if (rotate > 1) {
  27488. rotate = 1;
  27489. } else {
  27490. rotate = rotate * rotate * rotate;
  27491. }
  27492. const y = Math.round(deltaY / (range / height)) || 0;
  27493. refreshInnerElemStyle.transform = "rotate(" + 360 * rotate + "deg)";
  27494. refreshControllerElemStyle.clip = "rect(" + (45 - y) + "px,45px,45px,-5px)";
  27495. refreshControllerElemStyle.transform = "translate3d(-50%, " + y + "px, 0)";
  27496. }
  27497. const onTouchstartPassive = withWebEvent((ev) => {
  27498. if (!pageMeta.enablePullDownRefresh) {
  27499. return;
  27500. }
  27501. const touch = ev.changedTouches[0];
  27502. touchId = touch.identifier;
  27503. startY = touch.pageY;
  27504. if ([ABORTING, REFRESHING, RESTORING].indexOf(state2) >= 0) {
  27505. canRefresh = false;
  27506. } else {
  27507. canRefresh = true;
  27508. }
  27509. });
  27510. const onTouchmove = withWebEvent((ev) => {
  27511. if (!pageMeta.enablePullDownRefresh) {
  27512. return;
  27513. }
  27514. if (!canRefresh) {
  27515. return;
  27516. }
  27517. if (!processDeltaY(ev, touchId, startY)) {
  27518. return;
  27519. }
  27520. let { deltaY } = ev;
  27521. if ((document.documentElement.scrollTop || document.body.scrollTop) !== 0) {
  27522. touchId = null;
  27523. return;
  27524. }
  27525. if (deltaY < 0 && !state2) {
  27526. return;
  27527. }
  27528. if (ev.cancelable) {
  27529. ev.preventDefault();
  27530. }
  27531. if (distance2 === null) {
  27532. offset = deltaY;
  27533. state2 = PULLING;
  27534. addClass();
  27535. }
  27536. deltaY = deltaY - offset;
  27537. if (deltaY < 0) {
  27538. deltaY = 0;
  27539. }
  27540. distance2 = deltaY;
  27541. const isReached = deltaY >= range && state2 !== REACHED;
  27542. const isPulling = deltaY < range && state2 !== PULLING;
  27543. if (isReached || isPulling) {
  27544. removeClass();
  27545. state2 = state2 === REACHED ? PULLING : REACHED;
  27546. addClass();
  27547. }
  27548. pulling(deltaY);
  27549. });
  27550. const onTouchend = withWebEvent((ev) => {
  27551. if (!pageMeta.enablePullDownRefresh) {
  27552. return;
  27553. }
  27554. if (!processDeltaY(ev, touchId, startY)) {
  27555. return;
  27556. }
  27557. if (state2 === null) {
  27558. return;
  27559. }
  27560. if (state2 === PULLING) {
  27561. removeClass();
  27562. state2 = ABORTING;
  27563. addClass();
  27564. aborting(() => {
  27565. removeClass();
  27566. state2 = distance2 = offset = null;
  27567. });
  27568. } else if (state2 === REACHED) {
  27569. removeClass();
  27570. state2 = REFRESHING;
  27571. addClass();
  27572. refreshing();
  27573. }
  27574. });
  27575. function aborting(callback) {
  27576. if (!refreshControllerElem) {
  27577. return;
  27578. }
  27579. if (refreshControllerElemStyle.transform) {
  27580. refreshControllerElemStyle.transition = "-webkit-transform 0.3s";
  27581. refreshControllerElemStyle.transform = "translate3d(-50%, 0, 0)";
  27582. const abortTransitionEnd = function() {
  27583. timeout && clearTimeout(timeout);
  27584. refreshControllerElem.removeEventListener(
  27585. "webkitTransitionEnd",
  27586. abortTransitionEnd
  27587. );
  27588. refreshControllerElemStyle.transition = "";
  27589. callback();
  27590. };
  27591. refreshControllerElem.addEventListener(
  27592. "webkitTransitionEnd",
  27593. abortTransitionEnd
  27594. );
  27595. const timeout = setTimeout(abortTransitionEnd, 350);
  27596. } else {
  27597. callback();
  27598. }
  27599. }
  27600. function refreshing() {
  27601. if (!refreshControllerElem) {
  27602. return;
  27603. }
  27604. refreshControllerElemStyle.transition = "-webkit-transform 0.2s";
  27605. refreshControllerElemStyle.transform = "translate3d(-50%, " + height + "px, 0)";
  27606. invokeHook(id2, ON_PULL_DOWN_REFRESH);
  27607. }
  27608. function restoring(callback) {
  27609. if (!refreshControllerElem) {
  27610. return;
  27611. }
  27612. refreshControllerElemStyle.transition = "-webkit-transform 0.3s";
  27613. refreshControllerElemStyle.transform += " scale(0.01)";
  27614. const restoreTransitionEnd = function() {
  27615. timeout && clearTimeout(timeout);
  27616. refreshControllerElem.removeEventListener(
  27617. "webkitTransitionEnd",
  27618. restoreTransitionEnd
  27619. );
  27620. refreshControllerElemStyle.transition = "";
  27621. refreshControllerElemStyle.transform = "translate3d(-50%, 0, 0)";
  27622. callback();
  27623. };
  27624. refreshControllerElem.addEventListener(
  27625. "webkitTransitionEnd",
  27626. restoreTransitionEnd
  27627. );
  27628. const timeout = setTimeout(restoreTransitionEnd, 350);
  27629. }
  27630. return {
  27631. onTouchstartPassive,
  27632. onTouchmove,
  27633. onTouchend,
  27634. onTouchcancel: onTouchend
  27635. };
  27636. }
  27637. const PageBody = /* @__PURE__ */ defineSystemComponent({
  27638. name: "PageBody",
  27639. setup(props2, ctx) {
  27640. const pageMeta = __UNI_FEATURE_PULL_DOWN_REFRESH__ && usePageMeta();
  27641. const refreshRef = __UNI_FEATURE_PULL_DOWN_REFRESH__ && ref(null);
  27642. const _pageRefresh = __UNI_FEATURE_PULL_DOWN_REFRESH__ && (pageMeta.enablePullDownRefresh || true) ? usePageRefresh(refreshRef) : null;
  27643. const pageRefresh = ref(null);
  27644. watch(() => {
  27645. return pageMeta.enablePullDownRefresh;
  27646. }, () => {
  27647. pageRefresh.value = pageMeta.enablePullDownRefresh ? _pageRefresh : null;
  27648. }, {
  27649. immediate: true
  27650. });
  27651. return () => {
  27652. const pageRefreshTsx = __UNI_FEATURE_PULL_DOWN_REFRESH__ && createPageRefreshTsx(refreshRef);
  27653. return createVNode(Fragment, null, [pageRefreshTsx, createVNode("uni-page-wrapper", pageRefresh.value, [createVNode("uni-page-body", null, [renderSlot(ctx.slots, "default")])], 16)]);
  27654. };
  27655. }
  27656. });
  27657. function createPageRefreshTsx(refreshRef, pageMeta) {
  27658. return createVNode(PageRefresh, {
  27659. "ref": refreshRef
  27660. }, null, 512);
  27661. }
  27662. const index = /* @__PURE__ */ defineSystemComponent({
  27663. name: "Page",
  27664. setup(_props, ctx) {
  27665. const pageMeta = providePageMeta(getStateId());
  27666. const navigationBar = pageMeta.navigationBar;
  27667. const pageStyle = {};
  27668. useDocumentTitle(pageMeta);
  27669. {
  27670. useBackgroundColorContent(pageMeta);
  27671. }
  27672. return () => createVNode(
  27673. "uni-page",
  27674. {
  27675. "data-page": pageMeta.route,
  27676. style: pageStyle
  27677. },
  27678. __UNI_FEATURE_NAVIGATIONBAR__ && navigationBar.style !== "custom" ? [createVNode(PageHead), createPageBodyVNode(ctx)] : [createPageBodyVNode(ctx)]
  27679. );
  27680. }
  27681. });
  27682. function createPageBodyVNode(ctx) {
  27683. return openBlock(), createBlock(
  27684. PageBody,
  27685. { key: 0 },
  27686. {
  27687. default: withCtx(() => [renderSlot(ctx.slots, "page")]),
  27688. _: 3
  27689. }
  27690. );
  27691. }
  27692. export {
  27693. $emit,
  27694. $off,
  27695. $on,
  27696. $once,
  27697. index$6 as Ad,
  27698. index$5 as AdContentPage,
  27699. index$4 as AdDraw,
  27700. AsyncErrorComponent,
  27701. AsyncLoadingComponent,
  27702. index$w as Button,
  27703. index$3 as Camera,
  27704. indexX$4 as Canvas,
  27705. index$u as Checkbox,
  27706. index$v as CheckboxGroup,
  27707. index$8 as CoverImage,
  27708. index$9 as CoverView,
  27709. index$s as Editor,
  27710. index$y as Form,
  27711. index$r as Icon,
  27712. index$q as Image,
  27713. Input,
  27714. index$x as Label,
  27715. LayoutComponent,
  27716. index$h as ListItem,
  27717. index$i as ListView,
  27718. index$2 as LivePlayer,
  27719. index$1 as LivePusher,
  27720. Map$1 as Map,
  27721. MovableArea,
  27722. MovableView,
  27723. index$p as Navigator,
  27724. index as PageComponent,
  27725. index$7 as Picker,
  27726. PickerView,
  27727. PickerViewColumn,
  27728. index$o as Progress,
  27729. indexX$3 as Radio,
  27730. index$n as RadioGroup,
  27731. ResizeSensor,
  27732. index$m as RichText,
  27733. ScrollView,
  27734. indexX$2 as Slider,
  27735. index$f as StickyHeader,
  27736. index$g as StickySection,
  27737. Swiper,
  27738. SwiperItem,
  27739. indexX$1 as Switch,
  27740. index$l as Text,
  27741. index$k as Textarea,
  27742. UniButtonElement,
  27743. UniCanvasElement,
  27744. UniCheckboxElement,
  27745. UniCheckboxGroupElement,
  27746. UniCoverImageElement,
  27747. UniCoverViewElement,
  27748. UniEditorElement,
  27749. UniElement,
  27750. UniElement as UniElementImpl,
  27751. UniFormElement,
  27752. UniIconElement,
  27753. UniImageElement,
  27754. UniInputElement,
  27755. UniLabelElement,
  27756. UniListItemElement,
  27757. UniListViewElement,
  27758. UniMapElement,
  27759. UniMovableAreaElement,
  27760. UniMovableViewElement,
  27761. UniNavigatorElement,
  27762. UniPickerElement,
  27763. UniPickerViewColumnElement,
  27764. UniPickerViewElement,
  27765. UniProgressElement,
  27766. UniRadioElement,
  27767. UniRadioGroupElement,
  27768. UniRichTextElement,
  27769. UniScrollViewElement,
  27770. UniServiceJSBridge$1 as UniServiceJSBridge,
  27771. UniSliderElement,
  27772. UniStickyHeaderElement,
  27773. UniStickySectionElement,
  27774. UniSwiperElement,
  27775. UniSwiperItemElement,
  27776. UniSwitchElement,
  27777. UniTextElement,
  27778. UniTextareaElement,
  27779. UniVideoElement,
  27780. UniViewElement,
  27781. UniViewJSBridge$1 as UniViewJSBridge,
  27782. UniWebViewElement,
  27783. index$c as Video,
  27784. index$j as View,
  27785. indexX as WebView,
  27786. addInterceptor,
  27787. addPhoneContact,
  27788. arrayBufferToBase64,
  27789. base64ToArrayBuffer,
  27790. canIUse,
  27791. canvasGetImageData,
  27792. canvasPutImageData,
  27793. canvasToTempFilePath,
  27794. chooseFile,
  27795. chooseImage,
  27796. chooseLocation,
  27797. chooseVideo,
  27798. clearStorage,
  27799. clearStorageSync,
  27800. closePreviewImage,
  27801. closeSocket,
  27802. connectSocket,
  27803. createAnimation$1 as createAnimation,
  27804. createCameraContext,
  27805. createCanvasContext,
  27806. createCanvasContextAsync,
  27807. createInnerAudioContext,
  27808. createIntersectionObserver,
  27809. createLivePlayerContext,
  27810. createMapContext,
  27811. createMediaQueryObserver,
  27812. createSelectorQuery,
  27813. createVideoContext,
  27814. cssBackdropFilter,
  27815. cssConstant,
  27816. cssEnv,
  27817. cssVar,
  27818. downloadFile,
  27819. getApp$1 as getApp,
  27820. getAppBaseInfo,
  27821. getClipboardData,
  27822. getCurrentPages$1 as getCurrentPages,
  27823. getDeviceInfo,
  27824. getElementById,
  27825. getEnterOptionsSync,
  27826. getFileInfo,
  27827. getImageInfo,
  27828. getLaunchOptionsSync,
  27829. getLeftWindowStyle,
  27830. getLocale,
  27831. getLocation,
  27832. getNetworkType,
  27833. getProvider,
  27834. getPushClientId,
  27835. getRealPath,
  27836. getRecorderManager,
  27837. getRightWindowStyle,
  27838. getSavedFileInfo,
  27839. getSavedFileList,
  27840. getScreenBrightness,
  27841. getSelectedTextRange$1 as getSelectedTextRange,
  27842. getStorage,
  27843. getStorageInfo,
  27844. getStorageInfoSync,
  27845. getStorageSync,
  27846. getSystemInfo,
  27847. getSystemInfoSync,
  27848. getTabBarPageId,
  27849. getTopWindowStyle,
  27850. getVideoInfo,
  27851. getWindowInfo,
  27852. hideActionSheet,
  27853. hideKeyboard,
  27854. hideLeftWindow,
  27855. hideLoading,
  27856. hideModal,
  27857. hideNavigationBarLoading,
  27858. hideRightWindow,
  27859. hideTabBar,
  27860. hideTabBarRedDot,
  27861. hideToast,
  27862. hideTopWindow,
  27863. interceptors,
  27864. invokePushCallback,
  27865. loadFontFace,
  27866. login,
  27867. makePhoneCall,
  27868. navigateBack,
  27869. navigateTo,
  27870. offAccelerometerChange,
  27871. offAppHide,
  27872. offAppShow,
  27873. offCompassChange,
  27874. offError,
  27875. offLocationChange,
  27876. offLocationChangeError,
  27877. offNetworkStatusChange,
  27878. offPageNotFound,
  27879. offPushMessage,
  27880. offThemeChange,
  27881. offUnhandledRejection,
  27882. offWindowResize,
  27883. onAccelerometerChange,
  27884. onAppHide,
  27885. onAppShow,
  27886. onCompassChange,
  27887. onCreateVueApp2 as onCreateVueApp,
  27888. onError,
  27889. onGyroscopeChange,
  27890. onLocaleChange,
  27891. onLocationChange,
  27892. onLocationChangeError,
  27893. onMemoryWarning,
  27894. onNetworkStatusChange,
  27895. onPageNotFound,
  27896. onPushMessage,
  27897. onSocketClose,
  27898. onSocketError,
  27899. onSocketMessage,
  27900. onSocketOpen,
  27901. onTabBarMidButtonTap,
  27902. onThemeChange,
  27903. onUnhandledRejection,
  27904. onUserCaptureScreen,
  27905. onWindowResize,
  27906. openDocument,
  27907. openLocation,
  27908. pageScrollTo,
  27909. index$d as plugin,
  27910. preloadPage,
  27911. previewImage,
  27912. reLaunch,
  27913. redirectTo,
  27914. removeAllPages,
  27915. removeInterceptor,
  27916. removeLastPage,
  27917. removeNonTabBarPages,
  27918. removeSavedFile,
  27919. removeStorage,
  27920. removeStorageSync,
  27921. removeTabBarBadge,
  27922. request,
  27923. upx2px as rpx2px,
  27924. saveFile,
  27925. saveImageToPhotosAlbum,
  27926. saveVideoToPhotosAlbum,
  27927. scanCode,
  27928. sendSocketMessage,
  27929. setClipboardData,
  27930. setKeepScreenOn,
  27931. setLeftWindowStyle,
  27932. setLocale,
  27933. setNavigationBarColor,
  27934. setNavigationBarTitle,
  27935. setPageMeta,
  27936. setRightWindowStyle,
  27937. setScreenBrightness,
  27938. setStorage,
  27939. setStorageSync,
  27940. setTabBarBadge,
  27941. setTabBarItem,
  27942. setTabBarStyle,
  27943. setTopWindowStyle,
  27944. setupApp,
  27945. setupPage,
  27946. setupWindow,
  27947. showActionSheet,
  27948. showLeftWindow,
  27949. showLoading,
  27950. showModal,
  27951. showNavigationBarLoading,
  27952. showRightWindow,
  27953. showTabBar,
  27954. showTabBarRedDot,
  27955. showToast,
  27956. showTopWindow,
  27957. startAccelerometer,
  27958. startCompass,
  27959. startGyroscope,
  27960. startLocationUpdate,
  27961. startPullDownRefresh,
  27962. stopAccelerometer,
  27963. stopCompass,
  27964. stopGyroscope,
  27965. stopLocationUpdate,
  27966. stopPullDownRefresh,
  27967. switchTab,
  27968. uni$1 as uni,
  27969. uploadFile,
  27970. upx2px,
  27971. useI18n,
  27972. useTabBar,
  27973. vibrateLong,
  27974. vibrateShort
  27975. };