vant.es.js 490 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400
  1. import { unref, ref, reactive, inject, watch, onMounted, nextTick, createVNode, defineComponent, getCurrentInstance, computed, onActivated, onDeactivated, onBeforeUnmount, provide, watchEffect, mergeProps, Transition, Teleport, withDirectives, vShow, Fragment, onBeforeUpdate, Comment, createTextVNode, onUnmounted, createApp, resolveDirective, withKeys, onUpdated, Text, h } from "vue";
  2. import { useWindowSize, useRect, useChildren, useParent, onMountedOrActivated, getScrollParent, useEventListener, cancelRaf, raf, useScrollParent, usePageVisibility, doubleRaf, CUSTOM_FIELD_INJECTION_KEY, useCustomFieldValue, inBrowser as inBrowser$1, useToggle, useCountDown, useClickAway } from "@vant/use";
  3. import { normalizeClass, stringifyStyle, normalizeStyle } from "@vue/shared";
  4. import { offsetModifier, createPopper } from "@vant/popperjs";
  5. function noop() {
  6. }
  7. const extend = Object.assign;
  8. const inBrowser = typeof window !== "undefined";
  9. const isObject = (val) => val !== null && typeof val === "object";
  10. const isDef = (val) => val !== void 0 && val !== null;
  11. const isFunction = (val) => typeof val === "function";
  12. const isPromise = (val) => isObject(val) && isFunction(val.then) && isFunction(val.catch);
  13. const isDate = (val) => Object.prototype.toString.call(val) === "[object Date]" && !Number.isNaN(val.getTime());
  14. function isMobile(value) {
  15. value = value.replace(/[^-|\d]/g, "");
  16. return /^((\+86)|(86))?(1)\d{10}$/.test(value) || /^0[0-9-]{10,13}$/.test(value);
  17. }
  18. const isNumeric = (val) => typeof val === "number" || /^\d+(\.\d+)?$/.test(val);
  19. const isIOS$1 = () => inBrowser ? /ios|iphone|ipad|ipod/.test(navigator.userAgent.toLowerCase()) : false;
  20. function get(object, path) {
  21. const keys = path.split(".");
  22. let result = object;
  23. keys.forEach((key) => {
  24. var _a;
  25. result = isObject(result) ? (_a = result[key]) != null ? _a : "" : "";
  26. });
  27. return result;
  28. }
  29. function pick(obj, keys, ignoreUndefined) {
  30. return keys.reduce(
  31. (ret, key) => {
  32. if (!ignoreUndefined || obj[key] !== void 0) {
  33. ret[key] = obj[key];
  34. }
  35. return ret;
  36. },
  37. {}
  38. );
  39. }
  40. const isSameValue = (newValue, oldValue) => JSON.stringify(newValue) === JSON.stringify(oldValue);
  41. const toArray = (item) => Array.isArray(item) ? item : [item];
  42. const flat = (arr) => arr.reduce((acc, val) => acc.concat(val), []);
  43. const unknownProp = null;
  44. const numericProp = [Number, String];
  45. const truthProp = {
  46. type: Boolean,
  47. default: true
  48. };
  49. const makeRequiredProp = (type) => ({
  50. type,
  51. required: true
  52. });
  53. const makeArrayProp = () => ({
  54. type: Array,
  55. default: () => []
  56. });
  57. const makeNumberProp = (defaultVal) => ({
  58. type: Number,
  59. default: defaultVal
  60. });
  61. const makeNumericProp = (defaultVal) => ({
  62. type: numericProp,
  63. default: defaultVal
  64. });
  65. const makeStringProp = (defaultVal) => ({
  66. type: String,
  67. default: defaultVal
  68. });
  69. function getScrollTop(el) {
  70. const top = "scrollTop" in el ? el.scrollTop : el.pageYOffset;
  71. return Math.max(top, 0);
  72. }
  73. function setScrollTop(el, value) {
  74. if ("scrollTop" in el) {
  75. el.scrollTop = value;
  76. } else {
  77. el.scrollTo(el.scrollX, value);
  78. }
  79. }
  80. function getRootScrollTop() {
  81. return window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
  82. }
  83. function setRootScrollTop(value) {
  84. setScrollTop(window, value);
  85. setScrollTop(document.body, value);
  86. }
  87. function getElementTop(el, scroller) {
  88. if (el === window) {
  89. return 0;
  90. }
  91. const scrollTop = scroller ? getScrollTop(scroller) : getRootScrollTop();
  92. return useRect(el).top + scrollTop;
  93. }
  94. const isIOS = isIOS$1();
  95. function resetScroll() {
  96. if (isIOS) {
  97. setRootScrollTop(getRootScrollTop());
  98. }
  99. }
  100. const stopPropagation = (event) => event.stopPropagation();
  101. function preventDefault(event, isStopPropagation) {
  102. if (typeof event.cancelable !== "boolean" || event.cancelable) {
  103. event.preventDefault();
  104. }
  105. if (isStopPropagation) {
  106. stopPropagation(event);
  107. }
  108. }
  109. function isHidden(elementRef) {
  110. const el = unref(elementRef);
  111. if (!el) {
  112. return false;
  113. }
  114. const style = window.getComputedStyle(el);
  115. const hidden = style.display === "none";
  116. const parentHidden = el.offsetParent === null && style.position !== "fixed";
  117. return hidden || parentHidden;
  118. }
  119. const { width: windowWidth, height: windowHeight } = useWindowSize();
  120. function isContainingBlock(el) {
  121. const css = window.getComputedStyle(el);
  122. return css.transform !== "none" || css.perspective !== "none" || ["transform", "perspective", "filter"].some(
  123. (value) => (css.willChange || "").includes(value)
  124. );
  125. }
  126. function getContainingBlock(el) {
  127. let node = el.parentElement;
  128. while (node) {
  129. if (node && node.tagName !== "HTML" && node.tagName !== "BODY" && isContainingBlock(node)) {
  130. return node;
  131. }
  132. node = node.parentElement;
  133. }
  134. return null;
  135. }
  136. function addUnit(value) {
  137. if (isDef(value)) {
  138. return isNumeric(value) ? `${value}px` : String(value);
  139. }
  140. return void 0;
  141. }
  142. function getSizeStyle(originSize) {
  143. if (isDef(originSize)) {
  144. if (Array.isArray(originSize)) {
  145. return {
  146. width: addUnit(originSize[0]),
  147. height: addUnit(originSize[1])
  148. };
  149. }
  150. const size = addUnit(originSize);
  151. return {
  152. width: size,
  153. height: size
  154. };
  155. }
  156. }
  157. function getZIndexStyle(zIndex) {
  158. const style = {};
  159. if (zIndex !== void 0) {
  160. style.zIndex = +zIndex;
  161. }
  162. return style;
  163. }
  164. let rootFontSize;
  165. function getRootFontSize() {
  166. if (!rootFontSize) {
  167. const doc = document.documentElement;
  168. const fontSize = doc.style.fontSize || window.getComputedStyle(doc).fontSize;
  169. rootFontSize = parseFloat(fontSize);
  170. }
  171. return rootFontSize;
  172. }
  173. function convertRem(value) {
  174. value = value.replace(/rem/g, "");
  175. return +value * getRootFontSize();
  176. }
  177. function convertVw(value) {
  178. value = value.replace(/vw/g, "");
  179. return +value * windowWidth.value / 100;
  180. }
  181. function convertVh(value) {
  182. value = value.replace(/vh/g, "");
  183. return +value * windowHeight.value / 100;
  184. }
  185. function unitToPx(value) {
  186. if (typeof value === "number") {
  187. return value;
  188. }
  189. if (inBrowser) {
  190. if (value.includes("rem")) {
  191. return convertRem(value);
  192. }
  193. if (value.includes("vw")) {
  194. return convertVw(value);
  195. }
  196. if (value.includes("vh")) {
  197. return convertVh(value);
  198. }
  199. }
  200. return parseFloat(value);
  201. }
  202. const camelizeRE = /-(\w)/g;
  203. const camelize = (str) => str.replace(camelizeRE, (_, c) => c.toUpperCase());
  204. const kebabCase = (str) => str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
  205. function padZero(num, targetLength = 2) {
  206. let str = num + "";
  207. while (str.length < targetLength) {
  208. str = "0" + str;
  209. }
  210. return str;
  211. }
  212. const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
  213. function trimExtraChar(value, char, regExp) {
  214. const index = value.indexOf(char);
  215. if (index === -1) {
  216. return value;
  217. }
  218. if (char === "-" && index !== 0) {
  219. return value.slice(0, index);
  220. }
  221. return value.slice(0, index + 1) + value.slice(index).replace(regExp, "");
  222. }
  223. function formatNumber(value, allowDot = true, allowMinus = true) {
  224. if (allowDot) {
  225. value = trimExtraChar(value, ".", /\./g);
  226. } else {
  227. value = value.split(".")[0];
  228. }
  229. if (allowMinus) {
  230. value = trimExtraChar(value, "-", /-/g);
  231. } else {
  232. value = value.replace(/-/, "");
  233. }
  234. const regExp = allowDot ? /[^-0-9.]/g : /[^-0-9]/g;
  235. return value.replace(regExp, "");
  236. }
  237. function addNumber(num1, num2) {
  238. const cardinal = 10 ** 10;
  239. return Math.round((num1 + num2) * cardinal) / cardinal;
  240. }
  241. const { hasOwnProperty } = Object.prototype;
  242. function assignKey(to, from, key) {
  243. const val = from[key];
  244. if (!isDef(val)) {
  245. return;
  246. }
  247. if (!hasOwnProperty.call(to, key) || !isObject(val)) {
  248. to[key] = val;
  249. } else {
  250. to[key] = deepAssign(Object(to[key]), val);
  251. }
  252. }
  253. function deepAssign(to, from) {
  254. Object.keys(from).forEach((key) => {
  255. assignKey(to, from, key);
  256. });
  257. return to;
  258. }
  259. var stdin_default$1W = {
  260. name: "姓名",
  261. tel: "电话",
  262. save: "保存",
  263. clear: "清空",
  264. cancel: "取消",
  265. confirm: "确认",
  266. delete: "删除",
  267. loading: "加载中...",
  268. noCoupon: "暂无优惠券",
  269. nameEmpty: "请填写姓名",
  270. addContact: "添加联系人",
  271. telInvalid: "请填写正确的电话",
  272. vanCalendar: {
  273. end: "结束",
  274. start: "开始",
  275. title: "日期选择",
  276. weekdays: ["日", "一", "二", "三", "四", "五", "六"],
  277. monthTitle: (year, month) => `${year}年${month}月`,
  278. rangePrompt: (maxRange) => `最多选择 ${maxRange} 天`
  279. },
  280. vanCascader: {
  281. select: "请选择"
  282. },
  283. vanPagination: {
  284. prev: "上一页",
  285. next: "下一页"
  286. },
  287. vanPullRefresh: {
  288. pulling: "下拉即可刷新...",
  289. loosing: "释放即可刷新..."
  290. },
  291. vanSubmitBar: {
  292. label: "合计:"
  293. },
  294. vanCoupon: {
  295. unlimited: "无门槛",
  296. discount: (discount) => `${discount}折`,
  297. condition: (condition) => `满${condition}元可用`
  298. },
  299. vanCouponCell: {
  300. title: "优惠券",
  301. count: (count) => `${count}张可用`
  302. },
  303. vanCouponList: {
  304. exchange: "兑换",
  305. close: "不使用",
  306. enable: "可用",
  307. disabled: "不可用",
  308. placeholder: "输入优惠码"
  309. },
  310. vanAddressEdit: {
  311. area: "地区",
  312. areaEmpty: "请选择地区",
  313. addressEmpty: "请填写详细地址",
  314. addressDetail: "详细地址",
  315. defaultAddress: "设为默认收货地址"
  316. },
  317. vanAddressList: {
  318. add: "新增地址"
  319. }
  320. };
  321. const lang = ref("zh-CN");
  322. const messages = reactive({
  323. "zh-CN": stdin_default$1W
  324. });
  325. const Locale = {
  326. messages() {
  327. return messages[lang.value];
  328. },
  329. use(newLang, newMessages) {
  330. lang.value = newLang;
  331. this.add({ [newLang]: newMessages });
  332. },
  333. add(newMessages = {}) {
  334. deepAssign(messages, newMessages);
  335. }
  336. };
  337. const useCurrentLang = () => lang;
  338. var stdin_default$1V = Locale;
  339. function createTranslate(name2) {
  340. const prefix = camelize(name2) + ".";
  341. return (path, ...args) => {
  342. const messages2 = stdin_default$1V.messages();
  343. const message = get(messages2, prefix + path) || get(messages2, path);
  344. return isFunction(message) ? message(...args) : message;
  345. };
  346. }
  347. function genBem(name2, mods) {
  348. if (!mods) {
  349. return "";
  350. }
  351. if (typeof mods === "string") {
  352. return ` ${name2}--${mods}`;
  353. }
  354. if (Array.isArray(mods)) {
  355. return mods.reduce(
  356. (ret, item) => ret + genBem(name2, item),
  357. ""
  358. );
  359. }
  360. return Object.keys(mods).reduce(
  361. (ret, key) => ret + (mods[key] ? genBem(name2, key) : ""),
  362. ""
  363. );
  364. }
  365. function createBEM(name2) {
  366. return (el, mods) => {
  367. if (el && typeof el !== "string") {
  368. mods = el;
  369. el = "";
  370. }
  371. el = el ? `${name2}__${el}` : name2;
  372. return `${el}${genBem(el, mods)}`;
  373. };
  374. }
  375. function createNamespace(name2) {
  376. const prefixedName = `van-${name2}`;
  377. return [
  378. prefixedName,
  379. createBEM(prefixedName),
  380. createTranslate(prefixedName)
  381. ];
  382. }
  383. const BORDER = "van-hairline";
  384. const BORDER_TOP = `${BORDER}--top`;
  385. const BORDER_LEFT = `${BORDER}--left`;
  386. const BORDER_RIGHT = `${BORDER}--right`;
  387. const BORDER_BOTTOM = `${BORDER}--bottom`;
  388. const BORDER_SURROUND = `${BORDER}--surround`;
  389. const BORDER_TOP_BOTTOM = `${BORDER}--top-bottom`;
  390. const BORDER_UNSET_TOP_BOTTOM = `${BORDER}-unset--top-bottom`;
  391. const HAPTICS_FEEDBACK = "van-haptics-feedback";
  392. const FORM_KEY = Symbol("van-form");
  393. const LONG_PRESS_START_TIME = 500;
  394. const TAP_OFFSET = 5;
  395. function callInterceptor(interceptor, {
  396. args = [],
  397. done,
  398. canceled,
  399. error
  400. }) {
  401. if (interceptor) {
  402. const returnVal = interceptor.apply(null, args);
  403. if (isPromise(returnVal)) {
  404. returnVal.then((value) => {
  405. if (value) {
  406. done();
  407. } else if (canceled) {
  408. canceled();
  409. }
  410. }).catch(error || noop);
  411. } else if (returnVal) {
  412. done();
  413. } else if (canceled) {
  414. canceled();
  415. }
  416. } else {
  417. done();
  418. }
  419. }
  420. function withInstall(options) {
  421. options.install = (app) => {
  422. const { name: name2 } = options;
  423. if (name2) {
  424. app.component(name2, options);
  425. app.component(camelize(`-${name2}`), options);
  426. }
  427. };
  428. return options;
  429. }
  430. function closest(arr, target) {
  431. return arr.reduce(
  432. (pre, cur) => Math.abs(pre - target) < Math.abs(cur - target) ? pre : cur
  433. );
  434. }
  435. const POPUP_TOGGLE_KEY = Symbol();
  436. function onPopupReopen(callback) {
  437. const popupToggleStatus = inject(POPUP_TOGGLE_KEY, null);
  438. if (popupToggleStatus) {
  439. watch(popupToggleStatus, (show) => {
  440. if (show) {
  441. callback();
  442. }
  443. });
  444. }
  445. }
  446. const useHeight = (element, withSafeArea) => {
  447. const height = ref();
  448. const setHeight = () => {
  449. height.value = useRect(element).height;
  450. };
  451. onMounted(() => {
  452. nextTick(setHeight);
  453. if (withSafeArea) {
  454. for (let i = 1; i <= 3; i++) {
  455. setTimeout(setHeight, 100 * i);
  456. }
  457. }
  458. });
  459. onPopupReopen(() => nextTick(setHeight));
  460. watch([windowWidth, windowHeight], setHeight);
  461. return height;
  462. };
  463. function usePlaceholder(contentRef, bem2) {
  464. const height = useHeight(contentRef, true);
  465. return (renderContent) => createVNode("div", {
  466. "class": bem2("placeholder"),
  467. "style": {
  468. height: height.value ? `${height.value}px` : void 0
  469. }
  470. }, [renderContent()]);
  471. }
  472. const [name$1K, bem$1F] = createNamespace("action-bar");
  473. const ACTION_BAR_KEY = Symbol(name$1K);
  474. const actionBarProps = {
  475. placeholder: Boolean,
  476. safeAreaInsetBottom: truthProp
  477. };
  478. var stdin_default$1U = defineComponent({
  479. name: name$1K,
  480. props: actionBarProps,
  481. setup(props2, {
  482. slots
  483. }) {
  484. const root = ref();
  485. const renderPlaceholder = usePlaceholder(root, bem$1F);
  486. const {
  487. linkChildren
  488. } = useChildren(ACTION_BAR_KEY);
  489. linkChildren();
  490. const renderActionBar = () => {
  491. var _a;
  492. return createVNode("div", {
  493. "ref": root,
  494. "class": [bem$1F(), {
  495. "van-safe-area-bottom": props2.safeAreaInsetBottom
  496. }]
  497. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  498. };
  499. return () => {
  500. if (props2.placeholder) {
  501. return renderPlaceholder(renderActionBar);
  502. }
  503. return renderActionBar();
  504. };
  505. }
  506. });
  507. const ActionBar = withInstall(stdin_default$1U);
  508. function useExpose(apis) {
  509. const instance2 = getCurrentInstance();
  510. if (instance2) {
  511. extend(instance2.proxy, apis);
  512. }
  513. }
  514. const routeProps = {
  515. to: [String, Object],
  516. url: String,
  517. replace: Boolean
  518. };
  519. function route({
  520. to,
  521. url,
  522. replace,
  523. $router: router
  524. }) {
  525. if (to && router) {
  526. router[replace ? "replace" : "push"](to);
  527. } else if (url) {
  528. replace ? location.replace(url) : location.href = url;
  529. }
  530. }
  531. function useRoute() {
  532. const vm = getCurrentInstance().proxy;
  533. return () => route(vm);
  534. }
  535. const [name$1J, bem$1E] = createNamespace("badge");
  536. const badgeProps = {
  537. dot: Boolean,
  538. max: numericProp,
  539. tag: makeStringProp("div"),
  540. color: String,
  541. offset: Array,
  542. content: numericProp,
  543. showZero: truthProp,
  544. position: makeStringProp("top-right")
  545. };
  546. var stdin_default$1T = defineComponent({
  547. name: name$1J,
  548. props: badgeProps,
  549. setup(props2, {
  550. slots
  551. }) {
  552. const hasContent = () => {
  553. if (slots.content) {
  554. return true;
  555. }
  556. const {
  557. content,
  558. showZero
  559. } = props2;
  560. return isDef(content) && content !== "" && (showZero || content !== 0 && content !== "0");
  561. };
  562. const renderContent = () => {
  563. const {
  564. dot,
  565. max,
  566. content
  567. } = props2;
  568. if (!dot && hasContent()) {
  569. if (slots.content) {
  570. return slots.content();
  571. }
  572. if (isDef(max) && isNumeric(content) && +content > +max) {
  573. return `${max}+`;
  574. }
  575. return content;
  576. }
  577. };
  578. const getOffsetWithMinusString = (val) => val.startsWith("-") ? val.replace("-", "") : `-${val}`;
  579. const style = computed(() => {
  580. const style2 = {
  581. background: props2.color
  582. };
  583. if (props2.offset) {
  584. const [x, y] = props2.offset;
  585. const {
  586. position
  587. } = props2;
  588. const [offsetY, offsetX] = position.split("-");
  589. if (slots.default) {
  590. if (typeof y === "number") {
  591. style2[offsetY] = addUnit(offsetY === "top" ? y : -y);
  592. } else {
  593. style2[offsetY] = offsetY === "top" ? addUnit(y) : getOffsetWithMinusString(y);
  594. }
  595. if (typeof x === "number") {
  596. style2[offsetX] = addUnit(offsetX === "left" ? x : -x);
  597. } else {
  598. style2[offsetX] = offsetX === "left" ? addUnit(x) : getOffsetWithMinusString(x);
  599. }
  600. } else {
  601. style2.marginTop = addUnit(y);
  602. style2.marginLeft = addUnit(x);
  603. }
  604. }
  605. return style2;
  606. });
  607. const renderBadge = () => {
  608. if (hasContent() || props2.dot) {
  609. return createVNode("div", {
  610. "class": bem$1E([props2.position, {
  611. dot: props2.dot,
  612. fixed: !!slots.default
  613. }]),
  614. "style": style.value
  615. }, [renderContent()]);
  616. }
  617. };
  618. return () => {
  619. if (slots.default) {
  620. const {
  621. tag
  622. } = props2;
  623. return createVNode(tag, {
  624. "class": bem$1E("wrapper")
  625. }, {
  626. default: () => [slots.default(), renderBadge()]
  627. });
  628. }
  629. return renderBadge();
  630. };
  631. }
  632. });
  633. const Badge = withInstall(stdin_default$1T);
  634. let globalZIndex = 2e3;
  635. const useGlobalZIndex = () => ++globalZIndex;
  636. const setGlobalZIndex = (val) => {
  637. globalZIndex = val;
  638. };
  639. const [name$1I, bem$1D] = createNamespace("config-provider");
  640. const CONFIG_PROVIDER_KEY = Symbol(name$1I);
  641. const configProviderProps = {
  642. tag: makeStringProp("div"),
  643. theme: makeStringProp("light"),
  644. zIndex: Number,
  645. themeVars: Object,
  646. themeVarsDark: Object,
  647. themeVarsLight: Object,
  648. themeVarsScope: makeStringProp("local"),
  649. iconPrefix: String
  650. };
  651. function insertDash(str) {
  652. return str.replace(/([a-zA-Z])(\d)/g, "$1-$2");
  653. }
  654. function mapThemeVarsToCSSVars(themeVars) {
  655. const cssVars = {};
  656. Object.keys(themeVars).forEach((key) => {
  657. const formattedKey = insertDash(kebabCase(key));
  658. cssVars[`--van-${formattedKey}`] = themeVars[key];
  659. });
  660. return cssVars;
  661. }
  662. function syncThemeVarsOnRoot(newStyle = {}, oldStyle = {}) {
  663. Object.keys(newStyle).forEach((key) => {
  664. if (newStyle[key] !== oldStyle[key]) {
  665. document.documentElement.style.setProperty(key, newStyle[key]);
  666. }
  667. });
  668. Object.keys(oldStyle).forEach((key) => {
  669. if (!newStyle[key]) {
  670. document.documentElement.style.removeProperty(key);
  671. }
  672. });
  673. }
  674. var stdin_default$1S = defineComponent({
  675. name: name$1I,
  676. props: configProviderProps,
  677. setup(props2, {
  678. slots
  679. }) {
  680. const style = computed(() => mapThemeVarsToCSSVars(extend({}, props2.themeVars, props2.theme === "dark" ? props2.themeVarsDark : props2.themeVarsLight)));
  681. if (inBrowser) {
  682. const addTheme = () => {
  683. document.documentElement.classList.add(`van-theme-${props2.theme}`);
  684. };
  685. const removeTheme = (theme = props2.theme) => {
  686. document.documentElement.classList.remove(`van-theme-${theme}`);
  687. };
  688. watch(() => props2.theme, (newVal, oldVal) => {
  689. if (oldVal) {
  690. removeTheme(oldVal);
  691. }
  692. addTheme();
  693. }, {
  694. immediate: true
  695. });
  696. onActivated(addTheme);
  697. onDeactivated(removeTheme);
  698. onBeforeUnmount(removeTheme);
  699. watch(style, (newStyle, oldStyle) => {
  700. if (props2.themeVarsScope === "global") {
  701. syncThemeVarsOnRoot(newStyle, oldStyle);
  702. }
  703. });
  704. watch(() => props2.themeVarsScope, (newScope, oldScope) => {
  705. if (oldScope === "global") {
  706. syncThemeVarsOnRoot({}, style.value);
  707. }
  708. if (newScope === "global") {
  709. syncThemeVarsOnRoot(style.value, {});
  710. }
  711. });
  712. if (props2.themeVarsScope === "global") {
  713. syncThemeVarsOnRoot(style.value, {});
  714. }
  715. }
  716. provide(CONFIG_PROVIDER_KEY, props2);
  717. watchEffect(() => {
  718. if (props2.zIndex !== void 0) {
  719. setGlobalZIndex(props2.zIndex);
  720. }
  721. });
  722. return () => createVNode(props2.tag, {
  723. "class": bem$1D(),
  724. "style": props2.themeVarsScope === "local" ? style.value : void 0
  725. }, {
  726. default: () => {
  727. var _a;
  728. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  729. }
  730. });
  731. }
  732. });
  733. const [name$1H, bem$1C] = createNamespace("icon");
  734. const isImage$1 = (name2) => name2 == null ? void 0 : name2.includes("/");
  735. const iconProps = {
  736. dot: Boolean,
  737. tag: makeStringProp("i"),
  738. name: String,
  739. size: numericProp,
  740. badge: numericProp,
  741. color: String,
  742. badgeProps: Object,
  743. classPrefix: String
  744. };
  745. var stdin_default$1R = defineComponent({
  746. name: name$1H,
  747. props: iconProps,
  748. setup(props2, {
  749. slots
  750. }) {
  751. const config = inject(CONFIG_PROVIDER_KEY, null);
  752. const classPrefix = computed(() => props2.classPrefix || (config == null ? void 0 : config.iconPrefix) || bem$1C());
  753. return () => {
  754. const {
  755. tag,
  756. dot,
  757. name: name2,
  758. size,
  759. badge,
  760. color
  761. } = props2;
  762. const isImageIcon = isImage$1(name2);
  763. return createVNode(Badge, mergeProps({
  764. "dot": dot,
  765. "tag": tag,
  766. "class": [classPrefix.value, isImageIcon ? "" : `${classPrefix.value}-${name2}`],
  767. "style": {
  768. color,
  769. fontSize: addUnit(size)
  770. },
  771. "content": badge
  772. }, props2.badgeProps), {
  773. default: () => {
  774. var _a;
  775. return [(_a = slots.default) == null ? void 0 : _a.call(slots), isImageIcon && createVNode("img", {
  776. "class": bem$1C("image"),
  777. "src": name2
  778. }, null)];
  779. }
  780. });
  781. };
  782. }
  783. });
  784. const Icon = withInstall(stdin_default$1R);
  785. var stdin_default$1Q = Icon;
  786. const [name$1G, bem$1B] = createNamespace("loading");
  787. const SpinIcon = Array(12).fill(null).map((_, index) => createVNode("i", {
  788. "class": bem$1B("line", String(index + 1))
  789. }, null));
  790. const CircularIcon = createVNode("svg", {
  791. "class": bem$1B("circular"),
  792. "viewBox": "25 25 50 50"
  793. }, [createVNode("circle", {
  794. "cx": "50",
  795. "cy": "50",
  796. "r": "20",
  797. "fill": "none"
  798. }, null)]);
  799. const loadingProps = {
  800. size: numericProp,
  801. type: makeStringProp("circular"),
  802. color: String,
  803. vertical: Boolean,
  804. textSize: numericProp,
  805. textColor: String
  806. };
  807. var stdin_default$1P = defineComponent({
  808. name: name$1G,
  809. props: loadingProps,
  810. setup(props2, {
  811. slots
  812. }) {
  813. const spinnerStyle = computed(() => extend({
  814. color: props2.color
  815. }, getSizeStyle(props2.size)));
  816. const renderIcon = () => {
  817. const DefaultIcon = props2.type === "spinner" ? SpinIcon : CircularIcon;
  818. return createVNode("span", {
  819. "class": bem$1B("spinner", props2.type),
  820. "style": spinnerStyle.value
  821. }, [slots.icon ? slots.icon() : DefaultIcon]);
  822. };
  823. const renderText = () => {
  824. var _a;
  825. if (slots.default) {
  826. return createVNode("span", {
  827. "class": bem$1B("text"),
  828. "style": {
  829. fontSize: addUnit(props2.textSize),
  830. color: (_a = props2.textColor) != null ? _a : props2.color
  831. }
  832. }, [slots.default()]);
  833. }
  834. };
  835. return () => {
  836. const {
  837. type,
  838. vertical
  839. } = props2;
  840. return createVNode("div", {
  841. "class": bem$1B([type, {
  842. vertical
  843. }]),
  844. "aria-live": "polite",
  845. "aria-busy": true
  846. }, [renderIcon(), renderText()]);
  847. };
  848. }
  849. });
  850. const Loading = withInstall(stdin_default$1P);
  851. const [name$1F, bem$1A] = createNamespace("button");
  852. const buttonProps = extend({}, routeProps, {
  853. tag: makeStringProp("button"),
  854. text: String,
  855. icon: String,
  856. type: makeStringProp("default"),
  857. size: makeStringProp("normal"),
  858. color: String,
  859. block: Boolean,
  860. plain: Boolean,
  861. round: Boolean,
  862. square: Boolean,
  863. loading: Boolean,
  864. hairline: Boolean,
  865. disabled: Boolean,
  866. iconPrefix: String,
  867. nativeType: makeStringProp("button"),
  868. loadingSize: numericProp,
  869. loadingText: String,
  870. loadingType: String,
  871. iconPosition: makeStringProp("left")
  872. });
  873. var stdin_default$1O = defineComponent({
  874. name: name$1F,
  875. props: buttonProps,
  876. emits: ["click"],
  877. setup(props2, {
  878. emit,
  879. slots
  880. }) {
  881. const route2 = useRoute();
  882. const renderLoadingIcon = () => {
  883. if (slots.loading) {
  884. return slots.loading();
  885. }
  886. return createVNode(Loading, {
  887. "size": props2.loadingSize,
  888. "type": props2.loadingType,
  889. "class": bem$1A("loading")
  890. }, null);
  891. };
  892. const renderIcon = () => {
  893. if (props2.loading) {
  894. return renderLoadingIcon();
  895. }
  896. if (slots.icon) {
  897. return createVNode("div", {
  898. "class": bem$1A("icon")
  899. }, [slots.icon()]);
  900. }
  901. if (props2.icon) {
  902. return createVNode(Icon, {
  903. "name": props2.icon,
  904. "class": bem$1A("icon"),
  905. "classPrefix": props2.iconPrefix
  906. }, null);
  907. }
  908. };
  909. const renderText = () => {
  910. let text;
  911. if (props2.loading) {
  912. text = props2.loadingText;
  913. } else {
  914. text = slots.default ? slots.default() : props2.text;
  915. }
  916. if (text) {
  917. return createVNode("span", {
  918. "class": bem$1A("text")
  919. }, [text]);
  920. }
  921. };
  922. const getStyle = () => {
  923. const {
  924. color,
  925. plain
  926. } = props2;
  927. if (color) {
  928. const style = {
  929. color: plain ? color : "white"
  930. };
  931. if (!plain) {
  932. style.background = color;
  933. }
  934. if (color.includes("gradient")) {
  935. style.border = 0;
  936. } else {
  937. style.borderColor = color;
  938. }
  939. return style;
  940. }
  941. };
  942. const onClick = (event) => {
  943. if (props2.loading) {
  944. preventDefault(event);
  945. } else if (!props2.disabled) {
  946. emit("click", event);
  947. route2();
  948. }
  949. };
  950. return () => {
  951. const {
  952. tag,
  953. type,
  954. size,
  955. block,
  956. round,
  957. plain,
  958. square,
  959. loading,
  960. disabled,
  961. hairline,
  962. nativeType,
  963. iconPosition
  964. } = props2;
  965. const classes = [bem$1A([type, size, {
  966. plain,
  967. block,
  968. round,
  969. square,
  970. loading,
  971. disabled,
  972. hairline
  973. }]), {
  974. [BORDER_SURROUND]: hairline
  975. }];
  976. return createVNode(tag, {
  977. "type": nativeType,
  978. "class": classes,
  979. "style": getStyle(),
  980. "disabled": disabled,
  981. "onClick": onClick
  982. }, {
  983. default: () => [createVNode("div", {
  984. "class": bem$1A("content")
  985. }, [iconPosition === "left" && renderIcon(), renderText(), iconPosition === "right" && renderIcon()])]
  986. });
  987. };
  988. }
  989. });
  990. const Button = withInstall(stdin_default$1O);
  991. const [name$1E, bem$1z] = createNamespace("action-bar-button");
  992. const actionBarButtonProps = extend({}, routeProps, {
  993. type: String,
  994. text: String,
  995. icon: String,
  996. color: String,
  997. loading: Boolean,
  998. disabled: Boolean
  999. });
  1000. var stdin_default$1N = defineComponent({
  1001. name: name$1E,
  1002. props: actionBarButtonProps,
  1003. setup(props2, {
  1004. slots
  1005. }) {
  1006. const route2 = useRoute();
  1007. const {
  1008. parent,
  1009. index
  1010. } = useParent(ACTION_BAR_KEY);
  1011. const isFirst = computed(() => {
  1012. if (parent) {
  1013. const prev = parent.children[index.value - 1];
  1014. return !(prev && "isButton" in prev);
  1015. }
  1016. });
  1017. const isLast = computed(() => {
  1018. if (parent) {
  1019. const next = parent.children[index.value + 1];
  1020. return !(next && "isButton" in next);
  1021. }
  1022. });
  1023. useExpose({
  1024. isButton: true
  1025. });
  1026. return () => {
  1027. const {
  1028. type,
  1029. icon,
  1030. text,
  1031. color,
  1032. loading,
  1033. disabled
  1034. } = props2;
  1035. return createVNode(Button, {
  1036. "class": bem$1z([type, {
  1037. last: isLast.value,
  1038. first: isFirst.value
  1039. }]),
  1040. "size": "large",
  1041. "type": type,
  1042. "icon": icon,
  1043. "color": color,
  1044. "loading": loading,
  1045. "disabled": disabled,
  1046. "onClick": route2
  1047. }, {
  1048. default: () => [slots.default ? slots.default() : text]
  1049. });
  1050. };
  1051. }
  1052. });
  1053. const ActionBarButton = withInstall(stdin_default$1N);
  1054. const [name$1D, bem$1y] = createNamespace("action-bar-icon");
  1055. const actionBarIconProps = extend({}, routeProps, {
  1056. dot: Boolean,
  1057. text: String,
  1058. icon: String,
  1059. color: String,
  1060. badge: numericProp,
  1061. iconClass: unknownProp,
  1062. badgeProps: Object,
  1063. iconPrefix: String
  1064. });
  1065. var stdin_default$1M = defineComponent({
  1066. name: name$1D,
  1067. props: actionBarIconProps,
  1068. setup(props2, {
  1069. slots
  1070. }) {
  1071. const route2 = useRoute();
  1072. useParent(ACTION_BAR_KEY);
  1073. const renderIcon = () => {
  1074. const {
  1075. dot,
  1076. badge,
  1077. icon,
  1078. color,
  1079. iconClass,
  1080. badgeProps: badgeProps2,
  1081. iconPrefix
  1082. } = props2;
  1083. if (slots.icon) {
  1084. return createVNode(Badge, mergeProps({
  1085. "dot": dot,
  1086. "class": bem$1y("icon"),
  1087. "content": badge
  1088. }, badgeProps2), {
  1089. default: slots.icon
  1090. });
  1091. }
  1092. return createVNode(Icon, {
  1093. "tag": "div",
  1094. "dot": dot,
  1095. "name": icon,
  1096. "badge": badge,
  1097. "color": color,
  1098. "class": [bem$1y("icon"), iconClass],
  1099. "badgeProps": badgeProps2,
  1100. "classPrefix": iconPrefix
  1101. }, null);
  1102. };
  1103. return () => createVNode("div", {
  1104. "role": "button",
  1105. "class": bem$1y(),
  1106. "tabindex": 0,
  1107. "onClick": route2
  1108. }, [renderIcon(), slots.default ? slots.default() : props2.text]);
  1109. }
  1110. });
  1111. const ActionBarIcon = withInstall(stdin_default$1M);
  1112. const popupSharedProps = {
  1113. // whether to show popup
  1114. show: Boolean,
  1115. // z-index
  1116. zIndex: numericProp,
  1117. // whether to show overlay
  1118. overlay: truthProp,
  1119. // transition duration
  1120. duration: numericProp,
  1121. // teleport
  1122. teleport: [String, Object],
  1123. // prevent body scroll
  1124. lockScroll: truthProp,
  1125. // whether to lazy render
  1126. lazyRender: truthProp,
  1127. // callback function before close
  1128. beforeClose: Function,
  1129. // overlay custom style
  1130. overlayStyle: Object,
  1131. // overlay custom class name
  1132. overlayClass: unknownProp,
  1133. // Initial rendering animation
  1134. transitionAppear: Boolean,
  1135. // whether to close popup when overlay is clicked
  1136. closeOnClickOverlay: truthProp
  1137. };
  1138. const popupSharedPropKeys = Object.keys(
  1139. popupSharedProps
  1140. );
  1141. function getDirection(x, y) {
  1142. if (x > y) {
  1143. return "horizontal";
  1144. }
  1145. if (y > x) {
  1146. return "vertical";
  1147. }
  1148. return "";
  1149. }
  1150. function useTouch() {
  1151. const startX = ref(0);
  1152. const startY = ref(0);
  1153. const deltaX = ref(0);
  1154. const deltaY = ref(0);
  1155. const offsetX = ref(0);
  1156. const offsetY = ref(0);
  1157. const direction = ref("");
  1158. const isTap = ref(true);
  1159. const isVertical = () => direction.value === "vertical";
  1160. const isHorizontal = () => direction.value === "horizontal";
  1161. const reset = () => {
  1162. deltaX.value = 0;
  1163. deltaY.value = 0;
  1164. offsetX.value = 0;
  1165. offsetY.value = 0;
  1166. direction.value = "";
  1167. isTap.value = true;
  1168. };
  1169. const start = (event) => {
  1170. reset();
  1171. startX.value = event.touches[0].clientX;
  1172. startY.value = event.touches[0].clientY;
  1173. };
  1174. const move = (event) => {
  1175. const touch = event.touches[0];
  1176. deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
  1177. deltaY.value = touch.clientY - startY.value;
  1178. offsetX.value = Math.abs(deltaX.value);
  1179. offsetY.value = Math.abs(deltaY.value);
  1180. const LOCK_DIRECTION_DISTANCE = 10;
  1181. if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
  1182. direction.value = getDirection(offsetX.value, offsetY.value);
  1183. }
  1184. if (isTap.value && (offsetX.value > TAP_OFFSET || offsetY.value > TAP_OFFSET)) {
  1185. isTap.value = false;
  1186. }
  1187. };
  1188. return {
  1189. move,
  1190. start,
  1191. reset,
  1192. startX,
  1193. startY,
  1194. deltaX,
  1195. deltaY,
  1196. offsetX,
  1197. offsetY,
  1198. direction,
  1199. isVertical,
  1200. isHorizontal,
  1201. isTap
  1202. };
  1203. }
  1204. let totalLockCount = 0;
  1205. const BODY_LOCK_CLASS = "van-overflow-hidden";
  1206. function useLockScroll(rootRef, shouldLock) {
  1207. const touch = useTouch();
  1208. const DIRECTION_UP = "01";
  1209. const DIRECTION_DOWN = "10";
  1210. const onTouchMove = (event) => {
  1211. touch.move(event);
  1212. const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
  1213. const el = getScrollParent(
  1214. event.target,
  1215. rootRef.value
  1216. );
  1217. const { scrollHeight, offsetHeight, scrollTop } = el;
  1218. let status = "11";
  1219. if (scrollTop === 0) {
  1220. status = offsetHeight >= scrollHeight ? "00" : "01";
  1221. } else if (scrollTop + offsetHeight >= scrollHeight) {
  1222. status = "10";
  1223. }
  1224. if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
  1225. preventDefault(event, true);
  1226. }
  1227. };
  1228. const lock = () => {
  1229. document.addEventListener("touchstart", touch.start);
  1230. document.addEventListener("touchmove", onTouchMove, { passive: false });
  1231. if (!totalLockCount) {
  1232. document.body.classList.add(BODY_LOCK_CLASS);
  1233. }
  1234. totalLockCount++;
  1235. };
  1236. const unlock = () => {
  1237. if (totalLockCount) {
  1238. document.removeEventListener("touchstart", touch.start);
  1239. document.removeEventListener("touchmove", onTouchMove);
  1240. totalLockCount--;
  1241. if (!totalLockCount) {
  1242. document.body.classList.remove(BODY_LOCK_CLASS);
  1243. }
  1244. }
  1245. };
  1246. const init = () => shouldLock() && lock();
  1247. const destroy = () => shouldLock() && unlock();
  1248. onMountedOrActivated(init);
  1249. onDeactivated(destroy);
  1250. onBeforeUnmount(destroy);
  1251. watch(shouldLock, (value) => {
  1252. value ? lock() : unlock();
  1253. });
  1254. }
  1255. function useLazyRender(show) {
  1256. const inited = ref(false);
  1257. watch(
  1258. show,
  1259. (value) => {
  1260. if (value) {
  1261. inited.value = value;
  1262. }
  1263. },
  1264. { immediate: true }
  1265. );
  1266. return (render) => () => inited.value ? render() : null;
  1267. }
  1268. const useScopeId = () => {
  1269. var _a;
  1270. const { scopeId } = ((_a = getCurrentInstance()) == null ? void 0 : _a.vnode) || {};
  1271. return scopeId ? { [scopeId]: "" } : null;
  1272. };
  1273. const [name$1C, bem$1x] = createNamespace("overlay");
  1274. const overlayProps = {
  1275. show: Boolean,
  1276. zIndex: numericProp,
  1277. duration: numericProp,
  1278. className: unknownProp,
  1279. lockScroll: truthProp,
  1280. lazyRender: truthProp,
  1281. customStyle: Object,
  1282. teleport: [String, Object]
  1283. };
  1284. var stdin_default$1L = defineComponent({
  1285. name: name$1C,
  1286. props: overlayProps,
  1287. setup(props2, {
  1288. slots
  1289. }) {
  1290. const root = ref();
  1291. const lazyRender = useLazyRender(() => props2.show || !props2.lazyRender);
  1292. const onTouchMove = (event) => {
  1293. if (props2.lockScroll) {
  1294. preventDefault(event, true);
  1295. }
  1296. };
  1297. const renderOverlay = lazyRender(() => {
  1298. var _a;
  1299. const style = extend(getZIndexStyle(props2.zIndex), props2.customStyle);
  1300. if (isDef(props2.duration)) {
  1301. style.animationDuration = `${props2.duration}s`;
  1302. }
  1303. return withDirectives(createVNode("div", {
  1304. "ref": root,
  1305. "style": style,
  1306. "class": [bem$1x(), props2.className]
  1307. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[vShow, props2.show]]);
  1308. });
  1309. useEventListener("touchmove", onTouchMove, {
  1310. target: root
  1311. });
  1312. return () => {
  1313. const Content = createVNode(Transition, {
  1314. "name": "van-fade",
  1315. "appear": true
  1316. }, {
  1317. default: renderOverlay
  1318. });
  1319. if (props2.teleport) {
  1320. return createVNode(Teleport, {
  1321. "to": props2.teleport
  1322. }, {
  1323. default: () => [Content]
  1324. });
  1325. }
  1326. return Content;
  1327. };
  1328. }
  1329. });
  1330. const Overlay = withInstall(stdin_default$1L);
  1331. const popupProps$2 = extend({}, popupSharedProps, {
  1332. round: Boolean,
  1333. position: makeStringProp("center"),
  1334. closeIcon: makeStringProp("cross"),
  1335. closeable: Boolean,
  1336. transition: String,
  1337. iconPrefix: String,
  1338. closeOnPopstate: Boolean,
  1339. closeIconPosition: makeStringProp("top-right"),
  1340. safeAreaInsetTop: Boolean,
  1341. safeAreaInsetBottom: Boolean
  1342. });
  1343. const [name$1B, bem$1w] = createNamespace("popup");
  1344. var stdin_default$1K = defineComponent({
  1345. name: name$1B,
  1346. inheritAttrs: false,
  1347. props: popupProps$2,
  1348. emits: ["open", "close", "opened", "closed", "keydown", "update:show", "clickOverlay", "clickCloseIcon"],
  1349. setup(props2, {
  1350. emit,
  1351. attrs,
  1352. slots
  1353. }) {
  1354. let opened;
  1355. let shouldReopen;
  1356. const zIndex = ref();
  1357. const popupRef = ref();
  1358. const lazyRender = useLazyRender(() => props2.show || !props2.lazyRender);
  1359. const style = computed(() => {
  1360. const style2 = {
  1361. zIndex: zIndex.value
  1362. };
  1363. if (isDef(props2.duration)) {
  1364. const key = props2.position === "center" ? "animationDuration" : "transitionDuration";
  1365. style2[key] = `${props2.duration}s`;
  1366. }
  1367. return style2;
  1368. });
  1369. const open = () => {
  1370. if (!opened) {
  1371. opened = true;
  1372. zIndex.value = props2.zIndex !== void 0 ? +props2.zIndex : useGlobalZIndex();
  1373. emit("open");
  1374. }
  1375. };
  1376. const close = () => {
  1377. if (opened) {
  1378. callInterceptor(props2.beforeClose, {
  1379. done() {
  1380. opened = false;
  1381. emit("close");
  1382. emit("update:show", false);
  1383. }
  1384. });
  1385. }
  1386. };
  1387. const onClickOverlay = (event) => {
  1388. emit("clickOverlay", event);
  1389. if (props2.closeOnClickOverlay) {
  1390. close();
  1391. }
  1392. };
  1393. const renderOverlay = () => {
  1394. if (props2.overlay) {
  1395. return createVNode(Overlay, mergeProps({
  1396. "show": props2.show,
  1397. "class": props2.overlayClass,
  1398. "zIndex": zIndex.value,
  1399. "duration": props2.duration,
  1400. "customStyle": props2.overlayStyle,
  1401. "role": props2.closeOnClickOverlay ? "button" : void 0,
  1402. "tabindex": props2.closeOnClickOverlay ? 0 : void 0
  1403. }, useScopeId(), {
  1404. "onClick": onClickOverlay
  1405. }), {
  1406. default: slots["overlay-content"]
  1407. });
  1408. }
  1409. };
  1410. const onClickCloseIcon = (event) => {
  1411. emit("clickCloseIcon", event);
  1412. close();
  1413. };
  1414. const renderCloseIcon = () => {
  1415. if (props2.closeable) {
  1416. return createVNode(Icon, {
  1417. "role": "button",
  1418. "tabindex": 0,
  1419. "name": props2.closeIcon,
  1420. "class": [bem$1w("close-icon", props2.closeIconPosition), HAPTICS_FEEDBACK],
  1421. "classPrefix": props2.iconPrefix,
  1422. "onClick": onClickCloseIcon
  1423. }, null);
  1424. }
  1425. };
  1426. let timer2;
  1427. const onOpened = () => {
  1428. if (timer2) clearTimeout(timer2);
  1429. timer2 = setTimeout(() => {
  1430. emit("opened");
  1431. });
  1432. };
  1433. const onClosed = () => emit("closed");
  1434. const onKeydown = (event) => emit("keydown", event);
  1435. const renderPopup = lazyRender(() => {
  1436. var _a;
  1437. const {
  1438. round,
  1439. position,
  1440. safeAreaInsetTop,
  1441. safeAreaInsetBottom
  1442. } = props2;
  1443. return withDirectives(createVNode("div", mergeProps({
  1444. "ref": popupRef,
  1445. "style": style.value,
  1446. "role": "dialog",
  1447. "tabindex": 0,
  1448. "class": [bem$1w({
  1449. round,
  1450. [position]: position
  1451. }), {
  1452. "van-safe-area-top": safeAreaInsetTop,
  1453. "van-safe-area-bottom": safeAreaInsetBottom
  1454. }],
  1455. "onKeydown": onKeydown
  1456. }, attrs, useScopeId()), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[vShow, props2.show]]);
  1457. });
  1458. const renderTransition = () => {
  1459. const {
  1460. position,
  1461. transition,
  1462. transitionAppear
  1463. } = props2;
  1464. const name2 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
  1465. return createVNode(Transition, {
  1466. "name": transition || name2,
  1467. "appear": transitionAppear,
  1468. "onAfterEnter": onOpened,
  1469. "onAfterLeave": onClosed
  1470. }, {
  1471. default: renderPopup
  1472. });
  1473. };
  1474. watch(() => props2.show, (show) => {
  1475. if (show && !opened) {
  1476. open();
  1477. if (attrs.tabindex === 0) {
  1478. nextTick(() => {
  1479. var _a;
  1480. (_a = popupRef.value) == null ? void 0 : _a.focus();
  1481. });
  1482. }
  1483. }
  1484. if (!show && opened) {
  1485. opened = false;
  1486. emit("close");
  1487. }
  1488. });
  1489. useExpose({
  1490. popupRef
  1491. });
  1492. useLockScroll(popupRef, () => props2.show && props2.lockScroll);
  1493. useEventListener("popstate", () => {
  1494. if (props2.closeOnPopstate) {
  1495. close();
  1496. shouldReopen = false;
  1497. }
  1498. });
  1499. onMounted(() => {
  1500. if (props2.show) {
  1501. open();
  1502. }
  1503. });
  1504. onActivated(() => {
  1505. if (shouldReopen) {
  1506. emit("update:show", true);
  1507. shouldReopen = false;
  1508. }
  1509. });
  1510. onDeactivated(() => {
  1511. if (props2.show && props2.teleport) {
  1512. close();
  1513. shouldReopen = true;
  1514. }
  1515. });
  1516. provide(POPUP_TOGGLE_KEY, () => props2.show);
  1517. return () => {
  1518. if (props2.teleport) {
  1519. return createVNode(Teleport, {
  1520. "to": props2.teleport
  1521. }, {
  1522. default: () => [renderOverlay(), renderTransition()]
  1523. });
  1524. }
  1525. return createVNode(Fragment, null, [renderOverlay(), renderTransition()]);
  1526. };
  1527. }
  1528. });
  1529. const Popup = withInstall(stdin_default$1K);
  1530. const [name$1A, bem$1v] = createNamespace("action-sheet");
  1531. const actionSheetProps = extend({}, popupSharedProps, {
  1532. title: String,
  1533. round: truthProp,
  1534. actions: makeArrayProp(),
  1535. closeIcon: makeStringProp("cross"),
  1536. closeable: truthProp,
  1537. cancelText: String,
  1538. description: String,
  1539. closeOnPopstate: truthProp,
  1540. closeOnClickAction: Boolean,
  1541. safeAreaInsetBottom: truthProp
  1542. });
  1543. const popupInheritKeys$2 = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  1544. var stdin_default$1J = defineComponent({
  1545. name: name$1A,
  1546. props: actionSheetProps,
  1547. emits: ["select", "cancel", "update:show"],
  1548. setup(props2, {
  1549. slots,
  1550. emit
  1551. }) {
  1552. const updateShow = (show) => emit("update:show", show);
  1553. const onCancel = () => {
  1554. updateShow(false);
  1555. emit("cancel");
  1556. };
  1557. const renderHeader = () => {
  1558. if (props2.title) {
  1559. return createVNode("div", {
  1560. "class": bem$1v("header")
  1561. }, [props2.title, props2.closeable && createVNode(Icon, {
  1562. "name": props2.closeIcon,
  1563. "class": [bem$1v("close"), HAPTICS_FEEDBACK],
  1564. "onClick": onCancel
  1565. }, null)]);
  1566. }
  1567. };
  1568. const renderCancel = () => {
  1569. if (slots.cancel || props2.cancelText) {
  1570. return [createVNode("div", {
  1571. "class": bem$1v("gap")
  1572. }, null), createVNode("button", {
  1573. "type": "button",
  1574. "class": bem$1v("cancel"),
  1575. "onClick": onCancel
  1576. }, [slots.cancel ? slots.cancel() : props2.cancelText])];
  1577. }
  1578. };
  1579. const renderIcon = (action) => {
  1580. if (action.icon) {
  1581. return createVNode(Icon, {
  1582. "class": bem$1v("item-icon"),
  1583. "name": action.icon
  1584. }, null);
  1585. }
  1586. };
  1587. const renderActionContent = (action, index) => {
  1588. if (action.loading) {
  1589. return createVNode(Loading, {
  1590. "class": bem$1v("loading-icon")
  1591. }, null);
  1592. }
  1593. if (slots.action) {
  1594. return slots.action({
  1595. action,
  1596. index
  1597. });
  1598. }
  1599. return [createVNode("span", {
  1600. "class": bem$1v("name")
  1601. }, [action.name]), action.subname && createVNode("div", {
  1602. "class": bem$1v("subname")
  1603. }, [action.subname])];
  1604. };
  1605. const renderAction = (action, index) => {
  1606. const {
  1607. color,
  1608. loading,
  1609. callback,
  1610. disabled,
  1611. className
  1612. } = action;
  1613. const onClick = () => {
  1614. if (disabled || loading) {
  1615. return;
  1616. }
  1617. if (callback) {
  1618. callback(action);
  1619. }
  1620. if (props2.closeOnClickAction) {
  1621. updateShow(false);
  1622. }
  1623. nextTick(() => emit("select", action, index));
  1624. };
  1625. return createVNode("button", {
  1626. "type": "button",
  1627. "style": {
  1628. color
  1629. },
  1630. "class": [bem$1v("item", {
  1631. loading,
  1632. disabled
  1633. }), className],
  1634. "onClick": onClick
  1635. }, [renderIcon(action), renderActionContent(action, index)]);
  1636. };
  1637. const renderDescription = () => {
  1638. if (props2.description || slots.description) {
  1639. const content = slots.description ? slots.description() : props2.description;
  1640. return createVNode("div", {
  1641. "class": bem$1v("description")
  1642. }, [content]);
  1643. }
  1644. };
  1645. return () => createVNode(Popup, mergeProps({
  1646. "class": bem$1v(),
  1647. "position": "bottom",
  1648. "onUpdate:show": updateShow
  1649. }, pick(props2, popupInheritKeys$2)), {
  1650. default: () => {
  1651. var _a;
  1652. return [renderHeader(), renderDescription(), createVNode("div", {
  1653. "class": bem$1v("content")
  1654. }, [props2.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
  1655. }
  1656. });
  1657. }
  1658. });
  1659. const ActionSheet = withInstall(stdin_default$1J);
  1660. const [name$1z, bem$1u, t$k] = createNamespace("picker");
  1661. const getFirstEnabledOption = (options) => options.find((option) => !option.disabled) || options[0];
  1662. function getColumnsType(columns, fields) {
  1663. const firstColumn = columns[0];
  1664. if (firstColumn) {
  1665. if (Array.isArray(firstColumn)) {
  1666. return "multiple";
  1667. }
  1668. if (fields.children in firstColumn) {
  1669. return "cascade";
  1670. }
  1671. }
  1672. return "default";
  1673. }
  1674. function findIndexOfEnabledOption(options, index) {
  1675. index = clamp(index, 0, options.length);
  1676. for (let i = index; i < options.length; i++) {
  1677. if (!options[i].disabled) return i;
  1678. }
  1679. for (let i = index - 1; i >= 0; i--) {
  1680. if (!options[i].disabled) return i;
  1681. }
  1682. return 0;
  1683. }
  1684. const isOptionExist = (options, value, fields) => value !== void 0 && !!options.find((option) => option[fields.value] === value);
  1685. function findOptionByValue(options, value, fields) {
  1686. const index = options.findIndex((option) => option[fields.value] === value);
  1687. const enabledIndex = findIndexOfEnabledOption(options, index);
  1688. return options[enabledIndex];
  1689. }
  1690. function formatCascadeColumns(columns, fields, selectedValues) {
  1691. const formatted = [];
  1692. let cursor = {
  1693. [fields.children]: columns
  1694. };
  1695. let columnIndex = 0;
  1696. while (cursor && cursor[fields.children]) {
  1697. const options = cursor[fields.children];
  1698. const value = selectedValues.value[columnIndex];
  1699. cursor = isDef(value) ? findOptionByValue(options, value, fields) : void 0;
  1700. if (!cursor && options.length) {
  1701. const firstValue = getFirstEnabledOption(options)[fields.value];
  1702. cursor = findOptionByValue(options, firstValue, fields);
  1703. }
  1704. columnIndex++;
  1705. formatted.push(options);
  1706. }
  1707. return formatted;
  1708. }
  1709. function getElementTranslateY(element) {
  1710. const { transform } = window.getComputedStyle(element);
  1711. const translateY = transform.slice(7, transform.length - 1).split(", ")[5];
  1712. return Number(translateY);
  1713. }
  1714. function assignDefaultFields(fields) {
  1715. return extend(
  1716. {
  1717. text: "text",
  1718. value: "value",
  1719. children: "children"
  1720. },
  1721. fields
  1722. );
  1723. }
  1724. const DEFAULT_DURATION = 200;
  1725. const MOMENTUM_TIME = 300;
  1726. const MOMENTUM_DISTANCE = 15;
  1727. const [name$1y, bem$1t] = createNamespace("picker-column");
  1728. const PICKER_KEY = Symbol(name$1y);
  1729. var stdin_default$1I = defineComponent({
  1730. name: name$1y,
  1731. props: {
  1732. value: numericProp,
  1733. fields: makeRequiredProp(Object),
  1734. options: makeArrayProp(),
  1735. readonly: Boolean,
  1736. allowHtml: Boolean,
  1737. optionHeight: makeRequiredProp(Number),
  1738. swipeDuration: makeRequiredProp(numericProp),
  1739. visibleOptionNum: makeRequiredProp(numericProp)
  1740. },
  1741. emits: ["change", "clickOption", "scrollInto"],
  1742. setup(props2, {
  1743. emit,
  1744. slots
  1745. }) {
  1746. let moving;
  1747. let startOffset;
  1748. let touchStartTime;
  1749. let momentumOffset;
  1750. let transitionEndTrigger;
  1751. const root = ref();
  1752. const wrapper = ref();
  1753. const currentOffset = ref(0);
  1754. const currentDuration = ref(0);
  1755. const touch = useTouch();
  1756. const count = () => props2.options.length;
  1757. const baseOffset = () => props2.optionHeight * (+props2.visibleOptionNum - 1) / 2;
  1758. const updateValueByIndex = (index) => {
  1759. let enabledIndex = findIndexOfEnabledOption(props2.options, index);
  1760. const offset = -enabledIndex * props2.optionHeight;
  1761. const trigger = () => {
  1762. if (enabledIndex > count() - 1) {
  1763. enabledIndex = findIndexOfEnabledOption(props2.options, index);
  1764. }
  1765. const value = props2.options[enabledIndex][props2.fields.value];
  1766. if (value !== props2.value) {
  1767. emit("change", value);
  1768. }
  1769. };
  1770. if (moving && offset !== currentOffset.value) {
  1771. transitionEndTrigger = trigger;
  1772. } else {
  1773. trigger();
  1774. }
  1775. currentOffset.value = offset;
  1776. };
  1777. const isReadonly = () => props2.readonly || !props2.options.length;
  1778. const onClickOption = (index) => {
  1779. if (moving || isReadonly()) {
  1780. return;
  1781. }
  1782. transitionEndTrigger = null;
  1783. currentDuration.value = DEFAULT_DURATION;
  1784. updateValueByIndex(index);
  1785. emit("clickOption", props2.options[index]);
  1786. };
  1787. const getIndexByOffset = (offset) => clamp(Math.round(-offset / props2.optionHeight), 0, count() - 1);
  1788. const currentIndex = computed(() => getIndexByOffset(currentOffset.value));
  1789. const momentum = (distance, duration) => {
  1790. const speed = Math.abs(distance / duration);
  1791. distance = currentOffset.value + speed / 3e-3 * (distance < 0 ? -1 : 1);
  1792. const index = getIndexByOffset(distance);
  1793. currentDuration.value = +props2.swipeDuration;
  1794. updateValueByIndex(index);
  1795. };
  1796. const stopMomentum = () => {
  1797. moving = false;
  1798. currentDuration.value = 0;
  1799. if (transitionEndTrigger) {
  1800. transitionEndTrigger();
  1801. transitionEndTrigger = null;
  1802. }
  1803. };
  1804. const onTouchStart = (event) => {
  1805. if (isReadonly()) {
  1806. return;
  1807. }
  1808. touch.start(event);
  1809. if (moving) {
  1810. const translateY = getElementTranslateY(wrapper.value);
  1811. currentOffset.value = Math.min(0, translateY - baseOffset());
  1812. }
  1813. currentDuration.value = 0;
  1814. startOffset = currentOffset.value;
  1815. touchStartTime = Date.now();
  1816. momentumOffset = startOffset;
  1817. transitionEndTrigger = null;
  1818. };
  1819. const onTouchMove = (event) => {
  1820. if (isReadonly()) {
  1821. return;
  1822. }
  1823. touch.move(event);
  1824. if (touch.isVertical()) {
  1825. moving = true;
  1826. preventDefault(event, true);
  1827. }
  1828. const newOffset = clamp(startOffset + touch.deltaY.value, -(count() * props2.optionHeight), props2.optionHeight);
  1829. const newIndex = getIndexByOffset(newOffset);
  1830. if (newIndex !== currentIndex.value) {
  1831. emit("scrollInto", props2.options[newIndex]);
  1832. }
  1833. currentOffset.value = newOffset;
  1834. const now = Date.now();
  1835. if (now - touchStartTime > MOMENTUM_TIME) {
  1836. touchStartTime = now;
  1837. momentumOffset = newOffset;
  1838. }
  1839. };
  1840. const onTouchEnd = () => {
  1841. if (isReadonly()) {
  1842. return;
  1843. }
  1844. const distance = currentOffset.value - momentumOffset;
  1845. const duration = Date.now() - touchStartTime;
  1846. const startMomentum = duration < MOMENTUM_TIME && Math.abs(distance) > MOMENTUM_DISTANCE;
  1847. if (startMomentum) {
  1848. momentum(distance, duration);
  1849. return;
  1850. }
  1851. const index = getIndexByOffset(currentOffset.value);
  1852. currentDuration.value = DEFAULT_DURATION;
  1853. updateValueByIndex(index);
  1854. setTimeout(() => {
  1855. moving = false;
  1856. }, 0);
  1857. };
  1858. const renderOptions = () => {
  1859. const optionStyle = {
  1860. height: `${props2.optionHeight}px`
  1861. };
  1862. return props2.options.map((option, index) => {
  1863. const text = option[props2.fields.text];
  1864. const {
  1865. disabled
  1866. } = option;
  1867. const value = option[props2.fields.value];
  1868. const data = {
  1869. role: "button",
  1870. style: optionStyle,
  1871. tabindex: disabled ? -1 : 0,
  1872. class: [bem$1t("item", {
  1873. disabled,
  1874. selected: value === props2.value
  1875. }), option.className],
  1876. onClick: () => onClickOption(index)
  1877. };
  1878. const childData = {
  1879. class: "van-ellipsis",
  1880. [props2.allowHtml ? "innerHTML" : "textContent"]: text
  1881. };
  1882. return createVNode("li", data, [slots.option ? slots.option(option, index) : createVNode("div", childData, null)]);
  1883. });
  1884. };
  1885. useParent(PICKER_KEY);
  1886. useExpose({
  1887. stopMomentum
  1888. });
  1889. watchEffect(() => {
  1890. const index = moving ? Math.floor(-currentOffset.value / props2.optionHeight) : props2.options.findIndex((option) => option[props2.fields.value] === props2.value);
  1891. const enabledIndex = findIndexOfEnabledOption(props2.options, index);
  1892. const offset = -enabledIndex * props2.optionHeight;
  1893. if (moving && enabledIndex < index) stopMomentum();
  1894. currentOffset.value = offset;
  1895. });
  1896. useEventListener("touchmove", onTouchMove, {
  1897. target: root
  1898. });
  1899. return () => createVNode("div", {
  1900. "ref": root,
  1901. "class": bem$1t(),
  1902. "onTouchstartPassive": onTouchStart,
  1903. "onTouchend": onTouchEnd,
  1904. "onTouchcancel": onTouchEnd
  1905. }, [createVNode("ul", {
  1906. "ref": wrapper,
  1907. "style": {
  1908. transform: `translate3d(0, ${currentOffset.value + baseOffset()}px, 0)`,
  1909. transitionDuration: `${currentDuration.value}ms`,
  1910. transitionProperty: currentDuration.value ? "all" : "none"
  1911. },
  1912. "class": bem$1t("wrapper"),
  1913. "onTransitionend": stopMomentum
  1914. }, [renderOptions()])]);
  1915. }
  1916. });
  1917. const [name$1x] = createNamespace("picker-toolbar");
  1918. const pickerToolbarProps = {
  1919. title: String,
  1920. cancelButtonText: String,
  1921. confirmButtonText: String
  1922. };
  1923. const pickerToolbarSlots = ["cancel", "confirm", "title", "toolbar"];
  1924. const pickerToolbarPropKeys = Object.keys(pickerToolbarProps);
  1925. var stdin_default$1H = defineComponent({
  1926. name: name$1x,
  1927. props: pickerToolbarProps,
  1928. emits: ["confirm", "cancel"],
  1929. setup(props2, {
  1930. emit,
  1931. slots
  1932. }) {
  1933. const renderTitle = () => {
  1934. if (slots.title) {
  1935. return slots.title();
  1936. }
  1937. if (props2.title) {
  1938. return createVNode("div", {
  1939. "class": [bem$1u("title"), "van-ellipsis"]
  1940. }, [props2.title]);
  1941. }
  1942. };
  1943. const onCancel = () => emit("cancel");
  1944. const onConfirm = () => emit("confirm");
  1945. const renderCancel = () => {
  1946. var _a;
  1947. const text = (_a = props2.cancelButtonText) != null ? _a : t$k("cancel");
  1948. if (!slots.cancel && !text) {
  1949. return;
  1950. }
  1951. return createVNode("button", {
  1952. "type": "button",
  1953. "class": [bem$1u("cancel"), HAPTICS_FEEDBACK],
  1954. "onClick": onCancel
  1955. }, [slots.cancel ? slots.cancel() : text]);
  1956. };
  1957. const renderConfirm = () => {
  1958. var _a;
  1959. const text = (_a = props2.confirmButtonText) != null ? _a : t$k("confirm");
  1960. if (!slots.confirm && !text) {
  1961. return;
  1962. }
  1963. return createVNode("button", {
  1964. "type": "button",
  1965. "class": [bem$1u("confirm"), HAPTICS_FEEDBACK],
  1966. "onClick": onConfirm
  1967. }, [slots.confirm ? slots.confirm() : text]);
  1968. };
  1969. return () => createVNode("div", {
  1970. "class": bem$1u("toolbar")
  1971. }, [slots.toolbar ? slots.toolbar() : [renderCancel(), renderTitle(), renderConfirm()]]);
  1972. }
  1973. });
  1974. const useSyncPropRef = (getProp, setProp) => {
  1975. const propRef = ref(getProp());
  1976. watch(getProp, (value) => {
  1977. if (value !== propRef.value) {
  1978. propRef.value = value;
  1979. }
  1980. });
  1981. watch(propRef, (value) => {
  1982. if (value !== getProp()) {
  1983. setProp(value);
  1984. }
  1985. });
  1986. return propRef;
  1987. };
  1988. function scrollLeftTo(scroller, to, duration) {
  1989. let rafId;
  1990. let count = 0;
  1991. const from = scroller.scrollLeft;
  1992. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  1993. let scrollLeft = from;
  1994. function cancel() {
  1995. cancelRaf(rafId);
  1996. }
  1997. function animate() {
  1998. scrollLeft += (to - from) / frames;
  1999. scroller.scrollLeft = scrollLeft;
  2000. if (++count < frames) {
  2001. rafId = raf(animate);
  2002. }
  2003. }
  2004. animate();
  2005. return cancel;
  2006. }
  2007. function scrollTopTo(scroller, to, duration, callback) {
  2008. let rafId;
  2009. let current2 = getScrollTop(scroller);
  2010. const isDown = current2 < to;
  2011. const frames = duration === 0 ? 1 : Math.round(duration * 1e3 / 16);
  2012. const step = (to - current2) / frames;
  2013. function cancel() {
  2014. cancelRaf(rafId);
  2015. }
  2016. function animate() {
  2017. current2 += step;
  2018. if (isDown && current2 > to || !isDown && current2 < to) {
  2019. current2 = to;
  2020. }
  2021. setScrollTop(scroller, current2);
  2022. if (isDown && current2 < to || !isDown && current2 > to) {
  2023. rafId = raf(animate);
  2024. } else if (callback) {
  2025. rafId = raf(callback);
  2026. }
  2027. }
  2028. animate();
  2029. return cancel;
  2030. }
  2031. let current = 0;
  2032. function useId() {
  2033. const vm = getCurrentInstance();
  2034. const { name: name2 = "unknown" } = (vm == null ? void 0 : vm.type) || {};
  2035. if (process.env.NODE_ENV === "test") {
  2036. return name2;
  2037. }
  2038. return `${name2}-${++current}`;
  2039. }
  2040. function useRefs() {
  2041. const refs = ref([]);
  2042. const cache = [];
  2043. onBeforeUpdate(() => {
  2044. refs.value = [];
  2045. });
  2046. const setRefs = (index) => {
  2047. if (!cache[index]) {
  2048. cache[index] = (el) => {
  2049. refs.value[index] = el;
  2050. };
  2051. }
  2052. return cache[index];
  2053. };
  2054. return [refs, setRefs];
  2055. }
  2056. function useVisibilityChange(target, onChange) {
  2057. if (!inBrowser || !window.IntersectionObserver) {
  2058. return;
  2059. }
  2060. const observer = new IntersectionObserver(
  2061. (entries) => {
  2062. onChange(entries[0].intersectionRatio > 0);
  2063. },
  2064. { root: document.body }
  2065. );
  2066. const observe = () => {
  2067. if (target.value) {
  2068. observer.observe(target.value);
  2069. }
  2070. };
  2071. const unobserve = () => {
  2072. if (target.value) {
  2073. observer.unobserve(target.value);
  2074. }
  2075. };
  2076. onDeactivated(unobserve);
  2077. onBeforeUnmount(unobserve);
  2078. onMountedOrActivated(observe);
  2079. }
  2080. const [name$1w, bem$1s] = createNamespace("sticky");
  2081. const stickyProps = {
  2082. zIndex: numericProp,
  2083. position: makeStringProp("top"),
  2084. container: Object,
  2085. offsetTop: makeNumericProp(0),
  2086. offsetBottom: makeNumericProp(0)
  2087. };
  2088. var stdin_default$1G = defineComponent({
  2089. name: name$1w,
  2090. props: stickyProps,
  2091. emits: ["scroll", "change"],
  2092. setup(props2, {
  2093. emit,
  2094. slots
  2095. }) {
  2096. const root = ref();
  2097. const scrollParent = useScrollParent(root);
  2098. const state = reactive({
  2099. fixed: false,
  2100. width: 0,
  2101. // root width
  2102. height: 0,
  2103. // root height
  2104. transform: 0
  2105. });
  2106. const isReset = ref(false);
  2107. const offset = computed(() => unitToPx(props2.position === "top" ? props2.offsetTop : props2.offsetBottom));
  2108. const rootStyle = computed(() => {
  2109. if (isReset.value) {
  2110. return;
  2111. }
  2112. const {
  2113. fixed,
  2114. height,
  2115. width
  2116. } = state;
  2117. if (fixed) {
  2118. return {
  2119. width: `${width}px`,
  2120. height: `${height}px`
  2121. };
  2122. }
  2123. });
  2124. const stickyStyle = computed(() => {
  2125. if (!state.fixed || isReset.value) {
  2126. return;
  2127. }
  2128. const style = extend(getZIndexStyle(props2.zIndex), {
  2129. width: `${state.width}px`,
  2130. height: `${state.height}px`,
  2131. [props2.position]: `${offset.value}px`
  2132. });
  2133. if (state.transform) {
  2134. style.transform = `translate3d(0, ${state.transform}px, 0)`;
  2135. }
  2136. return style;
  2137. });
  2138. const emitScroll = (scrollTop) => emit("scroll", {
  2139. scrollTop,
  2140. isFixed: state.fixed
  2141. });
  2142. const onScroll = () => {
  2143. if (!root.value || isHidden(root)) {
  2144. return;
  2145. }
  2146. const {
  2147. container,
  2148. position
  2149. } = props2;
  2150. const rootRect = useRect(root);
  2151. const scrollTop = getScrollTop(window);
  2152. state.width = rootRect.width;
  2153. state.height = rootRect.height;
  2154. if (position === "top") {
  2155. if (container) {
  2156. const containerRect = useRect(container);
  2157. const difference = containerRect.bottom - offset.value - state.height;
  2158. state.fixed = offset.value > rootRect.top && containerRect.bottom > 0;
  2159. state.transform = difference < 0 ? difference : 0;
  2160. } else {
  2161. state.fixed = offset.value > rootRect.top;
  2162. }
  2163. } else {
  2164. const {
  2165. clientHeight
  2166. } = document.documentElement;
  2167. if (container) {
  2168. const containerRect = useRect(container);
  2169. const difference = clientHeight - containerRect.top - offset.value - state.height;
  2170. state.fixed = clientHeight - offset.value < rootRect.bottom && clientHeight > containerRect.top;
  2171. state.transform = difference < 0 ? -difference : 0;
  2172. } else {
  2173. state.fixed = clientHeight - offset.value < rootRect.bottom;
  2174. }
  2175. }
  2176. emitScroll(scrollTop);
  2177. };
  2178. watch(() => state.fixed, (value) => emit("change", value));
  2179. useEventListener("scroll", onScroll, {
  2180. target: scrollParent,
  2181. passive: true
  2182. });
  2183. useVisibilityChange(root, onScroll);
  2184. watch([windowWidth, windowHeight], () => {
  2185. if (!root.value || isHidden(root) || !state.fixed) {
  2186. return;
  2187. }
  2188. isReset.value = true;
  2189. nextTick(() => {
  2190. const rootRect = useRect(root);
  2191. state.width = rootRect.width;
  2192. state.height = rootRect.height;
  2193. isReset.value = false;
  2194. });
  2195. });
  2196. return () => {
  2197. var _a;
  2198. return createVNode("div", {
  2199. "ref": root,
  2200. "style": rootStyle.value
  2201. }, [createVNode("div", {
  2202. "class": bem$1s({
  2203. fixed: state.fixed && !isReset.value
  2204. }),
  2205. "style": stickyStyle.value
  2206. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  2207. };
  2208. }
  2209. });
  2210. const Sticky = withInstall(stdin_default$1G);
  2211. const [name$1v, bem$1r] = createNamespace("swipe");
  2212. const swipeProps = {
  2213. loop: truthProp,
  2214. width: numericProp,
  2215. height: numericProp,
  2216. vertical: Boolean,
  2217. autoplay: makeNumericProp(0),
  2218. duration: makeNumericProp(500),
  2219. touchable: truthProp,
  2220. lazyRender: Boolean,
  2221. initialSwipe: makeNumericProp(0),
  2222. indicatorColor: String,
  2223. showIndicators: truthProp,
  2224. stopPropagation: truthProp
  2225. };
  2226. const SWIPE_KEY = Symbol(name$1v);
  2227. var stdin_default$1F = defineComponent({
  2228. name: name$1v,
  2229. props: swipeProps,
  2230. emits: ["change", "dragStart", "dragEnd"],
  2231. setup(props2, {
  2232. emit,
  2233. slots
  2234. }) {
  2235. const root = ref();
  2236. const track = ref();
  2237. const state = reactive({
  2238. rect: null,
  2239. width: 0,
  2240. height: 0,
  2241. offset: 0,
  2242. active: 0,
  2243. swiping: false
  2244. });
  2245. let dragging = false;
  2246. const touch = useTouch();
  2247. const {
  2248. children,
  2249. linkChildren
  2250. } = useChildren(SWIPE_KEY);
  2251. const count = computed(() => children.length);
  2252. const size = computed(() => state[props2.vertical ? "height" : "width"]);
  2253. const delta = computed(() => props2.vertical ? touch.deltaY.value : touch.deltaX.value);
  2254. const minOffset = computed(() => {
  2255. if (state.rect) {
  2256. const base = props2.vertical ? state.rect.height : state.rect.width;
  2257. return base - size.value * count.value;
  2258. }
  2259. return 0;
  2260. });
  2261. const maxCount = computed(() => size.value ? Math.ceil(Math.abs(minOffset.value) / size.value) : count.value);
  2262. const trackSize = computed(() => count.value * size.value);
  2263. const activeIndicator = computed(() => (state.active + count.value) % count.value);
  2264. const isCorrectDirection = computed(() => {
  2265. const expect = props2.vertical ? "vertical" : "horizontal";
  2266. return touch.direction.value === expect;
  2267. });
  2268. const trackStyle = computed(() => {
  2269. const style = {
  2270. transitionDuration: `${state.swiping ? 0 : props2.duration}ms`,
  2271. transform: `translate${props2.vertical ? "Y" : "X"}(${+state.offset.toFixed(2)}px)`
  2272. };
  2273. if (size.value) {
  2274. const mainAxis = props2.vertical ? "height" : "width";
  2275. const crossAxis = props2.vertical ? "width" : "height";
  2276. style[mainAxis] = `${trackSize.value}px`;
  2277. style[crossAxis] = props2[crossAxis] ? `${props2[crossAxis]}px` : "";
  2278. }
  2279. return style;
  2280. });
  2281. const getTargetActive = (pace) => {
  2282. const {
  2283. active
  2284. } = state;
  2285. if (pace) {
  2286. if (props2.loop) {
  2287. return clamp(active + pace, -1, count.value);
  2288. }
  2289. return clamp(active + pace, 0, maxCount.value);
  2290. }
  2291. return active;
  2292. };
  2293. const getTargetOffset = (targetActive, offset = 0) => {
  2294. let currentPosition = targetActive * size.value;
  2295. if (!props2.loop) {
  2296. currentPosition = Math.min(currentPosition, -minOffset.value);
  2297. }
  2298. let targetOffset = offset - currentPosition;
  2299. if (!props2.loop) {
  2300. targetOffset = clamp(targetOffset, minOffset.value, 0);
  2301. }
  2302. return targetOffset;
  2303. };
  2304. const move = ({
  2305. pace = 0,
  2306. offset = 0,
  2307. emitChange
  2308. }) => {
  2309. if (count.value <= 1) {
  2310. return;
  2311. }
  2312. const {
  2313. active
  2314. } = state;
  2315. const targetActive = getTargetActive(pace);
  2316. const targetOffset = getTargetOffset(targetActive, offset);
  2317. if (props2.loop) {
  2318. if (children[0] && targetOffset !== minOffset.value) {
  2319. const outRightBound = targetOffset < minOffset.value;
  2320. children[0].setOffset(outRightBound ? trackSize.value : 0);
  2321. }
  2322. if (children[count.value - 1] && targetOffset !== 0) {
  2323. const outLeftBound = targetOffset > 0;
  2324. children[count.value - 1].setOffset(outLeftBound ? -trackSize.value : 0);
  2325. }
  2326. }
  2327. state.active = targetActive;
  2328. state.offset = targetOffset;
  2329. if (emitChange && targetActive !== active) {
  2330. emit("change", activeIndicator.value);
  2331. }
  2332. };
  2333. const correctPosition = () => {
  2334. state.swiping = true;
  2335. if (state.active <= -1) {
  2336. move({
  2337. pace: count.value
  2338. });
  2339. } else if (state.active >= count.value) {
  2340. move({
  2341. pace: -count.value
  2342. });
  2343. }
  2344. };
  2345. const prev = () => {
  2346. correctPosition();
  2347. touch.reset();
  2348. doubleRaf(() => {
  2349. state.swiping = false;
  2350. move({
  2351. pace: -1,
  2352. emitChange: true
  2353. });
  2354. });
  2355. };
  2356. const next = () => {
  2357. correctPosition();
  2358. touch.reset();
  2359. doubleRaf(() => {
  2360. state.swiping = false;
  2361. move({
  2362. pace: 1,
  2363. emitChange: true
  2364. });
  2365. });
  2366. };
  2367. let autoplayTimer;
  2368. const stopAutoplay = () => clearTimeout(autoplayTimer);
  2369. const autoplay = () => {
  2370. stopAutoplay();
  2371. if (+props2.autoplay > 0 && count.value > 1) {
  2372. autoplayTimer = setTimeout(() => {
  2373. next();
  2374. autoplay();
  2375. }, +props2.autoplay);
  2376. }
  2377. };
  2378. const initialize = (active = +props2.initialSwipe) => {
  2379. if (!root.value) {
  2380. return;
  2381. }
  2382. const cb = () => {
  2383. var _a, _b;
  2384. if (!isHidden(root)) {
  2385. const rect = {
  2386. width: root.value.offsetWidth,
  2387. height: root.value.offsetHeight
  2388. };
  2389. state.rect = rect;
  2390. state.width = +((_a = props2.width) != null ? _a : rect.width);
  2391. state.height = +((_b = props2.height) != null ? _b : rect.height);
  2392. }
  2393. if (count.value) {
  2394. active = Math.min(count.value - 1, active);
  2395. if (active === -1) {
  2396. active = count.value - 1;
  2397. }
  2398. }
  2399. state.active = active;
  2400. state.swiping = true;
  2401. state.offset = getTargetOffset(active);
  2402. children.forEach((swipe) => {
  2403. swipe.setOffset(0);
  2404. });
  2405. autoplay();
  2406. };
  2407. if (isHidden(root)) {
  2408. nextTick().then(cb);
  2409. } else {
  2410. cb();
  2411. }
  2412. };
  2413. const resize = () => initialize(state.active);
  2414. let touchStartTime;
  2415. const onTouchStart = (event) => {
  2416. if (!props2.touchable || // avoid resetting position on multi-finger touch
  2417. event.touches.length > 1) return;
  2418. touch.start(event);
  2419. dragging = false;
  2420. touchStartTime = Date.now();
  2421. stopAutoplay();
  2422. correctPosition();
  2423. };
  2424. const onTouchMove = (event) => {
  2425. if (props2.touchable && state.swiping) {
  2426. touch.move(event);
  2427. if (isCorrectDirection.value) {
  2428. const isEdgeTouch = !props2.loop && (state.active === 0 && delta.value > 0 || state.active === count.value - 1 && delta.value < 0);
  2429. if (!isEdgeTouch) {
  2430. preventDefault(event, props2.stopPropagation);
  2431. move({
  2432. offset: delta.value
  2433. });
  2434. if (!dragging) {
  2435. emit("dragStart", {
  2436. index: activeIndicator.value
  2437. });
  2438. dragging = true;
  2439. }
  2440. }
  2441. }
  2442. }
  2443. };
  2444. const onTouchEnd = () => {
  2445. if (!props2.touchable || !state.swiping) {
  2446. return;
  2447. }
  2448. const duration = Date.now() - touchStartTime;
  2449. const speed = delta.value / duration;
  2450. const shouldSwipe = Math.abs(speed) > 0.25 || Math.abs(delta.value) > size.value / 2;
  2451. if (shouldSwipe && isCorrectDirection.value) {
  2452. const offset = props2.vertical ? touch.offsetY.value : touch.offsetX.value;
  2453. let pace = 0;
  2454. if (props2.loop) {
  2455. pace = offset > 0 ? delta.value > 0 ? -1 : 1 : 0;
  2456. } else {
  2457. pace = -Math[delta.value > 0 ? "ceil" : "floor"](delta.value / size.value);
  2458. }
  2459. move({
  2460. pace,
  2461. emitChange: true
  2462. });
  2463. } else if (delta.value) {
  2464. move({
  2465. pace: 0
  2466. });
  2467. }
  2468. dragging = false;
  2469. state.swiping = false;
  2470. emit("dragEnd", {
  2471. index: activeIndicator.value
  2472. });
  2473. autoplay();
  2474. };
  2475. const swipeTo = (index, options = {}) => {
  2476. correctPosition();
  2477. touch.reset();
  2478. doubleRaf(() => {
  2479. let targetIndex;
  2480. if (props2.loop && index === count.value) {
  2481. targetIndex = state.active === 0 ? 0 : index;
  2482. } else {
  2483. targetIndex = index % count.value;
  2484. }
  2485. if (options.immediate) {
  2486. doubleRaf(() => {
  2487. state.swiping = false;
  2488. });
  2489. } else {
  2490. state.swiping = false;
  2491. }
  2492. move({
  2493. pace: targetIndex - state.active,
  2494. emitChange: true
  2495. });
  2496. });
  2497. };
  2498. const renderDot = (_, index) => {
  2499. const active = index === activeIndicator.value;
  2500. const style = active ? {
  2501. backgroundColor: props2.indicatorColor
  2502. } : void 0;
  2503. return createVNode("i", {
  2504. "style": style,
  2505. "class": bem$1r("indicator", {
  2506. active
  2507. })
  2508. }, null);
  2509. };
  2510. const renderIndicator = () => {
  2511. if (slots.indicator) {
  2512. return slots.indicator({
  2513. active: activeIndicator.value,
  2514. total: count.value
  2515. });
  2516. }
  2517. if (props2.showIndicators && count.value > 1) {
  2518. return createVNode("div", {
  2519. "class": bem$1r("indicators", {
  2520. vertical: props2.vertical
  2521. })
  2522. }, [Array(count.value).fill("").map(renderDot)]);
  2523. }
  2524. };
  2525. useExpose({
  2526. prev,
  2527. next,
  2528. state,
  2529. resize,
  2530. swipeTo
  2531. });
  2532. linkChildren({
  2533. size,
  2534. props: props2,
  2535. count,
  2536. activeIndicator
  2537. });
  2538. watch(() => props2.initialSwipe, (value) => initialize(+value));
  2539. watch(count, () => initialize(state.active));
  2540. watch(() => props2.autoplay, autoplay);
  2541. watch([windowWidth, windowHeight, () => props2.width, () => props2.height], resize);
  2542. watch(usePageVisibility(), (visible) => {
  2543. if (visible === "visible") {
  2544. autoplay();
  2545. } else {
  2546. stopAutoplay();
  2547. }
  2548. });
  2549. onMounted(initialize);
  2550. onActivated(() => initialize(state.active));
  2551. onPopupReopen(() => initialize(state.active));
  2552. onDeactivated(stopAutoplay);
  2553. onBeforeUnmount(stopAutoplay);
  2554. useEventListener("touchmove", onTouchMove, {
  2555. target: track
  2556. });
  2557. return () => {
  2558. var _a;
  2559. return createVNode("div", {
  2560. "ref": root,
  2561. "class": bem$1r()
  2562. }, [createVNode("div", {
  2563. "ref": track,
  2564. "style": trackStyle.value,
  2565. "class": bem$1r("track", {
  2566. vertical: props2.vertical
  2567. }),
  2568. "onTouchstartPassive": onTouchStart,
  2569. "onTouchend": onTouchEnd,
  2570. "onTouchcancel": onTouchEnd
  2571. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), renderIndicator()]);
  2572. };
  2573. }
  2574. });
  2575. const Swipe = withInstall(stdin_default$1F);
  2576. const [name$1u, bem$1q] = createNamespace("tabs");
  2577. var stdin_default$1E = defineComponent({
  2578. name: name$1u,
  2579. props: {
  2580. count: makeRequiredProp(Number),
  2581. inited: Boolean,
  2582. animated: Boolean,
  2583. duration: makeRequiredProp(numericProp),
  2584. swipeable: Boolean,
  2585. lazyRender: Boolean,
  2586. currentIndex: makeRequiredProp(Number)
  2587. },
  2588. emits: ["change"],
  2589. setup(props2, {
  2590. emit,
  2591. slots
  2592. }) {
  2593. const swipeRef = ref();
  2594. const onChange = (index) => emit("change", index);
  2595. const renderChildren = () => {
  2596. var _a;
  2597. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  2598. if (props2.animated || props2.swipeable) {
  2599. return createVNode(Swipe, {
  2600. "ref": swipeRef,
  2601. "loop": false,
  2602. "class": bem$1q("track"),
  2603. "duration": +props2.duration * 1e3,
  2604. "touchable": props2.swipeable,
  2605. "lazyRender": props2.lazyRender,
  2606. "showIndicators": false,
  2607. "onChange": onChange
  2608. }, {
  2609. default: () => [Content]
  2610. });
  2611. }
  2612. return Content;
  2613. };
  2614. const swipeToCurrentTab = (index) => {
  2615. const swipe = swipeRef.value;
  2616. if (swipe && swipe.state.active !== index) {
  2617. swipe.swipeTo(index, {
  2618. immediate: !props2.inited
  2619. });
  2620. }
  2621. };
  2622. watch(() => props2.currentIndex, swipeToCurrentTab);
  2623. onMounted(() => {
  2624. swipeToCurrentTab(props2.currentIndex);
  2625. });
  2626. useExpose({
  2627. swipeRef
  2628. });
  2629. return () => createVNode("div", {
  2630. "class": bem$1q("content", {
  2631. animated: props2.animated || props2.swipeable
  2632. })
  2633. }, [renderChildren()]);
  2634. }
  2635. });
  2636. const [name$1t, bem$1p] = createNamespace("tabs");
  2637. const tabsProps = {
  2638. type: makeStringProp("line"),
  2639. color: String,
  2640. border: Boolean,
  2641. sticky: Boolean,
  2642. shrink: Boolean,
  2643. active: makeNumericProp(0),
  2644. duration: makeNumericProp(0.3),
  2645. animated: Boolean,
  2646. ellipsis: truthProp,
  2647. swipeable: Boolean,
  2648. scrollspy: Boolean,
  2649. offsetTop: makeNumericProp(0),
  2650. background: String,
  2651. lazyRender: truthProp,
  2652. showHeader: truthProp,
  2653. lineWidth: numericProp,
  2654. lineHeight: numericProp,
  2655. beforeChange: Function,
  2656. swipeThreshold: makeNumericProp(5),
  2657. titleActiveColor: String,
  2658. titleInactiveColor: String
  2659. };
  2660. const TABS_KEY = Symbol(name$1t);
  2661. var stdin_default$1D = defineComponent({
  2662. name: name$1t,
  2663. props: tabsProps,
  2664. emits: ["change", "scroll", "rendered", "clickTab", "update:active"],
  2665. setup(props2, {
  2666. emit,
  2667. slots
  2668. }) {
  2669. let tabHeight;
  2670. let lockScroll;
  2671. let stickyFixed;
  2672. let cancelScrollLeftToRaf;
  2673. let cancelScrollTopToRaf;
  2674. const root = ref();
  2675. const navRef = ref();
  2676. const wrapRef = ref();
  2677. const contentRef = ref();
  2678. const id = useId();
  2679. const scroller = useScrollParent(root);
  2680. const [titleRefs, setTitleRefs] = useRefs();
  2681. const {
  2682. children,
  2683. linkChildren
  2684. } = useChildren(TABS_KEY);
  2685. const state = reactive({
  2686. inited: false,
  2687. position: "",
  2688. lineStyle: {},
  2689. currentIndex: -1
  2690. });
  2691. const scrollable = computed(() => children.length > +props2.swipeThreshold || !props2.ellipsis || props2.shrink);
  2692. const navStyle = computed(() => ({
  2693. borderColor: props2.color,
  2694. background: props2.background
  2695. }));
  2696. const getTabName = (tab, index) => {
  2697. var _a;
  2698. return (_a = tab.name) != null ? _a : index;
  2699. };
  2700. const currentName = computed(() => {
  2701. const activeTab = children[state.currentIndex];
  2702. if (activeTab) {
  2703. return getTabName(activeTab, state.currentIndex);
  2704. }
  2705. });
  2706. const offsetTopPx = computed(() => unitToPx(props2.offsetTop));
  2707. const scrollOffset = computed(() => {
  2708. if (props2.sticky) {
  2709. return offsetTopPx.value + tabHeight;
  2710. }
  2711. return 0;
  2712. });
  2713. const scrollIntoView = (immediate) => {
  2714. const nav = navRef.value;
  2715. const titles = titleRefs.value;
  2716. if (!scrollable.value || !nav || !titles || !titles[state.currentIndex]) {
  2717. return;
  2718. }
  2719. const title = titles[state.currentIndex].$el;
  2720. const to = title.offsetLeft - (nav.offsetWidth - title.offsetWidth) / 2;
  2721. if (cancelScrollLeftToRaf) cancelScrollLeftToRaf();
  2722. cancelScrollLeftToRaf = scrollLeftTo(nav, to, immediate ? 0 : +props2.duration);
  2723. };
  2724. const setLine = () => {
  2725. const shouldAnimate = state.inited;
  2726. nextTick(() => {
  2727. const titles = titleRefs.value;
  2728. if (!titles || !titles[state.currentIndex] || props2.type !== "line" || isHidden(root.value)) {
  2729. return;
  2730. }
  2731. const title = titles[state.currentIndex].$el;
  2732. const {
  2733. lineWidth,
  2734. lineHeight
  2735. } = props2;
  2736. const left = title.offsetLeft + title.offsetWidth / 2;
  2737. const lineStyle = {
  2738. width: addUnit(lineWidth),
  2739. backgroundColor: props2.color,
  2740. transform: `translateX(${left}px) translateX(-50%)`
  2741. };
  2742. if (shouldAnimate) {
  2743. lineStyle.transitionDuration = `${props2.duration}s`;
  2744. }
  2745. if (isDef(lineHeight)) {
  2746. const height = addUnit(lineHeight);
  2747. lineStyle.height = height;
  2748. lineStyle.borderRadius = height;
  2749. }
  2750. state.lineStyle = lineStyle;
  2751. });
  2752. };
  2753. const findAvailableTab = (index) => {
  2754. const diff = index < state.currentIndex ? -1 : 1;
  2755. while (index >= 0 && index < children.length) {
  2756. if (!children[index].disabled) {
  2757. return index;
  2758. }
  2759. index += diff;
  2760. }
  2761. };
  2762. const setCurrentIndex = (currentIndex, skipScrollIntoView) => {
  2763. const newIndex = findAvailableTab(currentIndex);
  2764. if (!isDef(newIndex)) {
  2765. return;
  2766. }
  2767. const newTab = children[newIndex];
  2768. const newName = getTabName(newTab, newIndex);
  2769. const shouldEmitChange = state.currentIndex !== null;
  2770. if (state.currentIndex !== newIndex) {
  2771. state.currentIndex = newIndex;
  2772. if (!skipScrollIntoView) {
  2773. scrollIntoView();
  2774. }
  2775. setLine();
  2776. }
  2777. if (newName !== props2.active) {
  2778. emit("update:active", newName);
  2779. if (shouldEmitChange) {
  2780. emit("change", newName, newTab.title);
  2781. }
  2782. }
  2783. if (stickyFixed && !props2.scrollspy) {
  2784. setRootScrollTop(Math.ceil(getElementTop(root.value) - offsetTopPx.value));
  2785. }
  2786. };
  2787. const setCurrentIndexByName = (name2, skipScrollIntoView) => {
  2788. const matched = children.find((tab, index2) => getTabName(tab, index2) === name2);
  2789. const index = matched ? children.indexOf(matched) : 0;
  2790. setCurrentIndex(index, skipScrollIntoView);
  2791. };
  2792. const scrollToCurrentContent = (immediate = false) => {
  2793. if (props2.scrollspy) {
  2794. const target = children[state.currentIndex].$el;
  2795. if (target && scroller.value) {
  2796. const to = getElementTop(target, scroller.value) - scrollOffset.value;
  2797. lockScroll = true;
  2798. if (cancelScrollTopToRaf) cancelScrollTopToRaf();
  2799. cancelScrollTopToRaf = scrollTopTo(scroller.value, to, immediate ? 0 : +props2.duration, () => {
  2800. lockScroll = false;
  2801. });
  2802. }
  2803. }
  2804. };
  2805. const onClickTab = (item, index, event) => {
  2806. const {
  2807. title,
  2808. disabled
  2809. } = children[index];
  2810. const name2 = getTabName(children[index], index);
  2811. if (!disabled) {
  2812. callInterceptor(props2.beforeChange, {
  2813. args: [name2],
  2814. done: () => {
  2815. setCurrentIndex(index);
  2816. scrollToCurrentContent();
  2817. }
  2818. });
  2819. route(item);
  2820. }
  2821. emit("clickTab", {
  2822. name: name2,
  2823. title,
  2824. event,
  2825. disabled
  2826. });
  2827. };
  2828. const onStickyScroll = (params) => {
  2829. stickyFixed = params.isFixed;
  2830. emit("scroll", params);
  2831. };
  2832. const scrollTo = (name2) => {
  2833. nextTick(() => {
  2834. setCurrentIndexByName(name2);
  2835. scrollToCurrentContent(true);
  2836. });
  2837. };
  2838. const getCurrentIndexOnScroll = () => {
  2839. for (let index = 0; index < children.length; index++) {
  2840. const {
  2841. top
  2842. } = useRect(children[index].$el);
  2843. if (top > scrollOffset.value) {
  2844. return index === 0 ? 0 : index - 1;
  2845. }
  2846. }
  2847. return children.length - 1;
  2848. };
  2849. const onScroll = () => {
  2850. if (props2.scrollspy && !lockScroll) {
  2851. const index = getCurrentIndexOnScroll();
  2852. setCurrentIndex(index);
  2853. }
  2854. };
  2855. const renderLine = () => {
  2856. if (props2.type === "line" && children.length) {
  2857. return createVNode("div", {
  2858. "class": bem$1p("line"),
  2859. "style": state.lineStyle
  2860. }, null);
  2861. }
  2862. };
  2863. const renderHeader = () => {
  2864. var _a, _b, _c;
  2865. const {
  2866. type,
  2867. border,
  2868. sticky
  2869. } = props2;
  2870. const Header = [createVNode("div", {
  2871. "ref": sticky ? void 0 : wrapRef,
  2872. "class": [bem$1p("wrap"), {
  2873. [BORDER_TOP_BOTTOM]: type === "line" && border
  2874. }]
  2875. }, [createVNode("div", {
  2876. "ref": navRef,
  2877. "role": "tablist",
  2878. "class": bem$1p("nav", [type, {
  2879. shrink: props2.shrink,
  2880. complete: scrollable.value
  2881. }]),
  2882. "style": navStyle.value,
  2883. "aria-orientation": "horizontal"
  2884. }, [(_a = slots["nav-left"]) == null ? void 0 : _a.call(slots), children.map((item) => item.renderTitle(onClickTab)), renderLine(), (_b = slots["nav-right"]) == null ? void 0 : _b.call(slots)])]), (_c = slots["nav-bottom"]) == null ? void 0 : _c.call(slots)];
  2885. if (sticky) {
  2886. return createVNode("div", {
  2887. "ref": wrapRef
  2888. }, [Header]);
  2889. }
  2890. return Header;
  2891. };
  2892. const resize = () => {
  2893. setLine();
  2894. nextTick(() => {
  2895. var _a, _b;
  2896. scrollIntoView(true);
  2897. (_b = (_a = contentRef.value) == null ? void 0 : _a.swipeRef.value) == null ? void 0 : _b.resize();
  2898. });
  2899. };
  2900. watch(() => [props2.color, props2.duration, props2.lineWidth, props2.lineHeight], setLine);
  2901. watch(windowWidth, resize);
  2902. watch(() => props2.active, (value) => {
  2903. if (value !== currentName.value) {
  2904. setCurrentIndexByName(value);
  2905. }
  2906. });
  2907. watch(() => children.length, () => {
  2908. if (state.inited) {
  2909. setCurrentIndexByName(props2.active);
  2910. setLine();
  2911. nextTick(() => {
  2912. scrollIntoView(true);
  2913. });
  2914. }
  2915. });
  2916. const init = () => {
  2917. setCurrentIndexByName(props2.active, true);
  2918. nextTick(() => {
  2919. state.inited = true;
  2920. if (wrapRef.value) {
  2921. tabHeight = useRect(wrapRef.value).height;
  2922. }
  2923. scrollIntoView(true);
  2924. });
  2925. };
  2926. const onRendered = (name2, title) => emit("rendered", name2, title);
  2927. useExpose({
  2928. resize,
  2929. scrollTo
  2930. });
  2931. onActivated(setLine);
  2932. onPopupReopen(setLine);
  2933. onMountedOrActivated(init);
  2934. useVisibilityChange(root, setLine);
  2935. useEventListener("scroll", onScroll, {
  2936. target: scroller,
  2937. passive: true
  2938. });
  2939. linkChildren({
  2940. id,
  2941. props: props2,
  2942. setLine,
  2943. scrollable,
  2944. onRendered,
  2945. currentName,
  2946. setTitleRefs,
  2947. scrollIntoView
  2948. });
  2949. return () => createVNode("div", {
  2950. "ref": root,
  2951. "class": bem$1p([props2.type])
  2952. }, [props2.showHeader ? props2.sticky ? createVNode(Sticky, {
  2953. "container": root.value,
  2954. "offsetTop": offsetTopPx.value,
  2955. "onScroll": onStickyScroll
  2956. }, {
  2957. default: () => [renderHeader()]
  2958. }) : renderHeader() : null, createVNode(stdin_default$1E, {
  2959. "ref": contentRef,
  2960. "count": children.length,
  2961. "inited": state.inited,
  2962. "animated": props2.animated,
  2963. "duration": props2.duration,
  2964. "swipeable": props2.swipeable,
  2965. "lazyRender": props2.lazyRender,
  2966. "currentIndex": state.currentIndex,
  2967. "onChange": setCurrentIndex
  2968. }, {
  2969. default: () => {
  2970. var _a;
  2971. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  2972. }
  2973. })]);
  2974. }
  2975. });
  2976. const TAB_STATUS_KEY = Symbol();
  2977. const useTabStatus = () => inject(TAB_STATUS_KEY, null);
  2978. const [name$1s, bem$1o] = createNamespace("tab");
  2979. const TabTitle = defineComponent({
  2980. name: name$1s,
  2981. props: {
  2982. id: String,
  2983. dot: Boolean,
  2984. type: String,
  2985. color: String,
  2986. title: String,
  2987. badge: numericProp,
  2988. shrink: Boolean,
  2989. isActive: Boolean,
  2990. disabled: Boolean,
  2991. controls: String,
  2992. scrollable: Boolean,
  2993. activeColor: String,
  2994. inactiveColor: String,
  2995. showZeroBadge: truthProp
  2996. },
  2997. setup(props2, {
  2998. slots
  2999. }) {
  3000. const style = computed(() => {
  3001. const style2 = {};
  3002. const {
  3003. type,
  3004. color,
  3005. disabled,
  3006. isActive,
  3007. activeColor,
  3008. inactiveColor
  3009. } = props2;
  3010. const isCard = type === "card";
  3011. if (color && isCard) {
  3012. style2.borderColor = color;
  3013. if (!disabled) {
  3014. if (isActive) {
  3015. style2.backgroundColor = color;
  3016. } else {
  3017. style2.color = color;
  3018. }
  3019. }
  3020. }
  3021. const titleColor = isActive ? activeColor : inactiveColor;
  3022. if (titleColor) {
  3023. style2.color = titleColor;
  3024. }
  3025. return style2;
  3026. });
  3027. const renderText = () => {
  3028. const Text2 = createVNode("span", {
  3029. "class": bem$1o("text", {
  3030. ellipsis: !props2.scrollable
  3031. })
  3032. }, [slots.title ? slots.title() : props2.title]);
  3033. if (props2.dot || isDef(props2.badge) && props2.badge !== "") {
  3034. return createVNode(Badge, {
  3035. "dot": props2.dot,
  3036. "content": props2.badge,
  3037. "showZero": props2.showZeroBadge
  3038. }, {
  3039. default: () => [Text2]
  3040. });
  3041. }
  3042. return Text2;
  3043. };
  3044. return () => createVNode("div", {
  3045. "id": props2.id,
  3046. "role": "tab",
  3047. "class": [bem$1o([props2.type, {
  3048. grow: props2.scrollable && !props2.shrink,
  3049. shrink: props2.shrink,
  3050. active: props2.isActive,
  3051. disabled: props2.disabled
  3052. }])],
  3053. "style": style.value,
  3054. "tabindex": props2.disabled ? void 0 : props2.isActive ? 0 : -1,
  3055. "aria-selected": props2.isActive,
  3056. "aria-disabled": props2.disabled || void 0,
  3057. "aria-controls": props2.controls,
  3058. "data-allow-mismatch": "attribute"
  3059. }, [renderText()]);
  3060. }
  3061. });
  3062. const [name$1r, bem$1n] = createNamespace("swipe-item");
  3063. var stdin_default$1C = defineComponent({
  3064. name: name$1r,
  3065. setup(props2, {
  3066. slots
  3067. }) {
  3068. let rendered;
  3069. const state = reactive({
  3070. offset: 0,
  3071. inited: false,
  3072. mounted: false
  3073. });
  3074. const {
  3075. parent,
  3076. index
  3077. } = useParent(SWIPE_KEY);
  3078. if (!parent) {
  3079. if (process.env.NODE_ENV !== "production") {
  3080. console.error("[Vant] <SwipeItem> must be a child component of <Swipe>.");
  3081. }
  3082. return;
  3083. }
  3084. const style = computed(() => {
  3085. const style2 = {};
  3086. const {
  3087. vertical
  3088. } = parent.props;
  3089. if (parent.size.value) {
  3090. style2[vertical ? "height" : "width"] = `${parent.size.value}px`;
  3091. }
  3092. if (state.offset) {
  3093. style2.transform = `translate${vertical ? "Y" : "X"}(${state.offset}px)`;
  3094. }
  3095. return style2;
  3096. });
  3097. const shouldRender = computed(() => {
  3098. const {
  3099. loop,
  3100. lazyRender
  3101. } = parent.props;
  3102. if (!lazyRender || rendered) {
  3103. return true;
  3104. }
  3105. if (!state.mounted) {
  3106. return false;
  3107. }
  3108. const active = parent.activeIndicator.value;
  3109. const maxActive = parent.count.value - 1;
  3110. const prevActive = active === 0 && loop ? maxActive : active - 1;
  3111. const nextActive = active === maxActive && loop ? 0 : active + 1;
  3112. rendered = index.value === active || index.value === prevActive || index.value === nextActive;
  3113. return rendered;
  3114. });
  3115. const setOffset = (offset) => {
  3116. state.offset = offset;
  3117. };
  3118. onMounted(() => {
  3119. nextTick(() => {
  3120. state.mounted = true;
  3121. });
  3122. });
  3123. useExpose({
  3124. setOffset
  3125. });
  3126. return () => {
  3127. var _a;
  3128. return createVNode("div", {
  3129. "class": bem$1n(),
  3130. "style": style.value
  3131. }, [shouldRender.value ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null]);
  3132. };
  3133. }
  3134. });
  3135. const SwipeItem = withInstall(stdin_default$1C);
  3136. const [name$1q, bem$1m] = createNamespace("tab");
  3137. const tabProps = extend({}, routeProps, {
  3138. dot: Boolean,
  3139. name: numericProp,
  3140. badge: numericProp,
  3141. title: String,
  3142. disabled: Boolean,
  3143. titleClass: unknownProp,
  3144. titleStyle: [String, Object],
  3145. showZeroBadge: truthProp
  3146. });
  3147. var stdin_default$1B = defineComponent({
  3148. name: name$1q,
  3149. props: tabProps,
  3150. setup(props2, {
  3151. slots
  3152. }) {
  3153. const id = useId();
  3154. const inited = ref(false);
  3155. const instance2 = getCurrentInstance();
  3156. const {
  3157. parent,
  3158. index
  3159. } = useParent(TABS_KEY);
  3160. if (!parent) {
  3161. if (process.env.NODE_ENV !== "production") {
  3162. console.error("[Vant] <Tab> must be a child component of <Tabs>.");
  3163. }
  3164. return;
  3165. }
  3166. const getName = () => {
  3167. var _a;
  3168. return (_a = props2.name) != null ? _a : index.value;
  3169. };
  3170. const init = () => {
  3171. inited.value = true;
  3172. if (parent.props.lazyRender) {
  3173. nextTick(() => {
  3174. parent.onRendered(getName(), props2.title);
  3175. });
  3176. }
  3177. };
  3178. const active = computed(() => {
  3179. const isActive = getName() === parent.currentName.value;
  3180. if (isActive && !inited.value) {
  3181. init();
  3182. }
  3183. return isActive;
  3184. });
  3185. const parsedClass = ref("");
  3186. const parsedStyle = ref("");
  3187. watchEffect(() => {
  3188. const {
  3189. titleClass,
  3190. titleStyle
  3191. } = props2;
  3192. parsedClass.value = titleClass ? normalizeClass(titleClass) : "";
  3193. parsedStyle.value = titleStyle && typeof titleStyle !== "string" ? stringifyStyle(normalizeStyle(titleStyle)) : titleStyle;
  3194. });
  3195. const renderTitle = (onClickTab) => createVNode(TabTitle, mergeProps({
  3196. "key": id,
  3197. "id": `${parent.id}-${index.value}`,
  3198. "ref": parent.setTitleRefs(index.value),
  3199. "style": parsedStyle.value,
  3200. "class": parsedClass.value,
  3201. "isActive": active.value,
  3202. "controls": id,
  3203. "scrollable": parent.scrollable.value,
  3204. "activeColor": parent.props.titleActiveColor,
  3205. "inactiveColor": parent.props.titleInactiveColor,
  3206. "onClick": (event) => onClickTab(instance2.proxy, index.value, event)
  3207. }, pick(parent.props, ["type", "color", "shrink"]), pick(props2, ["dot", "badge", "title", "disabled", "showZeroBadge"])), {
  3208. title: slots.title
  3209. });
  3210. const hasInactiveClass = ref(!active.value);
  3211. watch(active, (val) => {
  3212. if (val) {
  3213. hasInactiveClass.value = false;
  3214. } else {
  3215. doubleRaf(() => {
  3216. hasInactiveClass.value = true;
  3217. });
  3218. }
  3219. });
  3220. watch(() => props2.title, () => {
  3221. parent.setLine();
  3222. parent.scrollIntoView();
  3223. });
  3224. provide(TAB_STATUS_KEY, active);
  3225. useExpose({
  3226. id,
  3227. renderTitle
  3228. });
  3229. return () => {
  3230. var _a;
  3231. const label = `${parent.id}-${index.value}`;
  3232. const {
  3233. animated,
  3234. swipeable,
  3235. scrollspy,
  3236. lazyRender
  3237. } = parent.props;
  3238. if (!slots.default && !animated) {
  3239. return;
  3240. }
  3241. const show = scrollspy || active.value;
  3242. if (animated || swipeable) {
  3243. return createVNode(SwipeItem, {
  3244. "id": id,
  3245. "role": "tabpanel",
  3246. "class": bem$1m("panel-wrapper", {
  3247. inactive: hasInactiveClass.value
  3248. }),
  3249. "tabindex": active.value ? 0 : -1,
  3250. "aria-hidden": !active.value,
  3251. "aria-labelledby": label,
  3252. "data-allow-mismatch": "attribute"
  3253. }, {
  3254. default: () => {
  3255. var _a2;
  3256. return [createVNode("div", {
  3257. "class": bem$1m("panel")
  3258. }, [(_a2 = slots.default) == null ? void 0 : _a2.call(slots)])];
  3259. }
  3260. });
  3261. }
  3262. const shouldRender = inited.value || scrollspy || !lazyRender;
  3263. const Content = shouldRender ? (_a = slots.default) == null ? void 0 : _a.call(slots) : null;
  3264. return withDirectives(createVNode("div", {
  3265. "id": id,
  3266. "role": "tabpanel",
  3267. "class": bem$1m("panel"),
  3268. "tabindex": show ? 0 : -1,
  3269. "aria-labelledby": label,
  3270. "data-allow-mismatch": "attribute"
  3271. }, [Content]), [[vShow, show]]);
  3272. };
  3273. }
  3274. });
  3275. const Tab = withInstall(stdin_default$1B);
  3276. const Tabs = withInstall(stdin_default$1D);
  3277. const [name$1p, bem$1l] = createNamespace("picker-group");
  3278. const PICKER_GROUP_KEY = Symbol(name$1p);
  3279. const pickerGroupProps = extend({
  3280. tabs: makeArrayProp(),
  3281. activeTab: makeNumericProp(0),
  3282. nextStepText: String,
  3283. showToolbar: truthProp
  3284. }, pickerToolbarProps);
  3285. var stdin_default$1A = defineComponent({
  3286. name: name$1p,
  3287. props: pickerGroupProps,
  3288. emits: ["confirm", "cancel", "update:activeTab"],
  3289. setup(props2, {
  3290. emit,
  3291. slots
  3292. }) {
  3293. const activeTab = useSyncPropRef(() => props2.activeTab, (value) => emit("update:activeTab", value));
  3294. const {
  3295. children,
  3296. linkChildren
  3297. } = useChildren(PICKER_GROUP_KEY);
  3298. linkChildren();
  3299. const showNextButton = () => +activeTab.value < props2.tabs.length - 1 && props2.nextStepText;
  3300. const onConfirm = () => {
  3301. if (showNextButton()) {
  3302. activeTab.value = +activeTab.value + 1;
  3303. } else {
  3304. emit("confirm", children.map((item) => item.confirm()));
  3305. }
  3306. };
  3307. const onCancel = () => emit("cancel");
  3308. return () => {
  3309. var _a, _b;
  3310. let childNodes = (_b = (_a = slots.default) == null ? void 0 : _a.call(slots)) == null ? void 0 : _b.filter((node) => node.type !== Comment).map((node) => {
  3311. if (node.type === Fragment) {
  3312. return node.children;
  3313. }
  3314. return node;
  3315. });
  3316. if (childNodes) {
  3317. childNodes = flat(childNodes);
  3318. }
  3319. const confirmButtonText = showNextButton() ? props2.nextStepText : props2.confirmButtonText;
  3320. return createVNode("div", {
  3321. "class": bem$1l()
  3322. }, [props2.showToolbar ? createVNode(stdin_default$1H, {
  3323. "title": props2.title,
  3324. "cancelButtonText": props2.cancelButtonText,
  3325. "confirmButtonText": confirmButtonText,
  3326. "onConfirm": onConfirm,
  3327. "onCancel": onCancel
  3328. }, pick(slots, pickerToolbarSlots)) : null, createVNode(Tabs, {
  3329. "active": activeTab.value,
  3330. "onUpdate:active": ($event) => activeTab.value = $event,
  3331. "class": bem$1l("tabs"),
  3332. "shrink": true,
  3333. "animated": true,
  3334. "lazyRender": false
  3335. }, {
  3336. default: () => [props2.tabs.map((title, index) => createVNode(Tab, {
  3337. "title": title,
  3338. "titleClass": bem$1l("tab-title")
  3339. }, {
  3340. default: () => [childNodes == null ? void 0 : childNodes[index]]
  3341. }))]
  3342. })]);
  3343. };
  3344. }
  3345. });
  3346. const pickerSharedProps = extend({
  3347. loading: Boolean,
  3348. readonly: Boolean,
  3349. allowHtml: Boolean,
  3350. optionHeight: makeNumericProp(44),
  3351. showToolbar: truthProp,
  3352. swipeDuration: makeNumericProp(1e3),
  3353. visibleOptionNum: makeNumericProp(6)
  3354. }, pickerToolbarProps);
  3355. const pickerProps = extend({}, pickerSharedProps, {
  3356. columns: makeArrayProp(),
  3357. modelValue: makeArrayProp(),
  3358. toolbarPosition: makeStringProp("top"),
  3359. columnsFieldNames: Object
  3360. });
  3361. var stdin_default$1z = defineComponent({
  3362. name: name$1z,
  3363. props: pickerProps,
  3364. emits: ["confirm", "cancel", "change", "scrollInto", "clickOption", "update:modelValue"],
  3365. setup(props2, {
  3366. emit,
  3367. slots
  3368. }) {
  3369. const columnsRef = ref();
  3370. const selectedValues = ref(props2.modelValue.slice(0));
  3371. const {
  3372. parent
  3373. } = useParent(PICKER_GROUP_KEY);
  3374. const {
  3375. children,
  3376. linkChildren
  3377. } = useChildren(PICKER_KEY);
  3378. linkChildren();
  3379. const fields = computed(() => assignDefaultFields(props2.columnsFieldNames));
  3380. const optionHeight = computed(() => unitToPx(props2.optionHeight));
  3381. const columnsType = computed(() => getColumnsType(props2.columns, fields.value));
  3382. const currentColumns = computed(() => {
  3383. const {
  3384. columns
  3385. } = props2;
  3386. switch (columnsType.value) {
  3387. case "multiple":
  3388. return columns;
  3389. case "cascade":
  3390. return formatCascadeColumns(columns, fields.value, selectedValues);
  3391. default:
  3392. return [columns];
  3393. }
  3394. });
  3395. const hasOptions = computed(() => currentColumns.value.some((options) => options.length));
  3396. const selectedOptions = computed(() => currentColumns.value.map((options, index) => findOptionByValue(options, selectedValues.value[index], fields.value)));
  3397. const selectedIndexes = computed(() => currentColumns.value.map((options, index) => options.findIndex((option) => option[fields.value.value] === selectedValues.value[index])));
  3398. const setValue = (index, value) => {
  3399. if (selectedValues.value[index] !== value) {
  3400. const newValues = selectedValues.value.slice(0);
  3401. newValues[index] = value;
  3402. selectedValues.value = newValues;
  3403. }
  3404. };
  3405. const getEventParams = () => ({
  3406. selectedValues: selectedValues.value.slice(0),
  3407. selectedOptions: selectedOptions.value,
  3408. selectedIndexes: selectedIndexes.value
  3409. });
  3410. const onChange = (value, columnIndex) => {
  3411. setValue(columnIndex, value);
  3412. if (columnsType.value === "cascade") {
  3413. selectedValues.value.forEach((value2, index) => {
  3414. const options = currentColumns.value[index];
  3415. if (!isOptionExist(options, value2, fields.value)) {
  3416. setValue(index, options.length ? options[0][fields.value.value] : void 0);
  3417. }
  3418. });
  3419. }
  3420. nextTick(() => {
  3421. emit("change", extend({
  3422. columnIndex
  3423. }, getEventParams()));
  3424. });
  3425. };
  3426. const onClickOption = (currentOption, columnIndex) => {
  3427. const params = {
  3428. columnIndex,
  3429. currentOption
  3430. };
  3431. emit("clickOption", extend(getEventParams(), params));
  3432. emit("scrollInto", params);
  3433. };
  3434. const confirm = () => {
  3435. children.forEach((child) => child.stopMomentum());
  3436. const params = getEventParams();
  3437. nextTick(() => {
  3438. emit("confirm", params);
  3439. });
  3440. return params;
  3441. };
  3442. const cancel = () => emit("cancel", getEventParams());
  3443. const renderColumnItems = () => currentColumns.value.map((options, columnIndex) => createVNode(stdin_default$1I, {
  3444. "value": selectedValues.value[columnIndex],
  3445. "fields": fields.value,
  3446. "options": options,
  3447. "readonly": props2.readonly,
  3448. "allowHtml": props2.allowHtml,
  3449. "optionHeight": optionHeight.value,
  3450. "swipeDuration": props2.swipeDuration,
  3451. "visibleOptionNum": props2.visibleOptionNum,
  3452. "onChange": (value) => onChange(value, columnIndex),
  3453. "onClickOption": (option) => onClickOption(option, columnIndex),
  3454. "onScrollInto": (option) => {
  3455. emit("scrollInto", {
  3456. currentOption: option,
  3457. columnIndex
  3458. });
  3459. }
  3460. }, {
  3461. option: slots.option
  3462. }));
  3463. const renderMask = (wrapHeight) => {
  3464. if (hasOptions.value) {
  3465. const frameStyle = {
  3466. height: `${optionHeight.value}px`
  3467. };
  3468. const maskStyle = {
  3469. backgroundSize: `100% ${(wrapHeight - optionHeight.value) / 2}px`
  3470. };
  3471. return [createVNode("div", {
  3472. "class": bem$1u("mask"),
  3473. "style": maskStyle
  3474. }, null), createVNode("div", {
  3475. "class": [BORDER_UNSET_TOP_BOTTOM, bem$1u("frame")],
  3476. "style": frameStyle
  3477. }, null)];
  3478. }
  3479. };
  3480. const renderColumns = () => {
  3481. const wrapHeight = optionHeight.value * +props2.visibleOptionNum;
  3482. const columnsStyle = {
  3483. height: `${wrapHeight}px`
  3484. };
  3485. return createVNode("div", {
  3486. "ref": columnsRef,
  3487. "class": bem$1u("columns"),
  3488. "style": columnsStyle
  3489. }, [renderColumnItems(), renderMask(wrapHeight)]);
  3490. };
  3491. const renderToolbar = () => {
  3492. if (props2.showToolbar && !parent) {
  3493. return createVNode(stdin_default$1H, mergeProps(pick(props2, pickerToolbarPropKeys), {
  3494. "onConfirm": confirm,
  3495. "onCancel": cancel
  3496. }), pick(slots, pickerToolbarSlots));
  3497. }
  3498. };
  3499. watch(currentColumns, (columns) => {
  3500. columns.forEach((options, index) => {
  3501. if (options.length && !isOptionExist(options, selectedValues.value[index], fields.value)) {
  3502. setValue(index, getFirstEnabledOption(options)[fields.value.value]);
  3503. }
  3504. });
  3505. }, {
  3506. immediate: true
  3507. });
  3508. let lastEmittedModelValue;
  3509. watch(() => props2.modelValue, (newValues) => {
  3510. if (!isSameValue(newValues, selectedValues.value) && !isSameValue(newValues, lastEmittedModelValue)) {
  3511. selectedValues.value = newValues.slice(0);
  3512. lastEmittedModelValue = newValues.slice(0);
  3513. }
  3514. }, {
  3515. deep: true
  3516. });
  3517. watch(selectedValues, (newValues) => {
  3518. if (!isSameValue(newValues, props2.modelValue)) {
  3519. lastEmittedModelValue = newValues.slice(0);
  3520. emit("update:modelValue", lastEmittedModelValue);
  3521. }
  3522. }, {
  3523. immediate: true
  3524. });
  3525. useEventListener("touchmove", preventDefault, {
  3526. target: columnsRef
  3527. });
  3528. const getSelectedOptions = () => selectedOptions.value;
  3529. useExpose({
  3530. confirm,
  3531. getSelectedOptions
  3532. });
  3533. return () => {
  3534. var _a, _b;
  3535. return createVNode("div", {
  3536. "class": bem$1u()
  3537. }, [props2.toolbarPosition === "top" ? renderToolbar() : null, props2.loading ? createVNode(Loading, {
  3538. "class": bem$1u("loading")
  3539. }, null) : null, (_a = slots["columns-top"]) == null ? void 0 : _a.call(slots), renderColumns(), (_b = slots["columns-bottom"]) == null ? void 0 : _b.call(slots), props2.toolbarPosition === "bottom" ? renderToolbar() : null]);
  3540. };
  3541. }
  3542. });
  3543. const AREA_EMPTY_CODE = "000000";
  3544. const INHERIT_SLOTS = [
  3545. "title",
  3546. "cancel",
  3547. "confirm",
  3548. "toolbar",
  3549. "columns-top",
  3550. "columns-bottom"
  3551. ];
  3552. const INHERIT_PROPS = [
  3553. "title",
  3554. "loading",
  3555. "readonly",
  3556. "optionHeight",
  3557. "swipeDuration",
  3558. "visibleOptionNum",
  3559. "cancelButtonText",
  3560. "confirmButtonText"
  3561. ];
  3562. const makeOption = (text = "", value = AREA_EMPTY_CODE, children = void 0) => ({
  3563. text,
  3564. value,
  3565. children
  3566. });
  3567. function formatDataForCascade({
  3568. areaList,
  3569. columnsNum,
  3570. columnsPlaceholder: placeholder
  3571. }) {
  3572. const {
  3573. city_list: city = {},
  3574. county_list: county = {},
  3575. province_list: province = {}
  3576. } = areaList;
  3577. const showCity = +columnsNum > 1;
  3578. const showCounty = +columnsNum > 2;
  3579. const getProvinceChildren = () => {
  3580. if (showCity) {
  3581. return placeholder.length > 1 ? [
  3582. makeOption(
  3583. placeholder[1],
  3584. AREA_EMPTY_CODE,
  3585. showCounty ? [] : void 0
  3586. )
  3587. ] : [];
  3588. }
  3589. };
  3590. const provinceMap = /* @__PURE__ */ new Map();
  3591. Object.keys(province).forEach((code) => {
  3592. provinceMap.set(
  3593. code.slice(0, 2),
  3594. makeOption(province[code], code, getProvinceChildren())
  3595. );
  3596. });
  3597. const cityMap = /* @__PURE__ */ new Map();
  3598. if (showCity) {
  3599. const getCityChildren = () => {
  3600. if (showCounty) {
  3601. return placeholder.length > 2 ? [makeOption(placeholder[2])] : [];
  3602. }
  3603. };
  3604. Object.keys(city).forEach((code) => {
  3605. const option = makeOption(city[code], code, getCityChildren());
  3606. cityMap.set(code.slice(0, 4), option);
  3607. const province2 = provinceMap.get(code.slice(0, 2));
  3608. if (province2) {
  3609. province2.children.push(option);
  3610. }
  3611. });
  3612. }
  3613. if (showCounty) {
  3614. Object.keys(county).forEach((code) => {
  3615. const city2 = cityMap.get(code.slice(0, 4));
  3616. if (city2) {
  3617. city2.children.push(makeOption(county[code], code));
  3618. }
  3619. });
  3620. }
  3621. const options = Array.from(provinceMap.values());
  3622. if (placeholder.length) {
  3623. const county2 = showCounty ? [makeOption(placeholder[2])] : void 0;
  3624. const city2 = showCity ? [makeOption(placeholder[1], AREA_EMPTY_CODE, county2)] : void 0;
  3625. options.unshift(makeOption(placeholder[0], AREA_EMPTY_CODE, city2));
  3626. }
  3627. return options;
  3628. }
  3629. const Picker = withInstall(stdin_default$1z);
  3630. const [name$1o, bem$1k] = createNamespace("area");
  3631. const areaProps = extend({}, pick(pickerSharedProps, INHERIT_PROPS), {
  3632. modelValue: String,
  3633. columnsNum: makeNumericProp(3),
  3634. columnsPlaceholder: makeArrayProp(),
  3635. areaList: {
  3636. type: Object,
  3637. default: () => ({})
  3638. }
  3639. });
  3640. var stdin_default$1y = defineComponent({
  3641. name: name$1o,
  3642. props: areaProps,
  3643. emits: ["change", "confirm", "cancel", "update:modelValue"],
  3644. setup(props2, {
  3645. emit,
  3646. slots
  3647. }) {
  3648. const codes = ref([]);
  3649. const picker = ref();
  3650. const columns = computed(() => formatDataForCascade(props2));
  3651. const onChange = (...args) => emit("change", ...args);
  3652. const onCancel = (...args) => emit("cancel", ...args);
  3653. const onConfirm = (...args) => emit("confirm", ...args);
  3654. watch(codes, (newCodes) => {
  3655. const lastCode = newCodes.length ? newCodes[newCodes.length - 1] : "";
  3656. if (lastCode && lastCode !== props2.modelValue) {
  3657. emit("update:modelValue", lastCode);
  3658. }
  3659. }, {
  3660. deep: true
  3661. });
  3662. watch(() => props2.modelValue, (newCode) => {
  3663. if (newCode) {
  3664. const lastCode = codes.value.length ? codes.value[codes.value.length - 1] : "";
  3665. if (newCode !== lastCode) {
  3666. codes.value = [`${newCode.slice(0, 2)}0000`, `${newCode.slice(0, 4)}00`, newCode].slice(0, +props2.columnsNum);
  3667. }
  3668. } else {
  3669. codes.value = [];
  3670. }
  3671. }, {
  3672. immediate: true
  3673. });
  3674. useExpose({
  3675. confirm: () => {
  3676. var _a;
  3677. return (_a = picker.value) == null ? void 0 : _a.confirm();
  3678. },
  3679. getSelectedOptions: () => {
  3680. var _a;
  3681. return ((_a = picker.value) == null ? void 0 : _a.getSelectedOptions()) || [];
  3682. }
  3683. });
  3684. return () => createVNode(Picker, mergeProps({
  3685. "ref": picker,
  3686. "modelValue": codes.value,
  3687. "onUpdate:modelValue": ($event) => codes.value = $event,
  3688. "class": bem$1k(),
  3689. "columns": columns.value,
  3690. "onChange": onChange,
  3691. "onCancel": onCancel,
  3692. "onConfirm": onConfirm
  3693. }, pick(props2, INHERIT_PROPS)), pick(slots, INHERIT_SLOTS));
  3694. }
  3695. });
  3696. const Area = withInstall(stdin_default$1y);
  3697. const [name$1n, bem$1j] = createNamespace("cell");
  3698. const cellSharedProps = {
  3699. tag: makeStringProp("div"),
  3700. icon: String,
  3701. size: String,
  3702. title: numericProp,
  3703. value: numericProp,
  3704. label: numericProp,
  3705. center: Boolean,
  3706. isLink: Boolean,
  3707. border: truthProp,
  3708. iconPrefix: String,
  3709. valueClass: unknownProp,
  3710. labelClass: unknownProp,
  3711. titleClass: unknownProp,
  3712. titleStyle: null,
  3713. arrowDirection: String,
  3714. required: {
  3715. type: [Boolean, String],
  3716. default: null
  3717. },
  3718. clickable: {
  3719. type: Boolean,
  3720. default: null
  3721. }
  3722. };
  3723. const cellProps = extend({}, cellSharedProps, routeProps);
  3724. var stdin_default$1x = defineComponent({
  3725. name: name$1n,
  3726. props: cellProps,
  3727. setup(props2, {
  3728. slots
  3729. }) {
  3730. const route2 = useRoute();
  3731. const renderLabel = () => {
  3732. const showLabel = slots.label || isDef(props2.label);
  3733. if (showLabel) {
  3734. return createVNode("div", {
  3735. "class": [bem$1j("label"), props2.labelClass]
  3736. }, [slots.label ? slots.label() : props2.label]);
  3737. }
  3738. };
  3739. const renderTitle = () => {
  3740. var _a;
  3741. if (slots.title || isDef(props2.title)) {
  3742. const titleSlot = (_a = slots.title) == null ? void 0 : _a.call(slots);
  3743. if (Array.isArray(titleSlot) && titleSlot.length === 0) {
  3744. return;
  3745. }
  3746. return createVNode("div", {
  3747. "class": [bem$1j("title"), props2.titleClass],
  3748. "style": props2.titleStyle
  3749. }, [titleSlot || createVNode("span", null, [props2.title]), renderLabel()]);
  3750. }
  3751. };
  3752. const renderValue = () => {
  3753. const slot = slots.value || slots.default;
  3754. const hasValue = slot || isDef(props2.value);
  3755. if (hasValue) {
  3756. return createVNode("div", {
  3757. "class": [bem$1j("value"), props2.valueClass]
  3758. }, [slot ? slot() : createVNode("span", null, [props2.value])]);
  3759. }
  3760. };
  3761. const renderLeftIcon = () => {
  3762. if (slots.icon) {
  3763. return slots.icon();
  3764. }
  3765. if (props2.icon) {
  3766. return createVNode(Icon, {
  3767. "name": props2.icon,
  3768. "class": bem$1j("left-icon"),
  3769. "classPrefix": props2.iconPrefix
  3770. }, null);
  3771. }
  3772. };
  3773. const renderRightIcon = () => {
  3774. if (slots["right-icon"]) {
  3775. return slots["right-icon"]();
  3776. }
  3777. if (props2.isLink) {
  3778. const name2 = props2.arrowDirection && props2.arrowDirection !== "right" ? `arrow-${props2.arrowDirection}` : "arrow";
  3779. return createVNode(Icon, {
  3780. "name": name2,
  3781. "class": bem$1j("right-icon")
  3782. }, null);
  3783. }
  3784. };
  3785. return () => {
  3786. var _a;
  3787. const {
  3788. tag,
  3789. size,
  3790. center,
  3791. border,
  3792. isLink,
  3793. required
  3794. } = props2;
  3795. const clickable = (_a = props2.clickable) != null ? _a : isLink;
  3796. const classes = {
  3797. center,
  3798. required: !!required,
  3799. clickable,
  3800. borderless: !border
  3801. };
  3802. if (size) {
  3803. classes[size] = !!size;
  3804. }
  3805. return createVNode(tag, {
  3806. "class": bem$1j(classes),
  3807. "role": clickable ? "button" : void 0,
  3808. "tabindex": clickable ? 0 : void 0,
  3809. "onClick": route2
  3810. }, {
  3811. default: () => {
  3812. var _a2;
  3813. return [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_a2 = slots.extra) == null ? void 0 : _a2.call(slots)];
  3814. }
  3815. });
  3816. };
  3817. }
  3818. });
  3819. const Cell = withInstall(stdin_default$1x);
  3820. const [name$1m, bem$1i] = createNamespace("form");
  3821. const formProps = {
  3822. colon: Boolean,
  3823. disabled: Boolean,
  3824. readonly: Boolean,
  3825. required: [Boolean, String],
  3826. showError: Boolean,
  3827. labelWidth: numericProp,
  3828. labelAlign: String,
  3829. inputAlign: String,
  3830. scrollToError: Boolean,
  3831. scrollToErrorPosition: String,
  3832. validateFirst: Boolean,
  3833. submitOnEnter: truthProp,
  3834. showErrorMessage: truthProp,
  3835. errorMessageAlign: String,
  3836. validateTrigger: {
  3837. type: [String, Array],
  3838. default: "onBlur"
  3839. }
  3840. };
  3841. var stdin_default$1w = defineComponent({
  3842. name: name$1m,
  3843. props: formProps,
  3844. emits: ["submit", "failed"],
  3845. setup(props2, {
  3846. emit,
  3847. slots
  3848. }) {
  3849. const {
  3850. children,
  3851. linkChildren
  3852. } = useChildren(FORM_KEY);
  3853. const getFieldsByNames = (names) => {
  3854. if (names) {
  3855. return children.filter((field) => names.includes(field.name));
  3856. }
  3857. return children;
  3858. };
  3859. const validateSeq = (names) => new Promise((resolve, reject) => {
  3860. const errors = [];
  3861. const fields = getFieldsByNames(names);
  3862. fields.reduce((promise, field) => promise.then(() => {
  3863. if (!errors.length) {
  3864. return field.validate().then((error) => {
  3865. if (error) {
  3866. errors.push(error);
  3867. }
  3868. });
  3869. }
  3870. }), Promise.resolve()).then(() => {
  3871. if (errors.length) {
  3872. reject(errors);
  3873. } else {
  3874. resolve();
  3875. }
  3876. });
  3877. });
  3878. const validateAll = (names) => new Promise((resolve, reject) => {
  3879. const fields = getFieldsByNames(names);
  3880. Promise.all(fields.map((item) => item.validate())).then((errors) => {
  3881. errors = errors.filter(Boolean);
  3882. if (errors.length) {
  3883. reject(errors);
  3884. } else {
  3885. resolve();
  3886. }
  3887. });
  3888. });
  3889. const validateField = (name2) => {
  3890. const matched = children.find((item) => item.name === name2);
  3891. if (matched) {
  3892. return new Promise((resolve, reject) => {
  3893. matched.validate().then((error) => {
  3894. if (error) {
  3895. reject(error);
  3896. } else {
  3897. resolve();
  3898. }
  3899. });
  3900. });
  3901. }
  3902. return Promise.reject();
  3903. };
  3904. const validate = (name2) => {
  3905. if (typeof name2 === "string") {
  3906. return validateField(name2);
  3907. }
  3908. return props2.validateFirst ? validateSeq(name2) : validateAll(name2);
  3909. };
  3910. const resetValidation = (name2) => {
  3911. if (typeof name2 === "string") {
  3912. name2 = [name2];
  3913. }
  3914. const fields = getFieldsByNames(name2);
  3915. fields.forEach((item) => {
  3916. item.resetValidation();
  3917. });
  3918. };
  3919. const getValidationStatus = () => children.reduce((form, field) => {
  3920. form[field.name] = field.getValidationStatus();
  3921. return form;
  3922. }, {});
  3923. const scrollToField = (name2, options) => {
  3924. children.some((item) => {
  3925. if (item.name === name2) {
  3926. item.$el.scrollIntoView(options);
  3927. return true;
  3928. }
  3929. return false;
  3930. });
  3931. };
  3932. const getValues = () => children.reduce((form, field) => {
  3933. if (field.name !== void 0) {
  3934. form[field.name] = field.formValue.value;
  3935. }
  3936. return form;
  3937. }, {});
  3938. const submit = () => {
  3939. const values = getValues();
  3940. validate().then(() => emit("submit", values)).catch((errors) => {
  3941. emit("failed", {
  3942. values,
  3943. errors
  3944. });
  3945. const {
  3946. scrollToError,
  3947. scrollToErrorPosition
  3948. } = props2;
  3949. if (scrollToError && errors[0].name) {
  3950. scrollToField(errors[0].name, scrollToErrorPosition ? {
  3951. block: scrollToErrorPosition
  3952. } : void 0);
  3953. }
  3954. });
  3955. };
  3956. const onSubmit = (event) => {
  3957. preventDefault(event);
  3958. submit();
  3959. };
  3960. linkChildren({
  3961. props: props2
  3962. });
  3963. useExpose({
  3964. submit,
  3965. validate,
  3966. getValues,
  3967. scrollToField,
  3968. resetValidation,
  3969. getValidationStatus
  3970. });
  3971. return () => {
  3972. var _a;
  3973. return createVNode("form", {
  3974. "class": bem$1i(),
  3975. "onSubmit": onSubmit
  3976. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  3977. };
  3978. }
  3979. });
  3980. const Form = withInstall(stdin_default$1w);
  3981. function isEmptyValue(value) {
  3982. if (Array.isArray(value)) {
  3983. return !value.length;
  3984. }
  3985. if (value === 0) {
  3986. return false;
  3987. }
  3988. return !value;
  3989. }
  3990. function runSyncRule(value, rule) {
  3991. if (isEmptyValue(value)) {
  3992. if (rule.required) {
  3993. return false;
  3994. }
  3995. if (rule.validateEmpty === false) {
  3996. return true;
  3997. }
  3998. }
  3999. if (rule.pattern && !rule.pattern.test(String(value))) {
  4000. return false;
  4001. }
  4002. return true;
  4003. }
  4004. function runRuleValidator(value, rule) {
  4005. return new Promise((resolve) => {
  4006. const returnVal = rule.validator(value, rule);
  4007. if (isPromise(returnVal)) {
  4008. returnVal.then(resolve);
  4009. return;
  4010. }
  4011. resolve(returnVal);
  4012. });
  4013. }
  4014. function getRuleMessage(value, rule) {
  4015. const { message } = rule;
  4016. if (isFunction(message)) {
  4017. return message(value, rule);
  4018. }
  4019. return message || "";
  4020. }
  4021. function startComposing({ target }) {
  4022. target.composing = true;
  4023. }
  4024. function endComposing({ target }) {
  4025. if (target.composing) {
  4026. target.composing = false;
  4027. target.dispatchEvent(new Event("input"));
  4028. }
  4029. }
  4030. function resizeTextarea(input, autosize) {
  4031. const scrollTop = getRootScrollTop();
  4032. input.style.height = "auto";
  4033. let height = input.scrollHeight;
  4034. if (isObject(autosize)) {
  4035. const { maxHeight, minHeight } = autosize;
  4036. if (maxHeight !== void 0) {
  4037. height = Math.min(height, maxHeight);
  4038. }
  4039. if (minHeight !== void 0) {
  4040. height = Math.max(height, minHeight);
  4041. }
  4042. }
  4043. if (height) {
  4044. input.style.height = `${height}px`;
  4045. setRootScrollTop(scrollTop);
  4046. }
  4047. }
  4048. function mapInputType(type, inputmode) {
  4049. if (type === "number") {
  4050. type = "text";
  4051. inputmode != null ? inputmode : inputmode = "decimal";
  4052. }
  4053. if (type === "digit") {
  4054. type = "tel";
  4055. inputmode != null ? inputmode : inputmode = "numeric";
  4056. }
  4057. return { type, inputmode };
  4058. }
  4059. function getStringLength(str) {
  4060. return [...str].length;
  4061. }
  4062. function cutString(str, maxlength) {
  4063. return [...str].slice(0, maxlength).join("");
  4064. }
  4065. const [name$1l, bem$1h] = createNamespace("field");
  4066. const fieldSharedProps = {
  4067. id: String,
  4068. name: String,
  4069. leftIcon: String,
  4070. rightIcon: String,
  4071. autofocus: Boolean,
  4072. clearable: Boolean,
  4073. maxlength: numericProp,
  4074. max: Number,
  4075. min: Number,
  4076. formatter: Function,
  4077. clearIcon: makeStringProp("clear"),
  4078. modelValue: makeNumericProp(""),
  4079. inputAlign: String,
  4080. placeholder: String,
  4081. autocomplete: String,
  4082. autocapitalize: String,
  4083. autocorrect: String,
  4084. errorMessage: String,
  4085. enterkeyhint: String,
  4086. clearTrigger: makeStringProp("focus"),
  4087. formatTrigger: makeStringProp("onChange"),
  4088. spellcheck: {
  4089. type: Boolean,
  4090. default: null
  4091. },
  4092. error: {
  4093. type: Boolean,
  4094. default: null
  4095. },
  4096. disabled: {
  4097. type: Boolean,
  4098. default: null
  4099. },
  4100. readonly: {
  4101. type: Boolean,
  4102. default: null
  4103. },
  4104. inputmode: String
  4105. };
  4106. const fieldProps = extend({}, cellSharedProps, fieldSharedProps, {
  4107. rows: numericProp,
  4108. type: makeStringProp("text"),
  4109. rules: Array,
  4110. autosize: [Boolean, Object],
  4111. labelWidth: numericProp,
  4112. labelClass: unknownProp,
  4113. labelAlign: String,
  4114. showWordLimit: Boolean,
  4115. errorMessageAlign: String,
  4116. colon: {
  4117. type: Boolean,
  4118. default: null
  4119. }
  4120. });
  4121. var stdin_default$1v = defineComponent({
  4122. name: name$1l,
  4123. props: fieldProps,
  4124. emits: ["blur", "focus", "clear", "keypress", "clickInput", "endValidate", "startValidate", "clickLeftIcon", "clickRightIcon", "update:modelValue"],
  4125. setup(props2, {
  4126. emit,
  4127. slots
  4128. }) {
  4129. const id = useId();
  4130. const state = reactive({
  4131. status: "unvalidated",
  4132. focused: false,
  4133. validateMessage: ""
  4134. });
  4135. const inputRef = ref();
  4136. const clearIconRef = ref();
  4137. const customValue = ref();
  4138. const {
  4139. parent: form
  4140. } = useParent(FORM_KEY);
  4141. const getModelValue = () => {
  4142. var _a;
  4143. return String((_a = props2.modelValue) != null ? _a : "");
  4144. };
  4145. const getProp = (key) => {
  4146. if (isDef(props2[key])) {
  4147. return props2[key];
  4148. }
  4149. if (form && isDef(form.props[key])) {
  4150. return form.props[key];
  4151. }
  4152. };
  4153. const showClear = computed(() => {
  4154. const readonly = getProp("readonly");
  4155. if (props2.clearable && !readonly) {
  4156. const hasValue = getModelValue() !== "";
  4157. const trigger = props2.clearTrigger === "always" || props2.clearTrigger === "focus" && state.focused;
  4158. return hasValue && trigger;
  4159. }
  4160. return false;
  4161. });
  4162. const formValue = computed(() => {
  4163. if (customValue.value && slots.input) {
  4164. return customValue.value();
  4165. }
  4166. return props2.modelValue;
  4167. });
  4168. const showRequiredMark = computed(() => {
  4169. var _a;
  4170. const required = getProp("required");
  4171. if (required === "auto") {
  4172. return (_a = props2.rules) == null ? void 0 : _a.some((rule) => rule.required);
  4173. }
  4174. return required;
  4175. });
  4176. const runRules = (rules) => rules.reduce((promise, rule) => promise.then(() => {
  4177. if (state.status === "failed") {
  4178. return;
  4179. }
  4180. let {
  4181. value
  4182. } = formValue;
  4183. if (rule.formatter) {
  4184. value = rule.formatter(value, rule);
  4185. }
  4186. if (!runSyncRule(value, rule)) {
  4187. state.status = "failed";
  4188. state.validateMessage = getRuleMessage(value, rule);
  4189. return;
  4190. }
  4191. if (rule.validator) {
  4192. if (isEmptyValue(value) && rule.validateEmpty === false) {
  4193. return;
  4194. }
  4195. return runRuleValidator(value, rule).then((result) => {
  4196. if (result && typeof result === "string") {
  4197. state.status = "failed";
  4198. state.validateMessage = result;
  4199. } else if (result === false) {
  4200. state.status = "failed";
  4201. state.validateMessage = getRuleMessage(value, rule);
  4202. }
  4203. });
  4204. }
  4205. }), Promise.resolve());
  4206. const resetValidation = () => {
  4207. state.status = "unvalidated";
  4208. state.validateMessage = "";
  4209. };
  4210. const endValidate = () => emit("endValidate", {
  4211. status: state.status,
  4212. message: state.validateMessage
  4213. });
  4214. const validate = (rules = props2.rules) => new Promise((resolve) => {
  4215. resetValidation();
  4216. if (rules) {
  4217. emit("startValidate");
  4218. runRules(rules).then(() => {
  4219. if (state.status === "failed") {
  4220. resolve({
  4221. name: props2.name,
  4222. message: state.validateMessage
  4223. });
  4224. endValidate();
  4225. } else {
  4226. state.status = "passed";
  4227. resolve();
  4228. endValidate();
  4229. }
  4230. });
  4231. } else {
  4232. resolve();
  4233. }
  4234. });
  4235. const validateWithTrigger = (trigger) => {
  4236. if (form && props2.rules) {
  4237. const {
  4238. validateTrigger
  4239. } = form.props;
  4240. const defaultTrigger = toArray(validateTrigger).includes(trigger);
  4241. const rules = props2.rules.filter((rule) => {
  4242. if (rule.trigger) {
  4243. return toArray(rule.trigger).includes(trigger);
  4244. }
  4245. return defaultTrigger;
  4246. });
  4247. if (rules.length) {
  4248. validate(rules);
  4249. }
  4250. }
  4251. };
  4252. const limitValueLength = (value) => {
  4253. var _a;
  4254. const {
  4255. maxlength
  4256. } = props2;
  4257. if (isDef(maxlength) && getStringLength(value) > +maxlength) {
  4258. const modelValue = getModelValue();
  4259. if (modelValue && getStringLength(modelValue) === +maxlength) {
  4260. return modelValue;
  4261. }
  4262. const selectionEnd = (_a = inputRef.value) == null ? void 0 : _a.selectionEnd;
  4263. if (state.focused && selectionEnd) {
  4264. const valueArr = [...value];
  4265. const exceededLength = valueArr.length - +maxlength;
  4266. valueArr.splice(selectionEnd - exceededLength, exceededLength);
  4267. return valueArr.join("");
  4268. }
  4269. return cutString(value, +maxlength);
  4270. }
  4271. return value;
  4272. };
  4273. const updateValue = (value, trigger = "onChange") => {
  4274. var _a, _b;
  4275. const originalValue = value;
  4276. value = limitValueLength(value);
  4277. const limitDiffLen = getStringLength(originalValue) - getStringLength(value);
  4278. if (props2.type === "number" || props2.type === "digit") {
  4279. const isNumber = props2.type === "number";
  4280. value = formatNumber(value, isNumber, isNumber);
  4281. if (trigger === "onBlur" && value !== "" && (props2.min !== void 0 || props2.max !== void 0)) {
  4282. const adjustedValue = clamp(+value, (_a = props2.min) != null ? _a : -Infinity, (_b = props2.max) != null ? _b : Infinity);
  4283. value = adjustedValue.toString();
  4284. }
  4285. }
  4286. let formatterDiffLen = 0;
  4287. if (props2.formatter && trigger === props2.formatTrigger) {
  4288. const {
  4289. formatter,
  4290. maxlength
  4291. } = props2;
  4292. value = formatter(value);
  4293. if (isDef(maxlength) && getStringLength(value) > +maxlength) {
  4294. value = cutString(value, +maxlength);
  4295. }
  4296. if (inputRef.value && state.focused) {
  4297. const {
  4298. selectionEnd
  4299. } = inputRef.value;
  4300. const bcoVal = cutString(originalValue, selectionEnd);
  4301. formatterDiffLen = getStringLength(formatter(bcoVal)) - getStringLength(bcoVal);
  4302. }
  4303. }
  4304. if (inputRef.value && inputRef.value.value !== value) {
  4305. if (state.focused) {
  4306. let {
  4307. selectionStart,
  4308. selectionEnd
  4309. } = inputRef.value;
  4310. inputRef.value.value = value;
  4311. if (isDef(selectionStart) && isDef(selectionEnd)) {
  4312. const valueLen = getStringLength(value);
  4313. if (limitDiffLen) {
  4314. selectionStart -= limitDiffLen;
  4315. selectionEnd -= limitDiffLen;
  4316. } else if (formatterDiffLen) {
  4317. selectionStart += formatterDiffLen;
  4318. selectionEnd += formatterDiffLen;
  4319. }
  4320. inputRef.value.setSelectionRange(Math.min(selectionStart, valueLen), Math.min(selectionEnd, valueLen));
  4321. }
  4322. } else {
  4323. inputRef.value.value = value;
  4324. }
  4325. }
  4326. if (value !== props2.modelValue) {
  4327. emit("update:modelValue", value);
  4328. }
  4329. };
  4330. const onInput = (event) => {
  4331. if (!event.target.composing) {
  4332. updateValue(event.target.value);
  4333. }
  4334. };
  4335. const blur = () => {
  4336. var _a;
  4337. return (_a = inputRef.value) == null ? void 0 : _a.blur();
  4338. };
  4339. const focus = () => {
  4340. var _a;
  4341. return (_a = inputRef.value) == null ? void 0 : _a.focus();
  4342. };
  4343. const adjustTextareaSize = () => {
  4344. const input = inputRef.value;
  4345. if (props2.type === "textarea" && props2.autosize && input) {
  4346. resizeTextarea(input, props2.autosize);
  4347. }
  4348. };
  4349. const onFocus = (event) => {
  4350. state.focused = true;
  4351. emit("focus", event);
  4352. nextTick(adjustTextareaSize);
  4353. if (getProp("readonly")) {
  4354. blur();
  4355. }
  4356. };
  4357. const onBlur = (event) => {
  4358. state.focused = false;
  4359. updateValue(getModelValue(), "onBlur");
  4360. emit("blur", event);
  4361. if (getProp("readonly")) {
  4362. return;
  4363. }
  4364. validateWithTrigger("onBlur");
  4365. nextTick(adjustTextareaSize);
  4366. resetScroll();
  4367. };
  4368. const onClickInput = (event) => emit("clickInput", event);
  4369. const onClickLeftIcon = (event) => emit("clickLeftIcon", event);
  4370. const onClickRightIcon = (event) => emit("clickRightIcon", event);
  4371. const onClear = (event) => {
  4372. preventDefault(event);
  4373. emit("update:modelValue", "");
  4374. emit("clear", event);
  4375. };
  4376. const showError = computed(() => {
  4377. if (typeof props2.error === "boolean") {
  4378. return props2.error;
  4379. }
  4380. if (form && form.props.showError && state.status === "failed") {
  4381. return true;
  4382. }
  4383. });
  4384. const labelStyle = computed(() => {
  4385. const labelWidth = getProp("labelWidth");
  4386. const labelAlign = getProp("labelAlign");
  4387. if (labelWidth && labelAlign !== "top") {
  4388. return {
  4389. width: addUnit(labelWidth)
  4390. };
  4391. }
  4392. });
  4393. const onKeypress = (event) => {
  4394. const ENTER_CODE = 13;
  4395. if (event.keyCode === ENTER_CODE) {
  4396. const submitOnEnter = form && form.props.submitOnEnter;
  4397. if (!submitOnEnter && props2.type !== "textarea") {
  4398. preventDefault(event);
  4399. }
  4400. if (props2.type === "search") {
  4401. blur();
  4402. }
  4403. }
  4404. emit("keypress", event);
  4405. };
  4406. const getInputId = () => props2.id || `${id}-input`;
  4407. const getValidationStatus = () => state.status;
  4408. const renderInput = () => {
  4409. const controlClass = bem$1h("control", [getProp("inputAlign"), {
  4410. error: showError.value,
  4411. custom: !!slots.input,
  4412. "min-height": props2.type === "textarea" && !props2.autosize
  4413. }]);
  4414. if (slots.input) {
  4415. return createVNode("div", {
  4416. "class": controlClass,
  4417. "onClick": onClickInput
  4418. }, [slots.input()]);
  4419. }
  4420. const inputAttrs = {
  4421. id: getInputId(),
  4422. ref: inputRef,
  4423. name: props2.name,
  4424. rows: props2.rows !== void 0 ? +props2.rows : void 0,
  4425. class: controlClass,
  4426. disabled: getProp("disabled"),
  4427. readonly: getProp("readonly"),
  4428. autofocus: props2.autofocus,
  4429. placeholder: props2.placeholder,
  4430. autocomplete: props2.autocomplete,
  4431. autocapitalize: props2.autocapitalize,
  4432. autocorrect: props2.autocorrect,
  4433. enterkeyhint: props2.enterkeyhint,
  4434. spellcheck: props2.spellcheck,
  4435. "aria-labelledby": props2.label ? `${id}-label` : void 0,
  4436. "data-allow-mismatch": "attribute",
  4437. onBlur,
  4438. onFocus,
  4439. onInput,
  4440. onClick: onClickInput,
  4441. onChange: endComposing,
  4442. onKeypress,
  4443. onCompositionend: endComposing,
  4444. onCompositionstart: startComposing
  4445. };
  4446. if (props2.type === "textarea") {
  4447. return createVNode("textarea", mergeProps(inputAttrs, {
  4448. "inputmode": props2.inputmode
  4449. }), null);
  4450. }
  4451. return createVNode("input", mergeProps(mapInputType(props2.type, props2.inputmode), inputAttrs), null);
  4452. };
  4453. const renderLeftIcon = () => {
  4454. const leftIconSlot = slots["left-icon"];
  4455. if (props2.leftIcon || leftIconSlot) {
  4456. return createVNode("div", {
  4457. "class": bem$1h("left-icon"),
  4458. "onClick": onClickLeftIcon
  4459. }, [leftIconSlot ? leftIconSlot() : createVNode(Icon, {
  4460. "name": props2.leftIcon,
  4461. "classPrefix": props2.iconPrefix
  4462. }, null)]);
  4463. }
  4464. };
  4465. const renderRightIcon = () => {
  4466. const rightIconSlot = slots["right-icon"];
  4467. if (props2.rightIcon || rightIconSlot) {
  4468. return createVNode("div", {
  4469. "class": bem$1h("right-icon"),
  4470. "onClick": onClickRightIcon
  4471. }, [rightIconSlot ? rightIconSlot() : createVNode(Icon, {
  4472. "name": props2.rightIcon,
  4473. "classPrefix": props2.iconPrefix
  4474. }, null)]);
  4475. }
  4476. };
  4477. const renderWordLimit = () => {
  4478. if (props2.showWordLimit && props2.maxlength) {
  4479. const count = getStringLength(getModelValue());
  4480. return createVNode("div", {
  4481. "class": bem$1h("word-limit")
  4482. }, [createVNode("span", {
  4483. "class": bem$1h("word-num")
  4484. }, [count]), createTextVNode("/"), props2.maxlength]);
  4485. }
  4486. };
  4487. const renderMessage = () => {
  4488. if (form && form.props.showErrorMessage === false) {
  4489. return;
  4490. }
  4491. const message = props2.errorMessage || state.validateMessage;
  4492. if (message) {
  4493. const slot = slots["error-message"];
  4494. const errorMessageAlign = getProp("errorMessageAlign");
  4495. return createVNode("div", {
  4496. "class": bem$1h("error-message", errorMessageAlign)
  4497. }, [slot ? slot({
  4498. message
  4499. }) : message]);
  4500. }
  4501. };
  4502. const renderLabel = () => {
  4503. const labelWidth = getProp("labelWidth");
  4504. const labelAlign = getProp("labelAlign");
  4505. const colon = getProp("colon") ? ":" : "";
  4506. if (slots.label) {
  4507. return [slots.label(), colon];
  4508. }
  4509. if (props2.label) {
  4510. return createVNode("label", {
  4511. "id": `${id}-label`,
  4512. "for": slots.input ? void 0 : getInputId(),
  4513. "data-allow-mismatch": "attribute",
  4514. "onClick": (event) => {
  4515. preventDefault(event);
  4516. focus();
  4517. },
  4518. "style": labelAlign === "top" && labelWidth ? {
  4519. width: addUnit(labelWidth)
  4520. } : void 0
  4521. }, [props2.label + colon]);
  4522. }
  4523. };
  4524. const renderFieldBody = () => [createVNode("div", {
  4525. "class": bem$1h("body")
  4526. }, [renderInput(), showClear.value && createVNode(Icon, {
  4527. "ref": clearIconRef,
  4528. "name": props2.clearIcon,
  4529. "class": bem$1h("clear")
  4530. }, null), renderRightIcon(), slots.button && createVNode("div", {
  4531. "class": bem$1h("button")
  4532. }, [slots.button()])]), renderWordLimit(), renderMessage()];
  4533. useExpose({
  4534. blur,
  4535. focus,
  4536. validate,
  4537. formValue,
  4538. resetValidation,
  4539. getValidationStatus
  4540. });
  4541. provide(CUSTOM_FIELD_INJECTION_KEY, {
  4542. customValue,
  4543. resetValidation,
  4544. validateWithTrigger
  4545. });
  4546. watch(() => props2.modelValue, () => {
  4547. updateValue(getModelValue());
  4548. resetValidation();
  4549. validateWithTrigger("onChange");
  4550. nextTick(adjustTextareaSize);
  4551. });
  4552. onMounted(() => {
  4553. updateValue(getModelValue(), props2.formatTrigger);
  4554. nextTick(adjustTextareaSize);
  4555. });
  4556. useEventListener("touchstart", onClear, {
  4557. target: computed(() => {
  4558. var _a;
  4559. return (_a = clearIconRef.value) == null ? void 0 : _a.$el;
  4560. })
  4561. });
  4562. return () => {
  4563. const disabled = getProp("disabled");
  4564. const labelAlign = getProp("labelAlign");
  4565. const LeftIcon = renderLeftIcon();
  4566. const renderTitle = () => {
  4567. const Label = renderLabel();
  4568. if (labelAlign === "top") {
  4569. return [LeftIcon, Label].filter(Boolean);
  4570. }
  4571. return Label || [];
  4572. };
  4573. return createVNode(Cell, {
  4574. "size": props2.size,
  4575. "class": bem$1h({
  4576. error: showError.value,
  4577. disabled,
  4578. [`label-${labelAlign}`]: labelAlign
  4579. }),
  4580. "center": props2.center,
  4581. "border": props2.border,
  4582. "isLink": props2.isLink,
  4583. "clickable": props2.clickable,
  4584. "titleStyle": labelStyle.value,
  4585. "valueClass": bem$1h("value"),
  4586. "titleClass": [bem$1h("label", [labelAlign, {
  4587. required: showRequiredMark.value
  4588. }]), props2.labelClass],
  4589. "arrowDirection": props2.arrowDirection
  4590. }, {
  4591. icon: LeftIcon && labelAlign !== "top" ? () => LeftIcon : null,
  4592. title: renderTitle,
  4593. value: renderFieldBody,
  4594. extra: slots.extra
  4595. });
  4596. };
  4597. }
  4598. });
  4599. const Field = withInstall(stdin_default$1v);
  4600. let lockCount = 0;
  4601. function lockClick(lock) {
  4602. if (lock) {
  4603. if (!lockCount) {
  4604. document.body.classList.add("van-toast--unclickable");
  4605. }
  4606. lockCount++;
  4607. } else if (lockCount) {
  4608. lockCount--;
  4609. if (!lockCount) {
  4610. document.body.classList.remove("van-toast--unclickable");
  4611. }
  4612. }
  4613. }
  4614. const [name$1k, bem$1g] = createNamespace("toast");
  4615. const popupInheritProps$1 = ["show", "overlay", "teleport", "transition", "overlayClass", "overlayStyle", "closeOnClickOverlay", "zIndex"];
  4616. const toastProps = {
  4617. icon: String,
  4618. show: Boolean,
  4619. type: makeStringProp("text"),
  4620. overlay: Boolean,
  4621. message: numericProp,
  4622. iconSize: numericProp,
  4623. duration: makeNumberProp(2e3),
  4624. position: makeStringProp("middle"),
  4625. teleport: [String, Object],
  4626. wordBreak: String,
  4627. className: unknownProp,
  4628. iconPrefix: String,
  4629. transition: makeStringProp("van-fade"),
  4630. loadingType: String,
  4631. forbidClick: Boolean,
  4632. overlayClass: unknownProp,
  4633. overlayStyle: Object,
  4634. closeOnClick: Boolean,
  4635. closeOnClickOverlay: Boolean,
  4636. zIndex: numericProp
  4637. };
  4638. var stdin_default$1u = defineComponent({
  4639. name: name$1k,
  4640. props: toastProps,
  4641. emits: ["update:show"],
  4642. setup(props2, {
  4643. emit,
  4644. slots
  4645. }) {
  4646. let timer2;
  4647. let clickable = false;
  4648. const toggleClickable = () => {
  4649. const newValue = props2.show && props2.forbidClick;
  4650. if (clickable !== newValue) {
  4651. clickable = newValue;
  4652. lockClick(clickable);
  4653. }
  4654. };
  4655. const updateShow = (show) => emit("update:show", show);
  4656. const onClick = () => {
  4657. if (props2.closeOnClick) {
  4658. updateShow(false);
  4659. }
  4660. };
  4661. const clearTimer = () => clearTimeout(timer2);
  4662. const renderIcon = () => {
  4663. const {
  4664. icon,
  4665. type,
  4666. iconSize,
  4667. iconPrefix,
  4668. loadingType
  4669. } = props2;
  4670. const hasIcon = icon || type === "success" || type === "fail";
  4671. if (hasIcon) {
  4672. return createVNode(Icon, {
  4673. "name": icon || type,
  4674. "size": iconSize,
  4675. "class": bem$1g("icon"),
  4676. "classPrefix": iconPrefix
  4677. }, null);
  4678. }
  4679. if (type === "loading") {
  4680. return createVNode(Loading, {
  4681. "class": bem$1g("loading"),
  4682. "size": iconSize,
  4683. "type": loadingType
  4684. }, null);
  4685. }
  4686. };
  4687. const renderMessage = () => {
  4688. const {
  4689. type,
  4690. message
  4691. } = props2;
  4692. if (slots.message) {
  4693. return createVNode("div", {
  4694. "class": bem$1g("text")
  4695. }, [slots.message()]);
  4696. }
  4697. if (isDef(message) && message !== "") {
  4698. return type === "html" ? createVNode("div", {
  4699. "key": 0,
  4700. "class": bem$1g("text"),
  4701. "innerHTML": String(message)
  4702. }, null) : createVNode("div", {
  4703. "class": bem$1g("text")
  4704. }, [message]);
  4705. }
  4706. };
  4707. watch(() => [props2.show, props2.forbidClick], toggleClickable);
  4708. watch(() => [props2.show, props2.type, props2.message, props2.duration], () => {
  4709. clearTimer();
  4710. if (props2.show && props2.duration > 0) {
  4711. timer2 = setTimeout(() => {
  4712. updateShow(false);
  4713. }, props2.duration);
  4714. }
  4715. });
  4716. onMounted(toggleClickable);
  4717. onUnmounted(toggleClickable);
  4718. return () => createVNode(Popup, mergeProps({
  4719. "class": [bem$1g([props2.position, props2.wordBreak === "normal" ? "break-normal" : props2.wordBreak, {
  4720. [props2.type]: !props2.icon
  4721. }]), props2.className],
  4722. "lockScroll": false,
  4723. "onClick": onClick,
  4724. "onClosed": clearTimer,
  4725. "onUpdate:show": updateShow
  4726. }, pick(props2, popupInheritProps$1)), {
  4727. default: () => [renderIcon(), renderMessage()]
  4728. });
  4729. }
  4730. });
  4731. function usePopupState() {
  4732. const state = reactive({
  4733. show: false
  4734. });
  4735. const toggle = (show) => {
  4736. state.show = show;
  4737. };
  4738. const open = (props2) => {
  4739. extend(state, props2, { transitionAppear: true });
  4740. toggle(true);
  4741. };
  4742. const close = () => toggle(false);
  4743. useExpose({ open, close, toggle });
  4744. return {
  4745. open,
  4746. close,
  4747. state,
  4748. toggle
  4749. };
  4750. }
  4751. function mountComponent(RootComponent) {
  4752. const app = createApp(RootComponent);
  4753. const root = document.createElement("div");
  4754. document.body.appendChild(root);
  4755. return {
  4756. instance: app.mount(root),
  4757. unmount() {
  4758. app.unmount();
  4759. document.body.removeChild(root);
  4760. }
  4761. };
  4762. }
  4763. const defaultOptions$1 = {
  4764. icon: "",
  4765. type: "text",
  4766. message: "",
  4767. className: "",
  4768. overlay: false,
  4769. onClose: void 0,
  4770. onOpened: void 0,
  4771. duration: 2e3,
  4772. teleport: "body",
  4773. iconSize: void 0,
  4774. iconPrefix: void 0,
  4775. position: "middle",
  4776. transition: "van-fade",
  4777. forbidClick: false,
  4778. loadingType: void 0,
  4779. overlayClass: "",
  4780. overlayStyle: void 0,
  4781. closeOnClick: false,
  4782. closeOnClickOverlay: false
  4783. };
  4784. let queue = [];
  4785. let allowMultiple = false;
  4786. let currentOptions$2 = extend({}, defaultOptions$1);
  4787. const defaultOptionsMap = /* @__PURE__ */ new Map();
  4788. function parseOptions$1(message) {
  4789. if (isObject(message)) {
  4790. return message;
  4791. }
  4792. return {
  4793. message
  4794. };
  4795. }
  4796. function createInstance() {
  4797. const {
  4798. instance: instance2,
  4799. unmount
  4800. } = mountComponent({
  4801. setup() {
  4802. const message = ref("");
  4803. const {
  4804. open,
  4805. state,
  4806. close,
  4807. toggle
  4808. } = usePopupState();
  4809. const onClosed = () => {
  4810. if (allowMultiple) {
  4811. queue = queue.filter((item) => item !== instance2);
  4812. unmount();
  4813. }
  4814. };
  4815. const render = () => {
  4816. const attrs = {
  4817. onClosed,
  4818. "onUpdate:show": toggle
  4819. };
  4820. return createVNode(stdin_default$1u, mergeProps(state, attrs), null);
  4821. };
  4822. watch(message, (val) => {
  4823. state.message = val;
  4824. });
  4825. getCurrentInstance().render = render;
  4826. return {
  4827. open,
  4828. close,
  4829. message
  4830. };
  4831. }
  4832. });
  4833. return instance2;
  4834. }
  4835. function getInstance() {
  4836. if (!queue.length || allowMultiple) {
  4837. const instance2 = createInstance();
  4838. queue.push(instance2);
  4839. }
  4840. return queue[queue.length - 1];
  4841. }
  4842. function showToast(options = {}) {
  4843. if (!inBrowser) {
  4844. return {};
  4845. }
  4846. const toast = getInstance();
  4847. const parsedOptions = parseOptions$1(options);
  4848. toast.open(extend({}, currentOptions$2, defaultOptionsMap.get(parsedOptions.type || currentOptions$2.type), parsedOptions));
  4849. return toast;
  4850. }
  4851. const createMethod = (type) => (options) => showToast(extend({
  4852. type
  4853. }, parseOptions$1(options)));
  4854. const showLoadingToast = createMethod("loading");
  4855. const showSuccessToast = createMethod("success");
  4856. const showFailToast = createMethod("fail");
  4857. const closeToast = (all) => {
  4858. var _a;
  4859. if (queue.length) {
  4860. if (all) {
  4861. queue.forEach((toast) => {
  4862. toast.close();
  4863. });
  4864. queue = [];
  4865. } else if (!allowMultiple) {
  4866. queue[0].close();
  4867. } else {
  4868. (_a = queue.shift()) == null ? void 0 : _a.close();
  4869. }
  4870. }
  4871. };
  4872. function setToastDefaultOptions(type, options) {
  4873. if (typeof type === "string") {
  4874. defaultOptionsMap.set(type, options);
  4875. } else {
  4876. extend(currentOptions$2, type);
  4877. }
  4878. }
  4879. const resetToastDefaultOptions = (type) => {
  4880. if (typeof type === "string") {
  4881. defaultOptionsMap.delete(type);
  4882. } else {
  4883. currentOptions$2 = extend({}, defaultOptions$1);
  4884. defaultOptionsMap.clear();
  4885. }
  4886. };
  4887. const allowMultipleToast = (value = true) => {
  4888. allowMultiple = value;
  4889. };
  4890. const Toast = withInstall(stdin_default$1u);
  4891. const [name$1j, bem$1f] = createNamespace("switch");
  4892. const switchProps = {
  4893. size: numericProp,
  4894. loading: Boolean,
  4895. disabled: Boolean,
  4896. modelValue: unknownProp,
  4897. activeColor: String,
  4898. inactiveColor: String,
  4899. activeValue: {
  4900. type: unknownProp,
  4901. default: true
  4902. },
  4903. inactiveValue: {
  4904. type: unknownProp,
  4905. default: false
  4906. }
  4907. };
  4908. var stdin_default$1t = defineComponent({
  4909. name: name$1j,
  4910. props: switchProps,
  4911. emits: ["change", "update:modelValue"],
  4912. setup(props2, {
  4913. emit,
  4914. slots
  4915. }) {
  4916. const isChecked = () => props2.modelValue === props2.activeValue;
  4917. const onClick = () => {
  4918. if (!props2.disabled && !props2.loading) {
  4919. const newValue = isChecked() ? props2.inactiveValue : props2.activeValue;
  4920. emit("update:modelValue", newValue);
  4921. emit("change", newValue);
  4922. }
  4923. };
  4924. const renderLoading = () => {
  4925. if (props2.loading) {
  4926. const color = isChecked() ? props2.activeColor : props2.inactiveColor;
  4927. return createVNode(Loading, {
  4928. "class": bem$1f("loading"),
  4929. "color": color
  4930. }, null);
  4931. }
  4932. if (slots.node) {
  4933. return slots.node();
  4934. }
  4935. };
  4936. useCustomFieldValue(() => props2.modelValue);
  4937. return () => {
  4938. var _a;
  4939. const {
  4940. size,
  4941. loading,
  4942. disabled,
  4943. activeColor,
  4944. inactiveColor
  4945. } = props2;
  4946. const checked = isChecked();
  4947. const style = {
  4948. fontSize: addUnit(size),
  4949. backgroundColor: checked ? activeColor : inactiveColor
  4950. };
  4951. return createVNode("div", {
  4952. "role": "switch",
  4953. "class": bem$1f({
  4954. on: checked,
  4955. loading,
  4956. disabled
  4957. }),
  4958. "style": style,
  4959. "tabindex": disabled ? void 0 : 0,
  4960. "aria-checked": checked,
  4961. "onClick": onClick
  4962. }, [createVNode("div", {
  4963. "class": bem$1f("node")
  4964. }, [renderLoading()]), (_a = slots.background) == null ? void 0 : _a.call(slots)]);
  4965. };
  4966. }
  4967. });
  4968. const Switch = withInstall(stdin_default$1t);
  4969. const [name$1i, bem$1e] = createNamespace("address-edit-detail");
  4970. const t$j = createNamespace("address-edit")[2];
  4971. var stdin_default$1s = defineComponent({
  4972. name: name$1i,
  4973. props: {
  4974. show: Boolean,
  4975. rows: numericProp,
  4976. value: String,
  4977. rules: Array,
  4978. focused: Boolean,
  4979. maxlength: numericProp,
  4980. searchResult: Array,
  4981. showSearchResult: Boolean
  4982. },
  4983. emits: ["blur", "focus", "input", "selectSearch"],
  4984. setup(props2, {
  4985. emit
  4986. }) {
  4987. const field = ref();
  4988. const showSearchResult = () => props2.focused && props2.searchResult && props2.showSearchResult;
  4989. const onSelect = (express) => {
  4990. emit("selectSearch", express);
  4991. emit("input", `${express.address || ""} ${express.name || ""}`.trim());
  4992. };
  4993. const renderSearchResult = () => {
  4994. if (!showSearchResult()) {
  4995. return;
  4996. }
  4997. const {
  4998. searchResult
  4999. } = props2;
  5000. return searchResult.map((express) => createVNode(Cell, {
  5001. "clickable": true,
  5002. "key": (express.name || "") + (express.address || ""),
  5003. "icon": "location-o",
  5004. "title": express.name,
  5005. "label": express.address,
  5006. "class": bem$1e("search-item"),
  5007. "border": false,
  5008. "onClick": () => onSelect(express)
  5009. }, null));
  5010. };
  5011. const onBlur = (event) => emit("blur", event);
  5012. const onFocus = (event) => emit("focus", event);
  5013. const onInput = (value) => emit("input", value);
  5014. return () => {
  5015. if (props2.show) {
  5016. return createVNode(Fragment, null, [createVNode(Field, {
  5017. "autosize": true,
  5018. "clearable": true,
  5019. "ref": field,
  5020. "class": bem$1e(),
  5021. "rows": props2.rows,
  5022. "type": "textarea",
  5023. "rules": props2.rules,
  5024. "label": t$j("addressDetail"),
  5025. "border": !showSearchResult(),
  5026. "maxlength": props2.maxlength,
  5027. "modelValue": props2.value,
  5028. "placeholder": t$j("addressDetail"),
  5029. "onBlur": onBlur,
  5030. "onFocus": onFocus,
  5031. "onUpdate:modelValue": onInput
  5032. }, null), renderSearchResult()]);
  5033. }
  5034. };
  5035. }
  5036. });
  5037. const [name$1h, bem$1d, t$i] = createNamespace("address-edit");
  5038. const DEFAULT_DATA = {
  5039. name: "",
  5040. tel: "",
  5041. city: "",
  5042. county: "",
  5043. country: "",
  5044. province: "",
  5045. areaCode: "",
  5046. isDefault: false,
  5047. addressDetail: ""
  5048. };
  5049. const addressEditProps = {
  5050. areaList: Object,
  5051. isSaving: Boolean,
  5052. isDeleting: Boolean,
  5053. validator: Function,
  5054. showArea: truthProp,
  5055. showDetail: truthProp,
  5056. showDelete: Boolean,
  5057. disableArea: Boolean,
  5058. searchResult: Array,
  5059. telMaxlength: numericProp,
  5060. showSetDefault: Boolean,
  5061. saveButtonText: String,
  5062. areaPlaceholder: String,
  5063. deleteButtonText: String,
  5064. showSearchResult: Boolean,
  5065. detailRows: makeNumericProp(1),
  5066. detailMaxlength: makeNumericProp(200),
  5067. areaColumnsPlaceholder: makeArrayProp(),
  5068. addressInfo: {
  5069. type: Object,
  5070. default: () => extend({}, DEFAULT_DATA)
  5071. },
  5072. telValidator: {
  5073. type: Function,
  5074. default: isMobile
  5075. }
  5076. };
  5077. var stdin_default$1r = defineComponent({
  5078. name: name$1h,
  5079. props: addressEditProps,
  5080. emits: ["save", "focus", "change", "delete", "clickArea", "changeArea", "changeDetail", "selectSearch", "changeDefault"],
  5081. setup(props2, {
  5082. emit,
  5083. slots
  5084. }) {
  5085. const areaRef = ref();
  5086. const data = reactive({});
  5087. const showAreaPopup = ref(false);
  5088. const detailFocused = ref(false);
  5089. const areaListLoaded = computed(() => isObject(props2.areaList) && Object.keys(props2.areaList).length);
  5090. const areaText = computed(() => {
  5091. const {
  5092. province,
  5093. city,
  5094. county,
  5095. areaCode
  5096. } = data;
  5097. if (areaCode) {
  5098. const arr = [province, city, county];
  5099. if (province && province === city) {
  5100. arr.splice(1, 1);
  5101. }
  5102. return arr.filter(Boolean).join("/");
  5103. }
  5104. return "";
  5105. });
  5106. const hideBottomFields = computed(() => {
  5107. var _a;
  5108. return ((_a = props2.searchResult) == null ? void 0 : _a.length) && detailFocused.value;
  5109. });
  5110. const onFocus = (key) => {
  5111. detailFocused.value = key === "addressDetail";
  5112. emit("focus", key);
  5113. };
  5114. const onChange = (key, value) => {
  5115. emit("change", {
  5116. key,
  5117. value
  5118. });
  5119. };
  5120. const rules = computed(() => {
  5121. const {
  5122. validator,
  5123. telValidator
  5124. } = props2;
  5125. const makeRule = (name2, emptyMessage) => ({
  5126. validator: (value) => {
  5127. if (validator) {
  5128. const message = validator(name2, value);
  5129. if (message) {
  5130. return message;
  5131. }
  5132. }
  5133. if (!value) {
  5134. return emptyMessage;
  5135. }
  5136. return true;
  5137. }
  5138. });
  5139. return {
  5140. name: [makeRule("name", t$i("nameEmpty"))],
  5141. tel: [makeRule("tel", t$i("telInvalid")), {
  5142. validator: telValidator,
  5143. message: t$i("telInvalid")
  5144. }],
  5145. areaCode: [makeRule("areaCode", t$i("areaEmpty"))],
  5146. addressDetail: [makeRule("addressDetail", t$i("addressEmpty"))]
  5147. };
  5148. });
  5149. const onSave = () => emit("save", data);
  5150. const onChangeDetail = (val) => {
  5151. data.addressDetail = val;
  5152. emit("changeDetail", val);
  5153. };
  5154. const assignAreaText = (options) => {
  5155. data.province = options[0].text;
  5156. data.city = options[1].text;
  5157. data.county = options[2].text;
  5158. };
  5159. const onAreaConfirm = ({
  5160. selectedValues,
  5161. selectedOptions
  5162. }) => {
  5163. if (selectedValues.some((value) => value === AREA_EMPTY_CODE)) {
  5164. showToast(t$i("areaEmpty"));
  5165. } else {
  5166. showAreaPopup.value = false;
  5167. assignAreaText(selectedOptions);
  5168. emit("changeArea", selectedOptions);
  5169. }
  5170. };
  5171. const onDelete = () => emit("delete", data);
  5172. const setAreaCode = (code) => {
  5173. data.areaCode = code || "";
  5174. };
  5175. const onDetailBlur = () => {
  5176. setTimeout(() => {
  5177. detailFocused.value = false;
  5178. });
  5179. };
  5180. const setAddressDetail = (value) => {
  5181. data.addressDetail = value;
  5182. };
  5183. const renderSetDefaultCell = () => {
  5184. if (props2.showSetDefault) {
  5185. const slots2 = {
  5186. "right-icon": () => createVNode(Switch, {
  5187. "modelValue": data.isDefault,
  5188. "onUpdate:modelValue": ($event) => data.isDefault = $event,
  5189. "onChange": (event) => emit("changeDefault", event)
  5190. }, null)
  5191. };
  5192. return withDirectives(createVNode(Cell, {
  5193. "center": true,
  5194. "border": false,
  5195. "title": t$i("defaultAddress"),
  5196. "class": bem$1d("default")
  5197. }, slots2), [[vShow, !hideBottomFields.value]]);
  5198. }
  5199. };
  5200. useExpose({
  5201. setAreaCode,
  5202. setAddressDetail
  5203. });
  5204. watch(() => props2.addressInfo, (value) => {
  5205. extend(data, DEFAULT_DATA, value);
  5206. nextTick(() => {
  5207. var _a;
  5208. const options = (_a = areaRef.value) == null ? void 0 : _a.getSelectedOptions();
  5209. if (options && options.every((option) => option && option.value !== AREA_EMPTY_CODE)) {
  5210. assignAreaText(options);
  5211. }
  5212. });
  5213. }, {
  5214. deep: true,
  5215. immediate: true
  5216. });
  5217. return () => {
  5218. const {
  5219. disableArea
  5220. } = props2;
  5221. return createVNode(Form, {
  5222. "class": bem$1d(),
  5223. "onSubmit": onSave
  5224. }, {
  5225. default: () => {
  5226. var _a;
  5227. return [createVNode("div", {
  5228. "class": bem$1d("fields")
  5229. }, [createVNode(Field, {
  5230. "modelValue": data.name,
  5231. "onUpdate:modelValue": [($event) => data.name = $event, (val) => onChange("name", val)],
  5232. "clearable": true,
  5233. "label": t$i("name"),
  5234. "rules": rules.value.name,
  5235. "placeholder": t$i("name"),
  5236. "onFocus": () => onFocus("name")
  5237. }, null), createVNode(Field, {
  5238. "modelValue": data.tel,
  5239. "onUpdate:modelValue": [($event) => data.tel = $event, (val) => onChange("tel", val)],
  5240. "clearable": true,
  5241. "type": "tel",
  5242. "label": t$i("tel"),
  5243. "rules": rules.value.tel,
  5244. "maxlength": props2.telMaxlength,
  5245. "placeholder": t$i("tel"),
  5246. "onFocus": () => onFocus("tel")
  5247. }, null), withDirectives(createVNode(Field, {
  5248. "readonly": true,
  5249. "label": t$i("area"),
  5250. "is-link": !disableArea,
  5251. "modelValue": areaText.value,
  5252. "rules": props2.showArea ? rules.value.areaCode : void 0,
  5253. "placeholder": props2.areaPlaceholder || t$i("area"),
  5254. "onFocus": () => onFocus("areaCode"),
  5255. "onClick": () => {
  5256. emit("clickArea");
  5257. showAreaPopup.value = !disableArea;
  5258. }
  5259. }, null), [[vShow, props2.showArea]]), createVNode(stdin_default$1s, {
  5260. "show": props2.showDetail,
  5261. "rows": props2.detailRows,
  5262. "rules": rules.value.addressDetail,
  5263. "value": data.addressDetail,
  5264. "focused": detailFocused.value,
  5265. "maxlength": props2.detailMaxlength,
  5266. "searchResult": props2.searchResult,
  5267. "showSearchResult": props2.showSearchResult,
  5268. "onBlur": onDetailBlur,
  5269. "onFocus": () => onFocus("addressDetail"),
  5270. "onInput": onChangeDetail,
  5271. "onSelectSearch": (event) => emit("selectSearch", event)
  5272. }, null), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderSetDefaultCell(), withDirectives(createVNode("div", {
  5273. "class": bem$1d("buttons")
  5274. }, [createVNode(Button, {
  5275. "block": true,
  5276. "round": true,
  5277. "type": "primary",
  5278. "text": props2.saveButtonText || t$i("save"),
  5279. "class": bem$1d("button"),
  5280. "loading": props2.isSaving,
  5281. "nativeType": "submit"
  5282. }, null), props2.showDelete && createVNode(Button, {
  5283. "block": true,
  5284. "round": true,
  5285. "class": bem$1d("button"),
  5286. "loading": props2.isDeleting,
  5287. "text": props2.deleteButtonText || t$i("delete"),
  5288. "onClick": onDelete
  5289. }, null)]), [[vShow, !hideBottomFields.value]]), createVNode(Popup, {
  5290. "show": showAreaPopup.value,
  5291. "onUpdate:show": ($event) => showAreaPopup.value = $event,
  5292. "round": true,
  5293. "teleport": "body",
  5294. "position": "bottom",
  5295. "lazyRender": false
  5296. }, {
  5297. default: () => [createVNode(Area, {
  5298. "modelValue": data.areaCode,
  5299. "onUpdate:modelValue": ($event) => data.areaCode = $event,
  5300. "ref": areaRef,
  5301. "loading": !areaListLoaded.value,
  5302. "areaList": props2.areaList,
  5303. "columnsPlaceholder": props2.areaColumnsPlaceholder,
  5304. "onConfirm": onAreaConfirm,
  5305. "onCancel": () => {
  5306. showAreaPopup.value = false;
  5307. }
  5308. }, null)]
  5309. })];
  5310. }
  5311. });
  5312. };
  5313. }
  5314. });
  5315. const AddressEdit = withInstall(stdin_default$1r);
  5316. const [name$1g, bem$1c] = createNamespace("radio-group");
  5317. const radioGroupProps = {
  5318. shape: String,
  5319. disabled: Boolean,
  5320. iconSize: numericProp,
  5321. direction: String,
  5322. modelValue: unknownProp,
  5323. checkedColor: String
  5324. };
  5325. const RADIO_KEY = Symbol(name$1g);
  5326. var stdin_default$1q = defineComponent({
  5327. name: name$1g,
  5328. props: radioGroupProps,
  5329. emits: ["change", "update:modelValue"],
  5330. setup(props2, {
  5331. emit,
  5332. slots
  5333. }) {
  5334. const {
  5335. linkChildren
  5336. } = useChildren(RADIO_KEY);
  5337. const updateValue = (value) => emit("update:modelValue", value);
  5338. watch(() => props2.modelValue, (value) => emit("change", value));
  5339. linkChildren({
  5340. props: props2,
  5341. updateValue
  5342. });
  5343. useCustomFieldValue(() => props2.modelValue);
  5344. return () => {
  5345. var _a;
  5346. return createVNode("div", {
  5347. "class": bem$1c([props2.direction]),
  5348. "role": "radiogroup"
  5349. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  5350. };
  5351. }
  5352. });
  5353. const RadioGroup = withInstall(stdin_default$1q);
  5354. const [name$1f, bem$1b] = createNamespace("checkbox-group");
  5355. const checkboxGroupProps = {
  5356. max: numericProp,
  5357. shape: makeStringProp("round"),
  5358. disabled: Boolean,
  5359. iconSize: numericProp,
  5360. direction: String,
  5361. modelValue: makeArrayProp(),
  5362. checkedColor: String
  5363. };
  5364. const CHECKBOX_GROUP_KEY = Symbol(name$1f);
  5365. var stdin_default$1p = defineComponent({
  5366. name: name$1f,
  5367. props: checkboxGroupProps,
  5368. emits: ["change", "update:modelValue"],
  5369. setup(props2, {
  5370. emit,
  5371. slots
  5372. }) {
  5373. const {
  5374. children,
  5375. linkChildren
  5376. } = useChildren(CHECKBOX_GROUP_KEY);
  5377. const updateValue = (value) => emit("update:modelValue", value);
  5378. const toggleAll = (options = {}) => {
  5379. if (typeof options === "boolean") {
  5380. options = {
  5381. checked: options
  5382. };
  5383. }
  5384. const {
  5385. checked,
  5386. skipDisabled
  5387. } = options;
  5388. const checkedChildren = children.filter((item) => {
  5389. if (!item.props.bindGroup) {
  5390. return false;
  5391. }
  5392. if (item.props.disabled && skipDisabled) {
  5393. return item.checked.value;
  5394. }
  5395. return checked != null ? checked : !item.checked.value;
  5396. });
  5397. const names = checkedChildren.map((item) => item.name);
  5398. updateValue(names);
  5399. };
  5400. watch(() => props2.modelValue, (value) => emit("change", value));
  5401. useExpose({
  5402. toggleAll
  5403. });
  5404. useCustomFieldValue(() => props2.modelValue);
  5405. linkChildren({
  5406. props: props2,
  5407. updateValue
  5408. });
  5409. return () => {
  5410. var _a;
  5411. return createVNode("div", {
  5412. "class": bem$1b([props2.direction])
  5413. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  5414. };
  5415. }
  5416. });
  5417. const CheckboxGroup = withInstall(stdin_default$1p);
  5418. const [name$1e, bem$1a] = createNamespace("tag");
  5419. const tagProps = {
  5420. size: String,
  5421. mark: Boolean,
  5422. show: truthProp,
  5423. type: makeStringProp("default"),
  5424. color: String,
  5425. plain: Boolean,
  5426. round: Boolean,
  5427. textColor: String,
  5428. closeable: Boolean
  5429. };
  5430. var stdin_default$1o = defineComponent({
  5431. name: name$1e,
  5432. props: tagProps,
  5433. emits: ["close"],
  5434. setup(props2, {
  5435. slots,
  5436. emit
  5437. }) {
  5438. const onClose = (event) => {
  5439. event.stopPropagation();
  5440. emit("close", event);
  5441. };
  5442. const getStyle = () => {
  5443. if (props2.plain) {
  5444. return {
  5445. color: props2.textColor || props2.color,
  5446. borderColor: props2.color
  5447. };
  5448. }
  5449. return {
  5450. color: props2.textColor,
  5451. background: props2.color
  5452. };
  5453. };
  5454. const renderTag = () => {
  5455. var _a;
  5456. const {
  5457. type,
  5458. mark,
  5459. plain,
  5460. round,
  5461. size,
  5462. closeable
  5463. } = props2;
  5464. const classes = {
  5465. mark,
  5466. plain,
  5467. round
  5468. };
  5469. if (size) {
  5470. classes[size] = size;
  5471. }
  5472. const CloseIcon = closeable && createVNode(Icon, {
  5473. "name": "cross",
  5474. "class": [bem$1a("close"), HAPTICS_FEEDBACK],
  5475. "onClick": onClose
  5476. }, null);
  5477. return createVNode("span", {
  5478. "style": getStyle(),
  5479. "class": bem$1a([classes, type])
  5480. }, [(_a = slots.default) == null ? void 0 : _a.call(slots), CloseIcon]);
  5481. };
  5482. return () => createVNode(Transition, {
  5483. "name": props2.closeable ? "van-fade" : void 0
  5484. }, {
  5485. default: () => [props2.show ? renderTag() : null]
  5486. });
  5487. }
  5488. });
  5489. const Tag = withInstall(stdin_default$1o);
  5490. const checkerProps = {
  5491. name: unknownProp,
  5492. disabled: Boolean,
  5493. iconSize: numericProp,
  5494. modelValue: unknownProp,
  5495. checkedColor: String,
  5496. labelPosition: String,
  5497. labelDisabled: Boolean
  5498. };
  5499. var stdin_default$1n = defineComponent({
  5500. props: extend({}, checkerProps, {
  5501. bem: makeRequiredProp(Function),
  5502. role: String,
  5503. shape: String,
  5504. parent: Object,
  5505. checked: Boolean,
  5506. bindGroup: truthProp,
  5507. indeterminate: {
  5508. type: Boolean,
  5509. default: null
  5510. }
  5511. }),
  5512. emits: ["click", "toggle"],
  5513. setup(props2, {
  5514. emit,
  5515. slots
  5516. }) {
  5517. const iconRef = ref();
  5518. const getParentProp = (name2) => {
  5519. if (props2.parent && props2.bindGroup) {
  5520. return props2.parent.props[name2];
  5521. }
  5522. };
  5523. const disabled = computed(() => {
  5524. if (props2.parent && props2.bindGroup) {
  5525. const disabled2 = getParentProp("disabled") || props2.disabled;
  5526. if (props2.role === "checkbox") {
  5527. const checkedCount = getParentProp("modelValue").length;
  5528. const max = getParentProp("max");
  5529. const overlimit = max && checkedCount >= +max;
  5530. return disabled2 || overlimit && !props2.checked;
  5531. }
  5532. return disabled2;
  5533. }
  5534. return props2.disabled;
  5535. });
  5536. const direction = computed(() => getParentProp("direction"));
  5537. const iconStyle = computed(() => {
  5538. const checkedColor = props2.checkedColor || getParentProp("checkedColor");
  5539. if (checkedColor && props2.checked && !disabled.value) {
  5540. return {
  5541. borderColor: checkedColor,
  5542. backgroundColor: checkedColor
  5543. };
  5544. }
  5545. });
  5546. const shape = computed(() => {
  5547. return props2.shape || getParentProp("shape") || "round";
  5548. });
  5549. const onClick = (event) => {
  5550. const {
  5551. target
  5552. } = event;
  5553. const icon = iconRef.value;
  5554. const iconClicked = icon === target || (icon == null ? void 0 : icon.contains(target));
  5555. if (!disabled.value && (iconClicked || !props2.labelDisabled)) {
  5556. emit("toggle");
  5557. }
  5558. emit("click", event);
  5559. };
  5560. const renderIcon = () => {
  5561. var _a, _b;
  5562. const {
  5563. bem: bem2,
  5564. checked,
  5565. indeterminate
  5566. } = props2;
  5567. const iconSize = props2.iconSize || getParentProp("iconSize");
  5568. return createVNode("div", {
  5569. "ref": iconRef,
  5570. "class": bem2("icon", [shape.value, {
  5571. disabled: disabled.value,
  5572. checked,
  5573. indeterminate
  5574. }]),
  5575. "style": shape.value !== "dot" ? {
  5576. fontSize: addUnit(iconSize)
  5577. } : {
  5578. width: addUnit(iconSize),
  5579. height: addUnit(iconSize),
  5580. borderColor: (_a = iconStyle.value) == null ? void 0 : _a.borderColor
  5581. }
  5582. }, [slots.icon ? slots.icon({
  5583. checked,
  5584. disabled: disabled.value
  5585. }) : shape.value !== "dot" ? createVNode(Icon, {
  5586. "name": indeterminate ? "minus" : "success",
  5587. "style": iconStyle.value
  5588. }, null) : createVNode("div", {
  5589. "class": bem2("icon--dot__icon"),
  5590. "style": {
  5591. backgroundColor: (_b = iconStyle.value) == null ? void 0 : _b.backgroundColor
  5592. }
  5593. }, null)]);
  5594. };
  5595. const renderLabel = () => {
  5596. const {
  5597. checked
  5598. } = props2;
  5599. if (slots.default) {
  5600. return createVNode("span", {
  5601. "class": props2.bem("label", [props2.labelPosition, {
  5602. disabled: disabled.value
  5603. }])
  5604. }, [slots.default({
  5605. checked,
  5606. disabled: disabled.value
  5607. })]);
  5608. }
  5609. };
  5610. return () => {
  5611. const nodes = props2.labelPosition === "left" ? [renderLabel(), renderIcon()] : [renderIcon(), renderLabel()];
  5612. return createVNode("div", {
  5613. "role": props2.role,
  5614. "class": props2.bem([{
  5615. disabled: disabled.value,
  5616. "label-disabled": props2.labelDisabled
  5617. }, direction.value]),
  5618. "tabindex": disabled.value ? void 0 : 0,
  5619. "aria-checked": props2.checked,
  5620. "onClick": onClick
  5621. }, [nodes]);
  5622. };
  5623. }
  5624. });
  5625. const radioProps = extend({}, checkerProps, {
  5626. shape: String
  5627. });
  5628. const [name$1d, bem$19] = createNamespace("radio");
  5629. var stdin_default$1m = defineComponent({
  5630. name: name$1d,
  5631. props: radioProps,
  5632. emits: ["update:modelValue"],
  5633. setup(props2, {
  5634. emit,
  5635. slots
  5636. }) {
  5637. const {
  5638. parent
  5639. } = useParent(RADIO_KEY);
  5640. const checked = () => {
  5641. const value = parent ? parent.props.modelValue : props2.modelValue;
  5642. return value === props2.name;
  5643. };
  5644. const toggle = () => {
  5645. if (parent) {
  5646. parent.updateValue(props2.name);
  5647. } else {
  5648. emit("update:modelValue", props2.name);
  5649. }
  5650. };
  5651. return () => createVNode(stdin_default$1n, mergeProps({
  5652. "bem": bem$19,
  5653. "role": "radio",
  5654. "parent": parent,
  5655. "checked": checked(),
  5656. "onToggle": toggle
  5657. }, props2), pick(slots, ["default", "icon"]));
  5658. }
  5659. });
  5660. const Radio = withInstall(stdin_default$1m);
  5661. const [name$1c, bem$18] = createNamespace("checkbox");
  5662. const checkboxProps = extend({}, checkerProps, {
  5663. shape: String,
  5664. bindGroup: truthProp,
  5665. indeterminate: {
  5666. type: Boolean,
  5667. default: null
  5668. }
  5669. });
  5670. var stdin_default$1l = defineComponent({
  5671. name: name$1c,
  5672. props: checkboxProps,
  5673. emits: ["change", "update:modelValue"],
  5674. setup(props2, {
  5675. emit,
  5676. slots
  5677. }) {
  5678. const {
  5679. parent
  5680. } = useParent(CHECKBOX_GROUP_KEY);
  5681. const setParentValue = (checked2) => {
  5682. const {
  5683. name: name2
  5684. } = props2;
  5685. const {
  5686. max,
  5687. modelValue
  5688. } = parent.props;
  5689. const value = modelValue.slice();
  5690. if (checked2) {
  5691. const overlimit = max && value.length >= +max;
  5692. if (!overlimit && !value.includes(name2)) {
  5693. value.push(name2);
  5694. if (props2.bindGroup) {
  5695. parent.updateValue(value);
  5696. }
  5697. }
  5698. } else {
  5699. const index = value.indexOf(name2);
  5700. if (index !== -1) {
  5701. value.splice(index, 1);
  5702. if (props2.bindGroup) {
  5703. parent.updateValue(value);
  5704. }
  5705. }
  5706. }
  5707. };
  5708. const checked = computed(() => {
  5709. if (parent && props2.bindGroup) {
  5710. return parent.props.modelValue.indexOf(props2.name) !== -1;
  5711. }
  5712. return !!props2.modelValue;
  5713. });
  5714. const toggle = (newValue = !checked.value) => {
  5715. if (parent && props2.bindGroup) {
  5716. setParentValue(newValue);
  5717. } else {
  5718. emit("update:modelValue", newValue);
  5719. }
  5720. if (props2.indeterminate !== null) emit("change", newValue);
  5721. };
  5722. watch(() => props2.modelValue, (value) => {
  5723. if (props2.indeterminate === null) emit("change", value);
  5724. });
  5725. useExpose({
  5726. toggle,
  5727. props: props2,
  5728. checked
  5729. });
  5730. useCustomFieldValue(() => props2.modelValue);
  5731. return () => createVNode(stdin_default$1n, mergeProps({
  5732. "bem": bem$18,
  5733. "role": "checkbox",
  5734. "parent": parent,
  5735. "checked": checked.value,
  5736. "onToggle": toggle
  5737. }, props2), pick(slots, ["default", "icon"]));
  5738. }
  5739. });
  5740. const Checkbox = withInstall(stdin_default$1l);
  5741. const [name$1b, bem$17] = createNamespace("address-item");
  5742. var stdin_default$1k = defineComponent({
  5743. name: name$1b,
  5744. props: {
  5745. address: makeRequiredProp(Object),
  5746. disabled: Boolean,
  5747. switchable: Boolean,
  5748. singleChoice: Boolean,
  5749. defaultTagText: String,
  5750. rightIcon: makeStringProp("edit")
  5751. },
  5752. emits: ["edit", "click", "select"],
  5753. setup(props2, {
  5754. slots,
  5755. emit
  5756. }) {
  5757. const onClick = (event) => {
  5758. if (props2.switchable) {
  5759. emit("select");
  5760. }
  5761. emit("click", event);
  5762. };
  5763. const renderRightIcon = () => createVNode(Icon, {
  5764. "name": props2.rightIcon,
  5765. "class": bem$17("edit"),
  5766. "onClick": (event) => {
  5767. event.stopPropagation();
  5768. emit("edit");
  5769. emit("click", event);
  5770. }
  5771. }, null);
  5772. const renderTag = () => {
  5773. if (slots.tag) {
  5774. return slots.tag(props2.address);
  5775. }
  5776. if (props2.address.isDefault && props2.defaultTagText) {
  5777. return createVNode(Tag, {
  5778. "type": "primary",
  5779. "round": true,
  5780. "class": bem$17("tag")
  5781. }, {
  5782. default: () => [props2.defaultTagText]
  5783. });
  5784. }
  5785. };
  5786. const renderContent = () => {
  5787. const {
  5788. address,
  5789. disabled,
  5790. switchable,
  5791. singleChoice
  5792. } = props2;
  5793. const Info = [createVNode("div", {
  5794. "class": bem$17("name")
  5795. }, [`${address.name} ${address.tel}`, renderTag()]), createVNode("div", {
  5796. "class": bem$17("address")
  5797. }, [address.address])];
  5798. if (switchable && !disabled) {
  5799. if (singleChoice) {
  5800. return createVNode(Radio, {
  5801. "name": address.id,
  5802. "iconSize": 18
  5803. }, {
  5804. default: () => [Info]
  5805. });
  5806. } else {
  5807. return createVNode(Checkbox, {
  5808. "name": address.id,
  5809. "iconSize": 18
  5810. }, {
  5811. default: () => [Info]
  5812. });
  5813. }
  5814. }
  5815. return Info;
  5816. };
  5817. return () => {
  5818. var _a;
  5819. const {
  5820. disabled
  5821. } = props2;
  5822. return createVNode("div", {
  5823. "class": bem$17({
  5824. disabled
  5825. }),
  5826. "onClick": onClick
  5827. }, [createVNode(Cell, {
  5828. "border": false,
  5829. "titleClass": bem$17("title")
  5830. }, {
  5831. title: renderContent,
  5832. "right-icon": renderRightIcon
  5833. }), (_a = slots.bottom) == null ? void 0 : _a.call(slots, extend({}, props2.address, {
  5834. disabled
  5835. }))]);
  5836. };
  5837. }
  5838. });
  5839. const [name$1a, bem$16, t$h] = createNamespace("address-list");
  5840. const addressListProps = {
  5841. list: makeArrayProp(),
  5842. modelValue: [...numericProp, Array],
  5843. switchable: truthProp,
  5844. disabledText: String,
  5845. disabledList: makeArrayProp(),
  5846. showAddButton: truthProp,
  5847. addButtonText: String,
  5848. defaultTagText: String,
  5849. rightIcon: makeStringProp("edit")
  5850. };
  5851. var stdin_default$1j = defineComponent({
  5852. name: name$1a,
  5853. props: addressListProps,
  5854. emits: ["add", "edit", "select", "clickItem", "editDisabled", "selectDisabled", "update:modelValue"],
  5855. setup(props2, {
  5856. slots,
  5857. emit
  5858. }) {
  5859. const singleChoice = computed(() => !Array.isArray(props2.modelValue));
  5860. const renderItem = (item, index, disabled) => {
  5861. const onEdit = () => emit(disabled ? "editDisabled" : "edit", item, index);
  5862. const onClick = (event) => emit("clickItem", item, index, {
  5863. event
  5864. });
  5865. const onSelect = () => {
  5866. emit(disabled ? "selectDisabled" : "select", item, index);
  5867. if (!disabled) {
  5868. if (singleChoice.value) {
  5869. emit("update:modelValue", item.id);
  5870. } else {
  5871. const value = props2.modelValue;
  5872. if (value.includes(item.id)) {
  5873. emit("update:modelValue", value.filter((id) => id !== item.id));
  5874. } else {
  5875. emit("update:modelValue", [...value, item.id]);
  5876. }
  5877. }
  5878. }
  5879. };
  5880. return createVNode(stdin_default$1k, {
  5881. "key": item.id,
  5882. "address": item,
  5883. "disabled": disabled,
  5884. "switchable": props2.switchable,
  5885. "singleChoice": singleChoice.value,
  5886. "defaultTagText": props2.defaultTagText,
  5887. "rightIcon": props2.rightIcon,
  5888. "onEdit": onEdit,
  5889. "onClick": onClick,
  5890. "onSelect": onSelect
  5891. }, {
  5892. bottom: slots["item-bottom"],
  5893. tag: slots.tag
  5894. });
  5895. };
  5896. const renderList = (list, disabled) => {
  5897. if (list) {
  5898. return list.map((item, index) => renderItem(item, index, disabled));
  5899. }
  5900. };
  5901. const renderBottom = () => props2.showAddButton ? createVNode("div", {
  5902. "class": [bem$16("bottom"), "van-safe-area-bottom"]
  5903. }, [createVNode(Button, {
  5904. "round": true,
  5905. "block": true,
  5906. "type": "primary",
  5907. "text": props2.addButtonText || t$h("add"),
  5908. "class": bem$16("add"),
  5909. "onClick": () => emit("add")
  5910. }, null)]) : void 0;
  5911. return () => {
  5912. var _a, _b;
  5913. const List2 = renderList(props2.list);
  5914. const DisabledList = renderList(props2.disabledList, true);
  5915. const DisabledText = props2.disabledText && createVNode("div", {
  5916. "class": bem$16("disabled-text")
  5917. }, [props2.disabledText]);
  5918. return createVNode("div", {
  5919. "class": bem$16()
  5920. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), !singleChoice.value && Array.isArray(props2.modelValue) ? createVNode(CheckboxGroup, {
  5921. "modelValue": props2.modelValue
  5922. }, {
  5923. default: () => [List2]
  5924. }) : createVNode(RadioGroup, {
  5925. "modelValue": props2.modelValue
  5926. }, {
  5927. default: () => [List2]
  5928. }), DisabledText, DisabledList, (_b = slots.default) == null ? void 0 : _b.call(slots), renderBottom()]);
  5929. };
  5930. }
  5931. });
  5932. const AddressList = withInstall(stdin_default$1j);
  5933. const hasIntersectionObserver = inBrowser$1 && "IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype;
  5934. const modeType = {
  5935. event: "event",
  5936. observer: "observer"
  5937. };
  5938. function remove(arr, item) {
  5939. if (!arr.length) return;
  5940. const index = arr.indexOf(item);
  5941. if (index > -1) return arr.splice(index, 1);
  5942. }
  5943. function getBestSelectionFromSrcset(el, scale) {
  5944. if (el.tagName !== "IMG" || !el.getAttribute("data-srcset")) return;
  5945. let options = el.getAttribute("data-srcset");
  5946. const container = el.parentNode;
  5947. const containerWidth = container.offsetWidth * scale;
  5948. let spaceIndex;
  5949. let tmpSrc;
  5950. let tmpWidth;
  5951. options = options.trim().split(",");
  5952. const result = options.map((item) => {
  5953. item = item.trim();
  5954. spaceIndex = item.lastIndexOf(" ");
  5955. if (spaceIndex === -1) {
  5956. tmpSrc = item;
  5957. tmpWidth = 999998;
  5958. } else {
  5959. tmpSrc = item.substr(0, spaceIndex);
  5960. tmpWidth = parseInt(
  5961. item.substr(spaceIndex + 1, item.length - spaceIndex - 2),
  5962. 10
  5963. );
  5964. }
  5965. return [tmpWidth, tmpSrc];
  5966. });
  5967. result.sort((a, b) => {
  5968. if (a[0] < b[0]) {
  5969. return 1;
  5970. }
  5971. if (a[0] > b[0]) {
  5972. return -1;
  5973. }
  5974. if (a[0] === b[0]) {
  5975. if (b[1].indexOf(".webp", b[1].length - 5) !== -1) {
  5976. return 1;
  5977. }
  5978. if (a[1].indexOf(".webp", a[1].length - 5) !== -1) {
  5979. return -1;
  5980. }
  5981. }
  5982. return 0;
  5983. });
  5984. let bestSelectedSrc = "";
  5985. let tmpOption;
  5986. for (let i = 0; i < result.length; i++) {
  5987. tmpOption = result[i];
  5988. bestSelectedSrc = tmpOption[1];
  5989. const next = result[i + 1];
  5990. if (next && next[0] < containerWidth) {
  5991. bestSelectedSrc = tmpOption[1];
  5992. break;
  5993. } else if (!next) {
  5994. bestSelectedSrc = tmpOption[1];
  5995. break;
  5996. }
  5997. }
  5998. return bestSelectedSrc;
  5999. }
  6000. const getDPR = (scale = 1) => inBrowser$1 ? window.devicePixelRatio || scale : scale;
  6001. function supportWebp() {
  6002. if (!inBrowser$1) return false;
  6003. let support = true;
  6004. try {
  6005. const elem = document.createElement("canvas");
  6006. if (elem.getContext && elem.getContext("2d")) {
  6007. support = elem.toDataURL("image/webp").indexOf("data:image/webp") === 0;
  6008. }
  6009. } catch (err) {
  6010. support = false;
  6011. }
  6012. return support;
  6013. }
  6014. function throttle(action, delay) {
  6015. let timeout = null;
  6016. let lastRun = 0;
  6017. return function(...args) {
  6018. if (timeout) {
  6019. return;
  6020. }
  6021. const elapsed = Date.now() - lastRun;
  6022. const runCallback = () => {
  6023. lastRun = Date.now();
  6024. timeout = false;
  6025. action.apply(this, args);
  6026. };
  6027. if (elapsed >= delay) {
  6028. runCallback();
  6029. } else {
  6030. timeout = setTimeout(runCallback, delay);
  6031. }
  6032. };
  6033. }
  6034. function on(el, type, func) {
  6035. el.addEventListener(type, func, {
  6036. capture: false,
  6037. passive: true
  6038. });
  6039. }
  6040. function off(el, type, func) {
  6041. el.removeEventListener(type, func, false);
  6042. }
  6043. const loadImageAsync = (item, resolve, reject) => {
  6044. const image = new Image();
  6045. if (!item || !item.src) {
  6046. return reject(new Error("image src is required"));
  6047. }
  6048. image.src = item.src;
  6049. if (item.cors) {
  6050. image.crossOrigin = item.cors;
  6051. }
  6052. image.onload = () => resolve({
  6053. naturalHeight: image.naturalHeight,
  6054. naturalWidth: image.naturalWidth,
  6055. src: image.src
  6056. });
  6057. image.onerror = (e) => reject(e);
  6058. };
  6059. class ImageCache {
  6060. constructor({ max }) {
  6061. this.options = {
  6062. max: max || 100
  6063. };
  6064. this.caches = [];
  6065. }
  6066. has(key) {
  6067. return this.caches.indexOf(key) > -1;
  6068. }
  6069. add(key) {
  6070. if (this.has(key)) return;
  6071. this.caches.push(key);
  6072. if (this.caches.length > this.options.max) {
  6073. this.free();
  6074. }
  6075. }
  6076. free() {
  6077. this.caches.shift();
  6078. }
  6079. }
  6080. const [name$19, bem$15] = createNamespace("back-top");
  6081. const backTopProps = {
  6082. right: numericProp,
  6083. bottom: numericProp,
  6084. zIndex: numericProp,
  6085. target: [String, Object],
  6086. offset: makeNumericProp(200),
  6087. immediate: Boolean,
  6088. teleport: {
  6089. type: [String, Object],
  6090. default: "body"
  6091. }
  6092. };
  6093. var stdin_default$1i = defineComponent({
  6094. name: name$19,
  6095. inheritAttrs: false,
  6096. props: backTopProps,
  6097. emits: ["click"],
  6098. setup(props2, {
  6099. emit,
  6100. slots,
  6101. attrs
  6102. }) {
  6103. let shouldReshow = false;
  6104. const show = ref(false);
  6105. const root = ref();
  6106. const scrollParent = ref();
  6107. const style = computed(() => extend(getZIndexStyle(props2.zIndex), {
  6108. right: addUnit(props2.right),
  6109. bottom: addUnit(props2.bottom)
  6110. }));
  6111. const onClick = (event) => {
  6112. var _a;
  6113. emit("click", event);
  6114. (_a = scrollParent.value) == null ? void 0 : _a.scrollTo({
  6115. top: 0,
  6116. behavior: props2.immediate ? "auto" : "smooth"
  6117. });
  6118. };
  6119. const scroll = () => {
  6120. show.value = scrollParent.value ? getScrollTop(scrollParent.value) >= +props2.offset : false;
  6121. };
  6122. const getTarget = () => {
  6123. const {
  6124. target
  6125. } = props2;
  6126. if (typeof target === "string") {
  6127. const el = document.querySelector(target);
  6128. if (el) {
  6129. return el;
  6130. }
  6131. if (process.env.NODE_ENV !== "production") {
  6132. console.error(`[Vant] BackTop: target element "${target}" was not found, the BackTop component will not be rendered.`);
  6133. }
  6134. } else {
  6135. return target;
  6136. }
  6137. };
  6138. const updateTarget = () => {
  6139. if (inBrowser) {
  6140. nextTick(() => {
  6141. scrollParent.value = props2.target ? getTarget() : getScrollParent(root.value);
  6142. scroll();
  6143. });
  6144. }
  6145. };
  6146. useEventListener("scroll", throttle(scroll, 100), {
  6147. target: scrollParent
  6148. });
  6149. onMounted(updateTarget);
  6150. onActivated(() => {
  6151. if (shouldReshow) {
  6152. show.value = true;
  6153. shouldReshow = false;
  6154. }
  6155. });
  6156. onDeactivated(() => {
  6157. if (show.value && props2.teleport) {
  6158. show.value = false;
  6159. shouldReshow = true;
  6160. }
  6161. });
  6162. watch(() => props2.target, updateTarget);
  6163. return () => {
  6164. const Content = createVNode("div", mergeProps({
  6165. "ref": !props2.teleport ? root : void 0,
  6166. "class": bem$15({
  6167. active: show.value
  6168. }),
  6169. "style": style.value,
  6170. "onClick": onClick
  6171. }, attrs), [slots.default ? slots.default() : createVNode(Icon, {
  6172. "name": "back-top",
  6173. "class": bem$15("icon")
  6174. }, null)]);
  6175. if (props2.teleport) {
  6176. return [createVNode("div", {
  6177. "ref": root,
  6178. "class": bem$15("placeholder")
  6179. }, null), createVNode(Teleport, {
  6180. "to": props2.teleport
  6181. }, {
  6182. default: () => [Content]
  6183. })];
  6184. }
  6185. return Content;
  6186. };
  6187. }
  6188. });
  6189. const BackTop = withInstall(stdin_default$1i);
  6190. var __async = (__this, __arguments, generator) => {
  6191. return new Promise((resolve, reject) => {
  6192. var fulfilled = (value) => {
  6193. try {
  6194. step(generator.next(value));
  6195. } catch (e) {
  6196. reject(e);
  6197. }
  6198. };
  6199. var rejected = (value) => {
  6200. try {
  6201. step(generator.throw(value));
  6202. } catch (e) {
  6203. reject(e);
  6204. }
  6205. };
  6206. var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
  6207. step((generator = generator.apply(__this, __arguments)).next());
  6208. });
  6209. };
  6210. const barrageProps = {
  6211. top: makeNumericProp(10),
  6212. rows: makeNumericProp(4),
  6213. duration: makeNumericProp(4e3),
  6214. autoPlay: truthProp,
  6215. delay: makeNumberProp(300),
  6216. modelValue: makeArrayProp()
  6217. };
  6218. const [name$18, bem$14] = createNamespace("barrage");
  6219. var stdin_default$1h = defineComponent({
  6220. name: name$18,
  6221. props: barrageProps,
  6222. emits: ["update:modelValue"],
  6223. setup(props2, {
  6224. emit,
  6225. slots
  6226. }) {
  6227. const barrageWrapper = ref();
  6228. const className = bem$14("item");
  6229. const total = ref(0);
  6230. const barrageItems = [];
  6231. const createBarrageItem = (text, delay = props2.delay) => {
  6232. const item = document.createElement("span");
  6233. item.className = className;
  6234. item.innerText = String(text);
  6235. item.style.animationDuration = `${props2.duration}ms`;
  6236. item.style.animationDelay = `${delay}ms`;
  6237. item.style.animationName = "van-barrage";
  6238. item.style.animationTimingFunction = "linear";
  6239. return item;
  6240. };
  6241. const isInitBarrage = ref(true);
  6242. const isPlay = ref(props2.autoPlay);
  6243. const appendBarrageItem = ({
  6244. id,
  6245. text
  6246. }, i) => {
  6247. var _a;
  6248. const item = createBarrageItem(text, isInitBarrage.value ? i * props2.delay : void 0);
  6249. if (!props2.autoPlay && isPlay.value === false) {
  6250. item.style.animationPlayState = "paused";
  6251. }
  6252. (_a = barrageWrapper.value) == null ? void 0 : _a.append(item);
  6253. total.value++;
  6254. const top = (total.value - 1) % +props2.rows * item.offsetHeight + +props2.top;
  6255. item.style.top = `${top}px`;
  6256. item.dataset.id = String(id);
  6257. barrageItems.push(item);
  6258. item.addEventListener("animationend", () => {
  6259. emit("update:modelValue", [...props2.modelValue].filter((v) => String(v.id) !== item.dataset.id));
  6260. });
  6261. };
  6262. const updateBarrages = (newValue, oldValue) => {
  6263. const map = new Map(oldValue.map((item) => [item.id, item]));
  6264. newValue.forEach((item, i) => {
  6265. if (map.has(item.id)) {
  6266. map.delete(item.id);
  6267. } else {
  6268. appendBarrageItem(item, i);
  6269. }
  6270. });
  6271. map.forEach((item) => {
  6272. const index = barrageItems.findIndex((span) => span.dataset.id === String(item.id));
  6273. if (index > -1) {
  6274. barrageItems[index].remove();
  6275. barrageItems.splice(index, 1);
  6276. }
  6277. });
  6278. isInitBarrage.value = false;
  6279. };
  6280. watch(() => props2.modelValue.slice(), (newValue, oldValue) => updateBarrages(newValue != null ? newValue : [], oldValue != null ? oldValue : []), {
  6281. deep: true
  6282. });
  6283. const rootStyle = ref({});
  6284. onMounted(() => __async(this, null, function* () {
  6285. var _a;
  6286. rootStyle.value["--move-distance"] = `-${(_a = barrageWrapper.value) == null ? void 0 : _a.offsetWidth}px`;
  6287. yield nextTick();
  6288. updateBarrages(props2.modelValue, []);
  6289. }));
  6290. const play = () => {
  6291. isPlay.value = true;
  6292. barrageItems.forEach((item) => {
  6293. item.style.animationPlayState = "running";
  6294. });
  6295. };
  6296. const pause = () => {
  6297. isPlay.value = false;
  6298. barrageItems.forEach((item) => {
  6299. item.style.animationPlayState = "paused";
  6300. });
  6301. };
  6302. useExpose({
  6303. play,
  6304. pause
  6305. });
  6306. return () => {
  6307. var _a;
  6308. return createVNode("div", {
  6309. "class": bem$14(),
  6310. "ref": barrageWrapper,
  6311. "style": rootStyle.value
  6312. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  6313. };
  6314. }
  6315. });
  6316. const Barrage = withInstall(stdin_default$1h);
  6317. const [name$17, bem$13, t$g] = createNamespace("calendar");
  6318. const formatMonthTitle = (date) => t$g("monthTitle", date.getFullYear(), date.getMonth() + 1);
  6319. function compareMonth(date1, date2) {
  6320. const year1 = date1.getFullYear();
  6321. const year2 = date2.getFullYear();
  6322. if (year1 === year2) {
  6323. const month1 = date1.getMonth();
  6324. const month2 = date2.getMonth();
  6325. return month1 === month2 ? 0 : month1 > month2 ? 1 : -1;
  6326. }
  6327. return year1 > year2 ? 1 : -1;
  6328. }
  6329. function compareDay(day1, day2) {
  6330. const compareMonthResult = compareMonth(day1, day2);
  6331. if (compareMonthResult === 0) {
  6332. const date1 = day1.getDate();
  6333. const date2 = day2.getDate();
  6334. return date1 === date2 ? 0 : date1 > date2 ? 1 : -1;
  6335. }
  6336. return compareMonthResult;
  6337. }
  6338. const cloneDate = (date) => new Date(date);
  6339. const cloneDates = (dates) => Array.isArray(dates) ? dates.map(cloneDate) : cloneDate(dates);
  6340. function getDayByOffset(date, offset) {
  6341. const cloned = cloneDate(date);
  6342. cloned.setDate(cloned.getDate() + offset);
  6343. return cloned;
  6344. }
  6345. function getMonthByOffset(date, offset) {
  6346. const cloned = cloneDate(date);
  6347. cloned.setMonth(cloned.getMonth() + offset);
  6348. if (cloned.getDate() !== date.getDate()) {
  6349. cloned.setDate(0);
  6350. }
  6351. return cloned;
  6352. }
  6353. function getYearByOffset(date, offset) {
  6354. const cloned = cloneDate(date);
  6355. cloned.setFullYear(cloned.getFullYear() + offset);
  6356. if (cloned.getDate() !== date.getDate()) {
  6357. cloned.setDate(0);
  6358. }
  6359. return cloned;
  6360. }
  6361. const getPrevDay = (date) => getDayByOffset(date, -1);
  6362. const getNextDay = (date) => getDayByOffset(date, 1);
  6363. const getPrevMonth = (date) => getMonthByOffset(date, -1);
  6364. const getNextMonth = (date) => getMonthByOffset(date, 1);
  6365. const getPrevYear = (date) => getYearByOffset(date, -1);
  6366. const getNextYear = (date) => getYearByOffset(date, 1);
  6367. const getToday = () => {
  6368. const today = /* @__PURE__ */ new Date();
  6369. today.setHours(0, 0, 0, 0);
  6370. return today;
  6371. };
  6372. function calcDateNum(date) {
  6373. const day1 = date[0].getTime();
  6374. const day2 = date[1].getTime();
  6375. return (day2 - day1) / (1e3 * 60 * 60 * 24) + 1;
  6376. }
  6377. const sharedProps = extend({}, pickerSharedProps, {
  6378. modelValue: makeArrayProp(),
  6379. filter: Function,
  6380. formatter: {
  6381. type: Function,
  6382. default: (type, option) => option
  6383. }
  6384. });
  6385. const pickerInheritKeys = Object.keys(pickerSharedProps);
  6386. function times(n, iteratee) {
  6387. if (n < 0) {
  6388. return [];
  6389. }
  6390. const result = Array(n);
  6391. let index = -1;
  6392. while (++index < n) {
  6393. result[index] = iteratee(index);
  6394. }
  6395. return result;
  6396. }
  6397. const getMonthEndDay = (year, month) => 32 - new Date(year, month - 1, 32).getDate();
  6398. const genOptions = (min, max, type, formatter, filter, values) => {
  6399. const options = times(max - min + 1, (index) => {
  6400. const value = padZero(min + index);
  6401. return formatter(type, {
  6402. text: value,
  6403. value
  6404. });
  6405. });
  6406. return filter ? filter(type, options, values) : options;
  6407. };
  6408. const formatValueRange = (values, columns) => values.map((value, index) => {
  6409. const column = columns[index];
  6410. if (column.length) {
  6411. const minValue = +column[0].value;
  6412. const maxValue = +column[column.length - 1].value;
  6413. return padZero(clamp(+value, minValue, maxValue));
  6414. }
  6415. return value;
  6416. });
  6417. const [name$16] = createNamespace("calendar-day");
  6418. var stdin_default$1g = defineComponent({
  6419. name: name$16,
  6420. props: {
  6421. item: makeRequiredProp(Object),
  6422. color: String,
  6423. index: Number,
  6424. offset: makeNumberProp(0),
  6425. rowHeight: String
  6426. },
  6427. emits: ["click", "clickDisabledDate"],
  6428. setup(props2, {
  6429. emit,
  6430. slots
  6431. }) {
  6432. const style = computed(() => {
  6433. var _a;
  6434. const {
  6435. item,
  6436. index,
  6437. color,
  6438. offset,
  6439. rowHeight
  6440. } = props2;
  6441. const style2 = {
  6442. height: rowHeight
  6443. };
  6444. if (item.type === "placeholder") {
  6445. style2.width = "100%";
  6446. return style2;
  6447. }
  6448. if (index === 0) {
  6449. style2.marginLeft = `${100 * offset / 7}%`;
  6450. }
  6451. if (color) {
  6452. switch (item.type) {
  6453. case "end":
  6454. case "start":
  6455. case "start-end":
  6456. case "multiple-middle":
  6457. case "multiple-selected":
  6458. style2.background = color;
  6459. break;
  6460. case "middle":
  6461. style2.color = color;
  6462. break;
  6463. }
  6464. }
  6465. if (offset + (((_a = item.date) == null ? void 0 : _a.getDate()) || 1) > 28) {
  6466. style2.marginBottom = 0;
  6467. }
  6468. return style2;
  6469. });
  6470. const onClick = () => {
  6471. if (props2.item.type !== "disabled") {
  6472. emit("click", props2.item);
  6473. } else {
  6474. emit("clickDisabledDate", props2.item);
  6475. }
  6476. };
  6477. const renderTopInfo = () => {
  6478. const {
  6479. topInfo
  6480. } = props2.item;
  6481. if (topInfo || slots["top-info"]) {
  6482. return createVNode("div", {
  6483. "class": bem$13("top-info")
  6484. }, [slots["top-info"] ? slots["top-info"](props2.item) : topInfo]);
  6485. }
  6486. };
  6487. const renderBottomInfo = () => {
  6488. const {
  6489. bottomInfo
  6490. } = props2.item;
  6491. if (bottomInfo || slots["bottom-info"]) {
  6492. return createVNode("div", {
  6493. "class": bem$13("bottom-info")
  6494. }, [slots["bottom-info"] ? slots["bottom-info"](props2.item) : bottomInfo]);
  6495. }
  6496. };
  6497. const renderText = () => {
  6498. return slots.text ? slots.text(props2.item) : props2.item.text;
  6499. };
  6500. const renderContent = () => {
  6501. const {
  6502. item,
  6503. color,
  6504. rowHeight
  6505. } = props2;
  6506. const {
  6507. type
  6508. } = item;
  6509. const Nodes = [renderTopInfo(), renderText(), renderBottomInfo()];
  6510. if (type === "selected") {
  6511. return createVNode("div", {
  6512. "class": bem$13("selected-day"),
  6513. "style": {
  6514. width: rowHeight,
  6515. height: rowHeight,
  6516. background: color
  6517. }
  6518. }, [Nodes]);
  6519. }
  6520. return Nodes;
  6521. };
  6522. return () => {
  6523. const {
  6524. type,
  6525. className
  6526. } = props2.item;
  6527. if (type === "placeholder") {
  6528. return createVNode("div", {
  6529. "class": bem$13("day"),
  6530. "style": style.value
  6531. }, null);
  6532. }
  6533. return createVNode("div", {
  6534. "role": "gridcell",
  6535. "style": style.value,
  6536. "class": [bem$13("day", type), className],
  6537. "tabindex": type === "disabled" ? void 0 : -1,
  6538. "onClick": onClick
  6539. }, [renderContent()]);
  6540. };
  6541. }
  6542. });
  6543. const [name$15] = createNamespace("calendar-month");
  6544. const calendarMonthProps = {
  6545. date: makeRequiredProp(Date),
  6546. type: String,
  6547. color: String,
  6548. minDate: Date,
  6549. maxDate: Date,
  6550. showMark: Boolean,
  6551. rowHeight: numericProp,
  6552. formatter: Function,
  6553. lazyRender: Boolean,
  6554. currentDate: [Date, Array],
  6555. allowSameDay: Boolean,
  6556. showSubtitle: Boolean,
  6557. showMonthTitle: Boolean,
  6558. firstDayOfWeek: Number
  6559. };
  6560. var stdin_default$1f = defineComponent({
  6561. name: name$15,
  6562. props: calendarMonthProps,
  6563. emits: ["click", "clickDisabledDate"],
  6564. setup(props2, {
  6565. emit,
  6566. slots
  6567. }) {
  6568. const [visible, setVisible] = useToggle();
  6569. const daysRef = ref();
  6570. const monthRef = ref();
  6571. const height = useHeight(monthRef);
  6572. const title = computed(() => formatMonthTitle(props2.date));
  6573. const rowHeight = computed(() => addUnit(props2.rowHeight));
  6574. const offset = computed(() => {
  6575. const date = props2.date.getDate();
  6576. const day = props2.date.getDay();
  6577. const realDay = (day - date % 7 + 8) % 7;
  6578. if (props2.firstDayOfWeek) {
  6579. return (realDay + 7 - props2.firstDayOfWeek) % 7;
  6580. }
  6581. return realDay;
  6582. });
  6583. const totalDay = computed(() => getMonthEndDay(props2.date.getFullYear(), props2.date.getMonth() + 1));
  6584. const shouldRender = computed(() => visible.value || !props2.lazyRender);
  6585. const getTitle = () => title.value;
  6586. const getMultipleDayType = (day) => {
  6587. const isSelected = (date) => props2.currentDate.some((item) => compareDay(item, date) === 0);
  6588. if (isSelected(day)) {
  6589. const prevDay = getPrevDay(day);
  6590. const nextDay = getNextDay(day);
  6591. const prevSelected = isSelected(prevDay);
  6592. const nextSelected = isSelected(nextDay);
  6593. if (prevSelected && nextSelected) {
  6594. return "multiple-middle";
  6595. }
  6596. if (prevSelected) {
  6597. return "end";
  6598. }
  6599. if (nextSelected) {
  6600. return "start";
  6601. }
  6602. return "multiple-selected";
  6603. }
  6604. return "";
  6605. };
  6606. const getRangeDayType = (day) => {
  6607. const [startDay, endDay] = props2.currentDate;
  6608. if (!startDay) {
  6609. return "";
  6610. }
  6611. const compareToStart = compareDay(day, startDay);
  6612. if (!endDay) {
  6613. return compareToStart === 0 ? "start" : "";
  6614. }
  6615. const compareToEnd = compareDay(day, endDay);
  6616. if (props2.allowSameDay && compareToStart === 0 && compareToEnd === 0) {
  6617. return "start-end";
  6618. }
  6619. if (compareToStart === 0) {
  6620. return "start";
  6621. }
  6622. if (compareToEnd === 0) {
  6623. return "end";
  6624. }
  6625. if (compareToStart > 0 && compareToEnd < 0) {
  6626. return "middle";
  6627. }
  6628. return "";
  6629. };
  6630. const getDayType = (day) => {
  6631. const {
  6632. type,
  6633. minDate,
  6634. maxDate,
  6635. currentDate
  6636. } = props2;
  6637. if (minDate && compareDay(day, minDate) < 0 || maxDate && compareDay(day, maxDate) > 0) {
  6638. return "disabled";
  6639. }
  6640. if (currentDate === null) {
  6641. return "";
  6642. }
  6643. if (Array.isArray(currentDate)) {
  6644. if (type === "multiple") {
  6645. return getMultipleDayType(day);
  6646. }
  6647. if (type === "range") {
  6648. return getRangeDayType(day);
  6649. }
  6650. } else if (type === "single") {
  6651. return compareDay(day, currentDate) === 0 ? "selected" : "";
  6652. }
  6653. return "";
  6654. };
  6655. const getBottomInfo = (dayType) => {
  6656. if (props2.type === "range") {
  6657. if (dayType === "start" || dayType === "end") {
  6658. return t$g(dayType);
  6659. }
  6660. if (dayType === "start-end") {
  6661. return `${t$g("start")}/${t$g("end")}`;
  6662. }
  6663. }
  6664. };
  6665. const renderTitle = () => {
  6666. if (props2.showMonthTitle) {
  6667. return createVNode("div", {
  6668. "class": bem$13("month-title")
  6669. }, [slots["month-title"] ? slots["month-title"]({
  6670. date: props2.date,
  6671. text: title.value
  6672. }) : title.value]);
  6673. }
  6674. };
  6675. const renderMark = () => {
  6676. if (props2.showMark && shouldRender.value) {
  6677. return createVNode("div", {
  6678. "class": bem$13("month-mark")
  6679. }, [props2.date.getMonth() + 1]);
  6680. }
  6681. };
  6682. const placeholders = computed(() => {
  6683. const count = Math.ceil((totalDay.value + offset.value) / 7);
  6684. return Array(count).fill({
  6685. type: "placeholder"
  6686. });
  6687. });
  6688. const days = computed(() => {
  6689. const days2 = [];
  6690. const year = props2.date.getFullYear();
  6691. const month = props2.date.getMonth();
  6692. for (let day = 1; day <= totalDay.value; day++) {
  6693. const date = new Date(year, month, day);
  6694. const type = getDayType(date);
  6695. let config = {
  6696. date,
  6697. type,
  6698. text: day,
  6699. bottomInfo: getBottomInfo(type)
  6700. };
  6701. if (props2.formatter) {
  6702. config = props2.formatter(config);
  6703. }
  6704. days2.push(config);
  6705. }
  6706. return days2;
  6707. });
  6708. const disabledDays = computed(() => days.value.filter((day) => day.type === "disabled"));
  6709. const scrollToDate = (body, targetDate) => {
  6710. if (daysRef.value) {
  6711. const daysRect = useRect(daysRef.value);
  6712. const totalRows = placeholders.value.length;
  6713. const currentRow = Math.ceil((targetDate.getDate() + offset.value) / 7);
  6714. const rowOffset = (currentRow - 1) * daysRect.height / totalRows;
  6715. setScrollTop(body, daysRect.top + rowOffset + body.scrollTop - useRect(body).top);
  6716. }
  6717. };
  6718. const renderDay = (item, index) => createVNode(stdin_default$1g, {
  6719. "item": item,
  6720. "index": index,
  6721. "color": props2.color,
  6722. "offset": offset.value,
  6723. "rowHeight": rowHeight.value,
  6724. "onClick": (item2) => emit("click", item2),
  6725. "onClickDisabledDate": (item2) => emit("clickDisabledDate", item2)
  6726. }, pick(slots, ["top-info", "bottom-info", "text"]));
  6727. const renderDays = () => createVNode("div", {
  6728. "ref": daysRef,
  6729. "role": "grid",
  6730. "class": bem$13("days")
  6731. }, [renderMark(), (shouldRender.value ? days : placeholders).value.map(renderDay)]);
  6732. useExpose({
  6733. getTitle,
  6734. getHeight: () => height.value,
  6735. setVisible,
  6736. scrollToDate,
  6737. disabledDays
  6738. });
  6739. return () => createVNode("div", {
  6740. "class": bem$13("month"),
  6741. "ref": monthRef
  6742. }, [renderTitle(), renderDays()]);
  6743. }
  6744. });
  6745. const [name$14] = createNamespace("calendar-header");
  6746. var stdin_default$1e = defineComponent({
  6747. name: name$14,
  6748. props: {
  6749. date: Date,
  6750. minDate: Date,
  6751. maxDate: Date,
  6752. title: String,
  6753. subtitle: String,
  6754. showTitle: Boolean,
  6755. showSubtitle: Boolean,
  6756. firstDayOfWeek: Number,
  6757. switchMode: makeStringProp("none")
  6758. },
  6759. emits: ["clickSubtitle", "panelChange"],
  6760. setup(props2, {
  6761. slots,
  6762. emit
  6763. }) {
  6764. const prevMonthDisabled = computed(() => props2.date && props2.minDate && compareMonth(getPrevMonth(props2.date), props2.minDate) < 0);
  6765. const prevYearDisabled = computed(() => props2.date && props2.minDate && compareMonth(getPrevYear(props2.date), props2.minDate) < 0);
  6766. const nextMonthDisabled = computed(() => props2.date && props2.maxDate && compareMonth(getNextMonth(props2.date), props2.maxDate) > 0);
  6767. const nextYearDisabled = computed(() => props2.date && props2.maxDate && compareMonth(getNextYear(props2.date), props2.maxDate) > 0);
  6768. const renderTitle = () => {
  6769. if (props2.showTitle) {
  6770. const text = props2.title || t$g("title");
  6771. const title = slots.title ? slots.title() : text;
  6772. return createVNode("div", {
  6773. "class": bem$13("header-title")
  6774. }, [title]);
  6775. }
  6776. };
  6777. const onClickSubtitle = (event) => emit("clickSubtitle", event);
  6778. const onPanelChange = (date) => emit("panelChange", date);
  6779. const renderAction = (isNext) => {
  6780. const showYearAction = props2.switchMode === "year-month";
  6781. const monthSlot = slots[isNext ? "next-month" : "prev-month"];
  6782. const yearSlot = slots[isNext ? "next-year" : "prev-year"];
  6783. const monthDisabled = isNext ? nextMonthDisabled.value : prevMonthDisabled.value;
  6784. const yearDisabled = isNext ? nextYearDisabled.value : prevYearDisabled.value;
  6785. const monthIconName = isNext ? "arrow" : "arrow-left";
  6786. const yearIconName = isNext ? "arrow-double-right" : "arrow-double-left";
  6787. const onMonthChange = () => onPanelChange((isNext ? getNextMonth : getPrevMonth)(props2.date));
  6788. const onYearChange = () => onPanelChange((isNext ? getNextYear : getPrevYear)(props2.date));
  6789. const MonthAction = createVNode("view", {
  6790. "class": bem$13("header-action", {
  6791. disabled: monthDisabled
  6792. }),
  6793. "onClick": monthDisabled ? void 0 : onMonthChange
  6794. }, [monthSlot ? monthSlot({
  6795. disabled: monthDisabled
  6796. }) : createVNode(Icon, {
  6797. "class": {
  6798. [HAPTICS_FEEDBACK]: !monthDisabled
  6799. },
  6800. "name": monthIconName
  6801. }, null)]);
  6802. const YearAction = showYearAction && createVNode("view", {
  6803. "class": bem$13("header-action", {
  6804. disabled: yearDisabled
  6805. }),
  6806. "onClick": yearDisabled ? void 0 : onYearChange
  6807. }, [yearSlot ? yearSlot({
  6808. disabled: yearDisabled
  6809. }) : createVNode(Icon, {
  6810. "class": {
  6811. [HAPTICS_FEEDBACK]: !yearDisabled
  6812. },
  6813. "name": yearIconName
  6814. }, null)]);
  6815. return isNext ? [MonthAction, YearAction] : [YearAction, MonthAction];
  6816. };
  6817. const renderSubtitle = () => {
  6818. if (props2.showSubtitle) {
  6819. const title = slots.subtitle ? slots.subtitle({
  6820. date: props2.date,
  6821. text: props2.subtitle
  6822. }) : props2.subtitle;
  6823. const canSwitch = props2.switchMode !== "none";
  6824. return createVNode("div", {
  6825. "class": bem$13("header-subtitle", {
  6826. "with-switch": canSwitch
  6827. }),
  6828. "onClick": onClickSubtitle
  6829. }, [canSwitch ? [renderAction(), createVNode("div", {
  6830. "class": bem$13("header-subtitle-text")
  6831. }, [title]), renderAction(true)] : title]);
  6832. }
  6833. };
  6834. const renderWeekDays = () => {
  6835. const {
  6836. firstDayOfWeek
  6837. } = props2;
  6838. const weekdays = t$g("weekdays");
  6839. const renderWeekDays2 = [...weekdays.slice(firstDayOfWeek, 7), ...weekdays.slice(0, firstDayOfWeek)];
  6840. return createVNode("div", {
  6841. "class": bem$13("weekdays")
  6842. }, [renderWeekDays2.map((text) => createVNode("span", {
  6843. "class": bem$13("weekday")
  6844. }, [text]))]);
  6845. };
  6846. return () => createVNode("div", {
  6847. "class": bem$13("header")
  6848. }, [renderTitle(), renderSubtitle(), renderWeekDays()]);
  6849. }
  6850. });
  6851. const calendarProps = {
  6852. show: Boolean,
  6853. type: makeStringProp("single"),
  6854. switchMode: makeStringProp("none"),
  6855. title: String,
  6856. color: String,
  6857. round: truthProp,
  6858. readonly: Boolean,
  6859. poppable: truthProp,
  6860. maxRange: makeNumericProp(null),
  6861. position: makeStringProp("bottom"),
  6862. teleport: [String, Object],
  6863. showMark: truthProp,
  6864. showTitle: truthProp,
  6865. formatter: Function,
  6866. rowHeight: numericProp,
  6867. confirmText: String,
  6868. rangePrompt: String,
  6869. lazyRender: truthProp,
  6870. showConfirm: truthProp,
  6871. defaultDate: [Date, Array],
  6872. allowSameDay: Boolean,
  6873. showSubtitle: truthProp,
  6874. closeOnPopstate: truthProp,
  6875. showRangePrompt: truthProp,
  6876. confirmDisabledText: String,
  6877. closeOnClickOverlay: truthProp,
  6878. safeAreaInsetTop: Boolean,
  6879. safeAreaInsetBottom: truthProp,
  6880. minDate: {
  6881. type: Date,
  6882. validator: isDate
  6883. },
  6884. maxDate: {
  6885. type: Date,
  6886. validator: isDate
  6887. },
  6888. firstDayOfWeek: {
  6889. type: numericProp,
  6890. default: 0,
  6891. validator: (val) => val >= 0 && val <= 6
  6892. }
  6893. };
  6894. var stdin_default$1d = defineComponent({
  6895. name: name$17,
  6896. props: calendarProps,
  6897. emits: ["select", "confirm", "unselect", "monthShow", "overRange", "update:show", "clickSubtitle", "clickDisabledDate", "panelChange"],
  6898. setup(props2, {
  6899. emit,
  6900. slots
  6901. }) {
  6902. const canSwitch = computed(() => props2.switchMode !== "none");
  6903. const minDate = computed(() => {
  6904. if (!props2.minDate && !canSwitch.value) {
  6905. return getToday();
  6906. }
  6907. return props2.minDate;
  6908. });
  6909. const maxDate = computed(() => {
  6910. if (!props2.maxDate && !canSwitch.value) {
  6911. return getMonthByOffset(getToday(), 6);
  6912. }
  6913. return props2.maxDate;
  6914. });
  6915. const limitDateRange = (date, min = minDate.value, max = maxDate.value) => {
  6916. if (min && compareDay(date, min) === -1) {
  6917. return min;
  6918. }
  6919. if (max && compareDay(date, max) === 1) {
  6920. return max;
  6921. }
  6922. return date;
  6923. };
  6924. const getInitialDate = (defaultDate = props2.defaultDate) => {
  6925. const {
  6926. type,
  6927. allowSameDay
  6928. } = props2;
  6929. if (defaultDate === null) {
  6930. return defaultDate;
  6931. }
  6932. const now = getToday();
  6933. if (type === "range") {
  6934. if (!Array.isArray(defaultDate)) {
  6935. defaultDate = [];
  6936. }
  6937. if (defaultDate.length === 1 && compareDay(defaultDate[0], now) === 1) {
  6938. defaultDate = [];
  6939. }
  6940. const min = minDate.value;
  6941. const max = maxDate.value;
  6942. const start = limitDateRange(defaultDate[0] || now, min, max ? allowSameDay ? max : getPrevDay(max) : void 0);
  6943. const end = limitDateRange(defaultDate[1] || (allowSameDay ? now : getNextDay(now)), min ? allowSameDay ? min : getNextDay(min) : void 0);
  6944. return [start, end];
  6945. }
  6946. if (type === "multiple") {
  6947. if (Array.isArray(defaultDate)) {
  6948. return defaultDate.map((date) => limitDateRange(date));
  6949. }
  6950. return [limitDateRange(now)];
  6951. }
  6952. if (!defaultDate || Array.isArray(defaultDate)) {
  6953. defaultDate = now;
  6954. }
  6955. return limitDateRange(defaultDate);
  6956. };
  6957. const getInitialPanelDate = () => {
  6958. const date = Array.isArray(currentDate.value) ? currentDate.value[0] : currentDate.value;
  6959. return date ? date : limitDateRange(getToday());
  6960. };
  6961. let bodyHeight;
  6962. const bodyRef = ref();
  6963. const currentDate = ref(getInitialDate());
  6964. const currentPanelDate = ref(getInitialPanelDate());
  6965. const currentMonthRef = ref();
  6966. const [monthRefs, setMonthRefs] = useRefs();
  6967. const dayOffset = computed(() => props2.firstDayOfWeek ? +props2.firstDayOfWeek % 7 : 0);
  6968. const months = computed(() => {
  6969. const months2 = [];
  6970. if (!minDate.value || !maxDate.value) {
  6971. return months2;
  6972. }
  6973. const cursor = new Date(minDate.value);
  6974. cursor.setDate(1);
  6975. do {
  6976. months2.push(new Date(cursor));
  6977. cursor.setMonth(cursor.getMonth() + 1);
  6978. } while (compareMonth(cursor, maxDate.value) !== 1);
  6979. return months2;
  6980. });
  6981. const buttonDisabled = computed(() => {
  6982. if (currentDate.value) {
  6983. if (props2.type === "range") {
  6984. return !currentDate.value[0] || !currentDate.value[1];
  6985. }
  6986. if (props2.type === "multiple") {
  6987. return !currentDate.value.length;
  6988. }
  6989. }
  6990. return !currentDate.value;
  6991. });
  6992. const getSelectedDate = () => currentDate.value;
  6993. const onScroll = () => {
  6994. const top = getScrollTop(bodyRef.value);
  6995. const bottom = top + bodyHeight;
  6996. const heights = months.value.map((item, index) => monthRefs.value[index].getHeight());
  6997. const heightSum = heights.reduce((a, b) => a + b, 0);
  6998. if (bottom > heightSum && top > 0) {
  6999. return;
  7000. }
  7001. let height = 0;
  7002. let currentMonth;
  7003. const visibleRange = [-1, -1];
  7004. for (let i = 0; i < months.value.length; i++) {
  7005. const month = monthRefs.value[i];
  7006. const visible = height <= bottom && height + heights[i] >= top;
  7007. if (visible) {
  7008. visibleRange[1] = i;
  7009. if (!currentMonth) {
  7010. currentMonth = month;
  7011. visibleRange[0] = i;
  7012. }
  7013. if (!monthRefs.value[i].showed) {
  7014. monthRefs.value[i].showed = true;
  7015. emit("monthShow", {
  7016. date: month.date,
  7017. title: month.getTitle()
  7018. });
  7019. }
  7020. }
  7021. height += heights[i];
  7022. }
  7023. months.value.forEach((month, index) => {
  7024. const visible = index >= visibleRange[0] - 1 && index <= visibleRange[1] + 1;
  7025. monthRefs.value[index].setVisible(visible);
  7026. });
  7027. if (currentMonth) {
  7028. currentMonthRef.value = currentMonth;
  7029. }
  7030. };
  7031. const scrollToDate = (targetDate) => {
  7032. if (canSwitch.value) {
  7033. currentPanelDate.value = targetDate;
  7034. } else {
  7035. raf(() => {
  7036. months.value.some((month, index) => {
  7037. if (compareMonth(month, targetDate) === 0) {
  7038. if (bodyRef.value) {
  7039. monthRefs.value[index].scrollToDate(bodyRef.value, targetDate);
  7040. }
  7041. return true;
  7042. }
  7043. return false;
  7044. });
  7045. onScroll();
  7046. });
  7047. }
  7048. };
  7049. const scrollToCurrentDate = () => {
  7050. if (props2.poppable && !props2.show) {
  7051. return;
  7052. }
  7053. if (currentDate.value) {
  7054. const targetDate = props2.type === "single" ? currentDate.value : currentDate.value[0];
  7055. if (isDate(targetDate)) {
  7056. scrollToDate(targetDate);
  7057. }
  7058. } else if (!canSwitch.value) {
  7059. raf(onScroll);
  7060. }
  7061. };
  7062. const init = () => {
  7063. if (props2.poppable && !props2.show) {
  7064. return;
  7065. }
  7066. if (!canSwitch.value) {
  7067. raf(() => {
  7068. bodyHeight = Math.floor(useRect(bodyRef).height);
  7069. });
  7070. }
  7071. scrollToCurrentDate();
  7072. };
  7073. const reset = (date = getInitialDate()) => {
  7074. currentDate.value = date;
  7075. scrollToCurrentDate();
  7076. };
  7077. const checkRange = (date) => {
  7078. const {
  7079. maxRange,
  7080. rangePrompt,
  7081. showRangePrompt
  7082. } = props2;
  7083. if (maxRange && calcDateNum(date) > +maxRange) {
  7084. if (showRangePrompt) {
  7085. showToast(rangePrompt || t$g("rangePrompt", maxRange));
  7086. }
  7087. emit("overRange");
  7088. return false;
  7089. }
  7090. return true;
  7091. };
  7092. const onPanelChange = (date) => {
  7093. currentPanelDate.value = date;
  7094. emit("panelChange", {
  7095. date
  7096. });
  7097. };
  7098. const onConfirm = () => {
  7099. var _a;
  7100. return emit("confirm", (_a = currentDate.value) != null ? _a : cloneDates(currentDate.value));
  7101. };
  7102. const select = (date, complete) => {
  7103. const setCurrentDate = (date2) => {
  7104. currentDate.value = date2;
  7105. emit("select", cloneDates(date2));
  7106. };
  7107. if (complete && props2.type === "range") {
  7108. const valid = checkRange(date);
  7109. if (!valid) {
  7110. setCurrentDate([date[0], getDayByOffset(date[0], +props2.maxRange - 1)]);
  7111. return;
  7112. }
  7113. }
  7114. setCurrentDate(date);
  7115. if (complete && !props2.showConfirm) {
  7116. onConfirm();
  7117. }
  7118. };
  7119. const getDisabledDate = (disabledDays2, startDay, date) => {
  7120. var _a;
  7121. return (_a = disabledDays2.find((day) => compareDay(startDay, day.date) === -1 && compareDay(day.date, date) === -1)) == null ? void 0 : _a.date;
  7122. };
  7123. const disabledDays = computed(() => monthRefs.value.reduce((arr, ref2) => {
  7124. var _a, _b;
  7125. arr.push(...(_b = (_a = ref2.disabledDays) == null ? void 0 : _a.value) != null ? _b : []);
  7126. return arr;
  7127. }, []));
  7128. const onClickDay = (item) => {
  7129. if (props2.readonly || !item.date) {
  7130. return;
  7131. }
  7132. const {
  7133. date
  7134. } = item;
  7135. const {
  7136. type
  7137. } = props2;
  7138. if (type === "range") {
  7139. if (!currentDate.value) {
  7140. select([date]);
  7141. return;
  7142. }
  7143. const [startDay, endDay] = currentDate.value;
  7144. if (startDay && !endDay) {
  7145. const compareToStart = compareDay(date, startDay);
  7146. if (compareToStart === 1) {
  7147. const disabledDay = getDisabledDate(disabledDays.value, startDay, date);
  7148. if (disabledDay) {
  7149. const endDay2 = getPrevDay(disabledDay);
  7150. if (compareDay(startDay, endDay2) === -1) {
  7151. select([startDay, endDay2]);
  7152. } else {
  7153. select([date]);
  7154. }
  7155. } else {
  7156. select([startDay, date], true);
  7157. }
  7158. } else if (compareToStart === -1) {
  7159. select([date]);
  7160. } else if (props2.allowSameDay) {
  7161. select([date, date], true);
  7162. }
  7163. } else {
  7164. select([date]);
  7165. }
  7166. } else if (type === "multiple") {
  7167. if (!currentDate.value) {
  7168. select([date]);
  7169. return;
  7170. }
  7171. const dates = currentDate.value;
  7172. const selectedIndex = dates.findIndex((dateItem) => compareDay(dateItem, date) === 0);
  7173. if (selectedIndex !== -1) {
  7174. const [unselectedDate] = dates.splice(selectedIndex, 1);
  7175. emit("unselect", cloneDate(unselectedDate));
  7176. } else if (props2.maxRange && dates.length >= +props2.maxRange) {
  7177. showToast(props2.rangePrompt || t$g("rangePrompt", props2.maxRange));
  7178. } else {
  7179. select([...dates, date]);
  7180. }
  7181. } else {
  7182. select(date, true);
  7183. }
  7184. };
  7185. const updateShow = (value) => emit("update:show", value);
  7186. const renderMonth = (date, index) => {
  7187. const showMonthTitle = index !== 0 || !props2.showSubtitle;
  7188. return createVNode(stdin_default$1f, mergeProps({
  7189. "ref": canSwitch.value ? currentMonthRef : setMonthRefs(index),
  7190. "date": date,
  7191. "currentDate": currentDate.value,
  7192. "showMonthTitle": showMonthTitle,
  7193. "firstDayOfWeek": dayOffset.value,
  7194. "lazyRender": canSwitch.value ? false : props2.lazyRender,
  7195. "maxDate": maxDate.value,
  7196. "minDate": minDate.value
  7197. }, pick(props2, ["type", "color", "showMark", "formatter", "rowHeight", "showSubtitle", "allowSameDay"]), {
  7198. "onClick": onClickDay,
  7199. "onClickDisabledDate": (item) => emit("clickDisabledDate", item)
  7200. }), pick(slots, ["top-info", "bottom-info", "month-title", "text"]));
  7201. };
  7202. const renderFooterButton = () => {
  7203. if (slots.footer) {
  7204. return slots.footer();
  7205. }
  7206. if (props2.showConfirm) {
  7207. const slot = slots["confirm-text"];
  7208. const disabled = buttonDisabled.value;
  7209. const text = disabled ? props2.confirmDisabledText : props2.confirmText;
  7210. return createVNode(Button, {
  7211. "round": true,
  7212. "block": true,
  7213. "type": "primary",
  7214. "color": props2.color,
  7215. "class": bem$13("confirm"),
  7216. "disabled": disabled,
  7217. "nativeType": "button",
  7218. "onClick": onConfirm
  7219. }, {
  7220. default: () => [slot ? slot({
  7221. disabled
  7222. }) : text || t$g("confirm")]
  7223. });
  7224. }
  7225. };
  7226. const renderFooter = () => createVNode("div", {
  7227. "class": [bem$13("footer"), {
  7228. "van-safe-area-bottom": props2.safeAreaInsetBottom
  7229. }]
  7230. }, [renderFooterButton()]);
  7231. const renderCalendar = () => {
  7232. var _a, _b;
  7233. return createVNode("div", {
  7234. "class": bem$13()
  7235. }, [createVNode(stdin_default$1e, {
  7236. "date": (_a = currentMonthRef.value) == null ? void 0 : _a.date,
  7237. "maxDate": maxDate.value,
  7238. "minDate": minDate.value,
  7239. "title": props2.title,
  7240. "subtitle": (_b = currentMonthRef.value) == null ? void 0 : _b.getTitle(),
  7241. "showTitle": props2.showTitle,
  7242. "showSubtitle": props2.showSubtitle,
  7243. "switchMode": props2.switchMode,
  7244. "firstDayOfWeek": dayOffset.value,
  7245. "onClickSubtitle": (event) => emit("clickSubtitle", event),
  7246. "onPanelChange": onPanelChange
  7247. }, pick(slots, ["title", "subtitle", "prev-month", "prev-year", "next-month", "next-year"])), createVNode("div", {
  7248. "ref": bodyRef,
  7249. "class": bem$13("body"),
  7250. "onScroll": canSwitch.value ? void 0 : onScroll
  7251. }, [canSwitch.value ? renderMonth(currentPanelDate.value, 0) : months.value.map(renderMonth)]), renderFooter()]);
  7252. };
  7253. watch(() => props2.show, init);
  7254. watch(() => [props2.type, props2.minDate, props2.maxDate, props2.switchMode], () => reset(getInitialDate(currentDate.value)));
  7255. watch(() => props2.defaultDate, (value) => {
  7256. reset(value);
  7257. });
  7258. useExpose({
  7259. reset,
  7260. scrollToDate,
  7261. getSelectedDate
  7262. });
  7263. onMountedOrActivated(init);
  7264. return () => {
  7265. if (props2.poppable) {
  7266. return createVNode(Popup, {
  7267. "show": props2.show,
  7268. "class": bem$13("popup"),
  7269. "round": props2.round,
  7270. "position": props2.position,
  7271. "closeable": props2.showTitle || props2.showSubtitle,
  7272. "teleport": props2.teleport,
  7273. "closeOnPopstate": props2.closeOnPopstate,
  7274. "safeAreaInsetTop": props2.safeAreaInsetTop,
  7275. "closeOnClickOverlay": props2.closeOnClickOverlay,
  7276. "onUpdate:show": updateShow
  7277. }, {
  7278. default: renderCalendar
  7279. });
  7280. }
  7281. return renderCalendar();
  7282. };
  7283. }
  7284. });
  7285. const Calendar = withInstall(stdin_default$1d);
  7286. const [name$13, bem$12] = createNamespace("image");
  7287. const imageProps = {
  7288. src: String,
  7289. alt: String,
  7290. fit: String,
  7291. position: String,
  7292. round: Boolean,
  7293. block: Boolean,
  7294. width: numericProp,
  7295. height: numericProp,
  7296. radius: numericProp,
  7297. lazyLoad: Boolean,
  7298. iconSize: numericProp,
  7299. showError: truthProp,
  7300. errorIcon: makeStringProp("photo-fail"),
  7301. iconPrefix: String,
  7302. showLoading: truthProp,
  7303. loadingIcon: makeStringProp("photo"),
  7304. crossorigin: String,
  7305. referrerpolicy: String
  7306. };
  7307. var stdin_default$1c = defineComponent({
  7308. name: name$13,
  7309. props: imageProps,
  7310. emits: ["load", "error"],
  7311. setup(props2, {
  7312. emit,
  7313. slots
  7314. }) {
  7315. const error = ref(false);
  7316. const loading = ref(true);
  7317. const imageRef = ref();
  7318. const {
  7319. $Lazyload
  7320. } = getCurrentInstance().proxy;
  7321. const style = computed(() => {
  7322. const style2 = {
  7323. width: addUnit(props2.width),
  7324. height: addUnit(props2.height)
  7325. };
  7326. if (isDef(props2.radius)) {
  7327. style2.overflow = "hidden";
  7328. style2.borderRadius = addUnit(props2.radius);
  7329. }
  7330. return style2;
  7331. });
  7332. watch(() => props2.src, () => {
  7333. error.value = false;
  7334. loading.value = true;
  7335. });
  7336. const onLoad = (event) => {
  7337. if (loading.value) {
  7338. loading.value = false;
  7339. emit("load", event);
  7340. }
  7341. };
  7342. const triggerLoad = () => {
  7343. const loadEvent = new Event("load");
  7344. Object.defineProperty(loadEvent, "target", {
  7345. value: imageRef.value,
  7346. enumerable: true
  7347. });
  7348. onLoad(loadEvent);
  7349. };
  7350. const onError = (event) => {
  7351. error.value = true;
  7352. loading.value = false;
  7353. emit("error", event);
  7354. };
  7355. const renderIcon = (name2, className, slot) => {
  7356. if (slot) {
  7357. return slot();
  7358. }
  7359. return createVNode(Icon, {
  7360. "name": name2,
  7361. "size": props2.iconSize,
  7362. "class": className,
  7363. "classPrefix": props2.iconPrefix
  7364. }, null);
  7365. };
  7366. const renderPlaceholder = () => {
  7367. if (loading.value && props2.showLoading) {
  7368. return createVNode("div", {
  7369. "class": bem$12("loading")
  7370. }, [renderIcon(props2.loadingIcon, bem$12("loading-icon"), slots.loading)]);
  7371. }
  7372. if (error.value && props2.showError) {
  7373. return createVNode("div", {
  7374. "class": bem$12("error")
  7375. }, [renderIcon(props2.errorIcon, bem$12("error-icon"), slots.error)]);
  7376. }
  7377. };
  7378. const renderImage = () => {
  7379. if (error.value || !props2.src) {
  7380. return;
  7381. }
  7382. const attrs = {
  7383. alt: props2.alt,
  7384. class: bem$12("img"),
  7385. style: {
  7386. objectFit: props2.fit,
  7387. objectPosition: props2.position
  7388. },
  7389. crossorigin: props2.crossorigin,
  7390. referrerpolicy: props2.referrerpolicy
  7391. };
  7392. if (props2.lazyLoad) {
  7393. return withDirectives(createVNode("img", mergeProps({
  7394. "ref": imageRef
  7395. }, attrs), null), [[resolveDirective("lazy"), props2.src]]);
  7396. }
  7397. return createVNode("img", mergeProps({
  7398. "ref": imageRef,
  7399. "src": props2.src,
  7400. "onLoad": onLoad,
  7401. "onError": onError
  7402. }, attrs), null);
  7403. };
  7404. const onLazyLoaded = ({
  7405. el
  7406. }) => {
  7407. const check = () => {
  7408. if (el === imageRef.value && loading.value) {
  7409. triggerLoad();
  7410. }
  7411. };
  7412. if (imageRef.value) {
  7413. check();
  7414. } else {
  7415. nextTick(check);
  7416. }
  7417. };
  7418. const onLazyLoadError = ({
  7419. el
  7420. }) => {
  7421. if (el === imageRef.value && !error.value) {
  7422. onError();
  7423. }
  7424. };
  7425. if ($Lazyload && inBrowser) {
  7426. $Lazyload.$on("loaded", onLazyLoaded);
  7427. $Lazyload.$on("error", onLazyLoadError);
  7428. onBeforeUnmount(() => {
  7429. $Lazyload.$off("loaded", onLazyLoaded);
  7430. $Lazyload.$off("error", onLazyLoadError);
  7431. });
  7432. }
  7433. onMounted(() => {
  7434. nextTick(() => {
  7435. var _a;
  7436. if (((_a = imageRef.value) == null ? void 0 : _a.complete) && !props2.lazyLoad) {
  7437. triggerLoad();
  7438. }
  7439. });
  7440. });
  7441. return () => {
  7442. var _a;
  7443. return createVNode("div", {
  7444. "class": bem$12({
  7445. round: props2.round,
  7446. block: props2.block
  7447. }),
  7448. "style": style.value
  7449. }, [renderImage(), renderPlaceholder(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7450. };
  7451. }
  7452. });
  7453. const Image$1 = withInstall(stdin_default$1c);
  7454. const [name$12, bem$11] = createNamespace("card");
  7455. const cardProps = {
  7456. tag: String,
  7457. num: numericProp,
  7458. desc: String,
  7459. thumb: String,
  7460. title: String,
  7461. price: numericProp,
  7462. centered: Boolean,
  7463. lazyLoad: Boolean,
  7464. currency: makeStringProp("¥"),
  7465. thumbLink: String,
  7466. originPrice: numericProp
  7467. };
  7468. var stdin_default$1b = defineComponent({
  7469. name: name$12,
  7470. props: cardProps,
  7471. emits: ["clickThumb"],
  7472. setup(props2, {
  7473. slots,
  7474. emit
  7475. }) {
  7476. const renderTitle = () => {
  7477. if (slots.title) {
  7478. return slots.title();
  7479. }
  7480. if (props2.title) {
  7481. return createVNode("div", {
  7482. "class": [bem$11("title"), "van-multi-ellipsis--l2"]
  7483. }, [props2.title]);
  7484. }
  7485. };
  7486. const renderThumbTag = () => {
  7487. if (slots.tag || props2.tag) {
  7488. return createVNode("div", {
  7489. "class": bem$11("tag")
  7490. }, [slots.tag ? slots.tag() : createVNode(Tag, {
  7491. "mark": true,
  7492. "type": "primary"
  7493. }, {
  7494. default: () => [props2.tag]
  7495. })]);
  7496. }
  7497. };
  7498. const renderThumbImage = () => {
  7499. if (slots.thumb) {
  7500. return slots.thumb();
  7501. }
  7502. return createVNode(Image$1, {
  7503. "src": props2.thumb,
  7504. "fit": "cover",
  7505. "width": "100%",
  7506. "height": "100%",
  7507. "lazyLoad": props2.lazyLoad
  7508. }, null);
  7509. };
  7510. const renderThumb = () => {
  7511. if (slots.thumb || props2.thumb) {
  7512. return createVNode("a", {
  7513. "href": props2.thumbLink,
  7514. "class": bem$11("thumb"),
  7515. "onClick": (event) => emit("clickThumb", event)
  7516. }, [renderThumbImage(), renderThumbTag()]);
  7517. }
  7518. };
  7519. const renderDesc = () => {
  7520. if (slots.desc) {
  7521. return slots.desc();
  7522. }
  7523. if (props2.desc) {
  7524. return createVNode("div", {
  7525. "class": [bem$11("desc"), "van-ellipsis"]
  7526. }, [props2.desc]);
  7527. }
  7528. };
  7529. const renderPriceText = () => {
  7530. const priceArr = props2.price.toString().split(".");
  7531. return createVNode("div", null, [createVNode("span", {
  7532. "class": bem$11("price-currency")
  7533. }, [props2.currency]), createVNode("span", {
  7534. "class": bem$11("price-integer")
  7535. }, [priceArr[0]]), priceArr.length > 1 && createVNode(Fragment, null, [createTextVNode("."), createVNode("span", {
  7536. "class": bem$11("price-decimal")
  7537. }, [priceArr[1]])])]);
  7538. };
  7539. return () => {
  7540. var _a, _b, _c;
  7541. const showNum = slots.num || isDef(props2.num);
  7542. const showPrice = slots.price || isDef(props2.price);
  7543. const showOriginPrice = slots["origin-price"] || isDef(props2.originPrice);
  7544. const showBottom = showNum || showPrice || showOriginPrice || slots.bottom;
  7545. const Price = showPrice && createVNode("div", {
  7546. "class": bem$11("price")
  7547. }, [slots.price ? slots.price() : renderPriceText()]);
  7548. const OriginPrice = showOriginPrice && createVNode("div", {
  7549. "class": bem$11("origin-price")
  7550. }, [slots["origin-price"] ? slots["origin-price"]() : `${props2.currency} ${props2.originPrice}`]);
  7551. const Num = showNum && createVNode("div", {
  7552. "class": bem$11("num")
  7553. }, [slots.num ? slots.num() : `x${props2.num}`]);
  7554. const Footer = slots.footer && createVNode("div", {
  7555. "class": bem$11("footer")
  7556. }, [slots.footer()]);
  7557. const Bottom = showBottom && createVNode("div", {
  7558. "class": bem$11("bottom")
  7559. }, [(_a = slots["price-top"]) == null ? void 0 : _a.call(slots), Price, OriginPrice, Num, (_b = slots.bottom) == null ? void 0 : _b.call(slots)]);
  7560. return createVNode("div", {
  7561. "class": bem$11()
  7562. }, [createVNode("div", {
  7563. "class": bem$11("header")
  7564. }, [renderThumb(), createVNode("div", {
  7565. "class": bem$11("content", {
  7566. centered: props2.centered
  7567. })
  7568. }, [createVNode("div", null, [renderTitle(), renderDesc(), (_c = slots.tags) == null ? void 0 : _c.call(slots)]), Bottom])]), Footer]);
  7569. };
  7570. }
  7571. });
  7572. const Card = withInstall(stdin_default$1b);
  7573. const [name$11, bem$10, t$f] = createNamespace("cascader");
  7574. const cascaderProps = {
  7575. title: String,
  7576. options: makeArrayProp(),
  7577. closeable: truthProp,
  7578. swipeable: truthProp,
  7579. closeIcon: makeStringProp("cross"),
  7580. showHeader: truthProp,
  7581. modelValue: numericProp,
  7582. fieldNames: Object,
  7583. placeholder: String,
  7584. activeColor: String
  7585. };
  7586. var stdin_default$1a = defineComponent({
  7587. name: name$11,
  7588. props: cascaderProps,
  7589. emits: ["close", "change", "finish", "clickTab", "update:modelValue"],
  7590. setup(props2, {
  7591. slots,
  7592. emit
  7593. }) {
  7594. const tabs = ref([]);
  7595. const activeTab = ref(0);
  7596. const [selectedElementRefs, setSelectedElementRefs] = useRefs();
  7597. const {
  7598. text: textKey,
  7599. value: valueKey,
  7600. children: childrenKey
  7601. } = extend({
  7602. text: "text",
  7603. value: "value",
  7604. children: "children"
  7605. }, props2.fieldNames);
  7606. const getSelectedOptionsByValue = (options, value) => {
  7607. for (const option of options) {
  7608. if (option[valueKey] === value) {
  7609. return [option];
  7610. }
  7611. if (option[childrenKey]) {
  7612. const selectedOptions = getSelectedOptionsByValue(option[childrenKey], value);
  7613. if (selectedOptions) {
  7614. return [option, ...selectedOptions];
  7615. }
  7616. }
  7617. }
  7618. };
  7619. const updateTabs = () => {
  7620. const {
  7621. options,
  7622. modelValue
  7623. } = props2;
  7624. if (modelValue !== void 0) {
  7625. const selectedOptions = getSelectedOptionsByValue(options, modelValue);
  7626. if (selectedOptions) {
  7627. let optionsCursor = options;
  7628. tabs.value = selectedOptions.map((option) => {
  7629. const tab = {
  7630. options: optionsCursor,
  7631. selected: option
  7632. };
  7633. const next = optionsCursor.find((item) => item[valueKey] === option[valueKey]);
  7634. if (next) {
  7635. optionsCursor = next[childrenKey];
  7636. }
  7637. return tab;
  7638. });
  7639. if (optionsCursor) {
  7640. tabs.value.push({
  7641. options: optionsCursor,
  7642. selected: null
  7643. });
  7644. }
  7645. nextTick(() => {
  7646. activeTab.value = tabs.value.length - 1;
  7647. });
  7648. return;
  7649. }
  7650. }
  7651. tabs.value = [{
  7652. options,
  7653. selected: null
  7654. }];
  7655. };
  7656. const onSelect = (option, tabIndex) => {
  7657. if (option.disabled) {
  7658. return;
  7659. }
  7660. tabs.value[tabIndex].selected = option;
  7661. if (tabs.value.length > tabIndex + 1) {
  7662. tabs.value = tabs.value.slice(0, tabIndex + 1);
  7663. }
  7664. if (option[childrenKey]) {
  7665. const nextTab = {
  7666. options: option[childrenKey],
  7667. selected: null
  7668. };
  7669. if (tabs.value[tabIndex + 1]) {
  7670. tabs.value[tabIndex + 1] = nextTab;
  7671. } else {
  7672. tabs.value.push(nextTab);
  7673. }
  7674. nextTick(() => {
  7675. activeTab.value++;
  7676. });
  7677. }
  7678. const selectedOptions = tabs.value.map((tab) => tab.selected).filter(Boolean);
  7679. emit("update:modelValue", option[valueKey]);
  7680. const params = {
  7681. value: option[valueKey],
  7682. tabIndex,
  7683. selectedOptions
  7684. };
  7685. emit("change", params);
  7686. if (!option[childrenKey]) {
  7687. emit("finish", params);
  7688. }
  7689. };
  7690. const onClose = () => emit("close");
  7691. const onClickTab = ({
  7692. name: name2,
  7693. title
  7694. }) => emit("clickTab", name2, title);
  7695. const renderHeader = () => props2.showHeader ? createVNode("div", {
  7696. "class": bem$10("header")
  7697. }, [createVNode("h2", {
  7698. "class": bem$10("title")
  7699. }, [slots.title ? slots.title() : props2.title]), props2.closeable ? createVNode(Icon, {
  7700. "name": props2.closeIcon,
  7701. "class": [bem$10("close-icon"), HAPTICS_FEEDBACK],
  7702. "onClick": onClose
  7703. }, null) : null]) : null;
  7704. const renderOption = (option, selectedOption, tabIndex) => {
  7705. const {
  7706. disabled
  7707. } = option;
  7708. const selected = !!(selectedOption && option[valueKey] === selectedOption[valueKey]);
  7709. const color = option.color || (selected ? props2.activeColor : void 0);
  7710. const Text2 = slots.option ? slots.option({
  7711. option,
  7712. selected
  7713. }) : createVNode("span", null, [option[textKey]]);
  7714. return createVNode("li", {
  7715. "ref": selected ? setSelectedElementRefs(tabIndex) : void 0,
  7716. "role": "menuitemradio",
  7717. "class": [bem$10("option", {
  7718. selected,
  7719. disabled
  7720. }), option.className],
  7721. "style": {
  7722. color
  7723. },
  7724. "tabindex": disabled ? void 0 : selected ? 0 : -1,
  7725. "aria-checked": selected,
  7726. "aria-disabled": disabled || void 0,
  7727. "onClick": () => onSelect(option, tabIndex)
  7728. }, [Text2, selected ? createVNode(Icon, {
  7729. "name": "success",
  7730. "class": bem$10("selected-icon")
  7731. }, null) : null]);
  7732. };
  7733. const renderOptions = (options, selectedOption, tabIndex) => createVNode("ul", {
  7734. "role": "menu",
  7735. "class": bem$10("options")
  7736. }, [options.map((option) => renderOption(option, selectedOption, tabIndex))]);
  7737. const renderTab = (tab, tabIndex) => {
  7738. const {
  7739. options,
  7740. selected
  7741. } = tab;
  7742. const placeholder = props2.placeholder || t$f("select");
  7743. const title = selected ? selected[textKey] : placeholder;
  7744. return createVNode(Tab, {
  7745. "title": title,
  7746. "titleClass": bem$10("tab", {
  7747. unselected: !selected
  7748. })
  7749. }, {
  7750. default: () => {
  7751. var _a, _b;
  7752. return [(_a = slots["options-top"]) == null ? void 0 : _a.call(slots, {
  7753. tabIndex
  7754. }), renderOptions(options, selected, tabIndex), (_b = slots["options-bottom"]) == null ? void 0 : _b.call(slots, {
  7755. tabIndex
  7756. })];
  7757. }
  7758. });
  7759. };
  7760. const renderTabs = () => createVNode(Tabs, {
  7761. "active": activeTab.value,
  7762. "onUpdate:active": ($event) => activeTab.value = $event,
  7763. "shrink": true,
  7764. "animated": true,
  7765. "class": bem$10("tabs"),
  7766. "color": props2.activeColor,
  7767. "swipeable": props2.swipeable,
  7768. "onClickTab": onClickTab
  7769. }, {
  7770. default: () => [tabs.value.map(renderTab)]
  7771. });
  7772. const scrollIntoView = (el) => {
  7773. const scrollParent = el.parentElement;
  7774. if (scrollParent) {
  7775. scrollParent.scrollTop = el.offsetTop - (scrollParent.offsetHeight - el.offsetHeight) / 2;
  7776. }
  7777. };
  7778. updateTabs();
  7779. watch(activeTab, (value) => {
  7780. const el = selectedElementRefs.value[value];
  7781. if (el) scrollIntoView(el);
  7782. });
  7783. watch(() => props2.options, updateTabs, {
  7784. deep: true
  7785. });
  7786. watch(() => props2.modelValue, (value) => {
  7787. if (value !== void 0) {
  7788. const values = tabs.value.map((tab) => {
  7789. var _a;
  7790. return (_a = tab.selected) == null ? void 0 : _a[valueKey];
  7791. });
  7792. if (values.includes(value)) {
  7793. return;
  7794. }
  7795. }
  7796. updateTabs();
  7797. });
  7798. return () => createVNode("div", {
  7799. "class": bem$10()
  7800. }, [renderHeader(), renderTabs()]);
  7801. }
  7802. });
  7803. const Cascader = withInstall(stdin_default$1a);
  7804. const [name$10, bem$$] = createNamespace("cell-group");
  7805. const cellGroupProps = {
  7806. title: String,
  7807. inset: Boolean,
  7808. border: truthProp
  7809. };
  7810. var stdin_default$19 = defineComponent({
  7811. name: name$10,
  7812. inheritAttrs: false,
  7813. props: cellGroupProps,
  7814. setup(props2, {
  7815. slots,
  7816. attrs
  7817. }) {
  7818. const renderGroup = () => {
  7819. var _a;
  7820. return createVNode("div", mergeProps({
  7821. "class": [bem$$({
  7822. inset: props2.inset
  7823. }), {
  7824. [BORDER_TOP_BOTTOM]: props2.border && !props2.inset
  7825. }]
  7826. }, attrs, useScopeId()), [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  7827. };
  7828. const renderTitle = () => createVNode("div", {
  7829. "class": bem$$("title", {
  7830. inset: props2.inset
  7831. })
  7832. }, [slots.title ? slots.title() : props2.title]);
  7833. return () => {
  7834. if (props2.title || slots.title) {
  7835. return createVNode(Fragment, null, [renderTitle(), renderGroup()]);
  7836. }
  7837. return renderGroup();
  7838. };
  7839. }
  7840. });
  7841. const CellGroup = withInstall(stdin_default$19);
  7842. const [name$$, bem$_] = createNamespace("circle");
  7843. let uid = 0;
  7844. const format = (rate) => Math.min(Math.max(+rate, 0), 100);
  7845. function getPath(clockwise, viewBoxSize) {
  7846. const sweepFlag = clockwise ? 1 : 0;
  7847. 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`;
  7848. }
  7849. const circleProps = {
  7850. text: String,
  7851. size: numericProp,
  7852. fill: makeStringProp("none"),
  7853. rate: makeNumericProp(100),
  7854. speed: makeNumericProp(0),
  7855. color: [String, Object],
  7856. clockwise: truthProp,
  7857. layerColor: String,
  7858. currentRate: makeNumberProp(0),
  7859. strokeWidth: makeNumericProp(40),
  7860. strokeLinecap: String,
  7861. startPosition: makeStringProp("top")
  7862. };
  7863. var stdin_default$18 = defineComponent({
  7864. name: name$$,
  7865. props: circleProps,
  7866. emits: ["update:currentRate"],
  7867. setup(props2, {
  7868. emit,
  7869. slots
  7870. }) {
  7871. const id = `van-circle-${uid++}`;
  7872. const viewBoxSize = computed(() => +props2.strokeWidth + 1e3);
  7873. const path = computed(() => getPath(props2.clockwise, viewBoxSize.value));
  7874. const svgStyle = computed(() => {
  7875. const ROTATE_ANGLE_MAP = {
  7876. top: 0,
  7877. right: 90,
  7878. bottom: 180,
  7879. left: 270
  7880. };
  7881. const angleValue = ROTATE_ANGLE_MAP[props2.startPosition];
  7882. if (angleValue) {
  7883. return {
  7884. transform: `rotate(${angleValue}deg)`
  7885. };
  7886. }
  7887. });
  7888. watch(() => props2.rate, (rate) => {
  7889. let rafId;
  7890. const startTime = Date.now();
  7891. const startRate = props2.currentRate;
  7892. const endRate = format(rate);
  7893. const duration = Math.abs((startRate - endRate) * 1e3 / +props2.speed);
  7894. const animate = () => {
  7895. const now = Date.now();
  7896. const progress = Math.min((now - startTime) / duration, 1);
  7897. const rate2 = progress * (endRate - startRate) + startRate;
  7898. emit("update:currentRate", format(parseFloat(rate2.toFixed(1))));
  7899. if (endRate > startRate ? rate2 < endRate : rate2 > endRate) {
  7900. rafId = raf(animate);
  7901. }
  7902. };
  7903. if (props2.speed) {
  7904. if (rafId) {
  7905. cancelRaf(rafId);
  7906. }
  7907. rafId = raf(animate);
  7908. } else {
  7909. emit("update:currentRate", endRate);
  7910. }
  7911. }, {
  7912. immediate: true
  7913. });
  7914. const renderHover = () => {
  7915. const PERIMETER = 3140;
  7916. const {
  7917. strokeWidth,
  7918. currentRate,
  7919. strokeLinecap
  7920. } = props2;
  7921. const offset = PERIMETER * currentRate / 100;
  7922. const color = isObject(props2.color) ? `url(#${id})` : props2.color;
  7923. const style = {
  7924. stroke: color,
  7925. strokeWidth: `${+strokeWidth + 1}px`,
  7926. strokeLinecap,
  7927. strokeDasharray: `${offset}px ${PERIMETER}px`
  7928. };
  7929. return createVNode("path", {
  7930. "d": path.value,
  7931. "style": style,
  7932. "class": bem$_("hover"),
  7933. "stroke": color
  7934. }, null);
  7935. };
  7936. const renderLayer = () => {
  7937. const style = {
  7938. fill: props2.fill,
  7939. stroke: props2.layerColor,
  7940. strokeWidth: `${props2.strokeWidth}px`
  7941. };
  7942. return createVNode("path", {
  7943. "class": bem$_("layer"),
  7944. "style": style,
  7945. "d": path.value
  7946. }, null);
  7947. };
  7948. const renderGradient = () => {
  7949. const {
  7950. color
  7951. } = props2;
  7952. if (!isObject(color)) {
  7953. return;
  7954. }
  7955. const Stops = Object.keys(color).sort((a, b) => parseFloat(a) - parseFloat(b)).map((key, index) => createVNode("stop", {
  7956. "key": index,
  7957. "offset": key,
  7958. "stop-color": color[key]
  7959. }, null));
  7960. return createVNode("defs", null, [createVNode("linearGradient", {
  7961. "id": id,
  7962. "x1": "100%",
  7963. "y1": "0%",
  7964. "x2": "0%",
  7965. "y2": "0%"
  7966. }, [Stops])]);
  7967. };
  7968. const renderText = () => {
  7969. if (slots.default) {
  7970. return slots.default();
  7971. }
  7972. if (props2.text) {
  7973. return createVNode("div", {
  7974. "class": bem$_("text")
  7975. }, [props2.text]);
  7976. }
  7977. };
  7978. return () => createVNode("div", {
  7979. "class": bem$_(),
  7980. "style": getSizeStyle(props2.size)
  7981. }, [createVNode("svg", {
  7982. "viewBox": `0 0 ${viewBoxSize.value} ${viewBoxSize.value}`,
  7983. "style": svgStyle.value
  7984. }, [renderGradient(), renderLayer(), renderHover()]), renderText()]);
  7985. }
  7986. });
  7987. const Circle = withInstall(stdin_default$18);
  7988. const [name$_, bem$Z] = createNamespace("row");
  7989. const ROW_KEY = Symbol(name$_);
  7990. const rowProps = {
  7991. tag: makeStringProp("div"),
  7992. wrap: truthProp,
  7993. align: String,
  7994. gutter: {
  7995. type: [String, Number, Array],
  7996. default: 0
  7997. },
  7998. justify: String
  7999. };
  8000. var stdin_default$17 = defineComponent({
  8001. name: name$_,
  8002. props: rowProps,
  8003. setup(props2, {
  8004. slots
  8005. }) {
  8006. const {
  8007. children,
  8008. linkChildren
  8009. } = useChildren(ROW_KEY);
  8010. const groups = computed(() => {
  8011. const groups2 = [[]];
  8012. let totalSpan = 0;
  8013. children.forEach((child, index) => {
  8014. totalSpan += Number(child.span);
  8015. if (totalSpan > 24) {
  8016. groups2.push([index]);
  8017. totalSpan -= 24;
  8018. } else {
  8019. groups2[groups2.length - 1].push(index);
  8020. }
  8021. });
  8022. return groups2;
  8023. });
  8024. const spaces = computed(() => {
  8025. let gutter = 0;
  8026. if (Array.isArray(props2.gutter)) {
  8027. gutter = Number(props2.gutter[0]) || 0;
  8028. } else {
  8029. gutter = Number(props2.gutter);
  8030. }
  8031. const spaces2 = [];
  8032. if (!gutter) {
  8033. return spaces2;
  8034. }
  8035. groups.value.forEach((group) => {
  8036. const averagePadding = gutter * (group.length - 1) / group.length;
  8037. group.forEach((item, index) => {
  8038. if (index === 0) {
  8039. spaces2.push({
  8040. right: averagePadding
  8041. });
  8042. } else {
  8043. const left = gutter - spaces2[item - 1].right;
  8044. const right = averagePadding - left;
  8045. spaces2.push({
  8046. left,
  8047. right
  8048. });
  8049. }
  8050. });
  8051. });
  8052. return spaces2;
  8053. });
  8054. const verticalSpaces = computed(() => {
  8055. const {
  8056. gutter
  8057. } = props2;
  8058. const spaces2 = [];
  8059. if (Array.isArray(gutter) && gutter.length > 1) {
  8060. const bottom = Number(gutter[1]) || 0;
  8061. if (bottom <= 0) {
  8062. return spaces2;
  8063. }
  8064. groups.value.forEach((group, index) => {
  8065. if (index === groups.value.length - 1) return;
  8066. group.forEach(() => {
  8067. spaces2.push({
  8068. bottom
  8069. });
  8070. });
  8071. });
  8072. }
  8073. return spaces2;
  8074. });
  8075. linkChildren({
  8076. spaces,
  8077. verticalSpaces
  8078. });
  8079. return () => {
  8080. const {
  8081. tag,
  8082. wrap,
  8083. align,
  8084. justify
  8085. } = props2;
  8086. return createVNode(tag, {
  8087. "class": bem$Z({
  8088. [`align-${align}`]: align,
  8089. [`justify-${justify}`]: justify,
  8090. nowrap: !wrap
  8091. })
  8092. }, {
  8093. default: () => {
  8094. var _a;
  8095. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  8096. }
  8097. });
  8098. };
  8099. }
  8100. });
  8101. const [name$Z, bem$Y] = createNamespace("col");
  8102. const colProps = {
  8103. tag: makeStringProp("div"),
  8104. span: makeNumericProp(0),
  8105. offset: numericProp
  8106. };
  8107. var stdin_default$16 = defineComponent({
  8108. name: name$Z,
  8109. props: colProps,
  8110. setup(props2, {
  8111. slots
  8112. }) {
  8113. const {
  8114. parent,
  8115. index
  8116. } = useParent(ROW_KEY);
  8117. const style = computed(() => {
  8118. if (!parent) {
  8119. return;
  8120. }
  8121. const {
  8122. spaces,
  8123. verticalSpaces
  8124. } = parent;
  8125. let styles = {};
  8126. if (spaces && spaces.value && spaces.value[index.value]) {
  8127. const {
  8128. left,
  8129. right
  8130. } = spaces.value[index.value];
  8131. styles = {
  8132. paddingLeft: left ? `${left}px` : null,
  8133. paddingRight: right ? `${right}px` : null
  8134. };
  8135. }
  8136. const {
  8137. bottom
  8138. } = verticalSpaces.value[index.value] || {};
  8139. return extend(styles, {
  8140. marginBottom: bottom ? `${bottom}px` : null
  8141. });
  8142. });
  8143. return () => {
  8144. const {
  8145. tag,
  8146. span,
  8147. offset
  8148. } = props2;
  8149. return createVNode(tag, {
  8150. "style": style.value,
  8151. "class": bem$Y({
  8152. [span]: span,
  8153. [`offset-${offset}`]: offset
  8154. })
  8155. }, {
  8156. default: () => {
  8157. var _a;
  8158. return [(_a = slots.default) == null ? void 0 : _a.call(slots)];
  8159. }
  8160. });
  8161. };
  8162. }
  8163. });
  8164. const Col = withInstall(stdin_default$16);
  8165. const [name$Y, bem$X] = createNamespace("collapse");
  8166. const COLLAPSE_KEY = Symbol(name$Y);
  8167. const collapseProps = {
  8168. border: truthProp,
  8169. accordion: Boolean,
  8170. modelValue: {
  8171. type: [String, Number, Array],
  8172. default: ""
  8173. }
  8174. };
  8175. function validateModelValue(modelValue, accordion) {
  8176. if (accordion && Array.isArray(modelValue)) {
  8177. console.error('[Vant] Collapse: "v-model" should not be Array in accordion mode');
  8178. return false;
  8179. }
  8180. if (!accordion && !Array.isArray(modelValue)) {
  8181. console.error('[Vant] Collapse: "v-model" should be Array in non-accordion mode');
  8182. return false;
  8183. }
  8184. return true;
  8185. }
  8186. var stdin_default$15 = defineComponent({
  8187. name: name$Y,
  8188. props: collapseProps,
  8189. emits: ["change", "update:modelValue"],
  8190. setup(props2, {
  8191. emit,
  8192. slots
  8193. }) {
  8194. const {
  8195. linkChildren,
  8196. children
  8197. } = useChildren(COLLAPSE_KEY);
  8198. const updateName = (name2) => {
  8199. emit("change", name2);
  8200. emit("update:modelValue", name2);
  8201. };
  8202. const toggle = (name2, expanded) => {
  8203. const {
  8204. accordion,
  8205. modelValue
  8206. } = props2;
  8207. if (accordion) {
  8208. updateName(name2 === modelValue ? "" : name2);
  8209. } else if (expanded) {
  8210. updateName(modelValue.concat(name2));
  8211. } else {
  8212. updateName(modelValue.filter((activeName) => activeName !== name2));
  8213. }
  8214. };
  8215. const toggleAll = (options = {}) => {
  8216. if (props2.accordion) {
  8217. return;
  8218. }
  8219. if (typeof options === "boolean") {
  8220. options = {
  8221. expanded: options
  8222. };
  8223. }
  8224. const {
  8225. expanded,
  8226. skipDisabled
  8227. } = options;
  8228. const expandedChildren = children.filter((item) => {
  8229. if (item.disabled && skipDisabled) {
  8230. return item.expanded.value;
  8231. }
  8232. return expanded != null ? expanded : !item.expanded.value;
  8233. });
  8234. const names = expandedChildren.map((item) => item.itemName.value);
  8235. updateName(names);
  8236. };
  8237. const isExpanded = (name2) => {
  8238. const {
  8239. accordion,
  8240. modelValue
  8241. } = props2;
  8242. if (process.env.NODE_ENV !== "production" && !validateModelValue(modelValue, accordion)) {
  8243. return false;
  8244. }
  8245. return accordion ? modelValue === name2 : modelValue.includes(name2);
  8246. };
  8247. useExpose({
  8248. toggleAll
  8249. });
  8250. linkChildren({
  8251. toggle,
  8252. isExpanded
  8253. });
  8254. return () => {
  8255. var _a;
  8256. return createVNode("div", {
  8257. "class": [bem$X(), {
  8258. [BORDER_TOP_BOTTOM]: props2.border
  8259. }]
  8260. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  8261. };
  8262. }
  8263. });
  8264. const Collapse = withInstall(stdin_default$15);
  8265. const [name$X, bem$W] = createNamespace("collapse-item");
  8266. const CELL_SLOTS = ["icon", "title", "value", "label", "right-icon"];
  8267. const collapseItemProps = extend({}, cellSharedProps, {
  8268. name: numericProp,
  8269. isLink: truthProp,
  8270. disabled: Boolean,
  8271. readonly: Boolean,
  8272. lazyRender: truthProp
  8273. });
  8274. var stdin_default$14 = defineComponent({
  8275. name: name$X,
  8276. props: collapseItemProps,
  8277. setup(props2, {
  8278. slots
  8279. }) {
  8280. const wrapperRef = ref();
  8281. const contentRef = ref();
  8282. const {
  8283. parent,
  8284. index
  8285. } = useParent(COLLAPSE_KEY);
  8286. if (!parent) {
  8287. if (process.env.NODE_ENV !== "production") {
  8288. console.error("[Vant] <CollapseItem> must be a child component of <Collapse>.");
  8289. }
  8290. return;
  8291. }
  8292. const name2 = computed(() => {
  8293. var _a;
  8294. return (_a = props2.name) != null ? _a : index.value;
  8295. });
  8296. const expanded = computed(() => parent.isExpanded(name2.value));
  8297. const show = ref(expanded.value);
  8298. const lazyRender = useLazyRender(() => show.value || !props2.lazyRender);
  8299. const onTransitionEnd = () => {
  8300. if (!expanded.value) {
  8301. show.value = false;
  8302. } else if (wrapperRef.value) {
  8303. wrapperRef.value.style.height = "";
  8304. }
  8305. };
  8306. watch(expanded, (value, oldValue) => {
  8307. if (oldValue === null) {
  8308. return;
  8309. }
  8310. if (value) {
  8311. show.value = true;
  8312. }
  8313. const tick = value ? nextTick : raf;
  8314. tick(() => {
  8315. if (!contentRef.value || !wrapperRef.value) {
  8316. return;
  8317. }
  8318. const {
  8319. offsetHeight
  8320. } = contentRef.value;
  8321. if (offsetHeight) {
  8322. const contentHeight = `${offsetHeight}px`;
  8323. wrapperRef.value.style.height = value ? "0" : contentHeight;
  8324. doubleRaf(() => {
  8325. if (wrapperRef.value) {
  8326. wrapperRef.value.style.height = value ? contentHeight : "0";
  8327. }
  8328. });
  8329. } else {
  8330. onTransitionEnd();
  8331. }
  8332. });
  8333. });
  8334. const toggle = (newValue = !expanded.value) => {
  8335. parent.toggle(name2.value, newValue);
  8336. };
  8337. const onClickTitle = () => {
  8338. if (!props2.disabled && !props2.readonly) {
  8339. toggle();
  8340. }
  8341. };
  8342. const renderTitle = () => {
  8343. const {
  8344. border,
  8345. disabled,
  8346. readonly
  8347. } = props2;
  8348. const attrs = pick(props2, Object.keys(cellSharedProps));
  8349. if (readonly) {
  8350. attrs.isLink = false;
  8351. }
  8352. if (disabled || readonly) {
  8353. attrs.clickable = false;
  8354. }
  8355. return createVNode(Cell, mergeProps({
  8356. "role": "button",
  8357. "class": bem$W("title", {
  8358. disabled,
  8359. expanded: expanded.value,
  8360. borderless: !border
  8361. }),
  8362. "aria-expanded": String(expanded.value),
  8363. "onClick": onClickTitle
  8364. }, attrs), pick(slots, CELL_SLOTS));
  8365. };
  8366. const renderContent = lazyRender(() => {
  8367. var _a;
  8368. return withDirectives(createVNode("div", {
  8369. "ref": wrapperRef,
  8370. "class": bem$W("wrapper"),
  8371. "onTransitionend": onTransitionEnd
  8372. }, [createVNode("div", {
  8373. "ref": contentRef,
  8374. "class": bem$W("content")
  8375. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]), [[vShow, show.value]]);
  8376. });
  8377. useExpose({
  8378. toggle,
  8379. expanded,
  8380. itemName: name2
  8381. });
  8382. return () => createVNode("div", {
  8383. "class": [bem$W({
  8384. border: index.value && props2.border
  8385. })]
  8386. }, [renderTitle(), renderContent()]);
  8387. }
  8388. });
  8389. const CollapseItem = withInstall(stdin_default$14);
  8390. const ConfigProvider = withInstall(stdin_default$1S);
  8391. const [name$W, bem$V, t$e] = createNamespace("contact-card");
  8392. const contactCardProps = {
  8393. tel: String,
  8394. name: String,
  8395. type: makeStringProp("add"),
  8396. addText: String,
  8397. editable: truthProp
  8398. };
  8399. var stdin_default$13 = defineComponent({
  8400. name: name$W,
  8401. props: contactCardProps,
  8402. emits: ["click"],
  8403. setup(props2, {
  8404. emit
  8405. }) {
  8406. const onClick = (event) => {
  8407. if (props2.editable) {
  8408. emit("click", event);
  8409. }
  8410. };
  8411. const renderContent = () => {
  8412. if (props2.type === "add") {
  8413. return props2.addText || t$e("addContact");
  8414. }
  8415. return [createVNode("div", null, [`${t$e("name")}:${props2.name}`]), createVNode("div", null, [`${t$e("tel")}:${props2.tel}`])];
  8416. };
  8417. return () => createVNode(Cell, {
  8418. "center": true,
  8419. "icon": props2.type === "edit" ? "contact" : "add-square",
  8420. "class": bem$V([props2.type]),
  8421. "border": false,
  8422. "isLink": props2.editable,
  8423. "titleClass": bem$V("title"),
  8424. "onClick": onClick
  8425. }, {
  8426. title: renderContent
  8427. });
  8428. }
  8429. });
  8430. const ContactCard = withInstall(stdin_default$13);
  8431. const [name$V, bem$U, t$d] = createNamespace("contact-edit");
  8432. const DEFAULT_CONTACT = {
  8433. tel: "",
  8434. name: ""
  8435. };
  8436. const contactEditProps = {
  8437. isEdit: Boolean,
  8438. isSaving: Boolean,
  8439. isDeleting: Boolean,
  8440. showSetDefault: Boolean,
  8441. setDefaultLabel: String,
  8442. contactInfo: {
  8443. type: Object,
  8444. default: () => extend({}, DEFAULT_CONTACT)
  8445. },
  8446. telValidator: {
  8447. type: Function,
  8448. default: isMobile
  8449. }
  8450. };
  8451. var stdin_default$12 = defineComponent({
  8452. name: name$V,
  8453. props: contactEditProps,
  8454. emits: ["save", "delete", "changeDefault"],
  8455. setup(props2, {
  8456. emit
  8457. }) {
  8458. const contact = reactive(extend({}, DEFAULT_CONTACT, props2.contactInfo));
  8459. const onSave = () => {
  8460. if (!props2.isSaving) {
  8461. emit("save", contact);
  8462. }
  8463. };
  8464. const onDelete = () => emit("delete", contact);
  8465. const renderButtons = () => createVNode("div", {
  8466. "class": bem$U("buttons")
  8467. }, [createVNode(Button, {
  8468. "block": true,
  8469. "round": true,
  8470. "type": "primary",
  8471. "text": t$d("save"),
  8472. "class": bem$U("button"),
  8473. "loading": props2.isSaving,
  8474. "nativeType": "submit"
  8475. }, null), props2.isEdit && createVNode(Button, {
  8476. "block": true,
  8477. "round": true,
  8478. "text": t$d("delete"),
  8479. "class": bem$U("button"),
  8480. "loading": props2.isDeleting,
  8481. "onClick": onDelete
  8482. }, null)]);
  8483. const renderSwitch = () => createVNode(Switch, {
  8484. "modelValue": contact.isDefault,
  8485. "onUpdate:modelValue": ($event) => contact.isDefault = $event,
  8486. "onChange": (checked) => emit("changeDefault", checked)
  8487. }, null);
  8488. const renderSetDefault = () => {
  8489. if (props2.showSetDefault) {
  8490. return createVNode(Cell, {
  8491. "title": props2.setDefaultLabel,
  8492. "class": bem$U("switch-cell"),
  8493. "border": false
  8494. }, {
  8495. "right-icon": renderSwitch
  8496. });
  8497. }
  8498. };
  8499. watch(() => props2.contactInfo, (value) => extend(contact, DEFAULT_CONTACT, value));
  8500. return () => createVNode(Form, {
  8501. "class": bem$U(),
  8502. "onSubmit": onSave
  8503. }, {
  8504. default: () => [createVNode("div", {
  8505. "class": bem$U("fields")
  8506. }, [createVNode(Field, {
  8507. "modelValue": contact.name,
  8508. "onUpdate:modelValue": ($event) => contact.name = $event,
  8509. "clearable": true,
  8510. "label": t$d("name"),
  8511. "rules": [{
  8512. required: true,
  8513. message: t$d("nameEmpty")
  8514. }],
  8515. "maxlength": "30",
  8516. "placeholder": t$d("name")
  8517. }, null), createVNode(Field, {
  8518. "modelValue": contact.tel,
  8519. "onUpdate:modelValue": ($event) => contact.tel = $event,
  8520. "clearable": true,
  8521. "type": "tel",
  8522. "label": t$d("tel"),
  8523. "rules": [{
  8524. validator: props2.telValidator,
  8525. message: t$d("telInvalid")
  8526. }],
  8527. "placeholder": t$d("tel")
  8528. }, null)]), renderSetDefault(), renderButtons()]
  8529. });
  8530. }
  8531. });
  8532. const ContactEdit = withInstall(stdin_default$12);
  8533. const [name$U, bem$T, t$c] = createNamespace("contact-list");
  8534. const contactListProps = {
  8535. list: Array,
  8536. addText: String,
  8537. modelValue: unknownProp,
  8538. defaultTagText: String
  8539. };
  8540. var stdin_default$11 = defineComponent({
  8541. name: name$U,
  8542. props: contactListProps,
  8543. emits: ["add", "edit", "select", "update:modelValue"],
  8544. setup(props2, {
  8545. emit
  8546. }) {
  8547. const renderItem = (item, index) => {
  8548. const onClick = () => {
  8549. emit("update:modelValue", item.id);
  8550. emit("select", item, index);
  8551. };
  8552. const renderRightIcon = () => createVNode(Radio, {
  8553. "class": bem$T("radio"),
  8554. "name": item.id,
  8555. "iconSize": 18
  8556. }, null);
  8557. const renderEditIcon = () => createVNode(Icon, {
  8558. "name": "edit",
  8559. "class": bem$T("edit"),
  8560. "onClick": (event) => {
  8561. event.stopPropagation();
  8562. emit("edit", item, index);
  8563. }
  8564. }, null);
  8565. const renderContent = () => {
  8566. const nodes = [`${item.name},${item.tel}`];
  8567. if (item.isDefault && props2.defaultTagText) {
  8568. nodes.push(createVNode(Tag, {
  8569. "type": "primary",
  8570. "round": true,
  8571. "class": bem$T("item-tag")
  8572. }, {
  8573. default: () => [props2.defaultTagText]
  8574. }));
  8575. }
  8576. return nodes;
  8577. };
  8578. return createVNode(Cell, {
  8579. "key": item.id,
  8580. "isLink": true,
  8581. "center": true,
  8582. "class": bem$T("item"),
  8583. "titleClass": bem$T("item-title"),
  8584. "onClick": onClick
  8585. }, {
  8586. icon: renderEditIcon,
  8587. title: renderContent,
  8588. "right-icon": renderRightIcon
  8589. });
  8590. };
  8591. return () => createVNode("div", {
  8592. "class": bem$T()
  8593. }, [createVNode(RadioGroup, {
  8594. "modelValue": props2.modelValue,
  8595. "class": bem$T("group")
  8596. }, {
  8597. default: () => [props2.list && props2.list.map(renderItem)]
  8598. }), createVNode("div", {
  8599. "class": [bem$T("bottom"), "van-safe-area-bottom"]
  8600. }, [createVNode(Button, {
  8601. "round": true,
  8602. "block": true,
  8603. "type": "primary",
  8604. "class": bem$T("add"),
  8605. "text": props2.addText || t$c("addContact"),
  8606. "onClick": () => emit("add")
  8607. }, null)])]);
  8608. }
  8609. });
  8610. const ContactList = withInstall(stdin_default$11);
  8611. function parseFormat(format2, currentTime) {
  8612. const { days } = currentTime;
  8613. let { hours, minutes, seconds, milliseconds } = currentTime;
  8614. if (format2.includes("DD")) {
  8615. format2 = format2.replace("DD", padZero(days));
  8616. } else {
  8617. hours += days * 24;
  8618. }
  8619. if (format2.includes("HH")) {
  8620. format2 = format2.replace("HH", padZero(hours));
  8621. } else {
  8622. minutes += hours * 60;
  8623. }
  8624. if (format2.includes("mm")) {
  8625. format2 = format2.replace("mm", padZero(minutes));
  8626. } else {
  8627. seconds += minutes * 60;
  8628. }
  8629. if (format2.includes("ss")) {
  8630. format2 = format2.replace("ss", padZero(seconds));
  8631. } else {
  8632. milliseconds += seconds * 1e3;
  8633. }
  8634. if (format2.includes("S")) {
  8635. const ms = padZero(milliseconds, 3);
  8636. if (format2.includes("SSS")) {
  8637. format2 = format2.replace("SSS", ms);
  8638. } else if (format2.includes("SS")) {
  8639. format2 = format2.replace("SS", ms.slice(0, 2));
  8640. } else {
  8641. format2 = format2.replace("S", ms.charAt(0));
  8642. }
  8643. }
  8644. return format2;
  8645. }
  8646. const [name$T, bem$S] = createNamespace("count-down");
  8647. const countDownProps = {
  8648. time: makeNumericProp(0),
  8649. format: makeStringProp("HH:mm:ss"),
  8650. autoStart: truthProp,
  8651. millisecond: Boolean
  8652. };
  8653. var stdin_default$10 = defineComponent({
  8654. name: name$T,
  8655. props: countDownProps,
  8656. emits: ["change", "finish"],
  8657. setup(props2, {
  8658. emit,
  8659. slots
  8660. }) {
  8661. const {
  8662. start,
  8663. pause,
  8664. reset,
  8665. current: current2
  8666. } = useCountDown({
  8667. time: +props2.time,
  8668. millisecond: props2.millisecond,
  8669. onChange: (current22) => emit("change", current22),
  8670. onFinish: () => emit("finish")
  8671. });
  8672. const timeText = computed(() => parseFormat(props2.format, current2.value));
  8673. const resetTime = () => {
  8674. reset(+props2.time);
  8675. if (props2.autoStart) {
  8676. start();
  8677. }
  8678. };
  8679. watch(() => props2.time, resetTime, {
  8680. immediate: true
  8681. });
  8682. useExpose({
  8683. start,
  8684. pause,
  8685. reset: resetTime
  8686. });
  8687. return () => createVNode("div", {
  8688. "role": "timer",
  8689. "class": bem$S()
  8690. }, [slots.default ? slots.default(current2.value) : timeText.value]);
  8691. }
  8692. });
  8693. const CountDown = withInstall(stdin_default$10);
  8694. function getDate(timeStamp) {
  8695. const date = new Date(timeStamp * 1e3);
  8696. return `${date.getFullYear()}.${padZero(date.getMonth() + 1)}.${padZero(
  8697. date.getDate()
  8698. )}`;
  8699. }
  8700. const formatDiscount = (discount) => (discount / 10).toFixed(discount % 10 === 0 ? 0 : 1);
  8701. const formatAmount = (amount) => (amount / 100).toFixed(amount % 100 === 0 ? 0 : amount % 10 === 0 ? 1 : 2);
  8702. const [name$S, bem$R, t$b] = createNamespace("coupon");
  8703. var stdin_default$$ = defineComponent({
  8704. name: name$S,
  8705. props: {
  8706. chosen: Boolean,
  8707. coupon: makeRequiredProp(Object),
  8708. disabled: Boolean,
  8709. currency: makeStringProp("¥")
  8710. },
  8711. setup(props2) {
  8712. const validPeriod = computed(() => {
  8713. const {
  8714. startAt,
  8715. endAt
  8716. } = props2.coupon;
  8717. return `${getDate(startAt)} - ${getDate(endAt)}`;
  8718. });
  8719. const faceAmount = computed(() => {
  8720. const {
  8721. coupon,
  8722. currency
  8723. } = props2;
  8724. if (coupon.valueDesc) {
  8725. return [coupon.valueDesc, createVNode("span", null, [coupon.unitDesc || ""])];
  8726. }
  8727. if (coupon.denominations) {
  8728. const denominations = formatAmount(coupon.denominations);
  8729. return [createVNode("span", null, [currency]), ` ${denominations}`];
  8730. }
  8731. if (coupon.discount) {
  8732. return t$b("discount", formatDiscount(coupon.discount));
  8733. }
  8734. return "";
  8735. });
  8736. const conditionMessage = computed(() => {
  8737. const condition = formatAmount(props2.coupon.originCondition || 0);
  8738. return condition === "0" ? t$b("unlimited") : t$b("condition", condition);
  8739. });
  8740. return () => {
  8741. const {
  8742. chosen,
  8743. coupon,
  8744. disabled
  8745. } = props2;
  8746. const description = disabled && coupon.reason || coupon.description;
  8747. return createVNode("div", {
  8748. "class": bem$R({
  8749. disabled
  8750. })
  8751. }, [createVNode("div", {
  8752. "class": bem$R("content")
  8753. }, [createVNode("div", {
  8754. "class": bem$R("head")
  8755. }, [createVNode("h2", {
  8756. "class": bem$R("amount")
  8757. }, [faceAmount.value]), createVNode("p", {
  8758. "class": bem$R("condition")
  8759. }, [coupon.condition || conditionMessage.value])]), createVNode("div", {
  8760. "class": bem$R("body")
  8761. }, [createVNode("p", {
  8762. "class": bem$R("name")
  8763. }, [coupon.name]), createVNode("p", {
  8764. "class": bem$R("valid")
  8765. }, [validPeriod.value]), !disabled && createVNode(Checkbox, {
  8766. "class": bem$R("corner"),
  8767. "modelValue": chosen
  8768. }, null)])]), description && createVNode("p", {
  8769. "class": bem$R("description")
  8770. }, [description])]);
  8771. };
  8772. }
  8773. });
  8774. const Coupon = withInstall(stdin_default$$);
  8775. const [name$R, bem$Q, t$a] = createNamespace("coupon-cell");
  8776. const couponCellProps = {
  8777. title: String,
  8778. border: truthProp,
  8779. editable: truthProp,
  8780. coupons: makeArrayProp(),
  8781. currency: makeStringProp("¥"),
  8782. chosenCoupon: {
  8783. type: [Number, Array],
  8784. default: -1
  8785. }
  8786. };
  8787. const getValue = (coupon) => {
  8788. const {
  8789. value,
  8790. denominations
  8791. } = coupon;
  8792. if (isDef(value)) {
  8793. return value;
  8794. }
  8795. if (isDef(denominations)) {
  8796. return denominations;
  8797. }
  8798. return 0;
  8799. };
  8800. function formatValue({
  8801. coupons,
  8802. chosenCoupon,
  8803. currency
  8804. }) {
  8805. let value = 0;
  8806. let isExist = false;
  8807. (Array.isArray(chosenCoupon) ? chosenCoupon : [chosenCoupon]).forEach((i) => {
  8808. const coupon = coupons[+i];
  8809. if (coupon) {
  8810. isExist = true;
  8811. value += getValue(coupon);
  8812. }
  8813. });
  8814. if (isExist) {
  8815. return `-${currency} ${(value / 100).toFixed(2)}`;
  8816. }
  8817. return coupons.length === 0 ? t$a("noCoupon") : t$a("count", coupons.length);
  8818. }
  8819. var stdin_default$_ = defineComponent({
  8820. name: name$R,
  8821. props: couponCellProps,
  8822. setup(props2) {
  8823. return () => {
  8824. const selected = Array.isArray(props2.chosenCoupon) ? props2.chosenCoupon.length : props2.coupons[+props2.chosenCoupon];
  8825. return createVNode(Cell, {
  8826. "class": bem$Q(),
  8827. "value": formatValue(props2),
  8828. "title": props2.title || t$a("title"),
  8829. "border": props2.border,
  8830. "isLink": props2.editable,
  8831. "valueClass": bem$Q("value", {
  8832. selected
  8833. })
  8834. }, null);
  8835. };
  8836. }
  8837. });
  8838. const CouponCell = withInstall(stdin_default$_);
  8839. const [name$Q, bem$P] = createNamespace("empty");
  8840. const emptyProps = {
  8841. image: makeStringProp("default"),
  8842. imageSize: [Number, String, Array],
  8843. description: String
  8844. };
  8845. var stdin_default$Z = defineComponent({
  8846. name: name$Q,
  8847. props: emptyProps,
  8848. setup(props2, {
  8849. slots
  8850. }) {
  8851. const renderDescription = () => {
  8852. const description = slots.description ? slots.description() : props2.description;
  8853. if (description) {
  8854. return createVNode("p", {
  8855. "class": bem$P("description")
  8856. }, [description]);
  8857. }
  8858. };
  8859. const renderBottom = () => {
  8860. if (slots.default) {
  8861. return createVNode("div", {
  8862. "class": bem$P("bottom")
  8863. }, [slots.default()]);
  8864. }
  8865. };
  8866. const baseId = useId();
  8867. const getId = (num) => `${baseId}-${num}`;
  8868. const getUrlById = (num) => `url(#${getId(num)})`;
  8869. const renderStop = (color, offset, opacity) => createVNode("stop", {
  8870. "stop-color": color,
  8871. "offset": `${offset}%`,
  8872. "stop-opacity": opacity
  8873. }, null);
  8874. const renderStops = (fromColor, toColor) => [renderStop(fromColor, 0), renderStop(toColor, 100)];
  8875. const renderShadow = (id) => [createVNode("defs", null, [createVNode("radialGradient", {
  8876. "id": getId(id),
  8877. "cx": "50%",
  8878. "cy": "54%",
  8879. "fx": "50%",
  8880. "fy": "54%",
  8881. "r": "297%",
  8882. "gradientTransform": "matrix(-.16 0 0 -.33 .58 .72)",
  8883. "data-allow-mismatch": "attribute"
  8884. }, [renderStop("#EBEDF0", 0), renderStop("#F2F3F5", 100, 0.3)])]), createVNode("ellipse", {
  8885. "fill": getUrlById(id),
  8886. "opacity": ".8",
  8887. "cx": "80",
  8888. "cy": "140",
  8889. "rx": "46",
  8890. "ry": "8",
  8891. "data-allow-mismatch": "attribute"
  8892. }, null)];
  8893. const renderBuilding = () => [createVNode("defs", null, [createVNode("linearGradient", {
  8894. "id": getId("a"),
  8895. "x1": "64%",
  8896. "y1": "100%",
  8897. "x2": "64%",
  8898. "data-allow-mismatch": "attribute"
  8899. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)])]), createVNode("g", {
  8900. "opacity": ".8",
  8901. "data-allow-mismatch": "children"
  8902. }, [createVNode("path", {
  8903. "d": "M36 131V53H16v20H2v58h34z",
  8904. "fill": getUrlById("a")
  8905. }, null), createVNode("path", {
  8906. "d": "M123 15h22v14h9v77h-31V15z",
  8907. "fill": getUrlById("a")
  8908. }, null)])];
  8909. const renderCloud = () => [createVNode("defs", null, [createVNode("linearGradient", {
  8910. "id": getId("b"),
  8911. "x1": "64%",
  8912. "y1": "97%",
  8913. "x2": "64%",
  8914. "y2": "0%",
  8915. "data-allow-mismatch": "attribute"
  8916. }, [renderStop("#F2F3F5", 0, 0.3), renderStop("#F2F3F5", 100)])]), createVNode("g", {
  8917. "opacity": ".8",
  8918. "data-allow-mismatch": "children"
  8919. }, [createVNode("path", {
  8920. "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",
  8921. "fill": getUrlById("b")
  8922. }, null), createVNode("path", {
  8923. "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",
  8924. "fill": getUrlById("b")
  8925. }, null)])];
  8926. const renderNetwork = () => createVNode("svg", {
  8927. "viewBox": "0 0 160 160"
  8928. }, [createVNode("defs", {
  8929. "data-allow-mismatch": "children"
  8930. }, [createVNode("linearGradient", {
  8931. "id": getId(1),
  8932. "x1": "64%",
  8933. "y1": "100%",
  8934. "x2": "64%"
  8935. }, [renderStop("#FFF", 0, 0.5), renderStop("#F2F3F5", 100)]), createVNode("linearGradient", {
  8936. "id": getId(2),
  8937. "x1": "50%",
  8938. "x2": "50%",
  8939. "y2": "84%"
  8940. }, [renderStop("#EBEDF0", 0), renderStop("#DCDEE0", 100, 0)]), createVNode("linearGradient", {
  8941. "id": getId(3),
  8942. "x1": "100%",
  8943. "x2": "100%",
  8944. "y2": "100%"
  8945. }, [renderStops("#EAEDF0", "#DCDEE0")]), createVNode("radialGradient", {
  8946. "id": getId(4),
  8947. "cx": "50%",
  8948. "cy": "0%",
  8949. "fx": "50%",
  8950. "fy": "0%",
  8951. "r": "100%",
  8952. "gradientTransform": "matrix(0 1 -.54 0 .5 -.5)"
  8953. }, [renderStop("#EBEDF0", 0), renderStop("#FFF", 100, 0)])]), createVNode("g", {
  8954. "fill": "none"
  8955. }, [renderBuilding(), createVNode("path", {
  8956. "fill": getUrlById(4),
  8957. "d": "M0 139h160v21H0z",
  8958. "data-allow-mismatch": "attribute"
  8959. }, null), createVNode("path", {
  8960. "d": "M80 54a7 7 0 0 1 3 13v27l-2 2h-2a2 2 0 0 1-2-2V67a7 7 0 0 1 3-13z",
  8961. "fill": getUrlById(2),
  8962. "data-allow-mismatch": "attribute"
  8963. }, null), createVNode("g", {
  8964. "opacity": ".6",
  8965. "stroke-linecap": "round",
  8966. "stroke-width": "7",
  8967. "data-allow-mismatch": "children"
  8968. }, [createVNode("path", {
  8969. "d": "M64 47a19 19 0 0 0-5 13c0 5 2 10 5 13",
  8970. "stroke": getUrlById(3)
  8971. }, null), createVNode("path", {
  8972. "d": "M53 36a34 34 0 0 0 0 48",
  8973. "stroke": getUrlById(3)
  8974. }, null), createVNode("path", {
  8975. "d": "M95 73a19 19 0 0 0 6-13c0-5-2-9-6-13",
  8976. "stroke": getUrlById(3)
  8977. }, null), createVNode("path", {
  8978. "d": "M106 84a34 34 0 0 0 0-48",
  8979. "stroke": getUrlById(3)
  8980. }, null)]), createVNode("g", {
  8981. "transform": "translate(31 105)"
  8982. }, [createVNode("rect", {
  8983. "fill": "#EBEDF0",
  8984. "width": "98",
  8985. "height": "34",
  8986. "rx": "2"
  8987. }, null), createVNode("rect", {
  8988. "fill": "#FFF",
  8989. "x": "9",
  8990. "y": "8",
  8991. "width": "80",
  8992. "height": "18",
  8993. "rx": "1.1"
  8994. }, null), createVNode("rect", {
  8995. "fill": "#EBEDF0",
  8996. "x": "15",
  8997. "y": "12",
  8998. "width": "18",
  8999. "height": "6",
  9000. "rx": "1.1"
  9001. }, null)])])]);
  9002. const renderMaterial = () => createVNode("svg", {
  9003. "viewBox": "0 0 160 160"
  9004. }, [createVNode("defs", {
  9005. "data-allow-mismatch": "children"
  9006. }, [createVNode("linearGradient", {
  9007. "x1": "50%",
  9008. "x2": "50%",
  9009. "y2": "100%",
  9010. "id": getId(5)
  9011. }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
  9012. "x1": "95%",
  9013. "y1": "48%",
  9014. "x2": "5.5%",
  9015. "y2": "51%",
  9016. "id": getId(6)
  9017. }, [renderStops("#EAEDF1", "#DCDEE0")]), createVNode("linearGradient", {
  9018. "y1": "45%",
  9019. "x2": "100%",
  9020. "y2": "54%",
  9021. "id": getId(7)
  9022. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), createVNode("g", {
  9023. "transform": "translate(36 50)",
  9024. "fill": "none"
  9025. }, [createVNode("g", {
  9026. "transform": "translate(8)"
  9027. }, [createVNode("rect", {
  9028. "fill": "#EBEDF0",
  9029. "opacity": ".6",
  9030. "x": "38",
  9031. "y": "13",
  9032. "width": "36",
  9033. "height": "53",
  9034. "rx": "2"
  9035. }, null), createVNode("rect", {
  9036. "fill": getUrlById(5),
  9037. "width": "64",
  9038. "height": "66",
  9039. "rx": "2",
  9040. "data-allow-mismatch": "attribute"
  9041. }, null), createVNode("rect", {
  9042. "fill": "#FFF",
  9043. "x": "6",
  9044. "y": "6",
  9045. "width": "52",
  9046. "height": "55",
  9047. "rx": "1"
  9048. }, null), createVNode("g", {
  9049. "transform": "translate(15 17)",
  9050. "fill": getUrlById(6),
  9051. "data-allow-mismatch": "attribute"
  9052. }, [createVNode("rect", {
  9053. "width": "34",
  9054. "height": "6",
  9055. "rx": "1"
  9056. }, null), createVNode("path", {
  9057. "d": "M0 14h34v6H0z"
  9058. }, null), createVNode("rect", {
  9059. "y": "28",
  9060. "width": "34",
  9061. "height": "6",
  9062. "rx": "1"
  9063. }, null)])]), createVNode("rect", {
  9064. "fill": getUrlById(7),
  9065. "y": "61",
  9066. "width": "88",
  9067. "height": "28",
  9068. "rx": "1",
  9069. "data-allow-mismatch": "attribute"
  9070. }, null), createVNode("rect", {
  9071. "fill": "#F7F8FA",
  9072. "x": "29",
  9073. "y": "72",
  9074. "width": "30",
  9075. "height": "6",
  9076. "rx": "1"
  9077. }, null)])]);
  9078. const renderError = () => createVNode("svg", {
  9079. "viewBox": "0 0 160 160"
  9080. }, [createVNode("defs", null, [createVNode("linearGradient", {
  9081. "x1": "50%",
  9082. "x2": "50%",
  9083. "y2": "100%",
  9084. "id": getId(8),
  9085. "data-allow-mismatch": "attribute"
  9086. }, [renderStops("#EAEDF1", "#DCDEE0")])]), renderBuilding(), renderCloud(), renderShadow("c"), createVNode("path", {
  9087. "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",
  9088. "fill": getUrlById(8),
  9089. "data-allow-mismatch": "attribute"
  9090. }, null)]);
  9091. const renderSearch = () => createVNode("svg", {
  9092. "viewBox": "0 0 160 160"
  9093. }, [createVNode("defs", {
  9094. "data-allow-mismatch": "children"
  9095. }, [createVNode("linearGradient", {
  9096. "x1": "50%",
  9097. "y1": "100%",
  9098. "x2": "50%",
  9099. "id": getId(9)
  9100. }, [renderStops("#EEE", "#D8D8D8")]), createVNode("linearGradient", {
  9101. "x1": "100%",
  9102. "y1": "50%",
  9103. "y2": "50%",
  9104. "id": getId(10)
  9105. }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
  9106. "x1": "50%",
  9107. "x2": "50%",
  9108. "y2": "100%",
  9109. "id": getId(11)
  9110. }, [renderStops("#F2F3F5", "#DCDEE0")]), createVNode("linearGradient", {
  9111. "x1": "50%",
  9112. "x2": "50%",
  9113. "y2": "100%",
  9114. "id": getId(12)
  9115. }, [renderStops("#FFF", "#F7F8FA")])]), renderBuilding(), renderCloud(), renderShadow("d"), createVNode("g", {
  9116. "transform": "rotate(-45 113 -4)",
  9117. "fill": "none",
  9118. "data-allow-mismatch": "children"
  9119. }, [createVNode("rect", {
  9120. "fill": getUrlById(9),
  9121. "x": "24",
  9122. "y": "52.8",
  9123. "width": "5.8",
  9124. "height": "19",
  9125. "rx": "1"
  9126. }, null), createVNode("rect", {
  9127. "fill": getUrlById(10),
  9128. "x": "22.1",
  9129. "y": "67.3",
  9130. "width": "9.9",
  9131. "height": "28",
  9132. "rx": "1"
  9133. }, null), createVNode("circle", {
  9134. "stroke": getUrlById(11),
  9135. "stroke-width": "8",
  9136. "cx": "27",
  9137. "cy": "27",
  9138. "r": "27"
  9139. }, null), createVNode("circle", {
  9140. "fill": getUrlById(12),
  9141. "cx": "27",
  9142. "cy": "27",
  9143. "r": "16"
  9144. }, null), createVNode("path", {
  9145. "d": "M37 7c-8 0-15 5-16 12",
  9146. "stroke": getUrlById(11),
  9147. "stroke-width": "3",
  9148. "opacity": ".5",
  9149. "stroke-linecap": "round",
  9150. "transform": "rotate(45 29 13)"
  9151. }, null)])]);
  9152. const renderImage = () => {
  9153. var _a;
  9154. if (slots.image) {
  9155. return slots.image();
  9156. }
  9157. const PRESET_IMAGES = {
  9158. error: renderError,
  9159. search: renderSearch,
  9160. network: renderNetwork,
  9161. default: renderMaterial
  9162. };
  9163. return ((_a = PRESET_IMAGES[props2.image]) == null ? void 0 : _a.call(PRESET_IMAGES)) || createVNode("img", {
  9164. "src": props2.image
  9165. }, null);
  9166. };
  9167. return () => createVNode("div", {
  9168. "class": bem$P()
  9169. }, [createVNode("div", {
  9170. "class": bem$P("image"),
  9171. "style": getSizeStyle(props2.imageSize)
  9172. }, [renderImage()]), renderDescription(), renderBottom()]);
  9173. }
  9174. });
  9175. const Empty = withInstall(stdin_default$Z);
  9176. const [name$P, bem$O, t$9] = createNamespace("coupon-list");
  9177. const couponListProps = {
  9178. code: makeStringProp(""),
  9179. coupons: makeArrayProp(),
  9180. currency: makeStringProp("¥"),
  9181. showCount: truthProp,
  9182. emptyImage: String,
  9183. enabledTitle: String,
  9184. disabledTitle: String,
  9185. disabledCoupons: makeArrayProp(),
  9186. showExchangeBar: truthProp,
  9187. showCloseButton: truthProp,
  9188. closeButtonText: String,
  9189. inputPlaceholder: String,
  9190. exchangeMinLength: makeNumberProp(1),
  9191. exchangeButtonText: String,
  9192. displayedCouponIndex: makeNumberProp(-1),
  9193. exchangeButtonLoading: Boolean,
  9194. exchangeButtonDisabled: Boolean,
  9195. chosenCoupon: {
  9196. type: [Number, Array],
  9197. default: -1
  9198. }
  9199. };
  9200. var stdin_default$Y = defineComponent({
  9201. name: name$P,
  9202. props: couponListProps,
  9203. emits: ["change", "exchange", "update:code"],
  9204. setup(props2, {
  9205. emit,
  9206. slots
  9207. }) {
  9208. const [couponRefs, setCouponRefs] = useRefs();
  9209. const root = ref();
  9210. const barRef = ref();
  9211. const activeTab = ref(0);
  9212. const listHeight = ref(0);
  9213. const currentCode = ref(props2.code);
  9214. const buttonDisabled = computed(() => !props2.exchangeButtonLoading && (props2.exchangeButtonDisabled || !currentCode.value || currentCode.value.length < props2.exchangeMinLength));
  9215. const updateListHeight = () => {
  9216. const TABS_HEIGHT = 44;
  9217. const rootHeight = useRect(root).height;
  9218. const headerHeight = useRect(barRef).height + TABS_HEIGHT;
  9219. listHeight.value = (rootHeight > headerHeight ? rootHeight : windowHeight.value) - headerHeight;
  9220. };
  9221. const onExchange = () => {
  9222. emit("exchange", currentCode.value);
  9223. if (!props2.code) {
  9224. currentCode.value = "";
  9225. }
  9226. };
  9227. const scrollToCoupon = (index) => {
  9228. nextTick(() => {
  9229. var _a;
  9230. return (_a = couponRefs.value[index]) == null ? void 0 : _a.scrollIntoView();
  9231. });
  9232. };
  9233. const renderEmpty = () => createVNode(Empty, {
  9234. "image": props2.emptyImage
  9235. }, {
  9236. default: () => [createVNode("p", {
  9237. "class": bem$O("empty-tip")
  9238. }, [t$9("noCoupon")])]
  9239. });
  9240. const renderExchangeBar = () => {
  9241. if (props2.showExchangeBar) {
  9242. return createVNode("div", {
  9243. "ref": barRef,
  9244. "class": bem$O("exchange-bar")
  9245. }, [createVNode(Field, {
  9246. "modelValue": currentCode.value,
  9247. "onUpdate:modelValue": ($event) => currentCode.value = $event,
  9248. "clearable": true,
  9249. "border": false,
  9250. "class": bem$O("field"),
  9251. "placeholder": props2.inputPlaceholder || t$9("placeholder"),
  9252. "maxlength": "20"
  9253. }, null), createVNode(Button, {
  9254. "plain": true,
  9255. "type": "primary",
  9256. "class": bem$O("exchange"),
  9257. "text": props2.exchangeButtonText || t$9("exchange"),
  9258. "loading": props2.exchangeButtonLoading,
  9259. "disabled": buttonDisabled.value,
  9260. "onClick": onExchange
  9261. }, null)]);
  9262. }
  9263. };
  9264. const renderCouponTab = () => {
  9265. const {
  9266. coupons,
  9267. chosenCoupon
  9268. } = props2;
  9269. const count = props2.showCount ? ` (${coupons.length})` : "";
  9270. const title = (props2.enabledTitle || t$9("enable")) + count;
  9271. const updateChosenCoupon = (currentValues = [], value = 0) => {
  9272. if (currentValues.includes(value)) {
  9273. return currentValues.filter((item) => item !== value);
  9274. }
  9275. return [...currentValues, value];
  9276. };
  9277. return createVNode(Tab, {
  9278. "title": title
  9279. }, {
  9280. default: () => {
  9281. var _a;
  9282. return [createVNode("div", {
  9283. "class": bem$O("list", {
  9284. "with-bottom": props2.showCloseButton
  9285. }),
  9286. "style": {
  9287. height: `${listHeight.value}px`
  9288. }
  9289. }, [coupons.map((coupon, index) => createVNode(Coupon, {
  9290. "key": coupon.id,
  9291. "ref": setCouponRefs(index),
  9292. "coupon": coupon,
  9293. "chosen": Array.isArray(chosenCoupon) ? chosenCoupon.includes(index) : index === chosenCoupon,
  9294. "currency": props2.currency,
  9295. "onClick": () => emit("change", Array.isArray(chosenCoupon) ? updateChosenCoupon(chosenCoupon, index) : index)
  9296. }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
  9297. }
  9298. });
  9299. };
  9300. const renderDisabledTab = () => {
  9301. const {
  9302. disabledCoupons
  9303. } = props2;
  9304. const count = props2.showCount ? ` (${disabledCoupons.length})` : "";
  9305. const title = (props2.disabledTitle || t$9("disabled")) + count;
  9306. return createVNode(Tab, {
  9307. "title": title
  9308. }, {
  9309. default: () => {
  9310. var _a;
  9311. return [createVNode("div", {
  9312. "class": bem$O("list", {
  9313. "with-bottom": props2.showCloseButton
  9314. }),
  9315. "style": {
  9316. height: `${listHeight.value}px`
  9317. }
  9318. }, [disabledCoupons.map((coupon) => createVNode(Coupon, {
  9319. "disabled": true,
  9320. "key": coupon.id,
  9321. "coupon": coupon,
  9322. "currency": props2.currency
  9323. }, null)), !disabledCoupons.length && renderEmpty(), (_a = slots["disabled-list-footer"]) == null ? void 0 : _a.call(slots)])];
  9324. }
  9325. });
  9326. };
  9327. watch(() => props2.code, (value) => {
  9328. currentCode.value = value;
  9329. });
  9330. watch(windowHeight, updateListHeight);
  9331. watch(currentCode, (value) => emit("update:code", value));
  9332. watch(() => props2.displayedCouponIndex, scrollToCoupon);
  9333. onMounted(() => {
  9334. updateListHeight();
  9335. scrollToCoupon(props2.displayedCouponIndex);
  9336. });
  9337. return () => createVNode("div", {
  9338. "ref": root,
  9339. "class": bem$O()
  9340. }, [renderExchangeBar(), createVNode(Tabs, {
  9341. "active": activeTab.value,
  9342. "onUpdate:active": ($event) => activeTab.value = $event,
  9343. "class": bem$O("tab")
  9344. }, {
  9345. default: () => [renderCouponTab(), renderDisabledTab()]
  9346. }), createVNode("div", {
  9347. "class": bem$O("bottom")
  9348. }, [slots["list-button"] ? slots["list-button"]() : withDirectives(createVNode(Button, {
  9349. "round": true,
  9350. "block": true,
  9351. "type": "primary",
  9352. "class": bem$O("close"),
  9353. "text": props2.closeButtonText || t$9("close"),
  9354. "onClick": () => emit("change", Array.isArray(props2.chosenCoupon) ? [] : -1)
  9355. }, null), [[vShow, props2.showCloseButton]])])]);
  9356. }
  9357. });
  9358. const CouponList = withInstall(stdin_default$Y);
  9359. const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
  9360. const [name$O] = createNamespace("date-picker");
  9361. const datePickerProps = extend({}, sharedProps, {
  9362. columnsType: {
  9363. type: Array,
  9364. default: () => ["year", "month", "day"]
  9365. },
  9366. minDate: {
  9367. type: Date,
  9368. default: () => new Date(currentYear - 10, 0, 1),
  9369. validator: isDate
  9370. },
  9371. maxDate: {
  9372. type: Date,
  9373. default: () => new Date(currentYear + 10, 11, 31),
  9374. validator: isDate
  9375. }
  9376. });
  9377. var stdin_default$X = defineComponent({
  9378. name: name$O,
  9379. props: datePickerProps,
  9380. emits: ["confirm", "cancel", "change", "update:modelValue"],
  9381. setup(props2, {
  9382. emit,
  9383. slots
  9384. }) {
  9385. const currentValues = ref(props2.modelValue);
  9386. const updatedByExternalSources = ref(false);
  9387. const pickerRef = ref();
  9388. const computedValues = computed(() => updatedByExternalSources.value ? props2.modelValue : currentValues.value);
  9389. const isMinYear = (year) => year === props2.minDate.getFullYear();
  9390. const isMaxYear = (year) => year === props2.maxDate.getFullYear();
  9391. const isMinMonth = (month) => month === props2.minDate.getMonth() + 1;
  9392. const isMaxMonth = (month) => month === props2.maxDate.getMonth() + 1;
  9393. const getValue2 = (type) => {
  9394. const {
  9395. minDate,
  9396. columnsType
  9397. } = props2;
  9398. const index = columnsType.indexOf(type);
  9399. const value = computedValues.value[index];
  9400. if (value) {
  9401. return +value;
  9402. }
  9403. switch (type) {
  9404. case "year":
  9405. return minDate.getFullYear();
  9406. case "month":
  9407. return minDate.getMonth() + 1;
  9408. case "day":
  9409. return minDate.getDate();
  9410. }
  9411. };
  9412. const genYearOptions = () => {
  9413. const minYear = props2.minDate.getFullYear();
  9414. const maxYear = props2.maxDate.getFullYear();
  9415. return genOptions(minYear, maxYear, "year", props2.formatter, props2.filter, computedValues.value);
  9416. };
  9417. const genMonthOptions = () => {
  9418. const year = getValue2("year");
  9419. const minMonth = isMinYear(year) ? props2.minDate.getMonth() + 1 : 1;
  9420. const maxMonth = isMaxYear(year) ? props2.maxDate.getMonth() + 1 : 12;
  9421. return genOptions(minMonth, maxMonth, "month", props2.formatter, props2.filter, computedValues.value);
  9422. };
  9423. const genDayOptions = () => {
  9424. const year = getValue2("year");
  9425. const month = getValue2("month");
  9426. const minDate = isMinYear(year) && isMinMonth(month) ? props2.minDate.getDate() : 1;
  9427. const maxDate = isMaxYear(year) && isMaxMonth(month) ? props2.maxDate.getDate() : getMonthEndDay(year, month);
  9428. return genOptions(minDate, maxDate, "day", props2.formatter, props2.filter, computedValues.value);
  9429. };
  9430. const confirm = () => {
  9431. var _a;
  9432. return (_a = pickerRef.value) == null ? void 0 : _a.confirm();
  9433. };
  9434. const getSelectedDate = () => currentValues.value;
  9435. const columns = computed(() => props2.columnsType.map((type) => {
  9436. switch (type) {
  9437. case "year":
  9438. return genYearOptions();
  9439. case "month":
  9440. return genMonthOptions();
  9441. case "day":
  9442. return genDayOptions();
  9443. default:
  9444. if (process.env.NODE_ENV !== "production") {
  9445. throw new Error(`[Vant] DatePicker: unsupported columns type: ${type}`);
  9446. }
  9447. return [];
  9448. }
  9449. }));
  9450. watch(currentValues, (newValues) => {
  9451. if (!isSameValue(newValues, props2.modelValue)) {
  9452. emit("update:modelValue", newValues);
  9453. }
  9454. });
  9455. watch(() => props2.modelValue, (newValues, oldValues) => {
  9456. updatedByExternalSources.value = isSameValue(oldValues, currentValues.value);
  9457. newValues = formatValueRange(newValues, columns.value);
  9458. if (!isSameValue(newValues, currentValues.value)) {
  9459. currentValues.value = newValues;
  9460. }
  9461. updatedByExternalSources.value = false;
  9462. }, {
  9463. immediate: true
  9464. });
  9465. const onChange = (...args) => emit("change", ...args);
  9466. const onCancel = (...args) => emit("cancel", ...args);
  9467. const onConfirm = (...args) => emit("confirm", ...args);
  9468. useExpose({
  9469. confirm,
  9470. getSelectedDate
  9471. });
  9472. return () => createVNode(Picker, mergeProps({
  9473. "ref": pickerRef,
  9474. "modelValue": currentValues.value,
  9475. "onUpdate:modelValue": ($event) => currentValues.value = $event,
  9476. "columns": columns.value,
  9477. "onChange": onChange,
  9478. "onCancel": onCancel,
  9479. "onConfirm": onConfirm
  9480. }, pick(props2, pickerInheritKeys)), slots);
  9481. }
  9482. });
  9483. const DatePicker = withInstall(stdin_default$X);
  9484. const [name$N, bem$N, t$8] = createNamespace("dialog");
  9485. const dialogProps = extend({}, popupSharedProps, {
  9486. title: String,
  9487. theme: String,
  9488. width: numericProp,
  9489. message: [String, Function],
  9490. callback: Function,
  9491. allowHtml: Boolean,
  9492. className: unknownProp,
  9493. transition: makeStringProp("van-dialog-bounce"),
  9494. messageAlign: String,
  9495. closeOnPopstate: truthProp,
  9496. showCancelButton: Boolean,
  9497. cancelButtonText: String,
  9498. cancelButtonColor: String,
  9499. cancelButtonDisabled: Boolean,
  9500. confirmButtonText: String,
  9501. confirmButtonColor: String,
  9502. confirmButtonDisabled: Boolean,
  9503. showConfirmButton: truthProp,
  9504. closeOnClickOverlay: Boolean,
  9505. keyboardEnabled: truthProp
  9506. });
  9507. const popupInheritKeys$1 = [...popupSharedPropKeys, "transition", "closeOnPopstate"];
  9508. var stdin_default$W = defineComponent({
  9509. name: name$N,
  9510. props: dialogProps,
  9511. emits: ["confirm", "cancel", "keydown", "update:show"],
  9512. setup(props2, {
  9513. emit,
  9514. slots
  9515. }) {
  9516. const root = ref();
  9517. const loading = reactive({
  9518. confirm: false,
  9519. cancel: false
  9520. });
  9521. const updateShow = (value) => emit("update:show", value);
  9522. const close = (action) => {
  9523. var _a;
  9524. updateShow(false);
  9525. (_a = props2.callback) == null ? void 0 : _a.call(props2, action);
  9526. };
  9527. const getActionHandler = (action) => () => {
  9528. if (!props2.show) {
  9529. return;
  9530. }
  9531. emit(action);
  9532. if (props2.beforeClose) {
  9533. loading[action] = true;
  9534. callInterceptor(props2.beforeClose, {
  9535. args: [action],
  9536. done() {
  9537. close(action);
  9538. loading[action] = false;
  9539. },
  9540. canceled() {
  9541. loading[action] = false;
  9542. }
  9543. });
  9544. } else {
  9545. close(action);
  9546. }
  9547. };
  9548. const onCancel = getActionHandler("cancel");
  9549. const onConfirm = getActionHandler("confirm");
  9550. const onKeydown = withKeys((event) => {
  9551. var _a, _b;
  9552. if (!props2.keyboardEnabled) {
  9553. return;
  9554. }
  9555. if (event.target !== ((_b = (_a = root.value) == null ? void 0 : _a.popupRef) == null ? void 0 : _b.value)) {
  9556. return;
  9557. }
  9558. const onEventType = {
  9559. Enter: props2.showConfirmButton ? onConfirm : noop,
  9560. Escape: props2.showCancelButton ? onCancel : noop
  9561. };
  9562. onEventType[event.key]();
  9563. emit("keydown", event);
  9564. }, ["enter", "esc"]);
  9565. const renderTitle = () => {
  9566. const title = slots.title ? slots.title() : props2.title;
  9567. if (title) {
  9568. return createVNode("div", {
  9569. "class": bem$N("header", {
  9570. isolated: !props2.message && !slots.default
  9571. })
  9572. }, [title]);
  9573. }
  9574. };
  9575. const renderMessage = (hasTitle) => {
  9576. const {
  9577. message,
  9578. allowHtml,
  9579. messageAlign
  9580. } = props2;
  9581. const classNames = bem$N("message", {
  9582. "has-title": hasTitle,
  9583. [messageAlign]: messageAlign
  9584. });
  9585. const content = isFunction(message) ? message() : message;
  9586. if (allowHtml && typeof content === "string") {
  9587. return createVNode("div", {
  9588. "class": classNames,
  9589. "innerHTML": content
  9590. }, null);
  9591. }
  9592. return createVNode("div", {
  9593. "class": classNames
  9594. }, [content]);
  9595. };
  9596. const renderContent = () => {
  9597. if (slots.default) {
  9598. return createVNode("div", {
  9599. "class": bem$N("content")
  9600. }, [slots.default()]);
  9601. }
  9602. const {
  9603. title,
  9604. message,
  9605. allowHtml
  9606. } = props2;
  9607. if (message) {
  9608. const hasTitle = !!(title || slots.title);
  9609. return createVNode("div", {
  9610. "key": allowHtml ? 1 : 0,
  9611. "class": bem$N("content", {
  9612. isolated: !hasTitle
  9613. })
  9614. }, [renderMessage(hasTitle)]);
  9615. }
  9616. };
  9617. const renderButtons = () => createVNode("div", {
  9618. "class": [BORDER_TOP, bem$N("footer")]
  9619. }, [props2.showCancelButton && createVNode(Button, {
  9620. "size": "large",
  9621. "text": props2.cancelButtonText || t$8("cancel"),
  9622. "class": bem$N("cancel"),
  9623. "style": {
  9624. color: props2.cancelButtonColor
  9625. },
  9626. "loading": loading.cancel,
  9627. "disabled": props2.cancelButtonDisabled,
  9628. "onClick": onCancel
  9629. }, null), props2.showConfirmButton && createVNode(Button, {
  9630. "size": "large",
  9631. "text": props2.confirmButtonText || t$8("confirm"),
  9632. "class": [bem$N("confirm"), {
  9633. [BORDER_LEFT]: props2.showCancelButton
  9634. }],
  9635. "style": {
  9636. color: props2.confirmButtonColor
  9637. },
  9638. "loading": loading.confirm,
  9639. "disabled": props2.confirmButtonDisabled,
  9640. "onClick": onConfirm
  9641. }, null)]);
  9642. const renderRoundButtons = () => createVNode(ActionBar, {
  9643. "class": bem$N("footer")
  9644. }, {
  9645. default: () => [props2.showCancelButton && createVNode(ActionBarButton, {
  9646. "type": "warning",
  9647. "text": props2.cancelButtonText || t$8("cancel"),
  9648. "class": bem$N("cancel"),
  9649. "color": props2.cancelButtonColor,
  9650. "loading": loading.cancel,
  9651. "disabled": props2.cancelButtonDisabled,
  9652. "onClick": onCancel
  9653. }, null), props2.showConfirmButton && createVNode(ActionBarButton, {
  9654. "type": "danger",
  9655. "text": props2.confirmButtonText || t$8("confirm"),
  9656. "class": bem$N("confirm"),
  9657. "color": props2.confirmButtonColor,
  9658. "loading": loading.confirm,
  9659. "disabled": props2.confirmButtonDisabled,
  9660. "onClick": onConfirm
  9661. }, null)]
  9662. });
  9663. const renderFooter = () => {
  9664. if (slots.footer) {
  9665. return slots.footer();
  9666. }
  9667. return props2.theme === "round-button" ? renderRoundButtons() : renderButtons();
  9668. };
  9669. return () => {
  9670. const {
  9671. width,
  9672. title,
  9673. theme,
  9674. message,
  9675. className
  9676. } = props2;
  9677. return createVNode(Popup, mergeProps({
  9678. "ref": root,
  9679. "role": "dialog",
  9680. "class": [bem$N([theme]), className],
  9681. "style": {
  9682. width: addUnit(width)
  9683. },
  9684. "tabindex": 0,
  9685. "aria-labelledby": title || message,
  9686. "onKeydown": onKeydown,
  9687. "onUpdate:show": updateShow
  9688. }, pick(props2, popupInheritKeys$1)), {
  9689. default: () => [renderTitle(), renderContent(), renderFooter()]
  9690. });
  9691. };
  9692. }
  9693. });
  9694. let instance$2;
  9695. const DEFAULT_OPTIONS = {
  9696. title: "",
  9697. width: "",
  9698. theme: null,
  9699. message: "",
  9700. overlay: true,
  9701. callback: null,
  9702. teleport: "body",
  9703. className: "",
  9704. allowHtml: false,
  9705. lockScroll: true,
  9706. transition: void 0,
  9707. beforeClose: null,
  9708. overlayClass: "",
  9709. overlayStyle: void 0,
  9710. messageAlign: "",
  9711. cancelButtonText: "",
  9712. cancelButtonColor: null,
  9713. cancelButtonDisabled: false,
  9714. confirmButtonText: "",
  9715. confirmButtonColor: null,
  9716. confirmButtonDisabled: false,
  9717. showConfirmButton: true,
  9718. showCancelButton: false,
  9719. closeOnPopstate: true,
  9720. closeOnClickOverlay: false
  9721. };
  9722. let currentOptions$1 = extend({}, DEFAULT_OPTIONS);
  9723. function initInstance$2() {
  9724. const Wrapper = {
  9725. setup() {
  9726. const {
  9727. state,
  9728. toggle
  9729. } = usePopupState();
  9730. return () => createVNode(stdin_default$W, mergeProps(state, {
  9731. "onUpdate:show": toggle
  9732. }), null);
  9733. }
  9734. };
  9735. ({
  9736. instance: instance$2
  9737. } = mountComponent(Wrapper));
  9738. }
  9739. function showDialog(options) {
  9740. if (!inBrowser) {
  9741. return Promise.resolve(void 0);
  9742. }
  9743. return new Promise((resolve, reject) => {
  9744. if (!instance$2) {
  9745. initInstance$2();
  9746. }
  9747. instance$2.open(extend({}, currentOptions$1, options, {
  9748. callback: (action) => {
  9749. (action === "confirm" ? resolve : reject)(action);
  9750. }
  9751. }));
  9752. });
  9753. }
  9754. const setDialogDefaultOptions = (options) => {
  9755. extend(currentOptions$1, options);
  9756. };
  9757. const resetDialogDefaultOptions = () => {
  9758. currentOptions$1 = extend({}, DEFAULT_OPTIONS);
  9759. };
  9760. const showConfirmDialog = (options) => showDialog(extend({
  9761. showCancelButton: true
  9762. }, options));
  9763. const closeDialog = () => {
  9764. if (instance$2) {
  9765. instance$2.toggle(false);
  9766. }
  9767. };
  9768. const Dialog = withInstall(stdin_default$W);
  9769. const [name$M, bem$M] = createNamespace("divider");
  9770. const dividerProps = {
  9771. dashed: Boolean,
  9772. hairline: truthProp,
  9773. vertical: Boolean,
  9774. contentPosition: makeStringProp("center")
  9775. };
  9776. var stdin_default$V = defineComponent({
  9777. name: name$M,
  9778. props: dividerProps,
  9779. setup(props2, {
  9780. slots
  9781. }) {
  9782. return () => {
  9783. var _a;
  9784. return createVNode("div", {
  9785. "role": "separator",
  9786. "class": bem$M({
  9787. dashed: props2.dashed,
  9788. hairline: props2.hairline,
  9789. vertical: props2.vertical,
  9790. [`content-${props2.contentPosition}`]: !!slots.default && !props2.vertical
  9791. })
  9792. }, [!props2.vertical && ((_a = slots.default) == null ? void 0 : _a.call(slots))]);
  9793. };
  9794. }
  9795. });
  9796. const Divider = withInstall(stdin_default$V);
  9797. const [name$L, bem$L] = createNamespace("dropdown-menu");
  9798. const dropdownMenuProps = {
  9799. overlay: truthProp,
  9800. zIndex: numericProp,
  9801. duration: makeNumericProp(0.2),
  9802. direction: makeStringProp("down"),
  9803. activeColor: String,
  9804. autoLocate: Boolean,
  9805. closeOnClickOutside: truthProp,
  9806. closeOnClickOverlay: truthProp,
  9807. swipeThreshold: numericProp
  9808. };
  9809. const DROPDOWN_KEY = Symbol(name$L);
  9810. var stdin_default$U = defineComponent({
  9811. name: name$L,
  9812. props: dropdownMenuProps,
  9813. setup(props2, {
  9814. slots
  9815. }) {
  9816. const id = useId();
  9817. const root = ref();
  9818. const barRef = ref();
  9819. const offset = ref(0);
  9820. const {
  9821. children,
  9822. linkChildren
  9823. } = useChildren(DROPDOWN_KEY);
  9824. const scrollParent = useScrollParent(root);
  9825. const opened = computed(() => children.some((item) => item.state.showWrapper));
  9826. const scrollable = computed(() => props2.swipeThreshold && children.length > +props2.swipeThreshold);
  9827. const barStyle = computed(() => {
  9828. if (opened.value && isDef(props2.zIndex)) {
  9829. return {
  9830. zIndex: +props2.zIndex + 1
  9831. };
  9832. }
  9833. });
  9834. const close = () => {
  9835. children.forEach((item) => {
  9836. item.toggle(false);
  9837. });
  9838. };
  9839. const onClickAway = () => {
  9840. if (props2.closeOnClickOutside) {
  9841. close();
  9842. }
  9843. };
  9844. const updateOffset = () => {
  9845. if (barRef.value) {
  9846. const rect = useRect(barRef);
  9847. if (props2.direction === "down") {
  9848. offset.value = rect.bottom;
  9849. } else {
  9850. offset.value = windowHeight.value - rect.top;
  9851. }
  9852. }
  9853. };
  9854. const onScroll = () => {
  9855. if (opened.value) {
  9856. updateOffset();
  9857. }
  9858. };
  9859. const toggleItem = (active) => {
  9860. children.forEach((item, index) => {
  9861. if (index === active) {
  9862. item.toggle();
  9863. } else if (item.state.showPopup) {
  9864. item.toggle(false, {
  9865. immediate: true
  9866. });
  9867. }
  9868. });
  9869. };
  9870. const renderTitle = (item, index) => {
  9871. const {
  9872. showPopup
  9873. } = item.state;
  9874. const {
  9875. disabled,
  9876. titleClass
  9877. } = item;
  9878. return createVNode("div", {
  9879. "id": `${id}-${index}`,
  9880. "role": "button",
  9881. "tabindex": disabled ? void 0 : 0,
  9882. "data-allow-mismatch": "attribute",
  9883. "class": [bem$L("item", {
  9884. disabled,
  9885. grow: scrollable.value
  9886. }), {
  9887. [HAPTICS_FEEDBACK]: !disabled
  9888. }],
  9889. "onClick": () => {
  9890. if (!disabled) {
  9891. toggleItem(index);
  9892. }
  9893. }
  9894. }, [createVNode("span", {
  9895. "class": [bem$L("title", {
  9896. down: showPopup === (props2.direction === "down"),
  9897. active: showPopup
  9898. }), titleClass],
  9899. "style": {
  9900. color: showPopup ? props2.activeColor : ""
  9901. }
  9902. }, [createVNode("div", {
  9903. "class": "van-ellipsis"
  9904. }, [item.renderTitle()])])]);
  9905. };
  9906. useExpose({
  9907. close
  9908. });
  9909. linkChildren({
  9910. id,
  9911. props: props2,
  9912. offset,
  9913. updateOffset
  9914. });
  9915. useClickAway(root, onClickAway);
  9916. useEventListener("scroll", onScroll, {
  9917. target: scrollParent,
  9918. passive: true
  9919. });
  9920. return () => {
  9921. var _a;
  9922. return createVNode("div", {
  9923. "ref": root,
  9924. "class": bem$L()
  9925. }, [createVNode("div", {
  9926. "ref": barRef,
  9927. "style": barStyle.value,
  9928. "class": bem$L("bar", {
  9929. opened: opened.value,
  9930. scrollable: scrollable.value
  9931. })
  9932. }, [children.map(renderTitle)]), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  9933. };
  9934. }
  9935. });
  9936. const [name$K, bem$K] = createNamespace("dropdown-item");
  9937. const dropdownItemProps = {
  9938. title: String,
  9939. options: makeArrayProp(),
  9940. disabled: Boolean,
  9941. teleport: [String, Object],
  9942. lazyRender: truthProp,
  9943. modelValue: unknownProp,
  9944. titleClass: unknownProp
  9945. };
  9946. var stdin_default$T = defineComponent({
  9947. name: name$K,
  9948. inheritAttrs: false,
  9949. props: dropdownItemProps,
  9950. emits: ["open", "opened", "close", "closed", "change", "update:modelValue"],
  9951. setup(props2, {
  9952. emit,
  9953. slots,
  9954. attrs
  9955. }) {
  9956. const state = reactive({
  9957. showPopup: false,
  9958. transition: true,
  9959. showWrapper: false
  9960. });
  9961. const wrapperRef = ref();
  9962. const {
  9963. parent,
  9964. index
  9965. } = useParent(DROPDOWN_KEY);
  9966. if (!parent) {
  9967. if (process.env.NODE_ENV !== "production") {
  9968. console.error("[Vant] <DropdownItem> must be a child component of <DropdownMenu>.");
  9969. }
  9970. return;
  9971. }
  9972. const getEmitter = (name2) => () => emit(name2);
  9973. const onOpen = getEmitter("open");
  9974. const onClose = getEmitter("close");
  9975. const onOpened = getEmitter("opened");
  9976. const onClosed = () => {
  9977. state.showWrapper = false;
  9978. emit("closed");
  9979. };
  9980. const onClickWrapper = (event) => {
  9981. if (props2.teleport) {
  9982. event.stopPropagation();
  9983. }
  9984. };
  9985. const toggle = (show = !state.showPopup, options = {}) => {
  9986. if (show === state.showPopup) {
  9987. return;
  9988. }
  9989. state.showPopup = show;
  9990. state.transition = !options.immediate;
  9991. if (show) {
  9992. parent.updateOffset();
  9993. state.showWrapper = true;
  9994. }
  9995. };
  9996. const renderTitle = () => {
  9997. if (slots.title) {
  9998. return slots.title();
  9999. }
  10000. if (props2.title) {
  10001. return props2.title;
  10002. }
  10003. const match = props2.options.find((option) => option.value === props2.modelValue);
  10004. return match ? match.text : "";
  10005. };
  10006. const renderOption = (option) => {
  10007. const {
  10008. activeColor
  10009. } = parent.props;
  10010. const {
  10011. disabled
  10012. } = option;
  10013. const active = option.value === props2.modelValue;
  10014. const onClick = () => {
  10015. if (disabled) {
  10016. return;
  10017. }
  10018. state.showPopup = false;
  10019. if (option.value !== props2.modelValue) {
  10020. emit("update:modelValue", option.value);
  10021. emit("change", option.value);
  10022. }
  10023. };
  10024. const renderIcon = () => {
  10025. if (active) {
  10026. return createVNode(Icon, {
  10027. "class": bem$K("icon"),
  10028. "color": disabled ? void 0 : activeColor,
  10029. "name": "success"
  10030. }, null);
  10031. }
  10032. };
  10033. return createVNode(Cell, {
  10034. "role": "menuitem",
  10035. "key": String(option.value),
  10036. "icon": option.icon,
  10037. "title": option.text,
  10038. "class": bem$K("option", {
  10039. active,
  10040. disabled
  10041. }),
  10042. "style": {
  10043. color: active ? activeColor : ""
  10044. },
  10045. "tabindex": active ? 0 : -1,
  10046. "clickable": !disabled,
  10047. "onClick": onClick
  10048. }, {
  10049. value: renderIcon
  10050. });
  10051. };
  10052. const renderContent = () => {
  10053. const {
  10054. offset
  10055. } = parent;
  10056. const {
  10057. autoLocate,
  10058. zIndex,
  10059. overlay,
  10060. duration,
  10061. direction,
  10062. closeOnClickOverlay
  10063. } = parent.props;
  10064. const style = getZIndexStyle(zIndex);
  10065. let offsetValue = offset.value;
  10066. if (autoLocate && wrapperRef.value) {
  10067. const offsetParent = getContainingBlock(wrapperRef.value);
  10068. if (offsetParent) {
  10069. offsetValue -= useRect(offsetParent).top;
  10070. }
  10071. }
  10072. if (direction === "down") {
  10073. style.top = `${offsetValue}px`;
  10074. } else {
  10075. style.bottom = `${offsetValue}px`;
  10076. }
  10077. return withDirectives(createVNode("div", mergeProps({
  10078. "ref": wrapperRef,
  10079. "style": style,
  10080. "class": bem$K([direction]),
  10081. "onClick": onClickWrapper
  10082. }, attrs), [createVNode(Popup, {
  10083. "show": state.showPopup,
  10084. "onUpdate:show": ($event) => state.showPopup = $event,
  10085. "role": "menu",
  10086. "class": bem$K("content"),
  10087. "overlay": overlay,
  10088. "position": direction === "down" ? "top" : "bottom",
  10089. "duration": state.transition ? duration : 0,
  10090. "lazyRender": props2.lazyRender,
  10091. "overlayStyle": {
  10092. position: "absolute"
  10093. },
  10094. "aria-labelledby": `${parent.id}-${index.value}`,
  10095. "data-allow-mismatch": "attribute",
  10096. "closeOnClickOverlay": closeOnClickOverlay,
  10097. "onOpen": onOpen,
  10098. "onClose": onClose,
  10099. "onOpened": onOpened,
  10100. "onClosed": onClosed
  10101. }, {
  10102. default: () => {
  10103. var _a;
  10104. return [props2.options.map(renderOption), (_a = slots.default) == null ? void 0 : _a.call(slots)];
  10105. }
  10106. })]), [[vShow, state.showWrapper]]);
  10107. };
  10108. useExpose({
  10109. state,
  10110. toggle,
  10111. renderTitle
  10112. });
  10113. return () => {
  10114. if (props2.teleport) {
  10115. return createVNode(Teleport, {
  10116. "to": props2.teleport
  10117. }, {
  10118. default: () => [renderContent()]
  10119. });
  10120. }
  10121. return renderContent();
  10122. };
  10123. }
  10124. });
  10125. const DropdownItem = withInstall(stdin_default$T);
  10126. const DropdownMenu = withInstall(stdin_default$U);
  10127. const floatingBubbleProps = {
  10128. gap: makeNumberProp(24),
  10129. icon: String,
  10130. axis: makeStringProp("y"),
  10131. magnetic: String,
  10132. offset: {
  10133. type: Object,
  10134. default: () => ({
  10135. x: -1,
  10136. y: -1
  10137. })
  10138. },
  10139. teleport: {
  10140. type: [String, Object],
  10141. default: "body"
  10142. }
  10143. };
  10144. const [name$J, bem$J] = createNamespace("floating-bubble");
  10145. var stdin_default$S = defineComponent({
  10146. name: name$J,
  10147. inheritAttrs: false,
  10148. props: floatingBubbleProps,
  10149. emits: ["click", "update:offset", "offsetChange"],
  10150. setup(props2, {
  10151. slots,
  10152. emit,
  10153. attrs
  10154. }) {
  10155. const rootRef = ref();
  10156. const state = ref({
  10157. x: 0,
  10158. y: 0,
  10159. width: 0,
  10160. height: 0
  10161. });
  10162. const boundary = computed(() => ({
  10163. top: props2.gap,
  10164. right: windowWidth.value - state.value.width - props2.gap,
  10165. bottom: windowHeight.value - state.value.height - props2.gap,
  10166. left: props2.gap
  10167. }));
  10168. const dragging = ref(false);
  10169. let initialized = false;
  10170. const rootStyle = computed(() => {
  10171. const style = {};
  10172. const x = addUnit(state.value.x);
  10173. const y = addUnit(state.value.y);
  10174. style.transform = `translate3d(${x}, ${y}, 0)`;
  10175. if (dragging.value || !initialized) {
  10176. style.transition = "none";
  10177. }
  10178. return style;
  10179. });
  10180. const updateState = () => {
  10181. if (!show.value) return;
  10182. const {
  10183. width,
  10184. height
  10185. } = useRect(rootRef.value);
  10186. const {
  10187. offset
  10188. } = props2;
  10189. state.value = {
  10190. x: offset.x > -1 ? offset.x : windowWidth.value - width - props2.gap,
  10191. y: offset.y > -1 ? offset.y : windowHeight.value - height - props2.gap,
  10192. width,
  10193. height
  10194. };
  10195. };
  10196. const touch = useTouch();
  10197. let prevX = 0;
  10198. let prevY = 0;
  10199. const onTouchStart = (e) => {
  10200. touch.start(e);
  10201. dragging.value = true;
  10202. prevX = state.value.x;
  10203. prevY = state.value.y;
  10204. };
  10205. const onTouchMove = (e) => {
  10206. e.preventDefault();
  10207. touch.move(e);
  10208. if (props2.axis === "lock") return;
  10209. if (!touch.isTap.value) {
  10210. if (props2.axis === "x" || props2.axis === "xy") {
  10211. let nextX = prevX + touch.deltaX.value;
  10212. if (nextX < boundary.value.left) nextX = boundary.value.left;
  10213. if (nextX > boundary.value.right) nextX = boundary.value.right;
  10214. state.value.x = nextX;
  10215. }
  10216. if (props2.axis === "y" || props2.axis === "xy") {
  10217. let nextY = prevY + touch.deltaY.value;
  10218. if (nextY < boundary.value.top) nextY = boundary.value.top;
  10219. if (nextY > boundary.value.bottom) nextY = boundary.value.bottom;
  10220. state.value.y = nextY;
  10221. }
  10222. const offset = pick(state.value, ["x", "y"]);
  10223. emit("update:offset", offset);
  10224. }
  10225. };
  10226. useEventListener("touchmove", onTouchMove, {
  10227. target: rootRef
  10228. });
  10229. const onTouchEnd = () => {
  10230. dragging.value = false;
  10231. nextTick(() => {
  10232. if (props2.magnetic === "x") {
  10233. const nextX = closest([boundary.value.left, boundary.value.right], state.value.x);
  10234. state.value.x = nextX;
  10235. }
  10236. if (props2.magnetic === "y") {
  10237. const nextY = closest([boundary.value.top, boundary.value.bottom], state.value.y);
  10238. state.value.y = nextY;
  10239. }
  10240. if (!touch.isTap.value) {
  10241. const offset = pick(state.value, ["x", "y"]);
  10242. emit("update:offset", offset);
  10243. if (prevX !== offset.x || prevY !== offset.y) {
  10244. emit("offsetChange", offset);
  10245. }
  10246. }
  10247. });
  10248. };
  10249. const onClick = (e) => {
  10250. if (touch.isTap.value) emit("click", e);
  10251. else e.stopPropagation();
  10252. };
  10253. onMounted(() => {
  10254. updateState();
  10255. nextTick(() => {
  10256. initialized = true;
  10257. });
  10258. });
  10259. watch([windowWidth, windowHeight, () => props2.gap, () => props2.offset], updateState, {
  10260. deep: true
  10261. });
  10262. const show = ref(true);
  10263. onActivated(() => {
  10264. show.value = true;
  10265. });
  10266. onDeactivated(() => {
  10267. if (props2.teleport) {
  10268. show.value = false;
  10269. }
  10270. });
  10271. return () => {
  10272. const Content = withDirectives(createVNode("div", mergeProps({
  10273. "class": bem$J(),
  10274. "ref": rootRef,
  10275. "onTouchstartPassive": onTouchStart,
  10276. "onTouchend": onTouchEnd,
  10277. "onTouchcancel": onTouchEnd,
  10278. "onClickCapture": onClick,
  10279. "style": rootStyle.value
  10280. }, attrs), [slots.default ? slots.default() : createVNode(stdin_default$1Q, {
  10281. "name": props2.icon,
  10282. "class": bem$J("icon")
  10283. }, null)]), [[vShow, show.value]]);
  10284. return props2.teleport ? createVNode(Teleport, {
  10285. "to": props2.teleport
  10286. }, {
  10287. default: () => [Content]
  10288. }) : Content;
  10289. };
  10290. }
  10291. });
  10292. const FloatingBubble = withInstall(stdin_default$S);
  10293. const floatingPanelProps = {
  10294. height: makeNumericProp(0),
  10295. anchors: makeArrayProp(),
  10296. duration: makeNumericProp(0.3),
  10297. contentDraggable: truthProp,
  10298. lockScroll: Boolean,
  10299. safeAreaInsetBottom: truthProp
  10300. };
  10301. const [name$I, bem$I] = createNamespace("floating-panel");
  10302. var stdin_default$R = defineComponent({
  10303. name: name$I,
  10304. props: floatingPanelProps,
  10305. emits: ["heightChange", "update:height"],
  10306. setup(props2, {
  10307. emit,
  10308. slots
  10309. }) {
  10310. const DAMP = 0.2;
  10311. const rootRef = ref();
  10312. const contentRef = ref();
  10313. const height = useSyncPropRef(() => +props2.height, (value) => emit("update:height", value));
  10314. const boundary = computed(() => {
  10315. var _a, _b;
  10316. return {
  10317. min: (_a = props2.anchors[0]) != null ? _a : 100,
  10318. max: (_b = props2.anchors[props2.anchors.length - 1]) != null ? _b : Math.round(windowHeight.value * 0.6)
  10319. };
  10320. });
  10321. const anchors = computed(() => props2.anchors.length >= 2 ? props2.anchors : [boundary.value.min, boundary.value.max]);
  10322. const dragging = ref(false);
  10323. const rootStyle = computed(() => ({
  10324. height: addUnit(boundary.value.max),
  10325. transform: `translateY(calc(100% + ${addUnit(-height.value)}))`,
  10326. transition: !dragging.value ? `transform ${props2.duration}s cubic-bezier(0.18, 0.89, 0.32, 1.28)` : "none"
  10327. }));
  10328. const ease = (moveY) => {
  10329. const absDistance = Math.abs(moveY);
  10330. const {
  10331. min,
  10332. max
  10333. } = boundary.value;
  10334. if (absDistance > max) {
  10335. return -(max + (absDistance - max) * DAMP);
  10336. }
  10337. if (absDistance < min) {
  10338. return -(min - (min - absDistance) * DAMP);
  10339. }
  10340. return moveY;
  10341. };
  10342. let startY;
  10343. let maxScroll = -1;
  10344. const touch = useTouch();
  10345. const onTouchstart = (e) => {
  10346. touch.start(e);
  10347. dragging.value = true;
  10348. startY = -height.value;
  10349. maxScroll = -1;
  10350. };
  10351. const onTouchmove = (e) => {
  10352. var _a;
  10353. touch.move(e);
  10354. const target = e.target;
  10355. if (contentRef.value === target || ((_a = contentRef.value) == null ? void 0 : _a.contains(target))) {
  10356. const {
  10357. scrollTop
  10358. } = contentRef.value;
  10359. maxScroll = Math.max(maxScroll, scrollTop);
  10360. if (!props2.contentDraggable) return;
  10361. if (-startY < boundary.value.max) {
  10362. preventDefault(e, true);
  10363. } else if (!(scrollTop <= 0 && touch.deltaY.value > 0) || maxScroll > 0) {
  10364. return;
  10365. }
  10366. }
  10367. const moveY = touch.deltaY.value + startY;
  10368. height.value = -ease(moveY);
  10369. };
  10370. const onTouchend = () => {
  10371. maxScroll = -1;
  10372. dragging.value = false;
  10373. height.value = closest(anchors.value, height.value);
  10374. if (height.value !== -startY) {
  10375. emit("heightChange", {
  10376. height: height.value
  10377. });
  10378. }
  10379. };
  10380. watch(boundary, () => {
  10381. height.value = closest(anchors.value, height.value);
  10382. }, {
  10383. immediate: true
  10384. });
  10385. useLockScroll(rootRef, () => props2.lockScroll || dragging.value);
  10386. useEventListener("touchmove", onTouchmove, {
  10387. target: rootRef
  10388. });
  10389. const renderHeader = () => {
  10390. if (slots.header) {
  10391. return slots.header();
  10392. }
  10393. return createVNode("div", {
  10394. "class": bem$I("header")
  10395. }, [createVNode("div", {
  10396. "class": bem$I("header-bar")
  10397. }, null)]);
  10398. };
  10399. return () => {
  10400. var _a;
  10401. return createVNode("div", {
  10402. "class": [bem$I(), {
  10403. "van-safe-area-bottom": props2.safeAreaInsetBottom
  10404. }],
  10405. "ref": rootRef,
  10406. "style": rootStyle.value,
  10407. "onTouchstartPassive": onTouchstart,
  10408. "onTouchend": onTouchend,
  10409. "onTouchcancel": onTouchend
  10410. }, [renderHeader(), createVNode("div", {
  10411. "class": bem$I("content"),
  10412. "ref": contentRef
  10413. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  10414. };
  10415. }
  10416. });
  10417. const FloatingPanel = withInstall(stdin_default$R);
  10418. const [name$H, bem$H] = createNamespace("grid");
  10419. const gridProps = {
  10420. square: Boolean,
  10421. center: truthProp,
  10422. border: truthProp,
  10423. gutter: numericProp,
  10424. reverse: Boolean,
  10425. iconSize: numericProp,
  10426. direction: String,
  10427. clickable: Boolean,
  10428. columnNum: makeNumericProp(4)
  10429. };
  10430. const GRID_KEY = Symbol(name$H);
  10431. var stdin_default$Q = defineComponent({
  10432. name: name$H,
  10433. props: gridProps,
  10434. setup(props2, {
  10435. slots
  10436. }) {
  10437. const {
  10438. linkChildren
  10439. } = useChildren(GRID_KEY);
  10440. linkChildren({
  10441. props: props2
  10442. });
  10443. return () => {
  10444. var _a;
  10445. return createVNode("div", {
  10446. "style": {
  10447. paddingLeft: addUnit(props2.gutter)
  10448. },
  10449. "class": [bem$H(), {
  10450. [BORDER_TOP]: props2.border && !props2.gutter
  10451. }]
  10452. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  10453. };
  10454. }
  10455. });
  10456. const Grid = withInstall(stdin_default$Q);
  10457. const [name$G, bem$G] = createNamespace("grid-item");
  10458. const gridItemProps = extend({}, routeProps, {
  10459. dot: Boolean,
  10460. text: String,
  10461. icon: String,
  10462. badge: numericProp,
  10463. iconColor: String,
  10464. iconPrefix: String,
  10465. badgeProps: Object
  10466. });
  10467. var stdin_default$P = defineComponent({
  10468. name: name$G,
  10469. props: gridItemProps,
  10470. setup(props2, {
  10471. slots
  10472. }) {
  10473. const {
  10474. parent,
  10475. index
  10476. } = useParent(GRID_KEY);
  10477. const route2 = useRoute();
  10478. if (!parent) {
  10479. if (process.env.NODE_ENV !== "production") {
  10480. console.error("[Vant] <GridItem> must be a child component of <Grid>.");
  10481. }
  10482. return;
  10483. }
  10484. const rootStyle = computed(() => {
  10485. const {
  10486. square,
  10487. gutter,
  10488. columnNum
  10489. } = parent.props;
  10490. const percent = `${100 / +columnNum}%`;
  10491. const style = {
  10492. flexBasis: percent
  10493. };
  10494. if (square) {
  10495. style.paddingTop = percent;
  10496. } else if (gutter) {
  10497. const gutterValue = addUnit(gutter);
  10498. style.paddingRight = gutterValue;
  10499. if (index.value >= +columnNum) {
  10500. style.marginTop = gutterValue;
  10501. }
  10502. }
  10503. return style;
  10504. });
  10505. const contentStyle = computed(() => {
  10506. const {
  10507. square,
  10508. gutter
  10509. } = parent.props;
  10510. if (square && gutter) {
  10511. const gutterValue = addUnit(gutter);
  10512. return {
  10513. right: gutterValue,
  10514. bottom: gutterValue,
  10515. height: "auto"
  10516. };
  10517. }
  10518. });
  10519. const renderIcon = () => {
  10520. if (slots.icon) {
  10521. return createVNode(Badge, mergeProps({
  10522. "dot": props2.dot,
  10523. "content": props2.badge
  10524. }, props2.badgeProps), {
  10525. default: slots.icon
  10526. });
  10527. }
  10528. if (props2.icon) {
  10529. return createVNode(Icon, {
  10530. "dot": props2.dot,
  10531. "name": props2.icon,
  10532. "size": parent.props.iconSize,
  10533. "badge": props2.badge,
  10534. "class": bem$G("icon"),
  10535. "color": props2.iconColor,
  10536. "badgeProps": props2.badgeProps,
  10537. "classPrefix": props2.iconPrefix
  10538. }, null);
  10539. }
  10540. };
  10541. const renderText = () => {
  10542. if (slots.text) {
  10543. return slots.text();
  10544. }
  10545. if (props2.text) {
  10546. return createVNode("span", {
  10547. "class": bem$G("text")
  10548. }, [props2.text]);
  10549. }
  10550. };
  10551. const renderContent = () => {
  10552. if (slots.default) {
  10553. return slots.default();
  10554. }
  10555. return [renderIcon(), renderText()];
  10556. };
  10557. return () => {
  10558. const {
  10559. center,
  10560. border,
  10561. square,
  10562. gutter,
  10563. reverse,
  10564. direction,
  10565. clickable
  10566. } = parent.props;
  10567. const classes = [bem$G("content", [direction, {
  10568. center,
  10569. square,
  10570. reverse,
  10571. clickable,
  10572. surround: border && gutter
  10573. }]), {
  10574. [BORDER]: border
  10575. }];
  10576. return createVNode("div", {
  10577. "class": [bem$G({
  10578. square
  10579. })],
  10580. "style": rootStyle.value
  10581. }, [createVNode("div", {
  10582. "role": clickable ? "button" : void 0,
  10583. "class": classes,
  10584. "style": contentStyle.value,
  10585. "tabindex": clickable ? 0 : void 0,
  10586. "onClick": route2
  10587. }, [renderContent()])]);
  10588. };
  10589. }
  10590. });
  10591. const GridItem = withInstall(stdin_default$P);
  10592. const [name$F, bem$F] = createNamespace("highlight");
  10593. const highlightProps = {
  10594. autoEscape: truthProp,
  10595. caseSensitive: Boolean,
  10596. highlightClass: String,
  10597. highlightTag: makeStringProp("span"),
  10598. keywords: makeRequiredProp([String, Array]),
  10599. sourceString: makeStringProp(""),
  10600. tag: makeStringProp("div"),
  10601. unhighlightClass: String,
  10602. unhighlightTag: makeStringProp("span")
  10603. };
  10604. var stdin_default$O = defineComponent({
  10605. name: name$F,
  10606. props: highlightProps,
  10607. setup(props2) {
  10608. const highlightChunks = computed(() => {
  10609. const {
  10610. autoEscape,
  10611. caseSensitive,
  10612. keywords,
  10613. sourceString
  10614. } = props2;
  10615. const flags = caseSensitive ? "g" : "gi";
  10616. const _keywords = Array.isArray(keywords) ? keywords : [keywords];
  10617. let chunks = _keywords.filter((keyword) => keyword).reduce((chunks2, keyword) => {
  10618. if (autoEscape) {
  10619. keyword = keyword.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
  10620. }
  10621. const regex = new RegExp(keyword, flags);
  10622. let match;
  10623. while (match = regex.exec(sourceString)) {
  10624. const start = match.index;
  10625. const end = regex.lastIndex;
  10626. if (start >= end) {
  10627. regex.lastIndex++;
  10628. continue;
  10629. }
  10630. chunks2.push({
  10631. start,
  10632. end,
  10633. highlight: true
  10634. });
  10635. }
  10636. return chunks2;
  10637. }, []);
  10638. chunks = chunks.sort((a, b) => a.start - b.start).reduce((chunks2, currentChunk) => {
  10639. const prevChunk = chunks2[chunks2.length - 1];
  10640. if (!prevChunk || currentChunk.start > prevChunk.end) {
  10641. const unhighlightStart = prevChunk ? prevChunk.end : 0;
  10642. const unhighlightEnd = currentChunk.start;
  10643. if (unhighlightStart !== unhighlightEnd) {
  10644. chunks2.push({
  10645. start: unhighlightStart,
  10646. end: unhighlightEnd,
  10647. highlight: false
  10648. });
  10649. }
  10650. chunks2.push(currentChunk);
  10651. } else {
  10652. prevChunk.end = Math.max(prevChunk.end, currentChunk.end);
  10653. }
  10654. return chunks2;
  10655. }, []);
  10656. const lastChunk = chunks[chunks.length - 1];
  10657. if (!lastChunk) {
  10658. chunks.push({
  10659. start: 0,
  10660. end: sourceString.length,
  10661. highlight: false
  10662. });
  10663. }
  10664. if (lastChunk && lastChunk.end < sourceString.length) {
  10665. chunks.push({
  10666. start: lastChunk.end,
  10667. end: sourceString.length,
  10668. highlight: false
  10669. });
  10670. }
  10671. return chunks;
  10672. });
  10673. const renderContent = () => {
  10674. const {
  10675. sourceString,
  10676. highlightClass,
  10677. unhighlightClass,
  10678. highlightTag,
  10679. unhighlightTag
  10680. } = props2;
  10681. return highlightChunks.value.map((chunk) => {
  10682. const {
  10683. start,
  10684. end,
  10685. highlight
  10686. } = chunk;
  10687. const text = sourceString.slice(start, end);
  10688. if (highlight) {
  10689. return createVNode(highlightTag, {
  10690. "class": [bem$F("tag"), highlightClass]
  10691. }, {
  10692. default: () => [text]
  10693. });
  10694. }
  10695. return createVNode(unhighlightTag, {
  10696. "class": unhighlightClass
  10697. }, {
  10698. default: () => [text]
  10699. });
  10700. });
  10701. };
  10702. return () => {
  10703. const {
  10704. tag
  10705. } = props2;
  10706. return createVNode(tag, {
  10707. "class": bem$F()
  10708. }, {
  10709. default: () => [renderContent()]
  10710. });
  10711. };
  10712. }
  10713. });
  10714. const Highlight = withInstall(stdin_default$O);
  10715. const getDistance = (touches) => Math.sqrt((touches[0].clientX - touches[1].clientX) ** 2 + (touches[0].clientY - touches[1].clientY) ** 2);
  10716. const getCenter = (touches) => ({
  10717. x: (touches[0].clientX + touches[1].clientX) / 2,
  10718. y: (touches[0].clientY + touches[1].clientY) / 2
  10719. });
  10720. const bem$E = createNamespace("image-preview")[1];
  10721. const longImageRatio = 2.6;
  10722. const imagePreviewItemProps = {
  10723. src: String,
  10724. show: Boolean,
  10725. active: Number,
  10726. minZoom: makeRequiredProp(numericProp),
  10727. maxZoom: makeRequiredProp(numericProp),
  10728. rootWidth: makeRequiredProp(Number),
  10729. rootHeight: makeRequiredProp(Number),
  10730. disableZoom: Boolean,
  10731. doubleScale: Boolean,
  10732. closeOnClickImage: Boolean,
  10733. closeOnClickOverlay: Boolean,
  10734. vertical: Boolean
  10735. };
  10736. var stdin_default$N = defineComponent({
  10737. props: imagePreviewItemProps,
  10738. emits: ["scale", "close", "longPress"],
  10739. setup(props2, {
  10740. emit,
  10741. slots
  10742. }) {
  10743. const state = reactive({
  10744. scale: 1,
  10745. moveX: 0,
  10746. moveY: 0,
  10747. moving: false,
  10748. zooming: false,
  10749. initializing: false,
  10750. imageRatio: 0
  10751. });
  10752. const touch = useTouch();
  10753. const imageRef = ref();
  10754. const swipeItem = ref();
  10755. const vertical = ref(false);
  10756. const isLongImage = ref(false);
  10757. let initialMoveY = 0;
  10758. const imageStyle = computed(() => {
  10759. const {
  10760. scale,
  10761. moveX,
  10762. moveY,
  10763. moving,
  10764. zooming,
  10765. initializing
  10766. } = state;
  10767. const style = {
  10768. transitionDuration: zooming || moving || initializing ? "0s" : ".3s"
  10769. };
  10770. if (scale !== 1 || isLongImage.value) {
  10771. style.transform = `matrix(${scale}, 0, 0, ${scale}, ${moveX}, ${moveY})`;
  10772. }
  10773. return style;
  10774. });
  10775. const maxMoveX = computed(() => {
  10776. if (state.imageRatio) {
  10777. const {
  10778. rootWidth,
  10779. rootHeight
  10780. } = props2;
  10781. const displayWidth = vertical.value ? rootHeight / state.imageRatio : rootWidth;
  10782. return Math.max(0, (state.scale * displayWidth - rootWidth) / 2);
  10783. }
  10784. return 0;
  10785. });
  10786. const maxMoveY = computed(() => {
  10787. if (state.imageRatio) {
  10788. const {
  10789. rootWidth,
  10790. rootHeight
  10791. } = props2;
  10792. const displayHeight = vertical.value ? rootHeight : rootWidth * state.imageRatio;
  10793. return Math.max(0, (state.scale * displayHeight - rootHeight) / 2);
  10794. }
  10795. return 0;
  10796. });
  10797. const setScale = (scale, center) => {
  10798. var _a;
  10799. scale = clamp(scale, +props2.minZoom, +props2.maxZoom + 1);
  10800. if (scale !== state.scale) {
  10801. const ratio = scale / state.scale;
  10802. state.scale = scale;
  10803. if (center) {
  10804. const imageRect = useRect((_a = imageRef.value) == null ? void 0 : _a.$el);
  10805. const origin = {
  10806. x: imageRect.width * 0.5,
  10807. y: imageRect.height * 0.5
  10808. };
  10809. const moveX = state.moveX - (center.x - imageRect.left - origin.x) * (ratio - 1);
  10810. const moveY = state.moveY - (center.y - imageRect.top - origin.y) * (ratio - 1);
  10811. state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
  10812. state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
  10813. } else {
  10814. state.moveX = 0;
  10815. state.moveY = isLongImage.value ? initialMoveY : 0;
  10816. }
  10817. emit("scale", {
  10818. scale,
  10819. index: props2.active
  10820. });
  10821. }
  10822. };
  10823. const resetScale = () => {
  10824. setScale(1);
  10825. };
  10826. const toggleScale = () => {
  10827. const scale = state.scale > 1 ? 1 : 2;
  10828. setScale(scale, scale === 2 || isLongImage.value ? {
  10829. x: touch.startX.value,
  10830. y: touch.startY.value
  10831. } : void 0);
  10832. };
  10833. let fingerNum;
  10834. let startMoveX;
  10835. let startMoveY;
  10836. let startScale;
  10837. let startDistance;
  10838. let lastCenter;
  10839. let doubleTapTimer;
  10840. let touchStartTime;
  10841. let isImageMoved = false;
  10842. const onTouchStart = (event) => {
  10843. const {
  10844. touches
  10845. } = event;
  10846. fingerNum = touches.length;
  10847. if (fingerNum === 2 && props2.disableZoom) {
  10848. return;
  10849. }
  10850. const {
  10851. offsetX
  10852. } = touch;
  10853. touch.start(event);
  10854. startMoveX = state.moveX;
  10855. startMoveY = state.moveY;
  10856. touchStartTime = Date.now();
  10857. isImageMoved = false;
  10858. state.moving = fingerNum === 1 && (state.scale !== 1 || isLongImage.value);
  10859. state.zooming = fingerNum === 2 && !offsetX.value;
  10860. if (state.zooming) {
  10861. startScale = state.scale;
  10862. startDistance = getDistance(touches);
  10863. }
  10864. };
  10865. const onTouchMove = (event) => {
  10866. const {
  10867. touches
  10868. } = event;
  10869. touch.move(event);
  10870. if (state.moving) {
  10871. const {
  10872. deltaX,
  10873. deltaY
  10874. } = touch;
  10875. const moveX = deltaX.value + startMoveX;
  10876. const moveY = deltaY.value + startMoveY;
  10877. if ((props2.vertical ? touch.isVertical() && Math.abs(moveY) > maxMoveY.value : touch.isHorizontal() && Math.abs(moveX) > maxMoveX.value) && !isImageMoved) {
  10878. state.moving = false;
  10879. return;
  10880. }
  10881. isImageMoved = true;
  10882. preventDefault(event, true);
  10883. state.moveX = clamp(moveX, -maxMoveX.value, maxMoveX.value);
  10884. state.moveY = clamp(moveY, -maxMoveY.value, maxMoveY.value);
  10885. }
  10886. if (state.zooming) {
  10887. preventDefault(event, true);
  10888. if (touches.length === 2) {
  10889. const distance = getDistance(touches);
  10890. const scale = startScale * distance / startDistance;
  10891. lastCenter = getCenter(touches);
  10892. setScale(scale, lastCenter);
  10893. }
  10894. }
  10895. };
  10896. const checkClose = (event) => {
  10897. var _a;
  10898. const swipeItemEl = (_a = swipeItem.value) == null ? void 0 : _a.$el;
  10899. if (!swipeItemEl) return;
  10900. const imageEl = swipeItemEl.firstElementChild;
  10901. const isClickOverlay = event.target === swipeItemEl;
  10902. const isClickImage = imageEl == null ? void 0 : imageEl.contains(event.target);
  10903. if (!props2.closeOnClickImage && isClickImage) return;
  10904. if (!props2.closeOnClickOverlay && isClickOverlay) return;
  10905. emit("close");
  10906. };
  10907. const checkTap = (event) => {
  10908. if (fingerNum > 1) {
  10909. return;
  10910. }
  10911. const deltaTime = Date.now() - touchStartTime;
  10912. const TAP_TIME = 250;
  10913. if (touch.isTap.value) {
  10914. if (deltaTime < TAP_TIME) {
  10915. if (props2.doubleScale) {
  10916. if (doubleTapTimer) {
  10917. clearTimeout(doubleTapTimer);
  10918. doubleTapTimer = null;
  10919. toggleScale();
  10920. } else {
  10921. doubleTapTimer = setTimeout(() => {
  10922. checkClose(event);
  10923. doubleTapTimer = null;
  10924. }, TAP_TIME);
  10925. }
  10926. } else {
  10927. checkClose(event);
  10928. }
  10929. } else if (deltaTime > LONG_PRESS_START_TIME) {
  10930. emit("longPress");
  10931. }
  10932. }
  10933. };
  10934. const onTouchEnd = (event) => {
  10935. let stopPropagation2 = false;
  10936. if (state.moving || state.zooming) {
  10937. stopPropagation2 = true;
  10938. if (state.moving && startMoveX === state.moveX && startMoveY === state.moveY) {
  10939. stopPropagation2 = false;
  10940. }
  10941. if (!event.touches.length) {
  10942. if (state.zooming) {
  10943. state.moveX = clamp(state.moveX, -maxMoveX.value, maxMoveX.value);
  10944. state.moveY = clamp(state.moveY, -maxMoveY.value, maxMoveY.value);
  10945. state.zooming = false;
  10946. }
  10947. state.moving = false;
  10948. startMoveX = 0;
  10949. startMoveY = 0;
  10950. startScale = 1;
  10951. if (state.scale < 1) {
  10952. resetScale();
  10953. }
  10954. const maxZoom = +props2.maxZoom;
  10955. if (state.scale > maxZoom) {
  10956. setScale(maxZoom, lastCenter);
  10957. }
  10958. }
  10959. }
  10960. preventDefault(event, stopPropagation2);
  10961. checkTap(event);
  10962. touch.reset();
  10963. };
  10964. const resize = () => {
  10965. const {
  10966. rootWidth,
  10967. rootHeight
  10968. } = props2;
  10969. const rootRatio = rootHeight / rootWidth;
  10970. const {
  10971. imageRatio
  10972. } = state;
  10973. vertical.value = state.imageRatio > rootRatio && imageRatio < longImageRatio;
  10974. isLongImage.value = state.imageRatio > rootRatio && imageRatio >= longImageRatio;
  10975. if (isLongImage.value) {
  10976. initialMoveY = (imageRatio * rootWidth - rootHeight) / 2;
  10977. state.moveY = initialMoveY;
  10978. state.initializing = true;
  10979. raf(() => {
  10980. state.initializing = false;
  10981. });
  10982. }
  10983. resetScale();
  10984. };
  10985. const onLoad = (event) => {
  10986. const {
  10987. naturalWidth,
  10988. naturalHeight
  10989. } = event.target;
  10990. state.imageRatio = naturalHeight / naturalWidth;
  10991. resize();
  10992. };
  10993. watch(() => props2.active, resetScale);
  10994. watch(() => props2.show, (value) => {
  10995. if (!value) {
  10996. resetScale();
  10997. }
  10998. });
  10999. watch(() => [props2.rootWidth, props2.rootHeight], resize);
  11000. useEventListener("touchmove", onTouchMove, {
  11001. target: computed(() => {
  11002. var _a;
  11003. return (_a = swipeItem.value) == null ? void 0 : _a.$el;
  11004. })
  11005. });
  11006. useExpose({
  11007. resetScale
  11008. });
  11009. return () => {
  11010. const imageSlots = {
  11011. loading: () => createVNode(Loading, {
  11012. "type": "spinner"
  11013. }, null)
  11014. };
  11015. return createVNode(SwipeItem, {
  11016. "ref": swipeItem,
  11017. "class": bem$E("swipe-item"),
  11018. "onTouchstartPassive": onTouchStart,
  11019. "onTouchend": onTouchEnd,
  11020. "onTouchcancel": onTouchEnd
  11021. }, {
  11022. default: () => [slots.image ? createVNode("div", {
  11023. "class": bem$E("image-wrap")
  11024. }, [slots.image({
  11025. src: props2.src,
  11026. onLoad,
  11027. style: imageStyle.value
  11028. })]) : createVNode(Image$1, {
  11029. "ref": imageRef,
  11030. "src": props2.src,
  11031. "fit": "contain",
  11032. "class": bem$E("image", {
  11033. vertical: vertical.value
  11034. }),
  11035. "style": imageStyle.value,
  11036. "onLoad": onLoad
  11037. }, imageSlots)]
  11038. });
  11039. };
  11040. }
  11041. });
  11042. const [name$E, bem$D] = createNamespace("image-preview");
  11043. const popupProps$1 = ["show", "teleport", "transition", "overlayStyle", "closeOnPopstate"];
  11044. const imagePreviewProps = {
  11045. show: Boolean,
  11046. loop: truthProp,
  11047. images: makeArrayProp(),
  11048. minZoom: makeNumericProp(1 / 3),
  11049. maxZoom: makeNumericProp(3),
  11050. overlay: truthProp,
  11051. vertical: Boolean,
  11052. closeable: Boolean,
  11053. showIndex: truthProp,
  11054. className: unknownProp,
  11055. closeIcon: makeStringProp("clear"),
  11056. transition: String,
  11057. beforeClose: Function,
  11058. doubleScale: truthProp,
  11059. overlayClass: unknownProp,
  11060. overlayStyle: Object,
  11061. swipeDuration: makeNumericProp(300),
  11062. startPosition: makeNumericProp(0),
  11063. showIndicators: Boolean,
  11064. closeOnPopstate: truthProp,
  11065. closeOnClickImage: truthProp,
  11066. closeOnClickOverlay: truthProp,
  11067. closeIconPosition: makeStringProp("top-right"),
  11068. teleport: [String, Object]
  11069. };
  11070. var stdin_default$M = defineComponent({
  11071. name: name$E,
  11072. props: imagePreviewProps,
  11073. emits: ["scale", "close", "closed", "change", "longPress", "update:show"],
  11074. setup(props2, {
  11075. emit,
  11076. slots
  11077. }) {
  11078. const swipeRef = ref();
  11079. const activedPreviewItemRef = ref();
  11080. const state = reactive({
  11081. active: 0,
  11082. rootWidth: 0,
  11083. rootHeight: 0,
  11084. disableZoom: false
  11085. });
  11086. const resize = () => {
  11087. if (swipeRef.value) {
  11088. const rect = useRect(swipeRef.value.$el);
  11089. state.rootWidth = rect.width;
  11090. state.rootHeight = rect.height;
  11091. swipeRef.value.resize();
  11092. }
  11093. };
  11094. const emitScale = (args) => emit("scale", args);
  11095. const updateShow = (show) => emit("update:show", show);
  11096. const emitClose = () => {
  11097. callInterceptor(props2.beforeClose, {
  11098. args: [state.active],
  11099. done: () => updateShow(false)
  11100. });
  11101. };
  11102. const setActive = (active) => {
  11103. if (active !== state.active) {
  11104. state.active = active;
  11105. emit("change", active);
  11106. }
  11107. };
  11108. const renderIndex = () => {
  11109. if (props2.showIndex) {
  11110. return createVNode("div", {
  11111. "class": bem$D("index")
  11112. }, [slots.index ? slots.index({
  11113. index: state.active
  11114. }) : `${state.active + 1} / ${props2.images.length}`]);
  11115. }
  11116. };
  11117. const renderCover = () => {
  11118. if (slots.cover) {
  11119. return createVNode("div", {
  11120. "class": bem$D("cover")
  11121. }, [slots.cover()]);
  11122. }
  11123. };
  11124. const onDragStart = () => {
  11125. state.disableZoom = true;
  11126. };
  11127. const onDragEnd = () => {
  11128. state.disableZoom = false;
  11129. };
  11130. const renderImages = () => createVNode(Swipe, {
  11131. "ref": swipeRef,
  11132. "lazyRender": true,
  11133. "loop": props2.loop,
  11134. "class": bem$D("swipe"),
  11135. "vertical": props2.vertical,
  11136. "duration": props2.swipeDuration,
  11137. "initialSwipe": props2.startPosition,
  11138. "showIndicators": props2.showIndicators,
  11139. "indicatorColor": "white",
  11140. "onChange": setActive,
  11141. "onDragEnd": onDragEnd,
  11142. "onDragStart": onDragStart
  11143. }, {
  11144. default: () => [props2.images.map((image, index) => createVNode(stdin_default$N, {
  11145. "ref": (item) => {
  11146. if (index === state.active) {
  11147. activedPreviewItemRef.value = item;
  11148. }
  11149. },
  11150. "src": image,
  11151. "show": props2.show,
  11152. "active": state.active,
  11153. "maxZoom": props2.maxZoom,
  11154. "minZoom": props2.minZoom,
  11155. "rootWidth": state.rootWidth,
  11156. "rootHeight": state.rootHeight,
  11157. "disableZoom": state.disableZoom,
  11158. "doubleScale": props2.doubleScale,
  11159. "closeOnClickImage": props2.closeOnClickImage,
  11160. "closeOnClickOverlay": props2.closeOnClickOverlay,
  11161. "vertical": props2.vertical,
  11162. "onScale": emitScale,
  11163. "onClose": emitClose,
  11164. "onLongPress": () => emit("longPress", {
  11165. index
  11166. })
  11167. }, {
  11168. image: slots.image
  11169. }))]
  11170. });
  11171. const renderClose = () => {
  11172. if (props2.closeable) {
  11173. return createVNode(Icon, {
  11174. "role": "button",
  11175. "name": props2.closeIcon,
  11176. "class": [bem$D("close-icon", props2.closeIconPosition), HAPTICS_FEEDBACK],
  11177. "onClick": emitClose
  11178. }, null);
  11179. }
  11180. };
  11181. const onClosed = () => emit("closed");
  11182. const swipeTo = (index, options) => {
  11183. var _a;
  11184. return (_a = swipeRef.value) == null ? void 0 : _a.swipeTo(index, options);
  11185. };
  11186. useExpose({
  11187. resetScale: () => {
  11188. var _a;
  11189. (_a = activedPreviewItemRef.value) == null ? void 0 : _a.resetScale();
  11190. },
  11191. swipeTo
  11192. });
  11193. onMounted(resize);
  11194. watch([windowWidth, windowHeight], resize);
  11195. watch(() => props2.startPosition, (value) => setActive(+value));
  11196. watch(() => props2.show, (value) => {
  11197. const {
  11198. images,
  11199. startPosition
  11200. } = props2;
  11201. if (value) {
  11202. setActive(+startPosition);
  11203. nextTick(() => {
  11204. resize();
  11205. swipeTo(+startPosition, {
  11206. immediate: true
  11207. });
  11208. });
  11209. } else {
  11210. emit("close", {
  11211. index: state.active,
  11212. url: images[state.active]
  11213. });
  11214. }
  11215. });
  11216. return () => createVNode(Popup, mergeProps({
  11217. "class": [bem$D(), props2.className],
  11218. "overlayClass": [bem$D("overlay"), props2.overlayClass],
  11219. "onClosed": onClosed,
  11220. "onUpdate:show": updateShow
  11221. }, pick(props2, popupProps$1)), {
  11222. default: () => [renderClose(), renderImages(), renderIndex(), renderCover()]
  11223. });
  11224. }
  11225. });
  11226. let instance$1;
  11227. const defaultConfig = {
  11228. loop: true,
  11229. images: [],
  11230. maxZoom: 3,
  11231. minZoom: 1 / 3,
  11232. onScale: void 0,
  11233. onClose: void 0,
  11234. onChange: void 0,
  11235. vertical: false,
  11236. teleport: "body",
  11237. className: "",
  11238. showIndex: true,
  11239. closeable: false,
  11240. closeIcon: "clear",
  11241. transition: void 0,
  11242. beforeClose: void 0,
  11243. doubleScale: true,
  11244. overlayStyle: void 0,
  11245. overlayClass: void 0,
  11246. startPosition: 0,
  11247. swipeDuration: 300,
  11248. showIndicators: false,
  11249. closeOnPopstate: true,
  11250. closeOnClickOverlay: true,
  11251. closeIconPosition: "top-right"
  11252. };
  11253. function initInstance$1() {
  11254. ({
  11255. instance: instance$1
  11256. } = mountComponent({
  11257. setup() {
  11258. const {
  11259. state,
  11260. toggle
  11261. } = usePopupState();
  11262. const onClosed = () => {
  11263. state.images = [];
  11264. };
  11265. return () => createVNode(stdin_default$M, mergeProps(state, {
  11266. "onClosed": onClosed,
  11267. "onUpdate:show": toggle
  11268. }), null);
  11269. }
  11270. }));
  11271. }
  11272. const showImagePreview = (options, startPosition = 0) => {
  11273. if (!inBrowser) {
  11274. return;
  11275. }
  11276. if (!instance$1) {
  11277. initInstance$1();
  11278. }
  11279. options = Array.isArray(options) ? {
  11280. images: options,
  11281. startPosition
  11282. } : options;
  11283. instance$1.open(extend({}, defaultConfig, options));
  11284. return instance$1;
  11285. };
  11286. const ImagePreview = withInstall(stdin_default$M);
  11287. function genAlphabet() {
  11288. const charCodeOfA = "A".charCodeAt(0);
  11289. const indexList = Array(26).fill("").map((_, i) => String.fromCharCode(charCodeOfA + i));
  11290. return indexList;
  11291. }
  11292. const [name$D, bem$C] = createNamespace("index-bar");
  11293. const indexBarProps = {
  11294. sticky: truthProp,
  11295. zIndex: numericProp,
  11296. teleport: [String, Object],
  11297. highlightColor: String,
  11298. stickyOffsetTop: makeNumberProp(0),
  11299. indexList: {
  11300. type: Array,
  11301. default: genAlphabet
  11302. }
  11303. };
  11304. const INDEX_BAR_KEY = Symbol(name$D);
  11305. var stdin_default$L = defineComponent({
  11306. name: name$D,
  11307. props: indexBarProps,
  11308. emits: ["select", "change"],
  11309. setup(props2, {
  11310. emit,
  11311. slots
  11312. }) {
  11313. const root = ref();
  11314. const sidebar = ref();
  11315. const activeAnchor = ref("");
  11316. const touch = useTouch();
  11317. const scrollParent = useScrollParent(root);
  11318. const {
  11319. children,
  11320. linkChildren
  11321. } = useChildren(INDEX_BAR_KEY);
  11322. let selectActiveIndex;
  11323. linkChildren({
  11324. props: props2
  11325. });
  11326. const sidebarStyle = computed(() => {
  11327. if (isDef(props2.zIndex)) {
  11328. return {
  11329. zIndex: +props2.zIndex + 1
  11330. };
  11331. }
  11332. });
  11333. const highlightStyle = computed(() => {
  11334. if (props2.highlightColor) {
  11335. return {
  11336. color: props2.highlightColor
  11337. };
  11338. }
  11339. });
  11340. const getActiveAnchor = (scrollTop, rects) => {
  11341. for (let i = children.length - 1; i >= 0; i--) {
  11342. const prevHeight = i > 0 ? rects[i - 1].height : 0;
  11343. const reachTop = props2.sticky ? prevHeight + props2.stickyOffsetTop : 0;
  11344. if (scrollTop + reachTop >= rects[i].top) {
  11345. return i;
  11346. }
  11347. }
  11348. return -1;
  11349. };
  11350. const getMatchAnchor = (index) => children.find((item) => String(item.index) === index);
  11351. const onScroll = () => {
  11352. if (isHidden(root)) {
  11353. return;
  11354. }
  11355. const {
  11356. sticky,
  11357. indexList
  11358. } = props2;
  11359. const scrollTop = getScrollTop(scrollParent.value);
  11360. const scrollParentRect = useRect(scrollParent);
  11361. const rects = children.map((item) => item.getRect(scrollParent.value, scrollParentRect));
  11362. let active = -1;
  11363. if (selectActiveIndex) {
  11364. const match = getMatchAnchor(selectActiveIndex);
  11365. if (match) {
  11366. const rect = match.getRect(scrollParent.value, scrollParentRect);
  11367. if (props2.sticky && props2.stickyOffsetTop) {
  11368. active = getActiveAnchor(rect.top - props2.stickyOffsetTop, rects);
  11369. } else {
  11370. active = getActiveAnchor(rect.top, rects);
  11371. }
  11372. }
  11373. } else {
  11374. active = getActiveAnchor(scrollTop, rects);
  11375. }
  11376. activeAnchor.value = indexList[active];
  11377. if (sticky) {
  11378. children.forEach((item, index) => {
  11379. const {
  11380. state,
  11381. $el
  11382. } = item;
  11383. if (index === active || index === active - 1) {
  11384. const rect = $el.getBoundingClientRect();
  11385. state.left = rect.left;
  11386. state.width = rect.width;
  11387. } else {
  11388. state.left = null;
  11389. state.width = null;
  11390. }
  11391. if (index === active) {
  11392. state.active = true;
  11393. state.top = Math.max(props2.stickyOffsetTop, rects[index].top - scrollTop) + scrollParentRect.top;
  11394. } else if (index === active - 1 && selectActiveIndex === "") {
  11395. const activeItemTop = rects[active].top - scrollTop;
  11396. state.active = activeItemTop > 0;
  11397. state.top = activeItemTop + scrollParentRect.top - rects[index].height;
  11398. } else {
  11399. state.active = false;
  11400. }
  11401. });
  11402. }
  11403. selectActiveIndex = "";
  11404. };
  11405. const init = () => {
  11406. nextTick(onScroll);
  11407. };
  11408. useEventListener("scroll", onScroll, {
  11409. target: scrollParent,
  11410. passive: true
  11411. });
  11412. onMounted(init);
  11413. watch(() => props2.indexList, init);
  11414. watch(activeAnchor, (value) => {
  11415. if (value) {
  11416. emit("change", value);
  11417. }
  11418. });
  11419. const renderIndexes = () => props2.indexList.map((index) => {
  11420. const active = index === activeAnchor.value;
  11421. return createVNode("span", {
  11422. "class": bem$C("index", {
  11423. active
  11424. }),
  11425. "style": active ? highlightStyle.value : void 0,
  11426. "data-index": index
  11427. }, [index]);
  11428. });
  11429. const scrollTo = (index) => {
  11430. selectActiveIndex = String(index);
  11431. const match = getMatchAnchor(selectActiveIndex);
  11432. if (match) {
  11433. const scrollTop = getScrollTop(scrollParent.value);
  11434. const scrollParentRect = useRect(scrollParent);
  11435. const {
  11436. offsetHeight
  11437. } = document.documentElement;
  11438. match.$el.scrollIntoView();
  11439. if (scrollTop === offsetHeight - scrollParentRect.height) {
  11440. onScroll();
  11441. return;
  11442. }
  11443. if (props2.sticky && props2.stickyOffsetTop) {
  11444. if (getRootScrollTop() === offsetHeight - scrollParentRect.height) {
  11445. setRootScrollTop(getRootScrollTop());
  11446. } else {
  11447. setRootScrollTop(getRootScrollTop() - props2.stickyOffsetTop);
  11448. }
  11449. }
  11450. emit("select", match.index);
  11451. }
  11452. };
  11453. const scrollToElement = (element) => {
  11454. const {
  11455. index
  11456. } = element.dataset;
  11457. if (index) {
  11458. scrollTo(index);
  11459. }
  11460. };
  11461. const onClickSidebar = (event) => {
  11462. scrollToElement(event.target);
  11463. };
  11464. let touchActiveIndex;
  11465. const onTouchMove = (event) => {
  11466. touch.move(event);
  11467. if (touch.isVertical()) {
  11468. preventDefault(event);
  11469. const {
  11470. clientX,
  11471. clientY
  11472. } = event.touches[0];
  11473. const target = document.elementFromPoint(clientX, clientY);
  11474. if (target) {
  11475. const {
  11476. index
  11477. } = target.dataset;
  11478. if (index && touchActiveIndex !== index) {
  11479. touchActiveIndex = index;
  11480. scrollToElement(target);
  11481. }
  11482. }
  11483. }
  11484. };
  11485. const renderSidebar = () => createVNode("div", {
  11486. "ref": sidebar,
  11487. "class": bem$C("sidebar"),
  11488. "style": sidebarStyle.value,
  11489. "onClick": onClickSidebar,
  11490. "onTouchstartPassive": touch.start
  11491. }, [renderIndexes()]);
  11492. useExpose({
  11493. scrollTo
  11494. });
  11495. useEventListener("touchmove", onTouchMove, {
  11496. target: sidebar
  11497. });
  11498. return () => {
  11499. var _a;
  11500. return createVNode("div", {
  11501. "ref": root,
  11502. "class": bem$C()
  11503. }, [props2.teleport ? createVNode(Teleport, {
  11504. "to": props2.teleport
  11505. }, {
  11506. default: () => [renderSidebar()]
  11507. }) : renderSidebar(), (_a = slots.default) == null ? void 0 : _a.call(slots)]);
  11508. };
  11509. }
  11510. });
  11511. const [name$C, bem$B] = createNamespace("index-anchor");
  11512. const indexAnchorProps = {
  11513. index: numericProp
  11514. };
  11515. var stdin_default$K = defineComponent({
  11516. name: name$C,
  11517. props: indexAnchorProps,
  11518. setup(props2, {
  11519. slots
  11520. }) {
  11521. const state = reactive({
  11522. top: 0,
  11523. left: null,
  11524. rect: {
  11525. top: 0,
  11526. height: 0
  11527. },
  11528. width: null,
  11529. active: false
  11530. });
  11531. const root = ref();
  11532. const {
  11533. parent
  11534. } = useParent(INDEX_BAR_KEY);
  11535. if (!parent) {
  11536. if (process.env.NODE_ENV !== "production") {
  11537. console.error("[Vant] <IndexAnchor> must be a child component of <IndexBar>.");
  11538. }
  11539. return;
  11540. }
  11541. const isSticky = () => state.active && parent.props.sticky;
  11542. const anchorStyle = computed(() => {
  11543. const {
  11544. zIndex,
  11545. highlightColor
  11546. } = parent.props;
  11547. if (isSticky()) {
  11548. return extend(getZIndexStyle(zIndex), {
  11549. left: state.left ? `${state.left}px` : void 0,
  11550. width: state.width ? `${state.width}px` : void 0,
  11551. transform: state.top ? `translate3d(0, ${state.top}px, 0)` : void 0,
  11552. color: highlightColor
  11553. });
  11554. }
  11555. });
  11556. const getRect = (scrollParent, scrollParentRect) => {
  11557. const rootRect = useRect(root);
  11558. state.rect.height = rootRect.height;
  11559. if (scrollParent === window || scrollParent === document.body) {
  11560. state.rect.top = rootRect.top + getRootScrollTop();
  11561. } else {
  11562. state.rect.top = rootRect.top + getScrollTop(scrollParent) - scrollParentRect.top;
  11563. }
  11564. return state.rect;
  11565. };
  11566. useExpose({
  11567. state,
  11568. getRect
  11569. });
  11570. return () => {
  11571. const sticky = isSticky();
  11572. return createVNode("div", {
  11573. "ref": root,
  11574. "style": {
  11575. height: sticky ? `${state.rect.height}px` : void 0
  11576. }
  11577. }, [createVNode("div", {
  11578. "style": anchorStyle.value,
  11579. "class": [bem$B({
  11580. sticky
  11581. }), {
  11582. [BORDER_BOTTOM]: sticky
  11583. }]
  11584. }, [slots.default ? slots.default() : props2.index])]);
  11585. };
  11586. }
  11587. });
  11588. const IndexAnchor = withInstall(stdin_default$K);
  11589. const IndexBar = withInstall(stdin_default$L);
  11590. const [name$B, bem$A, t$7] = createNamespace("list");
  11591. const listProps = {
  11592. error: Boolean,
  11593. offset: makeNumericProp(300),
  11594. loading: Boolean,
  11595. disabled: Boolean,
  11596. finished: Boolean,
  11597. scroller: Object,
  11598. errorText: String,
  11599. direction: makeStringProp("down"),
  11600. loadingText: String,
  11601. finishedText: String,
  11602. immediateCheck: truthProp
  11603. };
  11604. var stdin_default$J = defineComponent({
  11605. name: name$B,
  11606. props: listProps,
  11607. emits: ["load", "update:error", "update:loading"],
  11608. setup(props2, {
  11609. emit,
  11610. slots
  11611. }) {
  11612. const loading = ref(props2.loading);
  11613. const root = ref();
  11614. const placeholder = ref();
  11615. const tabStatus = useTabStatus();
  11616. const scrollParent = useScrollParent(root);
  11617. const scroller = computed(() => props2.scroller || scrollParent.value);
  11618. const check = () => {
  11619. nextTick(() => {
  11620. if (loading.value || props2.finished || props2.disabled || props2.error || // skip check when inside an inactive tab
  11621. (tabStatus == null ? void 0 : tabStatus.value) === false) {
  11622. return;
  11623. }
  11624. const {
  11625. direction
  11626. } = props2;
  11627. const offset = +props2.offset;
  11628. const scrollParentRect = useRect(scroller);
  11629. if (!scrollParentRect.height || isHidden(root)) {
  11630. return;
  11631. }
  11632. let isReachEdge = false;
  11633. const placeholderRect = useRect(placeholder);
  11634. if (direction === "up") {
  11635. isReachEdge = scrollParentRect.top - placeholderRect.top <= offset;
  11636. } else {
  11637. isReachEdge = placeholderRect.bottom - scrollParentRect.bottom <= offset;
  11638. }
  11639. if (isReachEdge) {
  11640. loading.value = true;
  11641. emit("update:loading", true);
  11642. emit("load");
  11643. }
  11644. });
  11645. };
  11646. const renderFinishedText = () => {
  11647. if (props2.finished) {
  11648. const text = slots.finished ? slots.finished() : props2.finishedText;
  11649. if (text) {
  11650. return createVNode("div", {
  11651. "class": bem$A("finished-text")
  11652. }, [text]);
  11653. }
  11654. }
  11655. };
  11656. const clickErrorText = () => {
  11657. emit("update:error", false);
  11658. check();
  11659. };
  11660. const renderErrorText = () => {
  11661. if (props2.error) {
  11662. const text = slots.error ? slots.error() : props2.errorText;
  11663. if (text) {
  11664. return createVNode("div", {
  11665. "role": "button",
  11666. "class": bem$A("error-text"),
  11667. "tabindex": 0,
  11668. "onClick": clickErrorText
  11669. }, [text]);
  11670. }
  11671. }
  11672. };
  11673. const renderLoading = () => {
  11674. if (loading.value && !props2.finished && !props2.disabled) {
  11675. return createVNode("div", {
  11676. "class": bem$A("loading")
  11677. }, [slots.loading ? slots.loading() : createVNode(Loading, {
  11678. "class": bem$A("loading-icon")
  11679. }, {
  11680. default: () => [props2.loadingText || t$7("loading")]
  11681. })]);
  11682. }
  11683. };
  11684. watch(() => [props2.loading, props2.finished, props2.error], check);
  11685. if (tabStatus) {
  11686. watch(tabStatus, (tabActive) => {
  11687. if (tabActive) {
  11688. check();
  11689. }
  11690. });
  11691. }
  11692. onUpdated(() => {
  11693. loading.value = props2.loading;
  11694. });
  11695. onMounted(() => {
  11696. if (props2.immediateCheck) {
  11697. check();
  11698. }
  11699. });
  11700. useExpose({
  11701. check
  11702. });
  11703. useEventListener("scroll", check, {
  11704. target: scroller,
  11705. passive: true
  11706. });
  11707. return () => {
  11708. var _a;
  11709. const Content = (_a = slots.default) == null ? void 0 : _a.call(slots);
  11710. const Placeholder = createVNode("div", {
  11711. "ref": placeholder,
  11712. "class": bem$A("placeholder")
  11713. }, null);
  11714. return createVNode("div", {
  11715. "ref": root,
  11716. "role": "feed",
  11717. "class": bem$A(),
  11718. "aria-busy": loading.value
  11719. }, [props2.direction === "down" ? Content : Placeholder, renderLoading(), renderFinishedText(), renderErrorText(), props2.direction === "up" ? Content : Placeholder]);
  11720. };
  11721. }
  11722. });
  11723. const List = withInstall(stdin_default$J);
  11724. const [name$A, bem$z] = createNamespace("nav-bar");
  11725. const navBarProps = {
  11726. title: String,
  11727. fixed: Boolean,
  11728. zIndex: numericProp,
  11729. border: truthProp,
  11730. leftText: String,
  11731. rightText: String,
  11732. leftDisabled: Boolean,
  11733. rightDisabled: Boolean,
  11734. leftArrow: Boolean,
  11735. placeholder: Boolean,
  11736. safeAreaInsetTop: Boolean,
  11737. clickable: truthProp
  11738. };
  11739. var stdin_default$I = defineComponent({
  11740. name: name$A,
  11741. props: navBarProps,
  11742. emits: ["clickLeft", "clickRight"],
  11743. setup(props2, {
  11744. emit,
  11745. slots
  11746. }) {
  11747. const navBarRef = ref();
  11748. const renderPlaceholder = usePlaceholder(navBarRef, bem$z);
  11749. const onClickLeft = (event) => {
  11750. if (!props2.leftDisabled) {
  11751. emit("clickLeft", event);
  11752. }
  11753. };
  11754. const onClickRight = (event) => {
  11755. if (!props2.rightDisabled) {
  11756. emit("clickRight", event);
  11757. }
  11758. };
  11759. const renderLeft = () => {
  11760. if (slots.left) {
  11761. return slots.left();
  11762. }
  11763. return [props2.leftArrow && createVNode(Icon, {
  11764. "class": bem$z("arrow"),
  11765. "name": "arrow-left"
  11766. }, null), props2.leftText && createVNode("span", {
  11767. "class": bem$z("text")
  11768. }, [props2.leftText])];
  11769. };
  11770. const renderRight = () => {
  11771. if (slots.right) {
  11772. return slots.right();
  11773. }
  11774. return createVNode("span", {
  11775. "class": bem$z("text")
  11776. }, [props2.rightText]);
  11777. };
  11778. const renderNavBar = () => {
  11779. const {
  11780. title,
  11781. fixed,
  11782. border,
  11783. zIndex
  11784. } = props2;
  11785. const style = getZIndexStyle(zIndex);
  11786. const hasLeft = props2.leftArrow || props2.leftText || slots.left;
  11787. const hasRight = props2.rightText || slots.right;
  11788. return createVNode("div", {
  11789. "ref": navBarRef,
  11790. "style": style,
  11791. "class": [bem$z({
  11792. fixed
  11793. }), {
  11794. [BORDER_BOTTOM]: border,
  11795. "van-safe-area-top": props2.safeAreaInsetTop
  11796. }]
  11797. }, [createVNode("div", {
  11798. "class": bem$z("content")
  11799. }, [hasLeft && createVNode("div", {
  11800. "class": [bem$z("left", {
  11801. disabled: props2.leftDisabled
  11802. }), props2.clickable && !props2.leftDisabled ? HAPTICS_FEEDBACK : ""],
  11803. "onClick": onClickLeft
  11804. }, [renderLeft()]), createVNode("div", {
  11805. "class": [bem$z("title"), "van-ellipsis"]
  11806. }, [slots.title ? slots.title() : title]), hasRight && createVNode("div", {
  11807. "class": [bem$z("right", {
  11808. disabled: props2.rightDisabled
  11809. }), props2.clickable && !props2.rightDisabled ? HAPTICS_FEEDBACK : ""],
  11810. "onClick": onClickRight
  11811. }, [renderRight()])])]);
  11812. };
  11813. return () => {
  11814. if (props2.fixed && props2.placeholder) {
  11815. return renderPlaceholder(renderNavBar);
  11816. }
  11817. return renderNavBar();
  11818. };
  11819. }
  11820. });
  11821. const NavBar = withInstall(stdin_default$I);
  11822. const [name$z, bem$y] = createNamespace("notice-bar");
  11823. const noticeBarProps = {
  11824. text: String,
  11825. mode: String,
  11826. color: String,
  11827. delay: makeNumericProp(1),
  11828. speed: makeNumericProp(60),
  11829. leftIcon: String,
  11830. wrapable: Boolean,
  11831. background: String,
  11832. scrollable: {
  11833. type: Boolean,
  11834. default: null
  11835. }
  11836. };
  11837. var stdin_default$H = defineComponent({
  11838. name: name$z,
  11839. props: noticeBarProps,
  11840. emits: ["close", "replay"],
  11841. setup(props2, {
  11842. emit,
  11843. slots
  11844. }) {
  11845. let wrapWidth = 0;
  11846. let contentWidth = 0;
  11847. let startTimer;
  11848. const wrapRef = ref();
  11849. const contentRef = ref();
  11850. const state = reactive({
  11851. show: true,
  11852. offset: 0,
  11853. duration: 0
  11854. });
  11855. const renderLeftIcon = () => {
  11856. if (slots["left-icon"]) {
  11857. return slots["left-icon"]();
  11858. }
  11859. if (props2.leftIcon) {
  11860. return createVNode(Icon, {
  11861. "class": bem$y("left-icon"),
  11862. "name": props2.leftIcon
  11863. }, null);
  11864. }
  11865. };
  11866. const getRightIconName = () => {
  11867. if (props2.mode === "closeable") {
  11868. return "cross";
  11869. }
  11870. if (props2.mode === "link") {
  11871. return "arrow";
  11872. }
  11873. };
  11874. const onClickRightIcon = (event) => {
  11875. if (props2.mode === "closeable") {
  11876. state.show = false;
  11877. emit("close", event);
  11878. }
  11879. };
  11880. const renderRightIcon = () => {
  11881. if (slots["right-icon"]) {
  11882. return slots["right-icon"]();
  11883. }
  11884. const name2 = getRightIconName();
  11885. if (name2) {
  11886. return createVNode(Icon, {
  11887. "name": name2,
  11888. "class": bem$y("right-icon"),
  11889. "onClick": onClickRightIcon
  11890. }, null);
  11891. }
  11892. };
  11893. const onTransitionEnd = () => {
  11894. state.offset = wrapWidth;
  11895. state.duration = 0;
  11896. raf(() => {
  11897. doubleRaf(() => {
  11898. state.offset = -contentWidth;
  11899. state.duration = (contentWidth + wrapWidth) / +props2.speed;
  11900. emit("replay");
  11901. });
  11902. });
  11903. };
  11904. const renderMarquee = () => {
  11905. const ellipsis = props2.scrollable === false && !props2.wrapable;
  11906. const style = {
  11907. transform: state.offset ? `translateX(${state.offset}px)` : "",
  11908. transitionDuration: `${state.duration}s`
  11909. };
  11910. return createVNode("div", {
  11911. "ref": wrapRef,
  11912. "role": "marquee",
  11913. "class": bem$y("wrap")
  11914. }, [createVNode("div", {
  11915. "ref": contentRef,
  11916. "style": style,
  11917. "class": [bem$y("content"), {
  11918. "van-ellipsis": ellipsis
  11919. }],
  11920. "onTransitionend": onTransitionEnd
  11921. }, [slots.default ? slots.default() : props2.text])]);
  11922. };
  11923. const reset = () => {
  11924. const {
  11925. delay,
  11926. speed,
  11927. scrollable
  11928. } = props2;
  11929. const ms = isDef(delay) ? +delay * 1e3 : 0;
  11930. wrapWidth = 0;
  11931. contentWidth = 0;
  11932. state.offset = 0;
  11933. state.duration = 0;
  11934. clearTimeout(startTimer);
  11935. startTimer = setTimeout(() => {
  11936. if (!wrapRef.value || !contentRef.value || scrollable === false) {
  11937. return;
  11938. }
  11939. const wrapRefWidth = useRect(wrapRef).width;
  11940. const contentRefWidth = useRect(contentRef).width;
  11941. if (scrollable || contentRefWidth > wrapRefWidth) {
  11942. doubleRaf(() => {
  11943. wrapWidth = wrapRefWidth;
  11944. contentWidth = contentRefWidth;
  11945. state.offset = -contentWidth;
  11946. state.duration = contentWidth / +speed;
  11947. });
  11948. }
  11949. }, ms);
  11950. };
  11951. onPopupReopen(reset);
  11952. onMountedOrActivated(reset);
  11953. useEventListener("pageshow", reset);
  11954. useExpose({
  11955. reset
  11956. });
  11957. watch(() => [props2.text, props2.scrollable], reset);
  11958. return () => {
  11959. const {
  11960. color,
  11961. wrapable,
  11962. background
  11963. } = props2;
  11964. return withDirectives(createVNode("div", {
  11965. "role": "alert",
  11966. "class": bem$y({
  11967. wrapable
  11968. }),
  11969. "style": {
  11970. color,
  11971. background
  11972. }
  11973. }, [renderLeftIcon(), renderMarquee(), renderRightIcon()]), [[vShow, state.show]]);
  11974. };
  11975. }
  11976. });
  11977. const NoticeBar = withInstall(stdin_default$H);
  11978. const [name$y, bem$x] = createNamespace("notify");
  11979. const popupInheritProps = ["lockScroll", "position", "show", "teleport", "zIndex"];
  11980. const notifyProps = extend({}, popupSharedProps, {
  11981. type: makeStringProp("danger"),
  11982. color: String,
  11983. message: numericProp,
  11984. position: makeStringProp("top"),
  11985. className: unknownProp,
  11986. background: String,
  11987. lockScroll: Boolean
  11988. });
  11989. var stdin_default$G = defineComponent({
  11990. name: name$y,
  11991. props: notifyProps,
  11992. emits: ["update:show"],
  11993. setup(props2, {
  11994. emit,
  11995. slots
  11996. }) {
  11997. const updateShow = (show) => emit("update:show", show);
  11998. return () => createVNode(Popup, mergeProps({
  11999. "class": [bem$x([props2.type]), props2.className],
  12000. "style": {
  12001. color: props2.color,
  12002. background: props2.background
  12003. },
  12004. "overlay": false,
  12005. "duration": 0.2,
  12006. "onUpdate:show": updateShow
  12007. }, pick(props2, popupInheritProps)), {
  12008. default: () => [slots.default ? slots.default() : props2.message]
  12009. });
  12010. }
  12011. });
  12012. let timer;
  12013. let instance;
  12014. const parseOptions = (message) => isObject(message) ? message : {
  12015. message
  12016. };
  12017. function initInstance() {
  12018. ({
  12019. instance
  12020. } = mountComponent({
  12021. setup() {
  12022. const {
  12023. state,
  12024. toggle
  12025. } = usePopupState();
  12026. return () => createVNode(stdin_default$G, mergeProps(state, {
  12027. "onUpdate:show": toggle
  12028. }), null);
  12029. }
  12030. }));
  12031. }
  12032. const getDefaultOptions = () => ({
  12033. type: "danger",
  12034. color: void 0,
  12035. message: "",
  12036. onClose: void 0,
  12037. onClick: void 0,
  12038. onOpened: void 0,
  12039. duration: 3e3,
  12040. position: void 0,
  12041. className: "",
  12042. lockScroll: false,
  12043. background: void 0
  12044. });
  12045. let currentOptions = getDefaultOptions();
  12046. const closeNotify = () => {
  12047. if (instance) {
  12048. instance.toggle(false);
  12049. }
  12050. };
  12051. function showNotify(options) {
  12052. if (!inBrowser) {
  12053. return;
  12054. }
  12055. if (!instance) {
  12056. initInstance();
  12057. }
  12058. options = extend({}, currentOptions, parseOptions(options));
  12059. instance.open(options);
  12060. clearTimeout(timer);
  12061. if (options.duration > 0) {
  12062. timer = setTimeout(closeNotify, options.duration);
  12063. }
  12064. return instance;
  12065. }
  12066. const setNotifyDefaultOptions = (options) => extend(currentOptions, options);
  12067. const resetNotifyDefaultOptions = () => {
  12068. currentOptions = getDefaultOptions();
  12069. };
  12070. const Notify = withInstall(stdin_default$G);
  12071. const [name$x, bem$w] = createNamespace("key");
  12072. const CollapseIcon = createVNode("svg", {
  12073. "class": bem$w("collapse-icon"),
  12074. "viewBox": "0 0 30 24"
  12075. }, [createVNode("path", {
  12076. "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",
  12077. "fill": "currentColor"
  12078. }, null)]);
  12079. const DeleteIcon = createVNode("svg", {
  12080. "class": bem$w("delete-icon"),
  12081. "viewBox": "0 0 32 22"
  12082. }, [createVNode("path", {
  12083. "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",
  12084. "fill": "currentColor"
  12085. }, null)]);
  12086. var stdin_default$F = defineComponent({
  12087. name: name$x,
  12088. props: {
  12089. type: String,
  12090. text: numericProp,
  12091. color: String,
  12092. wider: Boolean,
  12093. large: Boolean,
  12094. loading: Boolean
  12095. },
  12096. emits: ["press"],
  12097. setup(props2, {
  12098. emit,
  12099. slots
  12100. }) {
  12101. const active = ref(false);
  12102. const touch = useTouch();
  12103. const onTouchStart = (event) => {
  12104. touch.start(event);
  12105. active.value = true;
  12106. };
  12107. const onTouchMove = (event) => {
  12108. touch.move(event);
  12109. if (touch.direction.value) {
  12110. active.value = false;
  12111. }
  12112. };
  12113. const onTouchEnd = (event) => {
  12114. if (active.value) {
  12115. if (!slots.default) {
  12116. preventDefault(event);
  12117. }
  12118. active.value = false;
  12119. emit("press", props2.text, props2.type);
  12120. }
  12121. };
  12122. const renderContent = () => {
  12123. if (props2.loading) {
  12124. return createVNode(Loading, {
  12125. "class": bem$w("loading-icon")
  12126. }, null);
  12127. }
  12128. const text = slots.default ? slots.default() : props2.text;
  12129. switch (props2.type) {
  12130. case "delete":
  12131. return text || DeleteIcon;
  12132. case "extra":
  12133. return text || CollapseIcon;
  12134. default:
  12135. return text;
  12136. }
  12137. };
  12138. return () => createVNode("div", {
  12139. "class": bem$w("wrapper", {
  12140. wider: props2.wider
  12141. }),
  12142. "onTouchstartPassive": onTouchStart,
  12143. "onTouchmovePassive": onTouchMove,
  12144. "onTouchend": onTouchEnd,
  12145. "onTouchcancel": onTouchEnd
  12146. }, [createVNode("div", {
  12147. "role": "button",
  12148. "tabindex": 0,
  12149. "class": bem$w([props2.color, {
  12150. large: props2.large,
  12151. active: active.value,
  12152. delete: props2.type === "delete"
  12153. }])
  12154. }, [renderContent()])]);
  12155. }
  12156. });
  12157. const [name$w, bem$v] = createNamespace("number-keyboard");
  12158. const numberKeyboardProps = {
  12159. show: Boolean,
  12160. title: String,
  12161. theme: makeStringProp("default"),
  12162. zIndex: numericProp,
  12163. teleport: [String, Object],
  12164. maxlength: makeNumericProp(Infinity),
  12165. modelValue: makeStringProp(""),
  12166. transition: truthProp,
  12167. blurOnClose: truthProp,
  12168. showDeleteKey: truthProp,
  12169. randomKeyOrder: Boolean,
  12170. closeButtonText: String,
  12171. deleteButtonText: String,
  12172. closeButtonLoading: Boolean,
  12173. hideOnClickOutside: truthProp,
  12174. safeAreaInsetBottom: truthProp,
  12175. extraKey: {
  12176. type: [String, Array],
  12177. default: ""
  12178. }
  12179. };
  12180. function shuffle(array) {
  12181. for (let i = array.length - 1; i > 0; i--) {
  12182. const j = Math.floor(Math.random() * (i + 1));
  12183. const temp = array[i];
  12184. array[i] = array[j];
  12185. array[j] = temp;
  12186. }
  12187. return array;
  12188. }
  12189. var stdin_default$E = defineComponent({
  12190. name: name$w,
  12191. inheritAttrs: false,
  12192. props: numberKeyboardProps,
  12193. emits: ["show", "hide", "blur", "input", "close", "delete", "update:modelValue"],
  12194. setup(props2, {
  12195. emit,
  12196. slots,
  12197. attrs
  12198. }) {
  12199. const root = ref();
  12200. const genBasicKeys = () => {
  12201. const keys2 = Array(9).fill("").map((_, i) => ({
  12202. text: i + 1
  12203. }));
  12204. if (props2.randomKeyOrder) {
  12205. shuffle(keys2);
  12206. }
  12207. return keys2;
  12208. };
  12209. const genDefaultKeys = () => [...genBasicKeys(), {
  12210. text: props2.extraKey,
  12211. type: "extra"
  12212. }, {
  12213. text: 0
  12214. }, {
  12215. text: props2.showDeleteKey ? props2.deleteButtonText : "",
  12216. type: props2.showDeleteKey ? "delete" : ""
  12217. }];
  12218. const genCustomKeys = () => {
  12219. const keys2 = genBasicKeys();
  12220. const {
  12221. extraKey
  12222. } = props2;
  12223. const extraKeys = Array.isArray(extraKey) ? extraKey : [extraKey];
  12224. if (extraKeys.length === 0) {
  12225. keys2.push({
  12226. text: 0,
  12227. wider: true
  12228. });
  12229. } else if (extraKeys.length === 1) {
  12230. keys2.push({
  12231. text: 0,
  12232. wider: true
  12233. }, {
  12234. text: extraKeys[0],
  12235. type: "extra"
  12236. });
  12237. } else if (extraKeys.length === 2) {
  12238. keys2.push({
  12239. text: extraKeys[0],
  12240. type: "extra"
  12241. }, {
  12242. text: 0
  12243. }, {
  12244. text: extraKeys[1],
  12245. type: "extra"
  12246. });
  12247. }
  12248. return keys2;
  12249. };
  12250. const keys = computed(() => props2.theme === "custom" ? genCustomKeys() : genDefaultKeys());
  12251. const onBlur = () => {
  12252. if (props2.show) {
  12253. emit("blur");
  12254. }
  12255. };
  12256. const onClose = () => {
  12257. emit("close");
  12258. if (props2.blurOnClose) {
  12259. onBlur();
  12260. }
  12261. };
  12262. const onAnimationEnd = () => emit(props2.show ? "show" : "hide");
  12263. const onPress = (text, type) => {
  12264. if (text === "") {
  12265. if (type === "extra") {
  12266. onBlur();
  12267. }
  12268. return;
  12269. }
  12270. const value = props2.modelValue;
  12271. if (type === "delete") {
  12272. emit("delete");
  12273. emit("update:modelValue", value.slice(0, value.length - 1));
  12274. } else if (type === "close") {
  12275. onClose();
  12276. } else if (value.length < +props2.maxlength) {
  12277. emit("input", text);
  12278. emit("update:modelValue", value + text);
  12279. }
  12280. };
  12281. const renderTitle = () => {
  12282. const {
  12283. title,
  12284. theme,
  12285. closeButtonText
  12286. } = props2;
  12287. const leftSlot = slots["title-left"];
  12288. const showClose = closeButtonText && theme === "default";
  12289. const showTitle = title || showClose || leftSlot;
  12290. if (!showTitle) {
  12291. return;
  12292. }
  12293. return createVNode("div", {
  12294. "class": bem$v("header")
  12295. }, [leftSlot && createVNode("span", {
  12296. "class": bem$v("title-left")
  12297. }, [leftSlot()]), title && createVNode("h2", {
  12298. "class": bem$v("title")
  12299. }, [title]), showClose && createVNode("button", {
  12300. "type": "button",
  12301. "class": [bem$v("close"), HAPTICS_FEEDBACK],
  12302. "onClick": onClose
  12303. }, [closeButtonText])]);
  12304. };
  12305. const renderKeys = () => keys.value.map((key) => {
  12306. const keySlots = {};
  12307. if (key.type === "delete") {
  12308. keySlots.default = slots.delete;
  12309. }
  12310. if (key.type === "extra") {
  12311. keySlots.default = slots["extra-key"];
  12312. }
  12313. return createVNode(stdin_default$F, {
  12314. "key": key.text,
  12315. "text": key.text,
  12316. "type": key.type,
  12317. "wider": key.wider,
  12318. "color": key.color,
  12319. "onPress": onPress
  12320. }, keySlots);
  12321. });
  12322. const renderSidebar = () => {
  12323. if (props2.theme === "custom") {
  12324. return createVNode("div", {
  12325. "class": bem$v("sidebar")
  12326. }, [props2.showDeleteKey && createVNode(stdin_default$F, {
  12327. "large": true,
  12328. "text": props2.deleteButtonText,
  12329. "type": "delete",
  12330. "onPress": onPress
  12331. }, {
  12332. default: slots.delete
  12333. }), createVNode(stdin_default$F, {
  12334. "large": true,
  12335. "text": props2.closeButtonText,
  12336. "type": "close",
  12337. "color": "blue",
  12338. "loading": props2.closeButtonLoading,
  12339. "onPress": onPress
  12340. }, null)]);
  12341. }
  12342. };
  12343. watch(() => props2.show, (value) => {
  12344. if (!props2.transition) {
  12345. emit(value ? "show" : "hide");
  12346. }
  12347. });
  12348. if (props2.hideOnClickOutside) {
  12349. useClickAway(root, onBlur, {
  12350. eventName: "touchstart"
  12351. });
  12352. }
  12353. return () => {
  12354. const Title = renderTitle();
  12355. const Content = createVNode(Transition, {
  12356. "name": props2.transition ? "van-slide-up" : ""
  12357. }, {
  12358. default: () => [withDirectives(createVNode("div", mergeProps({
  12359. "ref": root,
  12360. "style": getZIndexStyle(props2.zIndex),
  12361. "class": bem$v({
  12362. unfit: !props2.safeAreaInsetBottom,
  12363. "with-title": !!Title
  12364. }),
  12365. "onAnimationend": onAnimationEnd,
  12366. "onTouchstartPassive": stopPropagation
  12367. }, attrs), [Title, createVNode("div", {
  12368. "class": bem$v("body")
  12369. }, [createVNode("div", {
  12370. "class": bem$v("keys")
  12371. }, [renderKeys()]), renderSidebar()])]), [[vShow, props2.show]])]
  12372. });
  12373. if (props2.teleport) {
  12374. return createVNode(Teleport, {
  12375. "to": props2.teleport
  12376. }, {
  12377. default: () => [Content]
  12378. });
  12379. }
  12380. return Content;
  12381. };
  12382. }
  12383. });
  12384. const NumberKeyboard = withInstall(stdin_default$E);
  12385. const [name$v, bem$u, t$6] = createNamespace("pagination");
  12386. const makePage = (number, text, active) => ({
  12387. number,
  12388. text,
  12389. active
  12390. });
  12391. const paginationProps = {
  12392. mode: makeStringProp("multi"),
  12393. prevText: String,
  12394. nextText: String,
  12395. pageCount: makeNumericProp(0),
  12396. modelValue: makeNumberProp(0),
  12397. totalItems: makeNumericProp(0),
  12398. showPageSize: makeNumericProp(5),
  12399. itemsPerPage: makeNumericProp(10),
  12400. forceEllipses: Boolean,
  12401. showPrevButton: truthProp,
  12402. showNextButton: truthProp
  12403. };
  12404. var stdin_default$D = defineComponent({
  12405. name: name$v,
  12406. props: paginationProps,
  12407. emits: ["change", "update:modelValue"],
  12408. setup(props2, {
  12409. emit,
  12410. slots
  12411. }) {
  12412. const count = computed(() => {
  12413. const {
  12414. pageCount,
  12415. totalItems,
  12416. itemsPerPage
  12417. } = props2;
  12418. const count2 = +pageCount || Math.ceil(+totalItems / +itemsPerPage);
  12419. return Math.max(1, count2);
  12420. });
  12421. const pages = computed(() => {
  12422. const items = [];
  12423. const pageCount = count.value;
  12424. const showPageSize = +props2.showPageSize;
  12425. const {
  12426. modelValue,
  12427. forceEllipses
  12428. } = props2;
  12429. let startPage = 1;
  12430. let endPage = pageCount;
  12431. const isMaxSized = showPageSize < pageCount;
  12432. if (isMaxSized) {
  12433. startPage = Math.max(modelValue - Math.floor(showPageSize / 2), 1);
  12434. endPage = startPage + showPageSize - 1;
  12435. if (endPage > pageCount) {
  12436. endPage = pageCount;
  12437. startPage = endPage - showPageSize + 1;
  12438. }
  12439. }
  12440. for (let number = startPage; number <= endPage; number++) {
  12441. const page = makePage(number, number, number === modelValue);
  12442. items.push(page);
  12443. }
  12444. if (isMaxSized && showPageSize > 0 && forceEllipses) {
  12445. if (startPage > 1) {
  12446. const prevPages = makePage(startPage - 1, "...");
  12447. items.unshift(prevPages);
  12448. }
  12449. if (endPage < pageCount) {
  12450. const nextPages = makePage(endPage + 1, "...");
  12451. items.push(nextPages);
  12452. }
  12453. }
  12454. return items;
  12455. });
  12456. const updateModelValue = (value, emitChange) => {
  12457. value = clamp(value, 1, count.value);
  12458. if (props2.modelValue !== value) {
  12459. emit("update:modelValue", value);
  12460. if (emitChange) {
  12461. emit("change", value);
  12462. }
  12463. }
  12464. };
  12465. watchEffect(() => updateModelValue(props2.modelValue));
  12466. const renderDesc = () => createVNode("li", {
  12467. "class": bem$u("page-desc")
  12468. }, [slots.pageDesc ? slots.pageDesc() : `${props2.modelValue}/${count.value}`]);
  12469. const renderPrevButton = () => {
  12470. const {
  12471. mode,
  12472. modelValue,
  12473. showPrevButton
  12474. } = props2;
  12475. if (!showPrevButton) {
  12476. return;
  12477. }
  12478. const slot = slots["prev-text"];
  12479. const disabled = modelValue === 1;
  12480. return createVNode("li", {
  12481. "class": [bem$u("item", {
  12482. disabled,
  12483. border: mode === "simple",
  12484. prev: true
  12485. }), BORDER_SURROUND]
  12486. }, [createVNode("button", {
  12487. "type": "button",
  12488. "disabled": disabled,
  12489. "onClick": () => updateModelValue(modelValue - 1, true)
  12490. }, [slot ? slot() : props2.prevText || t$6("prev")])]);
  12491. };
  12492. const renderNextButton = () => {
  12493. const {
  12494. mode,
  12495. modelValue,
  12496. showNextButton
  12497. } = props2;
  12498. if (!showNextButton) {
  12499. return;
  12500. }
  12501. const slot = slots["next-text"];
  12502. const disabled = modelValue === count.value;
  12503. return createVNode("li", {
  12504. "class": [bem$u("item", {
  12505. disabled,
  12506. border: mode === "simple",
  12507. next: true
  12508. }), BORDER_SURROUND]
  12509. }, [createVNode("button", {
  12510. "type": "button",
  12511. "disabled": disabled,
  12512. "onClick": () => updateModelValue(modelValue + 1, true)
  12513. }, [slot ? slot() : props2.nextText || t$6("next")])]);
  12514. };
  12515. const renderPages = () => pages.value.map((page) => createVNode("li", {
  12516. "class": [bem$u("item", {
  12517. active: page.active,
  12518. page: true
  12519. }), BORDER_SURROUND]
  12520. }, [createVNode("button", {
  12521. "type": "button",
  12522. "aria-current": page.active || void 0,
  12523. "onClick": () => updateModelValue(page.number, true)
  12524. }, [slots.page ? slots.page(page) : page.text])]));
  12525. return () => createVNode("nav", {
  12526. "role": "navigation",
  12527. "class": bem$u()
  12528. }, [createVNode("ul", {
  12529. "class": bem$u("items")
  12530. }, [renderPrevButton(), props2.mode === "simple" ? renderDesc() : renderPages(), renderNextButton()])]);
  12531. }
  12532. });
  12533. const Pagination = withInstall(stdin_default$D);
  12534. const [name$u, bem$t] = createNamespace("password-input");
  12535. const passwordInputProps = {
  12536. info: String,
  12537. mask: truthProp,
  12538. value: makeStringProp(""),
  12539. gutter: numericProp,
  12540. length: makeNumericProp(6),
  12541. focused: Boolean,
  12542. errorInfo: String
  12543. };
  12544. var stdin_default$C = defineComponent({
  12545. name: name$u,
  12546. props: passwordInputProps,
  12547. emits: ["focus"],
  12548. setup(props2, {
  12549. emit
  12550. }) {
  12551. const onTouchStart = (event) => {
  12552. event.stopPropagation();
  12553. emit("focus", event);
  12554. };
  12555. const renderPoints = () => {
  12556. const Points = [];
  12557. const {
  12558. mask,
  12559. value,
  12560. gutter,
  12561. focused
  12562. } = props2;
  12563. const length = +props2.length;
  12564. for (let i = 0; i < length; i++) {
  12565. const char = value[i];
  12566. const showBorder = i !== 0 && !gutter;
  12567. const showCursor = focused && i === value.length;
  12568. let style;
  12569. if (i !== 0 && gutter) {
  12570. style = {
  12571. marginLeft: addUnit(gutter)
  12572. };
  12573. }
  12574. Points.push(createVNode("li", {
  12575. "class": [{
  12576. [BORDER_LEFT]: showBorder
  12577. }, bem$t("item", {
  12578. focus: showCursor
  12579. })],
  12580. "style": style
  12581. }, [mask ? createVNode("i", {
  12582. "style": {
  12583. visibility: char ? "visible" : "hidden"
  12584. }
  12585. }, null) : char, showCursor && createVNode("div", {
  12586. "class": bem$t("cursor")
  12587. }, null)]));
  12588. }
  12589. return Points;
  12590. };
  12591. return () => {
  12592. const info = props2.errorInfo || props2.info;
  12593. return createVNode("div", {
  12594. "class": bem$t()
  12595. }, [createVNode("ul", {
  12596. "class": [bem$t("security"), {
  12597. [BORDER_SURROUND]: !props2.gutter
  12598. }],
  12599. "onTouchstartPassive": onTouchStart
  12600. }, [renderPoints()]), info && createVNode("div", {
  12601. "class": bem$t(props2.errorInfo ? "error-info" : "info")
  12602. }, [info])]);
  12603. };
  12604. }
  12605. });
  12606. const PasswordInput = withInstall(stdin_default$C);
  12607. const PickerGroup = withInstall(stdin_default$1A);
  12608. const [name$t, bem$s] = createNamespace("popover");
  12609. const popupProps = ["overlay", "duration", "teleport", "overlayStyle", "overlayClass", "closeOnClickOverlay"];
  12610. const popoverProps = {
  12611. show: Boolean,
  12612. theme: makeStringProp("light"),
  12613. overlay: Boolean,
  12614. actions: makeArrayProp(),
  12615. actionsDirection: makeStringProp("vertical"),
  12616. trigger: makeStringProp("click"),
  12617. duration: numericProp,
  12618. showArrow: truthProp,
  12619. placement: makeStringProp("bottom"),
  12620. iconPrefix: String,
  12621. overlayClass: unknownProp,
  12622. overlayStyle: Object,
  12623. closeOnClickAction: truthProp,
  12624. closeOnClickOverlay: truthProp,
  12625. closeOnClickOutside: truthProp,
  12626. offset: {
  12627. type: Array,
  12628. default: () => [0, 8]
  12629. },
  12630. teleport: {
  12631. type: [String, Object],
  12632. default: "body"
  12633. }
  12634. };
  12635. var stdin_default$B = defineComponent({
  12636. name: name$t,
  12637. props: popoverProps,
  12638. emits: ["select", "touchstart", "update:show"],
  12639. setup(props2, {
  12640. emit,
  12641. slots,
  12642. attrs
  12643. }) {
  12644. let popper;
  12645. const popupRef = ref();
  12646. const wrapperRef = ref();
  12647. const popoverRef = ref();
  12648. const show = useSyncPropRef(() => props2.show, (value) => emit("update:show", value));
  12649. const getPopoverOptions = () => ({
  12650. placement: props2.placement,
  12651. modifiers: [{
  12652. name: "computeStyles",
  12653. options: {
  12654. adaptive: false,
  12655. gpuAcceleration: false
  12656. }
  12657. }, extend({}, offsetModifier, {
  12658. options: {
  12659. offset: props2.offset
  12660. }
  12661. })]
  12662. });
  12663. const createPopperInstance = () => {
  12664. if (wrapperRef.value && popoverRef.value) {
  12665. return createPopper(wrapperRef.value, popoverRef.value.popupRef.value, getPopoverOptions());
  12666. }
  12667. return null;
  12668. };
  12669. const updateLocation = () => {
  12670. nextTick(() => {
  12671. if (!show.value) {
  12672. return;
  12673. }
  12674. if (!popper) {
  12675. popper = createPopperInstance();
  12676. if (inBrowser) {
  12677. window.addEventListener("animationend", updateLocation);
  12678. window.addEventListener("transitionend", updateLocation);
  12679. }
  12680. } else {
  12681. popper.setOptions(getPopoverOptions());
  12682. }
  12683. });
  12684. };
  12685. const updateShow = (value) => {
  12686. show.value = value;
  12687. };
  12688. const onClickWrapper = () => {
  12689. if (props2.trigger === "click") {
  12690. show.value = !show.value;
  12691. }
  12692. };
  12693. const onClickAction = (action, index) => {
  12694. if (action.disabled) {
  12695. return;
  12696. }
  12697. emit("select", action, index);
  12698. if (props2.closeOnClickAction) {
  12699. show.value = false;
  12700. }
  12701. };
  12702. const onClickAway = () => {
  12703. if (show.value && props2.closeOnClickOutside && (!props2.overlay || props2.closeOnClickOverlay)) {
  12704. show.value = false;
  12705. }
  12706. };
  12707. const renderActionContent = (action, index) => {
  12708. if (slots.action) {
  12709. return slots.action({
  12710. action,
  12711. index
  12712. });
  12713. }
  12714. return [action.icon && createVNode(Icon, {
  12715. "name": action.icon,
  12716. "classPrefix": props2.iconPrefix,
  12717. "class": bem$s("action-icon")
  12718. }, null), createVNode("div", {
  12719. "class": [bem$s("action-text"), {
  12720. [BORDER_BOTTOM]: props2.actionsDirection === "vertical"
  12721. }]
  12722. }, [action.text])];
  12723. };
  12724. const renderAction = (action, index) => {
  12725. const {
  12726. icon,
  12727. color,
  12728. disabled,
  12729. className
  12730. } = action;
  12731. return createVNode("div", {
  12732. "role": "menuitem",
  12733. "class": [bem$s("action", {
  12734. disabled,
  12735. "with-icon": icon
  12736. }), {
  12737. [BORDER_RIGHT]: props2.actionsDirection === "horizontal"
  12738. }, className],
  12739. "style": {
  12740. color
  12741. },
  12742. "tabindex": disabled ? void 0 : 0,
  12743. "aria-disabled": disabled || void 0,
  12744. "onClick": () => onClickAction(action, index)
  12745. }, [renderActionContent(action, index)]);
  12746. };
  12747. onMounted(() => {
  12748. updateLocation();
  12749. watchEffect(() => {
  12750. var _a;
  12751. popupRef.value = (_a = popoverRef.value) == null ? void 0 : _a.popupRef.value;
  12752. });
  12753. });
  12754. onBeforeUnmount(() => {
  12755. if (popper) {
  12756. if (inBrowser) {
  12757. window.removeEventListener("animationend", updateLocation);
  12758. window.removeEventListener("transitionend", updateLocation);
  12759. }
  12760. popper.destroy();
  12761. popper = null;
  12762. }
  12763. });
  12764. watch(() => [show.value, props2.offset, props2.placement], updateLocation);
  12765. useClickAway([wrapperRef, popupRef], onClickAway, {
  12766. eventName: "touchstart"
  12767. });
  12768. return () => {
  12769. var _a;
  12770. return createVNode(Fragment, null, [createVNode("span", {
  12771. "ref": wrapperRef,
  12772. "class": bem$s("wrapper"),
  12773. "onClick": onClickWrapper
  12774. }, [(_a = slots.reference) == null ? void 0 : _a.call(slots)]), createVNode(Popup, mergeProps({
  12775. "ref": popoverRef,
  12776. "show": show.value,
  12777. "class": bem$s([props2.theme]),
  12778. "position": "",
  12779. "transition": "van-popover-zoom",
  12780. "lockScroll": false,
  12781. "onUpdate:show": updateShow
  12782. }, attrs, useScopeId(), pick(props2, popupProps)), {
  12783. default: () => [props2.showArrow && createVNode("div", {
  12784. "class": bem$s("arrow")
  12785. }, null), createVNode("div", {
  12786. "role": "menu",
  12787. "class": bem$s("content", props2.actionsDirection)
  12788. }, [slots.default ? slots.default() : props2.actions.map(renderAction)])]
  12789. })]);
  12790. };
  12791. }
  12792. });
  12793. const Popover = withInstall(stdin_default$B);
  12794. const [name$s, bem$r] = createNamespace("progress");
  12795. const progressProps = {
  12796. color: String,
  12797. inactive: Boolean,
  12798. pivotText: String,
  12799. textColor: String,
  12800. showPivot: truthProp,
  12801. pivotColor: String,
  12802. trackColor: String,
  12803. strokeWidth: numericProp,
  12804. percentage: {
  12805. type: numericProp,
  12806. default: 0,
  12807. validator: (value) => +value >= 0 && +value <= 100
  12808. }
  12809. };
  12810. var stdin_default$A = defineComponent({
  12811. name: name$s,
  12812. props: progressProps,
  12813. setup(props2) {
  12814. const background = computed(() => props2.inactive ? void 0 : props2.color);
  12815. const renderPivot = () => {
  12816. const {
  12817. textColor,
  12818. pivotText,
  12819. pivotColor,
  12820. percentage
  12821. } = props2;
  12822. const text = pivotText != null ? pivotText : `${percentage}%`;
  12823. if (props2.showPivot && text) {
  12824. const style = {
  12825. color: textColor,
  12826. left: `${+percentage}%`,
  12827. transform: `translate(-${+percentage}%,-50%)`,
  12828. background: pivotColor || background.value
  12829. };
  12830. return createVNode("span", {
  12831. "style": style,
  12832. "class": bem$r("pivot", {
  12833. inactive: props2.inactive
  12834. })
  12835. }, [text]);
  12836. }
  12837. };
  12838. return () => {
  12839. const {
  12840. trackColor,
  12841. percentage,
  12842. strokeWidth
  12843. } = props2;
  12844. const rootStyle = {
  12845. background: trackColor,
  12846. height: addUnit(strokeWidth)
  12847. };
  12848. const portionStyle = {
  12849. width: `${percentage}%`,
  12850. background: background.value
  12851. };
  12852. return createVNode("div", {
  12853. "class": bem$r(),
  12854. "style": rootStyle
  12855. }, [createVNode("span", {
  12856. "class": bem$r("portion", {
  12857. inactive: props2.inactive
  12858. }),
  12859. "style": portionStyle
  12860. }, null), renderPivot()]);
  12861. };
  12862. }
  12863. });
  12864. const Progress = withInstall(stdin_default$A);
  12865. const [name$r, bem$q, t$5] = createNamespace("pull-refresh");
  12866. const DEFAULT_HEAD_HEIGHT = 50;
  12867. const TEXT_STATUS = ["pulling", "loosing", "success"];
  12868. const pullRefreshProps = {
  12869. disabled: Boolean,
  12870. modelValue: Boolean,
  12871. headHeight: makeNumericProp(DEFAULT_HEAD_HEIGHT),
  12872. successText: String,
  12873. pullingText: String,
  12874. loosingText: String,
  12875. loadingText: String,
  12876. pullDistance: numericProp,
  12877. successDuration: makeNumericProp(500),
  12878. animationDuration: makeNumericProp(300)
  12879. };
  12880. var stdin_default$z = defineComponent({
  12881. name: name$r,
  12882. props: pullRefreshProps,
  12883. emits: ["change", "refresh", "update:modelValue"],
  12884. setup(props2, {
  12885. emit,
  12886. slots
  12887. }) {
  12888. let reachTop;
  12889. const root = ref();
  12890. const track = ref();
  12891. const scrollParent = useScrollParent(root);
  12892. const state = reactive({
  12893. status: "normal",
  12894. distance: 0,
  12895. duration: 0
  12896. });
  12897. const touch = useTouch();
  12898. const getHeadStyle = () => {
  12899. if (props2.headHeight !== DEFAULT_HEAD_HEIGHT) {
  12900. return {
  12901. height: `${props2.headHeight}px`
  12902. };
  12903. }
  12904. };
  12905. const isTouchable = () => state.status !== "loading" && state.status !== "success" && !props2.disabled;
  12906. const ease = (distance) => {
  12907. const pullDistance = +(props2.pullDistance || props2.headHeight);
  12908. if (distance > pullDistance) {
  12909. if (distance < pullDistance * 2) {
  12910. distance = pullDistance + (distance - pullDistance) / 2;
  12911. } else {
  12912. distance = pullDistance * 1.5 + (distance - pullDistance * 2) / 4;
  12913. }
  12914. }
  12915. return Math.round(distance);
  12916. };
  12917. const setStatus = (distance, isLoading) => {
  12918. const pullDistance = +(props2.pullDistance || props2.headHeight);
  12919. state.distance = distance;
  12920. if (isLoading) {
  12921. state.status = "loading";
  12922. } else if (distance === 0) {
  12923. state.status = "normal";
  12924. } else if (distance < pullDistance) {
  12925. state.status = "pulling";
  12926. } else {
  12927. state.status = "loosing";
  12928. }
  12929. emit("change", {
  12930. status: state.status,
  12931. distance
  12932. });
  12933. };
  12934. const getStatusText = () => {
  12935. const {
  12936. status
  12937. } = state;
  12938. if (status === "normal") {
  12939. return "";
  12940. }
  12941. return props2[`${status}Text`] || t$5(status);
  12942. };
  12943. const renderStatus = () => {
  12944. const {
  12945. status,
  12946. distance
  12947. } = state;
  12948. if (slots[status]) {
  12949. return slots[status]({
  12950. distance
  12951. });
  12952. }
  12953. const nodes = [];
  12954. if (TEXT_STATUS.includes(status)) {
  12955. nodes.push(createVNode("div", {
  12956. "class": bem$q("text")
  12957. }, [getStatusText()]));
  12958. }
  12959. if (status === "loading") {
  12960. nodes.push(createVNode(Loading, {
  12961. "class": bem$q("loading")
  12962. }, {
  12963. default: getStatusText
  12964. }));
  12965. }
  12966. return nodes;
  12967. };
  12968. const showSuccessTip = () => {
  12969. state.status = "success";
  12970. setTimeout(() => {
  12971. setStatus(0);
  12972. }, +props2.successDuration);
  12973. };
  12974. const checkPosition = (event) => {
  12975. reachTop = getScrollTop(scrollParent.value) === 0;
  12976. if (reachTop) {
  12977. state.duration = 0;
  12978. touch.start(event);
  12979. }
  12980. };
  12981. const onTouchStart = (event) => {
  12982. if (isTouchable()) {
  12983. checkPosition(event);
  12984. }
  12985. };
  12986. const onTouchMove = (event) => {
  12987. if (isTouchable()) {
  12988. if (!reachTop) {
  12989. checkPosition(event);
  12990. }
  12991. const {
  12992. deltaY
  12993. } = touch;
  12994. touch.move(event);
  12995. if (reachTop && deltaY.value >= 0 && touch.isVertical()) {
  12996. preventDefault(event);
  12997. setStatus(ease(deltaY.value));
  12998. }
  12999. }
  13000. };
  13001. const onTouchEnd = () => {
  13002. if (reachTop && touch.deltaY.value && isTouchable()) {
  13003. state.duration = +props2.animationDuration;
  13004. if (state.status === "loosing") {
  13005. setStatus(+props2.headHeight, true);
  13006. emit("update:modelValue", true);
  13007. nextTick(() => emit("refresh"));
  13008. } else {
  13009. setStatus(0);
  13010. }
  13011. }
  13012. };
  13013. watch(() => props2.modelValue, (value) => {
  13014. state.duration = +props2.animationDuration;
  13015. if (value) {
  13016. setStatus(+props2.headHeight, true);
  13017. } else if (slots.success || props2.successText) {
  13018. showSuccessTip();
  13019. } else {
  13020. setStatus(0, false);
  13021. }
  13022. });
  13023. useEventListener("touchmove", onTouchMove, {
  13024. target: track
  13025. });
  13026. return () => {
  13027. var _a;
  13028. const trackStyle = {
  13029. transitionDuration: `${state.duration}ms`,
  13030. transform: state.distance ? `translate3d(0,${state.distance}px, 0)` : ""
  13031. };
  13032. return createVNode("div", {
  13033. "ref": root,
  13034. "class": bem$q()
  13035. }, [createVNode("div", {
  13036. "ref": track,
  13037. "class": bem$q("track"),
  13038. "style": trackStyle,
  13039. "onTouchstartPassive": onTouchStart,
  13040. "onTouchend": onTouchEnd,
  13041. "onTouchcancel": onTouchEnd
  13042. }, [createVNode("div", {
  13043. "class": bem$q("head"),
  13044. "style": getHeadStyle()
  13045. }, [renderStatus()]), (_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  13046. };
  13047. }
  13048. });
  13049. const PullRefresh = withInstall(stdin_default$z);
  13050. const [name$q, bem$p] = createNamespace("rate");
  13051. function getRateStatus(value, index, allowHalf, readonly) {
  13052. if (value >= index) {
  13053. return {
  13054. status: "full",
  13055. value: 1
  13056. };
  13057. }
  13058. if (value + 0.5 >= index && allowHalf && !readonly) {
  13059. return {
  13060. status: "half",
  13061. value: 0.5
  13062. };
  13063. }
  13064. if (value + 1 >= index && allowHalf && readonly) {
  13065. const cardinal = 10 ** 10;
  13066. return {
  13067. status: "half",
  13068. value: Math.round((value - index + 1) * cardinal) / cardinal
  13069. };
  13070. }
  13071. return {
  13072. status: "void",
  13073. value: 0
  13074. };
  13075. }
  13076. const rateProps = {
  13077. size: numericProp,
  13078. icon: makeStringProp("star"),
  13079. color: String,
  13080. count: makeNumericProp(5),
  13081. gutter: numericProp,
  13082. clearable: Boolean,
  13083. readonly: Boolean,
  13084. disabled: Boolean,
  13085. voidIcon: makeStringProp("star-o"),
  13086. allowHalf: Boolean,
  13087. voidColor: String,
  13088. touchable: truthProp,
  13089. iconPrefix: String,
  13090. modelValue: makeNumberProp(0),
  13091. disabledColor: String
  13092. };
  13093. var stdin_default$y = defineComponent({
  13094. name: name$q,
  13095. props: rateProps,
  13096. emits: ["change", "update:modelValue"],
  13097. setup(props2, {
  13098. emit
  13099. }) {
  13100. const touch = useTouch();
  13101. const [itemRefs, setItemRefs] = useRefs();
  13102. const groupRef = ref();
  13103. const unselectable = computed(() => props2.readonly || props2.disabled);
  13104. const untouchable = computed(() => unselectable.value || !props2.touchable);
  13105. const list = computed(() => Array(+props2.count).fill("").map((_, i) => getRateStatus(props2.modelValue, i + 1, props2.allowHalf, props2.readonly)));
  13106. let ranges;
  13107. let groupRefRect;
  13108. let minRectTop = Number.MAX_SAFE_INTEGER;
  13109. let maxRectTop = Number.MIN_SAFE_INTEGER;
  13110. const updateRanges = () => {
  13111. groupRefRect = useRect(groupRef);
  13112. const rects = itemRefs.value.map(useRect);
  13113. ranges = [];
  13114. rects.forEach((rect, index) => {
  13115. minRectTop = Math.min(rect.top, minRectTop);
  13116. maxRectTop = Math.max(rect.top, maxRectTop);
  13117. if (props2.allowHalf) {
  13118. ranges.push({
  13119. score: index + 0.5,
  13120. left: rect.left,
  13121. top: rect.top,
  13122. height: rect.height
  13123. }, {
  13124. score: index + 1,
  13125. left: rect.left + rect.width / 2,
  13126. top: rect.top,
  13127. height: rect.height
  13128. });
  13129. } else {
  13130. ranges.push({
  13131. score: index + 1,
  13132. left: rect.left,
  13133. top: rect.top,
  13134. height: rect.height
  13135. });
  13136. }
  13137. });
  13138. };
  13139. const getScoreByPosition = (x, y) => {
  13140. for (let i = ranges.length - 1; i > 0; i--) {
  13141. if (y >= groupRefRect.top && y <= groupRefRect.bottom) {
  13142. if (x > ranges[i].left && y >= ranges[i].top && y <= ranges[i].top + ranges[i].height) {
  13143. return ranges[i].score;
  13144. }
  13145. } else {
  13146. const curTop = y < groupRefRect.top ? minRectTop : maxRectTop;
  13147. if (x > ranges[i].left && ranges[i].top === curTop) {
  13148. return ranges[i].score;
  13149. }
  13150. }
  13151. }
  13152. return props2.allowHalf ? 0.5 : 1;
  13153. };
  13154. const select = (value) => {
  13155. if (unselectable.value || value === props2.modelValue) return;
  13156. emit("update:modelValue", value);
  13157. emit("change", value);
  13158. };
  13159. const onTouchStart = (event) => {
  13160. if (untouchable.value) {
  13161. return;
  13162. }
  13163. touch.start(event);
  13164. updateRanges();
  13165. };
  13166. const onTouchMove = (event) => {
  13167. if (untouchable.value) {
  13168. return;
  13169. }
  13170. touch.move(event);
  13171. if (touch.isHorizontal() && !touch.isTap.value) {
  13172. const {
  13173. clientX,
  13174. clientY
  13175. } = event.touches[0];
  13176. preventDefault(event);
  13177. select(getScoreByPosition(clientX, clientY));
  13178. }
  13179. };
  13180. const renderStar = (item, index) => {
  13181. const {
  13182. icon,
  13183. size,
  13184. color,
  13185. count,
  13186. gutter,
  13187. voidIcon,
  13188. disabled,
  13189. voidColor,
  13190. allowHalf,
  13191. iconPrefix,
  13192. disabledColor
  13193. } = props2;
  13194. const score = index + 1;
  13195. const isFull = item.status === "full";
  13196. const isVoid = item.status === "void";
  13197. const renderHalf = allowHalf && item.value > 0 && item.value < 1;
  13198. let style;
  13199. if (gutter && score !== +count) {
  13200. style = {
  13201. paddingRight: addUnit(gutter)
  13202. };
  13203. }
  13204. const onClickItem = (event) => {
  13205. updateRanges();
  13206. let value = allowHalf ? getScoreByPosition(event.clientX, event.clientY) : score;
  13207. if (props2.clearable && touch.isTap.value && value === props2.modelValue) {
  13208. value = 0;
  13209. }
  13210. select(value);
  13211. };
  13212. return createVNode("div", {
  13213. "key": index,
  13214. "ref": setItemRefs(index),
  13215. "role": "radio",
  13216. "style": style,
  13217. "class": bem$p("item"),
  13218. "tabindex": disabled ? void 0 : 0,
  13219. "aria-setsize": count,
  13220. "aria-posinset": score,
  13221. "aria-checked": !isVoid,
  13222. "onClick": onClickItem
  13223. }, [createVNode(Icon, {
  13224. "size": size,
  13225. "name": isFull ? icon : voidIcon,
  13226. "class": bem$p("icon", {
  13227. disabled,
  13228. full: isFull
  13229. }),
  13230. "color": disabled ? disabledColor : isFull ? color : voidColor,
  13231. "classPrefix": iconPrefix
  13232. }, null), renderHalf && createVNode(Icon, {
  13233. "size": size,
  13234. "style": {
  13235. width: item.value + "em"
  13236. },
  13237. "name": isVoid ? voidIcon : icon,
  13238. "class": bem$p("icon", ["half", {
  13239. disabled,
  13240. full: !isVoid
  13241. }]),
  13242. "color": disabled ? disabledColor : isVoid ? voidColor : color,
  13243. "classPrefix": iconPrefix
  13244. }, null)]);
  13245. };
  13246. useCustomFieldValue(() => props2.modelValue);
  13247. useEventListener("touchmove", onTouchMove, {
  13248. target: groupRef
  13249. });
  13250. return () => createVNode("div", {
  13251. "ref": groupRef,
  13252. "role": "radiogroup",
  13253. "class": bem$p({
  13254. readonly: props2.readonly,
  13255. disabled: props2.disabled
  13256. }),
  13257. "tabindex": props2.disabled ? void 0 : 0,
  13258. "aria-disabled": props2.disabled,
  13259. "aria-readonly": props2.readonly,
  13260. "onTouchstartPassive": onTouchStart
  13261. }, [list.value.map(renderStar)]);
  13262. }
  13263. });
  13264. const Rate = withInstall(stdin_default$y);
  13265. const props = {
  13266. figureArr: makeArrayProp(),
  13267. delay: Number,
  13268. duration: makeNumberProp(2),
  13269. isStart: Boolean,
  13270. direction: makeStringProp("down"),
  13271. height: makeNumberProp(40)
  13272. };
  13273. const [name$p, bem$o] = createNamespace("rolling-text-item");
  13274. var stdin_default$x = defineComponent({
  13275. name: name$p,
  13276. props,
  13277. setup(props2) {
  13278. const newFigureArr = computed(() => props2.direction === "down" ? props2.figureArr.slice().reverse() : props2.figureArr);
  13279. const translatePx = computed(() => {
  13280. const totalHeight = props2.height * (props2.figureArr.length - 1);
  13281. return `-${totalHeight}px`;
  13282. });
  13283. const itemStyle = computed(() => ({
  13284. lineHeight: addUnit(props2.height)
  13285. }));
  13286. const rootStyle = computed(() => ({
  13287. height: addUnit(props2.height),
  13288. "--van-translate": translatePx.value,
  13289. "--van-duration": props2.duration + "s",
  13290. "--van-delay": props2.delay + "s"
  13291. }));
  13292. return () => createVNode("div", {
  13293. "class": bem$o([props2.direction]),
  13294. "style": rootStyle.value
  13295. }, [createVNode("div", {
  13296. "class": bem$o("box", {
  13297. animate: props2.isStart
  13298. })
  13299. }, [Array.isArray(newFigureArr.value) && newFigureArr.value.map((figure) => createVNode("div", {
  13300. "class": bem$o("item"),
  13301. "style": itemStyle.value
  13302. }, [figure]))])]);
  13303. }
  13304. });
  13305. const [name$o, bem$n] = createNamespace("rolling-text");
  13306. const rollingTextProps = {
  13307. startNum: makeNumberProp(0),
  13308. targetNum: Number,
  13309. textList: makeArrayProp(),
  13310. duration: makeNumberProp(2),
  13311. autoStart: truthProp,
  13312. direction: makeStringProp("down"),
  13313. stopOrder: makeStringProp("ltr"),
  13314. height: makeNumberProp(40)
  13315. };
  13316. const CIRCLE_NUM = 2;
  13317. var stdin_default$w = defineComponent({
  13318. name: name$o,
  13319. props: rollingTextProps,
  13320. setup(props2) {
  13321. const isCustomType = computed(() => Array.isArray(props2.textList) && props2.textList.length);
  13322. const itemLength = computed(() => {
  13323. if (isCustomType.value) return props2.textList[0].length;
  13324. return `${Math.max(props2.startNum, props2.targetNum)}`.length;
  13325. });
  13326. const getTextArrByIdx = (idx) => {
  13327. const result = [];
  13328. for (let i = 0; i < props2.textList.length; i++) {
  13329. result.push(props2.textList[i][idx]);
  13330. }
  13331. return result;
  13332. };
  13333. const targetNumArr = computed(() => {
  13334. if (isCustomType.value) return new Array(itemLength.value).fill("");
  13335. return padZero(props2.targetNum, itemLength.value).split("");
  13336. });
  13337. const startNumArr = computed(() => padZero(props2.startNum, itemLength.value).split(""));
  13338. const getFigureArr = (i) => {
  13339. const start2 = +startNumArr.value[i];
  13340. const target = +targetNumArr.value[i];
  13341. const result = [];
  13342. for (let i2 = start2; i2 <= 9; i2++) {
  13343. result.push(i2);
  13344. }
  13345. for (let i2 = 0; i2 <= CIRCLE_NUM; i2++) {
  13346. for (let j = 0; j <= 9; j++) {
  13347. result.push(j);
  13348. }
  13349. }
  13350. for (let i2 = 0; i2 <= target; i2++) {
  13351. result.push(i2);
  13352. }
  13353. return result;
  13354. };
  13355. const getDelay = (i, len) => {
  13356. if (props2.stopOrder === "ltr") return 0.2 * i;
  13357. return 0.2 * (len - 1 - i);
  13358. };
  13359. const rolling = ref(props2.autoStart);
  13360. const start = () => {
  13361. rolling.value = true;
  13362. };
  13363. const reset = () => {
  13364. rolling.value = false;
  13365. if (props2.autoStart) {
  13366. raf(() => start());
  13367. }
  13368. };
  13369. watch(() => props2.autoStart, (value) => {
  13370. if (value) {
  13371. start();
  13372. }
  13373. });
  13374. useExpose({
  13375. start,
  13376. reset
  13377. });
  13378. return () => createVNode("div", {
  13379. "class": bem$n()
  13380. }, [targetNumArr.value.map((_, i) => createVNode(stdin_default$x, {
  13381. "figureArr": isCustomType.value ? getTextArrByIdx(i) : getFigureArr(i),
  13382. "duration": props2.duration,
  13383. "direction": props2.direction,
  13384. "isStart": rolling.value,
  13385. "height": props2.height,
  13386. "delay": getDelay(i, itemLength.value)
  13387. }, null))]);
  13388. }
  13389. });
  13390. const RollingText = withInstall(stdin_default$w);
  13391. const Row = withInstall(stdin_default$17);
  13392. const [name$n, bem$m, t$4] = createNamespace("search");
  13393. const searchProps = extend({}, fieldSharedProps, {
  13394. label: String,
  13395. shape: makeStringProp("square"),
  13396. leftIcon: makeStringProp("search"),
  13397. clearable: truthProp,
  13398. actionText: String,
  13399. background: String,
  13400. showAction: Boolean
  13401. });
  13402. var stdin_default$v = defineComponent({
  13403. name: name$n,
  13404. props: searchProps,
  13405. emits: ["blur", "focus", "clear", "search", "cancel", "clickInput", "clickLeftIcon", "clickRightIcon", "update:modelValue"],
  13406. setup(props2, {
  13407. emit,
  13408. slots,
  13409. attrs
  13410. }) {
  13411. const id = useId();
  13412. const fieldRef = ref();
  13413. const onCancel = () => {
  13414. if (!slots.action) {
  13415. emit("update:modelValue", "");
  13416. emit("cancel");
  13417. }
  13418. };
  13419. const onKeypress = (event) => {
  13420. const ENTER_CODE = 13;
  13421. if (event.keyCode === ENTER_CODE) {
  13422. preventDefault(event);
  13423. emit("search", props2.modelValue);
  13424. }
  13425. };
  13426. const getInputId = () => props2.id || `${id}-input`;
  13427. const renderLabel = () => {
  13428. if (slots.label || props2.label) {
  13429. return createVNode("label", {
  13430. "class": bem$m("label"),
  13431. "for": getInputId(),
  13432. "data-allow-mismatch": "attribute"
  13433. }, [slots.label ? slots.label() : props2.label]);
  13434. }
  13435. };
  13436. const renderAction = () => {
  13437. if (props2.showAction) {
  13438. const text = props2.actionText || t$4("cancel");
  13439. return createVNode("div", {
  13440. "class": bem$m("action"),
  13441. "role": "button",
  13442. "tabindex": 0,
  13443. "onClick": onCancel
  13444. }, [slots.action ? slots.action() : text]);
  13445. }
  13446. };
  13447. const blur = () => {
  13448. var _a;
  13449. return (_a = fieldRef.value) == null ? void 0 : _a.blur();
  13450. };
  13451. const focus = () => {
  13452. var _a;
  13453. return (_a = fieldRef.value) == null ? void 0 : _a.focus();
  13454. };
  13455. const onBlur = (event) => emit("blur", event);
  13456. const onFocus = (event) => emit("focus", event);
  13457. const onClear = (event) => emit("clear", event);
  13458. const onClickInput = (event) => emit("clickInput", event);
  13459. const onClickLeftIcon = (event) => emit("clickLeftIcon", event);
  13460. const onClickRightIcon = (event) => emit("clickRightIcon", event);
  13461. const fieldPropNames = Object.keys(fieldSharedProps);
  13462. const renderField = () => {
  13463. const fieldAttrs = extend({}, attrs, pick(props2, fieldPropNames), {
  13464. id: getInputId()
  13465. });
  13466. const onInput = (value) => emit("update:modelValue", value);
  13467. return createVNode(Field, mergeProps({
  13468. "ref": fieldRef,
  13469. "type": "search",
  13470. "class": bem$m("field", {
  13471. "with-message": fieldAttrs.errorMessage
  13472. }),
  13473. "border": false,
  13474. "onBlur": onBlur,
  13475. "onFocus": onFocus,
  13476. "onClear": onClear,
  13477. "onKeypress": onKeypress,
  13478. "onClickInput": onClickInput,
  13479. "onClickLeftIcon": onClickLeftIcon,
  13480. "onClickRightIcon": onClickRightIcon,
  13481. "onUpdate:modelValue": onInput
  13482. }, fieldAttrs), pick(slots, ["left-icon", "right-icon"]));
  13483. };
  13484. useExpose({
  13485. focus,
  13486. blur
  13487. });
  13488. return () => {
  13489. var _a;
  13490. return createVNode("div", {
  13491. "class": bem$m({
  13492. "show-action": props2.showAction
  13493. }),
  13494. "style": {
  13495. background: props2.background
  13496. }
  13497. }, [(_a = slots.left) == null ? void 0 : _a.call(slots), createVNode("div", {
  13498. "class": bem$m("content", props2.shape)
  13499. }, [renderLabel(), renderField()]), renderAction()]);
  13500. };
  13501. }
  13502. });
  13503. const Search = withInstall(stdin_default$v);
  13504. const isImage = (name2) => name2 == null ? void 0 : name2.includes("/");
  13505. const popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
  13506. const iconMap = {
  13507. qq: "qq",
  13508. link: "link-o",
  13509. weibo: "weibo",
  13510. qrcode: "qr",
  13511. poster: "photo-o",
  13512. wechat: "wechat",
  13513. "weapp-qrcode": "miniprogram-o",
  13514. "wechat-moments": "wechat-moments"
  13515. };
  13516. const [name$m, bem$l, t$3] = createNamespace("share-sheet");
  13517. const shareSheetProps = extend({}, popupSharedProps, {
  13518. title: String,
  13519. round: truthProp,
  13520. options: makeArrayProp(),
  13521. cancelText: String,
  13522. description: String,
  13523. closeOnPopstate: truthProp,
  13524. safeAreaInsetBottom: truthProp
  13525. });
  13526. var stdin_default$u = defineComponent({
  13527. name: name$m,
  13528. props: shareSheetProps,
  13529. emits: ["cancel", "select", "update:show"],
  13530. setup(props2, {
  13531. emit,
  13532. slots
  13533. }) {
  13534. const updateShow = (value) => emit("update:show", value);
  13535. const onCancel = () => {
  13536. updateShow(false);
  13537. emit("cancel");
  13538. };
  13539. const onSelect = (option, index) => emit("select", option, index);
  13540. const renderHeader = () => {
  13541. const title = slots.title ? slots.title() : props2.title;
  13542. const description = slots.description ? slots.description() : props2.description;
  13543. if (title || description) {
  13544. return createVNode("div", {
  13545. "class": bem$l("header")
  13546. }, [title && createVNode("h2", {
  13547. "class": bem$l("title")
  13548. }, [title]), description && createVNode("span", {
  13549. "class": bem$l("description")
  13550. }, [description])]);
  13551. }
  13552. };
  13553. const renderIcon = (icon) => {
  13554. if (isImage(icon)) {
  13555. return createVNode("img", {
  13556. "src": icon,
  13557. "class": bem$l("image-icon")
  13558. }, null);
  13559. }
  13560. return createVNode("div", {
  13561. "class": bem$l("icon", [icon])
  13562. }, [createVNode(Icon, {
  13563. "name": iconMap[icon] || icon
  13564. }, null)]);
  13565. };
  13566. const renderOption = (option, index) => {
  13567. const {
  13568. name: name2,
  13569. icon,
  13570. className,
  13571. description
  13572. } = option;
  13573. return createVNode("div", {
  13574. "role": "button",
  13575. "tabindex": 0,
  13576. "class": [bem$l("option"), className, HAPTICS_FEEDBACK],
  13577. "onClick": () => onSelect(option, index)
  13578. }, [renderIcon(icon), name2 && createVNode("span", {
  13579. "class": bem$l("name")
  13580. }, [name2]), description && createVNode("span", {
  13581. "class": bem$l("option-description")
  13582. }, [description])]);
  13583. };
  13584. const renderOptions = (options, border) => createVNode("div", {
  13585. "class": bem$l("options", {
  13586. border
  13587. })
  13588. }, [options.map(renderOption)]);
  13589. const renderRows = () => {
  13590. const {
  13591. options
  13592. } = props2;
  13593. if (Array.isArray(options[0])) {
  13594. return options.map((item, index) => renderOptions(item, index !== 0));
  13595. }
  13596. return renderOptions(options);
  13597. };
  13598. const renderCancelButton = () => {
  13599. var _a;
  13600. const cancelText = (_a = props2.cancelText) != null ? _a : t$3("cancel");
  13601. if (slots.cancel || cancelText) {
  13602. return createVNode("button", {
  13603. "type": "button",
  13604. "class": bem$l("cancel"),
  13605. "onClick": onCancel
  13606. }, [slots.cancel ? slots.cancel() : cancelText]);
  13607. }
  13608. };
  13609. return () => createVNode(Popup, mergeProps({
  13610. "class": bem$l(),
  13611. "position": "bottom",
  13612. "onUpdate:show": updateShow
  13613. }, pick(props2, popupInheritKeys)), {
  13614. default: () => [renderHeader(), renderRows(), renderCancelButton()]
  13615. });
  13616. }
  13617. });
  13618. const ShareSheet = withInstall(stdin_default$u);
  13619. const [name$l, bem$k] = createNamespace("sidebar");
  13620. const SIDEBAR_KEY = Symbol(name$l);
  13621. const sidebarProps = {
  13622. modelValue: makeNumericProp(0)
  13623. };
  13624. var stdin_default$t = defineComponent({
  13625. name: name$l,
  13626. props: sidebarProps,
  13627. emits: ["change", "update:modelValue"],
  13628. setup(props2, {
  13629. emit,
  13630. slots
  13631. }) {
  13632. const {
  13633. linkChildren
  13634. } = useChildren(SIDEBAR_KEY);
  13635. const getActive = () => +props2.modelValue;
  13636. const setActive = (value) => {
  13637. if (value !== getActive()) {
  13638. emit("update:modelValue", value);
  13639. emit("change", value);
  13640. }
  13641. };
  13642. linkChildren({
  13643. getActive,
  13644. setActive
  13645. });
  13646. return () => {
  13647. var _a;
  13648. return createVNode("div", {
  13649. "role": "tablist",
  13650. "class": bem$k()
  13651. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  13652. };
  13653. }
  13654. });
  13655. const Sidebar = withInstall(stdin_default$t);
  13656. const [name$k, bem$j] = createNamespace("sidebar-item");
  13657. const sidebarItemProps = extend({}, routeProps, {
  13658. dot: Boolean,
  13659. title: String,
  13660. badge: numericProp,
  13661. disabled: Boolean,
  13662. badgeProps: Object
  13663. });
  13664. var stdin_default$s = defineComponent({
  13665. name: name$k,
  13666. props: sidebarItemProps,
  13667. emits: ["click"],
  13668. setup(props2, {
  13669. emit,
  13670. slots
  13671. }) {
  13672. const route2 = useRoute();
  13673. const {
  13674. parent,
  13675. index
  13676. } = useParent(SIDEBAR_KEY);
  13677. if (!parent) {
  13678. if (process.env.NODE_ENV !== "production") {
  13679. console.error("[Vant] <SidebarItem> must be a child component of <Sidebar>.");
  13680. }
  13681. return;
  13682. }
  13683. const onClick = () => {
  13684. if (props2.disabled) {
  13685. return;
  13686. }
  13687. emit("click", index.value);
  13688. parent.setActive(index.value);
  13689. route2();
  13690. };
  13691. return () => {
  13692. const {
  13693. dot,
  13694. badge,
  13695. title,
  13696. disabled
  13697. } = props2;
  13698. const selected = index.value === parent.getActive();
  13699. return createVNode("div", {
  13700. "role": "tab",
  13701. "class": bem$j({
  13702. select: selected,
  13703. disabled
  13704. }),
  13705. "tabindex": disabled ? void 0 : 0,
  13706. "aria-selected": selected,
  13707. "onClick": onClick
  13708. }, [createVNode(Badge, mergeProps({
  13709. "dot": dot,
  13710. "class": bem$j("text"),
  13711. "content": badge
  13712. }, props2.badgeProps), {
  13713. default: () => [slots.title ? slots.title() : title]
  13714. })]);
  13715. };
  13716. }
  13717. });
  13718. const SidebarItem = withInstall(stdin_default$s);
  13719. const [name$j, bem$i, t$2] = createNamespace("signature");
  13720. const signatureProps = {
  13721. tips: String,
  13722. type: makeStringProp("png"),
  13723. penColor: makeStringProp("#000"),
  13724. lineWidth: makeNumberProp(3),
  13725. clearButtonText: String,
  13726. backgroundColor: makeStringProp(""),
  13727. confirmButtonText: String
  13728. };
  13729. const hasCanvasSupport = () => {
  13730. var _a;
  13731. const canvas = document.createElement("canvas");
  13732. return !!((_a = canvas.getContext) == null ? void 0 : _a.call(canvas, "2d"));
  13733. };
  13734. var stdin_default$r = defineComponent({
  13735. name: name$j,
  13736. props: signatureProps,
  13737. emits: ["submit", "clear", "start", "end", "signing"],
  13738. setup(props2, {
  13739. emit
  13740. }) {
  13741. const canvasRef = ref();
  13742. const wrapRef = ref();
  13743. const ctx = computed(() => {
  13744. if (!canvasRef.value) return null;
  13745. return canvasRef.value.getContext("2d");
  13746. });
  13747. const isRenderCanvas = inBrowser ? hasCanvasSupport() : true;
  13748. let canvasWidth = 0;
  13749. let canvasHeight = 0;
  13750. let canvasRect;
  13751. const touchStart = () => {
  13752. if (!ctx.value) {
  13753. return false;
  13754. }
  13755. ctx.value.beginPath();
  13756. ctx.value.lineWidth = props2.lineWidth;
  13757. ctx.value.strokeStyle = props2.penColor;
  13758. canvasRect = useRect(canvasRef);
  13759. emit("start");
  13760. };
  13761. const touchMove = (event) => {
  13762. if (!ctx.value) {
  13763. return false;
  13764. }
  13765. preventDefault(event);
  13766. const touch = event.touches[0];
  13767. const mouseX = touch.clientX - ((canvasRect == null ? void 0 : canvasRect.left) || 0);
  13768. const mouseY = touch.clientY - ((canvasRect == null ? void 0 : canvasRect.top) || 0);
  13769. ctx.value.lineCap = "round";
  13770. ctx.value.lineJoin = "round";
  13771. ctx.value.lineTo(mouseX, mouseY);
  13772. ctx.value.stroke();
  13773. emit("signing", event);
  13774. };
  13775. const touchEnd = (event) => {
  13776. preventDefault(event);
  13777. emit("end");
  13778. };
  13779. const isCanvasEmpty = (canvas) => {
  13780. const empty = document.createElement("canvas");
  13781. empty.width = canvas.width;
  13782. empty.height = canvas.height;
  13783. if (props2.backgroundColor) {
  13784. const emptyCtx = empty.getContext("2d");
  13785. setCanvasBgColor(emptyCtx);
  13786. }
  13787. return canvas.toDataURL() === empty.toDataURL();
  13788. };
  13789. const setCanvasBgColor = (ctx2) => {
  13790. if (ctx2 && props2.backgroundColor) {
  13791. ctx2.fillStyle = props2.backgroundColor;
  13792. ctx2.fillRect(0, 0, canvasWidth, canvasHeight);
  13793. }
  13794. };
  13795. const submit = () => {
  13796. var _a, _b;
  13797. const canvas = canvasRef.value;
  13798. if (!canvas) {
  13799. return;
  13800. }
  13801. const isEmpty = isCanvasEmpty(canvas);
  13802. const image = isEmpty ? "" : ((_b = (_a = {
  13803. jpg: () => canvas.toDataURL("image/jpeg", 0.8),
  13804. jpeg: () => canvas.toDataURL("image/jpeg", 0.8)
  13805. })[props2.type]) == null ? void 0 : _b.call(_a)) || canvas.toDataURL(`image/${props2.type}`);
  13806. emit("submit", {
  13807. image,
  13808. canvas
  13809. });
  13810. };
  13811. const clear = () => {
  13812. if (ctx.value) {
  13813. ctx.value.clearRect(0, 0, canvasWidth, canvasHeight);
  13814. ctx.value.closePath();
  13815. setCanvasBgColor(ctx.value);
  13816. }
  13817. emit("clear");
  13818. };
  13819. const initialize = () => {
  13820. var _a, _b, _c;
  13821. if (isRenderCanvas && canvasRef.value) {
  13822. const canvas = canvasRef.value;
  13823. const dpr = inBrowser ? window.devicePixelRatio : 1;
  13824. canvasWidth = canvas.width = (((_a = wrapRef.value) == null ? void 0 : _a.offsetWidth) || 0) * dpr;
  13825. canvasHeight = canvas.height = (((_b = wrapRef.value) == null ? void 0 : _b.offsetHeight) || 0) * dpr;
  13826. (_c = ctx.value) == null ? void 0 : _c.scale(dpr, dpr);
  13827. setCanvasBgColor(ctx.value);
  13828. }
  13829. };
  13830. const resize = () => {
  13831. if (ctx.value) {
  13832. const data = ctx.value.getImageData(0, 0, canvasWidth, canvasHeight);
  13833. initialize();
  13834. ctx.value.putImageData(data, 0, 0);
  13835. }
  13836. };
  13837. watch(windowWidth, resize);
  13838. onMounted(initialize);
  13839. useExpose({
  13840. resize,
  13841. clear,
  13842. submit
  13843. });
  13844. return () => createVNode("div", {
  13845. "class": bem$i()
  13846. }, [createVNode("div", {
  13847. "class": bem$i("content"),
  13848. "ref": wrapRef
  13849. }, [isRenderCanvas ? createVNode("canvas", {
  13850. "ref": canvasRef,
  13851. "onTouchstartPassive": touchStart,
  13852. "onTouchmove": touchMove,
  13853. "onTouchend": touchEnd
  13854. }, null) : createVNode("p", null, [props2.tips])]), createVNode("div", {
  13855. "class": bem$i("footer")
  13856. }, [createVNode(Button, {
  13857. "size": "small",
  13858. "onClick": clear
  13859. }, {
  13860. default: () => [props2.clearButtonText || t$2("clear")]
  13861. }), createVNode(Button, {
  13862. "type": "primary",
  13863. "size": "small",
  13864. "onClick": submit
  13865. }, {
  13866. default: () => [props2.confirmButtonText || t$2("confirm")]
  13867. })])]);
  13868. }
  13869. });
  13870. const Signature = withInstall(stdin_default$r);
  13871. const [name$i, bem$h] = createNamespace("skeleton-title");
  13872. const skeletonTitleProps = {
  13873. round: Boolean,
  13874. titleWidth: numericProp
  13875. };
  13876. var stdin_default$q = defineComponent({
  13877. name: name$i,
  13878. props: skeletonTitleProps,
  13879. setup(props2) {
  13880. return () => createVNode("h3", {
  13881. "class": bem$h([{
  13882. round: props2.round
  13883. }]),
  13884. "style": {
  13885. width: addUnit(props2.titleWidth)
  13886. }
  13887. }, null);
  13888. }
  13889. });
  13890. const SkeletonTitle = withInstall(stdin_default$q);
  13891. var stdin_default$p = SkeletonTitle;
  13892. const [name$h, bem$g] = createNamespace("skeleton-avatar");
  13893. const skeletonAvatarProps = {
  13894. avatarSize: numericProp,
  13895. avatarShape: makeStringProp("round")
  13896. };
  13897. var stdin_default$o = defineComponent({
  13898. name: name$h,
  13899. props: skeletonAvatarProps,
  13900. setup(props2) {
  13901. return () => createVNode("div", {
  13902. "class": bem$g([props2.avatarShape]),
  13903. "style": getSizeStyle(props2.avatarSize)
  13904. }, null);
  13905. }
  13906. });
  13907. const SkeletonAvatar = withInstall(stdin_default$o);
  13908. var stdin_default$n = SkeletonAvatar;
  13909. const DEFAULT_ROW_WIDTH = "100%";
  13910. const skeletonParagraphProps = {
  13911. round: Boolean,
  13912. rowWidth: {
  13913. type: numericProp,
  13914. default: DEFAULT_ROW_WIDTH
  13915. }
  13916. };
  13917. const [name$g, bem$f] = createNamespace("skeleton-paragraph");
  13918. var stdin_default$m = defineComponent({
  13919. name: name$g,
  13920. props: skeletonParagraphProps,
  13921. setup(props2) {
  13922. return () => createVNode("div", {
  13923. "class": bem$f([{
  13924. round: props2.round
  13925. }]),
  13926. "style": {
  13927. width: props2.rowWidth
  13928. }
  13929. }, null);
  13930. }
  13931. });
  13932. const SkeletonParagraph = withInstall(stdin_default$m);
  13933. var stdin_default$l = SkeletonParagraph;
  13934. const [name$f, bem$e] = createNamespace("skeleton");
  13935. const DEFAULT_LAST_ROW_WIDTH = "60%";
  13936. const skeletonProps = {
  13937. row: makeNumericProp(0),
  13938. round: Boolean,
  13939. title: Boolean,
  13940. titleWidth: numericProp,
  13941. avatar: Boolean,
  13942. avatarSize: numericProp,
  13943. avatarShape: makeStringProp("round"),
  13944. loading: truthProp,
  13945. animate: truthProp,
  13946. rowWidth: {
  13947. type: [Number, String, Array],
  13948. default: DEFAULT_ROW_WIDTH
  13949. }
  13950. };
  13951. var stdin_default$k = defineComponent({
  13952. name: name$f,
  13953. inheritAttrs: false,
  13954. props: skeletonProps,
  13955. setup(props2, {
  13956. slots,
  13957. attrs
  13958. }) {
  13959. const renderAvatar = () => {
  13960. if (props2.avatar) {
  13961. return createVNode(stdin_default$n, {
  13962. "avatarShape": props2.avatarShape,
  13963. "avatarSize": props2.avatarSize
  13964. }, null);
  13965. }
  13966. };
  13967. const renderTitle = () => {
  13968. if (props2.title) {
  13969. return createVNode(stdin_default$p, {
  13970. "round": props2.round,
  13971. "titleWidth": props2.titleWidth
  13972. }, null);
  13973. }
  13974. };
  13975. const getRowWidth = (index) => {
  13976. const {
  13977. rowWidth
  13978. } = props2;
  13979. if (rowWidth === DEFAULT_ROW_WIDTH && index === +props2.row - 1) {
  13980. return DEFAULT_LAST_ROW_WIDTH;
  13981. }
  13982. if (Array.isArray(rowWidth)) {
  13983. return rowWidth[index];
  13984. }
  13985. return rowWidth;
  13986. };
  13987. const renderRows = () => Array(+props2.row).fill("").map((_, i) => createVNode(stdin_default$l, {
  13988. "key": i,
  13989. "round": props2.round,
  13990. "rowWidth": addUnit(getRowWidth(i))
  13991. }, null));
  13992. const renderContents = () => {
  13993. if (slots.template) {
  13994. return slots.template();
  13995. }
  13996. return createVNode(Fragment, null, [renderAvatar(), createVNode("div", {
  13997. "class": bem$e("content")
  13998. }, [renderTitle(), renderRows()])]);
  13999. };
  14000. return () => {
  14001. var _a;
  14002. if (!props2.loading) {
  14003. return (_a = slots.default) == null ? void 0 : _a.call(slots);
  14004. }
  14005. return createVNode("div", mergeProps({
  14006. "class": bem$e({
  14007. animate: props2.animate,
  14008. round: props2.round
  14009. })
  14010. }, attrs), [renderContents()]);
  14011. };
  14012. }
  14013. });
  14014. const Skeleton = withInstall(stdin_default$k);
  14015. const [name$e, bem$d] = createNamespace("skeleton-image");
  14016. const skeletonImageProps = {
  14017. imageSize: numericProp,
  14018. imageShape: makeStringProp("square")
  14019. };
  14020. var stdin_default$j = defineComponent({
  14021. name: name$e,
  14022. props: skeletonImageProps,
  14023. setup(props2) {
  14024. return () => createVNode("div", {
  14025. "class": bem$d([props2.imageShape]),
  14026. "style": getSizeStyle(props2.imageSize)
  14027. }, [createVNode(Icon, {
  14028. "name": "photo",
  14029. "class": bem$d("icon")
  14030. }, null)]);
  14031. }
  14032. });
  14033. const SkeletonImage = withInstall(stdin_default$j);
  14034. const [name$d, bem$c] = createNamespace("slider");
  14035. const sliderProps = {
  14036. min: makeNumericProp(0),
  14037. max: makeNumericProp(100),
  14038. step: makeNumericProp(1),
  14039. range: Boolean,
  14040. reverse: Boolean,
  14041. disabled: Boolean,
  14042. readonly: Boolean,
  14043. vertical: Boolean,
  14044. barHeight: numericProp,
  14045. buttonSize: numericProp,
  14046. activeColor: String,
  14047. inactiveColor: String,
  14048. modelValue: {
  14049. type: [Number, Array],
  14050. default: 0
  14051. }
  14052. };
  14053. var stdin_default$i = defineComponent({
  14054. name: name$d,
  14055. props: sliderProps,
  14056. emits: ["change", "dragEnd", "dragStart", "update:modelValue"],
  14057. setup(props2, {
  14058. emit,
  14059. slots
  14060. }) {
  14061. let buttonIndex;
  14062. let current2;
  14063. let startValue;
  14064. const root = ref();
  14065. const slider = [ref(), ref()];
  14066. const dragStatus = ref();
  14067. const touch = useTouch();
  14068. const scope = computed(() => Number(props2.max) - Number(props2.min));
  14069. const wrapperStyle = computed(() => {
  14070. const crossAxis = props2.vertical ? "width" : "height";
  14071. return {
  14072. background: props2.inactiveColor,
  14073. [crossAxis]: addUnit(props2.barHeight)
  14074. };
  14075. });
  14076. const isRange = (val) => props2.range && Array.isArray(val);
  14077. const calcMainAxis = () => {
  14078. const {
  14079. modelValue,
  14080. min
  14081. } = props2;
  14082. if (isRange(modelValue)) {
  14083. return `${(modelValue[1] - modelValue[0]) * 100 / scope.value}%`;
  14084. }
  14085. return `${(modelValue - Number(min)) * 100 / scope.value}%`;
  14086. };
  14087. const calcOffset = () => {
  14088. const {
  14089. modelValue,
  14090. min
  14091. } = props2;
  14092. if (isRange(modelValue)) {
  14093. return `${(modelValue[0] - Number(min)) * 100 / scope.value}%`;
  14094. }
  14095. return "0%";
  14096. };
  14097. const barStyle = computed(() => {
  14098. const mainAxis = props2.vertical ? "height" : "width";
  14099. const style = {
  14100. [mainAxis]: calcMainAxis(),
  14101. background: props2.activeColor
  14102. };
  14103. if (dragStatus.value) {
  14104. style.transition = "none";
  14105. }
  14106. const getPositionKey = () => {
  14107. if (props2.vertical) {
  14108. return props2.reverse ? "bottom" : "top";
  14109. }
  14110. return props2.reverse ? "right" : "left";
  14111. };
  14112. style[getPositionKey()] = calcOffset();
  14113. return style;
  14114. });
  14115. const format2 = (value) => {
  14116. const min = +props2.min;
  14117. const max = +props2.max;
  14118. const step = +props2.step;
  14119. value = clamp(value, min, max);
  14120. const diff = Math.round((value - min) / step) * step;
  14121. return addNumber(min, diff);
  14122. };
  14123. const updateStartValue = () => {
  14124. const current22 = props2.modelValue;
  14125. if (isRange(current22)) {
  14126. startValue = current22.map(format2);
  14127. } else {
  14128. startValue = format2(current22);
  14129. }
  14130. };
  14131. const handleRangeValue = (value) => {
  14132. var _a, _b;
  14133. const left = (_a = value[0]) != null ? _a : Number(props2.min);
  14134. const right = (_b = value[1]) != null ? _b : Number(props2.max);
  14135. return left > right ? [right, left] : [left, right];
  14136. };
  14137. const updateValue = (value, end) => {
  14138. if (isRange(value)) {
  14139. value = handleRangeValue(value).map(format2);
  14140. } else {
  14141. value = format2(value);
  14142. }
  14143. if (!isSameValue(value, props2.modelValue)) {
  14144. emit("update:modelValue", value);
  14145. }
  14146. if (end && !isSameValue(value, startValue)) {
  14147. emit("change", value);
  14148. }
  14149. };
  14150. const onClick = (event) => {
  14151. event.stopPropagation();
  14152. if (props2.disabled || props2.readonly) {
  14153. return;
  14154. }
  14155. updateStartValue();
  14156. const {
  14157. min,
  14158. reverse,
  14159. vertical,
  14160. modelValue
  14161. } = props2;
  14162. const rect = useRect(root);
  14163. const getDelta = () => {
  14164. if (vertical) {
  14165. if (reverse) {
  14166. return rect.bottom - event.clientY;
  14167. }
  14168. return event.clientY - rect.top;
  14169. }
  14170. if (reverse) {
  14171. return rect.right - event.clientX;
  14172. }
  14173. return event.clientX - rect.left;
  14174. };
  14175. const total = vertical ? rect.height : rect.width;
  14176. const value = Number(min) + getDelta() / total * scope.value;
  14177. if (isRange(modelValue)) {
  14178. const [left, right] = modelValue;
  14179. const middle = (left + right) / 2;
  14180. if (value <= middle) {
  14181. updateValue([value, right], true);
  14182. } else {
  14183. updateValue([left, value], true);
  14184. }
  14185. } else {
  14186. updateValue(value, true);
  14187. }
  14188. };
  14189. const onTouchStart = (event) => {
  14190. if (props2.disabled || props2.readonly) {
  14191. return;
  14192. }
  14193. touch.start(event);
  14194. current2 = props2.modelValue;
  14195. updateStartValue();
  14196. dragStatus.value = "start";
  14197. };
  14198. const onTouchMove = (event) => {
  14199. if (props2.disabled || props2.readonly) {
  14200. return;
  14201. }
  14202. if (dragStatus.value === "start") {
  14203. emit("dragStart", event);
  14204. }
  14205. preventDefault(event, true);
  14206. touch.move(event);
  14207. dragStatus.value = "dragging";
  14208. const rect = useRect(root);
  14209. const delta = props2.vertical ? touch.deltaY.value : touch.deltaX.value;
  14210. const total = props2.vertical ? rect.height : rect.width;
  14211. let diff = delta / total * scope.value;
  14212. if (props2.reverse) {
  14213. diff = -diff;
  14214. }
  14215. if (isRange(startValue)) {
  14216. const index = props2.reverse ? 1 - buttonIndex : buttonIndex;
  14217. current2[index] = startValue[index] + diff;
  14218. } else {
  14219. current2 = startValue + diff;
  14220. }
  14221. updateValue(current2);
  14222. };
  14223. const onTouchEnd = (event) => {
  14224. if (props2.disabled || props2.readonly) {
  14225. return;
  14226. }
  14227. if (dragStatus.value === "dragging") {
  14228. updateValue(current2, true);
  14229. emit("dragEnd", event);
  14230. }
  14231. dragStatus.value = "";
  14232. };
  14233. const getButtonClassName = (index) => {
  14234. if (typeof index === "number") {
  14235. const position = ["left", "right"];
  14236. return bem$c(`button-wrapper`, position[index]);
  14237. }
  14238. return bem$c("button-wrapper", props2.reverse ? "left" : "right");
  14239. };
  14240. const renderButtonContent = (value, index) => {
  14241. const dragging = dragStatus.value === "dragging";
  14242. if (typeof index === "number") {
  14243. const slot = slots[index === 0 ? "left-button" : "right-button"];
  14244. let dragIndex;
  14245. if (dragging && Array.isArray(current2)) {
  14246. dragIndex = current2[0] > current2[1] ? buttonIndex ^ 1 : buttonIndex;
  14247. }
  14248. if (slot) {
  14249. return slot({
  14250. value,
  14251. dragging,
  14252. dragIndex
  14253. });
  14254. }
  14255. }
  14256. if (slots.button) {
  14257. return slots.button({
  14258. value,
  14259. dragging
  14260. });
  14261. }
  14262. return createVNode("div", {
  14263. "class": bem$c("button"),
  14264. "style": getSizeStyle(props2.buttonSize)
  14265. }, null);
  14266. };
  14267. const renderButton = (index) => {
  14268. const current22 = typeof index === "number" ? props2.modelValue[index] : props2.modelValue;
  14269. return createVNode("div", {
  14270. "ref": slider[index != null ? index : 0],
  14271. "role": "slider",
  14272. "class": getButtonClassName(index),
  14273. "tabindex": props2.disabled ? void 0 : 0,
  14274. "aria-valuemin": props2.min,
  14275. "aria-valuenow": current22,
  14276. "aria-valuemax": props2.max,
  14277. "aria-disabled": props2.disabled || void 0,
  14278. "aria-readonly": props2.readonly || void 0,
  14279. "aria-orientation": props2.vertical ? "vertical" : "horizontal",
  14280. "onTouchstartPassive": (event) => {
  14281. if (typeof index === "number") {
  14282. buttonIndex = index;
  14283. }
  14284. onTouchStart(event);
  14285. },
  14286. "onTouchend": onTouchEnd,
  14287. "onTouchcancel": onTouchEnd,
  14288. "onClick": stopPropagation
  14289. }, [renderButtonContent(current22, index)]);
  14290. };
  14291. updateValue(props2.modelValue);
  14292. useCustomFieldValue(() => props2.modelValue);
  14293. slider.forEach((item) => {
  14294. useEventListener("touchmove", onTouchMove, {
  14295. target: item
  14296. });
  14297. });
  14298. return () => createVNode("div", {
  14299. "ref": root,
  14300. "style": wrapperStyle.value,
  14301. "class": bem$c({
  14302. vertical: props2.vertical,
  14303. disabled: props2.disabled
  14304. }),
  14305. "onClick": onClick
  14306. }, [createVNode("div", {
  14307. "class": bem$c("bar"),
  14308. "style": barStyle.value
  14309. }, [props2.range ? [renderButton(0), renderButton(1)] : renderButton()])]);
  14310. }
  14311. });
  14312. const Slider = withInstall(stdin_default$i);
  14313. const [name$c, bem$b] = createNamespace("space");
  14314. const spaceProps = {
  14315. align: String,
  14316. direction: {
  14317. type: String,
  14318. default: "horizontal"
  14319. },
  14320. size: {
  14321. type: [Number, String, Array],
  14322. default: 8
  14323. },
  14324. wrap: Boolean,
  14325. fill: Boolean
  14326. };
  14327. function filterEmpty(children = []) {
  14328. const nodes = [];
  14329. children.forEach((child) => {
  14330. if (Array.isArray(child)) {
  14331. nodes.push(...child);
  14332. } else if (child.type === Fragment) {
  14333. nodes.push(...filterEmpty(child.children));
  14334. } else {
  14335. nodes.push(child);
  14336. }
  14337. });
  14338. return nodes.filter((c) => {
  14339. var _a;
  14340. return !(c && (c.type === Comment || c.type === Fragment && ((_a = c.children) == null ? void 0 : _a.length) === 0 || c.type === Text && c.children.trim() === ""));
  14341. });
  14342. }
  14343. var stdin_default$h = defineComponent({
  14344. name: name$c,
  14345. props: spaceProps,
  14346. setup(props2, {
  14347. slots
  14348. }) {
  14349. const mergedAlign = computed(() => {
  14350. var _a;
  14351. return (_a = props2.align) != null ? _a : props2.direction === "horizontal" ? "center" : "";
  14352. });
  14353. const getMargin = (size) => {
  14354. if (typeof size === "number") {
  14355. return size + "px";
  14356. }
  14357. return size;
  14358. };
  14359. const getMarginStyle = (isLast) => {
  14360. const style = {};
  14361. const marginRight = `${getMargin(Array.isArray(props2.size) ? props2.size[0] : props2.size)}`;
  14362. const marginBottom = `${getMargin(Array.isArray(props2.size) ? props2.size[1] : props2.size)}`;
  14363. if (isLast) {
  14364. return props2.wrap ? {
  14365. marginBottom
  14366. } : {};
  14367. }
  14368. if (props2.direction === "horizontal") {
  14369. style.marginRight = marginRight;
  14370. }
  14371. if (props2.direction === "vertical" || props2.wrap) {
  14372. style.marginBottom = marginBottom;
  14373. }
  14374. return style;
  14375. };
  14376. return () => {
  14377. var _a;
  14378. const children = filterEmpty((_a = slots.default) == null ? void 0 : _a.call(slots));
  14379. return createVNode("div", {
  14380. "class": [bem$b({
  14381. [props2.direction]: props2.direction,
  14382. [`align-${mergedAlign.value}`]: mergedAlign.value,
  14383. wrap: props2.wrap,
  14384. fill: props2.fill
  14385. })]
  14386. }, [children.map((c, i) => createVNode("div", {
  14387. "key": `item-${i}`,
  14388. "class": `${name$c}-item`,
  14389. "style": getMarginStyle(i === children.length - 1)
  14390. }, [c]))]);
  14391. };
  14392. }
  14393. });
  14394. const Space = withInstall(stdin_default$h);
  14395. const [name$b, bem$a] = createNamespace("steps");
  14396. const stepsProps = {
  14397. active: makeNumericProp(0),
  14398. direction: makeStringProp("horizontal"),
  14399. activeIcon: makeStringProp("checked"),
  14400. iconPrefix: String,
  14401. finishIcon: String,
  14402. activeColor: String,
  14403. inactiveIcon: String,
  14404. inactiveColor: String
  14405. };
  14406. const STEPS_KEY = Symbol(name$b);
  14407. var stdin_default$g = defineComponent({
  14408. name: name$b,
  14409. props: stepsProps,
  14410. emits: ["clickStep"],
  14411. setup(props2, {
  14412. emit,
  14413. slots
  14414. }) {
  14415. const {
  14416. linkChildren
  14417. } = useChildren(STEPS_KEY);
  14418. const onClickStep = (index) => emit("clickStep", index);
  14419. linkChildren({
  14420. props: props2,
  14421. onClickStep
  14422. });
  14423. return () => {
  14424. var _a;
  14425. return createVNode("div", {
  14426. "class": bem$a([props2.direction])
  14427. }, [createVNode("div", {
  14428. "class": bem$a("items")
  14429. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)])]);
  14430. };
  14431. }
  14432. });
  14433. const [name$a, bem$9] = createNamespace("step");
  14434. var stdin_default$f = defineComponent({
  14435. name: name$a,
  14436. setup(props2, {
  14437. slots
  14438. }) {
  14439. const {
  14440. parent,
  14441. index
  14442. } = useParent(STEPS_KEY);
  14443. if (!parent) {
  14444. if (process.env.NODE_ENV !== "production") {
  14445. console.error("[Vant] <Step> must be a child component of <Steps>.");
  14446. }
  14447. return;
  14448. }
  14449. const parentProps = parent.props;
  14450. const getStatus = () => {
  14451. const active = +parentProps.active;
  14452. if (index.value < active) {
  14453. return "finish";
  14454. }
  14455. return index.value === active ? "process" : "waiting";
  14456. };
  14457. const isActive = () => getStatus() === "process";
  14458. const lineStyle = computed(() => ({
  14459. background: getStatus() === "finish" ? parentProps.activeColor : parentProps.inactiveColor
  14460. }));
  14461. const titleStyle = computed(() => {
  14462. if (isActive()) {
  14463. return {
  14464. color: parentProps.activeColor
  14465. };
  14466. }
  14467. if (getStatus() === "waiting") {
  14468. return {
  14469. color: parentProps.inactiveColor
  14470. };
  14471. }
  14472. });
  14473. const onClickStep = () => parent.onClickStep(index.value);
  14474. const renderCircle = () => {
  14475. const {
  14476. iconPrefix,
  14477. finishIcon,
  14478. activeIcon,
  14479. activeColor,
  14480. inactiveIcon
  14481. } = parentProps;
  14482. if (isActive()) {
  14483. if (slots["active-icon"]) {
  14484. return slots["active-icon"]();
  14485. }
  14486. return createVNode(Icon, {
  14487. "class": bem$9("icon", "active"),
  14488. "name": activeIcon,
  14489. "color": activeColor,
  14490. "classPrefix": iconPrefix
  14491. }, null);
  14492. }
  14493. if (getStatus() === "finish" && (finishIcon || slots["finish-icon"])) {
  14494. if (slots["finish-icon"]) {
  14495. return slots["finish-icon"]();
  14496. }
  14497. return createVNode(Icon, {
  14498. "class": bem$9("icon", "finish"),
  14499. "name": finishIcon,
  14500. "color": activeColor,
  14501. "classPrefix": iconPrefix
  14502. }, null);
  14503. }
  14504. if (slots["inactive-icon"]) {
  14505. return slots["inactive-icon"]();
  14506. }
  14507. if (inactiveIcon) {
  14508. return createVNode(Icon, {
  14509. "class": bem$9("icon"),
  14510. "name": inactiveIcon,
  14511. "classPrefix": iconPrefix
  14512. }, null);
  14513. }
  14514. return createVNode("i", {
  14515. "class": bem$9("circle"),
  14516. "style": lineStyle.value
  14517. }, null);
  14518. };
  14519. return () => {
  14520. var _a;
  14521. const status = getStatus();
  14522. return createVNode("div", {
  14523. "class": [BORDER, bem$9([parentProps.direction, {
  14524. [status]: status
  14525. }])]
  14526. }, [createVNode("div", {
  14527. "class": bem$9("title", {
  14528. active: isActive()
  14529. }),
  14530. "style": titleStyle.value,
  14531. "onClick": onClickStep
  14532. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]), createVNode("div", {
  14533. "class": bem$9("circle-container"),
  14534. "onClick": onClickStep
  14535. }, [renderCircle()]), createVNode("div", {
  14536. "class": bem$9("line"),
  14537. "style": lineStyle.value
  14538. }, null)]);
  14539. };
  14540. }
  14541. });
  14542. const Step = withInstall(stdin_default$f);
  14543. const [name$9, bem$8] = createNamespace("stepper");
  14544. const LONG_PRESS_INTERVAL = 200;
  14545. const isEqual = (value1, value2) => String(value1) === String(value2);
  14546. const stepperProps = {
  14547. min: makeNumericProp(1),
  14548. max: makeNumericProp(Infinity),
  14549. name: makeNumericProp(""),
  14550. step: makeNumericProp(1),
  14551. theme: String,
  14552. integer: Boolean,
  14553. disabled: Boolean,
  14554. showPlus: truthProp,
  14555. showMinus: truthProp,
  14556. showInput: truthProp,
  14557. longPress: truthProp,
  14558. autoFixed: truthProp,
  14559. allowEmpty: Boolean,
  14560. modelValue: numericProp,
  14561. inputWidth: numericProp,
  14562. buttonSize: numericProp,
  14563. placeholder: String,
  14564. disablePlus: Boolean,
  14565. disableMinus: Boolean,
  14566. disableInput: Boolean,
  14567. beforeChange: Function,
  14568. defaultValue: makeNumericProp(1),
  14569. decimalLength: numericProp
  14570. };
  14571. var stdin_default$e = defineComponent({
  14572. name: name$9,
  14573. props: stepperProps,
  14574. emits: ["plus", "blur", "minus", "focus", "change", "overlimit", "update:modelValue"],
  14575. setup(props2, {
  14576. emit
  14577. }) {
  14578. const format2 = (value, autoFixed = true) => {
  14579. const {
  14580. min,
  14581. max,
  14582. allowEmpty,
  14583. decimalLength
  14584. } = props2;
  14585. if (allowEmpty && value === "") {
  14586. return value;
  14587. }
  14588. value = formatNumber(String(value), !props2.integer);
  14589. value = value === "" ? 0 : +value;
  14590. value = Number.isNaN(value) ? +min : value;
  14591. value = autoFixed ? Math.max(Math.min(+max, value), +min) : value;
  14592. if (isDef(decimalLength)) {
  14593. value = value.toFixed(+decimalLength);
  14594. }
  14595. return value;
  14596. };
  14597. const getInitialValue = () => {
  14598. var _a;
  14599. const defaultValue = (_a = props2.modelValue) != null ? _a : props2.defaultValue;
  14600. const value = format2(defaultValue);
  14601. if (!isEqual(value, props2.modelValue)) {
  14602. emit("update:modelValue", value);
  14603. }
  14604. return value;
  14605. };
  14606. let actionType;
  14607. const inputRef = ref();
  14608. const current2 = ref(getInitialValue());
  14609. const minusDisabled = computed(() => props2.disabled || props2.disableMinus || +current2.value <= +props2.min);
  14610. const plusDisabled = computed(() => props2.disabled || props2.disablePlus || +current2.value >= +props2.max);
  14611. const inputStyle = computed(() => ({
  14612. width: addUnit(props2.inputWidth),
  14613. height: addUnit(props2.buttonSize)
  14614. }));
  14615. const buttonStyle = computed(() => getSizeStyle(props2.buttonSize));
  14616. const check = () => {
  14617. const value = format2(current2.value);
  14618. if (!isEqual(value, current2.value)) {
  14619. current2.value = value;
  14620. }
  14621. };
  14622. const setValue = (value) => {
  14623. if (props2.beforeChange) {
  14624. callInterceptor(props2.beforeChange, {
  14625. args: [value],
  14626. done() {
  14627. current2.value = value;
  14628. }
  14629. });
  14630. } else {
  14631. current2.value = value;
  14632. }
  14633. };
  14634. const onChange = () => {
  14635. if (actionType === "plus" && plusDisabled.value || actionType === "minus" && minusDisabled.value) {
  14636. emit("overlimit", actionType);
  14637. return;
  14638. }
  14639. const diff = actionType === "minus" ? -props2.step : +props2.step;
  14640. const value = format2(addNumber(+current2.value, diff));
  14641. setValue(value);
  14642. emit(actionType);
  14643. };
  14644. const onInput = (event) => {
  14645. const input = event.target;
  14646. const {
  14647. value
  14648. } = input;
  14649. const {
  14650. decimalLength
  14651. } = props2;
  14652. let formatted = formatNumber(String(value), !props2.integer);
  14653. if (isDef(decimalLength) && formatted.includes(".")) {
  14654. const pair = formatted.split(".");
  14655. formatted = `${pair[0]}.${pair[1].slice(0, +decimalLength)}`;
  14656. }
  14657. if (props2.beforeChange) {
  14658. input.value = String(current2.value);
  14659. } else if (!isEqual(value, formatted)) {
  14660. input.value = formatted;
  14661. }
  14662. const isNumeric2 = formatted === String(+formatted);
  14663. setValue(isNumeric2 ? +formatted : formatted);
  14664. };
  14665. const onFocus = (event) => {
  14666. var _a;
  14667. if (props2.disableInput) {
  14668. (_a = inputRef.value) == null ? void 0 : _a.blur();
  14669. } else {
  14670. emit("focus", event);
  14671. }
  14672. };
  14673. const onBlur = (event) => {
  14674. const input = event.target;
  14675. const value = format2(input.value, props2.autoFixed);
  14676. input.value = String(value);
  14677. current2.value = value;
  14678. nextTick(() => {
  14679. emit("blur", event);
  14680. resetScroll();
  14681. });
  14682. };
  14683. let isLongPress;
  14684. let longPressTimer;
  14685. const longPressStep = () => {
  14686. longPressTimer = setTimeout(() => {
  14687. onChange();
  14688. longPressStep();
  14689. }, LONG_PRESS_INTERVAL);
  14690. };
  14691. const onTouchStart = () => {
  14692. if (props2.longPress) {
  14693. isLongPress = false;
  14694. clearTimeout(longPressTimer);
  14695. longPressTimer = setTimeout(() => {
  14696. isLongPress = true;
  14697. onChange();
  14698. longPressStep();
  14699. }, LONG_PRESS_START_TIME);
  14700. }
  14701. };
  14702. const onTouchEnd = (event) => {
  14703. if (props2.longPress) {
  14704. clearTimeout(longPressTimer);
  14705. if (isLongPress) {
  14706. preventDefault(event);
  14707. }
  14708. }
  14709. };
  14710. const onMousedown = (event) => {
  14711. if (props2.disableInput) {
  14712. preventDefault(event);
  14713. }
  14714. };
  14715. const createListeners = (type) => ({
  14716. onClick: (event) => {
  14717. preventDefault(event);
  14718. actionType = type;
  14719. onChange();
  14720. },
  14721. onTouchstartPassive: () => {
  14722. actionType = type;
  14723. onTouchStart();
  14724. },
  14725. onTouchend: onTouchEnd,
  14726. onTouchcancel: onTouchEnd
  14727. });
  14728. watch(() => [props2.max, props2.min, props2.integer, props2.decimalLength], check);
  14729. watch(() => props2.modelValue, (value) => {
  14730. if (!isEqual(value, current2.value)) {
  14731. current2.value = format2(value);
  14732. }
  14733. });
  14734. watch(current2, (value) => {
  14735. emit("update:modelValue", value);
  14736. emit("change", value, {
  14737. name: props2.name
  14738. });
  14739. });
  14740. useCustomFieldValue(() => props2.modelValue);
  14741. return () => createVNode("div", {
  14742. "role": "group",
  14743. "class": bem$8([props2.theme])
  14744. }, [withDirectives(createVNode("button", mergeProps({
  14745. "type": "button",
  14746. "style": buttonStyle.value,
  14747. "class": [bem$8("minus", {
  14748. disabled: minusDisabled.value
  14749. }), {
  14750. [HAPTICS_FEEDBACK]: !minusDisabled.value
  14751. }],
  14752. "aria-disabled": minusDisabled.value || void 0
  14753. }, createListeners("minus")), null), [[vShow, props2.showMinus]]), withDirectives(createVNode("input", {
  14754. "ref": inputRef,
  14755. "type": props2.integer ? "tel" : "text",
  14756. "role": "spinbutton",
  14757. "class": bem$8("input"),
  14758. "value": current2.value,
  14759. "style": inputStyle.value,
  14760. "disabled": props2.disabled,
  14761. "readonly": props2.disableInput,
  14762. "inputmode": props2.integer ? "numeric" : "decimal",
  14763. "placeholder": props2.placeholder,
  14764. "autocomplete": "off",
  14765. "aria-valuemax": props2.max,
  14766. "aria-valuemin": props2.min,
  14767. "aria-valuenow": current2.value,
  14768. "onBlur": onBlur,
  14769. "onInput": onInput,
  14770. "onFocus": onFocus,
  14771. "onMousedown": onMousedown
  14772. }, null), [[vShow, props2.showInput]]), withDirectives(createVNode("button", mergeProps({
  14773. "type": "button",
  14774. "style": buttonStyle.value,
  14775. "class": [bem$8("plus", {
  14776. disabled: plusDisabled.value
  14777. }), {
  14778. [HAPTICS_FEEDBACK]: !plusDisabled.value
  14779. }],
  14780. "aria-disabled": plusDisabled.value || void 0
  14781. }, createListeners("plus")), null), [[vShow, props2.showPlus]])]);
  14782. }
  14783. });
  14784. const Stepper = withInstall(stdin_default$e);
  14785. const Steps = withInstall(stdin_default$g);
  14786. const [name$8, bem$7, t$1] = createNamespace("submit-bar");
  14787. const submitBarProps = {
  14788. tip: String,
  14789. label: String,
  14790. price: Number,
  14791. tipIcon: String,
  14792. loading: Boolean,
  14793. currency: makeStringProp("¥"),
  14794. disabled: Boolean,
  14795. textAlign: String,
  14796. buttonText: String,
  14797. buttonType: makeStringProp("danger"),
  14798. buttonColor: String,
  14799. suffixLabel: String,
  14800. placeholder: Boolean,
  14801. decimalLength: makeNumericProp(2),
  14802. safeAreaInsetBottom: truthProp
  14803. };
  14804. var stdin_default$d = defineComponent({
  14805. name: name$8,
  14806. props: submitBarProps,
  14807. emits: ["submit"],
  14808. setup(props2, {
  14809. emit,
  14810. slots
  14811. }) {
  14812. const root = ref();
  14813. const renderPlaceholder = usePlaceholder(root, bem$7);
  14814. const renderText = () => {
  14815. const {
  14816. price,
  14817. label,
  14818. currency,
  14819. textAlign,
  14820. suffixLabel,
  14821. decimalLength
  14822. } = props2;
  14823. if (typeof price === "number") {
  14824. const pricePair = (price / 100).toFixed(+decimalLength).split(".");
  14825. const decimal = decimalLength ? `.${pricePair[1]}` : "";
  14826. return createVNode("div", {
  14827. "class": bem$7("text"),
  14828. "style": {
  14829. textAlign
  14830. }
  14831. }, [createVNode("span", null, [label || t$1("label")]), createVNode("span", {
  14832. "class": bem$7("price")
  14833. }, [currency, createVNode("span", {
  14834. "class": bem$7("price-integer")
  14835. }, [pricePair[0]]), decimal]), suffixLabel && createVNode("span", {
  14836. "class": bem$7("suffix-label")
  14837. }, [suffixLabel])]);
  14838. }
  14839. };
  14840. const renderTip = () => {
  14841. var _a;
  14842. const {
  14843. tip,
  14844. tipIcon
  14845. } = props2;
  14846. if (slots.tip || tip) {
  14847. return createVNode("div", {
  14848. "class": bem$7("tip")
  14849. }, [tipIcon && createVNode(Icon, {
  14850. "class": bem$7("tip-icon"),
  14851. "name": tipIcon
  14852. }, null), tip && createVNode("span", {
  14853. "class": bem$7("tip-text")
  14854. }, [tip]), (_a = slots.tip) == null ? void 0 : _a.call(slots)]);
  14855. }
  14856. };
  14857. const onClickButton = () => emit("submit");
  14858. const renderButton = () => {
  14859. if (slots.button) {
  14860. return slots.button();
  14861. }
  14862. return createVNode(Button, {
  14863. "round": true,
  14864. "type": props2.buttonType,
  14865. "text": props2.buttonText,
  14866. "class": bem$7("button", props2.buttonType),
  14867. "color": props2.buttonColor,
  14868. "loading": props2.loading,
  14869. "disabled": props2.disabled,
  14870. "onClick": onClickButton
  14871. }, null);
  14872. };
  14873. const renderSubmitBar = () => {
  14874. var _a, _b;
  14875. return createVNode("div", {
  14876. "ref": root,
  14877. "class": [bem$7(), {
  14878. "van-safe-area-bottom": props2.safeAreaInsetBottom
  14879. }]
  14880. }, [(_a = slots.top) == null ? void 0 : _a.call(slots), renderTip(), createVNode("div", {
  14881. "class": bem$7("bar")
  14882. }, [(_b = slots.default) == null ? void 0 : _b.call(slots), renderText(), renderButton()])]);
  14883. };
  14884. return () => {
  14885. if (props2.placeholder) {
  14886. return renderPlaceholder(renderSubmitBar);
  14887. }
  14888. return renderSubmitBar();
  14889. };
  14890. }
  14891. });
  14892. const SubmitBar = withInstall(stdin_default$d);
  14893. const [name$7, bem$6] = createNamespace("swipe-cell");
  14894. const swipeCellProps = {
  14895. name: makeNumericProp(""),
  14896. disabled: Boolean,
  14897. leftWidth: numericProp,
  14898. rightWidth: numericProp,
  14899. beforeClose: Function,
  14900. stopPropagation: Boolean
  14901. };
  14902. var stdin_default$c = defineComponent({
  14903. name: name$7,
  14904. props: swipeCellProps,
  14905. emits: ["open", "close", "click"],
  14906. setup(props2, {
  14907. emit,
  14908. slots
  14909. }) {
  14910. let opened;
  14911. let lockClick2;
  14912. let startOffset;
  14913. let isInBeforeClosing;
  14914. const root = ref();
  14915. const leftRef = ref();
  14916. const rightRef = ref();
  14917. const state = reactive({
  14918. offset: 0,
  14919. dragging: false
  14920. });
  14921. const touch = useTouch();
  14922. const getWidthByRef = (ref2) => ref2.value ? useRect(ref2).width : 0;
  14923. const leftWidth = computed(() => isDef(props2.leftWidth) ? +props2.leftWidth : getWidthByRef(leftRef));
  14924. const rightWidth = computed(() => isDef(props2.rightWidth) ? +props2.rightWidth : getWidthByRef(rightRef));
  14925. const open = (side) => {
  14926. state.offset = side === "left" ? leftWidth.value : -rightWidth.value;
  14927. if (!opened) {
  14928. opened = true;
  14929. emit("open", {
  14930. name: props2.name,
  14931. position: side
  14932. });
  14933. }
  14934. };
  14935. const close = (position) => {
  14936. state.offset = 0;
  14937. if (opened) {
  14938. opened = false;
  14939. emit("close", {
  14940. name: props2.name,
  14941. position
  14942. });
  14943. }
  14944. };
  14945. const toggle = (side) => {
  14946. const offset = Math.abs(state.offset);
  14947. const THRESHOLD = 0.15;
  14948. const threshold = opened ? 1 - THRESHOLD : THRESHOLD;
  14949. const width = side === "left" ? leftWidth.value : rightWidth.value;
  14950. if (width && offset > width * threshold) {
  14951. open(side);
  14952. } else {
  14953. close(side);
  14954. }
  14955. };
  14956. const onTouchStart = (event) => {
  14957. if (!props2.disabled) {
  14958. startOffset = state.offset;
  14959. touch.start(event);
  14960. }
  14961. };
  14962. const onTouchMove = (event) => {
  14963. if (props2.disabled) {
  14964. return;
  14965. }
  14966. const {
  14967. deltaX
  14968. } = touch;
  14969. touch.move(event);
  14970. if (touch.isHorizontal()) {
  14971. lockClick2 = true;
  14972. state.dragging = true;
  14973. const isEdge = !opened || deltaX.value * startOffset < 0;
  14974. if (isEdge) {
  14975. preventDefault(event, props2.stopPropagation);
  14976. }
  14977. state.offset = clamp(deltaX.value + startOffset, -rightWidth.value, leftWidth.value);
  14978. }
  14979. };
  14980. const onTouchEnd = () => {
  14981. if (state.dragging) {
  14982. state.dragging = false;
  14983. toggle(state.offset > 0 ? "left" : "right");
  14984. setTimeout(() => {
  14985. lockClick2 = false;
  14986. }, 0);
  14987. }
  14988. };
  14989. const onClick = (position = "outside", event) => {
  14990. if (isInBeforeClosing) return;
  14991. emit("click", position);
  14992. if (opened && !lockClick2) {
  14993. isInBeforeClosing = true;
  14994. callInterceptor(props2.beforeClose, {
  14995. args: [{
  14996. event,
  14997. name: props2.name,
  14998. position
  14999. }],
  15000. done: () => {
  15001. isInBeforeClosing = false;
  15002. close(position);
  15003. },
  15004. canceled: () => isInBeforeClosing = false,
  15005. error: () => isInBeforeClosing = false
  15006. });
  15007. }
  15008. };
  15009. const getClickHandler = (position, stop) => (event) => {
  15010. if (stop) {
  15011. event.stopPropagation();
  15012. }
  15013. if (lockClick2) {
  15014. return;
  15015. }
  15016. onClick(position, event);
  15017. };
  15018. const renderSideContent = (side, ref2) => {
  15019. const contentSlot = slots[side];
  15020. if (contentSlot) {
  15021. return createVNode("div", {
  15022. "ref": ref2,
  15023. "class": bem$6(side),
  15024. "onClick": getClickHandler(side, true)
  15025. }, [contentSlot()]);
  15026. }
  15027. };
  15028. useExpose({
  15029. open,
  15030. close
  15031. });
  15032. useClickAway(root, (event) => onClick("outside", event), {
  15033. eventName: "touchstart"
  15034. });
  15035. useEventListener("touchmove", onTouchMove, {
  15036. target: root
  15037. });
  15038. return () => {
  15039. var _a;
  15040. const wrapperStyle = {
  15041. transform: `translate3d(${state.offset}px, 0, 0)`,
  15042. transitionDuration: state.dragging ? "0s" : ".6s"
  15043. };
  15044. return createVNode("div", {
  15045. "ref": root,
  15046. "class": bem$6(),
  15047. "onClick": getClickHandler("cell", lockClick2),
  15048. "onTouchstartPassive": onTouchStart,
  15049. "onTouchend": onTouchEnd,
  15050. "onTouchcancel": onTouchEnd
  15051. }, [createVNode("div", {
  15052. "class": bem$6("wrapper"),
  15053. "style": wrapperStyle
  15054. }, [renderSideContent("left", leftRef), (_a = slots.default) == null ? void 0 : _a.call(slots), renderSideContent("right", rightRef)])]);
  15055. };
  15056. }
  15057. });
  15058. const SwipeCell = withInstall(stdin_default$c);
  15059. const [name$6, bem$5] = createNamespace("tabbar");
  15060. const tabbarProps = {
  15061. route: Boolean,
  15062. fixed: truthProp,
  15063. border: truthProp,
  15064. zIndex: numericProp,
  15065. placeholder: Boolean,
  15066. activeColor: String,
  15067. beforeChange: Function,
  15068. inactiveColor: String,
  15069. modelValue: makeNumericProp(0),
  15070. safeAreaInsetBottom: {
  15071. type: Boolean,
  15072. default: null
  15073. }
  15074. };
  15075. const TABBAR_KEY = Symbol(name$6);
  15076. var stdin_default$b = defineComponent({
  15077. name: name$6,
  15078. props: tabbarProps,
  15079. emits: ["change", "update:modelValue"],
  15080. setup(props2, {
  15081. emit,
  15082. slots
  15083. }) {
  15084. const root = ref();
  15085. const {
  15086. linkChildren
  15087. } = useChildren(TABBAR_KEY);
  15088. const renderPlaceholder = usePlaceholder(root, bem$5);
  15089. const enableSafeArea = () => {
  15090. var _a;
  15091. return (_a = props2.safeAreaInsetBottom) != null ? _a : props2.fixed;
  15092. };
  15093. const renderTabbar = () => {
  15094. var _a;
  15095. const {
  15096. fixed,
  15097. zIndex,
  15098. border
  15099. } = props2;
  15100. return createVNode("div", {
  15101. "ref": root,
  15102. "role": "tablist",
  15103. "style": getZIndexStyle(zIndex),
  15104. "class": [bem$5({
  15105. fixed
  15106. }), {
  15107. [BORDER_TOP_BOTTOM]: border,
  15108. "van-safe-area-bottom": enableSafeArea()
  15109. }]
  15110. }, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
  15111. };
  15112. const setActive = (active, afterChange) => {
  15113. callInterceptor(props2.beforeChange, {
  15114. args: [active],
  15115. done() {
  15116. emit("update:modelValue", active);
  15117. emit("change", active);
  15118. afterChange();
  15119. }
  15120. });
  15121. };
  15122. linkChildren({
  15123. props: props2,
  15124. setActive
  15125. });
  15126. return () => {
  15127. if (props2.fixed && props2.placeholder) {
  15128. return renderPlaceholder(renderTabbar);
  15129. }
  15130. return renderTabbar();
  15131. };
  15132. }
  15133. });
  15134. const Tabbar = withInstall(stdin_default$b);
  15135. const [name$5, bem$4] = createNamespace("tabbar-item");
  15136. const tabbarItemProps = extend({}, routeProps, {
  15137. dot: Boolean,
  15138. icon: String,
  15139. name: numericProp,
  15140. badge: numericProp,
  15141. badgeProps: Object,
  15142. iconPrefix: String
  15143. });
  15144. var stdin_default$a = defineComponent({
  15145. name: name$5,
  15146. props: tabbarItemProps,
  15147. emits: ["click"],
  15148. setup(props2, {
  15149. emit,
  15150. slots
  15151. }) {
  15152. const route2 = useRoute();
  15153. const vm = getCurrentInstance().proxy;
  15154. const {
  15155. parent,
  15156. index
  15157. } = useParent(TABBAR_KEY);
  15158. if (!parent) {
  15159. if (process.env.NODE_ENV !== "production") {
  15160. console.error("[Vant] <TabbarItem> must be a child component of <Tabbar>.");
  15161. }
  15162. return;
  15163. }
  15164. const active = computed(() => {
  15165. var _a;
  15166. const {
  15167. route: route22,
  15168. modelValue
  15169. } = parent.props;
  15170. if (route22 && "$route" in vm) {
  15171. const {
  15172. $route
  15173. } = vm;
  15174. const {
  15175. to
  15176. } = props2;
  15177. const config = isObject(to) ? to : {
  15178. path: to
  15179. };
  15180. return !!$route.matched.find((val) => {
  15181. const pathMatched = "path" in config && config.path === val.path;
  15182. const nameMatched = "name" in config && config.name === val.name;
  15183. return pathMatched || nameMatched;
  15184. });
  15185. }
  15186. return ((_a = props2.name) != null ? _a : index.value) === modelValue;
  15187. });
  15188. const onClick = (event) => {
  15189. var _a;
  15190. if (!active.value) {
  15191. parent.setActive((_a = props2.name) != null ? _a : index.value, route2);
  15192. }
  15193. emit("click", event);
  15194. };
  15195. const renderIcon = () => {
  15196. if (slots.icon) {
  15197. return slots.icon({
  15198. active: active.value
  15199. });
  15200. }
  15201. if (props2.icon) {
  15202. return createVNode(Icon, {
  15203. "name": props2.icon,
  15204. "classPrefix": props2.iconPrefix
  15205. }, null);
  15206. }
  15207. };
  15208. return () => {
  15209. var _a;
  15210. const {
  15211. dot,
  15212. badge
  15213. } = props2;
  15214. const {
  15215. activeColor,
  15216. inactiveColor
  15217. } = parent.props;
  15218. const color = active.value ? activeColor : inactiveColor;
  15219. return createVNode("div", {
  15220. "role": "tab",
  15221. "class": bem$4({
  15222. active: active.value
  15223. }),
  15224. "style": {
  15225. color
  15226. },
  15227. "tabindex": 0,
  15228. "aria-selected": active.value,
  15229. "onClick": onClick
  15230. }, [createVNode(Badge, mergeProps({
  15231. "dot": dot,
  15232. "class": bem$4("icon"),
  15233. "content": badge
  15234. }, props2.badgeProps), {
  15235. default: renderIcon
  15236. }), createVNode("div", {
  15237. "class": bem$4("text")
  15238. }, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
  15239. active: active.value
  15240. })])]);
  15241. };
  15242. }
  15243. });
  15244. const TabbarItem = withInstall(stdin_default$a);
  15245. const [name$4, bem$3] = createNamespace("text-ellipsis");
  15246. const textEllipsisProps = {
  15247. rows: makeNumericProp(1),
  15248. dots: makeStringProp("..."),
  15249. content: makeStringProp(""),
  15250. expandText: makeStringProp(""),
  15251. collapseText: makeStringProp(""),
  15252. position: makeStringProp("end")
  15253. };
  15254. var stdin_default$9 = defineComponent({
  15255. name: name$4,
  15256. props: textEllipsisProps,
  15257. emits: ["clickAction"],
  15258. setup(props2, {
  15259. emit,
  15260. slots
  15261. }) {
  15262. const text = ref(props2.content);
  15263. const expanded = ref(false);
  15264. const hasAction = ref(false);
  15265. const root = ref();
  15266. const actionRef = ref();
  15267. let needRecalculate = false;
  15268. const actionText = computed(() => expanded.value ? props2.collapseText : props2.expandText);
  15269. const pxToNum = (value) => {
  15270. if (!value) return 0;
  15271. const match = value.match(/^\d*(\.\d*)?/);
  15272. return match ? Number(match[0]) : 0;
  15273. };
  15274. const cloneContainer = () => {
  15275. if (!root.value || !root.value.isConnected) return;
  15276. const originStyle = window.getComputedStyle(root.value);
  15277. const container = document.createElement("div");
  15278. const styleNames = Array.prototype.slice.apply(originStyle);
  15279. styleNames.forEach((name2) => {
  15280. container.style.setProperty(name2, originStyle.getPropertyValue(name2));
  15281. });
  15282. container.style.position = "fixed";
  15283. container.style.zIndex = "-9999";
  15284. container.style.top = "-9999px";
  15285. container.style.height = "auto";
  15286. container.style.minHeight = "auto";
  15287. container.style.maxHeight = "auto";
  15288. container.innerText = props2.content;
  15289. document.body.appendChild(container);
  15290. return container;
  15291. };
  15292. const calcEllipsisText = (container, maxHeight) => {
  15293. var _a, _b;
  15294. const {
  15295. content,
  15296. position,
  15297. dots
  15298. } = props2;
  15299. const end = content.length;
  15300. const middle = 0 + end >> 1;
  15301. const actionHTML = slots.action ? (_b = (_a = actionRef.value) == null ? void 0 : _a.outerHTML) != null ? _b : "" : props2.expandText;
  15302. const calcEllipse = () => {
  15303. const tail = (left, right) => {
  15304. if (right - left <= 1) {
  15305. if (position === "end") {
  15306. return content.slice(0, left) + dots;
  15307. }
  15308. return dots + content.slice(right, end);
  15309. }
  15310. const middle2 = Math.round((left + right) / 2);
  15311. if (position === "end") {
  15312. container.innerText = content.slice(0, middle2) + dots;
  15313. } else {
  15314. container.innerText = dots + content.slice(middle2, end);
  15315. }
  15316. container.innerHTML += actionHTML;
  15317. if (container.offsetHeight > maxHeight) {
  15318. if (position === "end") {
  15319. return tail(left, middle2);
  15320. }
  15321. return tail(middle2, right);
  15322. }
  15323. if (position === "end") {
  15324. return tail(middle2, right);
  15325. }
  15326. return tail(left, middle2);
  15327. };
  15328. return tail(0, end);
  15329. };
  15330. const middleTail = (leftPart, rightPart) => {
  15331. if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
  15332. return content.slice(0, leftPart[0]) + dots + content.slice(rightPart[1], end);
  15333. }
  15334. const leftMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
  15335. const rightMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
  15336. container.innerText = props2.content.slice(0, leftMiddle) + props2.dots + props2.content.slice(rightMiddle, end);
  15337. container.innerHTML += actionHTML;
  15338. if (container.offsetHeight >= maxHeight) {
  15339. return middleTail([leftPart[0], leftMiddle], [rightMiddle, rightPart[1]]);
  15340. }
  15341. return middleTail([leftMiddle, leftPart[1]], [rightPart[0], rightMiddle]);
  15342. };
  15343. return props2.position === "middle" ? middleTail([0, middle], [middle, end]) : calcEllipse();
  15344. };
  15345. const calcEllipsised = () => {
  15346. const container = cloneContainer();
  15347. if (!container) {
  15348. needRecalculate = true;
  15349. return;
  15350. }
  15351. const {
  15352. paddingBottom,
  15353. paddingTop,
  15354. lineHeight
  15355. } = container.style;
  15356. const maxHeight = Math.ceil((Number(props2.rows) + 0.5) * pxToNum(lineHeight) + pxToNum(paddingTop) + pxToNum(paddingBottom));
  15357. if (maxHeight < container.offsetHeight) {
  15358. hasAction.value = true;
  15359. text.value = calcEllipsisText(container, maxHeight);
  15360. } else {
  15361. hasAction.value = false;
  15362. text.value = props2.content;
  15363. }
  15364. document.body.removeChild(container);
  15365. };
  15366. const toggle = (isExpanded = !expanded.value) => {
  15367. expanded.value = isExpanded;
  15368. };
  15369. const onClickAction = (event) => {
  15370. toggle();
  15371. emit("clickAction", event);
  15372. };
  15373. const renderAction = () => {
  15374. const action = slots.action ? slots.action({
  15375. expanded: expanded.value
  15376. }) : actionText.value;
  15377. return createVNode("span", {
  15378. "ref": actionRef,
  15379. "class": bem$3("action"),
  15380. "onClick": onClickAction
  15381. }, [action]);
  15382. };
  15383. onMounted(() => {
  15384. calcEllipsised();
  15385. if (slots.action) {
  15386. nextTick(calcEllipsised);
  15387. }
  15388. });
  15389. onActivated(() => {
  15390. if (needRecalculate) {
  15391. needRecalculate = false;
  15392. calcEllipsised();
  15393. }
  15394. });
  15395. watch([windowWidth, () => [props2.content, props2.rows, props2.position]], calcEllipsised);
  15396. useExpose({
  15397. toggle
  15398. });
  15399. return () => createVNode("div", {
  15400. "ref": root,
  15401. "class": bem$3()
  15402. }, [expanded.value ? props2.content : text.value, hasAction.value ? renderAction() : null]);
  15403. }
  15404. });
  15405. const TextEllipsis = withInstall(stdin_default$9);
  15406. const [name$3] = createNamespace("time-picker");
  15407. const validateTime = (val) => /^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$/.test(val);
  15408. const fullColumns = ["hour", "minute", "second"];
  15409. const timePickerProps = extend({}, sharedProps, {
  15410. minHour: makeNumericProp(0),
  15411. maxHour: makeNumericProp(23),
  15412. minMinute: makeNumericProp(0),
  15413. maxMinute: makeNumericProp(59),
  15414. minSecond: makeNumericProp(0),
  15415. maxSecond: makeNumericProp(59),
  15416. minTime: {
  15417. type: String,
  15418. validator: validateTime
  15419. },
  15420. maxTime: {
  15421. type: String,
  15422. validator: validateTime
  15423. },
  15424. columnsType: {
  15425. type: Array,
  15426. default: () => ["hour", "minute"]
  15427. }
  15428. });
  15429. var stdin_default$8 = defineComponent({
  15430. name: name$3,
  15431. props: timePickerProps,
  15432. emits: ["confirm", "cancel", "change", "update:modelValue"],
  15433. setup(props2, {
  15434. emit,
  15435. slots
  15436. }) {
  15437. const currentValues = ref(props2.modelValue);
  15438. const pickerRef = ref();
  15439. const getValidTime = (time) => {
  15440. const timeLimitArr = time.split(":");
  15441. return fullColumns.map((col, i) => props2.columnsType.includes(col) ? timeLimitArr[i] : "00");
  15442. };
  15443. const confirm = () => {
  15444. var _a;
  15445. return (_a = pickerRef.value) == null ? void 0 : _a.confirm();
  15446. };
  15447. const getSelectedTime = () => currentValues.value;
  15448. const columns = computed(() => {
  15449. let {
  15450. minHour,
  15451. maxHour,
  15452. minMinute,
  15453. maxMinute,
  15454. minSecond,
  15455. maxSecond
  15456. } = props2;
  15457. if (props2.minTime || props2.maxTime) {
  15458. const fullTime = {
  15459. hour: 0,
  15460. minute: 0,
  15461. second: 0
  15462. };
  15463. props2.columnsType.forEach((col, i) => {
  15464. var _a;
  15465. fullTime[col] = (_a = currentValues.value[i]) != null ? _a : 0;
  15466. });
  15467. const {
  15468. hour,
  15469. minute
  15470. } = fullTime;
  15471. if (props2.minTime) {
  15472. const [minH, minM, minS] = getValidTime(props2.minTime);
  15473. minHour = minH;
  15474. minMinute = +hour <= +minHour ? minM : "00";
  15475. minSecond = +hour <= +minHour && +minute <= +minMinute ? minS : "00";
  15476. }
  15477. if (props2.maxTime) {
  15478. const [maxH, maxM, maxS] = getValidTime(props2.maxTime);
  15479. maxHour = maxH;
  15480. maxMinute = +hour >= +maxHour ? maxM : "59";
  15481. maxSecond = +hour >= +maxHour && +minute >= +maxMinute ? maxS : "59";
  15482. }
  15483. }
  15484. return props2.columnsType.map((type) => {
  15485. const {
  15486. filter,
  15487. formatter
  15488. } = props2;
  15489. switch (type) {
  15490. case "hour":
  15491. return genOptions(+minHour, +maxHour, type, formatter, filter, currentValues.value);
  15492. case "minute":
  15493. return genOptions(+minMinute, +maxMinute, type, formatter, filter, currentValues.value);
  15494. case "second":
  15495. return genOptions(+minSecond, +maxSecond, type, formatter, filter, currentValues.value);
  15496. default:
  15497. if (process.env.NODE_ENV !== "production") {
  15498. throw new Error(`[Vant] DatePicker: unsupported columns type: ${type}`);
  15499. }
  15500. return [];
  15501. }
  15502. });
  15503. });
  15504. watch(currentValues, (newValues) => {
  15505. if (!isSameValue(newValues, props2.modelValue)) {
  15506. emit("update:modelValue", newValues);
  15507. }
  15508. });
  15509. watch(() => props2.modelValue, (newValues) => {
  15510. newValues = formatValueRange(newValues, columns.value);
  15511. if (!isSameValue(newValues, currentValues.value)) {
  15512. currentValues.value = newValues;
  15513. }
  15514. }, {
  15515. immediate: true
  15516. });
  15517. const onChange = (...args) => emit("change", ...args);
  15518. const onCancel = (...args) => emit("cancel", ...args);
  15519. const onConfirm = (...args) => emit("confirm", ...args);
  15520. useExpose({
  15521. confirm,
  15522. getSelectedTime
  15523. });
  15524. return () => createVNode(Picker, mergeProps({
  15525. "ref": pickerRef,
  15526. "modelValue": currentValues.value,
  15527. "onUpdate:modelValue": ($event) => currentValues.value = $event,
  15528. "columns": columns.value,
  15529. "onChange": onChange,
  15530. "onCancel": onCancel,
  15531. "onConfirm": onConfirm
  15532. }, pick(props2, pickerInheritKeys)), slots);
  15533. }
  15534. });
  15535. const TimePicker = withInstall(stdin_default$8);
  15536. const [name$2, bem$2] = createNamespace("tree-select");
  15537. const treeSelectProps = {
  15538. max: makeNumericProp(Infinity),
  15539. items: makeArrayProp(),
  15540. height: makeNumericProp(300),
  15541. selectedIcon: makeStringProp("success"),
  15542. mainActiveIndex: makeNumericProp(0),
  15543. activeId: {
  15544. type: [Number, String, Array],
  15545. default: 0
  15546. }
  15547. };
  15548. var stdin_default$7 = defineComponent({
  15549. name: name$2,
  15550. props: treeSelectProps,
  15551. emits: ["clickNav", "clickItem", "update:activeId", "update:mainActiveIndex"],
  15552. setup(props2, {
  15553. emit,
  15554. slots
  15555. }) {
  15556. const isActiveItem = (id) => Array.isArray(props2.activeId) ? props2.activeId.includes(id) : props2.activeId === id;
  15557. const renderSubItem = (item) => {
  15558. const onClick = () => {
  15559. if (item.disabled) {
  15560. return;
  15561. }
  15562. let activeId;
  15563. if (Array.isArray(props2.activeId)) {
  15564. activeId = props2.activeId.slice();
  15565. const index = activeId.indexOf(item.id);
  15566. if (index !== -1) {
  15567. activeId.splice(index, 1);
  15568. } else if (activeId.length < +props2.max) {
  15569. activeId.push(item.id);
  15570. }
  15571. } else {
  15572. activeId = item.id;
  15573. }
  15574. emit("update:activeId", activeId);
  15575. emit("clickItem", item);
  15576. };
  15577. return createVNode("div", {
  15578. "key": item.id,
  15579. "class": ["van-ellipsis", bem$2("item", {
  15580. active: isActiveItem(item.id),
  15581. disabled: item.disabled
  15582. })],
  15583. "onClick": onClick
  15584. }, [item.text, isActiveItem(item.id) && createVNode(Icon, {
  15585. "name": props2.selectedIcon,
  15586. "class": bem$2("selected")
  15587. }, null)]);
  15588. };
  15589. const onSidebarChange = (index) => {
  15590. emit("update:mainActiveIndex", index);
  15591. };
  15592. const onClickSidebarItem = (index) => emit("clickNav", index);
  15593. const renderSidebar = () => {
  15594. const Items = props2.items.map((item) => createVNode(SidebarItem, {
  15595. "dot": item.dot,
  15596. "badge": item.badge,
  15597. "class": [bem$2("nav-item"), item.className],
  15598. "disabled": item.disabled,
  15599. "onClick": onClickSidebarItem
  15600. }, {
  15601. title: () => slots["nav-text"] ? slots["nav-text"](item) : item.text
  15602. }));
  15603. return createVNode(Sidebar, {
  15604. "class": bem$2("nav"),
  15605. "modelValue": props2.mainActiveIndex,
  15606. "onChange": onSidebarChange
  15607. }, {
  15608. default: () => [Items]
  15609. });
  15610. };
  15611. const renderContent = () => {
  15612. if (slots.content) {
  15613. return slots.content();
  15614. }
  15615. const selected = props2.items[+props2.mainActiveIndex] || {};
  15616. if (selected.children) {
  15617. return selected.children.map(renderSubItem);
  15618. }
  15619. };
  15620. return () => createVNode("div", {
  15621. "class": bem$2(),
  15622. "style": {
  15623. height: addUnit(props2.height)
  15624. }
  15625. }, [renderSidebar(), createVNode("div", {
  15626. "class": bem$2("content")
  15627. }, [renderContent()])]);
  15628. }
  15629. });
  15630. const TreeSelect = withInstall(stdin_default$7);
  15631. const [name$1, bem$1, t] = createNamespace("uploader");
  15632. function readFileContent(file, resultType) {
  15633. return new Promise((resolve) => {
  15634. if (resultType === "file") {
  15635. resolve();
  15636. return;
  15637. }
  15638. const reader = new FileReader();
  15639. reader.onload = (event) => {
  15640. resolve(event.target.result);
  15641. };
  15642. if (resultType === "dataUrl") {
  15643. reader.readAsDataURL(file);
  15644. } else if (resultType === "text") {
  15645. reader.readAsText(file);
  15646. }
  15647. });
  15648. }
  15649. function isOversize(items, maxSize) {
  15650. return toArray(items).some((item) => {
  15651. if (item.file) {
  15652. if (isFunction(maxSize)) {
  15653. return maxSize(item.file);
  15654. }
  15655. return item.file.size > +maxSize;
  15656. }
  15657. return false;
  15658. });
  15659. }
  15660. function filterFiles(items, maxSize) {
  15661. const valid = [];
  15662. const invalid = [];
  15663. items.forEach((item) => {
  15664. if (isOversize(item, maxSize)) {
  15665. invalid.push(item);
  15666. } else {
  15667. valid.push(item);
  15668. }
  15669. });
  15670. return { valid, invalid };
  15671. }
  15672. const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg|avif)/i;
  15673. const isImageUrl = (url) => IMAGE_REGEXP.test(url);
  15674. function isImageFile(item) {
  15675. if (item.isImage) {
  15676. return true;
  15677. }
  15678. if (item.file && item.file.type) {
  15679. return item.file.type.indexOf("image") === 0;
  15680. }
  15681. if (item.url) {
  15682. return isImageUrl(item.url);
  15683. }
  15684. if (typeof item.content === "string") {
  15685. return item.content.indexOf("data:image") === 0;
  15686. }
  15687. return false;
  15688. }
  15689. var stdin_default$6 = defineComponent({
  15690. props: {
  15691. name: numericProp,
  15692. item: makeRequiredProp(Object),
  15693. index: Number,
  15694. imageFit: String,
  15695. lazyLoad: Boolean,
  15696. deletable: Boolean,
  15697. reupload: Boolean,
  15698. previewSize: [Number, String, Array],
  15699. beforeDelete: Function
  15700. },
  15701. emits: ["delete", "preview", "reupload"],
  15702. setup(props2, {
  15703. emit,
  15704. slots
  15705. }) {
  15706. const renderMask = () => {
  15707. const {
  15708. status,
  15709. message
  15710. } = props2.item;
  15711. if (status === "uploading" || status === "failed") {
  15712. const MaskIcon = status === "failed" ? createVNode(Icon, {
  15713. "name": "close",
  15714. "class": bem$1("mask-icon")
  15715. }, null) : createVNode(Loading, {
  15716. "class": bem$1("loading")
  15717. }, null);
  15718. const showMessage = isDef(message) && message !== "";
  15719. return createVNode("div", {
  15720. "class": bem$1("mask")
  15721. }, [MaskIcon, showMessage && createVNode("div", {
  15722. "class": bem$1("mask-message")
  15723. }, [message])]);
  15724. }
  15725. };
  15726. const onDelete = (event) => {
  15727. const {
  15728. name: name2,
  15729. item,
  15730. index,
  15731. beforeDelete
  15732. } = props2;
  15733. event.stopPropagation();
  15734. callInterceptor(beforeDelete, {
  15735. args: [item, {
  15736. name: name2,
  15737. index
  15738. }],
  15739. done: () => emit("delete")
  15740. });
  15741. };
  15742. const onPreview = () => emit("preview");
  15743. const onReupload = () => emit("reupload");
  15744. const renderDeleteIcon = () => {
  15745. if (props2.deletable && props2.item.status !== "uploading") {
  15746. const slot = slots["preview-delete"];
  15747. return createVNode("div", {
  15748. "role": "button",
  15749. "class": bem$1("preview-delete", {
  15750. shadow: !slot
  15751. }),
  15752. "tabindex": 0,
  15753. "aria-label": t("delete"),
  15754. "onClick": onDelete
  15755. }, [slot ? slot() : createVNode(Icon, {
  15756. "name": "cross",
  15757. "class": bem$1("preview-delete-icon")
  15758. }, null)]);
  15759. }
  15760. };
  15761. const renderCover = () => {
  15762. if (slots["preview-cover"]) {
  15763. const {
  15764. index,
  15765. item
  15766. } = props2;
  15767. return createVNode("div", {
  15768. "class": bem$1("preview-cover")
  15769. }, [slots["preview-cover"](extend({
  15770. index
  15771. }, item))]);
  15772. }
  15773. };
  15774. const renderPreview = () => {
  15775. const {
  15776. item,
  15777. lazyLoad,
  15778. imageFit,
  15779. previewSize,
  15780. reupload
  15781. } = props2;
  15782. if (isImageFile(item)) {
  15783. return createVNode(Image$1, {
  15784. "fit": imageFit,
  15785. "src": item.objectUrl || item.content || item.url,
  15786. "class": bem$1("preview-image"),
  15787. "width": Array.isArray(previewSize) ? previewSize[0] : previewSize,
  15788. "height": Array.isArray(previewSize) ? previewSize[1] : previewSize,
  15789. "lazyLoad": lazyLoad,
  15790. "onClick": reupload ? onReupload : onPreview
  15791. }, {
  15792. default: renderCover
  15793. });
  15794. }
  15795. return createVNode("div", {
  15796. "class": bem$1("file"),
  15797. "style": getSizeStyle(props2.previewSize)
  15798. }, [createVNode(Icon, {
  15799. "class": bem$1("file-icon"),
  15800. "name": "description"
  15801. }, null), createVNode("div", {
  15802. "class": [bem$1("file-name"), "van-ellipsis"]
  15803. }, [item.file ? item.file.name : item.url]), renderCover()]);
  15804. };
  15805. return () => createVNode("div", {
  15806. "class": bem$1("preview")
  15807. }, [renderPreview(), renderMask(), renderDeleteIcon()]);
  15808. }
  15809. });
  15810. const uploaderProps = {
  15811. name: makeNumericProp(""),
  15812. accept: makeStringProp("image/*"),
  15813. capture: String,
  15814. multiple: Boolean,
  15815. disabled: Boolean,
  15816. readonly: Boolean,
  15817. lazyLoad: Boolean,
  15818. maxCount: makeNumericProp(Infinity),
  15819. imageFit: makeStringProp("cover"),
  15820. resultType: makeStringProp("dataUrl"),
  15821. uploadIcon: makeStringProp("photograph"),
  15822. uploadText: String,
  15823. deletable: truthProp,
  15824. reupload: Boolean,
  15825. afterRead: Function,
  15826. showUpload: truthProp,
  15827. modelValue: makeArrayProp(),
  15828. beforeRead: Function,
  15829. beforeDelete: Function,
  15830. previewSize: [Number, String, Array],
  15831. previewImage: truthProp,
  15832. previewOptions: Object,
  15833. previewFullImage: truthProp,
  15834. maxSize: {
  15835. type: [Number, String, Function],
  15836. default: Infinity
  15837. }
  15838. };
  15839. var stdin_default$5 = defineComponent({
  15840. name: name$1,
  15841. props: uploaderProps,
  15842. emits: ["delete", "oversize", "clickUpload", "closePreview", "clickPreview", "clickReupload", "update:modelValue"],
  15843. setup(props2, {
  15844. emit,
  15845. slots
  15846. }) {
  15847. const inputRef = ref();
  15848. const urls = [];
  15849. const reuploadIndex = ref(-1);
  15850. const isReuploading = ref(false);
  15851. const getDetail = (index = props2.modelValue.length) => ({
  15852. name: props2.name,
  15853. index
  15854. });
  15855. const resetInput = () => {
  15856. if (inputRef.value) {
  15857. inputRef.value.value = "";
  15858. }
  15859. };
  15860. const onAfterRead = (items) => {
  15861. resetInput();
  15862. if (isOversize(items, props2.maxSize)) {
  15863. if (Array.isArray(items)) {
  15864. const result = filterFiles(items, props2.maxSize);
  15865. items = result.valid;
  15866. emit("oversize", result.invalid, getDetail());
  15867. if (!items.length) {
  15868. return;
  15869. }
  15870. } else {
  15871. emit("oversize", items, getDetail());
  15872. return;
  15873. }
  15874. }
  15875. items = reactive(items);
  15876. if (reuploadIndex.value > -1) {
  15877. const arr = [...props2.modelValue];
  15878. arr.splice(reuploadIndex.value, 1, items);
  15879. emit("update:modelValue", arr);
  15880. reuploadIndex.value = -1;
  15881. } else {
  15882. emit("update:modelValue", [...props2.modelValue, ...toArray(items)]);
  15883. }
  15884. if (props2.afterRead) {
  15885. props2.afterRead(items, getDetail());
  15886. }
  15887. };
  15888. const readFile = (files) => {
  15889. const {
  15890. maxCount,
  15891. modelValue,
  15892. resultType
  15893. } = props2;
  15894. if (Array.isArray(files)) {
  15895. const remainCount = +maxCount - modelValue.length;
  15896. if (files.length > remainCount) {
  15897. files = files.slice(0, remainCount);
  15898. }
  15899. Promise.all(files.map((file) => readFileContent(file, resultType))).then((contents) => {
  15900. const fileList = files.map((file, index) => {
  15901. const result = {
  15902. file,
  15903. status: "",
  15904. message: "",
  15905. objectUrl: URL.createObjectURL(file)
  15906. };
  15907. if (contents[index]) {
  15908. result.content = contents[index];
  15909. }
  15910. return result;
  15911. });
  15912. onAfterRead(fileList);
  15913. });
  15914. } else {
  15915. readFileContent(files, resultType).then((content) => {
  15916. const result = {
  15917. file: files,
  15918. status: "",
  15919. message: "",
  15920. objectUrl: URL.createObjectURL(files)
  15921. };
  15922. if (content) {
  15923. result.content = content;
  15924. }
  15925. onAfterRead(result);
  15926. });
  15927. }
  15928. };
  15929. const onChange = (event) => {
  15930. const {
  15931. files
  15932. } = event.target;
  15933. if (props2.disabled || !files || !files.length) {
  15934. return;
  15935. }
  15936. const file = files.length === 1 ? files[0] : [].slice.call(files);
  15937. if (props2.beforeRead) {
  15938. const response = props2.beforeRead(file, getDetail());
  15939. if (!response) {
  15940. resetInput();
  15941. return;
  15942. }
  15943. if (isPromise(response)) {
  15944. response.then((data) => {
  15945. if (data) {
  15946. readFile(data);
  15947. } else {
  15948. readFile(file);
  15949. }
  15950. }).catch(resetInput);
  15951. return;
  15952. }
  15953. }
  15954. readFile(file);
  15955. };
  15956. let imagePreview;
  15957. const onClosePreview = () => emit("closePreview");
  15958. const previewImage = (item) => {
  15959. if (props2.previewFullImage) {
  15960. const imageFiles = props2.modelValue.filter(isImageFile);
  15961. const images = imageFiles.map((item2) => {
  15962. if (item2.objectUrl && !item2.url && item2.status !== "failed") {
  15963. item2.url = item2.objectUrl;
  15964. urls.push(item2.url);
  15965. }
  15966. return item2.url;
  15967. }).filter(Boolean);
  15968. imagePreview = showImagePreview(extend({
  15969. images,
  15970. startPosition: imageFiles.indexOf(item),
  15971. onClose: onClosePreview
  15972. }, props2.previewOptions));
  15973. }
  15974. };
  15975. const closeImagePreview = () => {
  15976. if (imagePreview) {
  15977. imagePreview.close();
  15978. }
  15979. };
  15980. const deleteFile = (item, index) => {
  15981. const fileList = props2.modelValue.slice(0);
  15982. fileList.splice(index, 1);
  15983. emit("update:modelValue", fileList);
  15984. emit("delete", item, getDetail(index));
  15985. };
  15986. const reuploadFile = (index) => {
  15987. isReuploading.value = true;
  15988. reuploadIndex.value = index;
  15989. nextTick(() => chooseFile());
  15990. };
  15991. const onInputClick = () => {
  15992. if (!isReuploading.value) {
  15993. reuploadIndex.value = -1;
  15994. }
  15995. isReuploading.value = false;
  15996. };
  15997. const renderPreviewItem = (item, index) => {
  15998. const needPickData = ["imageFit", "deletable", "reupload", "previewSize", "beforeDelete"];
  15999. const previewData = extend(pick(props2, needPickData), pick(item, needPickData, true));
  16000. return createVNode(stdin_default$6, mergeProps({
  16001. "item": item,
  16002. "index": index,
  16003. "onClick": () => emit(props2.reupload ? "clickReupload" : "clickPreview", item, getDetail(index)),
  16004. "onDelete": () => deleteFile(item, index),
  16005. "onPreview": () => previewImage(item),
  16006. "onReupload": () => reuploadFile(index)
  16007. }, pick(props2, ["name", "lazyLoad"]), previewData), pick(slots, ["preview-cover", "preview-delete"]));
  16008. };
  16009. const renderPreviewList = () => {
  16010. if (props2.previewImage) {
  16011. return props2.modelValue.map(renderPreviewItem);
  16012. }
  16013. };
  16014. const onClickUpload = (event) => emit("clickUpload", event);
  16015. const renderUpload = () => {
  16016. const lessThanMax = props2.modelValue.length < +props2.maxCount;
  16017. const Input = props2.readonly ? null : createVNode("input", {
  16018. "ref": inputRef,
  16019. "type": "file",
  16020. "class": bem$1("input"),
  16021. "accept": props2.accept,
  16022. "capture": props2.capture,
  16023. "multiple": props2.multiple && reuploadIndex.value === -1,
  16024. "disabled": props2.disabled,
  16025. "onChange": onChange,
  16026. "onClick": onInputClick
  16027. }, null);
  16028. if (slots.default) {
  16029. return withDirectives(createVNode("div", {
  16030. "class": bem$1("input-wrapper"),
  16031. "onClick": onClickUpload
  16032. }, [slots.default(), Input]), [[vShow, lessThanMax]]);
  16033. }
  16034. return withDirectives(createVNode("div", {
  16035. "class": bem$1("upload", {
  16036. readonly: props2.readonly
  16037. }),
  16038. "style": getSizeStyle(props2.previewSize),
  16039. "onClick": onClickUpload
  16040. }, [createVNode(Icon, {
  16041. "name": props2.uploadIcon,
  16042. "class": bem$1("upload-icon")
  16043. }, null), props2.uploadText && createVNode("span", {
  16044. "class": bem$1("upload-text")
  16045. }, [props2.uploadText]), Input]), [[vShow, props2.showUpload && lessThanMax]]);
  16046. };
  16047. const chooseFile = () => {
  16048. if (inputRef.value && !props2.disabled) {
  16049. inputRef.value.click();
  16050. }
  16051. };
  16052. onBeforeUnmount(() => {
  16053. urls.forEach((url) => URL.revokeObjectURL(url));
  16054. });
  16055. useExpose({
  16056. chooseFile,
  16057. reuploadFile,
  16058. closeImagePreview
  16059. });
  16060. useCustomFieldValue(() => props2.modelValue);
  16061. return () => createVNode("div", {
  16062. "class": bem$1()
  16063. }, [createVNode("div", {
  16064. "class": bem$1("wrapper", {
  16065. disabled: props2.disabled
  16066. })
  16067. }, [renderPreviewList(), renderUpload()])]);
  16068. }
  16069. });
  16070. const Uploader = withInstall(stdin_default$5);
  16071. const [name, bem] = createNamespace("watermark");
  16072. const watermarkProps = {
  16073. gapX: makeNumberProp(0),
  16074. gapY: makeNumberProp(0),
  16075. image: String,
  16076. width: makeNumberProp(100),
  16077. height: makeNumberProp(100),
  16078. rotate: makeNumericProp(-22),
  16079. zIndex: numericProp,
  16080. content: String,
  16081. opacity: numericProp,
  16082. fullPage: truthProp,
  16083. textColor: makeStringProp("#dcdee0")
  16084. };
  16085. var stdin_default$4 = defineComponent({
  16086. name,
  16087. props: watermarkProps,
  16088. setup(props2, {
  16089. slots
  16090. }) {
  16091. const svgElRef = ref();
  16092. const watermarkUrl = ref("");
  16093. const imageBase64 = ref("");
  16094. const renderWatermark = () => {
  16095. const rotateStyle = {
  16096. transformOrigin: "center",
  16097. transform: `rotate(${props2.rotate}deg)`
  16098. };
  16099. const svgInner = () => {
  16100. if (props2.image && !slots.content) {
  16101. return createVNode("image", {
  16102. "href": imageBase64.value,
  16103. "xlink:href": imageBase64.value,
  16104. "x": "0",
  16105. "y": "0",
  16106. "width": props2.width,
  16107. "height": props2.height,
  16108. "style": rotateStyle
  16109. }, null);
  16110. }
  16111. return createVNode("foreignObject", {
  16112. "x": "0",
  16113. "y": "0",
  16114. "width": props2.width,
  16115. "height": props2.height
  16116. }, [createVNode("div", {
  16117. "xmlns": "http://www.w3.org/1999/xhtml",
  16118. "style": rotateStyle
  16119. }, [slots.content ? slots.content() : createVNode("span", {
  16120. "style": {
  16121. color: props2.textColor
  16122. }
  16123. }, [props2.content])])]);
  16124. };
  16125. const svgWidth = props2.width + props2.gapX;
  16126. const svgHeight = props2.height + props2.gapY;
  16127. return createVNode("svg", {
  16128. "viewBox": `0 0 ${svgWidth} ${svgHeight}`,
  16129. "width": svgWidth,
  16130. "height": svgHeight,
  16131. "xmlns": "http://www.w3.org/2000/svg",
  16132. "xmlns:xlink": "http://www.w3.org/1999/xlink",
  16133. "style": {
  16134. padding: `0 ${props2.gapX}px ${props2.gapY}px 0`,
  16135. opacity: props2.opacity
  16136. }
  16137. }, [svgInner()]);
  16138. };
  16139. const makeImageToBase64 = (url) => {
  16140. const canvas = document.createElement("canvas");
  16141. const image = new Image();
  16142. image.crossOrigin = "anonymous";
  16143. image.referrerPolicy = "no-referrer";
  16144. image.onload = () => {
  16145. canvas.width = image.naturalWidth;
  16146. canvas.height = image.naturalHeight;
  16147. const ctx = canvas.getContext("2d");
  16148. ctx == null ? void 0 : ctx.drawImage(image, 0, 0);
  16149. imageBase64.value = canvas.toDataURL();
  16150. };
  16151. image.src = url;
  16152. };
  16153. const makeSvgToBlobUrl = (svgStr) => {
  16154. const svgBlob = new Blob([svgStr], {
  16155. type: "image/svg+xml"
  16156. });
  16157. return URL.createObjectURL(svgBlob);
  16158. };
  16159. watchEffect(() => {
  16160. if (props2.image) {
  16161. makeImageToBase64(props2.image);
  16162. }
  16163. });
  16164. watch(() => [imageBase64.value, props2.content, props2.textColor, props2.height, props2.width, props2.rotate, props2.gapX, props2.gapY], () => {
  16165. nextTick(() => {
  16166. if (svgElRef.value) {
  16167. if (watermarkUrl.value) {
  16168. URL.revokeObjectURL(watermarkUrl.value);
  16169. }
  16170. watermarkUrl.value = makeSvgToBlobUrl(svgElRef.value.innerHTML);
  16171. }
  16172. });
  16173. }, {
  16174. immediate: true
  16175. });
  16176. onUnmounted(() => {
  16177. if (watermarkUrl.value) {
  16178. URL.revokeObjectURL(watermarkUrl.value);
  16179. }
  16180. });
  16181. return () => {
  16182. const style = extend({
  16183. backgroundImage: `url(${watermarkUrl.value})`
  16184. }, getZIndexStyle(props2.zIndex));
  16185. return createVNode("div", {
  16186. "class": bem({
  16187. full: props2.fullPage
  16188. }),
  16189. "style": style
  16190. }, [createVNode("div", {
  16191. "class": bem("wrapper"),
  16192. "ref": svgElRef
  16193. }, [renderWatermark()])]);
  16194. };
  16195. }
  16196. });
  16197. const Watermark = withInstall(stdin_default$4);
  16198. class ReactiveListener {
  16199. constructor({
  16200. el,
  16201. src,
  16202. error,
  16203. loading,
  16204. bindType,
  16205. $parent,
  16206. options,
  16207. cors,
  16208. elRenderer,
  16209. imageCache
  16210. }) {
  16211. this.el = el;
  16212. this.src = src;
  16213. this.error = error;
  16214. this.loading = loading;
  16215. this.bindType = bindType;
  16216. this.attempt = 0;
  16217. this.cors = cors;
  16218. this.naturalHeight = 0;
  16219. this.naturalWidth = 0;
  16220. this.options = options;
  16221. this.$parent = $parent;
  16222. this.elRenderer = elRenderer;
  16223. this.imageCache = imageCache;
  16224. this.performanceData = {
  16225. loadStart: 0,
  16226. loadEnd: 0
  16227. };
  16228. this.filter();
  16229. this.initState();
  16230. this.render("loading", false);
  16231. }
  16232. /*
  16233. * init listener state
  16234. * @return
  16235. */
  16236. initState() {
  16237. if ("dataset" in this.el) {
  16238. this.el.dataset.src = this.src;
  16239. } else {
  16240. this.el.setAttribute("data-src", this.src);
  16241. }
  16242. this.state = {
  16243. loading: false,
  16244. error: false,
  16245. loaded: false,
  16246. rendered: false
  16247. };
  16248. }
  16249. /*
  16250. * record performance
  16251. * @return
  16252. */
  16253. record(event) {
  16254. this.performanceData[event] = Date.now();
  16255. }
  16256. /*
  16257. * update image listener data
  16258. * @param {String} image uri
  16259. * @param {String} loading image uri
  16260. * @param {String} error image uri
  16261. * @return
  16262. */
  16263. update({ src, loading, error }) {
  16264. const oldSrc = this.src;
  16265. this.src = src;
  16266. this.loading = loading;
  16267. this.error = error;
  16268. this.filter();
  16269. if (oldSrc !== this.src) {
  16270. this.attempt = 0;
  16271. this.initState();
  16272. }
  16273. }
  16274. /*
  16275. * check el is in view
  16276. * @return {Boolean} el is in view
  16277. */
  16278. checkInView() {
  16279. const rect = useRect(this.el);
  16280. return rect.top < window.innerHeight * this.options.preLoad && rect.bottom > this.options.preLoadTop && rect.left < window.innerWidth * this.options.preLoad && rect.right > 0;
  16281. }
  16282. /*
  16283. * listener filter
  16284. */
  16285. filter() {
  16286. Object.keys(this.options.filter).forEach((key) => {
  16287. this.options.filter[key](this, this.options);
  16288. });
  16289. }
  16290. /*
  16291. * render loading first
  16292. * @params cb:Function
  16293. * @return
  16294. */
  16295. renderLoading(cb) {
  16296. this.state.loading = true;
  16297. loadImageAsync(
  16298. {
  16299. src: this.loading,
  16300. cors: this.cors
  16301. },
  16302. () => {
  16303. this.render("loading", false);
  16304. this.state.loading = false;
  16305. cb();
  16306. },
  16307. () => {
  16308. cb();
  16309. this.state.loading = false;
  16310. if (process.env.NODE_ENV !== "production" && !this.options.silent)
  16311. console.warn(
  16312. `[@vant/lazyload] load failed with loading image(${this.loading})`
  16313. );
  16314. }
  16315. );
  16316. }
  16317. /*
  16318. * try load image and render it
  16319. * @return
  16320. */
  16321. load(onFinish = noop) {
  16322. if (this.attempt > this.options.attempt - 1 && this.state.error) {
  16323. if (process.env.NODE_ENV !== "production" && !this.options.silent) {
  16324. console.log(
  16325. `[@vant/lazyload] ${this.src} tried too more than ${this.options.attempt} times`
  16326. );
  16327. }
  16328. onFinish();
  16329. return;
  16330. }
  16331. if (this.state.rendered && this.state.loaded) return;
  16332. if (this.imageCache.has(this.src)) {
  16333. this.state.loaded = true;
  16334. this.render("loaded", true);
  16335. this.state.rendered = true;
  16336. return onFinish();
  16337. }
  16338. this.renderLoading(() => {
  16339. var _a, _b;
  16340. this.attempt++;
  16341. (_b = (_a = this.options.adapter).beforeLoad) == null ? void 0 : _b.call(_a, this, this.options);
  16342. this.record("loadStart");
  16343. loadImageAsync(
  16344. {
  16345. src: this.src,
  16346. cors: this.cors
  16347. },
  16348. (data) => {
  16349. this.naturalHeight = data.naturalHeight;
  16350. this.naturalWidth = data.naturalWidth;
  16351. this.state.loaded = true;
  16352. this.state.error = false;
  16353. this.record("loadEnd");
  16354. this.render("loaded", false);
  16355. this.state.rendered = true;
  16356. this.imageCache.add(this.src);
  16357. onFinish();
  16358. },
  16359. (err) => {
  16360. !this.options.silent && console.error(err);
  16361. this.state.error = true;
  16362. this.state.loaded = false;
  16363. this.render("error", false);
  16364. }
  16365. );
  16366. });
  16367. }
  16368. /*
  16369. * render image
  16370. * @param {String} state to render // ['loading', 'src', 'error']
  16371. * @param {String} is form cache
  16372. * @return
  16373. */
  16374. render(state, cache) {
  16375. this.elRenderer(this, state, cache);
  16376. }
  16377. /*
  16378. * output performance data
  16379. * @return {Object} performance data
  16380. */
  16381. performance() {
  16382. let state = "loading";
  16383. let time = 0;
  16384. if (this.state.loaded) {
  16385. state = "loaded";
  16386. time = (this.performanceData.loadEnd - this.performanceData.loadStart) / 1e3;
  16387. }
  16388. if (this.state.error) state = "error";
  16389. return {
  16390. src: this.src,
  16391. state,
  16392. time
  16393. };
  16394. }
  16395. /*
  16396. * $destroy
  16397. * @return
  16398. */
  16399. $destroy() {
  16400. this.el = null;
  16401. this.src = null;
  16402. this.error = null;
  16403. this.loading = null;
  16404. this.bindType = null;
  16405. this.attempt = 0;
  16406. }
  16407. }
  16408. const DEFAULT_URL = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
  16409. const DEFAULT_EVENTS = [
  16410. "scroll",
  16411. "wheel",
  16412. "mousewheel",
  16413. "resize",
  16414. "animationend",
  16415. "transitionend",
  16416. "touchmove"
  16417. ];
  16418. const DEFAULT_OBSERVER_OPTIONS = {
  16419. rootMargin: "0px",
  16420. threshold: 0
  16421. };
  16422. function stdin_default$3() {
  16423. return class Lazy {
  16424. constructor({
  16425. preLoad,
  16426. error,
  16427. throttleWait,
  16428. preLoadTop,
  16429. dispatchEvent,
  16430. loading,
  16431. attempt,
  16432. silent = true,
  16433. scale,
  16434. listenEvents,
  16435. filter,
  16436. adapter,
  16437. observer,
  16438. observerOptions
  16439. }) {
  16440. this.mode = modeType.event;
  16441. this.listeners = [];
  16442. this.targetIndex = 0;
  16443. this.targets = [];
  16444. this.options = {
  16445. silent,
  16446. dispatchEvent: !!dispatchEvent,
  16447. throttleWait: throttleWait || 200,
  16448. preLoad: preLoad || 1.3,
  16449. preLoadTop: preLoadTop || 0,
  16450. error: error || DEFAULT_URL,
  16451. loading: loading || DEFAULT_URL,
  16452. attempt: attempt || 3,
  16453. scale: scale || getDPR(scale),
  16454. ListenEvents: listenEvents || DEFAULT_EVENTS,
  16455. supportWebp: supportWebp(),
  16456. filter: filter || {},
  16457. adapter: adapter || {},
  16458. observer: !!observer,
  16459. observerOptions: observerOptions || DEFAULT_OBSERVER_OPTIONS
  16460. };
  16461. this.initEvent();
  16462. this.imageCache = new ImageCache({ max: 200 });
  16463. this.lazyLoadHandler = throttle(
  16464. this.lazyLoadHandler.bind(this),
  16465. this.options.throttleWait
  16466. );
  16467. this.setMode(this.options.observer ? modeType.observer : modeType.event);
  16468. }
  16469. /**
  16470. * update config
  16471. * @param {Object} config params
  16472. * @return
  16473. */
  16474. config(options = {}) {
  16475. Object.assign(this.options, options);
  16476. }
  16477. /**
  16478. * output listener's load performance
  16479. * @return {Array}
  16480. */
  16481. performance() {
  16482. return this.listeners.map((item) => item.performance());
  16483. }
  16484. /*
  16485. * add lazy component to queue
  16486. * @param {Vue} vm lazy component instance
  16487. * @return
  16488. */
  16489. addLazyBox(vm) {
  16490. this.listeners.push(vm);
  16491. if (inBrowser$1) {
  16492. this.addListenerTarget(window);
  16493. this.observer && this.observer.observe(vm.el);
  16494. if (vm.$el && vm.$el.parentNode) {
  16495. this.addListenerTarget(vm.$el.parentNode);
  16496. }
  16497. }
  16498. }
  16499. /*
  16500. * add image listener to queue
  16501. * @param {DOM} el
  16502. * @param {object} binding vue directive binding
  16503. * @param {vnode} vnode vue directive vnode
  16504. * @return
  16505. */
  16506. add(el, binding, vnode) {
  16507. if (this.listeners.some((item) => item.el === el)) {
  16508. this.update(el, binding);
  16509. return nextTick(this.lazyLoadHandler);
  16510. }
  16511. const value = this.valueFormatter(binding.value);
  16512. let { src } = value;
  16513. nextTick(() => {
  16514. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  16515. this.observer && this.observer.observe(el);
  16516. const container = Object.keys(binding.modifiers)[0];
  16517. let $parent;
  16518. if (container) {
  16519. $parent = vnode.context.$refs[container];
  16520. $parent = $parent ? $parent.$el || $parent : document.getElementById(container);
  16521. }
  16522. if (!$parent) {
  16523. $parent = getScrollParent(el);
  16524. }
  16525. const newListener = new ReactiveListener({
  16526. bindType: binding.arg,
  16527. $parent,
  16528. el,
  16529. src,
  16530. loading: value.loading,
  16531. error: value.error,
  16532. cors: value.cors,
  16533. elRenderer: this.elRenderer.bind(this),
  16534. options: this.options,
  16535. imageCache: this.imageCache
  16536. });
  16537. this.listeners.push(newListener);
  16538. if (inBrowser$1) {
  16539. this.addListenerTarget(window);
  16540. this.addListenerTarget($parent);
  16541. }
  16542. this.lazyLoadHandler();
  16543. nextTick(() => this.lazyLoadHandler());
  16544. });
  16545. }
  16546. /**
  16547. * update image src
  16548. * @param {DOM} el
  16549. * @param {object} vue directive binding
  16550. * @return
  16551. */
  16552. update(el, binding, vnode) {
  16553. const value = this.valueFormatter(binding.value);
  16554. let { src } = value;
  16555. src = getBestSelectionFromSrcset(el, this.options.scale) || src;
  16556. const exist = this.listeners.find((item) => item.el === el);
  16557. if (!exist) {
  16558. this.add(el, binding, vnode);
  16559. } else {
  16560. exist.update({
  16561. src,
  16562. error: value.error,
  16563. loading: value.loading
  16564. });
  16565. }
  16566. if (this.observer) {
  16567. this.observer.unobserve(el);
  16568. this.observer.observe(el);
  16569. }
  16570. this.lazyLoadHandler();
  16571. nextTick(() => this.lazyLoadHandler());
  16572. }
  16573. /**
  16574. * remove listener form list
  16575. * @param {DOM} el
  16576. * @return
  16577. */
  16578. remove(el) {
  16579. if (!el) return;
  16580. this.observer && this.observer.unobserve(el);
  16581. const existItem = this.listeners.find((item) => item.el === el);
  16582. if (existItem) {
  16583. this.removeListenerTarget(existItem.$parent);
  16584. this.removeListenerTarget(window);
  16585. remove(this.listeners, existItem);
  16586. existItem.$destroy();
  16587. }
  16588. }
  16589. /*
  16590. * remove lazy components form list
  16591. * @param {Vue} vm Vue instance
  16592. * @return
  16593. */
  16594. removeComponent(vm) {
  16595. if (!vm) return;
  16596. remove(this.listeners, vm);
  16597. this.observer && this.observer.unobserve(vm.el);
  16598. if (vm.$parent && vm.$el.parentNode) {
  16599. this.removeListenerTarget(vm.$el.parentNode);
  16600. }
  16601. this.removeListenerTarget(window);
  16602. }
  16603. setMode(mode) {
  16604. if (!hasIntersectionObserver && mode === modeType.observer) {
  16605. mode = modeType.event;
  16606. }
  16607. this.mode = mode;
  16608. if (mode === modeType.event) {
  16609. if (this.observer) {
  16610. this.listeners.forEach((listener) => {
  16611. this.observer.unobserve(listener.el);
  16612. });
  16613. this.observer = null;
  16614. }
  16615. this.targets.forEach((target) => {
  16616. this.initListen(target.el, true);
  16617. });
  16618. } else {
  16619. this.targets.forEach((target) => {
  16620. this.initListen(target.el, false);
  16621. });
  16622. this.initIntersectionObserver();
  16623. }
  16624. }
  16625. /*
  16626. *** Private functions ***
  16627. */
  16628. /*
  16629. * add listener target
  16630. * @param {DOM} el listener target
  16631. * @return
  16632. */
  16633. addListenerTarget(el) {
  16634. if (!el) return;
  16635. let target = this.targets.find((target2) => target2.el === el);
  16636. if (!target) {
  16637. target = {
  16638. el,
  16639. id: ++this.targetIndex,
  16640. childrenCount: 1,
  16641. listened: true
  16642. };
  16643. this.mode === modeType.event && this.initListen(target.el, true);
  16644. this.targets.push(target);
  16645. } else {
  16646. target.childrenCount++;
  16647. }
  16648. return this.targetIndex;
  16649. }
  16650. /*
  16651. * remove listener target or reduce target childrenCount
  16652. * @param {DOM} el or window
  16653. * @return
  16654. */
  16655. removeListenerTarget(el) {
  16656. this.targets.forEach((target, index) => {
  16657. if (target.el === el) {
  16658. target.childrenCount--;
  16659. if (!target.childrenCount) {
  16660. this.initListen(target.el, false);
  16661. this.targets.splice(index, 1);
  16662. target = null;
  16663. }
  16664. }
  16665. });
  16666. }
  16667. /*
  16668. * add or remove eventlistener
  16669. * @param {DOM} el DOM or Window
  16670. * @param {boolean} start flag
  16671. * @return
  16672. */
  16673. initListen(el, start) {
  16674. this.options.ListenEvents.forEach(
  16675. (evt) => (start ? on : off)(el, evt, this.lazyLoadHandler)
  16676. );
  16677. }
  16678. initEvent() {
  16679. this.Event = {
  16680. listeners: {
  16681. loading: [],
  16682. loaded: [],
  16683. error: []
  16684. }
  16685. };
  16686. this.$on = (event, func) => {
  16687. if (!this.Event.listeners[event]) this.Event.listeners[event] = [];
  16688. this.Event.listeners[event].push(func);
  16689. };
  16690. this.$once = (event, func) => {
  16691. const on2 = (...args) => {
  16692. this.$off(event, on2);
  16693. func.apply(this, args);
  16694. };
  16695. this.$on(event, on2);
  16696. };
  16697. this.$off = (event, func) => {
  16698. if (!func) {
  16699. if (!this.Event.listeners[event]) return;
  16700. this.Event.listeners[event].length = 0;
  16701. return;
  16702. }
  16703. remove(this.Event.listeners[event], func);
  16704. };
  16705. this.$emit = (event, context, inCache) => {
  16706. if (!this.Event.listeners[event]) return;
  16707. this.Event.listeners[event].forEach((func) => func(context, inCache));
  16708. };
  16709. }
  16710. /**
  16711. * find nodes which in viewport and trigger load
  16712. * @return
  16713. */
  16714. lazyLoadHandler() {
  16715. const freeList = [];
  16716. this.listeners.forEach((listener) => {
  16717. if (!listener.el || !listener.el.parentNode) {
  16718. freeList.push(listener);
  16719. }
  16720. const catIn = listener.checkInView();
  16721. if (!catIn) return;
  16722. listener.load();
  16723. });
  16724. freeList.forEach((item) => {
  16725. remove(this.listeners, item);
  16726. item.$destroy();
  16727. });
  16728. }
  16729. /**
  16730. * init IntersectionObserver
  16731. * set mode to observer
  16732. * @return
  16733. */
  16734. initIntersectionObserver() {
  16735. if (!hasIntersectionObserver) {
  16736. return;
  16737. }
  16738. this.observer = new IntersectionObserver(
  16739. this.observerHandler.bind(this),
  16740. this.options.observerOptions
  16741. );
  16742. if (this.listeners.length) {
  16743. this.listeners.forEach((listener) => {
  16744. this.observer.observe(listener.el);
  16745. });
  16746. }
  16747. }
  16748. /**
  16749. * init IntersectionObserver
  16750. * @return
  16751. */
  16752. observerHandler(entries) {
  16753. entries.forEach((entry) => {
  16754. if (entry.isIntersecting) {
  16755. this.listeners.forEach((listener) => {
  16756. if (listener.el === entry.target) {
  16757. if (listener.state.loaded)
  16758. return this.observer.unobserve(listener.el);
  16759. listener.load();
  16760. }
  16761. });
  16762. }
  16763. });
  16764. }
  16765. /**
  16766. * set element attribute with image'url and state
  16767. * @param {object} lazyload listener object
  16768. * @param {string} state will be rendered
  16769. * @param {bool} inCache is rendered from cache
  16770. * @return
  16771. */
  16772. elRenderer(listener, state, cache) {
  16773. if (!listener.el) return;
  16774. const { el, bindType } = listener;
  16775. let src;
  16776. switch (state) {
  16777. case "loading":
  16778. src = listener.loading;
  16779. break;
  16780. case "error":
  16781. src = listener.error;
  16782. break;
  16783. default:
  16784. ({ src } = listener);
  16785. break;
  16786. }
  16787. if (bindType) {
  16788. el.style[bindType] = 'url("' + src + '")';
  16789. } else if (el.getAttribute("src") !== src) {
  16790. el.setAttribute("src", src);
  16791. }
  16792. el.setAttribute("lazy", state);
  16793. this.$emit(state, listener, cache);
  16794. this.options.adapter[state] && this.options.adapter[state](listener, this.options);
  16795. if (this.options.dispatchEvent) {
  16796. const event = new CustomEvent(state, {
  16797. detail: listener
  16798. });
  16799. el.dispatchEvent(event);
  16800. }
  16801. }
  16802. /**
  16803. * generate loading loaded error image url
  16804. * @param {string} image's src
  16805. * @return {object} image's loading, loaded, error url
  16806. */
  16807. valueFormatter(value) {
  16808. let src = value;
  16809. let { loading, error } = this.options;
  16810. if (isObject(value)) {
  16811. if (process.env.NODE_ENV !== "production" && !value.src && !this.options.silent) {
  16812. console.error("[@vant/lazyload] miss src with " + value);
  16813. }
  16814. ({ src } = value);
  16815. loading = value.loading || this.options.loading;
  16816. error = value.error || this.options.error;
  16817. }
  16818. return {
  16819. src,
  16820. loading,
  16821. error
  16822. };
  16823. }
  16824. };
  16825. }
  16826. var stdin_default$2 = (lazy) => ({
  16827. props: {
  16828. tag: {
  16829. type: String,
  16830. default: "div"
  16831. }
  16832. },
  16833. emits: ["show"],
  16834. render() {
  16835. return h(
  16836. this.tag,
  16837. this.show && this.$slots.default ? this.$slots.default() : null
  16838. );
  16839. },
  16840. data() {
  16841. return {
  16842. el: null,
  16843. state: {
  16844. loaded: false
  16845. },
  16846. show: false
  16847. };
  16848. },
  16849. mounted() {
  16850. this.el = this.$el;
  16851. lazy.addLazyBox(this);
  16852. lazy.lazyLoadHandler();
  16853. },
  16854. beforeUnmount() {
  16855. lazy.removeComponent(this);
  16856. },
  16857. methods: {
  16858. checkInView() {
  16859. const rect = useRect(this.$el);
  16860. return inBrowser$1 && rect.top < window.innerHeight * lazy.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazy.options.preLoad && rect.right > 0;
  16861. },
  16862. load() {
  16863. this.show = true;
  16864. this.state.loaded = true;
  16865. this.$emit("show", this);
  16866. },
  16867. destroy() {
  16868. return this.$destroy;
  16869. }
  16870. }
  16871. });
  16872. const defaultOptions = {
  16873. selector: "img"
  16874. };
  16875. class LazyContainer {
  16876. constructor({ el, binding, vnode, lazy }) {
  16877. this.el = null;
  16878. this.vnode = vnode;
  16879. this.binding = binding;
  16880. this.options = {};
  16881. this.lazy = lazy;
  16882. this.queue = [];
  16883. this.update({ el, binding });
  16884. }
  16885. update({ el, binding }) {
  16886. this.el = el;
  16887. this.options = Object.assign({}, defaultOptions, binding.value);
  16888. const imgs = this.getImgs();
  16889. imgs.forEach((el2) => {
  16890. this.lazy.add(
  16891. el2,
  16892. Object.assign({}, this.binding, {
  16893. value: {
  16894. src: "dataset" in el2 ? el2.dataset.src : el2.getAttribute("data-src"),
  16895. error: ("dataset" in el2 ? el2.dataset.error : el2.getAttribute("data-error")) || this.options.error,
  16896. loading: ("dataset" in el2 ? el2.dataset.loading : el2.getAttribute("data-loading")) || this.options.loading
  16897. }
  16898. }),
  16899. this.vnode
  16900. );
  16901. });
  16902. }
  16903. getImgs() {
  16904. return Array.from(this.el.querySelectorAll(this.options.selector));
  16905. }
  16906. clear() {
  16907. const imgs = this.getImgs();
  16908. imgs.forEach((el) => this.lazy.remove(el));
  16909. this.vnode = null;
  16910. this.binding = null;
  16911. this.lazy = null;
  16912. }
  16913. }
  16914. class LazyContainerManager {
  16915. constructor({ lazy }) {
  16916. this.lazy = lazy;
  16917. this.queue = [];
  16918. }
  16919. bind(el, binding, vnode) {
  16920. const container = new LazyContainer({
  16921. el,
  16922. binding,
  16923. vnode,
  16924. lazy: this.lazy
  16925. });
  16926. this.queue.push(container);
  16927. }
  16928. update(el, binding, vnode) {
  16929. const container = this.queue.find((item) => item.el === el);
  16930. if (!container) return;
  16931. container.update({ el, binding, vnode });
  16932. }
  16933. unbind(el) {
  16934. const container = this.queue.find((item) => item.el === el);
  16935. if (!container) return;
  16936. container.clear();
  16937. remove(this.queue, container);
  16938. }
  16939. }
  16940. var stdin_default$1 = (lazyManager) => ({
  16941. props: {
  16942. src: [String, Object],
  16943. tag: {
  16944. type: String,
  16945. default: "img"
  16946. }
  16947. },
  16948. render() {
  16949. var _a, _b;
  16950. return h(
  16951. this.tag,
  16952. {
  16953. src: this.renderSrc
  16954. },
  16955. (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)
  16956. );
  16957. },
  16958. data() {
  16959. return {
  16960. el: null,
  16961. options: {
  16962. src: "",
  16963. error: "",
  16964. loading: "",
  16965. attempt: lazyManager.options.attempt
  16966. },
  16967. state: {
  16968. loaded: false,
  16969. error: false,
  16970. attempt: 0
  16971. },
  16972. renderSrc: ""
  16973. };
  16974. },
  16975. watch: {
  16976. src() {
  16977. this.init();
  16978. lazyManager.addLazyBox(this);
  16979. lazyManager.lazyLoadHandler();
  16980. }
  16981. },
  16982. created() {
  16983. this.init();
  16984. },
  16985. mounted() {
  16986. this.el = this.$el;
  16987. lazyManager.addLazyBox(this);
  16988. lazyManager.lazyLoadHandler();
  16989. },
  16990. beforeUnmount() {
  16991. lazyManager.removeComponent(this);
  16992. },
  16993. methods: {
  16994. init() {
  16995. const { src, loading, error } = lazyManager.valueFormatter(this.src);
  16996. this.state.loaded = false;
  16997. this.options.src = src;
  16998. this.options.error = error;
  16999. this.options.loading = loading;
  17000. this.renderSrc = this.options.loading;
  17001. },
  17002. checkInView() {
  17003. const rect = useRect(this.$el);
  17004. return rect.top < window.innerHeight * lazyManager.options.preLoad && rect.bottom > 0 && rect.left < window.innerWidth * lazyManager.options.preLoad && rect.right > 0;
  17005. },
  17006. load(onFinish = noop) {
  17007. if (this.state.attempt > this.options.attempt - 1 && this.state.error) {
  17008. if (process.env.NODE_ENV !== "production" && !lazyManager.options.silent) {
  17009. console.log(
  17010. `[@vant/lazyload] ${this.options.src} tried too more than ${this.options.attempt} times`
  17011. );
  17012. }
  17013. onFinish();
  17014. return;
  17015. }
  17016. const { src } = this.options;
  17017. loadImageAsync(
  17018. { src },
  17019. ({ src: src2 }) => {
  17020. this.renderSrc = src2;
  17021. this.state.loaded = true;
  17022. },
  17023. () => {
  17024. this.state.attempt++;
  17025. this.renderSrc = this.options.error;
  17026. this.state.error = true;
  17027. }
  17028. );
  17029. }
  17030. }
  17031. });
  17032. const Lazyload = {
  17033. /*
  17034. * install function
  17035. * @param {App} app
  17036. * @param {object} options lazyload options
  17037. */
  17038. install(app, options = {}) {
  17039. const LazyClass = stdin_default$3();
  17040. const lazy = new LazyClass(options);
  17041. const lazyContainer = new LazyContainerManager({ lazy });
  17042. app.config.globalProperties.$Lazyload = lazy;
  17043. if (options.lazyComponent) {
  17044. app.component("LazyComponent", stdin_default$2(lazy));
  17045. }
  17046. if (options.lazyImage) {
  17047. app.component("LazyImage", stdin_default$1(lazy));
  17048. }
  17049. app.directive("lazy", {
  17050. beforeMount: lazy.add.bind(lazy),
  17051. updated: lazy.update.bind(lazy),
  17052. unmounted: lazy.remove.bind(lazy)
  17053. });
  17054. app.directive("lazy-container", {
  17055. beforeMount: lazyContainer.bind.bind(lazyContainer),
  17056. updated: lazyContainer.update.bind(lazyContainer),
  17057. unmounted: lazyContainer.unbind.bind(lazyContainer)
  17058. });
  17059. }
  17060. };
  17061. const version = "4.9.9";
  17062. function install(app) {
  17063. const components = [
  17064. ActionBar,
  17065. ActionBarButton,
  17066. ActionBarIcon,
  17067. ActionSheet,
  17068. AddressEdit,
  17069. AddressList,
  17070. Area,
  17071. BackTop,
  17072. Badge,
  17073. Barrage,
  17074. Button,
  17075. Calendar,
  17076. Card,
  17077. Cascader,
  17078. Cell,
  17079. CellGroup,
  17080. Checkbox,
  17081. CheckboxGroup,
  17082. Circle,
  17083. Col,
  17084. Collapse,
  17085. CollapseItem,
  17086. ConfigProvider,
  17087. ContactCard,
  17088. ContactEdit,
  17089. ContactList,
  17090. CountDown,
  17091. Coupon,
  17092. CouponCell,
  17093. CouponList,
  17094. DatePicker,
  17095. Dialog,
  17096. Divider,
  17097. DropdownItem,
  17098. DropdownMenu,
  17099. Empty,
  17100. Field,
  17101. FloatingBubble,
  17102. FloatingPanel,
  17103. Form,
  17104. Grid,
  17105. GridItem,
  17106. Highlight,
  17107. Icon,
  17108. Image$1,
  17109. ImagePreview,
  17110. IndexAnchor,
  17111. IndexBar,
  17112. List,
  17113. Loading,
  17114. Locale,
  17115. NavBar,
  17116. NoticeBar,
  17117. Notify,
  17118. NumberKeyboard,
  17119. Overlay,
  17120. Pagination,
  17121. PasswordInput,
  17122. Picker,
  17123. PickerGroup,
  17124. Popover,
  17125. Popup,
  17126. Progress,
  17127. PullRefresh,
  17128. Radio,
  17129. RadioGroup,
  17130. Rate,
  17131. RollingText,
  17132. Row,
  17133. Search,
  17134. ShareSheet,
  17135. Sidebar,
  17136. SidebarItem,
  17137. Signature,
  17138. Skeleton,
  17139. SkeletonAvatar,
  17140. SkeletonImage,
  17141. SkeletonParagraph,
  17142. SkeletonTitle,
  17143. Slider,
  17144. Space,
  17145. Step,
  17146. Stepper,
  17147. Steps,
  17148. Sticky,
  17149. SubmitBar,
  17150. Swipe,
  17151. SwipeCell,
  17152. SwipeItem,
  17153. Switch,
  17154. Tab,
  17155. Tabbar,
  17156. TabbarItem,
  17157. Tabs,
  17158. Tag,
  17159. TextEllipsis,
  17160. TimePicker,
  17161. Toast,
  17162. TreeSelect,
  17163. Uploader,
  17164. Watermark
  17165. ];
  17166. components.forEach((item) => {
  17167. if (item.install) {
  17168. app.use(item);
  17169. } else if (item.name) {
  17170. app.component(item.name, item);
  17171. }
  17172. });
  17173. }
  17174. var stdin_default = {
  17175. install,
  17176. version
  17177. };
  17178. export {
  17179. ActionBar,
  17180. ActionBarButton,
  17181. ActionBarIcon,
  17182. ActionSheet,
  17183. AddressEdit,
  17184. AddressList,
  17185. Area,
  17186. BackTop,
  17187. Badge,
  17188. Barrage,
  17189. Button,
  17190. Calendar,
  17191. Card,
  17192. Cascader,
  17193. Cell,
  17194. CellGroup,
  17195. Checkbox,
  17196. CheckboxGroup,
  17197. Circle,
  17198. Col,
  17199. Collapse,
  17200. CollapseItem,
  17201. ConfigProvider,
  17202. ContactCard,
  17203. ContactEdit,
  17204. ContactList,
  17205. CountDown,
  17206. Coupon,
  17207. CouponCell,
  17208. CouponList,
  17209. DEFAULT_ROW_WIDTH,
  17210. DatePicker,
  17211. Dialog,
  17212. Divider,
  17213. DropdownItem,
  17214. DropdownMenu,
  17215. Empty,
  17216. Field,
  17217. FloatingBubble,
  17218. FloatingPanel,
  17219. Form,
  17220. Grid,
  17221. GridItem,
  17222. Highlight,
  17223. Icon,
  17224. Image$1 as Image,
  17225. ImagePreview,
  17226. IndexAnchor,
  17227. IndexBar,
  17228. Lazyload,
  17229. List,
  17230. Loading,
  17231. Locale,
  17232. NavBar,
  17233. NoticeBar,
  17234. Notify,
  17235. NumberKeyboard,
  17236. Overlay,
  17237. Pagination,
  17238. PasswordInput,
  17239. Picker,
  17240. PickerGroup,
  17241. Popover,
  17242. Popup,
  17243. Progress,
  17244. PullRefresh,
  17245. Radio,
  17246. RadioGroup,
  17247. Rate,
  17248. RollingText,
  17249. Row,
  17250. Search,
  17251. ShareSheet,
  17252. Sidebar,
  17253. SidebarItem,
  17254. Signature,
  17255. Skeleton,
  17256. SkeletonAvatar,
  17257. SkeletonImage,
  17258. SkeletonParagraph,
  17259. SkeletonTitle,
  17260. Slider,
  17261. Space,
  17262. Step,
  17263. Stepper,
  17264. Steps,
  17265. Sticky,
  17266. SubmitBar,
  17267. Swipe,
  17268. SwipeCell,
  17269. SwipeItem,
  17270. Switch,
  17271. Tab,
  17272. Tabbar,
  17273. TabbarItem,
  17274. Tabs,
  17275. Tag,
  17276. TextEllipsis,
  17277. TimePicker,
  17278. Toast,
  17279. TreeSelect,
  17280. Uploader,
  17281. Watermark,
  17282. actionBarButtonProps,
  17283. actionBarIconProps,
  17284. actionBarProps,
  17285. actionSheetProps,
  17286. addressEditProps,
  17287. addressListProps,
  17288. allowMultipleToast,
  17289. areaProps,
  17290. backTopProps,
  17291. badgeProps,
  17292. barrageProps,
  17293. buttonProps,
  17294. calendarProps,
  17295. cardProps,
  17296. cascaderProps,
  17297. cellGroupProps,
  17298. cellProps,
  17299. checkboxGroupProps,
  17300. checkboxProps,
  17301. circleProps,
  17302. closeDialog,
  17303. closeNotify,
  17304. closeToast,
  17305. colProps,
  17306. collapseItemProps,
  17307. collapseProps,
  17308. configProviderProps,
  17309. contactCardProps,
  17310. contactEditProps,
  17311. contactListProps,
  17312. countDownProps,
  17313. couponCellProps,
  17314. couponListProps,
  17315. datePickerProps,
  17316. stdin_default as default,
  17317. dialogProps,
  17318. dividerProps,
  17319. dropdownItemProps,
  17320. dropdownMenuProps,
  17321. emptyProps,
  17322. fieldProps,
  17323. floatingBubbleProps,
  17324. floatingPanelProps,
  17325. formProps,
  17326. gridItemProps,
  17327. gridProps,
  17328. highlightProps,
  17329. iconProps,
  17330. imagePreviewProps,
  17331. imageProps,
  17332. indexAnchorProps,
  17333. indexBarProps,
  17334. install,
  17335. listProps,
  17336. loadingProps,
  17337. navBarProps,
  17338. noticeBarProps,
  17339. notifyProps,
  17340. numberKeyboardProps,
  17341. overlayProps,
  17342. paginationProps,
  17343. passwordInputProps,
  17344. pickerGroupProps,
  17345. pickerProps,
  17346. popoverProps,
  17347. popupProps$2 as popupProps,
  17348. progressProps,
  17349. pullRefreshProps,
  17350. radioGroupProps,
  17351. radioProps,
  17352. rateProps,
  17353. resetDialogDefaultOptions,
  17354. resetNotifyDefaultOptions,
  17355. resetToastDefaultOptions,
  17356. rollingTextProps,
  17357. rowProps,
  17358. searchProps,
  17359. setDialogDefaultOptions,
  17360. setNotifyDefaultOptions,
  17361. setToastDefaultOptions,
  17362. shareSheetProps,
  17363. showConfirmDialog,
  17364. showDialog,
  17365. showFailToast,
  17366. showImagePreview,
  17367. showLoadingToast,
  17368. showNotify,
  17369. showSuccessToast,
  17370. showToast,
  17371. sidebarItemProps,
  17372. sidebarProps,
  17373. skeletonAvatarProps,
  17374. skeletonImageProps,
  17375. skeletonParagraphProps,
  17376. skeletonProps,
  17377. skeletonTitleProps,
  17378. sliderProps,
  17379. spaceProps,
  17380. stepperProps,
  17381. stepsProps,
  17382. stickyProps,
  17383. submitBarProps,
  17384. swipeCellProps,
  17385. swipeProps,
  17386. switchProps,
  17387. tabProps,
  17388. tabbarItemProps,
  17389. tabbarProps,
  17390. tabsProps,
  17391. tagProps,
  17392. textEllipsisProps,
  17393. timePickerProps,
  17394. toastProps,
  17395. treeSelectProps,
  17396. uploaderProps,
  17397. useCurrentLang,
  17398. version,
  17399. watermarkProps
  17400. };