vant.es.js 417 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142
  1. import { useWindowSize, useRect, useChildren, useParent, onMountedOrActivated, getScrollParent, useEventListener, CUSTOM_FIELD_INJECTION_KEY, useCustomFieldValue, useToggle, raf, useScrollParent, usePageVisibility, doubleRaf, cancelRaf, useCountDown, useClickAway, inBrowser as inBrowser$1 } from "@vant/use";
  2. import { unref, ref, reactive, inject, watch, onMounted, nextTick, createVNode, defineComponent, getCurrentInstance, computed, provide, watchEffect, mergeProps, onDeactivated, onBeforeUnmount, Transition, withDirectives, vShow, onActivated, Teleport, Fragment, createTextVNode, createApp, onUnmounted, onBeforeUpdate, resolveDirective, withKeys, onUpdated, h } from "vue";
  3. import { offsetModifier, createPopper } from "@vant/popperjs";
  4. const isDef = (val) => val !== void 0 && val !== null;
  5. const isFunction = (val) => typeof val === "function";
  6. const isObject = (val) => val !== null && typeof val === "object";
  7. const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
  8. const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
  9. function isMobile(value) {
  10. value = value.replace(/[^-|\d]/g, "");
  11. return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
  12. }
  13. const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
  14. const isIOS$1 = () => inBrowser ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
  15. function noop() {
  16. }
  17. const extend = Object.assign;
  18. const inBrowser = typeof window !== "undefined";
  19. function get(object, path) {
  20. const keys = path.split(".");
  21. let result = object;
  22. keys.forEach((key) => {
  23. var _a;
  24. result = isObject(result) ? (_a = result[key]) != null ? _a : "" : "";
  25. });
  26. return result;
  27. }
  28. function pick(obj, keys, ignoreUndefined) {
  29. return keys.reduce((ret, key) => {
  30. if (!ignoreUndefined || obj[key] !== void 0) {
  31. ret[key] = obj[key];
  32. }
  33. return ret;
  34. }, {});
  35. }
  36. const toArray = (item) => Array.isArray(item) ? item : [item];
  37. const unknownProp = null;
  38. const numericProp = [Number, String];
  39. const truthProp = {
  40. type: Boolean,
  41. default: true
  42. };
  43. const makeRequiredProp = (type) => ({
  44. type,
  45. required: true
  46. });
  47. const makeArrayProp = () => ({
  48. type: Array,
  49. default: () => []
  50. });
  51. const makeNumberProp = (defaultVal) => ({
  52. type: Number,
  53. default: defaultVal
  54. });
  55. const makeNumericProp = (defaultVal) => ({
  56. type: numericProp,
  57. default: defaultVal
  58. });
  59. const makeStringProp = (defaultVal) => ({
  60. type: String,
  61. default: defaultVal
  62. });
  63. function getScrollTop(el) {
  64. const top = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
  65. return Math.max(top, 0);
  66. }
  67. function setScrollTop(el, value) {
  68. if ("scrollTop" in el) {
  69. el.scrollTop = value;
  70. } else {
  71. el.scrollTo(el.scrollX, value);
  72. }
  73. }
  74. function getRootScrollTop() {
  75. return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
  76. }
  77. function setRootScrollTop(value) {
  78. setScrollTop(window, value);
  79. setScrollTop(document.body, value);
  80. }
  81. function getElementTop(el, scroller) {
  82. if (el === window) {
  83. return 0;
  84. }
  85. const scrollTop = scroller ? getScrollTop(scroller) : getRootScrollTop();
  86. return useRect(el).top + scrollTop;
  87. }
  88. const isIOS = isIOS$1();
  89. function resetScroll() {
  90. if (isIOS) {
  91. setRootScrollTop(getRootScrollTop());
  92. }
  93. }
  94. const stopPropagation = (event) => event.stopPropagation();
  95. function preventDefault(event, isStopPropagation) {
  96. if (typeof event.cancelable !== "boolean" || event.cancelable) {
  97. event.preventDefault();
  98. }
  99. if (isStopPropagation) {
  100. stopPropagation(event);
  101. }
  102. }
  103. function isHidden(elementRef) {
  104. const el = unref(elementRef);
  105. if (!el) {
  106. return false;
  107. }
  108. const style = window.getComputedStyle(el);
  109. const hidden = style.display === "none";
  110. const parentHidden = el.offsetParent === null && style.position !== "fixed";
  111. return hidden || parentHidden;
  112. }
  113. const { width: windowWidth, height: windowHeight } = useWindowSize();
  114. function addUnit(value) {
  115. if (isDef(value)) {
  116. return isNumeric(value) ? `${value}px` : String(value);
  117. }
  118. return void 0;
  119. }
  120. function getSizeStyle(originSize) {
  121. if (isDef(originSize)) {
  122. if (Array.isArray(originSize)) {
  123. return {
  124. width: addUnit(originSize[0]),
  125. height: addUnit(originSize[1])
  126. };
  127. }
  128. const size = addUnit(originSize);
  129. return {
  130. width: size,
  131. height: size
  132. };
  133. }
  134. }
  135. function getZIndexStyle(zIndex) {
  136. const style = {};
  137. if (zIndex !== void 0) {
  138. style.zIndex = +zIndex;
  139. }
  140. return style;
  141. }
  142. let rootFontSize;
  143. function getRootFontSize() {
  144. if (!rootFontSize) {
  145. const doc = document.documentElement;
  146. const fontSize = doc.style.fontSize || window.getComputedStyle(doc).fontSize;
  147. rootFontSize = parseFloat(fontSize);
  148. }
  149. return rootFontSize;
  150. }
  151. function convertRem(value) {
  152. value = value.replace(/rem/g, "");
  153. return +value * getRootFontSize();
  154. }
  155. function convertVw(value) {
  156. value = value.replace(/vw/g, "");
  157. return +value * windowWidth.value / 100;
  158. }
  159. function convertVh(value) {
  160. value = value.replace(/vh/g, "");
  161. return +value * windowHeight.value / 100;
  162. }
  163. function unitToPx(value) {
  164. if (typeof value === "number") {
  165. return value;
  166. }
  167. if (inBrowser) {
  168. if (value.includes("rem")) {
  169. return convertRem(value);
  170. }
  171. if (value.includes("vw")) {
  172. return convertVw(value);
  173. }
  174. if (value.includes("vh")) {
  175. return convertVh(value);
  176. }
  177. }
  178. return parseFloat(value);
  179. }
  180. const camelizeRE = /-(\w)/g;
  181. const camelize = (str) => str.replace(camelizeRE, (_, c) => c.toUpperCase());
  182. const kebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
  183. function padZero(num, targetLength = 2) {
  184. let str = num + "";
  185. while (str.length < targetLength) {
  186. str = "0" + str;
  187. }
  188. return str;
  189. }
  190. const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
  191. function trimExtraChar(value, char, regExp) {
  192. const index = value.indexOf(char);
  193. if (index === -1) {
  194. return value;
  195. }
  196. if (char === "-" && index !== 0) {
  197. return value.slice(0, index);
  198. }
  199. return value.slice(0, index + 1) + value.slice(index).replace(regExp, "");
  200. }
  201. function formatNumber(value, allowDot = true, allowMinus = true) {
  202. if (allowDot) {
  203. value = trimExtraChar(value, ".", /\./g);
  204. } else {
  205. value = value.split(".")[0];
  206. }
  207. if (allowMinus) {
  208. value = trimExtraChar(value, "-", /-/g);
  209. } else {
  210. value = value.replace(/-/, "");
  211. }
  212. const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
  213. return value.replace(regExp, "");
  214. }
  215. function addNumber(num1, num2) {
  216. const cardinal = 10 ** 10;
  217. return Math.round((num1 + num2) * cardinal) / cardinal;
  218. }
  219. const { hasOwnProperty } = Object.prototype;
  220. function assignKey(to, from, key) {
  221. const val = from[key];
  222. if (!isDef(val)) {
  223. return;
  224. }
  225. if (!hasOwnProperty.call(to, key) || !isObject(val)) {
  226. to[key] = val;
  227. } else {
  228. to[key] = deepAssign(Object(to[key]), val);
  229. }
  230. }
  231. function deepAssign(to, from) {
  232. Object.keys(from).forEach((key) => {
  233. assignKey(to, from, key);
  234. });
  235. return to;
  236. }
  237. var stdin_default$1E = {
  238. name: "\u59D3\u540D",
  239. tel: "\u7535\u8BDD",
  240. save: "\u4FDD\u5B58",
  241. confirm: "\u786E\u8BA4",
  242. cancel: "\u53D6\u6D88",
  243. delete: "\u5220\u9664",
  244. loading: "\u52A0\u8F7D\u4E2D...",
  245. noCoupon: "\u6682\u65E0\u4F18\u60E0\u5238",
  246. nameEmpty: "\u8BF7\u586B\u5199\u59D3\u540D",
  247. addContact: "\u6DFB\u52A0\u8054\u7CFB\u4EBA",
  248. telInvalid: "\u8BF7\u586B\u5199\u6B63\u786E\u7684\u7535\u8BDD",
  249. vanCalendar: {
  250. end: "\u7ED3\u675F",
  251. start: "\u5F00\u59CB",
  252. title: "\u65E5\u671F\u9009\u62E9",
  253. weekdays: ["\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"],
  254. monthTitle: (year, month) => `${year}\u5E74${month}\u6708`,
  255. rangePrompt: (maxRange) => `\u6700\u591A\u9009\u62E9 ${maxRange} \u5929`
  256. },
  257. vanCascader: {
  258. select: "\u8BF7\u9009\u62E9"
  259. },
  260. vanPagination: {
  261. prev: "\u4E0A\u4E00\u9875",
  262. next: "\u4E0B\u4E00\u9875"
  263. },
  264. vanPullRefresh: {
  265. pulling: "\u4E0B\u62C9\u5373\u53EF\u5237\u65B0...",
  266. loosing: "\u91CA\u653E\u5373\u53EF\u5237\u65B0..."
  267. },
  268. vanSubmitBar: {
  269. label: "\u5408\u8BA1:"
  270. },
  271. vanCoupon: {
  272. unlimited: "\u65E0\u95E8\u69DB",
  273. discount: (discount) => `${discount}\u6298`,
  274. condition: (condition) => `\u6EE1${condition}\u5143\u53EF\u7528`
  275. },
  276. vanCouponCell: {
  277. title: "\u4F18\u60E0\u5238",
  278. count: (count) => `${count}\u5F20\u53EF\u7528`
  279. },
  280. vanCouponList: {
  281. exchange: "\u5151\u6362",
  282. close: "\u4E0D\u4F7F\u7528",
  283. enable: "\u53EF\u7528",
  284. disabled: "\u4E0D\u53EF\u7528",
  285. placeholder: "\u8F93\u5165\u4F18\u60E0\u7801"
  286. },
  287. vanAddressEdit: {
  288. area: "\u5730\u533A",
  289. postal: "\u90AE\u653F\u7F16\u7801",
  290. areaEmpty: "\u8BF7\u9009\u62E9\u5730\u533A",
  291. addressEmpty: "\u8BF7\u586B\u5199\u8BE6\u7EC6\u5730\u5740",
  292. postalEmpty: "\u90AE\u653F\u7F16\u7801\u4E0D\u6B63\u786E",
  293. addressDetail: "\u8BE6\u7EC6\u5730\u5740",
  294. defaultAddress: "\u8BBE\u4E3A\u9ED8\u8BA4\u6536\u8D27\u5730\u5740"
  295. },
  296. vanAddressList: {
  297. add: "\u65B0\u589E\u5730\u5740"
  298. }
  299. };
  300. const lang = ref("zh-CN");
  301. const messages = reactive({
  302. "zh-CN": stdin_default$1E
  303. });
  304. const Locale = {
  305. messages() {
  306. return messages[lang.value];
  307. },
  308. use(newLang, newMessages) {
  309. lang.value = newLang;
  310. this.add({ [newLang]: newMessages });
  311. },
  312. add(newMessages = {}) {
  313. deepAssign(messages, newMessages);
  314. }
  315. };
  316. var stdin_default$1D = Locale;
  317. function createTranslate(name2) {
  318. const prefix = camelize(name2) + ".";
  319. return (path, ...args) => {
  320. const messages2 = stdin_default$1D.messages();
  321. const message = get(messages2, prefix + path) || get(messages2, path);
  322. return isFunction(message) ? message(...args) : message;
  323. };
  324. }
  325. function genBem(name2, mods) {
  326. if (!mods) {
  327. return "";
  328. }
  329. if (typeof mods === "string") {
  330. return ` ${name2}--${mods}`;
  331. }
  332. if (Array.isArray(mods)) {
  333. return mods.reduce(
  334. (ret, item) => ret + genBem(name2, item),
  335. ""
  336. );
  337. }
  338. return Object.keys(mods).reduce(
  339. (ret, key) => ret + (mods[key] ? genBem(name2, key) : ""),
  340. ""
  341. );
  342. }
  343. function createBEM(name2) {
  344. return (el, mods) => {
  345. if (el && typeof el !== "string") {
  346. mods = el;
  347. el = "";
  348. }
  349. el = el ? `${name2}__${el}` : name2;
  350. return `${el}${genBem(el, mods)}`;
  351. };
  352. }
  353. function createNamespace(name2) {
  354. const prefixedName = `van-${name2}`;
  355. return [
  356. prefixedName,
  357. createBEM(prefixedName),
  358. createTranslate(prefixedName)
  359. ];
  360. }
  361. const BORDER = "van-hairline";
  362. const BORDER_TOP = `${BORDER}--top`;
  363. const BORDER_LEFT = `${BORDER}--left`;
  364. const BORDER_BOTTOM = `${BORDER}--bottom`;
  365. const BORDER_SURROUND = `${BORDER}--surround`;
  366. const BORDER_TOP_BOTTOM = `${BORDER}--top-bottom`;
  367. const BORDER_UNSET_TOP_BOTTOM = `${BORDER}-unset--top-bottom`;
  368. const HAPTICS_FEEDBACK = "van-haptics-feedback";
  369. const FORM_KEY = Symbol("van-form");
  370. function callInterceptor(interceptor, {
  371. args = [],
  372. done,
  373. canceled
  374. }) {
  375. if (interceptor) {
  376. const returnVal = interceptor.apply(null, args);
  377. if (isPromise(returnVal)) {
  378. returnVal.then((value) => {
  379. if (value) {
  380. done();
  381. } else if (canceled) {
  382. canceled();
  383. }
  384. }).catch(noop);
  385. } else if (returnVal) {
  386. done();
  387. } else if (canceled) {
  388. canceled();
  389. }
  390. } else {
  391. done();
  392. }
  393. }
  394. function withInstall(options) {
  395. options.install = (app) => {
  396. const { name: name2 } = options;
  397. if (name2) {
  398. app.component(name2, options);
  399. app.component(camelize(`-${name2}`), options);
  400. }
  401. };
  402. return options;
  403. }
  404. const POPUP_TOGGLE_KEY = Symbol();
  405. function onPopupReopen(callback) {
  406. const popupToggleStatus = inject(POPUP_TOGGLE_KEY, null);
  407. if (popupToggleStatus) {
  408. watch(popupToggleStatus, (show) => {
  409. if (show) {
  410. callback();
  411. }
  412. });
  413. }
  414. }
  415. const useHeight = (element, withSafeArea) => {
  416. const height = ref();
  417. const setHeight = () => {
  418. height.value = useRect(element).height;
  419. };
  420. onMounted(() => {
  421. nextTick(setHeight);
  422. if (withSafeArea) {
  423. for (let i = 1; i <= 3; i++) {
  424. setTimeout(setHeight, 100 * i);
  425. }
  426. }
  427. });
  428. onPopupReopen(() => nextTick(setHeight));
  429. return height;
  430. };
  431. function usePlaceholder(contentRef, bem2) {
  432. const height = useHeight(contentRef, true);
  433. return (renderContent) => createVNode("div", {
  434. "class": bem2("placeholder"),
  435. "style": {
  436. height: height.value ? `${height.value}px` : void 0
  437. }
  438. }, [renderContent()]);
  439. }
  440. const [name$1v, bem$1r] = createNamespace("action-bar");
  441. const ACTION_BAR_KEY = Symbol(name$1v);
  442. const actionBarProps = {
  443. placeholder: Boolean,
  444. safeAreaInsetBottom: truthProp
  445. };
  446. var stdin_default$1C = defineComponent({
  447. name: name$1v,
  448. props: actionBarProps,
  449. setup(props, {
  450. slots
  451. }) {
  452. const root = ref();
  453. const renderPlaceholder = usePlaceholder(root, bem$1r);
  454. const {
  455. linkChildren
  456. } = useChildren(ACTION_BAR_KEY);
  457. linkChildren();
  458. const renderActionBar = () => {
  459. var _a;
  460. return createVNode("div", {
  461. "ref": root,
  462. "class": [bem$1r(), {
  463. "van-safe-area-bottom": props.safeAreaInsetBottom
  464. }]
  465. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  466. };
  467. return () => {
  468. if (props.placeholder) {
  469. return renderPlaceholder(renderActionBar);
  470. }
  471. return renderActionBar();
  472. };
  473. }
  474. });
  475. const ActionBar = withInstall(stdin_default$1C);
  476. function useExpose(apis) {
  477. const instance2 = getCurrentInstance();
  478. if (instance2) {
  479. extend(instance2.proxy, apis);
  480. }
  481. }
  482. const routeProps = {
  483. to: [String, Object],
  484. url: String,
  485. replace: Boolean
  486. };
  487. function route({
  488. to,
  489. url,
  490. replace,
  491. $router: router
  492. }) {
  493. if (to && router) {
  494. router[replace ? "replace" : "push"](to);
  495. } else if (url) {
  496. replace ? location.replace(url) : location.href = url;
  497. }
  498. }
  499. function useRoute() {
  500. const vm = getCurrentInstance().proxy;
  501. return () => route(vm);
  502. }
  503. const [name$1u, bem$1q] = createNamespace("badge");
  504. const badgeProps = {
  505. dot: Boolean,
  506. max: numericProp,
  507. tag: makeStringProp("div"),
  508. color: String,
  509. offset: Array,
  510. content: numericProp,
  511. showZero: truthProp,
  512. position: makeStringProp("top-right")
  513. };
  514. var stdin_default$1B = defineComponent({
  515. name: name$1u,
  516. props: badgeProps,
  517. setup(props, {
  518. slots
  519. }) {
  520. const hasContent = () => {
  521. if (slots.content) {
  522. return true;
  523. }
  524. const {
  525. content,
  526. showZero
  527. } = props;
  528. return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
  529. };
  530. const renderContent = () => {
  531. const {
  532. dot,
  533. max,
  534. content
  535. } = props;
  536. if (!dot && hasContent()) {
  537. if (slots.content) {
  538. return slots.content();
  539. }
  540. if (isDef(max) && isNumeric(content) && +content > max) {
  541. return `${max}+`;
  542. }
  543. return content;
  544. }
  545. };
  546. const style = computed(() => {
  547. const style2 = {
  548. background: props.color
  549. };
  550. if (props.offset) {
  551. const [x, y] = props.offset;
  552. if (slots.default) {
  553. style2.top = addUnit(y);
  554. if (typeof x === "number") {
  555. style2.right = addUnit(-x);
  556. } else {
  557. style2.right = x.startsWith("-") ? x.replace("-", "") : `-${x}`;
  558. }
  559. } else {
  560. style2.marginTop = addUnit(y);
  561. style2.marginLeft = addUnit(x);
  562. }
  563. }
  564. return style2;
  565. });
  566. const renderBadge = () => {
  567. if (hasContent() || props.dot) {
  568. return createVNode("div", {
  569. "class": bem$1q([props.position, {
  570. dot: props.dot,
  571. fixed: !!slots.default
  572. }]),
  573. "style": style.value
  574. }, [renderContent()]);
  575. }
  576. };
  577. return () => {
  578. if (slots.default) {
  579. const {
  580. tag
  581. } = props;
  582. return createVNode(tag, {
  583. "class": bem$1q("wrapper")
  584. }, {
  585. default: () => [slots.default(), renderBadge()]
  586. });
  587. }
  588. return renderBadge();
  589. };
  590. }
  591. });
  592. const Badge = withInstall(stdin_default$1B);
  593. let globalZIndex = 2e3;
  594. const useGlobalZIndex = () => ++globalZIndex;
  595. const setGlobalZIndex = (val) => {
  596. globalZIndex = val;
  597. };
  598. const [name$1t, bem$1p] = createNamespace("config-provider");
  599. const CONFIG_PROVIDER_KEY = Symbol(name$1t);
  600. const configProviderProps = {
  601. tag: makeStringProp("div"),
  602. zIndex: Number,
  603. themeVars: Object,
  604. iconPrefix: String
  605. };
  606. function mapThemeVarsToCSSVars(themeVars) {
  607. const cssVars = {};
  608. Object.keys(themeVars).forEach((key) => {
  609. cssVars[`--van-${kebabCase(key)}`] = themeVars[key];
  610. });
  611. return cssVars;
  612. }
  613. var stdin_default$1A = defineComponent({
  614. name: name$1t,
  615. props: configProviderProps,
  616. setup(props, {
  617. slots
  618. }) {
  619. const style = computed(() => {
  620. if (props.themeVars) {
  621. return mapThemeVarsToCSSVars(props.themeVars);
  622. }
  623. });
  624. provide(CONFIG_PROVIDER_KEY, props);
  625. watchEffect(() => {
  626. if (props.zIndex !== void 0) {
  627. setGlobalZIndex(props.zIndex);
  628. }
  629. });
  630. return () => createVNode(props.tag, {
  631. "class": bem$1p(),
  632. "style": style.value
  633. }, {
  634. default: () => {
  635. var _a;
  636. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  637. }
  638. });
  639. }
  640. });
  641. const [name$1s, bem$1o] = createNamespace("icon");
  642. const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
  643. const iconProps = {
  644. dot: Boolean,
  645. tag: makeStringProp("i"),
  646. name: String,
  647. size: numericProp,
  648. badge: numericProp,
  649. color: String,
  650. badgeProps: Object,
  651. classPrefix: String
  652. };
  653. var stdin_default$1z = defineComponent({
  654. name: name$1s,
  655. props: iconProps,
  656. setup(props, {
  657. slots
  658. }) {
  659. const config = inject(CONFIG_PROVIDER_KEY, null);
  660. const classPrefix = computed(() => props.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem$1o());
  661. return () => {
  662. const {
  663. tag,
  664. dot,
  665. name: name2,
  666. size,
  667. badge,
  668. color
  669. } = props;
  670. const isImageIcon = isImage(name2);
  671. return createVNode(Badge, mergeProps({
  672. "dot": dot,
  673. "tag": tag,
  674. "class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
  675. "style": {
  676. color,
  677. fontSize: addUnit(size)
  678. },
  679. "content": badge
  680. }, props.badgeProps), {
  681. default: () => {
  682. var _a;
  683. return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && createVNode("img", {
  684. "class": bem$1o("image"),
  685. "src": name2
  686. }, null)];
  687. }
  688. });
  689. };
  690. }
  691. });
  692. const Icon = withInstall(stdin_default$1z);
  693. const [name$1r, bem$1n] = createNamespace("loading");
  694. const SpinIcon = Array(12).fill(null).map((_, index) => createVNode("i", {
  695. "class": bem$1n("line", String(index + 1))
  696. }, null));
  697. const CircularIcon = createVNode("svg", {
  698. "class": bem$1n("circular"),
  699. "viewBox": "25 25 50 50"
  700. }, [createVNode("circle", {
  701. "cx": "50",
  702. "cy": "50",
  703. "r": "20",
  704. "fill": "none"
  705. }, null)]);
  706. const loadingProps = {
  707. size: numericProp,
  708. type: makeStringProp("circular"),
  709. color: String,
  710. vertical: Boolean,
  711. textSize: numericProp,
  712. textColor: String
  713. };
  714. var stdin_default$1y = defineComponent({
  715. name: name$1r,
  716. props: loadingProps,
  717. setup(props, {
  718. slots
  719. }) {
  720. const spinnerStyle = computed(() => extend({
  721. color: props.color
  722. }, getSizeStyle(props.size)));
  723. const renderText = () => {
  724. var _a;
  725. if (slots.default) {
  726. return createVNode("span", {
  727. "class": bem$1n("text"),
  728. "style": {
  729. fontSize: addUnit(props.textSize),
  730. color: (_a = props.textColor) != null ? _a : props.color
  731. }
  732. }, [slots.default()]);
  733. }
  734. };
  735. return () => {
  736. const {
  737. type,
  738. vertical
  739. } = props;
  740. return createVNode("div", {
  741. "class": bem$1n([type, {
  742. vertical
  743. }]),
  744. "aria-live": "polite",
  745. "aria-busy": true
  746. }, [createVNode("span", {
  747. "class": bem$1n("spinner", type),
  748. "style": spinnerStyle.value
  749. }, [type === "spinner" ? SpinIcon : CircularIcon]), renderText()]);
  750. };
  751. }
  752. });
  753. const Loading = withInstall(stdin_default$1y);
  754. const [name$1q, bem$1m] = createNamespace("button");
  755. const buttonProps = extend({}, routeProps, {
  756. tag: makeStringProp("button"),
  757. text: String,
  758. icon: String,
  759. type: makeStringProp("default"),
  760. size: makeStringProp("normal"),
  761. color: String,
  762. block: Boolean,
  763. plain: Boolean,
  764. round: Boolean,
  765. square: Boolean,
  766. loading: Boolean,
  767. hairline: Boolean,
  768. disabled: Boolean,
  769. iconPrefix: String,
  770. nativeType: makeStringProp("button"),
  771. loadingSize: numericProp,
  772. loadingText: String,
  773. loadingType: String,
  774. iconPosition: makeStringProp("left")
  775. });
  776. var stdin_default$1x = defineComponent({
  777. name: name$1q,
  778. props: buttonProps,
  779. emits: ["click"],
  780. setup(props, {
  781. emit,
  782. slots
  783. }) {
  784. const route2 = useRoute();
  785. const renderLoadingIcon = () => {
  786. if (slots.loading) {
  787. return slots.loading();
  788. }
  789. return createVNode(Loading, {
  790. "size": props.loadingSize,
  791. "type": props.loadingType,
  792. "class": bem$1m("loading")
  793. }, null);
  794. };
  795. const renderIcon = () => {
  796. if (props.loading) {
  797. return renderLoadingIcon();
  798. }
  799. if (slots.icon) {
  800. return createVNode("div", {
  801. "class": bem$1m("icon")
  802. }, [slots.icon()]);
  803. }
  804. if (props.icon) {
  805. return createVNode(Icon, {
  806. "name": props.icon,
  807. "class": bem$1m("icon"),
  808. "classPrefix": props.iconPrefix
  809. }, null);
  810. }
  811. };
  812. const renderText = () => {
  813. let text;
  814. if (props.loading) {
  815. text = props.loadingText;
  816. } else {
  817. text = slots.default ? slots.default() : props.text;
  818. }
  819. if (text) {
  820. return createVNode("span", {
  821. "class": bem$1m("text")
  822. }, [text]);
  823. }
  824. };
  825. const getStyle = () => {
  826. const {
  827. color,
  828. plain
  829. } = props;
  830. if (color) {
  831. const style = {
  832. color: plain ? color : "white"
  833. };
  834. if (!plain) {
  835. style.background = color;
  836. }
  837. if (color.includes("gradient")) {
  838. style.border = 0;
  839. } else {
  840. style.borderColor = color;
  841. }
  842. return style;
  843. }
  844. };
  845. const onClick = (event) => {
  846. if (props.loading) {
  847. preventDefault(event);
  848. } else if (!props.disabled) {
  849. emit("click", event);
  850. route2();
  851. }
  852. };
  853. return () => {
  854. const {
  855. tag,
  856. type,
  857. size,
  858. block,
  859. round,
  860. plain,
  861. square,
  862. loading,
  863. disabled,
  864. hairline,
  865. nativeType,
  866. iconPosition
  867. } = props;
  868. const classes = [bem$1m([type, size, {
  869. plain,
  870. block,
  871. round,
  872. square,
  873. loading,
  874. disabled,
  875. hairline
  876. }]), {
  877. [BORDER_SURROUND]: hairline
  878. }];
  879. return createVNode(tag, {
  880. "type": nativeType,
  881. "class": classes,
  882. "style": getStyle(),
  883. "disabled": disabled,
  884. "onClick": onClick
  885. }, {
  886. default: () => [createVNode("div", {
  887. "class": bem$1m("content")
  888. }, [iconPosition === "left" && renderIcon(), renderText(), iconPosition === "right" && renderIcon()])]
  889. });
  890. };
  891. }
  892. });
  893. const Button = withInstall(stdin_default$1x);
  894. const [name$1p, bem$1l] = createNamespace("action-bar-button");
  895. const actionBarButtonProps = extend({}, routeProps, {
  896. type: String,
  897. text: String,
  898. icon: String,
  899. color: String,
  900. loading: Boolean,
  901. disabled: Boolean
  902. });
  903. var stdin_default$1w = defineComponent({
  904. name: name$1p,
  905. props: actionBarButtonProps,
  906. setup(props, {
  907. slots
  908. }) {
  909. const route2 = useRoute();
  910. const {
  911. parent,
  912. index
  913. } = useParent(ACTION_BAR_KEY);
  914. const isFirst = computed(() => {
  915. if (parent) {
  916. const prev = parent.children[index.value - 1];
  917. return !(prev && "isButton" in prev);
  918. }
  919. });
  920. const isLast = computed(() => {
  921. if (parent) {
  922. const next = parent.children[index.value + 1];
  923. return !(next && "isButton" in next);
  924. }
  925. });
  926. useExpose({
  927. isButton: true
  928. });
  929. return () => {
  930. const {
  931. type,
  932. icon,
  933. text,
  934. color,
  935. loading,
  936. disabled
  937. } = props;
  938. return createVNode(Button, {
  939. "class": bem$1l([type, {
  940. last: isLast.value,
  941. first: isFirst.value
  942. }]),
  943. "size": "large",
  944. "type": type,
  945. "icon": icon,
  946. "color": color,
  947. "loading": loading,
  948. "disabled": disabled,
  949. "onClick": route2
  950. }, {
  951. default: () => [slots.default ? slots.default() : text]
  952. });
  953. };
  954. }
  955. });
  956. const ActionBarButton = withInstall(stdin_default$1w);
  957. const [name$1o, bem$1k] = createNamespace("action-bar-icon");
  958. const actionBarIconProps = extend({}, routeProps, {
  959. dot: Boolean,
  960. text: String,
  961. icon: String,
  962. color: String,
  963. badge: numericProp,
  964. iconClass: unknownProp,
  965. badgeProps: Object,
  966. iconPrefix: String
  967. });
  968. var stdin_default$1v = defineComponent({
  969. name: name$1o,
  970. props: actionBarIconProps,
  971. setup(props, {
  972. slots
  973. }) {
  974. const route2 = useRoute();
  975. useParent(ACTION_BAR_KEY);
  976. const renderIcon = () => {
  977. const {
  978. dot,
  979. badge,
  980. icon,
  981. color,
  982. iconClass,
  983. badgeProps: badgeProps2,
  984. iconPrefix
  985. } = props;
  986. if (slots.icon) {
  987. return createVNode(Badge, mergeProps({
  988. "dot": dot,
  989. "class": bem$1k("icon"),
  990. "content": badge
  991. }, badgeProps2), {
  992. default: slots.icon
  993. });
  994. }
  995. return createVNode(Icon, {
  996. "tag": "div",
  997. "dot": dot,
  998. "name": icon,
  999. "badge": badge,
  1000. "color": color,
  1001. "class": [bem$1k("icon"), iconClass],
  1002. "badgeProps": badgeProps2,
  1003. "classPrefix": iconPrefix
  1004. }, null);
  1005. };
  1006. return () => createVNode("div", {
  1007. "role": "button",
  1008. "class": bem$1k(),
  1009. "tabindex": 0,
  1010. "onClick": route2
  1011. }, [renderIcon(), slots.default ? slots.default() : props.text]);
  1012. }
  1013. });
  1014. const ActionBarIcon = withInstall(stdin_default$1v);
  1015. const popupSharedProps = {
  1016. show: Boolean,
  1017. zIndex: numericProp,
  1018. overlay: truthProp,
  1019. duration: numericProp,
  1020. teleport: [String, Object],
  1021. lockScroll: truthProp,
  1022. lazyRender: truthProp,
  1023. beforeClose: Function,
  1024. overlayStyle: Object,
  1025. overlayClass: unknownProp,
  1026. transitionAppear: Boolean,
  1027. closeOnClickOverlay: truthProp
  1028. };
  1029. const popupSharedPropKeys = Object.keys(
  1030. popupSharedProps
  1031. );
  1032. function getDirection(x, y) {
  1033. if (x > y) {
  1034. return "horizontal";
  1035. }
  1036. if (y > x) {
  1037. return "vertical";
  1038. }
  1039. return "";
  1040. }
  1041. function useTouch() {
  1042. const startX = ref(0);
  1043. const startY = ref(0);
  1044. const deltaX = ref(0);
  1045. const deltaY = ref(0);
  1046. const offsetX = ref(0);
  1047. const offsetY = ref(0);
  1048. const direction = ref("");
  1049. const isVertical = () => direction.value === "vertical";
  1050. const isHorizontal = () => direction.value === "horizontal";
  1051. const reset = () => {
  1052. deltaX.value = 0;
  1053. deltaY.value = 0;
  1054. offsetX.value = 0;
  1055. offsetY.value = 0;
  1056. direction.value = "";
  1057. };
  1058. const start = (event) => {
  1059. reset();
  1060. startX.value = event.touches[0].clientX;
  1061. startY.value = event.touches[0].clientY;
  1062. };
  1063. const move = (event) => {
  1064. const touch = event.touches[0];
  1065. deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
  1066. deltaY.value = touch.clientY - startY.value;
  1067. offsetX.value = Math.abs(deltaX.value);
  1068. offsetY.value = Math.abs(deltaY.value);
  1069. const LOCK_DIRECTION_DISTANCE = 10;
  1070. if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
  1071. direction.value = getDirection(offsetX.value, offsetY.value);
  1072. }
  1073. };
  1074. return {
  1075. move,
  1076. start,
  1077. reset,
  1078. startX,
  1079. startY,
  1080. deltaX,
  1081. deltaY,
  1082. offsetX,
  1083. offsetY,
  1084. direction,
  1085. isVertical,
  1086. isHorizontal
  1087. };
  1088. }
  1089. let totalLockCount = 0;
  1090. const BODY_LOCK_CLASS = "van-overflow-hidden";
  1091. function useLockScroll(rootRef, shouldLock) {
  1092. const touch = useTouch();
  1093. const DIRECTION_UP = "01";
  1094. const DIRECTION_DOWN = "10";
  1095. const onTouchMove = (event) => {
  1096. touch.move(event);
  1097. const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
  1098. const el = getScrollParent(
  1099. event.target,
  1100. rootRef.value
  1101. );
  1102. const { scrollHeight, offsetHeight, scrollTop } = el;
  1103. let status = "11";
  1104. if (scrollTop === 0) {
  1105. status = offsetHeight >= scrollHeight ? "00" : "01";
  1106. } else if (scrollTop + offsetHeight >= scrollHeight) {
  1107. status = "10";
  1108. }
  1109. if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
  1110. preventDefault(event, true);
  1111. }
  1112. };
  1113. const lock = () => {
  1114. document.addEventListener("touchstart", touch.start);
  1115. document.addEventListener("touchmove", onTouchMove, { passive: false });
  1116. if (!totalLockCount) {
  1117. document.body.classList.add(BODY_LOCK_CLASS);
  1118. }
  1119. totalLockCount++;
  1120. };
  1121. const unlock = () => {
  1122. if (totalLockCount) {
  1123. document.removeEventListener("touchstart", touch.start);
  1124. document.removeEventListener("touchmove", onTouchMove);
  1125. totalLockCount--;
  1126. if (!totalLockCount) {
  1127. document.body.classList.remove(BODY_LOCK_CLASS);
  1128. }
  1129. }
  1130. };
  1131. const init = () => shouldLock() && lock();
  1132. const destroy = () => shouldLock() && unlock();
  1133. onMountedOrActivated(init);
  1134. onDeactivated(destroy);
  1135. onBeforeUnmount(destroy);
  1136. watch(shouldLock, (value) => {
  1137. value ? lock() : unlock();
  1138. });
  1139. }
  1140. function useLazyRender(show) {
  1141. const inited = ref(false);
  1142. watch(
  1143. show,
  1144. (value) => {
  1145. if (value) {
  1146. inited.value = value;
  1147. }
  1148. },
  1149. { immediate: true }
  1150. );
  1151. return (render) => () => inited.value ? render() : null;
  1152. }
  1153. const [name$1n, bem$1j] = createNamespace("overlay");
  1154. const overlayProps = {
  1155. show: Boolean,
  1156. zIndex: numericProp,
  1157. duration: numericProp,
  1158. className: unknownProp,
  1159. lockScroll: truthProp,
  1160. lazyRender: truthProp,
  1161. customStyle: Object
  1162. };
  1163. var stdin_default$1u = defineComponent({
  1164. name: name$1n,
  1165. props: overlayProps,
  1166. setup(props, {
  1167. slots
  1168. }) {
  1169. const root = ref();
  1170. const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
  1171. const onTouchMove = (event) => {
  1172. if (props.lockScroll) {
  1173. preventDefault(event, true);
  1174. }
  1175. };
  1176. const renderOverlay = lazyRender(() => {
  1177. var _a;
  1178. const style = extend(getZIndexStyle(props.zIndex), props.customStyle);
  1179. if (isDef(props.duration)) {
  1180. style.animationDuration = `${props.duration}s`;
  1181. }
  1182. return withDirectives(createVNode("div", {
  1183. "ref": root,
  1184. "style": style,
  1185. "class": [bem$1j(), props.className]
  1186. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vShow, props.show]]);
  1187. });
  1188. useEventListener("touchmove", onTouchMove, {
  1189. target: root
  1190. });
  1191. return () => createVNode(Transition, {
  1192. "name": "van-fade",
  1193. "appear": true
  1194. }, {
  1195. default: renderOverlay
  1196. });
  1197. }
  1198. });
  1199. const Overlay = withInstall(stdin_default$1u);
  1200. const popupProps$2 = extend({}, popupSharedProps, {
  1201. round: Boolean,
  1202. position: makeStringProp("center"),
  1203. closeIcon: makeStringProp("cross"),
  1204. closeable: Boolean,
  1205. transition: String,
  1206. iconPrefix: String,
  1207. closeOnPopstate: Boolean,
  1208. closeIconPosition: makeStringProp("top-right"),
  1209. safeAreaInsetTop: Boolean,
  1210. safeAreaInsetBottom: Boolean
  1211. });
  1212. const [name$1m, bem$1i] = createNamespace("popup");
  1213. var stdin_default$1t = defineComponent({
  1214. name: name$1m,
  1215. inheritAttrs: false,
  1216. props: popupProps$2,
  1217. emits: ["open", "close", "opened", "closed", "keydown", "update:show", "click-overlay", "click-close-icon"],
  1218. setup(props, {
  1219. emit,
  1220. attrs,
  1221. slots
  1222. }) {
  1223. let opened;
  1224. let shouldReopen;
  1225. const zIndex = ref();
  1226. const popupRef = ref();
  1227. const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
  1228. const style = computed(() => {
  1229. const style2 = {
  1230. zIndex: zIndex.value
  1231. };
  1232. if (isDef(props.duration)) {
  1233. const key = props.position === "center" ? "animationDuration" : "transitionDuration";
  1234. style2[key] = `${props.duration}s`;
  1235. }
  1236. return style2;
  1237. });
  1238. const open = () => {
  1239. if (!opened) {
  1240. opened = true;
  1241. zIndex.value = props.zIndex !== void 0 ? +props.zIndex : useGlobalZIndex();
  1242. emit("open");
  1243. }
  1244. };
  1245. const close = () => {
  1246. if (opened) {
  1247. callInterceptor(props.beforeClose, {
  1248. done() {
  1249. opened = false;
  1250. emit("close");
  1251. emit("update:show", false);
  1252. }
  1253. });
  1254. }
  1255. };
  1256. const onClickOverlay = (event) => {
  1257. emit("click-overlay", event);
  1258. if (props.closeOnClickOverlay) {
  1259. close();
  1260. }
  1261. };
  1262. const renderOverlay = () => {
  1263. if (props.overlay) {
  1264. return createVNode(Overlay, {
  1265. "show": props.show,
  1266. "class": props.overlayClass,
  1267. "zIndex": zIndex.value,
  1268. "duration": props.duration,
  1269. "customStyle": props.overlayStyle,
  1270. "role": props.closeOnClickOverlay ? "button" : void 0,
  1271. "tabindex": props.closeOnClickOverlay ? 0 : void 0,
  1272. "onClick": onClickOverlay
  1273. }, {
  1274. default: slots["overlay-content"]
  1275. });
  1276. }
  1277. };
  1278. const onClickCloseIcon = (event) => {
  1279. emit("click-close-icon", event);
  1280. close();
  1281. };
  1282. const renderCloseIcon = () => {
  1283. if (props.closeable) {
  1284. return createVNode(Icon, {
  1285. "role": "button",
  1286. "tabindex": 0,
  1287. "name": props.closeIcon,
  1288. "class": [bem$1i("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
  1289. "classPrefix": props.iconPrefix,
  1290. "onClick": onClickCloseIcon
  1291. }, null);
  1292. }
  1293. };
  1294. const onOpened = () => emit("opened");
  1295. const onClosed = () => emit("closed");
  1296. const onKeydown = (event) => emit("keydown", event);
  1297. const renderPopup = lazyRender(() => {
  1298. var _a;
  1299. const {
  1300. round,
  1301. position,
  1302. safeAreaInsetTop,
  1303. safeAreaInsetBottom
  1304. } = props;
  1305. return withDirectives(createVNode("div", mergeProps({
  1306. "ref": popupRef,
  1307. "style": style.value,
  1308. "role": "dialog",
  1309. "tabindex": 0,
  1310. "class": [bem$1i({
  1311. round,
  1312. [position]: position
  1313. }), {
  1314. "van-safe-area-top": safeAreaInsetTop,
  1315. "van-safe-area-bottom": safeAreaInsetBottom
  1316. }],
  1317. "onKeydown": onKeydown
  1318. }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[vShow, props.show]]);
  1319. });
  1320. const renderTransition = () => {
  1321. const {
  1322. position,
  1323. transition,
  1324. transitionAppear
  1325. } = props;
  1326. const name2 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
  1327. return createVNode(Transition, {
  1328. "name": transition || name2,
  1329. "appear": transitionAppear,
  1330. "onAfterEnter": onOpened,
  1331. "onAfterLeave": onClosed
  1332. }, {
  1333. default: renderPopup
  1334. });
  1335. };
  1336. watch(() => props.show, (show) => {
  1337. if (show && !opened) {
  1338. open();
  1339. if (attrs.tabindex === 0) {
  1340. nextTick(() => {
  1341. var _a;
  1342. (_a = popupRef.value) == null ? void 0 : _a.focus();
  1343. });
  1344. }
  1345. }
  1346. if (!show && opened) {
  1347. opened = false;
  1348. emit("close");
  1349. }
  1350. });
  1351. useExpose({
  1352. popupRef
  1353. });
  1354. useLockScroll(popupRef, () => props.show && props.lockScroll);
  1355. useEventListener("popstate", () => {
  1356. if (props.closeOnPopstate) {
  1357. close();
  1358. shouldReopen = false;
  1359. }
  1360. });
  1361. onMounted(() => {
  1362. if (props.show) {
  1363. open();
  1364. }
  1365. });
  1366. onActivated(() => {
  1367. if (shouldReopen) {
  1368. emit("update:show", true);
  1369. shouldReopen = false;
  1370. }
  1371. });
  1372. onDeactivated(() => {
  1373. if (props.show && props.teleport) {
  1374. close();
  1375. shouldReopen = true;
  1376. }
  1377. });
  1378. provide(POPUP_TOGGLE_KEY, () => props.show);
  1379. return () => {
  1380. if (props.teleport) {
  1381. return createVNode(Teleport, {
  1382. "to": props.teleport
  1383. }, {
  1384. default: () => [renderOverlay(), renderTransition()]
  1385. });
  1386. }
  1387. return createVNode(Fragment, null, [renderOverlay(), renderTransition()]);
  1388. };
  1389. }
  1390. });
  1391. const Popup = withInstall(stdin_default$1t);
  1392. const [name$1l, bem$1h] = createNamespace("action-sheet");
  1393. const actionSheetProps = extend({}, popupSharedProps, {
  1394. title: String,
  1395. round: truthProp,
  1396. actions: makeArrayProp(),
  1397. closeIcon: makeStringProp("cross"),
  1398. closeable: truthProp,
  1399. cancelText: String,
  1400. description: String,
  1401. closeOnPopstate: truthProp,
  1402. closeOnClickAction: Boolean,
  1403. safeAreaInsetBottom: truthProp
  1404. });
  1405. const popupInheritKeys$2 = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  1406. var stdin_default$1s = defineComponent({
  1407. name: name$1l,
  1408. props: actionSheetProps,
  1409. emits: ["select", "cancel", "update:show"],
  1410. setup(props, {
  1411. slots,
  1412. emit
  1413. }) {
  1414. const updateShow = (show) => emit("update:show", show);
  1415. const onCancel = () => {
  1416. updateShow(false);
  1417. emit("cancel");
  1418. };
  1419. const renderHeader = () => {
  1420. if (props.title) {
  1421. return createVNode("div", {
  1422. "class": bem$1h("header")
  1423. }, [props.title, props.closeable && createVNode(Icon, {
  1424. "name": props.closeIcon,
  1425. "class": [bem$1h("close"), HAPTICS_FEEDBACK],
  1426. "onClick": onCancel
  1427. }, null)]);
  1428. }
  1429. };
  1430. const renderCancel = () => {
  1431. if (slots.cancel || props.cancelText) {
  1432. return [createVNode("div", {
  1433. "class": bem$1h("gap")
  1434. }, null), createVNode("button", {
  1435. "type": "button",
  1436. "class": bem$1h("cancel"),
  1437. "onClick": onCancel
  1438. }, [slots.cancel ? slots.cancel() : props.cancelText])];
  1439. }
  1440. };
  1441. const renderActionContent = (action, index) => {
  1442. if (action.loading) {
  1443. return createVNode(Loading, {
  1444. "class": bem$1h("loading-icon")
  1445. }, null);
  1446. }
  1447. if (slots.action) {
  1448. return slots.action({
  1449. action,
  1450. index
  1451. });
  1452. }
  1453. return [createVNode("span", {
  1454. "class": bem$1h("name")
  1455. }, [action.name]), action.subname && createVNode("div", {
  1456. "class": bem$1h("subname")
  1457. }, [action.subname])];
  1458. };
  1459. const renderAction = (action, index) => {
  1460. const {
  1461. color,
  1462. loading,
  1463. callback,
  1464. disabled,
  1465. className
  1466. } = action;
  1467. const onClick = () => {
  1468. if (disabled || loading) {
  1469. return;
  1470. }
  1471. if (callback) {
  1472. callback(action);
  1473. }
  1474. if (props.closeOnClickAction) {
  1475. updateShow(false);
  1476. }
  1477. nextTick(() => emit("select", action, index));
  1478. };
  1479. return createVNode("button", {
  1480. "type": "button",
  1481. "style": {
  1482. color
  1483. },
  1484. "class": [bem$1h("item", {
  1485. loading,
  1486. disabled
  1487. }), className],
  1488. "onClick": onClick
  1489. }, [renderActionContent(action, index)]);
  1490. };
  1491. const renderDescription = () => {
  1492. if (props.description || slots.description) {
  1493. const content = slots.description ? slots.description() : props.description;
  1494. return createVNode("div", {
  1495. "class": bem$1h("description")
  1496. }, [content]);
  1497. }
  1498. };
  1499. return () => createVNode(Popup, mergeProps({
  1500. "class": bem$1h(),
  1501. "position": "bottom",
  1502. "onUpdate:show": updateShow
  1503. }, pick(props, popupInheritKeys$2)), {
  1504. default: () => {
  1505. var _a;
  1506. return [renderHeader(), renderDescription(), createVNode("div", {
  1507. "class": bem$1h("content")
  1508. }, [props.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
  1509. }
  1510. });
  1511. }
  1512. });
  1513. const ActionSheet = withInstall(stdin_default$1s);
  1514. function deepClone(obj) {
  1515. if (!isDef(obj)) {
  1516. return obj;
  1517. }
  1518. if (Array.isArray(obj)) {
  1519. return obj.map((item) => deepClone(item));
  1520. }
  1521. if (isObject(obj)) {
  1522. const to = {};
  1523. Object.keys(obj).forEach((key) => {
  1524. to[key] = deepClone(obj[key]);
  1525. });
  1526. return to;
  1527. }
  1528. return obj;
  1529. }
  1530. const DEFAULT_DURATION = 200;
  1531. const MOMENTUM_LIMIT_TIME = 300;
  1532. const MOMENTUM_LIMIT_DISTANCE = 15;
  1533. const [name$1k, bem$1g] = createNamespace("picker-column");
  1534. function getElementTranslateY(element) {
  1535. const {
  1536. transform
  1537. } = window.getComputedStyle(element);
  1538. const translateY = transform.slice(7, transform.length - 1).split(", ")[5];
  1539. return Number(translateY);
  1540. }
  1541. const PICKER_KEY = Symbol(name$1k);
  1542. const isOptionDisabled = (option) => isObject(option) && option.disabled;
  1543. var stdin_default$1r = defineComponent({
  1544. name: name$1k,
  1545. props: {
  1546. textKey: makeRequiredProp(String),
  1547. readonly: Boolean,
  1548. allowHtml: Boolean,
  1549. className: unknownProp,
  1550. itemHeight: makeRequiredProp(Number),
  1551. defaultIndex: makeNumberProp(0),
  1552. swipeDuration: makeRequiredProp(numericProp),
  1553. initialOptions: makeArrayProp(),
  1554. visibleItemCount: makeRequiredProp(numericProp)
  1555. },
  1556. emits: ["change"],
  1557. setup(props, {
  1558. emit,
  1559. slots
  1560. }) {
  1561. let moving;
  1562. let startOffset;
  1563. let touchStartTime;
  1564. let momentumOffset;
  1565. let transitionEndTrigger;
  1566. const root = ref();
  1567. const wrapper = ref();
  1568. const state = reactive({
  1569. index: props.defaultIndex,
  1570. offset: 0,
  1571. duration: 0,
  1572. options: deepClone(props.initialOptions)
  1573. });
  1574. const touch = useTouch();
  1575. const count = () => state.options.length;
  1576. const baseOffset = () => props.itemHeight * (+props.visibleItemCount - 1) / 2;
  1577. const adjustIndex = (index) => {
  1578. index = clamp(index, 0, count());
  1579. for (let i = index; i < count(); i++) {
  1580. if (!isOptionDisabled(state.options[i]))
  1581. return i;
  1582. }
  1583. for (let i = index - 1; i >= 0; i--) {
  1584. if (!isOptionDisabled(state.options[i]))
  1585. return i;
  1586. }
  1587. };
  1588. const setIndex = (index, emitChange) => {
  1589. index = adjustIndex(index) || 0;
  1590. const offset = -index * props.itemHeight;
  1591. const trigger = () => {
  1592. if (index !== state.index) {
  1593. state.index = index;
  1594. if (emitChange) {
  1595. emit("change", index);
  1596. }
  1597. }
  1598. };
  1599. if (moving && offset !== state.offset) {
  1600. transitionEndTrigger = trigger;
  1601. } else {
  1602. trigger();
  1603. }
  1604. state.offset = offset;
  1605. };
  1606. const setOptions = (options) => {
  1607. if (JSON.stringify(options) !== JSON.stringify(state.options)) {
  1608. state.options = deepClone(options);
  1609. setIndex(props.defaultIndex);
  1610. }
  1611. };
  1612. const onClickItem = (index) => {
  1613. if (moving || props.readonly) {
  1614. return;
  1615. }
  1616. transitionEndTrigger = null;
  1617. state.duration = DEFAULT_DURATION;
  1618. setIndex(index, true);
  1619. };
  1620. const getOptionText = (option) => {
  1621. if (isObject(option) && props.textKey in option) {
  1622. return option[props.textKey];
  1623. }
  1624. return option;
  1625. };
  1626. const getIndexByOffset = (offset) => clamp(Math.round(-offset / props.itemHeight), 0, count() - 1);
  1627. const momentum = (distance, duration) => {
  1628. const speed = Math.abs(distance / duration);
  1629. distance = state.offset + speed / 3e-3 * (distance < 0 ? -1 : 1);
  1630. const index = getIndexByOffset(distance);
  1631. state.duration = +props.swipeDuration;
  1632. setIndex(index, true);
  1633. };
  1634. const stopMomentum = () => {
  1635. moving = false;
  1636. state.duration = 0;
  1637. if (transitionEndTrigger) {
  1638. transitionEndTrigger();
  1639. transitionEndTrigger = null;
  1640. }
  1641. };
  1642. const onTouchStart = (event) => {
  1643. if (props.readonly) {
  1644. return;
  1645. }
  1646. touch.start(event);
  1647. if (moving) {
  1648. const translateY = getElementTranslateY(wrapper.value);
  1649. state.offset = Math.min(0, translateY - baseOffset());
  1650. startOffset = state.offset;
  1651. } else {
  1652. startOffset = state.offset;
  1653. }
  1654. state.duration = 0;
  1655. touchStartTime = Date.now();
  1656. momentumOffset = startOffset;
  1657. transitionEndTrigger = null;
  1658. };
  1659. const onTouchMove = (event) => {
  1660. if (props.readonly) {
  1661. return;
  1662. }
  1663. touch.move(event);
  1664. if (touch.isVertical()) {
  1665. moving = true;
  1666. preventDefault(event, true);
  1667. }
  1668. state.offset = clamp(startOffset + touch.deltaY.value, -(count() * props.itemHeight), props.itemHeight);
  1669. const now = Date.now();
  1670. if (now - touchStartTime > MOMENTUM_LIMIT_TIME) {
  1671. touchStartTime = now;
  1672. momentumOffset = state.offset;
  1673. }
  1674. };
  1675. const onTouchEnd = () => {
  1676. if (props.readonly) {
  1677. return;
  1678. }
  1679. const distance = state.offset - momentumOffset;
  1680. const duration = Date.now() - touchStartTime;
  1681. const allowMomentum = duration < MOMENTUM_LIMIT_TIME && Math.abs(distance) > MOMENTUM_LIMIT_DISTANCE;
  1682. if (allowMomentum) {
  1683. momentum(distance, duration);
  1684. return;
  1685. }
  1686. const index = getIndexByOffset(state.offset);
  1687. state.duration = DEFAULT_DURATION;
  1688. setIndex(index, true);
  1689. setTimeout(() => {
  1690. moving = false;
  1691. }, 0);
  1692. };
  1693. const renderOptions = () => {
  1694. const optionStyle = {
  1695. height: `${props.itemHeight}px`
  1696. };
  1697. return state.options.map((option, index) => {
  1698. const text = getOptionText(option);
  1699. const disabled = isOptionDisabled(option);
  1700. const data = {
  1701. role: "button",
  1702. style: optionStyle,
  1703. tabindex: disabled ? -1 : 0,
  1704. class: bem$1g("item", {
  1705. disabled,
  1706. selected: index === state.index
  1707. }),
  1708. onClick: () => onClickItem(index)
  1709. };
  1710. const childData = {
  1711. class: "van-ellipsis",
  1712. [props.allowHtml ? "innerHTML" : "textContent"]: text
  1713. };
  1714. return createVNode("li", data, [slots.option ? slots.option(option) : createVNode("div", childData, null)]);
  1715. });
  1716. };
  1717. const setValue = (value) => {
  1718. const {
  1719. options
  1720. } = state;
  1721. for (let i = 0; i < options.length; i++) {
  1722. if (getOptionText(options[i]) === value) {
  1723. return setIndex(i);
  1724. }
  1725. }
  1726. };
  1727. const getValue = () => state.options[state.index];
  1728. const hasOptions = () => state.options.length;
  1729. setIndex(state.index);
  1730. useParent(PICKER_KEY);
  1731. useExpose({
  1732. state,
  1733. setIndex,
  1734. getValue,
  1735. setValue,
  1736. setOptions,
  1737. hasOptions,
  1738. stopMomentum
  1739. });
  1740. watch(() => props.initialOptions, setOptions);
  1741. watch(() => props.defaultIndex, (value) => setIndex(value));
  1742. useEventListener("touchmove", onTouchMove, {
  1743. target: root
  1744. });
  1745. return () => createVNode("div", {
  1746. "ref": root,
  1747. "class": [bem$1g(), props.className],
  1748. "onTouchstartPassive": onTouchStart,
  1749. "onTouchend": onTouchEnd,
  1750. "onTouchcancel": onTouchEnd
  1751. }, [createVNode("ul", {
  1752. "ref": wrapper,
  1753. "style": {
  1754. transform: `translate3d(0, ${state.offset + baseOffset()}px, 0)`,
  1755. transitionDuration: `${state.duration}ms`,
  1756. transitionProperty: state.duration ? "all" : "none"
  1757. },
  1758. "class": bem$1g("wrapper"),
  1759. "onTransitionend": stopMomentum
  1760. }, [renderOptions()])]);
  1761. }
  1762. });
  1763. const [name$1j, bem$1f, t$j] = createNamespace("picker");
  1764. const pickerSharedProps = {
  1765. title: String,
  1766. loading: Boolean,
  1767. readonly: Boolean,
  1768. allowHtml: Boolean,
  1769. itemHeight: makeNumericProp(44),
  1770. showToolbar: truthProp,
  1771. swipeDuration: makeNumericProp(1e3),
  1772. visibleItemCount: makeNumericProp(6),
  1773. cancelButtonText: String,
  1774. confirmButtonText: String
  1775. };
  1776. const pickerProps = extend({}, pickerSharedProps, {
  1777. columns: makeArrayProp(),
  1778. valueKey: String,
  1779. defaultIndex: makeNumericProp(0),
  1780. toolbarPosition: makeStringProp("top"),
  1781. columnsFieldNames: Object
  1782. });
  1783. var stdin_default$1q = defineComponent({
  1784. name: name$1j,
  1785. props: pickerProps,
  1786. emits: ["confirm", "cancel", "change"],
  1787. setup(props, {
  1788. emit,
  1789. slots
  1790. }) {
  1791. if (process.env.NODE_ENV !== "production") {
  1792. if (slots.default) {
  1793. console.warn('[Vant] Picker: "default" slot is deprecated, please use "toolbar" slot instead.');
  1794. }
  1795. if (props.valueKey) {
  1796. console.warn('[Vant] Picker: "valueKey" prop is deprecated, please use "columnsFieldNames" prop instead.');
  1797. }
  1798. }
  1799. const hasOptions = ref(false);
  1800. const columnsRef = ref();
  1801. const formattedColumns = ref([]);
  1802. const columnsFieldNames = computed(() => {
  1803. const {
  1804. columnsFieldNames: columnsFieldNames2
  1805. } = props;
  1806. return {
  1807. text: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.text) || props.valueKey || "text",
  1808. values: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.values) || "values",
  1809. children: (columnsFieldNames2 == null ? void 0 : columnsFieldNames2.children) || "children"
  1810. };
  1811. });
  1812. const {
  1813. children,
  1814. linkChildren
  1815. } = useChildren(PICKER_KEY);
  1816. linkChildren();
  1817. const itemHeight = computed(() => unitToPx(props.itemHeight));
  1818. const dataType = computed(() => {
  1819. const firstColumn = props.columns[0];
  1820. if (typeof firstColumn === "object") {
  1821. if (columnsFieldNames.value.children in firstColumn) {
  1822. return "cascade";
  1823. }
  1824. if (columnsFieldNames.value.values in firstColumn) {
  1825. return "object";
  1826. }
  1827. }
  1828. return "plain";
  1829. });
  1830. const formatCascade = () => {
  1831. var _a;
  1832. const formatted = [];
  1833. let cursor = {
  1834. [columnsFieldNames.value.children]: props.columns
  1835. };
  1836. while (cursor && cursor[columnsFieldNames.value.children]) {
  1837. const children2 = cursor[columnsFieldNames.value.children];
  1838. let defaultIndex = (_a = cursor.defaultIndex) != null ? _a : +props.defaultIndex;
  1839. while (children2[defaultIndex] && children2[defaultIndex].disabled) {
  1840. if (defaultIndex < children2.length - 1) {
  1841. defaultIndex++;
  1842. } else {
  1843. defaultIndex = 0;
  1844. break;
  1845. }
  1846. }
  1847. formatted.push({
  1848. [columnsFieldNames.value.values]: cursor[columnsFieldNames.value.children],
  1849. className: cursor.className,
  1850. defaultIndex
  1851. });
  1852. cursor = children2[defaultIndex];
  1853. }
  1854. formattedColumns.value = formatted;
  1855. };
  1856. const format2 = () => {
  1857. const {
  1858. columns
  1859. } = props;
  1860. if (dataType.value === "plain") {
  1861. formattedColumns.value = [{
  1862. [columnsFieldNames.value.values]: columns
  1863. }];
  1864. } else if (dataType.value === "cascade") {
  1865. formatCascade();
  1866. } else {
  1867. formattedColumns.value = columns;
  1868. }
  1869. hasOptions.value = formattedColumns.value.some((item) => item[columnsFieldNames.value.values] && item[columnsFieldNames.value.values].length !== 0) || children.some((item) => item.hasOptions);
  1870. };
  1871. const getIndexes = () => children.map((child) => child.state.index);
  1872. const setColumnValues = (index, options) => {
  1873. const column = children[index];
  1874. if (column) {
  1875. column.setOptions(options);
  1876. hasOptions.value = true;
  1877. }
  1878. };
  1879. const onCascadeChange = (columnIndex) => {
  1880. let cursor = {
  1881. [columnsFieldNames.value.children]: props.columns
  1882. };
  1883. const indexes = getIndexes();
  1884. for (let i = 0; i <= columnIndex; i++) {
  1885. cursor = cursor[columnsFieldNames.value.children][indexes[i]];
  1886. }
  1887. while (cursor && cursor[columnsFieldNames.value.children]) {
  1888. columnIndex++;
  1889. setColumnValues(columnIndex, cursor[columnsFieldNames.value.children]);
  1890. cursor = cursor[columnsFieldNames.value.children][cursor.defaultIndex || 0];
  1891. }
  1892. };
  1893. const getChild = (index) => children[index];
  1894. const getColumnValue = (index) => {
  1895. const column = getChild(index);
  1896. if (column) {
  1897. return column.getValue();
  1898. }
  1899. };
  1900. const setColumnValue = (index, value) => {
  1901. const column = getChild(index);
  1902. if (column) {
  1903. column.setValue(value);
  1904. if (dataType.value === "cascade") {
  1905. onCascadeChange(index);
  1906. }
  1907. }
  1908. };
  1909. const getColumnIndex = (index) => {
  1910. const column = getChild(index);
  1911. if (column) {
  1912. return column.state.index;
  1913. }
  1914. };
  1915. const setColumnIndex = (columnIndex, optionIndex) => {
  1916. const column = getChild(columnIndex);
  1917. if (column) {
  1918. column.setIndex(optionIndex);
  1919. if (dataType.value === "cascade") {
  1920. onCascadeChange(columnIndex);
  1921. }
  1922. }
  1923. };
  1924. const getColumnValues = (index) => {
  1925. const column = getChild(index);
  1926. if (column) {
  1927. return column.state.options;
  1928. }
  1929. };
  1930. const getValues = () => children.map((child) => child.getValue());
  1931. const setValues = (values) => {
  1932. values.forEach((value, index) => {
  1933. setColumnValue(index, value);
  1934. });
  1935. };
  1936. const setIndexes = (indexes) => {
  1937. indexes.forEach((optionIndex, columnIndex) => {
  1938. setColumnIndex(columnIndex, optionIndex);
  1939. });
  1940. };
  1941. const emitAction = (event) => {
  1942. if (dataType.value === "plain") {
  1943. emit(event, getColumnValue(0), getColumnIndex(0));
  1944. } else {
  1945. emit(event, getValues(), getIndexes());
  1946. }
  1947. };
  1948. const onChange = (columnIndex) => {
  1949. if (dataType.value === "cascade") {
  1950. onCascadeChange(columnIndex);
  1951. }
  1952. if (dataType.value === "plain") {
  1953. emit("change", getColumnValue(0), getColumnIndex(0));
  1954. } else {
  1955. emit("change", getValues(), columnIndex);
  1956. }
  1957. };
  1958. const confirm = () => {
  1959. children.forEach((child) => child.stopMomentum());
  1960. emitAction("confirm");
  1961. };
  1962. const cancel = () => emitAction("cancel");
  1963. const renderTitle = () => {
  1964. if (slots.title) {
  1965. return slots.title();
  1966. }
  1967. if (props.title) {
  1968. return createVNode("div", {
  1969. "class": [bem$1f("title"), "van-ellipsis"]
  1970. }, [props.title]);
  1971. }
  1972. };
  1973. const renderCancel = () => {
  1974. const text = props.cancelButtonText || t$j("cancel");
  1975. return createVNode("button", {
  1976. "type": "button",
  1977. "class": [bem$1f("cancel"), HAPTICS_FEEDBACK],
  1978. "onClick": cancel
  1979. }, [slots.cancel ? slots.cancel() : text]);
  1980. };
  1981. const renderConfirm = () => {
  1982. const text = props.confirmButtonText || t$j("confirm");
  1983. return createVNode("button", {
  1984. "type": "button",
  1985. "class": [bem$1f("confirm"), HAPTICS_FEEDBACK],
  1986. "onClick": confirm
  1987. }, [slots.confirm ? slots.confirm() : text]);
  1988. };
  1989. const renderToolbar = () => {
  1990. if (props.showToolbar) {
  1991. const slot = slots.toolbar || slots.default;
  1992. return createVNode("div", {
  1993. "class": bem$1f("toolbar")
  1994. }, [slot ? slot() : [renderCancel(), renderTitle(), renderConfirm()]]);
  1995. }
  1996. };
  1997. const renderColumnItems = () => formattedColumns.value.map((item, columnIndex) => {
  1998. var _a;
  1999. return createVNode(stdin_default$1r, {
  2000. "textKey": columnsFieldNames.value.text,
  2001. "readonly": props.readonly,
  2002. "allowHtml": props.allowHtml,
  2003. "className": item.className,
  2004. "itemHeight": itemHeight.value,
  2005. "defaultIndex": (_a = item.defaultIndex) != null ? _a : +props.defaultIndex,
  2006. "swipeDuration": props.swipeDuration,
  2007. "initialOptions": item[columnsFieldNames.value.values],
  2008. "visibleItemCount": props.visibleItemCount,
  2009. "onChange": () => onChange(columnIndex)
  2010. }, {
  2011. option: slots.option
  2012. });
  2013. });
  2014. const renderMask = (wrapHeight) => {
  2015. if (hasOptions.value) {
  2016. const frameStyle = {
  2017. height: `${itemHeight.value}px`
  2018. };
  2019. const maskStyle = {
  2020. backgroundSize: `100% ${(wrapHeight - itemHeight.value) / 2}px`
  2021. };
  2022. return [createVNode("div", {
  2023. "class": bem$1f("mask"),
  2024. "style": maskStyle
  2025. }, null), createVNode("div", {
  2026. "class": [BORDER_UNSET_TOP_BOTTOM, bem$1f("frame")],
  2027. "style": frameStyle
  2028. }, null)];
  2029. }
  2030. };
  2031. const renderColumns = () => {
  2032. const wrapHeight = itemHeight.value * +props.visibleItemCount;
  2033. const columnsStyle = {
  2034. height: `${wrapHeight}px`
  2035. };
  2036. return createVNode("div", {
  2037. "ref": columnsRef,
  2038. "class": bem$1f("columns"),
  2039. "style": columnsStyle
  2040. }, [renderColumnItems(), renderMask(wrapHeight)]);
  2041. };
  2042. watch(() => props.columns, format2, {
  2043. immediate: true
  2044. });
  2045. useEventListener("touchmove", preventDefault, {
  2046. target: columnsRef
  2047. });
  2048. useExpose({
  2049. confirm,
  2050. getValues,
  2051. setValues,
  2052. getIndexes,
  2053. setIndexes,
  2054. getColumnIndex,
  2055. setColumnIndex,
  2056. getColumnValue,
  2057. setColumnValue,
  2058. getColumnValues,
  2059. setColumnValues
  2060. });
  2061. return () => {
  2062. var _a, _b;
  2063. return createVNode("div", {
  2064. "class": bem$1f()
  2065. }, [props.toolbarPosition === "top" ? renderToolbar() : null, props.loading ? createVNode(Loading, {
  2066. "class": bem$1f("loading")
  2067. }, null) : null, (_a = slots["columns-top"]) == null ? void 0 : _a.call(slots), renderColumns(), (_b = slots["columns-bottom"]) == null ? void 0 : _b.call(slots), props.toolbarPosition === "bottom" ? renderToolbar() : null]);
  2068. };
  2069. }
  2070. });
  2071. const Picker = withInstall(stdin_default$1q);
  2072. const [name$1i, bem$1e] = createNamespace("area");
  2073. const EMPTY_CODE = "000000";
  2074. const INHERIT_SLOTS = ["title", "cancel", "confirm", "toolbar", "columns-top", "columns-bottom"];
  2075. const INHERIT_PROPS = ["title", "loading", "readonly", "itemHeight", "swipeDuration", "visibleItemCount", "cancelButtonText", "confirmButtonText"];
  2076. const isOverseaCode = (code) => code[0] === "9";
  2077. const areaProps = extend({}, pickerSharedProps, {
  2078. value: String,
  2079. columnsNum: makeNumericProp(3),
  2080. columnsPlaceholder: makeArrayProp(),
  2081. areaList: {
  2082. type: Object,
  2083. default: () => ({})
  2084. },
  2085. isOverseaCode: {
  2086. type: Function,
  2087. default: isOverseaCode
  2088. }
  2089. });
  2090. var stdin_default$1p = defineComponent({
  2091. name: name$1i,
  2092. props: areaProps,
  2093. emits: ["change", "confirm", "cancel"],
  2094. setup(props, {
  2095. emit,
  2096. slots
  2097. }) {
  2098. const pickerRef = ref();
  2099. const state = reactive({
  2100. code: props.value,
  2101. columns: [{
  2102. values: []
  2103. }, {
  2104. values: []
  2105. }, {
  2106. values: []
  2107. }]
  2108. });
  2109. const areaList = computed(() => {
  2110. const {
  2111. areaList: areaList2
  2112. } = props;
  2113. return {
  2114. province: areaList2.province_list || {},
  2115. city: areaList2.city_list || {},
  2116. county: areaList2.county_list || {}
  2117. };
  2118. });
  2119. const placeholderMap = computed(() => {
  2120. const {
  2121. columnsPlaceholder
  2122. } = props;
  2123. return {
  2124. province: columnsPlaceholder[0] || "",
  2125. city: columnsPlaceholder[1] || "",
  2126. county: columnsPlaceholder[2] || ""
  2127. };
  2128. });
  2129. const getDefaultCode = () => {
  2130. if (props.columnsPlaceholder.length) {
  2131. return EMPTY_CODE;
  2132. }
  2133. const {
  2134. county,
  2135. city
  2136. } = areaList.value;
  2137. const countyCodes = Object.keys(county);
  2138. if (countyCodes[0]) {
  2139. return countyCodes[0];
  2140. }
  2141. const cityCodes = Object.keys(city);
  2142. if (cityCodes[0]) {
  2143. return cityCodes[0];
  2144. }
  2145. return "";
  2146. };
  2147. const getColumnValues = (type, code) => {
  2148. let column = [];
  2149. if (type !== "province" && !code) {
  2150. return column;
  2151. }
  2152. const list = areaList.value[type];
  2153. column = Object.keys(list).map((listCode) => ({
  2154. code: listCode,
  2155. name: list[listCode]
  2156. }));
  2157. if (code) {
  2158. if (type === "city" && props.isOverseaCode(code)) {
  2159. code = "9";
  2160. }
  2161. column = column.filter((item) => item.code.indexOf(code) === 0);
  2162. }
  2163. if (placeholderMap.value[type] && column.length) {
  2164. let codeFill = "";
  2165. if (type === "city") {
  2166. codeFill = EMPTY_CODE.slice(2, 4);
  2167. } else if (type === "county") {
  2168. codeFill = EMPTY_CODE.slice(4, 6);
  2169. }
  2170. column.unshift({
  2171. code: code + codeFill,
  2172. name: placeholderMap.value[type]
  2173. });
  2174. }
  2175. return column;
  2176. };
  2177. const getIndex = (type, code) => {
  2178. let compareNum = code.length;
  2179. if (type === "province") {
  2180. compareNum = props.isOverseaCode(code) ? 1 : 2;
  2181. }
  2182. if (type === "city") {
  2183. compareNum = 4;
  2184. }
  2185. code = code.slice(0, compareNum);
  2186. const list = getColumnValues(type, compareNum > 2 ? code.slice(0, compareNum - 2) : "");
  2187. for (let i = 0; i < list.length; i++) {
  2188. if (list[i].code.slice(0, compareNum) === code) {
  2189. return i;
  2190. }
  2191. }
  2192. return 0;
  2193. };
  2194. const setValues = () => {
  2195. const picker = pickerRef.value;
  2196. if (!picker) {
  2197. return;
  2198. }
  2199. let code = state.code || getDefaultCode();
  2200. const province = getColumnValues("province");
  2201. const city = getColumnValues("city", code.slice(0, 2));
  2202. picker.setColumnValues(0, province);
  2203. picker.setColumnValues(1, city);
  2204. if (city.length && code.slice(2, 4) === "00" && !props.isOverseaCode(code)) {
  2205. [{
  2206. code
  2207. }] = city;
  2208. }
  2209. picker.setColumnValues(2, getColumnValues("county", code.slice(0, 4)));
  2210. picker.setIndexes([getIndex("province", code), getIndex("city", code), getIndex("county", code)]);
  2211. };
  2212. const parseValues = (values) => values.map((value, index) => {
  2213. if (value) {
  2214. value = deepClone(value);
  2215. if (!value.code || value.name === props.columnsPlaceholder[index]) {
  2216. value.code = "";
  2217. value.name = "";
  2218. }
  2219. }
  2220. return value;
  2221. });
  2222. const getValues = () => {
  2223. if (pickerRef.value) {
  2224. const values = pickerRef.value.getValues().filter(Boolean);
  2225. return parseValues(values);
  2226. }
  2227. return [];
  2228. };
  2229. const getArea = () => {
  2230. const values = getValues();
  2231. const area = {
  2232. code: "",
  2233. country: "",
  2234. province: "",
  2235. city: "",
  2236. county: ""
  2237. };
  2238. if (!values.length) {
  2239. return area;
  2240. }
  2241. const names = values.map((item) => item.name);
  2242. const validValues = values.filter((value) => value.code);
  2243. area.code = validValues.length ? validValues[validValues.length - 1].code : "";
  2244. if (props.isOverseaCode(area.code)) {
  2245. area.country = names[1] || "";
  2246. area.province = names[2] || "";
  2247. } else {
  2248. area.province = names[0] || "";
  2249. area.city = names[1] || "";
  2250. area.county = names[2] || "";
  2251. }
  2252. return area;
  2253. };
  2254. const reset = (newCode = "") => {
  2255. state.code = newCode;
  2256. setValues();
  2257. };
  2258. const onChange = (values, index) => {
  2259. state.code = values[index].code;
  2260. setValues();
  2261. if (pickerRef.value) {
  2262. const parsedValues = parseValues(pickerRef.value.getValues());
  2263. emit("change", parsedValues, index);
  2264. }
  2265. };
  2266. const onConfirm = (values, index) => {
  2267. setValues();
  2268. emit("confirm", parseValues(values), index);
  2269. };
  2270. const onCancel = (...args) => emit("cancel", ...args);
  2271. onMounted(setValues);
  2272. watch(() => props.value, (value) => {
  2273. state.code = value;
  2274. setValues();
  2275. });
  2276. watch(() => props.areaList, setValues, {
  2277. deep: true
  2278. });
  2279. watch(() => props.columnsNum, () => {
  2280. nextTick(setValues);
  2281. });
  2282. useExpose({
  2283. reset,
  2284. getArea,
  2285. getValues
  2286. });
  2287. return () => {
  2288. const columns = state.columns.slice(0, +props.columnsNum);
  2289. return createVNode(Picker, mergeProps({
  2290. "ref": pickerRef,
  2291. "class": bem$1e(),
  2292. "columns": columns,
  2293. "columnsFieldNames": {
  2294. text: "name"
  2295. },
  2296. "onChange": onChange,
  2297. "onCancel": onCancel,
  2298. "onConfirm": onConfirm
  2299. }, pick(props, INHERIT_PROPS)), pick(slots, INHERIT_SLOTS));
  2300. };
  2301. }
  2302. });
  2303. const Area = withInstall(stdin_default$1p);
  2304. const [name$1h, bem$1d] = createNamespace("cell");
  2305. const cellSharedProps = {
  2306. icon: String,
  2307. size: String,
  2308. title: numericProp,
  2309. value: numericProp,
  2310. label: numericProp,
  2311. center: Boolean,
  2312. isLink: Boolean,
  2313. border: truthProp,
  2314. required: Boolean,
  2315. iconPrefix: String,
  2316. valueClass: unknownProp,
  2317. labelClass: unknownProp,
  2318. titleClass: unknownProp,
  2319. titleStyle: null,
  2320. arrowDirection: String,
  2321. clickable: {
  2322. type: Boolean,
  2323. default: null
  2324. }
  2325. };
  2326. const cellProps = extend({}, cellSharedProps, routeProps);
  2327. var stdin_default$1o = defineComponent({
  2328. name: name$1h,
  2329. props: cellProps,
  2330. setup(props, {
  2331. slots
  2332. }) {
  2333. const route2 = useRoute();
  2334. const renderLabel = () => {
  2335. const showLabel = slots.label || isDef(props.label);
  2336. if (showLabel) {
  2337. return createVNode("div", {
  2338. "class": [bem$1d("label"), props.labelClass]
  2339. }, [slots.label ? slots.label() : props.label]);
  2340. }
  2341. };
  2342. const renderTitle = () => {
  2343. if (slots.title || isDef(props.title)) {
  2344. return createVNode("div", {
  2345. "class": [bem$1d("title"), props.titleClass],
  2346. "style": props.titleStyle
  2347. }, [slots.title ? slots.title() : createVNode("span", null, [props.title]), renderLabel()]);
  2348. }
  2349. };
  2350. const renderValue = () => {
  2351. const slot = slots.value || slots.default;
  2352. const hasValue = slot || isDef(props.value);
  2353. if (hasValue) {
  2354. const hasTitle = slots.title || isDef(props.title);
  2355. return createVNode("div", {
  2356. "class": [bem$1d("value", {
  2357. alone: !hasTitle
  2358. }), props.valueClass]
  2359. }, [slot ? slot() : createVNode("span", null, [props.value])]);
  2360. }
  2361. };
  2362. const renderLeftIcon = () => {
  2363. if (slots.icon) {
  2364. return slots.icon();
  2365. }
  2366. if (props.icon) {
  2367. return createVNode(Icon, {
  2368. "name": props.icon,
  2369. "class": bem$1d("left-icon"),
  2370. "classPrefix": props.iconPrefix
  2371. }, null);
  2372. }
  2373. };
  2374. const renderRightIcon = () => {
  2375. if (slots["right-icon"]) {
  2376. return slots["right-icon"]();
  2377. }
  2378. if (props.isLink) {
  2379. const name2 = props.arrowDirection ? `arrow-${props.arrowDirection}` : "arrow";
  2380. return createVNode(Icon, {
  2381. "name": name2,
  2382. "class": bem$1d("right-icon")
  2383. }, null);
  2384. }
  2385. };
  2386. return () => {
  2387. var _a, _b;
  2388. const {
  2389. size,
  2390. center,
  2391. border,
  2392. isLink,
  2393. required
  2394. } = props;
  2395. const clickable = (_a = props.clickable) != null ? _a : isLink;
  2396. const classes = {
  2397. center,
  2398. required,
  2399. clickable,
  2400. borderless: !border
  2401. };
  2402. if (size) {
  2403. classes[size] = !!size;
  2404. }
  2405. return createVNode("div", {
  2406. "class": bem$1d(classes),
  2407. "role": clickable ? "button" : void 0,
  2408. "tabindex": clickable ? 0 : void 0,
  2409. "onClick": route2
  2410. }, [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_b = slots.extra) == null ? void 0 : _b.call(slots)]);
  2411. };
  2412. }
  2413. });
  2414. const Cell = withInstall(stdin_default$1o);
  2415. const [name$1g, bem$1c] = createNamespace("form");
  2416. const formProps = {
  2417. colon: Boolean,
  2418. disabled: Boolean,
  2419. readonly: Boolean,
  2420. showError: Boolean,
  2421. labelWidth: numericProp,
  2422. labelAlign: String,
  2423. inputAlign: String,
  2424. scrollToError: Boolean,
  2425. validateFirst: Boolean,
  2426. submitOnEnter: truthProp,
  2427. showErrorMessage: truthProp,
  2428. errorMessageAlign: String,
  2429. validateTrigger: {
  2430. type: [String, Array],
  2431. default: "onBlur"
  2432. }
  2433. };
  2434. var stdin_default$1n = defineComponent({
  2435. name: name$1g,
  2436. props: formProps,
  2437. emits: ["submit", "failed"],
  2438. setup(props, {
  2439. emit,
  2440. slots
  2441. }) {
  2442. const {
  2443. children,
  2444. linkChildren
  2445. } = useChildren(FORM_KEY);
  2446. const getFieldsByNames = (names) => {
  2447. if (names) {
  2448. return children.filter((field) => names.includes(field.name));
  2449. }
  2450. return children;
  2451. };
  2452. const validateSeq = (names) => new Promise((resolve, reject) => {
  2453. const errors = [];
  2454. const fields = getFieldsByNames(names);
  2455. fields.reduce((promise, field) => promise.then(() => {
  2456. if (!errors.length) {
  2457. return field.validate().then((error) => {
  2458. if (error) {
  2459. errors.push(error);
  2460. }
  2461. });
  2462. }
  2463. }), Promise.resolve()).then(() => {
  2464. if (errors.length) {
  2465. reject(errors);
  2466. } else {
  2467. resolve();
  2468. }
  2469. });
  2470. });
  2471. const validateAll = (names) => new Promise((resolve, reject) => {
  2472. const fields = getFieldsByNames(names);
  2473. Promise.all(fields.map((item) => item.validate())).then((errors) => {
  2474. errors = errors.filter(Boolean);
  2475. if (errors.length) {
  2476. reject(errors);
  2477. } else {
  2478. resolve();
  2479. }
  2480. });
  2481. });
  2482. const validateField = (name2) => {
  2483. const matched = children.find((item) => item.name === name2);
  2484. if (matched) {
  2485. return new Promise((resolve, reject) => {
  2486. matched.validate().then((error) => {
  2487. if (error) {
  2488. reject(error);
  2489. } else {
  2490. resolve();
  2491. }
  2492. });
  2493. });
  2494. }
  2495. return Promise.reject();
  2496. };
  2497. const validate = (name2) => {
  2498. if (typeof name2 === "string") {
  2499. return validateField(name2);
  2500. }
  2501. return props.validateFirst ? validateSeq(name2) : validateAll(name2);
  2502. };
  2503. const resetValidation = (name2) => {
  2504. if (typeof name2 === "string") {
  2505. name2 = [name2];
  2506. }
  2507. const fields = getFieldsByNames(name2);
  2508. fields.forEach((item) => {
  2509. item.resetValidation();
  2510. });
  2511. };
  2512. const getValidationStatus = () => children.reduce((form, field) => {
  2513. form[field.name] = field.getValidationStatus();
  2514. return form;
  2515. }, {});
  2516. const scrollToField = (name2, options) => {
  2517. children.some((item) => {
  2518. if (item.name === name2) {
  2519. item.$el.scrollIntoView(options);
  2520. return true;
  2521. }
  2522. return false;
  2523. });
  2524. };
  2525. const getValues = () => children.reduce((form, field) => {
  2526. form[field.name] = field.formValue.value;
  2527. return form;
  2528. }, {});
  2529. const submit = () => {
  2530. const values = getValues();
  2531. validate().then(() => emit("submit", values)).catch((errors) => {
  2532. emit("failed", {
  2533. values,
  2534. errors
  2535. });
  2536. if (props.scrollToError && errors[0].name) {
  2537. scrollToField(errors[0].name);
  2538. }
  2539. });
  2540. };
  2541. const onSubmit = (event) => {
  2542. preventDefault(event);
  2543. submit();
  2544. };
  2545. linkChildren({
  2546. props
  2547. });
  2548. useExpose({
  2549. submit,
  2550. validate,
  2551. getValues,
  2552. scrollToField,
  2553. resetValidation,
  2554. getValidationStatus
  2555. });
  2556. return () => {
  2557. var _a;
  2558. return createVNode("form", {
  2559. "class": bem$1c(),
  2560. "onSubmit": onSubmit
  2561. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  2562. };
  2563. }
  2564. });
  2565. const Form = withInstall(stdin_default$1n);
  2566. function isEmptyValue(value) {
  2567. if (Array.isArray(value)) {
  2568. return !value.length;
  2569. }
  2570. if (value === 0) {
  2571. return false;
  2572. }
  2573. return !value;
  2574. }
  2575. function runSyncRule(value, rule) {
  2576. if (isEmptyValue(value)) {
  2577. if (rule.required) {
  2578. return false;
  2579. }
  2580. if (rule.validateEmpty === false) {
  2581. return true;
  2582. }
  2583. }
  2584. if (rule.pattern && !rule.pattern.test(String(value))) {
  2585. return false;
  2586. }
  2587. return true;
  2588. }
  2589. function runRuleValidator(value, rule) {
  2590. return new Promise((resolve) => {
  2591. const returnVal = rule.validator(value, rule);
  2592. if (isPromise(returnVal)) {
  2593. returnVal.then(resolve);
  2594. return;
  2595. }
  2596. resolve(returnVal);
  2597. });
  2598. }
  2599. function getRuleMessage(value, rule) {
  2600. const { message } = rule;
  2601. if (isFunction(message)) {
  2602. return message(value, rule);
  2603. }
  2604. return message || "";
  2605. }
  2606. function startComposing({ target }) {
  2607. target.composing = true;
  2608. }
  2609. function endComposing({ target }) {
  2610. if (target.composing) {
  2611. target.composing = false;
  2612. target.dispatchEvent(new Event("input"));
  2613. }
  2614. }
  2615. function resizeTextarea(input, autosize) {
  2616. const scrollTop = getRootScrollTop();
  2617. input.style.height = "auto";
  2618. let height = input.scrollHeight;
  2619. if (isObject(autosize)) {
  2620. const { maxHeight, minHeight } = autosize;
  2621. if (maxHeight !== void 0) {
  2622. height = Math.min(height, maxHeight);
  2623. }
  2624. if (minHeight !== void 0) {
  2625. height = Math.max(height, minHeight);
  2626. }
  2627. }
  2628. if (height) {
  2629. input.style.height = `${height}px`;
  2630. setRootScrollTop(scrollTop);
  2631. }
  2632. }
  2633. function mapInputType(type) {
  2634. if (type === "number") {
  2635. return {
  2636. type: "text",
  2637. inputmode: "decimal"
  2638. };
  2639. }
  2640. if (type === "digit") {
  2641. return {
  2642. type: "tel",
  2643. inputmode: "numeric"
  2644. };
  2645. }
  2646. return { type };
  2647. }
  2648. function getStringLength(str) {
  2649. return [...str].length;
  2650. }
  2651. function cutString(str, maxlength) {
  2652. return [...str].slice(0, maxlength).join("");
  2653. }
  2654. let current = 0;
  2655. function useId() {
  2656. const vm = getCurrentInstance();
  2657. const { name: name2 = "unknown" } = (vm == null ? void 0 : vm.type) || {};
  2658. if (process.env.NODE_ENV === "test") {
  2659. return name2;
  2660. }
  2661. return `${name2}-${++current}`;
  2662. }
  2663. const [name$1f, bem$1b] = createNamespace("field");
  2664. const fieldSharedProps = {
  2665. id: String,
  2666. name: String,
  2667. leftIcon: String,
  2668. rightIcon: String,
  2669. autofocus: Boolean,
  2670. clearable: Boolean,
  2671. maxlength: numericProp,
  2672. formatter: Function,
  2673. clearIcon: makeStringProp("clear"),
  2674. modelValue: makeNumericProp(""),
  2675. inputAlign: String,
  2676. placeholder: String,
  2677. autocomplete: String,
  2678. errorMessage: String,
  2679. enterkeyhint: String,
  2680. clearTrigger: makeStringProp("focus"),
  2681. formatTrigger: makeStringProp("onChange"),
  2682. error: {
  2683. type: Boolean,
  2684. default: null
  2685. },
  2686. disabled: {
  2687. type: Boolean,
  2688. default: null
  2689. },
  2690. readonly: {
  2691. type: Boolean,
  2692. default: null
  2693. }
  2694. };
  2695. const fieldProps = extend({}, cellSharedProps, fieldSharedProps, {
  2696. rows: numericProp,
  2697. type: makeStringProp("text"),
  2698. rules: Array,
  2699. autosize: [Boolean, Object],
  2700. labelWidth: numericProp,
  2701. labelClass: unknownProp,
  2702. labelAlign: String,
  2703. showWordLimit: Boolean,
  2704. errorMessageAlign: String,
  2705. colon: {
  2706. type: Boolean,
  2707. default: null
  2708. }
  2709. });
  2710. var stdin_default$1m = defineComponent({
  2711. name: name$1f,
  2712. props: fieldProps,
  2713. emits: ["blur", "focus", "clear", "keypress", "click-input", "end-validate", "start-validate", "click-left-icon", "click-right-icon", "update:modelValue"],
  2714. setup(props, {
  2715. emit,
  2716. slots
  2717. }) {
  2718. const id = useId();
  2719. const state = reactive({
  2720. status: "unvalidated",
  2721. focused: false,
  2722. validateMessage: ""
  2723. });
  2724. const inputRef = ref();
  2725. const clearIconRef = ref();
  2726. const customValue = ref();
  2727. const {
  2728. parent: form
  2729. } = useParent(FORM_KEY);
  2730. const getModelValue = () => {
  2731. var _a;
  2732. return String((_a = props.modelValue) != null ? _a : "");
  2733. };
  2734. const getProp = (key) => {
  2735. if (isDef(props[key])) {
  2736. return props[key];
  2737. }
  2738. if (form && isDef(form.props[key])) {
  2739. return form.props[key];
  2740. }
  2741. };
  2742. const showClear = computed(() => {
  2743. const readonly = getProp("readonly");
  2744. if (props.clearable && !readonly) {
  2745. const hasValue = getModelValue() !== "";
  2746. const trigger = props.clearTrigger === "always" || props.clearTrigger === "focus" && state.focused;
  2747. return hasValue && trigger;
  2748. }
  2749. return false;
  2750. });
  2751. const formValue = computed(() => {
  2752. if (customValue.value && slots.input) {
  2753. return customValue.value();
  2754. }
  2755. return props.modelValue;
  2756. });
  2757. const runRules = (rules) => rules.reduce((promise, rule) => promise.then(() => {
  2758. if (state.status === "failed") {
  2759. return;
  2760. }
  2761. let {
  2762. value
  2763. } = formValue;
  2764. if (rule.formatter) {
  2765. value = rule.formatter(value, rule);
  2766. }
  2767. if (!runSyncRule(value, rule)) {
  2768. state.status = "failed";
  2769. state.validateMessage = getRuleMessage(value, rule);
  2770. return;
  2771. }
  2772. if (rule.validator) {
  2773. if (isEmptyValue(value) && rule.validateEmpty === false) {
  2774. return;
  2775. }
  2776. return runRuleValidator(value, rule).then((result) => {
  2777. if (result && typeof result === "string") {
  2778. state.status = "failed";
  2779. state.validateMessage = result;
  2780. } else if (result === false) {
  2781. state.status = "failed";
  2782. state.validateMessage = getRuleMessage(value, rule);
  2783. }
  2784. });
  2785. }
  2786. }), Promise.resolve());
  2787. const resetValidation = () => {
  2788. state.status = "unvalidated";
  2789. state.validateMessage = "";
  2790. };
  2791. const endValidate = () => emit("end-validate", {
  2792. status: state.status
  2793. });
  2794. const validate = (rules = props.rules) => new Promise((resolve) => {
  2795. resetValidation();
  2796. if (rules) {
  2797. emit("start-validate");
  2798. runRules(rules).then(() => {
  2799. if (state.status === "failed") {
  2800. resolve({
  2801. name: props.name,
  2802. message: state.validateMessage
  2803. });
  2804. endValidate();
  2805. } else {
  2806. state.status = "passed";
  2807. resolve();
  2808. endValidate();
  2809. }
  2810. });
  2811. } else {
  2812. resolve();
  2813. }
  2814. });
  2815. const validateWithTrigger = (trigger) => {
  2816. if (form && props.rules) {
  2817. const {
  2818. validateTrigger
  2819. } = form.props;
  2820. const defaultTrigger = toArray(validateTrigger).includes(trigger);
  2821. const rules = props.rules.filter((rule) => {
  2822. if (rule.trigger) {
  2823. return toArray(rule.trigger).includes(trigger);
  2824. }
  2825. return defaultTrigger;
  2826. });
  2827. if (rules.length) {
  2828. validate(rules);
  2829. }
  2830. }
  2831. };
  2832. const limitValueLength = (value) => {
  2833. const {
  2834. maxlength
  2835. } = props;
  2836. if (isDef(maxlength) && getStringLength(value) > maxlength) {
  2837. const modelValue = getModelValue();
  2838. if (modelValue && getStringLength(modelValue) === +maxlength) {
  2839. return modelValue;
  2840. }
  2841. return cutString(value, +maxlength);
  2842. }
  2843. return value;
  2844. };
  2845. const updateValue = (value, trigger = "onChange") => {
  2846. value = limitValueLength(value);
  2847. if (props.type === "number" || props.type === "digit") {
  2848. const isNumber = props.type === "number";
  2849. value = formatNumber(value, isNumber, isNumber);
  2850. }
  2851. if (props.formatter && trigger === props.formatTrigger) {
  2852. value = props.formatter(value);
  2853. }
  2854. if (inputRef.value && inputRef.value.value !== value) {
  2855. inputRef.value.value = value;
  2856. }
  2857. if (value !== props.modelValue) {
  2858. emit("update:modelValue", value);
  2859. }
  2860. };
  2861. const onInput = (event) => {
  2862. if (!event.target.composing) {
  2863. updateValue(event.target.value);
  2864. }
  2865. };
  2866. const blur = () => {
  2867. var _a;
  2868. return (_a = inputRef.value) == null ? void 0 : _a.blur();
  2869. };
  2870. const focus = () => {
  2871. var _a;
  2872. return (_a = inputRef.value) == null ? void 0 : _a.focus();
  2873. };
  2874. const adjustTextareaSize = () => {
  2875. const input = inputRef.value;
  2876. if (props.type === "textarea" && props.autosize && input) {
  2877. resizeTextarea(input, props.autosize);
  2878. }
  2879. };
  2880. const onFocus = (event) => {
  2881. state.focused = true;
  2882. emit("focus", event);
  2883. nextTick(adjustTextareaSize);
  2884. if (getProp("readonly")) {
  2885. blur();
  2886. }
  2887. };
  2888. const onBlur = (event) => {
  2889. if (getProp("readonly")) {
  2890. return;
  2891. }
  2892. state.focused = false;
  2893. updateValue(getModelValue(), "onBlur");
  2894. emit("blur", event);
  2895. validateWithTrigger("onBlur");
  2896. nextTick(adjustTextareaSize);
  2897. resetScroll();
  2898. };
  2899. const onClickInput = (event) => emit("click-input", event);
  2900. const onClickLeftIcon = (event) => emit("click-left-icon", event);
  2901. const onClickRightIcon = (event) => emit("click-right-icon", event);
  2902. const onClear = (event) => {
  2903. preventDefault(event);
  2904. emit("update:modelValue", "");
  2905. emit("clear", event);
  2906. };
  2907. const showError = computed(() => {
  2908. if (typeof props.error === "boolean") {
  2909. return props.error;
  2910. }
  2911. if (form && form.props.showError && state.status === "failed") {
  2912. return true;
  2913. }
  2914. });
  2915. const labelStyle = computed(() => {
  2916. const labelWidth = getProp("labelWidth");
  2917. if (labelWidth) {
  2918. return {
  2919. width: addUnit(labelWidth)
  2920. };
  2921. }
  2922. });
  2923. const onKeypress = (event) => {
  2924. const ENTER_CODE = 13;
  2925. if (event.keyCode === ENTER_CODE) {
  2926. const submitOnEnter = form && form.props.submitOnEnter;
  2927. if (!submitOnEnter && props.type !== "textarea") {
  2928. preventDefault(event);
  2929. }
  2930. if (props.type === "search") {
  2931. blur();
  2932. }
  2933. }
  2934. emit("keypress", event);
  2935. };
  2936. const getInputId = () => props.id || `${id}-input`;
  2937. const getValidationStatus = () => state.status;
  2938. const renderInput = () => {
  2939. const controlClass = bem$1b("control", [getProp("inputAlign"), {
  2940. error: showError.value,
  2941. custom: !!slots.input,
  2942. "min-height": props.type === "textarea" && !props.autosize
  2943. }]);
  2944. if (slots.input) {
  2945. return createVNode("div", {
  2946. "class": controlClass,
  2947. "onClick": onClickInput
  2948. }, [slots.input()]);
  2949. }
  2950. const inputAttrs = {
  2951. id: getInputId(),
  2952. ref: inputRef,
  2953. name: props.name,
  2954. rows: props.rows !== void 0 ? +props.rows : void 0,
  2955. class: controlClass,
  2956. disabled: getProp("disabled"),
  2957. readonly: getProp("readonly"),
  2958. autofocus: props.autofocus,
  2959. placeholder: props.placeholder,
  2960. autocomplete: props.autocomplete,
  2961. enterkeyhint: props.enterkeyhint,
  2962. "aria-labelledby": props.label ? `${id}-label` : void 0,
  2963. onBlur,
  2964. onFocus,
  2965. onInput,
  2966. onClick: onClickInput,
  2967. onChange: endComposing,
  2968. onKeypress,
  2969. onCompositionend: endComposing,
  2970. onCompositionstart: startComposing
  2971. };
  2972. if (props.type === "textarea") {
  2973. return createVNode("textarea", inputAttrs, null);
  2974. }
  2975. return createVNode("input", mergeProps(mapInputType(props.type), inputAttrs), null);
  2976. };
  2977. const renderLeftIcon = () => {
  2978. const leftIconSlot = slots["left-icon"];
  2979. if (props.leftIcon || leftIconSlot) {
  2980. return createVNode("div", {
  2981. "class": bem$1b("left-icon"),
  2982. "onClick": onClickLeftIcon
  2983. }, [leftIconSlot ? leftIconSlot() : createVNode(Icon, {
  2984. "name": props.leftIcon,
  2985. "classPrefix": props.iconPrefix
  2986. }, null)]);
  2987. }
  2988. };
  2989. const renderRightIcon = () => {
  2990. const rightIconSlot = slots["right-icon"];
  2991. if (props.rightIcon || rightIconSlot) {
  2992. return createVNode("div", {
  2993. "class": bem$1b("right-icon"),
  2994. "onClick": onClickRightIcon
  2995. }, [rightIconSlot ? rightIconSlot() : createVNode(Icon, {
  2996. "name": props.rightIcon,
  2997. "classPrefix": props.iconPrefix
  2998. }, null)]);
  2999. }
  3000. };
  3001. const renderWordLimit = () => {
  3002. if (props.showWordLimit && props.maxlength) {
  3003. const count = getStringLength(getModelValue());
  3004. return createVNode("div", {
  3005. "class": bem$1b("word-limit")
  3006. }, [createVNode("span", {
  3007. "class": bem$1b("word-num")
  3008. }, [count]), createTextVNode("/"), props.maxlength]);
  3009. }
  3010. };
  3011. const renderMessage = () => {
  3012. if (form && form.props.showErrorMessage === false) {
  3013. return;
  3014. }
  3015. const message = props.errorMessage || state.validateMessage;
  3016. if (message) {
  3017. const slot = slots["error-message"];
  3018. const errorMessageAlign = getProp("errorMessageAlign");
  3019. return createVNode("div", {
  3020. "class": bem$1b("error-message", errorMessageAlign)
  3021. }, [slot ? slot({
  3022. message
  3023. }) : message]);
  3024. }
  3025. };
  3026. const renderLabel = () => {
  3027. const colon = getProp("colon") ? ":" : "";
  3028. if (slots.label) {
  3029. return [slots.label(), colon];
  3030. }
  3031. if (props.label) {
  3032. return createVNode("label", {
  3033. "id": `${id}-label`,
  3034. "for": getInputId()
  3035. }, [props.label + colon]);
  3036. }
  3037. };
  3038. const renderFieldBody = () => [createVNode("div", {
  3039. "class": bem$1b("body")
  3040. }, [renderInput(), showClear.value && createVNode(Icon, {
  3041. "ref": clearIconRef,
  3042. "name": props.clearIcon,
  3043. "class": bem$1b("clear")
  3044. }, null), renderRightIcon(), slots.button && createVNode("div", {
  3045. "class": bem$1b("button")
  3046. }, [slots.button()])]), renderWordLimit(), renderMessage()];
  3047. useExpose({
  3048. blur,
  3049. focus,
  3050. validate,
  3051. formValue,
  3052. resetValidation,
  3053. getValidationStatus
  3054. });
  3055. provide(CUSTOM_FIELD_INJECTION_KEY, {
  3056. customValue,
  3057. resetValidation,
  3058. validateWithTrigger
  3059. });
  3060. watch(() => props.modelValue, () => {
  3061. updateValue(getModelValue());
  3062. resetValidation();
  3063. validateWithTrigger("onChange");
  3064. nextTick(adjustTextareaSize);
  3065. });
  3066. onMounted(() => {
  3067. updateValue(getModelValue(), props.formatTrigger);
  3068. nextTick(adjustTextareaSize);
  3069. });
  3070. useEventListener("touchstart", onClear, {
  3071. target: computed(() => {
  3072. var _a;
  3073. return (_a = clearIconRef.value) == null ? void 0 : _a.$el;
  3074. })
  3075. });
  3076. return () => {
  3077. const disabled = getProp("disabled");
  3078. const labelAlign = getProp("labelAlign");
  3079. const Label = renderLabel();
  3080. const LeftIcon = renderLeftIcon();
  3081. return createVNode(Cell, {
  3082. "size": props.size,
  3083. "icon": props.leftIcon,
  3084. "class": bem$1b({
  3085. error: showError.value,
  3086. disabled,
  3087. [`label-${labelAlign}`]: labelAlign
  3088. }),
  3089. "center": props.center,
  3090. "border": props.border,
  3091. "isLink": props.isLink,
  3092. "clickable": props.clickable,
  3093. "titleStyle": labelStyle.value,
  3094. "valueClass": bem$1b("value"),
  3095. "titleClass": [bem$1b("label", [labelAlign, {
  3096. required: props.required
  3097. }]), props.labelClass],
  3098. "arrowDirection": props.arrowDirection
  3099. }, {
  3100. icon: LeftIcon ? () => LeftIcon : null,
  3101. title: Label ? () => Label : null,
  3102. value: renderFieldBody,
  3103. extra: slots.extra
  3104. });
  3105. };
  3106. }
  3107. });
  3108. const Field = withInstall(stdin_default$1m);
  3109. function usePopupState() {
  3110. const state = reactive({
  3111. show: false
  3112. });
  3113. const toggle = (show) => {
  3114. state.show = show;
  3115. };
  3116. const open = (props) => {
  3117. extend(state, props, { transitionAppear: true });
  3118. toggle(true);
  3119. };
  3120. const close = () => toggle(false);
  3121. useExpose({ open, close, toggle });
  3122. return {
  3123. open,
  3124. close,
  3125. state,
  3126. toggle
  3127. };
  3128. }
  3129. function mountComponent(RootComponent) {
  3130. const app = createApp(RootComponent);
  3131. const root = document.createElement("div");
  3132. document.body.appendChild(root);
  3133. return {
  3134. instance: app.mount(root),
  3135. unmount() {
  3136. app.unmount();
  3137. document.body.removeChild(root);
  3138. }
  3139. };
  3140. }
  3141. let lockCount = 0;
  3142. function lockClick(lock) {
  3143. if (lock) {
  3144. if (!lockCount) {
  3145. document.body.classList.add("van-toast--unclickable");
  3146. }
  3147. lockCount++;
  3148. } else if (lockCount) {
  3149. lockCount--;
  3150. if (!lockCount) {
  3151. document.body.classList.remove("van-toast--unclickable");
  3152. }
  3153. }
  3154. }
  3155. const [name$1e, bem$1a] = createNamespace("toast");
  3156. const popupInheritProps = ["show", "overlay", "teleport", "transition", "overlayClass", "overlayStyle", "closeOnClickOverlay"];
  3157. const toastProps = {
  3158. icon: String,
  3159. show: Boolean,
  3160. type: makeStringProp("text"),
  3161. overlay: Boolean,
  3162. message: numericProp,
  3163. iconSize: numericProp,
  3164. duration: makeNumberProp(2e3),
  3165. position: makeStringProp("middle"),
  3166. teleport: [String, Object],
  3167. className: unknownProp,
  3168. iconPrefix: String,
  3169. transition: makeStringProp("van-fade"),
  3170. loadingType: String,
  3171. forbidClick: Boolean,
  3172. overlayClass: unknownProp,
  3173. overlayStyle: Object,
  3174. closeOnClick: Boolean,
  3175. closeOnClickOverlay: Boolean
  3176. };
  3177. var stdin_default$1l = defineComponent({
  3178. name: name$1e,
  3179. props: toastProps,
  3180. emits: ["update:show"],
  3181. setup(props, {
  3182. emit
  3183. }) {
  3184. let timer2;
  3185. let clickable = false;
  3186. const toggleClickable = () => {
  3187. const newValue = props.show && props.forbidClick;
  3188. if (clickable !== newValue) {
  3189. clickable = newValue;
  3190. lockClick(clickable);
  3191. }
  3192. };
  3193. const updateShow = (show) => emit("update:show", show);
  3194. const onClick = () => {
  3195. if (props.closeOnClick) {
  3196. updateShow(false);
  3197. }
  3198. };
  3199. const clearTimer = () => clearTimeout(timer2);
  3200. const renderIcon = () => {
  3201. const {
  3202. icon,
  3203. type,
  3204. iconSize,
  3205. iconPrefix,
  3206. loadingType
  3207. } = props;
  3208. const hasIcon = icon || type === "success" || type === "fail";
  3209. if (hasIcon) {
  3210. return createVNode(Icon, {
  3211. "name": icon || type,
  3212. "size": iconSize,
  3213. "class": bem$1a("icon"),
  3214. "classPrefix": iconPrefix
  3215. }, null);
  3216. }
  3217. if (type === "loading") {
  3218. return createVNode(Loading, {
  3219. "class": bem$1a("loading"),
  3220. "size": iconSize,
  3221. "type": loadingType
  3222. }, null);
  3223. }
  3224. };
  3225. const renderMessage = () => {
  3226. const {
  3227. type,
  3228. message
  3229. } = props;
  3230. if (isDef(message) && message !== "") {
  3231. return type === "html" ? createVNode("div", {
  3232. "key": 0,
  3233. "class": bem$1a("text"),
  3234. "innerHTML": String(message)
  3235. }, null) : createVNode("div", {
  3236. "class": bem$1a("text")
  3237. }, [message]);
  3238. }
  3239. };
  3240. watch(() => [props.show, props.forbidClick], toggleClickable);
  3241. watch(() => [props.show, props.type, props.message, props.duration], () => {
  3242. clearTimer();
  3243. if (props.show && props.duration > 0) {
  3244. timer2 = setTimeout(() => {
  3245. updateShow(false);
  3246. }, props.duration);
  3247. }
  3248. });
  3249. onMounted(toggleClickable);
  3250. onUnmounted(toggleClickable);
  3251. return () => createVNode(Popup, mergeProps({
  3252. "class": [bem$1a([props.position, {
  3253. [props.type]: !props.icon
  3254. }]), props.className],
  3255. "lockScroll": false,
  3256. "onClick": onClick,
  3257. "onClosed": clearTimer,
  3258. "onUpdate:show": updateShow
  3259. }, pick(props, popupInheritProps)), {
  3260. default: () => [renderIcon(), renderMessage()]
  3261. });
  3262. }
  3263. });
  3264. const defaultOptions$1 = {
  3265. icon: "",
  3266. type: "text",
  3267. message: "",
  3268. className: "",
  3269. overlay: false,
  3270. onClose: void 0,
  3271. onOpened: void 0,
  3272. duration: 2e3,
  3273. teleport: "body",
  3274. iconSize: void 0,
  3275. iconPrefix: void 0,
  3276. position: "middle",
  3277. transition: "van-fade",
  3278. forbidClick: false,
  3279. loadingType: void 0,
  3280. overlayClass: "",
  3281. overlayStyle: void 0,
  3282. closeOnClick: false,
  3283. closeOnClickOverlay: false
  3284. };
  3285. let queue = [];
  3286. let allowMultiple = false;
  3287. let currentOptions = extend({}, defaultOptions$1);
  3288. const defaultOptionsMap = /* @__PURE__ */ new Map();
  3289. function parseOptions$1(message) {
  3290. if (isObject(message)) {
  3291. return message;
  3292. }
  3293. return {
  3294. message
  3295. };
  3296. }
  3297. function createInstance() {
  3298. const {
  3299. instance: instance2,
  3300. unmount
  3301. } = mountComponent({
  3302. setup() {
  3303. const message = ref("");
  3304. const {
  3305. open,
  3306. state,
  3307. close,
  3308. toggle
  3309. } = usePopupState();
  3310. const onClosed = () => {
  3311. if (allowMultiple) {
  3312. queue = queue.filter((item) => item !== instance2);
  3313. unmount();
  3314. }
  3315. };
  3316. const render = () => {
  3317. const attrs = {
  3318. onClosed,
  3319. "onUpdate:show": toggle
  3320. };
  3321. return createVNode(stdin_default$1l, mergeProps(state, attrs), null);
  3322. };
  3323. watch(message, (val) => {
  3324. state.message = val;
  3325. });
  3326. getCurrentInstance().render = render;
  3327. return {
  3328. open,
  3329. clear: close,
  3330. message
  3331. };
  3332. }
  3333. });
  3334. return instance2;
  3335. }
  3336. function getInstance() {
  3337. if (!queue.length || allowMultiple) {
  3338. const instance2 = createInstance();
  3339. queue.push(instance2);
  3340. }
  3341. return queue[queue.length - 1];
  3342. }
  3343. function Toast(options = {}) {
  3344. if (!inBrowser) {
  3345. return {};
  3346. }
  3347. const toast = getInstance();
  3348. const parsedOptions = parseOptions$1(options);
  3349. toast.open(extend({}, currentOptions, defaultOptionsMap.get(parsedOptions.type || currentOptions.type), parsedOptions));
  3350. return toast;
  3351. }
  3352. const createMethod = (type) => (options) => Toast(extend({
  3353. type
  3354. }, parseOptions$1(options)));
  3355. Toast.loading = createMethod("loading");
  3356. Toast.success = createMethod("success");
  3357. Toast.fail = createMethod("fail");
  3358. Toast.clear = (all) => {
  3359. var _a;
  3360. if (queue.length) {
  3361. if (all) {
  3362. queue.forEach((toast) => {
  3363. toast.clear();
  3364. });
  3365. queue = [];
  3366. } else if (!allowMultiple) {
  3367. queue[0].clear();
  3368. } else {
  3369. (_a = queue.shift()) == null ? void 0 : _a.clear();
  3370. }
  3371. }
  3372. };
  3373. function setDefaultOptions(type, options) {
  3374. if (typeof type === "string") {
  3375. defaultOptionsMap.set(type, options);
  3376. } else {
  3377. extend(currentOptions, type);
  3378. }
  3379. }
  3380. Toast.setDefaultOptions = setDefaultOptions;
  3381. Toast.resetDefaultOptions = (type) => {
  3382. if (typeof type === "string") {
  3383. defaultOptionsMap.delete(type);
  3384. } else {
  3385. currentOptions = extend({}, defaultOptions$1);
  3386. defaultOptionsMap.clear();
  3387. }
  3388. };
  3389. Toast.allowMultiple = (value = true) => {
  3390. allowMultiple = value;
  3391. };
  3392. Toast.install = (app) => {
  3393. app.use(withInstall(stdin_default$1l));
  3394. app.config.globalProperties.$toast = Toast;
  3395. };
  3396. const [name$1d, bem$19] = createNamespace("switch");
  3397. const switchProps = {
  3398. size: numericProp,
  3399. loading: Boolean,
  3400. disabled: Boolean,
  3401. modelValue: unknownProp,
  3402. activeColor: String,
  3403. inactiveColor: String,
  3404. activeValue: {
  3405. type: unknownProp,
  3406. default: true
  3407. },
  3408. inactiveValue: {
  3409. type: unknownProp,
  3410. default: false
  3411. }
  3412. };
  3413. var stdin_default$1k = defineComponent({
  3414. name: name$1d,
  3415. props: switchProps,
  3416. emits: ["change", "update:modelValue"],
  3417. setup(props, {
  3418. emit,
  3419. slots
  3420. }) {
  3421. const isChecked = () => props.modelValue === props.activeValue;
  3422. const onClick = () => {
  3423. if (!props.disabled && !props.loading) {
  3424. const newValue = isChecked() ? props.inactiveValue : props.activeValue;
  3425. emit("update:modelValue", newValue);
  3426. emit("change", newValue);
  3427. }
  3428. };
  3429. const renderLoading = () => {
  3430. if (props.loading) {
  3431. const color = isChecked() ? props.activeColor : props.inactiveColor;
  3432. return createVNode(Loading, {
  3433. "class": bem$19("loading"),
  3434. "color": color
  3435. }, null);
  3436. }
  3437. if (slots.node) {
  3438. return slots.node();
  3439. }
  3440. };
  3441. useCustomFieldValue(() => props.modelValue);
  3442. return () => {
  3443. var _a;
  3444. const {
  3445. size,
  3446. loading,
  3447. disabled,
  3448. activeColor,
  3449. inactiveColor
  3450. } = props;
  3451. const checked = isChecked();
  3452. const style = {
  3453. fontSize: addUnit(size),
  3454. backgroundColor: checked ? activeColor : inactiveColor
  3455. };
  3456. return createVNode("div", {
  3457. "role": "switch",
  3458. "class": bem$19({
  3459. on: checked,
  3460. loading,
  3461. disabled
  3462. }),
  3463. "style": style,
  3464. "tabindex": disabled ? void 0 : 0,
  3465. "aria-checked": checked,
  3466. "onClick": onClick
  3467. }, [createVNode("div", {
  3468. "class": bem$19("node")
  3469. }, [renderLoading()]), (_a = slots.background) == null ? void 0 : _a.call(slots)]);
  3470. };
  3471. }
  3472. });
  3473. const Switch = withInstall(stdin_default$1k);
  3474. const [name$1c, bem$18] = createNamespace("address-edit-detail");
  3475. const t$i = createNamespace("address-edit")[2];
  3476. var stdin_default$1j = defineComponent({
  3477. name: name$1c,
  3478. props: {
  3479. show: Boolean,
  3480. rows: numericProp,
  3481. value: String,
  3482. rules: Array,
  3483. focused: Boolean,
  3484. maxlength: numericProp,
  3485. searchResult: Array,
  3486. showSearchResult: Boolean
  3487. },
  3488. emits: ["blur", "focus", "input", "select-search"],
  3489. setup(props, {
  3490. emit
  3491. }) {
  3492. const field = ref();
  3493. const showSearchResult = () => props.focused && props.searchResult && props.showSearchResult;
  3494. const onSelect = (express) => {
  3495. emit("select-search", express);
  3496. emit("input", `${express.address || ""} ${express.name || ""}`.trim());
  3497. };
  3498. const renderSearchTitle = (express) => {
  3499. if (express.name) {
  3500. const text = express.name.replace(props.value, `<span class=${bem$18("keyword")}>${props.value}</span>`);
  3501. return createVNode("div", {
  3502. "innerHTML": text
  3503. }, null);
  3504. }
  3505. };
  3506. const renderSearchResult = () => {
  3507. if (!showSearchResult()) {
  3508. return;
  3509. }
  3510. const {
  3511. searchResult
  3512. } = props;
  3513. return searchResult.map((express) => createVNode(Cell, {
  3514. "clickable": true,
  3515. "key": express.name + express.address,
  3516. "icon": "location-o",
  3517. "label": express.address,
  3518. "class": bem$18("search-item"),
  3519. "border": false,
  3520. "onClick": () => onSelect(express)
  3521. }, {
  3522. title: () => renderSearchTitle(express)
  3523. }));
  3524. };
  3525. const onBlur = (event) => emit("blur", event);
  3526. const onFocus = (event) => emit("focus", event);
  3527. const onInput = (value) => emit("input", value);
  3528. return () => {
  3529. if (props.show) {
  3530. return createVNode(Fragment, null, [createVNode(Field, {
  3531. "autosize": true,
  3532. "clearable": true,
  3533. "ref": field,
  3534. "class": bem$18(),
  3535. "rows": props.rows,
  3536. "type": "textarea",
  3537. "rules": props.rules,
  3538. "label": t$i("addressDetail"),
  3539. "border": !showSearchResult(),
  3540. "maxlength": props.maxlength,
  3541. "modelValue": props.value,
  3542. "placeholder": t$i("addressDetail"),
  3543. "onBlur": onBlur,
  3544. "onFocus": onFocus,
  3545. "onUpdate:modelValue": onInput
  3546. }, null), renderSearchResult()]);
  3547. }
  3548. };
  3549. }
  3550. });
  3551. const [name$1b, bem$17, t$h] = createNamespace("address-edit");
  3552. const DEFAULT_DATA = {
  3553. name: "",
  3554. tel: "",
  3555. city: "",
  3556. county: "",
  3557. country: "",
  3558. province: "",
  3559. areaCode: "",
  3560. isDefault: false,
  3561. postalCode: "",
  3562. addressDetail: ""
  3563. };
  3564. const isPostal = (value) => /^\d{6}$/.test(value);
  3565. const addressEditProps = {
  3566. areaList: Object,
  3567. isSaving: Boolean,
  3568. isDeleting: Boolean,
  3569. validator: Function,
  3570. showArea: truthProp,
  3571. showDetail: truthProp,
  3572. showDelete: Boolean,
  3573. showPostal: Boolean,
  3574. disableArea: Boolean,
  3575. searchResult: Array,
  3576. telMaxlength: numericProp,
  3577. showSetDefault: Boolean,
  3578. saveButtonText: String,
  3579. areaPlaceholder: String,
  3580. deleteButtonText: String,
  3581. showSearchResult: Boolean,
  3582. detailRows: makeNumericProp(1),
  3583. detailMaxlength: makeNumericProp(200),
  3584. areaColumnsPlaceholder: makeArrayProp(),
  3585. addressInfo: {
  3586. type: Object,
  3587. default: () => extend({}, DEFAULT_DATA)
  3588. },
  3589. telValidator: {
  3590. type: Function,
  3591. default: isMobile
  3592. },
  3593. postalValidator: {
  3594. type: Function,
  3595. default: isPostal
  3596. }
  3597. };
  3598. var stdin_default$1i = defineComponent({
  3599. name: name$1b,
  3600. props: addressEditProps,
  3601. emits: ["save", "focus", "delete", "click-area", "change-area", "change-detail", "select-search", "change-default"],
  3602. setup(props, {
  3603. emit,
  3604. slots
  3605. }) {
  3606. const areaRef = ref();
  3607. const data = reactive({});
  3608. const showAreaPopup = ref(false);
  3609. const detailFocused = ref(false);
  3610. const areaListLoaded = computed(() => isObject(props.areaList) && Object.keys(props.areaList).length);
  3611. const areaText = computed(() => {
  3612. const {
  3613. country,
  3614. province,
  3615. city,
  3616. county,
  3617. areaCode
  3618. } = data;
  3619. if (areaCode) {
  3620. const arr = [country, province, city, county];
  3621. if (province && province === city) {
  3622. arr.splice(1, 1);
  3623. }
  3624. return arr.filter(Boolean).join("/");
  3625. }
  3626. return "";
  3627. });
  3628. const hideBottomFields = computed(() => {
  3629. var _a;
  3630. return ((_a = props.searchResult) == null ? void 0 : _a.length) && detailFocused.value;
  3631. });
  3632. const assignAreaValues = () => {
  3633. if (areaRef.value) {
  3634. const detail = areaRef.value.getArea();
  3635. detail.areaCode = detail.code;
  3636. delete detail.code;
  3637. extend(data, detail);
  3638. }
  3639. };
  3640. const onFocus = (key) => {
  3641. detailFocused.value = key === "addressDetail";
  3642. emit("focus", key);
  3643. };
  3644. const rules = computed(() => {
  3645. const {
  3646. validator,
  3647. telValidator,
  3648. postalValidator
  3649. } = props;
  3650. const makeRule = (name2, emptyMessage) => ({
  3651. validator: (value) => {
  3652. if (validator) {
  3653. const message = validator(name2, value);
  3654. if (message) {
  3655. return message;
  3656. }
  3657. }
  3658. if (!value) {
  3659. return emptyMessage;
  3660. }
  3661. return true;
  3662. }
  3663. });
  3664. return {
  3665. name: [makeRule("name", t$h("nameEmpty"))],
  3666. tel: [makeRule("tel", t$h("telInvalid")), {
  3667. validator: telValidator,
  3668. message: t$h("telInvalid")
  3669. }],
  3670. areaCode: [makeRule("areaCode", t$h("areaEmpty"))],
  3671. addressDetail: [makeRule("addressDetail", t$h("addressEmpty"))],
  3672. postalCode: [makeRule("addressDetail", t$h("postalEmpty")), {
  3673. validator: postalValidator,
  3674. message: t$h("postalEmpty")
  3675. }]
  3676. };
  3677. });
  3678. const onSave = () => emit("save", data);
  3679. const onChangeDetail = (val) => {
  3680. data.addressDetail = val;
  3681. emit("change-detail", val);
  3682. };
  3683. const onAreaConfirm = (values) => {
  3684. values = values.filter(Boolean);
  3685. if (values.some((value) => !value.code)) {
  3686. Toast(t$h("areaEmpty"));
  3687. } else {
  3688. showAreaPopup.value = false;
  3689. assignAreaValues();
  3690. emit("change-area", values);
  3691. }
  3692. };
  3693. const onDelete = () => emit("delete", data);
  3694. const getArea = () => {
  3695. var _a;
  3696. return ((_a = areaRef.value) == null ? void 0 : _a.getValues()) || [];
  3697. };
  3698. const setAreaCode = (code) => {
  3699. data.areaCode = code || "";
  3700. if (code) {
  3701. nextTick(assignAreaValues);
  3702. }
  3703. };
  3704. const onDetailBlur = () => {
  3705. setTimeout(() => {
  3706. detailFocused.value = false;
  3707. });
  3708. };
  3709. const setAddressDetail = (value) => {
  3710. data.addressDetail = value;
  3711. };
  3712. const renderSetDefaultCell = () => {
  3713. if (props.showSetDefault) {
  3714. const slots2 = {
  3715. "right-icon": () => createVNode(Switch, {
  3716. "modelValue": data.isDefault,
  3717. "onUpdate:modelValue": ($event) => data.isDefault = $event,
  3718. "size": "24",
  3719. "onChange": (event) => emit("change-default", event)
  3720. }, null)
  3721. };
  3722. return withDirectives(createVNode(Cell, {
  3723. "center": true,
  3724. "title": t$h("defaultAddress"),
  3725. "class": bem$17("default")
  3726. }, slots2), [[vShow, !hideBottomFields.value]]);
  3727. }
  3728. };
  3729. useExpose({
  3730. getArea,
  3731. setAreaCode,
  3732. setAddressDetail
  3733. });
  3734. watch(() => props.areaList, () => setAreaCode(data.areaCode));
  3735. watch(() => props.addressInfo, (value) => {
  3736. extend(data, DEFAULT_DATA, value);
  3737. setAreaCode(value.areaCode);
  3738. }, {
  3739. deep: true,
  3740. immediate: true
  3741. });
  3742. return () => {
  3743. const {
  3744. disableArea
  3745. } = props;
  3746. return createVNode(Form, {
  3747. "class": bem$17(),
  3748. "onSubmit": onSave
  3749. }, {
  3750. default: () => {
  3751. var _a;
  3752. return [createVNode("div", {
  3753. "class": bem$17("fields")
  3754. }, [createVNode(Field, {
  3755. "modelValue": data.name,
  3756. "onUpdate:modelValue": ($event) => data.name = $event,
  3757. "clearable": true,
  3758. "label": t$h("name"),
  3759. "rules": rules.value.name,
  3760. "placeholder": t$h("name"),
  3761. "onFocus": () => onFocus("name")
  3762. }, null), createVNode(Field, {
  3763. "modelValue": data.tel,
  3764. "onUpdate:modelValue": ($event) => data.tel = $event,
  3765. "clearable": true,
  3766. "type": "tel",
  3767. "label": t$h("tel"),
  3768. "rules": rules.value.tel,
  3769. "maxlength": props.telMaxlength,
  3770. "placeholder": t$h("tel"),
  3771. "onFocus": () => onFocus("tel")
  3772. }, null), withDirectives(createVNode(Field, {
  3773. "readonly": true,
  3774. "label": t$h("area"),
  3775. "is-link": !disableArea,
  3776. "modelValue": areaText.value,
  3777. "rules": rules.value.areaCode,
  3778. "placeholder": props.areaPlaceholder || t$h("area"),
  3779. "onFocus": () => onFocus("areaCode"),
  3780. "onClick": () => {
  3781. emit("click-area");
  3782. showAreaPopup.value = !disableArea;
  3783. }
  3784. }, null), [[vShow, props.showArea]]), createVNode(stdin_default$1j, {
  3785. "show": props.showDetail,
  3786. "rows": props.detailRows,
  3787. "rules": rules.value.addressDetail,
  3788. "value": data.addressDetail,
  3789. "focused": detailFocused.value,
  3790. "maxlength": props.detailMaxlength,
  3791. "searchResult": props.searchResult,
  3792. "showSearchResult": props.showSearchResult,
  3793. "onBlur": onDetailBlur,
  3794. "onFocus": () => onFocus("addressDetail"),
  3795. "onInput": onChangeDetail,
  3796. "onSelect-search": (event) => emit("select-search", event)
  3797. }, null), props.showPostal && withDirectives(createVNode(Field, {
  3798. "modelValue": data.postalCode,
  3799. "onUpdate:modelValue": ($event) => data.postalCode = $event,
  3800. "type": "tel",
  3801. "rules": rules.value.postalCode,
  3802. "label": t$h("postal"),
  3803. "maxlength": "6",
  3804. "placeholder": t$h("postal"),
  3805. "onFocus": () => onFocus("postalCode")
  3806. }, null), [[vShow, !hideBottomFields.value]]), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderSetDefaultCell(), withDirectives(createVNode("div", {
  3807. "class": bem$17("buttons")
  3808. }, [createVNode(Button, {
  3809. "block": true,
  3810. "round": true,
  3811. "type": "danger",
  3812. "text": props.saveButtonText || t$h("save"),
  3813. "class": bem$17("button"),
  3814. "loading": props.isSaving,
  3815. "nativeType": "submit"
  3816. }, null), props.showDelete && createVNode(Button, {
  3817. "block": true,
  3818. "round": true,
  3819. "class": bem$17("button"),
  3820. "loading": props.isDeleting,
  3821. "text": props.deleteButtonText || t$h("delete"),
  3822. "onClick": onDelete
  3823. }, null)]), [[vShow, !hideBottomFields.value]]), createVNode(Popup, {
  3824. "show": showAreaPopup.value,
  3825. "onUpdate:show": ($event) => showAreaPopup.value = $event,
  3826. "round": true,
  3827. "teleport": "body",
  3828. "position": "bottom",
  3829. "lazyRender": false
  3830. }, {
  3831. default: () => [createVNode(Area, {
  3832. "ref": areaRef,
  3833. "value": data.areaCode,
  3834. "loading": !areaListLoaded.value,
  3835. "areaList": props.areaList,
  3836. "columnsPlaceholder": props.areaColumnsPlaceholder,
  3837. "onConfirm": onAreaConfirm,
  3838. "onCancel": () => {
  3839. showAreaPopup.value = false;
  3840. }
  3841. }, null)]
  3842. })];
  3843. }
  3844. });
  3845. };
  3846. }
  3847. });
  3848. const AddressEdit = withInstall(stdin_default$1i);
  3849. const [name$1a, bem$16] = createNamespace("radio-group");
  3850. const radioGroupProps = {
  3851. disabled: Boolean,
  3852. iconSize: numericProp,
  3853. direction: String,
  3854. modelValue: unknownProp,
  3855. checkedColor: String
  3856. };
  3857. const RADIO_KEY = Symbol(name$1a);
  3858. var stdin_default$1h = defineComponent({
  3859. name: name$1a,
  3860. props: radioGroupProps,
  3861. emits: ["change", "update:modelValue"],
  3862. setup(props, {
  3863. emit,
  3864. slots
  3865. }) {
  3866. const {
  3867. linkChildren
  3868. } = useChildren(RADIO_KEY);
  3869. const updateValue = (value) => emit("update:modelValue", value);
  3870. watch(() => props.modelValue, (value) => emit("change", value));
  3871. linkChildren({
  3872. props,
  3873. updateValue
  3874. });
  3875. useCustomFieldValue(() => props.modelValue);
  3876. return () => {
  3877. var _a;
  3878. return createVNode("div", {
  3879. "class": bem$16([props.direction]),
  3880. "role": "radiogroup"
  3881. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  3882. };
  3883. }
  3884. });
  3885. const RadioGroup = withInstall(stdin_default$1h);
  3886. const [name$19, bem$15] = createNamespace("tag");
  3887. const tagProps = {
  3888. size: String,
  3889. mark: Boolean,
  3890. show: truthProp,
  3891. type: makeStringProp("default"),
  3892. color: String,
  3893. plain: Boolean,
  3894. round: Boolean,
  3895. textColor: String,
  3896. closeable: Boolean
  3897. };
  3898. var stdin_default$1g = defineComponent({
  3899. name: name$19,
  3900. props: tagProps,
  3901. emits: ["close"],
  3902. setup(props, {
  3903. slots,
  3904. emit
  3905. }) {
  3906. const onClose = (event) => {
  3907. event.stopPropagation();
  3908. emit("close", event);
  3909. };
  3910. const getStyle = () => {
  3911. if (props.plain) {
  3912. return {
  3913. color: props.textColor || props.color,
  3914. borderColor: props.color
  3915. };
  3916. }
  3917. return {
  3918. color: props.textColor,
  3919. background: props.color
  3920. };
  3921. };
  3922. const renderTag = () => {
  3923. var _a;
  3924. const {
  3925. type,
  3926. mark,
  3927. plain,
  3928. round,
  3929. size,
  3930. closeable
  3931. } = props;
  3932. const classes = {
  3933. mark,
  3934. plain,
  3935. round
  3936. };
  3937. if (size) {
  3938. classes[size] = size;
  3939. }
  3940. const CloseIcon = closeable && createVNode(Icon, {
  3941. "name": "cross",
  3942. "class": [bem$15("close"), HAPTICS_FEEDBACK],
  3943. "onClick": onClose
  3944. }, null);
  3945. return createVNode("span", {
  3946. "style": getStyle(),
  3947. "class": bem$15([classes, type])
  3948. }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]);
  3949. };
  3950. return () => createVNode(Transition, {
  3951. "name": props.closeable ? "van-fade" : void 0
  3952. }, {
  3953. default: () => [props.show ? renderTag() : null]
  3954. });
  3955. }
  3956. });
  3957. const Tag = withInstall(stdin_default$1g);
  3958. const checkerProps = {
  3959. name: unknownProp,
  3960. shape: makeStringProp("round"),
  3961. disabled: Boolean,
  3962. iconSize: numericProp,
  3963. modelValue: unknownProp,
  3964. checkedColor: String,
  3965. labelPosition: String,
  3966. labelDisabled: Boolean
  3967. };
  3968. var stdin_default$1f = defineComponent({
  3969. props: extend({}, checkerProps, {
  3970. bem: makeRequiredProp(Function),
  3971. role: String,
  3972. parent: Object,
  3973. checked: Boolean,
  3974. bindGroup: truthProp
  3975. }),
  3976. emits: ["click", "toggle"],
  3977. setup(props, {
  3978. emit,
  3979. slots
  3980. }) {
  3981. const iconRef = ref();
  3982. const getParentProp = (name2) => {
  3983. if (props.parent && props.bindGroup) {
  3984. return props.parent.props[name2];
  3985. }
  3986. };
  3987. const disabled = computed(() => getParentProp("disabled") || props.disabled);
  3988. const direction = computed(() => getParentProp("direction"));
  3989. const iconStyle = computed(() => {
  3990. const checkedColor = props.checkedColor || getParentProp("checkedColor");
  3991. if (checkedColor && props.checked && !disabled.value) {
  3992. return {
  3993. borderColor: checkedColor,
  3994. backgroundColor: checkedColor
  3995. };
  3996. }
  3997. });
  3998. const onClick = (event) => {
  3999. const {
  4000. target
  4001. } = event;
  4002. const icon = iconRef.value;
  4003. const iconClicked = icon === target || (icon == null ? void 0 : icon.contains(target));
  4004. if (!disabled.value && (iconClicked || !props.labelDisabled)) {
  4005. emit("toggle");
  4006. }
  4007. emit("click", event);
  4008. };
  4009. const renderIcon = () => {
  4010. const {
  4011. bem: bem2,
  4012. shape,
  4013. checked
  4014. } = props;
  4015. const iconSize = props.iconSize || getParentProp("iconSize");
  4016. return createVNode("div", {
  4017. "ref": iconRef,
  4018. "class": bem2("icon", [shape, {
  4019. disabled: disabled.value,
  4020. checked
  4021. }]),
  4022. "style": {
  4023. fontSize: addUnit(iconSize)
  4024. }
  4025. }, [slots.icon ? slots.icon({
  4026. checked,
  4027. disabled: disabled.value
  4028. }) : createVNode(Icon, {
  4029. "name": "success",
  4030. "style": iconStyle.value
  4031. }, null)]);
  4032. };
  4033. const renderLabel = () => {
  4034. if (slots.default) {
  4035. return createVNode("span", {
  4036. "class": props.bem("label", [props.labelPosition, {
  4037. disabled: disabled.value
  4038. }])
  4039. }, [slots.default()]);
  4040. }
  4041. };
  4042. return () => {
  4043. const nodes = props.labelPosition === "left" ? [renderLabel(), renderIcon()] : [renderIcon(), renderLabel()];
  4044. return createVNode("div", {
  4045. "role": props.role,
  4046. "class": props.bem([{
  4047. disabled: disabled.value,
  4048. "label-disabled": props.labelDisabled
  4049. }, direction.value]),
  4050. "tabindex": disabled.value ? void 0 : 0,
  4051. "aria-checked": props.checked,
  4052. "onClick": onClick
  4053. }, [nodes]);
  4054. };
  4055. }
  4056. });
  4057. const [name$18, bem$14] = createNamespace("radio");
  4058. var stdin_default$1e = defineComponent({
  4059. name: name$18,
  4060. props: checkerProps,
  4061. emits: ["update:modelValue"],
  4062. setup(props, {
  4063. emit,
  4064. slots
  4065. }) {
  4066. const {
  4067. parent
  4068. } = useParent(RADIO_KEY);
  4069. const checked = () => {
  4070. const value = parent ? parent.props.modelValue : props.modelValue;
  4071. return value === props.name;
  4072. };
  4073. const toggle = () => {
  4074. if (parent) {
  4075. parent.updateValue(props.name);
  4076. } else {
  4077. emit("update:modelValue", props.name);
  4078. }
  4079. };
  4080. return () => createVNode(stdin_default$1f, mergeProps({
  4081. "bem": bem$14,
  4082. "role": "radio",
  4083. "parent": parent,
  4084. "checked": checked(),
  4085. "onToggle": toggle
  4086. }, props), pick(slots, ["default", "icon"]));
  4087. }
  4088. });
  4089. const Radio = withInstall(stdin_default$1e);
  4090. const [name$17, bem$13] = createNamespace("address-item");
  4091. var stdin_default$1d = defineComponent({
  4092. name: name$17,
  4093. props: {
  4094. address: makeRequiredProp(Object),
  4095. disabled: Boolean,
  4096. switchable: Boolean,
  4097. defaultTagText: String
  4098. },
  4099. emits: ["edit", "click", "select"],
  4100. setup(props, {
  4101. slots,
  4102. emit
  4103. }) {
  4104. const onClick = () => {
  4105. if (props.switchable) {
  4106. emit("select");
  4107. }
  4108. emit("click");
  4109. };
  4110. const renderRightIcon = () => createVNode(Icon, {
  4111. "name": "edit",
  4112. "class": bem$13("edit"),
  4113. "onClick": (event) => {
  4114. event.stopPropagation();
  4115. emit("edit");
  4116. emit("click");
  4117. }
  4118. }, null);
  4119. const renderTag = () => {
  4120. if (slots.tag) {
  4121. return slots.tag(props.address);
  4122. }
  4123. if (props.address.isDefault && props.defaultTagText) {
  4124. return createVNode(Tag, {
  4125. "type": "danger",
  4126. "round": true,
  4127. "class": bem$13("tag")
  4128. }, {
  4129. default: () => [props.defaultTagText]
  4130. });
  4131. }
  4132. };
  4133. const renderContent = () => {
  4134. const {
  4135. address,
  4136. disabled,
  4137. switchable
  4138. } = props;
  4139. const Info = [createVNode("div", {
  4140. "class": bem$13("name")
  4141. }, [`${address.name} ${address.tel}`, renderTag()]), createVNode("div", {
  4142. "class": bem$13("address")
  4143. }, [address.address])];
  4144. if (switchable && !disabled) {
  4145. return createVNode(Radio, {
  4146. "name": address.id,
  4147. "iconSize": 18
  4148. }, {
  4149. default: () => [Info]
  4150. });
  4151. }
  4152. return Info;
  4153. };
  4154. return () => {
  4155. var _a;
  4156. const {
  4157. disabled
  4158. } = props;
  4159. return createVNode("div", {
  4160. "class": bem$13({
  4161. disabled
  4162. }),
  4163. "onClick": onClick
  4164. }, [createVNode(Cell, {
  4165. "border": false,
  4166. "valueClass": bem$13("value")
  4167. }, {
  4168. value: renderContent,
  4169. "right-icon": renderRightIcon
  4170. }), (_a = slots.bottom) == null ? void 0 : _a.call(slots, extend({}, props.address, {
  4171. disabled
  4172. }))]);
  4173. };
  4174. }
  4175. });
  4176. const [name$16, bem$12, t$g] = createNamespace("address-list");
  4177. const addressListProps = {
  4178. list: makeArrayProp(),
  4179. modelValue: numericProp,
  4180. switchable: truthProp,
  4181. disabledText: String,
  4182. disabledList: makeArrayProp(),
  4183. addButtonText: String,
  4184. defaultTagText: String
  4185. };
  4186. var stdin_default$1c = defineComponent({
  4187. name: name$16,
  4188. props: addressListProps,
  4189. emits: ["add", "edit", "select", "click-item", "edit-disabled", "select-disabled", "update:modelValue"],
  4190. setup(props, {
  4191. slots,
  4192. emit
  4193. }) {
  4194. const renderItem = (item, index, disabled) => {
  4195. const onEdit = () => emit(disabled ? "edit-disabled" : "edit", item, index);
  4196. const onClick = () => emit("click-item", item, index);
  4197. const onSelect = () => {
  4198. emit(disabled ? "select-disabled" : "select", item, index);
  4199. if (!disabled) {
  4200. emit("update:modelValue", item.id);
  4201. }
  4202. };
  4203. return createVNode(stdin_default$1d, {
  4204. "key": item.id,
  4205. "address": item,
  4206. "disabled": disabled,
  4207. "switchable": props.switchable,
  4208. "defaultTagText": props.defaultTagText,
  4209. "onEdit": onEdit,
  4210. "onClick": onClick,
  4211. "onSelect": onSelect
  4212. }, {
  4213. bottom: slots["item-bottom"],
  4214. tag: slots.tag
  4215. });
  4216. };
  4217. const renderList = (list, disabled) => {
  4218. if (list) {
  4219. return list.map((item, index) => renderItem(item, index, disabled));
  4220. }
  4221. };
  4222. const renderBottom = () => createVNode("div", {
  4223. "class": [bem$12("bottom"), "van-safe-area-bottom"]
  4224. }, [createVNode(Button, {
  4225. "round": true,
  4226. "block": true,
  4227. "type": "danger",
  4228. "text": props.addButtonText || t$g("add"),
  4229. "class": bem$12("add"),
  4230. "onClick": () => emit("add")
  4231. }, null)]);
  4232. return () => {
  4233. var _a, _b;
  4234. const List2 = renderList(props.list);
  4235. const DisabledList = renderList(props.disabledList, true);
  4236. const DisabledText = props.disabledText && createVNode("div", {
  4237. "class": bem$12("disabled-text")
  4238. }, [props.disabledText]);
  4239. return createVNode("div", {
  4240. "class": bem$12()
  4241. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), createVNode(RadioGroup, {
  4242. "modelValue": props.modelValue
  4243. }, {
  4244. default: () => [List2]
  4245. }), DisabledText, DisabledList, (_b = slots.default) == null ? void 0 : _b.call(slots), renderBottom()]);
  4246. };
  4247. }
  4248. });
  4249. const AddressList = withInstall(stdin_default$1c);
  4250. const [name$15, bem$11, t$f] = createNamespace("calendar");
  4251. const formatMonthTitle = (date) => t$f("monthTitle", date.getFullYear(), date.getMonth() + 1);
  4252. function compareMonth(date1, date2) {
  4253. const year1 = date1.getFullYear();
  4254. const year2 = date2.getFullYear();
  4255. if (year1 === year2) {
  4256. const month1 = date1.getMonth();
  4257. const month2 = date2.getMonth();
  4258. return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
  4259. }
  4260. return year1 > year2 ? 1 : -1;
  4261. }
  4262. function compareDay(day1, day2) {
  4263. const compareMonthResult = compareMonth(day1, day2);
  4264. if (compareMonthResult === 0) {
  4265. const date1 = day1.getDate();
  4266. const date2 = day2.getDate();
  4267. return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
  4268. }
  4269. return compareMonthResult;
  4270. }
  4271. const cloneDate = (date) => new Date(date);
  4272. const cloneDates = (dates) => Array.isArray(dates) ? dates.map(cloneDate) : cloneDate(dates);
  4273. function getDayByOffset(date, offset) {
  4274. const cloned = cloneDate(date);
  4275. cloned.setDate(cloned.getDate() + offset);
  4276. return cloned;
  4277. }
  4278. const getPrevDay = (date) => getDayByOffset(date, -1);
  4279. const getNextDay = (date) => getDayByOffset(date, 1);
  4280. const getToday = () => {
  4281. const today = new Date();
  4282. today.setHours(0, 0, 0, 0);
  4283. return today;
  4284. };
  4285. function calcDateNum(date) {
  4286. const day1 = date[0].getTime();
  4287. const day2 = date[1].getTime();
  4288. return (day2 - day1) / (1e3 * 60 * 60 * 24) + 1;
  4289. }
  4290. function useRefs() {
  4291. const refs = ref([]);
  4292. const cache = [];
  4293. onBeforeUpdate(() => {
  4294. refs.value = [];
  4295. });
  4296. const setRefs = (index) => {
  4297. if (!cache[index]) {
  4298. cache[index] = (el) => {
  4299. refs.value[index] = el;
  4300. };
  4301. }
  4302. return cache[index];
  4303. };
  4304. return [refs, setRefs];
  4305. }
  4306. const sharedProps = extend({}, pickerSharedProps, {
  4307. filter: Function,
  4308. columnsOrder: Array,
  4309. formatter: {
  4310. type: Function,
  4311. default: (type, value) => value
  4312. }
  4313. });
  4314. const pickerInheritKeys = Object.keys(pickerSharedProps);
  4315. function times(n, iteratee) {
  4316. if (n < 0) {
  4317. return [];
  4318. }
  4319. const result = Array(n);
  4320. let index = -1;
  4321. while (++index < n) {
  4322. result[index] = iteratee(index);
  4323. }
  4324. return result;
  4325. }
  4326. function getTrueValue(value) {
  4327. if (!value) {
  4328. return 0;
  4329. }
  4330. while (Number.isNaN(parseInt(value, 10))) {
  4331. if (value.length > 1) {
  4332. value = value.slice(1);
  4333. } else {
  4334. return 0;
  4335. }
  4336. }
  4337. return parseInt(value, 10);
  4338. }
  4339. const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
  4340. const proxyPickerMethods = (picker, callback) => {
  4341. const methods = [
  4342. "setValues",
  4343. "setIndexes",
  4344. "setColumnIndex",
  4345. "setColumnValue"
  4346. ];
  4347. return new Proxy(picker, {
  4348. get: (target, prop) => {
  4349. if (methods.includes(prop)) {
  4350. return (...args) => {
  4351. target[prop](...args);
  4352. callback();
  4353. };
  4354. }
  4355. return target[prop];
  4356. }
  4357. });
  4358. };
  4359. const [name$14] = createNamespace("calendar-day");
  4360. var stdin_default$1b = defineComponent({
  4361. name: name$14,
  4362. props: {
  4363. item: makeRequiredProp(Object),
  4364. color: String,
  4365. index: Number,
  4366. offset: makeNumberProp(0),
  4367. rowHeight: String
  4368. },
  4369. emits: ["click"],
  4370. setup(props, {
  4371. emit,
  4372. slots
  4373. }) {
  4374. const style = computed(() => {
  4375. var _a;
  4376. const {
  4377. item,
  4378. index,
  4379. color,
  4380. offset,
  4381. rowHeight
  4382. } = props;
  4383. const style2 = {
  4384. height: rowHeight
  4385. };
  4386. if (item.type === "placeholder") {
  4387. style2.width = "100%";
  4388. return style2;
  4389. }
  4390. if (index === 0) {
  4391. style2.marginLeft = `${100 * offset / 7}%`;
  4392. }
  4393. if (color) {
  4394. switch (item.type) {
  4395. case "end":
  4396. case "start":
  4397. case "start-end":
  4398. case "multiple-middle":
  4399. case "multiple-selected":
  4400. style2.background = color;
  4401. break;
  4402. case "middle":
  4403. style2.color = color;
  4404. break;
  4405. }
  4406. }
  4407. if (offset + (((_a = item.date) == null ? void 0 : _a.getDate()) || 1) > 28) {
  4408. style2.marginBottom = 0;
  4409. }
  4410. return style2;
  4411. });
  4412. const onClick = () => {
  4413. if (props.item.type !== "disabled") {
  4414. emit("click", props.item);
  4415. }
  4416. };
  4417. const renderTopInfo = () => {
  4418. const {
  4419. topInfo
  4420. } = props.item;
  4421. if (topInfo || slots["top-info"]) {
  4422. return createVNode("div", {
  4423. "class": bem$11("top-info")
  4424. }, [slots["top-info"] ? slots["top-info"](props.item) : topInfo]);
  4425. }
  4426. };
  4427. const renderBottomInfo = () => {
  4428. const {
  4429. bottomInfo
  4430. } = props.item;
  4431. if (bottomInfo || slots["bottom-info"]) {
  4432. return createVNode("div", {
  4433. "class": bem$11("bottom-info")
  4434. }, [slots["bottom-info"] ? slots["bottom-info"](props.item) : bottomInfo]);
  4435. }
  4436. };
  4437. const renderContent = () => {
  4438. const {
  4439. item,
  4440. color,
  4441. rowHeight
  4442. } = props;
  4443. const {
  4444. type,
  4445. text
  4446. } = item;
  4447. const Nodes = [renderTopInfo(), text, renderBottomInfo()];
  4448. if (type === "selected") {
  4449. return createVNode("div", {
  4450. "class": bem$11("selected-day"),
  4451. "style": {
  4452. width: rowHeight,
  4453. height: rowHeight,
  4454. background: color
  4455. }
  4456. }, [Nodes]);
  4457. }
  4458. return Nodes;
  4459. };
  4460. return () => {
  4461. const {
  4462. type,
  4463. className
  4464. } = props.item;
  4465. if (type === "placeholder") {
  4466. return createVNode("div", {
  4467. "class": bem$11("day"),
  4468. "style": style.value
  4469. }, null);
  4470. }
  4471. return createVNode("div", {
  4472. "role": "gridcell",
  4473. "style": style.value,
  4474. "class": [bem$11("day", type), className],
  4475. "tabindex": type === "disabled" ? void 0 : -1,
  4476. "onClick": onClick
  4477. }, [renderContent()]);
  4478. };
  4479. }
  4480. });
  4481. const [name$13] = createNamespace("calendar-month");
  4482. const calendarMonthProps = {
  4483. date: makeRequiredProp(Date),
  4484. type: String,
  4485. color: String,
  4486. minDate: makeRequiredProp(Date),
  4487. maxDate: makeRequiredProp(Date),
  4488. showMark: Boolean,
  4489. rowHeight: numericProp,
  4490. formatter: Function,
  4491. lazyRender: Boolean,
  4492. currentDate: [Date, Array],
  4493. allowSameDay: Boolean,
  4494. showSubtitle: Boolean,
  4495. showMonthTitle: Boolean,
  4496. firstDayOfWeek: Number
  4497. };
  4498. var stdin_default$1a = defineComponent({
  4499. name: name$13,
  4500. props: calendarMonthProps,
  4501. emits: ["click", "update-height"],
  4502. setup(props, {
  4503. emit,
  4504. slots
  4505. }) {
  4506. const [visible, setVisible] = useToggle();
  4507. const daysRef = ref();
  4508. const monthRef = ref();
  4509. const height = useHeight(monthRef);
  4510. const title = computed(() => formatMonthTitle(props.date));
  4511. const rowHeight = computed(() => addUnit(props.rowHeight));
  4512. const offset = computed(() => {
  4513. const realDay = props.date.getDay();
  4514. if (props.firstDayOfWeek) {
  4515. return (realDay + 7 - props.firstDayOfWeek) % 7;
  4516. }
  4517. return realDay;
  4518. });
  4519. const totalDay = computed(() => getMonthEndDay(props.date.getFullYear(), props.date.getMonth() + 1));
  4520. const shouldRender = computed(() => visible.value || !props.lazyRender);
  4521. const getTitle = () => title.value;
  4522. const getMultipleDayType = (day) => {
  4523. const isSelected = (date) => props.currentDate.some((item) => compareDay(item, date) === 0);
  4524. if (isSelected(day)) {
  4525. const prevDay = getPrevDay(day);
  4526. const nextDay = getNextDay(day);
  4527. const prevSelected = isSelected(prevDay);
  4528. const nextSelected = isSelected(nextDay);
  4529. if (prevSelected && nextSelected) {
  4530. return "multiple-middle";
  4531. }
  4532. if (prevSelected) {
  4533. return "end";
  4534. }
  4535. if (nextSelected) {
  4536. return "start";
  4537. }
  4538. return "multiple-selected";
  4539. }
  4540. return "";
  4541. };
  4542. const getRangeDayType = (day) => {
  4543. const [startDay, endDay] = props.currentDate;
  4544. if (!startDay) {
  4545. return "";
  4546. }
  4547. const compareToStart = compareDay(day, startDay);
  4548. if (!endDay) {
  4549. return compareToStart === 0 ? "start" : "";
  4550. }
  4551. const compareToEnd = compareDay(day, endDay);
  4552. if (props.allowSameDay && compareToStart === 0 && compareToEnd === 0) {
  4553. return "start-end";
  4554. }
  4555. if (compareToStart === 0) {
  4556. return "start";
  4557. }
  4558. if (compareToEnd === 0) {
  4559. return "end";
  4560. }
  4561. if (compareToStart > 0 && compareToEnd < 0) {
  4562. return "middle";
  4563. }
  4564. return "";
  4565. };
  4566. const getDayType = (day) => {
  4567. const {
  4568. type,
  4569. minDate,
  4570. maxDate,
  4571. currentDate
  4572. } = props;
  4573. if (compareDay(day, minDate) < 0 || compareDay(day, maxDate) > 0) {
  4574. return "disabled";
  4575. }
  4576. if (currentDate === null) {
  4577. return "";
  4578. }
  4579. if (Array.isArray(currentDate)) {
  4580. if (type === "multiple") {
  4581. return getMultipleDayType(day);
  4582. }
  4583. if (type === "range") {
  4584. return getRangeDayType(day);
  4585. }
  4586. } else if (type === "single") {
  4587. return compareDay(day, currentDate) === 0 ? "selected" : "";
  4588. }
  4589. return "";
  4590. };
  4591. const getBottomInfo = (dayType) => {
  4592. if (props.type === "range") {
  4593. if (dayType === "start" || dayType === "end") {
  4594. return t$f(dayType);
  4595. }
  4596. if (dayType === "start-end") {
  4597. return `${t$f("start")}/${t$f("end")}`;
  4598. }
  4599. }
  4600. };
  4601. const renderTitle = () => {
  4602. if (props.showMonthTitle) {
  4603. return createVNode("div", {
  4604. "class": bem$11("month-title")
  4605. }, [title.value]);
  4606. }
  4607. };
  4608. const renderMark = () => {
  4609. if (props.showMark && shouldRender.value) {
  4610. return createVNode("div", {
  4611. "class": bem$11("month-mark")
  4612. }, [props.date.getMonth() + 1]);
  4613. }
  4614. };
  4615. const placeholders = computed(() => {
  4616. const count = Math.ceil((totalDay.value + offset.value) / 7);
  4617. return Array(count).fill({
  4618. type: "placeholder"
  4619. });
  4620. });
  4621. const days = computed(() => {
  4622. const days2 = [];
  4623. const year = props.date.getFullYear();
  4624. const month = props.date.getMonth();
  4625. for (let day = 1; day <= totalDay.value; day++) {
  4626. const date = new Date(year, month, day);
  4627. const type = getDayType(date);
  4628. let config = {
  4629. date,
  4630. type,
  4631. text: day,
  4632. bottomInfo: getBottomInfo(type)
  4633. };
  4634. if (props.formatter) {
  4635. config = props.formatter(config);
  4636. }
  4637. days2.push(config);
  4638. }
  4639. return days2;
  4640. });
  4641. const disabledDays = computed(() => days.value.filter((day) => day.type === "disabled"));
  4642. const scrollToDate = (body, targetDate) => {
  4643. if (daysRef.value) {
  4644. const daysRect = useRect(daysRef.value);
  4645. const totalRows = placeholders.value.length;
  4646. const currentRow = Math.ceil((targetDate.getDate() + offset.value) / 7);
  4647. const rowOffset = (currentRow - 1) * daysRect.height / totalRows;
  4648. setScrollTop(body, daysRect.top + rowOffset + body.scrollTop - useRect(body).top);
  4649. }
  4650. };
  4651. const renderDay = (item, index) => createVNode(stdin_default$1b, {
  4652. "item": item,
  4653. "index": index,
  4654. "color": props.color,
  4655. "offset": offset.value,
  4656. "rowHeight": rowHeight.value,
  4657. "onClick": (item2) => emit("click", item2)
  4658. }, pick(slots, ["top-info", "bottom-info"]));
  4659. const renderDays = () => createVNode("div", {
  4660. "ref": daysRef,
  4661. "role": "grid",
  4662. "class": bem$11("days")
  4663. }, [renderMark(), (shouldRender.value ? days : placeholders).value.map(renderDay)]);
  4664. useExpose({
  4665. getTitle,
  4666. getHeight: () => height.value,
  4667. setVisible,
  4668. scrollToDate,
  4669. disabledDays
  4670. });
  4671. return () => createVNode("div", {
  4672. "class": bem$11("month"),
  4673. "ref": monthRef
  4674. }, [renderTitle(), renderDays()]);
  4675. }
  4676. });
  4677. const [name$12] = createNamespace("calendar-header");
  4678. var stdin_default$19 = defineComponent({
  4679. name: name$12,
  4680. props: {
  4681. title: String,
  4682. subtitle: String,
  4683. showTitle: Boolean,
  4684. showSubtitle: Boolean,
  4685. firstDayOfWeek: Number
  4686. },
  4687. emits: ["click-subtitle"],
  4688. setup(props, {
  4689. slots,
  4690. emit
  4691. }) {
  4692. const renderTitle = () => {
  4693. if (props.showTitle) {
  4694. const text = props.title || t$f("title");
  4695. const title = slots.title ? slots.title() : text;
  4696. return createVNode("div", {
  4697. "class": bem$11("header-title")
  4698. }, [title]);
  4699. }
  4700. };
  4701. const onClickSubtitle = (event) => emit("click-subtitle", event);
  4702. const renderSubtitle = () => {
  4703. if (props.showSubtitle) {
  4704. const title = slots.subtitle ? slots.subtitle() : props.subtitle;
  4705. return createVNode("div", {
  4706. "class": bem$11("header-subtitle"),
  4707. "onClick": onClickSubtitle
  4708. }, [title]);
  4709. }
  4710. };
  4711. const renderWeekDays = () => {
  4712. const {
  4713. firstDayOfWeek
  4714. } = props;
  4715. const weekdays = t$f("weekdays");
  4716. const renderWeekDays2 = [...weekdays.slice(firstDayOfWeek, 7), ...weekdays.slice(0, firstDayOfWeek)];
  4717. return createVNode("div", {
  4718. "class": bem$11("weekdays")
  4719. }, [renderWeekDays2.map((text) => createVNode("span", {
  4720. "class": bem$11("weekday")
  4721. }, [text]))]);
  4722. };
  4723. return () => createVNode("div", {
  4724. "class": bem$11("header")
  4725. }, [renderTitle(), renderSubtitle(), renderWeekDays()]);
  4726. }
  4727. });
  4728. const calendarProps = {
  4729. show: Boolean,
  4730. type: makeStringProp("single"),
  4731. title: String,
  4732. color: String,
  4733. round: truthProp,
  4734. readonly: Boolean,
  4735. poppable: truthProp,
  4736. maxRange: makeNumericProp(null),
  4737. position: makeStringProp("bottom"),
  4738. teleport: [String, Object],
  4739. showMark: truthProp,
  4740. showTitle: truthProp,
  4741. formatter: Function,
  4742. rowHeight: numericProp,
  4743. confirmText: String,
  4744. rangePrompt: String,
  4745. lazyRender: truthProp,
  4746. showConfirm: truthProp,
  4747. defaultDate: [Date, Array],
  4748. allowSameDay: Boolean,
  4749. showSubtitle: truthProp,
  4750. closeOnPopstate: truthProp,
  4751. showRangePrompt: truthProp,
  4752. confirmDisabledText: String,
  4753. closeOnClickOverlay: truthProp,
  4754. safeAreaInsetTop: Boolean,
  4755. safeAreaInsetBottom: truthProp,
  4756. minDate: {
  4757. type: Date,
  4758. validator: isDate,
  4759. default: getToday
  4760. },
  4761. maxDate: {
  4762. type: Date,
  4763. validator: isDate,
  4764. default: () => {
  4765. const now = getToday();
  4766. return new Date(now.getFullYear(), now.getMonth() + 6, now.getDate());
  4767. }
  4768. },
  4769. firstDayOfWeek: {
  4770. type: numericProp,
  4771. default: 0,
  4772. validator: (val) => val >= 0 && val <= 6
  4773. }
  4774. };
  4775. var stdin_default$18 = defineComponent({
  4776. name: name$15,
  4777. props: calendarProps,
  4778. emits: ["select", "confirm", "unselect", "month-show", "over-range", "update:show", "click-subtitle"],
  4779. setup(props, {
  4780. emit,
  4781. slots
  4782. }) {
  4783. const limitDateRange = (date, minDate = props.minDate, maxDate = props.maxDate) => {
  4784. if (compareDay(date, minDate) === -1) {
  4785. return minDate;
  4786. }
  4787. if (compareDay(date, maxDate) === 1) {
  4788. return maxDate;
  4789. }
  4790. return date;
  4791. };
  4792. const getInitialDate = (defaultDate = props.defaultDate) => {
  4793. const {
  4794. type,
  4795. minDate,
  4796. maxDate,
  4797. allowSameDay
  4798. } = props;
  4799. if (defaultDate === null) {
  4800. return defaultDate;
  4801. }
  4802. const now = getToday();
  4803. if (type === "range") {
  4804. if (!Array.isArray(defaultDate)) {
  4805. defaultDate = [];
  4806. }
  4807. const start = limitDateRange(defaultDate[0] || now, minDate, allowSameDay ? maxDate : getPrevDay(maxDate));
  4808. const end = limitDateRange(defaultDate[1] || now, allowSameDay ? minDate : getNextDay(minDate));
  4809. return [start, end];
  4810. }
  4811. if (type === "multiple") {
  4812. if (Array.isArray(defaultDate)) {
  4813. return defaultDate.map((date) => limitDateRange(date));
  4814. }
  4815. return [limitDateRange(now)];
  4816. }
  4817. if (!defaultDate || Array.isArray(defaultDate)) {
  4818. defaultDate = now;
  4819. }
  4820. return limitDateRange(defaultDate);
  4821. };
  4822. let bodyHeight;
  4823. const bodyRef = ref();
  4824. const subtitle = ref("");
  4825. const currentDate = ref(getInitialDate());
  4826. const [monthRefs, setMonthRefs] = useRefs();
  4827. const dayOffset = computed(() => props.firstDayOfWeek ? +props.firstDayOfWeek % 7 : 0);
  4828. const months = computed(() => {
  4829. const months2 = [];
  4830. const cursor = new Date(props.minDate);
  4831. cursor.setDate(1);
  4832. do {
  4833. months2.push(new Date(cursor));
  4834. cursor.setMonth(cursor.getMonth() + 1);
  4835. } while (compareMonth(cursor, props.maxDate) !== 1);
  4836. return months2;
  4837. });
  4838. const buttonDisabled = computed(() => {
  4839. if (currentDate.value) {
  4840. if (props.type === "range") {
  4841. return !currentDate.value[0] || !currentDate.value[1];
  4842. }
  4843. if (props.type === "multiple") {
  4844. return !currentDate.value.length;
  4845. }
  4846. }
  4847. return !currentDate.value;
  4848. });
  4849. const getSelectedDate = () => currentDate.value;
  4850. const onScroll = () => {
  4851. const top = getScrollTop(bodyRef.value);
  4852. const bottom = top + bodyHeight;
  4853. const heights = months.value.map((item, index) => monthRefs.value[index].getHeight());
  4854. const heightSum = heights.reduce((a, b) => a + b, 0);
  4855. if (bottom > heightSum && top > 0) {
  4856. return;
  4857. }
  4858. let height = 0;
  4859. let currentMonth;
  4860. const visibleRange = [-1, -1];
  4861. for (let i = 0; i < months.value.length; i++) {
  4862. const month = monthRefs.value[i];
  4863. const visible = height <= bottom && height + heights[i] >= top;
  4864. if (visible) {
  4865. visibleRange[1] = i;
  4866. if (!currentMonth) {
  4867. currentMonth = month;
  4868. visibleRange[0] = i;
  4869. }
  4870. if (!monthRefs.value[i].showed) {
  4871. monthRefs.value[i].showed = true;
  4872. emit("month-show", {
  4873. date: month.date,
  4874. title: month.getTitle()
  4875. });
  4876. }
  4877. }
  4878. height += heights[i];
  4879. }
  4880. months.value.forEach((month, index) => {
  4881. const visible = index >= visibleRange[0] - 1 && index <= visibleRange[1] + 1;
  4882. monthRefs.value[index].setVisible(visible);
  4883. });
  4884. if (currentMonth) {
  4885. subtitle.value = currentMonth.getTitle();
  4886. }
  4887. };
  4888. const scrollToDate = (targetDate) => {
  4889. raf(() => {
  4890. months.value.some((month, index) => {
  4891. if (compareMonth(month, targetDate) === 0) {
  4892. if (bodyRef.value) {
  4893. monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
  4894. }
  4895. return true;
  4896. }
  4897. return false;
  4898. });
  4899. onScroll();
  4900. });
  4901. };
  4902. const scrollToCurrentDate = () => {
  4903. if (props.poppable && !props.show) {
  4904. return;
  4905. }
  4906. if (currentDate.value) {
  4907. const targetDate = props.type === "single" ? currentDate.value : currentDate.value[0];
  4908. if (isDate(targetDate)) {
  4909. scrollToDate(targetDate);
  4910. }
  4911. } else {
  4912. raf(onScroll);
  4913. }
  4914. };
  4915. const init = () => {
  4916. if (props.poppable && !props.show) {
  4917. return;
  4918. }
  4919. raf(() => {
  4920. bodyHeight = Math.floor(useRect(bodyRef).height);
  4921. });
  4922. scrollToCurrentDate();
  4923. };
  4924. const reset = (date = getInitialDate()) => {
  4925. currentDate.value = date;
  4926. scrollToCurrentDate();
  4927. };
  4928. const checkRange = (date) => {
  4929. const {
  4930. maxRange,
  4931. rangePrompt,
  4932. showRangePrompt
  4933. } = props;
  4934. if (maxRange && calcDateNum(date) > maxRange) {
  4935. if (showRangePrompt) {
  4936. Toast(rangePrompt || t$f("rangePrompt", maxRange));
  4937. }
  4938. emit("over-range");
  4939. return false;
  4940. }
  4941. return true;
  4942. };
  4943. const onConfirm = () => {
  4944. var _a;
  4945. return emit("confirm", (_a = currentDate.value) != null ? _a : cloneDates(currentDate.value));
  4946. };
  4947. const select = (date, complete) => {
  4948. const setCurrentDate = (date2) => {
  4949. currentDate.value = date2;
  4950. emit("select", cloneDates(date2));
  4951. };
  4952. if (complete && props.type === "range") {
  4953. const valid = checkRange(date);
  4954. if (!valid) {
  4955. setCurrentDate([date[0], getDayByOffset(date[0], +props.maxRange - 1)]);
  4956. return;
  4957. }
  4958. }
  4959. setCurrentDate(date);
  4960. if (complete && !props.showConfirm) {
  4961. onConfirm();
  4962. }
  4963. };
  4964. const getDisabledDate = (disabledDays2, startDay, date) => {
  4965. var _a;
  4966. return (_a = disabledDays2.find((day) => compareDay(startDay, day.date) === -1 && compareDay(day.date, date) === -1)) == null ? void 0 : _a.date;
  4967. };
  4968. const disabledDays = computed(() => monthRefs.value.reduce((arr, ref2) => {
  4969. var _a, _b;
  4970. arr.push(...(_b = (_a = ref2.disabledDays) == null ? void 0 : _a.value) != null ? _b : []);
  4971. return arr;
  4972. }, []));
  4973. const onClickDay = (item) => {
  4974. if (props.readonly || !item.date) {
  4975. return;
  4976. }
  4977. const {
  4978. date
  4979. } = item;
  4980. const {
  4981. type
  4982. } = props;
  4983. if (type === "range") {
  4984. if (!currentDate.value) {
  4985. select([date]);
  4986. return;
  4987. }
  4988. const [startDay, endDay] = currentDate.value;
  4989. if (startDay && !endDay) {
  4990. const compareToStart = compareDay(date, startDay);
  4991. if (compareToStart === 1) {
  4992. const disabledDay = getDisabledDate(disabledDays.value, startDay, date);
  4993. if (disabledDay) {
  4994. const endDay2 = getPrevDay(disabledDay);
  4995. if (compareDay(startDay, endDay2) === -1) {
  4996. select([startDay, endDay2]);
  4997. } else {
  4998. select([date]);
  4999. }
  5000. } else {
  5001. select([startDay, date], true);
  5002. }
  5003. } else if (compareToStart === -1) {
  5004. select([date]);
  5005. } else if (props.allowSameDay) {
  5006. select([date, date], true);
  5007. }
  5008. } else {
  5009. select([date]);
  5010. }
  5011. } else if (type === "multiple") {
  5012. if (!currentDate.value) {
  5013. select([date]);
  5014. return;
  5015. }
  5016. const dates = currentDate.value;
  5017. const selectedIndex = dates.findIndex((dateItem) => compareDay(dateItem, date) === 0);
  5018. if (selectedIndex !== -1) {
  5019. const [unselectedDate] = dates.splice(selectedIndex, 1);
  5020. emit("unselect", cloneDate(unselectedDate));
  5021. } else if (props.maxRange && dates.length >= props.maxRange) {
  5022. Toast(props.rangePrompt || t$f("rangePrompt", props.maxRange));
  5023. } else {
  5024. select([...dates, date]);
  5025. }
  5026. } else {
  5027. select(date, true);
  5028. }
  5029. };
  5030. const updateShow = (value) => emit("update:show", value);
  5031. const renderMonth = (date, index) => {
  5032. const showMonthTitle = index !== 0 || !props.showSubtitle;
  5033. return createVNode(stdin_default$1a, mergeProps({
  5034. "ref": setMonthRefs(index),
  5035. "date": date,
  5036. "currentDate": currentDate.value,
  5037. "showMonthTitle": showMonthTitle,
  5038. "firstDayOfWeek": dayOffset.value
  5039. }, pick(props, ["type", "color", "minDate", "maxDate", "showMark", "formatter", "rowHeight", "lazyRender", "showSubtitle", "allowSameDay"]), {
  5040. "onClick": onClickDay
  5041. }), pick(slots, ["top-info", "bottom-info"]));
  5042. };
  5043. const renderFooterButton = () => {
  5044. if (slots.footer) {
  5045. return slots.footer();
  5046. }
  5047. if (props.showConfirm) {
  5048. const slot = slots["confirm-text"];
  5049. const disabled = buttonDisabled.value;
  5050. const text = disabled ? props.confirmDisabledText : props.confirmText;
  5051. return createVNode(Button, {
  5052. "round": true,
  5053. "block": true,
  5054. "type": "danger",
  5055. "color": props.color,
  5056. "class": bem$11("confirm"),
  5057. "disabled": disabled,
  5058. "nativeType": "button",
  5059. "onClick": onConfirm
  5060. }, {
  5061. default: () => [slot ? slot({
  5062. disabled
  5063. }) : text || t$f("confirm")]
  5064. });
  5065. }
  5066. };
  5067. const renderFooter = () => createVNode("div", {
  5068. "class": [bem$11("footer"), {
  5069. "van-safe-area-bottom": props.safeAreaInsetBottom
  5070. }]
  5071. }, [renderFooterButton()]);
  5072. const renderCalendar = () => createVNode("div", {
  5073. "class": bem$11()
  5074. }, [createVNode(stdin_default$19, {
  5075. "title": props.title,
  5076. "subtitle": subtitle.value,
  5077. "showTitle": props.showTitle,
  5078. "showSubtitle": props.showSubtitle,
  5079. "firstDayOfWeek": dayOffset.value,
  5080. "onClick-subtitle": (event) => emit("click-subtitle", event)
  5081. }, pick(slots, ["title", "subtitle"])), createVNode("div", {
  5082. "ref": bodyRef,
  5083. "class": bem$11("body"),
  5084. "onScroll": onScroll
  5085. }, [months.value.map(renderMonth)]), renderFooter()]);
  5086. watch(() => props.show, init);
  5087. watch(() => [props.type, props.minDate, props.maxDate], () => reset(getInitialDate(currentDate.value)));
  5088. watch(() => props.defaultDate, (value = null) => {
  5089. currentDate.value = value;
  5090. scrollToCurrentDate();
  5091. });
  5092. useExpose({
  5093. reset,
  5094. scrollToDate,
  5095. getSelectedDate
  5096. });
  5097. onMountedOrActivated(init);
  5098. return () => {
  5099. if (props.poppable) {
  5100. return createVNode(Popup, {
  5101. "show": props.show,
  5102. "class": bem$11("popup"),
  5103. "round": props.round,
  5104. "position": props.position,
  5105. "closeable": props.showTitle || props.showSubtitle,
  5106. "teleport": props.teleport,
  5107. "closeOnPopstate": props.closeOnPopstate,
  5108. "safeAreaInsetTop": props.safeAreaInsetTop,
  5109. "closeOnClickOverlay": props.closeOnClickOverlay,
  5110. "onUpdate:show": updateShow
  5111. }, {
  5112. default: renderCalendar
  5113. });
  5114. }
  5115. return renderCalendar();
  5116. };
  5117. }
  5118. });
  5119. const Calendar = withInstall(stdin_default$18);
  5120. const [name$11, bem$10] = createNamespace("image");
  5121. const imageProps = {
  5122. src: String,
  5123. alt: String,
  5124. fit: String,
  5125. position: String,
  5126. round: Boolean,
  5127. block: Boolean,
  5128. width: numericProp,
  5129. height: numericProp,
  5130. radius: numericProp,
  5131. lazyLoad: Boolean,
  5132. iconSize: numericProp,
  5133. showError: truthProp,
  5134. errorIcon: makeStringProp("photo-fail"),
  5135. iconPrefix: String,
  5136. showLoading: truthProp,
  5137. loadingIcon: makeStringProp("photo")
  5138. };
  5139. var stdin_default$17 = defineComponent({
  5140. name: name$11,
  5141. props: imageProps,
  5142. emits: ["load", "error"],
  5143. setup(props, {
  5144. emit,
  5145. slots
  5146. }) {
  5147. const error = ref(false);
  5148. const loading = ref(true);
  5149. const imageRef = ref();
  5150. const {
  5151. $Lazyload
  5152. } = getCurrentInstance().proxy;
  5153. const style = computed(() => {
  5154. const style2 = {
  5155. width: addUnit(props.width),
  5156. height: addUnit(props.height)
  5157. };
  5158. if (isDef(props.radius)) {
  5159. style2.overflow = "hidden";
  5160. style2.borderRadius = addUnit(props.radius);
  5161. }
  5162. return style2;
  5163. });
  5164. watch(() => props.src, () => {
  5165. error.value = false;
  5166. loading.value = true;
  5167. });
  5168. const onLoad = (event) => {
  5169. loading.value = false;
  5170. emit("load", event);
  5171. };
  5172. const onError = (event) => {
  5173. error.value = true;
  5174. loading.value = false;
  5175. emit("error", event);
  5176. };
  5177. const renderIcon = (name2, className, slot) => {
  5178. if (slot) {
  5179. return slot();
  5180. }
  5181. return createVNode(Icon, {
  5182. "name": name2,
  5183. "size": props.iconSize,
  5184. "class": className,
  5185. "classPrefix": props.iconPrefix
  5186. }, null);
  5187. };
  5188. const renderPlaceholder = () => {
  5189. if (loading.value && props.showLoading) {
  5190. return createVNode("div", {
  5191. "class": bem$10("loading")
  5192. }, [renderIcon(props.loadingIcon, bem$10("loading-icon"), slots.loading)]);
  5193. }
  5194. if (error.value && props.showError) {
  5195. return createVNode("div", {
  5196. "class": bem$10("error")
  5197. }, [renderIcon(props.errorIcon, bem$10("error-icon"), slots.error)]);
  5198. }
  5199. };
  5200. const renderImage = () => {
  5201. if (error.value || !props.src) {
  5202. return;
  5203. }
  5204. const attrs = {
  5205. alt: props.alt,
  5206. class: bem$10("img"),
  5207. style: {
  5208. objectFit: props.fit,
  5209. objectPosition: props.position
  5210. }
  5211. };
  5212. if (props.lazyLoad) {
  5213. return withDirectives(createVNode("img", mergeProps({
  5214. "ref": imageRef
  5215. }, attrs), null), [[resolveDirective("lazy"), props.src]]);
  5216. }
  5217. return createVNode("img", mergeProps({
  5218. "src": props.src,
  5219. "onLoad": onLoad,
  5220. "onError": onError
  5221. }, attrs), null);
  5222. };
  5223. const onLazyLoaded = ({
  5224. el
  5225. }) => {
  5226. const check = () => {
  5227. if (el === imageRef.value && loading.value) {
  5228. onLoad();
  5229. }
  5230. };
  5231. if (imageRef.value) {
  5232. check();
  5233. } else {
  5234. nextTick(check);
  5235. }
  5236. };
  5237. const onLazyLoadError = ({
  5238. el
  5239. }) => {
  5240. if (el === imageRef.value && !error.value) {
  5241. onError();
  5242. }
  5243. };
  5244. if ($Lazyload && inBrowser) {
  5245. $Lazyload.$on("loaded", onLazyLoaded);
  5246. $Lazyload.$on("error", onLazyLoadError);
  5247. onBeforeUnmount(() => {
  5248. $Lazyload.$off("loaded", onLazyLoaded);
  5249. $Lazyload.$off("error", onLazyLoadError);
  5250. });
  5251. }
  5252. return () => {
  5253. var _a;
  5254. return createVNode("div", {
  5255. "class": bem$10({
  5256. round: props.round,
  5257. block: props.block
  5258. }),
  5259. "style": style.value
  5260. }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  5261. };
  5262. }
  5263. });
  5264. const Image$1 = withInstall(stdin_default$17);
  5265. const [name$10, bem$$] = createNamespace("card");
  5266. const cardProps = {
  5267. tag: String,
  5268. num: numericProp,
  5269. desc: String,
  5270. thumb: String,
  5271. title: String,
  5272. price: numericProp,
  5273. centered: Boolean,
  5274. lazyLoad: Boolean,
  5275. currency: makeStringProp("\xA5"),
  5276. thumbLink: String,
  5277. originPrice: numericProp
  5278. };
  5279. var stdin_default$16 = defineComponent({
  5280. name: name$10,
  5281. props: cardProps,
  5282. emits: ["click-thumb"],
  5283. setup(props, {
  5284. slots,
  5285. emit
  5286. }) {
  5287. const renderTitle = () => {
  5288. if (slots.title) {
  5289. return slots.title();
  5290. }
  5291. if (props.title) {
  5292. return createVNode("div", {
  5293. "class": [bem$$("title"), "van-multi-ellipsis--l2"]
  5294. }, [props.title]);
  5295. }
  5296. };
  5297. const renderThumbTag = () => {
  5298. if (slots.tag || props.tag) {
  5299. return createVNode("div", {
  5300. "class": bem$$("tag")
  5301. }, [slots.tag ? slots.tag() : createVNode(Tag, {
  5302. "mark": true,
  5303. "type": "danger"
  5304. }, {
  5305. default: () => [props.tag]
  5306. })]);
  5307. }
  5308. };
  5309. const renderThumbImage = () => {
  5310. if (slots.thumb) {
  5311. return slots.thumb();
  5312. }
  5313. return createVNode(Image$1, {
  5314. "src": props.thumb,
  5315. "fit": "cover",
  5316. "width": "100%",
  5317. "height": "100%",
  5318. "lazyLoad": props.lazyLoad
  5319. }, null);
  5320. };
  5321. const renderThumb = () => {
  5322. if (slots.thumb || props.thumb) {
  5323. return createVNode("a", {
  5324. "href": props.thumbLink,
  5325. "class": bem$$("thumb"),
  5326. "onClick": (event) => emit("click-thumb", event)
  5327. }, [renderThumbImage(), renderThumbTag()]);
  5328. }
  5329. };
  5330. const renderDesc = () => {
  5331. if (slots.desc) {
  5332. return slots.desc();
  5333. }
  5334. if (props.desc) {
  5335. return createVNode("div", {
  5336. "class": [bem$$("desc"), "van-ellipsis"]
  5337. }, [props.desc]);
  5338. }
  5339. };
  5340. const renderPriceText = () => {
  5341. const priceArr = props.price.toString().split(".");
  5342. return createVNode("div", null, [createVNode("span", {
  5343. "class": bem$$("price-currency")
  5344. }, [props.currency]), createVNode("span", {
  5345. "class": bem$$("price-integer")
  5346. }, [priceArr[0]]), createTextVNode("."), createVNode("span", {
  5347. "class": bem$$("price-decimal")
  5348. }, [priceArr[1]])]);
  5349. };
  5350. return () => {
  5351. var _a, _b, _c;
  5352. const showNum = slots.num || isDef(props.num);
  5353. const showPrice = slots.price || isDef(props.price);
  5354. const showOriginPrice = slots["origin-price"] || isDef(props.originPrice);
  5355. const showBottom = showNum || showPrice || showOriginPrice || slots.bottom;
  5356. const Price = showPrice && createVNode("div", {
  5357. "class": bem$$("price")
  5358. }, [slots.price ? slots.price() : renderPriceText()]);
  5359. const OriginPrice = showOriginPrice && createVNode("div", {
  5360. "class": bem$$("origin-price")
  5361. }, [slots["origin-price"] ? slots["origin-price"]() : `${props.currency} ${props.originPrice}`]);
  5362. const Num = showNum && createVNode("div", {
  5363. "class": bem$$("num")
  5364. }, [slots.num ? slots.num() : `x${props.num}`]);
  5365. const Footer = slots.footer && createVNode("div", {
  5366. "class": bem$$("footer")
  5367. }, [slots.footer()]);
  5368. const Bottom = showBottom && createVNode("div", {
  5369. "class": bem$$("bottom")
  5370. }, [(_a = slots["price-top"]) == null ? void 0 : _a.call(slots), Price, OriginPrice, Num, (_b = slots.bottom) == null ? void 0 : _b.call(slots)]);
  5371. return createVNode("div", {
  5372. "class": bem$$()
  5373. }, [createVNode("div", {
  5374. "class": bem$$("header")
  5375. }, [renderThumb(), createVNode("div", {
  5376. "class": bem$$("content", {
  5377. centered: props.centered
  5378. })
  5379. }, [createVNode("div", null, [renderTitle(), renderDesc(), (_c = slots.tags) == null ? void 0 : _c.call(slots)]), Bottom])]), Footer]);
  5380. };
  5381. }
  5382. });
  5383. const Card = withInstall(stdin_default$16);
  5384. function scrollLeftTo(scroller, to, duration) {
  5385. let count = 0;
  5386. const from = scroller.scrollLeft;
  5387. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  5388. function animate() {
  5389. scroller.scrollLeft += (to - from) / frames;
  5390. if (++count < frames) {
  5391. raf(animate);
  5392. }
  5393. }
  5394. animate();
  5395. }
  5396. function scrollTopTo(scroller, to, duration, callback) {
  5397. let current2 = getScrollTop(scroller);
  5398. const isDown = current2 < to;
  5399. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  5400. const step = (to - current2) / frames;
  5401. function animate() {
  5402. current2 += step;
  5403. if (isDown && current2 > to || !isDown && current2 < to) {
  5404. current2 = to;
  5405. }
  5406. setScrollTop(scroller, current2);
  5407. if (isDown && current2 < to || !isDown && current2 > to) {
  5408. raf(animate);
  5409. } else if (callback) {
  5410. raf(callback);
  5411. }
  5412. }
  5413. animate();
  5414. }
  5415. function useVisibilityChange(target, onChange) {
  5416. if (!inBrowser || !window.IntersectionObserver) {
  5417. return;
  5418. }
  5419. const observer = new IntersectionObserver(
  5420. (entries) => {
  5421. onChange(entries[0].intersectionRatio > 0);
  5422. },
  5423. { root: document.body }
  5424. );
  5425. const observe = () => {
  5426. if (target.value) {
  5427. observer.observe(target.value);
  5428. }
  5429. };
  5430. const unobserve = () => {
  5431. if (target.value) {
  5432. observer.unobserve(target.value);
  5433. }
  5434. };
  5435. onDeactivated(unobserve);
  5436. onBeforeUnmount(unobserve);
  5437. onMountedOrActivated(observe);
  5438. }
  5439. const [name$$, bem$_] = createNamespace("sticky");
  5440. const stickyProps = {
  5441. zIndex: numericProp,
  5442. position: makeStringProp("top"),
  5443. container: Object,
  5444. offsetTop: makeNumericProp(0),
  5445. offsetBottom: makeNumericProp(0)
  5446. };
  5447. var stdin_default$15 = defineComponent({
  5448. name: name$$,
  5449. props: stickyProps,
  5450. emits: ["scroll", "change"],
  5451. setup(props, {
  5452. emit,
  5453. slots
  5454. }) {
  5455. const root = ref();
  5456. const scrollParent = useScrollParent(root);
  5457. const state = reactive({
  5458. fixed: false,
  5459. width: 0,
  5460. height: 0,
  5461. transform: 0
  5462. });
  5463. const offset = computed(() => unitToPx(props.position === "top" ? props.offsetTop : props.offsetBottom));
  5464. const rootStyle = computed(() => {
  5465. const {
  5466. fixed,
  5467. height,
  5468. width
  5469. } = state;
  5470. if (fixed) {
  5471. return {
  5472. width: `${width}px`,
  5473. height: `${height}px`
  5474. };
  5475. }
  5476. });
  5477. const stickyStyle = computed(() => {
  5478. if (!state.fixed) {
  5479. return;
  5480. }
  5481. const style = extend(getZIndexStyle(props.zIndex), {
  5482. width: `${state.width}px`,
  5483. height: `${state.height}px`,
  5484. [props.position]: `${offset.value}px`
  5485. });
  5486. if (state.transform) {
  5487. style.transform = `translate3d(0, ${state.transform}px, 0)`;
  5488. }
  5489. return style;
  5490. });
  5491. const emitScroll = (scrollTop) => emit("scroll", {
  5492. scrollTop,
  5493. isFixed: state.fixed
  5494. });
  5495. const onScroll = () => {
  5496. if (!root.value || isHidden(root)) {
  5497. return;
  5498. }
  5499. const {
  5500. container,
  5501. position
  5502. } = props;
  5503. const rootRect = useRect(root);
  5504. const scrollTop = getScrollTop(window);
  5505. state.width = rootRect.width;
  5506. state.height = rootRect.height;
  5507. if (position === "top") {
  5508. if (container) {
  5509. const containerRect = useRect(container);
  5510. const difference = containerRect.bottom - offset.value - state.height;
  5511. state.fixed = offset.value > rootRect.top && containerRect.bottom > 0;
  5512. state.transform = difference < 0 ? difference : 0;
  5513. } else {
  5514. state.fixed = offset.value > rootRect.top;
  5515. }
  5516. } else {
  5517. const {
  5518. clientHeight
  5519. } = document.documentElement;
  5520. if (container) {
  5521. const containerRect = useRect(container);
  5522. const difference = clientHeight - containerRect.top - offset.value - state.height;
  5523. state.fixed = clientHeight - offset.value < rootRect.bottom && clientHeight > containerRect.top;
  5524. state.transform = difference < 0 ? -difference : 0;
  5525. } else {
  5526. state.fixed = clientHeight - offset.value < rootRect.bottom;
  5527. }
  5528. }
  5529. emitScroll(scrollTop);
  5530. };
  5531. watch(() => state.fixed, (value) => emit("change", value));
  5532. useEventListener("scroll", onScroll, {
  5533. target: scrollParent,
  5534. passive: true
  5535. });
  5536. useVisibilityChange(root, onScroll);
  5537. return () => {
  5538. var _a;
  5539. return createVNode("div", {
  5540. "ref": root,
  5541. "style": rootStyle.value
  5542. }, [createVNode("div", {
  5543. "class": bem$_({
  5544. fixed: state.fixed
  5545. }),
  5546. "style": stickyStyle.value
  5547. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  5548. };
  5549. }
  5550. });
  5551. const Sticky = withInstall(stdin_default$15);
  5552. const [name$_, bem$Z] = createNamespace("tab");
  5553. var stdin_default$14 = defineComponent({
  5554. name: name$_,
  5555. props: {
  5556. id: String,
  5557. dot: Boolean,
  5558. type: String,
  5559. color: String,
  5560. title: String,
  5561. badge: numericProp,
  5562. shrink: Boolean,
  5563. isActive: Boolean,
  5564. disabled: Boolean,
  5565. controls: String,
  5566. scrollable: Boolean,
  5567. activeColor: String,
  5568. inactiveColor: String,
  5569. showZeroBadge: truthProp
  5570. },
  5571. setup(props, {
  5572. slots
  5573. }) {
  5574. const style = computed(() => {
  5575. const style2 = {};
  5576. const {
  5577. type,
  5578. color,
  5579. disabled,
  5580. isActive,
  5581. activeColor,
  5582. inactiveColor
  5583. } = props;
  5584. const isCard = type === "card";
  5585. if (color && isCard) {
  5586. style2.borderColor = color;
  5587. if (!disabled) {
  5588. if (isActive) {
  5589. style2.backgroundColor = color;
  5590. } else {
  5591. style2.color = color;
  5592. }
  5593. }
  5594. }
  5595. const titleColor = isActive ? activeColor : inactiveColor;
  5596. if (titleColor) {
  5597. style2.color = titleColor;
  5598. }
  5599. return style2;
  5600. });
  5601. const renderText = () => {
  5602. const Text2 = createVNode("span", {
  5603. "class": bem$Z("text", {
  5604. ellipsis: !props.scrollable
  5605. })
  5606. }, [slots.title ? slots.title() : props.title]);
  5607. if (props.dot || isDef(props.badge) && props.badge !== "") {
  5608. return createVNode(Badge, {
  5609. "dot": props.dot,
  5610. "content": props.badge,
  5611. "showZero": props.showZeroBadge
  5612. }, {
  5613. default: () => [Text2]
  5614. });
  5615. }
  5616. return Text2;
  5617. };
  5618. return () => createVNode("div", {
  5619. "id": props.id,
  5620. "role": "tab",
  5621. "class": [bem$Z([props.type, {
  5622. grow: props.scrollable && !props.shrink,
  5623. shrink: props.shrink,
  5624. active: props.isActive,
  5625. disabled: props.disabled
  5626. }])],
  5627. "style": style.value,
  5628. "tabindex": props.disabled ? void 0 : props.isActive ? 0 : -1,
  5629. "aria-selected": props.isActive,
  5630. "aria-disabled": props.disabled || void 0,
  5631. "aria-controls": props.controls
  5632. }, [renderText()]);
  5633. }
  5634. });
  5635. const [name$Z, bem$Y] = createNamespace("swipe");
  5636. const swipeProps = {
  5637. loop: truthProp,
  5638. width: numericProp,
  5639. height: numericProp,
  5640. vertical: Boolean,
  5641. autoplay: makeNumericProp(0),
  5642. duration: makeNumericProp(500),
  5643. touchable: truthProp,
  5644. lazyRender: Boolean,
  5645. initialSwipe: makeNumericProp(0),
  5646. indicatorColor: String,
  5647. showIndicators: truthProp,
  5648. stopPropagation: truthProp
  5649. };
  5650. const SWIPE_KEY = Symbol(name$Z);
  5651. var stdin_default$13 = defineComponent({
  5652. name: name$Z,
  5653. props: swipeProps,
  5654. emits: ["change"],
  5655. setup(props, {
  5656. emit,
  5657. slots
  5658. }) {
  5659. const root = ref();
  5660. const track = ref();
  5661. const state = reactive({
  5662. rect: null,
  5663. width: 0,
  5664. height: 0,
  5665. offset: 0,
  5666. active: 0,
  5667. swiping: false
  5668. });
  5669. const touch = useTouch();
  5670. const {
  5671. children,
  5672. linkChildren
  5673. } = useChildren(SWIPE_KEY);
  5674. const count = computed(() => children.length);
  5675. const size = computed(() => state[props.vertical ? "height" : "width"]);
  5676. const delta = computed(() => props.vertical ? touch.deltaY.value : touch.deltaX.value);
  5677. const minOffset = computed(() => {
  5678. if (state.rect) {
  5679. const base = props.vertical ? state.rect.height : state.rect.width;
  5680. return base - size.value * count.value;
  5681. }
  5682. return 0;
  5683. });
  5684. const maxCount = computed(() => Math.ceil(Math.abs(minOffset.value) / size.value));
  5685. const trackSize = computed(() => count.value * size.value);
  5686. const activeIndicator = computed(() => (state.active + count.value) % count.value);
  5687. const isCorrectDirection = computed(() => {
  5688. const expect = props.vertical ? "vertical" : "horizontal";
  5689. return touch.direction.value === expect;
  5690. });
  5691. const trackStyle = computed(() => {
  5692. const style = {
  5693. transitionDuration: `${state.swiping ? 0 : props.duration}ms`,
  5694. transform: `translate${props.vertical ? "Y" : "X"}(${state.offset}px)`
  5695. };
  5696. if (size.value) {
  5697. const mainAxis = props.vertical ? "height" : "width";
  5698. const crossAxis = props.vertical ? "width" : "height";
  5699. style[mainAxis] = `${trackSize.value}px`;
  5700. style[crossAxis] = props[crossAxis] ? `${props[crossAxis]}px` : "";
  5701. }
  5702. return style;
  5703. });
  5704. const getTargetActive = (pace) => {
  5705. const {
  5706. active
  5707. } = state;
  5708. if (pace) {
  5709. if (props.loop) {
  5710. return clamp(active + pace, -1, count.value);
  5711. }
  5712. return clamp(active + pace, 0, maxCount.value);
  5713. }
  5714. return active;
  5715. };
  5716. const getTargetOffset = (targetActive, offset = 0) => {
  5717. let currentPosition = targetActive * size.value;
  5718. if (!props.loop) {
  5719. currentPosition = Math.min(currentPosition, -minOffset.value);
  5720. }
  5721. let targetOffset = offset - currentPosition;
  5722. if (!props.loop) {
  5723. targetOffset = clamp(targetOffset, minOffset.value, 0);
  5724. }
  5725. return targetOffset;
  5726. };
  5727. const move = ({
  5728. pace = 0,
  5729. offset = 0,
  5730. emitChange
  5731. }) => {
  5732. if (count.value <= 1) {
  5733. return;
  5734. }
  5735. const {
  5736. active
  5737. } = state;
  5738. const targetActive = getTargetActive(pace);
  5739. const targetOffset = getTargetOffset(targetActive, offset);
  5740. if (props.loop) {
  5741. if (children[0] && targetOffset !== minOffset.value) {
  5742. const outRightBound = targetOffset < minOffset.value;
  5743. children[0].setOffset(outRightBound ? trackSize.value : 0);
  5744. }
  5745. if (children[count.value - 1] && targetOffset !== 0) {
  5746. const outLeftBound = targetOffset > 0;
  5747. children[count.value - 1].setOffset(outLeftBound ? -trackSize.value : 0);
  5748. }
  5749. }
  5750. state.active = targetActive;
  5751. state.offset = targetOffset;
  5752. if (emitChange && targetActive !== active) {
  5753. emit("change", activeIndicator.value);
  5754. }
  5755. };
  5756. const correctPosition = () => {
  5757. state.swiping = true;
  5758. if (state.active <= -1) {
  5759. move({
  5760. pace: count.value
  5761. });
  5762. } else if (state.active >= count.value) {
  5763. move({
  5764. pace: -count.value
  5765. });
  5766. }
  5767. };
  5768. const prev = () => {
  5769. correctPosition();
  5770. touch.reset();
  5771. doubleRaf(() => {
  5772. state.swiping = false;
  5773. move({
  5774. pace: -1,
  5775. emitChange: true
  5776. });
  5777. });
  5778. };
  5779. const next = () => {
  5780. correctPosition();
  5781. touch.reset();
  5782. doubleRaf(() => {
  5783. state.swiping = false;
  5784. move({
  5785. pace: 1,
  5786. emitChange: true
  5787. });
  5788. });
  5789. };
  5790. let autoplayTimer;
  5791. const stopAutoplay = () => clearTimeout(autoplayTimer);
  5792. const autoplay = () => {
  5793. stopAutoplay();
  5794. if (props.autoplay > 0 && count.value > 1) {
  5795. autoplayTimer = setTimeout(() => {
  5796. next();
  5797. autoplay();
  5798. }, +props.autoplay);
  5799. }
  5800. };
  5801. const initialize = (active = +props.initialSwipe) => {
  5802. if (!root.value) {
  5803. return;
  5804. }
  5805. const cb = () => {
  5806. var _a, _b;
  5807. if (!isHidden(root)) {
  5808. const rect = {
  5809. width: root.value.offsetWidth,
  5810. height: root.value.offsetHeight
  5811. };
  5812. state.rect = rect;
  5813. state.width = +((_a = props.width) != null ? _a : rect.width);
  5814. state.height = +((_b = props.height) != null ? _b : rect.height);
  5815. }
  5816. if (count.value) {
  5817. active = Math.min(count.value - 1, active);
  5818. }
  5819. state.active = active;
  5820. state.swiping = true;
  5821. state.offset = getTargetOffset(active);
  5822. children.forEach((swipe) => {
  5823. swipe.setOffset(0);
  5824. });
  5825. autoplay();
  5826. };
  5827. if (isHidden(root)) {
  5828. nextTick().then(cb);
  5829. } else {
  5830. cb();
  5831. }
  5832. };
  5833. const resize = () => initialize(state.active);
  5834. let touchStartTime;
  5835. const onTouchStart = (event) => {
  5836. if (!props.touchable)
  5837. return;
  5838. touch.start(event);
  5839. touchStartTime = Date.now();
  5840. stopAutoplay();
  5841. correctPosition();
  5842. };
  5843. const onTouchMove = (event) => {
  5844. if (props.touchable && state.swiping) {
  5845. touch.move(event);
  5846. if (isCorrectDirection.value) {
  5847. const isEdgeTouch = !props.loop && (state.active === 0 && delta.value > 0 || state.active === count.value - 1 && delta.value < 0);
  5848. if (!isEdgeTouch) {
  5849. preventDefault(event, props.stopPropagation);
  5850. move({
  5851. offset: delta.value
  5852. });
  5853. }
  5854. }
  5855. }
  5856. };
  5857. const onTouchEnd = () => {
  5858. if (!props.touchable || !state.swiping) {
  5859. return;
  5860. }
  5861. const duration = Date.now() - touchStartTime;
  5862. const speed = delta.value / duration;
  5863. const shouldSwipe = Math.abs(speed) > 0.25 || Math.abs(delta.value) > size.value / 2;
  5864. if (shouldSwipe && isCorrectDirection.value) {
  5865. const offset = props.vertical ? touch.offsetY.value : touch.offsetX.value;
  5866. let pace = 0;
  5867. if (props.loop) {
  5868. pace = offset > 0 ? delta.value > 0 ? -1 : 1 : 0;
  5869. } else {
  5870. pace = -Math[delta.value > 0 ? "ceil" : "floor"](delta.value / size.value);
  5871. }
  5872. move({
  5873. pace,
  5874. emitChange: true
  5875. });
  5876. } else if (delta.value) {
  5877. move({
  5878. pace: 0
  5879. });
  5880. }
  5881. state.swiping = false;
  5882. autoplay();
  5883. };
  5884. const swipeTo = (index, options = {}) => {
  5885. correctPosition();
  5886. touch.reset();
  5887. doubleRaf(() => {
  5888. let targetIndex;
  5889. if (props.loop && index === count.value) {
  5890. targetIndex = state.active === 0 ? 0 : index;
  5891. } else {
  5892. targetIndex = index % count.value;
  5893. }
  5894. if (options.immediate) {
  5895. doubleRaf(() => {
  5896. state.swiping = false;
  5897. });
  5898. } else {
  5899. state.swiping = false;
  5900. }
  5901. move({
  5902. pace: targetIndex - state.active,
  5903. emitChange: true
  5904. });
  5905. });
  5906. };
  5907. const renderDot = (_, index) => {
  5908. const active = index === activeIndicator.value;
  5909. const style = active ? {
  5910. backgroundColor: props.indicatorColor
  5911. } : void 0;
  5912. return createVNode("i", {
  5913. "style": style,
  5914. "class": bem$Y("indicator", {
  5915. active
  5916. })
  5917. }, null);
  5918. };
  5919. const renderIndicator = () => {
  5920. if (slots.indicator) {
  5921. return slots.indicator({
  5922. active: activeIndicator.value,
  5923. total: count.value
  5924. });
  5925. }
  5926. if (props.showIndicators && count.value > 1) {
  5927. return createVNode("div", {
  5928. "class": bem$Y("indicators", {
  5929. vertical: props.vertical
  5930. })
  5931. }, [Array(count.value).fill("").map(renderDot)]);
  5932. }
  5933. };
  5934. useExpose({
  5935. prev,
  5936. next,
  5937. state,
  5938. resize,
  5939. swipeTo
  5940. });
  5941. linkChildren({
  5942. size,
  5943. props,
  5944. count,
  5945. activeIndicator
  5946. });
  5947. watch(() => props.initialSwipe, (value) => initialize(+value));
  5948. watch(count, () => initialize(state.active));
  5949. watch(() => props.autoplay, autoplay);
  5950. watch([windowWidth, windowHeight], resize);
  5951. watch(usePageVisibility(), (visible) => {
  5952. if (visible === "visible") {
  5953. autoplay();
  5954. } else {
  5955. stopAutoplay();
  5956. }
  5957. });
  5958. onMounted(initialize);
  5959. onActivated(() => initialize(state.active));
  5960. onPopupReopen(() => initialize(state.active));
  5961. onDeactivated(stopAutoplay);
  5962. onBeforeUnmount(stopAutoplay);
  5963. useEventListener("touchmove", onTouchMove, {
  5964. target: track
  5965. });
  5966. return () => {
  5967. var _a;
  5968. return createVNode("div", {
  5969. "ref": root,
  5970. "class": bem$Y()
  5971. }, [createVNode("div", {
  5972. "ref": track,
  5973. "style": trackStyle.value,
  5974. "class": bem$Y("track", {
  5975. vertical: props.vertical
  5976. }),
  5977. "onTouchstartPassive": onTouchStart,
  5978. "onTouchend": onTouchEnd,
  5979. "onTouchcancel": onTouchEnd
  5980. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), renderIndicator()]);
  5981. };
  5982. }
  5983. });
  5984. const Swipe = withInstall(stdin_default$13);
  5985. const [name$Y, bem$X] = createNamespace("tabs");
  5986. var stdin_default$12 = defineComponent({
  5987. name: name$Y,
  5988. props: {
  5989. count: makeRequiredProp(Number),
  5990. inited: Boolean,
  5991. animated: Boolean,
  5992. duration: makeRequiredProp(numericProp),
  5993. swipeable: Boolean,
  5994. lazyRender: Boolean,
  5995. currentIndex: makeRequiredProp(Number)
  5996. },
  5997. emits: ["change"],
  5998. setup(props, {
  5999. emit,
  6000. slots
  6001. }) {
  6002. const swipeRef = ref();
  6003. const onChange = (index) => emit("change", index);
  6004. const renderChildren = () => {
  6005. var _a;
  6006. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  6007. if (props.animated || props.swipeable) {
  6008. return createVNode(Swipe, {
  6009. "ref": swipeRef,
  6010. "loop": false,
  6011. "class": bem$X("track"),
  6012. "duration": +props.duration * 1e3,
  6013. "touchable": props.swipeable,
  6014. "lazyRender": props.lazyRender,
  6015. "showIndicators": false,
  6016. "onChange": onChange
  6017. }, {
  6018. default: () => [Content]
  6019. });
  6020. }
  6021. return Content;
  6022. };
  6023. const swipeToCurrentTab = (index) => {
  6024. const swipe = swipeRef.value;
  6025. if (swipe && swipe.state.active !== index) {
  6026. swipe.swipeTo(index, {
  6027. immediate: !props.inited
  6028. });
  6029. }
  6030. };
  6031. watch(() => props.currentIndex, swipeToCurrentTab);
  6032. onMounted(() => {
  6033. swipeToCurrentTab(props.currentIndex);
  6034. });
  6035. useExpose({
  6036. swipeRef
  6037. });
  6038. return () => createVNode("div", {
  6039. "class": bem$X("content", {
  6040. animated: props.animated || props.swipeable
  6041. })
  6042. }, [renderChildren()]);
  6043. }
  6044. });
  6045. const [name$X, bem$W] = createNamespace("tabs");
  6046. const tabsProps = {
  6047. type: makeStringProp("line"),
  6048. color: String,
  6049. border: Boolean,
  6050. sticky: Boolean,
  6051. shrink: Boolean,
  6052. active: makeNumericProp(0),
  6053. duration: makeNumericProp(0.3),
  6054. animated: Boolean,
  6055. ellipsis: truthProp,
  6056. swipeable: Boolean,
  6057. scrollspy: Boolean,
  6058. offsetTop: makeNumericProp(0),
  6059. background: String,
  6060. lazyRender: truthProp,
  6061. lineWidth: numericProp,
  6062. lineHeight: numericProp,
  6063. beforeChange: Function,
  6064. swipeThreshold: makeNumericProp(5),
  6065. titleActiveColor: String,
  6066. titleInactiveColor: String
  6067. };
  6068. const TABS_KEY = Symbol(name$X);
  6069. var stdin_default$11 = defineComponent({
  6070. name: name$X,
  6071. props: tabsProps,
  6072. emits: ["click", "change", "scroll", "disabled", "rendered", "click-tab", "update:active"],
  6073. setup(props, {
  6074. emit,
  6075. slots
  6076. }) {
  6077. var _a, _b;
  6078. if (process.env.NODE_ENV !== "production") {
  6079. const props2 = (_b = (_a = getCurrentInstance()) == null ? void 0 : _a.vnode) == null ? void 0 : _b.props;
  6080. if (props2 && "onClick" in props2) {
  6081. console.warn('[Vant] Tabs: "click" event is deprecated, using "click-tab" instead.');
  6082. }
  6083. if (props2 && "onDisabled" in props2) {
  6084. console.warn('[Vant] Tabs: "disabled" event is deprecated, using "click-tab" instead.');
  6085. }
  6086. }
  6087. let tabHeight;
  6088. let lockScroll;
  6089. let stickyFixed;
  6090. const root = ref();
  6091. const navRef = ref();
  6092. const wrapRef = ref();
  6093. const contentRef = ref();
  6094. const id = useId();
  6095. const scroller = useScrollParent(root);
  6096. const [titleRefs, setTitleRefs] = useRefs();
  6097. const {
  6098. children,
  6099. linkChildren
  6100. } = useChildren(TABS_KEY);
  6101. const state = reactive({
  6102. inited: false,
  6103. position: "",
  6104. lineStyle: {},
  6105. currentIndex: -1
  6106. });
  6107. const scrollable = computed(() => children.length > props.swipeThreshold || !props.ellipsis || props.shrink);
  6108. const navStyle = computed(() => ({
  6109. borderColor: props.color,
  6110. background: props.background
  6111. }));
  6112. const getTabName = (tab, index) => {
  6113. var _a2;
  6114. return (_a2 = tab.name) != null ? _a2 : index;
  6115. };
  6116. const currentName = computed(() => {
  6117. const activeTab = children[state.currentIndex];
  6118. if (activeTab) {
  6119. return getTabName(activeTab, state.currentIndex);
  6120. }
  6121. });
  6122. const offsetTopPx = computed(() => unitToPx(props.offsetTop));
  6123. const scrollOffset = computed(() => {
  6124. if (props.sticky) {
  6125. return offsetTopPx.value + tabHeight;
  6126. }
  6127. return 0;
  6128. });
  6129. const scrollIntoView = (immediate) => {
  6130. const nav = navRef.value;
  6131. const titles = titleRefs.value;
  6132. if (!scrollable.value || !nav || !titles || !titles[state.currentIndex]) {
  6133. return;
  6134. }
  6135. const title = titles[state.currentIndex].$el;
  6136. const to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
  6137. scrollLeftTo(nav, to, immediate ? 0 : +props.duration);
  6138. };
  6139. const setLine = () => {
  6140. const shouldAnimate = state.inited;
  6141. nextTick(() => {
  6142. const titles = titleRefs.value;
  6143. if (!titles || !titles[state.currentIndex] || props.type !== "line" || isHidden(root.value)) {
  6144. return;
  6145. }
  6146. const title = titles[state.currentIndex].$el;
  6147. const {
  6148. lineWidth,
  6149. lineHeight
  6150. } = props;
  6151. const left = title.offsetLeft + title.offsetWidth / 2;
  6152. const lineStyle = {
  6153. width: addUnit(lineWidth),
  6154. backgroundColor: props.color,
  6155. transform: `translateX(${left}px) translateX(-50%)`
  6156. };
  6157. if (shouldAnimate) {
  6158. lineStyle.transitionDuration = `${props.duration}s`;
  6159. }
  6160. if (isDef(lineHeight)) {
  6161. const height = addUnit(lineHeight);
  6162. lineStyle.height = height;
  6163. lineStyle.borderRadius = height;
  6164. }
  6165. state.lineStyle = lineStyle;
  6166. });
  6167. };
  6168. const findAvailableTab = (index) => {
  6169. const diff = index < state.currentIndex ? -1 : 1;
  6170. while (index >= 0 && index < children.length) {
  6171. if (!children[index].disabled) {
  6172. return index;
  6173. }
  6174. index += diff;
  6175. }
  6176. };
  6177. const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
  6178. const newIndex = findAvailableTab(currentIndex);
  6179. if (!isDef(newIndex)) {
  6180. return;
  6181. }
  6182. const newTab = children[newIndex];
  6183. const newName = getTabName(newTab, newIndex);
  6184. const shouldEmitChange = state.currentIndex !== null;
  6185. if (state.currentIndex !== newIndex) {
  6186. state.currentIndex = newIndex;
  6187. if (!skipScrollIntoView) {
  6188. scrollIntoView();
  6189. }
  6190. setLine();
  6191. }
  6192. if (newName !== props.active) {
  6193. emit("update:active", newName);
  6194. if (shouldEmitChange) {
  6195. emit("change", newName, newTab.title);
  6196. }
  6197. }
  6198. if (stickyFixed && !props.scrollspy) {
  6199. setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
  6200. }
  6201. };
  6202. const setCurrentIndexByName = (name2, skipScrollIntoView) => {
  6203. const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
  6204. const index = matched ? children.indexOf(matched) : 0;
  6205. setCurrentIndex(index, skipScrollIntoView);
  6206. };
  6207. const scrollToCurrentContent = (immediate = false) => {
  6208. if (props.scrollspy) {
  6209. const target = children[state.currentIndex].$el;
  6210. if (target && scroller.value) {
  6211. const to = getElementTop(target, scroller.value) - scrollOffset.value;
  6212. lockScroll = true;
  6213. scrollTopTo(scroller.value, to, immediate ? 0 : +props.duration, () => {
  6214. lockScroll = false;
  6215. });
  6216. }
  6217. }
  6218. };
  6219. const onClickTab = (item, index, event) => {
  6220. const {
  6221. title,
  6222. disabled
  6223. } = children[index];
  6224. const name2 = getTabName(children[index], index);
  6225. if (disabled) {
  6226. emit("disabled", name2, title);
  6227. } else {
  6228. callInterceptor(props.beforeChange, {
  6229. args: [name2],
  6230. done: () => {
  6231. setCurrentIndex(index);
  6232. scrollToCurrentContent();
  6233. }
  6234. });
  6235. emit("click", name2, title);
  6236. route(item);
  6237. }
  6238. emit("click-tab", {
  6239. name: name2,
  6240. title,
  6241. event,
  6242. disabled
  6243. });
  6244. };
  6245. const onStickyScroll = (params) => {
  6246. stickyFixed = params.isFixed;
  6247. emit("scroll", params);
  6248. };
  6249. const scrollTo = (name2) => {
  6250. nextTick(() => {
  6251. setCurrentIndexByName(name2);
  6252. scrollToCurrentContent(true);
  6253. });
  6254. };
  6255. const getCurrentIndexOnScroll = () => {
  6256. for (let index = 0; index < children.length; index++) {
  6257. const {
  6258. top
  6259. } = useRect(children[index].$el);
  6260. if (top > scrollOffset.value) {
  6261. return index === 0 ? 0 : index - 1;
  6262. }
  6263. }
  6264. return children.length - 1;
  6265. };
  6266. const onScroll = () => {
  6267. if (props.scrollspy && !lockScroll) {
  6268. const index = getCurrentIndexOnScroll();
  6269. setCurrentIndex(index);
  6270. }
  6271. };
  6272. const renderNav = () => children.map((item, index) => createVNode(stdin_default$14, mergeProps({
  6273. "key": item.id,
  6274. "id": `${id}-${index}`,
  6275. "ref": setTitleRefs(index),
  6276. "type": props.type,
  6277. "color": props.color,
  6278. "style": item.titleStyle,
  6279. "class": item.titleClass,
  6280. "shrink": props.shrink,
  6281. "isActive": index === state.currentIndex,
  6282. "controls": item.id,
  6283. "scrollable": scrollable.value,
  6284. "activeColor": props.titleActiveColor,
  6285. "inactiveColor": props.titleInactiveColor,
  6286. "onClick": (event) => onClickTab(item, index, event)
  6287. }, pick(item, ["dot", "badge", "title", "disabled", "showZeroBadge"])), {
  6288. title: item.$slots.title
  6289. }));
  6290. const renderLine = () => {
  6291. if (props.type === "line" && children.length) {
  6292. return createVNode("div", {
  6293. "class": bem$W("line"),
  6294. "style": state.lineStyle
  6295. }, null);
  6296. }
  6297. };
  6298. const renderHeader = () => {
  6299. var _a2, _b2, _c;
  6300. const {
  6301. type,
  6302. border,
  6303. sticky
  6304. } = props;
  6305. const Header = [createVNode("div", {
  6306. "ref": sticky ? void 0 : wrapRef,
  6307. "class": [bem$W("wrap"), {
  6308. [BORDER_TOP_BOTTOM]: type === "line" && border
  6309. }]
  6310. }, [createVNode("div", {
  6311. "ref": navRef,
  6312. "role": "tablist",
  6313. "class": bem$W("nav", [type, {
  6314. shrink: props.shrink,
  6315. complete: scrollable.value
  6316. }]),
  6317. "style": navStyle.value,
  6318. "aria-orientation": "horizontal"
  6319. }, [(_a2 = slots["nav-left"]) == null ? void 0 : _a2.call(slots), renderNav(), renderLine(), (_b2 = slots["nav-right"]) == null ? void 0 : _b2.call(slots)])]), (_c = slots["nav-bottom"]) == null ? void 0 : _c.call(slots)];
  6320. if (sticky) {
  6321. return createVNode("div", {
  6322. "ref": wrapRef
  6323. }, [Header]);
  6324. }
  6325. return Header;
  6326. };
  6327. watch([() => props.color, windowWidth], setLine);
  6328. watch(() => props.active, (value) => {
  6329. if (value !== currentName.value) {
  6330. setCurrentIndexByName(value);
  6331. }
  6332. });
  6333. watch(() => children.length, () => {
  6334. if (state.inited) {
  6335. setCurrentIndexByName(props.active);
  6336. setLine();
  6337. nextTick(() => {
  6338. scrollIntoView(true);
  6339. });
  6340. }
  6341. });
  6342. const init = () => {
  6343. setCurrentIndexByName(props.active, true);
  6344. nextTick(() => {
  6345. state.inited = true;
  6346. if (wrapRef.value) {
  6347. tabHeight = useRect(wrapRef.value).height;
  6348. }
  6349. scrollIntoView(true);
  6350. });
  6351. };
  6352. const onRendered = (name2, title) => emit("rendered", name2, title);
  6353. const resize = () => {
  6354. setLine();
  6355. nextTick(() => {
  6356. var _a2, _b2;
  6357. return (_b2 = (_a2 = contentRef.value) == null ? void 0 : _a2.swipeRef.value) == null ? void 0 : _b2.resize();
  6358. });
  6359. };
  6360. useExpose({
  6361. resize,
  6362. scrollTo
  6363. });
  6364. onActivated(setLine);
  6365. onPopupReopen(setLine);
  6366. onMountedOrActivated(init);
  6367. useEventListener("scroll", onScroll, {
  6368. target: scroller,
  6369. passive: true
  6370. });
  6371. linkChildren({
  6372. id,
  6373. props,
  6374. setLine,
  6375. onRendered,
  6376. currentName,
  6377. scrollIntoView
  6378. });
  6379. return () => createVNode("div", {
  6380. "ref": root,
  6381. "class": bem$W([props.type])
  6382. }, [props.sticky ? createVNode(Sticky, {
  6383. "container": root.value,
  6384. "offsetTop": offsetTopPx.value,
  6385. "onScroll": onStickyScroll
  6386. }, {
  6387. default: () => [renderHeader()]
  6388. }) : renderHeader(), createVNode(stdin_default$12, {
  6389. "ref": contentRef,
  6390. "count": children.length,
  6391. "inited": state.inited,
  6392. "animated": props.animated,
  6393. "duration": props.duration,
  6394. "swipeable": props.swipeable,
  6395. "lazyRender": props.lazyRender,
  6396. "currentIndex": state.currentIndex,
  6397. "onChange": setCurrentIndex
  6398. }, {
  6399. default: () => {
  6400. var _a2;
  6401. return [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)];
  6402. }
  6403. })]);
  6404. }
  6405. });
  6406. const TAB_STATUS_KEY = Symbol();
  6407. const useTabStatus = () => inject(TAB_STATUS_KEY, null);
  6408. const [name$W, bem$V] = createNamespace("swipe-item");
  6409. var stdin_default$10 = defineComponent({
  6410. name: name$W,
  6411. setup(props, {
  6412. slots
  6413. }) {
  6414. let rendered;
  6415. const state = reactive({
  6416. offset: 0,
  6417. inited: false,
  6418. mounted: false
  6419. });
  6420. const {
  6421. parent,
  6422. index
  6423. } = useParent(SWIPE_KEY);
  6424. if (!parent) {
  6425. if (process.env.NODE_ENV !== "production") {
  6426. console.error("[Vant] <SwipeItem> must be a child component of <Swipe>.");
  6427. }
  6428. return;
  6429. }
  6430. const style = computed(() => {
  6431. const style2 = {};
  6432. const {
  6433. vertical
  6434. } = parent.props;
  6435. if (parent.size.value) {
  6436. style2[vertical ? "height" : "width"] = `${parent.size.value}px`;
  6437. }
  6438. if (state.offset) {
  6439. style2.transform = `translate${vertical ? "Y" : "X"}(${state.offset}px)`;
  6440. }
  6441. return style2;
  6442. });
  6443. const shouldRender = computed(() => {
  6444. const {
  6445. loop,
  6446. lazyRender
  6447. } = parent.props;
  6448. if (!lazyRender || rendered) {
  6449. return true;
  6450. }
  6451. if (!state.mounted) {
  6452. return false;
  6453. }
  6454. const active = parent.activeIndicator.value;
  6455. const maxActive = parent.count.value - 1;
  6456. const prevActive = active === 0 && loop ? maxActive : active - 1;
  6457. const nextActive = active === maxActive && loop ? 0 : active + 1;
  6458. rendered = index.value === active || index.value === prevActive || index.value === nextActive;
  6459. return rendered;
  6460. });
  6461. const setOffset = (offset) => {
  6462. state.offset = offset;
  6463. };
  6464. onMounted(() => {
  6465. nextTick(() => {
  6466. state.mounted = true;
  6467. });
  6468. });
  6469. useExpose({
  6470. setOffset
  6471. });
  6472. return () => {
  6473. var _a;
  6474. return createVNode("div", {
  6475. "class": bem$V(),
  6476. "style": style.value
  6477. }, [shouldRender.value ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null]);
  6478. };
  6479. }
  6480. });
  6481. const SwipeItem = withInstall(stdin_default$10);
  6482. const [name$V, bem$U] = createNamespace("tab");
  6483. const tabProps = extend({}, routeProps, {
  6484. dot: Boolean,
  6485. name: numericProp,
  6486. badge: numericProp,
  6487. title: String,
  6488. disabled: Boolean,
  6489. titleClass: unknownProp,
  6490. titleStyle: [String, Object],
  6491. showZeroBadge: truthProp
  6492. });
  6493. var stdin_default$$ = defineComponent({
  6494. name: name$V,
  6495. props: tabProps,
  6496. setup(props, {
  6497. slots
  6498. }) {
  6499. const id = useId();
  6500. const inited = ref(false);
  6501. const {
  6502. parent,
  6503. index
  6504. } = useParent(TABS_KEY);
  6505. if (!parent) {
  6506. if (process.env.NODE_ENV !== "production") {
  6507. console.error("[Vant] <Tab> must be a child component of <Tabs>.");
  6508. }
  6509. return;
  6510. }
  6511. const getName = () => {
  6512. var _a;
  6513. return (_a = props.name) != null ? _a : index.value;
  6514. };
  6515. const init = () => {
  6516. inited.value = true;
  6517. if (parent.props.lazyRender) {
  6518. nextTick(() => {
  6519. parent.onRendered(getName(), props.title);
  6520. });
  6521. }
  6522. };
  6523. const active = computed(() => {
  6524. const isActive = getName() === parent.currentName.value;
  6525. if (isActive && !inited.value) {
  6526. init();
  6527. }
  6528. return isActive;
  6529. });
  6530. const hasInactiveClass = ref(!active.value);
  6531. watch(active, (val) => {
  6532. if (val) {
  6533. hasInactiveClass.value = false;
  6534. } else {
  6535. doubleRaf(() => {
  6536. hasInactiveClass.value = true;
  6537. });
  6538. }
  6539. });
  6540. watch(() => props.title, () => {
  6541. parent.setLine();
  6542. parent.scrollIntoView();
  6543. });
  6544. provide(TAB_STATUS_KEY, active);
  6545. return () => {
  6546. var _a;
  6547. const label = `${parent.id}-${index.value}`;
  6548. const {
  6549. animated,
  6550. swipeable,
  6551. scrollspy,
  6552. lazyRender
  6553. } = parent.props;
  6554. if (!slots.default && !animated) {
  6555. return;
  6556. }
  6557. const show = scrollspy || active.value;
  6558. if (animated || swipeable) {
  6559. return createVNode(SwipeItem, {
  6560. "id": id,
  6561. "role": "tabpanel",
  6562. "class": bem$U("panel-wrapper", {
  6563. inactive: hasInactiveClass.value
  6564. }),
  6565. "tabindex": active.value ? 0 : -1,
  6566. "aria-hidden": !active.value,
  6567. "aria-labelledby": label
  6568. }, {
  6569. default: () => {
  6570. var _a2;
  6571. return [createVNode("div", {
  6572. "class": bem$U("panel")
  6573. }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])];
  6574. }
  6575. });
  6576. }
  6577. const shouldRender = inited.value || scrollspy || !lazyRender;
  6578. const Content = shouldRender ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null;
  6579. useExpose({
  6580. id
  6581. });
  6582. return withDirectives(createVNode("div", {
  6583. "id": id,
  6584. "role": "tabpanel",
  6585. "class": bem$U("panel"),
  6586. "tabindex": show ? 0 : -1,
  6587. "aria-labelledby": label
  6588. }, [Content]), [[vShow, show]]);
  6589. };
  6590. }
  6591. });
  6592. const Tab = withInstall(stdin_default$$);
  6593. const Tabs = withInstall(stdin_default$11);
  6594. const [name$U, bem$T, t$e] = createNamespace("cascader");
  6595. const cascaderProps = {
  6596. title: String,
  6597. options: makeArrayProp(),
  6598. closeable: truthProp,
  6599. swipeable: truthProp,
  6600. closeIcon: makeStringProp("cross"),
  6601. showHeader: truthProp,
  6602. modelValue: numericProp,
  6603. fieldNames: Object,
  6604. placeholder: String,
  6605. activeColor: String
  6606. };
  6607. var stdin_default$_ = defineComponent({
  6608. name: name$U,
  6609. props: cascaderProps,
  6610. emits: ["close", "change", "finish", "click-tab", "update:modelValue"],
  6611. setup(props, {
  6612. slots,
  6613. emit
  6614. }) {
  6615. const tabs = ref([]);
  6616. const activeTab = ref(0);
  6617. const {
  6618. text: textKey,
  6619. value: valueKey,
  6620. children: childrenKey
  6621. } = extend({
  6622. text: "text",
  6623. value: "value",
  6624. children: "children"
  6625. }, props.fieldNames);
  6626. const getSelectedOptionsByValue = (options, value) => {
  6627. for (const option of options) {
  6628. if (option[valueKey] === value) {
  6629. return [option];
  6630. }
  6631. if (option[childrenKey]) {
  6632. const selectedOptions = getSelectedOptionsByValue(option[childrenKey], value);
  6633. if (selectedOptions) {
  6634. return [option, ...selectedOptions];
  6635. }
  6636. }
  6637. }
  6638. };
  6639. const updateTabs = () => {
  6640. const {
  6641. options,
  6642. modelValue
  6643. } = props;
  6644. if (modelValue !== void 0) {
  6645. const selectedOptions = getSelectedOptionsByValue(options, modelValue);
  6646. if (selectedOptions) {
  6647. let optionsCursor = options;
  6648. tabs.value = selectedOptions.map((option) => {
  6649. const tab = {
  6650. options: optionsCursor,
  6651. selected: option
  6652. };
  6653. const next = optionsCursor.find((item) => item[valueKey] === option[valueKey]);
  6654. if (next) {
  6655. optionsCursor = next[childrenKey];
  6656. }
  6657. return tab;
  6658. });
  6659. if (optionsCursor) {
  6660. tabs.value.push({
  6661. options: optionsCursor,
  6662. selected: null
  6663. });
  6664. }
  6665. nextTick(() => {
  6666. activeTab.value = tabs.value.length - 1;
  6667. });
  6668. return;
  6669. }
  6670. }
  6671. tabs.value = [{
  6672. options,
  6673. selected: null
  6674. }];
  6675. };
  6676. const onSelect = (option, tabIndex) => {
  6677. if (option.disabled) {
  6678. return;
  6679. }
  6680. tabs.value[tabIndex].selected = option;
  6681. if (tabs.value.length > tabIndex + 1) {
  6682. tabs.value = tabs.value.slice(0, tabIndex + 1);
  6683. }
  6684. if (option[childrenKey]) {
  6685. const nextTab = {
  6686. options: option[childrenKey],
  6687. selected: null
  6688. };
  6689. if (tabs.value[tabIndex + 1]) {
  6690. tabs.value[tabIndex + 1] = nextTab;
  6691. } else {
  6692. tabs.value.push(nextTab);
  6693. }
  6694. nextTick(() => {
  6695. activeTab.value++;
  6696. });
  6697. }
  6698. const selectedOptions = tabs.value.map((tab) => tab.selected).filter(Boolean);
  6699. emit("update:modelValue", option[valueKey]);
  6700. const params = {
  6701. value: option[valueKey],
  6702. tabIndex,
  6703. selectedOptions
  6704. };
  6705. emit("change", params);
  6706. if (!option[childrenKey]) {
  6707. emit("finish", params);
  6708. }
  6709. };
  6710. const onClose = () => emit("close");
  6711. const onClickTab = ({
  6712. name: name2,
  6713. title
  6714. }) => emit("click-tab", name2, title);
  6715. const renderHeader = () => props.showHeader ? createVNode("div", {
  6716. "class": bem$T("header")
  6717. }, [createVNode("h2", {
  6718. "class": bem$T("title")
  6719. }, [slots.title ? slots.title() : props.title]), props.closeable ? createVNode(Icon, {
  6720. "name": props.closeIcon,
  6721. "class": [bem$T("close-icon"), HAPTICS_FEEDBACK],
  6722. "onClick": onClose
  6723. }, null) : null]) : null;
  6724. const renderOption = (option, selectedOption, tabIndex) => {
  6725. const {
  6726. disabled
  6727. } = option;
  6728. const selected = !!(selectedOption && option[valueKey] === selectedOption[valueKey]);
  6729. const color = option.color || (selected ? props.activeColor : void 0);
  6730. const Text2 = slots.option ? slots.option({
  6731. option,
  6732. selected
  6733. }) : createVNode("span", null, [option[textKey]]);
  6734. return createVNode("li", {
  6735. "role": "menuitemradio",
  6736. "class": [bem$T("option", {
  6737. selected,
  6738. disabled
  6739. }), option.className],
  6740. "style": {
  6741. color
  6742. },
  6743. "tabindex": disabled ? void 0 : selected ? 0 : -1,
  6744. "aria-checked": selected,
  6745. "aria-disabled": disabled || void 0,
  6746. "onClick": () => onSelect(option, tabIndex)
  6747. }, [Text2, selected ? createVNode(Icon, {
  6748. "name": "success",
  6749. "class": bem$T("selected-icon")
  6750. }, null) : null]);
  6751. };
  6752. const renderOptions = (options, selectedOption, tabIndex) => createVNode("ul", {
  6753. "role": "menu",
  6754. "class": bem$T("options")
  6755. }, [options.map((option) => renderOption(option, selectedOption, tabIndex))]);
  6756. const renderTab = (tab, tabIndex) => {
  6757. const {
  6758. options,
  6759. selected
  6760. } = tab;
  6761. const placeholder = props.placeholder || t$e("select");
  6762. const title = selected ? selected[textKey] : placeholder;
  6763. return createVNode(Tab, {
  6764. "title": title,
  6765. "titleClass": bem$T("tab", {
  6766. unselected: !selected
  6767. })
  6768. }, {
  6769. default: () => {
  6770. var _a, _b;
  6771. return [(_a = slots["options-top"]) == null ? void 0 : _a.call(slots, {
  6772. tabIndex
  6773. }), renderOptions(options, selected, tabIndex), (_b = slots["options-bottom"]) == null ? void 0 : _b.call(slots, {
  6774. tabIndex
  6775. })];
  6776. }
  6777. });
  6778. };
  6779. const renderTabs = () => createVNode(Tabs, {
  6780. "active": activeTab.value,
  6781. "onUpdate:active": ($event) => activeTab.value = $event,
  6782. "shrink": true,
  6783. "animated": true,
  6784. "class": bem$T("tabs"),
  6785. "color": props.activeColor,
  6786. "swipeable": props.swipeable,
  6787. "onClick-tab": onClickTab
  6788. }, {
  6789. default: () => [tabs.value.map(renderTab)]
  6790. });
  6791. updateTabs();
  6792. watch(() => props.options, updateTabs, {
  6793. deep: true
  6794. });
  6795. watch(() => props.modelValue, (value) => {
  6796. if (value !== void 0) {
  6797. const values = tabs.value.map((tab) => {
  6798. var _a;
  6799. return (_a = tab.selected) == null ? void 0 : _a[valueKey];
  6800. });
  6801. if (values.includes(value)) {
  6802. return;
  6803. }
  6804. }
  6805. updateTabs();
  6806. });
  6807. return () => createVNode("div", {
  6808. "class": bem$T()
  6809. }, [renderHeader(), renderTabs()]);
  6810. }
  6811. });
  6812. const Cascader = withInstall(stdin_default$_);
  6813. const [name$T, bem$S] = createNamespace("cell-group");
  6814. const cellGroupProps = {
  6815. title: String,
  6816. inset: Boolean,
  6817. border: truthProp
  6818. };
  6819. var stdin_default$Z = defineComponent({
  6820. name: name$T,
  6821. inheritAttrs: false,
  6822. props: cellGroupProps,
  6823. setup(props, {
  6824. slots,
  6825. attrs
  6826. }) {
  6827. const renderGroup = () => {
  6828. var _a;
  6829. return createVNode("div", mergeProps({
  6830. "class": [bem$S({
  6831. inset: props.inset
  6832. }), {
  6833. [BORDER_TOP_BOTTOM]: props.border && !props.inset
  6834. }]
  6835. }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  6836. };
  6837. const renderTitle = () => createVNode("div", {
  6838. "class": bem$S("title", {
  6839. inset: props.inset
  6840. })
  6841. }, [slots.title ? slots.title() : props.title]);
  6842. return () => {
  6843. if (props.title || slots.title) {
  6844. return createVNode(Fragment, null, [renderTitle(), renderGroup()]);
  6845. }
  6846. return renderGroup();
  6847. };
  6848. }
  6849. });
  6850. const CellGroup = withInstall(stdin_default$Z);
  6851. const [name$S, bem$R] = createNamespace("checkbox-group");
  6852. const checkboxGroupProps = {
  6853. max: numericProp,
  6854. disabled: Boolean,
  6855. iconSize: numericProp,
  6856. direction: String,
  6857. modelValue: makeArrayProp(),
  6858. checkedColor: String
  6859. };
  6860. const CHECKBOX_GROUP_KEY = Symbol(name$S);
  6861. var stdin_default$Y = defineComponent({
  6862. name: name$S,
  6863. props: checkboxGroupProps,
  6864. emits: ["change", "update:modelValue"],
  6865. setup(props, {
  6866. emit,
  6867. slots
  6868. }) {
  6869. const {
  6870. children,
  6871. linkChildren
  6872. } = useChildren(CHECKBOX_GROUP_KEY);
  6873. const updateValue = (value) => emit("update:modelValue", value);
  6874. const toggleAll = (options = {}) => {
  6875. if (typeof options === "boolean") {
  6876. options = {
  6877. checked: options
  6878. };
  6879. }
  6880. const {
  6881. checked,
  6882. skipDisabled
  6883. } = options;
  6884. const checkedChildren = children.filter((item) => {
  6885. if (!item.props.bindGroup) {
  6886. return false;
  6887. }
  6888. if (item.props.disabled && skipDisabled) {
  6889. return item.checked.value;
  6890. }
  6891. return checked != null ? checked : !item.checked.value;
  6892. });
  6893. const names = checkedChildren.map((item) => item.name);
  6894. updateValue(names);
  6895. };
  6896. watch(() => props.modelValue, (value) => emit("change", value));
  6897. useExpose({
  6898. toggleAll
  6899. });
  6900. useCustomFieldValue(() => props.modelValue);
  6901. linkChildren({
  6902. props,
  6903. updateValue
  6904. });
  6905. return () => {
  6906. var _a;
  6907. return createVNode("div", {
  6908. "class": bem$R([props.direction])
  6909. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  6910. };
  6911. }
  6912. });
  6913. const [name$R, bem$Q] = createNamespace("checkbox");
  6914. const checkboxProps = extend({}, checkerProps, {
  6915. bindGroup: truthProp
  6916. });
  6917. var stdin_default$X = defineComponent({
  6918. name: name$R,
  6919. props: checkboxProps,
  6920. emits: ["change", "update:modelValue"],
  6921. setup(props, {
  6922. emit,
  6923. slots
  6924. }) {
  6925. const {
  6926. parent
  6927. } = useParent(CHECKBOX_GROUP_KEY);
  6928. const setParentValue = (checked2) => {
  6929. const {
  6930. name: name2
  6931. } = props;
  6932. const {
  6933. max,
  6934. modelValue
  6935. } = parent.props;
  6936. const value = modelValue.slice();
  6937. if (checked2) {
  6938. const overlimit = max && value.length >= max;
  6939. if (!overlimit && !value.includes(name2)) {
  6940. value.push(name2);
  6941. if (props.bindGroup) {
  6942. parent.updateValue(value);
  6943. }
  6944. }
  6945. } else {
  6946. const index = value.indexOf(name2);
  6947. if (index !== -1) {
  6948. value.splice(index, 1);
  6949. if (props.bindGroup) {
  6950. parent.updateValue(value);
  6951. }
  6952. }
  6953. }
  6954. };
  6955. const checked = computed(() => {
  6956. if (parent && props.bindGroup) {
  6957. return parent.props.modelValue.indexOf(props.name) !== -1;
  6958. }
  6959. return !!props.modelValue;
  6960. });
  6961. const toggle = (newValue = !checked.value) => {
  6962. if (parent && props.bindGroup) {
  6963. setParentValue(newValue);
  6964. } else {
  6965. emit("update:modelValue", newValue);
  6966. }
  6967. };
  6968. watch(() => props.modelValue, (value) => emit("change", value));
  6969. useExpose({
  6970. toggle,
  6971. props,
  6972. checked
  6973. });
  6974. useCustomFieldValue(() => props.modelValue);
  6975. return () => createVNode(stdin_default$1f, mergeProps({
  6976. "bem": bem$Q,
  6977. "role": "checkbox",
  6978. "parent": parent,
  6979. "checked": checked.value,
  6980. "onToggle": toggle
  6981. }, props), pick(slots, ["default", "icon"]));
  6982. }
  6983. });
  6984. const Checkbox = withInstall(stdin_default$X);
  6985. const CheckboxGroup = withInstall(stdin_default$Y);
  6986. const [name$Q, bem$P] = createNamespace("circle");
  6987. let uid = 0;
  6988. const format = (rate) => Math.min(Math.max(+rate, 0), 100);
  6989. function getPath(clockwise, viewBoxSize) {
  6990. const sweepFlag = clockwise ? 1 : 0;
  6991. return `M ${viewBoxSize / 2} ${viewBoxSize / 2} m 0, -500 a 500, 500 0 1, ${sweepFlag} 0, 1000 a 500, 500 0 1, ${sweepFlag} 0, -1000`;
  6992. }
  6993. const circleProps = {
  6994. text: String,
  6995. size: numericProp,
  6996. fill: makeStringProp("none"),
  6997. rate: makeNumericProp(100),
  6998. speed: makeNumericProp(0),
  6999. color: [String, Object],
  7000. clockwise: truthProp,
  7001. layerColor: String,
  7002. currentRate: makeNumberProp(0),
  7003. strokeWidth: makeNumericProp(40),
  7004. strokeLinecap: String,
  7005. startPosition: makeStringProp("top")
  7006. };
  7007. var stdin_default$W = defineComponent({
  7008. name: name$Q,
  7009. props: circleProps,
  7010. emits: ["update:currentRate"],
  7011. setup(props, {
  7012. emit,
  7013. slots
  7014. }) {
  7015. const id = `van-circle-${uid++}`;
  7016. const viewBoxSize = computed(() => +props.strokeWidth + 1e3);
  7017. const path = computed(() => getPath(props.clockwise, viewBoxSize.value));
  7018. const svgStyle = computed(() => {
  7019. const ROTATE_ANGLE_MAP = {
  7020. top: 0,
  7021. right: 90,
  7022. bottom: 180,
  7023. left: 270
  7024. };
  7025. const angleValue = ROTATE_ANGLE_MAP[props.startPosition];
  7026. if (angleValue) {
  7027. return {
  7028. transform: `rotate(${angleValue}deg)`
  7029. };
  7030. }
  7031. });
  7032. watch(() => props.rate, (rate) => {
  7033. let rafId;
  7034. const startTime = Date.now();
  7035. const startRate = props.currentRate;
  7036. const endRate = format(rate);
  7037. const duration = Math.abs((startRate - endRate) * 1e3 / +props.speed);
  7038. const animate = () => {
  7039. const now = Date.now();
  7040. const progress = Math.min((now - startTime) / duration, 1);
  7041. const rate2 = progress * (endRate - startRate) + startRate;
  7042. emit("update:currentRate", format(parseFloat(rate2.toFixed(1))));
  7043. if (endRate > startRate ? rate2 < endRate : rate2 > endRate) {
  7044. rafId = raf(animate);
  7045. }
  7046. };
  7047. if (props.speed) {
  7048. if (rafId) {
  7049. cancelRaf(rafId);
  7050. }
  7051. rafId = raf(animate);
  7052. } else {
  7053. emit("update:currentRate", endRate);
  7054. }
  7055. }, {
  7056. immediate: true
  7057. });
  7058. const renderHover = () => {
  7059. const PERIMETER = 3140;
  7060. const {
  7061. strokeWidth,
  7062. currentRate,
  7063. strokeLinecap
  7064. } = props;
  7065. const offset = PERIMETER * currentRate / 100;
  7066. const color = isObject(props.color) ? `url(#${id})` : props.color;
  7067. const style = {
  7068. stroke: color,
  7069. strokeWidth: `${+strokeWidth + 1}px`,
  7070. strokeLinecap,
  7071. strokeDasharray: `${offset}px ${PERIMETER}px`
  7072. };
  7073. return createVNode("path", {
  7074. "d": path.value,
  7075. "style": style,
  7076. "class": bem$P("hover"),
  7077. "stroke": color
  7078. }, null);
  7079. };
  7080. const renderLayer = () => {
  7081. const style = {
  7082. fill: props.fill,
  7083. stroke: props.layerColor,
  7084. strokeWidth: `${props.strokeWidth}px`
  7085. };
  7086. return createVNode("path", {
  7087. "class": bem$P("layer"),
  7088. "style": style,
  7089. "d": path.value
  7090. }, null);
  7091. };
  7092. const renderGradient = () => {
  7093. const {
  7094. color
  7095. } = props;
  7096. if (!isObject(color)) {
  7097. return;
  7098. }
  7099. const Stops = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b)).map((key, index) => createVNode("stop", {
  7100. "key": index,
  7101. "offset": key,
  7102. "stop-color": color[key]
  7103. }, null));
  7104. return createVNode("defs", null, [createVNode("linearGradient", {
  7105. "id": id,
  7106. "x1": "100%",
  7107. "y1": "0%",
  7108. "x2": "0%",
  7109. "y2": "0%"
  7110. }, [Stops])]);
  7111. };
  7112. const renderText = () => {
  7113. if (slots.default) {
  7114. return slots.default();
  7115. }
  7116. if (props.text) {
  7117. return createVNode("div", {
  7118. "class": bem$P("text")
  7119. }, [props.text]);
  7120. }
  7121. };
  7122. return () => createVNode("div", {
  7123. "class": bem$P(),
  7124. "style": getSizeStyle(props.size)
  7125. }, [createVNode("svg", {
  7126. "viewBox": `0 0 ${viewBoxSize.value} ${viewBoxSize.value}`,
  7127. "style": svgStyle.value
  7128. }, [renderGradient(), renderLayer(), renderHover()]), renderText()]);
  7129. }
  7130. });
  7131. const Circle = withInstall(stdin_default$W);
  7132. const [name$P, bem$O] = createNamespace("row");
  7133. const ROW_KEY = Symbol(name$P);
  7134. const rowProps = {
  7135. tag: makeStringProp("div"),
  7136. wrap: truthProp,
  7137. align: String,
  7138. gutter: makeNumericProp(0),
  7139. justify: String
  7140. };
  7141. var stdin_default$V = defineComponent({
  7142. name: name$P,
  7143. props: rowProps,
  7144. setup(props, {
  7145. slots
  7146. }) {
  7147. const {
  7148. children,
  7149. linkChildren
  7150. } = useChildren(ROW_KEY);
  7151. const groups = computed(() => {
  7152. const groups2 = [[]];
  7153. let totalSpan = 0;
  7154. children.forEach((child, index) => {
  7155. totalSpan += Number(child.span);
  7156. if (totalSpan > 24) {
  7157. groups2.push([index]);
  7158. totalSpan -= 24;
  7159. } else {
  7160. groups2[groups2.length - 1].push(index);
  7161. }
  7162. });
  7163. return groups2;
  7164. });
  7165. const spaces = computed(() => {
  7166. const gutter = Number(props.gutter);
  7167. const spaces2 = [];
  7168. if (!gutter) {
  7169. return spaces2;
  7170. }
  7171. groups.value.forEach((group) => {
  7172. const averagePadding = gutter * (group.length - 1) / group.length;
  7173. group.forEach((item, index) => {
  7174. if (index === 0) {
  7175. spaces2.push({
  7176. right: averagePadding
  7177. });
  7178. } else {
  7179. const left = gutter - spaces2[item - 1].right;
  7180. const right = averagePadding - left;
  7181. spaces2.push({
  7182. left,
  7183. right
  7184. });
  7185. }
  7186. });
  7187. });
  7188. return spaces2;
  7189. });
  7190. linkChildren({
  7191. spaces
  7192. });
  7193. return () => {
  7194. const {
  7195. tag,
  7196. wrap,
  7197. align,
  7198. justify
  7199. } = props;
  7200. return createVNode(tag, {
  7201. "class": bem$O({
  7202. [`align-${align}`]: align,
  7203. [`justify-${justify}`]: justify,
  7204. nowrap: !wrap
  7205. })
  7206. }, {
  7207. default: () => {
  7208. var _a;
  7209. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  7210. }
  7211. });
  7212. };
  7213. }
  7214. });
  7215. const [name$O, bem$N] = createNamespace("col");
  7216. const colProps = {
  7217. tag: makeStringProp("div"),
  7218. span: makeNumericProp(0),
  7219. offset: numericProp
  7220. };
  7221. var stdin_default$U = defineComponent({
  7222. name: name$O,
  7223. props: colProps,
  7224. setup(props, {
  7225. slots
  7226. }) {
  7227. const {
  7228. parent,
  7229. index
  7230. } = useParent(ROW_KEY);
  7231. const style = computed(() => {
  7232. if (!parent) {
  7233. return;
  7234. }
  7235. const {
  7236. spaces
  7237. } = parent;
  7238. if (spaces && spaces.value && spaces.value[index.value]) {
  7239. const {
  7240. left,
  7241. right
  7242. } = spaces.value[index.value];
  7243. return {
  7244. paddingLeft: left ? `${left}px` : null,
  7245. paddingRight: right ? `${right}px` : null
  7246. };
  7247. }
  7248. });
  7249. return () => {
  7250. const {
  7251. tag,
  7252. span,
  7253. offset
  7254. } = props;
  7255. return createVNode(tag, {
  7256. "style": style.value,
  7257. "class": bem$N({
  7258. [span]: span,
  7259. [`offset-${offset}`]: offset
  7260. })
  7261. }, {
  7262. default: () => {
  7263. var _a;
  7264. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  7265. }
  7266. });
  7267. };
  7268. }
  7269. });
  7270. const Col = withInstall(stdin_default$U);
  7271. const [name$N, bem$M] = createNamespace("collapse");
  7272. const COLLAPSE_KEY = Symbol(name$N);
  7273. const collapseProps = {
  7274. border: truthProp,
  7275. accordion: Boolean,
  7276. modelValue: {
  7277. type: [String, Number, Array],
  7278. default: ""
  7279. }
  7280. };
  7281. function validateModelValue(modelValue, accordion) {
  7282. if (accordion && Array.isArray(modelValue)) {
  7283. console.error('[Vant] Collapse: "v-model" should not be Array in accordion mode');
  7284. return false;
  7285. }
  7286. if (!accordion && !Array.isArray(modelValue)) {
  7287. console.error('[Vant] Collapse: "v-model" should be Array in non-accordion mode');
  7288. return false;
  7289. }
  7290. return true;
  7291. }
  7292. var stdin_default$T = defineComponent({
  7293. name: name$N,
  7294. props: collapseProps,
  7295. emits: ["change", "update:modelValue"],
  7296. setup(props, {
  7297. emit,
  7298. slots
  7299. }) {
  7300. const {
  7301. linkChildren,
  7302. children
  7303. } = useChildren(COLLAPSE_KEY);
  7304. const updateName = (name2) => {
  7305. emit("change", name2);
  7306. emit("update:modelValue", name2);
  7307. };
  7308. const toggle = (name2, expanded) => {
  7309. const {
  7310. accordion,
  7311. modelValue
  7312. } = props;
  7313. if (accordion) {
  7314. updateName(name2 === modelValue ? "" : name2);
  7315. } else if (expanded) {
  7316. updateName(modelValue.concat(name2));
  7317. } else {
  7318. updateName(modelValue.filter((activeName) => activeName !== name2));
  7319. }
  7320. };
  7321. const toggleAll = (options = {}) => {
  7322. if (props.accordion) {
  7323. return;
  7324. }
  7325. if (typeof options === "boolean") {
  7326. options = {
  7327. expanded: options
  7328. };
  7329. }
  7330. const {
  7331. expanded,
  7332. skipDisabled
  7333. } = options;
  7334. const expandedChildren = children.filter((item) => {
  7335. if (item.disabled && skipDisabled) {
  7336. return item.expanded.value;
  7337. }
  7338. return expanded != null ? expanded : !item.expanded.value;
  7339. });
  7340. const names = expandedChildren.map((item) => item.itemName.value);
  7341. updateName(names);
  7342. };
  7343. const isExpanded = (name2) => {
  7344. const {
  7345. accordion,
  7346. modelValue
  7347. } = props;
  7348. if (process.env.NODE_ENV !== "production" && !validateModelValue(modelValue, accordion)) {
  7349. return false;
  7350. }
  7351. return accordion ? modelValue === name2 : modelValue.includes(name2);
  7352. };
  7353. useExpose({
  7354. toggleAll
  7355. });
  7356. linkChildren({
  7357. toggle,
  7358. isExpanded
  7359. });
  7360. return () => {
  7361. var _a;
  7362. return createVNode("div", {
  7363. "class": [bem$M(), {
  7364. [BORDER_TOP_BOTTOM]: props.border
  7365. }]
  7366. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7367. };
  7368. }
  7369. });
  7370. const Collapse = withInstall(stdin_default$T);
  7371. const [name$M, bem$L] = createNamespace("collapse-item");
  7372. const CELL_SLOTS = ["icon", "title", "value", "label", "right-icon"];
  7373. const collapseItemProps = extend({}, cellSharedProps, {
  7374. name: numericProp,
  7375. isLink: truthProp,
  7376. disabled: Boolean,
  7377. readonly: Boolean,
  7378. lazyRender: truthProp
  7379. });
  7380. var stdin_default$S = defineComponent({
  7381. name: name$M,
  7382. props: collapseItemProps,
  7383. setup(props, {
  7384. slots
  7385. }) {
  7386. const wrapperRef = ref();
  7387. const contentRef = ref();
  7388. const {
  7389. parent,
  7390. index
  7391. } = useParent(COLLAPSE_KEY);
  7392. if (!parent) {
  7393. if (process.env.NODE_ENV !== "production") {
  7394. console.error("[Vant] <CollapseItem> must be a child component of <Collapse>.");
  7395. }
  7396. return;
  7397. }
  7398. const name2 = computed(() => {
  7399. var _a;
  7400. return (_a = props.name) != null ? _a : index.value;
  7401. });
  7402. const expanded = computed(() => parent.isExpanded(name2.value));
  7403. const show = ref(expanded.value);
  7404. const lazyRender = useLazyRender(() => show.value || !props.lazyRender);
  7405. const onTransitionEnd = () => {
  7406. if (!expanded.value) {
  7407. show.value = false;
  7408. } else if (wrapperRef.value) {
  7409. wrapperRef.value.style.height = "";
  7410. }
  7411. };
  7412. watch(expanded, (value, oldValue) => {
  7413. if (oldValue === null) {
  7414. return;
  7415. }
  7416. if (value) {
  7417. show.value = true;
  7418. }
  7419. const tick = value ? nextTick : raf;
  7420. tick(() => {
  7421. if (!contentRef.value || !wrapperRef.value) {
  7422. return;
  7423. }
  7424. const {
  7425. offsetHeight
  7426. } = contentRef.value;
  7427. if (offsetHeight) {
  7428. const contentHeight = `${offsetHeight}px`;
  7429. wrapperRef.value.style.height = value ? "0" : contentHeight;
  7430. doubleRaf(() => {
  7431. if (wrapperRef.value) {
  7432. wrapperRef.value.style.height = value ? contentHeight : "0";
  7433. }
  7434. });
  7435. } else {
  7436. onTransitionEnd();
  7437. }
  7438. });
  7439. });
  7440. const toggle = (newValue = !expanded.value) => {
  7441. parent.toggle(name2.value, newValue);
  7442. };
  7443. const onClickTitle = () => {
  7444. if (!props.disabled && !props.readonly) {
  7445. toggle();
  7446. }
  7447. };
  7448. const renderTitle = () => {
  7449. const {
  7450. border,
  7451. disabled,
  7452. readonly
  7453. } = props;
  7454. const attrs = pick(props, Object.keys(cellSharedProps));
  7455. if (readonly) {
  7456. attrs.isLink = false;
  7457. }
  7458. if (disabled || readonly) {
  7459. attrs.clickable = false;
  7460. }
  7461. return createVNode(Cell, mergeProps({
  7462. "role": "button",
  7463. "class": bem$L("title", {
  7464. disabled,
  7465. expanded: expanded.value,
  7466. borderless: !border
  7467. }),
  7468. "aria-expanded": String(expanded.value),
  7469. "onClick": onClickTitle
  7470. }, attrs), pick(slots, CELL_SLOTS));
  7471. };
  7472. const renderContent = lazyRender(() => {
  7473. var _a;
  7474. return withDirectives(createVNode("div", {
  7475. "ref": wrapperRef,
  7476. "class": bem$L("wrapper"),
  7477. "onTransitionend": onTransitionEnd
  7478. }, [createVNode("div", {
  7479. "ref": contentRef,
  7480. "class": bem$L("content")
  7481. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]), [[vShow, show.value]]);
  7482. });
  7483. useExpose({
  7484. toggle,
  7485. expanded,
  7486. itemName: name2
  7487. });
  7488. return () => createVNode("div", {
  7489. "class": [bem$L({
  7490. border: index.value && props.border
  7491. })]
  7492. }, [renderTitle(), renderContent()]);
  7493. }
  7494. });
  7495. const CollapseItem = withInstall(stdin_default$S);
  7496. const ConfigProvider = withInstall(stdin_default$1A);
  7497. const [name$L, bem$K, t$d] = createNamespace("contact-card");
  7498. const contactCardProps = {
  7499. tel: String,
  7500. name: String,
  7501. type: makeStringProp("add"),
  7502. addText: String,
  7503. editable: truthProp
  7504. };
  7505. var stdin_default$R = defineComponent({
  7506. name: name$L,
  7507. props: contactCardProps,
  7508. emits: ["click"],
  7509. setup(props, {
  7510. emit
  7511. }) {
  7512. const onClick = (event) => {
  7513. if (props.editable) {
  7514. emit("click", event);
  7515. }
  7516. };
  7517. const renderContent = () => {
  7518. if (props.type === "add") {
  7519. return props.addText || t$d("addContact");
  7520. }
  7521. return [createVNode("div", null, [`${t$d("name")}\uFF1A${props.name}`]), createVNode("div", null, [`${t$d("tel")}\uFF1A${props.tel}`])];
  7522. };
  7523. return () => createVNode(Cell, {
  7524. "center": true,
  7525. "icon": props.type === "edit" ? "contact" : "add-square",
  7526. "class": bem$K([props.type]),
  7527. "border": false,
  7528. "isLink": props.editable,
  7529. "valueClass": bem$K("value"),
  7530. "onClick": onClick
  7531. }, {
  7532. value: renderContent
  7533. });
  7534. }
  7535. });
  7536. const ContactCard = withInstall(stdin_default$R);
  7537. const [name$K, bem$J, t$c] = createNamespace("contact-edit");
  7538. const DEFAULT_CONTACT = {
  7539. tel: "",
  7540. name: ""
  7541. };
  7542. const contactEditProps = {
  7543. isEdit: Boolean,
  7544. isSaving: Boolean,
  7545. isDeleting: Boolean,
  7546. showSetDefault: Boolean,
  7547. setDefaultLabel: String,
  7548. contactInfo: {
  7549. type: Object,
  7550. default: () => extend({}, DEFAULT_CONTACT)
  7551. },
  7552. telValidator: {
  7553. type: Function,
  7554. default: isMobile
  7555. }
  7556. };
  7557. var stdin_default$Q = defineComponent({
  7558. name: name$K,
  7559. props: contactEditProps,
  7560. emits: ["save", "delete", "change-default"],
  7561. setup(props, {
  7562. emit
  7563. }) {
  7564. const contact = reactive(extend({}, DEFAULT_CONTACT, props.contactInfo));
  7565. const onSave = () => {
  7566. if (!props.isSaving) {
  7567. emit("save", contact);
  7568. }
  7569. };
  7570. const onDelete = () => emit("delete", contact);
  7571. const renderButtons = () => createVNode("div", {
  7572. "class": bem$J("buttons")
  7573. }, [createVNode(Button, {
  7574. "block": true,
  7575. "round": true,
  7576. "type": "danger",
  7577. "text": t$c("save"),
  7578. "class": bem$J("button"),
  7579. "loading": props.isSaving,
  7580. "nativeType": "submit"
  7581. }, null), props.isEdit && createVNode(Button, {
  7582. "block": true,
  7583. "round": true,
  7584. "text": t$c("delete"),
  7585. "class": bem$J("button"),
  7586. "loading": props.isDeleting,
  7587. "onClick": onDelete
  7588. }, null)]);
  7589. const renderSwitch = () => createVNode(Switch, {
  7590. "modelValue": contact.isDefault,
  7591. "onUpdate:modelValue": ($event) => contact.isDefault = $event,
  7592. "size": 24,
  7593. "onChange": (checked) => emit("change-default", checked)
  7594. }, null);
  7595. const renderSetDefault = () => {
  7596. if (props.showSetDefault) {
  7597. return createVNode(Cell, {
  7598. "title": props.setDefaultLabel,
  7599. "class": bem$J("switch-cell"),
  7600. "border": false
  7601. }, {
  7602. "right-icon": renderSwitch
  7603. });
  7604. }
  7605. };
  7606. watch(() => props.contactInfo, (value) => extend(contact, DEFAULT_CONTACT, value));
  7607. return () => createVNode(Form, {
  7608. "class": bem$J(),
  7609. "onSubmit": onSave
  7610. }, {
  7611. default: () => [createVNode("div", {
  7612. "class": bem$J("fields")
  7613. }, [createVNode(Field, {
  7614. "modelValue": contact.name,
  7615. "onUpdate:modelValue": ($event) => contact.name = $event,
  7616. "clearable": true,
  7617. "label": t$c("name"),
  7618. "rules": [{
  7619. required: true,
  7620. message: t$c("nameEmpty")
  7621. }],
  7622. "maxlength": "30",
  7623. "placeholder": t$c("name")
  7624. }, null), createVNode(Field, {
  7625. "modelValue": contact.tel,
  7626. "onUpdate:modelValue": ($event) => contact.tel = $event,
  7627. "clearable": true,
  7628. "type": "tel",
  7629. "label": t$c("tel"),
  7630. "rules": [{
  7631. validator: props.telValidator,
  7632. message: t$c("telInvalid")
  7633. }],
  7634. "placeholder": t$c("tel")
  7635. }, null)]), renderSetDefault(), renderButtons()]
  7636. });
  7637. }
  7638. });
  7639. const ContactEdit = withInstall(stdin_default$Q);
  7640. const [name$J, bem$I, t$b] = createNamespace("contact-list");
  7641. const contactListProps = {
  7642. list: Array,
  7643. addText: String,
  7644. modelValue: unknownProp,
  7645. defaultTagText: String
  7646. };
  7647. var stdin_default$P = defineComponent({
  7648. name: name$J,
  7649. props: contactListProps,
  7650. emits: ["add", "edit", "select", "update:modelValue"],
  7651. setup(props, {
  7652. emit
  7653. }) {
  7654. const renderItem = (item, index) => {
  7655. const onClick = () => {
  7656. emit("update:modelValue", item.id);
  7657. emit("select", item, index);
  7658. };
  7659. const renderRightIcon = () => createVNode(Radio, {
  7660. "class": bem$I("radio"),
  7661. "name": item.id,
  7662. "iconSize": 16
  7663. }, null);
  7664. const renderEditIcon = () => createVNode(Icon, {
  7665. "name": "edit",
  7666. "class": bem$I("edit"),
  7667. "onClick": (event) => {
  7668. event.stopPropagation();
  7669. emit("edit", item, index);
  7670. }
  7671. }, null);
  7672. const renderContent = () => {
  7673. const nodes = [`${item.name}\uFF0C${item.tel}`];
  7674. if (item.isDefault && props.defaultTagText) {
  7675. nodes.push(createVNode(Tag, {
  7676. "type": "danger",
  7677. "round": true,
  7678. "class": bem$I("item-tag")
  7679. }, {
  7680. default: () => [props.defaultTagText]
  7681. }));
  7682. }
  7683. return nodes;
  7684. };
  7685. return createVNode(Cell, {
  7686. "key": item.id,
  7687. "isLink": true,
  7688. "center": true,
  7689. "class": bem$I("item"),
  7690. "valueClass": bem$I("item-value"),
  7691. "onClick": onClick
  7692. }, {
  7693. icon: renderEditIcon,
  7694. value: renderContent,
  7695. "right-icon": renderRightIcon
  7696. });
  7697. };
  7698. return () => createVNode("div", {
  7699. "class": bem$I()
  7700. }, [createVNode(RadioGroup, {
  7701. "modelValue": props.modelValue,
  7702. "class": bem$I("group")
  7703. }, {
  7704. default: () => [props.list && props.list.map(renderItem)]
  7705. }), createVNode("div", {
  7706. "class": [bem$I("bottom"), "van-safe-area-bottom"]
  7707. }, [createVNode(Button, {
  7708. "round": true,
  7709. "block": true,
  7710. "type": "danger",
  7711. "class": bem$I("add"),
  7712. "text": props.addText || t$b("addContact"),
  7713. "onClick": () => emit("add")
  7714. }, null)])]);
  7715. }
  7716. });
  7717. const ContactList = withInstall(stdin_default$P);
  7718. function parseFormat(format2, currentTime) {
  7719. const { days } = currentTime;
  7720. let { hours, minutes, seconds, milliseconds } = currentTime;
  7721. if (format2.includes("DD")) {
  7722. format2 = format2.replace("DD", padZero(days));
  7723. } else {
  7724. hours += days * 24;
  7725. }
  7726. if (format2.includes("HH")) {
  7727. format2 = format2.replace("HH", padZero(hours));
  7728. } else {
  7729. minutes += hours * 60;
  7730. }
  7731. if (format2.includes("mm")) {
  7732. format2 = format2.replace("mm", padZero(minutes));
  7733. } else {
  7734. seconds += minutes * 60;
  7735. }
  7736. if (format2.includes("ss")) {
  7737. format2 = format2.replace("ss", padZero(seconds));
  7738. } else {
  7739. milliseconds += seconds * 1e3;
  7740. }
  7741. if (format2.includes("S")) {
  7742. const ms = padZero(milliseconds, 3);
  7743. if (format2.includes("SSS")) {
  7744. format2 = format2.replace("SSS", ms);
  7745. } else if (format2.includes("SS")) {
  7746. format2 = format2.replace("SS", ms.slice(0, 2));
  7747. } else {
  7748. format2 = format2.replace("S", ms.charAt(0));
  7749. }
  7750. }
  7751. return format2;
  7752. }
  7753. const [name$I, bem$H] = createNamespace("count-down");
  7754. const countDownProps = {
  7755. time: makeNumericProp(0),
  7756. format: makeStringProp("HH:mm:ss"),
  7757. autoStart: truthProp,
  7758. millisecond: Boolean
  7759. };
  7760. var stdin_default$O = defineComponent({
  7761. name: name$I,
  7762. props: countDownProps,
  7763. emits: ["change", "finish"],
  7764. setup(props, {
  7765. emit,
  7766. slots
  7767. }) {
  7768. const {
  7769. start,
  7770. pause,
  7771. reset,
  7772. current: current2
  7773. } = useCountDown({
  7774. time: +props.time,
  7775. millisecond: props.millisecond,
  7776. onChange: (current22) => emit("change", current22),
  7777. onFinish: () => emit("finish")
  7778. });
  7779. const timeText = computed(() => parseFormat(props.format, current2.value));
  7780. const resetTime = () => {
  7781. reset(+props.time);
  7782. if (props.autoStart) {
  7783. start();
  7784. }
  7785. };
  7786. watch(() => props.time, resetTime, {
  7787. immediate: true
  7788. });
  7789. useExpose({
  7790. start,
  7791. pause,
  7792. reset: resetTime
  7793. });
  7794. return () => createVNode("div", {
  7795. "role": "timer",
  7796. "class": bem$H()
  7797. }, [slots.default ? slots.default(current2.value) : timeText.value]);
  7798. }
  7799. });
  7800. const CountDown = withInstall(stdin_default$O);
  7801. function getDate(timeStamp) {
  7802. const date = new Date(timeStamp * 1e3);
  7803. return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
  7804. date.getDate()
  7805. )}`;
  7806. }
  7807. const formatDiscount = (discount) => (discount / 10).toFixed(discount % 10 === 0 ? 0 : 1);
  7808. const formatAmount = (amount) => (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
  7809. const [name$H, bem$G, t$a] = createNamespace("coupon");
  7810. var stdin_default$N = defineComponent({
  7811. name: name$H,
  7812. props: {
  7813. chosen: Boolean,
  7814. coupon: makeRequiredProp(Object),
  7815. disabled: Boolean,
  7816. currency: makeStringProp("\xA5")
  7817. },
  7818. setup(props) {
  7819. const validPeriod = computed(() => {
  7820. const {
  7821. startAt,
  7822. endAt
  7823. } = props.coupon;
  7824. return `${getDate(startAt)} - ${getDate(endAt)}`;
  7825. });
  7826. const faceAmount = computed(() => {
  7827. const {
  7828. coupon,
  7829. currency
  7830. } = props;
  7831. if (coupon.valueDesc) {
  7832. return [coupon.valueDesc, createVNode("span", null, [coupon.unitDesc || ""])];
  7833. }
  7834. if (coupon.denominations) {
  7835. const denominations = formatAmount(coupon.denominations);
  7836. return [createVNode("span", null, [currency]), ` ${denominations}`];
  7837. }
  7838. if (coupon.discount) {
  7839. return t$a("discount", formatDiscount(coupon.discount));
  7840. }
  7841. return "";
  7842. });
  7843. const conditionMessage = computed(() => {
  7844. const condition = formatAmount(props.coupon.originCondition || 0);
  7845. return condition === "0" ? t$a("unlimited") : t$a("condition", condition);
  7846. });
  7847. return () => {
  7848. const {
  7849. chosen,
  7850. coupon,
  7851. disabled
  7852. } = props;
  7853. const description = disabled && coupon.reason || coupon.description;
  7854. return createVNode("div", {
  7855. "class": bem$G({
  7856. disabled
  7857. })
  7858. }, [createVNode("div", {
  7859. "class": bem$G("content")
  7860. }, [createVNode("div", {
  7861. "class": bem$G("head")
  7862. }, [createVNode("h2", {
  7863. "class": bem$G("amount")
  7864. }, [faceAmount.value]), createVNode("p", {
  7865. "class": bem$G("condition")
  7866. }, [coupon.condition || conditionMessage.value])]), createVNode("div", {
  7867. "class": bem$G("body")
  7868. }, [createVNode("p", {
  7869. "class": bem$G("name")
  7870. }, [coupon.name]), createVNode("p", {
  7871. "class": bem$G("valid")
  7872. }, [validPeriod.value]), !disabled && createVNode(Checkbox, {
  7873. "class": bem$G("corner"),
  7874. "modelValue": chosen
  7875. }, null)])]), description && createVNode("p", {
  7876. "class": bem$G("description")
  7877. }, [description])]);
  7878. };
  7879. }
  7880. });
  7881. const Coupon = withInstall(stdin_default$N);
  7882. const [name$G, bem$F, t$9] = createNamespace("coupon-cell");
  7883. const couponCellProps = {
  7884. title: String,
  7885. border: truthProp,
  7886. editable: truthProp,
  7887. coupons: makeArrayProp(),
  7888. currency: makeStringProp("\xA5"),
  7889. chosenCoupon: makeNumericProp(-1)
  7890. };
  7891. function formatValue({
  7892. coupons,
  7893. chosenCoupon,
  7894. currency
  7895. }) {
  7896. const coupon = coupons[+chosenCoupon];
  7897. if (coupon) {
  7898. let value = 0;
  7899. if (isDef(coupon.value)) {
  7900. ({
  7901. value
  7902. } = coupon);
  7903. } else if (isDef(coupon.denominations)) {
  7904. value = coupon.denominations;
  7905. }
  7906. return `-${currency} ${(value / 100).toFixed(2)}`;
  7907. }
  7908. return coupons.length === 0 ? t$9("noCoupon") : t$9("count", coupons.length);
  7909. }
  7910. var stdin_default$M = defineComponent({
  7911. name: name$G,
  7912. props: couponCellProps,
  7913. setup(props) {
  7914. return () => {
  7915. const selected = props.coupons[+props.chosenCoupon];
  7916. return createVNode(Cell, {
  7917. "class": bem$F(),
  7918. "value": formatValue(props),
  7919. "title": props.title || t$9("title"),
  7920. "border": props.border,
  7921. "isLink": props.editable,
  7922. "valueClass": bem$F("value", {
  7923. selected
  7924. })
  7925. }, null);
  7926. };
  7927. }
  7928. });
  7929. const CouponCell = withInstall(stdin_default$M);
  7930. const [name$F, bem$E] = createNamespace("empty");
  7931. const emptyProps = {
  7932. image: makeStringProp("default"),
  7933. imageSize: [Number, String, Array],
  7934. description: String
  7935. };
  7936. var stdin_default$L = defineComponent({
  7937. name: name$F,
  7938. props: emptyProps,
  7939. setup(props, {
  7940. slots
  7941. }) {
  7942. const renderDescription = () => {
  7943. const description = slots.description ? slots.description() : props.description;
  7944. if (description) {
  7945. return createVNode("p", {
  7946. "class": bem$E("description")
  7947. }, [description]);
  7948. }
  7949. };
  7950. const renderBottom = () => {
  7951. if (slots.default) {
  7952. return createVNode("div", {
  7953. "class": bem$E("bottom")
  7954. }, [slots.default()]);
  7955. }
  7956. };
  7957. const baseId = useId();
  7958. const getId = (num) => `${baseId}-${num}`;
  7959. const getUrlById = (num) => `url(#${getId(num)})`;
  7960. const renderStop = (color, offset, opacity) => createVNode("stop", {
  7961. "stop-color": color,
  7962. "offset": `${offset}%`,
  7963. "stop-opacity": opacity
  7964. }, null);
  7965. const renderStops = (fromColor, toColor) => [renderStop(fromColor, 0), renderStop(toColor, 100)];
  7966. const renderShadow = (id) => [createVNode("defs", null, [createVNode("radialGradient", {
  7967. "id": getId(id),
  7968. "cx": "50%",
  7969. "cy": "54%",
  7970. "fx": "50%",
  7971. "fy": "54%",
  7972. "r": "297%",
  7973. "gradientTransform": "matrix(-.16 0 0 -.33 .58 .72)"
  7974. }, [renderStop("#EBEDF0", 0), renderStop("#F2F3F5", 100, 0.3)])]), createVNode("ellipse", {
  7975. "fill": getUrlById(id),
  7976. "opacity": ".8",
  7977. "cx": "80",
  7978. "cy": "140",
  7979. "rx": "46",
  7980. "ry": "8"
  7981. }, null)];
  7982. const renderBuilding = () => [createVNode("defs", null, [createVNode("linearGradient", {
  7983. "id": getId("a"),
  7984. "x1": "64%",
  7985. "y1": "100%",
  7986. "x2": "64%"
  7987. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)])]), createVNode("g", {
  7988. "opacity": ".8"
  7989. }, [createVNode("path", {
  7990. "d": "M36 131V53H16v20H2v58h34z",
  7991. "fill": getUrlById("a")
  7992. }, null), createVNode("path", {
  7993. "d": "M123 15h22v14h9v77h-31V15z",
  7994. "fill": getUrlById("a")
  7995. }, null)])];
  7996. const renderCloud = () => [createVNode("defs", null, [createVNode("linearGradient", {
  7997. "id": getId("b"),
  7998. "x1": "64%",
  7999. "y1": "97%",
  8000. "x2": "64%",
  8001. "y2": "0%"
  8002. }, [renderStop("#F2F3F5", 0, 0.3), renderStop("#F2F3F5", 100)])]), createVNode("g", {
  8003. "opacity": ".8"
  8004. }, [createVNode("path", {
  8005. "d": "M87 6c3 0 7 3 8 6a8 8 0 1 1-1 16H80a7 7 0 0 1-8-6c0-4 3-7 6-7 0-5 4-9 9-9Z",
  8006. "fill": getUrlById("b")
  8007. }, null), createVNode("path", {
  8008. "d": "M19 23c2 0 3 1 4 3 2 0 4 2 4 4a4 4 0 0 1-4 3v1h-7v-1l-1 1c-2 0-3-2-3-4 0-1 1-3 3-3 0-2 2-4 4-4Z",
  8009. "fill": getUrlById("b")
  8010. }, null)])];
  8011. const renderNetwork = () => createVNode("svg", {
  8012. "viewBox": "0 0 160 160"
  8013. }, [createVNode("defs", null, [createVNode("linearGradient", {
  8014. "id": getId(1),
  8015. "x1": "64%",
  8016. "y1": "100%",
  8017. "x2": "64%"
  8018. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)]), createVNode("linearGradient", {
  8019. "id": getId(2),
  8020. "x1": "50%",
  8021. "x2": "50%",
  8022. "y2": "84%"
  8023. }, [renderStop("#EBEDF0", 0), renderStop("#DCDEE0", 100, 0)]), createVNode("linearGradient", {
  8024. "id": getId(3),
  8025. "x1": "100%",
  8026. "x2": "100%",
  8027. "y2": "100%"
  8028. }, [renderStops("#EAEDF0", "#DCDEE0")]), createVNode("radialGradient", {
  8029. "id": getId(4),
  8030. "cx": "50%",
  8031. "cy": "0%",
  8032. "fx": "50%",
  8033. "fy": "0%",
  8034. "r": "100%",
  8035. "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
  8036. }, [renderStop("#EBEDF0", 0), renderStop("#FFF", 100, 0)])]), createVNode("g", {
  8037. "fill": "none"
  8038. }, [renderBuilding(), createVNode("path", {
  8039. "fill": getUrlById(4),
  8040. "d": "M0 139h160v21H0z"
  8041. }, null), createVNode("path", {
  8042. "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
  8043. "fill": getUrlById(2)
  8044. }, null), createVNode("g", {
  8045. "opacity": ".6",
  8046. "stroke-linecap": "round",
  8047. "stroke-width": "7"
  8048. }, [createVNode("path", {
  8049. "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
  8050. "stroke": getUrlById(3)
  8051. }, null), createVNode("path", {
  8052. "d": "M53 36a34 34 0 0 0 0 48",
  8053. "stroke": getUrlById(3)
  8054. }, null), createVNode("path", {
  8055. "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
  8056. "stroke": getUrlById(3)
  8057. }, null), createVNode("path", {
  8058. "d": "M106 84a34 34 0 0 0 0-48",
  8059. "stroke": getUrlById(3)
  8060. }, null)]), createVNode("g", {
  8061. "transform": "translate(31 105)"
  8062. }, [createVNode("rect", {
  8063. "fill": "#EBEDF0",
  8064. "width": "98",
  8065. "height": "34",
  8066. "rx": "2"
  8067. }, null), createVNode("rect", {
  8068. "fill": "#FFF",
  8069. "x": "9",
  8070. "y": "8",
  8071. "width": "80",
  8072. "height": "18",
  8073. "rx": "1.1"
  8074. }, null), createVNode("rect", {
  8075. "fill": "#EBEDF0",
  8076. "x": "15",
  8077. "y": "12",
  8078. "width": "18",
  8079. "height": "6",
  8080. "rx": "1.1"
  8081. }, null)])])]);
  8082. const renderMaterial = () => createVNode("svg", {
  8083. "viewBox": "0 0 160 160"
  8084. }, [createVNode("defs", null, [createVNode("linearGradient", {
  8085. "x1": "50%",
  8086. "x2": "50%",
  8087. "y2": "100%",
  8088. "id": getId(5)
  8089. }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
  8090. "x1": "95%",
  8091. "y1": "48%",
  8092. "x2": "5.5%",
  8093. "y2": "51%",
  8094. "id": getId(6)
  8095. }, [renderStops("#EAEDF1", "#DCDEE0")]), createVNode("linearGradient", {
  8096. "y1": "45%",
  8097. "x2": "100%",
  8098. "y2": "54%",
  8099. "id": getId(7)
  8100. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), createVNode("g", {
  8101. "transform": "translate(36 50)",
  8102. "fill": "none"
  8103. }, [createVNode("g", {
  8104. "transform": "translate(8)"
  8105. }, [createVNode("rect", {
  8106. "fill": "#EBEDF0",
  8107. "opacity": ".6",
  8108. "x": "38",
  8109. "y": "13",
  8110. "width": "36",
  8111. "height": "53",
  8112. "rx": "2"
  8113. }, null), createVNode("rect", {
  8114. "fill": getUrlById(5),
  8115. "width": "64",
  8116. "height": "66",
  8117. "rx": "2"
  8118. }, null), createVNode("rect", {
  8119. "fill": "#FFF",
  8120. "x": "6",
  8121. "y": "6",
  8122. "width": "52",
  8123. "height": "55",
  8124. "rx": "1"
  8125. }, null), createVNode("g", {
  8126. "transform": "translate(15 17)",
  8127. "fill": getUrlById(6)
  8128. }, [createVNode("rect", {
  8129. "width": "34",
  8130. "height": "6",
  8131. "rx": "1"
  8132. }, null), createVNode("path", {
  8133. "d": "M0 14h34v6H0z"
  8134. }, null), createVNode("rect", {
  8135. "y": "28",
  8136. "width": "34",
  8137. "height": "6",
  8138. "rx": "1"
  8139. }, null)])]), createVNode("rect", {
  8140. "fill": getUrlById(7),
  8141. "y": "61",
  8142. "width": "88",
  8143. "height": "28",
  8144. "rx": "1"
  8145. }, null), createVNode("rect", {
  8146. "fill": "#F7F8FA",
  8147. "x": "29",
  8148. "y": "72",
  8149. "width": "30",
  8150. "height": "6",
  8151. "rx": "1"
  8152. }, null)])]);
  8153. const renderError = () => createVNode("svg", {
  8154. "viewBox": "0 0 160 160"
  8155. }, [createVNode("defs", null, [createVNode("linearGradient", {
  8156. "x1": "50%",
  8157. "x2": "50%",
  8158. "y2": "100%",
  8159. "id": getId(8)
  8160. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), renderShadow("c"), createVNode("path", {
  8161. "d": "m59 60 21 21 21-21h3l9 9v3L92 93l21 21v3l-9 9h-3l-21-21-21 21h-3l-9-9v-3l21-21-21-21v-3l9-9h3Z",
  8162. "fill": getUrlById(8)
  8163. }, null)]);
  8164. const renderSearch = () => createVNode("svg", {
  8165. "viewBox": "0 0 160 160"
  8166. }, [createVNode("defs", null, [createVNode("linearGradient", {
  8167. "x1": "50%",
  8168. "y1": "100%",
  8169. "x2": "50%",
  8170. "id": getId(9)
  8171. }, [renderStops("#EEE", "#D8D8D8")]), createVNode("linearGradient", {
  8172. "x1": "100%",
  8173. "y1": "50%",
  8174. "y2": "50%",
  8175. "id": getId(10)
  8176. }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
  8177. "x1": "50%",
  8178. "x2": "50%",
  8179. "y2": "100%",
  8180. "id": getId(11)
  8181. }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
  8182. "x1": "50%",
  8183. "x2": "50%",
  8184. "y2": "100%",
  8185. "id": getId(12)
  8186. }, [renderStops("#FFF", "#F7F8FA")])]), renderBuilding(), renderCloud(), renderShadow("d"), createVNode("g", {
  8187. "transform": "rotate(-45 113 -4)",
  8188. "fill": "none"
  8189. }, [createVNode("rect", {
  8190. "fill": getUrlById(9),
  8191. "x": "24",
  8192. "y": "52.8",
  8193. "width": "5.8",
  8194. "height": "19",
  8195. "rx": "1"
  8196. }, null), createVNode("rect", {
  8197. "fill": getUrlById(10),
  8198. "x": "22.1",
  8199. "y": "67.3",
  8200. "width": "9.9",
  8201. "height": "28",
  8202. "rx": "1"
  8203. }, null), createVNode("circle", {
  8204. "stroke": getUrlById(11),
  8205. "stroke-width": "8",
  8206. "cx": "27",
  8207. "cy": "27",
  8208. "r": "27"
  8209. }, null), createVNode("circle", {
  8210. "fill": getUrlById(12),
  8211. "cx": "27",
  8212. "cy": "27",
  8213. "r": "16"
  8214. }, null), createVNode("path", {
  8215. "d": "M37 7c-8 0-15 5-16 12",
  8216. "stroke": getUrlById(11),
  8217. "stroke-width": "3",
  8218. "opacity": ".5",
  8219. "stroke-linecap": "round",
  8220. "transform": "rotate(45 29 13)"
  8221. }, null)])]);
  8222. const renderImage = () => {
  8223. var _a;
  8224. if (slots.image) {
  8225. return slots.image();
  8226. }
  8227. const PRESET_IMAGES = {
  8228. error: renderError,
  8229. search: renderSearch,
  8230. network: renderNetwork,
  8231. default: renderMaterial
  8232. };
  8233. return ((_a = PRESET_IMAGES[props.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || createVNode("img", {
  8234. "src": props.image
  8235. }, null);
  8236. };
  8237. return () => createVNode("div", {
  8238. "class": bem$E()
  8239. }, [createVNode("div", {
  8240. "class": bem$E("image"),
  8241. "style": getSizeStyle(props.imageSize)
  8242. }, [renderImage()]), renderDescription(), renderBottom()]);
  8243. }
  8244. });
  8245. const Empty = withInstall(stdin_default$L);
  8246. const [name$E, bem$D, t$8] = createNamespace("coupon-list");
  8247. const couponListProps = {
  8248. code: makeStringProp(""),
  8249. coupons: makeArrayProp(),
  8250. currency: makeStringProp("\xA5"),
  8251. showCount: truthProp,
  8252. emptyImage: String,
  8253. chosenCoupon: makeNumberProp(-1),
  8254. enabledTitle: String,
  8255. disabledTitle: String,
  8256. disabledCoupons: makeArrayProp(),
  8257. showExchangeBar: truthProp,
  8258. showCloseButton: truthProp,
  8259. closeButtonText: String,
  8260. inputPlaceholder: String,
  8261. exchangeMinLength: makeNumberProp(1),
  8262. exchangeButtonText: String,
  8263. displayedCouponIndex: makeNumberProp(-1),
  8264. exchangeButtonLoading: Boolean,
  8265. exchangeButtonDisabled: Boolean
  8266. };
  8267. var stdin_default$K = defineComponent({
  8268. name: name$E,
  8269. props: couponListProps,
  8270. emits: ["change", "exchange", "update:code"],
  8271. setup(props, {
  8272. emit,
  8273. slots
  8274. }) {
  8275. const [couponRefs, setCouponRefs] = useRefs();
  8276. const root = ref();
  8277. const barRef = ref();
  8278. const activeTab = ref(0);
  8279. const listHeight = ref(0);
  8280. const currentCode = ref(props.code);
  8281. const buttonDisabled = computed(() => !props.exchangeButtonLoading && (props.exchangeButtonDisabled || !currentCode.value || currentCode.value.length < props.exchangeMinLength));
  8282. const updateListHeight = () => {
  8283. const TABS_HEIGHT = 44;
  8284. const rootHeight = useRect(root).height;
  8285. const headerHeight = useRect(barRef).height + TABS_HEIGHT;
  8286. listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
  8287. };
  8288. const onExchange = () => {
  8289. emit("exchange", currentCode.value);
  8290. if (!props.code) {
  8291. currentCode.value = "";
  8292. }
  8293. };
  8294. const scrollToCoupon = (index) => {
  8295. nextTick(() => {
  8296. var _a;
  8297. return (_a = couponRefs.value[index]) == null ? void 0 : _a.scrollIntoView();
  8298. });
  8299. };
  8300. const renderEmpty = () => createVNode(Empty, {
  8301. "image": props.emptyImage
  8302. }, {
  8303. default: () => [createVNode("p", {
  8304. "class": bem$D("empty-tip")
  8305. }, [t$8("noCoupon")])]
  8306. });
  8307. const renderExchangeBar = () => {
  8308. if (props.showExchangeBar) {
  8309. return createVNode("div", {
  8310. "ref": barRef,
  8311. "class": bem$D("exchange-bar")
  8312. }, [createVNode(Field, {
  8313. "modelValue": currentCode.value,
  8314. "onUpdate:modelValue": ($event) => currentCode.value = $event,
  8315. "clearable": true,
  8316. "border": false,
  8317. "class": bem$D("field"),
  8318. "placeholder": props.inputPlaceholder || t$8("placeholder"),
  8319. "maxlength": "20"
  8320. }, null), createVNode(Button, {
  8321. "plain": true,
  8322. "type": "danger",
  8323. "class": bem$D("exchange"),
  8324. "text": props.exchangeButtonText || t$8("exchange"),
  8325. "loading": props.exchangeButtonLoading,
  8326. "disabled": buttonDisabled.value,
  8327. "onClick": onExchange
  8328. }, null)]);
  8329. }
  8330. };
  8331. const renderCouponTab = () => {
  8332. const {
  8333. coupons
  8334. } = props;
  8335. const count = props.showCount ? ` (${coupons.length})` : "";
  8336. const title = (props.enabledTitle || t$8("enable")) + count;
  8337. return createVNode(Tab, {
  8338. "title": title
  8339. }, {
  8340. default: () => {
  8341. var _a;
  8342. return [createVNode("div", {
  8343. "class": bem$D("list", {
  8344. "with-bottom": props.showCloseButton
  8345. }),
  8346. "style": {
  8347. height: `${listHeight.value}px`
  8348. }
  8349. }, [coupons.map((coupon, index) => createVNode(Coupon, {
  8350. "key": coupon.id,
  8351. "ref": setCouponRefs(index),
  8352. "coupon": coupon,
  8353. "chosen": index === props.chosenCoupon,
  8354. "currency": props.currency,
  8355. "onClick": () => emit("change", index)
  8356. }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
  8357. }
  8358. });
  8359. };
  8360. const renderDisabledTab = () => {
  8361. const {
  8362. disabledCoupons
  8363. } = props;
  8364. const count = props.showCount ? ` (${disabledCoupons.length})` : "";
  8365. const title = (props.disabledTitle || t$8("disabled")) + count;
  8366. return createVNode(Tab, {
  8367. "title": title
  8368. }, {
  8369. default: () => {
  8370. var _a;
  8371. return [createVNode("div", {
  8372. "class": bem$D("list", {
  8373. "with-bottom": props.showCloseButton
  8374. }),
  8375. "style": {
  8376. height: `${listHeight.value}px`
  8377. }
  8378. }, [disabledCoupons.map((coupon) => createVNode(Coupon, {
  8379. "disabled": true,
  8380. "key": coupon.id,
  8381. "coupon": coupon,
  8382. "currency": props.currency
  8383. }, null)), !disabledCoupons.length && renderEmpty(), (_a = slots["disabled-list-footer"]) == null ? void 0 : _a.call(slots)])];
  8384. }
  8385. });
  8386. };
  8387. watch(() => props.code, (value) => {
  8388. currentCode.value = value;
  8389. });
  8390. watch(windowHeight, updateListHeight);
  8391. watch(currentCode, (value) => emit("update:code", value));
  8392. watch(() => props.displayedCouponIndex, scrollToCoupon);
  8393. onMounted(() => {
  8394. updateListHeight();
  8395. scrollToCoupon(props.displayedCouponIndex);
  8396. });
  8397. return () => createVNode("div", {
  8398. "ref": root,
  8399. "class": bem$D()
  8400. }, [renderExchangeBar(), createVNode(Tabs, {
  8401. "active": activeTab.value,
  8402. "onUpdate:active": ($event) => activeTab.value = $event,
  8403. "class": bem$D("tab")
  8404. }, {
  8405. default: () => [renderCouponTab(), renderDisabledTab()]
  8406. }), createVNode("div", {
  8407. "class": bem$D("bottom")
  8408. }, [withDirectives(createVNode(Button, {
  8409. "round": true,
  8410. "block": true,
  8411. "type": "danger",
  8412. "class": bem$D("close"),
  8413. "text": props.closeButtonText || t$8("close"),
  8414. "onClick": () => emit("change", -1)
  8415. }, null), [[vShow, props.showCloseButton]])])]);
  8416. }
  8417. });
  8418. const CouponList = withInstall(stdin_default$K);
  8419. const [name$D] = createNamespace("time-picker");
  8420. var stdin_default$J = defineComponent({
  8421. name: name$D,
  8422. props: extend({}, sharedProps, {
  8423. minHour: makeNumericProp(0),
  8424. maxHour: makeNumericProp(23),
  8425. minMinute: makeNumericProp(0),
  8426. maxMinute: makeNumericProp(59),
  8427. modelValue: String
  8428. }),
  8429. emits: ["confirm", "cancel", "change", "update:modelValue"],
  8430. setup(props, {
  8431. emit,
  8432. slots
  8433. }) {
  8434. const formatValue2 = (value) => {
  8435. const {
  8436. minHour,
  8437. maxHour,
  8438. maxMinute,
  8439. minMinute
  8440. } = props;
  8441. if (!value) {
  8442. value = `${padZero(minHour)}:${padZero(minMinute)}`;
  8443. }
  8444. let [hour, minute] = value.split(":");
  8445. hour = padZero(clamp(+hour, +minHour, +maxHour));
  8446. minute = padZero(clamp(+minute, +minMinute, +maxMinute));
  8447. return `${hour}:${minute}`;
  8448. };
  8449. const picker = ref();
  8450. const currentDate = ref(formatValue2(props.modelValue));
  8451. const ranges = computed(() => [{
  8452. type: "hour",
  8453. range: [+props.minHour, +props.maxHour]
  8454. }, {
  8455. type: "minute",
  8456. range: [+props.minMinute, +props.maxMinute]
  8457. }]);
  8458. const originColumns = computed(() => ranges.value.map(({
  8459. type,
  8460. range: rangeArr
  8461. }) => {
  8462. let values = times(rangeArr[1] - rangeArr[0] + 1, (index) => padZero(rangeArr[0] + index));
  8463. if (props.filter) {
  8464. values = props.filter(type, values);
  8465. }
  8466. return {
  8467. type,
  8468. values
  8469. };
  8470. }));
  8471. const columns = computed(() => originColumns.value.map((column) => ({
  8472. values: column.values.map((value) => props.formatter(column.type, value))
  8473. })));
  8474. const updateColumnValue = () => {
  8475. const pair = currentDate.value.split(":");
  8476. const values = [props.formatter("hour", pair[0]), props.formatter("minute", pair[1])];
  8477. nextTick(() => {
  8478. var _a;
  8479. (_a = picker.value) == null ? void 0 : _a.setValues(values);
  8480. });
  8481. };
  8482. const updateInnerValue = () => {
  8483. const [hourIndex, minuteIndex] = picker.value.getIndexes();
  8484. const [hourColumn, minuteColumn] = originColumns.value;
  8485. const hour = hourColumn.values[hourIndex] || hourColumn.values[0];
  8486. const minute = minuteColumn.values[minuteIndex] || minuteColumn.values[0];
  8487. currentDate.value = formatValue2(`${hour}:${minute}`);
  8488. updateColumnValue();
  8489. };
  8490. const onConfirm = () => emit("confirm", currentDate.value);
  8491. const onCancel = () => emit("cancel");
  8492. const onChange = () => {
  8493. updateInnerValue();
  8494. nextTick(() => {
  8495. nextTick(() => emit("change", currentDate.value));
  8496. });
  8497. };
  8498. onMounted(() => {
  8499. updateColumnValue();
  8500. nextTick(updateInnerValue);
  8501. });
  8502. watch(columns, updateColumnValue);
  8503. watch(() => [props.filter, props.maxHour, props.minMinute, props.maxMinute], updateInnerValue);
  8504. watch(() => props.minHour, () => {
  8505. nextTick(updateInnerValue);
  8506. });
  8507. watch(currentDate, (value) => emit("update:modelValue", value));
  8508. watch(() => props.modelValue, (value) => {
  8509. value = formatValue2(value);
  8510. if (value !== currentDate.value) {
  8511. currentDate.value = value;
  8512. updateColumnValue();
  8513. }
  8514. });
  8515. useExpose({
  8516. getPicker: () => picker.value && proxyPickerMethods(picker.value, updateInnerValue)
  8517. });
  8518. return () => createVNode(Picker, mergeProps({
  8519. "ref": picker,
  8520. "columns": columns.value,
  8521. "onChange": onChange,
  8522. "onCancel": onCancel,
  8523. "onConfirm": onConfirm
  8524. }, pick(props, pickerInheritKeys)), slots);
  8525. }
  8526. });
  8527. const currentYear = new Date().getFullYear();
  8528. const [name$C] = createNamespace("date-picker");
  8529. var stdin_default$I = defineComponent({
  8530. name: name$C,
  8531. props: extend({}, sharedProps, {
  8532. type: makeStringProp("datetime"),
  8533. modelValue: Date,
  8534. minDate: {
  8535. type: Date,
  8536. default: () => new Date(currentYear - 10, 0, 1),
  8537. validator: isDate
  8538. },
  8539. maxDate: {
  8540. type: Date,
  8541. default: () => new Date(currentYear + 10, 11, 31),
  8542. validator: isDate
  8543. }
  8544. }),
  8545. emits: ["confirm", "cancel", "change", "update:modelValue"],
  8546. setup(props, {
  8547. emit,
  8548. slots
  8549. }) {
  8550. const formatValue2 = (value) => {
  8551. if (isDate(value)) {
  8552. const timestamp = clamp(value.getTime(), props.minDate.getTime(), props.maxDate.getTime());
  8553. return new Date(timestamp);
  8554. }
  8555. return void 0;
  8556. };
  8557. const picker = ref();
  8558. const currentDate = ref(formatValue2(props.modelValue));
  8559. const getBoundary = (type, value) => {
  8560. const boundary = props[`${type}Date`];
  8561. const year = boundary.getFullYear();
  8562. let month = 1;
  8563. let date = 1;
  8564. let hour = 0;
  8565. let minute = 0;
  8566. if (type === "max") {
  8567. month = 12;
  8568. date = getMonthEndDay(value.getFullYear(), value.getMonth() + 1);
  8569. hour = 23;
  8570. minute = 59;
  8571. }
  8572. if (value.getFullYear() === year) {
  8573. month = boundary.getMonth() + 1;
  8574. if (value.getMonth() + 1 === month) {
  8575. date = boundary.getDate();
  8576. if (value.getDate() === date) {
  8577. hour = boundary.getHours();
  8578. if (value.getHours() === hour) {
  8579. minute = boundary.getMinutes();
  8580. }
  8581. }
  8582. }
  8583. }
  8584. return {
  8585. [`${type}Year`]: year,
  8586. [`${type}Month`]: month,
  8587. [`${type}Date`]: date,
  8588. [`${type}Hour`]: hour,
  8589. [`${type}Minute`]: minute
  8590. };
  8591. };
  8592. const ranges = computed(() => {
  8593. const {
  8594. maxYear,
  8595. maxDate,
  8596. maxMonth,
  8597. maxHour,
  8598. maxMinute
  8599. } = getBoundary("max", currentDate.value || props.minDate);
  8600. const {
  8601. minYear,
  8602. minDate,
  8603. minMonth,
  8604. minHour,
  8605. minMinute
  8606. } = getBoundary("min", currentDate.value || props.minDate);
  8607. let result = [{
  8608. type: "year",
  8609. range: [minYear, maxYear]
  8610. }, {
  8611. type: "month",
  8612. range: [minMonth, maxMonth]
  8613. }, {
  8614. type: "day",
  8615. range: [minDate, maxDate]
  8616. }, {
  8617. type: "hour",
  8618. range: [minHour, maxHour]
  8619. }, {
  8620. type: "minute",
  8621. range: [minMinute, maxMinute]
  8622. }];
  8623. switch (props.type) {
  8624. case "date":
  8625. result = result.slice(0, 3);
  8626. break;
  8627. case "year-month":
  8628. result = result.slice(0, 2);
  8629. break;
  8630. case "month-day":
  8631. result = result.slice(1, 3);
  8632. break;
  8633. case "datehour":
  8634. result = result.slice(0, 4);
  8635. break;
  8636. }
  8637. if (props.columnsOrder) {
  8638. const columnsOrder = props.columnsOrder.concat(result.map((column) => column.type));
  8639. result.sort((a, b) => columnsOrder.indexOf(a.type) - columnsOrder.indexOf(b.type));
  8640. }
  8641. return result;
  8642. });
  8643. const originColumns = computed(() => ranges.value.map(({
  8644. type,
  8645. range: rangeArr
  8646. }) => {
  8647. let values = times(rangeArr[1] - rangeArr[0] + 1, (index) => padZero(rangeArr[0] + index));
  8648. if (props.filter) {
  8649. values = props.filter(type, values);
  8650. }
  8651. return {
  8652. type,
  8653. values
  8654. };
  8655. }));
  8656. const columns = computed(() => originColumns.value.map((column) => ({
  8657. values: column.values.map((value) => props.formatter(column.type, value))
  8658. })));
  8659. const updateColumnValue = () => {
  8660. const value = currentDate.value || props.minDate;
  8661. const {
  8662. formatter
  8663. } = props;
  8664. const values = originColumns.value.map((column) => {
  8665. switch (column.type) {
  8666. case "year":
  8667. return formatter("year", `${value.getFullYear()}`);
  8668. case "month":
  8669. return formatter("month", padZero(value.getMonth() + 1));
  8670. case "day":
  8671. return formatter("day", padZero(value.getDate()));
  8672. case "hour":
  8673. return formatter("hour", padZero(value.getHours()));
  8674. case "minute":
  8675. return formatter("minute", padZero(value.getMinutes()));
  8676. default:
  8677. return "";
  8678. }
  8679. });
  8680. nextTick(() => {
  8681. var _a;
  8682. (_a = picker.value) == null ? void 0 : _a.setValues(values);
  8683. });
  8684. };
  8685. const updateInnerValue = () => {
  8686. const {
  8687. type
  8688. } = props;
  8689. const indexes = picker.value.getIndexes();
  8690. const getValue = (type2) => {
  8691. let index = 0;
  8692. originColumns.value.forEach((column, columnIndex) => {
  8693. if (type2 === column.type) {
  8694. index = columnIndex;
  8695. }
  8696. });
  8697. const {
  8698. values
  8699. } = originColumns.value[index];
  8700. return getTrueValue(values[indexes[index]]);
  8701. };
  8702. let year;
  8703. let month;
  8704. let day;
  8705. if (type === "month-day") {
  8706. year = (currentDate.value || props.minDate).getFullYear();
  8707. month = getValue("month");
  8708. day = getValue("day");
  8709. } else {
  8710. year = getValue("year");
  8711. month = getValue("month");
  8712. day = type === "year-month" ? 1 : getValue("day");
  8713. }
  8714. const maxDay = getMonthEndDay(year, month);
  8715. day = day > maxDay ? maxDay : day;
  8716. let hour = 0;
  8717. let minute = 0;
  8718. if (type === "datehour") {
  8719. hour = getValue("hour");
  8720. }
  8721. if (type === "datetime") {
  8722. hour = getValue("hour");
  8723. minute = getValue("minute");
  8724. }
  8725. const value = new Date(year, month - 1, day, hour, minute);
  8726. currentDate.value = formatValue2(value);
  8727. };
  8728. const onConfirm = () => {
  8729. emit("update:modelValue", currentDate.value);
  8730. emit("confirm", currentDate.value);
  8731. };
  8732. const onCancel = () => emit("cancel");
  8733. const onChange = () => {
  8734. updateInnerValue();
  8735. nextTick(() => {
  8736. updateInnerValue();
  8737. nextTick(() => emit("change", currentDate.value));
  8738. });
  8739. };
  8740. onMounted(() => {
  8741. updateColumnValue();
  8742. nextTick(updateInnerValue);
  8743. });
  8744. watch(columns, updateColumnValue);
  8745. watch(currentDate, (value, oldValue) => emit("update:modelValue", oldValue ? value : null));
  8746. watch(() => [props.filter, props.minDate, props.maxDate], () => {
  8747. nextTick(updateInnerValue);
  8748. });
  8749. watch(() => props.modelValue, (value) => {
  8750. var _a;
  8751. value = formatValue2(value);
  8752. if (value && value.valueOf() !== ((_a = currentDate.value) == null ? void 0 : _a.valueOf())) {
  8753. currentDate.value = value;
  8754. }
  8755. });
  8756. useExpose({
  8757. getPicker: () => picker.value && proxyPickerMethods(picker.value, updateInnerValue)
  8758. });
  8759. return () => createVNode(Picker, mergeProps({
  8760. "ref": picker,
  8761. "columns": columns.value,
  8762. "onChange": onChange,
  8763. "onCancel": onCancel,
  8764. "onConfirm": onConfirm
  8765. }, pick(props, pickerInheritKeys)), slots);
  8766. }
  8767. });
  8768. const [name$B, bem$C] = createNamespace("datetime-picker");
  8769. const timePickerPropKeys = Object.keys(stdin_default$J.props);
  8770. const datePickerPropKeys = Object.keys(stdin_default$I.props);
  8771. const datetimePickerProps = extend({}, stdin_default$J.props, stdin_default$I.props, {
  8772. modelValue: [String, Date]
  8773. });
  8774. var stdin_default$H = defineComponent({
  8775. name: name$B,
  8776. props: datetimePickerProps,
  8777. setup(props, {
  8778. attrs,
  8779. slots
  8780. }) {
  8781. const root = ref();
  8782. useExpose({
  8783. getPicker: () => {
  8784. var _a;
  8785. return (_a = root.value) == null ? void 0 : _a.getPicker();
  8786. }
  8787. });
  8788. return () => {
  8789. const isTimePicker = props.type === "time";
  8790. const Component = isTimePicker ? stdin_default$J : stdin_default$I;
  8791. const inheritProps = pick(props, isTimePicker ? timePickerPropKeys : datePickerPropKeys);
  8792. return createVNode(Component, mergeProps({
  8793. "ref": root,
  8794. "class": bem$C()
  8795. }, inheritProps, attrs), slots);
  8796. };
  8797. }
  8798. });
  8799. const DatetimePicker = withInstall(stdin_default$H);
  8800. const [name$A, bem$B, t$7] = createNamespace("dialog");
  8801. const dialogProps = extend({}, popupSharedProps, {
  8802. title: String,
  8803. theme: String,
  8804. width: numericProp,
  8805. message: [String, Function],
  8806. callback: Function,
  8807. allowHtml: Boolean,
  8808. className: unknownProp,
  8809. transition: makeStringProp("van-dialog-bounce"),
  8810. messageAlign: String,
  8811. closeOnPopstate: truthProp,
  8812. showCancelButton: Boolean,
  8813. cancelButtonText: String,
  8814. cancelButtonColor: String,
  8815. cancelButtonDisabled: Boolean,
  8816. confirmButtonText: String,
  8817. confirmButtonColor: String,
  8818. confirmButtonDisabled: Boolean,
  8819. showConfirmButton: truthProp,
  8820. closeOnClickOverlay: Boolean
  8821. });
  8822. const popupInheritKeys$1 = [...popupSharedPropKeys, "transition", "closeOnPopstate"];
  8823. var stdin_default$G = defineComponent({
  8824. name: name$A,
  8825. props: dialogProps,
  8826. emits: ["confirm", "cancel", "keydown", "update:show"],
  8827. setup(props, {
  8828. emit,
  8829. slots
  8830. }) {
  8831. const root = ref();
  8832. const loading = reactive({
  8833. confirm: false,
  8834. cancel: false
  8835. });
  8836. const updateShow = (value) => emit("update:show", value);
  8837. const close = (action) => {
  8838. var _a;
  8839. updateShow(false);
  8840. (_a = props.callback) == null ? void 0 : _a.call(props, action);
  8841. };
  8842. const getActionHandler = (action) => () => {
  8843. if (!props.show) {
  8844. return;
  8845. }
  8846. emit(action);
  8847. if (props.beforeClose) {
  8848. loading[action] = true;
  8849. callInterceptor(props.beforeClose, {
  8850. args: [action],
  8851. done() {
  8852. close(action);
  8853. loading[action] = false;
  8854. },
  8855. canceled() {
  8856. loading[action] = false;
  8857. }
  8858. });
  8859. } else {
  8860. close(action);
  8861. }
  8862. };
  8863. const onCancel = getActionHandler("cancel");
  8864. const onConfirm = getActionHandler("confirm");
  8865. const onKeydown = withKeys((event) => {
  8866. var _a, _b;
  8867. if (event.target !== ((_b = (_a = root.value) == null ? void 0 : _a.popupRef) == null ? void 0 : _b.value)) {
  8868. return;
  8869. }
  8870. const onEventType = {
  8871. Enter: props.showConfirmButton ? onConfirm : noop,
  8872. Escape: props.showCancelButton ? onCancel : noop
  8873. };
  8874. onEventType[event.key]();
  8875. emit("keydown", event);
  8876. }, ["enter", "esc"]);
  8877. const renderTitle = () => {
  8878. const title = slots.title ? slots.title() : props.title;
  8879. if (title) {
  8880. return createVNode("div", {
  8881. "class": bem$B("header", {
  8882. isolated: !props.message && !slots.default
  8883. })
  8884. }, [title]);
  8885. }
  8886. };
  8887. const renderMessage = (hasTitle) => {
  8888. const {
  8889. message,
  8890. allowHtml,
  8891. messageAlign
  8892. } = props;
  8893. const classNames = bem$B("message", {
  8894. "has-title": hasTitle,
  8895. [messageAlign]: messageAlign
  8896. });
  8897. const content = isFunction(message) ? message() : message;
  8898. if (allowHtml && typeof content === "string") {
  8899. return createVNode("div", {
  8900. "class": classNames,
  8901. "innerHTML": content
  8902. }, null);
  8903. }
  8904. return createVNode("div", {
  8905. "class": classNames
  8906. }, [content]);
  8907. };
  8908. const renderContent = () => {
  8909. if (slots.default) {
  8910. return createVNode("div", {
  8911. "class": bem$B("content")
  8912. }, [slots.default()]);
  8913. }
  8914. const {
  8915. title,
  8916. message,
  8917. allowHtml
  8918. } = props;
  8919. if (message) {
  8920. const hasTitle = !!(title || slots.title);
  8921. return createVNode("div", {
  8922. "key": allowHtml ? 1 : 0,
  8923. "class": bem$B("content", {
  8924. isolated: !hasTitle
  8925. })
  8926. }, [renderMessage(hasTitle)]);
  8927. }
  8928. };
  8929. const renderButtons = () => createVNode("div", {
  8930. "class": [BORDER_TOP, bem$B("footer")]
  8931. }, [props.showCancelButton && createVNode(Button, {
  8932. "size": "large",
  8933. "text": props.cancelButtonText || t$7("cancel"),
  8934. "class": bem$B("cancel"),
  8935. "style": {
  8936. color: props.cancelButtonColor
  8937. },
  8938. "loading": loading.cancel,
  8939. "disabled": props.cancelButtonDisabled,
  8940. "onClick": onCancel
  8941. }, null), props.showConfirmButton && createVNode(Button, {
  8942. "size": "large",
  8943. "text": props.confirmButtonText || t$7("confirm"),
  8944. "class": [bem$B("confirm"), {
  8945. [BORDER_LEFT]: props.showCancelButton
  8946. }],
  8947. "style": {
  8948. color: props.confirmButtonColor
  8949. },
  8950. "loading": loading.confirm,
  8951. "disabled": props.confirmButtonDisabled,
  8952. "onClick": onConfirm
  8953. }, null)]);
  8954. const renderRoundButtons = () => createVNode(ActionBar, {
  8955. "class": bem$B("footer")
  8956. }, {
  8957. default: () => [props.showCancelButton && createVNode(ActionBarButton, {
  8958. "type": "warning",
  8959. "text": props.cancelButtonText || t$7("cancel"),
  8960. "class": bem$B("cancel"),
  8961. "color": props.cancelButtonColor,
  8962. "loading": loading.cancel,
  8963. "disabled": props.cancelButtonDisabled,
  8964. "onClick": onCancel
  8965. }, null), props.showConfirmButton && createVNode(ActionBarButton, {
  8966. "type": "danger",
  8967. "text": props.confirmButtonText || t$7("confirm"),
  8968. "class": bem$B("confirm"),
  8969. "color": props.confirmButtonColor,
  8970. "loading": loading.confirm,
  8971. "disabled": props.confirmButtonDisabled,
  8972. "onClick": onConfirm
  8973. }, null)]
  8974. });
  8975. const renderFooter = () => {
  8976. if (slots.footer) {
  8977. return slots.footer();
  8978. }
  8979. return props.theme === "round-button" ? renderRoundButtons() : renderButtons();
  8980. };
  8981. return () => {
  8982. const {
  8983. width,
  8984. title,
  8985. theme,
  8986. message,
  8987. className
  8988. } = props;
  8989. return createVNode(Popup, mergeProps({
  8990. "ref": root,
  8991. "role": "dialog",
  8992. "class": [bem$B([theme]), className],
  8993. "style": {
  8994. width: addUnit(width)
  8995. },
  8996. "tabindex": 0,
  8997. "aria-labelledby": title || message,
  8998. "onKeydown": onKeydown,
  8999. "onUpdate:show": updateShow
  9000. }, pick(props, popupInheritKeys$1)), {
  9001. default: () => [renderTitle(), renderContent(), renderFooter()]
  9002. });
  9003. };
  9004. }
  9005. });
  9006. let instance$2;
  9007. function initInstance$2() {
  9008. const Wrapper = {
  9009. setup() {
  9010. const {
  9011. state,
  9012. toggle
  9013. } = usePopupState();
  9014. return () => createVNode(stdin_default$G, mergeProps(state, {
  9015. "onUpdate:show": toggle
  9016. }), null);
  9017. }
  9018. };
  9019. ({
  9020. instance: instance$2
  9021. } = mountComponent(Wrapper));
  9022. }
  9023. function Dialog(options) {
  9024. if (!inBrowser) {
  9025. return Promise.resolve();
  9026. }
  9027. return new Promise((resolve, reject) => {
  9028. if (!instance$2) {
  9029. initInstance$2();
  9030. }
  9031. instance$2.open(extend({}, Dialog.currentOptions, options, {
  9032. callback: (action) => {
  9033. (action === "confirm" ? resolve : reject)(action);
  9034. }
  9035. }));
  9036. });
  9037. }
  9038. Dialog.defaultOptions = {
  9039. title: "",
  9040. width: "",
  9041. theme: null,
  9042. message: "",
  9043. overlay: true,
  9044. callback: null,
  9045. teleport: "body",
  9046. className: "",
  9047. allowHtml: false,
  9048. lockScroll: true,
  9049. transition: void 0,
  9050. beforeClose: null,
  9051. overlayClass: "",
  9052. overlayStyle: void 0,
  9053. messageAlign: "",
  9054. cancelButtonText: "",
  9055. cancelButtonColor: null,
  9056. cancelButtonDisabled: false,
  9057. confirmButtonText: "",
  9058. confirmButtonColor: null,
  9059. confirmButtonDisabled: false,
  9060. showConfirmButton: true,
  9061. showCancelButton: false,
  9062. closeOnPopstate: true,
  9063. closeOnClickOverlay: false
  9064. };
  9065. Dialog.currentOptions = extend({}, Dialog.defaultOptions);
  9066. Dialog.alert = Dialog;
  9067. Dialog.confirm = (options) => Dialog(extend({
  9068. showCancelButton: true
  9069. }, options));
  9070. Dialog.close = () => {
  9071. if (instance$2) {
  9072. instance$2.toggle(false);
  9073. }
  9074. };
  9075. Dialog.setDefaultOptions = (options) => {
  9076. extend(Dialog.currentOptions, options);
  9077. };
  9078. Dialog.resetDefaultOptions = () => {
  9079. Dialog.currentOptions = extend({}, Dialog.defaultOptions);
  9080. };
  9081. Dialog.Component = withInstall(stdin_default$G);
  9082. Dialog.install = (app) => {
  9083. app.use(Dialog.Component);
  9084. app.config.globalProperties.$dialog = Dialog;
  9085. };
  9086. const [name$z, bem$A] = createNamespace("divider");
  9087. const dividerProps = {
  9088. dashed: Boolean,
  9089. hairline: truthProp,
  9090. contentPosition: makeStringProp("center")
  9091. };
  9092. var stdin_default$F = defineComponent({
  9093. name: name$z,
  9094. props: dividerProps,
  9095. setup(props, {
  9096. slots
  9097. }) {
  9098. return () => {
  9099. var _a;
  9100. return createVNode("div", {
  9101. "role": "separator",
  9102. "class": bem$A({
  9103. dashed: props.dashed,
  9104. hairline: props.hairline,
  9105. [`content-${props.contentPosition}`]: !!slots.default
  9106. })
  9107. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9108. };
  9109. }
  9110. });
  9111. const Divider = withInstall(stdin_default$F);
  9112. const [name$y, bem$z] = createNamespace("dropdown-menu");
  9113. const dropdownMenuProps = {
  9114. overlay: truthProp,
  9115. zIndex: numericProp,
  9116. duration: makeNumericProp(0.2),
  9117. direction: makeStringProp("down"),
  9118. activeColor: String,
  9119. closeOnClickOutside: truthProp,
  9120. closeOnClickOverlay: truthProp
  9121. };
  9122. const DROPDOWN_KEY = Symbol(name$y);
  9123. var stdin_default$E = defineComponent({
  9124. name: name$y,
  9125. props: dropdownMenuProps,
  9126. setup(props, {
  9127. slots
  9128. }) {
  9129. const id = useId();
  9130. const root = ref();
  9131. const barRef = ref();
  9132. const offset = ref(0);
  9133. const {
  9134. children,
  9135. linkChildren
  9136. } = useChildren(DROPDOWN_KEY);
  9137. const scrollParent = useScrollParent(root);
  9138. const opened = computed(() => children.some((item) => item.state.showWrapper));
  9139. const barStyle = computed(() => {
  9140. if (opened.value && isDef(props.zIndex)) {
  9141. return {
  9142. zIndex: +props.zIndex + 1
  9143. };
  9144. }
  9145. });
  9146. const onClickAway = () => {
  9147. if (props.closeOnClickOutside) {
  9148. children.forEach((item) => {
  9149. item.toggle(false);
  9150. });
  9151. }
  9152. };
  9153. const updateOffset = () => {
  9154. if (barRef.value) {
  9155. const rect = useRect(barRef);
  9156. if (props.direction === "down") {
  9157. offset.value = rect.bottom;
  9158. } else {
  9159. offset.value = windowHeight.value - rect.top;
  9160. }
  9161. }
  9162. };
  9163. const onScroll = () => {
  9164. if (opened.value) {
  9165. updateOffset();
  9166. }
  9167. };
  9168. const toggleItem = (active) => {
  9169. children.forEach((item, index) => {
  9170. if (index === active) {
  9171. updateOffset();
  9172. item.toggle();
  9173. } else if (item.state.showPopup) {
  9174. item.toggle(false, {
  9175. immediate: true
  9176. });
  9177. }
  9178. });
  9179. };
  9180. const renderTitle = (item, index) => {
  9181. const {
  9182. showPopup
  9183. } = item.state;
  9184. const {
  9185. disabled,
  9186. titleClass
  9187. } = item;
  9188. return createVNode("div", {
  9189. "id": `${id}-${index}`,
  9190. "role": "button",
  9191. "tabindex": disabled ? void 0 : 0,
  9192. "class": [bem$z("item", {
  9193. disabled
  9194. }), {
  9195. [HAPTICS_FEEDBACK]: !disabled
  9196. }],
  9197. "onClick": () => {
  9198. if (!disabled) {
  9199. toggleItem(index);
  9200. }
  9201. }
  9202. }, [createVNode("span", {
  9203. "class": [bem$z("title", {
  9204. down: showPopup === (props.direction === "down"),
  9205. active: showPopup
  9206. }), titleClass],
  9207. "style": {
  9208. color: showPopup ? props.activeColor : ""
  9209. }
  9210. }, [createVNode("div", {
  9211. "class": "van-ellipsis"
  9212. }, [item.renderTitle()])])]);
  9213. };
  9214. linkChildren({
  9215. id,
  9216. props,
  9217. offset
  9218. });
  9219. useClickAway(root, onClickAway);
  9220. useEventListener("scroll", onScroll, {
  9221. target: scrollParent,
  9222. passive: true
  9223. });
  9224. return () => {
  9225. var _a;
  9226. return createVNode("div", {
  9227. "ref": root,
  9228. "class": bem$z()
  9229. }, [createVNode("div", {
  9230. "ref": barRef,
  9231. "style": barStyle.value,
  9232. "class": bem$z("bar", {
  9233. opened: opened.value
  9234. })
  9235. }, [children.map(renderTitle)]), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9236. };
  9237. }
  9238. });
  9239. const [name$x, bem$y] = createNamespace("dropdown-item");
  9240. const dropdownItemProps = {
  9241. title: String,
  9242. options: makeArrayProp(),
  9243. disabled: Boolean,
  9244. teleport: [String, Object],
  9245. lazyRender: truthProp,
  9246. modelValue: unknownProp,
  9247. titleClass: unknownProp
  9248. };
  9249. var stdin_default$D = defineComponent({
  9250. name: name$x,
  9251. props: dropdownItemProps,
  9252. emits: ["open", "opened", "close", "closed", "change", "update:modelValue"],
  9253. setup(props, {
  9254. emit,
  9255. slots
  9256. }) {
  9257. const state = reactive({
  9258. showPopup: false,
  9259. transition: true,
  9260. showWrapper: false
  9261. });
  9262. const {
  9263. parent,
  9264. index
  9265. } = useParent(DROPDOWN_KEY);
  9266. if (!parent) {
  9267. if (process.env.NODE_ENV !== "production") {
  9268. console.error("[Vant] <DropdownItem> must be a child component of <DropdownMenu>.");
  9269. }
  9270. return;
  9271. }
  9272. const getEmitter = (name2) => () => emit(name2);
  9273. const onOpen = getEmitter("open");
  9274. const onClose = getEmitter("close");
  9275. const onOpened = getEmitter("opened");
  9276. const onClosed = () => {
  9277. state.showWrapper = false;
  9278. emit("closed");
  9279. };
  9280. const onClickWrapper = (event) => {
  9281. if (props.teleport) {
  9282. event.stopPropagation();
  9283. }
  9284. };
  9285. const toggle = (show = !state.showPopup, options = {}) => {
  9286. if (show === state.showPopup) {
  9287. return;
  9288. }
  9289. state.showPopup = show;
  9290. state.transition = !options.immediate;
  9291. if (show) {
  9292. state.showWrapper = true;
  9293. }
  9294. };
  9295. const renderTitle = () => {
  9296. if (slots.title) {
  9297. return slots.title();
  9298. }
  9299. if (props.title) {
  9300. return props.title;
  9301. }
  9302. const match = props.options.find((option) => option.value === props.modelValue);
  9303. return match ? match.text : "";
  9304. };
  9305. const renderOption = (option) => {
  9306. const {
  9307. activeColor
  9308. } = parent.props;
  9309. const active = option.value === props.modelValue;
  9310. const onClick = () => {
  9311. state.showPopup = false;
  9312. if (option.value !== props.modelValue) {
  9313. emit("update:modelValue", option.value);
  9314. emit("change", option.value);
  9315. }
  9316. };
  9317. const renderIcon = () => {
  9318. if (active) {
  9319. return createVNode(Icon, {
  9320. "class": bem$y("icon"),
  9321. "color": activeColor,
  9322. "name": "success"
  9323. }, null);
  9324. }
  9325. };
  9326. return createVNode(Cell, {
  9327. "role": "menuitem",
  9328. "key": option.value,
  9329. "icon": option.icon,
  9330. "title": option.text,
  9331. "class": bem$y("option", {
  9332. active
  9333. }),
  9334. "style": {
  9335. color: active ? activeColor : ""
  9336. },
  9337. "tabindex": active ? 0 : -1,
  9338. "clickable": true,
  9339. "onClick": onClick
  9340. }, {
  9341. value: renderIcon
  9342. });
  9343. };
  9344. const renderContent = () => {
  9345. const {
  9346. offset
  9347. } = parent;
  9348. const {
  9349. zIndex,
  9350. overlay,
  9351. duration,
  9352. direction,
  9353. closeOnClickOverlay
  9354. } = parent.props;
  9355. const style = getZIndexStyle(zIndex);
  9356. if (direction === "down") {
  9357. style.top = `${offset.value}px`;
  9358. } else {
  9359. style.bottom = `${offset.value}px`;
  9360. }
  9361. return withDirectives(createVNode("div", {
  9362. "style": style,
  9363. "class": bem$y([direction]),
  9364. "onClick": onClickWrapper
  9365. }, [createVNode(Popup, {
  9366. "show": state.showPopup,
  9367. "onUpdate:show": ($event) => state.showPopup = $event,
  9368. "role": "menu",
  9369. "class": bem$y("content"),
  9370. "overlay": overlay,
  9371. "position": direction === "down" ? "top" : "bottom",
  9372. "duration": state.transition ? duration : 0,
  9373. "lazyRender": props.lazyRender,
  9374. "overlayStyle": {
  9375. position: "absolute"
  9376. },
  9377. "aria-labelledby": `${parent.id}-${index.value}`,
  9378. "closeOnClickOverlay": closeOnClickOverlay,
  9379. "onOpen": onOpen,
  9380. "onClose": onClose,
  9381. "onOpened": onOpened,
  9382. "onClosed": onClosed
  9383. }, {
  9384. default: () => {
  9385. var _a;
  9386. return [props.options.map(renderOption), (_a = slots.default) == null ? void 0 : _a.call(slots)];
  9387. }
  9388. })]), [[vShow, state.showWrapper]]);
  9389. };
  9390. useExpose({
  9391. state,
  9392. toggle,
  9393. renderTitle
  9394. });
  9395. return () => {
  9396. if (props.teleport) {
  9397. return createVNode(Teleport, {
  9398. "to": props.teleport
  9399. }, {
  9400. default: () => [renderContent()]
  9401. });
  9402. }
  9403. return renderContent();
  9404. };
  9405. }
  9406. });
  9407. const DropdownItem = withInstall(stdin_default$D);
  9408. const DropdownMenu = withInstall(stdin_default$E);
  9409. const [name$w, bem$x] = createNamespace("grid");
  9410. const gridProps = {
  9411. square: Boolean,
  9412. center: truthProp,
  9413. border: truthProp,
  9414. gutter: numericProp,
  9415. reverse: Boolean,
  9416. iconSize: numericProp,
  9417. direction: String,
  9418. clickable: Boolean,
  9419. columnNum: makeNumericProp(4)
  9420. };
  9421. const GRID_KEY = Symbol(name$w);
  9422. var stdin_default$C = defineComponent({
  9423. name: name$w,
  9424. props: gridProps,
  9425. setup(props, {
  9426. slots
  9427. }) {
  9428. const {
  9429. linkChildren
  9430. } = useChildren(GRID_KEY);
  9431. linkChildren({
  9432. props
  9433. });
  9434. return () => {
  9435. var _a;
  9436. return createVNode("div", {
  9437. "style": {
  9438. paddingLeft: addUnit(props.gutter)
  9439. },
  9440. "class": [bem$x(), {
  9441. [BORDER_TOP]: props.border && !props.gutter
  9442. }]
  9443. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9444. };
  9445. }
  9446. });
  9447. const Grid = withInstall(stdin_default$C);
  9448. const [name$v, bem$w] = createNamespace("grid-item");
  9449. const gridItemProps = extend({}, routeProps, {
  9450. dot: Boolean,
  9451. text: String,
  9452. icon: String,
  9453. badge: numericProp,
  9454. iconColor: String,
  9455. iconPrefix: String,
  9456. badgeProps: Object
  9457. });
  9458. var stdin_default$B = defineComponent({
  9459. name: name$v,
  9460. props: gridItemProps,
  9461. setup(props, {
  9462. slots
  9463. }) {
  9464. const {
  9465. parent,
  9466. index
  9467. } = useParent(GRID_KEY);
  9468. const route2 = useRoute();
  9469. if (!parent) {
  9470. if (process.env.NODE_ENV !== "production") {
  9471. console.error("[Vant] <GridItem> must be a child component of <Grid>.");
  9472. }
  9473. return;
  9474. }
  9475. const rootStyle = computed(() => {
  9476. const {
  9477. square,
  9478. gutter,
  9479. columnNum
  9480. } = parent.props;
  9481. const percent = `${100 / +columnNum}%`;
  9482. const style = {
  9483. flexBasis: percent
  9484. };
  9485. if (square) {
  9486. style.paddingTop = percent;
  9487. } else if (gutter) {
  9488. const gutterValue = addUnit(gutter);
  9489. style.paddingRight = gutterValue;
  9490. if (index.value >= columnNum) {
  9491. style.marginTop = gutterValue;
  9492. }
  9493. }
  9494. return style;
  9495. });
  9496. const contentStyle = computed(() => {
  9497. const {
  9498. square,
  9499. gutter
  9500. } = parent.props;
  9501. if (square && gutter) {
  9502. const gutterValue = addUnit(gutter);
  9503. return {
  9504. right: gutterValue,
  9505. bottom: gutterValue,
  9506. height: "auto"
  9507. };
  9508. }
  9509. });
  9510. const renderIcon = () => {
  9511. if (slots.icon) {
  9512. return createVNode(Badge, mergeProps({
  9513. "dot": props.dot,
  9514. "content": props.badge
  9515. }, props.badgeProps), {
  9516. default: slots.icon
  9517. });
  9518. }
  9519. if (props.icon) {
  9520. return createVNode(Icon, {
  9521. "dot": props.dot,
  9522. "name": props.icon,
  9523. "size": parent.props.iconSize,
  9524. "badge": props.badge,
  9525. "class": bem$w("icon"),
  9526. "color": props.iconColor,
  9527. "badgeProps": props.badgeProps,
  9528. "classPrefix": props.iconPrefix
  9529. }, null);
  9530. }
  9531. };
  9532. const renderText = () => {
  9533. if (slots.text) {
  9534. return slots.text();
  9535. }
  9536. if (props.text) {
  9537. return createVNode("span", {
  9538. "class": bem$w("text")
  9539. }, [props.text]);
  9540. }
  9541. };
  9542. const renderContent = () => {
  9543. if (slots.default) {
  9544. return slots.default();
  9545. }
  9546. return [renderIcon(), renderText()];
  9547. };
  9548. return () => {
  9549. const {
  9550. center,
  9551. border,
  9552. square,
  9553. gutter,
  9554. reverse,
  9555. direction,
  9556. clickable
  9557. } = parent.props;
  9558. const classes = [bem$w("content", [direction, {
  9559. center,
  9560. square,
  9561. reverse,
  9562. clickable,
  9563. surround: border && gutter
  9564. }]), {
  9565. [BORDER]: border
  9566. }];
  9567. return createVNode("div", {
  9568. "class": [bem$w({
  9569. square
  9570. })],
  9571. "style": rootStyle.value
  9572. }, [createVNode("div", {
  9573. "role": clickable ? "button" : void 0,
  9574. "class": classes,
  9575. "style": contentStyle.value,
  9576. "tabindex": clickable ? 0 : void 0,
  9577. "onClick": route2
  9578. }, [renderContent()])]);
  9579. };
  9580. }
  9581. });
  9582. const GridItem = withInstall(stdin_default$B);
  9583. const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
  9584. const bem$v = createNamespace("image-preview")[1];
  9585. var stdin_default$A = defineComponent({
  9586. props: {
  9587. src: String,
  9588. show: Boolean,
  9589. active: Number,
  9590. minZoom: makeRequiredProp(numericProp),
  9591. maxZoom: makeRequiredProp(numericProp),
  9592. rootWidth: makeRequiredProp(Number),
  9593. rootHeight: makeRequiredProp(Number)
  9594. },
  9595. emits: ["scale", "close"],
  9596. setup(props, {
  9597. emit
  9598. }) {
  9599. const state = reactive({
  9600. scale: 1,
  9601. moveX: 0,
  9602. moveY: 0,
  9603. moving: false,
  9604. zooming: false,
  9605. imageRatio: 0,
  9606. displayWidth: 0,
  9607. displayHeight: 0
  9608. });
  9609. const touch = useTouch();
  9610. const swipeItem = ref();
  9611. const vertical = computed(() => {
  9612. const {
  9613. rootWidth,
  9614. rootHeight
  9615. } = props;
  9616. const rootRatio = rootHeight / rootWidth;
  9617. return state.imageRatio > rootRatio;
  9618. });
  9619. const imageStyle = computed(() => {
  9620. const {
  9621. scale,
  9622. moveX,
  9623. moveY,
  9624. moving,
  9625. zooming
  9626. } = state;
  9627. const style = {
  9628. transitionDuration: zooming || moving ? "0s" : ".3s"
  9629. };
  9630. if (scale !== 1) {
  9631. const offsetX = moveX / scale;
  9632. const offsetY = moveY / scale;
  9633. style.transform = `scale(${scale}, ${scale}) translate(${offsetX}px, ${offsetY}px)`;
  9634. }
  9635. return style;
  9636. });
  9637. const maxMoveX = computed(() => {
  9638. if (state.imageRatio) {
  9639. const {
  9640. rootWidth,
  9641. rootHeight
  9642. } = props;
  9643. const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
  9644. return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
  9645. }
  9646. return 0;
  9647. });
  9648. const maxMoveY = computed(() => {
  9649. if (state.imageRatio) {
  9650. const {
  9651. rootWidth,
  9652. rootHeight
  9653. } = props;
  9654. const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
  9655. return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
  9656. }
  9657. return 0;
  9658. });
  9659. const setScale = (scale) => {
  9660. scale = clamp(scale, +props.minZoom, +props.maxZoom + 1);
  9661. if (scale !== state.scale) {
  9662. state.scale = scale;
  9663. emit("scale", {
  9664. scale,
  9665. index: props.active
  9666. });
  9667. }
  9668. };
  9669. const resetScale = () => {
  9670. setScale(1);
  9671. state.moveX = 0;
  9672. state.moveY = 0;
  9673. };
  9674. const toggleScale = () => {
  9675. const scale = state.scale > 1 ? 1 : 2;
  9676. setScale(scale);
  9677. state.moveX = 0;
  9678. state.moveY = 0;
  9679. };
  9680. let fingerNum;
  9681. let startMoveX;
  9682. let startMoveY;
  9683. let startScale;
  9684. let startDistance;
  9685. let doubleTapTimer;
  9686. let touchStartTime;
  9687. const onTouchStart = (event) => {
  9688. const {
  9689. touches
  9690. } = event;
  9691. const {
  9692. offsetX
  9693. } = touch;
  9694. touch.start(event);
  9695. fingerNum = touches.length;
  9696. startMoveX = state.moveX;
  9697. startMoveY = state.moveY;
  9698. touchStartTime = Date.now();
  9699. state.moving = fingerNum === 1 && state.scale !== 1;
  9700. state.zooming = fingerNum === 2 && !offsetX.value;
  9701. if (state.zooming) {
  9702. startScale = state.scale;
  9703. startDistance = getDistance(event.touches);
  9704. }
  9705. };
  9706. const onTouchMove = (event) => {
  9707. const {
  9708. touches
  9709. } = event;
  9710. touch.move(event);
  9711. if (state.moving || state.zooming) {
  9712. preventDefault(event, true);
  9713. }
  9714. if (state.moving) {
  9715. const {
  9716. deltaX,
  9717. deltaY
  9718. } = touch;
  9719. const moveX = deltaX.value + startMoveX;
  9720. const moveY = deltaY.value + startMoveY;
  9721. state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
  9722. state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
  9723. }
  9724. if (state.zooming && touches.length === 2) {
  9725. const distance = getDistance(touches);
  9726. const scale = startScale * distance / startDistance;
  9727. setScale(scale);
  9728. }
  9729. };
  9730. const checkTap = () => {
  9731. if (fingerNum > 1) {
  9732. return;
  9733. }
  9734. const {
  9735. offsetX,
  9736. offsetY
  9737. } = touch;
  9738. const deltaTime = Date.now() - touchStartTime;
  9739. const TAP_TIME = 250;
  9740. const TAP_OFFSET = 5;
  9741. if (offsetX.value < TAP_OFFSET && offsetY.value < TAP_OFFSET && deltaTime < TAP_TIME) {
  9742. if (doubleTapTimer) {
  9743. clearTimeout(doubleTapTimer);
  9744. doubleTapTimer = null;
  9745. toggleScale();
  9746. } else {
  9747. doubleTapTimer = setTimeout(() => {
  9748. emit("close");
  9749. doubleTapTimer = null;
  9750. }, TAP_TIME);
  9751. }
  9752. }
  9753. };
  9754. const onTouchEnd = (event) => {
  9755. let stopPropagation2 = false;
  9756. if (state.moving || state.zooming) {
  9757. stopPropagation2 = true;
  9758. if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
  9759. stopPropagation2 = false;
  9760. }
  9761. if (!event.touches.length) {
  9762. if (state.zooming) {
  9763. state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
  9764. state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
  9765. state.zooming = false;
  9766. }
  9767. state.moving = false;
  9768. startMoveX = 0;
  9769. startMoveY = 0;
  9770. startScale = 1;
  9771. if (state.scale < 1) {
  9772. resetScale();
  9773. }
  9774. if (state.scale > props.maxZoom) {
  9775. state.scale = +props.maxZoom;
  9776. }
  9777. }
  9778. }
  9779. preventDefault(event, stopPropagation2);
  9780. checkTap();
  9781. touch.reset();
  9782. };
  9783. const onLoad = (event) => {
  9784. const {
  9785. naturalWidth,
  9786. naturalHeight
  9787. } = event.target;
  9788. state.imageRatio = naturalHeight / naturalWidth;
  9789. };
  9790. watch(() => props.active, resetScale);
  9791. watch(() => props.show, (value) => {
  9792. if (!value) {
  9793. resetScale();
  9794. }
  9795. });
  9796. useEventListener("touchmove", onTouchMove, {
  9797. target: computed(() => {
  9798. var _a;
  9799. return (_a = swipeItem.value) == null ? void 0 : _a.$el;
  9800. })
  9801. });
  9802. return () => {
  9803. const imageSlots = {
  9804. loading: () => createVNode(Loading, {
  9805. "type": "spinner"
  9806. }, null)
  9807. };
  9808. return createVNode(SwipeItem, {
  9809. "ref": swipeItem,
  9810. "class": bem$v("swipe-item"),
  9811. "onTouchstartPassive": onTouchStart,
  9812. "onTouchend": onTouchEnd,
  9813. "onTouchcancel": onTouchEnd
  9814. }, {
  9815. default: () => [createVNode(Image$1, {
  9816. "src": props.src,
  9817. "fit": "contain",
  9818. "class": bem$v("image", {
  9819. vertical: vertical.value
  9820. }),
  9821. "style": imageStyle.value,
  9822. "onLoad": onLoad
  9823. }, imageSlots)]
  9824. });
  9825. };
  9826. }
  9827. });
  9828. const [name$u, bem$u] = createNamespace("image-preview");
  9829. const popupProps$1 = ["show", "transition", "overlayStyle", "closeOnPopstate"];
  9830. const imagePreviewProps = {
  9831. show: Boolean,
  9832. loop: truthProp,
  9833. images: makeArrayProp(),
  9834. minZoom: makeNumericProp(1 / 3),
  9835. maxZoom: makeNumericProp(3),
  9836. overlay: truthProp,
  9837. closeable: Boolean,
  9838. showIndex: truthProp,
  9839. className: unknownProp,
  9840. closeIcon: makeStringProp("clear"),
  9841. transition: String,
  9842. beforeClose: Function,
  9843. overlayClass: unknownProp,
  9844. overlayStyle: Object,
  9845. swipeDuration: makeNumericProp(300),
  9846. startPosition: makeNumericProp(0),
  9847. showIndicators: Boolean,
  9848. closeOnPopstate: truthProp,
  9849. closeIconPosition: makeStringProp("top-right")
  9850. };
  9851. var stdin_default$z = defineComponent({
  9852. name: name$u,
  9853. props: imagePreviewProps,
  9854. emits: ["scale", "close", "closed", "change", "update:show"],
  9855. setup(props, {
  9856. emit,
  9857. slots
  9858. }) {
  9859. const swipeRef = ref();
  9860. const state = reactive({
  9861. active: 0,
  9862. rootWidth: 0,
  9863. rootHeight: 0
  9864. });
  9865. const resize = () => {
  9866. if (swipeRef.value) {
  9867. const rect = useRect(swipeRef.value.$el);
  9868. state.rootWidth = rect.width;
  9869. state.rootHeight = rect.height;
  9870. swipeRef.value.resize();
  9871. }
  9872. };
  9873. const emitScale = (args) => emit("scale", args);
  9874. const updateShow = (show) => emit("update:show", show);
  9875. const emitClose = () => {
  9876. callInterceptor(props.beforeClose, {
  9877. args: [state.active],
  9878. done: () => updateShow(false)
  9879. });
  9880. };
  9881. const setActive = (active) => {
  9882. if (active !== state.active) {
  9883. state.active = active;
  9884. emit("change", active);
  9885. }
  9886. };
  9887. const renderIndex = () => {
  9888. if (props.showIndex) {
  9889. return createVNode("div", {
  9890. "class": bem$u("index")
  9891. }, [slots.index ? slots.index({
  9892. index: state.active
  9893. }) : `${state.active + 1} / ${props.images.length}`]);
  9894. }
  9895. };
  9896. const renderCover = () => {
  9897. if (slots.cover) {
  9898. return createVNode("div", {
  9899. "class": bem$u("cover")
  9900. }, [slots.cover()]);
  9901. }
  9902. };
  9903. const renderImages = () => createVNode(Swipe, {
  9904. "ref": swipeRef,
  9905. "lazyRender": true,
  9906. "loop": props.loop,
  9907. "class": bem$u("swipe"),
  9908. "duration": props.swipeDuration,
  9909. "initialSwipe": props.startPosition,
  9910. "showIndicators": props.showIndicators,
  9911. "indicatorColor": "white",
  9912. "onChange": setActive
  9913. }, {
  9914. default: () => [props.images.map((image) => createVNode(stdin_default$A, {
  9915. "src": image,
  9916. "show": props.show,
  9917. "active": state.active,
  9918. "maxZoom": props.maxZoom,
  9919. "minZoom": props.minZoom,
  9920. "rootWidth": state.rootWidth,
  9921. "rootHeight": state.rootHeight,
  9922. "onScale": emitScale,
  9923. "onClose": emitClose
  9924. }, null))]
  9925. });
  9926. const renderClose = () => {
  9927. if (props.closeable) {
  9928. return createVNode(Icon, {
  9929. "role": "button",
  9930. "name": props.closeIcon,
  9931. "class": [bem$u("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
  9932. "onClick": emitClose
  9933. }, null);
  9934. }
  9935. };
  9936. const onClosed = () => emit("closed");
  9937. const swipeTo = (index, options) => {
  9938. var _a;
  9939. return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index, options);
  9940. };
  9941. useExpose({
  9942. swipeTo
  9943. });
  9944. onMounted(resize);
  9945. watch([windowWidth, windowHeight], resize);
  9946. watch(() => props.startPosition, (value) => setActive(+value));
  9947. watch(() => props.show, (value) => {
  9948. const {
  9949. images,
  9950. startPosition
  9951. } = props;
  9952. if (value) {
  9953. setActive(+startPosition);
  9954. nextTick(() => {
  9955. resize();
  9956. swipeTo(+startPosition, {
  9957. immediate: true
  9958. });
  9959. });
  9960. } else {
  9961. emit("close", {
  9962. index: state.active,
  9963. url: images[state.active]
  9964. });
  9965. }
  9966. });
  9967. return () => createVNode(Popup, mergeProps({
  9968. "class": [bem$u(), props.className],
  9969. "overlayClass": [bem$u("overlay"), props.overlayClass],
  9970. "onClosed": onClosed,
  9971. "onUpdate:show": updateShow
  9972. }, pick(props, popupProps$1)), {
  9973. default: () => [renderClose(), renderImages(), renderIndex(), renderCover()]
  9974. });
  9975. }
  9976. });
  9977. let instance$1;
  9978. const defaultConfig = {
  9979. loop: true,
  9980. images: [],
  9981. maxZoom: 3,
  9982. minZoom: 1 / 3,
  9983. onScale: void 0,
  9984. onClose: void 0,
  9985. onChange: void 0,
  9986. teleport: "body",
  9987. className: "",
  9988. showIndex: true,
  9989. closeable: false,
  9990. closeIcon: "clear",
  9991. transition: void 0,
  9992. beforeClose: void 0,
  9993. overlayStyle: void 0,
  9994. overlayClass: void 0,
  9995. startPosition: 0,
  9996. swipeDuration: 300,
  9997. showIndicators: false,
  9998. closeOnPopstate: true,
  9999. closeIconPosition: "top-right"
  10000. };
  10001. function initInstance$1() {
  10002. ({
  10003. instance: instance$1
  10004. } = mountComponent({
  10005. setup() {
  10006. const {
  10007. state,
  10008. toggle
  10009. } = usePopupState();
  10010. const onClosed = () => {
  10011. state.images = [];
  10012. };
  10013. return () => createVNode(stdin_default$z, mergeProps(state, {
  10014. "onClosed": onClosed,
  10015. "onUpdate:show": toggle
  10016. }), null);
  10017. }
  10018. }));
  10019. }
  10020. const ImagePreview = (options, startPosition = 0) => {
  10021. if (!inBrowser) {
  10022. return;
  10023. }
  10024. if (!instance$1) {
  10025. initInstance$1();
  10026. }
  10027. options = Array.isArray(options) ? {
  10028. images: options,
  10029. startPosition
  10030. } : options;
  10031. instance$1.open(extend({}, defaultConfig, options));
  10032. return instance$1;
  10033. };
  10034. ImagePreview.Component = withInstall(stdin_default$z);
  10035. ImagePreview.install = (app) => {
  10036. app.use(ImagePreview.Component);
  10037. };
  10038. function genAlphabet() {
  10039. const charCodeOfA = "A".charCodeAt(0);
  10040. const indexList = Array(26).fill("").map((_, i) => String.fromCharCode(charCodeOfA + i));
  10041. return indexList;
  10042. }
  10043. const [name$t, bem$t] = createNamespace("index-bar");
  10044. const indexBarProps = {
  10045. sticky: truthProp,
  10046. zIndex: numericProp,
  10047. teleport: [String, Object],
  10048. highlightColor: String,
  10049. stickyOffsetTop: makeNumberProp(0),
  10050. indexList: {
  10051. type: Array,
  10052. default: genAlphabet
  10053. }
  10054. };
  10055. const INDEX_BAR_KEY = Symbol(name$t);
  10056. var stdin_default$y = defineComponent({
  10057. name: name$t,
  10058. props: indexBarProps,
  10059. emits: ["select", "change"],
  10060. setup(props, {
  10061. emit,
  10062. slots
  10063. }) {
  10064. const root = ref();
  10065. const sidebar = ref();
  10066. const activeAnchor = ref("");
  10067. const touch = useTouch();
  10068. const scrollParent = useScrollParent(root);
  10069. const {
  10070. children,
  10071. linkChildren
  10072. } = useChildren(INDEX_BAR_KEY);
  10073. let selectActiveIndex;
  10074. linkChildren({
  10075. props
  10076. });
  10077. const sidebarStyle = computed(() => {
  10078. if (isDef(props.zIndex)) {
  10079. return {
  10080. zIndex: +props.zIndex + 1
  10081. };
  10082. }
  10083. });
  10084. const highlightStyle = computed(() => {
  10085. if (props.highlightColor) {
  10086. return {
  10087. color: props.highlightColor
  10088. };
  10089. }
  10090. });
  10091. const getActiveAnchor = (scrollTop, rects) => {
  10092. for (let i = children.length - 1; i >= 0; i--) {
  10093. const prevHeight = i > 0 ? rects[i - 1].height : 0;
  10094. const reachTop = props.sticky ? prevHeight + props.stickyOffsetTop : 0;
  10095. if (scrollTop + reachTop >= rects[i].top) {
  10096. return i;
  10097. }
  10098. }
  10099. return -1;
  10100. };
  10101. const getMatchAnchor = (index) => children.find((item) => String(item.index) === index);
  10102. const onScroll = () => {
  10103. if (isHidden(root)) {
  10104. return;
  10105. }
  10106. const {
  10107. sticky,
  10108. indexList
  10109. } = props;
  10110. const scrollTop = getScrollTop(scrollParent.value);
  10111. const scrollParentRect = useRect(scrollParent);
  10112. const rects = children.map((item) => item.getRect(scrollParent.value, scrollParentRect));
  10113. let active = -1;
  10114. if (selectActiveIndex) {
  10115. const match = getMatchAnchor(selectActiveIndex);
  10116. if (match) {
  10117. const rect = match.getRect(scrollParent.value, scrollParentRect);
  10118. active = getActiveAnchor(rect.top, rects);
  10119. }
  10120. } else {
  10121. active = getActiveAnchor(scrollTop, rects);
  10122. }
  10123. activeAnchor.value = indexList[active];
  10124. if (sticky) {
  10125. children.forEach((item, index) => {
  10126. const {
  10127. state,
  10128. $el
  10129. } = item;
  10130. if (index === active || index === active - 1) {
  10131. const rect = $el.getBoundingClientRect();
  10132. state.left = rect.left;
  10133. state.width = rect.width;
  10134. } else {
  10135. state.left = null;
  10136. state.width = null;
  10137. }
  10138. if (index === active) {
  10139. state.active = true;
  10140. state.top = Math.max(props.stickyOffsetTop, rects[index].top - scrollTop) + scrollParentRect.top;
  10141. } else if (index === active - 1 && selectActiveIndex === "") {
  10142. const activeItemTop = rects[active].top - scrollTop;
  10143. state.active = activeItemTop > 0;
  10144. state.top = activeItemTop + scrollParentRect.top - rects[index].height;
  10145. } else {
  10146. state.active = false;
  10147. }
  10148. });
  10149. }
  10150. selectActiveIndex = "";
  10151. };
  10152. const init = () => {
  10153. nextTick(onScroll);
  10154. };
  10155. useEventListener("scroll", onScroll, {
  10156. target: scrollParent,
  10157. passive: true
  10158. });
  10159. onMounted(init);
  10160. watch(() => props.indexList, init);
  10161. watch(activeAnchor, (value) => {
  10162. if (value) {
  10163. emit("change", value);
  10164. }
  10165. });
  10166. const renderIndexes = () => props.indexList.map((index) => {
  10167. const active = index === activeAnchor.value;
  10168. return createVNode("span", {
  10169. "class": bem$t("index", {
  10170. active
  10171. }),
  10172. "style": active ? highlightStyle.value : void 0,
  10173. "data-index": index
  10174. }, [index]);
  10175. });
  10176. const scrollTo = (index) => {
  10177. selectActiveIndex = String(index);
  10178. const match = getMatchAnchor(selectActiveIndex);
  10179. if (match) {
  10180. const scrollTop = getScrollTop(scrollParent.value);
  10181. const scrollParentRect = useRect(scrollParent);
  10182. const {
  10183. offsetHeight
  10184. } = document.documentElement;
  10185. match.$el.scrollIntoView();
  10186. if (scrollTop === offsetHeight - scrollParentRect.height) {
  10187. onScroll();
  10188. return;
  10189. }
  10190. if (props.sticky && props.stickyOffsetTop) {
  10191. setRootScrollTop(getRootScrollTop() - props.stickyOffsetTop);
  10192. }
  10193. emit("select", match.index);
  10194. }
  10195. };
  10196. const scrollToElement = (element) => {
  10197. const {
  10198. index
  10199. } = element.dataset;
  10200. if (index) {
  10201. scrollTo(index);
  10202. }
  10203. };
  10204. const onClickSidebar = (event) => {
  10205. scrollToElement(event.target);
  10206. };
  10207. let touchActiveIndex;
  10208. const onTouchMove = (event) => {
  10209. touch.move(event);
  10210. if (touch.isVertical()) {
  10211. preventDefault(event);
  10212. const {
  10213. clientX,
  10214. clientY
  10215. } = event.touches[0];
  10216. const target = document.elementFromPoint(clientX, clientY);
  10217. if (target) {
  10218. const {
  10219. index
  10220. } = target.dataset;
  10221. if (index && touchActiveIndex !== index) {
  10222. touchActiveIndex = index;
  10223. scrollToElement(target);
  10224. }
  10225. }
  10226. }
  10227. };
  10228. const renderSidebar = () => createVNode("div", {
  10229. "ref": sidebar,
  10230. "class": bem$t("sidebar"),
  10231. "style": sidebarStyle.value,
  10232. "onClick": onClickSidebar,
  10233. "onTouchstartPassive": touch.start
  10234. }, [renderIndexes()]);
  10235. useExpose({
  10236. scrollTo
  10237. });
  10238. useEventListener("touchmove", onTouchMove, {
  10239. target: sidebar
  10240. });
  10241. return () => {
  10242. var _a;
  10243. return createVNode("div", {
  10244. "ref": root,
  10245. "class": bem$t()
  10246. }, [props.teleport ? createVNode(Teleport, {
  10247. "to": props.teleport
  10248. }, {
  10249. default: () => [renderSidebar()]
  10250. }) : renderSidebar(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  10251. };
  10252. }
  10253. });
  10254. const [name$s, bem$s] = createNamespace("index-anchor");
  10255. const indexAnchorProps = {
  10256. index: numericProp
  10257. };
  10258. var stdin_default$x = defineComponent({
  10259. name: name$s,
  10260. props: indexAnchorProps,
  10261. setup(props, {
  10262. slots
  10263. }) {
  10264. const state = reactive({
  10265. top: 0,
  10266. left: null,
  10267. rect: {
  10268. top: 0,
  10269. height: 0
  10270. },
  10271. width: null,
  10272. active: false
  10273. });
  10274. const root = ref();
  10275. const {
  10276. parent
  10277. } = useParent(INDEX_BAR_KEY);
  10278. if (!parent) {
  10279. if (process.env.NODE_ENV !== "production") {
  10280. console.error("[Vant] <IndexAnchor> must be a child component of <IndexBar>.");
  10281. }
  10282. return;
  10283. }
  10284. const isSticky = () => state.active && parent.props.sticky;
  10285. const anchorStyle = computed(() => {
  10286. const {
  10287. zIndex,
  10288. highlightColor
  10289. } = parent.props;
  10290. if (isSticky()) {
  10291. return extend(getZIndexStyle(zIndex), {
  10292. left: state.left ? `${state.left}px` : void 0,
  10293. width: state.width ? `${state.width}px` : void 0,
  10294. transform: state.top ? `translate3d(0, ${state.top}px, 0)` : void 0,
  10295. color: highlightColor
  10296. });
  10297. }
  10298. });
  10299. const getRect = (scrollParent, scrollParentRect) => {
  10300. const rootRect = useRect(root);
  10301. state.rect.height = rootRect.height;
  10302. if (scrollParent === window || scrollParent === document.body) {
  10303. state.rect.top = rootRect.top + getRootScrollTop();
  10304. } else {
  10305. state.rect.top = rootRect.top + getScrollTop(scrollParent) - scrollParentRect.top;
  10306. }
  10307. return state.rect;
  10308. };
  10309. useExpose({
  10310. state,
  10311. getRect
  10312. });
  10313. return () => {
  10314. const sticky = isSticky();
  10315. return createVNode("div", {
  10316. "ref": root,
  10317. "style": {
  10318. height: sticky ? `${state.rect.height}px` : void 0
  10319. }
  10320. }, [createVNode("div", {
  10321. "style": anchorStyle.value,
  10322. "class": [bem$s({
  10323. sticky
  10324. }), {
  10325. [BORDER_BOTTOM]: sticky
  10326. }]
  10327. }, [slots.default ? slots.default() : props.index])]);
  10328. };
  10329. }
  10330. });
  10331. const IndexAnchor = withInstall(stdin_default$x);
  10332. const IndexBar = withInstall(stdin_default$y);
  10333. const [name$r, bem$r, t$6] = createNamespace("list");
  10334. const listProps = {
  10335. error: Boolean,
  10336. offset: makeNumericProp(300),
  10337. loading: Boolean,
  10338. finished: Boolean,
  10339. errorText: String,
  10340. direction: makeStringProp("down"),
  10341. loadingText: String,
  10342. finishedText: String,
  10343. immediateCheck: truthProp
  10344. };
  10345. var stdin_default$w = defineComponent({
  10346. name: name$r,
  10347. props: listProps,
  10348. emits: ["load", "update:error", "update:loading"],
  10349. setup(props, {
  10350. emit,
  10351. slots
  10352. }) {
  10353. const loading = ref(false);
  10354. const root = ref();
  10355. const placeholder = ref();
  10356. const tabStatus = useTabStatus();
  10357. const scrollParent = useScrollParent(root);
  10358. const check = () => {
  10359. nextTick(() => {
  10360. if (loading.value || props.finished || props.error || (tabStatus == null ? void 0 : tabStatus.value) === false) {
  10361. return;
  10362. }
  10363. const {
  10364. offset,
  10365. direction
  10366. } = props;
  10367. const scrollParentRect = useRect(scrollParent);
  10368. if (!scrollParentRect.height || isHidden(root)) {
  10369. return;
  10370. }
  10371. let isReachEdge = false;
  10372. const placeholderRect = useRect(placeholder);
  10373. if (direction === "up") {
  10374. isReachEdge = scrollParentRect.top - placeholderRect.top <= offset;
  10375. } else {
  10376. isReachEdge = placeholderRect.bottom - scrollParentRect.bottom <= offset;
  10377. }
  10378. if (isReachEdge) {
  10379. loading.value = true;
  10380. emit("update:loading", true);
  10381. emit("load");
  10382. }
  10383. });
  10384. };
  10385. const renderFinishedText = () => {
  10386. if (props.finished) {
  10387. const text = slots.finished ? slots.finished() : props.finishedText;
  10388. if (text) {
  10389. return createVNode("div", {
  10390. "class": bem$r("finished-text")
  10391. }, [text]);
  10392. }
  10393. }
  10394. };
  10395. const clickErrorText = () => {
  10396. emit("update:error", false);
  10397. check();
  10398. };
  10399. const renderErrorText = () => {
  10400. if (props.error) {
  10401. const text = slots.error ? slots.error() : props.errorText;
  10402. if (text) {
  10403. return createVNode("div", {
  10404. "role": "button",
  10405. "class": bem$r("error-text"),
  10406. "tabindex": 0,
  10407. "onClick": clickErrorText
  10408. }, [text]);
  10409. }
  10410. }
  10411. };
  10412. const renderLoading = () => {
  10413. if (loading.value && !props.finished) {
  10414. return createVNode("div", {
  10415. "class": bem$r("loading")
  10416. }, [slots.loading ? slots.loading() : createVNode(Loading, {
  10417. "class": bem$r("loading-icon")
  10418. }, {
  10419. default: () => [props.loadingText || t$6("loading")]
  10420. })]);
  10421. }
  10422. };
  10423. watch(() => [props.loading, props.finished, props.error], check);
  10424. if (tabStatus) {
  10425. watch(tabStatus, (tabActive) => {
  10426. if (tabActive) {
  10427. check();
  10428. }
  10429. });
  10430. }
  10431. onUpdated(() => {
  10432. loading.value = props.loading;
  10433. });
  10434. onMounted(() => {
  10435. if (props.immediateCheck) {
  10436. check();
  10437. }
  10438. });
  10439. useExpose({
  10440. check
  10441. });
  10442. useEventListener("scroll", check, {
  10443. target: scrollParent,
  10444. passive: true
  10445. });
  10446. return () => {
  10447. var _a;
  10448. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  10449. const Placeholder = createVNode("div", {
  10450. "ref": placeholder,
  10451. "class": bem$r("placeholder")
  10452. }, null);
  10453. return createVNode("div", {
  10454. "ref": root,
  10455. "role": "feed",
  10456. "class": bem$r(),
  10457. "aria-busy": loading.value
  10458. }, [props.direction === "down" ? Content : Placeholder, renderLoading(), renderFinishedText(), renderErrorText(), props.direction === "up" ? Content : Placeholder]);
  10459. };
  10460. }
  10461. });
  10462. const List = withInstall(stdin_default$w);
  10463. const [name$q, bem$q] = createNamespace("nav-bar");
  10464. const navBarProps = {
  10465. title: String,
  10466. fixed: Boolean,
  10467. zIndex: numericProp,
  10468. border: truthProp,
  10469. leftText: String,
  10470. rightText: String,
  10471. leftArrow: Boolean,
  10472. placeholder: Boolean,
  10473. safeAreaInsetTop: Boolean
  10474. };
  10475. var stdin_default$v = defineComponent({
  10476. name: name$q,
  10477. props: navBarProps,
  10478. emits: ["click-left", "click-right"],
  10479. setup(props, {
  10480. emit,
  10481. slots
  10482. }) {
  10483. const navBarRef = ref();
  10484. const renderPlaceholder = usePlaceholder(navBarRef, bem$q);
  10485. const onClickLeft = (event) => emit("click-left", event);
  10486. const onClickRight = (event) => emit("click-right", event);
  10487. const renderLeft = () => {
  10488. if (slots.left) {
  10489. return slots.left();
  10490. }
  10491. return [props.leftArrow && createVNode(Icon, {
  10492. "class": bem$q("arrow"),
  10493. "name": "arrow-left"
  10494. }, null), props.leftText && createVNode("span", {
  10495. "class": bem$q("text")
  10496. }, [props.leftText])];
  10497. };
  10498. const renderRight = () => {
  10499. if (slots.right) {
  10500. return slots.right();
  10501. }
  10502. return createVNode("span", {
  10503. "class": bem$q("text")
  10504. }, [props.rightText]);
  10505. };
  10506. const renderNavBar = () => {
  10507. const {
  10508. title,
  10509. fixed,
  10510. border,
  10511. zIndex
  10512. } = props;
  10513. const style = getZIndexStyle(zIndex);
  10514. const hasLeft = props.leftArrow || props.leftText || slots.left;
  10515. const hasRight = props.rightText || slots.right;
  10516. return createVNode("div", {
  10517. "ref": navBarRef,
  10518. "style": style,
  10519. "class": [bem$q({
  10520. fixed
  10521. }), {
  10522. [BORDER_BOTTOM]: border,
  10523. "van-safe-area-top": props.safeAreaInsetTop
  10524. }]
  10525. }, [createVNode("div", {
  10526. "class": bem$q("content")
  10527. }, [hasLeft && createVNode("div", {
  10528. "class": [bem$q("left"), HAPTICS_FEEDBACK],
  10529. "onClick": onClickLeft
  10530. }, [renderLeft()]), createVNode("div", {
  10531. "class": [bem$q("title"), "van-ellipsis"]
  10532. }, [slots.title ? slots.title() : title]), hasRight && createVNode("div", {
  10533. "class": [bem$q("right"), HAPTICS_FEEDBACK],
  10534. "onClick": onClickRight
  10535. }, [renderRight()])])]);
  10536. };
  10537. return () => {
  10538. if (props.fixed && props.placeholder) {
  10539. return renderPlaceholder(renderNavBar);
  10540. }
  10541. return renderNavBar();
  10542. };
  10543. }
  10544. });
  10545. const NavBar = withInstall(stdin_default$v);
  10546. const [name$p, bem$p] = createNamespace("notice-bar");
  10547. const noticeBarProps = {
  10548. text: String,
  10549. mode: String,
  10550. color: String,
  10551. delay: makeNumericProp(1),
  10552. speed: makeNumericProp(60),
  10553. leftIcon: String,
  10554. wrapable: Boolean,
  10555. background: String,
  10556. scrollable: {
  10557. type: Boolean,
  10558. default: null
  10559. }
  10560. };
  10561. var stdin_default$u = defineComponent({
  10562. name: name$p,
  10563. props: noticeBarProps,
  10564. emits: ["close", "replay"],
  10565. setup(props, {
  10566. emit,
  10567. slots
  10568. }) {
  10569. let wrapWidth = 0;
  10570. let contentWidth = 0;
  10571. let startTimer;
  10572. const wrapRef = ref();
  10573. const contentRef = ref();
  10574. const state = reactive({
  10575. show: true,
  10576. offset: 0,
  10577. duration: 0
  10578. });
  10579. const renderLeftIcon = () => {
  10580. if (slots["left-icon"]) {
  10581. return slots["left-icon"]();
  10582. }
  10583. if (props.leftIcon) {
  10584. return createVNode(Icon, {
  10585. "class": bem$p("left-icon"),
  10586. "name": props.leftIcon
  10587. }, null);
  10588. }
  10589. };
  10590. const getRightIconName = () => {
  10591. if (props.mode === "closeable") {
  10592. return "cross";
  10593. }
  10594. if (props.mode === "link") {
  10595. return "arrow";
  10596. }
  10597. };
  10598. const onClickRightIcon = (event) => {
  10599. if (props.mode === "closeable") {
  10600. state.show = false;
  10601. emit("close", event);
  10602. }
  10603. };
  10604. const renderRightIcon = () => {
  10605. if (slots["right-icon"]) {
  10606. return slots["right-icon"]();
  10607. }
  10608. const name2 = getRightIconName();
  10609. if (name2) {
  10610. return createVNode(Icon, {
  10611. "name": name2,
  10612. "class": bem$p("right-icon"),
  10613. "onClick": onClickRightIcon
  10614. }, null);
  10615. }
  10616. };
  10617. const onTransitionEnd = () => {
  10618. state.offset = wrapWidth;
  10619. state.duration = 0;
  10620. raf(() => {
  10621. doubleRaf(() => {
  10622. state.offset = -contentWidth;
  10623. state.duration = (contentWidth + wrapWidth) / +props.speed;
  10624. emit("replay");
  10625. });
  10626. });
  10627. };
  10628. const renderMarquee = () => {
  10629. const ellipsis = props.scrollable === false && !props.wrapable;
  10630. const style = {
  10631. transform: state.offset ? `translateX(${state.offset}px)` : "",
  10632. transitionDuration: `${state.duration}s`
  10633. };
  10634. return createVNode("div", {
  10635. "ref": wrapRef,
  10636. "role": "marquee",
  10637. "class": bem$p("wrap")
  10638. }, [createVNode("div", {
  10639. "ref": contentRef,
  10640. "style": style,
  10641. "class": [bem$p("content"), {
  10642. "van-ellipsis": ellipsis
  10643. }],
  10644. "onTransitionend": onTransitionEnd
  10645. }, [slots.default ? slots.default() : props.text])]);
  10646. };
  10647. const reset = () => {
  10648. const {
  10649. delay,
  10650. speed,
  10651. scrollable
  10652. } = props;
  10653. const ms = isDef(delay) ? +delay * 1e3 : 0;
  10654. wrapWidth = 0;
  10655. contentWidth = 0;
  10656. state.offset = 0;
  10657. state.duration = 0;
  10658. clearTimeout(startTimer);
  10659. startTimer = setTimeout(() => {
  10660. if (!wrapRef.value || !contentRef.value || scrollable === false) {
  10661. return;
  10662. }
  10663. const wrapRefWidth = useRect(wrapRef).width;
  10664. const contentRefWidth = useRect(contentRef).width;
  10665. if (scrollable || contentRefWidth > wrapRefWidth) {
  10666. doubleRaf(() => {
  10667. wrapWidth = wrapRefWidth;
  10668. contentWidth = contentRefWidth;
  10669. state.offset = -contentWidth;
  10670. state.duration = contentWidth / +speed;
  10671. });
  10672. }
  10673. }, ms);
  10674. };
  10675. onPopupReopen(reset);
  10676. onMountedOrActivated(reset);
  10677. useEventListener("pageshow", reset);
  10678. useExpose({
  10679. reset
  10680. });
  10681. watch(() => [props.text, props.scrollable], reset);
  10682. return () => {
  10683. const {
  10684. color,
  10685. wrapable,
  10686. background
  10687. } = props;
  10688. return withDirectives(createVNode("div", {
  10689. "role": "alert",
  10690. "class": bem$p({
  10691. wrapable
  10692. }),
  10693. "style": {
  10694. color,
  10695. background
  10696. }
  10697. }, [renderLeftIcon(), renderMarquee(), renderRightIcon()]), [[vShow, state.show]]);
  10698. };
  10699. }
  10700. });
  10701. const NoticeBar = withInstall(stdin_default$u);
  10702. const [name$o, bem$o] = createNamespace("notify");
  10703. const notifyProps = extend({}, popupSharedProps, {
  10704. type: makeStringProp("danger"),
  10705. color: String,
  10706. message: numericProp,
  10707. position: makeStringProp("top"),
  10708. className: unknownProp,
  10709. background: String,
  10710. lockScroll: Boolean
  10711. });
  10712. var stdin_default$t = defineComponent({
  10713. name: name$o,
  10714. props: notifyProps,
  10715. emits: ["update:show"],
  10716. setup(props, {
  10717. emit,
  10718. slots
  10719. }) {
  10720. const updateShow = (show) => emit("update:show", show);
  10721. return () => createVNode(Popup, {
  10722. "show": props.show,
  10723. "class": [bem$o([props.type]), props.className],
  10724. "style": {
  10725. color: props.color,
  10726. background: props.background
  10727. },
  10728. "overlay": false,
  10729. "position": props.position,
  10730. "duration": 0.2,
  10731. "lockScroll": props.lockScroll,
  10732. "onUpdate:show": updateShow
  10733. }, {
  10734. default: () => [slots.default ? slots.default() : props.message]
  10735. });
  10736. }
  10737. });
  10738. let timer;
  10739. let instance;
  10740. const parseOptions = (message) => isObject(message) ? message : {
  10741. message
  10742. };
  10743. function initInstance() {
  10744. ({
  10745. instance
  10746. } = mountComponent({
  10747. setup() {
  10748. const {
  10749. state,
  10750. toggle
  10751. } = usePopupState();
  10752. return () => createVNode(stdin_default$t, mergeProps(state, {
  10753. "onUpdate:show": toggle
  10754. }), null);
  10755. }
  10756. }));
  10757. }
  10758. function Notify(options) {
  10759. if (!inBrowser) {
  10760. return;
  10761. }
  10762. if (!instance) {
  10763. initInstance();
  10764. }
  10765. options = extend({}, Notify.currentOptions, parseOptions(options));
  10766. instance.open(options);
  10767. clearTimeout(timer);
  10768. if (options.duration > 0) {
  10769. timer = window.setTimeout(Notify.clear, options.duration);
  10770. }
  10771. return instance;
  10772. }
  10773. const getDefaultOptions = () => ({
  10774. type: "danger",
  10775. color: void 0,
  10776. message: "",
  10777. onClose: void 0,
  10778. onClick: void 0,
  10779. onOpened: void 0,
  10780. duration: 3e3,
  10781. position: void 0,
  10782. className: "",
  10783. lockScroll: false,
  10784. background: void 0
  10785. });
  10786. Notify.clear = () => {
  10787. if (instance) {
  10788. instance.toggle(false);
  10789. }
  10790. };
  10791. Notify.currentOptions = getDefaultOptions();
  10792. Notify.setDefaultOptions = (options) => {
  10793. extend(Notify.currentOptions, options);
  10794. };
  10795. Notify.resetDefaultOptions = () => {
  10796. Notify.currentOptions = getDefaultOptions();
  10797. };
  10798. Notify.Component = withInstall(stdin_default$t);
  10799. Notify.install = (app) => {
  10800. app.use(Notify.Component);
  10801. app.config.globalProperties.$notify = Notify;
  10802. };
  10803. const [name$n, bem$n] = createNamespace("key");
  10804. const CollapseIcon = createVNode("svg", {
  10805. "class": bem$n("collapse-icon"),
  10806. "viewBox": "0 0 30 24"
  10807. }, [createVNode("path", {
  10808. "d": "M26 13h-2v2h2v-2zm-8-3h2V8h-2v2zm2-4h2V4h-2v2zm2 4h4V4h-2v4h-2v2zm-7 14 3-3h-6l3 3zM6 13H4v2h2v-2zm16 0H8v2h14v-2zm-12-3h2V8h-2v2zM28 0l1 1 1 1v15l-1 2H1l-1-2V2l1-1 1-1zm0 2H2v15h26V2zM6 4v2H4V4zm10 2h2V4h-2v2zM8 9v1H4V8zm8 0v1h-2V8zm-6-5v2H8V4zm4 0v2h-2V4z",
  10809. "fill": "currentColor"
  10810. }, null)]);
  10811. const DeleteIcon = createVNode("svg", {
  10812. "class": bem$n("delete-icon"),
  10813. "viewBox": "0 0 32 22"
  10814. }, [createVNode("path", {
  10815. "d": "M28 0a4 4 0 0 1 4 4v14a4 4 0 0 1-4 4H10.4a2 2 0 0 1-1.4-.6L1 13.1c-.6-.5-.9-1.3-.9-2 0-1 .3-1.7.9-2.2L9 .6a2 2 0 0 1 1.4-.6zm0 2H10.4l-8.2 8.3a1 1 0 0 0-.3.7c0 .3.1.5.3.7l8.2 8.4H28a2 2 0 0 0 2-2V4c0-1.1-.9-2-2-2zm-5 4a1 1 0 0 1 .7.3 1 1 0 0 1 0 1.4L20.4 11l3.3 3.3c.2.2.3.5.3.7 0 .3-.1.5-.3.7a1 1 0 0 1-.7.3 1 1 0 0 1-.7-.3L19 12.4l-3.4 3.3a1 1 0 0 1-.6.3 1 1 0 0 1-.7-.3 1 1 0 0 1-.3-.7c0-.2.1-.5.3-.7l3.3-3.3-3.3-3.3A1 1 0 0 1 14 7c0-.3.1-.5.3-.7A1 1 0 0 1 15 6a1 1 0 0 1 .6.3L19 9.6l3.3-3.3A1 1 0 0 1 23 6z",
  10816. "fill": "currentColor"
  10817. }, null)]);
  10818. var stdin_default$s = defineComponent({
  10819. name: name$n,
  10820. props: {
  10821. type: String,
  10822. text: numericProp,
  10823. color: String,
  10824. wider: Boolean,
  10825. large: Boolean,
  10826. loading: Boolean
  10827. },
  10828. emits: ["press"],
  10829. setup(props, {
  10830. emit,
  10831. slots
  10832. }) {
  10833. const active = ref(false);
  10834. const touch = useTouch();
  10835. const onTouchStart = (event) => {
  10836. touch.start(event);
  10837. active.value = true;
  10838. };
  10839. const onTouchMove = (event) => {
  10840. touch.move(event);
  10841. if (touch.direction.value) {
  10842. active.value = false;
  10843. }
  10844. };
  10845. const onTouchEnd = (event) => {
  10846. if (active.value) {
  10847. if (!slots.default) {
  10848. preventDefault(event);
  10849. }
  10850. active.value = false;
  10851. emit("press", props.text, props.type);
  10852. }
  10853. };
  10854. const renderContent = () => {
  10855. if (props.loading) {
  10856. return createVNode(Loading, {
  10857. "class": bem$n("loading-icon")
  10858. }, null);
  10859. }
  10860. const text = slots.default ? slots.default() : props.text;
  10861. switch (props.type) {
  10862. case "delete":
  10863. return text || DeleteIcon;
  10864. case "extra":
  10865. return text || CollapseIcon;
  10866. default:
  10867. return text;
  10868. }
  10869. };
  10870. return () => createVNode("div", {
  10871. "class": bem$n("wrapper", {
  10872. wider: props.wider
  10873. }),
  10874. "onTouchstartPassive": onTouchStart,
  10875. "onTouchmovePassive": onTouchMove,
  10876. "onTouchend": onTouchEnd,
  10877. "onTouchcancel": onTouchEnd
  10878. }, [createVNode("div", {
  10879. "role": "button",
  10880. "tabindex": 0,
  10881. "class": bem$n([props.color, {
  10882. large: props.large,
  10883. active: active.value,
  10884. delete: props.type === "delete"
  10885. }])
  10886. }, [renderContent()])]);
  10887. }
  10888. });
  10889. const [name$m, bem$m] = createNamespace("number-keyboard");
  10890. const numberKeyboardProps = {
  10891. show: Boolean,
  10892. title: String,
  10893. theme: makeStringProp("default"),
  10894. zIndex: numericProp,
  10895. teleport: [String, Object],
  10896. maxlength: makeNumericProp(Infinity),
  10897. modelValue: makeStringProp(""),
  10898. transition: truthProp,
  10899. blurOnClose: truthProp,
  10900. showDeleteKey: truthProp,
  10901. randomKeyOrder: Boolean,
  10902. closeButtonText: String,
  10903. deleteButtonText: String,
  10904. closeButtonLoading: Boolean,
  10905. hideOnClickOutside: truthProp,
  10906. safeAreaInsetBottom: truthProp,
  10907. extraKey: {
  10908. type: [String, Array],
  10909. default: ""
  10910. }
  10911. };
  10912. function shuffle(array) {
  10913. for (let i = array.length - 1; i > 0; i--) {
  10914. const j = Math.floor(Math.random() * (i + 1));
  10915. const temp = array[i];
  10916. array[i] = array[j];
  10917. array[j] = temp;
  10918. }
  10919. return array;
  10920. }
  10921. var stdin_default$r = defineComponent({
  10922. name: name$m,
  10923. props: numberKeyboardProps,
  10924. emits: ["show", "hide", "blur", "input", "close", "delete", "update:modelValue"],
  10925. setup(props, {
  10926. emit,
  10927. slots
  10928. }) {
  10929. const root = ref();
  10930. const genBasicKeys = () => {
  10931. const keys2 = Array(9).fill("").map((_, i) => ({
  10932. text: i + 1
  10933. }));
  10934. if (props.randomKeyOrder) {
  10935. shuffle(keys2);
  10936. }
  10937. return keys2;
  10938. };
  10939. const genDefaultKeys = () => [...genBasicKeys(), {
  10940. text: props.extraKey,
  10941. type: "extra"
  10942. }, {
  10943. text: 0
  10944. }, {
  10945. text: props.showDeleteKey ? props.deleteButtonText : "",
  10946. type: props.showDeleteKey ? "delete" : ""
  10947. }];
  10948. const genCustomKeys = () => {
  10949. const keys2 = genBasicKeys();
  10950. const {
  10951. extraKey
  10952. } = props;
  10953. const extraKeys = Array.isArray(extraKey) ? extraKey : [extraKey];
  10954. if (extraKeys.length === 1) {
  10955. keys2.push({
  10956. text: 0,
  10957. wider: true
  10958. }, {
  10959. text: extraKeys[0],
  10960. type: "extra"
  10961. });
  10962. } else if (extraKeys.length === 2) {
  10963. keys2.push({
  10964. text: extraKeys[0],
  10965. type: "extra"
  10966. }, {
  10967. text: 0
  10968. }, {
  10969. text: extraKeys[1],
  10970. type: "extra"
  10971. });
  10972. }
  10973. return keys2;
  10974. };
  10975. const keys = computed(() => props.theme === "custom" ? genCustomKeys() : genDefaultKeys());
  10976. const onBlur = () => {
  10977. if (props.show) {
  10978. emit("blur");
  10979. }
  10980. };
  10981. const onClose = () => {
  10982. emit("close");
  10983. if (props.blurOnClose) {
  10984. onBlur();
  10985. }
  10986. };
  10987. const onAnimationEnd = () => emit(props.show ? "show" : "hide");
  10988. const onPress = (text, type) => {
  10989. if (text === "") {
  10990. if (type === "extra") {
  10991. onBlur();
  10992. }
  10993. return;
  10994. }
  10995. const value = props.modelValue;
  10996. if (type === "delete") {
  10997. emit("delete");
  10998. emit("update:modelValue", value.slice(0, value.length - 1));
  10999. } else if (type === "close") {
  11000. onClose();
  11001. } else if (value.length < props.maxlength) {
  11002. emit("input", text);
  11003. emit("update:modelValue", value + text);
  11004. }
  11005. };
  11006. const renderTitle = () => {
  11007. const {
  11008. title,
  11009. theme,
  11010. closeButtonText
  11011. } = props;
  11012. const leftSlot = slots["title-left"];
  11013. const showClose = closeButtonText && theme === "default";
  11014. const showTitle = title || showClose || leftSlot;
  11015. if (!showTitle) {
  11016. return;
  11017. }
  11018. return createVNode("div", {
  11019. "class": bem$m("header")
  11020. }, [leftSlot && createVNode("span", {
  11021. "class": bem$m("title-left")
  11022. }, [leftSlot()]), title && createVNode("h2", {
  11023. "class": bem$m("title")
  11024. }, [title]), showClose && createVNode("button", {
  11025. "type": "button",
  11026. "class": [bem$m("close"), HAPTICS_FEEDBACK],
  11027. "onClick": onClose
  11028. }, [closeButtonText])]);
  11029. };
  11030. const renderKeys = () => keys.value.map((key) => {
  11031. const keySlots = {};
  11032. if (key.type === "delete") {
  11033. keySlots.default = slots.delete;
  11034. }
  11035. if (key.type === "extra") {
  11036. keySlots.default = slots["extra-key"];
  11037. }
  11038. return createVNode(stdin_default$s, {
  11039. "key": key.text,
  11040. "text": key.text,
  11041. "type": key.type,
  11042. "wider": key.wider,
  11043. "color": key.color,
  11044. "onPress": onPress
  11045. }, keySlots);
  11046. });
  11047. const renderSidebar = () => {
  11048. if (props.theme === "custom") {
  11049. return createVNode("div", {
  11050. "class": bem$m("sidebar")
  11051. }, [props.showDeleteKey && createVNode(stdin_default$s, {
  11052. "large": true,
  11053. "text": props.deleteButtonText,
  11054. "type": "delete",
  11055. "onPress": onPress
  11056. }, {
  11057. delete: slots.delete
  11058. }), createVNode(stdin_default$s, {
  11059. "large": true,
  11060. "text": props.closeButtonText,
  11061. "type": "close",
  11062. "color": "blue",
  11063. "loading": props.closeButtonLoading,
  11064. "onPress": onPress
  11065. }, null)]);
  11066. }
  11067. };
  11068. watch(() => props.show, (value) => {
  11069. if (!props.transition) {
  11070. emit(value ? "show" : "hide");
  11071. }
  11072. });
  11073. if (props.hideOnClickOutside) {
  11074. useClickAway(root, onBlur, {
  11075. eventName: "touchstart"
  11076. });
  11077. }
  11078. return () => {
  11079. const Title = renderTitle();
  11080. const Content = createVNode(Transition, {
  11081. "name": props.transition ? "van-slide-up" : ""
  11082. }, {
  11083. default: () => [withDirectives(createVNode("div", {
  11084. "ref": root,
  11085. "style": getZIndexStyle(props.zIndex),
  11086. "class": bem$m({
  11087. unfit: !props.safeAreaInsetBottom,
  11088. "with-title": !!Title
  11089. }),
  11090. "onAnimationend": onAnimationEnd,
  11091. "onTouchstartPassive": stopPropagation
  11092. }, [Title, createVNode("div", {
  11093. "class": bem$m("body")
  11094. }, [createVNode("div", {
  11095. "class": bem$m("keys")
  11096. }, [renderKeys()]), renderSidebar()])]), [[vShow, props.show]])]
  11097. });
  11098. if (props.teleport) {
  11099. return createVNode(Teleport, {
  11100. "to": props.teleport
  11101. }, {
  11102. default: () => [Content]
  11103. });
  11104. }
  11105. return Content;
  11106. };
  11107. }
  11108. });
  11109. const NumberKeyboard = withInstall(stdin_default$r);
  11110. const [name$l, bem$l, t$5] = createNamespace("pagination");
  11111. const makePage = (number, text, active) => ({
  11112. number,
  11113. text,
  11114. active
  11115. });
  11116. const paginationProps = {
  11117. mode: makeStringProp("multi"),
  11118. prevText: String,
  11119. nextText: String,
  11120. pageCount: makeNumericProp(0),
  11121. modelValue: makeNumberProp(0),
  11122. totalItems: makeNumericProp(0),
  11123. showPageSize: makeNumericProp(5),
  11124. itemsPerPage: makeNumericProp(10),
  11125. forceEllipses: Boolean
  11126. };
  11127. var stdin_default$q = defineComponent({
  11128. name: name$l,
  11129. props: paginationProps,
  11130. emits: ["change", "update:modelValue"],
  11131. setup(props, {
  11132. emit,
  11133. slots
  11134. }) {
  11135. const count = computed(() => {
  11136. const {
  11137. pageCount,
  11138. totalItems,
  11139. itemsPerPage
  11140. } = props;
  11141. const count2 = +pageCount || Math.ceil(+totalItems / +itemsPerPage);
  11142. return Math.max(1, count2);
  11143. });
  11144. const pages = computed(() => {
  11145. const items = [];
  11146. const pageCount = count.value;
  11147. const showPageSize = +props.showPageSize;
  11148. const {
  11149. modelValue,
  11150. forceEllipses
  11151. } = props;
  11152. let startPage = 1;
  11153. let endPage = pageCount;
  11154. const isMaxSized = showPageSize < pageCount;
  11155. if (isMaxSized) {
  11156. startPage = Math.max(modelValue - Math.floor(showPageSize / 2), 1);
  11157. endPage = startPage + showPageSize - 1;
  11158. if (endPage > pageCount) {
  11159. endPage = pageCount;
  11160. startPage = endPage - showPageSize + 1;
  11161. }
  11162. }
  11163. for (let number = startPage; number <= endPage; number++) {
  11164. const page = makePage(number, number, number === modelValue);
  11165. items.push(page);
  11166. }
  11167. if (isMaxSized && showPageSize > 0 && forceEllipses) {
  11168. if (startPage > 1) {
  11169. const prevPages = makePage(startPage - 1, "...");
  11170. items.unshift(prevPages);
  11171. }
  11172. if (endPage < pageCount) {
  11173. const nextPages = makePage(endPage + 1, "...");
  11174. items.push(nextPages);
  11175. }
  11176. }
  11177. return items;
  11178. });
  11179. const updateModelValue = (value, emitChange) => {
  11180. value = clamp(value, 1, count.value);
  11181. if (props.modelValue !== value) {
  11182. emit("update:modelValue", value);
  11183. if (emitChange) {
  11184. emit("change", value);
  11185. }
  11186. }
  11187. };
  11188. watchEffect(() => updateModelValue(props.modelValue));
  11189. const renderDesc = () => createVNode("li", {
  11190. "class": bem$l("page-desc")
  11191. }, [slots.pageDesc ? slots.pageDesc() : `${props.modelValue}/${count.value}`]);
  11192. const renderPrevButton = () => {
  11193. const {
  11194. mode,
  11195. modelValue
  11196. } = props;
  11197. const slot = slots["prev-text"];
  11198. const disabled = modelValue === 1;
  11199. return createVNode("li", {
  11200. "class": [bem$l("item", {
  11201. disabled,
  11202. border: mode === "simple",
  11203. prev: true
  11204. }), BORDER_SURROUND]
  11205. }, [createVNode("button", {
  11206. "type": "button",
  11207. "disabled": disabled,
  11208. "onClick": () => updateModelValue(modelValue - 1, true)
  11209. }, [slot ? slot() : props.prevText || t$5("prev")])]);
  11210. };
  11211. const renderNextButton = () => {
  11212. const {
  11213. mode,
  11214. modelValue
  11215. } = props;
  11216. const slot = slots["next-text"];
  11217. const disabled = modelValue === count.value;
  11218. return createVNode("li", {
  11219. "class": [bem$l("item", {
  11220. disabled,
  11221. border: mode === "simple",
  11222. next: true
  11223. }), BORDER_SURROUND]
  11224. }, [createVNode("button", {
  11225. "type": "button",
  11226. "disabled": disabled,
  11227. "onClick": () => updateModelValue(modelValue + 1, true)
  11228. }, [slot ? slot() : props.nextText || t$5("next")])]);
  11229. };
  11230. const renderPages = () => pages.value.map((page) => createVNode("li", {
  11231. "class": [bem$l("item", {
  11232. active: page.active,
  11233. page: true
  11234. }), BORDER_SURROUND]
  11235. }, [createVNode("button", {
  11236. "type": "button",
  11237. "aria-current": page.active || void 0,
  11238. "onClick": () => updateModelValue(page.number, true)
  11239. }, [slots.page ? slots.page(page) : page.text])]));
  11240. return () => createVNode("nav", {
  11241. "role": "navigation",
  11242. "class": bem$l()
  11243. }, [createVNode("ul", {
  11244. "class": bem$l("items")
  11245. }, [renderPrevButton(), props.mode === "simple" ? renderDesc() : renderPages(), renderNextButton()])]);
  11246. }
  11247. });
  11248. const Pagination = withInstall(stdin_default$q);
  11249. const [name$k, bem$k] = createNamespace("password-input");
  11250. const passwordInputProps = {
  11251. info: String,
  11252. mask: truthProp,
  11253. value: makeStringProp(""),
  11254. gutter: numericProp,
  11255. length: makeNumericProp(6),
  11256. focused: Boolean,
  11257. errorInfo: String
  11258. };
  11259. var stdin_default$p = defineComponent({
  11260. name: name$k,
  11261. props: passwordInputProps,
  11262. emits: ["focus"],
  11263. setup(props, {
  11264. emit
  11265. }) {
  11266. const onTouchStart = (event) => {
  11267. event.stopPropagation();
  11268. emit("focus", event);
  11269. };
  11270. const renderPoints = () => {
  11271. const Points = [];
  11272. const {
  11273. mask,
  11274. value,
  11275. length,
  11276. gutter,
  11277. focused
  11278. } = props;
  11279. for (let i = 0; i < length; i++) {
  11280. const char = value[i];
  11281. const showBorder = i !== 0 && !gutter;
  11282. const showCursor = focused && i === value.length;
  11283. let style;
  11284. if (i !== 0 && gutter) {
  11285. style = {
  11286. marginLeft: addUnit(gutter)
  11287. };
  11288. }
  11289. Points.push(createVNode("li", {
  11290. "class": [{
  11291. [BORDER_LEFT]: showBorder
  11292. }, bem$k("item", {
  11293. focus: showCursor
  11294. })],
  11295. "style": style
  11296. }, [mask ? createVNode("i", {
  11297. "style": {
  11298. visibility: char ? "visible" : "hidden"
  11299. }
  11300. }, null) : char, showCursor && createVNode("div", {
  11301. "class": bem$k("cursor")
  11302. }, null)]));
  11303. }
  11304. return Points;
  11305. };
  11306. return () => {
  11307. const info = props.errorInfo || props.info;
  11308. return createVNode("div", {
  11309. "class": bem$k()
  11310. }, [createVNode("ul", {
  11311. "class": [bem$k("security"), {
  11312. [BORDER_SURROUND]: !props.gutter
  11313. }],
  11314. "onTouchstartPassive": onTouchStart
  11315. }, [renderPoints()]), info && createVNode("div", {
  11316. "class": bem$k(props.errorInfo ? "error-info" : "info")
  11317. }, [info])]);
  11318. };
  11319. }
  11320. });
  11321. const PasswordInput = withInstall(stdin_default$p);
  11322. const [name$j, bem$j] = createNamespace("popover");
  11323. const popupProps = ["show", "overlay", "duration", "teleport", "overlayStyle", "overlayClass", "closeOnClickOverlay"];
  11324. const popoverProps = {
  11325. show: Boolean,
  11326. theme: makeStringProp("light"),
  11327. overlay: Boolean,
  11328. actions: makeArrayProp(),
  11329. trigger: makeStringProp("click"),
  11330. duration: numericProp,
  11331. showArrow: truthProp,
  11332. placement: makeStringProp("bottom"),
  11333. iconPrefix: String,
  11334. overlayClass: unknownProp,
  11335. overlayStyle: Object,
  11336. closeOnClickAction: truthProp,
  11337. closeOnClickOverlay: truthProp,
  11338. closeOnClickOutside: truthProp,
  11339. offset: {
  11340. type: Array,
  11341. default: () => [0, 8]
  11342. },
  11343. teleport: {
  11344. type: [String, Object],
  11345. default: "body"
  11346. }
  11347. };
  11348. var stdin_default$o = defineComponent({
  11349. name: name$j,
  11350. props: popoverProps,
  11351. emits: ["select", "touchstart", "update:show"],
  11352. setup(props, {
  11353. emit,
  11354. slots,
  11355. attrs
  11356. }) {
  11357. let popper;
  11358. const popupRef = ref();
  11359. const wrapperRef = ref();
  11360. const popoverRef = ref();
  11361. const getPopoverOptions = () => ({
  11362. placement: props.placement,
  11363. modifiers: [{
  11364. name: "computeStyles",
  11365. options: {
  11366. adaptive: false,
  11367. gpuAcceleration: false
  11368. }
  11369. }, extend({}, offsetModifier, {
  11370. options: {
  11371. offset: props.offset
  11372. }
  11373. })]
  11374. });
  11375. const createPopperInstance = () => {
  11376. if (wrapperRef.value && popoverRef.value) {
  11377. return createPopper(wrapperRef.value, popoverRef.value.popupRef.value, getPopoverOptions());
  11378. }
  11379. return null;
  11380. };
  11381. const updateLocation = () => {
  11382. nextTick(() => {
  11383. if (!props.show) {
  11384. return;
  11385. }
  11386. if (!popper) {
  11387. popper = createPopperInstance();
  11388. } else {
  11389. popper.setOptions(getPopoverOptions());
  11390. }
  11391. });
  11392. };
  11393. const updateShow = (value) => emit("update:show", value);
  11394. const onClickWrapper = () => {
  11395. if (props.trigger === "click") {
  11396. updateShow(!props.show);
  11397. }
  11398. };
  11399. const onClickAction = (action, index) => {
  11400. if (action.disabled) {
  11401. return;
  11402. }
  11403. emit("select", action, index);
  11404. if (props.closeOnClickAction) {
  11405. updateShow(false);
  11406. }
  11407. };
  11408. const onClickAway = () => {
  11409. if (props.show && props.closeOnClickOutside && (!props.overlay || props.closeOnClickOverlay)) {
  11410. updateShow(false);
  11411. }
  11412. };
  11413. const renderActionContent = (action, index) => {
  11414. if (slots.action) {
  11415. return slots.action({
  11416. action,
  11417. index
  11418. });
  11419. }
  11420. return [action.icon && createVNode(Icon, {
  11421. "name": action.icon,
  11422. "classPrefix": props.iconPrefix,
  11423. "class": bem$j("action-icon")
  11424. }, null), createVNode("div", {
  11425. "class": [bem$j("action-text"), BORDER_BOTTOM]
  11426. }, [action.text])];
  11427. };
  11428. const renderAction = (action, index) => {
  11429. const {
  11430. icon,
  11431. color,
  11432. disabled,
  11433. className
  11434. } = action;
  11435. return createVNode("div", {
  11436. "role": "menuitem",
  11437. "class": [bem$j("action", {
  11438. disabled,
  11439. "with-icon": icon
  11440. }), className],
  11441. "style": {
  11442. color
  11443. },
  11444. "tabindex": disabled ? void 0 : 0,
  11445. "aria-disabled": disabled || void 0,
  11446. "onClick": () => onClickAction(action, index)
  11447. }, [renderActionContent(action, index)]);
  11448. };
  11449. onMounted(() => {
  11450. updateLocation();
  11451. watchEffect(() => {
  11452. var _a;
  11453. popupRef.value = (_a = popoverRef.value) == null ? void 0 : _a.popupRef.value;
  11454. });
  11455. });
  11456. onBeforeUnmount(() => {
  11457. if (popper) {
  11458. popper.destroy();
  11459. popper = null;
  11460. }
  11461. });
  11462. watch(() => [props.show, props.offset, props.placement], updateLocation);
  11463. useClickAway([wrapperRef, popupRef], onClickAway, {
  11464. eventName: "touchstart"
  11465. });
  11466. return () => {
  11467. var _a;
  11468. return createVNode(Fragment, null, [createVNode("span", {
  11469. "ref": wrapperRef,
  11470. "class": bem$j("wrapper"),
  11471. "onClick": onClickWrapper
  11472. }, [(_a = slots.reference) == null ? void 0 : _a.call(slots)]), createVNode(Popup, mergeProps({
  11473. "ref": popoverRef,
  11474. "class": bem$j([props.theme]),
  11475. "position": "",
  11476. "transition": "van-popover-zoom",
  11477. "lockScroll": false,
  11478. "onUpdate:show": updateShow
  11479. }, attrs, pick(props, popupProps)), {
  11480. default: () => [props.showArrow && createVNode("div", {
  11481. "class": bem$j("arrow")
  11482. }, null), createVNode("div", {
  11483. "role": "menu",
  11484. "class": bem$j("content")
  11485. }, [slots.default ? slots.default() : props.actions.map(renderAction)])]
  11486. })]);
  11487. };
  11488. }
  11489. });
  11490. const Popover = withInstall(stdin_default$o);
  11491. const [name$i, bem$i] = createNamespace("progress");
  11492. const progressProps = {
  11493. color: String,
  11494. inactive: Boolean,
  11495. pivotText: String,
  11496. textColor: String,
  11497. showPivot: truthProp,
  11498. pivotColor: String,
  11499. trackColor: String,
  11500. strokeWidth: numericProp,
  11501. percentage: {
  11502. type: numericProp,
  11503. default: 0,
  11504. validator: (value) => value >= 0 && value <= 100
  11505. }
  11506. };
  11507. var stdin_default$n = defineComponent({
  11508. name: name$i,
  11509. props: progressProps,
  11510. setup(props) {
  11511. const background = computed(() => props.inactive ? void 0 : props.color);
  11512. const renderPivot = () => {
  11513. const {
  11514. textColor,
  11515. pivotText,
  11516. pivotColor,
  11517. percentage
  11518. } = props;
  11519. const text = pivotText != null ? pivotText : `${percentage}%`;
  11520. if (props.showPivot && text) {
  11521. const style = {
  11522. color: textColor,
  11523. left: `${+percentage}%`,
  11524. transform: `translate(-${+percentage}%,-50%)`,
  11525. background: pivotColor || background.value
  11526. };
  11527. return createVNode("span", {
  11528. "style": style,
  11529. "class": bem$i("pivot", {
  11530. inactive: props.inactive
  11531. })
  11532. }, [text]);
  11533. }
  11534. };
  11535. return () => {
  11536. const {
  11537. trackColor,
  11538. percentage,
  11539. strokeWidth
  11540. } = props;
  11541. const rootStyle = {
  11542. background: trackColor,
  11543. height: addUnit(strokeWidth)
  11544. };
  11545. const portionStyle = {
  11546. width: `${percentage}%`,
  11547. background: background.value
  11548. };
  11549. return createVNode("div", {
  11550. "class": bem$i(),
  11551. "style": rootStyle
  11552. }, [createVNode("span", {
  11553. "class": bem$i("portion", {
  11554. inactive: props.inactive
  11555. }),
  11556. "style": portionStyle
  11557. }, null), renderPivot()]);
  11558. };
  11559. }
  11560. });
  11561. const Progress = withInstall(stdin_default$n);
  11562. const [name$h, bem$h, t$4] = createNamespace("pull-refresh");
  11563. const DEFAULT_HEAD_HEIGHT = 50;
  11564. const TEXT_STATUS = ["pulling", "loosing", "success"];
  11565. const pullRefreshProps = {
  11566. disabled: Boolean,
  11567. modelValue: Boolean,
  11568. headHeight: makeNumericProp(DEFAULT_HEAD_HEIGHT),
  11569. successText: String,
  11570. pullingText: String,
  11571. loosingText: String,
  11572. loadingText: String,
  11573. pullDistance: numericProp,
  11574. successDuration: makeNumericProp(500),
  11575. animationDuration: makeNumericProp(300)
  11576. };
  11577. var stdin_default$m = defineComponent({
  11578. name: name$h,
  11579. props: pullRefreshProps,
  11580. emits: ["change", "refresh", "update:modelValue"],
  11581. setup(props, {
  11582. emit,
  11583. slots
  11584. }) {
  11585. let reachTop;
  11586. const root = ref();
  11587. const track = ref();
  11588. const scrollParent = useScrollParent(root);
  11589. const state = reactive({
  11590. status: "normal",
  11591. distance: 0,
  11592. duration: 0
  11593. });
  11594. const touch = useTouch();
  11595. const getHeadStyle = () => {
  11596. if (props.headHeight !== DEFAULT_HEAD_HEIGHT) {
  11597. return {
  11598. height: `${props.headHeight}px`
  11599. };
  11600. }
  11601. };
  11602. const isTouchable = () => state.status !== "loading" && state.status !== "success" && !props.disabled;
  11603. const ease = (distance) => {
  11604. const pullDistance = +(props.pullDistance || props.headHeight);
  11605. if (distance > pullDistance) {
  11606. if (distance < pullDistance * 2) {
  11607. distance = pullDistance + (distance - pullDistance) / 2;
  11608. } else {
  11609. distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4;
  11610. }
  11611. }
  11612. return Math.round(distance);
  11613. };
  11614. const setStatus = (distance, isLoading) => {
  11615. const pullDistance = +(props.pullDistance || props.headHeight);
  11616. state.distance = distance;
  11617. if (isLoading) {
  11618. state.status = "loading";
  11619. } else if (distance === 0) {
  11620. state.status = "normal";
  11621. } else if (distance < pullDistance) {
  11622. state.status = "pulling";
  11623. } else {
  11624. state.status = "loosing";
  11625. }
  11626. emit("change", {
  11627. status: state.status,
  11628. distance
  11629. });
  11630. };
  11631. const getStatusText = () => {
  11632. const {
  11633. status
  11634. } = state;
  11635. if (status === "normal") {
  11636. return "";
  11637. }
  11638. return props[`${status}Text`] || t$4(status);
  11639. };
  11640. const renderStatus = () => {
  11641. const {
  11642. status,
  11643. distance
  11644. } = state;
  11645. if (slots[status]) {
  11646. return slots[status]({
  11647. distance
  11648. });
  11649. }
  11650. const nodes = [];
  11651. if (TEXT_STATUS.includes(status)) {
  11652. nodes.push(createVNode("div", {
  11653. "class": bem$h("text")
  11654. }, [getStatusText()]));
  11655. }
  11656. if (status === "loading") {
  11657. nodes.push(createVNode(Loading, {
  11658. "class": bem$h("loading")
  11659. }, {
  11660. default: getStatusText
  11661. }));
  11662. }
  11663. return nodes;
  11664. };
  11665. const showSuccessTip = () => {
  11666. state.status = "success";
  11667. setTimeout(() => {
  11668. setStatus(0);
  11669. }, +props.successDuration);
  11670. };
  11671. const checkPosition = (event) => {
  11672. reachTop = getScrollTop(scrollParent.value) === 0;
  11673. if (reachTop) {
  11674. state.duration = 0;
  11675. touch.start(event);
  11676. }
  11677. };
  11678. const onTouchStart = (event) => {
  11679. if (isTouchable()) {
  11680. checkPosition(event);
  11681. }
  11682. };
  11683. const onTouchMove = (event) => {
  11684. if (isTouchable()) {
  11685. if (!reachTop) {
  11686. checkPosition(event);
  11687. }
  11688. const {
  11689. deltaY
  11690. } = touch;
  11691. touch.move(event);
  11692. if (reachTop && deltaY.value >= 0 && touch.isVertical()) {
  11693. preventDefault(event);
  11694. setStatus(ease(deltaY.value));
  11695. }
  11696. }
  11697. };
  11698. const onTouchEnd = () => {
  11699. if (reachTop && touch.deltaY.value && isTouchable()) {
  11700. state.duration = +props.animationDuration;
  11701. if (state.status === "loosing") {
  11702. setStatus(+props.headHeight, true);
  11703. emit("update:modelValue", true);
  11704. nextTick(() => emit("refresh"));
  11705. } else {
  11706. setStatus(0);
  11707. }
  11708. }
  11709. };
  11710. watch(() => props.modelValue, (value) => {
  11711. state.duration = +props.animationDuration;
  11712. if (value) {
  11713. setStatus(+props.headHeight, true);
  11714. } else if (slots.success || props.successText) {
  11715. showSuccessTip();
  11716. } else {
  11717. setStatus(0, false);
  11718. }
  11719. });
  11720. useEventListener("touchmove", onTouchMove, {
  11721. target: track
  11722. });
  11723. return () => {
  11724. var _a;
  11725. const trackStyle = {
  11726. transitionDuration: `${state.duration}ms`,
  11727. transform: state.distance ? `translate3d(0,${state.distance}px, 0)` : ""
  11728. };
  11729. return createVNode("div", {
  11730. "ref": root,
  11731. "class": bem$h()
  11732. }, [createVNode("div", {
  11733. "ref": track,
  11734. "class": bem$h("track"),
  11735. "style": trackStyle,
  11736. "onTouchstartPassive": onTouchStart,
  11737. "onTouchend": onTouchEnd,
  11738. "onTouchcancel": onTouchEnd
  11739. }, [createVNode("div", {
  11740. "class": bem$h("head"),
  11741. "style": getHeadStyle()
  11742. }, [renderStatus()]), (_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  11743. };
  11744. }
  11745. });
  11746. const PullRefresh = withInstall(stdin_default$m);
  11747. const [name$g, bem$g] = createNamespace("rate");
  11748. function getRateStatus(value, index, allowHalf, readonly) {
  11749. if (value >= index) {
  11750. return {
  11751. status: "full",
  11752. value: 1
  11753. };
  11754. }
  11755. if (value + 0.5 >= index && allowHalf && !readonly) {
  11756. return {
  11757. status: "half",
  11758. value: 0.5
  11759. };
  11760. }
  11761. if (value + 1 >= index && allowHalf && readonly) {
  11762. const cardinal = 10 ** 10;
  11763. return {
  11764. status: "half",
  11765. value: Math.round((value - index + 1) * cardinal) / cardinal
  11766. };
  11767. }
  11768. return {
  11769. status: "void",
  11770. value: 0
  11771. };
  11772. }
  11773. const rateProps = {
  11774. size: numericProp,
  11775. icon: makeStringProp("star"),
  11776. color: String,
  11777. count: makeNumericProp(5),
  11778. gutter: numericProp,
  11779. readonly: Boolean,
  11780. disabled: Boolean,
  11781. voidIcon: makeStringProp("star-o"),
  11782. allowHalf: Boolean,
  11783. voidColor: String,
  11784. touchable: truthProp,
  11785. iconPrefix: String,
  11786. modelValue: makeNumberProp(0),
  11787. disabledColor: String
  11788. };
  11789. var stdin_default$l = defineComponent({
  11790. name: name$g,
  11791. props: rateProps,
  11792. emits: ["change", "update:modelValue"],
  11793. setup(props, {
  11794. emit
  11795. }) {
  11796. const touch = useTouch();
  11797. const [itemRefs, setItemRefs] = useRefs();
  11798. const groupRef = ref();
  11799. const untouchable = () => props.readonly || props.disabled || !props.touchable;
  11800. const list = computed(() => Array(+props.count).fill("").map((_, i) => getRateStatus(props.modelValue, i + 1, props.allowHalf, props.readonly)));
  11801. let ranges;
  11802. let groupRefRect;
  11803. let minRectTop = Number.MAX_SAFE_INTEGER;
  11804. let maxRectTop = Number.MIN_SAFE_INTEGER;
  11805. const updateRanges = () => {
  11806. groupRefRect = useRect(groupRef);
  11807. const rects = itemRefs.value.map(useRect);
  11808. ranges = [];
  11809. rects.forEach((rect, index) => {
  11810. minRectTop = Math.min(rect.top, minRectTop);
  11811. maxRectTop = Math.max(rect.top, maxRectTop);
  11812. if (props.allowHalf) {
  11813. ranges.push({
  11814. score: index + 0.5,
  11815. left: rect.left,
  11816. top: rect.top,
  11817. height: rect.height
  11818. }, {
  11819. score: index + 1,
  11820. left: rect.left + rect.width / 2,
  11821. top: rect.top,
  11822. height: rect.height
  11823. });
  11824. } else {
  11825. ranges.push({
  11826. score: index + 1,
  11827. left: rect.left,
  11828. top: rect.top,
  11829. height: rect.height
  11830. });
  11831. }
  11832. });
  11833. };
  11834. const getScoreByPosition = (x, y) => {
  11835. for (let i = ranges.length - 1; i > 0; i--) {
  11836. if (y >= groupRefRect.top && y <= groupRefRect.bottom) {
  11837. if (x > ranges[i].left && y >= ranges[i].top && y <= ranges[i].top + ranges[i].height) {
  11838. return ranges[i].score;
  11839. }
  11840. } else {
  11841. const curTop = y < groupRefRect.top ? minRectTop : maxRectTop;
  11842. if (x > ranges[i].left && ranges[i].top === curTop) {
  11843. return ranges[i].score;
  11844. }
  11845. }
  11846. }
  11847. return props.allowHalf ? 0.5 : 1;
  11848. };
  11849. const select = (index) => {
  11850. if (!props.disabled && !props.readonly && index !== props.modelValue) {
  11851. emit("update:modelValue", index);
  11852. emit("change", index);
  11853. }
  11854. };
  11855. const onTouchStart = (event) => {
  11856. if (untouchable()) {
  11857. return;
  11858. }
  11859. touch.start(event);
  11860. updateRanges();
  11861. };
  11862. const onTouchMove = (event) => {
  11863. if (untouchable()) {
  11864. return;
  11865. }
  11866. touch.move(event);
  11867. if (touch.isHorizontal()) {
  11868. const {
  11869. clientX,
  11870. clientY
  11871. } = event.touches[0];
  11872. preventDefault(event);
  11873. select(getScoreByPosition(clientX, clientY));
  11874. }
  11875. };
  11876. const renderStar = (item, index) => {
  11877. const {
  11878. icon,
  11879. size,
  11880. color,
  11881. count,
  11882. gutter,
  11883. voidIcon,
  11884. disabled,
  11885. voidColor,
  11886. allowHalf,
  11887. iconPrefix,
  11888. disabledColor
  11889. } = props;
  11890. const score = index + 1;
  11891. const isFull = item.status === "full";
  11892. const isVoid = item.status === "void";
  11893. const renderHalf = allowHalf && item.value > 0 && item.value < 1;
  11894. let style;
  11895. if (gutter && score !== +count) {
  11896. style = {
  11897. paddingRight: addUnit(gutter)
  11898. };
  11899. }
  11900. const onClickItem = (event) => {
  11901. updateRanges();
  11902. select(allowHalf ? getScoreByPosition(event.clientX, event.clientY) : score);
  11903. };
  11904. return createVNode("div", {
  11905. "key": index,
  11906. "ref": setItemRefs(index),
  11907. "role": "radio",
  11908. "style": style,
  11909. "class": bem$g("item"),
  11910. "tabindex": disabled ? void 0 : 0,
  11911. "aria-setsize": count,
  11912. "aria-posinset": score,
  11913. "aria-checked": !isVoid,
  11914. "onClick": onClickItem
  11915. }, [createVNode(Icon, {
  11916. "size": size,
  11917. "name": isFull ? icon : voidIcon,
  11918. "class": bem$g("icon", {
  11919. disabled,
  11920. full: isFull
  11921. }),
  11922. "color": disabled ? disabledColor : isFull ? color : voidColor,
  11923. "classPrefix": iconPrefix
  11924. }, null), renderHalf && createVNode(Icon, {
  11925. "size": size,
  11926. "style": {
  11927. width: item.value + "em"
  11928. },
  11929. "name": isVoid ? voidIcon : icon,
  11930. "class": bem$g("icon", ["half", {
  11931. disabled,
  11932. full: !isVoid
  11933. }]),
  11934. "color": disabled ? disabledColor : isVoid ? voidColor : color,
  11935. "classPrefix": iconPrefix
  11936. }, null)]);
  11937. };
  11938. useCustomFieldValue(() => props.modelValue);
  11939. useEventListener("touchmove", onTouchMove, {
  11940. target: groupRef
  11941. });
  11942. return () => createVNode("div", {
  11943. "ref": groupRef,
  11944. "role": "radiogroup",
  11945. "class": bem$g({
  11946. readonly: props.readonly,
  11947. disabled: props.disabled
  11948. }),
  11949. "tabindex": props.disabled ? void 0 : 0,
  11950. "aria-disabled": props.disabled,
  11951. "aria-readonly": props.readonly,
  11952. "onTouchstartPassive": onTouchStart
  11953. }, [list.value.map(renderStar)]);
  11954. }
  11955. });
  11956. const Rate = withInstall(stdin_default$l);
  11957. const Row = withInstall(stdin_default$V);
  11958. const [name$f, bem$f, t$3] = createNamespace("search");
  11959. const searchProps = extend({}, fieldSharedProps, {
  11960. label: String,
  11961. shape: makeStringProp("square"),
  11962. leftIcon: makeStringProp("search"),
  11963. clearable: truthProp,
  11964. actionText: String,
  11965. background: String,
  11966. showAction: Boolean
  11967. });
  11968. var stdin_default$k = defineComponent({
  11969. name: name$f,
  11970. props: searchProps,
  11971. emits: ["blur", "focus", "clear", "search", "cancel", "click-input", "click-left-icon", "click-right-icon", "update:modelValue"],
  11972. setup(props, {
  11973. emit,
  11974. slots,
  11975. attrs
  11976. }) {
  11977. const id = useId();
  11978. const filedRef = ref();
  11979. const onCancel = () => {
  11980. if (!slots.action) {
  11981. emit("update:modelValue", "");
  11982. emit("cancel");
  11983. }
  11984. };
  11985. const onKeypress = (event) => {
  11986. const ENTER_CODE = 13;
  11987. if (event.keyCode === ENTER_CODE) {
  11988. preventDefault(event);
  11989. emit("search", props.modelValue);
  11990. }
  11991. };
  11992. const getInputId = () => props.id || `${id}-input`;
  11993. const renderLabel = () => {
  11994. if (slots.label || props.label) {
  11995. return createVNode("label", {
  11996. "class": bem$f("label"),
  11997. "for": getInputId()
  11998. }, [slots.label ? slots.label() : props.label]);
  11999. }
  12000. };
  12001. const renderAction = () => {
  12002. if (props.showAction) {
  12003. const text = props.actionText || t$3("cancel");
  12004. return createVNode("div", {
  12005. "class": bem$f("action"),
  12006. "role": "button",
  12007. "tabindex": 0,
  12008. "onClick": onCancel
  12009. }, [slots.action ? slots.action() : text]);
  12010. }
  12011. };
  12012. const blur = () => {
  12013. var _a;
  12014. return (_a = filedRef.value) == null ? void 0 : _a.blur();
  12015. };
  12016. const focus = () => {
  12017. var _a;
  12018. return (_a = filedRef.value) == null ? void 0 : _a.focus();
  12019. };
  12020. const onBlur = (event) => emit("blur", event);
  12021. const onFocus = (event) => emit("focus", event);
  12022. const onClear = (event) => emit("clear", event);
  12023. const onClickInput = (event) => emit("click-input", event);
  12024. const onClickLeftIcon = (event) => emit("click-left-icon", event);
  12025. const onClickRightIcon = (event) => emit("click-right-icon", event);
  12026. const fieldPropNames = Object.keys(fieldSharedProps);
  12027. const renderField = () => {
  12028. const fieldAttrs = extend({}, attrs, pick(props, fieldPropNames), {
  12029. id: getInputId()
  12030. });
  12031. const onInput = (value) => emit("update:modelValue", value);
  12032. return createVNode(Field, mergeProps({
  12033. "ref": filedRef,
  12034. "type": "search",
  12035. "class": bem$f("field"),
  12036. "border": false,
  12037. "onBlur": onBlur,
  12038. "onFocus": onFocus,
  12039. "onClear": onClear,
  12040. "onKeypress": onKeypress,
  12041. "onClick-input": onClickInput,
  12042. "onClick-left-icon": onClickLeftIcon,
  12043. "onClick-right-icon": onClickRightIcon,
  12044. "onUpdate:modelValue": onInput
  12045. }, fieldAttrs), pick(slots, ["left-icon", "right-icon"]));
  12046. };
  12047. useExpose({
  12048. focus,
  12049. blur
  12050. });
  12051. return () => {
  12052. var _a;
  12053. return createVNode("div", {
  12054. "class": bem$f({
  12055. "show-action": props.showAction
  12056. }),
  12057. "style": {
  12058. background: props.background
  12059. }
  12060. }, [(_a = slots.left) == null ? void 0 : _a.call(slots), createVNode("div", {
  12061. "class": bem$f("content", props.shape)
  12062. }, [renderLabel(), renderField()]), renderAction()]);
  12063. };
  12064. }
  12065. });
  12066. const Search = withInstall(stdin_default$k);
  12067. const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  12068. const iconMap = {
  12069. qq: "qq",
  12070. link: "link-o",
  12071. weibo: "weibo",
  12072. qrcode: "qr",
  12073. poster: "photo-o",
  12074. wechat: "wechat",
  12075. "weapp-qrcode": "miniprogram-o",
  12076. "wechat-moments": "wechat-moments"
  12077. };
  12078. const [name$e, bem$e, t$2] = createNamespace("share-sheet");
  12079. const shareSheetProps = extend({}, popupSharedProps, {
  12080. title: String,
  12081. round: truthProp,
  12082. options: makeArrayProp(),
  12083. cancelText: String,
  12084. description: String,
  12085. closeOnPopstate: truthProp,
  12086. safeAreaInsetBottom: truthProp
  12087. });
  12088. var stdin_default$j = defineComponent({
  12089. name: name$e,
  12090. props: shareSheetProps,
  12091. emits: ["cancel", "select", "update:show"],
  12092. setup(props, {
  12093. emit,
  12094. slots
  12095. }) {
  12096. const updateShow = (value) => emit("update:show", value);
  12097. const onCancel = () => {
  12098. updateShow(false);
  12099. emit("cancel");
  12100. };
  12101. const onSelect = (option, index) => emit("select", option, index);
  12102. const renderHeader = () => {
  12103. const title = slots.title ? slots.title() : props.title;
  12104. const description = slots.description ? slots.description() : props.description;
  12105. if (title || description) {
  12106. return createVNode("div", {
  12107. "class": bem$e("header")
  12108. }, [title && createVNode("h2", {
  12109. "class": bem$e("title")
  12110. }, [title]), description && createVNode("span", {
  12111. "class": bem$e("description")
  12112. }, [description])]);
  12113. }
  12114. };
  12115. const renderIcon = (icon) => {
  12116. if (iconMap[icon]) {
  12117. return createVNode("div", {
  12118. "class": bem$e("icon", [icon])
  12119. }, [createVNode(Icon, {
  12120. "name": iconMap[icon] || icon
  12121. }, null)]);
  12122. }
  12123. return createVNode("img", {
  12124. "src": icon,
  12125. "class": bem$e("image-icon")
  12126. }, null);
  12127. };
  12128. const renderOption = (option, index) => {
  12129. const {
  12130. name: name2,
  12131. icon,
  12132. className,
  12133. description
  12134. } = option;
  12135. return createVNode("div", {
  12136. "role": "button",
  12137. "tabindex": 0,
  12138. "class": [bem$e("option"), className, HAPTICS_FEEDBACK],
  12139. "onClick": () => onSelect(option, index)
  12140. }, [renderIcon(icon), name2 && createVNode("span", {
  12141. "class": bem$e("name")
  12142. }, [name2]), description && createVNode("span", {
  12143. "class": bem$e("option-description")
  12144. }, [description])]);
  12145. };
  12146. const renderOptions = (options, border) => createVNode("div", {
  12147. "class": bem$e("options", {
  12148. border
  12149. })
  12150. }, [options.map(renderOption)]);
  12151. const renderRows = () => {
  12152. const {
  12153. options
  12154. } = props;
  12155. if (Array.isArray(options[0])) {
  12156. return options.map((item, index) => renderOptions(item, index !== 0));
  12157. }
  12158. return renderOptions(options);
  12159. };
  12160. const renderCancelButton = () => {
  12161. var _a;
  12162. const cancelText = (_a = props.cancelText) != null ? _a : t$2("cancel");
  12163. if (slots.cancel || cancelText) {
  12164. return createVNode("button", {
  12165. "type": "button",
  12166. "class": bem$e("cancel"),
  12167. "onClick": onCancel
  12168. }, [slots.cancel ? slots.cancel() : cancelText]);
  12169. }
  12170. };
  12171. return () => createVNode(Popup, mergeProps({
  12172. "class": bem$e(),
  12173. "position": "bottom",
  12174. "onUpdate:show": updateShow
  12175. }, pick(props, popupInheritKeys)), {
  12176. default: () => [renderHeader(), renderRows(), renderCancelButton()]
  12177. });
  12178. }
  12179. });
  12180. const ShareSheet = withInstall(stdin_default$j);
  12181. const [name$d, bem$d] = createNamespace("sidebar");
  12182. const SIDEBAR_KEY = Symbol(name$d);
  12183. const sidebarProps = {
  12184. modelValue: makeNumericProp(0)
  12185. };
  12186. var stdin_default$i = defineComponent({
  12187. name: name$d,
  12188. props: sidebarProps,
  12189. emits: ["change", "update:modelValue"],
  12190. setup(props, {
  12191. emit,
  12192. slots
  12193. }) {
  12194. const {
  12195. linkChildren
  12196. } = useChildren(SIDEBAR_KEY);
  12197. const getActive = () => +props.modelValue;
  12198. const setActive = (value) => {
  12199. if (value !== getActive()) {
  12200. emit("update:modelValue", value);
  12201. emit("change", value);
  12202. }
  12203. };
  12204. linkChildren({
  12205. getActive,
  12206. setActive
  12207. });
  12208. return () => {
  12209. var _a;
  12210. return createVNode("div", {
  12211. "role": "tablist",
  12212. "class": bem$d()
  12213. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  12214. };
  12215. }
  12216. });
  12217. const Sidebar = withInstall(stdin_default$i);
  12218. const [name$c, bem$c] = createNamespace("sidebar-item");
  12219. const sidebarItemProps = extend({}, routeProps, {
  12220. dot: Boolean,
  12221. title: String,
  12222. badge: numericProp,
  12223. disabled: Boolean,
  12224. badgeProps: Object
  12225. });
  12226. var stdin_default$h = defineComponent({
  12227. name: name$c,
  12228. props: sidebarItemProps,
  12229. emits: ["click"],
  12230. setup(props, {
  12231. emit,
  12232. slots
  12233. }) {
  12234. const route2 = useRoute();
  12235. const {
  12236. parent,
  12237. index
  12238. } = useParent(SIDEBAR_KEY);
  12239. if (!parent) {
  12240. if (process.env.NODE_ENV !== "production") {
  12241. console.error("[Vant] <SidebarItem> must be a child component of <Sidebar>.");
  12242. }
  12243. return;
  12244. }
  12245. const onClick = () => {
  12246. if (props.disabled) {
  12247. return;
  12248. }
  12249. emit("click", index.value);
  12250. parent.setActive(index.value);
  12251. route2();
  12252. };
  12253. return () => {
  12254. const {
  12255. dot,
  12256. badge,
  12257. title,
  12258. disabled
  12259. } = props;
  12260. const selected = index.value === parent.getActive();
  12261. return createVNode("div", {
  12262. "role": "tab",
  12263. "class": bem$c({
  12264. select: selected,
  12265. disabled
  12266. }),
  12267. "tabindex": disabled ? void 0 : 0,
  12268. "aria-selected": selected,
  12269. "onClick": onClick
  12270. }, [createVNode(Badge, mergeProps({
  12271. "dot": dot,
  12272. "class": bem$c("text"),
  12273. "content": badge
  12274. }, props.badgeProps), {
  12275. default: () => [slots.title ? slots.title() : title]
  12276. })]);
  12277. };
  12278. }
  12279. });
  12280. const SidebarItem = withInstall(stdin_default$h);
  12281. const [name$b, bem$b] = createNamespace("skeleton");
  12282. const DEFAULT_ROW_WIDTH = "100%";
  12283. const DEFAULT_LAST_ROW_WIDTH = "60%";
  12284. const skeletonProps = {
  12285. row: makeNumericProp(0),
  12286. title: Boolean,
  12287. round: Boolean,
  12288. avatar: Boolean,
  12289. loading: truthProp,
  12290. animate: truthProp,
  12291. avatarSize: numericProp,
  12292. titleWidth: numericProp,
  12293. avatarShape: makeStringProp("round"),
  12294. rowWidth: {
  12295. type: [Number, String, Array],
  12296. default: DEFAULT_ROW_WIDTH
  12297. }
  12298. };
  12299. var stdin_default$g = defineComponent({
  12300. name: name$b,
  12301. inheritAttrs: false,
  12302. props: skeletonProps,
  12303. setup(props, {
  12304. slots,
  12305. attrs
  12306. }) {
  12307. const renderAvatar = () => {
  12308. if (props.avatar) {
  12309. return createVNode("div", {
  12310. "class": bem$b("avatar", props.avatarShape),
  12311. "style": getSizeStyle(props.avatarSize)
  12312. }, null);
  12313. }
  12314. };
  12315. const renderTitle = () => {
  12316. if (props.title) {
  12317. return createVNode("h3", {
  12318. "class": bem$b("title"),
  12319. "style": {
  12320. width: addUnit(props.titleWidth)
  12321. }
  12322. }, null);
  12323. }
  12324. };
  12325. const getRowWidth = (index) => {
  12326. const {
  12327. rowWidth
  12328. } = props;
  12329. if (rowWidth === DEFAULT_ROW_WIDTH && index === +props.row - 1) {
  12330. return DEFAULT_LAST_ROW_WIDTH;
  12331. }
  12332. if (Array.isArray(rowWidth)) {
  12333. return rowWidth[index];
  12334. }
  12335. return rowWidth;
  12336. };
  12337. const renderRows = () => Array(+props.row).fill("").map((_, i) => createVNode("div", {
  12338. "class": bem$b("row"),
  12339. "style": {
  12340. width: addUnit(getRowWidth(i))
  12341. }
  12342. }, null));
  12343. return () => {
  12344. var _a;
  12345. if (!props.loading) {
  12346. return (_a = slots.default) == null ? void 0 : _a.call(slots);
  12347. }
  12348. return createVNode("div", mergeProps({
  12349. "class": bem$b({
  12350. animate: props.animate,
  12351. round: props.round
  12352. })
  12353. }, attrs), [renderAvatar(), createVNode("div", {
  12354. "class": bem$b("content")
  12355. }, [renderTitle(), renderRows()])]);
  12356. };
  12357. }
  12358. });
  12359. const Skeleton = withInstall(stdin_default$g);
  12360. const [name$a, bem$a] = createNamespace("slider");
  12361. const sliderProps = {
  12362. min: makeNumericProp(0),
  12363. max: makeNumericProp(100),
  12364. step: makeNumericProp(1),
  12365. range: Boolean,
  12366. reverse: Boolean,
  12367. disabled: Boolean,
  12368. readonly: Boolean,
  12369. vertical: Boolean,
  12370. barHeight: numericProp,
  12371. buttonSize: numericProp,
  12372. activeColor: String,
  12373. inactiveColor: String,
  12374. modelValue: {
  12375. type: [Number, Array],
  12376. default: 0
  12377. }
  12378. };
  12379. var stdin_default$f = defineComponent({
  12380. name: name$a,
  12381. props: sliderProps,
  12382. emits: ["change", "drag-end", "drag-start", "update:modelValue"],
  12383. setup(props, {
  12384. emit,
  12385. slots
  12386. }) {
  12387. let buttonIndex;
  12388. let current2;
  12389. let startValue;
  12390. const root = ref();
  12391. const slider = ref();
  12392. const dragStatus = ref();
  12393. const touch = useTouch();
  12394. const scope = computed(() => Number(props.max) - Number(props.min));
  12395. const wrapperStyle = computed(() => {
  12396. const crossAxis = props.vertical ? "width" : "height";
  12397. return {
  12398. background: props.inactiveColor,
  12399. [crossAxis]: addUnit(props.barHeight)
  12400. };
  12401. });
  12402. const isRange = (val) => props.range && Array.isArray(val);
  12403. const calcMainAxis = () => {
  12404. const {
  12405. modelValue,
  12406. min
  12407. } = props;
  12408. if (isRange(modelValue)) {
  12409. return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
  12410. }
  12411. return `${(modelValue - Number(min)) * 100 / scope.value}%`;
  12412. };
  12413. const calcOffset = () => {
  12414. const {
  12415. modelValue,
  12416. min
  12417. } = props;
  12418. if (isRange(modelValue)) {
  12419. return `${(modelValue[0] - Number(min)) * 100 / scope.value}%`;
  12420. }
  12421. return "0%";
  12422. };
  12423. const barStyle = computed(() => {
  12424. const mainAxis = props.vertical ? "height" : "width";
  12425. const style = {
  12426. [mainAxis]: calcMainAxis(),
  12427. background: props.activeColor
  12428. };
  12429. if (dragStatus.value) {
  12430. style.transition = "none";
  12431. }
  12432. const getPositionKey = () => {
  12433. if (props.vertical) {
  12434. return props.reverse ? "bottom" : "top";
  12435. }
  12436. return props.reverse ? "right" : "left";
  12437. };
  12438. style[getPositionKey()] = calcOffset();
  12439. return style;
  12440. });
  12441. const format2 = (value) => {
  12442. const min = +props.min;
  12443. const max = +props.max;
  12444. const step = +props.step;
  12445. value = clamp(value, min, max);
  12446. const diff = Math.round((value - min) / step) * step;
  12447. return addNumber(min, diff);
  12448. };
  12449. const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
  12450. const handleRangeValue = (value) => {
  12451. var _a, _b;
  12452. const left = (_a = value[0]) != null ? _a : Number(props.min);
  12453. const right = (_b = value[1]) != null ? _b : Number(props.max);
  12454. return left > right ? [right, left] : [left, right];
  12455. };
  12456. const updateValue = (value, end) => {
  12457. if (isRange(value)) {
  12458. value = handleRangeValue(value).map(format2);
  12459. } else {
  12460. value = format2(value);
  12461. }
  12462. if (!isSameValue(value, props.modelValue)) {
  12463. emit("update:modelValue", value);
  12464. }
  12465. if (end && !isSameValue(value, startValue)) {
  12466. emit("change", value);
  12467. }
  12468. };
  12469. const onClick = (event) => {
  12470. event.stopPropagation();
  12471. if (props.disabled || props.readonly) {
  12472. return;
  12473. }
  12474. const {
  12475. min,
  12476. reverse,
  12477. vertical,
  12478. modelValue
  12479. } = props;
  12480. const rect = useRect(root);
  12481. const getDelta = () => {
  12482. if (vertical) {
  12483. if (reverse) {
  12484. return rect.bottom - event.clientY;
  12485. }
  12486. return event.clientY - rect.top;
  12487. }
  12488. if (reverse) {
  12489. return rect.right - event.clientX;
  12490. }
  12491. return event.clientX - rect.left;
  12492. };
  12493. const total = vertical ? rect.height : rect.width;
  12494. const value = Number(min) + getDelta() / total * scope.value;
  12495. if (isRange(modelValue)) {
  12496. const [left, right] = modelValue;
  12497. const middle = (left + right) / 2;
  12498. if (value <= middle) {
  12499. updateValue([value, right], true);
  12500. } else {
  12501. updateValue([left, value], true);
  12502. }
  12503. } else {
  12504. updateValue(value, true);
  12505. }
  12506. };
  12507. const onTouchStart = (event) => {
  12508. if (props.disabled || props.readonly) {
  12509. return;
  12510. }
  12511. touch.start(event);
  12512. current2 = props.modelValue;
  12513. if (isRange(current2)) {
  12514. startValue = current2.map(format2);
  12515. } else {
  12516. startValue = format2(current2);
  12517. }
  12518. dragStatus.value = "start";
  12519. };
  12520. const onTouchMove = (event) => {
  12521. if (props.disabled || props.readonly) {
  12522. return;
  12523. }
  12524. if (dragStatus.value === "start") {
  12525. emit("drag-start", event);
  12526. }
  12527. preventDefault(event, true);
  12528. touch.move(event);
  12529. dragStatus.value = "dragging";
  12530. const rect = useRect(root);
  12531. const delta = props.vertical ? touch.deltaY.value : touch.deltaX.value;
  12532. const total = props.vertical ? rect.height : rect.width;
  12533. let diff = delta / total * scope.value;
  12534. if (props.reverse) {
  12535. diff = -diff;
  12536. }
  12537. if (isRange(startValue)) {
  12538. const index = props.reverse ? 1 - buttonIndex : buttonIndex;
  12539. current2[index] = startValue[index] + diff;
  12540. } else {
  12541. current2 = startValue + diff;
  12542. }
  12543. updateValue(current2);
  12544. };
  12545. const onTouchEnd = (event) => {
  12546. if (props.disabled || props.readonly) {
  12547. return;
  12548. }
  12549. if (dragStatus.value === "dragging") {
  12550. updateValue(current2, true);
  12551. emit("drag-end", event);
  12552. }
  12553. dragStatus.value = "";
  12554. };
  12555. const getButtonClassName = (index) => {
  12556. if (typeof index === "number") {
  12557. const position = ["left", "right"];
  12558. return bem$a(`button-wrapper`, position[index]);
  12559. }
  12560. return bem$a("button-wrapper", props.reverse ? "left" : "right");
  12561. };
  12562. const renderButtonContent = (value, index) => {
  12563. if (typeof index === "number") {
  12564. const slot = slots[index === 0 ? "left-button" : "right-button"];
  12565. if (slot) {
  12566. return slot({
  12567. value
  12568. });
  12569. }
  12570. }
  12571. if (slots.button) {
  12572. return slots.button({
  12573. value
  12574. });
  12575. }
  12576. return createVNode("div", {
  12577. "class": bem$a("button"),
  12578. "style": getSizeStyle(props.buttonSize)
  12579. }, null);
  12580. };
  12581. const renderButton = (index) => {
  12582. const current22 = typeof index === "number" ? props.modelValue[index] : props.modelValue;
  12583. return createVNode("div", {
  12584. "ref": slider,
  12585. "role": "slider",
  12586. "class": getButtonClassName(index),
  12587. "tabindex": props.disabled ? void 0 : 0,
  12588. "aria-valuemin": props.min,
  12589. "aria-valuenow": current22,
  12590. "aria-valuemax": props.max,
  12591. "aria-disabled": props.disabled || void 0,
  12592. "aria-readonly": props.readonly || void 0,
  12593. "aria-orientation": props.vertical ? "vertical" : "horizontal",
  12594. "onTouchstartPassive": (event) => {
  12595. if (typeof index === "number") {
  12596. buttonIndex = index;
  12597. }
  12598. onTouchStart(event);
  12599. },
  12600. "onTouchend": onTouchEnd,
  12601. "onTouchcancel": onTouchEnd,
  12602. "onClick": stopPropagation
  12603. }, [renderButtonContent(current22, index)]);
  12604. };
  12605. updateValue(props.modelValue);
  12606. useCustomFieldValue(() => props.modelValue);
  12607. useEventListener("touchmove", onTouchMove, {
  12608. target: slider
  12609. });
  12610. return () => createVNode("div", {
  12611. "ref": root,
  12612. "style": wrapperStyle.value,
  12613. "class": bem$a({
  12614. vertical: props.vertical,
  12615. disabled: props.disabled
  12616. }),
  12617. "onClick": onClick
  12618. }, [createVNode("div", {
  12619. "class": bem$a("bar"),
  12620. "style": barStyle.value
  12621. }, [props.range ? [renderButton(0), renderButton(1)] : renderButton()])]);
  12622. }
  12623. });
  12624. const Slider = withInstall(stdin_default$f);
  12625. const [name$9, bem$9] = createNamespace("space");
  12626. const spaceProps = {
  12627. align: String,
  12628. direction: {
  12629. type: String,
  12630. default: "horizontal"
  12631. },
  12632. size: {
  12633. type: [Number, String, Array],
  12634. default: 8
  12635. },
  12636. wrap: Boolean,
  12637. fill: Boolean
  12638. };
  12639. function filterEmpty(children = []) {
  12640. const nodes = [];
  12641. children.forEach((child) => {
  12642. if (Array.isArray(child)) {
  12643. nodes.push(...child);
  12644. } else if (child.type === Fragment) {
  12645. nodes.push(...filterEmpty(child.children));
  12646. } else {
  12647. nodes.push(child);
  12648. }
  12649. });
  12650. return nodes.filter((c) => {
  12651. var _a;
  12652. return !(c && (typeof Comment !== "undefined" && c.type === Comment || c.type === Fragment && ((_a = c.children) == null ? void 0 : _a.length) === 0 || c.type === Text && c.children.trim() === ""));
  12653. });
  12654. }
  12655. var stdin_default$e = defineComponent({
  12656. name: name$9,
  12657. props: spaceProps,
  12658. setup(props, {
  12659. slots
  12660. }) {
  12661. const mergedAlign = computed(() => {
  12662. var _a;
  12663. return (_a = props.align) != null ? _a : props.direction === "horizontal" ? "center" : "";
  12664. });
  12665. const getMargin = (size) => {
  12666. if (typeof size === "number") {
  12667. return size + "px";
  12668. }
  12669. return size;
  12670. };
  12671. const getMarginStyle = (isLast) => {
  12672. const style = {};
  12673. const marginRight = `${getMargin(Array.isArray(props.size) ? props.size[0] : props.size)}`;
  12674. const marginBottom = `${getMargin(Array.isArray(props.size) ? props.size[1] : props.size)}`;
  12675. if (isLast) {
  12676. return props.wrap ? {
  12677. marginBottom
  12678. } : {};
  12679. }
  12680. if (props.direction === "horizontal") {
  12681. style.marginRight = marginRight;
  12682. }
  12683. if (props.direction === "vertical" || props.wrap) {
  12684. style.marginBottom = marginBottom;
  12685. }
  12686. return style;
  12687. };
  12688. return () => {
  12689. var _a;
  12690. const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
  12691. return createVNode("div", {
  12692. "class": [bem$9({
  12693. [props.direction]: props.direction,
  12694. [`align-${mergedAlign.value}`]: mergedAlign.value,
  12695. wrap: props.wrap,
  12696. fill: props.fill
  12697. })]
  12698. }, [children.map((c, i) => createVNode("div", {
  12699. "key": `item-${i}`,
  12700. "class": `${name$9}-item`,
  12701. "style": getMarginStyle(i === children.length - 1)
  12702. }, [c]))]);
  12703. };
  12704. }
  12705. });
  12706. const Space = withInstall(stdin_default$e);
  12707. const [name$8, bem$8] = createNamespace("steps");
  12708. const stepsProps = {
  12709. active: makeNumericProp(0),
  12710. direction: makeStringProp("horizontal"),
  12711. activeIcon: makeStringProp("checked"),
  12712. iconPrefix: String,
  12713. finishIcon: String,
  12714. activeColor: String,
  12715. inactiveIcon: String,
  12716. inactiveColor: String
  12717. };
  12718. const STEPS_KEY = Symbol(name$8);
  12719. var stdin_default$d = defineComponent({
  12720. name: name$8,
  12721. props: stepsProps,
  12722. emits: ["click-step"],
  12723. setup(props, {
  12724. emit,
  12725. slots
  12726. }) {
  12727. const {
  12728. linkChildren
  12729. } = useChildren(STEPS_KEY);
  12730. const onClickStep = (index) => emit("click-step", index);
  12731. linkChildren({
  12732. props,
  12733. onClickStep
  12734. });
  12735. return () => {
  12736. var _a;
  12737. return createVNode("div", {
  12738. "class": bem$8([props.direction])
  12739. }, [createVNode("div", {
  12740. "class": bem$8("items")
  12741. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  12742. };
  12743. }
  12744. });
  12745. const [name$7, bem$7] = createNamespace("step");
  12746. var stdin_default$c = defineComponent({
  12747. name: name$7,
  12748. setup(props, {
  12749. slots
  12750. }) {
  12751. const {
  12752. parent,
  12753. index
  12754. } = useParent(STEPS_KEY);
  12755. if (!parent) {
  12756. if (process.env.NODE_ENV !== "production") {
  12757. console.error("[Vant] <Step> must be a child component of <Steps>.");
  12758. }
  12759. return;
  12760. }
  12761. const parentProps = parent.props;
  12762. const getStatus = () => {
  12763. const active = +parentProps.active;
  12764. if (index.value < active) {
  12765. return "finish";
  12766. }
  12767. return index.value === active ? "process" : "waiting";
  12768. };
  12769. const isActive = () => getStatus() === "process";
  12770. const lineStyle = computed(() => ({
  12771. background: getStatus() === "finish" ? parentProps.activeColor : parentProps.inactiveColor
  12772. }));
  12773. const titleStyle = computed(() => {
  12774. if (isActive()) {
  12775. return {
  12776. color: parentProps.activeColor
  12777. };
  12778. }
  12779. if (getStatus() === "waiting") {
  12780. return {
  12781. color: parentProps.inactiveColor
  12782. };
  12783. }
  12784. });
  12785. const onClickStep = () => parent.onClickStep(index.value);
  12786. const renderCircle = () => {
  12787. const {
  12788. iconPrefix,
  12789. finishIcon,
  12790. activeIcon,
  12791. activeColor,
  12792. inactiveIcon
  12793. } = parentProps;
  12794. if (isActive()) {
  12795. if (slots["active-icon"]) {
  12796. return slots["active-icon"]();
  12797. }
  12798. return createVNode(Icon, {
  12799. "class": bem$7("icon", "active"),
  12800. "name": activeIcon,
  12801. "color": activeColor,
  12802. "classPrefix": iconPrefix
  12803. }, null);
  12804. }
  12805. if (getStatus() === "finish" && (finishIcon || slots["finish-icon"])) {
  12806. if (slots["finish-icon"]) {
  12807. return slots["finish-icon"]();
  12808. }
  12809. return createVNode(Icon, {
  12810. "class": bem$7("icon", "finish"),
  12811. "name": finishIcon,
  12812. "color": activeColor,
  12813. "classPrefix": iconPrefix
  12814. }, null);
  12815. }
  12816. if (slots["inactive-icon"]) {
  12817. return slots["inactive-icon"]();
  12818. }
  12819. if (inactiveIcon) {
  12820. return createVNode(Icon, {
  12821. "class": bem$7("icon"),
  12822. "name": inactiveIcon,
  12823. "classPrefix": iconPrefix
  12824. }, null);
  12825. }
  12826. return createVNode("i", {
  12827. "class": bem$7("circle"),
  12828. "style": lineStyle.value
  12829. }, null);
  12830. };
  12831. return () => {
  12832. var _a;
  12833. const status = getStatus();
  12834. return createVNode("div", {
  12835. "class": [BORDER, bem$7([parentProps.direction, {
  12836. [status]: status
  12837. }])]
  12838. }, [createVNode("div", {
  12839. "class": bem$7("title", {
  12840. active: isActive()
  12841. }),
  12842. "style": titleStyle.value,
  12843. "onClick": onClickStep
  12844. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), createVNode("div", {
  12845. "class": bem$7("circle-container"),
  12846. "onClick": onClickStep
  12847. }, [renderCircle()]), createVNode("div", {
  12848. "class": bem$7("line"),
  12849. "style": lineStyle.value
  12850. }, null)]);
  12851. };
  12852. }
  12853. });
  12854. const Step = withInstall(stdin_default$c);
  12855. const [name$6, bem$6] = createNamespace("stepper");
  12856. const LONG_PRESS_INTERVAL = 200;
  12857. const LONG_PRESS_START_TIME = 600;
  12858. const isEqual = (value1, value2) => String(value1) === String(value2);
  12859. const stepperProps = {
  12860. min: makeNumericProp(1),
  12861. max: makeNumericProp(Infinity),
  12862. name: makeNumericProp(""),
  12863. step: makeNumericProp(1),
  12864. theme: String,
  12865. integer: Boolean,
  12866. disabled: Boolean,
  12867. showPlus: truthProp,
  12868. showMinus: truthProp,
  12869. showInput: truthProp,
  12870. longPress: truthProp,
  12871. allowEmpty: Boolean,
  12872. modelValue: numericProp,
  12873. inputWidth: numericProp,
  12874. buttonSize: numericProp,
  12875. placeholder: String,
  12876. disablePlus: Boolean,
  12877. disableMinus: Boolean,
  12878. disableInput: Boolean,
  12879. beforeChange: Function,
  12880. defaultValue: makeNumericProp(1),
  12881. decimalLength: numericProp
  12882. };
  12883. var stdin_default$b = defineComponent({
  12884. name: name$6,
  12885. props: stepperProps,
  12886. emits: ["plus", "blur", "minus", "focus", "change", "overlimit", "update:modelValue"],
  12887. setup(props, {
  12888. emit
  12889. }) {
  12890. const format2 = (value) => {
  12891. const {
  12892. min,
  12893. max,
  12894. allowEmpty,
  12895. decimalLength
  12896. } = props;
  12897. if (allowEmpty && value === "") {
  12898. return value;
  12899. }
  12900. value = formatNumber(String(value), !props.integer);
  12901. value = value === "" ? 0 : +value;
  12902. value = Number.isNaN(value) ? +min : value;
  12903. value = Math.max(Math.min(+max, value), +min);
  12904. if (isDef(decimalLength)) {
  12905. value = value.toFixed(+decimalLength);
  12906. }
  12907. return value;
  12908. };
  12909. const getInitialValue = () => {
  12910. var _a;
  12911. const defaultValue = (_a = props.modelValue) != null ? _a : props.defaultValue;
  12912. const value = format2(defaultValue);
  12913. if (!isEqual(value, props.modelValue)) {
  12914. emit("update:modelValue", value);
  12915. }
  12916. return value;
  12917. };
  12918. let actionType;
  12919. const inputRef = ref();
  12920. const current2 = ref(getInitialValue());
  12921. const minusDisabled = computed(() => props.disabled || props.disableMinus || current2.value <= +props.min);
  12922. const plusDisabled = computed(() => props.disabled || props.disablePlus || current2.value >= +props.max);
  12923. const inputStyle = computed(() => ({
  12924. width: addUnit(props.inputWidth),
  12925. height: addUnit(props.buttonSize)
  12926. }));
  12927. const buttonStyle = computed(() => getSizeStyle(props.buttonSize));
  12928. const check = () => {
  12929. const value = format2(current2.value);
  12930. if (!isEqual(value, current2.value)) {
  12931. current2.value = value;
  12932. }
  12933. };
  12934. const setValue = (value) => {
  12935. if (props.beforeChange) {
  12936. callInterceptor(props.beforeChange, {
  12937. args: [value],
  12938. done() {
  12939. current2.value = value;
  12940. }
  12941. });
  12942. } else {
  12943. current2.value = value;
  12944. }
  12945. };
  12946. const onChange = () => {
  12947. if (actionType === "plus" && plusDisabled.value || actionType === "minus" && minusDisabled.value) {
  12948. emit("overlimit", actionType);
  12949. return;
  12950. }
  12951. const diff = actionType === "minus" ? -props.step : +props.step;
  12952. const value = format2(addNumber(+current2.value, diff));
  12953. setValue(value);
  12954. emit(actionType);
  12955. };
  12956. const onInput = (event) => {
  12957. const input = event.target;
  12958. const {
  12959. value
  12960. } = input;
  12961. const {
  12962. decimalLength
  12963. } = props;
  12964. let formatted = formatNumber(String(value), !props.integer);
  12965. if (isDef(decimalLength) && formatted.includes(".")) {
  12966. const pair = formatted.split(".");
  12967. formatted = `${pair[0]}.${pair[1].slice(0, +decimalLength)}`;
  12968. }
  12969. if (props.beforeChange) {
  12970. input.value = String(current2.value);
  12971. } else if (!isEqual(value, formatted)) {
  12972. input.value = formatted;
  12973. }
  12974. const isNumeric2 = formatted === String(+formatted);
  12975. setValue(isNumeric2 ? +formatted : formatted);
  12976. };
  12977. const onFocus = (event) => {
  12978. var _a;
  12979. if (props.disableInput) {
  12980. (_a = inputRef.value) == null ? void 0 : _a.blur();
  12981. } else {
  12982. emit("focus", event);
  12983. }
  12984. };
  12985. const onBlur = (event) => {
  12986. const input = event.target;
  12987. const value = format2(input.value);
  12988. input.value = String(value);
  12989. current2.value = value;
  12990. nextTick(() => {
  12991. emit("blur", event);
  12992. resetScroll();
  12993. });
  12994. };
  12995. let isLongPress;
  12996. let longPressTimer;
  12997. const longPressStep = () => {
  12998. longPressTimer = setTimeout(() => {
  12999. onChange();
  13000. longPressStep();
  13001. }, LONG_PRESS_INTERVAL);
  13002. };
  13003. const onTouchStart = () => {
  13004. if (props.longPress) {
  13005. isLongPress = false;
  13006. clearTimeout(longPressTimer);
  13007. longPressTimer = setTimeout(() => {
  13008. isLongPress = true;
  13009. onChange();
  13010. longPressStep();
  13011. }, LONG_PRESS_START_TIME);
  13012. }
  13013. };
  13014. const onTouchEnd = (event) => {
  13015. if (props.longPress) {
  13016. clearTimeout(longPressTimer);
  13017. if (isLongPress) {
  13018. preventDefault(event);
  13019. }
  13020. }
  13021. };
  13022. const onMousedown = (event) => {
  13023. if (props.disableInput) {
  13024. preventDefault(event);
  13025. }
  13026. };
  13027. const createListeners = (type) => ({
  13028. onClick: (event) => {
  13029. preventDefault(event);
  13030. actionType = type;
  13031. onChange();
  13032. },
  13033. onTouchstartPassive: () => {
  13034. actionType = type;
  13035. onTouchStart();
  13036. },
  13037. onTouchend: onTouchEnd,
  13038. onTouchcancel: onTouchEnd
  13039. });
  13040. watch(() => [props.max, props.min, props.integer, props.decimalLength], check);
  13041. watch(() => props.modelValue, (value) => {
  13042. if (!isEqual(value, current2.value)) {
  13043. current2.value = format2(value);
  13044. }
  13045. });
  13046. watch(current2, (value) => {
  13047. emit("update:modelValue", value);
  13048. emit("change", value, {
  13049. name: props.name
  13050. });
  13051. });
  13052. useCustomFieldValue(() => props.modelValue);
  13053. return () => createVNode("div", {
  13054. "role": "group",
  13055. "class": bem$6([props.theme])
  13056. }, [withDirectives(createVNode("button", mergeProps({
  13057. "type": "button",
  13058. "style": buttonStyle.value,
  13059. "class": [bem$6("minus", {
  13060. disabled: minusDisabled.value
  13061. }), {
  13062. [HAPTICS_FEEDBACK]: !minusDisabled.value
  13063. }],
  13064. "aria-disabled": minusDisabled.value || void 0
  13065. }, createListeners("minus")), null), [[vShow, props.showMinus]]), withDirectives(createVNode("input", {
  13066. "ref": inputRef,
  13067. "type": props.integer ? "tel" : "text",
  13068. "role": "spinbutton",
  13069. "class": bem$6("input"),
  13070. "value": current2.value,
  13071. "style": inputStyle.value,
  13072. "disabled": props.disabled,
  13073. "readonly": props.disableInput,
  13074. "inputmode": props.integer ? "numeric" : "decimal",
  13075. "placeholder": props.placeholder,
  13076. "aria-valuemax": props.max,
  13077. "aria-valuemin": props.min,
  13078. "aria-valuenow": current2.value,
  13079. "onBlur": onBlur,
  13080. "onInput": onInput,
  13081. "onFocus": onFocus,
  13082. "onMousedown": onMousedown
  13083. }, null), [[vShow, props.showInput]]), withDirectives(createVNode("button", mergeProps({
  13084. "type": "button",
  13085. "style": buttonStyle.value,
  13086. "class": [bem$6("plus", {
  13087. disabled: plusDisabled.value
  13088. }), {
  13089. [HAPTICS_FEEDBACK]: !plusDisabled.value
  13090. }],
  13091. "aria-disabled": plusDisabled.value || void 0
  13092. }, createListeners("plus")), null), [[vShow, props.showPlus]])]);
  13093. }
  13094. });
  13095. const Stepper = withInstall(stdin_default$b);
  13096. const Steps = withInstall(stdin_default$d);
  13097. const [name$5, bem$5, t$1] = createNamespace("submit-bar");
  13098. const submitBarProps = {
  13099. tip: String,
  13100. label: String,
  13101. price: Number,
  13102. tipIcon: String,
  13103. loading: Boolean,
  13104. currency: makeStringProp("\xA5"),
  13105. disabled: Boolean,
  13106. textAlign: String,
  13107. buttonText: String,
  13108. buttonType: makeStringProp("danger"),
  13109. buttonColor: String,
  13110. suffixLabel: String,
  13111. placeholder: Boolean,
  13112. decimalLength: makeNumericProp(2),
  13113. safeAreaInsetBottom: truthProp
  13114. };
  13115. var stdin_default$a = defineComponent({
  13116. name: name$5,
  13117. props: submitBarProps,
  13118. emits: ["submit"],
  13119. setup(props, {
  13120. emit,
  13121. slots
  13122. }) {
  13123. const root = ref();
  13124. const renderPlaceholder = usePlaceholder(root, bem$5);
  13125. const renderText = () => {
  13126. const {
  13127. price,
  13128. label,
  13129. currency,
  13130. textAlign,
  13131. suffixLabel,
  13132. decimalLength
  13133. } = props;
  13134. if (typeof price === "number") {
  13135. const pricePair = (price / 100).toFixed(+decimalLength).split(".");
  13136. const decimal = decimalLength ? `.${pricePair[1]}` : "";
  13137. return createVNode("div", {
  13138. "class": bem$5("text"),
  13139. "style": {
  13140. textAlign
  13141. }
  13142. }, [createVNode("span", null, [label || t$1("label")]), createVNode("span", {
  13143. "class": bem$5("price")
  13144. }, [currency, createVNode("span", {
  13145. "class": bem$5("price-integer")
  13146. }, [pricePair[0]]), decimal]), suffixLabel && createVNode("span", {
  13147. "class": bem$5("suffix-label")
  13148. }, [suffixLabel])]);
  13149. }
  13150. };
  13151. const renderTip = () => {
  13152. var _a;
  13153. const {
  13154. tip,
  13155. tipIcon
  13156. } = props;
  13157. if (slots.tip || tip) {
  13158. return createVNode("div", {
  13159. "class": bem$5("tip")
  13160. }, [tipIcon && createVNode(Icon, {
  13161. "class": bem$5("tip-icon"),
  13162. "name": tipIcon
  13163. }, null), tip && createVNode("span", {
  13164. "class": bem$5("tip-text")
  13165. }, [tip]), (_a = slots.tip) == null ? void 0 : _a.call(slots)]);
  13166. }
  13167. };
  13168. const onClickButton = () => emit("submit");
  13169. const renderButton = () => {
  13170. if (slots.button) {
  13171. return slots.button();
  13172. }
  13173. return createVNode(Button, {
  13174. "round": true,
  13175. "type": props.buttonType,
  13176. "text": props.buttonText,
  13177. "class": bem$5("button", props.buttonType),
  13178. "color": props.buttonColor,
  13179. "loading": props.loading,
  13180. "disabled": props.disabled,
  13181. "onClick": onClickButton
  13182. }, null);
  13183. };
  13184. const renderSubmitBar = () => {
  13185. var _a, _b;
  13186. return createVNode("div", {
  13187. "ref": root,
  13188. "class": [bem$5(), {
  13189. "van-safe-area-bottom": props.safeAreaInsetBottom
  13190. }]
  13191. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), renderTip(), createVNode("div", {
  13192. "class": bem$5("bar")
  13193. }, [(_b = slots.default) == null ? void 0 : _b.call(slots), renderText(), renderButton()])]);
  13194. };
  13195. return () => {
  13196. if (props.placeholder) {
  13197. return renderPlaceholder(renderSubmitBar);
  13198. }
  13199. return renderSubmitBar();
  13200. };
  13201. }
  13202. });
  13203. const SubmitBar = withInstall(stdin_default$a);
  13204. const [name$4, bem$4] = createNamespace("swipe-cell");
  13205. const swipeCellProps = {
  13206. name: makeNumericProp(""),
  13207. disabled: Boolean,
  13208. leftWidth: numericProp,
  13209. rightWidth: numericProp,
  13210. beforeClose: Function,
  13211. stopPropagation: Boolean
  13212. };
  13213. var stdin_default$9 = defineComponent({
  13214. name: name$4,
  13215. props: swipeCellProps,
  13216. emits: ["open", "close", "click"],
  13217. setup(props, {
  13218. emit,
  13219. slots
  13220. }) {
  13221. let opened;
  13222. let lockClick2;
  13223. let startOffset;
  13224. const root = ref();
  13225. const leftRef = ref();
  13226. const rightRef = ref();
  13227. const state = reactive({
  13228. offset: 0,
  13229. dragging: false
  13230. });
  13231. const touch = useTouch();
  13232. const getWidthByRef = (ref2) => ref2.value ? useRect(ref2).width : 0;
  13233. const leftWidth = computed(() => isDef(props.leftWidth) ? +props.leftWidth : getWidthByRef(leftRef));
  13234. const rightWidth = computed(() => isDef(props.rightWidth) ? +props.rightWidth : getWidthByRef(rightRef));
  13235. const open = (side) => {
  13236. state.offset = side === "left" ? leftWidth.value : -rightWidth.value;
  13237. if (!opened) {
  13238. opened = true;
  13239. emit("open", {
  13240. name: props.name,
  13241. position: side
  13242. });
  13243. }
  13244. };
  13245. const close = (position) => {
  13246. state.offset = 0;
  13247. if (opened) {
  13248. opened = false;
  13249. emit("close", {
  13250. name: props.name,
  13251. position
  13252. });
  13253. }
  13254. };
  13255. const toggle = (side) => {
  13256. const offset = Math.abs(state.offset);
  13257. const THRESHOLD = 0.15;
  13258. const threshold = opened ? 1 - THRESHOLD : THRESHOLD;
  13259. const width = side === "left" ? leftWidth.value : rightWidth.value;
  13260. if (width && offset > width * threshold) {
  13261. open(side);
  13262. } else {
  13263. close(side);
  13264. }
  13265. };
  13266. const onTouchStart = (event) => {
  13267. if (!props.disabled) {
  13268. startOffset = state.offset;
  13269. touch.start(event);
  13270. }
  13271. };
  13272. const onTouchMove = (event) => {
  13273. if (props.disabled) {
  13274. return;
  13275. }
  13276. const {
  13277. deltaX
  13278. } = touch;
  13279. touch.move(event);
  13280. if (touch.isHorizontal()) {
  13281. lockClick2 = true;
  13282. state.dragging = true;
  13283. const isEdge = !opened || deltaX.value * startOffset < 0;
  13284. if (isEdge) {
  13285. preventDefault(event, props.stopPropagation);
  13286. }
  13287. state.offset = clamp(deltaX.value + startOffset, -rightWidth.value, leftWidth.value);
  13288. }
  13289. };
  13290. const onTouchEnd = () => {
  13291. if (state.dragging) {
  13292. state.dragging = false;
  13293. toggle(state.offset > 0 ? "left" : "right");
  13294. setTimeout(() => {
  13295. lockClick2 = false;
  13296. }, 0);
  13297. }
  13298. };
  13299. const onClick = (position = "outside") => {
  13300. emit("click", position);
  13301. if (opened && !lockClick2) {
  13302. callInterceptor(props.beforeClose, {
  13303. args: [{
  13304. name: props.name,
  13305. position
  13306. }],
  13307. done: () => close(position)
  13308. });
  13309. }
  13310. };
  13311. const getClickHandler = (position, stop) => (event) => {
  13312. if (stop) {
  13313. event.stopPropagation();
  13314. }
  13315. onClick(position);
  13316. };
  13317. const renderSideContent = (side, ref2) => {
  13318. const contentSlot = slots[side];
  13319. if (contentSlot) {
  13320. return createVNode("div", {
  13321. "ref": ref2,
  13322. "class": bem$4(side),
  13323. "onClick": getClickHandler(side, true)
  13324. }, [contentSlot()]);
  13325. }
  13326. };
  13327. useExpose({
  13328. open,
  13329. close
  13330. });
  13331. useClickAway(root, () => onClick("outside"), {
  13332. eventName: "touchstart"
  13333. });
  13334. useEventListener("touchmove", onTouchMove, {
  13335. target: root
  13336. });
  13337. return () => {
  13338. var _a;
  13339. const wrapperStyle = {
  13340. transform: `translate3d(${state.offset}px, 0, 0)`,
  13341. transitionDuration: state.dragging ? "0s" : ".6s"
  13342. };
  13343. return createVNode("div", {
  13344. "ref": root,
  13345. "class": bem$4(),
  13346. "onClick": getClickHandler("cell", lockClick2),
  13347. "onTouchstartPassive": onTouchStart,
  13348. "onTouchend": onTouchEnd,
  13349. "onTouchcancel": onTouchEnd
  13350. }, [createVNode("div", {
  13351. "class": bem$4("wrapper"),
  13352. "style": wrapperStyle
  13353. }, [renderSideContent("left", leftRef), (_a = slots.default) == null ? void 0 : _a.call(slots), renderSideContent("right", rightRef)])]);
  13354. };
  13355. }
  13356. });
  13357. const SwipeCell = withInstall(stdin_default$9);
  13358. const [name$3, bem$3] = createNamespace("tabbar");
  13359. const tabbarProps = {
  13360. route: Boolean,
  13361. fixed: truthProp,
  13362. border: truthProp,
  13363. zIndex: numericProp,
  13364. placeholder: Boolean,
  13365. activeColor: String,
  13366. beforeChange: Function,
  13367. inactiveColor: String,
  13368. modelValue: makeNumericProp(0),
  13369. safeAreaInsetBottom: {
  13370. type: Boolean,
  13371. default: null
  13372. }
  13373. };
  13374. const TABBAR_KEY = Symbol(name$3);
  13375. var stdin_default$8 = defineComponent({
  13376. name: name$3,
  13377. props: tabbarProps,
  13378. emits: ["change", "update:modelValue"],
  13379. setup(props, {
  13380. emit,
  13381. slots
  13382. }) {
  13383. const root = ref();
  13384. const {
  13385. linkChildren
  13386. } = useChildren(TABBAR_KEY);
  13387. const renderPlaceholder = usePlaceholder(root, bem$3);
  13388. const enableSafeArea = () => {
  13389. var _a;
  13390. return (_a = props.safeAreaInsetBottom) != null ? _a : props.fixed;
  13391. };
  13392. const renderTabbar = () => {
  13393. var _a;
  13394. const {
  13395. fixed,
  13396. zIndex,
  13397. border
  13398. } = props;
  13399. return createVNode("div", {
  13400. "ref": root,
  13401. "role": "tablist",
  13402. "style": getZIndexStyle(zIndex),
  13403. "class": [bem$3({
  13404. fixed
  13405. }), {
  13406. [BORDER_TOP_BOTTOM]: border,
  13407. "van-safe-area-bottom": enableSafeArea()
  13408. }]
  13409. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  13410. };
  13411. const setActive = (active, afterChange) => {
  13412. callInterceptor(props.beforeChange, {
  13413. args: [active],
  13414. done() {
  13415. emit("update:modelValue", active);
  13416. emit("change", active);
  13417. afterChange();
  13418. }
  13419. });
  13420. };
  13421. linkChildren({
  13422. props,
  13423. setActive
  13424. });
  13425. return () => {
  13426. if (props.fixed && props.placeholder) {
  13427. return renderPlaceholder(renderTabbar);
  13428. }
  13429. return renderTabbar();
  13430. };
  13431. }
  13432. });
  13433. const Tabbar = withInstall(stdin_default$8);
  13434. const [name$2, bem$2] = createNamespace("tabbar-item");
  13435. const tabbarItemProps = extend({}, routeProps, {
  13436. dot: Boolean,
  13437. icon: String,
  13438. name: numericProp,
  13439. badge: numericProp,
  13440. badgeProps: Object,
  13441. iconPrefix: String
  13442. });
  13443. var stdin_default$7 = defineComponent({
  13444. name: name$2,
  13445. props: tabbarItemProps,
  13446. emits: ["click"],
  13447. setup(props, {
  13448. emit,
  13449. slots
  13450. }) {
  13451. const route2 = useRoute();
  13452. const vm = getCurrentInstance().proxy;
  13453. const {
  13454. parent,
  13455. index
  13456. } = useParent(TABBAR_KEY);
  13457. if (!parent) {
  13458. if (process.env.NODE_ENV !== "production") {
  13459. console.error("[Vant] <TabbarItem> must be a child component of <Tabbar>.");
  13460. }
  13461. return;
  13462. }
  13463. const active = computed(() => {
  13464. var _a;
  13465. const {
  13466. route: route22,
  13467. modelValue
  13468. } = parent.props;
  13469. if (route22 && "$route" in vm) {
  13470. const {
  13471. $route
  13472. } = vm;
  13473. const {
  13474. to
  13475. } = props;
  13476. const config = isObject(to) ? to : {
  13477. path: to
  13478. };
  13479. return !!$route.matched.find((val) => {
  13480. const pathMatched = "path" in config && config.path === val.path;
  13481. const nameMatched = "name" in config && config.name === val.name;
  13482. return pathMatched || nameMatched;
  13483. });
  13484. }
  13485. return ((_a = props.name) != null ? _a : index.value) === modelValue;
  13486. });
  13487. const onClick = (event) => {
  13488. var _a;
  13489. if (!active.value) {
  13490. parent.setActive((_a = props.name) != null ? _a : index.value, route2);
  13491. }
  13492. emit("click", event);
  13493. };
  13494. const renderIcon = () => {
  13495. if (slots.icon) {
  13496. return slots.icon({
  13497. active: active.value
  13498. });
  13499. }
  13500. if (props.icon) {
  13501. return createVNode(Icon, {
  13502. "name": props.icon,
  13503. "classPrefix": props.iconPrefix
  13504. }, null);
  13505. }
  13506. };
  13507. return () => {
  13508. var _a;
  13509. const {
  13510. dot,
  13511. badge
  13512. } = props;
  13513. const {
  13514. activeColor,
  13515. inactiveColor
  13516. } = parent.props;
  13517. const color = active.value ? activeColor : inactiveColor;
  13518. return createVNode("div", {
  13519. "role": "tab",
  13520. "class": bem$2({
  13521. active: active.value
  13522. }),
  13523. "style": {
  13524. color
  13525. },
  13526. "tabindex": 0,
  13527. "aria-selected": active.value,
  13528. "onClick": onClick
  13529. }, [createVNode(Badge, mergeProps({
  13530. "dot": dot,
  13531. "class": bem$2("icon"),
  13532. "content": badge
  13533. }, props.badgeProps), {
  13534. default: renderIcon
  13535. }), createVNode("div", {
  13536. "class": bem$2("text")
  13537. }, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
  13538. active: active.value
  13539. })])]);
  13540. };
  13541. }
  13542. });
  13543. const TabbarItem = withInstall(stdin_default$7);
  13544. const [name$1, bem$1] = createNamespace("tree-select");
  13545. const treeSelectProps = {
  13546. max: makeNumericProp(Infinity),
  13547. items: makeArrayProp(),
  13548. height: makeNumericProp(300),
  13549. selectedIcon: makeStringProp("success"),
  13550. mainActiveIndex: makeNumericProp(0),
  13551. activeId: {
  13552. type: [Number, String, Array],
  13553. default: 0
  13554. }
  13555. };
  13556. var stdin_default$6 = defineComponent({
  13557. name: name$1,
  13558. props: treeSelectProps,
  13559. emits: ["click-nav", "click-item", "update:activeId", "update:mainActiveIndex"],
  13560. setup(props, {
  13561. emit,
  13562. slots
  13563. }) {
  13564. const isActiveItem = (id) => Array.isArray(props.activeId) ? props.activeId.includes(id) : props.activeId === id;
  13565. const renderSubItem = (item) => {
  13566. const onClick = () => {
  13567. if (item.disabled) {
  13568. return;
  13569. }
  13570. let activeId;
  13571. if (Array.isArray(props.activeId)) {
  13572. activeId = props.activeId.slice();
  13573. const index = activeId.indexOf(item.id);
  13574. if (index !== -1) {
  13575. activeId.splice(index, 1);
  13576. } else if (activeId.length < props.max) {
  13577. activeId.push(item.id);
  13578. }
  13579. } else {
  13580. activeId = item.id;
  13581. }
  13582. emit("update:activeId", activeId);
  13583. emit("click-item", item);
  13584. };
  13585. return createVNode("div", {
  13586. "key": item.id,
  13587. "class": ["van-ellipsis", bem$1("item", {
  13588. active: isActiveItem(item.id),
  13589. disabled: item.disabled
  13590. })],
  13591. "onClick": onClick
  13592. }, [item.text, isActiveItem(item.id) && createVNode(Icon, {
  13593. "name": props.selectedIcon,
  13594. "class": bem$1("selected")
  13595. }, null)]);
  13596. };
  13597. const onSidebarChange = (index) => {
  13598. emit("update:mainActiveIndex", index);
  13599. };
  13600. const onClickSidebarItem = (index) => emit("click-nav", index);
  13601. const renderSidebar = () => {
  13602. const Items = props.items.map((item) => createVNode(SidebarItem, {
  13603. "dot": item.dot,
  13604. "title": item.text,
  13605. "badge": item.badge,
  13606. "class": [bem$1("nav-item"), item.className],
  13607. "disabled": item.disabled,
  13608. "onClick": onClickSidebarItem
  13609. }, null));
  13610. return createVNode(Sidebar, {
  13611. "class": bem$1("nav"),
  13612. "modelValue": props.mainActiveIndex,
  13613. "onChange": onSidebarChange
  13614. }, {
  13615. default: () => [Items]
  13616. });
  13617. };
  13618. const renderContent = () => {
  13619. if (slots.content) {
  13620. return slots.content();
  13621. }
  13622. const selected = props.items[+props.mainActiveIndex] || {};
  13623. if (selected.children) {
  13624. return selected.children.map(renderSubItem);
  13625. }
  13626. };
  13627. return () => createVNode("div", {
  13628. "class": bem$1(),
  13629. "style": {
  13630. height: addUnit(props.height)
  13631. }
  13632. }, [renderSidebar(), createVNode("div", {
  13633. "class": bem$1("content")
  13634. }, [renderContent()])]);
  13635. }
  13636. });
  13637. const TreeSelect = withInstall(stdin_default$6);
  13638. const [name, bem, t] = createNamespace("uploader");
  13639. function readFileContent(file, resultType) {
  13640. return new Promise((resolve) => {
  13641. if (resultType === "file") {
  13642. resolve();
  13643. return;
  13644. }
  13645. const reader = new FileReader();
  13646. reader.onload = (event) => {
  13647. resolve(event.target.result);
  13648. };
  13649. if (resultType === "dataUrl") {
  13650. reader.readAsDataURL(file);
  13651. } else if (resultType === "text") {
  13652. reader.readAsText(file);
  13653. }
  13654. });
  13655. }
  13656. function isOversize(items, maxSize) {
  13657. return toArray(items).some((item) => {
  13658. if (item.file) {
  13659. if (isFunction(maxSize)) {
  13660. return maxSize(item.file);
  13661. }
  13662. return item.file.size > maxSize;
  13663. }
  13664. return false;
  13665. });
  13666. }
  13667. function filterFiles(items, maxSize) {
  13668. const valid = [];
  13669. const invalid = [];
  13670. items.forEach((item) => {
  13671. if (isOversize(item, maxSize)) {
  13672. invalid.push(item);
  13673. } else {
  13674. valid.push(item);
  13675. }
  13676. });
  13677. return { valid, invalid };
  13678. }
  13679. const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
  13680. const isImageUrl = (url) => IMAGE_REGEXP.test(url);
  13681. function isImageFile(item) {
  13682. if (item.isImage) {
  13683. return true;
  13684. }
  13685. if (item.file && item.file.type) {
  13686. return item.file.type.indexOf("image") === 0;
  13687. }
  13688. if (item.url) {
  13689. return isImageUrl(item.url);
  13690. }
  13691. if (typeof item.content === "string") {
  13692. return item.content.indexOf("data:image") === 0;
  13693. }
  13694. return false;
  13695. }
  13696. var stdin_default$5 = defineComponent({
  13697. props: {
  13698. name: numericProp,
  13699. item: makeRequiredProp(Object),
  13700. index: Number,
  13701. imageFit: String,
  13702. lazyLoad: Boolean,
  13703. deletable: Boolean,
  13704. previewSize: [Number, String, Array],
  13705. beforeDelete: Function
  13706. },
  13707. emits: ["delete", "preview"],
  13708. setup(props, {
  13709. emit,
  13710. slots
  13711. }) {
  13712. const renderMask = () => {
  13713. const {
  13714. status,
  13715. message
  13716. } = props.item;
  13717. if (status === "uploading" || status === "failed") {
  13718. const MaskIcon = status === "failed" ? createVNode(Icon, {
  13719. "name": "close",
  13720. "class": bem("mask-icon")
  13721. }, null) : createVNode(Loading, {
  13722. "class": bem("loading")
  13723. }, null);
  13724. const showMessage = isDef(message) && message !== "";
  13725. return createVNode("div", {
  13726. "class": bem("mask")
  13727. }, [MaskIcon, showMessage && createVNode("div", {
  13728. "class": bem("mask-message")
  13729. }, [message])]);
  13730. }
  13731. };
  13732. const onDelete = (event) => {
  13733. const {
  13734. name: name2,
  13735. item,
  13736. index,
  13737. beforeDelete
  13738. } = props;
  13739. event.stopPropagation();
  13740. callInterceptor(beforeDelete, {
  13741. args: [item, {
  13742. name: name2,
  13743. index
  13744. }],
  13745. done: () => emit("delete")
  13746. });
  13747. };
  13748. const onPreview = () => emit("preview");
  13749. const renderDeleteIcon = () => {
  13750. if (props.deletable && props.item.status !== "uploading") {
  13751. const slot = slots["preview-delete"];
  13752. return createVNode("div", {
  13753. "role": "button",
  13754. "class": bem("preview-delete", {
  13755. shadow: !slot
  13756. }),
  13757. "tabindex": 0,
  13758. "aria-label": t("delete"),
  13759. "onClick": onDelete
  13760. }, [slot ? slot() : createVNode(Icon, {
  13761. "name": "cross",
  13762. "class": bem("preview-delete-icon")
  13763. }, null)]);
  13764. }
  13765. };
  13766. const renderCover = () => {
  13767. if (slots["preview-cover"]) {
  13768. const {
  13769. index,
  13770. item
  13771. } = props;
  13772. return createVNode("div", {
  13773. "class": bem("preview-cover")
  13774. }, [slots["preview-cover"](extend({
  13775. index
  13776. }, item))]);
  13777. }
  13778. };
  13779. const renderPreview = () => {
  13780. const {
  13781. item,
  13782. lazyLoad,
  13783. imageFit,
  13784. previewSize
  13785. } = props;
  13786. if (isImageFile(item)) {
  13787. return createVNode(Image$1, {
  13788. "fit": imageFit,
  13789. "src": item.content || item.url,
  13790. "class": bem("preview-image"),
  13791. "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
  13792. "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
  13793. "lazyLoad": lazyLoad,
  13794. "onClick": onPreview
  13795. }, {
  13796. default: renderCover
  13797. });
  13798. }
  13799. return createVNode("div", {
  13800. "class": bem("file"),
  13801. "style": getSizeStyle(props.previewSize)
  13802. }, [createVNode(Icon, {
  13803. "class": bem("file-icon"),
  13804. "name": "description"
  13805. }, null), createVNode("div", {
  13806. "class": [bem("file-name"), "van-ellipsis"]
  13807. }, [item.file ? item.file.name : item.url]), renderCover()]);
  13808. };
  13809. return () => createVNode("div", {
  13810. "class": bem("preview")
  13811. }, [renderPreview(), renderMask(), renderDeleteIcon()]);
  13812. }
  13813. });
  13814. const uploaderProps = {
  13815. name: makeNumericProp(""),
  13816. accept: makeStringProp("image/*"),
  13817. capture: String,
  13818. multiple: Boolean,
  13819. disabled: Boolean,
  13820. readonly: Boolean,
  13821. lazyLoad: Boolean,
  13822. maxCount: makeNumericProp(Infinity),
  13823. imageFit: makeStringProp("cover"),
  13824. resultType: makeStringProp("dataUrl"),
  13825. uploadIcon: makeStringProp("photograph"),
  13826. uploadText: String,
  13827. deletable: truthProp,
  13828. afterRead: Function,
  13829. showUpload: truthProp,
  13830. modelValue: makeArrayProp(),
  13831. beforeRead: Function,
  13832. beforeDelete: Function,
  13833. previewSize: [Number, String, Array],
  13834. previewImage: truthProp,
  13835. previewOptions: Object,
  13836. previewFullImage: truthProp,
  13837. maxSize: {
  13838. type: [Number, String, Function],
  13839. default: Infinity
  13840. }
  13841. };
  13842. var stdin_default$4 = defineComponent({
  13843. name,
  13844. props: uploaderProps,
  13845. emits: ["delete", "oversize", "click-upload", "close-preview", "click-preview", "update:modelValue"],
  13846. setup(props, {
  13847. emit,
  13848. slots
  13849. }) {
  13850. const inputRef = ref();
  13851. const urls = [];
  13852. const getDetail = (index = props.modelValue.length) => ({
  13853. name: props.name,
  13854. index
  13855. });
  13856. const resetInput = () => {
  13857. if (inputRef.value) {
  13858. inputRef.value.value = "";
  13859. }
  13860. };
  13861. const onAfterRead = (items) => {
  13862. resetInput();
  13863. if (isOversize(items, props.maxSize)) {
  13864. if (Array.isArray(items)) {
  13865. const result = filterFiles(items, props.maxSize);
  13866. items = result.valid;
  13867. emit("oversize", result.invalid, getDetail());
  13868. if (!items.length) {
  13869. return;
  13870. }
  13871. } else {
  13872. emit("oversize", items, getDetail());
  13873. return;
  13874. }
  13875. }
  13876. items = reactive(items);
  13877. emit("update:modelValue", [...props.modelValue, ...toArray(items)]);
  13878. if (props.afterRead) {
  13879. props.afterRead(items, getDetail());
  13880. }
  13881. };
  13882. const readFile = (files) => {
  13883. const {
  13884. maxCount,
  13885. modelValue,
  13886. resultType
  13887. } = props;
  13888. if (Array.isArray(files)) {
  13889. const remainCount = +maxCount - modelValue.length;
  13890. if (files.length > remainCount) {
  13891. files = files.slice(0, remainCount);
  13892. }
  13893. Promise.all(files.map((file) => readFileContent(file, resultType))).then((contents) => {
  13894. const fileList = files.map((file, index) => {
  13895. const result = {
  13896. file,
  13897. status: "",
  13898. message: ""
  13899. };
  13900. if (contents[index]) {
  13901. result.content = contents[index];
  13902. }
  13903. return result;
  13904. });
  13905. onAfterRead(fileList);
  13906. });
  13907. } else {
  13908. readFileContent(files, resultType).then((content) => {
  13909. const result = {
  13910. file: files,
  13911. status: "",
  13912. message: ""
  13913. };
  13914. if (content) {
  13915. result.content = content;
  13916. }
  13917. onAfterRead(result);
  13918. });
  13919. }
  13920. };
  13921. const onChange = (event) => {
  13922. const {
  13923. files
  13924. } = event.target;
  13925. if (props.disabled || !files || !files.length) {
  13926. return;
  13927. }
  13928. const file = files.length === 1 ? files[0] : [].slice.call(files);
  13929. if (props.beforeRead) {
  13930. const response = props.beforeRead(file, getDetail());
  13931. if (!response) {
  13932. resetInput();
  13933. return;
  13934. }
  13935. if (isPromise(response)) {
  13936. response.then((data) => {
  13937. if (data) {
  13938. readFile(data);
  13939. } else {
  13940. readFile(file);
  13941. }
  13942. }).catch(resetInput);
  13943. return;
  13944. }
  13945. }
  13946. readFile(file);
  13947. };
  13948. let imagePreview;
  13949. const onClosePreview = () => emit("close-preview");
  13950. const previewImage = (item) => {
  13951. if (props.previewFullImage) {
  13952. const imageFiles = props.modelValue.filter(isImageFile);
  13953. const images = imageFiles.map((item2) => {
  13954. if (item2.file && !item2.url && item2.status !== "failed") {
  13955. item2.url = URL.createObjectURL(item2.file);
  13956. urls.push(item2.url);
  13957. }
  13958. return item2.url;
  13959. }).filter(Boolean);
  13960. imagePreview = ImagePreview(extend({
  13961. images,
  13962. startPosition: imageFiles.indexOf(item),
  13963. onClose: onClosePreview
  13964. }, props.previewOptions));
  13965. }
  13966. };
  13967. const closeImagePreview = () => {
  13968. if (imagePreview) {
  13969. imagePreview.close();
  13970. }
  13971. };
  13972. const deleteFile = (item, index) => {
  13973. const fileList = props.modelValue.slice(0);
  13974. fileList.splice(index, 1);
  13975. emit("update:modelValue", fileList);
  13976. emit("delete", item, getDetail(index));
  13977. };
  13978. const renderPreviewItem = (item, index) => {
  13979. const needPickData = ["imageFit", "deletable", "previewSize", "beforeDelete"];
  13980. const previewData = extend(pick(props, needPickData), pick(item, needPickData, true));
  13981. return createVNode(stdin_default$5, mergeProps({
  13982. "item": item,
  13983. "index": index,
  13984. "onClick": () => emit("click-preview", item, getDetail(index)),
  13985. "onDelete": () => deleteFile(item, index),
  13986. "onPreview": () => previewImage(item)
  13987. }, pick(props, ["name", "lazyLoad"]), previewData), pick(slots, ["preview-cover", "preview-delete"]));
  13988. };
  13989. const renderPreviewList = () => {
  13990. if (props.previewImage) {
  13991. return props.modelValue.map(renderPreviewItem);
  13992. }
  13993. };
  13994. const onClickUpload = (event) => emit("click-upload", event);
  13995. const renderUpload = () => {
  13996. if (props.modelValue.length >= props.maxCount || !props.showUpload) {
  13997. return;
  13998. }
  13999. const Input = props.readonly ? null : createVNode("input", {
  14000. "ref": inputRef,
  14001. "type": "file",
  14002. "class": bem("input"),
  14003. "accept": props.accept,
  14004. "capture": props.capture,
  14005. "multiple": props.multiple,
  14006. "disabled": props.disabled,
  14007. "onChange": onChange
  14008. }, null);
  14009. if (slots.default) {
  14010. return createVNode("div", {
  14011. "class": bem("input-wrapper"),
  14012. "onClick": onClickUpload
  14013. }, [slots.default(), Input]);
  14014. }
  14015. return createVNode("div", {
  14016. "class": bem("upload", {
  14017. readonly: props.readonly
  14018. }),
  14019. "style": getSizeStyle(props.previewSize),
  14020. "onClick": onClickUpload
  14021. }, [createVNode(Icon, {
  14022. "name": props.uploadIcon,
  14023. "class": bem("upload-icon")
  14024. }, null), props.uploadText && createVNode("span", {
  14025. "class": bem("upload-text")
  14026. }, [props.uploadText]), Input]);
  14027. };
  14028. const chooseFile = () => {
  14029. if (inputRef.value && !props.disabled) {
  14030. inputRef.value.click();
  14031. }
  14032. };
  14033. onBeforeUnmount(() => {
  14034. urls.forEach((url) => URL.revokeObjectURL(url));
  14035. });
  14036. useExpose({
  14037. chooseFile,
  14038. closeImagePreview
  14039. });
  14040. useCustomFieldValue(() => props.modelValue);
  14041. return () => createVNode("div", {
  14042. "class": bem()
  14043. }, [createVNode("div", {
  14044. "class": bem("wrapper", {
  14045. disabled: props.disabled
  14046. })
  14047. }, [renderPreviewList(), renderUpload()])]);
  14048. }
  14049. });
  14050. const Uploader = withInstall(stdin_default$4);
  14051. const hasIntersectionObserver = inBrowser$1 && "IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype;
  14052. const modeType = {
  14053. event: "event",
  14054. observer: "observer"
  14055. };
  14056. function remove(arr, item) {
  14057. if (!arr.length)
  14058. return;
  14059. const index = arr.indexOf(item);
  14060. if (index > -1)
  14061. return arr.splice(index, 1);
  14062. }
  14063. function getBestSelectionFromSrcset(el, scale) {
  14064. if (el.tagName !== "IMG" || !el.getAttribute("data-srcset"))
  14065. return;
  14066. let options = el.getAttribute("data-srcset");
  14067. const container = el.parentNode;
  14068. const containerWidth = container.offsetWidth * scale;
  14069. let spaceIndex;
  14070. let tmpSrc;
  14071. let tmpWidth;
  14072. options = options.trim().split(",");
  14073. const result = options.map((item) => {
  14074. item = item.trim();
  14075. spaceIndex = item.lastIndexOf(" ");
  14076. if (spaceIndex === -1) {
  14077. tmpSrc = item;
  14078. tmpWidth = 999998;
  14079. } else {
  14080. tmpSrc = item.substr(0, spaceIndex);
  14081. tmpWidth = parseInt(
  14082. item.substr(spaceIndex + 1, item.length - spaceIndex - 2),
  14083. 10
  14084. );
  14085. }
  14086. return [tmpWidth, tmpSrc];
  14087. });
  14088. result.sort((a, b) => {
  14089. if (a[0] < b[0]) {
  14090. return 1;
  14091. }
  14092. if (a[0] > b[0]) {
  14093. return -1;
  14094. }
  14095. if (a[0] === b[0]) {
  14096. if (b[1].indexOf(".webp", b[1].length - 5) !== -1) {
  14097. return 1;
  14098. }
  14099. if (a[1].indexOf(".webp", a[1].length - 5) !== -1) {
  14100. return -1;
  14101. }
  14102. }
  14103. return 0;
  14104. });
  14105. let bestSelectedSrc = "";
  14106. let tmpOption;
  14107. for (let i = 0; i < result.length; i++) {
  14108. tmpOption = result[i];
  14109. bestSelectedSrc = tmpOption[1];
  14110. const next = result[i + 1];
  14111. if (next && next[0] < containerWidth) {
  14112. bestSelectedSrc = tmpOption[1];
  14113. break;
  14114. } else if (!next) {
  14115. bestSelectedSrc = tmpOption[1];
  14116. break;
  14117. }
  14118. }
  14119. return bestSelectedSrc;
  14120. }
  14121. const getDPR = (scale = 1) => inBrowser$1 ? window.devicePixelRatio || scale : scale;
  14122. function supportWebp() {
  14123. if (!inBrowser$1)
  14124. return false;
  14125. let support = true;
  14126. try {
  14127. const elem = document.createElement("canvas");
  14128. if (elem.getContext && elem.getContext("2d")) {
  14129. support = elem.toDataURL("image/webp").indexOf("data:image/webp") === 0;
  14130. }
  14131. } catch (err) {
  14132. support = false;
  14133. }
  14134. return support;
  14135. }
  14136. function throttle(action, delay) {
  14137. let timeout = null;
  14138. let lastRun = 0;
  14139. return function(...args) {
  14140. if (timeout) {
  14141. return;
  14142. }
  14143. const elapsed = Date.now() - lastRun;
  14144. const runCallback = () => {
  14145. lastRun = Date.now();
  14146. timeout = false;
  14147. action.apply(this, args);
  14148. };
  14149. if (elapsed >= delay) {
  14150. runCallback();
  14151. } else {
  14152. timeout = setTimeout(runCallback, delay);
  14153. }
  14154. };
  14155. }
  14156. function on(el, type, func) {
  14157. el.addEventListener(type, func, {
  14158. capture: false,
  14159. passive: true
  14160. });
  14161. }
  14162. function off(el, type, func) {
  14163. el.removeEventListener(type, func, false);
  14164. }
  14165. const loadImageAsync = (item, resolve, reject) => {
  14166. const image = new Image();
  14167. if (!item || !item.src) {
  14168. return reject(new Error("image src is required"));
  14169. }
  14170. image.src = item.src;
  14171. if (item.cors) {
  14172. image.crossOrigin = item.cors;
  14173. }
  14174. image.onload = () => resolve({
  14175. naturalHeight: image.naturalHeight,
  14176. naturalWidth: image.naturalWidth,
  14177. src: image.src
  14178. });
  14179. image.onerror = (e) => reject(e);
  14180. };
  14181. class ImageCache {
  14182. constructor({ max }) {
  14183. this.options = {
  14184. max: max || 100
  14185. };
  14186. this.caches = [];
  14187. }
  14188. has(key) {
  14189. return this.caches.indexOf(key) > -1;
  14190. }
  14191. add(key) {
  14192. if (this.has(key))
  14193. return;
  14194. this.caches.push(key);
  14195. if (this.caches.length > this.options.max) {
  14196. this.free();
  14197. }
  14198. }
  14199. free() {
  14200. this.caches.shift();
  14201. }
  14202. }
  14203. class ReactiveListener {
  14204. constructor({
  14205. el,
  14206. src,
  14207. error,
  14208. loading,
  14209. bindType,
  14210. $parent,
  14211. options,
  14212. cors,
  14213. elRenderer,
  14214. imageCache
  14215. }) {
  14216. this.el = el;
  14217. this.src = src;
  14218. this.error = error;
  14219. this.loading = loading;
  14220. this.bindType = bindType;
  14221. this.attempt = 0;
  14222. this.cors = cors;
  14223. this.naturalHeight = 0;
  14224. this.naturalWidth = 0;
  14225. this.options = options;
  14226. this.$parent = $parent;
  14227. this.elRenderer = elRenderer;
  14228. this.imageCache = imageCache;
  14229. this.performanceData = {
  14230. loadStart: 0,
  14231. loadEnd: 0
  14232. };
  14233. this.filter();
  14234. this.initState();
  14235. this.render("loading", false);
  14236. }
  14237. initState() {
  14238. if ("dataset" in this.el) {
  14239. this.el.dataset.src = this.src;
  14240. } else {
  14241. this.el.setAttribute("data-src", this.src);
  14242. }
  14243. this.state = {
  14244. loading: false,
  14245. error: false,
  14246. loaded: false,
  14247. rendered: false
  14248. };
  14249. }
  14250. record(event) {
  14251. this.performanceData[event] = Date.now();
  14252. }
  14253. update({ src, loading, error }) {
  14254. const oldSrc = this.src;
  14255. this.src = src;
  14256. this.loading = loading;
  14257. this.error = error;
  14258. this.filter();
  14259. if (oldSrc !== this.src) {
  14260. this.attempt = 0;
  14261. this.initState();
  14262. }
  14263. }
  14264. checkInView() {
  14265. const rect = useRect(this.el);
  14266. return rect.top < window.innerHeight * this.options.preLoad && rect.bottom > this.options.preLoadTop && rect.left < window.innerWidth * this.options.preLoad && rect.right > 0;
  14267. }
  14268. filter() {
  14269. Object.keys(this.options.filter).forEach((key) => {
  14270. this.options.filter[key](this, this.options);
  14271. });
  14272. }
  14273. renderLoading(cb) {
  14274. this.state.loading = true;
  14275. loadImageAsync(
  14276. {
  14277. src: this.loading,
  14278. cors: this.cors
  14279. },
  14280. () => {
  14281. this.render("loading", false);
  14282. this.state.loading = false;
  14283. cb();
  14284. },
  14285. () => {
  14286. cb();
  14287. this.state.loading = false;
  14288. if (process.env.NODE_ENV !== "production" && !this.options.silent)
  14289. console.warn(
  14290. `[@vant/lazyload] load failed with loading image(${this.loading})`
  14291. );
  14292. }
  14293. );
  14294. }
  14295. load(onFinish = noop) {
  14296. if (this.attempt > this.options.attempt - 1 && this.state.error) {
  14297. if (process.env.NODE_ENV !== "production" && !this.options.silent) {
  14298. console.log(
  14299. `[@vant/lazyload] ${this.src} tried too more than ${this.options.attempt} times`
  14300. );
  14301. }
  14302. onFinish();
  14303. return;
  14304. }
  14305. if (this.state.rendered && this.state.loaded)
  14306. return;
  14307. if (this.imageCache.has(this.src)) {
  14308. this.state.loaded = true;
  14309. this.render("loaded", true);
  14310. this.state.rendered = true;
  14311. return onFinish();
  14312. }
  14313. this.renderLoading(() => {
  14314. var _a, _b;
  14315. this.attempt++;
  14316. (_b = (_a = this.options.adapter).beforeLoad) == null ? void 0 : _b.call(_a, this, this.options);
  14317. this.record("loadStart");
  14318. loadImageAsync(
  14319. {
  14320. src: this.src,
  14321. cors: this.cors
  14322. },
  14323. (data) => {
  14324. this.naturalHeight = data.naturalHeight;
  14325. this.naturalWidth = data.naturalWidth;
  14326. this.state.loaded = true;
  14327. this.state.error = false;
  14328. this.record("loadEnd");
  14329. this.render("loaded", false);
  14330. this.state.rendered = true;
  14331. this.imageCache.add(this.src);
  14332. onFinish();
  14333. },
  14334. (err) => {
  14335. !this.options.silent && console.error(err);
  14336. this.state.error = true;
  14337. this.state.loaded = false;
  14338. this.render("error", false);
  14339. }
  14340. );
  14341. });
  14342. }
  14343. render(state, cache) {
  14344. this.elRenderer(this, state, cache);
  14345. }
  14346. performance() {
  14347. let state = "loading";
  14348. let time = 0;
  14349. if (this.state.loaded) {
  14350. state = "loaded";
  14351. time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1e3;
  14352. }
  14353. if (this.state.error)
  14354. state = "error";
  14355. return {
  14356. src: this.src,
  14357. state,
  14358. time
  14359. };
  14360. }
  14361. $destroy() {
  14362. this.el = null;
  14363. this.src = null;
  14364. this.error = null;
  14365. this.loading = null;
  14366. this.bindType = null;
  14367. this.attempt = 0;
  14368. }
  14369. }
  14370. const DEFAULT_URL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
  14371. const DEFAULT_EVENTS = [
  14372. "scroll",
  14373. "wheel",
  14374. "mousewheel",
  14375. "resize",
  14376. "animationend",
  14377. "transitionend",
  14378. "touchmove"
  14379. ];
  14380. const DEFAULT_OBSERVER_OPTIONS = {
  14381. rootMargin: "0px",
  14382. threshold: 0
  14383. };
  14384. function stdin_default$3() {
  14385. return class Lazy {
  14386. constructor({
  14387. preLoad,
  14388. error,
  14389. throttleWait,
  14390. preLoadTop,
  14391. dispatchEvent,
  14392. loading,
  14393. attempt,
  14394. silent = true,
  14395. scale,
  14396. listenEvents,
  14397. filter,
  14398. adapter,
  14399. observer,
  14400. observerOptions
  14401. }) {
  14402. this.mode = modeType.event;
  14403. this.listeners = [];
  14404. this.targetIndex = 0;
  14405. this.targets = [];
  14406. this.options = {
  14407. silent,
  14408. dispatchEvent: !!dispatchEvent,
  14409. throttleWait: throttleWait || 200,
  14410. preLoad: preLoad || 1.3,
  14411. preLoadTop: preLoadTop || 0,
  14412. error: error || DEFAULT_URL,
  14413. loading: loading || DEFAULT_URL,
  14414. attempt: attempt || 3,
  14415. scale: scale || getDPR(scale),
  14416. ListenEvents: listenEvents || DEFAULT_EVENTS,
  14417. supportWebp: supportWebp(),
  14418. filter: filter || {},
  14419. adapter: adapter || {},
  14420. observer: !!observer,
  14421. observerOptions: observerOptions || DEFAULT_OBSERVER_OPTIONS
  14422. };
  14423. this.initEvent();
  14424. this.imageCache = new ImageCache({ max: 200 });
  14425. this.lazyLoadHandler = throttle(
  14426. this.lazyLoadHandler.bind(this),
  14427. this.options.throttleWait
  14428. );
  14429. this.setMode(this.options.observer ? modeType.observer : modeType.event);
  14430. }
  14431. config(options = {}) {
  14432. Object.assign(this.options, options);
  14433. }
  14434. performance() {
  14435. return this.listeners.map((item) => item.performance());
  14436. }
  14437. addLazyBox(vm) {
  14438. this.listeners.push(vm);
  14439. if (inBrowser$1) {
  14440. this.addListenerTarget(window);
  14441. this.observer && this.observer.observe(vm.el);
  14442. if (vm.$el && vm.$el.parentNode) {
  14443. this.addListenerTarget(vm.$el.parentNode);
  14444. }
  14445. }
  14446. }
  14447. add(el, binding, vnode) {
  14448. if (this.listeners.some((item) => item.el === el)) {
  14449. this.update(el, binding);
  14450. return nextTick(this.lazyLoadHandler);
  14451. }
  14452. const value = this.valueFormatter(binding.value);
  14453. let { src } = value;
  14454. nextTick(() => {
  14455. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  14456. this.observer && this.observer.observe(el);
  14457. const container = Object.keys(binding.modifiers)[0];
  14458. let $parent;
  14459. if (container) {
  14460. $parent = vnode.context.$refs[container];
  14461. $parent = $parent ? $parent.$el || $parent : document.getElementById(container);
  14462. }
  14463. if (!$parent) {
  14464. $parent = getScrollParent(el);
  14465. }
  14466. const newListener = new ReactiveListener({
  14467. bindType: binding.arg,
  14468. $parent,
  14469. el,
  14470. src,
  14471. loading: value.loading,
  14472. error: value.error,
  14473. cors: value.cors,
  14474. elRenderer: this.elRenderer.bind(this),
  14475. options: this.options,
  14476. imageCache: this.imageCache
  14477. });
  14478. this.listeners.push(newListener);
  14479. if (inBrowser$1) {
  14480. this.addListenerTarget(window);
  14481. this.addListenerTarget($parent);
  14482. }
  14483. this.lazyLoadHandler();
  14484. nextTick(() => this.lazyLoadHandler());
  14485. });
  14486. }
  14487. update(el, binding, vnode) {
  14488. const value = this.valueFormatter(binding.value);
  14489. let { src } = value;
  14490. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  14491. const exist = this.listeners.find((item) => item.el === el);
  14492. if (!exist) {
  14493. this.add(el, binding, vnode);
  14494. } else {
  14495. exist.update({
  14496. src,
  14497. error: value.error,
  14498. loading: value.loading
  14499. });
  14500. }
  14501. if (this.observer) {
  14502. this.observer.unobserve(el);
  14503. this.observer.observe(el);
  14504. }
  14505. this.lazyLoadHandler();
  14506. nextTick(() => this.lazyLoadHandler());
  14507. }
  14508. remove(el) {
  14509. if (!el)
  14510. return;
  14511. this.observer && this.observer.unobserve(el);
  14512. const existItem = this.listeners.find((item) => item.el === el);
  14513. if (existItem) {
  14514. this.removeListenerTarget(existItem.$parent);
  14515. this.removeListenerTarget(window);
  14516. remove(this.listeners, existItem);
  14517. existItem.$destroy();
  14518. }
  14519. }
  14520. removeComponent(vm) {
  14521. if (!vm)
  14522. return;
  14523. remove(this.listeners, vm);
  14524. this.observer && this.observer.unobserve(vm.el);
  14525. if (vm.$parent && vm.$el.parentNode) {
  14526. this.removeListenerTarget(vm.$el.parentNode);
  14527. }
  14528. this.removeListenerTarget(window);
  14529. }
  14530. setMode(mode) {
  14531. if (!hasIntersectionObserver && mode === modeType.observer) {
  14532. mode = modeType.event;
  14533. }
  14534. this.mode = mode;
  14535. if (mode === modeType.event) {
  14536. if (this.observer) {
  14537. this.listeners.forEach((listener) => {
  14538. this.observer.unobserve(listener.el);
  14539. });
  14540. this.observer = null;
  14541. }
  14542. this.targets.forEach((target) => {
  14543. this.initListen(target.el, true);
  14544. });
  14545. } else {
  14546. this.targets.forEach((target) => {
  14547. this.initListen(target.el, false);
  14548. });
  14549. this.initIntersectionObserver();
  14550. }
  14551. }
  14552. addListenerTarget(el) {
  14553. if (!el)
  14554. return;
  14555. let target = this.targets.find((target2) => target2.el === el);
  14556. if (!target) {
  14557. target = {
  14558. el,
  14559. id: ++this.targetIndex,
  14560. childrenCount: 1,
  14561. listened: true
  14562. };
  14563. this.mode === modeType.event && this.initListen(target.el, true);
  14564. this.targets.push(target);
  14565. } else {
  14566. target.childrenCount++;
  14567. }
  14568. return this.targetIndex;
  14569. }
  14570. removeListenerTarget(el) {
  14571. this.targets.forEach((target, index) => {
  14572. if (target.el === el) {
  14573. target.childrenCount--;
  14574. if (!target.childrenCount) {
  14575. this.initListen(target.el, false);
  14576. this.targets.splice(index, 1);
  14577. target = null;
  14578. }
  14579. }
  14580. });
  14581. }
  14582. initListen(el, start) {
  14583. this.options.ListenEvents.forEach(
  14584. (evt) => (start ? on : off)(el, evt, this.lazyLoadHandler)
  14585. );
  14586. }
  14587. initEvent() {
  14588. this.Event = {
  14589. listeners: {
  14590. loading: [],
  14591. loaded: [],
  14592. error: []
  14593. }
  14594. };
  14595. this.$on = (event, func) => {
  14596. if (!this.Event.listeners[event])
  14597. this.Event.listeners[event] = [];
  14598. this.Event.listeners[event].push(func);
  14599. };
  14600. this.$once = (event, func) => {
  14601. const on2 = (...args) => {
  14602. this.$off(event, on2);
  14603. func.apply(this, args);
  14604. };
  14605. this.$on(event, on2);
  14606. };
  14607. this.$off = (event, func) => {
  14608. if (!func) {
  14609. if (!this.Event.listeners[event])
  14610. return;
  14611. this.Event.listeners[event].length = 0;
  14612. return;
  14613. }
  14614. remove(this.Event.listeners[event], func);
  14615. };
  14616. this.$emit = (event, context, inCache) => {
  14617. if (!this.Event.listeners[event])
  14618. return;
  14619. this.Event.listeners[event].forEach((func) => func(context, inCache));
  14620. };
  14621. }
  14622. lazyLoadHandler() {
  14623. const freeList = [];
  14624. this.listeners.forEach((listener) => {
  14625. if (!listener.el || !listener.el.parentNode) {
  14626. freeList.push(listener);
  14627. }
  14628. const catIn = listener.checkInView();
  14629. if (!catIn)
  14630. return;
  14631. listener.load();
  14632. });
  14633. freeList.forEach((item) => {
  14634. remove(this.listeners, item);
  14635. item.$destroy();
  14636. });
  14637. }
  14638. initIntersectionObserver() {
  14639. if (!hasIntersectionObserver) {
  14640. return;
  14641. }
  14642. this.observer = new IntersectionObserver(
  14643. this.observerHandler.bind(this),
  14644. this.options.observerOptions
  14645. );
  14646. if (this.listeners.length) {
  14647. this.listeners.forEach((listener) => {
  14648. this.observer.observe(listener.el);
  14649. });
  14650. }
  14651. }
  14652. observerHandler(entries) {
  14653. entries.forEach((entry) => {
  14654. if (entry.isIntersecting) {
  14655. this.listeners.forEach((listener) => {
  14656. if (listener.el === entry.target) {
  14657. if (listener.state.loaded)
  14658. return this.observer.unobserve(listener.el);
  14659. listener.load();
  14660. }
  14661. });
  14662. }
  14663. });
  14664. }
  14665. elRenderer(listener, state, cache) {
  14666. if (!listener.el)
  14667. return;
  14668. const { el, bindType } = listener;
  14669. let src;
  14670. switch (state) {
  14671. case "loading":
  14672. src = listener.loading;
  14673. break;
  14674. case "error":
  14675. src = listener.error;
  14676. break;
  14677. default:
  14678. ({ src } = listener);
  14679. break;
  14680. }
  14681. if (bindType) {
  14682. el.style[bindType] = 'url("' + src + '")';
  14683. } else if (el.getAttribute("src") !== src) {
  14684. el.setAttribute("src", src);
  14685. }
  14686. el.setAttribute("lazy", state);
  14687. this.$emit(state, listener, cache);
  14688. this.options.adapter[state] && this.options.adapter[state](listener, this.options);
  14689. if (this.options.dispatchEvent) {
  14690. const event = new CustomEvent(state, {
  14691. detail: listener
  14692. });
  14693. el.dispatchEvent(event);
  14694. }
  14695. }
  14696. valueFormatter(value) {
  14697. let src = value;
  14698. let { loading, error } = this.options;
  14699. if (isObject(value)) {
  14700. if (process.env.NODE_ENV !== "production" && !value.src && !this.options.silent) {
  14701. console.error("[@vant/lazyload] miss src with " + value);
  14702. }
  14703. ({ src } = value);
  14704. loading = value.loading || this.options.loading;
  14705. error = value.error || this.options.error;
  14706. }
  14707. return {
  14708. src,
  14709. loading,
  14710. error
  14711. };
  14712. }
  14713. };
  14714. }
  14715. var stdin_default$2 = (lazy) => ({
  14716. props: {
  14717. tag: {
  14718. type: String,
  14719. default: "div"
  14720. }
  14721. },
  14722. emits: ["show"],
  14723. render() {
  14724. return h(
  14725. this.tag,
  14726. this.show && this.$slots.default ? this.$slots.default() : null
  14727. );
  14728. },
  14729. data() {
  14730. return {
  14731. el: null,
  14732. state: {
  14733. loaded: false
  14734. },
  14735. show: false
  14736. };
  14737. },
  14738. mounted() {
  14739. this.el = this.$el;
  14740. lazy.addLazyBox(this);
  14741. lazy.lazyLoadHandler();
  14742. },
  14743. beforeUnmount() {
  14744. lazy.removeComponent(this);
  14745. },
  14746. methods: {
  14747. checkInView() {
  14748. const rect = useRect(this.$el);
  14749. return inBrowser$1 && rect.top < window.innerHeight * lazy.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazy.options.preLoad && rect.right > 0;
  14750. },
  14751. load() {
  14752. this.show = true;
  14753. this.state.loaded = true;
  14754. this.$emit("show", this);
  14755. },
  14756. destroy() {
  14757. return this.$destroy;
  14758. }
  14759. }
  14760. });
  14761. const defaultOptions = {
  14762. selector: "img"
  14763. };
  14764. class LazyContainer {
  14765. constructor({ el, binding, vnode, lazy }) {
  14766. this.el = null;
  14767. this.vnode = vnode;
  14768. this.binding = binding;
  14769. this.options = {};
  14770. this.lazy = lazy;
  14771. this.queue = [];
  14772. this.update({ el, binding });
  14773. }
  14774. update({ el, binding }) {
  14775. this.el = el;
  14776. this.options = Object.assign({}, defaultOptions, binding.value);
  14777. const imgs = this.getImgs();
  14778. imgs.forEach((el2) => {
  14779. this.lazy.add(
  14780. el2,
  14781. Object.assign({}, this.binding, {
  14782. value: {
  14783. src: "dataset" in el2 ? el2.dataset.src : el2.getAttribute("data-src"),
  14784. error: ("dataset" in el2 ? el2.dataset.error : el2.getAttribute("data-error")) || this.options.error,
  14785. loading: ("dataset" in el2 ? el2.dataset.loading : el2.getAttribute("data-loading")) || this.options.loading
  14786. }
  14787. }),
  14788. this.vnode
  14789. );
  14790. });
  14791. }
  14792. getImgs() {
  14793. return Array.from(this.el.querySelectorAll(this.options.selector));
  14794. }
  14795. clear() {
  14796. const imgs = this.getImgs();
  14797. imgs.forEach((el) => this.lazy.remove(el));
  14798. this.vnode = null;
  14799. this.binding = null;
  14800. this.lazy = null;
  14801. }
  14802. }
  14803. class LazyContainerManager {
  14804. constructor({ lazy }) {
  14805. this.lazy = lazy;
  14806. this.queue = [];
  14807. }
  14808. bind(el, binding, vnode) {
  14809. const container = new LazyContainer({
  14810. el,
  14811. binding,
  14812. vnode,
  14813. lazy: this.lazy
  14814. });
  14815. this.queue.push(container);
  14816. }
  14817. update(el, binding, vnode) {
  14818. const container = this.queue.find((item) => item.el === el);
  14819. if (!container)
  14820. return;
  14821. container.update({ el, binding, vnode });
  14822. }
  14823. unbind(el) {
  14824. const container = this.queue.find((item) => item.el === el);
  14825. if (!container)
  14826. return;
  14827. container.clear();
  14828. remove(this.queue, container);
  14829. }
  14830. }
  14831. var stdin_default$1 = (lazyManager) => ({
  14832. props: {
  14833. src: [String, Object],
  14834. tag: {
  14835. type: String,
  14836. default: "img"
  14837. }
  14838. },
  14839. render(h2) {
  14840. return h2(
  14841. this.tag,
  14842. {
  14843. attrs: {
  14844. src: this.renderSrc
  14845. }
  14846. },
  14847. this.$slots.default
  14848. );
  14849. },
  14850. data() {
  14851. return {
  14852. el: null,
  14853. options: {
  14854. src: "",
  14855. error: "",
  14856. loading: "",
  14857. attempt: lazyManager.options.attempt
  14858. },
  14859. state: {
  14860. loaded: false,
  14861. error: false,
  14862. attempt: 0
  14863. },
  14864. renderSrc: ""
  14865. };
  14866. },
  14867. watch: {
  14868. src() {
  14869. this.init();
  14870. lazyManager.addLazyBox(this);
  14871. lazyManager.lazyLoadHandler();
  14872. }
  14873. },
  14874. created() {
  14875. this.init();
  14876. this.renderSrc = this.options.loading;
  14877. },
  14878. mounted() {
  14879. this.el = this.$el;
  14880. lazyManager.addLazyBox(this);
  14881. lazyManager.lazyLoadHandler();
  14882. },
  14883. beforeUnmount() {
  14884. lazyManager.removeComponent(this);
  14885. },
  14886. methods: {
  14887. init() {
  14888. const { src, loading, error } = lazyManager.valueFormatter(this.src);
  14889. this.state.loaded = false;
  14890. this.options.src = src;
  14891. this.options.error = error;
  14892. this.options.loading = loading;
  14893. this.renderSrc = this.options.loading;
  14894. },
  14895. checkInView() {
  14896. const rect = useRect(this.$el);
  14897. return rect.top < window.innerHeight * lazyManager.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazyManager.options.preLoad && rect.right > 0;
  14898. },
  14899. load(onFinish = noop) {
  14900. if (this.state.attempt > this.options.attempt - 1 && this.state.error) {
  14901. if (process.env.NODE_ENV !== "production" && !lazyManager.options.silent) {
  14902. console.log(
  14903. `[@vant/lazyload] ${this.options.src} tried too more than ${this.options.attempt} times`
  14904. );
  14905. }
  14906. onFinish();
  14907. return;
  14908. }
  14909. const { src } = this.options;
  14910. loadImageAsync(
  14911. { src },
  14912. ({ src: src2 }) => {
  14913. this.renderSrc = src2;
  14914. this.state.loaded = true;
  14915. },
  14916. () => {
  14917. this.state.attempt++;
  14918. this.renderSrc = this.options.error;
  14919. this.state.error = true;
  14920. }
  14921. );
  14922. }
  14923. }
  14924. });
  14925. const Lazyload = {
  14926. install(app, options = {}) {
  14927. const LazyClass = stdin_default$3();
  14928. const lazy = new LazyClass(options);
  14929. const lazyContainer = new LazyContainerManager({ lazy });
  14930. app.config.globalProperties.$Lazyload = lazy;
  14931. if (options.lazyComponent) {
  14932. app.component("LazyComponent", stdin_default$2(lazy));
  14933. }
  14934. if (options.lazyImage) {
  14935. app.component("LazyImage", stdin_default$1(lazy));
  14936. }
  14937. app.directive("lazy", {
  14938. beforeMount: lazy.add.bind(lazy),
  14939. updated: lazy.update.bind(lazy),
  14940. unmounted: lazy.remove.bind(lazy)
  14941. });
  14942. app.directive("lazy-container", {
  14943. beforeMount: lazyContainer.bind.bind(lazyContainer),
  14944. updated: lazyContainer.update.bind(lazyContainer),
  14945. unmounted: lazyContainer.unbind.bind(lazyContainer)
  14946. });
  14947. }
  14948. };
  14949. const version = "3.6.4";
  14950. function install(app) {
  14951. const components = [
  14952. ActionBar,
  14953. ActionBarButton,
  14954. ActionBarIcon,
  14955. ActionSheet,
  14956. AddressEdit,
  14957. AddressList,
  14958. Area,
  14959. Badge,
  14960. Button,
  14961. Calendar,
  14962. Card,
  14963. Cascader,
  14964. Cell,
  14965. CellGroup,
  14966. Checkbox,
  14967. CheckboxGroup,
  14968. Circle,
  14969. Col,
  14970. Collapse,
  14971. CollapseItem,
  14972. ConfigProvider,
  14973. ContactCard,
  14974. ContactEdit,
  14975. ContactList,
  14976. CountDown,
  14977. Coupon,
  14978. CouponCell,
  14979. CouponList,
  14980. DatetimePicker,
  14981. Dialog,
  14982. Divider,
  14983. DropdownItem,
  14984. DropdownMenu,
  14985. Empty,
  14986. Field,
  14987. Form,
  14988. Grid,
  14989. GridItem,
  14990. Icon,
  14991. Image$1,
  14992. ImagePreview,
  14993. IndexAnchor,
  14994. IndexBar,
  14995. List,
  14996. Loading,
  14997. Locale,
  14998. NavBar,
  14999. NoticeBar,
  15000. Notify,
  15001. NumberKeyboard,
  15002. Overlay,
  15003. Pagination,
  15004. PasswordInput,
  15005. Picker,
  15006. Popover,
  15007. Popup,
  15008. Progress,
  15009. PullRefresh,
  15010. Radio,
  15011. RadioGroup,
  15012. Rate,
  15013. Row,
  15014. Search,
  15015. ShareSheet,
  15016. Sidebar,
  15017. SidebarItem,
  15018. Skeleton,
  15019. Slider,
  15020. Space,
  15021. Step,
  15022. Stepper,
  15023. Steps,
  15024. Sticky,
  15025. SubmitBar,
  15026. Swipe,
  15027. SwipeCell,
  15028. SwipeItem,
  15029. Switch,
  15030. Tab,
  15031. Tabbar,
  15032. TabbarItem,
  15033. Tabs,
  15034. Tag,
  15035. Toast,
  15036. TreeSelect,
  15037. Uploader
  15038. ];
  15039. components.forEach((item) => {
  15040. if (item.install) {
  15041. app.use(item);
  15042. } else if (item.name) {
  15043. app.component(item.name, item);
  15044. }
  15045. });
  15046. }
  15047. var stdin_default = {
  15048. install,
  15049. version
  15050. };
  15051. export {
  15052. ActionBar,
  15053. ActionBarButton,
  15054. ActionBarIcon,
  15055. ActionSheet,
  15056. AddressEdit,
  15057. AddressList,
  15058. Area,
  15059. Badge,
  15060. Button,
  15061. Calendar,
  15062. Card,
  15063. Cascader,
  15064. Cell,
  15065. CellGroup,
  15066. Checkbox,
  15067. CheckboxGroup,
  15068. Circle,
  15069. Col,
  15070. Collapse,
  15071. CollapseItem,
  15072. ConfigProvider,
  15073. ContactCard,
  15074. ContactEdit,
  15075. ContactList,
  15076. CountDown,
  15077. Coupon,
  15078. CouponCell,
  15079. CouponList,
  15080. DatetimePicker,
  15081. Dialog,
  15082. Divider,
  15083. DropdownItem,
  15084. DropdownMenu,
  15085. Empty,
  15086. Field,
  15087. Form,
  15088. Grid,
  15089. GridItem,
  15090. Icon,
  15091. Image$1 as Image,
  15092. ImagePreview,
  15093. IndexAnchor,
  15094. IndexBar,
  15095. Lazyload,
  15096. List,
  15097. Loading,
  15098. Locale,
  15099. NavBar,
  15100. NoticeBar,
  15101. Notify,
  15102. NumberKeyboard,
  15103. Overlay,
  15104. Pagination,
  15105. PasswordInput,
  15106. Picker,
  15107. Popover,
  15108. Popup,
  15109. Progress,
  15110. PullRefresh,
  15111. Radio,
  15112. RadioGroup,
  15113. Rate,
  15114. Row,
  15115. Search,
  15116. ShareSheet,
  15117. Sidebar,
  15118. SidebarItem,
  15119. Skeleton,
  15120. Slider,
  15121. Space,
  15122. Step,
  15123. Stepper,
  15124. Steps,
  15125. Sticky,
  15126. SubmitBar,
  15127. Swipe,
  15128. SwipeCell,
  15129. SwipeItem,
  15130. Switch,
  15131. Tab,
  15132. Tabbar,
  15133. TabbarItem,
  15134. Tabs,
  15135. Tag,
  15136. Toast,
  15137. TreeSelect,
  15138. Uploader,
  15139. stdin_default as default,
  15140. install,
  15141. version
  15142. };